@tscircuit/pcb-viewer 1.11.301 → 1.11.303

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
@@ -7393,120 +7393,6 @@ var convertElementToPrimitives = (element, allElements) => {
7393
7393
  }
7394
7394
  ];
7395
7395
  }
7396
- case "pcb_board": {
7397
- const { width, height, center, outline } = element;
7398
- const primitives = [];
7399
- const hasSolderMask = allElements.some(
7400
- (elm) => elm.type === "pcb_smtpad" && elm.is_covered_with_solder_mask === true
7401
- );
7402
- if (hasSolderMask) {
7403
- if (outline && outline.length > 2) {
7404
- primitives.push({
7405
- _pcb_drawing_object_id: `polygon_${globalPcbDrawingObjectCount++}`,
7406
- pcb_drawing_type: "polygon",
7407
- points: normalizePolygonPoints(outline),
7408
- layer: "soldermask_top",
7409
- _element: element
7410
- });
7411
- primitives.push({
7412
- _pcb_drawing_object_id: `polygon_${globalPcbDrawingObjectCount++}`,
7413
- pcb_drawing_type: "polygon",
7414
- points: normalizePolygonPoints(outline),
7415
- layer: "soldermask_bottom",
7416
- _element: element
7417
- });
7418
- } else if (width && height) {
7419
- primitives.push({
7420
- _pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
7421
- pcb_drawing_type: "rect",
7422
- x: center.x,
7423
- y: center.y,
7424
- w: width,
7425
- h: height,
7426
- layer: "soldermask_top",
7427
- _element: element
7428
- });
7429
- primitives.push({
7430
- _pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
7431
- pcb_drawing_type: "rect",
7432
- x: center.x,
7433
- y: center.y,
7434
- w: width,
7435
- h: height,
7436
- layer: "soldermask_bottom",
7437
- _element: element
7438
- });
7439
- }
7440
- }
7441
- if (outline && outline.length > 2) {
7442
- primitives.push(
7443
- ...outline.map((point, index, array) => ({
7444
- _pcb_drawing_object_id: `line_${globalPcbDrawingObjectCount++}`,
7445
- pcb_drawing_type: "line",
7446
- x1: point.x,
7447
- y1: point.y,
7448
- x2: index === array.length - 1 ? array[0].x : array[index + 1].x,
7449
- y2: index === array.length - 1 ? array[0].y : array[index + 1].y,
7450
- width: 1,
7451
- zoomIndependent: true,
7452
- layer: "board",
7453
- _element: element
7454
- }))
7455
- );
7456
- } else {
7457
- primitives.push(
7458
- {
7459
- _pcb_drawing_object_id: `line_${globalPcbDrawingObjectCount++}`,
7460
- pcb_drawing_type: "line",
7461
- x1: center.x - width / 2,
7462
- y1: center.y - height / 2,
7463
- x2: center.x + width / 2,
7464
- y2: center.y - height / 2,
7465
- width: 1,
7466
- zoomIndependent: true,
7467
- layer: "board",
7468
- _element: element
7469
- },
7470
- {
7471
- _pcb_drawing_object_id: `line_${globalPcbDrawingObjectCount++}`,
7472
- pcb_drawing_type: "line",
7473
- x1: center.x - width / 2,
7474
- y1: center.y + height / 2,
7475
- x2: center.x + width / 2,
7476
- y2: center.y + height / 2,
7477
- width: 1,
7478
- zoomIndependent: true,
7479
- layer: "board",
7480
- _element: element
7481
- },
7482
- {
7483
- _pcb_drawing_object_id: `line_${globalPcbDrawingObjectCount++}`,
7484
- pcb_drawing_type: "line",
7485
- x1: center.x - width / 2,
7486
- y1: center.y - height / 2,
7487
- x2: center.x - width / 2,
7488
- y2: center.y + height / 2,
7489
- width: 1,
7490
- zoomIndependent: true,
7491
- layer: "board",
7492
- _element: element
7493
- },
7494
- {
7495
- _pcb_drawing_object_id: `line_${globalPcbDrawingObjectCount++}`,
7496
- pcb_drawing_type: "line",
7497
- x1: center.x + width / 2,
7498
- y1: center.y - height / 2,
7499
- x2: center.x + width / 2,
7500
- y2: center.y + height / 2,
7501
- width: 1,
7502
- zoomIndependent: true,
7503
- layer: "board",
7504
- _element: element
7505
- }
7506
- );
7507
- }
7508
- return primitives;
7509
- }
7510
7396
  case "pcb_smtpad": {
7511
7397
  const metadata = {
7512
7398
  _parent_pcb_component,
@@ -7526,64 +7412,6 @@ var convertElementToPrimitives = (element, allElements) => {
7526
7412
  }
7527
7413
  return [];
7528
7414
  }
7529
- case "pcb_hole": {
7530
- if (element.hole_shape === "circle" || !element.hole_shape) {
7531
- const { x, y, hole_diameter } = element;
7532
- return [
7533
- {
7534
- _pcb_drawing_object_id: `circle_${globalPcbDrawingObjectCount++}`,
7535
- pcb_drawing_type: "circle",
7536
- x,
7537
- y,
7538
- r: hole_diameter / 2,
7539
- layer: "drill",
7540
- _element: element,
7541
- _parent_pcb_component,
7542
- _parent_source_component
7543
- }
7544
- ];
7545
- } else if (element.hole_shape === "pill" || element.hole_shape === "rotated_pill") {
7546
- const { x, y, hole_width, hole_height } = element;
7547
- if (typeof hole_width !== "number" || typeof hole_height !== "number") {
7548
- return [];
7549
- }
7550
- return [
7551
- {
7552
- _pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
7553
- pcb_drawing_type: "pill",
7554
- x,
7555
- y,
7556
- w: hole_width,
7557
- h: hole_height,
7558
- layer: "drill",
7559
- _element: element,
7560
- _parent_pcb_component,
7561
- _parent_source_component,
7562
- ccw_rotation: element.ccw_rotation
7563
- }
7564
- ];
7565
- } else if (element.hole_shape === "rect") {
7566
- const { x, y, hole_width, hole_height } = element;
7567
- if (typeof hole_width !== "number" || typeof hole_height !== "number") {
7568
- return [];
7569
- }
7570
- return [
7571
- {
7572
- _pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
7573
- pcb_drawing_type: "rect",
7574
- x,
7575
- y,
7576
- w: hole_width,
7577
- h: hole_height,
7578
- layer: "drill",
7579
- _element: element,
7580
- _parent_pcb_component,
7581
- _parent_source_component
7582
- }
7583
- ];
7584
- }
7585
- return [];
7586
- }
7587
7415
  case "pcb_keepout": {
7588
7416
  if (element.shape === "circle") {
7589
7417
  const { center, radius } = element;
@@ -9084,6 +8912,30 @@ function drawPcbNoteElementsForLayer(canvas, elements, layers, realToCanvasMat)
9084
8912
  drawer.drawElements(pcbNoteElements, { layers });
9085
8913
  }
9086
8914
 
8915
+ // src/lib/draw-hole.ts
8916
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer5 } from "circuit-to-canvas";
8917
+ function isPcbHole(element) {
8918
+ return element.type === "pcb_hole";
8919
+ }
8920
+ function drawPcbHoleElementsForLayer(canvas, elements, layers, realToCanvasMat) {
8921
+ const drawer = new CircuitToCanvasDrawer5(canvas);
8922
+ drawer.realToCanvasMat = realToCanvasMat;
8923
+ const holeElements = elements.filter(isPcbHole);
8924
+ drawer.drawElements(holeElements, { layers });
8925
+ }
8926
+
8927
+ // src/lib/draw-pcb-board.ts
8928
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer6 } from "circuit-to-canvas";
8929
+ function isPcbBoardElement(element) {
8930
+ return element.type === "pcb_board";
8931
+ }
8932
+ function drawPcbBoardElements(canvas, elements, layers, realToCanvasMat) {
8933
+ const drawer = new CircuitToCanvasDrawer6(canvas);
8934
+ drawer.realToCanvasMat = realToCanvasMat;
8935
+ const pcbBoardElements = elements.filter(isPcbBoardElement);
8936
+ drawer.drawElements(pcbBoardElements, { layers });
8937
+ }
8938
+
9087
8939
  // src/components/CanvasPrimitiveRenderer.tsx
