@modular-circuit/transpiler 0.2.9 → 0.2.10

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.
package/dist/index.d.mts CHANGED
@@ -378,17 +378,6 @@ declare function collect_sub_sheets(dependencies: Record<string, string>, module
378
378
  modules: Record<string, ModuleCircuit>;
379
379
  }>;
380
380
 
381
- interface Size {
382
- height: number;
383
- width: number;
384
- }
385
- declare const PAPER_SIZE: Record<string, Size>;
386
- declare const DEFAULT_PAPER_SIZE: Size;
387
- declare const GENERATOR_NAME = "modular_circuit";
388
- declare const SCH_VERSION = 20231120;
389
- declare const PAPER = "A4";
390
- declare const GENERATOR_VERSION = "8.0";
391
-
392
381
  declare function filterNullOrUndefined(originalMethod: unknown, _context: ClassMethodDecoratorContext): (this: unknown, ...args: unknown[]) => any;
393
382
 
394
383
  declare const tab = "\t";
@@ -425,4 +414,4 @@ declare const gen_sch_gnd: (value: string, pwr_number: number, port_id: string,
425
414
 
426
415
  declare const gen_sch_vcc: (value: string, pwr_number: number, port_id: string, position: VECTOR2) => SCH_SYMBOL;
427
416
 
428
- export { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, DEFAULT_PAPER_SIZE, FONT_SIZE, GENERATOR_NAME, GENERATOR_VERSION, GRID_SIZE, GraphConverter, KICAD_SCH_FRAME, KiCadProjectArchive, type LabelPadding, Layout, NetListConverter, type NetlistProject, type NetlistToKicadContext, PAPER, PAPER_SIZE, SCHEMATIC_PRINTER, SCH_VERSION, type Size, StringFormatter, WIRE_PADDING, collect_sub_sheets, collect_sub_sheets_by_id, convert_graph_to_design_block, convert_graph_to_kicad_project, convert_graph_to_sheets, filterNullOrUndefined, fmt_module_place_holder_sch_name, fmt_to_valid_filename, gen_empty_sch, gen_lib_gnd, gen_lib_vcc, gen_sch_gnd, gen_sch_vcc, get_power_pos, get_sch_default_drawing_sheet, tab };
417
+ export { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, FONT_SIZE, GRID_SIZE, GraphConverter, KICAD_SCH_FRAME, KiCadProjectArchive, type LabelPadding, Layout, NetListConverter, type NetlistProject, type NetlistToKicadContext, SCHEMATIC_PRINTER, StringFormatter, WIRE_PADDING, collect_sub_sheets, collect_sub_sheets_by_id, convert_graph_to_design_block, convert_graph_to_kicad_project, convert_graph_to_sheets, filterNullOrUndefined, fmt_module_place_holder_sch_name, fmt_to_valid_filename, gen_empty_sch, gen_lib_gnd, gen_lib_vcc, gen_sch_gnd, gen_sch_vcc, get_power_pos, get_sch_default_drawing_sheet, tab };
package/dist/index.d.ts CHANGED
@@ -378,17 +378,6 @@ declare function collect_sub_sheets(dependencies: Record<string, string>, module
378
378
  modules: Record<string, ModuleCircuit>;
379
379
  }>;
380
380
 
381
- interface Size {
382
- height: number;
383
- width: number;
384
- }
385
- declare const PAPER_SIZE: Record<string, Size>;
386
- declare const DEFAULT_PAPER_SIZE: Size;
387
- declare const GENERATOR_NAME = "modular_circuit";
388
- declare const SCH_VERSION = 20231120;
389
- declare const PAPER = "A4";
390
- declare const GENERATOR_VERSION = "8.0";
391
-
392
381
  declare function filterNullOrUndefined(originalMethod: unknown, _context: ClassMethodDecoratorContext): (this: unknown, ...args: unknown[]) => any;
393
382
 
394
383
  declare const tab = "\t";
@@ -425,4 +414,4 @@ declare const gen_sch_gnd: (value: string, pwr_number: number, port_id: string,
425
414
 
426
415
  declare const gen_sch_vcc: (value: string, pwr_number: number, port_id: string, position: VECTOR2) => SCH_SYMBOL;
427
416
 
428
- export { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, DEFAULT_PAPER_SIZE, FONT_SIZE, GENERATOR_NAME, GENERATOR_VERSION, GRID_SIZE, GraphConverter, KICAD_SCH_FRAME, KiCadProjectArchive, type LabelPadding, Layout, NetListConverter, type NetlistProject, type NetlistToKicadContext, PAPER, PAPER_SIZE, SCHEMATIC_PRINTER, SCH_VERSION, type Size, StringFormatter, WIRE_PADDING, collect_sub_sheets, collect_sub_sheets_by_id, convert_graph_to_design_block, convert_graph_to_kicad_project, convert_graph_to_sheets, filterNullOrUndefined, fmt_module_place_holder_sch_name, fmt_to_valid_filename, gen_empty_sch, gen_lib_gnd, gen_lib_vcc, gen_sch_gnd, gen_sch_vcc, get_power_pos, get_sch_default_drawing_sheet, tab };
417
+ export { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, type BlockLabelPadding, type BlockSize, type BoxGeometry, type ConnectionGraphMap, type ConvertGraphToKiCadContext, type ConvertGraphToKiCadInput, FONT_SIZE, GRID_SIZE, GraphConverter, KICAD_SCH_FRAME, KiCadProjectArchive, type LabelPadding, Layout, NetListConverter, type NetlistProject, type NetlistToKicadContext, SCHEMATIC_PRINTER, StringFormatter, WIRE_PADDING, collect_sub_sheets, collect_sub_sheets_by_id, convert_graph_to_design_block, convert_graph_to_kicad_project, convert_graph_to_sheets, filterNullOrUndefined, fmt_module_place_holder_sch_name, fmt_to_valid_filename, gen_empty_sch, gen_lib_gnd, gen_lib_vcc, gen_sch_gnd, gen_sch_vcc, get_power_pos, get_sch_default_drawing_sheet, tab };
package/dist/index.js CHANGED
@@ -76,20 +76,14 @@ var index_exports = {};
76
76
  __export(index_exports, {
77
77
  BLOCK_PIN_GAP: () => BLOCK_PIN_GAP,
78
78
  BLOCK_PIN_TB_MARGIN: () => BLOCK_PIN_TB_MARGIN,
79
- DEFAULT_PAPER_SIZE: () => DEFAULT_PAPER_SIZE,
80
79
  FONT_SIZE: () => FONT_SIZE,
81
- GENERATOR_NAME: () => GENERATOR_NAME,
82
- GENERATOR_VERSION: () => GENERATOR_VERSION,
83
80
  GRID_SIZE: () => GRID_SIZE,
84
81
  GraphConverter: () => GraphConverter,
85
82
  KICAD_SCH_FRAME: () => KICAD_SCH_FRAME,
86
83
  KiCadProjectArchive: () => KiCadProjectArchive,
87
84
  Layout: () => Layout,
88
85
  NetListConverter: () => NetListConverter,
89
- PAPER: () => PAPER,
90
- PAPER_SIZE: () => PAPER_SIZE,
91
86
  SCHEMATIC_PRINTER: () => SCHEMATIC_PRINTER,
92
- SCH_VERSION: () => SCH_VERSION,
93
87
  StringFormatter: () => StringFormatter,
94
88
  WIRE_PADDING: () => WIRE_PADDING,
95
89
  collect_sub_sheets: () => collect_sub_sheets,
@@ -172,24 +166,6 @@ async function collect_sub_sheets(dependencies, module_resolver) {
172
166
  return { sheets, module_main_sheet, modules };
173
167
  }
174
168
 
175
- // src/utils/constraints.ts
176
- var PAPER_SIZE = {
177
- A0: { width: 841, height: 1189 },
178
- A1: { width: 594, height: 841 },
179
- A2: { width: 420, height: 594 },
180
- A3: { width: 297, height: 420 },
181
- A4: { width: 210, height: 297 },
182
- A5: { width: 148, height: 210 },
183
- A6: { width: 105, height: 148 },
184
- A7: { width: 74, height: 105 },
185
- A8: { width: 52, height: 74 }
186
- };
187
- var DEFAULT_PAPER_SIZE = PAPER_SIZE.A4;
188
- var GENERATOR_NAME = "modular_circuit";
189
- var SCH_VERSION = 20231120;
190
- var PAPER = "A4";
191
- var GENERATOR_VERSION = "8.0";
192
-
193
169
  // src/utils/filter_null_undefined.ts
194
170
  function filterNullOrUndefined(originalMethod, _context) {
195
171
  function replacementMethod(...args) {
@@ -353,11 +329,11 @@ var SCHEMATIC_PRINTER = class {
353
329
  })();
354
330
  return `
355
331
  (kicad_sch
356
- (version ${SCH_VERSION})
357
- (generator "${GENERATOR_NAME}")
358
- (generator_version "${GENERATOR_VERSION}")
332
+ (version ${import_utils4.SCH_VERSION})
333
+ (generator "${import_utils4.GENERATOR_NAME}")
334
+ (generator_version "${import_utils4.GENERATOR_VERSION}")
359
335
  (uuid "${(0, import_utils4.gen_uuid)()}")
360
- (paper "${PAPER}")
336
+ (paper "${import_utils4.PAPER}")
361
337
  ${lib_symbols}
362
338
  ${wires}
363
339
  ${labels}
@@ -1835,12 +1811,13 @@ var GraphConverter = class {
1835
1811
  };
1836
1812
 
1837
1813
  // src/converter/netlist_to_kicad/layout.ts
1814
+ var import_utils6 = require("@modular-circuit/utils");
1838
1815
  var import_elk_bundled = __toESM(require("elkjs/lib/elk.bundled.js"));
1839
1816
  var MIL_TO_MM = 0.0254;
1840
1817
  var GRID_SIZE = 50 * MIL_TO_MM;
1841
1818
  var FONT_SIZE = GRID_SIZE;
1842
1819
  var POWER_START_Y = 30 * GRID_SIZE;
1843
- var POWER_START_X = (PAPER_SIZE.A4.height - 30) * GRID_SIZE;
1820
+ var POWER_START_X = (import_utils6.PAPER_SIZE.A4.height - 30) * GRID_SIZE;
1844
1821
  var POWER_Y_STEP = 16 * GRID_SIZE;
1845
1822
  var BLOCK_V_SPACE = 8 * GRID_SIZE;
1846
1823
  var BLOCK_H_SPACE = 14 * GRID_SIZE - BLOCK_V_SPACE;
@@ -1878,8 +1855,8 @@ var Layout = class {
1878
1855
  "org.eclipse.elk.aspectRatio": "1.414",
1879
1856
  "elk.spacing.nodeNode": `${BLOCK_V_SPACE}`,
1880
1857
  "elk.padding": `[top=${PADDING_TOP},left=${PADDING},bottom=${PADDING},right=${PADDING}]`,
1881
- "elk.childAreaWidth": `${PAPER_SIZE.A4.height}`,
1882
- "elk.childAreaHeight": `${PAPER_SIZE.A4.width}`
1858
+ "elk.childAreaWidth": `${import_utils6.PAPER_SIZE.A4.height}`,
1859
+ "elk.childAreaHeight": `${import_utils6.PAPER_SIZE.A4.width}`
1883
1860
  },
1884
1861
  children: [],
1885
1862
  edges: []
@@ -1938,10 +1915,10 @@ var Layout = class {
1938
1915
  // src/converter/netlist_to_kicad/netlist_converter.ts
1939
1916
  var import_electronics_model8 = require("@modular-circuit/electronics-model");
1940
1917
  var import_ir4 = require("@modular-circuit/ir");
1941
- var import_utils14 = require("@modular-circuit/utils");
1918
+ var import_utils15 = require("@modular-circuit/utils");
1942
1919
 
1943
1920
  // src/kicad/label/net_label.ts
1944
- var import_utils6 = require("@modular-circuit/utils");
1921
+ var import_utils7 = require("@modular-circuit/utils");
1945
1922
  var gen_net_label = (name, at, justify) => ({
1946
1923
  label_type: "label",
1947
1924
  text: name,
@@ -1949,23 +1926,23 @@ var gen_net_label = (name, at, justify) => ({
1949
1926
  fields_autoplaced: true,
1950
1927
  at: { position: at, rotation: 0 },
1951
1928
  effects: {
1952
- font: { size: import_utils6.DEFAULT_FONT_SIZE },
1929
+ font: { size: import_utils7.DEFAULT_FONT_SIZE },
1953
1930
  justify
1954
1931
  },
1955
- uuid: (0, import_utils6.gen_uuid)()
1932
+ uuid: (0, import_utils7.gen_uuid)()
1956
1933
  });
1957
1934
 
1958
1935
  // src/kicad/label/sheet_pin.ts
1959
- var import_utils7 = require("@modular-circuit/utils");
1936
+ var import_utils8 = require("@modular-circuit/utils");
1960
1937
  var gen_base_hierarchical_label = (text, at, justify, rotation, shape) => ({
1961
1938
  shape,
1962
1939
  effects: {
1963
- font: { size: import_utils7.DEFAULT_FONT_SIZE },
1940
+ font: { size: import_utils8.DEFAULT_FONT_SIZE },
1964
1941
  justify
1965
1942
  },
1966
1943
  text,
1967
1944
  at: { position: at, rotation },
1968
- uuid: (0, import_utils7.gen_uuid)()
1945
+ uuid: (0, import_utils8.gen_uuid)()
1969
1946
  });
1970
1947
  var gen_sheet_pin = (text, at, justify, rotation, shape) => ({
1971
1948
  label_type: "hierarchical_label",
@@ -1974,7 +1951,7 @@ var gen_sheet_pin = (text, at, justify, rotation, shape) => ({
1974
1951
  var gen_hierarchical_label = gen_sheet_pin;
1975
1952
 
1976
1953
  // src/kicad/sheet/sheet.ts
1977
- var import_utils8 = require("@modular-circuit/utils");
1954
+ var import_utils9 = require("@modular-circuit/utils");
1978
1955
  var TEXT_MARGIN = 0.7116;
1979
1956
  var gen_sch_sheet = (rect, pins, fields) => ({
1980
1957
  // NOTE no rotation in the sheet
@@ -1987,7 +1964,7 @@ var gen_sch_sheet = (rect, pins, fields) => ({
1987
1964
  text: fields.Sheetname,
1988
1965
  at: { position: { x: rect.pos.x, y: rect.pos.y - TEXT_MARGIN }, rotation: 0 },
1989
1966
  effects: {
1990
- font: { size: import_utils8.DEFAULT_FONT_SIZE },
1967
+ font: { size: import_utils9.DEFAULT_FONT_SIZE },
1991
1968
  justify: {
1992
1969
  vertical: "bottom",
1993
1970
  horizontal: "left"
@@ -1999,7 +1976,7 @@ var gen_sch_sheet = (rect, pins, fields) => ({
1999
1976
  text: fields.Sheetfile,
2000
1977
  at: { position: { x: rect.pos.x, y: rect.pos.y + rect.size.y + TEXT_MARGIN }, rotation: 0 },
2001
1978
  effects: {
2002
- font: { size: import_utils8.DEFAULT_FONT_SIZE },
1979
+ font: { size: import_utils9.DEFAULT_FONT_SIZE },
2003
1980
  justify: {
2004
1981
  vertical: "top",
2005
1982
  horizontal: "left"
@@ -2015,13 +1992,13 @@ var gen_sch_sheet = (rect, pins, fields) => ({
2015
1992
  fill: {
2016
1993
  color: { r: 0, g: 0, b: 0, a: 0 }
2017
1994
  },
2018
- uuid: (0, import_utils8.gen_uuid)()
1995
+ uuid: (0, import_utils9.gen_uuid)()
2019
1996
  });
2020
1997
 
2021
1998
  // src/kicad/symbols/lib_symbol/gnd.ts
2022
1999
  var import_electronics_model5 = require("@modular-circuit/electronics-model");
2023
2000
  var import_ir2 = require("@modular-circuit/ir");
2024
- var import_utils9 = require("@modular-circuit/utils");
2001
+ var import_utils10 = require("@modular-circuit/utils");
2025
2002
  var gen_lib_gnd = (value) => ({
2026
2003
  name: `power:${value}`,
2027
2004
  pin_numbers: {
@@ -2041,7 +2018,7 @@ var gen_lib_gnd = (value) => ({
2041
2018
  text: "#PWR",
2042
2019
  at: { position: { x: 0, y: -6.35 }, rotation: 0 },
2043
2020
  effects: {
2044
- font: { size: import_utils9.DEFAULT_FONT_SIZE },
2021
+ font: { size: import_utils10.DEFAULT_FONT_SIZE },
2045
2022
  hide: true
2046
2023
  }
2047
2024
  },
@@ -2050,7 +2027,7 @@ var gen_lib_gnd = (value) => ({
2050
2027
  text: `${value}`,
2051
2028
  at: { position: { x: 0, y: -3.81 }, rotation: 0 },
2052
2029
  effects: {
2053
- font: { size: import_utils9.DEFAULT_FONT_SIZE }
2030
+ font: { size: import_utils10.DEFAULT_FONT_SIZE }
2054
2031
  }
2055
2032
  },
2056
2033
  {
@@ -2058,7 +2035,7 @@ var gen_lib_gnd = (value) => ({
2058
2035
  text: "",
2059
2036
  at: { position: { x: 0, y: 0 }, rotation: 0 },
2060
2037
  effects: {
2061
- font: { size: import_utils9.DEFAULT_FONT_SIZE },
2038
+ font: { size: import_utils10.DEFAULT_FONT_SIZE },
2062
2039
  hide: true
2063
2040
  }
2064
2041
  },
@@ -2067,7 +2044,7 @@ var gen_lib_gnd = (value) => ({
2067
2044
  text: "",
2068
2045
  at: { position: { x: 0, y: 0 }, rotation: 0 },
2069
2046
  effects: {
2070
- font: { size: import_utils9.DEFAULT_FONT_SIZE },
2047
+ font: { size: import_utils10.DEFAULT_FONT_SIZE },
2071
2048
  hide: true
2072
2049
  }
2073
2050
  },
@@ -2076,7 +2053,7 @@ var gen_lib_gnd = (value) => ({
2076
2053
  text: 'Power symbol creates a global label with name \\"GND\\" , ground',
2077
2054
  at: { position: { x: 0, y: 0 }, rotation: 0 },
2078
2055
  effects: {
2079
- font: { size: import_utils9.DEFAULT_FONT_SIZE },
2056
+ font: { size: import_utils10.DEFAULT_FONT_SIZE },
2080
2057
  hide: true
2081
2058
  }
2082
2059
  },
@@ -2085,7 +2062,7 @@ var gen_lib_gnd = (value) => ({
2085
2062
  text: "global power",
2086
2063
  at: { position: { x: 0, y: 0 }, rotation: 0 },
2087
2064
  effects: {
2088
- font: { size: import_utils9.DEFAULT_FONT_SIZE },
2065
+ font: { size: import_utils10.DEFAULT_FONT_SIZE },
2089
2066
  hide: true
2090
2067
  }
2091
2068
  }
@@ -2126,13 +2103,13 @@ var gen_lib_gnd = (value) => ({
2126
2103
  name: {
2127
2104
  text: "~",
2128
2105
  effects: {
2129
- font: { size: import_utils9.DEFAULT_FONT_SIZE }
2106
+ font: { size: import_utils10.DEFAULT_FONT_SIZE }
2130
2107
  }
2131
2108
  },
2132
2109
  number: {
2133
2110
  text: "1",
2134
2111
  effects: {
2135
- font: { size: import_utils9.DEFAULT_FONT_SIZE }
2112
+ font: { size: import_utils10.DEFAULT_FONT_SIZE }
2136
2113
  }
2137
2114
  }
2138
2115
  }
@@ -2144,7 +2121,7 @@ var gen_lib_gnd = (value) => ({
2144
2121
  // src/kicad/symbols/lib_symbol/vcc.ts
2145
2122
  var import_electronics_model6 = require("@modular-circuit/electronics-model");
2146
2123
  var import_ir3 = require("@modular-circuit/ir");
2147
- var import_utils10 = require("@modular-circuit/utils");
2124
+ var import_utils11 = require("@modular-circuit/utils");
2148
2125
  var gen_lib_vcc = (value) => ({
2149
2126
  name: `power:${value}`,
2150
2127
  power: true,
@@ -2165,7 +2142,7 @@ var gen_lib_vcc = (value) => ({
2165
2142
  text: "#PWR",
2166
2143
  at: { position: { x: 0, y: -3.81 }, rotation: 0 },
2167
2144
  effects: {
2168
- font: { size: import_utils10.DEFAULT_FONT_SIZE },
2145
+ font: { size: import_utils11.DEFAULT_FONT_SIZE },
2169
2146
  hide: true
2170
2147
  }
2171
2148
  },
@@ -2174,7 +2151,7 @@ var gen_lib_vcc = (value) => ({
2174
2151
  text: `${value}`,
2175
2152
  at: { position: { x: 0, y: 3.556 }, rotation: 0 },
2176
2153
  effects: {
2177
- font: { size: import_utils10.DEFAULT_FONT_SIZE }
2154
+ font: { size: import_utils11.DEFAULT_FONT_SIZE }
2178
2155
  }
2179
2156
  },
2180
2157
  {
@@ -2182,7 +2159,7 @@ var gen_lib_vcc = (value) => ({
2182
2159
  text: "",
2183
2160
  at: { position: { x: 0, y: 0 }, rotation: 0 },
2184
2161
  effects: {
2185
- font: { size: import_utils10.DEFAULT_FONT_SIZE },
2162
+ font: { size: import_utils11.DEFAULT_FONT_SIZE },
2186
2163
  hide: true
2187
2164
  }
2188
2165
  },
@@ -2191,7 +2168,7 @@ var gen_lib_vcc = (value) => ({
2191
2168
  text: "",
2192
2169
  at: { position: { x: 0, y: 0 }, rotation: 0 },
2193
2170
  effects: {
2194
- font: { size: import_utils10.DEFAULT_FONT_SIZE },
2171
+ font: { size: import_utils11.DEFAULT_FONT_SIZE },
2195
2172
  hide: true
2196
2173
  }
2197
2174
  },
@@ -2200,7 +2177,7 @@ var gen_lib_vcc = (value) => ({
2200
2177
  text: `Power symbol creates a global label with name \\"${value}\\"`,
2201
2178
  at: { position: { x: 0, y: 0 }, rotation: 0 },
2202
2179
  effects: {
2203
- font: { size: import_utils10.DEFAULT_FONT_SIZE },
2180
+ font: { size: import_utils11.DEFAULT_FONT_SIZE },
2204
2181
  hide: true
2205
2182
  }
2206
2183
  },
@@ -2209,7 +2186,7 @@ var gen_lib_vcc = (value) => ({
2209
2186
  text: "global power",
2210
2187
  at: { position: { x: 0, y: 0 }, rotation: 0 },
2211
2188
  effects: {
2212
- font: { size: import_utils10.DEFAULT_FONT_SIZE },
2189
+ font: { size: import_utils11.DEFAULT_FONT_SIZE },
2213
2190
  hide: true
2214
2191
  }
2215
2192
  }
@@ -2247,13 +2224,13 @@ var gen_lib_vcc = (value) => ({
2247
2224
  name: {
2248
2225
  text: "~",
2249
2226
  effects: {
2250
- font: { size: import_utils10.DEFAULT_FONT_SIZE }
2227
+ font: { size: import_utils11.DEFAULT_FONT_SIZE }
2251
2228
  }
2252
2229
  },
2253
2230
  number: {
2254
2231
  text: "1",
2255
2232
  effects: {
2256
- font: { size: import_utils10.DEFAULT_FONT_SIZE }
2233
+ font: { size: import_utils11.DEFAULT_FONT_SIZE }
2257
2234
  }
2258
2235
  }
2259
2236
  }
@@ -2263,7 +2240,7 @@ var gen_lib_vcc = (value) => ({
2263
2240
  });
2264
2241
 
2265
2242
  // src/kicad/symbols/sch_symbol/gnd.ts
2266
- var import_utils11 = require("@modular-circuit/utils");
2243
+ var import_utils12 = require("@modular-circuit/utils");
2267
2244
 
2268
2245
  // src/kicad/symbols/symbol_utils.ts
2269
2246
  var gen_pwr_ref = (pwr_num) => `#PWR${pwr_num}`;
@@ -2278,14 +2255,14 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
2278
2255
  on_board: true,
2279
2256
  dnp: false,
2280
2257
  fields_autoplaced: true,
2281
- uuid: (0, import_utils11.gen_uuid)(),
2258
+ uuid: (0, import_utils12.gen_uuid)(),
2282
2259
  properties: [
2283
2260
  {
2284
2261
  name: "Reference",
2285
2262
  text: gen_pwr_ref(pwr_number),
2286
2263
  at: { position: { x: position.x, y: position.y + 6.35 }, rotation: 0 },
2287
2264
  effects: {
2288
- font: { size: import_utils11.DEFAULT_FONT_SIZE },
2265
+ font: { size: import_utils12.DEFAULT_FONT_SIZE },
2289
2266
  hide: true
2290
2267
  }
2291
2268
  },
@@ -2294,7 +2271,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
2294
2271
  text: `${value}`,
2295
2272
  at: { position: { x: position.x, y: position.y + 5.08 }, rotation: 0 },
2296
2273
  effects: {
2297
- font: { size: import_utils11.DEFAULT_FONT_SIZE }
2274
+ font: { size: import_utils12.DEFAULT_FONT_SIZE }
2298
2275
  }
2299
2276
  },
2300
2277
  {
@@ -2302,7 +2279,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
2302
2279
  text: "",
2303
2280
  at: { position, rotation: 0 },
2304
2281
  effects: {
2305
- font: { size: import_utils11.DEFAULT_FONT_SIZE },
2282
+ font: { size: import_utils12.DEFAULT_FONT_SIZE },
2306
2283
  hide: true
2307
2284
  }
2308
2285
  },
@@ -2311,7 +2288,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
2311
2288
  text: "",
2312
2289
  at: { position, rotation: 0 },
2313
2290
  effects: {
2314
- font: { size: import_utils11.DEFAULT_FONT_SIZE },
2291
+ font: { size: import_utils12.DEFAULT_FONT_SIZE },
2315
2292
  hide: true
2316
2293
  }
2317
2294
  },
@@ -2320,7 +2297,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
2320
2297
  text: `Power symbol creates a global label with name \\"${value}\\" , ground`,
2321
2298
  at: { position, rotation: 0 },
2322
2299
  effects: {
2323
- font: { size: import_utils11.DEFAULT_FONT_SIZE },
2300
+ font: { size: import_utils12.DEFAULT_FONT_SIZE },
2324
2301
  hide: true
2325
2302
  }
2326
2303
  }
@@ -2334,7 +2311,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
2334
2311
  });
2335
2312
 
2336
2313
  // src/kicad/symbols/sch_symbol/vcc.ts
2337
- var import_utils12 = require("@modular-circuit/utils");
2314
+ var import_utils13 = require("@modular-circuit/utils");
2338
2315
  var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
2339
2316
  lib_id: `power:${value}`,
2340
2317
  at: { position, rotation: 0 },
@@ -2344,14 +2321,14 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
2344
2321
  on_board: true,
2345
2322
  dnp: false,
2346
2323
  fields_autoplaced: true,
2347
- uuid: (0, import_utils12.gen_uuid)(),
2324
+ uuid: (0, import_utils13.gen_uuid)(),
2348
2325
  properties: [
2349
2326
  {
2350
2327
  name: "Reference",
2351
2328
  text: gen_pwr_ref(pwr_number),
2352
2329
  at: { position: { x: position.x, y: position.y + 3.81 }, rotation: 0 },
2353
2330
  effects: {
2354
- font: { size: import_utils12.DEFAULT_FONT_SIZE },
2331
+ font: { size: import_utils13.DEFAULT_FONT_SIZE },
2355
2332
  hide: true
2356
2333
  }
2357
2334
  },
@@ -2360,7 +2337,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
2360
2337
  text: `${value}`,
2361
2338
  at: { position: { x: position.x, y: position.y - 5.08 }, rotation: 0 },
2362
2339
  effects: {
2363
- font: { size: import_utils12.DEFAULT_FONT_SIZE }
2340
+ font: { size: import_utils13.DEFAULT_FONT_SIZE }
2364
2341
  }
2365
2342
  },
2366
2343
  {
@@ -2368,7 +2345,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
2368
2345
  text: "",
2369
2346
  at: { position, rotation: 0 },
2370
2347
  effects: {
2371
- font: { size: import_utils12.DEFAULT_FONT_SIZE },
2348
+ font: { size: import_utils13.DEFAULT_FONT_SIZE },
2372
2349
  hide: true
2373
2350
  }
2374
2351
  },
@@ -2377,7 +2354,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
2377
2354
  text: "",
2378
2355
  at: { position, rotation: 0 },
2379
2356
  effects: {
2380
- font: { size: import_utils12.DEFAULT_FONT_SIZE },
2357
+ font: { size: import_utils13.DEFAULT_FONT_SIZE },
2381
2358
  hide: true
2382
2359
  }
2383
2360
  },
