@modular-circuit/transpiler 0.0.76 → 0.0.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/build/builder/graph_to_kicad/do_convert_graph_to_kicad_project.js +19 -108
  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 +245 -290
  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/calc_boxes_pos.d.ts +1 -1
  10. package/build/converter/netlist_to_kicad/calc_boxes_pos.d.ts.map +1 -1
  11. package/build/converter/netlist_to_kicad/calc_boxes_pos.js +36 -101
  12. package/build/converter/netlist_to_kicad/layout.js +28 -32
  13. package/build/converter/netlist_to_kicad/netlist_converter.d.ts +1 -1
  14. package/build/converter/netlist_to_kicad/netlist_converter.d.ts.map +1 -1
  15. package/build/converter/netlist_to_kicad/netlist_converter.js +128 -300
  16. package/build/kicad/constraints/index.js +1 -1
  17. package/build/kicad/label/net_label.js +2 -2
  18. package/build/kicad/label/sheet_pin.js +11 -19
  19. package/build/kicad/project/kicad_prl.js +3 -3
  20. package/build/kicad/project/kicad_pro.js +4 -4
  21. package/build/kicad/project/kicad_project_achieve.js +31 -45
  22. package/build/kicad/project/wildcards_and_files_ext.js +61 -61
  23. package/build/kicad/sheet/sheet.js +3 -3
  24. package/build/kicad/symbols/lib_symbol/gnd.js +6 -6
  25. package/build/kicad/symbols/lib_symbol/vcc.js +7 -7
  26. package/build/kicad/symbols/sch_symbol/gnd.js +9 -9
  27. package/build/kicad/symbols/sch_symbol/vcc.js +9 -9
  28. package/build/kicad/symbols/symbol_utils.js +1 -1
  29. package/build/kicad/wire/gen_wire.js +4 -4
  30. package/build/utils/collect_sub_sheets.js +37 -151
  31. package/build/utils/constraints.js +6 -6
  32. package/build/utils/filter_null_undefined.js +2 -31
  33. package/build/utils/string_formatter.js +23 -29
  34. package/package.json +5 -5
