@sienci/gviewer 0.1.6 → 0.1.7
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 +29 -6
- package/dist/{GCodeSVGRenderer-hZ8tZwov.cjs → GCodeSVGRenderer-BTecOJPu.cjs} +1 -1
- package/dist/{GCodeSVGRenderer-DUQ-WgJi.js → GCodeSVGRenderer-BubxJOY3.js} +184 -166
- package/dist/react.cjs +1 -1
- package/dist/react.js +39 -37
- package/dist/types/react/GCodeSVGVisualizer.d.ts +6 -0
- package/dist/types/viewer/svg/GCodeSVGRenderer.d.ts +10 -0
- package/dist/types/viewer/svg/types.d.ts +1 -0
- package/dist/types/viewer/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
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("react"),V=require("./GCodeSVGRenderer-BTecOJPu.cjs");function w(a){const u=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(u,s,i.get?i:{enumerable:!0,get:()=>a[s]})}}return u.default=a,Object.freeze(u)}const o=w(F),G=o.forwardRef(function(u,s){const{id:i,options:l,callbacks:c,className:m,style:f}=u,d=o.useRef(null),r=o.useRef(null);return o.useEffect(()=>{const e=d.current;if(!e)return;const p=new V.GCodeViewer({id:i,container:e,options:l,callbacks:c});return r.current=p,()=>{r.current=null,p.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)},setBitPosition(t,n){e().setBitPosition(t,n)},setBitVisible(t){e().setBitVisible(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:d,className:m,style:f})}),C=o.forwardRef(function(u,s){const{id:i,options:l,className:c,style:m}=u,f=o.useRef(null),d=o.useRef(null);return o.useEffect(()=>{const r=f.current;if(!r)return;const e=new V.GCodeSVGRenderer(r,l);return d.current=e,()=>{d.current=null,e.dispose()}},[]),o.useEffect(()=>{var r;l&&((r=d.current)==null||r.setOptions(l))},[l]),o.useImperativeHandle(s,()=>{const r=()=>{const e=d.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=>r().loadFromPrecomputedGroups(e),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:f,className:c,style:{width:"100%",height:"100%",...m}})});exports.GCodeSVGVisualizer=C;exports.GCodeVisualizer=G;
|
package/dist/react.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { a as F, G as w } from "./GCodeSVGRenderer-
|
|
3
|
-
const C =
|
|
1
|
+
import * as o from "react";
|
|
2
|
+
import { a as F, G as w } from "./GCodeSVGRenderer-BubxJOY3.js";
|
|
3
|
+
const C = o.forwardRef(
|
|
4
4
|
function(u, c) {
|
|
5
|
-
const { id: a, options: n, callbacks: l, className: m, style: d } = u, i =
|
|
6
|
-
return
|
|
5
|
+
const { id: a, options: n, callbacks: l, className: m, style: d } = u, i = o.useRef(null), t = o.useRef(null);
|
|
6
|
+
return o.useEffect(() => {
|
|
7
7
|
const e = i.current;
|
|
8
8
|
if (!e)
|
|
9
9
|
return;
|
|
10
10
|
const f = new F({ id: a, container: e, options: n, callbacks: l });
|
|
11
|
-
return
|
|
12
|
-
|
|
11
|
+
return t.current = f, () => {
|
|
12
|
+
t.current = null, f.dispose();
|
|
13
13
|
};
|
|
14
|
-
}, [a]),
|
|
14
|
+
}, [a]), o.useEffect(() => {
|
|
15
15
|
var e;
|
|
16
|
-
(e =
|
|
17
|
-
}, [n]),
|
|
16
|
+
(e = t.current) == null || e.setOptions(n ?? {});
|
|
17
|
+
}, [n]), o.useEffect(() => {
|
|
18
18
|
var e;
|
|
19
|
-
(e =
|
|
20
|
-
}, [l]),
|
|
19
|
+
(e = t.current) == null || e.setCallbacks(l ?? {});
|
|
20
|
+
}, [l]), o.useImperativeHandle(
|
|
21
21
|
c,
|
|
22
22
|
() => {
|
|
23
23
|
const e = () => {
|
|
24
|
-
const r =
|
|
24
|
+
const r = t.current;
|
|
25
25
|
if (!r)
|
|
26
26
|
throw new Error("GCodeViewer is not ready.");
|
|
27
27
|
return r;
|
|
@@ -99,41 +99,43 @@ const C = t.forwardRef(
|
|
|
99
99
|
};
|
|
100
100
|
},
|
|
101
101
|
[a]
|
|
102
|
-
),
|
|
102
|
+
), o.createElement("div", { ref: i, className: m, style: d });
|
|
103
103
|
}
|
|
104
|
-
), G =
|
|
104
|
+
), G = o.forwardRef(
|
|
105
105
|
function(u, c) {
|
|
106
|
-
const { id: a, options: n, className: l, style: m } = u, d =
|
|
107
|
-
return
|
|
108
|
-
const
|
|
109
|
-
if (!
|
|
110
|
-
const e = new w(
|
|
106
|
+
const { id: a, options: n, className: l, style: m } = u, d = o.useRef(null), i = o.useRef(null);
|
|
107
|
+
return o.useEffect(() => {
|
|
108
|
+
const t = d.current;
|
|
109
|
+
if (!t) return;
|
|
110
|
+
const e = new w(t, n);
|
|
111
111
|
return i.current = e, () => {
|
|
112
112
|
i.current = null, e.dispose();
|
|
113
113
|
};
|
|
114
|
-
}, []),
|
|
115
|
-
var
|
|
116
|
-
n && ((
|
|
117
|
-
}, [n]),
|
|
118
|
-
const
|
|
114
|
+
}, []), o.useEffect(() => {
|
|
115
|
+
var t;
|
|
116
|
+
n && ((t = i.current) == null || t.setOptions(n));
|
|
117
|
+
}, [n]), o.useImperativeHandle(c, () => {
|
|
118
|
+
const t = () => {
|
|
119
119
|
const e = i.current;
|
|
120
120
|
if (!e) throw new Error("GCodeSVGRenderer is not ready.");
|
|
121
121
|
return e;
|
|
122
122
|
};
|
|
123
123
|
return {
|
|
124
|
-
loadFromLines: (e) =>
|
|
125
|
-
loadFromFile: (e) =>
|
|
126
|
-
loadFromText: (e) =>
|
|
127
|
-
loadFromWorkerData: (e) =>
|
|
128
|
-
loadFromPrecomputedGroups: (e) =>
|
|
129
|
-
clear: () =>
|
|
130
|
-
resetView: () =>
|
|
131
|
-
setOptions: (e) =>
|
|
132
|
-
setProjectionMode: (e) =>
|
|
133
|
-
|
|
134
|
-
|
|
124
|
+
loadFromLines: (e) => t().loadFromLines(e),
|
|
125
|
+
loadFromFile: (e) => t().loadFromFile(e),
|
|
126
|
+
loadFromText: (e) => t().loadFromText(e),
|
|
127
|
+
loadFromWorkerData: (e) => t().loadFromWorkerData(e),
|
|
128
|
+
loadFromPrecomputedGroups: (e) => t().loadFromPrecomputedGroups(e),
|
|
129
|
+
clear: () => t().clear(),
|
|
130
|
+
resetView: () => t().resetView(),
|
|
131
|
+
setOptions: (e) => t().setOptions(e),
|
|
132
|
+
setProjectionMode: (e) => t().setProjectionMode(e),
|
|
133
|
+
setBitPosition: (e) => t().setBitPosition(e),
|
|
134
|
+
setBitVisible: (e) => t().setBitVisible(e),
|
|
135
|
+
getSVGElement: () => t().getSVGElement(),
|
|
136
|
+
dispose: () => t().dispose()
|
|
135
137
|
};
|
|
136
|
-
}, []),
|
|
138
|
+
}, []), o.createElement("div", {
|
|
137
139
|
ref: d,
|
|
138
140
|
className: l,
|
|
139
141
|
style: { width: "100%", height: "100%", ...m }
|
|
@@ -16,6 +16,12 @@ export type GCodeSVGRendererHandle = {
|
|
|
16
16
|
resetView(): void;
|
|
17
17
|
setOptions(opts: Partial<GCodeSVGOptions>): void;
|
|
18
18
|
setProjectionMode(mode: 'perspective' | 'isometric'): void;
|
|
19
|
+
setBitPosition(pos: {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
z: number;
|
|
23
|
+
}): void;
|
|
24
|
+
setBitVisible(visible: boolean): void;
|
|
19
25
|
getSVGElement(): SVGSVGElement;
|
|
20
26
|
dispose(): void;
|
|
21
27
|
};
|
|
@@ -8,6 +8,9 @@ export declare class GCodeSVGRenderer {
|
|
|
8
8
|
private bboxLabelZ;
|
|
9
9
|
private pathLayer;
|
|
10
10
|
private originMarker;
|
|
11
|
+
private crosshairEl;
|
|
12
|
+
private crosshairPos;
|
|
13
|
+
private crosshairVisible;
|
|
11
14
|
private pathEls;
|
|
12
15
|
private segmentGroups;
|
|
13
16
|
private workerMode;
|
|
@@ -48,6 +51,12 @@ export declare class GCodeSVGRenderer {
|
|
|
48
51
|
setOptions(opts: Partial<GCodeSVGOptions>): void;
|
|
49
52
|
setProjectionMode(mode: 'perspective' | 'isometric'): void;
|
|
50
53
|
getSVGElement(): SVGSVGElement;
|
|
54
|
+
setBitPosition(pos: {
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
z: number;
|
|
58
|
+
}): void;
|
|
59
|
+
setBitVisible(visible: boolean): void;
|
|
51
60
|
dispose(): void;
|
|
52
61
|
private updateTrig;
|
|
53
62
|
private project;
|
|
@@ -58,6 +67,7 @@ export declare class GCodeSVGRenderer {
|
|
|
58
67
|
private applyOptions;
|
|
59
68
|
private renderBbox;
|
|
60
69
|
private renderOriginMarker;
|
|
70
|
+
private renderCrosshairMarker;
|
|
61
71
|
private onWheel;
|
|
62
72
|
private onPointerDown;
|
|
63
73
|
private onPointerMove;
|
|
@@ -21,7 +21,7 @@ export type GCodeViewerTheme = {
|
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
-
export type GCodeViewerBitType = "circle" | "triangle" | "drill" | "laser";
|
|
24
|
+
export type GCodeViewerBitType = "circle" | "triangle" | "drill" | "laser" | "crosshair";
|
|
25
25
|
export type GCodeViewerBitPosition = {
|
|
26
26
|
x: number;
|
|
27
27
|
y: 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-BTecOJPu.cjs"),a={dark:{background:"#111827",opacity:.9,rapidOpacity:.3,colors:{rapid:"#0ef6ae",cutting:"#3e85c7",laser:"#a855f7",processed:"#6b7280",boundingBox:"#77a9d7",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:"#5191cc",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:"#da702c",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:"#73daca",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:"#076678",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:"#95E6CB",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",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