@molcrafts/molrs 0.0.1 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/molrs.js CHANGED
@@ -1,1403 +1,9 @@
1
1
  /* @ts-self-types="./molrs.d.ts" */
2
2
 
3
- /**
4
- * A block containing columnar data.
5
- */
6
- export class Block {
7
- static __wrap(ptr) {
8
- ptr = ptr >>> 0;
9
- const obj = Object.create(Block.prototype);
10
- obj.__wbg_ptr = ptr;
11
- BlockFinalization.register(obj, obj.__wbg_ptr, obj);
12
- return obj;
13
- }
14
- __destroy_into_raw() {
15
- const ptr = this.__wbg_ptr;
16
- this.__wbg_ptr = 0;
17
- BlockFinalization.unregister(this);
18
- return ptr;
19
- }
20
- free() {
21
- const ptr = this.__destroy_into_raw();
22
- wasm.__wbg_block_free(ptr, 0);
23
- }
24
- /**
25
- * Gets an f32 column as Float32Array.
26
- * @param {string} key
27
- * @returns {Float32Array}
28
- */
29
- getColumnF32(key) {
30
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
31
- const len0 = WASM_VECTOR_LEN;
32
- const ret = wasm.block_getColumnF32(this.__wbg_ptr, ptr0, len0);
33
- if (ret[2]) {
34
- throw takeFromExternrefTable0(ret[1]);
35
- }
36
- return takeFromExternrefTable0(ret[0]);
37
- }
38
- /**
39
- * Gets an f32 column with shape (for compatibility).
40
- * @param {string} key
41
- * @returns {any}
42
- */
43
- getColumnF32WithShape(key) {
44
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
45
- const len0 = WASM_VECTOR_LEN;
46
- const ret = wasm.block_getColumnF32WithShape(this.__wbg_ptr, ptr0, len0);
47
- if (ret[2]) {
48
- throw takeFromExternrefTable0(ret[1]);
49
- }
50
- return takeFromExternrefTable0(ret[0]);
51
- }
52
- /**
53
- * Gets an i64 column.
54
- * @param {string} key
55
- * @returns {BigInt64Array}
56
- */
57
- getColumnI64(key) {
58
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
59
- const len0 = WASM_VECTOR_LEN;
60
- const ret = wasm.block_getColumnI64(this.__wbg_ptr, ptr0, len0);
61
- if (ret[2]) {
62
- throw takeFromExternrefTable0(ret[1]);
63
- }
64
- return takeFromExternrefTable0(ret[0]);
65
- }
66
- /**
67
- * Gets a string column.
68
- * @param {string} key
69
- * @returns {Array<any> | undefined}
70
- */
71
- getColumnStrings(key) {
72
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
73
- const len0 = WASM_VECTOR_LEN;
74
- const ret = wasm.block_getColumnStrings(this.__wbg_ptr, ptr0, len0);
75
- return ret;
76
- }
77
- /**
78
- * Gets a u32 column.
79
- * @param {string} key
80
- * @returns {Uint32Array}
81
- */
82
- getColumnU32(key) {
83
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
84
- const len0 = WASM_VECTOR_LEN;
85
- const ret = wasm.block_getColumnU32(this.__wbg_ptr, ptr0, len0);
86
- if (ret[2]) {
87
- throw takeFromExternrefTable0(ret[1]);
88
- }
89
- return takeFromExternrefTable0(ret[0]);
90
- }
91
- /**
92
- * Gets a u8 column.
93
- * @param {string} key
94
- * @returns {Uint8Array | undefined}
95
- */
96
- getColumnU8(key) {
97
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
98
- const len0 = WASM_VECTOR_LEN;
99
- const ret = wasm.block_getColumnU8(this.__wbg_ptr, ptr0, len0);
100
- return ret;
101
- }
102
- /**
103
- * Gets column keys.
104
- * @returns {Array<any>}
105
- */
106
- keys() {
107
- const ret = wasm.block_keys(this.__wbg_ptr);
108
- if (ret[2]) {
109
- throw takeFromExternrefTable0(ret[1]);
110
- }
111
- return takeFromExternrefTable0(ret[0]);
112
- }
113
- /**
114
- * Gets the number of columns.
115
- * @returns {number}
116
- */
117
- len() {
118
- const ret = wasm.block_len(this.__wbg_ptr);
119
- if (ret[2]) {
120
- throw takeFromExternrefTable0(ret[1]);
121
- }
122
- return ret[0] >>> 0;
123
- }
124
- /**
125
- * Creates a new empty Block.
126
- */
127
- constructor() {
128
- const ret = wasm.block_new();
129
- this.__wbg_ptr = ret >>> 0;
130
- BlockFinalization.register(this, this.__wbg_ptr, this);
131
- return this;
132
- }
133
- /**
134
- * Gets the number of rows.
135
- * @returns {number}
136
- */
137
- nrows() {
138
- const ret = wasm.block_nrows(this.__wbg_ptr);
139
- if (ret[2]) {
140
- throw takeFromExternrefTable0(ret[1]);
141
- }
142
- return ret[0] >>> 0;
143
- }
144
- /**
145
- * Renames a column.
146
- * @param {string} old_key
147
- * @param {string} new_key
148
- * @returns {boolean}
149
- */
150
- renameColumn(old_key, new_key) {
151
- const ptr0 = passStringToWasm0(old_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
152
- const len0 = WASM_VECTOR_LEN;
153
- const ptr1 = passStringToWasm0(new_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
154
- const len1 = WASM_VECTOR_LEN;
155
- const ret = wasm.block_renameColumn(this.__wbg_ptr, ptr0, len0, ptr1, len1);
156
- if (ret[2]) {
157
- throw takeFromExternrefTable0(ret[1]);
158
- }
159
- return ret[0] !== 0;
160
- }
161
- /**
162
- * Sets an f32 column.
163
- * @param {string} key
164
- * @param {Float32Array} data
165
- * @param {Uint32Array | null} [shape]
166
- */
167
- setColumnF32(key, data, shape) {
168
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
169
- const len0 = WASM_VECTOR_LEN;
170
- const ret = wasm.block_setColumnF32(this.__wbg_ptr, ptr0, len0, data, isLikeNone(shape) ? 0 : addToExternrefTable0(shape));
171
- if (ret[1]) {
172
- throw takeFromExternrefTable0(ret[0]);
173
- }
174
- }
175
- /**
176
- * Sets an i64 column.
177
- * @param {string} key
178
- * @param {BigInt64Array} data
179
- * @param {Uint32Array | null} [_shape]
180
- */
181
- setColumnI64(key, data, _shape) {
182
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
183
- const len0 = WASM_VECTOR_LEN;
184
- const ret = wasm.block_setColumnI64(this.__wbg_ptr, ptr0, len0, data, isLikeNone(_shape) ? 0 : addToExternrefTable0(_shape));
185
- if (ret[1]) {
186
- throw takeFromExternrefTable0(ret[0]);
187
- }
188
- }
189
- /**
190
- * Sets a string column.
191
- * @param {string} key
192
- * @param {Array<any>} data
193
- * @param {Uint32Array | null} [_shape]
194
- */
195
- setColumnStrings(key, data, _shape) {
196
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
197
- const len0 = WASM_VECTOR_LEN;
198
- const ret = wasm.block_setColumnStrings(this.__wbg_ptr, ptr0, len0, data, isLikeNone(_shape) ? 0 : addToExternrefTable0(_shape));
199
- if (ret[1]) {
200
- throw takeFromExternrefTable0(ret[0]);
201
- }
202
- }
203
- /**
204
- * Sets a u32 column.
205
- * @param {string} key
206
- * @param {Uint32Array} data
207
- * @param {Uint32Array | null} [_shape]
208
- */
209
- setColumnU32(key, data, _shape) {
210
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
211
- const len0 = WASM_VECTOR_LEN;
212
- const ret = wasm.block_setColumnU32(this.__wbg_ptr, ptr0, len0, data, isLikeNone(_shape) ? 0 : addToExternrefTable0(_shape));
213
- if (ret[1]) {
214
- throw takeFromExternrefTable0(ret[0]);
215
- }
216
- }
217
- /**
218
- * Sets a u8 column.
219
- * @param {string} key
220
- * @param {Uint8Array} data
221
- * @param {Uint32Array | null} [_shape]
222
- */
223
- setColumnU8(key, data, _shape) {
224
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
225
- const len0 = WASM_VECTOR_LEN;
226
- const ret = wasm.block_setColumnU8(this.__wbg_ptr, ptr0, len0, data, isLikeNone(_shape) ? 0 : addToExternrefTable0(_shape));
227
- if (ret[1]) {
228
- throw takeFromExternrefTable0(ret[0]);
229
- }
230
- }
231
- }
232
- if (Symbol.dispose) Block.prototype[Symbol.dispose] = Block.prototype.free;
233
-
234
- /**
235
- * Simulation box defining the periodic boundary conditions and coordinate transformations.
236
- *
237
- * Represents a parallelepiped defined by a 3x3 matrix `h` and an origin.
238
- * Supports periodic boundary conditions (PBC) independently in x, y, z directions.
239
- */
240
- export class Box {
241
- static __wrap(ptr) {
242
- ptr = ptr >>> 0;
243
- const obj = Object.create(Box.prototype);
244
- obj.__wbg_ptr = ptr;
245
- BoxFinalization.register(obj, obj.__wbg_ptr, obj);
246
- return obj;
247
- }
248
- __destroy_into_raw() {
249
- const ptr = this.__wbg_ptr;
250
- this.__wbg_ptr = 0;
251
- BoxFinalization.unregister(this);
252
- return ptr;
253
- }
254
- free() {
255
- const ptr = this.__destroy_into_raw();
256
- wasm.__wbg_box_free(ptr, 0);
257
- }
258
- /**
259
- * Create a cubic box.
260
- *
261
- * # Arguments
262
- * * `a` - Side length of the cube
263
- * * `origin` - 3D origin vector as Float32Array with 3 elements
264
- * * `pbc_x`, `pbc_y`, `pbc_z` - Periodic boundary conditions for each axis
265
- * @param {number} a
266
- * @param {Float32Array} origin
267
- * @param {boolean} pbc_x
268
- * @param {boolean} pbc_y
269
- * @param {boolean} pbc_z
270
- * @returns {Box}
271
- */
272
- static cube(a, origin, pbc_x, pbc_y, pbc_z) {
273
- const ret = wasm.box_cube(a, origin, pbc_x, pbc_y, pbc_z);
274
- if (ret[2]) {
275
- throw takeFromExternrefTable0(ret[1]);
276
- }
277
- return Box.__wrap(ret[0]);
278
- }
279
- /**
280
- * Calculate displacement vectors between two sets of coordinates.
281
- *
282
- * # Arguments
283
- * * `a` - F32View with Nx3 coordinates
284
- * * `b` - F32View with Nx3 coordinates
285
- * * `minimum_image` - If true, apply minimum image convention
286
- *
287
- * # Returns
288
- * F32View with Nx3 displacement vectors (b - a)
289
- * @param {F32View} a
290
- * @param {F32View} b
291
- * @param {boolean} minimum_image
292
- * @returns {F32View}
293
- */
294
- delta(a, b, minimum_image) {
295
- _assertClass(a, F32View);
296
- _assertClass(b, F32View);
297
- const ret = wasm.box_delta(this.__wbg_ptr, a.__wbg_ptr, b.__wbg_ptr, minimum_image);
298
- if (ret[2]) {
299
- throw takeFromExternrefTable0(ret[1]);
300
- }
301
- return F32View.__wrap(ret[0]);
302
- }
303
- /**
304
- * @returns {F32View}
305
- */
306
- get_corners() {
307
- const ret = wasm.box_get_corners(this.__wbg_ptr);
308
- return F32View.__wrap(ret);
309
- }
310
- /**
311
- * Get the box edge lengths as F32View [lx, ly, lz].
312
- * @returns {F32View}
313
- */
314
- lengths() {
315
- const ret = wasm.box_lengths(this.__wbg_ptr);
316
- return F32View.__wrap(ret);
317
- }
318
- /**
319
- * Create a new box from a 3x3 matrix and origin.
320
- *
321
- * # Arguments
322
- * * `h` - 3x3 matrix as Float32Array with 9 elements (row-major: [h00, h01, h02, h10, ...])
323
- * * `origin` - 3D origin vector as Float32Array with 3 elements [x, y, z]
324
- * * `pbc_x`, `pbc_y`, `pbc_z` - Periodic boundary conditions for each axis
325
- * @param {Float32Array} h
326
- * @param {Float32Array} origin
327
- * @param {boolean} pbc_x
328
- * @param {boolean} pbc_y
329
- * @param {boolean} pbc_z
330
- */
331
- constructor(h, origin, pbc_x, pbc_y, pbc_z) {
332
- const ret = wasm.box_new(h, origin, pbc_x, pbc_y, pbc_z);
333
- if (ret[2]) {
334
- throw takeFromExternrefTable0(ret[1]);
335
- }
336
- this.__wbg_ptr = ret[0] >>> 0;
337
- BoxFinalization.register(this, this.__wbg_ptr, this);
338
- return this;
339
- }
340
- /**
341
- * Get the box origin as F32View [x, y, z].
342
- * @returns {F32View}
343
- */
344
- origin() {
345
- const ret = wasm.box_origin(this.__wbg_ptr);
346
- return F32View.__wrap(ret);
347
- }
348
- /**
349
- * Create an orthorhombic box (rectangular box with axis-aligned edges).
350
- *
351
- * # Arguments
352
- * * `lengths` - Box dimensions as Float32Array with 3 elements [lx, ly, lz]
353
- * * `origin` - 3D origin vector as Float32Array with 3 elements
354
- * * `pbc_x`, `pbc_y`, `pbc_z` - Periodic boundary conditions for each axis
355
- * @param {Float32Array} lengths
356
- * @param {Float32Array} origin
357
- * @param {boolean} pbc_x
358
- * @param {boolean} pbc_y
359
- * @param {boolean} pbc_z
360
- * @returns {Box}
361
- */
362
- static ortho(lengths, origin, pbc_x, pbc_y, pbc_z) {
363
- const ret = wasm.box_ortho(lengths, origin, pbc_x, pbc_y, pbc_z);
364
- if (ret[2]) {
365
- throw takeFromExternrefTable0(ret[1]);
366
- }
367
- return Box.__wrap(ret[0]);
368
- }
369
- /**
370
- * Get the box tilt factors as F32View [xy, xz, yz].
371
- * @returns {F32View}
372
- */
373
- tilts() {
374
- const ret = wasm.box_tilts(this.__wbg_ptr);
375
- return F32View.__wrap(ret);
376
- }
377
- /**
378
- * Convert fractional coordinates to Cartesian coordinates.
379
- *
380
- * # Arguments
381
- * * `coords` - F32View with Nx3 coordinates
382
- *
383
- * # Returns
384
- * F32View with Nx3 Cartesian coordinates
385
- * @param {F32View} coords
386
- * @returns {F32View}
387
- */
388
- to_cart(coords) {
389
- _assertClass(coords, F32View);
390
- const ret = wasm.box_to_cart(this.__wbg_ptr, coords.__wbg_ptr);
391
- if (ret[2]) {
392
- throw takeFromExternrefTable0(ret[1]);
393
- }
394
- return F32View.__wrap(ret[0]);
395
- }
396
- /**
397
- * Convert Cartesian coordinates to fractional coordinates.
398
- *
399
- * # Arguments
400
- * * `coords` - F32View with Nx3 coordinates
401
- *
402
- * # Returns
403
- * F32View with Nx3 fractional coordinates
404
- * @param {F32View} coords
405
- * @returns {F32View}
406
- */
407
- to_frac(coords) {
408
- _assertClass(coords, F32View);
409
- const ret = wasm.box_to_frac(this.__wbg_ptr, coords.__wbg_ptr);
410
- if (ret[2]) {
411
- throw takeFromExternrefTable0(ret[1]);
412
- }
413
- return F32View.__wrap(ret[0]);
414
- }
415
- /**
416
- * Get the volume of the box.
417
- * @returns {number}
418
- */
419
- volume() {
420
- const ret = wasm.box_volume(this.__wbg_ptr);
421
- return ret;
422
- }
423
- /**
424
- * Wrap coordinates into the primary simulation box.
425
- *
426
- * # Arguments
427
- * * `coords` - F32View with Nx3 coordinates
428
- *
429
- * # Returns
430
- * F32View with Nx3 wrapped coordinates
431
- * @param {F32View} coords
432
- * @returns {F32View}
433
- */
434
- wrap(coords) {
435
- _assertClass(coords, F32View);
436
- const ret = wasm.box_wrap(this.__wbg_ptr, coords.__wbg_ptr);
437
- if (ret[2]) {
438
- throw takeFromExternrefTable0(ret[1]);
439
- }
440
- return F32View.__wrap(ret[0]);
441
- }
442
- }
443
- if (Symbol.dispose) Box.prototype[Symbol.dispose] = Box.prototype.free;
444
-
445
- /**
446
- * Zero-copy view over f32 array data shared between JavaScript and Rust.
447
- *
448
- * `F32View` provides a safe wrapper around f32 arrays that can be accessed from both
449
- * JavaScript and Rust without copying data. The data lives in WASM linear memory,
450
- * and JavaScript can create typed array views over this memory using `ptr()` and `len()`.
451
- *
452
- * # Memory Model
453
- *
454
- * - Data is stored in `Vec<f32>` in WASM linear memory (Rust heap)
455
- * - JavaScript creates `Float32Array` views using `ptr()` and `len()`
456
- * - No copying occurs when JavaScript reads/writes via these views
457
- * - **Important**: Pointers are only valid until WASM memory grows
458
- *
459
- * # Safety Considerations
460
- *
461
- * - Views should be short-lived (don't store across async boundaries)
462
- * - JavaScript must not modify the underlying array while Rust holds a reference
463
- * - WASM memory can grow/relocate, invalidating pointers
464
- *
465
- * # Example
466
- *
467
- * ```javascript
468
- * // Create a view for 1000 atoms with 3D coordinates
469
- * const view = new F32View([1000, 3]);
470
- *
471
- * // Access the data from JavaScript without copying
472
- * const mem = new Float32Array(wasmMemory.buffer, view.ptr(), view.len());
473
- * mem.set([1.0, 2.0, 3.0, ...]); // Write data
474
- *
475
- * // Pass to Rust for zero-copy processing
476
- * const wrapped = box.wrap(view);
477
- *
478
- * // Read results without copying
479
- * const result = new Float32Array(wasmMemory.buffer, wrapped.ptr(), wrapped.len());
480
- * ```
481
- */
482
- export class F32View {
483
- static __wrap(ptr) {
484
- ptr = ptr >>> 0;
485
- const obj = Object.create(F32View.prototype);
486
- obj.__wbg_ptr = ptr;
487
- F32ViewFinalization.register(obj, obj.__wbg_ptr, obj);
488
- return obj;
489
- }
490
- __destroy_into_raw() {
491
- const ptr = this.__wbg_ptr;
492
- this.__wbg_ptr = 0;
493
- F32ViewFinalization.unregister(this);
494
- return ptr;
495
- }
496
- free() {
497
- const ptr = this.__destroy_into_raw();
498
- wasm.__wbg_f32view_free(ptr, 0);
499
- }
500
- /**
501
- * Get the total number of elements in the view.
502
- *
503
- * Returns the product of all shape dimensions.
504
- * @returns {number}
505
- */
506
- len() {
507
- const ret = wasm.f32view_len(this.__wbg_ptr);
508
- return ret >>> 0;
509
- }
510
- /**
511
- * Create a new F32View with the given shape.
512
- *
513
- * Allocates a buffer in WASM linear memory with size = product of shape dimensions.
514
- *
515
- * # Arguments
516
- *
517
- * * `shape` - Dimensions of the array (e.g., `[1000, 3]` for Nx3 coordinates)
518
- *
519
- * # Example
520
- *
521
- * ```javascript
522
- * const view = new F32View([100, 3]); // 100 atoms, 3D coordinates
523
- * console.log(view.len()); // 300
524
- * ```
525
- * @param {Uint32Array} shape
526
- */
527
- constructor(shape) {
528
- const ptr0 = passArray32ToWasm0(shape, wasm.__wbindgen_malloc);
529
- const len0 = WASM_VECTOR_LEN;
530
- const ret = wasm.f32view_new(ptr0, len0);
531
- this.__wbg_ptr = ret >>> 0;
532
- F32ViewFinalization.register(this, this.__wbg_ptr, this);
533
- return this;
534
- }
535
- /**
536
- * Get a pointer to the underlying data for zero-copy access from JavaScript.
537
- *
538
- * # Returns
539
- *
540
- * A raw pointer to the first element of the data buffer.
541
- *
542
- * # Safety
543
- *
544
- * The pointer is only valid until the next WASM memory allocation.
545
- * JavaScript should create typed array views immediately and not store the pointer.
546
- *
547
- * # Example
548
- *
549
- * ```javascript
550
- * const view = new F32View([10, 3]);
551
- * const ptr = view.ptr();
552
- * const arr = new Float32Array(wasmMemory.buffer, ptr, view.len());
553
- * ```
554
- * @returns {number}
555
- */
556
- ptr() {
557
- const ret = wasm.f32view_ptr(this.__wbg_ptr);
558
- return ret >>> 0;
559
- }
560
- /**
561
- * Get the shape of the array (cloned for JS boundary).
562
- * @returns {Uint32Array}
563
- */
564
- shape() {
565
- const ret = wasm.f32view_shape(this.__wbg_ptr);
566
- var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
567
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
568
- return v1;
569
- }
570
- /**
571
- * Compute the sum of all elements (for testing).
572
- *
573
- * # Returns
574
- *
575
- * Sum of all elements in the view.
576
- * @returns {number}
577
- */
578
- sum() {
579
- const ret = wasm.f32view_sum(this.__wbg_ptr);
580
- return ret;
581
- }
582
- /**
583
- * Export the view data as a JavaScript Float32Array.
584
- *
585
- * Creates a new JavaScript array and copies the data.
586
- * Use this for compatibility or when you need an owned JavaScript array.
587
- *
588
- * # Returns
589
- *
590
- * A new Float32Array containing a copy of the data.
591
- *
592
- * # Example
593
- *
594
- * ```javascript
595
- * const view = new F32View([2, 3]);
596
- * // ... populate view ...
597
- * const arr = view.to_js_array(); // Copies data
598
- * ```
599
- * @returns {Float32Array}
600
- */
601
- to_js_array() {
602
- const ret = wasm.f32view_to_js_array(this.__wbg_ptr);
603
- return ret;
604
- }
605
- /**
606
- * Write data from a JavaScript Float32Array into this view.
607
- *
608
- * Copies data from the JavaScript array into WASM memory once.
609
- * The array length must match the view's total size.
610
- *
611
- * # Arguments
612
- *
613
- * * `arr` - JavaScript Float32Array to copy from
614
- *
615
- * # Errors
616
- *
617
- * Returns an error if the array length doesn't match the view size.
618
- *
619
- * # Example
620
- *
621
- * ```javascript
622
- * const view = new F32View([2, 3]);
623
- * const data = new Float32Array([1, 2, 3, 4, 5, 6]);
624
- * view.write_from(data);
625
- * ```
626
- * @param {Float32Array} arr
627
- */
628
- write_from(arr) {
629
- const ret = wasm.f32view_write_from(this.__wbg_ptr, arr);
630
- if (ret[1]) {
631
- throw takeFromExternrefTable0(ret[0]);
632
- }
633
- }
634
- }
635
- if (Symbol.dispose) F32View.prototype[Symbol.dispose] = F32View.prototype.free;
636
-
637
- /**
638
- * A frame that contains blocks of data.
639
- */
640
- export class Frame {
641
- static __wrap(ptr) {
642
- ptr = ptr >>> 0;
643
- const obj = Object.create(Frame.prototype);
644
- obj.__wbg_ptr = ptr;
645
- FrameFinalization.register(obj, obj.__wbg_ptr, obj);
646
- return obj;
647
- }
648
- __destroy_into_raw() {
649
- const ptr = this.__wbg_ptr;
650
- this.__wbg_ptr = 0;
651
- FrameFinalization.unregister(this);
652
- return ptr;
653
- }
654
- free() {
655
- const ptr = this.__destroy_into_raw();
656
- wasm.__wbg_frame_free(ptr, 0);
657
- }
658
- /**
659
- * Clears all blocks from the frame.
660
- */
661
- clear() {
662
- const ret = wasm.frame_clear(this.__wbg_ptr);
663
- if (ret[1]) {
664
- throw takeFromExternrefTable0(ret[0]);
665
- }
666
- }
667
- /**
668
- * Creates a new block in this frame.
669
- * @param {string} key
670
- * @returns {Block}
671
- */
672
- createBlock(key) {
673
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
674
- const len0 = WASM_VECTOR_LEN;
675
- const ret = wasm.frame_createBlock(this.__wbg_ptr, ptr0, len0);
676
- if (ret[2]) {
677
- throw takeFromExternrefTable0(ret[1]);
678
- }
679
- return Block.__wrap(ret[0]);
680
- }
681
- /**
682
- * Drops this frame from the store.
683
- */
684
- drop() {
685
- const ret = wasm.frame_drop(this.__wbg_ptr);
686
- if (ret[1]) {
687
- throw takeFromExternrefTable0(ret[0]);
688
- }
689
- }
690
- /**
691
- * Gets an existing block by key.
692
- * @param {string} key
693
- * @returns {Block | undefined}
694
- */
695
- getBlock(key) {
696
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
697
- const len0 = WASM_VECTOR_LEN;
698
- const ret = wasm.frame_getBlock(this.__wbg_ptr, ptr0, len0);
699
- return ret === 0 ? undefined : Block.__wrap(ret);
700
- }
701
- /**
702
- * Inserts a block into the frame (takes ownership).
703
- * @param {string} key
704
- * @param {Block} block
705
- */
706
- insertBlock(key, block) {
707
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
708
- const len0 = WASM_VECTOR_LEN;
709
- _assertClass(block, Block);
710
- var ptr1 = block.__destroy_into_raw();
711
- const ret = wasm.frame_insertBlock(this.__wbg_ptr, ptr0, len0, ptr1);
712
- if (ret[1]) {
713
- throw takeFromExternrefTable0(ret[0]);
714
- }
715
- }
716
- /**
717
- * Creates a new Frame.
718
- */
719
- constructor() {
720
- const ret = wasm.frame_new();
721
- this.__wbg_ptr = ret >>> 0;
722
- FrameFinalization.register(this, this.__wbg_ptr, this);
723
- return this;
724
- }
725
- /**
726
- * Removes a block from the frame.
727
- * @param {string} key
728
- */
729
- removeBlock(key) {
730
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
731
- const len0 = WASM_VECTOR_LEN;
732
- const ret = wasm.frame_removeBlock(this.__wbg_ptr, ptr0, len0);
733
- if (ret[1]) {
734
- throw takeFromExternrefTable0(ret[0]);
735
- }
736
- }
737
- /**
738
- * Renames a block in the frame.
739
- * @param {string} old_key
740
- * @param {string} new_key
741
- * @returns {boolean}
742
- */
743
- renameBlock(old_key, new_key) {
744
- const ptr0 = passStringToWasm0(old_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
745
- const len0 = WASM_VECTOR_LEN;
746
- const ptr1 = passStringToWasm0(new_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
747
- const len1 = WASM_VECTOR_LEN;
748
- const ret = wasm.frame_renameBlock(this.__wbg_ptr, ptr0, len0, ptr1, len1);
749
- if (ret[2]) {
750
- throw takeFromExternrefTable0(ret[1]);
751
- }
752
- return ret[0] !== 0;
753
- }
754
- /**
755
- * Renames a column in the specified block.
756
- * @param {string} block_key
757
- * @param {string} old_col_key
758
- * @param {string} new_col_key
759
- * @returns {boolean}
760
- */
761
- renameColumn(block_key, old_col_key, new_col_key) {
762
- const ptr0 = passStringToWasm0(block_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
763
- const len0 = WASM_VECTOR_LEN;
764
- const ptr1 = passStringToWasm0(old_col_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
765
- const len1 = WASM_VECTOR_LEN;
766
- const ptr2 = passStringToWasm0(new_col_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
767
- const len2 = WASM_VECTOR_LEN;
768
- const ret = wasm.frame_renameColumn(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
769
- if (ret[2]) {
770
- throw takeFromExternrefTable0(ret[1]);
771
- }
772
- return ret[0] !== 0;
773
- }
774
- /**
775
- * Sets the simulation box.
776
- * @param {Box | null} [simbox]
777
- */
778
- set simbox(simbox) {
779
- let ptr0 = 0;
780
- if (!isLikeNone(simbox)) {
781
- _assertClass(simbox, Box);
782
- ptr0 = simbox.__destroy_into_raw();
783
- }
784
- wasm.frame_set_simbox(this.__wbg_ptr, ptr0);
785
- }
786
- /**
787
- * Gets the simulation box (if any).
788
- * @returns {Box | undefined}
789
- */
790
- get simbox() {
791
- const ret = wasm.frame_simbox(this.__wbg_ptr);
792
- return ret === 0 ? undefined : Box.__wrap(ret);
793
- }
794
- }
795
- if (Symbol.dispose) Frame.prototype[Symbol.dispose] = Frame.prototype.free;
796
-
797
- /**
798
- * LAMMPS data file reader for WASM
799
- *
800
- * # Example (JavaScript)
801
- * ```js
802
- * const reader = new LammpsReader(fileContent);
803
- * const frame = reader.read(0);
804
- * ```
805
- */
806
- export class LammpsReader {
807
- __destroy_into_raw() {
808
- const ptr = this.__wbg_ptr;
809
- this.__wbg_ptr = 0;
810
- LammpsReaderFinalization.unregister(this);
811
- return ptr;
812
- }
813
- free() {
814
- const ptr = this.__destroy_into_raw();
815
- wasm.__wbg_lammpsreader_free(ptr, 0);
816
- }
817
- /**
818
- * Returns the number of frames (always 1 for LAMMPS).
819
- * @returns {number}
820
- * @returns {number}
821
- */
822
- len() {
823
- const ret = wasm.lammpsreader_len(this.__wbg_ptr);
824
- if (ret[2]) {
825
- throw takeFromExternrefTable0(ret[1]);
826
- }
827
- return ret[0] >>> 0;
828
- }
829
- /**
830
- * @param {string} content
831
- */
832
- constructor(content) {
833
- const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
834
- const len0 = WASM_VECTOR_LEN;
835
- const ret = wasm.lammpsreader_new(ptr0, len0);
836
- this.__wbg_ptr = ret >>> 0;
837
- LammpsReaderFinalization.register(this, this.__wbg_ptr, this);
838
- return this;
839
- }
840
- /**
841
- * Reads a frame at the given step.
842
- * @param {number} step - Frame index (LAMMPS only supports single frame, so only step=0 is valid)
843
- * @returns {Frame | undefined}
844
- * @param {number} step
845
- * @returns {Frame | undefined}
846
- */
847
- read(step) {
848
- const ret = wasm.lammpsreader_read(this.__wbg_ptr, step);
849
- if (ret[2]) {
850
- throw takeFromExternrefTable0(ret[1]);
851
- }
852
- return ret[0] === 0 ? undefined : Frame.__wrap(ret[0]);
853
- }
854
- }
855
- if (Symbol.dispose) LammpsReader.prototype[Symbol.dispose] = LammpsReader.prototype.free;
856
-
857
- /**
858
- * PDB file reader for WASM
859
- *
860
- * # Example (JavaScript)
861
- * ```js
862
- * const reader = new PdbReader(fileContent);
863
- * const frame = reader.read(0);
864
- * ```
865
- */
866
- export class PdbReader {
867
- __destroy_into_raw() {
868
- const ptr = this.__wbg_ptr;
869
- this.__wbg_ptr = 0;
870
- PdbReaderFinalization.unregister(this);
871
- return ptr;
872
- }
873
- free() {
874
- const ptr = this.__destroy_into_raw();
875
- wasm.__wbg_pdbreader_free(ptr, 0);
876
- }
877
- /**
878
- * Returns the number of frames (always 1 for PDB).
879
- * @returns {number}
880
- * @returns {number}
881
- */
882
- len() {
883
- const ret = wasm.pdbreader_len(this.__wbg_ptr);
884
- if (ret[2]) {
885
- throw takeFromExternrefTable0(ret[1]);
886
- }
887
- return ret[0] >>> 0;
888
- }
889
- /**
890
- * @param {string} content
891
- */
892
- constructor(content) {
893
- const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
894
- const len0 = WASM_VECTOR_LEN;
895
- const ret = wasm.pdbreader_new(ptr0, len0);
896
- this.__wbg_ptr = ret >>> 0;
897
- PdbReaderFinalization.register(this, this.__wbg_ptr, this);
898
- return this;
899
- }
900
- /**
901
- * Reads a frame at the given step.
902
- * @param {number} step - Frame index (PDB only supports single frame, so only step=0 is valid)
903
- * @returns {Frame | undefined}
904
- * @param {number} step
905
- * @returns {Frame | undefined}
906
- */
907
- read(step) {
908
- const ret = wasm.pdbreader_read(this.__wbg_ptr, step);
909
- if (ret[2]) {
910
- throw takeFromExternrefTable0(ret[1]);
911
- }
912
- return ret[0] === 0 ? undefined : Frame.__wrap(ret[0]);
913
- }
914
- }
915
- if (Symbol.dispose) PdbReader.prototype[Symbol.dispose] = PdbReader.prototype.free;
916
-
917
- /**
918
- * XYZ/ExtXYZ file reader for WASM
919
- *
920
- * # Example (JavaScript)
921
- * ```js
922
- * const reader = new XyzReader(fileContent);
923
- * const frame = reader.read(0);
924
- * ```
925
- */
926
- export class XyzReader {
927
- __destroy_into_raw() {
928
- const ptr = this.__wbg_ptr;
929
- this.__wbg_ptr = 0;
930
- XyzReaderFinalization.unregister(this);
931
- return ptr;
932
- }
933
- free() {
934
- const ptr = this.__destroy_into_raw();
935
- wasm.__wbg_xyzreader_free(ptr, 0);
936
- }
937
- /**
938
- * Returns the number of frames in the file.
939
- * @returns {number}
940
- * @returns {number}
941
- */
942
- len() {
943
- const ret = wasm.xyzreader_len(this.__wbg_ptr);
944
- if (ret[2]) {
945
- throw takeFromExternrefTable0(ret[1]);
946
- }
947
- return ret[0] >>> 0;
948
- }
949
- /**
950
- * @param {string} content
951
- */
952
- constructor(content) {
953
- const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
954
- const len0 = WASM_VECTOR_LEN;
955
- const ret = wasm.xyzreader_new(ptr0, len0);
956
- this.__wbg_ptr = ret >>> 0;
957
- XyzReaderFinalization.register(this, this.__wbg_ptr, this);
958
- return this;
959
- }
960
- /**
961
- * Reads a frame at the given step.
962
- * @param {number} step - Frame index
963
- * @returns {Frame | undefined}
964
- * @param {number} step
965
- * @returns {Frame | undefined}
966
- */
967
- read(step) {
968
- const ret = wasm.xyzreader_read(this.__wbg_ptr, step);
969
- if (ret[2]) {
970
- throw takeFromExternrefTable0(ret[1]);
971
- }
972
- return ret[0] === 0 ? undefined : Frame.__wrap(ret[0]);
973
- }
974
- }
975
- if (Symbol.dispose) XyzReader.prototype[Symbol.dispose] = XyzReader.prototype.free;
976
-
977
- /**
978
- * Writes a frame to a string in the specified format.
979
- *
980
- * # Example (JavaScript)
981
- * ```js
982
- * const output = writeFrame(frame, "xyz");
983
- * console.log(output); // XYZ format string
984
- * ```
985
- *
986
- * @param {Frame} frame - Frame to write
987
- * @param {string} format - Output format ("xyz" or "pdb")
988
- * @returns {string} Formatted output
989
- * @param {Frame} frame
990
- * @param {string} format
991
- * @returns {string}
992
- */
993
- export function writeFrame(frame, format) {
994
- let deferred3_0;
995
- let deferred3_1;
996
- try {
997
- _assertClass(frame, Frame);
998
- const ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
999
- const len0 = WASM_VECTOR_LEN;
1000
- const ret = wasm.writeFrame(frame.__wbg_ptr, ptr0, len0);
1001
- var ptr2 = ret[0];
1002
- var len2 = ret[1];
1003
- if (ret[3]) {
1004
- ptr2 = 0; len2 = 0;
1005
- throw takeFromExternrefTable0(ret[2]);
1006
- }
1007
- deferred3_0 = ptr2;
1008
- deferred3_1 = len2;
1009
- return getStringFromWasm0(ptr2, len2);
1010
- } finally {
1011
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1012
- }
1013
- }
1014
-
1015
- function __wbg_get_imports() {
1016
- const import0 = {
1017
- __proto__: null,
1018
- __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
1019
- const obj = arg1;
1020
- const ret = typeof(obj) === 'string' ? obj : undefined;
1021
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1022
- var len1 = WASM_VECTOR_LEN;
1023
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1024
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1025
- },
1026
- __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
1027
- throw new Error(getStringFromWasm0(arg0, arg1));
1028
- },
1029
- __wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
1030
- const ret = arg0[arg1 >>> 0];
1031
- return ret;
1032
- },
1033
- __wbg_length_1e8b0a6e52c08b9a: function(arg0) {
1034
- const ret = arg0.length;
1035
- return ret;
1036
- },
1037
- __wbg_length_32ed9a279acd054c: function(arg0) {
1038
- const ret = arg0.length;
1039
- return ret;
1040
- },
1041
- __wbg_length_35a7bace40f36eac: function(arg0) {
1042
- const ret = arg0.length;
1043
- return ret;
1044
- },
1045
- __wbg_length_9a7876c9728a0979: function(arg0) {
1046
- const ret = arg0.length;
1047
- return ret;
1048
- },
1049
- __wbg_length_e2449a254c768bd8: function(arg0) {
1050
- const ret = arg0.length;
1051
- return ret;
1052
- },
1053
- __wbg_new_361308b2356cecd0: function() {
1054
- const ret = new Object();
1055
- return ret;
1056
- },
1057
- __wbg_new_3eb36ae241fe6f44: function() {
1058
- const ret = new Array();
1059
- return ret;
1060
- },
1061
- __wbg_new_from_slice_132ef6dc5072cf68: function(arg0, arg1) {
1062
- const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
1063
- return ret;
1064
- },
1065
- __wbg_new_from_slice_19d21922ff3c0ae6: function(arg0, arg1) {
1066
- const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
1067
- return ret;
1068
- },
1069
- __wbg_new_from_slice_9e2a2c824595cde0: function(arg0, arg1) {
1070
- const ret = new BigInt64Array(getArrayI64FromWasm0(arg0, arg1));
1071
- return ret;
1072
- },
1073
- __wbg_new_from_slice_a3d2629dc1826784: function(arg0, arg1) {
1074
- const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
1075
- return ret;
1076
- },
1077
- __wbg_prototypesetcall_4846d4aa386c936f: function(arg0, arg1, arg2) {
1078
- Uint32Array.prototype.set.call(getArrayU32FromWasm0(arg0, arg1), arg2);
1079
- },
1080
- __wbg_prototypesetcall_a294d00fdc9be271: function(arg0, arg1, arg2) {
1081
- BigInt64Array.prototype.set.call(getArrayI64FromWasm0(arg0, arg1), arg2);
1082
- },
1083
- __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
1084
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1085
- },
1086
- __wbg_prototypesetcall_c7e6a26aeade796d: function(arg0, arg1, arg2) {
1087
- Float32Array.prototype.set.call(getArrayF32FromWasm0(arg0, arg1), arg2);
1088
- },
1089
- __wbg_push_8ffdcb2063340ba5: function(arg0, arg1) {
1090
- const ret = arg0.push(arg1);
1091
- return ret;
1092
- },
1093
- __wbg_set_6cb8631f80447a67: function() { return handleError(function (arg0, arg1, arg2) {
1094
- const ret = Reflect.set(arg0, arg1, arg2);
1095
- return ret;
1096
- }, arguments); },
1097
- __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1098
- // Cast intrinsic for `Ref(String) -> Externref`.
1099
- const ret = getStringFromWasm0(arg0, arg1);
1100
- return ret;
1101
- },
1102
- __wbindgen_init_externref_table: function() {
1103
- const table = wasm.__wbindgen_externrefs;
1104
- const offset = table.grow(4);
1105
- table.set(0, undefined);
1106
- table.set(offset + 0, undefined);
1107
- table.set(offset + 1, null);
1108
- table.set(offset + 2, true);
1109
- table.set(offset + 3, false);
1110
- },
1111
- };
1112
- return {
1113
- __proto__: null,
1114
- "./molrs_bg.js": import0,
1115
- };
1116
- }
1117
-
1118
- const BlockFinalization = (typeof FinalizationRegistry === 'undefined')
1119
- ? { register: () => {}, unregister: () => {} }
1120
- : new FinalizationRegistry(ptr => wasm.__wbg_block_free(ptr >>> 0, 1));
1121
- const BoxFinalization = (typeof FinalizationRegistry === 'undefined')
1122
- ? { register: () => {}, unregister: () => {} }
1123
- : new FinalizationRegistry(ptr => wasm.__wbg_box_free(ptr >>> 0, 1));
1124
- const F32ViewFinalization = (typeof FinalizationRegistry === 'undefined')
1125
- ? { register: () => {}, unregister: () => {} }
1126
- : new FinalizationRegistry(ptr => wasm.__wbg_f32view_free(ptr >>> 0, 1));
1127
- const FrameFinalization = (typeof FinalizationRegistry === 'undefined')
1128
- ? { register: () => {}, unregister: () => {} }
1129
- : new FinalizationRegistry(ptr => wasm.__wbg_frame_free(ptr >>> 0, 1));
1130
- const LammpsReaderFinalization = (typeof FinalizationRegistry === 'undefined')
1131
- ? { register: () => {}, unregister: () => {} }
1132
- : new FinalizationRegistry(ptr => wasm.__wbg_lammpsreader_free(ptr >>> 0, 1));
1133
- const PdbReaderFinalization = (typeof FinalizationRegistry === 'undefined')
1134
- ? { register: () => {}, unregister: () => {} }
1135
- : new FinalizationRegistry(ptr => wasm.__wbg_pdbreader_free(ptr >>> 0, 1));
1136
- const XyzReaderFinalization = (typeof FinalizationRegistry === 'undefined')
1137
- ? { register: () => {}, unregister: () => {} }
1138
- : new FinalizationRegistry(ptr => wasm.__wbg_xyzreader_free(ptr >>> 0, 1));
1139
-
1140
- function addToExternrefTable0(obj) {
1141
- const idx = wasm.__externref_table_alloc();
1142
- wasm.__wbindgen_externrefs.set(idx, obj);
1143
- return idx;
1144
- }
1145
-
1146
- function _assertClass(instance, klass) {
1147
- if (!(instance instanceof klass)) {
1148
- throw new Error(`expected instance of ${klass.name}`);
1149
- }
1150
- }
1151
-
1152
- function getArrayF32FromWasm0(ptr, len) {
1153
- ptr = ptr >>> 0;
1154
- return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
1155
- }
1156
-
1157
- function getArrayI64FromWasm0(ptr, len) {
1158
- ptr = ptr >>> 0;
1159
- return getBigInt64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
1160
- }
1161
-
1162
- function getArrayU32FromWasm0(ptr, len) {
1163
- ptr = ptr >>> 0;
1164
- return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
1165
- }
1166
-
1167
- function getArrayU8FromWasm0(ptr, len) {
1168
- ptr = ptr >>> 0;
1169
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1170
- }
1171
-
1172
- let cachedBigInt64ArrayMemory0 = null;
1173
- function getBigInt64ArrayMemory0() {
1174
- if (cachedBigInt64ArrayMemory0 === null || cachedBigInt64ArrayMemory0.byteLength === 0) {
1175
- cachedBigInt64ArrayMemory0 = new BigInt64Array(wasm.memory.buffer);
1176
- }
1177
- return cachedBigInt64ArrayMemory0;
1178
- }
1179
-
1180
- let cachedDataViewMemory0 = null;
1181
- function getDataViewMemory0() {
1182
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1183
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
1184
- }
1185
- return cachedDataViewMemory0;
1186
- }
1187
-
1188
- let cachedFloat32ArrayMemory0 = null;
1189
- function getFloat32ArrayMemory0() {
1190
- if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
1191
- cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
1192
- }
1193
- return cachedFloat32ArrayMemory0;
1194
- }
1195
-
1196
- function getStringFromWasm0(ptr, len) {
1197
- ptr = ptr >>> 0;
1198
- return decodeText(ptr, len);
1199
- }
1200
-
1201
- let cachedUint32ArrayMemory0 = null;
1202
- function getUint32ArrayMemory0() {
1203
- if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
1204
- cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
1205
- }
1206
- return cachedUint32ArrayMemory0;
1207
- }
1208
-
1209
- let cachedUint8ArrayMemory0 = null;
1210
- function getUint8ArrayMemory0() {
1211
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1212
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1213
- }
1214
- return cachedUint8ArrayMemory0;
1215
- }
1216
-
1217
- function handleError(f, args) {
1218
- try {
1219
- return f.apply(this, args);
1220
- } catch (e) {
1221
- const idx = addToExternrefTable0(e);
1222
- wasm.__wbindgen_exn_store(idx);
1223
- }
1224
- }
1225
-
1226
- function isLikeNone(x) {
1227
- return x === undefined || x === null;
1228
- }
1229
-
1230
- function passArray32ToWasm0(arg, malloc) {
1231
- const ptr = malloc(arg.length * 4, 4) >>> 0;
1232
- getUint32ArrayMemory0().set(arg, ptr / 4);
1233
- WASM_VECTOR_LEN = arg.length;
1234
- return ptr;
1235
- }
1236
-
1237
- function passStringToWasm0(arg, malloc, realloc) {
1238
- if (realloc === undefined) {
1239
- const buf = cachedTextEncoder.encode(arg);
1240
- const ptr = malloc(buf.length, 1) >>> 0;
1241
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1242
- WASM_VECTOR_LEN = buf.length;
1243
- return ptr;
1244
- }
1245
-
1246
- let len = arg.length;
1247
- let ptr = malloc(len, 1) >>> 0;
1248
-
1249
- const mem = getUint8ArrayMemory0();
1250
-
1251
- let offset = 0;
1252
-
1253
- for (; offset < len; offset++) {
1254
- const code = arg.charCodeAt(offset);
1255
- if (code > 0x7F) break;
1256
- mem[ptr + offset] = code;
1257
- }
1258
- if (offset !== len) {
1259
- if (offset !== 0) {
1260
- arg = arg.slice(offset);
1261
- }
1262
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1263
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1264
- const ret = cachedTextEncoder.encodeInto(arg, view);
1265
-
1266
- offset += ret.written;
1267
- ptr = realloc(ptr, len, offset, 1) >>> 0;
1268
- }
1269
-
1270
- WASM_VECTOR_LEN = offset;
1271
- return ptr;
1272
- }
1273
-
1274
- function takeFromExternrefTable0(idx) {
1275
- const value = wasm.__wbindgen_externrefs.get(idx);
1276
- wasm.__externref_table_dealloc(idx);
1277
- return value;
1278
- }
1279
-
1280
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1281
- cachedTextDecoder.decode();
1282
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
1283
- let numBytesDecoded = 0;
1284
- function decodeText(ptr, len) {
1285
- numBytesDecoded += len;
1286
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1287
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1288
- cachedTextDecoder.decode();
1289
- numBytesDecoded = len;
1290
- }
1291
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1292
- }
1293
-
1294
- const cachedTextEncoder = new TextEncoder();
1295
-
1296
- if (!('encodeInto' in cachedTextEncoder)) {
1297
- cachedTextEncoder.encodeInto = function (arg, view) {
1298
- const buf = cachedTextEncoder.encode(arg);
1299
- view.set(buf);
1300
- return {
1301
- read: arg.length,
1302
- written: buf.length
1303
- };
1304
- };
1305
- }
1306
-
1307
- let WASM_VECTOR_LEN = 0;
1308
-
1309
- let wasmModule, wasm;
1310
- function __wbg_finalize_init(instance, module) {
1311
- wasm = instance.exports;
1312
- wasmModule = module;
1313
- cachedBigInt64ArrayMemory0 = null;
1314
- cachedDataViewMemory0 = null;
1315
- cachedFloat32ArrayMemory0 = null;
1316
- cachedUint32ArrayMemory0 = null;
1317
- cachedUint8ArrayMemory0 = null;
1318
- wasm.__wbindgen_start();
1319
- return wasm;
1320
- }
1321
-
1322
- async function __wbg_load(module, imports) {
1323
- if (typeof Response === 'function' && module instanceof Response) {
1324
- if (typeof WebAssembly.instantiateStreaming === 'function') {
1325
- try {
1326
- return await WebAssembly.instantiateStreaming(module, imports);
1327
- } catch (e) {
1328
- const validResponse = module.ok && expectedResponseType(module.type);
1329
-
1330
- if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1331
- console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1332
-
1333
- } else { throw e; }
1334
- }
1335
- }
1336
-
1337
- const bytes = await module.arrayBuffer();
1338
- return await WebAssembly.instantiate(bytes, imports);
1339
- } else {
1340
- const instance = await WebAssembly.instantiate(module, imports);
1341
-
1342
- if (instance instanceof WebAssembly.Instance) {
1343
- return { instance, module };
1344
- } else {
1345
- return instance;
1346
- }
1347
- }
1348
-
1349
- function expectedResponseType(type) {
1350
- switch (type) {
1351
- case 'basic': case 'cors': case 'default': return true;
1352
- }
1353
- return false;
1354
- }
1355
- }
1356
-
1357
- function initSync(module) {
1358
- if (wasm !== undefined) return wasm;
1359
-
1360
-
1361
- if (module !== undefined) {
1362
- if (Object.getPrototypeOf(module) === Object.prototype) {
1363
- ({module} = module)
1364
- } else {
1365
- console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1366
- }
1367
- }
1368
-
1369
- const imports = __wbg_get_imports();
1370
- if (!(module instanceof WebAssembly.Module)) {
1371
- module = new WebAssembly.Module(module);
1372
- }
1373
- const instance = new WebAssembly.Instance(module, imports);
1374
- return __wbg_finalize_init(instance, module);
1375
- }
1376
-
1377
- async function __wbg_init(module_or_path) {
1378
- if (wasm !== undefined) return wasm;
1379
-
1380
-
1381
- if (module_or_path !== undefined) {
1382
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1383
- ({module_or_path} = module_or_path)
1384
- } else {
1385
- console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1386
- }
1387
- }
1388
-
1389
- if (module_or_path === undefined) {
1390
- module_or_path = new URL('molrs_bg.wasm', import.meta.url);
1391
- }
1392
- const imports = __wbg_get_imports();
1393
-
1394
- if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1395
- module_or_path = fetch(module_or_path);
1396
- }
1397
-
1398
- const { instance, module } = await __wbg_load(await module_or_path, imports);
1399
-
1400
- return __wbg_finalize_init(instance, module);
1401
- }
1402
-
1403
- export { initSync, __wbg_init as default };
3
+ import * as wasm from "./molrs_bg.wasm";
4
+ import { __wbg_set_wasm } from "./molrs_bg.js";
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ Block, Box, Cluster, ClusterResult, Frame, LAMMPSReader, LinkedCell, MSD, MSDResult, NeighborList, PDBReader, RDF, RDFResult, SimulationReader, SmilesIR, WasmArray, XYZReader, generate3D, parseSMILES, start, wasmMemory, writeFrame
9
+ } from "./molrs_bg.js";