@@ -1,296 +1,251 @@
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 wires = (() => {
17
+ if (!sch.wires?.length)
18
+ return '';
19
+ return `${SCOPE_START}${sch.wires.map((it) => this.wire(it)).join(`${SCOPE_END}`)}\t`;
20
+ })();
21
+ const labels = (() => {
22
+ if (!sch.labels?.length)
23
+ return '';
24
+ return `${SCOPE_START}${sch.labels.map((it) => this.label(it)).join(`${SCOPE_END}`)}`;
25
+ })();
26
+ const sch_sheets = (() => {
27
+ if (!sch.sheets?.length)
28
+ return '';
29
+ return `${SCOPE_START}${sch.sheets.map((it) => this.sch_sheet(it)).join(`${SCOPE_END}`)}\t`;
30
+ })();
31
+ const sch_symbols = (() => {
32
+ if (!sch.symbols?.length)
33
+ return '';
34
+ return `${SCOPE_START}${sch.symbols.map((it) => this.sch_symbol(it)).join(`${SCOPE_END}`)}\t`;
35
+ })();
36
+ return `
37
+ (kicad_sch
38
+ (version ${SCH_VERSION})
39
+ (generator "${GENERATOR_NAME}")
40
+ (generator_version "${GENERATOR_VERSION}")
41
+ (uuid "${gen_uuid()}")
42
+ (paper "${PAPER}")
43
+ ${lib_symbols}
44
+ ${wires}
45
+ ${labels}
46
+ ${sch_symbols}
47
+ ${sch_sheets}
48
+ )
49
+ `;
5
50
  }
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
- }
51
+ @filterNullOrUndefined
52
+ power(power) {
53
+ return power ? '(power)' : '';
54
+ }
55
+ @filterNullOrUndefined
56
+ pin_display_opt(opt) {
57
+ if (!opt)
58
+ return;
59
+ const offset = (off) => (off ? `(offset ${off})` : '');
60
+ const hide = (h) => (h ? 'hide' : '');
61
+ const pin_numbers = `${opt.pin_numbers ? `(pin_numbers ${offset(opt.pin_numbers.offset)} ${hide(opt.pin_numbers.hide)})` : ''}`;
62
+ const pin_names = `${opt.pin_names ? `(pin_names ${offset(opt.pin_names.offset)} ${hide(opt.pin_names.hide)})` : ''}`;
63
+ return `${pin_numbers}
64
+ ${pin_names}
65
+ `;
66
+ }
67
+ lib_symbol(lib_symbol) {
68
+ return `
69
+ (symbol "${lib_symbol.name}" ${this.power(lib_symbol.power)}
70
+ ${this.pin_display_opt(lib_symbol)}
71
+ ${this.booleans(lib_symbol)}
72
+ ${this.fields(lib_symbol.properties)}
73
+ ${this.pin_defs(lib_symbol.pins)}
74
+ ${this.drawings(lib_symbol.drawings)}
75
+ ${this.lib_children(lib_symbol.children)}
76
+ )
77
+ `;
78
+ }
79
+ @filterNullOrUndefined
80
+ lib_children(libs) {
81
+ if (!libs)
82
+ return '';
83
+ return libs.map((i) => this.lib_symbol(i)).join(SCOPE_END);
31
84
  }
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 };
85
+ pts(points) {
86
+ return `(pts ${points.map((i) => `(xy ${i.x} ${i.y} )`).join(SPACE)})`;
87
+ }
88
+ @filterNullOrUndefined
89
+ drawings(draws) {
90
+ if (!draws)
91
+ return;
92
+ return draws.map((i) => this.drawing(i)).join(SCOPE_END);
93
+ }
94
+ drawing(draw) {
95
+ if (!('shape' in draw))
96
+ throw new Error(`Unhandled drawing ${draw}`);
97
+ switch (draw.shape) {
98
+ case SHAPE_T.POLY:
99
+ return `(polyline
100
+ ${this.pts(draw.pts)}
101
+ ${this.stroke(draw.stroke)}
102
+ ${this.fill(draw.fill)}
103
+ )`;
42
104
  }
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);
105
+ throw new Error(`Unhandled drawing ${draw}`);
106
+ }
107
+ @filterNullOrUndefined
108
+ pin_defs(defs) {
109
+ if (!defs)
110
+ return;
111
+ return defs.map((it) => this.pin_def(it)).join(SCOPE_END);
112
+ }
113
+ pin_def(def) {
114
+ return `(pin ${READABLE_ELECTRICAL_PINTYPE[def.type]} ${def.shape}
115
+ ${this.at(def.at)}
116
+ (length ${def.length})
117
+ (name "${def.name.text}"
118
+ ${this.effects(def.name.effects)}
119
+ )
120
+ (number "${def.number.text}"
121
+ ${this.effects(def.number.effects)}
122
+ )
123
+ )`;
124
+ }
125
+ label(label) {
126
+ return ` (${label.label_type} "${label.text}"
127
+ ${this.at(label.at)}
128
+ ${this.fields_autoplaced()}
129
+ ${this.effects(label.effects)}
130
+ ${this.uuid(label.uuid)}
131
+ )`;
132
+ }
133
+ @filterNullOrUndefined
134
+ unit(c) {
135
+ return `(unit ${c})`;
136
+ }
137
+ sch_symbol(sch_symbol) {
138
+ return `(symbol
139
+ ${this.lib_id(sch_symbol.lib_id)}
140
+ ${this.at(sch_symbol.at)}
141
+ ${this.unit(sch_symbol.unit)}
142
+ ${this.booleans(sch_symbol)}
143
+ ${this.fields(sch_symbol.properties)}
144
+ ${sch_symbol.pins.map((pin) => this.sch_symbol_pin(pin)).join(SCOPE_START)}
145
+ )`;
146
+ }
147
+ wire(w) {
148
+ return `(wire
149
+ ${this.pts([w.start, w.end])}
150
+ ${this.stroke(w.stroke)}
151
+ ${this.uuid(w.uuid)}
152
+ )`;
153
+ }
154
+ @filterNullOrUndefined
155
+ lib_id(id) {
156
+ if (!id)
157
+ return;
158
+ return `(lib_id "${id}")`;
52
159
  }
