Petrinaut Core

Headless document, simulation, and playback APIs

PetrinautTypeScriptBeta↓ 1.9k

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.

InstallationCopy link to this section

Shell
yarn add @hashintel/petrinaut-core

Document 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.