@tscircuit/pcb-viewer 1.11.307 → 1.11.309
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 +119 -49
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7412,43 +7412,6 @@ var convertElementToPrimitives = (element, allElements) => {
|
|
|
7412
7412
|
}
|
|
7413
7413
|
return [];
|
|
7414
7414
|
}
|
|
7415
|
-
case "pcb_keepout": {
|
|
7416
|
-
if (element.shape === "circle") {
|
|
7417
|
-
const { center, radius } = element;
|
|
7418
|
-
return [
|
|
7419
|
-
{
|
|
7420
|
-
_pcb_drawing_object_id: `circle_${globalPcbDrawingObjectCount++}`,
|
|
7421
|
-
pcb_drawing_type: "circle",
|
|
7422
|
-
x: center.x,
|
|
7423
|
-
y: center.y,
|
|
7424
|
-
r: radius,
|
|
7425
|
-
layer: "top",
|
|
7426
|
-
_element: element,
|
|
7427
|
-
_parent_pcb_component,
|
|
7428
|
-
_parent_source_component,
|
|
7429
|
-
mesh_fill: true
|
|
7430
|
-
}
|
|
7431
|
-
];
|
|
7432
|
-
} else if (element.shape === "rect") {
|
|
7433
|
-
const { center, width, height } = element;
|
|
7434
|
-
return [
|
|
7435
|
-
{
|
|
7436
|
-
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
7437
|
-
pcb_drawing_type: "rect",
|
|
7438
|
-
x: center.x,
|
|
7439
|
-
y: center.y,
|
|
7440
|
-
w: width,
|
|
7441
|
-
h: height,
|
|
7442
|
-
layer: "top",
|
|
7443
|
-
_element: element,
|
|
7444
|
-
_parent_pcb_component,
|
|
7445
|
-
_parent_source_component,
|
|
7446
|
-
mesh_fill: true
|
|
7447
|
-
}
|
|
7448
|
-
];
|
|
7449
|
-
}
|
|
7450
|
-
break;
|
|
7451
|
-
}
|
|
7452
7415
|
case "pcb_trace": {
|
|
7453
7416
|
const primitives = [];
|
|
7454
7417
|
if (element.route_thickness_mode === "interpolated") {
|
|
@@ -8586,23 +8549,23 @@ var Drawer = class {
|
|
|
8586
8549
|
}
|
|
8587
8550
|
applyAperture() {
|
|
8588
8551
|
const { transform, aperture } = this;
|
|
8589
|
-
let { size, mode, color:
|
|
8552
|
+
let { size, mode, color: color5, fontSize, layer } = aperture;
|
|
8590
8553
|
if (!(layer in this.ctxLayerMap)) this.aperture.layer = "other";
|
|
8591
8554
|
const ctx = this.getLayerCtx();
|
|
8592
8555
|
if (!ctx) {
|
|
8593
8556
|
throw new Error(`No context for layer "${this.foregroundLayer}"`);
|
|
8594
8557
|
}
|
|
8595
|
-
if (!
|
|
8558
|
+
if (!color5) color5 = "undefined";
|
|
8596
8559
|
ctx.lineWidth = scaleOnly(transform, size);
|
|
8597
8560
|
ctx.lineCap = "round";
|
|
8598
8561
|
if (mode === "add") {
|
|
8599
8562
|
ctx.globalCompositeOperation = "source-over";
|
|
8600
|
-
let colorString = LAYER_NAME_TO_COLOR[
|
|
8563
|
+
let colorString = LAYER_NAME_TO_COLOR[color5.toLowerCase()];
|
|
8601
8564
|
if (!colorString)
|
|
8602
8565
|
try {
|
|
8603
|
-
colorString = colorParser(
|
|
8566
|
+
colorString = colorParser(color5).rgb().toString();
|
|
8604
8567
|
} catch (error) {
|
|
8605
|
-
console.warn(`Invalid color format: '${
|
|
8568
|
+
console.warn(`Invalid color format: '${color5}'`);
|
|
8606
8569
|
colorString = "white";
|
|
8607
8570
|
}
|
|
8608
8571
|
ctx.fillStyle = colorString;
|
|
@@ -9318,6 +9281,79 @@ function drawPcbSmtPadElementsForLayer({
|
|
|
9318
9281
|
}
|
|
9319
9282
|
}
|
|
9320
9283
|
|
|
9284
|
+
// src/lib/draw-pcb-keepout.ts
|
|
9285
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer9 } from "circuit-to-canvas";
|
|
9286
|
+
function isPcbKeepout(element) {
|
|
9287
|
+
return element.type === "pcb_keepout";
|
|
9288
|
+
}
|
|
9289
|
+
function drawPcbKeepoutElementsForLayer({
|
|
9290
|
+
canvas,
|
|
9291
|
+
elements,
|
|
9292
|
+
layers,
|
|
9293
|
+
realToCanvasMat
|
|
9294
|
+
}) {
|
|
9295
|
+
const keepoutElements = elements.filter(isPcbKeepout);
|
|
9296
|
+
if (keepoutElements.length === 0) return;
|
|
9297
|
+
const drawer = new CircuitToCanvasDrawer9(canvas);
|
|
9298
|
+
drawer.realToCanvasMat = realToCanvasMat;
|
|
9299
|
+
drawer.drawElements(keepoutElements, { layers: [] });
|
|
9300
|
+
}
|
|
9301
|
+
|
|
9302
|
+
// src/lib/draw-via.ts
|
|
9303
|
+
import {
|
|
9304
|
+
DEFAULT_PCB_COLOR_MAP as DEFAULT_PCB_COLOR_MAP6,
|
|
9305
|
+
CircuitToCanvasDrawer as CircuitToCanvasDrawer10
|
|
9306
|
+
} from "circuit-to-canvas";
|
|
9307
|
+
import color4 from "color";
|
|
9308
|
+
var HOVER_COLOR_MAP3 = {
|
|
9309
|
+
...DEFAULT_PCB_COLOR_MAP6,
|
|
9310
|
+
copper: {
|
|
9311
|
+
...DEFAULT_PCB_COLOR_MAP6.copper,
|
|
9312
|
+
top: color4(colors_default.board.pad_front).lighten(0.5).toString(),
|
|
9313
|
+
bottom: color4(colors_default.board.pad_back).lighten(0.5).toString()
|
|
9314
|
+
}
|
|
9315
|
+
};
|
|
9316
|
+
function isPcbVia(element) {
|
|
9317
|
+
return element.type === "pcb_via";
|
|
9318
|
+
}
|
|
9319
|
+
function drawPcbViaElementsForLayer({
|
|
9320
|
+
canvas,
|
|
9321
|
+
elements,
|
|
9322
|
+
layers,
|
|
9323
|
+
realToCanvasMat,
|
|
9324
|
+
primitives
|
|
9325
|
+
}) {
|
|
9326
|
+
const viaElements = elements.filter(isPcbVia).filter((element) => {
|
|
9327
|
+
return layers.some((layer) => layer.includes("copper"));
|
|
9328
|
+
});
|
|
9329
|
+
if (viaElements.length === 0) return;
|
|
9330
|
+
const highlightedElementIds = /* @__PURE__ */ new Set();
|
|
9331
|
+
if (primitives) {
|
|
9332
|
+
for (const primitive of primitives) {
|
|
9333
|
+
if ((primitive.is_mouse_over || primitive.is_in_highlighted_net) && primitive._element?.type === "pcb_via") {
|
|
9334
|
+
highlightedElementIds.add(primitive._element.pcb_via_id);
|
|
9335
|
+
}
|
|
9336
|
+
}
|
|
9337
|
+
}
|
|
9338
|
+
const highlightedElements = viaElements.filter(
|
|
9339
|
+
(element) => highlightedElementIds.has(element.pcb_via_id)
|
|
9340
|
+
);
|
|
9341
|
+
const nonHighlightedElements = viaElements.filter(
|
|
9342
|
+
(element) => !highlightedElementIds.has(element.pcb_via_id)
|
|
9343
|
+
);
|
|
9344
|
+
if (nonHighlightedElements.length > 0) {
|
|
9345
|
+
const drawer = new CircuitToCanvasDrawer10(canvas);
|
|
9346
|
+
drawer.realToCanvasMat = realToCanvasMat;
|
|
9347
|
+
drawer.drawElements(nonHighlightedElements, { layers });
|
|
9348
|
+
}
|
|
9349
|
+
if (highlightedElements.length > 0) {
|
|
9350
|
+
const highlightDrawer = new CircuitToCanvasDrawer10(canvas);
|
|
9351
|
+
highlightDrawer.configure({ colorOverrides: HOVER_COLOR_MAP3 });
|
|
9352
|
+
highlightDrawer.realToCanvasMat = realToCanvasMat;
|
|
9353
|
+
highlightDrawer.drawElements(highlightedElements, { layers });
|
|
9354
|
+
}
|
|
9355
|
+
}
|
|
9356
|
+
|
|
9321
9357
|
// src/components/CanvasPrimitiveRenderer.tsx
|
|
9322
9358
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
9323
9359
|
var orderedLayers = [
|
|
@@ -9372,7 +9408,7 @@ var CanvasPrimitiveRenderer = ({
|
|
|
9372
9408
|
if (transform) drawer.transform = transform;
|
|
9373
9409
|
drawer.clear();
|
|
9374
9410
|
drawer.foregroundLayer = selectedLayer;
|
|
9375
|
-
const filteredPrimitives = primitives.filter((p) => isShowingSolderMask || !p.layer?.includes("soldermask")).filter((p) => p.layer !== "board").filter((p) => p._element?.type !== "pcb_smtpad").filter((p) => p._element?.type !== "pcb_plated_hole");
|
|
9411
|
+
const filteredPrimitives = primitives.filter((p) => isShowingSolderMask || !p.layer?.includes("soldermask")).filter((p) => p.layer !== "board").filter((p) => p._element?.type !== "pcb_smtpad").filter((p) => p._element?.type !== "pcb_plated_hole").filter((p) => p._element?.type !== "pcb_via");
|
|
9376
9412
|
drawPrimitives(drawer, filteredPrimitives);
|
|
9377
9413
|
if (transform) {
|
|
9378
9414
|
const topCanvas = canvasRefs.current.top;
|
|
@@ -9413,6 +9449,24 @@ var CanvasPrimitiveRenderer = ({
|
|
|
9413
9449
|
primitives
|
|
9414
9450
|
});
|
|
9415
9451
|
}
|
|
9452
|
+
if (topCanvas) {
|
|
9453
|
+
drawPcbViaElementsForLayer({
|
|
9454
|
+
canvas: topCanvas,
|
|
9455
|
+
elements,
|
|
9456
|
+
layers: ["top_copper"],
|
|
9457
|
+
realToCanvasMat: transform,
|
|
9458
|
+
primitives
|
|
9459
|
+
});
|
|
9460
|
+
}
|
|
9461
|
+
if (bottomCanvas) {
|
|
9462
|
+
drawPcbViaElementsForLayer({
|
|
9463
|
+
canvas: bottomCanvas,
|
|
9464
|
+
elements,
|
|
9465
|
+
layers: ["bottom_copper"],
|
|
9466
|
+
realToCanvasMat: transform,
|
|
9467
|
+
primitives
|
|
9468
|
+
});
|
|
9469
|
+
}
|
|
9416
9470
|
const topSilkscreenCanvas = canvasRefs.current.top_silkscreen;
|
|
9417
9471
|
if (topSilkscreenCanvas) {
|
|
9418
9472
|
drawSilkscreenElementsForLayer(
|
|
@@ -9484,6 +9538,22 @@ var CanvasPrimitiveRenderer = ({
|
|
|
9484
9538
|
transform
|
|
9485
9539
|
);
|
|
9486
9540
|
}
|
|
9541
|
+
if (topCanvas) {
|
|
9542
|
+
drawPcbKeepoutElementsForLayer({
|
|
9543
|
+
canvas: topCanvas,
|
|
9544
|
+
elements,
|
|
9545
|
+
layers: ["top"],
|
|
9546
|
+
realToCanvasMat: transform
|
|
9547
|
+
});
|
|
9548
|
+
}
|
|
9549
|
+
if (bottomCanvas) {
|
|
9550
|
+
drawPcbKeepoutElementsForLayer({
|
|
9551
|
+
canvas: bottomCanvas,
|
|
9552
|
+
elements,
|
|
9553
|
+
layers: ["bottom"],
|
|
9554
|
+
realToCanvasMat: transform
|
|
9555
|
+
});
|
|
9556
|
+
}
|
|
9487
9557
|
}
|
|
9488
9558
|
drawer.orderAndFadeLayers();
|
|
9489
9559
|
}, [primitives, elements, transform, selectedLayer, isShowingSolderMask]);
|
|
@@ -12084,7 +12154,7 @@ var HighlightedPrimitiveBoxWithText = ({
|
|
|
12084
12154
|
];
|
|
12085
12155
|
const si = primitive.same_space_index ?? 0;
|
|
12086
12156
|
const sip = 26;
|
|
12087
|
-
const
|
|
12157
|
+
const color5 = layerColorHightlightMap[primitive?._element?.layer] ?? "red";
|
|
12088
12158
|
let rotation = 0;
|
|
12089
12159
|
if (primitiveElement.type === "pcb_smtpad" && primitiveElement?.shape === "rotated_rect") {
|
|
12090
12160
|
rotation = primitiveElement?.ccw_rotation ?? 0;
|
|
@@ -12106,7 +12176,7 @@ var HighlightedPrimitiveBoxWithText = ({
|
|
|
12106
12176
|
position: "absolute",
|
|
12107
12177
|
left: mousePos.x,
|
|
12108
12178
|
top: yOffset,
|
|
12109
|
-
color:
|
|
12179
|
+
color: color5,
|
|
12110
12180
|
pointerEvents: "none",
|
|
12111
12181
|
transform: "translateX(-50%)"
|
|
12112
12182
|
},
|
|
@@ -12146,7 +12216,7 @@ var HighlightedPrimitiveBoxWithText = ({
|
|
|
12146
12216
|
top: y - h / 2 - 8,
|
|
12147
12217
|
width: w + 16,
|
|
12148
12218
|
height: h + 16,
|
|
12149
|
-
color:
|
|
12219
|
+
color: color5,
|
|
12150
12220
|
transform: `rotate(${-rotation}deg)`,
|
|
12151
12221
|
transformOrigin: "center center"
|
|
12152
12222
|
},
|
|
@@ -12162,7 +12232,7 @@ var HighlightedPrimitiveBoxWithText = ({
|
|
|
12162
12232
|
height: finalState ? `calc(100% + ${sip * 2 * si}px)` : "100%",
|
|
12163
12233
|
marginLeft: finalState ? `${-sip * si}px` : 0,
|
|
12164
12234
|
marginTop: finalState ? `${-sip * si}px` : 0,
|
|
12165
|
-
border: `1px solid ${
|
|
12235
|
+
border: `1px solid ${color5}`,
|
|
12166
12236
|
opacity: finalState ? 1 : si === 0 ? 1 : 0,
|
|
12167
12237
|
transition: "width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"
|
|
12168
12238
|
},
|
|
@@ -13521,7 +13591,7 @@ import { css as css3 } from "@emotion/css";
|
|
|
13521
13591
|
// package.json
|
|
13522
13592
|
var package_default = {
|
|
13523
13593
|
name: "@tscircuit/pcb-viewer",
|
|
13524
|
-
version: "1.11.
|
|
13594
|
+
version: "1.11.308",
|
|
13525
13595
|
main: "dist/index.js",
|
|
13526
13596
|
type: "module",
|
|
13527
13597
|
repository: "tscircuit/pcb-viewer",
|
|
@@ -13575,7 +13645,7 @@ var package_default = {
|
|
|
13575
13645
|
"@tscircuit/math-utils": "^0.0.29",
|
|
13576
13646
|
"@vitejs/plugin-react": "^5.0.2",
|
|
13577
13647
|
"circuit-json": "^0.0.353",
|
|
13578
|
-
"circuit-to-canvas": "^0.0.
|
|
13648
|
+
"circuit-to-canvas": "^0.0.43",
|
|
13579
13649
|
"circuit-to-svg": "^0.0.271",
|
|
13580
13650
|
color: "^4.2.3",
|
|
13581
13651
|
"react-supergrid": "^1.0.10",
|