Petrinaut Core
Headless document, simulation, and playback APIs
IntroductionCopy link to this section
@hashintel/petrinaut-core provides Petrinaut's document model, editing operations, simulation engine, and playback APIs. It runs in Node.js and workers without React or UI dependencies. The Petrinaut editor library builds on this package.
Published release: 0.0.6 on npm.
View on GitHub
View package source code in our hash monorepo
View on npm
or use npm install @hashintel/petrinaut-core
InstallationCopy link to this section
yarn add @hashintel/petrinaut-coreDocument handlesCopy link to this section
Use createJsonDocHandle to create an in-memory Petri net document with patch events and optional undo/redo history. Applications with their own document store can implement PetrinautDocHandle to connect that store to Petrinaut.
The package README shows handle creation. The host integration guide explains how to distinguish local edits from updates supplied by the host application.
Run simulationsCopy link to this section
Follow the simulation guide for examples using createSimulation and createMonteCarloSimulator. These APIs support running models independently of the visual editor.
The package also provides entry points for language services, compiled models, diagnostics, and workers. Applications using hir, compiled-model, or diagnostics must install the optional @typescript/typescript6 peer dependency. See the package exports for the available entry points.
Petrinaut