easyeda 0.0.288 → 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/browser/index.js +90 -4
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +90 -4
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +91 -5
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
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.
|
|
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 }) => {
|
|
@@ -11717,8 +11792,13 @@ var convertBetterEasyToTsx = async ({
|
|
|
11717
11792
|
cadComponent.position.x = 0;
|
|
11718
11793
|
cadComponent.position.y = 0;
|
|
11719
11794
|
}
|
|
11720
|
-
const
|
|
11721
|
-
|
|
11795
|
+
const manufacturerPartNumber = betterEasy.dataStr.head.c_para["Manufacturer Part"];
|
|
11796
|
+
if (!manufacturerPartNumber) {
|
|
11797
|
+
throw new Error(
|
|
11798
|
+
`Missing manufacturer part number for ${betterEasy.lcsc.number}`
|
|
11799
|
+
);
|
|
11800
|
+
}
|
|
11801
|
+
const componentName = normalizeManufacturerPartNumber(manufacturerPartNumber);
|
|
11722
11802
|
const sourcePorts = su(circuitJson).source_port.list();
|
|
11723
11803
|
const pinLabels = {};
|
|
11724
11804
|
const sortedPorts = sourcePorts.sort((a, b) => {
|
|
@@ -11750,16 +11830,22 @@ var convertBetterEasyToTsx = async ({
|
|
|
11750
11830
|
jlcpcb: [betterEasy.lcsc.number]
|
|
11751
11831
|
};
|
|
11752
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;
|
|
11753
11836
|
const symbolTsx = componentType === "chip" && hasNonBoxSchematicSymbol(betterEasy) ? generateSymbolTsx(betterEasy, circuitJson) : void 0;
|
|
11754
11837
|
return generateTypescriptComponent({
|
|
11755
|
-
componentName
|
|
11756
|
-
manufacturerPartNumber
|
|
11838
|
+
componentName,
|
|
11839
|
+
manufacturerPartNumber,
|
|
11757
11840
|
pinLabels,
|
|
11758
11841
|
objUrl: modelObjUrl,
|
|
11759
11842
|
stepUrl: modelStepUrl,
|
|
11760
11843
|
circuitJson,
|
|
11761
11844
|
supplierPartNumbers,
|
|
11762
11845
|
componentType,
|
|
11846
|
+
inductance: inductance2,
|
|
11847
|
+
crystalFrequency,
|
|
11848
|
+
crystalPinVariant,
|
|
11763
11849
|
symbolTsx
|
|
11764
11850
|
});
|
|
11765
11851
|
};
|