easyeda 0.0.295 → 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.
@@ -11455,6 +11455,7 @@ var generateTypescriptComponent = ({
11455
11455
  manufacturerPartNumber,
11456
11456
  componentType = "chip",
11457
11457
  capacitance: capacitance2,
11458
+ resistance: resistance2,
11458
11459
  inductance: inductance2,
11459
11460
  crystalFrequency,
11460
11461
  crystalPinVariant,
@@ -11618,6 +11619,32 @@ ${cadModelLines}
11618
11619
  />
11619
11620
  )
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
+ }
11621
11648
  `.trim();
11622
11649
  }
11623
11650
  if (componentType === "inductor") {
@@ -11790,6 +11817,43 @@ var isPushbuttonCategoryComponent = (betterEasy) => {
11790
11817
  ].some(categoryValueContainsPushbutton);
11791
11818
  };
11792
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
+
11793
11857
  // lib/websafe/convert-to-typescript-component/category-value-contains-switch.ts
11794
11858
  var categoryValueContainsSwitch = (value) => {
11795
11859
  if (typeof value === "string") {
@@ -12128,6 +12192,7 @@ var getGeneratedComponentType = (betterEasy, pinCount) => {
12128
12192
  if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
12129
12193
  if (isSwitchCategoryComponent(betterEasy)) return "switch";
12130
12194
  if (isCapacitorComponent(betterEasy)) return "capacitor";
12195
+ if (isResistorComponent(betterEasy) && pinCount === 2) return "resistor";
12131
12196
  if (isInductorComponent(betterEasy)) return "inductor";
12132
12197
  if (isCrystalComponent(betterEasy)) return "crystal";
12133
12198
  if (isMicroUsbConnectorComponent(betterEasy)) return "connector";
@@ -12201,6 +12266,7 @@ var convertBetterEasyToTsx = async ({
12201
12266
  );
12202
12267
  const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
12203
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;
12204
12270
  const crystalFrequency = componentType === "crystal" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
12205
12271
  const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
12206
12272
  const isMultiPinDiode = isDiodeCategoryComponent(betterEasy) && sourcePorts.length !== 2;
@@ -12215,6 +12281,7 @@ var convertBetterEasyToTsx = async ({
12215
12281
  supplierPartNumbers,
12216
12282
  componentType,
12217
12283
  capacitance: capacitance2,
12284
+ resistance: resistance2,
12218
12285
  inductance: inductance2,
12219
12286
  crystalFrequency,
12220
12287
  crystalPinVariant,