easyeda 0.0.294 → 0.0.295

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,7 @@ var generateTypescriptComponent = ({
11454
11454
  supplierPartNumbers,
11455
11455
  manufacturerPartNumber,
11456
11456
  componentType = "chip",
11457
+ capacitance: capacitance2,
11457
11458
  inductance: inductance2,
11458
11459
  crystalFrequency,
11459
11460
  crystalPinVariant,
@@ -11591,6 +11592,32 @@ ${cadModelLines}
11591
11592
  />
11592
11593
  )
11593
11594
  }
11595
+ `.trim();
11596
+ }
11597
+ if (componentType === "capacitor") {
11598
+ if (!capacitance2) {
11599
+ throw new Error("Capacitance is required for capacitor components");
11600
+ }
11601
+ return `
11602
+ import type { CapacitorProps } from "@tscircuit/props"
11603
+
11604
+ export const ${componentName} = (props: Omit<CapacitorProps, "capacitance">) => {
11605
+ const { name = "C1", ...restProps } = props
11606
+
11607
+ return (
11608
+ <capacitor
11609
+ name={name}
11610
+ capacitance=${JSON.stringify(capacitance2)}
11611
+ supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
11612
+ manufacturerPartNumber="${manufacturerPartNumber}"
11613
+ footprint={${footprintTsx}}
11614
+ ${objUrl || stepUrl ? `cadModel={{
11615
+ ${cadModelLines}
11616
+ }}` : ""}
11617
+ {...restProps}
11618
+ />
11619
+ )
11620
+ }
11594
11621
  `.trim();
11595
11622
  }
11596
11623
  if (componentType === "inductor") {
@@ -11693,6 +11720,21 @@ ${cadModelLines}
11693
11720
  `.trim();
11694
11721
  };
11695
11722
 
11723
+ // lib/websafe/convert-to-typescript-component/is-capacitor-component.ts
11724
+ var capacitancePattern = /^\d+(?:\.\d+)?\s*(?:pF|nF|[uµμ]F|mF|F)$/i;
11725
+ var normalizeCapacitanceValue = (value) => {
11726
+ if (typeof value !== "string") return void 0;
11727
+ const trimmedValue = value.trim();
11728
+ if (!capacitancePattern.test(trimmedValue)) return void 0;
11729
+ return trimmedValue.replace(/\s+/g, "").replace(/[µμ]/g, "u");
11730
+ };
11731
+ var isCapacitorComponent = (betterEasy) => {
11732
+ const componentParameters = betterEasy.dataStr.head.c_para;
11733
+ const prefix = componentParameters.pre;
11734
+ const value = componentParameters.Value;
11735
+ return prefix?.toUpperCase() === "C?" && normalizeCapacitanceValue(value) !== void 0;
11736
+ };
11737
+
11696
11738
  // lib/websafe/convert-to-typescript-component/is-crystal-component.ts
11697
11739
  var frequencyPattern = /^\d+(?:\.\d+)?\s*(?:Hz|kHz|MHz|GHz)$/i;
11698
11740
  var isCrystalComponent = (betterEasy) => {
@@ -12085,6 +12127,7 @@ var getGeneratedComponentType = (betterEasy, pinCount) => {
12085
12127
  if (isDiodeCategoryComponent(betterEasy) && pinCount === 2) return "diode";
12086
12128
  if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
12087
12129
  if (isSwitchCategoryComponent(betterEasy)) return "switch";
12130
+ if (isCapacitorComponent(betterEasy)) return "capacitor";
12088
12131
  if (isInductorComponent(betterEasy)) return "inductor";
12089
12132
  if (isCrystalComponent(betterEasy)) return "crystal";
12090
12133
  if (isMicroUsbConnectorComponent(betterEasy)) return "connector";
@@ -12157,6 +12200,7 @@ var convertBetterEasyToTsx = async ({
12157
12200
  sourcePorts.length
12158
12201
  );
12159
12202
  const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
12203
+ const capacitance2 = componentType === "capacitor" ? normalizeCapacitanceValue(betterEasy.dataStr.head.c_para.Value) : void 0;
12160
12204
  const crystalFrequency = componentType === "crystal" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
12161
12205
  const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
12162
12206
  const isMultiPinDiode = isDiodeCategoryComponent(betterEasy) && sourcePorts.length !== 2;
@@ -12170,6 +12214,7 @@ var convertBetterEasyToTsx = async ({
12170
12214
  circuitJson,
12171
12215
  supplierPartNumbers,
12172
12216
  componentType,
12217
+ capacitance: capacitance2,
12173
12218
  inductance: inductance2,
12174
12219
  crystalFrequency,
12175
12220
  crystalPinVariant,