easyeda 0.0.314 → 0.0.316
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 +79 -12
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +79 -12
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +80 -13
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6267,14 +6267,32 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
6267
6267
|
if (pin) labels.push(normalizeSymbolName(pin.label));
|
|
6268
6268
|
return labels;
|
|
6269
6269
|
});
|
|
6270
|
-
const
|
|
6270
|
+
const padNumberKeys = pads.map((pad, index) => {
|
|
6271
|
+
const padNumber = String(pad.number ?? "").trim();
|
|
6272
|
+
return padNumber ? `number:${padNumber}` : `index:${index}`;
|
|
6273
|
+
});
|
|
6274
|
+
const uniquePinLabelSets = [];
|
|
6275
|
+
const uniquePinIndexByKey = /* @__PURE__ */ new Map();
|
|
6276
|
+
const uniquePinIndexByPad = padNumberKeys.map((key, padIndex) => {
|
|
6277
|
+
const existingIndex = uniquePinIndexByKey.get(key);
|
|
6278
|
+
if (existingIndex !== void 0) return existingIndex;
|
|
6279
|
+
const uniquePinIndex = uniquePinLabelSets.length;
|
|
6280
|
+
uniquePinIndexByKey.set(key, uniquePinIndex);
|
|
6281
|
+
uniquePinLabelSets.push(pinLabelSets[padIndex]);
|
|
6282
|
+
return uniquePinIndex;
|
|
6283
|
+
});
|
|
6284
|
+
const normalizedUniquePinLabels = normalizePinLabels(uniquePinLabelSets);
|
|
6285
|
+
const normalizedPinLabels = uniquePinIndexByPad.map(
|
|
6286
|
+
(uniquePinIndex) => normalizedUniquePinLabels[uniquePinIndex]
|
|
6287
|
+
);
|
|
6271
6288
|
const normalizedPinLabelsByPin = Object.fromEntries(
|
|
6272
|
-
|
|
6289
|
+
normalizedUniquePinLabels.map((labels) => {
|
|
6273
6290
|
const pin = labels.find((label) => /^pin\d+$/i.test(label));
|
|
6274
6291
|
return [pin, labels.filter((label) => label !== pin)];
|
|
6275
6292
|
})
|
|
6276
6293
|
);
|
|
6277
6294
|
const polarizedPinMetadata = pads.length === 2 && (isDiodeCategoryComponent(easyEdaJson) || isLedCategoryComponent(easyEdaJson)) ? getPolarizedPinMetadata(normalizedPinLabelsByPin) : void 0;
|
|
6295
|
+
const emittedSourcePinIndexes = /* @__PURE__ */ new Set();
|
|
6278
6296
|
pads.forEach((pad, index) => {
|
|
6279
6297
|
const portHints = normalizedPinLabels[index];
|
|
6280
6298
|
const pinNumber = Number.parseInt(
|
|
@@ -6282,14 +6300,18 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
6282
6300
|
);
|
|
6283
6301
|
const canonicalPinName = `pin${pinNumber}`;
|
|
6284
6302
|
const pcbPortHints = polarizedPinMetadata?.portHintsMap[canonicalPinName] ?? [canonicalPinName];
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6303
|
+
const uniquePinIndex = uniquePinIndexByPad[index];
|
|
6304
|
+
if (!emittedSourcePinIndexes.has(uniquePinIndex)) {
|
|
6305
|
+
emittedSourcePinIndexes.add(uniquePinIndex);
|
|
6306
|
+
circuitElements.push({
|
|
6307
|
+
type: "source_port",
|
|
6308
|
+
source_port_id: `source_port_${index + 1}`,
|
|
6309
|
+
source_component_id: "source_component_1",
|
|
6310
|
+
name: `pin${pinNumber}`,
|
|
6311
|
+
pin_number: pinNumber,
|
|
6312
|
+
port_hints: portHints.filter((hint) => hint !== `pin${pinNumber}`)
|
|
6313
|
+
});
|
|
6314
|
+
}
|
|
6293
6315
|
if (pad.holeRadius !== void 0 && mil2mm(pad.holeRadius) !== 0) {
|
|
6294
6316
|
const platedHoleId = pad.shape === "RECT" && pad.rotation !== void 0 ? `pcb_plated_hole_${index + 1}_rot${pad.rotation}` : `pcb_plated_hole_${index + 1}`;
|
|
6295
6317
|
const commonPlatedHoleProps = {
|
|
@@ -7873,6 +7895,37 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
|
7873
7895
|
`.trim();
|
|
7874
7896
|
};
|
|
7875
7897
|
|
|
7898
|
+
// lib/websafe/convert-to-typescript-component/infer-pin-attributes.ts
|
|
7899
|
+
var POWER_PIN_LABEL = /^(?:VCC|VDD|VIN|VDDA)\d*$/;
|
|
7900
|
+
var GROUND_PIN_LABEL = /^(?:GND|VSS|PGND|AGND)\d*$/;
|
|
7901
|
+
var NO_CONNECT_PIN_LABEL = /^NC\d*$/;
|
|
7902
|
+
var getAttributeKind = (label) => {
|
|
7903
|
+
const normalizedLabel = label.trim().toUpperCase();
|
|
7904
|
+
if (POWER_PIN_LABEL.test(normalizedLabel)) return "power";
|
|
7905
|
+
if (GROUND_PIN_LABEL.test(normalizedLabel)) return "ground";
|
|
7906
|
+
if (NO_CONNECT_PIN_LABEL.test(normalizedLabel)) return "no-connect";
|
|
7907
|
+
return void 0;
|
|
7908
|
+
};
|
|
7909
|
+
var inferPinAttributes = (pinLabels) => {
|
|
7910
|
+
const pinAttributes = {};
|
|
7911
|
+
for (const [pinName, labels] of Object.entries(pinLabels)) {
|
|
7912
|
+
const labelList = typeof labels === "string" ? [labels] : labels;
|
|
7913
|
+
const inferredKinds = labelList.map(getAttributeKind);
|
|
7914
|
+
if (inferredKinds.some((kind) => kind === void 0)) continue;
|
|
7915
|
+
const attributeKinds = new Set(inferredKinds);
|
|
7916
|
+
if (attributeKinds.size !== 1) continue;
|
|
7917
|
+
const [attributeKind] = attributeKinds;
|
|
7918
|
+
if (attributeKind === "power") {
|
|
7919
|
+
pinAttributes[pinName] = { requiresPower: true };
|
|
7920
|
+
} else if (attributeKind === "ground") {
|
|
7921
|
+
pinAttributes[pinName] = { requiresGround: true };
|
|
7922
|
+
} else if (attributeKind === "no-connect") {
|
|
7923
|
+
pinAttributes[pinName] = { doNotConnect: true };
|
|
7924
|
+
}
|
|
7925
|
+
}
|
|
7926
|
+
return pinAttributes;
|
|
7927
|
+
};
|
|
7928
|
+
|
|
7876
7929
|
// lib/websafe/convert-to-typescript-component/generate-typescript-component.ts
|
|
7877
7930
|
var generateTypescriptComponent = ({
|
|
7878
7931
|
pinLabels,
|
|
@@ -7908,6 +7961,20 @@ var generateTypescriptComponent = ({
|
|
|
7908
7961
|
})
|
|
7909
7962
|
);
|
|
7910
7963
|
const pinLabelsString = Object.entries(simplifiedPinLabels).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
|
|
7964
|
+
const inferredPinAttributes = componentType === "chip" ? inferPinAttributes(simplifiedPinLabels) : {};
|
|
7965
|
+
const pinAttributesString = Object.entries(inferredPinAttributes).map(([pin, attributes]) => {
|
|
7966
|
+
const attributesString = Object.entries(attributes).map(
|
|
7967
|
+
([attributeName, value]) => `${attributeName}: ${JSON.stringify(value)}`
|
|
7968
|
+
).join(", ");
|
|
7969
|
+
return ` ${pin}: {${attributesString}}`;
|
|
7970
|
+
}).join(",\n");
|
|
7971
|
+
const pinAttributesBlock = pinAttributesString ? `const pinAttributes = {
|
|
7972
|
+
${pinAttributesString}
|
|
7973
|
+
} as const
|
|
7974
|
+
|
|
7975
|
+
` : "";
|
|
7976
|
+
const pinAttributesProp = pinAttributesString ? ` pinAttributes={pinAttributes}
|
|
7977
|
+
` : "";
|
|
7911
7978
|
const polarizedPinLabelsString = Object.entries(polarizedPinLabels ?? {}).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
|
|
7912
7979
|
const polarizedPinLabelsBlock = polarizedPinLabels ? `const pinLabels = {
|
|
7913
7980
|
${polarizedPinLabelsString}
|
|
@@ -8159,11 +8226,11 @@ const pinLabels = {
|
|
|
8159
8226
|
${pinLabelsString}
|
|
8160
8227
|
} as const
|
|
8161
8228
|
|
|
8162
|
-
export const ${componentName} = (props: ChipProps<typeof pinLabels>) => {
|
|
8229
|
+
${pinAttributesBlock}export const ${componentName} = (props: ChipProps<typeof pinLabels>) => {
|
|
8163
8230
|
return (
|
|
8164
8231
|
<chip
|
|
8165
8232
|
pinLabels={pinLabels}
|
|
8166
|
-
${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
8233
|
+
${pinAttributesProp}${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
8167
8234
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
8168
8235
|
footprint={${footprintTsx}}
|
|
8169
8236
|
${objUrl || stepUrl ? `cadModel={{
|