rdkit-esm 0.2.0 → 0.2.2-rc.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.
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -24,45 +24,27 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
value: mod,
|
|
25
25
|
enumerable: true
|
|
26
26
|
}) : target, mod));
|
|
27
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
|
|
28
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
29
|
-
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function.");
|
|
30
|
-
});
|
|
31
27
|
|
|
32
28
|
//#endregion
|
|
33
29
|
//#region MinimalLib/dist/RDKit_minimal.js
|
|
34
30
|
var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
35
|
-
var initRDKitModule
|
|
31
|
+
var initRDKitModule = (() => {
|
|
36
32
|
var _scriptName = globalThis.document?.currentScript?.src;
|
|
37
33
|
return async function(moduleArg = {}) {
|
|
38
34
|
var moduleRtn;
|
|
39
35
|
var Module = moduleArg;
|
|
40
36
|
var ENVIRONMENT_IS_WEB = !!globalThis.window;
|
|
41
37
|
var ENVIRONMENT_IS_WORKER = !!globalThis.WorkerGlobalScope;
|
|
42
|
-
|
|
38
|
+
globalThis.process?.versions?.node && globalThis.process?.type;
|
|
43
39
|
var thisProgram = "./this.program";
|
|
44
|
-
if (
|
|
45
|
-
else if (ENVIRONMENT_IS_WORKER) _scriptName = self.location.href;
|
|
40
|
+
if (ENVIRONMENT_IS_WORKER) _scriptName = self.location.href;
|
|
46
41
|
var scriptDirectory = "";
|
|
47
42
|
function locateFile(path) {
|
|
48
43
|
if (Module["locateFile"]) return Module["locateFile"](path, scriptDirectory);
|
|
49
44
|
return scriptDirectory + path;
|
|
50
45
|
}
|
|
51
46
|
var readAsync, readBinary;
|
|
52
|
-
if (
|
|
53
|
-
var fs = __require("node:fs");
|
|
54
|
-
scriptDirectory = __dirname + "/";
|
|
55
|
-
readBinary = (filename) => {
|
|
56
|
-
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
57
|
-
return fs.readFileSync(filename);
|
|
58
|
-
};
|
|
59
|
-
readAsync = async (filename, binary = true) => {
|
|
60
|
-
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
61
|
-
return fs.readFileSync(filename, binary ? void 0 : "utf8");
|
|
62
|
-
};
|
|
63
|
-
if (process.argv.length > 1) thisProgram = process.argv[1].replace(/\\/g, "/");
|
|
64
|
-
process.argv.slice(2);
|
|
65
|
-
} else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
47
|
+
if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
66
48
|
try {
|
|
67
49
|
scriptDirectory = new URL(".", _scriptName).href;
|
|
68
50
|
} catch {}
|
|
@@ -74,20 +56,6 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
74
56
|
return new Uint8Array(xhr.response);
|
|
75
57
|
};
|
|
76
58
|
readAsync = async (url) => {
|
|
77
|
-
if (isFileURI(url)) return new Promise((resolve, reject) => {
|
|
78
|
-
var xhr = new XMLHttpRequest();
|
|
79
|
-
xhr.open("GET", url, true);
|
|
80
|
-
xhr.responseType = "arraybuffer";
|
|
81
|
-
xhr.onload = () => {
|
|
82
|
-
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
83
|
-
resolve(xhr.response);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
reject(xhr.status);
|
|
87
|
-
};
|
|
88
|
-
xhr.onerror = reject;
|
|
89
|
-
xhr.send(null);
|
|
90
|
-
});
|
|
91
59
|
var response = await fetch(url, { credentials: "same-origin" });
|
|
92
60
|
if (response.ok) return response.arrayBuffer();
|
|
93
61
|
throw new Error(response.status + " : " + response.url);
|
|
@@ -97,7 +65,6 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
97
65
|
var err = console.error.bind(console);
|
|
98
66
|
var wasmBinary;
|
|
99
67
|
var ABORT = false;
|
|
100
|
-
var isFileURI = (filename) => filename.startsWith("file://");
|
|
101
68
|
function writeStackCookie() {
|
|
102
69
|
var max = _emscripten_stack_get_end();
|
|
103
70
|
if (max == 0) max += 4;
|
|
@@ -191,7 +158,7 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
191
158
|
}
|
|
192
159
|
}
|
|
193
160
|
async function instantiateAsync(binary, binaryFile, imports) {
|
|
194
|
-
if (!binary
|
|
161
|
+
if (!binary) try {
|
|
195
162
|
var response = fetch(binaryFile, { credentials: "same-origin" });
|
|
196
163
|
return await WebAssembly.instantiateStreaming(response, imports);
|
|
197
164
|
} catch (reason) {
|
|
@@ -278,13 +245,7 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
278
245
|
join: (...paths) => PATH.normalize(paths.join("/")),
|
|
279
246
|
join2: (l, r) => PATH.normalize(l + "/" + r)
|
|
280
247
|
};
|
|
281
|
-
var initRandomFill = () =>
|
|
282
|
-
if (ENVIRONMENT_IS_NODE) {
|
|
283
|
-
var nodeCrypto = __require("node:crypto");
|
|
284
|
-
return (view) => nodeCrypto.randomFillSync(view);
|
|
285
|
-
}
|
|
286
|
-
return (view) => crypto.getRandomValues(view);
|
|
287
|
-
};
|
|
248
|
+
var initRandomFill = () => (view) => crypto.getRandomValues(view);
|
|
288
249
|
var randomFill = (view) => {
|
|
289
250
|
(randomFill = initRandomFill())(view);
|
|
290
251
|
};
|
|
@@ -415,19 +376,7 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
415
376
|
var FS_stdin_getChar = () => {
|
|
416
377
|
if (!FS_stdin_getChar_buffer.length) {
|
|
417
378
|
var result = null;
|
|
418
|
-
if (
|
|
419
|
-
var BUFSIZE = 256;
|
|
420
|
-
var buf = Buffer.alloc(BUFSIZE);
|
|
421
|
-
var bytesRead = 0;
|
|
422
|
-
var fd = process.stdin.fd;
|
|
423
|
-
try {
|
|
424
|
-
bytesRead = fs.readSync(fd, buf, 0, BUFSIZE);
|
|
425
|
-
} catch (e) {
|
|
426
|
-
if (e.toString().includes("EOF")) bytesRead = 0;
|
|
427
|
-
else throw e;
|
|
428
|
-
}
|
|
429
|
-
if (bytesRead > 0) result = buf.slice(0, bytesRead).toString("utf-8");
|
|
430
|
-
} else if (globalThis.window?.prompt) {
|
|
379
|
+
if (globalThis.window?.prompt) {
|
|
431
380
|
result = window.prompt("Input: ");
|
|
432
381
|
if (result !== null) result += "\n";
|
|
433
382
|
}
|
|
@@ -3844,15 +3793,15 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
3844
3793
|
};
|
|
3845
3794
|
})();
|
|
3846
3795
|
if (typeof exports === "object" && typeof module === "object") {
|
|
3847
|
-
module.exports = initRDKitModule
|
|
3848
|
-
module.exports.default = initRDKitModule
|
|
3849
|
-
} else if (typeof define === "function" && define["amd"]) define([], () => initRDKitModule
|
|
3796
|
+
module.exports = initRDKitModule;
|
|
3797
|
+
module.exports.default = initRDKitModule;
|
|
3798
|
+
} else if (typeof define === "function" && define["amd"]) define([], () => initRDKitModule);
|
|
3850
3799
|
}));
|
|
3851
3800
|
|
|
3852
3801
|
//#endregion
|
|
3853
3802
|
//#region MinimalLib/dist/RDKit_minimal.wasm?url
|
|
3854
3803
|
var import_RDKit_minimal = /* @__PURE__ */ __toESM(require_RDKit_minimal(), 1);
|
|
3855
|
-
var RDKit_minimal_default = "
|
|
3804
|
+
var RDKit_minimal_default = "2e30dd9094dea95c.wasm";
|
|
3856
3805
|
|
|
3857
3806
|
//#endregion
|
|
3858
3807
|
//#region src/mol-array.ts
|
|
@@ -4694,16 +4643,26 @@ var RDKit = class {
|
|
|
4694
4643
|
* Resolves the WASM URL for the current environment.
|
|
4695
4644
|
* In browsers, uses `import.meta.url` to resolve the WASM filename relative
|
|
4696
4645
|
* to the JS bundle's location — works regardless of where the page is served.
|
|
4697
|
-
* In Node.js (e.g. vitest), the `?url` import returns a root-relative path
|
|
4698
|
-
* like `/src/minimalib/RDKit_minimal.wasm` which needs to be joined with cwd.
|
|
4699
4646
|
*/
|
|
4700
4647
|
function resolveWasmUrl() {
|
|
4701
4648
|
const url = RDKit_minimal_default;
|
|
4702
|
-
if (typeof process !== "undefined" && process.versions != null && process.versions.node != null && url.startsWith("/") && !url.startsWith("//")) return process.cwd() + url;
|
|
4703
4649
|
return new URL(url, import.meta.url).href;
|
|
4704
4650
|
}
|
|
4705
4651
|
async function initRDKit(options, constructor = RDKit) {
|
|
4706
|
-
|
|
4652
|
+
const locateFile = options?.locateFile ?? (() => resolveWasmUrl());
|
|
4653
|
+
const moduleArgs = { locateFile };
|
|
4654
|
+
if (typeof process !== "undefined" && process.versions?.node) {
|
|
4655
|
+
const fs = await import("node:fs");
|
|
4656
|
+
const { fileURLToPath } = await import("node:url");
|
|
4657
|
+
const wasmFileUrl = locateFile();
|
|
4658
|
+
let wasmPath = wasmFileUrl.startsWith("file://") ? fileURLToPath(wasmFileUrl) : wasmFileUrl;
|
|
4659
|
+
if (!fs.existsSync(wasmPath)) {
|
|
4660
|
+
const { join } = await import("node:path");
|
|
4661
|
+
wasmPath = join(process.cwd(), wasmPath);
|
|
4662
|
+
}
|
|
4663
|
+
moduleArgs.wasmBinary = fs.readFileSync(wasmPath);
|
|
4664
|
+
}
|
|
4665
|
+
return new constructor(await (0, import_RDKit_minimal.default)(moduleArgs));
|
|
4707
4666
|
}
|
|
4708
4667
|
|
|
4709
4668
|
//#endregion
|