@nsgx/runtime
v1.0.0
Published
NSG runtime engine - graph state, navigation, selection, isolation, and modeling
Downloads
108
Maintainers
Readme
@nsgx/runtime
Core runtime engine for NSG (Neural Structure Graph) visualization.
Installation
npm install @nsgx/runtime @nsgx/schemaUsage
import { createNSGRuntime } from "@nsgx/runtime"
import type { NSGFile } from "@nsgx/schema"
// Create a runtime instance
const runtime = createNSGRuntime({
graph: myNSGFile,
permissions: {
canEditGraph: true,
canEditNodes: true,
},
})
// Navigate layers
runtime.navigation.enterLayer("layer-id")
runtime.navigation.exitLayer()
// Select elements
runtime.selection.selectNode("node-id")
runtime.selection.clearSelection()
// Isolate views
runtime.isolation.isolateNode("node-id")
runtime.isolation.isolateDependencies("node-id", { depth: 2 })
runtime.isolation.clearIsolation()
// Edit graph (when permissions allow)
runtime.modeling.createNode("layer-id", { label: "New Node" })
runtime.modeling.updateNode("layer-id", "node-id", { label: "Updated" })
runtime.modeling.deleteNode("layer-id", "node-id")
// Subscribe to events
const unsubscribe = runtime.subscribe((event) => {
console.log("Runtime event:", event.type)
})
// Cleanup
runtime.destroy()Controllers
The runtime exposes these controllers:
navigation- Layer navigation and view modesselection- Node/edge/layer selectionisolation- Focus views and filteringmodeling- Graph editing operationsstacks- Stack composition managementlayers- Layer access and queriesnodes- Node queriesedges- Edge querieshistory- Undo/redoexport- Graph export and validation
License
MIT
