From 08989382a4fe368ad05117e501f21734139cc791 Mon Sep 17 00:00:00 2001 From: Scott Goodrow Date: Wed, 2 Aug 2023 13:14:13 -0700 Subject: [PATCH] docs: update readme and types to reflect alternate wasm loading path --- README.md | 7 ++++++- typescript/index.d.ts | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 53dbf6de..bc305618 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,12 @@ Once you have the RDKit package installed in your node modules, copy the followi - `node_modules/@rdkit/rdkit/dist/RDKit_minimal.js` - `node_modules/@rdkit/rdkit/dist/RDKit_minimal.wasm` -**NOTE: Both files must be copied at the same location in your deployed assets for the library to work properly.** +**NOTE: By default, both files must be copied at the same location in your deployed assets for the library to work properly.**. If you need the `RDKIT_minimal.wasm` file to be loaded from another location, use the `locateFile` option when invoking `initRDKitModule`. + +```js +// Load the RDKit WASM module from a specific path on your server. +window.initRDKitModule({ locateFile: () => '/path/to/RDKit_minimal.wasm' }).then(); +``` #### Option 2: Use the remote distribution files from [unpkg.com](https://unpkg.com/) diff --git a/typescript/index.d.ts b/typescript/index.d.ts index ed836c63..4f51e3a8 100644 --- a/typescript/index.d.ts +++ b/typescript/index.d.ts @@ -531,11 +531,18 @@ export interface RDKitModule { use_legacy_stereo_perception(value: boolean): void; } +type RDKitLoaderOptions = { + /** + * Optional path to the RDKit module .wasm file on your server. + */ + locateFile?: () => string +} + /** * Loads the RDKit module asynchronously. * In order to use the RDKit module, calling this function is necessary. */ -export type RDKitLoader = () => Promise; +export type RDKitLoader = (options: RDKitLoaderOptions) => Promise; declare global { interface Window {