@tscircuit/cli 0.1.670 → 0.1.672
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 +437 -37
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -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.30",
|
|
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",
|
|
@@ -81702,6 +81702,15 @@ import {
|
|
|
81702
81702
|
} from "kicadts";
|
|
81703
81703
|
import { applyToPoint as applyToPoint122 } from "transformation-matrix";
|
|
81704
81704
|
import { cju as cju3 } from "@tscircuit/circuit-json-util";
|
|
81705
|
+
import { cju as cju4 } from "@tscircuit/circuit-json-util";
|
|
81706
|
+
import { parseKicadSexpr, KicadSch as KicadSch2 } from "kicadts";
|
|
81707
|
+
import {
|
|
81708
|
+
parseKicadSexpr as parseKicadSexpr2,
|
|
81709
|
+
KicadPcb as KicadPcb2,
|
|
81710
|
+
FootprintModel as FootprintModel2,
|
|
81711
|
+
At as At2
|
|
81712
|
+
} from "kicadts";
|
|
81713
|
+
import { KicadSymbolLib } from "kicadts";
|
|
81705
81714
|
var ConverterStage = class {
|
|
81706
81715
|
MAX_ITERATIONS = 1000;
|
|
81707
81716
|
iteration = 0;
|
|
@@ -83741,6 +83750,311 @@ var CircuitJsonToKicadPcbConverter = class {
|
|
|
83741
83750
|
return this.ctx.kicadPcb.getString();
|
|
83742
83751
|
}
|
|
83743
83752
|
};
|
|
83753
|
+
var GenerateKicadSchAndPcbStage = class extends ConverterStage {
|
|
83754
|
+
_step() {
|
|
83755
|
+
const schConverter = new CircuitJsonToKicadSchConverter(this.ctx.circuitJson);
|
|
83756
|
+
schConverter.runUntilFinished();
|
|
83757
|
+
this.ctx.kicadSchString = schConverter.getOutputString();
|
|
83758
|
+
const pcbConverter = new CircuitJsonToKicadPcbConverter(this.ctx.circuitJson);
|
|
83759
|
+
pcbConverter.runUntilFinished();
|
|
83760
|
+
this.ctx.kicadPcbString = pcbConverter.getOutputString();
|
|
83761
|
+
this.finished = true;
|
|
83762
|
+
}
|
|
83763
|
+
getOutput() {
|
|
83764
|
+
return this.ctx.libraryOutput;
|
|
83765
|
+
}
|
|
83766
|
+
};
|
|
83767
|
+
var ExtractSymbolsStage = class extends ConverterStage {
|
|
83768
|
+
_step() {
|
|
83769
|
+
const schContent = this.ctx.kicadSchString;
|
|
83770
|
+
const fpLibraryName = this.ctx.fpLibraryName ?? "tscircuit";
|
|
83771
|
+
if (!schContent) {
|
|
83772
|
+
throw new Error("Schematic content not available. Run GenerateKicadSchAndPcbStage first.");
|
|
83773
|
+
}
|
|
83774
|
+
const uniqueSymbols = /* @__PURE__ */ new Map;
|
|
83775
|
+
try {
|
|
83776
|
+
const parsed = parseKicadSexpr(schContent);
|
|
83777
|
+
const sch = parsed.find((node) => node instanceof KicadSch2);
|
|
83778
|
+
if (!sch) {
|
|
83779
|
+
this.ctx.symbolEntries = [];
|
|
83780
|
+
this.finished = true;
|
|
83781
|
+
return;
|
|
83782
|
+
}
|
|
83783
|
+
const libSymbols = sch.libSymbols;
|
|
83784
|
+
if (!libSymbols) {
|
|
83785
|
+
this.ctx.symbolEntries = [];
|
|
83786
|
+
this.finished = true;
|
|
83787
|
+
return;
|
|
83788
|
+
}
|
|
83789
|
+
const symbols3 = libSymbols.symbols ?? [];
|
|
83790
|
+
for (const symbol of symbols3) {
|
|
83791
|
+
const symbolName = this.sanitizeSymbolName(symbol.libraryId);
|
|
83792
|
+
if (!uniqueSymbols.has(symbolName)) {
|
|
83793
|
+
symbol.libraryId = symbolName;
|
|
83794
|
+
this.updateFootprintProperty(symbol, fpLibraryName);
|
|
83795
|
+
uniqueSymbols.set(symbolName, {
|
|
83796
|
+
symbolName,
|
|
83797
|
+
symbol
|
|
83798
|
+
});
|
|
83799
|
+
}
|
|
83800
|
+
}
|
|
83801
|
+
} catch (error) {
|
|
83802
|
+
console.warn("Failed to parse schematic for symbol extraction:", error);
|
|
83803
|
+
}
|
|
83804
|
+
this.ctx.symbolEntries = Array.from(uniqueSymbols.values());
|
|
83805
|
+
this.finished = true;
|
|
83806
|
+
}
|
|
83807
|
+
updateFootprintProperty(symbol, fpLibraryName) {
|
|
83808
|
+
const properties = symbol.properties ?? [];
|
|
83809
|
+
for (const prop of properties) {
|
|
83810
|
+
if (prop.key === "Footprint" && prop.value) {
|
|
83811
|
+
const parts = prop.value.split(":");
|
|
83812
|
+
if (parts.length > 1) {
|
|
83813
|
+
prop.value = `${fpLibraryName}:${parts[1]}`;
|
|
83814
|
+
} else if (prop.value.trim()) {
|
|
83815
|
+
prop.value = `${fpLibraryName}:${prop.value}`;
|
|
83816
|
+
}
|
|
83817
|
+
}
|
|
83818
|
+
}
|
|
83819
|
+
}
|
|
83820
|
+
sanitizeSymbolName(libraryId) {
|
|
83821
|
+
if (!libraryId)
|
|
83822
|
+
return "symbol";
|
|
83823
|
+
const parts = libraryId.split(":");
|
|
83824
|
+
const name = parts.length > 1 ? parts[1] : parts[0];
|
|
83825
|
+
return name?.replace(/[\\\/]/g, "-").trim() || "symbol";
|
|
83826
|
+
}
|
|
83827
|
+
getOutput() {
|
|
83828
|
+
return this.ctx.libraryOutput;
|
|
83829
|
+
}
|
|
83830
|
+
};
|
|
83831
|
+
function getBasename(filePath) {
|
|
83832
|
+
const parts = filePath.split(/[/\\]/);
|
|
83833
|
+
return parts[parts.length - 1] || filePath;
|
|
83834
|
+
}
|
|
83835
|
+
var ExtractFootprintsStage = class extends ConverterStage {
|
|
83836
|
+
_step() {
|
|
83837
|
+
const kicadPcbString = this.ctx.kicadPcbString;
|
|
83838
|
+
const fpLibraryName = this.ctx.fpLibraryName ?? "tscircuit";
|
|
83839
|
+
if (!kicadPcbString) {
|
|
83840
|
+
throw new Error("PCB content not available. Run GenerateKicadSchAndPcbStage first.");
|
|
83841
|
+
}
|
|
83842
|
+
const uniqueFootprints = /* @__PURE__ */ new Map;
|
|
83843
|
+
try {
|
|
83844
|
+
const parsed = parseKicadSexpr2(kicadPcbString);
|
|
83845
|
+
const pcb = parsed.find((node) => node instanceof KicadPcb2);
|
|
83846
|
+
if (!pcb) {
|
|
83847
|
+
this.ctx.footprintEntries = [];
|
|
83848
|
+
this.finished = true;
|
|
83849
|
+
return;
|
|
83850
|
+
}
|
|
83851
|
+
const footprints = pcb.footprints ?? [];
|
|
83852
|
+
for (const footprint of footprints) {
|
|
83853
|
+
const sanitized = this.sanitizeFootprint(footprint, fpLibraryName);
|
|
83854
|
+
if (!uniqueFootprints.has(sanitized.footprintName)) {
|
|
83855
|
+
uniqueFootprints.set(sanitized.footprintName, sanitized);
|
|
83856
|
+
}
|
|
83857
|
+
}
|
|
83858
|
+
} catch (error) {
|
|
83859
|
+
console.warn("Failed to parse PCB for footprint extraction:", error);
|
|
83860
|
+
}
|
|
83861
|
+
this.ctx.footprintEntries = Array.from(uniqueFootprints.values());
|
|
83862
|
+
this.finished = true;
|
|
83863
|
+
}
|
|
83864
|
+
sanitizeFootprint(footprint, fpLibraryName) {
|
|
83865
|
+
const libraryLink = footprint.libraryLink ?? "footprint";
|
|
83866
|
+
const parts = libraryLink.split(":");
|
|
83867
|
+
const footprintName = (parts.length > 1 ? parts[1] : parts[0])?.replace(/[\\\/]/g, "-").trim() || "footprint";
|
|
83868
|
+
footprint.libraryLink = footprintName;
|
|
83869
|
+
footprint.position = At2.from([0, 0, 0]);
|
|
83870
|
+
footprint.locked = false;
|
|
83871
|
+
footprint.placed = false;
|
|
83872
|
+
footprint.uuid = undefined;
|
|
83873
|
+
footprint.path = undefined;
|
|
83874
|
+
footprint.sheetfile = undefined;
|
|
83875
|
+
footprint.sheetname = undefined;
|
|
83876
|
+
footprint.properties = [];
|
|
83877
|
+
const texts = footprint.fpTexts ?? [];
|
|
83878
|
+
for (const text of texts) {
|
|
83879
|
+
text.uuid = undefined;
|
|
83880
|
+
if (text.type === "reference") {
|
|
83881
|
+
text.text = "REF**";
|
|
83882
|
+
} else if (text.type === "value" && text.text.trim().length === 0) {
|
|
83883
|
+
text.text = footprintName;
|
|
83884
|
+
}
|
|
83885
|
+
}
|
|
83886
|
+
footprint.fpTexts = texts;
|
|
83887
|
+
const pads = footprint.fpPads ?? [];
|
|
83888
|
+
for (const pad of pads) {
|
|
83889
|
+
pad.uuid = undefined;
|
|
83890
|
+
pad.net = undefined;
|
|
83891
|
+
}
|
|
83892
|
+
footprint.fpPads = pads;
|
|
83893
|
+
const models = footprint.models ?? [];
|
|
83894
|
+
const updatedModels = [];
|
|
83895
|
+
const modelFiles = [];
|
|
83896
|
+
for (const model of models) {
|
|
83897
|
+
if (model.path) {
|
|
83898
|
+
const modelFilename = getBasename(model.path);
|
|
83899
|
+
const newPath = `\${KIPRJMOD}/${fpLibraryName}.3dshapes/${modelFilename}`;
|
|
83900
|
+
const newModel = new FootprintModel2(newPath);
|
|
83901
|
+
if (model.offset)
|
|
83902
|
+
newModel.offset = model.offset;
|
|
83903
|
+
if (model.scale)
|
|
83904
|
+
newModel.scale = model.scale;
|
|
83905
|
+
if (model.rotate)
|
|
83906
|
+
newModel.rotate = model.rotate;
|
|
83907
|
+
updatedModels.push(newModel);
|
|
83908
|
+
modelFiles.push(model.path);
|
|
83909
|
+
}
|
|
83910
|
+
}
|
|
83911
|
+
footprint.models = updatedModels;
|
|
83912
|
+
return {
|
|
83913
|
+
footprintName,
|
|
83914
|
+
kicadModString: footprint.getString(),
|
|
83915
|
+
model3dSourcePaths: modelFiles
|
|
83916
|
+
};
|
|
83917
|
+
}
|
|
83918
|
+
getOutput() {
|
|
83919
|
+
return this.ctx.libraryOutput;
|
|
83920
|
+
}
|
|
83921
|
+
};
|
|
83922
|
+
var KICAD_SYM_LIB_VERSION = 20211014;
|
|
83923
|
+
var GENERATOR = "circuit-json-to-kicad";
|
|
83924
|
+
var GenerateSymbolLibraryStage = class extends ConverterStage {
|
|
83925
|
+
_step() {
|
|
83926
|
+
const symbolEntries = this.ctx.symbolEntries ?? [];
|
|
83927
|
+
const symbolLibrary = this.generateSymbolLibrary(symbolEntries);
|
|
83928
|
+
if (!this.ctx.libraryOutput) {
|
|
83929
|
+
this.ctx.libraryOutput = {
|
|
83930
|
+
kicadSymString: "",
|
|
83931
|
+
footprints: [],
|
|
83932
|
+
fpLibTableString: "",
|
|
83933
|
+
symLibTableString: "",
|
|
83934
|
+
model3dSourcePaths: []
|
|
83935
|
+
};
|
|
83936
|
+
}
|
|
83937
|
+
this.ctx.libraryOutput.kicadSymString = symbolLibrary;
|
|
83938
|
+
this.finished = true;
|
|
83939
|
+
}
|
|
83940
|
+
generateSymbolLibrary(symbolEntries) {
|
|
83941
|
+
const symbolLib = new KicadSymbolLib({
|
|
83942
|
+
version: KICAD_SYM_LIB_VERSION,
|
|
83943
|
+
generator: GENERATOR,
|
|
83944
|
+
symbols: symbolEntries.map((entry) => entry.symbol)
|
|
83945
|
+
});
|
|
83946
|
+
return symbolLib.getString();
|
|
83947
|
+
}
|
|
83948
|
+
getOutput() {
|
|
83949
|
+
return this.ctx.libraryOutput;
|
|
83950
|
+
}
|
|
83951
|
+
};
|
|
83952
|
+
var GenerateLibraryTablesStage = class extends ConverterStage {
|
|
83953
|
+
_step() {
|
|
83954
|
+
const libraryName = this.ctx.libraryName ?? "tscircuit";
|
|
83955
|
+
const fpLibraryName = this.ctx.fpLibraryName ?? "tscircuit";
|
|
83956
|
+
const footprintEntries = this.ctx.footprintEntries ?? [];
|
|
83957
|
+
const model3dSourcePathsSet = /* @__PURE__ */ new Set;
|
|
83958
|
+
for (const fp of footprintEntries) {
|
|
83959
|
+
for (const modelPath of fp.model3dSourcePaths) {
|
|
83960
|
+
model3dSourcePathsSet.add(modelPath);
|
|
83961
|
+
}
|
|
83962
|
+
}
|
|
83963
|
+
const fpLibTableString = this.generateFpLibTable(fpLibraryName);
|
|
83964
|
+
const symLibTableString = this.generateSymLibTable(libraryName);
|
|
83965
|
+
if (!this.ctx.libraryOutput) {
|
|
83966
|
+
this.ctx.libraryOutput = {
|
|
83967
|
+
kicadSymString: "",
|
|
83968
|
+
footprints: [],
|
|
83969
|
+
fpLibTableString: "",
|
|
83970
|
+
symLibTableString: "",
|
|
83971
|
+
model3dSourcePaths: []
|
|
83972
|
+
};
|
|
83973
|
+
}
|
|
83974
|
+
this.ctx.libraryOutput.footprints = footprintEntries;
|
|
83975
|
+
this.ctx.libraryOutput.fpLibTableString = fpLibTableString;
|
|
83976
|
+
this.ctx.libraryOutput.symLibTableString = symLibTableString;
|
|
83977
|
+
this.ctx.libraryOutput.model3dSourcePaths = Array.from(model3dSourcePathsSet);
|
|
83978
|
+
this.finished = true;
|
|
83979
|
+
}
|
|
83980
|
+
generateFpLibTable(fpLibraryName) {
|
|
83981
|
+
return `(fp_lib_table
|
|
83982
|
+
(version 7)
|
|
83983
|
+
(lib (name "${fpLibraryName}") (type "KiCad") (uri "\${KIPRJMOD}/${fpLibraryName}.pretty") (options "") (descr "Generated by circuit-json-to-kicad"))
|
|
83984
|
+
)
|
|
83985
|
+
`;
|
|
83986
|
+
}
|
|
83987
|
+
generateSymLibTable(libraryName) {
|
|
83988
|
+
return `(sym_lib_table
|
|
83989
|
+
(version 7)
|
|
83990
|
+
(lib (name "${libraryName}") (type "KiCad") (uri "\${KIPRJMOD}/${libraryName}.kicad_sym") (options "") (descr "Generated by circuit-json-to-kicad"))
|
|
83991
|
+
)
|
|
83992
|
+
`;
|
|
83993
|
+
}
|
|
83994
|
+
getOutput() {
|
|
83995
|
+
return this.ctx.libraryOutput;
|
|
83996
|
+
}
|
|
83997
|
+
};
|
|
83998
|
+
var CircuitJsonToKicadLibraryConverter = class {
|
|
83999
|
+
ctx;
|
|
84000
|
+
pipeline;
|
|
84001
|
+
currentStageIndex = 0;
|
|
84002
|
+
finished = false;
|
|
84003
|
+
get currentStage() {
|
|
84004
|
+
return this.pipeline[this.currentStageIndex];
|
|
84005
|
+
}
|
|
84006
|
+
constructor(circuitJson, options = {}) {
|
|
84007
|
+
this.ctx = {
|
|
84008
|
+
db: cju4(circuitJson),
|
|
84009
|
+
circuitJson,
|
|
84010
|
+
libraryName: options.libraryName ?? "tscircuit",
|
|
84011
|
+
fpLibraryName: options.footprintLibraryName ?? "tscircuit"
|
|
84012
|
+
};
|
|
84013
|
+
this.pipeline = [
|
|
84014
|
+
new GenerateKicadSchAndPcbStage(circuitJson, this.ctx),
|
|
84015
|
+
new ExtractSymbolsStage(circuitJson, this.ctx),
|
|
84016
|
+
new ExtractFootprintsStage(circuitJson, this.ctx),
|
|
84017
|
+
new GenerateSymbolLibraryStage(circuitJson, this.ctx),
|
|
84018
|
+
new GenerateLibraryTablesStage(circuitJson, this.ctx)
|
|
84019
|
+
];
|
|
84020
|
+
}
|
|
84021
|
+
step() {
|
|
84022
|
+
if (!this.currentStage) {
|
|
84023
|
+
this.finished = true;
|
|
84024
|
+
return;
|
|
84025
|
+
}
|
|
84026
|
+
this.currentStage.step();
|
|
84027
|
+
if (this.currentStage.finished) {
|
|
84028
|
+
this.currentStageIndex++;
|
|
84029
|
+
}
|
|
84030
|
+
}
|
|
84031
|
+
runUntilFinished() {
|
|
84032
|
+
while (!this.finished) {
|
|
84033
|
+
this.step();
|
|
84034
|
+
}
|
|
84035
|
+
}
|
|
84036
|
+
getOutput() {
|
|
84037
|
+
if (!this.ctx.libraryOutput) {
|
|
84038
|
+
throw new Error("Converter has not been run yet");
|
|
84039
|
+
}
|
|
84040
|
+
return this.ctx.libraryOutput;
|
|
84041
|
+
}
|
|
84042
|
+
getSymbolLibraryString() {
|
|
84043
|
+
return this.getOutput().kicadSymString;
|
|
84044
|
+
}
|
|
84045
|
+
getFootprints() {
|
|
84046
|
+
return this.getOutput().footprints;
|
|
84047
|
+
}
|
|
84048
|
+
getFpLibTableString() {
|
|
84049
|
+
return this.getOutput().fpLibTableString;
|
|
84050
|
+
}
|
|
84051
|
+
getSymLibTableString() {
|
|
84052
|
+
return this.getOutput().symLibTableString;
|
|
84053
|
+
}
|
|
84054
|
+
getModel3dSourcePaths() {
|
|
84055
|
+
return this.getOutput().model3dSourcePaths;
|
|
84056
|
+
}
|
|
84057
|
+
};
|
|
83744
84058
|
|
|
83745
84059
|
// lib/shared/export-snippet.ts
|
|
83746
84060
|
var import_jszip2 = __toESM2(require_lib4(), 1);
|
|
@@ -83877,7 +84191,12 @@ async function generateCircuitJson({
|
|
|
83877
84191
|
// cli/build/generate-kicad-footprint-library.ts
|
|
83878
84192
|
import fs27 from "node:fs";
|
|
83879
84193
|
import path29 from "node:path";
|
|
83880
|
-
import {
|
|
84194
|
+
import {
|
|
84195
|
+
At as At3,
|
|
84196
|
+
KicadPcb as KicadPcb3,
|
|
84197
|
+
parseKicadSexpr as parseKicadSexpr3,
|
|
84198
|
+
FootprintModel as FootprintModel3
|
|
84199
|
+
} from "kicadts";
|
|
83881
84200
|
var sanitizeLibraryAndFootprintName = (libraryLink) => {
|
|
83882
84201
|
if (!libraryLink) {
|
|
83883
84202
|
return {
|
|
@@ -83899,10 +84218,11 @@ var sanitizeLibraryAndFootprintName = (libraryLink) => {
|
|
|
83899
84218
|
footprintName
|
|
83900
84219
|
};
|
|
83901
84220
|
};
|
|
83902
|
-
var sanitizeFootprint = (footprint) => {
|
|
84221
|
+
var sanitizeFootprint = (footprint, outputLibraryName) => {
|
|
83903
84222
|
const { libraryName, footprintName } = sanitizeLibraryAndFootprintName(footprint.libraryLink);
|
|
84223
|
+
const targetLibraryName = outputLibraryName || libraryName;
|
|
83904
84224
|
footprint.libraryLink = footprintName;
|
|
83905
|
-
footprint.position =
|
|
84225
|
+
footprint.position = At3.from([0, 0, 0]);
|
|
83906
84226
|
footprint.locked = false;
|
|
83907
84227
|
footprint.placed = false;
|
|
83908
84228
|
footprint.uuid = undefined;
|
|
@@ -83926,10 +84246,30 @@ var sanitizeFootprint = (footprint) => {
|
|
|
83926
84246
|
pad.net = undefined;
|
|
83927
84247
|
}
|
|
83928
84248
|
footprint.fpPads = pads;
|
|
84249
|
+
const models = footprint.models ?? [];
|
|
84250
|
+
const updatedModels = [];
|
|
84251
|
+
const modelFiles = [];
|
|
84252
|
+
for (const model of models) {
|
|
84253
|
+
if (model.path) {
|
|
84254
|
+
const modelFilename = path29.basename(model.path);
|
|
84255
|
+
const newPath = `\${KIPRJMOD}/${targetLibraryName}.3dshapes/${modelFilename}`;
|
|
84256
|
+
const newModel = new FootprintModel3(newPath);
|
|
84257
|
+
if (model.offset)
|
|
84258
|
+
newModel.offset = model.offset;
|
|
84259
|
+
if (model.scale)
|
|
84260
|
+
newModel.scale = model.scale;
|
|
84261
|
+
if (model.rotate)
|
|
84262
|
+
newModel.rotate = model.rotate;
|
|
84263
|
+
updatedModels.push(newModel);
|
|
84264
|
+
modelFiles.push(model.path);
|
|
84265
|
+
}
|
|
84266
|
+
}
|
|
84267
|
+
footprint.models = updatedModels;
|
|
83929
84268
|
return {
|
|
83930
84269
|
libraryName,
|
|
83931
84270
|
footprintName,
|
|
83932
|
-
content: footprint.getString()
|
|
84271
|
+
content: footprint.getString(),
|
|
84272
|
+
modelFiles
|
|
83933
84273
|
};
|
|
83934
84274
|
};
|
|
83935
84275
|
var generateKicadFootprintLibrary = async ({
|
|
@@ -83941,8 +84281,8 @@ var generateKicadFootprintLibrary = async ({
|
|
|
83941
84281
|
const uniqueFootprints = new Map;
|
|
83942
84282
|
for (const project of projects) {
|
|
83943
84283
|
try {
|
|
83944
|
-
const parsed =
|
|
83945
|
-
const pcb = parsed.find((node) => node instanceof
|
|
84284
|
+
const parsed = parseKicadSexpr3(project.pcbContent);
|
|
84285
|
+
const pcb = parsed.find((node) => node instanceof KicadPcb3);
|
|
83946
84286
|
if (!pcb)
|
|
83947
84287
|
continue;
|
|
83948
84288
|
const footprints = pcb.footprints ?? [];
|
|
@@ -83976,19 +84316,24 @@ ${libTableEntries.join(`
|
|
|
83976
84316
|
fs27.writeFileSync(path29.join(libraryRoot, "fp-lib-table"), libTableContent);
|
|
83977
84317
|
}
|
|
83978
84318
|
};
|
|
83979
|
-
var extractFootprintsFromPcb = (pcbContent) => {
|
|
84319
|
+
var extractFootprintsFromPcb = (pcbContent, outputLibraryName) => {
|
|
83980
84320
|
const uniqueFootprints = new Map;
|
|
83981
84321
|
try {
|
|
83982
|
-
const parsed =
|
|
83983
|
-
const pcb = parsed.find((node) => node instanceof
|
|
84322
|
+
const parsed = parseKicadSexpr3(pcbContent);
|
|
84323
|
+
const pcb = parsed.find((node) => node instanceof KicadPcb3);
|
|
83984
84324
|
if (!pcb)
|
|
83985
84325
|
return [];
|
|
83986
84326
|
const footprints = pcb.footprints ?? [];
|
|
83987
84327
|
for (const footprint of footprints) {
|
|
83988
|
-
const sanitized = sanitizeFootprint(footprint);
|
|
84328
|
+
const sanitized = sanitizeFootprint(footprint, outputLibraryName);
|
|
83989
84329
|
const key = `${sanitized.libraryName}::${sanitized.footprintName}`;
|
|
83990
84330
|
if (!uniqueFootprints.has(key)) {
|
|
83991
|
-
uniqueFootprints.set(key,
|
|
84331
|
+
uniqueFootprints.set(key, {
|
|
84332
|
+
libraryName: sanitized.libraryName,
|
|
84333
|
+
footprintName: sanitized.footprintName,
|
|
84334
|
+
content: sanitized.content,
|
|
84335
|
+
modelFiles: sanitized.modelFiles
|
|
84336
|
+
});
|
|
83992
84337
|
}
|
|
83993
84338
|
}
|
|
83994
84339
|
} catch (error) {
|
|
@@ -84012,7 +84357,8 @@ var ALLOWED_EXPORT_FORMATS = [
|
|
|
84012
84357
|
"kicad_sch",
|
|
84013
84358
|
"kicad_pcb",
|
|
84014
84359
|
"kicad_zip",
|
|
84015
|
-
"kicad-footprint-library"
|
|
84360
|
+
"kicad-footprint-library",
|
|
84361
|
+
"kicad-library"
|
|
84016
84362
|
];
|
|
84017
84363
|
var OUTPUT_EXTENSIONS = {
|
|
84018
84364
|
json: ".circuit.json",
|
|
@@ -84027,7 +84373,8 @@ var OUTPUT_EXTENSIONS = {
|
|
|
84027
84373
|
kicad_sch: ".kicad_sch",
|
|
84028
84374
|
kicad_pcb: ".kicad_pcb",
|
|
84029
84375
|
kicad_zip: "-kicad.zip",
|
|
84030
|
-
"kicad-footprint-library": "-footprints.zip"
|
|
84376
|
+
"kicad-footprint-library": "-footprints.zip",
|
|
84377
|
+
"kicad-library": "-kicad-library"
|
|
84031
84378
|
};
|
|
84032
84379
|
var exportSnippet = async ({
|
|
84033
84380
|
filePath,
|
|
@@ -84131,6 +84478,43 @@ ${libTableEntries.join(`
|
|
|
84131
84478
|
outputContent = await zip.generateAsync({ type: "nodebuffer" });
|
|
84132
84479
|
break;
|
|
84133
84480
|
}
|
|
84481
|
+
case "kicad-library": {
|
|
84482
|
+
const libraryName = outputBaseName;
|
|
84483
|
+
const fpLibName = outputBaseName;
|
|
84484
|
+
const libConverter = new CircuitJsonToKicadLibraryConverter(circuitData.circuitJson, {
|
|
84485
|
+
libraryName,
|
|
84486
|
+
footprintLibraryName: fpLibName
|
|
84487
|
+
});
|
|
84488
|
+
libConverter.runUntilFinished();
|
|
84489
|
+
const libOutput = libConverter.getOutput();
|
|
84490
|
+
const libDir = outputDestination;
|
|
84491
|
+
fs28.mkdirSync(libDir, { recursive: true });
|
|
84492
|
+
fs28.writeFileSync(path30.join(libDir, `${libraryName}.kicad_sym`), libOutput.kicadSymString);
|
|
84493
|
+
const fpDir = path30.join(libDir, `${fpLibName}.pretty`);
|
|
84494
|
+
fs28.mkdirSync(fpDir, { recursive: true });
|
|
84495
|
+
for (const fp of libOutput.footprints) {
|
|
84496
|
+
fs28.writeFileSync(path30.join(fpDir, `${fp.footprintName}.kicad_mod`), `${fp.kicadModString}
|
|
84497
|
+
`);
|
|
84498
|
+
}
|
|
84499
|
+
if (libOutput.model3dSourcePaths.length > 0) {
|
|
84500
|
+
const shapesDir = path30.join(libDir, `${fpLibName}.3dshapes`);
|
|
84501
|
+
fs28.mkdirSync(shapesDir, { recursive: true });
|
|
84502
|
+
for (const modelPath of libOutput.model3dSourcePaths) {
|
|
84503
|
+
if (fs28.existsSync(modelPath)) {
|
|
84504
|
+
const filename = path30.basename(modelPath);
|
|
84505
|
+
fs28.copyFileSync(modelPath, path30.join(shapesDir, filename));
|
|
84506
|
+
}
|
|
84507
|
+
}
|
|
84508
|
+
}
|
|
84509
|
+
fs28.writeFileSync(path30.join(libDir, "fp-lib-table"), libOutput.fpLibTableString);
|
|
84510
|
+
fs28.writeFileSync(path30.join(libDir, "sym-lib-table"), libOutput.symLibTableString);
|
|
84511
|
+
outputContent = "";
|
|
84512
|
+
if (writeFile) {
|
|
84513
|
+
onSuccess({ outputDestination: libDir, outputContent: "" });
|
|
84514
|
+
return onExit(0);
|
|
84515
|
+
}
|
|
84516
|
+
break;
|
|
84517
|
+
}
|
|
84134
84518
|
default:
|
|
84135
84519
|
outputContent = JSON.stringify(circuitData.circuitJson, null, 2);
|
|
84136
84520
|
}
|
|
@@ -89104,7 +89488,7 @@ function buildSubtree(soup, opts) {
|
|
|
89104
89488
|
}
|
|
89105
89489
|
return soup.filter((e3) => included.has(e3));
|
|
89106
89490
|
}
|
|
89107
|
-
var
|
|
89491
|
+
var cju5 = (circuitJsonInput, options = {}) => {
|
|
89108
89492
|
const circuitJson = circuitJsonInput;
|
|
89109
89493
|
let internalStore = circuitJson._internal_store;
|
|
89110
89494
|
if (!internalStore) {
|
|
@@ -89136,7 +89520,7 @@ var cju4 = (circuitJsonInput, options = {}) => {
|
|
|
89136
89520
|
return internalStore.editCount;
|
|
89137
89521
|
}
|
|
89138
89522
|
if (prop === "subtree") {
|
|
89139
|
-
return (opts) =>
|
|
89523
|
+
return (opts) => cju5(buildSubtree(circuitJson, opts), options);
|
|
89140
89524
|
}
|
|
89141
89525
|
const component_type = prop;
|
|
89142
89526
|
return {
|
|
@@ -89218,9 +89602,9 @@ var cju4 = (circuitJsonInput, options = {}) => {
|
|
|
89218
89602
|
});
|
|
89219
89603
|
return su22;
|
|
89220
89604
|
};
|
|
89221
|
-
|
|
89222
|
-
var su6 =
|
|
89223
|
-
var cju_default =
|
|
89605
|
+
cju5.unparsed = cju5;
|
|
89606
|
+
var su6 = cju5;
|
|
89607
|
+
var cju_default = cju5;
|
|
89224
89608
|
function createIdKey(element) {
|
|
89225
89609
|
const type = element.type;
|
|
89226
89610
|
return `${type}:${element[`${type}_id`]}`;
|
|
@@ -89757,7 +90141,7 @@ var getElementById = (soup, id2) => {
|
|
|
89757
90141
|
return soup.find((elm) => getElementId(elm) === id2) ?? null;
|
|
89758
90142
|
};
|
|
89759
90143
|
function getReadableNameForPcbTrace(soup, pcb_trace_id) {
|
|
89760
|
-
const pcbTrace =
|
|
90144
|
+
const pcbTrace = cju5(soup).pcb_trace.get(pcb_trace_id);
|
|
89761
90145
|
if (!pcbTrace) {
|
|
89762
90146
|
return `trace[${pcb_trace_id}]`;
|
|
89763
90147
|
}
|
|
@@ -89766,16 +90150,16 @@ function getReadableNameForPcbTrace(soup, pcb_trace_id) {
|
|
|
89766
90150
|
return `trace[${pcb_trace_id}]`;
|
|
89767
90151
|
}
|
|
89768
90152
|
function getComponentAndPortInfo(pcb_port_id) {
|
|
89769
|
-
const pcbPort =
|
|
90153
|
+
const pcbPort = cju5(soup).pcb_port.get(pcb_port_id);
|
|
89770
90154
|
if (!pcbPort)
|
|
89771
90155
|
return null;
|
|
89772
|
-
const pcbComponent =
|
|
90156
|
+
const pcbComponent = cju5(soup).pcb_component.get(pcbPort.pcb_component_id);
|
|
89773
90157
|
if (!pcbComponent)
|
|
89774
90158
|
return null;
|
|
89775
|
-
const sourceComponent =
|
|
90159
|
+
const sourceComponent = cju5(soup).source_component.get(pcbComponent.source_component_id);
|
|
89776
90160
|
if (!sourceComponent)
|
|
89777
90161
|
return null;
|
|
89778
|
-
const sourcePort =
|
|
90162
|
+
const sourcePort = cju5(soup).source_port.get(pcbPort.source_port_id);
|
|
89779
90163
|
const portHint = sourcePort?.port_hints ? sourcePort.port_hints[1] : "";
|
|
89780
90164
|
return {
|
|
89781
90165
|
componentName: sourceComponent.name,
|
|
@@ -89792,19 +90176,19 @@ function getReadableNameForPcbTrace(soup, pcb_trace_id) {
|
|
|
89792
90176
|
return `trace[${selectorParts.join(", ")}]`;
|
|
89793
90177
|
}
|
|
89794
90178
|
var getReadableNameForPcbPort = (soup, pcb_port_id) => {
|
|
89795
|
-
const pcbPort =
|
|
90179
|
+
const pcbPort = cju5(soup).pcb_port.get(pcb_port_id);
|
|
89796
90180
|
if (!pcbPort) {
|
|
89797
90181
|
return `pcb_port[#${pcb_port_id}]`;
|
|
89798
90182
|
}
|
|
89799
|
-
const pcbComponent =
|
|
90183
|
+
const pcbComponent = cju5(soup).pcb_component.get(pcbPort?.pcb_component_id);
|
|
89800
90184
|
if (!pcbComponent) {
|
|
89801
90185
|
return `pcb_port[#${pcb_port_id}]`;
|
|
89802
90186
|
}
|
|
89803
|
-
const sourceComponent =
|
|
90187
|
+
const sourceComponent = cju5(soup).source_component.get(pcbComponent.source_component_id);
|
|
89804
90188
|
if (!sourceComponent) {
|
|
89805
90189
|
return `pcb_port[#${pcb_port_id}]`;
|
|
89806
90190
|
}
|
|
89807
|
-
const sourcePort =
|
|
90191
|
+
const sourcePort = cju5(soup).source_port.get(pcbPort.source_port_id);
|
|
89808
90192
|
if (!sourcePort) {
|
|
89809
90193
|
return `pcb_port[#${pcb_port_id}]`;
|
|
89810
90194
|
}
|
|
@@ -89819,7 +90203,7 @@ var getReadableNameForPcbPort = (soup, pcb_port_id) => {
|
|
|
89819
90203
|
return `pcb_port[.${sourceComponent.name} > .${padIdentifier}]`;
|
|
89820
90204
|
};
|
|
89821
90205
|
function getReadableNameForPcbSmtpad(soup, pcb_smtpad_id) {
|
|
89822
|
-
const pcbSmtpad =
|
|
90206
|
+
const pcbSmtpad = cju5(soup).pcb_smtpad.get(pcb_smtpad_id);
|
|
89823
90207
|
if (!pcbSmtpad || !pcbSmtpad.pcb_port_id) {
|
|
89824
90208
|
return `smtpad[${pcb_smtpad_id}]`;
|
|
89825
90209
|
}
|
|
@@ -90819,12 +91203,12 @@ var { paths: Ac, texts: ov, bounds: Le, refblocks: $y, circles: Pc } = R;
|
|
|
90819
91203
|
var My = e({ primitives: [...Object.values(Ac), ...Object.values(Pc), { type: "text", text: "{REF}", x: 0.15, y: -0.2894553499999995 }, { type: "text", text: "{VAL}", x: -0.15, y: -0.2894553499999995 }], ports: [{ ...$y.left1, labels: ["1"] }, { ...$y.right1, labels: ["2"] }], size: { width: Le.width, height: Le.height }, center: { x: Le.centerX, y: Le.centerY } }).rotateRightFacingSymbol("up").labelPort("left1", ["1"]).labelPort("right1", ["2"]).changeTextAnchor("{REF}", "middle_left").changeTextAnchor("{VAL}", "middle_left").build();
|
|
90820
91204
|
var Cy = { paths: { path11: { type: "path", points: [{ x: -0.53, y: 0 }, { x: -0.3, y: 0 }], color: "primary", fill: false }, path12: { type: "path", points: [{ x: 0.29, y: 0 }, { x: 0.53, y: 0 }], color: "primary", fill: false } }, texts: { top1: { type: "text", text: "{REF}", x: -0.18, y: -0.36 }, bottom1: { type: "text", text: "{VAL}", x: -0.01, y: 0.43 }, left1: { type: "text", text: "Hz", x: 0, y: -0.04 } }, refblocks: { left1: { x: -0.54, y: 0 }, right1: { x: 0.54, y: 0 } }, bounds: { minX: -0.53, maxX: 0.53, minY: 0, maxY: 0, width: 1.06, height: 1, centerX: 0, centerY: 0 }, circles: { path1: { type: "circle", x: -0.01, y: -0.01, radius: 0.29, color: "primary", fill: false } } };
|
|
90821
91205
|
var { paths: Fc, texts: Rc, bounds: Ve, refblocks: Ny, circles: Tc } = Cy;
|
|
90822
|
-
var
|
|
90823
|
-
var { 5: Ec, ...Yc } =
|
|
91206
|
+
var At5 = s({ primitives: [...Object.values(Fc), ...Object.values(Tc), { type: "text", text: "{REF}", x: 0, y: -0.3594553499999995, anchor: "middle_top" }, { type: "text", text: "{VAL}", x: 0, y: 0.35, anchor: "middle_bottom" }, { ...Rc.left1, x: 0, y: 0.01, anchor: "center", fontSize: 0.2 }], ports: [{ ...Ny.left1, labels: ["1"] }, { ...Ny.right1, labels: ["2"] }], size: { width: Ve.width, height: Ve.height }, center: { x: Ve.centerX, y: Ve.centerY } });
|
|
91207
|
+
var { 5: Ec, ...Yc } = At5.primitives;
|
|
90824
91208
|
function Xc(t2) {
|
|
90825
91209
|
return typeof t2 == "object";
|
|
90826
91210
|
}
|
|
90827
|
-
var Iy = r({ ...
|
|
91211
|
+
var Iy = r({ ...At5, primitives: Object.values(Yc).filter(Xc) });
|
|
90828
91212
|
var By = { ...Iy, primitives: [...Iy.primitives, Ec] };
|
|
90829
91213
|
var qy = { paths: { path10: { type: "path", points: [{ x: -0.53, y: 0.04 }, { x: 0.53, y: 0.04 }], color: "primary", fill: false }, path14: { type: "path", points: [{ x: 0, y: 0.17 }, { x: 0.27, y: 0.17 }, { x: 0.27, y: -0.1 }, { x: -0.26, y: -0.1 }, { x: -0.26, y: 0.17 }, { x: 0, y: 0.17 }], color: "primary", fill: false } }, texts: { top1: { type: "text", text: "{REF}", x: -0.01, y: 0.24 }, bottom1: { type: "text", text: "{VAL}", x: -0.17, y: -0.24 } }, refblocks: { left1: { x: -0.53, y: 0.04 }, right1: { x: 0.53, y: 0.04 } }, bounds: { minX: -0.56, maxX: 0.56, minY: -0.24, maxY: 0.24, width: 1.13, height: 0.47, centerX: 0, centerY: 0 }, circles: {} };
|
|
90830
91214
|
var { paths: Vc, texts: jc, bounds: je, refblocks: Dy } = qy;
|
|
@@ -91604,7 +91988,7 @@ var mb = Cl.primitives.find((t3) => t3.type === "text" && t3.text === "{VAL}");
|
|
|
91604
91988
|
sb.anchor = "middle_left";
|
|
91605
91989
|
mb.anchor = "middle_right";
|
|
91606
91990
|
var B1 = Cl;
|
|
91607
|
-
var q1 = { ac_voltmeter_down: Ul, ac_voltmeter_horz: Wl, ac_voltmeter_left: Zl, ac_voltmeter_right: Kl, ac_voltmeter_up: ep, ac_voltmeter_vert: op, avalanche_diode_down: lp, avalanche_diode_horz: pp, avalanche_diode_left: yp, avalanche_diode_right: xp, avalanche_diode_up: mp, avalanche_diode_vert: fp, backward_diode_down: cp, backward_diode_left: Dt, backward_diode_right: _p, backward_diode_up: gp, battery_horz: Wt, battery_vert: Ap, boxresistor_down: Fp, boxresistor_left: Ep, boxresistor_right: Lp, boxresistor_small_down: jp, boxresistor_small_left: zp, boxresistor_small_right: Jp, boxresistor_small_up: Mp, boxresistor_up: Ip, bridged_ground_down: Dp, bridged_ground_left: Wp, bridged_ground_right: te, bridged_ground_up: Qp, capacitor_down: ta, capacitor_left: ea, capacitor_polarized_down: oa, capacitor_polarized_left: ia, capacitor_polarized_right: pa, capacitor_polarized_up: ya, capacitor_right: xa, capacitor_up: ma, constant_current_diode_down: fa, constant_current_diode_horz: ha, constant_current_diode_left: da, constant_current_diode_right: ba, constant_current_diode_up: ga, constant_current_diode_vert: va, crystal_4pin_down: wa, crystal_4pin_left: Aa, crystal_4pin_right: Pa, crystal_4pin_up: Sa, crystal_down: Ra, crystal_left: Ta, crystal_right: Ea, crystal_up: Xa, darlington_pair_transistor_down: La, darlington_pair_transistor_horz: Va, darlington_pair_transistor_left: ja, darlington_pair_transistor_right: ka, darlington_pair_transistor_up: za, darlington_pair_transistor_vert: Oa, dc_ammeter_horz: wt, dc_ammeter_vert: Ca, dc_voltmeter_down: Ia, dc_voltmeter_horz: qa, dc_voltmeter_left: Ua, dc_voltmeter_right: Wa, dc_voltmeter_up: Za, dc_voltmeter_vert: Ka, diac_down: ty, diac_horz: ey, diac_left: ry, diac_right: oy, diac_up: iy, diac_vert: ly, diode_down: ay, diode_left: yy, diode_right: $2, diode_up: xy, dpdt_normally_closed_switch_down: my, dpdt_normally_closed_switch_left: ny, dpdt_normally_closed_switch_right: M, dpdt_normally_closed_switch_up: fy, dpdt_switch_down: cy, dpdt_switch_left: dy, dpdt_switch_right: C, dpdt_switch_up: by, dpst_normally_closed_switch_down: gy, dpst_normally_closed_switch_left: uy, dpst_normally_closed_switch_right: N, dpst_normally_closed_switch_up: vy, dpst_switch_down: Ay, dpst_switch_left: Py, dpst_switch_right: I, dpst_switch_up: Sy, ferrite_bead_down: Ry, ferrite_bead_left: Ty, ferrite_bead_right: Fe, ferrite_bead_up: Se, filled_diode_down: Yy, filled_diode_horz: Ly, filled_diode_left: jy, filled_diode_right: zy, filled_diode_up: Jy, filled_diode_vert: My, frequency_meter_horz:
|
|
91991
|
+
var q1 = { ac_voltmeter_down: Ul, ac_voltmeter_horz: Wl, ac_voltmeter_left: Zl, ac_voltmeter_right: Kl, ac_voltmeter_up: ep, ac_voltmeter_vert: op, avalanche_diode_down: lp, avalanche_diode_horz: pp, avalanche_diode_left: yp, avalanche_diode_right: xp, avalanche_diode_up: mp, avalanche_diode_vert: fp, backward_diode_down: cp, backward_diode_left: Dt, backward_diode_right: _p, backward_diode_up: gp, battery_horz: Wt, battery_vert: Ap, boxresistor_down: Fp, boxresistor_left: Ep, boxresistor_right: Lp, boxresistor_small_down: jp, boxresistor_small_left: zp, boxresistor_small_right: Jp, boxresistor_small_up: Mp, boxresistor_up: Ip, bridged_ground_down: Dp, bridged_ground_left: Wp, bridged_ground_right: te, bridged_ground_up: Qp, capacitor_down: ta, capacitor_left: ea, capacitor_polarized_down: oa, capacitor_polarized_left: ia, capacitor_polarized_right: pa, capacitor_polarized_up: ya, capacitor_right: xa, capacitor_up: ma, constant_current_diode_down: fa, constant_current_diode_horz: ha, constant_current_diode_left: da, constant_current_diode_right: ba, constant_current_diode_up: ga, constant_current_diode_vert: va, crystal_4pin_down: wa, crystal_4pin_left: Aa, crystal_4pin_right: Pa, crystal_4pin_up: Sa, crystal_down: Ra, crystal_left: Ta, crystal_right: Ea, crystal_up: Xa, darlington_pair_transistor_down: La, darlington_pair_transistor_horz: Va, darlington_pair_transistor_left: ja, darlington_pair_transistor_right: ka, darlington_pair_transistor_up: za, darlington_pair_transistor_vert: Oa, dc_ammeter_horz: wt, dc_ammeter_vert: Ca, dc_voltmeter_down: Ia, dc_voltmeter_horz: qa, dc_voltmeter_left: Ua, dc_voltmeter_right: Wa, dc_voltmeter_up: Za, dc_voltmeter_vert: Ka, diac_down: ty, diac_horz: ey, diac_left: ry, diac_right: oy, diac_up: iy, diac_vert: ly, diode_down: ay, diode_left: yy, diode_right: $2, diode_up: xy, dpdt_normally_closed_switch_down: my, dpdt_normally_closed_switch_left: ny, dpdt_normally_closed_switch_right: M, dpdt_normally_closed_switch_up: fy, dpdt_switch_down: cy, dpdt_switch_left: dy, dpdt_switch_right: C, dpdt_switch_up: by, dpst_normally_closed_switch_down: gy, dpst_normally_closed_switch_left: uy, dpst_normally_closed_switch_right: N, dpst_normally_closed_switch_up: vy, dpst_switch_down: Ay, dpst_switch_left: Py, dpst_switch_right: I, dpst_switch_up: Sy, ferrite_bead_down: Ry, ferrite_bead_left: Ty, ferrite_bead_right: Fe, ferrite_bead_up: Se, filled_diode_down: Yy, filled_diode_horz: Ly, filled_diode_left: jy, filled_diode_right: zy, filled_diode_up: Jy, filled_diode_vert: My, frequency_meter_horz: At5, frequency_meter_vert: By, fuse_horz: ke, fuse_vert: Uy, ground_down: Gy, ground_horz: Wy, ground_left: Hy, ground_right: Zy, ground_up: Qy, ground_vert: Ky2, ground2_down: ex, ground2_left: ox, ground2_right: lx, ground2_up: ax, gunn_diode_horz: yx, gunn_diode_vert: xx, icled_down: mx, icled_left: nx, icled_right: q, icled_up: fx, igbt_transistor_horz: ze, igbt_transistor_vert: dx, illuminated_push_button_normally_open_horz: Oe, illuminated_push_button_normally_open_vert: ux, inductor_down: Px, inductor_left: Sx, inductor_right: _t, inductor_up: $e, laser_diode_down: Fx, laser_diode_left: Rx, laser_diode_right: D, laser_diode_up: Tx, led_down: Lx, led_left: Vx, led_right: gt, led_up: Ce, light_dependent_resistor_horz: Ie, light_dependent_resistor_vert: $x, mosfet_depletion_normally_on_horz: qe, mosfet_depletion_normally_on_vert: Ix, mushroom_head_normally_open_momentary_horz: Ue, mushroom_head_normally_open_momentary_vert: Ux, n_channel_d_mosfet_transistor_horz: He, n_channel_d_mosfet_transistor_vert: Qx, n_channel_e_mosfet_transistor_horz: Qe, n_channel_e_mosfet_transistor_vert: os5, njfet_transistor_horz: t0, njfet_transistor_vert: ys, not_connected_down: ms, not_connected_left: ns, not_connected_right: U, not_connected_up: fs31, npn_bipolar_transistor_down: hs, npn_bipolar_transistor_horz: cs, npn_bipolar_transistor_left: ds, npn_bipolar_transistor_right: bs, npn_bipolar_transistor_up: _s, npn_bipolar_transistor_vert: gs, opamp_no_power_down: vs, opamp_no_power_left: ws, opamp_no_power_right: G, opamp_no_power_up: As, opamp_with_power_down: Ss, opamp_with_power_left: Fs, opamp_with_power_right: W, opamp_with_power_up: Rs, p_channel_d_mosfet_transistor_horz: a0, p_channel_d_mosfet_transistor_vert: Ls, p_channel_e_mosfet_transistor_horz: x0, p_channel_e_mosfet_transistor_vert: Os, photodiode_horz: s0, photodiode_vert: Cs, pjfet_transistor_horz: n0, pjfet_transistor_vert: Ds, pnp_bipolar_transistor_down: Us, pnp_bipolar_transistor_horz: Gs, pnp_bipolar_transistor_left: Ws, pnp_bipolar_transistor_right: Hs, pnp_bipolar_transistor_up: Zs, pnp_bipolar_transistor_vert: Qs, potentiometer_horz: g0, potentiometer_vert: rm, potentiometer2_down: pm, potentiometer2_left: am, potentiometer2_right: H, potentiometer2_up: ym, potentiometer3_down: xm, potentiometer3_left: sm, potentiometer3_right: mm, potentiometer3_up: nm, power_factor_meter_horz: S0, power_factor_meter_vert: dm, push_button_normally_closed_momentary_horz: R0, push_button_normally_closed_momentary_vert: um, push_button_normally_open_momentary_horz: E0, push_button_normally_open_momentary_vert: Pm, rectifier_diode_horz: L0, rectifier_diode_vert: Rm, resistor_down: Em, resistor_left: Xm, resistor_right: Vm, resistor_up: km, resonator_down: Om, resonator_horz: M0, resonator_left: Jm, resonator_right: K, resonator_up: $m, resonator_vert: Mm, schottky_diode_down: Nm, schottky_diode_left: Im, schottky_diode_right: tt, schottky_diode_up: Bm, silicon_controlled_rectifier_horz: C0, silicon_controlled_rectifier_vert: Um, solderjumper2_bridged12_down: Gm, solderjumper2_bridged12_left: Wm, solderjumper2_bridged12_right: Hm, solderjumper2_bridged12_up: Zm, solderjumper2_down: Qm, solderjumper2_left: Km, solderjumper2_right: tn, solderjumper2_up: en, solderjumper3_bridged12_down: rn, solderjumper3_bridged12_left: on2, solderjumper3_bridged12_right: ln, solderjumper3_bridged12_up: pn, solderjumper3_bridged123_down: an, solderjumper3_bridged123_left: yn, solderjumper3_bridged123_right: xn, solderjumper3_bridged123_up: sn, solderjumper3_bridged23_down: mn, solderjumper3_bridged23_left: nn, solderjumper3_bridged23_right: fn, solderjumper3_bridged23_up: hn, solderjumper3_down: cn, solderjumper3_left: dn, solderjumper3_right: bn, solderjumper3_up: _n, spdt_normally_closed_switch_down: un, spdt_normally_closed_switch_left: vn, spdt_normally_closed_switch_right: at, spdt_normally_closed_switch_up: wn, spdt_switch_down: Pn, spdt_switch_left: Sn, spdt_switch_right: yt, spdt_switch_up: Fn, spst_normally_closed_switch_down: Rn, spst_normally_closed_switch_left: Tn, spst_normally_closed_switch_right: xt, spst_normally_closed_switch_up: En, spst_switch_down: Yn, spst_switch_left: Xn, spst_switch_right: st, spst_switch_up: Ln, square_wave_down: Vn, square_wave_left: jn, square_wave_right: kn, square_wave_up: zn, step_recovery_diode_horz: N0, step_recovery_diode_vert: On, tachometer_horz: Tt, tachometer_vert: Cn, testpoint_down: Bn, testpoint_left: qn, testpoint_right: nt, testpoint_up: Gn, tilted_ground_down: Hn, tilted_ground_left: Zn, tilted_ground_right: ut, tilted_ground_up: B0, triac_horz: q0, triac_vert: t1, tunnel_diode_horz: U0, tunnel_diode_vert: i1, unijunction_transistor_horz: W0, unijunction_transistor_vert: s1, usbc: n1, var_meter_horz: Z0, var_meter_vert: c1, varactor_diode_horz: K0, varactor_diode_vert: g1, varistor_horz: er, varistor_vert: A1, varmeter_horz: Et, varmeter_vert: R1, vcc_down: T1, vcc_left: E1, vcc_right: Y1, vcc_up: X1, volt_meter_horz: or, volt_meter_vert: L1, watt_hour_meter_horz: Yt, watt_hour_meter_vert: z1, wattmeter_horz: Xt, wattmeter_vert: M1, zener_diode_horz: ar, zener_diode_vert: B1 };
|
|
91608
91992
|
var Y$ = Object.fromEntries(Object.keys(q1).map((t3) => [t3, t3]));
|
|
91609
91993
|
function doesLineIntersectLine([a12, a22], [b12, b22], {
|
|
91610
91994
|
lineThickness = 0
|
|
@@ -185960,7 +186344,7 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
|
185960
186344
|
|
|
185961
186345
|
// node_modules/chalk/source/index.js
|
|
185962
186346
|
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
185963
|
-
var
|
|
186347
|
+
var GENERATOR2 = Symbol("GENERATOR");
|
|
185964
186348
|
var STYLER = Symbol("STYLER");
|
|
185965
186349
|
var IS_EMPTY = Symbol("IS_EMPTY");
|
|
185966
186350
|
var levelMapping = [
|
|
@@ -186045,10 +186429,10 @@ var proto = Object.defineProperties(() => {}, {
|
|
|
186045
186429
|
level: {
|
|
186046
186430
|
enumerable: true,
|
|
186047
186431
|
get() {
|
|
186048
|
-
return this[
|
|
186432
|
+
return this[GENERATOR2].level;
|
|
186049
186433
|
},
|
|
186050
186434
|
set(level) {
|
|
186051
|
-
this[
|
|
186435
|
+
this[GENERATOR2].level = level;
|
|
186052
186436
|
}
|
|
186053
186437
|
}
|
|
186054
186438
|
});
|
|
@@ -186073,7 +186457,7 @@ var createStyler = (open2, close, parent) => {
|
|
|
186073
186457
|
var createBuilder = (self2, _styler, _isEmpty) => {
|
|
186074
186458
|
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
186075
186459
|
Object.setPrototypeOf(builder, proto);
|
|
186076
|
-
builder[
|
|
186460
|
+
builder[GENERATOR2] = self2;
|
|
186077
186461
|
builder[STYLER] = _styler;
|
|
186078
186462
|
builder[IS_EMPTY] = _isEmpty;
|
|
186079
186463
|
return builder;
|
|
@@ -187070,11 +187454,27 @@ var buildFile = async (input, output, projectDir, options) => {
|
|
|
187070
187454
|
} catch (err) {
|
|
187071
187455
|
console.error(`Build failed: ${err}`);
|
|
187072
187456
|
if (err instanceof Error) {
|
|
187457
|
+
logTsxExtensionHint(err, input);
|
|
187073
187458
|
logTypeReexportHint(err, input);
|
|
187074
187459
|
}
|
|
187075
187460
|
return { ok: false };
|
|
187076
187461
|
}
|
|
187077
187462
|
};
|
|
187463
|
+
var logTsxExtensionHint = (error, entryFilePath) => {
|
|
187464
|
+
const lowerPath = entryFilePath.toLowerCase();
|
|
187465
|
+
const isTsEntry = lowerPath.endsWith(".ts") && !lowerPath.endsWith(".d.ts");
|
|
187466
|
+
const isAggregateError = error instanceof AggregateError || String(error).includes("AggregateError");
|
|
187467
|
+
if (!isTsEntry || !isAggregateError)
|
|
187468
|
+
return;
|
|
187469
|
+
const entryFileName = path34.basename(entryFilePath);
|
|
187470
|
+
console.error([
|
|
187471
|
+
"",
|
|
187472
|
+
`It looks like "${entryFileName}" is a ".ts" file. tscircuit component files must use the ".tsx" extension.`,
|
|
187473
|
+
"Try renaming the file to .tsx and re-running the build.",
|
|
187474
|
+
""
|
|
187475
|
+
].join(`
|
|
187476
|
+
`));
|
|
187477
|
+
};
|
|
187078
187478
|
var TYPE_REEXPORT_ERROR_REGEX = /SyntaxError: export '([^']+)' not found in '([^']+)'/;
|
|
187079
187479
|
var logTypeReexportHint = (error, entryFilePath) => {
|
|
187080
187480
|
const match = String(error).match(TYPE_REEXPORT_ERROR_REGEX);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.672",
|
|
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.30",
|
|
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",
|