bio-forge-wasm 0.3.1 → 0.4.1

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.
@@ -1,240 +1,3 @@
1
- let wasm;
2
- export function __wbg_set_wasm(val) {
3
- wasm = val;
4
- }
5
-
6
- function addHeapObject(obj) {
7
- if (heap_next === heap.length) heap.push(heap.length + 1);
8
- const idx = heap_next;
9
- heap_next = heap[idx];
10
-
11
- heap[idx] = obj;
12
- return idx;
13
- }
14
-
15
- function _assertClass(instance, klass) {
16
- if (!(instance instanceof klass)) {
17
- throw new Error(`expected instance of ${klass.name}`);
18
- }
19
- }
20
-
21
- function debugString(val) {
22
- // primitive types
23
- const type = typeof val;
24
- if (type == 'number' || type == 'boolean' || val == null) {
25
- return `${val}`;
26
- }
27
- if (type == 'string') {
28
- return `"${val}"`;
29
- }
30
- if (type == 'symbol') {
31
- const description = val.description;
32
- if (description == null) {
33
- return 'Symbol';
34
- } else {
35
- return `Symbol(${description})`;
36
- }
37
- }
38
- if (type == 'function') {
39
- const name = val.name;
40
- if (typeof name == 'string' && name.length > 0) {
41
- return `Function(${name})`;
42
- } else {
43
- return 'Function';
44
- }
45
- }
46
- // objects
47
- if (Array.isArray(val)) {
48
- const length = val.length;
49
- let debug = '[';
50
- if (length > 0) {
51
- debug += debugString(val[0]);
52
- }
53
- for(let i = 1; i < length; i++) {
54
- debug += ', ' + debugString(val[i]);
55
- }
56
- debug += ']';
57
- return debug;
58
- }
59
- // Test for built-in
60
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
61
- let className;
62
- if (builtInMatches && builtInMatches.length > 1) {
63
- className = builtInMatches[1];
64
- } else {
65
- // Failed to match the standard '[object ClassName]'
66
- return toString.call(val);
67
- }
68
- if (className == 'Object') {
69
- // we're a user defined class or Object
70
- // JSON.stringify avoids problems with cycles, and is generally much
71
- // easier than looping through ownProperties of `val`.
72
- try {
73
- return 'Object(' + JSON.stringify(val) + ')';
74
- } catch (_) {
75
- return 'Object';
76
- }
77
- }
78
- // errors
79
- if (val instanceof Error) {
80
- return `${val.name}: ${val.message}\n${val.stack}`;
81
- }
82
- // TODO we could test for more things here, like `Set`s and `Map`s.
83
- return className;
84
- }
85
-
86
- function dropObject(idx) {
87
- if (idx < 132) return;
88
- heap[idx] = heap_next;
89
- heap_next = idx;
90
- }
91
-
92
- function getArrayU8FromWasm0(ptr, len) {
93
- ptr = ptr >>> 0;
94
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
95
- }
96
-
97
- let cachedDataViewMemory0 = null;
98
- function getDataViewMemory0() {
99
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
100
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
101
- }
102
- return cachedDataViewMemory0;
103
- }
104
-
105
- function getStringFromWasm0(ptr, len) {
106
- ptr = ptr >>> 0;
107
- return decodeText(ptr, len);
108
- }
109
-
110
- let cachedUint8ArrayMemory0 = null;
111
- function getUint8ArrayMemory0() {
112
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
113
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
114
- }
115
- return cachedUint8ArrayMemory0;
116
- }
117
-
118
- function getObject(idx) { return heap[idx]; }
119
-
120
- function handleError(f, args) {
121
- try {
122
- return f.apply(this, args);
123
- } catch (e) {
124
- wasm.__wbindgen_export3(addHeapObject(e));
125
- }
126
- }
127
-
128
- let heap = new Array(128).fill(undefined);
129
- heap.push(undefined, null, true, false);
130
-
131
- let heap_next = heap.length;
132
-
133
- function isLikeNone(x) {
134
- return x === undefined || x === null;
135
- }
136
-
137
- function passArray8ToWasm0(arg, malloc) {
138
- const ptr = malloc(arg.length * 1, 1) >>> 0;
139
- getUint8ArrayMemory0().set(arg, ptr / 1);
140
- WASM_VECTOR_LEN = arg.length;
141
- return ptr;
142
- }
143
-
144
- function passArrayJsValueToWasm0(array, malloc) {
145
- const ptr = malloc(array.length * 4, 4) >>> 0;
146
- const mem = getDataViewMemory0();
147
- for (let i = 0; i < array.length; i++) {
148
- mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
149
- }
150
- WASM_VECTOR_LEN = array.length;
151
- return ptr;
152
- }
153
-
154
- function passStringToWasm0(arg, malloc, realloc) {
155
- if (realloc === undefined) {
156
- const buf = cachedTextEncoder.encode(arg);
157
- const ptr = malloc(buf.length, 1) >>> 0;
158
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
159
- WASM_VECTOR_LEN = buf.length;
160
- return ptr;
161
- }
162
-
163
- let len = arg.length;
164
- let ptr = malloc(len, 1) >>> 0;
165
-
166
- const mem = getUint8ArrayMemory0();
167
-
168
- let offset = 0;
169
-
170
- for (; offset < len; offset++) {
171
- const code = arg.charCodeAt(offset);
172
- if (code > 0x7F) break;
173
- mem[ptr + offset] = code;
174
- }
175
- if (offset !== len) {
176
- if (offset !== 0) {
177
- arg = arg.slice(offset);
178
- }
179
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
180
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
181
- const ret = cachedTextEncoder.encodeInto(arg, view);
182
-
183
- offset += ret.written;
184
- ptr = realloc(ptr, len, offset, 1) >>> 0;
185
- }
186
-
187
- WASM_VECTOR_LEN = offset;
188
- return ptr;
189
- }
190
-
191
- function takeObject(idx) {
192
- const ret = getObject(idx);
193
- dropObject(idx);
194
- return ret;
195
- }
196
-
197
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
198
- cachedTextDecoder.decode();
199
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
200
- let numBytesDecoded = 0;
201
- function decodeText(ptr, len) {
202
- numBytesDecoded += len;
203
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
204
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
205
- cachedTextDecoder.decode();
206
- numBytesDecoded = len;
207
- }
208
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
209
- }
210
-
211
- const cachedTextEncoder = new TextEncoder();
212
-
213
- if (!('encodeInto' in cachedTextEncoder)) {
214
- cachedTextEncoder.encodeInto = function (arg, view) {
215
- const buf = cachedTextEncoder.encode(arg);
216
- view.set(buf);
217
- return {
218
- read: arg.length,
219
- written: buf.length
220
- };
221
- }
222
- }
223
-
224
- let WASM_VECTOR_LEN = 0;
225
-
226
- const StructureFinalization = (typeof FinalizationRegistry === 'undefined')
227
- ? { register: () => {}, unregister: () => {} }
228
- : new FinalizationRegistry(ptr => wasm.__wbg_structure_free(ptr >>> 0, 1));
229
-
230
- const TemplateFinalization = (typeof FinalizationRegistry === 'undefined')
231
- ? { register: () => {}, unregister: () => {} }
232
- : new FinalizationRegistry(ptr => wasm.__wbg_template_free(ptr >>> 0, 1));
233
-
234
- const TopologyFinalization = (typeof FinalizationRegistry === 'undefined')
235
- ? { register: () => {}, unregister: () => {} }
236
- : new FinalizationRegistry(ptr => wasm.__wbg_topology_free(ptr >>> 0, 1));
237
-
238
1
  /**
239
2
  * A molecular structure for manipulation and export.
240
3
  */
