@modular-circuit/transpiler 0.1.7 → 0.1.9

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VECTOR2, At, Color, ConnectionGraph, NL_NetList, BOX2 } from '@modular-circuit/electronics-model';
2
- import { SCHEMATIC, PIN_DISPLAY_OPT, LIB_SYMBOL, Drawing, PIN_DEFINITION, SCH_LABEL, SCH_SYMBOL, SCH_LINE, PIN_INSTANCE, SCH_SHEET, SCH_SHEET_PIN, Effects, Justify, SCH_FIELD, Fill, Stroke, Project, IR_Graph, ModuleResolver, ModuleCircuit } from '@modular-circuit/ir';
2
+ import { SCHEMATIC, PIN_DISPLAY_OPT, LIB_SYMBOL, Drawing, PIN_DEFINITION, SCH_LABEL, SCH_SYMBOL, SCH_LINE, PIN_INSTANCE, SCH_SHEET, SCH_SHEET_PIN, Effects, Justify, SCH_FIELD, Fill, Stroke, Project, IR_Graph, ModuleResolver, ModuleCircuit, DesignBlockContent } from '@modular-circuit/ir';
3
3
  import { CG_SCHEMATIC, CONNECTION_GRAPH_BUILDER_CTX } from '@modular-circuit/perc';
4
4
 
5
5
  declare function get_sch_default_drawing_sheet(): string;
@@ -424,6 +424,7 @@ declare class KiCadProjectArchive {
424
424
  sheets: never[];
425
425
  text_variables: {};
426
426
  };
427
+ get main_sch_name(): string;
427
428
  constructor(project_name: string, sheets: Record<string, string>);
428
429
  get_project_directive_file_name(ext: string): string;
429
430
  toZip(): Promise<Blob>;
@@ -462,20 +463,11 @@ declare class StringFormatter {
462
463
  append_quote(str: string): void;
463
464
  }
464
465
 
465
- interface NamedContent {
466
- filename: string;
467
- content: string;
468
- }
469
- interface DesignBlock {
470
- main_sch: string;
471
- sheets: NamedContent[];
472
- pcb?: NamedContent;
473
- }
474
466
  declare function collect_sub_sheets_by_id(module_ids: string[], module_resolver: ModuleResolver): Promise<{
475
467
  sheets: Record<string, string>;
476
468
  module_main_sheet: Record<string, string>;
477
469
  modules: Record<string, ModuleCircuit>;
478
- design_blocks: DesignBlock[];
470
+ design_blocks: DesignBlockContent[];
479
471
  }>;
480
472
 
481
473
  declare const gen_lib_gnd: (value: string) => LIB_SYMBOL;
