@modular-circuit/transpiler 0.0.77 → 0.0.79

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.
Files changed (34) hide show
  1. package/build/builder/graph_to_kicad/do_convert_graph_to_kicad_project.js +108 -19
  2. package/build/builder/graph_to_kicad/index.js +59 -4
  3. package/build/converter/graph_to_netlist/graph_converter.js +171 -51
  4. package/build/converter/kicad_sexpr/eeschema/drawing_sheet/sch_default_drawing_sheet.js +1 -1
  5. package/build/converter/kicad_sexpr/eeschema/printer.js +290 -245
  6. package/build/converter/link_to_netlist/converter.js +135 -77
  7. package/build/converter/link_to_netlist/links/converter_base.js +131 -38
  8. package/build/converter/link_to_netlist/links/converters.js +554 -316
  9. package/build/converter/netlist_to_kicad/calc_boxes_pos.d.ts +1 -1
  10. package/build/converter/netlist_to_kicad/calc_boxes_pos.d.ts.map +1 -1
  11. package/build/converter/netlist_to_kicad/calc_boxes_pos.js +115 -36
  12. package/build/converter/netlist_to_kicad/layout.js +32 -28
  13. package/build/converter/netlist_to_kicad/netlist_converter.d.ts +1 -1
  14. package/build/converter/netlist_to_kicad/netlist_converter.d.ts.map +1 -1
  15. package/build/converter/netlist_to_kicad/netlist_converter.js +300 -128
  16. package/build/kicad/constraints/index.js +1 -1
  17. package/build/kicad/label/net_label.js +2 -2
  18. package/build/kicad/label/sheet_pin.js +19 -11
  19. package/build/kicad/project/kicad_prl.js +3 -3
  20. package/build/kicad/project/kicad_pro.js +4 -4
  21. package/build/kicad/project/kicad_project_achieve.js +45 -31
  22. package/build/kicad/project/wildcards_and_files_ext.js +61 -61
  23. package/build/kicad/sheet/sheet.js +3 -3
  24. package/build/kicad/symbols/lib_symbol/gnd.js +6 -6
  25. package/build/kicad/symbols/lib_symbol/vcc.js +7 -7
  26. package/build/kicad/symbols/sch_symbol/gnd.js +9 -9
  27. package/build/kicad/symbols/sch_symbol/vcc.js +9 -9
  28. package/build/kicad/symbols/symbol_utils.js +1 -1
  29. package/build/kicad/wire/gen_wire.js +4 -4
  30. package/build/utils/collect_sub_sheets.js +151 -37
  31. package/build/utils/constraints.js +6 -6
  32. package/build/utils/filter_null_undefined.js +31 -2
  33. package/build/utils/string_formatter.js +29 -23
  34. package/package.json +5 -5
@@ -1,39 +1,53 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import { zipFiles } from '@modular-circuit/utils';
2
13
  import { get_sch_default_drawing_sheet } from '../../converter';
3
14
  import { kicad_prl } from './kicad_prl';
4
15
  import { kicad_pro } from './kicad_pro';
5
16
  import { DrawingSheetFileExtension, ProjectFileExtension, ProjectLocalSettingsFileExtension, } from './wildcards_and_files_ext';
