@molcrafts/molrs 0.0.12 → 0.0.13

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 CHANGED
@@ -117,6 +117,50 @@ export class Block {
117
117
  * ```
118
118
  */
119
119
  copyColU32(key: string): Uint32Array;
120
+ /**
121
+ * Allocate a zero-filled float column at `key` with the given shape.
122
+ *
123
+ * Pair with [`viewColF`](Block::view_col_f) for zero-copy writes from JS:
124
+ *
125
+ * ```js
126
+ * block.createColF("x", [N]); // allocate
127
+ * const view = block.viewColF("x"); // zero-copy view into the column
128
+ * for (let i = 0; i < N; i++) view[i] = src[i]; // direct write
129
+ * ```
130
+ *
131
+ * # Arguments
132
+ *
133
+ * * `key` - Column name
134
+ * * `shape` - Shape of the column (e.g. `[N]` for 1D, `[N, 3]` for Nx3)
135
+ *
136
+ * # Errors
137
+ *
138
+ * Throws if the shape is empty, or if the leading dimension conflicts
139
+ * with existing columns in this block.
140
+ */
141
+ createColF(key: string, shape: Uint32Array): void;
142
+ /**
143
+ * Allocate a zero-filled i32 column at `key` with the given shape.
144
+ *
145
+ * See [`createColF`](Block::create_col_f) for the zero-copy write pattern.
146
+ *
147
+ * # Errors
148
+ *
149
+ * Throws if the shape is empty, or if the leading dimension conflicts
150
+ * with existing columns.
151
+ */
152
+ createColI32(key: string, shape: Uint32Array): void;
153
+ /**
154
+ * Allocate a zero-filled u32 column at `key` with the given shape.
155
+ *
156
+ * See [`createColF`](Block::create_col_f) for the zero-copy write pattern.
157
+ *
158
+ * # Errors
159
+ *
160
+ * Throws if the shape is empty, or if the leading dimension conflicts
161
+ * with existing columns.
162
+ */
163
+ createColU32(key: string, shape: Uint32Array): void;
120
164
  /**
121
165
  * Return the data type string for a column.
122
166
  *
@@ -1633,44 +1677,6 @@ export class InertiaTensor {
1633
1677
  constructor(masses?: Float64Array | null);
1634
1678
  }
1635
1679
 
1636
- /**
1637
- * LAMMPS dump trajectory file reader.
1638
- *
1639
- * Reads multi-frame LAMMPS dump files (the format produced by the
1640
- * `dump` command). Each frame produces a [`Frame`] containing an
1641
- * `"atoms"` block with columns matching the dump header (e.g.
1642
- * `id`, `type`, `x`, `y`, `z`, `vx`, `vy`, `vz`).
1643
- *
1644
- * # Example (JavaScript)
1645
- *
1646
- * ```js
1647
- * const reader = new LAMMPSDumpReader(dumpContent);
1648
- * console.log(reader.len()); // number of timesteps
1649
- * const frame = reader.read(0);
1650
- * const atoms = frame.getBlock("atoms");
1651
- * ```
1652
- */
1653
- export class LAMMPSDumpReader {
1654
- free(): void;
1655
- [Symbol.dispose](): void;
1656
- /**
1657
- * Check whether the file contains no frames.
1658
- */
1659
- isEmpty(): boolean;
1660
- /**
1661
- * Return the number of frames in the dump file.
1662
- */
1663
- len(): number;
1664
- /**
1665
- * Create a new LAMMPS dump reader from string content.
1666
- */
1667
- constructor(content: string);
1668
- /**
1669
- * Read a frame at the given step index.
1670
- */
1671
- read(step: number): Frame | undefined;
1672
- }
1673
-
1674
1680
  /**
1675
1681
  * LAMMPS data file reader.
1676
1682
  *
@@ -1754,6 +1760,44 @@ export class LAMMPSReader {
1754
1760
  read(step: number): Frame | undefined;
1755
1761
  }
1756
1762
 
1763
+ /**
1764
+ * LAMMPS dump trajectory file reader.
1765
+ *
1766
+ * Reads multi-frame LAMMPS dump files (the format produced by the
1767
+ * `dump` command). Each frame produces a [`Frame`] containing an
1768
+ * `"atoms"` block with columns matching the dump header (e.g.
1769
+ * `id`, `type`, `x`, `y`, `z`, `vx`, `vy`, `vz`).
1770
+ *
1771
+ * # Example (JavaScript)
1772
+ *
1773
+ * ```js
1774
+ * const reader = new LAMMPSTrajReader(dumpContent);
1775
+ * console.log(reader.len()); // number of timesteps
1776
+ * const frame = reader.read(0);
1777
+ * const atoms = frame.getBlock("atoms");
1778
+ * ```
1779
+ */
1780
+ export class LAMMPSTrajReader {
1781
+ free(): void;
1782
+ [Symbol.dispose](): void;
1783
+ /**
1784
+ * Check whether the file contains no frames.
1785
+ */
1786
+ isEmpty(): boolean;
1787
+ /**
1788
+ * Return the number of frames in the dump file.
1789
+ */
1790
+ len(): number;
1791
+ /**
1792
+ * Create a new LAMMPS dump reader from string content.
1793
+ */
1794
+ constructor(content: string);
1795
+ /**
1796
+ * Read a frame at the given step index.
1797
+ */
1798
+ read(step: number): Frame | undefined;
1799
+ }
1800
+
1757
1801
  /**
1758
1802
  * Cell-list (linked-cell) based neighbor search.
1759
1803
  *
package/molrs.js CHANGED
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./molrs_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
  wasm.__wbindgen_start();
7
7
  export {
8
- Block, Box, CenterOfMass, CenterOfMassResult, Cluster, ClusterCenters, ClusterResult, Frame, Grid, GyrationTensor, InertiaTensor, LAMMPSDumpReader, LAMMPSReader, LinkedCell, MSD, MSDResult, MolRecReader, NeighborList, PDBReader, RDF, RDFResult, RadiusOfGyration, SDFReader, SmilesIR, Topology, TopologyRingInfo, WasmArray, WasmKMeans, WasmPca2, WasmPcaResult, XYZReader, generate3D, parseSMILES, start, wasmMemory, writeFrame
8
+ Block, Box, CenterOfMass, CenterOfMassResult, Cluster, ClusterCenters, ClusterResult, Frame, Grid, GyrationTensor, InertiaTensor, LAMMPSReader, LAMMPSTrajReader, LinkedCell, MSD, MSDResult, MolRecReader, NeighborList, PDBReader, RDF, RDFResult, RadiusOfGyration, SDFReader, SmilesIR, Topology, TopologyRingInfo, WasmArray, WasmKMeans, WasmPca2, WasmPcaResult, XYZReader, generate3D, parseSMILES, start, wasmMemory, writeFrame
9
9
  } from "./molrs_bg.js";
package/molrs_bg.js CHANGED
@@ -169,6 +169,83 @@ export class Block {
169
169
  }
170
170
  return takeFromExternrefTable0(ret[0]);
171
171
  }
172
+ /**
173
+ * Allocate a zero-filled float column at `key` with the given shape.
174
+ *
175
+ * Pair with [`viewColF`](Block::view_col_f) for zero-copy writes from JS:
176
+ *
177
+ * ```js
178
+ * block.createColF("x", [N]); // allocate
179
+ * const view = block.viewColF("x"); // zero-copy view into the column
180
+ * for (let i = 0; i < N; i++) view[i] = src[i]; // direct write
181
+ * ```
182
+ *
183
+ * # Arguments
184
+ *
185
+ * * `key` - Column name
186
+ * * `shape` - Shape of the column (e.g. `[N]` for 1D, `[N, 3]` for Nx3)
187
+ *
188
+ * # Errors
189
+ *
190
+ * Throws if the shape is empty, or if the leading dimension conflicts
191
+ * with existing columns in this block.
192
+ * @param {string} key
193
+ * @param {Uint32Array} shape
194
+ */
195
+ createColF(key, shape) {
196
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
197
+ const len0 = WASM_VECTOR_LEN;
198
+ const ptr1 = passArray32ToWasm0(shape, wasm.__wbindgen_malloc_command_export);
199
+ const len1 = WASM_VECTOR_LEN;
200
+ const ret = wasm.block_createColF(this.__wbg_ptr, ptr0, len0, ptr1, len1);
201
+ if (ret[1]) {
202
+ throw takeFromExternrefTable0(ret[0]);
203
+ }
204
+ }
205
+ /**
206
+ * Allocate a zero-filled i32 column at `key` with the given shape.
207
+ *
208
+ * See [`createColF`](Block::create_col_f) for the zero-copy write pattern.
209
+ *
210
+ * # Errors
211
+ *
212
+ * Throws if the shape is empty, or if the leading dimension conflicts
213
+ * with existing columns.
214
+ * @param {string} key
215
+ * @param {Uint32Array} shape
216
+ */
217
+ createColI32(key, shape) {
218
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
219
+ const len0 = WASM_VECTOR_LEN;
220
+ const ptr1 = passArray32ToWasm0(shape, wasm.__wbindgen_malloc_command_export);
221
+ const len1 = WASM_VECTOR_LEN;
222
+ const ret = wasm.block_createColI32(this.__wbg_ptr, ptr0, len0, ptr1, len1);
223
+ if (ret[1]) {
224
+ throw takeFromExternrefTable0(ret[0]);
225
+ }
226
+ }
227
+ /**
228
+ * Allocate a zero-filled u32 column at `key` with the given shape.
229
+ *
230
+ * See [`createColF`](Block::create_col_f) for the zero-copy write pattern.
231
+ *
232
+ * # Errors
233
+ *
234
+ * Throws if the shape is empty, or if the leading dimension conflicts
235
+ * with existing columns.
236
+ * @param {string} key
237
+ * @param {Uint32Array} shape
238
+ */
239
+ createColU32(key, shape) {
240
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
241
+ const len0 = WASM_VECTOR_LEN;
242
+ const ptr1 = passArray32ToWasm0(shape, wasm.__wbindgen_malloc_command_export);
243
+ const len1 = WASM_VECTOR_LEN;
244
+ const ret = wasm.block_createColU32(this.__wbg_ptr, ptr0, len0, ptr1, len1);
245
+ if (ret[1]) {
246
+ throw takeFromExternrefTable0(ret[0]);
247
+ }
248
+ }
172
249
  /**
173
250
  * Return the data type string for a column.
174
251
  *
@@ -2455,83 +2532,6 @@ export class InertiaTensor {
2455
2532
  }
2456
2533
  if (Symbol.dispose) InertiaTensor.prototype[Symbol.dispose] = InertiaTensor.prototype.free;
2457
2534
 
2458
- /**
2459
- * LAMMPS dump trajectory file reader.
2460
- *
2461
- * Reads multi-frame LAMMPS dump files (the format produced by the
2462
- * `dump` command). Each frame produces a [`Frame`] containing an
2463
- * `"atoms"` block with columns matching the dump header (e.g.
2464
- * `id`, `type`, `x`, `y`, `z`, `vx`, `vy`, `vz`).
2465
- *
2466
- * # Example (JavaScript)
2467
- *
2468
- * ```js
2469
- * const reader = new LAMMPSDumpReader(dumpContent);
2470
- * console.log(reader.len()); // number of timesteps
2471
- * const frame = reader.read(0);
2472
- * const atoms = frame.getBlock("atoms");
2473
- * ```
2474
- */
2475
- export class LAMMPSDumpReader {
2476
- __destroy_into_raw() {
2477
- const ptr = this.__wbg_ptr;
2478
- this.__wbg_ptr = 0;
2479
- LAMMPSDumpReaderFinalization.unregister(this);
2480
- return ptr;
2481
- }
2482
- free() {
2483
- const ptr = this.__destroy_into_raw();
2484
- wasm.__wbg_lammpsdumpreader_free(ptr, 0);
2485
- }
2486
- /**
2487
- * Check whether the file contains no frames.
2488
- * @returns {boolean}
2489
- */
2490
- isEmpty() {
2491
- const ret = wasm.lammpsdumpreader_isEmpty(this.__wbg_ptr);
2492
- if (ret[2]) {
2493
- throw takeFromExternrefTable0(ret[1]);
2494
- }
2495
- return ret[0] !== 0;
2496
- }
2497
- /**
2498
- * Return the number of frames in the dump file.
2499
- * @returns {number}
2500
- */
2501
- len() {
2502
- const ret = wasm.lammpsdumpreader_len(this.__wbg_ptr);
2503
- if (ret[2]) {
2504
- throw takeFromExternrefTable0(ret[1]);
2505
- }
2506
- return ret[0] >>> 0;
2507
- }
2508
- /**
2509
- * Create a new LAMMPS dump reader from string content.
2510
- * @param {string} content
2511
- */
2512
- constructor(content) {
2513
- const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
2514
- const len0 = WASM_VECTOR_LEN;
2515
- const ret = wasm.lammpsdumpreader_new(ptr0, len0);
2516
- this.__wbg_ptr = ret >>> 0;
2517
- LAMMPSDumpReaderFinalization.register(this, this.__wbg_ptr, this);
2518
- return this;
2519
- }
2520
- /**
2521
- * Read a frame at the given step index.
2522
- * @param {number} step
2523
- * @returns {Frame | undefined}
2524
- */
2525
- read(step) {
2526
- const ret = wasm.lammpsdumpreader_read(this.__wbg_ptr, step);
2527
- if (ret[2]) {
2528
- throw takeFromExternrefTable0(ret[1]);
2529
- }
2530
- return ret[0] === 0 ? undefined : Frame.__wrap(ret[0]);
2531
- }
2532
- }
2533
- if (Symbol.dispose) LAMMPSDumpReader.prototype[Symbol.dispose] = LAMMPSDumpReader.prototype.free;
2534
-
2535
2535
  /**
2536
2536
  * LAMMPS data file reader.
2537
2537
  *
@@ -2654,6 +2654,83 @@ export class LAMMPSReader {
2654
2654
  }
2655
2655
  if (Symbol.dispose) LAMMPSReader.prototype[Symbol.dispose] = LAMMPSReader.prototype.free;
2656
2656
 
2657
+ /**
2658
+ * LAMMPS dump trajectory file reader.
2659
+ *
2660
+ * Reads multi-frame LAMMPS dump files (the format produced by the
2661
+ * `dump` command). Each frame produces a [`Frame`] containing an
2662
+ * `"atoms"` block with columns matching the dump header (e.g.
2663
+ * `id`, `type`, `x`, `y`, `z`, `vx`, `vy`, `vz`).
2664
+ *
2665
+ * # Example (JavaScript)
2666
+ *
2667
+ * ```js
2668
+ * const reader = new LAMMPSTrajReader(dumpContent);
2669
+ * console.log(reader.len()); // number of timesteps
2670
+ * const frame = reader.read(0);
2671
+ * const atoms = frame.getBlock("atoms");
2672
+ * ```
2673
+ */
2674
+ export class LAMMPSTrajReader {
2675
+ __destroy_into_raw() {
2676
+ const ptr = this.__wbg_ptr;
2677
+ this.__wbg_ptr = 0;
2678
+ LAMMPSTrajReaderFinalization.unregister(this);
2679
+ return ptr;
2680
+ }
2681
+ free() {
2682
+ const ptr = this.__destroy_into_raw();
2683
+ wasm.__wbg_lammpstrajreader_free(ptr, 0);
2684
+ }
2685
+ /**
2686
+ * Check whether the file contains no frames.
2687
+ * @returns {boolean}
2688
+ */
2689
+ isEmpty() {
2690
+ const ret = wasm.lammpstrajreader_isEmpty(this.__wbg_ptr);
2691
+ if (ret[2]) {
2692
+ throw takeFromExternrefTable0(ret[1]);
2693
+ }
2694
+ return ret[0] !== 0;
2695
+ }
2696
+ /**
2697
+ * Return the number of frames in the dump file.
2698
+ * @returns {number}
2699
+ */
2700
+ len() {
2701
+ const ret = wasm.lammpstrajreader_len(this.__wbg_ptr);
2702
+ if (ret[2]) {
2703
+ throw takeFromExternrefTable0(ret[1]);
2704
+ }
2705
+ return ret[0] >>> 0;
2706
+ }
2707
+ /**
2708
+ * Create a new LAMMPS dump reader from string content.
2709
+ * @param {string} content
2710
+ */
2711
+ constructor(content) {
2712
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
2713
+ const len0 = WASM_VECTOR_LEN;
2714
+ const ret = wasm.lammpstrajreader_new(ptr0, len0);
2715
+ this.__wbg_ptr = ret >>> 0;
2716
+ LAMMPSTrajReaderFinalization.register(this, this.__wbg_ptr, this);
2717
+ return this;
2718
+ }
2719
+ /**
2720
+ * Read a frame at the given step index.
2721
+ * @param {number} step
2722
+ * @returns {Frame | undefined}
2723
+ */
2724
+ read(step) {
2725
+ const ret = wasm.lammpstrajreader_read(this.__wbg_ptr, step);
2726
+ if (ret[2]) {
2727
+ throw takeFromExternrefTable0(ret[1]);
2728
+ }
2729
+ return ret[0] === 0 ? undefined : Frame.__wrap(ret[0]);
2730
+ }
2731
+ }
2732
+ if (Symbol.dispose) LAMMPSTrajReader.prototype[Symbol.dispose] = LAMMPSTrajReader.prototype.free;
2733
+
2657
2734
  /**
2658
2735
  * Cell-list (linked-cell) based neighbor search.
2659
2736
  *
@@ -5027,9 +5104,9 @@ const GyrationTensorFinalization = (typeof FinalizationRegistry === 'undefined')
5027
5104
  const InertiaTensorFinalization = (typeof FinalizationRegistry === 'undefined')
5028
5105
  ? { register: () => {}, unregister: () => {} }
5029
5106
  : new FinalizationRegistry(ptr => wasm.__wbg_inertiatensor_free(ptr >>> 0, 1));
5030
- const LAMMPSDumpReaderFinalization = (typeof FinalizationRegistry === 'undefined')
5107
+ const LAMMPSTrajReaderFinalization = (typeof FinalizationRegistry === 'undefined')
5031
5108
  ? { register: () => {}, unregister: () => {} }
5032
- : new FinalizationRegistry(ptr => wasm.__wbg_lammpsdumpreader_free(ptr >>> 0, 1));
5109
+ : new FinalizationRegistry(ptr => wasm.__wbg_lammpstrajreader_free(ptr >>> 0, 1));
5033
5110
  const LAMMPSReaderFinalization = (typeof FinalizationRegistry === 'undefined')
5034
5111
  ? { register: () => {}, unregister: () => {} }
5035
5112
  : new FinalizationRegistry(ptr => wasm.__wbg_lammpsreader_free(ptr >>> 0, 1));
package/molrs_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "MolCrafts"
6
6
  ],
7
7
  "description": "WASM bindings for molrs",
8
- "version": "0.0.12",
8
+ "version": "0.0.13",
9
9
  "license": "BSD-3-Clause",
10
10
  "repository": {
11
11
  "type": "git",