@molcrafts/molrs 0.0.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.
package/molrs.d.ts ADDED
@@ -0,0 +1,555 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * A block containing columnar data.
6
+ */
7
+ export class Block {
8
+ free(): void;
9
+ [Symbol.dispose](): void;
10
+ /**
11
+ * Gets an f32 column as Float32Array.
12
+ */
13
+ getColumnF32(key: string): Float32Array;
14
+ /**
15
+ * Gets an f32 column with shape (for compatibility).
16
+ */
17
+ getColumnF32WithShape(key: string): any;
18
+ /**
19
+ * Gets an i64 column.
20
+ */
21
+ getColumnI64(key: string): BigInt64Array;
22
+ /**
23
+ * Gets a string column.
24
+ */
25
+ getColumnStrings(key: string): Array<any> | undefined;
26
+ /**
27
+ * Gets a u32 column.
28
+ */
29
+ getColumnU32(key: string): Uint32Array;
30
+ /**
31
+ * Gets a u8 column.
32
+ */
33
+ getColumnU8(key: string): Uint8Array | undefined;
34
+ /**
35
+ * Gets column keys.
36
+ */
37
+ keys(): Array<any>;
38
+ /**
39
+ * Gets the number of columns.
40
+ */
41
+ len(): number;
42
+ /**
43
+ * Creates a new empty Block.
44
+ */
45
+ constructor();
46
+ /**
47
+ * Gets the number of rows.
48
+ */
49
+ nrows(): number;
50
+ /**
51
+ * Renames a column.
52
+ */
53
+ renameColumn(old_key: string, new_key: string): boolean;
54
+ /**
55
+ * Sets an f32 column.
56
+ */
57
+ setColumnF32(key: string, data: Float32Array, shape?: Uint32Array | null): void;
58
+ /**
59
+ * Sets an i64 column.
60
+ */
61
+ setColumnI64(key: string, data: BigInt64Array, _shape?: Uint32Array | null): void;
62
+ /**
63
+ * Sets a string column.
64
+ */
65
+ setColumnStrings(key: string, data: Array<any>, _shape?: Uint32Array | null): void;
66
+ /**
67
+ * Sets a u32 column.
68
+ */
69
+ setColumnU32(key: string, data: Uint32Array, _shape?: Uint32Array | null): void;
70
+ /**
71
+ * Sets a u8 column.
72
+ */
73
+ setColumnU8(key: string, data: Uint8Array, _shape?: Uint32Array | null): void;
74
+ }
75
+
76
+ /**
77
+ * Simulation box defining the periodic boundary conditions and coordinate transformations.
78
+ *
79
+ * Represents a parallelepiped defined by a 3x3 matrix `h` and an origin.
80
+ * Supports periodic boundary conditions (PBC) independently in x, y, z directions.
81
+ */
82
+ export class Box {
83
+ free(): void;
84
+ [Symbol.dispose](): void;
85
+ /**
86
+ * Create a cubic box.
87
+ *
88
+ * # Arguments
89
+ * * `a` - Side length of the cube
90
+ * * `origin` - 3D origin vector as Float32Array with 3 elements
91
+ * * `pbc_x`, `pbc_y`, `pbc_z` - Periodic boundary conditions for each axis
92
+ */
93
+ static cube(a: number, origin: Float32Array, pbc_x: boolean, pbc_y: boolean, pbc_z: boolean): Box;
94
+ /**
95
+ * Calculate displacement vectors between two sets of coordinates.
96
+ *
97
+ * # Arguments
98
+ * * `a` - F32View with Nx3 coordinates
99
+ * * `b` - F32View with Nx3 coordinates
100
+ * * `minimum_image` - If true, apply minimum image convention
101
+ *
102
+ * # Returns
103
+ * F32View with Nx3 displacement vectors (b - a)
104
+ */
105
+ delta(a: F32View, b: F32View, minimum_image: boolean): F32View;
106
+ get_corners(): F32View;
107
+ /**
108
+ * Get the box edge lengths as F32View [lx, ly, lz].
109
+ */
110
+ lengths(): F32View;
111
+ /**
112
+ * Create a new box from a 3x3 matrix and origin.
113
+ *
114
+ * # Arguments
115
+ * * `h` - 3x3 matrix as Float32Array with 9 elements (row-major: [h00, h01, h02, h10, ...])
116
+ * * `origin` - 3D origin vector as Float32Array with 3 elements [x, y, z]
117
+ * * `pbc_x`, `pbc_y`, `pbc_z` - Periodic boundary conditions for each axis
118
+ */
119
+ constructor(h: Float32Array, origin: Float32Array, pbc_x: boolean, pbc_y: boolean, pbc_z: boolean);
120
+ /**
121
+ * Get the box origin as F32View [x, y, z].
122
+ */
123
+ origin(): F32View;
124
+ /**
125
+ * Create an orthorhombic box (rectangular box with axis-aligned edges).
126
+ *
127
+ * # Arguments
128
+ * * `lengths` - Box dimensions as Float32Array with 3 elements [lx, ly, lz]
129
+ * * `origin` - 3D origin vector as Float32Array with 3 elements
130
+ * * `pbc_x`, `pbc_y`, `pbc_z` - Periodic boundary conditions for each axis
131
+ */
132
+ static ortho(lengths: Float32Array, origin: Float32Array, pbc_x: boolean, pbc_y: boolean, pbc_z: boolean): Box;
133
+ /**
134
+ * Get the box tilt factors as F32View [xy, xz, yz].
135
+ */
136
+ tilts(): F32View;
137
+ /**
138
+ * Convert fractional coordinates to Cartesian coordinates.
139
+ *
140
+ * # Arguments
141
+ * * `coords` - F32View with Nx3 coordinates
142
+ *
143
+ * # Returns
144
+ * F32View with Nx3 Cartesian coordinates
145
+ */
146
+ to_cart(coords: F32View): F32View;
147
+ /**
148
+ * Convert Cartesian coordinates to fractional coordinates.
149
+ *
150
+ * # Arguments
151
+ * * `coords` - F32View with Nx3 coordinates
152
+ *
153
+ * # Returns
154
+ * F32View with Nx3 fractional coordinates
155
+ */
156
+ to_frac(coords: F32View): F32View;
157
+ /**
158
+ * Get the volume of the box.
159
+ */
160
+ volume(): number;
161
+ /**
162
+ * Wrap coordinates into the primary simulation box.
163
+ *
164
+ * # Arguments
165
+ * * `coords` - F32View with Nx3 coordinates
166
+ *
167
+ * # Returns
168
+ * F32View with Nx3 wrapped coordinates
169
+ */
170
+ wrap(coords: F32View): F32View;
171
+ }
172
+
173
+ /**
174
+ * Zero-copy view over f32 array data shared between JavaScript and Rust.
175
+ *
176
+ * `F32View` provides a safe wrapper around f32 arrays that can be accessed from both
177
+ * JavaScript and Rust without copying data. The data lives in WASM linear memory,
178
+ * and JavaScript can create typed array views over this memory using `ptr()` and `len()`.
179
+ *
180
+ * # Memory Model
181
+ *
182
+ * - Data is stored in `Vec<f32>` in WASM linear memory (Rust heap)
183
+ * - JavaScript creates `Float32Array` views using `ptr()` and `len()`
184
+ * - No copying occurs when JavaScript reads/writes via these views
185
+ * - **Important**: Pointers are only valid until WASM memory grows
186
+ *
187
+ * # Safety Considerations
188
+ *
189
+ * - Views should be short-lived (don't store across async boundaries)
190
+ * - JavaScript must not modify the underlying array while Rust holds a reference
191
+ * - WASM memory can grow/relocate, invalidating pointers
192
+ *
193
+ * # Example
194
+ *
195
+ * ```javascript
196
+ * // Create a view for 1000 atoms with 3D coordinates
197
+ * const view = new F32View([1000, 3]);
198
+ *
199
+ * // Access the data from JavaScript without copying
200
+ * const mem = new Float32Array(wasmMemory.buffer, view.ptr(), view.len());
201
+ * mem.set([1.0, 2.0, 3.0, ...]); // Write data
202
+ *
203
+ * // Pass to Rust for zero-copy processing
204
+ * const wrapped = box.wrap(view);
205
+ *
206
+ * // Read results without copying
207
+ * const result = new Float32Array(wasmMemory.buffer, wrapped.ptr(), wrapped.len());
208
+ * ```
209
+ */
210
+ export class F32View {
211
+ free(): void;
212
+ [Symbol.dispose](): void;
213
+ /**
214
+ * Get the total number of elements in the view.
215
+ *
216
+ * Returns the product of all shape dimensions.
217
+ */
218
+ len(): number;
219
+ /**
220
+ * Create a new F32View with the given shape.
221
+ *
222
+ * Allocates a buffer in WASM linear memory with size = product of shape dimensions.
223
+ *
224
+ * # Arguments
225
+ *
226
+ * * `shape` - Dimensions of the array (e.g., `[1000, 3]` for Nx3 coordinates)
227
+ *
228
+ * # Example
229
+ *
230
+ * ```javascript
231
+ * const view = new F32View([100, 3]); // 100 atoms, 3D coordinates
232
+ * console.log(view.len()); // 300
233
+ * ```
234
+ */
235
+ constructor(shape: Uint32Array);
236
+ /**
237
+ * Get a pointer to the underlying data for zero-copy access from JavaScript.
238
+ *
239
+ * # Returns
240
+ *
241
+ * A raw pointer to the first element of the data buffer.
242
+ *
243
+ * # Safety
244
+ *
245
+ * The pointer is only valid until the next WASM memory allocation.
246
+ * JavaScript should create typed array views immediately and not store the pointer.
247
+ *
248
+ * # Example
249
+ *
250
+ * ```javascript
251
+ * const view = new F32View([10, 3]);
252
+ * const ptr = view.ptr();
253
+ * const arr = new Float32Array(wasmMemory.buffer, ptr, view.len());
254
+ * ```
255
+ */
256
+ ptr(): number;
257
+ /**
258
+ * Get the shape of the array (cloned for JS boundary).
259
+ */
260
+ shape(): Uint32Array;
261
+ /**
262
+ * Compute the sum of all elements (for testing).
263
+ *
264
+ * # Returns
265
+ *
266
+ * Sum of all elements in the view.
267
+ */
268
+ sum(): number;
269
+ /**
270
+ * Export the view data as a JavaScript Float32Array.
271
+ *
272
+ * Creates a new JavaScript array and copies the data.
273
+ * Use this for compatibility or when you need an owned JavaScript array.
274
+ *
275
+ * # Returns
276
+ *
277
+ * A new Float32Array containing a copy of the data.
278
+ *
279
+ * # Example
280
+ *
281
+ * ```javascript
282
+ * const view = new F32View([2, 3]);
283
+ * // ... populate view ...
284
+ * const arr = view.to_js_array(); // Copies data
285
+ * ```
286
+ */
287
+ to_js_array(): Float32Array;
288
+ /**
289
+ * Write data from a JavaScript Float32Array into this view.
290
+ *
291
+ * Copies data from the JavaScript array into WASM memory once.
292
+ * The array length must match the view's total size.
293
+ *
294
+ * # Arguments
295
+ *
296
+ * * `arr` - JavaScript Float32Array to copy from
297
+ *
298
+ * # Errors
299
+ *
300
+ * Returns an error if the array length doesn't match the view size.
301
+ *
302
+ * # Example
303
+ *
304
+ * ```javascript
305
+ * const view = new F32View([2, 3]);
306
+ * const data = new Float32Array([1, 2, 3, 4, 5, 6]);
307
+ * view.write_from(data);
308
+ * ```
309
+ */
310
+ write_from(arr: Float32Array): void;
311
+ }
312
+
313
+ /**
314
+ * A frame that contains blocks of data.
315
+ */
316
+ export class Frame {
317
+ free(): void;
318
+ [Symbol.dispose](): void;
319
+ /**
320
+ * Clears all blocks from the frame.
321
+ */
322
+ clear(): void;
323
+ /**
324
+ * Creates a new block in this frame.
325
+ */
326
+ createBlock(key: string): Block;
327
+ /**
328
+ * Drops this frame from the store.
329
+ */
330
+ drop(): void;
331
+ /**
332
+ * Gets an existing block by key.
333
+ */
334
+ getBlock(key: string): Block | undefined;
335
+ /**
336
+ * Inserts a block into the frame (takes ownership).
337
+ */
338
+ insertBlock(key: string, block: Block): void;
339
+ /**
340
+ * Creates a new Frame.
341
+ */
342
+ constructor();
343
+ /**
344
+ * Removes a block from the frame.
345
+ */
346
+ removeBlock(key: string): void;
347
+ /**
348
+ * Renames a block in the frame.
349
+ */
350
+ renameBlock(old_key: string, new_key: string): boolean;
351
+ /**
352
+ * Renames a column in the specified block.
353
+ */
354
+ renameColumn(block_key: string, old_col_key: string, new_col_key: string): boolean;
355
+ /**
356
+ * Gets the simulation box (if any).
357
+ */
358
+ get simbox(): Box | undefined;
359
+ /**
360
+ * Sets the simulation box.
361
+ */
362
+ set simbox(value: Box | null | undefined);
363
+ }
364
+
365
+ /**
366
+ * LAMMPS data file reader for WASM
367
+ *
368
+ * # Example (JavaScript)
369
+ * ```js
370
+ * const reader = new LammpsReader(fileContent);
371
+ * const frame = reader.read(0);
372
+ * ```
373
+ */
374
+ export class LammpsReader {
375
+ free(): void;
376
+ [Symbol.dispose](): void;
377
+ /**
378
+ * Returns the number of frames (always 1 for LAMMPS).
379
+ * @returns {number}
380
+ */
381
+ len(): number;
382
+ constructor(content: string);
383
+ /**
384
+ * Reads a frame at the given step.
385
+ * @param {number} step - Frame index (LAMMPS only supports single frame, so only step=0 is valid)
386
+ * @returns {Frame | undefined}
387
+ */
388
+ read(step: number): Frame | undefined;
389
+ }
390
+
391
+ /**
392
+ * PDB file reader for WASM
393
+ *
394
+ * # Example (JavaScript)
395
+ * ```js
396
+ * const reader = new PdbReader(fileContent);
397
+ * const frame = reader.read(0);
398
+ * ```
399
+ */
400
+ export class PdbReader {
401
+ free(): void;
402
+ [Symbol.dispose](): void;
403
+ /**
404
+ * Returns the number of frames (always 1 for PDB).
405
+ * @returns {number}
406
+ */
407
+ len(): number;
408
+ constructor(content: string);
409
+ /**
410
+ * Reads a frame at the given step.
411
+ * @param {number} step - Frame index (PDB only supports single frame, so only step=0 is valid)
412
+ * @returns {Frame | undefined}
413
+ */
414
+ read(step: number): Frame | undefined;
415
+ }
416
+
417
+ /**
418
+ * XYZ/ExtXYZ file reader for WASM
419
+ *
420
+ * # Example (JavaScript)
421
+ * ```js
422
+ * const reader = new XyzReader(fileContent);
423
+ * const frame = reader.read(0);
424
+ * ```
425
+ */
426
+ export class XyzReader {
427
+ free(): void;
428
+ [Symbol.dispose](): void;
429
+ /**
430
+ * Returns the number of frames in the file.
431
+ * @returns {number}
432
+ */
433
+ len(): number;
434
+ constructor(content: string);
435
+ /**
436
+ * Reads a frame at the given step.
437
+ * @param {number} step - Frame index
438
+ * @returns {Frame | undefined}
439
+ */
440
+ read(step: number): Frame | undefined;
441
+ }
442
+
443
+ /**
444
+ * Writes a frame to a string in the specified format.
445
+ *
446
+ * # Example (JavaScript)
447
+ * ```js
448
+ * const output = writeFrame(frame, "xyz");
449
+ * console.log(output); // XYZ format string
450
+ * ```
451
+ *
452
+ * @param {Frame} frame - Frame to write
453
+ * @param {string} format - Output format ("xyz" or "pdb")
454
+ * @returns {string} Formatted output
455
+ */
456
+ export function writeFrame(frame: Frame, format: string): string;
457
+
458
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
459
+
460
+ export interface InitOutput {
461
+ readonly memory: WebAssembly.Memory;
462
+ readonly __wbg_block_free: (a: number, b: number) => void;
463
+ readonly __wbg_frame_free: (a: number, b: number) => void;
464
+ readonly block_getColumnF32: (a: number, b: number, c: number) => [number, number, number];
465
+ readonly block_getColumnF32WithShape: (a: number, b: number, c: number) => [number, number, number];
466
+ readonly block_getColumnI64: (a: number, b: number, c: number) => [number, number, number];
467
+ readonly block_getColumnStrings: (a: number, b: number, c: number) => any;
468
+ readonly block_getColumnU32: (a: number, b: number, c: number) => [number, number, number];
469
+ readonly block_getColumnU8: (a: number, b: number, c: number) => any;
470
+ readonly block_keys: (a: number) => [number, number, number];
471
+ readonly block_len: (a: number) => [number, number, number];
472
+ readonly block_new: () => number;
473
+ readonly block_nrows: (a: number) => [number, number, number];
474
+ readonly block_renameColumn: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
475
+ readonly block_setColumnF32: (a: number, b: number, c: number, d: any, e: number) => [number, number];
476
+ readonly block_setColumnI64: (a: number, b: number, c: number, d: any, e: number) => [number, number];
477
+ readonly block_setColumnStrings: (a: number, b: number, c: number, d: any, e: number) => [number, number];
478
+ readonly block_setColumnU32: (a: number, b: number, c: number, d: any, e: number) => [number, number];
479
+ readonly block_setColumnU8: (a: number, b: number, c: number, d: any, e: number) => [number, number];
480
+ readonly frame_clear: (a: number) => [number, number];
481
+ readonly frame_createBlock: (a: number, b: number, c: number) => [number, number, number];
482
+ readonly frame_drop: (a: number) => [number, number];
483
+ readonly frame_getBlock: (a: number, b: number, c: number) => number;
484
+ readonly frame_insertBlock: (a: number, b: number, c: number, d: number) => [number, number];
485
+ readonly frame_new: () => number;
486
+ readonly frame_removeBlock: (a: number, b: number, c: number) => [number, number];
487
+ readonly frame_renameBlock: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
488
+ readonly frame_renameColumn: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
489
+ readonly frame_set_simbox: (a: number, b: number) => void;
490
+ readonly frame_simbox: (a: number) => number;
491
+ readonly __wbg_f32view_free: (a: number, b: number) => void;
492
+ readonly f32view_len: (a: number) => number;
493
+ readonly f32view_new: (a: number, b: number) => number;
494
+ readonly f32view_ptr: (a: number) => number;
495
+ readonly f32view_shape: (a: number) => [number, number];
496
+ readonly f32view_sum: (a: number) => number;
497
+ readonly f32view_to_js_array: (a: number) => any;
498
+ readonly f32view_write_from: (a: number, b: any) => [number, number];
499
+ readonly __wbg_lammpsreader_free: (a: number, b: number) => void;
500
+ readonly __wbg_pdbreader_free: (a: number, b: number) => void;
501
+ readonly __wbg_xyzreader_free: (a: number, b: number) => void;
502
+ readonly lammpsreader_len: (a: number) => [number, number, number];
503
+ readonly lammpsreader_new: (a: number, b: number) => number;
504
+ readonly lammpsreader_read: (a: number, b: number) => [number, number, number];
505
+ readonly pdbreader_len: (a: number) => [number, number, number];
506
+ readonly pdbreader_new: (a: number, b: number) => number;
507
+ readonly pdbreader_read: (a: number, b: number) => [number, number, number];
508
+ readonly xyzreader_len: (a: number) => [number, number, number];
509
+ readonly xyzreader_new: (a: number, b: number) => number;
510
+ readonly xyzreader_read: (a: number, b: number) => [number, number, number];
511
+ readonly __wbg_box_free: (a: number, b: number) => void;
512
+ readonly box_cube: (a: number, b: any, c: number, d: number, e: number) => [number, number, number];
513
+ readonly box_delta: (a: number, b: number, c: number, d: number) => [number, number, number];
514
+ readonly box_get_corners: (a: number) => number;
515
+ readonly box_lengths: (a: number) => number;
516
+ readonly box_new: (a: any, b: any, c: number, d: number, e: number) => [number, number, number];
517
+ readonly box_origin: (a: number) => number;
518
+ readonly box_ortho: (a: any, b: any, c: number, d: number, e: number) => [number, number, number];
519
+ readonly box_tilts: (a: number) => number;
520
+ readonly box_to_cart: (a: number, b: number) => [number, number, number];
521
+ readonly box_to_frac: (a: number, b: number) => [number, number, number];
522
+ readonly box_volume: (a: number) => number;
523
+ readonly box_wrap: (a: number, b: number) => [number, number, number];
524
+ readonly writeFrame: (a: number, b: number, c: number) => [number, number, number, number];
525
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
526
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
527
+ readonly __wbindgen_exn_store: (a: number) => void;
528
+ readonly __externref_table_alloc: () => number;
529
+ readonly __wbindgen_externrefs: WebAssembly.Table;
530
+ readonly __externref_table_dealloc: (a: number) => void;
531
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
532
+ readonly __wbindgen_start: () => void;
533
+ }
534
+
535
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
536
+
537
+ /**
538
+ * Instantiates the given `module`, which can either be bytes or
539
+ * a precompiled `WebAssembly.Module`.
540
+ *
541
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
542
+ *
543
+ * @returns {InitOutput}
544
+ */
545
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
546
+
547
+ /**
548
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
549
+ * for everything else, calls `WebAssembly.instantiate` directly.
550
+ *
551
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
552
+ *
553
+ * @returns {Promise<InitOutput>}
554
+ */
555
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;