easyeda 0.0.289 → 0.0.290

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.288",
3531
+ version: "0.0.289",
3532
3532
  files: [
3533
3533
  "dist"
3534
3534
  ],
@@ -11162,6 +11162,9 @@ var generateTypescriptComponent = ({
11162
11162
  supplierPartNumbers,
11163
11163
  manufacturerPartNumber,
11164
11164
  componentType = "chip",
11165
+ inductance: inductance2,
11166
+ crystalFrequency,
11167
+ crystalPinVariant,
11165
11168
  symbolTsx
11166
11169
  }) => {
11167
11170
  const safePinLabels = pinLabels ?? {};
@@ -11296,6 +11299,58 @@ ${cadModelLines}
11296
11299
  />
11297
11300
  )
11298
11301
  }
11302
+ `.trim();
11303
+ }
11304
+ if (componentType === "inductor") {
11305
+ if (!inductance2) {
11306
+ throw new Error("Inductance is required for inductor components");
11307
+ }
11308
+ return `
11309
+ import type { InductorProps } from "@tscircuit/props"
11310
+
11311
+ export const ${componentName} = (props: Omit<InductorProps, "inductance">) => {
11312
+ return (
11313
+ <inductor
11314
+ inductance=${JSON.stringify(inductance2)}
11315
+ supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
11316
+ manufacturerPartNumber="${manufacturerPartNumber}"
11317
+ footprint={${footprintTsx}}
11318
+ ${objUrl || stepUrl ? `cadModel={{
11319
+ ${cadModelLines}
11320
+ }}` : ""}
11321
+ {...props}
11322
+ />
11323
+ )
11324
+ }
11325
+ `.trim();
11326
+ }
11327
+ if (componentType === "crystal") {
11328
+ if (!crystalFrequency || !crystalPinVariant) {
11329
+ throw new Error("Crystal frequency and pin variant are required");
11330
+ }
11331
+ return `
11332
+ import type { CrystalProps } from "@tscircuit/props"
11333
+
11334
+ type ImportedCrystalProps = Omit<CrystalProps, "frequency" | "pinVariant">
11335
+
11336
+ export const ${componentName} = (props: ImportedCrystalProps) => {
11337
+ const { name = "X1", ...restProps } = props
11338
+
11339
+ return (
11340
+ <crystal
11341
+ name={name}
11342
+ frequency=${JSON.stringify(crystalFrequency)}
11343
+ pinVariant=${JSON.stringify(crystalPinVariant)}
11344
+ supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
11345
+ manufacturerPartNumber="${manufacturerPartNumber}"
11346
+ footprint={${footprintTsx}}
11347
+ ${objUrl || stepUrl ? `cadModel={{
11348
+ ${cadModelLines}
11349
+ }}` : ""}
11350
+ {...restProps}
11351
+ />
11352
+ )
11353
+ }
11299
11354
  `.trim();
11300
11355
  }
11301
11356
  return `
@@ -11322,6 +11377,24 @@ ${cadModelLines}
11322
11377
  `.trim();
11323
11378
  };
11324
11379
 
11380
+ // lib/websafe/convert-to-typescript-component/is-crystal-component.ts
11381
+ var frequencyPattern = /^\d+(?:\.\d+)?\s*(?:Hz|kHz|MHz|GHz)$/i;
11382
+ var isCrystalComponent = (betterEasy) => {
11383
+ const componentParameters = betterEasy.dataStr.head.c_para;
11384
+ const packageName = componentParameters.package;
11385
+ const value = componentParameters.Value;
11386
+ return componentParameters.pre === "X?" && packageName?.toUpperCase().startsWith("CRYSTAL-") === true && typeof value === "string" && frequencyPattern.test(value.trim());
11387
+ };
11388
+
11389
+ // lib/websafe/convert-to-typescript-component/is-inductor-component.ts
11390
+ var inductancePattern = /^\d+(?:\.\d+)?\s*(?:pH|nH|uH|µH|mH|H)$/i;
11391
+ var isInductorComponent = (betterEasy) => {
11392
+ const componentParameters = betterEasy.dataStr.head.c_para;
11393
+ const packageName = componentParameters.package;
11394
+ const value = componentParameters.Value;
11395
+ return packageName?.toUpperCase().startsWith("IND-") === true && typeof value === "string" && inductancePattern.test(value.trim());
11396
+ };
11397
+
11325
11398
  // lib/websafe/convert-to-typescript-component/category-value-contains-pushbutton.ts
11326
11399
  var categoryValueContainsPushbutton = (value) => {
11327
11400
  if (typeof value === "string") {
@@ -11690,6 +11763,8 @@ var getGeneratedComponentType = (betterEasy) => {
11690
11763
  if (isDiodeCategoryComponent(betterEasy)) return "diode";
11691
11764
  if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
11692
11765
  if (isSwitchCategoryComponent(betterEasy)) return "switch";
11766
+ if (isInductorComponent(betterEasy)) return "inductor";
11767
+ if (isCrystalComponent(betterEasy)) return "crystal";
11693
11768
  return "chip";
11694
11769
  };
11695
11770
  var convertRawEasyToTsx = async ({ rawEasy }) => {
@@ -11755,6 +11830,9 @@ var convertBetterEasyToTsx = async ({
11755
11830
  jlcpcb: [betterEasy.lcsc.number]
11756
11831
  };
11757
11832
  const componentType = getGeneratedComponentType(betterEasy);
11833
+ const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
11834
+ const crystalFrequency = componentType === "crystal" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
11835
+ const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
11758
11836
  const symbolTsx = componentType === "chip" && hasNonBoxSchematicSymbol(betterEasy) ? generateSymbolTsx(betterEasy, circuitJson) : void 0;
11759
11837
  return generateTypescriptComponent({
11760
11838
  componentName,
@@ -11765,6 +11843,9 @@ var convertBetterEasyToTsx = async ({
11765
11843
  circuitJson,
11766
11844
  supplierPartNumbers,
11767
11845
  componentType,
11846
+ inductance: inductance2,
11847
+ crystalFrequency,
11848
+ crystalPinVariant,
11768
11849
  symbolTsx
11769
11850
  });
11770
11851
  };