easyeda 0.0.294 → 0.0.296
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 +112 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +112 -0
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +113 -1
- 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.295",
|
|
3532
3532
|
files: [
|
|
3533
3533
|
"dist"
|
|
3534
3534
|
],
|
|
@@ -11162,6 +11162,8 @@ var generateTypescriptComponent = ({
|
|
|
11162
11162
|
supplierPartNumbers,
|
|
11163
11163
|
manufacturerPartNumber,
|
|
11164
11164
|
componentType = "chip",
|
|
11165
|
+
capacitance: capacitance2,
|
|
11166
|
+
resistance: resistance2,
|
|
11165
11167
|
inductance: inductance2,
|
|
11166
11168
|
crystalFrequency,
|
|
11167
11169
|
crystalPinVariant,
|
|
@@ -11299,6 +11301,58 @@ ${cadModelLines}
|
|
|
11299
11301
|
/>
|
|
11300
11302
|
)
|
|
11301
11303
|
}
|
|
11304
|
+
`.trim();
|
|
11305
|
+
}
|
|
11306
|
+
if (componentType === "capacitor") {
|
|
11307
|
+
if (!capacitance2) {
|
|
11308
|
+
throw new Error("Capacitance is required for capacitor components");
|
|
11309
|
+
}
|
|
11310
|
+
return `
|
|
11311
|
+
import type { CapacitorProps } from "@tscircuit/props"
|
|
11312
|
+
|
|
11313
|
+
export const ${componentName} = (props: Omit<CapacitorProps, "capacitance">) => {
|
|
11314
|
+
const { name = "C1", ...restProps } = props
|
|
11315
|
+
|
|
11316
|
+
return (
|
|
11317
|
+
<capacitor
|
|
11318
|
+
name={name}
|
|
11319
|
+
capacitance=${JSON.stringify(capacitance2)}
|
|
11320
|
+
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11321
|
+
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
11322
|
+
footprint={${footprintTsx}}
|
|
11323
|
+
${objUrl || stepUrl ? `cadModel={{
|
|
11324
|
+
${cadModelLines}
|
|
11325
|
+
}}` : ""}
|
|
11326
|
+
{...restProps}
|
|
11327
|
+
/>
|
|
11328
|
+
)
|
|
11329
|
+
}
|
|
11330
|
+
`.trim();
|
|
11331
|
+
}
|
|
11332
|
+
if (componentType === "resistor") {
|
|
11333
|
+
if (!resistance2) {
|
|
11334
|
+
throw new Error("Resistance is required for resistor components");
|
|
11335
|
+
}
|
|
11336
|
+
return `
|
|
11337
|
+
import type { ResistorProps } from "@tscircuit/props"
|
|
11338
|
+
|
|
11339
|
+
export const ${componentName} = (props: Omit<ResistorProps, "resistance">) => {
|
|
11340
|
+
const { name = "R1", ...restProps } = props
|
|
11341
|
+
|
|
11342
|
+
return (
|
|
11343
|
+
<resistor
|
|
11344
|
+
name={name}
|
|
11345
|
+
resistance=${JSON.stringify(resistance2)}
|
|
11346
|
+
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11347
|
+
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
11348
|
+
footprint={${footprintTsx}}
|
|
11349
|
+
${objUrl || stepUrl ? `cadModel={{
|
|
11350
|
+
${cadModelLines}
|
|
11351
|
+
}}` : ""}
|
|
11352
|
+
{...restProps}
|
|
11353
|
+
/>
|
|
11354
|
+
)
|
|
11355
|
+
}
|
|
11302
11356
|
`.trim();
|
|
11303
11357
|
}
|
|
11304
11358
|
if (componentType === "inductor") {
|
|
@@ -11401,6 +11455,21 @@ ${cadModelLines}
|
|
|
11401
11455
|
`.trim();
|
|
11402
11456
|
};
|
|
11403
11457
|
|
|
11458
|
+
// lib/websafe/convert-to-typescript-component/is-capacitor-component.ts
|
|
11459
|
+
var capacitancePattern = /^\d+(?:\.\d+)?\s*(?:pF|nF|[uµμ]F|mF|F)$/i;
|
|
11460
|
+
var normalizeCapacitanceValue = (value) => {
|
|
11461
|
+
if (typeof value !== "string") return void 0;
|
|
11462
|
+
const trimmedValue = value.trim();
|
|
11463
|
+
if (!capacitancePattern.test(trimmedValue)) return void 0;
|
|
11464
|
+
return trimmedValue.replace(/\s+/g, "").replace(/[µμ]/g, "u");
|
|
11465
|
+
};
|
|
11466
|
+
var isCapacitorComponent = (betterEasy) => {
|
|
11467
|
+
const componentParameters = betterEasy.dataStr.head.c_para;
|
|
11468
|
+
const prefix = componentParameters.pre;
|
|
11469
|
+
const value = componentParameters.Value;
|
|
11470
|
+
return prefix?.toUpperCase() === "C?" && normalizeCapacitanceValue(value) !== void 0;
|
|
11471
|
+
};
|
|
11472
|
+
|
|
11404
11473
|
// lib/websafe/convert-to-typescript-component/is-crystal-component.ts
|
|
11405
11474
|
var frequencyPattern = /^\d+(?:\.\d+)?\s*(?:Hz|kHz|MHz|GHz)$/i;
|
|
11406
11475
|
var isCrystalComponent = (betterEasy) => {
|
|
@@ -11456,6 +11525,43 @@ var isPushbuttonCategoryComponent = (betterEasy) => {
|
|
|
11456
11525
|
].some(categoryValueContainsPushbutton);
|
|
11457
11526
|
};
|
|
11458
11527
|
|
|
11528
|
+
// lib/websafe/convert-to-typescript-component/is-resistor-component.ts
|
|
11529
|
+
var standardSmdResistorPackagePattern = /^R(?:01005|0201|0402|0504|0603|0805|1206|1210|1812|2010|2512)(?:$|[_-])/i;
|
|
11530
|
+
var normalizeExplicitScale = (scale2) => {
|
|
11531
|
+
if (scale2 === "k" || scale2 === "K") return "k";
|
|
11532
|
+
if (scale2 === "m") return "m";
|
|
11533
|
+
if (scale2 === "M") return "M";
|
|
11534
|
+
if (scale2 === "g" || scale2 === "G") return "G";
|
|
11535
|
+
return "";
|
|
11536
|
+
};
|
|
11537
|
+
var normalizeResistorValue = (value) => {
|
|
11538
|
+
if (typeof value !== "string") return void 0;
|
|
11539
|
+
const compactValue = value.trim().replace(/\s+/g, "");
|
|
11540
|
+
const explicitUnitMatch = compactValue.match(
|
|
11541
|
+
/^(\d+(?:\.\d+)?)([mMkKgG]?)(?:Ω|ohms?)$/i
|
|
11542
|
+
);
|
|
11543
|
+
if (explicitUnitMatch) {
|
|
11544
|
+
const [, magnitude, scale2] = explicitUnitMatch;
|
|
11545
|
+
if (Number(magnitude) === 0) return "0ohm";
|
|
11546
|
+
return `${magnitude}${normalizeExplicitScale(scale2)}ohm`;
|
|
11547
|
+
}
|
|
11548
|
+
const resistorCodeMatch = compactValue.match(/^(\d+)([RrKkMm])(\d*)$/);
|
|
11549
|
+
if (resistorCodeMatch) {
|
|
11550
|
+
const [, whole, multiplier, fraction] = resistorCodeMatch;
|
|
11551
|
+
const magnitude = fraction ? `${whole}.${fraction}` : whole;
|
|
11552
|
+
if (Number(magnitude) === 0) return "0ohm";
|
|
11553
|
+
const scale2 = multiplier === "R" || multiplier === "r" ? "" : multiplier === "K" || multiplier === "k" ? "k" : "M";
|
|
11554
|
+
return `${magnitude}${scale2}ohm`;
|
|
11555
|
+
}
|
|
11556
|
+
if (/^0+(?:\.0+)?$/.test(compactValue)) return "0ohm";
|
|
11557
|
+
return void 0;
|
|
11558
|
+
};
|
|
11559
|
+
var isResistorComponent = (betterEasy) => {
|
|
11560
|
+
const componentParameters = betterEasy.dataStr.head.c_para;
|
|
11561
|
+
const packageName = componentParameters.package;
|
|
11562
|
+
return componentParameters.pre?.toUpperCase() === "R?" && typeof packageName === "string" && standardSmdResistorPackagePattern.test(packageName.trim()) && normalizeResistorValue(componentParameters.Value) !== void 0;
|
|
11563
|
+
};
|
|
11564
|
+
|
|
11459
11565
|
// lib/websafe/convert-to-typescript-component/category-value-contains-switch.ts
|
|
11460
11566
|
var categoryValueContainsSwitch = (value) => {
|
|
11461
11567
|
if (typeof value === "string") {
|
|
@@ -11793,6 +11899,8 @@ var getGeneratedComponentType = (betterEasy, pinCount) => {
|
|
|
11793
11899
|
if (isDiodeCategoryComponent(betterEasy) && pinCount === 2) return "diode";
|
|
11794
11900
|
if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
|
|
11795
11901
|
if (isSwitchCategoryComponent(betterEasy)) return "switch";
|
|
11902
|
+
if (isCapacitorComponent(betterEasy)) return "capacitor";
|
|
11903
|
+
if (isResistorComponent(betterEasy) && pinCount === 2) return "resistor";
|
|
11796
11904
|
if (isInductorComponent(betterEasy)) return "inductor";
|
|
11797
11905
|
if (isCrystalComponent(betterEasy)) return "crystal";
|
|
11798
11906
|
if (isMicroUsbConnectorComponent(betterEasy)) return "connector";
|
|
@@ -11865,6 +11973,8 @@ var convertBetterEasyToTsx = async ({
|
|
|
11865
11973
|
sourcePorts.length
|
|
11866
11974
|
);
|
|
11867
11975
|
const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
|
|
11976
|
+
const capacitance2 = componentType === "capacitor" ? normalizeCapacitanceValue(betterEasy.dataStr.head.c_para.Value) : void 0;
|
|
11977
|
+
const resistance2 = componentType === "resistor" ? normalizeResistorValue(betterEasy.dataStr.head.c_para.Value) : void 0;
|
|
11868
11978
|
const crystalFrequency = componentType === "crystal" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
|
|
11869
11979
|
const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
|
|
11870
11980
|
const isMultiPinDiode = isDiodeCategoryComponent(betterEasy) && sourcePorts.length !== 2;
|
|
@@ -11878,6 +11988,8 @@ var convertBetterEasyToTsx = async ({
|
|
|
11878
11988
|
circuitJson,
|
|
11879
11989
|
supplierPartNumbers,
|
|
11880
11990
|
componentType,
|
|
11991
|
+
capacitance: capacitance2,
|
|
11992
|
+
resistance: resistance2,
|
|
11881
11993
|
inductance: inductance2,
|
|
11882
11994
|
crystalFrequency,
|
|
11883
11995
|
crystalPinVariant,
|