easyeda 0.0.253 → 0.0.254
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.js +42 -8
- package/dist/browser/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +42 -8
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +43 -9
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -8896,9 +8896,6 @@ var mmStr = (n) => {
|
|
|
8896
8896
|
return `${mm(n)}mm`;
|
|
8897
8897
|
};
|
|
8898
8898
|
|
|
8899
|
-
// lib/constants.ts
|
|
8900
|
-
var DEFAULT_PCB_THICKNESS_MM = 1.6;
|
|
8901
|
-
|
|
8902
8899
|
// lib/math/arc-utils.ts
|
|
8903
8900
|
function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag, sweepFlag) {
|
|
8904
8901
|
const start = { x: startX, y: startY };
|
|
@@ -9024,6 +9021,9 @@ var normalizeSymbolName = (name) => {
|
|
|
9024
9021
|
return trimmedName;
|
|
9025
9022
|
};
|
|
9026
9023
|
|
|
9024
|
+
// lib/constants.ts
|
|
9025
|
+
var DEFAULT_PCB_THICKNESS_MM = 1.6;
|
|
9026
|
+
|
|
9027
9027
|
// lib/convert-easyeda-json-to-tscircuit-soup-json.ts
|
|
9028
9028
|
var EASYEDA_STEP_MODEL_URL = "https://modules.easyeda.com/qAxj6KHrDKw4blvCG8QJPs7Y";
|
|
9029
9029
|
var EASYEDA_OBJ_MODEL_URL = "https://modules.easyeda.com/3dmodel";
|
|
@@ -9164,7 +9164,8 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
9164
9164
|
shouldRecenter = true,
|
|
9165
9165
|
cadPositionXMm,
|
|
9166
9166
|
cadPositionYMm,
|
|
9167
|
-
cadPositionZMm
|
|
9167
|
+
cadPositionZMm,
|
|
9168
|
+
showDesignator = false
|
|
9168
9169
|
} = {}) => {
|
|
9169
9170
|
const resolvedCadPositionZMm = cadPositionZMm ?? getCadPositionZMmFromMetadata(easyEdaJson);
|
|
9170
9171
|
const circuitElements = [];
|
|
@@ -9353,6 +9354,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
9353
9354
|
).forEach((sr, index) => {
|
|
9354
9355
|
circuitElements.push(handleCutout(sr, index));
|
|
9355
9356
|
});
|
|
9357
|
+
let hasFoundDesignator = false;
|
|
9356
9358
|
easyEdaJson.packageDetail.dataStr.shape.forEach((shape, index) => {
|
|
9357
9359
|
if (shape.type === "TRACK") {
|
|
9358
9360
|
if (!isCourtyardLayer(shape.layer)) {
|
|
@@ -9364,12 +9366,22 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
9364
9366
|
}
|
|
9365
9367
|
} else if (shape.type === "TEXT") {
|
|
9366
9368
|
if (isCourtyardLayer(shape.layer)) return;
|
|
9369
|
+
let text = shape.text;
|
|
9370
|
+
const designatorPrefix = easyEdaJson.dataStr.head.c_para.pre || "U";
|
|
9371
|
+
const normalizedPrefix = designatorPrefix.replace(/\?/g, "");
|
|
9372
|
+
const trimmedText = text.trim();
|
|
9373
|
+
const isDesignator = trimmedText === designatorPrefix || trimmedText === `${normalizedPrefix}?` || trimmedText === normalizedPrefix;
|
|
9374
|
+
if (isDesignator) {
|
|
9375
|
+
if (!showDesignator) return;
|
|
9376
|
+
text = "{NAME}";
|
|
9377
|
+
hasFoundDesignator = true;
|
|
9378
|
+
}
|
|
9367
9379
|
circuitElements.push(
|
|
9368
9380
|
pcb_silkscreen_text.parse({
|
|
9369
9381
|
type: "pcb_silkscreen_text",
|
|
9370
9382
|
pcb_silkscreen_text_id: `pcb_silkscreen_text_${index + 1}`,
|
|
9371
9383
|
pcb_component_id: "pcb_component_1",
|
|
9372
|
-
text
|
|
9384
|
+
text,
|
|
9373
9385
|
anchor_position: {
|
|
9374
9386
|
x: mil2mm(shape.x),
|
|
9375
9387
|
y: mil2mm(shape.y)
|
|
@@ -9379,12 +9391,31 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
9379
9391
|
C: "center",
|
|
9380
9392
|
R: "bottom_right"
|
|
9381
9393
|
}[shape.textAnchor ?? "L"],
|
|
9382
|
-
font_size: shape.size_mm
|
|
9394
|
+
font_size: shape.size_mm || 1,
|
|
9383
9395
|
layer: "top"
|
|
9384
9396
|
})
|
|
9385
9397
|
);
|
|
9386
9398
|
}
|
|
9387
9399
|
});
|
|
9400
|
+
if (!hasFoundDesignator && showDesignator) {
|
|
9401
|
+
const bbox = easyEdaJson.packageDetail.dataStr.BBox;
|
|
9402
|
+
circuitElements.push(
|
|
9403
|
+
pcb_silkscreen_text.parse({
|
|
9404
|
+
type: "pcb_silkscreen_text",
|
|
9405
|
+
pcb_silkscreen_text_id: `pcb_silkscreen_text_designator_fallback`,
|
|
9406
|
+
pcb_component_id: "pcb_component_1",
|
|
9407
|
+
text: "{NAME}",
|
|
9408
|
+
anchor_position: {
|
|
9409
|
+
x: milx10(bbox.x + bbox.width / 2),
|
|
9410
|
+
y: milx10(bbox.y) - 1
|
|
9411
|
+
// 1mm above top edge
|
|
9412
|
+
},
|
|
9413
|
+
anchor_alignment: "center",
|
|
9414
|
+
font_size: 1,
|
|
9415
|
+
layer: "top"
|
|
9416
|
+
})
|
|
9417
|
+
);
|
|
9418
|
+
}
|
|
9388
9419
|
const pcbElements = circuitElements.filter(
|
|
9389
9420
|
(e) => e.type === "pcb_smtpad" || e.type === "pcb_plated_hole" || e.type === "pcb_hole" || e.type === "pcb_via" || e.type === "pcb_courtyard_outline" || e.type === "pcb_silkscreen_path" || e.type === "pcb_silkscreen_text"
|
|
9390
9421
|
);
|
|
@@ -10558,8 +10589,10 @@ var generateFootprintTsx = (circuitJson) => {
|
|
|
10558
10589
|
);
|
|
10559
10590
|
}
|
|
10560
10591
|
for (const silkscreenText of silkscreenTexts) {
|
|
10592
|
+
const isRefDes = silkscreenText.text === "{NAME}";
|
|
10593
|
+
const textValue = isRefDes ? "{props.name}" : JSON.stringify(silkscreenText.text);
|
|
10561
10594
|
elementStrings.push(
|
|
10562
|
-
`<silkscreentext text
|
|
10595
|
+
`<silkscreentext text=${textValue} pcbX="${mmStr(silkscreenText.anchor_position.x)}" pcbY="${mmStr(silkscreenText.anchor_position.y)}" anchorAlignment="${silkscreenText.anchor_alignment}" ${silkscreenText.font_size ? `fontSize="${mmStr(silkscreenText.font_size)}"` : ""} />`
|
|
10563
10596
|
);
|
|
10564
10597
|
}
|
|
10565
10598
|
for (const courtyardOutline of courtyardOutlines) {
|
|
@@ -10643,7 +10676,8 @@ var convertBetterEasyToTsx = async ({
|
|
|
10643
10676
|
shouldRecenter: true,
|
|
10644
10677
|
cadPositionXMm: cadPlacement?.positionXMm,
|
|
10645
10678
|
cadPositionYMm: cadPlacement?.positionYMm,
|
|
10646
|
-
cadPositionZMm: cadPlacement?.positionZMm
|
|
10679
|
+
cadPositionZMm: cadPlacement?.positionZMm,
|
|
10680
|
+
showDesignator: true
|
|
10647
10681
|
});
|
|
10648
10682
|
const [cadComponent] = su(circuitJson).cad_component.list();
|
|
10649
10683
|
if (cadComponent) {
|