rdkit-esm 0.2.2-rc.0 → 0.3.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/dist/index.d.ts CHANGED
@@ -649,7 +649,6 @@ interface RDKitModule {
649
649
  * @param input SMARTS string
650
650
  */
651
651
  get_qmol(input: string): JSMol | null;
652
- get_qmol(input: string, details_json?: string): JSMol | null;
653
652
 
654
653
  /**
655
654
  * Create a reaction instance
package/dist/index.js CHANGED
@@ -24,27 +24,45 @@ 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
+ });
27
31
 
28
32
  //#endregion
29
33
  //#region MinimalLib/dist/RDKit_minimal.js
30
34
  var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) => {
31
- var initRDKitModule = (() => {
35
+ var initRDKitModule$1 = (() => {
32
36
  var _scriptName = globalThis.document?.currentScript?.src;
33
37
  return async function(moduleArg = {}) {
34
38
  var moduleRtn;
35
39
  var Module = moduleArg;
36
40
  var ENVIRONMENT_IS_WEB = !!globalThis.window;
37
41
  var ENVIRONMENT_IS_WORKER = !!globalThis.WorkerGlobalScope;
38
- globalThis.process?.versions?.node && globalThis.process?.type;
42
+ var ENVIRONMENT_IS_NODE = globalThis.process?.versions?.node && globalThis.process?.type != "renderer";
39
43
  var thisProgram = "./this.program";
40
- if (ENVIRONMENT_IS_WORKER) _scriptName = self.location.href;
44
+ if (typeof __filename != "undefined") _scriptName = __filename;
45
+ else if (ENVIRONMENT_IS_WORKER) _scriptName = self.location.href;
41
46
  var scriptDirectory = "";
42
47
  function locateFile(path) {
43
48
  if (Module["locateFile"]) return Module["locateFile"](path, scriptDirectory);
44
49
  return scriptDirectory + path;
45
50
  }
46
51
  var readAsync, readBinary;
47
- if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
52
+ if (ENVIRONMENT_IS_NODE) {
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) {
48
66
  try {
49
67
  scriptDirectory = new URL(".", _scriptName).href;
50
68
  } catch {}
@@ -56,6 +74,20 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
56
74
  return new Uint8Array(xhr.response);
57
75
  };
58
76
  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
+ });
59
91
  var response = await fetch(url, { credentials: "same-origin" });
60
92
  if (response.ok) return response.arrayBuffer();
61
93
  throw new Error(response.status + " : " + response.url);
@@ -65,6 +97,7 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
65
97
  var err = console.error.bind(console);
66
98
  var wasmBinary;
67
99
  var ABORT = false;
100
+ var isFileURI = (filename) => filename.startsWith("file://");
68
101
  function writeStackCookie() {
69
102
  var max = _emscripten_stack_get_end();
70
103
  if (max == 0) max += 4;
@@ -158,7 +191,7 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
158
191
  }
159
192
  }
160
193
  async function instantiateAsync(binary, binaryFile, imports) {
161
- if (!binary) try {
194
+ if (!binary && !isFileURI(binaryFile) && !ENVIRONMENT_IS_NODE) try {
162
195
  var response = fetch(binaryFile, { credentials: "same-origin" });
163
196
  return await WebAssembly.instantiateStreaming(response, imports);
164
197
  } catch (reason) {
@@ -245,7 +278,13 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
245
278
  join: (...paths) => PATH.normalize(paths.join("/")),
246
279
  join2: (l, r) => PATH.normalize(l + "/" + r)
247
280
  };
248
- var initRandomFill = () => (view) => crypto.getRandomValues(view);
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
+ };
249
288
  var randomFill = (view) => {
250
289
  (randomFill = initRandomFill())(view);
251
290
  };
@@ -376,7 +415,19 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
376
415
  var FS_stdin_getChar = () => {
377
416
  if (!FS_stdin_getChar_buffer.length) {
378
417
  var result = null;
379
- if (globalThis.window?.prompt) {
418
+ if (ENVIRONMENT_IS_NODE) {
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) {
380
431
  result = window.prompt("Input: ");
381
432
  if (result !== null) result += "\n";
382
433
  }
@@ -587,7 +638,7 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
587
638
  node.node_ops = MEMFS.ops_table.file.node;
588
639
  node.stream_ops = MEMFS.ops_table.file.stream;
589
640
  node.usedBytes = 0;
590
- node.contents = null;
641
+ node.contents = MEMFS.emptyFileContents ??= new Uint8Array(0);
591
642
  } else if (FS.isLink(node.mode)) {
592
643
  node.node_ops = MEMFS.ops_table.link.node;
593
644
  node.stream_ops = MEMFS.ops_table.link.stream;
@@ -603,30 +654,23 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
603
654
  return node;
604
655
  },
605
656
  getFileDataAsTypedArray(node) {
606
- if (!node.contents) return new Uint8Array(0);
607
- if (node.contents.subarray) return node.contents.subarray(0, node.usedBytes);
608
- return new Uint8Array(node.contents);
657
+ return node.contents.subarray(0, node.usedBytes);
609
658
  },
610
659
  expandFileStorage(node, newCapacity) {
611
- var prevCapacity = node.contents ? node.contents.length : 0;
660
+ var prevCapacity = node.contents.length;
612
661
  if (prevCapacity >= newCapacity) return;
613
662
  newCapacity = Math.max(newCapacity, prevCapacity * (prevCapacity < 1024 * 1024 ? 2 : 1.125) >>> 0);
614
- if (prevCapacity != 0) newCapacity = Math.max(newCapacity, 256);
615
- var oldContents = node.contents;
663
+ if (prevCapacity) newCapacity = Math.max(newCapacity, 256);
664
+ var oldContents = MEMFS.getFileDataAsTypedArray(node);
616
665
  node.contents = new Uint8Array(newCapacity);
617
- if (node.usedBytes > 0) node.contents.set(oldContents.subarray(0, node.usedBytes), 0);
666
+ node.contents.set(oldContents);
618
667
  },
619
668
  resizeFileStorage(node, newSize) {
620
669
  if (node.usedBytes == newSize) return;
621
- if (newSize == 0) {
622
- node.contents = null;
623
- node.usedBytes = 0;
624
- } else {
625
- var oldContents = node.contents;
626
- node.contents = new Uint8Array(newSize);
627
- if (oldContents) node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes)));
628
- node.usedBytes = newSize;
629
- }
670
+ var oldContents = node.contents;
671
+ node.contents = new Uint8Array(newSize);
672
+ node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes)));
673
+ node.usedBytes = newSize;
630
674
  },
631
675
  node_ops: {
632
676
  getattr(node) {
@@ -713,8 +757,7 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
713
757
  var contents = stream.node.contents;
714
758
  if (position >= stream.node.usedBytes) return 0;
715
759
  var size = Math.min(stream.node.usedBytes - position, length);
716
- if (size > 8 && contents.subarray) buffer.set(contents.subarray(position, position + size), offset);
717
- else for (var i = 0; i < size; i++) buffer[offset + i] = contents[position + i];
760
+ buffer.set(contents.subarray(position, position + size), offset);
718
761
  return size;
719
762
  },
720
763
  write(stream, buffer, offset, length, position, canOwn) {
@@ -722,24 +765,17 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
722
765
  if (!length) return 0;
723
766
  var node = stream.node;
724
767
  node.mtime = node.ctime = Date.now();
725
- if (buffer.subarray && (!node.contents || node.contents.subarray)) {
726
- if (canOwn) {
727
- node.contents = buffer.subarray(offset, offset + length);
728
- node.usedBytes = length;
729
- return length;
730
- } else if (node.usedBytes === 0 && position === 0) {
731
- node.contents = buffer.slice(offset, offset + length);
732
- node.usedBytes = length;
733
- return length;
734
- } else if (position + length <= node.usedBytes) {
735
- node.contents.set(buffer.subarray(offset, offset + length), position);
736
- return length;
737
- }
768
+ if (canOwn) {
769
+ node.contents = buffer.subarray(offset, offset + length);
770
+ node.usedBytes = length;
771
+ } else if (node.usedBytes === 0 && position === 0) {
772
+ node.contents = buffer.slice(offset, offset + length);
773
+ node.usedBytes = length;
774
+ } else {
775
+ MEMFS.expandFileStorage(node, position + length);
776
+ node.contents.set(buffer.subarray(offset, offset + length), position);
777
+ node.usedBytes = Math.max(node.usedBytes, position + length);
738
778
  }
739
- MEMFS.expandFileStorage(node, position + length);
740
- if (node.contents.subarray && buffer.subarray) node.contents.set(buffer.subarray(offset, offset + length), position);
741
- else for (var i = 0; i < length; i++) node.contents[position + i] = buffer[offset + i];
742
- node.usedBytes = Math.max(node.usedBytes, position + length);
743
779
  return length;
744
780
  },
745
781
  llseek(stream, offset, whence) {
@@ -756,7 +792,7 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
756
792
  var ptr;
757
793
  var allocated;
758
794
  var contents = stream.node.contents;
759
- if (!(flags & 2) && contents && contents.buffer === HEAP8.buffer) {
795
+ if (!(flags & 2) && contents.buffer === HEAP8.buffer) {
760
796
  allocated = false;
761
797
  ptr = contents.byteOffset;
762
798
  } else {
@@ -781,6 +817,7 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
781
817
  }
782
818
  };
783
819
  var FS_modeStringToFlags = (str) => {
820
+ if (typeof str != "string") return str;
784
821
  var flags = {
785
822
  r: 0,
786
823
  "r+": 2,
@@ -792,6 +829,11 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
792
829
  if (typeof flags == "undefined") throw new Error(`Unknown file open mode: ${str}`);
793
830
  return flags;
794
831
  };
832
+ var FS_fileDataToTypedArray = (data) => {
833
+ if (typeof data == "string") data = intArrayFromString(data, true);
834
+ if (!data.subarray) data = new Uint8Array(data);
835
+ return data;
836
+ };
795
837
  var FS_getMode = (canRead, canWrite) => {
796
838
  var mode = 0;
797
839
  if (canRead) mode |= 365;
@@ -1476,7 +1518,7 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
1476
1518
  },
1477
1519
  open(path, flags, mode = 438) {
1478
1520
  if (path === "") throw new FS.ErrnoError(44);
1479
- flags = typeof flags == "string" ? FS_modeStringToFlags(flags) : flags;
1521
+ flags = FS_modeStringToFlags(flags);
1480
1522
  if (flags & 64) mode = mode & 4095 | 32768;
1481
1523
  else mode = 0;
1482
1524
  var node;
@@ -1602,9 +1644,8 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
1602
1644
  writeFile(path, data, opts = {}) {
1603
1645
  opts.flags = opts.flags || 577;
1604
1646
  var stream = FS.open(path, opts.flags, opts.mode);
1605
- if (typeof data == "string") data = new Uint8Array(intArrayFromString(data, true));
1606
- if (ArrayBuffer.isView(data)) FS.write(stream, data, 0, data.byteLength, void 0, opts.canOwn);
1607
- else abort("Unsupported data type");
1647
+ data = FS_fileDataToTypedArray(data);
1648
+ FS.write(stream, data, 0, data.byteLength, void 0, opts.canOwn);
1608
1649
  FS.close(stream);
1609
1650
  },
1610
1651
  cwd: () => FS.currentPath,
@@ -1771,11 +1812,7 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
1771
1812
  var mode = FS_getMode(canRead, canWrite);
1772
1813
  var node = FS.create(path, mode);
1773
1814
  if (data) {
1774
- if (typeof data == "string") {
1775
- var arr = new Array(data.length);
1776
- for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
1777
- data = arr;
1778
- }
1815
+ data = FS_fileDataToTypedArray(data);
1779
1816
  FS.chmod(node, mode | 146);
1780
1817
  var stream = FS.open(node, 577);
1781
1818
  FS.write(stream, data, 0, data.length, 0, canOwn);
@@ -3793,15 +3830,15 @@ var require_RDKit_minimal = /* @__PURE__ */ __commonJSMin(((exports, module) =>
3793
3830
  };
3794
3831
  })();
