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/browser/index.js
CHANGED
|
@@ -11572,6 +11572,37 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
|
11572
11572
|
`.trim();
|
|
11573
11573
|
};
|
|
11574
11574
|
|
|
11575
|
+
// lib/websafe/convert-to-typescript-component/infer-pin-attributes.ts
|
|
11576
|
+
var POWER_PIN_LABEL = /^(?:VCC|VDD|VIN|VDDA)\d*$/;
|
|
11577
|
+
var GROUND_PIN_LABEL = /^(?:GND|VSS|PGND|AGND)\d*$/;
|
|
11578
|
+
var NO_CONNECT_PIN_LABEL = /^NC\d*$/;
|
|
11579
|
+
var getAttributeKind = (label) => {
|
|
11580
|
+
const normalizedLabel = label.trim().toUpperCase();
|
|
11581
|
+
if (POWER_PIN_LABEL.test(normalizedLabel)) return "power";
|
|
11582
|
+
if (GROUND_PIN_LABEL.test(normalizedLabel)) return "ground";
|
|
11583
|
+
if (NO_CONNECT_PIN_LABEL.test(normalizedLabel)) return "no-connect";
|
|
11584
|
+
return void 0;
|
|
11585
|
+
};
|
|
11586
|
+
var inferPinAttributes = (pinLabels) => {
|
|
11587
|
+
const pinAttributes = {};
|
|
11588
|
+
for (const [pinName, labels] of Object.entries(pinLabels)) {
|
|
11589
|
+
const labelList = typeof labels === "string" ? [labels] : labels;
|
|
11590
|
+
const inferredKinds = labelList.map(getAttributeKind);
|
|
11591
|
+
if (inferredKinds.some((kind) => kind === void 0)) continue;
|
|
11592
|
+
const attributeKinds = new Set(inferredKinds);
|
|
11593
|
+
if (attributeKinds.size !== 1) continue;
|
|
11594
|
+
const [attributeKind] = attributeKinds;
|
|
11595
|
+
if (attributeKind === "power") {
|
|
11596
|
+
pinAttributes[pinName] = { requiresPower: true };
|
|
11597
|
+
} else if (attributeKind === "ground") {
|
|
11598
|
+
pinAttributes[pinName] = { requiresGround: true };
|
|
11599
|
+
} else if (attributeKind === "no-connect") {
|
|
11600
|
+
pinAttributes[pinName] = { doNotConnect: true };
|
|
11601
|
+
}
|
|
11602
|
+
}
|
|
11603
|
+
return pinAttributes;
|
|
11604
|
+
};
|
|
11605
|
+
|
|
11575
11606
|
// lib/websafe/convert-to-typescript-component/generate-typescript-component.ts
|
|
11576
11607
|
var generateTypescriptComponent = ({
|
|
11577
11608
|
pinLabels,
|
|
@@ -11607,6 +11638,20 @@ var generateTypescriptComponent = ({
|
|
|
11607
11638
|
})
|
|
11608
11639
|
);
|
|
11609
11640
|
const pinLabelsString = Object.entries(simplifiedPinLabels).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
|
|
11641
|
+
const inferredPinAttributes = componentType === "chip" ? inferPinAttributes(simplifiedPinLabels) : {};
|
|
11642
|
+
const pinAttributesString = Object.entries(inferredPinAttributes).map(([pin, attributes]) => {
|
|
11643
|
+
const attributesString = Object.entries(attributes).map(
|
|
11644
|
+
([attributeName, value]) => `${attributeName}: ${JSON.stringify(value)}`
|
|
11645
|
+
).join(", ");
|
|
11646
|
+
return ` ${pin}: {${attributesString}}`;
|
|
11647
|
+
}).join(",\n");
|
|
11648
|
+
const pinAttributesBlock = pinAttributesString ? `const pinAttributes = {
|
|
11649
|
+
${pinAttributesString}
|
|
11650
|
+
} as const
|
|
11651
|
+
|
|
11652
|
+
` : "";
|
|
11653
|
+
const pinAttributesProp = pinAttributesString ? ` pinAttributes={pinAttributes}
|
|
11654
|
+
` : "";
|
|
11610
11655
|
const polarizedPinLabelsString = Object.entries(polarizedPinLabels ?? {}).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
|
|
11611
11656
|
const polarizedPinLabelsBlock = polarizedPinLabels ? `const pinLabels = {
|
|
11612
11657
|
${polarizedPinLabelsString}
|
|
@@ -11858,11 +11903,11 @@ const pinLabels = {
|
|
|
11858
11903
|
${pinLabelsString}
|
|
11859
11904
|
} as const
|
|
11860
11905
|
|
|
11861
|
-
export const ${componentName} = (props: ChipProps<typeof pinLabels>) => {
|
|
11906
|
+
${pinAttributesBlock}export const ${componentName} = (props: ChipProps<typeof pinLabels>) => {
|
|
11862
11907
|
return (
|
|
11863
11908
|
<chip
|
|
11864
11909
|
pinLabels={pinLabels}
|
|
11865
|
-
${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11910
|
+
${pinAttributesProp}${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11866
11911
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
11867
11912
|
footprint={${footprintTsx}}
|
|
11868
11913
|
${objUrl || stepUrl ? `cadModel={{
|
|
@@ -11921,7 +11966,7 @@ var categoryValueContainsPushbutton = (value) => {
|
|
|
11921
11966
|
if (/analog\s+switch/.test(normalized) || /multiplex/.test(normalized) || /switching\s+diodes?/.test(normalized) || /\bics?\b/.test(normalized)) {
|
|
11922
11967
|
return false;
|
|
11923
11968
|
}
|
|
11924
|
-
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);
|
|
11969
|
+
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);
|
|
11925
11970
|
}
|
|
11926
11971
|
if (Array.isArray(value)) {
|
|
11927
11972
|
return value.some(categoryValueContainsPushbutton);
|
|
@@ -11937,10 +11982,14 @@ var isPushbuttonCategoryComponent = (betterEasy) => {
|
|
|
11937
11982
|
const cPara = betterEasy.dataStr.head.c_para;
|
|
11938
11983
|
return [
|
|
11939
11984
|
betterEasy.tags,
|
|
11985
|
+
betterEasy.title,
|
|
11986
|
+
betterEasy.description,
|
|
11940
11987
|
cPara.category,
|
|
11941
11988
|
cPara.Category,
|
|
11942
11989
|
cPara["LCSC Category"],
|
|
11943
11990
|
cPara["JLCPCB Category"],
|
|
11991
|
+
cPara.package,
|
|
11992
|
+
cPara.pre,
|
|
11944
11993
|
betterEasy.category
|
|
11945
11994
|
].some(categoryValueContainsPushbutton);
|
|
11946
11995
|
};
|