@molcrafts/molrs 0.0.14 → 0.0.16

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.
1443
- *
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.
1707
+ * One frame's location inside the source byte stream.
1447
1708
  *
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
- * ```
1720
+ * Size of this frame's encoded byte range, in bytes.
1480
1721
  */
1481
- arrayNames(): Array<any>;
1722
+ readonly byteLen: number;
1482
1723
  /**
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
- * ```
1724
+ * Absolute byte offset of this frame inside the source (in bytes).
1494
1725
  */
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
- * ```
1630
- */
1631
- pbc(): Uint8Array;
1632
- /**
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
- * ```
1640
- */
1641
- total(): number;
1726
+ readonly byteOffset: number;
1642
1727
  }
1643
1728
 
1644
1729
  /**
@@ -2842,6 +2927,288 @@ 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
+ * Current capacity (in bytes) of the reusable input buffer.
3023
+ */
3024
+ inputCapacity(): number;
3025
+ /**
3026
+ * Create a new streaming reader. The reusable input buffer
3027
+ * starts empty; call [`allocInputBuffer`] before feeding data.
3028
+ */
3029
+ constructor();
3030
+ /**
3031
+ * Decode the byte range `[offset, offset + len)` from the
3032
+ * reusable input buffer as a single frame. Replaces any
3033
+ * previously cached output; the caller must extract data
3034
+ * before the next `parseRangeInInput` (the same buffer can
3035
+ * be overwritten in between).
3036
+ */
3037
+ parseRangeInInput(offset: number, len: number): void;
3038
+ /**
3039
+ * Drop the cached output frame, releasing its memory and
3040
+ * invalidating any outstanding `columnPtr*` pointers.
3041
+ * pointers. Subsequent extraction calls return 0 / empty
3042
+ * until the next `parseRangeInInput`.
3043
+ */
3044
+ releaseFrame(): void;
3045
+ /**
3046
+ * Box H-matrix as a length-9 `Float64Array` (column-major:
3047
+ * `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`),
3048
+ * or `undefined` if the frame has no simbox.
3049
+ *
3050
+ * Returned by VALUE — the typed array is owned by JS and is
3051
+ * stable across subsequent wasm calls.
3052
+ */
3053
+ simboxH(): Float64Array | undefined;
3054
+ /**
3055
+ * Box origin as a length-3 `Float64Array`, or `undefined` if
3056
+ * the frame has no simbox.
3057
+ */
3058
+ simboxOrigin(): Float64Array | undefined;
3059
+ /**
3060
+ * Per-axis PBC flags as a length-3 `Uint8Array` (`1` = periodic,
3061
+ * `0` = open), or `undefined` if the frame has no simbox.
3062
+ *
3063
+ * (wasm-bindgen does not support `[bool; 3]` returns natively,
3064
+ * hence the `Uint8Array` wire format. The spec calls for
3065
+ * `[boolean, boolean, boolean]`; the JS side is expected to
3066
+ * `Boolean(arr[i])` each entry.)
3067
+ */
3068
+ simboxPbc(): Uint8Array | undefined;
3069
+ }
3070
+
3071
+ export class WasmLammpsDumpStream {
3072
+ free(): void;
3073
+ [Symbol.dispose](): void;
3074
+ /**
3075
+ * Resize the reusable input buffer so it can hold at least
3076
+ * `len` bytes, and return the WASM linear-memory pointer to
3077
+ * its first byte.
3078
+ *
3079
+ * CALLER MUST RE-DERIVE THIS POINTER AFTER ANY OTHER WASM CALL —
3080
+ * `wasm.memory.buffer` may have been detached by a `memory.grow`.
3081
+ */
3082
+ allocInputBuffer(len: number): number;
3083
+ /**
3084
+ * Number of blocks in the most recently parsed frame.
3085
+ */
3086
+ blockCount(): number;
3087
+ /**
3088
+ * Name of block `blockIdx`, or empty string if out of range.
3089
+ */
3090
+ blockName(block_idx: number): string;
3091
+ /**
3092
+ * Number of columns in block `blockIdx`.
3093
+ */
3094
+ columnCount(block_idx: number): number;
3095
+ /**
3096
+ * Column dtype string at `(blockIdx, colIdx)`. One of `"f64"`,
3097
+ * `"u32"`, `"i32"`, `"string"` — or `"bool"` / `"u8"` if a
3098
+ * future parser emits those (current streaming formats do not).
3099
+ * Empty string if the index is out of range.
3100
+ */
3101
+ columnDtype(block_idx: number, col_idx: number): string;
3102
+ /**
3103
+ * Total flat element count of the column. For multi-dimensional
3104
+ * columns (e.g. an Nx3 positions array) this is the product of
3105
+ * all axes — i.e. the length of the slice the matching
3106
+ * `columnPtr*` points at.
3107
+ */
3108
+ columnLen(block_idx: number, col_idx: number): number;
3109
+ /**
3110
+ * Column name at `(blockIdx, colIdx)`, or empty string if
3111
+ * either index is out of range.
3112
+ */
3113
+ columnName(block_idx: number, col_idx: number): string;
3114
+ /**
3115
+ * Pointer to the contiguous `f64` slice backing this column,
3116
+ * or 0 (null) if the column is missing or has the wrong
3117
+ * dtype.
3118
+ *
3119
+ * **Lifetime**: valid only until the next non-trivial wasm
3120
+ * call. See the module-level memory-grow contract.
3121
+ */
3122
+ columnPtrF64(block_idx: number, col_idx: number): number;
3123
+ /**
3124
+ * Pointer to the contiguous `i32` slice backing this column,
3125
+ * or 0 (null) if the column is missing or has the wrong
3126
+ * dtype.
3127
+ *
3128
+ * **Lifetime**: valid only until the next non-trivial wasm
3129
+ * call. See the module-level memory-grow contract.
3130
+ */
3131
+ columnPtrI32(block_idx: number, col_idx: number): number;
3132
+ /**
3133
+ * Pointer to the contiguous `u32` slice backing this column,
3134
+ * or 0 (null) if the column is missing or has the wrong
3135
+ * dtype.
3136
+ *
3137
+ * **Lifetime**: valid only until the next non-trivial wasm
3138
+ * call. See the module-level memory-grow contract.
3139
+ */
3140
+ columnPtrU32(block_idx: number, col_idx: number): number;
3141
+ /**
3142
+ * Copy a string column out by value. Returns an empty array
3143
+ * if the column is missing or not a string column.
3144
+ */
3145
+ columnStrings(block_idx: number, col_idx: number): string[];
3146
+ /**
3147
+ * Feed the first `len` bytes of the input buffer into the
3148
+ * indexer at absolute source offset `globalOffset`. Returns
3149
+ * any frame entries that became finalized as a result.
3150
+ *
3151
+ * `globalOffset` is round-tripped through `f64`; per the
3152
+ * streaming protocol the source size is capped at 1 TB
3153
+ * (well within `Number.MAX_SAFE_INTEGER`).
3154
+ */
3155
+ feedIndexChunk(global_offset: number, len: number): FrameIndexEntry[];
3156
+ /**
3157
+ * Signal end-of-stream; return any trailing frame entry. The
3158
+ * indexer is consumed and further `feedIndexChunk` calls
3159
+ * throw.
3160
+ */
3161
+ finishIndex(): FrameIndexEntry[];
3162
+ /**
3163
+ * Current capacity (in bytes) of the reusable input buffer.
3164
+ */
3165
+ inputCapacity(): number;
3166
+ /**
3167
+ * Create a new streaming reader. The reusable input buffer
3168
+ * starts empty; call [`allocInputBuffer`] before feeding data.
3169
+ */
3170
+ constructor();
3171
+ /**
3172
+ * Decode the byte range `[offset, offset + len)` from the
3173
+ * reusable input buffer as a single frame. Replaces any
3174
+ * previously cached output; the caller must extract data
3175
+ * before the next `parseRangeInInput` (the same buffer can
3176
+ * be overwritten in between).
3177
+ */
3178
+ parseRangeInInput(offset: number, len: number): void;
3179
+ /**
3180
+ * Drop the cached output frame, releasing its memory and
3181
+ * invalidating any outstanding `columnPtr*` pointers.
3182
+ * pointers. Subsequent extraction calls return 0 / empty
3183
+ * until the next `parseRangeInInput`.
3184
+ */
3185
+ releaseFrame(): void;
3186
+ /**
3187
+ * Box H-matrix as a length-9 `Float64Array` (column-major:
3188
+ * `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`),
3189
+ * or `undefined` if the frame has no simbox.
3190
+ *
3191
+ * Returned by VALUE — the typed array is owned by JS and is
3192
+ * stable across subsequent wasm calls.
3193
+ */
3194
+ simboxH(): Float64Array | undefined;
3195
+ /**
3196
+ * Box origin as a length-3 `Float64Array`, or `undefined` if
3197
+ * the frame has no simbox.
3198
+ */
3199
+ simboxOrigin(): Float64Array | undefined;
3200
+ /**
3201
+ * Per-axis PBC flags as a length-3 `Uint8Array` (`1` = periodic,
3202
+ * `0` = open), or `undefined` if the frame has no simbox.
3203
+ *
3204
+ * (wasm-bindgen does not support `[bool; 3]` returns natively,
3205
+ * hence the `Uint8Array` wire format. The spec calls for
3206
+ * `[boolean, boolean, boolean]`; the JS side is expected to
3207
+ * `Boolean(arr[i])` each entry.)
3208
+ */
3209
+ simboxPbc(): Uint8Array | undefined;
3210
+ }
3211
+
2845
3212
  /**
2846
3213
  * Stateless wrapper for [`molrs_compute::pca::Pca2`].
2847
3214
  *
@@ -2906,6 +3273,429 @@ export class WasmPcaResult {
2906
3273
  variance(): Float64Array;
2907
3274
  }
2908
3275
 
3276
+ export class WasmPdbStream {
3277
+ free(): void;
3278
+ [Symbol.dispose](): void;
3279
+ /**
3280
+ * Resize the reusable input buffer so it can hold at least
3281
+ * `len` bytes, and return the WASM linear-memory pointer to
3282
+ * its first byte.
3283
+ *
3284
+ * CALLER MUST RE-DERIVE THIS POINTER AFTER ANY OTHER WASM CALL —
3285
+ * `wasm.memory.buffer` may have been detached by a `memory.grow`.
3286
+ */
3287
+ allocInputBuffer(len: number): number;
3288
+ /**
3289
+ * Number of blocks in the most recently parsed frame.
3290
+ */
3291
+ blockCount(): number;
3292
+ /**
3293
+ * Name of block `blockIdx`, or empty string if out of range.
3294
+ */
3295
+ blockName(block_idx: number): string;
3296
+ /**
3297
+ * Number of columns in block `blockIdx`.
3298
+ */
3299
+ columnCount(block_idx: number): number;
3300
+ /**
3301
+ * Column dtype string at `(blockIdx, colIdx)`. One of `"f64"`,
3302
+ * `"u32"`, `"i32"`, `"string"` — or `"bool"` / `"u8"` if a
3303
+ * future parser emits those (current streaming formats do not).
3304
+ * Empty string if the index is out of range.
3305
+ */
3306
+ columnDtype(block_idx: number, col_idx: number): string;
3307
+ /**
3308
+ * Total flat element count of the column. For multi-dimensional
3309
+ * columns (e.g. an Nx3 positions array) this is the product of
3310
+ * all axes — i.e. the length of the slice the matching
3311
+ * `columnPtr*` points at.
3312
+ */
3313
+ columnLen(block_idx: number, col_idx: number): number;
3314
+ /**
3315
+ * Column name at `(blockIdx, colIdx)`, or empty string if
3316
+ * either index is out of range.
3317
+ */
3318
+ columnName(block_idx: number, col_idx: number): string;
3319
+ /**
3320
+ * Pointer to the contiguous `f64` slice backing this column,
3321
+ * or 0 (null) if the column is missing or has the wrong
3322
+ * dtype.
3323
+ *
3324
+ * **Lifetime**: valid only until the next non-trivial wasm
3325
+ * call. See the module-level memory-grow contract.
3326
+ */
3327
+ columnPtrF64(block_idx: number, col_idx: number): number;
3328
+ /**
3329
+ * Pointer to the contiguous `i32` slice backing this column,
3330
+ * or 0 (null) if the column is missing or has the wrong
3331
+ * dtype.
3332
+ *
3333
+ * **Lifetime**: valid only until the next non-trivial wasm
3334
+ * call. See the module-level memory-grow contract.
3335
+ */
3336
+ columnPtrI32(block_idx: number, col_idx: number): number;
3337
+ /**
3338
+ * Pointer to the contiguous `u32` slice backing this column,
3339
+ * or 0 (null) if the column is missing or has the wrong
3340
+ * dtype.
3341
+ *
3342
+ * **Lifetime**: valid only until the next non-trivial wasm
3343
+ * call. See the module-level memory-grow contract.
3344
+ */
3345
+ columnPtrU32(block_idx: number, col_idx: number): number;
3346
+ /**
3347
+ * Copy a string column out by value. Returns an empty array
3348
+ * if the column is missing or not a string column.
3349
+ */
3350
+ columnStrings(block_idx: number, col_idx: number): string[];
3351
+ /**
3352
+ * Feed the first `len` bytes of the input buffer into the
3353
+ * indexer at absolute source offset `globalOffset`. Returns
3354
+ * any frame entries that became finalized as a result.
3355
+ *
3356
+ * `globalOffset` is round-tripped through `f64`; per the
3357
+ * streaming protocol the source size is capped at 1 TB
3358
+ * (well within `Number.MAX_SAFE_INTEGER`).
3359
+ */
3360
+ feedIndexChunk(global_offset: number, len: number): FrameIndexEntry[];
3361
+ /**
3362
+ * Signal end-of-stream; return any trailing frame entry. The
3363
+ * indexer is consumed and further `feedIndexChunk` calls
3364
+ * throw.
3365
+ */
3366
+ finishIndex(): FrameIndexEntry[];
3367
+ /**
3368
+ * Current capacity (in bytes) of the reusable input buffer.
3369
+ */
3370
+ inputCapacity(): number;
3371
+ /**
3372
+ * Create a new streaming reader. The reusable input buffer
3373
+ * starts empty; call [`allocInputBuffer`] before feeding data.
3374
+ */
3375
+ constructor();
3376
+ /**
3377
+ * Decode the byte range `[offset, offset + len)` from the
3378
+ * reusable input buffer as a single frame. Replaces any
3379
+ * previously cached output; the caller must extract data
3380
+ * before the next `parseRangeInInput` (the same buffer can
3381
+ * be overwritten in between).
3382
+ */
3383
+ parseRangeInInput(offset: number, len: number): void;
3384
+ /**
3385
+ * Drop the cached output frame, releasing its memory and
3386
+ * invalidating any outstanding `columnPtr*` pointers.
3387
+ * pointers. Subsequent extraction calls return 0 / empty
3388
+ * until the next `parseRangeInInput`.
3389
+ */
3390
+ releaseFrame(): void;
3391
+ /**
3392
+ * Box H-matrix as a length-9 `Float64Array` (column-major:
3393
+ * `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`),
3394
+ * or `undefined` if the frame has no simbox.
3395
+ *
3396
+ * Returned by VALUE — the typed array is owned by JS and is
3397
+ * stable across subsequent wasm calls.
3398
+ */
3399
+ simboxH(): Float64Array | undefined;
3400
+ /**
3401
+ * Box origin as a length-3 `Float64Array`, or `undefined` if
3402
+ * the frame has no simbox.
3403
+ */
3404
+ simboxOrigin(): Float64Array | undefined;
3405
+ /**
3406
+ * Per-axis PBC flags as a length-3 `Uint8Array` (`1` = periodic,
3407
+ * `0` = open), or `undefined` if the frame has no simbox.
3408
+ *
3409
+ * (wasm-bindgen does not support `[bool; 3]` returns natively,
3410
+ * hence the `Uint8Array` wire format. The spec calls for
3411
+ * `[boolean, boolean, boolean]`; the JS side is expected to
3412
+ * `Boolean(arr[i])` each entry.)
3413
+ */
3414
+ simboxPbc(): Uint8Array | undefined;
3415
+ }
3416
+
3417
+ export class WasmSdfStream {
3418
+ free(): void;
3419
+ [Symbol.dispose](): void;
3420
+ /**
3421
+ * Resize the reusable input buffer so it can hold at least
3422
+ * `len` bytes, and return the WASM linear-memory pointer to
3423
+ * its first byte.
3424
+ *
3425
+ * CALLER MUST RE-DERIVE THIS POINTER AFTER ANY OTHER WASM CALL —
3426
+ * `wasm.memory.buffer` may have been detached by a `memory.grow`.
3427
+ */
3428
+ allocInputBuffer(len: number): number;
3429
+ /**
3430
+ * Number of blocks in the most recently parsed frame.
3431
+ */
3432
+ blockCount(): number;
3433
+ /**
3434
+ * Name of block `blockIdx`, or empty string if out of range.
3435
+ */
3436
+ blockName(block_idx: number): string;
3437
+ /**
3438
+ * Number of columns in block `blockIdx`.
3439
+ */
3440
+ columnCount(block_idx: number): number;
3441
+ /**
3442
+ * Column dtype string at `(blockIdx, colIdx)`. One of `"f64"`,
3443
+ * `"u32"`, `"i32"`, `"string"` — or `"bool"` / `"u8"` if a
3444
+ * future parser emits those (current streaming formats do not).
3445
+ * Empty string if the index is out of range.
3446
+ */
3447
+ columnDtype(block_idx: number, col_idx: number): string;
3448
+ /**
3449
+ * Total flat element count of the column. For multi-dimensional
3450
+ * columns (e.g. an Nx3 positions array) this is the product of
3451
+ * all axes — i.e. the length of the slice the matching
3452
+ * `columnPtr*` points at.
3453
+ */
3454
+ columnLen(block_idx: number, col_idx: number): number;
3455
+ /**
3456
+ * Column name at `(blockIdx, colIdx)`, or empty string if
3457
+ * either index is out of range.
3458
+ */
3459
+ columnName(block_idx: number, col_idx: number): string;
3460
+ /**
3461
+ * Pointer to the contiguous `f64` slice backing this column,
3462
+ * or 0 (null) if the column is missing or has the wrong
3463
+ * dtype.
3464
+ *
3465
+ * **Lifetime**: valid only until the next non-trivial wasm
3466
+ * call. See the module-level memory-grow contract.
3467
+ */
3468
+ columnPtrF64(block_idx: number, col_idx: number): number;
3469
+ /**
3470
+ * Pointer to the contiguous `i32` slice backing this column,
3471
+ * or 0 (null) if the column is missing or has the wrong
3472
+ * dtype.
3473
+ *
3474
+ * **Lifetime**: valid only until the next non-trivial wasm
3475
+ * call. See the module-level memory-grow contract.
3476
+ */
3477
+ columnPtrI32(block_idx: number, col_idx: number): number;
3478
+ /**
3479
+ * Pointer to the contiguous `u32` slice backing this column,
3480
+ * or 0 (null) if the column is missing or has the wrong
3481
+ * dtype.
3482
+ *
3483
+ * **Lifetime**: valid only until the next non-trivial wasm
3484
+ * call. See the module-level memory-grow contract.
3485
+ */
3486
+ columnPtrU32(block_idx: number, col_idx: number): number;
3487
+ /**
3488
+ * Copy a string column out by value. Returns an empty array
3489
+ * if the column is missing or not a string column.
3490
+ */
3491
+ columnStrings(block_idx: number, col_idx: number): string[];
3492
+ /**
3493
+ * Feed the first `len` bytes of the input buffer into the
3494
+ * indexer at absolute source offset `globalOffset`. Returns
3495
+ * any frame entries that became finalized as a result.
3496
+ *
3497
+ * `globalOffset` is round-tripped through `f64`; per the
3498
+ * streaming protocol the source size is capped at 1 TB
3499
+ * (well within `Number.MAX_SAFE_INTEGER`).
3500
+ */
3501
+ feedIndexChunk(global_offset: number, len: number): FrameIndexEntry[];
3502
+ /**
3503
+ * Signal end-of-stream; return any trailing frame entry. The
3504
+ * indexer is consumed and further `feedIndexChunk` calls
3505
+ * throw.
3506
+ */
3507
+ finishIndex(): FrameIndexEntry[];
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*` pointers.
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 WasmXyzStream {
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
+ * Current capacity (in bytes) of the reusable input buffer.
3651
+ */
3652
+ inputCapacity(): number;
3653
+ /**
3654
+ * Create a new streaming reader. The reusable input buffer
3655
+ * starts empty; call [`allocInputBuffer`] before feeding data.
3656
+ */
3657
+ constructor();
3658
+ /**
3659
+ * Decode the byte range `[offset, offset + len)` from the
3660
+ * reusable input buffer as a single frame. Replaces any
3661
+ * previously cached output; the caller must extract data
3662
+ * before the next `parseRangeInInput` (the same buffer can
3663
+ * be overwritten in between).
3664
+ */
3665
+ parseRangeInInput(offset: number, len: number): void;
3666
+ /**
3667
+ * Drop the cached output frame, releasing its memory and
3668
+ * invalidating any outstanding `columnPtr*` pointers.
3669
+ * pointers. Subsequent extraction calls return 0 / empty
3670
+ * until the next `parseRangeInInput`.
3671
+ */
3672
+ releaseFrame(): void;
3673
+ /**
3674
+ * Box H-matrix as a length-9 `Float64Array` (column-major:
3675
+ * `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`),
3676
+ * or `undefined` if the frame has no simbox.
3677
+ *
3678
+ * Returned by VALUE — the typed array is owned by JS and is
3679
+ * stable across subsequent wasm calls.
3680
+ */
3681
+ simboxH(): Float64Array | undefined;
3682
+ /**
3683
+ * Box origin as a length-3 `Float64Array`, or `undefined` if
3684
+ * the frame has no simbox.
3685
+ */
3686
+ simboxOrigin(): Float64Array | undefined;
3687
+ /**
3688
+ * Per-axis PBC flags as a length-3 `Uint8Array` (`1` = periodic,
3689
+ * `0` = open), or `undefined` if the frame has no simbox.
3690
+ *
3691
+ * (wasm-bindgen does not support `[bool; 3]` returns natively,
3692
+ * hence the `Uint8Array` wire format. The spec calls for
3693
+ * `[boolean, boolean, boolean]`; the JS side is expected to
3694
+ * `Boolean(arr[i])` each entry.)
3695
+ */
3696
+ simboxPbc(): Uint8Array | undefined;
3697
+ }
3698
+
2909
3699
  /**
2910
3700
  * XYZ / Extended XYZ file reader.
2911
3701
  *