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/browser/index.js
CHANGED
|
@@ -9586,9 +9586,11 @@ var getPolarizedPinMetadata = (pinLabels) => {
|
|
|
9586
9586
|
|
|
9587
9587
|
// lib/utils/normalize-pin-labels.ts
|
|
9588
9588
|
var normalizeActiveLowPinLabel = (label) => {
|
|
9589
|
-
|
|
9590
|
-
|
|
9589
|
+
const hasActiveLowMarker = label.startsWith("#") || label.endsWith("#");
|
|
9590
|
+
if (!hasActiveLowMarker) return label;
|
|
9591
|
+
const activeLowLabel = label.replace(/^#/, "").replace(/#$/, "");
|
|
9591
9592
|
if (activeLowLabel.length === 0) return label;
|
|
9593
|
+
if (activeLowLabel.startsWith("N_")) return activeLowLabel;
|
|
9592
9594
|
return `N_${activeLowLabel}`;
|
|
9593
9595
|
};
|
|
9594
9596
|
var normalizePinLabels = (inputPinLabels) => {
|
|
@@ -10130,14 +10132,32 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
10130
10132
|
if (pin) labels.push(normalizeSymbolName(pin.label));
|
|
10131
10133
|
return labels;
|
|
10132
10134
|
});
|
|
10133
|
-
const
|
|
10135
|
+
const padNumberKeys = pads.map((pad, index) => {
|
|
10136
|
+
const padNumber = String(pad.number ?? "").trim();
|
|
10137
|
+
return padNumber ? `number:${padNumber}` : `index:${index}`;
|
|
10138
|
+
});
|
|
10139
|
+
const uniquePinLabelSets = [];
|
|
10140
|
+
const uniquePinIndexByKey = /* @__PURE__ */ new Map();
|
|
10141
|
+
const uniquePinIndexByPad = padNumberKeys.map((key, padIndex) => {
|
|
10142
|
+
const existingIndex = uniquePinIndexByKey.get(key);
|
|
10143
|
+
if (existingIndex !== void 0) return existingIndex;
|
|
10144
|
+
const uniquePinIndex = uniquePinLabelSets.length;
|
|
10145
|
+
uniquePinIndexByKey.set(key, uniquePinIndex);
|
|
10146
|
+
uniquePinLabelSets.push(pinLabelSets[padIndex]);
|
|
10147
|
+
return uniquePinIndex;
|
|
10148
|
+
});
|
|
10149
|
+
const normalizedUniquePinLabels = normalizePinLabels(uniquePinLabelSets);
|
|
10150
|
+
const normalizedPinLabels = uniquePinIndexByPad.map(
|
|
10151
|
+
(uniquePinIndex) => normalizedUniquePinLabels[uniquePinIndex]
|
|
10152
|
+
);
|
|
10134
10153
|
const normalizedPinLabelsByPin = Object.fromEntries(
|
|
10135
|
-
|
|
10154
|
+
normalizedUniquePinLabels.map((labels) => {
|
|
10136
10155
|
const pin = labels.find((label) => /^pin\d+$/i.test(label));
|
|
10137
10156
|
return [pin, labels.filter((label) => label !== pin)];
|
|
10138
10157
|
})
|
|
10139
10158
|
);
|
|
10140
10159
|
const polarizedPinMetadata = pads.length === 2 && (isDiodeCategoryComponent(easyEdaJson) || isLedCategoryComponent(easyEdaJson)) ? getPolarizedPinMetadata(normalizedPinLabelsByPin) : void 0;
|
|
10160
|
+
const emittedSourcePinIndexes = /* @__PURE__ */ new Set();
|
|
10141
10161
|
pads.forEach((pad, index) => {
|
|
10142
10162
|
const portHints = normalizedPinLabels[index];
|
|
10143
10163
|
const pinNumber = Number.parseInt(
|
|
@@ -10145,14 +10165,18 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
10145
10165
|
);
|
|
10146
10166
|
const canonicalPinName = `pin${pinNumber}`;
|
|
10147
10167
|
const pcbPortHints = polarizedPinMetadata?.portHintsMap[canonicalPinName] ?? [canonicalPinName];
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
|
|
10154
|
-
|
|
10155
|
-
|
|
10168
|
+
const uniquePinIndex = uniquePinIndexByPad[index];
|
|
10169
|
+
if (!emittedSourcePinIndexes.has(uniquePinIndex)) {
|
|
10170
|
+
emittedSourcePinIndexes.add(uniquePinIndex);
|
|
10171
|
+
circuitElements.push({
|
|
10172
|
+
type: "source_port",
|
|
10173
|
+
source_port_id: `source_port_${index + 1}`,
|
|
10174
|
+
source_component_id: "source_component_1",
|
|
10175
|
+
name: `pin${pinNumber}`,
|
|
10176
|
+
pin_number: pinNumber,
|
|
10177
|
+
port_hints: portHints.filter((hint) => hint !== `pin${pinNumber}`)
|
|
10178
|
+
});
|
|
10179
|
+
}
|
|
10156
10180
|
if (pad.holeRadius !== void 0 && mil2mm(pad.holeRadius) !== 0) {
|
|
10157
10181
|
const platedHoleId = pad.shape === "RECT" && pad.rotation !== void 0 ? `pcb_plated_hole_${index + 1}_rot${pad.rotation}` : `pcb_plated_hole_${index + 1}`;
|
|
10158
10182
|
const commonPlatedHoleProps = {
|
|
@@ -10969,9 +10993,9 @@ var parsePin = (pinString) => {
|
|
|
10969
10993
|
const [, visibility, , pinNumber, x, y, rotation2, id] = parts;
|
|
10970
10994
|
const nameMatch = pinString.match(/~([\w+#-]+)~(start|end)~/);
|
|
10971
10995
|
let label = nameMatch ? nameMatch[1] : "";
|
|
10972
|
-
if (label.endsWith("+")) label = label.slice(0, -1)
|
|
10973
|
-
if (label.endsWith("-")) label = label.slice(0, -1)
|
|
10974
|
-
|
|
10996
|
+
if (label.endsWith("+")) label = `${label.slice(0, -1)}_POS`;
|
|
10997
|
+
if (label.endsWith("-")) label = `${label.slice(0, -1)}_NEG`;
|
|
10998
|
+
label = normalizeActiveLowPinLabel(label);
|
|
10975
10999
|
if (/^\+\d+(?:\.\d+)?V$/i.test(label)) label = `V${label.slice(1, -1)}`;
|
|
10976
11000
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
10977
11001
|
const labelColor = colorMatch ? colorMatch[0] : "";
|