Phase 5 first batch kind: fence migrates to registry behind feature flag

Same shape as wall milestone B — thin renderer + system re-export, no
geometry / floor-plan / tool ports yet (later milestones). Feature flag
NEXT_PUBLIC_USE_REGISTRY_FOR_FENCE gates the dispatch flip.

Files added (packages/nodes/src/fence/):
 - schema.ts: re-exports FenceNode from core.
 - parametrics.ts: dimensions / posts / style fields for the auto-
   inspector. Endpoints + curveOffset edited via tools, not in
   parametrics.
 - feature-flag.ts: mirrors the wall flag pattern.
 - definition.ts: capabilities (snappable + surfaces sides +
   selectable + duplicable + deletable), relations (linkedBy
   endpoint-match, no hosts, no affectsSpatial — matches legacy),
   parametrics, renderer, system, toolHints (Left click / Shift /
   Esc — fence has no helper file today so this adds a panel where
   there wasn't one). Tool field absent: fence has 4 tools (build,
   curve, move, move-endpoint) wired through editor state, not the
   registry dispatch — they keep running unchanged.
 - renderer.tsx: thin placeholder mesh + markDirty on mount + node
   events + DEFAULT_STAIR_MATERIAL (matches legacy material reuse).
   Verification log fires once on first mount.
 - system.tsx: re-exports the legacy FenceSystem from viewer.
   Verification log on mount/unmount confirms the bundle activates.
 - index.ts: barrel.

Files changed:
 - packages/viewer/src/index.ts: new exports for FenceSystem and
   DEFAULT_STAIR_MATERIAL so the @pascal-app/nodes bundle can
   compose them without reaching into viewer internals.
 - packages/viewer/src/components/renderers/fence/fence-renderer.tsx:
   paired one-shot legacy verification log so the dispatch path is
   unambiguous from the browser console.
 - packages/nodes/src/index.ts: conditional fenceEntries appended to
   builtinPlugin.nodes based on isFenceRegistryEnabled. With the flag
   off (default), behavior is unchanged; with it on, Phase 0 shims
   switch fence to the registry path — legacy <FenceRenderer> and
   <LegacySystem kind="fence"><FenceSystem /></LegacySystem> short-
   circuit, the bundled system.tsx re-mounts FenceSystem via
   RegisteredSystems, and the new renderer takes over the dispatch.

No behavior change with the flag off. With it on, behavior should be
byte-identical (same FenceSystem code, same priority, same geometry
path).

Phase 5 batch order continues with slab / ceiling / door / window /
item / etc. as flagged migrations after fence parity signs off.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Wassim SAMAD
2026-05-15 11:50:41 -04:00
co-authored by Claude Opus 4.7
parent 713ef5009e
commit 9883f1cdc1
10 changed files with 296 additions and 15 deletions
+19 -14
View File
@@ -1,4 +1,5 @@
import type { AnyNodeDefinition, Plugin } from '@pascal-app/core'
import { fenceDefinition, isFenceRegistryEnabled } from './fence'
import { shelfDefinition } from './shelf'
import { spawnDefinition } from './spawn'
import { isWallRegistryEnabled, wallDefinition } from './wall'
@@ -14,25 +15,27 @@ import { isWallRegistryEnabled, wallDefinition } from './wall'
* `loadPlugin` call path. This is intentional: the API is stress-tested
* by built-ins before any third-party plugin lands.
*
* Phase 2 status: shelf is a brand-new kind. Spawn is migrated to the
* registry path — the legacy SpawnRenderer / SpawnTool files are still
* present in viewer/editor packages but short-circuited by the Phase 0
* dispatch shims (`nodeRegistry.has('spawn')` is true → legacy path
* yields). Legacy spawn files are deleted in a follow-up PR.
*
* Phase 3 status: wall is registry-driven *behind a feature flag*. With
* `NEXT_PUBLIC_USE_REGISTRY_FOR_WALL=true`, `wallDefinition` is included
* here and the Phase 0 shims switch wall to the registry path; the
* `<LegacySystem kind="wall">` wrappers around `WallSystem` and
* `WallCutout` short-circuit and the bundled `system.tsx` re-mounts them
* via `RegisteredSystems`. Off (default): wall stays on the legacy path.
* The flag drops the moment parity is signed off across the Phase 3
* fixture scenes — until then it gates the migration safely.
* Status by kind:
* - **shelf**: brand-new kind, registry-driven, no legacy. Registered
* unconditionally.
* - **spawn**: migrated to the registry path during Phase 2. Legacy
* SpawnRenderer / SpawnTool files still present in viewer/editor but
* short-circuited by the Phase 0 shims. Registered unconditionally.
* - **wall**: registry-driven behind `NEXT_PUBLIC_USE_REGISTRY_FOR_WALL`.
* Phase 3 stress test; flag drops when fixture parity signs off.
* - **fence**: registry-driven behind `NEXT_PUBLIC_USE_REGISTRY_FOR_FENCE`.
* First Phase 5 batch-migration kind. Same shape as wall (thin
* renderer + system re-export); pure geometry / floor-plan / tool
* affordance ports as later milestones.
*/
const wallEntries: AnyNodeDefinition[] = isWallRegistryEnabled()
? [wallDefinition as unknown as AnyNodeDefinition]
: []
const fenceEntries: AnyNodeDefinition[] = isFenceRegistryEnabled()
? [fenceDefinition as unknown as AnyNodeDefinition]
: []
export const builtinPlugin: Plugin = {
id: 'pascal:core',
apiVersion: 1,
@@ -40,9 +43,11 @@ export const builtinPlugin: Plugin = {
shelfDefinition as unknown as AnyNodeDefinition,
spawnDefinition as unknown as AnyNodeDefinition,
...wallEntries,
...fenceEntries,
],
}
export { fenceDefinition } from './fence'
export { shelfDefinition } from './shelf'
export { spawnDefinition } from './spawn'
export { wallDefinition } from './wall'