@modular-circuit/transpiler 0.0.71 → 0.0.73

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.
@@ -7,19 +7,23 @@ export declare function get_power_pos(pwr_number: number): {
7
7
  };
8
8
  export declare const BLOCK_PIN_GAP: number;
9
9
  export declare const WIRE_PADDING: number;
10
- export interface BlockPadding {
10
+ export interface LabelPadding {
11
11
  l_side: number;
12
12
  r_side: number;
13
13
  }
14
- export interface BlockBoxPadding {
15
- internal: BlockPadding;
16
- outer: BlockPadding;
14
+ export interface BlockLabelPadding {
15
+ internal: LabelPadding;
16
+ outer: LabelPadding;
17
17
  total_pin_num: number;
18
18
  }
19
+ export interface BoxGeometry {
20
+ box: BOX2;
21
+ bounding_box: BOX2;
22
+ }
19
23
  export declare class Layout {
20
24
  private width;
21
25
  private height;
22
26
  private max_height;
23
- get_block_bounding_box(factor: BlockBoxPadding): BOX2;
27
+ get_block_geometry(factor: BlockLabelPadding): BoxGeometry;
24
28
  }
25
29
  //# sourceMappingURL=layout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAA;AAI9D,eAAO,MAAM,SAAS,QAAiB,CAAA;AAEvC,eAAO,MAAM,SAAS,QAAY,CAAA;AAQlC,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM;;;EAE/C;AAKD,eAAO,MAAM,aAAa,QAAgB,CAAA;AAO1C,eAAO,MAAM,YAAY,QAAY,CAAA;AAErC,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,YAAY,CAAA;IACtB,KAAK,EAAE,YAAY,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAgB;IAE7B,OAAO,CAAC,MAAM,CAAgB;IAE9B,OAAO,CAAC,UAAU,CAAI;IAEf,sBAAsB,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;CAoC7D"}
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAA;AAI9D,eAAO,MAAM,SAAS,QAAiB,CAAA;AAEvC,eAAO,MAAM,SAAS,QAAY,CAAA;AAQlC,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM;;;EAE/C;AAKD,eAAO,MAAM,aAAa,QAAgB,CAAA;AAQ1C,eAAO,MAAM,YAAY,QAAY,CAAA;AAErC,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,YAAY,CAAA;IACtB,KAAK,EAAE,YAAY,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,IAAI,CAAA;IACT,YAAY,EAAE,IAAI,CAAA;CACnB;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAgB;IAE7B,OAAO,CAAC,MAAM,CAAgB;IAE9B,OAAO,CAAC,UAAU,CAAI;IAEf,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW;CAoDlE"}
@@ -15,6 +15,7 @@ var BLOCK_MARGIN_TOP = 8 * GRID_SIZE;
15
15
  var MIN_BLOCK_WIDTH = 16 * GRID_SIZE;
16
16
  var BLOCK_MARGIN_LEFT = 16 * GRID_SIZE;
17
17
  var BLOCK_MARGIN_RIGHT = BLOCK_MARGIN_LEFT;
18
+ var INTERNAL_LABEL_MARGIN = 8 * FONT_SIZE;
18
19
  export var WIRE_PADDING = GRID_SIZE;
19
20
  var Layout = /** @class */ (function () {
20
21
  function Layout() {
@@ -22,15 +23,16 @@ var Layout = /** @class */ (function () {
22
23
  this.height = BLOCK_START_Y;
23
24
  this.max_height = 0;
24
25
  }
25
- Layout.prototype.get_block_bounding_box = function (factor) {
26
+ Layout.prototype.get_block_geometry = function (factor) {
26
27
  var block_height = (BLOCK_PIN_GAP * factor.total_pin_num) / 2 + BLOCK_PIN_GAP * 2;
27
- var block_width = Math.max(MIN_BLOCK_WIDTH, factor.internal.l_side +
28
+ var block_width = Math.max(MIN_BLOCK_WIDTH, factor.internal.l_side + factor.internal.r_side + INTERNAL_LABEL_MARGIN);
29
+ var block_bounding_width = Math.max(block_width, factor.internal.l_side +
28
30
  factor.internal.r_side +
29
31
  factor.outer.l_side +
30
32
  factor.outer.r_side +
31
33
  // | txt | | txt |
32
34
  WIRE_PADDING * 4);
33
- var rect = {
35
+ var box = {
34
36
  pos: {
35
37
  x: this.width,
36
38
  y: this.height,
@@ -40,14 +42,24 @@ var Layout = /** @class */ (function () {
40
42
  y: block_height,
41
43
  },
42
44
  };
45
+ var bounding_box = {
46
+ pos: {
47
+ x: this.width,
48
+ y: this.height,
49
+ },
50
+ size: {
51
+ x: block_bounding_width,
52
+ y: block_height,
53
+ },
54
+ };
43
55
  this.max_height = Math.max(this.max_height, block_height);
44
- this.width += block_width + BLOCK_MARGIN_LEFT;
45
- if (this.width + BLOCK_MARGIN_RIGHT + block_width + BLOCK_MARGIN_LEFT > POWER_START_X) {
56
+ this.width += block_bounding_width + BLOCK_MARGIN_LEFT;
57
+ if (this.width + BLOCK_MARGIN_RIGHT + MIN_BLOCK_WIDTH + BLOCK_MARGIN_LEFT > POWER_START_X) {
46
58
  this.width = BLOCK_START_X;
47
59
  this.height += this.max_height + BLOCK_MARGIN_TOP;
48
60
  this.max_height = 0;
49
61
  }
50
- return rect;
62
+ return { box: box, bounding_box: bounding_box };
51
63
  };
52
64
  return Layout;
53
65
  }());
@@ -20,7 +20,7 @@ export declare class NetListConverter {
20
20
  private convert_sch;
21
21
  private convert_hierarchical_label;
22
22
  private convert_pwr_symbol;
23
- private get_sheet_symbol_paddings;
23
+ private get_sheet_symbol_lb_padding;
24
24
  private convert_sheet_symbol;
25
25
  private convert_sheet_pin;
26
26
  private convert_net_label;
@@ -1 +1 @@
1
- {"version":3,"file":"netlist_converter.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/netlist_converter.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,SAAS,EAGf,MAAM,qBAAqB,CAAA;AAM5B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAatD,qBAAa,gBAAgB;IASR,OAAO,CAAC,GAAG;IAR9B,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO,CAAC,eAAe,CAAI;IAE3B,OAAO,CAAC,QAAQ,CAA6B;IAE7C,OAAO,CAAC,KAAK,CAAiB;gBAEH,GAAG,EAAE,qBAAqB;IAQrD,gBAAgB,CAAC,EAAE,EAAE,MAAM;IAI3B,gBAAgB,CAAC,EAAE,EAAE,MAAM;IAIpB,gBAAgB;IAYvB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAqEnB,OAAO,CAAC,0BAA0B;IAYlC,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,yBAAyB;IA8CjC,OAAO,CAAC,oBAAoB;IAgD5B,OAAO,CAAC,iBAAiB;IA+BzB,OAAO,CAAC,iBAAiB;CAQ1B"}
1
+ {"version":3,"file":"netlist_converter.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/netlist_converter.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,SAAS,EAGf,MAAM,qBAAqB,CAAA;AAM5B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAatD,qBAAa,gBAAgB;IASR,OAAO,CAAC,GAAG;IAR9B,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO,CAAC,eAAe,CAAI;IAE3B,OAAO,CAAC,QAAQ,CAA6B;IAE7C,OAAO,CAAC,KAAK,CAAiB;gBAEH,GAAG,EAAE,qBAAqB;IAQrD,gBAAgB,CAAC,EAAE,EAAE,MAAM;IAI3B,gBAAgB,CAAC,EAAE,EAAE,MAAM;IAIpB,gBAAgB;IAYvB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAiEnB,OAAO,CAAC,0BAA0B;IAYlC,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,2BAA2B;IA8CnC,OAAO,CAAC,oBAAoB;IAqC5B,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,iBAAiB;CAQ1B"}
@@ -155,33 +155,35 @@ var NetListConverter = /** @class */ (function () {
155
155
  finally { if (e_4) throw e_4.error; }
156
156
  }
157
157
  var sheet_names_count = new Map();
158
+ var ordered_sheets = schematic.sheet_symbols.sort(function (a, b) {
159
+ return b.pins.length - a.pins.length;
160
+ });
158
161
  try {
159
- for (var _h = __values(schematic.sheet_symbols.sort(function (a, b) {
160
- return b.pins.length - a.pins.length;
161
- })), _j = _h.next(); !_j.done; _j = _h.next()) {
162
- var it_3 = _j.value;
163
- var sheet_padding = this.get_sheet_symbol_paddings(it_3);
164
- this.convert_sheet_symbol(it_3, this.block_calc.get_block_bounding_box(sheet_padding), sch, sheet_names_count, sheet_padding.outer);
162
+ for (var ordered_sheets_1 = __values(ordered_sheets), ordered_sheets_1_1 = ordered_sheets_1.next(); !ordered_sheets_1_1.done; ordered_sheets_1_1 = ordered_sheets_1.next()) {
163
+ var it_3 = ordered_sheets_1_1.value;
164
+ var sheet_padding = this.get_sheet_symbol_lb_padding(it_3);
165
+ var block_geo = this.block_calc.get_block_geometry(sheet_padding);
166
+ this.convert_sheet_symbol(it_3, block_geo.box, sch, sheet_names_count);
165
167
  }
166
168
  }
167
169
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
168
170
  finally {
169
171
  try {
170
- if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
172
+ if (ordered_sheets_1_1 && !ordered_sheets_1_1.done && (_b = ordered_sheets_1.return)) _b.call(ordered_sheets_1);
171
173
  }
172
174
  finally { if (e_5) throw e_5.error; }
173
175
  }
174
176
  try {
175
177
  // Finally the hierarchical labels
176
- for (var _k = __values(schematic.hiera_labels), _l = _k.next(); !_l.done; _l = _k.next()) {
177
- var it_4 = _l.value;
178
+ for (var _h = __values(schematic.hiera_labels), _j = _h.next(); !_j.done; _j = _h.next()) {
179
+ var it_4 = _j.value;
178
180
  this.convert_hierarchical_label(it_4, sch);
179
181
  }
180
182
  }
181
183
  catch (e_6_1) { e_6 = { error: e_6_1 }; }
182
184
  finally {
183
185
  try {
184
- if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
186
+ if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
185
187
  }
186
188
  finally { if (e_6) throw e_6.error; }
187
189
  }
@@ -190,11 +192,11 @@ var NetListConverter = /** @class */ (function () {
190
192
  };
191
193
  NetListConverter.prototype.convert_hierarchical_label = function (pin, sch) {
192
194
  var _a;
193
- var pin_pos = this.block_calc.get_block_bounding_box({
195
+ var pin_pos = this.block_calc.get_block_geometry({
194
196
  internal: { l_side: 0, r_side: 0 },
195
197
  outer: { l_side: 0, r_side: 0 },
196
198
  total_pin_num: 1,
197
- }).pos;
199
+ }).box.pos;
198
200
  (_a = sch.labels) === null || _a === void 0 ? void 0 : _a.push(gen_hierarchical_label(pin.name, pin_pos, { horizontal: 'left', vertical: 'bottom' }, 0, pin.shape));
199
201
  };
200
202
  NetListConverter.prototype.convert_pwr_symbol = function (pwr, at, sch) {
@@ -206,7 +208,7 @@ var NetListConverter = /** @class */ (function () {
206
208
  sch.symbols.push(sch_pwr_symbol);
207
209
  this.convert_net_label(pwr.value, at, sch);
208
210
  };
209
- NetListConverter.prototype.get_sheet_symbol_paddings = function (sheet_sym) {
211
+ NetListConverter.prototype.get_sheet_symbol_lb_padding = function (sheet_sym) {
210
212
  var factor = {
211
213
  internal: {
212
214
  l_side: 0,
@@ -250,7 +252,7 @@ var NetListConverter = /** @class */ (function () {
250
252
  total_pin_num: sheet_sym.pins.length,
251
253
  };
252
254
  };
253
- NetListConverter.prototype.convert_sheet_symbol = function (sheet_sym, rect, sch, sheet_names_count, outer_padding) {
255
+ NetListConverter.prototype.convert_sheet_symbol = function (sheet_sym, rect, sch, sheet_names_count) {
254
256
  var port_count = sheet_sym.pins.length;
255
257
  var pins = [];
256
258
  for (var i = 0; i < port_count; i++) {
@@ -259,7 +261,7 @@ var NetListConverter = /** @class */ (function () {
259
261
  var y = rect.pos.y + BLOCK_PIN_GAP * ((i < port_count / 2 ? i : i - port_count / 2) + 1);
260
262
  var justify = is_left ? 'left' : 'right';
261
263
  var rotation = is_left ? 180 : 0;
262
- pins.push(this.convert_sheet_pin(sheet_sym.pins[i], { x: x, y: y }, sch, justify, rotation, is_left, is_left ? outer_padding.l_side : outer_padding.r_side));
264
+ pins.push(this.convert_sheet_pin(sheet_sym.pins[i], { x: x, y: y }, sch, justify, rotation, is_left));
263
265
  }
264
266
  var sheet_name = sheet_sym.sheet_name;
265
267
  if (sheet_names_count.has(sheet_name)) {
@@ -275,13 +277,15 @@ var NetListConverter = /** @class */ (function () {
275
277
  Sheetname: sheet_name,
276
278
  }));
277
279
  };
278
- NetListConverter.prototype.convert_sheet_pin = function (pin, pin_pos, sch, horizontal, rotation, is_left, padding) {
280
+ NetListConverter.prototype.convert_sheet_pin = function (pin, pin_pos, sch, horizontal, rotation, is_left) {
279
281
  if (this.pin_is_connected(pin.uuid)) {
280
- this.convert_net_label(this.get_pin_net_name(pin.uuid), {
282
+ var nt_name = this.get_pin_net_name(pin.uuid);
283
+ this.convert_net_label(nt_name, {
281
284
  x: pin_pos.x + (is_left ? -WIRE_PADDING : WIRE_PADDING),
282
285
  y: pin_pos.y,
283
286
  }, sch, horizontal === 'left' ? 'right' : 'left');
284
- var wire_padding = padding + 2 * WIRE_PADDING;
287
+ var lb_txt_len = nt_name.length * FONT_SIZE;
288
+ var wire_padding = lb_txt_len + 2 * WIRE_PADDING;
285
289
  this.wires.push(gen_wire(pin_pos, {
286
290
  x: pin_pos.x + (is_left ? -wire_padding : wire_padding),
287
291
  y: pin_pos.y,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-circuit/transpiler",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "description": "Intermediate representation of the modular circuit",
5
5
  "main": "./build/index.js",
6
6
  "files": [