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/index.js
CHANGED
|
@@ -5723,9 +5723,11 @@ var getPolarizedPinMetadata = (pinLabels) => {
|
|
|
5723
5723
|
|
|
5724
5724
|
// lib/utils/normalize-pin-labels.ts
|
|
5725
5725
|
var normalizeActiveLowPinLabel = (label) => {
|
|
5726
|
-
|
|
5727
|
-
|
|
5726
|
+
const hasActiveLowMarker = label.startsWith("#") || label.endsWith("#");
|
|
5727
|
+
if (!hasActiveLowMarker) return label;
|
|
5728
|
+
const activeLowLabel = label.replace(/^#/, "").replace(/#$/, "");
|
|
5728
5729
|
if (activeLowLabel.length === 0) return label;
|
|
5730
|
+
if (activeLowLabel.startsWith("N_")) return activeLowLabel;
|
|
5729
5731
|
return `N_${activeLowLabel}`;
|
|
5730
5732
|
};
|
|
5731
5733
|
var normalizePinLabels = (inputPinLabels) => {
|
|
@@ -6267,14 +6269,32 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
6267
6269
|
if (pin) labels.push(normalizeSymbolName(pin.label));
|
|
6268
6270
|
return labels;
|
|
6269
6271
|
});
|
|
6270
|
-
const
|
|
6272
|
+
const padNumberKeys = pads.map((pad, index) => {
|
|
6273
|
+
const padNumber = String(pad.number ?? "").trim();
|
|
6274
|
+
return padNumber ? `number:${padNumber}` : `index:${index}`;
|
|
6275
|
+
});
|
|
6276
|
+
const uniquePinLabelSets = [];
|
|
6277
|
+
const uniquePinIndexByKey = /* @__PURE__ */ new Map();
|
|
6278
|
+
const uniquePinIndexByPad = padNumberKeys.map((key, padIndex) => {
|
|
6279
|
+
const existingIndex = uniquePinIndexByKey.get(key);
|
|
6280
|
+
if (existingIndex !== void 0) return existingIndex;
|
|
6281
|
+
const uniquePinIndex = uniquePinLabelSets.length;
|
|
6282
|
+
uniquePinIndexByKey.set(key, uniquePinIndex);
|
|
6283
|
+
uniquePinLabelSets.push(pinLabelSets[padIndex]);
|
|
6284
|
+
return uniquePinIndex;
|
|
6285
|
+
});
|
|
6286
|
+
const normalizedUniquePinLabels = normalizePinLabels(uniquePinLabelSets);
|
|
6287
|
+
const normalizedPinLabels = uniquePinIndexByPad.map(
|
|
6288
|
+
(uniquePinIndex) => normalizedUniquePinLabels[uniquePinIndex]
|
|
6289
|
+
);
|
|
6271
6290
|
const normalizedPinLabelsByPin = Object.fromEntries(
|
|
6272
|
-
|
|
6291
|
+
normalizedUniquePinLabels.map((labels) => {
|
|
6273
6292
|
const pin = labels.find((label) => /^pin\d+$/i.test(label));
|
|
6274
6293
|
return [pin, labels.filter((label) => label !== pin)];
|
|
6275
6294
|
})
|
|
6276
6295
|
);
|
|
6277
6296
|
const polarizedPinMetadata = pads.length === 2 && (isDiodeCategoryComponent(easyEdaJson) || isLedCategoryComponent(easyEdaJson)) ? getPolarizedPinMetadata(normalizedPinLabelsByPin) : void 0;
|
|
6297
|
+
const emittedSourcePinIndexes = /* @__PURE__ */ new Set();
|
|
6278
6298
|
pads.forEach((pad, index) => {
|
|
6279
6299
|
const portHints = normalizedPinLabels[index];
|
|
6280
6300
|
const pinNumber = Number.parseInt(
|
|
@@ -6282,14 +6302,18 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
6282
6302
|
);
|
|
6283
6303
|
const canonicalPinName = `pin${pinNumber}`;
|
|
6284
6304
|
const pcbPortHints = polarizedPinMetadata?.portHintsMap[canonicalPinName] ?? [canonicalPinName];
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6305
|
+
const uniquePinIndex = uniquePinIndexByPad[index];
|
|
6306
|
+
if (!emittedSourcePinIndexes.has(uniquePinIndex)) {
|
|
6307
|
+
emittedSourcePinIndexes.add(uniquePinIndex);
|
|
6308
|
+
circuitElements.push({
|
|
6309
|
+
type: "source_port",
|
|
6310
|
+
source_port_id: `source_port_${index + 1}`,
|
|
6311
|
+
source_component_id: "source_component_1",
|
|
6312
|
+
name: `pin${pinNumber}`,
|
|
6313
|
+
pin_number: pinNumber,
|
|
6314
|
+
port_hints: portHints.filter((hint) => hint !== `pin${pinNumber}`)
|
|
6315
|
+
});
|
|
6316
|
+
}
|
|
6293
6317
|
if (pad.holeRadius !== void 0 && mil2mm(pad.holeRadius) !== 0) {
|
|
6294
6318
|
const platedHoleId = pad.shape === "RECT" && pad.rotation !== void 0 ? `pcb_plated_hole_${index + 1}_rot${pad.rotation}` : `pcb_plated_hole_${index + 1}`;
|
|
6295
6319
|
const commonPlatedHoleProps = {
|
|
@@ -7285,9 +7309,9 @@ var parsePin = (pinString) => {
|
|
|
7285
7309
|
const [, visibility, , pinNumber, x, y, rotation2, id] = parts;
|
|
7286
7310
|
const nameMatch = pinString.match(/~([\w+#-]+)~(start|end)~/);
|
|
7287
7311
|
let label = nameMatch ? nameMatch[1] : "";
|
|
7288
|
-
if (label.endsWith("+")) label = label.slice(0, -1)
|
|
7289
|
-
if (label.endsWith("-")) label = label.slice(0, -1)
|
|
7290
|
-
|
|
7312
|
+
if (label.endsWith("+")) label = `${label.slice(0, -1)}_POS`;
|
|
7313
|
+
if (label.endsWith("-")) label = `${label.slice(0, -1)}_NEG`;
|
|
7314
|
+
label = normalizeActiveLowPinLabel(label);
|
|
7291
7315
|
if (/^\+\d+(?:\.\d+)?V$/i.test(label)) label = `V${label.slice(1, -1)}`;
|
|
7292
7316
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
7293
7317
|
const labelColor = colorMatch ? colorMatch[0] : "";
|