@sienci/gviewer 0.1.29 → 0.1.31
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/dist/{GCodeSVGRenderer-BezIPixY.js → GCodeSVGRenderer-BeeQVu4r.js} +141 -100
- package/dist/{GCodeSVGRenderer-cfCcKFfP.cjs → GCodeSVGRenderer-HssywtI7.cjs} +3 -3
- package/dist/gviewer.cjs +1 -1
- package/dist/gviewer.js +412 -407
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/dist/types/geometry.d.ts +23 -5
- package/dist/types/types.d.ts +23 -0
- package/dist/types/viewer/GCodeViewer.d.ts +23 -2
- package/dist/types/viewer/index.d.ts +1 -1
- package/dist/types/viewer/toolpath/streams.d.ts +4 -0
- package/dist/viewer.cjs +1 -1
- package/dist/viewer.js +1 -1
- package/package.json +1 -1
package/dist/react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("react"),F=require("./GCodeSVGRenderer-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("react"),F=require("./GCodeSVGRenderer-HssywtI7.cjs");function C(a){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const s in a)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(a,s);Object.defineProperty(d,s,i.get?i:{enumerable:!0,get:()=>a[s]})}}return d.default=a,Object.freeze(d)}const o=C(V),G=o.forwardRef(function(d,s){const{id:i,options:l,callbacks:c,className:p,style:m}=d,u=o.useRef(null),r=o.useRef(null);return o.useEffect(()=>{const e=u.current;if(!e)return;const f=new F.GCodeViewer({id:i,container:e,options:l,callbacks:c});return r.current=f,()=>{r.current=null,f.dispose()}},[i]),o.useEffect(()=>{var e;(e=r.current)==null||e.setOptions(l??{})},[l]),o.useEffect(()=>{var e;(e=r.current)==null||e.setCallbacks(c??{})},[c]),o.useImperativeHandle(s,()=>{const e=()=>{const t=r.current;if(!t)throw new Error("GCodeViewer is not ready.");return t};return{get id(){return i},setCallbacks(t){e().setCallbacks(t)},snapCameraToView(t,n){e().snapCameraToView(t,n)},setRotateEnabled(t){e().setRotateEnabled(t)},setCameraFollowEnabled(t){e().setCameraFollowEnabled(t)},screenToWorld(t,n,w){return e().screenToWorld(t,n,w)},worldToScreen(t,n,w){return e().worldToScreen(t,n,w)},setBitPosition(t,n){e().setBitPosition(t,n)},setBitVisible(t){e().setBitVisible(t)},setBitSpinning(t){e().setBitSpinning(t)},setToolpathRotationA(t){e().setToolpathRotationA(t)},hideUntilLine(t,n){e().hideUntilLine(t,n)},seekToLine(t,n){e().seekToLine(t,n)},showAll(){e().showAll()},resetColors(){e().resetColors()},loadFromUrl(t,n){return e().loadFromUrl(t,n)},loadFromFile(t){return e().loadFromFile(t)},loadFromText(t){return e().loadFromText(t)},loadFromLines(t){return e().loadFromLines(t)},loadFromWorkerData(t){return e().loadFromWorkerData(t)},unload(){e().unload()},setOptions(t){e().setOptions(t)},getOptions(){return e().getOptions()},resize(){e().resize()},focusToModel(){e().focusToModel()},resetCamera(){e().resetCamera()},getBounds(){return e().getBounds()},dispose(){e().dispose()}}},[i]),o.createElement("div",{ref:u,className:p,style:m})}),b=o.forwardRef(function(d,s){const{id:i,options:l,className:c,style:p}=d,m=o.useRef(null),u=o.useRef(null);return o.useEffect(()=>{const r=m.current;if(!r)return;const e=new F.GCodeSVGRenderer(r,l);return u.current=e,()=>{u.current=null,e.dispose()}},[]),o.useEffect(()=>{var r;l&&((r=u.current)==null||r.setOptions(l))},[l]),o.useImperativeHandle(s,()=>{const r=()=>{const e=u.current;if(!e)throw new Error("GCodeSVGRenderer is not ready.");return e};return{loadFromLines:e=>r().loadFromLines(e),loadFromFile:e=>r().loadFromFile(e),loadFromText:e=>r().loadFromText(e),loadFromWorkerData:e=>r().loadFromWorkerData(e),loadFromPrecomputedGroups:(e,f)=>r().loadFromPrecomputedGroups(e,f),clear:()=>r().clear(),resetView:()=>r().resetView(),setOptions:e=>r().setOptions(e),setProjectionMode:e=>r().setProjectionMode(e),setBitPosition:e=>r().setBitPosition(e),setBitVisible:e=>r().setBitVisible(e),getSVGElement:()=>r().getSVGElement(),dispose:()=>r().dispose()}},[]),o.createElement("div",{ref:m,className:c,style:{width:"100%",height:"100%",...p}})});exports.GCodeSVGVisualizer=b;exports.GCodeVisualizer=G;
|
package/dist/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as o from "react";
|
|
2
|
-
import { a as w, G as V } from "./GCodeSVGRenderer-
|
|
2
|
+
import { a as w, G as V } from "./GCodeSVGRenderer-BeeQVu4r.js";
|
|
3
3
|
const G = o.forwardRef(
|
|
4
4
|
function(c, m) {
|
|
5
5
|
const { id: l, options: n, callbacks: a, className: f, style: u } = c, i = o.useRef(null), t = o.useRef(null);
|
package/dist/types/geometry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArcMoveCallback, LinearMoveCallback, Position, WorkerGeometryData } from "./types";
|
|
1
|
+
import { ArcMoveCallback, LinearMoveCallback, Position, WorkerGeometryData, LoadWorkerDataOptions } from "./types";
|
|
2
2
|
export type VertexCollector = {
|
|
3
3
|
onLinearMove?: (args: Parameters<LinearMoveCallback>[0], vertices: number[]) => void;
|
|
4
4
|
onArcMove?: (args: Parameters<ArcMoveCallback>[0], vertices: number[]) => void;
|
|
@@ -101,13 +101,18 @@ export type WorkerToolpathStream = {
|
|
|
101
101
|
positions: Float32Array;
|
|
102
102
|
colors: Float32Array;
|
|
103
103
|
prefixEndVertex: Int32Array;
|
|
104
|
+
/**
|
|
105
|
+
* Index into the `lineGroups` this stream was built for, or null for the
|
|
106
|
+
* catch-all stream holding lines that fell in no group.
|
|
107
|
+
*/
|
|
108
|
+
lineGroupIndex: number | null;
|
|
104
109
|
};
|
|
105
110
|
export type WorkerToolpathStreams = {
|
|
106
|
-
|
|
107
|
-
|
|
111
|
+
rapids: WorkerToolpathStream[];
|
|
112
|
+
cuts: WorkerToolpathStream[];
|
|
108
113
|
};
|
|
109
114
|
/**
|
|
110
|
-
* Builds
|
|
115
|
+
* Builds line-ordered toolpath streams (rapid + cut) from worker geometry,
|
|
111
116
|
* preserving per-vertex colours and producing per-stream `prefixEndVertex`
|
|
112
117
|
* arrays (indexed by source line) so `hideUntilLine`/progress greying works on
|
|
113
118
|
* the worker-data path.
|
|
@@ -115,5 +120,18 @@ export type WorkerToolpathStreams = {
|
|
|
115
120
|
* Unlike `buildWorkerSegmentGroups`, segments are appended in source-line order
|
|
116
121
|
* (driven by `frames`) rather than grouped by colour, which is what the
|
|
117
122
|
* cumulative `prefixEndVertex` cursor requires.
|
|
123
|
+
*
|
|
124
|
+
* With no `lineGroups`, the result is exactly one rapid stream and one cut
|
|
125
|
+
* stream, both with a null `lineGroupIndex`. Passing `lineGroups` splits both by
|
|
126
|
+
* source-line range instead - one rapid and one cut stream per group, plus a
|
|
127
|
+
* trailing pair for the lines in no group - so a host can hide an interior span
|
|
128
|
+
* by flipping those streams' visibility, which a single contiguous draw range
|
|
129
|
+
* (all `hideUntilLine` can offer) cannot express. Each group keeps its own
|
|
130
|
+
* carry-forward `prefixEndVertex`, so progress greying stays correct within
|
|
131
|
+
* every stream.
|
|
132
|
+
*
|
|
133
|
+
* Grouping costs an `Int32Array(framesLen)` per stream, so memory grows with
|
|
134
|
+
* lines x groups. It is meant for interactive review of a file already held in
|
|
135
|
+
* memory, not for the live job path.
|
|
118
136
|
*/
|
|
119
|
-
export declare function buildWorkerToolpathStreams(data: WorkerGeometryData): WorkerToolpathStreams;
|
|
137
|
+
export declare function buildWorkerToolpathStreams(data: WorkerGeometryData, options?: LoadWorkerDataOptions): WorkerToolpathStreams;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -81,3 +81,26 @@ export type WorkerGeometryData = {
|
|
|
81
81
|
isLaser?: boolean;
|
|
82
82
|
toolchangeCount?: number;
|
|
83
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* An inclusive range of source lines the host wants to show or hide as a unit,
|
|
86
|
+
* e.g. everything cut with one tool.
|
|
87
|
+
*
|
|
88
|
+
* Indices are 0-based and match `hideUntilLine`/`seekToLine` — the same source
|
|
89
|
+
* line indexing used by `prefixEndVertex` — not 1-based editor line numbers.
|
|
90
|
+
*/
|
|
91
|
+
export type LineRangeGroup = {
|
|
92
|
+
start: number;
|
|
93
|
+
end: number;
|
|
94
|
+
};
|
|
95
|
+
export type LoadWorkerDataOptions = {
|
|
96
|
+
/**
|
|
97
|
+
* Split the toolpath into separately hideable streams by source-line range,
|
|
98
|
+
* so `setLineGroupVisible` can hide an interior span. Without this the
|
|
99
|
+
* toolpath is one rapid stream plus one cut stream, and only a *prefix* can
|
|
100
|
+
* be hidden (via `hideUntilLine`, which sets a single contiguous draw range).
|
|
101
|
+
*
|
|
102
|
+
* Groups are matched in order, so where ranges overlap the first one wins.
|
|
103
|
+
* Lines in no group land in an always-visible stream.
|
|
104
|
+
*/
|
|
105
|
+
lineGroups?: readonly LineRangeGroup[];
|
|
106
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WorkerGeometryData } from "../types";
|
|
1
|
+
import type { LoadWorkerDataOptions, WorkerGeometryData } from "../types";
|
|
2
2
|
import { GCodeViewerCameraView, GCodeViewerBounds, GCodeViewerCallbacks, GCodeViewerCreateArgs, GCodeViewerHandle, GCodeViewerBitPosition, GCodeViewerOptions } from "./types";
|
|
3
3
|
export declare class GCodeViewer implements GCodeViewerHandle {
|
|
4
4
|
readonly id: string;
|
|
@@ -56,6 +56,21 @@ export declare class GCodeViewer implements GCodeViewerHandle {
|
|
|
56
56
|
hideUntilLine(lineIndex: number, mode?: "hide" | "grey"): void;
|
|
57
57
|
seekToLine(lineIndex: number, mode?: "hide" | "grey"): void;
|
|
58
58
|
showAll(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Show or hide one of the `lineGroups` the toolpath was loaded with.
|
|
61
|
+
*
|
|
62
|
+
* This is deliberately independent of `showAll()`, `hideUntilLine()` and
|
|
63
|
+
* `resetColors()`, which are all about *progress*: they move draw ranges and
|
|
64
|
+
* colors, while this flips object visibility. So the two compose in either
|
|
65
|
+
* order - but note a hidden group therefore stays hidden across a `showAll()`,
|
|
66
|
+
* which looks surprising if you expect "show all" to mean everything. Call
|
|
67
|
+
* `showAllLineGroups()` for that.
|
|
68
|
+
*
|
|
69
|
+
* A no-op when the load passed no `lineGroups`, or for the catch-all stream of
|
|
70
|
+
* lines outside every group, which has no index and is always visible.
|
|
71
|
+
*/
|
|
72
|
+
setLineGroupVisible(groupIndex: number, visible: boolean): void;
|
|
73
|
+
showAllLineGroups(): void;
|
|
59
74
|
resetColors(): void;
|
|
60
75
|
snapCameraToView(view: GCodeViewerCameraView, options?: {
|
|
61
76
|
durationMs?: number;
|
|
@@ -116,7 +131,13 @@ export declare class GCodeViewer implements GCodeViewerHandle {
|
|
|
116
131
|
loadFromFile(file: File): Promise<void>;
|
|
117
132
|
loadFromText(gcode: string): Promise<void>;
|
|
118
133
|
loadFromLines(lines: readonly string[]): Promise<void>;
|
|
119
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Pass `options.lineGroups` to split the toolpath into separately hideable
|
|
136
|
+
* streams by source-line range; `setLineGroupVisible` then shows or hides a
|
|
137
|
+
* group. Without it the toolpath is one rapid + one cut stream, exactly as
|
|
138
|
+
* before, and only a prefix can be hidden (`hideUntilLine`).
|
|
139
|
+
*/
|
|
140
|
+
loadFromWorkerData(data: WorkerGeometryData, options?: LoadWorkerDataOptions): Promise<void>;
|
|
120
141
|
unload(): void;
|
|
121
142
|
setOptions(next: Partial<GCodeViewerOptions>): void;
|
|
122
143
|
getOptions(): Readonly<GCodeViewerOptions>;
|
|
@@ -5,4 +5,4 @@ export type { GCodeViewerThemePresetName } from "./themes";
|
|
|
5
5
|
export * from "./types";
|
|
6
6
|
export { GCodeSVGRenderer } from "./svg/GCodeSVGRenderer";
|
|
7
7
|
export type { GCodeSVGOptions } from "./svg/types";
|
|
8
|
-
export type { WorkerGeometryData } from "../types";
|
|
8
|
+
export type { LineRangeGroup, LoadWorkerDataOptions, WorkerGeometryData } from "../types";
|
|
@@ -10,6 +10,9 @@ export type ToolpathStreamState = {
|
|
|
10
10
|
greyCursorVertex: number;
|
|
11
11
|
kind: ToolpathStreamKind;
|
|
12
12
|
cutBucketIndex: number | null;
|
|
13
|
+
/** Which of the load's `lineGroups` this stream holds, or null for the always-visible
|
|
14
|
+
* catch-all and for ungrouped loads. Drives setLineGroupVisible. */
|
|
15
|
+
lineGroupIndex: number | null;
|
|
13
16
|
/** Set when colors came from the worker's pre-baked colorArrayBuffer (e.g. toolchange palette).
|
|
14
17
|
* refreshToolpathStreamColors skips these streams so theme changes don't flatten per-tool colors. */
|
|
15
18
|
workerColors?: Float32Array;
|
|
@@ -17,6 +20,7 @@ export type ToolpathStreamState = {
|
|
|
17
20
|
export type ToolpathStreamSpec = {
|
|
18
21
|
kind: ToolpathStreamKind;
|
|
19
22
|
cutBucketIndex: number | null;
|
|
23
|
+
lineGroupIndex?: number | null;
|
|
20
24
|
positions: Float32Array;
|
|
21
25
|
prefixEndVertex: Int32Array;
|
|
22
26
|
opacity: number;
|
package/dist/viewer.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./GCodeSVGRenderer-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./GCodeSVGRenderer-HssywtI7.cjs"),a={dark:{background:"#111827",opacity:.9,rapidOpacity:.3,colors:{rapid:"#0ef6ae",cutting:"#3e85c7",laser:"#a855f7",processed:"#6b7280",boundingBox:"#e2e8f0",machineBed:"#f5a623",machineBedKeepout:"#df3b3b",grid:{major:"#77a9d7",minor:"#3e6e9e"},axes:{x:"#df3b3b",y:"#06b881",z:"#295d8d"}}},light:{background:"#e5e7eb",opacity:.9,rapidOpacity:.3,colors:{rapid:"#295d8d",cutting:"#111827",laser:"#FF0000",processed:"#9ca3af",boundingBox:"#4b5563",machineBed:"#b45309",machineBedKeepout:"#df3b3b",grid:{major:"#295d8d",minor:"#5191cc"},axes:{x:"#df3b3b",y:"#06b881",z:"#295d8d"}}},"flexoki-dark":{background:"#100f0f",opacity:.9,rapidOpacity:.3,colors:{rapid:"#DA702C",cutting:"#3AA99F",laser:"#8B7EC8",processed:"#6f6e69",boundingBox:"#cecdc3",machineBed:"#ffcc66",machineBedKeepout:"#d14d41",grid:{major:"#a89984",minor:"#6f6e69"},axes:{x:"#d14d41",y:"#879a39",z:"#4385be"}}},"tokyo-night":{background:"#1a1b26",opacity:.9,rapidOpacity:.3,colors:{rapid:"#ff9e64",cutting:"#7dcfff",laser:"#bb9af7",processed:"#565f89",boundingBox:"#c0caf5",machineBed:"#e0af68",machineBedKeepout:"#f7768e",grid:{major:"#7aa2f7",minor:"#414868"},axes:{x:"#f7768e",y:"#9ece6a",z:"#7aa2f7"}}},"gruvbox-light":{background:"#fbf1c7",opacity:.9,rapidOpacity:.3,colors:{rapid:"#d65d0e",cutting:"#3c3836",laser:"#b16286",processed:"#928374",boundingBox:"#7c6f64",machineBed:"#d79921",machineBedKeepout:"#cc241d",grid:{major:"#7c6f64",minor:"#a89984"},axes:{x:"#cc241d",y:"#98971a",z:"#458588"}}},"ayu-dark":{background:"#0b0e14",opacity:.9,rapidOpacity:.3,colors:{rapid:"#FFA659",cutting:"#73D0FF",laser:"#DFBFFF",processed:"#6E7C8F",boundingBox:"#CBCCC6",machineBed:"#FFD173",machineBedKeepout:"#F28779",grid:{major:"#77a9d7",minor:"#3e6590"},axes:{x:"#F28779",y:"#D5FF80",z:"#5CCFE6"}}},"ayu-light":{background:"#fafafa",opacity:.9,rapidOpacity:.3,colors:{rapid:"#FA8D3E",cutting:"#22A4E6",laser:"#A37ACC",processed:"#ADAEB1",boundingBox:"#5C6773",machineBed:"#F2AE49",machineBedKeepout:"#F07171",grid:{major:"#5c6773",minor:"#9aacba"},axes:{x:"#F07171",y:"#86B300",z:"#55B4D4"}}}};exports.GCodeSVGRenderer=e.GCodeSVGRenderer;exports.GCodeViewer=e.GCodeViewer;exports.ViewCube=e.ViewCube;exports.defaultGCodeViewerOptions=e.defaultGCodeViewerOptions;exports.defaultGCodeViewerTheme=e.defaultGCodeViewerTheme;exports.gCodeViewerThemePresets=a;
|
package/dist/viewer.js
CHANGED