openchemlib-search-wasm 1.2.0 → 2.1.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.
Files changed (59) hide show
  1. package/README.md +290 -3
  2. package/lib/functionKeys/dictionary.json +72071 -0
  3. package/lib/functionKeys/index.d.ts +105 -0
  4. package/lib/functionKeys/index.d.ts.map +1 -0
  5. package/lib/functionKeys/index.js +98 -0
  6. package/lib/functionKeys/index.js.map +1 -0
  7. package/lib/functions.d.ts +38 -0
  8. package/lib/functions.d.ts.map +1 -0
  9. package/lib/functions.js +54 -0
  10. package/lib/functions.js.map +1 -0
  11. package/lib/hex.d.ts +31 -0
  12. package/lib/hex.d.ts.map +1 -0
  13. package/lib/hex.js +41 -0
  14. package/lib/hex.js.map +1 -0
  15. package/lib/index.d.ts +140 -2
  16. package/lib/index.d.ts.map +1 -1
  17. package/lib/index.js +184 -7
  18. package/lib/index.js.map +1 -1
  19. package/lib/records.d.ts +45 -0
  20. package/lib/records.d.ts.map +1 -0
  21. package/lib/records.js +96 -0
  22. package/lib/records.js.map +1 -0
  23. package/lib/scan.d.ts +99 -7
  24. package/lib/scan.d.ts.map +1 -1
  25. package/lib/scan.js +158 -11
  26. package/lib/scan.js.map +1 -1
  27. package/lib/strongHash.d.ts +9 -0
  28. package/lib/strongHash.d.ts.map +1 -0
  29. package/lib/strongHash.js +56 -0
  30. package/lib/strongHash.js.map +1 -0
  31. package/lib/substructureSearch.d.ts +8 -5
  32. package/lib/substructureSearch.d.ts.map +1 -1
  33. package/lib/substructureSearch.js +28 -5
  34. package/lib/substructureSearch.js.map +1 -1
  35. package/lib/types.d.ts +120 -3
  36. package/lib/types.d.ts.map +1 -1
  37. package/lib/types.js +17 -1
  38. package/lib/types.js.map +1 -1
  39. package/lib/wasm/load.d.ts.map +1 -1
  40. package/lib/wasm/load.js +9 -1
  41. package/lib/wasm/load.js.map +1 -1
  42. package/lib/wasm/log.d.ts +36 -0
  43. package/lib/wasm/log.d.ts.map +1 -0
  44. package/lib/wasm/log.js +52 -0
  45. package/lib/wasm/log.js.map +1 -0
  46. package/package.json +6 -3
  47. package/src/functionKeys/index.ts +181 -0
  48. package/src/functions.ts +56 -0
  49. package/src/hex.ts +43 -0
  50. package/src/index.ts +269 -5
  51. package/src/records.ts +142 -0
  52. package/src/scan.ts +259 -16
  53. package/src/strongHash.ts +57 -0
  54. package/src/substructureSearch.ts +29 -6
  55. package/src/types.ts +171 -2
  56. package/src/wasm/load.ts +10 -1
  57. package/src/wasm/log.ts +66 -0
  58. package/wasm/data.js +1 -1
  59. package/wasm/runtime.d.ts +6 -0
package/lib/scan.js CHANGED
@@ -1,4 +1,4 @@
1
- import { SimilarityResult, SubstructureResult } from "./types.js";
1
+ import { DEFAULT_MAX_TAUTOMERS, INDEX_WORDS, NO_HASH, NO_ID_CODE, SimilarityResult, SubstructureResult, } from "./types.js";
2
2
  import { loadOCL } from "./wasm/load.js";
3
3
  // Top-level await: the WASM module is instantiated when this module is imported, so the searches are
4
4
  // plain calls. A worker pays it once, at startup, for about 25 ms from the built package.
