@tscircuit/pcb-viewer 1.11.227 → 1.11.229
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 +206 -16
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -7812,6 +7812,180 @@ var convertElementToPrimitives = (element, allElements) => {
|
|
|
7812
7812
|
return [];
|
|
7813
7813
|
}
|
|
7814
7814
|
}
|
|
7815
|
+
case "pcb_note_line": {
|
|
7816
|
+
const noteLineElement = element;
|
|
7817
|
+
return [
|
|
7818
|
+
{
|
|
7819
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_line"),
|
|
7820
|
+
pcb_drawing_type: "line",
|
|
7821
|
+
x1: noteLineElement.x1,
|
|
7822
|
+
y1: noteLineElement.y1,
|
|
7823
|
+
x2: noteLineElement.x2,
|
|
7824
|
+
y2: noteLineElement.y2,
|
|
7825
|
+
width: noteLineElement.stroke_width ?? 0.1,
|
|
7826
|
+
squareCap: false,
|
|
7827
|
+
layer: "notes",
|
|
7828
|
+
_element: element,
|
|
7829
|
+
_parent_pcb_component,
|
|
7830
|
+
_parent_source_component
|
|
7831
|
+
}
|
|
7832
|
+
];
|
|
7833
|
+
}
|
|
7834
|
+
case "pcb_note_rect": {
|
|
7835
|
+
const noteRectElement = element;
|
|
7836
|
+
return [
|
|
7837
|
+
{
|
|
7838
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_rect"),
|
|
7839
|
+
pcb_drawing_type: "rect",
|
|
7840
|
+
x: noteRectElement.center.x,
|
|
7841
|
+
y: noteRectElement.center.y,
|
|
7842
|
+
w: noteRectElement.width,
|
|
7843
|
+
h: noteRectElement.height,
|
|
7844
|
+
layer: "notes",
|
|
7845
|
+
stroke_width: noteRectElement.stroke_width,
|
|
7846
|
+
is_filled: noteRectElement.is_filled,
|
|
7847
|
+
has_stroke: noteRectElement.has_stroke,
|
|
7848
|
+
is_stroke_dashed: noteRectElement.is_stroke_dashed,
|
|
7849
|
+
_element: element,
|
|
7850
|
+
_parent_pcb_component,
|
|
7851
|
+
_parent_source_component
|
|
7852
|
+
}
|
|
7853
|
+
];
|
|
7854
|
+
}
|
|
7855
|
+
case "pcb_note_path": {
|
|
7856
|
+
const notePathElement = element;
|
|
7857
|
+
const { route, stroke_width } = notePathElement;
|
|
7858
|
+
return route.slice(0, -1).map((point, index) => {
|
|
7859
|
+
const nextPoint = route[index + 1];
|
|
7860
|
+
return {
|
|
7861
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_path"),
|
|
7862
|
+
pcb_drawing_type: "line",
|
|
7863
|
+
x1: point.x,
|
|
7864
|
+
y1: point.y,
|
|
7865
|
+
x2: nextPoint.x,
|
|
7866
|
+
y2: nextPoint.y,
|
|
7867
|
+
width: stroke_width ?? 0.1,
|
|
7868
|
+
squareCap: false,
|
|
7869
|
+
layer: "notes",
|
|
7870
|
+
_element: element,
|
|
7871
|
+
_parent_pcb_component,
|
|
7872
|
+
_parent_source_component
|
|
7873
|
+
};
|
|
7874
|
+
}).filter(Boolean);
|
|
7875
|
+
}
|
|
7876
|
+
case "pcb_note_text": {
|
|
7877
|
+
const noteTextElement = element;
|
|
7878
|
+
return [
|
|
7879
|
+
{
|
|
7880
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_text"),
|
|
7881
|
+
pcb_drawing_type: "text",
|
|
7882
|
+
x: noteTextElement.anchor_position.x,
|
|
7883
|
+
y: noteTextElement.anchor_position.y,
|
|
7884
|
+
layer: "notes",
|
|
7885
|
+
align: noteTextElement.anchor_alignment ?? "center",
|
|
7886
|
+
text: noteTextElement.text,
|
|
7887
|
+
size: noteTextElement.font_size,
|
|
7888
|
+
_element: element,
|
|
7889
|
+
_parent_pcb_component,
|
|
7890
|
+
_parent_source_component
|
|
7891
|
+
}
|
|
7892
|
+
];
|
|
7893
|
+
}
|
|
7894
|
+
case "pcb_note_dimension": {
|
|
7895
|
+
const dimensionElement = element;
|
|
7896
|
+
const { from, to, text, font_size, arrow_size } = dimensionElement;
|
|
7897
|
+
const primitives = [];
|
|
7898
|
+
primitives.push({
|
|
7899
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_dimension"),
|
|
7900
|
+
pcb_drawing_type: "line",
|
|
7901
|
+
x1: from.x,
|
|
7902
|
+
y1: from.y,
|
|
7903
|
+
x2: to.x,
|
|
7904
|
+
y2: to.y,
|
|
7905
|
+
width: 0.05,
|
|
7906
|
+
squareCap: false,
|
|
7907
|
+
layer: "notes",
|
|
7908
|
+
_element: element,
|
|
7909
|
+
_parent_pcb_component,
|
|
7910
|
+
_parent_source_component
|
|
7911
|
+
});
|
|
7912
|
+
const dx = to.x - from.x;
|
|
7913
|
+
const dy = to.y - from.y;
|
|
7914
|
+
const length = Math.sqrt(dx * dx + dy * dy);
|
|
7915
|
+
const unitX = dx / length;
|
|
7916
|
+
const unitY = dy / length;
|
|
7917
|
+
const arrowAngle = Math.PI / 6;
|
|
7918
|
+
const arrow1X1 = from.x + arrow_size * (unitX * Math.cos(arrowAngle) - unitY * Math.sin(arrowAngle));
|
|
7919
|
+
const arrow1Y1 = from.y + arrow_size * (unitX * Math.sin(arrowAngle) + unitY * Math.cos(arrowAngle));
|
|
7920
|
+
const arrow1X2 = from.x + arrow_size * (unitX * Math.cos(-arrowAngle) - unitY * Math.sin(-arrowAngle));
|
|
7921
|
+
const arrow1Y2 = from.y + arrow_size * (unitX * Math.sin(-arrowAngle) + unitY * Math.cos(-arrowAngle));
|
|
7922
|
+
primitives.push({
|
|
7923
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_dimension"),
|
|
7924
|
+
pcb_drawing_type: "line",
|
|
7925
|
+
x1: from.x,
|
|
7926
|
+
y1: from.y,
|
|
7927
|
+
x2: arrow1X1,
|
|
7928
|
+
y2: arrow1Y1,
|
|
7929
|
+
width: 0.05,
|
|
7930
|
+
squareCap: false,
|
|
7931
|
+
layer: "notes",
|
|
7932
|
+
_element: element
|
|
7933
|
+
});
|
|
7934
|
+
primitives.push({
|
|
7935
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_dimension"),
|
|
7936
|
+
pcb_drawing_type: "line",
|
|
7937
|
+
x1: from.x,
|
|
7938
|
+
y1: from.y,
|
|
7939
|
+
x2: arrow1X2,
|
|
7940
|
+
y2: arrow1Y2,
|
|
7941
|
+
width: 0.05,
|
|
7942
|
+
squareCap: false,
|
|
7943
|
+
layer: "notes",
|
|
7944
|
+
_element: element
|
|
7945
|
+
});
|
|
7946
|
+
const arrow2X1 = to.x - arrow_size * (unitX * Math.cos(arrowAngle) - unitY * Math.sin(arrowAngle));
|
|
7947
|
+
const arrow2Y1 = to.y - arrow_size * (unitX * Math.sin(arrowAngle) + unitY * Math.cos(arrowAngle));
|
|
7948
|
+
const arrow2X2 = to.x - arrow_size * (unitX * Math.cos(-arrowAngle) - unitY * Math.sin(-arrowAngle));
|
|
7949
|
+
const arrow2Y2 = to.y - arrow_size * (unitX * Math.sin(-arrowAngle) + unitY * Math.cos(-arrowAngle));
|
|
7950
|
+
primitives.push({
|
|
7951
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_dimension"),
|
|
7952
|
+
pcb_drawing_type: "line",
|
|
7953
|
+
x1: to.x,
|
|
7954
|
+
y1: to.y,
|
|
7955
|
+
x2: arrow2X1,
|
|
7956
|
+
y2: arrow2Y1,
|
|
7957
|
+
width: 0.05,
|
|
7958
|
+
squareCap: false,
|
|
7959
|
+
layer: "notes",
|
|
7960
|
+
_element: element
|
|
7961
|
+
});
|
|
7962
|
+
primitives.push({
|
|
7963
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_dimension"),
|
|
7964
|
+
pcb_drawing_type: "line",
|
|
7965
|
+
x1: to.x,
|
|
7966
|
+
y1: to.y,
|
|
7967
|
+
x2: arrow2X2,
|
|
7968
|
+
y2: arrow2Y2,
|
|
7969
|
+
width: 0.05,
|
|
7970
|
+
squareCap: false,
|
|
7971
|
+
layer: "notes",
|
|
7972
|
+
_element: element
|
|
7973
|
+
});
|
|
7974
|
+
if (text) {
|
|
7975
|
+
primitives.push({
|
|
7976
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_dimension"),
|
|
7977
|
+
pcb_drawing_type: "text",
|
|
7978
|
+
x: (from.x + to.x) / 2,
|
|
7979
|
+
y: (from.y + to.y) / 2,
|
|
7980
|
+
layer: "notes",
|
|
7981
|
+
align: "center",
|
|
7982
|
+
text,
|
|
7983
|
+
size: font_size,
|
|
7984
|
+
_element: element
|
|
7985
|
+
});
|
|
7986
|
+
}
|
|
7987
|
+
return primitives;
|
|
7988
|
+
}
|
|
7815
7989
|
}
|
|
7816
7990
|
return [];
|
|
7817
7991
|
};
|
|
@@ -8110,6 +8284,7 @@ var LAYER_NAME_TO_COLOR = {
|
|
|
8110
8284
|
bottom_silkscreen: colors_default.board.b_silks,
|
|
8111
8285
|
top_fabrication: colors_default.board.f_fab,
|
|
8112
8286
|
bottom_fabrication: colors_default.board.b_fab,
|
|
8287
|
+
notes: colors_default.board.user_2,
|
|
8113
8288
|
...colors_default.board
|
|
8114
8289
|
};
|
|
8115
8290
|
var DEFAULT_DRAW_ORDER = [
|
|
@@ -8931,6 +9106,7 @@ var orderedLayers = [
|
|
|
8931
9106
|
"inner5",
|
|
8932
9107
|
"inner6",
|
|
8933
9108
|
"drill",
|
|
9109
|
+
"notes",
|
|
8934
9110
|
"other"
|
|
8935
9111
|
];
|
|
8936
9112
|
var CanvasPrimitiveRenderer = ({
|
|
@@ -11553,12 +11729,11 @@ import {
|
|
|
11553
11729
|
useRef as useRef10
|
|
11554
11730
|
} from "react";
|
|
11555
11731
|
import { css as css3 } from "@emotion/css";
|
|
11556
|
-
import { all_layers } from "circuit-json";
|
|
11557
11732
|
|
|
11558
11733
|
// package.json
|
|
11559
11734
|
var package_default = {
|
|
11560
11735
|
name: "@tscircuit/pcb-viewer",
|
|
11561
|
-
version: "1.11.
|
|
11736
|
+
version: "1.11.228",
|
|
11562
11737
|
main: "dist/index.js",
|
|
11563
11738
|
type: "module",
|
|
11564
11739
|
repository: "tscircuit/pcb-viewer",
|
|
@@ -11595,7 +11770,7 @@ var package_default = {
|
|
|
11595
11770
|
"react-cosmos-plugin-vite": "7.0.0-beta.0",
|
|
11596
11771
|
"react-dom": "19.1.0",
|
|
11597
11772
|
"react-use": "^17.4.0",
|
|
11598
|
-
tscircuit: "^0.0.
|
|
11773
|
+
tscircuit: "^0.0.758",
|
|
11599
11774
|
tsup: "^8.0.2",
|
|
11600
11775
|
"type-fest": "^3.0.0",
|
|
11601
11776
|
typescript: "^5.4.4",
|
|
@@ -11609,7 +11784,7 @@ var package_default = {
|
|
|
11609
11784
|
dependencies: {
|
|
11610
11785
|
"@emotion/css": "^11.11.2",
|
|
11611
11786
|
"@vitejs/plugin-react": "^5.0.2",
|
|
11612
|
-
"circuit-json": "^0.0.
|
|
11787
|
+
"circuit-json": "^0.0.279",
|
|
11613
11788
|
"circuit-to-svg": "^0.0.191",
|
|
11614
11789
|
color: "^4.2.3",
|
|
11615
11790
|
"react-supergrid": "^1.0.10",
|
|
@@ -11866,15 +12041,33 @@ var ToolbarOverlay = ({ children, elements }) => {
|
|
|
11866
12041
|
window.removeEventListener("disarm-dimension-tool", disarm);
|
|
11867
12042
|
};
|
|
11868
12043
|
}, []);
|
|
12044
|
+
const errorCount = elements?.filter((e) => e.type.includes("error")).length ?? 0;
|
|
12045
|
+
const errorElements = elements?.filter((el) => el.type.includes("error")) || [];
|
|
12046
|
+
const pcbBoard = elements?.find((el) => el.type === "pcb_board");
|
|
12047
|
+
const numLayers = pcbBoard?.num_layers || 2;
|
|
12048
|
+
const availableLayers = numLayers <= 2 ? ["top", "bottom"] : [
|
|
12049
|
+
"top",
|
|
12050
|
+
...Array.from({ length: numLayers - 2 }, (_, i) => `inner${i + 1}`),
|
|
12051
|
+
"bottom"
|
|
12052
|
+
];
|
|
12053
|
+
const processedLayers = availableLayers;
|
|
11869
12054
|
const hotKeyCallbacks = {
|
|
11870
|
-
"1": () => selectLayer(
|
|
11871
|
-
|
|
11872
|
-
"
|
|
11873
|
-
|
|
11874
|
-
"
|
|
11875
|
-
|
|
11876
|
-
"
|
|
11877
|
-
|
|
12055
|
+
"1": availableLayers[0] ? () => selectLayer(availableLayers[0]) : () => {
|
|
12056
|
+
},
|
|
12057
|
+
"2": availableLayers[1] ? () => selectLayer(availableLayers[1]) : () => {
|
|
12058
|
+
},
|
|
12059
|
+
"3": availableLayers[2] ? () => selectLayer(availableLayers[2]) : () => {
|
|
12060
|
+
},
|
|
12061
|
+
"4": availableLayers[3] ? () => selectLayer(availableLayers[3]) : () => {
|
|
12062
|
+
},
|
|
12063
|
+
"5": availableLayers[4] ? () => selectLayer(availableLayers[4]) : () => {
|
|
12064
|
+
},
|
|
12065
|
+
"6": availableLayers[5] ? () => selectLayer(availableLayers[5]) : () => {
|
|
12066
|
+
},
|
|
12067
|
+
"7": availableLayers[6] ? () => selectLayer(availableLayers[6]) : () => {
|
|
12068
|
+
},
|
|
12069
|
+
"8": availableLayers[7] ? () => selectLayer(availableLayers[7]) : () => {
|
|
12070
|
+
}
|
|
11878
12071
|
};
|
|
11879
12072
|
useHotKey("1", hotKeyCallbacks["1"]);
|
|
11880
12073
|
useHotKey("2", hotKeyCallbacks["2"]);
|
|
@@ -11884,9 +12077,6 @@ var ToolbarOverlay = ({ children, elements }) => {
|
|
|
11884
12077
|
useHotKey("6", hotKeyCallbacks["6"]);
|
|
11885
12078
|
useHotKey("7", hotKeyCallbacks["7"]);
|
|
11886
12079
|
useHotKey("8", hotKeyCallbacks["8"]);
|
|
11887
|
-
const errorCount = elements?.filter((e) => e.type.includes("error")).length ?? 0;
|
|
11888
|
-
const errorElements = elements?.filter((el) => el.type.includes("error")) || [];
|
|
11889
|
-
const processedLayers = all_layers.map((l) => l.replace(/-/g, ""));
|
|
11890
12080
|
const handleMouseEnter = useCallback3(() => {
|
|
11891
12081
|
setIsMouseOverContainer(true);
|
|
11892
12082
|
}, [setIsMouseOverContainer]);
|
|
@@ -12014,7 +12204,7 @@ var ToolbarOverlay = ({ children, elements }) => {
|
|
|
12014
12204
|
name: layer,
|
|
12015
12205
|
selected: layer === selectedLayer,
|
|
12016
12206
|
onClick: () => {
|
|
12017
|
-
selectLayer(layer
|
|
12207
|
+
selectLayer(layer);
|
|
12018
12208
|
}
|
|
12019
12209
|
},
|
|
12020
12210
|
layer
|