easyeda 0.0.314 → 0.0.316

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.
@@ -10130,14 +10130,32 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
10130
10130
  if (pin) labels.push(normalizeSymbolName(pin.label));
10131
10131
  return labels;
10132
10132
  });
10133
- const normalizedPinLabels = normalizePinLabels(pinLabelSets);
10133
+ const padNumberKeys = pads.map((pad, index) => {
10134
+ const padNumber = String(pad.number ?? "").trim();
10135
+ return padNumber ? `number:${padNumber}` : `index:${index}`;
10136
+ });
10137
+ const uniquePinLabelSets = [];
10138
+ const uniquePinIndexByKey = /* @__PURE__ */ new Map();
10139
+ const uniquePinIndexByPad = padNumberKeys.map((key, padIndex) => {
10140
+ const existingIndex = uniquePinIndexByKey.get(key);
10141
+ if (existingIndex !== void 0) return existingIndex;
10142
+ const uniquePinIndex = uniquePinLabelSets.length;
10143
+ uniquePinIndexByKey.set(key, uniquePinIndex);
10144
+ uniquePinLabelSets.push(pinLabelSets[padIndex]);
10145
+ return uniquePinIndex;
10146
+ });
10147
+ const normalizedUniquePinLabels = normalizePinLabels(uniquePinLabelSets);
10148
+ const normalizedPinLabels = uniquePinIndexByPad.map(
10149
+ (uniquePinIndex) => normalizedUniquePinLabels[uniquePinIndex]
10150
+ );
10134
10151
  const normalizedPinLabelsByPin = Object.fromEntries(
10135
- normalizedPinLabels.map((labels) => {
10152
+ normalizedUniquePinLabels.map((labels) => {
10136
10153
  const pin = labels.find((label) => /^pin\d+$/i.test(label));
10137
10154
  return [pin, labels.filter((label) => label !== pin)];
10138
10155
  })
10139
10156
  );
10140
10157
  const polarizedPinMetadata = pads.length === 2 && (isDiodeCategoryComponent(easyEdaJson) || isLedCategoryComponent(easyEdaJson)) ? getPolarizedPinMetadata(normalizedPinLabelsByPin) : void 0;
10158
+ const emittedSourcePinIndexes = /* @__PURE__ */ new Set();
10141
10159
  pads.forEach((pad, index) => {
10142
10160
  const portHints = normalizedPinLabels[index];
10143
10161
  const pinNumber = Number.parseInt(
@@ -10145,14 +10163,18 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
10145
10163
  );
10146
10164
  const canonicalPinName = `pin${pinNumber}`;
10147
10165
  const pcbPortHints = polarizedPinMetadata?.portHintsMap[canonicalPinName] ?? [canonicalPinName];
10148
- circuitElements.push({
10149
- type: "source_port",
10150
- source_port_id: `source_port_${index + 1}`,
10151
- source_component_id: "source_component_1",
10152
- name: `pin${pinNumber}`,
10153
- pin_number: pinNumber,
10154
- port_hints: portHints.filter((hint) => hint !== `pin${pinNumber}`)
10155
- });
10166
+ const uniquePinIndex = uniquePinIndexByPad[index];
10167
+ if (!emittedSourcePinIndexes.has(uniquePinIndex)) {
10168
+ emittedSourcePinIndexes.add(uniquePinIndex);
10169
+ circuitElements.push({
10170
+ type: "source_port",
10171
+ source_port_id: `source_port_${index + 1}`,
10172
+ source_component_id: "source_component_1",
10173
+ name: `pin${pinNumber}`,
10174
+ pin_number: pinNumber,
10175
+ port_hints: portHints.filter((hint) => hint !== `pin${pinNumber}`)
10176
+ });
10177
+ }
10156
10178
  if (pad.holeRadius !== void 0 && mil2mm(pad.holeRadius) !== 0) {
10157
10179
  const platedHoleId = pad.shape === "RECT" && pad.rotation !== void 0 ? `pcb_plated_hole_${index + 1}_rot${pad.rotation}` : `pcb_plated_hole_${index + 1}`;
10158
10180
  const commonPlatedHoleProps = {
@@ -11572,6 +11594,37 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
11572
11594
  `.trim();
11573
11595
  };
11574
11596
 
11597
+ // lib/websafe/convert-to-typescript-component/infer-pin-attributes.ts
11598
+ var POWER_PIN_LABEL = /^(?:VCC|VDD|VIN|VDDA)\d*$/;
11599
+ var GROUND_PIN_LABEL = /^(?:GND|VSS|PGND|AGND)\d*$/;
11600
+ var NO_CONNECT_PIN_LABEL = /^NC\d*$/;
11601
+ var getAttributeKind = (label) => {
11602
+ const normalizedLabel = label.trim().toUpperCase();
11603
+ if (POWER_PIN_LABEL.test(normalizedLabel)) return "power";
11604
+ if (GROUND_PIN_LABEL.test(normalizedLabel)) return "ground";
11605
+ if (NO_CONNECT_PIN_LABEL.test(normalizedLabel)) return "no-connect";
11606
+ return void 0;
11607
+ };
11608
+ var inferPinAttributes = (pinLabels) => {
11609
+ const pinAttributes = {};
11610
+ for (const [pinName, labels] of Object.entries(pinLabels)) {
11611
+ const labelList = typeof labels === "string" ? [labels] : labels;
11612
+ const inferredKinds = labelList.map(getAttributeKind);
11613
+ if (inferredKinds.some((kind) => kind === void 0)) continue;
11614
+ const attributeKinds = new Set(inferredKinds);
11615
+ if (attributeKinds.size !== 1) continue;
11616
+ const [attributeKind] = attributeKinds;
11617
+ if (attributeKind === "power") {
11618
+ pinAttributes[pinName] = { requiresPower: true };
11619
+ } else if (attributeKind === "ground") {
11620
+ pinAttributes[pinName] = { requiresGround: true };
11621
+ } else if (attributeKind === "no-connect") {
11622
+ pinAttributes[pinName] = { doNotConnect: true };
11623
+ }
11624
+ }
11625
+ return pinAttributes;
11626
+ };
11627
+
11575
11628
  // lib/websafe/convert-to-typescript-component/generate-typescript-component.ts
11576
11629
  var generateTypescriptComponent = ({
11577
11630
  pinLabels,
@@ -11607,6 +11660,20 @@ var generateTypescriptComponent = ({
11607
11660
  })
11608
11661
  );
11609
11662
  const pinLabelsString = Object.entries(simplifiedPinLabels).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
11663
+ const inferredPinAttributes = componentType === "chip" ? inferPinAttributes(simplifiedPinLabels) : {};
11664
+ const pinAttributesString = Object.entries(inferredPinAttributes).map(([pin, attributes]) => {
11665
+ const attributesString = Object.entries(attributes).map(
11666
+ ([attributeName, value]) => `${attributeName}: ${JSON.stringify(value)}`
11667
+ ).join(", ");
11668
+ return ` ${pin}: {${attributesString}}`;
11669
+ }).join(",\n");
11670
+ const pinAttributesBlock = pinAttributesString ? `const pinAttributes = {
11671
+ ${pinAttributesString}
11672
+ } as const
11673
+
11674
+ ` : "";
11675
+ const pinAttributesProp = pinAttributesString ? ` pinAttributes={pinAttributes}
11676
+ ` : "";
11610
11677
  const polarizedPinLabelsString = Object.entries(polarizedPinLabels ?? {}).map(([pin, labels]) => ` ${pin}: ${JSON.stringify(labels)}`).join(",\n");
11611
11678
  const polarizedPinLabelsBlock = polarizedPinLabels ? `const pinLabels = {
11612
11679
  ${polarizedPinLabelsString}
@@ -11858,11 +11925,11 @@ const pinLabels = {
11858
11925
  ${pinLabelsString}
11859
11926
  } as const
11860
11927
 
11861
- export const ${componentName} = (props: ChipProps<typeof pinLabels>) => {
11928
+ ${pinAttributesBlock}export const ${componentName} = (props: ChipProps<typeof pinLabels>) => {
11862
11929
  return (
11863
11930
  <chip
11864
11931
  pinLabels={pinLabels}
11865
- ${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
11932
+ ${pinAttributesProp}${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
11866
11933
  manufacturerPartNumber="${manufacturerPartNumber}"
11867
11934
  footprint={${footprintTsx}}
11868
11935
  ${objUrl || stepUrl ? `cadModel={{