9088
8940
  import { jsx as jsx3, jsxs } from "react/jsx-runtime";
9089
8941
  var orderedLayers = [
@@ -9137,7 +8989,7 @@ var CanvasPrimitiveRenderer = ({
9137
8989
  if (transform) drawer.transform = transform;
9138
8990
  drawer.clear();
9139
8991
  drawer.foregroundLayer = selectedLayer;
9140
- const filteredPrimitives = isShowingSolderMask ? primitives : primitives.filter((p) => !p.layer?.includes("soldermask"));
8992
+ const filteredPrimitives = primitives.filter((p) => isShowingSolderMask || !p.layer?.includes("soldermask")).filter((p) => p.layer !== "board");
9141
8993
  drawPrimitives(drawer, filteredPrimitives);
9142
8994
  if (transform) {
9143
8995
  const topCanvas = canvasRefs.current.top;
@@ -9202,6 +9054,14 @@ var CanvasPrimitiveRenderer = ({
9202
9054
  transform
9203
9055
  );
9204
9056
  }
9057
+ const drillCanvas = canvasRefs.current.drill;
9058
+ if (drillCanvas) {
9059
+ drawPcbHoleElementsForLayer(drillCanvas, elements, ["drill"], transform);
9060
+ }
9061
+ const boardCanvas = canvasRefs.current.board;
9062
+ if (boardCanvas) {
9063
+ drawPcbBoardElements(boardCanvas, elements, [], transform);
9064
+ }
9205
9065
  }
9206
9066
  drawer.orderAndFadeLayers();
9207
9067
  }, [primitives, elements, transform, selectedLayer, isShowingSolderMask]);
@@ -13239,7 +13099,7 @@ import { css as css3 } from "@emotion/css";
13239
13099
  // package.json
13240
13100
  var package_default = {
13241
13101
  name: "@tscircuit/pcb-viewer",
13242
- version: "1.11.300",
13102
+ version: "1.11.302",
13243
13103
  main: "dist/index.js",
13244
13104
  type: "module",
13245
13105
  repository: "tscircuit/pcb-viewer",
@@ -13292,7 +13152,7 @@ var package_default = {
13292
13152
  "@tscircuit/alphabet": "^0.0.9",
13293
13153
  "@tscircuit/math-utils": "^0.0.29",
13294
13154
  "@vitejs/plugin-react": "^5.0.2",
13295
- "circuit-json": "^0.0.351",
13155
+ "circuit-json": "^0.0.353",
13296
13156
  "circuit-to-canvas": "^0.0.37",
13297
13157
  "circuit-to-svg": "^0.0.271",
13298
13158
  color: "^4.2.3",