@@ -486,4 +478,4 @@ declare const gen_sch_gnd: (value: string, pwr_number: number, port_id: string,
486
478
 
487
479
  declare const gen_sch_vcc: (value: string, pwr_number: number, port_id: string, position: VECTOR2) => SCH_SYMBOL;
488
480
 
489
- export { AllegroNetlistFileExtension, AltiumFootprintLibPathExtension, ArchiveFileExtension, BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, CadstarFootprintLibPathExtension, CadstarNetlistFileExtension, CadstarPartsLibraryFileExtension, CadstarPcbFileExtension, CadstarSchematicFileExtension, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, CsvFileExtension, DEFAULT_PAPER_SIZE, DatabaseLibraryFileExtension, type DesignBlock, DesignRulesFileExtension, DrawingSheetFileExtension, DrillFileExtension, EagleFootprintLibPathExtension, EaglePcbFileExtension, EquFileExtension, FONT_SIZE, FootprintAssignmentFileExtension, FootprintPlaceFileExtension, GENERATOR_NAME, GENERATOR_VERSION, GRID_SIZE, GedaPcbFootprintLibFileExtension, GerberFileExtension, GerberFileExtensionsRegex, GerberJobFileExtension, GltfBinaryFileExtension, GraphConverter, HTTPLibraryFileExtension, HotkeyFileExtension, HtmlFileExtension, Ipc2581FileExtension, IpcD356FileExtension, JpegFileExtension, JsonFileExtension, KICAD_SCH_FRAME, KiCadFootprintFileExtension, KiCadFootprintLibPathExtension, KiCadPcbFileExtension, KiCadProjectArchive, KiCadSchematicFileExtension, KiCadSymbolLibFileExtension, type LabelPadding, Layout, LegacyFootprintLibPathExtension, LegacyPcbFileExtension, LegacyProjectFileExtension, LegacySchematicFileExtension, LegacySymbolDocumentFileExtension, LegacySymbolLibFileExtension, MacrosFileExtension, MarkdownFileExtension, type NamedContent, NetListConverter, NetlistFileExtension, type NetlistProject, type NetlistToKicadContext, OrCadPcb2NetlistFileExtension, PAPER, PAPER_SIZE, PdfFileExtension, PngFileExtension, ProjectFileExtension, ProjectLocalSettingsFileExtension, ReportFileExtension, SCHEMATIC_PRINTER, SCH_VERSION, SVGFileExtension, SchematicSymbolFileExtension, type Size, SpecctraDsnFileExtension, SpecctraSessionFileExtension, SpiceFileExtension, StepFileAbrvExtension, StepFileExtension, StringFormatter, TextFileExtension, VrmlFileExtension, WIRE_PADDING, WorkbookFileExtension, XmlFileExtension, collect_sub_sheets, collect_sub_sheets_by_id, convert_graph_to_kicad_project, filterNullOrUndefined, gen_lib_gnd, gen_lib_vcc, gen_sch_gnd, gen_sch_vcc, get_power_pos, get_sch_default_drawing_sheet, tab };
481
+ export { AllegroNetlistFileExtension, AltiumFootprintLibPathExtension, ArchiveFileExtension, BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, CadstarFootprintLibPathExtension, CadstarNetlistFileExtension, CadstarPartsLibraryFileExtension, CadstarPcbFileExtension, CadstarSchematicFileExtension, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, CsvFileExtension, DEFAULT_PAPER_SIZE, DatabaseLibraryFileExtension, DesignRulesFileExtension, DrawingSheetFileExtension, DrillFileExtension, EagleFootprintLibPathExtension, EaglePcbFileExtension, EquFileExtension, FONT_SIZE, FootprintAssignmentFileExtension, FootprintPlaceFileExtension, GENERATOR_NAME, GENERATOR_VERSION, GRID_SIZE, GedaPcbFootprintLibFileExtension, GerberFileExtension, GerberFileExtensionsRegex, GerberJobFileExtension, GltfBinaryFileExtension, GraphConverter, HTTPLibraryFileExtension, HotkeyFileExtension, HtmlFileExtension, Ipc2581FileExtension, IpcD356FileExtension, JpegFileExtension, JsonFileExtension, KICAD_SCH_FRAME, KiCadFootprintFileExtension, KiCadFootprintLibPathExtension, KiCadPcbFileExtension, KiCadProjectArchive, KiCadSchematicFileExtension, KiCadSymbolLibFileExtension, type LabelPadding, Layout, LegacyFootprintLibPathExtension, LegacyPcbFileExtension, LegacyProjectFileExtension, LegacySchematicFileExtension, LegacySymbolDocumentFileExtension, LegacySymbolLibFileExtension, MacrosFileExtension, MarkdownFileExtension, NetListConverter, NetlistFileExtension, type NetlistProject, type NetlistToKicadContext, OrCadPcb2NetlistFileExtension, PAPER, PAPER_SIZE, PdfFileExtension, PngFileExtension, ProjectFileExtension, ProjectLocalSettingsFileExtension, ReportFileExtension, SCHEMATIC_PRINTER, SCH_VERSION, SVGFileExtension, SchematicSymbolFileExtension, type Size, SpecctraDsnFileExtension, SpecctraSessionFileExtension, SpiceFileExtension, StepFileAbrvExtension, StepFileExtension, StringFormatter, TextFileExtension, VrmlFileExtension, WIRE_PADDING, WorkbookFileExtension, XmlFileExtension, collect_sub_sheets, collect_sub_sheets_by_id, convert_graph_to_kicad_project, filterNullOrUndefined, 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
@@ -1,5 +1,5 @@
1
1
  import { VECTOR2, At, Color, ConnectionGraph, NL_NetList, BOX2 } from '@modular-circuit/electronics-model';
2
- import { SCHEMATIC, PIN_DISPLAY_OPT, LIB_SYMBOL, Drawing, PIN_DEFINITION, SCH_LABEL, SCH_SYMBOL, SCH_LINE, PIN_INSTANCE, SCH_SHEET, SCH_SHEET_PIN, Effects, Justify, SCH_FIELD, Fill, Stroke, Project, IR_Graph, ModuleResolver, ModuleCircuit } from '@modular-circuit/ir';
2
+ import { SCHEMATIC, PIN_DISPLAY_OPT, LIB_SYMBOL, Drawing, PIN_DEFINITION, SCH_LABEL, SCH_SYMBOL, SCH_LINE, PIN_INSTANCE, SCH_SHEET, SCH_SHEET_PIN, Effects, Justify, SCH_FIELD, Fill, Stroke, Project, IR_Graph, ModuleResolver, ModuleCircuit, DesignBlockContent } from '@modular-circuit/ir';
3
3
  import { CG_SCHEMATIC, CONNECTION_GRAPH_BUILDER_CTX } from '@modular-circuit/perc';
4
4
 
5
5
  declare function get_sch_default_drawing_sheet(): string;
@@ -424,6 +424,7 @@ declare class KiCadProjectArchive {
424
424
  sheets: never[];
425
425
  text_variables: {};
426
426
  };
427
+ get main_sch_name(): string;
427
428
  constructor(project_name: string, sheets: Record<string, string>);
428
429
  get_project_directive_file_name(ext: string): string;
429
430
  toZip(): Promise<Blob>;
@@ -462,20 +463,11 @@ declare class StringFormatter {
462
463
  append_quote(str: string): void;
463
464
  }
464
465
 
465
- interface NamedContent {
466
- filename: string;
467
- content: string;
468
- }
469
- interface DesignBlock {
470
- main_sch: string;
471
- sheets: NamedContent[];
472
- pcb?: NamedContent;
473
- }
474
466
  declare function collect_sub_sheets_by_id(module_ids: string[], module_resolver: ModuleResolver): Promise<{
475
467
  sheets: Record<string, string>;
476
468
  module_main_sheet: Record<string, string>;
477
469
  modules: Record<string, ModuleCircuit>;
478
- design_blocks: DesignBlock[];
470
+ design_blocks: DesignBlockContent[];
479
471
  }>;
480
472
 
481
473
  declare const gen_lib_gnd: (value: string) => LIB_SYMBOL;
@@ -486,4 +478,4 @@ declare const gen_sch_gnd: (value: string, pwr_number: number, port_id: string,
486
478
 
487
479
  declare const gen_sch_vcc: (value: string, pwr_number: number, port_id: string, position: VECTOR2) => SCH_SYMBOL;
488
480
 
489
- export { AllegroNetlistFileExtension, AltiumFootprintLibPathExtension, ArchiveFileExtension, BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, CadstarFootprintLibPathExtension, CadstarNetlistFileExtension, CadstarPartsLibraryFileExtension, CadstarPcbFileExtension, CadstarSchematicFileExtension, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, CsvFileExtension, DEFAULT_PAPER_SIZE, DatabaseLibraryFileExtension, type DesignBlock, DesignRulesFileExtension, DrawingSheetFileExtension, DrillFileExtension, EagleFootprintLibPathExtension, EaglePcbFileExtension, EquFileExtension, FONT_SIZE, FootprintAssignmentFileExtension, FootprintPlaceFileExtension, GENERATOR_NAME, GENERATOR_VERSION, GRID_SIZE, GedaPcbFootprintLibFileExtension, GerberFileExtension, GerberFileExtensionsRegex, GerberJobFileExtension, GltfBinaryFileExtension, GraphConverter, HTTPLibraryFileExtension, HotkeyFileExtension, HtmlFileExtension, Ipc2581FileExtension, IpcD356FileExtension, JpegFileExtension, JsonFileExtension, KICAD_SCH_FRAME, KiCadFootprintFileExtension, KiCadFootprintLibPathExtension, KiCadPcbFileExtension, KiCadProjectArchive, KiCadSchematicFileExtension, KiCadSymbolLibFileExtension, type LabelPadding, Layout, LegacyFootprintLibPathExtension, LegacyPcbFileExtension, LegacyProjectFileExtension, LegacySchematicFileExtension, LegacySymbolDocumentFileExtension, LegacySymbolLibFileExtension, MacrosFileExtension, MarkdownFileExtension, type NamedContent, NetListConverter, NetlistFileExtension, type NetlistProject, type NetlistToKicadContext, OrCadPcb2NetlistFileExtension, PAPER, PAPER_SIZE, PdfFileExtension, PngFileExtension, ProjectFileExtension, ProjectLocalSettingsFileExtension, ReportFileExtension, SCHEMATIC_PRINTER, SCH_VERSION, SVGFileExtension, SchematicSymbolFileExtension, type Size, SpecctraDsnFileExtension, SpecctraSessionFileExtension, SpiceFileExtension, StepFileAbrvExtension, StepFileExtension, StringFormatter, TextFileExtension, VrmlFileExtension, WIRE_PADDING, WorkbookFileExtension, XmlFileExtension, collect_sub_sheets, collect_sub_sheets_by_id, convert_graph_to_kicad_project, filterNullOrUndefined, gen_lib_gnd, gen_lib_vcc, gen_sch_gnd, gen_sch_vcc, get_power_pos, get_sch_default_drawing_sheet, tab };
481
+ export { AllegroNetlistFileExtension, AltiumFootprintLibPathExtension, ArchiveFileExtension, BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, CadstarFootprintLibPathExtension, CadstarNetlistFileExtension, CadstarPartsLibraryFileExtension, CadstarPcbFileExtension, CadstarSchematicFileExtension, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, CsvFileExtension, DEFAULT_PAPER_SIZE, DatabaseLibraryFileExtension, DesignRulesFileExtension, DrawingSheetFileExtension, DrillFileExtension, EagleFootprintLibPathExtension, EaglePcbFileExtension, EquFileExtension, FONT_SIZE, FootprintAssignmentFileExtension, FootprintPlaceFileExtension, GENERATOR_NAME, GENERATOR_VERSION, GRID_SIZE, GedaPcbFootprintLibFileExtension, GerberFileExtension, GerberFileExtensionsRegex, GerberJobFileExtension, GltfBinaryFileExtension, GraphConverter, HTTPLibraryFileExtension, HotkeyFileExtension, HtmlFileExtension, Ipc2581FileExtension, IpcD356FileExtension, JpegFileExtension, JsonFileExtension, KICAD_SCH_FRAME, KiCadFootprintFileExtension, KiCadFootprintLibPathExtension, KiCadPcbFileExtension, KiCadProjectArchive, KiCadSchematicFileExtension, KiCadSymbolLibFileExtension, type LabelPadding, Layout, LegacyFootprintLibPathExtension, LegacyPcbFileExtension, LegacyProjectFileExtension, LegacySchematicFileExtension, LegacySymbolDocumentFileExtension, LegacySymbolLibFileExtension, MacrosFileExtension, MarkdownFileExtension, NetListConverter, NetlistFileExtension, type NetlistProject, type NetlistToKicadContext, OrCadPcb2NetlistFileExtension, PAPER, PAPER_SIZE, PdfFileExtension, PngFileExtension, ProjectFileExtension, ProjectLocalSettingsFileExtension, ReportFileExtension, SCHEMATIC_PRINTER, SCH_VERSION, SVGFileExtension, SchematicSymbolFileExtension, type Size, SpecctraDsnFileExtension, SpecctraSessionFileExtension, SpiceFileExtension, StepFileAbrvExtension, StepFileExtension, StringFormatter, TextFileExtension, VrmlFileExtension, WIRE_PADDING, WorkbookFileExtension, XmlFileExtension, collect_sub_sheets, collect_sub_sheets_by_id, convert_graph_to_kicad_project, filterNullOrUndefined, 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
@@ -313,9 +313,12 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
313
313
  module_main_sheet[k] = module_circuit.main;
314
314
  modules[k] = module_circuit;
315
315
  const design_block = {
316
- main_sch: module_circuit.main,
317
- sheets: []
316
+ root: module_circuit.main,
317
+ schematics: [],
318
+ pcb: null,
319
+ components: []
318
320
  };
321
+ console.log(`Fetching ZIP archive for module ${id} from ${zip_archive_url.toString()}`);
319
322
  const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
320
323
  const files = await (0, import_utils2.unzipFile)(zip_archive);
321
324
  for (const [name, content] of Object.entries(files)) {
@@ -326,15 +329,15 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
326
329
  continue;
327
330
  }
328
331
  sheets[filename] = content;
329
- design_block.sheets.push({ filename, content });
332
+ design_block.schematics.push({ filename, content });
330
333
  } else if (name.endsWith(import_utils2.KICAD_PCB_FILE_EXT)) {
331
334
  const filename = (0, import_utils2.remove_filename_path_prefix)(name);
332
- design_block.pcb = { filename, content };
335
+ design_block.pcb = { pcb: { filename, content } };
333
336
  }
334
337
  }
335
338
  design_blocks.push(design_block);
336
339
  } catch (e) {
337
- console.error(`Failed to download zip for module : ${e}`);
340
+ console.error(`Failed to download zip for module, id: ${id}, fail reason: ${e}`);
338
341
  }
339
342
  }
