@modular-circuit/transpiler 0.0.58

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 (150) hide show
  1. package/LICENSE +21 -0
  2. package/build/builder/graph_to_kicad/do_convert_graph_to_kicad_project.d.ts +3 -0
  3. package/build/builder/graph_to_kicad/do_convert_graph_to_kicad_project.d.ts.map +1 -0
  4. package/build/builder/graph_to_kicad/do_convert_graph_to_kicad_project.js +113 -0
  5. package/build/builder/graph_to_kicad/index.d.ts +3 -0
  6. package/build/builder/graph_to_kicad/index.d.ts.map +1 -0
  7. package/build/builder/graph_to_kicad/index.js +63 -0
  8. package/build/builder/index.d.ts +2 -0
  9. package/build/builder/index.d.ts.map +1 -0
  10. package/build/builder/index.js +1 -0
  11. package/build/converter/graph_to_netlist/context.d.ts +13 -0
  12. package/build/converter/graph_to_netlist/context.d.ts.map +1 -0
  13. package/build/converter/graph_to_netlist/context.js +0 -0
  14. package/build/converter/graph_to_netlist/graph_converter.d.ts +8 -0
  15. package/build/converter/graph_to_netlist/graph_converter.d.ts.map +1 -0
  16. package/build/converter/graph_to_netlist/graph_converter.js +192 -0
  17. package/build/converter/graph_to_netlist/index.d.ts +3 -0
  18. package/build/converter/graph_to_netlist/index.d.ts.map +1 -0
  19. package/build/converter/graph_to_netlist/index.js +2 -0
  20. package/build/converter/index.d.ts +4 -0
  21. package/build/converter/index.d.ts.map +1 -0
  22. package/build/converter/index.js +3 -0
  23. package/build/converter/kicad_sexpr/eeschema/drawing_sheet/index.d.ts +2 -0
  24. package/build/converter/kicad_sexpr/eeschema/drawing_sheet/index.d.ts.map +1 -0
  25. package/build/converter/kicad_sexpr/eeschema/drawing_sheet/index.js +5 -0
  26. package/build/converter/kicad_sexpr/eeschema/drawing_sheet/sch_default_drawing_sheet.d.ts +2 -0
  27. package/build/converter/kicad_sexpr/eeschema/drawing_sheet/sch_default_drawing_sheet.d.ts.map +1 -0
  28. package/build/converter/kicad_sexpr/eeschema/drawing_sheet/sch_default_drawing_sheet.js +1 -0
  29. package/build/converter/kicad_sexpr/eeschema/index.d.ts +3 -0
  30. package/build/converter/kicad_sexpr/eeschema/index.d.ts.map +1 -0
  31. package/build/converter/kicad_sexpr/eeschema/index.js +2 -0
  32. package/build/converter/kicad_sexpr/eeschema/printer.d.ts +37 -0
  33. package/build/converter/kicad_sexpr/eeschema/printer.d.ts.map +1 -0
  34. package/build/converter/kicad_sexpr/eeschema/printer.js +287 -0
  35. package/build/converter/kicad_sexpr/index.d.ts +3 -0
  36. package/build/converter/kicad_sexpr/index.d.ts.map +1 -0
  37. package/build/converter/kicad_sexpr/index.js +2 -0
  38. package/build/converter/kicad_sexpr/pcb/index.d.ts +2 -0
  39. package/build/converter/kicad_sexpr/pcb/index.d.ts.map +1 -0
  40. package/build/converter/kicad_sexpr/pcb/index.js +1 -0
  41. package/build/converter/link_to_netlist/context.d.ts +12 -0
  42. package/build/converter/link_to_netlist/context.d.ts.map +1 -0
  43. package/build/converter/link_to_netlist/context.js +0 -0
  44. package/build/converter/link_to_netlist/converter.d.ts +13 -0
  45. package/build/converter/link_to_netlist/converter.d.ts.map +1 -0
  46. package/build/converter/link_to_netlist/converter.js +154 -0
  47. package/build/converter/link_to_netlist/index.d.ts +3 -0
  48. package/build/converter/link_to_netlist/index.d.ts.map +1 -0
  49. package/build/converter/link_to_netlist/index.js +2 -0
  50. package/build/converter/link_to_netlist/links/converter_base.d.ts +30 -0
  51. package/build/converter/link_to_netlist/links/converter_base.d.ts.map +1 -0
  52. package/build/converter/link_to_netlist/links/converter_base.js +154 -0
  53. package/build/converter/link_to_netlist/links/converters.d.ts +51 -0
  54. package/build/converter/link_to_netlist/links/converters.d.ts.map +1 -0
  55. package/build/converter/link_to_netlist/links/converters.js +1190 -0
  56. package/build/converter/link_to_netlist/links/index.d.ts +3 -0
  57. package/build/converter/link_to_netlist/links/index.d.ts.map +1 -0
  58. package/build/converter/link_to_netlist/links/index.js +2 -0
  59. package/build/converter/netlist_to_kicad/context.d.ts +10 -0
  60. package/build/converter/netlist_to_kicad/context.d.ts.map +1 -0
  61. package/build/converter/netlist_to_kicad/context.js +0 -0
  62. package/build/converter/netlist_to_kicad/index.d.ts +4 -0
  63. package/build/converter/netlist_to_kicad/index.d.ts.map +1 -0
  64. package/build/converter/netlist_to_kicad/index.js +3 -0
  65. package/build/converter/netlist_to_kicad/layout.d.ts +13 -0
  66. package/build/converter/netlist_to_kicad/layout.d.ts.map +1 -0
  67. package/build/converter/netlist_to_kicad/layout.js +44 -0
  68. package/build/converter/netlist_to_kicad/netlist_converter.d.ts +26 -0
  69. package/build/converter/netlist_to_kicad/netlist_converter.d.ts.map +1 -0
  70. package/build/converter/netlist_to_kicad/netlist_converter.js +237 -0
  71. package/build/index.d.ts +6 -0
  72. package/build/index.d.ts.map +1 -0
  73. package/build/index.js +5 -0
  74. package/build/kicad/constraints/index.d.ts +5 -0
  75. package/build/kicad/constraints/index.d.ts.map +1 -0
  76. package/build/kicad/constraints/index.js +4 -0
  77. package/build/kicad/index.d.ts +1 -0
  78. package/build/kicad/index.d.ts.map +1 -0
  79. package/build/kicad/index.js +1 -0
  80. package/build/kicad/label/index.d.ts +3 -0
  81. package/build/kicad/label/index.d.ts.map +1 -0
  82. package/build/kicad/label/index.js +2 -0
  83. package/build/kicad/label/net_label.d.ts +4 -0
  84. package/build/kicad/label/net_label.d.ts.map +1 -0
  85. package/build/kicad/label/net_label.js +14 -0
  86. package/build/kicad/label/sheet_pin.d.ts +5 -0
  87. package/build/kicad/label/sheet_pin.d.ts.map +1 -0
  88. package/build/kicad/label/sheet_pin.js +25 -0
  89. package/build/kicad/project/index.d.ts +3 -0
  90. package/build/kicad/project/index.d.ts.map +1 -0
  91. package/build/kicad/project/index.js +2 -0
  92. package/build/kicad/project/kicad_prl.d.ts +48 -0
  93. package/build/kicad/project/kicad_prl.d.ts.map +1 -0
  94. package/build/kicad/project/kicad_prl.js +50 -0
  95. package/build/kicad/project/kicad_pro.d.ts +176 -0
  96. package/build/kicad/project/kicad_pro.d.ts.map +1 -0
  97. package/build/kicad/project/kicad_pro.js +224 -0
  98. package/build/kicad/project/kicad_project_achieve.d.ts +237 -0
  99. package/build/kicad/project/kicad_project_achieve.d.ts.map +1 -0
  100. package/build/kicad/project/kicad_project_achieve.js +53 -0
  101. package/build/kicad/project/wildcards_and_files_ext.d.ts +62 -0
  102. package/build/kicad/project/wildcards_and_files_ext.d.ts.map +1 -0
  103. package/build/kicad/project/wildcards_and_files_ext.js +61 -0
  104. package/build/kicad/sheet/index.d.ts +2 -0
  105. package/build/kicad/sheet/index.d.ts.map +1 -0
  106. package/build/kicad/sheet/index.js +1 -0
  107. package/build/kicad/sheet/sheet.d.ts +8 -0
  108. package/build/kicad/sheet/sheet.d.ts.map +1 -0
  109. package/build/kicad/sheet/sheet.js +44 -0
  110. package/build/kicad/symbols/index.d.ts +3 -0
  111. package/build/kicad/symbols/index.d.ts.map +1 -0
  112. package/build/kicad/symbols/index.js +2 -0
  113. package/build/kicad/symbols/lib_symbol/gnd.d.ts +3 -0
  114. package/build/kicad/symbols/lib_symbol/gnd.d.ts.map +1 -0
  115. package/build/kicad/symbols/lib_symbol/gnd.js +121 -0
  116. package/build/kicad/symbols/lib_symbol/index.d.ts +3 -0
  117. package/build/kicad/symbols/lib_symbol/index.d.ts.map +1 -0
  118. package/build/kicad/symbols/lib_symbol/index.js +2 -0
  119. package/build/kicad/symbols/lib_symbol/vcc.d.ts +3 -0
  120. package/build/kicad/symbols/lib_symbol/vcc.d.ts.map +1 -0
  121. package/build/kicad/symbols/lib_symbol/vcc.js +119 -0
  122. package/build/kicad/symbols/sch_symbol/gnd.d.ts +4 -0
  123. package/build/kicad/symbols/sch_symbol/gnd.d.ts.map +1 -0
  124. package/build/kicad/symbols/sch_symbol/gnd.js +66 -0
  125. package/build/kicad/symbols/sch_symbol/index.d.ts +3 -0
  126. package/build/kicad/symbols/sch_symbol/index.d.ts.map +1 -0
  127. package/build/kicad/symbols/sch_symbol/index.js +2 -0
  128. package/build/kicad/symbols/sch_symbol/vcc.d.ts +4 -0
  129. package/build/kicad/symbols/sch_symbol/vcc.d.ts.map +1 -0
  130. package/build/kicad/symbols/sch_symbol/vcc.js +66 -0
  131. package/build/kicad/symbols/symbol_utils.d.ts +2 -0
  132. package/build/kicad/symbols/symbol_utils.d.ts.map +1 -0
  133. package/build/kicad/symbols/symbol_utils.js +1 -0
  134. package/build/tsconfig.build.tsbuildinfo +1 -0
  135. package/build/utils/collect_sub_sheets.d.ts +7 -0
  136. package/build/utils/collect_sub_sheets.d.ts.map +1 -0
  137. package/build/utils/collect_sub_sheets.js +150 -0
  138. package/build/utils/constraints.d.ts +11 -0
  139. package/build/utils/constraints.d.ts.map +1 -0
  140. package/build/utils/constraints.js +17 -0
  141. package/build/utils/filter_null_undefined.d.ts +2 -0
  142. package/build/utils/filter_null_undefined.d.ts.map +1 -0
  143. package/build/utils/filter_null_undefined.js +39 -0
  144. package/build/utils/index.d.ts +5 -0
  145. package/build/utils/index.d.ts.map +1 -0
  146. package/build/utils/index.js +4 -0
  147. package/build/utils/string_formatter.d.ts +14 -0
  148. package/build/utils/string_formatter.d.ts.map +1 -0
  149. package/build/utils/string_formatter.js +35 -0
  150. package/package.json +42 -0
