@modular-circuit/transpiler 0.0.58 → 0.0.59

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 (28) hide show
  1. package/build/builder/graph_to_kicad/do_convert_graph_to_kicad_project.js +19 -106
  2. package/build/builder/graph_to_kicad/index.js +4 -59
  3. package/build/converter/graph_to_netlist/graph_converter.js +51 -171
  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 +228 -281
  6. package/build/converter/link_to_netlist/converter.js +77 -135
  7. package/build/converter/link_to_netlist/links/converter_base.js +38 -131
  8. package/build/converter/link_to_netlist/links/converters.js +316 -554
  9. package/build/converter/netlist_to_kicad/layout.js +19 -23
  10. package/build/converter/netlist_to_kicad/netlist_converter.js +74 -167
  11. package/build/kicad/constraints/index.js +1 -1
  12. package/build/kicad/label/net_label.js +2 -2
  13. package/build/kicad/label/sheet_pin.js +11 -19
  14. package/build/kicad/project/kicad_prl.js +3 -3
  15. package/build/kicad/project/kicad_pro.js +4 -4
  16. package/build/kicad/project/kicad_project_achieve.js +31 -45
  17. package/build/kicad/project/wildcards_and_files_ext.js +61 -61
  18. package/build/kicad/sheet/sheet.js +3 -3
  19. package/build/kicad/symbols/lib_symbol/gnd.js +6 -6
  20. package/build/kicad/symbols/lib_symbol/vcc.js +7 -7
  21. package/build/kicad/symbols/sch_symbol/gnd.js +9 -9
  22. package/build/kicad/symbols/sch_symbol/vcc.js +9 -9
  23. package/build/kicad/symbols/symbol_utils.js +1 -1
  24. package/build/utils/collect_sub_sheets.js +32 -146
  25. package/build/utils/constraints.js +6 -6
  26. package/build/utils/filter_null_undefined.js +2 -31
  27. package/build/utils/string_formatter.js +23 -29
  28. package/package.json +5 -5
