@modular-circuit/transpiler 0.0.92 → 0.0.94

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.
@@ -1,6 +1,10 @@
1
1
  import type { BOX2 } from '@modular-circuit/electronics-model';
2
2
  export declare const GRID_SIZE: number;
3
3
  export declare const FONT_SIZE: number;
4
+ export declare function get_power_pos(pwr_number: number): {
5
+ x: number;
6
+ y: number;
7
+ };
4
8
  export declare const BLOCK_PIN_GAP: number;
5
9
  export declare const BLOCK_PIN_TB_MARGIN: number;
6
10
  export declare const WIRE_PADDING: number;
@@ -17,24 +21,14 @@ export interface BoxGeometry {
17
21
  box: BOX2;
18
22
  bounding_box: BOX2;
19
23
  }
20
- export declare function get_power_pos(pwr_number: number): {
21
- x: number;
22
- y: number;
23
- };
24
24
  export declare class Layout {
25
- private PAGE_MAX_WIDTH;
26
- private blocks;
27
- private assignments;
28
- add_block(factor: BlockLabelPadding): void;
29
- /**
30
- * PHASE 1: Create provisional columns using greedy online assignment.
31
- */
32
- private initial_column_assign;
33
- /**
34
- * PHASE 2: Rebalance columns globally.
35
- * Produce near-equal column heights for professional appearance.
36
- */
37
- private rebalance_columns;
38
- finalize(): BoxGeometry[];
25
+ private width;
26
+ private height;
27
+ private max_height;
28
+ private current_row_index;
29
+ private current_row_items;
30
+ private flush_row;
31
+ get_block_geometry(factor: BlockLabelPadding): BoxGeometry;
32
+ finalize(): void;
39
33
  }
