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.
package/dist/index.js CHANGED
@@ -7755,6 +7755,7 @@ var generateTypescriptComponent = ({
7755
7755
  supplierPartNumbers,
7756
7756
  manufacturerPartNumber,
7757
7757
  componentType = "chip",
7758
+ capacitance: capacitance2,
7758
7759
  inductance: inductance2,
7759
7760
  crystalFrequency,
7760
7761
  crystalPinVariant,
@@ -7892,6 +7893,32 @@ ${cadModelLines}
7892
7893
  />
7893
7894
  )
7894
7895
  }
7896
+ `.trim();
7897
+ }
7898
+ if (componentType === "capacitor") {
7899
+ if (!capacitance2) {
7900
+ throw new Error("Capacitance is required for capacitor components");
7901
+ }
7902
+ return `
7903
+ import type { CapacitorProps } from "@tscircuit/props"
7904
+
7905
+ export const ${componentName} = (props: Omit<CapacitorProps, "capacitance">) => {
7906
+ const { name = "C1", ...restProps } = props
7907
+
7908
+ return (
7909
+ <capacitor
7910
+ name={name}
7911
+ capacitance=${JSON.stringify(capacitance2)}
7912
+ supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
7913
+ manufacturerPartNumber="${manufacturerPartNumber}"
7914
+ footprint={${footprintTsx}}
7915
+ ${objUrl || stepUrl ? `cadModel={{
7916
+ ${cadModelLines}
7917
+ }}` : ""}
7918
+ {...restProps}
7919
+ />
7920
+ )
7921
+ }
7895
7922
  `.trim();
7896
7923
  }
7897
7924
  if (componentType === "inductor") {
@@ -7994,6 +8021,21 @@ ${cadModelLines}
7994
8021
  `.trim();
7995
8022
  };
7996
8023
 
8024
+ // lib/websafe/convert-to-typescript-component/is-capacitor-component.ts
8025
+ var capacitancePattern = /^\d+(?:\.\d+)?\s*(?:pF|nF|[uµμ]F|mF|F)$/i;
8026
+ var normalizeCapacitanceValue = (value) => {
8027
+ if (typeof value !== "string") return void 0;
8028
+ const trimmedValue = value.trim();
8029
+ if (!capacitancePattern.test(trimmedValue)) return void 0;
8030
+ return trimmedValue.replace(/\s+/g, "").replace(/[µμ]/g, "u");
8031
+ };
8032
+ var isCapacitorComponent = (betterEasy) => {
8033
+ const componentParameters = betterEasy.dataStr.head.c_para;
8034
+ const prefix = componentParameters.pre;
8035
+ const value = componentParameters.Value;
8036
+ return prefix?.toUpperCase() === "C?" && normalizeCapacitanceValue(value) !== void 0;
8037
+ };
8038
+
7997
8039
  // lib/websafe/convert-to-typescript-component/is-crystal-component.ts
7998
8040
  var frequencyPattern = /^\d+(?:\.\d+)?\s*(?:Hz|kHz|MHz|GHz)$/i;
7999
8041
  var isCrystalComponent = (betterEasy) => {
@@ -8386,6 +8428,7 @@ var getGeneratedComponentType = (betterEasy, pinCount) => {
8386
8428
  if (isDiodeCategoryComponent(betterEasy) && pinCount === 2) return "diode";
8387
8429
  if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
8388
8430
  if (isSwitchCategoryComponent(betterEasy)) return "switch";
8431
+ if (isCapacitorComponent(betterEasy)) return "capacitor";
8389
8432
  if (isInductorComponent(betterEasy)) return "inductor";
8390
8433
  if (isCrystalComponent(betterEasy)) return "crystal";
8391
8434
  if (isMicroUsbConnectorComponent(betterEasy)) return "connector";
@@ -8458,6 +8501,7 @@ var convertBetterEasyToTsx = async ({
8458
8501
  sourcePorts.length
8459
8502
  );
8460
8503
  const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
8504
+ const capacitance2 = componentType === "capacitor" ? normalizeCapacitanceValue(betterEasy.dataStr.head.c_para.Value) : void 0;
8461
8505
  const crystalFrequency = componentType === "crystal" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
8462
8506
  const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
8463
8507
  const isMultiPinDiode = isDiodeCategoryComponent(betterEasy) && sourcePorts.length !== 2;
@@ -8471,6 +8515,7 @@ var convertBetterEasyToTsx = async ({
8471
8515
  circuitJson,
8472
8516
  supplierPartNumbers,
8473
8517
  componentType,
8518
+ capacitance: capacitance2,
8474
8519
  inductance: inductance2,
8475
8520
  crystalFrequency,
8476
8521
  crystalPinVariant,