easyeda 0.0.386 → 0.0.388
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 +150 -150
- package/dist/browser/index.js +285 -91
- package/dist/browser/index.js.map +1 -1
- package/dist/index.d.ts +150 -150
- package/dist/index.js +285 -91
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +286 -92
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -1078,7 +1078,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
|
|
|
1078
1078
|
var package_default = {
|
|
1079
1079
|
name: "easyeda",
|
|
1080
1080
|
type: "module",
|
|
1081
|
-
version: "0.0.
|
|
1081
|
+
version: "0.0.387",
|
|
1082
1082
|
files: [
|
|
1083
1083
|
"dist"
|
|
1084
1084
|
],
|
|
@@ -16517,10 +16517,25 @@ var mil2mm = (mil) => {
|
|
|
16517
16517
|
// lib/constants.ts
|
|
16518
16518
|
var DEFAULT_PCB_THICKNESS_MM = 1.6;
|
|
16519
16519
|
|
|
16520
|
+
// lib/utils/easyeda-path-limits.ts
|
|
16521
|
+
var MAX_EASYEDA_PATH_POINTS = 8192;
|
|
16522
|
+
var EASYEDA_PATH_LIMIT_MESSAGE = "EasyEDA SOLIDREGION path exceeds the vertex limit";
|
|
16523
|
+
var INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE = "Invalid EasyEDA SOLIDREGION path geometry";
|
|
16524
|
+
|
|
16520
16525
|
// lib/math/arc-utils.ts
|
|
16521
|
-
function generateArcFromSweep(
|
|
16522
|
-
|
|
16523
|
-
|
|
16526
|
+
function generateArcFromSweep({
|
|
16527
|
+
start,
|
|
16528
|
+
end,
|
|
16529
|
+
radius,
|
|
16530
|
+
largeArcFlag,
|
|
16531
|
+
sweepFlag,
|
|
16532
|
+
maxSegments = MAX_EASYEDA_PATH_POINTS - 1
|
|
16533
|
+
}) {
|
|
16534
|
+
const { x: startX, y: startY } = start;
|
|
16535
|
+
const { x: endX, y: endY } = end;
|
|
16536
|
+
if (![startX, startY, endX, endY, radius].every(Number.isFinite) || !Number.isInteger(maxSegments) || maxSegments < 1) {
|
|
16537
|
+
throw new Error(INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE);
|
|
16538
|
+
}
|
|
16524
16539
|
const midX = (startX + endX) / 2;
|
|
16525
16540
|
const midY = (startY + endY) / 2;
|
|
16526
16541
|
const dx = endX - startX;
|
|
@@ -16546,12 +16561,26 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
16546
16561
|
const minNumPoints = Math.max(2, Math.ceil(arcAngle * radius));
|
|
16547
16562
|
const isSemicircle = Math.abs(arcAngle - Math.PI) < 1e-6;
|
|
16548
16563
|
const numPoints = isSemicircle ? minNumPoints + minNumPoints % 2 : minNumPoints;
|
|
16564
|
+
if (![centerX, centerY, startAngle, endAngle, numPoints].every(Number.isFinite)) {
|
|
16565
|
+
throw new Error(INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE);
|
|
16566
|
+
}
|
|
16567
|
+
const sampledSegments = Math.min(
|
|
16568
|
+
numPoints,
|
|
16569
|
+
maxSegments,
|
|
16570
|
+
MAX_EASYEDA_PATH_POINTS - 1
|
|
16571
|
+
);
|
|
16549
16572
|
const path = [];
|
|
16550
|
-
for (let i = 0; i <=
|
|
16551
|
-
const
|
|
16573
|
+
for (let i = 0; i <= sampledSegments; i++) {
|
|
16574
|
+
const pointIndex = sampledSegments === numPoints ? i : Math.round(
|
|
16575
|
+
numPoints <= Number.MAX_SAFE_INTEGER / sampledSegments ? i * numPoints / sampledSegments : i / sampledSegments * numPoints
|
|
16576
|
+
);
|
|
16577
|
+
const t = pointIndex / numPoints;
|
|
16552
16578
|
const angle2 = startAngle + t * (endAngle - startAngle);
|
|
16553
16579
|
const x = centerX + radius * Math.cos(angle2);
|
|
16554
16580
|
const y = centerY + radius * Math.sin(angle2);
|
|
16581
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) {
|
|
16582
|
+
throw new Error(INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE);
|
|
16583
|
+
}
|
|
16555
16584
|
path.push({ x, y });
|
|
16556
16585
|
}
|
|
16557
16586
|
return path;
|
|
@@ -16666,12 +16695,197 @@ var convertEasyEdaNpthCutoutsToHoles = (circuitJson, npthRegions) => {
|
|
|
16666
16695
|
});
|
|
16667
16696
|
};
|
|
16668
16697
|
|
|
16698
|
+
// lib/utils/append-easyeda-path-point.ts
|
|
16699
|
+
var appendEasyEdaPathPoint = (route, point4) => {
|
|
16700
|
+
if (!Number.isFinite(point4.x) || !Number.isFinite(point4.y)) {
|
|
16701
|
+
throw new Error(INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE);
|
|
16702
|
+
}
|
|
16703
|
+
const firstPoint = route[0] ?? point4;
|
|
16704
|
+
const needsClosingPoint = firstPoint.x !== point4.x || firstPoint.y !== point4.y;
|
|
16705
|
+
if (route.length + 1 + Number(needsClosingPoint) > MAX_EASYEDA_PATH_POINTS) {
|
|
16706
|
+
throw new Error(EASYEDA_PATH_LIMIT_MESSAGE);
|
|
16707
|
+
}
|
|
16708
|
+
route.push(point4);
|
|
16709
|
+
};
|
|
16710
|
+
|
|
16711
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
|
|
16712
|
+
function orientation(p, q, r) {
|
|
16713
|
+
const val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
16714
|
+
if (val === 0) return 0;
|
|
16715
|
+
return val > 0 ? 1 : 2;
|
|
16716
|
+
}
|
|
16717
|
+
function pointToSegmentDistance(p, v, w) {
|
|
16718
|
+
const l2 = (w.x - v.x) ** 2 + (w.y - v.y) ** 2;
|
|
16719
|
+
if (l2 === 0) return distance2(p, v);
|
|
16720
|
+
let t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2;
|
|
16721
|
+
t = Math.max(0, Math.min(1, t));
|
|
16722
|
+
const projection = {
|
|
16723
|
+
x: v.x + t * (w.x - v.x),
|
|
16724
|
+
y: v.y + t * (w.y - v.y)
|
|
16725
|
+
};
|
|
16726
|
+
return distance2(p, projection);
|
|
16727
|
+
}
|
|
16728
|
+
function distance2(p1, p2) {
|
|
16729
|
+
const dx = p1.x - p2.x;
|
|
16730
|
+
const dy = p1.y - p2.y;
|
|
16731
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
16732
|
+
}
|
|
16733
|
+
|
|
16734
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-GIGMPRPV.js
|
|
16735
|
+
var getUnitVectorFromDirection = (direction) => {
|
|
16736
|
+
switch (direction) {
|
|
16737
|
+
case "up":
|
|
16738
|
+
return { x: 0, y: 1 };
|
|
16739
|
+
case "down":
|
|
16740
|
+
return { x: 0, y: -1 };
|
|
16741
|
+
case "left":
|
|
16742
|
+
return { x: -1, y: 0 };
|
|
16743
|
+
case "right":
|
|
16744
|
+
return { x: 1, y: 0 };
|
|
16745
|
+
}
|
|
16746
|
+
};
|
|
16747
|
+
|
|
16748
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-5J3PCV4D.js
|
|
16749
|
+
function midpoint(p1, p2) {
|
|
16750
|
+
return {
|
|
16751
|
+
x: (p1.x + p2.x) / 2,
|
|
16752
|
+
y: (p1.y + p2.y) / 2
|
|
16753
|
+
};
|
|
16754
|
+
}
|
|
16755
|
+
|
|
16756
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-3WCUPG5S.js
|
|
16757
|
+
var getBoundsCenter = (bounds) => ({
|
|
16758
|
+
x: (bounds.minX + bounds.maxX) / 2,
|
|
16759
|
+
y: (bounds.minY + bounds.maxY) / 2
|
|
16760
|
+
});
|
|
16761
|
+
|
|
16762
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
16763
|
+
var getBoundsFromPoints2 = (points) => {
|
|
16764
|
+
if (points.length === 0) {
|
|
16765
|
+
return null;
|
|
16766
|
+
}
|
|
16767
|
+
let minX = points[0].x;
|
|
16768
|
+
let minY = points[0].y;
|
|
16769
|
+
let maxX = points[0].x;
|
|
16770
|
+
let maxY = points[0].y;
|
|
16771
|
+
for (let i = 1; i < points.length; i++) {
|
|
16772
|
+
const point4 = points[i];
|
|
16773
|
+
if (point4.x < minX) minX = point4.x;
|
|
16774
|
+
if (point4.y < minY) minY = point4.y;
|
|
16775
|
+
if (point4.x > maxX) maxX = point4.x;
|
|
16776
|
+
if (point4.y > maxY) maxY = point4.y;
|
|
16777
|
+
}
|
|
16778
|
+
return { minX, minY, maxX, maxY };
|
|
16779
|
+
};
|
|
16780
|
+
|
|
16781
|
+
// lib/utils/flatten-bezier-curve.ts
|
|
16782
|
+
var MAX_SUBDIVISION_DEPTH = 20;
|
|
16783
|
+
var BEZIER_SUBDIVISION_LIMIT_MESSAGE = "Bezier curve exceeds the subdivision limit";
|
|
16784
|
+
var INVALID_BEZIER_GEOMETRY_MESSAGE = "Invalid Bezier curve geometry";
|
|
16785
|
+
var flattenBezierCurve = ({
|
|
16786
|
+
controlPoints,
|
|
16787
|
+
tolerance,
|
|
16788
|
+
maxPoints = MAX_EASYEDA_PATH_POINTS
|
|
16789
|
+
}) => {
|
|
16790
|
+
if (![3, 4].includes(controlPoints.length) || !Number.isFinite(tolerance) || tolerance <= 0 || controlPoints.some(
|
|
16791
|
+
(point4) => !Number.isFinite(point4.x) || !Number.isFinite(point4.y)
|
|
16792
|
+
)) {
|
|
16793
|
+
throw new Error(INVALID_BEZIER_GEOMETRY_MESSAGE);
|
|
16794
|
+
}
|
|
16795
|
+
if (!Number.isInteger(maxPoints) || maxPoints < 2) {
|
|
16796
|
+
throw new Error(EASYEDA_PATH_LIMIT_MESSAGE);
|
|
16797
|
+
}
|
|
16798
|
+
const pointLimit = Math.min(maxPoints, MAX_EASYEDA_PATH_POINTS);
|
|
16799
|
+
const route = [controlPoints[0]];
|
|
16800
|
+
const pending = [{ points: controlPoints, depth: 0 }];
|
|
16801
|
+
while (pending.length) {
|
|
16802
|
+
const { points, depth } = pending.pop();
|
|
16803
|
+
const start = points[0];
|
|
16804
|
+
const end = points.at(-1);
|
|
16805
|
+
if (points.slice(1, -1).every(
|
|
16806
|
+
(point4) => pointToSegmentDistance(point4, start, end) <= tolerance
|
|
16807
|
+
)) {
|
|
16808
|
+
route.push(end);
|
|
16809
|
+
continue;
|
|
16810
|
+
}
|
|
16811
|
+
if (depth >= MAX_SUBDIVISION_DEPTH) {
|
|
16812
|
+
throw new Error(BEZIER_SUBDIVISION_LIMIT_MESSAGE);
|
|
16813
|
+
}
|
|
16814
|
+
if (route.length + pending.length + 2 > pointLimit) {
|
|
16815
|
+
throw new Error(EASYEDA_PATH_LIMIT_MESSAGE);
|
|
16816
|
+
}
|
|
16817
|
+
let level = points;
|
|
16818
|
+
const left = [start];
|
|
16819
|
+
const right = [end];
|
|
16820
|
+
while (level.length > 1) {
|
|
16821
|
+
level = level.slice(1).map((point4, index) => midpoint(level[index], point4));
|
|
16822
|
+
left.push(level[0]);
|
|
16823
|
+
right.unshift(level.at(-1));
|
|
16824
|
+
}
|
|
16825
|
+
pending.push(
|
|
16826
|
+
{ points: right, depth: depth + 1 },
|
|
16827
|
+
{ points: left, depth: depth + 1 }
|
|
16828
|
+
);
|
|
16829
|
+
}
|
|
16830
|
+
return route;
|
|
16831
|
+
};
|
|
16832
|
+
|
|
16833
|
+
// lib/utils/expand-easyeda-bezier-command.ts
|
|
16834
|
+
var BEZIER_TOLERANCE = 1e-3 / mil10ToMm(1);
|
|
16835
|
+
var expandEasyEdaBezierCommand = (pathCommand, ctx) => {
|
|
16836
|
+
const command = pathCommand.command.toUpperCase();
|
|
16837
|
+
const relative = command !== pathCommand.command;
|
|
16838
|
+
const groupSize = command === "C" ? 6 : command === "T" ? 2 : 4;
|
|
16839
|
+
const route = [];
|
|
16840
|
+
let { currentPoint, cubicControl, quadraticControl } = ctx;
|
|
16841
|
+
for (let offset = 0; offset < pathCommand.arguments.length; offset += groupSize) {
|
|
16842
|
+
if (route.length >= ctx.remainingPoints) {
|
|
16843
|
+
throw new Error(EASYEDA_PATH_LIMIT_MESSAGE);
|
|
16844
|
+
}
|
|
16845
|
+
const coordinates = [];
|
|
16846
|
+
for (let index = offset; index < offset + groupSize; index += 2) {
|
|
16847
|
+
coordinates.push({
|
|
16848
|
+
x: pathCommand.arguments[index] + (relative ? currentPoint.x : 0),
|
|
16849
|
+
y: pathCommand.arguments[index + 1] + (relative ? currentPoint.y : 0)
|
|
16850
|
+
});
|
|
16851
|
+
}
|
|
16852
|
+
const end = coordinates.at(-1);
|
|
16853
|
+
let controlPoints;
|
|
16854
|
+
if (command === "C" || command === "S") {
|
|
16855
|
+
const firstControl = command === "C" ? coordinates[0] : cubicControl ? {
|
|
16856
|
+
x: 2 * currentPoint.x - cubicControl.x,
|
|
16857
|
+
y: 2 * currentPoint.y - cubicControl.y
|
|
16858
|
+
} : currentPoint;
|
|
16859
|
+
cubicControl = coordinates.at(-2);
|
|
16860
|
+
quadraticControl = void 0;
|
|
16861
|
+
controlPoints = [currentPoint, firstControl, cubicControl, end];
|
|
16862
|
+
} else {
|
|
16863
|
+
quadraticControl = command === "Q" ? coordinates[0] : quadraticControl ? {
|
|
16864
|
+
x: 2 * currentPoint.x - quadraticControl.x,
|
|
16865
|
+
y: 2 * currentPoint.y - quadraticControl.y
|
|
16866
|
+
} : currentPoint;
|
|
16867
|
+
cubicControl = void 0;
|
|
16868
|
+
controlPoints = [currentPoint, quadraticControl, end];
|
|
16869
|
+
}
|
|
16870
|
+
const points = flattenBezierCurve({
|
|
16871
|
+
controlPoints,
|
|
16872
|
+
tolerance: BEZIER_TOLERANCE,
|
|
16873
|
+
maxPoints: ctx.remainingPoints - route.length + 1
|
|
16874
|
+
});
|
|
16875
|
+
for (let index = 1; index < points.length; index++) {
|
|
16876
|
+
route.push(points[index]);
|
|
16877
|
+
}
|
|
16878
|
+
currentPoint = end;
|
|
16879
|
+
}
|
|
16880
|
+
return { route, currentPoint, cubicControl, quadraticControl };
|
|
16881
|
+
};
|
|
16882
|
+
|
|
16669
16883
|
// lib/utils/expand-easyeda-path-data.ts
|
|
16670
16884
|
var expandEasyEdaPathData = (pathData) => {
|
|
16671
16885
|
const commands = parseEasyEdaPathCommands(pathData);
|
|
16672
16886
|
if (!commands) throw new Error("Invalid EasyEDA SOLIDREGION path");
|
|
16673
16887
|
for (const { command } of commands) {
|
|
16674
|
-
if (!/^[
|
|
16888
|
+
if (!/^[MLHVAZCSQT]$/i.test(command)) {
|
|
16675
16889
|
throw new Error(
|
|
16676
16890
|
`Unsupported EasyEDA SOLIDREGION path command: ${command}`
|
|
16677
16891
|
);
|
|
@@ -16684,14 +16898,18 @@ var expandEasyEdaPathData = (pathData) => {
|
|
|
16684
16898
|
let currentPoint;
|
|
16685
16899
|
let subpathStart;
|
|
16686
16900
|
let afterClose = false;
|
|
16901
|
+
let cubicControl;
|
|
16902
|
+
let quadraticControl;
|
|
16687
16903
|
for (const pathCommand of commands) {
|
|
16688
16904
|
const command = pathCommand.command.toUpperCase();
|
|
16689
16905
|
const relative = pathCommand.command !== command;
|
|
16690
16906
|
const commandArguments = pathCommand.arguments;
|
|
16907
|
+
if (command !== "C" && command !== "S") cubicControl = void 0;
|
|
16908
|
+
if (command !== "Q" && command !== "T") quadraticControl = void 0;
|
|
16691
16909
|
if (afterClose && command !== "Z" && currentPoint) {
|
|
16692
16910
|
const lastPoint = rawRoute.at(-1);
|
|
16693
16911
|
if (lastPoint?.x !== currentPoint.x || lastPoint?.y !== currentPoint.y) {
|
|
16694
|
-
rawRoute
|
|
16912
|
+
appendEasyEdaPathPoint(rawRoute, currentPoint);
|
|
16695
16913
|
}
|
|
16696
16914
|
}
|
|
16697
16915
|
afterClose = command === "Z";
|
|
@@ -16701,7 +16919,7 @@ var expandEasyEdaPathData = (pathData) => {
|
|
|
16701
16919
|
x: commandArguments[offset] + (relative ? currentPoint?.x ?? 0 : 0),
|
|
16702
16920
|
y: commandArguments[offset + 1] + (relative ? currentPoint?.y ?? 0 : 0)
|
|
16703
16921
|
};
|
|
16704
|
-
rawRoute
|
|
16922
|
+
appendEasyEdaPathPoint(rawRoute, currentPoint);
|
|
16705
16923
|
if (command === "M" && offset === 0) subpathStart = currentPoint;
|
|
16706
16924
|
}
|
|
16707
16925
|
} else if ((command === "H" || command === "V") && currentPoint) {
|
|
@@ -16710,32 +16928,35 @@ var expandEasyEdaPathData = (pathData) => {
|
|
|
16710
16928
|
x: command === "H" ? coordinate + (relative ? currentPoint.x : 0) : currentPoint.x,
|
|
16711
16929
|
y: command === "V" ? coordinate + (relative ? currentPoint.y : 0) : currentPoint.y
|
|
16712
16930
|
};
|
|
16713
|
-
rawRoute
|
|
16931
|
+
appendEasyEdaPathPoint(rawRoute, currentPoint);
|
|
16714
16932
|
}
|
|
16933
|
+
} else if (/^[CSQT]$/.test(command) && currentPoint) {
|
|
16934
|
+
const curve = expandEasyEdaBezierCommand(pathCommand, {
|
|
16935
|
+
currentPoint,
|
|
16936
|
+
cubicControl,
|
|
16937
|
+
quadraticControl,
|
|
16938
|
+
remainingPoints: MAX_EASYEDA_PATH_POINTS - rawRoute.length
|
|
16939
|
+
});
|
|
16940
|
+
for (const point4 of curve.route) appendEasyEdaPathPoint(rawRoute, point4);
|
|
16941
|
+
currentPoint = curve.currentPoint;
|
|
16942
|
+
cubicControl = curve.cubicControl;
|
|
16943
|
+
quadraticControl = curve.quadraticControl;
|
|
16715
16944
|
} else if (command === "A" && currentPoint && commandArguments.length >= 7) {
|
|
16716
16945
|
for (let offset = 0; offset + 6 < commandArguments.length; offset += 7) {
|
|
16717
16946
|
const [radiusX, , , largeArcFlag, sweepFlag, endpointX, endpointY] = commandArguments.slice(offset, offset + 7);
|
|
16718
16947
|
const endX = endpointX + (relative ? currentPoint.x : 0);
|
|
16719
16948
|
const endY = endpointY + (relative ? currentPoint.y : 0);
|
|
16720
|
-
const
|
|
16721
|
-
currentPoint
|
|
16722
|
-
|
|
16723
|
-
|
|
16724
|
-
|
|
16725
|
-
|
|
16726
|
-
|
|
16727
|
-
|
|
16728
|
-
)
|
|
16729
|
-
|
|
16730
|
-
|
|
16731
|
-
{ length: maxArcSegments + 1 },
|
|
16732
|
-
(_, pointIndex) => generatedArcRoute.at(
|
|
16733
|
-
Math.round(
|
|
16734
|
-
pointIndex * (generatedArcRoute.length - 1) / maxArcSegments
|
|
16735
|
-
)
|
|
16736
|
-
)
|
|
16737
|
-
).filter((point4) => !!point4);
|
|
16738
|
-
rawRoute.push(...arcRoute.slice(1));
|
|
16949
|
+
const arcRoute = generateArcFromSweep({
|
|
16950
|
+
start: currentPoint,
|
|
16951
|
+
end: { x: endX, y: endY },
|
|
16952
|
+
radius: radiusX,
|
|
16953
|
+
largeArcFlag: largeArcFlag === 1,
|
|
16954
|
+
sweepFlag: sweepFlag === 1,
|
|
16955
|
+
maxSegments: 16
|
|
16956
|
+
});
|
|
16957
|
+
for (let index = 1; index < arcRoute.length; index++) {
|
|
16958
|
+
appendEasyEdaPathPoint(rawRoute, arcRoute[index]);
|
|
16959
|
+
}
|
|
16739
16960
|
currentPoint = { x: endX, y: endY };
|
|
16740
16961
|
}
|
|
16741
16962
|
} else if (command === "Z" && subpathStart) {
|
|
@@ -16745,57 +16966,6 @@ var expandEasyEdaPathData = (pathData) => {
|
|
|
16745
16966
|
return rawRoute;
|
|
16746
16967
|
};
|
|
16747
16968
|
|
|
16748
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
|
|
16749
|
-
function orientation(p, q, r) {
|
|
16750
|
-
const val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
16751
|
-
if (val === 0) return 0;
|
|
16752
|
-
return val > 0 ? 1 : 2;
|
|
16753
|
-
}
|
|
16754
|
-
function distance2(p1, p2) {
|
|
16755
|
-
const dx = p1.x - p2.x;
|
|
16756
|
-
const dy = p1.y - p2.y;
|
|
16757
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
16758
|
-
}
|
|
16759
|
-
|
|
16760
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-GIGMPRPV.js
|
|
16761
|
-
var getUnitVectorFromDirection = (direction) => {
|
|
16762
|
-
switch (direction) {
|
|
16763
|
-
case "up":
|
|
16764
|
-
return { x: 0, y: 1 };
|
|
16765
|
-
case "down":
|
|
16766
|
-
return { x: 0, y: -1 };
|
|
16767
|
-
case "left":
|
|
16768
|
-
return { x: -1, y: 0 };
|
|
16769
|
-
case "right":
|
|
16770
|
-
return { x: 1, y: 0 };
|
|
16771
|
-
}
|
|
16772
|
-
};
|
|
16773
|
-
|
|
16774
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-3WCUPG5S.js
|
|
16775
|
-
var getBoundsCenter = (bounds) => ({
|
|
16776
|
-
x: (bounds.minX + bounds.maxX) / 2,
|
|
16777
|
-
y: (bounds.minY + bounds.maxY) / 2
|
|
16778
|
-
});
|
|
16779
|
-
|
|
16780
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
16781
|
-
var getBoundsFromPoints2 = (points) => {
|
|
16782
|
-
if (points.length === 0) {
|
|
16783
|
-
return null;
|
|
16784
|
-
}
|
|
16785
|
-
let minX = points[0].x;
|
|
16786
|
-
let minY = points[0].y;
|
|
16787
|
-
let maxX = points[0].x;
|
|
16788
|
-
let maxY = points[0].y;
|
|
16789
|
-
for (let i = 1; i < points.length; i++) {
|
|
16790
|
-
const point4 = points[i];
|
|
16791
|
-
if (point4.x < minX) minX = point4.x;
|
|
16792
|
-
if (point4.y < minY) minY = point4.y;
|
|
16793
|
-
if (point4.x > maxX) maxX = point4.x;
|
|
16794
|
-
if (point4.y > maxY) maxY = point4.y;
|
|
16795
|
-
}
|
|
16796
|
-
return { minX, minY, maxX, maxY };
|
|
16797
|
-
};
|
|
16798
|
-
|
|
16799
16969
|
// lib/utils/get-board-outline-polygons.ts
|
|
16800
16970
|
var same = (a, b) => distance2(a, b) < 1e-4;
|
|
16801
16971
|
var getBoardOutlinePolygons = (tracks) => {
|
|
@@ -17113,20 +17283,20 @@ var distanceFromRouteMidpoint = (route, point4) => {
|
|
|
17113
17283
|
return Math.hypot(midpoint2.x - point4.x, midpoint2.y - point4.y);
|
|
17114
17284
|
};
|
|
17115
17285
|
var getSilkscreenArcPath = (arc2, footprintCenter, silkscreenTracks) => {
|
|
17116
|
-
const
|
|
17117
|
-
arc2.start
|
|
17118
|
-
arc2.
|
|
17119
|
-
arc2.
|
|
17120
|
-
arc2.
|
|
17121
|
-
|
|
17122
|
-
arc2.largeArc,
|
|
17123
|
-
sweepFlag2
|
|
17124
|
-
);
|
|
17286
|
+
const arcOptions = {
|
|
17287
|
+
start: arc2.start,
|
|
17288
|
+
end: arc2.end,
|
|
17289
|
+
radius: arc2.radiusX,
|
|
17290
|
+
largeArcFlag: arc2.largeArc
|
|
17291
|
+
};
|
|
17125
17292
|
const sweepFlag = arc2.sweepDirection === "CW";
|
|
17126
|
-
const arcPath =
|
|
17293
|
+
const arcPath = generateArcFromSweep({ ...arcOptions, sweepFlag });
|
|
17127
17294
|
const semicircleRole = classifySemicircle(arc2, silkscreenTracks);
|
|
17128
17295
|
if (!semicircleRole) return arcPath;
|
|
17129
|
-
const oppositeArcPath =
|
|
17296
|
+
const oppositeArcPath = generateArcFromSweep({
|
|
17297
|
+
...arcOptions,
|
|
17298
|
+
sweepFlag: !sweepFlag
|
|
17299
|
+
});
|
|
17130
17300
|
const arcDistance = distanceFromRouteMidpoint(arcPath, footprintCenter);
|
|
17131
17301
|
const oppositeDistance = distanceFromRouteMidpoint(
|
|
17132
17302
|
oppositeArcPath,
|
|
@@ -17464,7 +17634,31 @@ var handleFabricationNotePath = (track, index) => pcb_fabrication_note_path.pars
|
|
|
17464
17634
|
stroke_width: mil10ToMm(track.width)
|
|
17465
17635
|
});
|
|
17466
17636
|
var handleFabricationNoteSolidRegion = (solidRegion, index) => {
|
|
17467
|
-
const
|
|
17637
|
+
const commands = parseEasyEdaPathCommands(solidRegion.pathData);
|
|
17638
|
+
const pathWarning = !commands ? "Invalid EasyEDA SOLIDREGION path" : commands.slice(1).some(({ command }) => command.toUpperCase() === "M") ? "Multiple EasyEDA SOLIDREGION subpaths are not supported" : void 0;
|
|
17639
|
+
if (pathWarning) {
|
|
17640
|
+
console.warn(
|
|
17641
|
+
`Skipping EasyEDA fabrication note ${solidRegion.id ?? index + 1}: ${pathWarning}`
|
|
17642
|
+
);
|
|
17643
|
+
return null;
|
|
17644
|
+
}
|
|
17645
|
+
let rawRoute;
|
|
17646
|
+
try {
|
|
17647
|
+
rawRoute = expandEasyEdaPathData(solidRegion.pathData);
|
|
17648
|
+
} catch (error) {
|
|
17649
|
+
if (!(error instanceof Error) || ![
|
|
17650
|
+
BEZIER_SUBDIVISION_LIMIT_MESSAGE,
|
|
17651
|
+
EASYEDA_PATH_LIMIT_MESSAGE,
|
|
17652
|
+
INVALID_BEZIER_GEOMETRY_MESSAGE,
|
|
17653
|
+
INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE
|
|
17654
|
+
].includes(error.message)) {
|
|
17655
|
+
throw error;
|
|
17656
|
+
}
|
|
17657
|
+
console.warn(
|
|
17658
|
+
`Skipping EasyEDA fabrication note ${solidRegion.id ?? index + 1}: ${error.message}`
|
|
17659
|
+
);
|
|
17660
|
+
return null;
|
|
17661
|
+
}
|
|
17468
17662
|
const route = rawRoute.map((point4) => ({
|
|
17469
17663
|
x: mil10ToMm(point4.x),
|
|
17470
17664
|
y: mil10ToMm(point4.y)
|