@modular-circuit/transpiler 0.1.6 → 0.1.8

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
@@ -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>;
package/dist/index.d.ts CHANGED
@@ -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>;
package/dist/index.js CHANGED
@@ -316,6 +316,7 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
316
316
  main_sch: module_circuit.main,
317
317
  sheets: []
318
318
  };
319
+ console.log(`Fetching ZIP archive for module ${id} from ${zip_archive_url.toString()}`);
319
320
  const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
320
321
  const files = await (0, import_utils2.unzipFile)(zip_archive);
321
322
  for (const [name, content] of Object.entries(files)) {
@@ -334,7 +335,7 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
334
335
  }
335
336
  design_blocks.push(design_block);
336
337
  } catch (e) {
337
- console.error(`Failed to download zip for module : ${e}`);
338
+ console.error(`Failed to download zip for module, id: ${id}, fail reason: ${e}`);
338
339
  }
339
340
  }
340
341
  return { sheets, module_main_sheet, modules, design_blocks };
@@ -2531,10 +2532,7 @@ var NetListConverter = class {
2531
2532
  }
2532
2533
  };
2533
2534
 
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
2535
+ // src/builder/graph_to_kicad/convert_graph_to_sheets.ts
2538
2536
  var import_ir5 = require("@modular-circuit/ir");
2539
2537
 
2540
2538
  // src/kicad/project/wildcards_and_files_ext.ts
@@ -2919,6 +2917,11 @@ var KiCadProjectArchive = class {
2919
2917
  constructor(project_name, sheets) {
2920
2918
  this.project_name = project_name;
2921
2919
  this.sheets = sheets;
2920
+ if (!(this.main_sch_name in this.sheets)) {
2921
+ throw new Error(
2922
+ `Expecting a main schematic file named ${this.main_sch_name} in the sheets : ${Object.keys(this.sheets)}`
2923
+ );
2924
+ }
2922
2925
  }
2923
2926
  get sch_frame() {
2924
2927
  return KICAD_SCH_FRAME;
@@ -2929,6 +2932,9 @@ var KiCadProjectArchive = class {
2929
2932
  get kicad_pro() {
2930
2933
  return kicad_pro(this.project_name);
2931
2934
  }
2935
+ get main_sch_name() {
2936
+ return this.get_project_directive_file_name(KiCadSchematicFileExtension);
2937
+ }
2932
2938
  get_project_directive_file_name(ext) {
2933
2939
  return `${this.project_name}.${ext}`;
2934
2940
  }
@@ -2942,7 +2948,8 @@ var KiCadProjectArchive = class {
2942
2948
  }
2943
2949
  };
2944
2950
 
2945
- // src/builder/graph_to_kicad/do_convert_graph_to_kicad_project.ts
2951
+ // src/builder/graph_to_kicad/convert_graph_to_sheets.ts
2952
+ var import_perc = require("@modular-circuit/perc");
2946
2953
  async function do_convert_graph_to_kicad_project(ctx) {
2947
2954
  const { sheets } = await collect_sub_sheets(ctx.project.dependencies, ctx.module_resolver);
2948
2955
  const netlist = new GraphConverter({
@@ -2959,18 +2966,25 @@ async function do_convert_graph_to_kicad_project(ctx) {
2959
2966
  }
2960
2967
  sheets[k.replace(import_ir5.MODULAR_CIRCUIT_SCH_EXT, KiCadSchematicFileExtension)] = sexpr_printer.schematic(v);
2961
2968
  }
2962
- const kicad_project = new KiCadProjectArchive(ctx.project.name, {
2963
- ...sheets
2969
+ return sheets;
2970
+ }
2971
+ async function convert_graph_to_sheets(ctx) {
2972
+ return do_convert_graph_to_kicad_project({
2973
+ ...ctx,
2974
+ ...await (0, import_perc.build_connection_graph)({
2975
+ ...ctx,
2976
+ dependencies: ctx.project.dependencies
2977
+ })
2964
2978
  });
2965
- return kicad_project.toZip();
2966
2979
  }
2967
2980
 
2968
- // src/builder/graph_to_kicad/index.ts
2981
+ // src/builder/graph_to_kicad/convert_graph_to_kicad_project.ts
2969
2982
  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 })
2983
+ const sheets = await convert_graph_to_sheets(ctx);
2984
+ const kicad_project = new KiCadProjectArchive(ctx.project.name, {
2985
+ ...sheets
2973
2986
  });
2987
+ return kicad_project.toZip();
2974
2988
  }
2975
2989
  // Annotate the CommonJS export names for ESM import in node:
2976
2990
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -203,6 +203,7 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
203
203
  main_sch: module_circuit.main,
204
204
  sheets: []
205
205
  };
206
+ console.log(`Fetching ZIP archive for module ${id} from ${zip_archive_url.toString()}`);
206
207
  const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
207
208
  const files = await unzipFile2(zip_archive);
208
209
  for (const [name, content] of Object.entries(files)) {
@@ -221,7 +222,7 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
221
222
  }
222
223
  design_blocks.push(design_block);
223
224
  } catch (e) {
224
- console.error(`Failed to download zip for module : ${e}`);
225
+ console.error(`Failed to download zip for module, id: ${id}, fail reason: ${e}`);
225
226
  }
