-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offline usage examples #160
Comments
I started experimenting with using the module in a browser-less / Node.js only setting. I've managed to load the module relatively easily and do some basic things with it. I'm a little unsure as to what would count as an "offline-first" app. Just some bare .js / .ts files, without any browser interaction or HTML? Edit: Very basic example // index.js
import initRDKitModule from '@rdkit/rdkit'
initRDKitModule()
.then((rdkit) => {
console.log(rdkit.version())
})
// console output
> 2022.03.5 |
Just being able to do server-side rendering would be very useful, both of depictions (particularly SVGs), and also (and likely easier) for molecule canonization. |
Showcase here. I'm building a plugin for the note-taking app Obsidian, aiming to render SMILES strings as chemical structures. Repo link Challenges
Solutions
|
@Acylation You may want to look at how I deal with this in |
@ptosco yes using Thanks a lot for providing these efficient examples! Beforeconst loadRDKitUnpkg = async () => {
const rdkitBundler = document.createElement('script');
document.body.appendChild(rdkitBundler);
console.log('Fetching RDKit.js from unpkg...');
//requestUrl() is an API that fetching js scripts as text asynchoronously, based on `fetch()` API
rdkitBundler.innerHTML = await requestUrl( 'https://unpkg.com/@rdkit/rdkit/dist/RDKit_minimal.js').text;
const RDKit = await window.initRDKitModule({
locateFile: () => 'https://unpkg.com/@rdkit/rdkit/dist/RDKit_minimal.wasm',
});
console.log('RDKit.js has been successfully loaded.');
return RDKit;
}; Afterconst loadRDKitUnpkg = async () => {
const rdkitBundler = document.createElement('script');
document.body.appendChild(rdkitBundler);
console.log('Fetching RDKit.js from unpkg...');
rdkitBundler.src = 'https://unpkg.com/@rdkit/rdkit/dist/RDKit_minimal.js';
return new Promise<RDKitModule>((resolve, reject) => {
rdkitBundler.onload = async () => {
const RDKit = await window.initRDKitModule({
locateFile: () => 'https://unpkg.com/@rdkit/rdkit/dist/RDKit_minimal.wasm',
});
console.log('RDKit.js has been successfully loaded.');
resolve(RDKit);
rdkitBundler.onerror = (error) => {
reject(error);
};
};
});
}; |
Add examples on how to use rdkit-js in a offline-first app
see context here #150 (comment)
The text was updated successfully, but these errors were encountered: