easyeda 0.0.369 → 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/browser/index.d.ts +13 -0
- package/dist/browser/index.js +107 -38
- package/dist/browser/index.js.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js +107 -38
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +108 -39
- 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.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
|
);
|
|
@@ -17330,6 +17366,7 @@ var TextShapeOutputSchema = import_zod217.z.object({
|
|
|
17330
17366
|
fontDecoration: optionalEasyEdaTextField(import_zod217.z.string().optional().default("")),
|
|
17331
17367
|
content: import_zod217.z.string(),
|
|
17332
17368
|
textType: import_zod217.z.string(),
|
|
17369
|
+
isReferenceDesignator: import_zod217.z.boolean().optional(),
|
|
17333
17370
|
visibility: import_zod217.z.enum(["0", "1"]),
|
|
17334
17371
|
mirror: import_zod217.z.string(),
|
|
17335
17372
|
id: import_zod217.z.string()
|
|
@@ -17337,7 +17374,7 @@ var TextShapeOutputSchema = import_zod217.z.object({
|
|
|
17337
17374
|
var parseText = (str) => {
|
|
17338
17375
|
const [
|
|
17339
17376
|
,
|
|
17340
|
-
|
|
17377
|
+
textMark,
|
|
17341
17378
|
x,
|
|
17342
17379
|
y,
|
|
17343
17380
|
rotation2,
|
|
@@ -17355,8 +17392,11 @@ var parseText = (str) => {
|
|
|
17355
17392
|
] = str.split("~");
|
|
17356
17393
|
return {
|
|
17357
17394
|
type: "TEXT",
|
|
17358
|
-
//
|
|
17359
|
-
|
|
17395
|
+
// EasyEDA's second text field is a mark: L=label, N=name, P=reference prefix.
|
|
17396
|
+
// Text anchoring is a separate field (start/middle/end).
|
|
17397
|
+
// https://docs.easyeda.com/en/DocumentFormat/2-EasyEDA-Schematic-File-Format/#annotations
|
|
17398
|
+
// Preserve the existing normalized alignment representation for consumers.
|
|
17399
|
+
alignment: textMark === "P" ? "L" : textMark,
|
|
17360
17400
|
x: Number(x),
|
|
17361
17401
|
y: Number(y),
|
|
17362
17402
|
rotation: Number(rotation2),
|
|
@@ -17368,6 +17408,7 @@ var parseText = (str) => {
|
|
|
17368
17408
|
fontDecoration,
|
|
17369
17409
|
content,
|
|
17370
17410
|
textType,
|
|
17411
|
+
...textMark === "P" ? { isReferenceDesignator: true } : {},
|
|
17371
17412
|
visibility,
|
|
17372
17413
|
mirror,
|
|
17373
17414
|
id
|
|
@@ -17688,6 +17729,27 @@ var normalizeSymbolName = (name) => {
|
|
|
17688
17729
|
return trimmedName.replace(/(?<=[A-Za-z0-9])-(?=[A-Za-z0-9])/g, "_");
|
|
17689
17730
|
};
|
|
17690
17731
|
|
|
17732
|
+
// lib/websafe/convert-to-typescript-component/generate-symbol-reference-text.ts
|
|
17733
|
+
var REFERENCE_TEXT_MARGIN_SCHEMATIC_UNITS = 0.2;
|
|
17734
|
+
var generateSymbolReferenceText = ({
|
|
17735
|
+
shapes,
|
|
17736
|
+
bounds,
|
|
17737
|
+
transformPoint
|
|
17738
|
+
}) => {
|
|
17739
|
+
const hasVisibleReferenceText = shapes.some(
|
|
17740
|
+
(shape) => shape.type === "TEXT" && shape.visibility === "1" && (shape.isReferenceDesignator || /\{(?:NAME|REF|REFERENCE)\}/.test(shape.content))
|
|
17741
|
+
);
|
|
17742
|
+
if (hasVisibleReferenceText) return void 0;
|
|
17743
|
+
const position2 = transformPoint({
|
|
17744
|
+
x: bounds.x + bounds.width / 2,
|
|
17745
|
+
y: bounds.y
|
|
17746
|
+
});
|
|
17747
|
+
const schY = Number(
|
|
17748
|
+
(position2.y + REFERENCE_TEXT_MARGIN_SCHEMATIC_UNITS).toFixed(6)
|
|
17749
|
+
);
|
|
17750
|
+
return `<schematictext schX={${position2.x}} schY={${schY}} text="{NAME}" fontSize={0.2} anchor="bottom_center" />`;
|
|
17751
|
+
};
|
|
17752
|
+
|
|
17691
17753
|
// lib/websafe/convert-to-typescript-component/generate-symbol-tsx.ts
|
|
17692
17754
|
var round = (value) => Number(value.toFixed(6));
|
|
17693
17755
|
var EASYEDA_SCHEMATIC_UNIT_TO_TSCIRCUIT_UNIT = 0.02;
|
|
@@ -17976,7 +18038,8 @@ var generateShapeTsx = ({
|
|
|
17976
18038
|
if (shape.type === "TEXT") {
|
|
17977
18039
|
if (shape.visibility !== "1") return void 0;
|
|
17978
18040
|
const position2 = transformPoint({ x: shape.x, y: shape.y });
|
|
17979
|
-
|
|
18041
|
+
const text = shape.isReferenceDesignator ? "{NAME}" : shape.content;
|
|
18042
|
+
return `<schematictext schX={${position2.x}} schY={${position2.y}} text=${JSON.stringify(text)} fontSize={${getTextFontSize(shape.fontSize)}} anchor=${JSON.stringify(getTextAnchor(shape.alignment))} color=${JSON.stringify(shape.fontColor)} schRotation={${round(-shape.rotation)}} />`;
|
|
17980
18043
|
}
|
|
17981
18044
|
if (shape.type === "PIN" && portMetadata) {
|
|
17982
18045
|
if (shape.visibility !== "show") return void 0;
|
|
@@ -18027,6 +18090,12 @@ var generateSymbolTsx = (easyEdaJson, circuitJson, {
|
|
|
18027
18090
|
})
|
|
18028
18091
|
).filter((tsx) => Boolean(tsx));
|
|
18029
18092
|
if (shapeTsx.length === 0) return void 0;
|
|
18093
|
+
const referenceTextTsx = generateSymbolReferenceText({
|
|
18094
|
+
shapes,
|
|
18095
|
+
bounds,
|
|
18096
|
+
transformPoint
|
|
18097
|
+
});
|
|
18098
|
+
if (referenceTextTsx) shapeTsx.push(referenceTextTsx);
|
|
18030
18099
|
return `<symbol>
|
|
18031
18100
|
${shapeTsx.map((tsx) => ` ${tsx}`).join("\n")}
|
|
18032
18101
|
</symbol>`;
|