apps/editor: mount node-registry bootstrap at the root layout#317
Merged
Conversation
The standalone editor app loaded `lib/bootstrap.ts` as a side-effect
import only from `components/scene-loader.tsx`. That worked for the
`/edit/[sceneId]` route but left every other page (homepage, settings,
viewer-only routes) hitting `<Viewer>` with an empty client-side
registry — node materials resolved to `null` and React surfaced a
`<html>`-level hydration mismatch on first paint.
Fix mirrors the community-app side that landed in pascalorg/private-
editor#27:
- New `app/client-bootstrap.tsx` — thin client wrapper that imports
`../lib/bootstrap` and renders children.
- `app/layout.tsx` mounts `<ClientBootstrap>` around `{children}` so
every page in the standalone editor gets the registry populated
before its first `<Viewer>` / `<Editor>` mounts.
- `lib/bootstrap.ts` switched to **synchronous** built-in registration
via `registerNode(def)` per kind instead of `await loadPlugin(...)`.
The previous async kick-off only resolved in a microtask, letting
the first SSR / hydration pass see an empty registry. External
plugin discovery (`discoverPlugins()`) stays async and runs via its
own `loadExternalPlugins()` path, gated by `externalsKickedOff` so
HMR doesn't re-fetch.
- `components/scene-loader.tsx` drops the per-page side-effect import
— the root provider handles it now.
`bun.lock` syncs `@pascal-app/editor` into `@pascal-app/nodes`'s
peerDependencies + devDependencies (already declared in
`packages/nodes/package.json`; only the lockfile lagged).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes a registry-not-loaded bug in the standalone editor app, mirroring the community-side fix that landed in pascalorg/private-editor#27.
lib/bootstrap.tswas previously imported as a side effect only fromcomponents/scene-loader.tsx, so:apps/editorother than the scene loader (homepage, settings, viewer-only routes) hit<Viewer>with an empty client registry → node materials resolved tonull.await loadPlugin(builtinPlugin)), so the first SSR / hydration pass saw an empty registry — React surfaced the well-known<html>-level hydration mismatch on first paint.Changes
apps/editor/app/client-bootstrap.tsx— thin client wrapper that imports../lib/bootstrapand renders children.apps/editor/app/layout.tsx— mounts<ClientBootstrap>around{children}so every page gets the registry populated before its first<Viewer>/<Editor>mounts.apps/editor/lib/bootstrap.ts— switched to synchronous built-in registration viaregisterNode(def)per kind (no moreawait loadPlugin(...)in the hot path). External plugin discovery (discoverPlugins()) stays async and runs via its ownloadExternalPlugins()path, gated byexternalsKickedOffso HMR doesn't re-fetch.apps/editor/components/scene-loader.tsx— drops the per-page side-effect import; root provider handles it now.bun.lock— syncs@pascal-app/editorinto@pascal-app/nodes's peerDependencies + devDependencies (already declared inpackages/nodes/package.json; only the lockfile lagged).How to test
bun install && bun devfromapps/editor.[pascal:registry] loaded @pascal-app/nodes-builtin v… (20 kinds: …)on first paint.<html>-level hydration warning. (Note: the OneSec / similar browser-extension warning aboutone-sec-browser-extension-idis independent — that's the extension stamping<html>before React loads. React even calls this case out in the warning text.)Screenshots / screen recording
N/A — fixes a render-bug, no visual surface added. Verification is "nodes show up everywhere" instead of "blank canvas off the scene-loader route."
Checklist
bun devmainbranch