@modular-circuit/transpiler 0.1.9 → 0.1.12

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.mjs CHANGED
@@ -65,7 +65,7 @@ import {
65
65
  import { gen_uuid } from "@modular-circuit/utils";
66
66
 
67
67
  // src/utils/collect_sub_sheets.ts
68
- import { KICAD_SHC_FILE_EXT, parse_module_name, remove_filename_path_prefix, unzipFile } from "@modular-circuit/utils";
68
+ import { KiCadSchematicFileExtension, parse_module_name, remove_filename_path_prefix, unzipFile } from "@modular-circuit/utils";
69
69
  async function collect_sub_sheets(dependencies, module_resolver) {
70
70
  const sheets = {};
71
71
  const module_main_sheet = {};
@@ -93,7 +93,7 @@ async function collect_sub_sheets(dependencies, module_resolver) {
93
93
  const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
94
94
  const files = await unzipFile(zip_archive);
95
95
  for (const [name, content] of Object.entries(files)) {
96
- if (name.endsWith(KICAD_SHC_FILE_EXT)) {
96
+ if (name.endsWith(KiCadSchematicFileExtension)) {
97
97
  const fileName = remove_filename_path_prefix(name);
98
98
  if (fileName in sheets) {
99
99
  console.error(`Duplicate sheet name: ${fileName}`);
@@ -169,9 +169,9 @@ var StringFormatter = class {
169
169
 
170
170
  // src/utils/collect_sub_sheets_by_id.ts
171
171
  import {
172
- KICAD_PCB_FILE_EXT,
173
- KICAD_SHC_FILE_EXT as KICAD_SHC_FILE_EXT2,
174
172
  fmt_module_name,
173
+ KiCadPcbFileExtension,
174
+ KiCadSchematicFileExtension as KiCadSchematicFileExtension2,
175
175
  remove_filename_path_prefix as remove_filename_path_prefix2,
176
176
  unzipFile as unzipFile2
177
177
  } from "@modular-circuit/utils";
@@ -209,7 +209,7 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
209
209
  const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
210
210
  const files = await unzipFile2(zip_archive);
211
211
  for (const [name, content] of Object.entries(files)) {
212
- if (name.endsWith(KICAD_SHC_FILE_EXT2)) {
212
+ if (name.endsWith(KiCadSchematicFileExtension2)) {
213
213
  const filename = remove_filename_path_prefix2(name);
214
214
  if (filename in sheets) {
215
215
  console.error(`Duplicate sheet name: ${filename}`);
@@ -217,7 +217,7 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
217
217
  }
218
218
  sheets[filename] = content;
219
219
  design_block.schematics.push({ filename, content });
220
- } else if (name.endsWith(KICAD_PCB_FILE_EXT)) {
220
+ } else if (name.endsWith(KiCadPcbFileExtension)) {
221
221
  const filename = remove_filename_path_prefix2(name);
222
222
  design_block.pcb = { pcb: { filename, content } };
223
223
  }
@@ -1745,15 +1745,7 @@ import {
1745
1745
  import { replaceAll } from "@modular-circuit/utils";
1746
1746
 
1747
1747
  // src/kicad/label/net_label.ts
1748
- import { gen_uuid as gen_uuid2 } from "@modular-circuit/utils";
1749
-
1750
- // src/kicad/constraints/index.ts
1751
- var DEFAULT_FONT_SIZE = {
1752
- x: 1.27,
1753
- y: 1.27
1754
- };
1755
-
1756
- // src/kicad/label/net_label.ts
1748
+ import { DEFAULT_FONT_SIZE, gen_uuid as gen_uuid2 } from "@modular-circuit/utils";
1757
1749
  var gen_net_label = (name, at, justify) => ({
1758
1750
  label_type: "label",
1759
1751
  text: name,
@@ -1768,11 +1760,11 @@ var gen_net_label = (name, at, justify) => ({
1768
1760
  });
1769
1761
 
1770
1762
  // src/kicad/label/sheet_pin.ts
1771
- import { gen_uuid as gen_uuid3 } from "@modular-circuit/utils";
1763
+ import { DEFAULT_FONT_SIZE as DEFAULT_FONT_SIZE2, gen_uuid as gen_uuid3 } from "@modular-circuit/utils";
1772
1764
  var gen_base_hierarchical_label = (text, at, justify, rotation, shape) => ({
1773
1765
  shape,
1774
1766
  effects: {
1775
- font: { size: DEFAULT_FONT_SIZE },
1767
+ font: { size: DEFAULT_FONT_SIZE2 },
1776
1768
  justify
1777
1769
  },
1778
1770
  text,
@@ -1786,7 +1778,7 @@ var gen_sheet_pin = (text, at, justify, rotation, shape) => ({
1786
1778
  var gen_hierarchical_label = gen_sheet_pin;
1787
1779
 
1788
1780
  // src/kicad/sheet/sheet.ts
1789
- import { gen_uuid as gen_uuid4 } from "@modular-circuit/utils";
1781
+ import { DEFAULT_FONT_SIZE as DEFAULT_FONT_SIZE3, gen_uuid as gen_uuid4 } from "@modular-circuit/utils";
1790
1782
  var TEXT_MARGIN = 0.7116;
1791
1783
  var gen_sch_sheet = (rect, pins, fields) => ({
1792
1784
  // NOTE no rotation in the sheet
@@ -1799,7 +1791,7 @@ var gen_sch_sheet = (rect, pins, fields) => ({
1799
1791
  text: fields.Sheetname,
1800
1792
  at: { position: { x: rect.pos.x, y: rect.pos.y - TEXT_MARGIN }, rotation: 0 },
1801
1793
  effects: {
1802
- font: { size: DEFAULT_FONT_SIZE },
1794
+ font: { size: DEFAULT_FONT_SIZE3 },
1803
1795
  justify: {
1804
1796
  vertical: "bottom",
1805
1797
  horizontal: "left"
@@ -1811,7 +1803,7 @@ var gen_sch_sheet = (rect, pins, fields) => ({
1811
1803
  text: fields.Sheetfile,
1812
1804
  at: { position: { x: rect.pos.x, y: rect.pos.y + rect.size.y + TEXT_MARGIN }, rotation: 0 },
1813
1805
  effects: {
1814
- font: { size: DEFAULT_FONT_SIZE },
1806
+ font: { size: DEFAULT_FONT_SIZE3 },
1815
1807
  justify: {
1816
1808
  vertical: "top",
1817
1809
  horizontal: "left"
@@ -1833,6 +1825,7 @@ var gen_sch_sheet = (rect, pins, fields) => ({
1833
1825
  // src/kicad/symbols/lib_symbol/gnd.ts
1834
1826
  import { ELECTRICAL_PINTYPE, GRAPHIC_PINSHAPE } from "@modular-circuit/electronics-model";
1835
1827
  import { SHAPE_T as SHAPE_T2 } from "@modular-circuit/ir";
1828
+ import { DEFAULT_FONT_SIZE as DEFAULT_FONT_SIZE4 } from "@modular-circuit/utils";
1836
1829
  var gen_lib_gnd = (value) => ({
1837
1830
  name: `power:${value}`,
1838
1831
  pin_numbers: {
@@ -1852,7 +1845,7 @@ var gen_lib_gnd = (value) => ({
1852
1845
  text: "#PWR",
1853
1846
  at: { position: { x: 0, y: -6.35 }, rotation: 0 },
1854
1847
  effects: {
1855
- font: { size: DEFAULT_FONT_SIZE },
1848
+ font: { size: DEFAULT_FONT_SIZE4 },
1856
1849
  hide: true
1857
1850
  }
1858
1851
  },
@@ -1861,7 +1854,7 @@ var gen_lib_gnd = (value) => ({
1861
1854
  text: `${value}`,
1862
1855
  at: { position: { x: 0, y: -3.81 }, rotation: 0 },
1863
1856
  effects: {
1864
- font: { size: DEFAULT_FONT_SIZE }
1857
+ font: { size: DEFAULT_FONT_SIZE4 }
1865
1858
  }
1866
1859
  },
1867
1860
  {
@@ -1869,7 +1862,7 @@ var gen_lib_gnd = (value) => ({
1869
1862
  text: "",
1870
1863
  at: { position: { x: 0, y: 0 }, rotation: 0 },
1871
1864
  effects: {
1872
- font: { size: DEFAULT_FONT_SIZE },
1865
+ font: { size: DEFAULT_FONT_SIZE4 },
1873
1866
  hide: true
1874
1867
  }
1875
1868
  },
@@ -1878,7 +1871,7 @@ var gen_lib_gnd = (value) => ({
1878
1871
  text: "",
1879
1872
  at: { position: { x: 0, y: 0 }, rotation: 0 },
1880
1873
  effects: {
1881
- font: { size: DEFAULT_FONT_SIZE },
1874
+ font: { size: DEFAULT_FONT_SIZE4 },
1882
1875
  hide: true
1883
1876
  }
1884
1877
  },
@@ -1887,7 +1880,7 @@ var gen_lib_gnd = (value) => ({
1887
1880
  text: 'Power symbol creates a global label with name \\"GND\\" , ground',
1888
1881
  at: { position: { x: 0, y: 0 }, rotation: 0 },
1889
1882
  effects: {
1890
- font: { size: DEFAULT_FONT_SIZE },
1883
+ font: { size: DEFAULT_FONT_SIZE4 },
1891
1884
  hide: true
1892
1885
  }
1893
1886
  },
@@ -1896,7 +1889,7 @@ var gen_lib_gnd = (value) => ({
1896
1889
  text: "global power",
1897
1890
  at: { position: { x: 0, y: 0 }, rotation: 0 },
1898
1891
  effects: {
1899
- font: { size: DEFAULT_FONT_SIZE },
1892
+ font: { size: DEFAULT_FONT_SIZE4 },
1900
1893
  hide: true
1901
1894
  }
1902
1895
  }
@@ -1937,13 +1930,13 @@ var gen_lib_gnd = (value) => ({
1937
1930
  name: {
1938
1931
  text: "~",
1939
1932
  effects: {
1940
- font: { size: DEFAULT_FONT_SIZE }
1933
+ font: { size: DEFAULT_FONT_SIZE4 }
1941
1934
  }
1942
1935
  },
1943
1936
  number: {
1944
1937
  text: "1",
1945
1938
  effects: {
1946
- font: { size: DEFAULT_FONT_SIZE }
1939
+ font: { size: DEFAULT_FONT_SIZE4 }
1947
1940
  }
1948
1941
  }
1949
1942
  }
@@ -1955,6 +1948,7 @@ var gen_lib_gnd = (value) => ({
1955
1948
  // src/kicad/symbols/lib_symbol/vcc.ts
1956
1949
  import { ELECTRICAL_PINTYPE as ELECTRICAL_PINTYPE2, GRAPHIC_PINSHAPE as GRAPHIC_PINSHAPE2 } from "@modular-circuit/electronics-model";
1957
1950
  import { SHAPE_T as SHAPE_T3 } from "@modular-circuit/ir";
1951
+ import { DEFAULT_FONT_SIZE as DEFAULT_FONT_SIZE5 } from "@modular-circuit/utils";
1958
1952
  var gen_lib_vcc = (value) => ({
1959
1953
  name: `power:${value}`,
1960
1954
  power: true,
@@ -1975,7 +1969,7 @@ var gen_lib_vcc = (value) => ({
1975
1969
  text: "#PWR",
1976
1970
  at: { position: { x: 0, y: -3.81 }, rotation: 0 },
1977
1971
  effects: {
1978
- font: { size: DEFAULT_FONT_SIZE },
1972
+ font: { size: DEFAULT_FONT_SIZE5 },
1979
1973
  hide: true
1980
1974
  }
1981
1975
  },
@@ -1984,7 +1978,7 @@ var gen_lib_vcc = (value) => ({
1984
1978
  text: `${value}`,
1985
1979
  at: { position: { x: 0, y: 3.556 }, rotation: 0 },
1986
1980
  effects: {
1987
- font: { size: DEFAULT_FONT_SIZE }
1981
+ font: { size: DEFAULT_FONT_SIZE5 }
1988
1982
  }
1989
1983
  },
1990
1984
  {
@@ -1992,7 +1986,7 @@ var gen_lib_vcc = (value) => ({
1992
1986
  text: "",
1993
1987
  at: { position: { x: 0, y: 0 }, rotation: 0 },
1994
1988
  effects: {
1995
- font: { size: DEFAULT_FONT_SIZE },
1989
+ font: { size: DEFAULT_FONT_SIZE5 },
1996
1990
  hide: true
1997
1991
  }
1998
1992
  },
@@ -2001,7 +1995,7 @@ var gen_lib_vcc = (value) => ({
2001
1995
  text: "",
2002
1996
  at: { position: { x: 0, y: 0 }, rotation: 0 },
2003
1997
  effects: {
2004
- font: { size: DEFAULT_FONT_SIZE },
1998
+ font: { size: DEFAULT_FONT_SIZE5 },
2005
1999
  hide: true
2006
2000
  }
2007
2001
  },
@@ -2010,7 +2004,7 @@ var gen_lib_vcc = (value) => ({
2010
2004
  text: `Power symbol creates a global label with name \\"${value}\\"`,
2011
2005
  at: { position: { x: 0, y: 0 }, rotation: 0 },
2012
2006
  effects: {
2013
- font: { size: DEFAULT_FONT_SIZE },
2007
+ font: { size: DEFAULT_FONT_SIZE5 },
2014
2008
  hide: true
2015
2009
  }
2016
2010
  },
@@ -2019,7 +2013,7 @@ var gen_lib_vcc = (value) => ({
2019
2013
  text: "global power",
2020
2014
  at: { position: { x: 0, y: 0 }, rotation: 0 },
2021
2015
  effects: {
2022
- font: { size: DEFAULT_FONT_SIZE },
2016
+ font: { size: DEFAULT_FONT_SIZE5 },
2023
2017
  hide: true
2024
2018
  }
2025
2019
  }
@@ -2057,13 +2051,13 @@ var gen_lib_vcc = (value) => ({
2057
2051
  name: {
2058
2052
  text: "~",
2059
2053
  effects: {
2060
- font: { size: DEFAULT_FONT_SIZE }
2054
+ font: { size: DEFAULT_FONT_SIZE5 }
2061
2055
  }
2062
2056
  },
2063
2057
  number: {
2064
2058
  text: "1",
2065
2059
  effects: {
2066
- font: { size: DEFAULT_FONT_SIZE }
2060
+ font: { size: DEFAULT_FONT_SIZE5 }
2067
2061
  }
2068
2062
  }
2069
2063
  }
@@ -2073,7 +2067,7 @@ var gen_lib_vcc = (value) => ({
2073
2067
  });
2074
2068
 
2075
2069
  // src/kicad/symbols/sch_symbol/gnd.ts
2076
- import { gen_uuid as gen_uuid5 } from "@modular-circuit/utils";
2070
+ import { DEFAULT_FONT_SIZE as DEFAULT_FONT_SIZE6, gen_uuid as gen_uuid5 } from "@modular-circuit/utils";
2077
2071
 
2078
2072
  // src/kicad/symbols/symbol_utils.ts
2079
2073
  var gen_pwr_ref = (pwr_num) => `#PWR${pwr_num}`;
@@ -2095,7 +2089,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
2095
2089
  text: gen_pwr_ref(pwr_number),
2096
2090
  at: { position: { x: position.x, y: position.y + 6.35 }, rotation: 0 },
2097
2091
  effects: {
2098
- font: { size: DEFAULT_FONT_SIZE },
2092
+ font: { size: DEFAULT_FONT_SIZE6 },
2099
2093
  hide: true
2100
2094
  }
2101
2095
  },
@@ -2104,7 +2098,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
2104
2098
  text: `${value}`,
2105
2099
  at: { position: { x: position.x, y: position.y + 5.08 }, rotation: 0 },
2106
2100
  effects: {
2107
- font: { size: DEFAULT_FONT_SIZE }
2101
+ font: { size: DEFAULT_FONT_SIZE6 }
2108
2102
  }
2109
2103
  },
2110
2104
  {
@@ -2112,7 +2106,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
2112
2106
  text: "",
2113
2107
  at: { position, rotation: 0 },
2114
2108
  effects: {
2115
- font: { size: DEFAULT_FONT_SIZE },
2109
+ font: { size: DEFAULT_FONT_SIZE6 },
2116
2110
  hide: true
2117
2111
  }
2118
2112
  },
@@ -2121,7 +2115,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
2121
2115
  text: "",
2122
2116
  at: { position, rotation: 0 },
2123
2117
  effects: {
2124
- font: { size: DEFAULT_FONT_SIZE },
2118
+ font: { size: DEFAULT_FONT_SIZE6 },
2125
2119
  hide: true
2126
2120
  }
2127
2121
  },
@@ -2130,7 +2124,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
2130
2124
  text: `Power symbol creates a global label with name \\"${value}\\" , ground`,
2131
2125
  at: { position, rotation: 0 },
2132
2126
  effects: {
2133
- font: { size: DEFAULT_FONT_SIZE },
2127
+ font: { size: DEFAULT_FONT_SIZE6 },
2134
2128
  hide: true
2135
2129
  }
2136
2130
  }
@@ -2144,7 +2138,7 @@ var gen_sch_gnd = (value, pwr_number, port_id, position) => ({
2144
2138
  });
2145
2139
 
2146
2140
  // src/kicad/symbols/sch_symbol/vcc.ts
2147
- import { gen_uuid as gen_uuid6 } from "@modular-circuit/utils";
2141
+ import { DEFAULT_FONT_SIZE as DEFAULT_FONT_SIZE7, gen_uuid as gen_uuid6 } from "@modular-circuit/utils";
2148
2142
  var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
2149
2143
  lib_id: `power:${value}`,
2150
2144
  at: { position, rotation: 0 },
@@ -2161,7 +2155,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
2161
2155
  text: gen_pwr_ref(pwr_number),
2162
2156
  at: { position: { x: position.x, y: position.y + 3.81 }, rotation: 0 },
2163
2157
  effects: {
2164
- font: { size: DEFAULT_FONT_SIZE },
2158
+ font: { size: DEFAULT_FONT_SIZE7 },
2165
2159
  hide: true
2166
2160
  }
2167
2161
  },
@@ -2170,7 +2164,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
2170
2164
  text: `${value}`,
2171
2165
  at: { position: { x: position.x, y: position.y - 5.08 }, rotation: 0 },
2172
2166
  effects: {
2173
- font: { size: DEFAULT_FONT_SIZE }
2167
+ font: { size: DEFAULT_FONT_SIZE7 }
2174
2168
  }
2175
2169
  },
2176
2170
  {
@@ -2178,7 +2172,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
2178
2172
  text: "",
2179
2173
  at: { position, rotation: 0 },
2180
2174
  effects: {
2181
- font: { size: DEFAULT_FONT_SIZE },
2175
+ font: { size: DEFAULT_FONT_SIZE7 },
2182
2176
  hide: true
2183
2177
  }
2184
2178
  },
@@ -2187,7 +2181,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
2187
2181
  text: "",
2188
2182
  at: { position, rotation: 0 },
2189
2183
  effects: {
2190
- font: { size: DEFAULT_FONT_SIZE },
2184
+ font: { size: DEFAULT_FONT_SIZE7 },
2191
2185
  hide: true
2192
2186
  }
2193
2187
  },
@@ -2196,7 +2190,7 @@ var gen_sch_vcc = (value, pwr_number, port_id, position) => ({
2196
2190
  text: `Power symbol creates a global label with name \\"${value}\\"`,
2197
2191
  at: { position, rotation: 0 },
2198
2192
  effects: {
2199
- font: { size: DEFAULT_FONT_SIZE },
2193
+ font: { size: DEFAULT_FONT_SIZE7 },
2200
2194
  hide: true
2201
2195
  }
2202
2196
  }
@@ -2437,69 +2431,35 @@ var NetListConverter = class {
2437
2431
 
2438
2432
  // src/builder/graph_to_kicad/convert_graph_to_sheets.ts
2439
2433
  import { MODULAR_CIRCUIT_SCH_EXT as MODULAR_CIRCUIT_SCH_EXT2 } from "@modular-circuit/ir";
2440
-
2441
- // src/kicad/project/wildcards_and_files_ext.ts
2442
- var KiCadSymbolLibFileExtension = "kicad_sym";
2443
- var SchematicSymbolFileExtension = "sym";
2444
- var LegacySymbolLibFileExtension = "lib";
2445
- var LegacySymbolDocumentFileExtension = "dcm";
2446
- var VrmlFileExtension = "wrl";
2447
- var ProjectFileExtension = "kicad_pro";
2448
- var LegacyProjectFileExtension = "pro";
2449
- var ProjectLocalSettingsFileExtension = "kicad_prl";
2450
- var LegacySchematicFileExtension = "sch";
2451
- var CadstarSchematicFileExtension = "csa";
2452
- var CadstarPartsLibraryFileExtension = "lib";
2453
- var KiCadSchematicFileExtension = "kicad_sch";
2454
- var SpiceFileExtension = "cir";
2455
- var CadstarNetlistFileExtension = "frp";
2456
- var OrCadPcb2NetlistFileExtension = "net";
2457
- var NetlistFileExtension = "net";
2458
- var AllegroNetlistFileExtension = "txt";
2459
- var FootprintAssignmentFileExtension = "cmp";
2460
- var GerberFileExtension = "gbr";
2461
- var GerberJobFileExtension = "gbrjob";
2462
- var HtmlFileExtension = "html";
2463
- var EquFileExtension = "equ";
2464
- var HotkeyFileExtension = "hotkeys";
2465
- var DatabaseLibraryFileExtension = "kicad_dbl";
2466
- var HTTPLibraryFileExtension = "kicad_httplib";
2467
- var ArchiveFileExtension = "zip";
2468
- var LegacyPcbFileExtension = "brd";
2469
- var EaglePcbFileExtension = "brd";
2470
- var CadstarPcbFileExtension = "cpa";
2471
- var KiCadPcbFileExtension = "kicad_pcb";
2472
- var DrawingSheetFileExtension = "kicad_wks";
2473
- var DesignRulesFileExtension = "kicad_dru";
2474
- var PdfFileExtension = "pdf";
2475
- var MacrosFileExtension = "mcr";
2476
- var DrillFileExtension = "drl";
2477
- var SVGFileExtension = "svg";
2478
- var ReportFileExtension = "rpt";
2479
- var FootprintPlaceFileExtension = "pos";
2480
- var KiCadFootprintLibPathExtension = "pretty";
2481
- var LegacyFootprintLibPathExtension = "mod";
2482
- var AltiumFootprintLibPathExtension = "PcbLib";
2483
- var CadstarFootprintLibPathExtension = "cpa";
2484
- var EagleFootprintLibPathExtension = "lbr";
2485
- var GedaPcbFootprintLibFileExtension = "fp";
2486
- var KiCadFootprintFileExtension = "kicad_mod";
2487
- var SpecctraDsnFileExtension = "dsn";
2488
- var SpecctraSessionFileExtension = "ses";
2489
- var IpcD356FileExtension = "d356";
2490
- var Ipc2581FileExtension = "xml";
2491
- var WorkbookFileExtension = "wbk";
2492
- var PngFileExtension = "png";
2493
- var JpegFileExtension = "jpg";
2494
- var TextFileExtension = "txt";
2495
- var MarkdownFileExtension = "md";
2496
- var CsvFileExtension = "csv";
2497
- var XmlFileExtension = "xml";
2498
- var JsonFileExtension = "json";
2499
- var StepFileExtension = "step";
2500
- var StepFileAbrvExtension = "stp";
2501
- var GltfBinaryFileExtension = "glb";
2502
- var GerberFileExtensionsRegex = /(gbr|gko|pho|(g[tb][alops])|(gm?\\d\\d*)|(gp[tb]))/;
2434
+ import { build_connection_graph } from "@modular-circuit/perc";
2435
+ import { KiCadSchematicFileExtension as KiCadSchematicFileExtension3 } from "@modular-circuit/utils";
2436
+ async function do_convert_graph_to_kicad_project(ctx) {
2437
+ const { sheets } = await collect_sub_sheets(ctx.project.dependencies, ctx.module_resolver);
2438
+ const netlist = new GraphConverter({
2439
+ ...ctx
2440
+ }).convert_to_netlist();
2441
+ const converted_sheets = await new NetListConverter({
2442
+ ...ctx,
2443
+ netlist
2444
+ }).convert_to_kicad();
2445
+ const sexpr_printer = new SCHEMATIC_PRINTER();
2446
+ for (const [k, v] of Object.entries(converted_sheets)) {
2447
+ if (k in sheets) {
2448
+ console.error(`Duplicated sheet file name found ${k}`);
2449
+ }
2450
+ sheets[k.replace(MODULAR_CIRCUIT_SCH_EXT2, KiCadSchematicFileExtension3)] = sexpr_printer.schematic(v);
2451
+ }
2452
+ return sheets;
2453
+ }
2454
+ async function convert_graph_to_sheets(ctx) {
2455
+ return do_convert_graph_to_kicad_project({
2456
+ ...ctx,
2457
+ ...await build_connection_graph({
2458
+ ...ctx,
2459
+ dependencies: ctx.project.dependencies
2460
+ })
2461
+ });
2462
+ }
2503
2463
 
2504
2464
  // src/kicad/project/kicad_project_archive.ts
2505
2465
  import { zipFiles } from "@modular-circuit/utils";
@@ -2590,6 +2550,7 @@ var kicad_prl = (prj_name) => ({
2590
2550
  });
2591
2551
 
2592
2552
  // src/kicad/project/kicad_pro.ts
2553
+ import { DrawingSheetFileExtension } from "@modular-circuit/utils";
2593
2554
  var kicad_pro = (project_name) => ({
2594
2555
  board: {
2595
2556
  "3dviewports": [],
@@ -2815,6 +2776,12 @@ var kicad_pro = (project_name) => ({
2815
2776
  });
2816
2777
 
2817
2778
  // src/kicad/project/kicad_project_archive.ts
2779
+ import {
2780
+ DrawingSheetFileExtension as DrawingSheetFileExtension2,
2781
+ KiCadSchematicFileExtension as KiCadSchematicFileExtension4,
2782
+ ProjectFileExtension,
2783
+ ProjectLocalSettingsFileExtension
2784
+ } from "@modular-circuit/utils";
2818
2785
  var KICAD_SCH_FRAME = get_sch_default_drawing_sheet();
2819
2786
  var KiCadProjectArchive = class {
2820
2787
  constructor(project_name, sheets) {
@@ -2836,7 +2803,7 @@ var KiCadProjectArchive = class {
2836
2803
  return kicad_pro(this.project_name);
2837
2804
  }
2838
2805
  get main_sch_name() {
2839
- return this.get_project_directive_file_name(KiCadSchematicFileExtension);
2806
+ return this.get_project_directive_file_name(KiCadSchematicFileExtension4);
2840
2807
  }
2841
2808
  get_project_directive_file_name(ext) {
2842
2809
  return `${this.project_name}.${ext}`;
@@ -2845,42 +2812,12 @@ var KiCadProjectArchive = class {
2845
2812
  return zipFiles({
2846
2813
  [this.get_project_directive_file_name(ProjectLocalSettingsFileExtension)]: JSON.stringify(this.kicad_prl),
2847
2814
  [this.get_project_directive_file_name(ProjectFileExtension)]: JSON.stringify(this.kicad_pro),
2848
- [this.get_project_directive_file_name(DrawingSheetFileExtension)]: this.sch_frame,
2815
+ [this.get_project_directive_file_name(DrawingSheetFileExtension2)]: this.sch_frame,
2849
2816
  ...this.sheets
2850
2817
  });
2851
2818
  }
2852
2819
  };
2853
2820
 
2854
- // src/builder/graph_to_kicad/convert_graph_to_sheets.ts
2855
- import { build_connection_graph } from "@modular-circuit/perc";
2856
- async function do_convert_graph_to_kicad_project(ctx) {
2857
- const { sheets } = await collect_sub_sheets(ctx.project.dependencies, ctx.module_resolver);
2858
- const netlist = new GraphConverter({
2859
- ...ctx
2860
- }).convert_to_netlist();
2861
- const converted_sheets = await new NetListConverter({
2862
- ...ctx,
2863
- netlist
2864
- }).convert_to_kicad();
2865
- const sexpr_printer = new SCHEMATIC_PRINTER();
2866
- for (const [k, v] of Object.entries(converted_sheets)) {
2867
- if (k in sheets) {
2868
- console.error(`Duplicated sheet file name found ${k}`);
2869
- }
2870
- sheets[k.replace(MODULAR_CIRCUIT_SCH_EXT2, KiCadSchematicFileExtension)] = sexpr_printer.schematic(v);
2871
- }
2872
- return sheets;
2873
- }
2874
- async function convert_graph_to_sheets(ctx) {
2875
- return do_convert_graph_to_kicad_project({
2876
- ...ctx,
2877
- ...await build_connection_graph({
2878
- ...ctx,
2879
- dependencies: ctx.project.dependencies
2880
- })
2881
- });
2882
- }
2883
-
2884
2821
  // src/builder/graph_to_kicad/convert_graph_to_kicad_project.ts
2885
2822
  async function convert_graph_to_kicad_project(ctx) {
2886
2823
  const sheets = await convert_graph_to_sheets(ctx);
@@ -2889,89 +2826,50 @@ async function convert_graph_to_kicad_project(ctx) {
2889
2826
  });
2890
2827
  return kicad_project.toZip();
2891
2828
  }
2829
+
2830
+ // src/builder/graph_to_kicad/convert_graph_to_design_block.ts
2831
+ async function convert_graph_to_design_block(ctx) {
2832
+ const sheets = await convert_graph_to_sheets(ctx);
2833
+ const kicad_project = new KiCadProjectArchive(ctx.project.name, {
2834
+ ...sheets
2835
+ });
2836
+ const design_block = {
2837
+ root: kicad_project.main_sch_name,
2838
+ pcb: null,
2839
+ components: [],
2840
+ schematics: Object.entries(sheets).map(([filename, content]) => {
2841
+ return {
2842
+ filename,
2843
+ content
2844
+ };
2845
+ })
2846
+ };
2847
+ return design_block;
2848
+ }
2892
2849
  export {
2893
- AllegroNetlistFileExtension,
2894
- AltiumFootprintLibPathExtension,
2895
- ArchiveFileExtension,
2896
2850
  BLOCK_PIN_GAP,
2897
2851
  BLOCK_PIN_TB_MARGIN,
2898
- CadstarFootprintLibPathExtension,
2899
- CadstarNetlistFileExtension,
2900
- CadstarPartsLibraryFileExtension,
2901
- CadstarPcbFileExtension,
2902
- CadstarSchematicFileExtension,
2903
- CsvFileExtension,
2904
2852
  DEFAULT_PAPER_SIZE,
2905
- DatabaseLibraryFileExtension,
2906
- DesignRulesFileExtension,
2907
- DrawingSheetFileExtension,
2908
- DrillFileExtension,
2909
- EagleFootprintLibPathExtension,
2910
- EaglePcbFileExtension,
2911
- EquFileExtension,
2912
2853
  FONT_SIZE,
2913
- FootprintAssignmentFileExtension,
2914
- FootprintPlaceFileExtension,
2915
2854
  GENERATOR_NAME,
2916
2855
  GENERATOR_VERSION,
2917
2856
  GRID_SIZE,
2918
- GedaPcbFootprintLibFileExtension,
2919
- GerberFileExtension,
2920
- GerberFileExtensionsRegex,
2921
- GerberJobFileExtension,
2922
- GltfBinaryFileExtension,
2923
2857
  GraphConverter,
2924
- HTTPLibraryFileExtension,
2925
- HotkeyFileExtension,
2926
- HtmlFileExtension,
2927
- Ipc2581FileExtension,
2928
- IpcD356FileExtension,
2929
- JpegFileExtension,
2930
- JsonFileExtension,
2931
2858
  KICAD_SCH_FRAME,
2932
- KiCadFootprintFileExtension,
2933
- KiCadFootprintLibPathExtension,
2934
- KiCadPcbFileExtension,
2935
2859
  KiCadProjectArchive,
2936
- KiCadSchematicFileExtension,
2937
- KiCadSymbolLibFileExtension,
2938
2860
  Layout,
2939
- LegacyFootprintLibPathExtension,
2940
- LegacyPcbFileExtension,
2941
- LegacyProjectFileExtension,
2942
- LegacySchematicFileExtension,
2943
- LegacySymbolDocumentFileExtension,
2944
- LegacySymbolLibFileExtension,
2945
- MacrosFileExtension,
2946
- MarkdownFileExtension,
2947
2861
  NetListConverter,
2948
- NetlistFileExtension,
2949
- OrCadPcb2NetlistFileExtension,
2950
2862
  PAPER,
2951
2863
  PAPER_SIZE,
2952
- PdfFileExtension,
2953
- PngFileExtension,
2954
- ProjectFileExtension,
2955
- ProjectLocalSettingsFileExtension,
2956
- ReportFileExtension,
2957
2864
  SCHEMATIC_PRINTER,
2958
2865
  SCH_VERSION,
2959
- SVGFileExtension,
2960
- SchematicSymbolFileExtension,
2961
- SpecctraDsnFileExtension,
2962
- SpecctraSessionFileExtension,
2963
- SpiceFileExtension,
2964
- StepFileAbrvExtension,
2965
- StepFileExtension,
2966
2866
  StringFormatter,
2967
- TextFileExtension,
2968
- VrmlFileExtension,
2969
2867
  WIRE_PADDING,
2970
- WorkbookFileExtension,
2971
- XmlFileExtension,
2972
2868
  collect_sub_sheets,
2973
2869
  collect_sub_sheets_by_id,
2870
+ convert_graph_to_design_block,
2974
2871
  convert_graph_to_kicad_project,
2872
+ convert_graph_to_sheets,
2975
2873
  filterNullOrUndefined,
2976
2874
  gen_lib_gnd,
2977
2875
  gen_lib_vcc,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-circuit/transpiler",
3
- "version": "0.1.9",
3
+ "version": "0.1.12",
4
4
  "description": "Intermediate representation of the modular circuit",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -31,8 +31,8 @@
31
31
  "jszip": "^3.10.1",
32
32
  "@modular-circuit/electronics-model": "0.1.1",
33
33
  "@modular-circuit/ir": "0.1.3",
34
- "@modular-circuit/perc": "0.1.4",
35
- "@modular-circuit/utils": "0.1.2"
34
+ "@modular-circuit/utils": "0.1.4",
35
+ "@modular-circuit/perc": "0.1.4"
36
36
  },
37
37
  "scripts": {
38
38
  "clean": "rimraf dist",