easyeda 0.0.314 → 0.0.315
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 +47 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +47 -2
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +48 -3
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7873,6 +7873,37 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
|
7873
7873
|
`.trim();
|
|
7874
7874
|
};
|
|
7875
7875
|
|
|
7876
|
+
// lib/websafe/convert-to-typescript-component/infer-pin-attributes.ts
|
|
7877
|
+
var POWER_PIN_LABEL = /^(?:VCC|VDD|VIN|VDDA)\d*$/;
|
|
7878
|
+
var GROUND_PIN_LABEL = /^(?:GND|VSS|PGND|AGND)\d*$/;
|
|
7879
|
+
var NO_CONNECT_PIN_LABEL = /^NC\d*$/;
|
|
7880
|
+
var getAttributeKind = (label) => {
|
|
7881
|
+
const normalizedLabel = label.trim().toUpperCase();
|
|
7882
|
+
if (POWER_PIN_LABEL.test(normalizedLabel)) return "power";
|
|
7883
|
+
if (GROUND_PIN_LABEL.test(normalizedLabel)) return "ground";
|
|
7884
|
+
if (NO_CONNECT_PIN_LABEL.test(normalizedLabel)) return "no-connect";
|
|
7885
|
+
return void 0;
|
|
7886
|
+
};
|
|
7887
|
+
var inferPinAttributes = (pinLabels) => {
|
|
7888
|
+
const pinAttributes = {};
|
|
7889
|
+
for (const [pinName, labels] of Object.entries(pinLabels)) {
|
|
7890
|
+
const labelList = typeof labels === "string" ? [labels] : labels;
|
|
7891
|
+
const inferredKinds = labelList.map(getAttributeKind);
|
|
7892
|
+
if (inferredKinds.some((kind) => kind === void 0)) continue;
|
|
7893
|
+
const attributeKinds = new Set(inferredKinds);
|
|
7894
|
+
if (attributeKinds.size !== 1) continue;
|
|
7895
|
+
const [attributeKind] = attributeKinds;
|
|
7896
|
+
if (attributeKind === "power") {
|
|
7897
|
+
pinAttributes[pinName] = { requiresPower: true };
|
|
7898
|
+
} else if (attributeKind === "ground") {
|
|
7899
|
+
pinAttributes[pinName] = { requiresGround: true };
|
|
7900
|
+
} else if (attributeKind === "no-connect") {
|
|
7901
|
+
pinAttributes[pinName] = { doNotConnect: true };
|
|
7902
|
+
}
|
|
7903
|
+
}
|
|
7904
|
+
return pinAttributes;
|
|
7905
|
+
};
|
|
7906
|
+
|
|
7876
7907
|
// lib/websafe/convert-to-typescript-component/generate-typescript-component.ts
|
|
7877
7908
|
var generateTypescriptComponent = ({
|
|
7878
7909
|
pinLabels,
|
|
@@ -7908,6 +7939,20 @@ var generateTypescriptComponent = ({
|
|
|
7908
7939
|
})
|
|
7909
7940
|
);
|
|
7910
7941
|
const pinLabelsString = Object.entries(simplifiedPinLabels).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
|
|
7942
|
+
const inferredPinAttributes = componentType === "chip" ? inferPinAttributes(simplifiedPinLabels) : {};
|
|
7943
|
+
const pinAttributesString = Object.entries(inferredPinAttributes).map(([pin, attributes]) => {
|
|
7944
|
+
const attributesString = Object.entries(attributes).map(
|
|
7945
|
+
([attributeName, value]) => `${attributeName}: ${JSON.stringify(value)}`
|
|
7946
|
+
).join(", ");
|
|
7947
|
+
return ` ${pin}: {${attributesString}}`;
|
|
7948
|
+
}).join(",\n");
|
|
7949
|
+
const pinAttributesBlock = pinAttributesString ? `const pinAttributes = {
|
|
7950
|
+
${pinAttributesString}
|
|
7951
|
+
} as const
|
|
7952
|
+
|
|
7953
|
+
` : "";
|
|
7954
|
+
const pinAttributesProp = pinAttributesString ? ` pinAttributes={pinAttributes}
|
|
7955
|
+
` : "";
|
|
7911
7956
|
const polarizedPinLabelsString = Object.entries(polarizedPinLabels ?? {}).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
|
|
7912
7957
|
const polarizedPinLabelsBlock = polarizedPinLabels ? `const pinLabels = {
|
|
7913
7958
|
${polarizedPinLabelsString}
|
|
@@ -8159,11 +8204,11 @@ const pinLabels = {
|
|
|
8159
8204
|
${pinLabelsString}
|
|
8160
8205
|
} as const
|
|
8161
8206
|
|
|
8162
|
-
export const ${componentName} = (props: ChipProps<typeof pinLabels>) => {
|
|
8207
|
+
${pinAttributesBlock}export const ${componentName} = (props: ChipProps<typeof pinLabels>) => {
|
|
8163
8208
|
return (
|
|
8164
8209
|
<chip
|
|
8165
8210
|
pinLabels={pinLabels}
|
|
8166
|
-
${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
8211
|
+
${pinAttributesProp}${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
8167
8212
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
8168
8213
|
footprint={${footprintTsx}}
|
|
8169
8214
|
${objUrl || stepUrl ? `cadModel={{
|