@tscircuit/cli 0.1.683 → 0.1.684
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/main.js +41 -24
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -74113,7 +74113,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
74113
74113
|
import { execSync as execSync2 } from "node:child_process";
|
|
74114
74114
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
74115
74115
|
// package.json
|
|
74116
|
-
var version = "0.1.
|
|
74116
|
+
var version = "0.1.683";
|
|
74117
74117
|
var package_default = {
|
|
74118
74118
|
name: "@tscircuit/cli",
|
|
74119
74119
|
version,
|
|
@@ -74140,7 +74140,7 @@ var package_default = {
|
|
|
74140
74140
|
chokidar: "4.0.1",
|
|
74141
74141
|
"circuit-json": "0.0.325",
|
|
74142
74142
|
"circuit-json-to-gltf": "^0.0.56",
|
|
74143
|
-
"circuit-json-to-kicad": "^0.0.
|
|
74143
|
+
"circuit-json-to-kicad": "^0.0.31",
|
|
74144
74144
|
"circuit-json-to-readable-netlist": "^0.0.13",
|
|
74145
74145
|
"circuit-json-to-spice": "^0.0.10",
|
|
74146
74146
|
"circuit-json-to-tscircuit": "^0.0.9",
|
|
@@ -81757,32 +81757,47 @@ var InitializeSchematicStage = class extends ConverterStage {
|
|
|
81757
81757
|
return this.ctx.kicadSch;
|
|
81758
81758
|
}
|
|
81759
81759
|
};
|
|
81760
|
-
function
|
|
81760
|
+
function getKicadCompatibleComponentName(sourceComponent, cadComponent) {
|
|
81761
|
+
if (sourceComponent.manufacturer_part_number) {
|
|
81762
|
+
return sanitizeName(sourceComponent.manufacturer_part_number);
|
|
81763
|
+
}
|
|
81764
|
+
const cleanType = getCleanTypeName(sourceComponent.ftype);
|
|
81765
|
+
const footprinterString = cadComponent?.footprinter_string;
|
|
81766
|
+
if (footprinterString) {
|
|
81767
|
+
return sanitizeName(`${cleanType}_${footprinterString}`);
|
|
81768
|
+
}
|
|
81769
|
+
return sanitizeName(cleanType);
|
|
81770
|
+
}
|
|
81771
|
+
function getCleanTypeName(ftype) {
|
|
81772
|
+
if (!ftype)
|
|
81773
|
+
return "component";
|
|
81774
|
+
let cleanName = ftype.replace(/^simple_/, "");
|
|
81775
|
+
if (!cleanName)
|
|
81776
|
+
return "component";
|
|
81777
|
+
return cleanName;
|
|
81778
|
+
}
|
|
81779
|
+
function sanitizeName(name) {
|
|
81780
|
+
return name.replace(/[\\\/:\s]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").trim() || "component";
|
|
81781
|
+
}
|
|
81782
|
+
function extractReferencePrefix(name) {
|
|
81783
|
+
if (!name)
|
|
81784
|
+
return "U";
|
|
81785
|
+
const match = name.match(/^([A-Za-z]+)/);
|
|
81786
|
+
return match?.[1]?.toUpperCase() ?? "U";
|
|
81787
|
+
}
|
|
81788
|
+
function getLibraryId(sourceComp, schematicComp, cadComponent) {
|
|
81761
81789
|
if (sourceComp.type !== "source_component") {
|
|
81762
81790
|
if (schematicComp.symbol_name) {
|
|
81763
81791
|
return `Custom:${schematicComp.symbol_name}`;
|
|
81764
81792
|
}
|
|
81765
81793
|
return "Device:Component";
|
|
81766
81794
|
}
|
|
81767
|
-
if (sourceComp.ftype === "simple_resistor") {
|
|
81768
|
-
return `Device:R_${sourceComp.source_component_id}`;
|
|
81769
|
-
}
|
|
81770
|
-
if (sourceComp.ftype === "simple_capacitor") {
|
|
81771
|
-
return `Device:C_${sourceComp.source_component_id}`;
|
|
81772
|
-
}
|
|
81773
|
-
if (sourceComp.ftype === "simple_inductor") {
|
|
81774
|
-
return `Device:L_${sourceComp.source_component_id}`;
|
|
81775
|
-
}
|
|
81776
|
-
if (sourceComp.ftype === "simple_diode") {
|
|
81777
|
-
return `Device:D_${sourceComp.source_component_id}`;
|
|
81778
|
-
}
|
|
81779
|
-
if (sourceComp.ftype === "simple_chip") {
|
|
81780
|
-
return `Device:U_${sourceComp.source_component_id}`;
|
|
81781
|
-
}
|
|
81782
81795
|
if (schematicComp.symbol_name) {
|
|
81783
81796
|
return `Custom:${schematicComp.symbol_name}`;
|
|
81784
81797
|
}
|
|
81785
|
-
|
|
81798
|
+
const ergonomicName = getKicadCompatibleComponentName(sourceComp, cadComponent);
|
|
81799
|
+
const refPrefix = extractReferencePrefix(sourceComp.name);
|
|
81800
|
+
return `Device:${refPrefix}_${ergonomicName}`;
|
|
81786
81801
|
}
|
|
81787
81802
|
var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
81788
81803
|
_step() {
|
|
@@ -81825,15 +81840,16 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
81825
81840
|
const sourceComp = schematicComponent.source_component_id ? db.source_component.get(schematicComponent.source_component_id) : null;
|
|
81826
81841
|
if (!sourceComp)
|
|
81827
81842
|
return null;
|
|
81843
|
+
const cadComponent = db.cad_component?.list()?.find((cad) => cad.source_component_id === sourceComp.source_component_id);
|
|
81828
81844
|
const symbolName = schematicComponent.symbol_name || (sourceComp.ftype === "simple_chip" ? `generic_chip_${schematicComponent.source_component_id}` : null);
|
|
81829
81845
|
if (!symbolName)
|
|
81830
81846
|
return null;
|
|
81831
81847
|
const symbolData = this.getSymbolData(symbolName, schematicComponent);
|
|
81832
81848
|
if (!symbolData)
|
|
81833
81849
|
return null;
|
|
81834
|
-
const libId = getLibraryId(sourceComp, schematicComponent);
|
|
81850
|
+
const libId = getLibraryId(sourceComp, schematicComponent, cadComponent);
|
|
81835
81851
|
const isChip = sourceComp.ftype === "simple_chip";
|
|
81836
|
-
const footprintName = sourceComp
|
|
81852
|
+
const footprintName = getKicadCompatibleComponentName(sourceComp, cadComponent);
|
|
81837
81853
|
return this.createLibrarySymbol({
|
|
81838
81854
|
libId,
|
|
81839
81855
|
symbolData,
|
|
@@ -82255,7 +82271,8 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
82255
82271
|
uuid,
|
|
82256
82272
|
fieldsAutoplaced: true
|
|
82257
82273
|
});
|
|
82258
|
-
const
|
|
82274
|
+
const cadComponent = db.cad_component?.list()?.find((cad) => cad.source_component_id === sourceComponent.source_component_id);
|
|
82275
|
+
const libId = getLibraryId(sourceComponent, schematicComponent, cadComponent);
|
|
82259
82276
|
const symLibId = new SymbolLibId(libId);
|
|
82260
82277
|
symbol._sxLibId = symLibId;
|
|
82261
82278
|
const { reference, value, description } = this.getComponentMetadata(sourceComponent);
|
|
@@ -83292,7 +83309,8 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
83292
83309
|
}
|
|
83293
83310
|
const component = this.pcbComponents[this.componentsProcessed];
|
|
83294
83311
|
const sourceComponent = component.source_component_id ? this.ctx.db.source_component.get(component.source_component_id) : null;
|
|
83295
|
-
const
|
|
83312
|
+
const cadComponent = this.getCadComponentForPcbComponent(component.pcb_component_id);
|
|
83313
|
+
const footprintName = sourceComponent ? getKicadCompatibleComponentName(sourceComponent, cadComponent) : "Unknown";
|
|
83296
83314
|
const transformedPos = applyToPoint92(c2kMatPcb, {
|
|
83297
83315
|
x: component.center.x,
|
|
83298
83316
|
y: component.center.y
|
|
@@ -83361,7 +83379,6 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
83361
83379
|
}
|
|
83362
83380
|
}
|
|
83363
83381
|
footprint.fpPads = fpPads;
|
|
83364
|
-
const cadComponent = this.getCadComponentForPcbComponent(component.pcb_component_id);
|
|
83365
83382
|
if (cadComponent) {
|
|
83366
83383
|
const models = this.create3DModelsFromCadComponent(cadComponent, component.center);
|
|
83367
83384
|
if (models.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.684",
|
|
4
4
|
"main": "dist/main.js",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@babel/standalone": "^7.26.9",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"chokidar": "4.0.1",
|
|
25
25
|
"circuit-json": "0.0.325",
|
|
26
26
|
"circuit-json-to-gltf": "^0.0.56",
|
|
27
|
-
"circuit-json-to-kicad": "^0.0.
|
|
27
|
+
"circuit-json-to-kicad": "^0.0.31",
|
|
28
28
|
"circuit-json-to-readable-netlist": "^0.0.13",
|
|
29
29
|
"circuit-json-to-spice": "^0.0.10",
|
|
30
30
|
"circuit-json-to-tscircuit": "^0.0.9",
|