@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,287 @@
1
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
2
+ var useValue = arguments.length > 2;
3
+ for (var i = 0; i < initializers.length; i++) {
4
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
5
+ }
6
+ return useValue ? value : void 0;
7
+ };
8
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
9
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
10
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
11
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
12
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
13
+ var _, done = false;
14
+ for (var i = decorators.length - 1; i >= 0; i--) {
15
+ var context = {};
16
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
17
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
18
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
19
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
20
+ if (kind === "accessor") {
21
+ if (result === void 0) continue;
22
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
23
+ if (_ = accept(result.get)) descriptor.get = _;
24
+ if (_ = accept(result.set)) descriptor.set = _;
25
+ if (_ = accept(result.init)) initializers.unshift(_);
26
+ }
27
+ else if (_ = accept(result)) {
28
+ if (kind === "field") initializers.unshift(_);
29
+ else descriptor[key] = _;
30
+ }
31
+ }
32
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
33
+ done = true;
34
+ };
35
+ var __values = (this && this.__values) || function(o) {
36
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
37
+ if (m) return m.call(o);
38
+ if (o && typeof o.length === "number") return {
39
+ next: function () {
40
+ if (o && i >= o.length) o = void 0;
41
+ return { value: o && o[i++], done: !o };
42
+ }
43
+ };
44
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
45
+ };
46
+ var __read = (this && this.__read) || function (o, n) {
47
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
48
+ if (!m) return o;
49
+ var i = m.call(o), r, ar = [], e;
50
+ try {
51
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
52
+ }
53
+ catch (error) { e = { error: error }; }
54
+ finally {
55
+ try {
56
+ if (r && !r.done && (m = i["return"])) m.call(i);
57
+ }
58
+ finally { if (e) throw e.error; }
59
+ }
60
+ return ar;
61
+ };
62
+ import { READABLE_ELECTRICAL_PINTYPE } from '@modular-circuit/electronics-model';
63
+ import { SHAPE_T, } from '@modular-circuit/ir';
64
+ import { gen_uuid } from '@modular-circuit/utils';
65
+ import { GENERATOR_NAME, GENERATOR_VERSION, PAPER, SCH_VERSION, filterNullOrUndefined } from '../../../utils';
66
+ var SCOPE_START = '\n\t';
67
+ var SPACE = ' ';
68
+ var SCOPE_END = '\n';
69
+ var IGNORE_BOOLEANS = new Set(['power']);
70
+ var SCHEMATIC_PRINTER = function () {
71
+ var _a;
72
+ var _instanceExtraInitializers = [];
73
+ var _power_decorators;
74
+ var _pin_display_opt_decorators;
75
+ var _lib_children_decorators;
76
+ var _drawings_decorators;
77
+ var _pin_defs_decorators;
78
+ var _unit_decorators;
79
+ var _lib_id_decorators;
80
+ var _justify_decorators;
81
+ var _fields_decorators;
82
+ var _fill_decorators;
83
+ var _stroke_decorators;
84
+ var _color_decorators;
85
+ return _a = /** @class */ (function () {
86
+ function SCHEMATIC_PRINTER() {
87
+ __runInitializers(this, _instanceExtraInitializers);
88
+ }
89
+ SCHEMATIC_PRINTER.prototype.schematic = function (sch) {
90
+ var _this = this;
91
+ var lib_symbols = (function () {
92
+ var _b, _c;
93
+ if (!((_b = sch.lib_symbols) === null || _b === void 0 ? void 0 : _b.symbols.length))
94
+ return '';
95
+ return "".concat(SCOPE_START, "(lib_symbols ").concat((_c = sch.lib_symbols) === null || _c === void 0 ? void 0 : _c.symbols.map(function (it) { return _this.lib_symbol(it); }).join("".concat(SCOPE_END)), "\t)");
96
+ })();
97
+ var labels = (function () {
98
+ var _b;
99
+ if (!((_b = sch.labels) === null || _b === void 0 ? void 0 : _b.length))
100
+ return '';
101
+ return "".concat(SCOPE_START).concat(sch.labels.map(function (it) { return _this.label(it); }).join("".concat(SCOPE_END)));
102
+ })();
103
+ var sch_sheets = (function () {
104
+ var _b;
105
+ if (!((_b = sch.sheets) === null || _b === void 0 ? void 0 : _b.length))
106
+ return '';
107
+ return "".concat(SCOPE_START).concat(sch.sheets.map(function (it) { return _this.sch_sheet(it); }).join("".concat(SCOPE_END)), "\t");
108
+ })();
109
+ var sch_symbols = (function () {
110
+ var _b;
111
+ if (!((_b = sch.symbols) === null || _b === void 0 ? void 0 : _b.length))
112
+ return '';
113
+ return "".concat(SCOPE_START).concat(sch.symbols.map(function (it) { return _this.sch_symbol(it); }).join("".concat(SCOPE_END)), "\t");
114
+ })();
115
+ return "\n(kicad_sch\n (version ".concat(SCH_VERSION, ")\n (generator \"").concat(GENERATOR_NAME, "\")\n (generator_version \"").concat(GENERATOR_VERSION, "\")\n (uuid \"").concat(gen_uuid(), "\")\n (paper \"").concat(PAPER, "\")").concat(lib_symbols).concat(labels).concat(sch_symbols).concat(sch_sheets, "\n)\n ");
116
+ };
117
+ SCHEMATIC_PRINTER.prototype.power = function (power) {
118
+ return power ? '(power)' : '';
119
+ };
120
+ SCHEMATIC_PRINTER.prototype.pin_display_opt = function (opt) {
121
+ if (!opt)
122
+ return;
123
+ var offset = function (off) { return (off ? "(offset ".concat(off, ")") : ''); };
124
+ var hide = function (h) { return (h ? 'hide' : ''); };
125
+ var pin_numbers = "".concat(opt.pin_numbers ? "(pin_numbers ".concat(offset(opt.pin_numbers.offset), " ").concat(hide(opt.pin_numbers.hide), ")") : '');
126
+ var pin_names = "".concat(opt.pin_names ? "(pin_names ".concat(offset(opt.pin_names.offset), " ").concat(hide(opt.pin_names.hide), ")") : '');
127
+ return "".concat(pin_numbers, "\n ").concat(pin_names, "\n ");
128
+ };
129
+ SCHEMATIC_PRINTER.prototype.lib_symbol = function (lib_symbol) {
130
+ return "\n (symbol \"".concat(lib_symbol.name, "\" ").concat(this.power(lib_symbol.power), "\n ").concat(this.pin_display_opt(lib_symbol), "\n ").concat(this.booleans(lib_symbol), "\n ").concat(this.fields(lib_symbol.properties), "\n ").concat(this.pin_defs(lib_symbol.pins), "\n ").concat(this.drawings(lib_symbol.drawings), "\n ").concat(this.lib_children(lib_symbol.children), "\n)\n ");
131
+ };
132
+ SCHEMATIC_PRINTER.prototype.lib_children = function (libs) {
133
+ var _this = this;
134
+ if (!libs)
135
+ return '';
136
+ return libs.map(function (i) { return _this.lib_symbol(i); }).join(SCOPE_END);
137
+ };
138
+ SCHEMATIC_PRINTER.prototype.pts = function (points) {
139
+ return "(pts ".concat(points.map(function (i) { return "(xy ".concat(i.x, " ").concat(i.y, " )"); }).join(SPACE), ")");
140
+ };
141
+ SCHEMATIC_PRINTER.prototype.drawings = function (draws) {
142
+ var _this = this;
143
+ if (!draws)
144
+ return;
145
+ return draws.map(function (i) { return _this.drawing(i); }).join(SCOPE_END);
146
+ };
147
+ SCHEMATIC_PRINTER.prototype.drawing = function (draw) {
148
+ if (!('shape' in draw))
149
+ throw new Error("Unhandled drawing ".concat(draw));
150
+ switch (draw.shape) {
151
+ case SHAPE_T.POLY:
152
+ return "(polyline\n ".concat(this.pts(draw.pts), "\n ").concat(this.stroke(draw.stroke), "\n ").concat(this.fill(draw.fill), "\n\t\t\t\t)");
153
+ }
154
+ throw new Error("Unhandled drawing ".concat(draw));
155
+ };
156
+ SCHEMATIC_PRINTER.prototype.pin_defs = function (defs) {
157
+ var _this = this;
158
+ if (!defs)
159
+ return;
160
+ return defs.map(function (it) { return _this.pin_def(it); }).join(SCOPE_END);
161
+ };
162
+ SCHEMATIC_PRINTER.prototype.pin_def = function (def) {
163
+ return "(pin ".concat(READABLE_ELECTRICAL_PINTYPE[def.type], " ").concat(def.shape, "\n\t\t\t\t\t").concat(this.at(def.at), "\n\t\t\t\t\t(length ").concat(def.length, ")\n\t\t\t\t\t(name \"").concat(def.name.text, "\"\n ").concat(this.effects(def.name.effects), "\n\t\t\t\t\t)\n\t\t\t\t\t(number \"").concat(def.number.text, "\"\n ").concat(this.effects(def.number.effects), "\n\t\t\t\t\t)\n\t\t\t\t)");
164
+ };
165
+ SCHEMATIC_PRINTER.prototype.label = function (label) {
166
+ return "\t(".concat(label.label_type, " \"").concat(label.text, "\"\n\t\t").concat(this.at(label.at), "\n ").concat(this.fields_autoplaced(), "\n ").concat(this.effects(label.effects), "\n\t\t").concat(this.uuid(label.uuid), "\n\t)");
167
+ };
168
+ SCHEMATIC_PRINTER.prototype.unit = function (c) {
169
+ return "(unit ".concat(c, ")");
170
+ };
171
+ SCHEMATIC_PRINTER.prototype.sch_symbol = function (sch_symbol) {
172
+ var _this = this;
173
+ return "(symbol\n\t\t".concat(this.lib_id(sch_symbol.lib_id), "\n\t\t").concat(this.at(sch_symbol.at), "\n\t\t").concat(this.unit(sch_symbol.unit), "\n ").concat(this.booleans(sch_symbol), "\n\t\t").concat(this.fields(sch_symbol.properties), "\n ").concat(sch_symbol.pins.map(function (pin) { return _this.sch_symbol_pin(pin); }).join(SCOPE_START), "\n\t)");
174
+ };
175
+ SCHEMATIC_PRINTER.prototype.lib_id = function (id) {
176
+ if (!id)
177
+ return;
178
+ return "(lib_id \"".concat(id, "\")");
179
+ };
180
+ SCHEMATIC_PRINTER.prototype.sch_symbol_pin = function (pin) {
181
+ return "(pin \"".concat(pin.number, "\" ").concat(this.uuid(pin.uuid), ")");
182
+ };
183
+ SCHEMATIC_PRINTER.prototype.sch_sheet = function (sheet) {
184
+ var _this = this;
185
+ return "(sheet \n ".concat(this.at(sheet.at), "\n ").concat(this.size(sheet.size), "\n ").concat(this.fields_autoplaced(), "\n ").concat(this.stroke(sheet.stroke), "\n ").concat(this.fill(sheet.fill), "\n ").concat(this.uuid(sheet.uuid), "\n ").concat(this.fields(sheet.fields), "\n ").concat(sheet.pins.map(function (sheet_pin) { return _this.sch_sheet_pin(sheet_pin); }).join(SCOPE_START), "\n )");
186
+ };
187
+ SCHEMATIC_PRINTER.prototype.sch_sheet_pin = function (sheet_pin) {
188
+ return "(pin \"".concat(sheet_pin.text, "\" ").concat(sheet_pin.shape, "\n\t\t\t").concat(this.at(sheet_pin.at), "\n ").concat(this.effects(sheet_pin.effects), "\n\t\t\t").concat(this.uuid(sheet_pin.uuid), "\n\t\t)");
189
+ };
190
+ SCHEMATIC_PRINTER.prototype.at = function (pos) {
191
+ return "(at ".concat(pos.position.x, " ").concat(pos.position.y, " ").concat(pos.rotation === undefined ? '' : pos.rotation, ")");
192
+ };
193
+ SCHEMATIC_PRINTER.prototype.uuid = function (id) {
194
+ return "(uuid \"".concat(id, "\")");
195
+ };
196
+ SCHEMATIC_PRINTER.prototype.effects = function (e) {
197
+ return "(effects\n (font\n (size ".concat(e.font.size.x, " ").concat(e.font.size.y, ")\n )").concat(this.justify(e.justify)).concat(e.hide ? '(hide yes)' : '', "\n )");
198
+ };
199
+ SCHEMATIC_PRINTER.prototype.justify = function (justify) {
200
+ if (!justify)
201
+ return;
202
+ return "(justify ".concat(justify.horizontal, " ").concat(justify.vertical, ")");
203
+ };
204
+ SCHEMATIC_PRINTER.prototype.booleans = function (it) {
205
+ var e_1, _b;
206
+ if (typeof it !== 'object' || !it)
207
+ return;
208
+ var res = [];
209
+ try {
210
+ for (var _c = __values(Object.entries(it)), _d = _c.next(); !_d.done; _d = _c.next()) {
211
+ var _e = __read(_d.value, 2), k = _e[0], v = _e[1];
212
+ if (typeof v === 'boolean' && !IGNORE_BOOLEANS.has(k))
213
+ res.push("( ".concat(k, " ").concat(v ? 'yes' : 'no', " )"));
214
+ }
215
+ }
216
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
217
+ finally {
218
+ try {
219
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
220
+ }
221
+ finally { if (e_1) throw e_1.error; }
222
+ }
223
+ return res.join(SCOPE_START);
224
+ };
225
+ SCHEMATIC_PRINTER.prototype.fields = function (fields) {
226
+ var _this = this;
227
+ if (!fields)
228
+ return;
229
+ return fields.map(function (f) { return _this.field(f); }).join(SCOPE_START);
230
+ };
231
+ SCHEMATIC_PRINTER.prototype.field = function (field) {
232
+ return "(property \"".concat(field.name, "\" \"").concat(field.text, "\"\n\t\t\t").concat(this.at(field.at), "\n ").concat(this.effects(field.effects), "\n\t\t)");
233
+ };
234
+ SCHEMATIC_PRINTER.prototype.fill = function (f) {
235
+ if (!f)
236
+ return;
237
+ return "(fill".concat(f.type ? " (type ".concat(f.type, ")") : '', " ").concat(this.color(f.color), ")");
238
+ };
239
+ SCHEMATIC_PRINTER.prototype.size = function (s) {
240
+ return "(size ".concat(s.x, " ").concat(s.y, ")");
241
+ };
242
+ SCHEMATIC_PRINTER.prototype.fields_autoplaced = function () {
243
+ return '(fields_autoplaced yes)';
244
+ };
245
+ SCHEMATIC_PRINTER.prototype.stroke = function (s) {
246
+ if (!s)
247
+ return;
248
+ return "(stroke\n\t\t\t(width ".concat(s.width, ")\n\t\t\t(type ").concat(s.type, ")\n ").concat(this.color(s.color), "\n\t\t)");
249
+ };
250
+ SCHEMATIC_PRINTER.prototype.color = function (c) {
251
+ if (!c)
252
+ return;
253
+ return "(color ".concat(c.r, " ").concat(c.g, " ").concat(c.b, " ").concat(c.a, ")");
254
+ };
255
+ return SCHEMATIC_PRINTER;
256
+ }()),
257
+ (function () {
258
+ var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
259
+ _power_decorators = [filterNullOrUndefined];
260
+ _pin_display_opt_decorators = [filterNullOrUndefined];
261
+ _lib_children_decorators = [filterNullOrUndefined];
262
+ _drawings_decorators = [filterNullOrUndefined];
263
+ _pin_defs_decorators = [filterNullOrUndefined];
264
+ _unit_decorators = [filterNullOrUndefined];
265
+ _lib_id_decorators = [filterNullOrUndefined];
266
+ _justify_decorators = [filterNullOrUndefined];
267
+ _fields_decorators = [filterNullOrUndefined];
268
+ _fill_decorators = [filterNullOrUndefined];
269
+ _stroke_decorators = [filterNullOrUndefined];
270
+ _color_decorators = [filterNullOrUndefined];
271
+ __esDecorate(_a, null, _power_decorators, { kind: "method", name: "power", static: false, private: false, access: { has: function (obj) { return "power" in obj; }, get: function (obj) { return obj.power; } }, metadata: _metadata }, null, _instanceExtraInitializers);
272
+ __esDecorate(_a, null, _pin_display_opt_decorators, { kind: "method", name: "pin_display_opt", static: false, private: false, access: { has: function (obj) { return "pin_display_opt" in obj; }, get: function (obj) { return obj.pin_display_opt; } }, metadata: _metadata }, null, _instanceExtraInitializers);
273
+ __esDecorate(_a, null, _lib_children_decorators, { kind: "method", name: "lib_children", static: false, private: false, access: { has: function (obj) { return "lib_children" in obj; }, get: function (obj) { return obj.lib_children; } }, metadata: _metadata }, null, _instanceExtraInitializers);
274
+ __esDecorate(_a, null, _drawings_decorators, { kind: "method", name: "drawings", static: false, private: false, access: { has: function (obj) { return "drawings" in obj; }, get: function (obj) { return obj.drawings; } }, metadata: _metadata }, null, _instanceExtraInitializers);
275
+ __esDecorate(_a, null, _pin_defs_decorators, { kind: "method", name: "pin_defs", static: false, private: false, access: { has: function (obj) { return "pin_defs" in obj; }, get: function (obj) { return obj.pin_defs; } }, metadata: _metadata }, null, _instanceExtraInitializers);
276
+ __esDecorate(_a, null, _unit_decorators, { kind: "method", name: "unit", static: false, private: false, access: { has: function (obj) { return "unit" in obj; }, get: function (obj) { return obj.unit; } }, metadata: _metadata }, null, _instanceExtraInitializers);
277
+ __esDecorate(_a, null, _lib_id_decorators, { kind: "method", name: "lib_id", static: false, private: false, access: { has: function (obj) { return "lib_id" in obj; }, get: function (obj) { return obj.lib_id; } }, metadata: _metadata }, null, _instanceExtraInitializers);
278
+ __esDecorate(_a, null, _justify_decorators, { kind: "method", name: "justify", static: false, private: false, access: { has: function (obj) { return "justify" in obj; }, get: function (obj) { return obj.justify; } }, metadata: _metadata }, null, _instanceExtraInitializers);
279
+ __esDecorate(_a, null, _fields_decorators, { kind: "method", name: "fields", static: false, private: false, access: { has: function (obj) { return "fields" in obj; }, get: function (obj) { return obj.fields; } }, metadata: _metadata }, null, _instanceExtraInitializers);
280
+ __esDecorate(_a, null, _fill_decorators, { kind: "method", name: "fill", static: false, private: false, access: { has: function (obj) { return "fill" in obj; }, get: function (obj) { return obj.fill; } }, metadata: _metadata }, null, _instanceExtraInitializers);
281
+ __esDecorate(_a, null, _stroke_decorators, { kind: "method", name: "stroke", static: false, private: false, access: { has: function (obj) { return "stroke" in obj; }, get: function (obj) { return obj.stroke; } }, metadata: _metadata }, null, _instanceExtraInitializers);
282
+ __esDecorate(_a, null, _color_decorators, { kind: "method", name: "color", static: false, private: false, access: { has: function (obj) { return "color" in obj; }, get: function (obj) { return obj.color; } }, metadata: _metadata }, null, _instanceExtraInitializers);
283
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
284
+ })(),
285
+ _a;
286
+ }();
287
+ export { SCHEMATIC_PRINTER };
@@ -0,0 +1,3 @@
1
+ export * from './eeschema';
2
+ export * from './pcb';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/converter/kicad_sexpr/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,OAAO,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './eeschema';
2
+ export * from './pcb';
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/converter/kicad_sexpr/pcb/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { NL_NetList, PortLike } from '@modular-circuit/electronics-model';
2
+ export interface LinkConverterContext {
3
+ pin_map: {
4
+ [port_uuid: string]: {
5
+ [label_name: string]: string;
6
+ };
7
+ };
8
+ nl_netlist: NL_NetList;
9
+ port_map: Map<PortLike, string>;
10
+ net_names_count: Map<string, number>;
11
+ }
12
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/converter/link_to_netlist/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAA;AAE9E,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE;QACP,CAAC,SAAS,EAAE,MAAM,GAAG;YACnB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAA;SAC7B,CAAA;KACF,CAAA;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC/B,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACrC"}
File without changes
@@ -0,0 +1,13 @@
1
+ import { type ConnectionSubgraph } from '@modular-circuit/electronics-model';
2
+ import type { CG_Visitor } from '@modular-circuit/perc/build/erc/connect_graph_visitor';
3
+ import type { LinkConverterContext } from './context';
4
+ export declare class LINK_CONVERTER implements CG_Visitor {
5
+ private readonly ctx;
6
+ constructor(ctx: LinkConverterContext);
7
+ private link_map;
8
+ private port_id;
9
+ private port_is_composite_port;
10
+ private do_convert;
11
+ visit_cc(cc: ConnectionSubgraph): void;
12
+ }
13
+ //# sourceMappingURL=converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.d.ts","sourceRoot":"","sources":["../../../src/converter/link_to_netlist/converter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,kBAAkB,EAOxB,MAAM,oCAAoC,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uDAAuD,CAAA;AACvF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAiBrD,qBAAa,cAAe,YAAW,UAAU;IAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,oBAAoB;IAE7D,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,OAAO,CAAwB;IAEvC,OAAO,CAAC,sBAAsB;IAI9B,OAAO,CAAC,UAAU;IAMlB,QAAQ,CAAC,EAAE,EAAE,kBAAkB;CAsFhC"}
@@ -0,0 +1,154 @@
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 { ConnectionNodeType, LinkType, gen_link_map, get_port_link_type, } from '@modular-circuit/electronics-model';
29
+ import { CanDiffLinkTester, CanLogicLinkTester, CrystalLinkTester, Dvp8LinkTester, I2cLinkTester, I2sLinkTester, MetaPortConverter, SpeakerLinkTester, SpiLinkTester, SwdLinkTester, UartLinkTester, UsbCcLinkTester, UsbLinkTester, } from './links';
30
+ var LINK_CONVERTER = /** @class */ (function () {
31
+ function LINK_CONVERTER(ctx) {
32
+ this.ctx = ctx;
33
+ }
34
+ LINK_CONVERTER.prototype.port_is_composite_port = function (p) {
35
+ return Object.values(this.ctx.pin_map[this.port_id.get(p)]).length > 1;
36
+ };
37
+ LINK_CONVERTER.prototype.do_convert = function (CtorClass, ports, net_pros) {
38
+ return new CtorClass(this.ctx, ports, net_pros).convert();
39
+ };
40
+ LINK_CONVERTER.prototype.visit_cc = function (cc) {
41
+ var e_1, _a, e_2, _b, e_3, _c;
42
+ if (cc.is_isolated) {
43
+ return;
44
+ }
45
+ this.link_map = gen_link_map();
46
+ var ports = cc.nodes.filter(function (i) { return i.type === ConnectionNodeType.Port; });
47
+ var meta_ports = [];
48
+ this.port_id = new Map();
49
+ try {
50
+ for (var ports_1 = __values(ports), ports_1_1 = ports_1.next(); !ports_1_1.done; ports_1_1 = ports_1.next()) {
51
+ var p = ports_1_1.value;
52
+ this.port_id.set(p.param, p.uuid);
53
+ }
54
+ }
55
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
56
+ finally {
57
+ try {
58
+ if (ports_1_1 && !ports_1_1.done && (_a = ports_1.return)) _a.call(ports_1);
59
+ }
60
+ finally { if (e_1) throw e_1.error; }
61
+ }
62
+ try {
63
+ for (var ports_2 = __values(ports), ports_2_1 = ports_2.next(); !ports_2_1.done; ports_2_1 = ports_2.next()) {
64
+ var v = ports_2_1.value;
65
+ var port = v.param;
66
+ var arr = this.link_map[get_port_link_type(port)];
67
+ if (this.port_is_composite_port(port)) {
68
+ arr.push(port);
69
+ }
70
+ else {
71
+ meta_ports.push(port);
72
+ }
73
+ }
74
+ }
75
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
76
+ finally {
77
+ try {
78
+ if (ports_2_1 && !ports_2_1.done && (_b = ports_2.return)) _b.call(ports_2);
79
+ }
80
+ finally { if (e_2) throw e_2.error; }
81
+ }
82
+ var meta_port_converter = new MetaPortConverter(this.ctx, meta_ports, cc);
83
+ meta_port_converter.convert();
84
+ try {
85
+ for (var _d = __values(Object.entries(this.link_map)), _e = _d.next(); !_e.done; _e = _d.next()) {
86
+ var _f = __read(_e.value, 2), k = _f[0], v = _f[1];
87
+ if (!v || !v.length)
88
+ continue;
89
+ switch (k) {
90
+ case LinkType.CanLogicLink: {
91
+ this.do_convert(CanLogicLinkTester, v, cc);
92
+ break;
93
+ }
94
+ case LinkType.CanDiffLink: {
95
+ this.do_convert(CanDiffLinkTester, v, cc);
96
+ break;
97
+ }
98
+ case LinkType.CrystalLink: {
99
+ this.do_convert(CrystalLinkTester, v, cc);
100
+ break;
101
+ }
102
+ case LinkType.SwdLink: {
103
+ this.do_convert(SwdLinkTester, v, cc);
104
+ break;
105
+ }
106
+ case LinkType.I2cLink: {
107
+ this.do_convert(I2cLinkTester, v, cc);
108
+ break;
109
+ }
110
+ case LinkType.I2sLink: {
111
+ this.do_convert(I2sLinkTester, v, cc);
112
+ break;
113
+ }
114
+ case LinkType.SpiLink: {
115
+ this.do_convert(SpiLinkTester, v, cc);
116
+ break;
117
+ }
118
+ case LinkType.SpeakerLink: {
119
+ this.do_convert(SpeakerLinkTester, v, cc);
120
+ break;
121
+ }
122
+ case LinkType.UartLink: {
123
+ this.do_convert(UartLinkTester, v, cc);
124
+ break;
125
+ }
126
+ case LinkType.UsbLink: {
127
+ this.do_convert(UsbLinkTester, v, cc);
128
+ break;
129
+ }
130
+ case LinkType.UsbCcLink: {
131
+ this.do_convert(UsbCcLinkTester, v, cc);
132
+ break;
133
+ }
134
+ case LinkType.Dvp8Link: {
135
+ this.do_convert(Dvp8LinkTester, v, cc);
136
+ break;
137
+ }
138
+ default: {
139
+ throw new Error("Unhandled link type: ".concat(k));
140
+ }
141
+ }
142
+ }
143
+ }
144
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
145
+ finally {
146
+ try {
147
+ if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
148
+ }
149
+ finally { if (e_3) throw e_3.error; }
150
+ }
151
+ };
152
+ return LINK_CONVERTER;
153
+ }());
154
+ export { LINK_CONVERTER };
@@ -0,0 +1,3 @@
1
+ export * from './converter';
2
+ export * from './context';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/converter/link_to_netlist/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './converter';
2
+ export * from './context';
@@ -0,0 +1,30 @@
1
+ import type { NET_PROPERTIES, PortLike } from '@modular-circuit/electronics-model';
2
+ import type { LinkConverterContext } from '../context';
3
+ export interface Signal {
4
+ name: string;
5
+ ports: {
6
+ parent: PortLike;
7
+ meta_port: PortLike;
8
+ }[];
9
+ }
10
+ export declare abstract class LinkConverterBase<LinkT> {
11
+ protected readonly ctx: LinkConverterContext;
12
+ protected readonly ports: PortLike[];
13
+ protected readonly net_pros: NET_PROPERTIES;
14
+ protected link: LinkT | undefined;
15
+ constructor(ctx: LinkConverterContext, ports: PortLike[], net_pros: NET_PROPERTIES);
16
+ convert(): void;
17
+ protected abstract do_convert(): void;
18
+ protected abstract init_link(): boolean;
19
+ protected get_net_code(): number;
20
+ protected gen_net_name(signal_name?: string): string;
21
+ }
22
+ export declare class MetaPortConverter extends LinkConverterBase<undefined> {
23
+ protected do_convert(): void;
24
+ protected init_link(): boolean;
25
+ }
26
+ export declare abstract class CompositePortLinkConverterBase<LinkT> extends LinkConverterBase<LinkT> {
27
+ do_convert(): void;
28
+ protected abstract get_signals(): Signal[];
29
+ }
30
+ //# sourceMappingURL=converter_base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter_base.d.ts","sourceRoot":"","sources":["../../../../src/converter/link_to_netlist/links/converter_base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAuB,cAAc,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAA;AACvG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEtD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE;QACL,MAAM,EAAE,QAAQ,CAAA;QAChB,SAAS,EAAE,QAAQ,CAAA;KACpB,EAAE,CAAA;CACJ;AAED,8BAAsB,iBAAiB,CAAC,KAAK;IAIzC,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,oBAAoB;IAC5C,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE;IACpC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,cAAc;IAL7C,SAAS,CAAC,IAAI,EAAE,KAAK,GAAG,SAAS,CAAA;gBAGZ,GAAG,EAAE,oBAAoB,EACzB,KAAK,EAAE,QAAQ,EAAE,EACjB,QAAQ,EAAE,cAAc;IAGtC,OAAO;IAKd,SAAS,CAAC,QAAQ,CAAC,UAAU,IAAI,IAAI;IAErC,SAAS,CAAC,QAAQ,CAAC,SAAS,IAAI,OAAO;IAEvC,SAAS,CAAC,YAAY;IAItB,SAAS,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,MAAM;CAY5C;AAED,qBAAa,iBAAkB,SAAQ,iBAAiB,CAAC,SAAS,CAAC;IACjE,SAAS,CAAC,UAAU,IAAI,IAAI;IAe5B,SAAS,CAAC,SAAS,IAAI,OAAO;CAG/B;AAED,8BAAsB,8BAA8B,CAAC,KAAK,CAAE,SAAQ,iBAAiB,CAAC,KAAK,CAAC;IAC1E,UAAU,IAAI,IAAI;IAoBlC,SAAS,CAAC,QAAQ,CAAC,WAAW,IAAI,MAAM,EAAE;CAC3C"}