@tscircuit/pcb-viewer 1.11.10 → 1.11.12

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/index.js CHANGED
@@ -1,211 +1,8 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x + '" is not supported');
12
- });
13
- var __commonJS = (cb, mod) => function __require2() {
14
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
- };
16
2
  var __export = (target, all) => {
17
3
  for (var name in all)
18
4
  __defProp(target, name, { get: all[name], enumerable: true });
19
5
  };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") {
22
- for (let key of __getOwnPropNames(from))
23
- if (!__hasOwnProp.call(to, key) && key !== except)
24
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
- }
26
- return to;
27
- };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
36
-
37
- // node_modules/use-mouse-matrix-transform/dist/index.js
38
- var require_dist = __commonJS({
39
- "node_modules/use-mouse-matrix-transform/dist/index.js"(exports, module) {
40
- "use strict";
41
- var __defProp2 = Object.defineProperty;
42
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
43
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
44
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
45
- var __export2 = (target, all) => {
46
- for (var name in all)
47
- __defProp2(target, name, { get: all[name], enumerable: true });
48
- };
49
- var __copyProps2 = (to, from, except, desc) => {
50
- if (from && typeof from === "object" || typeof from === "function") {
51
- for (let key of __getOwnPropNames2(from))
52
- if (!__hasOwnProp2.call(to, key) && key !== except)
53
- __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
54
- }
55
- return to;
56
- };
57
- var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
58
- var src_exports = {};
59
- __export2(src_exports, {
60
- default: () => src_default,
61
- useMouseMatrixTransform: () => useMouseMatrixTransform2
62
- });
63
- module.exports = __toCommonJS(src_exports);
64
- var import_transformation_matrix12 = __require("transformation-matrix");
65
- var import_react22 = __require("react");
66
- var useMouseMatrixTransform2 = (props = {}) => {
67
- const extRef = (0, import_react22.useRef)(null);
68
- const [lastDragCancelTime, setLastDragCancelTime] = (0, import_react22.useState)(0);
69
- const outerCanvasElm = props.canvasElm ?? extRef.current;
70
- const [internalTransform, setInternalTransform] = (0, import_react22.useState)(
71
- props.initialTransform ?? (0, import_transformation_matrix12.identity)()
72
- );
73
- const [waitCounter, setWaitCounter] = (0, import_react22.useState)(0);
74
- const [extChangeCounter, incExtChangeCounter] = (0, import_react22.useReducer)((s) => s + 1, 0);
75
- const setTransform = (0, import_react22.useCallback)(
76
- (newTransform) => {
77
- if (props.onSetTransform) {
78
- props.onSetTransform(newTransform);
79
- }
80
- if (!props.transform) {
81
- setInternalTransform(newTransform);
82
- }
83
- },
84
- [props.onSetTransform, setInternalTransform]
85
- );
86
- const setTransformExt = (0, import_react22.useCallback)(
87
- (newTransform) => {
88
- setTransform(newTransform);
89
- incExtChangeCounter();
90
- },
91
- [setTransform]
92
- );
93
- const transform = props.transform ?? internalTransform;
94
- const cancelDrag = (0, import_react22.useCallback)(() => {
95
- setLastDragCancelTime(Date.now());
96
- }, []);
97
- (0, import_react22.useEffect)(() => {
98
- const canvasElm = props.canvasElm ?? extRef.current;
99
- if (canvasElm && !outerCanvasElm) {
100
- setWaitCounter(waitCounter + 1);
101
- return;
102
- }
103
- if (!canvasElm) {
104
- const timeout = setTimeout(() => {
105
- setWaitCounter(waitCounter + 1);
106
- }, 100);
107
- return () => clearTimeout(timeout);
108
- }
109
- let init_tf = props.transform ?? internalTransform;
110
- let m0 = { x: 0, y: 0 }, m1 = { x: 0, y: 0 }, md = false, mlastrel = { x: 0, y: 0 };
111
- const getMousePos = (e) => {
112
- return {
113
- x: e.pageX - canvasElm.getBoundingClientRect().left - window.scrollX,
114
- y: e.pageY - canvasElm.getBoundingClientRect().top - window.scrollY
115
- };
116
- };
117
- function handleMouseDown(e) {
118
- if (props.enabled === false)
119
- return;
120
- if (props.shouldDrag && !props.shouldDrag(e))
121
- return;
122
- m0 = getMousePos(e);
123
- if (Date.now() - lastDragCancelTime < 100)
124
- return;
125
- md = true;
126
- e.preventDefault();
127
- }
128
- function handleMouseUp(e) {
129
- if (!md || props.enabled === false)
130
- return;
131
- if (props.shouldDrag && !props.shouldDrag(e))
132
- return;
133
- m1 = getMousePos(e);
134
- const new_tf = (0, import_transformation_matrix12.compose)((0, import_transformation_matrix12.translate)(m1.x - m0.x, m1.y - m0.y), init_tf);
135
- setTransform(new_tf);
136
- init_tf = new_tf;
137
- md = false;
138
- }
139
- function handleMouseMove(e) {
140
- mlastrel = getMousePos(e);
141
- if (!md || props.enabled === false)
142
- return;
143
- if (props.shouldDrag && !props.shouldDrag(e))
144
- return;
145
- m1 = getMousePos(e);
146
- setTransform((0, import_transformation_matrix12.compose)((0, import_transformation_matrix12.translate)(m1.x - m0.x, m1.y - m0.y), init_tf));
147
- }
148
- function handleMouseWheel(e) {
149
- if (props.enabled === false)
150
- return;
151
- if (props.shouldDrag && !props.shouldDrag(e))
152
- return;
153
- const center = getMousePos(e);
154
- const new_tf = (0, import_transformation_matrix12.compose)(
155
- (0, import_transformation_matrix12.translate)(center.x, center.y),
156
- (0, import_transformation_matrix12.scale)(1 - e.deltaY / 1e3, 1 - e.deltaY / 1e3),
157
- (0, import_transformation_matrix12.translate)(-center.x, -center.y),
158
- init_tf
159
- );
160
- setTransform(new_tf);
161
- init_tf = new_tf;
162
- e.preventDefault();
163
- }
164
- function handleMouseOut(e) {
165
- if (!md)
166
- return;
167
- if (props.shouldDrag && !props.shouldDrag(e))
168
- return;
169
- if (canvasElm) {
170
- const boundingBox = canvasElm.getBoundingClientRect();
171
- if (e.clientX >= boundingBox.left + 10 && e.clientX <= boundingBox.right - 10 && e.clientY >= boundingBox.top + 10 && e.clientY <= boundingBox.bottom - 10) {
172
- return;
173
- }
174
- }
175
- md = false;
176
- m1 = getMousePos(e);
177
- const new_tf = (0, import_transformation_matrix12.compose)((0, import_transformation_matrix12.translate)(m1.x - m0.x, m1.y - m0.y), init_tf);
178
- setTransform(new_tf);
179
- init_tf = new_tf;
180
- }
181
- canvasElm.addEventListener("mousedown", handleMouseDown);
182
- canvasElm.addEventListener("mouseup", handleMouseUp);
183
- window.addEventListener("mousemove", handleMouseMove);
184
- canvasElm.addEventListener("mouseout", handleMouseOut);
185
- canvasElm.addEventListener("wheel", handleMouseWheel);
186
- return () => {
187
- canvasElm.removeEventListener("mousedown", handleMouseDown);
188
- canvasElm.removeEventListener("mouseup", handleMouseUp);
189
- window.removeEventListener("mousemove", handleMouseMove);
190
- canvasElm.removeEventListener("mouseout", handleMouseOut);
191
- canvasElm.removeEventListener("wheel", handleMouseWheel);
192
- };
193
- }, [outerCanvasElm, waitCounter, extChangeCounter, lastDragCancelTime, props.enabled, props.shouldDrag]);
194
- const applyTransformToPoint = (0, import_react22.useCallback)(
195
- (obj) => (0, import_transformation_matrix12.applyToPoint)(transform, obj),
196
- [transform]
197
- );
198
- return {
199
- ref: extRef,
200
- transform,
201
- applyTransformToPoint,
202
- setTransform: setTransformExt,
203
- cancelDrag
204
- };
205
- };
206
- var src_default = useMouseMatrixTransform2;
207
- }
208
- });
209
6
 
