Upgrade to gcode-preview 3.0.0-alpha.6 - #1
Merged
Conversation
- `import * as GCodePreview` + `GCodePreview.init()` -> named `{ GCodePreview }`
+ `new GCodePreview()`; the component function keeps the `GCodePreviewUI`
name so the class and the component no longer collide.
- `WebGLPreview` type is gone: the preview instance is now typed `GCodePreview`
and held in a ref (the old state-based handle captured a stale `undefined`).
- `allowDragNDrop` -> `droppable`, `preview.resize()` ->
`preview.sceneManager.resize()`, `preview.layers.length` ->
`preview.countLayers`.
- Replace the hand-rolled setTimeout chunk loader (and the `window[id]` timer
stash it needed, plus the global `Window` index-signature augmentation) with
`processGCodeStream()`, which parses and renders progressively on its own.
The response body is decoded with `TextDecoderStream` first: the parser
splits chunks on newlines and silently renders nothing when fed raw bytes.
- Loads are guarded by an AbortController so a superseded fetch cannot stream
into a new job, and the preview is disposed on unmount.
- `@types/three` ^0.144.0 -> ^0.169.0 to match the `three` 0.169.0 that
gcode-preview resolves to (single three instance, verified with `npm ls`).
Assisted by Claude Code - Opus 5
|
Visit the preview URL for this PR (updated for commit 21fe28b): https://gcode-preview-react--pr1-upgrade-gcode-previe-4totfkfa.web.app (expires Tue, 15 Sep 2026 03:51:25 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: c787db3520fae43f256c13f53bbe62214d2df228 |
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.
Updates this demo to the 3.0 API.
What changed
GCodePreview.init(...)->new GCodePreview(...)(named import). The component function keeps itsGCodePreviewUIname so the class and the component don't collide.WebGLPreviewtype is gone; the instance is typedGCodePreviewand kept in a ref instead of state (the state version handed out a handle that had capturedundefined).allowDragNDrop->droppable,preview.resize()->preview.sceneManager.resize(),preview.layers.length->preview.countLayers.setTimeoutchunk loader is gone, along with thewindow[id]timer stash and the globalWindowindex-signature augmentation insrc/types/index.d.ts.processGCodeStream()now chunks, parses and draws by itself.@types/three^0.144.0 -> ^0.169.0 so the types match thethree0.169.0 actually resolved (single three instance).Note:
response.bodyhas to be piped throughTextDecoderStreambefore it is handed toprocessGCodeStream. The parser splits chunks on newlines, so rawUint8Arraychunks render nothing, silently.Worth eyeballing
initialCameraPosition— a stale saved camera will win on a repeat visit.The firebase PR preview deploy is the way to check all of this visually.
Assisted by Claude Code - Opus 5