@modular-circuit/transpiler 0.1.14 → 0.2.0
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/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +107 -59
- package/dist/index.mjs +59 -14
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -412,6 +412,11 @@ declare function collect_sub_sheets_by_id(module_ids: string[], module_resolver:
|
|
|
412
412
|
design_blocks: DesignBlockContent[];
|
|
413
413
|
}>;
|
|
414
414
|
|
|
415
|
+
declare const fmt_to_valid_filename: (name: string) => string;
|
|
416
|
+
declare const fmt_module_place_holder_sch_name: (mod_name: string) => string;
|
|
417
|
+
|
|
418
|
+
declare const gen_empty_sch: (name: string) => Promise<string>;
|
|
419
|
+
|
|
415
420
|
declare const gen_lib_gnd: (value: string) => LIB_SYMBOL;
|
|
416
421
|
|
|
417
422
|
declare const gen_lib_vcc: (value: string) => LIB_SYMBOL;
|
|
@@ -420,4 +425,4 @@ declare const gen_sch_gnd: (value: string, pwr_number: number, port_id: string,
|
|
|
420
425
|
|
|
421
426
|
declare const gen_sch_vcc: (value: string, pwr_number: number, port_id: string, position: VECTOR2) => SCH_SYMBOL;
|
|
422
427
|
|
|
423
|
-
export { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, DEFAULT_PAPER_SIZE, FONT_SIZE, GENERATOR_NAME, GENERATOR_VERSION, GRID_SIZE, GraphConverter, KICAD_SCH_FRAME, KiCadProjectArchive, type LabelPadding, Layout, NetListConverter, type NetlistProject, type NetlistToKicadContext, PAPER, PAPER_SIZE, SCHEMATIC_PRINTER, SCH_VERSION, type Size, StringFormatter, WIRE_PADDING, collect_sub_sheets, collect_sub_sheets_by_id, convert_graph_to_design_block, convert_graph_to_kicad_project, convert_graph_to_sheets, filterNullOrUndefined, gen_lib_gnd, gen_lib_vcc, gen_sch_gnd, gen_sch_vcc, get_power_pos, get_sch_default_drawing_sheet, tab };
|
|
428
|
+
export { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, DEFAULT_PAPER_SIZE, FONT_SIZE, GENERATOR_NAME, GENERATOR_VERSION, GRID_SIZE, GraphConverter, KICAD_SCH_FRAME, KiCadProjectArchive, type LabelPadding, Layout, NetListConverter, type NetlistProject, type NetlistToKicadContext, PAPER, PAPER_SIZE, SCHEMATIC_PRINTER, SCH_VERSION, type Size, StringFormatter, WIRE_PADDING, collect_sub_sheets, collect_sub_sheets_by_id, convert_graph_to_design_block, convert_graph_to_kicad_project, convert_graph_to_sheets, filterNullOrUndefined, fmt_module_place_holder_sch_name, fmt_to_valid_filename, gen_empty_sch, gen_lib_gnd, gen_lib_vcc, gen_sch_gnd, gen_sch_vcc, get_power_pos, get_sch_default_drawing_sheet, tab };
|
package/dist/index.d.ts
CHANGED
|
@@ -412,6 +412,11 @@ declare function collect_sub_sheets_by_id(module_ids: string[], module_resolver:
|
|
|
412
412
|
design_blocks: DesignBlockContent[];
|
|
413
413
|
}>;
|
|
414
414
|
|
|
415
|
+
declare const fmt_to_valid_filename: (name: string) => string;
|
|
416
|
+
declare const fmt_module_place_holder_sch_name: (mod_name: string) => string;
|
|
417
|
+
|
|
418
|
+
declare const gen_empty_sch: (name: string) => Promise<string>;
|
|
419
|
+
|
|
415
420
|
declare const gen_lib_gnd: (value: string) => LIB_SYMBOL;
|
|
416
421
|
|
|
417
422
|
declare const gen_lib_vcc: (value: string) => LIB_SYMBOL;
|
|
@@ -420,4 +425,4 @@ declare const gen_sch_gnd: (value: string, pwr_number: number, port_id: string,
|
|
|
420
425
|
|
|
421
426
|
declare const gen_sch_vcc: (value: string, pwr_number: number, port_id: string, position: VECTOR2) => SCH_SYMBOL;
|
|
422
427
|
|
|
423
|
-
export { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, DEFAULT_PAPER_SIZE, FONT_SIZE, GENERATOR_NAME, GENERATOR_VERSION, GRID_SIZE, GraphConverter, KICAD_SCH_FRAME, KiCadProjectArchive, type LabelPadding, Layout, NetListConverter, type NetlistProject, type NetlistToKicadContext, PAPER, PAPER_SIZE, SCHEMATIC_PRINTER, SCH_VERSION, type Size, StringFormatter, WIRE_PADDING, collect_sub_sheets, collect_sub_sheets_by_id, convert_graph_to_design_block, convert_graph_to_kicad_project, convert_graph_to_sheets, filterNullOrUndefined, gen_lib_gnd, gen_lib_vcc, gen_sch_gnd, gen_sch_vcc, get_power_pos, get_sch_default_drawing_sheet, tab };
|
|
428
|
+
export { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, DEFAULT_PAPER_SIZE, FONT_SIZE, GENERATOR_NAME, GENERATOR_VERSION, GRID_SIZE, GraphConverter, KICAD_SCH_FRAME, KiCadProjectArchive, type LabelPadding, Layout, NetListConverter, type NetlistProject, type NetlistToKicadContext, PAPER, PAPER_SIZE, SCHEMATIC_PRINTER, SCH_VERSION, type Size, StringFormatter, WIRE_PADDING, collect_sub_sheets, collect_sub_sheets_by_id, convert_graph_to_design_block, convert_graph_to_kicad_project, convert_graph_to_sheets, filterNullOrUndefined, fmt_module_place_holder_sch_name, fmt_to_valid_filename, gen_empty_sch, gen_lib_gnd, gen_lib_vcc, gen_sch_gnd, gen_sch_vcc, get_power_pos, get_sch_default_drawing_sheet, tab };
|
package/dist/index.js
CHANGED
|
@@ -98,6 +98,9 @@ __export(index_exports, {
|
|
|
98
98
|
convert_graph_to_kicad_project: () => convert_graph_to_kicad_project,
|
|
99
99
|
convert_graph_to_sheets: () => convert_graph_to_sheets,
|
|
100
100
|
filterNullOrUndefined: () => filterNullOrUndefined,
|
|
101
|
+
fmt_module_place_holder_sch_name: () => fmt_module_place_holder_sch_name,
|
|
102
|
+
fmt_to_valid_filename: () => fmt_to_valid_filename,
|
|
103
|
+
gen_empty_sch: () => gen_empty_sch,
|
|
101
104
|
gen_lib_gnd: () => gen_lib_gnd,
|
|
102
105
|
gen_lib_vcc: () => gen_lib_vcc,
|
|
103
106
|
gen_sch_gnd: () => gen_sch_gnd,
|
|
@@ -122,7 +125,7 @@ function get_sch_default_drawing_sheet() {
|
|
|
122
125
|
// src/converter/kicad_sexpr/eeschema/printer.ts
|
|
123
126
|
var import_electronics_model = require("@modular-circuit/electronics-model");
|
|
124
127
|
var import_ir = require("@modular-circuit/ir");
|
|
125
|
-
var
|
|
128
|
+
var import_utils4 = require("@modular-circuit/utils");
|
|
126
129
|
|
|
127
130
|
// src/utils/collect_sub_sheets.ts
|
|
128
131
|
var import_utils = require("@modular-circuit/utils");
|
|
@@ -284,6 +287,38 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
|
|
|
284
287
|
return { sheets, module_main_sheet, modules, design_blocks };
|
|
285
288
|
}
|
|
286
289
|
|
|
290
|
+
// src/utils/fmt_to_valid_filename.ts
|
|
291
|
+
var fmt_to_valid_filename = (name) => {
|
|
292
|
+
return name.replace(/[\\/:*?"<>|]/g, "_").trim();
|
|
293
|
+
};
|
|
294
|
+
var fmt_module_place_holder_sch_name = (mod_name) => `placeholder_${fmt_to_valid_filename(mod_name)}.kicad_sch`;
|
|
295
|
+
|
|
296
|
+
// src/utils/gen_empty_sch.ts
|
|
297
|
+
var import_utils3 = require("@modular-circuit/utils");
|
|
298
|
+
var gen_empty_sch = async (name) => {
|
|
299
|
+
const printer = new SCHEMATIC_PRINTER();
|
|
300
|
+
const schematics = {};
|
|
301
|
+
const filename = `${name}`;
|
|
302
|
+
schematics[filename] = {
|
|
303
|
+
uuid: (0, import_utils3.gen_uuid)(),
|
|
304
|
+
filename,
|
|
305
|
+
sheet_symbols: [],
|
|
306
|
+
powers: [],
|
|
307
|
+
hiera_labels: []
|
|
308
|
+
};
|
|
309
|
+
const EMPTY_SCH = await new NetListConverter({
|
|
310
|
+
netlist: {
|
|
311
|
+
nets: [],
|
|
312
|
+
schematics
|
|
313
|
+
},
|
|
314
|
+
project: {
|
|
315
|
+
author: "eda.cn",
|
|
316
|
+
name
|
|
317
|
+
}
|
|
318
|
+
}).convert_to_kicad();
|
|
319
|
+
return printer.schematic(EMPTY_SCH[filename]);
|
|
320
|
+
};
|
|
321
|
+
|
|
287
322
|
// src/converter/kicad_sexpr/eeschema/printer.ts
|
|
288
323
|
var SCOPE_START = "\n ";
|
|
289
324
|
var SPACE = " ";
|
|
@@ -321,7 +356,7 @@ var SCHEMATIC_PRINTER = class {
|
|
|
321
356
|
(version ${SCH_VERSION})
|
|
322
357
|
(generator "${GENERATOR_NAME}")
|
|
323
358
|
(generator_version "${GENERATOR_VERSION}")
|
|
324
|
-
(uuid "${(0,
|
|
359
|
+
(uuid "${(0, import_utils4.gen_uuid)()}")
|
|
325
360
|
(paper "${PAPER}")
|
|
326
361
|
${lib_symbols}
|
|
327
362
|
${wires}
|
|
@@ -1782,10 +1817,10 @@ var Layout = class {
|
|
|
1782
1817
|
// src/converter/netlist_to_kicad/netlist_converter.ts
|
|
1783
1818
|
var import_electronics_model8 = require("@modular-circuit/electronics-model");
|
|
1784
1819
|
var import_ir4 = require("@modular-circuit/ir");
|
|
1785
|
-
var
|
|
1820
|
+
var import_utils14 = require("@modular-circuit/utils");
|
|
1786
1821
|
|
|
1787
1822
|
// src/kicad/label/net_label.ts
|
|
1788
|
-
var
|
|
1823
|
+
var import_utils6 = require("@modular-circuit/utils");
|
|
1789
1824
|
var gen_net_label = (name, at, justify) => ({
|
|
1790
1825
|
label_type: "label",
|
|
1791
1826
|
text: name,
|
|
@@ -1793,23 +1828,23 @@ var gen_net_label = (name, at, justify) => ({
|
|
|
1793
1828
|
fields_autoplaced: true,
|
|
1794
1829
|
at: { position: at, rotation: 0 },
|
|
1795
1830
|
effects: {
|
|
1796
|
-
font: { size:
|
|
1831
|
+
font: { size: import_utils6.DEFAULT_FONT_SIZE },
|
|
1797
1832
|
justify
|
|
1798
1833
|
},
|
|
1799
|
-
uuid: (0,
|
|
1834
|
+
uuid: (0, import_utils6.gen_uuid)()
|
|
1800
1835
|
});
|
|
1801
1836
|
|
|
1802
1837
|
// src/kicad/label/sheet_pin.ts
|
|
1803
|
-
var
|
|
1838
|
+
var import_utils7 = require("@modular-circuit/utils");
|
|
1804
1839
|
var gen_base_hierarchical_label = (text, at, justify, rotation, shape) => ({
|
|
1805
1840
|
shape,
|
|
1806
1841
|
effects: {
|
|
1807
|
-
font: { size:
|
|
1842
|
+
font: { size: import_utils7.DEFAULT_FONT_SIZE },
|
|
1808
1843
|
justify
|
|
1809
1844
|
},
|
|
1810
1845
|
text,
|
|
1811
1846
|
at: { position: at, rotation },
|
|
1812
|
-
uuid: (0,
|
|
1847
|
+
uuid: (0, import_utils7.gen_uuid)()
|
|
1813
1848
|
});
|
|
1814
1849
|
var gen_sheet_pin = (text, at, justify, rotation, shape) => ({
|
|
1815
1850
|
label_type: "hierarchical_label",
|
|
@@ -1818,7 +1853,7 @@ var gen_sheet_pin = (text, at, justify, rotation, shape) => ({
|
|
|
1818
1853
|
var gen_hierarchical_label = gen_sheet_pin;
|
|
1819
1854
|
|
|
1820
1855
|
// src/kicad/sheet/sheet.ts
|
|
1821
|
-
var
|
|
1856
|
+
var import_utils8 = require("@modular-circuit/utils");
|
|
1822
1857
|
var TEXT_MARGIN = 0.7116;
|
|
1823
1858
|
var gen_sch_sheet = (rect, pins, fields) => ({
|
|
1824
1859
|
// NOTE no rotation in the sheet
|
|
@@ -1831,7 +1866,7 @@ var gen_sch_sheet = (rect, pins, fields) => ({
|
|
|
1831
1866
|
text: fields.Sheetname,
|
|
1832
1867
|
at: { position: { x: rect.pos.x, y: rect.pos.y - TEXT_MARGIN }, rotation: 0 },
|
|
1833
1868
|
effects: {
|
|
1834
|
-
font: { size:
|
|
1869
|
+
font: { size: import_utils8.DEFAULT_FONT_SIZE },
|
|
1835
1870
|
justify: {
|
|
1836
1871
|
vertical: "bottom",
|
|
1837
1872
|
horizontal: "left"
|
|
@@ -1843,7 +1878,7 @@ var gen_sch_sheet = (rect, pins, fields) => ({
|
|
|
1843
1878
|
text: fields.Sheetfile,
|
|
1844
1879
|
at: { position: { x: rect.pos.x, y: rect.pos.y + rect.size.y + TEXT_MARGIN }, rotation: 0 },
|
|
1845
1880
|
effects: {
|
|
1846
|
-
font: { size:
|
|
1881
|
+
font: { size: import_utils8.DEFAULT_FONT_SIZE },
|
|
1847
1882
|
justify: {
|
|
1848
1883
|
vertical: "top",
|
|
1849
1884
|
horizontal: "left"
|
|
@@ -1859,13 +1894,13 @@ var gen_sch_sheet = (rect, pins, fields) => ({
|
|
|
1859
1894
|
fill: {
|
|
1860
1895
|
color: { r: 0, g: 0, b: 0, a: 0 }
|
|
1861
1896
|
},
|
|
1862
|
-
uuid: (0,
|
|
1897
|
+
uuid: (0, import_utils8.gen_uuid)()
|
|
1863
1898
|
});
|
|
1864
1899
|
|
|
1865
1900
|
// src/kicad/symbols/lib_symbol/gnd.ts
|
|
1866
1901
|
var import_electronics_model5 = require("@modular-circuit/electronics-model");
|
|
1867
1902
|
var import_ir2 = require("@modular-circuit/ir");
|
|
1868
|
-
var
|
|
1903
|
+
var import_utils9 = require("@modular-circuit/utils");
|
|
1869
1904
|
var gen_lib_gnd = (value) => ({
|
|
1870
1905
|
name: `power:${value}`,
|
|
1871
1906
|
pin_numbers: {
|
|
@@ -1885,7 +1920,7 @@ var gen_lib_gnd = (value) => ({
|
|
|
1885
1920
|
text: "#PWR",
|
|
1886
1921
|
at: { position: { x: 0, y: -6.35 }, rotation: 0 },
|
|
1887
1922
|
effects: {
|
|
1888
|
-
font: { size:
|
|
1923
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE },
|
|
1889
1924
|
hide: true
|
|
1890
1925
|
}
|
|
1891
1926
|
},
|
|
@@ -1894,7 +1929,7 @@ var gen_lib_gnd = (value) => ({
|
|
|
1894
1929
|
text: `${value}`,
|
|
1895
1930
|
at: { position: { x: 0, y: -3.81 }, rotation: 0 },
|
|
1896
1931
|
effects: {
|
|
1897
|
-
font: { size:
|
|
1932
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE }
|
|
1898
1933
|
}
|
|
1899
1934
|
},
|
|
1900
1935
|
{
|
|
@@ -1902,7 +1937,7 @@ var gen_lib_gnd = (value) => ({
|
|
|
1902
1937
|
text: "",
|
|
1903
1938
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
1904
1939
|
effects: {
|
|
1905
|
-
font: { size:
|
|
1940
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE },
|
|
1906
1941
|
hide: true
|
|
1907
1942
|
}
|
|
1908
1943
|
},
|
|
@@ -1911,7 +1946,7 @@ var gen_lib_gnd = (value) => ({
|
|
|
1911
1946
|
text: "",
|
|
1912
1947
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
1913
1948
|
effects: {
|
|
1914
|
-
font: { size:
|
|
1949
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE },
|
|
1915
1950
|
hide: true
|
|
1916
1951
|
}
|
|
1917
1952
|
},
|
|
@@ -1920,7 +1955,7 @@ var gen_lib_gnd = (value) => ({
|
|
|
1920
1955
|
text: 'Power symbol creates a global label with name \\"GND\\" , ground',
|
|
1921
1956
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
1922
1957
|
effects: {
|
|
1923
|
-
font: { size:
|
|
1958
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE },
|
|
1924
1959
|
hide: true
|
|
1925
1960
|
}
|
|
1926
1961
|
},
|
|
@@ -1929,7 +1964,7 @@ var gen_lib_gnd = (value) => ({
|
|
|
1929
1964
|
text: "global power",
|
|
1930
1965
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
1931
1966
|
effects: {
|
|
1932
|
-
font: { size:
|
|
1967
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE },
|
|
1933
1968
|
hide: true
|
|
1934
1969
|
}
|
|
1935
1970
|
}
|
|
@@ -1970,13 +2005,13 @@ var gen_lib_gnd = (value) => ({
|
|
|
1970
2005
|
name: {
|
|
1971
2006
|
text: "~",
|
|
1972
2007
|
effects: {
|
|
1973
|
-
font: { size:
|
|
2008
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE }
|
|
1974
2009
|
}
|
|
1975
2010
|
},
|
|
1976
2011
|
number: {
|
|
1977
2012
|
text: "1",
|
|
1978
2013
|
effects: {
|
|
1979
|
-
font: { size:
|
|
2014
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE }
|
|
1980
2015
|
}
|
|
1981
2016
|
}
|
|
1982
2017
|
}
|
|
@@ -1988,7 +2023,7 @@ var gen_lib_gnd = (value) => ({
|
|
|
1988
2023
|
// src/kicad/symbols/lib_symbol/vcc.ts
|
|
1989
2024
|
var import_electronics_model6 = require("@modular-circuit/electronics-model");
|
|
1990
2025
|
var import_ir3 = require("@modular-circuit/ir");
|
|
1991
|
-
var
|
|
2026
|
+
var import_utils10 = require("@modular-circuit/utils");
|
|
1992
2027
|
var gen_lib_vcc = (value) => ({
|
|
1993
2028
|
name: `power:${value}`,
|
|
1994
2029
|
power: true,
|
|
@@ -2009,7 +2044,7 @@ var gen_lib_vcc = (value) => ({
|
|
|
2009
2044
|
text: "#PWR",
|
|
2010
2045
|
at: { position: { x: 0, y: -3.81 }, rotation: 0 },
|
|
2011
2046
|
effects: {
|
|
2012
|
-
font: { size:
|
|
2047
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE },
|
|
2013
2048
|
hide: true
|
|
2014
2049
|
}
|
|
2015
2050
|
},
|
|
@@ -2018,7 +2053,7 @@ var gen_lib_vcc = (value) => ({
|
|
|
2018
2053
|
text: `${value}`,
|
|
2019
2054
|
at: { position: { x: 0, y: 3.556 }, rotation: 0 },
|
|
2020
2055
|
effects: {
|
|
2021
|
-
font: { size:
|
|
2056
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE }
|
|
2022
2057
|
}
|
|
2023
2058
|
},
|
|
2024
2059
|
{
|
|
@@ -2026,7 +2061,7 @@ var gen_lib_vcc = (value) => ({
|
|
|
2026
2061
|
text: "",
|
|
2027
2062
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
2028
2063
|
effects: {
|
|
2029
|
-
font: { size:
|
|
2064
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE },
|
|
2030
2065
|
hide: true
|
|
2031
2066
|
}
|
|
2032
2067
|
},
|
|
@@ -2035,7 +2070,7 @@ var gen_lib_vcc = (value) => ({
|
|
|
2035
2070
|
text: "",
|
|
2036
2071
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
2037
2072
|
effects: {
|
|
2038
|
-
font: { size:
|
|
2073
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE },
|
|
2039
2074
|
hide: true
|
|
2040
2075
|
}
|
|
2041
2076
|
},
|
|
@@ -2044,7 +2079,7 @@ var gen_lib_vcc = (value) => ({
|
|
|
2044
2079
|
text: `Power symbol creates a global label with name \\"${value}\\"`,
|
|
2045
2080
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
2046
2081
|
effects: {
|
|
2047
|
-
font: { size:
|
|
2082
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE },
|
|
2048
2083
|
hide: true
|
|
2049
2084
|
}
|
|
2050
2085
|
},
|
|
@@ -2053,7 +2088,7 @@ var gen_lib_vcc = (value) => ({
|
|
|
2053
2088
|
text: "global power",
|
|
2054
2089
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
2055
2090
|
effects: {
|
|
2056
|
-
font: { size:
|
|
2091
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE },
|
|
2057
2092
|
hide: true
|
|
2058
2093
|
}
|
|
2059
2094
|
}
|
|
@@ -2091,13 +2126,13 @@ var gen_lib_vcc = (value) => ({
|
|
|
2091
2126
|
name: {
|
|
2092
2127
|
text: "~",
|
|
2093
2128
|
effects: {
|
|
2094
|
-
font: { size:
|
|
2129
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE }
|
|
2095
2130
|
}
|
|
2096
2131
|
},
|
|
2097
2132
|
number: {
|
|
2098
2133
|
text: "1",
|
|
2099
2134
|
effects: {
|
|
2100
|
-
font: { size:
|
|
2135
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE }
|
|
2101
2136
|
}
|
|
2102
2137
|
}
|
|
2103
2138
|
}
|
|
@@ -2107,7 +2142,7 @@ var gen_lib_vcc = (value) => ({
|
|
|
2107
2142
|
});
|
|
2108
2143
|
|
|
2109
2144
|
// src/kicad/symbols/sch_symbol/gnd.ts
|
|
2110
|
-
var
|
|
2145
|
+
var import_utils11 = require("@modular-circuit/utils");
|
|
2111
2146
|
|
|
2112
2147
|
// src/kicad/symbols/symbol_utils.ts
|
|
2113
2148
|
var gen_pwr_ref = (pwr_num) => `#PWR${pwr_num}`;
|
|
@@ -2122,14 +2157,14 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
|
|
|
2122
2157
|
on_board: true,
|
|
2123
2158
|
dnp: false,
|
|
2124
2159
|
fields_autoplaced: true,
|
|
2125
|
-
uuid: (0,
|
|
2160
|
+
uuid: (0, import_utils11.gen_uuid)(),
|
|
2126
2161
|
properties: [
|
|
2127
2162
|
{
|
|
2128
2163
|
name: "Reference",
|
|
2129
2164
|
text: gen_pwr_ref(pwr_number),
|
|
2130
2165
|
at: { position: { x: position.x, y: position.y + 6.35 }, rotation: 0 },
|
|
2131
2166
|
effects: {
|
|
2132
|
-
font: { size:
|
|
2167
|
+
font: { size: import_utils11.DEFAULT_FONT_SIZE },
|
|
2133
2168
|
hide: true
|
|
2134
2169
|
}
|
|
2135
2170
|
},
|
|
@@ -2138,7 +2173,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
|
|
|
2138
2173
|
text: `${value}`,
|
|
2139
2174
|
at: { position: { x: position.x, y: position.y + 5.08 }, rotation: 0 },
|
|
2140
2175
|
effects: {
|
|
2141
|
-
font: { size:
|
|
2176
|
+
font: { size: import_utils11.DEFAULT_FONT_SIZE }
|
|
2142
2177
|
}
|
|
2143
2178
|
},
|
|
2144
2179
|
{
|
|
@@ -2146,7 +2181,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
|
|
|
2146
2181
|
text: "",
|
|
2147
2182
|
at: { position, rotation: 0 },
|
|
2148
2183
|
effects: {
|
|
2149
|
-
font: { size:
|
|
2184
|
+
font: { size: import_utils11.DEFAULT_FONT_SIZE },
|
|
2150
2185
|
hide: true
|
|
2151
2186
|
}
|
|
2152
2187
|
},
|
|
@@ -2155,7 +2190,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
|
|
|
2155
2190
|
text: "",
|
|
2156
2191
|
at: { position, rotation: 0 },
|
|
2157
2192
|
effects: {
|
|
2158
|
-
font: { size:
|
|
2193
|
+
font: { size: import_utils11.DEFAULT_FONT_SIZE },
|
|
2159
2194
|
hide: true
|
|
2160
2195
|
}
|
|
2161
2196
|
},
|
|
@@ -2164,7 +2199,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
|
|
|
2164
2199
|
text: `Power symbol creates a global label with name \\"${value}\\" , ground`,
|
|
2165
2200
|
at: { position, rotation: 0 },
|
|
2166
2201
|
effects: {
|
|
2167
|
-
font: { size:
|
|
2202
|
+
font: { size: import_utils11.DEFAULT_FONT_SIZE },
|
|
2168
2203
|
hide: true
|
|
2169
2204
|
}
|
|
2170
2205
|
}
|
|
@@ -2178,7 +2213,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
|
|
|
2178
2213
|
});
|
|
2179
2214
|
|
|
2180
2215
|
// src/kicad/symbols/sch_symbol/vcc.ts
|
|
2181
|
-
var
|
|
2216
|
+
var import_utils12 = require("@modular-circuit/utils");
|
|
2182
2217
|
var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
2183
2218
|
lib_id: `power:${value}`,
|
|
2184
2219
|
at: { position, rotation: 0 },
|
|
@@ -2188,14 +2223,14 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
|
2188
2223
|
on_board: true,
|
|
2189
2224
|
dnp: false,
|
|
2190
2225
|
fields_autoplaced: true,
|
|
2191
|
-
uuid: (0,
|
|
2226
|
+
uuid: (0, import_utils12.gen_uuid)(),
|
|
2192
2227
|
properties: [
|
|
2193
2228
|
{
|
|
2194
2229
|
name: "Reference",
|
|
2195
2230
|
text: gen_pwr_ref(pwr_number),
|
|
2196
2231
|
at: { position: { x: position.x, y: position.y + 3.81 }, rotation: 0 },
|
|
2197
2232
|
effects: {
|
|
2198
|
-
font: { size:
|
|
2233
|
+
font: { size: import_utils12.DEFAULT_FONT_SIZE },
|
|
2199
2234
|
hide: true
|
|
2200
2235
|
}
|
|
2201
2236
|
},
|
|
@@ -2204,7 +2239,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
|
2204
2239
|
text: `${value}`,
|
|
2205
2240
|
at: { position: { x: position.x, y: position.y - 5.08 }, rotation: 0 },
|
|
2206
2241
|
effects: {
|
|
2207
|
-
font: { size:
|
|
2242
|
+
font: { size: import_utils12.DEFAULT_FONT_SIZE }
|
|
2208
2243
|
}
|
|
2209
2244
|
},
|
|
2210
2245
|
{
|
|
@@ -2212,7 +2247,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
|
2212
2247
|
text: "",
|
|
2213
2248
|
at: { position, rotation: 0 },
|
|
2214
2249
|
effects: {
|
|
2215
|
-
font: { size:
|
|
2250
|
+
font: { size: import_utils12.DEFAULT_FONT_SIZE },
|
|
2216
2251
|
hide: true
|
|
2217
2252
|
}
|
|
2218
2253
|
},
|
|
@@ -2221,7 +2256,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
|
2221
2256
|
text: "",
|
|
2222
2257
|
at: { position, rotation: 0 },
|
|
2223
2258
|
effects: {
|
|
2224
|
-
font: { size:
|
|
2259
|
+
font: { size: import_utils12.DEFAULT_FONT_SIZE },
|
|
2225
2260
|
hide: true
|
|
2226
2261
|
}
|
|
2227
2262
|
},
|
|
@@ -2230,7 +2265,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
|
2230
2265
|
text: `Power symbol creates a global label with name \\"${value}\\"`,
|
|
2231
2266
|
at: { position, rotation: 0 },
|
|
2232
2267
|
effects: {
|
|
2233
|
-
font: { size:
|
|
2268
|
+
font: { size: import_utils12.DEFAULT_FONT_SIZE },
|
|
2234
2269
|
hide: true
|
|
2235
2270
|
}
|
|
2236
2271
|
}
|
|
@@ -2245,7 +2280,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
|
2245
2280
|
|
|
2246
2281
|
// src/kicad/wire/gen_wire.ts
|
|
2247
2282
|
var import_electronics_model7 = require("@modular-circuit/electronics-model");
|
|
2248
|
-
var
|
|
2283
|
+
var import_utils13 = require("@modular-circuit/utils");
|
|
2249
2284
|
var gen_wire = (start, end) => ({
|
|
2250
2285
|
stroke: {
|
|
2251
2286
|
type: "default",
|
|
@@ -2253,7 +2288,7 @@ var gen_wire = (start, end) => ({
|
|
|
2253
2288
|
},
|
|
2254
2289
|
start,
|
|
2255
2290
|
end,
|
|
2256
|
-
uuid: (0,
|
|
2291
|
+
uuid: (0, import_utils13.gen_uuid)(),
|
|
2257
2292
|
type: import_electronics_model7.GS_SCH_ITEM_TYPE.LINE
|
|
2258
2293
|
});
|
|
2259
2294
|
|
|
@@ -2309,7 +2344,7 @@ var NetListConverter = class {
|
|
|
2309
2344
|
},
|
|
2310
2345
|
title_block: {
|
|
2311
2346
|
title: name.replace(`.${import_ir4.MODULAR_CIRCUIT_SCH_EXT}`, ""),
|
|
2312
|
-
date: (0,
|
|
2347
|
+
date: (0, import_utils14.replaceAll)((/* @__PURE__ */ new Date()).toISOString().slice(0, 10), "-", "/"),
|
|
2313
2348
|
rev: "1.0",
|
|
2314
2349
|
comment: {
|
|
2315
2350
|
1: "https://www.eda.cn",
|
|
@@ -2472,7 +2507,7 @@ var NetListConverter = class {
|
|
|
2472
2507
|
// src/builder/graph_to_kicad/convert_graph_to_sheets.ts
|
|
2473
2508
|
var import_ir5 = require("@modular-circuit/ir");
|
|
2474
2509
|
var import_perc = require("@modular-circuit/perc");
|
|
2475
|
-
var
|
|
2510
|
+
var import_utils15 = require("@modular-circuit/utils");
|
|
2476
2511
|
async function do_convert_graph_to_kicad_project(ctx) {
|
|
2477
2512
|
const module_ids = [];
|
|
2478
2513
|
for (const sch of Object.values(ctx.schematics)) {
|
|
@@ -2489,6 +2524,16 @@ async function do_convert_graph_to_kicad_project(ctx) {
|
|
|
2489
2524
|
const netlist = new GraphConverter({
|
|
2490
2525
|
...ctx
|
|
2491
2526
|
}).convert_to_netlist();
|
|
2527
|
+
for (const sch of Object.values(netlist.schematics)) {
|
|
2528
|
+
for (const sheet of sch.sheet_symbols) {
|
|
2529
|
+
const original_st_fn = sheet.sheet_file_name;
|
|
2530
|
+
if (!(original_st_fn in sheets)) {
|
|
2531
|
+
const placeholder_fn = fmt_module_place_holder_sch_name(sheet.sheet_name);
|
|
2532
|
+
sheet.sheet_file_name = placeholder_fn;
|
|
2533
|
+
sheets[placeholder_fn] = await gen_empty_sch(placeholder_fn);
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2492
2537
|
const converted_sheets = await new NetListConverter({
|
|
2493
2538
|
...ctx,
|
|
2494
2539
|
netlist
|
|
@@ -2498,7 +2543,7 @@ async function do_convert_graph_to_kicad_project(ctx) {
|
|
|
2498
2543
|
if (k in sheets) {
|
|
2499
2544
|
console.error(`Duplicated sheet file name found ${k}`);
|
|
2500
2545
|
}
|
|
2501
|
-
sheets[k.replace(import_ir5.MODULAR_CIRCUIT_SCH_EXT,
|
|
2546
|
+
sheets[k.replace(import_ir5.MODULAR_CIRCUIT_SCH_EXT, import_utils15.KiCadSchematicFileExtension)] = sexpr_printer.schematic(v);
|
|
2502
2547
|
}
|
|
2503
2548
|
return sheets;
|
|
2504
2549
|
}
|
|
@@ -2598,7 +2643,7 @@ var kicad_prl = (prj_name) => ({
|
|
|
2598
2643
|
});
|
|
2599
2644
|
|
|
2600
2645
|
// src/kicad/project/kicad_pro.ts
|
|
2601
|
-
var
|
|
2646
|
+
var import_utils17 = require("@modular-circuit/utils");
|
|
2602
2647
|
var kicad_pro = (project_name) => ({
|
|
2603
2648
|
board: {
|
|
2604
2649
|
"3dviewports": [],
|
|
@@ -2808,7 +2853,7 @@ var kicad_pro = (project_name) => ({
|
|
|
2808
2853
|
version: 1
|
|
2809
2854
|
},
|
|
2810
2855
|
net_format_name: "",
|
|
2811
|
-
page_layout_descr_file: `${project_name}.${
|
|
2856
|
+
page_layout_descr_file: `${project_name}.${import_utils17.DrawingSheetFileExtension}`,
|
|
2812
2857
|
plot_directory: "",
|
|
2813
2858
|
spice_current_sheet_as_root: false,
|
|
2814
2859
|
spice_external_command: 'spice "%I"',
|
|
@@ -2824,7 +2869,7 @@ var kicad_pro = (project_name) => ({
|
|
|
2824
2869
|
});
|
|
2825
2870
|
|
|
2826
2871
|
// src/kicad/project/kicad_project_archive.ts
|
|
2827
|
-
var
|
|
2872
|
+
var import_utils18 = require("@modular-circuit/utils");
|
|
2828
2873
|
var import_jszip = __toESM(require("jszip"));
|
|
2829
2874
|
var KICAD_SCH_FRAME = get_sch_default_drawing_sheet();
|
|
2830
2875
|
var KiCadProjectArchive = class {
|
|
@@ -2848,7 +2893,7 @@ var KiCadProjectArchive = class {
|
|
|
2848
2893
|
return kicad_pro(this.project_name);
|
|
2849
2894
|
}
|
|
2850
2895
|
get main_sch_name() {
|
|
2851
|
-
return this.get_project_directive_file_name(
|
|
2896
|
+
return this.get_project_directive_file_name(import_utils18.KiCadSchematicFileExtension);
|
|
2852
2897
|
}
|
|
2853
2898
|
get_project_directive_file_name(ext) {
|
|
2854
2899
|
return `${this.project_name}.${ext}`;
|
|
@@ -2856,15 +2901,15 @@ var KiCadProjectArchive = class {
|
|
|
2856
2901
|
async toZip() {
|
|
2857
2902
|
const zip = new import_jszip.default();
|
|
2858
2903
|
zip.file(
|
|
2859
|
-
this.get_project_directive_file_name(
|
|
2904
|
+
this.get_project_directive_file_name(import_utils18.ProjectLocalSettingsFileExtension),
|
|
2860
2905
|
JSON.stringify(this.kicad_prl)
|
|
2861
2906
|
);
|
|
2862
2907
|
zip.file(
|
|
2863
|
-
this.get_project_directive_file_name(
|
|
2908
|
+
this.get_project_directive_file_name(import_utils18.ProjectFileExtension),
|
|
2864
2909
|
JSON.stringify(this.kicad_pro)
|
|
2865
2910
|
);
|
|
2866
2911
|
zip.file(
|
|
2867
|
-
this.get_project_directive_file_name(
|
|
2912
|
+
this.get_project_directive_file_name(import_utils18.DrawingSheetFileExtension),
|
|
2868
2913
|
this.sch_frame
|
|
2869
2914
|
);
|
|
2870
2915
|
for (const schematic of this.designBlock.schematics) {
|
|
@@ -2920,9 +2965,9 @@ var KiCadProjectArchive = class {
|
|
|
2920
2965
|
};
|
|
2921
2966
|
|
|
2922
2967
|
// src/builder/graph_to_kicad/convert_graph_to_design_block.ts
|
|
2923
|
-
var
|
|
2968
|
+
var import_utils19 = require("@modular-circuit/utils");
|
|
2924
2969
|
async function convert_graph_to_design_block(ctx) {
|
|
2925
|
-
const root = ctx.project.main.replace(
|
|
2970
|
+
const root = ctx.project.main.replace(import_utils19.ModularCircuitFileExtension, import_utils19.KiCadSchematicFileExtension);
|
|
2926
2971
|
const sheets = await convert_graph_to_sheets(ctx);
|
|
2927
2972
|
if (!(root in sheets)) {
|
|
2928
2973
|
throw new Error(`Cannot find root sch file ${root}`);
|
|
@@ -2973,6 +3018,9 @@ async function convert_graph_to_kicad_project(ctx) {
|
|
|
2973
3018
|
convert_graph_to_kicad_project,
|
|
2974
3019
|
convert_graph_to_sheets,
|
|
2975
3020
|
filterNullOrUndefined,
|
|
3021
|
+
fmt_module_place_holder_sch_name,
|
|
3022
|
+
fmt_to_valid_filename,
|
|
3023
|
+
gen_empty_sch,
|
|
2976
3024
|
gen_lib_gnd,
|
|
2977
3025
|
gen_lib_vcc,
|
|
2978
3026
|
gen_sch_gnd,
|
package/dist/index.mjs
CHANGED
|
@@ -62,7 +62,7 @@ import { READABLE_ELECTRICAL_PINTYPE } from "@modular-circuit/electronics-model"
|
|
|
62
62
|
import {
|
|
63
63
|
SHAPE_T
|
|
64
64
|
} from "@modular-circuit/ir";
|
|
65
|
-
import { gen_uuid } from "@modular-circuit/utils";
|
|
65
|
+
import { gen_uuid as gen_uuid2 } from "@modular-circuit/utils";
|
|
66
66
|
|
|
67
67
|
// src/utils/collect_sub_sheets.ts
|
|
68
68
|
import { KiCadSchematicFileExtension, parse_module_name, remove_filename_path_prefix, unzipFile } from "@modular-circuit/utils";
|
|
@@ -230,6 +230,38 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
|
|
|
230
230
|
return { sheets, module_main_sheet, modules, design_blocks };
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
// src/utils/fmt_to_valid_filename.ts
|
|
234
|
+
var fmt_to_valid_filename = (name) => {
|
|
235
|
+
return name.replace(/[\\/:*?"<>|]/g, "_").trim();
|
|
236
|
+
};
|
|
237
|
+
var fmt_module_place_holder_sch_name = (mod_name) => `placeholder_${fmt_to_valid_filename(mod_name)}.kicad_sch`;
|
|
238
|
+
|
|
239
|
+
// src/utils/gen_empty_sch.ts
|
|
240
|
+
import { gen_uuid } from "@modular-circuit/utils";
|
|
241
|
+
var gen_empty_sch = async (name) => {
|
|
242
|
+
const printer = new SCHEMATIC_PRINTER();
|
|
243
|
+
const schematics = {};
|
|
244
|
+
const filename = `${name}`;
|
|
245
|
+
schematics[filename] = {
|
|
246
|
+
uuid: gen_uuid(),
|
|
247
|
+
filename,
|
|
248
|
+
sheet_symbols: [],
|
|
249
|
+
powers: [],
|
|
250
|
+
hiera_labels: []
|
|
251
|
+
};
|
|
252
|
+
const EMPTY_SCH = await new NetListConverter({
|
|
253
|
+
netlist: {
|
|
254
|
+
nets: [],
|
|
255
|
+
schematics
|
|
256
|
+
},
|
|
257
|
+
project: {
|
|
258
|
+
author: "eda.cn",
|
|
259
|
+
name
|
|
260
|
+
}
|
|
261
|
+
}).convert_to_kicad();
|
|
262
|
+
return printer.schematic(EMPTY_SCH[filename]);
|
|
263
|
+
};
|
|
264
|
+
|
|
233
265
|
// src/converter/kicad_sexpr/eeschema/printer.ts
|
|
234
266
|
var SCOPE_START = "\n ";
|
|
235
267
|
var SPACE = " ";
|
|
@@ -267,7 +299,7 @@ var SCHEMATIC_PRINTER = class {
|
|
|
267
299
|
(version ${SCH_VERSION})
|
|
268
300
|
(generator "${GENERATOR_NAME}")
|
|
269
301
|
(generator_version "${GENERATOR_VERSION}")
|
|
270
|
-
(uuid "${
|
|
302
|
+
(uuid "${gen_uuid2()}")
|
|
271
303
|
(paper "${PAPER}")
|
|
272
304
|
${lib_symbols}
|
|
273
305
|
${wires}
|
|
@@ -1745,7 +1777,7 @@ import {
|
|
|
1745
1777
|
import { replaceAll } from "@modular-circuit/utils";
|
|
1746
1778
|
|
|
1747
1779
|
// src/kicad/label/net_label.ts
|
|
1748
|
-
import { DEFAULT_FONT_SIZE, gen_uuid as
|
|
1780
|
+
import { DEFAULT_FONT_SIZE, gen_uuid as gen_uuid3 } from "@modular-circuit/utils";
|
|
1749
1781
|
var gen_net_label = (name, at, justify) => ({
|
|
1750
1782
|
label_type: "label",
|
|
1751
1783
|
text: name,
|
|
@@ -1756,11 +1788,11 @@ var gen_net_label = (name, at, justify) => ({
|
|
|
1756
1788
|
font: { size: DEFAULT_FONT_SIZE },
|
|
1757
1789
|
justify
|
|
1758
1790
|
},
|
|
1759
|
-
uuid:
|
|
1791
|
+
uuid: gen_uuid3()
|
|
1760
1792
|
});
|
|
1761
1793
|
|
|
1762
1794
|
// src/kicad/label/sheet_pin.ts
|
|
1763
|
-
import { DEFAULT_FONT_SIZE as DEFAULT_FONT_SIZE2, gen_uuid as
|
|
1795
|
+
import { DEFAULT_FONT_SIZE as DEFAULT_FONT_SIZE2, gen_uuid as gen_uuid4 } from "@modular-circuit/utils";
|
|
1764
1796
|
var gen_base_hierarchical_label = (text, at, justify, rotation, shape) => ({
|
|
1765
1797
|
shape,
|
|
1766
1798
|
effects: {
|
|
@@ -1769,7 +1801,7 @@ var gen_base_hierarchical_label = (text, at, justify, rotation, shape) => ({
|
|
|
1769
1801
|
},
|
|
1770
1802
|
text,
|
|
1771
1803
|
at: { position: at, rotation },
|
|
1772
|
-
uuid:
|
|
1804
|
+
uuid: gen_uuid4()
|
|
1773
1805
|
});
|
|
1774
1806
|
var gen_sheet_pin = (text, at, justify, rotation, shape) => ({
|
|
1775
1807
|
label_type: "hierarchical_label",
|
|
@@ -1778,7 +1810,7 @@ var gen_sheet_pin = (text, at, justify, rotation, shape) => ({
|
|
|
1778
1810
|
var gen_hierarchical_label = gen_sheet_pin;
|
|
1779
1811
|
|
|
1780
1812
|
// src/kicad/sheet/sheet.ts
|
|
1781
|
-
import { DEFAULT_FONT_SIZE as DEFAULT_FONT_SIZE3, gen_uuid as
|
|
1813
|
+
import { DEFAULT_FONT_SIZE as DEFAULT_FONT_SIZE3, gen_uuid as gen_uuid5 } from "@modular-circuit/utils";
|
|
1782
1814
|
var TEXT_MARGIN = 0.7116;
|
|
1783
1815
|
var gen_sch_sheet = (rect, pins, fields) => ({
|
|
1784
1816
|
// NOTE no rotation in the sheet
|
|
@@ -1819,7 +1851,7 @@ var gen_sch_sheet = (rect, pins, fields) => ({
|
|
|
1819
1851
|
fill: {
|
|
1820
1852
|
color: { r: 0, g: 0, b: 0, a: 0 }
|
|
1821
1853
|
},
|
|
1822
|
-
uuid:
|
|
1854
|
+
uuid: gen_uuid5()
|
|
1823
1855
|
});
|
|
1824
1856
|
|
|
1825
1857
|
// src/kicad/symbols/lib_symbol/gnd.ts
|
|
@@ -2067,7 +2099,7 @@ var gen_lib_vcc = (value) => ({
|
|
|
2067
2099
|
});
|
|
2068
2100
|
|
|
2069
2101
|
// src/kicad/symbols/sch_symbol/gnd.ts
|
|
2070
|
-
import { DEFAULT_FONT_SIZE as DEFAULT_FONT_SIZE6, gen_uuid as
|
|
2102
|
+
import { DEFAULT_FONT_SIZE as DEFAULT_FONT_SIZE6, gen_uuid as gen_uuid6 } from "@modular-circuit/utils";
|
|
2071
2103
|
|
|
2072
2104
|
// src/kicad/symbols/symbol_utils.ts
|
|
2073
2105
|
var gen_pwr_ref = (pwr_num) => `#PWR${pwr_num}`;
|
|
@@ -2082,7 +2114,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
|
|
|
2082
2114
|
on_board: true,
|
|
2083
2115
|
dnp: false,
|
|
2084
2116
|
fields_autoplaced: true,
|
|
2085
|
-
uuid:
|
|
2117
|
+
uuid: gen_uuid6(),
|
|
2086
2118
|
properties: [
|
|
2087
2119
|
{
|
|
2088
2120
|
name: "Reference",
|
|
@@ -2138,7 +2170,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
|
|
|
2138
2170
|
});
|
|
2139
2171
|
|
|
2140
2172
|
// src/kicad/symbols/sch_symbol/vcc.ts
|
|
2141
|
-
import { DEFAULT_FONT_SIZE as DEFAULT_FONT_SIZE7, gen_uuid as
|
|
2173
|
+
import { DEFAULT_FONT_SIZE as DEFAULT_FONT_SIZE7, gen_uuid as gen_uuid7 } from "@modular-circuit/utils";
|
|
2142
2174
|
var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
2143
2175
|
lib_id: `power:${value}`,
|
|
2144
2176
|
at: { position, rotation: 0 },
|
|
@@ -2148,7 +2180,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
|
2148
2180
|
on_board: true,
|
|
2149
2181
|
dnp: false,
|
|
2150
2182
|
fields_autoplaced: true,
|
|
2151
|
-
uuid:
|
|
2183
|
+
uuid: gen_uuid7(),
|
|
2152
2184
|
properties: [
|
|
2153
2185
|
{
|
|
2154
2186
|
name: "Reference",
|
|
@@ -2205,7 +2237,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
|
2205
2237
|
|
|
2206
2238
|
// src/kicad/wire/gen_wire.ts
|
|
2207
2239
|
import { GS_SCH_ITEM_TYPE } from "@modular-circuit/electronics-model";
|
|
2208
|
-
import { gen_uuid as
|
|
2240
|
+
import { gen_uuid as gen_uuid8 } from "@modular-circuit/utils";
|
|
2209
2241
|
var gen_wire = (start, end) => ({
|
|
2210
2242
|
stroke: {
|
|
2211
2243
|
type: "default",
|
|
@@ -2213,7 +2245,7 @@ var gen_wire = (start, end) => ({
|
|
|
2213
2245
|
},
|
|
2214
2246
|
start,
|
|
2215
2247
|
end,
|
|
2216
|
-
uuid:
|
|
2248
|
+
uuid: gen_uuid8(),
|
|
2217
2249
|
type: GS_SCH_ITEM_TYPE.LINE
|
|
2218
2250
|
});
|
|
2219
2251
|
|
|
@@ -2453,6 +2485,16 @@ async function do_convert_graph_to_kicad_project(ctx) {
|
|
|
2453
2485
|
const netlist = new GraphConverter({
|
|
2454
2486
|
...ctx
|
|
2455
2487
|
}).convert_to_netlist();
|
|
2488
|
+
for (const sch of Object.values(netlist.schematics)) {
|
|
2489
|
+
for (const sheet of sch.sheet_symbols) {
|
|
2490
|
+
const original_st_fn = sheet.sheet_file_name;
|
|
2491
|
+
if (!(original_st_fn in sheets)) {
|
|
2492
|
+
const placeholder_fn = fmt_module_place_holder_sch_name(sheet.sheet_name);
|
|
2493
|
+
sheet.sheet_file_name = placeholder_fn;
|
|
2494
|
+
sheets[placeholder_fn] = await gen_empty_sch(placeholder_fn);
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2456
2498
|
const converted_sheets = await new NetListConverter({
|
|
2457
2499
|
...ctx,
|
|
2458
2500
|
netlist
|
|
@@ -2941,6 +2983,9 @@ export {
|
|
|
2941
2983
|
convert_graph_to_kicad_project,
|
|
2942
2984
|
convert_graph_to_sheets,
|
|
2943
2985
|
filterNullOrUndefined,
|
|
2986
|
+
fmt_module_place_holder_sch_name,
|
|
2987
|
+
fmt_to_valid_filename,
|
|
2988
|
+
gen_empty_sch,
|
|
2944
2989
|
gen_lib_gnd,
|
|
2945
2990
|
gen_lib_vcc,
|
|
2946
2991
|
gen_sch_gnd,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modular-circuit/transpiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Intermediate representation of the modular circuit",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"elkjs": "^0.11.0",
|
|
30
30
|
"js-base64": "^3.7.7",
|
|
31
31
|
"jszip": "^3.10.1",
|
|
32
|
-
"@modular-circuit/electronics-model": "0.
|
|
33
|
-
"@modular-circuit/
|
|
34
|
-
"@modular-circuit/
|
|
35
|
-
"@modular-circuit/
|
|
32
|
+
"@modular-circuit/electronics-model": "0.2.0",
|
|
33
|
+
"@modular-circuit/utils": "0.2.0",
|
|
34
|
+
"@modular-circuit/perc": "0.2.0",
|
|
35
|
+
"@modular-circuit/ir": "0.2.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"clean": "rimraf dist",
|