3795
3832
  if (typeof exports === "object" && typeof module === "object") {
3796
- module.exports = initRDKitModule;
3797
- module.exports.default = initRDKitModule;
3798
- } else if (typeof define === "function" && define["amd"]) define([], () => initRDKitModule);
3833
+ module.exports = initRDKitModule$1;
3834
+ module.exports.default = initRDKitModule$1;
3835
+ } else if (typeof define === "function" && define["amd"]) define([], () => initRDKitModule$1);
3799
3836
  }));
3800
3837
 
3801
3838
  //#endregion
3802
3839
  //#region MinimalLib/dist/RDKit_minimal.wasm?url
3803
3840
  var import_RDKit_minimal = /* @__PURE__ */ __toESM(require_RDKit_minimal(), 1);
3804
- var RDKit_minimal_default = "2e30dd9094dea95c.wasm";
3841
+ var RDKit_minimal_default = "4c709c835a45b633.wasm";
3805
3842
 
3806
3843
  //#endregion
3807
3844
  //#region src/mol-array.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rdkit-esm",
3
- "version": "0.2.2-rc.0",
3
+ "version": "0.3.0",
4
4
  "description": "RDKit minimal lib for the modern web.",
5
5
  "homepage": "https://github.com/tandemai/rdkit-esm#readme",
6
6
  "bugs": {