lhasa-ligand-builder 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,9 +2,14 @@
2
2
 
3
3
  Frontend for Lhasa - Moorhen's ligand builder: a React + WebAssembly version of Layla (Coot's ligand builder).
4
4
 
5
+ LhasaReact can also be used standalone, outside of Moorhen.
6
+
5
7
  ## Installation / embedding
6
8
 
7
- There is an experimental [`lhasa-ligand-builder`](https://www.npmjs.com/package/lhasa-ligand-builder) package.
9
+ There is an npm package available: [`lhasa-ligand-builder`](https://www.npmjs.com/package/lhasa-ligand-builder).
10
+ It makes it easy to embed Lhasa into your own React app!
11
+
12
+ If you're not using React, have a look at `LhasaPlainJS` on [Github](https://github.com/moorhen-coot/LhasaPlainJS) and [npm](https://www.npmjs.com/package/lhasa-ligand-builder-plainjs) - it's a vanilla JavaScript wrapper version of this library.
8
13
 
9
14
  ### Quick start
10
15
 
@@ -65,6 +70,28 @@ Both plugins accept an options object:
65
70
  | `outputPath` | `'lhasa-assets'` | Sub-path in the build output where assets are placed. |
66
71
  | `assets` | All entries | Array of asset names to copy: `'lhasa.js'`, `'lhasa.wasm'`, `'Components-inchikey.ich'`, `'icons'`. |
67
72
 
73
+ ```js
74
+ // vite.config.js — custom output path
75
+ lhasaCopyAssets({
76
+ outputPath: 'static/lhasa',
77
+ // Optional override of defaults - if you know what you are doing
78
+ // assets: ['lhasa.js', 'lhasa.wasm'],
79
+ })
80
+
81
+ // webpack.config.js — custom output path
82
+ new LhasaCopyAssetsPlugin({
83
+ outputPath: 'static/lhasa',
84
+ // Optional override of defaults - if you know what you are doing
85
+ // assets: ['lhasa.js', 'lhasa.wasm'],
86
+ })
87
+ ```
88
+
89
+ Remember to update `assetsBaseUrl` on `LhasaEmbedder` to match your chosen `outputPath`:
90
+
91
+ ```tsx
92
+ <LhasaEmbedder assetsBaseUrl="/static/lhasa/" />
93
+ ```
94
+
68
95
  #### Manual copy (fallback)
69
96
 
70
97
  If you're not using Vite or Webpack, copy the assets from `node_modules/lhasa-ligand-builder/dist/assets/` to your public directory (e.g. `public/lhasa-assets/`).
@@ -97,11 +124,11 @@ import 'lhasa-ligand-builder/style.css'
97
124
  />
98
125
  ```
99
126
 
100
- ## Building from source
127
+ ## Building from source (alternative)
101
128
 
102
- LhasaReact can be used standalone, outside of Moorhen.
129
+ You can also build everything from source yourself, using the `build_wasm.sh` script found in this repo.
103
130
 
104
- Lhasa is part of [Coot](https://github.com/pemsley/coot) and you need to compile the C++ WebAssembly module first.
131
+ Lhasa's C++ sources are a part of [Coot](https://github.com/pemsley/coot) and the C++ WebAssembly module needs to be compiled first.
105
132
 
106
133
  NOTE: All build scripts are Unix scripts. On Windows, you may need WSL.
107
134
 
@@ -113,14 +140,25 @@ NOTE: All build scripts are Unix scripts. On Windows, you may need WSL.
113
140
  * meson
114
141
  * curl, tar, etc.
115
142
 
116
- Clone the [Coot](https://github.com/pemsley/coot) repo and go to `lhasa/`.
143
+ Conveniently, now there is a build script: `build_wasm.sh`.
144
+ It clones the [Coot](https://github.com/pemsley/coot) repo and builds the sources found at `lhasa/` and `layla/`.
117
145
 
118
- The build procedure is very much like [Moorhen](https://github.com/moorhen-coot/Moorhen)'s:
146
+ You can just simply run
147
+ ```bash
148
+ ./build_wasm.sh
149
+ ```
150
+ and it will do everything for you, including downloading and building all C++ dependencies.
151
+ For more options, run:
152
+ ```bash
153
+ ./build_wasm.sh --help
154
+ ```
155
+ By default, the script will output artifacts to `wasm_build/outputs` (This is configurable with environment variables).
119
156
 
120
- * Run `get_sources` (download C++ dependencies)
121
- * Run `initial_build.sh` to build all the necessary dependencies using Emscripten
122
- * Run `build_lhasa.sh` to build the Lhasa WebAssembly module
123
- * Copy `lhasa.js`, `lhasa.worker.js` (if it exists) and `lhasa.wasm` from `Coot/lhasa/lhbuild/` to `LhasaReact/public`
157
+ Then, after the build finishes, you can run:
158
+ ```bash
159
+ ./build_wasm.sh --install
160
+ ```
161
+ in order to copy the freshly generated `lhasa.js` and `lhasa.wasm` to `LhasaReact/public` (and `lhasa.d.ts` to `LhasaReact/src/types.d.ts`)
124
162
 
125
163
  ### Running LhasaReact locally
126
164
 
@@ -128,7 +166,10 @@ After building and copying the WebAssembly module:
128
166
 
129
167
  ```bash
130
168
  npm install
169
+ # and then
131
170
  npm run dev
171
+ # or, alternatively:
172
+ npx vite serve
132
173
  ```
133
174
 
134
175
  ### Building the library
@@ -138,3 +179,11 @@ npm run build:lib
138
179
  ```
139
180
 
140
181
  This produces `dist/` with the ESM bundle, CSS, type declarations, and all WASM/icon/data assets.
182
+
183
+ ### Building the standalone demo app
184
+
185
+ ```bash
186
+ npm run build
187
+ # or, if you want more options passed to vite underneath:
188
+ npm run build -- --outDir dist_dir/ --base /lhasa
189
+ ```
@@ -0,0 +1,15 @@
1
+ # bundler_plugins/
2
+
3
+ These plugins are **for consumers of the `lhasa-ligand-builder` npm package**, not for building the library itself.
4
+
5
+ When a consumer installs the package, these plugins help them integrate Lhasa's runtime assets (`lhasa.js`, `lhasa.wasm`, `Components-inchikey.ich`, `icons/`) into their own build pipeline. The assets are sourced from this package's own `dist/assets/` directory (i.e. `node_modules/lhasa-ligand-builder/dist/assets/`) and copied into the consumer's build output.
6
+
7
+ ## Files
8
+
9
+ - `vite.mjs` — Vite plugin. Copies assets on production build (`closeBundle` hook) and serves them via dev-server middleware during development.
10
+ - `webpack.cjs` — Webpack plugin. Copies assets after emit (`afterEmit` hook) and exposes a `devServerStatic()` helper for webpack-dev-server.
11
+ - `utils.mjs` — Shared constants (asset list, path to `dist/assets/`).
12
+
13
+ ## Relation to the library build
14
+
15
+ The library's own build uses `scripts/copy-assets.mjs` to populate `dist/assets/`. These bundler plugins are downstream of that: they distribute those already-built assets into whatever project the consumer is building.