@chestnutlabs/gcode-preview-react 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017-2025 Remco Veldkamp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE.md ADDED
@@ -0,0 +1,46 @@
1
+ # NOTICE — Attribution & Provenance
2
+
3
+ This file summarizes attribution and provenance for **ChestnutLabs/gcode-preview**. It complements,
4
+ and does not replace, the [`LICENSE`](LICENSE) file and the full
5
+ [Upstream, Fork, License & Contribution Policy](docs/03_UPSTREAM_FORK_LICENSE_AND_CONTRIBUTION_POLICY.md).
6
+
7
+ ## Upstream origin
8
+
9
+ - **This repository is a public GitHub fork of** [`xyz-tools/gcode-preview`](https://github.com/xyz-tools/gcode-preview)
10
+ (project identity `remcoder/gcode-preview`; npm package `gcode-preview`).
11
+ - **Chestnut founding baseline:** branch `develop` at commit
12
+ `15375e56129f5a57aebc099ed7bfb5a092dcfb9e` (2026-06-08).
13
+ - The inherited Git history and the upstream fork relationship are preserved. Chestnut Labs maintains
14
+ its own roadmap, governance, release cadence, and package APIs.
15
+
16
+ ## Copyright
17
+
18
+ - Inherited code: **Copyright (c) 2017–2025 Remco Veldkamp** and the `xyz-tools/gcode-preview`
19
+ contributors, licensed under the MIT License (see [`LICENSE`](LICENSE)).
20
+ - Chestnut Labs additions and modifications: **Copyright (c) 2026 Chestnut Labs**, also under the MIT
21
+ License.
22
+
23
+ The upstream copyright notice and MIT permission notice are retained in [`LICENSE`](LICENSE) and must
24
+ not be removed. Chestnut notices are added **alongside** — never in place of — upstream notices.
25
+
26
+ ## License
27
+
28
+ MIT for both the inherited fork and Chestnut Labs additions, unless a later, explicit
29
+ legal/governance decision changes the license for an independently separable new package. See the
30
+ fork/license policy for the full rationale, including how an MIT package may be consumed by a
31
+ GPL-3.0 application (e.g., AnyBridge) without altering the package's MIT notice obligations.
32
+
33
+ ## Derived vs. independently replaced code
34
+
35
+ Chestnut Labs does **not** claim a clean-room implementation. Subsystem provenance (inherited /
36
+ modified / replaced / original) is tracked in
37
+ [`docs/UPSTREAM_PROVENANCE.md`](docs/UPSTREAM_PROVENANCE.md). Replacing every line of an inherited
38
+ file does not by itself establish clean-room status; the ledger exists for honesty, maintenance, and
39
+ license review.
40
+
41
+ ## Third-party code
42
+
43
+ Bundled and dependency notices are tracked in [`THIRD_PARTY_NOTICES.md`](THIRD_PARTY_NOTICES.md).
44
+ Reference implementations studied for behavior (Sindarius/Mainsail, Fluidd, PrusaSlicer/libvgcode,
45
+ BambuBuddy, and others) are **not** incorporated as source unless their license is compatible and the
46
+ incorporation is recorded per policy.
@@ -1 +1 @@
1
- {"version":3,"file":"use-model-viewer.d.ts","sourceRoot":"","sources":["../../src/model/use-model-viewer.ts"],"names":[],"mappings":"AAQA,OAAO,EAGL,KAAK,6B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E,MAAM,oCAAoC,CAAC;AAEzE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAC;AAC1F,MAAM,MAAM,qBAAqB,GAAG,6BAA6B,CAAC;AAElE,MAAM,WAAW,iBAAiB;IAChC,2EAA2E;IAC3E,SAAS,EAAE,CAAC,EAAE,EAAE,iBAAiB,GAAG,IAAI,KAAK,IAAI,CAAC;IAClD,+EAA+E;IAC/E,SAAS,EAAE,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAC7C,6EAA6E;IAC7E,OAAO,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,mEAAmE;IACnE,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,GAAG,EAAE;QAAE,MAAM,EAAE,MAAM,WAAW,GAAG,IAAI,CAAA;KAAE,CAAC;IAC1C,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,gBAAgB,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACvD,OAAO,IAAI,IAAI,CAAC;CACjB;AAQD,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,iBAAiB,CAgErF"}
@@ -5,7 +5,7 @@
5
5
  * — never a separate viewer implementation (the D1 drift firewall). Shared contracts are re-exported
6
6
  * from the controller.
7
7
  */
8
- import { useCallback, useMemo, useRef, useSyncExternalStore } from 'react';
8
+ import { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from 'react';
9
9
  import { createModelPreviewController } from '@chestnutlabs/gcode-model-renderer';
10
10
  export function useModelViewer(options = {}) {
11
11
  const optionsRef = useRef(options);
@@ -24,6 +24,22 @@ export function useModelViewer(options = {}) {
24
24
  const subscribe = useCallback((cb) => ensure().onStateChange(() => cb()), [ensure]);
25
25
  const getSnapshot = useCallback(() => ensure().getState(), [ensure]);
26
26
  const state = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
27
+ // Own the controller's lifecycle: (re)create on mount (StrictMode's second setup lands here) and
28
+ // DISPOSE on unmount. Without this the GL engine was freed via the canvas-ref-null path but the
29
+ // controller was never disposed, so in-flight setSource promises never settled and the controller
30
+ // leaked — the toolpath hook already does this; the model hook must match.
31
+ useEffect(() => {
32
+ const c = ensure();
33
+ // Refs attach BEFORE StrictMode's dispose/recreate cycle: rebind the delivered canvas to the fresh
34
+ // controller (refs never re-fire) so it renders again after a remount.
35
+ if (slot.current.canvas !== null && c.raw.viewer() === null) {
36
+ c.bindCanvas(slot.current.canvas);
37
+ }
38
+ return () => {
39
+ slot.current.controller?.dispose();
40
+ slot.current.disposed = true;
41
+ };
42
+ }, [ensure]);
27
43
  const stateRef = useRef(state);
28
44
  stateRef.current = state;
29
45
  return useMemo(() => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chestnutlabs/gcode-preview-react",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Thin React integration for the Chestnut Labs G-code viewer (DD-007 D1 amendment): useGcodePreview hook + GcodePreview component as a reactivity bridge over @chestnutlabs/gcode-preview-core.",
5
5
  "keywords": [
6
6
  "gcode",
@@ -42,7 +42,9 @@
42
42
  }
43
43
  },
44
44
  "files": [
45
- "dist"
45
+ "dist",
46
+ "LICENSE",
47
+ "NOTICE.md"
46
48
  ],
47
49
  "publishConfig": {
48
50
  "access": "public"
@@ -53,11 +55,11 @@
53
55
  "test": "vitest run"
54
56
  },
55
57
  "dependencies": {
56
- "@chestnutlabs/gcode-model-renderer": "0.20.0",
57
- "@chestnutlabs/gcode-parser": "0.20.0",
58
- "@chestnutlabs/gcode-preview-core": "0.20.0",
59
- "@chestnutlabs/gcode-renderer-three": "0.20.0",
60
- "@chestnutlabs/toolpath-core": "0.20.0"
58
+ "@chestnutlabs/gcode-model-renderer": "0.21.0",
59
+ "@chestnutlabs/gcode-parser": "0.21.0",
60
+ "@chestnutlabs/gcode-preview-core": "0.21.0",
61
+ "@chestnutlabs/gcode-renderer-three": "0.21.0",
62
+ "@chestnutlabs/toolpath-core": "0.21.0"
61
63
  },
62
64
  "peerDependencies": {
63
65
  "react": "^18.0.0 || ^19.0.0"