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/browser/index.js
CHANGED
|
@@ -11455,6 +11455,7 @@ var generateTypescriptComponent = ({
|
|
|
11455
11455
|
manufacturerPartNumber,
|
|
11456
11456
|
componentType = "chip",
|
|
11457
11457
|
capacitance: capacitance2,
|
|
11458
|
+
resistance: resistance2,
|
|
11458
11459
|
inductance: inductance2,
|
|
11459
11460
|
crystalFrequency,
|
|
11460
11461
|
crystalPinVariant,
|
|
@@ -11608,7 +11609,33 @@ export const ${componentName} = (props: Omit<CapacitorProps, "capacitance">) =>
|
|
|
11608
11609
|
<capacitor
|
|
11609
11610
|
name={name}
|
|
11610
11611
|
capacitance=${JSON.stringify(capacitance2)}
|
|
11611
|
-
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11612
|
+
${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11613
|
+
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
11614
|
+
footprint={${footprintTsx}}
|
|
11615
|
+
${objUrl || stepUrl ? `cadModel={{
|
|
11616
|
+
${cadModelLines}
|
|
11617
|
+
}}` : ""}
|
|
11618
|
+
{...restProps}
|
|
11619
|
+
/>
|
|
11620
|
+
)
|
|
11621
|
+
}
|
|
11622
|
+
`.trim();
|
|
11623
|
+
}
|
|
11624
|
+
if (componentType === "resistor") {
|
|
11625
|
+
if (!resistance2) {
|
|
11626
|
+
throw new Error("Resistance is required for resistor components");
|
|
11627
|
+
}
|
|
11628
|
+
return `
|
|
11629
|
+
import type { ResistorProps } from "@tscircuit/props"
|
|
11630
|
+
|
|
11631
|
+
export const ${componentName} = (props: Omit<ResistorProps, "resistance">) => {
|
|
11632
|
+
const { name = "R1", ...restProps } = props
|
|
11633
|
+
|
|
11634
|
+
return (
|
|
11635
|
+
<resistor
|
|
11636
|
+
name={name}
|
|
11637
|
+
resistance=${JSON.stringify(resistance2)}
|
|
11638
|
+
${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
11612
11639
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
11613
11640
|
footprint={${footprintTsx}}
|
|
11614
11641
|
${objUrl || stepUrl ? `cadModel={{
|
|
@@ -11790,6 +11817,43 @@ var isPushbuttonCategoryComponent = (betterEasy) => {
|
|
|
11790
11817
|
].some(categoryValueContainsPushbutton);
|
|
11791
11818
|
};
|
|
11792
11819
|
|
|
11820
|
+
// lib/websafe/convert-to-typescript-component/is-resistor-component.ts
|
|
11821
|
+
var standardSmdResistorPackagePattern = /^R(?:01005|0201|0402|0504|0603|0805|1206|1210|1812|2010|2512)(?:$|[_-])/i;
|
|
11822
|
+
var normalizeExplicitScale = (scale2) => {
|
|
11823
|
+
if (scale2 === "k" || scale2 === "K") return "k";
|
|
11824
|
+
if (scale2 === "m") return "m";
|
|
11825
|
+
if (scale2 === "M") return "M";
|
|
11826
|
+
if (scale2 === "g" || scale2 === "G") return "G";
|
|
11827
|
+
return "";
|
|
11828
|
+
};
|
|
11829
|
+
var normalizeResistorValue = (value) => {
|
|
11830
|
+
if (typeof value !== "string") return void 0;
|
|
11831
|
+
const compactValue = value.trim().replace(/\s+/g, "");
|
|
11832
|
+
const explicitUnitMatch = compactValue.match(
|
|
11833
|
+
/^(\d+(?:\.\d+)?)([mMkKgG]?)(?:Ω|ohms?)$/i
|
|
11834
|
+
);
|
|
11835
|
+
if (explicitUnitMatch) {
|
|
11836
|
+
const [, magnitude, scale2] = explicitUnitMatch;
|
|
11837
|
+
if (Number(magnitude) === 0) return "0ohm";
|
|
11838
|
+
return `${magnitude}${normalizeExplicitScale(scale2)}ohm`;
|
|
11839
|
+
}
|
|
11840
|
+
const resistorCodeMatch = compactValue.match(/^(\d+)([RrKkMm])(\d*)$/);
|
|
11841
|
+
if (resistorCodeMatch) {
|
|
11842
|
+
const [, whole, multiplier, fraction] = resistorCodeMatch;
|
|
11843
|
+
const magnitude = fraction ? `${whole}.${fraction}` : whole;
|
|
11844
|
+
if (Number(magnitude) === 0) return "0ohm";
|
|
11845
|
+
const scale2 = multiplier === "R" || multiplier === "r" ? "" : multiplier === "K" || multiplier === "k" ? "k" : "M";
|
|
11846
|
+
return `${magnitude}${scale2}ohm`;
|
|
11847
|
+
}
|
|
11848
|
+
if (/^0+(?:\.0+)?$/.test(compactValue)) return "0ohm";
|
|
11849
|
+
return void 0;
|
|
11850
|
+
};
|
|
11851
|
+
var isResistorComponent = (betterEasy) => {
|
|
11852
|
+
const componentParameters = betterEasy.dataStr.head.c_para;
|
|
11853
|
+
const packageName = componentParameters.package;
|
|
11854
|
+
return componentParameters.pre?.toUpperCase() === "R?" && typeof packageName === "string" && standardSmdResistorPackagePattern.test(packageName.trim()) && normalizeResistorValue(componentParameters.Value) !== void 0;
|
|
11855
|
+
};
|
|
11856
|
+
|
|
11793
11857
|
// lib/websafe/convert-to-typescript-component/category-value-contains-switch.ts
|
|
11794
11858
|
var categoryValueContainsSwitch = (value) => {
|
|
11795
11859
|
if (typeof value === "string") {
|
|
@@ -12078,7 +12142,7 @@ var generateShapeTsx = ({
|
|
|
12078
12142
|
}
|
|
12079
12143
|
return void 0;
|
|
12080
12144
|
};
|
|
12081
|
-
var generateSymbolTsx = (easyEdaJson, circuitJson) => {
|
|
12145
|
+
var generateSymbolTsx = (easyEdaJson, circuitJson, { includePorts = true } = {}) => {
|
|
12082
12146
|
const shapes = easyEdaJson.dataStr.shape;
|
|
12083
12147
|
if (shapes.length === 0) return void 0;
|
|
12084
12148
|
const headOrigin = {
|
|
@@ -12095,7 +12159,7 @@ var generateSymbolTsx = (easyEdaJson, circuitJson) => {
|
|
|
12095
12159
|
easyEdaJson,
|
|
12096
12160
|
circuitJson
|
|
12097
12161
|
);
|
|
12098
|
-
const shapeTsx = shapes.map(
|
|
12162
|
+
const shapeTsx = shapes.filter((shape) => includePorts || shape.type !== "PIN").map(
|
|
12099
12163
|
(shape) => generateShapeTsx({
|
|
12100
12164
|
shape,
|
|
12101
12165
|
origin,
|
|
@@ -12128,6 +12192,7 @@ var getGeneratedComponentType = (betterEasy, pinCount) => {
|
|
|
12128
12192
|
if (isPushbuttonCategoryComponent(betterEasy)) return "pushbutton";
|
|
12129
12193
|
if (isSwitchCategoryComponent(betterEasy)) return "switch";
|
|
12130
12194
|
if (isCapacitorComponent(betterEasy)) return "capacitor";
|
|
12195
|
+
if (isResistorComponent(betterEasy) && pinCount === 2) return "resistor";
|
|
12131
12196
|
if (isInductorComponent(betterEasy)) return "inductor";
|
|
12132
12197
|
if (isCrystalComponent(betterEasy)) return "crystal";
|
|
12133
12198
|
if (isMicroUsbConnectorComponent(betterEasy)) return "connector";
|
|
@@ -12201,10 +12266,15 @@ var convertBetterEasyToTsx = async ({
|
|
|
12201
12266
|
);
|
|
12202
12267
|
const inductance2 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
|
|
12203
12268
|
const capacitance2 = componentType === "capacitor" ? normalizeCapacitanceValue(betterEasy.dataStr.head.c_para.Value) : void 0;
|
|
12269
|
+
const resistance2 = componentType === "resistor" ? normalizeResistorValue(betterEasy.dataStr.head.c_para.Value) : void 0;
|
|
12204
12270
|
const crystalFrequency = componentType === "crystal" ? betterEasy.dataStr.head.c_para.Value?.trim() : void 0;
|
|
12205
12271
|
const crystalPinVariant = componentType !== "crystal" ? void 0 : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : void 0;
|
|
12206
12272
|
const isMultiPinDiode = isDiodeCategoryComponent(betterEasy) && sourcePorts.length !== 2;
|
|
12207
|
-
const
|
|
12273
|
+
const isPassiveWithCustomSymbol = componentType === "capacitor" || componentType === "resistor";
|
|
12274
|
+
const symbolTsx = isPassiveWithCustomSymbol || componentType === "chip" && !isMultiPinDiode && hasNonBoxSchematicSymbol(betterEasy) ? generateSymbolTsx(betterEasy, circuitJson, {
|
|
12275
|
+
// Passive primitives already create their two source ports.
|
|
12276
|
+
includePorts: !isPassiveWithCustomSymbol
|
|
12277
|
+
}) : void 0;
|
|
12208
12278
|
return generateTypescriptComponent({
|
|
12209
12279
|
componentName,
|
|
12210
12280
|
manufacturerPartNumber,
|
|
@@ -12215,6 +12285,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
12215
12285
|
supplierPartNumbers,
|
|
12216
12286
|
componentType,
|
|
12217
12287
|
capacitance: capacitance2,
|
|
12288
|
+
resistance: resistance2,
|
|
12218
12289
|
inductance: inductance2,
|
|
12219
12290
|
crystalFrequency,
|
|
12220
12291
|
crystalPinVariant,
|