Repository navigation
Turn the example into a reusable component package - #3
Merged
Merged
Conversation
Wrap gcode-preview in a component with typed option props (live or mount-only), src/gcode loading, ready/load/error callbacks and instance access. The library builds to dist/ for npm (still private: true); the demo imports it from source and gets its own build script for Firebase.
|
Visit the preview URL for this PR (updated for commit bc710d0): https://gcode-preview-react--pr3-feature-reusable-com-117xfxb2.web.app (expires Sun, 11 Oct 2026 20:24:51 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: c787db3520fae43f256c13f53bbe62214d2df228 |
Drops the React logos, web manifest, robots.txt and the matching head tags, trims CRA entries from .gitignore, gives the page a real title, and makes the preview droppable with a hint, like the Svelte and Vue demos.
TypeScript stays on 6.0 (typescript-eslint supports <6.1) and ESLint on 9 (eslint-plugin-react supports up to ^9.7). @types/three stays on 0.185 to match the three range gcode-preview accepts.
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.
Turns the example into a reusable component package that can later be published to npm. The demo stays in this repo, imports the component from source and still deploys to Firebase.
What changes
gcode-previewoption is a prop, typed from the core. Options with a live setter update the preview in place (only when they change); the rest are read once at mount. A typecheck fails if the core adds an option the component doesn't list.src(fetched and streamed) orgcode(text, wins oversrc). A new load aborts the previous one; start/end layer are re-applied after each load.console.error.GCodePreview.<canvas>with attributes passed through; size it with CSS. AResizeObserverresizes it, and unmount cleans everything up. No hardcoded size, colors, build volume or camera.dist/with typings.gcode-previewand the framework are peer dependencies. Version0.1.0, still"private": trueuntil we publish.publintis added aslint:package.Checks
Typecheck, unit tests (core mocked), library build,
publintandnpm pack --dry-runall pass. A packed tarball was installed in a separate Vite + TypeScript app, which typechecked and built. The demo was checked in a browser.Known core issues (gcode-preview 3.0.0-alpha.6)
buildVolume's type requiressmallGrid..d.tsneeds@types/threein TypeScript consumers.