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/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,
|
|
@@ -7909,7 +7910,33 @@ export const ${componentName} = (props: Omit<CapacitorProps, "capacitance">) =>
|
|
|
7909
7910
|
<capacitor
|
|
7910
7911
|
name={name}
|
|
7911
7912
|
capacitance=${JSON.stringify(capacitance2)}
|
|
7912
|
-
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
7913
|
+
${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
7914
|
+
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
7915
|
+
footprint={${footprintTsx}}
|
|
7916
|
+
${objUrl || stepUrl ? `cadModel={{
|
|
7917
|
+
${cadModelLines}
|
|
7918
|
+
}}` : ""}
|
|
7919
|
+
{...restProps}
|
|
7920
|
+
/>
|
|
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
|
+
${symbolProp} supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
7913
7940
|
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
7914
7941
|
footprint={${footprintTsx}}
|
|
7915
7942
|
${objUrl || stepUrl ? `cadModel={{
|
|
@@ -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") {
|
|
@@ -8379,7 +8443,7 @@ var generateShapeTsx = ({
|
|
|
8379
8443
|
}
|
|
8380
8444
|
return void 0;
|
|
8381
8445
|
};
|
|
8382
|
-
var generateSymbolTsx = (easyEdaJson, circuitJson) => {
|
|
8446
|
+
var generateSymbolTsx = (easyEdaJson, circuitJson, { includePorts = true } = {}) => {
|
|
8383
8447
|
const shapes = easyEdaJson.dataStr.shape;
|
|
8384
8448
|
if (shapes.length === 0) return void 0;
|
|
8385
8449
|
const headOrigin = {
|
|
@@ -8396,7 +8460,7 @@ var generateSymbolTsx = (easyEdaJson, circuitJson) => {
|
|
|
8396
8460
|
easyEdaJson,
|
|
8397
8461
|
circuitJson
|
|
8398
8462
|
);
|
|
8399
|
-
const shapeTsx = shapes.map(
|
|
8463
|
+
const shapeTsx = shapes.filter((shape) => includePorts || shape.type !== "PIN").map(
|
|
8400
8464
|
(shape) => generateShapeTsx({
|
|
8401
8465
|
shape,
|
|
8402
8466
|
origin,
|
|
@@ -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,10 +8567,15 @@ 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;
|
|
8508
|
-
const
|
|
8574
|
+
const isPassiveWithCustomSymbol = componentType === "capacitor" || componentType === "resistor";
|
|
8575
|
+
const symbolTsx = isPassiveWithCustomSymbol || componentType === "chip" && !isMultiPinDiode && hasNonBoxSchematicSymbol(betterEasy) ? generateSymbolTsx(betterEasy, circuitJson, {
|
|
8576
|
+
// Passive primitives already create their two source ports.
|
|
8577
|
+
includePorts: !isPassiveWithCustomSymbol
|
|
8578
|
+
}) : void 0;
|
|
8509
8579
|
return generateTypescriptComponent({
|
|
8510
8580
|
componentName,
|
|
8511
8581
|
manufacturerPartNumber,
|
|
@@ -8516,6 +8586,7 @@ var convertBetterEasyToTsx = async ({
|
|
|
8516
8586
|
supplierPartNumbers,
|
|
8517
8587
|
componentType,
|
|
8518
8588
|
capacitance: capacitance2,
|
|
8589
|
+
resistance: resistance2,
|
|
8519
8590
|
inductance: inductance2,
|
|
8520
8591
|
crystalFrequency,
|
|
8521
8592
|
crystalPinVariant,
|