Repository navigation
Conversation
…pp's iframe `?embed=1` inside an iframe mounts src/embed/EmbedBridge.tsx (a lazyOr chunk on EvalGate's terms — an ordinary boot never fetches it — and never in a study): postMessage to and from the parent window at the page's own origin only. `superwxr:open` restores a shader .js export through importShaderText (the "Load Script…" path, no Open/Add dialog); `superwxr:module` broadcasts the settled export module (images inlined, project block appended, trailing-debounced like the preview, deduped on the text); `superwxr:export` hands EXPORT's bytes to the host instead of the download folder (exportShader.ts). src/embed/embedMode.ts is the switch: a LEAF sampled once at module init, never true at the top level. The bridge's store subscription compares three references and the Output node's settings object by reference, so a drag frame costs nothing. Pinned by src/embed/embedBridge.test.ts; the tree entries in CLAUDE.md and docs/dev/project-structure.md describe it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JrG3bmbgVjHDfnAHEaJEAE
…p after the first settle As a lazyOr chunk the bridge mounts after the demo graph has settled, so a host that only shows what the editor holds never saw a `superwxr:module`: nothing changed the store again. The bridge now broadcasts once at mount, at the same trailing delay, unless a `superwxr:open` arrives first — the import's own settle broadcasts then. Found by SuperWXR's 30-shader browser suite against the rebuilt vendored copy. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JrG3bmbgVjHDfnAHEaJEAE
This branch has not been deployed
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
FastShaders can now run as the shader editor of another app: opened at
?embed=1inside an iframe, it mounts a small postMessage bridge (src/embed/EmbedBridge.tsx) that talks to the parent window at the page's own origin only. The host is SuperWXR, a WebXR game engine + editor whose Material component edits its shader in an embedded FastShaders.Messages (all
type: 'superwxr:*'):superwxr:open { module, name? }.jsexport — aFASTSHADERS_PROJECT_V1block restores the graph, a bare module is parsed back — throughimportShaderText, the "Load Script…" path (no Open/Add dialog)superwxr:readysuperwxr:module { module, name }superwxr:export { kind, fileName, mime, bytes }downloadShaderwould have downloaded: when embedded,exportShader.tsposts the bytes to the host instead of saving themHow it stays out of the way
src/embed/embedMode.tsis the switch: a LEAF (imports nothing), sampled once at module init likeeval/evalArm.ts, never true at the top level — only an embedding page can answer the bridge.lazyOrchunk mounted fromApp.tsxon EvalGate's terms: an ordinary visitor's boot never creates the element and never fetches the chunk (it pulls the import path and the export assembly).bootWave.test.tsstill passes.isEmbedMode() && !isEvalMode()): it is a second way to change the graph.window.parentatlocation.originonly; the module is type-checked before anything runs; the name is bounded (80 chars, extension stripped) and still goes through the import path's ownsanitizeDroppedName.Tests and docs
src/embed/embedBridge.test.tspins the shape: the switch is a leaf and off under node,App.tsxmounts the bridge lazily behind the switch and outside a study, the bridge answers the parent at its own origin only, EXPORT posts instead of downloading only when embedded.npm run build(tsc -b + vite) andnpm testgreen locally: 502 files, 11231 tests passed, 3 skipped.CLAUDE.mdanddocs/dev/project-structure.md.The host side (the panel, the
superwxr:*consumer, the browser suite that drives the real embed end-to-end) lives in SuperWXR; this is the whole FastShaders half.Generated by Claude Code