easyeda 0.0.327 → 0.0.329
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 +29 -11
- package/dist/browser/index.js +116 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/index.d.ts +29 -11
- package/dist/index.js +116 -2
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +117 -3
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -1026,7 +1026,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
|
|
|
1026
1026
|
var package_default = {
|
|
1027
1027
|
name: "easyeda",
|
|
1028
1028
|
type: "module",
|
|
1029
|
-
version: "0.0.
|
|
1029
|
+
version: "0.0.328",
|
|
1030
1030
|
files: [
|
|
1031
1031
|
"dist"
|
|
1032
1032
|
],
|
|
@@ -7272,7 +7272,7 @@ var normalizeSymbolName = (name) => {
|
|
|
7272
7272
|
const trimmedName = name.trim();
|
|
7273
7273
|
if (trimmedName === "+") return "_POS";
|
|
7274
7274
|
if (trimmedName === "-") return "_NEG";
|
|
7275
|
-
return trimmedName;
|
|
7275
|
+
return trimmedName.replace(/(?<=[A-Za-z0-9])-(?=[A-Za-z0-9])/g, "_");
|
|
7276
7276
|
};
|
|
7277
7277
|
|
|
7278
7278
|
// lib/websafe/convert-to-typescript-component/category-value-contains-diode.ts
|
|
@@ -7553,6 +7553,62 @@ var handleFabricationNotePath = (track, index) => pcb_fabrication_note_path.pars
|
|
|
7553
7553
|
})),
|
|
7554
7554
|
stroke_width: mil10ToMm(track.width)
|
|
7555
7555
|
});
|
|
7556
|
+
var handleFabricationNoteSolidRegion = (solidRegion, index) => {
|
|
7557
|
+
const rawRoute = [];
|
|
7558
|
+
let currentPoint;
|
|
7559
|
+
for (const commandMatch of solidRegion.pathData.matchAll(
|
|
7560
|
+
/([MLAZ])([^MLAZ]*)/gi
|
|
7561
|
+
)) {
|
|
7562
|
+
const command = commandMatch[1]?.toUpperCase();
|
|
7563
|
+
const values = commandMatch[2]?.match(/[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g)?.map(Number) ?? [];
|
|
7564
|
+
if ((command === "M" || command === "L") && values.length >= 2) {
|
|
7565
|
+
currentPoint = { x: values[0], y: values[1] };
|
|
7566
|
+
rawRoute.push(currentPoint);
|
|
7567
|
+
} else if (command === "A" && currentPoint && values.length >= 7) {
|
|
7568
|
+
const [radiusX, , , largeArcFlag, sweepFlag, endX, endY] = values;
|
|
7569
|
+
const generatedArcRoute = generateArcFromSweep(
|
|
7570
|
+
currentPoint.x,
|
|
7571
|
+
currentPoint.y,
|
|
7572
|
+
endX,
|
|
7573
|
+
endY,
|
|
7574
|
+
radiusX,
|
|
7575
|
+
largeArcFlag === 1,
|
|
7576
|
+
sweepFlag === 1
|
|
7577
|
+
);
|
|
7578
|
+
const maxArcSegments = 16;
|
|
7579
|
+
const arcRoute = generatedArcRoute.length <= maxArcSegments + 1 ? generatedArcRoute : Array.from(
|
|
7580
|
+
{ length: maxArcSegments + 1 },
|
|
7581
|
+
(_, pointIndex) => generatedArcRoute.at(
|
|
7582
|
+
Math.round(
|
|
7583
|
+
pointIndex * (generatedArcRoute.length - 1) / maxArcSegments
|
|
7584
|
+
)
|
|
7585
|
+
)
|
|
7586
|
+
).filter((point2) => !!point2);
|
|
7587
|
+
rawRoute.push(...arcRoute.slice(1));
|
|
7588
|
+
currentPoint = { x: endX, y: endY };
|
|
7589
|
+
}
|
|
7590
|
+
}
|
|
7591
|
+
const route = rawRoute.map((point2) => ({
|
|
7592
|
+
x: mil10ToMm(point2.x),
|
|
7593
|
+
y: mil10ToMm(point2.y)
|
|
7594
|
+
}));
|
|
7595
|
+
const firstPoint = route[0];
|
|
7596
|
+
const lastPoint = route.at(-1);
|
|
7597
|
+
if (firstPoint && lastPoint && (firstPoint.x !== lastPoint.x || firstPoint.y !== lastPoint.y)) {
|
|
7598
|
+
route.push({ ...firstPoint });
|
|
7599
|
+
}
|
|
7600
|
+
if (route.length < 2) return null;
|
|
7601
|
+
return pcb_fabrication_note_path.parse({
|
|
7602
|
+
type: "pcb_fabrication_note_path",
|
|
7603
|
+
pcb_fabrication_note_path_id: `pcb_fabrication_note_solid_region_${index + 1}`,
|
|
7604
|
+
pcb_component_id: "pcb_component_1",
|
|
7605
|
+
layer: "top",
|
|
7606
|
+
route,
|
|
7607
|
+
// EasyEDA solid regions have no stroke width. Use its standard 1-unit
|
|
7608
|
+
// document stroke so the closed region remains visible as a note path.
|
|
7609
|
+
stroke_width: mil10ToMm(1)
|
|
7610
|
+
});
|
|
7611
|
+
};
|
|
7556
7612
|
var getSideFromLayer = (layer) => {
|
|
7557
7613
|
if (layer === 4 || layer === 14) return "bottom";
|
|
7558
7614
|
return "top";
|
|
@@ -7923,6 +7979,9 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
7923
7979
|
} else if (isDocumentLayer(shape.layer)) {
|
|
7924
7980
|
circuitElements.push(handleFabricationNotePath(shape, index));
|
|
7925
7981
|
}
|
|
7982
|
+
} else if (shape.type === "SOLIDREGION" && isDocumentLayer(shape.layermask)) {
|
|
7983
|
+
const fabricationNote = handleFabricationNoteSolidRegion(shape, index);
|
|
7984
|
+
if (fabricationNote) circuitElements.push(fabricationNote);
|
|
7926
7985
|
} else if (shape.type === "CIRCLE") {
|
|
7927
7986
|
if (isSilkscreenLayer(shape.layer)) {
|
|
7928
7987
|
circuitElements.push(handleSilkscreenCircle(shape, index));
|
|
@@ -8236,6 +8295,7 @@ var CircleSchema = BaseShapeSchema.extend({
|
|
|
8236
8295
|
var SolidRegionSchema = BaseShapeSchema.extend({
|
|
8237
8296
|
type: import_zod193.z.literal("SOLIDREGION"),
|
|
8238
8297
|
layermask: import_zod193.z.number(),
|
|
8298
|
+
pathData: import_zod193.z.string(),
|
|
8239
8299
|
points: import_zod193.z.array(PointSchema),
|
|
8240
8300
|
fillStyle: import_zod193.z.string().default("none")
|
|
8241
8301
|
});
|
|
@@ -8430,6 +8490,7 @@ var ShapeItemSchema = import_zod193.z.object({
|
|
|
8430
8490
|
return SolidRegionSchema.parse({
|
|
8431
8491
|
type: "SOLIDREGION",
|
|
8432
8492
|
layermask: Number(layermask),
|
|
8493
|
+
pathData,
|
|
8433
8494
|
points,
|
|
8434
8495
|
fillStyle: fillStyle || void 0,
|
|
8435
8496
|
id
|
|
@@ -9083,6 +9144,9 @@ var mapPortHints = (portHints, portHintsMap) => {
|
|
|
9083
9144
|
if (!portHintsMap || !portHints) return portHints;
|
|
9084
9145
|
return [...new Set(portHints.flatMap((hint) => portHintsMap[hint] ?? [hint]))];
|
|
9085
9146
|
};
|
|
9147
|
+
var getLayerAttr = (layer) => layer && layer !== "top" ? ` layer="${layer}"` : "";
|
|
9148
|
+
var getRotationAttr = (rotation2) => rotation2 ? ` pcbRotation="${rotation2}deg"` : "";
|
|
9149
|
+
var getStringAttr = (name, value) => value === void 0 ? "" : ` ${name}=${JSON.stringify(value)}`;
|
|
9086
9150
|
var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
9087
9151
|
const holes = su(circuitJson).pcb_hole.list();
|
|
9088
9152
|
const platedHoles = su(circuitJson).pcb_plated_hole.list();
|
|
@@ -9093,6 +9157,14 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
|
9093
9157
|
const silkscreenRects = su(circuitJson).pcb_silkscreen_rect.list();
|
|
9094
9158
|
const silkscreenTexts = su(circuitJson).pcb_silkscreen_text.list();
|
|
9095
9159
|
const fabricationNotePaths = su(circuitJson).pcb_fabrication_note_path.list();
|
|
9160
|
+
const fabricationNoteTexts = su(circuitJson).pcb_fabrication_note_text.list();
|
|
9161
|
+
const fabricationNoteRects = su(circuitJson).pcb_fabrication_note_rect.list();
|
|
9162
|
+
const fabricationNoteDimensions = su(circuitJson).pcb_fabrication_note_dimension.list();
|
|
9163
|
+
const pcbNoteTexts = su(circuitJson).pcb_note_text.list();
|
|
9164
|
+
const pcbNoteRects = su(circuitJson).pcb_note_rect.list();
|
|
9165
|
+
const pcbNotePaths = su(circuitJson).pcb_note_path.list();
|
|
9166
|
+
const pcbNoteLines = su(circuitJson).pcb_note_line.list();
|
|
9167
|
+
const pcbNoteDimensions = su(circuitJson).pcb_note_dimension.list();
|
|
9096
9168
|
const courtyardOutlines = su(circuitJson).pcb_courtyard_outline.list();
|
|
9097
9169
|
const elementStrings = [];
|
|
9098
9170
|
for (const hole of holes) {
|
|
@@ -9185,7 +9257,49 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
|
9185
9257
|
}
|
|
9186
9258
|
for (const fabricationNotePath of fabricationNotePaths) {
|
|
9187
9259
|
elementStrings.push(
|
|
9188
|
-
`<fabricationnotepath route={${JSON.stringify(fabricationNotePath.route)}} strokeWidth="${mmStr(fabricationNotePath.stroke_width)}" />`
|
|
9260
|
+
`<fabricationnotepath route={${JSON.stringify(fabricationNotePath.route)}} strokeWidth="${mmStr(fabricationNotePath.stroke_width)}"${getStringAttr("color", fabricationNotePath.color)}${getLayerAttr(fabricationNotePath.layer)} />`
|
|
9261
|
+
);
|
|
9262
|
+
}
|
|
9263
|
+
for (const fabricationNoteText of fabricationNoteTexts) {
|
|
9264
|
+
elementStrings.push(
|
|
9265
|
+
`<fabricationnotetext text=${JSON.stringify(fabricationNoteText.text)} pcbX="${mmStr(fabricationNoteText.anchor_position.x)}" pcbY="${mmStr(fabricationNoteText.anchor_position.y)}" anchorAlignment="${fabricationNoteText.anchor_alignment}"${getStringAttr("font", fabricationNoteText.font)}${fabricationNoteText.font_size === void 0 ? "" : ` fontSize="${mmStr(fabricationNoteText.font_size)}"`}${getStringAttr("color", fabricationNoteText.color)}${getRotationAttr(fabricationNoteText.ccw_rotation)}${getLayerAttr(fabricationNoteText.layer)} />`
|
|
9266
|
+
);
|
|
9267
|
+
}
|
|
9268
|
+
for (const fabricationNoteRect of fabricationNoteRects) {
|
|
9269
|
+
elementStrings.push(
|
|
9270
|
+
`<fabricationnoterect pcbX="${mmStr(fabricationNoteRect.center.x)}" pcbY="${mmStr(fabricationNoteRect.center.y)}" width="${mmStr(fabricationNoteRect.width)}" height="${mmStr(fabricationNoteRect.height)}" strokeWidth="${mmStr(fabricationNoteRect.stroke_width)}"${fabricationNoteRect.corner_radius === void 0 ? "" : ` cornerRadius="${mmStr(fabricationNoteRect.corner_radius)}"`}${fabricationNoteRect.is_filled === void 0 ? "" : ` isFilled={${fabricationNoteRect.is_filled}}`}${fabricationNoteRect.has_stroke === void 0 ? "" : ` hasStroke={${fabricationNoteRect.has_stroke}}`}${fabricationNoteRect.is_stroke_dashed === void 0 ? "" : ` isStrokeDashed={${fabricationNoteRect.is_stroke_dashed}}`}${getStringAttr("color", fabricationNoteRect.color)}${getLayerAttr(fabricationNoteRect.layer)} />`
|
|
9271
|
+
);
|
|
9272
|
+
}
|
|
9273
|
+
for (const fabricationNoteDimension of fabricationNoteDimensions) {
|
|
9274
|
+
const offset = "offset" in fabricationNoteDimension ? fabricationNoteDimension.offset : fabricationNoteDimension.offset_distance;
|
|
9275
|
+
elementStrings.push(
|
|
9276
|
+
`<fabricationnotedimension from={${JSON.stringify(fabricationNoteDimension.from)}} to={${JSON.stringify(fabricationNoteDimension.to)}}${getStringAttr("text", fabricationNoteDimension.text)}${getStringAttr("font", fabricationNoteDimension.font)}${fabricationNoteDimension.font_size === void 0 ? "" : ` fontSize="${mmStr(fabricationNoteDimension.font_size)}"`}${fabricationNoteDimension.arrow_size === void 0 ? "" : ` arrowSize="${mmStr(fabricationNoteDimension.arrow_size)}"`}${offset === void 0 ? "" : ` offset="${mmStr(offset)}"`}${getStringAttr("color", fabricationNoteDimension.color)}${getLayerAttr(fabricationNoteDimension.layer)} />`
|
|
9277
|
+
);
|
|
9278
|
+
}
|
|
9279
|
+
for (const pcbNoteText of pcbNoteTexts) {
|
|
9280
|
+
elementStrings.push(
|
|
9281
|
+
`<pcbnotetext text=${JSON.stringify(pcbNoteText.text ?? "")} pcbX="${mmStr(pcbNoteText.anchor_position.x)}" pcbY="${mmStr(pcbNoteText.anchor_position.y)}" anchorAlignment="${pcbNoteText.anchor_alignment}"${getStringAttr("font", pcbNoteText.font)}${pcbNoteText.font_size === void 0 ? "" : ` fontSize="${mmStr(pcbNoteText.font_size)}"`}${getStringAttr("color", pcbNoteText.color)}${getLayerAttr(pcbNoteText.layer)} />`
|
|
9282
|
+
);
|
|
9283
|
+
}
|
|
9284
|
+
for (const pcbNoteRect of pcbNoteRects) {
|
|
9285
|
+
elementStrings.push(
|
|
9286
|
+
`<pcbnoterect pcbX="${mmStr(pcbNoteRect.center.x)}" pcbY="${mmStr(pcbNoteRect.center.y)}" width="${mmStr(pcbNoteRect.width)}" height="${mmStr(pcbNoteRect.height)}" strokeWidth="${mmStr(pcbNoteRect.stroke_width)}"${pcbNoteRect.corner_radius === void 0 ? "" : ` cornerRadius="${mmStr(pcbNoteRect.corner_radius)}"`}${pcbNoteRect.is_filled === void 0 ? "" : ` isFilled={${pcbNoteRect.is_filled}}`}${pcbNoteRect.has_stroke === void 0 ? "" : ` hasStroke={${pcbNoteRect.has_stroke}}`}${pcbNoteRect.is_stroke_dashed === void 0 ? "" : ` isStrokeDashed={${pcbNoteRect.is_stroke_dashed}}`}${getStringAttr("color", pcbNoteRect.color)}${getLayerAttr(pcbNoteRect.layer)} />`
|
|
9287
|
+
);
|
|
9288
|
+
}
|
|
9289
|
+
for (const pcbNotePath of pcbNotePaths) {
|
|
9290
|
+
elementStrings.push(
|
|
9291
|
+
`<pcbnotepath route={${JSON.stringify(pcbNotePath.route)}} strokeWidth="${mmStr(pcbNotePath.stroke_width)}"${getStringAttr("color", pcbNotePath.color)}${getLayerAttr(pcbNotePath.layer)} />`
|
|
9292
|
+
);
|
|
9293
|
+
}
|
|
9294
|
+
for (const pcbNoteLine of pcbNoteLines) {
|
|
9295
|
+
elementStrings.push(
|
|
9296
|
+
`<pcbnoteline x1="${mmStr(pcbNoteLine.x1)}" y1="${mmStr(pcbNoteLine.y1)}" x2="${mmStr(pcbNoteLine.x2)}" y2="${mmStr(pcbNoteLine.y2)}" strokeWidth="${mmStr(pcbNoteLine.stroke_width)}"${pcbNoteLine.is_dashed === void 0 ? "" : ` isDashed={${pcbNoteLine.is_dashed}}`}${getStringAttr("color", pcbNoteLine.color)}${getLayerAttr(pcbNoteLine.layer)} />`
|
|
9297
|
+
);
|
|
9298
|
+
}
|
|
9299
|
+
for (const pcbNoteDimension of pcbNoteDimensions) {
|
|
9300
|
+
const offset = pcbNoteDimension.offset_distance;
|
|
9301
|
+
elementStrings.push(
|
|
9302
|
+
`<pcbnotedimension from={${JSON.stringify(pcbNoteDimension.from)}} to={${JSON.stringify(pcbNoteDimension.to)}}${getStringAttr("text", pcbNoteDimension.text)}${getStringAttr("font", pcbNoteDimension.font)}${pcbNoteDimension.font_size === void 0 ? "" : ` fontSize="${mmStr(pcbNoteDimension.font_size)}"`}${pcbNoteDimension.arrow_size === void 0 ? "" : ` arrowSize="${mmStr(pcbNoteDimension.arrow_size)}"`}${offset === void 0 ? "" : ` offset="${mmStr(offset)}"`}${getStringAttr("color", pcbNoteDimension.color)}${getLayerAttr(pcbNoteDimension.layer)} />`
|
|
9189
9303
|
);
|
|
9190
9304
|
}
|
|
9191
9305
|
for (const courtyardOutline of courtyardOutlines) {
|