@tscircuit/pcb-viewer 1.11.228 → 1.11.230
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 +305 -4
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -7746,6 +7746,131 @@ var convertElementToPrimitives = (element, allElements) => {
|
|
|
7746
7746
|
}
|
|
7747
7747
|
return [];
|
|
7748
7748
|
}
|
|
7749
|
+
case "pcb_fabrication_note_dimension": {
|
|
7750
|
+
const dimensionElement = element;
|
|
7751
|
+
const { from, to, text, font_size, arrow_size } = dimensionElement;
|
|
7752
|
+
const layer = element.layer === "bottom" ? "bottom_fabrication" : "top_fabrication";
|
|
7753
|
+
const primitives = [];
|
|
7754
|
+
const arrowSize = typeof arrow_size === "number" && !Number.isNaN(arrow_size) ? arrow_size : 1;
|
|
7755
|
+
primitives.push({
|
|
7756
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId(
|
|
7757
|
+
"pcb_fabrication_note_dimension"
|
|
7758
|
+
),
|
|
7759
|
+
pcb_drawing_type: "line",
|
|
7760
|
+
x1: from.x,
|
|
7761
|
+
y1: from.y,
|
|
7762
|
+
x2: to.x,
|
|
7763
|
+
y2: to.y,
|
|
7764
|
+
width: 0.05,
|
|
7765
|
+
squareCap: false,
|
|
7766
|
+
layer,
|
|
7767
|
+
_element: element,
|
|
7768
|
+
_parent_pcb_component,
|
|
7769
|
+
_parent_source_component,
|
|
7770
|
+
_source_port
|
|
7771
|
+
});
|
|
7772
|
+
const dx = to.x - from.x;
|
|
7773
|
+
const dy = to.y - from.y;
|
|
7774
|
+
const length = Math.sqrt(dx * dx + dy * dy) || 1;
|
|
7775
|
+
const unitX = dx / length;
|
|
7776
|
+
const unitY = dy / length;
|
|
7777
|
+
const arrowAngle = Math.PI / 6;
|
|
7778
|
+
const arrow1X1 = from.x + arrowSize * (unitX * Math.cos(arrowAngle) - unitY * Math.sin(arrowAngle));
|
|
7779
|
+
const arrow1Y1 = from.y + arrowSize * (unitX * Math.sin(arrowAngle) + unitY * Math.cos(arrowAngle));
|
|
7780
|
+
const arrow1X2 = from.x + arrowSize * (unitX * Math.cos(-arrowAngle) - unitY * Math.sin(-arrowAngle));
|
|
7781
|
+
const arrow1Y2 = from.y + arrowSize * (unitX * Math.sin(-arrowAngle) + unitY * Math.cos(-arrowAngle));
|
|
7782
|
+
primitives.push({
|
|
7783
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId(
|
|
7784
|
+
"pcb_fabrication_note_dimension"
|
|
7785
|
+
),
|
|
7786
|
+
pcb_drawing_type: "line",
|
|
7787
|
+
x1: from.x,
|
|
7788
|
+
y1: from.y,
|
|
7789
|
+
x2: arrow1X1,
|
|
7790
|
+
y2: arrow1Y1,
|
|
7791
|
+
width: 0.05,
|
|
7792
|
+
squareCap: false,
|
|
7793
|
+
layer,
|
|
7794
|
+
_element: element,
|
|
7795
|
+
_parent_pcb_component,
|
|
7796
|
+
_parent_source_component,
|
|
7797
|
+
_source_port
|
|
7798
|
+
});
|
|
7799
|
+
primitives.push({
|
|
7800
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId(
|
|
7801
|
+
"pcb_fabrication_note_dimension"
|
|
7802
|
+
),
|
|
7803
|
+
pcb_drawing_type: "line",
|
|
7804
|
+
x1: from.x,
|
|
7805
|
+
y1: from.y,
|
|
7806
|
+
x2: arrow1X2,
|
|
7807
|
+
y2: arrow1Y2,
|
|
7808
|
+
width: 0.05,
|
|
7809
|
+
squareCap: false,
|
|
7810
|
+
layer,
|
|
7811
|
+
_element: element,
|
|
7812
|
+
_parent_pcb_component,
|
|
7813
|
+
_parent_source_component,
|
|
7814
|
+
_source_port
|
|
7815
|
+
});
|
|
7816
|
+
const arrow2X1 = to.x - arrowSize * (unitX * Math.cos(arrowAngle) - unitY * Math.sin(arrowAngle));
|
|
7817
|
+
const arrow2Y1 = to.y - arrowSize * (unitX * Math.sin(arrowAngle) + unitY * Math.cos(arrowAngle));
|
|
7818
|
+
const arrow2X2 = to.x - arrowSize * (unitX * Math.cos(-arrowAngle) - unitY * Math.sin(-arrowAngle));
|
|
7819
|
+
const arrow2Y2 = to.y - arrowSize * (unitX * Math.sin(-arrowAngle) + unitY * Math.cos(-arrowAngle));
|
|
7820
|
+
primitives.push({
|
|
7821
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId(
|
|
7822
|
+
"pcb_fabrication_note_dimension"
|
|
7823
|
+
),
|
|
7824
|
+
pcb_drawing_type: "line",
|
|
7825
|
+
x1: to.x,
|
|
7826
|
+
y1: to.y,
|
|
7827
|
+
x2: arrow2X1,
|
|
7828
|
+
y2: arrow2Y1,
|
|
7829
|
+
width: 0.05,
|
|
7830
|
+
squareCap: false,
|
|
7831
|
+
layer,
|
|
7832
|
+
_element: element,
|
|
7833
|
+
_parent_pcb_component,
|
|
7834
|
+
_parent_source_component,
|
|
7835
|
+
_source_port
|
|
7836
|
+
});
|
|
7837
|
+
primitives.push({
|
|
7838
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId(
|
|
7839
|
+
"pcb_fabrication_note_dimension"
|
|
7840
|
+
),
|
|
7841
|
+
pcb_drawing_type: "line",
|
|
7842
|
+
x1: to.x,
|
|
7843
|
+
y1: to.y,
|
|
7844
|
+
x2: arrow2X2,
|
|
7845
|
+
y2: arrow2Y2,
|
|
7846
|
+
width: 0.05,
|
|
7847
|
+
squareCap: false,
|
|
7848
|
+
layer,
|
|
7849
|
+
_element: element,
|
|
7850
|
+
_parent_pcb_component,
|
|
7851
|
+
_parent_source_component,
|
|
7852
|
+
_source_port
|
|
7853
|
+
});
|
|
7854
|
+
if (text) {
|
|
7855
|
+
primitives.push({
|
|
7856
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId(
|
|
7857
|
+
"pcb_fabrication_note_dimension"
|
|
7858
|
+
),
|
|
7859
|
+
pcb_drawing_type: "text",
|
|
7860
|
+
x: (from.x + to.x) / 2,
|
|
7861
|
+
y: (from.y + to.y) / 2,
|
|
7862
|
+
layer,
|
|
7863
|
+
align: "center",
|
|
7864
|
+
text,
|
|
7865
|
+
size: font_size,
|
|
7866
|
+
_element: element,
|
|
7867
|
+
_parent_pcb_component,
|
|
7868
|
+
_parent_source_component,
|
|
7869
|
+
_source_port
|
|
7870
|
+
});
|
|
7871
|
+
}
|
|
7872
|
+
return primitives;
|
|
7873
|
+
}
|
|
7749
7874
|
case "pcb_fabrication_note_text": {
|
|
7750
7875
|
return [
|
|
7751
7876
|
{
|
|
@@ -7812,6 +7937,180 @@ var convertElementToPrimitives = (element, allElements) => {
|
|
|
7812
7937
|
return [];
|
|
7813
7938
|
}
|
|
7814
7939
|
}
|
|
7940
|
+
case "pcb_note_line": {
|
|
7941
|
+
const noteLineElement = element;
|
|
7942
|
+
return [
|
|
7943
|
+
{
|
|
7944
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_line"),
|
|
7945
|
+
pcb_drawing_type: "line",
|
|
7946
|
+
x1: noteLineElement.x1,
|
|
7947
|
+
y1: noteLineElement.y1,
|
|
7948
|
+
x2: noteLineElement.x2,
|
|
7949
|
+
y2: noteLineElement.y2,
|
|
7950
|
+
width: noteLineElement.stroke_width ?? 0.1,
|
|
7951
|
+
squareCap: false,
|
|
7952
|
+
layer: "notes",
|
|
7953
|
+
_element: element,
|
|
7954
|
+
_parent_pcb_component,
|
|
7955
|
+
_parent_source_component
|
|
7956
|
+
}
|
|
7957
|
+
];
|
|
7958
|
+
}
|
|
7959
|
+
case "pcb_note_rect": {
|
|
7960
|
+
const noteRectElement = element;
|
|
7961
|
+
return [
|
|
7962
|
+
{
|
|
7963
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_rect"),
|
|
7964
|
+
pcb_drawing_type: "rect",
|
|
7965
|
+
x: noteRectElement.center.x,
|
|
7966
|
+
y: noteRectElement.center.y,
|
|
7967
|
+
w: noteRectElement.width,
|
|
7968
|
+
h: noteRectElement.height,
|
|
7969
|
+
layer: "notes",
|
|
7970
|
+
stroke_width: noteRectElement.stroke_width,
|
|
7971
|
+
is_filled: noteRectElement.is_filled,
|
|
7972
|
+
has_stroke: noteRectElement.has_stroke,
|
|
7973
|
+
is_stroke_dashed: noteRectElement.is_stroke_dashed,
|
|
7974
|
+
_element: element,
|
|
7975
|
+
_parent_pcb_component,
|
|
7976
|
+
_parent_source_component
|
|
7977
|
+
}
|
|
7978
|
+
];
|
|
7979
|
+
}
|
|
7980
|
+
case "pcb_note_path": {
|
|
7981
|
+
const notePathElement = element;
|
|
7982
|
+
const { route, stroke_width } = notePathElement;
|
|
7983
|
+
return route.slice(0, -1).map((point, index) => {
|
|
7984
|
+
const nextPoint = route[index + 1];
|
|
7985
|
+
return {
|
|
7986
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_path"),
|
|
7987
|
+
pcb_drawing_type: "line",
|
|
7988
|
+
x1: point.x,
|
|
7989
|
+
y1: point.y,
|
|
7990
|
+
x2: nextPoint.x,
|
|
7991
|
+
y2: nextPoint.y,
|
|
7992
|
+
width: stroke_width ?? 0.1,
|
|
7993
|
+
squareCap: false,
|
|
7994
|
+
layer: "notes",
|
|
7995
|
+
_element: element,
|
|
7996
|
+
_parent_pcb_component,
|
|
7997
|
+
_parent_source_component
|
|
7998
|
+
};
|
|
7999
|
+
}).filter(Boolean);
|
|
8000
|
+
}
|
|
8001
|
+
case "pcb_note_text": {
|
|
8002
|
+
const noteTextElement = element;
|
|
8003
|
+
return [
|
|
8004
|
+
{
|
|
8005
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_text"),
|
|
8006
|
+
pcb_drawing_type: "text",
|
|
8007
|
+
x: noteTextElement.anchor_position.x,
|
|
8008
|
+
y: noteTextElement.anchor_position.y,
|
|
8009
|
+
layer: "notes",
|
|
8010
|
+
align: noteTextElement.anchor_alignment ?? "center",
|
|
8011
|
+
text: noteTextElement.text,
|
|
8012
|
+
size: noteTextElement.font_size,
|
|
8013
|
+
_element: element,
|
|
8014
|
+
_parent_pcb_component,
|
|
8015
|
+
_parent_source_component
|
|
8016
|
+
}
|
|
8017
|
+
];
|
|
8018
|
+
}
|
|
8019
|
+
case "pcb_note_dimension": {
|
|
8020
|
+
const dimensionElement = element;
|
|
8021
|
+
const { from, to, text, font_size, arrow_size } = dimensionElement;
|
|
8022
|
+
const primitives = [];
|
|
8023
|
+
primitives.push({
|
|
8024
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_dimension"),
|
|
8025
|
+
pcb_drawing_type: "line",
|
|
8026
|
+
x1: from.x,
|
|
8027
|
+
y1: from.y,
|
|
8028
|
+
x2: to.x,
|
|
8029
|
+
y2: to.y,
|
|
8030
|
+
width: 0.05,
|
|
8031
|
+
squareCap: false,
|
|
8032
|
+
layer: "notes",
|
|
8033
|
+
_element: element,
|
|
8034
|
+
_parent_pcb_component,
|
|
8035
|
+
_parent_source_component
|
|
8036
|
+
});
|
|
8037
|
+
const dx = to.x - from.x;
|
|
8038
|
+
const dy = to.y - from.y;
|
|
8039
|
+
const length = Math.sqrt(dx * dx + dy * dy);
|
|
8040
|
+
const unitX = dx / length;
|
|
8041
|
+
const unitY = dy / length;
|
|
8042
|
+
const arrowAngle = Math.PI / 6;
|
|
8043
|
+
const arrow1X1 = from.x + arrow_size * (unitX * Math.cos(arrowAngle) - unitY * Math.sin(arrowAngle));
|
|
8044
|
+
const arrow1Y1 = from.y + arrow_size * (unitX * Math.sin(arrowAngle) + unitY * Math.cos(arrowAngle));
|
|
8045
|
+
const arrow1X2 = from.x + arrow_size * (unitX * Math.cos(-arrowAngle) - unitY * Math.sin(-arrowAngle));
|
|
8046
|
+
const arrow1Y2 = from.y + arrow_size * (unitX * Math.sin(-arrowAngle) + unitY * Math.cos(-arrowAngle));
|
|
8047
|
+
primitives.push({
|
|
8048
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_dimension"),
|
|
8049
|
+
pcb_drawing_type: "line",
|
|
8050
|
+
x1: from.x,
|
|
8051
|
+
y1: from.y,
|
|
8052
|
+
x2: arrow1X1,
|
|
8053
|
+
y2: arrow1Y1,
|
|
8054
|
+
width: 0.05,
|
|
8055
|
+
squareCap: false,
|
|
8056
|
+
layer: "notes",
|
|
8057
|
+
_element: element
|
|
8058
|
+
});
|
|
8059
|
+
primitives.push({
|
|
8060
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_dimension"),
|
|
8061
|
+
pcb_drawing_type: "line",
|
|
8062
|
+
x1: from.x,
|
|
8063
|
+
y1: from.y,
|
|
8064
|
+
x2: arrow1X2,
|
|
8065
|
+
y2: arrow1Y2,
|
|
8066
|
+
width: 0.05,
|
|
8067
|
+
squareCap: false,
|
|
8068
|
+
layer: "notes",
|
|
8069
|
+
_element: element
|
|
8070
|
+
});
|
|
8071
|
+
const arrow2X1 = to.x - arrow_size * (unitX * Math.cos(arrowAngle) - unitY * Math.sin(arrowAngle));
|
|
8072
|
+
const arrow2Y1 = to.y - arrow_size * (unitX * Math.sin(arrowAngle) + unitY * Math.cos(arrowAngle));
|
|
8073
|
+
const arrow2X2 = to.x - arrow_size * (unitX * Math.cos(-arrowAngle) - unitY * Math.sin(-arrowAngle));
|
|
8074
|
+
const arrow2Y2 = to.y - arrow_size * (unitX * Math.sin(-arrowAngle) + unitY * Math.cos(-arrowAngle));
|
|
8075
|
+
primitives.push({
|
|
8076
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_dimension"),
|
|
8077
|
+
pcb_drawing_type: "line",
|
|
8078
|
+
x1: to.x,
|
|
8079
|
+
y1: to.y,
|
|
8080
|
+
x2: arrow2X1,
|
|
8081
|
+
y2: arrow2Y1,
|
|
8082
|
+
width: 0.05,
|
|
8083
|
+
squareCap: false,
|
|
8084
|
+
layer: "notes",
|
|
8085
|
+
_element: element
|
|
8086
|
+
});
|
|
8087
|
+
primitives.push({
|
|
8088
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_dimension"),
|
|
8089
|
+
pcb_drawing_type: "line",
|
|
8090
|
+
x1: to.x,
|
|
8091
|
+
y1: to.y,
|
|
8092
|
+
x2: arrow2X2,
|
|
8093
|
+
y2: arrow2Y2,
|
|
8094
|
+
width: 0.05,
|
|
8095
|
+
squareCap: false,
|
|
8096
|
+
layer: "notes",
|
|
8097
|
+
_element: element
|
|
8098
|
+
});
|
|
8099
|
+
if (text) {
|
|
8100
|
+
primitives.push({
|
|
8101
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_dimension"),
|
|
8102
|
+
pcb_drawing_type: "text",
|
|
8103
|
+
x: (from.x + to.x) / 2,
|
|
8104
|
+
y: (from.y + to.y) / 2,
|
|
8105
|
+
layer: "notes",
|
|
8106
|
+
align: "center",
|
|
8107
|
+
text,
|
|
8108
|
+
size: font_size,
|
|
8109
|
+
_element: element
|
|
8110
|
+
});
|
|
8111
|
+
}
|
|
8112
|
+
return primitives;
|
|
8113
|
+
}
|
|
7815
8114
|
}
|
|
7816
8115
|
return [];
|
|
7817
8116
|
};
|
|
@@ -8110,6 +8409,7 @@ var LAYER_NAME_TO_COLOR = {
|
|
|
8110
8409
|
bottom_silkscreen: colors_default.board.b_silks,
|
|
8111
8410
|
top_fabrication: colors_default.board.f_fab,
|
|
8112
8411
|
bottom_fabrication: colors_default.board.b_fab,
|
|
8412
|
+
notes: colors_default.board.user_2,
|
|
8113
8413
|
...colors_default.board
|
|
8114
8414
|
};
|
|
8115
8415
|
var DEFAULT_DRAW_ORDER = [
|
|
@@ -8931,6 +9231,7 @@ var orderedLayers = [
|
|
|
8931
9231
|
"inner5",
|
|
8932
9232
|
"inner6",
|
|
8933
9233
|
"drill",
|
|
9234
|
+
"notes",
|
|
8934
9235
|
"other"
|
|
8935
9236
|
];
|
|
8936
9237
|
var CanvasPrimitiveRenderer = ({
|
|
@@ -11557,7 +11858,7 @@ import { css as css3 } from "@emotion/css";
|
|
|
11557
11858
|
// package.json
|
|
11558
11859
|
var package_default = {
|
|
11559
11860
|
name: "@tscircuit/pcb-viewer",
|
|
11560
|
-
version: "1.11.
|
|
11861
|
+
version: "1.11.229",
|
|
11561
11862
|
main: "dist/index.js",
|
|
11562
11863
|
type: "module",
|
|
11563
11864
|
repository: "tscircuit/pcb-viewer",
|
|
@@ -11594,7 +11895,7 @@ var package_default = {
|
|
|
11594
11895
|
"react-cosmos-plugin-vite": "7.0.0-beta.0",
|
|
11595
11896
|
"react-dom": "19.1.0",
|
|
11596
11897
|
"react-use": "^17.4.0",
|
|
11597
|
-
tscircuit: "^0.0.
|
|
11898
|
+
tscircuit: "^0.0.758",
|
|
11598
11899
|
tsup: "^8.0.2",
|
|
11599
11900
|
"type-fest": "^3.0.0",
|
|
11600
11901
|
typescript: "^5.4.4",
|
|
@@ -11608,8 +11909,8 @@ var package_default = {
|
|
|
11608
11909
|
dependencies: {
|
|
11609
11910
|
"@emotion/css": "^11.11.2",
|
|
11610
11911
|
"@vitejs/plugin-react": "^5.0.2",
|
|
11611
|
-
"circuit-json": "^0.0.
|
|
11612
|
-
"circuit-to-svg": "^0.0.
|
|
11912
|
+
"circuit-json": "^0.0.279",
|
|
11913
|
+
"circuit-to-svg": "^0.0.240",
|
|
11613
11914
|
color: "^4.2.3",
|
|
11614
11915
|
"react-supergrid": "^1.0.10",
|
|
11615
11916
|
"react-toastify": "^10.0.5",
|