mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-10-24 18:48:33 +00:00
Compare commits
606 Commits
2.0.0-rc4
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e394a5b010 | ||
|
|
3d8f3fa3e3 | ||
|
|
c1e5fbc8a5 | ||
|
|
ee4f74d566 | ||
|
|
0f9f0d07b7 | ||
|
|
2f0414a5a1 | ||
|
|
e3319dab1a | ||
|
|
a669a43449 | ||
|
|
56ab874177 | ||
|
|
e36f393682 | ||
|
|
4d52bb2843 | ||
|
|
39c8db8e90 | ||
|
|
8aa3c28c50 | ||
|
|
d293595b89 | ||
|
|
4b0982ccb3 | ||
|
|
9b15695c60 | ||
|
|
0dff87e29c | ||
|
|
7dafe7b0d3 | ||
|
|
859d29d41a | ||
|
|
d298b3ffc9 | ||
|
|
9ab87bf8b5 | ||
|
|
5ec1915000 | ||
|
|
6d96e227eb | ||
|
|
1712f9ea9d | ||
|
|
6eef09efd8 | ||
|
|
1112057979 | ||
|
|
8e18c47d30 | ||
|
|
4788bfbc3f | ||
|
|
71b11ed829 | ||
|
|
3aedafa306 | ||
|
|
284dd83d7d | ||
|
|
c09b5f718a | ||
|
|
dba57b312c | ||
|
|
90d3d77ca4 | ||
|
|
0aec778e84 | ||
|
|
84d2dfd13e | ||
|
|
86c7fd7b59 | ||
|
|
de265694ee | ||
|
|
8462d8a391 | ||
|
|
48d6d37539 | ||
|
|
d1065886ef | ||
|
|
8773bd67ab | ||
|
|
4189b086de | ||
|
|
3fc8474d71 | ||
|
|
4cf9909a07 | ||
|
|
41844c9470 | ||
|
|
7c231fff76 | ||
|
|
d6235f0a0c | ||
|
|
d377d00042 | ||
|
|
f232010bec | ||
|
|
788017bb99 | ||
|
|
9331d2ec0d | ||
|
|
6e695429cc | ||
|
|
4f8b9800a0 | ||
|
|
f72d1f0ac8 | ||
|
|
0fe0feace4 | ||
|
|
43f0ccb250 | ||
|
|
c0b0b84d79 | ||
|
|
3d82cb3525 | ||
|
|
9cbee0eacf | ||
|
|
63e9dfd7f5 | ||
|
|
3ccc864453 | ||
|
|
44f15238d6 | ||
|
|
4a3abf542c | ||
|
|
91bb75ca97 | ||
|
|
77136687d3 | ||
|
|
16bc1a4610 | ||
|
|
2921979678 | ||
|
|
a5bf56ffa6 | ||
|
|
2de8bd1717 | ||
|
|
1ec0a8cc77 | ||
|
|
c3adde5460 | ||
|
|
2e78e96b75 | ||
|
|
aa9b10d68e | ||
|
|
4217c0001d | ||
|
|
a088ba99f5 | ||
|
|
2a325a5b74 | ||
|
|
347e3d8118 | ||
|
|
8e09971078 | ||
|
|
48e7bf6b5d | ||
|
|
95c4399c07 | ||
|
|
4a807ab538 | ||
|
|
1a98485b02 | ||
|
|
8fe6a81230 | ||
|
|
547a630598 | ||
|
|
ff8c646cfa | ||
|
|
316e0fd8be | ||
|
|
ca779e5cf2 | ||
|
|
74c580175b | ||
|
|
71bd189eb1 | ||
|
|
0822ed28da | ||
|
|
1b9c7e93e0 | ||
|
|
d419a6c6f0 | ||
|
|
dda7770105 | ||
|
|
763fde036c | ||
|
|
0e7b0c9486 | ||
|
|
b8dd39c729 | ||
|
|
d6de53780d | ||
|
|
2f2b19f613 | ||
|
|
0ca1a31747 | ||
|
|
d01f95647e | ||
|
|
074f654457 | ||
|
|
3eef857b48 | ||
|
|
73b6dc4774 | ||
|
|
42bf1a0e99 | ||
|
|
5abdc18fcc | ||
|
|
633346a3b0 | ||
|
|
0f83a48649 | ||
|
|
a0bd5d022f | ||
|
|
101ba650f3 | ||
|
|
64ce35edbb | ||
|
|
2dae4c8258 | ||
|
|
e7754b7c3b | ||
|
|
3d2511194a | ||
|
|
59a3c4faf0 | ||
|
|
22a69f7488 | ||
|
|
503533d712 | ||
|
|
8687e2e044 | ||
|
|
69b73657b6 | ||
|
|
7e8f723df3 | ||
|
|
d19778d0fb | ||
|
|
e5ef564817 | ||
|
|
ce01351bfe | ||
|
|
a110c2b1f2 | ||
|
|
153e34f11b | ||
|
|
ed1cb6bcf9 | ||
|
|
a8e63c8c90 | ||
|
|
0b2410d49a | ||
|
|
3f4d2745a8 | ||
|
|
136545491d | ||
|
|
7e1d441e6a | ||
|
|
f0706e1849 | ||
|
|
4708bae9ab | ||
|
|
57975f8d91 | ||
|
|
8f4bcc83ec | ||
|
|
ce02e263ec | ||
|
|
ed2d8ad13c | ||
|
|
bb4b1450e3 | ||
|
|
8a5dee9307 | ||
|
|
5939b65511 | ||
|
|
7f660d76a8 | ||
|
|
9f48296d4d | ||
|
|
ec28623a97 | ||
|
|
73ddbefc3e | ||
|
|
fe53b8e0d0 | ||
|
|
90b886ea92 | ||
|
|
97e26a9584 | ||
|
|
f0704b678c | ||
|
|
95bd2cf2e7 | ||
|
|
8d2808893c | ||
|
|
e5b5b2a4be | ||
|
|
e08439b6a4 | ||
|
|
e03e5eb603 | ||
|
|
b723951d78 | ||
|
|
ea2c54bff0 | ||
|
|
5fd02b9fd7 | ||
|
|
10b38820bc | ||
|
|
ea91904f00 | ||
|
|
57fa18b940 | ||
|
|
2aae9e0a07 | ||
|
|
9a99957e73 | ||
|
|
b25665561e | ||
|
|
420d31ff4b | ||
|
|
db01efead3 | ||
|
|
5a76be306a | ||
|
|
69ae38effa | ||
|
|
9a6a457bc4 | ||
|
|
144df893d0 | ||
|
|
e17472ef07 | ||
|
|
f6a43254f5 | ||
|
|
94d2962985 | ||
|
|
95fdc593ed | ||
|
|
954fee41a0 | ||
|
|
0bcb182ec0 | ||
|
|
42d017e876 | ||
|
|
c66b720509 | ||
|
|
a5c9735619 | ||
|
|
6e18dca644 | ||
|
|
f3b99b08da | ||
|
|
d0bce15f8b | ||
|
|
d79bc0d083 | ||
|
|
8f8b46fa6f | ||
|
|
d1fa6d4f3b | ||
|
|
4af488b05e | ||
|
|
db0049d635 | ||
|
|
0fbd1fbe85 | ||
|
|
9d2297c684 | ||
|
|
e47fb2e651 | ||
|
|
ee43a12eb7 | ||
|
|
31deeebb49 | ||
|
|
117b2a4fc7 | ||
|
|
278dd4ba87 | ||
|
|
36e2092398 | ||
|
|
33ab2a6955 | ||
|
|
192aac5a81 | ||
|
|
964ea3bc0c | ||
|
|
e6828f86d7 | ||
|
|
51f69f6a59 | ||
|
|
097c92d904 | ||
|
|
b451e2db8c | ||
|
|
b3b94948a3 | ||
|
|
80afd382ad | ||
|
|
2c74ad6437 | ||
|
|
9fff553f1a | ||
|
|
4c2f0fb841 | ||
|
|
54f210d4de | ||
|
|
5540170341 | ||
|
|
7cc252fc36 | ||
|
|
cb2a371263 | ||
|
|
96da5bb5ea | ||
|
|
ef5762599a | ||
|
|
3aee575a35 | ||
|
|
80d5b5afa7 | ||
|
|
ab5c63c4b7 | ||
|
|
0a53550b0b | ||
|
|
f5c98c8400 | ||
|
|
eb1f247296 | ||
|
|
6e72be1b4c | ||
|
|
e4beb03a40 | ||
|
|
39ab836880 | ||
|
|
dafb2454fd | ||
|
|
9b49712669 | ||
|
|
0ab28266df | ||
|
|
b09ae48536 | ||
|
|
2aad0e3b16 | ||
|
|
58aac236bf | ||
|
|
ec24b6813d | ||
|
|
d398ed1345 | ||
|
|
fb10de1446 | ||
|
|
24dc0bbc88 | ||
|
|
fa9777e529 | ||
|
|
77213507fb | ||
|
|
bfec85c352 | ||
|
|
f3d3d40c75 | ||
|
|
5bf38d804e | ||
|
|
9dec9c5a18 | ||
|
|
43b5d4e22f | ||
|
|
fe19e0ef26 | ||
|
|
c0af297f48 | ||
|
|
c97e34aa04 | ||
|
|
01ee045beb | ||
|
|
cf6f83c8a2 | ||
|
|
4deaf4fb76 | ||
|
|
d68bc4abdb | ||
|
|
4f07515ee8 | ||
|
|
25b545d4c4 | ||
|
|
79b6b7ecc0 | ||
|
|
5d264ef5b6 | ||
|
|
f63ee85fa3 | ||
|
|
083a7069f0 | ||
|
|
f5621db85d | ||
|
|
658f117e93 | ||
|
|
6140ae525c | ||
|
|
afb02da806 | ||
|
|
692f29fe1a | ||
|
|
40e797966f | ||
|
|
a15a94a339 | ||
|
|
ca687cfe40 | ||
|
|
32e17745f1 | ||
|
|
432f3654df | ||
|
|
197cea2a60 | ||
|
|
b2bf368db9 | ||
|
|
287b2e3f41 | ||
|
|
da0fecfd0f | ||
|
|
76f9f635d8 | ||
|
|
3f05396222 | ||
|
|
644e6079b3 | ||
|
|
1d342cdbd0 | ||
|
|
908ec4c544 | ||
|
|
7c86f1f9d3 | ||
|
|
f8c01e379c | ||
|
|
af468a73bc | ||
|
|
d3a863911c | ||
|
|
c4172ee8e1 | ||
|
|
ed8ed15168 | ||
|
|
32f0426f01 | ||
|
|
200c00244b | ||
|
|
1104467329 | ||
|
|
5695fd8afb | ||
|
|
d0e383853f | ||
|
|
3bc412b42f | ||
|
|
f553d6919d | ||
|
|
d6a4b0f910 | ||
|
|
c0488d1f64 | ||
|
|
81195431b0 | ||
|
|
87109e6559 | ||
|
|
c0af1e62e8 | ||
|
|
ac9cce16f7 | ||
|
|
3ad660927f | ||
|
|
8778d70ad7 | ||
|
|
fe3fbb189c | ||
|
|
23c7f5f848 | ||
|
|
f1144efb93 | ||
|
|
9cec643cab | ||
|
|
1a7784a540 | ||
|
|
d24a3911f8 | ||
|
|
3735553003 | ||
|
|
f6d112e1f6 | ||
|
|
cc2d557706 | ||
|
|
103acc4b7e | ||
|
|
c3dc7c6307 | ||
|
|
7d6a2d5e33 | ||
|
|
6984c52b92 | ||
|
|
3a70547770 | ||
|
|
8a85b5c3d8 | ||
|
|
b998d35524 | ||
|
|
ddec64c4a5 | ||
|
|
8fed08003e | ||
|
|
8454c625f7 | ||
|
|
60df322f09 | ||
|
|
8bfb140e7c | ||
|
|
260227e79a | ||
|
|
cc310bf1a5 | ||
|
|
dbd52e2f34 | ||
|
|
9cd03bec46 | ||
|
|
c29452a858 | ||
|
|
7d91f2d8cb | ||
|
|
f6275f9f62 | ||
|
|
0d0550974a | ||
|
|
4e882d25d9 | ||
|
|
f93f78039b | ||
|
|
2b2463b834 | ||
|
|
0773c3915c | ||
|
|
2f5afe0d9c | ||
|
|
b8370686ec | ||
|
|
3b2d12eff9 | ||
|
|
cdaaa5584d | ||
|
|
3476de27f7 | ||
|
|
b55cfc2052 | ||
|
|
44751c370b | ||
|
|
32d904ca36 | ||
|
|
5424dfcf70 | ||
|
|
b8bf1eefa2 | ||
|
|
93291b6811 | ||
|
|
87ebcbe77e | ||
|
|
99b10942bb | ||
|
|
960a2d0634 | ||
|
|
e577de4e8e | ||
|
|
f3ef95cfe2 | ||
|
|
bc264d1adf | ||
|
|
5444395f34 | ||
|
|
2d2be1f6d0 | ||
|
|
1e269ac83d | ||
|
|
0c49709f26 | ||
|
|
019b2d5588 | ||
|
|
aa0807ca3f | ||
|
|
61a11a0857 | ||
|
|
0c20ae0e28 | ||
|
|
945a8f4841 | ||
|
|
ae76432944 | ||
|
|
40807db65e | ||
|
|
da22f1ed11 | ||
|
|
32b70efd5c | ||
|
|
6f07717369 | ||
|
|
d6cb23f782 | ||
|
|
9ac2638335 | ||
|
|
96cf09d594 | ||
|
|
8380c82028 | ||
|
|
5eb2926407 | ||
|
|
a4ab204400 | ||
|
|
6416c431c6 | ||
|
|
8f88aa69bf | ||
|
|
3c2b2a0734 | ||
|
|
39538f163f | ||
|
|
9ef04bb8d6 | ||
|
|
707f3bef61 | ||
|
|
878395221a | ||
|
|
6a35bbfa7e | ||
|
|
42f6f43870 | ||
|
|
6983c5bf7f | ||
|
|
b3ab5cbd2a | ||
|
|
8a5995920a | ||
|
|
8de6cf84d9 | ||
|
|
f5c36bb691 | ||
|
|
364f8b8e51 | ||
|
|
671d2eabd4 | ||
|
|
9a65ef6ea8 | ||
|
|
4e590ab618 | ||
|
|
026e80e7fc | ||
|
|
fdf6f0f9c8 | ||
|
|
0151e4c224 | ||
|
|
e8b0ea4f2d | ||
|
|
7c1ca04c75 | ||
|
|
0ba88d5ab6 | ||
|
|
96e229d803 | ||
|
|
d07d83fdfe | ||
|
|
5f82577bc1 | ||
|
|
35fcfb89c1 | ||
|
|
6e3fe08c4c | ||
|
|
7f06b148f4 | ||
|
|
bf303d1b2f | ||
|
|
59ca91d805 | ||
|
|
69bb0aa385 | ||
|
|
565970e779 | ||
|
|
fec3b1138b | ||
|
|
dcc0c0aa5d | ||
|
|
76673cb553 | ||
|
|
8f95fd6ca6 | ||
|
|
4907ef2a47 | ||
|
|
9ae3402631 | ||
|
|
d0dfc656e6 | ||
|
|
df3a34eec6 | ||
|
|
20cc34ca9d | ||
|
|
1b7f86b231 | ||
|
|
0d545bea0e | ||
|
|
204d71b2dd | ||
|
|
5cb9166c83 | ||
|
|
7828cc11ac | ||
|
|
34a7fdb733 | ||
|
|
7c361cf2d1 | ||
|
|
8beade0867 | ||
|
|
3afc2d7e4b | ||
|
|
d40401437a | ||
|
|
10ac7fd50a | ||
|
|
07962e81d4 | ||
|
|
785775327b | ||
|
|
80dfa5b7dd | ||
|
|
40425d49e0 | ||
|
|
0c87fa9877 | ||
|
|
5b79320302 | ||
|
|
1da2dfc349 | ||
|
|
d7bbfc515d | ||
|
|
0c22884729 | ||
|
|
fc9107c084 | ||
|
|
474d5e5975 | ||
|
|
f7f644cf36 | ||
|
|
b5f9aa0f15 | ||
|
|
cc5cf3b165 | ||
|
|
125bd64c91 | ||
|
|
ca47e8a09a | ||
|
|
52804a5b52 | ||
|
|
3ec62642dd | ||
|
|
1281ad1932 | ||
|
|
de32bddc20 | ||
|
|
79ea0fa9a6 | ||
|
|
683219dc1c | ||
|
|
d674ab9b73 | ||
|
|
5be1f9d7fe | ||
|
|
9e2b73a045 | ||
|
|
75e00c2bae | ||
|
|
989300f25d | ||
|
|
5226636fed | ||
|
|
8b3f3c69fc | ||
|
|
a39ab47e70 | ||
|
|
9cabd40429 | ||
|
|
6e3681896c | ||
|
|
8a1cabd2bc | ||
|
|
7a3e6789d1 | ||
|
|
92bc5ecf7b | ||
|
|
aebec0f942 | ||
|
|
54db9bbce8 | ||
|
|
676eb2f588 | ||
|
|
ce273adf77 | ||
|
|
0b33b51700 | ||
|
|
36ac47b975 | ||
|
|
bf193b1cac | ||
|
|
879aedeaa3 | ||
|
|
d556ee95c0 | ||
|
|
d93c9ba654 | ||
|
|
8a0dc1be7e | ||
|
|
564862e173 | ||
|
|
d7f7010bb5 | ||
|
|
e156dcc213 | ||
|
|
27a2a6ca03 | ||
|
|
581379f86f | ||
|
|
b62f3dec84 | ||
|
|
90d2950bdd | ||
|
|
5b7d64c1c1 | ||
|
|
55927ac3dd | ||
|
|
40c93bc19a | ||
|
|
59b8a2d6bb | ||
|
|
124738d810 | ||
|
|
19c0334a91 | ||
|
|
f22be3c587 | ||
|
|
9373a0bcaf | ||
|
|
5087ff08f2 | ||
|
|
71d5a1520a | ||
|
|
ec160df25e | ||
|
|
7fbf3dc656 | ||
|
|
7680194feb | ||
|
|
2fdb19ea75 | ||
|
|
8610332afc | ||
|
|
1f7c2eb52c | ||
|
|
119dfa78d9 | ||
|
|
337d22efbd | ||
|
|
5ff9ce0028 | ||
|
|
d4833affc6 | ||
|
|
8ad10b5adf | ||
|
|
fe31d15b9f | ||
|
|
99664ee544 | ||
|
|
57841b3c0a | ||
|
|
ed41b25889 | ||
|
|
4f27725b35 | ||
|
|
73835eced3 | ||
|
|
46fcc71dd8 | ||
|
|
453a657172 | ||
|
|
1514d014a9 | ||
|
|
e4d9243486 | ||
|
|
fb690c97e8 | ||
|
|
a0038315da | ||
|
|
aea550fe33 | ||
|
|
813444408e | ||
|
|
d8be8888ef | ||
|
|
431c3bdf2b | ||
|
|
c51b201362 | ||
|
|
7fed8febf1 | ||
|
|
f4a68e793e | ||
|
|
7d961537eb | ||
|
|
d7a2d83990 | ||
|
|
a36524e02a | ||
|
|
1073c3fc7d | ||
|
|
69d7e8e96c | ||
|
|
7f2b849963 | ||
|
|
0ce065e496 | ||
|
|
0b0958c20e | ||
|
|
06acd7fcde | ||
|
|
b1e00e6ff2 | ||
|
|
ea42dc52fd | ||
|
|
6586cb37a8 | ||
|
|
9b7ab14253 | ||
|
|
d6899af5e7 | ||
|
|
087cab177b | ||
|
|
5da558dfd9 | ||
|
|
953859831c | ||
|
|
a13a8771d1 | ||
|
|
5499c25528 | ||
|
|
1e469627b4 | ||
|
|
34ef25c4e4 | ||
|
|
d1aa446c89 | ||
|
|
e454acba41 | ||
|
|
75abb70bcd | ||
|
|
7ba98a212c | ||
|
|
6ae6ba5b3d | ||
|
|
439cdfbbff | ||
|
|
672fd4e4b0 | ||
|
|
0f1d379e58 | ||
|
|
a79c9b4449 | ||
|
|
0f8a29a493 | ||
|
|
a54d7c8f45 | ||
|
|
84109e416a | ||
|
|
083337de1c | ||
|
|
bd6bc135fd | ||
|
|
4611381a38 | ||
|
|
d6f4096cd0 | ||
|
|
a715da3d18 | ||
|
|
94ceefd960 | ||
|
|
27dd120e5d | ||
|
|
f5cee97fef | ||
|
|
a9aac0dbb0 | ||
|
|
4c6243176c | ||
|
|
a8047660a6 | ||
|
|
7c2843f7fd | ||
|
|
fd5154ae93 | ||
|
|
726628e20c | ||
|
|
585a82b51a | ||
|
|
5edccb9c35 | ||
|
|
555da878f4 | ||
|
|
df8658eff9 | ||
|
|
4c55807392 | ||
|
|
cb50d3a70d | ||
|
|
eaf14aa1eb | ||
|
|
a59e0da2af | ||
|
|
3a3ac6da4e | ||
|
|
d7809616a4 | ||
|
|
5b486b1480 | ||
|
|
5fc30bd33e | ||
|
|
522a5c6e01 | ||
|
|
1ae60ec9bc | ||
|
|
b8c718ce9e | ||
|
|
b407d0aee0 | ||
|
|
289f9d7946 | ||
|
|
905b78008d | ||
|
|
11961bb7c7 | ||
|
|
2be1fac585 | ||
|
|
b35340caa9 | ||
|
|
e6b3e2ec23 | ||
|
|
c07232698c | ||
|
|
58e992af13 | ||
|
|
a44b84ffd0 | ||
|
|
a3640cf812 | ||
|
|
03a75273e3 | ||
|
|
6176e50acf | ||
|
|
46a3466bc5 | ||
|
|
aba9db6a6b | ||
|
|
e5b34624ac | ||
|
|
c430cf0d88 | ||
|
|
1969e292f0 | ||
|
|
0db119d7ba | ||
|
|
c9b498fb08 | ||
|
|
78004fa4ca | ||
|
|
4de7737d14 | ||
|
|
f36df02f5d | ||
|
|
753872ea2a | ||
|
|
ca1c24050d | ||
|
|
61c2b1a007 | ||
|
|
8cac0872a4 | ||
|
|
70f1c5f8ec | ||
|
|
b416e5f9e8 | ||
|
|
bfe6835cab | ||
|
|
9e89964df2 | ||
|
|
04c3d0c1d3 | ||
|
|
c9996df11c | ||
|
|
49971ada07 | ||
|
|
e6b9d4e2aa | ||
|
|
93a374d0c6 | ||
|
|
0fc7c78e11 |
123
.eslintrc.js
123
.eslintrc.js
@@ -1,65 +1,66 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
|
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
|
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
|
||||||
sourceType: 'module', // Allows for the use of imports
|
sourceType: 'module', // Allows for the use of imports
|
||||||
ecmaFeatures: {
|
ecmaFeatures: {
|
||||||
jsx: true, // Allows for the parsing of JSX
|
jsx: true, // Allows for the parsing of JSX
|
||||||
},
|
|
||||||
},
|
},
|
||||||
ignorePatterns: [
|
},
|
||||||
'node_modules/*',
|
ignorePatterns: [
|
||||||
'**/node_modules/*',
|
'node_modules/*',
|
||||||
'.node_modules/*',
|
'**/node_modules/*',
|
||||||
'.github/*',
|
'.github/*',
|
||||||
'.browser_modules/*',
|
'.browser_modules/*',
|
||||||
'docs/*',
|
'docs/*',
|
||||||
'scripts/*',
|
'scripts/*',
|
||||||
'electron/*',
|
'electron-app/lib/*',
|
||||||
'electron-app/*',
|
'electron-app/src-gen/*',
|
||||||
'browser-app/*',
|
'electron-app/gen-webpack*.js',
|
||||||
'plugins/*',
|
'!electron-app/webpack.config.js',
|
||||||
'arduino-ide-extension/src/node/cli-protocol',
|
'electron-app/plugins/*',
|
||||||
|
'arduino-ide-extension/src/node/cli-protocol',
|
||||||
|
'**/lib/*',
|
||||||
|
],
|
||||||
|
settings: {
|
||||||
|
react: {
|
||||||
|
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
|
||||||
|
},
|
||||||
|
},
|
||||||
|
extends: [
|
||||||
|
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
|
||||||
|
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
|
||||||
|
'plugin:react-hooks/recommended', // Uses recommended rules from react hooks
|
||||||
|
'plugin:prettier/recommended',
|
||||||
|
'prettier', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
|
||||||
|
],
|
||||||
|
plugins: ['prettier', 'unused-imports'],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/no-unused-expressions': 'off',
|
||||||
|
'@typescript-eslint/no-namespace': 'off',
|
||||||
|
'@typescript-eslint/no-var-requires': 'off',
|
||||||
|
'@typescript-eslint/no-empty-function': 'warn',
|
||||||
|
'@typescript-eslint/no-empty-interface': 'warn',
|
||||||
|
'no-unused-vars': 'off',
|
||||||
|
'unused-imports/no-unused-imports': 'error',
|
||||||
|
'unused-imports/no-unused-vars': [
|
||||||
|
'warn',
|
||||||
|
{
|
||||||
|
vars: 'all',
|
||||||
|
varsIgnorePattern: '^_',
|
||||||
|
args: 'after-used',
|
||||||
|
argsIgnorePattern: '^_',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
settings: {
|
'react/display-name': 'warn',
|
||||||
react: {
|
eqeqeq: ['error', 'smart'],
|
||||||
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
|
'guard-for-in': 'off',
|
||||||
},
|
'id-blacklist': 'off',
|
||||||
},
|
'id-match': 'off',
|
||||||
extends: [
|
'no-underscore-dangle': 'off',
|
||||||
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
|
'no-unused-expressions': 'off',
|
||||||
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
|
'no-var': 'error',
|
||||||
'plugin:react-hooks/recommended', // Uses recommended rules from react hooks
|
radix: 'error',
|
||||||
'plugin:prettier/recommended',
|
'prettier/prettier': 'warn',
|
||||||
'prettier', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
|
},
|
||||||
],
|
|
||||||
plugins: ['prettier', 'unused-imports'],
|
|
||||||
rules: {
|
|
||||||
'@typescript-eslint/no-unused-expressions': 'off',
|
|
||||||
'@typescript-eslint/no-namespace': 'off',
|
|
||||||
'@typescript-eslint/no-var-requires': 'off',
|
|
||||||
'@typescript-eslint/no-empty-function': 'warn',
|
|
||||||
'@typescript-eslint/no-empty-interface': 'warn',
|
|
||||||
'no-unused-vars': 'off',
|
|
||||||
'unused-imports/no-unused-imports': 'error',
|
|
||||||
'unused-imports/no-unused-vars': [
|
|
||||||
'warn',
|
|
||||||
{
|
|
||||||
vars: 'all',
|
|
||||||
varsIgnorePattern: '^_',
|
|
||||||
args: 'after-used',
|
|
||||||
argsIgnorePattern: '^_',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'react/display-name': 'warn',
|
|
||||||
eqeqeq: ['error', 'smart'],
|
|
||||||
'guard-for-in': 'off',
|
|
||||||
'id-blacklist': 'off',
|
|
||||||
'id-match': 'off',
|
|
||||||
'no-underscore-dangle': 'off',
|
|
||||||
'no-unused-expressions': 'off',
|
|
||||||
'no-var': 'error',
|
|
||||||
radix: 'error',
|
|
||||||
'prettier/prettier': 'warn',
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|||||||
74
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
Normal file
74
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
name: Bug report
|
||||||
|
description: Report a problem with the code or documentation in this repository.
|
||||||
|
labels:
|
||||||
|
- 'type: imperfection'
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: Describe the problem
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: reproduce
|
||||||
|
attributes:
|
||||||
|
label: To reproduce
|
||||||
|
description: Provide the specific set of steps we can follow to reproduce the problem.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: expected
|
||||||
|
attributes:
|
||||||
|
label: Expected behavior
|
||||||
|
description: What would you expect to happen after following those instructions?
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: project-version
|
||||||
|
attributes:
|
||||||
|
label: Arduino IDE version
|
||||||
|
description: |
|
||||||
|
Which version of the Arduino IDE are you using?
|
||||||
|
See **Help > About Arduino IDE** in the Arduino IDE menus (**Arduino IDE > About Arduino IDE** on macOS).
|
||||||
|
This should be the latest [nightly build](https://www.arduino.cc/en/software#nightly-builds).
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: os
|
||||||
|
attributes:
|
||||||
|
label: Operating system
|
||||||
|
description: Which operating system(s) are you using on your computer?
|
||||||
|
multiple: true
|
||||||
|
options:
|
||||||
|
- Windows
|
||||||
|
- Linux
|
||||||
|
- macOS
|
||||||
|
- N/A
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: os-version
|
||||||
|
attributes:
|
||||||
|
label: Operating system version
|
||||||
|
description: Which version of the operating system are you using on your computer?
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: additional
|
||||||
|
attributes:
|
||||||
|
label: Additional context
|
||||||
|
description: Add any additional information here.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: checkboxes
|
||||||
|
id: checklist
|
||||||
|
attributes:
|
||||||
|
label: Issue checklist
|
||||||
|
description: Please double-check that you have done each of the following things before submitting the issue.
|
||||||
|
options:
|
||||||
|
- label: I searched for previous reports in [the issue tracker](https://github.com/arduino/arduino-ide/issues?q=)
|
||||||
|
required: true
|
||||||
|
- label: I verified the problem still occurs when using the latest [nightly build](https://www.arduino.cc/en/software#nightly-builds)
|
||||||
|
required: true
|
||||||
|
- label: My report contains all necessary details
|
||||||
|
required: true
|
||||||
32
.github/ISSUE_TEMPLATE/bug_report.md
vendored
32
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,32 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a report to help us improve
|
|
||||||
title: ''
|
|
||||||
labels: 'type: imperfection'
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Describe the bug**
|
|
||||||
A clear and concise description of what the bug is.
|
|
||||||
|
|
||||||
**To Reproduce**
|
|
||||||
Steps to reproduce the behavior:
|
|
||||||
1. Go to '...'
|
|
||||||
2. Click on '....'
|
|
||||||
3. Scroll down to '....'
|
|
||||||
4. See error
|
|
||||||
|
|
||||||
**Expected behavior**
|
|
||||||
A clear and concise description of what you expected to happen.
|
|
||||||
|
|
||||||
**Screenshots**
|
|
||||||
If applicable, add screenshots to help explain your problem.
|
|
||||||
|
|
||||||
**Desktop (please complete the following information):**
|
|
||||||
- OS: [e.g. Windows]
|
|
||||||
- Version: [e.g. 2.0.0]
|
|
||||||
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context about the problem here.
|
|
||||||
19
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
19
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Source:
|
||||||
|
# https://github.com/arduino/tooling-project-assets/blob/main/issue-templates/template-choosers/general/config.yml
|
||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: Learn about using this project
|
||||||
|
url: https://github.com/arduino/arduino-ide#readme
|
||||||
|
about: Detailed usage documentation is available here.
|
||||||
|
- name: Support request
|
||||||
|
url: https://forum.arduino.cc/
|
||||||
|
about: We can help you out on the Arduino Forum!
|
||||||
|
- name: Issue report guide
|
||||||
|
url: https://github.com/arduino/arduino-ide/blob/main/docs/contributor-guide/issues.md#issue-report-guide
|
||||||
|
about: Learn about submitting issue reports to this repository.
|
||||||
|
- name: Contributor guide
|
||||||
|
url: https://github.com/arduino/arduino-ide/blob/main/docs/CONTRIBUTING.md#contributor-guide
|
||||||
|
about: Learn about contributing to this project.
|
||||||
|
- name: Discuss development work on the project
|
||||||
|
url: https://groups.google.com/a/arduino.cc/g/developers
|
||||||
|
about: Arduino Developers Mailing List
|
||||||
69
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
Normal file
69
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
name: Feature request
|
||||||
|
description: Suggest an enhancement to this project.
|
||||||
|
labels:
|
||||||
|
- 'type: enhancement'
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: Describe the request
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: current
|
||||||
|
attributes:
|
||||||
|
label: Describe the current behavior
|
||||||
|
description: |
|
||||||
|
What is the current behavior of the Arduino IDE in relation to your request?
|
||||||
|
How can we reproduce that behavior?
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: project-version
|
||||||
|
attributes:
|
||||||
|
label: Arduino IDE version
|
||||||
|
description: |
|
||||||
|
Which version of the Arduino IDE are you using?
|
||||||
|
See **Help > About Arduino IDE** in the Arduino IDE menus (**Arduino IDE > About Arduino IDE** on macOS).
|
||||||
|
This should be the latest [nightly build](https://www.arduino.cc/en/software#nightly-builds).
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: os
|
||||||
|
attributes:
|
||||||
|
label: Operating system
|
||||||
|
description: Which operating system(s) are you using on your computer?
|
||||||
|
multiple: true
|
||||||
|
options:
|
||||||
|
- Windows
|
||||||
|
- Linux
|
||||||
|
- macOS
|
||||||
|
- N/A
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: os-version
|
||||||
|
attributes:
|
||||||
|
label: Operating system version
|
||||||
|
description: Which version of the operating system are you using on your computer?
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: additional
|
||||||
|
attributes:
|
||||||
|
label: Additional context
|
||||||
|
description: Add any additional information here.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: checkboxes
|
||||||
|
id: checklist
|
||||||
|
attributes:
|
||||||
|
label: Issue checklist
|
||||||
|
description: Please double-check that you have done each of the following things before submitting the issue.
|
||||||
|
options:
|
||||||
|
- label: I searched for previous requests in [the issue tracker](https://github.com/arduino/arduino-ide/issues?q=)
|
||||||
|
required: true
|
||||||
|
- label: I verified the feature was still missing when using the latest [nightly build](https://www.arduino.cc/en/software#nightly-builds)
|
||||||
|
required: true
|
||||||
|
- label: My request contains all necessary details
|
||||||
|
required: true
|
||||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
title: ''
|
|
||||||
labels: 'type: enhancement'
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
|
||||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
||||||
|
|
||||||
**Describe the solution you'd like**
|
|
||||||
A clear and concise description of what you want to happen.
|
|
||||||
|
|
||||||
**Describe alternatives you've considered**
|
|
||||||
A clear and concise description of any alternative solutions or features you've considered.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
||||||
18
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
18
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
### Motivation
|
||||||
|
|
||||||
|
<!-- Why this pull request? -->
|
||||||
|
|
||||||
|
### Change description
|
||||||
|
|
||||||
|
<!-- What does your code do? -->
|
||||||
|
|
||||||
|
### Other information
|
||||||
|
|
||||||
|
<!-- Any additional information that could help the review process -->
|
||||||
|
|
||||||
|
### Reviewer checklist
|
||||||
|
|
||||||
|
- [ ] PR addresses a single concern.
|
||||||
|
- [ ] The PR has no duplicates (please search among the [Pull Requests](https://github.com/arduino/arduino-ide/pulls) before creating one)
|
||||||
|
- [ ] PR title and description are properly filled.
|
||||||
|
- [ ] Docs have been added / updated (for bug fixes / features)
|
||||||
15
.github/dependabot.yml
vendored
Normal file
15
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# See: https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#about-the-dependabotyml-file
|
||||||
|
version: 2
|
||||||
|
|
||||||
|
updates:
|
||||||
|
# Configure check for outdated GitHub Actions actions in workflows.
|
||||||
|
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/dependabot/README.md
|
||||||
|
# See: https://docs.github.com/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
|
||||||
|
- package-ecosystem: github-actions
|
||||||
|
directory: / # Check the repository's workflows under /.github/workflows/
|
||||||
|
assignees:
|
||||||
|
- per1234
|
||||||
|
schedule:
|
||||||
|
interval: daily
|
||||||
|
labels:
|
||||||
|
- 'topic: infrastructure'
|
||||||
31
.github/label-configuration-files/labels.yml
vendored
31
.github/label-configuration-files/labels.yml
vendored
@@ -1,24 +1,27 @@
|
|||||||
# Used by the "Sync Labels" workflow
|
# Used by the "Sync Labels" workflow
|
||||||
# See: https://github.com/Financial-Times/github-label-sync#label-config-file
|
# See: https://github.com/Financial-Times/github-label-sync#label-config-file
|
||||||
|
|
||||||
- name: "topic: accessibility"
|
- name: 'topic: accessibility'
|
||||||
color: "00ffff"
|
color: '00ffff'
|
||||||
description: Enabling the use of the software by everyone
|
description: Enabling the use of the software by everyone
|
||||||
- name: "topic: CLI"
|
- name: 'topic: CLI'
|
||||||
color: "00ffff"
|
color: '00ffff'
|
||||||
description: Related to Arduino CLI
|
description: Related to Arduino CLI
|
||||||
- name: "topic: debugger"
|
- name: 'topic: cloud'
|
||||||
color: "00ffff"
|
color: '00ffff'
|
||||||
|
description: Related to Arduino Cloud and cloud sketches
|
||||||
|
- name: 'topic: debugger'
|
||||||
|
color: '00ffff'
|
||||||
description: Related to the integrated debugger
|
description: Related to the integrated debugger
|
||||||
- name: "topic: language server"
|
- name: 'topic: language server'
|
||||||
color: "00ffff"
|
color: '00ffff'
|
||||||
description: Related to the Arduino Language Server
|
description: Related to the Arduino Language Server
|
||||||
- name: "topic: serial monitor"
|
- name: 'topic: serial monitor'
|
||||||
color: "00ffff"
|
color: '00ffff'
|
||||||
description: Related to the Serial Monitor
|
description: Related to the Serial Monitor
|
||||||
- name: "topic: theia"
|
- name: 'topic: theia'
|
||||||
color: "00ffff"
|
color: '00ffff'
|
||||||
description: Related to the Theia IDE framework
|
description: Related to the Theia IDE framework
|
||||||
- name: "topic: theme"
|
- name: 'topic: theme'
|
||||||
color: "00ffff"
|
color: '00ffff'
|
||||||
description: Related to GUI theming
|
description: Related to GUI theming
|
||||||
|
|||||||
131
.github/tools/fetch_athena_stats.py
vendored
131
.github/tools/fetch_athena_stats.py
vendored
@@ -1,131 +0,0 @@
|
|||||||
import boto3
|
|
||||||
import semver
|
|
||||||
import os
|
|
||||||
import logging
|
|
||||||
import uuid
|
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
# logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
|
|
||||||
log = logging.getLogger()
|
|
||||||
logging.getLogger("boto3").setLevel(logging.CRITICAL)
|
|
||||||
logging.getLogger("botocore").setLevel(logging.CRITICAL)
|
|
||||||
logging.getLogger("urllib3").setLevel(logging.CRITICAL)
|
|
||||||
|
|
||||||
|
|
||||||
def execute(client, statement, dest_s3_output_location):
|
|
||||||
log.info("execute query: {} dumping in {}".format(statement, dest_s3_output_location))
|
|
||||||
result = client.start_query_execution(
|
|
||||||
QueryString=statement,
|
|
||||||
ClientRequestToken=str(uuid.uuid4()),
|
|
||||||
ResultConfiguration={
|
|
||||||
"OutputLocation": dest_s3_output_location,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
execution_id = result["QueryExecutionId"]
|
|
||||||
log.info("wait for query {} completion".format(execution_id))
|
|
||||||
wait_for_query_execution_completion(client, execution_id)
|
|
||||||
log.info("operation successful")
|
|
||||||
return execution_id
|
|
||||||
|
|
||||||
|
|
||||||
def wait_for_query_execution_completion(client, query_execution_id):
|
|
||||||
query_ended = False
|
|
||||||
while not query_ended:
|
|
||||||
query_execution = client.get_query_execution(QueryExecutionId=query_execution_id)
|
|
||||||
state = query_execution["QueryExecution"]["Status"]["State"]
|
|
||||||
if state == "SUCCEEDED":
|
|
||||||
query_ended = True
|
|
||||||
elif state in ["FAILED", "CANCELLED"]:
|
|
||||||
raise BaseException(
|
|
||||||
"query failed or canceled: {}".format(query_execution["QueryExecution"]["Status"]["StateChangeReason"])
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
|
|
||||||
def valid(key):
|
|
||||||
split = key.split("_")
|
|
||||||
if len(split) < 1:
|
|
||||||
return False
|
|
||||||
try:
|
|
||||||
semver.parse(split[0])
|
|
||||||
except ValueError:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def get_results(client, execution_id):
|
|
||||||
results_paginator = client.get_paginator("get_query_results")
|
|
||||||
results_iter = results_paginator.paginate(QueryExecutionId=execution_id, PaginationConfig={"PageSize": 1000})
|
|
||||||
res = {}
|
|
||||||
for results_page in results_iter:
|
|
||||||
for row in results_page["ResultSet"]["Rows"][1:]:
|
|
||||||
# Loop through the JSON objects
|
|
||||||
key = row["Data"][0]["VarCharValue"]
|
|
||||||
if valid(key):
|
|
||||||
res[key] = row["Data"][1]["VarCharValue"]
|
|
||||||
|
|
||||||
return res
|
|
||||||
|
|
||||||
|
|
||||||
def convert_data(data):
|
|
||||||
result = []
|
|
||||||
for key, value in data.items():
|
|
||||||
# 0.18.0_macOS_64bit.tar.gz
|
|
||||||
split_key = key.split("_")
|
|
||||||
if len(split_key) != 3:
|
|
||||||
continue
|
|
||||||
(version, os_version, arch) = split_key
|
|
||||||
arch_split = arch.split(".")
|
|
||||||
if len(arch_split) < 1:
|
|
||||||
continue
|
|
||||||
arch = arch_split[0]
|
|
||||||
if len(arch) > 10:
|
|
||||||
# This can't be an architecture really.
|
|
||||||
# It's an ugly solution but works for now so deal with it.
|
|
||||||
continue
|
|
||||||
repo = os.environ["GITHUB_REPOSITORY"].split("/")[1]
|
|
||||||
result.append(
|
|
||||||
{
|
|
||||||
"type": "gauge",
|
|
||||||
"name": "arduino.downloads.total",
|
|
||||||
"value": value,
|
|
||||||
"host": os.environ["GITHUB_REPOSITORY"],
|
|
||||||
"tags": [
|
|
||||||
f"version:{version}",
|
|
||||||
f"os:{os_version}",
|
|
||||||
f"arch:{arch}",
|
|
||||||
"cdn:downloads.arduino.cc",
|
|
||||||
f"project:{repo}",
|
|
||||||
],
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
DEST_S3_OUTPUT = os.environ["AWS_ATHENA_OUTPUT_LOCATION"]
|
|
||||||
AWS_ATHENA_SOURCE_TABLE = os.environ["AWS_ATHENA_SOURCE_TABLE"]
|
|
||||||
|
|
||||||
session = boto3.session.Session(region_name="us-east-1")
|
|
||||||
athena_client = session.client("athena")
|
|
||||||
|
|
||||||
# Load all partitions before querying downloads
|
|
||||||
execute(athena_client, f"MSCK REPAIR TABLE {AWS_ATHENA_SOURCE_TABLE};", DEST_S3_OUTPUT)
|
|
||||||
|
|
||||||
query = f"""SELECT replace(json_extract_scalar(url_decode(url_decode(querystring)),
|
|
||||||
'$.data.url'), 'https://downloads.arduino.cc/arduino-ide/arduino-ide_', '')
|
|
||||||
AS flavor, count(json_extract(url_decode(url_decode(querystring)),'$')) AS gauge
|
|
||||||
FROM {AWS_ATHENA_SOURCE_TABLE}
|
|
||||||
WHERE json_extract_scalar(url_decode(url_decode(querystring)),'$.data.url')
|
|
||||||
LIKE 'https://downloads.arduino.cc/arduino-ide/arduino-ide_%'
|
|
||||||
AND json_extract_scalar(url_decode(url_decode(querystring)),'$.data.url')
|
|
||||||
NOT LIKE '%latest%' -- exclude latest redirect
|
|
||||||
group by 1 ;"""
|
|
||||||
exec_id = execute(athena_client, query, DEST_S3_OUTPUT)
|
|
||||||
results = get_results(athena_client, exec_id)
|
|
||||||
result_json = convert_data(results)
|
|
||||||
|
|
||||||
print(f"::set-output name=result::{result_json}")
|
|
||||||
57
.github/workflows/arduino-stats.yaml
vendored
57
.github/workflows/arduino-stats.yaml
vendored
@@ -1,57 +0,0 @@
|
|||||||
name: arduino-stats
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
# run every day at 07:00 AM, 03:00 PM and 11:00 PM
|
|
||||||
- cron: "0 7,15,23 * * *"
|
|
||||||
workflow_dispatch:
|
|
||||||
repository_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
push-stats:
|
|
||||||
# This workflow is only of value to the arduino/arduino-ide repository and
|
|
||||||
# would always fail in forks
|
|
||||||
if: github.repository == 'arduino/arduino-ide'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: '3.x'
|
|
||||||
|
|
||||||
- name: Fetch downloads count form Arduino CDN using AWS Athena
|
|
||||||
id: fetch
|
|
||||||
env:
|
|
||||||
AWS_ACCESS_KEY_ID: ${{ secrets.STATS_AWS_ACCESS_KEY_ID }}
|
|
||||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.STATS_AWS_SECRET_ACCESS_KEY }}
|
|
||||||
AWS_ATHENA_SOURCE_TABLE: ${{ secrets.STATS_AWS_ATHENA_SOURCE_TABLE }}
|
|
||||||
AWS_ATHENA_OUTPUT_LOCATION: ${{ secrets.STATS_AWS_ATHENA_OUTPUT_LOCATION }}
|
|
||||||
GITHUB_REPOSITORY: ${{ github.repository }}
|
|
||||||
run: |
|
|
||||||
pip install boto3 semver
|
|
||||||
python .github/tools/fetch_athena_stats.py
|
|
||||||
|
|
||||||
- name: Send metrics
|
|
||||||
uses: masci/datadog@v1
|
|
||||||
with:
|
|
||||||
api-key: ${{ secrets.DD_API_KEY }}
|
|
||||||
# Metrics input expects YAML but JSON will work just right.
|
|
||||||
metrics: ${{steps.fetch.outputs.result}}
|
|
||||||
|
|
||||||
- name: Report failure
|
|
||||||
if: failure()
|
|
||||||
uses: masci/datadog@v1
|
|
||||||
with:
|
|
||||||
api-key: ${{ secrets.DD_API_KEY }}
|
|
||||||
events: |
|
|
||||||
- title: "Arduino IDE stats failing"
|
|
||||||
text: "Stats collection failed"
|
|
||||||
alert_type: "error"
|
|
||||||
host: ${{ github.repository }}
|
|
||||||
tags:
|
|
||||||
- "project:arduino-ide"
|
|
||||||
- "cdn:downloads.arduino.cc"
|
|
||||||
- "workflow:${{ github.workflow }}"
|
|
||||||
63
.github/workflows/assets/linux.Dockerfile
vendored
Normal file
63
.github/workflows/assets/linux.Dockerfile
vendored
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# The Arduino IDE Linux build workflow job runs in this container.
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
# See: https://hub.docker.com/_/ubuntu/tags
|
||||||
|
FROM ubuntu:18.10
|
||||||
|
|
||||||
|
# This is required in order to use the Ubuntu package repositories for EOL Ubuntu versions:
|
||||||
|
# https://help.ubuntu.com/community/EOLUpgrades#Update_sources.list
|
||||||
|
RUN \
|
||||||
|
sed \
|
||||||
|
--in-place \
|
||||||
|
--regexp-extended \
|
||||||
|
--expression='s/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' \
|
||||||
|
"/etc/apt/sources.list"
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
apt-get \
|
||||||
|
--yes \
|
||||||
|
update
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
apt-get \
|
||||||
|
--yes \
|
||||||
|
install \
|
||||||
|
"git"
|
||||||
|
|
||||||
|
# The repository path must be added to safe.directory, otherwise any Git operations on it would fail with a
|
||||||
|
# "dubious ownership" error. actions/checkout configures this, but it is not applied to containers.
|
||||||
|
RUN \
|
||||||
|
git config \
|
||||||
|
--add \
|
||||||
|
--global \
|
||||||
|
"safe.directory" "/__w/arduino-ide/arduino-ide"
|
||||||
|
ENV \
|
||||||
|
GIT_CONFIG_GLOBAL="/root/.gitconfig"
|
||||||
|
|
||||||
|
# Install Python
|
||||||
|
# The Python installed by actions/setup-python has dependency on a higher version of glibc than available in the
|
||||||
|
# container.
|
||||||
|
RUN \
|
||||||
|
apt-get \
|
||||||
|
--yes \
|
||||||
|
install \
|
||||||
|
"python3.7-minimal=3.7.3-2~18.10"
|
||||||
|
|
||||||
|
# Install Theia's package dependencies
|
||||||
|
# These are pre-installed in the GitHub Actions hosted runner machines.
|
||||||
|
RUN \
|
||||||
|
apt-get \
|
||||||
|
--yes \
|
||||||
|
install \
|
||||||
|
"libsecret-1-dev=0.18.6-3" \
|
||||||
|
"libx11-dev=2:1.6.7-1" \
|
||||||
|
"libxkbfile-dev=1:1.0.9-2"
|
||||||
|
|
||||||
|
# Target python3 symlink to Python 3.7 installation. It would otherwise target version 3.6 due to the installation of
|
||||||
|
# the `python3` package as a transitive dependency.
|
||||||
|
RUN \
|
||||||
|
ln \
|
||||||
|
--symbolic \
|
||||||
|
--force \
|
||||||
|
"$(which python3.7)" \
|
||||||
|
"/usr/bin/python3"
|
||||||
678
.github/workflows/build.yml
vendored
678
.github/workflows/build.yml
vendored
@@ -1,144 +1,546 @@
|
|||||||
name: Arduino IDE
|
name: Arduino IDE
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
create:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
- '[0-9]+.[0-9]+.x'
|
||||||
|
paths-ignore:
|
||||||
|
- '.github/**'
|
||||||
|
- '!.github/workflows/build.yml'
|
||||||
|
- '.vscode/**'
|
||||||
|
- 'docs/**'
|
||||||
|
- 'scripts/**'
|
||||||
|
- '!scripts/merge-channel-files.js'
|
||||||
|
- 'static/**'
|
||||||
|
- '*.md'
|
||||||
tags:
|
tags:
|
||||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
paid-runners:
|
||||||
|
description: Include builds on non-free runners
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
paths-ignore:
|
||||||
- main
|
- '.github/**'
|
||||||
|
- '!.github/workflows/build.yml'
|
||||||
|
- '.vscode/**'
|
||||||
|
- 'docs/**'
|
||||||
|
- 'scripts/**'
|
||||||
|
- '!scripts/merge-channel-files.js'
|
||||||
|
- 'static/**'
|
||||||
|
- '*.md'
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 3 * * *' # run every day at 3AM (https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule)
|
- cron: '0 3 * * *' # run every day at 3AM (https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule)
|
||||||
|
workflow_run:
|
||||||
|
workflows:
|
||||||
|
- Push Container Images
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
|
||||||
env:
|
env:
|
||||||
JOB_TRANSFER_ARTIFACT: build-artifacts
|
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
||||||
|
GO_VERSION: '1.21'
|
||||||
|
# See: https://github.com/actions/setup-node/#readme
|
||||||
|
NODE_VERSION: '18.17'
|
||||||
|
YARN_VERSION: '1.22'
|
||||||
|
JOB_TRANSFER_ARTIFACT_PREFIX: build-artifacts-
|
||||||
CHANGELOG_ARTIFACTS: changelog
|
CHANGELOG_ARTIFACTS: changelog
|
||||||
|
STAGED_CHANNEL_FILE_ARTIFACT_PREFIX: staged-channel-file-
|
||||||
|
BASE_BUILD_DATA: |
|
||||||
|
- config:
|
||||||
|
# Human identifier for the job.
|
||||||
|
name: Windows
|
||||||
|
runs-on: [self-hosted, windows-sign-pc]
|
||||||
|
# The value is a string representing a JSON document.
|
||||||
|
# Setting this to null causes the job to run directly in the runner machine instead of in a container.
|
||||||
|
container: |
|
||||||
|
null
|
||||||
|
# Name of the secret that contains the certificate.
|
||||||
|
certificate-secret: INSTALLER_CERT_WINDOWS_CER
|
||||||
|
# Name of the secret that contains the certificate password.
|
||||||
|
certificate-password-secret: INSTALLER_CERT_WINDOWS_PASSWORD
|
||||||
|
# File extension for the certificate.
|
||||||
|
certificate-extension: pfx
|
||||||
|
# Container for windows cert signing
|
||||||
|
certificate-container: INSTALLER_CERT_WINDOWS_CONTAINER
|
||||||
|
# Arbitrary identifier used to give the workflow artifact uploaded by each "build" matrix job a unique name.
|
||||||
|
job-transfer-artifact-suffix: Windows_64bit
|
||||||
|
# Quoting on the value is required here to allow the same comparison expression syntax to be used for this
|
||||||
|
# and the companion needs.select-targets.outputs.merge-channel-files property (output values always have string
|
||||||
|
# type).
|
||||||
|
mergeable-channel-file: 'false'
|
||||||
|
# as this runs on a self hosted runner, we need to avoid building with the default working directory path,
|
||||||
|
# otherwise paths in the build job will be too long for `light.exe`
|
||||||
|
# we use the below as a Symbolic link (just changing the wd will break the checkout action)
|
||||||
|
# this is a work around (see: https://github.com/actions/checkout/issues/197).
|
||||||
|
working-directory: 'C:\a'
|
||||||
|
artifacts:
|
||||||
|
- path: '*Windows_64bit.exe'
|
||||||
|
name: Windows_X86-64_interactive_installer
|
||||||
|
- path: '*Windows_64bit.msi'
|
||||||
|
name: Windows_X86-64_MSI
|
||||||
|
- path: '*Windows_64bit.zip'
|
||||||
|
name: Windows_X86-64_zip
|
||||||
|
- config:
|
||||||
|
name: Linux
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: |
|
||||||
|
{
|
||||||
|
\"image\": \"ghcr.io/arduino/arduino-ide/linux:main\"
|
||||||
|
}
|
||||||
|
job-transfer-artifact-suffix: Linux_64bit
|
||||||
|
mergeable-channel-file: 'false'
|
||||||
|
artifacts:
|
||||||
|
- path: '*Linux_64bit.zip'
|
||||||
|
name: Linux_X86-64_zip
|
||||||
|
- path: '*Linux_64bit.AppImage'
|
||||||
|
name: Linux_X86-64_app_image
|
||||||
|
- config:
|
||||||
|
name: macOS x86
|
||||||
|
runs-on: macos-13
|
||||||
|
container: |
|
||||||
|
null
|
||||||
|
# APPLE_SIGNING_CERTIFICATE_P12 secret was produced by following the procedure from:
|
||||||
|
# https://www.kencochrane.com/2020/08/01/build-and-sign-golang-binaries-for-macos-with-github-actions/#exporting-the-developer-certificate
|
||||||
|
certificate-secret: APPLE_SIGNING_CERTIFICATE_P12
|
||||||
|
certificate-password-secret: KEYCHAIN_PASSWORD
|
||||||
|
certificate-extension: p12
|
||||||
|
job-transfer-artifact-suffix: macOS_64bit
|
||||||
|
mergeable-channel-file: 'true'
|
||||||
|
artifacts:
|
||||||
|
- path: '*macOS_64bit.dmg'
|
||||||
|
name: macOS_X86-64_dmg
|
||||||
|
- path: '*macOS_64bit.zip'
|
||||||
|
name: macOS_X86-64_zip
|
||||||
|
- config:
|
||||||
|
name: macOS ARM
|
||||||
|
runs-on: macos-latest
|
||||||
|
container: |
|
||||||
|
null
|
||||||
|
certificate-secret: APPLE_SIGNING_CERTIFICATE_P12
|
||||||
|
certificate-password-secret: KEYCHAIN_PASSWORD
|
||||||
|
certificate-extension: p12
|
||||||
|
job-transfer-artifact-suffix: macOS_arm64
|
||||||
|
mergeable-channel-file: 'true'
|
||||||
|
artifacts:
|
||||||
|
- path: '*macOS_arm64.dmg'
|
||||||
|
name: macOS_arm64_dmg
|
||||||
|
- path: '*macOS_arm64.zip'
|
||||||
|
name: macOS_arm64_zip
|
||||||
|
PAID_RUNNER_BUILD_DATA: |
|
||||||
|
# This system was implemented to allow selective use of paid GitHub-hosted runners, due to the Apple Silicon runner
|
||||||
|
# incurring a charge at that time. Free Apple Silicon runners are now available so the configuration was moved to
|
||||||
|
# `BASE_BUILD_DATA`, but the system was left in place for future use.
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
run-determination:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
result: ${{ steps.determination.outputs.result }}
|
||||||
|
permissions: {}
|
||||||
|
steps:
|
||||||
|
- name: Determine if the rest of the workflow should run
|
||||||
|
id: determination
|
||||||
|
run: |
|
||||||
|
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
|
||||||
|
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
|
||||||
|
if [[
|
||||||
|
"${{ github.event_name }}" != "create" ||
|
||||||
|
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
|
||||||
|
]]; then
|
||||||
|
# Run the other jobs.
|
||||||
|
RESULT="true"
|
||||||
|
else
|
||||||
|
# There is no need to run the other jobs.
|
||||||
|
RESULT="false"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "result=$RESULT" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
build-type-determination:
|
||||||
|
needs: run-determination
|
||||||
|
if: needs.run-determination.outputs.result == 'true'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
is-release: ${{ steps.determination.outputs.is-release }}
|
||||||
|
is-nightly: ${{ steps.determination.outputs.is-nightly }}
|
||||||
|
channel-name: ${{ steps.determination.outputs.channel-name }}
|
||||||
|
publish-to-s3: ${{ steps.determination.outputs.publish-to-s3 }}
|
||||||
|
environment: production
|
||||||
|
permissions: {}
|
||||||
|
steps:
|
||||||
|
- name: Determine the type of build
|
||||||
|
id: determination
|
||||||
|
run: |
|
||||||
|
if [[
|
||||||
|
"${{ startsWith(github.ref, 'refs/tags/') }}" == "true"
|
||||||
|
]]; then
|
||||||
|
is_release="true"
|
||||||
|
is_nightly="false"
|
||||||
|
channel_name="stable"
|
||||||
|
elif [[
|
||||||
|
"${{ github.event_name }}" == "schedule" ||
|
||||||
|
(
|
||||||
|
"${{ github.event_name }}" == "workflow_dispatch" &&
|
||||||
|
"${{ github.ref }}" == "refs/heads/main"
|
||||||
|
)
|
||||||
|
]]; then
|
||||||
|
is_release="false"
|
||||||
|
is_nightly="true"
|
||||||
|
channel_name="nightly"
|
||||||
|
else
|
||||||
|
is_release="false"
|
||||||
|
is_nightly="false"
|
||||||
|
channel_name="nightly"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "is-release=$is_release" >> $GITHUB_OUTPUT
|
||||||
|
echo "is-nightly=$is_nightly" >> $GITHUB_OUTPUT
|
||||||
|
echo "channel-name=$channel_name" >> $GITHUB_OUTPUT
|
||||||
|
# Only attempt upload to Amazon S3 if the credentials are available.
|
||||||
|
echo "publish-to-s3=${{ secrets.AWS_ROLE_ARN != '' }}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
select-targets:
|
||||||
|
needs: build-type-determination
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
artifact-matrix: ${{ steps.assemble.outputs.artifact-matrix }}
|
||||||
|
build-matrix: ${{ steps.assemble.outputs.build-matrix }}
|
||||||
|
merge-channel-files: ${{ steps.assemble.outputs.merge-channel-files }}
|
||||||
|
permissions: {}
|
||||||
|
steps:
|
||||||
|
- name: Assemble target data
|
||||||
|
id: assemble
|
||||||
|
run: |
|
||||||
|
# Only run the builds that incur runner charges on release or select manually triggered runs.
|
||||||
|
if [[
|
||||||
|
"${{ needs.build-type-determination.outputs.is-release }}" == "true" ||
|
||||||
|
"${{ github.event.inputs.paid-runners }}" == "true"
|
||||||
|
]]; then
|
||||||
|
build_matrix="$(
|
||||||
|
(
|
||||||
|
echo "${{ env.BASE_BUILD_DATA }}";
|
||||||
|
echo "${{ env.PAID_RUNNER_BUILD_DATA }}"
|
||||||
|
) | \
|
||||||
|
yq \
|
||||||
|
--output-format json \
|
||||||
|
'[.[].config]'
|
||||||
|
)"
|
||||||
|
|
||||||
|
artifact_matrix="$(
|
||||||
|
(
|
||||||
|
echo "${{ env.BASE_BUILD_DATA }}";
|
||||||
|
echo "${{ env.PAID_RUNNER_BUILD_DATA }}"
|
||||||
|
) | \
|
||||||
|
yq \
|
||||||
|
--output-format json \
|
||||||
|
'map(.artifacts[] + (.config | pick(["job-transfer-artifact-suffix"])))'
|
||||||
|
)"
|
||||||
|
|
||||||
|
# The build matrix produces two macOS jobs (x86 and ARM) so the "channel update info files"
|
||||||
|
# generated by each must be merged.
|
||||||
|
merge_channel_files="true"
|
||||||
|
|
||||||
|
else
|
||||||
|
build_matrix="$(
|
||||||
|
echo "${{ env.BASE_BUILD_DATA }}" | \
|
||||||
|
yq \
|
||||||
|
--output-format json \
|
||||||
|
'[.[].config]'
|
||||||
|
)"
|
||||||
|
|
||||||
|
artifact_matrix="$(
|
||||||
|
echo "${{ env.BASE_BUILD_DATA }}" | \
|
||||||
|
yq \
|
||||||
|
--output-format json \
|
||||||
|
'map(.artifacts[] + (.config | pick(["job-transfer-artifact-suffix"])))'
|
||||||
|
)"
|
||||||
|
|
||||||
|
merge_channel_files="false"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set workflow step outputs.
|
||||||
|
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
|
||||||
|
delimiter="$RANDOM"
|
||||||
|
echo "build-matrix<<$delimiter" >> $GITHUB_OUTPUT
|
||||||
|
echo "$build_matrix" >> $GITHUB_OUTPUT
|
||||||
|
echo "$delimiter" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
delimiter="$RANDOM"
|
||||||
|
echo "artifact-matrix<<$delimiter" >> $GITHUB_OUTPUT
|
||||||
|
echo "$artifact_matrix" >> $GITHUB_OUTPUT
|
||||||
|
echo "$delimiter" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
echo "merge-channel-files=$merge_channel_files" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
build:
|
build:
|
||||||
if: github.repository == 'arduino/arduino-ide'
|
name: build (${{ matrix.config.name }})
|
||||||
|
needs:
|
||||||
|
- build-type-determination
|
||||||
|
- select-targets
|
||||||
|
env:
|
||||||
|
# Location of artifacts generated by build.
|
||||||
|
BUILD_ARTIFACTS_PATH: electron-app/dist/build-artifacts
|
||||||
|
# to skip passing signing credentials to electron-builder
|
||||||
|
IS_WINDOWS_CONFIG: ${{ matrix.config.name == 'Windows' }}
|
||||||
|
INSTALLER_CERT_WINDOWS_CER: "/tmp/cert.cer"
|
||||||
|
# We are hardcoding the path for signtool because is not present on the windows PATH env var by default.
|
||||||
|
# Keep in mind that this path could change when upgrading to a new runner version
|
||||||
|
SIGNTOOL_PATH: "C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x86/signtool.exe"
|
||||||
|
WIN_CERT_PASSWORD: ${{ secrets[matrix.config.certificate-password-secret] }}
|
||||||
|
WIN_CERT_CONTAINER_NAME: ${{ secrets[matrix.config.certificate-container] }}
|
||||||
|
PUPPETEER_SKIP_DOWNLOAD: true
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
config:
|
config: ${{ fromJson(needs.select-targets.outputs.build-matrix) }}
|
||||||
- os: windows-2019
|
runs-on: ${{ matrix.config.runs-on }}
|
||||||
- os: ubuntu-18.04 # https://github.com/arduino/arduino-ide/issues/259
|
container: ${{ fromJSON(matrix.config.container) }}
|
||||||
- os: macos-latest
|
defaults:
|
||||||
runs-on: ${{ matrix.config.os }}
|
run:
|
||||||
|
# Avoid problems caused by different default shell for container jobs (sh) vs non-container jobs (bash).
|
||||||
|
shell: bash
|
||||||
|
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Symlink custom working directory
|
||||||
uses: actions/checkout@v2
|
shell: cmd
|
||||||
|
if: runner.os == 'Windows' && matrix.config.working-directory
|
||||||
|
run: |
|
||||||
|
if not exist "${{ matrix.config.working-directory }}" mklink /d "${{ matrix.config.working-directory }}" "C:\actions-runner\_work\arduino-ide\arduino-ide"
|
||||||
|
|
||||||
- name: Install Node.js 14.x
|
- name: Checkout
|
||||||
uses: actions/setup-node@v1
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
|
||||||
|
- name: Install Node.js
|
||||||
|
if: runner.name != 'WINDOWS-SIGN-PC'
|
||||||
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '14.x'
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
# Yarn is a prerequisite for the action's cache feature, so caching should be disabled when running in the
|
||||||
|
# container where Yarn is not pre-installed.
|
||||||
|
cache: ${{ fromJSON(matrix.config.container) == null && 'yarn' || null }}
|
||||||
|
|
||||||
|
- name: Install Yarn
|
||||||
|
if: runner.name != 'WINDOWS-SIGN-PC'
|
||||||
|
run: |
|
||||||
|
npm \
|
||||||
|
install \
|
||||||
|
--global \
|
||||||
|
"yarn@${{ env.YARN_VERSION }}"
|
||||||
|
|
||||||
- name: Install Python 3.x
|
- name: Install Python 3.x
|
||||||
uses: actions/setup-python@v2
|
if: fromJSON(matrix.config.container) == null && runner.name != 'WINDOWS-SIGN-PC'
|
||||||
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.11.x'
|
||||||
|
|
||||||
|
- name: Install Go
|
||||||
|
if: runner.name != 'WINDOWS-SIGN-PC'
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
|
- name: Install Taskfile
|
||||||
|
if: runner.name != 'WINDOWS-SIGN-PC'
|
||||||
|
uses: arduino/setup-task@v2
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
version: 3.x
|
||||||
|
|
||||||
- name: Package
|
- name: Package
|
||||||
shell: bash
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
AC_USERNAME: ${{ secrets.AC_USERNAME }}
|
AC_USERNAME: ${{ secrets.AC_USERNAME }}
|
||||||
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
|
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
|
||||||
AC_TEAM_ID: ${{ secrets.AC_TEAM_ID }}
|
AC_TEAM_ID: ${{ secrets.AC_TEAM_ID }}
|
||||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
IS_NIGHTLY: ${{ needs.build-type-determination.outputs.is-nightly }}
|
||||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
IS_RELEASE: ${{ needs.build-type-determination.outputs.is-release }}
|
||||||
IS_NIGHTLY: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') }}
|
CAN_SIGN: ${{ secrets[matrix.config.certificate-secret] != '' }}
|
||||||
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }}
|
working-directory: ${{ matrix.config.working-directory || './' }}
|
||||||
IS_FORK: ${{ github.event.pull_request.head.repo.fork == true }}
|
|
||||||
run: |
|
run: |
|
||||||
# See: https://www.electron.build/code-signing
|
# See: https://www.electron.build/code-signing
|
||||||
if [ $IS_FORK = true ]; then
|
if [ $CAN_SIGN = false ] || [ $IS_WINDOWS_CONFIG = true ]; then
|
||||||
echo "Skipping the app signing: building from a fork."
|
echo "Skipping the app signing: certificate not provided."
|
||||||
else
|
else
|
||||||
if [ "${{ runner.OS }}" = "macOS" ]; then
|
export CSC_LINK="${{ runner.temp }}/signing_certificate.${{ matrix.config.certificate-extension }}"
|
||||||
export CSC_LINK="${{ runner.temp }}/signing_certificate.p12"
|
echo "${{ secrets[matrix.config.certificate-secret] }}" | base64 --decode > "$CSC_LINK"
|
||||||
# APPLE_SIGNING_CERTIFICATE_P12 secret was produced by following the procedure from:
|
export CSC_KEY_PASSWORD="${{ secrets[matrix.config.certificate-password-secret] }}"
|
||||||
# https://www.kencochrane.com/2020/08/01/build-and-sign-golang-binaries-for-macos-with-github-actions/#exporting-the-developer-certificate
|
export CSC_FOR_PULL_REQUEST=true
|
||||||
echo "${{ secrets.APPLE_SIGNING_CERTIFICATE_P12 }}" | base64 --decode > "$CSC_LINK"
|
|
||||||
|
|
||||||
export CSC_KEY_PASSWORD="${{ secrets.KEYCHAIN_PASSWORD }}"
|
|
||||||
|
|
||||||
elif [ "${{ runner.OS }}" = "Windows" ]; then
|
|
||||||
export CSC_LINK="${{ runner.temp }}/signing_certificate.pfx"
|
|
||||||
npm config set msvs_version 2017 --global
|
|
||||||
echo "${{ secrets.WINDOWS_SIGNING_CERTIFICATE_PFX }}" | base64 --decode > "$CSC_LINK"
|
|
||||||
|
|
||||||
export CSC_KEY_PASSWORD="${{ secrets.WINDOWS_SIGNING_CERTIFICATE_PASSWORD }}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
yarn --cwd ./electron/packager/
|
npx node-gyp install
|
||||||
yarn --cwd ./electron/packager/ package
|
yarn install
|
||||||
|
|
||||||
- name: Upload [GitHub Actions]
|
yarn --cwd arduino-ide-extension build
|
||||||
uses: actions/upload-artifact@v2
|
yarn --cwd electron-app rebuild
|
||||||
|
yarn --cwd electron-app build
|
||||||
|
yarn --cwd electron-app package
|
||||||
|
|
||||||
|
# Both macOS jobs generate a "channel update info file" with same path and name. The second job to complete would
|
||||||
|
# overwrite the file generated by the first in the workflow artifact.
|
||||||
|
- name: Stage channel file for merge
|
||||||
|
if: >
|
||||||
|
needs.select-targets.outputs.merge-channel-files == 'true' &&
|
||||||
|
matrix.config.mergeable-channel-file == 'true'
|
||||||
|
working-directory: ${{ matrix.config.working-directory || './' }}
|
||||||
|
run: |
|
||||||
|
staged_channel_files_path="${{ runner.temp }}/staged-channel-files"
|
||||||
|
mkdir "$staged_channel_files_path"
|
||||||
|
mv \
|
||||||
|
"${{ env.BUILD_ARTIFACTS_PATH }}/${{ needs.build-type-determination.outputs.channel-name }}-mac.yml" \
|
||||||
|
"${staged_channel_files_path}/${{ needs.build-type-determination.outputs.channel-name }}-mac-${{ runner.arch }}.yml"
|
||||||
|
|
||||||
|
# Set workflow environment variable for use in other steps.
|
||||||
|
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
|
||||||
|
echo "STAGED_CHANNEL_FILES_PATH=$staged_channel_files_path" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Upload staged-for-merge channel file artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
if: >
|
||||||
|
needs.select-targets.outputs.merge-channel-files == 'true' &&
|
||||||
|
matrix.config.mergeable-channel-file == 'true'
|
||||||
with:
|
with:
|
||||||
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
|
if-no-files-found: error
|
||||||
path: electron/build/dist/build-artifacts/
|
name: ${{ env.STAGED_CHANNEL_FILE_ARTIFACT_PREFIX }}${{ matrix.config.job-transfer-artifact-suffix }}
|
||||||
|
path: ${{ matrix.config.working-directory && format('{0}/{1}', matrix.config.working-directory, env.STAGED_CHANNEL_FILES_PATH) || env.STAGED_CHANNEL_FILES_PATH }}
|
||||||
|
|
||||||
|
- name: Upload builds to job transfer artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ env.JOB_TRANSFER_ARTIFACT_PREFIX }}${{ matrix.config.job-transfer-artifact-suffix }}
|
||||||
|
path: ${{ matrix.config.working-directory && format('{0}/{1}', matrix.config.working-directory, env.BUILD_ARTIFACTS_PATH) || env.BUILD_ARTIFACTS_PATH }}
|
||||||
|
|
||||||
|
- name: Manual Clean up for self-hosted runners
|
||||||
|
if: runner.os == 'Windows' && matrix.config.working-directory
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
rmdir /s /q "${{ matrix.config.working-directory }}\${{ env.BUILD_ARTIFACTS_PATH }}"
|
||||||
|
|
||||||
|
merge-channel-files:
|
||||||
|
needs:
|
||||||
|
- build-type-determination
|
||||||
|
- select-targets
|
||||||
|
- build
|
||||||
|
if: needs.select-targets.outputs.merge-channel-files == 'true'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions: {}
|
||||||
|
steps:
|
||||||
|
- name: Set environment variables
|
||||||
|
run: |
|
||||||
|
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
|
||||||
|
echo "CHANNEL_FILES_PATH=${{ runner.temp }}/channel-files" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Download staged-for-merge channel file artifacts
|
||||||
|
uses: actions/download-artifact@v5
|
||||||
|
with:
|
||||||
|
merge-multiple: true
|
||||||
|
path: ${{ env.CHANNEL_FILES_PATH }}
|
||||||
|
pattern: ${{ env.STAGED_CHANNEL_FILE_ARTIFACT_PREFIX }}*
|
||||||
|
|
||||||
|
- name: Remove no longer needed artifacts
|
||||||
|
uses: geekyeggo/delete-artifact@v5
|
||||||
|
with:
|
||||||
|
name: ${{ env.STAGED_CHANNEL_FILE_ARTIFACT_PREFIX }}*
|
||||||
|
|
||||||
|
- name: Install Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
cache: 'yarn'
|
||||||
|
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
|
- name: Install Task
|
||||||
|
uses: arduino/setup-task@v2
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
version: 3.x
|
||||||
|
|
||||||
|
- name: Install dependencies (Linux only)
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libx11-dev libxkbfile-dev libsecret-1-dev
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: yarn
|
||||||
|
|
||||||
|
- name: Merge "channel update info files"
|
||||||
|
run: |
|
||||||
|
node \
|
||||||
|
./scripts/merge-channel-files.js \
|
||||||
|
--channel "${{ needs.build-type-determination.outputs.channel-name }}" \
|
||||||
|
--input "${{ env.CHANNEL_FILES_PATH }}"
|
||||||
|
|
||||||
|
- name: Upload merged channel files job transfer artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
if-no-files-found: error
|
||||||
|
name: ${{ env.JOB_TRANSFER_ARTIFACT_PREFIX }}channel-files
|
||||||
|
path: ${{ env.CHANNEL_FILES_PATH }}
|
||||||
|
|
||||||
artifacts:
|
artifacts:
|
||||||
name: ${{ matrix.artifact.name }} artifact
|
name: ${{ matrix.artifact.name }} artifact
|
||||||
needs: build
|
needs:
|
||||||
|
- select-targets
|
||||||
|
- build
|
||||||
if: always() && needs.build.result != 'skipped'
|
if: always() && needs.build.result != 'skipped'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
env:
|
||||||
|
BUILD_ARTIFACTS_FOLDER: build-artifacts
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
artifact:
|
artifact: ${{ fromJson(needs.select-targets.outputs.artifact-matrix) }}
|
||||||
- path: '*Linux_64bit.zip'
|
|
||||||
name: Linux_X86-64_zip
|
|
||||||
- path: '*Linux_64bit.AppImage'
|
|
||||||
name: Linux_X86-64_app_image
|
|
||||||
- path: '*macOS_64bit.dmg'
|
|
||||||
name: macOS_dmg
|
|
||||||
- path: '*macOS_64bit.zip'
|
|
||||||
name: macOS_zip
|
|
||||||
- path: '*Windows_64bit.exe'
|
|
||||||
name: Windows_X86-64_interactive_installer
|
|
||||||
- path: '*Windows_64bit.msi'
|
|
||||||
name: Windows_X86-64_MSI
|
|
||||||
- path: '*Windows_64bit.zip'
|
|
||||||
name: Windows_X86-64_zip
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download job transfer artifact
|
- name: Download job transfer artifact that contains ${{ matrix.artifact.name }} tester build
|
||||||
uses: actions/download-artifact@v2
|
uses: actions/download-artifact@v5
|
||||||
with:
|
with:
|
||||||
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
|
name: ${{ env.JOB_TRANSFER_ARTIFACT_PREFIX }}${{ matrix.artifact.job-transfer-artifact-suffix }}
|
||||||
path: ${{ env.JOB_TRANSFER_ARTIFACT }}
|
path: ${{ env.BUILD_ARTIFACTS_FOLDER }}
|
||||||
|
|
||||||
- name: Upload tester build artifact
|
- name: Upload tester build artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.artifact.name }}
|
name: ${{ matrix.artifact.name }}
|
||||||
path: ${{ env.JOB_TRANSFER_ARTIFACT }}/${{ matrix.artifact.path }}
|
path: ${{ env.BUILD_ARTIFACTS_FOLDER }}/${{ matrix.artifact.path }}
|
||||||
|
|
||||||
changelog:
|
changelog:
|
||||||
needs: build
|
needs:
|
||||||
|
- build-type-determination
|
||||||
|
- build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
BODY: ${{ steps.changelog.outputs.BODY }}
|
BODY: ${{ steps.changelog.outputs.BODY }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # To fetch all history for all branches and tags.
|
fetch-depth: 0 # To fetch all history for all branches and tags.
|
||||||
|
|
||||||
- name: Generate Changelog
|
- name: Generate Changelog
|
||||||
id: changelog
|
id: changelog
|
||||||
env:
|
env:
|
||||||
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }}
|
IS_RELEASE: ${{ needs.build-type-determination.outputs.is-release }}
|
||||||
run: |
|
run: |
|
||||||
export LATEST_TAG=$(git describe --abbrev=0)
|
export LATEST_TAG=$(git describe --abbrev=0)
|
||||||
export GIT_LOG=$(git log --pretty=" - %s [%h]" $LATEST_TAG..HEAD | sed 's/ *$//g')
|
export GIT_LOG=$(git log --pretty=" - %s [%h]" $LATEST_TAG..HEAD | sed 's/ *$//g')
|
||||||
@@ -153,80 +555,132 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo -e "$BODY"
|
echo -e "$BODY"
|
||||||
OUTPUT_SAFE_BODY="${BODY//'%'/'%25'}"
|
|
||||||
OUTPUT_SAFE_BODY="${OUTPUT_SAFE_BODY//$'\n'/'%0A'}"
|
# Set workflow step output
|
||||||
OUTPUT_SAFE_BODY="${OUTPUT_SAFE_BODY//$'\r'/'%0D'}"
|
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
|
||||||
echo "::set-output name=BODY::$OUTPUT_SAFE_BODY"
|
DELIMITER="$RANDOM"
|
||||||
|
echo "BODY<<$DELIMITER" >> $GITHUB_OUTPUT
|
||||||
|
echo "$BODY" >> $GITHUB_OUTPUT
|
||||||
|
echo "$DELIMITER" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
echo "$BODY" > CHANGELOG.txt
|
echo "$BODY" > CHANGELOG.txt
|
||||||
|
|
||||||
- name: Upload Changelog [GitHub Actions]
|
- name: Upload changelog job transfer artifact
|
||||||
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
|
if: needs.build-type-determination.outputs.is-nightly == 'true'
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
|
name: ${{ env.JOB_TRANSFER_ARTIFACT_PREFIX }}changelog
|
||||||
path: CHANGELOG.txt
|
path: CHANGELOG.txt
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
needs: changelog
|
needs:
|
||||||
if: github.repository == 'arduino/arduino-ide' && (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'))
|
- build-type-determination
|
||||||
|
- merge-channel-files
|
||||||
|
- changelog
|
||||||
|
if: >
|
||||||
|
always() &&
|
||||||
|
needs.build-type-determination.result == 'success' &&
|
||||||
|
(
|
||||||
|
needs.merge-channel-files.result == 'skipped' ||
|
||||||
|
needs.merge-channel-files.result == 'success'
|
||||||
|
) &&
|
||||||
|
needs.changelog.result == 'success' &&
|
||||||
|
needs.build-type-determination.outputs.publish-to-s3 == 'true' &&
|
||||||
|
needs.build-type-determination.outputs.is-nightly == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
env:
|
||||||
|
ARTIFACTS_FOLDER: build-artifacts
|
||||||
|
|
||||||
|
environment: production
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download [GitHub Actions]
|
- name: Download all job transfer artifacts
|
||||||
uses: actions/download-artifact@v2
|
uses: actions/download-artifact@v5
|
||||||
with:
|
with:
|
||||||
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
|
merge-multiple: true
|
||||||
path: ${{ env.JOB_TRANSFER_ARTIFACT }}
|
path: ${{ env.ARTIFACTS_FOLDER }}
|
||||||
|
pattern: ${{ env.JOB_TRANSFER_ARTIFACT_PREFIX }}*
|
||||||
|
|
||||||
|
- name: Configure AWS Credentials for Nightly [S3]
|
||||||
|
uses: aws-actions/configure-aws-credentials@v5
|
||||||
|
with:
|
||||||
|
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
|
||||||
|
aws-region: us-east-1
|
||||||
|
|
||||||
- name: Publish Nightly [S3]
|
- name: Publish Nightly [S3]
|
||||||
uses: docker://plugins/s3
|
run: |
|
||||||
env:
|
aws s3 sync ${{ env.ARTIFACTS_FOLDER }} s3://${{ secrets.DOWNLOADS_BUCKET }}/arduino-ide/nightly
|
||||||
PLUGIN_SOURCE: '${{ env.JOB_TRANSFER_ARTIFACT }}/*'
|
|
||||||
PLUGIN_STRIP_PREFIX: '${{ env.JOB_TRANSFER_ARTIFACT }}/'
|
|
||||||
PLUGIN_TARGET: '/arduino-ide/nightly'
|
|
||||||
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
|
|
||||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
||||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
needs: changelog
|
needs:
|
||||||
if: github.repository == 'arduino/arduino-ide' && startsWith(github.ref, 'refs/tags/')
|
- build-type-determination
|
||||||
|
- merge-channel-files
|
||||||
|
- changelog
|
||||||
|
if: >
|
||||||
|
always() &&
|
||||||
|
needs.build-type-determination.result == 'success' &&
|
||||||
|
(
|
||||||
|
needs.merge-channel-files.result == 'skipped' ||
|
||||||
|
needs.merge-channel-files.result == 'success'
|
||||||
|
) &&
|
||||||
|
needs.changelog.result == 'success' &&
|
||||||
|
needs.build-type-determination.outputs.is-release == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
env:
|
||||||
|
ARTIFACTS_FOLDER: build-artifacts
|
||||||
|
|
||||||
|
environment: production
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
|
contents: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download [GitHub Actions]
|
- name: Download all job transfer artifacts
|
||||||
uses: actions/download-artifact@v2
|
uses: actions/download-artifact@v5
|
||||||
with:
|
with:
|
||||||
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
|
merge-multiple: true
|
||||||
path: ${{ env.JOB_TRANSFER_ARTIFACT }}
|
path: ${{ env.ARTIFACTS_FOLDER }}
|
||||||
|
pattern: ${{ env.JOB_TRANSFER_ARTIFACT_PREFIX }}*
|
||||||
|
|
||||||
- name: Get Tag
|
- name: Get Tag
|
||||||
id: tag_name
|
id: tag_name
|
||||||
run: |
|
run: |
|
||||||
echo ::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/}
|
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Publish Release [GitHub]
|
- name: Publish Release [GitHub]
|
||||||
uses: svenstaro/upload-release-action@2.2.0
|
uses: svenstaro/upload-release-action@2.9.0
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
release_name: ${{ steps.tag_name.outputs.TAG_NAME }}
|
release_name: ${{ steps.tag_name.outputs.TAG_NAME }}
|
||||||
file: ${{ env.JOB_TRANSFER_ARTIFACT }}/*
|
file: ${{ env.ARTIFACTS_FOLDER }}/*
|
||||||
tag: ${{ github.ref }}
|
tag: ${{ github.ref }}
|
||||||
file_glob: true
|
file_glob: true
|
||||||
body: ${{ needs.changelog.outputs.BODY }}
|
body: ${{ needs.changelog.outputs.BODY }}
|
||||||
|
|
||||||
|
- name: Configure AWS Credentials for Release [S3]
|
||||||
|
if: needs.build-type-determination.outputs.publish-to-s3 == 'true'
|
||||||
|
uses: aws-actions/configure-aws-credentials@v5
|
||||||
|
with:
|
||||||
|
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
|
||||||
|
aws-region: us-east-1
|
||||||
|
|
||||||
- name: Publish Release [S3]
|
- name: Publish Release [S3]
|
||||||
uses: docker://plugins/s3
|
if: needs.build-type-determination.outputs.publish-to-s3 == 'true'
|
||||||
env:
|
run: |
|
||||||
PLUGIN_SOURCE: '${{ env.JOB_TRANSFER_ARTIFACT }}/*'
|
aws s3 sync ${{ env.ARTIFACTS_FOLDER }} s3://${{ secrets.DOWNLOADS_BUCKET }}/arduino-ide
|
||||||
PLUGIN_STRIP_PREFIX: '${{ env.JOB_TRANSFER_ARTIFACT }}/'
|
|
||||||
PLUGIN_TARGET: '/arduino-ide'
|
|
||||||
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
|
|
||||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
||||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
# This job must run after all jobs that use the transfer artifact.
|
# This job must run after all jobs that use the transfer artifact.
|
||||||
needs:
|
needs:
|
||||||
- build
|
- build
|
||||||
|
- merge-channel-files
|
||||||
- publish
|
- publish
|
||||||
- release
|
- release
|
||||||
- artifacts
|
- artifacts
|
||||||
@@ -234,7 +688,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Remove unneeded job transfer artifact
|
- name: Remove unneeded job transfer artifacts
|
||||||
uses: geekyeggo/delete-artifact@v1
|
uses: geekyeggo/delete-artifact@v5
|
||||||
with:
|
with:
|
||||||
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
|
name: ${{ env.JOB_TRANSFER_ARTIFACT_PREFIX }}*
|
||||||
|
|||||||
116
.github/workflows/check-certificates.yml
vendored
116
.github/workflows/check-certificates.yml
vendored
@@ -3,6 +3,7 @@ name: Check Certificates
|
|||||||
|
|
||||||
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
|
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
|
||||||
on:
|
on:
|
||||||
|
create:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
- '.github/workflows/check-certificates.ya?ml'
|
- '.github/workflows/check-certificates.ya?ml'
|
||||||
@@ -20,12 +21,49 @@ env:
|
|||||||
EXPIRATION_WARNING_PERIOD: 30
|
EXPIRATION_WARNING_PERIOD: 30
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
run-determination:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
result: ${{ steps.determination.outputs.result }}
|
||||||
|
steps:
|
||||||
|
- name: Determine if the rest of the workflow should run
|
||||||
|
id: determination
|
||||||
|
run: |
|
||||||
|
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
|
||||||
|
REPO_SLUG="arduino/arduino-ide"
|
||||||
|
if [[
|
||||||
|
(
|
||||||
|
# Only run on branch creation when it is a release branch.
|
||||||
|
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
|
||||||
|
"${{ github.event_name }}" != "create" ||
|
||||||
|
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
|
||||||
|
) &&
|
||||||
|
(
|
||||||
|
# Only run when the workflow will have access to the certificate secrets.
|
||||||
|
# This could be done via a GitHub Actions workflow conditional, but makes more sense to do it here as well.
|
||||||
|
(
|
||||||
|
"${{ github.event_name }}" != "pull_request" &&
|
||||||
|
"${{ github.repository }}" == "$REPO_SLUG"
|
||||||
|
) ||
|
||||||
|
(
|
||||||
|
"${{ github.event_name }}" == "pull_request" &&
|
||||||
|
"${{ github.event.pull_request.head.repo.full_name }}" == "$REPO_SLUG"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]]; then
|
||||||
|
# Run the other jobs.
|
||||||
|
RESULT="true"
|
||||||
|
else
|
||||||
|
# There is no need to run the other jobs.
|
||||||
|
RESULT="false"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "result=$RESULT" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
check-certificates:
|
check-certificates:
|
||||||
name: ${{ matrix.certificate.identifier }}
|
name: ${{ matrix.certificate.identifier }}
|
||||||
# Only run when the workflow will have access to the certificate secrets.
|
needs: run-determination
|
||||||
if: >
|
if: needs.run-determination.outputs.result == 'true'
|
||||||
(github.event_name != 'pull_request' && github.repository == 'arduino/arduino-ide') ||
|
|
||||||
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'arduino/arduino-ide')
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@@ -36,9 +74,11 @@ jobs:
|
|||||||
- identifier: macOS signing certificate # Text used to identify certificate in notifications.
|
- identifier: macOS signing certificate # Text used to identify certificate in notifications.
|
||||||
certificate-secret: APPLE_SIGNING_CERTIFICATE_P12 # Name of the secret that contains the certificate.
|
certificate-secret: APPLE_SIGNING_CERTIFICATE_P12 # Name of the secret that contains the certificate.
|
||||||
password-secret: KEYCHAIN_PASSWORD # Name of the secret that contains the certificate password.
|
password-secret: KEYCHAIN_PASSWORD # Name of the secret that contains the certificate password.
|
||||||
|
type: pkcs12
|
||||||
- identifier: Windows signing certificate
|
- identifier: Windows signing certificate
|
||||||
certificate-secret: WINDOWS_SIGNING_CERTIFICATE_PFX
|
certificate-secret: INSTALLER_CERT_WINDOWS_CER
|
||||||
password-secret: WINDOWS_SIGNING_CERTIFICATE_PASSWORD
|
# The password for the Windows certificate is not needed, because its not a container, but a single certificate.
|
||||||
|
type: x509
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Set certificate path environment variable
|
- name: Set certificate path environment variable
|
||||||
@@ -57,9 +97,11 @@ jobs:
|
|||||||
CERTIFICATE_PASSWORD: ${{ secrets[matrix.certificate.password-secret] }}
|
CERTIFICATE_PASSWORD: ${{ secrets[matrix.certificate.password-secret] }}
|
||||||
run: |
|
run: |
|
||||||
(
|
(
|
||||||
openssl pkcs12 \
|
openssl ${{ matrix.certificate.type }} \
|
||||||
-in "${{ env.CERTIFICATE_PATH }}" \
|
-in "${{ env.CERTIFICATE_PATH }}" \
|
||||||
-noout -passin env:CERTIFICATE_PASSWORD
|
-legacy \
|
||||||
|
-noout \
|
||||||
|
-passin env:CERTIFICATE_PASSWORD
|
||||||
) || (
|
) || (
|
||||||
echo "::error::Verification of ${{ matrix.certificate.identifier }} failed!!!"
|
echo "::error::Verification of ${{ matrix.certificate.identifier }} failed!!!"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -82,25 +124,43 @@ jobs:
|
|||||||
CERTIFICATE_PASSWORD: ${{ secrets[matrix.certificate.password-secret] }}
|
CERTIFICATE_PASSWORD: ${{ secrets[matrix.certificate.password-secret] }}
|
||||||
id: get-days-before-expiration
|
id: get-days-before-expiration
|
||||||
run: |
|
run: |
|
||||||
EXPIRATION_DATE="$(
|
if [[ ${{ matrix.certificate.type }} == "pkcs12" ]]; then
|
||||||
(
|
EXPIRATION_DATE="$(
|
||||||
openssl pkcs12 \
|
(
|
||||||
-in "${{ env.CERTIFICATE_PATH }}" \
|
openssl pkcs12 \
|
||||||
-clcerts \
|
-in "${{ env.CERTIFICATE_PATH }}" \
|
||||||
-nodes \
|
-clcerts \
|
||||||
-passin env:CERTIFICATE_PASSWORD
|
-legacy \
|
||||||
) | (
|
-nodes \
|
||||||
openssl x509 \
|
-passin env:CERTIFICATE_PASSWORD
|
||||||
-noout \
|
) | (
|
||||||
-enddate
|
openssl x509 \
|
||||||
) | (
|
-noout \
|
||||||
grep \
|
-enddate
|
||||||
--max-count=1 \
|
) | (
|
||||||
--only-matching \
|
grep \
|
||||||
--perl-regexp \
|
--max-count=1 \
|
||||||
'notAfter=(\K.*)'
|
--only-matching \
|
||||||
)
|
--perl-regexp \
|
||||||
)"
|
'notAfter=(\K.*)'
|
||||||
|
)
|
||||||
|
)"
|
||||||
|
elif [[ ${{ matrix.certificate.type }} == "x509" ]]; then
|
||||||
|
EXPIRATION_DATE="$(
|
||||||
|
(
|
||||||
|
openssl x509 \
|
||||||
|
-in ${{ env.CERTIFICATE_PATH }} \
|
||||||
|
-noout \
|
||||||
|
-enddate
|
||||||
|
) | (
|
||||||
|
grep \
|
||||||
|
--max-count=1 \
|
||||||
|
--only-matching \
|
||||||
|
--perl-regexp \
|
||||||
|
'notAfter=(\K.*)'
|
||||||
|
)
|
||||||
|
)"
|
||||||
|
fi
|
||||||
|
|
||||||
DAYS_BEFORE_EXPIRATION="$((($(date --utc --date="$EXPIRATION_DATE" +%s) - $(date --utc +%s)) / 60 / 60 / 24))"
|
DAYS_BEFORE_EXPIRATION="$((($(date --utc --date="$EXPIRATION_DATE" +%s) - $(date --utc +%s)) / 60 / 60 / 24))"
|
||||||
|
|
||||||
@@ -108,7 +168,7 @@ jobs:
|
|||||||
echo "Certificate expiration date: $EXPIRATION_DATE"
|
echo "Certificate expiration date: $EXPIRATION_DATE"
|
||||||
echo "Days remaining before expiration: $DAYS_BEFORE_EXPIRATION"
|
echo "Days remaining before expiration: $DAYS_BEFORE_EXPIRATION"
|
||||||
|
|
||||||
echo "::set-output name=days::$DAYS_BEFORE_EXPIRATION"
|
echo "days=$DAYS_BEFORE_EXPIRATION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Check if expiration notification period has been reached
|
- name: Check if expiration notification period has been reached
|
||||||
id: check-expiration
|
id: check-expiration
|
||||||
|
|||||||
58
.github/workflows/check-containers.yml
vendored
Normal file
58
.github/workflows/check-containers.yml
vendored
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
name: Check Containers
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- ".github/workflows/check-containers.ya?ml"
|
||||||
|
- "**.Dockerfile"
|
||||||
|
- "**/Dockerfile"
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- ".github/workflows/check-containers.ya?ml"
|
||||||
|
- "**.Dockerfile"
|
||||||
|
- "**/Dockerfile"
|
||||||
|
repository_dispatch:
|
||||||
|
schedule:
|
||||||
|
# Run periodically to catch breakage caused by external changes.
|
||||||
|
- cron: "0 7 * * MON"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run:
|
||||||
|
name: Run (${{ matrix.image.path }})
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions: {}
|
||||||
|
services:
|
||||||
|
registry:
|
||||||
|
image: registry:2
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: name/app:latest
|
||||||
|
REGISTRY: localhost:5000
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
image:
|
||||||
|
- path: .github/workflows/assets/linux.Dockerfile
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Build and push to local registry
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ${{ matrix.image.path }}
|
||||||
|
push: true
|
||||||
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
|
||||||
|
- name: Run container
|
||||||
|
run: |
|
||||||
|
docker \
|
||||||
|
run \
|
||||||
|
--rm \
|
||||||
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
63
.github/workflows/check-i18n-task.yml
vendored
63
.github/workflows/check-i18n-task.yml
vendored
@@ -1,7 +1,12 @@
|
|||||||
name: Check Internationalization
|
name: Check Internationalization
|
||||||
|
|
||||||
|
env:
|
||||||
|
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
||||||
|
GO_VERSION: '1.21'
|
||||||
|
|
||||||
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
|
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
|
||||||
on:
|
on:
|
||||||
|
create:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
- '.github/workflows/check-i18n-task.ya?ml'
|
- '.github/workflows/check-i18n-task.ya?ml'
|
||||||
@@ -18,21 +23,69 @@ on:
|
|||||||
repository_dispatch:
|
repository_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
run-determination:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
result: ${{ steps.determination.outputs.result }}
|
||||||
|
permissions: {}
|
||||||
|
steps:
|
||||||
|
- name: Determine if the rest of the workflow should run
|
||||||
|
id: determination
|
||||||
|
run: |
|
||||||
|
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
|
||||||
|
TAG_REGEX="refs/tags/.*"
|
||||||
|
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
|
||||||
|
if [[
|
||||||
|
("${{ github.event_name }}" != "create" ||
|
||||||
|
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX) &&
|
||||||
|
! "${{ github.ref }}" =~ $TAG_REGEX
|
||||||
|
]]; then
|
||||||
|
# Run the other jobs.
|
||||||
|
RESULT="true"
|
||||||
|
else
|
||||||
|
# There is no need to run the other jobs.
|
||||||
|
RESULT="false"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "result=$RESULT" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
check:
|
check:
|
||||||
|
needs: run-determination
|
||||||
|
if: needs.run-determination.outputs.result == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- name: Install Node.js 14.x
|
- name: Install Node.js 18.17
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '14.x'
|
node-version: '18.17'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
cache: 'yarn'
|
||||||
|
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
|
- name: Install Taskfile
|
||||||
|
uses: arduino/setup-task@v2
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
version: 3.x
|
||||||
|
|
||||||
|
- name: Install dependencies (Linux only)
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libx11-dev libxkbfile-dev libsecret-1-dev
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn
|
run: yarn install --immutable
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Check for errors
|
- name: Check for errors
|
||||||
run: yarn i18n:check
|
run: yarn i18n:check
|
||||||
|
|||||||
94
.github/workflows/check-javascript.yml
vendored
Normal file
94
.github/workflows/check-javascript.yml
vendored
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-javascript-task.md
|
||||||
|
name: Check JavaScript
|
||||||
|
|
||||||
|
env:
|
||||||
|
# See: https://github.com/actions/setup-node/#readme
|
||||||
|
NODE_VERSION: 18.17
|
||||||
|
|
||||||
|
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
|
||||||
|
on:
|
||||||
|
create:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- '.github/workflows/check-javascript.ya?ml'
|
||||||
|
- '**/.eslintignore'
|
||||||
|
- '**/.eslintrc*'
|
||||||
|
- '**/.npmrc'
|
||||||
|
- '**/package.json'
|
||||||
|
- '**/package-lock.json'
|
||||||
|
- '**/yarn.lock'
|
||||||
|
- '**.jsx?'
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- '.github/workflows/check-javascript.ya?ml'
|
||||||
|
- '**/.eslintignore'
|
||||||
|
- '**/.eslintrc*'
|
||||||
|
- '**/.npmrc'
|
||||||
|
- '**/package.json'
|
||||||
|
- '**/package-lock.json'
|
||||||
|
- '**/yarn.lock'
|
||||||
|
- '**.jsx?'
|
||||||
|
workflow_dispatch:
|
||||||
|
repository_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run-determination:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions: {}
|
||||||
|
outputs:
|
||||||
|
result: ${{ steps.determination.outputs.result }}
|
||||||
|
steps:
|
||||||
|
- name: Determine if the rest of the workflow should run
|
||||||
|
id: determination
|
||||||
|
run: |
|
||||||
|
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
|
||||||
|
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
|
||||||
|
if [[
|
||||||
|
"${{ github.event_name }}" != "create" ||
|
||||||
|
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
|
||||||
|
]]; then
|
||||||
|
# Run the other jobs.
|
||||||
|
RESULT="true"
|
||||||
|
else
|
||||||
|
# There is no need to run the other jobs.
|
||||||
|
RESULT="false"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "result=$RESULT" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
check:
|
||||||
|
needs: run-determination
|
||||||
|
if: needs.run-determination.outputs.result == 'true'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
cache: yarn
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
|
- name: Install Dependencies (Linux only)
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libx11-dev libxkbfile-dev libsecret-1-dev
|
||||||
|
|
||||||
|
- name: Install npm package dependencies
|
||||||
|
env:
|
||||||
|
# Avoid failure of @vscode/ripgrep installation due to GitHub API rate limiting:
|
||||||
|
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
yarn install
|
||||||
|
|
||||||
|
- name: Lint
|
||||||
|
run: |
|
||||||
|
yarn \
|
||||||
|
--cwd arduino-ide-extension \
|
||||||
|
lint
|
||||||
97
.github/workflows/check-yarn.yml
vendored
Normal file
97
.github/workflows/check-yarn.yml
vendored
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
name: Check Yarn
|
||||||
|
|
||||||
|
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
|
||||||
|
on:
|
||||||
|
create:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- ".github/workflows/check-yarn.ya?ml"
|
||||||
|
- "**/.yarnrc"
|
||||||
|
- "**/package.json"
|
||||||
|
- "**/package-lock.json"
|
||||||
|
- "**/yarn.lock"
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- ".github/workflows/check-yarn.ya?ml"
|
||||||
|
- "**/.yarnrc"
|
||||||
|
- "**/package.json"
|
||||||
|
- "**/package-lock.json"
|
||||||
|
- "**/yarn.lock"
|
||||||
|
schedule:
|
||||||
|
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
|
||||||
|
- cron: "0 8 * * TUE"
|
||||||
|
workflow_dispatch:
|
||||||
|
repository_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run-determination:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions: {}
|
||||||
|
outputs:
|
||||||
|
result: ${{ steps.determination.outputs.result }}
|
||||||
|
steps:
|
||||||
|
- name: Determine if the rest of the workflow should run
|
||||||
|
id: determination
|
||||||
|
run: |
|
||||||
|
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
|
||||||
|
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
|
||||||
|
if [[
|
||||||
|
"${{ github.event_name }}" != "create" ||
|
||||||
|
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
|
||||||
|
]]; then
|
||||||
|
# Run the other jobs.
|
||||||
|
RESULT="true"
|
||||||
|
else
|
||||||
|
# There is no need to run the other jobs.
|
||||||
|
RESULT="false"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "result=$RESULT" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
check-sync:
|
||||||
|
name: check-sync (${{ matrix.project.path }})
|
||||||
|
needs: run-determination
|
||||||
|
if: needs.run-determination.outputs.result == 'true'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
project:
|
||||||
|
- path: .
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
cache: yarn
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
|
- name: Install Dependencies (Linux only)
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libx11-dev libxkbfile-dev libsecret-1-dev
|
||||||
|
|
||||||
|
- name: Install npm package dependencies
|
||||||
|
env:
|
||||||
|
# Avoid failure of @vscode/ripgrep installation due to GitHub API rate limiting:
|
||||||
|
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
yarn \
|
||||||
|
install \
|
||||||
|
--ignore-scripts
|
||||||
|
|
||||||
|
- name: Check yarn.lock
|
||||||
|
run: |
|
||||||
|
git \
|
||||||
|
diff \
|
||||||
|
--color \
|
||||||
|
--exit-code \
|
||||||
|
"${{ matrix.project.path }}/yarn.lock"
|
||||||
45
.github/workflows/compose-full-changelog.yaml
vendored
45
.github/workflows/compose-full-changelog.yaml
vendored
@@ -1,45 +0,0 @@
|
|||||||
name: Compose full changelog
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [created, edited]
|
|
||||||
|
|
||||||
env:
|
|
||||||
CHANGELOG_ARTIFACTS: changelog
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
create-changelog:
|
|
||||||
if: github.repository == 'arduino/arduino-ide'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Get Tag
|
|
||||||
id: tag_name
|
|
||||||
run: |
|
|
||||||
echo ::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/}
|
|
||||||
|
|
||||||
- name: Create full changelog
|
|
||||||
id: full-changelog
|
|
||||||
run: |
|
|
||||||
mkdir "${{ github.workspace }}/${{ env.CHANGELOG_ARTIFACTS }}"
|
|
||||||
|
|
||||||
# Get the changelog file name to build
|
|
||||||
CHANGELOG_FILE_NAME="${{ steps.tag_name.outputs.TAG_NAME }}-$(date --iso-8601=s).md"
|
|
||||||
|
|
||||||
# Create manifest file pointing to latest changelog file name
|
|
||||||
echo "$CHANGELOG_FILE_NAME" >> "${{ github.workspace }}/${{ env.CHANGELOG_ARTIFACTS }}/latest.txt"
|
|
||||||
|
|
||||||
# Compose changelog
|
|
||||||
yarn run compose-changelog "${{ github.workspace }}/${{ env.CHANGELOG_ARTIFACTS }}/$CHANGELOG_FILE_NAME"
|
|
||||||
|
|
||||||
- name: Publish Changelog [S3]
|
|
||||||
uses: docker://plugins/s3
|
|
||||||
env:
|
|
||||||
PLUGIN_SOURCE: '${{ env.CHANGELOG_ARTIFACTS }}/*'
|
|
||||||
PLUGIN_STRIP_PREFIX: '${{ env.CHANGELOG_ARTIFACTS }}/'
|
|
||||||
PLUGIN_TARGET: '/arduino-ide/changelog'
|
|
||||||
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
|
|
||||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
||||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
||||||
66
.github/workflows/compose-full-changelog.yml
vendored
Normal file
66
.github/workflows/compose-full-changelog.yml
vendored
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
name: Compose full changelog
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- edited
|
||||||
|
|
||||||
|
env:
|
||||||
|
CHANGELOG_ARTIFACTS: changelog
|
||||||
|
# See: https://github.com/actions/setup-node/#readme
|
||||||
|
NODE_VERSION: '18.17'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
create-changelog:
|
||||||
|
if: github.repository == 'arduino/arduino-ide'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
|
contents: read
|
||||||
|
environment: production
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Install Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
|
||||||
|
- name: Install Dependencies (Linux only)
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libx11-dev libxkbfile-dev libsecret-1-dev
|
||||||
|
|
||||||
|
- name: Get Tag
|
||||||
|
id: tag_name
|
||||||
|
run: |
|
||||||
|
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Create full changelog
|
||||||
|
id: full-changelog
|
||||||
|
run: |
|
||||||
|
yarn add @octokit/rest@19.0.13 --ignore-workspace-root-check
|
||||||
|
mkdir "${{ github.workspace }}/${{ env.CHANGELOG_ARTIFACTS }}"
|
||||||
|
|
||||||
|
# Get the changelog file name to build
|
||||||
|
CHANGELOG_FILE_NAME="${{ steps.tag_name.outputs.TAG_NAME }}-$(date +%s).md"
|
||||||
|
|
||||||
|
# Create manifest file pointing to latest changelog file name
|
||||||
|
echo "$CHANGELOG_FILE_NAME" >> "${{ github.workspace }}/${{ env.CHANGELOG_ARTIFACTS }}/latest.txt"
|
||||||
|
|
||||||
|
# Compose changelog
|
||||||
|
yarn run compose-changelog "${{ github.workspace }}/${{ env.CHANGELOG_ARTIFACTS }}/$CHANGELOG_FILE_NAME"
|
||||||
|
|
||||||
|
- name: Configure AWS Credentials for Changelog [S3]
|
||||||
|
uses: aws-actions/configure-aws-credentials@v5
|
||||||
|
with:
|
||||||
|
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
|
||||||
|
aws-region: us-east-1
|
||||||
|
|
||||||
|
- name: Publish Changelog [S3]
|
||||||
|
run: |
|
||||||
|
aws s3 sync ${{ env.CHANGELOG_ARTIFACTS }} s3://${{ secrets.DOWNLOADS_BUCKET }}/arduino-ide/changelog
|
||||||
96
.github/workflows/github-stats.yaml
vendored
96
.github/workflows/github-stats.yaml
vendored
@@ -1,96 +0,0 @@
|
|||||||
name: github-stats
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
# run every 30 minutes
|
|
||||||
- cron: "*/30 * * * *"
|
|
||||||
workflow_dispatch:
|
|
||||||
repository_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
push-stats:
|
|
||||||
# This workflow is only of value to the arduino/arduino-ide repository and
|
|
||||||
# would always fail in forks
|
|
||||||
if: github.repository == 'arduino/arduino-ide'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Fetch downloads count
|
|
||||||
id: fetch
|
|
||||||
uses: actions/github-script@v4
|
|
||||||
with:
|
|
||||||
github-token: ${{github.token}}
|
|
||||||
script: |
|
|
||||||
let metrics = []
|
|
||||||
|
|
||||||
// Get a list of releases
|
|
||||||
const opts = github.repos.listReleases.endpoint.merge({
|
|
||||||
...context.repo
|
|
||||||
})
|
|
||||||
const releases = await github.paginate(opts)
|
|
||||||
|
|
||||||
// Get download stats for every release
|
|
||||||
for (const rel of releases) {
|
|
||||||
// Names for assets are like `arduino-ide_2.0.0-beta.12_Linux_64bit.zip`,
|
|
||||||
// we'll use this later to split the asset file name more easily
|
|
||||||
const baseName = `arduino-ide_${rel.name}_`
|
|
||||||
|
|
||||||
// Get a list of assets for this release
|
|
||||||
const opts = github.repos.listReleaseAssets.endpoint.merge({
|
|
||||||
...context.repo,
|
|
||||||
release_id: rel.id
|
|
||||||
})
|
|
||||||
const assets = await github.paginate(opts)
|
|
||||||
|
|
||||||
for (const asset of assets) {
|
|
||||||
// Ignore files that are not arduino-ide packages
|
|
||||||
if (!asset.name.startsWith(baseName)) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strip the base and remove file extension to get `Linux_32bit`
|
|
||||||
systemArch = asset.name.replace(baseName, "").split(".")[0].split("_")
|
|
||||||
|
|
||||||
// Add a metric object to the list of gathered metrics
|
|
||||||
metrics.push({
|
|
||||||
"type": "gauge",
|
|
||||||
"name": "arduino.downloads.total",
|
|
||||||
"value": asset.download_count,
|
|
||||||
"host": "${{ github.repository }}",
|
|
||||||
"tags": [
|
|
||||||
`version:${rel.name}`,
|
|
||||||
`os:${systemArch[0]}`,
|
|
||||||
`arch:${systemArch[1]}`,
|
|
||||||
"cdn:github.com",
|
|
||||||
"project:arduino-ide"
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The action will put whatever we return from this function in
|
|
||||||
// `outputs.result`, JSON encoded. So we just return the array
|
|
||||||
// of objects and GitHub will do the rest.
|
|
||||||
return metrics
|
|
||||||
|
|
||||||
- name: Send metrics
|
|
||||||
uses: masci/datadog@v1
|
|
||||||
with:
|
|
||||||
api-key: ${{ secrets.DD_API_KEY }}
|
|
||||||
# Metrics input expects YAML but JSON will work just right.
|
|
||||||
metrics: ${{steps.fetch.outputs.result}}
|
|
||||||
|
|
||||||
- name: Report failure
|
|
||||||
if: failure()
|
|
||||||
uses: masci/datadog@v1
|
|
||||||
with:
|
|
||||||
api-key: ${{ secrets.DD_API_KEY }}
|
|
||||||
events: |
|
|
||||||
- title: "Arduino IDE stats failing"
|
|
||||||
text: "Stats collection failed"
|
|
||||||
alert_type: "error"
|
|
||||||
host: ${{ github.repository }}
|
|
||||||
tags:
|
|
||||||
- "project:arduino-ide"
|
|
||||||
- "cdn:github.com"
|
|
||||||
- "workflow:${{ github.workflow }}"
|
|
||||||
32
.github/workflows/i18n-nightly-push.yml
vendored
32
.github/workflows/i18n-nightly-push.yml
vendored
@@ -1,5 +1,9 @@
|
|||||||
name: i18n-nightly-push
|
name: i18n-nightly-push
|
||||||
|
|
||||||
|
env:
|
||||||
|
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
||||||
|
GO_VERSION: '1.21'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
# run every day at 1AM
|
# run every day at 1AM
|
||||||
@@ -10,16 +14,34 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- name: Install Node.js 14.x
|
- name: Install Node.js 18.17
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '14.x'
|
node-version: '18.17'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
cache: 'yarn'
|
||||||
|
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
|
- name: Install Task
|
||||||
|
uses: arduino/setup-task@v2
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
version: 3.x
|
||||||
|
|
||||||
|
- name: Install dependencies (Linux only)
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libx11-dev libxkbfile-dev libsecret-1-dev
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn
|
run: yarn install --immutable
|
||||||
|
|
||||||
- name: Run i18n:push script
|
- name: Run i18n:push script
|
||||||
run: yarn run i18n:push
|
run: yarn run i18n:push
|
||||||
|
|||||||
34
.github/workflows/i18n-weekly-pull.yml
vendored
34
.github/workflows/i18n-weekly-pull.yml
vendored
@@ -1,5 +1,9 @@
|
|||||||
name: i18n-weekly-pull
|
name: i18n-weekly-pull
|
||||||
|
|
||||||
|
env:
|
||||||
|
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
||||||
|
GO_VERSION: '1.21'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
# run every monday at 2AM
|
# run every monday at 2AM
|
||||||
@@ -10,16 +14,34 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- name: Install Node.js 14.x
|
- name: Install Node.js 18.17
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '14.x'
|
node-version: '18.17'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
cache: 'yarn'
|
||||||
|
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
|
- name: Install Task
|
||||||
|
uses: arduino/setup-task@v2
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
version: 3.x
|
||||||
|
|
||||||
|
- name: Install dependencies (Linux only)
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libx11-dev libxkbfile-dev libsecret-1-dev
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn
|
run: yarn install --immutable
|
||||||
|
|
||||||
- name: Run i18n:pull script
|
- name: Run i18n:pull script
|
||||||
run: yarn run i18n:pull
|
run: yarn run i18n:pull
|
||||||
@@ -30,7 +52,7 @@ jobs:
|
|||||||
TRANSIFEX_API_KEY: ${{ secrets.TRANSIFEX_API_KEY }}
|
TRANSIFEX_API_KEY: ${{ secrets.TRANSIFEX_API_KEY }}
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v3
|
uses: peter-evans/create-pull-request@v7
|
||||||
with:
|
with:
|
||||||
commit-message: Updated translation files
|
commit-message: Updated translation files
|
||||||
title: Update translation files
|
title: Update translation files
|
||||||
|
|||||||
70
.github/workflows/push-container-images.yml
vendored
Normal file
70
.github/workflows/push-container-images.yml
vendored
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
name: Push Container Images
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- ".github/workflows/push-container-images.ya?ml"
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- ".github/workflows/push-container-images.ya?ml"
|
||||||
|
- "**.Dockerfile"
|
||||||
|
- "**/Dockerfile"
|
||||||
|
repository_dispatch:
|
||||||
|
schedule:
|
||||||
|
# Run periodically to catch breakage caused by external changes.
|
||||||
|
- cron: "0 8 * * MON"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
push:
|
||||||
|
name: Push (${{ matrix.image.name }})
|
||||||
|
# Only run the job when GITHUB_TOKEN has the privileges required for Container registry login.
|
||||||
|
if: >
|
||||||
|
(
|
||||||
|
github.event_name != 'pull_request' &&
|
||||||
|
github.repository == 'arduino/arduino-ide'
|
||||||
|
) ||
|
||||||
|
(
|
||||||
|
github.event_name == 'pull_request' &&
|
||||||
|
github.event.pull_request.head.repo.full_name == 'arduino/arduino-ide'
|
||||||
|
)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
image:
|
||||||
|
- path: .github/workflows/assets/linux.Dockerfile
|
||||||
|
name: ${{ github.repository }}/linux
|
||||||
|
registry: ghcr.io
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Log in to the Container registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
registry: ${{ matrix.image.registry }}
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
|
||||||
|
- name: Extract metadata for image
|
||||||
|
id: metadata
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ matrix.image.registry }}/${{ matrix.image.name }}
|
||||||
|
|
||||||
|
- name: Build and push image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ${{ matrix.image.path }}
|
||||||
|
labels: ${{ steps.metadata.outputs.labels }}
|
||||||
|
# Workflow is triggered on relevant events for the sake of a "dry run" validation but image is only pushed to
|
||||||
|
# registry on commit to the main branch.
|
||||||
|
push: ${{ github.ref == 'refs/heads/main' }}
|
||||||
|
tags: ${{ steps.metadata.outputs.tags }}
|
||||||
39
.github/workflows/sync-labels.yml
vendored
39
.github/workflows/sync-labels.yml
vendored
@@ -5,21 +5,21 @@ name: Sync Labels
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
- ".github/workflows/sync-labels.ya?ml"
|
- '.github/workflows/sync-labels.ya?ml'
|
||||||
- ".github/label-configuration-files/*.ya?ml"
|
- '.github/label-configuration-files/*.ya?ml'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- ".github/workflows/sync-labels.ya?ml"
|
- '.github/workflows/sync-labels.ya?ml'
|
||||||
- ".github/label-configuration-files/*.ya?ml"
|
- '.github/label-configuration-files/*.ya?ml'
|
||||||
schedule:
|
schedule:
|
||||||
# Run daily at 8 AM UTC to sync with changes to shared label configurations.
|
# Run daily at 8 AM UTC to sync with changes to shared label configurations.
|
||||||
- cron: "0 8 * * *"
|
- cron: '0 8 * * *'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
repository_dispatch:
|
repository_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CONFIGURATIONS_FOLDER: .github/label-configuration-files
|
CONFIGURATIONS_FOLDER: .github/label-configuration-files
|
||||||
CONFIGURATIONS_ARTIFACT: label-configuration-files
|
CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file-
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
@@ -27,11 +27,11 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- name: Download JSON schema for labels configuration file
|
- name: Download JSON schema for labels configuration file
|
||||||
id: download-schema
|
id: download-schema
|
||||||
uses: carlosperate/download-file-action@v1
|
uses: carlosperate/download-file-action@v2
|
||||||
with:
|
with:
|
||||||
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json
|
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json
|
||||||
location: ${{ runner.temp }}/label-configuration-schema
|
location: ${{ runner.temp }}/label-configuration-schema
|
||||||
@@ -66,18 +66,18 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download
|
- name: Download
|
||||||
uses: carlosperate/download-file-action@v1
|
uses: carlosperate/download-file-action@v2
|
||||||
with:
|
with:
|
||||||
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }}
|
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }}
|
||||||
|
|
||||||
- name: Pass configuration files to next job via workflow artifact
|
- name: Pass configuration files to next job via workflow artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
*.yaml
|
*.yaml
|
||||||
*.yml
|
*.yml
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
|
name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}${{ matrix.filename }}
|
||||||
|
|
||||||
sync:
|
sync:
|
||||||
needs: download
|
needs: download
|
||||||
@@ -103,21 +103,22 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
# Use of this flag in the github-label-sync command will cause it to only check the validity of the
|
# Use of this flag in the github-label-sync command will cause it to only check the validity of the
|
||||||
# configuration.
|
# configuration.
|
||||||
echo "::set-output name=flag::--dry-run"
|
echo "flag=--dry-run" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- name: Download configuration files artifact
|
- name: Download configuration file artifacts
|
||||||
uses: actions/download-artifact@v2
|
uses: actions/download-artifact@v5
|
||||||
with:
|
with:
|
||||||
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
|
merge-multiple: true
|
||||||
|
pattern: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*
|
||||||
path: ${{ env.CONFIGURATIONS_FOLDER }}
|
path: ${{ env.CONFIGURATIONS_FOLDER }}
|
||||||
|
|
||||||
- name: Remove unneeded artifact
|
- name: Remove unneeded artifacts
|
||||||
uses: geekyeggo/delete-artifact@v1
|
uses: geekyeggo/delete-artifact@v5
|
||||||
with:
|
with:
|
||||||
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
|
name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*
|
||||||
|
|
||||||
- name: Merge label configuration files
|
- name: Merge label configuration files
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
140
.github/workflows/test-javascript.yml
vendored
Normal file
140
.github/workflows/test-javascript.yml
vendored
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
name: Test JavaScript
|
||||||
|
|
||||||
|
env:
|
||||||
|
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
||||||
|
GO_VERSION: '1.21'
|
||||||
|
# See: https://github.com/actions/setup-node/#readme
|
||||||
|
NODE_VERSION: 18.17
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- ".github/workflows/test-javascript.ya?ml"
|
||||||
|
- "**/.mocharc.js"
|
||||||
|
- "**/.mocharc.jsonc?"
|
||||||
|
- "**/.mocharc.ya?ml"
|
||||||
|
- "**/package.json"
|
||||||
|
- "**/package-lock.json"
|
||||||
|
- "**/yarn.lock"
|
||||||
|
- "tests/testdata/**"
|
||||||
|
- "**/tsconfig.json"
|
||||||
|
- "**.[jt]sx?"
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- ".github/workflows/test-javascript.ya?ml"
|
||||||
|
- "**/.mocharc.js"
|
||||||
|
- "**/.mocharc.jsonc?"
|
||||||
|
- "**/.mocharc.ya?ml"
|
||||||
|
- "**/package.json"
|
||||||
|
- "**/package-lock.json"
|
||||||
|
- "**/yarn.lock"
|
||||||
|
- "tests/testdata/**"
|
||||||
|
- "**/tsconfig.json"
|
||||||
|
- "**.[jt]sx?"
|
||||||
|
workflow_dispatch:
|
||||||
|
repository_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run-determination:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions: {}
|
||||||
|
outputs:
|
||||||
|
result: ${{ steps.determination.outputs.result }}
|
||||||
|
steps:
|
||||||
|
- name: Determine if the rest of the workflow should run
|
||||||
|
id: determination
|
||||||
|
run: |
|
||||||
|
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
|
||||||
|
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
|
||||||
|
if [[
|
||||||
|
"${{ github.event_name }}" != "create" ||
|
||||||
|
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
|
||||||
|
]]; then
|
||||||
|
# Run the other jobs.
|
||||||
|
RESULT="true"
|
||||||
|
else
|
||||||
|
# There is no need to run the other jobs.
|
||||||
|
RESULT="false"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "result=$RESULT" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: test (${{ matrix.project.path }}, ${{ matrix.operating-system }})
|
||||||
|
needs: run-determination
|
||||||
|
if: needs.run-determination.outputs.result == 'true'
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
project:
|
||||||
|
- path: .
|
||||||
|
operating-system:
|
||||||
|
- macos-latest
|
||||||
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
cache: yarn
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
|
# See: https://github.com/eclipse-theia/theia/blob/master/doc/Developing.md#prerequisites
|
||||||
|
- name: Install Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.11.x'
|
||||||
|
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
|
- name: Install Taskfile
|
||||||
|
uses: arduino/setup-task@v2
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
version: 3.x
|
||||||
|
|
||||||
|
- name: Install Dependencies (Linux only)
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libx11-dev libxkbfile-dev libsecret-1-dev
|
||||||
|
|
||||||
|
- name: Install npm package dependencies
|
||||||
|
env:
|
||||||
|
# Avoid failure of @vscode/ripgrep installation due to GitHub API rate limiting:
|
||||||
|
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
yarn install
|
||||||
|
|
||||||
|
- name: Compile TypeScript
|
||||||
|
run: |
|
||||||
|
yarn \
|
||||||
|
--cwd arduino-ide-extension \
|
||||||
|
build
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
env:
|
||||||
|
# These secrets are optional. Dependent tests will be skipped if not available.
|
||||||
|
CREATE_USERNAME: ${{ secrets.CREATE_USERNAME }}
|
||||||
|
CREATE_PASSWORD: ${{ secrets.CREATE_PASSWORD }}
|
||||||
|
CREATE_CLIENT_SECRET: ${{ secrets.CREATE_CLIENT_SECRET }}
|
||||||
|
run: |
|
||||||
|
yarn test
|
||||||
|
yarn \
|
||||||
|
--cwd arduino-ide-extension \
|
||||||
|
test:slow
|
||||||
69
.github/workflows/themes-weekly-pull.yml
vendored
Normal file
69
.github/workflows/themes-weekly-pull.yml
vendored
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
name: themes-weekly-pull
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# run every friday at 5AM
|
||||||
|
- cron: '0 5 * * 5'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
||||||
|
GO_VERSION: '1.21'
|
||||||
|
NODE_VERSION: '18.17'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pull-from-jsonbin:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Install Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
cache: 'yarn'
|
||||||
|
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
|
- name: Install Task
|
||||||
|
uses: arduino/setup-task@v2
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
version: 3.x
|
||||||
|
|
||||||
|
- name: Install dependencies (Linux only)
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libx11-dev libxkbfile-dev libsecret-1-dev
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: yarn install --immutable
|
||||||
|
|
||||||
|
- name: Run themes:pull script
|
||||||
|
run: yarn run themes:pull
|
||||||
|
env:
|
||||||
|
JSONBIN_MASTER_KEY: ${{ secrets.JSONBIN_MASTER_KEY }}
|
||||||
|
JSONBIN_ID: ${{ secrets.JSONBIN_ID }}
|
||||||
|
|
||||||
|
- name: Generate dark tokens
|
||||||
|
run: npx token-transformer scripts/themes/tokens/arduino-tokens.json scripts/themes/tokens/dark.json core,ide-default,ide-dark,theia core,ide-default,ide-dark
|
||||||
|
|
||||||
|
- name: Generate default tokens
|
||||||
|
run: npx token-transformer scripts/themes/tokens/arduino-tokens.json scripts/themes/tokens/default.json core,ide-default,theia core,ide-default
|
||||||
|
|
||||||
|
- name: Run themes:generate script
|
||||||
|
run: yarn run themes:generate
|
||||||
|
|
||||||
|
- name: Create Pull Request
|
||||||
|
uses: peter-evans/create-pull-request@v7
|
||||||
|
with:
|
||||||
|
commit-message: Updated themes
|
||||||
|
title: Update themes
|
||||||
|
branch: themes/themes-update
|
||||||
|
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
||||||
21
.gitignore
vendored
21
.gitignore
vendored
@@ -1,19 +1,22 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
# .node_modules is a hack for the electron builder.
|
|
||||||
.node_modules/
|
|
||||||
lib/
|
lib/
|
||||||
downloads/
|
downloads/
|
||||||
build/
|
arduino-ide-extension/src/node/resources
|
||||||
Examples/
|
arduino-ide-extension/Examples/
|
||||||
!electron/build/
|
|
||||||
src-gen/
|
src-gen/
|
||||||
!webpack.config.js
|
|
||||||
gen-webpack.config.js
|
gen-webpack.config.js
|
||||||
|
gen-webpack.node.config.js
|
||||||
.DS_Store
|
.DS_Store
|
||||||
# switching from `electron` to `browser` in dev mode.
|
# switching from `electron` to `browser` in dev mode.
|
||||||
.browser_modules
|
.browser_modules
|
||||||
yarn*.log
|
yarn*.log
|
||||||
# For the VS Code extensions used by Theia.
|
# For the VS Code extensions used by Theia.
|
||||||
plugins
|
electron-app/plugins
|
||||||
# the config files for the CLI
|
# the tokens folder for the themes
|
||||||
arduino-ide-extension/data/cli/config
|
scripts/themes/tokens
|
||||||
|
# content trace files for electron
|
||||||
|
electron-app/traces
|
||||||
|
# any Arduino LS generated log files
|
||||||
|
inols*.log
|
||||||
|
# The electron-builder output.
|
||||||
|
electron-app/dist
|
||||||
|
|||||||
11
.prettierignore
Normal file
11
.prettierignore
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
lib
|
||||||
|
dist
|
||||||
|
plugins
|
||||||
|
src-gen
|
||||||
|
i18n
|
||||||
|
gen-webpack*
|
||||||
|
.browser_modules
|
||||||
|
arduino-ide-extension/src/node/resources
|
||||||
|
cli-protocol
|
||||||
|
*color-theme.json
|
||||||
|
arduino-icons.json
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"singleQuote": true,
|
|
||||||
"tabWidth": 2,
|
|
||||||
"useTabs": false,
|
|
||||||
"printWidth": 80
|
|
||||||
}
|
|
||||||
28
.prettierrc.json
Normal file
28
.prettierrc.json
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"useTabs": false,
|
||||||
|
"printWidth": 80,
|
||||||
|
"endOfLine": "auto",
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": "*.json",
|
||||||
|
"options": {
|
||||||
|
"tabWidth": 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": "*.css",
|
||||||
|
"options": {
|
||||||
|
"tabWidth": 4,
|
||||||
|
"singleQuote": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": "*.html",
|
||||||
|
"options": {
|
||||||
|
"tabWidth": 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
118
.vscode/launch.json
vendored
118
.vscode/launch.json
vendored
@@ -4,34 +4,70 @@
|
|||||||
{
|
{
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "App (Electron)",
|
"name": "App",
|
||||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
|
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
|
||||||
"windows": {
|
"windows": {
|
||||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd",
|
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
|
||||||
},
|
},
|
||||||
"cwd": "${workspaceFolder}/electron-app",
|
"cwd": "${workspaceFolder}/electron-app",
|
||||||
"protocol": "inspector",
|
|
||||||
"args": [
|
"args": [
|
||||||
".",
|
".",
|
||||||
"--log-level=debug",
|
"--log-level=debug",
|
||||||
"--hostname=localhost",
|
"--hostname=localhost",
|
||||||
"--no-cluster",
|
"--app-project-path=${workspaceFolder}/electron-app",
|
||||||
"--app-project-path=${workspaceRoot}/electron-app",
|
|
||||||
"--remote-debugging-port=9222",
|
"--remote-debugging-port=9222",
|
||||||
"--no-app-auto-install",
|
"--no-app-auto-install",
|
||||||
"--plugins=local-dir:../plugins",
|
"--plugins=local-dir:./plugins",
|
||||||
"--hosted-plugin-inspect=9339"
|
"--hosted-plugin-inspect=9339",
|
||||||
|
"--no-ping-timeout"
|
||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"NODE_ENV": "development"
|
"NODE_ENV": "development"
|
||||||
},
|
},
|
||||||
"sourceMaps": true,
|
"sourceMaps": true,
|
||||||
"outFiles": [
|
"outFiles": [
|
||||||
"${workspaceRoot}/electron-app/src-gen/backend/*.js",
|
"${workspaceFolder}/electron-app/lib/backend/electron-main.js",
|
||||||
"${workspaceRoot}/electron-app/src-gen/frontend/*.js",
|
"${workspaceFolder}/electron-app/lib/backend/main.js",
|
||||||
"${workspaceRoot}/electron-app/lib/**/*.js",
|
"${workspaceFolder}/electron-app/lib/**/*.js",
|
||||||
"${workspaceRoot}/arduino-ide-extension/lib/**/*.js",
|
"${workspaceFolder}/arduino-ide-extension/lib/**/*.js",
|
||||||
"${workspaceRoot}/node_modules/@theia/**/*.js"
|
"${workspaceFolder}/node_modules/@theia/**/*.js"
|
||||||
|
],
|
||||||
|
"smartStep": true,
|
||||||
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
|
"outputCapture": "std"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "App [Dev]",
|
||||||
|
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
|
||||||
|
"windows": {
|
||||||
|
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
|
||||||
|
},
|
||||||
|
"cwd": "${workspaceFolder}/electron-app",
|
||||||
|
"args": [
|
||||||
|
".",
|
||||||
|
"--log-level=debug",
|
||||||
|
"--hostname=localhost",
|
||||||
|
"--app-project-path=${workspaceFolder}/electron-app",
|
||||||
|
"--remote-debugging-port=9222",
|
||||||
|
"--no-app-auto-install",
|
||||||
|
"--plugins=local-dir:./plugins",
|
||||||
|
"--hosted-plugin-inspect=9339",
|
||||||
|
"--content-trace",
|
||||||
|
"--open-devtools",
|
||||||
|
"--no-ping-timeout"
|
||||||
|
],
|
||||||
|
"env": {
|
||||||
|
"NODE_ENV": "development"
|
||||||
|
},
|
||||||
|
"sourceMaps": true,
|
||||||
|
"outFiles": [
|
||||||
|
"${workspaceFolder}/electron-app/lib/backend/electron-main.js",
|
||||||
|
"${workspaceFolder}/electron-app/lib/backend/main.js",
|
||||||
|
"${workspaceFolder}/electron-app/lib/**/*.js",
|
||||||
|
"${workspaceFolder}/arduino-ide-extension/lib/**/*.js",
|
||||||
|
"${workspaceFolder}/node_modules/@theia/**/*.js"
|
||||||
],
|
],
|
||||||
"smartStep": true,
|
"smartStep": true,
|
||||||
"internalConsoleOptions": "openOnSessionStart",
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
@@ -47,40 +83,8 @@
|
|||||||
{
|
{
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "App (Browser)",
|
|
||||||
"program": "${workspaceRoot}/browser-app/src-gen/backend/main.js",
|
|
||||||
"args": [
|
|
||||||
"--hostname=0.0.0.0",
|
|
||||||
"--port=3000",
|
|
||||||
"--no-cluster",
|
|
||||||
"--no-app-auto-install",
|
|
||||||
"--plugins=local-dir:plugins"
|
|
||||||
],
|
|
||||||
"windows": {
|
|
||||||
"env": {
|
|
||||||
"NODE_ENV": "development",
|
|
||||||
"NODE_PRESERVE_SYMLINKS": "1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"env": {
|
|
||||||
"NODE_ENV": "development"
|
|
||||||
},
|
|
||||||
"sourceMaps": true,
|
|
||||||
"outFiles": [
|
|
||||||
"${workspaceRoot}/browser-app/src-gen/backend/*.js",
|
|
||||||
"${workspaceRoot}/browser-app/lib/**/*.js",
|
|
||||||
"${workspaceRoot}/arduino-ide-extension/lib/**/*.js"
|
|
||||||
],
|
|
||||||
"smartStep": true,
|
|
||||||
"internalConsoleOptions": "openOnSessionStart",
|
|
||||||
"outputCapture": "std"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"name": "Run Test [current]",
|
"name": "Run Test [current]",
|
||||||
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
|
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
|
||||||
"args": [
|
"args": [
|
||||||
"--require",
|
"--require",
|
||||||
"reflect-metadata/Reflect",
|
"reflect-metadata/Reflect",
|
||||||
@@ -90,8 +94,16 @@
|
|||||||
"--colors",
|
"--colors",
|
||||||
"**/${fileBasenameNoExtension}.js"
|
"**/${fileBasenameNoExtension}.js"
|
||||||
],
|
],
|
||||||
|
"outFiles": [
|
||||||
|
"${workspaceRoot}/electron-app/src-gen/backend/*.js",
|
||||||
|
"${workspaceRoot}/electron-app/src-gen/frontend/*.js",
|
||||||
|
"${workspaceRoot}/electron-app/lib/**/*.js",
|
||||||
|
"${workspaceRoot}/arduino-ide-extension/lib/**/*.js",
|
||||||
|
"${workspaceRoot}/node_modules/@theia/**/*.js"
|
||||||
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"TS_NODE_PROJECT": "${workspaceRoot}/tsconfig.json"
|
"TS_NODE_PROJECT": "${workspaceFolder}/tsconfig.json",
|
||||||
|
"IDE2_TEST": "true"
|
||||||
},
|
},
|
||||||
"sourceMaps": true,
|
"sourceMaps": true,
|
||||||
"smartStep": true,
|
"smartStep": true,
|
||||||
@@ -103,22 +115,12 @@
|
|||||||
"request": "attach",
|
"request": "attach",
|
||||||
"name": "Attach by Process ID",
|
"name": "Attach by Process ID",
|
||||||
"processId": "${command:PickProcess}"
|
"processId": "${command:PickProcess}"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "Electron Packager",
|
|
||||||
"program": "${workspaceRoot}/electron/packager/index.js",
|
|
||||||
"cwd": "${workspaceFolder}/electron/packager"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"compounds": [
|
"compounds": [
|
||||||
{
|
{
|
||||||
"name": "Launch Electron Backend & Frontend",
|
"name": "Launch Electron Backend & Frontend",
|
||||||
"configurations": [
|
"configurations": ["App", "Attach to Electron Frontend"]
|
||||||
"App (Electron)",
|
|
||||||
"Attach to Electron Frontend"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
@@ -2,8 +2,11 @@
|
|||||||
"files.exclude": {
|
"files.exclude": {
|
||||||
"**/lib": false
|
"**/lib": false
|
||||||
},
|
},
|
||||||
|
"search.exclude": {
|
||||||
|
"arduino-ide-extension/src/test/node/__test_sketchbook__": true
|
||||||
|
},
|
||||||
"typescript.tsdk": "node_modules/typescript/lib",
|
"typescript.tsdk": "node_modules/typescript/lib",
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": true
|
"source.fixAll.eslint": "explicit"
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
48
.vscode/tasks.json
vendored
48
.vscode/tasks.json
vendored
@@ -2,10 +2,13 @@
|
|||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"label": "Arduino IDE - Rebuild Electron App",
|
"label": "Rebuild App",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "yarn rebuild:browser && yarn rebuild:electron",
|
"command": "yarn rebuild",
|
||||||
"group": "build",
|
"group": "build",
|
||||||
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}/electron-app"
|
||||||
|
},
|
||||||
"presentation": {
|
"presentation": {
|
||||||
"reveal": "always",
|
"reveal": "always",
|
||||||
"panel": "new",
|
"panel": "new",
|
||||||
@@ -13,18 +16,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Arduino IDE - Start Browser App",
|
"label": "Watch Extension",
|
||||||
"type": "shell",
|
|
||||||
"command": "yarn --cwd ./browser-app start",
|
|
||||||
"group": "build",
|
|
||||||
"presentation": {
|
|
||||||
"reveal": "always",
|
|
||||||
"panel": "new",
|
|
||||||
"clear": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Arduino IDE - Watch IDE Extension",
|
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "yarn --cwd ./arduino-ide-extension watch",
|
"command": "yarn --cwd ./arduino-ide-extension watch",
|
||||||
"group": "build",
|
"group": "build",
|
||||||
@@ -35,18 +27,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Arduino IDE - Watch Browser App",
|
"label": "Watch App",
|
||||||
"type": "shell",
|
|
||||||
"command": "yarn --cwd ./browser-app watch",
|
|
||||||
"group": "build",
|
|
||||||
"presentation": {
|
|
||||||
"reveal": "always",
|
|
||||||
"panel": "new",
|
|
||||||
"clear": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Arduino IDE - Watch Electron App",
|
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "yarn --cwd ./electron-app watch",
|
"command": "yarn --cwd ./electron-app watch",
|
||||||
"group": "build",
|
"group": "build",
|
||||||
@@ -57,20 +38,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Arduino IDE - Watch All [Browser]",
|
"label": "Watch All",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"dependsOn": [
|
"dependsOn": ["Watch Extension", "Watch App"]
|
||||||
"Arduino IDE - Watch IDE Extension",
|
|
||||||
"Arduino IDE - Watch Browser App"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Arduino IDE - Watch All [Electron]",
|
|
||||||
"type": "shell",
|
|
||||||
"dependsOn": [
|
|
||||||
"Arduino IDE - Watch IDE Extension",
|
|
||||||
"Arduino IDE - Watch Electron App"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
146
BUILDING.md
146
BUILDING.md
@@ -1,145 +1,3 @@
|
|||||||
# Development
|
# Development Guide
|
||||||
|
|
||||||
This page includes technical documentation for developers who want to build the IDE locally and contribute to the project.
|
|
||||||
|
|
||||||
## Architecture overview
|
|
||||||
|
|
||||||
The IDE consists of three major parts:
|
|
||||||
- the _Electron main_ process,
|
|
||||||
- the _backend_, and
|
|
||||||
- the _frontend_.
|
|
||||||
|
|
||||||
The _Electron main_ process is responsible for:
|
|
||||||
- creating the application,
|
|
||||||
- managing the application lifecycle via listeners, and
|
|
||||||
- creating and managing the web pages for the app.
|
|
||||||
|
|
||||||
In Electron, the process that runs the main entry JavaScript file is called the main process. The _Electron main_ process can display a GUI by creating web pages. An Electron app always has exactly one main process.
|
|
||||||
|
|
||||||
By default, whenever the _Electron main_ process creates a web page, it will instantiate a new `BrowserWindow` instance. Since Electron uses Chromium for displaying web pages, Chromium's multi-process architecture is also used. Each web page in Electron runs in its own process, which is called the renderer process. Each `BrowserWindow` instance runs the web page in its own renderer process. When a `BrowserWindow` instance is destroyed, the corresponding renderer process is also terminated. The main process manages all web pages and their corresponding renderer processes. Each renderer process is isolated and only cares about the web page running in it.<sup>[[1]]</sup>
|
|
||||||
|
|
||||||
In normal browsers, web pages usually run in a sandboxed environment, and accessing native resources are disallowed. However, Electron has the power to use Node.js APIs in the web pages allowing lower-level OS interactions. Due to security reasons, accessing native resources is an undesired behavior in the IDE. So by convention, we do not use Node.js APIs. (Note: the Node.js integration is [not yet disabled](https://github.com/eclipse-theia/theia/issues/2018) although it is not used). In the IDE, only the _backend_ allows OS interaction.
|
|
||||||
|
|
||||||
The _backend_ process is responsible for:
|
|
||||||
- providing access to the filesystem,
|
|
||||||
- communicating with the [Arduino CLI](https://github.com/arduino/arduino-cli) via gRPC,
|
|
||||||
- running your terminal,
|
|
||||||
- exposing additional RESTful APIs,
|
|
||||||
- performing the Git commands in the local repositories,
|
|
||||||
- hosting and running any VS Code extensions, or
|
|
||||||
- executing VS Code tasks<sup>[[2]]</sup>.
|
|
||||||
|
|
||||||
The _Electron main_ process spawns the _backend_ process. There is always exactly one _backend_ process. However, due to performance considerations, the _backend_ spawns several sub-processes for the filesystem watching, Git repository discovery, etc. The communication between the _backend_ process and its sub-processes is established via IPC. Besides spawning sub-processes, the _backend_ will start an HTTP server on a random available port, and serves the web application as static content. When the sub-processes are up and running, and the HTTP server is also listening, the _backend_ process sends the HTTP server port to the _Electron main_ process via IPC. The _Electron main_ process will load the _backend_'s endpoint in the `BrowserWindow`.
|
|
||||||
|
|
||||||
The _frontend_ is running as an Electron renderer process and can invoke services implemented on the _backend_. The communication between the _backend_ and the _frontend_ is done via JSON-RPC over a websocket connection. This means, the services running in the _frontend_ are all proxies, and will ask the corresponding service implementation on the _backend_.
|
|
||||||
|
|
||||||
[1]: https://www.electronjs.org/docs/tutorial/application-architecture#differences-between-main-process-and-renderer-process
|
|
||||||
[2]: https://code.visualstudio.com/Docs/editor/tasks
|
|
||||||
|
|
||||||
|
|
||||||
## Build from source
|
|
||||||
|
|
||||||
If you’re familiar with TypeScript, the [Theia IDE](https://theia-ide.org/), and if you want to contribute to the
|
|
||||||
project, you should be able to build the Arduino IDE locally.
|
|
||||||
Please refer to the [Theia IDE prerequisites](https://github.com/theia-ide/theia/blob/master/doc/) documentation for the setup instructions.
|
|
||||||
> **Note**: Node.js 14 must be used instead of the version 12 recommended at the link above.
|
|
||||||
|
|
||||||
Once you have all the tools installed, you can build the editor following these steps
|
|
||||||
|
|
||||||
1. Install the dependencies and build
|
|
||||||
```sh
|
|
||||||
yarn
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Rebuild the dependencies
|
|
||||||
```sh
|
|
||||||
yarn rebuild:browser
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Rebuild the electron dependencies
|
|
||||||
```sh
|
|
||||||
yarn rebuild:electron
|
|
||||||
```
|
|
||||||
|
|
||||||
4. Start the application
|
|
||||||
```sh
|
|
||||||
yarn start
|
|
||||||
```
|
|
||||||
|
|
||||||
### CI
|
|
||||||
|
|
||||||
This project is built on [GitHub Actions](https://github.com/arduino/arduino-ide/actions).
|
|
||||||
|
|
||||||
- _Snapshot_ builds run when changes are pushed to the `main` branch, or when a PR is created against the `main` branch. For the sake of the review and verification process, the build artifacts for each operating system can be downloaded from the GitHub Actions page.
|
|
||||||
- _Nightly_ builds run every day at 03:00 GMT from the `main` branch.
|
|
||||||
- _Release_ builds run when a new tag is pushed to the remote. The tag must follow the [semver](https://semver.org/). For instance, `1.2.3` is a correct tag, but `v2.3.4` won't work. Steps to trigger a new release build:
|
|
||||||
- Create a local tag:
|
|
||||||
```sh
|
|
||||||
git tag -a 1.2.3 -m "Creating a new tag for the `1.2.3` release."
|
|
||||||
```
|
|
||||||
- Push it to the remote:
|
|
||||||
```sh
|
|
||||||
git push origin 1.2.3
|
|
||||||
```
|
|
||||||
|
|
||||||
## Notes for macOS contributors
|
|
||||||
Beginning in macOS 10.14.5, the software [must be notarized to run](https://developer.apple.com/documentation/xcode/notarizing_macos_software_before_distribution). The signing and notarization processes for the Arduino IDE are managed by our Continuous Integration (CI) workflows, implemented with GitHub Actions. On every push and pull request, the Arduino IDE is built and saved to a workflow artifact. These artifacts can be used by contributors and beta testers who don't want to set up a build system locally.
|
|
||||||
For security reasons, signing and notarization are disabled for workflow runs for pull requests from forks of this repository. This means that macOS will block you from running those artifacts.
|
|
||||||
Due to this limitation, Mac users have two options for testing contributions from forks:
|
|
||||||
|
|
||||||
### The Safe approach (recommended)
|
|
||||||
|
|
||||||
Follow [the instructions above](#build-from-source) to create the build environment locally, then build the code you want to test.
|
|
||||||
|
|
||||||
### The Risky approach
|
|
||||||
|
|
||||||
*Please note that this approach is risky as you are lowering the security on your system, therefore we strongly discourage you from following it.*
|
|
||||||
1. Use [this guide](https://help.apple.com/xcode/mac/10.2/index.html?localePath=en.lproj#/dev9b7736b0e), in order to disable Gatekeeper (at your own risk!).
|
|
||||||
1. Download the unsigned artifact provided by the CI workflow run related to the Pull Request at each push.
|
|
||||||
1. Re-enable Gatekeeper after tests are done, following the guide linked above.
|
|
||||||
|
|
||||||
### Creating a release
|
|
||||||
|
|
||||||
You will not need to create a new release yourself as the Arduino team takes care of this on a regular basis, but we are documenting the process here. Let's assume the current version is `0.1.3` and you want to release `0.2.0`.
|
|
||||||
|
|
||||||
- Make sure the `main` state represents what you want to release and you're on `main`.
|
|
||||||
- Prepare a release-candidate build on a branch:
|
|
||||||
```bash
|
|
||||||
git branch 0.2.0-rc \
|
|
||||||
&& git checkout 0.2.0-rc
|
|
||||||
```
|
|
||||||
- Bump up the version number. It must be a valid [semver](https://semver.org/) and must be greater than the current one:
|
|
||||||
```bash
|
|
||||||
yarn update:version 0.2.0
|
|
||||||
```
|
|
||||||
- This should generate multiple outgoing changes with the version update.
|
|
||||||
- Commit your changes and push to the remote:
|
|
||||||
```bash
|
|
||||||
git add . \
|
|
||||||
&& git commit -s -m "Updated versions to 0.2.0" \
|
|
||||||
&& git push
|
|
||||||
```
|
|
||||||
- Create the GH PR the workflow starts automatically.
|
|
||||||
- Once you're happy with the RC, merge the changes to the `main`.
|
|
||||||
- Create a tag and push it:
|
|
||||||
```bash
|
|
||||||
git tag -a 0.2.0 -m "0.2.0" \
|
|
||||||
&& git push origin 0.2.0
|
|
||||||
```
|
|
||||||
- The release build starts automatically and uploads the artifacts with the changelog to the [release page](https://github.com/arduino/arduino-ide/releases).
|
|
||||||
- If you do not want to release the `EXE` and `MSI` installers, wipe them manually.
|
|
||||||
- If you do not like the generated changelog, modify it and update the GH release.
|
|
||||||
|
|
||||||
## FAQ
|
|
||||||
|
|
||||||
* *Can I manually change the version of the [`arduino-cli`](https://github.com/arduino/arduino-cli/) used by the IDE?*
|
|
||||||
|
|
||||||
Yes. It is possible but not recommended. The CLI exposes a set of functionality via [gRPC](https://github.com/arduino/arduino-cli/tree/master/rpc) and the IDE uses this API to communicate with the CLI. Before we build a new version of IDE, we pin a specific version of CLI and use the corresponding `proto` files to generate TypeScript modules for gRPC. This means, a particular version of IDE is compliant only with the pinned version of CLI. Mismatching IDE and CLI versions might not be able to communicate with each other. This could cause unpredictable IDE behavior.
|
|
||||||
|
|
||||||
* *I have understood that not all versions of the CLI are compatible with my version of IDE but how can I manually update the `arduino-cli` inside the IDE?*
|
|
||||||
|
|
||||||
[Get](https://arduino.github.io/arduino-cli/installation) the desired version of `arduino-cli` for your platform and manually replace the one inside the IDE. The CLI can be found inside the IDE at:
|
|
||||||
- Windows: `C:\path\to\Arduino IDE\resources\app\node_modules\arduino-ide-extension\build\arduino-cli.exe`,
|
|
||||||
- macOS: `/path/to/Arduino IDE.app/Contents/Resources/app/node_modules/arduino-ide-extension/build/arduino-cli`, and
|
|
||||||
- Linux: `/path/to/Arduino IDE/resources/app/node_modules/arduino-ide-extension/build/arduino-cli`.
|
|
||||||
|
|
||||||
|
This documentation has been moved [**here**](docs/development.md#development-guide).
|
||||||
|
|||||||
54
README.md
54
README.md
@@ -1,44 +1,20 @@
|
|||||||
<img src="https://content.arduino.cc/website/Arduino_logo_teal.svg" height="100" align="right" />
|
<img src="https://content.arduino.cc/website/Arduino_logo_teal.svg" height="100" align="right" />
|
||||||
|
|
||||||
# Arduino IDE 2.x (beta)
|
# Arduino IDE 2.x
|
||||||
|
|
||||||
[](https://github.com/arduino/arduino-ide/actions?query=workflow%3A%22Arduino+IDE%22)
|
[](https://github.com/arduino/arduino-ide/actions/workflows/build.yml)
|
||||||
|
[](https://github.com/arduino/arduino-ide/actions/workflows/check-javascript.yml)
|
||||||
|
[](https://github.com/arduino/arduino-ide/actions/workflows/test-javascript.yml)
|
||||||
|
|
||||||
This repository contains the source code of the Arduino IDE 2.x, which is currently in beta stage. If you're looking for the stable IDE, go to the repository of the 1.x version at https://github.com/arduino/Arduino.
|
This repository contains the source code of the Arduino IDE 2.x. If you're looking for the old IDE, go to the [repository of the 1.x version](https://github.com/arduino/Arduino).
|
||||||
|
|
||||||
The Arduino IDE 2.x is a major rewrite, sharing no code with the IDE 1.x. It is based on the [Theia IDE](https://theia-ide.org/) framework and built with [Electron](https://www.electronjs.org/). The backend operations such as compilation and uploading are offloaded to an [arduino-cli](https://github.com/arduino/arduino-cli) instance running in daemon mode. This new IDE was developed with the goal of preserving the same interface and user experience of the previous major version in order to provide a frictionless upgrade.
|
The Arduino IDE 2.x is a major rewrite, sharing no code with the IDE 1.x. It is based on the [Theia IDE](https://theia-ide.org/) framework and built with [Electron](https://www.electronjs.org/). The backend operations such as compilation and uploading are offloaded to an [arduino-cli](https://github.com/arduino/arduino-cli) instance running in daemon mode. This new IDE was developed with the goal of preserving the same interface and user experience of the previous major version in order to provide a frictionless upgrade.
|
||||||
|
|
||||||
> ⚠️ This is **beta** software. Help us test it!
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Download
|
## Download
|
||||||
|
|
||||||
You can download the latest version from the [software download page on the Arduino website](https://www.arduino.cc/en/software#experimental-software).
|
You can download the latest release version and nightly builds from the [software download page on the Arduino website](https://www.arduino.cc/en/software).
|
||||||
|
|
||||||
### Nightly builds
|
|
||||||
|
|
||||||
These builds are generated every day at 03:00 GMT from the `main` branch and
|
|
||||||
should be considered unstable:
|
|
||||||
|
|
||||||
| Platform | 32 bit | 64 bit |
|
|
||||||
| --------- | ------------------------ | ------------------------------------------------------------------------------------------------------ |
|
|
||||||
| Linux | | [Nightly Linux 64 bit] |
|
|
||||||
| Linux ARM | [🚧 Work in progress...] | [🚧 Work in progress...] |
|
|
||||||
| Windows | | [Nightly Windows 64 bit installer]<br />[Nightly Windows 64 bit MSI]<br />[Nightly Windows 64 bit ZIP] |
|
|
||||||
| macOS | | [Nightly macOS 64 bit] |
|
|
||||||
|
|
||||||
[🚧 work in progress...]: https://github.com/arduino/arduino-ide/issues/107
|
|
||||||
[nightly linux 64 bit]: https://downloads.arduino.cc/arduino-ide/nightly/arduino-ide_nightly-latest_Linux_64bit.zip
|
|
||||||
[nightly windows 64 bit installer]: https://downloads.arduino.cc/arduino-ide/nightly/arduino-ide_nightly-latest_Windows_64bit.exe
|
|
||||||
[nightly windows 64 bit msi]: https://downloads.arduino.cc/arduino-ide/nightly/arduino-ide_nightly-latest_Windows_64bit.msi
|
|
||||||
[nightly windows 64 bit zip]: https://downloads.arduino.cc/arduino-ide/nightly/arduino-ide_nightly-latest_Windows_64bit.zip
|
|
||||||
[nightly macos 64 bit]: https://downloads.arduino.cc/arduino-ide/nightly/arduino-ide_nightly-latest_macOS_64bit.dmg
|
|
||||||
|
|
||||||
> These links return an HTTP `302: Found` response, redirecting to latest
|
|
||||||
> generated builds by replacing `latest` with the latest available build
|
|
||||||
> date, using the format YYYYMMDD (i.e for 2019/Aug/06 `latest` is
|
|
||||||
> replaced with `20190806`)
|
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
@@ -46,10 +22,9 @@ If you need assistance, see the [Help Center](https://support.arduino.cc/hc/en-u
|
|||||||
|
|
||||||
## Bugs & Issues
|
## Bugs & Issues
|
||||||
|
|
||||||
If you want to report an issue, you can submit it to the [issue tracker](https://github.com/arduino/arduino-ide/issues) of this repository. A few rules apply:
|
If you want to report an issue, you can submit it to the [issue tracker](https://github.com/arduino/arduino-ide/issues) of this repository.
|
||||||
|
|
||||||
- Before posting, please check if the same problem has been already reported by someone else to avoid duplicates.
|
See [**the issue report guide**](docs/contributor-guide/issues.md#issue-report-guide) for instructions.
|
||||||
- Remember to include as much detail as you can about your hardware set-up, code and steps for reproducing the issue. Make sure you're using an original Arduino board.
|
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
||||||
@@ -61,16 +36,15 @@ e-mail contact: security@arduino.cc
|
|||||||
|
|
||||||
## Contributions and development
|
## Contributions and development
|
||||||
|
|
||||||
Contributions are very welcome! You can browse the list of open issues to see what's needed and then you can submit your code using a Pull Request. Please provide detailed descriptions. We also appreciate any help in testing issues and patches contributed by other users.
|
Contributions are very welcome! There are several ways to participate in this project, including:
|
||||||
|
|
||||||
This repository contains the main code, but two more repositories are included during the build process:
|
- Fixing bugs
|
||||||
|
- Beta testing
|
||||||
|
- Translation
|
||||||
|
|
||||||
- [vscode-arduino-tools](https://github.com/arduino/vscode-arduino-tools): provides support for the language server and the debugger
|
See [**the contributor guide**](docs/CONTRIBUTING.md#contributor-guide) for more information.
|
||||||
- [arduino-language-server](https://github.com/arduino/arduino-language-server): provides the language server that parses Arduino code
|
|
||||||
|
|
||||||
See the [BUILDING.md](BUILDING.md) for a technical overview of the application and instructions for building the code.
|
See the [**development guide**](docs/development.md) for a technical overview of the application and instructions for building the code.
|
||||||
|
|
||||||
You can help with the translation of the Arduino IDE to your language here: [Arduino IDE on Transifex](https://www.transifex.com/arduino-1/ide2/dashboard/).
|
|
||||||
|
|
||||||
## Donations
|
## Donations
|
||||||
|
|
||||||
|
|||||||
@@ -55,19 +55,32 @@ The Config Service knows about your system, like for example the default sketch
|
|||||||
- checking whether a file is in a data or sketch directory
|
- checking whether a file is in a data or sketch directory
|
||||||
|
|
||||||
### `"arduino"` configuration in the `package.json`:
|
### `"arduino"` configuration in the `package.json`:
|
||||||
- `"cli"`:
|
|
||||||
- `"version"` type `string` | `{ owner: string, repo: string, commitish?: string }`: if the type is a `string` and is a valid semver, it will get the corresponding [released](https://github.com/arduino/arduino-cli/releases) CLI. If the type is `string` and is a [date in `YYYYMMDD`](https://arduino.github.io/arduino-cli/latest/installation/#nightly-builds) format, it will get a nightly CLI. If the type is an object, a CLI, build from the sources in the `owner/repo` will be used. If `commitish` is not defined, the HEAD of the default branch will be used. In any other cases an error is thrown.
|
- `"cli"`:
|
||||||
|
- `"version"` type `string` | `{ owner: string, repo: string, commitish?: string }`: if the type is a `string` and is a valid semver, it will get the corresponding [released](https://github.com/arduino/arduino-cli/releases) CLI. If the type is `string` and is a [date in `YYYYMMDD`](https://arduino.github.io/arduino-cli/latest/installation/#nightly-builds) format, it will get a nightly CLI. If the type is an object, a CLI, build from the sources in the `owner/repo` will be used. If `commitish` is not defined, the HEAD of the default branch will be used. In any other cases an error is thrown.
|
||||||
|
|
||||||
#### Rebuild gRPC protocol interfaces
|
#### Rebuild gRPC protocol interfaces
|
||||||
- Some CLI updates can bring changes to the gRPC interfaces, as the API might change. gRPC interfaces can be updated running the command
|
|
||||||
`yarn --cwd arduino-ide-extension generate-protocol`
|
- Some CLI updates can bring changes to the gRPC interfaces, as the API might change. gRPC interfaces can be updated running the command
|
||||||
|
`yarn --cwd arduino-ide-extension generate-protocol`
|
||||||
|
|
||||||
|
### Update **clangd** and **ClangFormat**
|
||||||
|
|
||||||
|
The [**clangd** C++ language server](https://clangd.llvm.org/) and the [**ClangFormat** code formatter](https://clang.llvm.org/docs/ClangFormat.html) tool dependencies are managed in parallel. Updating them to a different version is done by the following procedure:
|
||||||
|
|
||||||
|
1. If the target version is not already [available from the `arduino/clang-static-binaries` repository](https://github.com/arduino/clang-static-binaries/releases), submit [an issue there](https://github.com/arduino/clang-static-binaries/issues) requesting a build and wait for that to be completed.
|
||||||
|
1. Validate the **ClangFormat** configuration for the target version by following the instructions [**here**](https://github.com/arduino/tooling-project-assets/tree/main/other/clang-format-configuration#clangformat-version-updates)
|
||||||
|
1. Submit a pull request in the `arduino/arduino-ide` repository to update the version in the `arduino.clangd.version` key of [`package.json`](package.json).
|
||||||
|
1. Submit a pull request in [the `arduino/tooling-project-assets` repository](https://github.com/arduino/tooling-project-assets) to update the version in the `vars.DEFAULT_CLANG_FORMAT_VERSION` field of [`Taskfile.yml`](https://github.com/arduino/tooling-project-assets/blob/main/Taskfile.yml).
|
||||||
|
|
||||||
### Customize Icons
|
### Customize Icons
|
||||||
|
|
||||||
ArduinoIde uses a customized version of FontAwesome.
|
ArduinoIde uses a customized version of FontAwesome.
|
||||||
In order to update/replace icons follow the following steps:
|
In order to update/replace icons follow the following steps:
|
||||||
- import the file `arduino-icons.json` in [Icomoon](https://icomoon.io/app/#/projects)
|
|
||||||
- load it
|
- import the file `arduino-icons.json` in [Icomoon](https://icomoon.io/app/#/projects)
|
||||||
- edit the icons as needed
|
- load it
|
||||||
- !! download the **new** `arduino-icons.json` file and put it in this repo
|
- edit the icons as needed
|
||||||
- Click on "Generate Font" in Icomoon, then download
|
- !! download the **new** `arduino-icons.json` file and put it in this repo
|
||||||
- place the updated fonts in the `src/style/fonts` directory
|
- Click on "Generate Font" in Icomoon, then download
|
||||||
|
- place the updated fonts in the `src/style/fonts` directory
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,128 +1,136 @@
|
|||||||
{
|
{
|
||||||
"name": "arduino-ide-extension",
|
"name": "arduino-ide-extension",
|
||||||
"version": "2.0.0-rc4",
|
"version": "2.3.7",
|
||||||
"description": "An extension for Theia building the Arduino IDE",
|
"description": "An extension for Theia building the Arduino IDE",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "yarn download-cli && yarn download-fwuploader && yarn download-ls && yarn copy-serial-plotter && yarn clean && yarn download-examples && yarn build && yarn test",
|
"prepare": "yarn download-cli && yarn download-fwuploader && yarn download-ls && yarn copy-i18n && yarn download-examples",
|
||||||
"clean": "rimraf lib",
|
"clean": "rimraf lib",
|
||||||
"compose-changelog": "node ./scripts/compose-changelog.js",
|
"compose-changelog": "node ./scripts/compose-changelog.js",
|
||||||
"download-cli": "node ./scripts/download-cli.js",
|
"download-cli": "node ./scripts/download-cli.js",
|
||||||
"download-fwuploader": "node ./scripts/download-fwuploader.js",
|
"download-fwuploader": "node ./scripts/download-fwuploader.js",
|
||||||
"copy-serial-plotter": "npx ncp ../node_modules/arduino-serial-plotter-webapp ./build/arduino-serial-plotter-webapp",
|
"copy-i18n": "ncp ../i18n ./src/node/resources/i18n",
|
||||||
"download-ls": "node ./scripts/download-ls.js",
|
"download-ls": "node ./scripts/download-ls.js",
|
||||||
"download-examples": "node ./scripts/download-examples.js",
|
"download-examples": "node ./scripts/download-examples.js",
|
||||||
"generate-protocol": "node ./scripts/generate-protocol.js",
|
"generate-protocol": "node ./scripts/generate-protocol.js",
|
||||||
"lint": "eslint",
|
"lint": "eslint .",
|
||||||
"build": "tsc && ncp ./src/node/cli-protocol/ ./lib/node/cli-protocol/ && yarn lint",
|
"prebuild": "rimraf lib",
|
||||||
|
"build": "tsc",
|
||||||
|
"build:dev": "yarn build",
|
||||||
|
"postbuild": "ncp ./src/node/cli-protocol/ ./lib/node/cli-protocol/",
|
||||||
"watch": "tsc -w",
|
"watch": "tsc -w",
|
||||||
"test": "mocha \"./lib/test/**/*.test.js\"",
|
"test": "cross-env IDE2_TEST=true mocha \"./lib/test/**/*.test.js\"",
|
||||||
"test:watch": "mocha --watch --watch-files lib \"./lib/test/**/*.test.js\""
|
"test:slow": "cross-env IDE2_TEST=true mocha \"./lib/test/**/*.slow-test.js\" --slow 5000"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.3.7",
|
"@grpc/grpc-js": "^1.8.14",
|
||||||
"@theia/application-package": "1.22.1",
|
"@theia/application-package": "1.57.0",
|
||||||
"@theia/core": "1.22.1",
|
"@theia/core": "1.57.0",
|
||||||
"@theia/editor": "1.22.1",
|
"@theia/debug": "1.57.0",
|
||||||
"@theia/editor-preview": "1.22.1",
|
"@theia/editor": "1.57.0",
|
||||||
"@theia/electron": "1.22.1",
|
"@theia/electron": "1.57.0",
|
||||||
"@theia/filesystem": "1.22.1",
|
"@theia/filesystem": "1.57.0",
|
||||||
"@theia/git": "1.22.1",
|
"@theia/keymaps": "1.57.0",
|
||||||
"@theia/keymaps": "1.22.1",
|
"@theia/markers": "1.57.0",
|
||||||
"@theia/markers": "1.22.1",
|
"@theia/messages": "1.57.0",
|
||||||
"@theia/monaco": "1.22.1",
|
"@theia/monaco": "1.57.0",
|
||||||
"@theia/navigator": "1.22.1",
|
"@theia/monaco-editor-core": "1.83.101",
|
||||||
"@theia/outline-view": "1.22.1",
|
"@theia/navigator": "1.57.0",
|
||||||
"@theia/output": "1.22.1",
|
"@theia/outline-view": "1.57.0",
|
||||||
"@theia/preferences": "1.22.1",
|
"@theia/output": "1.57.0",
|
||||||
"@theia/search-in-workspace": "1.22.1",
|
"@theia/plugin-ext": "1.57.0",
|
||||||
"@theia/terminal": "1.22.1",
|
"@theia/plugin-ext-vscode": "1.57.0",
|
||||||
"@theia/workspace": "1.22.1",
|
"@theia/preferences": "1.57.0",
|
||||||
|
"@theia/scm": "1.57.0",
|
||||||
|
"@theia/search-in-workspace": "1.57.0",
|
||||||
|
"@theia/terminal": "1.57.0",
|
||||||
|
"@theia/test": "1.57.0",
|
||||||
|
"@theia/typehierarchy": "1.57.0",
|
||||||
|
"@theia/workspace": "1.57.0",
|
||||||
"@tippyjs/react": "^4.2.5",
|
"@tippyjs/react": "^4.2.5",
|
||||||
"@types/atob": "^2.1.2",
|
"@types/auth0-js": "^9.21.3",
|
||||||
"@types/auth0-js": "^9.14.0",
|
|
||||||
"@types/btoa": "^1.2.3",
|
"@types/btoa": "^1.2.3",
|
||||||
"@types/dateformat": "^3.0.1",
|
"@types/dateformat": "^3.0.1",
|
||||||
"@types/deepmerge": "^2.2.0",
|
|
||||||
"@types/glob": "^5.0.35",
|
|
||||||
"@types/google-protobuf": "^3.7.2",
|
"@types/google-protobuf": "^3.7.2",
|
||||||
"@types/js-yaml": "^3.12.2",
|
"@types/js-yaml": "^3.12.2",
|
||||||
"@types/keytar": "^4.4.0",
|
"@types/jsdom": "^21.1.1",
|
||||||
"@types/lodash.debounce": "^4.0.6",
|
"@types/lodash.debounce": "^4.0.6",
|
||||||
"@types/ncp": "^2.0.4",
|
|
||||||
"@types/node-fetch": "^2.5.7",
|
"@types/node-fetch": "^2.5.7",
|
||||||
|
"@types/p-queue": "^2.3.1",
|
||||||
"@types/ps-tree": "^1.1.0",
|
"@types/ps-tree": "^1.1.0",
|
||||||
"@types/react-select": "^3.0.0",
|
|
||||||
"@types/react-tabs": "^2.3.2",
|
|
||||||
"@types/temp": "^0.8.34",
|
"@types/temp": "^0.8.34",
|
||||||
"@types/which": "^1.3.1",
|
"arduino-serial-plotter-webapp": "0.2.0",
|
||||||
"ajv": "^6.5.3",
|
|
||||||
"arduino-serial-plotter-webapp": "0.0.17",
|
|
||||||
"async-mutex": "^0.3.0",
|
"async-mutex": "^0.3.0",
|
||||||
"atob": "^2.1.2",
|
"auth0-js": "^9.23.2",
|
||||||
"auth0-js": "^9.14.0",
|
|
||||||
"btoa": "^1.2.1",
|
"btoa": "^1.2.1",
|
||||||
"css-element-queries": "^1.2.0",
|
"classnames": "^2.3.1",
|
||||||
|
"cross-fetch": "^3.1.5",
|
||||||
"dateformat": "^3.0.3",
|
"dateformat": "^3.0.3",
|
||||||
"deepmerge": "2.0.1",
|
"deepmerge": "^4.2.2",
|
||||||
|
"dompurify": "^2.4.7",
|
||||||
|
"drivelist": "^9.2.4",
|
||||||
"electron-updater": "^4.6.5",
|
"electron-updater": "^4.6.5",
|
||||||
"fuzzy": "^0.1.3",
|
"fast-deep-equal": "^3.1.3",
|
||||||
"glob": "^7.1.6",
|
"fast-json-stable-stringify": "^2.1.0",
|
||||||
"google-protobuf": "^3.11.4",
|
"fast-safe-stringify": "^2.1.1",
|
||||||
"grpc": "^1.24.11",
|
"filename-reserved-regex": "^2.0.0",
|
||||||
|
"fqbn": "^1.0.5",
|
||||||
|
"glob": "10.4.4",
|
||||||
|
"google-protobuf": "^3.20.1",
|
||||||
"hash.js": "^1.1.7",
|
"hash.js": "^1.1.7",
|
||||||
"is-valid-path": "^0.1.1",
|
"is-online": "^10.0.0",
|
||||||
"js-yaml": "^3.13.1",
|
"js-yaml": "^3.13.1",
|
||||||
|
"jsdom": "^21.1.1",
|
||||||
|
"jsonc-parser": "^2.2.0",
|
||||||
|
"just-diff": "^5.1.1",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"keytar": "7.2.0",
|
"keytar": "7.2.0",
|
||||||
"lodash.debounce": "^4.0.8",
|
"lodash.debounce": "^4.0.8",
|
||||||
"ncp": "^2.0.0",
|
"minimatch": "^3.1.2",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
|
"node-log-rotate": "^0.1.5",
|
||||||
"open": "^8.0.6",
|
"open": "^8.0.6",
|
||||||
"p-queue": "^5.0.0",
|
"p-debounce": "^2.1.0",
|
||||||
|
"p-queue": "^2.4.2",
|
||||||
|
"process": "^0.11.10",
|
||||||
"ps-tree": "^1.2.0",
|
"ps-tree": "^1.2.0",
|
||||||
"query-string": "^7.0.1",
|
"query-string": "^7.0.1",
|
||||||
"react-disable": "^0.1.0",
|
"react-disable": "^0.1.1",
|
||||||
"react-markdown": "^8.0.0",
|
"react-markdown": "^8.0.0",
|
||||||
"react-select": "^3.0.4",
|
"react-perfect-scrollbar": "^1.5.8",
|
||||||
"react-tabs": "^3.1.2",
|
"react-select": "^5.6.0",
|
||||||
|
"react-tabs": "^6.1.0",
|
||||||
"react-window": "^1.8.6",
|
"react-window": "^1.8.6",
|
||||||
"semver": "^7.3.2",
|
"semver": "^7.3.2",
|
||||||
"string-natural-compare": "^2.0.3",
|
"string-natural-compare": "^2.0.3",
|
||||||
"temp": "^0.9.1",
|
"temp": "^0.9.1",
|
||||||
|
"temp-dir": "^2.0.0",
|
||||||
"tree-kill": "^1.2.1",
|
"tree-kill": "^1.2.1",
|
||||||
"upath": "^1.1.2",
|
"util": "^0.12.5",
|
||||||
"url": "^0.11.0",
|
"vscode-arduino-api": "^0.1.2"
|
||||||
"which": "^1.3.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@octokit/rest": "^18.12.0",
|
"@octokit/rest": "^18.12.0",
|
||||||
"@types/chai": "^4.2.7",
|
"@types/chai": "^4.2.7",
|
||||||
"@types/chai-string": "^1.4.2",
|
"@types/mocha": "^10.0.0",
|
||||||
"@types/mocha": "^5.2.7",
|
|
||||||
"@types/react-window": "^1.8.5",
|
"@types/react-window": "^1.8.5",
|
||||||
"@types/sinon": "^10.0.6",
|
"@xhmikosr/downloader": "^13.0.1",
|
||||||
"@types/sinon-chai": "^3.2.6",
|
|
||||||
"chai": "^4.2.0",
|
"chai": "^4.2.0",
|
||||||
"chai-string": "^1.5.0",
|
"cross-env": "^7.0.3",
|
||||||
"decompress": "^4.2.0",
|
"decompress": "^4.2.0",
|
||||||
|
"decompress-tarbz2": "^4.1.1",
|
||||||
"decompress-targz": "^4.1.1",
|
"decompress-targz": "^4.1.1",
|
||||||
"decompress-unzip": "^4.0.1",
|
"decompress-unzip": "^4.0.1",
|
||||||
"download": "^7.1.0",
|
"grpc_tools_node_protoc_ts": "^5.3.3",
|
||||||
"grpc_tools_node_protoc_ts": "^4.1.0",
|
"mocha": "^10.2.0",
|
||||||
"mocha": "^7.0.0",
|
|
||||||
"mockdate": "^3.0.5",
|
"mockdate": "^3.0.5",
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.24.0",
|
||||||
"protoc": "^1.0.4",
|
"ncp": "^2.0.0",
|
||||||
"shelljs": "^0.8.3",
|
"rimraf": "^5.0.0"
|
||||||
"sinon": "^12.0.1",
|
|
||||||
"sinon-chai": "^3.7.0",
|
|
||||||
"typemoq": "^2.1.0",
|
|
||||||
"uuid": "^3.2.1",
|
|
||||||
"yargs": "^11.1.0"
|
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"grpc-tools": "^1.9.0"
|
"@pingghost/protoc": "^1.0.2",
|
||||||
|
"grpc-tools": "^1.12.4"
|
||||||
},
|
},
|
||||||
"mocha": {
|
"mocha": {
|
||||||
"require": [
|
"require": [
|
||||||
@@ -142,30 +150,42 @@
|
|||||||
"examples"
|
"examples"
|
||||||
],
|
],
|
||||||
"theiaExtensions": [
|
"theiaExtensions": [
|
||||||
|
{
|
||||||
|
"preload": "lib/electron-browser/preload"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"backend": "lib/node/arduino-ide-backend-module",
|
"backend": "lib/node/arduino-ide-backend-module",
|
||||||
"frontend": "lib/browser/arduino-ide-frontend-module"
|
"frontend": "lib/browser/arduino-ide-frontend-module"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"frontend": "lib/browser/theia/core/browser-menu-module",
|
|
||||||
"frontendElectron": "lib/electron-browser/theia/core/electron-menu-module"
|
"frontendElectron": "lib/electron-browser/theia/core/electron-menu-module"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"frontendElectron": "lib/electron-browser/theia/core/electron-window-module"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"frontendElectron": "lib/electron-browser/electron-arduino-module"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"electronMain": "lib/electron-main/arduino-electron-main-module"
|
"electronMain": "lib/electron-main/arduino-electron-main-module"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"arduino": {
|
"arduino": {
|
||||||
"cli": {
|
"arduino-cli": {
|
||||||
"version": "0.21.0"
|
"version": "1.2.0"
|
||||||
},
|
},
|
||||||
"fwuploader": {
|
"arduino-fwuploader": {
|
||||||
"version": "2.0.0"
|
"version": "2.4.1"
|
||||||
|
},
|
||||||
|
"arduino-language-server": {
|
||||||
|
"version": {
|
||||||
|
"owner": "arduino",
|
||||||
|
"repo": "arduino-language-server",
|
||||||
|
"commitish": "05ec308"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"clangd": {
|
"clangd": {
|
||||||
"version": "13.0.0"
|
"version": "14.0.0"
|
||||||
},
|
|
||||||
"languageServer": {
|
|
||||||
"version": "0.6.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
}, '');
|
}, '');
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
if (args.length == 0) {
|
if (args.length === 0) {
|
||||||
console.error('Missing argument to destination file');
|
console.error('Missing argument to destination file');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,141 +1,95 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
const path = require('path');
|
||||||
|
const semver = require('semver');
|
||||||
|
const moment = require('moment');
|
||||||
|
const downloader = require('./downloader');
|
||||||
|
const { taskBuildFromGit } = require('./utils');
|
||||||
|
|
||||||
const fs = require('fs');
|
const version = (() => {
|
||||||
const path = require('path');
|
const pkg = require(path.join(__dirname, '..', 'package.json'));
|
||||||
const temp = require('temp');
|
if (!pkg) {
|
||||||
const shell = require('shelljs');
|
return undefined;
|
||||||
const semver = require('semver');
|
}
|
||||||
const moment = require('moment');
|
|
||||||
const downloader = require('./downloader');
|
|
||||||
|
|
||||||
const version = (() => {
|
const { arduino } = pkg;
|
||||||
const pkg = require(path.join(__dirname, '..', 'package.json'));
|
if (!arduino) {
|
||||||
if (!pkg) {
|
return undefined;
|
||||||
return undefined;
|
}
|
||||||
|
|
||||||
|
const cli = arduino['arduino-cli'];
|
||||||
|
if (!cli) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { version } = cli;
|
||||||
|
return version;
|
||||||
|
})();
|
||||||
|
|
||||||
|
if (!version) {
|
||||||
|
console.log(`Could not retrieve CLI version info from the 'package.json'.`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { platform, arch } = process;
|
||||||
|
const resourcesFolder = path.join(
|
||||||
|
__dirname,
|
||||||
|
'..',
|
||||||
|
'src',
|
||||||
|
'node',
|
||||||
|
'resources'
|
||||||
|
);
|
||||||
|
const cliName = `arduino-cli${platform === 'win32' ? '.exe' : ''}`;
|
||||||
|
const destinationPath = path.join(resourcesFolder, cliName);
|
||||||
|
|
||||||
|
if (typeof version === 'string') {
|
||||||
|
const suffix = (() => {
|
||||||
|
switch (platform) {
|
||||||
|
case 'darwin':
|
||||||
|
if (arch === 'arm64') {
|
||||||
|
return 'macOS_ARM64.tar.gz';
|
||||||
|
}
|
||||||
|
return 'macOS_64bit.tar.gz';
|
||||||
|
case 'win32':
|
||||||
|
return 'Windows_64bit.zip';
|
||||||
|
case 'linux': {
|
||||||
|
switch (arch) {
|
||||||
|
case 'arm':
|
||||||
|
return 'Linux_ARMv7.tar.gz';
|
||||||
|
case 'arm64':
|
||||||
|
return 'Linux_ARM64.tar.gz';
|
||||||
|
case 'x64':
|
||||||
|
return 'Linux_64bit.tar.gz';
|
||||||
|
default:
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
const { arduino } = pkg;
|
return undefined;
|
||||||
if (!arduino) {
|
}
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { cli } = arduino;
|
|
||||||
if (!cli) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { version } = cli;
|
|
||||||
return version;
|
|
||||||
})();
|
})();
|
||||||
|
if (!suffix) {
|
||||||
if (!version) {
|
console.log(`The CLI is not available for ${platform} ${arch}.`);
|
||||||
shell.echo(`Could not retrieve CLI version info from the 'package.json'.`);
|
process.exit(1);
|
||||||
shell.exit(1);
|
|
||||||
}
|
}
|
||||||
|
if (semver.valid(version)) {
|
||||||
const { platform, arch } = process;
|
const url = `https://downloads.arduino.cc/arduino-cli/arduino-cli_${version}_${suffix}`;
|
||||||
const buildFolder = path.join(__dirname, '..', 'build');
|
console.log(
|
||||||
const cliName = `arduino-cli${platform === 'win32' ? '.exe' : ''}`;
|
`📦 Identified released version of the CLI. Downloading version ${version} from '${url}'`
|
||||||
const destinationPath = path.join(buildFolder, cliName);
|
);
|
||||||
|
await downloader.downloadUnzipFile(url, destinationPath, 'arduino-cli');
|
||||||
if (typeof version === 'string') {
|
} else if (moment(version, 'YYYYMMDD', true).isValid()) {
|
||||||
const suffix = (() => {
|
const url = `https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-${version}_${suffix}`;
|
||||||
switch (platform) {
|
console.log(
|
||||||
case 'darwin': return 'macOS_64bit.tar.gz';
|
`🌙 Identified nightly version of the CLI. Downloading version ${version} from '${url}'`
|
||||||
case 'win32': return 'Windows_64bit.zip';
|
);
|
||||||
case 'linux': {
|
await downloader.downloadUnzipFile(url, destinationPath, 'arduino-cli');
|
||||||
switch (arch) {
|
|
||||||
case 'arm': return 'Linux_ARMv7.tar.gz';
|
|
||||||
case 'arm64': return 'Linux_ARM64.tar.gz';
|
|
||||||
case 'x64': return 'Linux_64bit.tar.gz';
|
|
||||||
default: return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default: return undefined;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
if (!suffix) {
|
|
||||||
shell.echo(`The CLI is not available for ${platform} ${arch}.`);
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
if (semver.valid(version)) {
|
|
||||||
const url = `https://downloads.arduino.cc/arduino-cli/arduino-cli_${version}_${suffix}`;
|
|
||||||
shell.echo(`📦 Identified released version of the CLI. Downloading version ${version} from '${url}'`);
|
|
||||||
await downloader.downloadUnzipFile(url, destinationPath, 'arduino-cli');
|
|
||||||
} else if (moment(version, 'YYYYMMDD', true).isValid()) {
|
|
||||||
const url = `https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-${version}_${suffix}`;
|
|
||||||
shell.echo(`🌙 Identified nightly version of the CLI. Downloading version ${version} from '${url}'`);
|
|
||||||
await downloader.downloadUnzipFile(url, destinationPath, 'arduino-cli');
|
|
||||||
} else {
|
|
||||||
shell.echo(`🔥 Could not interpret 'version': ${version}`);
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
console.log(`🔥 Could not interpret 'version': ${version}`);
|
||||||
// We assume an object with `owner`, `repo`, commitish?` properties.
|
process.exit(1);
|
||||||
const { owner, repo, commitish } = version;
|
|
||||||
if (!owner) {
|
|
||||||
shell.echo(`Could not retrieve 'owner' from ${JSON.stringify(version)}`);
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
if (!repo) {
|
|
||||||
shell.echo(`Could not retrieve 'repo' from ${JSON.stringify(version)}`);
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
const url = `https://github.com/${owner}/${repo}.git`;
|
|
||||||
shell.echo(`Building CLI from ${url}. Commitish: ${commitish ? commitish : 'HEAD'}`);
|
|
||||||
|
|
||||||
if (fs.existsSync(destinationPath)) {
|
|
||||||
shell.echo(`Skipping the CLI build because it already exists: ${destinationPath}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shell.mkdir('-p', buildFolder).code !== 0) {
|
|
||||||
shell.echo('Could not create build folder.');
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const tempRepoPath = temp.mkdirSync();
|
|
||||||
shell.echo(`>>> Cloning CLI source to ${tempRepoPath}...`);
|
|
||||||
if (shell.exec(`git clone ${url} ${tempRepoPath}`).code !== 0) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
shell.echo('<<< Cloned CLI repo.')
|
|
||||||
|
|
||||||
if (commitish) {
|
|
||||||
shell.echo(`>>> Checking out ${commitish}...`);
|
|
||||||
if (shell.exec(`git -C ${tempRepoPath} checkout ${commitish}`).code !== 0) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
shell.echo(`<<< Checked out ${commitish}.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
shell.echo(`>>> Building the CLI...`);
|
|
||||||
if (shell.exec('go build', { cwd: tempRepoPath }).code !== 0) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
shell.echo('<<< CLI build done.')
|
|
||||||
|
|
||||||
if (!fs.existsSync(path.join(tempRepoPath, cliName))) {
|
|
||||||
shell.echo(`Could not find the CLI at ${path.join(tempRepoPath, cliName)}.`);
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const builtCliPath = path.join(tempRepoPath, cliName);
|
|
||||||
shell.echo(`>>> Copying CLI from ${builtCliPath} to ${destinationPath}...`);
|
|
||||||
if (shell.cp(builtCliPath, destinationPath).code !== 0) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
shell.echo(`<<< Copied the CLI.`);
|
|
||||||
|
|
||||||
shell.echo('<<< Verifying CLI...');
|
|
||||||
if (!fs.existsSync(destinationPath)) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
shell.echo('>>> Verified CLI.');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
taskBuildFromGit(version, destinationPath, 'CLI');
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1,33 +1,119 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
// The version to use.
|
// The version to use.
|
||||||
const version = '1.9.1';
|
const version = '1.10.2';
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
const os = require('node:os');
|
||||||
|
const {
|
||||||
|
existsSync,
|
||||||
|
promises: fs,
|
||||||
|
mkdirSync,
|
||||||
|
readdirSync,
|
||||||
|
cpSync,
|
||||||
|
} = require('node:fs');
|
||||||
|
const path = require('node:path');
|
||||||
|
const { exec } = require('./utils');
|
||||||
|
|
||||||
const os = require('os');
|
const destination = path.join(
|
||||||
const path = require('path');
|
__dirname,
|
||||||
const shell = require('shelljs');
|
'..',
|
||||||
const { v4 } = require('uuid');
|
'src',
|
||||||
|
'node',
|
||||||
|
'resources',
|
||||||
|
'Examples'
|
||||||
|
);
|
||||||
|
if (existsSync(destination)) {
|
||||||
|
console.log(
|
||||||
|
`Skipping Git checkout of the examples because the repository already exists: ${destination}`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const repository = path.join(os.tmpdir(), `${v4()}-arduino-examples`);
|
const repository = await fs.mkdtemp(
|
||||||
if (shell.mkdir('-p', repository).code !== 0) {
|
path.join(os.tmpdir(), 'arduino-examples-')
|
||||||
shell.exit(1);
|
);
|
||||||
process.exit(1);
|
|
||||||
|
exec(
|
||||||
|
'git',
|
||||||
|
['clone', 'https://github.com/arduino/arduino-examples.git', repository],
|
||||||
|
{ logStdout: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
exec(
|
||||||
|
'git',
|
||||||
|
['-C', repository, 'checkout', `tags/${version}`, '-b', version],
|
||||||
|
{ logStdout: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
mkdirSync(destination, { recursive: true });
|
||||||
|
const examplesPath = path.join(repository, 'examples');
|
||||||
|
const exampleResources = readdirSync(examplesPath);
|
||||||
|
for (const exampleResource of exampleResources) {
|
||||||
|
cpSync(
|
||||||
|
path.join(examplesPath, exampleResource),
|
||||||
|
path.join(destination, exampleResource),
|
||||||
|
{ recursive: true }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const isSketch = async (pathLike) => {
|
||||||
|
try {
|
||||||
|
const names = await fs.readdir(pathLike);
|
||||||
|
const dirName = path.basename(pathLike);
|
||||||
|
return names.indexOf(`${dirName}.ino`) !== -1;
|
||||||
|
} catch (e) {
|
||||||
|
if (e.code === 'ENOTDIR') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
if (shell.exec(`git clone https://github.com/arduino/arduino-examples.git ${repository}`).code !== 0) {
|
const examples = [];
|
||||||
shell.exit(1);
|
const categories = await fs.readdir(destination);
|
||||||
process.exit(1);
|
const visit = async (pathLike, container) => {
|
||||||
|
const stat = await fs.lstat(pathLike);
|
||||||
|
if (stat.isDirectory()) {
|
||||||
|
if (await isSketch(pathLike)) {
|
||||||
|
container.sketches.push({
|
||||||
|
name: path.basename(pathLike),
|
||||||
|
relativePath: path.relative(destination, pathLike),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const names = await fs.readdir(pathLike);
|
||||||
|
for (const name of names) {
|
||||||
|
const childPath = path.join(pathLike, name);
|
||||||
|
if (await isSketch(childPath)) {
|
||||||
|
container.sketches.push({
|
||||||
|
name,
|
||||||
|
relativePath: path.relative(destination, childPath),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const child = {
|
||||||
|
label: name,
|
||||||
|
children: [],
|
||||||
|
sketches: [],
|
||||||
|
};
|
||||||
|
container.children.push(child);
|
||||||
|
await visit(childPath, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
if (shell.exec(`git -C ${repository} checkout tags/${version} -b ${version}`).code !== 0) {
|
for (const category of categories) {
|
||||||
shell.exit(1);
|
const example = {
|
||||||
process.exit(1);
|
label: category,
|
||||||
}
|
children: [],
|
||||||
|
sketches: [],
|
||||||
const destination = path.join(__dirname, '..', 'Examples');
|
};
|
||||||
shell.mkdir('-p', destination);
|
await visit(path.join(destination, category), example);
|
||||||
shell.cp('-fR', path.join(repository, 'examples', '*'), destination);
|
examples.push(example);
|
||||||
|
}
|
||||||
|
await fs.writeFile(
|
||||||
|
path.join(destination, 'examples.json'),
|
||||||
|
JSON.stringify(examples, null, 2),
|
||||||
|
{ encoding: 'utf8' }
|
||||||
|
);
|
||||||
|
console.log(`Generated output to ${path.join(destination, 'examples.json')}`);
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const fs = require('fs');
|
const path = require('node:path');
|
||||||
const path = require('path');
|
|
||||||
const temp = require('temp');
|
|
||||||
const shell = require('shelljs');
|
|
||||||
const semver = require('semver');
|
const semver = require('semver');
|
||||||
const downloader = require('./downloader');
|
const downloader = require('./downloader');
|
||||||
|
const { taskBuildFromGit } = require('./utils');
|
||||||
|
|
||||||
const version = (() => {
|
const version = (() => {
|
||||||
const pkg = require(path.join(__dirname, '..', 'package.json'));
|
const pkg = require(path.join(__dirname, '..', 'package.json'));
|
||||||
@@ -19,7 +17,7 @@
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { fwuploader } = arduino;
|
const fwuploader = arduino['arduino-fwuploader'];
|
||||||
if (!fwuploader) {
|
if (!fwuploader) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -29,24 +27,37 @@
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
if (!version) {
|
if (!version) {
|
||||||
shell.echo(
|
console.log(
|
||||||
`Could not retrieve Firmware Uploader version info from the 'package.json'.`
|
`Could not retrieve Firmware Uploader version info from the 'package.json'.`
|
||||||
);
|
);
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { platform, arch } = process;
|
const { platform, arch } = process;
|
||||||
const buildFolder = path.join(__dirname, '..', 'build');
|
const resourcesFolder = path.join(
|
||||||
|
__dirname,
|
||||||
|
'..',
|
||||||
|
'src',
|
||||||
|
'node',
|
||||||
|
'resources'
|
||||||
|
);
|
||||||
const fwuploderName = `arduino-fwuploader${
|
const fwuploderName = `arduino-fwuploader${
|
||||||
platform === 'win32' ? '.exe' : ''
|
platform === 'win32' ? '.exe' : ''
|
||||||
}`;
|
}`;
|
||||||
const destinationPath = path.join(buildFolder, fwuploderName);
|
const destinationPath = path.join(resourcesFolder, fwuploderName);
|
||||||
|
|
||||||
if (typeof version === 'string') {
|
if (typeof version === 'string') {
|
||||||
const suffix = (() => {
|
const suffix = (() => {
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'macOS_64bit.tar.gz';
|
switch (arch) {
|
||||||
|
case 'arm64':
|
||||||
|
return 'macOS_ARM64.tar.gz';
|
||||||
|
case 'x64':
|
||||||
|
return 'macOS_64bit.tar.gz';
|
||||||
|
default:
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'Windows_64bit.zip';
|
return 'Windows_64bit.zip';
|
||||||
case 'linux': {
|
case 'linux': {
|
||||||
@@ -66,14 +77,14 @@
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
if (!suffix) {
|
if (!suffix) {
|
||||||
shell.echo(
|
console.log(
|
||||||
`The Firmware Uploader is not available for ${platform} ${arch}.`
|
`The Firmware Uploader is not available for ${platform} ${arch}.`
|
||||||
);
|
);
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
if (semver.valid(version)) {
|
if (semver.valid(version)) {
|
||||||
const url = `https://downloads.arduino.cc/arduino-fwuploader/arduino-fwuploader_${version}_${suffix}`;
|
const url = `https://downloads.arduino.cc/arduino-fwuploader/arduino-fwuploader_${version}_${suffix}`;
|
||||||
shell.echo(
|
console.log(
|
||||||
`📦 Identified released version of the Firmware Uploader. Downloading version ${version} from '${url}'`
|
`📦 Identified released version of the Firmware Uploader. Downloading version ${version} from '${url}'`
|
||||||
);
|
);
|
||||||
await downloader.downloadUnzipFile(
|
await downloader.downloadUnzipFile(
|
||||||
@@ -82,85 +93,10 @@
|
|||||||
'arduino-fwuploader'
|
'arduino-fwuploader'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
shell.echo(`🔥 Could not interpret 'version': ${version}`);
|
console.log(`🔥 Could not interpret 'version': ${version}`);
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// We assume an object with `owner`, `repo`, commitish?` properties.
|
taskBuildFromGit(version, destinationPath, 'Firmware Uploader');
|
||||||
const { owner, repo, commitish } = version;
|
|
||||||
if (!owner) {
|
|
||||||
shell.echo(`Could not retrieve 'owner' from ${JSON.stringify(version)}`);
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
if (!repo) {
|
|
||||||
shell.echo(`Could not retrieve 'repo' from ${JSON.stringify(version)}`);
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
const url = `https://github.com/${owner}/${repo}.git`;
|
|
||||||
shell.echo(
|
|
||||||
`Building Firmware Uploader from ${url}. Commitish: ${
|
|
||||||
commitish ? commitish : 'HEAD'
|
|
||||||
}`
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fs.existsSync(destinationPath)) {
|
|
||||||
shell.echo(
|
|
||||||
`Skipping the Firmware Uploader build because it already exists: ${destinationPath}`
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shell.mkdir('-p', buildFolder).code !== 0) {
|
|
||||||
shell.echo('Could not create build folder.');
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const tempRepoPath = temp.mkdirSync();
|
|
||||||
shell.echo(`>>> Cloning Firmware Uploader source to ${tempRepoPath}...`);
|
|
||||||
if (shell.exec(`git clone ${url} ${tempRepoPath}`).code !== 0) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
shell.echo('<<< Cloned Firmware Uploader repo.');
|
|
||||||
|
|
||||||
if (commitish) {
|
|
||||||
shell.echo(`>>> Checking out ${commitish}...`);
|
|
||||||
if (
|
|
||||||
shell.exec(`git -C ${tempRepoPath} checkout ${commitish}`).code !== 0
|
|
||||||
) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
shell.echo(`<<< Checked out ${commitish}.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
shell.echo(`>>> Building the Firmware Uploader...`);
|
|
||||||
if (shell.exec('go build', { cwd: tempRepoPath }).code !== 0) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
shell.echo('<<< Firmware Uploader build done.');
|
|
||||||
|
|
||||||
if (!fs.existsSync(path.join(tempRepoPath, fwuploderName))) {
|
|
||||||
shell.echo(
|
|
||||||
`Could not find the Firmware Uploader at ${path.join(
|
|
||||||
tempRepoPath,
|
|
||||||
fwuploderName
|
|
||||||
)}.`
|
|
||||||
);
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const builtFwUploaderPath = path.join(tempRepoPath, fwuploderName);
|
|
||||||
shell.echo(
|
|
||||||
`>>> Copying Firmware Uploader from ${builtFwUploaderPath} to ${destinationPath}...`
|
|
||||||
);
|
|
||||||
if (shell.cp(builtFwUploaderPath, destinationPath).code !== 0) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
shell.echo(`<<< Copied the Firmware Uploader.`);
|
|
||||||
|
|
||||||
shell.echo('<<< Verifying Firmware Uploader...');
|
|
||||||
if (!fs.existsSync(destinationPath)) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
shell.echo('>>> Verified Firmware Uploader.');
|
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -5,42 +5,43 @@
|
|||||||
|
|
||||||
(() => {
|
(() => {
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const shell = require('shelljs');
|
|
||||||
const downloader = require('./downloader');
|
const downloader = require('./downloader');
|
||||||
|
const { goBuildFromGit } = require('./utils');
|
||||||
|
|
||||||
const [DEFAULT_ALS_VERSION, DEFAULT_CLANGD_VERSION] = (() => {
|
const [DEFAULT_LS_VERSION, DEFAULT_CLANGD_VERSION] = (() => {
|
||||||
const pkg = require(path.join(__dirname, '..', 'package.json'));
|
const pkg = require(path.join(__dirname, '..', 'package.json'));
|
||||||
if (!pkg) return undefined;
|
if (!pkg) return [undefined, undefined];
|
||||||
|
|
||||||
const { arduino } = pkg;
|
const { arduino } = pkg;
|
||||||
if (!arduino) return undefined;
|
if (!arduino) return [undefined, undefined];
|
||||||
|
|
||||||
const { languageServer, clangd } = arduino;
|
const { clangd } = arduino;
|
||||||
if (!languageServer) return undefined;
|
const languageServer = arduino['arduino-language-server'];
|
||||||
if (!clangd) return undefined;
|
if (!languageServer) return [undefined, undefined];
|
||||||
|
if (!clangd) return [undefined, undefined];
|
||||||
|
|
||||||
return [languageServer.version, clangd.version];
|
return [languageServer.version, clangd.version];
|
||||||
})();
|
})();
|
||||||
|
|
||||||
if (!DEFAULT_ALS_VERSION) {
|
if (!DEFAULT_LS_VERSION) {
|
||||||
shell.echo(
|
console.log(
|
||||||
`Could not retrieve Arduino Language Server version info from the 'package.json'.`
|
`Could not retrieve Arduino Language Server version info from the 'package.json'.`
|
||||||
);
|
);
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DEFAULT_CLANGD_VERSION) {
|
if (!DEFAULT_CLANGD_VERSION) {
|
||||||
shell.echo(
|
console.log(
|
||||||
`Could not retrieve clangd version info from the 'package.json'.`
|
`Could not retrieve clangd version info from the 'package.json'.`
|
||||||
);
|
);
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const yargs = require('yargs')
|
const yargs = require('@theia/core/shared/yargs')
|
||||||
.option('ls-version', {
|
.option('ls-version', {
|
||||||
alias: 'lv',
|
alias: 'lv',
|
||||||
default: DEFAULT_ALS_VERSION,
|
default: DEFAULT_LS_VERSION,
|
||||||
describe: `The version of the 'arduino-language-server' to download. Defaults to ${DEFAULT_ALS_VERSION}.`,
|
describe: `The version of the 'arduino-language-server' to download. Defaults to ${DEFAULT_LS_VERSION}.`,
|
||||||
})
|
})
|
||||||
.option('clangd-version', {
|
.option('clangd-version', {
|
||||||
alias: 'cv',
|
alias: 'cv',
|
||||||
@@ -56,51 +57,103 @@
|
|||||||
.version(false)
|
.version(false)
|
||||||
.parse();
|
.parse();
|
||||||
|
|
||||||
const alsVersion = yargs['ls-version'];
|
const lsVersion = yargs['ls-version'];
|
||||||
const clangdVersion = yargs['clangd-version'];
|
const clangdVersion = yargs['clangd-version'];
|
||||||
const force = yargs['force-download'];
|
const force = yargs['force-download'];
|
||||||
const { platform, arch } = process;
|
const { platform, arch } = process;
|
||||||
const platformArch = platform + '-' + arch;
|
const platformArch = platform + '-' + arch;
|
||||||
const build = path.join(__dirname, '..', 'build');
|
const resourcesFolder = path.join(
|
||||||
|
__dirname,
|
||||||
|
'..',
|
||||||
|
'src',
|
||||||
|
'node',
|
||||||
|
'resources'
|
||||||
|
);
|
||||||
const lsExecutablePath = path.join(
|
const lsExecutablePath = path.join(
|
||||||
build,
|
resourcesFolder,
|
||||||
`arduino-language-server${platform === 'win32' ? '.exe' : ''}`
|
`arduino-language-server${platform === 'win32' ? '.exe' : ''}`
|
||||||
);
|
);
|
||||||
let clangdExecutablePath, lsSuffix, clangdSuffix;
|
let clangdExecutablePath, clangFormatExecutablePath, lsSuffix, clangdSuffix;
|
||||||
|
|
||||||
switch (platformArch) {
|
switch (platformArch) {
|
||||||
case 'darwin-x64':
|
case 'darwin-x64':
|
||||||
clangdExecutablePath = path.join(build, 'clangd');
|
clangdExecutablePath = path.join(resourcesFolder, 'clangd');
|
||||||
|
clangFormatExecutablePath = path.join(resourcesFolder, 'clang-format');
|
||||||
lsSuffix = 'macOS_64bit.tar.gz';
|
lsSuffix = 'macOS_64bit.tar.gz';
|
||||||
clangdSuffix = 'macOS_64bit';
|
clangdSuffix = 'macOS_64bit';
|
||||||
break;
|
break;
|
||||||
|
case 'darwin-arm64':
|
||||||
|
clangdExecutablePath = path.join(resourcesFolder, 'clangd');
|
||||||
|
clangFormatExecutablePath = path.join(resourcesFolder, 'clang-format');
|
||||||
|
lsSuffix = 'macOS_ARM64.tar.gz';
|
||||||
|
clangdSuffix = 'macOS_ARM64';
|
||||||
|
break;
|
||||||
case 'linux-x64':
|
case 'linux-x64':
|
||||||
clangdExecutablePath = path.join(build, 'clangd');
|
clangdExecutablePath = path.join(resourcesFolder, 'clangd');
|
||||||
|
clangFormatExecutablePath = path.join(resourcesFolder, 'clang-format');
|
||||||
lsSuffix = 'Linux_64bit.tar.gz';
|
lsSuffix = 'Linux_64bit.tar.gz';
|
||||||
clangdSuffix = 'Linux_64bit';
|
clangdSuffix = 'Linux_64bit';
|
||||||
break;
|
break;
|
||||||
|
case 'linux-arm64':
|
||||||
|
clangdExecutablePath = path.join(resourcesFolder, 'clangd');
|
||||||
|
clangFormatExecutablePath = path.join(resourcesFolder, 'clang-format');
|
||||||
|
lsSuffix = 'Linux_ARM64.tar.gz';
|
||||||
|
clangdSuffix = 'Linux_ARM64';
|
||||||
|
break;
|
||||||
case 'win32-x64':
|
case 'win32-x64':
|
||||||
clangdExecutablePath = path.join(build, 'clangd.exe');
|
clangdExecutablePath = path.join(resourcesFolder, 'clangd.exe');
|
||||||
|
clangFormatExecutablePath = path.join(
|
||||||
|
resourcesFolder,
|
||||||
|
'clang-format.exe'
|
||||||
|
);
|
||||||
lsSuffix = 'Windows_64bit.zip';
|
lsSuffix = 'Windows_64bit.zip';
|
||||||
clangdSuffix = 'Windows_64bit';
|
clangdSuffix = 'Windows_64bit';
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error(`Unsupported platform/arch: ${platformArch}.`);
|
||||||
}
|
}
|
||||||
if (!lsSuffix || !clangdSuffix) {
|
if (!lsSuffix || !clangdSuffix) {
|
||||||
shell.echo(
|
console.log(
|
||||||
`The arduino-language-server is not available for ${platform} ${arch}.`
|
`The arduino-language-server is not available for ${platform} ${arch}.`
|
||||||
);
|
);
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const alsUrl = `https://downloads.arduino.cc/arduino-language-server/${
|
if (typeof lsVersion === 'string') {
|
||||||
alsVersion === 'nightly'
|
const lsUrl = `https://downloads.arduino.cc/arduino-language-server/${
|
||||||
? 'nightly/arduino-language-server'
|
lsVersion === 'nightly'
|
||||||
: 'arduino-language-server_' + alsVersion
|
? 'nightly/arduino-language-server'
|
||||||
}_${lsSuffix}`;
|
: 'arduino-language-server_' + lsVersion
|
||||||
downloader.downloadUnzipAll(alsUrl, build, lsExecutablePath, force);
|
}_${lsSuffix}`;
|
||||||
|
downloader.downloadUnzipAll(
|
||||||
|
lsUrl,
|
||||||
|
resourcesFolder,
|
||||||
|
lsExecutablePath,
|
||||||
|
force
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
goBuildFromGit(lsVersion, lsExecutablePath, 'language-server');
|
||||||
|
}
|
||||||
|
|
||||||
const clangdUrl = `https://downloads.arduino.cc/tools/clangd_${clangdVersion}_${clangdSuffix}.tar.bz2`;
|
const clangdUrl = `https://downloads.arduino.cc/tools/clangd_${clangdVersion}_${clangdSuffix}.tar.bz2`;
|
||||||
downloader.downloadUnzipAll(clangdUrl, build, clangdExecutablePath, force, {
|
downloader.downloadUnzipAll(
|
||||||
strip: 1,
|
clangdUrl,
|
||||||
}); // `strip`: the new clangd (12.x) is zipped into a folder, so we have to strip the outmost folder.
|
resourcesFolder,
|
||||||
|
clangdExecutablePath,
|
||||||
|
force,
|
||||||
|
{
|
||||||
|
strip: 1,
|
||||||
|
}
|
||||||
|
); // `strip`: the new clangd (12.x) is zipped into a folder, so we have to strip the outmost folder.
|
||||||
|
|
||||||
|
const clangdFormatUrl = `https://downloads.arduino.cc/tools/clang-format_${clangdVersion}_${clangdSuffix}.tar.bz2`;
|
||||||
|
downloader.downloadUnzipAll(
|
||||||
|
clangdFormatUrl,
|
||||||
|
resourcesFolder,
|
||||||
|
clangFormatExecutablePath,
|
||||||
|
force,
|
||||||
|
{
|
||||||
|
strip: 1,
|
||||||
|
}
|
||||||
|
);
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
|
// @ts-check
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const shell = require('shelljs');
|
|
||||||
const download = require('download');
|
|
||||||
const decompress = require('decompress');
|
const decompress = require('decompress');
|
||||||
const unzip = require('decompress-unzip');
|
const unzip = require('decompress-unzip');
|
||||||
const untargz = require('decompress-targz');
|
const untargz = require('decompress-targz');
|
||||||
const untarbz2 = require('decompress-tarbz2');
|
const untarbz2 = require('decompress-tarbz2');
|
||||||
|
|
||||||
process.on('unhandledRejection', (reason, _) => {
|
process.on('unhandledRejection', (reason) => {
|
||||||
shell.echo(String(reason));
|
console.log(String(reason));
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
throw reason;
|
|
||||||
});
|
});
|
||||||
process.on('uncaughtException', (error) => {
|
process.on('uncaughtException', (error) => {
|
||||||
shell.echo(String(error));
|
console.log(String(error));
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
throw error;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,54 +29,42 @@ exports.downloadUnzipFile = async (
|
|||||||
force = false
|
force = false
|
||||||
) => {
|
) => {
|
||||||
if (fs.existsSync(targetFile) && !force) {
|
if (fs.existsSync(targetFile) && !force) {
|
||||||
shell.echo(`Skipping download because file already exists: ${targetFile}`);
|
console.log(`Skipping download because file already exists: ${targetFile}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!fs.existsSync(path.dirname(targetFile))) {
|
fs.mkdirSync(path.dirname(targetFile), { recursive: true });
|
||||||
if (shell.mkdir('-p', path.dirname(targetFile)).code !== 0) {
|
|
||||||
shell.echo('Could not create new directory.');
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const downloads = path.join(__dirname, '..', 'downloads');
|
const downloads = path.join(__dirname, '..', 'downloads');
|
||||||
if (shell.rm('-rf', targetFile, downloads).code !== 0) {
|
fs.rmSync(targetFile, { recursive: true, force: true });
|
||||||
shell.exit(1);
|
fs.rmSync(downloads, { recursive: true, force: true });
|
||||||
}
|
|
||||||
|
|
||||||
shell.echo(`>>> Downloading from '${url}'...`);
|
console.log(`>>> Downloading from '${url}'...`);
|
||||||
const data = await download(url);
|
const data = await download(url);
|
||||||
shell.echo(`<<< Download succeeded.`);
|
console.log(`<<< Download succeeded.`);
|
||||||
|
|
||||||
shell.echo('>>> Decompressing...');
|
console.log('>>> Decompressing...');
|
||||||
const files = await decompress(data, downloads, {
|
const files = await decompress(data, downloads, {
|
||||||
plugins: [unzip(), untargz(), untarbz2()],
|
plugins: [unzip(), untargz(), untarbz2()],
|
||||||
});
|
});
|
||||||
if (files.length === 0) {
|
if (files.length === 0) {
|
||||||
shell.echo('Error ocurred while decompressing the archive.');
|
console.log('Error ocurred while decompressing the archive.');
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
const fileIndex = files.findIndex((f) => f.path.startsWith(filePrefix));
|
const fileIndex = files.findIndex((f) => f.path.startsWith(filePrefix));
|
||||||
if (fileIndex === -1) {
|
if (fileIndex === -1) {
|
||||||
shell.echo(
|
console.log(
|
||||||
`The downloaded artifact does not contain any file with prefix ${filePrefix}.`
|
`The downloaded artifact does not contain any file with prefix ${filePrefix}.`
|
||||||
);
|
);
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
shell.echo('<<< Decompressing succeeded.');
|
console.log('<<< Decompressing succeeded.');
|
||||||
|
|
||||||
if (
|
fs.renameSync(path.join(downloads, files[fileIndex].path), targetFile);
|
||||||
shell.mv('-f', path.join(downloads, files[fileIndex].path), targetFile)
|
|
||||||
.code !== 0
|
|
||||||
) {
|
|
||||||
shell.echo(`Could not move file to target path: ${targetFile}`);
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
if (!fs.existsSync(targetFile)) {
|
if (!fs.existsSync(targetFile)) {
|
||||||
shell.echo(`Could not find file: ${targetFile}`);
|
console.log(`Could not find file: ${targetFile}`);
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
shell.echo(`Done: ${targetFile}`);
|
console.log(`Done: ${targetFile}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,6 +72,7 @@ exports.downloadUnzipFile = async (
|
|||||||
* @param targetDir {string} Directory into which to decompress the archive
|
* @param targetDir {string} Directory into which to decompress the archive
|
||||||
* @param targetFile {string} Path to the main file expected after decompressing
|
* @param targetFile {string} Path to the main file expected after decompressing
|
||||||
* @param force {boolean} Whether to download even if the target file exists
|
* @param force {boolean} Whether to download even if the target file exists
|
||||||
|
* @param decompressOptions {import('decompress').DecompressOptions|undefined} [decompressOptions]
|
||||||
*/
|
*/
|
||||||
exports.downloadUnzipAll = async (
|
exports.downloadUnzipAll = async (
|
||||||
url,
|
url,
|
||||||
@@ -95,21 +82,16 @@ exports.downloadUnzipAll = async (
|
|||||||
decompressOptions = undefined
|
decompressOptions = undefined
|
||||||
) => {
|
) => {
|
||||||
if (fs.existsSync(targetFile) && !force) {
|
if (fs.existsSync(targetFile) && !force) {
|
||||||
shell.echo(`Skipping download because file already exists: ${targetFile}`);
|
console.log(`Skipping download because file already exists: ${targetFile}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!fs.existsSync(targetDir)) {
|
fs.mkdirSync(targetDir, { recursive: true });
|
||||||
if (shell.mkdir('-p', targetDir).code !== 0) {
|
|
||||||
shell.echo('Could not create new directory.');
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
shell.echo(`>>> Downloading from '${url}'...`);
|
console.log(`>>> Downloading from '${url}'...`);
|
||||||
const data = await download(url);
|
const data = await download(url);
|
||||||
shell.echo(`<<< Download succeeded.`);
|
console.log(`<<< Download succeeded.`);
|
||||||
|
|
||||||
shell.echo('>>> Decompressing...');
|
console.log('>>> Decompressing...');
|
||||||
let options = {
|
let options = {
|
||||||
plugins: [unzip(), untargz(), untarbz2()],
|
plugins: [unzip(), untargz(), untarbz2()],
|
||||||
};
|
};
|
||||||
@@ -118,14 +100,27 @@ exports.downloadUnzipAll = async (
|
|||||||
}
|
}
|
||||||
const files = await decompress(data, targetDir, options);
|
const files = await decompress(data, targetDir, options);
|
||||||
if (files.length === 0) {
|
if (files.length === 0) {
|
||||||
shell.echo('Error ocurred while decompressing the archive.');
|
console.log('Error ocurred while decompressing the archive.');
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
shell.echo('<<< Decompressing succeeded.');
|
console.log('<<< Decompressing succeeded.');
|
||||||
|
|
||||||
if (!fs.existsSync(targetFile)) {
|
if (!fs.existsSync(targetFile)) {
|
||||||
shell.echo(`Could not find file: ${targetFile}`);
|
console.log(`Could not find file: ${targetFile}`);
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
shell.echo(`Done: ${targetFile}`);
|
console.log(`Done: ${targetFile}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} url
|
||||||
|
* @returns {Promise<import('node:buffer').Buffer>}
|
||||||
|
*/
|
||||||
|
async function download(url) {
|
||||||
|
const { default: download } = await import('@xhmikosr/downloader');
|
||||||
|
/** @type {import('node:buffer').Buffer} */
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
const data = await download(url);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,82 +1,88 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
const os = require('node:os');
|
||||||
|
const path = require('node:path');
|
||||||
|
const decompress = require('decompress');
|
||||||
|
const unzip = require('decompress-unzip');
|
||||||
|
const { mkdirSync, promises: fs, rmSync, existsSync } = require('node:fs');
|
||||||
|
const { exec } = require('./utils');
|
||||||
|
const { glob } = require('glob');
|
||||||
|
const { SemVer, gte, valid: validSemVer, eq } = require('semver');
|
||||||
|
// Use a node-protoc fork until apple arm32 is supported
|
||||||
|
// https://github.com/YePpHa/node-protoc/pull/10
|
||||||
|
const protoc = path.dirname(require('@pingghost/protoc/protoc'));
|
||||||
|
|
||||||
const os = require('os');
|
const { owner, repo, commitish } = (() => {
|
||||||
const path = require('path');
|
const pkg = require(path.join(__dirname, '..', 'package.json'));
|
||||||
const glob = require('glob');
|
if (!pkg) {
|
||||||
const { v4 } = require('uuid');
|
console.log(`Could not parse the 'package.json'.`);
|
||||||
const shell = require('shelljs');
|
process.exit(1);
|
||||||
const protoc = path.dirname(require('protoc/protoc'));
|
|
||||||
shell.env.PATH = `${shell.env.PATH}${path.delimiter}${protoc}`;
|
|
||||||
shell.env.PATH = `${shell.env.PATH}${path.delimiter}${path.join(__dirname, '..', 'node_modules', '.bin')}`;
|
|
||||||
|
|
||||||
const repository = path.join(os.tmpdir(), `${v4()}-arduino-cli`);
|
|
||||||
if (shell.mkdir('-p', repository).code !== 0) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { owner, repo, commitish } = (() => {
|
const defaultVersion = {
|
||||||
const pkg = require(path.join(__dirname, '..', 'package.json'));
|
owner: 'arduino',
|
||||||
if (!pkg) {
|
repo: 'arduino-cli',
|
||||||
shell.echo(`Could not parse the 'package.json'.`);
|
commitish: undefined,
|
||||||
shell.exit(1);
|
};
|
||||||
}
|
const { arduino } = pkg;
|
||||||
|
if (!arduino) {
|
||||||
const { arduino } = pkg;
|
return defaultVersion;
|
||||||
if (!arduino) {
|
|
||||||
return { owner: 'arduino', repo: 'arduino-cli' };
|
|
||||||
}
|
|
||||||
|
|
||||||
const { cli } = arduino;
|
|
||||||
if (!cli) {
|
|
||||||
return { owner: 'arduino', repo: 'arduino-cli' };
|
|
||||||
}
|
|
||||||
|
|
||||||
const { version } = cli;
|
|
||||||
if (!version) {
|
|
||||||
return { owner: 'arduino', repo: 'arduino-cli' };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof version === 'string') {
|
|
||||||
return { owner: 'arduino', repo: 'arduino-cli' };
|
|
||||||
}
|
|
||||||
|
|
||||||
// We assume an object with `owner`, `repo`, commitish?` properties.
|
|
||||||
const { owner, repo, commitish } = version;
|
|
||||||
if (!owner) {
|
|
||||||
shell.echo(`Could not retrieve 'owner' from ${JSON.stringify(version)}`);
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
if (!repo) {
|
|
||||||
shell.echo(`Could not retrieve 'repo' from ${JSON.stringify(version)}`);
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return { owner, repo, commitish };
|
|
||||||
})();
|
|
||||||
|
|
||||||
const url = `https://github.com/${owner}/${repo}.git`;
|
|
||||||
shell.echo(`>>> Cloning repository from '${url}'...`);
|
|
||||||
if (shell.exec(`git clone ${url} ${repository}`).code !== 0) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
}
|
||||||
shell.echo(`<<< Repository cloned.`);
|
|
||||||
|
|
||||||
const { platform } = process;
|
const cli = arduino['arduino-cli'];
|
||||||
const build = path.join(__dirname, '..', 'build');
|
if (!cli) {
|
||||||
const cli = path.join(build, `arduino-cli${platform === 'win32' ? '.exe' : ''}`);
|
return defaultVersion;
|
||||||
const versionJson = shell.exec(`${cli} version --format json`).trim();
|
|
||||||
if (!versionJson) {
|
|
||||||
shell.echo(`Could not retrieve the CLI version from ${cli}.`);
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
}
|
||||||
// As of today (28.01.2021), the `VersionString` can be one of the followings:
|
|
||||||
// - `nightly-YYYYMMDD` stands for the nightly build, we use the , the `commitish` from the `package.json` to check out the code.
|
const { version } = cli;
|
||||||
// - `0.0.0-git` for local builds, we use the `commitish` from the `package.json` to check out the code and generate the APIs.
|
if (!version) {
|
||||||
// - `git-snapshot` for local build executed via `task build`. We do not do this.
|
return defaultVersion;
|
||||||
// - rest, we assume it is a valid semver and has the corresponding tagged code, we use the tag to generate the APIs from the `proto` files.
|
}
|
||||||
/*
|
|
||||||
|
if (typeof version === 'string') {
|
||||||
|
return defaultVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We assume an object with `owner`, `repo`, commitish?` properties.
|
||||||
|
const { owner, repo, commitish } = version;
|
||||||
|
if (!owner) {
|
||||||
|
console.log(`Could not retrieve 'owner' from ${JSON.stringify(version)}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
if (!repo) {
|
||||||
|
console.log(`Could not retrieve 'repo' from ${JSON.stringify(version)}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return { owner, repo, commitish };
|
||||||
|
})();
|
||||||
|
|
||||||
|
const { platform } = process;
|
||||||
|
const resourcesFolder = path.join(
|
||||||
|
__dirname,
|
||||||
|
'..',
|
||||||
|
'src',
|
||||||
|
'node',
|
||||||
|
'resources'
|
||||||
|
);
|
||||||
|
const cli = path.join(
|
||||||
|
resourcesFolder,
|
||||||
|
`arduino-cli${platform === 'win32' ? '.exe' : ''}`
|
||||||
|
);
|
||||||
|
const versionJson = exec(cli, ['version', '--format', 'json'], {
|
||||||
|
logStdout: true,
|
||||||
|
}).trim();
|
||||||
|
if (!versionJson) {
|
||||||
|
console.log(`Could not retrieve the CLI version from ${cli}.`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
// As of today (28.01.2021), the `VersionString` can be one of the followings:
|
||||||
|
// - `nightly-YYYYMMDD` stands for the nightly build, we use the , the `commitish` from the `package.json` to check out the code.
|
||||||
|
// - `0.0.0-git` for local builds, we use the `commitish` from the `package.json` to check out the code and generate the APIs.
|
||||||
|
// - `git-snapshot` for local build executed via `task build`. We do not do this.
|
||||||
|
// - rest, we assume it is a valid semver and has the corresponding tagged code, we use the tag to generate the APIs from the `proto` files.
|
||||||
|
/*
|
||||||
{
|
{
|
||||||
"Application": "arduino-cli",
|
"Application": "arduino-cli",
|
||||||
"VersionString": "nightly-20210126",
|
"VersionString": "nightly-20210126",
|
||||||
@@ -84,73 +90,200 @@
|
|||||||
"Status": "alpha",
|
"Status": "alpha",
|
||||||
"Date": "2021-01-26T01:46:31Z"
|
"Date": "2021-01-26T01:46:31Z"
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
const versionObject = JSON.parse(versionJson);
|
const versionObject = JSON.parse(versionJson);
|
||||||
const version = versionObject.VersionString;
|
|
||||||
if (version && !version.startsWith('nightly-') && version !== '0.0.0-git' && version !== 'git-snapshot') {
|
async function globProtos(folder, pattern = '**/*.proto') {
|
||||||
shell.echo(`>>> Checking out tagged version: '${version}'...`);
|
let protos = [];
|
||||||
shell.exec(`git -C ${repository} fetch --all --tags`);
|
try {
|
||||||
if (shell.exec(`git -C ${repository} checkout tags/${version} -b ${version}`).code !== 0) {
|
const matches = await glob(pattern, { cwd: folder });
|
||||||
shell.exit(1);
|
protos = matches.map((filename) => path.join(folder, filename));
|
||||||
}
|
} catch (error) {
|
||||||
shell.echo(`<<< Checked out tagged version: '${commitish}'.`);
|
console.log(error.stack ?? error.message);
|
||||||
|
}
|
||||||
|
return protos;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getProtosFromRepo(
|
||||||
|
commitish = '',
|
||||||
|
version = '',
|
||||||
|
owner = 'arduino',
|
||||||
|
repo = 'arduino-cli'
|
||||||
|
) {
|
||||||
|
const repoFolder = await fs.mkdtemp(path.join(os.tmpdir(), 'arduino-cli-'));
|
||||||
|
|
||||||
|
const url = `https://github.com/${owner}/${repo}.git`;
|
||||||
|
console.log(`>>> Cloning repository from '${url}'...`);
|
||||||
|
exec('git', ['clone', url, repoFolder], { logStdout: true });
|
||||||
|
console.log(`<<< Repository cloned.`);
|
||||||
|
|
||||||
|
if (validSemVer(version)) {
|
||||||
|
let versionTag = version;
|
||||||
|
// https://github.com/arduino/arduino-cli/pull/2374
|
||||||
|
if (
|
||||||
|
gte(new SemVer(version, { loose: true }), new SemVer('0.35.0-rc.1'))
|
||||||
|
) {
|
||||||
|
versionTag = `v${version}`;
|
||||||
|
}
|
||||||
|
console.log(`>>> Checking out tagged version: '${versionTag}'...`);
|
||||||
|
exec('git', ['-C', repoFolder, 'fetch', '--all', '--tags'], {
|
||||||
|
logStdout: true,
|
||||||
|
});
|
||||||
|
exec(
|
||||||
|
'git',
|
||||||
|
['-C', repoFolder, 'checkout', `tags/${versionTag}`, '-b', versionTag],
|
||||||
|
{ logStdout: true }
|
||||||
|
);
|
||||||
|
console.log(`<<< Checked out tagged version: '${versionTag}'.`);
|
||||||
} else if (commitish) {
|
} else if (commitish) {
|
||||||
shell.echo(`>>> Checking out commitish from 'package.json': '${commitish}'...`);
|
console.log(`>>> Checking out commitish: '${commitish}'...`);
|
||||||
if (shell.exec(`git -C ${repository} checkout ${commitish}`).code !== 0) {
|
exec('git', ['-C', repoFolder, 'checkout', commitish], {
|
||||||
shell.exit(1);
|
logStdout: true,
|
||||||
}
|
});
|
||||||
shell.echo(`<<< Checked out commitish from 'package.json': '${commitish}'.`);
|
console.log(`<<< Checked out commitish: '${commitish}'.`);
|
||||||
} else if (versionObject.Commit) {
|
|
||||||
shell.echo(`>>> Checking out commitish from the CLI: '${versionObject.Commit}'...`);
|
|
||||||
if (shell.exec(`git -C ${repository} checkout ${versionObject.Commit}`).code !== 0) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
shell.echo(`<<< Checked out commitish from the CLI: '${versionObject.Commit}'.`);
|
|
||||||
} else {
|
} else {
|
||||||
shell.echo(`WARN: no 'git checkout'. Generating from the HEAD revision.`);
|
console.log(
|
||||||
|
`WARN: no 'git checkout'. Generating from the HEAD revision.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.echo('>>> Generating TS/JS API from:');
|
const rpcFolder = await fs.mkdtemp(
|
||||||
if (shell.exec(`git -C ${repository} rev-parse --abbrev-ref HEAD`).code !== 0) {
|
path.join(os.tmpdir(), 'arduino-cli-rpc')
|
||||||
shell.exit(1);
|
);
|
||||||
|
|
||||||
|
// Copy the the repository rpc folder so we can remove the repository
|
||||||
|
await fs.cp(path.join(repoFolder, 'rpc'), path.join(rpcFolder), {
|
||||||
|
recursive: true,
|
||||||
|
});
|
||||||
|
rmSync(repoFolder, { recursive: true, maxRetries: 5, force: true });
|
||||||
|
|
||||||
|
// Patch for https://github.com/arduino/arduino-cli/issues/2755
|
||||||
|
// Google proto files are removed from source since v1.1.0
|
||||||
|
if (!existsSync(path.join(rpcFolder, 'google'))) {
|
||||||
|
// Include packaged google proto files from v1.1.1
|
||||||
|
// See https://github.com/arduino/arduino-cli/pull/2761
|
||||||
|
console.log(`>>> Missing google proto files. Including from v1.1.1...`);
|
||||||
|
const v111ProtoFolder = await getProtosFromZip('1.1.1');
|
||||||
|
|
||||||
|
// Create an return a folder name google in rpcFolder
|
||||||
|
const googleFolder = path.join(rpcFolder, 'google');
|
||||||
|
await fs.cp(path.join(v111ProtoFolder, 'google'), googleFolder, {
|
||||||
|
recursive: true,
|
||||||
|
});
|
||||||
|
console.log(`<<< Included google proto files from v1.1.1.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rpc = path.join(repository, 'rpc');
|
return rpcFolder;
|
||||||
const out = path.join(__dirname, '..', 'src', 'node', 'cli-protocol');
|
}
|
||||||
shell.mkdir('-p', out);
|
|
||||||
|
|
||||||
const protos = await new Promise(resolve =>
|
async function getProtosFromZip(version) {
|
||||||
glob('**/*.proto', { cwd: rpc }, (error, matches) => {
|
if (!version) {
|
||||||
if (error) {
|
console.log(`Could not download proto files: CLI version not provided.`);
|
||||||
shell.echo(error.stack);
|
process.exit(1);
|
||||||
resolve([]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
resolve(matches.map(filename => path.join(rpc, filename)));
|
|
||||||
}));
|
|
||||||
if (!protos || protos.length === 0) {
|
|
||||||
shell.echo(`Could not find any .proto files under ${rpc}.`);
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
}
|
||||||
|
console.log(`>>> Downloading proto files from zip for ${version}.`);
|
||||||
|
|
||||||
|
const url = `https://downloads.arduino.cc/arduino-cli/arduino-cli_${version}_proto.zip`;
|
||||||
|
const protos = await fs.mkdtemp(
|
||||||
|
path.join(os.tmpdir(), 'arduino-cli-proto')
|
||||||
|
);
|
||||||
|
|
||||||
|
const { default: download } = await import('@xhmikosr/downloader');
|
||||||
|
/** @type {import('node:buffer').Buffer} */
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
const data = await download(url);
|
||||||
|
|
||||||
|
await decompress(data, protos, {
|
||||||
|
plugins: [unzip()],
|
||||||
|
filter: (file) => file.path.endsWith('.proto'),
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`<<< Finished downloading and extracting proto files for ${version}.`
|
||||||
|
);
|
||||||
|
|
||||||
|
return protos;
|
||||||
|
}
|
||||||
|
|
||||||
|
let protosFolder;
|
||||||
|
|
||||||
|
if (commitish) {
|
||||||
|
protosFolder = await getProtosFromRepo(commitish, undefined, owner, repo);
|
||||||
|
} else if (
|
||||||
|
versionObject.VersionString &&
|
||||||
|
validSemVer(versionObject.VersionString)
|
||||||
|
) {
|
||||||
|
const version = versionObject.VersionString;
|
||||||
|
// v1.1.0 does not contains google proto files in zip
|
||||||
|
// See https://github.com/arduino/arduino-cli/issues/2755
|
||||||
|
const isV110 = eq(new SemVer(version, { loose: true }), '1.1.0');
|
||||||
|
protosFolder = isV110
|
||||||
|
? await getProtosFromRepo(undefined, version)
|
||||||
|
: await getProtosFromZip(version);
|
||||||
|
} else if (versionObject.Commit) {
|
||||||
|
protosFolder = await getProtosFromRepo(versionObject.Commit);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!protosFolder) {
|
||||||
|
console.log(`Could not get proto files: missing commitish or version.`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const protos = await globProtos(protosFolder);
|
||||||
|
|
||||||
|
if (!protos || protos.length === 0) {
|
||||||
|
rmSync(protosFolder, { recursive: true, maxRetries: 5, force: true });
|
||||||
|
console.log(`Could not find any .proto files under ${protosFolder}.`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('>>> Generating TS/JS API from:');
|
||||||
|
|
||||||
|
const out = path.join(__dirname, '..', 'src', 'node', 'cli-protocol');
|
||||||
|
// Must wipe the gen output folder. Otherwise, dangling service implementation remain in IDE2 code,
|
||||||
|
// although it has been removed from the proto file.
|
||||||
|
// For example, https://github.com/arduino/arduino-cli/commit/50a8bf5c3e61d5b661ccfcd6a055e82eeb510859.
|
||||||
|
// rmSync(out, { recursive: true, maxRetries: 5, force: true });
|
||||||
|
mkdirSync(out, { recursive: true });
|
||||||
|
|
||||||
|
try {
|
||||||
// Generate JS code from the `.proto` files.
|
// Generate JS code from the `.proto` files.
|
||||||
if (shell.exec(`grpc_tools_node_protoc \
|
exec(
|
||||||
--js_out=import_style=commonjs,binary:${out} \
|
'grpc_tools_node_protoc',
|
||||||
--grpc_out=generate_package_definition:${out} \
|
[
|
||||||
-I ${rpc} \
|
`--js_out=import_style=commonjs,binary:${out}`,
|
||||||
${protos.join(' ')}`).code !== 0) {
|
`--grpc_out=generate_package_definition:${out}`,
|
||||||
shell.exit(1);
|
'-I',
|
||||||
}
|
protosFolder,
|
||||||
|
...protos,
|
||||||
|
],
|
||||||
|
{ logStdout: true }
|
||||||
|
);
|
||||||
|
|
||||||
// Generate the `.d.ts` files for JS.
|
// Generate the `.d.ts` files for JS.
|
||||||
if (shell.exec(`protoc \
|
exec(
|
||||||
--plugin=protoc-gen-ts=${path.resolve(__dirname, '..', 'node_modules', '.bin', `protoc-gen-ts${platform === 'win32' ? '.cmd' : ''}`)} \
|
path.join(protoc, `protoc${platform === 'win32' ? '.exe' : ''}`),
|
||||||
--ts_out=generate_package_definition:${out} \
|
[
|
||||||
-I ${rpc} \
|
`--plugin=protoc-gen-ts=${path.resolve(
|
||||||
${protos.join(' ')}`).code !== 0) {
|
__dirname,
|
||||||
shell.exit(1);
|
'..',
|
||||||
}
|
'node_modules',
|
||||||
|
'.bin',
|
||||||
shell.echo('<<< Generation was successful.');
|
`protoc-gen-ts${platform === 'win32' ? '.cmd' : ''}`
|
||||||
|
)}`,
|
||||||
|
`--ts_out=generate_package_definition:${out}`,
|
||||||
|
'-I',
|
||||||
|
protosFolder,
|
||||||
|
...protos,
|
||||||
|
],
|
||||||
|
{ logStdout: true }
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
} finally {
|
||||||
|
rmSync(protosFolder, { recursive: true, maxRetries: 5, force: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('<<< Generation was successful.');
|
||||||
})();
|
})();
|
||||||
|
|||||||
143
arduino-ide-extension/scripts/utils.js
Normal file
143
arduino-ide-extension/scripts/utils.js
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
// @ts-check
|
||||||
|
|
||||||
|
const exec = (
|
||||||
|
/** @type {string} */ command,
|
||||||
|
/** @type {readonly string[]} */ args,
|
||||||
|
/** @type {Partial<import('node:child_process').ExecFileSyncOptionsWithStringEncoding> & { logStdout?: boolean }|undefined} */ options = undefined
|
||||||
|
) => {
|
||||||
|
try {
|
||||||
|
const stdout = require('node:child_process').execFileSync(command, args, {
|
||||||
|
encoding: 'utf8',
|
||||||
|
...(options ?? {}),
|
||||||
|
});
|
||||||
|
if (options?.logStdout) {
|
||||||
|
console.log(stdout.trim());
|
||||||
|
}
|
||||||
|
return stdout;
|
||||||
|
} catch (err) {
|
||||||
|
console.log(
|
||||||
|
`Failed to execute ${command} with args: ${JSON.stringify(args)}`
|
||||||
|
);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
exports.exec = exec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones something from GitHub and builds it with [`Task`](https://taskfile.dev/).
|
||||||
|
*
|
||||||
|
* @param version {object} the version object.
|
||||||
|
* @param destinationPath {string} the absolute path of the output binary. For example, `C:\\folder\\arduino-cli.exe` or `/path/to/arduino-language-server`
|
||||||
|
* @param taskName {string} for the CLI logging . Can be `'CLI'` or `'language-server'`, etc.
|
||||||
|
*/
|
||||||
|
exports.taskBuildFromGit = (version, destinationPath, taskName) => {
|
||||||
|
return buildFromGit('task', version, destinationPath, taskName);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones something from GitHub and builds it with `Golang`.
|
||||||
|
*
|
||||||
|
* @param version {object} the version object.
|
||||||
|
* @param destinationPath {string} the absolute path of the output binary. For example, `C:\\folder\\arduino-cli.exe` or `/path/to/arduino-language-server`
|
||||||
|
* @param taskName {string} for the CLI logging . Can be `'CLI'` or `'language-server'`, etc.
|
||||||
|
*/
|
||||||
|
exports.goBuildFromGit = (version, destinationPath, taskName) => {
|
||||||
|
return buildFromGit('go', version, destinationPath, taskName);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `command` must be either `'go'` or `'task'`.
|
||||||
|
* @param {string} command
|
||||||
|
* @param {{ owner: any; repo: any; commitish: any; }} version
|
||||||
|
* @param {string} destinationPath
|
||||||
|
* @param {string} taskName
|
||||||
|
*/
|
||||||
|
function buildFromGit(command, version, destinationPath, taskName) {
|
||||||
|
const fs = require('node:fs');
|
||||||
|
const path = require('node:path');
|
||||||
|
const temp = require('temp');
|
||||||
|
|
||||||
|
// We assume an object with `owner`, `repo`, commitish?` properties.
|
||||||
|
if (typeof version !== 'object') {
|
||||||
|
console.log(
|
||||||
|
`Expected a \`{ owner, repo, commitish }\` object. Got <${version}> instead.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const { owner, repo, commitish } = version;
|
||||||
|
if (!owner) {
|
||||||
|
console.log(`Could not retrieve 'owner' from ${JSON.stringify(version)}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
if (!repo) {
|
||||||
|
console.log(`Could not retrieve 'repo' from ${JSON.stringify(version)}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
const url = `https://github.com/${owner}/${repo}.git`;
|
||||||
|
console.log(
|
||||||
|
`Building ${taskName} from ${url}. Commitish: ${
|
||||||
|
commitish ? commitish : 'HEAD'
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fs.existsSync(destinationPath)) {
|
||||||
|
console.log(
|
||||||
|
`Skipping the ${taskName} build because it already exists: ${destinationPath}`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const resourcesFolder = path.join(
|
||||||
|
__dirname,
|
||||||
|
'..',
|
||||||
|
'src',
|
||||||
|
'node',
|
||||||
|
'resources'
|
||||||
|
);
|
||||||
|
fs.mkdirSync(resourcesFolder, { recursive: true });
|
||||||
|
|
||||||
|
const tempRepoPath = temp.mkdirSync();
|
||||||
|
console.log(`>>> Cloning ${taskName} source to ${tempRepoPath}...`);
|
||||||
|
exec('git', ['clone', url, tempRepoPath], { logStdout: true });
|
||||||
|
console.log(`<<< Cloned ${taskName} repo.`);
|
||||||
|
|
||||||
|
if (commitish) {
|
||||||
|
console.log(`>>> Checking out ${commitish}...`);
|
||||||
|
exec('git', ['-C', tempRepoPath, 'checkout', commitish], {
|
||||||
|
logStdout: true,
|
||||||
|
});
|
||||||
|
console.log(`<<< Checked out ${commitish}.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
exec('git', ['-C', tempRepoPath, 'rev-parse', '--short', 'HEAD'], {
|
||||||
|
logStdout: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`>>> Building the ${taskName}...`);
|
||||||
|
exec(command, ['build'], {
|
||||||
|
cwd: tempRepoPath,
|
||||||
|
encoding: 'utf8',
|
||||||
|
logStdout: true,
|
||||||
|
});
|
||||||
|
console.log(`<<< Done ${taskName} build.`);
|
||||||
|
|
||||||
|
const binName = path.basename(destinationPath);
|
||||||
|
if (!fs.existsSync(path.join(tempRepoPath, binName))) {
|
||||||
|
console.log(
|
||||||
|
`Could not find the ${taskName} at ${path.join(tempRepoPath, binName)}.`
|
||||||
|
);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const binPath = path.join(tempRepoPath, binName);
|
||||||
|
console.log(
|
||||||
|
`>>> Copying ${taskName} from ${binPath} to ${destinationPath}...`
|
||||||
|
);
|
||||||
|
fs.copyFileSync(binPath, destinationPath);
|
||||||
|
console.log(`<<< Copied the ${taskName}.`);
|
||||||
|
|
||||||
|
console.log(`<<< Verifying ${taskName}...`);
|
||||||
|
if (!fs.existsSync(destinationPath)) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
console.log(`>>> Verified ${taskName}.`);
|
||||||
|
}
|
||||||
16
arduino-ide-extension/src/browser/app-service.ts
Normal file
16
arduino-ide-extension/src/browser/app-service.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import type { Disposable } from '@theia/core/lib/common/disposable';
|
||||||
|
import type { AppInfo } from '../electron-common/electron-arduino';
|
||||||
|
import type { StartupTasks } from '../electron-common/startup-task';
|
||||||
|
import type { Sketch } from './contributions/contribution';
|
||||||
|
|
||||||
|
export type { AppInfo };
|
||||||
|
|
||||||
|
export const AppService = Symbol('AppService');
|
||||||
|
export interface AppService {
|
||||||
|
quit(): void;
|
||||||
|
info(): Promise<AppInfo>;
|
||||||
|
registerStartupTasksHandler(
|
||||||
|
handler: (tasks: StartupTasks) => void
|
||||||
|
): Disposable;
|
||||||
|
scheduleDeletion(sketch: Sketch): void; // TODO: find a better place
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { Command } from '@theia/core/lib/common/command';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated all these commands should go under contributions and have their command, menu, keybinding, and toolbar contributions.
|
|
||||||
*/
|
|
||||||
export namespace ArduinoCommands {
|
|
||||||
export const TOGGLE_COMPILE_FOR_DEBUG: Command = {
|
|
||||||
id: 'arduino-toggle-compile-for-debug',
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unlike `OPEN_SKETCH`, it opens all files from a sketch folder. (ino, cpp, etc...)
|
|
||||||
*/
|
|
||||||
export const OPEN_SKETCH_FILES: Command = {
|
|
||||||
id: 'arduino-open-sketch-files',
|
|
||||||
};
|
|
||||||
|
|
||||||
export const OPEN_BOARDS_DIALOG: Command = {
|
|
||||||
id: 'arduino-open-boards-dialog',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,78 +1,47 @@
|
|||||||
import { inject, injectable, postConstruct } from 'inversify';
|
|
||||||
import * as React from 'react';
|
|
||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
|
||||||
import {
|
|
||||||
BoardsService,
|
|
||||||
SketchesService,
|
|
||||||
ExecutableService,
|
|
||||||
Sketch,
|
|
||||||
LibraryService,
|
|
||||||
} from '../common/protocol';
|
|
||||||
import { Mutex } from 'async-mutex';
|
|
||||||
import {
|
|
||||||
MAIN_MENU_BAR,
|
|
||||||
MenuContribution,
|
|
||||||
MenuModelRegistry,
|
|
||||||
ILogger,
|
|
||||||
DisposableCollection,
|
|
||||||
} from '@theia/core';
|
|
||||||
import {
|
|
||||||
FrontendApplication,
|
|
||||||
FrontendApplicationContribution,
|
|
||||||
LocalStorageService,
|
|
||||||
StatusBar,
|
|
||||||
StatusBarAlignment,
|
|
||||||
} from '@theia/core/lib/browser';
|
|
||||||
import { nls } from '@theia/core/lib/common';
|
|
||||||
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
|
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
|
||||||
import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
|
import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
|
||||||
import { CommonMenus } from '@theia/core/lib/browser/common-frontend-contribution';
|
import { CommonMenus } from '@theia/core/lib/browser/common-frontend-contribution';
|
||||||
|
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution';
|
||||||
|
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
||||||
import {
|
import {
|
||||||
TabBarToolbarContribution,
|
TabBarToolbarContribution,
|
||||||
TabBarToolbarRegistry,
|
TabBarToolbarRegistry,
|
||||||
} from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
} from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
||||||
|
import {
|
||||||
|
ColorTheme,
|
||||||
|
CssStyleCollector,
|
||||||
|
StylingParticipant,
|
||||||
|
} from '@theia/core/lib/browser/styling-service';
|
||||||
import {
|
import {
|
||||||
CommandContribution,
|
CommandContribution,
|
||||||
CommandRegistry,
|
CommandRegistry,
|
||||||
} from '@theia/core/lib/common/command';
|
} from '@theia/core/lib/common/command';
|
||||||
import { MessageService } from '@theia/core/lib/common/message-service';
|
|
||||||
import URI from '@theia/core/lib/common/uri';
|
|
||||||
import {
|
import {
|
||||||
EditorMainMenu,
|
MAIN_MENU_BAR,
|
||||||
EditorManager,
|
MenuContribution,
|
||||||
EditorOpenerOptions,
|
MenuModelRegistry,
|
||||||
} from '@theia/editor/lib/browser';
|
} from '@theia/core/lib/common/menu';
|
||||||
import { ProblemContribution } from '@theia/markers/lib/browser/problem/problem-contribution';
|
import { MessageService } from '@theia/core/lib/common/message-service';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { isHighContrast } from '@theia/core/lib/common/theme';
|
||||||
|
import { ElectronWindowPreferences } from '@theia/core/lib/electron-browser/window/electron-window-preferences';
|
||||||
|
import {
|
||||||
|
inject,
|
||||||
|
injectable,
|
||||||
|
postConstruct,
|
||||||
|
} from '@theia/core/shared/inversify';
|
||||||
|
import React from '@theia/core/shared/react';
|
||||||
|
import { EditorCommands } from '@theia/editor/lib/browser/editor-command';
|
||||||
|
import { EditorMainMenu } from '@theia/editor/lib/browser/editor-menu';
|
||||||
import { MonacoMenus } from '@theia/monaco/lib/browser/monaco-menu';
|
import { MonacoMenus } from '@theia/monaco/lib/browser/monaco-menu';
|
||||||
import { FileNavigatorContribution } from '@theia/navigator/lib/browser/navigator-contribution';
|
import { FileNavigatorCommands } from '@theia/navigator/lib/browser/navigator-contribution';
|
||||||
import { OutlineViewContribution } from '@theia/outline-view/lib/browser/outline-view-contribution';
|
|
||||||
import { OutputContribution } from '@theia/output/lib/browser/output-contribution';
|
|
||||||
import { ScmContribution } from '@theia/scm/lib/browser/scm-contribution';
|
|
||||||
import { SearchInWorkspaceFrontendContribution } from '@theia/search-in-workspace/lib/browser/search-in-workspace-frontend-contribution';
|
|
||||||
import { TerminalMenus } from '@theia/terminal/lib/browser/terminal-frontend-contribution';
|
import { TerminalMenus } from '@theia/terminal/lib/browser/terminal-frontend-contribution';
|
||||||
import { HostedPluginSupport } from '@theia/plugin-ext/lib/hosted/browser/hosted-plugin';
|
|
||||||
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
||||||
import { FileChangeType } from '@theia/filesystem/lib/browser';
|
|
||||||
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
|
||||||
import { ConfigService } from '../common/protocol/config-service';
|
|
||||||
import { ArduinoCommands } from './arduino-commands';
|
|
||||||
import { BoardsConfig } from './boards/boards-config';
|
|
||||||
import { BoardsConfigDialog } from './boards/boards-config-dialog';
|
|
||||||
import { BoardsServiceProvider } from './boards/boards-service-provider';
|
import { BoardsServiceProvider } from './boards/boards-service-provider';
|
||||||
import { BoardsToolBarItem } from './boards/boards-toolbar-item';
|
import { BoardsToolBarItem } from './boards/boards-toolbar-item';
|
||||||
import { EditorMode } from './editor-mode';
|
|
||||||
import { ArduinoMenus } from './menu/arduino-menus';
|
import { ArduinoMenus } from './menu/arduino-menus';
|
||||||
import { MonitorViewContribution } from './serial/monitor/monitor-view-contribution';
|
import { MonitorViewContribution } from './serial/monitor/monitor-view-contribution';
|
||||||
|
import { SerialPlotterContribution } from './serial/plotter/plotter-frontend-contribution';
|
||||||
import { ArduinoToolbar } from './toolbar/arduino-toolbar';
|
import { ArduinoToolbar } from './toolbar/arduino-toolbar';
|
||||||
import { ArduinoPreferences } from './arduino-preferences';
|
|
||||||
import { SketchesServiceClientImpl } from '../common/protocol/sketches-service-client-impl';
|
|
||||||
import { SaveAsSketch } from './contributions/save-as-sketch';
|
|
||||||
import { SketchbookWidgetContribution } from './widgets/sketchbook/sketchbook-widget-contribution';
|
|
||||||
import { IDEUpdaterDialog } from './dialogs/ide-updater/ide-updater-dialog';
|
|
||||||
import { IDEUpdater } from '../common/protocol/ide-updater';
|
|
||||||
|
|
||||||
const INIT_LIBS_AND_PACKAGES = 'initializedLibsAndPackages';
|
|
||||||
export const SKIP_IDE_VERSION = 'skipIDEVersion';
|
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class ArduinoFrontendContribution
|
export class ArduinoFrontendContribution
|
||||||
@@ -81,118 +50,26 @@ export class ArduinoFrontendContribution
|
|||||||
TabBarToolbarContribution,
|
TabBarToolbarContribution,
|
||||||
CommandContribution,
|
CommandContribution,
|
||||||
MenuContribution,
|
MenuContribution,
|
||||||
ColorContribution {
|
ColorContribution,
|
||||||
@inject(ILogger)
|
StylingParticipant
|
||||||
protected logger: ILogger;
|
{
|
||||||
|
|
||||||
@inject(MessageService)
|
@inject(MessageService)
|
||||||
protected readonly messageService: MessageService;
|
private readonly messageService: MessageService;
|
||||||
|
|
||||||
@inject(BoardsService)
|
|
||||||
protected readonly boardsService: BoardsService;
|
|
||||||
|
|
||||||
@inject(LibraryService)
|
|
||||||
protected readonly libraryService: LibraryService;
|
|
||||||
|
|
||||||
@inject(BoardsServiceProvider)
|
@inject(BoardsServiceProvider)
|
||||||
protected readonly boardsServiceClientImpl: BoardsServiceProvider;
|
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
|
||||||
@inject(EditorManager)
|
|
||||||
protected readonly editorManager: EditorManager;
|
|
||||||
|
|
||||||
@inject(FileService)
|
|
||||||
protected readonly fileService: FileService;
|
|
||||||
|
|
||||||
@inject(SketchesService)
|
|
||||||
protected readonly sketchService: SketchesService;
|
|
||||||
|
|
||||||
@inject(BoardsConfigDialog)
|
|
||||||
protected readonly boardsConfigDialog: BoardsConfigDialog;
|
|
||||||
|
|
||||||
@inject(CommandRegistry)
|
@inject(CommandRegistry)
|
||||||
protected readonly commandRegistry: CommandRegistry;
|
private readonly commandRegistry: CommandRegistry;
|
||||||
|
|
||||||
@inject(StatusBar)
|
@inject(ElectronWindowPreferences)
|
||||||
protected readonly statusBar: StatusBar;
|
private readonly electronWindowPreferences: ElectronWindowPreferences;
|
||||||
|
|
||||||
@inject(FileNavigatorContribution)
|
@inject(FrontendApplicationStateService)
|
||||||
protected readonly fileNavigatorContributions: FileNavigatorContribution;
|
private readonly appStateService: FrontendApplicationStateService;
|
||||||
|
|
||||||
@inject(OutputContribution)
|
|
||||||
protected readonly outputContribution: OutputContribution;
|
|
||||||
|
|
||||||
@inject(OutlineViewContribution)
|
|
||||||
protected readonly outlineContribution: OutlineViewContribution;
|
|
||||||
|
|
||||||
@inject(ProblemContribution)
|
|
||||||
protected readonly problemContribution: ProblemContribution;
|
|
||||||
|
|
||||||
@inject(ScmContribution)
|
|
||||||
protected readonly scmContribution: ScmContribution;
|
|
||||||
|
|
||||||
@inject(SearchInWorkspaceFrontendContribution)
|
|
||||||
protected readonly siwContribution: SearchInWorkspaceFrontendContribution;
|
|
||||||
|
|
||||||
@inject(SketchbookWidgetContribution)
|
|
||||||
protected readonly sketchbookWidgetContribution: SketchbookWidgetContribution;
|
|
||||||
|
|
||||||
@inject(EditorMode)
|
|
||||||
protected readonly editorMode: EditorMode;
|
|
||||||
|
|
||||||
@inject(ConfigService)
|
|
||||||
protected readonly configService: ConfigService;
|
|
||||||
|
|
||||||
@inject(HostedPluginSupport)
|
|
||||||
protected hostedPluginSupport: HostedPluginSupport;
|
|
||||||
|
|
||||||
@inject(ExecutableService)
|
|
||||||
protected executableService: ExecutableService;
|
|
||||||
|
|
||||||
@inject(ArduinoPreferences)
|
|
||||||
protected readonly arduinoPreferences: ArduinoPreferences;
|
|
||||||
|
|
||||||
@inject(SketchesServiceClientImpl)
|
|
||||||
protected readonly sketchServiceClient: SketchesServiceClientImpl;
|
|
||||||
|
|
||||||
protected readonly appStateService: FrontendApplicationStateService;
|
|
||||||
|
|
||||||
@inject(LocalStorageService)
|
|
||||||
protected readonly localStorageService: LocalStorageService;
|
|
||||||
|
|
||||||
@inject(IDEUpdater)
|
|
||||||
protected readonly updater: IDEUpdater;
|
|
||||||
|
|
||||||
@inject(IDEUpdaterDialog)
|
|
||||||
protected readonly updaterDialog: IDEUpdaterDialog;
|
|
||||||
|
|
||||||
protected invalidConfigPopup:
|
|
||||||
| Promise<void | 'No' | 'Yes' | undefined>
|
|
||||||
| undefined;
|
|
||||||
protected toDisposeOnStop = new DisposableCollection();
|
|
||||||
|
|
||||||
@postConstruct()
|
@postConstruct()
|
||||||
protected async init(): Promise<void> {
|
protected init(): void {
|
||||||
const isFirstStartup = !(await this.localStorageService.getData(
|
|
||||||
INIT_LIBS_AND_PACKAGES
|
|
||||||
));
|
|
||||||
if (isFirstStartup) {
|
|
||||||
await this.localStorageService.setData(INIT_LIBS_AND_PACKAGES, true);
|
|
||||||
const avrPackage = await this.boardsService.getBoardPackage({
|
|
||||||
id: 'arduino:avr',
|
|
||||||
});
|
|
||||||
const builtInLibrary = (
|
|
||||||
await this.libraryService.search({
|
|
||||||
query: 'Arduino_BuiltIn',
|
|
||||||
})
|
|
||||||
)[0];
|
|
||||||
|
|
||||||
!!avrPackage && (await this.boardsService.install({ item: avrPackage }));
|
|
||||||
!!builtInLibrary &&
|
|
||||||
(await this.libraryService.install({
|
|
||||||
item: builtInLibrary,
|
|
||||||
installDependencies: true,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
if (!window.navigator.onLine) {
|
if (!window.navigator.onLine) {
|
||||||
// tslint:disable-next-line:max-line-length
|
// tslint:disable-next-line:max-line-length
|
||||||
this.messageService.warn(
|
this.messageService.warn(
|
||||||
@@ -202,232 +79,27 @@ export class ArduinoFrontendContribution
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const updateStatusBar = ({
|
|
||||||
selectedBoard,
|
|
||||||
selectedPort,
|
|
||||||
}: BoardsConfig.Config) => {
|
|
||||||
this.statusBar.setElement('arduino-selected-board', {
|
|
||||||
alignment: StatusBarAlignment.RIGHT,
|
|
||||||
text: selectedBoard
|
|
||||||
? `$(microchip) ${selectedBoard.name}`
|
|
||||||
: `$(close) ${nls.localize(
|
|
||||||
'arduino/common/noBoardSelected',
|
|
||||||
'No board selected'
|
|
||||||
)}`,
|
|
||||||
className: 'arduino-selected-board',
|
|
||||||
});
|
|
||||||
if (selectedBoard) {
|
|
||||||
this.statusBar.setElement('arduino-selected-port', {
|
|
||||||
alignment: StatusBarAlignment.RIGHT,
|
|
||||||
text: selectedPort
|
|
||||||
? nls.localize(
|
|
||||||
'arduino/common/selectedOn',
|
|
||||||
'on {0}',
|
|
||||||
selectedPort.address
|
|
||||||
)
|
|
||||||
: nls.localize('arduino/common/notConnected', '[not connected]'),
|
|
||||||
className: 'arduino-selected-port',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this.boardsServiceClientImpl.onBoardsConfigChanged(updateStatusBar);
|
|
||||||
updateStatusBar(this.boardsServiceClientImpl.boardsConfig);
|
|
||||||
this.appStateService.reachedState('ready').then(async () => {
|
|
||||||
const sketch = await this.sketchServiceClient.currentSketch();
|
|
||||||
if (sketch && !(await this.sketchService.isTemp(sketch))) {
|
|
||||||
this.toDisposeOnStop.push(this.fileService.watch(new URI(sketch.uri)));
|
|
||||||
this.toDisposeOnStop.push(
|
|
||||||
this.fileService.onDidFilesChange(async (event) => {
|
|
||||||
for (const { type, resource } of event.changes) {
|
|
||||||
if (
|
|
||||||
type === FileChangeType.ADDED &&
|
|
||||||
resource.parent.toString() === sketch.uri
|
|
||||||
) {
|
|
||||||
const reloadedSketch = await this.sketchService.loadSketch(
|
|
||||||
sketch.uri
|
|
||||||
);
|
|
||||||
if (Sketch.isInSketch(resource, reloadedSketch)) {
|
|
||||||
this.ensureOpened(resource.toString(), true, {
|
|
||||||
mode: 'open',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async onStart(app: FrontendApplication): Promise<void> {
|
onStart(): void {
|
||||||
// Initialize all `pro-mode` widgets. This is a NOOP if in normal mode.
|
this.electronWindowPreferences.onPreferenceChanged((event) => {
|
||||||
for (const viewContribution of [
|
|
||||||
this.fileNavigatorContributions,
|
|
||||||
this.outputContribution,
|
|
||||||
this.outlineContribution,
|
|
||||||
this.problemContribution,
|
|
||||||
this.scmContribution,
|
|
||||||
this.siwContribution,
|
|
||||||
this.sketchbookWidgetContribution,
|
|
||||||
] as Array<FrontendApplicationContribution>) {
|
|
||||||
if (viewContribution.initializeLayout) {
|
|
||||||
viewContribution.initializeLayout(app);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updater
|
|
||||||
.init(
|
|
||||||
this.arduinoPreferences.get('arduino.ide.updateChannel'),
|
|
||||||
this.arduinoPreferences.get('arduino.ide.updateBaseUrl')
|
|
||||||
)
|
|
||||||
.then(() => this.updater.checkForUpdates(true))
|
|
||||||
.then(async (updateInfo) => {
|
|
||||||
if (!updateInfo) return;
|
|
||||||
const versionToSkip = await this.localStorageService.getData<string>(
|
|
||||||
SKIP_IDE_VERSION
|
|
||||||
);
|
|
||||||
if (versionToSkip === updateInfo.version) return;
|
|
||||||
this.updaterDialog.open(updateInfo);
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
this.messageService.error(
|
|
||||||
nls.localize(
|
|
||||||
'arduino/ide-updater/errorCheckingForUpdates',
|
|
||||||
'Error while checking for Arduino IDE updates.\n{0}',
|
|
||||||
e.message
|
|
||||||
)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
const start = async ({ selectedBoard }: BoardsConfig.Config) => {
|
|
||||||
if (selectedBoard) {
|
|
||||||
const { name, fqbn } = selectedBoard;
|
|
||||||
if (fqbn) {
|
|
||||||
this.startLanguageServer(fqbn, name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this.boardsServiceClientImpl.onBoardsConfigChanged(start);
|
|
||||||
this.arduinoPreferences.onPreferenceChanged((event) => {
|
|
||||||
if (event.newValue !== event.oldValue) {
|
if (event.newValue !== event.oldValue) {
|
||||||
switch (event.preferenceName) {
|
switch (event.preferenceName) {
|
||||||
case 'arduino.language.log':
|
case 'window.zoomLevel':
|
||||||
start(this.boardsServiceClientImpl.boardsConfig);
|
|
||||||
break;
|
|
||||||
case 'arduino.window.zoomLevel':
|
|
||||||
if (typeof event.newValue === 'number') {
|
if (typeof event.newValue === 'number') {
|
||||||
const webContents = remote.getCurrentWebContents();
|
window.electronTheiaCore.setZoomLevel(event.newValue || 0);
|
||||||
webContents.setZoomLevel(event.newValue || 0);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'arduino.ide.updateChannel':
|
|
||||||
case 'arduino.ide.updateBaseUrl':
|
|
||||||
this.updater.init(
|
|
||||||
this.arduinoPreferences.get('arduino.ide.updateChannel'),
|
|
||||||
this.arduinoPreferences.get('arduino.ide.updateBaseUrl')
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.arduinoPreferences.ready.then(() => {
|
this.appStateService.reachedState('ready').then(() =>
|
||||||
const webContents = remote.getCurrentWebContents();
|
this.electronWindowPreferences.ready.then(() => {
|
||||||
const zoomLevel = this.arduinoPreferences.get('arduino.window.zoomLevel');
|
const zoomLevel =
|
||||||
webContents.setZoomLevel(zoomLevel);
|
this.electronWindowPreferences.get('window.zoomLevel');
|
||||||
});
|
window.electronTheiaCore.setZoomLevel(zoomLevel);
|
||||||
|
})
|
||||||
app.shell.leftPanelHandler.removeBottomMenu('settings-menu');
|
);
|
||||||
}
|
|
||||||
|
|
||||||
onStop(): void {
|
|
||||||
this.toDisposeOnStop.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected languageServerFqbn?: string;
|
|
||||||
protected languageServerStartMutex = new Mutex();
|
|
||||||
protected async startLanguageServer(
|
|
||||||
fqbn: string,
|
|
||||||
name: string | undefined
|
|
||||||
): Promise<void> {
|
|
||||||
const release = await this.languageServerStartMutex.acquire();
|
|
||||||
try {
|
|
||||||
await this.hostedPluginSupport.didStart;
|
|
||||||
const details = await this.boardsService.getBoardDetails({ fqbn });
|
|
||||||
if (!details) {
|
|
||||||
// Core is not installed for the selected board.
|
|
||||||
console.info(
|
|
||||||
`Could not start language server for ${fqbn}. The core is not installed for the board.`
|
|
||||||
);
|
|
||||||
if (this.languageServerFqbn) {
|
|
||||||
try {
|
|
||||||
await this.commandRegistry.executeCommand(
|
|
||||||
'arduino.languageserver.stop'
|
|
||||||
);
|
|
||||||
console.info(
|
|
||||||
`Stopped language server process for ${this.languageServerFqbn}.`
|
|
||||||
);
|
|
||||||
this.languageServerFqbn = undefined;
|
|
||||||
} catch (e) {
|
|
||||||
console.error(
|
|
||||||
`Failed to start language server process for ${this.languageServerFqbn}`,
|
|
||||||
e
|
|
||||||
);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (fqbn === this.languageServerFqbn) {
|
|
||||||
// NOOP
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.logger.info(`Starting language server: ${fqbn}`);
|
|
||||||
const log = this.arduinoPreferences.get('arduino.language.log');
|
|
||||||
let currentSketchPath: string | undefined = undefined;
|
|
||||||
if (log) {
|
|
||||||
const currentSketch = await this.sketchServiceClient.currentSketch();
|
|
||||||
if (currentSketch) {
|
|
||||||
currentSketchPath = await this.fileService.fsPath(
|
|
||||||
new URI(currentSketch.uri)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const { clangdUri, lsUri } = await this.executableService.list();
|
|
||||||
const [clangdPath, lsPath] = await Promise.all([
|
|
||||||
this.fileService.fsPath(new URI(clangdUri)),
|
|
||||||
this.fileService.fsPath(new URI(lsUri)),
|
|
||||||
]);
|
|
||||||
|
|
||||||
const config = await this.configService.getConfiguration();
|
|
||||||
|
|
||||||
this.languageServerFqbn = await Promise.race([
|
|
||||||
new Promise<undefined>((_, reject) =>
|
|
||||||
setTimeout(
|
|
||||||
() => reject(new Error(`Timeout after ${20_000} ms.`)),
|
|
||||||
20_000
|
|
||||||
)
|
|
||||||
),
|
|
||||||
this.commandRegistry.executeCommand<string>(
|
|
||||||
'arduino.languageserver.start',
|
|
||||||
{
|
|
||||||
lsPath,
|
|
||||||
cliDaemonAddr: `localhost:${config.daemon.port}`, // TODO: verify if this port is coming from the BE
|
|
||||||
clangdPath,
|
|
||||||
log: currentSketchPath ? currentSketchPath : log,
|
|
||||||
cliDaemonInstance: '1',
|
|
||||||
board: {
|
|
||||||
fqbn,
|
|
||||||
name: name ? `"${name}"` : undefined,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
} catch (e) {
|
|
||||||
console.log(`Failed to start language server for ${fqbn}`, e);
|
|
||||||
this.languageServerFqbn = undefined;
|
|
||||||
} finally {
|
|
||||||
release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registerToolbarItems(registry: TabBarToolbarRegistry): void {
|
registerToolbarItems(registry: TabBarToolbarRegistry): void {
|
||||||
@@ -437,13 +109,21 @@ export class ArduinoFrontendContribution
|
|||||||
<BoardsToolBarItem
|
<BoardsToolBarItem
|
||||||
key="boardsToolbarItem"
|
key="boardsToolbarItem"
|
||||||
commands={this.commandRegistry}
|
commands={this.commandRegistry}
|
||||||
boardsServiceClient={this.boardsServiceClientImpl}
|
boardsServiceProvider={this.boardsServiceProvider}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
isVisible: (widget) =>
|
isVisible: (widget) =>
|
||||||
ArduinoToolbar.is(widget) && widget.side === 'left',
|
ArduinoToolbar.is(widget) && widget.side === 'left',
|
||||||
priority: 7,
|
priority: 7,
|
||||||
});
|
});
|
||||||
|
registry.registerItem({
|
||||||
|
id: 'toggle-serial-plotter',
|
||||||
|
command: SerialPlotterContribution.Commands.OPEN_TOOLBAR.id,
|
||||||
|
tooltip: nls.localize(
|
||||||
|
'arduino/serial/openSerialPlotter',
|
||||||
|
'Serial Plotter'
|
||||||
|
),
|
||||||
|
});
|
||||||
registry.registerItem({
|
registry.registerItem({
|
||||||
id: 'toggle-serial-monitor',
|
id: 'toggle-serial-monitor',
|
||||||
command: MonitorViewContribution.TOGGLE_SERIAL_MONITOR_TOOLBAR,
|
command: MonitorViewContribution.TOGGLE_SERIAL_MONITOR_TOOLBAR,
|
||||||
@@ -452,26 +132,20 @@ export class ArduinoFrontendContribution
|
|||||||
}
|
}
|
||||||
|
|
||||||
registerCommands(registry: CommandRegistry): void {
|
registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(ArduinoCommands.TOGGLE_COMPILE_FOR_DEBUG, {
|
for (const command of [
|
||||||
execute: () => this.editorMode.toggleCompileForDebug(),
|
EditorCommands.SPLIT_EDITOR_DOWN,
|
||||||
isToggled: () => this.editorMode.compileForDebug,
|
EditorCommands.SPLIT_EDITOR_LEFT,
|
||||||
});
|
EditorCommands.SPLIT_EDITOR_RIGHT,
|
||||||
registry.registerCommand(ArduinoCommands.OPEN_SKETCH_FILES, {
|
EditorCommands.SPLIT_EDITOR_UP,
|
||||||
execute: async (uri: URI) => {
|
EditorCommands.SPLIT_EDITOR_VERTICAL,
|
||||||
this.openSketchFiles(uri);
|
EditorCommands.SPLIT_EDITOR_HORIZONTAL,
|
||||||
},
|
FileNavigatorCommands.REVEAL_IN_NAVIGATOR,
|
||||||
});
|
]) {
|
||||||
registry.registerCommand(ArduinoCommands.OPEN_BOARDS_DIALOG, {
|
registry.unregisterCommand(command);
|
||||||
execute: async (query?: string | undefined) => {
|
}
|
||||||
const boardsConfig = await this.boardsConfigDialog.open(query);
|
|
||||||
if (boardsConfig) {
|
|
||||||
this.boardsServiceClientImpl.boardsConfig = boardsConfig;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMenus(registry: MenuModelRegistry) {
|
registerMenus(registry: MenuModelRegistry): void {
|
||||||
const menuId = (menuPath: string[]): string => {
|
const menuId = (menuPath: string[]): string => {
|
||||||
const index = menuPath.length - 1;
|
const index = menuPath.length - 1;
|
||||||
const menuId = menuPath[index];
|
const menuId = menuPath[index];
|
||||||
@@ -490,143 +164,316 @@ export class ArduinoFrontendContribution
|
|||||||
ArduinoMenus.TOOLS,
|
ArduinoMenus.TOOLS,
|
||||||
nls.localize('arduino/menu/tools', 'Tools')
|
nls.localize('arduino/menu/tools', 'Tools')
|
||||||
);
|
);
|
||||||
registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, {
|
|
||||||
commandId: ArduinoCommands.TOGGLE_COMPILE_FOR_DEBUG.id,
|
|
||||||
label: nls.localize(
|
|
||||||
'arduino/debug/optimizeForDebugging',
|
|
||||||
'Optimize for Debugging'
|
|
||||||
),
|
|
||||||
order: '5',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async openSketchFiles(uri: URI): Promise<void> {
|
|
||||||
try {
|
|
||||||
const sketch = await this.sketchService.loadSketch(uri.toString());
|
|
||||||
const { mainFileUri, rootFolderFileUris } = sketch;
|
|
||||||
for (const uri of [mainFileUri, ...rootFolderFileUris]) {
|
|
||||||
await this.ensureOpened(uri);
|
|
||||||
}
|
|
||||||
if (mainFileUri.endsWith('.pde')) {
|
|
||||||
const message = nls.localize(
|
|
||||||
'arduino/common/oldFormat',
|
|
||||||
"The '{0}' still uses the old `.pde` format. Do you want to switch to the new `.ino` extension?",
|
|
||||||
sketch.name
|
|
||||||
);
|
|
||||||
const yes = nls.localize('vscode/extensionsUtils/yes', 'Yes');
|
|
||||||
this.messageService
|
|
||||||
.info(message, nls.localize('arduino/common/later', 'Later'), yes)
|
|
||||||
.then(async (answer) => {
|
|
||||||
if (answer === yes) {
|
|
||||||
this.commandRegistry.executeCommand(
|
|
||||||
SaveAsSketch.Commands.SAVE_AS_SKETCH.id,
|
|
||||||
{
|
|
||||||
execOnlyIfTemp: false,
|
|
||||||
openAfterMove: true,
|
|
||||||
wipeOriginal: false,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
const message = e instanceof Error ? e.message : JSON.stringify(e);
|
|
||||||
this.messageService.error(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async ensureOpened(
|
|
||||||
uri: string,
|
|
||||||
forceOpen = false,
|
|
||||||
options?: EditorOpenerOptions | undefined
|
|
||||||
): Promise<any> {
|
|
||||||
const widget = this.editorManager.all.find(
|
|
||||||
(widget) => widget.editor.uri.toString() === uri
|
|
||||||
);
|
|
||||||
if (!widget || forceOpen) {
|
|
||||||
return this.editorManager.open(new URI(uri), options);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registerColors(colors: ColorRegistry): void {
|
registerColors(colors: ColorRegistry): void {
|
||||||
colors.register(
|
colors.register(
|
||||||
{
|
{
|
||||||
id: 'arduino.branding.primary',
|
id: 'arduino.toolbar.button.background',
|
||||||
defaults: {
|
|
||||||
dark: 'statusBar.background',
|
|
||||||
light: 'statusBar.background',
|
|
||||||
},
|
|
||||||
description:
|
|
||||||
'The primary branding color, such as dialog titles, library, and board manager list labels.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'arduino.branding.secondary',
|
|
||||||
defaults: {
|
|
||||||
dark: 'statusBar.background',
|
|
||||||
light: 'statusBar.background',
|
|
||||||
},
|
|
||||||
description:
|
|
||||||
'Secondary branding color for list selections, dropdowns, and widget borders.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'arduino.foreground',
|
|
||||||
defaults: {
|
|
||||||
dark: 'editorWidget.background',
|
|
||||||
light: 'editorWidget.background',
|
|
||||||
hc: 'editorWidget.background',
|
|
||||||
},
|
|
||||||
description:
|
|
||||||
'Color of the Arduino IDE foreground which is used for dialogs, such as the Select Board dialog.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'arduino.toolbar.background',
|
|
||||||
defaults: {
|
defaults: {
|
||||||
dark: 'button.background',
|
dark: 'button.background',
|
||||||
light: 'button.background',
|
light: 'button.background',
|
||||||
hc: 'activityBar.inactiveForeground',
|
hcDark: 'activityBar.inactiveForeground',
|
||||||
|
hcLight: 'activityBar.inactiveForeground',
|
||||||
},
|
},
|
||||||
description:
|
description:
|
||||||
'Background color of the toolbar items. Such as Upload, Verify, etc.',
|
'Background color of the toolbar items. Such as Upload, Verify, etc.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'arduino.toolbar.hoverBackground',
|
id: 'arduino.toolbar.button.hoverBackground',
|
||||||
defaults: {
|
defaults: {
|
||||||
dark: 'button.hoverBackground',
|
dark: 'button.hoverBackground',
|
||||||
light: 'button.foreground',
|
light: 'button.hoverBackground',
|
||||||
hc: 'textLink.foreground',
|
hcDark: 'button.background',
|
||||||
|
hcLight: 'button.background',
|
||||||
},
|
},
|
||||||
description:
|
description:
|
||||||
'Background color of the toolbar items when hovering over them. Such as Upload, Verify, etc.',
|
'Background color of the toolbar items when hovering over them. Such as Upload, Verify, etc.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'arduino.toolbar.button.secondary.label',
|
||||||
|
defaults: {
|
||||||
|
dark: 'secondaryButton.foreground',
|
||||||
|
light: 'button.foreground',
|
||||||
|
hcDark: 'activityBar.inactiveForeground',
|
||||||
|
hcLight: 'activityBar.inactiveForeground',
|
||||||
|
},
|
||||||
|
description:
|
||||||
|
'Foreground color of the toolbar items. Such as Serial Monitor and Serial Plotter',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'arduino.toolbar.button.secondary.hoverBackground',
|
||||||
|
defaults: {
|
||||||
|
dark: 'secondaryButton.hoverBackground',
|
||||||
|
light: 'button.hoverBackground',
|
||||||
|
hcDark: 'textLink.foreground',
|
||||||
|
hcLight: 'textLink.foreground',
|
||||||
|
},
|
||||||
|
description:
|
||||||
|
'Background color of the toolbar items when hovering over them, such as "Serial Monitor" and "Serial Plotter"',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'arduino.toolbar.toggleBackground',
|
id: 'arduino.toolbar.toggleBackground',
|
||||||
defaults: {
|
defaults: {
|
||||||
dark: 'editor.selectionBackground',
|
dark: 'editor.selectionBackground',
|
||||||
light: 'editor.selectionBackground',
|
light: 'editor.selectionBackground',
|
||||||
hc: 'textPreformat.foreground',
|
hcDark: 'textPreformat.foreground',
|
||||||
|
hcLight: 'textPreformat.foreground',
|
||||||
},
|
},
|
||||||
description:
|
description:
|
||||||
'Toggle color of the toolbar items when they are currently toggled (the command is in progress)',
|
'Toggle color of the toolbar items when they are currently toggled (the command is in progress)',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'arduino.output.foreground',
|
id: 'arduino.toolbar.dropdown.border',
|
||||||
defaults: {
|
defaults: {
|
||||||
dark: 'editor.foreground',
|
dark: 'dropdown.border',
|
||||||
light: 'editor.foreground',
|
light: 'dropdown.border',
|
||||||
hc: 'editor.foreground',
|
hcDark: 'dropdown.border',
|
||||||
|
hcLight: 'dropdown.border',
|
||||||
},
|
},
|
||||||
description: 'Color of the text in the Output view.',
|
description: 'Border color of the Board Selector.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'arduino.output.background',
|
id: 'arduino.toolbar.dropdown.borderActive',
|
||||||
defaults: {
|
defaults: {
|
||||||
dark: 'editor.background',
|
dark: 'focusBorder',
|
||||||
light: 'editor.background',
|
light: 'focusBorder',
|
||||||
hc: 'editor.background',
|
hcDark: 'focusBorder',
|
||||||
|
hcLight: 'focusBorder',
|
||||||
},
|
},
|
||||||
description: 'Background color of the Output view.',
|
description: "Border color of the Board Selector when it's active",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'arduino.toolbar.dropdown.background',
|
||||||
|
defaults: {
|
||||||
|
dark: 'tab.unfocusedActiveBackground',
|
||||||
|
light: 'dropdown.background',
|
||||||
|
hcDark: 'dropdown.background',
|
||||||
|
hcLight: 'dropdown.background',
|
||||||
|
},
|
||||||
|
description: 'Background color of the Board Selector.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'arduino.toolbar.dropdown.label',
|
||||||
|
defaults: {
|
||||||
|
dark: 'dropdown.foreground',
|
||||||
|
light: 'dropdown.foreground',
|
||||||
|
hcDark: 'dropdown.foreground',
|
||||||
|
hcLight: 'dropdown.foreground',
|
||||||
|
},
|
||||||
|
description: 'Font color of the Board Selector.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'arduino.toolbar.dropdown.iconSelected',
|
||||||
|
defaults: {
|
||||||
|
dark: 'list.activeSelectionIconForeground',
|
||||||
|
light: 'list.activeSelectionIconForeground',
|
||||||
|
hcDark: 'list.activeSelectionIconForeground',
|
||||||
|
hcLight: 'list.activeSelectionIconForeground',
|
||||||
|
},
|
||||||
|
description:
|
||||||
|
'Color of the selected protocol icon in the Board Selector.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'arduino.toolbar.dropdown.option.backgroundHover',
|
||||||
|
defaults: {
|
||||||
|
dark: 'list.hoverBackground',
|
||||||
|
light: 'list.hoverBackground',
|
||||||
|
hcDark: 'list.hoverBackground',
|
||||||
|
hcLight: 'list.hoverBackground',
|
||||||
|
},
|
||||||
|
description: 'Background color on hover of the Board Selector options.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'arduino.toolbar.dropdown.option.backgroundSelected',
|
||||||
|
defaults: {
|
||||||
|
dark: 'list.activeSelectionBackground',
|
||||||
|
light: 'list.activeSelectionBackground',
|
||||||
|
hcDark: 'list.activeSelectionBackground',
|
||||||
|
hcLight: 'list.activeSelectionBackground',
|
||||||
|
},
|
||||||
|
description:
|
||||||
|
'Background color of the selected board in the Board Selector.',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerThemeStyle(theme: ColorTheme, collector: CssStyleCollector): void {
|
||||||
|
const warningForeground = theme.getColor('warningForeground');
|
||||||
|
const warningBackground = theme.getColor('warningBackground');
|
||||||
|
const focusBorder = theme.getColor('focusBorder');
|
||||||
|
const contrastBorder = theme.getColor('contrastBorder');
|
||||||
|
const notificationsBackground = theme.getColor('notifications.background');
|
||||||
|
const buttonBorder = theme.getColor('button.border');
|
||||||
|
const buttonBackground = theme.getColor('button.background') || 'none';
|
||||||
|
const dropdownBackground = theme.getColor('dropdown.background');
|
||||||
|
const arduinoToolbarButtonBackground = theme.getColor(
|
||||||
|
'arduino.toolbar.button.background'
|
||||||
|
);
|
||||||
|
if (isHighContrast(theme.type)) {
|
||||||
|
// toolbar items
|
||||||
|
collector.addRule(`
|
||||||
|
.p-TabBar-toolbar .item.arduino-tool-item.enabled:hover > div.toggle-serial-monitor,
|
||||||
|
.p-TabBar-toolbar .item.arduino-tool-item.enabled:hover > div.toggle-serial-plotter {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
if (contrastBorder) {
|
||||||
|
collector.addRule(`
|
||||||
|
.quick-input-widget {
|
||||||
|
outline: 1px solid ${contrastBorder};
|
||||||
|
outline-offset: -1px;
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
if (focusBorder) {
|
||||||
|
// customized react-select widget
|
||||||
|
collector.addRule(`
|
||||||
|
.arduino-select__option--is-selected {
|
||||||
|
outline: 1px solid ${focusBorder};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
collector.addRule(`
|
||||||
|
.arduino-select__option--is-focused {
|
||||||
|
outline: 1px dashed ${focusBorder};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
// boards selector dropdown
|
||||||
|
collector.addRule(`
|
||||||
|
#select-board-dialog .selectBoardContainer .list .item:hover {
|
||||||
|
outline: 1px dashed ${focusBorder};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
// button hover
|
||||||
|
collector.addRule(`
|
||||||
|
.theia-button:hover,
|
||||||
|
button.theia-button:hover {
|
||||||
|
outline: 1px dashed ${focusBorder};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
collector.addRule(`
|
||||||
|
.theia-button {
|
||||||
|
border: 1px solid ${focusBorder};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
collector.addRule(`
|
||||||
|
.component-list-item .header .installed-version:hover:before {
|
||||||
|
background-color: transparent;
|
||||||
|
outline: 1px dashed ${focusBorder};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
// tree node
|
||||||
|
collector.addRule(`
|
||||||
|
.theia-TreeNode:hover {
|
||||||
|
outline: 1px dashed ${focusBorder};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
collector.addRule(`
|
||||||
|
.quick-input-list .monaco-list-row.focused,
|
||||||
|
.theia-Tree .theia-TreeNode.theia-mod-selected {
|
||||||
|
outline: 1px dotted ${focusBorder};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
collector.addRule(`
|
||||||
|
div#select-board-dialog .selectBoardContainer .list .item.selected,
|
||||||
|
.theia-Tree:focus .theia-TreeNode.theia-mod-selected,
|
||||||
|
.theia-Tree .ReactVirtualized__List:focus .theia-TreeNode.theia-mod-selected {
|
||||||
|
outline: 1px solid ${focusBorder};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
// quick input
|
||||||
|
collector.addRule(`
|
||||||
|
.quick-input-list .monaco-list-row:hover {
|
||||||
|
outline: 1px dashed ${focusBorder};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
// editor tab-bar
|
||||||
|
collector.addRule(`
|
||||||
|
.p-TabBar.theia-app-centers .p-TabBar-tab.p-mod-closable > .p-TabBar-tabCloseIcon:hover {
|
||||||
|
outline: 1px dashed ${focusBorder};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
collector.addRule(`
|
||||||
|
#theia-main-content-panel .p-TabBar .p-TabBar-tab:hover {
|
||||||
|
outline: 1px dashed ${focusBorder};
|
||||||
|
outline-offset: -4px;
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
collector.addRule(`
|
||||||
|
#theia-main-content-panel .p-TabBar .p-TabBar-tab.p-mod-current {
|
||||||
|
outline: 1px solid ${focusBorder};
|
||||||
|
outline-offset: -4px;
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
// boards selector dropdown
|
||||||
|
collector.addRule(`
|
||||||
|
.arduino-boards-dropdown-item:hover {
|
||||||
|
outline: 1px dashed ${focusBorder};
|
||||||
|
outline-offset: -2px;
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
if (notificationsBackground) {
|
||||||
|
// notification
|
||||||
|
collector.addRule(`
|
||||||
|
.theia-notification-list-item:hover:not(:focus) {
|
||||||
|
background-color: ${notificationsBackground};
|
||||||
|
outline: 1px dashed ${focusBorder};
|
||||||
|
outline-offset: -2px;
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
if (arduinoToolbarButtonBackground) {
|
||||||
|
// toolbar item
|
||||||
|
collector.addRule(`
|
||||||
|
.item.arduino-tool-item.toggled .arduino-upload-sketch--toolbar,
|
||||||
|
.item.arduino-tool-item.toggled .arduino-verify-sketch--toolbar {
|
||||||
|
background-color: ${arduinoToolbarButtonBackground} !important;
|
||||||
|
outline: 1px solid ${focusBorder};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
collector.addRule(`
|
||||||
|
.p-TabBar-toolbar .item.arduino-tool-item.enabled:hover > div {
|
||||||
|
background: ${arduinoToolbarButtonBackground};
|
||||||
|
outline: 1px dashed ${focusBorder};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dropdownBackground) {
|
||||||
|
// boards selector dropdown
|
||||||
|
collector.addRule(`
|
||||||
|
.arduino-boards-dropdown-item:hover {
|
||||||
|
background: ${dropdownBackground};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
if (warningForeground && warningBackground) {
|
||||||
|
// <input> widget with inverted foreground and background colors
|
||||||
|
collector.addRule(`
|
||||||
|
.theia-input.warning:focus,
|
||||||
|
.theia-input.warning::placeholder,
|
||||||
|
.theia-input.warning {
|
||||||
|
color: ${warningBackground};
|
||||||
|
background-color: ${warningForeground};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
if (buttonBorder) {
|
||||||
|
collector.addRule(`
|
||||||
|
button.theia-button,
|
||||||
|
button.theia-button.secondary,
|
||||||
|
.component-list-item .theia-button.secondary.no-border,
|
||||||
|
.component-list-item .theia-button.secondary.no-border:hover {
|
||||||
|
border: 1px solid ${buttonBorder};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
collector.addRule(`
|
||||||
|
.component-list-item .header .installed-version:before {
|
||||||
|
color: ${buttonBackground};
|
||||||
|
border: 1px solid ${buttonBorder};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
import '../../src/browser/style/index.css';
|
import '../../src/browser/style/index.css';
|
||||||
import { ContainerModule } from 'inversify';
|
import { Container, ContainerModule } from '@theia/core/shared/inversify';
|
||||||
import { WidgetFactory } from '@theia/core/lib/browser/widget-manager';
|
import { WidgetFactory } from '@theia/core/lib/browser/widget-manager';
|
||||||
import { CommandContribution } from '@theia/core/lib/common/command';
|
import { CommandContribution } from '@theia/core/lib/common/command';
|
||||||
import { bindViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
|
import { bindViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
|
||||||
import {
|
import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
||||||
TabBarToolbarContribution,
|
|
||||||
TabBarToolbarFactory,
|
|
||||||
} from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
||||||
import { WebSocketConnectionProvider } from '@theia/core/lib/browser/messaging/ws-connection-provider';
|
import { WebSocketConnectionProvider } from '@theia/core/lib/browser/messaging/ws-connection-provider';
|
||||||
import {
|
import { FrontendApplication as TheiaFrontendApplication } from '@theia/core/lib/browser/frontend-application';
|
||||||
FrontendApplicationContribution,
|
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution';
|
||||||
FrontendApplication as TheiaFrontendApplication,
|
|
||||||
} from '@theia/core/lib/browser/frontend-application';
|
|
||||||
import { LibraryListWidget } from './library/library-list-widget';
|
import { LibraryListWidget } from './library/library-list-widget';
|
||||||
import { ArduinoFrontendContribution } from './arduino-frontend-contribution';
|
import { ArduinoFrontendContribution } from './arduino-frontend-contribution';
|
||||||
import {
|
import {
|
||||||
@@ -26,11 +21,14 @@ import {
|
|||||||
SketchesService,
|
SketchesService,
|
||||||
SketchesServicePath,
|
SketchesServicePath,
|
||||||
} from '../common/protocol/sketches-service';
|
} from '../common/protocol/sketches-service';
|
||||||
import { SketchesServiceClientImpl } from '../common/protocol/sketches-service-client-impl';
|
import { SketchesServiceClientImpl } from './sketches-service-client-impl';
|
||||||
import { CoreService, CoreServicePath } from '../common/protocol/core-service';
|
import { CoreService, CoreServicePath } from '../common/protocol/core-service';
|
||||||
import { BoardsListWidget } from './boards/boards-list-widget';
|
import { BoardsListWidget } from './boards/boards-list-widget';
|
||||||
import { BoardsListWidgetFrontendContribution } from './boards/boards-widget-frontend-contribution';
|
import { BoardsListWidgetFrontendContribution } from './boards/boards-widget-frontend-contribution';
|
||||||
import { BoardsServiceProvider } from './boards/boards-service-provider';
|
import {
|
||||||
|
BoardListDumper,
|
||||||
|
BoardsServiceProvider,
|
||||||
|
} from './boards/boards-service-provider';
|
||||||
import { WorkspaceService as TheiaWorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
|
import { WorkspaceService as TheiaWorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
|
||||||
import { WorkspaceService } from './theia/workspace/workspace-service';
|
import { WorkspaceService } from './theia/workspace/workspace-service';
|
||||||
import { OutlineViewContribution as TheiaOutlineViewContribution } from '@theia/outline-view/lib/browser/outline-view-contribution';
|
import { OutlineViewContribution as TheiaOutlineViewContribution } from '@theia/outline-view/lib/browser/outline-view-contribution';
|
||||||
@@ -42,73 +40,69 @@ import { FileNavigatorContribution as TheiaFileNavigatorContribution } from '@th
|
|||||||
import { KeymapsFrontendContribution } from './theia/keymaps/keymaps-frontend-contribution';
|
import { KeymapsFrontendContribution } from './theia/keymaps/keymaps-frontend-contribution';
|
||||||
import { KeymapsFrontendContribution as TheiaKeymapsFrontendContribution } from '@theia/keymaps/lib/browser/keymaps-frontend-contribution';
|
import { KeymapsFrontendContribution as TheiaKeymapsFrontendContribution } from '@theia/keymaps/lib/browser/keymaps-frontend-contribution';
|
||||||
import { ArduinoToolbarContribution } from './toolbar/arduino-toolbar-contribution';
|
import { ArduinoToolbarContribution } from './toolbar/arduino-toolbar-contribution';
|
||||||
import { EditorPreviewContribution as TheiaEditorPreviewContribution } from '@theia/editor-preview/lib/browser/editor-preview-contribution';
|
import { EditorContribution as TheiaEditorContribution } from '@theia/editor/lib/browser/editor-contribution';
|
||||||
import { EditorPreviewContribution } from './theia/editor/editor-contribution';
|
import { EditorContribution } from './theia/editor/editor-contribution';
|
||||||
import { MonacoStatusBarContribution as TheiaMonacoStatusBarContribution } from '@theia/monaco/lib/browser/monaco-status-bar-contribution';
|
import { MonacoStatusBarContribution as TheiaMonacoStatusBarContribution } from '@theia/monaco/lib/browser/monaco-status-bar-contribution';
|
||||||
import { MonacoStatusBarContribution } from './theia/monaco/monaco-status-bar-contribution';
|
import { MonacoStatusBarContribution } from './theia/monaco/monaco-status-bar-contribution';
|
||||||
import {
|
import {
|
||||||
ApplicationShell as TheiaApplicationShell,
|
ApplicationShell as TheiaApplicationShell,
|
||||||
ShellLayoutRestorer as TheiaShellLayoutRestorer,
|
ShellLayoutRestorer as TheiaShellLayoutRestorer,
|
||||||
CommonFrontendContribution as TheiaCommonFrontendContribution,
|
CommonFrontendContribution as TheiaCommonFrontendContribution,
|
||||||
KeybindingRegistry as TheiaKeybindingRegistry,
|
DockPanelRenderer as TheiaDockPanelRenderer,
|
||||||
TabBarRendererFactory,
|
TabBarRendererFactory,
|
||||||
ContextMenuRenderer,
|
ContextMenuRenderer,
|
||||||
createTreeContainer,
|
|
||||||
TreeWidget,
|
|
||||||
} from '@theia/core/lib/browser';
|
} from '@theia/core/lib/browser';
|
||||||
import { MenuContribution } from '@theia/core/lib/common/menu';
|
import { MenuContribution } from '@theia/core/lib/common/menu';
|
||||||
import { ApplicationShell } from './theia/core/application-shell';
|
import {
|
||||||
|
ApplicationShell,
|
||||||
|
DockPanelRenderer,
|
||||||
|
} from './theia/core/application-shell';
|
||||||
import { FrontendApplication } from './theia/core/frontend-application';
|
import { FrontendApplication } from './theia/core/frontend-application';
|
||||||
import {
|
import {
|
||||||
BoardsConfigDialog,
|
BoardsConfigDialog,
|
||||||
BoardsConfigDialogProps,
|
BoardsConfigDialogProps,
|
||||||
} from './boards/boards-config-dialog';
|
} from './boards/boards-config-dialog';
|
||||||
import { BoardsConfigDialogWidget } from './boards/boards-config-dialog-widget';
|
|
||||||
import { ScmContribution as TheiaScmContribution } from '@theia/scm/lib/browser/scm-contribution';
|
import { ScmContribution as TheiaScmContribution } from '@theia/scm/lib/browser/scm-contribution';
|
||||||
import { ScmContribution } from './theia/scm/scm-contribution';
|
import { ScmContribution } from './theia/scm/scm-contribution';
|
||||||
import { SearchInWorkspaceFrontendContribution as TheiaSearchInWorkspaceFrontendContribution } from '@theia/search-in-workspace/lib/browser/search-in-workspace-frontend-contribution';
|
import { SearchInWorkspaceFrontendContribution as TheiaSearchInWorkspaceFrontendContribution } from '@theia/search-in-workspace/lib/browser/search-in-workspace-frontend-contribution';
|
||||||
import { SearchInWorkspaceFrontendContribution } from './theia/search-in-workspace/search-in-workspace-frontend-contribution';
|
import { SearchInWorkspaceFrontendContribution } from './theia/search-in-workspace/search-in-workspace-frontend-contribution';
|
||||||
import { LibraryListWidgetFrontendContribution } from './library/library-widget-frontend-contribution';
|
import { LibraryListWidgetFrontendContribution } from './library/library-widget-frontend-contribution';
|
||||||
import { SerialServiceClientImpl } from './serial/serial-service-client-impl';
|
|
||||||
import {
|
|
||||||
SerialServicePath,
|
|
||||||
SerialService,
|
|
||||||
SerialServiceClient,
|
|
||||||
} from '../common/protocol/serial-service';
|
|
||||||
import {
|
import {
|
||||||
ConfigService,
|
ConfigService,
|
||||||
ConfigServicePath,
|
ConfigServicePath,
|
||||||
} from '../common/protocol/config-service';
|
} from '../common/protocol/config-service';
|
||||||
import { MonitorWidget } from './serial/monitor/monitor-widget';
|
import { MonitorWidget } from './serial/monitor/monitor-widget';
|
||||||
import { MonitorViewContribution } from './serial/monitor/monitor-view-contribution';
|
import { MonitorViewContribution } from './serial/monitor/monitor-view-contribution';
|
||||||
import { SerialConnectionManager } from './serial/serial-connection-manager';
|
|
||||||
import { SerialModel } from './serial/serial-model';
|
|
||||||
import { TabBarDecoratorService as TheiaTabBarDecoratorService } from '@theia/core/lib/browser/shell/tab-bar-decorator';
|
import { TabBarDecoratorService as TheiaTabBarDecoratorService } from '@theia/core/lib/browser/shell/tab-bar-decorator';
|
||||||
import { TabBarDecoratorService } from './theia/core/tab-bar-decorator';
|
import { TabBarDecoratorService } from './theia/core/tab-bar-decorator';
|
||||||
import { ProblemManager as TheiaProblemManager } from '@theia/markers/lib/browser';
|
import { ProblemManager as TheiaProblemManager } from '@theia/markers/lib/browser';
|
||||||
import { ProblemManager } from './theia/markers/problem-manager';
|
import { ProblemManager } from './theia/markers/problem-manager';
|
||||||
import { BoardsAutoInstaller } from './boards/boards-auto-installer';
|
import { BoardsAutoInstaller } from './boards/boards-auto-installer';
|
||||||
import { ShellLayoutRestorer } from './theia/core/shell-layout-restorer';
|
import { ShellLayoutRestorer } from './theia/core/shell-layout-restorer';
|
||||||
import { EditorMode } from './editor-mode';
|
import {
|
||||||
import { ListItemRenderer } from './widgets/component-list/list-item-renderer';
|
ArduinoComponentContextMenuRenderer,
|
||||||
|
ListItemRenderer,
|
||||||
|
} from './widgets/component-list/list-item-renderer';
|
||||||
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
|
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
|
||||||
import { MonacoThemingService } from '@theia/monaco/lib/browser/monaco-theming-service';
|
|
||||||
import {
|
import {
|
||||||
ArduinoDaemonPath,
|
ArduinoDaemonPath,
|
||||||
ArduinoDaemon,
|
ArduinoDaemon,
|
||||||
} from '../common/protocol/arduino-daemon';
|
} from '../common/protocol/arduino-daemon';
|
||||||
import { EditorCommandContribution as TheiaEditorCommandContribution } from '@theia/editor/lib/browser';
|
|
||||||
import {
|
import {
|
||||||
FrontendConnectionStatusService,
|
FrontendConnectionStatusService,
|
||||||
ApplicationConnectionStatusContribution,
|
ApplicationConnectionStatusContribution,
|
||||||
|
DaemonPort,
|
||||||
|
IsOnline,
|
||||||
} from './theia/core/connection-status-service';
|
} from './theia/core/connection-status-service';
|
||||||
import {
|
import {
|
||||||
FrontendConnectionStatusService as TheiaFrontendConnectionStatusService,
|
FrontendConnectionStatusService as TheiaFrontendConnectionStatusService,
|
||||||
ApplicationConnectionStatusContribution as TheiaApplicationConnectionStatusContribution,
|
ApplicationConnectionStatusContribution as TheiaApplicationConnectionStatusContribution,
|
||||||
} from '@theia/core/lib/browser/connection-status-service';
|
} from '@theia/core/lib/browser/connection-status-service';
|
||||||
import { BoardsDataMenuUpdater } from './boards/boards-data-menu-updater';
|
import { BoardsDataMenuUpdater } from './contributions/boards-data-menu-updater';
|
||||||
import { BoardsDataStore } from './boards/boards-data-store';
|
import { BoardsDataStore } from './boards/boards-data-store';
|
||||||
import { ILogger } from '@theia/core';
|
import { ILogger } from '@theia/core/lib/common/logger';
|
||||||
|
import { bindContributionProvider } from '@theia/core/lib/common/contribution-provider';
|
||||||
import {
|
import {
|
||||||
FileSystemExt,
|
FileSystemExt,
|
||||||
FileSystemExtPath,
|
FileSystemExtPath,
|
||||||
@@ -128,7 +122,10 @@ import { OpenSketch } from './contributions/open-sketch';
|
|||||||
import { Close } from './contributions/close';
|
import { Close } from './contributions/close';
|
||||||
import { SaveAsSketch } from './contributions/save-as-sketch';
|
import { SaveAsSketch } from './contributions/save-as-sketch';
|
||||||
import { SaveSketch } from './contributions/save-sketch';
|
import { SaveSketch } from './contributions/save-sketch';
|
||||||
import { VerifySketch } from './contributions/verify-sketch';
|
import {
|
||||||
|
CompileSummaryProvider,
|
||||||
|
VerifySketch,
|
||||||
|
} from './contributions/verify-sketch';
|
||||||
import { UploadSketch } from './contributions/upload-sketch';
|
import { UploadSketch } from './contributions/upload-sketch';
|
||||||
import { CommonFrontendContribution } from './theia/core/common-frontend-contribution';
|
import { CommonFrontendContribution } from './theia/core/common-frontend-contribution';
|
||||||
import { EditContributions } from './contributions/edit-contributions';
|
import { EditContributions } from './contributions/edit-contributions';
|
||||||
@@ -137,16 +134,12 @@ import { PreferencesContribution as TheiaPreferencesContribution } from '@theia/
|
|||||||
import { PreferencesContribution } from './theia/preferences/preferences-contribution';
|
import { PreferencesContribution } from './theia/preferences/preferences-contribution';
|
||||||
import { QuitApp } from './contributions/quit-app';
|
import { QuitApp } from './contributions/quit-app';
|
||||||
import { SketchControl } from './contributions/sketch-control';
|
import { SketchControl } from './contributions/sketch-control';
|
||||||
import { Settings } from './contributions/settings';
|
import { OpenSettings } from './contributions/open-settings';
|
||||||
import { KeybindingRegistry } from './theia/core/keybindings';
|
|
||||||
import { WorkspaceCommandContribution } from './theia/workspace/workspace-commands';
|
import { WorkspaceCommandContribution } from './theia/workspace/workspace-commands';
|
||||||
import { WorkspaceDeleteHandler as TheiaWorkspaceDeleteHandler } from '@theia/workspace/lib/browser/workspace-delete-handler';
|
import { WorkspaceDeleteHandler as TheiaWorkspaceDeleteHandler } from '@theia/workspace/lib/browser/workspace-delete-handler';
|
||||||
import { WorkspaceDeleteHandler } from './theia/workspace/workspace-delete-handler';
|
import { WorkspaceDeleteHandler } from './theia/workspace/workspace-delete-handler';
|
||||||
import { TabBarToolbar } from './theia/core/tab-bar-toolbar';
|
|
||||||
import { EditorWidgetFactory as TheiaEditorWidgetFactory } from '@theia/editor/lib/browser/editor-widget-factory';
|
import { EditorWidgetFactory as TheiaEditorWidgetFactory } from '@theia/editor/lib/browser/editor-widget-factory';
|
||||||
import { EditorWidgetFactory } from './theia/editor/editor-widget-factory';
|
import { EditorWidgetFactory } from './theia/editor/editor-widget-factory';
|
||||||
import { OutputWidget as TheiaOutputWidget } from '@theia/output/lib/browser/output-widget';
|
|
||||||
import { OutputWidget } from './theia/output/output-widget';
|
|
||||||
import { BurnBootloader } from './contributions/burn-bootloader';
|
import { BurnBootloader } from './contributions/burn-bootloader';
|
||||||
import {
|
import {
|
||||||
ExamplesServicePath,
|
ExamplesServicePath,
|
||||||
@@ -160,13 +153,20 @@ import {
|
|||||||
OutputChannelRegistryMainImpl as TheiaOutputChannelRegistryMainImpl,
|
OutputChannelRegistryMainImpl as TheiaOutputChannelRegistryMainImpl,
|
||||||
OutputChannelRegistryMainImpl,
|
OutputChannelRegistryMainImpl,
|
||||||
} from './theia/plugin-ext/output-channel-registry-main';
|
} from './theia/plugin-ext/output-channel-registry-main';
|
||||||
import { ExecutableService, ExecutableServicePath } from '../common/protocol';
|
import {
|
||||||
|
ExecutableService,
|
||||||
|
ExecutableServicePath,
|
||||||
|
MonitorManagerProxy,
|
||||||
|
MonitorManagerProxyClient,
|
||||||
|
MonitorManagerProxyFactory,
|
||||||
|
MonitorManagerProxyPath,
|
||||||
|
} from '../common/protocol';
|
||||||
import { MonacoTextModelService as TheiaMonacoTextModelService } from '@theia/monaco/lib/browser/monaco-text-model-service';
|
import { MonacoTextModelService as TheiaMonacoTextModelService } from '@theia/monaco/lib/browser/monaco-text-model-service';
|
||||||
import { MonacoTextModelService } from './theia/monaco/monaco-text-model-service';
|
import { MonacoTextModelService } from './theia/monaco/monaco-text-model-service';
|
||||||
import { ResponseServiceImpl } from './response-service-impl';
|
import { ResponseServiceImpl } from './response-service-impl';
|
||||||
import {
|
import {
|
||||||
ResponseService,
|
ResponseService,
|
||||||
ResponseServiceArduino,
|
ResponseServiceClient,
|
||||||
ResponseServicePath,
|
ResponseServicePath,
|
||||||
} from '../common/protocol/response-service';
|
} from '../common/protocol/response-service';
|
||||||
import { NotificationCenter } from './notification-center';
|
import { NotificationCenter } from './notification-center';
|
||||||
@@ -177,12 +177,9 @@ import {
|
|||||||
import { About } from './contributions/about';
|
import { About } from './contributions/about';
|
||||||
import { IconThemeService } from '@theia/core/lib/browser/icon-theme-service';
|
import { IconThemeService } from '@theia/core/lib/browser/icon-theme-service';
|
||||||
import { TabBarRenderer } from './theia/core/tab-bars';
|
import { TabBarRenderer } from './theia/core/tab-bars';
|
||||||
import { EditorCommandContribution } from './theia/editor/editor-command';
|
|
||||||
import { NavigatorTabBarDecorator as TheiaNavigatorTabBarDecorator } from '@theia/navigator/lib/browser/navigator-tab-bar-decorator';
|
import { NavigatorTabBarDecorator as TheiaNavigatorTabBarDecorator } from '@theia/navigator/lib/browser/navigator-tab-bar-decorator';
|
||||||
import { NavigatorTabBarDecorator } from './theia/navigator/navigator-tab-bar-decorator';
|
import { NavigatorTabBarDecorator } from './theia/navigator/navigator-tab-bar-decorator';
|
||||||
import { Debug } from './contributions/debug';
|
import { Debug, DebugDisabledStatusMessageSource } from './contributions/debug';
|
||||||
import { DebugSessionManager } from './theia/debug/debug-session-manager';
|
|
||||||
import { DebugSessionManager as TheiaDebugSessionManager } from '@theia/debug/lib/browser/debug-session-manager';
|
|
||||||
import { Sketchbook } from './contributions/sketchbook';
|
import { Sketchbook } from './contributions/sketchbook';
|
||||||
import { DebugFrontendApplicationContribution } from './theia/debug/debug-frontend-application-contribution';
|
import { DebugFrontendApplicationContribution } from './theia/debug/debug-frontend-application-contribution';
|
||||||
import { DebugFrontendApplicationContribution as TheiaDebugFrontendApplicationContribution } from '@theia/debug/lib/browser/debug-frontend-application-contribution';
|
import { DebugFrontendApplicationContribution as TheiaDebugFrontendApplicationContribution } from '@theia/debug/lib/browser/debug-frontend-application-contribution';
|
||||||
@@ -205,15 +202,13 @@ import { WorkspaceVariableContribution as TheiaWorkspaceVariableContribution } f
|
|||||||
import { WorkspaceVariableContribution } from './theia/workspace/workspace-variable-contribution';
|
import { WorkspaceVariableContribution } from './theia/workspace/workspace-variable-contribution';
|
||||||
import { DebugConfigurationManager } from './theia/debug/debug-configuration-manager';
|
import { DebugConfigurationManager } from './theia/debug/debug-configuration-manager';
|
||||||
import { DebugConfigurationManager as TheiaDebugConfigurationManager } from '@theia/debug/lib/browser/debug-configuration-manager';
|
import { DebugConfigurationManager as TheiaDebugConfigurationManager } from '@theia/debug/lib/browser/debug-configuration-manager';
|
||||||
import { SearchInWorkspaceWidget as TheiaSearchInWorkspaceWidget } from '@theia/search-in-workspace/lib/browser/search-in-workspace-widget';
|
|
||||||
import { SearchInWorkspaceWidget } from './theia/search-in-workspace/search-in-workspace-widget';
|
|
||||||
import { SearchInWorkspaceFactory as TheiaSearchInWorkspaceFactory } from '@theia/search-in-workspace/lib/browser/search-in-workspace-factory';
|
import { SearchInWorkspaceFactory as TheiaSearchInWorkspaceFactory } from '@theia/search-in-workspace/lib/browser/search-in-workspace-factory';
|
||||||
import { SearchInWorkspaceFactory } from './theia/search-in-workspace/search-in-workspace-factory';
|
import { SearchInWorkspaceFactory } from './theia/search-in-workspace/search-in-workspace-factory';
|
||||||
import { SearchInWorkspaceResultTreeWidget as TheiaSearchInWorkspaceResultTreeWidget } from '@theia/search-in-workspace/lib/browser/search-in-workspace-result-tree-widget';
|
|
||||||
import { SearchInWorkspaceResultTreeWidget } from './theia/search-in-workspace/search-in-workspace-result-tree-widget';
|
|
||||||
import { MonacoEditorProvider } from './theia/monaco/monaco-editor-provider';
|
import { MonacoEditorProvider } from './theia/monaco/monaco-editor-provider';
|
||||||
import { MonacoEditorProvider as TheiaMonacoEditorProvider } from '@theia/monaco/lib/browser/monaco-editor-provider';
|
import {
|
||||||
import { StorageWrapper } from './storage-wrapper';
|
MonacoEditorFactory,
|
||||||
|
MonacoEditorProvider as TheiaMonacoEditorProvider,
|
||||||
|
} from '@theia/monaco/lib/browser/monaco-editor-provider';
|
||||||
import { NotificationManager } from './theia/messages/notifications-manager';
|
import { NotificationManager } from './theia/messages/notifications-manager';
|
||||||
import { NotificationManager as TheiaNotificationManager } from '@theia/messages/lib/browser/notifications-manager';
|
import { NotificationManager as TheiaNotificationManager } from '@theia/messages/lib/browser/notifications-manager';
|
||||||
import { NotificationsRenderer as TheiaNotificationsRenderer } from '@theia/messages/lib/browser/notifications-renderer';
|
import { NotificationsRenderer as TheiaNotificationsRenderer } from '@theia/messages/lib/browser/notifications-renderer';
|
||||||
@@ -242,9 +237,7 @@ import { UploadFirmware } from './contributions/upload-firmware';
|
|||||||
import {
|
import {
|
||||||
UploadFirmwareDialog,
|
UploadFirmwareDialog,
|
||||||
UploadFirmwareDialogProps,
|
UploadFirmwareDialogProps,
|
||||||
UploadFirmwareDialogWidget,
|
|
||||||
} from './dialogs/firmware-uploader/firmware-uploader-dialog';
|
} from './dialogs/firmware-uploader/firmware-uploader-dialog';
|
||||||
|
|
||||||
import { UploadCertificate } from './contributions/upload-certificate';
|
import { UploadCertificate } from './contributions/upload-certificate';
|
||||||
import {
|
import {
|
||||||
ArduinoFirmwareUploader,
|
ArduinoFirmwareUploader,
|
||||||
@@ -259,7 +252,6 @@ import { PlotterFrontendContribution } from './serial/plotter/plotter-frontend-c
|
|||||||
import {
|
import {
|
||||||
UserFieldsDialog,
|
UserFieldsDialog,
|
||||||
UserFieldsDialogProps,
|
UserFieldsDialogProps,
|
||||||
UserFieldsDialogWidget,
|
|
||||||
} from './dialogs/user-fields/user-fields-dialog';
|
} from './dialogs/user-fields/user-fields-dialog';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import { nls } from '@theia/core/lib/common';
|
||||||
import { IDEUpdaterCommands } from './ide-updater/ide-updater-commands';
|
import { IDEUpdaterCommands } from './ide-updater/ide-updater-commands';
|
||||||
@@ -272,36 +264,144 @@ import { IDEUpdaterClientImpl } from './ide-updater/ide-updater-client-impl';
|
|||||||
import {
|
import {
|
||||||
IDEUpdaterDialog,
|
IDEUpdaterDialog,
|
||||||
IDEUpdaterDialogProps,
|
IDEUpdaterDialogProps,
|
||||||
IDEUpdaterDialogWidget,
|
|
||||||
} from './dialogs/ide-updater/ide-updater-dialog';
|
} from './dialogs/ide-updater/ide-updater-dialog';
|
||||||
import { ElectronIpcConnectionProvider } from '@theia/core/lib/electron-browser/messaging/electron-ipc-connection-provider';
|
import { ElectronIpcConnectionProvider } from '@theia/core/lib/electron-browser/messaging/electron-ipc-connection-source';
|
||||||
|
import { MonitorModel } from './monitor-model';
|
||||||
|
import { MonitorManagerProxyClientImpl } from './monitor-manager-proxy-client-impl';
|
||||||
|
import { EditorManager as TheiaEditorManager } from '@theia/editor/lib/browser/editor-manager';
|
||||||
|
import { EditorManager } from './theia/editor/editor-manager';
|
||||||
|
import { HostedPluginEvents } from './hosted/hosted-plugin-events';
|
||||||
|
import { HostedPluginSupportImpl } from './theia/plugin-ext/hosted-plugin';
|
||||||
|
import { HostedPluginSupport as TheiaHostedPluginSupport } from '@theia/plugin-ext/lib/hosted/browser/hosted-plugin';
|
||||||
|
import { Formatter, FormatterPath } from '../common/protocol/formatter';
|
||||||
|
import { Format } from './contributions/format';
|
||||||
|
import { MonacoFormattingConflictsContribution } from './theia/monaco/monaco-formatting-conflicts';
|
||||||
|
import { MonacoFormattingConflictsContribution as TheiaMonacoFormattingConflictsContribution } from '@theia/monaco/lib/browser/monaco-formatting-conflicts';
|
||||||
|
import { DefaultJsonSchemaContribution } from './theia/core/json-schema-store';
|
||||||
|
import { DefaultJsonSchemaContribution as TheiaDefaultJsonSchemaContribution } from '@theia/core/lib/browser/json-schema-store';
|
||||||
|
import { EditorNavigationContribution } from './theia/editor/editor-navigation-contribution';
|
||||||
|
import { EditorNavigationContribution as TheiaEditorNavigationContribution } from '@theia/editor/lib/browser/editor-navigation-contribution';
|
||||||
|
import { PreferenceTreeGenerator } from './theia/preferences/preference-tree-generator';
|
||||||
|
import { PreferenceTreeGenerator as TheiaPreferenceTreeGenerator } from '@theia/preferences/lib/browser/util/preference-tree-generator';
|
||||||
|
import { AboutDialog } from './theia/core/about-dialog';
|
||||||
|
import { AboutDialog as TheiaAboutDialog } from '@theia/core/lib/browser/about-dialog';
|
||||||
|
import { WindowContribution } from './theia/core/window-contribution';
|
||||||
|
import { WindowContribution as TheiaWindowContribution } from '@theia/core/lib/browser/window-contribution';
|
||||||
|
import { CoreErrorHandler } from './contributions/core-error-handler';
|
||||||
|
import { CompilerErrors } from './contributions/compiler-errors';
|
||||||
|
import { WidgetManager } from './theia/core/widget-manager';
|
||||||
|
import { WidgetManager as TheiaWidgetManager } from '@theia/core/lib/browser/widget-manager';
|
||||||
|
import { StartupTasksExecutor } from './contributions/startup-tasks-executor';
|
||||||
|
import { IndexesUpdateProgress } from './contributions/indexes-update-progress';
|
||||||
|
import { Daemon } from './contributions/daemon';
|
||||||
|
import { FirstStartupInstaller } from './contributions/first-startup-installer';
|
||||||
|
import { OpenSketchFiles } from './contributions/open-sketch-files';
|
||||||
|
import { InoLanguage } from './contributions/ino-language';
|
||||||
|
import { SelectedBoard } from './contributions/selected-board';
|
||||||
|
import { CheckForIDEUpdates } from './contributions/check-for-ide-updates';
|
||||||
|
import { OpenBoardsConfig } from './contributions/open-boards-config';
|
||||||
|
import { SketchFilesTracker } from './contributions/sketch-files-tracker';
|
||||||
|
import { EditorMenuContribution } from './theia/editor/editor-file';
|
||||||
|
import { EditorMenuContribution as TheiaEditorMenuContribution } from '@theia/editor/lib/browser/editor-menu';
|
||||||
|
import { PreferencesEditorWidget as TheiaPreferencesEditorWidget } from '@theia/preferences/lib/browser/views/preference-editor-widget';
|
||||||
|
import { PreferencesEditorWidget } from './theia/preferences/preference-editor-widget';
|
||||||
|
import { PreferencesWidget } from '@theia/preferences/lib/browser/views/preference-widget';
|
||||||
|
import { createPreferencesWidgetContainer } from '@theia/preferences/lib/browser/views/preference-widget-bindings';
|
||||||
|
import {
|
||||||
|
BoardsFilterRenderer,
|
||||||
|
LibraryFilterRenderer,
|
||||||
|
} from './widgets/component-list/filter-renderer';
|
||||||
|
import { CheckForUpdates } from './contributions/check-for-updates';
|
||||||
|
import { OutputEditorFactory } from './theia/output/output-editor-factory';
|
||||||
|
import { StartupTaskProvider } from '../electron-common/startup-task';
|
||||||
|
import { DeleteSketch } from './contributions/delete-sketch';
|
||||||
|
import { UserFields } from './contributions/user-fields';
|
||||||
|
import { UpdateIndexes } from './contributions/update-indexes';
|
||||||
|
import { InterfaceScale } from './contributions/interface-scale';
|
||||||
|
import { OpenHandler } from '@theia/core/lib/browser/opener-service';
|
||||||
|
import { NewCloudSketch } from './contributions/new-cloud-sketch';
|
||||||
|
import { SketchbookCompositeWidget } from './widgets/sketchbook/sketchbook-composite-widget';
|
||||||
|
import { WindowTitleUpdater } from './theia/core/window-title-updater';
|
||||||
|
import { WindowTitleUpdater as TheiaWindowTitleUpdater } from '@theia/core/lib/browser/window/window-title-updater';
|
||||||
|
import {
|
||||||
|
MonacoThemingService,
|
||||||
|
CleanupObsoleteThemes,
|
||||||
|
ThemesRegistrationSummary,
|
||||||
|
MonacoThemeRegistry,
|
||||||
|
} from './theia/monaco/monaco-theming-service';
|
||||||
|
import { MonacoThemeRegistry as TheiaMonacoThemeRegistry } from '@theia/monaco/lib/browser/textmate/monaco-theme-registry';
|
||||||
|
import { MonacoThemingService as TheiaMonacoThemingService } from '@theia/monaco/lib/browser/monaco-theming-service';
|
||||||
|
import { TypeHierarchyServiceProvider } from './theia/typehierarchy/type-hierarchy-service';
|
||||||
|
import { TypeHierarchyServiceProvider as TheiaTypeHierarchyServiceProvider } from '@theia/typehierarchy/lib/browser/typehierarchy-service';
|
||||||
|
import { TypeHierarchyContribution } from './theia/typehierarchy/type-hierarchy-contribution';
|
||||||
|
import { TypeHierarchyContribution as TheiaTypeHierarchyContribution } from '@theia/typehierarchy/lib/browser/typehierarchy-contribution';
|
||||||
|
import { DefaultDebugSessionFactory } from './theia/debug/debug-session-contribution';
|
||||||
|
import { DebugSessionFactory } from '@theia/debug/lib/browser/debug-session-contribution';
|
||||||
|
import { ConfigServiceClient } from './config/config-service-client';
|
||||||
|
import { ValidateSketch } from './contributions/validate-sketch';
|
||||||
|
import { RenameCloudSketch } from './contributions/rename-cloud-sketch';
|
||||||
|
import { CreateFeatures } from './create/create-features';
|
||||||
|
import { Account } from './contributions/account';
|
||||||
|
import { SidebarBottomMenuWidget } from './theia/core/sidebar-bottom-menu-widget';
|
||||||
|
import { SidebarBottomMenuWidget as TheiaSidebarBottomMenuWidget } from '@theia/core/lib/browser/shell/sidebar-bottom-menu-widget';
|
||||||
|
import { CreateCloudCopy } from './contributions/create-cloud-copy';
|
||||||
|
import { FileResourceResolver } from './theia/filesystem/file-resource';
|
||||||
|
import { FileResourceResolver as TheiaFileResourceResolver } from '@theia/filesystem/lib/browser/file-resource';
|
||||||
|
import { StylingParticipant } from '@theia/core/lib/browser/styling-service';
|
||||||
|
import { MonacoEditorMenuContribution } from './theia/monaco/monaco-menu';
|
||||||
|
import { MonacoEditorMenuContribution as TheiaMonacoEditorMenuContribution } from '@theia/monaco/lib/browser/monaco-menu';
|
||||||
|
import { UpdateArduinoState } from './contributions/update-arduino-state';
|
||||||
|
import { TerminalFrontendContribution } from './theia/terminal/terminal-frontend-contribution';
|
||||||
|
import { TerminalFrontendContribution as TheiaTerminalFrontendContribution } from '@theia/terminal/lib/browser/terminal-frontend-contribution';
|
||||||
|
import { SelectionService } from '@theia/core/lib/common/selection-service';
|
||||||
|
import { CommandService } from '@theia/core/lib/common/command';
|
||||||
|
import { CorePreferences } from '@theia/core/lib/browser/core-preferences';
|
||||||
|
import { AutoSelectProgrammer } from './contributions/auto-select-programmer';
|
||||||
|
import { HostedPluginSupport } from './hosted/hosted-plugin-support';
|
||||||
|
import { DebugSessionManager as TheiaDebugSessionManager } from '@theia/debug/lib/browser/debug-session-manager';
|
||||||
|
import { DebugSessionManager } from './theia/debug/debug-session-manager';
|
||||||
|
import { DebugWidget as TheiaDebugWidget } from '@theia/debug/lib/browser/view/debug-widget';
|
||||||
|
import { DebugWidget } from './theia/debug/debug-widget';
|
||||||
|
import { DebugViewModel } from '@theia/debug/lib/browser/view/debug-view-model';
|
||||||
|
import { DebugSessionWidget } from '@theia/debug/lib/browser/view/debug-session-widget';
|
||||||
|
import { DebugConfigurationWidget } from './theia/debug/debug-configuration-widget';
|
||||||
|
import { DebugConfigurationWidget as TheiaDebugConfigurationWidget } from '@theia/debug/lib/browser/view/debug-configuration-widget';
|
||||||
|
import { DebugToolBar } from '@theia/debug/lib/browser/view/debug-toolbar-widget';
|
||||||
|
|
||||||
const ElementQueries = require('css-element-queries/src/ElementQueries');
|
import {
|
||||||
|
VersionWelcomeDialog,
|
||||||
|
VersionWelcomeDialogProps,
|
||||||
|
} from './dialogs/version-welcome-dialog';
|
||||||
|
import { TestViewContribution as TheiaTestViewContribution } from '@theia/test/lib/browser/view/test-view-contribution';
|
||||||
|
import { TestViewContribution } from './theia/test/test-view-contribution';
|
||||||
|
|
||||||
MonacoThemingService.register({
|
// Hack to fix copy/cut/paste issue after electron version update in Theia.
|
||||||
id: 'arduino-theme',
|
// https://github.com/eclipse-theia/theia/issues/12487
|
||||||
label: 'Light (Arduino)',
|
import('@theia/core/lib/browser/common-frontend-contribution.js').then(
|
||||||
uiTheme: 'vs',
|
(theiaCommonContribution) => {
|
||||||
json: require('../../src/browser/data/arduino.color-theme.json'),
|
theiaCommonContribution['supportCopy'] = true;
|
||||||
});
|
theiaCommonContribution['supportCut'] = true;
|
||||||
|
theiaCommonContribution['supportPaste'] = true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
||||||
ElementQueries.listen();
|
// Commands, colors, theme adjustments, and toolbar items
|
||||||
ElementQueries.init();
|
|
||||||
|
|
||||||
// Commands and toolbar items
|
|
||||||
bind(ArduinoFrontendContribution).toSelf().inSingletonScope();
|
bind(ArduinoFrontendContribution).toSelf().inSingletonScope();
|
||||||
bind(CommandContribution).toService(ArduinoFrontendContribution);
|
bind(CommandContribution).toService(ArduinoFrontendContribution);
|
||||||
bind(MenuContribution).toService(ArduinoFrontendContribution);
|
bind(MenuContribution).toService(ArduinoFrontendContribution);
|
||||||
bind(TabBarToolbarContribution).toService(ArduinoFrontendContribution);
|
bind(TabBarToolbarContribution).toService(ArduinoFrontendContribution);
|
||||||
bind(FrontendApplicationContribution).toService(ArduinoFrontendContribution);
|
bind(FrontendApplicationContribution).toService(ArduinoFrontendContribution);
|
||||||
bind(ColorContribution).toService(ArduinoFrontendContribution);
|
bind(ColorContribution).toService(ArduinoFrontendContribution);
|
||||||
|
bind(StylingParticipant).toService(ArduinoFrontendContribution);
|
||||||
|
|
||||||
bind(ArduinoToolbarContribution).toSelf().inSingletonScope();
|
bind(ArduinoToolbarContribution).toSelf().inSingletonScope();
|
||||||
bind(FrontendApplicationContribution).toService(ArduinoToolbarContribution);
|
bind(FrontendApplicationContribution).toService(ArduinoToolbarContribution);
|
||||||
|
|
||||||
// Renderer for both the library and the core widgets.
|
// Renderer for both the library and the core widgets.
|
||||||
bind(ListItemRenderer).toSelf().inSingletonScope();
|
bind(ListItemRenderer).toSelf().inSingletonScope();
|
||||||
|
bind(LibraryFilterRenderer).toSelf().inSingletonScope();
|
||||||
|
bind(BoardsFilterRenderer).toSelf().inSingletonScope();
|
||||||
|
|
||||||
// Library service
|
// Library service
|
||||||
bind(LibraryService)
|
bind(LibraryService)
|
||||||
@@ -323,6 +423,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
bind(FrontendApplicationContribution).toService(
|
bind(FrontendApplicationContribution).toService(
|
||||||
LibraryListWidgetFrontendContribution
|
LibraryListWidgetFrontendContribution
|
||||||
);
|
);
|
||||||
|
bind(OpenHandler).toService(LibraryListWidgetFrontendContribution);
|
||||||
|
|
||||||
// Sketch list service
|
// Sketch list service
|
||||||
bind(SketchesService)
|
bind(SketchesService)
|
||||||
@@ -345,6 +446,8 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.inSingletonScope();
|
.inSingletonScope();
|
||||||
|
bind(ConfigServiceClient).toSelf().inSingletonScope();
|
||||||
|
bind(FrontendApplicationContribution).toService(ConfigServiceClient);
|
||||||
|
|
||||||
// Boards service
|
// Boards service
|
||||||
bind(BoardsService)
|
bind(BoardsService)
|
||||||
@@ -358,13 +461,15 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
// Boards service client to receive and delegate notifications from the backend.
|
// Boards service client to receive and delegate notifications from the backend.
|
||||||
bind(BoardsServiceProvider).toSelf().inSingletonScope();
|
bind(BoardsServiceProvider).toSelf().inSingletonScope();
|
||||||
bind(FrontendApplicationContribution).toService(BoardsServiceProvider);
|
bind(FrontendApplicationContribution).toService(BoardsServiceProvider);
|
||||||
|
bind(CommandContribution).toService(BoardsServiceProvider);
|
||||||
|
bind(BoardListDumper).toSelf().inSingletonScope();
|
||||||
|
|
||||||
// To be able to track, and update the menu based on the core settings (aka. board details) of the currently selected board.
|
// To be able to track, and update the menu based on the core settings (aka. board details) of the currently selected board.
|
||||||
bind(FrontendApplicationContribution)
|
|
||||||
.to(BoardsDataMenuUpdater)
|
|
||||||
.inSingletonScope();
|
|
||||||
bind(BoardsDataStore).toSelf().inSingletonScope();
|
bind(BoardsDataStore).toSelf().inSingletonScope();
|
||||||
bind(FrontendApplicationContribution).toService(BoardsDataStore);
|
bind(FrontendApplicationContribution).toService(BoardsDataStore);
|
||||||
|
bind(CommandContribution).toService(BoardsDataStore);
|
||||||
|
bind(StartupTaskProvider).toService(BoardsDataStore); // to inherit the boards config options, programmer, etc in a new window
|
||||||
|
|
||||||
// Logger for the Arduino daemon
|
// Logger for the Arduino daemon
|
||||||
bind(ILogger)
|
bind(ILogger)
|
||||||
.toDynamicValue((ctx) => {
|
.toDynamicValue((ctx) => {
|
||||||
@@ -388,12 +493,15 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
bind(FrontendApplicationContribution).toService(
|
bind(FrontendApplicationContribution).toService(
|
||||||
BoardsListWidgetFrontendContribution
|
BoardsListWidgetFrontendContribution
|
||||||
);
|
);
|
||||||
|
bind(OpenHandler).toService(BoardsListWidgetFrontendContribution);
|
||||||
|
|
||||||
// Board select dialog
|
// Board select dialog
|
||||||
bind(BoardsConfigDialogWidget).toSelf().inSingletonScope();
|
|
||||||
bind(BoardsConfigDialog).toSelf().inSingletonScope();
|
bind(BoardsConfigDialog).toSelf().inSingletonScope();
|
||||||
bind(BoardsConfigDialogProps).toConstantValue({
|
bind(BoardsConfigDialogProps).toConstantValue({
|
||||||
title: nls.localize('arduino/common/selectBoard', 'Select Board'),
|
title: nls.localize(
|
||||||
|
'arduino/board/boardConfigDialogTitle',
|
||||||
|
'Select Other Board and Port'
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Core service
|
// Core service
|
||||||
@@ -405,31 +513,39 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.inSingletonScope();
|
.inSingletonScope();
|
||||||
|
bind(CoreErrorHandler).toSelf().inSingletonScope();
|
||||||
|
|
||||||
// Serial monitor
|
// Serial monitor
|
||||||
bind(SerialModel).toSelf().inSingletonScope();
|
|
||||||
bind(FrontendApplicationContribution).toService(SerialModel);
|
|
||||||
bind(MonitorWidget).toSelf();
|
bind(MonitorWidget).toSelf();
|
||||||
|
bind(FrontendApplicationContribution).toService(MonitorModel);
|
||||||
|
bind(MonitorModel).toSelf().inSingletonScope();
|
||||||
bindViewContribution(bind, MonitorViewContribution);
|
bindViewContribution(bind, MonitorViewContribution);
|
||||||
bind(TabBarToolbarContribution).toService(MonitorViewContribution);
|
bind(TabBarToolbarContribution).toService(MonitorViewContribution);
|
||||||
bind(WidgetFactory).toDynamicValue((context) => ({
|
bind(WidgetFactory).toDynamicValue((context) => ({
|
||||||
id: MonitorWidget.ID,
|
id: MonitorWidget.ID,
|
||||||
createWidget: () => context.container.get(MonitorWidget),
|
createWidget: () => context.container.get(MonitorWidget),
|
||||||
}));
|
}));
|
||||||
// Frontend binding for the serial service
|
|
||||||
bind(SerialService)
|
|
||||||
.toDynamicValue((context) => {
|
|
||||||
const connection = context.container.get(WebSocketConnectionProvider);
|
|
||||||
const client = context.container.get<SerialServiceClient>(
|
|
||||||
SerialServiceClient
|
|
||||||
);
|
|
||||||
return connection.createProxy(SerialServicePath, client);
|
|
||||||
})
|
|
||||||
.inSingletonScope();
|
|
||||||
bind(SerialConnectionManager).toSelf().inSingletonScope();
|
|
||||||
|
|
||||||
// Serial service client to receive and delegate notifications from the backend.
|
bind(MonitorManagerProxyFactory).toFactory(
|
||||||
bind(SerialServiceClient).to(SerialServiceClientImpl).inSingletonScope();
|
(context) => () =>
|
||||||
|
context.container.get<MonitorManagerProxy>(MonitorManagerProxy)
|
||||||
|
);
|
||||||
|
|
||||||
|
bind(MonitorManagerProxy)
|
||||||
|
.toDynamicValue((context) =>
|
||||||
|
WebSocketConnectionProvider.createProxy(
|
||||||
|
context.container,
|
||||||
|
MonitorManagerProxyPath,
|
||||||
|
context.container.get(MonitorManagerProxyClient)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.inSingletonScope();
|
||||||
|
|
||||||
|
// Monitor manager proxy client to receive and delegate pluggable monitors
|
||||||
|
// notifications from the backend
|
||||||
|
bind(MonitorManagerProxyClient)
|
||||||
|
.to(MonitorManagerProxyClientImpl)
|
||||||
|
.inSingletonScope();
|
||||||
|
|
||||||
bind(WorkspaceService).toSelf().inSingletonScope();
|
bind(WorkspaceService).toSelf().inSingletonScope();
|
||||||
rebind(TheiaWorkspaceService).toService(WorkspaceService);
|
rebind(TheiaWorkspaceService).toService(WorkspaceService);
|
||||||
@@ -438,10 +554,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
WorkspaceVariableContribution
|
WorkspaceVariableContribution
|
||||||
);
|
);
|
||||||
|
|
||||||
// Customizing default Theia layout based on the editor mode: `pro-mode` or `classic`.
|
|
||||||
bind(EditorMode).toSelf().inSingletonScope();
|
|
||||||
bind(FrontendApplicationContribution).toService(EditorMode);
|
|
||||||
|
|
||||||
// Layout and shell customizations.
|
// Layout and shell customizations.
|
||||||
rebind(TheiaOutlineViewContribution)
|
rebind(TheiaOutlineViewContribution)
|
||||||
.to(OutlineViewContribution)
|
.to(OutlineViewContribution)
|
||||||
@@ -453,9 +565,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
rebind(TheiaKeymapsFrontendContribution)
|
rebind(TheiaKeymapsFrontendContribution)
|
||||||
.to(KeymapsFrontendContribution)
|
.to(KeymapsFrontendContribution)
|
||||||
.inSingletonScope();
|
.inSingletonScope();
|
||||||
rebind(TheiaEditorPreviewContribution)
|
rebind(TheiaEditorContribution).to(EditorContribution).inSingletonScope();
|
||||||
.to(EditorPreviewContribution)
|
|
||||||
.inSingletonScope();
|
|
||||||
rebind(TheiaMonacoStatusBarContribution)
|
rebind(TheiaMonacoStatusBarContribution)
|
||||||
.to(MonacoStatusBarContribution)
|
.to(MonacoStatusBarContribution)
|
||||||
.inSingletonScope();
|
.inSingletonScope();
|
||||||
@@ -477,7 +587,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
rebind(TheiaPreferencesContribution)
|
rebind(TheiaPreferencesContribution)
|
||||||
.to(PreferencesContribution)
|
.to(PreferencesContribution)
|
||||||
.inSingletonScope();
|
.inSingletonScope();
|
||||||
rebind(TheiaKeybindingRegistry).to(KeybindingRegistry).inSingletonScope();
|
|
||||||
rebind(TheiaWorkspaceCommandContribution)
|
rebind(TheiaWorkspaceCommandContribution)
|
||||||
.to(WorkspaceCommandContribution)
|
.to(WorkspaceCommandContribution)
|
||||||
.inSingletonScope();
|
.inSingletonScope();
|
||||||
@@ -485,15 +594,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
.to(WorkspaceDeleteHandler)
|
.to(WorkspaceDeleteHandler)
|
||||||
.inSingletonScope();
|
.inSingletonScope();
|
||||||
rebind(TheiaEditorWidgetFactory).to(EditorWidgetFactory).inSingletonScope();
|
rebind(TheiaEditorWidgetFactory).to(EditorWidgetFactory).inSingletonScope();
|
||||||
rebind(TabBarToolbarFactory).toFactory(
|
|
||||||
({ container: parentContainer }) => () => {
|
|
||||||
const container = parentContainer.createChild();
|
|
||||||
container.bind(TabBarToolbar).toSelf().inSingletonScope();
|
|
||||||
return container.get(TabBarToolbar);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
bind(OutputWidget).toSelf().inSingletonScope();
|
|
||||||
rebind(TheiaOutputWidget).toService(OutputWidget);
|
|
||||||
bind(OutputChannelManager).toSelf().inSingletonScope();
|
bind(OutputChannelManager).toSelf().inSingletonScope();
|
||||||
rebind(TheiaOutputChannelManager).toService(OutputChannelManager);
|
rebind(TheiaOutputChannelManager).toService(OutputChannelManager);
|
||||||
bind(OutputChannelRegistryMainImpl).toSelf().inTransientScope();
|
bind(OutputChannelRegistryMainImpl).toSelf().inTransientScope();
|
||||||
@@ -505,25 +605,15 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
bind(MonacoEditorProvider).toSelf().inSingletonScope();
|
bind(MonacoEditorProvider).toSelf().inSingletonScope();
|
||||||
rebind(TheiaMonacoEditorProvider).toService(MonacoEditorProvider);
|
rebind(TheiaMonacoEditorProvider).toService(MonacoEditorProvider);
|
||||||
|
|
||||||
bind(SearchInWorkspaceWidget).toSelf();
|
// Disabled reference counter in the editor manager to avoid opening the same editor (with different opener options) multiple times.
|
||||||
rebind(TheiaSearchInWorkspaceWidget).toService(SearchInWorkspaceWidget);
|
bind(EditorManager).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaEditorManager).toService(EditorManager);
|
||||||
|
|
||||||
// replace search icon
|
// replace search icon
|
||||||
rebind(TheiaSearchInWorkspaceFactory)
|
rebind(TheiaSearchInWorkspaceFactory)
|
||||||
.to(SearchInWorkspaceFactory)
|
.to(SearchInWorkspaceFactory)
|
||||||
.inSingletonScope();
|
.inSingletonScope();
|
||||||
|
|
||||||
rebind(TheiaSearchInWorkspaceResultTreeWidget).toDynamicValue(
|
|
||||||
({ container }) => {
|
|
||||||
const childContainer = createTreeContainer(container);
|
|
||||||
childContainer.bind(SearchInWorkspaceResultTreeWidget).toSelf();
|
|
||||||
childContainer
|
|
||||||
.rebind(TreeWidget)
|
|
||||||
.toService(SearchInWorkspaceResultTreeWidget);
|
|
||||||
return childContainer.get(SearchInWorkspaceResultTreeWidget);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Show a disconnected status bar, when the daemon is not available
|
// Show a disconnected status bar, when the daemon is not available
|
||||||
bind(ApplicationConnectionStatusContribution).toSelf().inSingletonScope();
|
bind(ApplicationConnectionStatusContribution).toSelf().inSingletonScope();
|
||||||
rebind(TheiaApplicationConnectionStatusContribution).toService(
|
rebind(TheiaApplicationConnectionStatusContribution).toService(
|
||||||
@@ -550,6 +640,19 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
bind(OutputToolbarContribution).toSelf().inSingletonScope();
|
bind(OutputToolbarContribution).toSelf().inSingletonScope();
|
||||||
rebind(TheiaOutputToolbarContribution).toService(OutputToolbarContribution);
|
rebind(TheiaOutputToolbarContribution).toService(OutputToolbarContribution);
|
||||||
|
|
||||||
|
// To remove `New Window` from the `File` menu
|
||||||
|
bind(WindowContribution).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaWindowContribution).toService(WindowContribution);
|
||||||
|
|
||||||
|
// To remove `File` > `Close Editor`.
|
||||||
|
bind(EditorMenuContribution).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaEditorMenuContribution).toService(EditorMenuContribution);
|
||||||
|
|
||||||
|
// To disable the highlighting of non-unicode characters in the _Output_ view
|
||||||
|
bind(OutputEditorFactory).toSelf().inSingletonScope();
|
||||||
|
// Rebind to `TheiaOutputEditorFactory` when https://github.com/eclipse-theia/theia/pull/11615 is available.
|
||||||
|
rebind(MonacoEditorFactory).toService(OutputEditorFactory);
|
||||||
|
|
||||||
bind(ArduinoDaemon)
|
bind(ArduinoDaemon)
|
||||||
.toDynamicValue((context) =>
|
.toDynamicValue((context) =>
|
||||||
WebSocketConnectionProvider.createProxy(
|
WebSocketConnectionProvider.createProxy(
|
||||||
@@ -559,6 +662,12 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
)
|
)
|
||||||
.inSingletonScope();
|
.inSingletonScope();
|
||||||
|
|
||||||
|
bind(Formatter)
|
||||||
|
.toDynamicValue(({ container }) =>
|
||||||
|
WebSocketConnectionProvider.createProxy(container, FormatterPath)
|
||||||
|
)
|
||||||
|
.inSingletonScope();
|
||||||
|
|
||||||
bind(ArduinoFirmwareUploader)
|
bind(ArduinoFirmwareUploader)
|
||||||
.toDynamicValue((context) =>
|
.toDynamicValue((context) =>
|
||||||
WebSocketConnectionProvider.createProxy(
|
WebSocketConnectionProvider.createProxy(
|
||||||
@@ -609,7 +718,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
Contribution.configure(bind, EditContributions);
|
Contribution.configure(bind, EditContributions);
|
||||||
Contribution.configure(bind, QuitApp);
|
Contribution.configure(bind, QuitApp);
|
||||||
Contribution.configure(bind, SketchControl);
|
Contribution.configure(bind, SketchControl);
|
||||||
Contribution.configure(bind, Settings);
|
Contribution.configure(bind, OpenSettings);
|
||||||
Contribution.configure(bind, BurnBootloader);
|
Contribution.configure(bind, BurnBootloader);
|
||||||
Contribution.configure(bind, BuiltInExamples);
|
Contribution.configure(bind, BuiltInExamples);
|
||||||
Contribution.configure(bind, LibraryExamples);
|
Contribution.configure(bind, LibraryExamples);
|
||||||
@@ -626,6 +735,46 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
Contribution.configure(bind, ArchiveSketch);
|
Contribution.configure(bind, ArchiveSketch);
|
||||||
Contribution.configure(bind, AddZipLibrary);
|
Contribution.configure(bind, AddZipLibrary);
|
||||||
Contribution.configure(bind, PlotterFrontendContribution);
|
Contribution.configure(bind, PlotterFrontendContribution);
|
||||||
|
Contribution.configure(bind, Format);
|
||||||
|
Contribution.configure(bind, CompilerErrors);
|
||||||
|
Contribution.configure(bind, StartupTasksExecutor);
|
||||||
|
Contribution.configure(bind, IndexesUpdateProgress);
|
||||||
|
Contribution.configure(bind, Daemon);
|
||||||
|
Contribution.configure(bind, FirstStartupInstaller);
|
||||||
|
Contribution.configure(bind, OpenSketchFiles);
|
||||||
|
Contribution.configure(bind, InoLanguage);
|
||||||
|
Contribution.configure(bind, SelectedBoard);
|
||||||
|
Contribution.configure(bind, CheckForIDEUpdates);
|
||||||
|
Contribution.configure(bind, OpenBoardsConfig);
|
||||||
|
Contribution.configure(bind, SketchFilesTracker);
|
||||||
|
Contribution.configure(bind, CheckForUpdates);
|
||||||
|
Contribution.configure(bind, UserFields);
|
||||||
|
Contribution.configure(bind, DeleteSketch);
|
||||||
|
Contribution.configure(bind, UpdateIndexes);
|
||||||
|
Contribution.configure(bind, InterfaceScale);
|
||||||
|
Contribution.configure(bind, NewCloudSketch);
|
||||||
|
Contribution.configure(bind, ValidateSketch);
|
||||||
|
Contribution.configure(bind, RenameCloudSketch);
|
||||||
|
Contribution.configure(bind, Account);
|
||||||
|
Contribution.configure(bind, CloudSketchbookContribution);
|
||||||
|
Contribution.configure(bind, CreateCloudCopy);
|
||||||
|
Contribution.configure(bind, UpdateArduinoState);
|
||||||
|
Contribution.configure(bind, BoardsDataMenuUpdater);
|
||||||
|
Contribution.configure(bind, AutoSelectProgrammer);
|
||||||
|
|
||||||
|
bind(CompileSummaryProvider).toService(VerifySketch);
|
||||||
|
|
||||||
|
bindContributionProvider(bind, StartupTaskProvider);
|
||||||
|
bind(StartupTaskProvider).toService(BoardsServiceProvider); // to reuse the boards config in another window
|
||||||
|
|
||||||
|
bind(DebugDisabledStatusMessageSource).toService(Debug);
|
||||||
|
|
||||||
|
// Disabled the quick-pick customization from Theia when multiple formatters are available.
|
||||||
|
// Use the default VS Code behavior, and pick the first one. In the IDE2, clang-format has `exclusive` selectors.
|
||||||
|
bind(MonacoFormattingConflictsContribution).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaMonacoFormattingConflictsContribution).toService(
|
||||||
|
MonacoFormattingConflictsContribution
|
||||||
|
);
|
||||||
|
|
||||||
bind(ResponseServiceImpl)
|
bind(ResponseServiceImpl)
|
||||||
.toSelf()
|
.toSelf()
|
||||||
@@ -640,7 +789,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
bind(ResponseService).toService(ResponseServiceImpl);
|
bind(ResponseService).toService(ResponseServiceImpl);
|
||||||
bind(ResponseServiceArduino).toService(ResponseServiceImpl);
|
bind(ResponseServiceClient).toService(ResponseServiceImpl);
|
||||||
|
|
||||||
bind(NotificationCenter).toSelf().inSingletonScope();
|
bind(NotificationCenter).toSelf().inSingletonScope();
|
||||||
bind(FrontendApplicationContribution).toService(NotificationCenter);
|
bind(FrontendApplicationContribution).toService(NotificationCenter);
|
||||||
@@ -655,34 +804,53 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
|
|
||||||
// Enable the dirty indicator on uncloseable widgets.
|
// Enable the dirty indicator on uncloseable widgets.
|
||||||
rebind(TabBarRendererFactory).toFactory((context) => () => {
|
rebind(TabBarRendererFactory).toFactory((context) => () => {
|
||||||
const contextMenuRenderer = context.container.get<ContextMenuRenderer>(
|
const contextMenuRenderer =
|
||||||
ContextMenuRenderer
|
context.container.get<ContextMenuRenderer>(ContextMenuRenderer);
|
||||||
);
|
|
||||||
const decoratorService = context.container.get<TabBarDecoratorService>(
|
const decoratorService = context.container.get<TabBarDecoratorService>(
|
||||||
TabBarDecoratorService
|
TabBarDecoratorService
|
||||||
);
|
);
|
||||||
const iconThemeService = context.container.get<IconThemeService>(
|
const iconThemeService =
|
||||||
IconThemeService
|
context.container.get<IconThemeService>(IconThemeService);
|
||||||
);
|
const selectionService =
|
||||||
|
context.container.get<SelectionService>(SelectionService);
|
||||||
|
const commandService =
|
||||||
|
context.container.get<CommandService>(CommandService);
|
||||||
|
const corePreferences =
|
||||||
|
context.container.get<CorePreferences>(CorePreferences);
|
||||||
return new TabBarRenderer(
|
return new TabBarRenderer(
|
||||||
contextMenuRenderer,
|
contextMenuRenderer,
|
||||||
decoratorService,
|
decoratorService,
|
||||||
iconThemeService
|
iconThemeService,
|
||||||
|
selectionService,
|
||||||
|
commandService,
|
||||||
|
corePreferences
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Workaround for https://github.com/eclipse-theia/theia/issues/8722
|
|
||||||
// Do not trigger a save on IDE startup if `"editor.autoSave": "on"` was set as a preference.
|
|
||||||
bind(EditorCommandContribution).toSelf().inSingletonScope();
|
|
||||||
rebind(TheiaEditorCommandContribution).toService(EditorCommandContribution);
|
|
||||||
|
|
||||||
// Silent the badge decoration in the Explorer view.
|
// Silent the badge decoration in the Explorer view.
|
||||||
bind(NavigatorTabBarDecorator).toSelf().inSingletonScope();
|
bind(NavigatorTabBarDecorator).toSelf().inSingletonScope();
|
||||||
rebind(TheiaNavigatorTabBarDecorator).toService(NavigatorTabBarDecorator);
|
rebind(TheiaNavigatorTabBarDecorator).toService(NavigatorTabBarDecorator);
|
||||||
|
|
||||||
// To avoid running `Save All` when there are no dirty editors before starting the debug session.
|
// Do not fetch the `catalog.json` from Azure on FE load.
|
||||||
bind(DebugSessionManager).toSelf().inSingletonScope();
|
bind(DefaultJsonSchemaContribution).toSelf().inSingletonScope();
|
||||||
rebind(TheiaDebugSessionManager).toService(DebugSessionManager);
|
rebind(TheiaDefaultJsonSchemaContribution).toService(
|
||||||
|
DefaultJsonSchemaContribution
|
||||||
|
);
|
||||||
|
|
||||||
|
// Do not block the app startup when initializing the editor navigation history.
|
||||||
|
bind(EditorNavigationContribution).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaEditorNavigationContribution).toService(
|
||||||
|
EditorNavigationContribution
|
||||||
|
);
|
||||||
|
|
||||||
|
// IDE2 does not use the Theia preferences widget, no need to create and sync the underlying tree model.
|
||||||
|
bind(PreferenceTreeGenerator).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaPreferenceTreeGenerator).toService(PreferenceTreeGenerator);
|
||||||
|
|
||||||
|
// IDE2 has a custom about dialog, so there is no need to load the Theia extensions on FE load
|
||||||
|
bind(AboutDialog).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaAboutDialog).toService(AboutDialog);
|
||||||
|
|
||||||
// To remove the `Run` menu item from the application menu.
|
// To remove the `Run` menu item from the application menu.
|
||||||
bind(DebugFrontendApplicationContribution).toSelf().inSingletonScope();
|
bind(DebugFrontendApplicationContribution).toSelf().inSingletonScope();
|
||||||
rebind(TheiaDebugFrontendApplicationContribution).toService(
|
rebind(TheiaDebugFrontendApplicationContribution).toService(
|
||||||
@@ -691,6 +859,48 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
// To be able to use a `launch.json` from outside of the workspace.
|
// To be able to use a `launch.json` from outside of the workspace.
|
||||||
bind(DebugConfigurationManager).toSelf().inSingletonScope();
|
bind(DebugConfigurationManager).toSelf().inSingletonScope();
|
||||||
rebind(TheiaDebugConfigurationManager).toService(DebugConfigurationManager);
|
rebind(TheiaDebugConfigurationManager).toService(DebugConfigurationManager);
|
||||||
|
// To update the currently selected debug config <select> option when starting a debug session.
|
||||||
|
bind(DebugSessionManager).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaDebugSessionManager).toService(DebugSessionManager);
|
||||||
|
// Customized debug widget with its customized config <select> to update it programmatically.
|
||||||
|
bind(WidgetFactory)
|
||||||
|
.toDynamicValue(({ container }) => ({
|
||||||
|
id: TheiaDebugWidget.ID,
|
||||||
|
createWidget: () => {
|
||||||
|
const child = new Container({ defaultScope: 'Singleton' });
|
||||||
|
child.parent = container;
|
||||||
|
child.bind(DebugViewModel).toSelf();
|
||||||
|
child.bind(DebugToolBar).toSelf();
|
||||||
|
child.bind(DebugSessionWidget).toSelf();
|
||||||
|
child.bind(DebugConfigurationWidget).toSelf(); // with the patched select
|
||||||
|
child // use the customized one in the Theia DI
|
||||||
|
.bind(TheiaDebugConfigurationWidget)
|
||||||
|
.toService(DebugConfigurationWidget);
|
||||||
|
child.bind(DebugWidget).toSelf();
|
||||||
|
return child.get(DebugWidget);
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
.inSingletonScope();
|
||||||
|
|
||||||
|
// To avoid duplicate tabs use deepEqual instead of string equal: https://github.com/eclipse-theia/theia/issues/11309
|
||||||
|
bind(WidgetManager).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaWidgetManager).toService(WidgetManager);
|
||||||
|
|
||||||
|
// Debounced update for the tab-bar toolbar when typing in the editor.
|
||||||
|
bind(DockPanelRenderer).toSelf();
|
||||||
|
rebind(TheiaDockPanelRenderer).toService(DockPanelRenderer);
|
||||||
|
|
||||||
|
// Avoid running the "reset scroll" interval tasks until the preference editor opens.
|
||||||
|
rebind(PreferencesWidget)
|
||||||
|
.toDynamicValue(({ container }) => {
|
||||||
|
const child = createPreferencesWidgetContainer(container);
|
||||||
|
child.bind(PreferencesEditorWidget).toSelf().inSingletonScope();
|
||||||
|
child
|
||||||
|
.rebind(TheiaPreferencesEditorWidget)
|
||||||
|
.toService(PreferencesEditorWidget);
|
||||||
|
return child.get(PreferencesWidget);
|
||||||
|
})
|
||||||
|
.inSingletonScope();
|
||||||
|
|
||||||
// Preferences
|
// Preferences
|
||||||
bindArduinoPreferences(bind);
|
bindArduinoPreferences(bind);
|
||||||
@@ -707,9 +917,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
bind(StorageWrapper).toSelf().inSingletonScope();
|
|
||||||
bind(CommandContribution).toService(StorageWrapper);
|
|
||||||
|
|
||||||
bind(NotificationManager).toSelf().inSingletonScope();
|
bind(NotificationManager).toSelf().inSingletonScope();
|
||||||
rebind(TheiaNotificationManager).toService(NotificationManager);
|
rebind(TheiaNotificationManager).toService(NotificationManager);
|
||||||
bind(NotificationsRenderer).toSelf().inSingletonScope();
|
bind(NotificationsRenderer).toSelf().inSingletonScope();
|
||||||
@@ -726,6 +933,11 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
id: 'arduino-sketchbook-widget',
|
id: 'arduino-sketchbook-widget',
|
||||||
createWidget: () => container.get(SketchbookWidget),
|
createWidget: () => container.get(SketchbookWidget),
|
||||||
}));
|
}));
|
||||||
|
bind(SketchbookCompositeWidget).toSelf();
|
||||||
|
bind<WidgetFactory>(WidgetFactory).toDynamicValue((ctx) => ({
|
||||||
|
id: 'sketchbook-composite-widget',
|
||||||
|
createWidget: () => ctx.container.get(SketchbookCompositeWidget),
|
||||||
|
}));
|
||||||
|
|
||||||
bind(CloudSketchbookWidget).toSelf();
|
bind(CloudSketchbookWidget).toSelf();
|
||||||
rebind(SketchbookWidget).toService(CloudSketchbookWidget);
|
rebind(SketchbookWidget).toService(CloudSketchbookWidget);
|
||||||
@@ -734,6 +946,8 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
);
|
);
|
||||||
bind(CreateApi).toSelf().inSingletonScope();
|
bind(CreateApi).toSelf().inSingletonScope();
|
||||||
bind(SketchCache).toSelf().inSingletonScope();
|
bind(SketchCache).toSelf().inSingletonScope();
|
||||||
|
bind(CreateFeatures).toSelf().inSingletonScope();
|
||||||
|
bind(FrontendApplicationContribution).toService(CreateFeatures);
|
||||||
|
|
||||||
bind(ShareSketchDialog).toSelf().inSingletonScope();
|
bind(ShareSketchDialog).toSelf().inSingletonScope();
|
||||||
bind(AuthenticationClientService).toSelf().inSingletonScope();
|
bind(AuthenticationClientService).toSelf().inSingletonScope();
|
||||||
@@ -750,17 +964,14 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
bind(CreateFsProvider).toSelf().inSingletonScope();
|
bind(CreateFsProvider).toSelf().inSingletonScope();
|
||||||
bind(FrontendApplicationContribution).toService(CreateFsProvider);
|
bind(FrontendApplicationContribution).toService(CreateFsProvider);
|
||||||
bind(FileServiceContribution).toService(CreateFsProvider);
|
bind(FileServiceContribution).toService(CreateFsProvider);
|
||||||
bind(CloudSketchbookContribution).toSelf().inSingletonScope();
|
|
||||||
bind(CommandContribution).toService(CloudSketchbookContribution);
|
|
||||||
bind(LocalCacheFsProvider).toSelf().inSingletonScope();
|
bind(LocalCacheFsProvider).toSelf().inSingletonScope();
|
||||||
bind(FileServiceContribution).toService(LocalCacheFsProvider);
|
bind(FileServiceContribution).toService(LocalCacheFsProvider);
|
||||||
bind(CloudSketchbookCompositeWidget).toSelf();
|
bind(CloudSketchbookCompositeWidget).toSelf();
|
||||||
bind<WidgetFactory>(WidgetFactory).toDynamicValue((ctx) => ({
|
bind(WidgetFactory).toDynamicValue((ctx) => ({
|
||||||
id: 'cloud-sketchbook-composite-widget',
|
id: 'cloud-sketchbook-composite-widget',
|
||||||
createWidget: () => ctx.container.get(CloudSketchbookCompositeWidget),
|
createWidget: () => ctx.container.get(CloudSketchbookCompositeWidget),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
bind(UploadFirmwareDialogWidget).toSelf().inSingletonScope();
|
|
||||||
bind(UploadFirmwareDialog).toSelf().inSingletonScope();
|
bind(UploadFirmwareDialog).toSelf().inSingletonScope();
|
||||||
bind(UploadFirmwareDialogProps).toConstantValue({
|
bind(UploadFirmwareDialogProps).toConstantValue({
|
||||||
title: 'UploadFirmware',
|
title: 'UploadFirmware',
|
||||||
@@ -771,13 +982,16 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
title: 'UploadCertificate',
|
title: 'UploadCertificate',
|
||||||
});
|
});
|
||||||
|
|
||||||
bind(IDEUpdaterDialogWidget).toSelf().inSingletonScope();
|
|
||||||
bind(IDEUpdaterDialog).toSelf().inSingletonScope();
|
bind(IDEUpdaterDialog).toSelf().inSingletonScope();
|
||||||
bind(IDEUpdaterDialogProps).toConstantValue({
|
bind(IDEUpdaterDialogProps).toConstantValue({
|
||||||
title: 'IDEUpdater',
|
title: 'IDEUpdater',
|
||||||
});
|
});
|
||||||
|
|
||||||
bind(UserFieldsDialogWidget).toSelf().inSingletonScope();
|
bind(VersionWelcomeDialog).toSelf().inSingletonScope();
|
||||||
|
bind(VersionWelcomeDialogProps).toConstantValue({
|
||||||
|
title: 'VersionWelcomeDialog',
|
||||||
|
});
|
||||||
|
|
||||||
bind(UserFieldsDialog).toSelf().inSingletonScope();
|
bind(UserFieldsDialog).toSelf().inSingletonScope();
|
||||||
bind(UserFieldsDialogProps).toConstantValue({
|
bind(UserFieldsDialogProps).toConstantValue({
|
||||||
title: 'UserFields',
|
title: 'UserFields',
|
||||||
@@ -799,4 +1013,70 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
.inSingletonScope();
|
.inSingletonScope();
|
||||||
|
|
||||||
|
bind(HostedPluginSupportImpl).toSelf().inSingletonScope();
|
||||||
|
bind(HostedPluginSupport).toService(HostedPluginSupportImpl);
|
||||||
|
rebind(TheiaHostedPluginSupport).toService(HostedPluginSupportImpl);
|
||||||
|
bind(HostedPluginEvents).toSelf().inSingletonScope();
|
||||||
|
bind(FrontendApplicationContribution).toService(HostedPluginEvents);
|
||||||
|
|
||||||
|
// custom window titles
|
||||||
|
bind(WindowTitleUpdater).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaWindowTitleUpdater).toService(WindowTitleUpdater);
|
||||||
|
|
||||||
|
// register Arduino themes
|
||||||
|
bind(MonacoThemingService).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaMonacoThemingService).toService(MonacoThemingService);
|
||||||
|
|
||||||
|
// workaround for themes cannot be removed after registration
|
||||||
|
// https://github.com/eclipse-theia/theia/issues/11151
|
||||||
|
bind(CleanupObsoleteThemes).toSelf().inSingletonScope();
|
||||||
|
bind(FrontendApplicationContribution).toService(CleanupObsoleteThemes);
|
||||||
|
bind(ThemesRegistrationSummary).toSelf().inSingletonScope();
|
||||||
|
bind(MonacoThemeRegistry).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaMonacoThemeRegistry).toService(MonacoThemeRegistry);
|
||||||
|
|
||||||
|
// disable type-hierarchy support
|
||||||
|
// https://github.com/eclipse-theia/theia/commit/16c88a584bac37f5cf3cc5eb92ffdaa541bda5be
|
||||||
|
bind(TypeHierarchyServiceProvider).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaTypeHierarchyServiceProvider).toService(
|
||||||
|
TypeHierarchyServiceProvider
|
||||||
|
);
|
||||||
|
bind(TypeHierarchyContribution).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaTypeHierarchyContribution).toService(TypeHierarchyContribution);
|
||||||
|
|
||||||
|
bind(DefaultDebugSessionFactory).toSelf().inSingletonScope();
|
||||||
|
rebind(DebugSessionFactory).toService(DefaultDebugSessionFactory);
|
||||||
|
|
||||||
|
bind(SidebarBottomMenuWidget).toSelf();
|
||||||
|
rebind(TheiaSidebarBottomMenuWidget).toService(SidebarBottomMenuWidget);
|
||||||
|
|
||||||
|
bind(ArduinoComponentContextMenuRenderer).toSelf().inSingletonScope();
|
||||||
|
|
||||||
|
bind(DaemonPort).toSelf().inSingletonScope();
|
||||||
|
bind(FrontendApplicationContribution).toService(DaemonPort);
|
||||||
|
bind(IsOnline).toSelf().inSingletonScope();
|
||||||
|
bind(FrontendApplicationContribution).toService(IsOnline);
|
||||||
|
|
||||||
|
// https://github.com/arduino/arduino-ide/issues/437
|
||||||
|
bind(FileResourceResolver).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaFileResourceResolver).toService(FileResourceResolver);
|
||||||
|
|
||||||
|
// Full control over the editor context menu to filter undesired menu items contributed by Theia.
|
||||||
|
// https://github.com/arduino/arduino-ide/issues/1394
|
||||||
|
// https://github.com/arduino/arduino-ide/pull/2027#pullrequestreview-1414246614
|
||||||
|
bind(MonacoEditorMenuContribution).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaMonacoEditorMenuContribution).toService(
|
||||||
|
MonacoEditorMenuContribution
|
||||||
|
);
|
||||||
|
|
||||||
|
// Patch terminal issues.
|
||||||
|
bind(TerminalFrontendContribution).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaTerminalFrontendContribution).toService(
|
||||||
|
TerminalFrontendContribution
|
||||||
|
);
|
||||||
|
|
||||||
|
// Hides the Test Explorer from the side-bar
|
||||||
|
bind(TestViewContribution).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaTestViewContribution).toService(TestViewContribution);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,190 +1,338 @@
|
|||||||
import { interfaces } from 'inversify';
|
|
||||||
import {
|
import {
|
||||||
createPreferenceProxy,
|
|
||||||
PreferenceProxy,
|
|
||||||
PreferenceService,
|
|
||||||
PreferenceContribution,
|
PreferenceContribution,
|
||||||
|
PreferenceProxy,
|
||||||
PreferenceSchema,
|
PreferenceSchema,
|
||||||
|
PreferenceService,
|
||||||
|
createPreferenceProxy,
|
||||||
} from '@theia/core/lib/browser/preferences';
|
} from '@theia/core/lib/browser/preferences';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { PreferenceSchemaProperty } from '@theia/core/lib/common/preferences/preference-schema';
|
||||||
|
import { interfaces } from '@theia/core/shared/inversify';
|
||||||
|
import { serialMonitorWidgetLabel } from '../common/nls';
|
||||||
import { CompilerWarningLiterals, CompilerWarnings } from '../common/protocol';
|
import { CompilerWarningLiterals, CompilerWarnings } from '../common/protocol';
|
||||||
|
|
||||||
export enum UpdateChannel {
|
export enum UpdateChannel {
|
||||||
Stable = 'stable',
|
Stable = 'stable',
|
||||||
Nightly = 'nightly',
|
Nightly = 'nightly',
|
||||||
}
|
}
|
||||||
|
export const ErrorRevealStrategyLiterals = [
|
||||||
|
/**
|
||||||
|
* Scroll vertically as necessary and reveal a line.
|
||||||
|
*/
|
||||||
|
'auto',
|
||||||
|
/**
|
||||||
|
* Scroll vertically as necessary and reveal a line centered vertically.
|
||||||
|
*/
|
||||||
|
'center',
|
||||||
|
/**
|
||||||
|
* Scroll vertically as necessary and reveal a line close to the top of the viewport, optimized for viewing a code definition.
|
||||||
|
*/
|
||||||
|
'top',
|
||||||
|
/**
|
||||||
|
* Scroll vertically as necessary and reveal a line centered vertically only if it lies outside the viewport.
|
||||||
|
*/
|
||||||
|
'centerIfOutsideViewport',
|
||||||
|
] as const;
|
||||||
|
export type ErrorRevealStrategy = (typeof ErrorRevealStrategyLiterals)[number];
|
||||||
|
export namespace ErrorRevealStrategy {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
||||||
|
export function is(arg: any): arg is ErrorRevealStrategy {
|
||||||
|
return !!arg && ErrorRevealStrategyLiterals.includes(arg);
|
||||||
|
}
|
||||||
|
export const Default: ErrorRevealStrategy = 'centerIfOutsideViewport';
|
||||||
|
}
|
||||||
|
|
||||||
|
export type MonitorWidgetDockPanel = Extract<
|
||||||
|
ApplicationShell.Area,
|
||||||
|
'bottom' | 'right'
|
||||||
|
>;
|
||||||
|
export const defaultMonitorWidgetDockPanel: MonitorWidgetDockPanel = 'bottom';
|
||||||
|
export function isMonitorWidgetDockPanel(
|
||||||
|
arg: unknown
|
||||||
|
): arg is MonitorWidgetDockPanel {
|
||||||
|
return arg === 'bottom' || arg === 'right';
|
||||||
|
}
|
||||||
|
|
||||||
|
export const defaultAsyncWorkers = 0 as const;
|
||||||
|
export const minAsyncWorkers = defaultAsyncWorkers;
|
||||||
|
export const maxAsyncWorkers = 8 as const;
|
||||||
|
|
||||||
|
type StrictPreferenceSchemaProperties<T extends object> = {
|
||||||
|
[p in keyof T]: PreferenceSchemaProperty;
|
||||||
|
};
|
||||||
|
type ArduinoPreferenceSchemaProperties =
|
||||||
|
StrictPreferenceSchemaProperties<ArduinoConfiguration> & {
|
||||||
|
'arduino.window.zoomLevel': PreferenceSchemaProperty;
|
||||||
|
};
|
||||||
|
|
||||||
|
const properties: ArduinoPreferenceSchemaProperties = {
|
||||||
|
'arduino.language.log': {
|
||||||
|
type: 'boolean',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/language.log',
|
||||||
|
"True if the Arduino Language Server should generate log files into the sketch folder. Otherwise, false. It's false by default."
|
||||||
|
),
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
'arduino.language.realTimeDiagnostics': {
|
||||||
|
type: 'boolean',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/language.realTimeDiagnostics',
|
||||||
|
"If true, the language server provides real-time diagnostics when typing in the editor. It's false by default."
|
||||||
|
),
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
'arduino.language.asyncWorkers': {
|
||||||
|
type: 'number',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/language.asyncWorkers',
|
||||||
|
'Number of async workers used by the Arduino Language Server (clangd). Background index also uses this many workers. The minimum value is 0, and the maximum is 8. When it is 0, the language server uses all available cores. The default value is 0.'
|
||||||
|
),
|
||||||
|
minimum: minAsyncWorkers,
|
||||||
|
maximum: maxAsyncWorkers,
|
||||||
|
default: defaultAsyncWorkers,
|
||||||
|
},
|
||||||
|
'arduino.compile.verbose': {
|
||||||
|
type: 'boolean',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/compile.verbose',
|
||||||
|
'True for verbose compile output. False by default'
|
||||||
|
),
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
'arduino.compile.experimental': {
|
||||||
|
type: 'boolean',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/compile.experimental',
|
||||||
|
'True if the IDE should handle multiple compiler errors. False by default'
|
||||||
|
),
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
'arduino.compile.revealRange': {
|
||||||
|
enum: [...ErrorRevealStrategyLiterals],
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/compile.revealRange',
|
||||||
|
"Adjusts how compiler errors are revealed in the editor after a failed verify/upload. Possible values: 'auto': Scroll vertically as necessary and reveal a line. 'center': Scroll vertically as necessary and reveal a line centered vertically. 'top': Scroll vertically as necessary and reveal a line close to the top of the viewport, optimized for viewing a code definition. 'centerIfOutsideViewport': Scroll vertically as necessary and reveal a line centered vertically only if it lies outside the viewport. The default value is '{0}'.",
|
||||||
|
ErrorRevealStrategy.Default
|
||||||
|
),
|
||||||
|
default: ErrorRevealStrategy.Default,
|
||||||
|
},
|
||||||
|
'arduino.compile.warnings': {
|
||||||
|
enum: [...CompilerWarningLiterals],
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/compile.warnings',
|
||||||
|
"Tells gcc which warning level to use. It's 'None' by default"
|
||||||
|
),
|
||||||
|
default: 'None',
|
||||||
|
},
|
||||||
|
'arduino.upload.verbose': {
|
||||||
|
type: 'boolean',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/upload.verbose',
|
||||||
|
'True for verbose upload output. False by default.'
|
||||||
|
),
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
'arduino.upload.verify': {
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/upload.verify',
|
||||||
|
'After upload, verify that the contents of the memory on the board match the uploaded binary.'
|
||||||
|
),
|
||||||
|
},
|
||||||
|
'arduino.upload.autoVerify': {
|
||||||
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/upload.autoVerify',
|
||||||
|
"True if the IDE should automatically verify the code before the upload. True by default. When this value is false, IDE does not recompile the code before uploading the binary to the board. It's highly advised to only set this value to false if you know what you are doing."
|
||||||
|
),
|
||||||
|
},
|
||||||
|
'arduino.window.autoScale': {
|
||||||
|
type: 'boolean',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/window.autoScale',
|
||||||
|
'True if the user interface automatically scales with the font size.'
|
||||||
|
),
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
'arduino.window.zoomLevel': {
|
||||||
|
type: 'number',
|
||||||
|
description: '',
|
||||||
|
default: 0,
|
||||||
|
deprecationMessage: nls.localize(
|
||||||
|
'arduino/preferences/window.zoomLevel/deprecationMessage',
|
||||||
|
"Deprecated. Use 'window.zoomLevel' instead."
|
||||||
|
),
|
||||||
|
},
|
||||||
|
'arduino.ide.updateChannel': {
|
||||||
|
type: 'string',
|
||||||
|
enum: Object.values(UpdateChannel) as UpdateChannel[],
|
||||||
|
default: UpdateChannel.Stable,
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/ide.updateChannel',
|
||||||
|
"Release channel to get updated from. 'stable' is the stable release, 'nightly' is the latest development build."
|
||||||
|
),
|
||||||
|
},
|
||||||
|
'arduino.ide.updateBaseUrl': {
|
||||||
|
type: 'string',
|
||||||
|
default: 'https://downloads.arduino.cc/arduino-ide',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/ide.updateBaseUrl',
|
||||||
|
"The base URL where to download updates from. Defaults to 'https://downloads.arduino.cc/arduino-ide'"
|
||||||
|
),
|
||||||
|
},
|
||||||
|
'arduino.board.certificates': {
|
||||||
|
type: 'string',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/board.certificates',
|
||||||
|
'List of certificates that can be uploaded to boards'
|
||||||
|
),
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
'arduino.sketchbook.showAllFiles': {
|
||||||
|
type: 'boolean',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/sketchbook.showAllFiles',
|
||||||
|
'True to show all sketch files inside the sketch. It is false by default.'
|
||||||
|
),
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
'arduino.cloud.enabled': {
|
||||||
|
type: 'boolean',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/cloud.enabled',
|
||||||
|
'True if the sketch sync functions are enabled. Defaults to true.'
|
||||||
|
),
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
'arduino.cloud.pull.warn': {
|
||||||
|
type: 'boolean',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/cloud.pull.warn',
|
||||||
|
'True if users should be warned before pulling a cloud sketch. Defaults to true.'
|
||||||
|
),
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
'arduino.cloud.push.warn': {
|
||||||
|
type: 'boolean',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/cloud.push.warn',
|
||||||
|
'True if users should be warned before pushing a cloud sketch. Defaults to true.'
|
||||||
|
),
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
'arduino.cloud.pushpublic.warn': {
|
||||||
|
type: 'boolean',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/cloud.pushpublic.warn',
|
||||||
|
'True if users should be warned before pushing a public sketch to the cloud. Defaults to true.'
|
||||||
|
),
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
'arduino.cloud.sketchSyncEndpoint': {
|
||||||
|
type: 'string',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/cloud.sketchSyncEndpoint',
|
||||||
|
'The endpoint used to push and pull sketches from a backend. By default it points to Arduino Cloud API.'
|
||||||
|
),
|
||||||
|
default: 'https://api2.arduino.cc/create',
|
||||||
|
},
|
||||||
|
'arduino.cloud.sharedSpaceID': {
|
||||||
|
type: 'string',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/cloud.sharedSpaceId',
|
||||||
|
'The ID of the Arduino Cloud shared space to load the sketchbook from. If empty, your private space is selected.'
|
||||||
|
),
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
'arduino.auth.clientID': {
|
||||||
|
type: 'string',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/auth.clientID',
|
||||||
|
'The OAuth2 client ID.'
|
||||||
|
),
|
||||||
|
default: 'C34Ya6ex77jTNxyKWj01lCe1vAHIaPIo',
|
||||||
|
},
|
||||||
|
'arduino.auth.domain': {
|
||||||
|
type: 'string',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/auth.domain',
|
||||||
|
'The OAuth2 domain.'
|
||||||
|
),
|
||||||
|
default: 'login.arduino.cc',
|
||||||
|
},
|
||||||
|
'arduino.auth.audience': {
|
||||||
|
type: 'string',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/auth.audience',
|
||||||
|
'The OAuth2 audience.'
|
||||||
|
),
|
||||||
|
default: 'https://api.arduino.cc',
|
||||||
|
},
|
||||||
|
'arduino.auth.registerUri': {
|
||||||
|
type: 'string',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/auth.registerUri',
|
||||||
|
'The URI used to register a new user.'
|
||||||
|
),
|
||||||
|
default: 'https://auth.arduino.cc/login#/register',
|
||||||
|
},
|
||||||
|
'arduino.cli.daemon.debug': {
|
||||||
|
type: 'boolean',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/cli.daemonDebug',
|
||||||
|
"Enable debug logging of the gRPC calls to the Arduino CLI. A restart of the IDE is needed for this setting to take effect. It's false by default."
|
||||||
|
),
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
'arduino.checkForUpdates': {
|
||||||
|
type: 'boolean',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/checkForUpdate',
|
||||||
|
"Receive notifications of available updates for the IDE, boards, and libraries. Requires an IDE restart after change. It's true by default."
|
||||||
|
),
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
'arduino.sketch.inoBlueprint': {
|
||||||
|
type: 'string',
|
||||||
|
markdownDescription: nls.localize(
|
||||||
|
'arduino/preferences/sketch/inoBlueprint',
|
||||||
|
'Absolute filesystem path to the default `.ino` blueprint file. If specified, the content of the blueprint file will be used for every new sketch created by the IDE. The sketches will be generated with the default Arduino content if not specified. Unaccessible blueprint files are ignored. **A restart of the IDE is needed** for this setting to take effect.'
|
||||||
|
),
|
||||||
|
default: undefined,
|
||||||
|
},
|
||||||
|
'arduino.monitor.dockPanel': {
|
||||||
|
type: 'string',
|
||||||
|
enum: ['bottom', 'right'],
|
||||||
|
markdownDescription: nls.localize(
|
||||||
|
'arduino/preferences/monitor/dockPanel',
|
||||||
|
'The area of the application shell where the _{0}_ widget will reside. It is either "bottom" or "right". It defaults to "{1}".',
|
||||||
|
serialMonitorWidgetLabel,
|
||||||
|
defaultMonitorWidgetDockPanel
|
||||||
|
),
|
||||||
|
default: defaultMonitorWidgetDockPanel,
|
||||||
|
},
|
||||||
|
};
|
||||||
export const ArduinoConfigSchema: PreferenceSchema = {
|
export const ArduinoConfigSchema: PreferenceSchema = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties,
|
||||||
'arduino.language.log': {
|
|
||||||
type: 'boolean',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/language.log',
|
|
||||||
"True if the Arduino Language Server should generate log files into the sketch folder. Otherwise, false. It's false by default."
|
|
||||||
),
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
'arduino.compile.verbose': {
|
|
||||||
type: 'boolean',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/compile.verbose',
|
|
||||||
'True for verbose compile output. False by default'
|
|
||||||
),
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
'arduino.compile.warnings': {
|
|
||||||
enum: [...CompilerWarningLiterals],
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/compile.warnings',
|
|
||||||
"Tells gcc which warning level to use. It's 'None' by default"
|
|
||||||
),
|
|
||||||
default: 'None',
|
|
||||||
},
|
|
||||||
'arduino.upload.verbose': {
|
|
||||||
type: 'boolean',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/upload.verbose',
|
|
||||||
'True for verbose upload output. False by default.'
|
|
||||||
),
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
'arduino.upload.verify': {
|
|
||||||
type: 'boolean',
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
'arduino.window.autoScale': {
|
|
||||||
type: 'boolean',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/window.autoScale',
|
|
||||||
'True if the user interface automatically scales with the font size.'
|
|
||||||
),
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
'arduino.window.zoomLevel': {
|
|
||||||
type: 'number',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/window.zoomLevel',
|
|
||||||
'Adjust the zoom level of the window. The original size is 0 and each increment above (e.g. 1) or below (e.g. -1) represents zooming 20% larger or smaller. You can also enter decimals to adjust the zoom level with a finer granularity.'
|
|
||||||
),
|
|
||||||
default: 0,
|
|
||||||
},
|
|
||||||
'arduino.ide.updateChannel': {
|
|
||||||
type: 'string',
|
|
||||||
enum: Object.values(UpdateChannel) as UpdateChannel[],
|
|
||||||
default: UpdateChannel.Stable,
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/ide.updateChannel',
|
|
||||||
"Release channel to get updated from. 'stable' is the stable release, 'nightly' is the latest development build."
|
|
||||||
),
|
|
||||||
},
|
|
||||||
'arduino.ide.updateBaseUrl': {
|
|
||||||
type: 'string',
|
|
||||||
default: 'https://downloads.arduino.cc/arduino-ide',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/ide.updateBaseUrl',
|
|
||||||
`The base URL where to download updates from. Defaults to 'https://downloads.arduino.cc/arduino-ide'`
|
|
||||||
),
|
|
||||||
},
|
|
||||||
'arduino.board.certificates': {
|
|
||||||
type: 'string',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/board.certificates',
|
|
||||||
'List of certificates that can be uploaded to boards'
|
|
||||||
),
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
'arduino.sketchbook.showAllFiles': {
|
|
||||||
type: 'boolean',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/sketchbook.showAllFiles',
|
|
||||||
'True to show all sketch files inside the sketch. It is false by default.'
|
|
||||||
),
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
'arduino.cloud.enabled': {
|
|
||||||
type: 'boolean',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/cloud.enabled',
|
|
||||||
'True if the sketch sync functions are enabled. Defaults to true.'
|
|
||||||
),
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
'arduino.cloud.pull.warn': {
|
|
||||||
type: 'boolean',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/cloud.pull.warn',
|
|
||||||
'True if users should be warned before pulling a cloud sketch. Defaults to true.'
|
|
||||||
),
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
'arduino.cloud.push.warn': {
|
|
||||||
type: 'boolean',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/cloud.push.warn',
|
|
||||||
'True if users should be warned before pushing a cloud sketch. Defaults to true.'
|
|
||||||
),
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
'arduino.cloud.pushpublic.warn': {
|
|
||||||
type: 'boolean',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/cloud.pushpublic.warn',
|
|
||||||
'True if users should be warned before pushing a public sketch to the cloud. Defaults to true.'
|
|
||||||
),
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
'arduino.cloud.sketchSyncEnpoint': {
|
|
||||||
type: 'string',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/cloud.sketchSyncEnpoint',
|
|
||||||
'The endpoint used to push and pull sketches from a backend. By default it points to Arduino Cloud API.'
|
|
||||||
),
|
|
||||||
default: 'https://api2.arduino.cc/create',
|
|
||||||
},
|
|
||||||
'arduino.auth.clientID': {
|
|
||||||
type: 'string',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/auth.clientID',
|
|
||||||
'The OAuth2 client ID.'
|
|
||||||
),
|
|
||||||
default: 'C34Ya6ex77jTNxyKWj01lCe1vAHIaPIo',
|
|
||||||
},
|
|
||||||
'arduino.auth.domain': {
|
|
||||||
type: 'string',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/auth.domain',
|
|
||||||
'The OAuth2 domain.'
|
|
||||||
),
|
|
||||||
default: 'login.arduino.cc',
|
|
||||||
},
|
|
||||||
'arduino.auth.audience': {
|
|
||||||
type: 'string',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/auth.audience',
|
|
||||||
'The OAuth2 audience.'
|
|
||||||
),
|
|
||||||
default: 'https://api.arduino.cc',
|
|
||||||
},
|
|
||||||
'arduino.auth.registerUri': {
|
|
||||||
type: 'string',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/auth.registerUri',
|
|
||||||
'The URI used to register a new user.'
|
|
||||||
),
|
|
||||||
default: 'https://auth.arduino.cc/login#/register',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ArduinoConfiguration {
|
export interface ArduinoConfiguration {
|
||||||
'arduino.language.log': boolean;
|
'arduino.language.log': boolean;
|
||||||
|
'arduino.language.realTimeDiagnostics': boolean;
|
||||||
|
'arduino.language.asyncWorkers': number;
|
||||||
'arduino.compile.verbose': boolean;
|
'arduino.compile.verbose': boolean;
|
||||||
|
'arduino.compile.experimental': boolean;
|
||||||
|
'arduino.compile.revealRange': ErrorRevealStrategy;
|
||||||
'arduino.compile.warnings': CompilerWarnings;
|
'arduino.compile.warnings': CompilerWarnings;
|
||||||
'arduino.upload.verbose': boolean;
|
'arduino.upload.verbose': boolean;
|
||||||
'arduino.upload.verify': boolean;
|
'arduino.upload.verify': boolean;
|
||||||
|
'arduino.upload.autoVerify': boolean;
|
||||||
'arduino.window.autoScale': boolean;
|
'arduino.window.autoScale': boolean;
|
||||||
'arduino.window.zoomLevel': number;
|
|
||||||
'arduino.ide.updateChannel': UpdateChannel;
|
'arduino.ide.updateChannel': UpdateChannel;
|
||||||
'arduino.ide.updateBaseUrl': string;
|
'arduino.ide.updateBaseUrl': string;
|
||||||
'arduino.board.certificates': string;
|
'arduino.board.certificates': string;
|
||||||
@@ -193,11 +341,16 @@ export interface ArduinoConfiguration {
|
|||||||
'arduino.cloud.pull.warn': boolean;
|
'arduino.cloud.pull.warn': boolean;
|
||||||
'arduino.cloud.push.warn': boolean;
|
'arduino.cloud.push.warn': boolean;
|
||||||
'arduino.cloud.pushpublic.warn': boolean;
|
'arduino.cloud.pushpublic.warn': boolean;
|
||||||
'arduino.cloud.sketchSyncEnpoint': string;
|
'arduino.cloud.sketchSyncEndpoint': string;
|
||||||
|
'arduino.cloud.sharedSpaceID': string;
|
||||||
'arduino.auth.clientID': string;
|
'arduino.auth.clientID': string;
|
||||||
'arduino.auth.domain': string;
|
'arduino.auth.domain': string;
|
||||||
'arduino.auth.audience': string;
|
'arduino.auth.audience': string;
|
||||||
'arduino.auth.registerUri': string;
|
'arduino.auth.registerUri': string;
|
||||||
|
'arduino.cli.daemon.debug': boolean;
|
||||||
|
'arduino.sketch.inoBlueprint': string;
|
||||||
|
'arduino.checkForUpdates': boolean;
|
||||||
|
'arduino.monitor.dockPanel': MonitorWidgetDockPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ArduinoPreferences = Symbol('ArduinoPreferences');
|
export const ArduinoPreferences = Symbol('ArduinoPreferences');
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
import { URI } from '@theia/core/shared/vscode-uri';
|
|
||||||
import { isWindows } from '@theia/core/lib/common/os';
|
|
||||||
import { notEmpty } from '@theia/core/lib/common/objects';
|
|
||||||
import { MaybePromise } from '@theia/core/lib/common/types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class for determining the default workspace location from the
|
|
||||||
* `location.hash`, the historical workspace locations, and recent sketch files.
|
|
||||||
*
|
|
||||||
* The following logic is used for determining the default workspace location:
|
|
||||||
* - `hash` points to an existing location?
|
|
||||||
* - Yes
|
|
||||||
* - `validate location`. Is valid sketch location?
|
|
||||||
* - Yes
|
|
||||||
* - Done.
|
|
||||||
* - No
|
|
||||||
* - `try open recent workspace roots`, then `try open last modified sketches`, finally `create new sketch`.
|
|
||||||
* - No
|
|
||||||
* - `try open recent workspace roots`, then `try open last modified sketches`, finally `create new sketch`.
|
|
||||||
*/
|
|
||||||
namespace ArduinoWorkspaceRootResolver {
|
|
||||||
export interface InitOptions {
|
|
||||||
readonly isValid: (uri: string) => MaybePromise<boolean>;
|
|
||||||
}
|
|
||||||
export interface ResolveOptions {
|
|
||||||
readonly hash?: string;
|
|
||||||
readonly recentWorkspaces: string[];
|
|
||||||
// Gathered from the default sketch folder. The default sketch folder is defined by the CLI.
|
|
||||||
readonly recentSketches: string[];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export class ArduinoWorkspaceRootResolver {
|
|
||||||
constructor(protected options: ArduinoWorkspaceRootResolver.InitOptions) {}
|
|
||||||
|
|
||||||
async resolve(
|
|
||||||
options: ArduinoWorkspaceRootResolver.ResolveOptions
|
|
||||||
): Promise<{ uri: string } | undefined> {
|
|
||||||
const { hash, recentWorkspaces, recentSketches } = options;
|
|
||||||
for (const uri of [
|
|
||||||
this.hashToUri(hash),
|
|
||||||
...recentWorkspaces,
|
|
||||||
...recentSketches,
|
|
||||||
].filter(notEmpty)) {
|
|
||||||
const valid = await this.isValid(uri);
|
|
||||||
if (valid) {
|
|
||||||
return { uri };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected isValid(uri: string): MaybePromise<boolean> {
|
|
||||||
return this.options.isValid(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: here, the `hash` was defined as new `URI(yourValidFsPath).path` so we have to map it to a valid FS path first.
|
|
||||||
// This is important for Windows only and a NOOP on POSIX.
|
|
||||||
// Note: we set the `new URI(myValidUri).path.toString()` as the `hash`. See:
|
|
||||||
// - https://github.com/eclipse-theia/theia/blob/8196e9dcf9c8de8ea0910efeb5334a974f426966/packages/workspace/src/browser/workspace-service.ts#L143 and
|
|
||||||
// - https://github.com/eclipse-theia/theia/blob/8196e9dcf9c8de8ea0910efeb5334a974f426966/packages/workspace/src/browser/workspace-service.ts#L423
|
|
||||||
protected hashToUri(hash: string | undefined): string | undefined {
|
|
||||||
if (hash && hash.length > 1 && hash.startsWith('#')) {
|
|
||||||
const path = decodeURI(hash.slice(1)).replace(/\\/g, '/'); // Trim the leading `#`, decode the URI and replace Windows separators
|
|
||||||
return URI.file(path.slice(isWindows && hash.startsWith('/') ? 1 : 0)).toString();
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
import { inject, injectable } from 'inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { Emitter } from '@theia/core/lib/common/event';
|
import { Emitter } from '@theia/core/lib/common/event';
|
||||||
import { JsonRpcProxy } from '@theia/core/lib/common/messaging/proxy-factory';
|
import { JsonRpcProxy } from '@theia/core/lib/common/messaging/proxy-factory';
|
||||||
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
||||||
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
||||||
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application';
|
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution';
|
||||||
import {
|
import {
|
||||||
CommandRegistry,
|
CommandRegistry,
|
||||||
CommandContribution,
|
CommandContribution,
|
||||||
} from '@theia/core/lib/common/command';
|
} from '@theia/core/lib/common/command';
|
||||||
import {
|
import {
|
||||||
|
AuthOptions,
|
||||||
AuthenticationService,
|
AuthenticationService,
|
||||||
AuthenticationServiceClient,
|
AuthenticationServiceClient,
|
||||||
AuthenticationSession,
|
AuthenticationSession,
|
||||||
|
authServerPort,
|
||||||
} from '../../common/protocol/authentication-service';
|
} from '../../common/protocol/authentication-service';
|
||||||
import { CloudUserCommands } from './cloud-user-commands';
|
import { CloudUserCommands } from './cloud-user-commands';
|
||||||
import { serverPort } from '../../node/auth/authentication-server';
|
|
||||||
import { AuthOptions } from '../../node/auth/types';
|
|
||||||
import { ArduinoPreferences } from '../arduino-preferences';
|
import { ArduinoPreferences } from '../arduino-preferences';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
@@ -43,13 +43,15 @@ export class AuthenticationClientService
|
|||||||
|
|
||||||
readonly onSessionDidChange = this.onSessionDidChangeEmitter.event;
|
readonly onSessionDidChange = this.onSessionDidChangeEmitter.event;
|
||||||
|
|
||||||
onStart(): void {
|
async onStart(): Promise<void> {
|
||||||
this.toDispose.push(this.onSessionDidChangeEmitter);
|
this.toDispose.push(this.onSessionDidChangeEmitter);
|
||||||
this.service.setClient(this);
|
this.service.setClient(this);
|
||||||
this.service
|
this.service
|
||||||
.session()
|
.session()
|
||||||
.then((session) => this.notifySessionDidChange(session));
|
.then((session) => this.notifySessionDidChange(session));
|
||||||
this.setOptions();
|
|
||||||
|
this.setOptions().then(() => this.service.initAuthSession());
|
||||||
|
|
||||||
this.arduinoPreferences.onPreferenceChanged((event) => {
|
this.arduinoPreferences.onPreferenceChanged((event) => {
|
||||||
if (event.preferenceName.startsWith('arduino.auth.')) {
|
if (event.preferenceName.startsWith('arduino.auth.')) {
|
||||||
this.setOptions();
|
this.setOptions();
|
||||||
@@ -57,9 +59,9 @@ export class AuthenticationClientService
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setOptions(): void {
|
setOptions(): Promise<void> {
|
||||||
this.service.setOptions({
|
return this.service.setOptions({
|
||||||
redirectUri: `http://localhost:${serverPort}/callback`,
|
redirectUri: `http://localhost:${authServerPort}/callback`,
|
||||||
responseType: 'code',
|
responseType: 'code',
|
||||||
clientID: this.arduinoPreferences['arduino.auth.clientID'],
|
clientID: this.arduinoPreferences['arduino.auth.clientID'],
|
||||||
domain: this.arduinoPreferences['arduino.auth.domain'],
|
domain: this.arduinoPreferences['arduino.auth.domain'],
|
||||||
@@ -81,9 +83,13 @@ export class AuthenticationClientService
|
|||||||
registerCommands(registry: CommandRegistry): void {
|
registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(CloudUserCommands.LOGIN, {
|
registry.registerCommand(CloudUserCommands.LOGIN, {
|
||||||
execute: () => this.service.login(),
|
execute: () => this.service.login(),
|
||||||
|
isEnabled: () => !this._session,
|
||||||
|
isVisible: () => !this._session,
|
||||||
});
|
});
|
||||||
registry.registerCommand(CloudUserCommands.LOGOUT, {
|
registry.registerCommand(CloudUserCommands.LOGOUT, {
|
||||||
execute: () => this.service.logout(),
|
execute: () => this.service.logout(),
|
||||||
|
isEnabled: () => !!this._session,
|
||||||
|
isVisible: () => !!this._session,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { Command } from '@theia/core/lib/common/command';
|
import { Command } from '@theia/core/lib/common/command';
|
||||||
|
|
||||||
|
export const LEARN_MORE_URL =
|
||||||
|
'https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-cloud-sketch-sync';
|
||||||
|
|
||||||
export namespace CloudUserCommands {
|
export namespace CloudUserCommands {
|
||||||
export const LOGIN = Command.toLocalizedCommand(
|
export const LOGIN = Command.toLocalizedCommand(
|
||||||
{
|
{
|
||||||
@@ -16,9 +19,4 @@ export namespace CloudUserCommands {
|
|||||||
},
|
},
|
||||||
'arduino/cloud/signOut'
|
'arduino/cloud/signOut'
|
||||||
);
|
);
|
||||||
|
|
||||||
export const OPEN_PROFILE_CONTEXT_MENU: Command = {
|
|
||||||
id: 'arduino-cloud-sketchbook--open-profile-menu',
|
|
||||||
label: 'Contextual menu',
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,132 +1,229 @@
|
|||||||
import { injectable, inject } from 'inversify';
|
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution';
|
||||||
|
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
||||||
import { MessageService } from '@theia/core/lib/common/message-service';
|
import { MessageService } from '@theia/core/lib/common/message-service';
|
||||||
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application';
|
import { MessageType } from '@theia/core/lib/common/message-service-protocol';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { notEmpty } from '@theia/core/lib/common/objects';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { NotificationManager } from '@theia/messages/lib/browser/notifications-manager';
|
||||||
|
import { InstallManually } from '../../common/nls';
|
||||||
|
import { Installable, ResponseServiceClient } from '../../common/protocol';
|
||||||
import {
|
import {
|
||||||
BoardsService,
|
BoardIdentifier,
|
||||||
BoardsPackage,
|
BoardsPackage,
|
||||||
Board,
|
BoardsService,
|
||||||
|
createPlatformIdentifier,
|
||||||
|
isBoardIdentifierChangeEvent,
|
||||||
|
PlatformIdentifier,
|
||||||
|
platformIdentifierEquals,
|
||||||
|
serializePlatformIdentifier,
|
||||||
} from '../../common/protocol/boards-service';
|
} from '../../common/protocol/boards-service';
|
||||||
|
import { NotificationCenter } from '../notification-center';
|
||||||
import { BoardsServiceProvider } from './boards-service-provider';
|
import { BoardsServiceProvider } from './boards-service-provider';
|
||||||
import { BoardsConfig } from './boards-config';
|
|
||||||
import { Installable, ResponseServiceArduino } from '../../common/protocol';
|
|
||||||
import { BoardsListWidgetFrontendContribution } from './boards-widget-frontend-contribution';
|
import { BoardsListWidgetFrontendContribution } from './boards-widget-frontend-contribution';
|
||||||
import { nls } from '@theia/core/lib/common';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listens on `BoardsConfig.Config` changes, if a board is selected which does not
|
* Listens on `BoardsConfigChangeEvent`s, if a board is selected which does not
|
||||||
* have the corresponding core installed, it proposes the user to install the core.
|
* have the corresponding core installed, it proposes the user to install the core.
|
||||||
*/
|
*/
|
||||||
@injectable()
|
@injectable()
|
||||||
export class BoardsAutoInstaller implements FrontendApplicationContribution {
|
export class BoardsAutoInstaller implements FrontendApplicationContribution {
|
||||||
|
@inject(NotificationCenter)
|
||||||
|
private readonly notificationCenter: NotificationCenter;
|
||||||
@inject(MessageService)
|
@inject(MessageService)
|
||||||
protected readonly messageService: MessageService;
|
private readonly messageService: MessageService;
|
||||||
|
@inject(NotificationManager)
|
||||||
|
private readonly notificationManager: NotificationManager;
|
||||||
@inject(BoardsService)
|
@inject(BoardsService)
|
||||||
protected readonly boardsService: BoardsService;
|
private readonly boardsService: BoardsService;
|
||||||
|
|
||||||
@inject(BoardsServiceProvider)
|
@inject(BoardsServiceProvider)
|
||||||
protected readonly boardsServiceClient: BoardsServiceProvider;
|
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
@inject(ResponseServiceClient)
|
||||||
@inject(ResponseServiceArduino)
|
private readonly responseService: ResponseServiceClient;
|
||||||
protected readonly responseService: ResponseServiceArduino;
|
|
||||||
|
|
||||||
@inject(BoardsListWidgetFrontendContribution)
|
@inject(BoardsListWidgetFrontendContribution)
|
||||||
protected readonly boardsManagerFrontendContribution: BoardsListWidgetFrontendContribution;
|
private readonly boardsManagerWidgetContribution: BoardsListWidgetFrontendContribution;
|
||||||
|
|
||||||
// Workaround for https://github.com/eclipse-theia/theia/issues/9349
|
// Workaround for https://github.com/eclipse-theia/theia/issues/9349
|
||||||
protected notifications: Board[] = [];
|
private readonly installNotificationInfos: Readonly<{
|
||||||
|
boardName: string;
|
||||||
|
platformId: string;
|
||||||
|
notificationId: string;
|
||||||
|
}>[] = [];
|
||||||
|
private readonly toDispose = new DisposableCollection();
|
||||||
|
|
||||||
onStart(): void {
|
onStart(): void {
|
||||||
this.boardsServiceClient.onBoardsConfigChanged(
|
this.toDispose.pushAll([
|
||||||
this.ensureCoreExists.bind(this)
|
this.boardsServiceProvider.onBoardsConfigDidChange((event) => {
|
||||||
);
|
if (isBoardIdentifierChangeEvent(event)) {
|
||||||
this.ensureCoreExists(this.boardsServiceClient.boardsConfig);
|
this.ensureCoreExists(event.selectedBoard);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
this.notificationCenter.onPlatformDidInstall((event) =>
|
||||||
|
this.clearAllNotificationForPlatform(event.item.id)
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
this.boardsServiceProvider.ready.then(() => {
|
||||||
|
const { selectedBoard } = this.boardsServiceProvider.boardsConfig;
|
||||||
|
this.ensureCoreExists(selectedBoard);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ensureCoreExists(config: BoardsConfig.Config): void {
|
private async findPlatformToInstall(
|
||||||
const { selectedBoard, selectedPort } = config;
|
selectedBoard: BoardIdentifier
|
||||||
if (
|
): Promise<BoardsPackage | undefined> {
|
||||||
selectedBoard &&
|
const platformId = await this.findPlatformIdToInstall(selectedBoard);
|
||||||
selectedPort &&
|
if (!platformId) {
|
||||||
!this.notifications.find((board) => Board.sameAs(board, selectedBoard))
|
return undefined;
|
||||||
) {
|
}
|
||||||
this.notifications.push(selectedBoard);
|
const id = serializePlatformIdentifier(platformId);
|
||||||
this.boardsService.search({}).then((packages) => {
|
const platform = await this.boardsService.getBoardPackage({ id });
|
||||||
// filter packagesForBoard selecting matches from the cli (installed packages)
|
if (!platform) {
|
||||||
// and matches based on the board name
|
console.warn(`Could not resolve platform for ID: ${id}`);
|
||||||
// NOTE: this ensures the Deprecated & new packages are all in the array
|
return undefined;
|
||||||
// so that we can check if any of the valid packages is already installed
|
}
|
||||||
const packagesForBoard = packages.filter(
|
if (platform.installedVersion) {
|
||||||
(pkg) =>
|
return undefined;
|
||||||
BoardsPackage.contains(selectedBoard, pkg) ||
|
}
|
||||||
pkg.boards.some((board) => board.name === selectedBoard.name)
|
return platform;
|
||||||
);
|
}
|
||||||
|
|
||||||
// check if one of the packages for the board is already installed. if so, no hint
|
private async findPlatformIdToInstall(
|
||||||
if (
|
selectedBoard: BoardIdentifier
|
||||||
packagesForBoard.some(({ installedVersion }) => !!installedVersion)
|
): Promise<PlatformIdentifier | undefined> {
|
||||||
) {
|
const selectedBoardPlatformId = createPlatformIdentifier(selectedBoard);
|
||||||
return;
|
// The board is installed or the FQBN is available from the `board list watch` for Arduino boards. The latter might change!
|
||||||
}
|
if (selectedBoardPlatformId) {
|
||||||
|
const installedPlatforms =
|
||||||
// filter the installable (not installed) packages,
|
await this.boardsService.getInstalledPlatforms();
|
||||||
// CLI returns the packages already sorted with the deprecated ones at the end of the list
|
const installedPlatformIds = installedPlatforms
|
||||||
// in order to ensure the new ones are preferred
|
.map((platform) => createPlatformIdentifier(platform.id))
|
||||||
const candidates = packagesForBoard.filter(
|
.filter(notEmpty);
|
||||||
({ installable, installedVersion }) =>
|
if (
|
||||||
installable && !installedVersion
|
installedPlatformIds.every(
|
||||||
);
|
(installedPlatformId) =>
|
||||||
|
!platformIdentifierEquals(
|
||||||
const candidate = candidates[0];
|
installedPlatformId,
|
||||||
if (candidate) {
|
selectedBoardPlatformId
|
||||||
const version = candidate.availableVersions[0]
|
|
||||||
? `[v ${candidate.availableVersions[0]}]`
|
|
||||||
: '';
|
|
||||||
const yes = nls.localize('vscode/extensionsUtils/yes', 'Yes');
|
|
||||||
const manualInstall = nls.localize(
|
|
||||||
'arduino/board/installManually',
|
|
||||||
'Install Manually'
|
|
||||||
);
|
|
||||||
// tslint:disable-next-line:max-line-length
|
|
||||||
this.messageService
|
|
||||||
.info(
|
|
||||||
nls.localize(
|
|
||||||
'arduino/board/installNow',
|
|
||||||
'The "{0} {1}" core has to be installed for the currently selected "{2}" board. Do you want to install it now?',
|
|
||||||
candidate.name,
|
|
||||||
version,
|
|
||||||
selectedBoard.name
|
|
||||||
),
|
|
||||||
manualInstall,
|
|
||||||
yes
|
|
||||||
)
|
)
|
||||||
.then(async (answer) => {
|
)
|
||||||
const index = this.notifications.findIndex((board) =>
|
) {
|
||||||
Board.sameAs(board, selectedBoard)
|
return selectedBoardPlatformId;
|
||||||
);
|
}
|
||||||
if (index !== -1) {
|
} else {
|
||||||
this.notifications.splice(index, 1);
|
// IDE2 knows that selected board is not installed. Look for board `name` match in not yet installed platforms.
|
||||||
}
|
// The order should be correct when there is a board name collision (e.g. Arduino Nano RP2040 from Arduino Mbed OS Nano Boards, [DEPRECATED] Arduino Mbed OS Nano Boards). The CLI boosts the platforms, so picking the first name match should be fine.
|
||||||
if (answer === yes) {
|
const platforms = await this.boardsService.search({});
|
||||||
await Installable.installWithProgress({
|
for (const platform of platforms) {
|
||||||
installable: this.boardsService,
|
// Ignore installed platforms
|
||||||
item: candidate,
|
if (platform.installedVersion) {
|
||||||
messageService: this.messageService,
|
continue;
|
||||||
responseService: this.responseService,
|
|
||||||
version: candidate.availableVersions[0],
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (answer === manualInstall) {
|
|
||||||
this.boardsManagerFrontendContribution
|
|
||||||
.openView({ reveal: true })
|
|
||||||
.then((widget) =>
|
|
||||||
widget.refresh(candidate.name.toLocaleLowerCase())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
if (
|
||||||
|
platform.boards.some((board) => board.name === selectedBoard.name)
|
||||||
|
) {
|
||||||
|
const platformId = createPlatformIdentifier(platform.id);
|
||||||
|
if (platformId) {
|
||||||
|
return platformId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async ensureCoreExists(
|
||||||
|
selectedBoard: BoardIdentifier | undefined
|
||||||
|
): Promise<void> {
|
||||||
|
if (!selectedBoard) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const candidate = await this.findPlatformToInstall(selectedBoard);
|
||||||
|
if (!candidate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const platformIdToInstall = candidate.id;
|
||||||
|
const selectedBoardName = selectedBoard.name;
|
||||||
|
if (
|
||||||
|
this.installNotificationInfos.some(
|
||||||
|
({ boardName, platformId }) =>
|
||||||
|
platformIdToInstall === platformId && selectedBoardName === boardName
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
// Already has a notification for the board with the same platform. Nothing to do.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.clearAllNotificationForPlatform(platformIdToInstall);
|
||||||
|
|
||||||
|
const version = candidate.availableVersions[0]
|
||||||
|
? `[v ${candidate.availableVersions[0]}]`
|
||||||
|
: '';
|
||||||
|
const yes = nls.localize('vscode/extensionsUtils/yes', 'Yes');
|
||||||
|
const message = nls.localize(
|
||||||
|
'arduino/board/installNow',
|
||||||
|
'The "{0} {1}" core has to be installed for the currently selected "{2}" board. Do you want to install it now?',
|
||||||
|
candidate.name,
|
||||||
|
version,
|
||||||
|
selectedBoard.name
|
||||||
|
);
|
||||||
|
const notificationId = this.notificationId(message, InstallManually, yes);
|
||||||
|
this.installNotificationInfos.push({
|
||||||
|
boardName: selectedBoardName,
|
||||||
|
platformId: platformIdToInstall,
|
||||||
|
notificationId,
|
||||||
|
});
|
||||||
|
const answer = await this.messageService.info(
|
||||||
|
message,
|
||||||
|
InstallManually,
|
||||||
|
yes
|
||||||
|
);
|
||||||
|
if (answer) {
|
||||||
|
const index = this.installNotificationInfos.findIndex(
|
||||||
|
({ boardName, platformId }) =>
|
||||||
|
platformIdToInstall === platformId && selectedBoardName === boardName
|
||||||
|
);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.installNotificationInfos.splice(index, 1);
|
||||||
|
}
|
||||||
|
if (answer === yes) {
|
||||||
|
await Installable.installWithProgress({
|
||||||
|
installable: this.boardsService,
|
||||||
|
item: candidate,
|
||||||
|
messageService: this.messageService,
|
||||||
|
responseService: this.responseService,
|
||||||
|
version: candidate.availableVersions[0],
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (answer === InstallManually) {
|
||||||
|
this.boardsManagerWidgetContribution
|
||||||
|
.openView({ reveal: true })
|
||||||
|
.then((widget) =>
|
||||||
|
widget.refresh({
|
||||||
|
query: candidate.name.toLocaleLowerCase(),
|
||||||
|
type: 'All',
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private clearAllNotificationForPlatform(predicatePlatformId: string): void {
|
||||||
|
// Discard all install notifications for the same platform.
|
||||||
|
const notificationsLength = this.installNotificationInfos.length;
|
||||||
|
for (let i = notificationsLength - 1; i >= 0; i--) {
|
||||||
|
const { notificationId, platformId } = this.installNotificationInfos[i];
|
||||||
|
if (platformId === predicatePlatformId) {
|
||||||
|
this.installNotificationInfos.splice(i, 1);
|
||||||
|
this.notificationManager.clear(notificationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private notificationId(message: string, ...actions: string[]): string {
|
||||||
|
return this.notificationManager['getMessageId']({
|
||||||
|
text: message,
|
||||||
|
actions,
|
||||||
|
type: MessageType.Info,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,345 @@
|
|||||||
|
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
||||||
|
import { Event } from '@theia/core/lib/common/event';
|
||||||
|
import { FrontendApplicationState } from '@theia/core/lib/common/frontend-application-state';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import React from '@theia/core/shared/react';
|
||||||
|
import { EditBoardsConfigActionParams } from '../../common/protocol/board-list';
|
||||||
|
import {
|
||||||
|
Board,
|
||||||
|
BoardIdentifier,
|
||||||
|
BoardWithPackage,
|
||||||
|
DetectedPort,
|
||||||
|
findMatchingPortIndex,
|
||||||
|
Port,
|
||||||
|
PortIdentifier,
|
||||||
|
} from '../../common/protocol/boards-service';
|
||||||
|
import type { Defined } from '../../common/types';
|
||||||
|
import { NotificationCenter } from '../notification-center';
|
||||||
|
import { BoardsConfigDialogState } from './boards-config-dialog';
|
||||||
|
|
||||||
|
namespace BoardsConfigComponent {
|
||||||
|
export interface Props {
|
||||||
|
/**
|
||||||
|
* This is not the real config, it's only living in the dialog. Users can change it without update and can cancel any modifications.
|
||||||
|
*/
|
||||||
|
readonly boardsConfig: BoardsConfigDialogState;
|
||||||
|
readonly searchSet: BoardIdentifier[] | undefined;
|
||||||
|
readonly notificationCenter: NotificationCenter;
|
||||||
|
readonly appState: FrontendApplicationState;
|
||||||
|
readonly onFocusNodeSet: (element: HTMLElement | undefined) => void;
|
||||||
|
readonly onFilteredTextDidChangeEvent: Event<
|
||||||
|
Defined<EditBoardsConfigActionParams['query']>
|
||||||
|
>;
|
||||||
|
readonly onAppStateDidChange: Event<FrontendApplicationState>;
|
||||||
|
readonly onBoardSelected: (board: BoardIdentifier) => void;
|
||||||
|
readonly onPortSelected: (port: PortIdentifier) => void;
|
||||||
|
readonly searchBoards: (query?: {
|
||||||
|
query?: string;
|
||||||
|
}) => Promise<BoardWithPackage[]>;
|
||||||
|
readonly ports: (
|
||||||
|
predicate?: (port: DetectedPort) => boolean
|
||||||
|
) => readonly DetectedPort[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface State {
|
||||||
|
searchResults: Array<BoardWithPackage>;
|
||||||
|
showAllPorts: boolean;
|
||||||
|
query: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Item<T> extends React.Component<{
|
||||||
|
item: T;
|
||||||
|
label: string;
|
||||||
|
selected: boolean;
|
||||||
|
onClick: (item: T) => void;
|
||||||
|
missing?: boolean;
|
||||||
|
details?: string;
|
||||||
|
title?: string | ((item: T) => string);
|
||||||
|
}> {
|
||||||
|
override render(): React.ReactNode {
|
||||||
|
const { selected, label, missing, details, item } = this.props;
|
||||||
|
const classNames = ['item'];
|
||||||
|
if (selected) {
|
||||||
|
classNames.push('selected');
|
||||||
|
}
|
||||||
|
if (missing === true) {
|
||||||
|
classNames.push('missing');
|
||||||
|
}
|
||||||
|
let title = this.props.title ?? `${label}${!details ? '' : details}`;
|
||||||
|
if (typeof title === 'function') {
|
||||||
|
title = title(item);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
onClick={this.onClick}
|
||||||
|
className={classNames.join(' ')}
|
||||||
|
title={title}
|
||||||
|
>
|
||||||
|
<div className="label">{label}</div>
|
||||||
|
{!details ? '' : <div className="details">{details}</div>}
|
||||||
|
{!selected ? (
|
||||||
|
''
|
||||||
|
) : (
|
||||||
|
<div className="selected-icon">
|
||||||
|
<i className="fa fa-check" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly onClick = () => {
|
||||||
|
this.props.onClick(this.props.item);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export class BoardsConfigComponent extends React.Component<
|
||||||
|
BoardsConfigComponent.Props,
|
||||||
|
BoardsConfigComponent.State
|
||||||
|
> {
|
||||||
|
private readonly toDispose: DisposableCollection;
|
||||||
|
|
||||||
|
constructor(props: BoardsConfigComponent.Props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
searchResults: [],
|
||||||
|
showAllPorts: false,
|
||||||
|
query: '',
|
||||||
|
};
|
||||||
|
this.toDispose = new DisposableCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
override componentDidMount(): void {
|
||||||
|
this.toDispose.pushAll([
|
||||||
|
this.props.onAppStateDidChange(async (state) => {
|
||||||
|
if (state === 'ready') {
|
||||||
|
const searchResults = await this.queryBoards({});
|
||||||
|
this.setState({ searchResults });
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
this.props.notificationCenter.onPlatformDidInstall(() =>
|
||||||
|
this.updateBoards(this.state.query)
|
||||||
|
),
|
||||||
|
this.props.notificationCenter.onPlatformDidUninstall(() =>
|
||||||
|
this.updateBoards(this.state.query)
|
||||||
|
),
|
||||||
|
this.props.notificationCenter.onIndexUpdateDidComplete(() =>
|
||||||
|
this.updateBoards(this.state.query)
|
||||||
|
),
|
||||||
|
this.props.notificationCenter.onDaemonDidStart(() =>
|
||||||
|
this.updateBoards(this.state.query)
|
||||||
|
),
|
||||||
|
this.props.notificationCenter.onDaemonDidStop(() =>
|
||||||
|
this.setState({ searchResults: [] })
|
||||||
|
),
|
||||||
|
this.props.onFilteredTextDidChangeEvent((query) => {
|
||||||
|
if (typeof query === 'string') {
|
||||||
|
this.setState({ query }, () => this.updateBoards(this.state.query));
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
override componentWillUnmount(): void {
|
||||||
|
this.toDispose.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly updateBoards = (
|
||||||
|
eventOrQuery: React.ChangeEvent<HTMLInputElement> | string = ''
|
||||||
|
) => {
|
||||||
|
const query =
|
||||||
|
typeof eventOrQuery === 'string'
|
||||||
|
? eventOrQuery
|
||||||
|
: eventOrQuery.target.value.toLowerCase();
|
||||||
|
this.setState({ query });
|
||||||
|
this.queryBoards({ query }).then((searchResults) =>
|
||||||
|
this.setState({ searchResults })
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly queryBoards = async (
|
||||||
|
options: { query?: string } = {}
|
||||||
|
): Promise<Array<BoardWithPackage>> => {
|
||||||
|
const result = await this.props.searchBoards(options);
|
||||||
|
const { searchSet } = this.props;
|
||||||
|
if (searchSet) {
|
||||||
|
return result.filter((board) =>
|
||||||
|
searchSet.some(
|
||||||
|
(restriction) =>
|
||||||
|
restriction.fqbn === board.fqbn || restriction.name === board.fqbn
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly toggleFilterPorts = () => {
|
||||||
|
this.setState({ showAllPorts: !this.state.showAllPorts });
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly selectPort = (selectedPort: PortIdentifier) => {
|
||||||
|
this.props.onPortSelected(selectedPort);
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly selectBoard = (selectedBoard: BoardWithPackage) => {
|
||||||
|
this.props.onBoardSelected(selectedBoard);
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly focusNodeSet = (element: HTMLElement | null) => {
|
||||||
|
this.props.onFocusNodeSet(element || undefined);
|
||||||
|
};
|
||||||
|
|
||||||
|
override render(): React.ReactNode {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{this.renderContainer(
|
||||||
|
nls.localize('arduino/board/boards', 'boards'),
|
||||||
|
this.renderBoards.bind(this)
|
||||||
|
)}
|
||||||
|
{this.renderContainer(
|
||||||
|
nls.localize('arduino/board/ports', 'ports'),
|
||||||
|
this.renderPorts.bind(this),
|
||||||
|
this.renderPortsFooter.bind(this)
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private renderContainer(
|
||||||
|
title: string,
|
||||||
|
contentRenderer: () => React.ReactNode,
|
||||||
|
footerRenderer?: () => React.ReactNode
|
||||||
|
): React.ReactNode {
|
||||||
|
return (
|
||||||
|
<div className="container">
|
||||||
|
<div className="content">
|
||||||
|
<div className="title">{title}</div>
|
||||||
|
{contentRenderer()}
|
||||||
|
<div className="footer">{footerRenderer ? footerRenderer() : ''}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private renderBoards(): React.ReactNode {
|
||||||
|
const { boardsConfig } = this.props;
|
||||||
|
const { searchResults, query } = this.state;
|
||||||
|
// Board names are not unique per core https://github.com/arduino/arduino-pro-ide/issues/262#issuecomment-661019560
|
||||||
|
// It is tricky when the core is not yet installed, no FQBNs are available.
|
||||||
|
const distinctBoards = new Map<string, Board.Detailed>();
|
||||||
|
const toKey = ({ name, packageName, fqbn }: Board.Detailed) =>
|
||||||
|
!!fqbn ? `${name}-${packageName}-${fqbn}` : `${name}-${packageName}`;
|
||||||
|
for (const board of Board.decorateBoards(
|
||||||
|
boardsConfig.selectedBoard,
|
||||||
|
searchResults
|
||||||
|
)) {
|
||||||
|
const key = toKey(board);
|
||||||
|
if (!distinctBoards.has(key)) {
|
||||||
|
distinctBoards.set(key, board);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const title = (board: Board.Detailed): string => {
|
||||||
|
const { details, manuallyInstalled } = board;
|
||||||
|
let label = board.name;
|
||||||
|
if (details) {
|
||||||
|
label += details;
|
||||||
|
}
|
||||||
|
if (manuallyInstalled) {
|
||||||
|
label += nls.localize('arduino/board/inSketchbook', ' (in Sketchbook)');
|
||||||
|
}
|
||||||
|
return label;
|
||||||
|
};
|
||||||
|
|
||||||
|
const boardsList = Array.from(distinctBoards.values()).map((board) => (
|
||||||
|
<Item<Board.Detailed>
|
||||||
|
key={toKey(board)}
|
||||||
|
item={board}
|
||||||
|
label={board.name}
|
||||||
|
details={board.details}
|
||||||
|
selected={board.selected}
|
||||||
|
onClick={this.selectBoard}
|
||||||
|
missing={board.missing}
|
||||||
|
title={title}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<div className="search">
|
||||||
|
<input
|
||||||
|
type="search"
|
||||||
|
value={query}
|
||||||
|
className="theia-input"
|
||||||
|
placeholder={nls.localize(
|
||||||
|
'arduino/board/searchBoard',
|
||||||
|
'Search board'
|
||||||
|
)}
|
||||||
|
onChange={this.updateBoards}
|
||||||
|
ref={this.focusNodeSet}
|
||||||
|
/>
|
||||||
|
<i className="fa fa-search"></i>
|
||||||
|
</div>
|
||||||
|
{boardsList.length > 0 ? (
|
||||||
|
<div className="boards list">{boardsList}</div>
|
||||||
|
) : (
|
||||||
|
<div className="no-result">
|
||||||
|
{nls.localize(
|
||||||
|
'arduino/board/noBoardsFound',
|
||||||
|
'No boards found for "{0}"',
|
||||||
|
query
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private renderPorts(): React.ReactNode {
|
||||||
|
const predicate = this.state.showAllPorts ? undefined : Port.isVisiblePort;
|
||||||
|
const detectedPorts = this.props.ports(predicate);
|
||||||
|
const matchingIndex = findMatchingPortIndex(
|
||||||
|
this.props.boardsConfig.selectedPort,
|
||||||
|
detectedPorts
|
||||||
|
);
|
||||||
|
return !detectedPorts.length ? (
|
||||||
|
<div className="no-result">
|
||||||
|
{nls.localize('arduino/board/noPortsDiscovered', 'No ports discovered')}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="ports list">
|
||||||
|
{detectedPorts.map((detectedPort, index) => (
|
||||||
|
<Item<Port>
|
||||||
|
key={`${Port.keyOf(detectedPort.port)}`}
|
||||||
|
item={detectedPort.port}
|
||||||
|
label={Port.toString(detectedPort.port)}
|
||||||
|
selected={index === matchingIndex}
|
||||||
|
onClick={this.selectPort}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private renderPortsFooter(): React.ReactNode {
|
||||||
|
return (
|
||||||
|
<div className="noselect">
|
||||||
|
<label
|
||||||
|
title={nls.localize(
|
||||||
|
'arduino/board/showAllAvailablePorts',
|
||||||
|
'Shows all available ports when enabled'
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
defaultChecked={this.state.showAllPorts}
|
||||||
|
onChange={this.toggleFilterPorts}
|
||||||
|
/>
|
||||||
|
<span>
|
||||||
|
{nls.localize('arduino/board/showAllPorts', 'Show all ports')}
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
import { injectable, inject } from 'inversify';
|
|
||||||
import { Emitter } from '@theia/core/lib/common/event';
|
|
||||||
import { ReactWidget, Message } from '@theia/core/lib/browser';
|
|
||||||
import { BoardsService } from '../../common/protocol/boards-service';
|
|
||||||
import { BoardsConfig } from './boards-config';
|
|
||||||
import { BoardsServiceProvider } from './boards-service-provider';
|
|
||||||
import { NotificationCenter } from '../notification-center';
|
|
||||||
|
|
||||||
@injectable()
|
|
||||||
export class BoardsConfigDialogWidget extends ReactWidget {
|
|
||||||
@inject(BoardsService)
|
|
||||||
protected readonly boardsService: BoardsService;
|
|
||||||
|
|
||||||
@inject(BoardsServiceProvider)
|
|
||||||
protected readonly boardsServiceClient: BoardsServiceProvider;
|
|
||||||
|
|
||||||
@inject(NotificationCenter)
|
|
||||||
protected readonly notificationCenter: NotificationCenter;
|
|
||||||
|
|
||||||
protected readonly onFilterTextDidChangeEmitter = new Emitter<string>();
|
|
||||||
protected readonly onBoardConfigChangedEmitter =
|
|
||||||
new Emitter<BoardsConfig.Config>();
|
|
||||||
readonly onBoardConfigChanged = this.onBoardConfigChangedEmitter.event;
|
|
||||||
|
|
||||||
protected focusNode: HTMLElement | undefined;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.id = 'select-board-dialog';
|
|
||||||
this.toDispose.pushAll([
|
|
||||||
this.onBoardConfigChangedEmitter,
|
|
||||||
this.onFilterTextDidChangeEmitter,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
search(query: string): void {
|
|
||||||
this.onFilterTextDidChangeEmitter.fire(query);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected fireConfigChanged = (config: BoardsConfig.Config) => {
|
|
||||||
this.onBoardConfigChangedEmitter.fire(config);
|
|
||||||
};
|
|
||||||
|
|
||||||
protected setFocusNode = (element: HTMLElement | undefined) => {
|
|
||||||
this.focusNode = element;
|
|
||||||
};
|
|
||||||
|
|
||||||
protected render(): React.ReactNode {
|
|
||||||
return (
|
|
||||||
<div className="selectBoardContainer">
|
|
||||||
<BoardsConfig
|
|
||||||
boardsServiceProvider={this.boardsServiceClient}
|
|
||||||
notificationCenter={this.notificationCenter}
|
|
||||||
onConfigChange={this.fireConfigChanged}
|
|
||||||
onFocusNodeSet={this.setFocusNode}
|
|
||||||
onFilteredTextDidChangeEvent={this.onFilterTextDidChangeEmitter.event}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected onActivateRequest(msg: Message): void {
|
|
||||||
super.onActivateRequest(msg);
|
|
||||||
if (this.focusNode instanceof HTMLInputElement) {
|
|
||||||
this.focusNode.select();
|
|
||||||
}
|
|
||||||
(this.focusNode || this.node).focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
import { injectable, inject, postConstruct } from 'inversify';
|
|
||||||
import { Message } from '@phosphor/messaging';
|
|
||||||
import { DialogProps, Widget, DialogError } from '@theia/core/lib/browser';
|
|
||||||
import { AbstractDialog } from '../theia/dialogs/dialogs';
|
|
||||||
import { BoardsConfig } from './boards-config';
|
|
||||||
import { BoardsService } from '../../common/protocol/boards-service';
|
|
||||||
import { BoardsServiceProvider } from './boards-service-provider';
|
|
||||||
import { BoardsConfigDialogWidget } from './boards-config-dialog-widget';
|
|
||||||
import { nls } from '@theia/core/lib/common';
|
|
||||||
|
|
||||||
@injectable()
|
|
||||||
export class BoardsConfigDialogProps extends DialogProps {}
|
|
||||||
|
|
||||||
@injectable()
|
|
||||||
export class BoardsConfigDialog extends AbstractDialog<BoardsConfig.Config> {
|
|
||||||
@inject(BoardsConfigDialogWidget)
|
|
||||||
protected readonly widget: BoardsConfigDialogWidget;
|
|
||||||
|
|
||||||
@inject(BoardsService)
|
|
||||||
protected readonly boardService: BoardsService;
|
|
||||||
|
|
||||||
@inject(BoardsServiceProvider)
|
|
||||||
protected readonly boardsServiceClient: BoardsServiceProvider;
|
|
||||||
|
|
||||||
protected config: BoardsConfig.Config = {};
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
@inject(BoardsConfigDialogProps)
|
|
||||||
protected readonly props: BoardsConfigDialogProps
|
|
||||||
) {
|
|
||||||
super(props);
|
|
||||||
|
|
||||||
this.contentNode.classList.add('select-board-dialog');
|
|
||||||
this.contentNode.appendChild(this.createDescription());
|
|
||||||
|
|
||||||
this.appendCloseButton(
|
|
||||||
nls.localize('vscode/issueMainService/cancel', 'Cancel')
|
|
||||||
);
|
|
||||||
this.appendAcceptButton(nls.localize('vscode/issueMainService/ok', 'OK'));
|
|
||||||
}
|
|
||||||
|
|
||||||
@postConstruct()
|
|
||||||
protected init(): void {
|
|
||||||
this.toDispose.push(
|
|
||||||
this.boardsServiceClient.onBoardsConfigChanged((config) => {
|
|
||||||
this.config = config;
|
|
||||||
this.update();
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pass in an empty string if you want to reset the search term. Using `undefined` has no effect.
|
|
||||||
*/
|
|
||||||
async open(
|
|
||||||
query: string | undefined = undefined
|
|
||||||
): Promise<BoardsConfig.Config | undefined> {
|
|
||||||
if (typeof query === 'string') {
|
|
||||||
this.widget.search(query);
|
|
||||||
}
|
|
||||||
return super.open();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected createDescription(): HTMLElement {
|
|
||||||
const head = document.createElement('div');
|
|
||||||
head.classList.add('head');
|
|
||||||
|
|
||||||
const title = document.createElement('div');
|
|
||||||
title.textContent = nls.localize(
|
|
||||||
'arduino/board/configDialogTitle',
|
|
||||||
'Select Other Board & Port'
|
|
||||||
);
|
|
||||||
title.classList.add('title');
|
|
||||||
head.appendChild(title);
|
|
||||||
|
|
||||||
const text = document.createElement('div');
|
|
||||||
text.classList.add('text');
|
|
||||||
head.appendChild(text);
|
|
||||||
|
|
||||||
for (const paragraph of [
|
|
||||||
nls.localize(
|
|
||||||
'arduino/board/configDialog1',
|
|
||||||
'Select both a Board and a Port if you want to upload a sketch.'
|
|
||||||
),
|
|
||||||
nls.localize(
|
|
||||||
'arduino/board/configDialog2',
|
|
||||||
'If you only select a Board you will be able to compile, but not to upload your sketch.'
|
|
||||||
),
|
|
||||||
]) {
|
|
||||||
const p = document.createElement('div');
|
|
||||||
p.textContent = paragraph;
|
|
||||||
text.appendChild(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
return head;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected onAfterAttach(msg: Message): void {
|
|
||||||
if (this.widget.isAttached) {
|
|
||||||
Widget.detach(this.widget);
|
|
||||||
}
|
|
||||||
Widget.attach(this.widget, this.contentNode);
|
|
||||||
this.toDisposeOnDetach.push(
|
|
||||||
this.widget.onBoardConfigChanged((config) => {
|
|
||||||
this.config = config;
|
|
||||||
this.update();
|
|
||||||
})
|
|
||||||
);
|
|
||||||
super.onAfterAttach(msg);
|
|
||||||
this.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected onUpdateRequest(msg: Message) {
|
|
||||||
super.onUpdateRequest(msg);
|
|
||||||
this.widget.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected onActivateRequest(msg: Message): void {
|
|
||||||
super.onActivateRequest(msg);
|
|
||||||
this.widget.activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected handleEnter(event: KeyboardEvent): boolean | void {
|
|
||||||
if (event.target instanceof HTMLTextAreaElement) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected isValid(value: BoardsConfig.Config): DialogError {
|
|
||||||
if (!value.selectedBoard) {
|
|
||||||
if (value.selectedPort) {
|
|
||||||
return nls.localize(
|
|
||||||
'arduino/board/pleasePickBoard',
|
|
||||||
'Please pick a board connected to the port you have selected.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
get value(): BoardsConfig.Config {
|
|
||||||
return this.config;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,203 @@
|
|||||||
|
import { DialogError, DialogProps } from '@theia/core/lib/browser/dialogs';
|
||||||
|
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
||||||
|
import { Emitter } from '@theia/core/lib/common/event';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { deepClone } from '@theia/core/lib/common/objects';
|
||||||
|
import type { Message } from '@theia/core/shared/@phosphor/messaging';
|
||||||
|
import {
|
||||||
|
inject,
|
||||||
|
injectable,
|
||||||
|
postConstruct,
|
||||||
|
} from '@theia/core/shared/inversify';
|
||||||
|
import React from '@theia/core/shared/react';
|
||||||
|
import type { ReactNode } from '@theia/core/shared/react/index';
|
||||||
|
import { EditBoardsConfigActionParams } from '../../common/protocol/board-list';
|
||||||
|
import {
|
||||||
|
BoardIdentifier,
|
||||||
|
BoardsConfig,
|
||||||
|
BoardWithPackage,
|
||||||
|
DetectedPort,
|
||||||
|
emptyBoardsConfig,
|
||||||
|
PortIdentifier,
|
||||||
|
} from '../../common/protocol/boards-service';
|
||||||
|
import type { Defined } from '../../common/types';
|
||||||
|
import { NotificationCenter } from '../notification-center';
|
||||||
|
import { ReactDialog } from '../theia/dialogs/dialogs';
|
||||||
|
import { BoardsConfigComponent } from './boards-config-component';
|
||||||
|
import { BoardsServiceProvider } from './boards-service-provider';
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class BoardsConfigDialogProps extends DialogProps {}
|
||||||
|
|
||||||
|
export type BoardsConfigDialogState = Omit<BoardsConfig, 'selectedBoard'> & {
|
||||||
|
selectedBoard: BoardsConfig['selectedBoard'] | BoardWithPackage;
|
||||||
|
};
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class BoardsConfigDialog extends ReactDialog<BoardsConfigDialogState> {
|
||||||
|
@inject(BoardsServiceProvider)
|
||||||
|
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
@inject(NotificationCenter)
|
||||||
|
private readonly notificationCenter: NotificationCenter;
|
||||||
|
@inject(FrontendApplicationStateService)
|
||||||
|
private readonly appStateService: FrontendApplicationStateService;
|
||||||
|
|
||||||
|
private readonly onFilterTextDidChangeEmitter: Emitter<
|
||||||
|
Defined<EditBoardsConfigActionParams['query']>
|
||||||
|
>;
|
||||||
|
private readonly onBoardSelected = (board: BoardWithPackage): void => {
|
||||||
|
this._boardsConfig.selectedBoard = board;
|
||||||
|
this.update();
|
||||||
|
};
|
||||||
|
private readonly onPortSelected = (port: PortIdentifier): void => {
|
||||||
|
this._boardsConfig.selectedPort = port;
|
||||||
|
this.update();
|
||||||
|
};
|
||||||
|
private readonly setFocusNode = (element: HTMLElement | undefined): void => {
|
||||||
|
this.focusNode = element;
|
||||||
|
};
|
||||||
|
private readonly searchBoards = (options: {
|
||||||
|
query?: string;
|
||||||
|
}): Promise<BoardWithPackage[]> => {
|
||||||
|
return this.boardsServiceProvider.searchBoards(options);
|
||||||
|
};
|
||||||
|
private readonly ports = (
|
||||||
|
predicate?: (port: DetectedPort) => boolean
|
||||||
|
): readonly DetectedPort[] => {
|
||||||
|
return this.boardsServiceProvider.boardList.ports(predicate);
|
||||||
|
};
|
||||||
|
private _boardsConfig: BoardsConfigDialogState;
|
||||||
|
/**
|
||||||
|
* When the dialog's boards result set is limited to a subset of boards when searching, this field is set.
|
||||||
|
*/
|
||||||
|
private _searchSet: BoardIdentifier[] | undefined;
|
||||||
|
private focusNode: HTMLElement | undefined;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@inject(BoardsConfigDialogProps)
|
||||||
|
protected override readonly props: BoardsConfigDialogProps
|
||||||
|
) {
|
||||||
|
super({ ...props, maxWidth: 500 });
|
||||||
|
this.node.id = 'select-board-dialog-container';
|
||||||
|
this.contentNode.classList.add('select-board-dialog');
|
||||||
|
this.appendCloseButton(
|
||||||
|
nls.localize('vscode/issueMainService/cancel', 'Cancel')
|
||||||
|
);
|
||||||
|
this.appendAcceptButton(nls.localize('vscode/issueMainService/ok', 'OK'));
|
||||||
|
this._boardsConfig = emptyBoardsConfig();
|
||||||
|
this.onFilterTextDidChangeEmitter = new Emitter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@postConstruct()
|
||||||
|
protected init(): void {
|
||||||
|
this.boardsServiceProvider.onBoardListDidChange(() => {
|
||||||
|
this._boardsConfig = deepClone(this.boardsServiceProvider.boardsConfig);
|
||||||
|
this.update();
|
||||||
|
});
|
||||||
|
this._boardsConfig = deepClone(this.boardsServiceProvider.boardsConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
override async open(
|
||||||
|
disposeOnResolve = true,
|
||||||
|
params?: EditBoardsConfigActionParams
|
||||||
|
): Promise<BoardsConfig | undefined> {
|
||||||
|
this._searchSet = undefined;
|
||||||
|
this._boardsConfig.selectedBoard =
|
||||||
|
this.boardsServiceProvider.boardsConfig.selectedBoard;
|
||||||
|
this._boardsConfig.selectedPort =
|
||||||
|
this.boardsServiceProvider.boardsConfig.selectedPort;
|
||||||
|
if (params) {
|
||||||
|
if (typeof params.query === 'string') {
|
||||||
|
this.onFilterTextDidChangeEmitter.fire(params.query);
|
||||||
|
}
|
||||||
|
if (params.portToSelect) {
|
||||||
|
this._boardsConfig.selectedPort = params.portToSelect;
|
||||||
|
}
|
||||||
|
if (params.boardToSelect) {
|
||||||
|
this._boardsConfig.selectedBoard = params.boardToSelect;
|
||||||
|
}
|
||||||
|
if (params.searchSet) {
|
||||||
|
this._searchSet = params.searchSet.slice();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.open(disposeOnResolve);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override onAfterAttach(msg: Message): void {
|
||||||
|
super.onAfterAttach(msg);
|
||||||
|
this.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override render(): ReactNode {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="head">
|
||||||
|
<div className="text">
|
||||||
|
<div>
|
||||||
|
{nls.localize(
|
||||||
|
'arduino/board/configDialog1',
|
||||||
|
'Select both a Board and a Port if you want to upload a sketch.'
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{nls.localize(
|
||||||
|
'arduino/board/configDialog2',
|
||||||
|
'If you only select a Board you will be able to compile, but not to upload your sketch.'
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="select-board-dialog" className="p-Widget ps">
|
||||||
|
<div className="selectBoardContainer">
|
||||||
|
<BoardsConfigComponent
|
||||||
|
boardsConfig={this._boardsConfig}
|
||||||
|
searchSet={this._searchSet}
|
||||||
|
onBoardSelected={this.onBoardSelected}
|
||||||
|
onPortSelected={this.onPortSelected}
|
||||||
|
notificationCenter={this.notificationCenter}
|
||||||
|
onFocusNodeSet={this.setFocusNode}
|
||||||
|
onFilteredTextDidChangeEvent={
|
||||||
|
this.onFilterTextDidChangeEmitter.event
|
||||||
|
}
|
||||||
|
appState={this.appStateService.state}
|
||||||
|
onAppStateDidChange={this.notificationCenter.onAppStateDidChange}
|
||||||
|
searchBoards={this.searchBoards}
|
||||||
|
ports={this.ports}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override onActivateRequest(msg: Message): void {
|
||||||
|
super.onActivateRequest(msg);
|
||||||
|
if (this.focusNode instanceof HTMLInputElement) {
|
||||||
|
this.focusNode.select();
|
||||||
|
}
|
||||||
|
(this.focusNode || this.node).focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override handleEnter(event: KeyboardEvent): boolean | void {
|
||||||
|
if (event.target instanceof HTMLTextAreaElement) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override isValid(value: BoardsConfig): DialogError {
|
||||||
|
if (!value.selectedBoard) {
|
||||||
|
if (value.selectedPort) {
|
||||||
|
return nls.localize(
|
||||||
|
'arduino/board/pleasePickBoard',
|
||||||
|
'Please pick a board connected to the port you have selected.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
get value(): BoardsConfigDialogState {
|
||||||
|
return this._boardsConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,464 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
import { Event } from '@theia/core/lib/common/event';
|
|
||||||
import { notEmpty } from '@theia/core/lib/common/objects';
|
|
||||||
import { MaybePromise } from '@theia/core/lib/common/types';
|
|
||||||
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
|
||||||
import {
|
|
||||||
Board,
|
|
||||||
Port,
|
|
||||||
AttachedBoardsChangeEvent,
|
|
||||||
BoardWithPackage,
|
|
||||||
} from '../../common/protocol/boards-service';
|
|
||||||
import { NotificationCenter } from '../notification-center';
|
|
||||||
import {
|
|
||||||
AvailableBoard,
|
|
||||||
BoardsServiceProvider,
|
|
||||||
} from './boards-service-provider';
|
|
||||||
import { naturalCompare } from '../../common/utils';
|
|
||||||
import { nls } from '@theia/core/lib/common';
|
|
||||||
|
|
||||||
export namespace BoardsConfig {
|
|
||||||
export interface Config {
|
|
||||||
selectedBoard?: Board;
|
|
||||||
selectedPort?: Port;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Props {
|
|
||||||
readonly boardsServiceProvider: BoardsServiceProvider;
|
|
||||||
readonly notificationCenter: NotificationCenter;
|
|
||||||
readonly onConfigChange: (config: Config) => void;
|
|
||||||
readonly onFocusNodeSet: (element: HTMLElement | undefined) => void;
|
|
||||||
readonly onFilteredTextDidChangeEvent: Event<string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface State extends Config {
|
|
||||||
searchResults: Array<BoardWithPackage>;
|
|
||||||
knownPorts: Port[];
|
|
||||||
showAllPorts: boolean;
|
|
||||||
query: string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export abstract class Item<T> extends React.Component<{
|
|
||||||
item: T;
|
|
||||||
label: string;
|
|
||||||
selected: boolean;
|
|
||||||
onClick: (item: T) => void;
|
|
||||||
missing?: boolean;
|
|
||||||
details?: string;
|
|
||||||
}> {
|
|
||||||
render(): React.ReactNode {
|
|
||||||
const { selected, label, missing, details } = this.props;
|
|
||||||
const classNames = ['item'];
|
|
||||||
if (selected) {
|
|
||||||
classNames.push('selected');
|
|
||||||
}
|
|
||||||
if (missing === true) {
|
|
||||||
classNames.push('missing');
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
onClick={this.onClick}
|
|
||||||
className={classNames.join(' ')}
|
|
||||||
title={`${label}${!details ? '' : details}`}
|
|
||||||
>
|
|
||||||
<div className="label">{label}</div>
|
|
||||||
{!details ? '' : <div className="details">{details}</div>}
|
|
||||||
{!selected ? (
|
|
||||||
''
|
|
||||||
) : (
|
|
||||||
<div className="selected-icon">
|
|
||||||
<i className="fa fa-check" />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected onClick = () => {
|
|
||||||
this.props.onClick(this.props.item);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export class BoardsConfig extends React.Component<
|
|
||||||
BoardsConfig.Props,
|
|
||||||
BoardsConfig.State
|
|
||||||
> {
|
|
||||||
protected toDispose = new DisposableCollection();
|
|
||||||
|
|
||||||
constructor(props: BoardsConfig.Props) {
|
|
||||||
super(props);
|
|
||||||
|
|
||||||
const { boardsConfig } = props.boardsServiceProvider;
|
|
||||||
this.state = {
|
|
||||||
searchResults: [],
|
|
||||||
knownPorts: [],
|
|
||||||
showAllPorts: false,
|
|
||||||
query: '',
|
|
||||||
...boardsConfig,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.updateBoards();
|
|
||||||
this.updatePorts(
|
|
||||||
this.props.boardsServiceProvider.availableBoards
|
|
||||||
.map(({ port }) => port)
|
|
||||||
.filter(notEmpty)
|
|
||||||
);
|
|
||||||
this.toDispose.pushAll([
|
|
||||||
this.props.notificationCenter.onAttachedBoardsChanged((event) =>
|
|
||||||
this.updatePorts(
|
|
||||||
event.newState.ports,
|
|
||||||
AttachedBoardsChangeEvent.diff(event).detached.ports
|
|
||||||
)
|
|
||||||
),
|
|
||||||
this.props.boardsServiceProvider.onBoardsConfigChanged(
|
|
||||||
({ selectedBoard, selectedPort }) => {
|
|
||||||
this.setState({ selectedBoard, selectedPort }, () =>
|
|
||||||
this.fireConfigChanged()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
),
|
|
||||||
this.props.notificationCenter.onPlatformInstalled(() =>
|
|
||||||
this.updateBoards(this.state.query)
|
|
||||||
),
|
|
||||||
this.props.notificationCenter.onPlatformUninstalled(() =>
|
|
||||||
this.updateBoards(this.state.query)
|
|
||||||
),
|
|
||||||
this.props.notificationCenter.onIndexUpdated(() =>
|
|
||||||
this.updateBoards(this.state.query)
|
|
||||||
),
|
|
||||||
this.props.notificationCenter.onDaemonStarted(() =>
|
|
||||||
this.updateBoards(this.state.query)
|
|
||||||
),
|
|
||||||
this.props.notificationCenter.onDaemonStopped(() =>
|
|
||||||
this.setState({ searchResults: [] })
|
|
||||||
),
|
|
||||||
this.props.onFilteredTextDidChangeEvent((query) =>
|
|
||||||
this.setState({ query }, () => this.updateBoards(this.state.query))
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount(): void {
|
|
||||||
this.toDispose.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected fireConfigChanged() {
|
|
||||||
const { selectedBoard, selectedPort } = this.state;
|
|
||||||
this.props.onConfigChange({ selectedBoard, selectedPort });
|
|
||||||
}
|
|
||||||
|
|
||||||
protected updateBoards = (
|
|
||||||
eventOrQuery: React.ChangeEvent<HTMLInputElement> | string = ''
|
|
||||||
) => {
|
|
||||||
const query =
|
|
||||||
typeof eventOrQuery === 'string'
|
|
||||||
? eventOrQuery
|
|
||||||
: eventOrQuery.target.value.toLowerCase();
|
|
||||||
this.setState({ query });
|
|
||||||
this.queryBoards({ query }).then((searchResults) =>
|
|
||||||
this.setState({ searchResults })
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
protected updatePorts = (ports: Port[] = [], removedPorts: Port[] = []) => {
|
|
||||||
this.queryPorts(Promise.resolve(ports)).then(({ knownPorts }) => {
|
|
||||||
let { selectedPort } = this.state;
|
|
||||||
// If the currently selected port is not available anymore, unset the selected port.
|
|
||||||
if (removedPorts.some((port) => Port.sameAs(port, selectedPort))) {
|
|
||||||
selectedPort = undefined;
|
|
||||||
}
|
|
||||||
this.setState({ knownPorts, selectedPort }, () =>
|
|
||||||
this.fireConfigChanged()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
protected queryBoards = (
|
|
||||||
options: { query?: string } = {}
|
|
||||||
): Promise<Array<BoardWithPackage>> => {
|
|
||||||
return this.props.boardsServiceProvider.searchBoards(options);
|
|
||||||
};
|
|
||||||
|
|
||||||
protected get availablePorts(): MaybePromise<Port[]> {
|
|
||||||
return this.props.boardsServiceProvider.availableBoards
|
|
||||||
.map(({ port }) => port)
|
|
||||||
.filter(notEmpty);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected get availableBoards(): AvailableBoard[] {
|
|
||||||
return this.props.boardsServiceProvider.availableBoards;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected queryPorts = async (
|
|
||||||
availablePorts: MaybePromise<Port[]> = this.availablePorts
|
|
||||||
) => {
|
|
||||||
// Available ports must be sorted in this order:
|
|
||||||
// 1. Serial with recognized boards
|
|
||||||
// 2. Serial with guessed boards
|
|
||||||
// 3. Serial with incomplete boards
|
|
||||||
// 4. Network with recognized boards
|
|
||||||
// 5. Other protocols with recognized boards
|
|
||||||
const ports = (await availablePorts).sort((left: Port, right: Port) => {
|
|
||||||
if (left.protocol === 'serial' && right.protocol !== 'serial') {
|
|
||||||
return -1;
|
|
||||||
} else if (left.protocol !== 'serial' && right.protocol === 'serial') {
|
|
||||||
return 1;
|
|
||||||
} else if (left.protocol === 'network' && right.protocol !== 'network') {
|
|
||||||
return -1;
|
|
||||||
} else if (left.protocol !== 'network' && right.protocol === 'network') {
|
|
||||||
return 1;
|
|
||||||
} else if (left.protocol === right.protocol) {
|
|
||||||
// We show ports, including those that have guessed
|
|
||||||
// or unrecognized boards, so we must sort those too.
|
|
||||||
const leftBoard = this.availableBoards.find(
|
|
||||||
(board) => board.port === left
|
|
||||||
);
|
|
||||||
const rightBoard = this.availableBoards.find(
|
|
||||||
(board) => board.port === right
|
|
||||||
);
|
|
||||||
if (leftBoard && !rightBoard) {
|
|
||||||
return -1;
|
|
||||||
} else if (!leftBoard && rightBoard) {
|
|
||||||
return 1;
|
|
||||||
} else if (leftBoard?.state! < rightBoard?.state!) {
|
|
||||||
return -1;
|
|
||||||
} else if (leftBoard?.state! > rightBoard?.state!) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return naturalCompare(left.address, right.address);
|
|
||||||
});
|
|
||||||
return { knownPorts: ports };
|
|
||||||
};
|
|
||||||
|
|
||||||
protected toggleFilterPorts = () => {
|
|
||||||
this.setState({ showAllPorts: !this.state.showAllPorts });
|
|
||||||
};
|
|
||||||
|
|
||||||
protected selectPort = (selectedPort: Port | undefined) => {
|
|
||||||
this.setState({ selectedPort }, () => this.fireConfigChanged());
|
|
||||||
};
|
|
||||||
|
|
||||||
protected selectBoard = (selectedBoard: BoardWithPackage | undefined) => {
|
|
||||||
this.setState({ selectedBoard }, () => this.fireConfigChanged());
|
|
||||||
};
|
|
||||||
|
|
||||||
protected focusNodeSet = (element: HTMLElement | null) => {
|
|
||||||
this.props.onFocusNodeSet(element || undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
render(): React.ReactNode {
|
|
||||||
return (
|
|
||||||
<div className="body">
|
|
||||||
{this.renderContainer('boards', this.renderBoards.bind(this))}
|
|
||||||
{this.renderContainer(
|
|
||||||
'ports',
|
|
||||||
this.renderPorts.bind(this),
|
|
||||||
this.renderPortsFooter.bind(this)
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected renderContainer(
|
|
||||||
title: string,
|
|
||||||
contentRenderer: () => React.ReactNode,
|
|
||||||
footerRenderer?: () => React.ReactNode
|
|
||||||
): React.ReactNode {
|
|
||||||
return (
|
|
||||||
<div className="container">
|
|
||||||
<div className="content">
|
|
||||||
<div className="title">{title}</div>
|
|
||||||
{contentRenderer()}
|
|
||||||
<div className="footer">{footerRenderer ? footerRenderer() : ''}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected renderBoards(): React.ReactNode {
|
|
||||||
const { selectedBoard, searchResults, query } = this.state;
|
|
||||||
// Board names are not unique per core https://github.com/arduino/arduino-pro-ide/issues/262#issuecomment-661019560
|
|
||||||
// It is tricky when the core is not yet installed, no FQBNs are available.
|
|
||||||
const distinctBoards = new Map<string, Board.Detailed>();
|
|
||||||
const toKey = ({ name, packageName, fqbn }: Board.Detailed) =>
|
|
||||||
!!fqbn ? `${name}-${packageName}-${fqbn}` : `${name}-${packageName}`;
|
|
||||||
for (const board of Board.decorateBoards(selectedBoard, searchResults)) {
|
|
||||||
const key = toKey(board);
|
|
||||||
if (!distinctBoards.has(key)) {
|
|
||||||
distinctBoards.set(key, board);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
<div className="search">
|
|
||||||
<input
|
|
||||||
type="search"
|
|
||||||
value={query}
|
|
||||||
className="theia-input"
|
|
||||||
placeholder="SEARCH BOARD"
|
|
||||||
onChange={this.updateBoards}
|
|
||||||
ref={this.focusNodeSet}
|
|
||||||
/>
|
|
||||||
<i className="fa fa-search"></i>
|
|
||||||
</div>
|
|
||||||
<div className="boards list">
|
|
||||||
{Array.from(distinctBoards.values()).map((board) => (
|
|
||||||
<Item<BoardWithPackage>
|
|
||||||
key={toKey(board)}
|
|
||||||
item={board}
|
|
||||||
label={board.name}
|
|
||||||
details={board.details}
|
|
||||||
selected={board.selected}
|
|
||||||
onClick={this.selectBoard}
|
|
||||||
missing={board.missing}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected renderPorts(): React.ReactNode {
|
|
||||||
let ports = [] as Port[];
|
|
||||||
if (this.state.showAllPorts) {
|
|
||||||
ports = this.state.knownPorts;
|
|
||||||
} else {
|
|
||||||
ports = this.state.knownPorts.filter((port) => {
|
|
||||||
if (port.protocol === 'serial') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// All other ports with different protocol are
|
|
||||||
// only shown if there is a recognized board
|
|
||||||
// connected
|
|
||||||
for (const board of this.availableBoards) {
|
|
||||||
if (board.port?.address === port.address) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return !ports.length ? (
|
|
||||||
<div className="loading noselect">No ports discovered</div>
|
|
||||||
) : (
|
|
||||||
<div className="ports list">
|
|
||||||
{ports.map((port) => (
|
|
||||||
<Item<Port>
|
|
||||||
key={`${port.id}`}
|
|
||||||
item={port}
|
|
||||||
label={Port.toString(port)}
|
|
||||||
selected={Port.sameAs(this.state.selectedPort, port)}
|
|
||||||
onClick={this.selectPort}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected renderPortsFooter(): React.ReactNode {
|
|
||||||
return (
|
|
||||||
<div className="noselect">
|
|
||||||
<label
|
|
||||||
title={nls.localize(
|
|
||||||
'arduino/board/showAllAvailablePorts',
|
|
||||||
'Shows all available ports when enabled'
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
defaultChecked={this.state.showAllPorts}
|
|
||||||
onChange={this.toggleFilterPorts}
|
|
||||||
/>
|
|
||||||
<span>Show all ports</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export namespace BoardsConfig {
|
|
||||||
export namespace Config {
|
|
||||||
export function sameAs(config: Config, other: Config | Board): boolean {
|
|
||||||
const { selectedBoard, selectedPort } = config;
|
|
||||||
if (Board.is(other)) {
|
|
||||||
return (
|
|
||||||
!!selectedBoard &&
|
|
||||||
Board.equals(other, selectedBoard) &&
|
|
||||||
Port.sameAs(selectedPort, other.port)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return sameAs(config, other);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function equals(left: Config, right: Config): boolean {
|
|
||||||
return (
|
|
||||||
left.selectedBoard === right.selectedBoard &&
|
|
||||||
left.selectedPort === right.selectedPort
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function toString(
|
|
||||||
config: Config,
|
|
||||||
options: { default: string } = { default: '' }
|
|
||||||
): string {
|
|
||||||
const { selectedBoard, selectedPort: port } = config;
|
|
||||||
if (!selectedBoard) {
|
|
||||||
return options.default;
|
|
||||||
}
|
|
||||||
const { name } = selectedBoard;
|
|
||||||
return `${name}${port ? ` at ${port.address}` : ''}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setConfig(
|
|
||||||
config: Config | undefined,
|
|
||||||
urlToAttachTo: URL
|
|
||||||
): URL {
|
|
||||||
const copy = new URL(urlToAttachTo.toString());
|
|
||||||
if (!config) {
|
|
||||||
copy.searchParams.delete('boards-config');
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
const selectedBoard = config.selectedBoard
|
|
||||||
? {
|
|
||||||
name: config.selectedBoard.name,
|
|
||||||
fqbn: config.selectedBoard.fqbn,
|
|
||||||
}
|
|
||||||
: undefined;
|
|
||||||
const selectedPort = config.selectedPort
|
|
||||||
? {
|
|
||||||
protocol: config.selectedPort.protocol,
|
|
||||||
address: config.selectedPort.address,
|
|
||||||
}
|
|
||||||
: undefined;
|
|
||||||
const jsonConfig = JSON.stringify({ selectedBoard, selectedPort });
|
|
||||||
copy.searchParams.set('boards-config', encodeURIComponent(jsonConfig));
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getConfig(url: URL): Config | undefined {
|
|
||||||
const encoded = url.searchParams.get('boards-config');
|
|
||||||
if (!encoded) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const raw = decodeURIComponent(encoded);
|
|
||||||
const candidate = JSON.parse(raw);
|
|
||||||
if (typeof candidate === 'object') {
|
|
||||||
return candidate;
|
|
||||||
}
|
|
||||||
console.warn(
|
|
||||||
`Expected candidate to be an object. It was ${typeof candidate}. URL was: ${url}`
|
|
||||||
);
|
|
||||||
return undefined;
|
|
||||||
} catch (e) {
|
|
||||||
console.log(`Could not get board config from URL: ${url}.`, e);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,77 +1,202 @@
|
|||||||
import { injectable, inject, named } from 'inversify';
|
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution';
|
||||||
|
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
||||||
|
import { StorageService } from '@theia/core/lib/browser/storage-service';
|
||||||
|
import type {
|
||||||
|
Command,
|
||||||
|
CommandContribution,
|
||||||
|
CommandRegistry,
|
||||||
|
} from '@theia/core/lib/common/command';
|
||||||
|
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
||||||
|
import { Emitter, Event } from '@theia/core/lib/common/event';
|
||||||
import { ILogger } from '@theia/core/lib/common/logger';
|
import { ILogger } from '@theia/core/lib/common/logger';
|
||||||
import { deepClone } from '@theia/core/lib/common/objects';
|
import { deepClone, deepFreeze } from '@theia/core/lib/common/objects';
|
||||||
import { Event, Emitter } from '@theia/core/lib/common/event';
|
import type { Mutable } from '@theia/core/lib/common/types';
|
||||||
import {
|
import { inject, injectable, named } from '@theia/core/shared/inversify';
|
||||||
FrontendApplicationContribution,
|
import { FQBN } from 'fqbn';
|
||||||
LocalStorageService,
|
|
||||||
} from '@theia/core/lib/browser';
|
|
||||||
import { notEmpty } from '../../common/utils';
|
|
||||||
import {
|
import {
|
||||||
|
BoardDetails,
|
||||||
BoardsService,
|
BoardsService,
|
||||||
ConfigOption,
|
ConfigOption,
|
||||||
BoardDetails,
|
ConfigValue,
|
||||||
Programmer,
|
Programmer,
|
||||||
|
isBoardIdentifierChangeEvent,
|
||||||
|
isProgrammer,
|
||||||
|
sanitizeFqbn,
|
||||||
} from '../../common/protocol';
|
} from '../../common/protocol';
|
||||||
|
import { notEmpty } from '../../common/utils';
|
||||||
|
import type {
|
||||||
|
StartupTask,
|
||||||
|
StartupTaskProvider,
|
||||||
|
} from '../../electron-common/startup-task';
|
||||||
import { NotificationCenter } from '../notification-center';
|
import { NotificationCenter } from '../notification-center';
|
||||||
|
import { BoardsServiceProvider } from './boards-service-provider';
|
||||||
|
|
||||||
|
export interface SelectConfigOptionParams {
|
||||||
|
readonly fqbn: string;
|
||||||
|
readonly optionsToUpdate: readonly Readonly<{
|
||||||
|
option: string;
|
||||||
|
selectedValue: string;
|
||||||
|
}>[];
|
||||||
|
}
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class BoardsDataStore implements FrontendApplicationContribution {
|
export class BoardsDataStore
|
||||||
|
implements
|
||||||
|
FrontendApplicationContribution,
|
||||||
|
StartupTaskProvider,
|
||||||
|
CommandContribution
|
||||||
|
{
|
||||||
@inject(ILogger)
|
@inject(ILogger)
|
||||||
@named('store')
|
@named('store')
|
||||||
protected readonly logger: ILogger;
|
private readonly logger: ILogger;
|
||||||
|
|
||||||
@inject(BoardsService)
|
@inject(BoardsService)
|
||||||
protected readonly boardsService: BoardsService;
|
private readonly boardsService: BoardsService;
|
||||||
|
|
||||||
@inject(NotificationCenter)
|
@inject(NotificationCenter)
|
||||||
protected readonly notificationCenter: NotificationCenter;
|
private readonly notificationCenter: NotificationCenter;
|
||||||
|
// When `@theia/workspace` is part of the application, the workspace-scoped storage service is the default implementation, and the `StorageService` symbol must be used for the injection.
|
||||||
|
// https://github.com/eclipse-theia/theia/blob/ba3722b04ff91eb6a4af6a571c9e263c77cdd8b5/packages/workspace/src/browser/workspace-frontend-module.ts#L97-L98
|
||||||
|
// In other words, store the data (such as the board configs) per sketch, not per IDE2 installation. https://github.com/arduino/arduino-ide/issues/2240
|
||||||
|
@inject(StorageService)
|
||||||
|
private readonly storageService: StorageService;
|
||||||
|
@inject(BoardsServiceProvider)
|
||||||
|
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
@inject(FrontendApplicationStateService)
|
||||||
|
private readonly appStateService: FrontendApplicationStateService;
|
||||||
|
|
||||||
@inject(LocalStorageService)
|
private readonly onDidChangeEmitter =
|
||||||
protected readonly storageService: LocalStorageService;
|
new Emitter<BoardsDataStoreChangeEvent>();
|
||||||
|
private readonly toDispose = new DisposableCollection(
|
||||||
protected readonly onChangedEmitter = new Emitter<void>();
|
this.onDidChangeEmitter
|
||||||
|
);
|
||||||
|
private _selectedBoardData: BoardsDataStoreChange | undefined;
|
||||||
|
|
||||||
onStart(): void {
|
onStart(): void {
|
||||||
this.notificationCenter.onPlatformInstalled(async ({ item }) => {
|
this.toDispose.pushAll([
|
||||||
let shouldFireChanged = false;
|
this.boardsServiceProvider.onBoardsConfigDidChange((event) => {
|
||||||
for (const fqbn of item.boards
|
if (isBoardIdentifierChangeEvent(event)) {
|
||||||
.map(({ fqbn }) => fqbn)
|
this.updateSelectedBoardData(
|
||||||
.filter(notEmpty)
|
event.selectedBoard?.fqbn,
|
||||||
.filter((fqbn) => !!fqbn)) {
|
// If the change event comes from toolbar and the FQBN contains custom board options, change the currently selected options
|
||||||
const key = this.getStorageKey(fqbn);
|
// https://github.com/arduino/arduino-ide/issues/1588
|
||||||
let data = await this.storageService.getData<
|
event.reason === 'toolbar'
|
||||||
ConfigOption[] | undefined
|
);
|
||||||
>(key);
|
}
|
||||||
if (!data || !data.length) {
|
}),
|
||||||
const details = await this.getBoardDetailsSafe(fqbn);
|
this.notificationCenter.onPlatformDidInstall(async ({ item }) => {
|
||||||
|
const boardsWithFqbn = item.boards
|
||||||
|
.map(({ fqbn }) => fqbn)
|
||||||
|
.filter(notEmpty);
|
||||||
|
const changes: BoardsDataStoreChange[] = [];
|
||||||
|
for (const fqbn of boardsWithFqbn) {
|
||||||
|
const key = this.getStorageKey(fqbn);
|
||||||
|
const storedData =
|
||||||
|
await this.storageService.getData<BoardsDataStore.Data>(key);
|
||||||
|
if (!storedData) {
|
||||||
|
// if no previously value is available for the board, do not update the cache
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const details = await this.loadBoardDetails(fqbn);
|
||||||
if (details) {
|
if (details) {
|
||||||
data = details.configOptions;
|
const data = createDataStoreEntry(details);
|
||||||
if (data.length) {
|
await this.storageService.setData(key, data);
|
||||||
await this.storageService.setData(key, data);
|
changes.push({ fqbn, data });
|
||||||
shouldFireChanged = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (changes.length) {
|
||||||
|
this.fireChanged(...changes);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
this.onDidChange((event) => {
|
||||||
|
const selectedFqbn =
|
||||||
|
this.boardsServiceProvider.boardsConfig.selectedBoard?.fqbn;
|
||||||
|
if (event.changes.find((change) => change.fqbn === selectedFqbn)) {
|
||||||
|
this.updateSelectedBoardData(selectedFqbn);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Promise.all([
|
||||||
|
this.boardsServiceProvider.ready,
|
||||||
|
this.appStateService.reachedState('ready'),
|
||||||
|
]).then(() =>
|
||||||
|
this.updateSelectedBoardData(
|
||||||
|
this.boardsServiceProvider.boardsConfig.selectedBoard?.fqbn
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getSelectedBoardData(
|
||||||
|
fqbn: string | undefined
|
||||||
|
): Promise<BoardsDataStoreChange | undefined> {
|
||||||
|
if (!fqbn) {
|
||||||
|
return undefined;
|
||||||
|
} else {
|
||||||
|
const data = await this.getData(sanitizeFqbn(fqbn));
|
||||||
|
if (data === BoardsDataStore.Data.EMPTY) {
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
if (shouldFireChanged) {
|
return { fqbn, data };
|
||||||
this.fireChanged();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updateSelectedBoardData(
|
||||||
|
fqbn: string | undefined,
|
||||||
|
updateConfigOptions = false
|
||||||
|
): Promise<void> {
|
||||||
|
this._selectedBoardData = await this.getSelectedBoardData(fqbn);
|
||||||
|
if (fqbn && updateConfigOptions) {
|
||||||
|
const { options } = new FQBN(fqbn);
|
||||||
|
if (options) {
|
||||||
|
const optionsToUpdate = Object.entries(options).map(([key, value]) => ({
|
||||||
|
option: key,
|
||||||
|
selectedValue: value,
|
||||||
|
}));
|
||||||
|
const params = { fqbn, optionsToUpdate };
|
||||||
|
await this.selectConfigOption(params);
|
||||||
|
this._selectedBoardData = await this.getSelectedBoardData(fqbn); // reload the updated data
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onStop(): void {
|
||||||
|
this.toDispose.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
registerCommands(registry: CommandRegistry): void {
|
||||||
|
registry.registerCommand(USE_INHERITED_DATA, {
|
||||||
|
execute: async (arg: unknown) => {
|
||||||
|
if (isBoardsDataStoreChange(arg)) {
|
||||||
|
await this.setData(arg);
|
||||||
|
this.fireChanged(arg);
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get onChanged(): Event<void> {
|
tasks(): StartupTask[] {
|
||||||
return this.onChangedEmitter.event;
|
if (!this._selectedBoardData) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
command: USE_INHERITED_DATA.id,
|
||||||
|
args: [this._selectedBoardData],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
get onDidChange(): Event<BoardsDataStoreChangeEvent> {
|
||||||
|
return this.onDidChangeEmitter.event;
|
||||||
}
|
}
|
||||||
|
|
||||||
async appendConfigToFqbn(
|
async appendConfigToFqbn(
|
||||||
fqbn: string | undefined,
|
fqbn: string | undefined
|
||||||
): Promise<string | undefined> {
|
): Promise<string | undefined> {
|
||||||
if (!fqbn) {
|
if (!fqbn) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const { configOptions } = await this.getData(fqbn);
|
const { configOptions } = await this.getData(fqbn);
|
||||||
return ConfigOption.decorate(fqbn, configOptions);
|
return new FQBN(fqbn).withConfigOptions(...configOptions).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getData(fqbn: string | undefined): Promise<BoardsDataStore.Data> {
|
async getData(fqbn: string | undefined): Promise<BoardsDataStore.Data> {
|
||||||
@@ -80,83 +205,106 @@ export class BoardsDataStore implements FrontendApplicationContribution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const key = this.getStorageKey(fqbn);
|
const key = this.getStorageKey(fqbn);
|
||||||
let data = await this.storageService.getData<
|
const storedData = await this.storageService.getData<
|
||||||
BoardsDataStore.Data | undefined
|
BoardsDataStore.Data | undefined
|
||||||
>(key, undefined);
|
>(key, undefined);
|
||||||
if (BoardsDataStore.Data.is(data)) {
|
if (BoardsDataStore.Data.is(storedData)) {
|
||||||
return data;
|
return storedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
const boardDetails = await this.getBoardDetailsSafe(fqbn);
|
const boardDetails = await this.loadBoardDetails(fqbn);
|
||||||
if (!boardDetails) {
|
if (!boardDetails) {
|
||||||
return BoardsDataStore.Data.EMPTY;
|
return BoardsDataStore.Data.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = {
|
const data = createDataStoreEntry(boardDetails);
|
||||||
configOptions: boardDetails.configOptions,
|
|
||||||
programmers: boardDetails.programmers,
|
|
||||||
};
|
|
||||||
await this.storageService.setData(key, data);
|
await this.storageService.setData(key, data);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectProgrammer(
|
async reloadBoardData(fqbn: string | undefined): Promise<void> {
|
||||||
{
|
if (!fqbn) {
|
||||||
fqbn,
|
return;
|
||||||
selectedProgrammer,
|
}
|
||||||
}: { fqbn: string; selectedProgrammer: Programmer },
|
const key = this.getStorageKey(fqbn);
|
||||||
): Promise<boolean> {
|
const details = await this.loadBoardDetails(fqbn, true);
|
||||||
const data = deepClone(await this.getData(fqbn));
|
if (!details) {
|
||||||
const { programmers } = data;
|
return;
|
||||||
|
}
|
||||||
|
const data = createDataStoreEntry(details);
|
||||||
|
await this.storageService.setData(key, data);
|
||||||
|
this.fireChanged({ fqbn, data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async selectProgrammer({
|
||||||
|
fqbn,
|
||||||
|
selectedProgrammer,
|
||||||
|
}: {
|
||||||
|
fqbn: string;
|
||||||
|
selectedProgrammer: Programmer;
|
||||||
|
}): Promise<boolean> {
|
||||||
|
const sanitizedFQBN = sanitizeFqbn(fqbn);
|
||||||
|
const storedData = deepClone(await this.getData(sanitizedFQBN));
|
||||||
|
const { programmers } = storedData;
|
||||||
if (!programmers.find((p) => Programmer.equals(selectedProgrammer, p))) {
|
if (!programmers.find((p) => Programmer.equals(selectedProgrammer, p))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.setData({
|
const change: BoardsDataStoreChange = {
|
||||||
fqbn,
|
fqbn: sanitizedFQBN,
|
||||||
data: { ...data, selectedProgrammer },
|
data: { ...storedData, selectedProgrammer },
|
||||||
});
|
};
|
||||||
this.fireChanged();
|
await this.setData(change);
|
||||||
|
this.fireChanged(change);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectConfigOption(
|
async selectConfigOption(params: SelectConfigOptionParams): Promise<boolean> {
|
||||||
{
|
const { fqbn, optionsToUpdate } = params;
|
||||||
fqbn,
|
if (!optionsToUpdate.length) {
|
||||||
option,
|
|
||||||
selectedValue,
|
|
||||||
}: { fqbn: string; option: string; selectedValue: string }
|
|
||||||
): Promise<boolean> {
|
|
||||||
const data = deepClone(await this.getData(fqbn));
|
|
||||||
const { configOptions } = data;
|
|
||||||
const configOption = configOptions.find((c) => c.option === option);
|
|
||||||
if (!configOption) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let updated = false;
|
|
||||||
for (const value of configOption.values) {
|
const sanitizedFQBN = sanitizeFqbn(fqbn);
|
||||||
if (value.value === selectedValue) {
|
const mutableData = deepClone(await this.getData(sanitizedFQBN));
|
||||||
(value as any).selected = true;
|
let didChange = false;
|
||||||
updated = true;
|
|
||||||
} else {
|
for (const { option, selectedValue } of optionsToUpdate) {
|
||||||
(value as any).selected = false;
|
const { configOptions } = mutableData;
|
||||||
|
const configOption = configOptions.find((c) => c.option === option);
|
||||||
|
if (configOption) {
|
||||||
|
const configOptionValueIndex = configOption.values.findIndex(
|
||||||
|
(configOptionValue) => configOptionValue.value === selectedValue
|
||||||
|
);
|
||||||
|
if (configOptionValueIndex >= 0) {
|
||||||
|
// unselect all
|
||||||
|
configOption.values
|
||||||
|
.map((value) => value as Mutable<ConfigValue>)
|
||||||
|
.forEach((value) => (value.selected = false));
|
||||||
|
const mutableConfigValue: Mutable<ConfigValue> =
|
||||||
|
configOption.values[configOptionValueIndex];
|
||||||
|
// make the new value `selected`
|
||||||
|
mutableConfigValue.selected = true;
|
||||||
|
didChange = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!updated) {
|
|
||||||
|
if (!didChange) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
await this.setData({ fqbn, data });
|
|
||||||
this.fireChanged();
|
const change: BoardsDataStoreChange = {
|
||||||
|
fqbn: sanitizedFQBN,
|
||||||
|
data: mutableData,
|
||||||
|
};
|
||||||
|
await this.setData(change);
|
||||||
|
this.fireChanged(change);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async setData({
|
protected async setData(change: BoardsDataStoreChange): Promise<void> {
|
||||||
fqbn,
|
const { fqbn, data } = change;
|
||||||
data,
|
|
||||||
}: {
|
|
||||||
fqbn: string;
|
|
||||||
data: BoardsDataStore.Data;
|
|
||||||
}): Promise<void> {
|
|
||||||
const key = this.getStorageKey(fqbn);
|
const key = this.getStorageKey(fqbn);
|
||||||
return this.storageService.setData(key, data);
|
return this.storageService.setData(key, data);
|
||||||
}
|
}
|
||||||
@@ -165,11 +313,15 @@ export class BoardsDataStore implements FrontendApplicationContribution {
|
|||||||
return `.arduinoIDE-configOptions-${fqbn}`;
|
return `.arduinoIDE-configOptions-${fqbn}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getBoardDetailsSafe(
|
async loadBoardDetails(
|
||||||
fqbn: string
|
fqbn: string,
|
||||||
|
forceRefresh = false
|
||||||
): Promise<BoardDetails | undefined> {
|
): Promise<BoardDetails | undefined> {
|
||||||
try {
|
try {
|
||||||
const details = this.boardsService.getBoardDetails({ fqbn });
|
const details = await this.boardsService.getBoardDetails({
|
||||||
|
fqbn,
|
||||||
|
forceRefresh,
|
||||||
|
});
|
||||||
return details;
|
return details;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (
|
if (
|
||||||
@@ -190,8 +342,8 @@ export class BoardsDataStore implements FrontendApplicationContribution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fireChanged(): void {
|
protected fireChanged(...changes: BoardsDataStoreChange[]): void {
|
||||||
this.onChangedEmitter.fire();
|
this.onDidChangeEmitter.fire({ changes });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,20 +352,86 @@ export namespace BoardsDataStore {
|
|||||||
readonly configOptions: ConfigOption[];
|
readonly configOptions: ConfigOption[];
|
||||||
readonly programmers: Programmer[];
|
readonly programmers: Programmer[];
|
||||||
readonly selectedProgrammer?: Programmer;
|
readonly selectedProgrammer?: Programmer;
|
||||||
|
readonly defaultProgrammerId?: string;
|
||||||
}
|
}
|
||||||
export namespace Data {
|
export namespace Data {
|
||||||
export const EMPTY: Data = {
|
export const EMPTY: Data = deepFreeze({
|
||||||
configOptions: [],
|
configOptions: [],
|
||||||
programmers: [],
|
programmers: [],
|
||||||
};
|
});
|
||||||
export function is(arg: any): arg is Data {
|
|
||||||
|
export function is(arg: unknown): arg is Data {
|
||||||
return (
|
return (
|
||||||
!!arg &&
|
typeof arg === 'object' &&
|
||||||
'configOptions' in arg &&
|
arg !== null &&
|
||||||
Array.isArray(arg['configOptions']) &&
|
Array.isArray((<Data>arg).configOptions) &&
|
||||||
'programmers' in arg &&
|
Array.isArray((<Data>arg).programmers) &&
|
||||||
Array.isArray(arg['programmers'])
|
((<Data>arg).selectedProgrammer === undefined ||
|
||||||
|
isProgrammer((<Data>arg).selectedProgrammer)) &&
|
||||||
|
((<Data>arg).defaultProgrammerId === undefined ||
|
||||||
|
typeof (<Data>arg).defaultProgrammerId === 'string')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isEmptyData(data: BoardsDataStore.Data): boolean {
|
||||||
|
return (
|
||||||
|
Boolean(!data.configOptions.length) &&
|
||||||
|
Boolean(!data.programmers.length) &&
|
||||||
|
Boolean(!data.selectedProgrammer) &&
|
||||||
|
Boolean(!data.defaultProgrammerId)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function findDefaultProgrammer(
|
||||||
|
programmers: readonly Programmer[],
|
||||||
|
defaultProgrammerId: string | undefined | BoardsDataStore.Data
|
||||||
|
): Programmer | undefined {
|
||||||
|
if (!defaultProgrammerId) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const id =
|
||||||
|
typeof defaultProgrammerId === 'string'
|
||||||
|
? defaultProgrammerId
|
||||||
|
: defaultProgrammerId.defaultProgrammerId;
|
||||||
|
return programmers.find((p) => p.id === id);
|
||||||
|
}
|
||||||
|
function createDataStoreEntry(details: BoardDetails): BoardsDataStore.Data {
|
||||||
|
const configOptions = details.configOptions.slice();
|
||||||
|
const programmers = details.programmers.slice();
|
||||||
|
const { defaultProgrammerId } = details;
|
||||||
|
const selectedProgrammer = findDefaultProgrammer(
|
||||||
|
programmers,
|
||||||
|
defaultProgrammerId
|
||||||
|
);
|
||||||
|
const data = {
|
||||||
|
configOptions,
|
||||||
|
programmers,
|
||||||
|
...(selectedProgrammer ? { selectedProgrammer } : {}),
|
||||||
|
...(defaultProgrammerId ? { defaultProgrammerId } : {}),
|
||||||
|
};
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BoardsDataStoreChange {
|
||||||
|
readonly fqbn: string;
|
||||||
|
readonly data: BoardsDataStore.Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isBoardsDataStoreChange(arg: unknown): arg is BoardsDataStoreChange {
|
||||||
|
return (
|
||||||
|
typeof arg === 'object' &&
|
||||||
|
arg !== null &&
|
||||||
|
typeof (<BoardsDataStoreChange>arg).fqbn === 'string' &&
|
||||||
|
BoardsDataStore.Data.is((<BoardsDataStoreChange>arg).data)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BoardsDataStoreChangeEvent {
|
||||||
|
readonly changes: readonly BoardsDataStoreChange[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const USE_INHERITED_DATA: Command = {
|
||||||
|
id: 'arduino-use-inherited-boards-data',
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,21 +1,27 @@
|
|||||||
import { inject, injectable, postConstruct } from 'inversify';
|
|
||||||
import {
|
import {
|
||||||
|
inject,
|
||||||
|
injectable,
|
||||||
|
postConstruct,
|
||||||
|
} from '@theia/core/shared/inversify';
|
||||||
|
import {
|
||||||
|
BoardSearch,
|
||||||
BoardsPackage,
|
BoardsPackage,
|
||||||
BoardsService,
|
BoardsService,
|
||||||
} from '../../common/protocol/boards-service';
|
} from '../../common/protocol/boards-service';
|
||||||
import { ListWidget } from '../widgets/component-list/list-widget';
|
import { ListWidget } from '../widgets/component-list/list-widget';
|
||||||
import { ListItemRenderer } from '../widgets/component-list/list-item-renderer';
|
import { ListItemRenderer } from '../widgets/component-list/list-item-renderer';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import { nls } from '@theia/core/lib/common';
|
||||||
|
import { BoardsFilterRenderer } from '../widgets/component-list/filter-renderer';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class BoardsListWidget extends ListWidget<BoardsPackage> {
|
export class BoardsListWidget extends ListWidget<BoardsPackage, BoardSearch> {
|
||||||
static WIDGET_ID = 'boards-list-widget';
|
static WIDGET_ID = 'boards-list-widget';
|
||||||
static WIDGET_LABEL = nls.localize('arduino/boardsManager', 'Boards Manager');
|
static WIDGET_LABEL = nls.localize('arduino/boardsManager', 'Boards Manager');
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@inject(BoardsService) protected service: BoardsService,
|
@inject(BoardsService) service: BoardsService,
|
||||||
@inject(ListItemRenderer)
|
@inject(ListItemRenderer) itemRenderer: ListItemRenderer<BoardsPackage>,
|
||||||
protected itemRenderer: ListItemRenderer<BoardsPackage>
|
@inject(BoardsFilterRenderer) filterRenderer: BoardsFilterRenderer
|
||||||
) {
|
) {
|
||||||
super({
|
super({
|
||||||
id: BoardsListWidget.WIDGET_ID,
|
id: BoardsListWidget.WIDGET_ID,
|
||||||
@@ -24,25 +30,26 @@ export class BoardsListWidget extends ListWidget<BoardsPackage> {
|
|||||||
searchable: service,
|
searchable: service,
|
||||||
installable: service,
|
installable: service,
|
||||||
itemLabel: (item: BoardsPackage) => item.name,
|
itemLabel: (item: BoardsPackage) => item.name,
|
||||||
itemDeprecated: (item: BoardsPackage) => item.deprecated,
|
|
||||||
itemRenderer,
|
itemRenderer,
|
||||||
|
filterRenderer,
|
||||||
|
defaultSearchOptions: { query: '', type: 'All' },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@postConstruct()
|
@postConstruct()
|
||||||
protected init(): void {
|
protected override init(): void {
|
||||||
super.init();
|
super.init();
|
||||||
this.toDispose.pushAll([
|
this.toDispose.pushAll([
|
||||||
this.notificationCenter.onPlatformInstalled(() =>
|
this.notificationCenter.onPlatformDidInstall(() =>
|
||||||
this.refresh(undefined)
|
this.refresh(undefined)
|
||||||
),
|
),
|
||||||
this.notificationCenter.onPlatformUninstalled(() =>
|
this.notificationCenter.onPlatformDidUninstall(() =>
|
||||||
this.refresh(undefined)
|
this.refresh(undefined)
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async install({
|
protected override async install({
|
||||||
item,
|
item,
|
||||||
progressId,
|
progressId,
|
||||||
version,
|
version,
|
||||||
@@ -63,7 +70,7 @@ export class BoardsListWidget extends ListWidget<BoardsPackage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async uninstall({
|
protected override async uninstall({
|
||||||
item,
|
item,
|
||||||
progressId,
|
progressId,
|
||||||
}: {
|
}: {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,21 @@
|
|||||||
import * as React from 'react';
|
import { TabBarToolbar } from '@theia/core/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar';
|
||||||
import * as ReactDOM from 'react-dom';
|
import { codicon } from '@theia/core/lib/browser/widgets/widget';
|
||||||
import { CommandRegistry } from '@theia/core/lib/common/command';
|
import { CommandRegistry } from '@theia/core/lib/common/command';
|
||||||
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
|
||||||
import { Port } from '../../common/protocol';
|
|
||||||
import { BoardsConfig } from './boards-config';
|
|
||||||
import { ArduinoCommands } from '../arduino-commands';
|
|
||||||
import {
|
import {
|
||||||
|
Disposable,
|
||||||
|
DisposableCollection,
|
||||||
|
} from '@theia/core/lib/common/disposable';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import React from '@theia/core/shared/react';
|
||||||
|
import ReactDOM from '@theia/core/shared/react-dom';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import { boardIdentifierLabel, Port } from '../../common/protocol';
|
||||||
|
import { BoardListItemUI } from '../../common/protocol/board-list';
|
||||||
|
import { assertUnreachable } from '../../common/utils';
|
||||||
|
import type {
|
||||||
|
BoardListUI,
|
||||||
BoardsServiceProvider,
|
BoardsServiceProvider,
|
||||||
AvailableBoard,
|
|
||||||
} from './boards-service-provider';
|
} from './boards-service-provider';
|
||||||
import { nls } from '@theia/core/lib/common';
|
|
||||||
|
|
||||||
export interface BoardsDropDownListCoords {
|
export interface BoardsDropDownListCoords {
|
||||||
readonly top: number;
|
readonly top: number;
|
||||||
@@ -21,17 +27,19 @@ export interface BoardsDropDownListCoords {
|
|||||||
export namespace BoardsDropDown {
|
export namespace BoardsDropDown {
|
||||||
export interface Props {
|
export interface Props {
|
||||||
readonly coords: BoardsDropDownListCoords | 'hidden';
|
readonly coords: BoardsDropDownListCoords | 'hidden';
|
||||||
readonly items: Array<AvailableBoard & { onClick: () => void; port: Port }>;
|
readonly boardList: BoardListUI;
|
||||||
readonly openBoardsConfig: () => void;
|
readonly openBoardsConfig: () => void;
|
||||||
|
readonly hide: () => void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BoardsDropDown extends React.Component<BoardsDropDown.Props> {
|
export class BoardListDropDown extends React.Component<BoardsDropDown.Props> {
|
||||||
protected dropdownElement: HTMLElement;
|
private dropdownElement: HTMLElement;
|
||||||
|
private listRef: React.RefObject<HTMLDivElement>;
|
||||||
|
|
||||||
constructor(props: BoardsDropDown.Props) {
|
constructor(props: BoardsDropDown.Props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
this.listRef = React.createRef();
|
||||||
let list = document.getElementById('boards-dropdown-container');
|
let list = document.getElementById('boards-dropdown-container');
|
||||||
if (!list) {
|
if (!list) {
|
||||||
list = document.createElement('div');
|
list = document.createElement('div');
|
||||||
@@ -41,12 +49,21 @@ export class BoardsDropDown extends React.Component<BoardsDropDown.Props> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render(): React.ReactNode {
|
override componentDidUpdate(prevProps: BoardsDropDown.Props): void {
|
||||||
return ReactDOM.createPortal(this.renderNode(), this.dropdownElement);
|
if (prevProps.coords === 'hidden' && this.listRef.current) {
|
||||||
|
this.listRef.current.focus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected renderNode(): React.ReactNode {
|
override render(): React.ReactNode {
|
||||||
const { coords, items } = this.props;
|
return ReactDOM.createPortal(
|
||||||
|
this.renderBoardListItems(),
|
||||||
|
this.dropdownElement
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private renderBoardListItems(): React.ReactNode {
|
||||||
|
const { coords, boardList } = this.props;
|
||||||
if (coords === 'hidden') {
|
if (coords === 'hidden') {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -61,21 +78,20 @@ export class BoardsDropDown extends React.Component<BoardsDropDown.Props> {
|
|||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
...coords,
|
...coords,
|
||||||
}}
|
}}
|
||||||
|
ref={this.listRef}
|
||||||
|
tabIndex={0}
|
||||||
>
|
>
|
||||||
{items
|
<div className="arduino-boards-dropdown-list--items-container">
|
||||||
.map(({ name, port, selected, onClick }) => ({
|
{boardList.items.map((item, index) =>
|
||||||
label: nls.localize(
|
this.renderBoardListItem({
|
||||||
'arduino/board/boardListItem',
|
item,
|
||||||
'{0} at {1}',
|
selected: index === boardList.selectedIndex,
|
||||||
name,
|
})
|
||||||
Port.toString(port)
|
)}
|
||||||
),
|
</div>
|
||||||
selected,
|
|
||||||
onClick,
|
|
||||||
}))
|
|
||||||
.map(this.renderItem)}
|
|
||||||
<div
|
<div
|
||||||
key={footerLabel}
|
key={footerLabel}
|
||||||
|
tabIndex={0}
|
||||||
className="arduino-boards-dropdown-item arduino-board-dropdown-footer"
|
className="arduino-boards-dropdown-item arduino-board-dropdown-footer"
|
||||||
onClick={() => this.props.openBoardsConfig()}
|
onClick={() => this.props.openBoardsConfig()}
|
||||||
>
|
>
|
||||||
@@ -85,23 +101,125 @@ export class BoardsDropDown extends React.Component<BoardsDropDown.Props> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected renderItem({
|
private readonly onDefaultAction = (item: BoardListItemUI): unknown => {
|
||||||
label,
|
const { boardList, hide } = this.props;
|
||||||
|
const { type, params } = item.defaultAction;
|
||||||
|
hide();
|
||||||
|
switch (type) {
|
||||||
|
case 'select-boards-config': {
|
||||||
|
return boardList.select(params);
|
||||||
|
}
|
||||||
|
case 'edit-boards-config': {
|
||||||
|
return boardList.edit(params);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return assertUnreachable(type);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private renderBoardListItem({
|
||||||
|
item,
|
||||||
selected,
|
selected,
|
||||||
onClick,
|
|
||||||
}: {
|
}: {
|
||||||
label: string;
|
item: BoardListItemUI;
|
||||||
selected?: boolean;
|
selected: boolean;
|
||||||
onClick: () => void;
|
|
||||||
}): React.ReactNode {
|
}): React.ReactNode {
|
||||||
|
const { boardLabel, portLabel, portProtocol, tooltip } = item.labels;
|
||||||
|
const port = item.port;
|
||||||
|
const onKeyUp = (e: React.KeyboardEvent) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
this.onDefaultAction(item);
|
||||||
|
}
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={label}
|
key={`board-item--${Port.keyOf(port)}`}
|
||||||
className={`arduino-boards-dropdown-item ${selected ? 'selected' : ''}`}
|
className={classNames('arduino-boards-dropdown-item', {
|
||||||
onClick={onClick}
|
'arduino-boards-dropdown-item--selected': selected,
|
||||||
|
})}
|
||||||
|
onClick={() => this.onDefaultAction(item)}
|
||||||
|
onKeyUp={onKeyUp}
|
||||||
|
tabIndex={0}
|
||||||
>
|
>
|
||||||
<div>{label}</div>
|
<div
|
||||||
{selected ? <span className="fa fa-check" /> : ''}
|
className={classNames(
|
||||||
|
'arduino-boards-dropdown-item--protocol',
|
||||||
|
'fa',
|
||||||
|
iconNameFromProtocol(portProtocol)
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<div className="arduino-boards-dropdown-item--label" title={tooltip}>
|
||||||
|
<div className="arduino-boards-dropdown-item--board-header">
|
||||||
|
<div className="arduino-boards-dropdown-item--board-label noWrapInfo noselect">
|
||||||
|
{boardLabel}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="arduino-boards-dropdown-item--port-label noWrapInfo noselect">
|
||||||
|
{portLabel}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{this.renderActions(item)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private renderActions(item: BoardListItemUI): React.ReactNode {
|
||||||
|
const { boardList, hide } = this.props;
|
||||||
|
const { revert, edit } = item.otherActions;
|
||||||
|
if (!edit && !revert) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const handleOnClick = (
|
||||||
|
event: React.MouseEvent<HTMLElement, MouseEvent>,
|
||||||
|
callback: () => void
|
||||||
|
) => {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
hide();
|
||||||
|
callback();
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div className={TabBarToolbar.Styles.TAB_BAR_TOOLBAR}>
|
||||||
|
{edit && (
|
||||||
|
<div
|
||||||
|
className={`${TabBarToolbar.Styles.TAB_BAR_TOOLBAR_ITEM} enabled`}
|
||||||
|
>
|
||||||
|
{
|
||||||
|
<div
|
||||||
|
id="edit"
|
||||||
|
className={codicon('pencil', true)}
|
||||||
|
title={nls.localize(
|
||||||
|
'arduino/board/editBoardsConfig',
|
||||||
|
'Edit Board and Port...'
|
||||||
|
)}
|
||||||
|
onClick={(event) =>
|
||||||
|
handleOnClick(event, () => boardList.edit(edit.params))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{revert && (
|
||||||
|
<div
|
||||||
|
className={`${TabBarToolbar.Styles.TAB_BAR_TOOLBAR_ITEM} enabled`}
|
||||||
|
>
|
||||||
|
{
|
||||||
|
<div
|
||||||
|
id="revert"
|
||||||
|
className={codicon('discard', true)}
|
||||||
|
title={nls.localize(
|
||||||
|
'arduino/board/revertBoardsConfig',
|
||||||
|
"Use '{0}' discovered on '{1}'",
|
||||||
|
boardIdentifierLabel(revert.params.selectedBoard),
|
||||||
|
item.labels.portLabel
|
||||||
|
)}
|
||||||
|
onClick={(event) =>
|
||||||
|
handleOnClick(event, () => boardList.select(revert.params))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -113,34 +231,35 @@ export class BoardsToolBarItem extends React.Component<
|
|||||||
> {
|
> {
|
||||||
static TOOLBAR_ID: 'boards-toolbar';
|
static TOOLBAR_ID: 'boards-toolbar';
|
||||||
|
|
||||||
protected readonly toDispose: DisposableCollection =
|
private readonly toDispose: DisposableCollection;
|
||||||
new DisposableCollection();
|
|
||||||
|
|
||||||
constructor(props: BoardsToolBarItem.Props) {
|
constructor(props: BoardsToolBarItem.Props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
const { boardList } = props.boardsServiceProvider;
|
||||||
const { availableBoards } = props.boardsServiceClient;
|
|
||||||
this.state = {
|
this.state = {
|
||||||
availableBoards,
|
boardList,
|
||||||
coords: 'hidden',
|
coords: 'hidden',
|
||||||
};
|
};
|
||||||
|
const listener = () => this.setState({ coords: 'hidden' });
|
||||||
document.addEventListener('click', () => {
|
document.addEventListener('click', listener);
|
||||||
this.setState({ coords: 'hidden' });
|
this.toDispose = new DisposableCollection(
|
||||||
});
|
Disposable.create(() => document.removeEventListener('click', listener))
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.props.boardsServiceClient.onAvailableBoardsChanged((availableBoards) =>
|
|
||||||
this.setState({ availableBoards })
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount(): void {
|
override componentDidMount(): void {
|
||||||
|
this.toDispose.push(
|
||||||
|
this.props.boardsServiceProvider.onBoardListDidChange((boardList) =>
|
||||||
|
this.setState({ boardList })
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
override componentWillUnmount(): void {
|
||||||
this.toDispose.dispose();
|
this.toDispose.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected readonly show = (event: React.MouseEvent<HTMLElement>) => {
|
private readonly show = (event: React.MouseEvent<HTMLElement>): void => {
|
||||||
const { currentTarget: element } = event;
|
const { currentTarget: element } = event;
|
||||||
if (element instanceof HTMLElement) {
|
if (element instanceof HTMLElement) {
|
||||||
if (this.state.coords === 'hidden') {
|
if (this.state.coords === 'hidden') {
|
||||||
@@ -161,78 +280,73 @@ export class BoardsToolBarItem extends React.Component<
|
|||||||
event.nativeEvent.stopImmediatePropagation();
|
event.nativeEvent.stopImmediatePropagation();
|
||||||
};
|
};
|
||||||
|
|
||||||
render(): React.ReactNode {
|
private readonly hide = () => {
|
||||||
const { coords, availableBoards } = this.state;
|
this.setState({ coords: 'hidden' });
|
||||||
const boardsConfig = this.props.boardsServiceClient.boardsConfig;
|
};
|
||||||
const title = BoardsConfig.Config.toString(boardsConfig, {
|
|
||||||
default: nls.localize(
|
|
||||||
'arduino/common/noBoardSelected',
|
|
||||||
'No board selected'
|
|
||||||
),
|
|
||||||
});
|
|
||||||
const decorator = (() => {
|
|
||||||
const selectedBoard = availableBoards.find(({ selected }) => selected);
|
|
||||||
if (!selectedBoard || !selectedBoard.port) {
|
|
||||||
return 'fa fa-times notAttached';
|
|
||||||
}
|
|
||||||
if (selectedBoard.state === AvailableBoard.State.guessed) {
|
|
||||||
return 'fa fa-exclamation-triangle guessed';
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
})();
|
|
||||||
|
|
||||||
|
override render(): React.ReactNode {
|
||||||
|
const { coords, boardList } = this.state;
|
||||||
|
const { boardLabel, selected, portProtocol, tooltip } = boardList.labels;
|
||||||
|
const protocolIcon = portProtocol
|
||||||
|
? iconNameFromProtocol(portProtocol)
|
||||||
|
: null;
|
||||||
|
const protocolIconClassNames = classNames(
|
||||||
|
'arduino-boards-toolbar-item--protocol',
|
||||||
|
'fa',
|
||||||
|
protocolIcon
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<div className="arduino-boards-toolbar-item-container">
|
<div
|
||||||
<div className="arduino-boards-toolbar-item" title={title}>
|
className="arduino-boards-toolbar-item-container"
|
||||||
<div className="inner-container" onClick={this.show}>
|
title={tooltip}
|
||||||
<span className={decorator} />
|
onClick={this.show}
|
||||||
<div className="label noWrapInfo">
|
>
|
||||||
<div className="noWrapInfo noselect">{title}</div>
|
{protocolIcon && <div className={protocolIconClassNames} />}
|
||||||
</div>
|
<div
|
||||||
<span className="fa fa-caret-down caret" />
|
className={classNames(
|
||||||
</div>
|
'arduino-boards-toolbar-item--label',
|
||||||
|
'noWrapInfo',
|
||||||
|
'noselect',
|
||||||
|
{ 'arduino-boards-toolbar-item--label-connected': selected }
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{boardLabel}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="fa fa-caret-down caret" />
|
||||||
</div>
|
</div>
|
||||||
<BoardsDropDown
|
<BoardListDropDown
|
||||||
coords={coords}
|
coords={coords}
|
||||||
items={availableBoards
|
boardList={boardList}
|
||||||
.filter(AvailableBoard.hasPort)
|
openBoardsConfig={() => boardList.edit({ query: '' })}
|
||||||
.map((board) => ({
|
hide={this.hide}
|
||||||
...board,
|
/>
|
||||||
onClick: () => {
|
|
||||||
if (board.state === AvailableBoard.State.incomplete) {
|
|
||||||
this.props.boardsServiceClient.boardsConfig = {
|
|
||||||
selectedPort: board.port,
|
|
||||||
};
|
|
||||||
this.openDialog();
|
|
||||||
} else {
|
|
||||||
this.props.boardsServiceClient.boardsConfig = {
|
|
||||||
selectedBoard: board,
|
|
||||||
selectedPort: board.port,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}))}
|
|
||||||
openBoardsConfig={this.openDialog}
|
|
||||||
></BoardsDropDown>
|
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected openDialog = () => {
|
|
||||||
this.props.commands.executeCommand(ArduinoCommands.OPEN_BOARDS_DIALOG.id);
|
|
||||||
this.setState({ coords: 'hidden' });
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
export namespace BoardsToolBarItem {
|
export namespace BoardsToolBarItem {
|
||||||
export interface Props {
|
export interface Props {
|
||||||
readonly boardsServiceClient: BoardsServiceProvider;
|
readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
readonly commands: CommandRegistry;
|
readonly commands: CommandRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
availableBoards: AvailableBoard[];
|
boardList: BoardListUI;
|
||||||
coords: BoardsDropDownListCoords | 'hidden';
|
coords: BoardsDropDownListCoords | 'hidden';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function iconNameFromProtocol(protocol: string): string {
|
||||||
|
switch (protocol) {
|
||||||
|
case 'serial':
|
||||||
|
return 'fa-arduino-technology-usb';
|
||||||
|
case 'network':
|
||||||
|
return 'fa-arduino-technology-connection';
|
||||||
|
// it is fine to assign dedicated icons to the protocols used by the official boards,
|
||||||
|
// but other than that it is best to avoid implementing any special handling
|
||||||
|
// for specific protocols in the IDE codebase.
|
||||||
|
default:
|
||||||
|
return 'fa-arduino-technology-3dimensionscube';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
import { injectable } from 'inversify';
|
import { injectable } from '@theia/core/shared/inversify';
|
||||||
import { BoardsListWidget } from './boards-list-widget';
|
import {
|
||||||
import { BoardsPackage } from '../../common/protocol/boards-service';
|
BoardSearch,
|
||||||
|
BoardsPackage,
|
||||||
|
} from '../../common/protocol/boards-service';
|
||||||
|
import { URI } from '../contributions/contribution';
|
||||||
import { ListWidgetFrontendContribution } from '../widgets/component-list/list-widget-frontend-contribution';
|
import { ListWidgetFrontendContribution } from '../widgets/component-list/list-widget-frontend-contribution';
|
||||||
|
import { BoardsListWidget } from './boards-list-widget';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class BoardsListWidgetFrontendContribution extends ListWidgetFrontendContribution<BoardsPackage> {
|
export class BoardsListWidgetFrontendContribution extends ListWidgetFrontendContribution<
|
||||||
|
BoardsPackage,
|
||||||
|
BoardSearch
|
||||||
|
> {
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
widgetId: BoardsListWidget.WIDGET_ID,
|
widgetId: BoardsListWidget.WIDGET_ID,
|
||||||
@@ -18,7 +25,16 @@ export class BoardsListWidgetFrontendContribution extends ListWidgetFrontendCont
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async initializeLayout(): Promise<void> {
|
protected canParse(uri: URI): boolean {
|
||||||
this.openView();
|
try {
|
||||||
|
BoardSearch.UriParser.parse(uri);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected parse(uri: URI): BoardSearch | undefined {
|
||||||
|
return BoardSearch.UriParser.parse(uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as React from 'react';
|
import React from '@theia/core/shared/react';
|
||||||
|
|
||||||
export type ProgressBarProps = {
|
export type ProgressBarProps = {
|
||||||
percent?: number;
|
percent?: number;
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution';
|
||||||
|
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
||||||
|
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
||||||
|
import { Emitter, Event } from '@theia/core/lib/common/event';
|
||||||
|
import { MessageService } from '@theia/core/lib/common/message-service';
|
||||||
|
import { deepClone } from '@theia/core/lib/common/objects';
|
||||||
|
import URI from '@theia/core/lib/common/uri';
|
||||||
|
import {
|
||||||
|
inject,
|
||||||
|
injectable,
|
||||||
|
postConstruct,
|
||||||
|
} from '@theia/core/shared/inversify';
|
||||||
|
import { ConfigService, ConfigState } from '../../common/protocol';
|
||||||
|
import { NotificationCenter } from '../notification-center';
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class ConfigServiceClient implements FrontendApplicationContribution {
|
||||||
|
@inject(ConfigService)
|
||||||
|
private readonly delegate: ConfigService;
|
||||||
|
@inject(NotificationCenter)
|
||||||
|
private readonly notificationCenter: NotificationCenter;
|
||||||
|
@inject(FrontendApplicationStateService)
|
||||||
|
private readonly appStateService: FrontendApplicationStateService;
|
||||||
|
@inject(MessageService)
|
||||||
|
private readonly messageService: MessageService;
|
||||||
|
|
||||||
|
private readonly didChangeSketchDirUriEmitter = new Emitter<
|
||||||
|
URI | undefined
|
||||||
|
>();
|
||||||
|
private readonly didChangeDataDirUriEmitter = new Emitter<URI | undefined>();
|
||||||
|
private readonly toDispose = new DisposableCollection(
|
||||||
|
this.didChangeSketchDirUriEmitter,
|
||||||
|
this.didChangeDataDirUriEmitter
|
||||||
|
);
|
||||||
|
|
||||||
|
private config: ConfigState | undefined;
|
||||||
|
|
||||||
|
@postConstruct()
|
||||||
|
protected init(): void {
|
||||||
|
this.appStateService.reachedState('ready').then(async () => {
|
||||||
|
const config = await this.delegate.getConfiguration();
|
||||||
|
this.use(config);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onStart(): void {
|
||||||
|
this.notificationCenter.onConfigDidChange((config) => this.use(config));
|
||||||
|
}
|
||||||
|
|
||||||
|
onStop(): void {
|
||||||
|
this.toDispose.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
get onDidChangeSketchDirUri(): Event<URI | undefined> {
|
||||||
|
return this.didChangeSketchDirUriEmitter.event;
|
||||||
|
}
|
||||||
|
|
||||||
|
get onDidChangeDataDirUri(): Event<URI | undefined> {
|
||||||
|
return this.didChangeDataDirUriEmitter.event;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CLI config related error messages if any.
|
||||||
|
*/
|
||||||
|
tryGetMessages(): string[] | undefined {
|
||||||
|
return this.config?.messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `directories.user`
|
||||||
|
*/
|
||||||
|
tryGetSketchDirUri(): URI | undefined {
|
||||||
|
return this.config?.config?.sketchDirUri
|
||||||
|
? new URI(this.config?.config?.sketchDirUri)
|
||||||
|
: undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `directories.data`
|
||||||
|
*/
|
||||||
|
tryGetDataDirUri(): URI | undefined {
|
||||||
|
return this.config?.config?.dataDirUri
|
||||||
|
? new URI(this.config?.config?.dataDirUri)
|
||||||
|
: undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
private use(config: ConfigState): void {
|
||||||
|
const oldConfig = deepClone(this.config);
|
||||||
|
this.config = config;
|
||||||
|
if (oldConfig?.config?.sketchDirUri !== this.config?.config?.sketchDirUri) {
|
||||||
|
this.didChangeSketchDirUriEmitter.fire(this.tryGetSketchDirUri());
|
||||||
|
}
|
||||||
|
if (oldConfig?.config?.dataDirUri !== this.config?.config?.dataDirUri) {
|
||||||
|
this.didChangeDataDirUriEmitter.fire(this.tryGetDataDirUri());
|
||||||
|
}
|
||||||
|
if (this.config.messages?.length) {
|
||||||
|
const message = this.config.messages.join(' ');
|
||||||
|
// toast the error later otherwise it might not show up in IDE2
|
||||||
|
setTimeout(() => this.messageService.error(message), 1_000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,34 +1,32 @@
|
|||||||
import { inject, injectable } from 'inversify';
|
|
||||||
import * as moment from 'moment';
|
|
||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
|
||||||
import { isOSX, isWindows } from '@theia/core/lib/common/os';
|
|
||||||
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
|
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
|
||||||
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
|
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
|
||||||
import {
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
Contribution,
|
import { isOSX, isWindows } from '@theia/core/lib/common/os';
|
||||||
Command,
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
MenuModelRegistry,
|
import moment from 'moment';
|
||||||
CommandRegistry,
|
import { AppService } from '../app-service';
|
||||||
} from './contribution';
|
|
||||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
import { ConfigService } from '../../common/protocol';
|
import {
|
||||||
import { nls } from '@theia/core/lib/common';
|
Command,
|
||||||
|
CommandRegistry,
|
||||||
|
Contribution,
|
||||||
|
MenuModelRegistry,
|
||||||
|
} from './contribution';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class About extends Contribution {
|
export class About extends Contribution {
|
||||||
@inject(ClipboardService)
|
@inject(ClipboardService)
|
||||||
protected readonly clipboardService: ClipboardService;
|
private readonly clipboardService: ClipboardService;
|
||||||
|
@inject(AppService)
|
||||||
|
private readonly appService: AppService;
|
||||||
|
|
||||||
@inject(ConfigService)
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
protected readonly configService: ConfigService;
|
|
||||||
|
|
||||||
registerCommands(registry: CommandRegistry): void {
|
|
||||||
registry.registerCommand(About.Commands.ABOUT_APP, {
|
registry.registerCommand(About.Commands.ABOUT_APP, {
|
||||||
execute: () => this.showAbout(),
|
execute: () => this.showAbout(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMenus(registry: MenuModelRegistry): void {
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
registry.registerMenuAction(ArduinoMenus.HELP__ABOUT_GROUP, {
|
registry.registerMenuAction(ArduinoMenus.HELP__ABOUT_GROUP, {
|
||||||
commandId: About.Commands.ABOUT_APP.id,
|
commandId: About.Commands.ABOUT_APP.id,
|
||||||
label: nls.localize(
|
label: nls.localize(
|
||||||
@@ -40,23 +38,18 @@ export class About extends Contribution {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async showAbout(): Promise<void> {
|
private async showAbout(): Promise<void> {
|
||||||
const {
|
const appInfo = await this.appService.info();
|
||||||
version,
|
const { appVersion, cliVersion, buildDate } = appInfo;
|
||||||
commit,
|
|
||||||
status: cliStatus,
|
|
||||||
} = await this.configService.getVersion();
|
|
||||||
const buildDate = this.buildDate;
|
|
||||||
const detail = (showAll: boolean) =>
|
const detail = (showAll: boolean) =>
|
||||||
nls.localize(
|
nls.localize(
|
||||||
'arduino/about/detail',
|
'arduino/about/detail',
|
||||||
'Version: {0}\nDate: {1}{2}\nCLI Version: {3}{4} [{5}]\n\n{6}',
|
'Version: {0}\nDate: {1}{2}\nCLI Version: {3}\n\n{4}',
|
||||||
remote.app.getVersion(),
|
appVersion,
|
||||||
buildDate ? buildDate : nls.localize('', 'dev build'),
|
buildDate ? buildDate : nls.localize('', 'dev build'),
|
||||||
buildDate && showAll ? ` (${this.ago(buildDate)})` : '',
|
buildDate && showAll ? ` (${this.ago(buildDate)})` : '',
|
||||||
version,
|
cliVersion,
|
||||||
cliStatus ? ` ${cliStatus}` : '',
|
|
||||||
commit,
|
|
||||||
nls.localize(
|
nls.localize(
|
||||||
'arduino/about/copyright',
|
'arduino/about/copyright',
|
||||||
'Copyright © {0} Arduino SA',
|
'Copyright © {0} Arduino SA',
|
||||||
@@ -66,34 +59,27 @@ export class About extends Contribution {
|
|||||||
const ok = nls.localize('vscode/issueMainService/ok', 'OK');
|
const ok = nls.localize('vscode/issueMainService/ok', 'OK');
|
||||||
const copy = nls.localize('vscode/textInputActions/copy', 'Copy');
|
const copy = nls.localize('vscode/textInputActions/copy', 'Copy');
|
||||||
const buttons = !isWindows && !isOSX ? [copy, ok] : [ok, copy];
|
const buttons = !isWindows && !isOSX ? [copy, ok] : [ok, copy];
|
||||||
const { response } = await remote.dialog.showMessageBox(
|
const { response } = await this.dialogService.showMessageBox({
|
||||||
remote.getCurrentWindow(),
|
message: `${this.applicationName}`,
|
||||||
{
|
title: `${this.applicationName}`,
|
||||||
message: `${this.applicationName}`,
|
type: 'info',
|
||||||
title: `${this.applicationName}`,
|
detail: detail(true),
|
||||||
type: 'info',
|
buttons,
|
||||||
detail: detail(true),
|
noLink: true,
|
||||||
buttons,
|
defaultId: buttons.indexOf(ok),
|
||||||
noLink: true,
|
cancelId: buttons.indexOf(ok),
|
||||||
defaultId: buttons.indexOf(ok),
|
});
|
||||||
cancelId: buttons.indexOf(ok),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (buttons[response] === copy) {
|
if (buttons[response] === copy) {
|
||||||
await this.clipboardService.writeText(detail(false).trim());
|
await this.clipboardService.writeText(detail(false).trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected get applicationName(): string {
|
private get applicationName(): string {
|
||||||
return FrontendApplicationConfigProvider.get().applicationName;
|
return FrontendApplicationConfigProvider.get().applicationName;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected get buildDate(): string | undefined {
|
private ago(isoTime: string): string {
|
||||||
return FrontendApplicationConfigProvider.get().buildDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ago(isoTime: string): string {
|
|
||||||
const now = moment(Date.now());
|
const now = moment(Date.now());
|
||||||
const other = moment(isoTime);
|
const other = moment(isoTime);
|
||||||
let result = now.diff(other, 'minute');
|
let result = now.diff(other, 'minute');
|
||||||
|
|||||||
155
arduino-ide-extension/src/browser/contributions/account.ts
Normal file
155
arduino-ide-extension/src/browser/contributions/account.ts
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
|
||||||
|
import { SidebarMenu } from '@theia/core/lib/browser/shell/sidebar-menu-widget';
|
||||||
|
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
||||||
|
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
||||||
|
import { MenuPath } from '@theia/core/lib/common/menu';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { CloudUserCommands, LEARN_MORE_URL } from '../auth/cloud-user-commands';
|
||||||
|
import { CreateFeatures } from '../create/create-features';
|
||||||
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
|
import { ApplicationConnectionStatusContribution } from '../theia/core/connection-status-service';
|
||||||
|
import {
|
||||||
|
Command,
|
||||||
|
CommandRegistry,
|
||||||
|
Contribution,
|
||||||
|
MenuModelRegistry,
|
||||||
|
} from './contribution';
|
||||||
|
|
||||||
|
export const accountMenu: SidebarMenu = {
|
||||||
|
id: 'arduino-accounts-menu',
|
||||||
|
iconClass: 'codicon codicon-account',
|
||||||
|
title: nls.localize('arduino/account/menuTitle', 'Arduino Cloud'),
|
||||||
|
menuPath: ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT,
|
||||||
|
order: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class Account extends Contribution {
|
||||||
|
@inject(WindowService)
|
||||||
|
private readonly windowService: WindowService;
|
||||||
|
@inject(CreateFeatures)
|
||||||
|
private readonly createFeatures: CreateFeatures;
|
||||||
|
@inject(ApplicationConnectionStatusContribution)
|
||||||
|
private readonly connectionStatus: ApplicationConnectionStatusContribution;
|
||||||
|
|
||||||
|
private readonly toDispose = new DisposableCollection();
|
||||||
|
private app: FrontendApplication;
|
||||||
|
|
||||||
|
override onStart(app: FrontendApplication): void {
|
||||||
|
this.app = app;
|
||||||
|
this.updateSidebarCommand();
|
||||||
|
this.toDispose.push(
|
||||||
|
this.createFeatures.onDidChangeEnabled((enabled) =>
|
||||||
|
this.updateSidebarCommand(enabled)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onStop(): void {
|
||||||
|
this.toDispose.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
|
const openExternal = (url: string) =>
|
||||||
|
this.windowService.openNewWindow(url, { external: true });
|
||||||
|
const loggedIn = () => Boolean(this.createFeatures.session);
|
||||||
|
const loggedInWithInternetConnection = () =>
|
||||||
|
loggedIn() && this.connectionStatus.offlineStatus !== 'internet';
|
||||||
|
registry.registerCommand(Account.Commands.LEARN_MORE, {
|
||||||
|
execute: () => openExternal(LEARN_MORE_URL),
|
||||||
|
isEnabled: () => !loggedIn(),
|
||||||
|
isVisible: () => !loggedIn(),
|
||||||
|
});
|
||||||
|
registry.registerCommand(Account.Commands.GO_TO_PROFILE, {
|
||||||
|
execute: () => openExternal('https://id.arduino.cc/'),
|
||||||
|
isEnabled: () => loggedInWithInternetConnection(),
|
||||||
|
isVisible: () => loggedIn(),
|
||||||
|
});
|
||||||
|
registry.registerCommand(Account.Commands.GO_TO_CLOUD_EDITOR, {
|
||||||
|
execute: () => openExternal('https://create.arduino.cc/editor'),
|
||||||
|
isEnabled: () => loggedInWithInternetConnection(),
|
||||||
|
isVisible: () => loggedIn(),
|
||||||
|
});
|
||||||
|
registry.registerCommand(Account.Commands.GO_TO_IOT_CLOUD, {
|
||||||
|
execute: () => openExternal('https://create.arduino.cc/iot/'),
|
||||||
|
isEnabled: () => loggedInWithInternetConnection(),
|
||||||
|
isVisible: () => loggedIn(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
|
const register = (
|
||||||
|
menuPath: MenuPath,
|
||||||
|
...commands: (Command | [command: Command, menuLabel: string])[]
|
||||||
|
) =>
|
||||||
|
commands.forEach((command, index) => {
|
||||||
|
const commandId = Array.isArray(command) ? command[0].id : command.id;
|
||||||
|
const label = Array.isArray(command) ? command[1] : command.label;
|
||||||
|
registry.registerMenuAction(menuPath, {
|
||||||
|
label,
|
||||||
|
commandId,
|
||||||
|
order: String(index),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
register(ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__SIGN_IN_GROUP, [
|
||||||
|
CloudUserCommands.LOGIN,
|
||||||
|
nls.localize('arduino/cloud/signInToCloud', 'Sign in to Arduino Cloud'),
|
||||||
|
]);
|
||||||
|
register(ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__LEARN_MORE_GROUP, [
|
||||||
|
Account.Commands.LEARN_MORE,
|
||||||
|
nls.localize('arduino/cloud/learnMore', 'Learn more'),
|
||||||
|
]);
|
||||||
|
register(
|
||||||
|
ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__GO_TO_GROUP,
|
||||||
|
[
|
||||||
|
Account.Commands.GO_TO_PROFILE,
|
||||||
|
nls.localize('arduino/account/goToProfile', 'Go to Profile'),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
Account.Commands.GO_TO_CLOUD_EDITOR,
|
||||||
|
nls.localize('arduino/account/goToCloudEditor', 'Go to Cloud Editor'),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
Account.Commands.GO_TO_IOT_CLOUD,
|
||||||
|
nls.localize('arduino/account/goToIoTCloud', 'Go to IoT Cloud'),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
register(
|
||||||
|
ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__SIGN_OUT_GROUP,
|
||||||
|
CloudUserCommands.LOGOUT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateSidebarCommand(
|
||||||
|
visible: boolean = this.preferences['arduino.cloud.enabled']
|
||||||
|
): void {
|
||||||
|
if (!this.app) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const handler = this.app.shell.leftPanelHandler;
|
||||||
|
if (visible) {
|
||||||
|
handler.addBottomMenu(accountMenu);
|
||||||
|
} else {
|
||||||
|
handler.removeBottomMenu(accountMenu.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace Account {
|
||||||
|
export namespace Commands {
|
||||||
|
export const GO_TO_PROFILE: Command = {
|
||||||
|
id: 'arduino-go-to-profile',
|
||||||
|
};
|
||||||
|
export const GO_TO_CLOUD_EDITOR: Command = {
|
||||||
|
id: 'arduino-go-to-cloud-editor',
|
||||||
|
};
|
||||||
|
export const GO_TO_IOT_CLOUD: Command = {
|
||||||
|
id: 'arduino-go-to-iot-cloud',
|
||||||
|
};
|
||||||
|
export const LEARN_MORE: Command = {
|
||||||
|
id: 'arduino-learn-more',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,28 +1,29 @@
|
|||||||
import { inject, injectable } from 'inversify';
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { FileDialogService } from '@theia/filesystem/lib/browser';
|
||||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
|
import { CurrentSketch } from '../sketches-service-client-impl';
|
||||||
import {
|
import {
|
||||||
SketchContribution,
|
|
||||||
Command,
|
Command,
|
||||||
CommandRegistry,
|
CommandRegistry,
|
||||||
MenuModelRegistry,
|
MenuModelRegistry,
|
||||||
|
Sketch,
|
||||||
|
SketchContribution,
|
||||||
URI,
|
URI,
|
||||||
} from './contribution';
|
} from './contribution';
|
||||||
import { FileDialogService } from '@theia/filesystem/lib/browser';
|
|
||||||
import { nls } from '@theia/core/lib/common';
|
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class AddFile extends SketchContribution {
|
export class AddFile extends SketchContribution {
|
||||||
@inject(FileDialogService)
|
@inject(FileDialogService)
|
||||||
protected readonly fileDialogService: FileDialogService;
|
private readonly fileDialogService: FileDialogService; // TODO: use dialogService
|
||||||
|
|
||||||
registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(AddFile.Commands.ADD_FILE, {
|
registry.registerCommand(AddFile.Commands.ADD_FILE, {
|
||||||
execute: () => this.addFile(),
|
execute: () => this.addFile(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMenus(registry: MenuModelRegistry): void {
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
registry.registerMenuAction(ArduinoMenus.SKETCH__UTILS_GROUP, {
|
registry.registerMenuAction(ArduinoMenus.SKETCH__UTILS_GROUP, {
|
||||||
commandId: AddFile.Commands.ADD_FILE.id,
|
commandId: AddFile.Commands.ADD_FILE.id,
|
||||||
label: nls.localize('arduino/contributions/addFile', 'Add File') + '...',
|
label: nls.localize('arduino/contributions/addFile', 'Add File') + '...',
|
||||||
@@ -30,9 +31,9 @@ export class AddFile extends SketchContribution {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async addFile(): Promise<void> {
|
private async addFile(): Promise<void> {
|
||||||
const sketch = await this.sketchServiceClient.currentSketch();
|
const sketch = await this.sketchServiceClient.currentSketch();
|
||||||
if (!sketch) {
|
if (!CurrentSketch.isValid(sketch)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const toAddUri = await this.fileDialogService.showOpenDialog({
|
const toAddUri = await this.fileDialogService.showOpenDialog({
|
||||||
@@ -40,16 +41,15 @@ export class AddFile extends SketchContribution {
|
|||||||
canSelectFiles: true,
|
canSelectFiles: true,
|
||||||
canSelectFolders: false,
|
canSelectFolders: false,
|
||||||
canSelectMany: false,
|
canSelectMany: false,
|
||||||
|
modal: true,
|
||||||
});
|
});
|
||||||
if (!toAddUri) {
|
if (!toAddUri) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const sketchUri = new URI(sketch.uri);
|
const { uri: targetUri, filename } = this.resolveTarget(sketch, toAddUri);
|
||||||
const filename = toAddUri.path.base;
|
|
||||||
const targetUri = sketchUri.resolve('data').resolve(filename);
|
|
||||||
const exists = await this.fileService.exists(targetUri);
|
const exists = await this.fileService.exists(targetUri);
|
||||||
if (exists) {
|
if (exists) {
|
||||||
const { response } = await remote.dialog.showMessageBox({
|
const { response } = await this.dialogService.showMessageBox({
|
||||||
type: 'question',
|
type: 'question',
|
||||||
title: nls.localize('arduino/contributions/replaceTitle', 'Replace'),
|
title: nls.localize('arduino/contributions/replaceTitle', 'Replace'),
|
||||||
buttons: [
|
buttons: [
|
||||||
@@ -78,6 +78,22 @@ export class AddFile extends SketchContribution {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/arduino/arduino-ide/issues/284#issuecomment-1364533662
|
||||||
|
// File the file to add has one of the following extension, it goes to the sketch folder root: .ino, .h, .cpp, .c, .S
|
||||||
|
// Otherwise, the files goes to the `data` folder inside the sketch folder root.
|
||||||
|
private resolveTarget(
|
||||||
|
sketch: Sketch,
|
||||||
|
toAddUri: URI
|
||||||
|
): { uri: URI; filename: string } {
|
||||||
|
const path = toAddUri.path;
|
||||||
|
const filename = path.base;
|
||||||
|
let root = new URI(sketch.uri);
|
||||||
|
if (!Sketch.Extensions.CODE_FILES.includes(path.ext)) {
|
||||||
|
root = root.resolve('data');
|
||||||
|
}
|
||||||
|
return { uri: root.resolve(filename), filename: filename };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace AddFile {
|
export namespace AddFile {
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
import { inject, injectable } from 'inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
|
||||||
import URI from '@theia/core/lib/common/uri';
|
import URI from '@theia/core/lib/common/uri';
|
||||||
import { ConfirmDialog } from '@theia/core/lib/browser/dialogs';
|
import { ConfirmDialog } from '@theia/core/lib/browser/dialogs';
|
||||||
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
|
|
||||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
import {
|
import { LibraryService, ResponseServiceClient } from '../../common/protocol';
|
||||||
Installable,
|
import { ExecuteWithProgress } from '../../common/protocol/progressible';
|
||||||
LibraryService,
|
|
||||||
ResponseServiceArduino,
|
|
||||||
} from '../../common/protocol';
|
|
||||||
import {
|
import {
|
||||||
SketchContribution,
|
SketchContribution,
|
||||||
Command,
|
Command,
|
||||||
@@ -19,30 +14,23 @@ import { nls } from '@theia/core/lib/common';
|
|||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class AddZipLibrary extends SketchContribution {
|
export class AddZipLibrary extends SketchContribution {
|
||||||
@inject(EnvVariablesServer)
|
@inject(ResponseServiceClient)
|
||||||
protected readonly envVariableServer: EnvVariablesServer;
|
private readonly responseService: ResponseServiceClient;
|
||||||
|
|
||||||
@inject(ResponseServiceArduino)
|
|
||||||
protected readonly responseService: ResponseServiceArduino;
|
|
||||||
|
|
||||||
@inject(LibraryService)
|
@inject(LibraryService)
|
||||||
protected readonly libraryService: LibraryService;
|
private readonly libraryService: LibraryService;
|
||||||
|
|
||||||
registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(AddZipLibrary.Commands.ADD_ZIP_LIBRARY, {
|
registry.registerCommand(AddZipLibrary.Commands.ADD_ZIP_LIBRARY, {
|
||||||
execute: () => this.addZipLibrary(),
|
execute: () => this.addZipLibrary(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMenus(registry: MenuModelRegistry): void {
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
const includeLibMenuPath = [
|
const includeLibMenuPath = [
|
||||||
...ArduinoMenus.SKETCH__UTILS_GROUP,
|
...ArduinoMenus.SKETCH__UTILS_GROUP,
|
||||||
'0_include',
|
'0_include',
|
||||||
];
|
];
|
||||||
// TODO: do we need it? calling `registerSubmenu` multiple times is noop, so it does not hurt.
|
|
||||||
registry.registerSubmenu(includeLibMenuPath, 'Include Library', {
|
|
||||||
order: '1',
|
|
||||||
});
|
|
||||||
registry.registerMenuAction([...includeLibMenuPath, '1_install'], {
|
registry.registerMenuAction([...includeLibMenuPath, '1_install'], {
|
||||||
commandId: AddZipLibrary.Commands.ADD_ZIP_LIBRARY.id,
|
commandId: AddZipLibrary.Commands.ADD_ZIP_LIBRARY.id,
|
||||||
label: nls.localize('arduino/library/addZip', 'Add .ZIP Library...'),
|
label: nls.localize('arduino/library/addZip', 'Add .ZIP Library...'),
|
||||||
@@ -50,10 +38,10 @@ export class AddZipLibrary extends SketchContribution {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async addZipLibrary(): Promise<void> {
|
private async addZipLibrary(): Promise<void> {
|
||||||
const homeUri = await this.envVariableServer.getHomeDirUri();
|
const homeUri = await this.envVariableServer.getHomeDirUri();
|
||||||
const defaultPath = await this.fileService.fsPath(new URI(homeUri));
|
const defaultPath = await this.fileService.fsPath(new URI(homeUri));
|
||||||
const { canceled, filePaths } = await remote.dialog.showOpenDialog({
|
const { canceled, filePaths } = await this.dialogService.showOpenDialog({
|
||||||
title: nls.localize(
|
title: nls.localize(
|
||||||
'arduino/selectZip',
|
'arduino/selectZip',
|
||||||
"Select a zip file containing the library you'd like to add"
|
"Select a zip file containing the library you'd like to add"
|
||||||
@@ -92,7 +80,7 @@ export class AddZipLibrary extends SketchContribution {
|
|||||||
|
|
||||||
private async doInstall(zipUri: string, overwrite?: boolean): Promise<void> {
|
private async doInstall(zipUri: string, overwrite?: boolean): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await Installable.doWithProgress({
|
await ExecuteWithProgress.doWithProgress({
|
||||||
messageService: this.messageService,
|
messageService: this.messageService,
|
||||||
progressText:
|
progressText:
|
||||||
nls.localize('arduino/common/processing', 'Processing') +
|
nls.localize('arduino/common/processing', 'Processing') +
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { injectable } from 'inversify';
|
import { injectable } from '@theia/core/shared/inversify';
|
||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
import dateFormat from 'dateformat';
|
||||||
import * as dateFormat from 'dateformat';
|
|
||||||
import URI from '@theia/core/lib/common/uri';
|
|
||||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
import {
|
import {
|
||||||
SketchContribution,
|
SketchContribution,
|
||||||
@@ -10,16 +8,17 @@ import {
|
|||||||
MenuModelRegistry,
|
MenuModelRegistry,
|
||||||
} from './contribution';
|
} from './contribution';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import { nls } from '@theia/core/lib/common';
|
||||||
|
import { CurrentSketch } from '../sketches-service-client-impl';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class ArchiveSketch extends SketchContribution {
|
export class ArchiveSketch extends SketchContribution {
|
||||||
registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(ArchiveSketch.Commands.ARCHIVE_SKETCH, {
|
registry.registerCommand(ArchiveSketch.Commands.ARCHIVE_SKETCH, {
|
||||||
execute: () => this.archiveSketch(),
|
execute: () => this.archiveSketch(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMenus(registry: MenuModelRegistry): void {
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
registry.registerMenuAction(ArduinoMenus.TOOLS__MAIN_GROUP, {
|
registry.registerMenuAction(ArduinoMenus.TOOLS__MAIN_GROUP, {
|
||||||
commandId: ArchiveSketch.Commands.ARCHIVE_SKETCH.id,
|
commandId: ArchiveSketch.Commands.ARCHIVE_SKETCH.id,
|
||||||
label: nls.localize('arduino/sketch/archiveSketch', 'Archive Sketch'),
|
label: nls.localize('arduino/sketch/archiveSketch', 'Archive Sketch'),
|
||||||
@@ -27,22 +26,19 @@ export class ArchiveSketch extends SketchContribution {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async archiveSketch(): Promise<void> {
|
private async archiveSketch(): Promise<void> {
|
||||||
const [sketch, config] = await Promise.all([
|
const sketch = await this.sketchServiceClient.currentSketch();
|
||||||
this.sketchServiceClient.currentSketch(),
|
if (!CurrentSketch.isValid(sketch)) {
|
||||||
this.configService.getConfiguration(),
|
|
||||||
]);
|
|
||||||
if (!sketch) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const archiveBasename = `${sketch.name}-${dateFormat(
|
const archiveBasename = `${sketch.name}-${dateFormat(
|
||||||
new Date(),
|
new Date(),
|
||||||
'yymmdd'
|
'yymmdd'
|
||||||
)}a.zip`;
|
)}a.zip`;
|
||||||
const defaultPath = await this.fileService.fsPath(
|
const defaultContainerUri = await this.defaultUri();
|
||||||
new URI(config.sketchDirUri).resolve(archiveBasename)
|
const defaultUri = defaultContainerUri.resolve(archiveBasename);
|
||||||
);
|
const defaultPath = await this.fileService.fsPath(defaultUri);
|
||||||
const { filePath, canceled } = await remote.dialog.showSaveDialog({
|
const { filePath, canceled } = await this.dialogService.showSaveDialog({
|
||||||
title: nls.localize(
|
title: nls.localize(
|
||||||
'arduino/sketch/saveSketchAs',
|
'arduino/sketch/saveSketchAs',
|
||||||
'Save sketch folder as...'
|
'Save sketch folder as...'
|
||||||
@@ -56,7 +52,7 @@ export class ArchiveSketch extends SketchContribution {
|
|||||||
if (!destinationUri) {
|
if (!destinationUri) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.sketchService.archive(sketch, destinationUri.toString());
|
await this.sketchesService.archive(sketch, destinationUri.toString());
|
||||||
this.messageService.info(
|
this.messageService.info(
|
||||||
nls.localize(
|
nls.localize(
|
||||||
'arduino/sketch/createdArchive',
|
'arduino/sketch/createdArchive',
|
||||||
|
|||||||
@@ -0,0 +1,123 @@
|
|||||||
|
import type { MaybePromise } from '@theia/core/lib/common/types';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import {
|
||||||
|
BoardDetails,
|
||||||
|
Programmer,
|
||||||
|
isBoardIdentifierChangeEvent,
|
||||||
|
} from '../../common/protocol';
|
||||||
|
import {
|
||||||
|
BoardsDataStore,
|
||||||
|
findDefaultProgrammer,
|
||||||
|
isEmptyData,
|
||||||
|
} from '../boards/boards-data-store';
|
||||||
|
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
||||||
|
import { Contribution } from './contribution';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Before CLI 0.35.0-rc.3, there was no `programmer#default` property in the `board details` response.
|
||||||
|
* This method does the programmer migration in the data store. If there is a programmer selected, it's a noop.
|
||||||
|
* If no programmer is selected, it forcefully reloads the details from the CLI and updates it in the local storage.
|
||||||
|
*/
|
||||||
|
@injectable()
|
||||||
|
export class AutoSelectProgrammer extends Contribution {
|
||||||
|
@inject(BoardsServiceProvider)
|
||||||
|
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
@inject(BoardsDataStore)
|
||||||
|
private readonly boardsDataStore: BoardsDataStore;
|
||||||
|
|
||||||
|
override onStart(): void {
|
||||||
|
this.boardsServiceProvider.onBoardsConfigDidChange((event) => {
|
||||||
|
if (isBoardIdentifierChangeEvent(event)) {
|
||||||
|
this.ensureProgrammerIsSelected();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override onReady(): void {
|
||||||
|
this.boardsServiceProvider.ready.then(() =>
|
||||||
|
this.ensureProgrammerIsSelected()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async ensureProgrammerIsSelected(): Promise<boolean> {
|
||||||
|
return ensureProgrammerIsSelected({
|
||||||
|
fqbn: this.boardsServiceProvider.boardsConfig.selectedBoard?.fqbn,
|
||||||
|
getData: (fqbn) => this.boardsDataStore.getData(fqbn),
|
||||||
|
loadBoardDetails: (fqbn) => this.boardsDataStore.loadBoardDetails(fqbn),
|
||||||
|
selectProgrammer: (arg) => this.boardsDataStore.selectProgrammer(arg),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface EnsureProgrammerIsSelectedParams {
|
||||||
|
fqbn: string | undefined;
|
||||||
|
getData: (fqbn: string | undefined) => MaybePromise<BoardsDataStore.Data>;
|
||||||
|
loadBoardDetails: (fqbn: string) => MaybePromise<BoardDetails | undefined>;
|
||||||
|
selectProgrammer(options: {
|
||||||
|
fqbn: string;
|
||||||
|
selectedProgrammer: Programmer;
|
||||||
|
}): MaybePromise<boolean>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function ensureProgrammerIsSelected(
|
||||||
|
params: EnsureProgrammerIsSelectedParams
|
||||||
|
): Promise<boolean> {
|
||||||
|
const { fqbn, getData, loadBoardDetails, selectProgrammer } = params;
|
||||||
|
if (!fqbn) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
console.debug(`Ensuring a programmer is selected for ${fqbn}...`);
|
||||||
|
const data = await getData(fqbn);
|
||||||
|
if (isEmptyData(data)) {
|
||||||
|
// For example, the platform is not installed.
|
||||||
|
console.debug(`Skipping. No boards data is available for ${fqbn}.`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (data.selectedProgrammer) {
|
||||||
|
console.debug(
|
||||||
|
`A programmer is already selected for ${fqbn}: '${data.selectedProgrammer.id}'.`
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
let programmer = findDefaultProgrammer(data.programmers, data);
|
||||||
|
if (programmer) {
|
||||||
|
// select the programmer if the default info is available
|
||||||
|
const result = await selectProgrammer({
|
||||||
|
fqbn,
|
||||||
|
selectedProgrammer: programmer,
|
||||||
|
});
|
||||||
|
if (result) {
|
||||||
|
console.debug(`Selected '${programmer.id}' programmer for ${fqbn}.`);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.debug(`Reloading board details for ${fqbn}...`);
|
||||||
|
const reloadedData = await loadBoardDetails(fqbn);
|
||||||
|
if (!reloadedData) {
|
||||||
|
console.debug(`Skipping. No board details found for ${fqbn}.`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!reloadedData.programmers.length) {
|
||||||
|
console.debug(`Skipping. ${fqbn} does not have programmers.`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
programmer = findDefaultProgrammer(reloadedData.programmers, reloadedData);
|
||||||
|
if (!programmer) {
|
||||||
|
console.debug(
|
||||||
|
`Skipping. Could not find a default programmer for ${fqbn}. Programmers were: `
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const result = await selectProgrammer({
|
||||||
|
fqbn,
|
||||||
|
selectedProgrammer: programmer,
|
||||||
|
});
|
||||||
|
if (result) {
|
||||||
|
console.debug(`Selected '${programmer.id}' programmer for ${fqbn}.`);
|
||||||
|
} else {
|
||||||
|
console.debug(
|
||||||
|
`Could not select '${programmer.id}' programmer for ${fqbn}.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -1,133 +1,137 @@
|
|||||||
import { inject, injectable } from 'inversify';
|
|
||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
|
||||||
import { MenuModelRegistry } from '@theia/core/lib/common/menu';
|
|
||||||
import {
|
import {
|
||||||
DisposableCollection,
|
|
||||||
Disposable,
|
Disposable,
|
||||||
|
DisposableCollection,
|
||||||
} from '@theia/core/lib/common/disposable';
|
} from '@theia/core/lib/common/disposable';
|
||||||
import { firstToUpperCase } from '../../common/utils';
|
import { MenuModelRegistry } from '@theia/core/lib/common/menu/menu-model-registry';
|
||||||
import { BoardsConfig } from '../boards/boards-config';
|
import type { MenuPath } from '@theia/core/lib/common/menu/menu-types';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { Deferred } from '@theia/core/lib/common/promise-util';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { MainMenuManager } from '../../common/main-menu-manager';
|
import { MainMenuManager } from '../../common/main-menu-manager';
|
||||||
|
import {
|
||||||
|
BoardsService,
|
||||||
|
BoardWithPackage,
|
||||||
|
createPlatformIdentifier,
|
||||||
|
getBoardInfo,
|
||||||
|
InstalledBoardWithPackage,
|
||||||
|
platformIdentifierEquals,
|
||||||
|
Port,
|
||||||
|
serializePlatformIdentifier,
|
||||||
|
} from '../../common/protocol';
|
||||||
|
import type { BoardList } from '../../common/protocol/board-list';
|
||||||
import { BoardsListWidget } from '../boards/boards-list-widget';
|
import { BoardsListWidget } from '../boards/boards-list-widget';
|
||||||
import { NotificationCenter } from '../notification-center';
|
import { BoardsDataStore } from '../boards/boards-data-store';
|
||||||
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
||||||
import {
|
import {
|
||||||
ArduinoMenus,
|
ArduinoMenus,
|
||||||
PlaceholderMenuNode,
|
PlaceholderMenuNode,
|
||||||
unregisterSubmenu,
|
unregisterSubmenu,
|
||||||
} from '../menu/arduino-menus';
|
} from '../menu/arduino-menus';
|
||||||
import {
|
import { NotificationCenter } from '../notification-center';
|
||||||
BoardsService,
|
import { Command, CommandRegistry, SketchContribution } from './contribution';
|
||||||
InstalledBoardWithPackage,
|
|
||||||
AvailablePorts,
|
|
||||||
Port,
|
|
||||||
} from '../../common/protocol';
|
|
||||||
import { SketchContribution, Command, CommandRegistry } from './contribution';
|
|
||||||
import { nls } from '@theia/core/lib/common';
|
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class BoardSelection extends SketchContribution {
|
export class BoardSelection extends SketchContribution {
|
||||||
@inject(CommandRegistry)
|
@inject(CommandRegistry)
|
||||||
protected readonly commandRegistry: CommandRegistry;
|
private readonly commandRegistry: CommandRegistry;
|
||||||
|
|
||||||
@inject(MainMenuManager)
|
@inject(MainMenuManager)
|
||||||
protected readonly mainMenuManager: MainMenuManager;
|
private readonly mainMenuManager: MainMenuManager;
|
||||||
|
|
||||||
@inject(MenuModelRegistry)
|
@inject(MenuModelRegistry)
|
||||||
protected readonly menuModelRegistry: MenuModelRegistry;
|
private readonly menuModelRegistry: MenuModelRegistry;
|
||||||
|
|
||||||
@inject(NotificationCenter)
|
@inject(NotificationCenter)
|
||||||
protected readonly notificationCenter: NotificationCenter;
|
private readonly notificationCenter: NotificationCenter;
|
||||||
|
@inject(BoardsDataStore)
|
||||||
|
private readonly boardsDataStore: BoardsDataStore;
|
||||||
@inject(BoardsService)
|
@inject(BoardsService)
|
||||||
protected readonly boardsService: BoardsService;
|
private readonly boardsService: BoardsService;
|
||||||
|
|
||||||
@inject(BoardsServiceProvider)
|
@inject(BoardsServiceProvider)
|
||||||
protected readonly boardsServiceProvider: BoardsServiceProvider;
|
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
|
||||||
protected readonly toDisposeBeforeMenuRebuild = new DisposableCollection();
|
private readonly toDisposeBeforeMenuRebuild = new DisposableCollection();
|
||||||
|
// do not query installed platforms on every change
|
||||||
|
private _installedBoards: Deferred<InstalledBoardWithPackage[]> | undefined;
|
||||||
|
|
||||||
registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(BoardSelection.Commands.GET_BOARD_INFO, {
|
registry.registerCommand(BoardSelection.Commands.GET_BOARD_INFO, {
|
||||||
execute: async () => {
|
execute: async () => {
|
||||||
const { selectedBoard, selectedPort } =
|
const boardInfo = await getBoardInfo(
|
||||||
this.boardsServiceProvider.boardsConfig;
|
this.boardsServiceProvider.boardList
|
||||||
if (!selectedBoard) {
|
);
|
||||||
this.messageService.info(
|
if (typeof boardInfo === 'string') {
|
||||||
nls.localize(
|
this.messageService.info(boardInfo);
|
||||||
'arduino/board/selectBoardForInfo',
|
|
||||||
'Please select a board to obtain board info.'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!selectedBoard.fqbn) {
|
const { BN, VID, PID, SN } = boardInfo;
|
||||||
this.messageService.info(
|
const detail = `
|
||||||
nls.localize(
|
BN: ${BN}
|
||||||
'arduino/board/platformMissing',
|
|
||||||
"The platform for the selected '{0}' board is not installed.",
|
|
||||||
selectedBoard.name
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!selectedPort) {
|
|
||||||
this.messageService.info(
|
|
||||||
nls.localize(
|
|
||||||
'arduino/board/selectPortForInfo',
|
|
||||||
'Please select a port to obtain board info.'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const boardDetails = await this.boardsService.getBoardDetails({
|
|
||||||
fqbn: selectedBoard.fqbn,
|
|
||||||
});
|
|
||||||
if (boardDetails) {
|
|
||||||
const { VID, PID } = boardDetails;
|
|
||||||
const detail = `BN: ${selectedBoard.name}
|
|
||||||
VID: ${VID}
|
VID: ${VID}
|
||||||
PID: ${PID}`;
|
PID: ${PID}
|
||||||
await remote.dialog.showMessageBox(remote.getCurrentWindow(), {
|
SN: ${SN}
|
||||||
message: nls.localize('arduino/board/boardInfo', 'Board Info'),
|
`.trim();
|
||||||
title: nls.localize('arduino/board/boardInfo', 'Board Info'),
|
await this.dialogService.showMessageBox({
|
||||||
type: 'info',
|
message: nls.localize('arduino/board/boardInfo', 'Board Info'),
|
||||||
detail,
|
title: nls.localize('arduino/board/boardInfo', 'Board Info'),
|
||||||
buttons: [nls.localize('vscode/issueMainService/ok', 'OK')],
|
type: 'info',
|
||||||
});
|
detail,
|
||||||
|
buttons: [nls.localize('vscode/issueMainService/ok', 'OK')],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
registry.registerCommand(BoardSelection.Commands.RELOAD_BOARD_DATA, {
|
||||||
|
execute: async () => {
|
||||||
|
const selectedFqbn =
|
||||||
|
this.boardsServiceProvider.boardList.boardsConfig.selectedBoard?.fqbn;
|
||||||
|
let message: string;
|
||||||
|
|
||||||
|
if (selectedFqbn) {
|
||||||
|
await this.boardsDataStore.reloadBoardData(selectedFqbn);
|
||||||
|
message = nls.localize(
|
||||||
|
'arduino/board/boardDataReloaded',
|
||||||
|
'Board data reloaded.'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
message = nls.localize(
|
||||||
|
'arduino/board/selectBoardToReload',
|
||||||
|
'Please select a board first.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.messageService.info(message, { timeout: 2000 });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onStart(): void {
|
override onStart(): void {
|
||||||
|
this.notificationCenter.onPlatformDidInstall(() => this.updateMenus(true));
|
||||||
|
this.notificationCenter.onPlatformDidUninstall(() =>
|
||||||
|
this.updateMenus(true)
|
||||||
|
);
|
||||||
|
this.boardsServiceProvider.onBoardListDidChange(() => this.updateMenus());
|
||||||
|
}
|
||||||
|
|
||||||
|
override async onReady(): Promise<void> {
|
||||||
this.updateMenus();
|
this.updateMenus();
|
||||||
this.notificationCenter.onPlatformInstalled(this.updateMenus.bind(this));
|
|
||||||
this.notificationCenter.onPlatformUninstalled(this.updateMenus.bind(this));
|
|
||||||
this.boardsServiceProvider.onBoardsConfigChanged(
|
|
||||||
this.updateMenus.bind(this)
|
|
||||||
);
|
|
||||||
this.boardsServiceProvider.onAvailableBoardsChanged(
|
|
||||||
this.updateMenus.bind(this)
|
|
||||||
);
|
|
||||||
this.boardsServiceProvider.onAvailablePortsChanged(
|
|
||||||
this.updateMenus.bind(this)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async updateMenus(): Promise<void> {
|
private async updateMenus(discardCache = false): Promise<void> {
|
||||||
const [installedBoards, availablePorts, config] = await Promise.all([
|
if (discardCache) {
|
||||||
this.installedBoards(),
|
this._installedBoards?.reject();
|
||||||
this.boardsService.getState(),
|
this._installedBoards = undefined;
|
||||||
this.boardsServiceProvider.boardsConfig,
|
}
|
||||||
]);
|
if (!this._installedBoards) {
|
||||||
this.rebuildMenus(installedBoards, availablePorts, config);
|
this._installedBoards = new Deferred();
|
||||||
|
this.installedBoards().then((installedBoards) =>
|
||||||
|
this._installedBoards?.resolve(installedBoards)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const installedBoards = await this._installedBoards.promise;
|
||||||
|
this.rebuildMenus(installedBoards, this.boardsServiceProvider.boardList);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected rebuildMenus(
|
private rebuildMenus(
|
||||||
installedBoards: InstalledBoardWithPackage[],
|
installedBoards: InstalledBoardWithPackage[],
|
||||||
availablePorts: AvailablePorts,
|
boardList: BoardList
|
||||||
config: BoardsConfig.Config
|
|
||||||
): void {
|
): void {
|
||||||
this.toDisposeBeforeMenuRebuild.dispose();
|
this.toDisposeBeforeMenuRebuild.dispose();
|
||||||
|
|
||||||
@@ -136,7 +140,8 @@ PID: ${PID}`;
|
|||||||
...ArduinoMenus.TOOLS__BOARD_SELECTION_GROUP,
|
...ArduinoMenus.TOOLS__BOARD_SELECTION_GROUP,
|
||||||
'1_boards',
|
'1_boards',
|
||||||
];
|
];
|
||||||
const boardsSubmenuLabel = config.selectedBoard?.name;
|
const { selectedBoard, selectedPort } = boardList.boardsConfig;
|
||||||
|
const boardsSubmenuLabel = selectedBoard?.name;
|
||||||
// Note: The submenu order starts from `100` because `Auto Format`, `Serial Monitor`, etc starts from `0` index.
|
// Note: The submenu order starts from `100` because `Auto Format`, `Serial Monitor`, etc starts from `0` index.
|
||||||
// The board specific items, and the rest, have order with `z`. We needed something between `0` and `z` with natural-order.
|
// The board specific items, and the rest, have order with `z`. We needed something between `0` and `z` with natural-order.
|
||||||
this.menuModelRegistry.registerSubmenu(
|
this.menuModelRegistry.registerSubmenu(
|
||||||
@@ -155,11 +160,8 @@ PID: ${PID}`;
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Ports submenu
|
// Ports submenu
|
||||||
const portsSubmenuPath = [
|
const portsSubmenuPath = ArduinoMenus.TOOLS__PORTS_SUBMENU;
|
||||||
...ArduinoMenus.TOOLS__BOARD_SELECTION_GROUP,
|
const portsSubmenuLabel = selectedPort?.address;
|
||||||
'2_ports',
|
|
||||||
];
|
|
||||||
const portsSubmenuLabel = config.selectedPort?.address;
|
|
||||||
this.menuModelRegistry.registerSubmenu(
|
this.menuModelRegistry.registerSubmenu(
|
||||||
portsSubmenuPath,
|
portsSubmenuPath,
|
||||||
nls.localize(
|
nls.localize(
|
||||||
@@ -175,6 +177,21 @@ PID: ${PID}`;
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const reloadBoardData = {
|
||||||
|
commandId: BoardSelection.Commands.RELOAD_BOARD_DATA.id,
|
||||||
|
label: nls.localize('arduino/board/reloadBoardData', 'Reload Board Data'),
|
||||||
|
order: '102',
|
||||||
|
};
|
||||||
|
this.menuModelRegistry.registerMenuAction(
|
||||||
|
ArduinoMenus.TOOLS__BOARD_SELECTION_GROUP,
|
||||||
|
reloadBoardData
|
||||||
|
);
|
||||||
|
this.toDisposeBeforeMenuRebuild.push(
|
||||||
|
Disposable.create(() =>
|
||||||
|
this.menuModelRegistry.unregisterMenuAction(reloadBoardData)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
const getBoardInfo = {
|
const getBoardInfo = {
|
||||||
commandId: BoardSelection.Commands.GET_BOARD_INFO.id,
|
commandId: BoardSelection.Commands.GET_BOARD_INFO.id,
|
||||||
label: nls.localize('arduino/board/getBoardInfo', 'Get Board Info'),
|
label: nls.localize('arduino/board/getBoardInfo', 'Get Board Info'),
|
||||||
@@ -198,64 +215,116 @@ PID: ${PID}`;
|
|||||||
label: `${BoardsListWidget.WIDGET_LABEL}...`,
|
label: `${BoardsListWidget.WIDGET_LABEL}...`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Installed boards
|
const selectedBoardPlatformId = selectedBoard
|
||||||
|
? createPlatformIdentifier(selectedBoard)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
// Keys are the vendor IDs
|
||||||
|
type BoardsPerVendor = Record<string, BoardWithPackage[]>;
|
||||||
|
// Group boards by their platform names. The keys are the platform names as menu labels.
|
||||||
|
// If there is a platform name (menu label) collision, refine the menu label with the vendor ID.
|
||||||
|
const groupedBoards = new Map<string, BoardsPerVendor>();
|
||||||
for (const board of installedBoards) {
|
for (const board of installedBoards) {
|
||||||
const { packageId, packageName, fqbn, name, manuallyInstalled } = board;
|
const { packageId, packageName } = board;
|
||||||
|
const { vendorId } = packageId;
|
||||||
const packageLabel =
|
let boardsPerPackageName = groupedBoards.get(packageName);
|
||||||
packageName +
|
if (!boardsPerPackageName) {
|
||||||
`${manuallyInstalled
|
boardsPerPackageName = {} as BoardsPerVendor;
|
||||||
? nls.localize('arduino/board/inSketchbook', ' (in Sketchbook)')
|
groupedBoards.set(packageName, boardsPerPackageName);
|
||||||
: ''
|
}
|
||||||
}`;
|
let boardPerVendor: BoardWithPackage[] | undefined =
|
||||||
// Platform submenu
|
boardsPerPackageName[vendorId];
|
||||||
const platformMenuPath = [...boardsPackagesGroup, packageId];
|
if (!boardPerVendor) {
|
||||||
// Note: Registering the same submenu twice is a noop. No need to group the boards per platform.
|
boardPerVendor = [];
|
||||||
this.menuModelRegistry.registerSubmenu(platformMenuPath, packageLabel, {
|
boardsPerPackageName[vendorId] = boardPerVendor;
|
||||||
order: packageName.toLowerCase(),
|
}
|
||||||
});
|
boardPerVendor.push(board);
|
||||||
|
|
||||||
const id = `arduino-select-board--${fqbn}`;
|
|
||||||
const command = { id };
|
|
||||||
const handler = {
|
|
||||||
execute: () => {
|
|
||||||
if (
|
|
||||||
fqbn !== this.boardsServiceProvider.boardsConfig.selectedBoard?.fqbn
|
|
||||||
) {
|
|
||||||
this.boardsServiceProvider.boardsConfig = {
|
|
||||||
selectedBoard: {
|
|
||||||
name,
|
|
||||||
fqbn,
|
|
||||||
port: this.boardsServiceProvider.boardsConfig.selectedBoard
|
|
||||||
?.port, // TODO: verify!
|
|
||||||
},
|
|
||||||
selectedPort:
|
|
||||||
this.boardsServiceProvider.boardsConfig.selectedPort,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
|
||||||
isToggled: () =>
|
|
||||||
fqbn === this.boardsServiceProvider.boardsConfig.selectedBoard?.fqbn,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Board menu
|
|
||||||
const menuAction = { commandId: id, label: name };
|
|
||||||
this.commandRegistry.registerCommand(command, handler);
|
|
||||||
this.toDisposeBeforeMenuRebuild.push(
|
|
||||||
Disposable.create(() => this.commandRegistry.unregisterCommand(command))
|
|
||||||
);
|
|
||||||
this.menuModelRegistry.registerMenuAction(platformMenuPath, menuAction);
|
|
||||||
// Note: we do not dispose the menu actions individually. Calling `unregisterSubmenu` on the parent will wipe the children menu nodes recursively.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Installed ports
|
// Installed boards
|
||||||
|
Array.from(groupedBoards.entries()).forEach(
|
||||||
|
([packageName, boardsPerPackage]) => {
|
||||||
|
const useVendorSuffix = Object.keys(boardsPerPackage).length > 1;
|
||||||
|
Object.entries(boardsPerPackage).forEach(([vendorId, boards]) => {
|
||||||
|
let platformMenuPath: MenuPath | undefined = undefined;
|
||||||
|
boards.forEach((board, index) => {
|
||||||
|
const { packageId, fqbn, name, manuallyInstalled } = board;
|
||||||
|
// create the platform submenu once.
|
||||||
|
// creating and registering the same submenu twice in Theia is a noop, though.
|
||||||
|
if (!platformMenuPath) {
|
||||||
|
let packageLabel =
|
||||||
|
packageName +
|
||||||
|
`${
|
||||||
|
manuallyInstalled
|
||||||
|
? nls.localize(
|
||||||
|
'arduino/board/inSketchbook',
|
||||||
|
' (in Sketchbook)'
|
||||||
|
)
|
||||||
|
: ''
|
||||||
|
}`;
|
||||||
|
if (
|
||||||
|
selectedBoardPlatformId &&
|
||||||
|
platformIdentifierEquals(packageId, selectedBoardPlatformId)
|
||||||
|
) {
|
||||||
|
packageLabel = `● ${packageLabel}`;
|
||||||
|
}
|
||||||
|
if (useVendorSuffix) {
|
||||||
|
packageLabel += ` (${vendorId})`;
|
||||||
|
}
|
||||||
|
// Platform submenu
|
||||||
|
platformMenuPath = [
|
||||||
|
...boardsPackagesGroup,
|
||||||
|
serializePlatformIdentifier(packageId),
|
||||||
|
];
|
||||||
|
this.menuModelRegistry.registerSubmenu(
|
||||||
|
platformMenuPath,
|
||||||
|
packageLabel,
|
||||||
|
{
|
||||||
|
order: packageName.toLowerCase(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const id = `arduino-select-board--${fqbn}`;
|
||||||
|
const command = { id };
|
||||||
|
const handler = {
|
||||||
|
execute: () =>
|
||||||
|
this.boardsServiceProvider.updateConfig({
|
||||||
|
name: name,
|
||||||
|
fqbn: fqbn,
|
||||||
|
}),
|
||||||
|
isToggled: () => fqbn === selectedBoard?.fqbn,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Board menu
|
||||||
|
const menuAction = {
|
||||||
|
commandId: id,
|
||||||
|
label: name,
|
||||||
|
order: String(index).padStart(4), // pads with leading zeros for alphanumeric sort where order is 1, 2, 11, and NOT 1, 11, 2
|
||||||
|
};
|
||||||
|
this.commandRegistry.registerCommand(command, handler);
|
||||||
|
this.toDisposeBeforeMenuRebuild.push(
|
||||||
|
Disposable.create(() =>
|
||||||
|
this.commandRegistry.unregisterCommand(command)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
this.menuModelRegistry.registerMenuAction(
|
||||||
|
platformMenuPath,
|
||||||
|
menuAction
|
||||||
|
);
|
||||||
|
// Note: we do not dispose the menu actions individually. Calling `unregisterSubmenu` on the parent will wipe the children menu nodes recursively.
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Detected ports
|
||||||
const registerPorts = (
|
const registerPorts = (
|
||||||
protocol: string,
|
protocol: string,
|
||||||
protocolOrder: number,
|
ports: ReturnType<BoardList['ports']>,
|
||||||
ports: AvailablePorts
|
protocolOrder: number
|
||||||
) => {
|
) => {
|
||||||
const portIDs = Object.keys(ports);
|
if (!ports.length) {
|
||||||
if (!portIDs.length) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,8 +335,12 @@ PID: ${PID}`;
|
|||||||
];
|
];
|
||||||
const placeholder = new PlaceholderMenuNode(
|
const placeholder = new PlaceholderMenuNode(
|
||||||
menuPath,
|
menuPath,
|
||||||
`${firstToUpperCase(protocol)} ports`,
|
nls.localize(
|
||||||
{ order: protocolOrder.toString() }
|
'arduino/board/typeOfPorts',
|
||||||
|
'{0} ports',
|
||||||
|
Port.Protocols.protocolLabel(protocol)
|
||||||
|
),
|
||||||
|
{ order: protocolOrder.toString().padStart(4) }
|
||||||
);
|
);
|
||||||
this.menuModelRegistry.registerMenuNode(menuPath, placeholder);
|
this.menuModelRegistry.registerMenuNode(menuPath, placeholder);
|
||||||
this.toDisposeBeforeMenuRebuild.push(
|
this.toDisposeBeforeMenuRebuild.push(
|
||||||
@@ -276,49 +349,31 @@ PID: ${PID}`;
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// First we show addresses with recognized boards connected,
|
for (let i = 0; i < ports.length; i++) {
|
||||||
// then all the rest.
|
const { port, boards } = ports[i];
|
||||||
const sortedIDs = Object.keys(ports).sort((left: string, right: string): number => {
|
const portKey = Port.keyOf(port);
|
||||||
const [, leftBoards] = ports[left];
|
let label = `${port.addressLabel}`;
|
||||||
const [, rightBoards] = ports[right];
|
if (boards?.length) {
|
||||||
return rightBoards.length - leftBoards.length;
|
|
||||||
});
|
|
||||||
|
|
||||||
for (let i = 0; i < sortedIDs.length; i++) {
|
|
||||||
const portID = sortedIDs[i];
|
|
||||||
const [port, boards] = ports[portID];
|
|
||||||
let label = `${port.address}`;
|
|
||||||
if (boards.length) {
|
|
||||||
const boardsList = boards.map((board) => board.name).join(', ');
|
const boardsList = boards.map((board) => board.name).join(', ');
|
||||||
label = `${label} (${boardsList})`;
|
label = `${label} (${boardsList})`;
|
||||||
}
|
}
|
||||||
const id = `arduino-select-port--${portID}`;
|
const id = `arduino-select-port--${portKey}`;
|
||||||
const command = { id };
|
const command = { id };
|
||||||
const handler = {
|
const handler = {
|
||||||
execute: () => {
|
execute: () => {
|
||||||
if (
|
this.boardsServiceProvider.updateConfig({
|
||||||
!Port.sameAs(
|
protocol: port.protocol,
|
||||||
port,
|
address: port.address,
|
||||||
this.boardsServiceProvider.boardsConfig.selectedPort
|
});
|
||||||
)
|
},
|
||||||
) {
|
isToggled: () => {
|
||||||
this.boardsServiceProvider.boardsConfig = {
|
return i === ports.matchingIndex;
|
||||||
selectedBoard:
|
|
||||||
this.boardsServiceProvider.boardsConfig.selectedBoard,
|
|
||||||
selectedPort: port,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
isToggled: () =>
|
|
||||||
Port.sameAs(
|
|
||||||
port,
|
|
||||||
this.boardsServiceProvider.boardsConfig.selectedPort
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
const menuAction = {
|
const menuAction = {
|
||||||
commandId: id,
|
commandId: id,
|
||||||
label,
|
label,
|
||||||
order: `${protocolOrder + i + 1}`,
|
order: String(protocolOrder + i + 1).padStart(4),
|
||||||
};
|
};
|
||||||
this.commandRegistry.registerCommand(command, handler);
|
this.commandRegistry.registerCommand(command, handler);
|
||||||
this.toDisposeBeforeMenuRebuild.push(
|
this.toDisposeBeforeMenuRebuild.push(
|
||||||
@@ -330,32 +385,25 @@ PID: ${PID}`;
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const grouped = AvailablePorts.byProtocol(availablePorts);
|
const groupedPorts = boardList.portsGroupedByProtocol();
|
||||||
let protocolOrder = 100;
|
let protocolOrder = 100;
|
||||||
// We first show serial and network ports, then all the rest
|
Object.entries(groupedPorts).forEach(([protocol, ports]) => {
|
||||||
['serial', 'network'].forEach((protocol) => {
|
registerPorts(protocol, ports, protocolOrder);
|
||||||
const ports = grouped.get(protocol);
|
protocolOrder += 100;
|
||||||
if (ports) {
|
|
||||||
registerPorts(protocol, protocolOrder, ports);
|
|
||||||
grouped.delete(protocol);
|
|
||||||
protocolOrder = protocolOrder + 100;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
grouped.forEach((ports, protocol) => {
|
|
||||||
registerPorts(protocol, protocolOrder, ports);
|
|
||||||
protocolOrder = protocolOrder + 100;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.mainMenuManager.update();
|
this.mainMenuManager.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async installedBoards(): Promise<InstalledBoardWithPackage[]> {
|
protected async installedBoards(): Promise<InstalledBoardWithPackage[]> {
|
||||||
const allBoards = await this.boardsService.searchBoards({});
|
const allBoards = await this.boardsService.getInstalledBoards();
|
||||||
return allBoards.filter(InstalledBoardWithPackage.is);
|
return allBoards.filter(InstalledBoardWithPackage.is);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export namespace BoardSelection {
|
export namespace BoardSelection {
|
||||||
export namespace Commands {
|
export namespace Commands {
|
||||||
export const GET_BOARD_INFO: Command = { id: 'arduino-get-board-info' };
|
export const GET_BOARD_INFO: Command = { id: 'arduino-get-board-info' };
|
||||||
|
export const RELOAD_BOARD_DATA: Command = {
|
||||||
|
id: 'arduino-reload-board-data',
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,57 +1,66 @@
|
|||||||
import * as PQueue from 'p-queue';
|
|
||||||
import { inject, injectable } from 'inversify';
|
|
||||||
import { CommandRegistry } from '@theia/core/lib/common/command';
|
|
||||||
import { MenuModelRegistry } from '@theia/core/lib/common/menu';
|
|
||||||
import {
|
import {
|
||||||
Disposable,
|
Disposable,
|
||||||
DisposableCollection,
|
DisposableCollection,
|
||||||
} from '@theia/core/lib/common/disposable';
|
} from '@theia/core/lib/common/disposable';
|
||||||
import { BoardsServiceProvider } from './boards-service-provider';
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
import { Board, ConfigOption, Programmer } from '../../common/protocol';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
import PQueue from 'p-queue';
|
||||||
import { BoardsDataStore } from './boards-data-store';
|
import {
|
||||||
import { MainMenuManager } from '../../common/main-menu-manager';
|
BoardIdentifier,
|
||||||
|
ConfigOption,
|
||||||
|
isBoardIdentifierChangeEvent,
|
||||||
|
Programmer,
|
||||||
|
} from '../../common/protocol';
|
||||||
|
import { BoardsDataStore } from '../boards/boards-data-store';
|
||||||
|
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
||||||
import { ArduinoMenus, unregisterSubmenu } from '../menu/arduino-menus';
|
import { ArduinoMenus, unregisterSubmenu } from '../menu/arduino-menus';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import {
|
||||||
|
CommandRegistry,
|
||||||
|
Contribution,
|
||||||
|
MenuModelRegistry,
|
||||||
|
} from './contribution';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class BoardsDataMenuUpdater implements FrontendApplicationContribution {
|
export class BoardsDataMenuUpdater extends Contribution {
|
||||||
@inject(CommandRegistry)
|
@inject(CommandRegistry)
|
||||||
protected readonly commandRegistry: CommandRegistry;
|
private readonly commandRegistry: CommandRegistry;
|
||||||
|
|
||||||
@inject(MenuModelRegistry)
|
@inject(MenuModelRegistry)
|
||||||
protected readonly menuRegistry: MenuModelRegistry;
|
private readonly menuRegistry: MenuModelRegistry;
|
||||||
|
|
||||||
@inject(MainMenuManager)
|
|
||||||
protected readonly mainMenuManager: MainMenuManager;
|
|
||||||
|
|
||||||
@inject(BoardsDataStore)
|
@inject(BoardsDataStore)
|
||||||
protected readonly boardsDataStore: BoardsDataStore;
|
private readonly boardsDataStore: BoardsDataStore;
|
||||||
|
|
||||||
@inject(BoardsServiceProvider)
|
@inject(BoardsServiceProvider)
|
||||||
protected readonly boardsServiceClient: BoardsServiceProvider;
|
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
|
||||||
protected readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
|
private readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
|
||||||
protected readonly toDisposeOnBoardChange = new DisposableCollection();
|
private readonly toDisposeOnBoardChange = new DisposableCollection();
|
||||||
|
|
||||||
async onStart(): Promise<void> {
|
override onStart(): void {
|
||||||
this.updateMenuActions(this.boardsServiceClient.boardsConfig.selectedBoard);
|
this.boardsDataStore.onDidChange(() =>
|
||||||
this.boardsDataStore.onChanged(() =>
|
|
||||||
this.updateMenuActions(
|
this.updateMenuActions(
|
||||||
this.boardsServiceClient.boardsConfig.selectedBoard
|
this.boardsServiceProvider.boardsConfig.selectedBoard
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
this.boardsServiceClient.onBoardsConfigChanged(({ selectedBoard }) =>
|
this.boardsServiceProvider.onBoardsConfigDidChange((event) => {
|
||||||
this.updateMenuActions(selectedBoard)
|
if (isBoardIdentifierChangeEvent(event)) {
|
||||||
|
this.updateMenuActions(event.selectedBoard);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override onReady(): void {
|
||||||
|
this.boardsServiceProvider.ready.then(() =>
|
||||||
|
this.updateMenuActions(
|
||||||
|
this.boardsServiceProvider.boardsConfig.selectedBoard
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async updateMenuActions(
|
private async updateMenuActions(
|
||||||
selectedBoard: Board | undefined
|
selectedBoard: BoardIdentifier | undefined
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return this.queue.add(async () => {
|
return this.queue.add(async () => {
|
||||||
this.toDisposeOnBoardChange.dispose();
|
this.toDisposeOnBoardChange.dispose();
|
||||||
this.mainMenuManager.update();
|
this.menuManager.update();
|
||||||
if (selectedBoard) {
|
if (selectedBoard) {
|
||||||
const { fqbn } = selectedBoard;
|
const { fqbn } = selectedBoard;
|
||||||
if (fqbn) {
|
if (fqbn) {
|
||||||
@@ -70,16 +79,15 @@ export class BoardsDataMenuUpdater implements FrontendApplicationContribution {
|
|||||||
string,
|
string,
|
||||||
Disposable & { label: string }
|
Disposable & { label: string }
|
||||||
>();
|
>();
|
||||||
|
let selectedValue = '';
|
||||||
for (const value of values) {
|
for (const value of values) {
|
||||||
const id = `${fqbn}-${option}--${value.value}`;
|
const id = `${fqbn}-${option}--${value.value}`;
|
||||||
const command = { id };
|
const command = { id };
|
||||||
const selectedValue = value.value;
|
|
||||||
const handler = {
|
const handler = {
|
||||||
execute: () =>
|
execute: () =>
|
||||||
this.boardsDataStore.selectConfigOption({
|
this.boardsDataStore.selectConfigOption({
|
||||||
fqbn,
|
fqbn,
|
||||||
option,
|
optionsToUpdate: [{ option, selectedValue: value.value }],
|
||||||
selectedValue,
|
|
||||||
}),
|
}),
|
||||||
isToggled: () => value.selected,
|
isToggled: () => value.selected,
|
||||||
};
|
};
|
||||||
@@ -90,8 +98,14 @@ export class BoardsDataMenuUpdater implements FrontendApplicationContribution {
|
|||||||
{ label: value.label }
|
{ label: value.label }
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
if (value.selected) {
|
||||||
|
selectedValue = value.label;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.menuRegistry.registerSubmenu(menuPath, label);
|
this.menuRegistry.registerSubmenu(
|
||||||
|
menuPath,
|
||||||
|
`${label}${selectedValue ? `: "${selectedValue}"` : ''}`
|
||||||
|
);
|
||||||
this.toDisposeOnBoardChange.pushAll([
|
this.toDisposeOnBoardChange.pushAll([
|
||||||
...commands.values(),
|
...commands.values(),
|
||||||
Disposable.create(() =>
|
Disposable.create(() =>
|
||||||
@@ -101,7 +115,7 @@ export class BoardsDataMenuUpdater implements FrontendApplicationContribution {
|
|||||||
const { label } = commands.get(commandId)!;
|
const { label } = commands.get(commandId)!;
|
||||||
this.menuRegistry.registerMenuAction(menuPath, {
|
this.menuRegistry.registerMenuAction(menuPath, {
|
||||||
commandId,
|
commandId,
|
||||||
order: `${i}`,
|
order: String(i).padStart(4),
|
||||||
label,
|
label,
|
||||||
});
|
});
|
||||||
return Disposable.create(() =>
|
return Disposable.create(() =>
|
||||||
@@ -156,7 +170,7 @@ export class BoardsDataMenuUpdater implements FrontendApplicationContribution {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.mainMenuManager.update();
|
this.menuManager.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1,42 +1,23 @@
|
|||||||
import { inject, injectable } from 'inversify';
|
import { nls } from '@theia/core/lib/common';
|
||||||
import { OutputChannelManager } from '@theia/output/lib/browser/output-channel';
|
import { injectable } from '@theia/core/shared/inversify';
|
||||||
import { CoreService } from '../../common/protocol';
|
import { CoreService } from '../../common/protocol';
|
||||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
import { BoardsDataStore } from '../boards/boards-data-store';
|
|
||||||
import { SerialConnectionManager } from '../serial/serial-connection-manager';
|
|
||||||
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
|
||||||
import {
|
import {
|
||||||
SketchContribution,
|
|
||||||
Command,
|
Command,
|
||||||
CommandRegistry,
|
CommandRegistry,
|
||||||
|
CoreServiceContribution,
|
||||||
MenuModelRegistry,
|
MenuModelRegistry,
|
||||||
} from './contribution';
|
} from './contribution';
|
||||||
import { nls } from '@theia/core/lib/common';
|
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class BurnBootloader extends SketchContribution {
|
export class BurnBootloader extends CoreServiceContribution {
|
||||||
@inject(CoreService)
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
protected readonly coreService: CoreService;
|
|
||||||
|
|
||||||
@inject(SerialConnectionManager)
|
|
||||||
protected readonly serialConnection: SerialConnectionManager;
|
|
||||||
|
|
||||||
@inject(BoardsDataStore)
|
|
||||||
protected readonly boardsDataStore: BoardsDataStore;
|
|
||||||
|
|
||||||
@inject(BoardsServiceProvider)
|
|
||||||
protected readonly boardsServiceClientImpl: BoardsServiceProvider;
|
|
||||||
|
|
||||||
@inject(OutputChannelManager)
|
|
||||||
protected readonly outputChannelManager: OutputChannelManager;
|
|
||||||
|
|
||||||
registerCommands(registry: CommandRegistry): void {
|
|
||||||
registry.registerCommand(BurnBootloader.Commands.BURN_BOOTLOADER, {
|
registry.registerCommand(BurnBootloader.Commands.BURN_BOOTLOADER, {
|
||||||
execute: () => this.burnBootloader(),
|
execute: () => this.burnBootloader(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMenus(registry: MenuModelRegistry): void {
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
registry.registerMenuAction(ArduinoMenus.TOOLS__BOARD_SETTINGS_GROUP, {
|
registry.registerMenuAction(ArduinoMenus.TOOLS__BOARD_SETTINGS_GROUP, {
|
||||||
commandId: BurnBootloader.Commands.BURN_BOOTLOADER.id,
|
commandId: BurnBootloader.Commands.BURN_BOOTLOADER.id,
|
||||||
label: nls.localize(
|
label: nls.localize(
|
||||||
@@ -47,26 +28,24 @@ export class BurnBootloader extends SketchContribution {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async burnBootloader(): Promise<void> {
|
private async burnBootloader(): Promise<void> {
|
||||||
|
this.clearVisibleNotification();
|
||||||
|
const options = await this.options();
|
||||||
try {
|
try {
|
||||||
const { boardsConfig } = this.boardsServiceClientImpl;
|
await this.doWithProgress({
|
||||||
const port = boardsConfig.selectedPort;
|
progressText: nls.localize(
|
||||||
const [fqbn, { selectedProgrammer: programmer }, verify, verbose] =
|
'arduino/bootloader/burningBootloader',
|
||||||
await Promise.all([
|
'Burning bootloader...'
|
||||||
this.boardsDataStore.appendConfigToFqbn(
|
),
|
||||||
boardsConfig.selectedBoard?.fqbn
|
task: (progressId, coreService, token) =>
|
||||||
|
coreService.burnBootloader(
|
||||||
|
{
|
||||||
|
...options,
|
||||||
|
progressId,
|
||||||
|
},
|
||||||
|
token
|
||||||
),
|
),
|
||||||
this.boardsDataStore.getData(boardsConfig.selectedBoard?.fqbn),
|
cancelable: true,
|
||||||
this.preferences.get('arduino.upload.verify'),
|
|
||||||
this.preferences.get('arduino.upload.verbose'),
|
|
||||||
]);
|
|
||||||
this.outputChannelManager.getChannel('Arduino').clear();
|
|
||||||
await this.coreService.burnBootloader({
|
|
||||||
fqbn,
|
|
||||||
programmer,
|
|
||||||
port,
|
|
||||||
verify,
|
|
||||||
verbose,
|
|
||||||
});
|
});
|
||||||
this.messageService.info(
|
this.messageService.info(
|
||||||
nls.localize(
|
nls.localize(
|
||||||
@@ -78,17 +57,30 @@ export class BurnBootloader extends SketchContribution {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
let errorMessage = "";
|
this.handleError(e);
|
||||||
if (typeof e === "string") {
|
|
||||||
errorMessage = e;
|
|
||||||
} else {
|
|
||||||
errorMessage = e.toString();
|
|
||||||
}
|
|
||||||
this.messageService.error(errorMessage);
|
|
||||||
} finally {
|
|
||||||
await this.serialConnection.reconnectAfterUpload();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async options(): Promise<CoreService.Options.Bootloader> {
|
||||||
|
const { boardsConfig } = this.boardsServiceProvider;
|
||||||
|
const port = boardsConfig.selectedPort;
|
||||||
|
const [fqbn, { selectedProgrammer: programmer }, verify, verbose] =
|
||||||
|
await Promise.all([
|
||||||
|
this.boardsDataStore.appendConfigToFqbn(
|
||||||
|
boardsConfig.selectedBoard?.fqbn
|
||||||
|
),
|
||||||
|
this.boardsDataStore.getData(boardsConfig.selectedBoard?.fqbn),
|
||||||
|
this.preferences.get('arduino.upload.verify'),
|
||||||
|
this.preferences.get('arduino.upload.verbose'),
|
||||||
|
]);
|
||||||
|
return {
|
||||||
|
fqbn,
|
||||||
|
programmer,
|
||||||
|
port,
|
||||||
|
verify,
|
||||||
|
verbose,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace BurnBootloader {
|
export namespace BurnBootloader {
|
||||||
|
|||||||
@@ -0,0 +1,123 @@
|
|||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { LocalStorageService } from '@theia/core/lib/browser/storage-service';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import {
|
||||||
|
IDEUpdater,
|
||||||
|
LAST_USED_IDE_VERSION,
|
||||||
|
SKIP_IDE_VERSION,
|
||||||
|
} from '../../common/protocol/ide-updater';
|
||||||
|
import { IDEUpdaterDialog } from '../dialogs/ide-updater/ide-updater-dialog';
|
||||||
|
import { Contribution } from './contribution';
|
||||||
|
import { VersionWelcomeDialog } from '../dialogs/version-welcome-dialog';
|
||||||
|
import { AppService } from '../app-service';
|
||||||
|
import { SemVer } from 'semver';
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class CheckForIDEUpdates extends Contribution {
|
||||||
|
@inject(IDEUpdater)
|
||||||
|
private readonly updater: IDEUpdater;
|
||||||
|
|
||||||
|
@inject(IDEUpdaterDialog)
|
||||||
|
private readonly updaterDialog: IDEUpdaterDialog;
|
||||||
|
|
||||||
|
@inject(VersionWelcomeDialog)
|
||||||
|
private readonly versionWelcomeDialog: VersionWelcomeDialog;
|
||||||
|
|
||||||
|
@inject(LocalStorageService)
|
||||||
|
private readonly localStorage: LocalStorageService;
|
||||||
|
|
||||||
|
@inject(AppService)
|
||||||
|
private readonly appService: AppService;
|
||||||
|
|
||||||
|
override onStart(): void {
|
||||||
|
this.preferences.onPreferenceChanged(
|
||||||
|
({ preferenceName, newValue, oldValue }) => {
|
||||||
|
if (newValue !== oldValue) {
|
||||||
|
switch (preferenceName) {
|
||||||
|
case 'arduino.ide.updateChannel':
|
||||||
|
case 'arduino.ide.updateBaseUrl':
|
||||||
|
this.updater.init(
|
||||||
|
this.preferences.get('arduino.ide.updateChannel'),
|
||||||
|
this.preferences.get('arduino.ide.updateBaseUrl')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
override async onReady(): Promise<void> {
|
||||||
|
this.updater
|
||||||
|
.init(
|
||||||
|
this.preferences.get('arduino.ide.updateChannel'),
|
||||||
|
this.preferences.get('arduino.ide.updateBaseUrl')
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
if (!this.preferences['arduino.checkForUpdates']) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return this.updater.checkForUpdates(true);
|
||||||
|
})
|
||||||
|
.then(async (updateInfo) => {
|
||||||
|
if (!updateInfo) {
|
||||||
|
const isNewVersion = await this.isNewStableVersion();
|
||||||
|
if (isNewVersion) {
|
||||||
|
this.versionWelcomeDialog.open();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const versionToSkip = await this.localStorage.getData<string>(
|
||||||
|
SKIP_IDE_VERSION
|
||||||
|
);
|
||||||
|
if (versionToSkip === updateInfo.version) return;
|
||||||
|
this.updaterDialog.open(true, updateInfo);
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
this.messageService.error(
|
||||||
|
nls.localize(
|
||||||
|
'arduino/ide-updater/errorCheckingForUpdates',
|
||||||
|
'Error while checking for Arduino IDE updates.\n{0}',
|
||||||
|
e.message
|
||||||
|
)
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.setCurrentIDEVersion();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async setCurrentIDEVersion(): Promise<void> {
|
||||||
|
try {
|
||||||
|
const { appVersion } = await this.appService.info();
|
||||||
|
const currSemVer = new SemVer(appVersion ?? '');
|
||||||
|
this.localStorage.setData(LAST_USED_IDE_VERSION, currSemVer.format());
|
||||||
|
} catch {
|
||||||
|
// ignore invalid versions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if user is running a new IDE version for the first time.
|
||||||
|
* @returns true if the current IDE version is greater than the last used version
|
||||||
|
* and both are non-prerelease versions.
|
||||||
|
*/
|
||||||
|
private async isNewStableVersion(): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
const { appVersion } = await this.appService.info();
|
||||||
|
const prevVersion = await this.localStorage.getData<string>(
|
||||||
|
LAST_USED_IDE_VERSION
|
||||||
|
);
|
||||||
|
|
||||||
|
const prevSemVer = new SemVer(prevVersion ?? '');
|
||||||
|
const currSemVer = new SemVer(appVersion ?? '');
|
||||||
|
|
||||||
|
if (prevSemVer.prerelease.length || currSemVer.prerelease.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return currSemVer.compare(prevSemVer) === 1;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,221 @@
|
|||||||
|
import type { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { InstallManually, Later } from '../../common/nls';
|
||||||
|
import {
|
||||||
|
ArduinoComponent,
|
||||||
|
BoardsPackage,
|
||||||
|
BoardsService,
|
||||||
|
LibraryPackage,
|
||||||
|
LibraryService,
|
||||||
|
ResponseServiceClient,
|
||||||
|
Searchable,
|
||||||
|
} from '../../common/protocol';
|
||||||
|
import { Installable } from '../../common/protocol/installable';
|
||||||
|
import { ExecuteWithProgress } from '../../common/protocol/progressible';
|
||||||
|
import { BoardsListWidgetFrontendContribution } from '../boards/boards-widget-frontend-contribution';
|
||||||
|
import { LibraryListWidgetFrontendContribution } from '../library/library-widget-frontend-contribution';
|
||||||
|
import { WindowServiceExt } from '../theia/core/window-service-ext';
|
||||||
|
import type { ListWidget } from '../widgets/component-list/list-widget';
|
||||||
|
import { Command, CommandRegistry, Contribution } from './contribution';
|
||||||
|
|
||||||
|
const NoUpdates = nls.localize(
|
||||||
|
'arduino/checkForUpdates/noUpdates',
|
||||||
|
'There are no recent updates available.'
|
||||||
|
);
|
||||||
|
const PromptUpdateBoards = nls.localize(
|
||||||
|
'arduino/checkForUpdates/promptUpdateBoards',
|
||||||
|
'Updates are available for some of your boards.'
|
||||||
|
);
|
||||||
|
const PromptUpdateLibraries = nls.localize(
|
||||||
|
'arduino/checkForUpdates/promptUpdateLibraries',
|
||||||
|
'Updates are available for some of your libraries.'
|
||||||
|
);
|
||||||
|
const UpdatingBoards = nls.localize(
|
||||||
|
'arduino/checkForUpdates/updatingBoards',
|
||||||
|
'Updating boards...'
|
||||||
|
);
|
||||||
|
const UpdatingLibraries = nls.localize(
|
||||||
|
'arduino/checkForUpdates/updatingLibraries',
|
||||||
|
'Updating libraries...'
|
||||||
|
);
|
||||||
|
const InstallAll = nls.localize(
|
||||||
|
'arduino/checkForUpdates/installAll',
|
||||||
|
'Install All'
|
||||||
|
);
|
||||||
|
|
||||||
|
interface Task<T extends ArduinoComponent> {
|
||||||
|
readonly run: () => Promise<void>;
|
||||||
|
readonly item: T;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Updatable = { type: 'Updatable' } as const;
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class CheckForUpdates extends Contribution {
|
||||||
|
@inject(WindowServiceExt)
|
||||||
|
private readonly windowService: WindowServiceExt;
|
||||||
|
@inject(ResponseServiceClient)
|
||||||
|
private readonly responseService: ResponseServiceClient;
|
||||||
|
@inject(BoardsService)
|
||||||
|
private readonly boardsService: BoardsService;
|
||||||
|
@inject(LibraryService)
|
||||||
|
private readonly libraryService: LibraryService;
|
||||||
|
@inject(BoardsListWidgetFrontendContribution)
|
||||||
|
private readonly boardsContribution: BoardsListWidgetFrontendContribution;
|
||||||
|
@inject(LibraryListWidgetFrontendContribution)
|
||||||
|
private readonly librariesContribution: LibraryListWidgetFrontendContribution;
|
||||||
|
|
||||||
|
override registerCommands(register: CommandRegistry): void {
|
||||||
|
register.registerCommand(CheckForUpdates.Commands.CHECK_FOR_UPDATES, {
|
||||||
|
execute: () => this.checkForUpdates(false),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override async onReady(): Promise<void> {
|
||||||
|
const checkForUpdates = this.preferences['arduino.checkForUpdates'];
|
||||||
|
if (checkForUpdates) {
|
||||||
|
this.windowService.isFirstWindow().then((firstWindow) => {
|
||||||
|
if (firstWindow) {
|
||||||
|
this.checkForUpdates();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async checkForUpdates(silent = true) {
|
||||||
|
const [boardsPackages, libraryPackages] = await Promise.all([
|
||||||
|
this.boardsService.search(Updatable),
|
||||||
|
this.libraryService.search(Updatable),
|
||||||
|
]);
|
||||||
|
this.promptUpdateBoards(boardsPackages);
|
||||||
|
this.promptUpdateLibraries(libraryPackages);
|
||||||
|
if (!libraryPackages.length && !boardsPackages.length && !silent) {
|
||||||
|
this.messageService.info(NoUpdates);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private promptUpdateBoards(items: BoardsPackage[]): void {
|
||||||
|
this.prompt({
|
||||||
|
items,
|
||||||
|
installable: this.boardsService,
|
||||||
|
viewContribution: this.boardsContribution,
|
||||||
|
viewSearchOptions: { query: '', ...Updatable },
|
||||||
|
promptMessage: PromptUpdateBoards,
|
||||||
|
updatingMessage: UpdatingBoards,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private promptUpdateLibraries(items: LibraryPackage[]): void {
|
||||||
|
this.prompt({
|
||||||
|
items,
|
||||||
|
installable: this.libraryService,
|
||||||
|
viewContribution: this.librariesContribution,
|
||||||
|
viewSearchOptions: { query: '', topic: 'All', ...Updatable },
|
||||||
|
promptMessage: PromptUpdateLibraries,
|
||||||
|
updatingMessage: UpdatingLibraries,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private prompt<
|
||||||
|
T extends ArduinoComponent,
|
||||||
|
S extends Searchable.Options
|
||||||
|
>(options: {
|
||||||
|
items: T[];
|
||||||
|
installable: Installable<T>;
|
||||||
|
viewContribution: AbstractViewContribution<ListWidget<T, S>>;
|
||||||
|
viewSearchOptions: S;
|
||||||
|
promptMessage: string;
|
||||||
|
updatingMessage: string;
|
||||||
|
}): void {
|
||||||
|
const {
|
||||||
|
items,
|
||||||
|
installable,
|
||||||
|
viewContribution,
|
||||||
|
promptMessage: message,
|
||||||
|
viewSearchOptions,
|
||||||
|
updatingMessage,
|
||||||
|
} = options;
|
||||||
|
|
||||||
|
if (!items.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.messageService
|
||||||
|
.info(message, Later, InstallManually, InstallAll)
|
||||||
|
.then((answer) => {
|
||||||
|
if (answer === InstallAll) {
|
||||||
|
const tasks = items.map((item) =>
|
||||||
|
this.createInstallTask(item, installable)
|
||||||
|
);
|
||||||
|
this.executeTasks(updatingMessage, tasks);
|
||||||
|
} else if (answer === InstallManually) {
|
||||||
|
viewContribution
|
||||||
|
.openView({ reveal: true })
|
||||||
|
.then((widget) => widget.refresh(viewSearchOptions));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async executeTasks(
|
||||||
|
message: string,
|
||||||
|
tasks: Task<ArduinoComponent>[]
|
||||||
|
): Promise<void> {
|
||||||
|
if (tasks.length) {
|
||||||
|
return ExecuteWithProgress.withProgress(
|
||||||
|
message,
|
||||||
|
this.messageService,
|
||||||
|
async (progress) => {
|
||||||
|
try {
|
||||||
|
const total = tasks.length;
|
||||||
|
let count = 0;
|
||||||
|
for (const { run, item } of tasks) {
|
||||||
|
try {
|
||||||
|
await run(); // runs update sequentially. // TODO: is parallel update desired?
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
this.messageService.error(
|
||||||
|
`Failed to update ${item.name}. ${err}`
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
progress.report({ work: { total, done: ++count } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
progress.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private createInstallTask<T extends ArduinoComponent>(
|
||||||
|
item: T,
|
||||||
|
installable: Installable<T>
|
||||||
|
): Task<T> {
|
||||||
|
const latestVersion = item.availableVersions[0];
|
||||||
|
return {
|
||||||
|
item,
|
||||||
|
run: () =>
|
||||||
|
Installable.installWithProgress({
|
||||||
|
installable,
|
||||||
|
item,
|
||||||
|
version: latestVersion,
|
||||||
|
messageService: this.messageService,
|
||||||
|
responseService: this.responseService,
|
||||||
|
keepOutput: true,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export namespace CheckForUpdates {
|
||||||
|
export namespace Commands {
|
||||||
|
export const CHECK_FOR_UPDATES: Command = Command.toLocalizedCommand(
|
||||||
|
{
|
||||||
|
id: 'arduino-check-for-updates',
|
||||||
|
label: 'Check for Arduino Updates',
|
||||||
|
category: 'Arduino',
|
||||||
|
},
|
||||||
|
'arduino/checkForUpdates/checkForUpdates'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,39 +1,43 @@
|
|||||||
import { inject, injectable } from 'inversify';
|
import { Dialog } from '@theia/core/lib/browser/dialogs';
|
||||||
import { toArray } from '@phosphor/algorithm';
|
import type { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
|
||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
import type { OnWillStopAction } from '@theia/core/lib/browser/frontend-application-contribution';
|
||||||
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
|
|
||||||
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
|
||||||
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
|
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
|
||||||
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import type { MaybePromise } from '@theia/core/lib/common/types';
|
||||||
|
import { toArray } from '@theia/core/shared/@phosphor/algorithm';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
|
||||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
import { SaveAsSketch } from './save-as-sketch';
|
import { CurrentSketch } from '../sketches-service-client-impl';
|
||||||
|
import { WindowServiceExt } from '../theia/core/window-service-ext';
|
||||||
import {
|
import {
|
||||||
SketchContribution,
|
|
||||||
Command,
|
Command,
|
||||||
CommandRegistry,
|
CommandRegistry,
|
||||||
MenuModelRegistry,
|
|
||||||
KeybindingRegistry,
|
KeybindingRegistry,
|
||||||
|
MenuModelRegistry,
|
||||||
|
Sketch,
|
||||||
|
SketchContribution,
|
||||||
URI,
|
URI,
|
||||||
} from './contribution';
|
} from './contribution';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import { SaveAsSketch } from './save-as-sketch';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the `current` closeable editor, or any closeable current widget from the main area, or the current sketch window.
|
* Closes the `current` closeable editor, or any closeable current widget from the main area, or the current sketch window.
|
||||||
*/
|
*/
|
||||||
@injectable()
|
@injectable()
|
||||||
export class Close extends SketchContribution {
|
export class Close extends SketchContribution {
|
||||||
@inject(EditorManager)
|
@inject(WindowServiceExt)
|
||||||
protected readonly editorManager: EditorManager;
|
private readonly windowServiceExt: WindowServiceExt;
|
||||||
|
|
||||||
protected shell: ApplicationShell;
|
private shell: ApplicationShell | undefined;
|
||||||
|
|
||||||
onStart(app: FrontendApplication): void {
|
override onStart(app: FrontendApplication): MaybePromise<void> {
|
||||||
this.shell = app.shell;
|
this.shell = app.shell;
|
||||||
}
|
}
|
||||||
|
|
||||||
registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(Close.Commands.CLOSE, {
|
registry.registerCommand(Close.Commands.CLOSE, {
|
||||||
execute: async () => {
|
execute: () => {
|
||||||
// Close current editor if closeable.
|
// Close current editor if closeable.
|
||||||
const { currentEditor } = this.editorManager;
|
const { currentEditor } = this.editorManager;
|
||||||
if (currentEditor && currentEditor.title.closable) {
|
if (currentEditor && currentEditor.title.closable) {
|
||||||
@@ -41,86 +45,152 @@ export class Close extends SketchContribution {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close current widget from the main area if possible.
|
if (this.shell) {
|
||||||
const { currentWidget } = this.shell;
|
// Close current widget from the main area if possible.
|
||||||
if (currentWidget) {
|
const { currentWidget } = this.shell;
|
||||||
const currentWidgetInMain = toArray(
|
if (currentWidget) {
|
||||||
this.shell.mainPanel.widgets()
|
const currentWidgetInMain = toArray(
|
||||||
).find((widget) => widget === currentWidget);
|
this.shell.mainPanel.widgets()
|
||||||
if (currentWidgetInMain && currentWidgetInMain.title.closable) {
|
).find((widget) => widget === currentWidget);
|
||||||
return currentWidgetInMain.close();
|
if (currentWidgetInMain && currentWidgetInMain.title.closable) {
|
||||||
}
|
return currentWidgetInMain.close();
|
||||||
}
|
|
||||||
|
|
||||||
// Close the sketch (window).
|
|
||||||
const sketch = await this.sketchServiceClient.currentSketch();
|
|
||||||
if (!sketch) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const isTemp = await this.sketchService.isTemp(sketch);
|
|
||||||
const uri = await this.sketchServiceClient.currentSketchFile();
|
|
||||||
if (!uri) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isTemp && (await this.wasTouched(uri))) {
|
|
||||||
const { response } = await remote.dialog.showMessageBox({
|
|
||||||
type: 'question',
|
|
||||||
buttons: [
|
|
||||||
nls.localize(
|
|
||||||
'vscode/abstractTaskService/saveBeforeRun.dontSave',
|
|
||||||
"Don't Save"
|
|
||||||
),
|
|
||||||
nls.localize('vscode/issueMainService/cancel', 'Cancel'),
|
|
||||||
nls.localize(
|
|
||||||
'vscode/abstractTaskService/saveBeforeRun.save',
|
|
||||||
'Save'
|
|
||||||
),
|
|
||||||
],
|
|
||||||
message: nls.localize(
|
|
||||||
'arduino/common/saveChangesToSketch',
|
|
||||||
'Do you want to save changes to this sketch before closing?'
|
|
||||||
),
|
|
||||||
detail: nls.localize(
|
|
||||||
'arduino/common/loseChanges',
|
|
||||||
"If you don't save, your changes will be lost."
|
|
||||||
),
|
|
||||||
});
|
|
||||||
if (response === 1) {
|
|
||||||
// Cancel
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (response === 2) {
|
|
||||||
// Save
|
|
||||||
const saved = await this.commandService.executeCommand(
|
|
||||||
SaveAsSketch.Commands.SAVE_AS_SKETCH.id,
|
|
||||||
{ openAfterMove: false, execOnlyIfTemp: true }
|
|
||||||
);
|
|
||||||
if (!saved) {
|
|
||||||
// If it was not saved, do bail the close.
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.close();
|
return this.windowServiceExt.close();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMenus(registry: MenuModelRegistry): void {
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
registry.registerMenuAction(ArduinoMenus.FILE__SKETCH_GROUP, {
|
registry.registerMenuAction(ArduinoMenus.FILE__SKETCH_GROUP, {
|
||||||
commandId: Close.Commands.CLOSE.id,
|
commandId: Close.Commands.CLOSE.id,
|
||||||
label: nls.localize('vscode/editor.contribution/close', 'Close'),
|
label: nls.localize('vscode/editor.contribution/close', 'Close'),
|
||||||
order: '5',
|
order: '6',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerKeybindings(registry: KeybindingRegistry): void {
|
override registerKeybindings(registry: KeybindingRegistry): void {
|
||||||
registry.registerKeybinding({
|
registry.registerKeybinding({
|
||||||
command: Close.Commands.CLOSE.id,
|
command: Close.Commands.CLOSE.id,
|
||||||
keybinding: 'CtrlCmd+W',
|
keybinding: 'CtrlCmd+W',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// `FrontendApplicationContribution#onWillStop`
|
||||||
|
onWillStop(): OnWillStopAction {
|
||||||
|
return {
|
||||||
|
reason: 'save-sketch',
|
||||||
|
action: () => {
|
||||||
|
return this.showSaveSketchDialog();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If returns with `true`, IDE2 will close. Otherwise, it won't.
|
||||||
|
*/
|
||||||
|
private async showSaveSketchDialog(): Promise<boolean> {
|
||||||
|
const sketch = await this.isCurrentSketchTemp();
|
||||||
|
if (!sketch) {
|
||||||
|
// Normal close workflow: if there are dirty editors prompt the user.
|
||||||
|
if (!this.shell) {
|
||||||
|
console.error(
|
||||||
|
`Could not get the application shell. Something went wrong.`
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (this.shell.canSaveAll()) {
|
||||||
|
const prompt = await this.prompt(false);
|
||||||
|
switch (prompt) {
|
||||||
|
case Prompt.DoNotSave:
|
||||||
|
return true;
|
||||||
|
case Prompt.Cancel:
|
||||||
|
return false;
|
||||||
|
case Prompt.Save: {
|
||||||
|
await this.shell.saveAll();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw new Error(`Unexpected prompt: ${prompt}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If non of the sketch files were ever touched, do not prompt the save dialog. (#1274)
|
||||||
|
const wereTouched = await Promise.all(
|
||||||
|
Sketch.uris(sketch).map((uri) => this.wasTouched(uri))
|
||||||
|
);
|
||||||
|
if (wereTouched.every((wasTouched) => !Boolean(wasTouched))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const prompt = await this.prompt(true);
|
||||||
|
switch (prompt) {
|
||||||
|
case Prompt.DoNotSave:
|
||||||
|
return true;
|
||||||
|
case Prompt.Cancel:
|
||||||
|
return false;
|
||||||
|
case Prompt.Save: {
|
||||||
|
// If `save as` was canceled by user, the result will be `undefined`, otherwise the new URI.
|
||||||
|
const result = await this.commandService.executeCommand(
|
||||||
|
SaveAsSketch.Commands.SAVE_AS_SKETCH.id,
|
||||||
|
{
|
||||||
|
execOnlyIfTemp: false,
|
||||||
|
openAfterMove: false,
|
||||||
|
wipeOriginal: true,
|
||||||
|
markAsRecentlyOpened: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return !!result;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw new Error(`Unexpected prompt: ${prompt}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async prompt(isTemp: boolean): Promise<Prompt> {
|
||||||
|
const { response } = await this.dialogService.showMessageBox({
|
||||||
|
message: nls.localize(
|
||||||
|
'arduino/sketch/saveSketch',
|
||||||
|
'Save your sketch to open it again later.'
|
||||||
|
),
|
||||||
|
title: nls.localize(
|
||||||
|
'theia/core/quitTitle',
|
||||||
|
'Are you sure you want to quit?'
|
||||||
|
),
|
||||||
|
type: 'question',
|
||||||
|
buttons: [
|
||||||
|
nls.localizeByDefault("Don't Save"),
|
||||||
|
Dialog.CANCEL,
|
||||||
|
nls.localizeByDefault(isTemp ? 'Save As...' : 'Save'),
|
||||||
|
],
|
||||||
|
defaultId: 2, // `Save`/`Save As...` button index is the default.
|
||||||
|
});
|
||||||
|
switch (response) {
|
||||||
|
case 0:
|
||||||
|
return Prompt.DoNotSave;
|
||||||
|
case 1:
|
||||||
|
return Prompt.Cancel;
|
||||||
|
case 2:
|
||||||
|
return Prompt.Save;
|
||||||
|
default:
|
||||||
|
throw new Error(`Unexpected response: ${response}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async isCurrentSketchTemp(): Promise<false | Sketch> {
|
||||||
|
const currentSketch = await this.sketchServiceClient.currentSketch();
|
||||||
|
if (CurrentSketch.isValid(currentSketch)) {
|
||||||
|
const isTemp = await this.sketchesService.isTemp(currentSketch);
|
||||||
|
if (isTemp) {
|
||||||
|
return currentSketch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the file was ever touched/modified. We get this based on the `version` of the monaco model.
|
* If the file was ever touched/modified. We get this based on the `version` of the monaco model.
|
||||||
*/
|
*/
|
||||||
@@ -130,13 +200,23 @@ export class Close extends SketchContribution {
|
|||||||
const { editor } = editorWidget;
|
const { editor } = editorWidget;
|
||||||
if (editor instanceof MonacoEditor) {
|
if (editor instanceof MonacoEditor) {
|
||||||
const versionId = editor.getControl().getModel()?.getVersionId();
|
const versionId = editor.getControl().getModel()?.getVersionId();
|
||||||
if (Number.isInteger(versionId) && versionId! > 1) {
|
if (this.isInteger(versionId) && versionId > 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isInteger(arg: unknown): arg is number {
|
||||||
|
return Number.isInteger(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Prompt {
|
||||||
|
Save,
|
||||||
|
DoNotSave,
|
||||||
|
Cancel,
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace Close {
|
export namespace Close {
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
import { CompositeTreeNode } from '@theia/core/lib/browser/tree';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { CreateApi } from '../create/create-api';
|
||||||
|
import { CreateFeatures } from '../create/create-features';
|
||||||
|
import { CreateUri } from '../create/create-uri';
|
||||||
|
import { Create, isNotFound } from '../create/typings';
|
||||||
|
import { CloudSketchbookTree } from '../widgets/cloud-sketchbook/cloud-sketchbook-tree';
|
||||||
|
import { CloudSketchbookTreeModel } from '../widgets/cloud-sketchbook/cloud-sketchbook-tree-model';
|
||||||
|
import { CloudSketchbookTreeWidget } from '../widgets/cloud-sketchbook/cloud-sketchbook-tree-widget';
|
||||||
|
import { SketchbookWidget } from '../widgets/sketchbook/sketchbook-widget';
|
||||||
|
import { SketchbookWidgetContribution } from '../widgets/sketchbook/sketchbook-widget-contribution';
|
||||||
|
import { SketchContribution } from './contribution';
|
||||||
|
|
||||||
|
export function sketchAlreadyExists(input: string): string {
|
||||||
|
return nls.localize(
|
||||||
|
'arduino/cloudSketch/alreadyExists',
|
||||||
|
"Cloud sketch '{0}' already exists.",
|
||||||
|
input
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export function sketchNotFound(input: string): string {
|
||||||
|
return nls.localize(
|
||||||
|
'arduino/cloudSketch/notFound',
|
||||||
|
"Could not pull the cloud sketch '{0}'. It does not exist.",
|
||||||
|
input
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export const synchronizingSketchbook = nls.localize(
|
||||||
|
'arduino/cloudSketch/synchronizingSketchbook',
|
||||||
|
'Synchronizing sketchbook...'
|
||||||
|
);
|
||||||
|
export function pullingSketch(input: string): string {
|
||||||
|
return nls.localize(
|
||||||
|
'arduino/cloudSketch/pulling',
|
||||||
|
"Synchronizing sketchbook, pulling '{0}'...",
|
||||||
|
input
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export function pushingSketch(input: string): string {
|
||||||
|
return nls.localize(
|
||||||
|
'arduino/cloudSketch/pushing',
|
||||||
|
"Synchronizing sketchbook, pushing '{0}'...",
|
||||||
|
input
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export abstract class CloudSketchContribution extends SketchContribution {
|
||||||
|
@inject(SketchbookWidgetContribution)
|
||||||
|
private readonly widgetContribution: SketchbookWidgetContribution;
|
||||||
|
@inject(CreateApi)
|
||||||
|
protected readonly createApi: CreateApi;
|
||||||
|
@inject(CreateFeatures)
|
||||||
|
protected readonly createFeatures: CreateFeatures;
|
||||||
|
|
||||||
|
protected async treeModel(): Promise<
|
||||||
|
(CloudSketchbookTreeModel & { root: CompositeTreeNode }) | undefined
|
||||||
|
> {
|
||||||
|
const { enabled, session } = this.createFeatures;
|
||||||
|
if (enabled && session) {
|
||||||
|
const widget = await this.widgetContribution.widget;
|
||||||
|
const treeModel = this.treeModelFrom(widget);
|
||||||
|
if (treeModel) {
|
||||||
|
const root = treeModel.root;
|
||||||
|
if (CompositeTreeNode.is(root)) {
|
||||||
|
return treeModel as CloudSketchbookTreeModel & {
|
||||||
|
root: CompositeTreeNode;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async pull(
|
||||||
|
sketch: Create.Sketch
|
||||||
|
): Promise<CloudSketchbookTree.CloudSketchDirNode | undefined> {
|
||||||
|
const treeModel = await this.treeModel();
|
||||||
|
if (!treeModel) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const id = CreateUri.toUri(sketch).path.toString();
|
||||||
|
const node = treeModel.getNode(id);
|
||||||
|
if (!node) {
|
||||||
|
throw new Error(
|
||||||
|
`Could not find cloud sketchbook tree node with ID: ${id}.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!CloudSketchbookTree.CloudSketchDirNode.is(node)) {
|
||||||
|
throw new Error(
|
||||||
|
`Cloud sketchbook tree node expected to represent a directory but it did not. Tree node ID: ${id}.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await treeModel.sketchbookTree().pull({ node }, true);
|
||||||
|
return node;
|
||||||
|
} catch (err) {
|
||||||
|
if (isNotFound(err)) {
|
||||||
|
await treeModel.refresh();
|
||||||
|
this.messageService.error(sketchNotFound(sketch.name));
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private treeModelFrom(
|
||||||
|
widget: SketchbookWidget
|
||||||
|
): CloudSketchbookTreeModel | undefined {
|
||||||
|
for (const treeWidget of widget.getTreeWidgets()) {
|
||||||
|
if (treeWidget instanceof CloudSketchbookTreeWidget) {
|
||||||
|
const model = treeWidget.model;
|
||||||
|
if (model instanceof CloudSketchbookTreeModel) {
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,804 @@
|
|||||||
|
import {
|
||||||
|
Command,
|
||||||
|
CommandRegistry,
|
||||||
|
Disposable,
|
||||||
|
DisposableCollection,
|
||||||
|
Emitter,
|
||||||
|
MaybeArray,
|
||||||
|
MaybePromise,
|
||||||
|
nls,
|
||||||
|
notEmpty,
|
||||||
|
} from '@theia/core';
|
||||||
|
import { ApplicationShell, FrontendApplication } from '@theia/core/lib/browser';
|
||||||
|
import { ITextModel } from '@theia/monaco-editor-core/esm/vs/editor/common/model';
|
||||||
|
import URI from '@theia/core/lib/common/uri';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import {
|
||||||
|
Location,
|
||||||
|
Range,
|
||||||
|
} from '@theia/core/shared/vscode-languageserver-protocol';
|
||||||
|
import {
|
||||||
|
EditorWidget,
|
||||||
|
TextDocumentChangeEvent,
|
||||||
|
} from '@theia/editor/lib/browser';
|
||||||
|
import {
|
||||||
|
EditorDecoration,
|
||||||
|
TrackedRangeStickiness,
|
||||||
|
} from '@theia/editor/lib/browser/decorations/editor-decoration';
|
||||||
|
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
||||||
|
import * as monaco from '@theia/monaco-editor-core';
|
||||||
|
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
|
||||||
|
import { MonacoToProtocolConverter } from '@theia/monaco/lib/browser/monaco-to-protocol-converter';
|
||||||
|
import { ProtocolToMonacoConverter } from '@theia/monaco/lib/browser/protocol-to-monaco-converter';
|
||||||
|
import { OutputUri } from '@theia/output/lib/common/output-uri';
|
||||||
|
import { CoreError } from '../../common/protocol/core-service';
|
||||||
|
import { ErrorRevealStrategy } from '../arduino-preferences';
|
||||||
|
import { ArduinoOutputSelector, InoSelector } from '../selectors';
|
||||||
|
import { Contribution } from './contribution';
|
||||||
|
import { CoreErrorHandler } from './core-error-handler';
|
||||||
|
import { MonacoEditorModel } from '@theia/monaco/lib/browser/monaco-editor-model';
|
||||||
|
|
||||||
|
interface ErrorDecorationRef {
|
||||||
|
/**
|
||||||
|
* This is the unique ID of the decoration given by `monaco`.
|
||||||
|
*/
|
||||||
|
readonly id: string;
|
||||||
|
/**
|
||||||
|
* The resource this decoration belongs to.
|
||||||
|
*/
|
||||||
|
readonly uri: string;
|
||||||
|
}
|
||||||
|
export namespace ErrorDecorationRef {
|
||||||
|
export function is(arg: unknown): arg is ErrorDecorationRef {
|
||||||
|
if (typeof arg === 'object') {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const object = arg as any;
|
||||||
|
return (
|
||||||
|
'uri' in object &&
|
||||||
|
typeof object['uri'] === 'string' &&
|
||||||
|
'id' in object &&
|
||||||
|
typeof object['id'] === 'string'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
export function sameAs(
|
||||||
|
left: ErrorDecorationRef,
|
||||||
|
right: ErrorDecorationRef
|
||||||
|
): boolean {
|
||||||
|
return left.id === right.id && left.uri === right.uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ErrorDecoration extends ErrorDecorationRef {
|
||||||
|
/**
|
||||||
|
* The range of the error location the error in the compiler output from the CLI.
|
||||||
|
*/
|
||||||
|
readonly rangesInOutput: monaco.Range[];
|
||||||
|
}
|
||||||
|
namespace ErrorDecoration {
|
||||||
|
export function rangeOf(
|
||||||
|
editorOrModel: MonacoEditor | ITextModel | undefined,
|
||||||
|
decorations: ErrorDecoration
|
||||||
|
): monaco.Range | undefined;
|
||||||
|
export function rangeOf(
|
||||||
|
editorOrModel: MonacoEditor | ITextModel | undefined,
|
||||||
|
decorations: ErrorDecoration[]
|
||||||
|
): (monaco.Range | undefined)[];
|
||||||
|
export function rangeOf(
|
||||||
|
editorOrModel: MonacoEditor | ITextModel | undefined,
|
||||||
|
decorations: ErrorDecoration | ErrorDecoration[]
|
||||||
|
): MaybePromise<MaybeArray<monaco.Range | undefined>> {
|
||||||
|
if (editorOrModel) {
|
||||||
|
const allDecorations = getAllDecorations(editorOrModel);
|
||||||
|
if (allDecorations) {
|
||||||
|
if (Array.isArray(decorations)) {
|
||||||
|
return decorations.map(({ id: decorationId }) =>
|
||||||
|
findRangeOf(decorationId, allDecorations)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return findRangeOf(decorations.id, allDecorations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Array.isArray(decorations)
|
||||||
|
? decorations.map(() => undefined)
|
||||||
|
: undefined;
|
||||||
|
}
|
||||||
|
function findRangeOf(
|
||||||
|
decorationId: string,
|
||||||
|
allDecorations: { id: string; range?: monaco.Range }[]
|
||||||
|
): monaco.Range | undefined {
|
||||||
|
return allDecorations.find(
|
||||||
|
({ id: candidateId }) => candidateId === decorationId
|
||||||
|
)?.range;
|
||||||
|
}
|
||||||
|
function getAllDecorations(
|
||||||
|
editorOrModel: MonacoEditor | ITextModel
|
||||||
|
): { id: string; range?: monaco.Range }[] {
|
||||||
|
if (editorOrModel instanceof MonacoEditor) {
|
||||||
|
const model = editorOrModel.getControl().getModel();
|
||||||
|
if (!model) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return model.getAllDecorations();
|
||||||
|
}
|
||||||
|
return editorOrModel.getAllDecorations();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class CompilerErrors
|
||||||
|
extends Contribution
|
||||||
|
implements monaco.languages.CodeLensProvider, monaco.languages.LinkProvider
|
||||||
|
{
|
||||||
|
@inject(EditorManager)
|
||||||
|
private readonly editorManager: EditorManager;
|
||||||
|
|
||||||
|
@inject(ProtocolToMonacoConverter)
|
||||||
|
private readonly p2m: ProtocolToMonacoConverter;
|
||||||
|
|
||||||
|
@inject(MonacoToProtocolConverter)
|
||||||
|
private readonly m2p: MonacoToProtocolConverter;
|
||||||
|
|
||||||
|
@inject(CoreErrorHandler)
|
||||||
|
private readonly coreErrorHandler: CoreErrorHandler;
|
||||||
|
|
||||||
|
private revealStrategy = ErrorRevealStrategy.Default;
|
||||||
|
private experimental = false;
|
||||||
|
|
||||||
|
private readonly errors: ErrorDecoration[] = [];
|
||||||
|
private readonly onDidChangeEmitter = new monaco.Emitter<this>();
|
||||||
|
private readonly currentErrorDidChangEmitter = new Emitter<ErrorDecoration>();
|
||||||
|
private readonly onCurrentErrorDidChange =
|
||||||
|
this.currentErrorDidChangEmitter.event;
|
||||||
|
private readonly toDisposeOnCompilerErrorDidChange =
|
||||||
|
new DisposableCollection();
|
||||||
|
|
||||||
|
private shell: ApplicationShell | undefined;
|
||||||
|
private currentError: ErrorDecoration | undefined;
|
||||||
|
private get currentErrorIndex(): number {
|
||||||
|
const current = this.currentError;
|
||||||
|
if (!current) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return this.errors.findIndex((error) =>
|
||||||
|
ErrorDecorationRef.sameAs(error, current)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
override onStart(app: FrontendApplication): void {
|
||||||
|
this.shell = app.shell;
|
||||||
|
monaco.languages.registerCodeLensProvider(InoSelector, this);
|
||||||
|
monaco.languages.registerLinkProvider(ArduinoOutputSelector, this);
|
||||||
|
this.coreErrorHandler.onCompilerErrorsDidChange((errors) =>
|
||||||
|
this.handleCompilerErrorsDidChange(errors)
|
||||||
|
);
|
||||||
|
this.onCurrentErrorDidChange(async (error) => {
|
||||||
|
const monacoEditor = await this.monacoEditor(error.uri);
|
||||||
|
const monacoRange = ErrorDecoration.rangeOf(monacoEditor, error);
|
||||||
|
if (!monacoRange) {
|
||||||
|
console.warn(
|
||||||
|
'compiler-errors',
|
||||||
|
`Could not find range of decoration: ${error.id}`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const range = this.m2p.asRange(monacoRange);
|
||||||
|
const editor = await this.revealLocationInEditor({
|
||||||
|
uri: error.uri,
|
||||||
|
range,
|
||||||
|
});
|
||||||
|
if (!editor) {
|
||||||
|
console.warn(
|
||||||
|
'compiler-errors',
|
||||||
|
`Failed to mark error ${error.id} as the current one.`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const monacoEditor = this.monacoEditor(editor);
|
||||||
|
if (monacoEditor) {
|
||||||
|
monacoEditor.cursor = range.start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override onReady(): MaybePromise<void> {
|
||||||
|
this.preferences.ready.then(() => {
|
||||||
|
this.experimental = Boolean(
|
||||||
|
this.preferences['arduino.compile.experimental']
|
||||||
|
);
|
||||||
|
const strategy = this.preferences['arduino.compile.revealRange'];
|
||||||
|
this.revealStrategy = ErrorRevealStrategy.is(strategy)
|
||||||
|
? strategy
|
||||||
|
: ErrorRevealStrategy.Default;
|
||||||
|
this.preferences.onPreferenceChanged(
|
||||||
|
({ preferenceName, newValue, oldValue }) => {
|
||||||
|
if (newValue === oldValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (preferenceName) {
|
||||||
|
case 'arduino.compile.revealRange': {
|
||||||
|
this.revealStrategy = ErrorRevealStrategy.is(newValue)
|
||||||
|
? newValue
|
||||||
|
: ErrorRevealStrategy.Default;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case 'arduino.compile.experimental': {
|
||||||
|
this.experimental = Boolean(newValue);
|
||||||
|
this.onDidChangeEmitter.fire(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
|
registry.registerCommand(CompilerErrors.Commands.NEXT_ERROR, {
|
||||||
|
execute: () => {
|
||||||
|
const index = this.currentErrorIndex;
|
||||||
|
if (index < 0) {
|
||||||
|
console.warn(
|
||||||
|
'compiler-errors',
|
||||||
|
`Could not advance to next error. Unknown current error.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const nextError =
|
||||||
|
this.errors[index === this.errors.length - 1 ? 0 : index + 1];
|
||||||
|
return this.markAsCurrentError(nextError, {
|
||||||
|
forceReselect: true,
|
||||||
|
reveal: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
isEnabled: () =>
|
||||||
|
this.experimental && !!this.currentError && this.errors.length > 1,
|
||||||
|
});
|
||||||
|
registry.registerCommand(CompilerErrors.Commands.PREVIOUS_ERROR, {
|
||||||
|
execute: () => {
|
||||||
|
const index = this.currentErrorIndex;
|
||||||
|
if (index < 0) {
|
||||||
|
console.warn(
|
||||||
|
'compiler-errors',
|
||||||
|
`Could not advance to previous error. Unknown current error.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const previousError =
|
||||||
|
this.errors[index === 0 ? this.errors.length - 1 : index - 1];
|
||||||
|
return this.markAsCurrentError(previousError, {
|
||||||
|
forceReselect: true,
|
||||||
|
reveal: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
isEnabled: () =>
|
||||||
|
this.experimental && !!this.currentError && this.errors.length > 1,
|
||||||
|
});
|
||||||
|
registry.registerCommand(CompilerErrors.Commands.MARK_AS_CURRENT, {
|
||||||
|
execute: (arg: unknown) => {
|
||||||
|
if (ErrorDecorationRef.is(arg)) {
|
||||||
|
return this.markAsCurrentError(
|
||||||
|
{ id: arg.id, uri: new URI(arg.uri).toString() }, // Make sure the URI fragments are encoded. On Windows, `C:` is encoded as `C%3A`.
|
||||||
|
{ forceReselect: true, reveal: true }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isEnabled: () => !!this.errors.length,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
get onDidChange(): monaco.IEvent<this> {
|
||||||
|
return this.onDidChangeEmitter.event;
|
||||||
|
}
|
||||||
|
|
||||||
|
async provideCodeLenses(
|
||||||
|
model: monaco.editor.ITextModel,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
_token: monaco.CancellationToken
|
||||||
|
): Promise<monaco.languages.CodeLensList> {
|
||||||
|
const lenses: monaco.languages.CodeLens[] = [];
|
||||||
|
if (
|
||||||
|
this.experimental &&
|
||||||
|
this.currentError &&
|
||||||
|
this.currentError.uri === model.uri.toString() &&
|
||||||
|
this.errors.length > 1
|
||||||
|
) {
|
||||||
|
const monacoEditor = await this.monacoEditor(model.uri);
|
||||||
|
const range = ErrorDecoration.rangeOf(monacoEditor, this.currentError);
|
||||||
|
if (range) {
|
||||||
|
lenses.push(
|
||||||
|
{
|
||||||
|
range,
|
||||||
|
command: {
|
||||||
|
id: CompilerErrors.Commands.PREVIOUS_ERROR.id,
|
||||||
|
title: nls.localize(
|
||||||
|
'arduino/editor/previousError',
|
||||||
|
'Previous Error'
|
||||||
|
),
|
||||||
|
arguments: [this.currentError],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
range,
|
||||||
|
command: {
|
||||||
|
id: CompilerErrors.Commands.NEXT_ERROR.id,
|
||||||
|
title: nls.localize('arduino/editor/nextError', 'Next Error'),
|
||||||
|
arguments: [this.currentError],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
lenses,
|
||||||
|
dispose: () => {
|
||||||
|
/* NOOP */
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async provideLinks(
|
||||||
|
model: monaco.editor.ITextModel,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
_token: monaco.CancellationToken
|
||||||
|
): Promise<monaco.languages.ILinksList> {
|
||||||
|
const links: monaco.languages.ILink[] = [];
|
||||||
|
if (
|
||||||
|
model.uri.scheme === OutputUri.SCHEME &&
|
||||||
|
model.uri.path === '/Arduino'
|
||||||
|
) {
|
||||||
|
links.push(
|
||||||
|
...this.errors
|
||||||
|
.filter((decoration) => !!decoration.rangesInOutput.length)
|
||||||
|
.map(({ rangesInOutput, id, uri }) =>
|
||||||
|
rangesInOutput.map(
|
||||||
|
(range) =>
|
||||||
|
<monaco.languages.ILink>{
|
||||||
|
range,
|
||||||
|
url: monaco.Uri.parse(`command://`).with({
|
||||||
|
query: JSON.stringify({ id, uri }),
|
||||||
|
path: CompilerErrors.Commands.MARK_AS_CURRENT.id,
|
||||||
|
}),
|
||||||
|
tooltip: nls.localize(
|
||||||
|
'arduino/editor/revealError',
|
||||||
|
'Reveal Error'
|
||||||
|
),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.reduce((acc, curr) => acc.concat(curr), [])
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.warn('unexpected URI: ' + model.uri.toString());
|
||||||
|
}
|
||||||
|
return { links };
|
||||||
|
}
|
||||||
|
|
||||||
|
async resolveLink(
|
||||||
|
link: monaco.languages.ILink,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
_token: monaco.CancellationToken
|
||||||
|
): Promise<monaco.languages.ILink | undefined> {
|
||||||
|
if (!this.experimental) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const { url } = link;
|
||||||
|
if (url) {
|
||||||
|
const candidateUri = new URI(
|
||||||
|
typeof url === 'string' ? url : url.toString()
|
||||||
|
);
|
||||||
|
const candidateId = candidateUri.path.toString();
|
||||||
|
const error = this.errors.find((error) => error.id === candidateId);
|
||||||
|
if (error) {
|
||||||
|
const monacoEditor = await this.monacoEditor(error.uri);
|
||||||
|
const range = ErrorDecoration.rangeOf(monacoEditor, error);
|
||||||
|
if (range) {
|
||||||
|
return {
|
||||||
|
range,
|
||||||
|
url: monaco.Uri.parse(error.uri),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async handleCompilerErrorsDidChange(
|
||||||
|
errors: CoreError.ErrorLocation[]
|
||||||
|
): Promise<void> {
|
||||||
|
this.toDisposeOnCompilerErrorDidChange.dispose();
|
||||||
|
const groupedErrors = this.groupBy(
|
||||||
|
errors,
|
||||||
|
(error: CoreError.ErrorLocation) => error.location.uri
|
||||||
|
);
|
||||||
|
const decorations = await this.decorateEditors(groupedErrors);
|
||||||
|
this.errors.push(...decorations.errors);
|
||||||
|
this.toDisposeOnCompilerErrorDidChange.pushAll([
|
||||||
|
Disposable.create(() => (this.errors.length = 0)),
|
||||||
|
Disposable.create(() => this.onDidChangeEmitter.fire(this)),
|
||||||
|
...(await Promise.all([
|
||||||
|
decorations.dispose,
|
||||||
|
this.trackEditors(
|
||||||
|
groupedErrors,
|
||||||
|
(editor) =>
|
||||||
|
editor.onSelectionChanged((selection) =>
|
||||||
|
this.handleSelectionChange(editor, selection)
|
||||||
|
),
|
||||||
|
(editor) =>
|
||||||
|
editor.onDispose(() =>
|
||||||
|
this.handleEditorDidDispose(editor.uri.toString())
|
||||||
|
),
|
||||||
|
(editor) =>
|
||||||
|
editor.onDocumentContentChanged((event) =>
|
||||||
|
this.handleDocumentContentChange(editor, event)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
])),
|
||||||
|
]);
|
||||||
|
const currentError = this.errors[0];
|
||||||
|
if (currentError) {
|
||||||
|
await this.markAsCurrentError(currentError, {
|
||||||
|
forceReselect: true,
|
||||||
|
reveal: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async decorateEditors(
|
||||||
|
errors: Map<string, CoreError.ErrorLocation[]>
|
||||||
|
): Promise<{ dispose: Disposable; errors: ErrorDecoration[] }> {
|
||||||
|
const composite = await Promise.all(
|
||||||
|
[...errors.entries()].map(([uri, errors]) =>
|
||||||
|
this.decorateEditor(uri, errors)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
dispose: new DisposableCollection(
|
||||||
|
...composite.map(({ dispose }) => dispose)
|
||||||
|
),
|
||||||
|
errors: composite.reduce(
|
||||||
|
(acc, { errors }) => acc.concat(errors),
|
||||||
|
[] as ErrorDecoration[]
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private async decorateEditor(
|
||||||
|
uri: string,
|
||||||
|
errors: CoreError.ErrorLocation[]
|
||||||
|
): Promise<{ dispose: Disposable; errors: ErrorDecoration[] }> {
|
||||||
|
const editor = await this.monacoEditor(uri);
|
||||||
|
if (!editor) {
|
||||||
|
return { dispose: Disposable.NULL, errors: [] };
|
||||||
|
}
|
||||||
|
const oldDecorations = editor.deltaDecorations({
|
||||||
|
oldDecorations: [],
|
||||||
|
newDecorations: errors.map((error) =>
|
||||||
|
this.compilerErrorDecoration(error.location.range)
|
||||||
|
),
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
dispose: Disposable.create(() => {
|
||||||
|
if (editor) {
|
||||||
|
editor.deltaDecorations({
|
||||||
|
oldDecorations,
|
||||||
|
newDecorations: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
errors: oldDecorations.map((id, index) => ({
|
||||||
|
id,
|
||||||
|
uri,
|
||||||
|
rangesInOutput: errors[index].rangesInOutput.map((range) =>
|
||||||
|
this.p2m.asRange(range)
|
||||||
|
),
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private compilerErrorDecoration(range: Range): EditorDecoration {
|
||||||
|
return {
|
||||||
|
range,
|
||||||
|
options: {
|
||||||
|
isWholeLine: true,
|
||||||
|
className: 'compiler-error',
|
||||||
|
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tracks the selection in all editors that have an error. If the editor selection overlaps one of the compiler error's range, mark as current error.
|
||||||
|
*/
|
||||||
|
private handleSelectionChange(
|
||||||
|
monacoEditor: MonacoEditor,
|
||||||
|
selection: Range
|
||||||
|
): void {
|
||||||
|
const uri = monacoEditor.uri.toString();
|
||||||
|
const monacoSelection = this.p2m.asRange(selection);
|
||||||
|
console.log(
|
||||||
|
'compiler-errors',
|
||||||
|
`Handling selection change in editor ${uri}. New (monaco) selection: ${monacoSelection.toJSON()}`
|
||||||
|
);
|
||||||
|
const calculatePriority = (
|
||||||
|
candidateErrorRange: monaco.Range,
|
||||||
|
currentSelection: monaco.Range
|
||||||
|
) => {
|
||||||
|
console.trace(
|
||||||
|
'compiler-errors',
|
||||||
|
`Candidate error range: ${candidateErrorRange.toJSON()}`
|
||||||
|
);
|
||||||
|
console.trace(
|
||||||
|
'compiler-errors',
|
||||||
|
`Current selection range: ${currentSelection.toJSON()}`
|
||||||
|
);
|
||||||
|
if (candidateErrorRange.intersectRanges(currentSelection)) {
|
||||||
|
console.trace('Intersects.');
|
||||||
|
return { score: 2 };
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
candidateErrorRange.startLineNumber <=
|
||||||
|
currentSelection.startLineNumber &&
|
||||||
|
candidateErrorRange.endLineNumber >= currentSelection.endLineNumber
|
||||||
|
) {
|
||||||
|
console.trace('Same line.');
|
||||||
|
return { score: 1 };
|
||||||
|
}
|
||||||
|
|
||||||
|
console.trace('No match');
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
const errorsPerResource = this.errors.filter((error) => error.uri === uri);
|
||||||
|
const rangesPerResource = ErrorDecoration.rangeOf(
|
||||||
|
monacoEditor,
|
||||||
|
errorsPerResource
|
||||||
|
);
|
||||||
|
const error = rangesPerResource
|
||||||
|
.map((range, index) => ({ error: errorsPerResource[index], range }))
|
||||||
|
.map(({ error, range }) => {
|
||||||
|
if (range) {
|
||||||
|
const priority = calculatePriority(range, monacoSelection);
|
||||||
|
if (priority) {
|
||||||
|
return { ...priority, error };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
})
|
||||||
|
.filter(notEmpty)
|
||||||
|
.sort((left, right) => right.score - left.score) // highest first
|
||||||
|
.map(({ error }) => error)
|
||||||
|
.shift();
|
||||||
|
if (error) {
|
||||||
|
this.markAsCurrentError(error);
|
||||||
|
} else {
|
||||||
|
console.info(
|
||||||
|
'compiler-errors',
|
||||||
|
`New (monaco) selection ${monacoSelection.toJSON()} does not intersect any error locations. Skipping.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This code does not deal with resource deletion, but tracks editor dispose events. It does not matter what was the cause of the editor disposal.
|
||||||
|
* If editor closes, delete the decorators.
|
||||||
|
*/
|
||||||
|
private handleEditorDidDispose(uri: string): void {
|
||||||
|
let i = this.errors.length;
|
||||||
|
// `splice` re-indexes the array. It's better to "iterate and modify" from the last element.
|
||||||
|
while (i--) {
|
||||||
|
const error = this.errors[i];
|
||||||
|
if (error.uri === uri) {
|
||||||
|
this.errors.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.onDidChangeEmitter.fire(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the text document changes in the line where compiler errors are, the compiler errors will be removed.
|
||||||
|
*/
|
||||||
|
private handleDocumentContentChange(
|
||||||
|
monacoEditor: MonacoEditor,
|
||||||
|
event: TextDocumentChangeEvent
|
||||||
|
): void {
|
||||||
|
const errorsPerResource = this.errors.filter(
|
||||||
|
(error) => error.uri === event.document.uri
|
||||||
|
);
|
||||||
|
let editorOrModel: MonacoEditor | ITextModel = monacoEditor;
|
||||||
|
const doc = event.document;
|
||||||
|
if (doc instanceof MonacoEditorModel) {
|
||||||
|
editorOrModel = doc.textEditorModel;
|
||||||
|
}
|
||||||
|
const rangesPerResource = ErrorDecoration.rangeOf(
|
||||||
|
editorOrModel,
|
||||||
|
errorsPerResource
|
||||||
|
);
|
||||||
|
const resolvedDecorations = rangesPerResource.map((range, index) => ({
|
||||||
|
error: errorsPerResource[index],
|
||||||
|
range,
|
||||||
|
}));
|
||||||
|
const decoratorsToRemove = event.contentChanges
|
||||||
|
.map(({ range }) => this.p2m.asRange(range))
|
||||||
|
.map((changedRange) =>
|
||||||
|
resolvedDecorations
|
||||||
|
.filter(({ range: decorationRange }) => {
|
||||||
|
if (!decorationRange) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const affects =
|
||||||
|
changedRange.startLineNumber <= decorationRange.startLineNumber &&
|
||||||
|
changedRange.endLineNumber >= decorationRange.endLineNumber;
|
||||||
|
console.log(
|
||||||
|
'compiler-errors',
|
||||||
|
`decoration range: ${decorationRange.toString()}, change range: ${changedRange.toString()}, affects: ${affects}`
|
||||||
|
);
|
||||||
|
return affects;
|
||||||
|
})
|
||||||
|
.map(({ error }) => {
|
||||||
|
const index = this.errors.findIndex((candidate) =>
|
||||||
|
ErrorDecorationRef.sameAs(candidate, error)
|
||||||
|
);
|
||||||
|
return index !== -1 ? { error, index } : undefined;
|
||||||
|
})
|
||||||
|
.filter(notEmpty)
|
||||||
|
)
|
||||||
|
.reduce((acc, curr) => acc.concat(curr), [])
|
||||||
|
.sort((left, right) => left.index - right.index); // highest index last
|
||||||
|
|
||||||
|
if (decoratorsToRemove.length) {
|
||||||
|
let i = decoratorsToRemove.length;
|
||||||
|
while (i--) {
|
||||||
|
this.errors.splice(decoratorsToRemove[i].index, 1);
|
||||||
|
}
|
||||||
|
monacoEditor.getControl().deltaDecorations(
|
||||||
|
decoratorsToRemove.map(({ error }) => error.id),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
this.onDidChangeEmitter.fire(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async trackEditors(
|
||||||
|
errors: Map<string, CoreError.ErrorLocation[]>,
|
||||||
|
...track: ((editor: MonacoEditor) => Disposable)[]
|
||||||
|
): Promise<Disposable> {
|
||||||
|
return new DisposableCollection(
|
||||||
|
...(await Promise.all(
|
||||||
|
Array.from(errors.keys()).map(async (uri) => {
|
||||||
|
const editor = await this.monacoEditor(uri);
|
||||||
|
if (!editor) {
|
||||||
|
return Disposable.NULL;
|
||||||
|
}
|
||||||
|
return new DisposableCollection(...track.map((t) => t(editor)));
|
||||||
|
})
|
||||||
|
))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async markAsCurrentError(
|
||||||
|
ref: ErrorDecorationRef,
|
||||||
|
options?: { forceReselect?: boolean; reveal?: boolean }
|
||||||
|
): Promise<void> {
|
||||||
|
const index = this.errors.findIndex((candidate) =>
|
||||||
|
ErrorDecorationRef.sameAs(candidate, ref)
|
||||||
|
);
|
||||||
|
if (index < 0) {
|
||||||
|
console.warn(
|
||||||
|
'compiler-errors',
|
||||||
|
`Failed to mark error ${
|
||||||
|
ref.id
|
||||||
|
} as the current one. Error is unknown. Known errors are: ${this.errors.map(
|
||||||
|
({ id }) => id
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const newError = this.errors[index];
|
||||||
|
if (
|
||||||
|
options?.forceReselect ||
|
||||||
|
!this.currentError ||
|
||||||
|
!ErrorDecorationRef.sameAs(this.currentError, newError)
|
||||||
|
) {
|
||||||
|
this.currentError = this.errors[index];
|
||||||
|
console.log(
|
||||||
|
'compiler-errors',
|
||||||
|
`Current error changed to ${this.currentError.id}`
|
||||||
|
);
|
||||||
|
if (options?.reveal) {
|
||||||
|
this.currentErrorDidChangEmitter.fire(this.currentError);
|
||||||
|
}
|
||||||
|
this.onDidChangeEmitter.fire(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The double editor activation logic is required: https://github.com/eclipse-theia/theia/issues/11284
|
||||||
|
private async revealLocationInEditor(
|
||||||
|
location: Location
|
||||||
|
): Promise<EditorWidget | undefined> {
|
||||||
|
const { uri, range } = location;
|
||||||
|
const editor = await this.editorManager.getByUri(new URI(uri), {
|
||||||
|
mode: 'activate',
|
||||||
|
});
|
||||||
|
if (editor && this.shell) {
|
||||||
|
// to avoid flickering, reveal the range here and not with `getByUri`, because it uses `at: 'center'` for the reveal option.
|
||||||
|
// TODO: check the community reaction whether it is better to set the focus at the error marker. it might cause flickering even if errors are close to each other
|
||||||
|
editor.editor.revealRange(range, { at: this.revealStrategy });
|
||||||
|
const activeWidget = await this.shell.activateWidget(editor.id);
|
||||||
|
if (!activeWidget) {
|
||||||
|
console.warn(
|
||||||
|
'compiler-errors',
|
||||||
|
`editor widget activation has failed. editor widget ${editor.id} expected to be the active one.`
|
||||||
|
);
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
if (editor !== activeWidget) {
|
||||||
|
console.warn(
|
||||||
|
'compiler-errors',
|
||||||
|
`active widget was not the same as previously activated editor. editor widget ID ${editor.id}, active widget ID: ${activeWidget.id}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
console.warn(
|
||||||
|
'compiler-errors',
|
||||||
|
`could not find editor widget for URI: ${uri}`
|
||||||
|
);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
private groupBy<K, V>(
|
||||||
|
elements: V[],
|
||||||
|
extractKey: (element: V) => K
|
||||||
|
): Map<K, V[]> {
|
||||||
|
return elements.reduce((acc, curr) => {
|
||||||
|
const key = extractKey(curr);
|
||||||
|
let values = acc.get(key);
|
||||||
|
if (!values) {
|
||||||
|
values = [];
|
||||||
|
acc.set(key, values);
|
||||||
|
}
|
||||||
|
values.push(curr);
|
||||||
|
return acc;
|
||||||
|
}, new Map<K, V[]>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private monacoEditor(widget: EditorWidget): MonacoEditor | undefined;
|
||||||
|
private monacoEditor(
|
||||||
|
uri: string | monaco.Uri
|
||||||
|
): Promise<MonacoEditor | undefined>;
|
||||||
|
private monacoEditor(
|
||||||
|
uriOrWidget: string | monaco.Uri | EditorWidget
|
||||||
|
): MaybePromise<MonacoEditor | undefined> {
|
||||||
|
if (uriOrWidget instanceof EditorWidget) {
|
||||||
|
const editor = uriOrWidget.editor;
|
||||||
|
if (editor instanceof MonacoEditor) {
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
} else {
|
||||||
|
return this.editorManager
|
||||||
|
.getByUri(new URI(uriOrWidget.toString()))
|
||||||
|
.then((editor) => {
|
||||||
|
if (editor) {
|
||||||
|
return this.monacoEditor(editor);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export namespace CompilerErrors {
|
||||||
|
export namespace Commands {
|
||||||
|
export const NEXT_ERROR: Command = {
|
||||||
|
id: 'arduino-editor-next-error',
|
||||||
|
};
|
||||||
|
export const PREVIOUS_ERROR: Command = {
|
||||||
|
id: 'arduino-editor-previous-error',
|
||||||
|
};
|
||||||
|
export const MARK_AS_CURRENT: Command = {
|
||||||
|
id: 'arduino-editor-mark-as-current-error',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,56 +1,87 @@
|
|||||||
import { inject, injectable, interfaces } from 'inversify';
|
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
|
||||||
import URI from '@theia/core/lib/common/uri';
|
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
|
||||||
import { ILogger } from '@theia/core/lib/common/logger';
|
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution';
|
||||||
import { Saveable } from '@theia/core/lib/browser/saveable';
|
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
||||||
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
||||||
import { MaybePromise } from '@theia/core/lib/common/types';
|
|
||||||
import { LabelProvider } from '@theia/core/lib/browser/label-provider';
|
|
||||||
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
|
||||||
import { MessageService } from '@theia/core/lib/common/message-service';
|
|
||||||
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
|
|
||||||
import { open, OpenerService } from '@theia/core/lib/browser/opener-service';
|
|
||||||
import { OutputChannelManager } from '@theia/output/lib/browser/output-channel';
|
|
||||||
import {
|
import {
|
||||||
MenuModelRegistry,
|
|
||||||
MenuContribution,
|
|
||||||
} from '@theia/core/lib/common/menu';
|
|
||||||
import {
|
|
||||||
KeybindingRegistry,
|
|
||||||
KeybindingContribution,
|
KeybindingContribution,
|
||||||
|
KeybindingRegistry,
|
||||||
} from '@theia/core/lib/browser/keybinding';
|
} from '@theia/core/lib/browser/keybinding';
|
||||||
|
import { LabelProvider } from '@theia/core/lib/browser/label-provider';
|
||||||
|
import { OpenerService, open } from '@theia/core/lib/browser/opener-service';
|
||||||
|
import { Saveable } from '@theia/core/lib/browser/saveable';
|
||||||
|
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
|
||||||
import {
|
import {
|
||||||
TabBarToolbarContribution,
|
TabBarToolbarContribution,
|
||||||
TabBarToolbarRegistry,
|
TabBarToolbarRegistry,
|
||||||
} from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
} from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
||||||
import {
|
import { CancellationToken } from '@theia/core/lib/common/cancellation';
|
||||||
FrontendApplicationContribution,
|
|
||||||
FrontendApplication,
|
|
||||||
} from '@theia/core/lib/browser/frontend-application';
|
|
||||||
import {
|
import {
|
||||||
Command,
|
Command,
|
||||||
CommandRegistry,
|
|
||||||
CommandContribution,
|
CommandContribution,
|
||||||
|
CommandRegistry,
|
||||||
CommandService,
|
CommandService,
|
||||||
} from '@theia/core/lib/common/command';
|
} from '@theia/core/lib/common/command';
|
||||||
import { EditorMode } from '../editor-mode';
|
|
||||||
import { SettingsService } from '../dialogs/settings/settings';
|
|
||||||
import { SketchesServiceClientImpl } from '../../common/protocol/sketches-service-client-impl';
|
|
||||||
import {
|
import {
|
||||||
SketchesService,
|
Disposable,
|
||||||
ConfigService,
|
DisposableCollection,
|
||||||
|
} from '@theia/core/lib/common/disposable';
|
||||||
|
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
|
||||||
|
import { ILogger } from '@theia/core/lib/common/logger';
|
||||||
|
import {
|
||||||
|
MenuContribution,
|
||||||
|
MenuModelRegistry,
|
||||||
|
} from '@theia/core/lib/common/menu';
|
||||||
|
import { MessageService } from '@theia/core/lib/common/message-service';
|
||||||
|
import { MessageType } from '@theia/core/lib/common/message-service-protocol';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { MaybePromise, isObject } from '@theia/core/lib/common/types';
|
||||||
|
import URI from '@theia/core/lib/common/uri';
|
||||||
|
import {
|
||||||
|
inject,
|
||||||
|
injectable,
|
||||||
|
interfaces,
|
||||||
|
postConstruct,
|
||||||
|
} from '@theia/core/shared/inversify';
|
||||||
|
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
||||||
|
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
||||||
|
import { NotificationManager } from '@theia/messages/lib/browser/notifications-manager';
|
||||||
|
import { OutputChannelSeverity } from '@theia/output/lib/browser/output-channel';
|
||||||
|
import { MainMenuManager } from '../../common/main-menu-manager';
|
||||||
|
import { userAbort } from '../../common/nls';
|
||||||
|
import {
|
||||||
|
CoreError,
|
||||||
|
CoreService,
|
||||||
FileSystemExt,
|
FileSystemExt,
|
||||||
|
ResponseServiceClient,
|
||||||
Sketch,
|
Sketch,
|
||||||
|
SketchesService,
|
||||||
} from '../../common/protocol';
|
} from '../../common/protocol';
|
||||||
|
import {
|
||||||
|
ExecuteWithProgress,
|
||||||
|
UserAbortApplicationError,
|
||||||
|
} from '../../common/protocol/progressible';
|
||||||
import { ArduinoPreferences } from '../arduino-preferences';
|
import { ArduinoPreferences } from '../arduino-preferences';
|
||||||
|
import { BoardsDataStore } from '../boards/boards-data-store';
|
||||||
|
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
||||||
|
import { ConfigServiceClient } from '../config/config-service-client';
|
||||||
|
import { DialogService } from '../dialog-service';
|
||||||
|
import { SettingsService } from '../dialogs/settings/settings';
|
||||||
|
import {
|
||||||
|
CurrentSketch,
|
||||||
|
SketchesServiceClientImpl,
|
||||||
|
} from '../sketches-service-client-impl';
|
||||||
|
import { ApplicationConnectionStatusContribution } from '../theia/core/connection-status-service';
|
||||||
|
import { OutputChannelManager } from '../theia/output/output-channel';
|
||||||
|
import { WorkspaceService } from '../theia/workspace/workspace-service';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
Command,
|
Command,
|
||||||
CommandRegistry,
|
CommandRegistry,
|
||||||
MenuModelRegistry,
|
|
||||||
KeybindingRegistry,
|
KeybindingRegistry,
|
||||||
|
MenuModelRegistry,
|
||||||
|
Sketch,
|
||||||
TabBarToolbarRegistry,
|
TabBarToolbarRegistry,
|
||||||
URI,
|
URI,
|
||||||
Sketch,
|
|
||||||
open,
|
open,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -75,24 +106,46 @@ export abstract class Contribution
|
|||||||
@inject(WorkspaceService)
|
@inject(WorkspaceService)
|
||||||
protected readonly workspaceService: WorkspaceService;
|
protected readonly workspaceService: WorkspaceService;
|
||||||
|
|
||||||
@inject(EditorMode)
|
|
||||||
protected readonly editorMode: EditorMode;
|
|
||||||
|
|
||||||
@inject(LabelProvider)
|
@inject(LabelProvider)
|
||||||
protected readonly labelProvider: LabelProvider;
|
protected readonly labelProvider: LabelProvider;
|
||||||
|
|
||||||
@inject(SettingsService)
|
@inject(SettingsService)
|
||||||
protected readonly settingsService: SettingsService;
|
protected readonly settingsService: SettingsService;
|
||||||
|
|
||||||
|
@inject(ArduinoPreferences)
|
||||||
|
protected readonly preferences: ArduinoPreferences;
|
||||||
|
|
||||||
|
@inject(FrontendApplicationStateService)
|
||||||
|
protected readonly appStateService: FrontendApplicationStateService;
|
||||||
|
|
||||||
|
@inject(MainMenuManager)
|
||||||
|
protected readonly menuManager: MainMenuManager;
|
||||||
|
|
||||||
|
@inject(DialogService)
|
||||||
|
protected readonly dialogService: DialogService;
|
||||||
|
|
||||||
|
@postConstruct()
|
||||||
|
protected init(): void {
|
||||||
|
this.appStateService.reachedState('ready').then(() => this.onReady());
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function, unused-imports/no-unused-vars
|
||||||
onStart(app: FrontendApplication): MaybePromise<void> {}
|
onStart(app: FrontendApplication): MaybePromise<void> {}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function, unused-imports/no-unused-vars
|
||||||
registerCommands(registry: CommandRegistry): void {}
|
registerCommands(registry: CommandRegistry): void {}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function, unused-imports/no-unused-vars
|
||||||
registerMenus(registry: MenuModelRegistry): void {}
|
registerMenus(registry: MenuModelRegistry): void {}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function, unused-imports/no-unused-vars
|
||||||
registerKeybindings(registry: KeybindingRegistry): void {}
|
registerKeybindings(registry: KeybindingRegistry): void {}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function, unused-imports/no-unused-vars
|
||||||
registerToolbarItems(registry: TabBarToolbarRegistry): void {}
|
registerToolbarItems(registry: TabBarToolbarRegistry): void {}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||||
|
onReady(): MaybePromise<void> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
@@ -103,11 +156,11 @@ export abstract class SketchContribution extends Contribution {
|
|||||||
@inject(FileSystemExt)
|
@inject(FileSystemExt)
|
||||||
protected readonly fileSystemExt: FileSystemExt;
|
protected readonly fileSystemExt: FileSystemExt;
|
||||||
|
|
||||||
@inject(ConfigService)
|
@inject(ConfigServiceClient)
|
||||||
protected readonly configService: ConfigService;
|
protected readonly configService: ConfigServiceClient;
|
||||||
|
|
||||||
@inject(SketchesService)
|
@inject(SketchesService)
|
||||||
protected readonly sketchService: SketchesService;
|
protected readonly sketchesService: SketchesService;
|
||||||
|
|
||||||
@inject(OpenerService)
|
@inject(OpenerService)
|
||||||
protected readonly openerService: OpenerService;
|
protected readonly openerService: OpenerService;
|
||||||
@@ -115,19 +168,22 @@ export abstract class SketchContribution extends Contribution {
|
|||||||
@inject(SketchesServiceClientImpl)
|
@inject(SketchesServiceClientImpl)
|
||||||
protected readonly sketchServiceClient: SketchesServiceClientImpl;
|
protected readonly sketchServiceClient: SketchesServiceClientImpl;
|
||||||
|
|
||||||
@inject(ArduinoPreferences)
|
|
||||||
protected readonly preferences: ArduinoPreferences;
|
|
||||||
|
|
||||||
@inject(EditorManager)
|
@inject(EditorManager)
|
||||||
protected readonly editorManager: EditorManager;
|
protected readonly editorManager: EditorManager;
|
||||||
|
|
||||||
@inject(OutputChannelManager)
|
@inject(OutputChannelManager)
|
||||||
protected readonly outputChannelManager: OutputChannelManager;
|
protected readonly outputChannelManager: OutputChannelManager;
|
||||||
|
|
||||||
|
@inject(EnvVariablesServer)
|
||||||
|
protected readonly envVariableServer: EnvVariablesServer;
|
||||||
|
|
||||||
|
@inject(ApplicationConnectionStatusContribution)
|
||||||
|
protected readonly connectionStatusService: ApplicationConnectionStatusContribution;
|
||||||
|
|
||||||
protected async sourceOverride(): Promise<Record<string, string>> {
|
protected async sourceOverride(): Promise<Record<string, string>> {
|
||||||
const override: Record<string, string> = {};
|
const override: Record<string, string> = {};
|
||||||
const sketch = await this.sketchServiceClient.currentSketch();
|
const sketch = await this.sketchServiceClient.currentSketch();
|
||||||
if (sketch) {
|
if (CurrentSketch.isValid(sketch)) {
|
||||||
for (const editor of this.editorManager.all) {
|
for (const editor of this.editorManager.all) {
|
||||||
const uri = editor.editor.uri;
|
const uri = editor.editor.uri;
|
||||||
if (Saveable.isDirty(editor) && Sketch.isInSketch(uri, sketch)) {
|
if (Saveable.isDirty(editor) && Sketch.isInSketch(uri, sketch)) {
|
||||||
@@ -137,10 +193,169 @@ export abstract class SketchContribution extends Contribution {
|
|||||||
}
|
}
|
||||||
return override;
|
return override;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defaults to `directories.user` if defined and not CLI config errors were detected.
|
||||||
|
* Otherwise, the URI of the user home directory.
|
||||||
|
*/
|
||||||
|
protected async defaultUri(): Promise<URI> {
|
||||||
|
const errors = this.configService.tryGetMessages();
|
||||||
|
let defaultUri = this.configService.tryGetSketchDirUri();
|
||||||
|
if (!defaultUri || errors?.length) {
|
||||||
|
// Fall back to user home when the `directories.user` is not available or there are known CLI config errors
|
||||||
|
defaultUri = new URI(await this.envVariableServer.getHomeDirUri());
|
||||||
|
}
|
||||||
|
return defaultUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async defaultPath(): Promise<string> {
|
||||||
|
const defaultUri = await this.defaultUri();
|
||||||
|
return this.fileService.fsPath(defaultUri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export abstract class CoreServiceContribution extends SketchContribution {
|
||||||
|
@inject(BoardsDataStore)
|
||||||
|
protected readonly boardsDataStore: BoardsDataStore;
|
||||||
|
|
||||||
|
@inject(BoardsServiceProvider)
|
||||||
|
protected readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
|
||||||
|
@inject(CoreService)
|
||||||
|
private readonly coreService: CoreService;
|
||||||
|
|
||||||
|
@inject(ClipboardService)
|
||||||
|
private readonly clipboardService: ClipboardService;
|
||||||
|
|
||||||
|
@inject(ResponseServiceClient)
|
||||||
|
private readonly responseService: ResponseServiceClient;
|
||||||
|
|
||||||
|
@inject(NotificationManager)
|
||||||
|
private readonly notificationManager: NotificationManager;
|
||||||
|
|
||||||
|
@inject(ApplicationShell)
|
||||||
|
private readonly shell: ApplicationShell;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the internal (Theia) ID of the notification that is currently visible.
|
||||||
|
* It's stored here as a field to be able to close it before executing any new core command (such as verify, upload, etc.)
|
||||||
|
*/
|
||||||
|
private visibleNotificationId: string | undefined;
|
||||||
|
|
||||||
|
protected clearVisibleNotification(): void {
|
||||||
|
if (this.visibleNotificationId) {
|
||||||
|
this.notificationManager.clear(this.visibleNotificationId);
|
||||||
|
this.visibleNotificationId = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected handleError(error: unknown): void {
|
||||||
|
if (isObject(error) && UserAbortApplicationError.is(error)) {
|
||||||
|
this.outputChannelManager
|
||||||
|
.getChannel('Arduino')
|
||||||
|
.appendLine(userAbort, OutputChannelSeverity.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.tryToastErrorMessage(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
private tryToastErrorMessage(error: unknown): void {
|
||||||
|
let message: undefined | string = undefined;
|
||||||
|
if (CoreError.is(error)) {
|
||||||
|
message = error.message;
|
||||||
|
} else if (error instanceof Error) {
|
||||||
|
message = error.message;
|
||||||
|
} else if (typeof error === 'string') {
|
||||||
|
message = error;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
message = JSON.stringify(error);
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
if (message) {
|
||||||
|
if (message.includes('Missing FQBN (Fully Qualified Board Name)')) {
|
||||||
|
message = nls.localize(
|
||||||
|
'arduino/coreContribution/noBoardSelected',
|
||||||
|
'No board selected. Please select your Arduino board from the Tools > Board menu.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const copyAction = nls.localize(
|
||||||
|
'arduino/coreContribution/copyError',
|
||||||
|
'Copy error messages'
|
||||||
|
);
|
||||||
|
this.visibleNotificationId = this.notificationId(message, copyAction);
|
||||||
|
this.messageService.error(message, copyAction).then(async (action) => {
|
||||||
|
if (action === copyAction) {
|
||||||
|
const content = await this.outputChannelManager.contentOfChannel(
|
||||||
|
'Arduino'
|
||||||
|
);
|
||||||
|
if (content) {
|
||||||
|
this.clipboardService.writeText(content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async doWithProgress<T>(options: {
|
||||||
|
progressText: string;
|
||||||
|
keepOutput?: boolean;
|
||||||
|
task: (
|
||||||
|
progressId: string,
|
||||||
|
coreService: CoreService,
|
||||||
|
cancellationToken?: CancellationToken
|
||||||
|
) => Promise<T>;
|
||||||
|
// false by default
|
||||||
|
cancelable?: boolean;
|
||||||
|
}): Promise<T> {
|
||||||
|
const toDisposeOnComplete = new DisposableCollection(
|
||||||
|
this.maybeActivateMonitorWidget()
|
||||||
|
);
|
||||||
|
const { progressText, keepOutput, task } = options;
|
||||||
|
this.outputChannelManager
|
||||||
|
.getChannel('Arduino')
|
||||||
|
.show({ preserveFocus: true });
|
||||||
|
const result = await ExecuteWithProgress.doWithProgress({
|
||||||
|
messageService: this.messageService,
|
||||||
|
responseService: this.responseService,
|
||||||
|
progressText,
|
||||||
|
run: ({ progressId, cancellationToken }) =>
|
||||||
|
task(progressId, this.coreService, cancellationToken),
|
||||||
|
keepOutput,
|
||||||
|
cancelable: options.cancelable,
|
||||||
|
});
|
||||||
|
toDisposeOnComplete.dispose();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: cleanup!
|
||||||
|
// this dependency does not belong here
|
||||||
|
// support core command contribution handlers, the monitor-widget should implement it and register itself as a handler
|
||||||
|
// the monitor widget should reveal itself after a successful core command execution
|
||||||
|
private maybeActivateMonitorWidget(): Disposable {
|
||||||
|
const currentWidget = this.shell.bottomPanel.currentTitle?.owner;
|
||||||
|
if (currentWidget?.id === 'serial-monitor') {
|
||||||
|
return Disposable.create(() =>
|
||||||
|
this.shell.bottomPanel.activateWidget(currentWidget)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Disposable.NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
private notificationId(message: string, ...actions: string[]): string {
|
||||||
|
return this.notificationManager['getMessageId']({
|
||||||
|
text: message,
|
||||||
|
actions,
|
||||||
|
type: MessageType.Error,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace Contribution {
|
export namespace Contribution {
|
||||||
export function configure<T>(
|
export function configure(
|
||||||
bind: interfaces.Bind,
|
bind: interfaces.Bind,
|
||||||
serviceIdentifier: typeof Contribution
|
serviceIdentifier: typeof Contribution
|
||||||
): void {
|
): void {
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { Emitter, Event } from '@theia/core';
|
||||||
|
import { injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { CoreError } from '../../common/protocol/core-service';
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class CoreErrorHandler {
|
||||||
|
private readonly errors: CoreError.ErrorLocation[] = [];
|
||||||
|
private readonly compilerErrorsDidChangeEmitter = new Emitter<
|
||||||
|
CoreError.ErrorLocation[]
|
||||||
|
>();
|
||||||
|
|
||||||
|
tryHandle(error: unknown): void {
|
||||||
|
if (CoreError.is(error)) {
|
||||||
|
this.errors.length = 0;
|
||||||
|
this.errors.push(...error.data);
|
||||||
|
this.fireCompilerErrorsDidChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reset(): void {
|
||||||
|
this.errors.length = 0;
|
||||||
|
this.fireCompilerErrorsDidChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
get onCompilerErrorsDidChange(): Event<CoreError.ErrorLocation[]> {
|
||||||
|
return this.compilerErrorsDidChangeEmitter.event;
|
||||||
|
}
|
||||||
|
|
||||||
|
private fireCompilerErrorsDidChange(): void {
|
||||||
|
this.compilerErrorsDidChangeEmitter.fire(this.errors.slice());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
|
||||||
|
import { ApplicationShell } from '@theia/core/lib/browser/shell';
|
||||||
|
import type { Command, CommandRegistry } from '@theia/core/lib/common/command';
|
||||||
|
import { Progress } from '@theia/core/lib/common/message-service-protocol';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { Create } from '../create/typings';
|
||||||
|
import { ApplicationConnectionStatusContribution } from '../theia/core/connection-status-service';
|
||||||
|
import { CloudSketchbookTree } from '../widgets/cloud-sketchbook/cloud-sketchbook-tree';
|
||||||
|
import { SketchbookTree } from '../widgets/sketchbook/sketchbook-tree';
|
||||||
|
import { SketchbookTreeModel } from '../widgets/sketchbook/sketchbook-tree-model';
|
||||||
|
import { CloudSketchContribution, pushingSketch } from './cloud-contribution';
|
||||||
|
import {
|
||||||
|
CreateNewCloudSketchCallback,
|
||||||
|
NewCloudSketch,
|
||||||
|
NewCloudSketchParams,
|
||||||
|
} from './new-cloud-sketch';
|
||||||
|
import { saveOntoCopiedSketch } from './save-as-sketch';
|
||||||
|
|
||||||
|
interface CreateCloudCopyParams {
|
||||||
|
readonly model: SketchbookTreeModel;
|
||||||
|
readonly node: SketchbookTree.SketchDirNode;
|
||||||
|
}
|
||||||
|
function isCreateCloudCopyParams(arg: unknown): arg is CreateCloudCopyParams {
|
||||||
|
return (
|
||||||
|
typeof arg === 'object' &&
|
||||||
|
(<CreateCloudCopyParams>arg).model !== undefined &&
|
||||||
|
(<CreateCloudCopyParams>arg).model instanceof SketchbookTreeModel &&
|
||||||
|
(<CreateCloudCopyParams>arg).node !== undefined &&
|
||||||
|
SketchbookTree.SketchDirNode.is((<CreateCloudCopyParams>arg).node)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class CreateCloudCopy extends CloudSketchContribution {
|
||||||
|
@inject(ApplicationConnectionStatusContribution)
|
||||||
|
private readonly connectionStatus: ApplicationConnectionStatusContribution;
|
||||||
|
|
||||||
|
private shell: ApplicationShell;
|
||||||
|
|
||||||
|
override onStart(app: FrontendApplication): void {
|
||||||
|
this.shell = app.shell;
|
||||||
|
}
|
||||||
|
|
||||||
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
|
registry.registerCommand(CreateCloudCopy.Commands.CREATE_CLOUD_COPY, {
|
||||||
|
execute: (args: CreateCloudCopyParams) => this.createCloudCopy(args),
|
||||||
|
isEnabled: (args: unknown) =>
|
||||||
|
Boolean(this.createFeatures.session) && isCreateCloudCopyParams(args),
|
||||||
|
isVisible: (args: unknown) =>
|
||||||
|
Boolean(this.createFeatures.enabled) &&
|
||||||
|
Boolean(this.createFeatures.session) &&
|
||||||
|
this.connectionStatus.offlineStatus !== 'internet' &&
|
||||||
|
isCreateCloudCopyParams(args),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* - creates new cloud sketch with the name of the params sketch,
|
||||||
|
* - pulls the cloud sketch,
|
||||||
|
* - copies files from params sketch to pulled cloud sketch in the cache folder,
|
||||||
|
* - pushes the cloud sketch, and
|
||||||
|
* - opens in new window.
|
||||||
|
*/
|
||||||
|
private async createCloudCopy(params: CreateCloudCopyParams): Promise<void> {
|
||||||
|
const sketch = await this.sketchesService.loadSketch(
|
||||||
|
params.node.fileStat.resource.toString()
|
||||||
|
);
|
||||||
|
const callback: CreateNewCloudSketchCallback = async (
|
||||||
|
newSketch: Create.Sketch,
|
||||||
|
newNode: CloudSketchbookTree.CloudSketchDirNode,
|
||||||
|
progress: Progress
|
||||||
|
) => {
|
||||||
|
const treeModel = await this.treeModel();
|
||||||
|
if (!treeModel) {
|
||||||
|
throw new Error('Could not retrieve the cloud sketchbook tree model.');
|
||||||
|
}
|
||||||
|
|
||||||
|
progress.report({
|
||||||
|
message: nls.localize(
|
||||||
|
'arduino/createCloudCopy/copyingSketchFilesMessage',
|
||||||
|
'Copying local sketch files...'
|
||||||
|
),
|
||||||
|
});
|
||||||
|
const localCacheFolderUri = newNode.uri.toString();
|
||||||
|
await this.sketchesService.copy(sketch, {
|
||||||
|
destinationUri: localCacheFolderUri,
|
||||||
|
onlySketchFiles: true,
|
||||||
|
});
|
||||||
|
await saveOntoCopiedSketch(
|
||||||
|
sketch,
|
||||||
|
localCacheFolderUri,
|
||||||
|
this.shell,
|
||||||
|
this.editorManager
|
||||||
|
);
|
||||||
|
|
||||||
|
progress.report({ message: pushingSketch(newSketch.name) });
|
||||||
|
await treeModel.sketchbookTree().push(newNode, true, true);
|
||||||
|
};
|
||||||
|
return this.commandService.executeCommand(
|
||||||
|
NewCloudSketch.Commands.NEW_CLOUD_SKETCH.id,
|
||||||
|
<NewCloudSketchParams>{
|
||||||
|
initialValue: params.node.fileStat.name,
|
||||||
|
callback,
|
||||||
|
skipShowErrorMessageOnOpen: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace CreateCloudCopy {
|
||||||
|
export namespace Commands {
|
||||||
|
export const CREATE_CLOUD_COPY: Command = {
|
||||||
|
id: 'arduino-create-cloud-copy',
|
||||||
|
iconClass: 'fa fa-arduino-cloud-upload',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
41
arduino-ide-extension/src/browser/contributions/daemon.ts
Normal file
41
arduino-ide-extension/src/browser/contributions/daemon.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { nls } from '@theia/core';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { ArduinoDaemon } from '../../common/protocol';
|
||||||
|
import { Contribution, Command, CommandRegistry } from './contribution';
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class Daemon extends Contribution {
|
||||||
|
@inject(ArduinoDaemon)
|
||||||
|
private readonly daemon: ArduinoDaemon;
|
||||||
|
|
||||||
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
|
registry.registerCommand(Daemon.Commands.START_DAEMON, {
|
||||||
|
execute: () => this.daemon.start(),
|
||||||
|
});
|
||||||
|
registry.registerCommand(Daemon.Commands.STOP_DAEMON, {
|
||||||
|
execute: () => this.daemon.stop(),
|
||||||
|
});
|
||||||
|
registry.registerCommand(Daemon.Commands.RESTART_DAEMON, {
|
||||||
|
execute: () => this.daemon.restart(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export namespace Daemon {
|
||||||
|
export namespace Commands {
|
||||||
|
export const START_DAEMON: Command = {
|
||||||
|
id: 'arduino-start-daemon',
|
||||||
|
label: nls.localize('arduino/daemon/start', 'Start Daemon'),
|
||||||
|
category: 'Arduino',
|
||||||
|
};
|
||||||
|
export const STOP_DAEMON: Command = {
|
||||||
|
id: 'arduino-stop-daemon',
|
||||||
|
label: nls.localize('arduino/daemon/stop', 'Stop Daemon'),
|
||||||
|
category: 'Arduino',
|
||||||
|
};
|
||||||
|
export const RESTART_DAEMON: Command = {
|
||||||
|
id: 'arduino-restart-daemon',
|
||||||
|
label: nls.localize('arduino/daemon/restart', 'Restart Daemon'),
|
||||||
|
category: 'Arduino',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,185 +1,347 @@
|
|||||||
import { inject, injectable } from 'inversify';
|
import { Emitter, Event } from '@theia/core/lib/common/event';
|
||||||
import { Event, Emitter } from '@theia/core/lib/common/event';
|
import { MenuModelRegistry } from '@theia/core/lib/common/menu/menu-model-registry';
|
||||||
import { HostedPluginSupport } from '@theia/plugin-ext/lib/hosted/browser/hosted-plugin';
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
import { ArduinoToolbar } from '../toolbar/arduino-toolbar';
|
import { MaybePromise } from '@theia/core/lib/common/types';
|
||||||
import { NotificationCenter } from '../notification-center';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { Board, BoardsService, ExecutableService } from '../../common/protocol';
|
import { noBoardSelected } from '../../common/nls';
|
||||||
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
import {
|
||||||
|
BoardDetails,
|
||||||
|
BoardIdentifier,
|
||||||
|
BoardsService,
|
||||||
|
CheckDebugEnabledParams,
|
||||||
|
ExecutableService,
|
||||||
|
SketchRef,
|
||||||
|
isBoardIdentifierChangeEvent,
|
||||||
|
isCompileSummary,
|
||||||
|
} from '../../common/protocol';
|
||||||
|
import { BoardsDataStore } from '../boards/boards-data-store';
|
||||||
|
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
||||||
|
import { HostedPluginSupport } from '../hosted/hosted-plugin-support';
|
||||||
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
|
import { NotificationCenter } from '../notification-center';
|
||||||
|
import { CurrentSketch } from '../sketches-service-client-impl';
|
||||||
|
import { ArduinoToolbar } from '../toolbar/arduino-toolbar';
|
||||||
import {
|
import {
|
||||||
URI,
|
|
||||||
Command,
|
Command,
|
||||||
CommandRegistry,
|
CommandRegistry,
|
||||||
SketchContribution,
|
SketchContribution,
|
||||||
TabBarToolbarRegistry,
|
TabBarToolbarRegistry,
|
||||||
|
URI,
|
||||||
} from './contribution';
|
} from './contribution';
|
||||||
import { nls } from '@theia/core/lib/common';
|
|
||||||
|
const COMPILE_FOR_DEBUG_KEY = 'arduino-compile-for-debug';
|
||||||
|
|
||||||
|
interface StartDebugParams {
|
||||||
|
/**
|
||||||
|
* Absolute filesystem path to the Arduino CLI executable.
|
||||||
|
*/
|
||||||
|
readonly cliPath: string;
|
||||||
|
/**
|
||||||
|
* The the board to debug.
|
||||||
|
*/
|
||||||
|
readonly board: Readonly<{ fqbn: string; name?: string }>;
|
||||||
|
/**
|
||||||
|
* Absolute filesystem path of the sketch to debug.
|
||||||
|
*/
|
||||||
|
readonly sketchPath: string;
|
||||||
|
/**
|
||||||
|
* Location where the `launch.json` will be created on the fly before starting every debug session.
|
||||||
|
* If not defined, it falls back to `sketchPath/.vscode/launch.json`.
|
||||||
|
*/
|
||||||
|
readonly launchConfigsDirPath?: string;
|
||||||
|
/**
|
||||||
|
* Absolute path to the `arduino-cli.yaml` file. If not specified, it falls back to `~/.arduinoIDE/arduino-cli.yaml`.
|
||||||
|
*/
|
||||||
|
readonly cliConfigPath?: string;
|
||||||
|
/**
|
||||||
|
* Programmer for the debugging.
|
||||||
|
*/
|
||||||
|
readonly programmer?: string;
|
||||||
|
/**
|
||||||
|
* Custom progress title to use when getting the debug information from the CLI.
|
||||||
|
*/
|
||||||
|
readonly title?: string;
|
||||||
|
}
|
||||||
|
type StartDebugResult = boolean;
|
||||||
|
|
||||||
|
export const DebugDisabledStatusMessageSource = Symbol(
|
||||||
|
'DebugDisabledStatusMessageSource'
|
||||||
|
);
|
||||||
|
export interface DebugDisabledStatusMessageSource {
|
||||||
|
/**
|
||||||
|
* `undefined` if debugging is enabled (for the currently selected board + programmer + config options).
|
||||||
|
* Otherwise, it's the human readable message why it's disabled.
|
||||||
|
*/
|
||||||
|
get message(): string | undefined;
|
||||||
|
/**
|
||||||
|
* Emits an event when {@link message} changes.
|
||||||
|
*/
|
||||||
|
get onDidChangeMessage(): Event<string | undefined>;
|
||||||
|
}
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class Debug extends SketchContribution {
|
export class Debug
|
||||||
|
extends SketchContribution
|
||||||
|
implements DebugDisabledStatusMessageSource
|
||||||
|
{
|
||||||
@inject(HostedPluginSupport)
|
@inject(HostedPluginSupport)
|
||||||
protected hostedPluginSupport: HostedPluginSupport;
|
private readonly hostedPluginSupport: HostedPluginSupport;
|
||||||
|
|
||||||
@inject(NotificationCenter)
|
@inject(NotificationCenter)
|
||||||
protected readonly notificationCenter: NotificationCenter;
|
private readonly notificationCenter: NotificationCenter;
|
||||||
|
|
||||||
@inject(ExecutableService)
|
@inject(ExecutableService)
|
||||||
protected readonly executableService: ExecutableService;
|
private readonly executableService: ExecutableService;
|
||||||
|
|
||||||
@inject(BoardsService)
|
@inject(BoardsService)
|
||||||
protected readonly boardService: BoardsService;
|
private readonly boardService: BoardsService;
|
||||||
|
|
||||||
@inject(BoardsServiceProvider)
|
@inject(BoardsServiceProvider)
|
||||||
protected readonly boardsServiceProvider: BoardsServiceProvider;
|
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
@inject(BoardsDataStore)
|
||||||
|
private readonly boardsDataStore: BoardsDataStore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If `undefined`, debugging is enabled. Otherwise, the reason why it's disabled.
|
* If `undefined`, debugging is enabled. Otherwise, the human-readable reason why it's disabled.
|
||||||
*/
|
*/
|
||||||
protected _disabledMessages?: string = nls.localize(
|
private _message?: string = noBoardSelected; // Initial pessimism.
|
||||||
'arduino/common/noBoardSelected',
|
private readonly didChangeMessageEmitter = new Emitter<string | undefined>();
|
||||||
'No board selected'
|
readonly onDidChangeMessage = this.didChangeMessageEmitter.event;
|
||||||
); // Initial pessimism.
|
|
||||||
protected disabledMessageDidChangeEmitter = new Emitter<string | undefined>();
|
|
||||||
protected onDisabledMessageDidChange =
|
|
||||||
this.disabledMessageDidChangeEmitter.event;
|
|
||||||
|
|
||||||
protected get disabledMessage(): string | undefined {
|
get message(): string | undefined {
|
||||||
return this._disabledMessages;
|
return this._message;
|
||||||
}
|
}
|
||||||
protected set disabledMessage(message: string | undefined) {
|
private set message(message: string | undefined) {
|
||||||
this._disabledMessages = message;
|
this._message = message;
|
||||||
this.disabledMessageDidChangeEmitter.fire(this._disabledMessages);
|
this.didChangeMessageEmitter.fire(this._message);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected readonly debugToolbarItem = {
|
private readonly debugToolbarItem = {
|
||||||
id: Debug.Commands.START_DEBUGGING.id,
|
id: Debug.Commands.START_DEBUGGING.id,
|
||||||
command: Debug.Commands.START_DEBUGGING.id,
|
command: Debug.Commands.START_DEBUGGING.id,
|
||||||
tooltip: `${
|
tooltip: `${
|
||||||
this.disabledMessage
|
this.message
|
||||||
? nls.localize(
|
? nls.localize(
|
||||||
'arduino/debug/debugWithMessage',
|
'arduino/debug/debugWithMessage',
|
||||||
'Debug - {0}',
|
'Debug - {0}',
|
||||||
this.disabledMessage
|
this.message
|
||||||
)
|
)
|
||||||
: Debug.Commands.START_DEBUGGING.label
|
: Debug.Commands.START_DEBUGGING.label
|
||||||
}`,
|
}`,
|
||||||
priority: 3,
|
priority: 3,
|
||||||
onDidChange: this.onDisabledMessageDidChange as Event<void>,
|
onDidChange: this.onDidChangeMessage as Event<void>,
|
||||||
};
|
};
|
||||||
|
|
||||||
onStart(): void {
|
override onStart(): void {
|
||||||
this.onDisabledMessageDidChange(
|
this.onDidChangeMessage(
|
||||||
() =>
|
() =>
|
||||||
(this.debugToolbarItem.tooltip = `${
|
(this.debugToolbarItem.tooltip = `${
|
||||||
this.disabledMessage
|
this.message
|
||||||
? nls.localize(
|
? nls.localize(
|
||||||
'arduino/debug/debugWithMessage',
|
'arduino/debug/debugWithMessage',
|
||||||
'Debug - {0}',
|
'Debug - {0}',
|
||||||
this.disabledMessage
|
this.message
|
||||||
)
|
)
|
||||||
: Debug.Commands.START_DEBUGGING.label
|
: Debug.Commands.START_DEBUGGING.label
|
||||||
}`)
|
}`)
|
||||||
);
|
);
|
||||||
const refreshState = async (
|
this.boardsServiceProvider.onBoardsConfigDidChange((event) => {
|
||||||
board: Board | undefined = this.boardsServiceProvider.boardsConfig
|
if (isBoardIdentifierChangeEvent(event)) {
|
||||||
.selectedBoard
|
this.updateMessage();
|
||||||
) => {
|
|
||||||
if (!board) {
|
|
||||||
this.disabledMessage = nls.localize(
|
|
||||||
'arduino/common/noBoardSelected',
|
|
||||||
'No board selected'
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const fqbn = board.fqbn;
|
});
|
||||||
if (!fqbn) {
|
this.notificationCenter.onPlatformDidInstall(() => this.updateMessage());
|
||||||
this.disabledMessage = nls.localize(
|
this.notificationCenter.onPlatformDidUninstall(() => this.updateMessage());
|
||||||
'arduino/debug/noPlatformInstalledFor',
|
this.boardsDataStore.onDidChange((event) => {
|
||||||
"Platform is not installed for '{0}'",
|
const selectedFqbn =
|
||||||
board.name
|
this.boardsServiceProvider.boardsConfig.selectedBoard?.fqbn;
|
||||||
);
|
if (event.changes.find((change) => change.fqbn === selectedFqbn)) {
|
||||||
return;
|
this.updateMessage();
|
||||||
}
|
}
|
||||||
const details = await this.boardService.getBoardDetails({ fqbn });
|
});
|
||||||
if (!details) {
|
this.commandService.onDidExecuteCommand((event) => {
|
||||||
this.disabledMessage = nls.localize(
|
const { commandId, args } = event;
|
||||||
'arduino/debug/noPlatformInstalledFor',
|
if (
|
||||||
"Platform is not installed for '{0}'",
|
commandId === 'arduino.languageserver.notifyBuildDidComplete' &&
|
||||||
board.name
|
isCompileSummary(args[0])
|
||||||
);
|
) {
|
||||||
return;
|
this.updateMessage();
|
||||||
}
|
}
|
||||||
const { debuggingSupported } = details;
|
});
|
||||||
if (!debuggingSupported) {
|
|
||||||
this.disabledMessage = nls.localize(
|
|
||||||
'arduino/debug/debuggingNotSupported',
|
|
||||||
"Debugging is not supported by '{0}'",
|
|
||||||
board.name
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
this.disabledMessage = undefined;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this.boardsServiceProvider.onBoardsConfigChanged(({ selectedBoard }) =>
|
|
||||||
refreshState(selectedBoard)
|
|
||||||
);
|
|
||||||
this.notificationCenter.onPlatformInstalled(() => refreshState());
|
|
||||||
this.notificationCenter.onPlatformUninstalled(() => refreshState());
|
|
||||||
refreshState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registerCommands(registry: CommandRegistry): void {
|
override onReady(): void {
|
||||||
|
this.boardsServiceProvider.ready.then(() => this.updateMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(Debug.Commands.START_DEBUGGING, {
|
registry.registerCommand(Debug.Commands.START_DEBUGGING, {
|
||||||
execute: () => this.startDebug(),
|
execute: () => this.startDebug(),
|
||||||
isVisible: (widget) =>
|
isVisible: (widget) =>
|
||||||
ArduinoToolbar.is(widget) && widget.side === 'left',
|
ArduinoToolbar.is(widget) && widget.side === 'left',
|
||||||
isEnabled: () => !this.disabledMessage,
|
isEnabled: () => !this.message,
|
||||||
|
});
|
||||||
|
registry.registerCommand(Debug.Commands.TOGGLE_OPTIMIZE_FOR_DEBUG, {
|
||||||
|
execute: () => this.toggleCompileForDebug(),
|
||||||
|
isToggled: () => this.compileForDebug,
|
||||||
|
});
|
||||||
|
registry.registerCommand(Debug.Commands.IS_OPTIMIZE_FOR_DEBUG, {
|
||||||
|
execute: () => this.compileForDebug,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerToolbarItems(registry: TabBarToolbarRegistry): void {
|
override registerToolbarItems(registry: TabBarToolbarRegistry): void {
|
||||||
registry.registerItem(this.debugToolbarItem);
|
registry.registerItem(this.debugToolbarItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async startDebug(
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
board: Board | undefined = this.boardsServiceProvider.boardsConfig
|
registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, {
|
||||||
.selectedBoard
|
commandId: Debug.Commands.TOGGLE_OPTIMIZE_FOR_DEBUG.id,
|
||||||
): Promise<void> {
|
label: Debug.Commands.TOGGLE_OPTIMIZE_FOR_DEBUG.label,
|
||||||
if (!board) {
|
order: '5',
|
||||||
return;
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updateMessage(): Promise<void> {
|
||||||
|
try {
|
||||||
|
await this.isDebugEnabled();
|
||||||
|
this.message = undefined;
|
||||||
|
} catch (err) {
|
||||||
|
let message = String(err);
|
||||||
|
if (err instanceof Error) {
|
||||||
|
message = err.message;
|
||||||
|
}
|
||||||
|
this.message = message;
|
||||||
}
|
}
|
||||||
const { name, fqbn } = board;
|
}
|
||||||
if (!fqbn) {
|
|
||||||
return;
|
private async isDebugEnabled(
|
||||||
|
board: BoardIdentifier | undefined = this.boardsServiceProvider.boardsConfig
|
||||||
|
.selectedBoard
|
||||||
|
): Promise<string> {
|
||||||
|
const debugFqbn = await isDebugEnabled(
|
||||||
|
board,
|
||||||
|
(fqbn) => this.boardService.getBoardDetails({ fqbn }),
|
||||||
|
(fqbn) => this.boardsDataStore.getData(fqbn),
|
||||||
|
(fqbn) => this.boardsDataStore.appendConfigToFqbn(fqbn),
|
||||||
|
(params) => this.boardService.checkDebugEnabled(params)
|
||||||
|
);
|
||||||
|
return debugFqbn;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async startDebug(
|
||||||
|
board: BoardIdentifier | undefined = this.boardsServiceProvider.boardsConfig
|
||||||
|
.selectedBoard,
|
||||||
|
sketch:
|
||||||
|
| CurrentSketch
|
||||||
|
| undefined = this.sketchServiceClient.tryGetCurrentSketch()
|
||||||
|
): Promise<StartDebugResult> {
|
||||||
|
if (!CurrentSketch.isValid(sketch)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const params = await this.createStartDebugParams(board);
|
||||||
|
if (!params) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
await this.hostedPluginSupport.didStart;
|
await this.hostedPluginSupport.didStart;
|
||||||
const [sketch, executables] = await Promise.all([
|
try {
|
||||||
|
const result = await this.debug(params);
|
||||||
|
return Boolean(result);
|
||||||
|
} catch (err) {
|
||||||
|
if (await this.isSketchNotVerifiedError(err, sketch)) {
|
||||||
|
const yes = nls.localize('vscode/extensionsUtils/yes', 'Yes');
|
||||||
|
const answer = await this.messageService.error(
|
||||||
|
sketchIsNotCompiled(sketch.name),
|
||||||
|
yes
|
||||||
|
);
|
||||||
|
if (answer === yes) {
|
||||||
|
this.commandService.executeCommand('arduino-verify-sketch');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.messageService.error(
|
||||||
|
err instanceof Error ? err.message : String(err)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async debug(
|
||||||
|
params: StartDebugParams
|
||||||
|
): Promise<StartDebugResult | undefined> {
|
||||||
|
return this.commandService.executeCommand<StartDebugResult>(
|
||||||
|
'arduino.debug.start',
|
||||||
|
params
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
get compileForDebug(): boolean {
|
||||||
|
const value = window.localStorage.getItem(COMPILE_FOR_DEBUG_KEY);
|
||||||
|
return value === 'true';
|
||||||
|
}
|
||||||
|
|
||||||
|
private toggleCompileForDebug(): void {
|
||||||
|
const oldState = this.compileForDebug;
|
||||||
|
const newState = !oldState;
|
||||||
|
window.localStorage.setItem(COMPILE_FOR_DEBUG_KEY, String(newState));
|
||||||
|
this.menuManager.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async isSketchNotVerifiedError(
|
||||||
|
err: unknown,
|
||||||
|
sketch: SketchRef
|
||||||
|
): Promise<boolean> {
|
||||||
|
if (err instanceof Error) {
|
||||||
|
try {
|
||||||
|
const buildPaths = await this.sketchesService.getBuildPath(sketch);
|
||||||
|
return buildPaths.some((tempBuildPath) =>
|
||||||
|
err.message.includes(tempBuildPath)
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async createStartDebugParams(
|
||||||
|
board: BoardIdentifier | undefined
|
||||||
|
): Promise<StartDebugParams | undefined> {
|
||||||
|
if (!board || !board.fqbn) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
let debugFqbn: string | undefined = undefined;
|
||||||
|
try {
|
||||||
|
debugFqbn = await this.isDebugEnabled(board);
|
||||||
|
} catch {}
|
||||||
|
if (!debugFqbn) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const [sketch, executables, boardsData] = await Promise.all([
|
||||||
this.sketchServiceClient.currentSketch(),
|
this.sketchServiceClient.currentSketch(),
|
||||||
this.executableService.list(),
|
this.executableService.list(),
|
||||||
|
this.boardsDataStore.getData(board.fqbn),
|
||||||
]);
|
]);
|
||||||
if (!sketch) {
|
if (!CurrentSketch.isValid(sketch)) {
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
const ideTempFolderUri = await this.sketchService.getIdeTempFolderUri(
|
const ideTempFolderUri = await this.sketchesService.getIdeTempFolderUri(
|
||||||
sketch
|
sketch
|
||||||
);
|
);
|
||||||
const [cliPath, sketchPath, configPath] = await Promise.all([
|
const [cliPath, sketchPath, launchConfigsDirPath] = await Promise.all([
|
||||||
this.fileService.fsPath(new URI(executables.cliUri)),
|
this.fileService.fsPath(new URI(executables.cliUri)),
|
||||||
this.fileService.fsPath(new URI(sketch.uri)),
|
this.fileService.fsPath(new URI(sketch.uri)),
|
||||||
this.fileService.fsPath(new URI(ideTempFolderUri)),
|
this.fileService.fsPath(new URI(ideTempFolderUri)),
|
||||||
]);
|
]);
|
||||||
const config = {
|
return {
|
||||||
|
board: { fqbn: debugFqbn, name: board.name },
|
||||||
cliPath,
|
cliPath,
|
||||||
board: {
|
|
||||||
fqbn,
|
|
||||||
name,
|
|
||||||
},
|
|
||||||
sketchPath,
|
sketchPath,
|
||||||
configPath,
|
launchConfigsDirPath,
|
||||||
|
programmer: boardsData.selectedProgrammer?.id,
|
||||||
|
title: nls.localize(
|
||||||
|
'arduino/debug/getDebugInfo',
|
||||||
|
'Getting debug info...'
|
||||||
|
),
|
||||||
};
|
};
|
||||||
return this.commandService.executeCommand('arduino.debug.start', config);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace Debug {
|
export namespace Debug {
|
||||||
export namespace Commands {
|
export namespace Commands {
|
||||||
export const START_DEBUGGING = Command.toLocalizedCommand(
|
export const START_DEBUGGING = Command.toLocalizedCommand(
|
||||||
@@ -190,5 +352,91 @@ export namespace Debug {
|
|||||||
},
|
},
|
||||||
'vscode/debug.contribution/startDebuggingHelp'
|
'vscode/debug.contribution/startDebuggingHelp'
|
||||||
);
|
);
|
||||||
|
export const TOGGLE_OPTIMIZE_FOR_DEBUG = Command.toLocalizedCommand(
|
||||||
|
{
|
||||||
|
id: 'arduino-toggle-optimize-for-debug',
|
||||||
|
label: 'Optimize for Debugging',
|
||||||
|
category: 'Arduino',
|
||||||
|
},
|
||||||
|
'arduino/debug/optimizeForDebugging'
|
||||||
|
);
|
||||||
|
export const IS_OPTIMIZE_FOR_DEBUG: Command = {
|
||||||
|
id: 'arduino-is-optimize-for-debug',
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolves with the FQBN to use for the `debug --info --programmer p --fqbn $FQBN` command. Otherwise, rejects.
|
||||||
|
*
|
||||||
|
* (non-API)
|
||||||
|
*/
|
||||||
|
export async function isDebugEnabled(
|
||||||
|
board: BoardIdentifier | undefined,
|
||||||
|
getDetails: (fqbn: string) => MaybePromise<BoardDetails | undefined>,
|
||||||
|
getData: (fqbn: string) => MaybePromise<BoardsDataStore.Data>,
|
||||||
|
appendConfigToFqbn: (fqbn: string) => MaybePromise<string | undefined>,
|
||||||
|
checkDebugEnabled: (params: CheckDebugEnabledParams) => MaybePromise<string>
|
||||||
|
): Promise<string> {
|
||||||
|
if (!board) {
|
||||||
|
throw new Error(noBoardSelected);
|
||||||
|
}
|
||||||
|
const { fqbn } = board;
|
||||||
|
if (!fqbn) {
|
||||||
|
throw new Error(noPlatformInstalledFor(board.name));
|
||||||
|
}
|
||||||
|
const [details, data, fqbnWithConfig] = await Promise.all([
|
||||||
|
getDetails(fqbn),
|
||||||
|
getData(fqbn),
|
||||||
|
appendConfigToFqbn(fqbn),
|
||||||
|
]);
|
||||||
|
if (!details) {
|
||||||
|
throw new Error(noPlatformInstalledFor(board.name));
|
||||||
|
}
|
||||||
|
if (!fqbnWithConfig) {
|
||||||
|
throw new Error(
|
||||||
|
`Failed to append boards config to the FQBN. Original FQBN was: ${fqbn}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const params = {
|
||||||
|
fqbn: fqbnWithConfig,
|
||||||
|
programmer: data.selectedProgrammer?.id,
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const debugFqbn = await checkDebugEnabled(params);
|
||||||
|
return debugFqbn;
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(debuggingNotSupported(board.name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (non-API)
|
||||||
|
*/
|
||||||
|
export function sketchIsNotCompiled(sketchName: string): string {
|
||||||
|
return nls.localize(
|
||||||
|
'arduino/debug/sketchIsNotCompiled',
|
||||||
|
"Sketch '{0}' must be verified before starting a debug session. Please verify the sketch and start debugging again. Do you want to verify the sketch now?",
|
||||||
|
sketchName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* (non-API)
|
||||||
|
*/
|
||||||
|
export function noPlatformInstalledFor(boardName: string): string {
|
||||||
|
return nls.localize(
|
||||||
|
'arduino/debug/noPlatformInstalledFor',
|
||||||
|
"Platform is not installed for '{0}'",
|
||||||
|
boardName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* (non-API)
|
||||||
|
*/
|
||||||
|
export function debuggingNotSupported(boardName: string): string {
|
||||||
|
return nls.localize(
|
||||||
|
'arduino/debug/debuggingNotSupported',
|
||||||
|
"Debugging is not supported by '{0}'",
|
||||||
|
boardName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
168
arduino-ide-extension/src/browser/contributions/delete-sketch.ts
Normal file
168
arduino-ide-extension/src/browser/contributions/delete-sketch.ts
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
import { Dialog } from '@theia/core/lib/browser/dialogs';
|
||||||
|
import { NavigatableWidget } from '@theia/core/lib/browser/navigatable-types';
|
||||||
|
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
|
||||||
|
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import type { MaybeArray } from '@theia/core/lib/common/types';
|
||||||
|
import URI from '@theia/core/lib/common/uri';
|
||||||
|
import type { Widget } from '@theia/core/shared/@phosphor/widgets';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { SketchesError } from '../../common/protocol';
|
||||||
|
import { Sketch } from '../contributions/contribution';
|
||||||
|
import { isNotFound } from '../create/typings';
|
||||||
|
import { Command, CommandRegistry } from './contribution';
|
||||||
|
import { CloudSketchContribution } from './cloud-contribution';
|
||||||
|
import { AppService } from '../app-service';
|
||||||
|
|
||||||
|
export interface DeleteSketchParams {
|
||||||
|
/**
|
||||||
|
* Either the URI of the sketch folder or the sketch to delete.
|
||||||
|
*/
|
||||||
|
readonly toDelete: string | Sketch;
|
||||||
|
/**
|
||||||
|
* If `true`, the currently opened sketch is expected to be deleted.
|
||||||
|
* Hence, the editors must be closed, the sketch will be scheduled
|
||||||
|
* for deletion, and the browser window will close or navigate away.
|
||||||
|
* If `false`, the sketch will be scheduled for deletion,
|
||||||
|
* but the current window remains open. If `force`, the window will
|
||||||
|
* navigate away, but IDE2 won't open any confirmation dialogs.
|
||||||
|
*/
|
||||||
|
readonly willNavigateAway?: boolean | 'force';
|
||||||
|
}
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class DeleteSketch extends CloudSketchContribution {
|
||||||
|
@inject(ApplicationShell)
|
||||||
|
private readonly shell: ApplicationShell;
|
||||||
|
@inject(WindowService)
|
||||||
|
private readonly windowService: WindowService;
|
||||||
|
@inject(AppService)
|
||||||
|
private readonly appService: AppService;
|
||||||
|
|
||||||
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
|
registry.registerCommand(DeleteSketch.Commands.DELETE_SKETCH, {
|
||||||
|
execute: (params: DeleteSketchParams) => this.deleteSketch(params),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async deleteSketch(params: DeleteSketchParams): Promise<void> {
|
||||||
|
const { toDelete, willNavigateAway } = params;
|
||||||
|
let sketch: Sketch;
|
||||||
|
if (typeof toDelete === 'string') {
|
||||||
|
const resolvedSketch = await this.loadSketch(toDelete);
|
||||||
|
if (!resolvedSketch) {
|
||||||
|
console.info(
|
||||||
|
`Failed to load the sketch. It was not found at '${toDelete}'. Skipping deletion.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sketch = resolvedSketch;
|
||||||
|
} else {
|
||||||
|
sketch = toDelete;
|
||||||
|
}
|
||||||
|
if (!willNavigateAway) {
|
||||||
|
this.scheduleDeletion(sketch);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const cloudUri = this.createFeatures.cloudUri(sketch);
|
||||||
|
if (willNavigateAway !== 'force') {
|
||||||
|
const { response } = await this.dialogService.showMessageBox({
|
||||||
|
title: nls.localizeByDefault('Delete'),
|
||||||
|
type: 'question',
|
||||||
|
buttons: [Dialog.CANCEL, Dialog.OK],
|
||||||
|
message: cloudUri
|
||||||
|
? nls.localize(
|
||||||
|
'theia/workspace/deleteCloudSketch',
|
||||||
|
"The cloud sketch '{0}' will be permanently deleted from the Arduino servers and the local caches. This action is irreversible. Do you want to delete the current sketch?",
|
||||||
|
sketch.name
|
||||||
|
)
|
||||||
|
: nls.localize(
|
||||||
|
'theia/workspace/deleteCurrentSketch',
|
||||||
|
"The sketch '{0}' will be permanently deleted. This action is irreversible. Do you want to delete the current sketch?",
|
||||||
|
sketch.name
|
||||||
|
),
|
||||||
|
});
|
||||||
|
// cancel
|
||||||
|
if (response === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cloudUri) {
|
||||||
|
const posixPath = cloudUri.path.toString();
|
||||||
|
const cloudSketch = this.createApi.sketchCache.getSketch(posixPath);
|
||||||
|
if (!cloudSketch) {
|
||||||
|
throw new Error(
|
||||||
|
`Cloud sketch with path '${posixPath}' was not cached. Cache: ${this.createApi.sketchCache.toString()}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// IDE2 cannot use DELETE directory as the server responses with HTTP 500 if it's missing.
|
||||||
|
// https://github.com/arduino/arduino-ide/issues/1825#issuecomment-1406301406
|
||||||
|
await this.createApi.deleteSketch(cloudSketch.path);
|
||||||
|
} catch (err) {
|
||||||
|
if (!isNotFound(err)) {
|
||||||
|
throw err;
|
||||||
|
} else {
|
||||||
|
console.info(
|
||||||
|
`Could not delete the cloud sketch with path '${posixPath}'. It does not exist.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await Promise.all([
|
||||||
|
...Sketch.uris(sketch).map((uri) =>
|
||||||
|
this.closeWithoutSaving(new URI(uri))
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
this.windowService.setSafeToShutDown();
|
||||||
|
this.scheduleDeletion(sketch);
|
||||||
|
return window.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private scheduleDeletion(sketch: Sketch): void {
|
||||||
|
this.appService.scheduleDeletion(sketch);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async loadSketch(uri: string): Promise<Sketch | undefined> {
|
||||||
|
try {
|
||||||
|
const sketch = await this.sketchesService.loadSketch(uri);
|
||||||
|
return sketch;
|
||||||
|
} catch (err) {
|
||||||
|
if (SketchesError.NotFound.is(err)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// fix: https://github.com/eclipse-theia/theia/issues/12107
|
||||||
|
private async closeWithoutSaving(uri: URI): Promise<void> {
|
||||||
|
const affected = getAffected(this.shell.widgets, uri);
|
||||||
|
const toClose = [...affected].map(([, widget]) => widget);
|
||||||
|
await this.shell.closeMany(toClose, { save: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export namespace DeleteSketch {
|
||||||
|
export namespace Commands {
|
||||||
|
export const DELETE_SKETCH: Command = {
|
||||||
|
id: 'arduino-delete-sketch',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAffected<T extends Widget>(
|
||||||
|
widgets: Iterable<T>,
|
||||||
|
context: MaybeArray<URI>
|
||||||
|
): [URI, T & NavigatableWidget][] {
|
||||||
|
const uris = Array.isArray(context) ? context : [context];
|
||||||
|
const result: [URI, T & NavigatableWidget][] = [];
|
||||||
|
for (const widget of widgets) {
|
||||||
|
if (NavigatableWidget.is(widget)) {
|
||||||
|
const resourceUri = widget.getResourceUri();
|
||||||
|
if (resourceUri && uris.some((uri) => uri.isEqualOrParent(resourceUri))) {
|
||||||
|
result.push([resourceUri, widget]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
import { inject, injectable } from 'inversify';
|
import { nls } from '@theia/core/lib/common';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { CommonCommands } from '@theia/core/lib/browser/common-frontend-contribution';
|
import { CommonCommands } from '@theia/core/lib/browser/common-frontend-contribution';
|
||||||
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
|
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
|
||||||
import { PreferenceService } from '@theia/core/lib/browser/preferences/preference-service';
|
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
||||||
import { MonacoEditorService } from '@theia/monaco/lib/browser/monaco-editor-service';
|
import { ICodeEditorService } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/codeEditorService';
|
||||||
|
import type { ICodeEditor } from '@theia/monaco-editor-core/esm/vs/editor/browser/editorBrowser';
|
||||||
|
import type { StandaloneCodeEditor } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneCodeEditor';
|
||||||
import {
|
import {
|
||||||
Contribution,
|
Contribution,
|
||||||
Command,
|
Command,
|
||||||
@@ -11,22 +14,15 @@ import {
|
|||||||
CommandRegistry,
|
CommandRegistry,
|
||||||
} from './contribution';
|
} from './contribution';
|
||||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
import { nls } from '@theia/core/lib/common';
|
|
||||||
|
|
||||||
// TODO: [macOS]: to remove `Start Dictation...` and `Emoji & Symbol` see this thread: https://github.com/electron/electron/issues/8283#issuecomment-269522072
|
// TODO: [macOS]: to remove `Start Dictation...` and `Emoji & Symbol` see this thread: https://github.com/electron/electron/issues/8283#issuecomment-269522072
|
||||||
// Depends on https://github.com/eclipse-theia/theia/pull/7964
|
// Depends on https://github.com/eclipse-theia/theia/pull/7964
|
||||||
@injectable()
|
@injectable()
|
||||||
export class EditContributions extends Contribution {
|
export class EditContributions extends Contribution {
|
||||||
@inject(MonacoEditorService)
|
|
||||||
protected readonly codeEditorService: MonacoEditorService;
|
|
||||||
|
|
||||||
@inject(ClipboardService)
|
@inject(ClipboardService)
|
||||||
protected readonly clipboardService: ClipboardService;
|
private readonly clipboardService: ClipboardService;
|
||||||
|
|
||||||
@inject(PreferenceService)
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
protected readonly preferences: PreferenceService;
|
|
||||||
|
|
||||||
registerCommands(registry: CommandRegistry): void {
|
|
||||||
registry.registerCommand(EditContributions.Commands.GO_TO_LINE, {
|
registry.registerCommand(EditContributions.Commands.GO_TO_LINE, {
|
||||||
execute: () => this.run('editor.action.gotoLine'),
|
execute: () => this.run('editor.action.gotoLine'),
|
||||||
});
|
});
|
||||||
@@ -43,38 +39,14 @@ export class EditContributions extends Contribution {
|
|||||||
execute: () => this.run('actions.find'),
|
execute: () => this.run('actions.find'),
|
||||||
});
|
});
|
||||||
registry.registerCommand(EditContributions.Commands.FIND_NEXT, {
|
registry.registerCommand(EditContributions.Commands.FIND_NEXT, {
|
||||||
execute: () => this.run('actions.findWithSelection'),
|
execute: () => this.run('editor.action.nextMatchFindAction'),
|
||||||
});
|
});
|
||||||
registry.registerCommand(EditContributions.Commands.FIND_PREVIOUS, {
|
registry.registerCommand(EditContributions.Commands.FIND_PREVIOUS, {
|
||||||
execute: () => this.run('editor.action.nextMatchFindAction'),
|
execute: () => this.run('editor.action.previousMatchFindAction'),
|
||||||
});
|
});
|
||||||
registry.registerCommand(EditContributions.Commands.USE_FOR_FIND, {
|
registry.registerCommand(EditContributions.Commands.USE_FOR_FIND, {
|
||||||
execute: () => this.run('editor.action.previousSelectionMatchFindAction'),
|
execute: () => this.run('editor.action.previousSelectionMatchFindAction'),
|
||||||
});
|
});
|
||||||
registry.registerCommand(EditContributions.Commands.INCREASE_FONT_SIZE, {
|
|
||||||
execute: async () => {
|
|
||||||
const settings = await this.settingsService.settings();
|
|
||||||
if (settings.autoScaleInterface) {
|
|
||||||
settings.interfaceScale = settings.interfaceScale + 1;
|
|
||||||
} else {
|
|
||||||
settings.editorFontSize = settings.editorFontSize + 1;
|
|
||||||
}
|
|
||||||
await this.settingsService.update(settings);
|
|
||||||
await this.settingsService.save();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
registry.registerCommand(EditContributions.Commands.DECREASE_FONT_SIZE, {
|
|
||||||
execute: async () => {
|
|
||||||
const settings = await this.settingsService.settings();
|
|
||||||
if (settings.autoScaleInterface) {
|
|
||||||
settings.interfaceScale = settings.interfaceScale - 1;
|
|
||||||
} else {
|
|
||||||
settings.editorFontSize = settings.editorFontSize - 1;
|
|
||||||
}
|
|
||||||
await this.settingsService.update(settings);
|
|
||||||
await this.settingsService.save();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
/* Tools */ registry.registerCommand(
|
/* Tools */ registry.registerCommand(
|
||||||
EditContributions.Commands.AUTO_FORMAT,
|
EditContributions.Commands.AUTO_FORMAT,
|
||||||
{ execute: () => this.run('editor.action.formatDocument') }
|
{ execute: () => this.run('editor.action.formatDocument') }
|
||||||
@@ -83,15 +55,17 @@ export class EditContributions extends Contribution {
|
|||||||
execute: async () => {
|
execute: async () => {
|
||||||
const value = await this.currentValue();
|
const value = await this.currentValue();
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
this.clipboardService.writeText(`\`\`\`cpp
|
this.clipboardService.writeText(`
|
||||||
|
\`\`\`cpp
|
||||||
${value}
|
${value}
|
||||||
\`\`\``);
|
\`\`\`
|
||||||
|
`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMenus(registry: MenuModelRegistry): void {
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
registry.registerMenuAction(ArduinoMenus.EDIT__TEXT_CONTROL_GROUP, {
|
registry.registerMenuAction(ArduinoMenus.EDIT__TEXT_CONTROL_GROUP, {
|
||||||
commandId: CommonCommands.CUT.id,
|
commandId: CommonCommands.CUT.id,
|
||||||
order: '0',
|
order: '0',
|
||||||
@@ -143,22 +117,10 @@ ${value}
|
|||||||
label: nls.localize('arduino/editor/decreaseIndent', 'Decrease Indent'),
|
label: nls.localize('arduino/editor/decreaseIndent', 'Decrease Indent'),
|
||||||
order: '2',
|
order: '2',
|
||||||
});
|
});
|
||||||
|
registry.registerMenuAction(ArduinoMenus.EDIT__CODE_CONTROL_GROUP, {
|
||||||
registry.registerMenuAction(ArduinoMenus.EDIT__FONT_CONTROL_GROUP, {
|
commandId: EditContributions.Commands.AUTO_FORMAT.id,
|
||||||
commandId: EditContributions.Commands.INCREASE_FONT_SIZE.id,
|
label: nls.localize('arduino/editor/autoFormat', 'Auto Format'),
|
||||||
label: nls.localize(
|
order: '3',
|
||||||
'arduino/editor/increaseFontSize',
|
|
||||||
'Increase Font Size'
|
|
||||||
),
|
|
||||||
order: '0',
|
|
||||||
});
|
|
||||||
registry.registerMenuAction(ArduinoMenus.EDIT__FONT_CONTROL_GROUP, {
|
|
||||||
commandId: EditContributions.Commands.DECREASE_FONT_SIZE.id,
|
|
||||||
label: nls.localize(
|
|
||||||
'arduino/editor/decreaseFontSize',
|
|
||||||
'Decrease Font Size'
|
|
||||||
),
|
|
||||||
order: '1',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
registry.registerMenuAction(ArduinoMenus.EDIT__FIND_GROUP, {
|
registry.registerMenuAction(ArduinoMenus.EDIT__FIND_GROUP, {
|
||||||
@@ -199,7 +161,7 @@ ${value}
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerKeybindings(registry: KeybindingRegistry): void {
|
override registerKeybindings(registry: KeybindingRegistry): void {
|
||||||
registry.registerKeybinding({
|
registry.registerKeybinding({
|
||||||
command: EditContributions.Commands.COPY_FOR_FORUM.id,
|
command: EditContributions.Commands.COPY_FOR_FORUM.id,
|
||||||
keybinding: 'CtrlCmd+Shift+C',
|
keybinding: 'CtrlCmd+Shift+C',
|
||||||
@@ -217,15 +179,6 @@ ${value}
|
|||||||
when: 'editorFocus',
|
when: 'editorFocus',
|
||||||
});
|
});
|
||||||
|
|
||||||
registry.registerKeybinding({
|
|
||||||
command: EditContributions.Commands.INCREASE_FONT_SIZE.id,
|
|
||||||
keybinding: 'CtrlCmd+=',
|
|
||||||
});
|
|
||||||
registry.registerKeybinding({
|
|
||||||
command: EditContributions.Commands.DECREASE_FONT_SIZE.id,
|
|
||||||
keybinding: 'CtrlCmd+-',
|
|
||||||
});
|
|
||||||
|
|
||||||
registry.registerKeybinding({
|
registry.registerKeybinding({
|
||||||
command: EditContributions.Commands.FIND.id,
|
command: EditContributions.Commands.FIND.id,
|
||||||
keybinding: 'CtrlCmd+F',
|
keybinding: 'CtrlCmd+F',
|
||||||
@@ -250,10 +203,14 @@ ${value}
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async current(): Promise<monaco.editor.ICodeEditor | undefined> {
|
protected async current(): Promise<
|
||||||
|
ICodeEditor | StandaloneCodeEditor | undefined
|
||||||
|
> {
|
||||||
|
const codeEditorService = StandaloneServices.get(ICodeEditorService);
|
||||||
return (
|
return (
|
||||||
this.codeEditorService.getFocusedCodeEditor() ||
|
codeEditorService.getFocusedCodeEditor() ||
|
||||||
this.codeEditorService.getActiveCodeEditor()
|
codeEditorService.getActiveCodeEditor() ||
|
||||||
|
undefined
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,12 +266,6 @@ export namespace EditContributions {
|
|||||||
export const USE_FOR_FIND: Command = {
|
export const USE_FOR_FIND: Command = {
|
||||||
id: 'arduino-for-find',
|
id: 'arduino-for-find',
|
||||||
};
|
};
|
||||||
export const INCREASE_FONT_SIZE: Command = {
|
|
||||||
id: 'arduino-increase-font-size',
|
|
||||||
};
|
|
||||||
export const DECREASE_FONT_SIZE: Command = {
|
|
||||||
id: 'arduino-decrease-font-size',
|
|
||||||
};
|
|
||||||
export const AUTO_FORMAT: Command = {
|
export const AUTO_FORMAT: Command = {
|
||||||
id: 'arduino-auto-format', // `Auto Format` should belong to `Tool`.
|
id: 'arduino-auto-format', // `Auto Format` should belong to `Tool`.
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
import * as PQueue from 'p-queue';
|
import PQueue from 'p-queue';
|
||||||
import { inject, injectable, postConstruct } from 'inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { CommandHandler } from '@theia/core/lib/common/command';
|
import { CommandHandler, CommandService } from '@theia/core/lib/common/command';
|
||||||
import {
|
import { MenuPath, SubMenuOptions } from '@theia/core/lib/common/menu';
|
||||||
MenuPath,
|
|
||||||
CompositeMenuNode,
|
|
||||||
SubMenuOptions,
|
|
||||||
} from '@theia/core/lib/common/menu';
|
|
||||||
import {
|
import {
|
||||||
Disposable,
|
Disposable,
|
||||||
DisposableCollection,
|
DisposableCollection,
|
||||||
} from '@theia/core/lib/common/disposable';
|
} from '@theia/core/lib/common/disposable';
|
||||||
import { OpenSketch } from './open-sketch';
|
import { OpenSketch } from './open-sketch';
|
||||||
import { ArduinoMenus, PlaceholderMenuNode } from '../menu/arduino-menus';
|
import {
|
||||||
import { MainMenuManager } from '../../common/main-menu-manager';
|
ArduinoMenus,
|
||||||
|
examplesLabel,
|
||||||
|
PlaceholderMenuNode,
|
||||||
|
} from '../menu/arduino-menus';
|
||||||
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
||||||
import { ExamplesService } from '../../common/protocol/examples-service';
|
import { ExamplesService } from '../../common/protocol/examples-service';
|
||||||
import {
|
import {
|
||||||
@@ -21,58 +20,134 @@ import {
|
|||||||
MenuModelRegistry,
|
MenuModelRegistry,
|
||||||
} from './contribution';
|
} from './contribution';
|
||||||
import { NotificationCenter } from '../notification-center';
|
import { NotificationCenter } from '../notification-center';
|
||||||
import { Board, Sketch, SketchContainer } from '../../common/protocol';
|
import {
|
||||||
import { nls } from '@theia/core/lib/common';
|
Board,
|
||||||
|
SketchRef,
|
||||||
|
SketchContainer,
|
||||||
|
SketchesError,
|
||||||
|
CoreService,
|
||||||
|
SketchesService,
|
||||||
|
Sketch,
|
||||||
|
isBoardIdentifierChangeEvent,
|
||||||
|
BoardIdentifier,
|
||||||
|
} from '../../common/protocol';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { unregisterSubmenu } from '../menu/arduino-menus';
|
||||||
|
import { MaybePromise } from '@theia/core/lib/common/types';
|
||||||
|
import { ApplicationError } from '@theia/core/lib/common/application-error';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a cloned copy of the example sketch and opens it in a new window.
|
||||||
|
*/
|
||||||
|
export async function openClonedExample(
|
||||||
|
uri: string,
|
||||||
|
services: {
|
||||||
|
sketchesService: SketchesService;
|
||||||
|
commandService: CommandService;
|
||||||
|
},
|
||||||
|
onError: {
|
||||||
|
onDidFailClone?: (
|
||||||
|
err: ApplicationError<
|
||||||
|
number,
|
||||||
|
{
|
||||||
|
uri: string;
|
||||||
|
}
|
||||||
|
>,
|
||||||
|
uri: string
|
||||||
|
) => MaybePromise<unknown>;
|
||||||
|
onDidFailOpen?: (
|
||||||
|
err: ApplicationError<
|
||||||
|
number,
|
||||||
|
{
|
||||||
|
uri: string;
|
||||||
|
}
|
||||||
|
>,
|
||||||
|
sketch: Sketch
|
||||||
|
) => MaybePromise<unknown>;
|
||||||
|
} = {}
|
||||||
|
): Promise<void> {
|
||||||
|
const { sketchesService, commandService } = services;
|
||||||
|
const { onDidFailClone, onDidFailOpen } = onError;
|
||||||
|
try {
|
||||||
|
const sketch = await sketchesService.cloneExample(uri);
|
||||||
|
try {
|
||||||
|
await commandService.executeCommand(
|
||||||
|
OpenSketch.Commands.OPEN_SKETCH.id,
|
||||||
|
sketch
|
||||||
|
);
|
||||||
|
} catch (openError) {
|
||||||
|
if (SketchesError.NotFound.is(openError)) {
|
||||||
|
if (onDidFailOpen) {
|
||||||
|
await onDidFailOpen(openError, sketch);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw openError;
|
||||||
|
}
|
||||||
|
} catch (cloneError) {
|
||||||
|
if (SketchesError.NotFound.is(cloneError)) {
|
||||||
|
if (onDidFailClone) {
|
||||||
|
await onDidFailClone(cloneError, uri);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw cloneError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export abstract class Examples extends SketchContribution {
|
export abstract class Examples extends SketchContribution {
|
||||||
@inject(CommandRegistry)
|
@inject(CommandRegistry)
|
||||||
protected readonly commandRegistry: CommandRegistry;
|
private readonly commandRegistry: CommandRegistry;
|
||||||
|
|
||||||
@inject(MenuModelRegistry)
|
@inject(MenuModelRegistry)
|
||||||
protected readonly menuRegistry: MenuModelRegistry;
|
protected readonly menuRegistry: MenuModelRegistry;
|
||||||
|
|
||||||
@inject(MainMenuManager)
|
|
||||||
protected readonly menuManager: MainMenuManager;
|
|
||||||
|
|
||||||
@inject(ExamplesService)
|
@inject(ExamplesService)
|
||||||
protected readonly examplesService: ExamplesService;
|
protected readonly examplesService: ExamplesService;
|
||||||
|
|
||||||
|
@inject(CoreService)
|
||||||
|
protected readonly coreService: CoreService;
|
||||||
|
|
||||||
@inject(BoardsServiceProvider)
|
@inject(BoardsServiceProvider)
|
||||||
protected readonly boardsServiceClient: BoardsServiceProvider;
|
protected readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
|
||||||
|
@inject(NotificationCenter)
|
||||||
|
protected readonly notificationCenter: NotificationCenter;
|
||||||
|
|
||||||
protected readonly toDispose = new DisposableCollection();
|
protected readonly toDispose = new DisposableCollection();
|
||||||
|
|
||||||
@postConstruct()
|
protected override init(): void {
|
||||||
init(): void {
|
super.init();
|
||||||
this.boardsServiceClient.onBoardsConfigChanged(({ selectedBoard }) =>
|
this.boardsServiceProvider.onBoardsConfigDidChange((event) => {
|
||||||
this.handleBoardChanged(selectedBoard)
|
if (isBoardIdentifierChangeEvent(event)) {
|
||||||
|
this.handleBoardChanged(event.selectedBoard);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.notificationCenter.onDidReinitialize(() =>
|
||||||
|
this.update({
|
||||||
|
board: this.boardsServiceProvider.boardsConfig.selectedBoard,
|
||||||
|
// No force refresh. The core client was already refreshed.
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-vars
|
||||||
protected handleBoardChanged(board: Board | undefined): void {
|
protected handleBoardChanged(board: Board | undefined): void {
|
||||||
// NOOP
|
// NOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMenus(registry: MenuModelRegistry): void {
|
protected abstract update(options?: {
|
||||||
try {
|
board?: BoardIdentifier | undefined;
|
||||||
// This is a hack the ensures the desired menu ordering! We cannot use https://github.com/eclipse-theia/theia/pull/8377 due to ATL-222.
|
forceRefresh?: boolean;
|
||||||
const index = ArduinoMenus.FILE__EXAMPLES_SUBMENU.length - 1;
|
}): void;
|
||||||
const menuId = ArduinoMenus.FILE__EXAMPLES_SUBMENU[index];
|
|
||||||
const groupPath =
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
index === 0 ? [] : ArduinoMenus.FILE__EXAMPLES_SUBMENU.slice(0, index);
|
|
||||||
const parent: CompositeMenuNode = (registry as any).findGroup(groupPath);
|
|
||||||
const examples = new CompositeMenuNode(menuId, '', { order: '4' });
|
|
||||||
parent.addNode(examples);
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
console.warn('Could not patch menu ordering.');
|
|
||||||
}
|
|
||||||
// Registering the same submenu multiple times has no side-effect.
|
// Registering the same submenu multiple times has no side-effect.
|
||||||
// TODO: unregister submenu? https://github.com/eclipse-theia/theia/issues/7300
|
// TODO: unregister submenu? https://github.com/eclipse-theia/theia/issues/7300
|
||||||
registry.registerSubmenu(
|
registry.registerSubmenu(
|
||||||
ArduinoMenus.FILE__EXAMPLES_SUBMENU,
|
ArduinoMenus.FILE__EXAMPLES_SUBMENU,
|
||||||
nls.localize('arduino/examples/menu', 'Examples'),
|
examplesLabel,
|
||||||
{
|
{
|
||||||
order: '4',
|
order: '4',
|
||||||
}
|
}
|
||||||
@@ -82,7 +157,7 @@ export abstract class Examples extends SketchContribution {
|
|||||||
registerRecursively(
|
registerRecursively(
|
||||||
sketchContainerOrPlaceholder:
|
sketchContainerOrPlaceholder:
|
||||||
| SketchContainer
|
| SketchContainer
|
||||||
| (Sketch | SketchContainer)[]
|
| (SketchRef | SketchContainer)[]
|
||||||
| string,
|
| string,
|
||||||
menuPath: MenuPath,
|
menuPath: MenuPath,
|
||||||
pushToDispose: DisposableCollection = new DisposableCollection(),
|
pushToDispose: DisposableCollection = new DisposableCollection(),
|
||||||
@@ -100,7 +175,7 @@ export abstract class Examples extends SketchContribution {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const sketches: Sketch[] = [];
|
const sketches: SketchRef[] = [];
|
||||||
const children: SketchContainer[] = [];
|
const children: SketchContainer[] = [];
|
||||||
let submenuPath = menuPath;
|
let submenuPath = menuPath;
|
||||||
|
|
||||||
@@ -108,6 +183,11 @@ export abstract class Examples extends SketchContribution {
|
|||||||
const { label } = sketchContainerOrPlaceholder;
|
const { label } = sketchContainerOrPlaceholder;
|
||||||
submenuPath = [...menuPath, label];
|
submenuPath = [...menuPath, label];
|
||||||
this.menuRegistry.registerSubmenu(submenuPath, label, subMenuOptions);
|
this.menuRegistry.registerSubmenu(submenuPath, label, subMenuOptions);
|
||||||
|
this.toDispose.push(
|
||||||
|
Disposable.create(() =>
|
||||||
|
unregisterSubmenu(submenuPath, this.menuRegistry)
|
||||||
|
)
|
||||||
|
);
|
||||||
sketches.push(...sketchContainerOrPlaceholder.sketches);
|
sketches.push(...sketchContainerOrPlaceholder.sketches);
|
||||||
children.push(...sketchContainerOrPlaceholder.children);
|
children.push(...sketchContainerOrPlaceholder.children);
|
||||||
} else {
|
} else {
|
||||||
@@ -147,12 +227,29 @@ export abstract class Examples extends SketchContribution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected createHandler(uri: string): CommandHandler {
|
protected createHandler(uri: string): CommandHandler {
|
||||||
|
const forceUpdate = () =>
|
||||||
|
this.update({
|
||||||
|
board: this.boardsServiceProvider.boardsConfig.selectedBoard,
|
||||||
|
forceRefresh: true,
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
execute: async () => {
|
execute: async () => {
|
||||||
const sketch = await this.sketchService.cloneExample(uri);
|
await openClonedExample(
|
||||||
return this.commandService.executeCommand(
|
uri,
|
||||||
OpenSketch.Commands.OPEN_SKETCH.id,
|
{
|
||||||
sketch
|
sketchesService: this.sketchesService,
|
||||||
|
commandService: this.commandRegistry,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onDidFailClone: () => {
|
||||||
|
// Do not toast the error message. It's handled by the `Open Sketch` command.
|
||||||
|
forceUpdate();
|
||||||
|
},
|
||||||
|
onDidFailOpen: (err) => {
|
||||||
|
this.messageService.error(err.message);
|
||||||
|
forceUpdate();
|
||||||
|
},
|
||||||
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -161,11 +258,11 @@ export abstract class Examples extends SketchContribution {
|
|||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class BuiltInExamples extends Examples {
|
export class BuiltInExamples extends Examples {
|
||||||
onStart(): void {
|
override async onReady(): Promise<void> {
|
||||||
this.register(); // no `await`
|
this.update(); // no `await`
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async register(): Promise<void> {
|
protected override async update(): Promise<void> {
|
||||||
let sketchContainers: SketchContainer[] | undefined;
|
let sketchContainers: SketchContainer[] | undefined;
|
||||||
try {
|
try {
|
||||||
sketchContainers = await this.examplesService.builtIns();
|
sketchContainers = await this.examplesService.builtIns();
|
||||||
@@ -196,27 +293,32 @@ export class BuiltInExamples extends Examples {
|
|||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class LibraryExamples extends Examples {
|
export class LibraryExamples extends Examples {
|
||||||
@inject(NotificationCenter)
|
private readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
|
||||||
protected readonly notificationCenter: NotificationCenter;
|
|
||||||
|
|
||||||
protected readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
|
override onStart(): void {
|
||||||
|
this.notificationCenter.onLibraryDidInstall(() => this.update());
|
||||||
onStart(): void {
|
this.notificationCenter.onLibraryDidUninstall(() => this.update());
|
||||||
this.register(); // no `await`
|
|
||||||
this.notificationCenter.onLibraryInstalled(() => this.register());
|
|
||||||
this.notificationCenter.onLibraryUninstalled(() => this.register());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected handleBoardChanged(board: Board | undefined): void {
|
override onReady(): void {
|
||||||
this.register(board);
|
this.boardsServiceProvider.ready.then(() => this.update());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async register(
|
protected override handleBoardChanged(board: Board | undefined): void {
|
||||||
board: Board | undefined = this.boardsServiceClient.boardsConfig
|
this.update({ board });
|
||||||
.selectedBoard
|
}
|
||||||
|
|
||||||
|
protected override async update(
|
||||||
|
options: { board?: Board; forceRefresh?: boolean } = {
|
||||||
|
board: this.boardsServiceProvider.boardsConfig.selectedBoard,
|
||||||
|
}
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
const { board, forceRefresh } = options;
|
||||||
return this.queue.add(async () => {
|
return this.queue.add(async () => {
|
||||||
this.toDispose.dispose();
|
this.toDispose.dispose();
|
||||||
|
if (forceRefresh) {
|
||||||
|
await this.coreService.refresh();
|
||||||
|
}
|
||||||
const fqbn = board?.fqbn;
|
const fqbn = board?.fqbn;
|
||||||
const name = board?.name;
|
const name = board?.name;
|
||||||
// Shows all examples when no board is selected, or the platform of the currently selected board is not installed.
|
// Shows all examples when no board is selected, or the platform of the currently selected board is not installed.
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
import { LocalStorageService } from '@theia/core/lib/browser';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import {
|
||||||
|
BoardsService,
|
||||||
|
LibraryLocation,
|
||||||
|
LibraryService,
|
||||||
|
} from '../../common/protocol';
|
||||||
|
import { Contribution } from './contribution';
|
||||||
|
|
||||||
|
const Arduino_BuiltIn = 'Arduino_BuiltIn';
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class FirstStartupInstaller extends Contribution {
|
||||||
|
@inject(LocalStorageService)
|
||||||
|
private readonly localStorageService: LocalStorageService;
|
||||||
|
@inject(BoardsService)
|
||||||
|
private readonly boardsService: BoardsService;
|
||||||
|
@inject(LibraryService)
|
||||||
|
private readonly libraryService: LibraryService;
|
||||||
|
|
||||||
|
override async onReady(): Promise<void> {
|
||||||
|
const isFirstStartup = !(await this.localStorageService.getData(
|
||||||
|
FirstStartupInstaller.INIT_LIBS_AND_PACKAGES
|
||||||
|
));
|
||||||
|
if (isFirstStartup) {
|
||||||
|
const avrPackage = await this.boardsService.getBoardPackage({
|
||||||
|
id: 'arduino:avr',
|
||||||
|
});
|
||||||
|
const builtInLibrary = (
|
||||||
|
await this.libraryService.search({ query: Arduino_BuiltIn })
|
||||||
|
).find(({ name }) => name === Arduino_BuiltIn); // Filter by `name` to ensure "exact match". See: https://github.com/arduino/arduino-ide/issues/1526.
|
||||||
|
|
||||||
|
let avrPackageError: Error | undefined;
|
||||||
|
let builtInLibraryError: Error | undefined;
|
||||||
|
|
||||||
|
if (avrPackage) {
|
||||||
|
try {
|
||||||
|
await this.boardsService.install({
|
||||||
|
item: avrPackage,
|
||||||
|
noOverwrite: true, // We don't want to automatically replace custom platforms the user might already have in place
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
// There's no error code, I need to parse the error message: https://github.com/arduino/arduino-cli/commit/ffe4232b359fcfa87238d68acf1c3b64a1621f14#diff-10ffbdde46838dd9caa881fd1f2a5326a49f8061f6cfd7c9d430b4875a6b6895R62
|
||||||
|
if (
|
||||||
|
e.message.includes(
|
||||||
|
`Platform ${avrPackage.id}@${avrPackage.installedVersion} already installed`
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
// If arduino:avr installation fails because it's already installed we don't want to retry on next start-up
|
||||||
|
console.error(e);
|
||||||
|
} else {
|
||||||
|
// But if there is any other error (e.g.: no Internet connection), we want to retry next time
|
||||||
|
avrPackageError = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
avrPackageError = new Error('Could not find platform.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (builtInLibrary) {
|
||||||
|
try {
|
||||||
|
await this.libraryService.install({
|
||||||
|
item: builtInLibrary,
|
||||||
|
installDependencies: true,
|
||||||
|
noOverwrite: true, // We don't want to automatically replace custom libraries the user might already have in place
|
||||||
|
installLocation: LibraryLocation.BUILTIN,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
// There's no error code, I need to parse the error message: https://github.com/arduino/arduino-cli/commit/2ea3608453b17b1157f8a1dc892af2e13e40f4f0#diff-1de7569144d4e260f8dde0e0d00a4e2a218c57966d583da1687a70d518986649R95
|
||||||
|
if (/Library (.*) is already installed/.test(e.message)) {
|
||||||
|
// If Arduino_BuiltIn installation fails because it's already installed we don't want to retry on next start-up
|
||||||
|
console.log('error installing core', e);
|
||||||
|
} else {
|
||||||
|
// But if there is any other error (e.g.: no Internet connection), we want to retry next time
|
||||||
|
builtInLibraryError = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
builtInLibraryError = new Error('Could not find library');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (avrPackageError) {
|
||||||
|
this.messageService.error(
|
||||||
|
`Could not install Arduino AVR platform: ${avrPackageError}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (builtInLibraryError) {
|
||||||
|
this.messageService.error(
|
||||||
|
`Could not install ${Arduino_BuiltIn} library: ${builtInLibraryError}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!avrPackageError && !builtInLibraryError) {
|
||||||
|
await this.localStorageService.setData(
|
||||||
|
FirstStartupInstaller.INIT_LIBS_AND_PACKAGES,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export namespace FirstStartupInstaller {
|
||||||
|
export const INIT_LIBS_AND_PACKAGES = 'initializedLibsAndPackages';
|
||||||
|
}
|
||||||
78
arduino-ide-extension/src/browser/contributions/format.ts
Normal file
78
arduino-ide-extension/src/browser/contributions/format.ts
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
import { MaybePromise } from '@theia/core';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import * as monaco from '@theia/monaco-editor-core';
|
||||||
|
import { Formatter } from '../../common/protocol/formatter';
|
||||||
|
import { InoSelector } from '../selectors';
|
||||||
|
import { Contribution, URI } from './contribution';
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class Format
|
||||||
|
extends Contribution
|
||||||
|
implements
|
||||||
|
monaco.languages.DocumentRangeFormattingEditProvider,
|
||||||
|
monaco.languages.DocumentFormattingEditProvider
|
||||||
|
{
|
||||||
|
@inject(Formatter)
|
||||||
|
private readonly formatter: Formatter;
|
||||||
|
|
||||||
|
override onStart(): MaybePromise<void> {
|
||||||
|
monaco.languages.registerDocumentRangeFormattingEditProvider(
|
||||||
|
InoSelector,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
monaco.languages.registerDocumentFormattingEditProvider(InoSelector, this);
|
||||||
|
}
|
||||||
|
async provideDocumentRangeFormattingEdits(
|
||||||
|
model: monaco.editor.ITextModel,
|
||||||
|
range: monaco.Range,
|
||||||
|
options: monaco.languages.FormattingOptions,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
_token: monaco.CancellationToken
|
||||||
|
): Promise<monaco.languages.TextEdit[]> {
|
||||||
|
const text = await this.format(model, range, options);
|
||||||
|
return [{ range, text }];
|
||||||
|
}
|
||||||
|
|
||||||
|
async provideDocumentFormattingEdits(
|
||||||
|
model: monaco.editor.ITextModel,
|
||||||
|
options: monaco.languages.FormattingOptions,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
_token: monaco.CancellationToken
|
||||||
|
): Promise<monaco.languages.TextEdit[]> {
|
||||||
|
const range = model.getFullModelRange();
|
||||||
|
const text = await this.format(model, range, options);
|
||||||
|
return [{ range, text }];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From the currently opened workspaces (IDE2 has always one), it calculates all possible
|
||||||
|
* folder locations where the `.clang-format` file could be.
|
||||||
|
*/
|
||||||
|
private formatterConfigFolderUris(model: monaco.editor.ITextModel): string[] {
|
||||||
|
const editorUri = new URI(model.uri.toString());
|
||||||
|
return this.workspaceService
|
||||||
|
.tryGetRoots()
|
||||||
|
.map(({ resource }) => resource)
|
||||||
|
.filter((workspaceUri) => workspaceUri.isEqualOrParent(editorUri))
|
||||||
|
.map((uri) => uri.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private format(
|
||||||
|
model: monaco.editor.ITextModel,
|
||||||
|
range: monaco.Range,
|
||||||
|
options: monaco.languages.FormattingOptions
|
||||||
|
): Promise<string> {
|
||||||
|
console.info(
|
||||||
|
`Formatting ${model.uri.toString()} [Range: ${JSON.stringify(
|
||||||
|
range.toJSON()
|
||||||
|
)}]`
|
||||||
|
);
|
||||||
|
const content = model.getValueInRange(range);
|
||||||
|
const formatterConfigFolderUris = this.formatterConfigFolderUris(model);
|
||||||
|
return this.formatter.format({
|
||||||
|
content,
|
||||||
|
formatterConfigFolderUris,
|
||||||
|
options,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { inject, injectable } from 'inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
|
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
|
||||||
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
||||||
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
||||||
@@ -14,6 +14,8 @@ import {
|
|||||||
} from './contribution';
|
} from './contribution';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import { nls } from '@theia/core/lib/common';
|
||||||
import { IDEUpdaterCommands } from '../ide-updater/ide-updater-commands';
|
import { IDEUpdaterCommands } from '../ide-updater/ide-updater-commands';
|
||||||
|
import { ElectronCommands } from '@theia/core/lib/electron-browser/menu/electron-menu-contribution';
|
||||||
|
import * as monaco from '@theia/monaco-editor-core';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class Help extends Contribution {
|
export class Help extends Contribution {
|
||||||
@@ -26,7 +28,7 @@ export class Help extends Contribution {
|
|||||||
@inject(QuickInputService)
|
@inject(QuickInputService)
|
||||||
protected readonly quickInputService: QuickInputService;
|
protected readonly quickInputService: QuickInputService;
|
||||||
|
|
||||||
registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
const open = (url: string) =>
|
const open = (url: string) =>
|
||||||
this.windowService.openNewWindow(url, { external: true });
|
this.windowService.openNewWindow(url, { external: true });
|
||||||
const createOpenHandler = (url: string) =>
|
const createOpenHandler = (url: string) =>
|
||||||
@@ -39,7 +41,9 @@ export class Help extends Contribution {
|
|||||||
);
|
);
|
||||||
registry.registerCommand(
|
registry.registerCommand(
|
||||||
Help.Commands.ENVIRONMENT,
|
Help.Commands.ENVIRONMENT,
|
||||||
createOpenHandler('https://www.arduino.cc/en/Guide/Environment')
|
createOpenHandler(
|
||||||
|
'https://docs.arduino.cc/software/ide-v2/tutorials/getting-started-ide-v2'
|
||||||
|
)
|
||||||
);
|
);
|
||||||
registry.registerCommand(
|
registry.registerCommand(
|
||||||
Help.Commands.TROUBLESHOOTING,
|
Help.Commands.TROUBLESHOOTING,
|
||||||
@@ -84,9 +88,17 @@ export class Help extends Contribution {
|
|||||||
Help.Commands.VISIT_ARDUINO,
|
Help.Commands.VISIT_ARDUINO,
|
||||||
createOpenHandler('https://www.arduino.cc/')
|
createOpenHandler('https://www.arduino.cc/')
|
||||||
);
|
);
|
||||||
|
registry.registerCommand(
|
||||||
|
Help.Commands.PRIVACY_POLICY,
|
||||||
|
createOpenHandler('https://www.arduino.cc/en/privacy-policy')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMenus(registry: MenuModelRegistry): void {
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
|
registry.unregisterMenuAction({
|
||||||
|
commandId: ElectronCommands.TOGGLE_DEVELOPER_TOOLS.id,
|
||||||
|
});
|
||||||
|
|
||||||
registry.registerMenuAction(ArduinoMenus.HELP__MAIN_GROUP, {
|
registry.registerMenuAction(ArduinoMenus.HELP__MAIN_GROUP, {
|
||||||
commandId: Help.Commands.GETTING_STARTED.id,
|
commandId: Help.Commands.GETTING_STARTED.id,
|
||||||
order: '0',
|
order: '0',
|
||||||
@@ -117,12 +129,16 @@ export class Help extends Contribution {
|
|||||||
order: '6',
|
order: '6',
|
||||||
});
|
});
|
||||||
registry.registerMenuAction(ArduinoMenus.HELP__FIND_GROUP, {
|
registry.registerMenuAction(ArduinoMenus.HELP__FIND_GROUP, {
|
||||||
commandId: IDEUpdaterCommands.CHECK_FOR_UPDATES.id,
|
commandId: Help.Commands.PRIVACY_POLICY.id,
|
||||||
order: '7',
|
order: '7',
|
||||||
});
|
});
|
||||||
|
registry.registerMenuAction(ArduinoMenus.HELP__FIND_GROUP, {
|
||||||
|
commandId: IDEUpdaterCommands.CHECK_FOR_UPDATES.id,
|
||||||
|
order: '8',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerKeybindings(registry: KeybindingRegistry): void {
|
override registerKeybindings(registry: KeybindingRegistry): void {
|
||||||
registry.registerKeybinding({
|
registry.registerKeybinding({
|
||||||
command: Help.Commands.FIND_IN_REFERENCE.id,
|
command: Help.Commands.FIND_IN_REFERENCE.id,
|
||||||
keybinding: 'CtrlCmd+Shift+F',
|
keybinding: 'CtrlCmd+Shift+F',
|
||||||
@@ -167,5 +183,10 @@ export namespace Help {
|
|||||||
label: nls.localize('arduino/help/visit', 'Visit Arduino.cc'),
|
label: nls.localize('arduino/help/visit', 'Visit Arduino.cc'),
|
||||||
category: 'Arduino',
|
category: 'Arduino',
|
||||||
};
|
};
|
||||||
|
export const PRIVACY_POLICY: Command = {
|
||||||
|
id: 'arduino-privacy-policy',
|
||||||
|
label: nls.localize('arduino/help/privacyPolicy', 'Privacy Policy'),
|
||||||
|
category: 'Arduino',
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import * as PQueue from 'p-queue';
|
import PQueue from 'p-queue';
|
||||||
import { inject, injectable } from 'inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import URI from '@theia/core/lib/common/uri';
|
import URI from '@theia/core/lib/common/uri';
|
||||||
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
|
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
|
||||||
import { EditorManager } from '@theia/editor/lib/browser';
|
|
||||||
import { MenuModelRegistry, MenuPath } from '@theia/core/lib/common/menu';
|
import { MenuModelRegistry, MenuPath } from '@theia/core/lib/common/menu';
|
||||||
import {
|
import {
|
||||||
Disposable,
|
Disposable,
|
||||||
@@ -16,45 +15,48 @@ import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
|||||||
import { SketchContribution, Command, CommandRegistry } from './contribution';
|
import { SketchContribution, Command, CommandRegistry } from './contribution';
|
||||||
import { NotificationCenter } from '../notification-center';
|
import { NotificationCenter } from '../notification-center';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import { nls } from '@theia/core/lib/common';
|
||||||
|
import * as monaco from '@theia/monaco-editor-core';
|
||||||
|
import { CurrentSketch } from '../sketches-service-client-impl';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class IncludeLibrary extends SketchContribution {
|
export class IncludeLibrary extends SketchContribution {
|
||||||
@inject(CommandRegistry)
|
@inject(CommandRegistry)
|
||||||
protected readonly commandRegistry: CommandRegistry;
|
private readonly commandRegistry: CommandRegistry;
|
||||||
|
|
||||||
@inject(MenuModelRegistry)
|
@inject(MenuModelRegistry)
|
||||||
protected readonly menuRegistry: MenuModelRegistry;
|
private readonly menuRegistry: MenuModelRegistry;
|
||||||
|
|
||||||
@inject(MainMenuManager)
|
@inject(MainMenuManager)
|
||||||
protected readonly mainMenuManager: MainMenuManager;
|
private readonly mainMenuManager: MainMenuManager;
|
||||||
|
|
||||||
@inject(EditorManager)
|
|
||||||
protected readonly editorManager: EditorManager;
|
|
||||||
|
|
||||||
@inject(NotificationCenter)
|
@inject(NotificationCenter)
|
||||||
protected readonly notificationCenter: NotificationCenter;
|
private readonly notificationCenter: NotificationCenter;
|
||||||
|
|
||||||
@inject(BoardsServiceProvider)
|
@inject(BoardsServiceProvider)
|
||||||
protected readonly boardsServiceClient: BoardsServiceProvider;
|
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
|
||||||
@inject(LibraryService)
|
@inject(LibraryService)
|
||||||
protected readonly libraryService: LibraryService;
|
private readonly libraryService: LibraryService;
|
||||||
|
|
||||||
protected readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
|
private readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
|
||||||
protected readonly toDispose = new DisposableCollection();
|
private readonly toDispose = new DisposableCollection();
|
||||||
|
|
||||||
onStart(): void {
|
override onStart(): void {
|
||||||
this.updateMenuActions();
|
this.boardsServiceProvider.onBoardsConfigDidChange(() =>
|
||||||
this.boardsServiceClient.onBoardsConfigChanged(() =>
|
|
||||||
this.updateMenuActions()
|
this.updateMenuActions()
|
||||||
);
|
);
|
||||||
this.notificationCenter.onLibraryInstalled(() => this.updateMenuActions());
|
this.notificationCenter.onLibraryDidInstall(() => this.updateMenuActions());
|
||||||
this.notificationCenter.onLibraryUninstalled(() =>
|
this.notificationCenter.onLibraryDidUninstall(() =>
|
||||||
this.updateMenuActions()
|
this.updateMenuActions()
|
||||||
);
|
);
|
||||||
|
this.notificationCenter.onDidReinitialize(() => this.updateMenuActions());
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMenus(registry: MenuModelRegistry): void {
|
override onReady(): void {
|
||||||
|
this.boardsServiceProvider.ready.then(() => this.updateMenuActions());
|
||||||
|
}
|
||||||
|
|
||||||
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
// `Include Library` submenu
|
// `Include Library` submenu
|
||||||
const includeLibMenuPath = [
|
const includeLibMenuPath = [
|
||||||
...ArduinoMenus.SKETCH__UTILS_GROUP,
|
...ArduinoMenus.SKETCH__UTILS_GROUP,
|
||||||
@@ -77,7 +79,7 @@ export class IncludeLibrary extends SketchContribution {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(IncludeLibrary.Commands.INCLUDE_LIBRARY, {
|
registry.registerCommand(IncludeLibrary.Commands.INCLUDE_LIBRARY, {
|
||||||
execute: async (arg) => {
|
execute: async (arg) => {
|
||||||
if (LibraryPackage.is(arg)) {
|
if (LibraryPackage.is(arg)) {
|
||||||
@@ -87,12 +89,12 @@ export class IncludeLibrary extends SketchContribution {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async updateMenuActions(): Promise<void> {
|
private async updateMenuActions(): Promise<void> {
|
||||||
return this.queue.add(async () => {
|
return this.queue.add(async () => {
|
||||||
this.toDispose.dispose();
|
this.toDispose.dispose();
|
||||||
this.mainMenuManager.update();
|
this.mainMenuManager.update();
|
||||||
const libraries: LibraryPackage[] = [];
|
const libraries: LibraryPackage[] = [];
|
||||||
const fqbn = this.boardsServiceClient.boardsConfig.selectedBoard?.fqbn;
|
const fqbn = this.boardsServiceProvider.boardsConfig.selectedBoard?.fqbn;
|
||||||
// Show all libraries, when no board is selected.
|
// Show all libraries, when no board is selected.
|
||||||
// Otherwise, show libraries only for the selected board.
|
// Otherwise, show libraries only for the selected board.
|
||||||
libraries.push(...(await this.libraryService.list({ fqbn })));
|
libraries.push(...(await this.libraryService.list({ fqbn })));
|
||||||
@@ -133,7 +135,7 @@ export class IncludeLibrary extends SketchContribution {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected registerLibrary(
|
private registerLibrary(
|
||||||
libraryOrPlaceholder: LibraryPackage | string,
|
libraryOrPlaceholder: LibraryPackage | string,
|
||||||
menuPath: MenuPath
|
menuPath: MenuPath
|
||||||
): Disposable {
|
): Disposable {
|
||||||
@@ -166,9 +168,9 @@ export class IncludeLibrary extends SketchContribution {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async includeLibrary(library: LibraryPackage): Promise<void> {
|
private async includeLibrary(library: LibraryPackage): Promise<void> {
|
||||||
const sketch = await this.sketchServiceClient.currentSketch();
|
const sketch = await this.sketchServiceClient.currentSketch();
|
||||||
if (!sketch) {
|
if (!CurrentSketch.isValid(sketch)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If the current editor is one of the additional files from the sketch, we use that.
|
// If the current editor is one of the additional files from the sketch, we use that.
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import { Progress } from '@theia/core/lib/common/message-service-protocol';
|
||||||
|
import { ProgressService } from '@theia/core/lib/common/progress-service';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { ProgressMessage } from '../../common/protocol';
|
||||||
|
import { NotificationCenter } from '../notification-center';
|
||||||
|
import { Contribution } from './contribution';
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class IndexesUpdateProgress extends Contribution {
|
||||||
|
@inject(NotificationCenter)
|
||||||
|
private readonly notificationCenter: NotificationCenter;
|
||||||
|
@inject(ProgressService)
|
||||||
|
private readonly progressService: ProgressService;
|
||||||
|
private currentProgress:
|
||||||
|
| (Progress & Readonly<{ progressId: string }>)
|
||||||
|
| undefined;
|
||||||
|
|
||||||
|
override onStart(): void {
|
||||||
|
this.notificationCenter.onIndexUpdateWillStart(({ progressId }) =>
|
||||||
|
this.getOrCreateProgress(progressId)
|
||||||
|
);
|
||||||
|
this.notificationCenter.onIndexUpdateDidProgress((progress) => {
|
||||||
|
this.getOrCreateProgress(progress).then((delegate) =>
|
||||||
|
delegate.report(progress)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
this.notificationCenter.onIndexUpdateDidComplete(({ progressId }) => {
|
||||||
|
this.cancelProgress(progressId);
|
||||||
|
});
|
||||||
|
this.notificationCenter.onIndexUpdateDidFail(({ progressId, message }) => {
|
||||||
|
this.cancelProgress(progressId);
|
||||||
|
this.messageService.error(message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getOrCreateProgress(
|
||||||
|
progressOrId: ProgressMessage | string
|
||||||
|
): Promise<Progress & { progressId: string }> {
|
||||||
|
const progressId = ProgressMessage.is(progressOrId)
|
||||||
|
? progressOrId.progressId
|
||||||
|
: progressOrId;
|
||||||
|
if (this.currentProgress?.progressId === progressId) {
|
||||||
|
return this.currentProgress;
|
||||||
|
}
|
||||||
|
if (this.currentProgress) {
|
||||||
|
this.currentProgress.cancel();
|
||||||
|
}
|
||||||
|
this.currentProgress = undefined;
|
||||||
|
const progress = await this.progressService.showProgress({
|
||||||
|
text: '',
|
||||||
|
options: { location: 'notification' },
|
||||||
|
});
|
||||||
|
if (ProgressMessage.is(progressOrId)) {
|
||||||
|
progress.report(progressOrId);
|
||||||
|
}
|
||||||
|
this.currentProgress = { ...progress, progressId };
|
||||||
|
return this.currentProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
private cancelProgress(progressId: string) {
|
||||||
|
if (this.currentProgress) {
|
||||||
|
if (this.currentProgress.progressId !== progressId) {
|
||||||
|
console.warn(
|
||||||
|
`Mismatching progress IDs. Expected ${progressId}, got ${this.currentProgress.progressId}. Canceling anyway.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
this.currentProgress.cancel();
|
||||||
|
this.currentProgress = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
359
arduino-ide-extension/src/browser/contributions/ino-language.ts
Normal file
359
arduino-ide-extension/src/browser/contributions/ino-language.ts
Normal file
@@ -0,0 +1,359 @@
|
|||||||
|
import {
|
||||||
|
Disposable,
|
||||||
|
DisposableCollection,
|
||||||
|
} from '@theia/core/lib/common/disposable';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { Mutex } from 'async-mutex';
|
||||||
|
import {
|
||||||
|
ArduinoDaemon,
|
||||||
|
BoardIdentifier,
|
||||||
|
BoardsService,
|
||||||
|
CompileSummary,
|
||||||
|
ExecutableService,
|
||||||
|
isBoardIdentifierChangeEvent,
|
||||||
|
sanitizeFqbn,
|
||||||
|
} from '../../common/protocol';
|
||||||
|
import {
|
||||||
|
defaultAsyncWorkers,
|
||||||
|
maxAsyncWorkers,
|
||||||
|
minAsyncWorkers,
|
||||||
|
} from '../arduino-preferences';
|
||||||
|
import { BoardsDataStore } from '../boards/boards-data-store';
|
||||||
|
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
||||||
|
import { HostedPluginEvents } from '../hosted/hosted-plugin-events';
|
||||||
|
import { NotificationCenter } from '../notification-center';
|
||||||
|
import { CurrentSketch } from '../sketches-service-client-impl';
|
||||||
|
import { SketchContribution, URI } from './contribution';
|
||||||
|
import { CompileSummaryProvider } from './verify-sketch';
|
||||||
|
|
||||||
|
interface DaemonAddress {
|
||||||
|
/**
|
||||||
|
* The host where the Arduino CLI daemon is available.
|
||||||
|
*/
|
||||||
|
readonly hostname: string;
|
||||||
|
/**
|
||||||
|
* The port where the Arduino CLI daemon is listening.
|
||||||
|
*/
|
||||||
|
readonly port: number;
|
||||||
|
/**
|
||||||
|
* The [id](https://arduino.github.io/arduino-cli/latest/rpc/commands/#instance) of the initialized core Arduino client instance.
|
||||||
|
*/
|
||||||
|
readonly instance: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StartLanguageServerParams {
|
||||||
|
/**
|
||||||
|
* Absolute filesystem path to the Arduino Language Server executable.
|
||||||
|
*/
|
||||||
|
readonly lsPath: string;
|
||||||
|
/**
|
||||||
|
* The hostname and the port for the gRPC channel connecting to the Arduino CLI daemon.
|
||||||
|
* The `instance` number is for the initialized core Arduino client.
|
||||||
|
*/
|
||||||
|
readonly daemonAddress: DaemonAddress;
|
||||||
|
/**
|
||||||
|
* Absolute filesystem path to [`clangd`](https://clangd.llvm.org/).
|
||||||
|
*/
|
||||||
|
readonly clangdPath: string;
|
||||||
|
/**
|
||||||
|
* The board is relevant to start a specific "flavor" of the language.
|
||||||
|
*/
|
||||||
|
readonly board: { fqbn: string; name?: string };
|
||||||
|
/**
|
||||||
|
* `true` if the LS should generate the log files into the default location. The default location is the `cwd` of the process.
|
||||||
|
* It's very often the same as the workspace root of the IDE, aka the sketch folder.
|
||||||
|
* When it is a string, it is the absolute filesystem path to the folder to generate the log files.
|
||||||
|
* If `string`, but the path is inaccessible, the log files will be generated into the default location.
|
||||||
|
*/
|
||||||
|
readonly log?: boolean | string;
|
||||||
|
/**
|
||||||
|
* Optional `env` for the language server process.
|
||||||
|
*/
|
||||||
|
readonly env?: NodeJS.ProcessEnv;
|
||||||
|
/**
|
||||||
|
* Additional flags for the Arduino Language server process.
|
||||||
|
*/
|
||||||
|
readonly flags?: readonly string[];
|
||||||
|
/**
|
||||||
|
* Set to `true`, to enable `Diagnostics`.
|
||||||
|
*/
|
||||||
|
readonly realTimeDiagnostics?: boolean;
|
||||||
|
/**
|
||||||
|
* If `true`, the logging is not forwarded to the _Output_ view via the language client.
|
||||||
|
*/
|
||||||
|
readonly silentOutput?: boolean;
|
||||||
|
/**
|
||||||
|
* Number of async workers used by `clangd`. Background index also uses this many workers. If `0`, `clangd` uses all available cores. It's `0` by default.
|
||||||
|
*/
|
||||||
|
readonly jobs?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The FQBN the language server runs with or `undefined` if it could not start.
|
||||||
|
*/
|
||||||
|
type StartLanguageServerResult = string | undefined;
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class InoLanguage extends SketchContribution {
|
||||||
|
@inject(HostedPluginEvents)
|
||||||
|
private readonly hostedPluginEvents: HostedPluginEvents;
|
||||||
|
@inject(ExecutableService)
|
||||||
|
private readonly executableService: ExecutableService;
|
||||||
|
@inject(ArduinoDaemon)
|
||||||
|
private readonly daemon: ArduinoDaemon;
|
||||||
|
@inject(BoardsService)
|
||||||
|
private readonly boardsService: BoardsService;
|
||||||
|
@inject(BoardsServiceProvider)
|
||||||
|
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
@inject(NotificationCenter)
|
||||||
|
private readonly notificationCenter: NotificationCenter;
|
||||||
|
@inject(BoardsDataStore)
|
||||||
|
private readonly boardDataStore: BoardsDataStore;
|
||||||
|
@inject(CompileSummaryProvider)
|
||||||
|
private readonly compileSummaryProvider: CompileSummaryProvider;
|
||||||
|
|
||||||
|
private readonly toDispose = new DisposableCollection();
|
||||||
|
private readonly languageServerStartMutex = new Mutex();
|
||||||
|
private languageServerFqbn?: string;
|
||||||
|
|
||||||
|
override onReady(): void {
|
||||||
|
const start = (
|
||||||
|
selectedBoard: BoardIdentifier | undefined,
|
||||||
|
forceStart = false
|
||||||
|
) => {
|
||||||
|
if (selectedBoard) {
|
||||||
|
const { name, fqbn } = selectedBoard;
|
||||||
|
if (fqbn) {
|
||||||
|
this.startLanguageServer(fqbn, name, forceStart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const forceRestart = () => {
|
||||||
|
start(this.boardsServiceProvider.boardsConfig.selectedBoard, true);
|
||||||
|
};
|
||||||
|
this.toDispose.pushAll([
|
||||||
|
this.boardsServiceProvider.onBoardsConfigDidChange((event) => {
|
||||||
|
if (isBoardIdentifierChangeEvent(event)) {
|
||||||
|
start(event.selectedBoard);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
this.hostedPluginEvents.onPluginsDidStart(() =>
|
||||||
|
start(this.boardsServiceProvider.boardsConfig.selectedBoard)
|
||||||
|
),
|
||||||
|
this.hostedPluginEvents.onPluginsWillUnload(
|
||||||
|
() => (this.languageServerFqbn = undefined)
|
||||||
|
),
|
||||||
|
this.preferences.onPreferenceChanged(
|
||||||
|
({ preferenceName, oldValue, newValue }) => {
|
||||||
|
if (oldValue !== newValue) {
|
||||||
|
switch (preferenceName) {
|
||||||
|
case 'arduino.language.log':
|
||||||
|
case 'arduino.language.realTimeDiagnostics':
|
||||||
|
case 'arduino.language.asyncWorkers':
|
||||||
|
forceRestart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
this.notificationCenter.onLibraryDidInstall(() => forceRestart()),
|
||||||
|
this.notificationCenter.onLibraryDidUninstall(() => forceRestart()),
|
||||||
|
this.notificationCenter.onPlatformDidInstall(() => forceRestart()),
|
||||||
|
this.notificationCenter.onPlatformDidUninstall(() => forceRestart()),
|
||||||
|
this.notificationCenter.onDidReinitialize(() => forceRestart()),
|
||||||
|
this.boardDataStore.onDidChange((event) => {
|
||||||
|
if (this.languageServerFqbn) {
|
||||||
|
const sanitizedFQBN = sanitizeFqbn(this.languageServerFqbn);
|
||||||
|
// The incoming FQBNs might contain custom boards configs, sanitize them before the comparison.
|
||||||
|
// https://github.com/arduino/arduino-ide/pull/2113#pullrequestreview-1499998328
|
||||||
|
const matchingChange = event.changes.find(
|
||||||
|
(change) => sanitizedFQBN === sanitizeFqbn(change.fqbn)
|
||||||
|
);
|
||||||
|
const { boardsConfig } = this.boardsServiceProvider;
|
||||||
|
if (
|
||||||
|
matchingChange &&
|
||||||
|
boardsConfig.selectedBoard?.fqbn === matchingChange.fqbn
|
||||||
|
) {
|
||||||
|
start(boardsConfig.selectedBoard);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
this.compileSummaryProvider.onDidChangeCompileSummary(
|
||||||
|
(compileSummary) => {
|
||||||
|
if (compileSummary) {
|
||||||
|
this.fireBuildDidComplete(compileSummary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
Promise.all([
|
||||||
|
this.boardsServiceProvider.ready,
|
||||||
|
this.preferences.ready,
|
||||||
|
]).then(() => {
|
||||||
|
start(this.boardsServiceProvider.boardsConfig.selectedBoard);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onStop(): void {
|
||||||
|
this.toDispose.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async startLanguageServer(
|
||||||
|
fqbn: string,
|
||||||
|
name: string | undefined,
|
||||||
|
forceStart = false
|
||||||
|
): Promise<void> {
|
||||||
|
const port = await this.daemon.tryGetPort();
|
||||||
|
if (typeof port !== 'number') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const release = await this.languageServerStartMutex.acquire();
|
||||||
|
const toDisposeOnRelease = new DisposableCollection();
|
||||||
|
try {
|
||||||
|
await this.hostedPluginEvents.didStart;
|
||||||
|
const details = await this.boardsService.getBoardDetails({ fqbn });
|
||||||
|
if (!details) {
|
||||||
|
// Core is not installed for the selected board.
|
||||||
|
console.info(
|
||||||
|
`Could not start language server for ${fqbn}. The core is not installed for the board.`
|
||||||
|
);
|
||||||
|
if (this.languageServerFqbn) {
|
||||||
|
try {
|
||||||
|
await this.commandService.executeCommand(
|
||||||
|
'arduino.languageserver.stop'
|
||||||
|
);
|
||||||
|
console.info(
|
||||||
|
`Stopped language server process for ${this.languageServerFqbn}.`
|
||||||
|
);
|
||||||
|
this.languageServerFqbn = undefined;
|
||||||
|
} catch (e) {
|
||||||
|
console.error(
|
||||||
|
`Failed to start language server process for ${this.languageServerFqbn}`,
|
||||||
|
e
|
||||||
|
);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const fqbnWithConfig = await this.boardDataStore.appendConfigToFqbn(fqbn);
|
||||||
|
if (!fqbnWithConfig) {
|
||||||
|
throw new Error(
|
||||||
|
`Failed to append boards config to the FQBN. Original FQBN was: ${fqbn}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!forceStart && fqbnWithConfig === this.languageServerFqbn) {
|
||||||
|
// NOOP
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const log = this.preferences.get('arduino.language.log');
|
||||||
|
const realTimeDiagnostics = this.preferences.get(
|
||||||
|
'arduino.language.realTimeDiagnostics'
|
||||||
|
);
|
||||||
|
const jobs = this.getAsyncWorkersPreferenceSafe();
|
||||||
|
this.logger.info(
|
||||||
|
`Starting language server: ${fqbnWithConfig}${
|
||||||
|
jobs ? ` (async worker count: ${jobs})` : ''
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
let currentSketchPath: string | undefined = undefined;
|
||||||
|
if (log) {
|
||||||
|
const currentSketch = await this.sketchServiceClient.currentSketch();
|
||||||
|
if (CurrentSketch.isValid(currentSketch)) {
|
||||||
|
currentSketchPath = await this.fileService.fsPath(
|
||||||
|
new URI(currentSketch.uri)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const { clangdUri, lsUri } = await this.executableService.list();
|
||||||
|
const [clangdPath, lsPath] = await Promise.all([
|
||||||
|
this.fileService.fsPath(new URI(clangdUri)),
|
||||||
|
this.fileService.fsPath(new URI(lsUri)),
|
||||||
|
]);
|
||||||
|
|
||||||
|
this.languageServerFqbn = await Promise.race([
|
||||||
|
new Promise<undefined>((_, reject) => {
|
||||||
|
const timer = setTimeout(
|
||||||
|
() => reject(new Error(`Timeout after ${20_000} ms.`)),
|
||||||
|
20_000
|
||||||
|
);
|
||||||
|
toDisposeOnRelease.push(Disposable.create(() => clearTimeout(timer)));
|
||||||
|
}),
|
||||||
|
this.start({
|
||||||
|
lsPath,
|
||||||
|
daemonAddress: {
|
||||||
|
hostname: 'localhost',
|
||||||
|
port,
|
||||||
|
instance: 1, // TODO: get it from the backend
|
||||||
|
},
|
||||||
|
clangdPath,
|
||||||
|
log: currentSketchPath ? currentSketchPath : log,
|
||||||
|
board: {
|
||||||
|
fqbn: fqbnWithConfig,
|
||||||
|
name,
|
||||||
|
},
|
||||||
|
realTimeDiagnostics,
|
||||||
|
silentOutput: true,
|
||||||
|
jobs,
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(`Failed to start language server. Original FQBN: ${fqbn}`, e);
|
||||||
|
this.languageServerFqbn = undefined;
|
||||||
|
} finally {
|
||||||
|
toDisposeOnRelease.dispose();
|
||||||
|
release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// The Theia preference UI validation is bogus.
|
||||||
|
// To restrict the number of jobs to a valid value.
|
||||||
|
private getAsyncWorkersPreferenceSafe(): number {
|
||||||
|
const jobs = this.preferences.get(
|
||||||
|
'arduino.language.asyncWorkers',
|
||||||
|
defaultAsyncWorkers
|
||||||
|
);
|
||||||
|
if (jobs < minAsyncWorkers) {
|
||||||
|
return minAsyncWorkers;
|
||||||
|
}
|
||||||
|
if (jobs > maxAsyncWorkers) {
|
||||||
|
return maxAsyncWorkers;
|
||||||
|
}
|
||||||
|
return jobs;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async start(
|
||||||
|
params: StartLanguageServerParams
|
||||||
|
): Promise<StartLanguageServerResult | undefined> {
|
||||||
|
return this.commandService.executeCommand<StartLanguageServerResult>(
|
||||||
|
'arduino.languageserver.start',
|
||||||
|
params
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute the a command contributed by the Arduino Tools VSIX to send the `ino/buildDidComplete` notification to the language server
|
||||||
|
private async fireBuildDidComplete(
|
||||||
|
compileSummary: CompileSummary
|
||||||
|
): Promise<void> {
|
||||||
|
const params = {
|
||||||
|
...compileSummary,
|
||||||
|
};
|
||||||
|
console.info(
|
||||||
|
`Executing 'arduino.languageserver.notifyBuildDidComplete' with ${JSON.stringify(
|
||||||
|
params.buildOutputUri
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.commandService.executeCommand(
|
||||||
|
'arduino.languageserver.notifyBuildDidComplete',
|
||||||
|
params
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(
|
||||||
|
`Unexpected error when firing event on build did complete. ${JSON.stringify(
|
||||||
|
params.buildOutputUri
|
||||||
|
)}`,
|
||||||
|
err
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
import { injectable } from '@theia/core/shared/inversify';
|
||||||
|
import {
|
||||||
|
Contribution,
|
||||||
|
Command,
|
||||||
|
MenuModelRegistry,
|
||||||
|
KeybindingRegistry,
|
||||||
|
} from './contribution';
|
||||||
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
|
import { CommandRegistry, MaybePromise, nls } from '@theia/core/lib/common';
|
||||||
|
import { Settings } from '../dialogs/settings/settings';
|
||||||
|
import debounce from 'lodash.debounce';
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class InterfaceScale extends Contribution {
|
||||||
|
private fontScalingEnabled: InterfaceScale.FontScalingEnabled = {
|
||||||
|
increase: true,
|
||||||
|
decrease: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
private currentSettings: Settings;
|
||||||
|
private updateSettingsDebounced = debounce(
|
||||||
|
async () => {
|
||||||
|
await this.settingsService.update(this.currentSettings);
|
||||||
|
await this.settingsService.save();
|
||||||
|
},
|
||||||
|
100,
|
||||||
|
{ maxWait: 200 }
|
||||||
|
);
|
||||||
|
|
||||||
|
override onStart(): MaybePromise<void> {
|
||||||
|
const updateCurrent = (settings: Settings) => {
|
||||||
|
this.currentSettings = settings;
|
||||||
|
this.updateFontScalingEnabled();
|
||||||
|
};
|
||||||
|
this.settingsService.onDidChange((settings) => updateCurrent(settings));
|
||||||
|
this.settingsService.settings().then((settings) => updateCurrent(settings));
|
||||||
|
}
|
||||||
|
|
||||||
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
|
registry.registerCommand(InterfaceScale.Commands.INCREASE_FONT_SIZE, {
|
||||||
|
execute: () => this.updateFontSize('increase'),
|
||||||
|
isEnabled: () => this.fontScalingEnabled.increase,
|
||||||
|
});
|
||||||
|
registry.registerCommand(InterfaceScale.Commands.DECREASE_FONT_SIZE, {
|
||||||
|
execute: () => this.updateFontSize('decrease'),
|
||||||
|
isEnabled: () => this.fontScalingEnabled.decrease,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
|
registry.registerMenuAction(ArduinoMenus.EDIT__FONT_CONTROL_GROUP, {
|
||||||
|
commandId: InterfaceScale.Commands.INCREASE_FONT_SIZE.id,
|
||||||
|
label: nls.localize(
|
||||||
|
'arduino/editor/increaseFontSize',
|
||||||
|
'Increase Font Size'
|
||||||
|
),
|
||||||
|
order: '0',
|
||||||
|
});
|
||||||
|
registry.registerMenuAction(ArduinoMenus.EDIT__FONT_CONTROL_GROUP, {
|
||||||
|
commandId: InterfaceScale.Commands.DECREASE_FONT_SIZE.id,
|
||||||
|
label: nls.localize(
|
||||||
|
'arduino/editor/decreaseFontSize',
|
||||||
|
'Decrease Font Size'
|
||||||
|
),
|
||||||
|
order: '1',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateFontScalingEnabled(): void {
|
||||||
|
let fontScalingEnabled = {
|
||||||
|
increase: true,
|
||||||
|
decrease: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (this.currentSettings.autoScaleInterface) {
|
||||||
|
fontScalingEnabled = {
|
||||||
|
increase:
|
||||||
|
this.currentSettings.interfaceScale + InterfaceScale.ZoomLevel.STEP <=
|
||||||
|
InterfaceScale.ZoomLevel.MAX,
|
||||||
|
decrease:
|
||||||
|
this.currentSettings.interfaceScale - InterfaceScale.ZoomLevel.STEP >=
|
||||||
|
InterfaceScale.ZoomLevel.MIN,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
fontScalingEnabled = {
|
||||||
|
increase:
|
||||||
|
this.currentSettings.editorFontSize + InterfaceScale.FontSize.STEP <=
|
||||||
|
InterfaceScale.FontSize.MAX,
|
||||||
|
decrease:
|
||||||
|
this.currentSettings.editorFontSize - InterfaceScale.FontSize.STEP >=
|
||||||
|
InterfaceScale.FontSize.MIN,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const isChanged = Object.keys(fontScalingEnabled).some(
|
||||||
|
(key: keyof InterfaceScale.FontScalingEnabled) =>
|
||||||
|
fontScalingEnabled[key] !== this.fontScalingEnabled[key]
|
||||||
|
);
|
||||||
|
if (isChanged) {
|
||||||
|
this.fontScalingEnabled = fontScalingEnabled;
|
||||||
|
this.menuManager.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateFontSize(mode: 'increase' | 'decrease'): void {
|
||||||
|
if (this.currentSettings.autoScaleInterface) {
|
||||||
|
mode === 'increase'
|
||||||
|
? (this.currentSettings.interfaceScale += InterfaceScale.ZoomLevel.STEP)
|
||||||
|
: (this.currentSettings.interfaceScale -=
|
||||||
|
InterfaceScale.ZoomLevel.STEP);
|
||||||
|
} else {
|
||||||
|
mode === 'increase'
|
||||||
|
? (this.currentSettings.editorFontSize += InterfaceScale.FontSize.STEP)
|
||||||
|
: (this.currentSettings.editorFontSize -= InterfaceScale.FontSize.STEP);
|
||||||
|
}
|
||||||
|
this.updateFontScalingEnabled();
|
||||||
|
this.updateSettingsDebounced();
|
||||||
|
}
|
||||||
|
|
||||||
|
override registerKeybindings(registry: KeybindingRegistry): void {
|
||||||
|
registry.registerKeybinding({
|
||||||
|
command: InterfaceScale.Commands.INCREASE_FONT_SIZE.id,
|
||||||
|
keybinding: 'CtrlCmd+=',
|
||||||
|
});
|
||||||
|
registry.registerKeybinding({
|
||||||
|
command: InterfaceScale.Commands.DECREASE_FONT_SIZE.id,
|
||||||
|
keybinding: 'CtrlCmd+-',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace InterfaceScale {
|
||||||
|
export namespace Commands {
|
||||||
|
export const INCREASE_FONT_SIZE: Command = {
|
||||||
|
id: 'arduino-increase-font-size',
|
||||||
|
};
|
||||||
|
export const DECREASE_FONT_SIZE: Command = {
|
||||||
|
id: 'arduino-decrease-font-size',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace ZoomLevel {
|
||||||
|
export const MIN = -8;
|
||||||
|
export const MAX = 9;
|
||||||
|
export const STEP = 1;
|
||||||
|
|
||||||
|
export function toPercentage(scale: number): number {
|
||||||
|
return scale * 20 + 100;
|
||||||
|
}
|
||||||
|
export function fromPercentage(percentage: number): number {
|
||||||
|
return (percentage - 100) / 20;
|
||||||
|
}
|
||||||
|
export namespace Step {
|
||||||
|
export function toPercentage(step: number): number {
|
||||||
|
return step * 20;
|
||||||
|
}
|
||||||
|
export function fromPercentage(percentage: number): number {
|
||||||
|
return percentage / 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace FontSize {
|
||||||
|
export const MIN = 8;
|
||||||
|
export const MAX = 72;
|
||||||
|
export const STEP = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FontScalingEnabled {
|
||||||
|
increase: boolean;
|
||||||
|
decrease: boolean;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
import { KeybindingRegistry } from '@theia/core/lib/browser/keybinding';
|
||||||
|
import { CompositeTreeNode } from '@theia/core/lib/browser/tree';
|
||||||
|
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
||||||
|
import { MenuModelRegistry } from '@theia/core/lib/common/menu';
|
||||||
|
import { Progress } from '@theia/core/lib/common/message-service-protocol';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { CreateUri } from '../create/create-uri';
|
||||||
|
import { Create, isConflict } from '../create/typings';
|
||||||
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
|
import {
|
||||||
|
TaskFactoryImpl,
|
||||||
|
WorkspaceInputDialogWithProgress,
|
||||||
|
} from '../theia/workspace/workspace-input-dialog';
|
||||||
|
import { CloudSketchbookTree } from '../widgets/cloud-sketchbook/cloud-sketchbook-tree';
|
||||||
|
import { CloudSketchbookTreeModel } from '../widgets/cloud-sketchbook/cloud-sketchbook-tree-model';
|
||||||
|
import { SketchbookCommands } from '../widgets/sketchbook/sketchbook-commands';
|
||||||
|
import {
|
||||||
|
CloudSketchContribution,
|
||||||
|
pullingSketch,
|
||||||
|
sketchAlreadyExists,
|
||||||
|
synchronizingSketchbook,
|
||||||
|
} from './cloud-contribution';
|
||||||
|
import { Command, CommandRegistry, Sketch } from './contribution';
|
||||||
|
|
||||||
|
export interface CreateNewCloudSketchCallback {
|
||||||
|
(
|
||||||
|
newSketch: Create.Sketch,
|
||||||
|
newNode: CloudSketchbookTree.CloudSketchDirNode,
|
||||||
|
progress: Progress
|
||||||
|
): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NewCloudSketchParams {
|
||||||
|
/**
|
||||||
|
* Value to populate the dialog `<input>` when it opens.
|
||||||
|
*/
|
||||||
|
readonly initialValue?: string | undefined;
|
||||||
|
/**
|
||||||
|
* Additional callback to call when the new cloud sketch has been created.
|
||||||
|
*/
|
||||||
|
readonly callback?: CreateNewCloudSketchCallback;
|
||||||
|
/**
|
||||||
|
* If `true`, the validation error message will not be visible in the input dialog, but the `OK` button will be disabled. Defaults to `true`.
|
||||||
|
*/
|
||||||
|
readonly skipShowErrorMessageOnOpen?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class NewCloudSketch extends CloudSketchContribution {
|
||||||
|
private readonly toDispose = new DisposableCollection();
|
||||||
|
|
||||||
|
override onReady(): void {
|
||||||
|
this.toDispose.pushAll([
|
||||||
|
this.createFeatures.onDidChangeEnabled(() => this.menuManager.update()),
|
||||||
|
this.createFeatures.onDidChangeSession(() => this.menuManager.update()),
|
||||||
|
]);
|
||||||
|
if (this.createFeatures.session) {
|
||||||
|
this.menuManager.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onStop(): void {
|
||||||
|
this.toDispose.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
|
registry.registerCommand(NewCloudSketch.Commands.NEW_CLOUD_SKETCH, {
|
||||||
|
execute: (params: NewCloudSketchParams) =>
|
||||||
|
this.createNewSketch(
|
||||||
|
params?.skipShowErrorMessageOnOpen === false ? false : true,
|
||||||
|
params?.initialValue,
|
||||||
|
params?.callback
|
||||||
|
),
|
||||||
|
isEnabled: () => Boolean(this.createFeatures.session),
|
||||||
|
isVisible: () => this.createFeatures.enabled,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
|
registry.registerMenuAction(ArduinoMenus.FILE__SKETCH_GROUP, {
|
||||||
|
commandId: NewCloudSketch.Commands.NEW_CLOUD_SKETCH.id,
|
||||||
|
label: nls.localize('arduino/cloudSketch/new', 'New Cloud Sketch'),
|
||||||
|
order: '1',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override registerKeybindings(registry: KeybindingRegistry): void {
|
||||||
|
registry.registerKeybinding({
|
||||||
|
command: NewCloudSketch.Commands.NEW_CLOUD_SKETCH.id,
|
||||||
|
keybinding: 'CtrlCmd+Alt+N',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async createNewSketch(
|
||||||
|
skipShowErrorMessageOnOpen: boolean,
|
||||||
|
initialValue?: string | undefined,
|
||||||
|
callback?: CreateNewCloudSketchCallback
|
||||||
|
): Promise<void> {
|
||||||
|
const treeModel = await this.treeModel();
|
||||||
|
if (treeModel) {
|
||||||
|
const rootNode = treeModel.root;
|
||||||
|
return this.openWizard(
|
||||||
|
rootNode,
|
||||||
|
treeModel,
|
||||||
|
skipShowErrorMessageOnOpen,
|
||||||
|
initialValue,
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async openWizard(
|
||||||
|
rootNode: CompositeTreeNode,
|
||||||
|
treeModel: CloudSketchbookTreeModel,
|
||||||
|
skipShowErrorMessageOnOpen: boolean,
|
||||||
|
initialValue?: string | undefined,
|
||||||
|
callback?: CreateNewCloudSketchCallback
|
||||||
|
): Promise<void> {
|
||||||
|
const existingNames = rootNode.children
|
||||||
|
.filter(CloudSketchbookTree.CloudSketchDirNode.is)
|
||||||
|
.map(({ fileStat }) => fileStat.name);
|
||||||
|
const taskFactory = new TaskFactoryImpl((value) =>
|
||||||
|
this.createNewSketchWithProgress(treeModel, value, callback)
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
const dialog = new WorkspaceInputDialogWithProgress(
|
||||||
|
{
|
||||||
|
title: nls.localize(
|
||||||
|
'arduino/newCloudSketch/newSketchTitle',
|
||||||
|
'Name of the new Cloud Sketch'
|
||||||
|
),
|
||||||
|
parentUri: CreateUri.root,
|
||||||
|
initialValue,
|
||||||
|
validate: (input) => {
|
||||||
|
if (existingNames.includes(input)) {
|
||||||
|
return sketchAlreadyExists(input);
|
||||||
|
}
|
||||||
|
return Sketch.validateCloudSketchFolderName(input) ?? '';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
this.labelProvider,
|
||||||
|
taskFactory
|
||||||
|
);
|
||||||
|
await dialog.open(skipShowErrorMessageOnOpen);
|
||||||
|
if (dialog.taskResult) {
|
||||||
|
this.openInNewWindow(dialog.taskResult);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (isConflict(err)) {
|
||||||
|
await treeModel.refresh();
|
||||||
|
return this.createNewSketch(
|
||||||
|
false,
|
||||||
|
taskFactory.value ?? initialValue,
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private createNewSketchWithProgress(
|
||||||
|
treeModel: CloudSketchbookTreeModel,
|
||||||
|
value: string,
|
||||||
|
callback?: CreateNewCloudSketchCallback
|
||||||
|
): (
|
||||||
|
progress: Progress
|
||||||
|
) => Promise<CloudSketchbookTree.CloudSketchDirNode | undefined> {
|
||||||
|
return async (progress: Progress) => {
|
||||||
|
progress.report({
|
||||||
|
message: nls.localize(
|
||||||
|
'arduino/cloudSketch/creating',
|
||||||
|
"Creating cloud sketch '{0}'...",
|
||||||
|
value
|
||||||
|
),
|
||||||
|
});
|
||||||
|
const sketch = await this.createApi.createSketch(value);
|
||||||
|
progress.report({ message: synchronizingSketchbook });
|
||||||
|
await treeModel.refresh();
|
||||||
|
progress.report({ message: pullingSketch(sketch.name) });
|
||||||
|
const node = await this.pull(sketch);
|
||||||
|
if (callback && node) {
|
||||||
|
await callback(sketch, node, progress);
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private openInNewWindow(
|
||||||
|
node: CloudSketchbookTree.CloudSketchDirNode
|
||||||
|
): Promise<void> {
|
||||||
|
return this.commandService.executeCommand(
|
||||||
|
SketchbookCommands.OPEN_NEW_WINDOW.id,
|
||||||
|
{ node, treeWidgetId: 'cloud-sketchbook-composite-widget' }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export namespace NewCloudSketch {
|
||||||
|
export namespace Commands {
|
||||||
|
export const NEW_CLOUD_SKETCH: Command = {
|
||||||
|
id: 'arduino-new-cloud-sketch',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import { nls } from '@theia/core/lib/common';
|
import { nls } from '@theia/core/lib/common';
|
||||||
import { injectable } from 'inversify';
|
import { injectable } from '@theia/core/shared/inversify';
|
||||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
import { ArduinoToolbar } from '../toolbar/arduino-toolbar';
|
|
||||||
import {
|
import {
|
||||||
SketchContribution,
|
SketchContribution,
|
||||||
URI,
|
URI,
|
||||||
@@ -9,49 +8,34 @@ import {
|
|||||||
CommandRegistry,
|
CommandRegistry,
|
||||||
MenuModelRegistry,
|
MenuModelRegistry,
|
||||||
KeybindingRegistry,
|
KeybindingRegistry,
|
||||||
TabBarToolbarRegistry,
|
|
||||||
} from './contribution';
|
} from './contribution';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class NewSketch extends SketchContribution {
|
export class NewSketch extends SketchContribution {
|
||||||
registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(NewSketch.Commands.NEW_SKETCH, {
|
registry.registerCommand(NewSketch.Commands.NEW_SKETCH, {
|
||||||
execute: () => this.newSketch(),
|
execute: () => this.newSketch(),
|
||||||
});
|
});
|
||||||
registry.registerCommand(NewSketch.Commands.NEW_SKETCH__TOOLBAR, {
|
|
||||||
isVisible: (widget) =>
|
|
||||||
ArduinoToolbar.is(widget) && widget.side === 'left',
|
|
||||||
execute: () => registry.executeCommand(NewSketch.Commands.NEW_SKETCH.id),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMenus(registry: MenuModelRegistry): void {
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
registry.registerMenuAction(ArduinoMenus.FILE__SKETCH_GROUP, {
|
registry.registerMenuAction(ArduinoMenus.FILE__SKETCH_GROUP, {
|
||||||
commandId: NewSketch.Commands.NEW_SKETCH.id,
|
commandId: NewSketch.Commands.NEW_SKETCH.id,
|
||||||
label: nls.localize('arduino/sketch/new', 'New'),
|
label: nls.localize('arduino/sketch/new', 'New Sketch'),
|
||||||
order: '0',
|
order: '0',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerKeybindings(registry: KeybindingRegistry): void {
|
override registerKeybindings(registry: KeybindingRegistry): void {
|
||||||
registry.registerKeybinding({
|
registry.registerKeybinding({
|
||||||
command: NewSketch.Commands.NEW_SKETCH.id,
|
command: NewSketch.Commands.NEW_SKETCH.id,
|
||||||
keybinding: 'CtrlCmd+N',
|
keybinding: 'CtrlCmd+N',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerToolbarItems(registry: TabBarToolbarRegistry): void {
|
|
||||||
registry.registerItem({
|
|
||||||
id: NewSketch.Commands.NEW_SKETCH__TOOLBAR.id,
|
|
||||||
command: NewSketch.Commands.NEW_SKETCH__TOOLBAR.id,
|
|
||||||
tooltip: nls.localize('arduino/sketch/new', 'New'),
|
|
||||||
priority: 3,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async newSketch(): Promise<void> {
|
async newSketch(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const sketch = await this.sketchService.createNewSketch();
|
const sketch = await this.sketchesService.createNewSketch();
|
||||||
this.workspaceService.open(new URI(sketch.uri));
|
this.workspaceService.open(new URI(sketch.uri));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await this.messageService.error(e.toString());
|
await this.messageService.error(e.toString());
|
||||||
@@ -64,8 +48,5 @@ export namespace NewSketch {
|
|||||||
export const NEW_SKETCH: Command = {
|
export const NEW_SKETCH: Command = {
|
||||||
id: 'arduino-new-sketch',
|
id: 'arduino-new-sketch',
|
||||||
};
|
};
|
||||||
export const NEW_SKETCH__TOOLBAR: Command = {
|
|
||||||
id: 'arduino-new-sketch--toolbar',
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import type { Command, CommandRegistry } from '@theia/core/lib/common/command';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import type { EditBoardsConfigActionParams } from '../../common/protocol/board-list';
|
||||||
|
import { BoardsConfigDialog } from '../boards/boards-config-dialog';
|
||||||
|
import { Contribution } from './contribution';
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class OpenBoardsConfig extends Contribution {
|
||||||
|
@inject(BoardsConfigDialog)
|
||||||
|
private readonly boardsConfigDialog: BoardsConfigDialog;
|
||||||
|
|
||||||
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
|
registry.registerCommand(OpenBoardsConfig.Commands.OPEN_DIALOG, {
|
||||||
|
execute: async (params?: EditBoardsConfigActionParams) =>
|
||||||
|
this.boardsConfigDialog.open(true, params),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export namespace OpenBoardsConfig {
|
||||||
|
export namespace Commands {
|
||||||
|
export const OPEN_DIALOG: Command = {
|
||||||
|
id: 'arduino-open-boards-dialog',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user