6
- export const KICAD_SCH_FRAME = get_sch_default_drawing_sheet();
7
- export class KiCadProjectAchieve {
8
- project_name;
9
- sheets;
10
- kicad_sym;
11
- fp_lib_table;
12
- layout_frame;
13
- pcb;
14
- sym_lib_table;
15
- get sch_frame() {
16
- return KICAD_SCH_FRAME;
17
- }
18
- get kicad_prl() {
19
- return kicad_prl(this.project_name);
20
- }
21
- get kicad_pro() {
22
- return kicad_pro(this.project_name);
23
- }
24
- constructor(project_name, sheets) {
17
+ export var KICAD_SCH_FRAME = get_sch_default_drawing_sheet();
18
+ var KiCadProjectAchieve = /** @class */ (function () {
19
+ function KiCadProjectAchieve(project_name, sheets) {
25
20
  this.project_name = project_name;
26
21
  this.sheets = sheets;
27
22
  }
28
- get_project_directive_file_name(ext) {
29
- return `${this.project_name}.${ext}`;
30
- }
31
- toZip() {
32
- return zipFiles({
33
- [this.get_project_directive_file_name(ProjectLocalSettingsFileExtension)]: JSON.stringify(this.kicad_prl),
34
- [this.get_project_directive_file_name(ProjectFileExtension)]: JSON.stringify(this.kicad_pro),
35
- [this.get_project_directive_file_name(DrawingSheetFileExtension)]: this.sch_frame,
36
- ...this.sheets,
37
- });
38
- }
39
- }
23
+ Object.defineProperty(KiCadProjectAchieve.prototype, "sch_frame", {
24
+ get: function () {
25
+ return KICAD_SCH_FRAME;
26
+ },
27
+ enumerable: false,
28
+ configurable: true
29
+ });
30
+ Object.defineProperty(KiCadProjectAchieve.prototype, "kicad_prl", {
31
+ get: function () {
32
+ return kicad_prl(this.project_name);
33
+ },
34
+ enumerable: false,
35
+ configurable: true
36
+ });
37
+ Object.defineProperty(KiCadProjectAchieve.prototype, "kicad_pro", {
38
+ get: function () {
39
+ return kicad_pro(this.project_name);
40
+ },
41
+ enumerable: false,
42
+ configurable: true
43
+ });
44
+ KiCadProjectAchieve.prototype.get_project_directive_file_name = function (ext) {
45
+ return "".concat(this.project_name, ".").concat(ext);
46
+ };
47
+ KiCadProjectAchieve.prototype.toZip = function () {
48
+ var _a;
49
+ return zipFiles(__assign((_a = {}, _a[this.get_project_directive_file_name(ProjectLocalSettingsFileExtension)] = JSON.stringify(this.kicad_prl), _a[this.get_project_directive_file_name(ProjectFileExtension)] = JSON.stringify(this.kicad_pro), _a[this.get_project_directive_file_name(DrawingSheetFileExtension)] = this.sch_frame, _a), this.sheets));
50
+ };
51
+ return KiCadProjectAchieve;
52
+ }());
53
+ export { KiCadProjectAchieve };
@@ -1,61 +1,61 @@
1
- export const KiCadSymbolLibFileExtension = 'kicad_sym';
2
- export const SchematicSymbolFileExtension = 'sym';
3
- export const LegacySymbolLibFileExtension = 'lib';
4
- export const LegacySymbolDocumentFileExtension = 'dcm';
5
- export const VrmlFileExtension = 'wrl';
6
- export const ProjectFileExtension = 'kicad_pro';
7
- export const LegacyProjectFileExtension = 'pro';
8
- export const ProjectLocalSettingsFileExtension = 'kicad_prl';
9
- export const LegacySchematicFileExtension = 'sch';
10
- export const CadstarSchematicFileExtension = 'csa';
11
- export const CadstarPartsLibraryFileExtension = 'lib';
12
- export const KiCadSchematicFileExtension = 'kicad_sch';
13
- export const SpiceFileExtension = 'cir';
14
- export const CadstarNetlistFileExtension = 'frp';
15
- export const OrCadPcb2NetlistFileExtension = 'net';
16
- export const NetlistFileExtension = 'net';
17
- export const AllegroNetlistFileExtension = 'txt';
18
- export const FootprintAssignmentFileExtension = 'cmp';
19
- export const GerberFileExtension = 'gbr';
20
- export const GerberJobFileExtension = 'gbrjob';
21
- export const HtmlFileExtension = 'html';
22
- export const EquFileExtension = 'equ';
23
- export const HotkeyFileExtension = 'hotkeys';
24
- export const DatabaseLibraryFileExtension = 'kicad_dbl';
25
- export const HTTPLibraryFileExtension = 'kicad_httplib';
26
- export const ArchiveFileExtension = 'zip';
27
- export const LegacyPcbFileExtension = 'brd';
28
- export const EaglePcbFileExtension = 'brd';
29
- export const CadstarPcbFileExtension = 'cpa';
30
- export const KiCadPcbFileExtension = 'kicad_pcb';
31
- export const DrawingSheetFileExtension = 'kicad_wks';
32
- export const DesignRulesFileExtension = 'kicad_dru';
33
- export const PdfFileExtension = 'pdf';
34
- export const MacrosFileExtension = 'mcr';
35
- export const DrillFileExtension = 'drl';
36
- export const SVGFileExtension = 'svg';
37
- export const ReportFileExtension = 'rpt';
38
- export const FootprintPlaceFileExtension = 'pos';
39
- export const KiCadFootprintLibPathExtension = 'pretty'; // this is a directory
40
- export const LegacyFootprintLibPathExtension = 'mod'; // this is a file
41
- export const AltiumFootprintLibPathExtension = 'PcbLib'; // this is a file
42
- export const CadstarFootprintLibPathExtension = 'cpa'; // this is a file
43
- export const EagleFootprintLibPathExtension = 'lbr'; // this is a file
44
- export const GedaPcbFootprintLibFileExtension = 'fp'; // this is a file
45
- export const KiCadFootprintFileExtension = 'kicad_mod';
46
- export const SpecctraDsnFileExtension = 'dsn';
47
- export const SpecctraSessionFileExtension = 'ses';
48
- export const IpcD356FileExtension = 'd356';
49
- export const Ipc2581FileExtension = 'xml';
50
- export const WorkbookFileExtension = 'wbk';
51
- export const PngFileExtension = 'png';
52
- export const JpegFileExtension = 'jpg';
53
- export const TextFileExtension = 'txt';
54
- export const MarkdownFileExtension = 'md';
55
- export const CsvFileExtension = 'csv';
56
- export const XmlFileExtension = 'xml';
57
- export const JsonFileExtension = 'json';
58
- export const StepFileExtension = 'step';
59
- export const StepFileAbrvExtension = 'stp';
60
- export const GltfBinaryFileExtension = 'glb';
61
- export const GerberFileExtensionsRegex = /(gbr|gko|pho|(g[tb][alops])|(gm?\\d\\d*)|(gp[tb]))/;
1
+ export var KiCadSymbolLibFileExtension = 'kicad_sym';
2
+ export var SchematicSymbolFileExtension = 'sym';
3
+ export var LegacySymbolLibFileExtension = 'lib';
4
+ export var LegacySymbolDocumentFileExtension = 'dcm';
5
+ export var VrmlFileExtension = 'wrl';
6
+ export var ProjectFileExtension = 'kicad_pro';
7
+ export var LegacyProjectFileExtension = 'pro';
8
+ export var ProjectLocalSettingsFileExtension = 'kicad_prl';
9
+ export var LegacySchematicFileExtension = 'sch';
10
+ export var CadstarSchematicFileExtension = 'csa';
11
+ export var CadstarPartsLibraryFileExtension = 'lib';
12
+ export var KiCadSchematicFileExtension = 'kicad_sch';
13
+ export var SpiceFileExtension = 'cir';
14
+ export var CadstarNetlistFileExtension = 'frp';
15
+ export var OrCadPcb2NetlistFileExtension = 'net';
16
+ export var NetlistFileExtension = 'net';
17
+ export var AllegroNetlistFileExtension = 'txt';
18
+ export var FootprintAssignmentFileExtension = 'cmp';
19
+ export var GerberFileExtension = 'gbr';
20
+ export var GerberJobFileExtension = 'gbrjob';
21
+ export var HtmlFileExtension = 'html';
22
+ export var EquFileExtension = 'equ';
23
+ export var HotkeyFileExtension = 'hotkeys';
24
+ export var DatabaseLibraryFileExtension = 'kicad_dbl';
25
+ export var HTTPLibraryFileExtension = 'kicad_httplib';
26
+ export var ArchiveFileExtension = 'zip';
27
+ export var LegacyPcbFileExtension = 'brd';
28
+ export var EaglePcbFileExtension = 'brd';
29
+ export var CadstarPcbFileExtension = 'cpa';
30
+ export var KiCadPcbFileExtension = 'kicad_pcb';
31
+ export var DrawingSheetFileExtension = 'kicad_wks';
32
+ export var DesignRulesFileExtension = 'kicad_dru';
33
+ export var PdfFileExtension = 'pdf';
34
+ export var MacrosFileExtension = 'mcr';
35
+ export var DrillFileExtension = 'drl';
36
+ export var SVGFileExtension = 'svg';
37
+ export var ReportFileExtension = 'rpt';
38
+ export var FootprintPlaceFileExtension = 'pos';
39
+ export var KiCadFootprintLibPathExtension = 'pretty'; // this is a directory
40
+ export var LegacyFootprintLibPathExtension = 'mod'; // this is a file
41
+ export var AltiumFootprintLibPathExtension = 'PcbLib'; // this is a file
42
+ export var CadstarFootprintLibPathExtension = 'cpa'; // this is a file
43
+ export var EagleFootprintLibPathExtension = 'lbr'; // this is a file
44
+ export var GedaPcbFootprintLibFileExtension = 'fp'; // this is a file
45
+ export var KiCadFootprintFileExtension = 'kicad_mod';
46
+ export var SpecctraDsnFileExtension = 'dsn';
47
+ export var SpecctraSessionFileExtension = 'ses';
48
+ export var IpcD356FileExtension = 'd356';
49
+ export var Ipc2581FileExtension = 'xml';
50
+ export var WorkbookFileExtension = 'wbk';
51
+ export var PngFileExtension = 'png';
52
+ export var JpegFileExtension = 'jpg';
53
+ export var TextFileExtension = 'txt';
54
+ export var MarkdownFileExtension = 'md';
55
+ export var CsvFileExtension = 'csv';
56
+ export var XmlFileExtension = 'xml';
57
+ export var JsonFileExtension = 'json';
58
+ export var StepFileExtension = 'step';
59
+ export var StepFileAbrvExtension = 'stp';
60
+ export var GltfBinaryFileExtension = 'glb';
61
+ export var GerberFileExtensionsRegex = /(gbr|gko|pho|(g[tb][alops])|(gm?\\d\\d*)|(gp[tb]))/;
@@ -1,7 +1,7 @@
1
1
  import { gen_uuid } from '@modular-circuit/utils';
2
2
  import { DEFAULT_FONT_SIZE } from '../constraints';
3
- const TEXT_MARGIN = 0.7116;
4
- export const gen_sch_sheet = (rect, pins, fields) => ({
3
+ var TEXT_MARGIN = 0.7116;
4
+ export var gen_sch_sheet = function (rect, pins, fields) { return ({
5
5
  // NOTE no rotation in the sheet
6
6
  at: { position: rect.pos },
7
7
  size: rect.size,
@@ -41,4 +41,4 @@ export const gen_sch_sheet = (rect, pins, fields) => ({
41
41
  color: { r: 0, g: 0, b: 0, a: 0.0 },
42
42
  },
43
43
  uuid: gen_uuid(),
44
- });
44
+ }); };
@@ -1,8 +1,8 @@
1
1
  import { ELECTRICAL_PINTYPE, GRAPHIC_PINSHAPE } from '@modular-circuit/electronics-model';
2
2
  import { SHAPE_T } from '@modular-circuit/ir';
3
3
  import { DEFAULT_FONT_SIZE } from '../../constraints';
4
- export const gen_lib_gnd = (value) => ({
5
- name: `power:${value}`,
4
+ export var gen_lib_gnd = function (value) { return ({
5
+ name: "power:".concat(value),
6
6
  pin_numbers: {
7
7
  offset: 0,
8
8
  hide: true,
@@ -26,7 +26,7 @@ export const gen_lib_gnd = (value) => ({
26
26
  },
27
27
  {
28
28
  name: 'Value',
29
- text: `${value}`,
29
+ text: "".concat(value),
30
30
  at: { position: { x: 0, y: -3.81 }, rotation: 0 },
31
31
  effects: {
32
32
  font: { size: DEFAULT_FONT_SIZE },
@@ -71,7 +71,7 @@ export const gen_lib_gnd = (value) => ({
71
71
  ],
72
72
  children: [
73
73
  {
74
- name: `${value}_0_1`,
74
+ name: "".concat(value, "_0_1"),
75
75
  drawings: [
76
76
  {
77
77
  shape: SHAPE_T.POLY,
@@ -94,7 +94,7 @@ export const gen_lib_gnd = (value) => ({
94
94
  ],
95
95
  },
96
96
  {
97
- name: `${value}_0_1`,
97
+ name: "".concat(value, "_0_1"),
98
98
  pins: [
99
99
  {
100
100
  type: ELECTRICAL_PINTYPE.PT_POWER_IN,
@@ -118,4 +118,4 @@ export const gen_lib_gnd = (value) => ({
118
118
  ],
119
119
  },
120
120
  ],
121
- });
121
+ }); };
@@ -1,8 +1,8 @@
1
1
  import { ELECTRICAL_PINTYPE, GRAPHIC_PINSHAPE } from '@modular-circuit/electronics-model';
2
2
  import { SHAPE_T } from '@modular-circuit/ir';
3
3
  import { DEFAULT_FONT_SIZE } from '../../constraints';
4
- export const gen_lib_vcc = (value) => ({
5
- name: `power:${value}`,
4
+ export var gen_lib_vcc = function (value) { return ({
5
+ name: "power:".concat(value),
6
6
  power: true,
7
7
  pin_numbers: {
8
8
  offset: 0,
@@ -27,7 +27,7 @@ export const gen_lib_vcc = (value) => ({
27
27
  },
28
28
  {
29
29
  name: 'Value',
30
- text: `${value}`,
30
+ text: "".concat(value),
31
31
  at: { position: { x: 0, y: 3.556 }, rotation: 0 },
32
32
  effects: {
33
33
  font: { size: DEFAULT_FONT_SIZE },
@@ -53,7 +53,7 @@ export const gen_lib_vcc = (value) => ({
53
53
  },
54
54
  {
55
55
  name: 'Description',
56
- text: `Power symbol creates a global label with name \\"${value}\\"`,
56
+ text: "Power symbol creates a global label with name \\\"".concat(value, "\\\""),
57
57
  at: { position: { x: 0, y: 0 }, rotation: 0 },
58
58
  effects: {
59
59
  font: { size: DEFAULT_FONT_SIZE },
@@ -72,7 +72,7 @@ export const gen_lib_vcc = (value) => ({
72
72
  ],
73
73
  children: [
74
74
  {
75
- name: `${value}_0_1`,
75
+ name: "".concat(value, "_0_1"),
76
76
  drawings: [
77
77
  {
78
78
  shape: SHAPE_T.POLY,
@@ -92,7 +92,7 @@ export const gen_lib_vcc = (value) => ({
92
92
  ],
93
93
  },
94
94
  {
95
- name: `${value}_1_1`,
95
+ name: "".concat(value, "_1_1"),
96
96
  pins: [
97
97
  {
98
98
  type: ELECTRICAL_PINTYPE.PT_POWER_IN,
@@ -116,4 +116,4 @@ export const gen_lib_vcc = (value) => ({
116
116
  ],
117
117
  },
118
118
  ],
119
- });
119
+ }); };
@@ -1,9 +1,9 @@
1
1
  import { gen_uuid } from '@modular-circuit/utils';
2
2
  import { DEFAULT_FONT_SIZE } from '../../constraints';
3
3
  import { gen_pwr_ref } from '../symbol_utils';
4
- export const gen_sch_gnd = (value, pwr_number, port_id, position) => ({
5
- lib_id: `power:${value}`,
6
- at: { position, rotation: 0 },
4
+ export var gen_sch_gnd = function (value, pwr_number, port_id, position) { return ({
5
+ lib_id: "power:".concat(value),
6
+ at: { position: position, rotation: 0 },
7
7
  unit: 1,
8
8
  exclude_from_sim: false,
9
9
  in_bom: true,
@@ -23,7 +23,7 @@ export const gen_sch_gnd = (value, pwr_number, port_id, position) => ({
23
23
  },
24
24
  {
25
25
  name: 'Value',
26
- text: `${value}`,
26
+ text: "".concat(value),
27
27
  at: { position: { x: position.x, y: position.y + 5.08 }, rotation: 0 },
28
28
  effects: {
29
29
  font: { size: DEFAULT_FONT_SIZE },
@@ -32,7 +32,7 @@ export const gen_sch_gnd = (value, pwr_number, port_id, position) => ({
32
32
  {
33
33
  name: 'Footprint',
34
34
  text: '',
35
- at: { position, rotation: 0 },
35
+ at: { position: position, rotation: 0 },
36
36
  effects: {
37
37
  font: { size: DEFAULT_FONT_SIZE },
38
38
  hide: true,
@@ -41,7 +41,7 @@ export const gen_sch_gnd = (value, pwr_number, port_id, position) => ({
41
41
  {
42
42
  name: 'Datasheet',
43
43
  text: '',
44
- at: { position, rotation: 0 },
44
+ at: { position: position, rotation: 0 },
45
45
  effects: {
46
46
  font: { size: DEFAULT_FONT_SIZE },
47
47
  hide: true,
@@ -49,8 +49,8 @@ export const gen_sch_gnd = (value, pwr_number, port_id, position) => ({
49
49
  },
50
50
  {
51
51
  name: 'Description',
52
- text: `Power symbol creates a global label with name \\"${value}\\" , ground`,
53
- at: { position, rotation: 0 },
52
+ text: "Power symbol creates a global label with name \\\"".concat(value, "\\\" , ground"),
53
+ at: { position: position, rotation: 0 },
54
54
  effects: {
55
55
  font: { size: DEFAULT_FONT_SIZE },
56
56
  hide: true,
@@ -63,4 +63,4 @@ export const gen_sch_gnd = (value, pwr_number, port_id, position) => ({
63
63
  number: '1',
64
64
  },
65
65
  ],
66
- });
66
+ }); };
@@ -1,9 +1,9 @@
1
1
  import { gen_uuid } from '@modular-circuit/utils';
2
2
  import { DEFAULT_FONT_SIZE } from '../../constraints';
3
3
  import { gen_pwr_ref } from '../symbol_utils';
4
- export const gen_sch_vcc = (value, pwr_number, port_id, position) => ({
5
- lib_id: `power:${value}`,
6
- at: { position, rotation: 0 },
4
+ export var gen_sch_vcc = function (value, pwr_number, port_id, position) { return ({
5
+ lib_id: "power:".concat(value),
6
+ at: { position: position, rotation: 0 },
7
7
  unit: 1,
8
8
  exclude_from_sim: false,
9
9
  in_bom: true,
@@ -23,7 +23,7 @@ export const gen_sch_vcc = (value, pwr_number, port_id, position) => ({
23
23
  },
24
24
  {
25
25
  name: 'Value',
26
- text: `${value}`,
26
+ text: "".concat(value),
27
27
  at: { position: { x: position.x, y: position.y - 5.08 }, rotation: 0 },
28
28
  effects: {
29
29
  font: { size: DEFAULT_FONT_SIZE },
@@ -32,7 +32,7 @@ export const gen_sch_vcc = (value, pwr_number, port_id, position) => ({
32
32
  {
33
33
  name: 'Footprint',
34
34
  text: '',
35
- at: { position, rotation: 0 },
35
+ at: { position: position, rotation: 0 },
36
36
  effects: {
37
37
  font: { size: DEFAULT_FONT_SIZE },
38
38
  hide: true,
@@ -41,7 +41,7 @@ export const gen_sch_vcc = (value, pwr_number, port_id, position) => ({
41
41
  {
42
42
  name: 'Datasheet',
43
43
  text: '',
44
- at: { position, rotation: 0 },
44
+ at: { position: position, rotation: 0 },
45
45
  effects: {
46
46
  font: { size: DEFAULT_FONT_SIZE },
47
47
  hide: true,
@@ -49,8 +49,8 @@ export const gen_sch_vcc = (value, pwr_number, port_id, position) => ({
49
49
  },
50
50
  {
51
51
  name: 'Description',
52
- text: `Power symbol creates a global label with name \\"${value}\\"`,
53
- at: { position, rotation: 0 },
52
+ text: "Power symbol creates a global label with name \\\"".concat(value, "\\\""),
53
+ at: { position: position, rotation: 0 },
54
54
  effects: {
55
55
  font: { size: DEFAULT_FONT_SIZE },
56
56
  hide: true,
@@ -63,4 +63,4 @@ export const gen_sch_vcc = (value, pwr_number, port_id, position) => ({
63
63
  uuid: port_id,
64
64
  },
65
65
  ],
66
- });
66
+ }); };
@@ -1 +1 @@
1
- export const gen_pwr_ref = (pwr_num) => `#PWR${pwr_num}`;
1
+ export var gen_pwr_ref = function (pwr_num) { return "#PWR".concat(pwr_num); };
@@ -1,12 +1,12 @@
1
1
  import { GS_SCH_ITEM_TYPE } from '@modular-circuit/electronics-model';
2
2
  import { gen_uuid } from '@modular-circuit/utils';
3
- export const gen_wire = (start, end) => ({
3
+ export var gen_wire = function (start, end) { return ({
4
4
  stroke: {
5
5
  type: 'default',
6
6
  width: 0,
7
7
  },
8
- start,
9
- end,
8
+ start: start,
9
+ end: end,
10
10
  uuid: gen_uuid(),
11
11
  type: GS_SCH_ITEM_TYPE.LINE,
12
- });
12
+ }); };
@@ -1,42 +1,156 @@
1
- import { KICAD_SHC_FILE_EXT, parse_module_name, remove_filename_path_prefix, unzipFile } from '@modular-circuit/utils';
2
- export async function collect_sub_sheets(dependencies, module_resolver) {
3
- const sheets = {};
4
- const module_main_sheet = {};
5
- const modules = {};
6
- for (const [k, v] of Object.entries(dependencies)) {
7
- // Get the URL for the ZIP archive
8
- const zip_achieve_url = await module_resolver.get_module_achieve({
9
- ...parse_module_name(k),
10
- version: v,
11
- });
12
- const module = await module_resolver.get_module_circuit({
13
- ...parse_module_name(k),
14
- version: v,
15
- });
16
- if (!zip_achieve_url || !module) {
17
- console.error(`Module ${k}/${v} not found`);
18
- continue;
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
19
7
  }
20
- if (!module.main) {
21
- console.error(`Missing main entry in module ${k}/${v}`);
22
- continue;
23
- }
24
- module_main_sheet[k] = module.main;
25
- modules[k] = module;
26
- // Fetch the ZIP archive
27
- const zip_achieve = await fetch(zip_achieve_url).then((res) => res.arrayBuffer());
28
- const files = await unzipFile(zip_achieve);
29
- for (const [name, content] of Object.entries(files)) {
30
- if (name.endsWith(KICAD_SHC_FILE_EXT)) {
31
- const fileName = remove_filename_path_prefix(name);
32
- // FIXME : Should auto rename the sheets and remapping them
33
- if (fileName in sheets) {
34
- console.error(`Duplicate sheet name: ${fileName}`);
35
- continue;
36
- }
37
- sheets[fileName] = content;
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
23
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
38
42
  }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var __values = (this && this.__values) || function(o) {
49
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
50
+ if (m) return m.call(o);
51
+ if (o && typeof o.length === "number") return {
52
+ next: function () {
53
+ if (o && i >= o.length) o = void 0;
54
+ return { value: o && o[i++], done: !o };
39
55
  }
56
+ };
57
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
58
+ };
59
+ var __read = (this && this.__read) || function (o, n) {
60
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
61
+ if (!m) return o;
62
+ var i = m.call(o), r, ar = [], e;
63
+ try {
64
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
40
65
  }
41
- return { sheets, module_main_sheet, modules };
66
+ catch (error) { e = { error: error }; }
67
+ finally {
68
+ try {
69
+ if (r && !r.done && (m = i["return"])) m.call(i);
70
+ }
71
+ finally { if (e) throw e.error; }
72
+ }
73
+ return ar;
74
+ };
75
+ import { KICAD_SHC_FILE_EXT, parse_module_name, remove_filename_path_prefix, unzipFile } from '@modular-circuit/utils';
76
+ export function collect_sub_sheets(dependencies, module_resolver) {
77
+ return __awaiter(this, void 0, void 0, function () {
78
+ var sheets, module_main_sheet, modules, _a, _b, _c, k, v, zip_achieve_url, module_1, zip_achieve, files, _d, _e, _f, name, content, fileName, e_1_1;
79
+ var e_1, _g, e_2, _h;
80
+ return __generator(this, function (_j) {
81
+ switch (_j.label) {
82
+ case 0:
83
+ sheets = {};
84
+ module_main_sheet = {};
85
+ modules = {};
86
+ _j.label = 1;
87
+ case 1:
88
+ _j.trys.push([1, 9, 10, 11]);
89
+ _a = __values(Object.entries(dependencies)), _b = _a.next();
90
+ _j.label = 2;
91
+ case 2:
92
+ if (!!_b.done) return [3 /*break*/, 8];
93
+ _c = __read(_b.value, 2), k = _c[0], v = _c[1];
94
+ return [4 /*yield*/, module_resolver.get_module_achieve(__assign(__assign({}, parse_module_name(k)), { version: v }))];
95
+ case 3:
96
+ zip_achieve_url = _j.sent();
97
+ return [4 /*yield*/, module_resolver.get_module_circuit(__assign(__assign({}, parse_module_name(k)), { version: v }))];
98
+ case 4:
99
+ module_1 = _j.sent();
100
+ if (!zip_achieve_url || !module_1) {
101
+ console.error("Module ".concat(k, "/").concat(v, " not found"));
102
+ return [3 /*break*/, 7];
103
+ }
104
+ if (!module_1.main) {
105
+ console.error("Missing main entry in module ".concat(k, "/").concat(v));
106
+ return [3 /*break*/, 7];
107
+ }
108
+ module_main_sheet[k] = module_1.main;
109
+ modules[k] = module_1;
110
+ return [4 /*yield*/, fetch(zip_achieve_url).then(function (res) { return res.arrayBuffer(); })];
111
+ case 5:
112
+ zip_achieve = _j.sent();
113
+ return [4 /*yield*/, unzipFile(zip_achieve)];
114
+ case 6:
115
+ files = _j.sent();
116
+ try {
117
+ for (_d = (e_2 = void 0, __values(Object.entries(files))), _e = _d.next(); !_e.done; _e = _d.next()) {
118
+ _f = __read(_e.value, 2), name = _f[0], content = _f[1];
119
+ if (name.endsWith(KICAD_SHC_FILE_EXT)) {
120
+ fileName = remove_filename_path_prefix(name);
121
+ // FIXME : Should auto rename the sheets and remapping them
122
+ if (fileName in sheets) {
123
+ console.error("Duplicate sheet name: ".concat(fileName));
124
+ continue;
125
+ }
126
+ sheets[fileName] = content;
127
+ }
128
+ }
129
+ }
130
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
131
+ finally {
132
+ try {
133
+ if (_e && !_e.done && (_h = _d.return)) _h.call(_d);
134
+ }
135
+ finally { if (e_2) throw e_2.error; }
136
+ }
137
+ _j.label = 7;
138
+ case 7:
139
+ _b = _a.next();
140
+ return [3 /*break*/, 2];
141
+ case 8: return [3 /*break*/, 11];
142
+ case 9:
143
+ e_1_1 = _j.sent();
144
+ e_1 = { error: e_1_1 };
145
+ return [3 /*break*/, 11];
146
+ case 10:
147
+ try {
148
+ if (_b && !_b.done && (_g = _a.return)) _g.call(_a);
149
+ }
150
+ finally { if (e_1) throw e_1.error; }
151
+ return [7 /*endfinally*/];
152
+ case 11: return [2 /*return*/, { sheets: sheets, module_main_sheet: module_main_sheet, modules: modules }];
153
+ }
154
+ });
155
+ });
42
156
  }