@@ -0,0 +1,3 @@
1
+ export * from './converters';
2
+ export * from './converter_base';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/converter/link_to_netlist/links/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './converters';
2
+ export * from './converter_base';
@@ -0,0 +1,10 @@
1
+ import type { NL_NetList } from "@modular-circuit/electronics-model";
2
+ export interface NetlistProject {
3
+ author: string;
4
+ name: string;
5
+ }
6
+ export interface NetlistToKicadContext {
7
+ project: NetlistProject;
8
+ netlist: NL_NetList;
9
+ }
10
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAErE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,UAAU,CAAC;CACrB"}
File without changes
@@ -0,0 +1,4 @@
1
+ export * from './context';
2
+ export * from './layout';
3
+ export * from './netlist_converter';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './context';
2
+ export * from './layout';
3
+ export * from './netlist_converter';
@@ -0,0 +1,13 @@
1
+ import type { BOX2 } from '@modular-circuit/electronics-model';
2
+ export declare function get_power_pos(pwr_number: number): {
3
+ x: number;
4
+ y: number;
5
+ };
6
+ export declare const BLOCK_PIN_GAP = 4;
7
+ export declare class Layout {
8
+ private width;
9
+ private height;
10
+ private max_height;
11
+ get_block_rect(pin_num: number): BOX2;
12
+ }
13
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAA;AAS9D,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM;;;EAE/C;AAID,eAAO,MAAM,aAAa,IAAI,CAAA;AAM9B,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAgB;IAE7B,OAAO,CAAC,MAAM,CAAgB;IAE9B,OAAO,CAAC,UAAU,CAAI;IAEf,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CA0B7C"}
@@ -0,0 +1,44 @@
1
+ import { PAPER_SIZE } from '../../utils/constraints';
2
+ var POWER_START_Y = 30;
3
+ var POWER_START_X = PAPER_SIZE.A4.height - 30;
4
+ var POWER_Y_STEP = 16;
5
+ export function get_power_pos(pwr_number) {
6
+ return { x: POWER_START_X, y: POWER_START_Y + POWER_Y_STEP * pwr_number };
7
+ }
8
+ var BLOCK_START_Y = 36;
9
+ var BLOCK_START_X = BLOCK_START_Y;
10
+ export var BLOCK_PIN_GAP = 4;
11
+ var BLOCK_MARGIN_TOP = 8;
12
+ var BLOCK_WIDTH = 36;
13
+ var BLOCK_MARGIN_LEFT = 16;
14
+ var BLOCK_MARGIN_RIGHT = BLOCK_MARGIN_LEFT;
15
+ var Layout = /** @class */ (function () {
16
+ function Layout() {
17
+ this.width = BLOCK_START_X;
18
+ this.height = BLOCK_START_Y;
19
+ this.max_height = 0;
20
+ }
21
+ Layout.prototype.get_block_rect = function (pin_num) {
22
+ var block_height = (BLOCK_PIN_GAP * pin_num) / 2 + BLOCK_PIN_GAP * 2;
23
+ var rect = {
24
+ pos: {
25
+ x: this.width,
26
+ y: this.height,
27
+ },
28
+ size: {
29
+ x: BLOCK_WIDTH,
30
+ y: block_height,
31
+ },
32
+ };
33
+ this.max_height = Math.max(this.max_height, block_height);
34
+ this.width += BLOCK_WIDTH + BLOCK_MARGIN_LEFT;
35
+ if (this.width + BLOCK_MARGIN_RIGHT + BLOCK_WIDTH + BLOCK_MARGIN_LEFT > POWER_START_X) {
36
+ this.width = BLOCK_START_X;
37
+ this.height += this.max_height + BLOCK_MARGIN_TOP;
38
+ this.max_height = 0;
39
+ }
40
+ return rect;
41
+ };
42
+ return Layout;
43
+ }());
44
+ export { Layout };
@@ -0,0 +1,26 @@
1
+ import { type SCHEMATIC } from '@modular-circuit/ir';
2
+ import type { NetlistToKicadContext } from './context';
3
+ export declare class NetListConverter {
4
+ private ctx;
5
+ private block_calc;
6
+ private sheet_pwr_count;
7
+ private net_name;
8
+ constructor(ctx: NetlistToKicadContext);
9
+ pin_is_connected(id: string): boolean;
10
+ get_pin_net_name(id: string): string;
11
+ convert_to_kicad(): Record<string, SCHEMATIC>;
12
+ /**
13
+ * Convert a schematic to a kicad schematic
14
+ * @param name The name of the graph ,also the file name of the converted schematic
15
+ * @param schematic For net label , it will be reflected by the net name,
16
+ * no need to handle them before the other types of label are introduced, e.g. global or hierarchical
17
+ * @returns
18
+ */
19
+ private convert_sch;
20
+ private convert_hierarchical_label;
21
+ private convert_pwr_symbol;
22
+ private convert_sheet_symbol;
23
+ private convert_sheet_pin;
24
+ private convert_net_label;
25
+ }
26
+ //# sourceMappingURL=netlist_converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"netlist_converter.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/netlist_converter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyC,KAAK,SAAS,EAAsB,MAAM,qBAAqB,CAAA;AAM/G,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAItD,qBAAa,gBAAgB;IAOR,OAAO,CAAC,GAAG;IAN9B,OAAO,CAAC,UAAU,CAAU;IAE5B,OAAO,CAAC,eAAe,CAAI;IAE3B,OAAO,CAAC,QAAQ,CAA6B;gBAElB,GAAG,EAAE,qBAAqB;IAQrD,gBAAgB,CAAC,EAAE,EAAE,MAAM;IAI3B,gBAAgB,CAAC,EAAE,EAAE,MAAM;IAIpB,gBAAgB;IAYvB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IA4DnB,OAAO,CAAC,0BAA0B;IAKlC,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,oBAAoB;IAqC5B,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,iBAAiB;CAQ1B"}
@@ -0,0 +1,237 @@
1
+ var __values = (this && this.__values) || function(o) {
2
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
+ if (m) return m.call(o);
4
+ if (o && typeof o.length === "number") return {
5
+ next: function () {
6
+ if (o && i >= o.length) o = void 0;
7
+ return { value: o && o[i++], done: !o };
8
+ }
9
+ };
10
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
+ };
12
+ var __read = (this && this.__read) || function (o, n) {
13
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
14
+ if (!m) return o;
15
+ var i = m.call(o), r, ar = [], e;
16
+ try {
17
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
18
+ }
19
+ catch (error) { e = { error: error }; }
20
+ finally {
21
+ try {
22
+ if (r && !r.done && (m = i["return"])) m.call(i);
23
+ }
24
+ finally { if (e) throw e.error; }
25
+ }
26
+ return ar;
27
+ };
28
+ import { PowerShape } from '@modular-circuit/electronics-model';
29
+ import { MODULAR_CIRCUIT_SCH_EXT } from '@modular-circuit/ir';
30
+ import { replaceAll } from '@modular-circuit/utils';
31
+ import { gen_hierarchical_label, gen_net_label, gen_sheet_pin } from '../../kicad/label';
32
+ import { gen_sch_sheet } from '../../kicad/sheet';
33
+ import { gen_lib_gnd, gen_lib_vcc, gen_sch_gnd, gen_sch_vcc } from '../../kicad/symbols';
34
+ import { GENERATOR_NAME, GENERATOR_VERSION, SCH_VERSION } from '../../utils/constraints';
35
+ import { BLOCK_PIN_GAP, Layout, get_power_pos } from './layout';
36
+ var NetListConverter = /** @class */ (function () {
37
+ function NetListConverter(ctx) {
38
+ var e_1, _a, e_2, _b;
39
+ this.ctx = ctx;
40
+ this.sheet_pwr_count = 0;
41
+ this.net_name = {};
42
+ try {
43
+ for (var _c = __values(this.ctx.netlist.nets), _d = _c.next(); !_d.done; _d = _c.next()) {
44
+ var net = _d.value;
45
+ try {
46
+ for (var _e = (e_2 = void 0, __values(net.pins)), _f = _e.next(); !_f.done; _f = _e.next()) {
47
+ var it_1 = _f.value;
48
+ this.net_name[it_1] = net.name;
49
+ }
50
+ }
51
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
52
+ finally {
53
+ try {
54
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
55
+ }
56
+ finally { if (e_2) throw e_2.error; }
57
+ }
58
+ }
59
+ }
60
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
61
+ finally {
62
+ try {
63
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
64
+ }
65
+ finally { if (e_1) throw e_1.error; }
66
+ }
67
+ }
68
+ NetListConverter.prototype.pin_is_connected = function (id) {
69
+ return this.net_name[id] !== undefined;
70
+ };
71
+ NetListConverter.prototype.get_pin_net_name = function (id) {
72
+ return this.net_name[id];
73
+ };
74
+ NetListConverter.prototype.convert_to_kicad = function () {
75
+ var e_3, _a;
76
+ var all_sch = {};
77
+ try {
78
+ for (var _b = __values(Object.entries(this.ctx.netlist.schematics)), _c = _b.next(); !_c.done; _c = _b.next()) {
79
+ var _d = __read(_c.value, 2), k = _d[0], v = _d[1];
80
+ this.sheet_pwr_count = 0;
81
+ this.block_calc = new Layout();
82
+ all_sch[k] = this.convert_sch(k, v);
83
+ }
84
+ }
85
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
86
+ finally {
87
+ try {
88
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
89
+ }
90
+ finally { if (e_3) throw e_3.error; }
91
+ }
92
+ return all_sch;
93
+ };
94
+ /**
95
+ * Convert a schematic to a kicad schematic
96
+ * @param name The name of the graph ,also the file name of the converted schematic
97
+ * @param schematic For net label , it will be reflected by the net name,
98
+ * no need to handle them before the other types of label are introduced, e.g. global or hierarchical
99
+ * @returns
100
+ */
101
+ NetListConverter.prototype.convert_sch = function (name, schematic) {
102
+ var e_4, _a, e_5, _b, e_6, _c;
103
+ var _d, _e;
104
+ var powers = new Set();
105
+ var sch = {
106
+ version: SCH_VERSION,
107
+ generator: GENERATOR_NAME,
108
+ generator_version: GENERATOR_VERSION,
109
+ paper: {
110
+ size: 'A4',
111
+ },
112
+ title_block: {
113
+ title: name.replace(".".concat(MODULAR_CIRCUIT_SCH_EXT), ''),
114
+ date: replaceAll(new Date().toISOString().slice(0, 10), '-', '/'),
115
+ rev: '1.0',
116
+ comment: {
117
+ 1: 'https://www.eda.cn',
118
+ 2: this.ctx.project.author,
119
+ 3: this.ctx.project.name,
120
+ },
121
+ },
122
+ lib_symbols: {
123
+ symbols: [],
124
+ },
125
+ uuid: schematic.uuid,
126
+ symbols: [],
127
+ labels: [],
128
+ sheets: [],
129
+ };
130
+ try {
131
+ for (var _f = __values(schematic.powers), _g = _f.next(); !_g.done; _g = _f.next()) {
132
+ var it_2 = _g.value;
133
+ if (!powers.has(it_2.value)) {
134
+ switch (it_2.shape) {
135
+ case PowerShape.VCC:
136
+ (_d = sch.lib_symbols) === null || _d === void 0 ? void 0 : _d.symbols.push(gen_lib_vcc(it_2.value));
137
+ break;
138
+ case PowerShape.GND:
139
+ (_e = sch.lib_symbols) === null || _e === void 0 ? void 0 : _e.symbols.push(gen_lib_gnd(it_2.value));
140
+ break;
141
+ }
142
+ powers.add(it_2.value);
143
+ }
144
+ this.convert_pwr_symbol(it_2, get_power_pos(this.sheet_pwr_count++), sch);
145
+ }
146
+ }
147
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
148
+ finally {
149
+ try {
150
+ if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
151
+ }
152
+ finally { if (e_4) throw e_4.error; }
153
+ }
154
+ var sheet_names_count = new Map();
155
+ try {
156
+ for (var _h = __values(schematic.sheet_symbols.sort(function (a, b) {
157
+ return b.pins.length - a.pins.length;
158
+ })), _j = _h.next(); !_j.done; _j = _h.next()) {
159
+ var it_3 = _j.value;
160
+ this.convert_sheet_symbol(it_3, this.block_calc.get_block_rect(it_3.pins.length), sch, sheet_names_count);
161
+ }
162
+ }
163
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
164
+ finally {
165
+ try {
166
+ if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
167
+ }
168
+ finally { if (e_5) throw e_5.error; }
169
+ }
170
+ try {
171
+ // Finally the hierarchical labels
172
+ for (var _k = __values(schematic.hiera_labels), _l = _k.next(); !_l.done; _l = _k.next()) {
173
+ var it_4 = _l.value;
174
+ this.convert_hierarchical_label(it_4, sch);
175
+ }
176
+ }
177
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
178
+ finally {
179
+ try {
180
+ if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
181
+ }
182
+ finally { if (e_6) throw e_6.error; }
183
+ }
184
+ return sch;
185
+ };
186
+ NetListConverter.prototype.convert_hierarchical_label = function (pin, sch) {
187
+ var _a;
188
+ var pin_pos = this.block_calc.get_block_rect(1).pos;
189
+ (_a = sch.labels) === null || _a === void 0 ? void 0 : _a.push(gen_hierarchical_label(pin.name, pin_pos, { horizontal: 'left', vertical: 'bottom' }, 0, pin.shape));
190
+ };
191
+ NetListConverter.prototype.convert_pwr_symbol = function (pwr, at, sch) {
192
+ // NOTE : The power uuid is used as the uuid of its pin ,cause all power symbols have only one pin
193
+ var pin_id = pwr.uuid;
194
+ var sch_pwr_symbol = pwr.shape === PowerShape.VCC
195
+ ? gen_sch_vcc(pwr.value, this.sheet_pwr_count, pin_id, at)
196
+ : gen_sch_gnd(pwr.value, this.sheet_pwr_count, pin_id, at);
197
+ sch.symbols.push(sch_pwr_symbol);
198
+ this.convert_net_label(pwr.value, at, sch);
199
+ };
200
+ NetListConverter.prototype.convert_sheet_symbol = function (sheet_sym, rect, sch, sheet_names_count) {
201
+ var port_count = sheet_sym.pins.length;
202
+ var pins = [];
203
+ for (var i = 0; i < port_count; i++) {
204
+ var is_left = i < port_count / 2;
205
+ var x = is_left ? rect.pos.x : rect.pos.x + rect.size.x;
206
+ var y = rect.pos.y + BLOCK_PIN_GAP * ((i < port_count / 2 ? i : i - port_count / 2) + 1);
207
+ var justify = is_left ? 'left' : 'right';
208
+ var rotation = is_left ? 180 : 0;
209
+ pins.push(this.convert_sheet_pin(sheet_sym.pins[i], { x: x, y: y }, sch, justify, rotation));
210
+ }
211
+ var sheet_name = sheet_sym.sheet_name;
212
+ if (sheet_names_count.has(sheet_name)) {
213
+ var count = sheet_names_count.get(sheet_name);
214
+ sheet_name += "_".concat(count);
215
+ sheet_names_count.set(sheet_name, count + 1);
216
+ }
217
+ else {
218
+ sheet_names_count.set(sheet_name, 1);
219
+ }
220
+ sch.sheets.push(gen_sch_sheet(rect, pins, {
221
+ Sheetfile: sheet_sym.sheet_file_name,
222
+ Sheetname: sheet_name,
223
+ }));
224
+ };
225
+ NetListConverter.prototype.convert_sheet_pin = function (pin, pin_pos, sch, horizontal, rotation) {
226
+ if (this.pin_is_connected(pin.uuid)) {
227
+ this.convert_net_label(this.get_pin_net_name(pin.uuid), pin_pos, sch, horizontal === 'left' ? 'right' : 'left');
228
+ }
229
+ return gen_sheet_pin(pin.name, pin_pos, { horizontal: horizontal, vertical: 'bottom' }, rotation, pin.shape);
230
+ };
231
+ NetListConverter.prototype.convert_net_label = function (net_name, pin_pos, sch, horizontal) {
232
+ if (horizontal === void 0) { horizontal = 'right'; }
233
+ sch.labels.push(gen_net_label(net_name, pin_pos, { horizontal: horizontal, vertical: 'bottom' }));
234
+ };
235
+ return NetListConverter;
236
+ }());
237
+ export { NetListConverter };
@@ -0,0 +1,6 @@
1
+ export * from './converter';
2
+ export * from './builder';
3
+ export * from './kicad/project';
4
+ export * from './utils';
5
+ export * from './kicad/symbols';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA"}
package/build/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './converter';
2
+ export * from './builder';
3
+ export * from './kicad/project';
4
+ export * from './utils';
5
+ export * from './kicad/symbols';
@@ -0,0 +1,5 @@
1
+ export declare const DEFAULT_FONT_SIZE: {
2
+ x: number;
3
+ y: number;
4
+ };
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/kicad/constraints/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB;;;CAG7B,CAAA"}
@@ -0,0 +1,4 @@
1
+ export var DEFAULT_FONT_SIZE = {
2
+ x: 1.27,
3
+ y: 1.27,
4
+ };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/kicad/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,3 @@
1
+ export * from './net_label';
2
+ export * from './sheet_pin';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/kicad/label/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './net_label';
2
+ export * from './sheet_pin';
@@ -0,0 +1,4 @@
1
+ import type { VECTOR2 } from '@modular-circuit/electronics-model';
2
+ import type { Justify, NetLabel } from '@modular-circuit/ir';
3
+ export declare const gen_net_label: (name: string, at: VECTOR2, justify: Justify) => NetLabel;
4
+ //# sourceMappingURL=net_label.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"net_label.d.ts","sourceRoot":"","sources":["../../../src/kicad/label/net_label.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAA;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAI5D,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,EAAE,IAAI,OAAO,EAAE,SAAS,OAAO,KAAG,QAW1E,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { gen_uuid } from '@modular-circuit/utils';
2
+ import { DEFAULT_FONT_SIZE } from '../constraints';
3
+ export var gen_net_label = function (name, at, justify) { return ({
4
+ label_type: 'label',
5
+ text: name,
6
+ fields: [],
7
+ fields_autoplaced: true,
8
+ at: { position: at, rotation: 0 },
9
+ effects: {
10
+ font: { size: DEFAULT_FONT_SIZE },
11
+ justify: justify,
12
+ },
13
+ uuid: gen_uuid(),
14
+ }); };
@@ -0,0 +1,5 @@
1
+ import type { LabelShapes, VECTOR2 } from '@modular-circuit/electronics-model';
2
+ import type { Justify, SCH_SHEET_PIN } from '@modular-circuit/ir';
3
+ export declare const gen_sheet_pin: (text: string, at: VECTOR2, justify: Justify, rotation: number, shape: LabelShapes) => SCH_SHEET_PIN;
4
+ export declare const gen_hierarchical_label: (text: string, at: VECTOR2, justify: Justify, rotation: number, shape: LabelShapes) => SCH_SHEET_PIN;
5
+ //# sourceMappingURL=sheet_pin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sheet_pin.d.ts","sourceRoot":"","sources":["../../../src/kicad/label/sheet_pin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAA;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAqBjE,eAAO,MAAM,aAAa,GACxB,MAAM,MAAM,EACZ,IAAI,OAAO,EACX,SAAS,OAAO,EAChB,UAAU,MAAM,EAChB,OAAO,WAAW,KACjB,aAGD,CAAA;AAEF,eAAO,MAAM,sBAAsB,SAV3B,MAAM,MACR,OAAO,WACF,OAAO,YACN,MAAM,SACT,WAAW,KACjB,aAKgD,CAAA"}
@@ -0,0 +1,25 @@
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
+ };
12
+ import { gen_uuid } from '@modular-circuit/utils';
13
+ import { DEFAULT_FONT_SIZE } from '../constraints';
14
+ var gen_base_hierarchical_label = function (text, at, justify, rotation, shape) { return ({
15
+ shape: shape,
16
+ effects: {
17
+ font: { size: DEFAULT_FONT_SIZE },
18
+ justify: justify,
19
+ },
20
+ text: text,
21
+ at: { position: at, rotation: rotation },
22
+ uuid: gen_uuid(),
23
+ }); };
24
+ export var gen_sheet_pin = function (text, at, justify, rotation, shape) { return (__assign({ label_type: 'hierarchical_label' }, gen_base_hierarchical_label(text, at, justify, rotation, shape))); };
25
+ export var gen_hierarchical_label = gen_sheet_pin;
@@ -0,0 +1,3 @@
1
+ export * from './wildcards_and_files_ext';
2
+ export * from './kicad_project_achieve';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/kicad/project/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,yBAAyB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './wildcards_and_files_ext';
2
+ export * from './kicad_project_achieve';
@@ -0,0 +1,48 @@
1
+ export declare const kicad_prl: (prj_name: string) => {
2
+ board: {
3
+ active_layer: number;
4
+ active_layer_preset: string;
5
+ auto_track_width: boolean;
6
+ hidden_netclasses: never[];
7
+ hidden_nets: never[];
8
+ high_contrast_mode: number;
9
+ net_color_mode: number;
10
+ opacity: {
11
+ images: number;
12
+ pads: number;
13
+ tracks: number;
14
+ vias: number;
15
+ zones: number;
16
+ };
17
+ selection_filter: {
18
+ dimensions: boolean;
19
+ footprints: boolean;
20
+ graphics: boolean;
21
+ keepouts: boolean;
22
+ lockedItems: boolean;
23
+ otherItems: boolean;
24
+ pads: boolean;
25
+ text: boolean;
26
+ tracks: boolean;
27
+ vias: boolean;
28
+ zones: boolean;
29
+ };
30
+ visible_items: number[];
31
+ visible_layers: string;
32
+ zone_display_mode: number;
33
+ };
34
+ git: {
35
+ repo_password: string;
36
+ repo_type: string;
37
+ repo_username: string;
38
+ ssh_key: string;
39
+ };
40
+ meta: {
41
+ filename: string;
42
+ version: number;
43
+ };
44
+ project: {
45
+ files: never[];
46
+ };
47
+ };
48
+ //# sourceMappingURL=kicad_prl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kicad_prl.d.ts","sourceRoot":"","sources":["../../../src/kicad/project/kicad_prl.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GAAI,UAAU,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDxC,CAAA"}
@@ -0,0 +1,50 @@
1
+ export var kicad_prl = function (prj_name) { return ({
2
+ board: {
3
+ active_layer: 0,
4
+ active_layer_preset: '',
5
+ auto_track_width: true,
6
+ hidden_netclasses: [],
7
+ hidden_nets: [],
8
+ high_contrast_mode: 0,
9
+ net_color_mode: 1,
10
+ opacity: {
11
+ images: 0.6,
12
+ pads: 1.0,
13
+ tracks: 1.0,
14
+ vias: 1.0,
15
+ zones: 0.6,
16
+ },
17
+ selection_filter: {
18
+ dimensions: true,
19
+ footprints: true,
20
+ graphics: true,
21
+ keepouts: true,
22
+ lockedItems: false,
23
+ otherItems: true,
24
+ pads: true,
25
+ text: true,
26
+ tracks: true,
27
+ vias: true,
28
+ zones: true,
29
+ },
30
+ visible_items: [
31
+ 0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 33,
32
+ 34, 35, 36, 39, 40,
33
+ ],
34
+ visible_layers: 'fffffff_ffffffff',
35
+ zone_display_mode: 0,
36
+ },
37
+ git: {
38
+ repo_password: '',
39
+ repo_type: '',
40
+ repo_username: '',
41
+ ssh_key: '',
42
+ },
43
+ meta: {
44
+ filename: "".concat(prj_name, ".kicad_prl"),
45
+ version: 3,
46
+ },
47
+ project: {
48
+ files: [],
49
+ },
50
+ }); };