easyeda 0.0.315 → 0.0.318
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 +39 -15
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +39 -15
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +40 -16
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -3528,7 +3528,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
|
|
|
3528
3528
|
var package_default = {
|
|
3529
3529
|
name: "easyeda",
|
|
3530
3530
|
type: "module",
|
|
3531
|
-
version: "0.0.
|
|
3531
|
+
version: "0.0.316",
|
|
3532
3532
|
files: [
|
|
3533
3533
|
"dist"
|
|
3534
3534
|
],
|
|
@@ -9304,9 +9304,11 @@ var getPolarizedPinMetadata = (pinLabels) => {
|
|
|
9304
9304
|
|
|
9305
9305
|
// lib/utils/normalize-pin-labels.ts
|
|
9306
9306
|
var normalizeActiveLowPinLabel = (label) => {
|
|
9307
|
-
|
|
9308
|
-
|
|
9307
|
+
const hasActiveLowMarker = label.startsWith("#") || label.endsWith("#");
|
|
9308
|
+
if (!hasActiveLowMarker) return label;
|
|
9309
|
+
const activeLowLabel = label.replace(/^#/, "").replace(/#$/, "");
|
|
9309
9310
|
if (activeLowLabel.length === 0) return label;
|
|
9311
|
+
if (activeLowLabel.startsWith("N_")) return activeLowLabel;
|
|
9310
9312
|
return `N_${activeLowLabel}`;
|
|
9311
9313
|
};
|
|
9312
9314
|
var normalizePinLabels = (inputPinLabels) => {
|
|
@@ -9848,14 +9850,32 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
9848
9850
|
if (pin) labels.push(normalizeSymbolName(pin.label));
|
|
9849
9851
|
return labels;
|
|
9850
9852
|
});
|
|
9851
|
-
const
|
|
9853
|
+
const padNumberKeys = pads.map((pad, index) => {
|
|
9854
|
+
const padNumber = String(pad.number ?? "").trim();
|
|
9855
|
+
return padNumber ? `number:${padNumber}` : `index:${index}`;
|
|
9856
|
+
});
|
|
9857
|
+
const uniquePinLabelSets = [];
|
|
9858
|
+
const uniquePinIndexByKey = /* @__PURE__ */ new Map();
|
|
9859
|
+
const uniquePinIndexByPad = padNumberKeys.map((key, padIndex) => {
|
|
9860
|
+
const existingIndex = uniquePinIndexByKey.get(key);
|
|
9861
|
+
if (existingIndex !== void 0) return existingIndex;
|
|
9862
|
+
const uniquePinIndex = uniquePinLabelSets.length;
|
|
9863
|
+
uniquePinIndexByKey.set(key, uniquePinIndex);
|
|
9864
|
+
uniquePinLabelSets.push(pinLabelSets[padIndex]);
|
|
9865
|
+
return uniquePinIndex;
|
|
9866
|
+
});
|
|
9867
|
+
const normalizedUniquePinLabels = normalizePinLabels(uniquePinLabelSets);
|
|
9868
|
+
const normalizedPinLabels = uniquePinIndexByPad.map(
|
|
9869
|
+
(uniquePinIndex) => normalizedUniquePinLabels[uniquePinIndex]
|
|
9870
|
+
);
|
|
9852
9871
|
const normalizedPinLabelsByPin = Object.fromEntries(
|
|
9853
|
-
|
|
9872
|
+
normalizedUniquePinLabels.map((labels) => {
|
|
9854
9873
|
const pin = labels.find((label) => /^pin\d+$/i.test(label));
|
|
9855
9874
|
return [pin, labels.filter((label) => label !== pin)];
|
|
9856
9875
|
})
|
|
9857
9876
|
);
|
|
9858
9877
|
const polarizedPinMetadata = pads.length === 2 && (isDiodeCategoryComponent(easyEdaJson) || isLedCategoryComponent(easyEdaJson)) ? getPolarizedPinMetadata(normalizedPinLabelsByPin) : void 0;
|
|
9878
|
+
const emittedSourcePinIndexes = /* @__PURE__ */ new Set();
|
|
9859
9879
|
pads.forEach((pad, index) => {
|
|
9860
9880
|
const portHints = normalizedPinLabels[index];
|
|
9861
9881
|
const pinNumber = Number.parseInt(
|
|
@@ -9863,14 +9883,18 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
9863
9883
|
);
|
|
9864
9884
|
const canonicalPinName = `pin${pinNumber}`;
|
|
9865
9885
|
const pcbPortHints = polarizedPinMetadata?.portHintsMap[canonicalPinName] ?? [canonicalPinName];
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
|
|
9886
|
+
const uniquePinIndex = uniquePinIndexByPad[index];
|
|
9887
|
+
if (!emittedSourcePinIndexes.has(uniquePinIndex)) {
|
|
9888
|
+
emittedSourcePinIndexes.add(uniquePinIndex);
|
|
9889
|
+
circuitElements.push({
|
|
9890
|
+
type: "source_port",
|
|
9891
|
+
source_port_id: `source_port_${index + 1}`,
|
|
9892
|
+
source_component_id: "source_component_1",
|
|
9893
|
+
name: `pin${pinNumber}`,
|
|
9894
|
+
pin_number: pinNumber,
|
|
9895
|
+
port_hints: portHints.filter((hint) => hint !== `pin${pinNumber}`)
|
|
9896
|
+
});
|
|
9897
|
+
}
|
|
9874
9898
|
if (pad.holeRadius !== void 0 && mil2mm(pad.holeRadius) !== 0) {
|
|
9875
9899
|
const platedHoleId = pad.shape === "RECT" && pad.rotation !== void 0 ? `pcb_plated_hole_${index + 1}_rot${pad.rotation}` : `pcb_plated_hole_${index + 1}`;
|
|
9876
9900
|
const commonPlatedHoleProps = {
|
|
@@ -10692,9 +10716,9 @@ var parsePin = (pinString) => {
|
|
|
10692
10716
|
const [, visibility, , pinNumber, x, y, rotation2, id] = parts;
|
|
10693
10717
|
const nameMatch = pinString.match(/~([\w+#-]+)~(start|end)~/);
|
|
10694
10718
|
let label = nameMatch ? nameMatch[1] : "";
|
|
10695
|
-
if (label.endsWith("+")) label = label.slice(0, -1)
|
|
10696
|
-
if (label.endsWith("-")) label = label.slice(0, -1)
|
|
10697
|
-
|
|
10719
|
+
if (label.endsWith("+")) label = `${label.slice(0, -1)}_POS`;
|
|
10720
|
+
if (label.endsWith("-")) label = `${label.slice(0, -1)}_NEG`;
|
|
10721
|
+
label = normalizeActiveLowPinLabel(label);
|
|
10698
10722
|
if (/^\+\d+(?:\.\d+)?V$/i.test(label)) label = `V${label.slice(1, -1)}`;
|
|
10699
10723
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
10700
10724
|
const labelColor = colorMatch ? colorMatch[0] : "";
|