WASM Reference¶
@molcrafts/molrs ships its TypeScript declarations in the package itself:
molrs.d.ts, generated by wasm-bindgen from the Rust doc comments of the
molrs-wasm crate. Editors and tsc pick them up from the installed package,
so hover documentation and signatures match the version you installed.
To read them from a source checkout, build the package with the same flags as
release publishing and open molrs-wasm/pkg/molrs.d.ts:
The generated pkg/ directory is not committed.
Main exports¶
| Area | Exports |
|---|---|
Core data model (molrs::core) |
Frame (getMeta / setMeta / metaKeys, delBlock), Block (get, view, copy, set, dtype, shape, nRows), Box (new Box(cell, origin, pbc) with Cell.matrix / lengths / lengthsAngles / lengthsTilts / undefined(), Box.bounding(points, padding, pbc); toFrac, toCart, delta, wrap → {xyz, shifts}, corners, …), NDArray, Topology (fromFrame, delAtom / delAtoms / delBond / delBonds), TriMesh, regions (Sphere, Cuboid, Parallelepiped.create(cell, origin), …, Region), NeighborList / NeighborQuery / Neighbors, covalentRadius |
| SMILES and 3D | SmilesIr.parse(text) (toFrame), SmilesIr.fromFrame(frame).toString(), CgSmilesIr.parse(text) (toFrame), Conformer (generate) |
| File formats | one door per format and direction, the camelCase of Rust's and Python's read_<fmt> / write_<fmt>: readX(source: string \| Uint8Array) (a string is always the text of a file) and writeX(frame) — readPdb / writePdb, readXyz / writeXyz, readSdf, readGro / writeGro, readMol2 / writeMol2, readCif / writeCif, readXsf / writeXsf, readCube / writeCube, readPoscar / writePoscar, readChgcar, readInpcrd, readAc, readPrmtop, readLammpsData / writeLammpsData, readLammpsDump / writeLammpsDump, and the binary readDcd / writeDcd, readTrr / writeTrr, readXtc / writeXtc (Uint8Array only); readCsvBlock / writeCsvBlock (a Block); the reader classes CifReader, GroReader, Mol2Reader, VaspPoscarReader; readStl → TriMesh; readLammpsLog → LammpsLog, isLammpsLog; wire-encoded frames: readWireFrame(source, FrameEncoding) / writeWireFrame(frame, FrameEncoding) |
| Chunk-fed streams (the one reader of their format) | XyzStream, PdbStream, SdfStream, LammpsDataStream, LammpsDumpStream, DcdStream, XtcStream, TrrStream (FrameOffset) |
Record files (*.mrec) |
new MrecFile(source) (sections(), frame(), system(), meta()), new MrecReader(source) (readFrame, readColumns, …), each over packed bytes, a file map or a storage host |
| Perception | assignRings, assignAromaticity, assignKekuleBondOrders (mutate the frame they are given), addHydrogens, removeHydrogens (return a new frame) |
Analysis (molrs::compute) |
Rdf, Msd, Cluster, Vacf, Steinhardt, PmftXy, DistributionFunction, … (one class per molrs compute type, under its Rust name; Msd / Vacf take per-frame records {a, dt, simbox?}); molrsComputeCatalog() lists them all |
| Force fields | UffTypifier, Mmff94Typifier, Mmff94sTypifier (typify, forcefield → ForceField), PotentialCompiler (compile → Potentials), Potentials (evaluate), Lbfgs (pairs from a NeighborList's Neighbors), KineticEnergy (new KineticEnergy(units, mvv2e?, boltzmann?)), CarbonTubeBuilder (setExtent(TubeExtent.cells(n) \| TubeExtent.length(l))) |
| Schema | schemaDocument, keysDocument, schemaColumnDtype |
The package README shows each of these in use, including the column dtype table and the record readers.