@tscircuit/pcb-viewer 1.4.3 → 1.4.4
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.d.ts +20 -1
- package/dist/index.js +177 -73
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -33,15 +33,34 @@ type EditTraceHintEvent = {
|
|
|
33
33
|
};
|
|
34
34
|
type EditEvent = EditComponentLocationEvent | EditTraceHintEvent;
|
|
35
35
|
|
|
36
|
+
interface State {
|
|
37
|
+
selected_layer: LayerRef;
|
|
38
|
+
in_edit_mode: boolean;
|
|
39
|
+
in_move_footprint_mode: boolean;
|
|
40
|
+
in_draw_trace_mode: boolean;
|
|
41
|
+
is_moving_component: boolean;
|
|
42
|
+
is_drawing_trace: boolean;
|
|
43
|
+
is_showing_rats_nest: boolean;
|
|
44
|
+
selectLayer: (layer: LayerRef) => void;
|
|
45
|
+
setEditMode: (mode: "off" | "move_footprint" | "draw_trace") => void;
|
|
46
|
+
setIsMovingComponent: (is_moving: boolean) => void;
|
|
47
|
+
setIsDrawingTrace: (is_drawing: boolean) => void;
|
|
48
|
+
setIsShowingRatsNest: (is_showing: boolean) => void;
|
|
49
|
+
}
|
|
50
|
+
type StateProps = {
|
|
51
|
+
[key in keyof State]: State[key] extends boolean ? boolean : never;
|
|
52
|
+
};
|
|
53
|
+
|
|
36
54
|
type Props = {
|
|
37
55
|
children?: any;
|
|
38
56
|
soup?: any;
|
|
39
57
|
height?: number;
|
|
40
58
|
allowEditing?: boolean;
|
|
41
59
|
editEvents?: EditEvent[];
|
|
60
|
+
initialState?: Partial<StateProps>;
|
|
42
61
|
onEditEventsChanged?: (editEvents: EditEvent[]) => void;
|
|
43
62
|
};
|
|
44
|
-
declare const PCBViewer: ({ children, soup, height, allowEditing, editEvents: editEventsProp, onEditEventsChanged, }: Props) => react_jsx_runtime.JSX.Element;
|
|
63
|
+
declare const PCBViewer: ({ children, soup, height, initialState, allowEditing, editEvents: editEventsProp, onEditEventsChanged, }: Props) => react_jsx_runtime.JSX.Element;
|
|
45
64
|
|
|
46
65
|
declare const applyEditEvents: (soup: AnySoupElement[], edit_events: EditEvent[]) => AnySoupElement[];
|
|
47
66
|
|
package/dist/index.js
CHANGED
|
@@ -870,10 +870,10 @@ var require_lodash14 = __commonJS({
|
|
|
870
870
|
// node_modules/lodash.identity/index.js
|
|
871
871
|
var require_lodash15 = __commonJS({
|
|
872
872
|
"node_modules/lodash.identity/index.js": function(exports2, module2) {
|
|
873
|
-
function
|
|
873
|
+
function identity7(value) {
|
|
874
874
|
return value;
|
|
875
875
|
}
|
|
876
|
-
module2.exports =
|
|
876
|
+
module2.exports = identity7;
|
|
877
877
|
}
|
|
878
878
|
});
|
|
879
879
|
// node_modules/lodash.support/index.js
|
|
@@ -893,7 +893,7 @@ var require_lodash16 = __commonJS({
|
|
|
893
893
|
var require_lodash17 = __commonJS({
|
|
894
894
|
"node_modules/lodash._basecreatecallback/index.js": function(exports2, module2) {
|
|
895
895
|
var bind = require_lodash14();
|
|
896
|
-
var
|
|
896
|
+
var identity7 = require_lodash15();
|
|
897
897
|
var setBindData = require_lodash8();
|
|
898
898
|
var support = require_lodash16();
|
|
899
899
|
var reFuncName = /^\s*function[ \n\r\t]+\w/;
|
|
@@ -901,7 +901,7 @@ var require_lodash17 = __commonJS({
|
|
|
901
901
|
var fnToString = Function.prototype.toString;
|
|
902
902
|
function baseCreateCallback(func, thisArg, argCount) {
|
|
903
903
|
if (typeof func != "function") {
|
|
904
|
-
return
|
|
904
|
+
return identity7;
|
|
905
905
|
}
|
|
906
906
|
if (typeof thisArg == "undefined" || !("prototype" in func)) {
|
|
907
907
|
return func;
|
|
@@ -10918,7 +10918,7 @@ var require_dist2 = __commonJS({
|
|
|
10918
10918
|
}
|
|
10919
10919
|
});
|
|
10920
10920
|
module2.exports = __toCommonJS2(soup_util_exports);
|
|
10921
|
-
var
|
|
10921
|
+
var su5 = function(soup) {
|
|
10922
10922
|
var su22 = new Proxy({}, {
|
|
10923
10923
|
get: function(proxy_target, component_type) {
|
|
10924
10924
|
return {
|
|
@@ -10991,8 +10991,8 @@ var require_dist2 = __commonJS({
|
|
|
10991
10991
|
});
|
|
10992
10992
|
return su22;
|
|
10993
10993
|
};
|
|
10994
|
-
|
|
10995
|
-
var su_default =
|
|
10994
|
+
su5.unparsed = su5;
|
|
10995
|
+
var su_default = su5;
|
|
10996
10996
|
var directionToVec = function(direction) {
|
|
10997
10997
|
if (direction === "up") return {
|
|
10998
10998
|
x: 0,
|
|
@@ -11061,30 +11061,30 @@ var require_dist2 = __commonJS({
|
|
|
11061
11061
|
else if (sideOrDir === "right") return "left";
|
|
11062
11062
|
throw new Error("Invalid sideOrDir: ".concat(sideOrDir));
|
|
11063
11063
|
};
|
|
11064
|
-
var
|
|
11064
|
+
var import_transformation_matrix10 = require("transformation-matrix");
|
|
11065
11065
|
var transformSchematicElement = function(elm, matrix) {
|
|
11066
11066
|
if (elm.type === "schematic_component") {
|
|
11067
|
-
elm.center = (0,
|
|
11067
|
+
elm.center = (0, import_transformation_matrix10.applyToPoint)(matrix, elm.center);
|
|
11068
11068
|
} else if (elm.type === "schematic_port") {
|
|
11069
|
-
elm.center = (0,
|
|
11069
|
+
elm.center = (0, import_transformation_matrix10.applyToPoint)(matrix, elm.center);
|
|
11070
11070
|
if (elm.facing_direction) {
|
|
11071
11071
|
elm.facing_direction = rotateDirection(elm.facing_direction, -(Math.atan2(matrix.b, matrix.a) / Math.PI) * 2);
|
|
11072
11072
|
}
|
|
11073
11073
|
} else if (elm.type === "schematic_text") {
|
|
11074
|
-
elm.position = (0,
|
|
11074
|
+
elm.position = (0, import_transformation_matrix10.applyToPoint)(matrix, elm.position);
|
|
11075
11075
|
} else if (elm.type === "schematic_trace") {} else if (elm.type === "schematic_box") {
|
|
11076
|
-
var _ref = (0,
|
|
11076
|
+
var _ref = (0, import_transformation_matrix10.applyToPoint)(matrix, {
|
|
11077
11077
|
x: elm.x,
|
|
11078
11078
|
y: elm.y
|
|
11079
11079
|
}), x = _ref.x, y = _ref.y;
|
|
11080
11080
|
elm.x = x;
|
|
11081
11081
|
elm.y = y;
|
|
11082
11082
|
} else if (elm.type === "schematic_line") {
|
|
11083
|
-
var _ref1 = (0,
|
|
11083
|
+
var _ref1 = (0, import_transformation_matrix10.applyToPoint)(matrix, {
|
|
11084
11084
|
x: elm.x1,
|
|
11085
11085
|
y: elm.y1
|
|
11086
11086
|
}), x1 = _ref1.x, y1 = _ref1.y;
|
|
11087
|
-
var _ref2 = (0,
|
|
11087
|
+
var _ref2 = (0, import_transformation_matrix10.applyToPoint)(matrix, {
|
|
11088
11088
|
x: elm.x2,
|
|
11089
11089
|
y: elm.y2
|
|
11090
11090
|
}), x2 = _ref2.x, y2 = _ref2.y;
|
|
@@ -11102,19 +11102,19 @@ var require_dist2 = __commonJS({
|
|
|
11102
11102
|
};
|
|
11103
11103
|
var transformPCBElement2 = function(elm, matrix) {
|
|
11104
11104
|
if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "pcb_via" || elm.type === "pcb_smtpad" || elm.type === "pcb_port") {
|
|
11105
|
-
var _ref = (0,
|
|
11105
|
+
var _ref = (0, import_transformation_matrix10.applyToPoint)(matrix, {
|
|
11106
11106
|
x: elm.x,
|
|
11107
11107
|
y: elm.y
|
|
11108
11108
|
}), x = _ref.x, y = _ref.y;
|
|
11109
11109
|
elm.x = x;
|
|
11110
11110
|
elm.y = y;
|
|
11111
11111
|
} else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text") {
|
|
11112
|
-
elm.anchor_position = (0,
|
|
11112
|
+
elm.anchor_position = (0, import_transformation_matrix10.applyToPoint)(matrix, elm.anchor_position);
|
|
11113
11113
|
} else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect" || elm.type === "pcb_component") {
|
|
11114
|
-
elm.center = (0,
|
|
11114
|
+
elm.center = (0, import_transformation_matrix10.applyToPoint)(matrix, elm.center);
|
|
11115
11115
|
} else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace" || elm.type === "pcb_fabrication_note_path") {
|
|
11116
11116
|
elm.route = elm.route.map(function(rp) {
|
|
11117
|
-
var tp = (0,
|
|
11117
|
+
var tp = (0, import_transformation_matrix10.applyToPoint)(matrix, rp);
|
|
11118
11118
|
rp.x = tp.x;
|
|
11119
11119
|
rp.y = tp.y;
|
|
11120
11120
|
return rp;
|
|
@@ -11128,14 +11128,14 @@ var require_dist2 = __commonJS({
|
|
|
11128
11128
|
x: elm.x2,
|
|
11129
11129
|
y: elm.y2
|
|
11130
11130
|
};
|
|
11131
|
-
var p1t = (0,
|
|
11132
|
-
var p2t = (0,
|
|
11131
|
+
var p1t = (0, import_transformation_matrix10.applyToPoint)(matrix, p1);
|
|
11132
|
+
var p2t = (0, import_transformation_matrix10.applyToPoint)(matrix, p2);
|
|
11133
11133
|
elm.x1 = p1t.x;
|
|
11134
11134
|
elm.y1 = p1t.y;
|
|
11135
11135
|
elm.x2 = p2t.x;
|
|
11136
11136
|
elm.y2 = p2t.y;
|
|
11137
11137
|
} else if (elm.type === "cad_component") {
|
|
11138
|
-
var newPos = (0,
|
|
11138
|
+
var newPos = (0, import_transformation_matrix10.applyToPoint)(matrix, {
|
|
11139
11139
|
x: elm.position.x,
|
|
11140
11140
|
y: elm.position.y
|
|
11141
11141
|
});
|
|
@@ -11145,7 +11145,7 @@ var require_dist2 = __commonJS({
|
|
|
11145
11145
|
return elm;
|
|
11146
11146
|
};
|
|
11147
11147
|
var transformPCBElements2 = function(elms, matrix) {
|
|
11148
|
-
var tsr = (0,
|
|
11148
|
+
var tsr = (0, import_transformation_matrix10.decomposeTSR)(matrix);
|
|
11149
11149
|
var flipPadWidthHeight = Math.round(tsr.rotation.angle / (Math.PI / 2)) % 2 === 1;
|
|
11150
11150
|
var transformedElms = elms.map(function(elm) {
|
|
11151
11151
|
return transformPCBElement2(elm, matrix);
|
|
@@ -11331,7 +11331,7 @@ var require_dist3 = __commonJS({
|
|
|
11331
11331
|
}
|
|
11332
11332
|
});
|
|
11333
11333
|
module2.exports = __toCommonJS2(src_exports2);
|
|
11334
|
-
var
|
|
11334
|
+
var import_transformation_matrix10 = require("transformation-matrix");
|
|
11335
11335
|
var import_react18 = require("react");
|
|
11336
11336
|
var useMouseMatrixTransform2 = function() {
|
|
11337
11337
|
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
@@ -11340,7 +11340,7 @@ var require_dist3 = __commonJS({
|
|
|
11340
11340
|
var _props_canvasElm;
|
|
11341
11341
|
var outerCanvasElm = (_props_canvasElm = props.canvasElm) !== null && _props_canvasElm !== void 0 ? _props_canvasElm : extRef.current;
|
|
11342
11342
|
var _props_initialTransform;
|
|
11343
|
-
var _ref1 = _sliced_to_array((0, import_react18.useState)((_props_initialTransform = props.initialTransform) !== null && _props_initialTransform !== void 0 ? _props_initialTransform : (0,
|
|
11343
|
+
var _ref1 = _sliced_to_array((0, import_react18.useState)((_props_initialTransform = props.initialTransform) !== null && _props_initialTransform !== void 0 ? _props_initialTransform : (0, import_transformation_matrix10.identity)()), 2), internalTransform = _ref1[0], setInternalTransform = _ref1[1];
|
|
11344
11344
|
var _ref2 = _sliced_to_array((0, import_react18.useState)(0), 2), waitCounter = _ref2[0], setWaitCounter = _ref2[1];
|
|
11345
11345
|
var _ref3 = _sliced_to_array((0, import_react18.useReducer)(function(s) {
|
|
11346
11346
|
return s + 1;
|
|
@@ -11377,7 +11377,7 @@ var require_dist3 = __commonJS({
|
|
|
11377
11377
|
var handleMouseUp = function handleMouseUp(e) {
|
|
11378
11378
|
if (!md) return;
|
|
11379
11379
|
m1 = getMousePos(e);
|
|
11380
|
-
var new_tf = (0,
|
|
11380
|
+
var new_tf = (0, import_transformation_matrix10.compose)((0, import_transformation_matrix10.translate)(m1.x - m0.x, m1.y - m0.y), init_tf);
|
|
11381
11381
|
setTransform(new_tf);
|
|
11382
11382
|
init_tf = new_tf;
|
|
11383
11383
|
md = false;
|
|
@@ -11386,11 +11386,11 @@ var require_dist3 = __commonJS({
|
|
|
11386
11386
|
mlastrel = getMousePos(e);
|
|
11387
11387
|
if (!md) return;
|
|
11388
11388
|
m1 = getMousePos(e);
|
|
11389
|
-
setTransform((0,
|
|
11389
|
+
setTransform((0, import_transformation_matrix10.compose)((0, import_transformation_matrix10.translate)(m1.x - m0.x, m1.y - m0.y), init_tf));
|
|
11390
11390
|
};
|
|
11391
11391
|
var handleMouseWheel = function handleMouseWheel(e) {
|
|
11392
11392
|
var center = getMousePos(e);
|
|
11393
|
-
var new_tf = (0,
|
|
11393
|
+
var new_tf = (0, import_transformation_matrix10.compose)((0, import_transformation_matrix10.translate)(center.x, center.y), (0, import_transformation_matrix10.scale)(1 - e.deltaY / 1e3, 1 - e.deltaY / 1e3), (0, import_transformation_matrix10.translate)(-center.x, -center.y), init_tf);
|
|
11394
11394
|
setTransform(new_tf);
|
|
11395
11395
|
init_tf = new_tf;
|
|
11396
11396
|
e.preventDefault();
|
|
@@ -11405,7 +11405,7 @@ var require_dist3 = __commonJS({
|
|
|
11405
11405
|
}
|
|
11406
11406
|
md = false;
|
|
11407
11407
|
m1 = getMousePos(e);
|
|
11408
|
-
var new_tf = (0,
|
|
11408
|
+
var new_tf = (0, import_transformation_matrix10.compose)((0, import_transformation_matrix10.translate)(m1.x - m0.x, m1.y - m0.y), init_tf);
|
|
11409
11409
|
setTransform(new_tf);
|
|
11410
11410
|
init_tf = new_tf;
|
|
11411
11411
|
};
|
|
@@ -11460,7 +11460,7 @@ var require_dist3 = __commonJS({
|
|
|
11460
11460
|
lastDragCancelTime
|
|
11461
11461
|
]);
|
|
11462
11462
|
var applyTransformToPoint = (0, import_react18.useCallback)(function(obj) {
|
|
11463
|
-
return (0,
|
|
11463
|
+
return (0, import_transformation_matrix10.applyToPoint)(transform, obj);
|
|
11464
11464
|
}, [
|
|
11465
11465
|
transform
|
|
11466
11466
|
]);
|
|
@@ -12255,9 +12255,9 @@ var import_react2 = require("react");
|
|
|
12255
12255
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
12256
12256
|
var StoreContext = (0, import_react2.createContext)(null);
|
|
12257
12257
|
var ContextProviders = function(param) {
|
|
12258
|
-
var children = param.children;
|
|
12258
|
+
var children = param.children, initialState = param.initialState;
|
|
12259
12259
|
var store = (0, import_react.useMemo)(function() {
|
|
12260
|
-
return createStore();
|
|
12260
|
+
return createStore(initialState);
|
|
12261
12261
|
}, []);
|
|
12262
12262
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StoreContext.Provider, {
|
|
12263
12263
|
value: store,
|
|
@@ -12267,14 +12267,17 @@ var ContextProviders = function(param) {
|
|
|
12267
12267
|
// src/global-store.ts
|
|
12268
12268
|
var import_react3 = require("react");
|
|
12269
12269
|
var createStore = function() {
|
|
12270
|
+
var initialState = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
12270
12271
|
return (0, import_zustand.createStore)(function(set) {
|
|
12271
|
-
return {
|
|
12272
|
+
return _object_spread_props(_object_spread({
|
|
12272
12273
|
selected_layer: "top",
|
|
12273
12274
|
in_edit_mode: false,
|
|
12274
12275
|
in_move_footprint_mode: false,
|
|
12275
12276
|
in_draw_trace_mode: false,
|
|
12276
12277
|
is_moving_component: false,
|
|
12277
12278
|
is_drawing_trace: false,
|
|
12279
|
+
is_showing_rats_nest: false
|
|
12280
|
+
}, initialState), {
|
|
12278
12281
|
selectLayer: function(layer) {
|
|
12279
12282
|
return set({
|
|
12280
12283
|
selected_layer: layer
|
|
@@ -12289,6 +12292,11 @@ var createStore = function() {
|
|
|
12289
12292
|
is_drawing_trace: false
|
|
12290
12293
|
});
|
|
12291
12294
|
},
|
|
12295
|
+
setIsShowingRatsNest: function(is_showing) {
|
|
12296
|
+
return set({
|
|
12297
|
+
is_showing_rats_nest: is_showing
|
|
12298
|
+
});
|
|
12299
|
+
},
|
|
12292
12300
|
setIsMovingComponent: function(is_moving) {
|
|
12293
12301
|
return set({
|
|
12294
12302
|
is_moving_component: is_moving
|
|
@@ -12299,7 +12307,7 @@ var createStore = function() {
|
|
|
12299
12307
|
is_drawing_trace: is_drawing
|
|
12300
12308
|
});
|
|
12301
12309
|
}
|
|
12302
|
-
};
|
|
12310
|
+
});
|
|
12303
12311
|
});
|
|
12304
12312
|
};
|
|
12305
12313
|
var useGlobalStore = function(s) {
|
|
@@ -13280,7 +13288,7 @@ var import_soup2 = __toESM(require_dist());
|
|
|
13280
13288
|
// package.json
|
|
13281
13289
|
var package_default = {
|
|
13282
13290
|
name: "@tscircuit/pcb-viewer",
|
|
13283
|
-
version: "1.4.
|
|
13291
|
+
version: "1.4.3",
|
|
13284
13292
|
main: "dist/index.js",
|
|
13285
13293
|
repository: "tscircuit/pcb-viewer",
|
|
13286
13294
|
license: "MIT",
|
|
@@ -13395,12 +13403,16 @@ var ToolbarOverlay = function(param) {
|
|
|
13395
13403
|
var _useGlobalStore1 = _sliced_to_array(useGlobalStore(function(s) {
|
|
13396
13404
|
return [
|
|
13397
13405
|
s.in_move_footprint_mode,
|
|
13398
|
-
s.in_draw_trace_mode
|
|
13406
|
+
s.in_draw_trace_mode,
|
|
13407
|
+
s.is_showing_rats_nest
|
|
13399
13408
|
];
|
|
13400
|
-
}),
|
|
13409
|
+
}), 3), in_move_footprint_mode = _useGlobalStore1[0], in_draw_trace_mode = _useGlobalStore1[1], is_showing_rats_nest = _useGlobalStore1[2];
|
|
13401
13410
|
var setEditMode = useGlobalStore(function(s) {
|
|
13402
13411
|
return s.setEditMode;
|
|
13403
13412
|
});
|
|
13413
|
+
var setIsShowingRatsNest = useGlobalStore(function(s) {
|
|
13414
|
+
return s.setIsShowingRatsNest;
|
|
13415
|
+
});
|
|
13404
13416
|
var _elements_filter_length;
|
|
13405
13417
|
var errorCount = (_elements_filter_length = elements === null || elements === void 0 ? void 0 : elements.filter(function(e) {
|
|
13406
13418
|
return e.type.includes("error");
|
|
@@ -13556,6 +13568,18 @@ var ToolbarOverlay = function(param) {
|
|
|
13556
13568
|
"Move Components"
|
|
13557
13569
|
]
|
|
13558
13570
|
})
|
|
13571
|
+
}),
|
|
13572
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ToolbarButton, {
|
|
13573
|
+
style: {},
|
|
13574
|
+
onClick: function() {
|
|
13575
|
+
setIsShowingRatsNest(!is_showing_rats_nest);
|
|
13576
|
+
},
|
|
13577
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", {
|
|
13578
|
+
children: [
|
|
13579
|
+
is_showing_rats_nest ? "✖ " : "",
|
|
13580
|
+
"Rats Nest"
|
|
13581
|
+
]
|
|
13582
|
+
})
|
|
13559
13583
|
})
|
|
13560
13584
|
]
|
|
13561
13585
|
})
|
|
@@ -14183,9 +14207,84 @@ var EditTraceHintOverlay = function(param) {
|
|
|
14183
14207
|
]
|
|
14184
14208
|
});
|
|
14185
14209
|
};
|
|
14186
|
-
// src/components/
|
|
14210
|
+
// src/components/RatsNestOverlay.tsx
|
|
14211
|
+
var import_transformation_matrix7 = require("transformation-matrix");
|
|
14212
|
+
var import_soup_util3 = __toESM(require_dist2());
|
|
14187
14213
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
14214
|
+
var RatsNestOverlay = function(param) {
|
|
14215
|
+
var transform = param.transform, soup = param.soup, children = param.children;
|
|
14216
|
+
var isShowingRatsNest = useGlobalStore(function(s) {
|
|
14217
|
+
return s.is_showing_rats_nest;
|
|
14218
|
+
});
|
|
14219
|
+
if (!soup || !isShowingRatsNest) return children;
|
|
14220
|
+
if (!transform) transform = (0, import_transformation_matrix7.identity)();
|
|
14221
|
+
var sourceTraces = (0, import_soup_util3.su)(soup).source_trace.list();
|
|
14222
|
+
var groups = [];
|
|
14223
|
+
sourceTraces.forEach(function(sourceTrace) {
|
|
14224
|
+
if (sourceTrace.connected_source_port_ids) {
|
|
14225
|
+
var group = [];
|
|
14226
|
+
sourceTrace.connected_source_port_ids.forEach(function(source_port_id) {
|
|
14227
|
+
var pcbPort = (0, import_soup_util3.su)(soup).pcb_port.getWhere({
|
|
14228
|
+
source_port_id: source_port_id
|
|
14229
|
+
});
|
|
14230
|
+
if (pcbPort) group.push(pcbPort);
|
|
14231
|
+
});
|
|
14232
|
+
groups.push(group);
|
|
14233
|
+
}
|
|
14234
|
+
});
|
|
14235
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", {
|
|
14236
|
+
style: {
|
|
14237
|
+
position: "relative"
|
|
14238
|
+
},
|
|
14239
|
+
children: [
|
|
14240
|
+
children,
|
|
14241
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("svg", {
|
|
14242
|
+
style: {
|
|
14243
|
+
position: "absolute",
|
|
14244
|
+
left: 0,
|
|
14245
|
+
top: 0,
|
|
14246
|
+
width: "100%",
|
|
14247
|
+
height: "100%",
|
|
14248
|
+
pointerEvents: "none",
|
|
14249
|
+
opacity: 0.5,
|
|
14250
|
+
zIndex: 100
|
|
14251
|
+
},
|
|
14252
|
+
children: groups.map(function(group, index) {
|
|
14253
|
+
var points = group.map(function(port) {
|
|
14254
|
+
return (0, import_transformation_matrix7.applyToPoint)(transform, {
|
|
14255
|
+
x: port.x,
|
|
14256
|
+
y: port.y
|
|
14257
|
+
});
|
|
14258
|
+
});
|
|
14259
|
+
var lines = [];
|
|
14260
|
+
for(var i = 0; i < points.length; i++){
|
|
14261
|
+
for(var j = i + 1; j < points.length; j++){
|
|
14262
|
+
lines.push([
|
|
14263
|
+
points[i],
|
|
14264
|
+
points[j]
|
|
14265
|
+
]);
|
|
14266
|
+
}
|
|
14267
|
+
}
|
|
14268
|
+
return lines.map(function(param, index2) {
|
|
14269
|
+
var _param = _sliced_to_array(param, 2), start = _param[0], end = _param[1];
|
|
14270
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("line", {
|
|
14271
|
+
x1: start.x,
|
|
14272
|
+
y1: start.y,
|
|
14273
|
+
x2: end.x,
|
|
14274
|
+
y2: end.y,
|
|
14275
|
+
stroke: "white",
|
|
14276
|
+
strokeWidth: "1"
|
|
14277
|
+
}, index2);
|
|
14278
|
+
});
|
|
14279
|
+
})
|
|
14280
|
+
})
|
|
14281
|
+
]
|
|
14282
|
+
});
|
|
14283
|
+
};
|
|
14284
|
+
// src/components/CanvasElementsRenderer.tsx
|
|
14285
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
14188
14286
|
var CanvasElementsRenderer = function(props) {
|
|
14287
|
+
var transform = props.transform, elements = props.elements;
|
|
14189
14288
|
var primitives = (0, import_react14.useMemo)(function() {
|
|
14190
14289
|
var primitives2 = props.elements.flatMap(function(elm) {
|
|
14191
14290
|
return convertElementToPrimitives(elm, props.elements);
|
|
@@ -14194,36 +14293,40 @@ var CanvasElementsRenderer = function(props) {
|
|
|
14194
14293
|
}, [
|
|
14195
14294
|
props.elements
|
|
14196
14295
|
]);
|
|
14197
|
-
return /* @__PURE__ */ (0,
|
|
14198
|
-
transform:
|
|
14296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MouseElementTracker, {
|
|
14297
|
+
transform: transform,
|
|
14199
14298
|
primitives: primitives,
|
|
14200
|
-
children: /* @__PURE__ */ (0,
|
|
14299
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(EditPlacementOverlay, {
|
|
14201
14300
|
disabled: !props.allowEditing,
|
|
14202
|
-
transform:
|
|
14203
|
-
soup:
|
|
14301
|
+
transform: transform,
|
|
14302
|
+
soup: elements,
|
|
14204
14303
|
cancelPanDrag: props.cancelPanDrag,
|
|
14205
14304
|
onCreateEditEvent: props.onCreateEditEvent,
|
|
14206
14305
|
onModifyEditEvent: props.onModifyEditEvent,
|
|
14207
|
-
children: /* @__PURE__ */ (0,
|
|
14306
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(EditTraceHintOverlay, {
|
|
14208
14307
|
disabled: !props.allowEditing,
|
|
14209
|
-
transform:
|
|
14210
|
-
soup:
|
|
14308
|
+
transform: transform,
|
|
14309
|
+
soup: elements,
|
|
14211
14310
|
cancelPanDrag: props.cancelPanDrag,
|
|
14212
14311
|
onCreateEditEvent: props.onCreateEditEvent,
|
|
14213
14312
|
onModifyEditEvent: props.onModifyEditEvent,
|
|
14214
|
-
children: /* @__PURE__ */ (0,
|
|
14215
|
-
transform:
|
|
14216
|
-
children: /* @__PURE__ */ (0,
|
|
14217
|
-
elements:
|
|
14218
|
-
children: /* @__PURE__ */ (0,
|
|
14219
|
-
transform:
|
|
14220
|
-
elements:
|
|
14221
|
-
children: /* @__PURE__ */ (0,
|
|
14222
|
-
transform:
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
|
|
14313
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DimensionOverlay, {
|
|
14314
|
+
transform: transform,
|
|
14315
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ToolbarOverlay, {
|
|
14316
|
+
elements: elements,
|
|
14317
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ErrorOverlay, {
|
|
14318
|
+
transform: transform,
|
|
14319
|
+
elements: elements,
|
|
14320
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RatsNestOverlay, {
|
|
14321
|
+
transform: transform,
|
|
14322
|
+
soup: elements,
|
|
14323
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CanvasPrimitiveRenderer, {
|
|
14324
|
+
transform: transform,
|
|
14325
|
+
primitives: primitives,
|
|
14326
|
+
width: props.width,
|
|
14327
|
+
height: props.height,
|
|
14328
|
+
grid: props.grid
|
|
14329
|
+
})
|
|
14227
14330
|
})
|
|
14228
14331
|
})
|
|
14229
14332
|
})
|
|
@@ -14294,13 +14397,13 @@ var useMeasure_default = isBrowser && typeof window.ResizeObserver !== "undefine
|
|
|
14294
14397
|
];
|
|
14295
14398
|
};
|
|
14296
14399
|
// src/PCBViewer.tsx
|
|
14297
|
-
var
|
|
14400
|
+
var import_transformation_matrix9 = require("transformation-matrix");
|
|
14298
14401
|
var import_builder3 = require("@tscircuit/builder");
|
|
14299
14402
|
// src/lib/apply-edit-events.ts
|
|
14300
14403
|
var import_builder = require("@tscircuit/builder");
|
|
14301
|
-
var
|
|
14404
|
+
var import_transformation_matrix8 = require("transformation-matrix");
|
|
14302
14405
|
// src/lib/apply-edit-events/apply-edit-trace-hint-event.ts
|
|
14303
|
-
var
|
|
14406
|
+
var import_soup_util4 = __toESM(require_dist2());
|
|
14304
14407
|
var applyTraceHintEditEvent = function(soup, edit_event) {
|
|
14305
14408
|
var existing_trace_hint = soup.find(function(th) {
|
|
14306
14409
|
return th.type === "pcb_trace_hint" && th.pcb_trace_hint_id === edit_event.pcb_trace_hint_id;
|
|
@@ -14312,7 +14415,7 @@ var applyTraceHintEditEvent = function(soup, edit_event) {
|
|
|
14312
14415
|
}) : e;
|
|
14313
14416
|
});
|
|
14314
14417
|
} else {
|
|
14315
|
-
var pcb_port = (0,
|
|
14418
|
+
var pcb_port = (0, import_soup_util4.su)(soup).pcb_port.get(edit_event.pcb_port_id);
|
|
14316
14419
|
soup = soup.filter(function(e) {
|
|
14317
14420
|
return !(e.type === "pcb_trace_hint" && e.pcb_port_id === edit_event.pcb_port_id);
|
|
14318
14421
|
}).concat([
|
|
@@ -14335,7 +14438,7 @@ var applyEditEvents = function(soup, edit_events) {
|
|
|
14335
14438
|
var _loop = function() {
|
|
14336
14439
|
var edit_event = _step.value;
|
|
14337
14440
|
if (edit_event.pcb_edit_event_type === "edit_component_location") {
|
|
14338
|
-
var mat = (0,
|
|
14441
|
+
var mat = (0, import_transformation_matrix8.translate)(edit_event.new_center.x - edit_event.original_center.x, edit_event.new_center.y - edit_event.original_center.y);
|
|
14339
14442
|
soup = soup.map(function(e) {
|
|
14340
14443
|
return e.pcb_component_id !== edit_event.pcb_component_id ? e : (0, import_builder.transformPCBElement)(e, mat);
|
|
14341
14444
|
});
|
|
@@ -14361,10 +14464,10 @@ var applyEditEvents = function(soup, edit_events) {
|
|
|
14361
14464
|
return soup;
|
|
14362
14465
|
};
|
|
14363
14466
|
// src/PCBViewer.tsx
|
|
14364
|
-
var
|
|
14365
|
-
var defaultTransform = (0,
|
|
14467
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
14468
|
+
var defaultTransform = (0, import_transformation_matrix9.compose)((0, import_transformation_matrix9.translate)(400, 300), (0, import_transformation_matrix9.scale)(40, -40));
|
|
14366
14469
|
var PCBViewer = function(param) {
|
|
14367
|
-
var children = param.children, soup = param.soup, _param_height = param.height, height = _param_height === void 0 ? 600 : _param_height, _param_allowEditing = param.allowEditing, allowEditing = _param_allowEditing === void 0 ? true : _param_allowEditing, editEventsProp = param.editEvents, onEditEventsChanged = param.onEditEventsChanged;
|
|
14470
|
+
var children = param.children, soup = param.soup, _param_height = param.height, height = _param_height === void 0 ? 600 : _param_height, initialState = param.initialState, _param_allowEditing = param.allowEditing, allowEditing = _param_allowEditing === void 0 ? true : _param_allowEditing, editEventsProp = param.editEvents, onEditEventsChanged = param.onEditEventsChanged;
|
|
14368
14471
|
var _ref = _sliced_to_array((0, import_react17.useState)([]), 2), stateElements = _ref[0], setStateElements = _ref[1];
|
|
14369
14472
|
var _useMeasure_default = _sliced_to_array(useMeasure_default(), 2), ref = _useMeasure_default[0], refDimensions = _useMeasure_default[1];
|
|
14370
14473
|
var _ref1 = _sliced_to_array((0, import_react17.useState)(defaultTransform), 2), transform = _ref1[0], setTransformInternal = _ref1[1];
|
|
@@ -14395,8 +14498,8 @@ var PCBViewer = function(param) {
|
|
|
14395
14498
|
var _elmBounds_width, _elmBounds_height;
|
|
14396
14499
|
var scaleFactor = Math.min(((_elmBounds_width = elmBounds.width) !== null && _elmBounds_width !== void 0 ? _elmBounds_width : 0) / width, ((_elmBounds_height = elmBounds.height) !== null && _elmBounds_height !== void 0 ? _elmBounds_height : 0) / height2, 100) * 0.75;
|
|
14397
14500
|
var _elmBounds_width1, _elmBounds_height1;
|
|
14398
|
-
setTransform((0,
|
|
14399
|
-
(0,
|
|
14501
|
+
setTransform((0, import_transformation_matrix9.compose)((0, import_transformation_matrix9.translate)(((_elmBounds_width1 = elmBounds.width) !== null && _elmBounds_width1 !== void 0 ? _elmBounds_width1 : 0) / 2, ((_elmBounds_height1 = elmBounds.height) !== null && _elmBounds_height1 !== void 0 ? _elmBounds_height1 : 0) / 2), // translate(100, 0),
|
|
14502
|
+
(0, import_transformation_matrix9.scale)(scaleFactor, -scaleFactor, 0, 0), (0, import_transformation_matrix9.translate)(-center.x, -center.y)));
|
|
14400
14503
|
};
|
|
14401
14504
|
(0, import_react17.useEffect)(function() {
|
|
14402
14505
|
var doRender = function doRender() {
|
|
@@ -14442,7 +14545,7 @@ var PCBViewer = function(param) {
|
|
|
14442
14545
|
children,
|
|
14443
14546
|
refDimensions
|
|
14444
14547
|
]);
|
|
14445
|
-
if (error) return /* @__PURE__ */ (0,
|
|
14548
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", {
|
|
14446
14549
|
style: {
|
|
14447
14550
|
color: "red"
|
|
14448
14551
|
},
|
|
@@ -14476,12 +14579,13 @@ var PCBViewer = function(param) {
|
|
|
14476
14579
|
setEditEvents(newEditEvents);
|
|
14477
14580
|
onEditEventsChanged === null || onEditEventsChanged === void 0 ? void 0 : onEditEventsChanged(newEditEvents);
|
|
14478
14581
|
};
|
|
14479
|
-
return /* @__PURE__ */ (0,
|
|
14582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", {
|
|
14480
14583
|
ref: transformRef,
|
|
14481
|
-
children: /* @__PURE__ */ (0,
|
|
14584
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", {
|
|
14482
14585
|
ref: ref,
|
|
14483
|
-
children: /* @__PURE__ */ (0,
|
|
14484
|
-
|
|
14586
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ContextProviders, {
|
|
14587
|
+
initialState: initialState,
|
|
14588
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CanvasElementsRenderer, {
|
|
14485
14589
|
transform: transform,
|
|
14486
14590
|
height: height,
|
|
14487
14591
|
width: refDimensions.width,
|