40
34
  //# 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;AACvC,eAAO,MAAM,SAAS,QAAY,CAAA;AAKlC,eAAO,MAAM,aAAa,QAAgB,CAAA;AAC1C,eAAO,MAAM,mBAAmB,QAAgB,CAAA;AAMhD,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;AAcD,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM;;;EAE/C;AACD,qBAAa,MAAM;IACjB,OAAO,CAAC,cAAc,CAAkC;IAExD,OAAO,CAAC,MAAM,CAAyB;IAGvC,OAAO,CAAC,WAAW,CAAe;IAE3B,SAAS,CAAC,MAAM,EAAE,iBAAiB;IAsB1C;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAwD7B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IA8ClB,QAAQ,IAAI,WAAW,EAAE;CA8CjC"}
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;AAE1C,eAAO,MAAM,mBAAmB,QAAgB,CAAA;AAQhD,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;IAC7B,OAAO,CAAC,MAAM,CAAgB;IAE9B,OAAO,CAAC,UAAU,CAAI;IAEtB,OAAO,CAAC,iBAAiB,CAAI;IAC7B,OAAO,CAAC,iBAAiB,CAA0C;IAEnE,OAAO,CAAC,SAAS;IAwBV,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW;IA4C1D,QAAQ;CAGhB"}
@@ -1,3 +1,28 @@
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
+ if (ar || !(i in from)) {
20
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
+ ar[i] = from[i];
22
+ }
23
+ }
24
+ return to.concat(ar || Array.prototype.slice.call(from));
25
+ };
1
26
  var __values = (this && this.__values) || function(o) {
2
27
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
28
  if (m) return m.call(o);
@@ -13,193 +38,90 @@ import { PAPER_SIZE } from '../../utils/constraints';
13
38
  var MIL_TO_MM = 0.0254;
14
39
  export var GRID_SIZE = 50 * MIL_TO_MM;
15
40
  export var FONT_SIZE = GRID_SIZE;
16
- var BLOCK_START_Y = 5 * GRID_SIZE;
17
- var BLOCK_START_X = 5 * GRID_SIZE;
18
- export var BLOCK_PIN_GAP = 4 * GRID_SIZE;
19
- export var BLOCK_PIN_TB_MARGIN = 2 * GRID_SIZE;
20
- var BLOCK_MARGIN_TOP = 6 * GRID_SIZE;
21
- var BLOCK_MARGIN_LEFT = 4 * GRID_SIZE;
22
- var INTERNAL_LABEL_MARGIN = 3 * FONT_SIZE;
23
- var MIN_BLOCK_WIDTH = 8 * GRID_SIZE;
24
- export var WIRE_PADDING = GRID_SIZE;
25
41
  var POWER_START_Y = 30 * GRID_SIZE;
26
42
  var POWER_START_X = (PAPER_SIZE.A4.height - 30) * GRID_SIZE;
27
43
  var POWER_Y_STEP = 16 * GRID_SIZE;
28
44
  export function get_power_pos(pwr_number) {
29
45
  return { x: POWER_START_X, y: POWER_START_Y + POWER_Y_STEP * pwr_number };
30
46
  }
47
+ var BLOCK_START_Y = GRID_SIZE;
48
+ var BLOCK_START_X = BLOCK_START_Y;
49
+ export var BLOCK_PIN_GAP = 4 * GRID_SIZE;
50
+ export var BLOCK_PIN_TB_MARGIN = 2 * GRID_SIZE;
51
+ var BLOCK_MARGIN_TOP = 8 * GRID_SIZE;
52
+ var MIN_BLOCK_WIDTH = 8 * GRID_SIZE;
53
+ var BLOCK_MARGIN_LEFT = 16 * GRID_SIZE;
54
+ var BLOCK_MARGIN_RIGHT = BLOCK_MARGIN_LEFT;
55
+ var INTERNAL_LABEL_MARGIN = 8 * FONT_SIZE;
56
+ export var WIRE_PADDING = GRID_SIZE;
31
57
  var Layout = /** @class */ (function () {
32
58
  function Layout() {
33
- this.PAGE_MAX_WIDTH = PAPER_SIZE.A4.width * GRID_SIZE;
34
- this.blocks = [];
35
- // Provisional placement: column index for each block
36
- this.assignments = [];
59
+ this.width = BLOCK_START_X;
60
+ this.height = BLOCK_START_Y;
61
+ this.max_height = 0;
62
+ this.current_row_index = 0;
63
+ this.current_row_items = [];
37
64
  }
38
- Layout.prototype.add_block = function (factor) {
39
- var block_height = Math.floor(factor.total_pin_num / 2) * BLOCK_PIN_GAP + 2 * BLOCK_PIN_TB_MARGIN;
40
- var block_width = Math.max(MIN_BLOCK_WIDTH, factor.internal.l_side + factor.internal.r_side + INTERNAL_LABEL_MARGIN);
41
- var bounding_width = Math.max(block_width, factor.internal.l_side + factor.internal.r_side + factor.outer.l_side + factor.outer.r_side + WIRE_PADDING * 2);
42
- var measurement = {
43
- block_width: block_width,
44
- bounding_width: bounding_width,
45
- height: block_height,
46
- };
47
- this.blocks.push(measurement);
48
- };
49
- /**
50
- * PHASE 1: Create provisional columns using greedy online assignment.
51
- */
52
- Layout.prototype.initial_column_assign = function () {
53
- var cols = [];
54
- for (var i = 0; i < this.blocks.length; i++) {
55
- var b = this.blocks[i];
56
- if (cols.length === 0) {
57
- cols.push({ height: 0, width: b.bounding_width });
58
- this.assignments.push(0);
59
- cols[0].height += b.height + BLOCK_MARGIN_TOP;
60
- cols[0].width = Math.max(cols[0].width, b.bounding_width);
61
- continue;
62
- }
63
- // find shortest column
64
- var bestIdx = 0;
65
- for (var c = 1; c < cols.length; c++) {
66
- if (cols[c].height < cols[bestIdx].height)
67
- bestIdx = c;
68
- }
69
- var best = cols[bestIdx];
70
- var newColWidth = Math.max(best.width, b.bounding_width);
71
- // Check if expanding this column fits page width
72
- var currentTotalWidth = cols.reduce(function (s, c) { return s + c.width; }, 0) + BLOCK_MARGIN_LEFT * (cols.length - 1);
73
- var totalIfExpand = currentTotalWidth - best.width + newColWidth;
74
- if (totalIfExpand <= this.PAGE_MAX_WIDTH - BLOCK_START_X) {
75
- // expand best column
76
- best.width = newColWidth;
77
- this.assignments.push(bestIdx);
78
- best.height += b.height + BLOCK_MARGIN_TOP;
79
- }
80
- else {
81
- // try new column
82
- var widthIfNew = currentTotalWidth + BLOCK_MARGIN_LEFT + b.bounding_width;
83
- if (widthIfNew <= this.PAGE_MAX_WIDTH - BLOCK_START_X) {
84
- cols.push({
85
- height: b.height + BLOCK_MARGIN_TOP,
86
- width: b.bounding_width,
87
- });
88
- this.assignments.push(cols.length - 1);
89
- }
90
- else {
91
- // fallback: place in best column even if slightly overflowing
92
- best.width = newColWidth;
93
- this.assignments.push(bestIdx);
94
- best.height += b.height + BLOCK_MARGIN_TOP;
95
- }
96
- }
97
- }
98
- return cols;
99
- };
100
- /**
101
- * PHASE 2: Rebalance columns globally.
102
- * Produce near-equal column heights for professional appearance.
103
- */
104
- Layout.prototype.rebalance_columns = function (initialCols) {
105
- var _this = this;
106
- var colCount = initialCols.length;
107
- var itemsPerColumn = Array.from({ length: colCount }, function () { return []; });
108
- for (var i = 0; i < this.blocks.length; i++) {
109
- itemsPerColumn[this.assignments[i]].push(i);
110
- }
111
- // Compute heights per column
112
- var heights = itemsPerColumn.map(function (colIndices) {
113
- return colIndices.reduce(function (sum, idx) { return sum + _this.blocks[idx].height + BLOCK_MARGIN_TOP; }, 0);
114
- });
115
- // Simple redistribution: move from tallest to shortest until balanced
116
- var changed = true;
117
- while (changed) {
118
- changed = false;
119
- // Find tallest & shortest
120
- var maxIdx = 0;
121
- var minIdx = 0;
122
- for (var i = 1; i < colCount; i++) {
123
- if (heights[i] > heights[maxIdx])
124
- maxIdx = i;
125
- if (heights[i] < heights[minIdx])
126
- minIdx = i;
127
- }
128
- if (heights[maxIdx] - heights[minIdx] < BLOCK_MARGIN_TOP * 2)
129
- break; // good enough
130
- // Move one block (the last one) from max column to min column
131
- var from = itemsPerColumn[maxIdx];
132
- if (from.length <= 1)
133
- break;
134
- var idxToMove = from.pop();
135
- var b = this.blocks[idxToMove];
136
- heights[maxIdx] -= b.height + BLOCK_MARGIN_TOP;
137
- itemsPerColumn[minIdx].push(idxToMove);
138
- heights[minIdx] += b.height + BLOCK_MARGIN_TOP;
139
- this.assignments[idxToMove] = minIdx;
140
- changed = true;
141
- }
142
- return itemsPerColumn;
143
- };
144
- Layout.prototype.finalize = function () {
145
- var e_1, _a, e_2, _b;
146
- var initialCols = this.initial_column_assign();
147
- var itemsPerColumn = this.rebalance_columns(initialCols);
148
- var colCount = itemsPerColumn.length;
149
- // Recompute column widths after rebalancing
150
- var finalColWidths = new Array(colCount).fill(0);
151
- for (var c = 0; c < colCount; c++) {
65
+ Layout.prototype.flush_row = function () {
66
+ var e_1, _a;
67
+ if (this.current_row_items.length === 0)
68
+ return;
69
+ // If this row is odd: apply right-to-left packing
70
+ var rtl = this.current_row_index % 2 === 1;
71
+ if (rtl) {
72
+ // right-most limit
73
+ var cursor = POWER_START_X - BLOCK_MARGIN_RIGHT;
152
74
  try {
153
- for (var _c = (e_1 = void 0, __values(itemsPerColumn[c])), _d = _c.next(); !_d.done; _d = _c.next()) {
154
- var idx = _d.value;
155
- finalColWidths[c] = Math.max(finalColWidths[c], this.blocks[idx].bounding_width);
75
+ for (var _b = __values(__spreadArray([], __read(this.current_row_items), false).reverse()), _c = _b.next(); !_c.done; _c = _b.next()) {
76
+ var item = _c.value;
77
+ var w = item.bounding_box.size.x;
78
+ cursor -= w;
79
+ item.box.pos.x = cursor;
80
+ item.bounding_box.pos.x = cursor;
81
+ cursor -= BLOCK_MARGIN_LEFT;
156
82
  }
157
83
  }
158
84
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
159
85
  finally {
160
86
  try {
161
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
87
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
162
88
  }
163
89
  finally { if (e_1) throw e_1.error; }
164
90
  }
165
91
  }
166
- // Compute X positions
167
- var colX = [];
168
- var x = BLOCK_START_X;
169
- for (var c = 0; c < colCount; c++) {
170
- colX[c] = x;
171
- x += finalColWidths[c] + BLOCK_MARGIN_LEFT;
172
- }
173
- // Produce final coordinates
174
- var result = new Array(this.blocks.length);
175
- var colY = new Array(colCount).fill(BLOCK_START_Y);
176
- for (var c = 0; c < colCount; c++) {
177
- try {
178
- for (var _e = (e_2 = void 0, __values(itemsPerColumn[c])), _f = _e.next(); !_f.done; _f = _e.next()) {
179
- var idx = _f.value;
180
- var b = this.blocks[idx];
181
- result[idx] = {
182
- box: {
183
- pos: { x: colX[c], y: colY[c] },
184
- size: { x: b.block_width, y: b.height },
185
- },
186
- bounding_box: {
187
- pos: { x: colX[c], y: colY[c] },
188
- size: { x: finalColWidths[c], y: b.height },
189
- },
190
- };
191
- colY[c] += b.height + BLOCK_MARGIN_TOP;
192
- }
193
- }
194
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
195
- finally {
196
- try {
197
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
198
- }
199
- finally { if (e_2) throw e_2.error; }
200
- }
92
+ // row finished → move to next
93
+ this.current_row_items = [];
94
+ this.current_row_index++;
95
+ };
96
+ Layout.prototype.get_block_geometry = function (factor) {
97
+ var block_height = Math.floor(factor.total_pin_num / 2) * BLOCK_PIN_GAP + 2 * BLOCK_PIN_TB_MARGIN;
98
+ var block_width = Math.max(MIN_BLOCK_WIDTH, factor.internal.l_side + factor.internal.r_side + INTERNAL_LABEL_MARGIN);
99
+ var block_bounding_width = Math.max(block_width, factor.internal.l_side + factor.internal.r_side + factor.outer.l_side + factor.outer.r_side + WIRE_PADDING * 4);
100
+ var box = {
101
+ pos: { x: this.width, y: this.height },
102
+ size: { x: block_width, y: block_height },
103
+ };
104
+ var bounding_box = {
105
+ pos: { x: this.width, y: this.height },
106
+ size: { x: block_bounding_width, y: block_height },
107
+ };
108
+ this.current_row_items.push({ box: box, bounding_box: bounding_box });
109
+ this.max_height = Math.max(this.max_height, block_height);
110
+ // compute next X
111
+ this.width += block_bounding_width + BLOCK_MARGIN_LEFT;
112
+ // Row break?
113
+ if (this.width + BLOCK_MARGIN_RIGHT + MIN_BLOCK_WIDTH + BLOCK_MARGIN_LEFT > POWER_START_X) {
114
+ this.flush_row();
115
+ // reset for next row
116
+ this.width = BLOCK_START_X;
117
+ this.height += this.max_height + BLOCK_MARGIN_TOP;
118
+ this.max_height = 0;
201
119
  }
202
- return result;
120
+ return { box: box, bounding_box: bounding_box };
121
+ };
122
+ // When all blocks processed, call this
123
+ Layout.prototype.finalize = function () {
124
+ this.flush_row();
203
125
  };
204
126
  return Layout;
205
127
  }());
@@ -2,6 +2,7 @@ import { type SCHEMATIC } from '@modular-circuit/ir';
2
2
  import type { NetlistToKicadContext } from './context';
3
3
  export declare class NetListConverter {
4
4
  private ctx;
5
+ private block_calc;
5
6
  private sheet_pwr_count;
6
7
  private net_name;
7
8
  private wires;
@@ -17,6 +18,7 @@ export declare class NetListConverter {
17
18
  * @returns
18
19
  */
19
20
  private convert_sch;
21
+ private convert_hierarchical_label;
20
22
  private convert_pwr_symbol;
21
23
  private get_sheet_symbol_lb_padding;
22
24
  private convert_sheet_symbol;
@@ -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;IAOR,OAAO,CAAC,GAAG;IAN9B,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;IAWvB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAqFnB,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,2BAA2B;IA+CnC,OAAO,CAAC,oBAAoB;IAsC5B,OAAO,CAAC,iBAAiB;IAgCzB,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;IAgEnB,OAAO,CAAC,0BAA0B;IAYlC,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,2BAA2B;IA+CnC,OAAO,CAAC,oBAAoB;IAsC5B,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,iBAAiB;CAQ1B"}
@@ -80,6 +80,7 @@ var NetListConverter = /** @class */ (function () {
80
80
  for (var _b = __values(Object.entries(this.ctx.netlist.schematics)), _c = _b.next(); !_c.done; _c = _b.next()) {
81
81
  var _d = __read(_c.value, 2), k = _d[0], v = _d[1];
82
82
  this.sheet_pwr_count = 0;
83
+ this.block_calc = new Layout();
83
84
  all_sch[k] = this.convert_sch(k, v);
84
85
  }
85
86
  }
@@ -100,8 +101,8 @@ var NetListConverter = /** @class */ (function () {
100
101
  * @returns
101
102
  */
102
103
  NetListConverter.prototype.convert_sch = function (name, schematic) {
103
- var e_4, _a, e_5, _b;
104
- var _c, _d;
104
+ var e_4, _a, e_5, _b, e_6, _c;
105
+ var _d, _e;
105
106
  var powers = new Set();
106
107
  this.wires = [];
107
108
  var sch = {
@@ -130,15 +131,15 @@ var NetListConverter = /** @class */ (function () {
130
131
  sheets: [],
131
132
  };
132
133
  try {
133
- for (var _e = __values(schematic.powers), _f = _e.next(); !_f.done; _f = _e.next()) {
134
- var it_2 = _f.value;
134
+ for (var _f = __values(schematic.powers), _g = _f.next(); !_g.done; _g = _f.next()) {
135
+ var it_2 = _g.value;
135
136
  if (!powers.has(it_2.value)) {
136
137
  switch (it_2.shape) {
137
138
  case PowerShape.VCC:
138
- (_c = sch.lib_symbols) === null || _c === void 0 ? void 0 : _c.symbols.push(gen_lib_vcc(it_2.value));
139
+ (_d = sch.lib_symbols) === null || _d === void 0 ? void 0 : _d.symbols.push(gen_lib_vcc(it_2.value));
139
140
  break;
140
141
  case PowerShape.GND:
141
- (_d = sch.lib_symbols) === null || _d === void 0 ? void 0 : _d.symbols.push(gen_lib_gnd(it_2.value));
142
+ (_e = sch.lib_symbols) === null || _e === void 0 ? void 0 : _e.symbols.push(gen_lib_gnd(it_2.value));
142
143
  break;
143
144
  }
144
145
  powers.add(it_2.value);
@@ -149,7 +150,7 @@ var NetListConverter = /** @class */ (function () {
149
150
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
150
151
  finally {
151
152
  try {
152
- if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
153
+ if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
153
154
  }
154
155
  finally { if (e_4) throw e_4.error; }
155
156
  }
@@ -157,12 +158,12 @@ var NetListConverter = /** @class */ (function () {
157
158
  var ordered_sheets = schematic.sheet_symbols.sort(function (a, b) {
158
159
  return b.pins.length - a.pins.length;
159
160
  });
160
- var layout = new Layout();
161
161
  try {
162
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
163
  var it_3 = ordered_sheets_1_1.value;
164
164
  var sheet_padding = this.get_sheet_symbol_lb_padding(it_3);
165
- layout.add_block(sheet_padding);
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);
166
167
  }
167
168
  }
168
169
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
@@ -172,28 +173,32 @@ var NetListConverter = /** @class */ (function () {
172
173
  }
173
174
  finally { if (e_5) throw e_5.error; }
174
175
  }
175
- var result = layout.finalize();
176
- for (var i = 0; i < ordered_sheets.length; i++) {
177
- var sheet_sym = ordered_sheets[i];
178
- var rect = result[i].box;
179
- this.convert_sheet_symbol(sheet_sym, rect, sch, sheet_names_count);
176
+ try {
177
+ for (var _h = __values(schematic.hiera_labels), _j = _h.next(); !_j.done; _j = _h.next()) {
178
+ var it_4 = _j.value;
179
+ this.convert_hierarchical_label(it_4, sch);
180
+ }
180
181
  }
181
- // for (const it of schematic.hiera_labels) {
182
- // this.convert_hierarchical_label(it, sch)
183
- // }
182
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
183
+ finally {
184
+ try {
185
+ if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
186
+ }
187
+ finally { if (e_6) throw e_6.error; }
188
+ }
189
+ this.block_calc.finalize();
184
190
  sch.wires = this.wires;
185
191
  return sch;
186
192
  };
187
- // private convert_hierarchical_label(pin: NL_HierarchicalLabel, sch: SCHEMATIC) {
188
- // const layout = new Layout()
189
- // layout.add_block({
190
- // internal: { l_side: 0, r_side: 0 },
191
- // outer: { l_side: 0, r_side: 0 },
192
- // total_pin_num: 1,
193
- // })
194
- // const pos = layout.finalize()[0].box.pos
195
- // sch.labels?.push(gen_hierarchical_label(pin.name, pos, { horizontal: 'left', vertical: 'bottom' }, 0, pin.shape))
196
- // }
193
+ NetListConverter.prototype.convert_hierarchical_label = function (pin, sch) {
194
+ var _a;
195
+ var pin_pos = this.block_calc.get_block_geometry({
196
+ internal: { l_side: 0, r_side: 0 },
197
+ outer: { l_side: 0, r_side: 0 },
198
+ total_pin_num: 1,
199
+ }).box.pos;
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));
201
+ };
197
202
  NetListConverter.prototype.convert_pwr_symbol = function (pwr, at, sch) {
198
203
  // NOTE : The power uuid is used as the uuid of its pin ,cause all power symbols have only one pin
199
204
  var pin_id = pwr.uuid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-circuit/transpiler",
3
- "version": "0.0.92",
3
+ "version": "0.0.94",
4
4
  "description": "Intermediate representation of the modular circuit",
5
5
  "main": "./build/index.js",
6
6
  "files": [
@@ -27,9 +27,9 @@
27
27
  "js-base64": "^3.7.7",
28
28
  "jszip": "^3.10.1",
29
29
  "@modular-circuit/electronics-model": "0.0.54",
30
- "@modular-circuit/perc": "0.0.61",
31
30
  "@modular-circuit/ir": "0.0.63",
32
- "@modular-circuit/utils": "0.0.41"
31
+ "@modular-circuit/utils": "0.0.41",
32
+ "@modular-circuit/perc": "0.0.61"
33
33
  },
34
34
  "scripts": {
35
35
  "clean": "rimraf build",