easyeda 0.0.313 → 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 +52 -3
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +52 -3
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +53 -4
- 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={{
|
|
@@ -8222,7 +8267,7 @@ var categoryValueContainsPushbutton = (value) => {
|
|
|
8222
8267
|
if (/analog\s+switch/.test(normalized) || /multiplex/.test(normalized) || /switching\s+diodes?/.test(normalized) || /\bics?\b/.test(normalized)) {
|
|
8223
8268
|
return false;
|
|
8224
8269
|
}
|
|
8225
|
-
return /push\s*buttons?/.test(normalized) || /pushbuttons?/.test(normalized) || /tact(?:ile)?\s+switch(?:es)?/.test(normalized) || /keyboard\s+(?:switch(?:es)?|shaft)/.test(normalized) || /mechanical\s+keyboard\s+shaft/.test(normalized);
|
|
8270
|
+
return /push\s*buttons?/.test(normalized) || /pushbuttons?/.test(normalized) || /tact(?:ile)?\s+switch(?:es)?/.test(normalized) || /keyboard\s+(?:switch(?:es)?|shaft)/.test(normalized) || /mechanical\s+keyboard\s+shaft/.test(normalized) || /\bkey[-_\s]+(?:th|smd)(?:\b|[_-])/.test(normalized);
|
|
8226
8271
|
}
|
|
8227
8272
|
if (Array.isArray(value)) {
|
|
8228
8273
|
return value.some(categoryValueContainsPushbutton);
|
|
@@ -8238,10 +8283,14 @@ var isPushbuttonCategoryComponent = (betterEasy) => {
|
|
|
8238
8283
|
const cPara = betterEasy.dataStr.head.c_para;
|
|
8239
8284
|
return [
|
|
8240
8285
|
betterEasy.tags,
|
|
8286
|
+
betterEasy.title,
|
|
8287
|
+
betterEasy.description,
|
|
8241
8288
|
cPara.category,
|
|
8242
8289
|
cPara.Category,
|
|
8243
8290
|
cPara["LCSC Category"],
|
|
8244
8291
|
cPara["JLCPCB Category"],
|
|
8292
|
+
cPara.package,
|
|
8293
|
+
cPara.pre,
|
|
8245
8294
|
betterEasy.category
|
|
8246
8295
|
].some(categoryValueContainsPushbutton);
|
|
8247
8296
|
};
|