@tscircuit/pcb-viewer 1.11.275 → 1.11.277
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 +117 -103
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7094,51 +7094,57 @@ var convertElementToPrimitives = (element, allElements) => {
|
|
|
7094
7094
|
) : void 0;
|
|
7095
7095
|
switch (element.type) {
|
|
7096
7096
|
case "pcb_panel": {
|
|
7097
|
-
const { width, height } = element;
|
|
7097
|
+
const { width, height, center } = element;
|
|
7098
|
+
const cx = center?.x ?? 0;
|
|
7099
|
+
const cy = center?.y ?? 0;
|
|
7098
7100
|
return [
|
|
7101
|
+
// Bottom line
|
|
7099
7102
|
{
|
|
7100
7103
|
_pcb_drawing_object_id: `line_${globalPcbDrawingObjectCount++}`,
|
|
7101
7104
|
pcb_drawing_type: "line",
|
|
7102
|
-
x1:
|
|
7103
|
-
y1:
|
|
7104
|
-
x2: width,
|
|
7105
|
-
y2:
|
|
7105
|
+
x1: cx - width / 2,
|
|
7106
|
+
y1: cy - height / 2,
|
|
7107
|
+
x2: cx + width / 2,
|
|
7108
|
+
y2: cy - height / 2,
|
|
7106
7109
|
width: 1,
|
|
7107
7110
|
zoomIndependent: true,
|
|
7108
7111
|
layer: "board",
|
|
7109
7112
|
_element: element
|
|
7110
7113
|
},
|
|
7114
|
+
// Top line
|
|
7111
7115
|
{
|
|
7112
7116
|
_pcb_drawing_object_id: `line_${globalPcbDrawingObjectCount++}`,
|
|
7113
7117
|
pcb_drawing_type: "line",
|
|
7114
|
-
x1:
|
|
7115
|
-
y1: height,
|
|
7116
|
-
x2: width,
|
|
7117
|
-
y2: height,
|
|
7118
|
+
x1: cx - width / 2,
|
|
7119
|
+
y1: cy + height / 2,
|
|
7120
|
+
x2: cx + width / 2,
|
|
7121
|
+
y2: cy + height / 2,
|
|
7118
7122
|
width: 1,
|
|
7119
7123
|
zoomIndependent: true,
|
|
7120
7124
|
layer: "board",
|
|
7121
7125
|
_element: element
|
|
7122
7126
|
},
|
|
7127
|
+
// Left line
|
|
7123
7128
|
{
|
|
7124
7129
|
_pcb_drawing_object_id: `line_${globalPcbDrawingObjectCount++}`,
|
|
7125
7130
|
pcb_drawing_type: "line",
|
|
7126
|
-
x1:
|
|
7127
|
-
y1:
|
|
7128
|
-
x2:
|
|
7129
|
-
y2: height,
|
|
7131
|
+
x1: cx - width / 2,
|
|
7132
|
+
y1: cy - height / 2,
|
|
7133
|
+
x2: cx - width / 2,
|
|
7134
|
+
y2: cy + height / 2,
|
|
7130
7135
|
width: 1,
|
|
7131
7136
|
zoomIndependent: true,
|
|
7132
7137
|
layer: "board",
|
|
7133
7138
|
_element: element
|
|
7134
7139
|
},
|
|
7140
|
+
// Right line
|
|
7135
7141
|
{
|
|
7136
7142
|
_pcb_drawing_object_id: `line_${globalPcbDrawingObjectCount++}`,
|
|
7137
7143
|
pcb_drawing_type: "line",
|
|
7138
|
-
x1: width,
|
|
7139
|
-
y1:
|
|
7140
|
-
x2: width,
|
|
7141
|
-
y2: height,
|
|
7144
|
+
x1: cx + width / 2,
|
|
7145
|
+
y1: cy - height / 2,
|
|
7146
|
+
x2: cx + width / 2,
|
|
7147
|
+
y2: cy + height / 2,
|
|
7142
7148
|
width: 1,
|
|
7143
7149
|
zoomIndependent: true,
|
|
7144
7150
|
layer: "board",
|
|
@@ -13305,7 +13311,7 @@ import { css as css3 } from "@emotion/css";
|
|
|
13305
13311
|
// package.json
|
|
13306
13312
|
var package_default = {
|
|
13307
13313
|
name: "@tscircuit/pcb-viewer",
|
|
13308
|
-
version: "1.11.
|
|
13314
|
+
version: "1.11.276",
|
|
13309
13315
|
main: "dist/index.js",
|
|
13310
13316
|
type: "module",
|
|
13311
13317
|
repository: "tscircuit/pcb-viewer",
|
|
@@ -13342,7 +13348,7 @@ var package_default = {
|
|
|
13342
13348
|
"react-cosmos-plugin-vite": "7.0.0-beta.0",
|
|
13343
13349
|
"react-dom": "19.1.0",
|
|
13344
13350
|
"react-use": "^17.4.0",
|
|
13345
|
-
tscircuit: "^0.0.
|
|
13351
|
+
tscircuit: "^0.0.1015",
|
|
13346
13352
|
tsup: "^8.0.2",
|
|
13347
13353
|
"type-fest": "^3.0.0",
|
|
13348
13354
|
typescript: "^5.4.4",
|
|
@@ -14442,96 +14448,104 @@ var PCBViewer = ({
|
|
|
14442
14448
|
}),
|
|
14443
14449
|
[initialState, disablePcbGroups]
|
|
14444
14450
|
);
|
|
14445
|
-
return /* @__PURE__ */ jsxs14(
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
|
|
14450
|
-
|
|
14451
|
-
|
|
14452
|
-
|
|
14453
|
-
|
|
14454
|
-
|
|
14455
|
-
|
|
14456
|
-
|
|
14457
|
-
|
|
14458
|
-
|
|
14459
|
-
|
|
14460
|
-
|
|
14461
|
-
|
|
14462
|
-
|
|
14463
|
-
|
|
14464
|
-
|
|
14465
|
-
|
|
14466
|
-
|
|
14467
|
-
|
|
14468
|
-
|
|
14469
|
-
|
|
14470
|
-
|
|
14471
|
-
|
|
14472
|
-
|
|
14473
|
-
|
|
14474
|
-
|
|
14475
|
-
|
|
14476
|
-
|
|
14477
|
-
|
|
14478
|
-
|
|
14479
|
-
|
|
14480
|
-
|
|
14481
|
-
|
|
14482
|
-
|
|
14483
|
-
|
|
14484
|
-
|
|
14485
|
-
|
|
14486
|
-
|
|
14487
|
-
|
|
14488
|
-
onTouchStart: (e) => {
|
|
14489
|
-
const touch = e.touches[0];
|
|
14490
|
-
touchStartRef.current = {
|
|
14491
|
-
x: touch.clientX,
|
|
14492
|
-
y: touch.clientY
|
|
14493
|
-
};
|
|
14494
|
-
},
|
|
14495
|
-
onTouchEnd: (e) => {
|
|
14496
|
-
const touch = e.changedTouches[0];
|
|
14497
|
-
const start = touchStartRef.current;
|
|
14498
|
-
if (!start) return;
|
|
14499
|
-
const deltaX = Math.abs(touch.clientX - start.x);
|
|
14500
|
-
const deltaY = Math.abs(touch.clientY - start.y);
|
|
14501
|
-
if (deltaX < 10 && deltaY < 10) {
|
|
14502
|
-
e.preventDefault();
|
|
14503
|
-
setIsInteractionEnabled(true);
|
|
14504
|
-
resetTransform();
|
|
14505
|
-
}
|
|
14506
|
-
touchStartRef.current = null;
|
|
14507
|
-
},
|
|
14508
|
-
style: {
|
|
14509
|
-
position: "absolute",
|
|
14510
|
-
inset: 0,
|
|
14511
|
-
cursor: "pointer",
|
|
14512
|
-
zIndex: zIndexMap.clickToInteractOverlay,
|
|
14513
|
-
display: "flex",
|
|
14514
|
-
alignItems: "center",
|
|
14515
|
-
justifyContent: "center",
|
|
14516
|
-
touchAction: "pan-x pan-y pinch-zoom"
|
|
14517
|
-
},
|
|
14518
|
-
children: /* @__PURE__ */ jsx18(
|
|
14451
|
+
return /* @__PURE__ */ jsxs14(
|
|
14452
|
+
"div",
|
|
14453
|
+
{
|
|
14454
|
+
ref: transformRef,
|
|
14455
|
+
style: { position: "relative" },
|
|
14456
|
+
onContextMenu: (event) => event.preventDefault(),
|
|
14457
|
+
children: [
|
|
14458
|
+
/* @__PURE__ */ jsx18("div", { ref, children: /* @__PURE__ */ jsxs14(
|
|
14459
|
+
ContextProviders,
|
|
14460
|
+
{
|
|
14461
|
+
initialState: mergedInitialState,
|
|
14462
|
+
disablePcbGroups,
|
|
14463
|
+
children: [
|
|
14464
|
+
/* @__PURE__ */ jsx18(
|
|
14465
|
+
CanvasElementsRenderer,
|
|
14466
|
+
{
|
|
14467
|
+
transform,
|
|
14468
|
+
height,
|
|
14469
|
+
width: refDimensions.width,
|
|
14470
|
+
allowEditing,
|
|
14471
|
+
focusOnHover,
|
|
14472
|
+
cancelPanDrag,
|
|
14473
|
+
onCreateEditEvent,
|
|
14474
|
+
onModifyEditEvent,
|
|
14475
|
+
grid: {
|
|
14476
|
+
spacing: 1,
|
|
14477
|
+
view_window: {
|
|
14478
|
+
left: 0,
|
|
14479
|
+
right: refDimensions.width || 500,
|
|
14480
|
+
top: height,
|
|
14481
|
+
bottom: 0
|
|
14482
|
+
}
|
|
14483
|
+
},
|
|
14484
|
+
elements,
|
|
14485
|
+
debugGraphics
|
|
14486
|
+
},
|
|
14487
|
+
refDimensions.width
|
|
14488
|
+
),
|
|
14489
|
+
/* @__PURE__ */ jsx18(ToastContainer, {})
|
|
14490
|
+
]
|
|
14491
|
+
}
|
|
14492
|
+
) }),
|
|
14493
|
+
clickToInteractEnabled && !isInteractionEnabled && /* @__PURE__ */ jsx18(
|
|
14519
14494
|
"div",
|
|
14520
14495
|
{
|
|
14496
|
+
onClick: () => {
|
|
14497
|
+
setIsInteractionEnabled(true);
|
|
14498
|
+
resetTransform();
|
|
14499
|
+
},
|
|
14500
|
+
onTouchStart: (e) => {
|
|
14501
|
+
const touch = e.touches[0];
|
|
14502
|
+
touchStartRef.current = {
|
|
14503
|
+
x: touch.clientX,
|
|
14504
|
+
y: touch.clientY
|
|
14505
|
+
};
|
|
14506
|
+
},
|
|
14507
|
+
onTouchEnd: (e) => {
|
|
14508
|
+
const touch = e.changedTouches[0];
|
|
14509
|
+
const start = touchStartRef.current;
|
|
14510
|
+
if (!start) return;
|
|
14511
|
+
const deltaX = Math.abs(touch.clientX - start.x);
|
|
14512
|
+
const deltaY = Math.abs(touch.clientY - start.y);
|
|
14513
|
+
if (deltaX < 10 && deltaY < 10) {
|
|
14514
|
+
e.preventDefault();
|
|
14515
|
+
setIsInteractionEnabled(true);
|
|
14516
|
+
resetTransform();
|
|
14517
|
+
}
|
|
14518
|
+
touchStartRef.current = null;
|
|
14519
|
+
},
|
|
14521
14520
|
style: {
|
|
14522
|
-
|
|
14523
|
-
|
|
14524
|
-
|
|
14525
|
-
|
|
14526
|
-
|
|
14527
|
-
|
|
14521
|
+
position: "absolute",
|
|
14522
|
+
inset: 0,
|
|
14523
|
+
cursor: "pointer",
|
|
14524
|
+
zIndex: zIndexMap.clickToInteractOverlay,
|
|
14525
|
+
display: "flex",
|
|
14526
|
+
alignItems: "center",
|
|
14527
|
+
justifyContent: "center",
|
|
14528
|
+
touchAction: "pan-x pan-y pinch-zoom"
|
|
14528
14529
|
},
|
|
14529
|
-
children:
|
|
14530
|
+
children: /* @__PURE__ */ jsx18(
|
|
14531
|
+
"div",
|
|
14532
|
+
{
|
|
14533
|
+
style: {
|
|
14534
|
+
backgroundColor: "rgba(0, 0, 0, 0.8)",
|
|
14535
|
+
color: "white",
|
|
14536
|
+
padding: "12px 24px",
|
|
14537
|
+
borderRadius: "8px",
|
|
14538
|
+
fontSize: "16px",
|
|
14539
|
+
pointerEvents: "none"
|
|
14540
|
+
},
|
|
14541
|
+
children: typeof window !== "undefined" && ("ontouchstart" in window || navigator.maxTouchPoints > 0) ? "Touch to Interact" : "Click to Interact"
|
|
14542
|
+
}
|
|
14543
|
+
)
|
|
14530
14544
|
}
|
|
14531
14545
|
)
|
|
14532
|
-
|
|
14533
|
-
|
|
14534
|
-
|
|
14546
|
+
]
|
|
14547
|
+
}
|
|
14548
|
+
);
|
|
14535
14549
|
};
|
|
14536
14550
|
export {
|
|
14537
14551
|
CanvasElementsRenderer,
|