easyeda 0.0.357 → 0.0.359
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/browser/index.d.ts +10 -10
- package/dist/browser/index.js +397 -111
- package/dist/browser/index.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +395 -109
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +396 -110
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -758,7 +758,7 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
|
|
|
758
758
|
c_spiceCmd?: any;
|
|
759
759
|
};
|
|
760
760
|
canvas: string;
|
|
761
|
-
colors: Record<string, string
|
|
761
|
+
colors: string[] | Record<string, string>;
|
|
762
762
|
BBox?: {
|
|
763
763
|
x: number;
|
|
764
764
|
y: number;
|
|
@@ -787,7 +787,7 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
|
|
|
787
787
|
width: number;
|
|
788
788
|
height: number;
|
|
789
789
|
} | undefined;
|
|
790
|
-
colors?: Record<string, string> |
|
|
790
|
+
colors?: string[] | Record<string, string> | undefined;
|
|
791
791
|
}>, {
|
|
792
792
|
BBox: {
|
|
793
793
|
x: number;
|
|
@@ -908,7 +908,7 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
|
|
|
908
908
|
c_spiceCmd?: any;
|
|
909
909
|
};
|
|
910
910
|
canvas: string;
|
|
911
|
-
colors: Record<string, string
|
|
911
|
+
colors: string[] | Record<string, string>;
|
|
912
912
|
}, {
|
|
913
913
|
shape: string[];
|
|
914
914
|
head: {
|
|
@@ -931,7 +931,7 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
|
|
|
931
931
|
width: number;
|
|
932
932
|
height: number;
|
|
933
933
|
} | undefined;
|
|
934
|
-
colors?: Record<string, string> |
|
|
934
|
+
colors?: string[] | Record<string, string> | undefined;
|
|
935
935
|
}>;
|
|
936
936
|
declare const PackageDetailDataStrSchema: z.ZodObject<{
|
|
937
937
|
head: z.ZodObject<{
|
|
@@ -3477,7 +3477,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
3477
3477
|
c_spiceCmd?: any;
|
|
3478
3478
|
};
|
|
3479
3479
|
canvas: string;
|
|
3480
|
-
colors: Record<string, string
|
|
3480
|
+
colors: string[] | Record<string, string>;
|
|
3481
3481
|
BBox?: {
|
|
3482
3482
|
x: number;
|
|
3483
3483
|
y: number;
|
|
@@ -3506,7 +3506,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
3506
3506
|
width: number;
|
|
3507
3507
|
height: number;
|
|
3508
3508
|
} | undefined;
|
|
3509
|
-
colors?: Record<string, string> |
|
|
3509
|
+
colors?: string[] | Record<string, string> | undefined;
|
|
3510
3510
|
}>, {
|
|
3511
3511
|
BBox: {
|
|
3512
3512
|
x: number;
|
|
@@ -3627,7 +3627,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
3627
3627
|
c_spiceCmd?: any;
|
|
3628
3628
|
};
|
|
3629
3629
|
canvas: string;
|
|
3630
|
-
colors: Record<string, string
|
|
3630
|
+
colors: string[] | Record<string, string>;
|
|
3631
3631
|
}, {
|
|
3632
3632
|
shape: string[];
|
|
3633
3633
|
head: {
|
|
@@ -3650,7 +3650,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
3650
3650
|
width: number;
|
|
3651
3651
|
height: number;
|
|
3652
3652
|
} | undefined;
|
|
3653
|
-
colors?: Record<string, string> |
|
|
3653
|
+
colors?: string[] | Record<string, string> | undefined;
|
|
3654
3654
|
}>;
|
|
3655
3655
|
verify: z.ZodBoolean;
|
|
3656
3656
|
SMT: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -4895,7 +4895,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
4895
4895
|
c_spiceCmd?: any;
|
|
4896
4896
|
};
|
|
4897
4897
|
canvas: string;
|
|
4898
|
-
colors: Record<string, string
|
|
4898
|
+
colors: string[] | Record<string, string>;
|
|
4899
4899
|
};
|
|
4900
4900
|
description: string;
|
|
4901
4901
|
szlcsc: {
|
|
@@ -5146,7 +5146,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
5146
5146
|
width: number;
|
|
5147
5147
|
height: number;
|
|
5148
5148
|
} | undefined;
|
|
5149
|
-
colors?: Record<string, string> |
|
|
5149
|
+
colors?: string[] | Record<string, string> | undefined;
|
|
5150
5150
|
};
|
|
5151
5151
|
description: string;
|
|
5152
5152
|
szlcsc: {
|
package/dist/browser/index.js
CHANGED
|
@@ -9847,6 +9847,225 @@ var transformPCBElements = (elms, matrix) => {
|
|
|
9847
9847
|
}
|
|
9848
9848
|
return transformedElms;
|
|
9849
9849
|
};
|
|
9850
|
+
var mergeBounds = (currentBounds, nextBounds) => ({
|
|
9851
|
+
minX: Math.min(currentBounds.minX, nextBounds.minX),
|
|
9852
|
+
minY: Math.min(currentBounds.minY, nextBounds.minY),
|
|
9853
|
+
maxX: Math.max(currentBounds.maxX, nextBounds.maxX),
|
|
9854
|
+
maxY: Math.max(currentBounds.maxY, nextBounds.maxY)
|
|
9855
|
+
});
|
|
9856
|
+
var getCircleBounds = (x, y, diameter) => {
|
|
9857
|
+
const radius = diameter / 2;
|
|
9858
|
+
return {
|
|
9859
|
+
minX: x - radius,
|
|
9860
|
+
minY: y - radius,
|
|
9861
|
+
maxX: x + radius,
|
|
9862
|
+
maxY: y + radius
|
|
9863
|
+
};
|
|
9864
|
+
};
|
|
9865
|
+
var getRotatedRectBounds = (x, y, width, height, rotationDegrees) => {
|
|
9866
|
+
const halfWidth = width / 2;
|
|
9867
|
+
const halfHeight = height / 2;
|
|
9868
|
+
const theta = rotationDegrees * Math.PI / 180;
|
|
9869
|
+
const cosTheta = Math.cos(theta);
|
|
9870
|
+
const sinTheta = Math.sin(theta);
|
|
9871
|
+
const corners = [
|
|
9872
|
+
{ x: -halfWidth, y: -halfHeight },
|
|
9873
|
+
{ x: halfWidth, y: -halfHeight },
|
|
9874
|
+
{ x: halfWidth, y: halfHeight },
|
|
9875
|
+
{ x: -halfWidth, y: halfHeight }
|
|
9876
|
+
].map((corner) => ({
|
|
9877
|
+
x: x + corner.x * cosTheta - corner.y * sinTheta,
|
|
9878
|
+
y: y + corner.x * sinTheta + corner.y * cosTheta
|
|
9879
|
+
}));
|
|
9880
|
+
return {
|
|
9881
|
+
minX: Math.min(...corners.map((corner) => corner.x)),
|
|
9882
|
+
minY: Math.min(...corners.map((corner) => corner.y)),
|
|
9883
|
+
maxX: Math.max(...corners.map((corner) => corner.x)),
|
|
9884
|
+
maxY: Math.max(...corners.map((corner) => corner.y))
|
|
9885
|
+
};
|
|
9886
|
+
};
|
|
9887
|
+
var getRotatedOvalBounds = (x, y, width, height, rotationDegrees) => {
|
|
9888
|
+
const radiusX = width / 2;
|
|
9889
|
+
const radiusY = height / 2;
|
|
9890
|
+
const theta = rotationDegrees * Math.PI / 180;
|
|
9891
|
+
const cosTheta = Math.cos(theta);
|
|
9892
|
+
const sinTheta = Math.sin(theta);
|
|
9893
|
+
const halfWidth = Math.hypot(radiusX * cosTheta, radiusY * sinTheta);
|
|
9894
|
+
const halfHeight = Math.hypot(radiusX * sinTheta, radiusY * cosTheta);
|
|
9895
|
+
return {
|
|
9896
|
+
minX: x - halfWidth,
|
|
9897
|
+
minY: y - halfHeight,
|
|
9898
|
+
maxX: x + halfWidth,
|
|
9899
|
+
maxY: y + halfHeight
|
|
9900
|
+
};
|
|
9901
|
+
};
|
|
9902
|
+
var getRotatedPillBounds = (x, y, width, height, rotationDegrees) => {
|
|
9903
|
+
const radius = Math.min(width, height) / 2;
|
|
9904
|
+
const halfLineLength = Math.max(width, height) / 2 - radius;
|
|
9905
|
+
const theta = rotationDegrees * Math.PI / 180;
|
|
9906
|
+
const axis = width >= height ? { x: halfLineLength, y: 0 } : { x: 0, y: halfLineLength };
|
|
9907
|
+
const rotatedAxis = {
|
|
9908
|
+
x: axis.x * Math.cos(theta) - axis.y * Math.sin(theta),
|
|
9909
|
+
y: axis.x * Math.sin(theta) + axis.y * Math.cos(theta)
|
|
9910
|
+
};
|
|
9911
|
+
const halfWidth = Math.abs(rotatedAxis.x) + radius;
|
|
9912
|
+
const halfHeight = Math.abs(rotatedAxis.y) + radius;
|
|
9913
|
+
return {
|
|
9914
|
+
minX: x - halfWidth,
|
|
9915
|
+
minY: y - halfHeight,
|
|
9916
|
+
maxX: x + halfWidth,
|
|
9917
|
+
maxY: y + halfHeight
|
|
9918
|
+
};
|
|
9919
|
+
};
|
|
9920
|
+
var getBoundsFromPoints = (points) => {
|
|
9921
|
+
if (points.length === 0) return null;
|
|
9922
|
+
return {
|
|
9923
|
+
minX: Math.min(...points.map((point2) => point2.x)),
|
|
9924
|
+
minY: Math.min(...points.map((point2) => point2.y)),
|
|
9925
|
+
maxX: Math.max(...points.map((point2) => point2.x)),
|
|
9926
|
+
maxY: Math.max(...points.map((point2) => point2.y))
|
|
9927
|
+
};
|
|
9928
|
+
};
|
|
9929
|
+
var getRoutePoints = (route) => {
|
|
9930
|
+
if (!Array.isArray(route)) return [];
|
|
9931
|
+
return route.flatMap((point2) => {
|
|
9932
|
+
if (!point2 || typeof point2 !== "object") return [];
|
|
9933
|
+
if ("x" in point2 && "y" in point2 && typeof point2.x === "number" && typeof point2.y === "number") {
|
|
9934
|
+
return [{ x: point2.x, y: point2.y }];
|
|
9935
|
+
}
|
|
9936
|
+
if ("start" in point2 && "end" in point2) {
|
|
9937
|
+
const positions = [point2.start, point2.end];
|
|
9938
|
+
return positions.filter(
|
|
9939
|
+
(position2) => Boolean(
|
|
9940
|
+
position2 && typeof position2 === "object" && "x" in position2 && "y" in position2 && typeof position2.x === "number" && typeof position2.y === "number"
|
|
9941
|
+
)
|
|
9942
|
+
);
|
|
9943
|
+
}
|
|
9944
|
+
return [];
|
|
9945
|
+
});
|
|
9946
|
+
};
|
|
9947
|
+
var getPcbElementBounds = (elm) => {
|
|
9948
|
+
if (!elm.type.startsWith("pcb_")) return null;
|
|
9949
|
+
if (elm.type === "pcb_smtpad" && elm.shape === "polygon" && Array.isArray(elm.points)) {
|
|
9950
|
+
return getBoundsFromPoints(elm.points);
|
|
9951
|
+
}
|
|
9952
|
+
if (elm.type === "pcb_hole" && elm.hole_shape === "circle") {
|
|
9953
|
+
return getCircleBounds(elm.x, elm.y, elm.hole_diameter);
|
|
9954
|
+
}
|
|
9955
|
+
if (elm.type === "pcb_plated_hole") {
|
|
9956
|
+
let platedHoleBounds;
|
|
9957
|
+
if ("outer_diameter" in elm && typeof elm.outer_diameter === "number") {
|
|
9958
|
+
platedHoleBounds = getCircleBounds(elm.x, elm.y, elm.outer_diameter);
|
|
9959
|
+
} else if ("hole_diameter" in elm && typeof elm.hole_diameter === "number") {
|
|
9960
|
+
platedHoleBounds = getCircleBounds(elm.x, elm.y, elm.hole_diameter);
|
|
9961
|
+
}
|
|
9962
|
+
if ((elm.shape === "oval" || elm.shape === "pill") && typeof elm.outer_width === "number" && typeof elm.outer_height === "number") {
|
|
9963
|
+
const getOuterBounds = elm.shape === "pill" ? getRotatedPillBounds : getRotatedOvalBounds;
|
|
9964
|
+
platedHoleBounds = getOuterBounds(
|
|
9965
|
+
elm.x,
|
|
9966
|
+
elm.y,
|
|
9967
|
+
elm.outer_width,
|
|
9968
|
+
elm.outer_height,
|
|
9969
|
+
elm.ccw_rotation ?? 0
|
|
9970
|
+
);
|
|
9971
|
+
}
|
|
9972
|
+
if ("rect_pad_width" in elm && typeof elm.rect_pad_width === "number" && "rect_pad_height" in elm && typeof elm.rect_pad_height === "number") {
|
|
9973
|
+
const rectBounds = getRotatedRectBounds(
|
|
9974
|
+
elm.x,
|
|
9975
|
+
elm.y,
|
|
9976
|
+
elm.rect_pad_width,
|
|
9977
|
+
elm.rect_pad_height,
|
|
9978
|
+
"rect_ccw_rotation" in elm ? elm.rect_ccw_rotation ?? 0 : 0
|
|
9979
|
+
);
|
|
9980
|
+
platedHoleBounds = platedHoleBounds ? mergeBounds(platedHoleBounds, rectBounds) : rectBounds;
|
|
9981
|
+
}
|
|
9982
|
+
if ("hole_diameter" in elm && typeof elm.hole_diameter === "number") {
|
|
9983
|
+
const drillBounds = getCircleBounds(
|
|
9984
|
+
elm.x + ("hole_offset_x" in elm ? elm.hole_offset_x ?? 0 : 0),
|
|
9985
|
+
elm.y + ("hole_offset_y" in elm ? elm.hole_offset_y ?? 0 : 0),
|
|
9986
|
+
elm.hole_diameter
|
|
9987
|
+
);
|
|
9988
|
+
platedHoleBounds = platedHoleBounds ? mergeBounds(platedHoleBounds, drillBounds) : drillBounds;
|
|
9989
|
+
}
|
|
9990
|
+
if (platedHoleBounds) return platedHoleBounds;
|
|
9991
|
+
}
|
|
9992
|
+
const elementRecord = elm;
|
|
9993
|
+
const routeBounds = getBoundsFromPoints(getRoutePoints(elementRecord.route));
|
|
9994
|
+
if (routeBounds) return routeBounds;
|
|
9995
|
+
const outlineBounds = getBoundsFromPoints(
|
|
9996
|
+
getRoutePoints(elementRecord.outline)
|
|
9997
|
+
);
|
|
9998
|
+
if (outlineBounds) return outlineBounds;
|
|
9999
|
+
const pointsBounds = getBoundsFromPoints(getRoutePoints(elementRecord.points));
|
|
10000
|
+
if (pointsBounds) return pointsBounds;
|
|
10001
|
+
let centerX;
|
|
10002
|
+
let centerY;
|
|
10003
|
+
let width;
|
|
10004
|
+
let height;
|
|
10005
|
+
if ("x" in elm && "y" in elm) {
|
|
10006
|
+
centerX = Number(elm.x);
|
|
10007
|
+
centerY = Number(elm.y);
|
|
10008
|
+
}
|
|
10009
|
+
if ("outer_diameter" in elm) {
|
|
10010
|
+
width = Number(elm.outer_diameter);
|
|
10011
|
+
height = Number(elm.outer_diameter);
|
|
10012
|
+
}
|
|
10013
|
+
if ("width" in elm) {
|
|
10014
|
+
width = Number(elm.width);
|
|
10015
|
+
}
|
|
10016
|
+
if ("height" in elm) {
|
|
10017
|
+
height = Number(elm.height);
|
|
10018
|
+
}
|
|
10019
|
+
if ("center" in elm && elm.center && typeof elm.center === "object" && "x" in elm.center && "y" in elm.center) {
|
|
10020
|
+
centerX = Number(elm.center.x);
|
|
10021
|
+
centerY = Number(elm.center.y);
|
|
10022
|
+
}
|
|
10023
|
+
let rotation2 = 0;
|
|
10024
|
+
if ("rotation" in elm && typeof elm.rotation === "number") {
|
|
10025
|
+
rotation2 = elm.rotation;
|
|
10026
|
+
}
|
|
10027
|
+
if ("ccw_rotation" in elm && typeof elm.ccw_rotation === "number") {
|
|
10028
|
+
rotation2 = elm.ccw_rotation;
|
|
10029
|
+
}
|
|
10030
|
+
if (centerX !== void 0 && centerY !== void 0) {
|
|
10031
|
+
if (width !== void 0 && height !== void 0) {
|
|
10032
|
+
return rotation2 ? getRotatedRectBounds(centerX, centerY, width, height, rotation2) : {
|
|
10033
|
+
minX: centerX - width / 2,
|
|
10034
|
+
minY: centerY - height / 2,
|
|
10035
|
+
maxX: centerX + width / 2,
|
|
10036
|
+
maxY: centerY + height / 2
|
|
10037
|
+
};
|
|
10038
|
+
}
|
|
10039
|
+
if ("radius" in elm && typeof elm.radius === "number") {
|
|
10040
|
+
return getCircleBounds(centerX, centerY, elm.radius * 2);
|
|
10041
|
+
}
|
|
10042
|
+
return { minX: centerX, minY: centerY, maxX: centerX, maxY: centerY };
|
|
10043
|
+
}
|
|
10044
|
+
const anchoredPoint = [elementRecord.anchor_position, elementRecord.position].filter(
|
|
10045
|
+
(position2) => Boolean(
|
|
10046
|
+
position2 && typeof position2 === "object" && "x" in position2 && "y" in position2 && typeof position2.x === "number" && typeof position2.y === "number"
|
|
10047
|
+
)
|
|
10048
|
+
).at(0);
|
|
10049
|
+
return anchoredPoint ? {
|
|
10050
|
+
minX: anchoredPoint.x,
|
|
10051
|
+
minY: anchoredPoint.y,
|
|
10052
|
+
maxX: anchoredPoint.x,
|
|
10053
|
+
maxY: anchoredPoint.y
|
|
10054
|
+
} : null;
|
|
10055
|
+
};
|
|
10056
|
+
var getBoundsOfPcbElements = (elements) => {
|
|
10057
|
+
let bounds = {
|
|
10058
|
+
minX: Number.POSITIVE_INFINITY,
|
|
10059
|
+
minY: Number.POSITIVE_INFINITY,
|
|
10060
|
+
maxX: Number.NEGATIVE_INFINITY,
|
|
10061
|
+
maxY: Number.NEGATIVE_INFINITY
|
|
10062
|
+
};
|
|
10063
|
+
for (const element of elements) {
|
|
10064
|
+
const elementBounds = getPcbElementBounds(element);
|
|
10065
|
+
if (elementBounds) bounds = mergeBounds(bounds, elementBounds);
|
|
10066
|
+
}
|
|
10067
|
+
return bounds;
|
|
10068
|
+
};
|
|
9850
10069
|
function stringHash(str) {
|
|
9851
10070
|
let hash = 0;
|
|
9852
10071
|
if (str.length == 0) return hash;
|
|
@@ -10063,6 +10282,112 @@ var PIN1_LOCATION_PARTS = {
|
|
|
10063
10282
|
};
|
|
10064
10283
|
var PIN1_LOCATIONS = Object.keys(PIN1_LOCATION_PARTS);
|
|
10065
10284
|
|
|
10285
|
+
// lib/utils/normalize-pin-labels.ts
|
|
10286
|
+
var normalizeActiveLowPinLabel = (label) => {
|
|
10287
|
+
const hasActiveLowMarker = label.startsWith("#") || label.endsWith("#");
|
|
10288
|
+
if (!hasActiveLowMarker) return label;
|
|
10289
|
+
const activeLowLabel = label.replace(/^#/, "").replace(/#$/, "");
|
|
10290
|
+
if (activeLowLabel.length === 0) return label;
|
|
10291
|
+
if (activeLowLabel.startsWith("N_")) return activeLowLabel;
|
|
10292
|
+
return `N_${activeLowLabel}`;
|
|
10293
|
+
};
|
|
10294
|
+
var normalizePinLabels = (inputPinLabels) => {
|
|
10295
|
+
const normalizedInputPinLabels = inputPinLabels.map(
|
|
10296
|
+
(labels) => labels.map(normalizeActiveLowPinLabel)
|
|
10297
|
+
);
|
|
10298
|
+
const uniqueInputPinLabels = normalizedInputPinLabels.map((labels) => [
|
|
10299
|
+
...new Set(labels)
|
|
10300
|
+
]);
|
|
10301
|
+
const result = uniqueInputPinLabels.map(() => []);
|
|
10302
|
+
const desiredNumbers = uniqueInputPinLabels.map(() => null);
|
|
10303
|
+
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
10304
|
+
for (const label of uniqueInputPinLabels[i]) {
|
|
10305
|
+
if (/^\d+$/.test(label)) {
|
|
10306
|
+
desiredNumbers[i] = Number.parseInt(label);
|
|
10307
|
+
break;
|
|
10308
|
+
}
|
|
10309
|
+
}
|
|
10310
|
+
}
|
|
10311
|
+
let highestPinNumber = 0;
|
|
10312
|
+
const acceptedDesiredNumbers = /* @__PURE__ */ new Set();
|
|
10313
|
+
for (let i = 0; i < desiredNumbers.length; i++) {
|
|
10314
|
+
const desiredNumber = desiredNumbers[i];
|
|
10315
|
+
if (desiredNumber === null || desiredNumber < 1) continue;
|
|
10316
|
+
if (!acceptedDesiredNumbers.has(desiredNumber)) {
|
|
10317
|
+
acceptedDesiredNumbers.add(desiredNumber);
|
|
10318
|
+
result[i].push(`pin${desiredNumber}`);
|
|
10319
|
+
highestPinNumber = Math.max(highestPinNumber, desiredNumber);
|
|
10320
|
+
continue;
|
|
10321
|
+
}
|
|
10322
|
+
let existingAltCount = 0;
|
|
10323
|
+
for (const label of result[i]) {
|
|
10324
|
+
if (label.startsWith(`pin${desiredNumber}_alt`)) {
|
|
10325
|
+
existingAltCount += 1;
|
|
10326
|
+
}
|
|
10327
|
+
}
|
|
10328
|
+
result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`);
|
|
10329
|
+
}
|
|
10330
|
+
for (let i = 0; i < result.length; i++) {
|
|
10331
|
+
const firstLabel = result[i][0];
|
|
10332
|
+
if (firstLabel?.includes("_alt")) {
|
|
10333
|
+
highestPinNumber += 1;
|
|
10334
|
+
result[i].unshift(`pin${highestPinNumber}`);
|
|
10335
|
+
}
|
|
10336
|
+
}
|
|
10337
|
+
for (let i = 0; i < result.length; i++) {
|
|
10338
|
+
if (result[i].length === 0) {
|
|
10339
|
+
highestPinNumber += 1;
|
|
10340
|
+
result[i].push(`pin${highestPinNumber}`);
|
|
10341
|
+
}
|
|
10342
|
+
}
|
|
10343
|
+
const totalLabelCounts = {};
|
|
10344
|
+
for (const inputLabels of uniqueInputPinLabels) {
|
|
10345
|
+
for (const label of inputLabels) {
|
|
10346
|
+
if (/^\d+$/.test(label)) continue;
|
|
10347
|
+
totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1;
|
|
10348
|
+
}
|
|
10349
|
+
}
|
|
10350
|
+
const incrementalLabelCounts = {};
|
|
10351
|
+
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
10352
|
+
for (const label of uniqueInputPinLabels[i]) {
|
|
10353
|
+
if (/^\d+$/.test(label)) continue;
|
|
10354
|
+
if (totalLabelCounts[label] === 1) {
|
|
10355
|
+
result[i].push(label);
|
|
10356
|
+
} else {
|
|
10357
|
+
incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1;
|
|
10358
|
+
result[i].push(`${label}${incrementalLabelCounts[label]}`);
|
|
10359
|
+
}
|
|
10360
|
+
}
|
|
10361
|
+
}
|
|
10362
|
+
return result;
|
|
10363
|
+
};
|
|
10364
|
+
|
|
10365
|
+
// lib/utils/normalize-easyeda-pin-label.ts
|
|
10366
|
+
var normalizeEasyEdaPinLabel = (label) => {
|
|
10367
|
+
if (label.endsWith("+")) label = `${label.slice(0, -1)}_POS`;
|
|
10368
|
+
if (/[-–−]$/.test(label)) label = `${label.slice(0, -1)}_NEG`;
|
|
10369
|
+
label = normalizeActiveLowPinLabel(label);
|
|
10370
|
+
if (/^\+\d+(?:\.\d+)?V$/i.test(label)) label = `V${label.slice(1, -1)}`;
|
|
10371
|
+
if (label.startsWith("+")) label = `${label.slice(1)}_POS`;
|
|
10372
|
+
if (/^[-–−]/.test(label)) label = `${label.slice(1)}_NEG`;
|
|
10373
|
+
return label;
|
|
10374
|
+
};
|
|
10375
|
+
|
|
10376
|
+
// lib/utils/get-easyeda-pin-aliases.ts
|
|
10377
|
+
var getEasyEdaPinAliases = (label) => {
|
|
10378
|
+
label = label.replace(/&#(x[0-9a-f]+|[0-9]+);/gi, (entity, code) => {
|
|
10379
|
+
let codePoint = Number(code);
|
|
10380
|
+
if (/^x/i.test(code)) codePoint = Number.parseInt(code.slice(1), 16);
|
|
10381
|
+
const maximumUnicodeCodePoint = 1114111;
|
|
10382
|
+
if (codePoint > maximumUnicodeCodePoint) return entity;
|
|
10383
|
+
return String.fromCodePoint(codePoint);
|
|
10384
|
+
});
|
|
10385
|
+
if (label.includes("/") && !/[a-zA-Z0-9]/.test(label)) return [];
|
|
10386
|
+
return label.split("/").map(
|
|
10387
|
+
(alias) => normalizeEasyEdaPinLabel(alias.trim()).replace(/[`′]/g, "_PRIME").replace(/^[()]+|[()]+$/g, "").replace(/[^a-zA-Z0-9_]/g, "_")
|
|
10388
|
+
).filter((alias) => /[a-zA-Z0-9]/.test(alias));
|
|
10389
|
+
};
|
|
10390
|
+
|
|
10066
10391
|
// node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
|
|
10067
10392
|
function orientation(p, q, r) {
|
|
10068
10393
|
const val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
@@ -10096,7 +10421,7 @@ var getBoundsCenter = (bounds) => ({
|
|
|
10096
10421
|
});
|
|
10097
10422
|
|
|
10098
10423
|
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
10099
|
-
var
|
|
10424
|
+
var getBoundsFromPoints2 = (points) => {
|
|
10100
10425
|
if (points.length === 0) {
|
|
10101
10426
|
return null;
|
|
10102
10427
|
}
|
|
@@ -10368,94 +10693,6 @@ var getPolarizedPinMetadata = (pinLabels) => {
|
|
|
10368
10693
|
};
|
|
10369
10694
|
};
|
|
10370
10695
|
|
|
10371
|
-
// lib/utils/normalize-pin-labels.ts
|
|
10372
|
-
var normalizeActiveLowPinLabel = (label) => {
|
|
10373
|
-
const hasActiveLowMarker = label.startsWith("#") || label.endsWith("#");
|
|
10374
|
-
if (!hasActiveLowMarker) return label;
|
|
10375
|
-
const activeLowLabel = label.replace(/^#/, "").replace(/#$/, "");
|
|
10376
|
-
if (activeLowLabel.length === 0) return label;
|
|
10377
|
-
if (activeLowLabel.startsWith("N_")) return activeLowLabel;
|
|
10378
|
-
return `N_${activeLowLabel}`;
|
|
10379
|
-
};
|
|
10380
|
-
var normalizePinLabels = (inputPinLabels) => {
|
|
10381
|
-
const normalizedInputPinLabels = inputPinLabels.map(
|
|
10382
|
-
(labels) => labels.map(normalizeActiveLowPinLabel)
|
|
10383
|
-
);
|
|
10384
|
-
const uniqueInputPinLabels = normalizedInputPinLabels.map((labels) => [
|
|
10385
|
-
...new Set(labels)
|
|
10386
|
-
]);
|
|
10387
|
-
const result = uniqueInputPinLabels.map(() => []);
|
|
10388
|
-
const desiredNumbers = uniqueInputPinLabels.map(() => null);
|
|
10389
|
-
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
10390
|
-
for (const label of uniqueInputPinLabels[i]) {
|
|
10391
|
-
if (/^\d+$/.test(label)) {
|
|
10392
|
-
desiredNumbers[i] = Number.parseInt(label);
|
|
10393
|
-
break;
|
|
10394
|
-
}
|
|
10395
|
-
}
|
|
10396
|
-
}
|
|
10397
|
-
let highestPinNumber = 0;
|
|
10398
|
-
const acceptedDesiredNumbers = /* @__PURE__ */ new Set();
|
|
10399
|
-
for (let i = 0; i < desiredNumbers.length; i++) {
|
|
10400
|
-
const desiredNumber = desiredNumbers[i];
|
|
10401
|
-
if (desiredNumber === null || desiredNumber < 1) continue;
|
|
10402
|
-
if (!acceptedDesiredNumbers.has(desiredNumber)) {
|
|
10403
|
-
acceptedDesiredNumbers.add(desiredNumber);
|
|
10404
|
-
result[i].push(`pin${desiredNumber}`);
|
|
10405
|
-
highestPinNumber = Math.max(highestPinNumber, desiredNumber);
|
|
10406
|
-
continue;
|
|
10407
|
-
}
|
|
10408
|
-
let existingAltCount = 0;
|
|
10409
|
-
for (const label of result[i]) {
|
|
10410
|
-
if (label.startsWith(`pin${desiredNumber}_alt`)) {
|
|
10411
|
-
existingAltCount += 1;
|
|
10412
|
-
}
|
|
10413
|
-
}
|
|
10414
|
-
result[i].push(`pin${desiredNumber}_alt${existingAltCount + 1}`);
|
|
10415
|
-
}
|
|
10416
|
-
for (let i = 0; i < result.length; i++) {
|
|
10417
|
-
const firstLabel = result[i][0];
|
|
10418
|
-
if (firstLabel?.includes("_alt")) {
|
|
10419
|
-
highestPinNumber += 1;
|
|
10420
|
-
result[i].unshift(`pin${highestPinNumber}`);
|
|
10421
|
-
}
|
|
10422
|
-
}
|
|
10423
|
-
for (let i = 0; i < result.length; i++) {
|
|
10424
|
-
if (result[i].length === 0) {
|
|
10425
|
-
highestPinNumber += 1;
|
|
10426
|
-
result[i].push(`pin${highestPinNumber}`);
|
|
10427
|
-
}
|
|
10428
|
-
}
|
|
10429
|
-
const totalLabelCounts = {};
|
|
10430
|
-
for (const inputLabels of uniqueInputPinLabels) {
|
|
10431
|
-
for (const label of inputLabels) {
|
|
10432
|
-
if (/^\d+$/.test(label)) continue;
|
|
10433
|
-
totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1;
|
|
10434
|
-
}
|
|
10435
|
-
}
|
|
10436
|
-
const incrementalLabelCounts = {};
|
|
10437
|
-
for (let i = 0; i < uniqueInputPinLabels.length; i++) {
|
|
10438
|
-
for (const label of uniqueInputPinLabels[i]) {
|
|
10439
|
-
if (/^\d+$/.test(label)) continue;
|
|
10440
|
-
if (totalLabelCounts[label] === 1) {
|
|
10441
|
-
result[i].push(label);
|
|
10442
|
-
} else {
|
|
10443
|
-
incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1;
|
|
10444
|
-
result[i].push(`${label}${incrementalLabelCounts[label]}`);
|
|
10445
|
-
}
|
|
10446
|
-
}
|
|
10447
|
-
}
|
|
10448
|
-
return result;
|
|
10449
|
-
};
|
|
10450
|
-
|
|
10451
|
-
// lib/utils/normalize-symbol-name.ts
|
|
10452
|
-
var normalizeSymbolName = (name) => {
|
|
10453
|
-
const trimmedName = name.trim();
|
|
10454
|
-
if (trimmedName === "+") return "_POS";
|
|
10455
|
-
if (trimmedName === "-") return "_NEG";
|
|
10456
|
-
return trimmedName.replace(/(?<=[A-Za-z0-9])-(?=[A-Za-z0-9])/g, "_");
|
|
10457
|
-
};
|
|
10458
|
-
|
|
10459
10696
|
// lib/websafe/convert-to-typescript-component/category-value-contains-diode.ts
|
|
10460
10697
|
var categoryValueContainsDiode = (value) => {
|
|
10461
10698
|
if (typeof value === "string") {
|
|
@@ -10557,7 +10794,7 @@ var getEasyEdaModelOriginOnBoardMm = ({
|
|
|
10557
10794
|
}
|
|
10558
10795
|
let modelOriginMm = null;
|
|
10559
10796
|
if (points.length > 0) {
|
|
10560
|
-
const bounds =
|
|
10797
|
+
const bounds = getBoundsFromPoints2(points);
|
|
10561
10798
|
modelOriginMm = bounds ? getBoundsCenter(bounds) : null;
|
|
10562
10799
|
} else {
|
|
10563
10800
|
const [originX, originY] = String(svgNode.svgData.attrs?.c_origin ?? "0,0").split(",").map((value) => Number(value.trim()));
|
|
@@ -10648,6 +10885,39 @@ var parseCadOffsetsFromSvgNode = (svgNode) => {
|
|
|
10648
10885
|
})()
|
|
10649
10886
|
};
|
|
10650
10887
|
};
|
|
10888
|
+
var getCadModelOutlineBounds = (svgNode) => {
|
|
10889
|
+
const points = [];
|
|
10890
|
+
for (const childNode of svgNode?.svgData.childNodes ?? []) {
|
|
10891
|
+
if (typeof childNode !== "object" || childNode === null) continue;
|
|
10892
|
+
const attrs = childNode.attrs;
|
|
10893
|
+
if (typeof attrs !== "object" || attrs === null) continue;
|
|
10894
|
+
const rawPoints = attrs.points;
|
|
10895
|
+
if (typeof rawPoints !== "string") continue;
|
|
10896
|
+
const coordinates = rawPoints.trim().split(/\s+/).map(Number);
|
|
10897
|
+
for (let index = 0; index + 1 < coordinates.length; index += 2) {
|
|
10898
|
+
const x = coordinates[index];
|
|
10899
|
+
const y = coordinates[index + 1];
|
|
10900
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) continue;
|
|
10901
|
+
points.push({ x: milx10(x), y: milx10(y) });
|
|
10902
|
+
}
|
|
10903
|
+
}
|
|
10904
|
+
if (points.length === 0) return void 0;
|
|
10905
|
+
return {
|
|
10906
|
+
minX: Math.min(...points.map((point2) => point2.x)),
|
|
10907
|
+
minY: Math.min(...points.map((point2) => point2.y)),
|
|
10908
|
+
maxX: Math.max(...points.map((point2) => point2.x)),
|
|
10909
|
+
maxY: Math.max(...points.map((point2) => point2.y))
|
|
10910
|
+
};
|
|
10911
|
+
};
|
|
10912
|
+
var unionBounds = (first, second) => {
|
|
10913
|
+
if (!second) return first;
|
|
10914
|
+
return {
|
|
10915
|
+
minX: Math.min(first.minX, second.minX),
|
|
10916
|
+
minY: Math.min(first.minY, second.minY),
|
|
10917
|
+
maxX: Math.max(first.maxX, second.maxX),
|
|
10918
|
+
maxY: Math.max(first.maxY, second.maxY)
|
|
10919
|
+
};
|
|
10920
|
+
};
|
|
10651
10921
|
var readModelHeightMm = (raw) => {
|
|
10652
10922
|
const fallback = 3.5;
|
|
10653
10923
|
if (raw == null) return fallback;
|
|
@@ -10906,9 +11176,9 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
10906
11176
|
const pins = easyEdaJson.dataStr.shape.filter((shape) => shape.type === "PIN");
|
|
10907
11177
|
const pinLabelSets = pads.map((pad) => {
|
|
10908
11178
|
const labels = [];
|
|
10909
|
-
if (pad.number) labels.push(pad.number.toString());
|
|
11179
|
+
if (pad.number) labels.push(...getEasyEdaPinAliases(pad.number.toString()));
|
|
10910
11180
|
const pin = pins.find((p) => p.pinNumber === pad.number);
|
|
10911
|
-
if (pin) labels.push(
|
|
11181
|
+
if (pin) labels.push(...getEasyEdaPinAliases(pin.label));
|
|
10912
11182
|
return labels;
|
|
10913
11183
|
});
|
|
10914
11184
|
const padNumberKeys = pads.map((pad, index) => {
|
|
@@ -11239,17 +11509,29 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
11239
11509
|
);
|
|
11240
11510
|
}
|
|
11241
11511
|
const hasExplicitCourtyard = circuitElements.some(
|
|
11242
|
-
(e) => e.type === "pcb_courtyard_outline"
|
|
11512
|
+
(e) => e.type === "pcb_courtyard_outline" || e.type === "pcb_courtyard_rect"
|
|
11243
11513
|
);
|
|
11244
11514
|
if (!hasExplicitCourtyard) {
|
|
11245
11515
|
const bbox = easyEdaJson.packageDetail.dataStr.BBox;
|
|
11246
|
-
|
|
11516
|
+
const modelOutlineBounds = getCadModelOutlineBounds(svgNode);
|
|
11517
|
+
const packageElements = circuitElements.filter(
|
|
11518
|
+
(element) => element.type === "pcb_smtpad" || element.type === "pcb_plated_hole" || element.type === "pcb_hole" || element.type === "pcb_via"
|
|
11519
|
+
);
|
|
11520
|
+
const packageElementBounds = packageElements.length > 0 ? getBoundsOfPcbElements(packageElements) : void 0;
|
|
11521
|
+
const fallbackBounds = bbox ? {
|
|
11522
|
+
minX: milx10(bbox.x),
|
|
11523
|
+
minY: milx10(bbox.y),
|
|
11524
|
+
maxX: milx10(bbox.x + bbox.width),
|
|
11525
|
+
maxY: milx10(bbox.y + bbox.height)
|
|
11526
|
+
} : void 0;
|
|
11527
|
+
const courtyardBounds = modelOutlineBounds ? unionBounds(modelOutlineBounds, packageElementBounds) : fallbackBounds;
|
|
11528
|
+
if (courtyardBounds) {
|
|
11247
11529
|
const strokeWidth = 0.05;
|
|
11248
11530
|
const margin = 0.25;
|
|
11249
|
-
const x1 =
|
|
11250
|
-
const y1 =
|
|
11251
|
-
const x2 =
|
|
11252
|
-
const y2 =
|
|
11531
|
+
const x1 = courtyardBounds.minX - margin;
|
|
11532
|
+
const y1 = courtyardBounds.minY - margin;
|
|
11533
|
+
const x2 = courtyardBounds.maxX + margin;
|
|
11534
|
+
const y2 = courtyardBounds.maxY + margin;
|
|
11253
11535
|
circuitElements.push(
|
|
11254
11536
|
pcb_courtyard_outline.parse({
|
|
11255
11537
|
type: "pcb_courtyard_outline",
|
|
@@ -11811,14 +12093,9 @@ var PinShapeOutputSchema = external_exports.object({
|
|
|
11811
12093
|
var parsePin = (pinString) => {
|
|
11812
12094
|
const parts = pinString.split("~");
|
|
11813
12095
|
const [, visibility, , pinNumber, x, y, rotation2, id] = parts;
|
|
11814
|
-
const
|
|
11815
|
-
let label =
|
|
11816
|
-
if (label.
|
|
11817
|
-
if (label.endsWith("-")) label = `${label.slice(0, -1)}_NEG`;
|
|
11818
|
-
label = normalizeActiveLowPinLabel(label);
|
|
11819
|
-
if (/^\+\d+(?:\.\d+)?V$/i.test(label)) label = `V${label.slice(1, -1)}`;
|
|
11820
|
-
if (label.startsWith("+")) label = `${label.slice(1)}_POS`;
|
|
11821
|
-
if (label.startsWith("-")) label = `${label.slice(1)}_NEG`;
|
|
12096
|
+
const pinNameSection = pinString.split("^^")[3];
|
|
12097
|
+
let label = pinNameSection?.split("~")[4] ?? "";
|
|
12098
|
+
if (!label.includes("/")) label = normalizeEasyEdaPinLabel(label);
|
|
11822
12099
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
11823
12100
|
const labelColor = colorMatch ? colorMatch[0] : "";
|
|
11824
12101
|
const path = pinString.split("^^")[2]?.split("~")[0] ?? "";
|
|
@@ -12312,6 +12589,14 @@ var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalTh
|
|
|
12312
12589
|
return placementPromise;
|
|
12313
12590
|
};
|
|
12314
12591
|
|
|
12592
|
+
// lib/utils/normalize-symbol-name.ts
|
|
12593
|
+
var normalizeSymbolName = (name) => {
|
|
12594
|
+
const trimmedName = name.trim();
|
|
12595
|
+
if (trimmedName === "+") return "_POS";
|
|
12596
|
+
if (trimmedName === "-") return "_NEG";
|
|
12597
|
+
return trimmedName.replace(/(?<=[A-Za-z0-9])-(?=[A-Za-z0-9])/g, "_");
|
|
12598
|
+
};
|
|
12599
|
+
|
|
12315
12600
|
// lib/websafe/convert-to-typescript-component/generate-symbol-tsx.ts
|
|
12316
12601
|
var round = (value) => Number(value.toFixed(6));
|
|
12317
12602
|
var EASYEDA_SCHEMATIC_UNIT_TO_TSCIRCUIT_UNIT = 0.02;
|
|
@@ -12538,14 +12823,15 @@ var getPortMetadataByShapeId = (easyEdaJson, circuitJson) => {
|
|
|
12538
12823
|
portName ??= `pin${pinIndex + 1}`;
|
|
12539
12824
|
usedPortNames.add(portName);
|
|
12540
12825
|
const sourcePort = sourcePorts.find((port) => port.name === portName);
|
|
12826
|
+
let aliases = getEasyEdaPinAliases(pin.label);
|
|
12827
|
+
if (sourcePort?.port_hints?.length) {
|
|
12828
|
+
aliases = sourcePort.port_hints;
|
|
12829
|
+
}
|
|
12541
12830
|
metadataByShapeId.set(pin.id, {
|
|
12542
12831
|
name: portName,
|
|
12543
12832
|
pinNumber: sourcePort?.pin_number,
|
|
12544
|
-
aliases:
|
|
12545
|
-
|
|
12546
|
-
...pin.label ? [normalizeSymbolName(pin.label)] : []
|
|
12547
|
-
].filter(
|
|
12548
|
-
(alias, index, aliases) => alias !== portName && aliases.indexOf(alias) === index
|
|
12833
|
+
aliases: aliases.filter(
|
|
12834
|
+
(alias, index, aliases2) => alias !== portName && aliases2.indexOf(alias) === index
|
|
12549
12835
|
)
|
|
12550
12836
|
});
|
|
12551
12837
|
});
|