diff --git a/apps/editor/components/scene-loader.tsx b/apps/editor/components/scene-loader.tsx index b3606f76..22b655ad 100644 --- a/apps/editor/components/scene-loader.tsx +++ b/apps/editor/components/scene-loader.tsx @@ -1,5 +1,6 @@ 'use client' +import '../lib/bootstrap' import { applySceneGraphToEditor, Editor, diff --git a/apps/editor/lib/bootstrap.ts b/apps/editor/lib/bootstrap.ts new file mode 100644 index 00000000..ef48a8ec --- /dev/null +++ b/apps/editor/lib/bootstrap.ts @@ -0,0 +1,17 @@ +import { loadPlugin } from '@pascal-app/core' +import { builtinPlugin } from '@pascal-app/nodes' + +// Idempotency guard: HMR can reload this module, but `registerNode` throws on +// duplicate kinds. The flag lives in the module closure so it's reset on a +// hard reload but survives within a session. +let loaded = false + +export function loadBuiltinNodes(): void { + if (loaded) return + loaded = true + void loadPlugin(builtinPlugin) +} + +// Run as a side effect on first import so any consumer of this module gets a +// populated registry without remembering to call the function explicitly. +loadBuiltinNodes() diff --git a/apps/editor/package.json b/apps/editor/package.json index f2c00a2e..b4ef4235 100644 --- a/apps/editor/package.json +++ b/apps/editor/package.json @@ -16,6 +16,7 @@ "@pascal-app/core": "*", "@pascal-app/editor": "*", "@pascal-app/mcp": "*", + "@pascal-app/nodes": "*", "@pascal-app/viewer": "*", "@radix-ui/react-tooltip": "^1.2.8", "@react-three/drei": "^10.7.7", diff --git a/bun.lock b/bun.lock index 5cf22a6d..dffc8910 100644 --- a/bun.lock +++ b/bun.lock @@ -31,6 +31,7 @@ "@pascal-app/core": "*", "@pascal-app/editor": "*", "@pascal-app/mcp": "*", + "@pascal-app/nodes": "*", "@pascal-app/viewer": "*", "@radix-ui/react-tooltip": "^1.2.8", "@react-three/drei": "^10.7.7",