@chestnutlabs/gcode-preview-svelte 0.1.0 → 0.3.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/README.md CHANGED
@@ -10,7 +10,7 @@ npm install @chestnutlabs/gcode-preview-svelte three
10
10
 
11
11
  (`three` is a peerDependency of the renderer, supported range `^0.178.0` — npm ≥ 7 installs
12
12
  it automatically; pnpm/yarn users add it explicitly. See the
13
- [support policy](../../docs/reference/support-policy.md).)
13
+ [support policy](https://github.com/ChestnutLabs/gcode-preview/blob/dev/docs/reference/support-policy.md).)
14
14
 
15
15
  ## Ready-to-use component
16
16
 
@@ -20,17 +20,31 @@
20
20
  /** Consumer-configured volume — wins over file-discovered geometry (DD-005). */
21
21
  export let buildVolume = undefined;
22
22
  export let quality = 'auto';
23
+ /** #150 (DD-009 D3): camera projection ('perspective' | 'orthographic'). */
24
+ export let cameraMode = 'perspective';
25
+ /** #153 (DD-009 D4): bounded declarative theme. */
26
+ export let theme = undefined;
23
27
  export let colorMode = undefined;
24
28
  export let tube = undefined;
25
29
  /** Inclusive [start, end]; null shows every layer. */
26
30
  export let layerRange = null;
27
31
  /** Scrub cut (IR segment index); null shows everything up to the layer range. */
28
32
  export let scrub = null;
33
+ /** Time-based scrub cut in ms of print time (#181); null clears it. */
34
+ export let scrubTime = null;
29
35
  export let showTravel = true;
36
+ /** DD-016 (#182): show slicer wipe moves. Default true. */
37
+ export let showWipe = true;
38
+ /** DD-009 D1 (#148): opt-in retraction/deretraction markers. */
39
+ export let showRetractions = false;
30
40
  /** DD-006 live progress observation; null hides the overlay. */
31
41
  export let progress = null;
32
42
  /** Worker factory escape hatch (DD-005 slim/custom entries; D2). */
33
43
  export let createWorker = undefined;
44
+ /** DD-014 D5: '3d' (default, Three.js — loaded on demand) or '2d' (low-resource Canvas view). */
45
+ export let renderer = undefined;
46
+ /** 2D only (renderer="2d"): preceding "ghost" layers beneath the active one (default 1, floor 0). */
47
+ export let adjacentLayers = undefined;
34
48
  /** Advanced/test renderer injectables (pass-throughs of the renderer contract). */
35
49
  export let rendererOptions = undefined;
36
50
 
@@ -41,10 +55,14 @@
41
55
  export const preview = createGcodePreview({
42
56
  createWorker,
43
57
  renderer: {
58
+ mode: renderer,
44
59
  buildVolume: isMachine ? undefined : buildVolume,
45
60
  quality,
61
+ cameraMode,
62
+ theme,
46
63
  colorMode,
47
64
  tube,
65
+ adjacentLayers,
48
66
  ...rendererOptions
49
67
  },
50
68
  parseDefaults: parseOptions
@@ -97,9 +115,14 @@
97
115
  $: if (layerRange === null || layerRange === undefined) preview.controls.setLayerRange(0, Number.POSITIVE_INFINITY);
98
116
  else preview.controls.setLayerRange(layerRange[0], layerRange[1]);
99
117
  $: preview.controls.setScrubPosition(scrub ?? null);
118
+ $: preview.controls.setScrubTime(scrubTime ?? null);
100
119
  $: preview.controls.setKindVisible('travel', showTravel);
120
+ $: preview.controls.setKindVisible('wipe', showWipe);
121
+ $: preview.controls.setShowRetractions(showRetractions);
101
122
  $: if (colorMode !== undefined) preview.controls.setColorMode(colorMode);
102
123
  $: preview.controls.setQuality(quality);
124
+ $: preview.controls.setCameraMode(cameraMode);
125
+ $: if (theme !== undefined) preview.controls.setTheme(theme);
103
126
  $: if (progress === null || progress === undefined) preview.clearProgress();
104
127
  else preview.observeProgress(progress);
105
128
 
@@ -9,10 +9,9 @@
9
9
  * outside a component) call `dispose()` themselves — there is no ambient scope to tie to.
10
10
  */
11
11
  import type { GcodeParseSession, WireParseOptions } from '@chestnutlabs/gcode-parser';
12
- import type { ToolpathRenderer } from '@chestnutlabs/gcode-renderer-three';
13
12
  import type { MappedProgress, ProgressObservation } from '@chestnutlabs/toolpath-core';
14
- import { type GcodePreviewControls, type GcodePreviewState, type ParseOutcome, type PreviewControllerOptions, type PreviewEvent } from '@chestnutlabs/gcode-preview-core';
15
- export type { GcodePreviewControls, GcodePreviewState, ParseOutcome, PreviewEvent } from '@chestnutlabs/gcode-preview-core';
13
+ import { type GcodePreviewControls, type GcodePreviewState, type ParseOutcome, type PreviewControllerOptions, type PreviewEvent, type PreviewRenderer } from '@chestnutlabs/gcode-preview-core';
14
+ export type { GcodePreviewControls, GcodePreviewState, ParseOutcome, PreviewEvent, PreviewRenderer, RendererMode } from '@chestnutlabs/gcode-preview-core';
16
15
  /** Svelte-facing options — identical to the controller's (the alias is the public name). */
17
16
  export type CreateGcodePreviewOptions = PreviewControllerOptions;
18
17
  /** Minimal svelte/store Readable contract — declared structurally so the shipped JS
@@ -38,7 +37,7 @@ export interface SvelteGcodePreview {
38
37
  controls: GcodePreviewControls;
39
38
  raw: {
40
39
  session: GcodeParseSession;
41
- renderer: () => ToolpathRenderer | null;
40
+ renderer: () => PreviewRenderer | null;
42
41
  };
43
42
  onEvent(cb: (e: PreviewEvent) => void): () => void;
44
43
  dispose(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"create-gcode-preview.d.ts","sourceRoot":"","sources":["../src/create-gcode-preview.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvF,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EAClB,MAAM,kCAAkC,CAAC;AAG1C,YAAY,EACV,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACb,MAAM,kCAAkC,CAAC;AAE1C,4FAA4F;AAC5F,MAAM,MAAM,yBAAyB,GAAG,wBAAwB,CAAC;AAEjE;4EAC4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,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B;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,kBAAkB,CAuB9F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chestnutlabs/gcode-preview-svelte",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Thin Svelte integration for the Chestnut Labs G-code viewer (DD-007 D1 amendment): createGcodePreview store/action API + GcodePreview component as a reactivity bridge over @chestnutlabs/gcode-preview-core.",
5
5
  "keywords": [
6
6
  "gcode",
@@ -55,10 +55,10 @@
55
55
  "test": "vitest run"
56
56
  },
57
57
  "dependencies": {
58
- "@chestnutlabs/gcode-parser": "0.1.0",
59
- "@chestnutlabs/gcode-preview-core": "0.1.0",
60
- "@chestnutlabs/gcode-renderer-three": "0.1.0",
61
- "@chestnutlabs/toolpath-core": "0.1.0"
58
+ "@chestnutlabs/gcode-parser": "0.3.0",
59
+ "@chestnutlabs/gcode-preview-core": "0.3.0",
60
+ "@chestnutlabs/gcode-renderer-three": "0.3.0",
61
+ "@chestnutlabs/toolpath-core": "0.3.0"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "svelte": "^4.0.0 || ^5.0.0"