@@ -1,287 +1,234 @@
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);
1
+ import { READABLE_ELECTRICAL_PINTYPE } from '@modular-circuit/electronics-model';
2
+ import { SHAPE_T, } from '@modular-circuit/ir';
3
+ import { gen_uuid } from '@modular-circuit/utils';
4
+ import { GENERATOR_NAME, GENERATOR_VERSION, PAPER, SCH_VERSION, filterNullOrUndefined } from '../../../utils';
5
+ const SCOPE_START = '\n\t';
6
+ const SPACE = ' ';
7
+ const SCOPE_END = '\n';
8
+ const IGNORE_BOOLEANS = new Set(['power']);
9
+ export class SCHEMATIC_PRINTER {
10
+ schematic(sch) {
11
+ const lib_symbols = (() => {
12
+ if (!sch.lib_symbols?.symbols.length)
13
+ return '';
14
+ return `${SCOPE_START}(lib_symbols ${sch.lib_symbols?.symbols.map((it) => this.lib_symbol(it)).join(`${SCOPE_END}`)}\t)`;
15
+ })();
16
+ const labels = (() => {
17
+ if (!sch.labels?.length)
18
+ return '';
19
+ return `${SCOPE_START}${sch.labels.map((it) => this.label(it)).join(`${SCOPE_END}`)}`;
20
+ })();
21
+ const sch_sheets = (() => {
22
+ if (!sch.sheets?.length)
23
+ return '';
24
+ return `${SCOPE_START}${sch.sheets.map((it) => this.sch_sheet(it)).join(`${SCOPE_END}`)}\t`;
25
+ })();
26
+ const sch_symbols = (() => {
27
+ if (!sch.symbols?.length)
28
+ return '';
29
+ return `${SCOPE_START}${sch.symbols.map((it) => this.sch_symbol(it)).join(`${SCOPE_END}`)}\t`;
30
+ })();
31
+ return `
32
+ (kicad_sch
33
+ (version ${SCH_VERSION})
34
+ (generator "${GENERATOR_NAME}")
35
+ (generator_version "${GENERATOR_VERSION}")
36
+ (uuid "${gen_uuid()}")
37
+ (paper "${PAPER}")${lib_symbols}${labels}${sch_symbols}${sch_sheets}
38
+ )
39
+ `;
5
40
  }
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
- }
41
+ @filterNullOrUndefined
42
+ power(power) {
43
+ return power ? '(power)' : '';
44
+ }
45
+ @filterNullOrUndefined
46
+ pin_display_opt(opt) {
47
+ if (!opt)
48
+ return;
49
+ const offset = (off) => (off ? `(offset ${off})` : '');
50
+ const hide = (h) => (h ? 'hide' : '');
51
+ const pin_numbers = `${opt.pin_numbers ? `(pin_numbers ${offset(opt.pin_numbers.offset)} ${hide(opt.pin_numbers.hide)})` : ''}`;
52
+ const pin_names = `${opt.pin_names ? `(pin_names ${offset(opt.pin_names.offset)} ${hide(opt.pin_names.hide)})` : ''}`;
53
+ return `${pin_numbers}
54
+ ${pin_names}
55
+ `;
56
+ }
57
+ lib_symbol(lib_symbol) {
58
+ return `
59
+ (symbol "${lib_symbol.name}" ${this.power(lib_symbol.power)}
60
+ ${this.pin_display_opt(lib_symbol)}
61
+ ${this.booleans(lib_symbol)}
62
+ ${this.fields(lib_symbol.properties)}
63
+ ${this.pin_defs(lib_symbol.pins)}
64
+ ${this.drawings(lib_symbol.drawings)}
65
+ ${this.lib_children(lib_symbol.children)}
66
+ )
67
+ `;
68
+ }
69
+ @filterNullOrUndefined
70
+ lib_children(libs) {
71
+ if (!libs)
72
+ return '';
73
+ return libs.map((i) => this.lib_symbol(i)).join(SCOPE_END);
31
74
  }
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 };
75
+ pts(points) {
76
+ return `(pts ${points.map((i) => `(xy ${i.x} ${i.y} )`).join(SPACE)})`;
77
+ }
78
+ @filterNullOrUndefined
79
+ drawings(draws) {
80
+ if (!draws)
81
+ return;
82
+ return draws.map((i) => this.drawing(i)).join(SCOPE_END);
83
+ }
84
+ drawing(draw) {
85
+ if (!('shape' in draw))
86
+ throw new Error(`Unhandled drawing ${draw}`);
87
+ switch (draw.shape) {
88
+ case SHAPE_T.POLY:
89
+ return `(polyline
90
+ ${this.pts(draw.pts)}
91
+ ${this.stroke(draw.stroke)}
92
+ ${this.fill(draw.fill)}
93
+ )`;
42
94
  }
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);
95
+ throw new Error(`Unhandled drawing ${draw}`);
96
+ }
97
+ @filterNullOrUndefined
98
+ pin_defs(defs) {
99
+ if (!defs)
100
+ return;
101
+ return defs.map((it) => this.pin_def(it)).join(SCOPE_END);
102
+ }
103
+ pin_def(def) {
104
+ return `(pin ${READABLE_ELECTRICAL_PINTYPE[def.type]} ${def.shape}
105
+ ${this.at(def.at)}
106
+ (length ${def.length})
107
+ (name "${def.name.text}"
108
+ ${this.effects(def.name.effects)}
109
+ )
110
+ (number "${def.number.text}"
111
+ ${this.effects(def.number.effects)}
112
+ )
113
+ )`;
114
+ }
115
+ label(label) {
116
+ return ` (${label.label_type} "${label.text}"
117
+ ${this.at(label.at)}
118
+ ${this.fields_autoplaced()}
119
+ ${this.effects(label.effects)}
120
+ ${this.uuid(label.uuid)}
121
+ )`;
122
+ }
123
+ @filterNullOrUndefined
124
+ unit(c) {
125
+ return `(unit ${c})`;
126
+ }
127
+ sch_symbol(sch_symbol) {
128
+ return `(symbol
129
+ ${this.lib_id(sch_symbol.lib_id)}
130
+ ${this.at(sch_symbol.at)}
131
+ ${this.unit(sch_symbol.unit)}
132
+ ${this.booleans(sch_symbol)}
133
+ ${this.fields(sch_symbol.properties)}
134
+ ${sch_symbol.pins.map((pin) => this.sch_symbol_pin(pin)).join(SCOPE_START)}
135
+ )`;
136
+ }
137
+ @filterNullOrUndefined
138
+ lib_id(id) {
139
+ if (!id)
140
+ return;
141
+ return `(lib_id "${id}")`;
142
+ }
143
+ sch_symbol_pin(pin) {
144
+ return `(pin "${pin.number}" ${this.uuid(pin.uuid)})`;
52
145
  }
