easyeda 0.0.386 → 0.0.387
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/index.js
CHANGED
|
@@ -15380,10 +15380,25 @@ var mil2mm = (mil) => {
|
|
|
15380
15380
|
// lib/constants.ts
|
|
15381
15381
|
var DEFAULT_PCB_THICKNESS_MM = 1.6;
|
|
15382
15382
|
|
|
15383
|
+
// lib/utils/easyeda-path-limits.ts
|
|
15384
|
+
var MAX_EASYEDA_PATH_POINTS = 8192;
|
|
15385
|
+
var EASYEDA_PATH_LIMIT_MESSAGE = "EasyEDA SOLIDREGION path exceeds the vertex limit";
|
|
15386
|
+
var INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE = "Invalid EasyEDA SOLIDREGION path geometry";
|
|
15387
|
+
|
|
15383
15388
|
// lib/math/arc-utils.ts
|
|
15384
|
-
function generateArcFromSweep(
|
|
15385
|
-
|
|
15386
|
-
|
|
15389
|
+
function generateArcFromSweep({
|
|
15390
|
+
start,
|
|
15391
|
+
end,
|
|
15392
|
+
radius,
|
|
15393
|
+
largeArcFlag,
|
|
15394
|
+
sweepFlag,
|
|
15395
|
+
maxSegments = MAX_EASYEDA_PATH_POINTS - 1
|
|
15396
|
+
}) {
|
|
15397
|
+
const { x: startX, y: startY } = start;
|
|
15398
|
+
const { x: endX, y: endY } = end;
|
|
15399
|
+
if (![startX, startY, endX, endY, radius].every(Number.isFinite) || !Number.isInteger(maxSegments) || maxSegments < 1) {
|
|
15400
|
+
throw new Error(INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE);
|
|
15401
|
+
}
|
|
15387
15402
|
const midX = (startX + endX) / 2;
|
|
15388
15403
|
const midY = (startY + endY) / 2;
|
|
15389
15404
|
const dx = endX - startX;
|
|
@@ -15409,12 +15424,26 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
15409
15424
|
const minNumPoints = Math.max(2, Math.ceil(arcAngle * radius));
|
|
15410
15425
|
const isSemicircle = Math.abs(arcAngle - Math.PI) < 1e-6;
|
|
15411
15426
|
const numPoints = isSemicircle ? minNumPoints + minNumPoints % 2 : minNumPoints;
|
|
15427
|
+
if (![centerX, centerY, startAngle, endAngle, numPoints].every(Number.isFinite)) {
|
|
15428
|
+
throw new Error(INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE);
|
|
15429
|
+
}
|
|
15430
|
+
const sampledSegments = Math.min(
|
|
15431
|
+
numPoints,
|
|
15432
|
+
maxSegments,
|
|
15433
|
+
MAX_EASYEDA_PATH_POINTS - 1
|
|
15434
|
+
);
|
|
15412
15435
|
const path = [];
|
|
15413
|
-
for (let i = 0; i <=
|
|
15414
|
-
const
|
|
15436
|
+
for (let i = 0; i <= sampledSegments; i++) {
|
|
15437
|
+
const pointIndex = sampledSegments === numPoints ? i : Math.round(
|
|
15438
|
+
numPoints <= Number.MAX_SAFE_INTEGER / sampledSegments ? i * numPoints / sampledSegments : i / sampledSegments * numPoints
|
|
15439
|
+
);
|
|
15440
|
+
const t = pointIndex / numPoints;
|
|
15415
15441
|
const angle2 = startAngle + t * (endAngle - startAngle);
|
|
15416
15442
|
const x = centerX + radius * Math.cos(angle2);
|
|
15417
15443
|
const y = centerY + radius * Math.sin(angle2);
|
|
15444
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) {
|
|
15445
|
+
throw new Error(INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE);
|
|
15446
|
+
}
|
|
15418
15447
|
path.push({ x, y });
|
|
15419
15448
|
}
|
|
15420
15449
|
return path;
|
|
@@ -15529,12 +15558,197 @@ var convertEasyEdaNpthCutoutsToHoles = (circuitJson, npthRegions) => {
|
|
|
15529
15558
|
});
|
|
15530
15559
|
};
|
|
15531
15560
|
|
|
15561
|
+
// lib/utils/append-easyeda-path-point.ts
|
|
15562
|
+
var appendEasyEdaPathPoint = (route, point4) => {
|
|
15563
|
+
if (!Number.isFinite(point4.x) || !Number.isFinite(point4.y)) {
|
|
15564
|
+
throw new Error(INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE);
|
|
15565
|
+
}
|
|
15566
|
+
const firstPoint = route[0] ?? point4;
|
|
15567
|
+
const needsClosingPoint = firstPoint.x !== point4.x || firstPoint.y !== point4.y;
|
|
15568
|
+
if (route.length + 1 + Number(needsClosingPoint) > MAX_EASYEDA_PATH_POINTS) {
|
|
15569
|
+
throw new Error(EASYEDA_PATH_LIMIT_MESSAGE);
|
|
15570
|
+
}
|
|
15571
|
+
route.push(point4);
|
|
15572
|
+
};
|
|
15573
|
+
|
|
15574
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
|
|
15575
|
+
function orientation(p, q, r) {
|
|
15576
|
+
const val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
15577
|
+
if (val === 0) return 0;
|
|
15578
|
+
return val > 0 ? 1 : 2;
|
|
15579
|
+
}
|
|
15580
|
+
function pointToSegmentDistance(p, v, w) {
|
|
15581
|
+
const l2 = (w.x - v.x) ** 2 + (w.y - v.y) ** 2;
|
|
15582
|
+
if (l2 === 0) return distance2(p, v);
|
|
15583
|
+
let t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2;
|
|
15584
|
+
t = Math.max(0, Math.min(1, t));
|
|
15585
|
+
const projection = {
|
|
15586
|
+
x: v.x + t * (w.x - v.x),
|
|
15587
|
+
y: v.y + t * (w.y - v.y)
|
|
15588
|
+
};
|
|
15589
|
+
return distance2(p, projection);
|
|
15590
|
+
}
|
|
15591
|
+
function distance2(p1, p2) {
|
|
15592
|
+
const dx = p1.x - p2.x;
|
|
15593
|
+
const dy = p1.y - p2.y;
|
|
15594
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
15595
|
+
}
|
|
15596
|
+
|
|
15597
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-GIGMPRPV.js
|
|
15598
|
+
var getUnitVectorFromDirection = (direction) => {
|
|
15599
|
+
switch (direction) {
|
|
15600
|
+
case "up":
|
|
15601
|
+
return { x: 0, y: 1 };
|
|
15602
|
+
case "down":
|
|
15603
|
+
return { x: 0, y: -1 };
|
|
15604
|
+
case "left":
|
|
15605
|
+
return { x: -1, y: 0 };
|
|
15606
|
+
case "right":
|
|
15607
|
+
return { x: 1, y: 0 };
|
|
15608
|
+
}
|
|
15609
|
+
};
|
|
15610
|
+
|
|
15611
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-5J3PCV4D.js
|
|
15612
|
+
function midpoint(p1, p2) {
|
|
15613
|
+
return {
|
|
15614
|
+
x: (p1.x + p2.x) / 2,
|
|
15615
|
+
y: (p1.y + p2.y) / 2
|
|
15616
|
+
};
|
|
15617
|
+
}
|
|
15618
|
+
|
|
15619
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-3WCUPG5S.js
|
|
15620
|
+
var getBoundsCenter = (bounds) => ({
|
|
15621
|
+
x: (bounds.minX + bounds.maxX) / 2,
|
|
15622
|
+
y: (bounds.minY + bounds.maxY) / 2
|
|
15623
|
+
});
|
|
15624
|
+
|
|
15625
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
15626
|
+
var getBoundsFromPoints2 = (points) => {
|
|
15627
|
+
if (points.length === 0) {
|
|
15628
|
+
return null;
|
|
15629
|
+
}
|
|
15630
|
+
let minX = points[0].x;
|
|
15631
|
+
let minY = points[0].y;
|
|
15632
|
+
let maxX = points[0].x;
|
|
15633
|
+
let maxY = points[0].y;
|
|
15634
|
+
for (let i = 1; i < points.length; i++) {
|
|
15635
|
+
const point4 = points[i];
|
|
15636
|
+
if (point4.x < minX) minX = point4.x;
|
|
15637
|
+
if (point4.y < minY) minY = point4.y;
|
|
15638
|
+
if (point4.x > maxX) maxX = point4.x;
|
|
15639
|
+
if (point4.y > maxY) maxY = point4.y;
|
|
15640
|
+
}
|
|
15641
|
+
return { minX, minY, maxX, maxY };
|
|
15642
|
+
};
|
|
15643
|
+
|
|
15644
|
+
// lib/utils/flatten-bezier-curve.ts
|
|
15645
|
+
var MAX_SUBDIVISION_DEPTH = 20;
|
|
15646
|
+
var BEZIER_SUBDIVISION_LIMIT_MESSAGE = "Bezier curve exceeds the subdivision limit";
|
|
15647
|
+
var INVALID_BEZIER_GEOMETRY_MESSAGE = "Invalid Bezier curve geometry";
|
|
15648
|
+
var flattenBezierCurve = ({
|
|
15649
|
+
controlPoints,
|
|
15650
|
+
tolerance,
|
|
15651
|
+
maxPoints = MAX_EASYEDA_PATH_POINTS
|
|
15652
|
+
}) => {
|
|
15653
|
+
if (![3, 4].includes(controlPoints.length) || !Number.isFinite(tolerance) || tolerance <= 0 || controlPoints.some(
|
|
15654
|
+
(point4) => !Number.isFinite(point4.x) || !Number.isFinite(point4.y)
|
|
15655
|
+
)) {
|
|
15656
|
+
throw new Error(INVALID_BEZIER_GEOMETRY_MESSAGE);
|
|
15657
|
+
}
|
|
15658
|
+
if (!Number.isInteger(maxPoints) || maxPoints < 2) {
|
|
15659
|
+
throw new Error(EASYEDA_PATH_LIMIT_MESSAGE);
|
|
15660
|
+
}
|
|
15661
|
+
const pointLimit = Math.min(maxPoints, MAX_EASYEDA_PATH_POINTS);
|
|
15662
|
+
const route = [controlPoints[0]];
|
|
15663
|
+
const pending = [{ points: controlPoints, depth: 0 }];
|
|
15664
|
+
while (pending.length) {
|
|
15665
|
+
const { points, depth } = pending.pop();
|
|
15666
|
+
const start = points[0];
|
|
15667
|
+
const end = points.at(-1);
|
|
15668
|
+
if (points.slice(1, -1).every(
|
|
15669
|
+
(point4) => pointToSegmentDistance(point4, start, end) <= tolerance
|
|
15670
|
+
)) {
|
|
15671
|
+
route.push(end);
|
|
15672
|
+
continue;
|
|
15673
|
+
}
|
|
15674
|
+
if (depth >= MAX_SUBDIVISION_DEPTH) {
|
|
15675
|
+
throw new Error(BEZIER_SUBDIVISION_LIMIT_MESSAGE);
|
|
15676
|
+
}
|
|
15677
|
+
if (route.length + pending.length + 2 > pointLimit) {
|
|
15678
|
+
throw new Error(EASYEDA_PATH_LIMIT_MESSAGE);
|
|
15679
|
+
}
|
|
15680
|
+
let level = points;
|
|
15681
|
+
const left = [start];
|
|
15682
|
+
const right = [end];
|
|
15683
|
+
while (level.length > 1) {
|
|
15684
|
+
level = level.slice(1).map((point4, index) => midpoint(level[index], point4));
|
|
15685
|
+
left.push(level[0]);
|
|
15686
|
+
right.unshift(level.at(-1));
|
|
15687
|
+
}
|
|
15688
|
+
pending.push(
|
|
15689
|
+
{ points: right, depth: depth + 1 },
|
|
15690
|
+
{ points: left, depth: depth + 1 }
|
|
15691
|
+
);
|
|
15692
|
+
}
|
|
15693
|
+
return route;
|
|
15694
|
+
};
|
|
15695
|
+
|
|
15696
|
+
// lib/utils/expand-easyeda-bezier-command.ts
|
|
15697
|
+
var BEZIER_TOLERANCE = 1e-3 / mil10ToMm(1);
|
|
15698
|
+
var expandEasyEdaBezierCommand = (pathCommand, ctx) => {
|
|
15699
|
+
const command = pathCommand.command.toUpperCase();
|
|
15700
|
+
const relative = command !== pathCommand.command;
|
|
15701
|
+
const groupSize = command === "C" ? 6 : command === "T" ? 2 : 4;
|
|
15702
|
+
const route = [];
|
|
15703
|
+
let { currentPoint, cubicControl, quadraticControl } = ctx;
|
|
15704
|
+
for (let offset = 0; offset < pathCommand.arguments.length; offset += groupSize) {
|
|
15705
|
+
if (route.length >= ctx.remainingPoints) {
|
|
15706
|
+
throw new Error(EASYEDA_PATH_LIMIT_MESSAGE);
|
|
15707
|
+
}
|
|
15708
|
+
const coordinates = [];
|
|
15709
|
+
for (let index = offset; index < offset + groupSize; index += 2) {
|
|
15710
|
+
coordinates.push({
|
|
15711
|
+
x: pathCommand.arguments[index] + (relative ? currentPoint.x : 0),
|
|
15712
|
+
y: pathCommand.arguments[index + 1] + (relative ? currentPoint.y : 0)
|
|
15713
|
+
});
|
|
15714
|
+
}
|
|
15715
|
+
const end = coordinates.at(-1);
|
|
15716
|
+
let controlPoints;
|
|
15717
|
+
if (command === "C" || command === "S") {
|
|
15718
|
+
const firstControl = command === "C" ? coordinates[0] : cubicControl ? {
|
|
15719
|
+
x: 2 * currentPoint.x - cubicControl.x,
|
|
15720
|
+
y: 2 * currentPoint.y - cubicControl.y
|
|
15721
|
+
} : currentPoint;
|
|
15722
|
+
cubicControl = coordinates.at(-2);
|
|
15723
|
+
quadraticControl = void 0;
|
|
15724
|
+
controlPoints = [currentPoint, firstControl, cubicControl, end];
|
|
15725
|
+
} else {
|
|
15726
|
+
quadraticControl = command === "Q" ? coordinates[0] : quadraticControl ? {
|
|
15727
|
+
x: 2 * currentPoint.x - quadraticControl.x,
|
|
15728
|
+
y: 2 * currentPoint.y - quadraticControl.y
|
|
15729
|
+
} : currentPoint;
|
|
15730
|
+
cubicControl = void 0;
|
|
15731
|
+
controlPoints = [currentPoint, quadraticControl, end];
|
|
15732
|
+
}
|
|
15733
|
+
const points = flattenBezierCurve({
|
|
15734
|
+
controlPoints,
|
|
15735
|
+
tolerance: BEZIER_TOLERANCE,
|
|
15736
|
+
maxPoints: ctx.remainingPoints - route.length + 1
|
|
15737
|
+
});
|
|
15738
|
+
for (let index = 1; index < points.length; index++) {
|
|
15739
|
+
route.push(points[index]);
|
|
15740
|
+
}
|
|
15741
|
+
currentPoint = end;
|
|
15742
|
+
}
|
|
15743
|
+
return { route, currentPoint, cubicControl, quadraticControl };
|
|
15744
|
+
};
|
|
15745
|
+
|
|
15532
15746
|
// lib/utils/expand-easyeda-path-data.ts
|
|
15533
15747
|
var expandEasyEdaPathData = (pathData) => {
|
|
15534
15748
|
const commands = parseEasyEdaPathCommands(pathData);
|
|
15535
15749
|
if (!commands) throw new Error("Invalid EasyEDA SOLIDREGION path");
|
|
15536
15750
|
for (const { command } of commands) {
|
|
15537
|
-
if (!/^[
|
|
15751
|
+
if (!/^[MLHVAZCSQT]$/i.test(command)) {
|
|
15538
15752
|
throw new Error(
|
|
15539
15753
|
`Unsupported EasyEDA SOLIDREGION path command: ${command}`
|
|
15540
15754
|
);
|
|
@@ -15547,14 +15761,18 @@ var expandEasyEdaPathData = (pathData) => {
|
|
|
15547
15761
|
let currentPoint;
|
|
15548
15762
|
let subpathStart;
|
|
15549
15763
|
let afterClose = false;
|
|
15764
|
+
let cubicControl;
|
|
15765
|
+
let quadraticControl;
|
|
15550
15766
|
for (const pathCommand of commands) {
|
|
15551
15767
|
const command = pathCommand.command.toUpperCase();
|
|
15552
15768
|
const relative = pathCommand.command !== command;
|
|
15553
15769
|
const commandArguments = pathCommand.arguments;
|
|
15770
|
+
if (command !== "C" && command !== "S") cubicControl = void 0;
|
|
15771
|
+
if (command !== "Q" && command !== "T") quadraticControl = void 0;
|
|
15554
15772
|
if (afterClose && command !== "Z" && currentPoint) {
|
|
15555
15773
|
const lastPoint = rawRoute.at(-1);
|
|
15556
15774
|
if (lastPoint?.x !== currentPoint.x || lastPoint?.y !== currentPoint.y) {
|
|
15557
|
-
rawRoute
|
|
15775
|
+
appendEasyEdaPathPoint(rawRoute, currentPoint);
|
|
15558
15776
|
}
|
|
15559
15777
|
}
|
|
15560
15778
|
afterClose = command === "Z";
|
|
@@ -15564,7 +15782,7 @@ var expandEasyEdaPathData = (pathData) => {
|
|
|
15564
15782
|
x: commandArguments[offset] + (relative ? currentPoint?.x ?? 0 : 0),
|
|
15565
15783
|
y: commandArguments[offset + 1] + (relative ? currentPoint?.y ?? 0 : 0)
|
|
15566
15784
|
};
|
|
15567
|
-
rawRoute
|
|
15785
|
+
appendEasyEdaPathPoint(rawRoute, currentPoint);
|
|
15568
15786
|
if (command === "M" && offset === 0) subpathStart = currentPoint;
|
|
15569
15787
|
}
|
|
15570
15788
|
} else if ((command === "H" || command === "V") && currentPoint) {
|
|
@@ -15573,32 +15791,35 @@ var expandEasyEdaPathData = (pathData) => {
|
|
|
15573
15791
|
x: command === "H" ? coordinate + (relative ? currentPoint.x : 0) : currentPoint.x,
|
|
15574
15792
|
y: command === "V" ? coordinate + (relative ? currentPoint.y : 0) : currentPoint.y
|
|
15575
15793
|
};
|
|
15576
|
-
rawRoute
|
|
15794
|
+
appendEasyEdaPathPoint(rawRoute, currentPoint);
|
|
15577
15795
|
}
|
|
15796
|
+
} else if (/^[CSQT]$/.test(command) && currentPoint) {
|
|
15797
|
+
const curve = expandEasyEdaBezierCommand(pathCommand, {
|
|
15798
|
+
currentPoint,
|
|
15799
|
+
cubicControl,
|
|
15800
|
+
quadraticControl,
|
|
15801
|
+
remainingPoints: MAX_EASYEDA_PATH_POINTS - rawRoute.length
|
|
15802
|
+
});
|
|
15803
|
+
for (const point4 of curve.route) appendEasyEdaPathPoint(rawRoute, point4);
|
|
15804
|
+
currentPoint = curve.currentPoint;
|
|
15805
|
+
cubicControl = curve.cubicControl;
|
|
15806
|
+
quadraticControl = curve.quadraticControl;
|
|
15578
15807
|
} else if (command === "A" && currentPoint && commandArguments.length >= 7) {
|
|
15579
15808
|
for (let offset = 0; offset + 6 < commandArguments.length; offset += 7) {
|
|
15580
15809
|
const [radiusX, , , largeArcFlag, sweepFlag, endpointX, endpointY] = commandArguments.slice(offset, offset + 7);
|
|
15581
15810
|
const endX = endpointX + (relative ? currentPoint.x : 0);
|
|
15582
15811
|
const endY = endpointY + (relative ? currentPoint.y : 0);
|
|
15583
|
-
const
|
|
15584
|
-
currentPoint
|
|
15585
|
-
|
|
15586
|
-
|
|
15587
|
-
|
|
15588
|
-
|
|
15589
|
-
|
|
15590
|
-
|
|
15591
|
-
)
|
|
15592
|
-
|
|
15593
|
-
|
|
15594
|
-
{ length: maxArcSegments + 1 },
|
|
15595
|
-
(_, pointIndex) => generatedArcRoute.at(
|
|
15596
|
-
Math.round(
|
|
15597
|
-
pointIndex * (generatedArcRoute.length - 1) / maxArcSegments
|
|
15598
|
-
)
|
|
15599
|
-
)
|
|
15600
|
-
).filter((point4) => !!point4);
|
|
15601
|
-
rawRoute.push(...arcRoute.slice(1));
|
|
15812
|
+
const arcRoute = generateArcFromSweep({
|
|
15813
|
+
start: currentPoint,
|
|
15814
|
+
end: { x: endX, y: endY },
|
|
15815
|
+
radius: radiusX,
|
|
15816
|
+
largeArcFlag: largeArcFlag === 1,
|
|
15817
|
+
sweepFlag: sweepFlag === 1,
|
|
15818
|
+
maxSegments: 16
|
|
15819
|
+
});
|
|
15820
|
+
for (let index = 1; index < arcRoute.length; index++) {
|
|
15821
|
+
appendEasyEdaPathPoint(rawRoute, arcRoute[index]);
|
|
15822
|
+
}
|
|
15602
15823
|
currentPoint = { x: endX, y: endY };
|
|
15603
15824
|
}
|
|
15604
15825
|
} else if (command === "Z" && subpathStart) {
|
|
@@ -15608,57 +15829,6 @@ var expandEasyEdaPathData = (pathData) => {
|
|
|
15608
15829
|
return rawRoute;
|
|
15609
15830
|
};
|
|
15610
15831
|
|
|
15611
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
|
|
15612
|
-
function orientation(p, q, r) {
|
|
15613
|
-
const val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
15614
|
-
if (val === 0) return 0;
|
|
15615
|
-
return val > 0 ? 1 : 2;
|
|
15616
|
-
}
|
|
15617
|
-
function distance2(p1, p2) {
|
|
15618
|
-
const dx = p1.x - p2.x;
|
|
15619
|
-
const dy = p1.y - p2.y;
|
|
15620
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
15621
|
-
}
|
|
15622
|
-
|
|
15623
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-GIGMPRPV.js
|
|
15624
|
-
var getUnitVectorFromDirection = (direction) => {
|
|
15625
|
-
switch (direction) {
|
|
15626
|
-
case "up":
|
|
15627
|
-
return { x: 0, y: 1 };
|
|
15628
|
-
case "down":
|
|
15629
|
-
return { x: 0, y: -1 };
|
|
15630
|
-
case "left":
|
|
15631
|
-
return { x: -1, y: 0 };
|
|
15632
|
-
case "right":
|
|
15633
|
-
return { x: 1, y: 0 };
|
|
15634
|
-
}
|
|
15635
|
-
};
|
|
15636
|
-
|
|
15637
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-3WCUPG5S.js
|
|
15638
|
-
var getBoundsCenter = (bounds) => ({
|
|
15639
|
-
x: (bounds.minX + bounds.maxX) / 2,
|
|
15640
|
-
y: (bounds.minY + bounds.maxY) / 2
|
|
15641
|
-
});
|
|
15642
|
-
|
|
15643
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
15644
|
-
var getBoundsFromPoints2 = (points) => {
|
|
15645
|
-
if (points.length === 0) {
|
|
15646
|
-
return null;
|
|
15647
|
-
}
|
|
15648
|
-
let minX = points[0].x;
|
|
15649
|
-
let minY = points[0].y;
|
|
15650
|
-
let maxX = points[0].x;
|
|
15651
|
-
let maxY = points[0].y;
|
|
15652
|
-
for (let i = 1; i < points.length; i++) {
|
|
15653
|
-
const point4 = points[i];
|
|
15654
|
-
if (point4.x < minX) minX = point4.x;
|
|
15655
|
-
if (point4.y < minY) minY = point4.y;
|
|
15656
|
-
if (point4.x > maxX) maxX = point4.x;
|
|
15657
|
-
if (point4.y > maxY) maxY = point4.y;
|
|
15658
|
-
}
|
|
15659
|
-
return { minX, minY, maxX, maxY };
|
|
15660
|
-
};
|
|
15661
|
-
|
|
15662
15832
|
// lib/utils/get-board-outline-polygons.ts
|
|
15663
15833
|
var same = (a, b) => distance2(a, b) < 1e-4;
|
|
15664
15834
|
var getBoardOutlinePolygons = (tracks) => {
|
|
@@ -15976,20 +16146,20 @@ var distanceFromRouteMidpoint = (route, point4) => {
|
|
|
15976
16146
|
return Math.hypot(midpoint2.x - point4.x, midpoint2.y - point4.y);
|
|
15977
16147
|
};
|
|
15978
16148
|
var getSilkscreenArcPath = (arc2, footprintCenter, silkscreenTracks) => {
|
|
15979
|
-
const
|
|
15980
|
-
arc2.start
|
|
15981
|
-
arc2.
|
|
15982
|
-
arc2.
|
|
15983
|
-
arc2.
|
|
15984
|
-
|
|
15985
|
-
arc2.largeArc,
|
|
15986
|
-
sweepFlag2
|
|
15987
|
-
);
|
|
16149
|
+
const arcOptions = {
|
|
16150
|
+
start: arc2.start,
|
|
16151
|
+
end: arc2.end,
|
|
16152
|
+
radius: arc2.radiusX,
|
|
16153
|
+
largeArcFlag: arc2.largeArc
|
|
16154
|
+
};
|
|
15988
16155
|
const sweepFlag = arc2.sweepDirection === "CW";
|
|
15989
|
-
const arcPath =
|
|
16156
|
+
const arcPath = generateArcFromSweep({ ...arcOptions, sweepFlag });
|
|
15990
16157
|
const semicircleRole = classifySemicircle(arc2, silkscreenTracks);
|
|
15991
16158
|
if (!semicircleRole) return arcPath;
|
|
15992
|
-
const oppositeArcPath =
|
|
16159
|
+
const oppositeArcPath = generateArcFromSweep({
|
|
16160
|
+
...arcOptions,
|
|
16161
|
+
sweepFlag: !sweepFlag
|
|
16162
|
+
});
|
|
15993
16163
|
const arcDistance = distanceFromRouteMidpoint(arcPath, footprintCenter);
|
|
15994
16164
|
const oppositeDistance = distanceFromRouteMidpoint(
|
|
15995
16165
|
oppositeArcPath,
|
|
@@ -16327,7 +16497,31 @@ var handleFabricationNotePath = (track, index) => pcb_fabrication_note_path.pars
|
|
|
16327
16497
|
stroke_width: mil10ToMm(track.width)
|
|
16328
16498
|
});
|
|
16329
16499
|
var handleFabricationNoteSolidRegion = (solidRegion, index) => {
|
|
16330
|
-
const
|
|
16500
|
+
const commands = parseEasyEdaPathCommands(solidRegion.pathData);
|
|
16501
|
+
const pathWarning = !commands ? "Invalid EasyEDA SOLIDREGION path" : commands.slice(1).some(({ command }) => command.toUpperCase() === "M") ? "Multiple EasyEDA SOLIDREGION subpaths are not supported" : void 0;
|
|
16502
|
+
if (pathWarning) {
|
|
16503
|
+
console.warn(
|
|
16504
|
+
`Skipping EasyEDA fabrication note ${solidRegion.id ?? index + 1}: ${pathWarning}`
|
|
16505
|
+
);
|
|
16506
|
+
return null;
|
|
16507
|
+
}
|
|
16508
|
+
let rawRoute;
|
|
16509
|
+
try {
|
|
16510
|
+
rawRoute = expandEasyEdaPathData(solidRegion.pathData);
|
|
16511
|
+
} catch (error) {
|
|
16512
|
+
if (!(error instanceof Error) || ![
|
|
16513
|
+
BEZIER_SUBDIVISION_LIMIT_MESSAGE,
|
|
16514
|
+
EASYEDA_PATH_LIMIT_MESSAGE,
|
|
16515
|
+
INVALID_BEZIER_GEOMETRY_MESSAGE,
|
|
16516
|
+
INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE
|
|
16517
|
+
].includes(error.message)) {
|
|
16518
|
+
throw error;
|
|
16519
|
+
}
|
|
16520
|
+
console.warn(
|
|
16521
|
+
`Skipping EasyEDA fabrication note ${solidRegion.id ?? index + 1}: ${error.message}`
|
|
16522
|
+
);
|
|
16523
|
+
return null;
|
|
16524
|
+
}
|
|
16331
16525
|
const route = rawRoute.map((point4) => ({
|
|
16332
16526
|
x: mil10ToMm(point4.x),
|
|
16333
16527
|
y: mil10ToMm(point4.y)
|