226
227
  }
227
228
  return { sheets, module_main_sheet, modules, design_blocks };
@@ -2432,10 +2433,7 @@ var NetListConverter = class {
2432
2433
  }
2433
2434
  };
2434
2435
 
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
2436
+ // src/builder/graph_to_kicad/convert_graph_to_sheets.ts
2439
2437
  import { MODULAR_CIRCUIT_SCH_EXT as MODULAR_CIRCUIT_SCH_EXT2 } from "@modular-circuit/ir";
2440
2438
 
2441
2439
  // src/kicad/project/wildcards_and_files_ext.ts
@@ -2820,6 +2818,11 @@ var KiCadProjectArchive = class {
2820
2818
  constructor(project_name, sheets) {
2821
2819
  this.project_name = project_name;
2822
2820
  this.sheets = sheets;
2821
+ if (!(this.main_sch_name in this.sheets)) {
2822
+ throw new Error(
2823
+ `Expecting a main schematic file named ${this.main_sch_name} in the sheets : ${Object.keys(this.sheets)}`
2824
+ );
2825
+ }
2823
2826
  }
2824
2827
  get sch_frame() {
2825
2828
  return KICAD_SCH_FRAME;
@@ -2830,6 +2833,9 @@ var KiCadProjectArchive = class {
2830
2833
  get kicad_pro() {
2831
2834
  return kicad_pro(this.project_name);
2832
2835
  }
2836
+ get main_sch_name() {
2837
+ return this.get_project_directive_file_name(KiCadSchematicFileExtension);
2838
+ }
2833
2839
  get_project_directive_file_name(ext) {
2834
2840
  return `${this.project_name}.${ext}`;
2835
2841
  }
@@ -2843,7 +2849,8 @@ var KiCadProjectArchive = class {
2843
2849
  }
2844
2850
  };
2845
2851
 
2846
- // src/builder/graph_to_kicad/do_convert_graph_to_kicad_project.ts
2852
+ // src/builder/graph_to_kicad/convert_graph_to_sheets.ts
2853
+ import { build_connection_graph } from "@modular-circuit/perc";
2847
2854
  async function do_convert_graph_to_kicad_project(ctx) {
2848
2855
  const { sheets } = await collect_sub_sheets(ctx.project.dependencies, ctx.module_resolver);
2849
2856
  const netlist = new GraphConverter({
@@ -2860,18 +2867,25 @@ async function do_convert_graph_to_kicad_project(ctx) {
2860
2867
  }
2861
2868
  sheets[k.replace(MODULAR_CIRCUIT_SCH_EXT2, KiCadSchematicFileExtension)] = sexpr_printer.schematic(v);
2862
2869
  }
2863
- const kicad_project = new KiCadProjectArchive(ctx.project.name, {
2864
- ...sheets
2870
+ return sheets;
2871
+ }
2872
+ async function convert_graph_to_sheets(ctx) {
2873
+ return do_convert_graph_to_kicad_project({
2874
+ ...ctx,
2875
+ ...await build_connection_graph({
2876
+ ...ctx,
2877
+ dependencies: ctx.project.dependencies
2878
+ })
2865
2879
  });
2866
- return kicad_project.toZip();
2867
2880
  }
2868
2881
 
2869
- // src/builder/graph_to_kicad/index.ts
2882
+ // src/builder/graph_to_kicad/convert_graph_to_kicad_project.ts
2870
2883
  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 })
2884
+ const sheets = await convert_graph_to_sheets(ctx);
2885
+ const kicad_project = new KiCadProjectArchive(ctx.project.name, {
2886
+ ...sheets
2874
2887
  });
2888
+ return kicad_project.toZip();
2875
2889
  }
2876
2890
  export {
2877
2891
  AllegroNetlistFileExtension,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-circuit/transpiler",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Intermediate representation of the modular circuit",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -29,9 +29,9 @@
29
29
  "elkjs": "^0.11.0",
30
30
  "js-base64": "^3.7.7",
31
31
  "jszip": "^3.10.1",
32
- "@modular-circuit/ir": "0.1.2",
33
- "@modular-circuit/perc": "0.1.4",
34
32
  "@modular-circuit/electronics-model": "0.1.1",
33
+ "@modular-circuit/ir": "0.1.3",
34
+ "@modular-circuit/perc": "0.1.4",
35
35
  "@modular-circuit/utils": "0.1.2"
36
36
  },
37
37
  "scripts": {