@modular-circuit/transpiler 0.2.12 → 0.3.1
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 +4 -8
- package/dist/index.d.ts +4 -8
- package/dist/index.js +85 -132
- package/dist/index.mjs +17 -68
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -133,7 +133,9 @@ declare class NetListConverter {
|
|
|
133
133
|
private convert_net_label;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
declare function convert_graph_to_sheets(ctx: ConvertGraphToKiCadInput): Promise<
|
|
136
|
+
declare function convert_graph_to_sheets(ctx: ConvertGraphToKiCadInput): Promise<{
|
|
137
|
+
[x: string]: string;
|
|
138
|
+
}>;
|
|
137
139
|
|
|
138
140
|
declare function convert_graph_to_kicad_project(ctx: ConvertGraphToKiCadInput): Promise<Blob>;
|
|
139
141
|
|
|
@@ -377,12 +379,6 @@ declare class KiCadProjectArchive {
|
|
|
377
379
|
toZip(): Promise<Blob>;
|
|
378
380
|
}
|
|
379
381
|
|
|
380
|
-
declare function collect_sub_sheets(dependencies: Record<string, string>, module_resolver: ModuleResolver): Promise<{
|
|
381
|
-
sheets: Record<string, string>;
|
|
382
|
-
module_main_sheet: Record<string, string>;
|
|
383
|
-
modules: Record<string, ModuleCircuit>;
|
|
384
|
-
}>;
|
|
385
|
-
|
|
386
382
|
declare function filterNullOrUndefined(originalMethod: unknown, _context: ClassMethodDecoratorContext): (this: unknown, ...args: unknown[]) => any;
|
|
387
383
|
|
|
388
384
|
declare const tab = "\t";
|
|
@@ -416,4 +412,4 @@ declare const gen_sch_gnd: (value: string, pwr_number: number, port_id: string,
|
|
|
416
412
|
|
|
417
413
|
declare const gen_sch_vcc: (value: string, pwr_number: number, port_id: string, position: VECTOR2) => SCH_SYMBOL;
|
|
418
414
|
|
|
419
|
-
export { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, FONT_SIZE, GRID_SIZE, GraphConverter, KICAD_SCH_FRAME, KiCadProjectArchive, type LabelPadding, Layout, NetListConverter, type NetlistProject, type NetlistToKicadContext, SCHEMATIC_PRINTER, StringFormatter, WIRE_PADDING,
|
|
415
|
+
export { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, FONT_SIZE, GRID_SIZE, GraphConverter, KICAD_SCH_FRAME, KiCadProjectArchive, type LabelPadding, Layout, NetListConverter, type NetlistProject, type NetlistToKicadContext, SCHEMATIC_PRINTER, StringFormatter, WIRE_PADDING, collect_sub_sheets_by_id, convert_graph_to_design_block, convert_graph_to_kicad_project, convert_graph_to_sheets, filterNullOrUndefined, 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
|
@@ -133,7 +133,9 @@ declare class NetListConverter {
|
|
|
133
133
|
private convert_net_label;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
declare function convert_graph_to_sheets(ctx: ConvertGraphToKiCadInput): Promise<
|
|
136
|
+
declare function convert_graph_to_sheets(ctx: ConvertGraphToKiCadInput): Promise<{
|
|
137
|
+
[x: string]: string;
|
|
138
|
+
}>;
|
|
137
139
|
|
|
138
140
|
declare function convert_graph_to_kicad_project(ctx: ConvertGraphToKiCadInput): Promise<Blob>;
|
|
139
141
|
|
|
@@ -377,12 +379,6 @@ declare class KiCadProjectArchive {
|
|
|
377
379
|
toZip(): Promise<Blob>;
|
|
378
380
|
}
|
|
379
381
|
|
|
380
|
-
declare function collect_sub_sheets(dependencies: Record<string, string>, module_resolver: ModuleResolver): Promise<{
|
|
381
|
-
sheets: Record<string, string>;
|
|
382
|
-
module_main_sheet: Record<string, string>;
|
|
383
|
-
modules: Record<string, ModuleCircuit>;
|
|
384
|
-
}>;
|
|
385
|
-
|
|
386
382
|
declare function filterNullOrUndefined(originalMethod: unknown, _context: ClassMethodDecoratorContext): (this: unknown, ...args: unknown[]) => any;
|
|
387
383
|
|
|
388
384
|
declare const tab = "\t";
|
|
@@ -416,4 +412,4 @@ declare const gen_sch_gnd: (value: string, pwr_number: number, port_id: string,
|
|
|
416
412
|
|
|
417
413
|
declare const gen_sch_vcc: (value: string, pwr_number: number, port_id: string, position: VECTOR2) => SCH_SYMBOL;
|
|
418
414
|
|
|
419
|
-
export { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, FONT_SIZE, GRID_SIZE, GraphConverter, KICAD_SCH_FRAME, KiCadProjectArchive, type LabelPadding, Layout, NetListConverter, type NetlistProject, type NetlistToKicadContext, SCHEMATIC_PRINTER, StringFormatter, WIRE_PADDING,
|
|
415
|
+
export { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, FONT_SIZE, GRID_SIZE, GraphConverter, KICAD_SCH_FRAME, KiCadProjectArchive, type LabelPadding, Layout, NetListConverter, type NetlistProject, type NetlistToKicadContext, SCHEMATIC_PRINTER, StringFormatter, WIRE_PADDING, collect_sub_sheets_by_id, convert_graph_to_design_block, convert_graph_to_kicad_project, convert_graph_to_sheets, filterNullOrUndefined, 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
|
@@ -86,7 +86,6 @@ __export(index_exports, {
|
|
|
86
86
|
SCHEMATIC_PRINTER: () => SCHEMATIC_PRINTER,
|
|
87
87
|
StringFormatter: () => StringFormatter,
|
|
88
88
|
WIRE_PADDING: () => WIRE_PADDING,
|
|
89
|
-
collect_sub_sheets: () => collect_sub_sheets,
|
|
90
89
|
collect_sub_sheets_by_id: () => collect_sub_sheets_by_id,
|
|
91
90
|
convert_graph_to_design_block: () => convert_graph_to_design_block,
|
|
92
91
|
convert_graph_to_kicad_project: () => convert_graph_to_kicad_project,
|
|
@@ -117,52 +116,7 @@ function get_sch_default_drawing_sheet() {
|
|
|
117
116
|
// src/converter/kicad_sexpr/eeschema/printer.ts
|
|
118
117
|
var import_electronics_model = require("@modular-circuit/electronics-model");
|
|
119
118
|
var import_ir = require("@modular-circuit/ir");
|
|
120
|
-
var
|
|
121
|
-
|
|
122
|
-
// src/utils/collect_sub_sheets.ts
|
|
123
|
-
var import_utils = require("@modular-circuit/utils");
|
|
124
|
-
async function collect_sub_sheets(dependencies, module_resolver) {
|
|
125
|
-
const sheets = {};
|
|
126
|
-
const module_main_sheet = {};
|
|
127
|
-
const modules = {};
|
|
128
|
-
for (const [k, v] of Object.entries(dependencies)) {
|
|
129
|
-
try {
|
|
130
|
-
const zip_archive_url = await module_resolver.get_module_archive({
|
|
131
|
-
...(0, import_utils.parse_module_name)(k),
|
|
132
|
-
version: v
|
|
133
|
-
});
|
|
134
|
-
const module2 = await module_resolver.get_module_circuit({
|
|
135
|
-
...(0, import_utils.parse_module_name)(k),
|
|
136
|
-
version: v
|
|
137
|
-
});
|
|
138
|
-
if (!zip_archive_url || !module2) {
|
|
139
|
-
console.error(`Module ${k}/${v} not found`);
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
if (!module2.main) {
|
|
143
|
-
console.error(`Missing main entry in module ${k}/${v}`);
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
module_main_sheet[k] = module2.main;
|
|
147
|
-
modules[k] = module2;
|
|
148
|
-
const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
|
|
149
|
-
const files = await (0, import_utils.unzipFile)(zip_archive);
|
|
150
|
-
for (const [name, content] of Object.entries(files)) {
|
|
151
|
-
if (name.endsWith(import_utils.KiCadSchematicFileExtension)) {
|
|
152
|
-
const fileName = (0, import_utils.remove_filename_path_prefix)(name);
|
|
153
|
-
if (fileName in sheets) {
|
|
154
|
-
console.error(`Duplicate sheet name: ${fileName}`);
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
sheets[fileName] = content;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
} catch (e) {
|
|
161
|
-
console.error(`Failed to download zip for module : ${e}`);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return { sheets, module_main_sheet, modules };
|
|
165
|
-
}
|
|
119
|
+
var import_utils3 = require("@modular-circuit/utils");
|
|
166
120
|
|
|
167
121
|
// src/utils/filter_null_undefined.ts
|
|
168
122
|
function filterNullOrUndefined(originalMethod, _context) {
|
|
@@ -205,7 +159,7 @@ var StringFormatter = class {
|
|
|
205
159
|
};
|
|
206
160
|
|
|
207
161
|
// src/utils/collect_sub_sheets_by_id.ts
|
|
208
|
-
var
|
|
162
|
+
var import_utils = require("@modular-circuit/utils");
|
|
209
163
|
async function collect_sub_sheets_by_id(module_ids, module_resolver) {
|
|
210
164
|
const sheets = {};
|
|
211
165
|
const module_main_sheet = {};
|
|
@@ -227,7 +181,7 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
|
|
|
227
181
|
console.error(`Missing main entry in module${module_circuit.author}/${module_circuit.name}`);
|
|
228
182
|
continue;
|
|
229
183
|
}
|
|
230
|
-
const k = (0,
|
|
184
|
+
const k = (0, import_utils.fmt_module_name)(module_circuit);
|
|
231
185
|
module_main_sheet[k] = module_circuit.main;
|
|
232
186
|
modules[k] = module_circuit;
|
|
233
187
|
const design_block = {
|
|
@@ -238,18 +192,18 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
|
|
|
238
192
|
};
|
|
239
193
|
console.log(`Fetching ZIP archive for module ${id} from ${zip_archive_url.toString()}`);
|
|
240
194
|
const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
|
|
241
|
-
const files = await (0,
|
|
195
|
+
const files = await (0, import_utils.unzipFile)(zip_archive);
|
|
242
196
|
for (const [name, content] of Object.entries(files)) {
|
|
243
|
-
if (name.endsWith(
|
|
244
|
-
const filename = (0,
|
|
197
|
+
if (name.endsWith(import_utils.KiCadSchematicFileExtension)) {
|
|
198
|
+
const filename = (0, import_utils.remove_filename_path_prefix)(name);
|
|
245
199
|
if (filename in sheets) {
|
|
246
200
|
console.error(`Duplicate sheet name: ${filename}`);
|
|
247
201
|
continue;
|
|
248
202
|
}
|
|
249
203
|
sheets[filename] = content;
|
|
250
204
|
design_block.schematics.push({ filename, content });
|
|
251
|
-
} else if (name.endsWith(
|
|
252
|
-
const filename = (0,
|
|
205
|
+
} else if (name.endsWith(import_utils.KiCadPcbFileExtension)) {
|
|
206
|
+
const filename = (0, import_utils.remove_filename_path_prefix)(name);
|
|
253
207
|
design_block.pcb = { pcb: { filename, content } };
|
|
254
208
|
}
|
|
255
209
|
}
|
|
@@ -262,13 +216,13 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
|
|
|
262
216
|
}
|
|
263
217
|
|
|
264
218
|
// src/utils/gen_empty_sch.ts
|
|
265
|
-
var
|
|
219
|
+
var import_utils2 = require("@modular-circuit/utils");
|
|
266
220
|
var gen_empty_sch = async (name) => {
|
|
267
221
|
const printer = new SCHEMATIC_PRINTER();
|
|
268
222
|
const schematics = {};
|
|
269
223
|
const filename = `${name}`;
|
|
270
224
|
schematics[filename] = {
|
|
271
|
-
uuid: (0,
|
|
225
|
+
uuid: (0, import_utils2.gen_uuid)(),
|
|
272
226
|
filename,
|
|
273
227
|
sheet_symbols: [],
|
|
274
228
|
powers: [],
|
|
@@ -321,11 +275,11 @@ var SCHEMATIC_PRINTER = class {
|
|
|
321
275
|
})();
|
|
322
276
|
return `
|
|
323
277
|
(kicad_sch
|
|
324
|
-
(version ${
|
|
325
|
-
(generator "${
|
|
326
|
-
(generator_version "${
|
|
327
|
-
(uuid "${(0,
|
|
328
|
-
(paper "${
|
|
278
|
+
(version ${import_utils3.SCH_VERSION})
|
|
279
|
+
(generator "${import_utils3.GENERATOR_NAME}")
|
|
280
|
+
(generator_version "${import_utils3.GENERATOR_VERSION}")
|
|
281
|
+
(uuid "${(0, import_utils3.gen_uuid)()}")
|
|
282
|
+
(paper "${import_utils3.PAPER}")
|
|
329
283
|
${lib_symbols}
|
|
330
284
|
${wires}
|
|
331
285
|
${labels}
|
|
@@ -1803,13 +1757,13 @@ var GraphConverter = class {
|
|
|
1803
1757
|
};
|
|
1804
1758
|
|
|
1805
1759
|
// src/converter/netlist_to_kicad/layout.ts
|
|
1806
|
-
var
|
|
1760
|
+
var import_utils5 = require("@modular-circuit/utils");
|
|
1807
1761
|
var import_elk_bundled = __toESM(require("elkjs/lib/elk.bundled.js"));
|
|
1808
1762
|
var MIL_TO_MM = 0.0254;
|
|
1809
1763
|
var GRID_SIZE = 50 * MIL_TO_MM;
|
|
1810
1764
|
var FONT_SIZE = GRID_SIZE;
|
|
1811
1765
|
var POWER_START_Y = 30 * GRID_SIZE;
|
|
1812
|
-
var POWER_START_X = (
|
|
1766
|
+
var POWER_START_X = (import_utils5.PAPER_SIZE.A4.height - 30) * GRID_SIZE;
|
|
1813
1767
|
var POWER_Y_STEP = 16 * GRID_SIZE;
|
|
1814
1768
|
var BLOCK_V_SPACE = 8 * GRID_SIZE;
|
|
1815
1769
|
var BLOCK_H_SPACE = 14 * GRID_SIZE - BLOCK_V_SPACE;
|
|
@@ -1847,8 +1801,8 @@ var Layout = class {
|
|
|
1847
1801
|
"org.eclipse.elk.aspectRatio": "1.414",
|
|
1848
1802
|
"elk.spacing.nodeNode": `${BLOCK_V_SPACE}`,
|
|
1849
1803
|
"elk.padding": `[top=${PADDING_TOP},left=${PADDING},bottom=${PADDING},right=${PADDING}]`,
|
|
1850
|
-
"elk.childAreaWidth": `${
|
|
1851
|
-
"elk.childAreaHeight": `${
|
|
1804
|
+
"elk.childAreaWidth": `${import_utils5.PAPER_SIZE.A4.height}`,
|
|
1805
|
+
"elk.childAreaHeight": `${import_utils5.PAPER_SIZE.A4.width}`
|
|
1852
1806
|
},
|
|
1853
1807
|
children: [],
|
|
1854
1808
|
edges: []
|
|
@@ -1907,10 +1861,10 @@ var Layout = class {
|
|
|
1907
1861
|
// src/converter/netlist_to_kicad/netlist_converter.ts
|
|
1908
1862
|
var import_electronics_model8 = require("@modular-circuit/electronics-model");
|
|
1909
1863
|
var import_ir4 = require("@modular-circuit/ir");
|
|
1910
|
-
var
|
|
1864
|
+
var import_utils14 = require("@modular-circuit/utils");
|
|
1911
1865
|
|
|
1912
1866
|
// src/kicad/label/net_label.ts
|
|
1913
|
-
var
|
|
1867
|
+
var import_utils6 = require("@modular-circuit/utils");
|
|
1914
1868
|
var gen_net_label = (name, at, justify) => ({
|
|
1915
1869
|
label_type: "label",
|
|
1916
1870
|
text: name,
|
|
@@ -1918,23 +1872,23 @@ var gen_net_label = (name, at, justify) => ({
|
|
|
1918
1872
|
fields_autoplaced: true,
|
|
1919
1873
|
at: { position: at, rotation: 0 },
|
|
1920
1874
|
effects: {
|
|
1921
|
-
font: { size:
|
|
1875
|
+
font: { size: import_utils6.DEFAULT_FONT_SIZE },
|
|
1922
1876
|
justify
|
|
1923
1877
|
},
|
|
1924
|
-
uuid: (0,
|
|
1878
|
+
uuid: (0, import_utils6.gen_uuid)()
|
|
1925
1879
|
});
|
|
1926
1880
|
|
|
1927
1881
|
// src/kicad/label/sheet_pin.ts
|
|
1928
|
-
var
|
|
1882
|
+
var import_utils7 = require("@modular-circuit/utils");
|
|
1929
1883
|
var gen_base_hierarchical_label = (text, at, justify, rotation, shape) => ({
|
|
1930
1884
|
shape,
|
|
1931
1885
|
effects: {
|
|
1932
|
-
font: { size:
|
|
1886
|
+
font: { size: import_utils7.DEFAULT_FONT_SIZE },
|
|
1933
1887
|
justify
|
|
1934
1888
|
},
|
|
1935
1889
|
text,
|
|
1936
1890
|
at: { position: at, rotation },
|
|
1937
|
-
uuid: (0,
|
|
1891
|
+
uuid: (0, import_utils7.gen_uuid)()
|
|
1938
1892
|
});
|
|
1939
1893
|
var gen_sheet_pin = (text, at, justify, rotation, shape) => ({
|
|
1940
1894
|
label_type: "hierarchical_label",
|
|
@@ -1943,7 +1897,7 @@ var gen_sheet_pin = (text, at, justify, rotation, shape) => ({
|
|
|
1943
1897
|
var gen_hierarchical_label = gen_sheet_pin;
|
|
1944
1898
|
|
|
1945
1899
|
// src/kicad/sheet/sheet.ts
|
|
1946
|
-
var
|
|
1900
|
+
var import_utils8 = require("@modular-circuit/utils");
|
|
1947
1901
|
var TEXT_MARGIN = 0.7116;
|
|
1948
1902
|
var gen_sch_sheet = (rect, pins, fields) => ({
|
|
1949
1903
|
// NOTE no rotation in the sheet
|
|
@@ -1956,7 +1910,7 @@ var gen_sch_sheet = (rect, pins, fields) => ({
|
|
|
1956
1910
|
text: fields.Sheetname,
|
|
1957
1911
|
at: { position: { x: rect.pos.x, y: rect.pos.y - TEXT_MARGIN }, rotation: 0 },
|
|
1958
1912
|
effects: {
|
|
1959
|
-
font: { size:
|
|
1913
|
+
font: { size: import_utils8.DEFAULT_FONT_SIZE },
|
|
1960
1914
|
justify: {
|
|
1961
1915
|
vertical: "bottom",
|
|
1962
1916
|
horizontal: "left"
|
|
@@ -1968,7 +1922,7 @@ var gen_sch_sheet = (rect, pins, fields) => ({
|
|
|
1968
1922
|
text: fields.Sheetfile,
|
|
1969
1923
|
at: { position: { x: rect.pos.x, y: rect.pos.y + rect.size.y + TEXT_MARGIN }, rotation: 0 },
|
|
1970
1924
|
effects: {
|
|
1971
|
-
font: { size:
|
|
1925
|
+
font: { size: import_utils8.DEFAULT_FONT_SIZE },
|
|
1972
1926
|
justify: {
|
|
1973
1927
|
vertical: "top",
|
|
1974
1928
|
horizontal: "left"
|
|
@@ -1984,13 +1938,13 @@ var gen_sch_sheet = (rect, pins, fields) => ({
|
|
|
1984
1938
|
fill: {
|
|
1985
1939
|
color: { r: 0, g: 0, b: 0, a: 0 }
|
|
1986
1940
|
},
|
|
1987
|
-
uuid: (0,
|
|
1941
|
+
uuid: (0, import_utils8.gen_uuid)()
|
|
1988
1942
|
});
|
|
1989
1943
|
|
|
1990
1944
|
// src/kicad/symbols/lib_symbol/gnd.ts
|
|
1991
1945
|
var import_electronics_model5 = require("@modular-circuit/electronics-model");
|
|
1992
1946
|
var import_ir2 = require("@modular-circuit/ir");
|
|
1993
|
-
var
|
|
1947
|
+
var import_utils9 = require("@modular-circuit/utils");
|
|
1994
1948
|
var gen_lib_gnd = (value) => ({
|
|
1995
1949
|
name: `power:${value}`,
|
|
1996
1950
|
pin_numbers: {
|
|
@@ -2010,7 +1964,7 @@ var gen_lib_gnd = (value) => ({
|
|
|
2010
1964
|
text: "#PWR",
|
|
2011
1965
|
at: { position: { x: 0, y: -6.35 }, rotation: 0 },
|
|
2012
1966
|
effects: {
|
|
2013
|
-
font: { size:
|
|
1967
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE },
|
|
2014
1968
|
hide: true
|
|
2015
1969
|
}
|
|
2016
1970
|
},
|
|
@@ -2019,7 +1973,7 @@ var gen_lib_gnd = (value) => ({
|
|
|
2019
1973
|
text: `${value}`,
|
|
2020
1974
|
at: { position: { x: 0, y: -3.81 }, rotation: 0 },
|
|
2021
1975
|
effects: {
|
|
2022
|
-
font: { size:
|
|
1976
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE }
|
|
2023
1977
|
}
|
|
2024
1978
|
},
|
|
2025
1979
|
{
|
|
@@ -2027,7 +1981,7 @@ var gen_lib_gnd = (value) => ({
|
|
|
2027
1981
|
text: "",
|
|
2028
1982
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
2029
1983
|
effects: {
|
|
2030
|
-
font: { size:
|
|
1984
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE },
|
|
2031
1985
|
hide: true
|
|
2032
1986
|
}
|
|
2033
1987
|
},
|
|
@@ -2036,7 +1990,7 @@ var gen_lib_gnd = (value) => ({
|
|
|
2036
1990
|
text: "",
|
|
2037
1991
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
2038
1992
|
effects: {
|
|
2039
|
-
font: { size:
|
|
1993
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE },
|
|
2040
1994
|
hide: true
|
|
2041
1995
|
}
|
|
2042
1996
|
},
|
|
@@ -2045,7 +1999,7 @@ var gen_lib_gnd = (value) => ({
|
|
|
2045
1999
|
text: 'Power symbol creates a global label with name \\"GND\\" , ground',
|
|
2046
2000
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
2047
2001
|
effects: {
|
|
2048
|
-
font: { size:
|
|
2002
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE },
|
|
2049
2003
|
hide: true
|
|
2050
2004
|
}
|
|
2051
2005
|
},
|
|
@@ -2054,7 +2008,7 @@ var gen_lib_gnd = (value) => ({
|
|
|
2054
2008
|
text: "global power",
|
|
2055
2009
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
2056
2010
|
effects: {
|
|
2057
|
-
font: { size:
|
|
2011
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE },
|
|
2058
2012
|
hide: true
|
|
2059
2013
|
}
|
|
2060
2014
|
}
|
|
@@ -2095,13 +2049,13 @@ var gen_lib_gnd = (value) => ({
|
|
|
2095
2049
|
name: {
|
|
2096
2050
|
text: "~",
|
|
2097
2051
|
effects: {
|
|
2098
|
-
font: { size:
|
|
2052
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE }
|
|
2099
2053
|
}
|
|
2100
2054
|
},
|
|
2101
2055
|
number: {
|
|
2102
2056
|
text: "1",
|
|
2103
2057
|
effects: {
|
|
2104
|
-
font: { size:
|
|
2058
|
+
font: { size: import_utils9.DEFAULT_FONT_SIZE }
|
|
2105
2059
|
}
|
|
2106
2060
|
}
|
|
2107
2061
|
}
|
|
@@ -2113,7 +2067,7 @@ var gen_lib_gnd = (value) => ({
|
|
|
2113
2067
|
// src/kicad/symbols/lib_symbol/vcc.ts
|
|
2114
2068
|
var import_electronics_model6 = require("@modular-circuit/electronics-model");
|
|
2115
2069
|
var import_ir3 = require("@modular-circuit/ir");
|
|
2116
|
-
var
|
|
2070
|
+
var import_utils10 = require("@modular-circuit/utils");
|
|
2117
2071
|
var gen_lib_vcc = (value) => ({
|
|
2118
2072
|
name: `power:${value}`,
|
|
2119
2073
|
power: true,
|
|
@@ -2134,7 +2088,7 @@ var gen_lib_vcc = (value) => ({
|
|
|
2134
2088
|
text: "#PWR",
|
|
2135
2089
|
at: { position: { x: 0, y: -3.81 }, rotation: 0 },
|
|
2136
2090
|
effects: {
|
|
2137
|
-
font: { size:
|
|
2091
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE },
|
|
2138
2092
|
hide: true
|
|
2139
2093
|
}
|
|
2140
2094
|
},
|
|
@@ -2143,7 +2097,7 @@ var gen_lib_vcc = (value) => ({
|
|
|
2143
2097
|
text: `${value}`,
|
|
2144
2098
|
at: { position: { x: 0, y: 3.556 }, rotation: 0 },
|
|
2145
2099
|
effects: {
|
|
2146
|
-
font: { size:
|
|
2100
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE }
|
|
2147
2101
|
}
|
|
2148
2102
|
},
|
|
2149
2103
|
{
|
|
@@ -2151,7 +2105,7 @@ var gen_lib_vcc = (value) => ({
|
|
|
2151
2105
|
text: "",
|
|
2152
2106
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
2153
2107
|
effects: {
|
|
2154
|
-
font: { size:
|
|
2108
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE },
|
|
2155
2109
|
hide: true
|
|
2156
2110
|
}
|
|
2157
2111
|
},
|
|
@@ -2160,7 +2114,7 @@ var gen_lib_vcc = (value) => ({
|
|
|
2160
2114
|
text: "",
|
|
2161
2115
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
2162
2116
|
effects: {
|
|
2163
|
-
font: { size:
|
|
2117
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE },
|
|
2164
2118
|
hide: true
|
|
2165
2119
|
}
|
|
2166
2120
|
},
|
|
@@ -2169,7 +2123,7 @@ var gen_lib_vcc = (value) => ({
|
|
|
2169
2123
|
text: `Power symbol creates a global label with name \\"${value}\\"`,
|
|
2170
2124
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
2171
2125
|
effects: {
|
|
2172
|
-
font: { size:
|
|
2126
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE },
|
|
2173
2127
|
hide: true
|
|
2174
2128
|
}
|
|
2175
2129
|
},
|
|
@@ -2178,7 +2132,7 @@ var gen_lib_vcc = (value) => ({
|
|
|
2178
2132
|
text: "global power",
|
|
2179
2133
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
2180
2134
|
effects: {
|
|
2181
|
-
font: { size:
|
|
2135
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE },
|
|
2182
2136
|
hide: true
|
|
2183
2137
|
}
|
|
2184
2138
|
}
|
|
@@ -2216,13 +2170,13 @@ var gen_lib_vcc = (value) => ({
|
|
|
2216
2170
|
name: {
|
|
2217
2171
|
text: "~",
|
|
2218
2172
|
effects: {
|
|
2219
|
-
font: { size:
|
|
2173
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE }
|
|
2220
2174
|
}
|
|
2221
2175
|
},
|
|
2222
2176
|
number: {
|
|
2223
2177
|
text: "1",
|
|
2224
2178
|
effects: {
|
|
2225
|
-
font: { size:
|
|
2179
|
+
font: { size: import_utils10.DEFAULT_FONT_SIZE }
|
|
2226
2180
|
}
|
|
2227
2181
|
}
|
|
2228
2182
|
}
|
|
@@ -2232,7 +2186,7 @@ var gen_lib_vcc = (value) => ({
|
|
|
2232
2186
|
});
|
|
2233
2187
|
|
|
2234
2188
|
// src/kicad/symbols/sch_symbol/gnd.ts
|
|
2235
|
-
var
|
|
2189
|
+
var import_utils11 = require("@modular-circuit/utils");
|
|
2236
2190
|
|
|
2237
2191
|
// src/kicad/symbols/symbol_utils.ts
|
|
2238
2192
|
var gen_pwr_ref = (pwr_num) => `#PWR${pwr_num}`;
|
|
@@ -2247,14 +2201,14 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
|
|
|
2247
2201
|
on_board: true,
|
|
2248
2202
|
dnp: false,
|
|
2249
2203
|
fields_autoplaced: true,
|
|
2250
|
-
uuid: (0,
|
|
2204
|
+
uuid: (0, import_utils11.gen_uuid)(),
|
|
2251
2205
|
properties: [
|
|
2252
2206
|
{
|
|
2253
2207
|
name: "Reference",
|
|
2254
2208
|
text: gen_pwr_ref(pwr_number),
|
|
2255
2209
|
at: { position: { x: position.x, y: position.y + 6.35 }, rotation: 0 },
|
|
2256
2210
|
effects: {
|
|
2257
|
-
font: { size:
|
|
2211
|
+
font: { size: import_utils11.DEFAULT_FONT_SIZE },
|
|
2258
2212
|
hide: true
|
|
2259
2213
|
}
|
|
2260
2214
|
},
|
|
@@ -2263,7 +2217,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
|
|
|
2263
2217
|
text: `${value}`,
|
|
2264
2218
|
at: { position: { x: position.x, y: position.y + 5.08 }, rotation: 0 },
|
|
2265
2219
|
effects: {
|
|
2266
|
-
font: { size:
|
|
2220
|
+
font: { size: import_utils11.DEFAULT_FONT_SIZE }
|
|
2267
2221
|
}
|
|
2268
2222
|
},
|
|
2269
2223
|
{
|
|
@@ -2271,7 +2225,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
|
|
|
2271
2225
|
text: "",
|
|
2272
2226
|
at: { position, rotation: 0 },
|
|
2273
2227
|
effects: {
|
|
2274
|
-
font: { size:
|
|
2228
|
+
font: { size: import_utils11.DEFAULT_FONT_SIZE },
|
|
2275
2229
|
hide: true
|
|
2276
2230
|
}
|
|
2277
2231
|
},
|
|
@@ -2280,7 +2234,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
|
|
|
2280
2234
|
text: "",
|
|
2281
2235
|
at: { position, rotation: 0 },
|
|
2282
2236
|
effects: {
|
|
2283
|
-
font: { size:
|
|
2237
|
+
font: { size: import_utils11.DEFAULT_FONT_SIZE },
|
|
2284
2238
|
hide: true
|
|
2285
2239
|
}
|
|
2286
2240
|
},
|
|
@@ -2289,7 +2243,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
|
|
|
2289
2243
|
text: `Power symbol creates a global label with name \\"${value}\\" , ground`,
|
|
2290
2244
|
at: { position, rotation: 0 },
|
|
2291
2245
|
effects: {
|
|
2292
|
-
font: { size:
|
|
2246
|
+
font: { size: import_utils11.DEFAULT_FONT_SIZE },
|
|
2293
2247
|
hide: true
|
|
2294
2248
|
}
|
|
2295
2249
|
}
|
|
@@ -2303,7 +2257,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
|
|
|
2303
2257
|
});
|
|
2304
2258
|
|
|
2305
2259
|
// src/kicad/symbols/sch_symbol/vcc.ts
|
|
2306
|
-
var
|
|
2260
|
+
var import_utils12 = require("@modular-circuit/utils");
|
|
2307
2261
|
var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
2308
2262
|
lib_id: `power:${value}`,
|
|
2309
2263
|
at: { position, rotation: 0 },
|
|
@@ -2313,14 +2267,14 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
|
2313
2267
|
on_board: true,
|
|
2314
2268
|
dnp: false,
|
|
2315
2269
|
fields_autoplaced: true,
|
|
2316
|
-
uuid: (0,
|
|
2270
|
+
uuid: (0, import_utils12.gen_uuid)(),
|
|
2317
2271
|
properties: [
|
|
2318
2272
|
{
|
|
2319
2273
|
name: "Reference",
|
|
2320
2274
|
text: gen_pwr_ref(pwr_number),
|
|
2321
2275
|
at: { position: { x: position.x, y: position.y + 3.81 }, rotation: 0 },
|
|
2322
2276
|
effects: {
|
|
2323
|
-
font: { size:
|
|
2277
|
+
font: { size: import_utils12.DEFAULT_FONT_SIZE },
|
|
2324
2278
|
hide: true
|
|
2325
2279
|
}
|
|
2326
2280
|
},
|
|
@@ -2329,7 +2283,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
|
2329
2283
|
text: `${value}`,
|
|
2330
2284
|
at: { position: { x: position.x, y: position.y - 5.08 }, rotation: 0 },
|
|
2331
2285
|
effects: {
|
|
2332
|
-
font: { size:
|
|
2286
|
+
font: { size: import_utils12.DEFAULT_FONT_SIZE }
|
|
2333
2287
|
}
|
|
2334
2288
|
},
|
|
2335
2289
|
{
|
|
@@ -2337,7 +2291,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
|
2337
2291
|
text: "",
|
|
2338
2292
|
at: { position, rotation: 0 },
|
|
2339
2293
|
effects: {
|
|
2340
|
-
font: { size:
|
|
2294
|
+
font: { size: import_utils12.DEFAULT_FONT_SIZE },
|
|
2341
2295
|
hide: true
|
|
2342
2296
|
}
|
|
2343
2297
|
},
|
|
@@ -2346,7 +2300,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
|
2346
2300
|
text: "",
|
|
2347
2301
|
at: { position, rotation: 0 },
|
|
2348
2302
|
effects: {
|
|
2349
|
-
font: { size:
|
|
2303
|
+
font: { size: import_utils12.DEFAULT_FONT_SIZE },
|
|
2350
2304
|
hide: true
|
|
2351
2305
|
}
|
|
2352
2306
|
},
|
|
@@ -2355,7 +2309,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
|
2355
2309
|
text: `Power symbol creates a global label with name \\"${value}\\"`,
|
|
2356
2310
|
at: { position, rotation: 0 },
|
|
2357
2311
|
effects: {
|
|
2358
|
-
font: { size:
|
|
2312
|
+
font: { size: import_utils12.DEFAULT_FONT_SIZE },
|
|
2359
2313
|
hide: true
|
|
2360
2314
|
}
|
|
2361
2315
|
}
|
|
@@ -2370,7 +2324,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
|
2370
2324
|
|
|
2371
2325
|
// src/kicad/wire/gen_wire.ts
|
|
2372
2326
|
var import_electronics_model7 = require("@modular-circuit/electronics-model");
|
|
2373
|
-
var
|
|
2327
|
+
var import_utils13 = require("@modular-circuit/utils");
|
|
2374
2328
|
var gen_wire = (start, end) => ({
|
|
2375
2329
|
stroke: {
|
|
2376
2330
|
type: "default",
|
|
@@ -2378,7 +2332,7 @@ var gen_wire = (start, end) => ({
|
|
|
2378
2332
|
},
|
|
2379
2333
|
start,
|
|
2380
2334
|
end,
|
|
2381
|
-
uuid: (0,
|
|
2335
|
+
uuid: (0, import_utils13.gen_uuid)(),
|
|
2382
2336
|
type: import_electronics_model7.GS_SCH_ITEM_TYPE.LINE
|
|
2383
2337
|
});
|
|
2384
2338
|
|
|
@@ -2426,15 +2380,15 @@ var NetListConverter = class {
|
|
|
2426
2380
|
const powers = /* @__PURE__ */ new Set();
|
|
2427
2381
|
this.wires = [];
|
|
2428
2382
|
const sch = {
|
|
2429
|
-
version:
|
|
2430
|
-
generator:
|
|
2431
|
-
generator_version:
|
|
2383
|
+
version: import_utils14.SCH_VERSION,
|
|
2384
|
+
generator: import_utils14.GENERATOR_NAME,
|
|
2385
|
+
generator_version: import_utils14.GENERATOR_VERSION,
|
|
2432
2386
|
paper: {
|
|
2433
2387
|
size: "A4"
|
|
2434
2388
|
},
|
|
2435
2389
|
title_block: {
|
|
2436
2390
|
title: name.replace(`.${import_ir4.MODULAR_CIRCUIT_SCH_EXT}`, ""),
|
|
2437
|
-
date: (0,
|
|
2391
|
+
date: (0, import_utils14.replaceAll)((/* @__PURE__ */ new Date()).toISOString().slice(0, 10), "-", "/"),
|
|
2438
2392
|
rev: "1.0",
|
|
2439
2393
|
comment: {
|
|
2440
2394
|
1: "https://www.eda.cn",
|
|
@@ -2597,7 +2551,7 @@ var NetListConverter = class {
|
|
|
2597
2551
|
// src/builder/graph_to_kicad/convert_graph_to_sheets.ts
|
|
2598
2552
|
var import_ir5 = require("@modular-circuit/ir");
|
|
2599
2553
|
var import_perc = require("@modular-circuit/perc");
|
|
2600
|
-
var
|
|
2554
|
+
var import_utils15 = require("@modular-circuit/utils");
|
|
2601
2555
|
async function do_convert_graph_to_kicad_project(ctx) {
|
|
2602
2556
|
const module_ids = [];
|
|
2603
2557
|
const generated_sheets = {};
|
|
@@ -2607,17 +2561,17 @@ async function do_convert_graph_to_kicad_project(ctx) {
|
|
|
2607
2561
|
if ((0, import_ir5.block_is_associated_with_concrete_module)(mod.type)) module_ids.push(mod.type);
|
|
2608
2562
|
} else {
|
|
2609
2563
|
if (ctx.netlist_transpiler && (0, import_ir5.block_is_resolved_abstract)(mod)) {
|
|
2610
|
-
const sheet_file_name = (0,
|
|
2564
|
+
const sheet_file_name = (0, import_utils15.fmt_abstract_sch_name)(mod);
|
|
2611
2565
|
const netlist2 = mod.netlist;
|
|
2612
2566
|
generated_sheets[sheet_file_name] = await ctx.netlist_transpiler.convert_netlist_to_kicad(netlist2);
|
|
2613
2567
|
}
|
|
2614
2568
|
}
|
|
2615
2569
|
}
|
|
2616
2570
|
}
|
|
2617
|
-
const
|
|
2618
|
-
|
|
2619
|
-
...
|
|
2620
|
-
...
|
|
2571
|
+
const collected = await collect_sub_sheets_by_id(module_ids, ctx.module_resolver);
|
|
2572
|
+
const sheets = {
|
|
2573
|
+
...collected.sheets,
|
|
2574
|
+
...generated_sheets
|
|
2621
2575
|
};
|
|
2622
2576
|
const netlist = new GraphConverter({
|
|
2623
2577
|
...ctx
|
|
@@ -2626,7 +2580,7 @@ async function do_convert_graph_to_kicad_project(ctx) {
|
|
|
2626
2580
|
for (const sheet of sch.sheet_symbols) {
|
|
2627
2581
|
const original_st_fn = sheet.sheet_file_name;
|
|
2628
2582
|
if (!(original_st_fn in sheets)) {
|
|
2629
|
-
const placeholder_fn = (0,
|
|
2583
|
+
const placeholder_fn = (0, import_utils15.fmt_module_place_holder_sch_name)(sheet.sheet_name);
|
|
2630
2584
|
sheet.sheet_file_name = placeholder_fn;
|
|
2631
2585
|
sheets[placeholder_fn] = await gen_empty_sch(placeholder_fn);
|
|
2632
2586
|
}
|
|
@@ -2641,7 +2595,7 @@ async function do_convert_graph_to_kicad_project(ctx) {
|
|
|
2641
2595
|
if (k in sheets) {
|
|
2642
2596
|
console.error(`Duplicated sheet file name found ${k}`);
|
|
2643
2597
|
}
|
|
2644
|
-
sheets[k.replace(import_ir5.MODULAR_CIRCUIT_SCH_EXT,
|
|
2598
|
+
sheets[k.replace(import_ir5.MODULAR_CIRCUIT_SCH_EXT, import_utils15.KiCadSchematicFileExtension)] = sexpr_printer.schematic(v);
|
|
2645
2599
|
}
|
|
2646
2600
|
return sheets;
|
|
2647
2601
|
}
|
|
@@ -2656,7 +2610,7 @@ async function convert_graph_to_sheets(ctx) {
|
|
|
2656
2610
|
}
|
|
2657
2611
|
|
|
2658
2612
|
// src/kicad/project/kicad_project_archive.ts
|
|
2659
|
-
var
|
|
2613
|
+
var import_utils18 = require("@modular-circuit/utils");
|
|
2660
2614
|
var import_jszip = __toESM(require("jszip"));
|
|
2661
2615
|
|
|
2662
2616
|
// src/kicad/project/kicad_prl.ts
|
|
@@ -2745,7 +2699,7 @@ var kicad_prl = (prj_name) => ({
|
|
|
2745
2699
|
});
|
|
2746
2700
|
|
|
2747
2701
|
// src/kicad/project/kicad_pro.ts
|
|
2748
|
-
var
|
|
2702
|
+
var import_utils17 = require("@modular-circuit/utils");
|
|
2749
2703
|
var kicad_pro = (project_name) => ({
|
|
2750
2704
|
board: {
|
|
2751
2705
|
"3dviewports": [],
|
|
@@ -2955,7 +2909,7 @@ var kicad_pro = (project_name) => ({
|
|
|
2955
2909
|
version: 1
|
|
2956
2910
|
},
|
|
2957
2911
|
net_format_name: "",
|
|
2958
|
-
page_layout_descr_file: `${project_name}.${
|
|
2912
|
+
page_layout_descr_file: `${project_name}.${import_utils17.DrawingSheetFileExtension}`,
|
|
2959
2913
|
plot_directory: "",
|
|
2960
2914
|
spice_current_sheet_as_root: false,
|
|
2961
2915
|
spice_external_command: 'spice "%I"',
|
|
@@ -2993,16 +2947,16 @@ var KiCadProjectArchive = class {
|
|
|
2993
2947
|
return kicad_pro(this.project_name);
|
|
2994
2948
|
}
|
|
2995
2949
|
get main_sch_name() {
|
|
2996
|
-
return this.get_project_directive_file_name(
|
|
2950
|
+
return this.get_project_directive_file_name(import_utils18.KiCadSchematicFileExtension);
|
|
2997
2951
|
}
|
|
2998
2952
|
get_project_directive_file_name(ext) {
|
|
2999
2953
|
return `${this.project_name}.${ext}`;
|
|
3000
2954
|
}
|
|
3001
2955
|
async toZip() {
|
|
3002
2956
|
const zip = new import_jszip.default();
|
|
3003
|
-
zip.file(this.get_project_directive_file_name(
|
|
3004
|
-
zip.file(this.get_project_directive_file_name(
|
|
3005
|
-
zip.file(this.get_project_directive_file_name(
|
|
2957
|
+
zip.file(this.get_project_directive_file_name(import_utils18.ProjectLocalSettingsFileExtension), JSON.stringify(this.kicad_prl));
|
|
2958
|
+
zip.file(this.get_project_directive_file_name(import_utils18.ProjectFileExtension), JSON.stringify(this.kicad_pro));
|
|
2959
|
+
zip.file(this.get_project_directive_file_name(import_utils18.DrawingSheetFileExtension), this.sch_frame);
|
|
3006
2960
|
for (const schematic of this.designBlock.schematics) {
|
|
3007
2961
|
zip.file(schematic.filename, schematic.content);
|
|
3008
2962
|
}
|
|
@@ -3050,9 +3004,9 @@ var KiCadProjectArchive = class {
|
|
|
3050
3004
|
};
|
|
3051
3005
|
|
|
3052
3006
|
// src/builder/graph_to_kicad/convert_graph_to_design_block.ts
|
|
3053
|
-
var
|
|
3007
|
+
var import_utils19 = require("@modular-circuit/utils");
|
|
3054
3008
|
async function convert_graph_to_design_block(ctx) {
|
|
3055
|
-
const root = ctx.project.main.replace(
|
|
3009
|
+
const root = ctx.project.main.replace(import_utils19.ModularCircuitFileExtension, import_utils19.KiCadSchematicFileExtension);
|
|
3056
3010
|
const sheets = await convert_graph_to_sheets(ctx);
|
|
3057
3011
|
if (!(root in sheets)) {
|
|
3058
3012
|
throw new Error(`Cannot find root sch file ${root}`);
|
|
@@ -3091,7 +3045,6 @@ async function convert_graph_to_kicad_project(ctx) {
|
|
|
3091
3045
|
SCHEMATIC_PRINTER,
|
|
3092
3046
|
StringFormatter,
|
|
3093
3047
|
WIRE_PADDING,
|
|
3094
|
-
collect_sub_sheets,
|
|
3095
3048
|
collect_sub_sheets_by_id,
|
|
3096
3049
|
convert_graph_to_design_block,
|
|
3097
3050
|
convert_graph_to_kicad_project,
|
package/dist/index.mjs
CHANGED
|
@@ -64,56 +64,6 @@ import {
|
|
|
64
64
|
} from "@modular-circuit/ir";
|
|
65
65
|
import { GENERATOR_NAME, GENERATOR_VERSION, PAPER, SCH_VERSION, gen_uuid as gen_uuid2 } from "@modular-circuit/utils";
|
|
66
66
|
|
|
67
|
-
// src/utils/collect_sub_sheets.ts
|
|
68
|
-
import {
|
|
69
|
-
KiCadSchematicFileExtension,
|
|
70
|
-
parse_module_name,
|
|
71
|
-
remove_filename_path_prefix,
|
|
72
|
-
unzipFile
|
|
73
|
-
} from "@modular-circuit/utils";
|
|
74
|
-
async function collect_sub_sheets(dependencies, module_resolver) {
|
|
75
|
-
const sheets = {};
|
|
76
|
-
const module_main_sheet = {};
|
|
77
|
-
const modules = {};
|
|
78
|
-
for (const [k, v] of Object.entries(dependencies)) {
|
|
79
|
-
try {
|
|
80
|
-
const zip_archive_url = await module_resolver.get_module_archive({
|
|
81
|
-
...parse_module_name(k),
|
|
82
|
-
version: v
|
|
83
|
-
});
|
|
84
|
-
const module = await module_resolver.get_module_circuit({
|
|
85
|
-
...parse_module_name(k),
|
|
86
|
-
version: v
|
|
87
|
-
});
|
|
88
|
-
if (!zip_archive_url || !module) {
|
|
89
|
-
console.error(`Module ${k}/${v} not found`);
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (!module.main) {
|
|
93
|
-
console.error(`Missing main entry in module ${k}/${v}`);
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
module_main_sheet[k] = module.main;
|
|
97
|
-
modules[k] = module;
|
|
98
|
-
const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
|
|
99
|
-
const files = await unzipFile(zip_archive);
|
|
100
|
-
for (const [name, content] of Object.entries(files)) {
|
|
101
|
-
if (name.endsWith(KiCadSchematicFileExtension)) {
|
|
102
|
-
const fileName = remove_filename_path_prefix(name);
|
|
103
|
-
if (fileName in sheets) {
|
|
104
|
-
console.error(`Duplicate sheet name: ${fileName}`);
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
sheets[fileName] = content;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
} catch (e) {
|
|
111
|
-
console.error(`Failed to download zip for module : ${e}`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return { sheets, module_main_sheet, modules };
|
|
115
|
-
}
|
|
116
|
-
|
|
117
67
|
// src/utils/filter_null_undefined.ts
|
|
118
68
|
function filterNullOrUndefined(originalMethod, _context) {
|
|
119
69
|
function replacementMethod(...args) {
|
|
@@ -157,10 +107,10 @@ var StringFormatter = class {
|
|
|
157
107
|
// src/utils/collect_sub_sheets_by_id.ts
|
|
158
108
|
import {
|
|
159
109
|
KiCadPcbFileExtension,
|
|
160
|
-
KiCadSchematicFileExtension
|
|
110
|
+
KiCadSchematicFileExtension,
|
|
161
111
|
fmt_module_name,
|
|
162
|
-
remove_filename_path_prefix
|
|
163
|
-
unzipFile
|
|
112
|
+
remove_filename_path_prefix,
|
|
113
|
+
unzipFile
|
|
164
114
|
} from "@modular-circuit/utils";
|
|
165
115
|
async function collect_sub_sheets_by_id(module_ids, module_resolver) {
|
|
166
116
|
const sheets = {};
|
|
@@ -194,10 +144,10 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
|
|
|
194
144
|
};
|
|
195
145
|
console.log(`Fetching ZIP archive for module ${id} from ${zip_archive_url.toString()}`);
|
|
196
146
|
const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
|
|
197
|
-
const files = await
|
|
147
|
+
const files = await unzipFile(zip_archive);
|
|
198
148
|
for (const [name, content] of Object.entries(files)) {
|
|
199
|
-
if (name.endsWith(
|
|
200
|
-
const filename =
|
|
149
|
+
if (name.endsWith(KiCadSchematicFileExtension)) {
|
|
150
|
+
const filename = remove_filename_path_prefix(name);
|
|
201
151
|
if (filename in sheets) {
|
|
202
152
|
console.error(`Duplicate sheet name: ${filename}`);
|
|
203
153
|
continue;
|
|
@@ -205,7 +155,7 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
|
|
|
205
155
|
sheets[filename] = content;
|
|
206
156
|
design_block.schematics.push({ filename, content });
|
|
207
157
|
} else if (name.endsWith(KiCadPcbFileExtension)) {
|
|
208
|
-
const filename =
|
|
158
|
+
const filename = remove_filename_path_prefix(name);
|
|
209
159
|
design_block.pcb = { pcb: { filename, content } };
|
|
210
160
|
}
|
|
211
161
|
}
|
|
@@ -2575,7 +2525,7 @@ import { build_connection_graph } from "@modular-circuit/perc";
|
|
|
2575
2525
|
import {
|
|
2576
2526
|
fmt_abstract_sch_name,
|
|
2577
2527
|
fmt_module_place_holder_sch_name,
|
|
2578
|
-
KiCadSchematicFileExtension as
|
|
2528
|
+
KiCadSchematicFileExtension as KiCadSchematicFileExtension2
|
|
2579
2529
|
} from "@modular-circuit/utils";
|
|
2580
2530
|
async function do_convert_graph_to_kicad_project(ctx) {
|
|
2581
2531
|
const module_ids = [];
|
|
@@ -2593,10 +2543,10 @@ async function do_convert_graph_to_kicad_project(ctx) {
|
|
|
2593
2543
|
}
|
|
2594
2544
|
}
|
|
2595
2545
|
}
|
|
2596
|
-
const
|
|
2597
|
-
|
|
2598
|
-
...
|
|
2599
|
-
...
|
|
2546
|
+
const collected = await collect_sub_sheets_by_id(module_ids, ctx.module_resolver);
|
|
2547
|
+
const sheets = {
|
|
2548
|
+
...collected.sheets,
|
|
2549
|
+
...generated_sheets
|
|
2600
2550
|
};
|
|
2601
2551
|
const netlist = new GraphConverter({
|
|
2602
2552
|
...ctx
|
|
@@ -2620,7 +2570,7 @@ async function do_convert_graph_to_kicad_project(ctx) {
|
|
|
2620
2570
|
if (k in sheets) {
|
|
2621
2571
|
console.error(`Duplicated sheet file name found ${k}`);
|
|
2622
2572
|
}
|
|
2623
|
-
sheets[k.replace(MODULAR_CIRCUIT_SCH_EXT2,
|
|
2573
|
+
sheets[k.replace(MODULAR_CIRCUIT_SCH_EXT2, KiCadSchematicFileExtension2)] = sexpr_printer.schematic(v);
|
|
2624
2574
|
}
|
|
2625
2575
|
return sheets;
|
|
2626
2576
|
}
|
|
@@ -2637,7 +2587,7 @@ async function convert_graph_to_sheets(ctx) {
|
|
|
2637
2587
|
// src/kicad/project/kicad_project_archive.ts
|
|
2638
2588
|
import {
|
|
2639
2589
|
DrawingSheetFileExtension as DrawingSheetFileExtension2,
|
|
2640
|
-
KiCadSchematicFileExtension as
|
|
2590
|
+
KiCadSchematicFileExtension as KiCadSchematicFileExtension3,
|
|
2641
2591
|
ProjectFileExtension,
|
|
2642
2592
|
ProjectLocalSettingsFileExtension
|
|
2643
2593
|
} from "@modular-circuit/utils";
|
|
@@ -2977,7 +2927,7 @@ var KiCadProjectArchive = class {
|
|
|
2977
2927
|
return kicad_pro(this.project_name);
|
|
2978
2928
|
}
|
|
2979
2929
|
get main_sch_name() {
|
|
2980
|
-
return this.get_project_directive_file_name(
|
|
2930
|
+
return this.get_project_directive_file_name(KiCadSchematicFileExtension3);
|
|
2981
2931
|
}
|
|
2982
2932
|
get_project_directive_file_name(ext) {
|
|
2983
2933
|
return `${this.project_name}.${ext}`;
|
|
@@ -3034,9 +2984,9 @@ var KiCadProjectArchive = class {
|
|
|
3034
2984
|
};
|
|
3035
2985
|
|
|
3036
2986
|
// src/builder/graph_to_kicad/convert_graph_to_design_block.ts
|
|
3037
|
-
import { KiCadSchematicFileExtension as
|
|
2987
|
+
import { KiCadSchematicFileExtension as KiCadSchematicFileExtension4, ModularCircuitFileExtension } from "@modular-circuit/utils";
|
|
3038
2988
|
async function convert_graph_to_design_block(ctx) {
|
|
3039
|
-
const root = ctx.project.main.replace(ModularCircuitFileExtension,
|
|
2989
|
+
const root = ctx.project.main.replace(ModularCircuitFileExtension, KiCadSchematicFileExtension4);
|
|
3040
2990
|
const sheets = await convert_graph_to_sheets(ctx);
|
|
3041
2991
|
if (!(root in sheets)) {
|
|
3042
2992
|
throw new Error(`Cannot find root sch file ${root}`);
|
|
@@ -3074,7 +3024,6 @@ export {
|
|
|
3074
3024
|
SCHEMATIC_PRINTER,
|
|
3075
3025
|
StringFormatter,
|
|
3076
3026
|
WIRE_PADDING,
|
|
3077
|
-
collect_sub_sheets,
|
|
3078
3027
|
collect_sub_sheets_by_id,
|
|
3079
3028
|
convert_graph_to_design_block,
|
|
3080
3029
|
convert_graph_to_kicad_project,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modular-circuit/transpiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Intermediate representation of the modular circuit",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -29,11 +29,11 @@
|
|
|
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/ir": "0.
|
|
34
|
-
"@modular-circuit/
|
|
35
|
-
"@modular-circuit/
|
|
36
|
-
"@modular-circuit/
|
|
32
|
+
"@modular-circuit/electronics-model": "0.3.0",
|
|
33
|
+
"@modular-circuit/ir": "0.3.0",
|
|
34
|
+
"@modular-circuit/perc": "0.3.0",
|
|
35
|
+
"@modular-circuit/utils": "0.3.0",
|
|
36
|
+
"@modular-circuit/genai": "0.3.0"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"clean": "rimraf dist",
|