Wholesale move of every remaining kind into its own subdirectory under
`packages/nodes/src/`, finishing the registry-driven migration. Each
kind now ships its definition, schema (re-exported from core), and any
of `geometry` / `renderer` / `system` / `floorplan` / `tool` /
`move-tool` / `panel` / `floorplan-move` / `floorplan-affordances` /
`parametrics` / `preview` it needs — no per-kind code remains under
`packages/editor/src/components/tools/` or
`packages/viewer/src/components/renderers/`.
Deleted (replaced by registry-driven equivalents):
- `tools/{ceiling,column,door,fence,item,slab,spawn,wall,window}/...`
(boundary editors, hole editors, placement tools, move tools,
endpoint movers, curve tools, helpers, math libs)
- `ui/helpers/{ceiling,slab,wall}-helper.tsx`
- `ui/panels/{column,door,elevator,item,roof,roof-segment,spawn,
stair,stair-segment,wall,window}-panel.tsx`
- `viewer/src/components/renderers/{building,ceiling,column,door,
elevator,fence,guide,item,level,roof,roof-segment,scan,site,slab,
spawn,stair,stair-segment,wall,window,zone}-renderer.tsx`
- `viewer/src/components/viewer/legacy-system.tsx`
Added under `packages/nodes/src/`:
- `building/`, `column/`, `elevator/`, `guide/`, `level/`, `roof/`,
`roof-segment/`, `scan/`, `shared/`, `site/`, `stair/`,
`stair-segment/` packages with definition + schema + renderer / system
/ floorplan / panel as appropriate.
- New `floorplan-move.ts` for every kind that supports 2D moves
(ceiling, door, item, shelf, slab, window) — single registry-driven
dispatch path via `def.floorplanMoveTarget`.
- New `floorplan-affordances.ts` for kinds with polygon / endpoint
drags (ceiling, fence, slab, wall) — using the shared
`polygon-vertex-affordance` factories.
- New per-kind `panel.tsx` for kinds with custom inspector content
(door, item, shelf, spawn, wall, window).
- New per-kind `tool.tsx` for placement (door, item, shelf, window).
- New per-kind `move-tool.tsx` for kinds with custom 3D move flows
(door, item, slab, window).
Coordinator + manager updates in `packages/editor/`:
- `tool-manager.tsx` resolves tools from the registry only — no
hardcoded type→component map.
- `panel-manager.tsx` resolves inspector panels the same way.
- `placement-{coordinator,strategies,types}.ts` extended with
shelf-surface placement.
- `selection-manager.tsx` adds the registry-selectable fallback.
- `floorplan-panel.tsx`, `floorplan-background-placement.ts`,
`floorplan-render-context.tsx` updated for the registry layer's new
contract (props, affordance dispatch, render context).
Viewer updates:
- `viewer/index.tsx` drops legacy renderer mounts.
- `node-renderer.tsx` resolves by registry only.
- `scene-bvh.tsx`, `use-node-events.ts`, `level-system.tsx`,
`wall-cutout.tsx`, `zone-system.tsx`, `materials.ts` adjusted for
the registry-only world.
Sidebar tree nodes for ceiling / fence / slab / shelf / tree-node
updated to read from the registered nodes instead of the deleted
legacy renderer trees.
Wiki: new `plugin-authoring.md` page, README index updated.
Tests in `packages/nodes/src/index.test.ts` validate every registered
kind has the required shape.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
55 lines
2.2 KiB
TypeScript
55 lines
2.2 KiB
TypeScript
'use client'
|
|
|
|
import type { FloorplanPalette } from '@pascal-app/core'
|
|
import { createContext, type ReactNode, useContext, useMemo } from 'react'
|
|
|
|
/**
|
|
* Per-frame render context shared between the legacy `floorplan-panel.tsx`
|
|
* and the registry-driven `<FloorplanRegistryLayer>`.
|
|
*
|
|
* The legacy panel is the authoritative owner of the floor-plan SVG —
|
|
* it computes `unitsPerPixel` from the viewBox / surface size, mounts the
|
|
* pan/zoom `<g>`, and knows the active theme. The registry layer is mounted
|
|
* inside the same `<g>`, so anything it draws shares the same coordinate
|
|
* system; this context plumbs through the bits it can't recompute on its
|
|
* own without re-implementing the legacy's resize / theme logic.
|
|
*
|
|
* Once `floorplan-panel.tsx` is fully migrated (Phase 6), this provider
|
|
* moves into a kind-agnostic 2D editor shell and the context loses the
|
|
* "legacy bridge" connotation.
|
|
*/
|
|
export type FloorplanRenderContextValue = {
|
|
/** SVG units per screen pixel — used to keep handle radii consistent at any zoom. */
|
|
unitsPerPixel: number
|
|
/** Themed palette mirroring the legacy `FloorplanPalette` accent slots. */
|
|
palette: FloorplanPalette
|
|
/** SVG `<pattern>` id mounted in `<defs>` by the legacy panel for selection hatch fills. */
|
|
hatchPatternId: string
|
|
}
|
|
|
|
const FloorplanRenderContext = createContext<FloorplanRenderContextValue | null>(null)
|
|
|
|
export function FloorplanRenderProvider({
|
|
children,
|
|
unitsPerPixel,
|
|
palette,
|
|
hatchPatternId,
|
|
}: FloorplanRenderContextValue & { children: ReactNode }) {
|
|
const value = useMemo<FloorplanRenderContextValue>(
|
|
() => ({ unitsPerPixel, palette, hatchPatternId }),
|
|
[unitsPerPixel, palette, hatchPatternId],
|
|
)
|
|
return <FloorplanRenderContext.Provider value={value}>{children}</FloorplanRenderContext.Provider>
|
|
}
|
|
|
|
/**
|
|
* Read the active render context. Returns `null` when called outside a
|
|
* provider — the registry layer treats this as "render statically, skip
|
|
* theme-aware chrome and interactive handles". This makes the layer
|
|
* usable in isolation tests + future editor shells without bringing the
|
|
* whole legacy panel along.
|
|
*/
|
|
export function useFloorplanRender(): FloorplanRenderContextValue | null {
|
|
return useContext(FloorplanRenderContext)
|
|
}
|