Bootstrap: log registered kinds + expose nodeRegistry on globalThis in dev
Verification anchor for "which path is running this kind?":
[pascal:registry] loaded pascal:core v1 (1 kinds: shelf)
prints in the browser dev console on app boot. Empty array means every
kind is on the legacy dispatch path. A kind in the array means the
registry-first NodeRenderer / ToolManager shims own it (legacy path is
short-circuited).
Also exposes `globalThis.__pascalNodeRegistry` in dev so you can run
ad-hoc inspections like `__pascalNodeRegistry.has('spawn')` from the
console. Production builds skip both.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
b6d77206b4
commit
88546d26f0
@@ -1,4 +1,4 @@
|
|||||||
import { loadPlugin } from '@pascal-app/core'
|
import { loadPlugin, nodeRegistry } from '@pascal-app/core'
|
||||||
import { builtinPlugin } from '@pascal-app/nodes'
|
import { builtinPlugin } from '@pascal-app/nodes'
|
||||||
|
|
||||||
// Idempotency guard: HMR can reload this module, but `registerNode` throws on
|
// Idempotency guard: HMR can reload this module, but `registerNode` throws on
|
||||||
@@ -6,10 +6,34 @@ import { builtinPlugin } from '@pascal-app/nodes'
|
|||||||
// hard reload but survives within a session.
|
// hard reload but survives within a session.
|
||||||
let loaded = false
|
let loaded = false
|
||||||
|
|
||||||
|
function isDev(): boolean {
|
||||||
|
const env = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process
|
||||||
|
?.env
|
||||||
|
return env?.NODE_ENV !== 'production'
|
||||||
|
}
|
||||||
|
|
||||||
export function loadBuiltinNodes(): void {
|
export function loadBuiltinNodes(): void {
|
||||||
if (loaded) return
|
if (loaded) return
|
||||||
loaded = true
|
loaded = true
|
||||||
void loadPlugin(builtinPlugin)
|
void loadPlugin(builtinPlugin)
|
||||||
|
|
||||||
|
if (isDev()) {
|
||||||
|
const kinds = Array.from(nodeRegistry.entries(), ([k]) => k)
|
||||||
|
if (typeof console !== 'undefined') {
|
||||||
|
// Visible in the browser dev console — the verification anchor for
|
||||||
|
// "which path is running this kind?" Empty array = every kind is on
|
||||||
|
// the legacy path. Kind in the array = registry path is live for it.
|
||||||
|
console.info(
|
||||||
|
`[pascal:registry] loaded ${builtinPlugin.id} v${builtinPlugin.apiVersion} (${kinds.length} kinds: ${kinds.join(', ') || '∅'})`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// Expose the registry on window for ad-hoc dev inspection. In prod the
|
||||||
|
// registry is reachable through @pascal-app/core's exports only.
|
||||||
|
if (typeof globalThis !== 'undefined') {
|
||||||
|
;(globalThis as { __pascalNodeRegistry?: typeof nodeRegistry }).__pascalNodeRegistry =
|
||||||
|
nodeRegistry
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run as a side effect on first import so any consumer of this module gets a
|
// Run as a side effect on first import so any consumer of this module gets a
|
||||||
|
|||||||
Reference in New Issue
Block a user