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/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.315",
|
|
3532
3532
|
files: [
|
|
3533
3533
|
"dist"
|
|
3534
3534
|
],
|
|
@@ -9848,14 +9848,32 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
9848
9848
|
if (pin) labels.push(normalizeSymbolName(pin.label));
|
|
9849
9849
|
return labels;
|
|
9850
9850
|
});
|
|
9851
|
-
const
|
|
9851
|
+
const padNumberKeys = pads.map((pad, index) => {
|
|
9852
|
+
const padNumber = String(pad.number ?? "").trim();
|
|
9853
|
+
return padNumber ? `number:${padNumber}` : `index:${index}`;
|
|
9854
|
+
});
|
|
9855
|
+
const uniquePinLabelSets = [];
|
|
9856
|
+
const uniquePinIndexByKey = /* @__PURE__ */ new Map();
|
|
9857
|
+
const uniquePinIndexByPad = padNumberKeys.map((key, padIndex) => {
|
|
9858
|
+
const existingIndex = uniquePinIndexByKey.get(key);
|
|
9859
|
+
if (existingIndex !== void 0) return existingIndex;
|
|
9860
|
+
const uniquePinIndex = uniquePinLabelSets.length;
|
|
9861
|
+
uniquePinIndexByKey.set(key, uniquePinIndex);
|
|
9862
|
+
uniquePinLabelSets.push(pinLabelSets[padIndex]);
|
|
9863
|
+
return uniquePinIndex;
|
|
9864
|
+
});
|
|
9865
|
+
const normalizedUniquePinLabels = normalizePinLabels(uniquePinLabelSets);
|
|
9866
|
+
const normalizedPinLabels = uniquePinIndexByPad.map(
|
|
9867
|
+
(uniquePinIndex) => normalizedUniquePinLabels[uniquePinIndex]
|
|
9868
|
+
);
|
|
9852
9869
|
const normalizedPinLabelsByPin = Object.fromEntries(
|
|
9853
|
-
|
|
9870
|
+
normalizedUniquePinLabels.map((labels) => {
|
|
9854
9871
|
const pin = labels.find((label) => /^pin\d+$/i.test(label));
|
|
9855
9872
|
return [pin, labels.filter((label) => label !== pin)];
|
|
9856
9873
|
})
|
|
9857
9874
|
);
|
|
9858
9875
|
const polarizedPinMetadata = pads.length === 2 && (isDiodeCategoryComponent(easyEdaJson) || isLedCategoryComponent(easyEdaJson)) ? getPolarizedPinMetadata(normalizedPinLabelsByPin) : void 0;
|
|
9876
|
+
const emittedSourcePinIndexes = /* @__PURE__ */ new Set();
|
|
9859
9877
|
pads.forEach((pad, index) => {
|
|
9860
9878
|
const portHints = normalizedPinLabels[index];
|
|
9861
9879
|
const pinNumber = Number.parseInt(
|
|
@@ -9863,14 +9881,18 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
9863
9881
|
);
|
|
9864
9882
|
const canonicalPinName = `pin${pinNumber}`;
|
|
9865
9883
|
const pcbPortHints = polarizedPinMetadata?.portHintsMap[canonicalPinName] ?? [canonicalPinName];
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
|
|
9884
|
+
const uniquePinIndex = uniquePinIndexByPad[index];
|
|
9885
|
+
if (!emittedSourcePinIndexes.has(uniquePinIndex)) {
|
|
9886
|
+
emittedSourcePinIndexes.add(uniquePinIndex);
|
|
9887
|
+
circuitElements.push({
|
|
9888
|
+
type: "source_port",
|
|
9889
|
+
source_port_id: `source_port_${index + 1}`,
|
|
9890
|
+
source_component_id: "source_component_1",
|
|
9891
|
+
name: `pin${pinNumber}`,
|
|
9892
|
+
pin_number: pinNumber,
|
|
9893
|
+
port_hints: portHints.filter((hint) => hint !== `pin${pinNumber}`)
|
|
9894
|
+
});
|
|
9895
|
+
}
|
|
9874
9896
|
if (pad.holeRadius !== void 0 && mil2mm(pad.holeRadius) !== 0) {
|
|
9875
9897
|
const platedHoleId = pad.shape === "RECT" && pad.rotation !== void 0 ? `pcb_plated_hole_${index + 1}_rot${pad.rotation}` : `pcb_plated_hole_${index + 1}`;
|
|
9876
9898
|
const commonPlatedHoleProps = {
|
|
@@ -11280,6 +11302,37 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
|
11280
11302
|
`.trim();
|
|
11281
11303
|
};
|
|
11282
11304
|
|
|
11305
|
+
// lib/websafe/convert-to-typescript-component/infer-pin-attributes.ts
|
|
11306
|
+
var POWER_PIN_LABEL = /^(?:VCC|VDD|VIN|VDDA)\d*$/;
|
|
11307
|
+
var GROUND_PIN_LABEL = /^(?:GND|VSS|PGND|AGND)\d*$/;
|
|
11308
|
+
var NO_CONNECT_PIN_LABEL = /^NC\d*$/;
|
|
11309
|
+
var getAttributeKind = (label) => {
|
|
11310
|
+
const normalizedLabel = label.trim().toUpperCase();
|
|
11311
|
+
if (POWER_PIN_LABEL.test(normalizedLabel)) return "power";
|
|
11312
|
+
if (GROUND_PIN_LABEL.test(normalizedLabel)) return "ground";
|
|
11313
|
+
if (NO_CONNECT_PIN_LABEL.test(normalizedLabel)) return "no-connect";
|
|
11314
|
+
return void 0;
|
|
11315
|
+
};
|
|
11316
|
+
var inferPinAttributes = (pinLabels) => {
|
|
11317
|
+
const pinAttributes = {};
|
|
11318
|
+
for (const [pinName, labels] of Object.entries(pinLabels)) {
|
|
11319
|
+
const labelList = typeof labels === "string" ? [labels] : labels;
|
|
11320
|
+
const inferredKinds = labelList.map(getAttributeKind);
|
|
11321
|
+
if (inferredKinds.some((kind) => kind === void 0)) continue;
|
|
11322
|
+
const attributeKinds = new Set(inferredKinds);
|
|
11323
|
+
if (attributeKinds.size !== 1) continue;
|
|
11324
|
+
const [attributeKind] = attributeKinds;
|
|
11325
|
+
if (attributeKind === "power") {
|
|
11326
|
+
pinAttributes[pinName] = { requiresPower: true };
|
|
11327
|
+
} else if (attributeKind === "ground") {
|
|
11328
|
+
pinAttributes[pinName] = { requiresGround: true };
|
|
11329
|
+
} else if (attributeKind === "no-connect") {
|
|
11330
|
+
pinAttributes[pinName] = { doNotConnect: true };
|
|
11331
|
+
}
|
|
11332
|
+
}
|
|
11333
|
+
return pinAttributes;
|
|
11334
|
+
};
|
|
11335
|
+
|
|
11283
11336
|
// lib/websafe/convert-to-typescript-component/generate-typescript-component.ts
|
|
11284
11337
|
var generateTypescriptComponent = ({
|
|
11285
11338
|
pinLabels,
|
|
@@ -11315,6 +11368,20 @@ var generateTypescriptComponent = ({
|
|
|
11315
11368
|
})
|
|
11316
11369
|
);
|
|
11317
11370
|
const pinLabelsString = Object.entries(simplifiedPinLabels).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
|
|
11371
|
+
const inferredPinAttributes = componentType === "chip" ? inferPinAttributes(simplifiedPinLabels) : {};
|
|
11372
|
+
const pinAttributesString = Object.entries(inferredPinAttributes).map(([pin, attributes]) => {
|
|
11373
|
+
const attributesString = Object.entries(attributes).map(
|
|
11374
|
+
([attributeName, value]) => `${attributeName}: ${JSON.stringify(value)}`
|
|
11375
|
+
).join(", ");
|
|
11376
|
+
return ` ${pin}: {${attributesString}}`;
|
|
11377
|
+
}).join(",\n");
|
|
11378
|
+
const pinAttributesBlock = pinAttributesString ? `const pinAttributes = {
|
|
11379
|
+
${pinAttributesString}
|
|
11380
|
+
} as const
|
|
11381
|
+
|
|
11382
|
+
` : "";
|
|
11383
|
+
const pinAttributesProp = pinAttributesString ? ` pinAttributes={pinAttributes}
|
|
11384
|
+
` : "";
|
|
11318
11385
|
const polarizedPinLabelsString = Object.entries(polarizedPinLabels ?? {}).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
|
|
11319
11386
|
const polarizedPinLabelsBlock = polarizedPinLabels ? `const pinLabels = {
|
|
11320
11387
|
${polarizedPinLabelsString}
|
|
@@ -11566,11 +11633,11 @@ const pinLabels = {
|
|
|
11566
11633
|
${pinLabelsString}
|
|
11567
11634
|
} as const
|
|
11568
11635
|
|
|
11569
|
-
export const ${componentName} = (props: ChipProps<typeof pinLabels>) => {
|
|
11636
|
+
${pinAttributesBlock}export const ${componentName} = (props: ChipProps<typeof pinLabels>) => {
|
|
11570
11637
|
return (
|
|
11571
11638
|
<chip
|
|
11572
11639
|
pinLabels={pinLabels}
|
|
11573
|
-
${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11640
|
+
${pinAttributesProp}${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11574
11641
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
11575
11642
|
footprint={${footprintTsx}}
|
|
11576
11643
|
${objUrl || stepUrl ? `cadModel={{
|