@tscircuit/pcb-viewer 1.11.298 → 1.11.299

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
@@ -7718,57 +7718,6 @@ var convertElementToPrimitives = (element, allElements) => {
7718
7718
  });
7719
7719
  return primitives;
7720
7720
  }
7721
- case "pcb_fabrication_note_rect": {
7722
- const rectElement = element;
7723
- const layer = rectElement.layer === "bottom" ? "bottom_fabrication" : "top_fabrication";
7724
- const hasStroke = rectElement.has_stroke !== void 0 ? rectElement.has_stroke : typeof rectElement.stroke_width === "number" ? rectElement.stroke_width > 0 : void 0;
7725
- return [
7726
- {
7727
- _pcb_drawing_object_id: getNewPcbDrawingObjectId(
7728
- "pcb_fabrication_note_rect"
7729
- ),
7730
- pcb_drawing_type: "rect",
7731
- x: rectElement.center.x,
7732
- y: rectElement.center.y,
7733
- w: rectElement.width,
7734
- h: rectElement.height,
7735
- roundness: rectElement.corner_radius,
7736
- layer,
7737
- stroke_width: rectElement.stroke_width,
7738
- is_filled: rectElement.is_filled,
7739
- has_stroke: hasStroke,
7740
- is_stroke_dashed: rectElement.is_stroke_dashed,
7741
- color: rectElement.color,
7742
- _element: element,
7743
- _parent_pcb_component,
7744
- _parent_source_component,
7745
- _source_port
7746
- }
7747
- ];
7748
- }
7749
- case "pcb_fabrication_note_path": {
7750
- const { route } = element;
7751
- const layer = "top_fabrication";
7752
- return route.slice(0, -1).map((point, index) => {
7753
- const nextPoint = route[index + 1];
7754
- return {
7755
- _pcb_drawing_object_id: `line_${globalPcbDrawingObjectCount++}`,
7756
- pcb_drawing_type: "line",
7757
- x1: point.x,
7758
- y1: point.y,
7759
- x2: nextPoint.x,
7760
- y2: nextPoint.y,
7761
- width: element.stroke_width ?? 0.1,
7762
- squareCap: false,
7763
- layer,
7764
- color: element.color,
7765
- _element: element,
7766
- _parent_pcb_component,
7767
- _parent_source_component,
7768
- _source_port
7769
- };
7770
- }).filter(Boolean);
7771
- }
7772
7721
  case "pcb_copper_text": {
7773
7722
  return convertPcbCopperTextToPrimitive(element, {
7774
7723
  _parent_pcb_component,
@@ -7827,161 +7776,6 @@ var convertElementToPrimitives = (element, allElements) => {
7827
7776
  }
7828
7777
  return [];
7829
7778
  }
7830
- case "pcb_fabrication_note_dimension": {
7831
- const dimensionElement = element;
7832
- const { from, to, text, font_size, arrow_size } = dimensionElement;
7833
- const layer = element.layer === "bottom" ? "bottom_fabrication" : "top_fabrication";
7834
- const primitives = [];
7835
- const arrowSize = typeof arrow_size === "number" && !Number.isNaN(arrow_size) ? arrow_size : 1;
7836
- primitives.push({
7837
- _pcb_drawing_object_id: getNewPcbDrawingObjectId(
7838
- "pcb_fabrication_note_dimension"
7839
- ),
7840
- pcb_drawing_type: "line",
7841
- x1: from.x,
7842
- y1: from.y,
7843
- x2: to.x,
7844
- y2: to.y,
7845
- width: 0.05,
7846
- squareCap: false,
7847
- layer,
7848
- _element: element,
7849
- _parent_pcb_component,
7850
- _parent_source_component,
7851
- _source_port
7852
- });
7853
- const dx = to.x - from.x;
7854
- const dy = to.y - from.y;
7855
- const length = Math.sqrt(dx * dx + dy * dy) || 1;
7856
- const unitX = dx / length;
7857
- const unitY = dy / length;
7858
- const arrowAngle = Math.PI / 6;
7859
- const arrow1X1 = from.x + arrowSize * (unitX * Math.cos(arrowAngle) - unitY * Math.sin(arrowAngle));
7860
- const arrow1Y1 = from.y + arrowSize * (unitX * Math.sin(arrowAngle) + unitY * Math.cos(arrowAngle));
7861
- const arrow1X2 = from.x + arrowSize * (unitX * Math.cos(-arrowAngle) - unitY * Math.sin(-arrowAngle));
7862
- const arrow1Y2 = from.y + arrowSize * (unitX * Math.sin(-arrowAngle) + unitY * Math.cos(-arrowAngle));
7863
- primitives.push({
7864
- _pcb_drawing_object_id: getNewPcbDrawingObjectId(
7865
- "pcb_fabrication_note_dimension"
7866
- ),
7867
- pcb_drawing_type: "line",
7868
- x1: from.x,
7869
- y1: from.y,
7870
- x2: arrow1X1,
7871
- y2: arrow1Y1,
7872
- width: 0.05,
7873
- squareCap: false,
7874
- layer,
7875
- _element: element,
7876
- _parent_pcb_component,
7877
- _parent_source_component,
7878
- _source_port
7879
- });
7880
- primitives.push({
7881
- _pcb_drawing_object_id: getNewPcbDrawingObjectId(
7882
- "pcb_fabrication_note_dimension"
7883
- ),
7884
- pcb_drawing_type: "line",
7885
- x1: from.x,
7886
- y1: from.y,
7887
- x2: arrow1X2,
7888
- y2: arrow1Y2,
7889
- width: 0.05,
7890
- squareCap: false,
7891
- layer,
7892
- _element: element,
7893
- _parent_pcb_component,
7894
- _parent_source_component,
7895
- _source_port
7896
- });
7897
- const arrow2X1 = to.x - arrowSize * (unitX * Math.cos(arrowAngle) - unitY * Math.sin(arrowAngle));
7898
- const arrow2Y1 = to.y - arrowSize * (unitX * Math.sin(arrowAngle) + unitY * Math.cos(arrowAngle));
7899
- const arrow2X2 = to.x - arrowSize * (unitX * Math.cos(-arrowAngle) - unitY * Math.sin(-arrowAngle));
7900
- const arrow2Y2 = to.y - arrowSize * (unitX * Math.sin(-arrowAngle) + unitY * Math.cos(-arrowAngle));
7901
- primitives.push({
7902
- _pcb_drawing_object_id: getNewPcbDrawingObjectId(
7903
- "pcb_fabrication_note_dimension"
7904
- ),
7905
- pcb_drawing_type: "line",
7906
- x1: to.x,
7907
- y1: to.y,
7908
- x2: arrow2X1,
7909
- y2: arrow2Y1,
7910
- width: 0.05,
7911
- squareCap: false,
7912
- layer,
7913
- _element: element,
7914
- _parent_pcb_component,
7915
- _parent_source_component,
7916
- _source_port
7917
- });
7918
- primitives.push({
7919
- _pcb_drawing_object_id: getNewPcbDrawingObjectId(
7920
- "pcb_fabrication_note_dimension"
7921
- ),
7922
- pcb_drawing_type: "line",
7923
- x1: to.x,
7924
- y1: to.y,
7925
- x2: arrow2X2,
7926
- y2: arrow2Y2,
7927
- width: 0.05,
7928
- squareCap: false,
7929
- layer,
7930
- _element: element,
7931
- _parent_pcb_component,
7932
- _parent_source_component,
7933
- _source_port
7934
- });
7935
- if (text) {
7936
- const baseOffset = (font_size ?? 1) * 1.5;
7937
- const perpX = -unitY;
7938
- const perpY = unitX;
7939
- const midpointX = (from.x + to.x) / 2;
7940
- const midpointY = (from.y + to.y) / 2;
7941
- let textOffset = baseOffset;
7942
- if (Math.abs(unitX) > Math.abs(unitY)) {
7943
- textOffset = midpointY >= 0 ? baseOffset : -baseOffset;
7944
- } else {
7945
- textOffset = midpointX >= 0 ? -baseOffset : baseOffset;
7946
- }
7947
- primitives.push({
7948
- _pcb_drawing_object_id: getNewPcbDrawingObjectId(
7949
- "pcb_fabrication_note_dimension"
7950
- ),
7951
- pcb_drawing_type: "text",
7952
- x: (from.x + to.x) / 2 + perpX * textOffset,
7953
- y: (from.y + to.y) / 2 + perpY * textOffset,
7954
- layer,
7955
- align: "center",
7956
- text,
7957
- size: font_size,
7958
- _element: element,
7959
- _parent_pcb_component,
7960
- _parent_source_component,
7961
- _source_port
7962
- });
7963
- }
7964
- return primitives;
7965
- }
7966
- case "pcb_fabrication_note_text": {
7967
- return [
7968
- {
7969
- _pcb_drawing_object_id: getNewPcbDrawingObjectId("text"),
7970
- pcb_drawing_type: "text",
7971
- x: element.anchor_position.x,
7972
- y: element.anchor_position.y,
7973
- layer: element.layer === "bottom" ? "bottom_fabrication" : "top_fabrication",
7974
- size: element.font_size,
7975
- align: element.anchor_alignment ?? "center",
7976
- text: element.text,
7977
- color: element.color,
7978
- _element: element,
7979
- _parent_pcb_component,
7980
- _parent_source_component,
7981
- _source_port
7982
- }
7983
- ];
7984
- }
7985
7779
  case "pcb_cutout": {
7986
7780
  switch (element.shape) {
7987
7781
  case "rect": {
@@ -9441,6 +9235,31 @@ function drawPlatedHolePads(canvas, elements, layers, realToCanvasMat) {
9441
9235
  drawer.drawElements(platedHoleElements, { layers });
9442
9236
  }
9443
9237
 
9238
+ // src/lib/draw-fabrication-note.ts
9239
+ import {
9240
+ DEFAULT_PCB_COLOR_MAP as DEFAULT_PCB_COLOR_MAP2,
9241
+ CircuitToCanvasDrawer as CircuitToCanvasDrawer3
9242
+ } from "circuit-to-canvas";
9243
+ var PCB_VIEWER_COLOR_MAP2 = {
9244
+ ...DEFAULT_PCB_COLOR_MAP2,
9245
+ silkscreen: {
9246
+ top: colors_default.board.f_fab,
9247
+ bottom: colors_default.board.b_fab
9248
+ }
9249
+ };
9250
+ function isFabricationNote(element) {
9251
+ return element.type.includes("pcb_fabrication_note");
9252
+ }
9253
+ function drawFabricationNoteElementsForLayer(canvas, elements, layers, realToCanvasMat) {
9254
+ const drawer = new CircuitToCanvasDrawer3(canvas);
9255
+ drawer.configure({
9256
+ colorOverrides: PCB_VIEWER_COLOR_MAP2
9257
+ });
9258
+ drawer.realToCanvasMat = realToCanvasMat;
9259
+ const fabricationElements = elements.filter(isFabricationNote);
9260
+ drawer.drawElements(fabricationElements, { layers });
9261
+ }
9262
+
9444
9263
  // src/components/CanvasPrimitiveRenderer.tsx
9445
9264
  import { jsx as jsx3, jsxs } from "react/jsx-runtime";
9446
9265
  var orderedLayers = [
@@ -9453,6 +9272,8 @@ var orderedLayers = [
9453
9272
  "soldermask_with_copper_bottom",
9454
9273
  "soldermask_with_copper_top",
9455
9274
  "top_silkscreen",
9275
+ "top_fabrication",
9276
+ "bottom_fabrication",
9456
9277
  "inner1",
9457
9278
  "inner2",
9458
9279
  "inner3",
@@ -9520,6 +9341,24 @@ var CanvasPrimitiveRenderer = ({
9520
9341
  transform
9521
9342
  );
9522
9343
  }
9344
+ const topFabCanvas = canvasRefs.current.top_fabrication;
9345
+ if (topFabCanvas) {
9346
+ drawFabricationNoteElementsForLayer(
9347
+ topFabCanvas,
9348
+ elements,
9349
+ ["top_fabrication_note"],
9350
+ transform
9351
+ );
9352
+ }
9353
+ const bottomFabCanvas = canvasRefs.current.bottom_fabrication;
9354
+ if (bottomFabCanvas) {
9355
+ drawFabricationNoteElementsForLayer(
9356
+ bottomFabCanvas,
9357
+ elements,
9358
+ ["bottom_fabrication_note"],
9359
+ transform
9360
+ );
9361
+ }
9523
9362
  }
9524
9363
  drawer.orderAndFadeLayers();
9525
9364
  }, [primitives, elements, transform, selectedLayer, isShowingSolderMask]);
@@ -13557,7 +13396,7 @@ import { css as css3 } from "@emotion/css";
13557
13396
  // package.json
13558
13397
  var package_default = {
13559
13398
  name: "@tscircuit/pcb-viewer",
13560
- version: "1.11.297",
13399
+ version: "1.11.298",
13561
13400
  main: "dist/index.js",
13562
13401
  type: "module",
13563
13402
  repository: "tscircuit/pcb-viewer",
@@ -13611,7 +13450,7 @@ var package_default = {
13611
13450
  "@tscircuit/math-utils": "^0.0.29",
13612
13451
  "@vitejs/plugin-react": "^5.0.2",
13613
13452
  "circuit-json": "^0.0.347",
13614
- "circuit-to-canvas": "^0.0.31",
13453
+ "circuit-to-canvas": "^0.0.37",
13615
13454
  "circuit-to-svg": "^0.0.271",
13616
13455
  color: "^4.2.3",
13617
13456
  "react-supergrid": "^1.0.10",