@xenolithengine/graph-runtime-as
v0.7.0-beta.3
Published
AssemblyScript-based WASM code generator for the XenolithGraph Blueprint runtime. Emits AS source from an RtGraph + NodeDef set, compiles to a WebAssembly module via asc, exposes the same call surface as the JS codegen.
Maintainers
Readme
@xenolithengine/graph-runtime-as
AssemblyScript-based WASM code generator for the XenolithGraph Blueprint runtime. Emits AS source from an RtGraph + NodeDef set, compiles to a WebAssembly module via asc, exposes the same call surface as the JS codegen.
Experimental — supports the numeric subset only (
canCompileToAS(graph)gates eligibility). Non-numeric primitives fall back to@xenolithengine/graph-plugin-runtime's JS codegen.
Part of XenolithGraph — an AI-native, embeddable node-graph editor for the web with its own visual design language (Xen).
Install
pnpm add @xenolithengine/graph-runtime-as @xenolithengine/graph-plugin-runtimeRequires assemblyscript at compile time (the package builds the WASM module in-process).
Usage
import { compile, canCompileToAS } from '@xenolithengine/graph-runtime-as'
import { BUILTIN_PRIMITIVES, type RtGraph } from '@xenolithengine/graph-plugin-runtime'
if (canCompileToAS(myGraph)) {
const wasm = await compile(myGraph, BUILTIN_PRIMITIVES)
wasm.setVar('x', 0.3)
wasm.tick() // executes the WASM module
console.log(wasm.getVar('y'))
if (wasm.tickArgs) console.log(wasm.tickArgs(0.3, 0.6)) // ~2× faster on hot loops
}wasm.wasm and wasm.source are exposed for inspection — the raw bytes and the generated AS source.
What's exported
compile(graph, defs)→Promise<ASWasmGraph>— emit + compile + instantiatecanCompileToAS(graph)— gate for eligibility (numeric primitives only)emitASSource(graph, defs)— generate AS source without compilingcompileAS(source)— compile a hand-authored AS source stringASWasmGraph—{ tick, getVar, setVar, reset, tickArgs?, wasm, source }
Docs
- API reference — every method exposed by
XenolithEditor - GitHub
MIT © XenolithEngine
