easyeda 0.0.295 → 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 +67 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +68 -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
|
],
|
|
@@ -11163,6 +11163,7 @@ var generateTypescriptComponent = ({
|
|
|
11163
11163
|
manufacturerPartNumber,
|
|
11164
11164
|
componentType = "chip",
|
|
11165
11165
|
capacitance: capacitance2,
|
|
11166
|
+
resistance: resistance2,
|
|
11166
11167
|
inductance: inductance2,
|
|
11167
11168
|
crystalFrequency,
|
|
11168
11169
|
crystalPinVariant,
|
|
@@ -11326,6 +11327,32 @@ ${cadModelLines}
|
|
|
11326
11327
|
/>
|
|
11327
11328
|
)
|
|
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
|
+
}
|
|
11329
11356
|
`.trim();
|
|
11330
11357
|
}
|
|
11331
11358
|
if (componentType === "inductor") {
|
|
@@ -11498,6 +11525,43 @@ var isPushbuttonCategoryComponent = (betterEasy) => {
|
|
|
11498
11525
|
].some(categoryValueContainsPushbutton);
|
|
11499
11526
|
};
|
|
11500
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
|
+
|
|
11501
11565
|
// lib/websafe/convert-to-typescript-component/category-value-contains-switch.ts
|
|
11502
11566
|
var categoryValueContainsSwitch = (value) => {
|
|
11503
11567
|
if (typeof value === "string") {
|
|
@@ -11836,6 +11900,7 @@ var getGeneratedComponentType = (betterEasy, pinCount) => {
|
|
|
11836
11900
|
if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
|
|
11837
11901
|
if (isSwitchCategoryComponent(betterEasy)) return "switch";
|
|
11838
11902
|
if (isCapacitorComponent(betterEasy)) return "capacitor";
|
|
11903
|
+
if (isResistorComponent(betterEasy) && pinCount === 2) return "resistor";
|
|
11839
11904
|
if (isInductorComponent(betterEasy)) return "inductor";
|
|
11840
11905
|
if (isCrystalComponent(betterEasy)) return "crystal";
|
|
11841
11906
|
if (isMicroUsbConnectorComponent(betterEasy)) return "connector";
|
|
@@ -11909,6 +11974,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
11909
11974
|
);
|
|
11910
11975
|
const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
|
|
11911
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;
|
|
11912
11978
|
const crystalFrequency = componentType === "crystal" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
|
|
11913
11979
|
const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
|
|
11914
11980
|
const isMultiPinDiode = isDiodeCategoryComponent(betterEasy) && sourcePorts.length !== 2;
|
|
@@ -11923,6 +11989,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
11923
11989
|
supplierPartNumbers,
|
|
11924
11990
|
componentType,
|
|
11925
11991
|
capacitance: capacitance2,
|
|
11992
|
+
resistance: resistance2,
|
|
11926
11993
|
inductance: inductance2,
|
|
11927
11994
|
crystalFrequency,
|
|
11928
11995
|
crystalPinVariant,
|