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/index.js
CHANGED
|
@@ -7756,6 +7756,7 @@ var generateTypescriptComponent = ({
|
|
|
7756
7756
|
manufacturerPartNumber,
|
|
7757
7757
|
componentType = "chip",
|
|
7758
7758
|
capacitance: capacitance2,
|
|
7759
|
+
resistance: resistance2,
|
|
7759
7760
|
inductance: inductance2,
|
|
7760
7761
|
crystalFrequency,
|
|
7761
7762
|
crystalPinVariant,
|
|
@@ -7919,6 +7920,32 @@ ${cadModelLines}
|
|
|
7919
7920
|
/>
|
|
7920
7921
|
)
|
|
7921
7922
|
}
|
|
7923
|
+
`.trim();
|
|
7924
|
+
}
|
|
7925
|
+
if (componentType === "resistor") {
|
|
7926
|
+
if (!resistance2) {
|
|
7927
|
+
throw new Error("Resistance is required for resistor components");
|
|
7928
|
+
}
|
|
7929
|
+
return `
|
|
7930
|
+
import type { ResistorProps } from "@tscircuit/props"
|
|
7931
|
+
|
|
7932
|
+
export const ${componentName} = (props: Omit<ResistorProps, "resistance">) => {
|
|
7933
|
+
const { name = "R1", ...restProps } = props
|
|
7934
|
+
|
|
7935
|
+
return (
|
|
7936
|
+
<resistor
|
|
7937
|
+
name={name}
|
|
7938
|
+
resistance=${JSON.stringify(resistance2)}
|
|
7939
|
+
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
7940
|
+
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
7941
|
+
footprint={${footprintTsx}}
|
|
7942
|
+
${objUrl || stepUrl ? `cadModel={{
|
|
7943
|
+
${cadModelLines}
|
|
7944
|
+
}}` : ""}
|
|
7945
|
+
{...restProps}
|
|
7946
|
+
/>
|
|
7947
|
+
)
|
|
7948
|
+
}
|
|
7922
7949
|
`.trim();
|
|
7923
7950
|
}
|
|
7924
7951
|
if (componentType === "inductor") {
|
|
@@ -8091,6 +8118,43 @@ var isPushbuttonCategoryComponent = (betterEasy) => {
|
|
|
8091
8118
|
].some(categoryValueContainsPushbutton);
|
|
8092
8119
|
};
|
|
8093
8120
|
|
|
8121
|
+
// lib/websafe/convert-to-typescript-component/is-resistor-component.ts
|
|
8122
|
+
var standardSmdResistorPackagePattern = /^R(?:01005|0201|0402|0504|0603|0805|1206|1210|1812|2010|2512)(?:$|[_-])/i;
|
|
8123
|
+
var normalizeExplicitScale = (scale2) => {
|
|
8124
|
+
if (scale2 === "k" || scale2 === "K") return "k";
|
|
8125
|
+
if (scale2 === "m") return "m";
|
|
8126
|
+
if (scale2 === "M") return "M";
|
|
8127
|
+
if (scale2 === "g" || scale2 === "G") return "G";
|
|
8128
|
+
return "";
|
|
8129
|
+
};
|
|
8130
|
+
var normalizeResistorValue = (value) => {
|
|
8131
|
+
if (typeof value !== "string") return void 0;
|
|
8132
|
+
const compactValue = value.trim().replace(/\s+/g, "");
|
|
8133
|
+
const explicitUnitMatch = compactValue.match(
|
|
8134
|
+
/^(\d+(?:\.\d+)?)([mMkKgG]?)(?:Ω|ohms?)$/i
|
|
8135
|
+
);
|
|
8136
|
+
if (explicitUnitMatch) {
|
|
8137
|
+
const [, magnitude, scale2] = explicitUnitMatch;
|
|
8138
|
+
if (Number(magnitude) === 0) return "0ohm";
|
|
8139
|
+
return `${magnitude}${normalizeExplicitScale(scale2)}ohm`;
|
|
8140
|
+
}
|
|
8141
|
+
const resistorCodeMatch = compactValue.match(/^(\d+)([RrKkMm])(\d*)$/);
|
|
8142
|
+
if (resistorCodeMatch) {
|
|
8143
|
+
const [, whole, multiplier, fraction] = resistorCodeMatch;
|
|
8144
|
+
const magnitude = fraction ? `${whole}.${fraction}` : whole;
|
|
8145
|
+
if (Number(magnitude) === 0) return "0ohm";
|
|
8146
|
+
const scale2 = multiplier === "R" || multiplier === "r" ? "" : multiplier === "K" || multiplier === "k" ? "k" : "M";
|
|
8147
|
+
return `${magnitude}${scale2}ohm`;
|
|
8148
|
+
}
|
|
8149
|
+
if (/^0+(?:\.0+)?$/.test(compactValue)) return "0ohm";
|
|
8150
|
+
return void 0;
|
|
8151
|
+
};
|
|
8152
|
+
var isResistorComponent = (betterEasy) => {
|
|
8153
|
+
const componentParameters = betterEasy.dataStr.head.c_para;
|
|
8154
|
+
const packageName = componentParameters.package;
|
|
8155
|
+
return componentParameters.pre?.toUpperCase() === "R?" && typeof packageName === "string" && standardSmdResistorPackagePattern.test(packageName.trim()) && normalizeResistorValue(componentParameters.Value) !== void 0;
|
|
8156
|
+
};
|
|
8157
|
+
|
|
8094
8158
|
// lib/websafe/convert-to-typescript-component/category-value-contains-switch.ts
|
|
8095
8159
|
var categoryValueContainsSwitch = (value) => {
|
|
8096
8160
|
if (typeof value === "string") {
|
|
@@ -8429,6 +8493,7 @@ var getGeneratedComponentType = (betterEasy, pinCount) => {
|
|
|
8429
8493
|
if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
|
|
8430
8494
|
if (isSwitchCategoryComponent(betterEasy)) return "switch";
|
|
8431
8495
|
if (isCapacitorComponent(betterEasy)) return "capacitor";
|
|
8496
|
+
if (isResistorComponent(betterEasy) && pinCount === 2) return "resistor";
|
|
8432
8497
|
if (isInductorComponent(betterEasy)) return "inductor";
|
|
8433
8498
|
if (isCrystalComponent(betterEasy)) return "crystal";
|
|
8434
8499
|
if (isMicroUsbConnectorComponent(betterEasy)) return "connector";
|
|
@@ -8502,6 +8567,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
8502
8567
|
);
|
|
8503
8568
|
const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
|
|
8504
8569
|
const capacitance2 = componentType === "capacitor" ? normalizeCapacitanceValue(betterEasy.dataStr.head.c_para.Value) : void 0;
|
|
8570
|
+
const resistance2 = componentType === "resistor" ? normalizeResistorValue(betterEasy.dataStr.head.c_para.Value) : void 0;
|
|
8505
8571
|
const crystalFrequency = componentType === "crystal" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
|
|
8506
8572
|
const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
|
|
8507
8573
|
const isMultiPinDiode = isDiodeCategoryComponent(betterEasy) && sourcePorts.length !== 2;
|
|
@@ -8516,6 +8582,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
8516
8582
|
supplierPartNumbers,
|
|
8517
8583
|
componentType,
|
|
8518
8584
|
capacitance: capacitance2,
|
|
8585
|
+
resistance: resistance2,
|
|
8519
8586
|
inductance: inductance2,
|
|
8520
8587
|
crystalFrequency,
|
|
8521
8588
|
crystalPinVariant,
|