@sienci/gviewer 0.1.24 → 0.1.26
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-BrTJFrH-.js → GCodeSVGRenderer-B3yGZPdi.js} +1818 -1737
- package/dist/{GCodeSVGRenderer-BS3n-2zr.cjs → GCodeSVGRenderer-Cs4ED_O_.cjs} +3 -3
- package/dist/react.cjs +1 -1
- package/dist/react.js +15 -15
- package/dist/types/react/GCodeSVGVisualizer.d.ts +6 -2
- package/dist/types/viewer/svg/GCodeSVGRenderer.d.ts +12 -2
- package/dist/types/viewer/svg/types.d.ts +1 -1
- 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-Cs4ED_O_.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,15 +1,15 @@
|
|
|
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-B3yGZPdi.js";
|
|
3
3
|
const G = o.forwardRef(
|
|
4
|
-
function(
|
|
5
|
-
const { id: l, options: n, callbacks: a, className:
|
|
4
|
+
function(c, m) {
|
|
5
|
+
const { id: l, options: n, callbacks: a, className: f, style: u } = c, i = o.useRef(null), t = o.useRef(null);
|
|
6
6
|
return o.useEffect(() => {
|
|
7
7
|
const e = i.current;
|
|
8
8
|
if (!e)
|
|
9
9
|
return;
|
|
10
|
-
const
|
|
11
|
-
return t.current =
|
|
12
|
-
t.current = null,
|
|
10
|
+
const d = new w({ id: l, container: e, options: n, callbacks: a });
|
|
11
|
+
return t.current = d, () => {
|
|
12
|
+
t.current = null, d.dispose();
|
|
13
13
|
};
|
|
14
14
|
}, [l]), o.useEffect(() => {
|
|
15
15
|
var e;
|
|
@@ -18,7 +18,7 @@ const G = o.forwardRef(
|
|
|
18
18
|
var e;
|
|
19
19
|
(e = t.current) == null || e.setCallbacks(a ?? {});
|
|
20
20
|
}, [a]), o.useImperativeHandle(
|
|
21
|
-
|
|
21
|
+
m,
|
|
22
22
|
() => {
|
|
23
23
|
const e = () => {
|
|
24
24
|
const r = t.current;
|
|
@@ -114,13 +114,13 @@ const G = o.forwardRef(
|
|
|
114
114
|
};
|
|
115
115
|
},
|
|
116
116
|
[l]
|
|
117
|
-
), o.createElement("div", { ref: i, className:
|
|
117
|
+
), o.createElement("div", { ref: i, className: f, style: u });
|
|
118
118
|
}
|
|
119
119
|
), R = o.forwardRef(
|
|
120
|
-
function(
|
|
121
|
-
const { id: l, options: n, className: a, style:
|
|
120
|
+
function(c, m) {
|
|
121
|
+
const { id: l, options: n, className: a, style: f } = c, u = o.useRef(null), i = o.useRef(null);
|
|
122
122
|
return o.useEffect(() => {
|
|
123
|
-
const t =
|
|
123
|
+
const t = u.current;
|
|
124
124
|
if (!t) return;
|
|
125
125
|
const e = new V(t, n);
|
|
126
126
|
return i.current = e, () => {
|
|
@@ -129,7 +129,7 @@ const G = o.forwardRef(
|
|
|
129
129
|
}, []), o.useEffect(() => {
|
|
130
130
|
var t;
|
|
131
131
|
n && ((t = i.current) == null || t.setOptions(n));
|
|
132
|
-
}, [n]), o.useImperativeHandle(
|
|
132
|
+
}, [n]), o.useImperativeHandle(m, () => {
|
|
133
133
|
const t = () => {
|
|
134
134
|
const e = i.current;
|
|
135
135
|
if (!e) throw new Error("GCodeSVGRenderer is not ready.");
|
|
@@ -140,7 +140,7 @@ const G = o.forwardRef(
|
|
|
140
140
|
loadFromFile: (e) => t().loadFromFile(e),
|
|
141
141
|
loadFromText: (e) => t().loadFromText(e),
|
|
142
142
|
loadFromWorkerData: (e) => t().loadFromWorkerData(e),
|
|
143
|
-
loadFromPrecomputedGroups: (e) => t().loadFromPrecomputedGroups(e),
|
|
143
|
+
loadFromPrecomputedGroups: (e, d) => t().loadFromPrecomputedGroups(e, d),
|
|
144
144
|
clear: () => t().clear(),
|
|
145
145
|
resetView: () => t().resetView(),
|
|
146
146
|
setOptions: (e) => t().setOptions(e),
|
|
@@ -151,9 +151,9 @@ const G = o.forwardRef(
|
|
|
151
151
|
dispose: () => t().dispose()
|
|
152
152
|
};
|
|
153
153
|
}, []), o.createElement("div", {
|
|
154
|
-
ref:
|
|
154
|
+
ref: u,
|
|
155
155
|
className: a,
|
|
156
|
-
style: { width: "100%", height: "100%", ...
|
|
156
|
+
style: { width: "100%", height: "100%", ...f }
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
);
|
|
@@ -11,11 +11,15 @@ export type GCodeSVGRendererHandle = {
|
|
|
11
11
|
opacity: number;
|
|
12
12
|
positionsBuffer: ArrayBuffer;
|
|
13
13
|
positionsLen: number;
|
|
14
|
-
|
|
14
|
+
stride?: 4 | 6;
|
|
15
|
+
}[], meta?: {
|
|
16
|
+
minZ?: number;
|
|
17
|
+
maxZ?: number;
|
|
18
|
+
}): void;
|
|
15
19
|
clear(): void;
|
|
16
20
|
resetView(): void;
|
|
17
21
|
setOptions(opts: Partial<GCodeSVGOptions>): void;
|
|
18
|
-
setProjectionMode(mode: 'perspective' | 'isometric'): void;
|
|
22
|
+
setProjectionMode(mode: 'perspective' | 'isometric' | 'top'): void;
|
|
19
23
|
setBitPosition(pos: {
|
|
20
24
|
x: number;
|
|
21
25
|
y: number;
|
|
@@ -31,9 +31,11 @@ export declare class GCodeSVGRenderer {
|
|
|
31
31
|
private pinchLastDist;
|
|
32
32
|
private pinchLastMid;
|
|
33
33
|
private rafPending;
|
|
34
|
+
private overlayRafPending;
|
|
34
35
|
private rapidVerts;
|
|
35
36
|
private cutVerts;
|
|
36
37
|
private bounds;
|
|
38
|
+
private hasZInfo;
|
|
37
39
|
constructor(container: HTMLElement, options?: Partial<GCodeSVGOptions>);
|
|
38
40
|
loadFromLines(lines: string[]): void;
|
|
39
41
|
loadFromFile(file: File): Promise<void>;
|
|
@@ -45,11 +47,15 @@ export declare class GCodeSVGRenderer {
|
|
|
45
47
|
opacity: number;
|
|
46
48
|
positionsBuffer: ArrayBuffer;
|
|
47
49
|
positionsLen: number;
|
|
48
|
-
|
|
50
|
+
stride?: 4 | 6;
|
|
51
|
+
}[], meta?: {
|
|
52
|
+
minZ?: number;
|
|
53
|
+
maxZ?: number;
|
|
54
|
+
}): void;
|
|
49
55
|
private syncSegmentGroupsFromLines;
|
|
50
56
|
resetView(): void;
|
|
51
57
|
setOptions(opts: Partial<GCodeSVGOptions>): void;
|
|
52
|
-
setProjectionMode(mode: 'perspective' | 'isometric'): void;
|
|
58
|
+
setProjectionMode(mode: 'perspective' | 'isometric' | 'top'): void;
|
|
53
59
|
getSVGElement(): SVGSVGElement;
|
|
54
60
|
setBitPosition(pos: {
|
|
55
61
|
x: number;
|
|
@@ -61,7 +67,11 @@ export declare class GCodeSVGRenderer {
|
|
|
61
67
|
private updateTrig;
|
|
62
68
|
private project;
|
|
63
69
|
private rebuildAndRender;
|
|
70
|
+
private rebuildToolpaths;
|
|
71
|
+
private renderOverlays;
|
|
72
|
+
private simplifyTolerance;
|
|
64
73
|
private scheduleDraw;
|
|
74
|
+
private scheduleOverlayDraw;
|
|
65
75
|
private fitView;
|
|
66
76
|
private applyViewBox;
|
|
67
77
|
private applyOptions;
|
|
@@ -5,7 +5,7 @@ export type GCodeSVGOptions = {
|
|
|
5
5
|
strokeWidth: number;
|
|
6
6
|
arcSegments: number;
|
|
7
7
|
padding: number;
|
|
8
|
-
projectionMode: 'perspective' | 'isometric';
|
|
8
|
+
projectionMode: 'perspective' | 'isometric' | 'top';
|
|
9
9
|
showOrigin: boolean;
|
|
10
10
|
originColor: string;
|
|
11
11
|
crosshairColor: string;
|
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-Cs4ED_O_.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