@@ -257,35 +20,36 @@ export class Structure {
257
20
  wasm.__wbg_structure_free(ptr, 0);
258
21
  }
259
22
  /**
260
- * Returns the number of atoms.
261
- * @returns {number}
262
- */
263
- get atomCount() {
264
- const ret = wasm.structure_atomCount(this.__wbg_ptr);
265
- return ret >>> 0;
266
- }
267
- /**
268
- * Parses an mmCIF string into a Structure.
269
- * @param {string} content
270
- * @returns {Structure}
23
+ * Adds hydrogen atoms.
24
+ * @param {HydroConfig | null} [config]
271
25
  */
272
- static fromMmcif(content) {
26
+ addHydrogens(config) {
273
27
  try {
274
28
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
275
- const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
276
- const len0 = WASM_VECTOR_LEN;
277
- wasm.structure_fromMmcif(retptr, ptr0, len0);
29
+ wasm.structure_addHydrogens(retptr, this.__wbg_ptr, isLikeNone(config) ? 0 : addHeapObject(config));
278
30
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
279
31
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
280
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
281
- if (r2) {
282
- throw takeObject(r1);
32
+ if (r1) {
33
+ throw takeObject(r0);
283
34
  }
284
- return Structure.__wrap(r0);
285
35
  } finally {
286
36
  wasm.__wbindgen_add_to_stack_pointer(16);
287
37
  }
288
38
  }
39
+ /**
40
+ * Returns the number of atoms.
41
+ * @returns {number}
42
+ */
43
+ get atomCount() {
44
+ const ret = wasm.structure_atomCount(this.__wbg_ptr);
45
+ return ret >>> 0;
46
+ }
47
+ /**
48
+ * Centers the geometric centroid at the origin.
49
+ */
50
+ centerGeometry() {
51
+ wasm.structure_centerGeometry(this.__wbg_ptr);
52
+ }
289
53
  /**
290
54
  * Centers the center of mass at the origin.
291
55
  */
@@ -301,95 +65,63 @@ export class Structure {
301
65
  return ret >>> 0;
302
66
  }
303
67
  /**
304
- * Builds a Topology from this structure.
305
- * @param {TopologyConfig | null} [config]
306
- * @param {Template[] | null} [templates]
307
- * @returns {Topology}
68
+ * Removes unwanted components (water, ions, hydrogens, hetero residues).
69
+ * @param {CleanConfig | null} [config]
308
70
  */
309
- toTopology(config, templates) {
71
+ clean(config) {
310
72
  try {
311
73
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
312
- var ptr0 = isLikeNone(templates) ? 0 : passArrayJsValueToWasm0(templates, wasm.__wbindgen_export);
313
- var len0 = WASM_VECTOR_LEN;
314
- wasm.structure_toTopology(retptr, this.__wbg_ptr, isLikeNone(config) ? 0 : addHeapObject(config), ptr0, len0);
74
+ wasm.structure_clean(retptr, this.__wbg_ptr, isLikeNone(config) ? 0 : addHeapObject(config));
315
75
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
316
76
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
317
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
318
- if (r2) {
319
- throw takeObject(r1);
77
+ if (r1) {
78
+ throw takeObject(r0);
320
79
  }
321
- return Topology.__wrap(r0);
322
80
  } finally {
323
81
  wasm.__wbindgen_add_to_stack_pointer(16);
324
82
  }
325
83
  }
326
84
  /**
327
- * Rotates using Euler angles (XYZ convention, all in radians).
328
- * @param {number} x
329
- * @param {number} y
330
- * @param {number} z
85
+ * Creates a deep copy of the structure.
86
+ * @returns {Structure}
331
87
  */
332
- rotateEuler(x, y, z) {
333
- wasm.structure_rotateEuler(this.__wbg_ptr, x, y, z);
88
+ clone() {
89
+ const ret = wasm.structure_clone(this.__wbg_ptr);
90
+ return Structure.__wrap(ret);
334
91
  }
335
92
  /**
336
- * Serializes to PDB format as bytes.
337
- * @returns {Uint8Array}
93
+ * Parses an mmCIF string into a Structure.
94
+ * @param {string} content
95
+ * @returns {Structure}
338
96
  */
339
- toPdbBytes() {
97
+ static fromMmcif(content) {
340
98
  try {
341
99
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
342
- wasm.structure_toPdbBytes(retptr, this.__wbg_ptr);
100
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
101
+ const len0 = WASM_VECTOR_LEN;
102
+ wasm.structure_fromMmcif(retptr, ptr0, len0);
343
103
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
344
104
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
345
105
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
346
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
347
- if (r3) {
348
- throw takeObject(r2);
349
- }
350
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
351
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
352
- return v1;
353
- } finally {
354
- wasm.__wbindgen_add_to_stack_pointer(16);
355
- }
356
- }
357
- /**
358
- * Adds hydrogen atoms.
359
- * @param {HydroConfig | null} [config]
360
- */
361
- addHydrogens(config) {
362
- try {
363
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
364
- wasm.structure_addHydrogens(retptr, this.__wbg_ptr, isLikeNone(config) ? 0 : addHeapObject(config));
365
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
366
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
367
- if (r1) {
368
- throw takeObject(r0);
106
+ if (r2) {
107
+ throw takeObject(r1);
369
108
  }
109
+ return Structure.__wrap(r0);
370
110
  } finally {
371
111
  wasm.__wbindgen_add_to_stack_pointer(16);
372
112
  }
373
113
  }
374
114
  /**
375
- * Returns the number of residues.
376
- * @returns {number}
377
- */
378
- get residueCount() {
379
- const ret = wasm.structure_residueCount(this.__wbg_ptr);
380
- return ret >>> 0;
381
- }
382
- /**
383
- * Parses a PDB byte array into a Structure.
115
+ * Parses an mmCIF byte array into a Structure.
384
116
  * @param {Uint8Array} content
385
117
  * @returns {Structure}
386
118
  */
387
- static fromPdbBytes(content) {
119
+ static fromMmcifBytes(content) {
388
120
  try {
389
121
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
390
122
  const ptr0 = passArray8ToWasm0(content, wasm.__wbindgen_export);
391
123
  const len0 = WASM_VECTOR_LEN;
392
- wasm.structure_fromPdbBytes(retptr, ptr0, len0);
124
+ wasm.structure_fromMmcifBytes(retptr, ptr0, len0);
393
125
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
394
126
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
395
127
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -402,52 +134,38 @@ export class Structure {
402
134
  }
403
135
  }
404
136
  /**
405
- * Serializes to mmCIF format as bytes.
406
- * @returns {Uint8Array}
137
+ * Parses a PDB string into a Structure.
138
+ * @param {string} content
139
+ * @returns {Structure}
407
140
  */
408
- toMmcifBytes() {
141
+ static fromPdb(content) {
409
142
  try {
410
143
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
411
- wasm.structure_toMmcifBytes(retptr, this.__wbg_ptr);
144
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
145
+ const len0 = WASM_VECTOR_LEN;
146
+ wasm.structure_fromPdb(retptr, ptr0, len0);
412
147
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
413
148
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
414
149
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
415
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
416
- if (r3) {
417
- throw takeObject(r2);
150
+ if (r2) {
151
+ throw takeObject(r1);
418
152
  }
419
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
420
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
421
- return v1;
153
+ return Structure.__wrap(r0);
422
154
  } finally {
423
155
  wasm.__wbindgen_add_to_stack_pointer(16);
424
156
  }
425
157
  }
426
158
  /**
427
- * Centers the geometric centroid at the origin.
428
- */
429
- centerGeometry() {
430
- wasm.structure_centerGeometry(this.__wbg_ptr);
431
- }
432
- /**
433
- * Creates a deep copy of the structure.
434
- * @returns {Structure}
435
- */
436
- clone() {
437
- const ret = wasm.structure_clone(this.__wbg_ptr);
438
- return Structure.__wrap(ret);
439
- }
440
- /**
441
- * Parses an mmCIF byte array into a Structure.
159
+ * Parses a PDB byte array into a Structure.
442
160
  * @param {Uint8Array} content
443
161
  * @returns {Structure}
444
162
  */
445
- static fromMmcifBytes(content) {
163
+ static fromPdbBytes(content) {
446
164
  try {
447
165
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
448
166
  const ptr0 = passArray8ToWasm0(content, wasm.__wbindgen_export);
449
167
  const len0 = WASM_VECTOR_LEN;
450
- wasm.structure_fromMmcif(retptr, ptr0, len0);
168
+ wasm.structure_fromPdbBytes(retptr, ptr0, len0);
451
169
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
452
170
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
453
171
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -479,13 +197,12 @@ export class Structure {
479
197
  }
480
198
  }
481
199
  /**
482
- * Removes unwanted components (water, ions, hydrogens, hetero residues).
483
- * @param {CleanConfig | null} [config]
200
+ * Reconstructs missing atoms from templates.
484
201
  */
485
- clean(config) {
202
+ repair() {
486
203
  try {
487
204
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
488
- wasm.structure_clean(retptr, this.__wbg_ptr, isLikeNone(config) ? 0 : addHeapObject(config));
205
+ wasm.structure_repair(retptr, this.__wbg_ptr);
489
206
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
490
207
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
491
208
  if (r1) {
@@ -496,12 +213,51 @@ export class Structure {
496
213
  }
497
214
  }
498
215
  /**
499
- * Reconstructs missing atoms from templates.
216
+ * Returns the number of residues.
217
+ * @returns {number}
500
218
  */
501
- repair() {
219
+ get residueCount() {
220
+ const ret = wasm.structure_residueCount(this.__wbg_ptr);
221
+ return ret >>> 0;
222
+ }
223
+ /**
224
+ * Rotates using Euler angles (XYZ convention, all in radians).
225
+ * @param {number} x
226
+ * @param {number} y
227
+ * @param {number} z
228
+ */
229
+ rotateEuler(x, y, z) {
230
+ wasm.structure_rotateEuler(this.__wbg_ptr, x, y, z);
231
+ }
232
+ /**
233
+ * Rotates around the X axis (angle in radians).
234
+ * @param {number} radians
235
+ */
236
+ rotateX(radians) {
237
+ wasm.structure_rotateX(this.__wbg_ptr, radians);
238
+ }
239
+ /**
240
+ * Rotates around the Y axis (angle in radians).
241
+ * @param {number} radians
242
+ */
243
+ rotateY(radians) {
244
+ wasm.structure_rotateY(this.__wbg_ptr, radians);
245
+ }
246
+ /**
247
+ * Rotates around the Z axis (angle in radians).
248
+ * @param {number} radians
249
+ */
250
+ rotateZ(radians) {
251
+ wasm.structure_rotateZ(this.__wbg_ptr, radians);
252
+ }
253
+ /**
254
+ * Solvates the structure with water and ions.
255
+ * @param {SolvateConfig | null} [config]
256
+ */
257
+ solvate(config) {
502
258
  try {
503
259
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
504
- wasm.structure_repair(retptr, this.__wbg_ptr);
260
+ wasm.structure_solvate(retptr, this.__wbg_ptr, isLikeNone(config) ? 0 : addHeapObject(config));
505
261
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
506
262
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
507
263
  if (r1) {
@@ -512,15 +268,15 @@ export class Structure {
512
268
  }
513
269
  }
514
270
  /**
515
- * Serializes to PDB format.
271
+ * Serializes to mmCIF format.
516
272
  * @returns {string}
517
273
  */
518
- toPdb() {
274
+ toMmcif() {
519
275
  let deferred2_0;
520
276
  let deferred2_1;
521
277
  try {
522
278
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
523
- wasm.structure_toPdb(retptr, this.__wbg_ptr);
279
+ wasm.structure_toMmcif(retptr, this.__wbg_ptr);
524
280
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
525
281
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
526
282
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -540,91 +296,98 @@ export class Structure {
540
296
  }
541
297
  }
542
298
  /**
543
- * Solvates the structure with water and ions.
544
- * @param {SolvateConfig | null} [config]
299
+ * Serializes to mmCIF format as bytes.
300
+ * @returns {Uint8Array}
545
301
  */
546
- solvate(config) {
302
+ toMmcifBytes() {
547
303
  try {
548
304
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
549
- wasm.structure_solvate(retptr, this.__wbg_ptr, isLikeNone(config) ? 0 : addHeapObject(config));
305
+ wasm.structure_toMmcifBytes(retptr, this.__wbg_ptr);
550
306
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
551
307
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
552
- if (r1) {
553
- throw takeObject(r0);
308
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
309
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
310
+ if (r3) {
311
+ throw takeObject(r2);
554
312
  }
313
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
314
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
315
+ return v1;
555
316
  } finally {
556
317
  wasm.__wbindgen_add_to_stack_pointer(16);
557
318
  }
558
319
  }
559
320
  /**
560
- * Parses a PDB string into a Structure.
561
- * @param {string} content
562
- * @returns {Structure}
321
+ * Serializes to PDB format.
322
+ * @returns {string}
563
323
  */
564
- static fromPdb(content) {
324
+ toPdb() {
325
+ let deferred2_0;
326
+ let deferred2_1;
565
327
  try {
566
328
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
567
- const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
568
- const len0 = WASM_VECTOR_LEN;
569
- wasm.structure_fromPdb(retptr, ptr0, len0);
329
+ wasm.structure_toPdb(retptr, this.__wbg_ptr);
570
330
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
571
331
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
572
332
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
573
- if (r2) {
574
- throw takeObject(r1);
333
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
334
+ var ptr1 = r0;
335
+ var len1 = r1;
336
+ if (r3) {
337
+ ptr1 = 0; len1 = 0;
338
+ throw takeObject(r2);
575
339
  }
576
- return Structure.__wrap(r0);
340
+ deferred2_0 = ptr1;
341
+ deferred2_1 = len1;
342
+ return getStringFromWasm0(ptr1, len1);
577
343
  } finally {
578
344
  wasm.__wbindgen_add_to_stack_pointer(16);
345
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
579
346
  }
580
347
  }
581
348
  /**
582
- * Rotates around the X axis (angle in radians).
583
- * @param {number} radians
584
- */
585
- rotateX(radians) {
586
- wasm.structure_rotateX(this.__wbg_ptr, radians);
587
- }
588
- /**
589
- * Rotates around the Y axis (angle in radians).
590
- * @param {number} radians
591
- */
592
- rotateY(radians) {
593
- wasm.structure_rotateY(this.__wbg_ptr, radians);
594
- }
595
- /**
596
- * Rotates around the Z axis (angle in radians).
597
- * @param {number} radians
598
- */
599
- rotateZ(radians) {
600
- wasm.structure_rotateZ(this.__wbg_ptr, radians);
601
- }
602
- /**
603
- * Serializes to mmCIF format.
604
- * @returns {string}
349
+ * Serializes to PDB format as bytes.
350
+ * @returns {Uint8Array}
605
351
  */
606
- toMmcif() {
607
- let deferred2_0;
608
- let deferred2_1;
352
+ toPdbBytes() {
609
353
  try {
610
354
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
611
- wasm.structure_toMmcif(retptr, this.__wbg_ptr);
355
+ wasm.structure_toPdbBytes(retptr, this.__wbg_ptr);
612
356
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
613
357
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
614
358
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
615
359
  var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
616
- var ptr1 = r0;
617
- var len1 = r1;
618
360
  if (r3) {
619
- ptr1 = 0; len1 = 0;
620
361
  throw takeObject(r2);
621
362
  }
622
- deferred2_0 = ptr1;
623
- deferred2_1 = len1;
624
- return getStringFromWasm0(ptr1, len1);
363
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
364
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
365
+ return v1;
366
+ } finally {
367
+ wasm.__wbindgen_add_to_stack_pointer(16);
368
+ }
369
+ }
370
+ /**
371
+ * Builds a Topology from this structure.
372
+ * @param {TopologyConfig | null} [config]
373
+ * @param {Template[] | null} [templates]
374
+ * @returns {Topology}
375
+ */
376
+ toTopology(config, templates) {
377
+ try {
378
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
379
+ var ptr0 = isLikeNone(templates) ? 0 : passArrayJsValueToWasm0(templates, wasm.__wbindgen_export);
380
+ var len0 = WASM_VECTOR_LEN;
381
+ wasm.structure_toTopology(retptr, this.__wbg_ptr, isLikeNone(config) ? 0 : addHeapObject(config), ptr0, len0);
382
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
383
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
384
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
385
+ if (r2) {
386
+ throw takeObject(r1);
387
+ }
388
+ return Topology.__wrap(r0);
625
389
  } finally {
626
390
  wasm.__wbindgen_add_to_stack_pointer(16);
627
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
628
391
  }
629
392
  }
630
393
  /**
@@ -667,14 +430,14 @@ export class Template {
667
430
  wasm.__wbg_template_free(ptr, 0);
668
431
  }
669
432
  /**
670
- * Parses a MOL2 byte array into a Template.
671
- * @param {Uint8Array} content
433
+ * Parses a MOL2 string into a Template.
434
+ * @param {string} content
672
435
  * @returns {Template}
673
436
  */
674
- static fromMol2Bytes(content) {
437
+ static fromMol2(content) {
675
438
  try {
676
439
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
677
- const ptr0 = passArray8ToWasm0(content, wasm.__wbindgen_export);
440
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
678
441
  const len0 = WASM_VECTOR_LEN;
679
442
  wasm.template_fromMol2(retptr, ptr0, len0);
680
443
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
@@ -689,45 +452,45 @@ export class Template {
689
452
  }
690
453
  }
691
454
  /**
692
- * Returns the template name (residue code).
693
- * @returns {string}
455
+ * Parses a MOL2 byte array into a Template.
456
+ * @param {Uint8Array} content
457
+ * @returns {Template}
694
458
  */
695
- get name() {
696
- let deferred1_0;
697
- let deferred1_1;
459
+ static fromMol2Bytes(content) {
698
460
  try {
699
461
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
700
- wasm.template_name(retptr, this.__wbg_ptr);
462
+ const ptr0 = passArray8ToWasm0(content, wasm.__wbindgen_export);
463
+ const len0 = WASM_VECTOR_LEN;
464
+ wasm.template_fromMol2Bytes(retptr, ptr0, len0);
701
465
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
702
466
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
703
- deferred1_0 = r0;
704
- deferred1_1 = r1;
705
- return getStringFromWasm0(r0, r1);
467
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
468
+ if (r2) {
469
+ throw takeObject(r1);
470
+ }
471
+ return Template.__wrap(r0);
706
472
  } finally {
707
473
  wasm.__wbindgen_add_to_stack_pointer(16);
708
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
709
474
  }
710
475
  }
711
476
  /**
712
- * Parses a MOL2 string into a Template.
713
- * @param {string} content
714
- * @returns {Template}
477
+ * Returns the template name (residue code).
478
+ * @returns {string}
715
479
  */
716
- static fromMol2(content) {
480
+ get name() {
481
+ let deferred1_0;
482
+ let deferred1_1;
717
483
  try {
718
484
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
719
- const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
720
- const len0 = WASM_VECTOR_LEN;
721
- wasm.template_fromMol2(retptr, ptr0, len0);
485
+ wasm.template_name(retptr, this.__wbg_ptr);
722
486
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
723
487
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
724
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
725
- if (r2) {
726
- throw takeObject(r1);
727
- }
728
- return Template.__wrap(r0);
488
+ deferred1_0 = r0;
489
+ deferred1_1 = r1;
490
+ return getStringFromWasm0(r0, r1);
729
491
  } finally {
730
492
  wasm.__wbindgen_add_to_stack_pointer(16);
493
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
731
494
  }
732
495
  }
733
496
  }
@@ -762,28 +525,6 @@ export class Topology {
762
525
  const ret = wasm.topology_bondCount(this.__wbg_ptr);
763
526
  return ret >>> 0;
764
527
  }
765
- /**
766
- * Serializes to PDB format as bytes.
767
- * @returns {Uint8Array}
768
- */
769
- toPdbBytes() {
770
- try {
771
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
772
- wasm.topology_toPdbBytes(retptr, this.__wbg_ptr);
773
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
774
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
775
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
776
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
777
- if (r3) {
778
- throw takeObject(r2);
779
- }
780
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
781
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
782
- return v1;
783
- } finally {
784
- wasm.__wbindgen_add_to_stack_pointer(16);
785
- }
786
- }
787
528
  /**
788
529
  * Creates a Topology from a Structure.
789
530
  * @param {Structure} structure
@@ -809,6 +550,42 @@ export class Topology {
809
550
  wasm.__wbindgen_add_to_stack_pointer(16);
810
551
  }
811
552
  }
553
+ /**
554
+ * Returns a copy of the underlying structure.
555
+ * @returns {Structure}
556
+ */
557
+ get structure() {
558
+ const ret = wasm.topology_structure(this.__wbg_ptr);
559
+ return Structure.__wrap(ret);
560
+ }
561
+ /**
562
+ * Serializes to mmCIF format with struct_conn records.
563
+ * @returns {string}
564
+ */
565
+ toMmcif() {
566
+ let deferred2_0;
567
+ let deferred2_1;
568
+ try {
569
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
570
+ wasm.topology_toMmcif(retptr, this.__wbg_ptr);
571
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
572
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
573
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
574
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
575
+ var ptr1 = r0;
576
+ var len1 = r1;
577
+ if (r3) {
578
+ ptr1 = 0; len1 = 0;
579
+ throw takeObject(r2);
580
+ }
581
+ deferred2_0 = ptr1;
582
+ deferred2_1 = len1;
583
+ return getStringFromWasm0(ptr1, len1);
584
+ } finally {
585
+ wasm.__wbindgen_add_to_stack_pointer(16);
586
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
587
+ }
588
+ }
812
589
  /**
813
590
  * Serializes to mmCIF format as bytes.
814
591
  * @returns {Uint8Array}
@@ -860,41 +637,27 @@ export class Topology {
860
637
  }
861
638
  }
862
639
  /**
863
- * Serializes to mmCIF format with struct_conn records.
864
- * @returns {string}
640
+ * Serializes to PDB format as bytes.
641
+ * @returns {Uint8Array}
865
642
  */
866
- toMmcif() {
867
- let deferred2_0;
868
- let deferred2_1;
643
+ toPdbBytes() {
869
644
  try {
870
645
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
871
- wasm.topology_toMmcif(retptr, this.__wbg_ptr);
646
+ wasm.topology_toPdbBytes(retptr, this.__wbg_ptr);
872
647
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
873
648
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
874
649
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
875
650
  var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
876
- var ptr1 = r0;
877
- var len1 = r1;
878
651
  if (r3) {
879
- ptr1 = 0; len1 = 0;
880
652
  throw takeObject(r2);
881
653
  }
882
- deferred2_0 = ptr1;
883
- deferred2_1 = len1;
884
- return getStringFromWasm0(ptr1, len1);
654
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
655
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
656
+ return v1;
885
657
  } finally {
886
658
  wasm.__wbindgen_add_to_stack_pointer(16);
887
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
888
659
  }
889
660
  }
890
- /**
891
- * Returns a copy of the underlying structure.
892
- * @returns {Structure}
893
- */
894
- get structure() {
895
- const ret = wasm.topology_structure(this.__wbg_ptr);
896
- return Structure.__wrap(ret);
897
- }
898
661
  }
899
662
  if (Symbol.dispose) Topology.prototype[Symbol.dispose] = Topology.prototype.free;
900
663
 
@@ -908,273 +671,461 @@ if (Symbol.dispose) Topology.prototype[Symbol.dispose] = Topology.prototype.free
908
671
  export function init() {
909
672
  wasm.init();
910
673
  }
911
-
912
- export function __wbg_Error_52673b7de5a0ca89(arg0, arg1) {
674
+ export function __wbg_Error_55538483de6e3abe(arg0, arg1) {
913
675
  const ret = Error(getStringFromWasm0(arg0, arg1));
914
676
  return addHeapObject(ret);
915
- };
916
-
917
- export function __wbg_Number_2d1dcfcf4ec51736(arg0) {
677
+ }
678
+ export function __wbg_Number_f257194b7002d6f9(arg0) {
918
679
  const ret = Number(getObject(arg0));
919
680
  return ret;
920
- };
921
-
922
- export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
681
+ }
682
+ export function __wbg_String_8564e559799eccda(arg0, arg1) {
923
683
  const ret = String(getObject(arg1));
924
684
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
925
685
  const len1 = WASM_VECTOR_LEN;
926
686
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
927
687
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
928
- };
929
-
930
- export function __wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d(arg0, arg1) {
688
+ }
689
+ export function __wbg___wbindgen_bigint_get_as_i64_a738e80c0fe6f6a7(arg0, arg1) {
931
690
  const v = getObject(arg1);
932
691
  const ret = typeof(v) === 'bigint' ? v : undefined;
933
692
  getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
934
693
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
935
- };
936
-
937
- export function __wbg___wbindgen_boolean_get_dea25b33882b895b(arg0) {
694
+ }
695
+ export function __wbg___wbindgen_boolean_get_fe2a24fdfdb4064f(arg0) {
938
696
  const v = getObject(arg0);
939
697
  const ret = typeof(v) === 'boolean' ? v : undefined;
940
698
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
941
- };
942
-
943
- export function __wbg___wbindgen_debug_string_adfb662ae34724b6(arg0, arg1) {
699
+ }
700
+ export function __wbg___wbindgen_debug_string_d89627202d0155b7(arg0, arg1) {
944
701
  const ret = debugString(getObject(arg1));
945
702
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
946
703
  const len1 = WASM_VECTOR_LEN;
947
704
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
948
705
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
949
- };
950
-
951
- export function __wbg___wbindgen_in_0d3e1e8f0c669317(arg0, arg1) {
706
+ }
707
+ export function __wbg___wbindgen_in_fe3eb6a509f75744(arg0, arg1) {
952
708
  const ret = getObject(arg0) in getObject(arg1);
953
709
  return ret;
954
- };
955
-
956
- export function __wbg___wbindgen_is_bigint_0e1a2e3f55cfae27(arg0) {
710
+ }
711
+ export function __wbg___wbindgen_is_bigint_ca270ac12ef71091(arg0) {
957
712
  const ret = typeof(getObject(arg0)) === 'bigint';
958
713
  return ret;
959
- };
960
-
961
- export function __wbg___wbindgen_is_function_8d400b8b1af978cd(arg0) {
714
+ }
715
+ export function __wbg___wbindgen_is_function_2a95406423ea8626(arg0) {
962
716
  const ret = typeof(getObject(arg0)) === 'function';
963
717
  return ret;
964
- };
965
-
966
- export function __wbg___wbindgen_is_object_ce774f3490692386(arg0) {
718
+ }
719
+ export function __wbg___wbindgen_is_object_59a002e76b059312(arg0) {
967
720
  const val = getObject(arg0);
968
721
  const ret = typeof(val) === 'object' && val !== null;
969
722
  return ret;
970
- };
971
-
972
- export function __wbg___wbindgen_is_undefined_f6b95eab589e0269(arg0) {
723
+ }
724
+ export function __wbg___wbindgen_is_undefined_87a3a837f331fef5(arg0) {
973
725
  const ret = getObject(arg0) === undefined;
974
726
  return ret;
975
- };
976
-
977
- export function __wbg___wbindgen_jsval_eq_b6101cc9cef1fe36(arg0, arg1) {
727
+ }
728
+ export function __wbg___wbindgen_jsval_eq_eedd705f9f2a4f35(arg0, arg1) {
978
729
  const ret = getObject(arg0) === getObject(arg1);
979
730
  return ret;
980
- };
981
-
982
- export function __wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d(arg0, arg1) {
731
+ }
732
+ export function __wbg___wbindgen_jsval_loose_eq_cf851f110c48f9ba(arg0, arg1) {
983
733
  const ret = getObject(arg0) == getObject(arg1);
984
734
  return ret;
985
- };
986
-
987
- export function __wbg___wbindgen_number_get_9619185a74197f95(arg0, arg1) {
735
+ }
736
+ export function __wbg___wbindgen_number_get_769f3676dc20c1d7(arg0, arg1) {
988
737
  const obj = getObject(arg1);
989
738
  const ret = typeof(obj) === 'number' ? obj : undefined;
990
739
  getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
991
740
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
992
- };
993
-
994
- export function __wbg___wbindgen_string_get_a2a31e16edf96e42(arg0, arg1) {
741
+ }
742
+ export function __wbg___wbindgen_string_get_f1161390414f9b59(arg0, arg1) {
995
743
  const obj = getObject(arg1);
996
744
  const ret = typeof(obj) === 'string' ? obj : undefined;
997
745
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
998
746
  var len1 = WASM_VECTOR_LEN;
999
747
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1000
748
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1001
- };
1002
-
1003
- export function __wbg___wbindgen_throw_dd24417ed36fc46e(arg0, arg1) {
749
+ }
750
+ export function __wbg___wbindgen_throw_5549492daedad139(arg0, arg1) {
1004
751
  throw new Error(getStringFromWasm0(arg0, arg1));
1005
- };
1006
-
1007
- export function __wbg_call_abb4ff46ce38be40() { return handleError(function (arg0, arg1) {
752
+ }
753
+ export function __wbg_call_6ae20895a60069a2() { return handleError(function (arg0, arg1) {
1008
754
  const ret = getObject(arg0).call(getObject(arg1));
1009
755
  return addHeapObject(ret);
1010
- }, arguments) };
1011
-
1012
- export function __wbg_done_62ea16af4ce34b24(arg0) {
756
+ }, arguments); }
757
+ export function __wbg_done_19f92cb1f8738aba(arg0) {
1013
758
  const ret = getObject(arg0).done;
1014
759
  return ret;
1015
- };
760
+ }
761
+ export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
762
+ let deferred0_0;
763
+ let deferred0_1;
764
+ try {
765
+ deferred0_0 = arg0;
766
+ deferred0_1 = arg1;
767
+ console.error(getStringFromWasm0(arg0, arg1));
768
+ } finally {
769
+ wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
770
+ }
771
+ }
772
+ export function __wbg_getRandomValues_3f44b700395062e5() { return handleError(function (arg0, arg1) {
773
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
774
+ }, arguments); }
775
+ export function __wbg_get_a50328e7325d7f9b() { return handleError(function (arg0, arg1) {
776
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
777
+ return addHeapObject(ret);
778
+ }, arguments); }
779
+ export function __wbg_get_unchecked_7c6bbabf5b0b1fbf(arg0, arg1) {
780
+ const ret = getObject(arg0)[arg1 >>> 0];
781
+ return addHeapObject(ret);
782
+ }
783
+ export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
784
+ const ret = getObject(arg0)[getObject(arg1)];
785
+ return addHeapObject(ret);
786
+ }
787
+ export function __wbg_instanceof_ArrayBuffer_8d855993947fc3a2(arg0) {
788
+ let result;
789
+ try {
790
+ result = getObject(arg0) instanceof ArrayBuffer;
791
+ } catch (_) {
792
+ result = false;
793
+ }
794
+ const ret = result;
795
+ return ret;
796
+ }
797
+ export function __wbg_instanceof_Uint8Array_ce24d58a5f4bdcc3(arg0) {
798
+ let result;
799
+ try {
800
+ result = getObject(arg0) instanceof Uint8Array;
801
+ } catch (_) {
802
+ result = false;
803
+ }
804
+ const ret = result;
805
+ return ret;
806
+ }
807
+ export function __wbg_isArray_867202cf8f195ed8(arg0) {
808
+ const ret = Array.isArray(getObject(arg0));
809
+ return ret;
810
+ }
811
+ export function __wbg_isSafeInteger_1dfae065cbfe1915(arg0) {
812
+ const ret = Number.isSafeInteger(getObject(arg0));
813
+ return ret;
814
+ }
815
+ export function __wbg_iterator_54661826e186eb6a() {
816
+ const ret = Symbol.iterator;
817
+ return addHeapObject(ret);
818
+ }
819
+ export function __wbg_length_e6e1633fbea6cfa9(arg0) {
820
+ const ret = getObject(arg0).length;
821
+ return ret;
822
+ }
823
+ export function __wbg_length_fae3e439140f48a4(arg0) {
824
+ const ret = getObject(arg0).length;
825
+ return ret;
826
+ }
827
+ export function __wbg_new_1d96678aaacca32e(arg0) {
828
+ const ret = new Uint8Array(getObject(arg0));
829
+ return addHeapObject(ret);
830
+ }
831
+ export function __wbg_new_227d7c05414eb861() {
832
+ const ret = new Error();
833
+ return addHeapObject(ret);
834
+ }
835
+ export function __wbg_new_4370be21fa2b2f80() {
836
+ const ret = new Array();
837
+ return addHeapObject(ret);
838
+ }
839
+ export function __wbg_new_48e1d86cfd30c8e7() {
840
+ const ret = new Object();
841
+ return addHeapObject(ret);
842
+ }
843
+ export function __wbg_next_55d835fe0ab5b3e7(arg0) {
844
+ const ret = getObject(arg0).next;
845
+ return addHeapObject(ret);
846
+ }
847
+ export function __wbg_next_e34cfb9df1518d7c() { return handleError(function (arg0) {
848
+ const ret = getObject(arg0).next();
849
+ return addHeapObject(ret);
850
+ }, arguments); }
851
+ export function __wbg_prototypesetcall_3875d54d12ef2eec(arg0, arg1, arg2) {
852
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
853
+ }
854
+ export function __wbg_set_4702dfa37c77f492(arg0, arg1, arg2) {
855
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
856
+ }
857
+ export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
858
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
859
+ }
860
+ export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
861
+ const ret = getObject(arg1).stack;
862
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
863
+ const len1 = WASM_VECTOR_LEN;
864
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
865
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
866
+ }
867
+ export function __wbg_template_unwrap(arg0) {
868
+ const ret = Template.__unwrap(getObject(arg0));
869
+ return ret;
870
+ }
871
+ export function __wbg_value_d5b248ce8419bd1b(arg0) {
872
+ const ret = getObject(arg0).value;
873
+ return addHeapObject(ret);
874
+ }
875
+ export function __wbindgen_cast_0000000000000001(arg0) {
876
+ // Cast intrinsic for `F64 -> Externref`.
877
+ const ret = arg0;
878
+ return addHeapObject(ret);
879
+ }
880
+ export function __wbindgen_cast_0000000000000002(arg0, arg1) {
881
+ // Cast intrinsic for `Ref(String) -> Externref`.
882
+ const ret = getStringFromWasm0(arg0, arg1);
883
+ return addHeapObject(ret);
884
+ }
885
+ export function __wbindgen_cast_0000000000000003(arg0) {
886
+ // Cast intrinsic for `U64 -> Externref`.
887
+ const ret = BigInt.asUintN(64, arg0);
888
+ return addHeapObject(ret);
889
+ }
890
+ export function __wbindgen_object_clone_ref(arg0) {
891
+ const ret = getObject(arg0);
892
+ return addHeapObject(ret);
893
+ }
894
+ export function __wbindgen_object_drop_ref(arg0) {
895
+ takeObject(arg0);
896
+ }
897
+ const StructureFinalization = (typeof FinalizationRegistry === 'undefined')
898
+ ? { register: () => {}, unregister: () => {} }
899
+ : new FinalizationRegistry(ptr => wasm.__wbg_structure_free(ptr >>> 0, 1));
900
+ const TemplateFinalization = (typeof FinalizationRegistry === 'undefined')
901
+ ? { register: () => {}, unregister: () => {} }
902
+ : new FinalizationRegistry(ptr => wasm.__wbg_template_free(ptr >>> 0, 1));
903
+ const TopologyFinalization = (typeof FinalizationRegistry === 'undefined')
904
+ ? { register: () => {}, unregister: () => {} }
905
+ : new FinalizationRegistry(ptr => wasm.__wbg_topology_free(ptr >>> 0, 1));
906
+
907
+ function addHeapObject(obj) {
908
+ if (heap_next === heap.length) heap.push(heap.length + 1);
909
+ const idx = heap_next;
910
+ heap_next = heap[idx];
911
+
912
+ heap[idx] = obj;
913
+ return idx;
914
+ }
915
+
916
+ function _assertClass(instance, klass) {
917
+ if (!(instance instanceof klass)) {
918
+ throw new Error(`expected instance of ${klass.name}`);
919
+ }
920
+ }
1016
921
 
1017
- export function __wbg_error_7534b8e9a36f1ab4(arg0, arg1) {
1018
- let deferred0_0;
1019
- let deferred0_1;
1020
- try {
1021
- deferred0_0 = arg0;
1022
- deferred0_1 = arg1;
1023
- console.error(getStringFromWasm0(arg0, arg1));
1024
- } finally {
1025
- wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
922
+ function debugString(val) {
923
+ // primitive types
924
+ const type = typeof val;
925
+ if (type == 'number' || type == 'boolean' || val == null) {
926
+ return `${val}`;
927
+ }
928
+ if (type == 'string') {
929
+ return `"${val}"`;
930
+ }
931
+ if (type == 'symbol') {
932
+ const description = val.description;
933
+ if (description == null) {
934
+ return 'Symbol';
935
+ } else {
936
+ return `Symbol(${description})`;
937
+ }
938
+ }
939
+ if (type == 'function') {
940
+ const name = val.name;
941
+ if (typeof name == 'string' && name.length > 0) {
942
+ return `Function(${name})`;
943
+ } else {
944
+ return 'Function';
945
+ }
946
+ }
947
+ // objects
948
+ if (Array.isArray(val)) {
949
+ const length = val.length;
950
+ let debug = '[';
951
+ if (length > 0) {
952
+ debug += debugString(val[0]);
953
+ }
954
+ for(let i = 1; i < length; i++) {
955
+ debug += ', ' + debugString(val[i]);
956
+ }
957
+ debug += ']';
958
+ return debug;
959
+ }
960
+ // Test for built-in
961
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
962
+ let className;
963
+ if (builtInMatches && builtInMatches.length > 1) {
964
+ className = builtInMatches[1];
965
+ } else {
966
+ // Failed to match the standard '[object ClassName]'
967
+ return toString.call(val);
968
+ }
969
+ if (className == 'Object') {
970
+ // we're a user defined class or Object
971
+ // JSON.stringify avoids problems with cycles, and is generally much
972
+ // easier than looping through ownProperties of `val`.
973
+ try {
974
+ return 'Object(' + JSON.stringify(val) + ')';
975
+ } catch (_) {
976
+ return 'Object';
977
+ }
1026
978
  }
1027
- };
979
+ // errors
980
+ if (val instanceof Error) {
981
+ return `${val.name}: ${val.message}\n${val.stack}`;
982
+ }
983
+ // TODO we could test for more things here, like `Set`s and `Map`s.
984
+ return className;
985
+ }
1028
986
 
1029
- export function __wbg_getRandomValues_1c61fac11405ffdc() { return handleError(function (arg0, arg1) {
1030
- globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
1031
- }, arguments) };
987
+ function dropObject(idx) {
988
+ if (idx < 1028) return;
989
+ heap[idx] = heap_next;
990
+ heap_next = idx;
991
+ }
1032
992
 
1033
- export function __wbg_get_6b7bd52aca3f9671(arg0, arg1) {
1034
- const ret = getObject(arg0)[arg1 >>> 0];
1035
- return addHeapObject(ret);
1036
- };
993
+ function getArrayU8FromWasm0(ptr, len) {
994
+ ptr = ptr >>> 0;
995
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
996
+ }
1037
997
 
1038
- export function __wbg_get_af9dab7e9603ea93() { return handleError(function (arg0, arg1) {
1039
- const ret = Reflect.get(getObject(arg0), getObject(arg1));
1040
- return addHeapObject(ret);
1041
- }, arguments) };
998
+ let cachedDataViewMemory0 = null;
999
+ function getDataViewMemory0() {
1000
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1001
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
1002
+ }
1003
+ return cachedDataViewMemory0;
1004
+ }
1042
1005
 
1043
- export function __wbg_get_with_ref_key_1dc361bd10053bfe(arg0, arg1) {
1044
- const ret = getObject(arg0)[getObject(arg1)];
1045
- return addHeapObject(ret);
1046
- };
1006
+ function getStringFromWasm0(ptr, len) {
1007
+ ptr = ptr >>> 0;
1008
+ return decodeText(ptr, len);
1009
+ }
1047
1010
 
1048
- export function __wbg_instanceof_ArrayBuffer_f3320d2419cd0355(arg0) {
1049
- let result;
1050
- try {
1051
- result = getObject(arg0) instanceof ArrayBuffer;
1052
- } catch (_) {
1053
- result = false;
1011
+ let cachedUint8ArrayMemory0 = null;
1012
+ function getUint8ArrayMemory0() {
1013
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1014
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1054
1015
  }
1055
- const ret = result;
1056
- return ret;
1057
- };
1016
+ return cachedUint8ArrayMemory0;
1017
+ }
1058
1018
 
1059
- export function __wbg_instanceof_Uint8Array_da54ccc9d3e09434(arg0) {
1060
- let result;
1019
+ function getObject(idx) { return heap[idx]; }
1020
+
1021
+ function handleError(f, args) {
1061
1022
  try {
1062
- result = getObject(arg0) instanceof Uint8Array;
1063
- } catch (_) {
1064
- result = false;
1023
+ return f.apply(this, args);
1024
+ } catch (e) {
1025
+ wasm.__wbindgen_export3(addHeapObject(e));
1065
1026
  }
1066
- const ret = result;
1067
- return ret;
1068
- };
1069
-
1070
- export function __wbg_isArray_51fd9e6422c0a395(arg0) {
1071
- const ret = Array.isArray(getObject(arg0));
1072
- return ret;
1073
- };
1074
-
1075
- export function __wbg_isSafeInteger_ae7d3f054d55fa16(arg0) {
1076
- const ret = Number.isSafeInteger(getObject(arg0));
1077
- return ret;
1078
- };
1079
-
1080
- export function __wbg_iterator_27b7c8b35ab3e86b() {
1081
- const ret = Symbol.iterator;
1082
- return addHeapObject(ret);
1083
- };
1027
+ }
1084
1028
 
1085
- export function __wbg_length_22ac23eaec9d8053(arg0) {
1086
- const ret = getObject(arg0).length;
1087
- return ret;
1088
- };
1029
+ let heap = new Array(1024).fill(undefined);
1030
+ heap.push(undefined, null, true, false);
1089
1031
 
1090
- export function __wbg_length_d45040a40c570362(arg0) {
1091
- const ret = getObject(arg0).length;
1092
- return ret;
1093
- };
1032
+ let heap_next = heap.length;
1094
1033
 
1095
- export function __wbg_new_1ba21ce319a06297() {
1096
- const ret = new Object();
1097
- return addHeapObject(ret);
1098
- };
1034
+ function isLikeNone(x) {
1035
+ return x === undefined || x === null;
1036
+ }
1099
1037
 
1100
- export function __wbg_new_25f239778d6112b9() {
1101
- const ret = new Array();
1102
- return addHeapObject(ret);
1103
- };
1038
+ function passArray8ToWasm0(arg, malloc) {
1039
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1040
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1041
+ WASM_VECTOR_LEN = arg.length;
1042
+ return ptr;
1043
+ }
1104
1044
 
1105
- export function __wbg_new_6421f6084cc5bc5a(arg0) {
1106
- const ret = new Uint8Array(getObject(arg0));
1107
- return addHeapObject(ret);
1108
- };
1045
+ function passArrayJsValueToWasm0(array, malloc) {
1046
+ const ptr = malloc(array.length * 4, 4) >>> 0;
1047
+ const mem = getDataViewMemory0();
1048
+ for (let i = 0; i < array.length; i++) {
1049
+ mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
1050
+ }
1051
+ WASM_VECTOR_LEN = array.length;
1052
+ return ptr;
1053
+ }
1109
1054
 
1110
- export function __wbg_new_8a6f238a6ece86ea() {
1111
- const ret = new Error();
1112
- return addHeapObject(ret);
1113
- };
1055
+ function passStringToWasm0(arg, malloc, realloc) {
1056
+ if (realloc === undefined) {
1057
+ const buf = cachedTextEncoder.encode(arg);
1058
+ const ptr = malloc(buf.length, 1) >>> 0;
1059
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1060
+ WASM_VECTOR_LEN = buf.length;
1061
+ return ptr;
1062
+ }
1114
1063
 
1115
- export function __wbg_next_138a17bbf04e926c(arg0) {
1116
- const ret = getObject(arg0).next;
1117
- return addHeapObject(ret);
1118
- };
1064
+ let len = arg.length;
1065
+ let ptr = malloc(len, 1) >>> 0;
1119
1066
 
1120
- export function __wbg_next_3cfe5c0fe2a4cc53() { return handleError(function (arg0) {
1121
- const ret = getObject(arg0).next();
1122
- return addHeapObject(ret);
1123
- }, arguments) };
1067
+ const mem = getUint8ArrayMemory0();
1124
1068
 
1125
- export function __wbg_prototypesetcall_dfe9b766cdc1f1fd(arg0, arg1, arg2) {
1126
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
1127
- };
1069
+ let offset = 0;
1128
1070
 
1129
- export function __wbg_set_3f1d0b984ed272ed(arg0, arg1, arg2) {
1130
- getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
1131
- };
1071
+ for (; offset < len; offset++) {
1072
+ const code = arg.charCodeAt(offset);
1073
+ if (code > 0x7F) break;
1074
+ mem[ptr + offset] = code;
1075
+ }
1076
+ if (offset !== len) {
1077
+ if (offset !== 0) {
1078
+ arg = arg.slice(offset);
1079
+ }
1080
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1081
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1082
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1132
1083
 
1133
- export function __wbg_set_7df433eea03a5c14(arg0, arg1, arg2) {
1134
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
1135
- };
1084
+ offset += ret.written;
1085
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1086
+ }
1136
1087
 
1137
- export function __wbg_stack_0ed75d68575b0f3c(arg0, arg1) {
1138
- const ret = getObject(arg1).stack;
1139
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1140
- const len1 = WASM_VECTOR_LEN;
1141
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1142
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1143
- };
1088
+ WASM_VECTOR_LEN = offset;
1089
+ return ptr;
1090
+ }
1144
1091
 
1145
- export function __wbg_template_unwrap(arg0) {
1146
- const ret = Template.__unwrap(getObject(arg0));
1092
+ function takeObject(idx) {
1093
+ const ret = getObject(idx);
1094
+ dropObject(idx);
1147
1095
  return ret;
1148
- };
1096
+ }
1149
1097
 
1150
- export function __wbg_value_57b7b035e117f7ee(arg0) {
1151
- const ret = getObject(arg0).value;
1152
- return addHeapObject(ret);
1153
- };
1098
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1099
+ cachedTextDecoder.decode();
1100
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1101
+ let numBytesDecoded = 0;
1102
+ function decodeText(ptr, len) {
1103
+ numBytesDecoded += len;
1104
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1105
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1106
+ cachedTextDecoder.decode();
1107
+ numBytesDecoded = len;
1108
+ }
1109
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1110
+ }
1154
1111
 
1155
- export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
1156
- // Cast intrinsic for `Ref(String) -> Externref`.
1157
- const ret = getStringFromWasm0(arg0, arg1);
1158
- return addHeapObject(ret);
1159
- };
1112
+ const cachedTextEncoder = new TextEncoder();
1160
1113
 
1161
- export function __wbindgen_cast_4625c577ab2ec9ee(arg0) {
1162
- // Cast intrinsic for `U64 -> Externref`.
1163
- const ret = BigInt.asUintN(64, arg0);
1164
- return addHeapObject(ret);
1165
- };
1114
+ if (!('encodeInto' in cachedTextEncoder)) {
1115
+ cachedTextEncoder.encodeInto = function (arg, view) {
1116
+ const buf = cachedTextEncoder.encode(arg);
1117
+ view.set(buf);
1118
+ return {
1119
+ read: arg.length,
1120
+ written: buf.length
1121
+ };
1122
+ };
1123
+ }
1166
1124
 
1167
- export function __wbindgen_cast_d6cd19b81560fd6e(arg0) {
1168
- // Cast intrinsic for `F64 -> Externref`.
1169
- const ret = arg0;
1170
- return addHeapObject(ret);
1171
- };
1125
+ let WASM_VECTOR_LEN = 0;
1172
1126
 
1173
- export function __wbindgen_object_clone_ref(arg0) {
1174
- const ret = getObject(arg0);
1175
- return addHeapObject(ret);
1176
- };
1177
1127
 
1178
- export function __wbindgen_object_drop_ref(arg0) {
1179
- takeObject(arg0);
1180
- };
1128
+ let wasm;
1129
+ export function __wbg_set_wasm(val) {
1130
+ wasm = val;
1131
+ }