340
343
  return { sheets, module_main_sheet, modules, design_blocks };
@@ -2531,10 +2534,7 @@ var NetListConverter = class {
2531
2534
  }
2532
2535
  };
2533
2536
 
2534
- // src/builder/graph_to_kicad/index.ts
2535
- var import_perc = require("@modular-circuit/perc");
2536
-
2537
- // src/builder/graph_to_kicad/do_convert_graph_to_kicad_project.ts
2537
+ // src/builder/graph_to_kicad/convert_graph_to_sheets.ts
2538
2538
  var import_ir5 = require("@modular-circuit/ir");
2539
2539
 
2540
2540
  // src/kicad/project/wildcards_and_files_ext.ts
@@ -2919,6 +2919,11 @@ var KiCadProjectArchive = class {
2919
2919
  constructor(project_name, sheets) {
2920
2920
  this.project_name = project_name;
2921
2921
  this.sheets = sheets;
2922
+ if (!(this.main_sch_name in this.sheets)) {
2923
+ throw new Error(
2924
+ `Expecting a main schematic file named ${this.main_sch_name} in the sheets : ${Object.keys(this.sheets)}`
2925
+ );
2926
+ }
2922
2927
  }
2923
2928
  get sch_frame() {
2924
2929
  return KICAD_SCH_FRAME;
@@ -2929,6 +2934,9 @@ var KiCadProjectArchive = class {
2929
2934
  get kicad_pro() {
2930
2935
  return kicad_pro(this.project_name);
2931
2936
  }
2937
+ get main_sch_name() {
2938
+ return this.get_project_directive_file_name(KiCadSchematicFileExtension);
2939
+ }
2932
2940
  get_project_directive_file_name(ext) {
2933
2941
  return `${this.project_name}.${ext}`;
2934
2942
  }
@@ -2942,7 +2950,8 @@ var KiCadProjectArchive = class {
2942
2950
  }
2943
2951
  };
2944
2952
 
2945
- // src/builder/graph_to_kicad/do_convert_graph_to_kicad_project.ts
2953
+ // src/builder/graph_to_kicad/convert_graph_to_sheets.ts
2954
+ var import_perc = require("@modular-circuit/perc");
2946
2955
  async function do_convert_graph_to_kicad_project(ctx) {
2947
2956
  const { sheets } = await collect_sub_sheets(ctx.project.dependencies, ctx.module_resolver);
2948
2957
  const netlist = new GraphConverter({
@@ -2959,18 +2968,25 @@ async function do_convert_graph_to_kicad_project(ctx) {
2959
2968
  }
2960
2969
  sheets[k.replace(import_ir5.MODULAR_CIRCUIT_SCH_EXT, KiCadSchematicFileExtension)] = sexpr_printer.schematic(v);
2961
2970
  }
2962
- const kicad_project = new KiCadProjectArchive(ctx.project.name, {
2963
- ...sheets
2971
+ return sheets;
2972
+ }
2973
+ async function convert_graph_to_sheets(ctx) {
2974
+ return do_convert_graph_to_kicad_project({
2975
+ ...ctx,
2976
+ ...await (0, import_perc.build_connection_graph)({
2977
+ ...ctx,
2978
+ dependencies: ctx.project.dependencies
2979
+ })
2964
2980
  });
2965
- return kicad_project.toZip();
2966
2981
  }
2967
2982
 
2968
- // src/builder/graph_to_kicad/index.ts
2983
+ // src/builder/graph_to_kicad/convert_graph_to_kicad_project.ts
2969
2984
  async function convert_graph_to_kicad_project(ctx) {
2970
- return do_convert_graph_to_kicad_project({
2971
- ...ctx,
2972
- ...await (0, import_perc.build_connection_graph)({ ...ctx, dependencies: ctx.project.dependencies })
2985
+ const sheets = await convert_graph_to_sheets(ctx);
2986
+ const kicad_project = new KiCadProjectArchive(ctx.project.name, {
2987
+ ...sheets
2973
2988
  });
2989
+ return kicad_project.toZip();
2974
2990
  }
2975
2991
  // Annotate the CommonJS export names for ESM import in node:
2976
2992
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -200,9 +200,12 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
200
200
  module_main_sheet[k] = module_circuit.main;
201
201
  modules[k] = module_circuit;
202
202
  const design_block = {
203
- main_sch: module_circuit.main,
204
- sheets: []
203
+ root: module_circuit.main,
204
+ schematics: [],
205
+ pcb: null,
206
+ components: []
205
207
  };
208
+ console.log(`Fetching ZIP archive for module ${id} from ${zip_archive_url.toString()}`);
206
209
  const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
207
210
  const files = await unzipFile2(zip_archive);
208
211
  for (const [name, content] of Object.entries(files)) {
@@ -213,15 +216,15 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
213
216
  continue;
214
217
  }
215
218
  sheets[filename] = content;
216
- design_block.sheets.push({ filename, content });
219
+ design_block.schematics.push({ filename, content });
217
220
  } else if (name.endsWith(KICAD_PCB_FILE_EXT)) {
218
221
  const filename = remove_filename_path_prefix2(name);
219
- design_block.pcb = { filename, content };
222
+ design_block.pcb = { pcb: { filename, content } };
220
223
  }
221
224
  }
222
225
  design_blocks.push(design_block);
223
226
  } catch (e) {
224
- console.error(`Failed to download zip for module : ${e}`);
227
+ console.error(`Failed to download zip for module, id: ${id}, fail reason: ${e}`);
225
228
  }
226
229
  }
227
230
  return { sheets, module_main_sheet, modules, design_blocks };
@@ -2432,10 +2435,7 @@ var NetListConverter = class {
2432
2435
  }
2433
2436
  };
2434
2437
 
2435
- // src/builder/graph_to_kicad/index.ts
2436
- import { build_connection_graph } from "@modular-circuit/perc";
2437
-
2438
- // src/builder/graph_to_kicad/do_convert_graph_to_kicad_project.ts
2438
+ // src/builder/graph_to_kicad/convert_graph_to_sheets.ts
2439
2439
  import { MODULAR_CIRCUIT_SCH_EXT as MODULAR_CIRCUIT_SCH_EXT2 } from "@modular-circuit/ir";
2440
2440
 
2441
2441
  // src/kicad/project/wildcards_and_files_ext.ts
@@ -2820,6 +2820,11 @@ var KiCadProjectArchive = class {
2820
2820
  constructor(project_name, sheets) {
2821
2821
  this.project_name = project_name;
2822
2822
  this.sheets = sheets;
2823
+ if (!(this.main_sch_name in this.sheets)) {
2824
+ throw new Error(
2825
+ `Expecting a main schematic file named ${this.main_sch_name} in the sheets : ${Object.keys(this.sheets)}`
2826
+ );
2827
+ }
2823
2828
  }
2824
2829
  get sch_frame() {
2825
2830
  return KICAD_SCH_FRAME;
@@ -2830,6 +2835,9 @@ var KiCadProjectArchive = class {
2830
2835
  get kicad_pro() {
2831
2836
  return kicad_pro(this.project_name);
2832
2837
  }
2838
+ get main_sch_name() {
2839
+ return this.get_project_directive_file_name(KiCadSchematicFileExtension);
2840
+ }
2833
2841
  get_project_directive_file_name(ext) {
2834
2842
  return `${this.project_name}.${ext}`;
2835
2843
  }
@@ -2843,7 +2851,8 @@ var KiCadProjectArchive = class {
2843
2851
  }
2844
2852
  };
2845
2853
 
2846
- // src/builder/graph_to_kicad/do_convert_graph_to_kicad_project.ts
2854
+ // src/builder/graph_to_kicad/convert_graph_to_sheets.ts
2855
+ import { build_connection_graph } from "@modular-circuit/perc";
2847
2856
  async function do_convert_graph_to_kicad_project(ctx) {
2848
2857
  const { sheets } = await collect_sub_sheets(ctx.project.dependencies, ctx.module_resolver);
2849
2858
  const netlist = new GraphConverter({
@@ -2860,18 +2869,25 @@ async function do_convert_graph_to_kicad_project(ctx) {
2860
2869
  }
2861
2870
  sheets[k.replace(MODULAR_CIRCUIT_SCH_EXT2, KiCadSchematicFileExtension)] = sexpr_printer.schematic(v);
2862
2871
  }
2863
- const kicad_project = new KiCadProjectArchive(ctx.project.name, {
2864
- ...sheets
2872
+ return sheets;
2873
+ }
2874
+ async function convert_graph_to_sheets(ctx) {
2875
+ return do_convert_graph_to_kicad_project({
2876
+ ...ctx,
2877
+ ...await build_connection_graph({
2878
+ ...ctx,
2879
+ dependencies: ctx.project.dependencies
2880
+ })
2865
2881
  });
2866
- return kicad_project.toZip();
2867
2882
  }
2868
2883
 
2869
- // src/builder/graph_to_kicad/index.ts
2884
+ // src/builder/graph_to_kicad/convert_graph_to_kicad_project.ts
2870
2885
  async function convert_graph_to_kicad_project(ctx) {
2871
- return do_convert_graph_to_kicad_project({
2872
- ...ctx,
2873
- ...await build_connection_graph({ ...ctx, dependencies: ctx.project.dependencies })
2886
+ const sheets = await convert_graph_to_sheets(ctx);
2887
+ const kicad_project = new KiCadProjectArchive(ctx.project.name, {
2888
+ ...sheets
2874
2889
  });
2890
+ return kicad_project.toZip();
2875
2891
  }
2876
2892
  export {
2877
2893
  AllegroNetlistFileExtension,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-circuit/transpiler",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Intermediate representation of the modular circuit",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -30,7 +30,7 @@
30
30
  "js-base64": "^3.7.7",
31
31
  "jszip": "^3.10.1",
32
32
  "@modular-circuit/electronics-model": "0.1.1",
33
- "@modular-circuit/ir": "0.1.2",
33
+ "@modular-circuit/ir": "0.1.3",
34
34
  "@modular-circuit/perc": "0.1.4",
35
35
  "@modular-circuit/utils": "0.1.2"
36
36
  },