easyeda 0.0.295 → 0.0.297
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 +75 -4
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +75 -4
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +76 -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.296",
|
|
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,
|
|
@@ -11316,7 +11317,33 @@ export const ${componentName} = (props: Omit<CapacitorProps, "capacitance">) =>
|
|
|
11316
11317
|
<capacitor
|
|
11317
11318
|
name={name}
|
|
11318
11319
|
capacitance=${JSON.stringify(capacitance2)}
|
|
11319
|
-
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11320
|
+
${symbolProp} 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
|
+
${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11320
11347
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
11321
11348
|
footprint={${footprintTsx}}
|
|
11322
11349
|
${objUrl || stepUrl ? `cadModel={{
|
|
@@ -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") {
|
|
@@ -11786,7 +11850,7 @@ var generateShapeTsx = ({
|
|
|
11786
11850
|
}
|
|
11787
11851
|
return void 0;
|
|
11788
11852
|
};
|
|
11789
|
-
var generateSymbolTsx = (easyEdaJson, circuitJson) => {
|
|
11853
|
+
var generateSymbolTsx = (easyEdaJson, circuitJson, { includePorts = true } = {}) => {
|
|
11790
11854
|
const shapes = easyEdaJson.dataStr.shape;
|
|
11791
11855
|
if (shapes.length === 0) return void 0;
|
|
11792
11856
|
const headOrigin = {
|
|
@@ -11803,7 +11867,7 @@ var generateSymbolTsx = (easyEdaJson, circuitJson) => {
|
|
|
11803
11867
|
easyEdaJson,
|
|
11804
11868
|
circuitJson
|
|
11805
11869
|
);
|
|
11806
|
-
const shapeTsx = shapes.map(
|
|
11870
|
+
const shapeTsx = shapes.filter((shape) => includePorts || shape.type !== "PIN").map(
|
|
11807
11871
|
(shape) => generateShapeTsx({
|
|
11808
11872
|
shape,
|
|
11809
11873
|
origin,
|
|
@@ -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,10 +11974,15 @@ 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;
|
|
11915
|
-
const
|
|
11981
|
+
const isPassiveWithCustomSymbol = componentType === "capacitor" || componentType === "resistor";
|
|
11982
|
+
const symbolTsx = isPassiveWithCustomSymbol || componentType === "chip" && !isMultiPinDiode && hasNonBoxSchematicSymbol(betterEasy) ? generateSymbolTsx(betterEasy, circuitJson, {
|
|
11983
|
+
// Passive primitives already create their two source ports.
|
|
11984
|
+
includePorts: !isPassiveWithCustomSymbol
|
|
11985
|
+
}) : void 0;
|
|
11916
11986
|
return generateTypescriptComponent({
|
|
11917
11987
|
componentName,
|
|
11918
11988
|
manufacturerPartNumber,
|
|
@@ -11923,6 +11993,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
11923
11993
|
supplierPartNumbers,
|
|
11924
11994
|
componentType,
|
|
11925
11995
|
capacitance: capacitance2,
|
|
11996
|
+
resistance: resistance2,
|
|
11926
11997
|
inductance: inductance2,
|
|
11927
11998
|
crystalFrequency,
|
|
11928
11999
|
crystalPinVariant,
|