easyeda 0.0.370 → 0.0.371

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/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.369",
1081
+ version: "0.0.370",
1082
1082
  files: [
1083
1083
  "dist"
1084
1084
  ],
@@ -15404,6 +15404,43 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
15404
15404
  // lib/utils/easyeda-unit-to-mm.ts
15405
15405
  var mil10ToMm = (value) => value * 10 * 0.0254;
15406
15406
 
15407
+ // lib/utils/expand-easyeda-path-data.ts
15408
+ var expandEasyEdaPathData = (pathData) => {
15409
+ const rawRoute = [];
15410
+ let currentPoint;
15411
+ for (const commandMatch of pathData.matchAll(/([MLAZ])([^MLAZ]*)/gi)) {
15412
+ const command = commandMatch[1]?.toUpperCase();
15413
+ const values = commandMatch[2]?.match(/[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g)?.map(Number) ?? [];
15414
+ if ((command === "M" || command === "L") && values.length >= 2) {
15415
+ currentPoint = { x: values[0], y: values[1] };
15416
+ rawRoute.push(currentPoint);
15417
+ } else if (command === "A" && currentPoint && values.length >= 7) {
15418
+ const [radiusX, , , largeArcFlag, sweepFlag, endX, endY] = values;
15419
+ const generatedArcRoute = generateArcFromSweep(
15420
+ currentPoint.x,
15421
+ currentPoint.y,
15422
+ endX,
15423
+ endY,
15424
+ radiusX,
15425
+ largeArcFlag === 1,
15426
+ sweepFlag === 1
15427
+ );
15428
+ const maxArcSegments = 16;
15429
+ const arcRoute = generatedArcRoute.length <= maxArcSegments + 1 ? generatedArcRoute : Array.from(
15430
+ { length: maxArcSegments + 1 },
15431
+ (_, pointIndex) => generatedArcRoute.at(
15432
+ Math.round(
15433
+ pointIndex * (generatedArcRoute.length - 1) / maxArcSegments
15434
+ )
15435
+ )
15436
+ ).filter((point4) => !!point4);
15437
+ rawRoute.push(...arcRoute.slice(1));
15438
+ currentPoint = { x: endX, y: endY };
15439
+ }
15440
+ }
15441
+ return rawRoute;
15442
+ };
15443
+
15407
15444
  // node_modules/@tscircuit/math-utils/dist/chunk-EFLPMB4J.js
15408
15445
  function orientation(p, q, r) {
15409
15446
  const val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
@@ -15519,6 +15556,22 @@ var getBoardOutlinePolygons = (tracks) => {
15519
15556
  return polygons;
15520
15557
  };
15521
15558
 
15559
+ // lib/utils/get-easyeda-npth-slot-geometry.ts
15560
+ var getEasyEdaNpthSlotGeometry = (solidRegion) => {
15561
+ const rawRoute = expandEasyEdaPathData(solidRegion.pathData);
15562
+ if (rawRoute.length < 2) return null;
15563
+ const points = rawRoute.map((point4) => ({
15564
+ x: mil2mm(point4.x) * 10,
15565
+ y: mil2mm(point4.y) * 10
15566
+ }));
15567
+ const firstPoint = points[0];
15568
+ const lastPoint = points.at(-1);
15569
+ if (firstPoint.x !== lastPoint.x || firstPoint.y !== lastPoint.y) {
15570
+ points.push({ ...firstPoint });
15571
+ }
15572
+ return { points };
15573
+ };
15574
+
15522
15575
  // lib/utils/normalize-pin-labels.ts
15523
15576
  var normalizeActiveLowPinLabel = (label) => {
15524
15577
  const hasActiveLowMarker = label.startsWith("#") || label.endsWith("#");
@@ -16107,40 +16160,7 @@ var handleFabricationNotePath = (track, index) => pcb_fabrication_note_path.pars
16107
16160
  stroke_width: mil10ToMm(track.width)
16108
16161
  });
16109
16162
  var handleFabricationNoteSolidRegion = (solidRegion, index) => {
16110
- const rawRoute = [];
16111
- let currentPoint;
16112
- for (const commandMatch of solidRegion.pathData.matchAll(
16113
- /([MLAZ])([^MLAZ]*)/gi
16114
- )) {
16115
- const command = commandMatch[1]?.toUpperCase();
16116
- const values = commandMatch[2]?.match(/[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g)?.map(Number) ?? [];
16117
- if ((command === "M" || command === "L") && values.length >= 2) {
16118
- currentPoint = { x: values[0], y: values[1] };
16119
- rawRoute.push(currentPoint);
16120
- } else if (command === "A" && currentPoint && values.length >= 7) {
16121
- const [radiusX, , , largeArcFlag, sweepFlag, endX, endY] = values;
16122
- const generatedArcRoute = generateArcFromSweep(
16123
- currentPoint.x,
16124
- currentPoint.y,
16125
- endX,
16126
- endY,
16127
- radiusX,
16128
- largeArcFlag === 1,
16129
- sweepFlag === 1
16130
- );
16131
- const maxArcSegments = 16;
16132
- const arcRoute = generatedArcRoute.length <= maxArcSegments + 1 ? generatedArcRoute : Array.from(
16133
- { length: maxArcSegments + 1 },
16134
- (_, pointIndex) => generatedArcRoute.at(
16135
- Math.round(
16136
- pointIndex * (generatedArcRoute.length - 1) / maxArcSegments
16137
- )
16138
- )
16139
- ).filter((point4) => !!point4);
16140
- rawRoute.push(...arcRoute.slice(1));
16141
- currentPoint = { x: endX, y: endY };
16142
- }
16143
- }
16163
+ const rawRoute = expandEasyEdaPathData(solidRegion.pathData);
16144
16164
  const route = rawRoute.map((point4) => ({
16145
16165
  x: mil10ToMm(point4.x),
16146
16166
  y: mil10ToMm(point4.y)
@@ -16271,9 +16291,11 @@ var handleCutout = (solidRegion, index) => {
16271
16291
  });
16272
16292
  };
16273
16293
  var LEAD_SHAPE_LAYER = 100;
16294
+ var NPTH_FILL_STYLE = "npth";
16274
16295
  var isPcbSolidRegionCutout = (shape) => {
16275
16296
  return shape.fillStyle === "cutout" && shape.layermask !== LEAD_SHAPE_LAYER;
16276
16297
  };
16298
+ var isPcbSolidRegionNpth = (shape) => shape.fillStyle === NPTH_FILL_STYLE && shape.layermask !== LEAD_SHAPE_LAYER;
16277
16299
  var getCadPositionZMmFromMetadata = (easyEdaJson) => {
16278
16300
  const svgNode = easyEdaJson.packageDetail.dataStr.shape.find(
16279
16301
  (shape) => shape.type === "SVGNODE" && shape.svgData.attrs?.uuid
@@ -16469,6 +16491,20 @@ var convertEasyEdaJsonToCircuitJsonWithPinAttributes = (easyEdaJson, {
16469
16491
  ).forEach((sr, index) => {
16470
16492
  circuitElements.push(handleCutout(sr, index));
16471
16493
  });
16494
+ easyEdaJson.packageDetail.dataStr.shape.filter(
16495
+ (shape) => shape.type === "SOLIDREGION" && isPcbSolidRegionNpth(shape)
16496
+ ).forEach((sr, index) => {
16497
+ const geometry = getEasyEdaNpthSlotGeometry(sr);
16498
+ if (!geometry) return;
16499
+ circuitElements.push(
16500
+ pcb_cutout.parse({
16501
+ type: "pcb_cutout",
16502
+ pcb_cutout_id: `pcb_cutout_npth_${index + 1}`,
16503
+ shape: "polygon",
16504
+ points: geometry.points
16505
+ })
16506
+ );
16507
+ });
16472
16508
  const boardOutlineTracks = easyEdaJson.packageDetail.dataStr.shape.filter(
16473
16509
  (shape) => shape.type === "TRACK" && shape.layer === 10
16474
16510
  );