@molcrafts/molrs 0.0.14 → 0.0.15

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
@@ -370,6 +370,58 @@ export class Block {
370
370
  * ```
371
371
  */
372
372
  setColU32(key: string, data: Uint32Array): void;
373
+ /**
374
+ * Declare this block as N-dimensional with the given `shape`.
375
+ *
376
+ * `shape.iter().product()` must equal the block's current `nrows`
377
+ * when the block has columns. Pass an empty array to clear the
378
+ * shape and revert to plain row-table semantics.
379
+ *
380
+ * This does **not** reshape column storage — columns remain
381
+ * row-major 1D buffers of length `product(shape)`. `shape` is
382
+ * structural metadata; consumers (e.g. the volumetric renderer in
383
+ * MolVis) use it to unflatten the row index back into N-D
384
+ * coordinates.
385
+ *
386
+ * # Errors
387
+ *
388
+ * Throws if `shape.iter().product()` does not match the block's
389
+ * existing `nrows`, or if the block handle has been invalidated.
390
+ *
391
+ * # Example (JavaScript)
392
+ *
393
+ * ```js
394
+ * const grid = frame.createBlock("grid");
395
+ * grid.setColF("electron_density", values); // values.length === 32*32*32
396
+ * grid.setShape(new Uint32Array([32, 32, 32]));
397
+ * ```
398
+ */
399
+ setShape(shape: Uint32Array): void;
400
+ /**
401
+ * Return the structural shape of the block as a `Uint32Array`.
402
+ *
403
+ * - Plain row tables (atoms, bonds): `[nrows]` — single-axis.
404
+ * - Volumetric grids: `[Nx, Ny, Nz]` — explicitly declared via
405
+ * [`setShape`](Self::set_shape).
406
+ * - Empty blocks: `[]`.
407
+ *
408
+ * `block.shape()` is uniform across all block kinds — the rank of
409
+ * the returned array is what distinguishes a plain table from a
410
+ * volumetric grid. The product of the shape always equals
411
+ * `block.nrows()`.
412
+ *
413
+ * # Errors
414
+ *
415
+ * Throws if the block handle has been invalidated.
416
+ *
417
+ * # Example (JavaScript)
418
+ *
419
+ * ```js
420
+ * const atomsShape = atoms.shape(); // Uint32Array([1000])
421
+ * const gridShape = grid.shape(); // Uint32Array([32, 32, 32])
422
+ * ```
423
+ */
424
+ shape(): Uint32Array;
373
425
  /**
374
426
  * Zero-copy JS float typed-array view into WASM linear memory.
375
427
  *
@@ -571,21 +623,25 @@ export class Box {
571
623
  */
572
624
  get_corners(): WasmArray;
573
625
  /**
574
- * Return the box edge lengths as a `WasmArray` with shape `[3]`.
575
- *
576
- * For orthorhombic boxes these are `[lx, ly, lz]`. For triclinic
577
- * boxes these are the lengths of the three cell vectors.
626
+ * Return the box's 3×3 cell matrix `h` as a `WasmArray` with shape
627
+ * `[9]`, **column-major** (column j of `h` is the j-th lattice
628
+ * vector). Suitable for direct consumption by `marchingCubes` and
629
+ * other code that expects the cell as a flat 3×3 column-major
630
+ * `Float64Array`.
578
631
  *
579
632
  * # Returns
580
633
  *
581
- * `WasmArray` containing `[lx, ly, lz]` in angstrom (A).
634
+ * `WasmArray` of length 9: `[h00, h10, h20, h01, h11, h21, h02, h12, h22]`,
635
+ * in angstrom (A).
582
636
  *
583
637
  * # Example (JavaScript)
584
638
  *
585
639
  * ```js
586
- * const L = box.lengths().toCopy(); // Float32Array or Float64Array [10, 10, 10]
640
+ * const cell = box.hMatrix().toCopy(); // Float64Array, length 9
641
+ * // col0 = a-vector = cell[0..3]
587
642
  * ```
588
643
  */
644
+ hMatrix(): WasmArray;
589
645
  lengths(): WasmArray;
590
646
  /**
591
647
  * Create a new box from a 3x3 cell matrix and origin.
@@ -666,6 +722,36 @@ export class Box {
666
722
  * ```
667
723
  */
668
724
  static ortho(lengths: Float64Array, origin: Float64Array, pbc_x: boolean, pbc_y: boolean, pbc_z: boolean): Box;
725
+ /**
726
+ * Return the box edge lengths as a `WasmArray` with shape `[3]`.
727
+ *
728
+ * For orthorhombic boxes these are `[lx, ly, lz]`. For triclinic
729
+ * boxes these are the lengths of the three cell vectors.
730
+ *
731
+ * # Returns
732
+ *
733
+ * `WasmArray` containing `[lx, ly, lz]` in angstrom (A).
734
+ *
735
+ * # Example (JavaScript)
736
+ *
737
+ * ```js
738
+ * const L = box.lengths().toCopy(); // Float32Array or Float64Array [10, 10, 10]
739
+ * ```
740
+ * Return the per-axis periodic boundary flags as a `Uint8Array`
741
+ * of length 3 (`[px, py, pz]`, 1 = periodic, 0 = open).
742
+ *
743
+ * Renderers that respect PBC (isosurface marching cubes,
744
+ * bond minimum-image, atom wrap-around) need this to decide
745
+ * whether to wrap coordinates across the cell.
746
+ *
747
+ * # Example (JavaScript)
748
+ *
749
+ * ```js
750
+ * const pbc = box.pbc(); // Uint8Array [1, 1, 1] for fully periodic
751
+ * const fullyPeriodic = pbc[0] === 1 && pbc[1] === 1 && pbc[2] === 1;
752
+ * ```
753
+ */
754
+ pbc(): Uint8Array;
669
755
  /**
670
756
  * Return the box tilt factors as a `WasmArray` with shape `[3]`.
671
757
  *
@@ -848,6 +934,130 @@ export class Box {
848
934
  wrapToBlock(coords: WasmArray, out_block: Block, out_key: string): void;
849
935
  }
850
936
 
937
+ /**
938
+ * VASP CHGCAR / CHGDIF volumetric data reader.
939
+ *
940
+ * Reads VASP-format charge density files (extension-less canonical name
941
+ * `CHGCAR` or `CHGCAR_*`). Produces a [`Frame`] with:
942
+ * - `"atoms"` block: `element` (string), `x`/`y`/`z` (F, Cartesian Å).
943
+ * - `"grid"` block: structural shape `[nx, ny, nz]`, columns
944
+ * `total` (always) and `diff` (when ISPIN=2).
945
+ * - `simbox`: triclinic POSCAR lattice in Å, fully periodic.
946
+ *
947
+ * CHGCAR is single-frame; only `step = 0` is valid.
948
+ *
949
+ * # Example (JavaScript)
950
+ *
951
+ * ```js
952
+ * const content = await file.text();
953
+ * const reader = new CHGCARReader(content);
954
+ * const frame = reader.read(0);
955
+ * const grid = frame.getBlock("grid");
956
+ * const total = grid.copyColF("total");
957
+ * ```
958
+ */
959
+ export class CHGCARReader {
960
+ free(): void;
961
+ [Symbol.dispose](): void;
962
+ isEmpty(): boolean;
963
+ len(): number;
964
+ /**
965
+ * Create a new CHGCAR reader from the file's text content.
966
+ */
967
+ constructor(content: string);
968
+ /**
969
+ * Read the frame at `step`. CHGCAR is single-frame.
970
+ *
971
+ * # Errors
972
+ *
973
+ * Throws a `JsValue` string on parse errors.
974
+ */
975
+ read(step: number): Frame | undefined;
976
+ }
977
+
978
+ /**
979
+ * Crystallographic Information File (CIF / mmCIF) reader.
980
+ *
981
+ * Each `data_*` block in the file becomes one [`Frame`]. Most CIF files
982
+ * contain a single block (one structure), but multi-block files (e.g.
983
+ * polymorphs of the same compound) are also supported and are exposed
984
+ * as a multi-frame sequence. The unit cell parameters
985
+ * (`_cell_length_a`, `_b`, `_c`, `_cell_angle_alpha`, `_beta`,
986
+ * `_gamma`) are converted to a 3x3 h-matrix on the Rust side and
987
+ * surface on the JS side as `frame.simbox`.
988
+ *
989
+ * Produces a [`Frame`] with an `"atoms"` block containing
990
+ * `element` (string), `x`, `y`, `z` (F, angstrom in Cartesian
991
+ * coordinates) and (when present in the file) `label`, `occupancy`,
992
+ * `bfactor` columns.
993
+ *
994
+ * CIF parsing reads the entire file on each `read(step)` call --
995
+ * random access is therefore O(file_size), but typical CIF files are
996
+ * small (< 1 MB) and the molvis lazy trajectory caches frames at the
997
+ * JS level, so this is rarely a bottleneck.
998
+ *
999
+ * # Example (JavaScript)
1000
+ *
1001
+ * ```js
1002
+ * const content = await file.text();
1003
+ * const reader = new CIFReader(content);
1004
+ * const frame = reader.read(0);
1005
+ * const atoms = frame.getBlock("atoms");
1006
+ * const box = frame.simbox; // populated from the unit cell
1007
+ * ```
1008
+ */
1009
+ export class CIFReader {
1010
+ free(): void;
1011
+ [Symbol.dispose](): void;
1012
+ /**
1013
+ * Check whether the file contains no valid blocks.
1014
+ *
1015
+ * # Errors
1016
+ *
1017
+ * Throws a `JsValue` string on parse errors.
1018
+ */
1019
+ isEmpty(): boolean;
1020
+ /**
1021
+ * Return the number of `data_*` blocks in the file.
1022
+ *
1023
+ * # Errors
1024
+ *
1025
+ * Throws a `JsValue` string on parse errors.
1026
+ */
1027
+ len(): number;
1028
+ /**
1029
+ * Create a new CIF reader from a string containing the file content.
1030
+ *
1031
+ * # Arguments
1032
+ *
1033
+ * * `content` - The full text content of a CIF file
1034
+ *
1035
+ * # Example (JavaScript)
1036
+ *
1037
+ * ```js
1038
+ * const reader = new CIFReader(cifString);
1039
+ * ```
1040
+ */
1041
+ constructor(content: string);
1042
+ /**
1043
+ * Read the frame at the given block index.
1044
+ *
1045
+ * # Arguments
1046
+ *
1047
+ * * `step` - 0-based index of the `data_*` block to return
1048
+ *
1049
+ * # Returns
1050
+ *
1051
+ * A [`Frame`] for the requested block, or `undefined` when
1052
+ * `step >= len()`.
1053
+ *
1054
+ * # Errors
1055
+ *
1056
+ * Throws a `JsValue` string on parse errors.
1057
+ */
1058
+ read(step: number): Frame | undefined;
1059
+ }
1060
+
851
1061
  /**
852
1062
  * Mass-weighted cluster center calculator.
853
1063
  */
@@ -1028,6 +1238,135 @@ export class ClusterResult {
1028
1238
  readonly numClusters: number;
1029
1239
  }
1030
1240
 
1241
+ /**
1242
+ * Gaussian Cube file reader.
1243
+ *
1244
+ * Cube files describe a single voxel grid with embedded atom geometry.
1245
+ * The reader produces a [`Frame`] with:
1246
+ * - `"atoms"` block: `element` (string), `atomic_number` (i32),
1247
+ * `charge` (F), `x`/`y`/`z` (F, **always Å** — Bohr files are converted
1248
+ * on read).
1249
+ * - `"grid"` block: structural shape `[nx, ny, nz]` and one f64 column
1250
+ * per scalar field — `density` for single-density files,
1251
+ * `mo_<idx>` for negative-natoms multi-orbital files.
1252
+ * - `simbox`: voxel cell × dims in Å.
1253
+ *
1254
+ * Cube is inherently single-frame (only `step = 0` is valid).
1255
+ *
1256
+ * # Example (JavaScript)
1257
+ *
1258
+ * ```js
1259
+ * const content = await file.text();
1260
+ * const reader = new CubeReader(content);
1261
+ * const frame = reader.read(0);
1262
+ * const grid = frame.getBlock("grid"); // shape [nx, ny, nz]
1263
+ * const density = grid.copyColF("density"); // owned Float64Array
1264
+ * ```
1265
+ */
1266
+ export class CubeReader {
1267
+ free(): void;
1268
+ [Symbol.dispose](): void;
1269
+ isEmpty(): boolean;
1270
+ /**
1271
+ * Return the number of frames (always 0 or 1).
1272
+ */
1273
+ len(): number;
1274
+ /**
1275
+ * Create a new Cube reader from the file's text content.
1276
+ */
1277
+ constructor(content: string);
1278
+ /**
1279
+ * Read the frame at `step`. Cube files are single-frame, so any
1280
+ * `step != 0` returns `undefined`.
1281
+ *
1282
+ * # Errors
1283
+ *
1284
+ * Throws a `JsValue` string on parse errors.
1285
+ */
1286
+ read(step: number): Frame | undefined;
1287
+ }
1288
+
1289
+ /**
1290
+ * DCD trajectory file reader.
1291
+ *
1292
+ * DCD is a binary multi-frame trajectory format originally used by
1293
+ * CHARMM and now widely produced by NAMD / OpenMM / GROMACS-via-VMD.
1294
+ * This wrapper accepts the file as raw bytes (`Uint8Array`) since
1295
+ * DCD is not text-encoded — passing a JS string would corrupt the
1296
+ * fixed-width Fortran record markers.
1297
+ *
1298
+ * Each frame produces a [`Frame`] with an `"atoms"` block carrying
1299
+ * `x`, `y`, `z` (F, angstrom). Box/cell information, when the DCD
1300
+ * header declares it present, is attached as the frame's `simbox`.
1301
+ *
1302
+ * # Example (JavaScript)
1303
+ *
1304
+ * ```js
1305
+ * const bytes = new Uint8Array(await blob.arrayBuffer());
1306
+ * const reader = new DCDReader(bytes);
1307
+ * console.log(reader.len()); // number of frames
1308
+ *
1309
+ * const frame = reader.read(0); // first frame
1310
+ * const atoms = frame.getBlock("atoms");
1311
+ * const x = atoms.copyColF("x");
1312
+ * ```
1313
+ */
1314
+ export class DCDReader {
1315
+ free(): void;
1316
+ [Symbol.dispose](): void;
1317
+ /**
1318
+ * Check whether the file contains no frames.
1319
+ *
1320
+ * # Errors
1321
+ *
1322
+ * Throws a `JsValue` string if the header cannot be parsed.
1323
+ */
1324
+ isEmpty(): boolean;
1325
+ /**
1326
+ * Return the number of frames in the DCD file.
1327
+ *
1328
+ * # Errors
1329
+ *
1330
+ * Throws a `JsValue` string if the header cannot be parsed.
1331
+ */
1332
+ len(): number;
1333
+ /**
1334
+ * Create a new DCD reader from the file's raw bytes.
1335
+ *
1336
+ * # Arguments
1337
+ *
1338
+ * * `bytes` - The full binary content of a DCD file. The reader
1339
+ * takes ownership of an internal copy, so the caller is free
1340
+ * to discard the buffer immediately after this returns.
1341
+ *
1342
+ * # Example (JavaScript)
1343
+ *
1344
+ * ```js
1345
+ * const bytes = new Uint8Array(await file.arrayBuffer());
1346
+ * const reader = new DCDReader(bytes);
1347
+ * ```
1348
+ */
1349
+ constructor(bytes: Uint8Array);
1350
+ /**
1351
+ * Read a frame at the given step index.
1352
+ *
1353
+ * # Arguments
1354
+ *
1355
+ * * `step` - Zero-based frame index
1356
+ *
1357
+ * # Returns
1358
+ *
1359
+ * A [`Frame`] if the step exists, or `undefined` if `step` is
1360
+ * out of range.
1361
+ *
1362
+ * # Errors
1363
+ *
1364
+ * Throws a `JsValue` string on parse errors (truncated record,
1365
+ * malformed header, byte-order mismatch).
1366
+ */
1367
+ read(step: number): Frame | undefined;
1368
+ }
1369
+
1031
1370
  /**
1032
1371
  * Hierarchical data container mapping string keys to typed [`Block`]s.
1033
1372
  *
@@ -1055,6 +1394,21 @@ export class ClusterResult {
1055
1394
  export class Frame {
1056
1395
  free(): void;
1057
1396
  [Symbol.dispose](): void;
1397
+ /**
1398
+ * Return the names of all blocks attached to this frame.
1399
+ *
1400
+ * Iteration order matches the underlying `HashMap` and is therefore
1401
+ * not stable across runs — callers that need a deterministic order
1402
+ * must sort on the JS side. Returns an empty array if the frame
1403
+ * has been dropped.
1404
+ *
1405
+ * # Example (JavaScript)
1406
+ *
1407
+ * ```js
1408
+ * const names = frame.blockNames(); // e.g. ["atoms", "bonds"]
1409
+ * ```
1410
+ */
1411
+ blockNames(): string[];
1058
1412
  /**
1059
1413
  * Remove all blocks from this frame (but keep the frame alive).
1060
1414
  *
@@ -1136,28 +1490,6 @@ export class Frame {
1136
1490
  * ```
1137
1491
  */
1138
1492
  getBlock(key: string): Block | undefined;
1139
- /**
1140
- * Retrieve a named grid attached to this frame.
1141
- *
1142
- * Returns a cloned [`Grid`] wrapper, or `undefined` if the grid does
1143
- * not exist. The returned object is independent of the frame — mutations
1144
- * to it are not reflected in the frame without a subsequent
1145
- * [`insertGrid`](Frame::insert_grid) call.
1146
- *
1147
- * # Arguments
1148
- *
1149
- * * `name` — Grid name to retrieve.
1150
- *
1151
- * # Example (JavaScript)
1152
- *
1153
- * ```js
1154
- * const g = frame.getGrid("chgcar");
1155
- * if (g) {
1156
- * const arr = g.getArray("rho");
1157
- * }
1158
- * ```
1159
- */
1160
- getGrid(name: string): Grid | undefined;
1161
1493
  /**
1162
1494
  * Read a per-frame metadata value as a numeric scalar.
1163
1495
  *
@@ -1183,30 +1515,6 @@ export class Frame {
1183
1515
  * ```
1184
1516
  */
1185
1517
  getMetaScalar(name: string): number | undefined;
1186
- /**
1187
- * Return the names of all grids attached to this frame.
1188
- *
1189
- * # Example (JavaScript)
1190
- *
1191
- * ```js
1192
- * const names = frame.gridNames(); // e.g. ["chgcar", "spin"]
1193
- * ```
1194
- */
1195
- gridNames(): Array<any>;
1196
- /**
1197
- * Returns `true` if a named grid is attached to this frame.
1198
- *
1199
- * # Arguments
1200
- *
1201
- * * `name` — Grid name to look up.
1202
- *
1203
- * # Example (JavaScript)
1204
- *
1205
- * ```js
1206
- * frame.hasGrid("chgcar"); // true or false
1207
- * ```
1208
- */
1209
- hasGrid(name: string): boolean;
1210
1518
  /**
1211
1519
  * Insert a block by deep-copying its data into this frame's store.
1212
1520
  *
@@ -1235,36 +1543,11 @@ export class Frame {
1235
1543
  */
1236
1544
  insertBlock(key: string, block: Block): void;
1237
1545
  /**
1238
- * Attach a grid to this frame under the given name.
1546
+ * Return the names of all metadata keys on this frame.
1239
1547
  *
1240
- * If a grid with the same name already exists it is replaced. The grid
1241
- * data is moved into the frame; the JS `Grid` object becomes empty after
1242
- * this call and should not be reused.
1243
- *
1244
- * # Arguments
1245
- *
1246
- * * `name` — Name to store the grid under (e.g., `"chgcar"`).
1247
- * * `grid` — The [`Grid`] to attach.
1248
- *
1249
- * # Errors
1250
- *
1251
- * Throws a `JsValue` string if the frame has been dropped.
1252
- *
1253
- * # Example (JavaScript)
1254
- *
1255
- * ```js
1256
- * const grid = new Grid(10, 10, 10, origin, cell, true, true, true);
1257
- * grid.insertArray("rho", rhoData);
1258
- * frame.insertGrid("chgcar", grid);
1259
- * ```
1260
- */
1261
- insertGrid(name: string, grid: Grid): void;
1262
- /**
1263
- * Return the names of all metadata keys on this frame.
1264
- *
1265
- * Includes all keys regardless of whether their values are numeric
1266
- * or categorical. To filter to numeric keys, iterate and call
1267
- * [`getMetaScalar`](Self::get_meta_scalar) on each.
1548
+ * Includes all keys regardless of whether their values are numeric
1549
+ * or categorical. To filter to numeric keys, iterate and call
1550
+ * [`getMetaScalar`](Self::get_meta_scalar) on each.
1268
1551
  *
1269
1552
  * # Example (JavaScript)
1270
1553
  *
@@ -1302,24 +1585,6 @@ export class Frame {
1302
1585
  * ```
1303
1586
  */
1304
1587
  removeBlock(key: string): void;
1305
- /**
1306
- * Remove a named grid from this frame.
1307
- *
1308
- * # Arguments
1309
- *
1310
- * * `name` — Grid name to remove.
1311
- *
1312
- * # Errors
1313
- *
1314
- * Throws a `JsValue` string if the frame has been dropped.
1315
- *
1316
- * # Example (JavaScript)
1317
- *
1318
- * ```js
1319
- * frame.removeGrid("chgcar");
1320
- * ```
1321
- */
1322
- removeGrid(name: string): void;
1323
1588
  /**
1324
1589
  * Rename a block from `old_key` to `new_key`.
1325
1590
  *
@@ -1439,206 +1704,26 @@ export class Frame {
1439
1704
  }
1440
1705
 
1441
1706
  /**
1442
- * A uniform spatial grid storing multiple named scalar arrays.
1707
+ * One frame's location inside the source byte stream.
1443
1708
  *
1444
- * All arrays in a `Grid` share the same spatial definition: dimensions
1445
- * (`[nx, ny, nz]`), Cartesian origin, cell matrix (columns are lattice
1446
- * vectors, matching VASP/molrs convention), and periodic boundary flags.
1447
- *
1448
- * # Example (JavaScript)
1449
- *
1450
- * ```js
1451
- * // Create a 10×10×10 cubic grid
1452
- * const origin = new Float32Array([0, 0, 0]);
1453
- * const cell = new Float32Array([
1454
- * 10, 0, 0, // first column (a vector)
1455
- * 0,10, 0, // second column (b vector)
1456
- * 0, 0,10, // third column (c vector)
1457
- * ]);
1458
- * const grid = new Grid(10, 10, 10, origin, cell, true, true, true);
1459
- *
1460
- * // Insert a density array (must have length = 10*10*10 = 1000)
1461
- * const rho = new Float32Array(1000).fill(1.0);
1462
- * grid.insertArray("rho", rho);
1463
- *
1464
- * // Retrieve it
1465
- * const arr = grid.getArray("rho");
1466
- * console.log(arr.toCopy());
1467
- * ```
1709
+ * `byteOffset` is the absolute byte position of the frame's first byte
1710
+ * inside the source (round-tripped through `f64`; the spec caps source
1711
+ * size at 1 TB which is well within `Number.MAX_SAFE_INTEGER`).
1712
+ * `byteLen` is `u32` — per-frame size never exceeds the worker chunk
1713
+ * size plus a small slack.
1468
1714
  */
1469
- export class Grid {
1715
+ export class FrameIndexEntry {
1716
+ private constructor();
1470
1717
  free(): void;
1471
1718
  [Symbol.dispose](): void;
1472
1719
  /**
1473
- * Names of all scalar arrays stored in this grid.
1474
- *
1475
- * # Example (JavaScript)
1476
- *
1477
- * ```js
1478
- * const names = grid.arrayNames(); // e.g. ["rho", "spin"]
1479
- * ```
1480
- */
1481
- arrayNames(): Array<any>;
1482
- /**
1483
- * Cell matrix in Ångström as a flat array of length 9 in column-major
1484
- * order (columns are lattice vectors, matching VASP/molrs convention).
1485
- *
1486
- * Layout: `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`
1487
- *
1488
- * # Example (JavaScript)
1489
- *
1490
- * ```js
1491
- * const c = grid.cell();
1492
- * const flat = c.toCopy(); // Float32Array of length 9
1493
- * ```
1494
- */
1495
- cell(): WasmArray;
1496
- /**
1497
- * Grid dimensions `[nx, ny, nz]`.
1498
- *
1499
- * # Example (JavaScript)
1500
- *
1501
- * ```js
1502
- * console.log(grid.dim()); // [10, 10, 10]
1503
- * ```
1504
- */
1505
- dim(): Uint32Array;
1506
- /**
1507
- * Retrieve a named scalar array as a zero-copy `Float64Array` view
1508
- * over the underlying WASM memory. Flat row-major order, length
1509
- * `nx * ny * nz`. Use [`Grid::dim`] for shape.
1510
- *
1511
- * **Warning**: the view is invalidated on any WASM memory growth.
1512
- * Copy it in JS (`new Float64Array(view)`) if it needs to outlive
1513
- * subsequent allocations.
1514
- *
1515
- * Returns `undefined` if the named array does not exist.
1516
- *
1517
- * # Example (JavaScript)
1518
- *
1519
- * ```js
1520
- * const view = grid.getArray("rho"); // zero-copy
1521
- * const copy = new Float64Array(view); // owned copy if needed
1522
- * ```
1523
- */
1524
- getArray(name: string): Float64Array | undefined;
1525
- /**
1526
- * Returns `true` if a named array is present in this grid.
1527
- *
1528
- * # Arguments
1529
- *
1530
- * * `name` — Array name to look up.
1531
- *
1532
- * # Example (JavaScript)
1533
- *
1534
- * ```js
1535
- * grid.hasArray("rho"); // true or false
1536
- * ```
1537
- */
1538
- hasArray(name: string): boolean;
1539
- /**
1540
- * Insert (or replace) a named scalar array.
1541
- *
1542
- * The provided `data` must have exactly `nx * ny * nz` elements in
1543
- * row-major `(ix, iy, iz)` order.
1544
- *
1545
- * # Arguments
1546
- *
1547
- * * `name` — Array name.
1548
- * * `data` — Float32Array with length equal to `grid.total()`.
1549
- *
1550
- * # Errors
1551
- *
1552
- * Throws if `data.length != nx * ny * nz`.
1553
- *
1554
- * # Example (JavaScript)
1555
- *
1556
- * ```js
1557
- * const rho = new Float32Array(grid.total()).fill(0.5);
1558
- * grid.insertArray("rho", rho);
1559
- * ```
1560
- */
1561
- insertArray(name: string, data: Float64Array): void;
1562
- /**
1563
- * Returns `true` if no arrays are stored.
1564
- *
1565
- * # Example (JavaScript)
1566
- *
1567
- * ```js
1568
- * console.log(grid.isEmpty()); // true for a freshly created grid
1569
- * ```
1570
- */
1571
- isEmpty(): boolean;
1572
- /**
1573
- * Number of named arrays stored in this grid.
1574
- *
1575
- * # Example (JavaScript)
1576
- *
1577
- * ```js
1578
- * console.log(grid.len()); // e.g. 2
1579
- * ```
1580
- */
1581
- len(): number;
1582
- /**
1583
- * Create a new empty grid with the given spatial definition.
1584
- *
1585
- * # Arguments
1586
- *
1587
- * * `dim_x`, `dim_y`, `dim_z` — Number of grid points along each axis.
1588
- * * `origin` — Float32Array of length 3: Cartesian origin in Ångström.
1589
- * * `cell` — Float32Array of length 9: cell matrix in column-major order.
1590
- * `cell[0..3]` is the first lattice vector (a), `cell[3..6]` is b,
1591
- * `cell[6..9]` is c (matching VASP/molrs convention where columns are
1592
- * lattice vectors).
1593
- * * `pbc_x`, `pbc_y`, `pbc_z` — Periodic boundary flags for each axis.
1594
- *
1595
- * # Errors
1596
- *
1597
- * Throws if `origin` does not have length 3, or `cell` does not have
1598
- * length 9.
1599
- *
1600
- * # Example (JavaScript)
1601
- *
1602
- * ```js
1603
- * const origin = new Float32Array([0, 0, 0]);
1604
- * const cell = new Float32Array([10,0,0, 0,10,0, 0,0,10]);
1605
- * const grid = new Grid(10, 10, 10, origin, cell, true, true, true);
1606
- * ```
1607
- */
1608
- constructor(dim_x: number, dim_y: number, dim_z: number, origin: Float64Array, cell: Float64Array, pbc_x: boolean, pbc_y: boolean, pbc_z: boolean);
1609
- /**
1610
- * Cartesian origin in Ångström as a 1-D array of length 3.
1611
- *
1612
- * # Example (JavaScript)
1613
- *
1614
- * ```js
1615
- * const o = grid.origin();
1616
- * const arr = o.toCopy(); // Float32Array [ox, oy, oz]
1617
- * ```
1618
- */
1619
- origin(): WasmArray;
1620
- /**
1621
- * Periodic boundary flags as a `Uint8Array`-compatible slice.
1622
- *
1623
- * Each element is `1` (periodic) or `0` (not periodic).
1624
- *
1625
- * # Example (JavaScript)
1626
- *
1627
- * ```js
1628
- * console.log(grid.pbc()); // [1, 1, 1]
1629
- * ```
1720
+ * Size of this frame's encoded byte range, in bytes.
1630
1721
  */
1631
- pbc(): Uint8Array;
1722
+ readonly byteLen: number;
1632
1723
  /**
1633
- * Total number of voxels: `nx * ny * nz`.
1634
- *
1635
- * # Example (JavaScript)
1636
- *
1637
- * ```js
1638
- * console.log(grid.total()); // 1000 for a 10×10×10 grid
1639
- * ```
1724
+ * Absolute byte offset of this frame inside the source (in bytes).
1640
1725
  */
1641
- total(): number;
1726
+ readonly byteOffset: number;
1642
1727
  }
1643
1728
 
1644
1729
  /**
@@ -2842,6 +2927,382 @@ export class WasmKMeans {
2842
2927
  constructor(k: number, max_iter: number, seed: number);
2843
2928
  }
2844
2929
 
2930
+ export class WasmLammpsDataStream {
2931
+ free(): void;
2932
+ [Symbol.dispose](): void;
2933
+ /**
2934
+ * Resize the reusable input buffer so it can hold at least
2935
+ * `len` bytes, and return the WASM linear-memory pointer to
2936
+ * its first byte.
2937
+ *
2938
+ * CALLER MUST RE-DERIVE THIS POINTER AFTER ANY OTHER WASM CALL —
2939
+ * `wasm.memory.buffer` may have been detached by a `memory.grow`.
2940
+ */
2941
+ allocInputBuffer(len: number): number;
2942
+ /**
2943
+ * Number of blocks in the most recently parsed frame.
2944
+ */
2945
+ blockCount(): number;
2946
+ /**
2947
+ * Name of block `blockIdx`, or empty string if out of range.
2948
+ */
2949
+ blockName(block_idx: number): string;
2950
+ /**
2951
+ * Number of columns in block `blockIdx`.
2952
+ */
2953
+ columnCount(block_idx: number): number;
2954
+ /**
2955
+ * Column dtype string at `(blockIdx, colIdx)`. One of `"f64"`,
2956
+ * `"u32"`, `"i32"`, `"string"` — or `"bool"` / `"u8"` if a
2957
+ * future parser emits those (current streaming formats do not).
2958
+ * Empty string if the index is out of range.
2959
+ */
2960
+ columnDtype(block_idx: number, col_idx: number): string;
2961
+ /**
2962
+ * Total flat element count of the column. For multi-dimensional
2963
+ * columns (e.g. an Nx3 positions array) this is the product of
2964
+ * all axes — i.e. the length of the slice the matching
2965
+ * `columnPtr*` points at.
2966
+ */
2967
+ columnLen(block_idx: number, col_idx: number): number;
2968
+ /**
2969
+ * Column name at `(blockIdx, colIdx)`, or empty string if
2970
+ * either index is out of range.
2971
+ */
2972
+ columnName(block_idx: number, col_idx: number): string;
2973
+ /**
2974
+ * Pointer to the contiguous `f64` slice backing this column,
2975
+ * or 0 (null) if the column is missing or has the wrong
2976
+ * dtype.
2977
+ *
2978
+ * **Lifetime**: valid only until the next non-trivial wasm
2979
+ * call. See the module-level memory-grow contract.
2980
+ */
2981
+ columnPtrF64(block_idx: number, col_idx: number): number;
2982
+ /**
2983
+ * Pointer to the contiguous `i32` slice backing this column,
2984
+ * or 0 (null) if the column is missing or has the wrong
2985
+ * dtype.
2986
+ *
2987
+ * **Lifetime**: valid only until the next non-trivial wasm
2988
+ * call. See the module-level memory-grow contract.
2989
+ */
2990
+ columnPtrI32(block_idx: number, col_idx: number): number;
2991
+ /**
2992
+ * Pointer to the contiguous `u32` slice backing this column,
2993
+ * or 0 (null) if the column is missing or has the wrong
2994
+ * dtype.
2995
+ *
2996
+ * **Lifetime**: valid only until the next non-trivial wasm
2997
+ * call. See the module-level memory-grow contract.
2998
+ */
2999
+ columnPtrU32(block_idx: number, col_idx: number): number;
3000
+ /**
3001
+ * Copy a string column out by value. Returns an empty array
3002
+ * if the column is missing or not a string column.
3003
+ */
3004
+ columnStrings(block_idx: number, col_idx: number): string[];
3005
+ /**
3006
+ * Feed the first `len` bytes of the input buffer into the
3007
+ * indexer at absolute source offset `globalOffset`. Returns
3008
+ * any frame entries that became finalized as a result.
3009
+ *
3010
+ * `globalOffset` is round-tripped through `f64`; per the
3011
+ * streaming protocol the source size is capped at 1 TB
3012
+ * (well within `Number.MAX_SAFE_INTEGER`).
3013
+ */
3014
+ feedIndexChunk(global_offset: number, len: number): FrameIndexEntry[];
3015
+ /**
3016
+ * Signal end-of-stream; return any trailing frame entry. The
3017
+ * indexer is consumed and further `feedIndexChunk` calls
3018
+ * throw.
3019
+ */
3020
+ finishIndex(): FrameIndexEntry[];
3021
+ /**
3022
+ * Number of named scalar arrays in grid `gridIdx`.
3023
+ */
3024
+ gridArrayCount(grid_idx: number): number;
3025
+ /**
3026
+ * Length (number of `f64` elements) of the grid scalar field.
3027
+ */
3028
+ gridArrayLen(grid_idx: number, array_idx: number): number;
3029
+ /**
3030
+ * Name of scalar array `(gridIdx, arrayIdx)`, or empty string
3031
+ * if either index is out of range.
3032
+ */
3033
+ gridArrayName(grid_idx: number, array_idx: number): string;
3034
+ /**
3035
+ * Pointer to the contiguous `f64` slice backing the grid
3036
+ * scalar field, or 0 (null) if either index is out of range.
3037
+ *
3038
+ * **Lifetime**: valid only until the next non-trivial wasm
3039
+ * call. See the module-level memory-grow contract.
3040
+ */
3041
+ gridArrayPtrF64(grid_idx: number, array_idx: number): number;
3042
+ /**
3043
+ * Grid lattice cell as a length-9 `Float64Array` (column-major:
3044
+ * `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`).
3045
+ */
3046
+ gridCell(grid_idx: number): Float64Array;
3047
+ /**
3048
+ * Number of named grids attached to the current frame.
3049
+ */
3050
+ gridCount(): number;
3051
+ /**
3052
+ * Name of grid `gridIdx`, or empty string if out of range.
3053
+ */
3054
+ gridName(grid_idx: number): string;
3055
+ /**
3056
+ * Grid origin (Cartesian, Å) as a length-3 `Float64Array`.
3057
+ */
3058
+ gridOrigin(grid_idx: number): Float64Array;
3059
+ /**
3060
+ * Grid PBC flags as a length-3 `Uint8Array` (`1` = periodic,
3061
+ * `0` = open).
3062
+ */
3063
+ gridPbc(grid_idx: number): Uint8Array;
3064
+ /**
3065
+ * Grid dimensions `[nx, ny, nz]` as a length-3 `Uint32Array`.
3066
+ */
3067
+ gridShape(grid_idx: number): Uint32Array;
3068
+ /**
3069
+ * Current capacity (in bytes) of the reusable input buffer.
3070
+ */
3071
+ inputCapacity(): number;
3072
+ /**
3073
+ * Create a new streaming reader. The reusable input buffer
3074
+ * starts empty; call [`allocInputBuffer`] before feeding data.
3075
+ */
3076
+ constructor();
3077
+ /**
3078
+ * Decode the byte range `[offset, offset + len)` from the
3079
+ * reusable input buffer as a single frame. Replaces any
3080
+ * previously cached output; the caller must extract data
3081
+ * before the next `parseRangeInInput` (the same buffer can
3082
+ * be overwritten in between).
3083
+ */
3084
+ parseRangeInInput(offset: number, len: number): void;
3085
+ /**
3086
+ * Drop the cached output frame, releasing its memory and
3087
+ * invalidating any outstanding `columnPtr*` / `gridArrayPtr*`
3088
+ * pointers. Subsequent extraction calls return 0 / empty
3089
+ * until the next `parseRangeInInput`.
3090
+ */
3091
+ releaseFrame(): void;
3092
+ /**
3093
+ * Box H-matrix as a length-9 `Float64Array` (column-major:
3094
+ * `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`),
3095
+ * or `undefined` if the frame has no simbox.
3096
+ *
3097
+ * Returned by VALUE — the typed array is owned by JS and is
3098
+ * stable across subsequent wasm calls.
3099
+ */
3100
+ simboxH(): Float64Array | undefined;
3101
+ /**
3102
+ * Box origin as a length-3 `Float64Array`, or `undefined` if
3103
+ * the frame has no simbox.
3104
+ */
3105
+ simboxOrigin(): Float64Array | undefined;
3106
+ /**
3107
+ * Per-axis PBC flags as a length-3 `Uint8Array` (`1` = periodic,
3108
+ * `0` = open), or `undefined` if the frame has no simbox.
3109
+ *
3110
+ * (wasm-bindgen does not support `[bool; 3]` returns natively,
3111
+ * hence the `Uint8Array` wire format. The spec calls for
3112
+ * `[boolean, boolean, boolean]`; the JS side is expected to
3113
+ * `Boolean(arr[i])` each entry.)
3114
+ */
3115
+ simboxPbc(): Uint8Array | undefined;
3116
+ }
3117
+
3118
+ export class WasmLammpsDumpStream {
3119
+ free(): void;
3120
+ [Symbol.dispose](): void;
3121
+ /**
3122
+ * Resize the reusable input buffer so it can hold at least
3123
+ * `len` bytes, and return the WASM linear-memory pointer to
3124
+ * its first byte.
3125
+ *
3126
+ * CALLER MUST RE-DERIVE THIS POINTER AFTER ANY OTHER WASM CALL —
3127
+ * `wasm.memory.buffer` may have been detached by a `memory.grow`.
3128
+ */
3129
+ allocInputBuffer(len: number): number;
3130
+ /**
3131
+ * Number of blocks in the most recently parsed frame.
3132
+ */
3133
+ blockCount(): number;
3134
+ /**
3135
+ * Name of block `blockIdx`, or empty string if out of range.
3136
+ */
3137
+ blockName(block_idx: number): string;
3138
+ /**
3139
+ * Number of columns in block `blockIdx`.
3140
+ */
3141
+ columnCount(block_idx: number): number;
3142
+ /**
3143
+ * Column dtype string at `(blockIdx, colIdx)`. One of `"f64"`,
3144
+ * `"u32"`, `"i32"`, `"string"` — or `"bool"` / `"u8"` if a
3145
+ * future parser emits those (current streaming formats do not).
3146
+ * Empty string if the index is out of range.
3147
+ */
3148
+ columnDtype(block_idx: number, col_idx: number): string;
3149
+ /**
3150
+ * Total flat element count of the column. For multi-dimensional
3151
+ * columns (e.g. an Nx3 positions array) this is the product of
3152
+ * all axes — i.e. the length of the slice the matching
3153
+ * `columnPtr*` points at.
3154
+ */
3155
+ columnLen(block_idx: number, col_idx: number): number;
3156
+ /**
3157
+ * Column name at `(blockIdx, colIdx)`, or empty string if
3158
+ * either index is out of range.
3159
+ */
3160
+ columnName(block_idx: number, col_idx: number): string;
3161
+ /**
3162
+ * Pointer to the contiguous `f64` slice backing this column,
3163
+ * or 0 (null) if the column is missing or has the wrong
3164
+ * dtype.
3165
+ *
3166
+ * **Lifetime**: valid only until the next non-trivial wasm
3167
+ * call. See the module-level memory-grow contract.
3168
+ */
3169
+ columnPtrF64(block_idx: number, col_idx: number): number;
3170
+ /**
3171
+ * Pointer to the contiguous `i32` slice backing this column,
3172
+ * or 0 (null) if the column is missing or has the wrong
3173
+ * dtype.
3174
+ *
3175
+ * **Lifetime**: valid only until the next non-trivial wasm
3176
+ * call. See the module-level memory-grow contract.
3177
+ */
3178
+ columnPtrI32(block_idx: number, col_idx: number): number;
3179
+ /**
3180
+ * Pointer to the contiguous `u32` slice backing this column,
3181
+ * or 0 (null) if the column is missing or has the wrong
3182
+ * dtype.
3183
+ *
3184
+ * **Lifetime**: valid only until the next non-trivial wasm
3185
+ * call. See the module-level memory-grow contract.
3186
+ */
3187
+ columnPtrU32(block_idx: number, col_idx: number): number;
3188
+ /**
3189
+ * Copy a string column out by value. Returns an empty array
3190
+ * if the column is missing or not a string column.
3191
+ */
3192
+ columnStrings(block_idx: number, col_idx: number): string[];
3193
+ /**
3194
+ * Feed the first `len` bytes of the input buffer into the
3195
+ * indexer at absolute source offset `globalOffset`. Returns
3196
+ * any frame entries that became finalized as a result.
3197
+ *
3198
+ * `globalOffset` is round-tripped through `f64`; per the
3199
+ * streaming protocol the source size is capped at 1 TB
3200
+ * (well within `Number.MAX_SAFE_INTEGER`).
3201
+ */
3202
+ feedIndexChunk(global_offset: number, len: number): FrameIndexEntry[];
3203
+ /**
3204
+ * Signal end-of-stream; return any trailing frame entry. The
3205
+ * indexer is consumed and further `feedIndexChunk` calls
3206
+ * throw.
3207
+ */
3208
+ finishIndex(): FrameIndexEntry[];
3209
+ /**
3210
+ * Number of named scalar arrays in grid `gridIdx`.
3211
+ */
3212
+ gridArrayCount(grid_idx: number): number;
3213
+ /**
3214
+ * Length (number of `f64` elements) of the grid scalar field.
3215
+ */
3216
+ gridArrayLen(grid_idx: number, array_idx: number): number;
3217
+ /**
3218
+ * Name of scalar array `(gridIdx, arrayIdx)`, or empty string
3219
+ * if either index is out of range.
3220
+ */
3221
+ gridArrayName(grid_idx: number, array_idx: number): string;
3222
+ /**
3223
+ * Pointer to the contiguous `f64` slice backing the grid
3224
+ * scalar field, or 0 (null) if either index is out of range.
3225
+ *
3226
+ * **Lifetime**: valid only until the next non-trivial wasm
3227
+ * call. See the module-level memory-grow contract.
3228
+ */
3229
+ gridArrayPtrF64(grid_idx: number, array_idx: number): number;
3230
+ /**
3231
+ * Grid lattice cell as a length-9 `Float64Array` (column-major:
3232
+ * `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`).
3233
+ */
3234
+ gridCell(grid_idx: number): Float64Array;
3235
+ /**
3236
+ * Number of named grids attached to the current frame.
3237
+ */
3238
+ gridCount(): number;
3239
+ /**
3240
+ * Name of grid `gridIdx`, or empty string if out of range.
3241
+ */
3242
+ gridName(grid_idx: number): string;
3243
+ /**
3244
+ * Grid origin (Cartesian, Å) as a length-3 `Float64Array`.
3245
+ */
3246
+ gridOrigin(grid_idx: number): Float64Array;
3247
+ /**
3248
+ * Grid PBC flags as a length-3 `Uint8Array` (`1` = periodic,
3249
+ * `0` = open).
3250
+ */
3251
+ gridPbc(grid_idx: number): Uint8Array;
3252
+ /**
3253
+ * Grid dimensions `[nx, ny, nz]` as a length-3 `Uint32Array`.
3254
+ */
3255
+ gridShape(grid_idx: number): Uint32Array;
3256
+ /**
3257
+ * Current capacity (in bytes) of the reusable input buffer.
3258
+ */
3259
+ inputCapacity(): number;
3260
+ /**
3261
+ * Create a new streaming reader. The reusable input buffer
3262
+ * starts empty; call [`allocInputBuffer`] before feeding data.
3263
+ */
3264
+ constructor();
3265
+ /**
3266
+ * Decode the byte range `[offset, offset + len)` from the
3267
+ * reusable input buffer as a single frame. Replaces any
3268
+ * previously cached output; the caller must extract data
3269
+ * before the next `parseRangeInInput` (the same buffer can
3270
+ * be overwritten in between).
3271
+ */
3272
+ parseRangeInInput(offset: number, len: number): void;
3273
+ /**
3274
+ * Drop the cached output frame, releasing its memory and
3275
+ * invalidating any outstanding `columnPtr*` / `gridArrayPtr*`
3276
+ * pointers. Subsequent extraction calls return 0 / empty
3277
+ * until the next `parseRangeInInput`.
3278
+ */
3279
+ releaseFrame(): void;
3280
+ /**
3281
+ * Box H-matrix as a length-9 `Float64Array` (column-major:
3282
+ * `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`),
3283
+ * or `undefined` if the frame has no simbox.
3284
+ *
3285
+ * Returned by VALUE — the typed array is owned by JS and is
3286
+ * stable across subsequent wasm calls.
3287
+ */
3288
+ simboxH(): Float64Array | undefined;
3289
+ /**
3290
+ * Box origin as a length-3 `Float64Array`, or `undefined` if
3291
+ * the frame has no simbox.
3292
+ */
3293
+ simboxOrigin(): Float64Array | undefined;
3294
+ /**
3295
+ * Per-axis PBC flags as a length-3 `Uint8Array` (`1` = periodic,
3296
+ * `0` = open), or `undefined` if the frame has no simbox.
3297
+ *
3298
+ * (wasm-bindgen does not support `[bool; 3]` returns natively,
3299
+ * hence the `Uint8Array` wire format. The spec calls for
3300
+ * `[boolean, boolean, boolean]`; the JS side is expected to
3301
+ * `Boolean(arr[i])` each entry.)
3302
+ */
3303
+ simboxPbc(): Uint8Array | undefined;
3304
+ }
3305
+
2845
3306
  /**
2846
3307
  * Stateless wrapper for [`molrs_compute::pca::Pca2`].
2847
3308
  *
@@ -2906,6 +3367,570 @@ export class WasmPcaResult {
2906
3367
  variance(): Float64Array;
2907
3368
  }
2908
3369
 
3370
+ export class WasmPdbStream {
3371
+ free(): void;
3372
+ [Symbol.dispose](): void;
3373
+ /**
3374
+ * Resize the reusable input buffer so it can hold at least
3375
+ * `len` bytes, and return the WASM linear-memory pointer to
3376
+ * its first byte.
3377
+ *
3378
+ * CALLER MUST RE-DERIVE THIS POINTER AFTER ANY OTHER WASM CALL —
3379
+ * `wasm.memory.buffer` may have been detached by a `memory.grow`.
3380
+ */
3381
+ allocInputBuffer(len: number): number;
3382
+ /**
3383
+ * Number of blocks in the most recently parsed frame.
3384
+ */
3385
+ blockCount(): number;
3386
+ /**
3387
+ * Name of block `blockIdx`, or empty string if out of range.
3388
+ */
3389
+ blockName(block_idx: number): string;
3390
+ /**
3391
+ * Number of columns in block `blockIdx`.
3392
+ */
3393
+ columnCount(block_idx: number): number;
3394
+ /**
3395
+ * Column dtype string at `(blockIdx, colIdx)`. One of `"f64"`,
3396
+ * `"u32"`, `"i32"`, `"string"` — or `"bool"` / `"u8"` if a
3397
+ * future parser emits those (current streaming formats do not).
3398
+ * Empty string if the index is out of range.
3399
+ */
3400
+ columnDtype(block_idx: number, col_idx: number): string;
3401
+ /**
3402
+ * Total flat element count of the column. For multi-dimensional
3403
+ * columns (e.g. an Nx3 positions array) this is the product of
3404
+ * all axes — i.e. the length of the slice the matching
3405
+ * `columnPtr*` points at.
3406
+ */
3407
+ columnLen(block_idx: number, col_idx: number): number;
3408
+ /**
3409
+ * Column name at `(blockIdx, colIdx)`, or empty string if
3410
+ * either index is out of range.
3411
+ */
3412
+ columnName(block_idx: number, col_idx: number): string;
3413
+ /**
3414
+ * Pointer to the contiguous `f64` slice backing this column,
3415
+ * or 0 (null) if the column is missing or has the wrong
3416
+ * dtype.
3417
+ *
3418
+ * **Lifetime**: valid only until the next non-trivial wasm
3419
+ * call. See the module-level memory-grow contract.
3420
+ */
3421
+ columnPtrF64(block_idx: number, col_idx: number): number;
3422
+ /**
3423
+ * Pointer to the contiguous `i32` slice backing this column,
3424
+ * or 0 (null) if the column is missing or has the wrong
3425
+ * dtype.
3426
+ *
3427
+ * **Lifetime**: valid only until the next non-trivial wasm
3428
+ * call. See the module-level memory-grow contract.
3429
+ */
3430
+ columnPtrI32(block_idx: number, col_idx: number): number;
3431
+ /**
3432
+ * Pointer to the contiguous `u32` slice backing this column,
3433
+ * or 0 (null) if the column is missing or has the wrong
3434
+ * dtype.
3435
+ *
3436
+ * **Lifetime**: valid only until the next non-trivial wasm
3437
+ * call. See the module-level memory-grow contract.
3438
+ */
3439
+ columnPtrU32(block_idx: number, col_idx: number): number;
3440
+ /**
3441
+ * Copy a string column out by value. Returns an empty array
3442
+ * if the column is missing or not a string column.
3443
+ */
3444
+ columnStrings(block_idx: number, col_idx: number): string[];
3445
+ /**
3446
+ * Feed the first `len` bytes of the input buffer into the
3447
+ * indexer at absolute source offset `globalOffset`. Returns
3448
+ * any frame entries that became finalized as a result.
3449
+ *
3450
+ * `globalOffset` is round-tripped through `f64`; per the
3451
+ * streaming protocol the source size is capped at 1 TB
3452
+ * (well within `Number.MAX_SAFE_INTEGER`).
3453
+ */
3454
+ feedIndexChunk(global_offset: number, len: number): FrameIndexEntry[];
3455
+ /**
3456
+ * Signal end-of-stream; return any trailing frame entry. The
3457
+ * indexer is consumed and further `feedIndexChunk` calls
3458
+ * throw.
3459
+ */
3460
+ finishIndex(): FrameIndexEntry[];
3461
+ /**
3462
+ * Number of named scalar arrays in grid `gridIdx`.
3463
+ */
3464
+ gridArrayCount(grid_idx: number): number;
3465
+ /**
3466
+ * Length (number of `f64` elements) of the grid scalar field.
3467
+ */
3468
+ gridArrayLen(grid_idx: number, array_idx: number): number;
3469
+ /**
3470
+ * Name of scalar array `(gridIdx, arrayIdx)`, or empty string
3471
+ * if either index is out of range.
3472
+ */
3473
+ gridArrayName(grid_idx: number, array_idx: number): string;
3474
+ /**
3475
+ * Pointer to the contiguous `f64` slice backing the grid
3476
+ * scalar field, or 0 (null) if either index is out of range.
3477
+ *
3478
+ * **Lifetime**: valid only until the next non-trivial wasm
3479
+ * call. See the module-level memory-grow contract.
3480
+ */
3481
+ gridArrayPtrF64(grid_idx: number, array_idx: number): number;
3482
+ /**
3483
+ * Grid lattice cell as a length-9 `Float64Array` (column-major:
3484
+ * `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`).
3485
+ */
3486
+ gridCell(grid_idx: number): Float64Array;
3487
+ /**
3488
+ * Number of named grids attached to the current frame.
3489
+ */
3490
+ gridCount(): number;
3491
+ /**
3492
+ * Name of grid `gridIdx`, or empty string if out of range.
3493
+ */
3494
+ gridName(grid_idx: number): string;
3495
+ /**
3496
+ * Grid origin (Cartesian, Å) as a length-3 `Float64Array`.
3497
+ */
3498
+ gridOrigin(grid_idx: number): Float64Array;
3499
+ /**
3500
+ * Grid PBC flags as a length-3 `Uint8Array` (`1` = periodic,
3501
+ * `0` = open).
3502
+ */
3503
+ gridPbc(grid_idx: number): Uint8Array;
3504
+ /**
3505
+ * Grid dimensions `[nx, ny, nz]` as a length-3 `Uint32Array`.
3506
+ */
3507
+ gridShape(grid_idx: number): Uint32Array;
3508
+ /**
3509
+ * Current capacity (in bytes) of the reusable input buffer.
3510
+ */
3511
+ inputCapacity(): number;
3512
+ /**
3513
+ * Create a new streaming reader. The reusable input buffer
3514
+ * starts empty; call [`allocInputBuffer`] before feeding data.
3515
+ */
3516
+ constructor();
3517
+ /**
3518
+ * Decode the byte range `[offset, offset + len)` from the
3519
+ * reusable input buffer as a single frame. Replaces any
3520
+ * previously cached output; the caller must extract data
3521
+ * before the next `parseRangeInInput` (the same buffer can
3522
+ * be overwritten in between).
3523
+ */
3524
+ parseRangeInInput(offset: number, len: number): void;
3525
+ /**
3526
+ * Drop the cached output frame, releasing its memory and
3527
+ * invalidating any outstanding `columnPtr*` / `gridArrayPtr*`
3528
+ * pointers. Subsequent extraction calls return 0 / empty
3529
+ * until the next `parseRangeInInput`.
3530
+ */
3531
+ releaseFrame(): void;
3532
+ /**
3533
+ * Box H-matrix as a length-9 `Float64Array` (column-major:
3534
+ * `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`),
3535
+ * or `undefined` if the frame has no simbox.
3536
+ *
3537
+ * Returned by VALUE — the typed array is owned by JS and is
3538
+ * stable across subsequent wasm calls.
3539
+ */
3540
+ simboxH(): Float64Array | undefined;
3541
+ /**
3542
+ * Box origin as a length-3 `Float64Array`, or `undefined` if
3543
+ * the frame has no simbox.
3544
+ */
3545
+ simboxOrigin(): Float64Array | undefined;
3546
+ /**
3547
+ * Per-axis PBC flags as a length-3 `Uint8Array` (`1` = periodic,
3548
+ * `0` = open), or `undefined` if the frame has no simbox.
3549
+ *
3550
+ * (wasm-bindgen does not support `[bool; 3]` returns natively,
3551
+ * hence the `Uint8Array` wire format. The spec calls for
3552
+ * `[boolean, boolean, boolean]`; the JS side is expected to
3553
+ * `Boolean(arr[i])` each entry.)
3554
+ */
3555
+ simboxPbc(): Uint8Array | undefined;
3556
+ }
3557
+
3558
+ export class WasmSdfStream {
3559
+ free(): void;
3560
+ [Symbol.dispose](): void;
3561
+ /**
3562
+ * Resize the reusable input buffer so it can hold at least
3563
+ * `len` bytes, and return the WASM linear-memory pointer to
3564
+ * its first byte.
3565
+ *
3566
+ * CALLER MUST RE-DERIVE THIS POINTER AFTER ANY OTHER WASM CALL —
3567
+ * `wasm.memory.buffer` may have been detached by a `memory.grow`.
3568
+ */
3569
+ allocInputBuffer(len: number): number;
3570
+ /**
3571
+ * Number of blocks in the most recently parsed frame.
3572
+ */
3573
+ blockCount(): number;
3574
+ /**
3575
+ * Name of block `blockIdx`, or empty string if out of range.
3576
+ */
3577
+ blockName(block_idx: number): string;
3578
+ /**
3579
+ * Number of columns in block `blockIdx`.
3580
+ */
3581
+ columnCount(block_idx: number): number;
3582
+ /**
3583
+ * Column dtype string at `(blockIdx, colIdx)`. One of `"f64"`,
3584
+ * `"u32"`, `"i32"`, `"string"` — or `"bool"` / `"u8"` if a
3585
+ * future parser emits those (current streaming formats do not).
3586
+ * Empty string if the index is out of range.
3587
+ */
3588
+ columnDtype(block_idx: number, col_idx: number): string;
3589
+ /**
3590
+ * Total flat element count of the column. For multi-dimensional
3591
+ * columns (e.g. an Nx3 positions array) this is the product of
3592
+ * all axes — i.e. the length of the slice the matching
3593
+ * `columnPtr*` points at.
3594
+ */
3595
+ columnLen(block_idx: number, col_idx: number): number;
3596
+ /**
3597
+ * Column name at `(blockIdx, colIdx)`, or empty string if
3598
+ * either index is out of range.
3599
+ */
3600
+ columnName(block_idx: number, col_idx: number): string;
3601
+ /**
3602
+ * Pointer to the contiguous `f64` slice backing this column,
3603
+ * or 0 (null) if the column is missing or has the wrong
3604
+ * dtype.
3605
+ *
3606
+ * **Lifetime**: valid only until the next non-trivial wasm
3607
+ * call. See the module-level memory-grow contract.
3608
+ */
3609
+ columnPtrF64(block_idx: number, col_idx: number): number;
3610
+ /**
3611
+ * Pointer to the contiguous `i32` slice backing this column,
3612
+ * or 0 (null) if the column is missing or has the wrong
3613
+ * dtype.
3614
+ *
3615
+ * **Lifetime**: valid only until the next non-trivial wasm
3616
+ * call. See the module-level memory-grow contract.
3617
+ */
3618
+ columnPtrI32(block_idx: number, col_idx: number): number;
3619
+ /**
3620
+ * Pointer to the contiguous `u32` slice backing this column,
3621
+ * or 0 (null) if the column is missing or has the wrong
3622
+ * dtype.
3623
+ *
3624
+ * **Lifetime**: valid only until the next non-trivial wasm
3625
+ * call. See the module-level memory-grow contract.
3626
+ */
3627
+ columnPtrU32(block_idx: number, col_idx: number): number;
3628
+ /**
3629
+ * Copy a string column out by value. Returns an empty array
3630
+ * if the column is missing or not a string column.
3631
+ */
3632
+ columnStrings(block_idx: number, col_idx: number): string[];
3633
+ /**
3634
+ * Feed the first `len` bytes of the input buffer into the
3635
+ * indexer at absolute source offset `globalOffset`. Returns
3636
+ * any frame entries that became finalized as a result.
3637
+ *
3638
+ * `globalOffset` is round-tripped through `f64`; per the
3639
+ * streaming protocol the source size is capped at 1 TB
3640
+ * (well within `Number.MAX_SAFE_INTEGER`).
3641
+ */
3642
+ feedIndexChunk(global_offset: number, len: number): FrameIndexEntry[];
3643
+ /**
3644
+ * Signal end-of-stream; return any trailing frame entry. The
3645
+ * indexer is consumed and further `feedIndexChunk` calls
3646
+ * throw.
3647
+ */
3648
+ finishIndex(): FrameIndexEntry[];
3649
+ /**
3650
+ * Number of named scalar arrays in grid `gridIdx`.
3651
+ */
3652
+ gridArrayCount(grid_idx: number): number;
3653
+ /**
3654
+ * Length (number of `f64` elements) of the grid scalar field.
3655
+ */
3656
+ gridArrayLen(grid_idx: number, array_idx: number): number;
3657
+ /**
3658
+ * Name of scalar array `(gridIdx, arrayIdx)`, or empty string
3659
+ * if either index is out of range.
3660
+ */
3661
+ gridArrayName(grid_idx: number, array_idx: number): string;
3662
+ /**
3663
+ * Pointer to the contiguous `f64` slice backing the grid
3664
+ * scalar field, or 0 (null) if either index is out of range.
3665
+ *
3666
+ * **Lifetime**: valid only until the next non-trivial wasm
3667
+ * call. See the module-level memory-grow contract.
3668
+ */
3669
+ gridArrayPtrF64(grid_idx: number, array_idx: number): number;
3670
+ /**
3671
+ * Grid lattice cell as a length-9 `Float64Array` (column-major:
3672
+ * `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`).
3673
+ */
3674
+ gridCell(grid_idx: number): Float64Array;
3675
+ /**
3676
+ * Number of named grids attached to the current frame.
3677
+ */
3678
+ gridCount(): number;
3679
+ /**
3680
+ * Name of grid `gridIdx`, or empty string if out of range.
3681
+ */
3682
+ gridName(grid_idx: number): string;
3683
+ /**
3684
+ * Grid origin (Cartesian, Å) as a length-3 `Float64Array`.
3685
+ */
3686
+ gridOrigin(grid_idx: number): Float64Array;
3687
+ /**
3688
+ * Grid PBC flags as a length-3 `Uint8Array` (`1` = periodic,
3689
+ * `0` = open).
3690
+ */
3691
+ gridPbc(grid_idx: number): Uint8Array;
3692
+ /**
3693
+ * Grid dimensions `[nx, ny, nz]` as a length-3 `Uint32Array`.
3694
+ */
3695
+ gridShape(grid_idx: number): Uint32Array;
3696
+ /**
3697
+ * Current capacity (in bytes) of the reusable input buffer.
3698
+ */
3699
+ inputCapacity(): number;
3700
+ /**
3701
+ * Create a new streaming reader. The reusable input buffer
3702
+ * starts empty; call [`allocInputBuffer`] before feeding data.
3703
+ */
3704
+ constructor();
3705
+ /**
3706
+ * Decode the byte range `[offset, offset + len)` from the
3707
+ * reusable input buffer as a single frame. Replaces any
3708
+ * previously cached output; the caller must extract data
3709
+ * before the next `parseRangeInInput` (the same buffer can
3710
+ * be overwritten in between).
3711
+ */
3712
+ parseRangeInInput(offset: number, len: number): void;
3713
+ /**
3714
+ * Drop the cached output frame, releasing its memory and
3715
+ * invalidating any outstanding `columnPtr*` / `gridArrayPtr*`
3716
+ * pointers. Subsequent extraction calls return 0 / empty
3717
+ * until the next `parseRangeInInput`.
3718
+ */
3719
+ releaseFrame(): void;
3720
+ /**
3721
+ * Box H-matrix as a length-9 `Float64Array` (column-major:
3722
+ * `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`),
3723
+ * or `undefined` if the frame has no simbox.
3724
+ *
3725
+ * Returned by VALUE — the typed array is owned by JS and is
3726
+ * stable across subsequent wasm calls.
3727
+ */
3728
+ simboxH(): Float64Array | undefined;
3729
+ /**
3730
+ * Box origin as a length-3 `Float64Array`, or `undefined` if
3731
+ * the frame has no simbox.
3732
+ */
3733
+ simboxOrigin(): Float64Array | undefined;
3734
+ /**
3735
+ * Per-axis PBC flags as a length-3 `Uint8Array` (`1` = periodic,
3736
+ * `0` = open), or `undefined` if the frame has no simbox.
3737
+ *
3738
+ * (wasm-bindgen does not support `[bool; 3]` returns natively,
3739
+ * hence the `Uint8Array` wire format. The spec calls for
3740
+ * `[boolean, boolean, boolean]`; the JS side is expected to
3741
+ * `Boolean(arr[i])` each entry.)
3742
+ */
3743
+ simboxPbc(): Uint8Array | undefined;
3744
+ }
3745
+
3746
+ export class WasmXyzStream {
3747
+ free(): void;
3748
+ [Symbol.dispose](): void;
3749
+ /**
3750
+ * Resize the reusable input buffer so it can hold at least
3751
+ * `len` bytes, and return the WASM linear-memory pointer to
3752
+ * its first byte.
3753
+ *
3754
+ * CALLER MUST RE-DERIVE THIS POINTER AFTER ANY OTHER WASM CALL —
3755
+ * `wasm.memory.buffer` may have been detached by a `memory.grow`.
3756
+ */
3757
+ allocInputBuffer(len: number): number;
3758
+ /**
3759
+ * Number of blocks in the most recently parsed frame.
3760
+ */
3761
+ blockCount(): number;
3762
+ /**
3763
+ * Name of block `blockIdx`, or empty string if out of range.
3764
+ */
3765
+ blockName(block_idx: number): string;
3766
+ /**
3767
+ * Number of columns in block `blockIdx`.
3768
+ */
3769
+ columnCount(block_idx: number): number;
3770
+ /**
3771
+ * Column dtype string at `(blockIdx, colIdx)`. One of `"f64"`,
3772
+ * `"u32"`, `"i32"`, `"string"` — or `"bool"` / `"u8"` if a
3773
+ * future parser emits those (current streaming formats do not).
3774
+ * Empty string if the index is out of range.
3775
+ */
3776
+ columnDtype(block_idx: number, col_idx: number): string;
3777
+ /**
3778
+ * Total flat element count of the column. For multi-dimensional
3779
+ * columns (e.g. an Nx3 positions array) this is the product of
3780
+ * all axes — i.e. the length of the slice the matching
3781
+ * `columnPtr*` points at.
3782
+ */
3783
+ columnLen(block_idx: number, col_idx: number): number;
3784
+ /**
3785
+ * Column name at `(blockIdx, colIdx)`, or empty string if
3786
+ * either index is out of range.
3787
+ */
3788
+ columnName(block_idx: number, col_idx: number): string;
3789
+ /**
3790
+ * Pointer to the contiguous `f64` slice backing this column,
3791
+ * or 0 (null) if the column is missing or has the wrong
3792
+ * dtype.
3793
+ *
3794
+ * **Lifetime**: valid only until the next non-trivial wasm
3795
+ * call. See the module-level memory-grow contract.
3796
+ */
3797
+ columnPtrF64(block_idx: number, col_idx: number): number;
3798
+ /**
3799
+ * Pointer to the contiguous `i32` slice backing this column,
3800
+ * or 0 (null) if the column is missing or has the wrong
3801
+ * dtype.
3802
+ *
3803
+ * **Lifetime**: valid only until the next non-trivial wasm
3804
+ * call. See the module-level memory-grow contract.
3805
+ */
3806
+ columnPtrI32(block_idx: number, col_idx: number): number;
3807
+ /**
3808
+ * Pointer to the contiguous `u32` slice backing this column,
3809
+ * or 0 (null) if the column is missing or has the wrong
3810
+ * dtype.
3811
+ *
3812
+ * **Lifetime**: valid only until the next non-trivial wasm
3813
+ * call. See the module-level memory-grow contract.
3814
+ */
3815
+ columnPtrU32(block_idx: number, col_idx: number): number;
3816
+ /**
3817
+ * Copy a string column out by value. Returns an empty array
3818
+ * if the column is missing or not a string column.
3819
+ */
3820
+ columnStrings(block_idx: number, col_idx: number): string[];
3821
+ /**
3822
+ * Feed the first `len` bytes of the input buffer into the
3823
+ * indexer at absolute source offset `globalOffset`. Returns
3824
+ * any frame entries that became finalized as a result.
3825
+ *
3826
+ * `globalOffset` is round-tripped through `f64`; per the
3827
+ * streaming protocol the source size is capped at 1 TB
3828
+ * (well within `Number.MAX_SAFE_INTEGER`).
3829
+ */
3830
+ feedIndexChunk(global_offset: number, len: number): FrameIndexEntry[];
3831
+ /**
3832
+ * Signal end-of-stream; return any trailing frame entry. The
3833
+ * indexer is consumed and further `feedIndexChunk` calls
3834
+ * throw.
3835
+ */
3836
+ finishIndex(): FrameIndexEntry[];
3837
+ /**
3838
+ * Number of named scalar arrays in grid `gridIdx`.
3839
+ */
3840
+ gridArrayCount(grid_idx: number): number;
3841
+ /**
3842
+ * Length (number of `f64` elements) of the grid scalar field.
3843
+ */
3844
+ gridArrayLen(grid_idx: number, array_idx: number): number;
3845
+ /**
3846
+ * Name of scalar array `(gridIdx, arrayIdx)`, or empty string
3847
+ * if either index is out of range.
3848
+ */
3849
+ gridArrayName(grid_idx: number, array_idx: number): string;
3850
+ /**
3851
+ * Pointer to the contiguous `f64` slice backing the grid
3852
+ * scalar field, or 0 (null) if either index is out of range.
3853
+ *
3854
+ * **Lifetime**: valid only until the next non-trivial wasm
3855
+ * call. See the module-level memory-grow contract.
3856
+ */
3857
+ gridArrayPtrF64(grid_idx: number, array_idx: number): number;
3858
+ /**
3859
+ * Grid lattice cell as a length-9 `Float64Array` (column-major:
3860
+ * `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`).
3861
+ */
3862
+ gridCell(grid_idx: number): Float64Array;
3863
+ /**
3864
+ * Number of named grids attached to the current frame.
3865
+ */
3866
+ gridCount(): number;
3867
+ /**
3868
+ * Name of grid `gridIdx`, or empty string if out of range.
3869
+ */
3870
+ gridName(grid_idx: number): string;
3871
+ /**
3872
+ * Grid origin (Cartesian, Å) as a length-3 `Float64Array`.
3873
+ */
3874
+ gridOrigin(grid_idx: number): Float64Array;
3875
+ /**
3876
+ * Grid PBC flags as a length-3 `Uint8Array` (`1` = periodic,
3877
+ * `0` = open).
3878
+ */
3879
+ gridPbc(grid_idx: number): Uint8Array;
3880
+ /**
3881
+ * Grid dimensions `[nx, ny, nz]` as a length-3 `Uint32Array`.
3882
+ */
3883
+ gridShape(grid_idx: number): Uint32Array;
3884
+ /**
3885
+ * Current capacity (in bytes) of the reusable input buffer.
3886
+ */
3887
+ inputCapacity(): number;
3888
+ /**
3889
+ * Create a new streaming reader. The reusable input buffer
3890
+ * starts empty; call [`allocInputBuffer`] before feeding data.
3891
+ */
3892
+ constructor();
3893
+ /**
3894
+ * Decode the byte range `[offset, offset + len)` from the
3895
+ * reusable input buffer as a single frame. Replaces any
3896
+ * previously cached output; the caller must extract data
3897
+ * before the next `parseRangeInInput` (the same buffer can
3898
+ * be overwritten in between).
3899
+ */
3900
+ parseRangeInInput(offset: number, len: number): void;
3901
+ /**
3902
+ * Drop the cached output frame, releasing its memory and
3903
+ * invalidating any outstanding `columnPtr*` / `gridArrayPtr*`
3904
+ * pointers. Subsequent extraction calls return 0 / empty
3905
+ * until the next `parseRangeInInput`.
3906
+ */
3907
+ releaseFrame(): void;
3908
+ /**
3909
+ * Box H-matrix as a length-9 `Float64Array` (column-major:
3910
+ * `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`),
3911
+ * or `undefined` if the frame has no simbox.
3912
+ *
3913
+ * Returned by VALUE — the typed array is owned by JS and is
3914
+ * stable across subsequent wasm calls.
3915
+ */
3916
+ simboxH(): Float64Array | undefined;
3917
+ /**
3918
+ * Box origin as a length-3 `Float64Array`, or `undefined` if
3919
+ * the frame has no simbox.
3920
+ */
3921
+ simboxOrigin(): Float64Array | undefined;
3922
+ /**
3923
+ * Per-axis PBC flags as a length-3 `Uint8Array` (`1` = periodic,
3924
+ * `0` = open), or `undefined` if the frame has no simbox.
3925
+ *
3926
+ * (wasm-bindgen does not support `[bool; 3]` returns natively,
3927
+ * hence the `Uint8Array` wire format. The spec calls for
3928
+ * `[boolean, boolean, boolean]`; the JS side is expected to
3929
+ * `Boolean(arr[i])` each entry.)
3930
+ */
3931
+ simboxPbc(): Uint8Array | undefined;
3932
+ }
3933
+
2909
3934
  /**
2910
3935
  * XYZ / Extended XYZ file reader.
2911
3936
  *