easyeda 0.0.294 → 0.0.296

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.
@@ -11454,6 +11454,8 @@ var generateTypescriptComponent = ({
11454
11454
  supplierPartNumbers,
11455
11455
  manufacturerPartNumber,
11456
11456
  componentType = "chip",
11457
+ capacitance: capacitance2,
11458
+ resistance: resistance2,
11457
11459
  inductance: inductance2,
11458
11460
  crystalFrequency,
11459
11461
  crystalPinVariant,
@@ -11591,6 +11593,58 @@ ${cadModelLines}
11591
11593
  />
11592
11594
  )
11593
11595
  }
11596
+ `.trim();
11597
+ }
11598
+ if (componentType === "capacitor") {
11599
+ if (!capacitance2) {
11600
+ throw new Error("Capacitance is required for capacitor components");
11601
+ }
11602
+ return `
11603
+ import type { CapacitorProps } from "@tscircuit/props"
11604
+
11605
+ export const ${componentName} = (props: Omit<CapacitorProps, "capacitance">) => {
11606
+ const { name = "C1", ...restProps } = props
11607
+
11608
+ return (
11609
+ <capacitor
11610
+ name={name}
11611
+ capacitance=${JSON.stringify(capacitance2)}
11612
+ supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
11613
+ manufacturerPartNumber="${manufacturerPartNumber}"
11614
+ footprint={${footprintTsx}}
11615
+ ${objUrl || stepUrl ? `cadModel={{
11616
+ ${cadModelLines}
11617
+ }}` : ""}
11618
+ {...restProps}
11619
+ />
11620
+ )
11621
+ }
11622
+ `.trim();
11623
+ }
11624
+ if (componentType === "resistor") {
11625
+ if (!resistance2) {
11626
+ throw new Error("Resistance is required for resistor components");
11627
+ }
11628
+ return `
11629
+ import type { ResistorProps } from "@tscircuit/props"
11630
+
11631
+ export const ${componentName} = (props: Omit<ResistorProps, "resistance">) => {
11632
+ const { name = "R1", ...restProps } = props
11633
+
11634
+ return (
11635
+ <resistor
11636
+ name={name}
11637
+ resistance=${JSON.stringify(resistance2)}
11638
+ supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
11639
+ manufacturerPartNumber="${manufacturerPartNumber}"
11640
+ footprint={${footprintTsx}}
11641
+ ${objUrl || stepUrl ? `cadModel={{
11642
+ ${cadModelLines}
11643
+ }}` : ""}
11644
+ {...restProps}
11645
+ />
11646
+ )
11647
+ }
11594
11648
  `.trim();
11595
11649
  }
11596
11650
  if (componentType === "inductor") {
@@ -11693,6 +11747,21 @@ ${cadModelLines}
11693
11747
  `.trim();
11694
11748
  };
11695
11749
 
11750
+ // lib/websafe/convert-to-typescript-component/is-capacitor-component.ts
11751
+ var capacitancePattern = /^\d+(?:\.\d+)?\s*(?:pF|nF|[uµμ]F|mF|F)$/i;
11752
+ var normalizeCapacitanceValue = (value) => {
11753
+ if (typeof value !== "string") return void 0;
11754
+ const trimmedValue = value.trim();
11755
+ if (!capacitancePattern.test(trimmedValue)) return void 0;
11756
+ return trimmedValue.replace(/\s+/g, "").replace(/[µμ]/g, "u");
11757
+ };
11758
+ var isCapacitorComponent = (betterEasy) => {
11759
+ const componentParameters = betterEasy.dataStr.head.c_para;
11760
+ const prefix = componentParameters.pre;
11761
+ const value = componentParameters.Value;
11762
+ return prefix?.toUpperCase() === "C?" && normalizeCapacitanceValue(value) !== void 0;
11763
+ };
11764
+
11696
11765
  // lib/websafe/convert-to-typescript-component/is-crystal-component.ts
11697
11766
  var frequencyPattern = /^\d+(?:\.\d+)?\s*(?:Hz|kHz|MHz|GHz)$/i;
11698
11767
  var isCrystalComponent = (betterEasy) => {
@@ -11748,6 +11817,43 @@ var isPushbuttonCategoryComponent = (betterEasy) => {
11748
11817
  ].some(categoryValueContainsPushbutton);
11749
11818
  };
11750
11819
 
