diff --git a/README.md b/README.md index bad8510..8efc21a 100644 --- a/README.md +++ b/README.md @@ -60,18 +60,18 @@ The components can be used directly in the browser, without your own build syste [example.html](example.html) is a clustered table example which uses the latest package version from npm via https://esm.sh/. [example-molviewer.html](example-molviewer.html) is a simple molecule viewer example. -### Offline +### Offline bundle The table components are used by the caprieval module of haddock3 to generate report.html. Haddock3 can be used [offline](https://www.bonvinlab.org/haddock3/modules/general_module_params.html#offline), which means after installation the running of haddock3 will be isolated from the Internet. -To use the table components offline, you can build an offline version of the components with +To use the table components offline, you can build an offline bundle of the components with ```bash # Installs dependencies pnpm install -# Create dist/index.css and dist/report.offline.js, +# Create dist/index.css and dist/report.bundle.js, # which contains the table components and all of its dependencies pnpm build ``` @@ -79,25 +79,3 @@ pnpm build See [example-offline.html](example-offline.html) for an example of how to use the offline version. To prevent CORS issues, the html, css and js files should be served from the same http server like with `python3 -m http.server` and visit http://localhost:8000/example-offline.html. - -### Embedded - -Similar to offline, the js and css can be embedded into a HTML file instead of importing js and css files. - -To genererate an embedded example, run - -```bash -# Installs dependencies -pnpm install -# Creates dist/index.css -pnpm build:css -# Creates dist/report.embedded.js, -# Which defines the `haddock3ui` global variable that contains the table components -pnon build:embedded -# Creates example-embedded.html -node generate-embedded-example.mjs -# Start a web server -python3 -m http.server -``` - -Then open `http://localhost:8000/example-embedded.html` in your browser. diff --git a/build.mjs b/build.mjs index fe5c5b0..c2e8aad 100644 --- a/build.mjs +++ b/build.mjs @@ -25,7 +25,7 @@ for (const file of await readdir("dist", { recursive: true })) { const jsfn = "./dist/" + file; // Each .js file has a corresponding .d.ts file let types = jsfn.replace(/\.js$/, ".d.ts"); - if (types === "./dist/report.offline.d.ts") { + if (types === "./dist/report.bundle.d.ts") { types = "./dist/report.d.ts"; } packageJson.exports[key] = { diff --git a/example-offline.html b/example-offline.html index 6de5c35..b89c6dd 100644 --- a/example-offline.html +++ b/example-offline.html @@ -97,7 +97,7 @@ } diff --git a/example.html b/example.html index abf8349..e9d1ce1 100644 --- a/example.html +++ b/example.html @@ -97,6 +97,11 @@ diff --git a/generate-embedded-example.mjs b/generate-embedded-example.mjs deleted file mode 100644 index 8e0c274..0000000 --- a/generate-embedded-example.mjs +++ /dev/null @@ -1,120 +0,0 @@ -import { readFile, writeFile } from "node:fs/promises"; - -// Script that creates example-embedded.html file -// By embedding dist/index.css and dist/report.offline.js files -// into the example.html file - -const css = await readFile("dist/index.css", "utf8"); -const js = await readFile("dist/report.embed.js", "utf8"); - -const exampleEmbeddedHtml = ` - - - - - Haddock3 ui components - Embedded clusterTable example - - - -
- - - - - -`; - -await writeFile("example-embedded.html", exampleEmbeddedHtml); diff --git a/package.json b/package.json index b17b3b6..2d1f4de 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,7 @@ "build:js": "tsc --project tsconfig.build.json", "build:package": "node build.mjs && pnpm format package.json", "build:css": "tailwindcss --content './src/**/*.{js,ts,jsx,tsx,mdx}' -i .ladle/index.css -o dist/index.css --minify", - "build:offline": "esbuild --bundle --format=esm --minify src/report.tsx --outfile=dist/report.offline.js", - "build:embed": "esbuild --bundle --format=iife --minify --global-name=haddock3ui src/report.tsx --outfile=dist/report.embed.js", + "build:offline": "esbuild --bundle --format=esm --minify src/report.tsx --outfile=dist/report.bundle.js", "typecheck": "tsc --noEmit", "docs:ladle": "ladle build", "docs:api": "typedoc", @@ -129,16 +128,16 @@ "default": "./dist/molviewer.js" } }, - "./report": { + "./report.bundle": { "import": { "types": "./dist/report.d.ts", - "default": "./dist/report.js" + "default": "./dist/report.bundle.js" } }, - "./report.offline": { + "./report": { "import": { "types": "./dist/report.d.ts", - "default": "./dist/report.offline.js" + "default": "./dist/report.js" } }, "./toggles": {