@modular-circuit/transpiler 0.0.76 → 0.0.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/builder/graph_to_kicad/do_convert_graph_to_kicad_project.js +19 -108
- package/build/builder/graph_to_kicad/index.js +4 -59
- package/build/converter/graph_to_netlist/graph_converter.js +51 -171
- package/build/converter/kicad_sexpr/eeschema/drawing_sheet/sch_default_drawing_sheet.js +1 -1
- package/build/converter/kicad_sexpr/eeschema/printer.js +245 -290
- package/build/converter/link_to_netlist/converter.js +77 -135
- package/build/converter/link_to_netlist/links/converter_base.js +38 -131
- package/build/converter/link_to_netlist/links/converters.js +316 -554
- package/build/converter/netlist_to_kicad/calc_boxes_pos.d.ts +1 -1
- package/build/converter/netlist_to_kicad/calc_boxes_pos.d.ts.map +1 -1
- package/build/converter/netlist_to_kicad/calc_boxes_pos.js +36 -101
- package/build/converter/netlist_to_kicad/layout.js +28 -32
- package/build/converter/netlist_to_kicad/netlist_converter.d.ts +1 -1
- package/build/converter/netlist_to_kicad/netlist_converter.d.ts.map +1 -1
- package/build/converter/netlist_to_kicad/netlist_converter.js +128 -300
- package/build/kicad/constraints/index.js +1 -1
- package/build/kicad/label/net_label.js +2 -2
- package/build/kicad/label/sheet_pin.js +11 -19
- package/build/kicad/project/kicad_prl.js +3 -3
- package/build/kicad/project/kicad_pro.js +4 -4
- package/build/kicad/project/kicad_project_achieve.js +31 -45
- package/build/kicad/project/wildcards_and_files_ext.js +61 -61
- package/build/kicad/sheet/sheet.js +3 -3
- package/build/kicad/symbols/lib_symbol/gnd.js +6 -6
- package/build/kicad/symbols/lib_symbol/vcc.js +7 -7
- package/build/kicad/symbols/sch_symbol/gnd.js +9 -9
- package/build/kicad/symbols/sch_symbol/vcc.js +9 -9
- package/build/kicad/symbols/symbol_utils.js +1 -1
- package/build/kicad/wire/gen_wire.js +4 -4
- package/build/utils/collect_sub_sheets.js +37 -151
- package/build/utils/constraints.js +6 -6
- package/build/utils/filter_null_undefined.js +2 -31
- package/build/utils/string_formatter.js +23 -29
- package/package.json +5 -5
|
@@ -1,53 +1,39 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { zipFiles } from '@modular-circuit/utils';
|
|
13
2
|
import { get_sch_default_drawing_sheet } from '../../converter';
|
|
14
3
|
import { kicad_prl } from './kicad_prl';
|
|
15
4
|
import { kicad_pro } from './kicad_pro';
|
|
16
5
|
import { DrawingSheetFileExtension, ProjectFileExtension, ProjectLocalSettingsFileExtension, } from './wildcards_and_files_ext';
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
export const KICAD_SCH_FRAME = get_sch_default_drawing_sheet();
|
|
7
|
+
export class KiCadProjectAchieve {
|
|
8
|
+
project_name;
|
|
9
|
+
sheets;
|
|
10
|
+
kicad_sym;
|
|
11
|
+
fp_lib_table;
|
|
12
|
+
layout_frame;
|
|
13
|
+
pcb;
|
|
14
|
+
sym_lib_table;
|
|
15
|
+
get sch_frame() {
|
|
16
|
+
return KICAD_SCH_FRAME;
|
|
17
|
+
}
|
|
18
|
+
get kicad_prl() {
|
|
19
|
+
return kicad_prl(this.project_name);
|
|
20
|
+
}
|
|
21
|
+
get kicad_pro() {
|
|
22
|
+
return kicad_pro(this.project_name);
|
|
23
|
+
}
|
|
24
|
+
constructor(project_name, sheets) {
|
|
20
25
|
this.project_name = project_name;
|
|
21
26
|
this.sheets = sheets;
|
|
22
27
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
configurable: true
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(KiCadProjectAchieve.prototype, "kicad_pro", {
|
|
38
|
-
get: function () {
|
|
39
|
-
return kicad_pro(this.project_name);
|
|
40
|
-
},
|
|
41
|
-
enumerable: false,
|
|
42
|
-
configurable: true
|
|
43
|
-
});
|
|
44
|
-
KiCadProjectAchieve.prototype.get_project_directive_file_name = function (ext) {
|
|
45
|
-
return "".concat(this.project_name, ".").concat(ext);
|
|
46
|
-
};
|
|
47
|
-
KiCadProjectAchieve.prototype.toZip = function () {
|
|
48
|
-
var _a;
|
|
49
|
-
return zipFiles(__assign((_a = {}, _a[this.get_project_directive_file_name(ProjectLocalSettingsFileExtension)] = JSON.stringify(this.kicad_prl), _a[this.get_project_directive_file_name(ProjectFileExtension)] = JSON.stringify(this.kicad_pro), _a[this.get_project_directive_file_name(DrawingSheetFileExtension)] = this.sch_frame, _a), this.sheets));
|
|
50
|
-
};
|
|
51
|
-
return KiCadProjectAchieve;
|
|
52
|
-
}());
|
|
53
|
-
export { KiCadProjectAchieve };
|
|
28
|
+
get_project_directive_file_name(ext) {
|
|
29
|
+
return `${this.project_name}.${ext}`;
|
|
30
|
+
}
|
|
31
|
+
toZip() {
|
|
32
|
+
return zipFiles({
|
|
33
|
+
[this.get_project_directive_file_name(ProjectLocalSettingsFileExtension)]: JSON.stringify(this.kicad_prl),
|
|
34
|
+
[this.get_project_directive_file_name(ProjectFileExtension)]: JSON.stringify(this.kicad_pro),
|
|
35
|
+
[this.get_project_directive_file_name(DrawingSheetFileExtension)]: this.sch_frame,
|
|
36
|
+
...this.sheets,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
export
|
|
42
|
-
export
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
48
|
-
export
|
|
49
|
-
export
|
|
50
|
-
export
|
|
51
|
-
export
|
|
52
|
-
export
|
|
53
|
-
export
|
|
54
|
-
export
|
|
55
|
-
export
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
export
|
|
60
|
-
export
|
|
61
|
-
export
|
|
1
|
+
export const KiCadSymbolLibFileExtension = 'kicad_sym';
|
|
2
|
+
export const SchematicSymbolFileExtension = 'sym';
|
|
3
|
+
export const LegacySymbolLibFileExtension = 'lib';
|
|
4
|
+
export const LegacySymbolDocumentFileExtension = 'dcm';
|
|
5
|
+
export const VrmlFileExtension = 'wrl';
|
|
6
|
+
export const ProjectFileExtension = 'kicad_pro';
|
|
7
|
+
export const LegacyProjectFileExtension = 'pro';
|
|
8
|
+
export const ProjectLocalSettingsFileExtension = 'kicad_prl';
|
|
9
|
+
export const LegacySchematicFileExtension = 'sch';
|
|
10
|
+
export const CadstarSchematicFileExtension = 'csa';
|
|
11
|
+
export const CadstarPartsLibraryFileExtension = 'lib';
|
|
12
|
+
export const KiCadSchematicFileExtension = 'kicad_sch';
|
|
13
|
+
export const SpiceFileExtension = 'cir';
|
|
14
|
+
export const CadstarNetlistFileExtension = 'frp';
|
|
15
|
+
export const OrCadPcb2NetlistFileExtension = 'net';
|
|
16
|
+
export const NetlistFileExtension = 'net';
|
|
17
|
+
export const AllegroNetlistFileExtension = 'txt';
|
|
18
|
+
export const FootprintAssignmentFileExtension = 'cmp';
|
|
19
|
+
export const GerberFileExtension = 'gbr';
|
|
20
|
+
export const GerberJobFileExtension = 'gbrjob';
|
|
21
|
+
export const HtmlFileExtension = 'html';
|
|
22
|
+
export const EquFileExtension = 'equ';
|
|
23
|
+
export const HotkeyFileExtension = 'hotkeys';
|
|
24
|
+
export const DatabaseLibraryFileExtension = 'kicad_dbl';
|
|
25
|
+
export const HTTPLibraryFileExtension = 'kicad_httplib';
|
|
26
|
+
export const ArchiveFileExtension = 'zip';
|
|
27
|
+
export const LegacyPcbFileExtension = 'brd';
|
|
28
|
+
export const EaglePcbFileExtension = 'brd';
|
|
29
|
+
export const CadstarPcbFileExtension = 'cpa';
|
|
30
|
+
export const KiCadPcbFileExtension = 'kicad_pcb';
|
|
31
|
+
export const DrawingSheetFileExtension = 'kicad_wks';
|
|
32
|
+
export const DesignRulesFileExtension = 'kicad_dru';
|
|
33
|
+
export const PdfFileExtension = 'pdf';
|
|
34
|
+
export const MacrosFileExtension = 'mcr';
|
|
35
|
+
export const DrillFileExtension = 'drl';
|
|
36
|
+
export const SVGFileExtension = 'svg';
|
|
37
|
+
export const ReportFileExtension = 'rpt';
|
|
38
|
+
export const FootprintPlaceFileExtension = 'pos';
|
|
39
|
+
export const KiCadFootprintLibPathExtension = 'pretty'; // this is a directory
|
|
40
|
+
export const LegacyFootprintLibPathExtension = 'mod'; // this is a file
|
|
41
|
+
export const AltiumFootprintLibPathExtension = 'PcbLib'; // this is a file
|
|
42
|
+
export const CadstarFootprintLibPathExtension = 'cpa'; // this is a file
|
|
43
|
+
export const EagleFootprintLibPathExtension = 'lbr'; // this is a file
|
|
44
|
+
export const GedaPcbFootprintLibFileExtension = 'fp'; // this is a file
|
|
45
|
+
export const KiCadFootprintFileExtension = 'kicad_mod';
|
|
46
|
+
export const SpecctraDsnFileExtension = 'dsn';
|
|
47
|
+
export const SpecctraSessionFileExtension = 'ses';
|
|
48
|
+
export const IpcD356FileExtension = 'd356';
|
|
49
|
+
export const Ipc2581FileExtension = 'xml';
|
|
50
|
+
export const WorkbookFileExtension = 'wbk';
|
|
51
|
+
export const PngFileExtension = 'png';
|
|
52
|
+
export const JpegFileExtension = 'jpg';
|
|
53
|
+
export const TextFileExtension = 'txt';
|
|
54
|
+
export const MarkdownFileExtension = 'md';
|
|
55
|
+
export const CsvFileExtension = 'csv';
|
|
56
|
+
export const XmlFileExtension = 'xml';
|
|
57
|
+
export const JsonFileExtension = 'json';
|
|
58
|
+
export const StepFileExtension = 'step';
|
|
59
|
+
export const StepFileAbrvExtension = 'stp';
|
|
60
|
+
export const GltfBinaryFileExtension = 'glb';
|
|
61
|
+
export const GerberFileExtensionsRegex = /(gbr|gko|pho|(g[tb][alops])|(gm?\\d\\d*)|(gp[tb]))/;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { gen_uuid } from '@modular-circuit/utils';
|
|
2
2
|
import { DEFAULT_FONT_SIZE } from '../constraints';
|
|
3
|
-
|
|
4
|
-
export
|
|
3
|
+
const TEXT_MARGIN = 0.7116;
|
|
4
|
+
export const gen_sch_sheet = (rect, pins, fields) => ({
|
|
5
5
|
// NOTE no rotation in the sheet
|
|
6
6
|
at: { position: rect.pos },
|
|
7
7
|
size: rect.size,
|
|
@@ -41,4 +41,4 @@ export var gen_sch_sheet = function (rect, pins, fields) { return ({
|
|
|
41
41
|
color: { r: 0, g: 0, b: 0, a: 0.0 },
|
|
42
42
|
},
|
|
43
43
|
uuid: gen_uuid(),
|
|
44
|
-
});
|
|
44
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ELECTRICAL_PINTYPE, GRAPHIC_PINSHAPE } from '@modular-circuit/electronics-model';
|
|
2
2
|
import { SHAPE_T } from '@modular-circuit/ir';
|
|
3
3
|
import { DEFAULT_FONT_SIZE } from '../../constraints';
|
|
4
|
-
export
|
|
5
|
-
name:
|
|
4
|
+
export const gen_lib_gnd = (value) => ({
|
|
5
|
+
name: `power:${value}`,
|
|
6
6
|
pin_numbers: {
|
|
7
7
|
offset: 0,
|
|
8
8
|
hide: true,
|
|
@@ -26,7 +26,7 @@ export var gen_lib_gnd = function (value) { return ({
|
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
name: 'Value',
|
|
29
|
-
text:
|
|
29
|
+
text: `${value}`,
|
|
30
30
|
at: { position: { x: 0, y: -3.81 }, rotation: 0 },
|
|
31
31
|
effects: {
|
|
32
32
|
font: { size: DEFAULT_FONT_SIZE },
|
|
@@ -71,7 +71,7 @@ export var gen_lib_gnd = function (value) { return ({
|
|
|
71
71
|
],
|
|
72
72
|
children: [
|
|
73
73
|
{
|
|
74
|
-
name:
|
|
74
|
+
name: `${value}_0_1`,
|
|
75
75
|
drawings: [
|
|
76
76
|
{
|
|
77
77
|
shape: SHAPE_T.POLY,
|
|
@@ -94,7 +94,7 @@ export var gen_lib_gnd = function (value) { return ({
|
|
|
94
94
|
],
|
|
95
95
|
},
|
|
96
96
|
{
|
|
97
|
-
name:
|
|
97
|
+
name: `${value}_0_1`,
|
|
98
98
|
pins: [
|
|
99
99
|
{
|
|
100
100
|
type: ELECTRICAL_PINTYPE.PT_POWER_IN,
|
|
@@ -118,4 +118,4 @@ export var gen_lib_gnd = function (value) { return ({
|
|
|
118
118
|
],
|
|
119
119
|
},
|
|
120
120
|
],
|
|
121
|
-
});
|
|
121
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ELECTRICAL_PINTYPE, GRAPHIC_PINSHAPE } from '@modular-circuit/electronics-model';
|
|
2
2
|
import { SHAPE_T } from '@modular-circuit/ir';
|
|
3
3
|
import { DEFAULT_FONT_SIZE } from '../../constraints';
|
|
4
|
-
export
|
|
5
|
-
name:
|
|
4
|
+
export const gen_lib_vcc = (value) => ({
|
|
5
|
+
name: `power:${value}`,
|
|
6
6
|
power: true,
|
|
7
7
|
pin_numbers: {
|
|
8
8
|
offset: 0,
|
|
@@ -27,7 +27,7 @@ export var gen_lib_vcc = function (value) { return ({
|
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
name: 'Value',
|
|
30
|
-
text:
|
|
30
|
+
text: `${value}`,
|
|
31
31
|
at: { position: { x: 0, y: 3.556 }, rotation: 0 },
|
|
32
32
|
effects: {
|
|
33
33
|
font: { size: DEFAULT_FONT_SIZE },
|
|
@@ -53,7 +53,7 @@ export var gen_lib_vcc = function (value) { return ({
|
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
name: 'Description',
|
|
56
|
-
text:
|
|
56
|
+
text: `Power symbol creates a global label with name \\"${value}\\"`,
|
|
57
57
|
at: { position: { x: 0, y: 0 }, rotation: 0 },
|
|
58
58
|
effects: {
|
|
59
59
|
font: { size: DEFAULT_FONT_SIZE },
|
|
@@ -72,7 +72,7 @@ export var gen_lib_vcc = function (value) { return ({
|
|
|
72
72
|
],
|
|
73
73
|
children: [
|
|
74
74
|
{
|
|
75
|
-
name:
|
|
75
|
+
name: `${value}_0_1`,
|
|
76
76
|
drawings: [
|
|
77
77
|
{
|
|
78
78
|
shape: SHAPE_T.POLY,
|
|
@@ -92,7 +92,7 @@ export var gen_lib_vcc = function (value) { return ({
|
|
|
92
92
|
],
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
|
-
name:
|
|
95
|
+
name: `${value}_1_1`,
|
|
96
96
|
pins: [
|
|
97
97
|
{
|
|
98
98
|
type: ELECTRICAL_PINTYPE.PT_POWER_IN,
|
|
@@ -116,4 +116,4 @@ export var gen_lib_vcc = function (value) { return ({
|
|
|
116
116
|
],
|
|
117
117
|
},
|
|
118
118
|
],
|
|
119
|
-
});
|
|
119
|
+
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { gen_uuid } from '@modular-circuit/utils';
|
|
2
2
|
import { DEFAULT_FONT_SIZE } from '../../constraints';
|
|
3
3
|
import { gen_pwr_ref } from '../symbol_utils';
|
|
4
|
-
export
|
|
5
|
-
lib_id:
|
|
6
|
-
at: { position
|
|
4
|
+
export const gen_sch_gnd = (value, pwr_number, port_id, position) => ({
|
|
5
|
+
lib_id: `power:${value}`,
|
|
6
|
+
at: { position, rotation: 0 },
|
|
7
7
|
unit: 1,
|
|
8
8
|
exclude_from_sim: false,
|
|
9
9
|
in_bom: true,
|
|
@@ -23,7 +23,7 @@ export var gen_sch_gnd = function (value, pwr_number, port_id, position) { retur
|
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
name: 'Value',
|
|
26
|
-
text:
|
|
26
|
+
text: `${value}`,
|
|
27
27
|
at: { position: { x: position.x, y: position.y + 5.08 }, rotation: 0 },
|
|
28
28
|
effects: {
|
|
29
29
|
font: { size: DEFAULT_FONT_SIZE },
|
|
@@ -32,7 +32,7 @@ export var gen_sch_gnd = function (value, pwr_number, port_id, position) { retur
|
|
|
32
32
|
{
|
|
33
33
|
name: 'Footprint',
|
|
34
34
|
text: '',
|
|
35
|
-
at: { position
|
|
35
|
+
at: { position, rotation: 0 },
|
|
36
36
|
effects: {
|
|
37
37
|
font: { size: DEFAULT_FONT_SIZE },
|
|
38
38
|
hide: true,
|
|
@@ -41,7 +41,7 @@ export var gen_sch_gnd = function (value, pwr_number, port_id, position) { retur
|
|
|
41
41
|
{
|
|
42
42
|
name: 'Datasheet',
|
|
43
43
|
text: '',
|
|
44
|
-
at: { position
|
|
44
|
+
at: { position, rotation: 0 },
|
|
45
45
|
effects: {
|
|
46
46
|
font: { size: DEFAULT_FONT_SIZE },
|
|
47
47
|
hide: true,
|
|
@@ -49,8 +49,8 @@ export var gen_sch_gnd = function (value, pwr_number, port_id, position) { retur
|
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
name: 'Description',
|
|
52
|
-
text:
|
|
53
|
-
at: { position
|
|
52
|
+
text: `Power symbol creates a global label with name \\"${value}\\" , ground`,
|
|
53
|
+
at: { position, rotation: 0 },
|
|
54
54
|
effects: {
|
|
55
55
|
font: { size: DEFAULT_FONT_SIZE },
|
|
56
56
|
hide: true,
|
|
@@ -63,4 +63,4 @@ export var gen_sch_gnd = function (value, pwr_number, port_id, position) { retur
|
|
|
63
63
|
number: '1',
|
|
64
64
|
},
|
|
65
65
|
],
|
|
66
|
-
});
|
|
66
|
+
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { gen_uuid } from '@modular-circuit/utils';
|
|
2
2
|
import { DEFAULT_FONT_SIZE } from '../../constraints';
|
|
3
3
|
import { gen_pwr_ref } from '../symbol_utils';
|
|
4
|
-
export
|
|
5
|
-
lib_id:
|
|
6
|
-
at: { position
|
|
4
|
+
export const gen_sch_vcc = (value, pwr_number, port_id, position) => ({
|
|
5
|
+
lib_id: `power:${value}`,
|
|
6
|
+
at: { position, rotation: 0 },
|
|
7
7
|
unit: 1,
|
|
8
8
|
exclude_from_sim: false,
|
|
9
9
|
in_bom: true,
|
|
@@ -23,7 +23,7 @@ export var gen_sch_vcc = function (value, pwr_number, port_id, position) { retur
|
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
name: 'Value',
|
|
26
|
-
text:
|
|
26
|
+
text: `${value}`,
|
|
27
27
|
at: { position: { x: position.x, y: position.y - 5.08 }, rotation: 0 },
|
|
28
28
|
effects: {
|
|
29
29
|
font: { size: DEFAULT_FONT_SIZE },
|
|
@@ -32,7 +32,7 @@ export var gen_sch_vcc = function (value, pwr_number, port_id, position) { retur
|
|
|
32
32
|
{
|
|
33
33
|
name: 'Footprint',
|
|
34
34
|
text: '',
|
|
35
|
-
at: { position
|
|
35
|
+
at: { position, rotation: 0 },
|
|
36
36
|
effects: {
|
|
37
37
|
font: { size: DEFAULT_FONT_SIZE },
|
|
38
38
|
hide: true,
|
|
@@ -41,7 +41,7 @@ export var gen_sch_vcc = function (value, pwr_number, port_id, position) { retur
|
|
|
41
41
|
{
|
|
42
42
|
name: 'Datasheet',
|
|
43
43
|
text: '',
|
|
44
|
-
at: { position
|
|
44
|
+
at: { position, rotation: 0 },
|
|
45
45
|
effects: {
|
|
46
46
|
font: { size: DEFAULT_FONT_SIZE },
|
|
47
47
|
hide: true,
|
|
@@ -49,8 +49,8 @@ export var gen_sch_vcc = function (value, pwr_number, port_id, position) { retur
|
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
name: 'Description',
|
|
52
|
-
text:
|
|
53
|
-
at: { position
|
|
52
|
+
text: `Power symbol creates a global label with name \\"${value}\\"`,
|
|
53
|
+
at: { position, rotation: 0 },
|
|
54
54
|
effects: {
|
|
55
55
|
font: { size: DEFAULT_FONT_SIZE },
|
|
56
56
|
hide: true,
|
|
@@ -63,4 +63,4 @@ export var gen_sch_vcc = function (value, pwr_number, port_id, position) { retur
|
|
|
63
63
|
uuid: port_id,
|
|
64
64
|
},
|
|
65
65
|
],
|
|
66
|
-
});
|
|
66
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const gen_pwr_ref = (pwr_num) => `#PWR${pwr_num}`;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { GS_SCH_ITEM_TYPE } from '@modular-circuit/electronics-model';
|
|
2
2
|
import { gen_uuid } from '@modular-circuit/utils';
|
|
3
|
-
export
|
|
3
|
+
export const gen_wire = (start, end) => ({
|
|
4
4
|
stroke: {
|
|
5
5
|
type: 'default',
|
|
6
6
|
width: 0,
|
|
7
7
|
},
|
|
8
|
-
start
|
|
9
|
-
end
|
|
8
|
+
start,
|
|
9
|
+
end,
|
|
10
10
|
uuid: gen_uuid(),
|
|
11
11
|
type: GS_SCH_ITEM_TYPE.LINE,
|
|
12
|
-
});
|
|
12
|
+
});
|
|
@@ -1,156 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { KICAD_SHC_FILE_EXT, parse_module_name, remove_filename_path_prefix, unzipFile } from '@modular-circuit/utils';
|
|
2
|
+
export async function collect_sub_sheets(dependencies, module_resolver) {
|
|
3
|
+
const sheets = {};
|
|
4
|
+
const module_main_sheet = {};
|
|
5
|
+
const modules = {};
|
|
6
|
+
for (const [k, v] of Object.entries(dependencies)) {
|
|
7
|
+
// Get the URL for the ZIP archive
|
|
8
|
+
const zip_achieve_url = await module_resolver.get_module_achieve({
|
|
9
|
+
...parse_module_name(k),
|
|
10
|
+
version: v,
|
|
11
|
+
});
|
|
12
|
+
const module = await module_resolver.get_module_circuit({
|
|
13
|
+
...parse_module_name(k),
|
|
14
|
+
version: v,
|
|
15
|
+
});
|
|
16
|
+
if (!zip_achieve_url || !module) {
|
|
17
|
+
console.error(`Module ${k}/${v} not found`);
|
|
18
|
+
continue;
|
|
7
19
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var __values = (this && this.__values) || function(o) {
|
|
49
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
50
|
-
if (m) return m.call(o);
|
|
51
|
-
if (o && typeof o.length === "number") return {
|
|
52
|
-
next: function () {
|
|
53
|
-
if (o && i >= o.length) o = void 0;
|
|
54
|
-
return { value: o && o[i++], done: !o };
|
|
20
|
+
if (!module.main) {
|
|
21
|
+
console.error(`Missing main entry in module ${k}/${v}`);
|
|
22
|
+
continue;
|
|
55
23
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
24
|
+
module_main_sheet[k] = module.main;
|
|
25
|
+
modules[k] = module;
|
|
26
|
+
// Fetch the ZIP archive
|
|
27
|
+
const zip_achieve = await fetch(zip_achieve_url).then((res) => res.arrayBuffer());
|
|
28
|
+
const files = await unzipFile(zip_achieve);
|
|
29
|
+
for (const [name, content] of Object.entries(files)) {
|
|
30
|
+
if (name.endsWith(KICAD_SHC_FILE_EXT)) {
|
|
31
|
+
const fileName = remove_filename_path_prefix(name);
|
|
32
|
+
// FIXME : Should auto rename the sheets and remapping them
|
|
33
|
+
if (fileName in sheets) {
|
|
34
|
+
console.error(`Duplicate sheet name: ${fileName}`);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
sheets[fileName] = content;
|
|
38
|
+
}
|
|
70
39
|
}
|
|
71
|
-
finally { if (e) throw e.error; }
|
|
72
40
|
}
|
|
73
|
-
return
|
|
74
|
-
};
|
|
75
|
-
import { KICAD_SHC_FILE_EXT, parse_module_name, remove_filename_path_prefix, unzipFile } from '@modular-circuit/utils';
|
|
76
|
-
export function collect_sub_sheets(dependencies, module_resolver) {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
-
var sheets, module_main_sheet, modules, _a, _b, _c, k, v, zip_achieve_url, module_1, zip_achieve, files, _d, _e, _f, name, content, fileName, e_1_1;
|
|
79
|
-
var e_1, _g, e_2, _h;
|
|
80
|
-
return __generator(this, function (_j) {
|
|
81
|
-
switch (_j.label) {
|
|
82
|
-
case 0:
|
|
83
|
-
sheets = {};
|
|
84
|
-
module_main_sheet = {};
|
|
85
|
-
modules = {};
|
|
86
|
-
_j.label = 1;
|
|
87
|
-
case 1:
|
|
88
|
-
_j.trys.push([1, 9, 10, 11]);
|
|
89
|
-
_a = __values(Object.entries(dependencies)), _b = _a.next();
|
|
90
|
-
_j.label = 2;
|
|
91
|
-
case 2:
|
|
92
|
-
if (!!_b.done) return [3 /*break*/, 8];
|
|
93
|
-
_c = __read(_b.value, 2), k = _c[0], v = _c[1];
|
|
94
|
-
return [4 /*yield*/, module_resolver.get_module_achieve(__assign(__assign({}, parse_module_name(k)), { version: v }))];
|
|
95
|
-
case 3:
|
|
96
|
-
zip_achieve_url = _j.sent();
|
|
97
|
-
return [4 /*yield*/, module_resolver.get_module_circuit(__assign(__assign({}, parse_module_name(k)), { version: v }))];
|
|
98
|
-
case 4:
|
|
99
|
-
module_1 = _j.sent();
|
|
100
|
-
if (!zip_achieve_url || !module_1) {
|
|
101
|
-
console.error("Module ".concat(k, "/").concat(v, " not found"));
|
|
102
|
-
return [3 /*break*/, 7];
|
|
103
|
-
}
|
|
104
|
-
if (!module_1.main) {
|
|
105
|
-
console.error("Missing main entry in module ".concat(k, "/").concat(v));
|
|
106
|
-
return [3 /*break*/, 7];
|
|
107
|
-
}
|
|
108
|
-
module_main_sheet[k] = module_1.main;
|
|
109
|
-
modules[k] = module_1;
|
|
110
|
-
return [4 /*yield*/, fetch(zip_achieve_url).then(function (res) { return res.arrayBuffer(); })];
|
|
111
|
-
case 5:
|
|
112
|
-
zip_achieve = _j.sent();
|
|
113
|
-
return [4 /*yield*/, unzipFile(zip_achieve)];
|
|
114
|
-
case 6:
|
|
115
|
-
files = _j.sent();
|
|
116
|
-
try {
|
|
117
|
-
for (_d = (e_2 = void 0, __values(Object.entries(files))), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
118
|
-
_f = __read(_e.value, 2), name = _f[0], content = _f[1];
|
|
119
|
-
if (name.endsWith(KICAD_SHC_FILE_EXT)) {
|
|
120
|
-
fileName = remove_filename_path_prefix(name);
|
|
121
|
-
// FIXME : Should auto rename the sheets and remapping them
|
|
122
|
-
if (fileName in sheets) {
|
|
123
|
-
console.error("Duplicate sheet name: ".concat(fileName));
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
sheets[fileName] = content;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
131
|
-
finally {
|
|
132
|
-
try {
|
|
133
|
-
if (_e && !_e.done && (_h = _d.return)) _h.call(_d);
|
|
134
|
-
}
|
|
135
|
-
finally { if (e_2) throw e_2.error; }
|
|
136
|
-
}
|
|
137
|
-
_j.label = 7;
|
|
138
|
-
case 7:
|
|
139
|
-
_b = _a.next();
|
|
140
|
-
return [3 /*break*/, 2];
|
|
141
|
-
case 8: return [3 /*break*/, 11];
|
|
142
|
-
case 9:
|
|
143
|
-
e_1_1 = _j.sent();
|
|
144
|
-
e_1 = { error: e_1_1 };
|
|
145
|
-
return [3 /*break*/, 11];
|
|
146
|
-
case 10:
|
|
147
|
-
try {
|
|
148
|
-
if (_b && !_b.done && (_g = _a.return)) _g.call(_a);
|
|
149
|
-
}
|
|
150
|
-
finally { if (e_1) throw e_1.error; }
|
|
151
|
-
return [7 /*endfinally*/];
|
|
152
|
-
case 11: return [2 /*return*/, { sheets: sheets, module_main_sheet: module_main_sheet, modules: modules }];
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
});
|
|
41
|
+
return { sheets, module_main_sheet, modules };
|
|
156
42
|
}
|