Add FluidNC WASM demo bridge support - #29
Draft
MitchBradley wants to merge 3 commits into
Draft
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
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.
Summary
Lets FigUI run against a real, compiled FluidNC instance running in WebAssembly in the browser (see
FluidNC/wasm/README.mdin the firmware repo), instead of only real hardware or the JS-simulated demo mode.wasmBridge/index.ts'sinstallWasmBridgeIfActive()is called unconditionally frommain.tsx(works in every build mode, including the realbuild:esp32artifact) and is a no-op unless a runtime marker is present, so it's harmless in a normal deployment — the marker only gets injected when this build is loaded inside the FluidNC WASM demo's iframe.wasmBridge/shimTransport.ts— low-levelpostMessageclient talking to the demo page'sShimChannelbridge (raw Grbl-line stream + a file-op request/response RPC).wasmBridge/WasmBridgeWebSocket.ts— installed aswindow.WebSocketsosrc/lib/ws.tsworks unmodified.wasmBridge/httpBridge.ts— interceptsfetch/XMLHttpRequestfor/command,/upload,/files, etc., matchingsrc/lib/http.ts's real endpoints.wasmBridge/commandBridge.ts— request/response command sends for the HTTP-shaped surface.Since the wasm build shares one physical channel for everything (unlike real hardware's genuinely independent HTTP and WebSocket connections), the last two commits close a couple of races that only show up in that environment:
JSONencoderwraps JSON payloads sent over a serial-shaped channel in[JSON:...]-tagged chunks, so a payload line can't collide with theok/errorline that terminates a command. That reassembly used to be done independently in this bridge and in the equivalent bridges for two other WebUI projects (ESP3D-WEBUI, WebUI-mm) that talk to the same demo. It's now done once, by the demo page itself, before anything is ever posted here — this bridge just receives whole, already-unwrapped lines.WasmBridgeWebSocket(bypassing the old per-bridge queue) could still race a pending command and steal itsokline, so the queue now serializes all shim traffic — raw sends and RPC commands alike — not just commands against each other.[ESP800]json=yeshandler (FluidNC/wasm/FwInfo.cppin the firmware repo) rather than each bridge hardcoding a fake firmware-info response —parser.ts/App.tsx/http.tsupdated to consume the real JSON shape.Note for reviewers
src/lib/http.tsoverlaps withe4d3cec(Serialize filesystem ops), already onmain. This branch predates that commit, so it doesn't yet reflect it — both efforts independently added serialization to prevent races in their own subsystem (filesystem ops there, shim commands here), just worth being aware of when merging. The overlapping line (getDeviceInfoFast's[ESP800]command string) isn't touched bye4d3cecitself, so I don't expect a real conflict, but flagging it since I haven't rebased onto currentmainyet.Test plan
npx tsc --noEmitcleannpm run build:esp32cleanmainand re-verify (12 commits behind at the time of this PR)🤖 Generated with Claude Code