The scripting system is a node editor plus a compile/run runtime. It lets users wire visual units together, execute them in the editor, export a versioned JSON artifact, run the artifact, and import compiled programs as reusable units.
Use loadScript when application code needs to load a compiled artifact or a locally saved editor document and execute it without opening the visual editor:
import { loadScript } from "@/app/scripting/ScriptRuntime";
const script = await loadScript("/scripts/add-two.json");
const outputs = script.run({ input: 21 });loadScript("local:<script-id>") loads from the browser-local script library. script.run(...) accepts either a named input object or positional inputs in the order exposed by the compiled script interface.
- Architecture: editor execution, compiled execution, and data flow.
- Authoring Units: how to create React units and
UnitBlockbehavior. - Extension Guide: checklist for adding a block safely.
- Artifact Schema v2: compiled program format.
- Testing: runtime test patterns.
app/scripting/Scripting.js: canvas shell, output node sidebar, compile/run/import buttons.app/scripting/ScriptManager.js: graph manager,UnitBlock, connections, compiled program wrapper.app/scripting/LineManager.js: visual wire creation and deletion.app/scripting/UnitCatalog.js: block library inventory, categories, React components, and backend block classes.app/scripting/AddMenu.js: searchable/categorized block library UI and spawn positioning.app/scripting/ScriptRuntime.js: load local or URL scripts and run compiled artifacts from code.app/scripting/BlockRegistry.js: block type registry.app/scripting/registerBuiltInBlocks.js: built-in block registration.app/scripting/runtime/Compiler.js: v2 artifact compiler.app/scripting/runtime/Runner.js: v2 artifact runner.app/scripting/units/: built-in unit UI and block classes.