From 4d5226ce10cae2116e75f483bd7362bdc6417a8c Mon Sep 17 00:00:00 2001 From: Wassim SAMAD Date: Thu, 14 May 2026 11:28:01 -0400 Subject: [PATCH] Wire loadPlugin(builtinPlugin) at editor app bootstrap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds apps/editor/lib/bootstrap.ts that calls loadPlugin(builtinPlugin) as a module-side-effect on first import. Imported from scene-loader.tsx so it runs on the client side where the editor mounts. Idempotency guard handles HMR re-execution (would otherwise throw on duplicate registerNode). For the empty plugin this commit, the entire call is a no-op — included now so future commits that add real node kinds only need to push them onto builtinPlugin.nodes. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/editor/components/scene-loader.tsx | 1 + apps/editor/lib/bootstrap.ts | 17 +++++++++++++++++ apps/editor/package.json | 1 + bun.lock | 1 + 4 files changed, 20 insertions(+) create mode 100644 apps/editor/lib/bootstrap.ts 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",