@tscircuit/cli 0.1.1920 → 0.1.1921
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/cli/main.js +126 -7
- package/dist/lib/index.js +2 -2
- package/package.json +2 -2
package/dist/cli/main.js
CHANGED
|
@@ -136044,7 +136044,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
|
|
|
136044
136044
|
// lib/getVersion.ts
|
|
136045
136045
|
import { createRequire as createRequire2 } from "node:module";
|
|
136046
136046
|
// package.json
|
|
136047
|
-
var version = "0.1.
|
|
136047
|
+
var version = "0.1.1920";
|
|
136048
136048
|
var package_default = {
|
|
136049
136049
|
name: "@tscircuit/cli",
|
|
136050
136050
|
version,
|
|
@@ -136105,7 +136105,7 @@ var package_default = {
|
|
|
136105
136105
|
debug: "^4.4.0",
|
|
136106
136106
|
delay: "^6.0.0",
|
|
136107
136107
|
"dsn-converter": "^0.0.90",
|
|
136108
|
-
easyeda: "^0.0.
|
|
136108
|
+
easyeda: "^0.0.296",
|
|
136109
136109
|
"fuse.js": "^7.1.0",
|
|
136110
136110
|
"get-port": "^7.1.0",
|
|
136111
136111
|
globby: "^14.1.0",
|
|
@@ -328489,6 +328489,8 @@ var generateTypescriptComponent = ({
|
|
|
328489
328489
|
supplierPartNumbers,
|
|
328490
328490
|
manufacturerPartNumber,
|
|
328491
328491
|
componentType = "chip",
|
|
328492
|
+
capacitance: capacitance22,
|
|
328493
|
+
resistance: resistance22,
|
|
328492
328494
|
inductance: inductance22,
|
|
328493
328495
|
crystalFrequency,
|
|
328494
328496
|
crystalPinVariant,
|
|
@@ -328626,6 +328628,58 @@ ${cadModelLines}
|
|
|
328626
328628
|
/>
|
|
328627
328629
|
)
|
|
328628
328630
|
}
|
|
328631
|
+
`.trim();
|
|
328632
|
+
}
|
|
328633
|
+
if (componentType === "capacitor") {
|
|
328634
|
+
if (!capacitance22) {
|
|
328635
|
+
throw new Error("Capacitance is required for capacitor components");
|
|
328636
|
+
}
|
|
328637
|
+
return `
|
|
328638
|
+
import type { CapacitorProps } from "@tscircuit/props"
|
|
328639
|
+
|
|
328640
|
+
export const ${componentName} = (props: Omit<CapacitorProps, "capacitance">) => {
|
|
328641
|
+
const { name = "C1", ...restProps } = props
|
|
328642
|
+
|
|
328643
|
+
return (
|
|
328644
|
+
<capacitor
|
|
328645
|
+
name={name}
|
|
328646
|
+
capacitance=${JSON.stringify(capacitance22)}
|
|
328647
|
+
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
328648
|
+
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
328649
|
+
footprint={${footprintTsx}}
|
|
328650
|
+
${objUrl || stepUrl ? `cadModel={{
|
|
328651
|
+
${cadModelLines}
|
|
328652
|
+
}}` : ""}
|
|
328653
|
+
{...restProps}
|
|
328654
|
+
/>
|
|
328655
|
+
)
|
|
328656
|
+
}
|
|
328657
|
+
`.trim();
|
|
328658
|
+
}
|
|
328659
|
+
if (componentType === "resistor") {
|
|
328660
|
+
if (!resistance22) {
|
|
328661
|
+
throw new Error("Resistance is required for resistor components");
|
|
328662
|
+
}
|
|
328663
|
+
return `
|
|
328664
|
+
import type { ResistorProps } from "@tscircuit/props"
|
|
328665
|
+
|
|
328666
|
+
export const ${componentName} = (props: Omit<ResistorProps, "resistance">) => {
|
|
328667
|
+
const { name = "R1", ...restProps } = props
|
|
328668
|
+
|
|
328669
|
+
return (
|
|
328670
|
+
<resistor
|
|
328671
|
+
name={name}
|
|
328672
|
+
resistance=${JSON.stringify(resistance22)}
|
|
328673
|
+
supplierPartNumbers={${JSON.stringify(supplierPartNumbers, null, " ")}}
|
|
328674
|
+
manufacturerPartNumber="${manufacturerPartNumber}"
|
|
328675
|
+
footprint={${footprintTsx}}
|
|
328676
|
+
${objUrl || stepUrl ? `cadModel={{
|
|
328677
|
+
${cadModelLines}
|
|
328678
|
+
}}` : ""}
|
|
328679
|
+
{...restProps}
|
|
328680
|
+
/>
|
|
328681
|
+
)
|
|
328682
|
+
}
|
|
328629
328683
|
`.trim();
|
|
328630
328684
|
}
|
|
328631
328685
|
if (componentType === "inductor") {
|
|
@@ -328727,6 +328781,21 @@ ${cadModelLines}
|
|
|
328727
328781
|
}
|
|
328728
328782
|
`.trim();
|
|
328729
328783
|
};
|
|
328784
|
+
var capacitancePattern = /^\d+(?:\.\d+)?\s*(?:pF|nF|[uµμ]F|mF|F)$/i;
|
|
328785
|
+
var normalizeCapacitanceValue = (value) => {
|
|
328786
|
+
if (typeof value !== "string")
|
|
328787
|
+
return;
|
|
328788
|
+
const trimmedValue = value.trim();
|
|
328789
|
+
if (!capacitancePattern.test(trimmedValue))
|
|
328790
|
+
return;
|
|
328791
|
+
return trimmedValue.replace(/\s+/g, "").replace(/[µμ]/g, "u");
|
|
328792
|
+
};
|
|
328793
|
+
var isCapacitorComponent = (betterEasy) => {
|
|
328794
|
+
const componentParameters = betterEasy.dataStr.head.c_para;
|
|
328795
|
+
const prefix = componentParameters.pre;
|
|
328796
|
+
const value = componentParameters.Value;
|
|
328797
|
+
return prefix?.toUpperCase() === "C?" && normalizeCapacitanceValue(value) !== undefined;
|
|
328798
|
+
};
|
|
328730
328799
|
var frequencyPattern = /^\d+(?:\.\d+)?\s*(?:Hz|kHz|MHz|GHz)$/i;
|
|
328731
328800
|
var isCrystalComponent = (betterEasy) => {
|
|
328732
328801
|
const componentParameters = betterEasy.dataStr.head.c_para;
|
|
@@ -328772,6 +328841,47 @@ var isPushbuttonCategoryComponent = (betterEasy) => {
|
|
|
328772
328841
|
betterEasy.category
|
|
328773
328842
|
].some(categoryValueContainsPushbutton);
|
|
328774
328843
|
};
|
|
328844
|
+
var standardSmdResistorPackagePattern = /^R(?:01005|0201|0402|0504|0603|0805|1206|1210|1812|2010|2512)(?:$|[_-])/i;
|
|
328845
|
+
var normalizeExplicitScale = (scale23) => {
|
|
328846
|
+
if (scale23 === "k" || scale23 === "K")
|
|
328847
|
+
return "k";
|
|
328848
|
+
if (scale23 === "m")
|
|
328849
|
+
return "m";
|
|
328850
|
+
if (scale23 === "M")
|
|
328851
|
+
return "M";
|
|
328852
|
+
if (scale23 === "g" || scale23 === "G")
|
|
328853
|
+
return "G";
|
|
328854
|
+
return "";
|
|
328855
|
+
};
|
|
328856
|
+
var normalizeResistorValue = (value) => {
|
|
328857
|
+
if (typeof value !== "string")
|
|
328858
|
+
return;
|
|
328859
|
+
const compactValue = value.trim().replace(/\s+/g, "");
|
|
328860
|
+
const explicitUnitMatch = compactValue.match(/^(\d+(?:\.\d+)?)([mMkKgG]?)(?:Ω|ohms?)$/i);
|
|
328861
|
+
if (explicitUnitMatch) {
|
|
328862
|
+
const [, magnitude, scale23] = explicitUnitMatch;
|
|
328863
|
+
if (Number(magnitude) === 0)
|
|
328864
|
+
return "0ohm";
|
|
328865
|
+
return `${magnitude}${normalizeExplicitScale(scale23)}ohm`;
|
|
328866
|
+
}
|
|
328867
|
+
const resistorCodeMatch = compactValue.match(/^(\d+)([RrKkMm])(\d*)$/);
|
|
328868
|
+
if (resistorCodeMatch) {
|
|
328869
|
+
const [, whole, multiplier, fraction] = resistorCodeMatch;
|
|
328870
|
+
const magnitude = fraction ? `${whole}.${fraction}` : whole;
|
|
328871
|
+
if (Number(magnitude) === 0)
|
|
328872
|
+
return "0ohm";
|
|
328873
|
+
const scale23 = multiplier === "R" || multiplier === "r" ? "" : multiplier === "K" || multiplier === "k" ? "k" : "M";
|
|
328874
|
+
return `${magnitude}${scale23}ohm`;
|
|
328875
|
+
}
|
|
328876
|
+
if (/^0+(?:\.0+)?$/.test(compactValue))
|
|
328877
|
+
return "0ohm";
|
|
328878
|
+
return;
|
|
328879
|
+
};
|
|
328880
|
+
var isResistorComponent = (betterEasy) => {
|
|
328881
|
+
const componentParameters = betterEasy.dataStr.head.c_para;
|
|
328882
|
+
const packageName = componentParameters.package;
|
|
328883
|
+
return componentParameters.pre?.toUpperCase() === "R?" && typeof packageName === "string" && standardSmdResistorPackagePattern.test(packageName.trim()) && normalizeResistorValue(componentParameters.Value) !== undefined;
|
|
328884
|
+
};
|
|
328775
328885
|
var categoryValueContainsSwitch = (value) => {
|
|
328776
328886
|
if (typeof value === "string") {
|
|
328777
328887
|
const normalized = value.toLowerCase();
|
|
@@ -329076,15 +329186,19 @@ var hasNonBoxSchematicSymbol = (easyEdaJson) => {
|
|
|
329076
329186
|
const onlyBoxPrimitives = drawableShapes.every((shape) => shape.type === "RECTANGLE" || shape.type === "ELLIPSE" && shape.radiusX <= 2 && shape.radiusY <= 2);
|
|
329077
329187
|
return rectangles.length !== 1 || !onlyBoxPrimitives;
|
|
329078
329188
|
};
|
|
329079
|
-
var getGeneratedComponentType = (betterEasy) => {
|
|
329080
|
-
if (isLedCategoryComponent(betterEasy))
|
|
329189
|
+
var getGeneratedComponentType = (betterEasy, pinCount) => {
|
|
329190
|
+
if (isLedCategoryComponent(betterEasy) && pinCount === 2)
|
|
329081
329191
|
return "led";
|
|
329082
|
-
if (isDiodeCategoryComponent(betterEasy))
|
|
329192
|
+
if (isDiodeCategoryComponent(betterEasy) && pinCount === 2)
|
|
329083
329193
|
return "diode";
|
|
329084
329194
|
if (isPushbuttonCategoryComponent(betterEasy))
|
|
329085
329195
|
return "pushbutton";
|
|
329086
329196
|
if (isSwitchCategoryComponent(betterEasy))
|
|
329087
329197
|
return "switch";
|
|
329198
|
+
if (isCapacitorComponent(betterEasy))
|
|
329199
|
+
return "capacitor";
|
|
329200
|
+
if (isResistorComponent(betterEasy) && pinCount === 2)
|
|
329201
|
+
return "resistor";
|
|
329088
329202
|
if (isInductorComponent(betterEasy))
|
|
329089
329203
|
return "inductor";
|
|
329090
329204
|
if (isCrystalComponent(betterEasy))
|
|
@@ -329151,11 +329265,14 @@ var convertBetterEasyToTsx = async ({
|
|
|
329151
329265
|
const supplierPartNumbers = {
|
|
329152
329266
|
jlcpcb: [betterEasy.lcsc.number]
|
|
329153
329267
|
};
|
|
329154
|
-
const componentType = getGeneratedComponentType(betterEasy);
|
|
329268
|
+
const componentType = getGeneratedComponentType(betterEasy, sourcePorts.length);
|
|
329155
329269
|
const inductance22 = componentType === "inductor" ? betterEasy.dataStr.head.c_para.Value?.trim() : undefined;
|
|
329270
|
+
const capacitance22 = componentType === "capacitor" ? normalizeCapacitanceValue(betterEasy.dataStr.head.c_para.Value) : undefined;
|
|
329271
|
+
const resistance22 = componentType === "resistor" ? normalizeResistorValue(betterEasy.dataStr.head.c_para.Value) : undefined;
|
|
329156
329272
|
const crystalFrequency = componentType === "crystal" ? betterEasy.dataStr.head.c_para.Value?.trim() : undefined;
|
|
329157
329273
|
const crystalPinVariant = componentType !== "crystal" ? undefined : sourcePorts.length === 4 ? "four_pin" : sourcePorts.length === 2 ? "two_pin" : undefined;
|
|
329158
|
-
const
|
|
329274
|
+
const isMultiPinDiode = isDiodeCategoryComponent(betterEasy) && sourcePorts.length !== 2;
|
|
329275
|
+
const symbolTsx = componentType === "chip" && !isMultiPinDiode && hasNonBoxSchematicSymbol(betterEasy) ? generateSymbolTsx2(betterEasy, circuitJson) : undefined;
|
|
329159
329276
|
return generateTypescriptComponent({
|
|
329160
329277
|
componentName,
|
|
329161
329278
|
manufacturerPartNumber,
|
|
@@ -329165,6 +329282,8 @@ var convertBetterEasyToTsx = async ({
|
|
|
329165
329282
|
circuitJson,
|
|
329166
329283
|
supplierPartNumbers,
|
|
329167
329284
|
componentType,
|
|
329285
|
+
capacitance: capacitance22,
|
|
329286
|
+
resistance: resistance22,
|
|
329168
329287
|
inductance: inductance22,
|
|
329169
329288
|
crystalFrequency,
|
|
329170
329289
|
crystalPinVariant,
|
package/dist/lib/index.js
CHANGED
|
@@ -65757,7 +65757,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
65757
65757
|
}));
|
|
65758
65758
|
};
|
|
65759
65759
|
// package.json
|
|
65760
|
-
var version = "0.1.
|
|
65760
|
+
var version = "0.1.1920";
|
|
65761
65761
|
var package_default = {
|
|
65762
65762
|
name: "@tscircuit/cli",
|
|
65763
65763
|
version,
|
|
@@ -65818,7 +65818,7 @@ var package_default = {
|
|
|
65818
65818
|
debug: "^4.4.0",
|
|
65819
65819
|
delay: "^6.0.0",
|
|
65820
65820
|
"dsn-converter": "^0.0.90",
|
|
65821
|
-
easyeda: "^0.0.
|
|
65821
|
+
easyeda: "^0.0.296",
|
|
65822
65822
|
"fuse.js": "^7.1.0",
|
|
65823
65823
|
"get-port": "^7.1.0",
|
|
65824
65824
|
globby: "^14.1.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1921",
|
|
4
4
|
"main": "dist/cli/main.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/cli/main.js",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"debug": "^4.4.0",
|
|
59
59
|
"delay": "^6.0.0",
|
|
60
60
|
"dsn-converter": "^0.0.90",
|
|
61
|
-
"easyeda": "^0.0.
|
|
61
|
+
"easyeda": "^0.0.296",
|
|
62
62
|
"fuse.js": "^7.1.0",
|
|
63
63
|
"get-port": "^7.1.0",
|
|
64
64
|
"globby": "^14.1.0",
|