@sienci/gviewer 0.1.0 → 0.1.2
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 +142 -3
- package/dist/{GCodeSVGRenderer-DnFLLJmH.js → GCodeSVGRenderer-B3Yor_nk.js} +568 -505
- package/dist/GCodeSVGRenderer-DGzotwOB.cjs +1 -0
- package/dist/gviewer.cjs +1 -1
- package/dist/gviewer.js +321 -296
- package/dist/react.cjs +1 -1
- package/dist/react.js +15 -11
- package/dist/types/geometry.d.ts +8 -1
- package/dist/types/react/GCodeSVGVisualizer.d.ts +2 -0
- package/dist/types/types.d.ts +8 -0
- package/dist/types/viewer/GCodeViewer.d.ts +2 -0
- package/dist/types/viewer/index.d.ts +1 -0
- package/dist/types/viewer/svg/GCodeSVGRenderer.d.ts +9 -2
- package/dist/types/viewer/svg/types.d.ts +2 -0
- package/dist/types/viewer/toolpath/streams.d.ts +1 -0
- package/dist/types/viewer/types.d.ts +2 -0
- package/dist/viewer.cjs +1 -1
- package/dist/viewer.js +1 -1
- package/package.json +1 -1
- package/dist/GCodeSVGRenderer-DaLc9_L-.cjs +0 -1
package/dist/react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),V=require("./GCodeSVGRenderer-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),V=require("./GCodeSVGRenderer-DGzotwOB.cjs");function F(l){const u=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const s in l)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(l,s);Object.defineProperty(u,s,i.get?i:{enumerable:!0,get:()=>l[s]})}}return u.default=l,Object.freeze(u)}const o=F(w),C=o.forwardRef(function(u,s){const{id:i,options:a,callbacks:d,className:m,style:f}=u,c=o.useRef(null),t=o.useRef(null);return o.useEffect(()=>{const e=c.current;if(!e)return;const p=new V.GCodeViewer({id:i,container:e,options:a,callbacks:d});return t.current=p,()=>{t.current=null,p.dispose()}},[i]),o.useEffect(()=>{var e;(e=t.current)==null||e.setOptions(a??{})},[a]),o.useEffect(()=>{var e;(e=t.current)==null||e.setCallbacks(d??{})},[d]),o.useImperativeHandle(s,()=>{const e=()=>{const r=t.current;if(!r)throw new Error("GCodeViewer is not ready.");return r};return{get id(){return i},setCallbacks(r){e().setCallbacks(r)},snapCameraToView(r,n){e().snapCameraToView(r,n)},setBitPosition(r,n){e().setBitPosition(r,n)},setBitVisible(r){e().setBitVisible(r)},setToolpathRotationA(r){e().setToolpathRotationA(r)},hideUntilLine(r,n){e().hideUntilLine(r,n)},seekToLine(r,n){e().seekToLine(r,n)},showAll(){e().showAll()},resetColors(){e().resetColors()},loadFromUrl(r,n){return e().loadFromUrl(r,n)},loadFromFile(r){return e().loadFromFile(r)},loadFromText(r){return e().loadFromText(r)},loadFromLines(r){return e().loadFromLines(r)},loadFromWorkerData(r){return e().loadFromWorkerData(r)},unload(){e().unload()},setOptions(r){e().setOptions(r)},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:c,className:m,style:f})}),G=o.forwardRef(function(u,s){const{id:i,options:a,className:d,style:m}=u,f=o.useRef(null),c=o.useRef(null);return o.useEffect(()=>{const t=f.current;if(!t)return;const e=new V.GCodeSVGRenderer(t,a);return c.current=e,()=>{c.current=null,e.dispose()}},[]),o.useEffect(()=>{var t;a&&((t=c.current)==null||t.setOptions(a))},[a]),o.useImperativeHandle(s,()=>{const t=()=>{const e=c.current;if(!e)throw new Error("GCodeSVGRenderer is not ready.");return e};return{loadFromLines:e=>t().loadFromLines(e),loadFromFile:e=>t().loadFromFile(e),loadFromText:e=>t().loadFromText(e),loadFromWorkerData:e=>t().loadFromWorkerData(e),clear:()=>t().clear(),resetView:()=>t().resetView(),setOptions:e=>t().setOptions(e),setProjectionMode:e=>t().setProjectionMode(e),getSVGElement:()=>t().getSVGElement(),dispose:()=>t().dispose()}},[]),o.createElement("div",{ref:f,className:d,style:{width:"100%",height:"100%",...m}})});exports.GCodeSVGVisualizer=G;exports.GCodeVisualizer=C;
|
package/dist/react.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import * as o from "react";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as F, G as w } from "./GCodeSVGRenderer-B3Yor_nk.js";
|
|
3
3
|
const C = o.forwardRef(
|
|
4
4
|
function(u, c) {
|
|
5
|
-
const { id:
|
|
5
|
+
const { id: a, options: n, callbacks: l, className: f, style: d } = u, 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 m = new
|
|
10
|
+
const m = new F({ id: a, container: e, options: n, callbacks: l });
|
|
11
11
|
return t.current = m, () => {
|
|
12
12
|
t.current = null, m.dispose();
|
|
13
13
|
};
|
|
14
|
-
}, [
|
|
14
|
+
}, [a]), o.useEffect(() => {
|
|
15
15
|
var e;
|
|
16
16
|
(e = t.current) == null || e.setOptions(n ?? {});
|
|
17
17
|
}, [n]), o.useEffect(() => {
|
|
18
18
|
var e;
|
|
19
|
-
(e = t.current) == null || e.setCallbacks(
|
|
20
|
-
}, [
|
|
19
|
+
(e = t.current) == null || e.setCallbacks(l ?? {});
|
|
20
|
+
}, [l]), o.useImperativeHandle(
|
|
21
21
|
c,
|
|
22
22
|
() => {
|
|
23
23
|
const e = () => {
|
|
@@ -28,7 +28,7 @@ const C = o.forwardRef(
|
|
|
28
28
|
};
|
|
29
29
|
return {
|
|
30
30
|
get id() {
|
|
31
|
-
return
|
|
31
|
+
return a;
|
|
32
32
|
},
|
|
33
33
|
setCallbacks(r) {
|
|
34
34
|
e().setCallbacks(r);
|
|
@@ -69,6 +69,9 @@ const C = o.forwardRef(
|
|
|
69
69
|
loadFromLines(r) {
|
|
70
70
|
return e().loadFromLines(r);
|
|
71
71
|
},
|
|
72
|
+
loadFromWorkerData(r) {
|
|
73
|
+
return e().loadFromWorkerData(r);
|
|
74
|
+
},
|
|
72
75
|
unload() {
|
|
73
76
|
e().unload();
|
|
74
77
|
},
|
|
@@ -95,16 +98,16 @@ const C = o.forwardRef(
|
|
|
95
98
|
}
|
|
96
99
|
};
|
|
97
100
|
},
|
|
98
|
-
[
|
|
101
|
+
[a]
|
|
99
102
|
), o.createElement("div", { ref: i, className: f, style: d });
|
|
100
103
|
}
|
|
101
104
|
), G = o.forwardRef(
|
|
102
105
|
function(u, c) {
|
|
103
|
-
const { id:
|
|
106
|
+
const { id: a, options: n, className: l, style: f } = u, d = o.useRef(null), i = o.useRef(null);
|
|
104
107
|
return o.useEffect(() => {
|
|
105
108
|
const t = d.current;
|
|
106
109
|
if (!t) return;
|
|
107
|
-
const e = new
|
|
110
|
+
const e = new w(t, n);
|
|
108
111
|
return i.current = e, () => {
|
|
109
112
|
i.current = null, e.dispose();
|
|
110
113
|
};
|
|
@@ -121,6 +124,7 @@ const C = o.forwardRef(
|
|
|
121
124
|
loadFromLines: (e) => t().loadFromLines(e),
|
|
122
125
|
loadFromFile: (e) => t().loadFromFile(e),
|
|
123
126
|
loadFromText: (e) => t().loadFromText(e),
|
|
127
|
+
loadFromWorkerData: (e) => t().loadFromWorkerData(e),
|
|
124
128
|
clear: () => t().clear(),
|
|
125
129
|
resetView: () => t().resetView(),
|
|
126
130
|
setOptions: (e) => t().setOptions(e),
|
|
@@ -130,7 +134,7 @@ const C = o.forwardRef(
|
|
|
130
134
|
};
|
|
131
135
|
}, []), o.createElement("div", {
|
|
132
136
|
ref: d,
|
|
133
|
-
className:
|
|
137
|
+
className: l,
|
|
134
138
|
style: { width: "100%", height: "100%", ...f }
|
|
135
139
|
});
|
|
136
140
|
}
|
package/dist/types/geometry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArcMoveCallback, LinearMoveCallback, Position } from "./types";
|
|
1
|
+
import { ArcMoveCallback, LinearMoveCallback, Position, WorkerGeometryData } 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;
|
|
@@ -90,3 +90,10 @@ export declare function buildLaserGeometryFromLinesBatched(lines: readonly strin
|
|
|
90
90
|
batch?: BatchBuildOptions;
|
|
91
91
|
}): Promise<LaserGeometry>;
|
|
92
92
|
export declare function pushXYZ(vertices: number[], position: Position): void;
|
|
93
|
+
export type WorkerSegmentGroup = {
|
|
94
|
+
hexColor: string;
|
|
95
|
+
opacity: number;
|
|
96
|
+
positions: Float32Array;
|
|
97
|
+
rgbColors: Float32Array;
|
|
98
|
+
};
|
|
99
|
+
export declare function buildWorkerSegmentGroups(data: WorkerGeometryData): WorkerSegmentGroup[];
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { GCodeSVGOptions } from "../viewer/svg/types";
|
|
3
|
+
import type { WorkerGeometryData } from "../types";
|
|
3
4
|
export type GCodeSVGRendererHandle = {
|
|
4
5
|
loadFromLines(lines: string[]): void;
|
|
5
6
|
loadFromFile(file: File): Promise<void>;
|
|
6
7
|
loadFromText(gcode: string): void;
|
|
8
|
+
loadFromWorkerData(data: WorkerGeometryData): void;
|
|
7
9
|
clear(): void;
|
|
8
10
|
resetView(): void;
|
|
9
11
|
setOptions(opts: Partial<GCodeSVGOptions>): void;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -69,3 +69,11 @@ export type VirtualizeResult = {
|
|
|
69
69
|
movement: "none" | "linear" | "arc";
|
|
70
70
|
arcMax?: Position;
|
|
71
71
|
};
|
|
72
|
+
export type WorkerGeometryData = {
|
|
73
|
+
vertices: ArrayBuffer;
|
|
74
|
+
frames: ArrayBuffer;
|
|
75
|
+
colorArrayBuffer: ArrayBuffer;
|
|
76
|
+
verticesLen: number;
|
|
77
|
+
framesLen: number;
|
|
78
|
+
colorLen: number;
|
|
79
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WorkerGeometryData } from "../types";
|
|
1
2
|
import { GCodeViewerCameraView, GCodeViewerBounds, GCodeViewerCallbacks, GCodeViewerCreateArgs, GCodeViewerHandle, GCodeViewerBitPosition, GCodeViewerOptions } from "./types";
|
|
2
3
|
export declare class GCodeViewer implements GCodeViewerHandle {
|
|
3
4
|
readonly id: string;
|
|
@@ -52,6 +53,7 @@ export declare class GCodeViewer implements GCodeViewerHandle {
|
|
|
52
53
|
loadFromFile(file: File): Promise<void>;
|
|
53
54
|
loadFromText(gcode: string): Promise<void>;
|
|
54
55
|
loadFromLines(lines: readonly string[]): Promise<void>;
|
|
56
|
+
loadFromWorkerData(data: WorkerGeometryData): Promise<void>;
|
|
55
57
|
unload(): void;
|
|
56
58
|
setOptions(next: Partial<GCodeViewerOptions>): void;
|
|
57
59
|
getOptions(): Readonly<GCodeViewerOptions>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WorkerGeometryData } from "../../types";
|
|
1
2
|
import { GCodeSVGOptions } from "./types";
|
|
2
3
|
export declare class GCodeSVGRenderer {
|
|
3
4
|
private svg;
|
|
@@ -5,8 +6,11 @@ export declare class GCodeSVGRenderer {
|
|
|
5
6
|
private bboxLabelX;
|
|
6
7
|
private bboxLabelY;
|
|
7
8
|
private bboxLabelZ;
|
|
8
|
-
private
|
|
9
|
-
private
|
|
9
|
+
private pathLayer;
|
|
10
|
+
private originMarker;
|
|
11
|
+
private pathEls;
|
|
12
|
+
private segmentGroups;
|
|
13
|
+
private workerMode;
|
|
10
14
|
private options;
|
|
11
15
|
private viewBox;
|
|
12
16
|
private rotX;
|
|
@@ -30,6 +34,8 @@ export declare class GCodeSVGRenderer {
|
|
|
30
34
|
loadFromFile(file: File): Promise<void>;
|
|
31
35
|
loadFromText(gcode: string): void;
|
|
32
36
|
clear(): void;
|
|
37
|
+
loadFromWorkerData(data: WorkerGeometryData): void;
|
|
38
|
+
private syncSegmentGroupsFromLines;
|
|
33
39
|
resetView(): void;
|
|
34
40
|
setOptions(opts: Partial<GCodeSVGOptions>): void;
|
|
35
41
|
setProjectionMode(mode: 'perspective' | 'isometric'): void;
|
|
@@ -43,6 +49,7 @@ export declare class GCodeSVGRenderer {
|
|
|
43
49
|
private applyViewBox;
|
|
44
50
|
private applyOptions;
|
|
45
51
|
private renderBbox;
|
|
52
|
+
private renderOriginMarker;
|
|
46
53
|
private onWheel;
|
|
47
54
|
private onPointerDown;
|
|
48
55
|
private onPointerMove;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WorkerGeometryData } from "../types";
|
|
1
2
|
export type GridUnits = "mm" | "in";
|
|
2
3
|
export type GCodeViewerTheme = {
|
|
3
4
|
background: string;
|
|
@@ -153,6 +154,7 @@ export type GCodeViewerHandle = {
|
|
|
153
154
|
loadFromFile(file: File): Promise<void>;
|
|
154
155
|
loadFromText(gcode: string): Promise<void>;
|
|
155
156
|
loadFromLines(lines: readonly string[]): Promise<void>;
|
|
157
|
+
loadFromWorkerData(data: WorkerGeometryData): Promise<void>;
|
|
156
158
|
unload(): void;
|
|
157
159
|
setOptions(next: Partial<GCodeViewerOptions>): void;
|
|
158
160
|
getOptions(): Readonly<GCodeViewerOptions>;
|
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-DGzotwOB.cjs"),a={dark:{background:"#111827",opacity:.9,rapidOpacity:.3,colors:{rapid:"#0ef6ae",cutting:"#3e85c7",laser:"#a855f7",processed:"#6b7280",boundingBox:"#77a9d7",grid:{major:"#2f3840",minor:"#1f252b"},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:"#77a9d7",minor:"#a8c6e4"},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:"#403e3c",minor:"#282726"},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:"#414868",minor:"#24283b"},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:"#d5c4a1",minor:"#ebdbb2"},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:"#242b38",minor:"#1a1f2b"},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:"#c9cacc",minor:"#e5e7ea"},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