210
7
  // src/PCBViewer.tsx
211
8
  import { useRenderedCircuit } from "@tscircuit/core";
@@ -5616,7 +5413,7 @@ var su = (soup, options = {}) => {
5616
5413
  },
5617
5414
  update: (id, newProps) => {
5618
5415
  const elm = soup.find(
5619
- (e) => e[`${component_type}_id`] === id
5416
+ (e) => e.type === component_type && e[`${component_type}_id`] === id
5620
5417
  );
5621
5418
  if (!elm)
5622
5419
  return;
@@ -6011,7 +5808,7 @@ var ToastContainer = () => {
6011
5808
  };
6012
5809
 
6013
5810
  // src/PCBViewer.tsx
6014
- import { useEffect as useEffect11, useMemo as useMemo6, useState as useState9 } from "react";
5811
+ import { useEffect as useEffect12, useMemo as useMemo6, useState as useState10 } from "react";
6015
5812
 
6016
5813
  // node_modules/react-use/esm/misc/util.js
6017
5814
  var noop = function() {
@@ -6061,23 +5858,173 @@ var useMeasure_default = isBrowser && typeof window.ResizeObserver !== "undefine
6061
5858
  };
6062
5859
 
6063
5860
  // src/PCBViewer.tsx
6064
- var import_use_mouse_matrix_transform = __toESM(require_dist(), 1);
6065
- import { compose as compose3, scale, translate as translate4 } from "transformation-matrix";
5861
+ import { compose as compose4, scale as scale2, translate as translate5 } from "transformation-matrix";
5862
+
5863
+ // node_modules/use-mouse-matrix-transform/dist/chunk-5TGSLHOO.js
5864
+ import {
5865
+ identity,
5866
+ scale,
5867
+ translate as translate2,
5868
+ compose,
5869
+ applyToPoint as applyToPoint2
5870
+ } from "transformation-matrix";
5871
+ import { useCallback, useEffect as useEffect3, useReducer, useRef, useState as useState2 } from "react";
5872
+ var useMouseMatrixTransform = (props = {}) => {
5873
+ const extRef = useRef(null);
5874
+ const [lastDragCancelTime, setLastDragCancelTime] = useState2(0);
5875
+ const outerCanvasElm = props.canvasElm ?? extRef.current;
5876
+ const [internalTransform, setInternalTransform] = useState2(
5877
+ props.initialTransform ?? identity()
5878
+ );
5879
+ const [waitCounter, setWaitCounter] = useState2(0);
5880
+ const [extChangeCounter, incExtChangeCounter] = useReducer((s) => s + 1, 0);
5881
+ const setTransform = useCallback(
5882
+ (newTransform) => {
5883
+ if (props.onSetTransform) {
5884
+ props.onSetTransform(newTransform);
5885
+ }
5886
+ if (!props.transform) {
5887
+ setInternalTransform(newTransform);
5888
+ }
5889
+ },
5890
+ [props.onSetTransform, setInternalTransform]
5891
+ );
5892
+ const setTransformExt = useCallback(
5893
+ (newTransform) => {
5894
+ setTransform(newTransform);
5895
+ incExtChangeCounter();
5896
+ },
5897
+ [setTransform]
5898
+ );
5899
+ const transform = props.transform ?? internalTransform;
5900
+ const cancelDrag = useCallback(() => {
5901
+ setLastDragCancelTime(Date.now());
5902
+ }, []);
5903
+ useEffect3(() => {
5904
+ const canvasElm = props.canvasElm ?? extRef.current;
5905
+ if (canvasElm && !outerCanvasElm) {
5906
+ setWaitCounter(waitCounter + 1);
5907
+ return;
5908
+ }
5909
+ if (!canvasElm) {
5910
+ const timeout = setTimeout(() => {
5911
+ setWaitCounter(waitCounter + 1);
5912
+ }, 100);
5913
+ return () => clearTimeout(timeout);
5914
+ }
5915
+ let init_tf = props.transform ?? internalTransform;
5916
+ let m0 = { x: 0, y: 0 }, m1 = { x: 0, y: 0 }, md = false, mlastrel = { x: 0, y: 0 };
5917
+ const getMousePos = (e) => {
5918
+ return {
5919
+ x: e.pageX - canvasElm.getBoundingClientRect().left - window.scrollX,
5920
+ y: e.pageY - canvasElm.getBoundingClientRect().top - window.scrollY
5921
+ };
5922
+ };
5923
+ function handleMouseDown(e) {
5924
+ if (props.enabled === false)
5925
+ return;
5926
+ if (props.shouldDrag && !props.shouldDrag(e))
5927
+ return;
5928
+ m0 = getMousePos(e);
5929
+ if (Date.now() - lastDragCancelTime < 100)
5930
+ return;
5931
+ md = true;
5932
+ e.preventDefault();
5933
+ }
5934
+ function handleMouseUp(e) {
5935
+ if (!md || props.enabled === false)
5936
+ return;
5937
+ if (props.shouldDrag && !props.shouldDrag(e))
5938
+ return;
5939
+ m1 = getMousePos(e);
5940
+ const new_tf = compose(translate2(m1.x - m0.x, m1.y - m0.y), init_tf);
5941
+ setTransform(new_tf);
5942
+ init_tf = new_tf;
5943
+ md = false;
5944
+ }
5945
+ function handleMouseMove(e) {
5946
+ mlastrel = getMousePos(e);
5947
+ if (!md || props.enabled === false)
5948
+ return;
5949
+ if (props.shouldDrag && !props.shouldDrag(e))
5950
+ return;
5951
+ m1 = getMousePos(e);
5952
+ setTransform(compose(translate2(m1.x - m0.x, m1.y - m0.y), init_tf));
5953
+ }
5954
+ function handleMouseWheel(e) {
5955
+ if (props.enabled === false)
5956
+ return;
5957
+ if (props.shouldDrag && !props.shouldDrag(e))
5958
+ return;
5959
+ const center = getMousePos(e);
5960
+ const new_tf = compose(
5961
+ translate2(center.x, center.y),
5962
+ scale(1 - e.deltaY / 1e3, 1 - e.deltaY / 1e3),
5963
+ translate2(-center.x, -center.y),
5964
+ init_tf
5965
+ );
5966
+ setTransform(new_tf);
5967
+ init_tf = new_tf;
5968
+ e.preventDefault();
5969
+ }
5970
+ function handleMouseOut(e) {
5971
+ if (!md)
5972
+ return;
5973
+ if (props.shouldDrag && !props.shouldDrag(e))
5974
+ return;
5975
+ if (canvasElm) {
5976
+ const boundingBox = canvasElm.getBoundingClientRect();
5977
+ if (e.clientX >= boundingBox.left + 10 && e.clientX <= boundingBox.right - 10 && e.clientY >= boundingBox.top + 10 && e.clientY <= boundingBox.bottom - 10) {
5978
+ return;
5979
+ }
5980
+ }
5981
+ md = false;
5982
+ m1 = getMousePos(e);
5983
+ const new_tf = compose(translate2(m1.x - m0.x, m1.y - m0.y), init_tf);
5984
+ setTransform(new_tf);
5985
+ init_tf = new_tf;
5986
+ }
5987
+ canvasElm.addEventListener("mousedown", handleMouseDown);
5988
+ canvasElm.addEventListener("mouseup", handleMouseUp);
5989
+ window.addEventListener("mousemove", handleMouseMove);
5990
+ canvasElm.addEventListener("mouseout", handleMouseOut);
5991
+ canvasElm.addEventListener("wheel", handleMouseWheel);
5992
+ return () => {
5993
+ canvasElm.removeEventListener("mousedown", handleMouseDown);
5994
+ canvasElm.removeEventListener("mouseup", handleMouseUp);
5995
+ window.removeEventListener("mousemove", handleMouseMove);
5996
+ canvasElm.removeEventListener("mouseout", handleMouseOut);
5997
+ canvasElm.removeEventListener("wheel", handleMouseWheel);
5998
+ };
5999
+ }, [outerCanvasElm, waitCounter, extChangeCounter, lastDragCancelTime, props.enabled, props.shouldDrag]);
6000
+ const applyTransformToPoint = useCallback(
6001
+ (obj) => applyToPoint2(transform, obj),
6002
+ [transform]
6003
+ );
6004
+ return {
6005
+ ref: extRef,
6006
+ transform,
6007
+ applyTransformToPoint,
6008
+ setTransform: setTransformExt,
6009
+ cancelDrag
6010
+ };
6011
+ };
6012
+ var src_default = useMouseMatrixTransform;
6066
6013
 
6067
6014
  // src/components/CanvasElementsRenderer.tsx
6068
- import { useState as useState8 } from "react";
6015
+ import { useState as useState9 } from "react";
6069
6016
 
6070
6017
  // src/components/CanvasPrimitiveRenderer.tsx
6071
6018
  import { SuperGrid, toMMSI } from "react-supergrid";
6072
- import { useEffect as useEffect3, useRef } from "react";
6019
+ import { useEffect as useEffect4, useRef as useRef2 } from "react";
6073
6020
 
6074
6021
  // src/lib/Drawer.ts
6075
6022
  import {
6076
- applyToPoint as applyToPoint2,
6077
- compose,
6078
- identity,
6023
+ applyToPoint as applyToPoint3,
6024
+ compose as compose2,
6025
+ identity as identity2,
6079
6026
  inverse,
6080
- translate as translate2
6027
+ translate as translate3
6081
6028
  } from "transformation-matrix";
6082
6029
 
6083
6030
  // src/lib/colors.ts
@@ -6386,9 +6333,9 @@ var Drawer = class {
6386
6333
  canvas.getContext("2d")
6387
6334
  ])
