@sienci/gviewer 0.1.6 → 0.1.8

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/react.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("react"),F=require("./GCodeSVGRenderer-hZ8tZwov.cjs");function w(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=w(V),G=o.forwardRef(function(u,s){const{id:i,options:a,callbacks:c,className:m,style:f}=u,d=o.useRef(null),t=o.useRef(null);return o.useEffect(()=>{const e=d.current;if(!e)return;const p=new F.GCodeViewer({id:i,container:e,options:a,callbacks:c});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(c??{})},[c]),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:d,className:m,style:f})}),C=o.forwardRef(function(u,s){const{id:i,options:a,className:c,style:m}=u,f=o.useRef(null),d=o.useRef(null);return o.useEffect(()=>{const t=f.current;if(!t)return;const e=new F.GCodeSVGRenderer(t,a);return d.current=e,()=>{d.current=null,e.dispose()}},[]),o.useEffect(()=>{var t;a&&((t=d.current)==null||t.setOptions(a))},[a]),o.useImperativeHandle(s,()=>{const t=()=>{const e=d.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),loadFromPrecomputedGroups:e=>t().loadFromPrecomputedGroups(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:c,style:{width:"100%",height:"100%",...m}})});exports.GCodeSVGVisualizer=C;exports.GCodeVisualizer=G;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("react"),V=require("./GCodeSVGRenderer-BHrFbBpp.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 t from "react";
2
- import { a as F, G as w } from "./GCodeSVGRenderer-DUQ-WgJi.js";
3
- const C = t.forwardRef(
1
+ import * as o from "react";
2
+ import { a as F, G as w } from "./GCodeSVGRenderer-BNcU8eeP.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 = t.useRef(null), o = t.useRef(null);
6
- return t.useEffect(() => {
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 o.current = f, () => {
12
- o.current = null, f.dispose();
11
+ return t.current = f, () => {
12
+ t.current = null, f.dispose();
13
13
  };
14
- }, [a]), t.useEffect(() => {
14
+ }, [a]), o.useEffect(() => {
15
15
  var e;
16
- (e = o.current) == null || e.setOptions(n ?? {});
17
- }, [n]), t.useEffect(() => {
16
+ (e = t.current) == null || e.setOptions(n ?? {});
17
+ }, [n]), o.useEffect(() => {
18
18
  var e;
19
- (e = o.current) == null || e.setCallbacks(l ?? {});
20
- }, [l]), t.useImperativeHandle(
19
+ (e = t.current) == null || e.setCallbacks(l ?? {});
20
+ }, [l]), o.useImperativeHandle(
21
21
  c,
22
22
  () => {
23
23
  const e = () => {
24
- const r = o.current;
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
- ), t.createElement("div", { ref: i, className: m, style: d });
102
+ ), o.createElement("div", { ref: i, className: m, style: d });
103
103
  }
104
- ), G = t.forwardRef(
104
+ ), G = o.forwardRef(
105
105
  function(u, c) {
106
- const { id: a, options: n, className: l, style: m } = u, d = t.useRef(null), i = t.useRef(null);
107
- return t.useEffect(() => {
108
- const o = d.current;
109
- if (!o) return;
110
- const e = new w(o, n);
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
- }, []), t.useEffect(() => {
115
- var o;
116
- n && ((o = i.current) == null || o.setOptions(n));
117
- }, [n]), t.useImperativeHandle(c, () => {
118
- const o = () => {
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) => o().loadFromLines(e),
125
- loadFromFile: (e) => o().loadFromFile(e),
126
- loadFromText: (e) => o().loadFromText(e),
127
- loadFromWorkerData: (e) => o().loadFromWorkerData(e),
128
- loadFromPrecomputedGroups: (e) => o().loadFromPrecomputedGroups(e),
129
- clear: () => o().clear(),
130
- resetView: () => o().resetView(),
131
- setOptions: (e) => o().setOptions(e),
132
- setProjectionMode: (e) => o().setProjectionMode(e),
133
- getSVGElement: () => o().getSVGElement(),
134
- dispose: () => o().dispose()
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
- }, []), t.createElement("div", {
138
+ }, []), o.createElement("div", {
137
139
  ref: d,
138
140
  className: l,
139
141
  style: { width: "100%", height: "100%", ...m }
@@ -97,3 +97,23 @@ export type WorkerSegmentGroup = {
97
97
  rgbColors: Float32Array;
98
98
  };
99
99
  export declare function buildWorkerSegmentGroups(data: WorkerGeometryData): WorkerSegmentGroup[];
100
+ export type WorkerToolpathStream = {
101
+ positions: Float32Array;
102
+ colors: Float32Array;
103
+ prefixEndVertex: Int32Array;
104
+ };
105
+ export type WorkerToolpathStreams = {
106
+ rapid: WorkerToolpathStream;
107
+ cut: WorkerToolpathStream;
108
+ };
109
+ /**
110
+ * Builds two line-ordered toolpath streams (rapid + cut) from worker geometry,
111
+ * preserving per-vertex colours and producing per-stream `prefixEndVertex`
112
+ * arrays (indexed by source line) so `hideUntilLine`/progress greying works on
113
+ * the worker-data path.
114
+ *
115
+ * Unlike `buildWorkerSegmentGroups`, segments are appended in source-line order
116
+ * (driven by `frames`) rather than grouped by colour, which is what the
117
+ * cumulative `prefixEndVertex` cursor requires.
118
+ */
119
+ export declare function buildWorkerToolpathStreams(data: WorkerGeometryData): WorkerToolpathStreams;
@@ -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;
@@ -8,5 +8,6 @@ export type GCodeSVGOptions = {
8
8
  projectionMode: 'perspective' | 'isometric';
9
9
  showOrigin: boolean;
10
10
  originColor: string;
11
+ crosshairColor: string;
11
12
  };
12
13
  export declare const defaultGCodeSVGOptions: GCodeSVGOptions;
@@ -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-hZ8tZwov.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./GCodeSVGRenderer-BHrFbBpp.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
@@ -1,4 +1,4 @@
1
- import { G as e, a as d, V as i, d as c, b as s } from "./GCodeSVGRenderer-DUQ-WgJi.js";
1
+ import { G as e, a as d, V as i, d as c, b as s } from "./GCodeSVGRenderer-BNcU8eeP.js";
2
2
  const a = {
3
3
  dark: {
4
4
  background: "#111827",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sienci/gviewer",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "GCode visualization library using Three.js",
5
5
  "repository": {
6
6
  "type": "git",