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/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.312",
3531
+ version: "0.0.314",
3532
3532
  files: [
3533
3533
  "dist"
3534
3534
  ],
@@ -11280,6 +11280,37 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
11280
11280
  `.trim();
11281
11281
  };
11282
11282
 
11283
+ // lib/websafe/convert-to-typescript-component/infer-pin-attributes.ts
11284
+ var POWER_PIN_LABEL = /^(?:VCC|VDD|VIN|VDDA)\d*$/;
11285
+ var GROUND_PIN_LABEL = /^(?:GND|VSS|PGND|AGND)\d*$/;
11286
+ var NO_CONNECT_PIN_LABEL = /^NC\d*$/;
11287
+ var getAttributeKind = (label) => {
11288
+ const normalizedLabel = label.trim().toUpperCase();
11289
+ if (POWER_PIN_LABEL.test(normalizedLabel)) return "power";
11290
+ if (GROUND_PIN_LABEL.test(normalizedLabel)) return "ground";
11291
+ if (NO_CONNECT_PIN_LABEL.test(normalizedLabel)) return "no-connect";
11292
+ return void 0;
11293
+ };
11294
+ var inferPinAttributes = (pinLabels) => {
11295
+ const pinAttributes = {};
11296
+ for (const [pinName, labels] of Object.entries(pinLabels)) {
11297
+ const labelList = typeof labels === "string" ? [labels] : labels;
11298
+ const inferredKinds = labelList.map(getAttributeKind);
11299
+ if (inferredKinds.some((kind) => kind === void 0)) continue;
11300
+ const attributeKinds = new Set(inferredKinds);
11301
+ if (attributeKinds.size !== 1) continue;
11302
+ const [attributeKind] = attributeKinds;
11303
+ if (attributeKind === "power") {
11304
+ pinAttributes[pinName] = { requiresPower: true };
11305
+ } else if (attributeKind === "ground") {
11306
+ pinAttributes[pinName] = { requiresGround: true };
11307
+ } else if (attributeKind === "no-connect") {
11308
+ pinAttributes[pinName] = { doNotConnect: true };
11309
+ }
11310
+ }
11311
+ return pinAttributes;
11312
+ };
11313
+
11283
11314
  // lib/websafe/convert-to-typescript-component/generate-typescript-component.ts
11284
11315
  var generateTypescriptComponent = ({
11285
11316
  pinLabels,
@@ -11315,6 +11346,20 @@ var generateTypescriptComponent = ({
11315
11346
  })
11316
11347
  );
11317
11348
  const pinLabelsString = Object.entries(simplifiedPinLabels).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
11349
+ const inferredPinAttributes = componentType === "chip" ? inferPinAttributes(simplifiedPinLabels) : {};
11350
+ const pinAttributesString = Object.entries(inferredPinAttributes).map(([pin, attributes]) => {
11351
+ const attributesString = Object.entries(attributes).map(
11352
+ ([attributeName, value]) => `${attributeName}: ${JSON.stringify(value)}`
11353
+ ).join(", ");
11354
+ return ` ${pin}: {${attributesString}}`;
11355
+ }).join(",\n");
11356
+ const pinAttributesBlock = pinAttributesString ? `const pinAttributes = {
11357
+ ${pinAttributesString}
11358
+ } as const
11359
+
11360
+ ` : "";
11361
+ const pinAttributesProp = pinAttributesString ? ` pinAttributes={pinAttributes}
11362
+ ` : "";
11318
11363
  const polarizedPinLabelsString = Object.entries(polarizedPinLabels ?? {}).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
11319
11364
  const polarizedPinLabelsBlock = polarizedPinLabels ? `const pinLabels = {
11320
11365
  ${polarizedPinLabelsString}
@@ -11566,11 +11611,11 @@ const pinLabels = {
11566
11611
  ${pinLabelsString}
11567
11612
  } as const
11568
11613
 
11569
- export const ${componentName} = (props: ChipProps<typeof pinLabels>) => {
11614
+ ${pinAttributesBlock}export const ${componentName} = (props: ChipProps<typeof pinLabels>) => {
11570
11615
  return (
11571
11616
  <chip
11572
11617
  pinLabels={pinLabels}
11573
- ${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
11618
+ ${pinAttributesProp}${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
11574
11619
  manufacturerPartNumber="${manufacturerPartNumber}"
11575
11620
  footprint={${footprintTsx}}
11576
11621
  ${objUrl || stepUrl ? `cadModel={{
@@ -11629,7 +11674,7 @@ var categoryValueContainsPushbutton = (value) => {
11629
11674
  if (/analog\s+switch/.test(normalized) || /multiplex/.test(normalized) || /switching\s+diodes?/.test(normalized) || /\bics?\b/.test(normalized)) {
11630
11675
  return false;
11631
11676
  }
11632
- 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);
11677
+ 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);
11633
11678
  }
11634
11679
  if (Array.isArray(value)) {
11635
11680
  return value.some(categoryValueContainsPushbutton);
@@ -11645,10 +11690,14 @@ var isPushbuttonCategoryComponent = (betterEasy) => {
11645
11690
  const cPara = betterEasy.dataStr.head.c_para;
11646
11691
  return [
11647
11692
  betterEasy.tags,
11693
+ betterEasy.title,
11694
+ betterEasy.description,
11648
11695
  cPara.category,
11649
11696
  cPara.Category,
11650
11697
  cPara["LCSC Category"],
11651
11698
  cPara["JLCPCB Category"],
11699
+ cPara.package,
11700
+ cPara.pre,
11652
11701
  betterEasy.category
11653
11702
  ].some(categoryValueContainsPushbutton);
11654
11703
  };