@@ -2386,7 +2363,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
2386
2363
  text: `Power symbol creates a global label with name \\"${value}\\"`,
2387
2364
  at: { position, rotation: 0 },
2388
2365
  effects: {
2389
- font: { size: import_utils12.DEFAULT_FONT_SIZE },
2366
+ font: { size: import_utils13.DEFAULT_FONT_SIZE },
2390
2367
  hide: true
2391
2368
  }
2392
2369
  }
@@ -2401,7 +2378,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
2401
2378
 
2402
2379
  // src/kicad/wire/gen_wire.ts
2403
2380
  var import_electronics_model7 = require("@modular-circuit/electronics-model");
2404
- var import_utils13 = require("@modular-circuit/utils");
2381
+ var import_utils14 = require("@modular-circuit/utils");
2405
2382
  var gen_wire = (start, end) => ({
2406
2383
  stroke: {
2407
2384
  type: "default",
@@ -2409,7 +2386,7 @@ var gen_wire = (start, end) => ({
2409
2386
  },
2410
2387
  start,
2411
2388
  end,
2412
- uuid: (0, import_utils13.gen_uuid)(),
2389
+ uuid: (0, import_utils14.gen_uuid)(),
2413
2390
  type: import_electronics_model7.GS_SCH_ITEM_TYPE.LINE
2414
2391
  });
2415
2392
 
@@ -2457,15 +2434,15 @@ var NetListConverter = class {
2457
2434
  const powers = /* @__PURE__ */ new Set();
2458
2435
  this.wires = [];
2459
2436
  const sch = {
2460
- version: SCH_VERSION,
2461
- generator: GENERATOR_NAME,
2462
- generator_version: GENERATOR_VERSION,
2437
+ version: import_utils15.SCH_VERSION,
2438
+ generator: import_utils15.GENERATOR_NAME,
2439
+ generator_version: import_utils15.GENERATOR_VERSION,
2463
2440
  paper: {
2464
2441
  size: "A4"
2465
2442
  },
2466
2443
  title_block: {
2467
2444
  title: name.replace(`.${import_ir4.MODULAR_CIRCUIT_SCH_EXT}`, ""),
2468
- date: (0, import_utils14.replaceAll)((/* @__PURE__ */ new Date()).toISOString().slice(0, 10), "-", "/"),
2445
+ date: (0, import_utils15.replaceAll)((/* @__PURE__ */ new Date()).toISOString().slice(0, 10), "-", "/"),
2469
2446
  rev: "1.0",
2470
2447
  comment: {
2471
2448
  1: "https://www.eda.cn",
@@ -2628,7 +2605,7 @@ var NetListConverter = class {
2628
2605
  // src/builder/graph_to_kicad/convert_graph_to_sheets.ts
2629
2606
  var import_ir5 = require("@modular-circuit/ir");
2630
2607
  var import_perc = require("@modular-circuit/perc");
2631
- var import_utils15 = require("@modular-circuit/utils");
2608
+ var import_utils16 = require("@modular-circuit/utils");
2632
2609
  async function do_convert_graph_to_kicad_project(ctx) {
2633
2610
  const module_ids = [];
2634
2611
  for (const sch of Object.values(ctx.schematics)) {
@@ -2664,7 +2641,7 @@ async function do_convert_graph_to_kicad_project(ctx) {
2664
2641
  if (k in sheets) {
2665
2642
  console.error(`Duplicated sheet file name found ${k}`);
2666
2643
  }
2667
- sheets[k.replace(import_ir5.MODULAR_CIRCUIT_SCH_EXT, import_utils15.KiCadSchematicFileExtension)] = sexpr_printer.schematic(v);
2644
+ sheets[k.replace(import_ir5.MODULAR_CIRCUIT_SCH_EXT, import_utils16.KiCadSchematicFileExtension)] = sexpr_printer.schematic(v);
2668
2645
  }
2669
2646
  return sheets;
2670
2647
  }
@@ -2679,7 +2656,7 @@ async function convert_graph_to_sheets(ctx) {
2679
2656
  }
2680
2657
 
2681
2658
  // src/kicad/project/kicad_project_archive.ts
2682
- var import_utils18 = require("@modular-circuit/utils");
2659
+ var import_utils19 = require("@modular-circuit/utils");
2683
2660
  var import_jszip = __toESM(require("jszip"));
2684
2661
 
2685
2662
  // src/kicad/project/kicad_prl.ts
@@ -2768,7 +2745,7 @@ var kicad_prl = (prj_name) => ({
2768
2745
  });
2769
2746
 
2770
2747
  // src/kicad/project/kicad_pro.ts
2771
- var import_utils17 = require("@modular-circuit/utils");
2748
+ var import_utils18 = require("@modular-circuit/utils");
2772
2749
  var kicad_pro = (project_name) => ({
2773
2750
  board: {
2774
2751
  "3dviewports": [],
@@ -2978,7 +2955,7 @@ var kicad_pro = (project_name) => ({
2978
2955
  version: 1
2979
2956
  },
2980
2957
  net_format_name: "",
2981
- page_layout_descr_file: `${project_name}.${import_utils17.DrawingSheetFileExtension}`,
2958
+ page_layout_descr_file: `${project_name}.${import_utils18.DrawingSheetFileExtension}`,
2982
2959
  plot_directory: "",
2983
2960
  spice_current_sheet_as_root: false,
2984
2961
  spice_external_command: 'spice "%I"',
@@ -3016,16 +2993,16 @@ var KiCadProjectArchive = class {
3016
2993
  return kicad_pro(this.project_name);
3017
2994
  }
3018
2995
  get main_sch_name() {
3019
- return this.get_project_directive_file_name(import_utils18.KiCadSchematicFileExtension);
2996
+ return this.get_project_directive_file_name(import_utils19.KiCadSchematicFileExtension);
3020
2997
  }
3021
2998
  get_project_directive_file_name(ext) {
3022
2999
  return `${this.project_name}.${ext}`;
3023
3000
  }
3024
3001
  async toZip() {
3025
3002
  const zip = new import_jszip.default();
3026
- zip.file(this.get_project_directive_file_name(import_utils18.ProjectLocalSettingsFileExtension), JSON.stringify(this.kicad_prl));
3027
- zip.file(this.get_project_directive_file_name(import_utils18.ProjectFileExtension), JSON.stringify(this.kicad_pro));
3028
- zip.file(this.get_project_directive_file_name(import_utils18.DrawingSheetFileExtension), this.sch_frame);
3003
+ zip.file(this.get_project_directive_file_name(import_utils19.ProjectLocalSettingsFileExtension), JSON.stringify(this.kicad_prl));
3004
+ zip.file(this.get_project_directive_file_name(import_utils19.ProjectFileExtension), JSON.stringify(this.kicad_pro));
3005
+ zip.file(this.get_project_directive_file_name(import_utils19.DrawingSheetFileExtension), this.sch_frame);
3029
3006
  for (const schematic of this.designBlock.schematics) {
3030
3007
  zip.file(schematic.filename, schematic.content);
3031
3008
  }
@@ -3073,9 +3050,9 @@ var KiCadProjectArchive = class {
3073
3050
  };
3074
3051
 
3075
3052
  // src/builder/graph_to_kicad/convert_graph_to_design_block.ts
3076
- var import_utils19 = require("@modular-circuit/utils");
3053
+ var import_utils20 = require("@modular-circuit/utils");
3077
3054
  async function convert_graph_to_design_block(ctx) {
3078
- const root = ctx.project.main.replace(import_utils19.ModularCircuitFileExtension, import_utils19.KiCadSchematicFileExtension);
3055
+ const root = ctx.project.main.replace(import_utils20.ModularCircuitFileExtension, import_utils20.KiCadSchematicFileExtension);
3079
3056
  const sheets = await convert_graph_to_sheets(ctx);
3080
3057
  if (!(root in sheets)) {
3081
3058
  throw new Error(`Cannot find root sch file ${root}`);
@@ -3104,20 +3081,14 @@ async function convert_graph_to_kicad_project(ctx) {
3104
3081
  0 && (module.exports = {
3105
3082
  BLOCK_PIN_GAP,
3106
3083
  BLOCK_PIN_TB_MARGIN,
3107
- DEFAULT_PAPER_SIZE,
3108
3084
  FONT_SIZE,
3109
- GENERATOR_NAME,
3110
- GENERATOR_VERSION,
3111
3085
  GRID_SIZE,
3112
3086
  GraphConverter,
3113
3087
  KICAD_SCH_FRAME,
3114
3088
  KiCadProjectArchive,
3115
3089
  Layout,
3116
3090
  NetListConverter,
3117
- PAPER,
3118
- PAPER_SIZE,
3119
3091
  SCHEMATIC_PRINTER,
3120
- SCH_VERSION,
3121
3092
  StringFormatter,
3122
3093
  WIRE_PADDING,
3123
3094
  collect_sub_sheets,
package/dist/index.mjs CHANGED
@@ -62,7 +62,7 @@ import { READABLE_ELECTRICAL_PINTYPE } from "@modular-circuit/electronics-model"
62
62
  import {
63
63
  SHAPE_T
64
64
  } from "@modular-circuit/ir";
65
- import { gen_uuid as gen_uuid2 } from "@modular-circuit/utils";
65
+ import { GENERATOR_NAME, GENERATOR_VERSION, PAPER, SCH_VERSION, gen_uuid as gen_uuid2 } from "@modular-circuit/utils";
66
66
 
67
67
  // src/utils/collect_sub_sheets.ts
68
68
  import {
@@ -114,24 +114,6 @@ async function collect_sub_sheets(dependencies, module_resolver) {
114
114
  return { sheets, module_main_sheet, modules };
115
115
  }
116
116
 
117
- // src/utils/constraints.ts
118
- var PAPER_SIZE = {
119
- A0: { width: 841, height: 1189 },
120
- A1: { width: 594, height: 841 },
121
- A2: { width: 420, height: 594 },
122
- A3: { width: 297, height: 420 },
123
- A4: { width: 210, height: 297 },
124
- A5: { width: 148, height: 210 },
125
- A6: { width: 105, height: 148 },
126
- A7: { width: 74, height: 105 },
127
- A8: { width: 52, height: 74 }
128
- };
129
- var DEFAULT_PAPER_SIZE = PAPER_SIZE.A4;
130
- var GENERATOR_NAME = "modular_circuit";
131
- var SCH_VERSION = 20231120;
132
- var PAPER = "A4";
133
- var GENERATOR_VERSION = "8.0";
134
-
135
117
  // src/utils/filter_null_undefined.ts
136
118
  function filterNullOrUndefined(originalMethod, _context) {
137
119
  function replacementMethod(...args) {
@@ -1795,6 +1777,7 @@ var GraphConverter = class {
1795
1777
  };
1796
1778
 
1797
1779
  // src/converter/netlist_to_kicad/layout.ts
1780
+ import { PAPER_SIZE } from "@modular-circuit/utils";
1798
1781
  import ELK from "elkjs/lib/elk.bundled.js";
1799
1782
  var MIL_TO_MM = 0.0254;
1800
1783
  var GRID_SIZE = 50 * MIL_TO_MM;
@@ -1900,7 +1883,7 @@ import { PowerShape } from "@modular-circuit/electronics-model";
1900
1883
  import {
1901
1884
  MODULAR_CIRCUIT_SCH_EXT
1902
1885
  } from "@modular-circuit/ir";
1903
- import { replaceAll } from "@modular-circuit/utils";
1886
+ import { GENERATOR_NAME as GENERATOR_NAME2, GENERATOR_VERSION as GENERATOR_VERSION2, SCH_VERSION as SCH_VERSION2, replaceAll } from "@modular-circuit/utils";
1904
1887
 
1905
1888
  // src/kicad/label/net_label.ts
1906
1889
  import { DEFAULT_FONT_SIZE, gen_uuid as gen_uuid3 } from "@modular-circuit/utils";
@@ -2419,9 +2402,9 @@ var NetListConverter = class {
2419
2402
  const powers = /* @__PURE__ */ new Set();
2420
2403
  this.wires = [];
2421
2404
  const sch = {
2422
- version: SCH_VERSION,
2423
- generator: GENERATOR_NAME,
2424
- generator_version: GENERATOR_VERSION,
2405
+ version: SCH_VERSION2,
2406
+ generator: GENERATOR_NAME2,
2407
+ generator_version: GENERATOR_VERSION2,
2425
2408
  paper: {
2426
2409
  size: "A4"
2427
2410
  },
@@ -3074,20 +3057,14 @@ async function convert_graph_to_kicad_project(ctx) {
3074
3057
  export {
3075
3058
  BLOCK_PIN_GAP,
3076
3059
  BLOCK_PIN_TB_MARGIN,
3077
- DEFAULT_PAPER_SIZE,
3078
3060
  FONT_SIZE,
3079
- GENERATOR_NAME,
3080
- GENERATOR_VERSION,
3081
3061
  GRID_SIZE,
3082
3062
  GraphConverter,
3083
3063
  KICAD_SCH_FRAME,
3084
3064
  KiCadProjectArchive,
3085
3065
  Layout,
3086
3066
  NetListConverter,
3087
- PAPER,
3088
- PAPER_SIZE,
3089
3067
  SCHEMATIC_PRINTER,
3090
- SCH_VERSION,
3091
3068
  StringFormatter,
3092
3069
  WIRE_PADDING,
3093
3070
  collect_sub_sheets,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-circuit/transpiler",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "Intermediate representation of the modular circuit",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -29,10 +29,10 @@
29
29
  "elkjs": "^0.11.0",
30
30
  "js-base64": "^3.7.7",
31
31
  "jszip": "^3.10.1",
32
- "@modular-circuit/electronics-model": "0.2.11",
33
- "@modular-circuit/ir": "0.2.9",
34
- "@modular-circuit/perc": "0.2.17",
35
- "@modular-circuit/utils": "0.2.9"
32
+ "@modular-circuit/ir": "0.2.10",
33
+ "@modular-circuit/electronics-model": "0.2.12",
34
+ "@modular-circuit/perc": "0.2.18",
35
+ "@modular-circuit/utils": "0.2.10"
36
36
  },
37
37
  "scripts": {
38
38
  "clean": "rimraf dist",
@@ -40,6 +40,6 @@
40
40
  "build": "tsup src/index.ts --format cjs,esm --dts --clean --tsconfig tsconfig.build.json",
41
41
  "lint:ci": "biome ci",
42
42
  "lint": "biome check --fix --unsafe",
43
- "test:unit": "vitest --workspace ../../vitest.workspace.ts --project unit run"
43
+ "type-check": "tsc --noEmit"
44
44
  }
45
45
  }