@@ -88,9 +88,8 @@ function firstPending(mode, result, from, to) {
88
88
  /**
89
89
  * Fingerprints `idCodes[from .. to)` into `result`, sixteen words per molecule.
90
90
  *
91
- * Unlike the searches, a malformed idcode needs no recovery here: the WASM side writes sixteen
92
- * zeros for it and carries on, because a fingerprint no query can be a subset of is the safe answer
93
- * for a molecule that could not be read.
91
+ * A molecule that cannot be read gets sixteen zeros, which no non-empty query is a subset of, so it
92
+ * is never a false candidate.
94
93
  * @param idCodes - The molecules to fingerprint.
95
94
  * @param result - The caller's buffer, `16 * idCodes.length` words long.
96
95
  * @param from - The first index to fingerprint.
@@ -98,23 +97,95 @@ function firstPending(mode, result, from, to) {
98
97
  * @returns How many molecules were parsed and fingerprinted.
99
98
  */
100
99
  export function buildIndexes(idCodes, result, from, to) {
101
- return Search.getIndexes(idCodes, result, from, to);
100
+ return recoveringFromTraps((first, last) => Search.getIndexes(idCodes, result, first, last), (index) => result.fill(0, index * INDEX_WORDS, (index + 1) * INDEX_WORDS), from, to);
101
+ }
102
+ /**
103
+ * Screens `idCodes[from .. to)` into `result`, sixteen words per molecule.
104
+ *
105
+ * Fails like {@link buildIndexes}: sixteen zeros for an idcode the WASM side cannot read.
106
+ * @param idCodes - The molecules to screen.
107
+ * @param result - The caller's buffer, `16 * idCodes.length` words long.
108
+ * @param from - The first index to screen.
109
+ * @param to - One past the last index to screen.
110
+ * @returns How many molecules were parsed and screened.
111
+ */
112
+ export function buildScreens(idCodes, result, from, to) {
113
+ return Search.getScreens(idCodes, result, from, to);
114
+ }
115
+ /**
116
+ * Builds the function bits of `idCodes[from .. to)` into `result`, sixteen words per molecule.
117
+ *
118
+ * Fails like {@link buildIndexes}: sixteen zeros for an idcode the WASM side cannot read.
119
+ * @param idCodes - The molecules to read.
120
+ * @param result - The caller's buffer, `16 * idCodes.length` words long.
121
+ * @param from - The first index to read.
122
+ * @param to - One past the last index to read.
123
+ * @returns How many molecules were parsed and read.
124
+ */
125
+ export function buildFunctions(idCodes, result, from, to) {
126
+ return recoveringFromTraps((first, last) => Search.getFunctions(idCodes, result, first, last), (index) => result.fill(0, index * INDEX_WORDS, (index + 1) * INDEX_WORDS), from, to);
127
+ }
128
+ /**
129
+ * Reads the fragments of the 512 stored function keys, in bit order.
130
+ * @returns Per key, its fragment idcodes.
131
+ */
132
+ export function readFunctionKeys() {
133
+ return Search.getFunctionKeys()
134
+ .split('\n')
135
+ .map((key) => key.split(' '));
136
+ }
137
+ /**
138
+ * Builds what every molecule a query matches has: its FragFp words, or its screen words.
139
+ * @param kind - `'index'` for the FragFp words, `'screen'` for the screen words.
140
+ * @param idCodeQuery - The query, as an idcode.
141
+ * @returns Sixteen words.
142
+ * @throws {Error} If the query cannot be parsed.
143
+ */
144
+ export function buildQueryWords(kind, idCodeQuery) {
145
+ const result = new Int32Array(INDEX_WORDS);
146
+ try {
147
+ if (kind === 'index') {
148
+ Search.getQueryIndex(idCodeQuery, result);
149
+ }
150
+ else {
151
+ Search.getQueryScreen(idCodeQuery, result);
152
+ }
153
+ }
154
+ catch (error) {
155
+ throw new Error(`"${idCodeQuery}" is not a valid query idcode`, {
156
+ cause: error,
157
+ });
158
+ }
159
+ return result;
160
+ }
161
+ /**
162
+ * Reads the key fragments behind the bits of the FragFp words, or of the screen words.
163
+ * @param kind - `'index'` for FragFp's keys, `'screen'` for the screen's.
164
+ * @returns 512 idcodes, in bit order.
165
+ */
166
+ export function readKeys(kind) {
167
+ const joined = kind === 'index' ? Search.getFragFpKeys() : Search.getScreenKeys();
168
+ return joined.split('\n');
102
169
  }
103
170
  /**
104
171
  * Hashes `idCodes[from .. to)` into `result`, one no-stereo tautomer hash per molecule.
105
172
  *
106
- * Like the fingerprints and unlike the searches, a malformed idcode needs no recovery here: the
107
- * WASM side writes `0` for one it cannot read and carries on, and `0` is also what OpenChemLib
108
- * returns for a molecule it cannot canonize, so the two failures are reported the same way.
173
+ * A molecule that cannot be read gets `NO_HASH`, which is also what OpenChemLib returns for one it
174
+ * cannot canonize, so the two failures are reported the same way.
109
175
  * @param idCodes - The molecules to hash.
110
176
  * @param result - The caller's buffer, `idCodes.length` entries long.
111
177
  * @param largestFragmentOnly - Whether to strip and neutralize down to the largest fragment first.
112
178
  * @param from - The first index to hash.
113
179
  * @param to - One past the last index to hash.
180
+ * @param tautomerCounts - Filled with how many tautomers each molecule needed; an entry that reached
181
+ * `maxTautomers` is one OpenChemLib stopped early on.
182
+ * @param maxTautomers - The ceiling on that enumeration, which is what bounds the cost.
114
183
  * @returns How many molecules were hashed.
115
184
  */
116
- export function buildNoStereoTautomerHashes(idCodes, result, largestFragmentOnly, from, to) {
117
- return Search.getNoStereoTautomerHashes(idCodes, result, largestFragmentOnly, from, to);
185
+ export function buildNoStereoTautomerHashes(idCodes, result, largestFragmentOnly, from, to, tautomerCounts = new Int32Array(idCodes.length), maxTautomers = DEFAULT_MAX_TAUTOMERS) {
186
+ return recoveringFromTraps((first, last) => Search.getNoStereoTautomerHashes(idCodes, result, tautomerCounts, largestFragmentOnly, maxTautomers, first, last), (index) => {
187
+ result[index] = NO_HASH;
188
+ }, from, to);
118
189
  }
119
190
  /**
120
191
  * Hashes `idCodes[from .. to)` into `result`, one no-stereo hash per molecule.
@@ -129,6 +200,82 @@ export function buildNoStereoTautomerHashes(idCodes, result, largestFragmentOnly
129
200
  * @returns How many molecules were hashed.
130
201
  */
131
202
  export function buildNoStereoHashes(idCodes, result, largestFragmentOnly, from, to) {
132
- return Search.getNoStereoHashes(idCodes, result, largestFragmentOnly, from, to);
203
+ return recoveringFromTraps((first, last) => Search.getNoStereoHashes(idCodes, result, largestFragmentOnly, first, last), (index) => {
204
+ result[index] = NO_HASH;
205
+ }, from, to);
206
+ }
207
+ /**
208
+ * Canonizes `idCodes[from .. to)` into `result`, one no-stereo idcode per molecule.
209
+ *
210
+ * This is the string {@link buildNoStereoHashes} hashes, for a caller that stores the canonical form
211
+ * rather than a 64-bit key. A molecule that cannot be read keeps the `NO_ID_CODE` the caller's array
212
+ * was filled with.
213
+ * @param idCodes - The molecules to canonize.
214
+ * @param result - The caller's array, `idCodes.length` entries long, filled with `NO_ID_CODE`.
215
+ * @param largestFragmentOnly - Whether to strip and neutralize down to the largest fragment first.
216
+ * @param from - The first index to canonize.
217
+ * @param to - One past the last index to canonize.
218
+ * @returns How many molecules were canonized.
219
+ */
220
+ export function buildNoStereoIdCodes(idCodes, result, largestFragmentOnly, from, to) {
221
+ return recoveringFromTraps((first, last) => Search.getNoStereoIdCodes(idCodes, result, largestFragmentOnly, first, last), (index) => {
222
+ result[index] = NO_ID_CODE;
223
+ }, from, to);
224
+ }
225
+ /**
226
+ * Canonizes `idCodes[from .. to)` into `result`, one no-stereo generic-tautomer idcode per molecule.
227
+ *
228
+ * Fails the same way {@link buildNoStereoIdCodes} does.
229
+ * @param idCodes - The molecules to canonize.
230
+ * @param result - The caller's array, `idCodes.length` entries long, filled with `NO_ID_CODE`.
231
+ * @param largestFragmentOnly - Whether to strip and neutralize down to the largest fragment first.
232
+ * @param from - The first index to canonize.
233
+ * @param to - One past the last index to canonize.
234
+ * @param tautomerCounts - Filled with how many tautomers each molecule needed; an entry that reached
235
+ * `maxTautomers` is one OpenChemLib stopped early on.
236
+ * @param maxTautomers - The ceiling on that enumeration, which is what bounds the cost.
237
+ * @returns How many molecules were canonized.
238
+ */
239
+ export function buildNoStereoTautomerIdCodes(idCodes, result, largestFragmentOnly, from, to, tautomerCounts = new Int32Array(idCodes.length), maxTautomers = DEFAULT_MAX_TAUTOMERS) {
240
+ return recoveringFromTraps((first, last) => Search.getNoStereoTautomerIdCodes(idCodes, result, tautomerCounts, largestFragmentOnly, maxTautomers, first, last), (index) => {
241
+ result[index] = NO_ID_CODE;
242
+ }, from, to);
243
+ }
244
+ /**
245
+ * Runs a ranged WASM call, and redoes the range one molecule at a time if it traps.
246
+ *
247
+ * A malformed idcode makes OpenChemLib's bit-stream parser read past its input, which WebAssembly
248
+ * traps on — the same trap {@link scanRange} recovers from. The Java guard catches an empty or
249
+ * non-ASCII idcode, but a malformed ASCII one reaches the parser and traps there, which would
250
+ * otherwise lose every molecule in the range including the good ones. The trap leaves the module
251
+ * usable, and a per-molecule call costs what a batched one does because the 512 key fragments are
252
+ * parsed once for the module's lifetime, so redoing the range singly costs nothing that was not
253
+ * already going to be spent.
254
+ *
255
+ * There is no cap on the failures: these functions promise a per-molecule "could not read this"
256
+ * answer rather than an exception, so an array that is entirely garbage yields one of those per
257
+ * entry.
258
+ * @param call - Runs the WASM call over a range, returning how many molecules it handled.
259
+ * @param markUnreadable - Writes the "could not read this" answer for one molecule.
260
+ * @param from - The first index to handle.
261
+ * @param to - One past the last index to handle.
262
+ * @returns How many molecules were handled.
263
+ */
264
+ export function recoveringFromTraps(call, markUnreadable, from, to) {
265
+ try {
266
+ return call(from, to);
267
+ }
268
+ catch {
269
+ let handled = 0;
270
+ for (let index = from; index < to; index++) {
271
+ try {
272
+ handled += call(index, index + 1);
273
+ }
274
+ catch {
275
+ markUnreadable(index);
276
+ }
277
+ }
278
+ return handled;
279
+ }
133
280
  }
134
281
  //# sourceMappingURL=scan.js.map
package/lib/scan.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"scan.js","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,qGAAqG;AACrG,0FAA0F;AAC1F,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,OAAO,EAAE,CAAC;AAEnC,kGAAkG;AAClG,8FAA8F;AAC9F,kGAAkG;AAClG,wEAAwE;AACxE,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,SAAS,CACvB,IAAgB,EAChB,WAAmB,EACnB,OAAiB,EACjB,MAAoB,EACpB,IAAY,EACZ,EAAU;IAEV,MAAM,UAAU,GACd,IAAI,KAAK,YAAY;QACnB,CAAC,CAAC,gBAAgB,CAAC,UAAU;QAC7B,CAAC,CAAC,kBAAkB,CAAC,UAAU,CAAC;IACpC,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,OAAO,MAAM,GAAG,EAAE,EAAE,CAAC;QACnB,IAAI,CAAC;YACH,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;YACpD,OAAO;QACT,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;YACtD,IAAI,MAAM,KAAK,CAAC,CAAC,IAAI,QAAQ,IAAI,cAAc,EAAE,CAAC;gBAChD,MAAM,IAAI,KAAK,CACb,4BAA4B,MAA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EACZ,EAAU,EACV,iBAA6B,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,EAC3D,eAAuB,qBAAqB;IAE5C,OAAO,mBAAmB,CACxB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CACd,MAAM,CAAC,0BAA0B,CAC/B,OAAO,EACP,MAAM,EACN,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,KAAK,EACL,IAAI,CACL,EACH,CAAC,KAAK,EAAE,EAAE;QACR,MAAM,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC;IAC7B,CAAC,EACD,IAAI,EACJ,EAAE,CACH,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAA0C,EAC1C,cAAuC,EACvC,IAAY,EACZ,EAAU;IAEV,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,KAAK,IAAI,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC;YAC3C,IAAI,CAAC;gBACH,OAAO,IAAI,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;YACpC,CAAC;YAAC,MAAM,CAAC;gBACP,cAAc,CAAC,KAAK,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * `openchemlib-js` exposes `CanonizerUtil.getIDCode` but not the hash built from it, so the hash
3
+ * tests hash that idcode here. This is OpenChemLib's `StrongHasher.hash` transcribed, and having it
4
+ * written a second way is what makes those comparisons a real cross-check.
5
+ * @param text - The idcode to hash.
6
+ * @returns Its 64-bit hash, signed, as a `BigInt64Array` entry holds it.
7
+ */
8
+ export declare function strongHash(text: string): bigint;
9
+ //# sourceMappingURL=strongHash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strongHash.d.ts","sourceRoot":"","sources":["../src/strongHash.ts"],"names":[],"mappings":"AAmBA;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAY/C"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * OpenChemLib's 64-bit StrongHasher, which is how every `CanonizerUtil` hash is defined: the
3
+ * molecule is reduced to a canonical idcode, and that string is hashed. `openchemlib` exposes the
4
+ * canonical forms but not the hasher, so this is its `CanonizerUtil.StrongHasher` transcribed.
5
+ *
6
+ * It is here so a caller that already holds a canonical idcode — one of this package's, or a column
7
+ * of them in a database — can get its hash without canonizing again. That matters because
8
+ * canonizing a generic tautomer is the most expensive thing this package does, and asking for both
9
+ * the idcode and the hash would otherwise pay for it twice.
10
+ *
11
+ * ```js
12
+ * strongHash(getNoStereoTautomerIdCode(idCode)) === getNoStereoTautomerHash(idCode);
13
+ * ```
14
+ */
15
+ const MASK_64 = (1n << 64n) - 1n;
16
+ const HSTART = 0xbb40e64da205b064n;
17
+ const HMULT = 7664345821815920749n;
18
+ const BYTE_TABLE = buildByteTable();
19
+ /**
20
+ * `openchemlib-js` exposes `CanonizerUtil.getIDCode` but not the hash built from it, so the hash
21
+ * tests hash that idcode here. This is OpenChemLib's `StrongHasher.hash` transcribed, and having it
22
+ * written a second way is what makes those comparisons a real cross-check.
23
+ * @param text - The idcode to hash.
24
+ * @returns Its 64-bit hash, signed, as a `BigInt64Array` entry holds it.
25
+ */
26
+ export function strongHash(text) {
27
+ let h = HSTART;
28
+ for (let i = text.length - 1; i >= 0; i--) {
29
+ const character = BigInt(text.codePointAt(i));
30
+ h =
31
+ ((h * HMULT) & MASK_64) ^
32
+ BYTE_TABLE[Number(character & 0xffn)];
33
+ h =
34
+ ((h * HMULT) & MASK_64) ^
35
+ BYTE_TABLE[Number((character >> 8n) & 0xffn)];
36
+ }
37
+ return BigInt.asIntN(64, h);
38
+ }
39
+ /**
40
+ * OpenChemLib's `CanonizerUtil.StrongHasher` byte table, built the same way the Java does.
41
+ * @returns The 256 seeds, as unsigned 64-bit values.
42
+ */
43
+ function buildByteTable() {
44
+ const table = new Array(256);
45
+ let h = 0x544b2fbacaaf1684n;
46
+ for (let i = 0; i < 256; i++) {
47
+ for (let j = 0; j < 31; j++) {
48
+ h = ((h >> 7n) ^ h) & MASK_64;
49
+ h = ((h << 11n) ^ h) & MASK_64;
50
+ h = ((h >> 10n) ^ h) & MASK_64;
51
+ }
52
+ table[i] = h;
53
+ }
54
+ return table;
55
+ }
56
+ //# sourceMappingURL=strongHash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strongHash.js","sourceRoot":"","sources":["../src/strongHash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC;AACjC,MAAM,MAAM,GAAG,mBAAmB,CAAC;AACnC,MAAM,KAAK,GAAG,oBAAoB,CAAC;AACnC,MAAM,UAAU,GAAG,cAAc,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,IAAI,CAAC,GAAG,MAAM,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAW,CAAC,CAAC;QACxD,CAAC;YACC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC;gBACtB,UAAU,CAAC,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC,CAAY,CAAC;QACpD,CAAC;YACC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC;gBACtB,UAAU,CAAC,MAAM,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,CAAY,CAAC;IAC9D,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED;;;GAGG;AACH,SAAS,cAAc;IACrB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAS,GAAG,CAAC,CAAC;IACrC,IAAI,CAAC,GAAG,mBAAmB,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC;YAC9B,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC;YAC/B,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC;QACjC,CAAC;QACD,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import type { SubstructureSearchOptions, SubstructureSearchResult } from './types.ts';
2
2
  /**
3
- * Tests a query fragment against many molecules and returns the ones that contain it.
3
+ * Tests a query fragment, or any of several, against many molecules and returns the ones that
4
+ * contain it.
4
5
  *
5
6
  * The entries are either idcodes or objects carrying one — a database row, a candidate a prescreen
6
7
  * yielded — and what comes back is those same objects, so nothing has to map positions back onto
@@ -10,17 +11,19 @@ import type { SubstructureSearchOptions, SubstructureSearchResult } from './type
10
11
  * The scan is synchronous. `onStep` reports it and can stop it, but the thread is not yielded:
11
12
  * a caller that needs a responsive main thread slices the array across calls, or runs this in a
12
13
  * worker.
13
- * @param idCodeQuery - The query, as an idcode. It is searched as a fragment whatever its own
14
+ * @param idCodeQuery - The query, as an idcode, or several: a molecule then matches when it holds
15
+ * any of them, which is how a function key of `openchemlib-search-wasm/function-keys` is searched
16
+ * (`substructureSearch(key.fragments, entries)`). Each is searched as a fragment whatever its own
14
17
  * fragment flag says, which is what `openchemlib`'s `SSSearcher` does with `setFragment(true)`.
15
18
  * @param entries - The molecules to test: idcodes, or objects holding one at `options.jpath`.
16
19
  * @param options - Where the idcode sits, how many matches are enough, and how to report progress.
17
20
  * @returns The matching entries, their positions, the status buffer and the counts.
18
- * @throws {Error} If the query cannot be parsed, if more than 100 idcodes cannot be, or if no entry
19
- * holds a string at the jpath.
21
+ * @throws {Error} If the query cannot be parsed or is an empty list, if more than 100 idcodes cannot
22
+ * be, or if no entry holds a string at the jpath.
20
23
  * @example
21
24
  * ```js
22
25
  * const { matches } = substructureSearch('gFp@DiTt@@B', rows, { jpath: 'molecule.idCode' });
23
26
  * ```
24
27
  */
25
- export declare function substructureSearch<Entry>(idCodeQuery: string, entries: readonly Entry[], options?: SubstructureSearchOptions): SubstructureSearchResult<Entry>;
28
+ export declare function substructureSearch<Entry>(idCodeQuery: string | readonly string[], entries: readonly Entry[], options?: SubstructureSearchOptions): SubstructureSearchResult<Entry>;
26
29
  //# sourceMappingURL=substructureSearch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"substructureSearch.d.ts","sourceRoot":"","sources":["../src/substructureSearch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EACtC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,GAAE,yBAA8B,GACtC,wBAAwB,CAAC,KAAK,CAAC,CA6DjC"}
1
+ {"version":3,"file":"substructureSearch.d.ts","sourceRoot":"","sources":["../src/substructureSearch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EACtC,WAAW,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EACvC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,GAAE,yBAA8B,GACtC,wBAAwB,CAAC,KAAK,CAAC,CA6DjC"}
@@ -2,7 +2,8 @@ import { toIdCodes } from "./jpath.js";
2
2
  import { runSearch } from "./runSearch.js";
3
3
  import { SubstructureResult } from "./types.js";
4
4
  /**
5
- * Tests a query fragment against many molecules and returns the ones that contain it.
5
+ * Tests a query fragment, or any of several, against many molecules and returns the ones that
6
+ * contain it.
6
7
  *
7
8
  * The entries are either idcodes or objects carrying one — a database row, a candidate a prescreen
8
9
  * yielded — and what comes back is those same objects, so nothing has to map positions back onto
@@ -12,13 +13,15 @@ import { SubstructureResult } from "./types.js";
12
13
  * The scan is synchronous. `onStep` reports it and can stop it, but the thread is not yielded:
13
14
  * a caller that needs a responsive main thread slices the array across calls, or runs this in a
14
15
  * worker.
15
- * @param idCodeQuery - The query, as an idcode. It is searched as a fragment whatever its own
16
+ * @param idCodeQuery - The query, as an idcode, or several: a molecule then matches when it holds
17
+ * any of them, which is how a function key of `openchemlib-search-wasm/function-keys` is searched
18
+ * (`substructureSearch(key.fragments, entries)`). Each is searched as a fragment whatever its own
16
19
  * fragment flag says, which is what `openchemlib`'s `SSSearcher` does with `setFragment(true)`.
17
20
  * @param entries - The molecules to test: idcodes, or objects holding one at `options.jpath`.
18
21
  * @param options - Where the idcode sits, how many matches are enough, and how to report progress.
19
22
  * @returns The matching entries, their positions, the status buffer and the counts.
20
- * @throws {Error} If the query cannot be parsed, if more than 100 idcodes cannot be, or if no entry
21
- * holds a string at the jpath.
23
+ * @throws {Error} If the query cannot be parsed or is an empty list, if more than 100 idcodes cannot
24
+ * be, or if no entry holds a string at the jpath.
22
25
  * @example
23
26
  * ```js
24
27
  * const { matches } = substructureSearch('gFp@DiTt@@B', rows, { jpath: 'molecule.idCode' });
@@ -51,7 +54,7 @@ export function substructureSearch(idCodeQuery, entries, options = {}) {
51
54
  };
52
55
  const run = runSearch({
53
56
  mode: 'substructure',
54
- idCodeQuery,
57
+ idCodeQuery: joinQueries(idCodeQuery),
55
58
  idCodes,
56
59
  result,
57
60
  tally,
@@ -78,4 +81,24 @@ export function substructureSearch(idCodeQuery, entries, options = {}) {
78
81
  stopped: run.stopped,
79
82
  };
80
83
  }
84
+ /**
85
+ * The query as the WebAssembly side reads it: one idcode, or several joined by `'\n'`, which no
86
+ * idcode contains.
87
+ * @param idCodeQuery - The query, as an idcode or several.
88
+ * @returns The query string.
89
+ * @throws {Error} If the list is empty or an entry holds a line break.
90
+ */
91
+ function joinQueries(idCodeQuery) {
92
+ if (typeof idCodeQuery === 'string')
93
+ return idCodeQuery;
94
+ if (idCodeQuery.length === 0) {
95
+ throw new Error('the query list is empty: give at least one idcode');
96
+ }
97
+ for (const idCode of idCodeQuery) {
98
+ if (idCode.includes('\n')) {
99
+ throw new Error(`"${idCode}" is not a valid query idcode`);
100
+ }
101
+ }
102
+ return idCodeQuery.join('\n');
103
+ }
81
104
  //# sourceMappingURL=substructureSearch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"substructureSearch.js","sourceRoot":"","sources":["../src/substructureSearch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,kBAAkB,CAChC,WAAmB,EACnB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KAAK,CAAC;IACnD,MAAM,OAAO,GAAG,IAAI,KAAK,CAAQ,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAW,CAAU,CAAC;IACtD,CAAC;IAED,OAAO;QACL,OAAO;QACP,OAAO;QACP,MAAM;QACN,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,KAAK,EAAE,OAAO,CAAC,MAAM;QACrB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,WAAuC;IAC1D,IAAI,OAAO,WAAW,KAAK,QAAQ;QAAE,OAAO,WAAW,CAAC;IACxD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IACD,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE,CAAC;QACjC,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,IAAI,MAAM,+BAA+B,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC"}
package/lib/types.d.ts CHANGED
@@ -156,20 +156,55 @@ export interface SimilaritySearchResult<Entry> extends SearchResult<Entry> {
156
156
  /** The shape TeaVM exports from the WasmGC module. Both take a half-open `[from, to)` range. */
157
157
  export interface OCLSearch {
158
158
  Search: {
159
- /** Returns how many molecules in the range contain the fragment. */
159
+ /**
160
+ * Returns how many molecules in the range contain the fragment, or any of the fragments when
161
+ * the query holds several idcodes joined by `'\n'`.
162
+ */
160
163
  ssSearch: (idCodeQuery: string, idCodes: string[], result: Uint8Array, from: number, to: number) => number;
161
164
  /** Returns how many molecules in the range were parsed and compared. */
162
165
  similaritySearch: (idCodeQuery: string, idCodes: string[], result: Float32Array, from: number, to: number) => number;
163
166
  /** Returns how many molecules in the range were parsed and fingerprinted. */
164
167
  getIndexes: (idCodes: string[], result: Int32Array, from: number, to: number) => number;
168
+ /** Returns how many molecules in the range were parsed and screened. */
169
+ getScreens: (idCodes: string[], result: Int32Array, from: number, to: number) => number;
170
+ /** Writes the query's sixteen screen words into `result`. */
171
+ getQueryScreen: (idCodeQuery: string, result: Int32Array) => void;
172
+ /** Writes the query's sixteen FragFp words into `result`. */
173
+ getQueryIndex: (idCodeQuery: string, result: Int32Array) => void;
174
+ /** Returns FragFp's 512 key idcodes, in bit order, joined by `'\n'`. */
175
+ getFragFpKeys: () => string;
176
+ /** Returns the screen's 512 key idcodes, in bit order, joined by `'\n'`. */
177
+ getScreenKeys: () => string;
178
+ /** Returns how many molecules in the range were parsed and read. */
179
+ getFunctions: (idCodes: string[], result: Int32Array, from: number, to: number) => number;
180
+ /**
181
+ * Returns the 512 stored function keys, in bit order, joined by `'\n'`: each key's fragment
182
+ * idcodes joined by a space.
183
+ */
184
+ getFunctionKeys: () => string;
165
185
  /** Returns how many molecules in the range were hashed. */
166
- getNoStereoTautomerHashes: (idCodes: string[], result: BigInt64Array, largestFragmentOnly: boolean, from: number, to: number) => number;
186
+ getNoStereoTautomerHashes: (idCodes: string[], result: BigInt64Array, tautomerCounts: Int32Array, largestFragmentOnly: boolean, maxTautomers: number, from: number, to: number) => number;
167
187
  /** Returns how many molecules in the range were hashed. */
168
188
  getNoStereoHashes: (idCodes: string[], result: BigInt64Array, largestFragmentOnly: boolean, from: number, to: number) => number;
189
+ /** Returns how many molecules in the range were canonized. */
190
+ getNoStereoIdCodes: (idCodes: string[], result: string[], largestFragmentOnly: boolean, from: number, to: number) => number;
191
+ /** Returns how many molecules in the range were canonized. */
192
+ getNoStereoTautomerIdCodes: (idCodes: string[], result: string[], tautomerCounts: Int32Array, largestFragmentOnly: boolean, maxTautomers: number, from: number, to: number) => number;
193
+ /** Returns how many molecules in the range were read. */
194
+ getMoleculeRecords: (idCodes: string[], canonical: string[], words: Int32Array, atomCounts: Int32Array, weights: Float64Array, noStereoHashes: BigInt64Array, tautomerHashes: BigInt64Array, tautomerCounts: Int32Array, maxTautomers: number, from: number, to: number) => number;
195
+ /** Returns how many molecules in the range were read. */
196
+ getMoleculeSizes: (idCodes: string[], atomCounts: Int32Array, weights: Float64Array, from: number, to: number) => number;
197
+ /** Returns the query's atom floor. */
198
+ getQueryAtomFloor: (idCodeQuery: string) => number;
169
199
  };
170
200
  }
171
- /** How many 32-bit words one molecule's FragFp fingerprint occupies. */
201
+ /** How many 32-bit words one molecule's FragFp fingerprint, its screen, or its function bits occupy. */
172
202
  export declare const INDEX_WORDS = 16;
203
+ /**
204
+ * How many 32-bit words one molecule's record holds in `getMoleculeRecords`: its FragFp, its screen,
205
+ * then its function bits, {@link INDEX_WORDS} each.
206
+ */
207
+ export declare const RECORD_WORDS: number;
173
208
  /** What every hash function takes. */
174
209
  export interface HashOptions {
175
210
  /**
@@ -179,13 +214,95 @@ export interface HashOptions {
179
214
  * @default false
180
215
  */
181
216
  largestFragmentOnly?: boolean;
217
+ /**
218
+ * The ceiling on how many tautomers OpenChemLib enumerates before it settles for what it has.
219
+ * Only the tautomer functions read it.
220
+ *
221
+ * The cost of a tautomer key is set by this, not by the molecule's size: the median molecule needs
222
+ * a hundred microseconds and one in a hundred runs into the ceiling and spends the better part of
223
+ * a second getting there. Lowering it bounds that tail, at the price of a key that may not be
224
+ * canonical for the molecules that hit it — compare `tautomerCounts` against this value to find
225
+ * them.
226
+ * @default 100000 — OpenChemLib's own
227
+ */
228
+ maxTautomers?: number;
229
+ /**
230
+ * Filled with how many tautomers were enumerated for each molecule, if given. An entry that
231
+ * reached {@link HashOptions.maxTautomers} is one OpenChemLib stopped early on, which is the only
232
+ * signal that a key may not be canonical.
233
+ *
234
+ * It is the caller's buffer, `idCodes.length` entries long, so a table of flags costs one
235
+ * allocation. Only the tautomer functions write it.
236
+ */
237
+ tautomerCounts?: Int32Array;
182
238
  }
183
239
  /** {@link HashOptions} under the name the tautomer hashes introduced it with. */
184
240
  export type TautomerHashOptions = HashOptions;
241
+ /** What `getMoleculeRecords` takes. */
242
+ export interface MoleculeRecordsOptions {
243
+ /**
244
+ * The ceiling on the tautomer enumeration. A molecule that reaches it takes its no-stereo hash as
245
+ * its tautomer hash, because a key from a truncated enumeration is not canonical.
246
+ * @default DEFAULT_MAX_TAUTOMERS
247
+ */
248
+ maxTautomers?: number;
249
+ }
250
+ /**
251
+ * Everything a molecule table stores about each molecule, one entry per input idcode, in input
252
+ * order. A molecule whose idcode cannot be read gets `NO_ID_CODE`, 48 zero words, 0 atoms, a `NaN`
253
+ * weight, `NO_HASH` twice and a tautomer count of 0.
254
+ */
255
+ export interface MoleculeRecords {
256
+ /**
257
+ * The canonical idcode, stereochemistry included: what `openchemlib-js` gives for
258
+ * `Molecule.fromIDCode(idCode).getIDCode()`.
259
+ */
260
+ idCodes: string[];
261
+ /**
262
+ * {@link RECORD_WORDS} words per molecule, at `48 * i`: the FragFp (the 16 words of `getIndexes`),
263
+ * the screen (the 16 words of `getScreens`), then the function bits (the 16 words of
264
+ * `getFunctions`).
265
+ */
266
+ words: Int32Array;
267
+ /** `getAllAtoms()` of the molecule parsed without coordinates, explicit hydrogens included. */
268
+ atomCounts: Int32Array;
269
+ /** OpenChemLib's relative molecular weight. */
270
+ weights: Float64Array;
271
+ /** The value of `getNoStereoHashes`. */
272
+ noStereoHashes: BigInt64Array;
273
+ /**
274
+ * The value of `getNoStereoTautomerHashes`, except for a molecule whose enumeration reached
275
+ * `maxTautomers` or could not be canonized: that one gets its no-stereo hash.
276
+ */
277
+ tautomerHashes: BigInt64Array;
278
+ /** How many tautomers were enumerated; at or above `maxTautomers` the enumeration was cut short. */
279
+ tautomerCounts: Int32Array;
280
+ }
281
+ /** The size of each molecule, one entry per input idcode, in input order. */
282
+ export interface MoleculeSizes {
283
+ /**
284
+ * `getAllAtoms()` of the molecule parsed without coordinates, explicit hydrogens included; 0 when
285
+ * the idcode cannot be read.
286
+ */
287
+ atomCounts: Int32Array;
288
+ /** OpenChemLib's relative molecular weight; `NaN` when the idcode cannot be read. */
289
+ weights: Float64Array;
290
+ }
185
291
  /**
186
292
  * The hash of a molecule that has none: its idcode could not be parsed, or OpenChemLib could not
187
293
  * canonize it. A real hash collides with it once in 2^64, so an equality test against it is a
188
294
  * usable "no hash" check.
189
295
  */
190
296
  export declare const NO_HASH = 0n;
297
+ /**
298
+ * The canonical idcode of a molecule that has none: its idcode could not be parsed, or OpenChemLib
299
+ * could not canonize it. The empty string is never a valid idcode, so an equality test against it is
300
+ * the idcode counterpart of {@link NO_HASH}.
301
+ */
302
+ export declare const NO_ID_CODE = "";
303
+ /**
304
+ * How many tautomers OpenChemLib enumerates before it settles for what it has, unless
305
+ * {@link HashOptions.maxTautomers} says otherwise. It is OpenChemLib's own ceiling.
306
+ */
307
+ export declare const DEFAULT_MAX_TAUTOMERS = 100000;
191
308
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;IAC7B,sBAAsB;;IAEtB,oDAAoD;;IAEpD,wDAAwD;;IAExD,0DAA0D;;EAE1D,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;IAC3B,wBAAwB;;IAExB,4DAA4D;;EAE5D,CAAC;AAEH,uFAAuF;AACvF,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,YAAY,CAAC;AAErD;;;GAGG;AACH,MAAM,M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qBAAqB,SAAU,CAAC"}
package/lib/types.js CHANGED
@@ -25,12 +25,28 @@ export const SimilarityResult = Object.freeze({
25
25
  /** The idcode could not be parsed; nothing was compared. */
26
26
  unparsable: -1,
27
27
  });
28
- /** How many 32-bit words one molecule's FragFp fingerprint occupies. */
28
+ /** How many 32-bit words one molecule's FragFp fingerprint, its screen, or its function bits occupy. */
29
29
  export const INDEX_WORDS = 16;
30
+ /**
31
+ * How many 32-bit words one molecule's record holds in `getMoleculeRecords`: its FragFp, its screen,
32
+ * then its function bits, {@link INDEX_WORDS} each.
33
+ */
34
+ export const RECORD_WORDS = 3 * INDEX_WORDS;
30
35
  /**
31
36
  * The hash of a molecule that has none: its idcode could not be parsed, or OpenChemLib could not
32
37
  * canonize it. A real hash collides with it once in 2^64, so an equality test against it is a
33
38
  * usable "no hash" check.
34
39
  */
35
40
  export const NO_HASH = 0n;
41
+ /**
42
+ * The canonical idcode of a molecule that has none: its idcode could not be parsed, or OpenChemLib
43
+ * could not canonize it. The empty string is never a valid idcode, so an equality test against it is
44
+ * the idcode counterpart of {@link NO_HASH}.
45
+ */
46
+ export const NO_ID_CODE = '';
47
+ /**
48
+ * How many tautomers OpenChemLib enumerates before it settles for what it has, unless
49
+ * {@link HashOptions.maxTautomers} says otherwise. It is OpenChemLib's own ceiling.
50
+ */
51
+ export const DEFAULT_MAX_TAUTOMERS = 100_000;
36
52
  //# sourceMappingURL=types.js.map
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,sBAAsB;IACtB,WAAW,EAAE,CAAC;IACd,oDAAoD;IACpD,KAAK,EAAE,CAAC;IACR,wDAAwD;IACxD,OAAO,EAAE,CAAC;IACV,0DAA0D;IAC1D,UAAU,EAAE,CAAC;CACd,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,wBAAwB;IACxB,WAAW,EAAE,MAAM,CAAC,GAAG;IACvB,4DAA4D;IAC5D,UAAU,EAAE,CAAC,CAAC;CACf,CAAC,CAAC;AAwLH,wEAAwE;AACxE,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAgB9B;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,sBAAsB;IACtB,WAAW,EAAE,CAAC;IACd,oDAAoD;IACpD,KAAK,EAAE,CAAC;IACR,wDAAwD;IACxD,OAAO,EAAE,CAAC;IACV,0DAA0D;IAC1D,UAAU,EAAE,CAAC;CACd,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,wBAAwB;IACxB,WAAW,EAAE,MAAM,CAAC,GAAG;IACvB,4DAA4D;IAC5D,UAAU,EAAE,CAAC,CAAC;CACf,CAAC,CAAC;AAkQH,wGAAwG;AACxG,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAE9B;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAG,WAAW,CAAC;AA4F5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,CAAC;AAE1B;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAC;AAE7B;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/wasm/load.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAa7C;;;;;;GAMG;AACH,wBAAgB,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC,CAG5C"}
1
+ {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/wasm/load.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAe7C;;;;;;GAMG;AACH,wBAAgB,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC,CAG5C"}