53
- catch (error) { e = { error: error }; }
54
- finally {
55
- try {
56
- if (r && !r.done && (m = i["return"])) m.call(i);
160
+ sch_symbol_pin(pin) {
161
+ return `(pin "${pin.number}" ${this.uuid(pin.uuid)})`;
162
+ }
163
+ sch_sheet(sheet) {
164
+ return `(sheet
165
+ ${this.at(sheet.at)}
166
+ ${this.size(sheet.size)}
167
+ ${this.fields_autoplaced()}
168
+ ${this.stroke(sheet.stroke)}
169
+ ${this.fill(sheet.fill)}
170
+ ${this.uuid(sheet.uuid)}
171
+ ${this.fields(sheet.fields)}
172
+ ${sheet.pins.map((sheet_pin) => this.sch_sheet_pin(sheet_pin)).join(SCOPE_START)}
173
+ )`;
174
+ }
175
+ sch_sheet_pin(sheet_pin) {
176
+ return `(pin "${sheet_pin.text}" ${sheet_pin.shape}
177
+ ${this.at(sheet_pin.at)}
178
+ ${this.effects(sheet_pin.effects)}
179
+ ${this.uuid(sheet_pin.uuid)}
180
+ )`;
181
+ }
182
+ at(pos) {
183
+ return `(at ${pos.position.x} ${pos.position.y} ${pos.rotation === undefined ? '' : pos.rotation})`;
184
+ }
185
+ uuid(id) {
186
+ return `(uuid "${id}")`;
187
+ }
188
+ effects(e) {
189
+ return `(effects
190
+ (font
191
+ (size ${e.font.size.x} ${e.font.size.y})
192
+ )${this.justify(e.justify)}${e.hide ? '(hide yes)' : ''}
193
+ )`;
194
+ }
195
+ @filterNullOrUndefined
196
+ justify(justify) {
197
+ if (!justify)
198
+ return;
199
+ return `(justify ${justify.horizontal} ${justify.vertical})`;
200
+ }
201
+ booleans(it) {
202
+ if (typeof it !== 'object' || !it)
203
+ return;
204
+ const res = [];
205
+ for (const [k, v] of Object.entries(it)) {
206
+ if (typeof v === 'boolean' && !IGNORE_BOOLEANS.has(k))
207
+ res.push(`( ${k} ${v ? 'yes' : 'no'} )`);
57
208
  }
58
- finally { if (e) throw e.error; }
209
+ return res.join(SCOPE_START);
59
210
  }
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 wires = (function () {
98
- var _b;
99
- if (!((_b = sch.wires) === null || _b === void 0 ? void 0 : _b.length))
100
- return '';
101
- return "".concat(SCOPE_START).concat(sch.wires.map(function (it) { return _this.wire(it); }).join("".concat(SCOPE_END)), "\t");
102
- })();
103
- var labels = (function () {
104
- var _b;
105
- if (!((_b = sch.labels) === null || _b === void 0 ? void 0 : _b.length))
106
- return '';
107
- return "".concat(SCOPE_START).concat(sch.labels.map(function (it) { return _this.label(it); }).join("".concat(SCOPE_END)));
108
- })();
109
- var sch_sheets = (function () {
110
- var _b;
111
- if (!((_b = sch.sheets) === null || _b === void 0 ? void 0 : _b.length))
112
- return '';
113
- return "".concat(SCOPE_START).concat(sch.sheets.map(function (it) { return _this.sch_sheet(it); }).join("".concat(SCOPE_END)), "\t");
114
- })();
115
- var sch_symbols = (function () {
116
- var _b;
117
- if (!((_b = sch.symbols) === null || _b === void 0 ? void 0 : _b.length))
118
- return '';
119
- return "".concat(SCOPE_START).concat(sch.symbols.map(function (it) { return _this.sch_symbol(it); }).join("".concat(SCOPE_END)), "\t");
120
- })();
121
- 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, "\")\n ").concat(lib_symbols, "\n ").concat(wires, "\n ").concat(labels, "\n ").concat(sch_symbols, "\n ").concat(sch_sheets, "\n)\n ");
122
- };
123
- SCHEMATIC_PRINTER.prototype.power = function (power) {
124
- return power ? '(power)' : '';
125
- };
126
- SCHEMATIC_PRINTER.prototype.pin_display_opt = function (opt) {
127
- if (!opt)
128
- return;
129
- var offset = function (off) { return (off ? "(offset ".concat(off, ")") : ''); };
130
- var hide = function (h) { return (h ? 'hide' : ''); };
131
- var pin_numbers = "".concat(opt.pin_numbers ? "(pin_numbers ".concat(offset(opt.pin_numbers.offset), " ").concat(hide(opt.pin_numbers.hide), ")") : '');
132
- var pin_names = "".concat(opt.pin_names ? "(pin_names ".concat(offset(opt.pin_names.offset), " ").concat(hide(opt.pin_names.hide), ")") : '');
133
- return "".concat(pin_numbers, "\n ").concat(pin_names, "\n ");
134
- };
135
- SCHEMATIC_PRINTER.prototype.lib_symbol = function (lib_symbol) {
136
- 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 ");
137
- };
138
- SCHEMATIC_PRINTER.prototype.lib_children = function (libs) {
139
- var _this = this;
140
- if (!libs)
141
- return '';
142
- return libs.map(function (i) { return _this.lib_symbol(i); }).join(SCOPE_END);
143
- };
144
- SCHEMATIC_PRINTER.prototype.pts = function (points) {
145
- return "(pts ".concat(points.map(function (i) { return "(xy ".concat(i.x, " ").concat(i.y, " )"); }).join(SPACE), ")");
146
- };
147
- SCHEMATIC_PRINTER.prototype.drawings = function (draws) {
148
- var _this = this;
149
- if (!draws)
150
- return;
151
- return draws.map(function (i) { return _this.drawing(i); }).join(SCOPE_END);
152
- };
153
- SCHEMATIC_PRINTER.prototype.drawing = function (draw) {
154
- if (!('shape' in draw))
155
- throw new Error("Unhandled drawing ".concat(draw));
156
- switch (draw.shape) {
157
- case SHAPE_T.POLY:
158
- 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)");
159
- }
160
- throw new Error("Unhandled drawing ".concat(draw));
161
- };
162
- SCHEMATIC_PRINTER.prototype.pin_defs = function (defs) {
163
- var _this = this;
164
- if (!defs)
165
- return;
166
- return defs.map(function (it) { return _this.pin_def(it); }).join(SCOPE_END);
167
- };
168
- SCHEMATIC_PRINTER.prototype.pin_def = function (def) {
169
- 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)");
170
- };
171
- SCHEMATIC_PRINTER.prototype.label = function (label) {
172
- 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)");
173
- };
174
- SCHEMATIC_PRINTER.prototype.unit = function (c) {
175
- return "(unit ".concat(c, ")");
176
- };
177
- SCHEMATIC_PRINTER.prototype.sch_symbol = function (sch_symbol) {
178
- var _this = this;
179
- 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)");
180
- };
181
- SCHEMATIC_PRINTER.prototype.wire = function (w) {
182
- return "(wire\n ".concat(this.pts([w.start, w.end]), "\n ").concat(this.stroke(w.stroke), "\n ").concat(this.uuid(w.uuid), "\n )");
183
- };
184
- SCHEMATIC_PRINTER.prototype.lib_id = function (id) {
185
- if (!id)
186
- return;
187
- return "(lib_id \"".concat(id, "\")");
188
- };
189
- SCHEMATIC_PRINTER.prototype.sch_symbol_pin = function (pin) {
190
- return "(pin \"".concat(pin.number, "\" ").concat(this.uuid(pin.uuid), ")");
191
- };
192
- SCHEMATIC_PRINTER.prototype.sch_sheet = function (sheet) {
193
- var _this = this;
194
- 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 )");
195
- };
196
- SCHEMATIC_PRINTER.prototype.sch_sheet_pin = function (sheet_pin) {
197
- 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)");
198
- };
199
- SCHEMATIC_PRINTER.prototype.at = function (pos) {
200
- return "(at ".concat(pos.position.x, " ").concat(pos.position.y, " ").concat(pos.rotation === undefined ? '' : pos.rotation, ")");
201
- };
202
- SCHEMATIC_PRINTER.prototype.uuid = function (id) {
203
- return "(uuid \"".concat(id, "\")");
204
- };
205
- SCHEMATIC_PRINTER.prototype.effects = function (e) {
206
- 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 )");
207
- };
208
- SCHEMATIC_PRINTER.prototype.justify = function (justify) {
209
- if (!justify)
210
- return;
211
- return "(justify ".concat(justify.horizontal, " ").concat(justify.vertical, ")");
212
- };
213
- SCHEMATIC_PRINTER.prototype.booleans = function (it) {
214
- var e_1, _b;
215
- if (typeof it !== 'object' || !it)
216
- return;
217
- var res = [];
218
- try {
219
- for (var _c = __values(Object.entries(it)), _d = _c.next(); !_d.done; _d = _c.next()) {
220
- var _e = __read(_d.value, 2), k = _e[0], v = _e[1];
221
- if (typeof v === 'boolean' && !IGNORE_BOOLEANS.has(k))
222
- res.push("( ".concat(k, " ").concat(v ? 'yes' : 'no', " )"));
223
- }
224
- }
225
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
226
- finally {
227
- try {
228
- if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
229
- }
230
- finally { if (e_1) throw e_1.error; }
231
- }
232
- return res.join(SCOPE_START);
233
- };
234
- SCHEMATIC_PRINTER.prototype.fields = function (fields) {
235
- var _this = this;
236
- if (!fields)
237
- return;
238
- return fields.map(function (f) { return _this.field(f); }).join(SCOPE_START);
239
- };
240
- SCHEMATIC_PRINTER.prototype.field = function (field) {
241
- 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)");
242
- };
243
- SCHEMATIC_PRINTER.prototype.fill = function (f) {
244
- if (!f)
245
- return;
246
- return "(fill".concat(f.type ? " (type ".concat(f.type, ")") : '', " ").concat(this.color(f.color), ")");
247
- };
248
- SCHEMATIC_PRINTER.prototype.size = function (s) {
249
- return "(size ".concat(s.x, " ").concat(s.y, ")");
250
- };
251
- SCHEMATIC_PRINTER.prototype.fields_autoplaced = function () {
252
- return '(fields_autoplaced yes)';
253
- };
254
- SCHEMATIC_PRINTER.prototype.stroke = function (s) {
255
- if (!s)
256
- return;
257
- 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)");
258
- };
259
- SCHEMATIC_PRINTER.prototype.color = function (c) {
260
- if (!c)
261
- return;
262
- return "(color ".concat(c.r, " ").concat(c.g, " ").concat(c.b, " ").concat(c.a, ")");
263
- };
264
- return SCHEMATIC_PRINTER;
265
- }()),
266
- (function () {
267
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
268
- _power_decorators = [filterNullOrUndefined];
269
- _pin_display_opt_decorators = [filterNullOrUndefined];
270
- _lib_children_decorators = [filterNullOrUndefined];
271
- _drawings_decorators = [filterNullOrUndefined];
272
- _pin_defs_decorators = [filterNullOrUndefined];
273
- _unit_decorators = [filterNullOrUndefined];
274
- _lib_id_decorators = [filterNullOrUndefined];
275
- _justify_decorators = [filterNullOrUndefined];
276
- _fields_decorators = [filterNullOrUndefined];
277
- _fill_decorators = [filterNullOrUndefined];
278
- _stroke_decorators = [filterNullOrUndefined];
279
- _color_decorators = [filterNullOrUndefined];
280
- __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);
281
- __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);
282
- __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);
283
- __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);
284
- __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);
285
- __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);
286
- __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);
287
- __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);
288
- __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);
289
- __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);
290
- __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);
291
- __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);
292
- if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
293
- })(),
294
- _a;
295
- }();
296
- export { SCHEMATIC_PRINTER };
211
+ @filterNullOrUndefined
212
+ fields(fields) {
213
+ if (!fields)
214
+ return;
215
+ return fields.map((f) => this.field(f)).join(SCOPE_START);
216
+ }
217
+ field(field) {
218
+ return `(property "${field.name}" "${field.text}"
219
+ ${this.at(field.at)}
220
+ ${this.effects(field.effects)}
221
+ )`;
222
+ }
223
+ @filterNullOrUndefined
224
+ fill(f) {
225
+ if (!f)
226
+ return;
227
+ return `(fill${f.type ? ` (type ${f.type})` : ''} ${this.color(f.color)})`;
228
+ }
229
+ size(s) {
230
+ return `(size ${s.x} ${s.y})`;
231
+ }
232
+ fields_autoplaced() {
233
+ return '(fields_autoplaced yes)';
234
+ }
235
+ @filterNullOrUndefined
236
+ stroke(s) {
237
+ if (!s)
238
+ return;
239
+ return `(stroke
240
+ (width ${s.width})
241
+ (type ${s.type})
242
+ ${this.color(s.color)}
243
+ )`;
244
+ }
245
+ @filterNullOrUndefined
246
+ color(c) {
247
+ if (!c)
248
+ return;
249
+ return `(color ${c.r} ${c.g} ${c.b} ${c.a})`;
250
+ }
251
+ }