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.
@@ -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={{