easyeda 0.0.289 → 0.0.291

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,9 @@ var generateTypescriptComponent = ({
11454
11454
  supplierPartNumbers,
11455
11455
  manufacturerPartNumber,
11456
11456
  componentType = "chip",
11457
+ inductance: inductance2,
11458
+ crystalFrequency,
11459
+ crystalPinVariant,
11457
11460
  symbolTsx
11458
11461
  }) => {
11459
11462
  const safePinLabels = pinLabels ?? {};
@@ -11588,6 +11591,58 @@ ${cadModelLines}
11588
11591
  />
11589
11592
  )
11590
11593
  }
11594
+ `.trim();
11595
+ }
11596
+ if (componentType === "inductor") {
11597
+ if (!inductance2) {
11598
+ throw new Error("Inductance is required for inductor components");
11599
+ }
11600
+ return `
11601
+ import type { InductorProps } from "@tscircuit/props"
11602
+
11603
+ export const ${componentName} = (props: Omit<InductorProps, "inductance">) => {
11604
+ return (
11605
+ <inductor
11606
+ inductance=${JSON.stringify(inductance2)}
11607
+ supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
11608
+ manufacturerPartNumber="${manufacturerPartNumber}"
11609
+ footprint={${footprintTsx}}
11610
+ ${objUrl || stepUrl ? `cadModel={{
11611
+ ${cadModelLines}
11612
+ }}` : ""}
11613
+ {...props}
11614
+ />
11615
+ )
11616
+ }
11617
+ `.trim();
11618
+ }
11619
+ if (componentType === "crystal") {
11620
+ if (!crystalFrequency || !crystalPinVariant) {
11621
+ throw new Error("Crystal frequency and pin variant are required");
11622
+ }
11623
+ return `
11624
+ import type { CrystalProps } from "@tscircuit/props"
11625
+
11626
+ type ImportedCrystalProps = Omit<CrystalProps, "frequency" | "pinVariant">
11627
+
11628
+ export const ${componentName} = (props: ImportedCrystalProps) => {
11629
+ const { name = "X1", ...restProps } = props
11630
+
11631
+ return (
11632
+ <crystal
11633
+ name={name}
11634
+ frequency=${JSON.stringify(crystalFrequency)}
11635
+ pinVariant=${JSON.stringify(crystalPinVariant)}
11636
+ supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
11637
+ manufacturerPartNumber="${manufacturerPartNumber}"
11638
+ footprint={${footprintTsx}}
11639
+ ${objUrl || stepUrl ? `cadModel={{
11640
+ ${cadModelLines}
11641
+ }}` : ""}
11642
+ {...restProps}
11643
+ />
11644
+ )
11645
+ }
11591
11646
  `.trim();
11592
11647
  }
11593
11648
  return `
@@ -11614,6 +11669,24 @@ ${cadModelLines}
11614
11669
  `.trim();
11615
11670
  };
11616
11671
 
11672
+ // lib/websafe/convert-to-typescript-component/is-crystal-component.ts
11673
+ var frequencyPattern = /^\d+(?:\.\d+)?\s*(?:Hz|kHz|MHz|GHz)$/i;
11674
+ var isCrystalComponent = (betterEasy) => {
11675
+ const componentParameters = betterEasy.dataStr.head.c_para;
11676
+ const packageName = componentParameters.package;
11677
+ const value = componentParameters.Value;
11678
+ return componentParameters.pre === "X?" && packageName?.toUpperCase().startsWith("CRYSTAL-") === true && typeof value === "string" && frequencyPattern.test(value.trim());
11679
+ };
11680
+
11681
+ // lib/websafe/convert-to-typescript-component/is-inductor-component.ts
11682
+ var inductancePattern = /^\d+(?:\.\d+)?\s*(?:pH|nH|uH|µH|mH|H)$/i;
11683
+ var isInductorComponent = (betterEasy) => {
11684
+ const componentParameters = betterEasy.dataStr.head.c_para;
11685
+ const packageName = componentParameters.package;
11686
+ const value = componentParameters.Value;
11687
+ return packageName?.toUpperCase().startsWith("IND-") === true && typeof value === "string" && inductancePattern.test(value.trim());
11688
+ };
11689
+
11617
11690
  // lib/websafe/convert-to-typescript-component/category-value-contains-pushbutton.ts
11618
11691
  var categoryValueContainsPushbutton = (value) => {
11619
11692
  if (typeof value === "string") {
@@ -11982,6 +12055,8 @@ var getGeneratedComponentType = (betterEasy) => {
11982
12055
  if (isDiodeCategoryComponent(betterEasy)) return "diode";
11983
12056
  if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
11984
12057
  if (isSwitchCategoryComponent(betterEasy)) return "switch";
12058
+ if (isInductorComponent(betterEasy)) return "inductor";
12059
+ if (isCrystalComponent(betterEasy)) return "crystal";
11985
12060
  return "chip";
11986
12061
  };
11987
12062
  var convertRawEasyToTsx = async ({ rawEasy }) => {
@@ -12047,6 +12122,9 @@ var convertBetterEasyToTsx = async ({
12047
12122
  jlcpcb: [betterEasy.lcsc.number]
12048
12123
  };
12049
12124
  const componentType = getGeneratedComponentType(betterEasy);
12125
+ const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
12126
+ const crystalFrequency = componentType === "crystal" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
12127
+ const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
12050
12128
  const symbolTsx = componentType === "chip" && hasNonBoxSchematicSymbol(betterEasy) ? generateSymbolTsx(betterEasy, circuitJson) : void 0;
12051
12129
  return generateTypescriptComponent({
12052
12130
  componentName,
@@ -12057,6 +12135,9 @@ var convertBetterEasyToTsx = async ({
12057
12135
  circuitJson,
12058
12136
  supplierPartNumbers,
12059
12137
  componentType,
12138
+ inductance: inductance2,
12139
+ crystalFrequency,
12140
+ crystalPinVariant,
12060
12141
  symbolTsx
12061
12142
  });
12062
12143
  };