11820
+ // lib/websafe/convert-to-typescript-component/is-resistor-component.ts
11821
+ var standardSmdResistorPackagePattern = /^R(?:01005|0201|0402|0504|0603|0805|1206|1210|1812|2010|2512)(?:$|[_-])/i;
11822
+ var normalizeExplicitScale = (scale2) => {
11823
+ if (scale2 === "k" || scale2 === "K") return "k";
11824
+ if (scale2 === "m") return "m";
11825
+ if (scale2 === "M") return "M";
11826
+ if (scale2 === "g" || scale2 === "G") return "G";
11827
+ return "";
11828
+ };
11829
+ var normalizeResistorValue = (value) => {
11830
+ if (typeof value !== "string") return void 0;
11831
+ const compactValue = value.trim().replace(/\s+/g, "");
11832
+ const explicitUnitMatch = compactValue.match(
11833
+ /^(\d+(?:\.\d+)?)([mMkKgG]?)(?:Ω|ohms?)$/i
11834
+ );
11835
+ if (explicitUnitMatch) {
11836
+ const [, magnitude, scale2] = explicitUnitMatch;
11837
+ if (Number(magnitude) === 0) return "0ohm";
11838
+ return `${magnitude}${normalizeExplicitScale(scale2)}ohm`;
11839
+ }
11840
+ const resistorCodeMatch = compactValue.match(/^(\d+)([RrKkMm])(\d*)$/);
11841
+ if (resistorCodeMatch) {
11842
+ const [, whole, multiplier, fraction] = resistorCodeMatch;
11843
+ const magnitude = fraction ? `${whole}.${fraction}` : whole;
11844
+ if (Number(magnitude) === 0) return "0ohm";
11845
+ const scale2 = multiplier === "R" || multiplier === "r" ? "" : multiplier === "K" || multiplier === "k" ? "k" : "M";
11846
+ return `${magnitude}${scale2}ohm`;
11847
+ }
11848
+ if (/^0+(?:\.0+)?$/.test(compactValue)) return "0ohm";
11849
+ return void 0;
11850
+ };
11851
+ var isResistorComponent = (betterEasy) => {
11852
+ const componentParameters = betterEasy.dataStr.head.c_para;
11853
+ const packageName = componentParameters.package;
11854
+ return componentParameters.pre?.toUpperCase() === "R?" && typeof packageName === "string" && standardSmdResistorPackagePattern.test(packageName.trim()) && normalizeResistorValue(componentParameters.Value) !== void 0;
11855
+ };
11856
+
11751
11857
  // lib/websafe/convert-to-typescript-component/category-value-contains-switch.ts
11752
11858
  var categoryValueContainsSwitch = (value) => {
11753
11859
  if (typeof value === "string") {
@@ -12085,6 +12191,8 @@ var getGeneratedComponentType = (betterEasy, pinCount) => {
12085
12191
  if (isDiodeCategoryComponent(betterEasy) && pinCount === 2) return "diode";
12086
12192
  if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
12087
12193
  if (isSwitchCategoryComponent(betterEasy)) return "switch";
12194
+ if (isCapacitorComponent(betterEasy)) return "capacitor";
12195
+ if (isResistorComponent(betterEasy) && pinCount === 2) return "resistor";
12088
12196
  if (isInductorComponent(betterEasy)) return "inductor";
12089
12197
  if (isCrystalComponent(betterEasy)) return "crystal";
12090
12198
  if (isMicroUsbConnectorComponent(betterEasy)) return "connector";
@@ -12157,6 +12265,8 @@ var convertBetterEasyToTsx = async ({
12157
12265
  sourcePorts.length
12158
12266
  );
12159
12267
  const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
12268
+ const capacitance2 = componentType === "capacitor" ? normalizeCapacitanceValue(betterEasy.dataStr.head.c_para.Value) : void 0;
12269
+ const resistance2 = componentType === "resistor" ? normalizeResistorValue(betterEasy.dataStr.head.c_para.Value) : void 0;
12160
12270
  const crystalFrequency = componentType === "crystal" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
12161
12271
  const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
12162
12272
  const isMultiPinDiode = isDiodeCategoryComponent(betterEasy) && sourcePorts.length !== 2;
@@ -12170,6 +12280,8 @@ var convertBetterEasyToTsx = async ({
12170
12280
  circuitJson,
12171
12281
  supplierPartNumbers,
12172
12282
  componentType,
12283
+ capacitance: capacitance2,
12284
+ resistance: resistance2,
12173
12285
  inductance: inductance2,
12174
12286
  crystalFrequency,
12175
12287
  crystalPinVariant,