easyeda 0.0.293 → 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/main.cjs CHANGED
@@ -3528,7 +3528,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
3528
3528
  var package_default = {
3529
3529
  name: "easyeda",
3530
3530
  type: "module",
3531
- version: "0.0.292",
3531
+ version: "0.0.294",
3532
3532
  files: [
3533
3533
  "dist"
3534
3534
  ],
@@ -11162,6 +11162,7 @@ var generateTypescriptComponent = ({
11162
11162
  supplierPartNumbers,
11163
11163
  manufacturerPartNumber,
11164
11164
  componentType = "chip",
11165
+ capacitance: capacitance2,
11165
11166
  inductance: inductance2,
11166
11167
  crystalFrequency,
11167
11168
  crystalPinVariant,
@@ -11299,6 +11300,32 @@ ${cadModelLines}
11299
11300
  />
11300
11301
  )
11301
11302
  }
11303
+ `.trim();
11304
+ }
11305
+ if (componentType === "capacitor") {
11306
+ if (!capacitance2) {
11307
+ throw new Error("Capacitance is required for capacitor components");
11308
+ }
11309
+ return `
11310
+ import type { CapacitorProps } from "@tscircuit/props"
11311
+
11312
+ export const ${componentName} = (props: Omit<CapacitorProps, "capacitance">) => {
11313
+ const { name = "C1", ...restProps } = props
11314
+
11315
+ return (
11316
+ <capacitor
11317
+ name={name}
11318
+ capacitance=${JSON.stringify(capacitance2)}
11319
+ supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
11320
+ manufacturerPartNumber="${manufacturerPartNumber}"
11321
+ footprint={${footprintTsx}}
11322
+ ${objUrl || stepUrl ? `cadModel={{
11323
+ ${cadModelLines}
11324
+ }}` : ""}
11325
+ {...restProps}
11326
+ />
11327
+ )
11328
+ }
11302
11329
  `.trim();
11303
11330
  }
11304
11331
  if (componentType === "inductor") {
@@ -11401,6 +11428,21 @@ ${cadModelLines}
11401
11428
  `.trim();
11402
11429
  };
11403
11430
 
11431
+ // lib/websafe/convert-to-typescript-component/is-capacitor-component.ts
11432
+ var capacitancePattern = /^\d+(?:\.\d+)?\s*(?:pF|nF|[uµμ]F|mF|F)$/i;
11433
+ var normalizeCapacitanceValue = (value) => {
11434
+ if (typeof value !== "string") return void 0;
11435
+ const trimmedValue = value.trim();
11436
+ if (!capacitancePattern.test(trimmedValue)) return void 0;
11437
+ return trimmedValue.replace(/\s+/g, "").replace(/[µμ]/g, "u");
11438
+ };
11439
+ var isCapacitorComponent = (betterEasy) => {
11440
+ const componentParameters = betterEasy.dataStr.head.c_para;
11441
+ const prefix = componentParameters.pre;
11442
+ const value = componentParameters.Value;
11443
+ return prefix?.toUpperCase() === "C?" && normalizeCapacitanceValue(value) !== void 0;
11444
+ };
11445
+
11404
11446
  // lib/websafe/convert-to-typescript-component/is-crystal-component.ts
11405
11447
  var frequencyPattern = /^\d+(?:\.\d+)?\s*(?:Hz|kHz|MHz|GHz)$/i;
11406
11448
  var isCrystalComponent = (betterEasy) => {
@@ -11789,10 +11831,11 @@ var hasNonBoxSchematicSymbol = (easyEdaJson) => {
11789
11831
 
11790
11832
  // lib/websafe/convert-to-typescript-component/index.tsx
11791
11833
  var getGeneratedComponentType = (betterEasy, pinCount) => {
11792
- if (isLedCategoryComponent(betterEasy)) return "led";
11834
+ if (isLedCategoryComponent(betterEasy) && pinCount === 2) return "led";
11793
11835
  if (isDiodeCategoryComponent(betterEasy) && pinCount === 2) return "diode";
11794
11836
  if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
11795
11837
  if (isSwitchCategoryComponent(betterEasy)) return "switch";
11838
+ if (isCapacitorComponent(betterEasy)) return "capacitor";
11796
11839
  if (isInductorComponent(betterEasy)) return "inductor";
11797
11840
  if (isCrystalComponent(betterEasy)) return "crystal";
11798
11841
  if (isMicroUsbConnectorComponent(betterEasy)) return "connector";
@@ -11865,6 +11908,7 @@ var convertBetterEasyToTsx = async ({
11865
11908
  sourcePorts.length
11866
11909
  );
11867
11910
  const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
11911
+ const capacitance2 = componentType === "capacitor" ? normalizeCapacitanceValue(betterEasy.dataStr.head.c_para.Value) : void 0;
11868
11912
  const crystalFrequency = componentType === "crystal" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
11869
11913
  const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
11870
11914
  const isMultiPinDiode = isDiodeCategoryComponent(betterEasy) && sourcePorts.length !== 2;
@@ -11878,6 +11922,7 @@ var convertBetterEasyToTsx = async ({
11878
11922
  circuitJson,
11879
11923
  supplierPartNumbers,
11880
11924
  componentType,
11925
+ capacitance: capacitance2,
11881
11926
  inductance: inductance2,
11882
11927
  crystalFrequency,
11883
11928
  crystalPinVariant,