53
- catch (error) { e = { error: error }; }
54
- finally {
55
- try {
56
- if (r && !r.done && (m = i["return"])) m.call(i);
146
+ sch_sheet(sheet) {
147
+ return `(sheet
148
+ ${this.at(sheet.at)}
149
+ ${this.size(sheet.size)}
150
+ ${this.fields_autoplaced()}
151
+ ${this.stroke(sheet.stroke)}
152
+ ${this.fill(sheet.fill)}
153
+ ${this.uuid(sheet.uuid)}
154
+ ${this.fields(sheet.fields)}
155
+ ${sheet.pins.map((sheet_pin) => this.sch_sheet_pin(sheet_pin)).join(SCOPE_START)}
156
+ )`;
157
+ }
158
+ sch_sheet_pin(sheet_pin) {
159
+ return `(pin "${sheet_pin.text}" ${sheet_pin.shape}
160
+ ${this.at(sheet_pin.at)}
161
+ ${this.effects(sheet_pin.effects)}
162
+ ${this.uuid(sheet_pin.uuid)}
163
+ )`;
164
+ }
165
+ at(pos) {
166
+ return `(at ${pos.position.x} ${pos.position.y} ${pos.rotation === undefined ? '' : pos.rotation})`;
167
+ }
168
+ uuid(id) {
169
+ return `(uuid "${id}")`;
170
+ }
171
+ effects(e) {
172
+ return `(effects
173
+ (font
174
+ (size ${e.font.size.x} ${e.font.size.y})
175
+ )${this.justify(e.justify)}${e.hide ? '(hide yes)' : ''}
176
+ )`;
177
+ }
178
+ @filterNullOrUndefined
179
+ justify(justify) {
180
+ if (!justify)
181
+ return;
182
+ return `(justify ${justify.horizontal} ${justify.vertical})`;
183
+ }
184
+ booleans(it) {
185
+ if (typeof it !== 'object' || !it)
186
+ return;
187
+ const res = [];
188
+ for (const [k, v] of Object.entries(it)) {
189
+ if (typeof v === 'boolean' && !IGNORE_BOOLEANS.has(k))
190
+ res.push(`( ${k} ${v ? 'yes' : 'no'} )`);
57
191
  }
58
- finally { if (e) throw e.error; }
192
+ return res.join(SCOPE_START);
59
193
  }
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 };
194
+ @filterNullOrUndefined
195
+ fields(fields) {
196
+ if (!fields)
197
+ return;
198
+ return fields.map((f) => this.field(f)).join(SCOPE_START);
199
+ }
200
+ field(field) {
201
+ return `(property "${field.name}" "${field.text}"
202
+ ${this.at(field.at)}
203
+ ${this.effects(field.effects)}
204
+ )`;
205
+ }
206
+ @filterNullOrUndefined
207
+ fill(f) {
208
+ if (!f)
209
+ return;
210
+ return `(fill${f.type ? ` (type ${f.type})` : ''} ${this.color(f.color)})`;
211
+ }
212
+ size(s) {
213
+ return `(size ${s.x} ${s.y})`;
214
+ }
215
+ fields_autoplaced() {
216
+ return '(fields_autoplaced yes)';
217
+ }
218
+ @filterNullOrUndefined
219
+ stroke(s) {
220
+ if (!s)
221
+ return;
222
+ return `(stroke
223
+ (width ${s.width})
224
+ (type ${s.type})
225
+ ${this.color(s.color)}
226
+ )`;
227
+ }
228
+ @filterNullOrUndefined
229
+ color(c) {
230
+ if (!c)
231
+ return;
232
+ return `(color ${c.r} ${c.g} ${c.b} ${c.a})`;
233
+ }
234
+ }