@chestnutlabs/gcode-preview-react 0.1.0 → 0.2.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BuildVolumeDef, ColorMode, QualityMode, TubeOptions } from '@chestnutlabs/gcode-renderer-three';
|
|
1
|
+
import type { BuildVolumeDef, CameraMode, ColorMode, QualityMode, Theme, TubeOptions } from '@chestnutlabs/gcode-renderer-three';
|
|
2
2
|
import type { MachineGeometry, ProgressObservation } from '@chestnutlabs/toolpath-core';
|
|
3
3
|
import type { WireParseOptions, WorkerLike } from '@chestnutlabs/gcode-parser';
|
|
4
4
|
import { type GcodePreviewHandle, type UseGcodePreviewOptions } from './use-gcode-preview.js';
|
|
@@ -10,6 +10,10 @@ export interface GcodePreviewProps {
|
|
|
10
10
|
/** Consumer-configured volume — wins over file-discovered geometry (DD-005 precedence). */
|
|
11
11
|
buildVolume?: BuildVolumeDef | MachineGeometry;
|
|
12
12
|
quality?: QualityMode | 'auto';
|
|
13
|
+
/** #150 (DD-009 D3): camera projection. */
|
|
14
|
+
cameraMode?: CameraMode;
|
|
15
|
+
/** #153 (DD-009 D4): bounded declarative theme. */
|
|
16
|
+
theme?: Theme;
|
|
13
17
|
colorMode?: ColorMode;
|
|
14
18
|
tube?: TubeOptions;
|
|
15
19
|
/** Inclusive [start, end]; null/undefined shows every layer. */
|
|
@@ -17,12 +21,14 @@ export interface GcodePreviewProps {
|
|
|
17
21
|
/** Scrub cut (IR segment index); null shows everything up to the layer range. */
|
|
18
22
|
scrub?: number | null;
|
|
19
23
|
showTravel?: boolean;
|
|
24
|
+
/** DD-009 D1 (#148): opt-in retraction/deretraction markers. */
|
|
25
|
+
showRetractions?: boolean;
|
|
20
26
|
/** DD-006 live progress observation; null hides the overlay. */
|
|
21
27
|
progress?: ProgressObservation | null;
|
|
22
28
|
/** Worker factory escape hatch (DD-005 slim/custom entries; D2). */
|
|
23
29
|
createWorker?: () => WorkerLike;
|
|
24
30
|
/** Advanced/test renderer injectables (pass-throughs of the renderer contract). */
|
|
25
|
-
rendererOptions?: Omit<NonNullable<UseGcodePreviewOptions['renderer']>, 'buildVolume' | 'quality' | 'colorMode' | 'tube'>;
|
|
31
|
+
rendererOptions?: Omit<NonNullable<UseGcodePreviewOptions['renderer']>, 'buildVolume' | 'quality' | 'cameraMode' | 'theme' | 'colorMode' | 'tube'>;
|
|
26
32
|
onReady?: (summary: {
|
|
27
33
|
segments: number;
|
|
28
34
|
layers: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gcode-preview-component.d.ts","sourceRoot":"","sources":["../src/gcode-preview-component.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"gcode-preview-component.d.ts","sourceRoot":"","sources":["../src/gcode-preview-component.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,SAAS,EACT,WAAW,EACX,KAAK,EACL,WAAW,EACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACxF,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAEL,KAAK,kBAAkB,EAEvB,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,WAAW,GAAG,IAAI,GAAG,IAAI,CAAC;AAExE,MAAM,WAAW,iBAAiB;IAChC,mFAAmF;IACnF,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,2FAA2F;IAC3F,WAAW,CAAC,EAAE,cAAc,GAAG,eAAe,CAAC;IAC/C,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAC/B,2CAA2C;IAC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C,OAAO,EAAE,WAAW,CAAA;KAAE,KAAK,IAAI,CAAC;IAC1E,iBAAiB,CAAC,EAAE,CAAC,CAAC,EAAE;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,EAAE,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACxF,yBAAyB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,2BAA2B,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IACjE,6BAA6B,CAAC,EAAE,CAAC,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC/E,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAC1D;AAwHD,8EAA8E;AAC9E,eAAO,MAAM,YAAY,kHAA+B,CAAC"}
|
|
@@ -18,6 +18,8 @@ function GcodePreviewImpl(props, ref) {
|
|
|
18
18
|
renderer: {
|
|
19
19
|
buildVolume: isMachine ? undefined : props.buildVolume,
|
|
20
20
|
quality: props.quality ?? 'auto',
|
|
21
|
+
cameraMode: props.cameraMode ?? 'perspective',
|
|
22
|
+
theme: props.theme,
|
|
21
23
|
colorMode: props.colorMode,
|
|
22
24
|
tube: props.tube,
|
|
23
25
|
...props.rendererOptions
|
|
@@ -69,7 +71,7 @@ function GcodePreviewImpl(props, ref) {
|
|
|
69
71
|
});
|
|
70
72
|
}, []);
|
|
71
73
|
// ---- prop wiring: each prop is a thin call into the hook (D1 shell rule) ----
|
|
72
|
-
const { source, layerRange, scrub, showTravel, colorMode, quality, buildVolume, progress } = props;
|
|
74
|
+
const { source, layerRange, scrub, showTravel, showRetractions, colorMode, quality, cameraMode, theme, buildVolume, progress } = props;
|
|
73
75
|
useEffect(() => {
|
|
74
76
|
if (source !== null && source !== undefined)
|
|
75
77
|
void preview.parse(source, cbRef.current.parseOptions);
|
|
@@ -86,6 +88,9 @@ function GcodePreviewImpl(props, ref) {
|
|
|
86
88
|
useEffect(() => {
|
|
87
89
|
preview.controls.setKindVisible('travel', showTravel ?? true);
|
|
88
90
|
}, [showTravel]);
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
preview.controls.setShowRetractions(showRetractions ?? false);
|
|
93
|
+
}, [showRetractions]);
|
|
89
94
|
useEffect(() => {
|
|
90
95
|
if (colorMode !== undefined)
|
|
91
96
|
preview.controls.setColorMode(colorMode);
|
|
@@ -94,6 +99,14 @@ function GcodePreviewImpl(props, ref) {
|
|
|
94
99
|
if (quality !== undefined)
|
|
95
100
|
preview.controls.setQuality(quality);
|
|
96
101
|
}, [quality]);
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (cameraMode !== undefined)
|
|
104
|
+
preview.controls.setCameraMode(cameraMode);
|
|
105
|
+
}, [cameraMode]);
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (theme !== undefined)
|
|
108
|
+
preview.controls.setTheme(theme);
|
|
109
|
+
}, [theme]);
|
|
97
110
|
useEffect(() => {
|
|
98
111
|
if (buildVolume !== undefined && 'bed' in buildVolume)
|
|
99
112
|
preview.controls.setBuildVolume(buildVolume);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chestnutlabs/gcode-preview-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"test": "vitest run"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@chestnutlabs/gcode-parser": "0.
|
|
53
|
-
"@chestnutlabs/gcode-preview-core": "0.
|
|
54
|
-
"@chestnutlabs/gcode-renderer-three": "0.
|
|
55
|
-
"@chestnutlabs/toolpath-core": "0.
|
|
52
|
+
"@chestnutlabs/gcode-parser": "0.2.0",
|
|
53
|
+
"@chestnutlabs/gcode-preview-core": "0.2.0",
|
|
54
|
+
"@chestnutlabs/gcode-renderer-three": "0.2.0",
|
|
55
|
+
"@chestnutlabs/toolpath-core": "0.2.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"react": "^18.0.0 || ^19.0.0"
|