6388
6335
  );
6389
- this.transform = identity();
6336
+ this.transform = identity2();
6390
6337
  this.transform.d *= -1;
6391
- this.transform = compose(this.transform, translate2(0, -500));
6338
+ this.transform = compose2(this.transform, translate3(0, -500));
6392
6339
  this.lastPoint = { x: 0, y: 0 };
6393
6340
  this.equip({});
6394
6341
  }
@@ -6411,8 +6358,8 @@ var Drawer = class {
6411
6358
  }
6412
6359
  drawMeshPattern(x, y, width, height, spacing, angle = 45) {
6413
6360
  const ctx = this.getLayerCtx();
6414
- const [x1, y1] = applyToPoint2(this.transform, [x, y]);
6415
- const [x2, y2] = applyToPoint2(this.transform, [x + width, y + height]);
6361
+ const [x1, y1] = applyToPoint3(this.transform, [x, y]);
6362
+ const [x2, y2] = applyToPoint3(this.transform, [x + width, y + height]);
6416
6363
  const spacing$ = scaleOnly(this.transform, spacing);
6417
6364
  ctx.lineWidth = 1;
6418
6365
  ctx.strokeStyle = this.aperture.color;
@@ -6431,8 +6378,8 @@ var Drawer = class {
6431
6378
  drawLines((angle + 90) * Math.PI / 180);
6432
6379
  }
6433
6380
  rect(x, y, w, h, mesh_fill) {
6434
- const [x1$, y1$] = applyToPoint2(this.transform, [x - w / 2, y - h / 2]);
6435
- const [x2$, y2$] = applyToPoint2(this.transform, [x + w / 2, y + h / 2]);
6381
+ const [x1$, y1$] = applyToPoint3(this.transform, [x - w / 2, y - h / 2]);
6382
+ const [x2$, y2$] = applyToPoint3(this.transform, [x + w / 2, y + h / 2]);
6436
6383
  this.applyAperture();
6437
6384
  const ctx = this.getLayerCtx();
6438
6385
  if (mesh_fill) {
@@ -6450,10 +6397,10 @@ var Drawer = class {
6450
6397
  rotatedRect(x, y, w, h, ccw_rotation, mesh_fill) {
6451
6398
  const ctx = this.getLayerCtx();
6452
6399
  this.applyAperture();
6453
- const [x1$, y1$] = applyToPoint2(this.transform, [x - w / 2, y - h / 2]);
6454
- const [x2$, y2$] = applyToPoint2(this.transform, [x + w / 2, y + h / 2]);
6400
+ const [x1$, y1$] = applyToPoint3(this.transform, [x - w / 2, y - h / 2]);
6401
+ const [x2$, y2$] = applyToPoint3(this.transform, [x + w / 2, y + h / 2]);
6455
6402
  ctx.save();
6456
- const [centerX, centerY] = applyToPoint2(this.transform, [x, y]);
6403
+ const [centerX, centerY] = applyToPoint3(this.transform, [x, y]);
6457
6404
  ctx.translate(centerX, centerY);
6458
6405
  const cw_rotation = 360 - ccw_rotation;
6459
6406
  if (ccw_rotation) ctx.rotate(cw_rotation * Math.PI / 180);
@@ -6471,7 +6418,7 @@ var Drawer = class {
6471
6418
  }
6472
6419
  circle(x, y, r, mesh_fill) {
6473
6420
  const r$ = scaleOnly(this.transform, r);
6474
- const [x$, y$] = applyToPoint2(this.transform, [x, y]);
6421
+ const [x$, y$] = applyToPoint3(this.transform, [x, y]);
6475
6422
  this.applyAperture();
6476
6423
  const ctx = this.getLayerCtx();
6477
6424
  if (mesh_fill) {
@@ -6493,7 +6440,7 @@ var Drawer = class {
6493
6440
  oval(x, y, rx, ry) {
6494
6441
  const rx$ = scaleOnly(this.transform, rx);
6495
6442
  const ry$ = scaleOnly(this.transform, ry);
6496
- const [x$, y$] = applyToPoint2(this.transform, [x, y]);
6443
+ const [x$, y$] = applyToPoint3(this.transform, [x, y]);
6497
6444
  this.applyAperture();
6498
6445
  const ctx = this.getLayerCtx();
6499
6446
  ctx.beginPath();
@@ -6502,7 +6449,7 @@ var Drawer = class {
6502
6449
  ctx.closePath();
6503
6450
  }
6504
6451
  pill(x, y, w, h) {
6505
- const [x$, y$] = applyToPoint2(this.transform, [x - w / 2, y + h / 2]);
6452
+ const [x$, y$] = applyToPoint3(this.transform, [x - w / 2, y + h / 2]);
6506
6453
  const width$ = scaleOnly(this.transform, w);
6507
6454
  const height$ = scaleOnly(this.transform, h);
6508
6455
  const radius = Math.min(width$, height$) / 2;
@@ -6529,7 +6476,7 @@ var Drawer = class {
6529
6476
  this.applyAperture();
6530
6477
  const ctx = this.getLayerCtx();
6531
6478
  const transformedPoints = points.map(
6532
- (point2) => applyToPoint2(this.transform, [point2.x, point2.y])
6479
+ (point2) => applyToPoint3(this.transform, [point2.x, point2.y])
6533
6480
  );
6534
6481
  ctx.beginPath();
6535
6482
  ctx.moveTo(transformedPoints[0][0], transformedPoints[0][1]);
@@ -6544,7 +6491,7 @@ var Drawer = class {
6544
6491
  }
6545
6492
  /* NOTE: This is not gerber compatible */
6546
6493
  debugText(text, x, y) {
6547
- const [x$, y$] = applyToPoint2(this.transform, [x, y]);
6494
+ const [x$, y$] = applyToPoint3(this.transform, [x, y]);
6548
6495
  this.applyAperture();
6549
6496
  const ctx = this.getLayerCtx();
6550
6497
  ctx.font = `10px sans-serif`;
@@ -6609,11 +6556,11 @@ var Drawer = class {
6609
6556
  this.lastPoint = { x, y };
6610
6557
  }
6611
6558
  lineTo(x, y) {
6612
- const [x$, y$] = applyToPoint2(this.transform, [x, y]);
6559
+ const [x$, y$] = applyToPoint3(this.transform, [x, y]);
6613
6560
  const { size: size2, shape, mode } = this.aperture;
6614
6561
  const size$ = scaleOnly(this.transform, size2);
6615
6562
  let { lastPoint } = this;
6616
- const lastPoint$ = applyToPoint2(this.transform, lastPoint);
6563
+ const lastPoint$ = applyToPoint3(this.transform, lastPoint);
6617
6564
  this.applyAperture();
6618
6565
  const ctx = this.getLayerCtx();
6619
6566
  if (shape === "square")
@@ -6635,24 +6582,24 @@ var Drawer = class {
6635
6582
  };
6636
6583
 
6637
6584
  // src/lib/util/rotate-text.ts
6638
- import { compose as compose2, translate as translate3, rotate, applyToPoint as applyToPoint3 } from "transformation-matrix";
6585
+ import { compose as compose3, translate as translate4, rotate, applyToPoint as applyToPoint4 } from "transformation-matrix";
6639
6586
  function rotateText(rotateTextParams) {
6640
6587
  const { lines, anchorPoint, ccwRotation } = rotateTextParams;
6641
6588
  if (!ccwRotation) return lines;
6642
6589
  const rad = ccwRotation * Math.PI / 180;
6643
6590
  const rotationMatrix = rotate(rad);
6644
- const transform = compose2(
6645
- translate3(anchorPoint.x, anchorPoint.y),
6591
+ const transform = compose3(
6592
+ translate4(anchorPoint.x, anchorPoint.y),
6646
6593
  rotationMatrix,
6647
- translate3(-anchorPoint.x, -anchorPoint.y)
6594
+ translate4(-anchorPoint.x, -anchorPoint.y)
6648
6595
  );
6649
- applyToPoint3(transform, anchorPoint);
6596
+ applyToPoint4(transform, anchorPoint);
6650
6597
  return lines.map((line) => ({
6651
6598
  ...line,
6652
- x1: applyToPoint3(transform, { x: line.x1, y: line.y1 }).x,
6653
- y1: applyToPoint3(transform, { x: line.x1, y: line.y1 }).y,
6654
- x2: applyToPoint3(transform, { x: line.x2, y: line.y2 }).x,
6655
- y2: applyToPoint3(transform, { x: line.x2, y: line.y2 }).y
6599
+ x1: applyToPoint4(transform, { x: line.x1, y: line.y1 }).x,
6600
+ y1: applyToPoint4(transform, { x: line.x1, y: line.y1 }).y,
6601
+ x2: applyToPoint4(transform, { x: line.x2, y: line.y2 }).x,
6602
+ y2: applyToPoint4(transform, { x: line.x2, y: line.y2 }).y
6656
6603
  }));
6657
6604
  }
6658
6605
 
@@ -6904,9 +6851,9 @@ var CanvasPrimitiveRenderer = ({
6904
6851
  width = 500,
6905
6852
  height = 500
6906
6853
  }) => {
6907
- const canvasRefs = useRef();
6854
+ const canvasRefs = useRef2();
6908
6855
  const selectedLayer = useGlobalStore((s) => s.selected_layer);
6909
- useEffect3(() => {
6856
+ useEffect4(() => {
6910
6857
  if (!canvasRefs.current) return;
6911
6858
  if (Object.keys(canvasRefs.current).length === 0) return;
6912
6859
  const drawer = new Drawer(canvasRefs.current);
@@ -7017,16 +6964,16 @@ function getExpandedStroke(strokeInput, defaultWidth) {
7017
6964
  addPoint(current2, normalPrev, -1, currentWidth);
7018
6965
  addPoint(current2, normalNext, -1, currentWidth);
7019
6966
  } else {
7020
- const scale2 = 1 / miterLength;
6967
+ const scale3 = 1 / miterLength;
7021
6968
  addPoint(
7022
6969
  current2,
7023
- { x: miterX * scale2, y: miterY * scale2 },
6970
+ { x: miterX * scale3, y: miterY * scale3 },
7024
6971
  1,
7025
6972
  currentWidth
7026
6973
  );
7027
6974
  addPoint(
7028
6975
  current2,
7029
- { x: miterX * scale2, y: miterY * scale2 },
6976
+ { x: miterX * scale3, y: miterY * scale3 },
7030
6977
  -1,
7031
6978
  currentWidth
7032
6979
  );
@@ -7544,12 +7491,12 @@ var convertElementToPrimitives = (element, allElements) => {
7544
7491
  };
7545
7492
 
7546
7493
  // src/components/MouseElementTracker.tsx
7547
- import { useState as useState3 } from "react";
7494
+ import { useState as useState4 } from "react";
7548
7495
  import { useMemo as useMemo3 } from "react";
7549
- import { applyToPoint as applyToPoint4, inverse as inverse2 } from "transformation-matrix";
7496
+ import { applyToPoint as applyToPoint5, inverse as inverse2 } from "transformation-matrix";
7550
7497
 
7551
7498
  // src/components/ElementOverlayBox.tsx
7552
- import { useEffect as useEffect4, useState as useState2 } from "react";
7499
+ import { useEffect as useEffect5, useState as useState3 } from "react";
7553
7500
 
7554
7501
  // src/lib/get-trace-overlay-text.ts
7555
7502
  function getTraceOverlayInfo({
@@ -7660,9 +7607,9 @@ var HighlightedPrimitiveBoxWithText = ({
7660
7607
  mousePos,
7661
7608
  elements
7662
7609
  }) => {
7663
- const [finalState, setFinalState] = useState2(false);
7610
+ const [finalState, setFinalState] = useState3(false);
7664
7611
  const primitiveElement = primitive._element;
7665
- useEffect4(() => {
7612
+ useEffect5(() => {
7666
7613
  setTimeout(() => {
7667
7614
  setFinalState(true);
7668
7615
  }, 100);
@@ -7824,15 +7771,15 @@ var MouseElementTracker = ({
7824
7771
  primitives,
7825
7772
  onMouseHoverOverPrimitives
7826
7773
  }) => {
7827
- const [mousedPrimitives, setMousedPrimitives] = useState3([]);
7828
- const [mousePos, setMousePos] = useState3({ x: 0, y: 0 });
7774
+ const [mousedPrimitives, setMousedPrimitives] = useState4([]);
7775
+ const [mousePos, setMousePos] = useState4({ x: 0, y: 0 });
7829
7776
  const highlightedPrimitives = useMemo3(() => {
7830
7777
  const highlightedPrimitives2 = [];
7831
7778
  for (const primitive of mousedPrimitives) {
7832
7779
  if (primitive._element?.type === "pcb_via") continue;
7833
7780
  if (primitive._element?.type === "pcb_component") continue;
7834
7781
  if (primitive?.layer === "drill") continue;
7835
- const screenPos = applyToPoint4(
7782
+ const screenPos = applyToPoint5(
7836
7783
  transform,
7837
7784
  primitive
7838
7785
  );
@@ -7866,7 +7813,7 @@ var MouseElementTracker = ({
7866
7813
  const x = e.clientX - rect.left;
7867
7814
  const y = e.clientY - rect.top;
7868
7815
  setMousePos({ x, y });
7869
- const rwPoint = applyToPoint4(inverse2(transform), { x, y });
7816
+ const rwPoint = applyToPoint5(inverse2(transform), { x, y });
7870
7817
  const newMousedPrimitives = [];
7871
7818
  for (const primitive of primitives) {
7872
7819
  if (!primitive._element) continue;
@@ -7924,20 +7871,20 @@ var MouseElementTracker = ({
7924
7871
  };
7925
7872
 
7926
7873
  // src/components/DimensionOverlay.tsx
7927
- import { useEffect as useEffect5, useRef as useRef2, useState as useState4 } from "react";
7928
- import { applyToPoint as applyToPoint5, identity as identity2, inverse as inverse3 } from "transformation-matrix";
7874
+ import { useEffect as useEffect6, useRef as useRef3, useState as useState5 } from "react";
7875
+ import { applyToPoint as applyToPoint6, identity as identity3, inverse as inverse3 } from "transformation-matrix";
7929
7876
  import { Fragment, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
7930
7877
  var DimensionOverlay = ({ children, transform }) => {
7931
- if (!transform) transform = identity2();
7932
- const [dimensionToolVisible, setDimensionToolVisible] = useState4(false);
7933
- const [dimensionToolStretching, setDimensionToolStretching] = useState4(false);
7934
- const [dStart, setDStart] = useState4({ x: 0, y: 0 });
7935
- const [dEnd, setDEnd] = useState4({ x: 0, y: 0 });
7936
- const mousePosRef = useRef2({ x: 0, y: 0 });
7937
- const containerRef = useRef2(null);
7878
+ if (!transform) transform = identity3();
7879
+ const [dimensionToolVisible, setDimensionToolVisible] = useState5(false);
7880
+ const [dimensionToolStretching, setDimensionToolStretching] = useState5(false);
7881
+ const [dStart, setDStart] = useState5({ x: 0, y: 0 });
7882
+ const [dEnd, setDEnd] = useState5({ x: 0, y: 0 });
7883
+ const mousePosRef = useRef3({ x: 0, y: 0 });
7884
+ const containerRef = useRef3(null);
7938
7885
  const container = containerRef.current;
7939
7886
  const containerBounds = container?.getBoundingClientRect();
7940
- useEffect5(() => {
7887
+ useEffect6(() => {
7941
7888
  const container2 = containerRef.current;
7942
7889
  const down = (e) => {
7943
7890
  if (e.key === "d") {
@@ -7977,8 +7924,8 @@ var DimensionOverlay = ({ children, transform }) => {
7977
7924
  }
7978
7925
  };
7979
7926
  }, [containerRef]);
7980
- const screenDStart = applyToPoint5(transform, dStart);
7981
- const screenDEnd = applyToPoint5(transform, dEnd);
7927
+ const screenDStart = applyToPoint6(transform, dStart);
7928
+ const screenDEnd = applyToPoint6(transform, dEnd);
7982
7929
  const arrowScreenBounds = {
7983
7930
  left: Math.min(screenDStart.x, screenDEnd.x),
7984
7931
  right: Math.max(screenDStart.x, screenDEnd.x),
@@ -8011,7 +7958,7 @@ var DimensionOverlay = ({ children, transform }) => {
8011
7958
  const rect = e.currentTarget.getBoundingClientRect();
8012
7959
  const x = e.clientX - rect.left;
8013
7960
  const y = e.clientY - rect.top;
8014
- const rwPoint = applyToPoint5(inverse3(transform), { x, y });
7961
+ const rwPoint = applyToPoint6(inverse3(transform), { x, y });
8015
7962
  mousePosRef.current.x = rwPoint.x;
8016
7963
  mousePosRef.current.y = rwPoint.y;
8017
7964
  if (dimensionToolStretching) {
@@ -8186,13 +8133,13 @@ var DimensionOverlay = ({ children, transform }) => {
8186
8133
  };
8187
8134
 
8188
8135
  // src/components/ToolbarOverlay.tsx
8189
- import { Fragment as Fragment2, useState as useState5 } from "react";
8136
+ import { Fragment as Fragment2, useState as useState6 } from "react";
8190
8137
  import { css } from "@emotion/css";
8191
8138
 
8192
8139
  // package.json
8193
8140
  var package_default = {
8194
8141
  name: "@tscircuit/pcb-viewer",
8195
- version: "1.11.9",
8142
+ version: "1.11.11",
8196
8143
  main: "dist/index.js",
8197
8144
  type: "module",
8198
8145
  repository: "tscircuit/pcb-viewer",
@@ -8221,7 +8168,7 @@ var package_default = {
8221
8168
  "@tscircuit/core": "0.0.255",
8222
8169
  "@tscircuit/eagle-xml-converter": "^0.0.7",
8223
8170
  "@tscircuit/props": "^0.0.128",
8224
- "@tscircuit/soup-util": "^0.0.38",
8171
+ "@tscircuit/soup-util": "^0.0.41",
8225
8172
  "@types/color": "^3.0.6",
8226
8173
  "@types/node": "18.7.23",
8227
8174
  "@types/react": "^18.3.3",
@@ -8235,7 +8182,7 @@ var package_default = {
8235
8182
  tsup: "^8.0.2",
8236
8183
  "type-fest": "^3.0.0",
8237
8184
  typescript: "^5.4.4",
8238
- "use-mouse-matrix-transform": "^1.1.13",
8185
+ "use-mouse-matrix-transform": "^1.3.0",
8239
8186
  zod: "^3.23.5"
8240
8187
  },
8241
8188
  peerDependencies: {
@@ -8256,12 +8203,12 @@ var package_default = {
8256
8203
  };
8257
8204
 
8258
8205
  // src/hooks/useHotKey.ts
8259
- import { useEffect as useEffect6 } from "react";
8206
+ import { useEffect as useEffect7 } from "react";
8260
8207
  var useHotKey = (key, onUse) => {
8261
8208
  const isMouseOverContainer = useGlobalStore(
8262
8209
  (s) => s.is_mouse_over_container
8263
8210
  );
8264
- useEffect6(() => {
8211
+ useEffect7(() => {
8265
8212
  if (!key || typeof onUse !== "function") return;
8266
8213
  const handleKeyDown = (event) => {
8267
8214
  const keyParts = key.split("+");
@@ -8378,9 +8325,9 @@ var ToolbarOverlay = ({ children, elements }) => {
8378
8325
  const [isMouseOverContainer, setIsMouseOverContainer] = useGlobalStore(
8379
8326
  (s) => [s.is_mouse_over_container, s.setIsMouseOverContainer]
8380
8327
  );
8381
- const [isViewMenuOpen, setViewMenuOpen] = useState5(false);
8382
- const [isLayerMenuOpen, setLayerMenuOpen] = useState5(false);
8383
- const [isErrorsOpen, setErrorsOpen] = useState5(false);
8328
+ const [isViewMenuOpen, setViewMenuOpen] = useState6(false);
8329
+ const [isLayerMenuOpen, setLayerMenuOpen] = useState6(false);
8330
+ const [isErrorsOpen, setErrorsOpen] = useState6(false);
8384
8331
  const [selectedLayer, selectLayer] = useGlobalStore(
8385
8332
  (s) => [s.selected_layer, s.selectLayer]
8386
8333
  );
@@ -8622,8 +8569,8 @@ var ToolbarOverlay = ({ children, elements }) => {
8622
8569
 
8623
8570
  // src/components/ErrorOverlay.tsx
8624
8571
  import { css as css2 } from "@emotion/css";
8625
- import { useRef as useRef3 } from "react";
8626
- import { applyToPoint as applyToPoint6, identity as identity3 } from "transformation-matrix";
8572
+ import { useRef as useRef4 } from "react";
8573
+ import { applyToPoint as applyToPoint7, identity as identity4 } from "transformation-matrix";
8627
8574
  import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
8628
8575
  var ErrorSVG = ({
8629
8576
  screenPort1,
@@ -8683,8 +8630,8 @@ var ErrorSVG = ({
8683
8630
  }
8684
8631
  );
8685
8632
  var ErrorOverlay = ({ children, transform, elements }) => {
8686
- if (!transform) transform = identity3();
8687
- const containerRef = useRef3(null);
8633
+ if (!transform) transform = identity4();
8634
+ const containerRef = useRef4(null);
8688
8635
  return /* @__PURE__ */ jsxs5("div", { style: { position: "relative" }, ref: containerRef, children: [
8689
8636
  children,
8690
8637
  elements?.filter((el) => el.type === "pcb_trace_error").map((el) => {
@@ -8696,11 +8643,11 @@ var ErrorOverlay = ({ children, transform, elements }) => {
8696
8643
  (el2) => el2.type === "pcb_port" && el2.pcb_port_id === pcb_port_ids?.[1]
8697
8644
  );
8698
8645
  if (!port1 || !port2) return null;
8699
- const screenPort1 = applyToPoint6(transform, {
8646
+ const screenPort1 = applyToPoint7(transform, {
8700
8647
  x: port1.x,
8701
8648
  y: port1.y
8702
8649
  });
8703
- const screenPort2 = applyToPoint6(transform, {
8650
+ const screenPort2 = applyToPoint7(transform, {
8704
8651
  x: port2.x,
8705
8652
  y: port2.y
8706
8653
  });
@@ -8776,8 +8723,8 @@ var ErrorOverlay = ({ children, transform, elements }) => {
8776
8723
  };
8777
8724
 
8778
8725
  // src/components/EditPlacementOverlay.tsx
8779
- import { useRef as useRef4, useState as useState6 } from "react";
8780
- import { applyToPoint as applyToPoint7, identity as identity4, inverse as inverse4 } from "transformation-matrix";
8726
+ import { useRef as useRef5, useState as useState7 } from "react";
8727
+ import { applyToPoint as applyToPoint8, identity as identity5, inverse as inverse4 } from "transformation-matrix";
8781
8728
  import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
8782
8729
  var isInsideOf = (pcb_component2, point2, padding = 0) => {
8783
8730
  const halfWidth = pcb_component2.width / 2;
@@ -8797,12 +8744,12 @@ var EditPlacementOverlay = ({
8797
8744
  onCreateEditEvent,
8798
8745
  onModifyEditEvent
8799
8746
  }) => {
8800
- if (!transform) transform = identity4();
8801
- const containerRef = useRef4(null);
8802
- const [activePcbComponentId, setActivePcbComponent] = useState6(
8747
+ if (!transform) transform = identity5();
8748
+ const containerRef = useRef5(null);
8749
+ const [activePcbComponentId, setActivePcbComponent] = useState7(
8803
8750
  null
8804
8751
  );
8805
- const [dragState, setDragState] = useState6(null);
8752
+ const [dragState, setDragState] = useState7(null);
8806
8753
  const isPcbComponentActive = activePcbComponentId !== null;
8807
8754
  const in_edit_mode = useGlobalStore((s) => s.in_edit_mode);
8808
8755
  const in_move_footprint_mode = useGlobalStore((s) => s.in_move_footprint_mode);
@@ -8822,7 +8769,7 @@ var EditPlacementOverlay = ({
8822
8769
  const x = e.clientX - rect.left;
8823
8770
  const y = e.clientY - rect.top;
8824
8771
  if (isNaN(x) || isNaN(y)) return;
8825
- const rwMousePoint = applyToPoint7(inverse4(transform), { x, y });
8772
+ const rwMousePoint = applyToPoint8(inverse4(transform), { x, y });
8826
8773
  let foundActiveComponent = false;
8827
8774
  for (const e2 of soup) {
8828
8775
  if (e2.type === "pcb_component" && isInsideOf(e2, rwMousePoint, 10 / transform.a)) {
@@ -8863,7 +8810,7 @@ var EditPlacementOverlay = ({
8863
8810
  const x = e.clientX - rect.left;
8864
8811
  const y = e.clientY - rect.top;
8865
8812
  if (isNaN(x) || isNaN(y)) return;
8866
- const rwMousePoint = applyToPoint7(inverse4(transform), { x, y });
8813
+ const rwMousePoint = applyToPoint8(inverse4(transform), { x, y });
8867
8814
  setDragState({
8868
8815
  ...dragState,
8869
8816
  dragEnd: rwMousePoint
@@ -8892,7 +8839,7 @@ var EditPlacementOverlay = ({
8892
8839
  children,
8893
8840
  !disabled && soup.filter((e) => e.type === "pcb_component").map((e) => {
8894
8841
  if (!e?.center) return null;
8895
- const projectedCenter = applyToPoint7(transform, e.center);
8842
+ const projectedCenter = applyToPoint8(transform, e.center);
8896
8843
  return /* @__PURE__ */ jsx9(
8897
8844
  "div",
8898
8845
  {
@@ -8917,21 +8864,21 @@ var EditPlacementOverlay = ({
8917
8864
  };
8918
8865
 
8919
8866
  // src/components/EditTraceHintOverlay.tsx
8920
- import { Fragment as Fragment4, useEffect as useEffect10, useRef as useRef5, useState as useState7 } from "react";
8867
+ import { Fragment as Fragment4, useEffect as useEffect11, useRef as useRef6, useState as useState8 } from "react";
8921
8868
  import {
8922
- applyToPoint as applyToPoint8,
8923
- identity as identity5,
8869
+ applyToPoint as applyToPoint9,
8870
+ identity as identity6,
8924
8871
  inverse as inverse5
8925
8872
  } from "transformation-matrix";
8926
8873
 
8927
8874
  // src/components/HotkeyActionMenu.tsx
8928
8875
  import { css as css3 } from "@emotion/css";
8929
- import { useEffect as useEffect9 } from "react";
8876
+ import { useEffect as useEffect10 } from "react";
8930
8877
  import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
8931
8878
  var HotkeyActionMenu = ({
8932
8879
  hotkeys
8933
8880
  }) => {
8934
- useEffect9(() => {
8881
+ useEffect10(() => {
8935
8882
  const handleKeyDown = (event) => {
8936
8883
  hotkeys.forEach((hotkey) => {
8937
8884
  if (event.key === hotkey.key) {
@@ -9031,22 +8978,22 @@ var EditTraceHintOverlay = ({
9031
8978
  onCreateEditEvent,
9032
8979
  onModifyEditEvent
9033
8980
  }) => {
9034
- if (!transform) transform = identity5();
9035
- const containerRef = useRef5(null);
8981
+ if (!transform) transform = identity6();
8982
+ const containerRef = useRef6(null);
9036
8983
  const containerBounds = containerRef.current?.getBoundingClientRect();
9037
- const [selectedElement, setSelectedElement] = useState7(null);
8984
+ const [selectedElement, setSelectedElement] = useState8(null);
9038
8985
  const toast = useToast();
9039
- const [dragState, setDragState] = useState7(null);
9040
- const [shouldCreateAsVia, setShouldCreateAsVia] = useState7(false);
8986
+ const [dragState, setDragState] = useState8(null);
8987
+ const [shouldCreateAsVia, setShouldCreateAsVia] = useState8(false);
9041
8988
  const isElementSelected = selectedElement !== null;
9042
8989
  const in_edit_trace_mode = useGlobalStore((s) => s.in_draw_trace_mode);
9043
8990
  const disabled = disabledProp || !in_edit_trace_mode;
9044
8991
  let ogCenterScreen, dragEndScreen;
9045
8992
  if (dragState?.originalCenter && dragState?.dragEnd) {
9046
- ogCenterScreen = applyToPoint8(transform, dragState?.originalCenter);
9047
- dragEndScreen = applyToPoint8(transform, dragState?.dragEnd);
8993
+ ogCenterScreen = applyToPoint9(transform, dragState?.originalCenter);
8994
+ dragEndScreen = applyToPoint9(transform, dragState?.dragEnd);
9048
8995
  }
9049
- useEffect10(() => {
8996
+ useEffect11(() => {
9050
8997
  if (!isElementSelected) return;
9051
8998
  function keyDown(e) {
9052
8999
  if (e.key === "Escape") {
@@ -9071,7 +9018,7 @@ var EditTraceHintOverlay = ({
9071
9018
  const x = e.clientX - rect.left;
9072
9019
  const y = e.clientY - rect.top;
9073
9020
  if (isNaN(x) || isNaN(y)) return;
9074
- const rwMousePoint = applyToPoint8(inverse5(transform), { x, y });
9021
+ const rwMousePoint = applyToPoint9(inverse5(transform), { x, y });
9075
9022
  if (!isElementSelected) {
9076
9023
  for (const e2 of soup) {
9077
9024
  if (e2.type === "pcb_smtpad" && isInsideOfSmtpad(e2, rwMousePoint, 10 / transform.a) || e2.type === "pcb_plated_hole" && isInsideOfPlatedHole(e2, rwMousePoint, 10 / transform.a)) {
@@ -9114,7 +9061,7 @@ var EditTraceHintOverlay = ({
9114
9061
  const x = e.clientX - rect.left;
9115
9062
  const y = e.clientY - rect.top;
9116
9063
  if (isNaN(x) || isNaN(y)) return;
9117
- const rwMousePoint = applyToPoint8(inverse5(transform), { x, y });
9064
+ const rwMousePoint = applyToPoint9(inverse5(transform), { x, y });
9118
9065
  setDragState({
9119
9066
  ...dragState,
9120
9067
  dragEnd: rwMousePoint
@@ -9133,10 +9080,10 @@ var EditTraceHintOverlay = ({
9133
9080
  const x = e.clientX - rect.left;
9134
9081
  const y = e.clientY - rect.top;
9135
9082
  if (isNaN(x) || isNaN(y)) return;
9136
- const rwMousePoint = applyToPoint8(inverse5(transform), { x, y });
9083
+ const rwMousePoint = applyToPoint9(inverse5(transform), { x, y });
9137
9084
  if (dragState) {
9138
9085
  cancelPanDrag();
9139
- const lastPointScreen = applyToPoint8(
9086
+ const lastPointScreen = applyToPoint9(
9140
9087
  transform,
9141
9088
  dragState.editEvent.route.slice(-1)[0] ?? dragState.originalCenter
9142
9089
  );
@@ -9184,11 +9131,11 @@ var EditTraceHintOverlay = ({
9184
9131
  "path",
9185
9132
  {
9186
9133
  stroke: "red",
9187
- d: `M ${ogCenterScreen.x} ${ogCenterScreen.y} ${dragState?.editEvent.route.map((p) => applyToPoint8(transform, p)).map((p) => `L ${p.x} ${p.y}`).join(" ")} L ${dragEndScreen.x} ${dragEndScreen.y}`
9134
+ d: `M ${ogCenterScreen.x} ${ogCenterScreen.y} ${dragState?.editEvent.route.map((p) => applyToPoint9(transform, p)).map((p) => `L ${p.x} ${p.y}`).join(" ")} L ${dragEndScreen.x} ${dragEndScreen.y}`
9188
9135
  }
9189
9136
  ),
9190
9137
  dragState?.editEvent.route.map((r, i) => {
9191
- const rScreen = applyToPoint8(transform, r);
9138
+ const rScreen = applyToPoint9(transform, r);
9192
9139
  return /* @__PURE__ */ jsxs8(Fragment4, { children: [
9193
9140
  r.via && /* @__PURE__ */ jsx11("circle", { cx: rScreen.x, cy: rScreen.y, r: 16, stroke: "red" }),
9194
9141
  /* @__PURE__ */ jsx11("circle", { cx: rScreen.x, cy: rScreen.y, r: 8, stroke: "red" })
@@ -9232,7 +9179,7 @@ var EditTraceHintOverlay = ({
9232
9179
  children: soup.filter((e) => e.type === "pcb_trace_hint").map((e) => {
9233
9180
  const { route } = e;
9234
9181
  const pcb_port2 = su_default(soup).pcb_port.get(e.pcb_port_id);
9235
- const pcb_port_screen = applyToPoint8(transform, pcb_port2);
9182
+ const pcb_port_screen = applyToPoint9(transform, pcb_port2);
9236
9183
  return /* @__PURE__ */ jsxs8(Fragment4, { children: [
9237
9184
  /* @__PURE__ */ jsx11(
9238
9185
  "rect",
@@ -9249,11 +9196,11 @@ var EditTraceHintOverlay = ({
9249
9196
  "path",
9250
9197
  {
9251
9198
  stroke: "red",
9252
- d: `M ${pcb_port_screen.x} ${pcb_port_screen.y} ${route.map((r) => applyToPoint8(transform, r)).map((r) => `L ${r.x} ${r.y}`).join(" ")}`
9199
+ d: `M ${pcb_port_screen.x} ${pcb_port_screen.y} ${route.map((r) => applyToPoint9(transform, r)).map((r) => `L ${r.x} ${r.y}`).join(" ")}`
9253
9200
  },
9254
9201
  `path-${e.pcb_port_id}`
9255
9202
  ),
9256
- route.map((r) => ({ ...r, ...applyToPoint8(transform, r) })).map((r, i) => /* @__PURE__ */ jsxs8(Fragment4, { children: [
9203
+ route.map((r) => ({ ...r, ...applyToPoint9(transform, r) })).map((r, i) => /* @__PURE__ */ jsxs8(Fragment4, { children: [
9257
9204
  /* @__PURE__ */ jsx11("circle", { cx: r.x, cy: r.y, r: 8, stroke: "red" }),
9258
9205
  r.via && /* @__PURE__ */ jsx11(
9259
9206
  "circle",
@@ -9311,7 +9258,7 @@ var EditTraceHintOverlay = ({
9311
9258
  };
9312
9259
 
9313
9260
  // src/components/RatsNestOverlay.tsx
9314
- import { applyToPoint as applyToPoint9, identity as identity6 } from "transformation-matrix";
9261
+ import { applyToPoint as applyToPoint10, identity as identity7 } from "transformation-matrix";
9315
9262
  import { getFullConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map";
9316
9263
  import { useMemo as useMemo4 } from "react";
9317
9264
  import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
@@ -9377,7 +9324,7 @@ var RatsNestOverlay = ({ transform, soup, children }) => {
9377
9324
  return lines;
9378
9325
  }, [soup, netMap, idToNetMap, isShowingRatsNest]);
9379
9326
  if (!soup || !isShowingRatsNest) return children;
9380
- if (!transform) transform = identity6();
9327
+ if (!transform) transform = identity7();
9381
9328
  return /* @__PURE__ */ jsxs9("div", { style: { position: "relative" }, children: [
9382
9329
  children,
9383
9330
  /* @__PURE__ */ jsx12(
@@ -9394,8 +9341,8 @@ var RatsNestOverlay = ({ transform, soup, children }) => {
9394
9341
  zIndex: zIndexMap.ratsNestOverlay
9395
9342
  },
9396
9343
  children: ratsNestLines.map(({ key, startPoint, endPoint, isInNet }) => {
9397
- const transformedStart = applyToPoint9(transform, startPoint);
9398
- const transformedEnd = applyToPoint9(transform, endPoint);
9344
+ const transformedStart = applyToPoint10(transform, startPoint);
9345
+ const transformedEnd = applyToPoint10(transform, endPoint);
9399
9346
  return /* @__PURE__ */ jsx12(
9400
9347
  "line",
9401
9348
  {
@@ -9460,7 +9407,7 @@ var CanvasElementsRenderer = (props) => {
9460
9407
  );
9461
9408
  return [primitivesWithoutInteractionMetadata2, connectivityMap2];
9462
9409
  }, [props.elements]);
9463
- const [primitives, setPrimitives] = useState8(
9410
+ const [primitives, setPrimitives] = useState9(
9464
9411
  primitivesWithoutInteractionMetadata
9465
9412
  );
9466
9413
  return /* @__PURE__ */ jsx13(
@@ -9529,7 +9476,7 @@ var CanvasElementsRenderer = (props) => {
9529
9476
 
9530
9477
  // src/PCBViewer.tsx
9531
9478
  import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
9532
- var defaultTransform = compose3(translate4(400, 300), scale(40, -40));
9479
+ var defaultTransform = compose4(translate5(400, 300), scale2(40, -40));
9533
9480
  var PCBViewer = ({
9534
9481
  children,
9535
9482
  soup,
@@ -9548,16 +9495,16 @@ var PCBViewer = ({
9548
9495
  } = useRenderedCircuit(children);
9549
9496
  circuitJson ??= circuitJsonFromChildren ?? [];
9550
9497
  const [ref, refDimensions] = useMeasure_default();
9551
- const [transform, setTransformInternal] = useState9(defaultTransform);
9498
+ const [transform, setTransformInternal] = useState10(defaultTransform);
9552
9499
  const {
9553
9500
  ref: transformRef,
9554
9501
  setTransform,
9555
9502
  cancelDrag: cancelPanDrag
9556
- } = (0, import_use_mouse_matrix_transform.default)({
9503
+ } = src_default({
9557
9504
  transform,
9558
9505
  onSetTransform: setTransformInternal
9559
9506
  });
9560
- let [editEvents, setEditEvents] = useState9([]);
9507
+ let [editEvents, setEditEvents] = useState10([]);
9561
9508
  editEvents = editEventsProp ?? editEvents;
9562
9509
  const resetTransform = () => {
9563
9510
  const elmBounds = refDimensions?.width > 0 ? refDimensions : { width: 500, height: 500 };
@@ -9572,14 +9519,14 @@ var PCBViewer = ({
9572
9519
  100
9573
9520
  ) * 0.75;
9574
9521
  setTransform(
9575
- compose3(
9576
- translate4((elmBounds.width ?? 0) / 2, (elmBounds.height ?? 0) / 2),
9577
- scale(scaleFactor, -scaleFactor, 0, 0),
9578
- translate4(-center.x, -center.y)
9522
+ compose4(
9523
+ translate5((elmBounds.width ?? 0) / 2, (elmBounds.height ?? 0) / 2),
9524
+ scale2(scaleFactor, -scaleFactor, 0, 0),
9525
+ translate5(-center.x, -center.y)
9579
9526
  )
9580
9527
  );
9581
9528
  };
9582
- useEffect11(() => {
9529
+ useEffect12(() => {
9583
9530
  if (refDimensions && refDimensions.width !== 0 && (children || soup)) {
9584
9531
  resetTransform();
9585
9532
  }