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/browser/index.js
CHANGED
|
@@ -19177,10 +19177,25 @@ var mil2mm = (mil) => {
|
|
|
19177
19177
|
// lib/constants.ts
|
|
19178
19178
|
var DEFAULT_PCB_THICKNESS_MM = 1.6;
|
|
19179
19179
|
|
|
19180
|
+
// lib/utils/easyeda-path-limits.ts
|
|
19181
|
+
var MAX_EASYEDA_PATH_POINTS = 8192;
|
|
19182
|
+
var EASYEDA_PATH_LIMIT_MESSAGE = "EasyEDA SOLIDREGION path exceeds the vertex limit";
|
|
19183
|
+
var INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE = "Invalid EasyEDA SOLIDREGION path geometry";
|
|
19184
|
+
|
|
19180
19185
|
// lib/math/arc-utils.ts
|
|
19181
|
-
function generateArcFromSweep(
|
|
19182
|
-
|
|
19183
|
-
|
|
19186
|
+
function generateArcFromSweep({
|
|
19187
|
+
start,
|
|
19188
|
+
end,
|
|
19189
|
+
radius,
|
|
19190
|
+
largeArcFlag,
|
|
19191
|
+
sweepFlag,
|
|
19192
|
+
maxSegments = MAX_EASYEDA_PATH_POINTS - 1
|
|
19193
|
+
}) {
|
|
19194
|
+
const { x: startX, y: startY } = start;
|
|
19195
|
+
const { x: endX, y: endY } = end;
|
|
19196
|
+
if (![startX, startY, endX, endY, radius].every(Number.isFinite) || !Number.isInteger(maxSegments) || maxSegments < 1) {
|
|
19197
|
+
throw new Error(INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE);
|
|
19198
|
+
}
|
|
19184
19199
|
const midX = (startX + endX) / 2;
|
|
19185
19200
|
const midY = (startY + endY) / 2;
|
|
19186
19201
|
const dx = endX - startX;
|
|
@@ -19206,12 +19221,26 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
19206
19221
|
const minNumPoints = Math.max(2, Math.ceil(arcAngle * radius));
|
|
19207
19222
|
const isSemicircle = Math.abs(arcAngle - Math.PI) < 1e-6;
|
|
19208
19223
|
const numPoints = isSemicircle ? minNumPoints + minNumPoints % 2 : minNumPoints;
|
|
19224
|
+
if (![centerX, centerY, startAngle, endAngle, numPoints].every(Number.isFinite)) {
|
|
19225
|
+
throw new Error(INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE);
|
|
19226
|
+
}
|
|
19227
|
+
const sampledSegments = Math.min(
|
|
19228
|
+
numPoints,
|
|
19229
|
+
maxSegments,
|
|
19230
|
+
MAX_EASYEDA_PATH_POINTS - 1
|
|
19231
|
+
);
|
|
19209
19232
|
const path = [];
|
|
19210
|
-
for (let i = 0; i <=
|
|
19211
|
-
const
|
|
19233
|
+
for (let i = 0; i <= sampledSegments; i++) {
|
|
19234
|
+
const pointIndex = sampledSegments === numPoints ? i : Math.round(
|
|
19235
|
+
numPoints <= Number.MAX_SAFE_INTEGER / sampledSegments ? i * numPoints / sampledSegments : i / sampledSegments * numPoints
|
|
19236
|
+
);
|
|
19237
|
+
const t = pointIndex / numPoints;
|
|
19212
19238
|
const angle2 = startAngle + t * (endAngle - startAngle);
|
|
19213
19239
|
const x = centerX + radius * Math.cos(angle2);
|
|
19214
19240
|
const y = centerY + radius * Math.sin(angle2);
|
|
19241
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) {
|
|
19242
|
+
throw new Error(INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE);
|
|
19243
|
+
}
|
|
19215
19244
|
path.push({ x, y });
|
|
19216
19245
|
}
|
|
19217
19246
|
return path;
|
|
@@ -19326,12 +19355,197 @@ var convertEasyEdaNpthCutoutsToHoles = (circuitJson, npthRegions) => {
|
|
|
19326
19355
|
});
|
|
19327
19356
|
};
|
|
19328
19357
|
|
|
19358
|
+
// lib/utils/append-easyeda-path-point.ts
|
|
19359
|
+
var appendEasyEdaPathPoint = (route, point4) => {
|
|
19360
|
+
if (!Number.isFinite(point4.x) || !Number.isFinite(point4.y)) {
|
|
19361
|
+
throw new Error(INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE);
|
|
19362
|
+
}
|
|
19363
|
+
const firstPoint = route[0] ?? point4;
|
|
19364
|
+
const needsClosingPoint = firstPoint.x !== point4.x || firstPoint.y !== point4.y;
|
|
19365
|
+
if (route.length + 1 + Number(needsClosingPoint) > MAX_EASYEDA_PATH_POINTS) {
|
|
19366
|
+
throw new Error(EASYEDA_PATH_LIMIT_MESSAGE);
|
|
19367
|
+
}
|
|
19368
|
+
route.push(point4);
|
|
19369
|
+
};
|
|
19370
|
+
|
|
19371
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
|
|
19372
|
+
function orientation(p, q, r) {
|
|
19373
|
+
const val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
19374
|
+
if (val === 0) return 0;
|
|
19375
|
+
return val > 0 ? 1 : 2;
|
|
19376
|
+
}
|
|
19377
|
+
function pointToSegmentDistance(p, v, w) {
|
|
19378
|
+
const l2 = (w.x - v.x) ** 2 + (w.y - v.y) ** 2;
|
|
19379
|
+
if (l2 === 0) return distance2(p, v);
|
|
19380
|
+
let t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2;
|
|
19381
|
+
t = Math.max(0, Math.min(1, t));
|
|
19382
|
+
const projection = {
|
|
19383
|
+
x: v.x + t * (w.x - v.x),
|
|
19384
|
+
y: v.y + t * (w.y - v.y)
|
|
19385
|
+
};
|
|
19386
|
+
return distance2(p, projection);
|
|
19387
|
+
}
|
|
19388
|
+
function distance2(p1, p2) {
|
|
19389
|
+
const dx = p1.x - p2.x;
|
|
19390
|
+
const dy = p1.y - p2.y;
|
|
19391
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
19392
|
+
}
|
|
19393
|
+
|
|
19394
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-GIGMPRPV.js
|
|
19395
|
+
var getUnitVectorFromDirection = (direction) => {
|
|
19396
|
+
switch (direction) {
|
|
19397
|
+
case "up":
|
|
19398
|
+
return { x: 0, y: 1 };
|
|
19399
|
+
case "down":
|
|
19400
|
+
return { x: 0, y: -1 };
|
|
19401
|
+
case "left":
|
|
19402
|
+
return { x: -1, y: 0 };
|
|
19403
|
+
case "right":
|
|
19404
|
+
return { x: 1, y: 0 };
|
|
19405
|
+
}
|
|
19406
|
+
};
|
|
19407
|
+
|
|
19408
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-5J3PCV4D.js
|
|
19409
|
+
function midpoint(p1, p2) {
|
|
19410
|
+
return {
|
|
19411
|
+
x: (p1.x + p2.x) / 2,
|
|
19412
|
+
y: (p1.y + p2.y) / 2
|
|
19413
|
+
};
|
|
19414
|
+
}
|
|
19415
|
+
|
|
19416
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-3WCUPG5S.js
|
|
19417
|
+
var getBoundsCenter = (bounds) => ({
|
|
19418
|
+
x: (bounds.minX + bounds.maxX) / 2,
|
|
19419
|
+
y: (bounds.minY + bounds.maxY) / 2
|
|
19420
|
+
});
|
|
19421
|
+
|
|
19422
|
+
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
19423
|
+
var getBoundsFromPoints2 = (points) => {
|
|
19424
|
+
if (points.length === 0) {
|
|
19425
|
+
return null;
|
|
19426
|
+
}
|
|
19427
|
+
let minX = points[0].x;
|
|
19428
|
+
let minY = points[0].y;
|
|
19429
|
+
let maxX = points[0].x;
|
|
19430
|
+
let maxY = points[0].y;
|
|
19431
|
+
for (let i = 1; i < points.length; i++) {
|
|
19432
|
+
const point4 = points[i];
|
|
19433
|
+
if (point4.x < minX) minX = point4.x;
|
|
19434
|
+
if (point4.y < minY) minY = point4.y;
|
|
19435
|
+
if (point4.x > maxX) maxX = point4.x;
|
|
19436
|
+
if (point4.y > maxY) maxY = point4.y;
|
|
19437
|
+
}
|
|
19438
|
+
return { minX, minY, maxX, maxY };
|
|
19439
|
+
};
|
|
19440
|
+
|
|
19441
|
+
// lib/utils/flatten-bezier-curve.ts
|
|
19442
|
+
var MAX_SUBDIVISION_DEPTH = 20;
|
|
19443
|
+
var BEZIER_SUBDIVISION_LIMIT_MESSAGE = "Bezier curve exceeds the subdivision limit";
|
|
19444
|
+
var INVALID_BEZIER_GEOMETRY_MESSAGE = "Invalid Bezier curve geometry";
|
|
19445
|
+
var flattenBezierCurve = ({
|
|
19446
|
+
controlPoints,
|
|
19447
|
+
tolerance,
|
|
19448
|
+
maxPoints = MAX_EASYEDA_PATH_POINTS
|
|
19449
|
+
}) => {
|
|
19450
|
+
if (![3, 4].includes(controlPoints.length) || !Number.isFinite(tolerance) || tolerance <= 0 || controlPoints.some(
|
|
19451
|
+
(point4) => !Number.isFinite(point4.x) || !Number.isFinite(point4.y)
|
|
19452
|
+
)) {
|
|
19453
|
+
throw new Error(INVALID_BEZIER_GEOMETRY_MESSAGE);
|
|
19454
|
+
}
|
|
19455
|
+
if (!Number.isInteger(maxPoints) || maxPoints < 2) {
|
|
19456
|
+
throw new Error(EASYEDA_PATH_LIMIT_MESSAGE);
|
|
19457
|
+
}
|
|
19458
|
+
const pointLimit = Math.min(maxPoints, MAX_EASYEDA_PATH_POINTS);
|
|
19459
|
+
const route = [controlPoints[0]];
|
|
19460
|
+
const pending = [{ points: controlPoints, depth: 0 }];
|
|
19461
|
+
while (pending.length) {
|
|
19462
|
+
const { points, depth } = pending.pop();
|
|
19463
|
+
const start = points[0];
|
|
19464
|
+
const end = points.at(-1);
|
|
19465
|
+
if (points.slice(1, -1).every(
|
|
19466
|
+
(point4) => pointToSegmentDistance(point4, start, end) <= tolerance
|
|
19467
|
+
)) {
|
|
19468
|
+
route.push(end);
|
|
19469
|
+
continue;
|
|
19470
|
+
}
|
|
19471
|
+
if (depth >= MAX_SUBDIVISION_DEPTH) {
|
|
19472
|
+
throw new Error(BEZIER_SUBDIVISION_LIMIT_MESSAGE);
|
|
19473
|
+
}
|
|
19474
|
+
if (route.length + pending.length + 2 > pointLimit) {
|
|
19475
|
+
throw new Error(EASYEDA_PATH_LIMIT_MESSAGE);
|
|
19476
|
+
}
|
|
19477
|
+
let level = points;
|
|
19478
|
+
const left = [start];
|
|
19479
|
+
const right = [end];
|
|
19480
|
+
while (level.length > 1) {
|
|
19481
|
+
level = level.slice(1).map((point4, index) => midpoint(level[index], point4));
|
|
19482
|
+
left.push(level[0]);
|
|
19483
|
+
right.unshift(level.at(-1));
|
|
19484
|
+
}
|
|
19485
|
+
pending.push(
|
|
19486
|
+
{ points: right, depth: depth + 1 },
|
|
19487
|
+
{ points: left, depth: depth + 1 }
|
|
19488
|
+
);
|
|
19489
|
+
}
|
|
19490
|
+
return route;
|
|
19491
|
+
};
|
|
19492
|
+
|
|
19493
|
+
// lib/utils/expand-easyeda-bezier-command.ts
|
|
19494
|
+
var BEZIER_TOLERANCE = 1e-3 / mil10ToMm(1);
|
|
19495
|
+
var expandEasyEdaBezierCommand = (pathCommand, ctx) => {
|
|
19496
|
+
const command = pathCommand.command.toUpperCase();
|
|
19497
|
+
const relative = command !== pathCommand.command;
|
|
19498
|
+
const groupSize = command === "C" ? 6 : command === "T" ? 2 : 4;
|
|
19499
|
+
const route = [];
|
|
19500
|
+
let { currentPoint, cubicControl, quadraticControl } = ctx;
|
|
19501
|
+
for (let offset = 0; offset < pathCommand.arguments.length; offset += groupSize) {
|
|
19502
|
+
if (route.length >= ctx.remainingPoints) {
|
|
19503
|
+
throw new Error(EASYEDA_PATH_LIMIT_MESSAGE);
|
|
19504
|
+
}
|
|
19505
|
+
const coordinates = [];
|
|
19506
|
+
for (let index = offset; index < offset + groupSize; index += 2) {
|
|
19507
|
+
coordinates.push({
|
|
19508
|
+
x: pathCommand.arguments[index] + (relative ? currentPoint.x : 0),
|
|
19509
|
+
y: pathCommand.arguments[index + 1] + (relative ? currentPoint.y : 0)
|
|
19510
|
+
});
|
|
19511
|
+
}
|
|
19512
|
+
const end = coordinates.at(-1);
|
|
19513
|
+
let controlPoints;
|
|
19514
|
+
if (command === "C" || command === "S") {
|
|
19515
|
+
const firstControl = command === "C" ? coordinates[0] : cubicControl ? {
|
|
19516
|
+
x: 2 * currentPoint.x - cubicControl.x,
|
|
19517
|
+
y: 2 * currentPoint.y - cubicControl.y
|
|
19518
|
+
} : currentPoint;
|
|
19519
|
+
cubicControl = coordinates.at(-2);
|
|
19520
|
+
quadraticControl = void 0;
|
|
19521
|
+
controlPoints = [currentPoint, firstControl, cubicControl, end];
|
|
19522
|
+
} else {
|
|
19523
|
+
quadraticControl = command === "Q" ? coordinates[0] : quadraticControl ? {
|
|
19524
|
+
x: 2 * currentPoint.x - quadraticControl.x,
|
|
19525
|
+
y: 2 * currentPoint.y - quadraticControl.y
|
|
19526
|
+
} : currentPoint;
|
|
19527
|
+
cubicControl = void 0;
|
|
19528
|
+
controlPoints = [currentPoint, quadraticControl, end];
|
|
19529
|
+
}
|
|
19530
|
+
const points = flattenBezierCurve({
|
|
19531
|
+
controlPoints,
|
|
19532
|
+
tolerance: BEZIER_TOLERANCE,
|
|
19533
|
+
maxPoints: ctx.remainingPoints - route.length + 1
|
|
19534
|
+
});
|
|
19535
|
+
for (let index = 1; index < points.length; index++) {
|
|
19536
|
+
route.push(points[index]);
|
|
19537
|
+
}
|
|
19538
|
+
currentPoint = end;
|
|
19539
|
+
}
|
|
19540
|
+
return { route, currentPoint, cubicControl, quadraticControl };
|
|
19541
|
+
};
|
|
19542
|
+
|
|
19329
19543
|
// lib/utils/expand-easyeda-path-data.ts
|
|
19330
19544
|
var expandEasyEdaPathData = (pathData) => {
|
|
19331
19545
|
const commands = parseEasyEdaPathCommands(pathData);
|
|
19332
19546
|
if (!commands) throw new Error("Invalid EasyEDA SOLIDREGION path");
|
|
19333
19547
|
for (const { command } of commands) {
|
|
19334
|
-
if (!/^[
|
|
19548
|
+
if (!/^[MLHVAZCSQT]$/i.test(command)) {
|
|
19335
19549
|
throw new Error(
|
|
19336
19550
|
`Unsupported EasyEDA SOLIDREGION path command: ${command}`
|
|
19337
19551
|
);
|
|
@@ -19344,14 +19558,18 @@ var expandEasyEdaPathData = (pathData) => {
|
|
|
19344
19558
|
let currentPoint;
|
|
19345
19559
|
let subpathStart;
|
|
19346
19560
|
let afterClose = false;
|
|
19561
|
+
let cubicControl;
|
|
19562
|
+
let quadraticControl;
|
|
19347
19563
|
for (const pathCommand of commands) {
|
|
19348
19564
|
const command = pathCommand.command.toUpperCase();
|
|
19349
19565
|
const relative = pathCommand.command !== command;
|
|
19350
19566
|
const commandArguments = pathCommand.arguments;
|
|
19567
|
+
if (command !== "C" && command !== "S") cubicControl = void 0;
|
|
19568
|
+
if (command !== "Q" && command !== "T") quadraticControl = void 0;
|
|
19351
19569
|
if (afterClose && command !== "Z" && currentPoint) {
|
|
19352
19570
|
const lastPoint = rawRoute.at(-1);
|
|
19353
19571
|
if (lastPoint?.x !== currentPoint.x || lastPoint?.y !== currentPoint.y) {
|
|
19354
|
-
rawRoute
|
|
19572
|
+
appendEasyEdaPathPoint(rawRoute, currentPoint);
|
|
19355
19573
|
}
|
|
19356
19574
|
}
|
|
19357
19575
|
afterClose = command === "Z";
|
|
@@ -19361,7 +19579,7 @@ var expandEasyEdaPathData = (pathData) => {
|
|
|
19361
19579
|
x: commandArguments[offset] + (relative ? currentPoint?.x ?? 0 : 0),
|
|
19362
19580
|
y: commandArguments[offset + 1] + (relative ? currentPoint?.y ?? 0 : 0)
|
|
19363
19581
|
};
|
|
19364
|
-
rawRoute
|
|
19582
|
+
appendEasyEdaPathPoint(rawRoute, currentPoint);
|
|
19365
19583
|
if (command === "M" && offset === 0) subpathStart = currentPoint;
|
|
19366
19584
|
}
|
|
19367
19585
|
} else if ((command === "H" || command === "V") && currentPoint) {
|
|
@@ -19370,32 +19588,35 @@ var expandEasyEdaPathData = (pathData) => {
|
|
|
19370
19588
|
x: command === "H" ? coordinate + (relative ? currentPoint.x : 0) : currentPoint.x,
|
|
19371
19589
|
y: command === "V" ? coordinate + (relative ? currentPoint.y : 0) : currentPoint.y
|
|
19372
19590
|
};
|
|
19373
|
-
rawRoute
|
|
19591
|
+
appendEasyEdaPathPoint(rawRoute, currentPoint);
|
|
19374
19592
|
}
|
|
19593
|
+
} else if (/^[CSQT]$/.test(command) && currentPoint) {
|
|
19594
|
+
const curve = expandEasyEdaBezierCommand(pathCommand, {
|
|
19595
|
+
currentPoint,
|
|
19596
|
+
cubicControl,
|
|
19597
|
+
quadraticControl,
|
|
19598
|
+
remainingPoints: MAX_EASYEDA_PATH_POINTS - rawRoute.length
|
|
19599
|
+
});
|
|
19600
|
+
for (const point4 of curve.route) appendEasyEdaPathPoint(rawRoute, point4);
|
|
19601
|
+
currentPoint = curve.currentPoint;
|
|
19602
|
+
cubicControl = curve.cubicControl;
|
|
19603
|
+
quadraticControl = curve.quadraticControl;
|
|
19375
19604
|
} else if (command === "A" && currentPoint && commandArguments.length >= 7) {
|
|
19376
19605
|
for (let offset = 0; offset + 6 < commandArguments.length; offset += 7) {
|
|
19377
19606
|
const [radiusX, , , largeArcFlag, sweepFlag, endpointX, endpointY] = commandArguments.slice(offset, offset + 7);
|
|
19378
19607
|
const endX = endpointX + (relative ? currentPoint.x : 0);
|
|
19379
19608
|
const endY = endpointY + (relative ? currentPoint.y : 0);
|
|
19380
|
-
const
|
|
19381
|
-
currentPoint
|
|
19382
|
-
|
|
19383
|
-
|
|
19384
|
-
|
|
19385
|
-
|
|
19386
|
-
|
|
19387
|
-
|
|
19388
|
-
)
|
|
19389
|
-
|
|
19390
|
-
|
|
19391
|
-
{ length: maxArcSegments + 1 },
|
|
19392
|
-
(_, pointIndex) => generatedArcRoute.at(
|
|
19393
|
-
Math.round(
|
|
19394
|
-
pointIndex * (generatedArcRoute.length - 1) / maxArcSegments
|
|
19395
|
-
)
|
|
19396
|
-
)
|
|
19397
|
-
).filter((point4) => !!point4);
|
|
19398
|
-
rawRoute.push(...arcRoute.slice(1));
|
|
19609
|
+
const arcRoute = generateArcFromSweep({
|
|
19610
|
+
start: currentPoint,
|
|
19611
|
+
end: { x: endX, y: endY },
|
|
19612
|
+
radius: radiusX,
|
|
19613
|
+
largeArcFlag: largeArcFlag === 1,
|
|
19614
|
+
sweepFlag: sweepFlag === 1,
|
|
19615
|
+
maxSegments: 16
|
|
19616
|
+
});
|
|
19617
|
+
for (let index = 1; index < arcRoute.length; index++) {
|
|
19618
|
+
appendEasyEdaPathPoint(rawRoute, arcRoute[index]);
|
|
19619
|
+
}
|
|
19399
19620
|
currentPoint = { x: endX, y: endY };
|
|
19400
19621
|
}
|
|
19401
19622
|
} else if (command === "Z" && subpathStart) {
|
|
@@ -19405,57 +19626,6 @@ var expandEasyEdaPathData = (pathData) => {
|
|
|
19405
19626
|
return rawRoute;
|
|
19406
19627
|
};
|
|
19407
19628
|
|
|
19408
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
|
|
19409
|
-
function orientation(p, q, r) {
|
|
19410
|
-
const val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
19411
|
-
if (val === 0) return 0;
|
|
19412
|
-
return val > 0 ? 1 : 2;
|
|
19413
|
-
}
|
|
19414
|
-
function distance2(p1, p2) {
|
|
19415
|
-
const dx = p1.x - p2.x;
|
|
19416
|
-
const dy = p1.y - p2.y;
|
|
19417
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
19418
|
-
}
|
|
19419
|
-
|
|
19420
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-GIGMPRPV.js
|
|
19421
|
-
var getUnitVectorFromDirection = (direction) => {
|
|
19422
|
-
switch (direction) {
|
|
19423
|
-
case "up":
|
|
19424
|
-
return { x: 0, y: 1 };
|
|
19425
|
-
case "down":
|
|
19426
|
-
return { x: 0, y: -1 };
|
|
19427
|
-
case "left":
|
|
19428
|
-
return { x: -1, y: 0 };
|
|
19429
|
-
case "right":
|
|
19430
|
-
return { x: 1, y: 0 };
|
|
19431
|
-
}
|
|
19432
|
-
};
|
|
19433
|
-
|
|
19434
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-3WCUPG5S.js
|
|
19435
|
-
var getBoundsCenter = (bounds) => ({
|
|
19436
|
-
x: (bounds.minX + bounds.maxX) / 2,
|
|
19437
|
-
y: (bounds.minY + bounds.maxY) / 2
|
|
19438
|
-
});
|
|
19439
|
-
|
|
19440
|
-
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
19441
|
-
var getBoundsFromPoints2 = (points) => {
|
|
19442
|
-
if (points.length === 0) {
|
|
19443
|
-
return null;
|
|
19444
|
-
}
|
|
19445
|
-
let minX = points[0].x;
|
|
19446
|
-
let minY = points[0].y;
|
|
19447
|
-
let maxX = points[0].x;
|
|
19448
|
-
let maxY = points[0].y;
|
|
19449
|
-
for (let i = 1; i < points.length; i++) {
|
|
19450
|
-
const point4 = points[i];
|
|
19451
|
-
if (point4.x < minX) minX = point4.x;
|
|
19452
|
-
if (point4.y < minY) minY = point4.y;
|
|
19453
|
-
if (point4.x > maxX) maxX = point4.x;
|
|
19454
|
-
if (point4.y > maxY) maxY = point4.y;
|
|
19455
|
-
}
|
|
19456
|
-
return { minX, minY, maxX, maxY };
|
|
19457
|
-
};
|
|
19458
|
-
|
|
19459
19629
|
// lib/utils/get-board-outline-polygons.ts
|
|
19460
19630
|
var same = (a, b) => distance2(a, b) < 1e-4;
|
|
19461
19631
|
var getBoardOutlinePolygons = (tracks) => {
|
|
@@ -19773,20 +19943,20 @@ var distanceFromRouteMidpoint = (route, point4) => {
|
|
|
19773
19943
|
return Math.hypot(midpoint2.x - point4.x, midpoint2.y - point4.y);
|
|
19774
19944
|
};
|
|
19775
19945
|
var getSilkscreenArcPath = (arc2, footprintCenter, silkscreenTracks) => {
|
|
19776
|
-
const
|
|
19777
|
-
arc2.start
|
|
19778
|
-
arc2.
|
|
19779
|
-
arc2.
|
|
19780
|
-
arc2.
|
|
19781
|
-
|
|
19782
|
-
arc2.largeArc,
|
|
19783
|
-
sweepFlag2
|
|
19784
|
-
);
|
|
19946
|
+
const arcOptions = {
|
|
19947
|
+
start: arc2.start,
|
|
19948
|
+
end: arc2.end,
|
|
19949
|
+
radius: arc2.radiusX,
|
|
19950
|
+
largeArcFlag: arc2.largeArc
|
|
19951
|
+
};
|
|
19785
19952
|
const sweepFlag = arc2.sweepDirection === "CW";
|
|
19786
|
-
const arcPath =
|
|
19953
|
+
const arcPath = generateArcFromSweep({ ...arcOptions, sweepFlag });
|
|
19787
19954
|
const semicircleRole = classifySemicircle(arc2, silkscreenTracks);
|
|
19788
19955
|
if (!semicircleRole) return arcPath;
|
|
19789
|
-
const oppositeArcPath =
|
|
19956
|
+
const oppositeArcPath = generateArcFromSweep({
|
|
19957
|
+
...arcOptions,
|
|
19958
|
+
sweepFlag: !sweepFlag
|
|
19959
|
+
});
|
|
19790
19960
|
const arcDistance = distanceFromRouteMidpoint(arcPath, footprintCenter);
|
|
19791
19961
|
const oppositeDistance = distanceFromRouteMidpoint(
|
|
19792
19962
|
oppositeArcPath,
|
|
@@ -20124,7 +20294,31 @@ var handleFabricationNotePath = (track, index) => pcb_fabrication_note_path.pars
|
|
|
20124
20294
|
stroke_width: mil10ToMm(track.width)
|
|
20125
20295
|
});
|
|
20126
20296
|
var handleFabricationNoteSolidRegion = (solidRegion, index) => {
|
|
20127
|
-
const
|
|
20297
|
+
const commands = parseEasyEdaPathCommands(solidRegion.pathData);
|
|
20298
|
+
const pathWarning = !commands ? "Invalid EasyEDA SOLIDREGION path" : commands.slice(1).some(({ command }) => command.toUpperCase() === "M") ? "Multiple EasyEDA SOLIDREGION subpaths are not supported" : void 0;
|
|
20299
|
+
if (pathWarning) {
|
|
20300
|
+
console.warn(
|
|
20301
|
+
`Skipping EasyEDA fabrication note ${solidRegion.id ?? index + 1}: ${pathWarning}`
|
|
20302
|
+
);
|
|
20303
|
+
return null;
|
|
20304
|
+
}
|
|
20305
|
+
let rawRoute;
|
|
20306
|
+
try {
|
|
20307
|
+
rawRoute = expandEasyEdaPathData(solidRegion.pathData);
|
|
20308
|
+
} catch (error) {
|
|
20309
|
+
if (!(error instanceof Error) || ![
|
|
20310
|
+
BEZIER_SUBDIVISION_LIMIT_MESSAGE,
|
|
20311
|
+
EASYEDA_PATH_LIMIT_MESSAGE,
|
|
20312
|
+
INVALID_BEZIER_GEOMETRY_MESSAGE,
|
|
20313
|
+
INVALID_EASYEDA_PATH_GEOMETRY_MESSAGE
|
|
20314
|
+
].includes(error.message)) {
|
|
20315
|
+
throw error;
|
|
20316
|
+
}
|
|
20317
|
+
console.warn(
|
|
20318
|
+
`Skipping EasyEDA fabrication note ${solidRegion.id ?? index + 1}: ${error.message}`
|
|
20319
|
+
);
|
|
20320
|
+
return null;
|
|
20321
|
+
}
|
|
20128
20322
|
const route = rawRoute.map((point4) => ({
|
|
20129
20323
|
x: mil10ToMm(point4.x),
|
|
20130
20324
|
y: mil10ToMm(point4.y)
|