mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-10-24 18:48:33 +00:00
Compare commits
141 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da57c53700 | ||
|
|
527246b13f | ||
|
|
b178cefe0a | ||
|
|
cac351fa70 | ||
|
|
30d059afb9 | ||
|
|
c54fbc80e4 | ||
|
|
bb1dc74e33 | ||
|
|
470db5606e | ||
|
|
8c1ffe9c5f | ||
|
|
958e1591cf | ||
|
|
11da49ac18 | ||
|
|
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 |
121
.eslintrc.js
121
.eslintrc.js
@@ -1,63 +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-app/*',
|
'electron-app/lib/*',
|
||||||
'plugins/*',
|
'electron-app/src-gen/*',
|
||||||
'arduino-ide-extension/src/node/cli-protocol',
|
'electron-app/gen-webpack*.js',
|
||||||
|
'!electron-app/webpack.config.js',
|
||||||
|
'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',
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|||||||
2
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
2
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
name: Bug report
|
name: Bug report
|
||||||
description: Report a problem with the code or documentation in this repository.
|
description: Report a problem with the code or documentation in this repository.
|
||||||
labels:
|
labels:
|
||||||
- "type: imperfection"
|
- 'type: imperfection'
|
||||||
body:
|
body:
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: description
|
id: description
|
||||||
|
|||||||
2
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
2
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
name: Feature request
|
name: Feature request
|
||||||
description: Suggest an enhancement to this project.
|
description: Suggest an enhancement to this project.
|
||||||
labels:
|
labels:
|
||||||
- "type: enhancement"
|
- 'type: enhancement'
|
||||||
body:
|
body:
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: description
|
id: description
|
||||||
|
|||||||
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,15 +1,18 @@
|
|||||||
### Motivation
|
### Motivation
|
||||||
|
|
||||||
<!-- Why this pull request? -->
|
<!-- Why this pull request? -->
|
||||||
|
|
||||||
### Change description
|
### Change description
|
||||||
|
|
||||||
<!-- What does your code do? -->
|
<!-- What does your code do? -->
|
||||||
|
|
||||||
### Other information
|
### Other information
|
||||||
|
|
||||||
<!-- Any additional information that could help the review process -->
|
<!-- Any additional information that could help the review process -->
|
||||||
|
|
||||||
### Reviewer checklist
|
### Reviewer checklist
|
||||||
|
|
||||||
* [ ] PR addresses a single concern.
|
- [ ] 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)
|
- [ ] 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.
|
- [ ] PR title and description are properly filled.
|
||||||
* [ ] Docs have been added / updated (for bug fixes / features)
|
- [ ] Docs have been added / updated (for bug fixes / features)
|
||||||
|
|||||||
2
.github/dependabot.yml
vendored
2
.github/dependabot.yml
vendored
@@ -12,4 +12,4 @@ updates:
|
|||||||
schedule:
|
schedule:
|
||||||
interval: daily
|
interval: daily
|
||||||
labels:
|
labels:
|
||||||
- "topic: infrastructure"
|
- '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
|
||||||
|
|||||||
112
.github/workflows/assets/linux.Dockerfile
vendored
Normal file
112
.github/workflows/assets/linux.Dockerfile
vendored
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
# The Arduino IDE Linux build workflow job runs in this container.
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
FROM ubuntu:18.04
|
||||||
|
|
||||||
|
# See: https://unofficial-builds.nodejs.org/download/release/
|
||||||
|
ARG node_version="18.17.1"
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
apt-get \
|
||||||
|
--yes \
|
||||||
|
update
|
||||||
|
|
||||||
|
# This is required to get add-apt-repository
|
||||||
|
RUN \
|
||||||
|
apt-get \
|
||||||
|
--yes \
|
||||||
|
install \
|
||||||
|
"software-properties-common=0.96.24.32.22"
|
||||||
|
|
||||||
|
# Install Git
|
||||||
|
# The PPA is required to get a modern version of Git. The version in the Ubuntu 18.04 package repository is 2.17.1,
|
||||||
|
# while action/checkout@v3 requires 2.18 or higher.
|
||||||
|
RUN \
|
||||||
|
add-apt-repository \
|
||||||
|
--yes \
|
||||||
|
"ppa:git-core/ppa" && \
|
||||||
|
apt-get \
|
||||||
|
--yes \
|
||||||
|
update && \
|
||||||
|
\
|
||||||
|
apt-get \
|
||||||
|
--yes \
|
||||||
|
install \
|
||||||
|
"git" && \
|
||||||
|
\
|
||||||
|
apt-get \
|
||||||
|
--yes \
|
||||||
|
purge \
|
||||||
|
"software-properties-common"
|
||||||
|
|
||||||
|
# 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
|
||||||
|
# ubuntu:18.04 container.
|
||||||
|
RUN \
|
||||||
|
apt-get \
|
||||||
|
--yes \
|
||||||
|
install \
|
||||||
|
"python3.8-minimal=3.8.0-3ubuntu1~18.04.2" && \
|
||||||
|
\
|
||||||
|
ln \
|
||||||
|
--symbolic \
|
||||||
|
--force \
|
||||||
|
"$(which python3.8)" \
|
||||||
|
"/usr/bin/python3"
|
||||||
|
|
||||||
|
# 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-1" \
|
||||||
|
"libx11-dev=2:1.6.4-3ubuntu0.4" \
|
||||||
|
"libxkbfile-dev=1:1.0.9-2"
|
||||||
|
|
||||||
|
# Install Node.js
|
||||||
|
# It is necessary to use the "unofficial" linux-x64-glibc-217 build because the official Node.js 18.x is dynamically
|
||||||
|
# linked against glibc 2.28, while Ubuntu 18.04 has glibc 2.27.
|
||||||
|
ARG node_installation_path="/tmp/node-installation"
|
||||||
|
ARG artifact_name="node-v${node_version}-linux-x64-glibc-217"
|
||||||
|
RUN \
|
||||||
|
mkdir "$node_installation_path" && \
|
||||||
|
cd "$node_installation_path" && \
|
||||||
|
\
|
||||||
|
apt-get \
|
||||||
|
--yes \
|
||||||
|
install \
|
||||||
|
"wget=1.19.4-1ubuntu2.2" && \
|
||||||
|
\
|
||||||
|
archive_name="${artifact_name}.tar.xz" && \
|
||||||
|
wget \
|
||||||
|
"https://unofficial-builds.nodejs.org/download/release/v${node_version}/${archive_name}" && \
|
||||||
|
\
|
||||||
|
apt-get \
|
||||||
|
--yes \
|
||||||
|
purge \
|
||||||
|
"wget" && \
|
||||||
|
\
|
||||||
|
tar \
|
||||||
|
--file="$archive_name" \
|
||||||
|
--extract && \
|
||||||
|
rm "$archive_name"
|
||||||
|
ENV PATH="${PATH}:${node_installation_path}/${artifact_name}/bin"
|
||||||
|
|
||||||
|
# Install Yarn
|
||||||
|
# Yarn is pre-installed in the GitHub Actions hosted runner machines.
|
||||||
|
RUN \
|
||||||
|
npm \
|
||||||
|
install \
|
||||||
|
--global \
|
||||||
|
"yarn@1.22.19"
|
||||||
479
.github/workflows/build.yml
vendored
479
.github/workflows/build.yml
vendored
@@ -1,20 +1,28 @@
|
|||||||
name: Arduino IDE
|
name: Arduino IDE
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
create:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
- '[0-9]+.[0-9]+.x'
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '.github/**'
|
- '.github/**'
|
||||||
- '!.github/workflows/build.yml'
|
- '!.github/workflows/build.yml'
|
||||||
- '.vscode/**'
|
- '.vscode/**'
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
- 'scripts/**'
|
- 'scripts/**'
|
||||||
|
- '!scripts/merge-channel-files.js'
|
||||||
- 'static/**'
|
- 'static/**'
|
||||||
- '*.md'
|
- '*.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:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '.github/**'
|
- '.github/**'
|
||||||
@@ -22,65 +30,311 @@ on:
|
|||||||
- '.vscode/**'
|
- '.vscode/**'
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
- 'scripts/**'
|
- 'scripts/**'
|
||||||
|
- '!scripts/merge-channel-files.js'
|
||||||
- 'static/**'
|
- 'static/**'
|
||||||
- '*.md'
|
- '*.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:
|
||||||
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
||||||
GO_VERSION: "1.19"
|
GO_VERSION: '1.21'
|
||||||
|
# See: https://github.com/actions/setup-node/#readme
|
||||||
|
NODE_VERSION: '18.17'
|
||||||
JOB_TRANSFER_ARTIFACT: build-artifacts
|
JOB_TRANSFER_ARTIFACT: build-artifacts
|
||||||
CHANGELOG_ARTIFACTS: changelog
|
CHANGELOG_ARTIFACTS: changelog
|
||||||
|
STAGED_CHANNEL_FILES_ARTIFACT: staged-channel-files
|
||||||
|
BASE_BUILD_DATA: |
|
||||||
|
- config:
|
||||||
|
# Human identifier for the job.
|
||||||
|
name: Windows
|
||||||
|
runs-on: windows-2019
|
||||||
|
# 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: WINDOWS_SIGNING_CERTIFICATE_PFX
|
||||||
|
# Name of the secret that contains the certificate password.
|
||||||
|
certificate-password-secret: WINDOWS_SIGNING_CERTIFICATE_PASSWORD
|
||||||
|
# File extension for the certificate.
|
||||||
|
certificate-extension: pfx
|
||||||
|
# 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'
|
||||||
|
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\"
|
||||||
|
}
|
||||||
|
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-latest
|
||||||
|
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
|
||||||
|
mergeable-channel-file: 'true'
|
||||||
|
artifacts:
|
||||||
|
- path: '*macOS_64bit.dmg'
|
||||||
|
name: macOS_X86-64_dmg
|
||||||
|
- path: '*macOS_64bit.zip'
|
||||||
|
name: macOS_X86-64_zip
|
||||||
|
PAID_RUNNER_BUILD_DATA: |
|
||||||
|
- config:
|
||||||
|
name: macOS ARM
|
||||||
|
runs-on: macos-latest-xlarge
|
||||||
|
container: |
|
||||||
|
null
|
||||||
|
certificate-secret: APPLE_SIGNING_CERTIFICATE_P12
|
||||||
|
certificate-password-secret: KEYCHAIN_PASSWORD
|
||||||
|
certificate-extension: p12
|
||||||
|
mergeable-channel-file: 'true'
|
||||||
|
artifacts:
|
||||||
|
- path: '*macOS_arm64.dmg'
|
||||||
|
name: macOS_arm64_dmg
|
||||||
|
- path: '*macOS_arm64.zip'
|
||||||
|
name: macOS_arm64_zip
|
||||||
|
|
||||||
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 }}
|
||||||
|
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_SECRET_ACCESS_KEY != '' }}" >> $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 \
|
||||||
|
'[.[].artifacts.[]]'
|
||||||
|
)"
|
||||||
|
|
||||||
|
# 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 \
|
||||||
|
'[.[].artifacts.[]]'
|
||||||
|
)"
|
||||||
|
|
||||||
|
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:
|
||||||
name: build (${{ matrix.config.os }})
|
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
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
config:
|
config: ${{ fromJson(needs.select-targets.outputs.build-matrix) }}
|
||||||
- os: windows-2019
|
runs-on: ${{ matrix.config.runs-on }}
|
||||||
certificate-secret: WINDOWS_SIGNING_CERTIFICATE_PFX # Name of the secret that contains the certificate.
|
container: ${{ fromJSON(matrix.config.container) }}
|
||||||
certificate-password-secret: WINDOWS_SIGNING_CERTIFICATE_PASSWORD # Name of the secret that contains the certificate password.
|
defaults:
|
||||||
certificate-extension: pfx # File extension for the certificate.
|
run:
|
||||||
- os: ubuntu-18.04 # https://github.com/arduino/arduino-ide/issues/259
|
# Avoid problems caused by different default shell for container jobs (sh) vs non-container jobs (bash).
|
||||||
- os: macos-latest
|
shell: bash
|
||||||
# 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
|
|
||||||
runs-on: ${{ matrix.config.os }}
|
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
if: fromJSON(matrix.config.container) == null
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
# actions/checkout@v4 has dependency on a higher version of glibc than available in the Linux container.
|
||||||
|
if: fromJSON(matrix.config.container) != null
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install Node.js 16.x
|
- name: Install Node.js
|
||||||
uses: actions/setup-node@v3
|
if: fromJSON(matrix.config.container) == null
|
||||||
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '16.x'
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
cache: 'yarn'
|
||||||
|
|
||||||
- name: Install Python 3.x
|
- name: Install Python 3.x
|
||||||
uses: actions/setup-python@v4
|
if: fromJSON(matrix.config.container) == null
|
||||||
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.11.x'
|
||||||
|
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
|
if: fromJSON(matrix.config.container) == null
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
|
- name: Install Go
|
||||||
|
# actions/setup-go@v5 has dependency on a higher version of glibc than available in the Linux container.
|
||||||
|
if: fromJSON(matrix.config.container) != null
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
- name: Install Taskfile
|
- name: Install Taskfile
|
||||||
|
if: fromJSON(matrix.config.container) == null
|
||||||
|
uses: arduino/setup-task@v2
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
version: 3.x
|
||||||
|
|
||||||
|
- name: Install Taskfile
|
||||||
|
# actions/setup-task@v2 has dependency on a higher version of glibc than available in the Linux container.
|
||||||
|
if: fromJSON(matrix.config.container) != null
|
||||||
uses: arduino/setup-task@v1
|
uses: arduino/setup-task@v1
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
version: 3.x
|
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 }}
|
||||||
@@ -88,9 +342,14 @@ jobs:
|
|||||||
AC_TEAM_ID: ${{ secrets.AC_TEAM_ID }}
|
AC_TEAM_ID: ${{ secrets.AC_TEAM_ID }}
|
||||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
IS_NIGHTLY: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') }}
|
IS_NIGHTLY: ${{ needs.build-type-determination.outputs.is-nightly }}
|
||||||
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }}
|
IS_RELEASE: ${{ needs.build-type-determination.outputs.is-release }}
|
||||||
CAN_SIGN: ${{ secrets[matrix.config.certificate-secret] != '' }}
|
CAN_SIGN: ${{ secrets[matrix.config.certificate-secret] != '' }}
|
||||||
|
# The CREATE_* environment vars are only used to run tests. 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: |
|
run: |
|
||||||
# See: https://www.electron.build/code-signing
|
# See: https://www.electron.build/code-signing
|
||||||
if [ $CAN_SIGN = false ]; then
|
if [ $CAN_SIGN = false ]; then
|
||||||
@@ -99,44 +358,128 @@ jobs:
|
|||||||
export CSC_LINK="${{ runner.temp }}/signing_certificate.${{ matrix.config.certificate-extension }}"
|
export CSC_LINK="${{ runner.temp }}/signing_certificate.${{ matrix.config.certificate-extension }}"
|
||||||
echo "${{ secrets[matrix.config.certificate-secret] }}" | base64 --decode > "$CSC_LINK"
|
echo "${{ secrets[matrix.config.certificate-secret] }}" | base64 --decode > "$CSC_LINK"
|
||||||
export CSC_KEY_PASSWORD="${{ secrets[matrix.config.certificate-password-secret] }}"
|
export CSC_KEY_PASSWORD="${{ secrets[matrix.config.certificate-password-secret] }}"
|
||||||
|
export CSC_FOR_PULL_REQUEST=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${{ runner.OS }}" = "Windows" ]; then
|
|
||||||
npm config set msvs_version 2017 --global
|
|
||||||
fi
|
|
||||||
npx node-gyp install
|
npx node-gyp install
|
||||||
yarn --cwd ./electron/packager/
|
yarn install --immutable
|
||||||
yarn --cwd ./electron/packager/ package
|
|
||||||
|
yarn --cwd arduino-ide-extension build
|
||||||
|
yarn test
|
||||||
|
yarn --cwd arduino-ide-extension test:slow
|
||||||
|
yarn --cwd arduino-ide-extension lint
|
||||||
|
|
||||||
|
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'
|
||||||
|
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@v3
|
||||||
|
if: >
|
||||||
|
needs.select-targets.outputs.merge-channel-files == 'true' &&
|
||||||
|
matrix.config.mergeable-channel-file == 'true'
|
||||||
|
with:
|
||||||
|
if-no-files-found: error
|
||||||
|
name: ${{ env.STAGED_CHANNEL_FILES_ARTIFACT }}
|
||||||
|
path: ${{ env.STAGED_CHANNEL_FILES_PATH }}
|
||||||
|
|
||||||
- name: Upload [GitHub Actions]
|
- name: Upload [GitHub Actions]
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
|
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
|
||||||
path: electron/build/dist/build-artifacts/
|
path: ${{ 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@v4
|
||||||
|
|
||||||
|
- name: Download staged-for-merge channel files artifact
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{ env.STAGED_CHANNEL_FILES_ARTIFACT }}
|
||||||
|
path: ${{ env.CHANNEL_FILES_PATH }}
|
||||||
|
|
||||||
|
- name: Remove no longer needed artifact
|
||||||
|
uses: geekyeggo/delete-artifact@v2
|
||||||
|
with:
|
||||||
|
name: ${{ env.STAGED_CHANNEL_FILES_ARTIFACT }}
|
||||||
|
|
||||||
|
- 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
|
||||||
|
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 to job transfer artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
if-no-files-found: error
|
||||||
|
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
|
||||||
|
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
|
||||||
|
|
||||||
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
|
||||||
@@ -152,20 +495,22 @@ jobs:
|
|||||||
path: ${{ env.JOB_TRANSFER_ARTIFACT }}/${{ matrix.artifact.path }}
|
path: ${{ env.JOB_TRANSFER_ARTIFACT }}/${{ 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@v3
|
uses: actions/checkout@v4
|
||||||
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')
|
||||||
@@ -191,15 +536,27 @@ jobs:
|
|||||||
echo "$BODY" > CHANGELOG.txt
|
echo "$BODY" > CHANGELOG.txt
|
||||||
|
|
||||||
- name: Upload Changelog [GitHub Actions]
|
- name: Upload Changelog [GitHub Actions]
|
||||||
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@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
|
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
|
||||||
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
|
||||||
steps:
|
steps:
|
||||||
- name: Download [GitHub Actions]
|
- name: Download [GitHub Actions]
|
||||||
@@ -219,8 +576,19 @@ jobs:
|
|||||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
|
||||||
release:
|
release:
|
||||||
needs: changelog
|
needs:
|
||||||
if: 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
|
||||||
steps:
|
steps:
|
||||||
- name: Download [GitHub Actions]
|
- name: Download [GitHub Actions]
|
||||||
@@ -235,7 +603,7 @@ jobs:
|
|||||||
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Publish Release [GitHub]
|
- name: Publish Release [GitHub]
|
||||||
uses: svenstaro/upload-release-action@2.5.0
|
uses: svenstaro/upload-release-action@2.7.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 }}
|
||||||
@@ -245,7 +613,7 @@ jobs:
|
|||||||
body: ${{ needs.changelog.outputs.BODY }}
|
body: ${{ needs.changelog.outputs.BODY }}
|
||||||
|
|
||||||
- name: Publish Release [S3]
|
- name: Publish Release [S3]
|
||||||
if: github.repository == 'arduino/arduino-ide'
|
if: needs.build-type-determination.outputs.publish-to-s3 == 'true'
|
||||||
uses: docker://plugins/s3
|
uses: docker://plugins/s3
|
||||||
env:
|
env:
|
||||||
PLUGIN_SOURCE: '${{ env.JOB_TRANSFER_ARTIFACT }}/*'
|
PLUGIN_SOURCE: '${{ env.JOB_TRANSFER_ARTIFACT }}/*'
|
||||||
@@ -259,6 +627,7 @@ jobs:
|
|||||||
# 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
|
||||||
|
|||||||
46
.github/workflows/check-certificates.yml
vendored
46
.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
|
||||||
|
|||||||
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@v4
|
||||||
|
|
||||||
|
- name: Build and push to local registry
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
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 }}
|
||||||
46
.github/workflows/check-i18n-task.yml
vendored
46
.github/workflows/check-i18n-task.yml
vendored
@@ -2,10 +2,11 @@ name: Check Internationalization
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
||||||
GO_VERSION: "1.19"
|
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'
|
||||||
@@ -22,32 +23,61 @@ 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@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Node.js 16.x
|
- name: Install Node.js 18.17
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '16.x'
|
node-version: '18.17'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
cache: 'yarn'
|
||||||
|
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
- name: Install Taskfile
|
- name: Install Taskfile
|
||||||
uses: arduino/setup-task@v1
|
uses: arduino/setup-task@v2
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
version: 3.x
|
version: 3.x
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn
|
run: yarn install --immutable
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
|||||||
8
.github/workflows/compose-full-changelog.yml
vendored
8
.github/workflows/compose-full-changelog.yml
vendored
@@ -8,7 +8,7 @@ on:
|
|||||||
env:
|
env:
|
||||||
CHANGELOG_ARTIFACTS: changelog
|
CHANGELOG_ARTIFACTS: changelog
|
||||||
# See: https://github.com/actions/setup-node/#readme
|
# See: https://github.com/actions/setup-node/#readme
|
||||||
NODE_VERSION: 16.x
|
NODE_VERSION: '18.17'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
create-changelog:
|
create-changelog:
|
||||||
@@ -16,10 +16,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
@@ -32,7 +32,7 @@ jobs:
|
|||||||
- name: Create full changelog
|
- name: Create full changelog
|
||||||
id: full-changelog
|
id: full-changelog
|
||||||
run: |
|
run: |
|
||||||
yarn add @octokit/rest --ignore-workspace-root-check
|
yarn add @octokit/rest@19.0.13 --ignore-workspace-root-check
|
||||||
mkdir "${{ github.workspace }}/${{ env.CHANGELOG_ARTIFACTS }}"
|
mkdir "${{ github.workspace }}/${{ env.CHANGELOG_ARTIFACTS }}"
|
||||||
|
|
||||||
# Get the changelog file name to build
|
# Get the changelog file name to build
|
||||||
|
|||||||
17
.github/workflows/i18n-nightly-push.yml
vendored
17
.github/workflows/i18n-nightly-push.yml
vendored
@@ -2,7 +2,7 @@ name: i18n-nightly-push
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
||||||
GO_VERSION: "1.19"
|
GO_VERSION: '1.21'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
@@ -14,27 +14,28 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Node.js 16.x
|
- name: Install Node.js 18.17
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '16.x'
|
node-version: '18.17'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
cache: 'yarn'
|
||||||
|
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
- name: Install Task
|
- name: Install Task
|
||||||
uses: arduino/setup-task@v1
|
uses: arduino/setup-task@v2
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
version: 3.x
|
version: 3.x
|
||||||
|
|
||||||
- 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
|
||||||
|
|||||||
19
.github/workflows/i18n-weekly-pull.yml
vendored
19
.github/workflows/i18n-weekly-pull.yml
vendored
@@ -2,7 +2,7 @@ name: i18n-weekly-pull
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
||||||
GO_VERSION: "1.19"
|
GO_VERSION: '1.21'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
@@ -14,27 +14,28 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Node.js 16.x
|
- name: Install Node.js 18.17
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '16.x'
|
node-version: '18.17'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
cache: 'yarn'
|
||||||
|
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
- name: Install Task
|
- name: Install Task
|
||||||
uses: arduino/setup-task@v1
|
uses: arduino/setup-task@v2
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
version: 3.x
|
version: 3.x
|
||||||
|
|
||||||
- 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
|
||||||
@@ -45,7 +46,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@v4
|
uses: peter-evans/create-pull-request@v5
|
||||||
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@v4
|
||||||
|
|
||||||
|
- 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@v5
|
||||||
|
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 }}
|
||||||
14
.github/workflows/sync-labels.yml
vendored
14
.github/workflows/sync-labels.yml
vendored
@@ -5,15 +5,15 @@ 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:
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Download JSON schema for labels configuration file
|
- name: Download JSON schema for labels configuration file
|
||||||
id: download-schema
|
id: download-schema
|
||||||
@@ -106,7 +106,7 @@ jobs:
|
|||||||
echo "flag=--dry-run" >> $GITHUB_OUTPUT
|
echo "flag=--dry-run" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Download configuration files artifact
|
- name: Download configuration files artifact
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
|
|||||||
17
.github/workflows/themes-weekly-pull.yml
vendored
17
.github/workflows/themes-weekly-pull.yml
vendored
@@ -8,35 +8,36 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
|
||||||
GO_VERSION: "1.19"
|
GO_VERSION: '1.21'
|
||||||
NODE_VERSION: 16.x
|
NODE_VERSION: '18.17'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pull-from-jsonbin:
|
pull-from-jsonbin:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
cache: 'yarn'
|
||||||
|
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
- name: Install Task
|
- name: Install Task
|
||||||
uses: arduino/setup-task@v1
|
uses: arduino/setup-task@v2
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
version: 3.x
|
version: 3.x
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn
|
run: yarn install --immutable
|
||||||
|
|
||||||
- name: Run themes:pull script
|
- name: Run themes:pull script
|
||||||
run: yarn run themes:pull
|
run: yarn run themes:pull
|
||||||
@@ -54,7 +55,7 @@ jobs:
|
|||||||
run: yarn run themes:generate
|
run: yarn run themes:generate
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v4
|
uses: peter-evans/create-pull-request@v5
|
||||||
with:
|
with:
|
||||||
commit-message: Updated themes
|
commit-message: Updated themes
|
||||||
title: Update themes
|
title: Update themes
|
||||||
|
|||||||
13
.gitignore
vendored
13
.gitignore
vendored
@@ -1,25 +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
|
||||||
arduino-ide-extension/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 tokens folder for the themes
|
# the tokens folder for the themes
|
||||||
scripts/themes/tokens
|
scripts/themes/tokens
|
||||||
# environment variables
|
|
||||||
.env
|
|
||||||
# content trace files for electron
|
# content trace files for electron
|
||||||
electron-app/traces
|
electron-app/traces
|
||||||
# any Arduino LS generated log files
|
# any Arduino LS generated log files
|
||||||
inols*.log
|
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,7 +0,0 @@
|
|||||||
{
|
|
||||||
"singleQuote": true,
|
|
||||||
"tabWidth": 2,
|
|
||||||
"useTabs": false,
|
|
||||||
"printWidth": 80,
|
|
||||||
"endOfLine": "auto"
|
|
||||||
}
|
|
||||||
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
72
.vscode/launch.json
vendored
72
.vscode/launch.json
vendored
@@ -4,35 +4,33 @@
|
|||||||
{
|
{
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "App (Electron) [Dev]",
|
"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",
|
||||||
"args": [
|
"args": [
|
||||||
".",
|
".",
|
||||||
"--log-level=debug",
|
"--log-level=debug",
|
||||||
"--hostname=localhost",
|
"--hostname=localhost",
|
||||||
"--app-project-path=${workspaceRoot}/electron-app",
|
"--app-project-path=${workspaceFolder}/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",
|
||||||
"--content-trace",
|
"--no-ping-timeout"
|
||||||
"--open-devtools",
|
|
||||||
"--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,
|
"smartStep": true,
|
||||||
"internalConsoleOptions": "openOnSessionStart",
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
@@ -41,33 +39,35 @@
|
|||||||
{
|
{
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "App (Electron)",
|
"name": "App [Dev]",
|
||||||
"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",
|
||||||
"args": [
|
"args": [
|
||||||
".",
|
".",
|
||||||
"--log-level=debug",
|
"--log-level=debug",
|
||||||
"--hostname=localhost",
|
"--hostname=localhost",
|
||||||
"--app-project-path=${workspaceRoot}/electron-app",
|
"--app-project-path=${workspaceFolder}/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",
|
"--content-trace",
|
||||||
|
"--open-devtools",
|
||||||
|
"--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,
|
"smartStep": true,
|
||||||
"internalConsoleOptions": "openOnSessionStart",
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
"type": "node",
|
"type": "node",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"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",
|
||||||
@@ -94,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,
|
||||||
@@ -107,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"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@@ -7,6 +7,6 @@
|
|||||||
},
|
},
|
||||||
"typescript.tsdk": "node_modules/typescript/lib",
|
"typescript.tsdk": "node_modules/typescript/lib",
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": true
|
"source.fixAll.eslint": "explicit"
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
.vscode/tasks.json
vendored
18
.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,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Arduino IDE - Watch IDE Extension",
|
"label": "Watch Extension",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "yarn --cwd ./arduino-ide-extension watch",
|
"command": "yarn --cwd ./arduino-ide-extension watch",
|
||||||
"group": "build",
|
"group": "build",
|
||||||
@@ -24,7 +27,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Arduino IDE - Watch Electron App",
|
"label": "Watch App",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "yarn --cwd ./electron-app watch",
|
"command": "yarn --cwd ./electron-app watch",
|
||||||
"group": "build",
|
"group": "build",
|
||||||
@@ -35,12 +38,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Arduino IDE - Watch All [Electron]",
|
"label": "Watch All",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"dependsOn": [
|
"dependsOn": ["Watch Extension", "Watch App"]
|
||||||
"Arduino IDE - Watch IDE Extension",
|
|
||||||
"Arduino IDE - Watch Electron App"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
[](https://github.com/arduino/arduino-ide/actions?query=workflow%3A%22Arduino+IDE%22)
|
[](https://github.com/arduino/arduino-ide/actions?query=workflow%3A%22Arduino+IDE%22)
|
||||||
|
|
||||||
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 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.
|
||||||
|
|
||||||
|
|||||||
@@ -55,12 +55,14 @@ 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**
|
### Update **clangd** and **ClangFormat**
|
||||||
|
|
||||||
@@ -72,11 +74,13 @@ The [**clangd** C++ language server](https://clangd.llvm.org/) and the [**ClangF
|
|||||||
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).
|
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
|
||||||
|
|||||||
@@ -1,83 +1,83 @@
|
|||||||
{
|
{
|
||||||
"name": "arduino-ide-extension",
|
"name": "arduino-ide-extension",
|
||||||
"version": "2.0.5",
|
"version": "2.3.2",
|
||||||
"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-i18n && 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-i18n": "npx ncp ../i18n ./build/i18n",
|
"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:slow": "mocha \"./lib/test/**/*.slow-test.js\" --slow 5000",
|
"test:slow": "cross-env IDE2_TEST=true mocha \"./lib/test/**/*.slow-test.js\" --slow 5000"
|
||||||
"test:watch": "mocha --watch --watch-files lib \"./lib/test/**/*.test.js\""
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.8.14",
|
||||||
"@theia/application-package": "1.31.1",
|
"@theia/application-package": "1.41.0",
|
||||||
"@theia/core": "1.31.1",
|
"@theia/core": "1.41.0",
|
||||||
"@theia/debug": "1.31.1",
|
"@theia/debug": "1.41.0",
|
||||||
"@theia/editor": "1.31.1",
|
"@theia/editor": "1.41.0",
|
||||||
"@theia/electron": "1.31.1",
|
"@theia/electron": "1.41.0",
|
||||||
"@theia/filesystem": "1.31.1",
|
"@theia/filesystem": "1.41.0",
|
||||||
"@theia/keymaps": "1.31.1",
|
"@theia/keymaps": "1.41.0",
|
||||||
"@theia/markers": "1.31.1",
|
"@theia/markers": "1.41.0",
|
||||||
"@theia/messages": "1.31.1",
|
"@theia/messages": "1.41.0",
|
||||||
"@theia/monaco": "1.31.1",
|
"@theia/monaco": "1.41.0",
|
||||||
"@theia/monaco-editor-core": "1.67.2",
|
"@theia/monaco-editor-core": "1.72.3",
|
||||||
"@theia/navigator": "1.31.1",
|
"@theia/navigator": "1.41.0",
|
||||||
"@theia/outline-view": "1.31.1",
|
"@theia/outline-view": "1.41.0",
|
||||||
"@theia/output": "1.31.1",
|
"@theia/output": "1.41.0",
|
||||||
"@theia/plugin-ext": "1.31.1",
|
"@theia/plugin-ext": "1.41.0",
|
||||||
"@theia/preferences": "1.31.1",
|
"@theia/preferences": "1.41.0",
|
||||||
"@theia/scm": "1.31.1",
|
"@theia/scm": "1.41.0",
|
||||||
"@theia/search-in-workspace": "1.31.1",
|
"@theia/search-in-workspace": "1.41.0",
|
||||||
"@theia/terminal": "1.31.1",
|
"@theia/terminal": "1.41.0",
|
||||||
"@theia/typehierarchy": "1.31.1",
|
"@theia/typehierarchy": "1.41.0",
|
||||||
"@theia/workspace": "1.31.1",
|
"@theia/workspace": "1.41.0",
|
||||||
"@tippyjs/react": "^4.2.5",
|
"@tippyjs/react": "^4.2.5",
|
||||||
"@types/auth0-js": "^9.14.0",
|
"@types/auth0-js": "^9.21.3",
|
||||||
"@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": "^7.2.0",
|
|
||||||
"@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/node-fetch": "^2.5.7",
|
"@types/node-fetch": "^2.5.7",
|
||||||
"@types/p-queue": "^2.3.1",
|
"@types/p-queue": "^2.3.1",
|
||||||
"@types/ps-tree": "^1.1.0",
|
"@types/ps-tree": "^1.1.0",
|
||||||
"@types/react-tabs": "^2.3.2",
|
"@types/react-tabs": "^2.3.2",
|
||||||
"@types/temp": "^0.8.34",
|
"@types/temp": "^0.8.34",
|
||||||
"@types/which": "^1.3.1",
|
|
||||||
"@vscode/debugprotocol": "^1.51.0",
|
|
||||||
"arduino-serial-plotter-webapp": "0.2.0",
|
"arduino-serial-plotter-webapp": "0.2.0",
|
||||||
"async-mutex": "^0.3.0",
|
"async-mutex": "^0.3.0",
|
||||||
"auth0-js": "^9.14.0",
|
"auth0-js": "^9.23.2",
|
||||||
"btoa": "^1.2.1",
|
"btoa": "^1.2.1",
|
||||||
"classnames": "^2.3.1",
|
"classnames": "^2.3.1",
|
||||||
"cpy": "^8.1.2",
|
|
||||||
"cross-fetch": "^3.1.5",
|
"cross-fetch": "^3.1.5",
|
||||||
"dateformat": "^3.0.3",
|
"dateformat": "^3.0.3",
|
||||||
"deepmerge": "2.0.1",
|
"deepmerge": "^4.2.2",
|
||||||
|
"drivelist": "^9.2.4",
|
||||||
"electron-updater": "^4.6.5",
|
"electron-updater": "^4.6.5",
|
||||||
|
"fast-deep-equal": "^3.1.3",
|
||||||
"fast-json-stable-stringify": "^2.1.0",
|
"fast-json-stable-stringify": "^2.1.0",
|
||||||
"fast-safe-stringify": "^2.1.1",
|
"fast-safe-stringify": "^2.1.1",
|
||||||
"filename-reserved-regex": "^2.0.0",
|
"filename-reserved-regex": "^2.0.0",
|
||||||
"glob": "^7.1.6",
|
"glob": "^7.1.6",
|
||||||
"google-protobuf": "^3.20.1",
|
"google-protobuf": "^3.20.1",
|
||||||
"hash.js": "^1.1.7",
|
"hash.js": "^1.1.7",
|
||||||
"is-online": "^9.0.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",
|
"jsonc-parser": "^2.2.0",
|
||||||
"just-diff": "^5.1.1",
|
"just-diff": "^5.1.1",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
@@ -85,9 +85,11 @@
|
|||||||
"lodash.debounce": "^4.0.8",
|
"lodash.debounce": "^4.0.8",
|
||||||
"minimatch": "^3.1.2",
|
"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-debounce": "^2.1.0",
|
"p-debounce": "^2.1.0",
|
||||||
"p-queue": "^2.4.2",
|
"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.1",
|
"react-disable": "^0.1.1",
|
||||||
@@ -101,33 +103,31 @@
|
|||||||
"temp": "^0.9.1",
|
"temp": "^0.9.1",
|
||||||
"temp-dir": "^2.0.0",
|
"temp-dir": "^2.0.0",
|
||||||
"tree-kill": "^1.2.1",
|
"tree-kill": "^1.2.1",
|
||||||
"which": "^1.3.1"
|
"util": "^0.12.5",
|
||||||
|
"vscode-arduino-api": "^0.1.2"
|
||||||
},
|
},
|
||||||
"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",
|
||||||
|
"@xhmikosr/downloader": "^13.0.1",
|
||||||
"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-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",
|
||||||
"ncp": "^2.0.0",
|
"ncp": "^2.0.0",
|
||||||
"protoc": "^1.0.4",
|
"rimraf": "^2.6.1"
|
||||||
"shelljs": "^0.8.3",
|
|
||||||
"uuid": "^3.2.1",
|
|
||||||
"yargs": "^11.1.0"
|
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"grpc-tools": "^1.9.0"
|
"grpc-tools": "^1.12.4",
|
||||||
|
"protoc": "^1.0.4"
|
||||||
},
|
},
|
||||||
"mocha": {
|
"mocha": {
|
||||||
"require": [
|
"require": [
|
||||||
@@ -147,6 +147,9 @@
|
|||||||
"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"
|
||||||
@@ -157,26 +160,25 @@
|
|||||||
{
|
{
|
||||||
"frontendElectron": "lib/electron-browser/theia/core/electron-window-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": {
|
"version": "0.35.3"
|
||||||
"owner": "arduino",
|
|
||||||
"repo": "arduino-cli",
|
|
||||||
"commitish": "71a8576"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"fwuploader": {
|
"arduino-fwuploader": {
|
||||||
"version": "2.2.2"
|
"version": "2.4.1"
|
||||||
|
},
|
||||||
|
"arduino-language-server": {
|
||||||
|
"version": "0.7.6"
|
||||||
},
|
},
|
||||||
"clangd": {
|
"clangd": {
|
||||||
"version": "14.0.0"
|
"version": "14.0.0"
|
||||||
},
|
|
||||||
"languageServer": {
|
|
||||||
"version": "0.7.4"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const shell = require('shelljs');
|
|
||||||
const semver = require('semver');
|
const semver = require('semver');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
const downloader = require('./downloader');
|
const downloader = require('./downloader');
|
||||||
@@ -19,7 +18,7 @@
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { cli } = arduino;
|
const cli = arduino['arduino-cli'];
|
||||||
if (!cli) {
|
if (!cli) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -29,14 +28,20 @@
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
if (!version) {
|
if (!version) {
|
||||||
shell.echo(`Could not retrieve CLI version info from the 'package.json'.`);
|
console.log(`Could not retrieve CLI 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 cliName = `arduino-cli${platform === 'win32' ? '.exe' : ''}`;
|
const cliName = `arduino-cli${platform === 'win32' ? '.exe' : ''}`;
|
||||||
const destinationPath = path.join(buildFolder, cliName);
|
const destinationPath = path.join(resourcesFolder, cliName);
|
||||||
|
|
||||||
if (typeof version === 'string') {
|
if (typeof version === 'string') {
|
||||||
const suffix = (() => {
|
const suffix = (() => {
|
||||||
@@ -65,24 +70,24 @@
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
if (!suffix) {
|
if (!suffix) {
|
||||||
shell.echo(`The CLI is not available for ${platform} ${arch}.`);
|
console.log(`The CLI 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-cli/arduino-cli_${version}_${suffix}`;
|
const url = `https://downloads.arduino.cc/arduino-cli/arduino-cli_${version}_${suffix}`;
|
||||||
shell.echo(
|
console.log(
|
||||||
`📦 Identified released version of the CLI. Downloading version ${version} from '${url}'`
|
`📦 Identified released version of the CLI. Downloading version ${version} from '${url}'`
|
||||||
);
|
);
|
||||||
await downloader.downloadUnzipFile(url, destinationPath, 'arduino-cli');
|
await downloader.downloadUnzipFile(url, destinationPath, 'arduino-cli');
|
||||||
} else if (moment(version, 'YYYYMMDD', true).isValid()) {
|
} else if (moment(version, 'YYYYMMDD', true).isValid()) {
|
||||||
const url = `https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-${version}_${suffix}`;
|
const url = `https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-${version}_${suffix}`;
|
||||||
shell.echo(
|
console.log(
|
||||||
`🌙 Identified nightly version of the CLI. Downloading version ${version} from '${url}'`
|
`🌙 Identified nightly version of the CLI. Downloading version ${version} from '${url}'`
|
||||||
);
|
);
|
||||||
await downloader.downloadUnzipFile(url, destinationPath, 'arduino-cli');
|
await downloader.downloadUnzipFile(url, destinationPath, 'arduino-cli');
|
||||||
} else {
|
} else {
|
||||||
shell.echo(`🔥 Could not interpret 'version': ${version}`);
|
console.log(`🔥 Could not interpret 'version': ${version}`);
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
taskBuildFromGit(version, destinationPath, 'CLI');
|
taskBuildFromGit(version, destinationPath, 'CLI');
|
||||||
|
|||||||
@@ -1,38 +1,61 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
// The version to use.
|
// The version to use.
|
||||||
const version = '1.10.0';
|
const version = '1.10.1';
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const os = require('os');
|
const os = require('node:os');
|
||||||
const { promises: fs } = require('fs');
|
const {
|
||||||
const path = require('path');
|
existsSync,
|
||||||
const shell = require('shelljs');
|
promises: fs,
|
||||||
const { v4 } = require('uuid');
|
mkdirSync,
|
||||||
|
readdirSync,
|
||||||
|
cpSync,
|
||||||
|
} = require('node:fs');
|
||||||
|
const path = require('node:path');
|
||||||
|
const { exec } = require('./utils');
|
||||||
|
|
||||||
const repository = path.join(os.tmpdir(), `${v4()}-arduino-examples`);
|
const destination = path.join(
|
||||||
if (shell.mkdir('-p', repository).code !== 0) {
|
__dirname,
|
||||||
shell.exit(1);
|
'..',
|
||||||
|
'src',
|
||||||
|
'node',
|
||||||
|
'resources',
|
||||||
|
'Examples'
|
||||||
|
);
|
||||||
|
if (existsSync(destination)) {
|
||||||
|
console.log(
|
||||||
|
`Skipping Git checkout of the examples because the repository already exists: ${destination}`
|
||||||
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
const repository = await fs.mkdtemp(
|
||||||
shell.exec(
|
path.join(os.tmpdir(), 'arduino-examples-')
|
||||||
`git clone https://github.com/arduino/arduino-examples.git ${repository}`
|
);
|
||||||
).code !== 0
|
|
||||||
) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
exec(
|
||||||
shell.exec(`git -C ${repository} checkout tags/${version} -b ${version}`)
|
'git',
|
||||||
.code !== 0
|
['clone', 'https://github.com/arduino/arduino-examples.git', repository],
|
||||||
) {
|
{ logStdout: true }
|
||||||
shell.exit(1);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
const destination = path.join(__dirname, '..', 'Examples');
|
exec(
|
||||||
shell.mkdir('-p', destination);
|
'git',
|
||||||
shell.cp('-fR', path.join(repository, 'examples', '*'), destination);
|
['-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) => {
|
const isSketch = async (pathLike) => {
|
||||||
try {
|
try {
|
||||||
@@ -92,5 +115,5 @@ const version = '1.10.0';
|
|||||||
JSON.stringify(examples, null, 2),
|
JSON.stringify(examples, null, 2),
|
||||||
{ encoding: 'utf8' }
|
{ encoding: 'utf8' }
|
||||||
);
|
);
|
||||||
shell.echo(`Generated output to ${path.join(destination, 'examples.json')}`);
|
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,7 +5,6 @@
|
|||||||
|
|
||||||
(() => {
|
(() => {
|
||||||
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 { goBuildFromGit } = require('./utils');
|
||||||
|
|
||||||
@@ -16,7 +15,8 @@
|
|||||||
const { arduino } = pkg;
|
const { arduino } = pkg;
|
||||||
if (!arduino) return [undefined, undefined];
|
if (!arduino) return [undefined, undefined];
|
||||||
|
|
||||||
const { languageServer, clangd } = arduino;
|
const { clangd } = arduino;
|
||||||
|
const languageServer = arduino['arduino-language-server'];
|
||||||
if (!languageServer) return [undefined, undefined];
|
if (!languageServer) return [undefined, undefined];
|
||||||
if (!clangd) return [undefined, undefined];
|
if (!clangd) return [undefined, undefined];
|
||||||
|
|
||||||
@@ -24,20 +24,20 @@
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
if (!DEFAULT_LS_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_LS_VERSION,
|
default: DEFAULT_LS_VERSION,
|
||||||
@@ -62,35 +62,50 @@
|
|||||||
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, clangFormatExecutablePath, 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(build, 'clang-format');
|
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':
|
case 'darwin-arm64':
|
||||||
clangdExecutablePath = path.join(build, 'clangd');
|
clangdExecutablePath = path.join(resourcesFolder, 'clangd');
|
||||||
clangFormatExecutablePath = path.join(build, 'clang-format');
|
clangFormatExecutablePath = path.join(resourcesFolder, 'clang-format');
|
||||||
lsSuffix = 'macOS_ARM64.tar.gz';
|
lsSuffix = 'macOS_ARM64.tar.gz';
|
||||||
clangdSuffix = 'macOS_ARM64';
|
clangdSuffix = 'macOS_ARM64';
|
||||||
break;
|
break;
|
||||||
case 'linux-x64':
|
case 'linux-x64':
|
||||||
clangdExecutablePath = path.join(build, 'clangd');
|
clangdExecutablePath = path.join(resourcesFolder, 'clangd');
|
||||||
clangFormatExecutablePath = path.join(build, 'clang-format');
|
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(build, 'clang-format.exe');
|
clangFormatExecutablePath = path.join(
|
||||||
|
resourcesFolder,
|
||||||
|
'clang-format.exe'
|
||||||
|
);
|
||||||
lsSuffix = 'Windows_64bit.zip';
|
lsSuffix = 'Windows_64bit.zip';
|
||||||
clangdSuffix = 'Windows_64bit';
|
clangdSuffix = 'Windows_64bit';
|
||||||
break;
|
break;
|
||||||
@@ -98,10 +113,10 @@
|
|||||||
throw new Error(`Unsupported platform/arch: ${platformArch}.`);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof lsVersion === 'string') {
|
if (typeof lsVersion === 'string') {
|
||||||
@@ -110,20 +125,31 @@
|
|||||||
? 'nightly/arduino-language-server'
|
? 'nightly/arduino-language-server'
|
||||||
: 'arduino-language-server_' + lsVersion
|
: 'arduino-language-server_' + lsVersion
|
||||||
}_${lsSuffix}`;
|
}_${lsSuffix}`;
|
||||||
downloader.downloadUnzipAll(lsUrl, build, lsExecutablePath, force);
|
downloader.downloadUnzipAll(
|
||||||
|
lsUrl,
|
||||||
|
resourcesFolder,
|
||||||
|
lsExecutablePath,
|
||||||
|
force
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
goBuildFromGit(lsVersion, lsExecutablePath, 'language-server');
|
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`;
|
const clangdFormatUrl = `https://downloads.arduino.cc/tools/clang-format_${clangdVersion}_${clangdSuffix}.tar.bz2`;
|
||||||
downloader.downloadUnzipAll(
|
downloader.downloadUnzipAll(
|
||||||
clangdFormatUrl,
|
clangdFormatUrl,
|
||||||
build,
|
resourcesFolder,
|
||||||
clangFormatExecutablePath,
|
clangFormatExecutablePath,
|
||||||
force,
|
force,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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,7 +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}
|
* @param decompressOptions {import('decompress').DecompressOptions|undefined} [decompressOptions]
|
||||||
*/
|
*/
|
||||||
exports.downloadUnzipAll = async (
|
exports.downloadUnzipAll = async (
|
||||||
url,
|
url,
|
||||||
@@ -96,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()],
|
||||||
};
|
};
|
||||||
@@ -119,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,156 +1,193 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
const os = require('node:os');
|
||||||
|
const path = require('node:path');
|
||||||
|
const { mkdirSync, promises: fs } = require('node:fs');
|
||||||
|
const { exec } = require('./utils');
|
||||||
|
const glob = require('glob');
|
||||||
|
const { SemVer, gte, valid: validSemVer } = require('semver');
|
||||||
|
const protoc = path.dirname(require('protoc/protoc'));
|
||||||
|
|
||||||
const os = require('os');
|
const repository = await fs.mkdtemp(path.join(os.tmpdir(), 'arduino-cli-'));
|
||||||
const path = require('path');
|
|
||||||
const glob = require('glob');
|
|
||||||
const { v4 } = require('uuid');
|
|
||||||
const shell = require('shelljs');
|
|
||||||
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`);
|
const { owner, repo, commitish } = (() => {
|
||||||
if (shell.mkdir('-p', repository).code !== 0) {
|
const pkg = require(path.join(__dirname, '..', 'package.json'));
|
||||||
shell.exit(1);
|
if (!pkg) {
|
||||||
|
console.log(`Could not parse the 'package.json'.`);
|
||||||
|
process.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 build = path.join(__dirname, '..', 'build');
|
|
||||||
const cli = path.join(build, `arduino-cli${platform === 'win32' ? '.exe' : ''}`);
|
|
||||||
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.
|
|
||||||
// - `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",
|
|
||||||
"VersionString": "nightly-20210126",
|
|
||||||
"Commit": "079bb6c6",
|
|
||||||
"Status": "alpha",
|
|
||||||
"Date": "2021-01-26T01:46:31Z"
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
const versionObject = JSON.parse(versionJson);
|
|
||||||
const version = versionObject.VersionString;
|
|
||||||
if (version && !version.startsWith('nightly-') && version !== '0.0.0-git' && version !== 'git-snapshot') {
|
|
||||||
shell.echo(`>>> Checking out tagged version: '${version}'...`);
|
|
||||||
shell.exec(`git -C ${repository} fetch --all --tags`);
|
|
||||||
if (shell.exec(`git -C ${repository} checkout tags/${version} -b ${version}`).code !== 0) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
shell.echo(`<<< Checked out tagged version: '${commitish}'.`);
|
|
||||||
} else if (commitish) {
|
|
||||||
shell.echo(`>>> Checking out commitish from 'package.json': '${commitish}'...`);
|
|
||||||
if (shell.exec(`git -C ${repository} checkout ${commitish}`).code !== 0) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
|
||||||
shell.echo(`<<< Checked out commitish from 'package.json': '${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 {
|
|
||||||
shell.echo(`WARN: no 'git checkout'. Generating from the HEAD revision.`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.echo('>>> Generating TS/JS API from:');
|
const cli = arduino['arduino-cli'];
|
||||||
if (shell.exec(`git -C ${repository} rev-parse --abbrev-ref HEAD`).code !== 0) {
|
if (!cli) {
|
||||||
shell.exit(1);
|
return defaultVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rpc = path.join(repository, 'rpc');
|
const { version } = cli;
|
||||||
const out = path.join(__dirname, '..', 'src', 'node', 'cli-protocol');
|
if (!version) {
|
||||||
shell.mkdir('-p', out);
|
return defaultVersion;
|
||||||
|
|
||||||
const protos = await new Promise(resolve =>
|
|
||||||
glob('**/*.proto', { cwd: rpc }, (error, matches) => {
|
|
||||||
if (error) {
|
|
||||||
shell.echo(error.stack);
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate JS code from the `.proto` files.
|
if (typeof version === 'string') {
|
||||||
if (shell.exec(`grpc_tools_node_protoc \
|
return defaultVersion;
|
||||||
--js_out=import_style=commonjs,binary:${out} \
|
|
||||||
--grpc_out=generate_package_definition:${out} \
|
|
||||||
-I ${rpc} \
|
|
||||||
${protos.join(' ')}`).code !== 0) {
|
|
||||||
shell.exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the `.d.ts` files for JS.
|
// We assume an object with `owner`, `repo`, commitish?` properties.
|
||||||
if (shell.exec(`protoc \
|
const { owner, repo, commitish } = version;
|
||||||
--plugin=protoc-gen-ts=${path.resolve(__dirname, '..', 'node_modules', '.bin', `protoc-gen-ts${platform === 'win32' ? '.cmd' : ''}`)} \
|
if (!owner) {
|
||||||
--ts_out=generate_package_definition:${out} \
|
console.log(`Could not retrieve 'owner' from ${JSON.stringify(version)}`);
|
||||||
-I ${rpc} \
|
process.exit(1);
|
||||||
${protos.join(' ')}`).code !== 0) {
|
}
|
||||||
shell.exit(1);
|
if (!repo) {
|
||||||
|
console.log(`Could not retrieve 'repo' from ${JSON.stringify(version)}`);
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.echo('<<< Generation was successful.');
|
return { owner, repo, commitish };
|
||||||
|
})();
|
||||||
|
|
||||||
|
const url = `https://github.com/${owner}/${repo}.git`;
|
||||||
|
console.log(`>>> Cloning repository from '${url}'...`);
|
||||||
|
exec('git', ['clone', url, repository], { logStdout: true });
|
||||||
|
console.log(`<<< Repository cloned.`);
|
||||||
|
|
||||||
|
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",
|
||||||
|
"VersionString": "nightly-20210126",
|
||||||
|
"Commit": "079bb6c6",
|
||||||
|
"Status": "alpha",
|
||||||
|
"Date": "2021-01-26T01:46:31Z"
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
const versionObject = JSON.parse(versionJson);
|
||||||
|
let version = versionObject.VersionString;
|
||||||
|
if (validSemVer(version)) {
|
||||||
|
// https://github.com/arduino/arduino-cli/pull/2374
|
||||||
|
if (gte(new SemVer(version, { loose: true }), new SemVer('0.35.0-rc.1'))) {
|
||||||
|
version = `v${version}`;
|
||||||
|
}
|
||||||
|
console.log(`>>> Checking out tagged version: '${version}'...`);
|
||||||
|
exec('git', ['-C', repository, 'fetch', '--all', '--tags'], {
|
||||||
|
logStdout: true,
|
||||||
|
});
|
||||||
|
exec(
|
||||||
|
'git',
|
||||||
|
['-C', repository, 'checkout', `tags/${version}`, '-b', version],
|
||||||
|
{ logStdout: true }
|
||||||
|
);
|
||||||
|
console.log(`<<< Checked out tagged version: '${version}'.`);
|
||||||
|
} else if (commitish) {
|
||||||
|
console.log(
|
||||||
|
`>>> Checking out commitish from 'package.json': '${commitish}'...`
|
||||||
|
);
|
||||||
|
exec('git', ['-C', repository, 'checkout', commitish], { logStdout: true });
|
||||||
|
console.log(
|
||||||
|
`<<< Checked out commitish from 'package.json': '${commitish}'.`
|
||||||
|
);
|
||||||
|
} else if (versionObject.Commit) {
|
||||||
|
console.log(
|
||||||
|
`>>> Checking out commitish from the CLI: '${versionObject.Commit}'...`
|
||||||
|
);
|
||||||
|
exec('git', ['-C', repository, 'checkout', versionObject.Commit], {
|
||||||
|
logStdout: true,
|
||||||
|
});
|
||||||
|
console.log(
|
||||||
|
`<<< Checked out commitish from the CLI: '${versionObject.Commit}'.`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log(`WARN: no 'git checkout'. Generating from the HEAD revision.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('>>> Generating TS/JS API from:');
|
||||||
|
exec('git', ['-C', repository, 'rev-parse', '--abbrev-ref', 'HEAD'], {
|
||||||
|
logStdout: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const rpc = path.join(repository, 'rpc');
|
||||||
|
const out = path.join(__dirname, '..', 'src', 'node', 'cli-protocol');
|
||||||
|
mkdirSync(out, { recursive: true });
|
||||||
|
|
||||||
|
const protos = await new Promise((resolve) =>
|
||||||
|
glob('**/*.proto', { cwd: rpc }, (error, matches) => {
|
||||||
|
if (error) {
|
||||||
|
console.log(error.stack ?? error.message);
|
||||||
|
resolve([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve(matches.map((filename) => path.join(rpc, filename)));
|
||||||
|
})
|
||||||
|
);
|
||||||
|
if (!protos || protos.length === 0) {
|
||||||
|
console.log(`Could not find any .proto files under ${rpc}.`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate JS code from the `.proto` files.
|
||||||
|
exec(
|
||||||
|
'grpc_tools_node_protoc',
|
||||||
|
[
|
||||||
|
`--js_out=import_style=commonjs,binary:${out}`,
|
||||||
|
`--grpc_out=generate_package_definition:${out}`,
|
||||||
|
'-I',
|
||||||
|
rpc,
|
||||||
|
...protos,
|
||||||
|
],
|
||||||
|
{ logStdout: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
// Generate the `.d.ts` files for JS.
|
||||||
|
exec(
|
||||||
|
path.join(protoc, `protoc${platform === 'win32' ? '.exe' : ''}`),
|
||||||
|
[
|
||||||
|
`--plugin=protoc-gen-ts=${path.resolve(
|
||||||
|
__dirname,
|
||||||
|
'..',
|
||||||
|
'node_modules',
|
||||||
|
'.bin',
|
||||||
|
`protoc-gen-ts${platform === 'win32' ? '.cmd' : ''}`
|
||||||
|
)}`,
|
||||||
|
`--ts_out=generate_package_definition:${out}`,
|
||||||
|
'-I',
|
||||||
|
rpc,
|
||||||
|
...protos,
|
||||||
|
],
|
||||||
|
{ logStdout: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log('<<< Generation was successful.');
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1,3 +1,28 @@
|
|||||||
|
// @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/).
|
* Clones something from GitHub and builds it with [`Task`](https://taskfile.dev/).
|
||||||
*
|
*
|
||||||
@@ -21,90 +46,98 @@ exports.goBuildFromGit = (version, destinationPath, taskName) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `command` is either `go` or `task`.
|
* 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) {
|
function buildFromGit(command, version, destinationPath, taskName) {
|
||||||
const fs = require('fs');
|
const fs = require('node:fs');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
const temp = require('temp');
|
const temp = require('temp');
|
||||||
const shell = require('shelljs');
|
|
||||||
|
|
||||||
// We assume an object with `owner`, `repo`, commitish?` properties.
|
// We assume an object with `owner`, `repo`, commitish?` properties.
|
||||||
if (typeof version !== 'object') {
|
if (typeof version !== 'object') {
|
||||||
shell.echo(
|
console.log(
|
||||||
`Expected a \`{ owner, repo, commitish }\` object. Got <${version}> instead.`
|
`Expected a \`{ owner, repo, commitish }\` object. Got <${version}> instead.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const { owner, repo, commitish } = version;
|
const { owner, repo, commitish } = version;
|
||||||
if (!owner) {
|
if (!owner) {
|
||||||
shell.echo(`Could not retrieve 'owner' from ${JSON.stringify(version)}`);
|
console.log(`Could not retrieve 'owner' from ${JSON.stringify(version)}`);
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
if (!repo) {
|
if (!repo) {
|
||||||
shell.echo(`Could not retrieve 'repo' from ${JSON.stringify(version)}`);
|
console.log(`Could not retrieve 'repo' from ${JSON.stringify(version)}`);
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
const url = `https://github.com/${owner}/${repo}.git`;
|
const url = `https://github.com/${owner}/${repo}.git`;
|
||||||
shell.echo(
|
console.log(
|
||||||
`Building ${taskName} from ${url}. Commitish: ${
|
`Building ${taskName} from ${url}. Commitish: ${
|
||||||
commitish ? commitish : 'HEAD'
|
commitish ? commitish : 'HEAD'
|
||||||
}`
|
}`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (fs.existsSync(destinationPath)) {
|
if (fs.existsSync(destinationPath)) {
|
||||||
shell.echo(
|
console.log(
|
||||||
`Skipping the ${taskName} build because it already exists: ${destinationPath}`
|
`Skipping the ${taskName} build because it already exists: ${destinationPath}`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildFolder = path.join(__dirname, '..', 'build');
|
const resourcesFolder = path.join(
|
||||||
if (shell.mkdir('-p', buildFolder).code !== 0) {
|
__dirname,
|
||||||
shell.echo('Could not create build folder.');
|
'..',
|
||||||
shell.exit(1);
|
'src',
|
||||||
}
|
'node',
|
||||||
|
'resources'
|
||||||
|
);
|
||||||
|
fs.mkdirSync(resourcesFolder, { recursive: true });
|
||||||
|
|
||||||
const tempRepoPath = temp.mkdirSync();
|
const tempRepoPath = temp.mkdirSync();
|
||||||
shell.echo(`>>> Cloning ${taskName} source to ${tempRepoPath}...`);
|
console.log(`>>> Cloning ${taskName} source to ${tempRepoPath}...`);
|
||||||
if (shell.exec(`git clone ${url} ${tempRepoPath}`).code !== 0) {
|
exec('git', ['clone', url, tempRepoPath], { logStdout: true });
|
||||||
shell.exit(1);
|
console.log(`<<< Cloned ${taskName} repo.`);
|
||||||
}
|
|
||||||
shell.echo(`<<< Cloned ${taskName} repo.`);
|
|
||||||
|
|
||||||
if (commitish) {
|
if (commitish) {
|
||||||
shell.echo(`>>> Checking out ${commitish}...`);
|
console.log(`>>> Checking out ${commitish}...`);
|
||||||
if (shell.exec(`git -C ${tempRepoPath} checkout ${commitish}`).code !== 0) {
|
exec('git', ['-C', tempRepoPath, 'checkout', commitish], {
|
||||||
shell.exit(1);
|
logStdout: true,
|
||||||
}
|
});
|
||||||
shell.echo(`<<< Checked out ${commitish}.`);
|
console.log(`<<< Checked out ${commitish}.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.echo(`>>> Building the ${taskName}...`);
|
exec('git', ['-C', tempRepoPath, 'rev-parse', '--short', 'HEAD'], {
|
||||||
if (shell.exec(`${command} build`, { cwd: tempRepoPath }).code !== 0) {
|
logStdout: true,
|
||||||
shell.exit(1);
|
});
|
||||||
}
|
|
||||||
shell.echo(`<<< Done ${taskName} build.`);
|
console.log(`>>> Building the ${taskName}...`);
|
||||||
|
exec(command, ['build'], {
|
||||||
|
cwd: tempRepoPath,
|
||||||
|
encoding: 'utf8',
|
||||||
|
logStdout: true,
|
||||||
|
});
|
||||||
|
console.log(`<<< Done ${taskName} build.`);
|
||||||
|
|
||||||
const binName = path.basename(destinationPath);
|
const binName = path.basename(destinationPath);
|
||||||
if (!fs.existsSync(path.join(tempRepoPath, binName))) {
|
if (!fs.existsSync(path.join(tempRepoPath, binName))) {
|
||||||
shell.echo(
|
console.log(
|
||||||
`Could not find the ${taskName} at ${path.join(tempRepoPath, binName)}.`
|
`Could not find the ${taskName} at ${path.join(tempRepoPath, binName)}.`
|
||||||
);
|
);
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const binPath = path.join(tempRepoPath, binName);
|
const binPath = path.join(tempRepoPath, binName);
|
||||||
shell.echo(
|
console.log(
|
||||||
`>>> Copying ${taskName} from ${binPath} to ${destinationPath}...`
|
`>>> Copying ${taskName} from ${binPath} to ${destinationPath}...`
|
||||||
);
|
);
|
||||||
if (shell.cp(binPath, destinationPath).code !== 0) {
|
fs.copyFileSync(binPath, destinationPath);
|
||||||
shell.exit(1);
|
console.log(`<<< Copied the ${taskName}.`);
|
||||||
}
|
|
||||||
shell.echo(`<<< Copied the ${taskName}.`);
|
|
||||||
|
|
||||||
shell.echo(`<<< Verifying ${taskName}...`);
|
console.log(`<<< Verifying ${taskName}...`);
|
||||||
if (!fs.existsSync(destinationPath)) {
|
if (!fs.existsSync(destinationPath)) {
|
||||||
shell.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
shell.echo(`>>> Verified ${taskName}.`);
|
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,41 +1,47 @@
|
|||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
|
||||||
|
import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
|
||||||
|
import { CommonMenus } from '@theia/core/lib/browser/common-frontend-contribution';
|
||||||
|
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application';
|
||||||
|
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
||||||
|
import {
|
||||||
|
TabBarToolbarContribution,
|
||||||
|
TabBarToolbarRegistry,
|
||||||
|
} from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
||||||
|
import {
|
||||||
|
ColorTheme,
|
||||||
|
CssStyleCollector,
|
||||||
|
StylingParticipant,
|
||||||
|
} from '@theia/core/lib/browser/styling-service';
|
||||||
|
import {
|
||||||
|
CommandContribution,
|
||||||
|
CommandRegistry,
|
||||||
|
} from '@theia/core/lib/common/command';
|
||||||
|
import {
|
||||||
|
MAIN_MENU_BAR,
|
||||||
|
MenuContribution,
|
||||||
|
MenuModelRegistry,
|
||||||
|
} from '@theia/core/lib/common/menu';
|
||||||
|
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 {
|
import {
|
||||||
inject,
|
inject,
|
||||||
injectable,
|
injectable,
|
||||||
postConstruct,
|
postConstruct,
|
||||||
} from '@theia/core/shared/inversify';
|
} from '@theia/core/shared/inversify';
|
||||||
import * as React from '@theia/core/shared/react';
|
import React from '@theia/core/shared/react';
|
||||||
import {
|
import { EditorCommands } from '@theia/editor/lib/browser/editor-command';
|
||||||
MAIN_MENU_BAR,
|
import { EditorMainMenu } from '@theia/editor/lib/browser/editor-menu';
|
||||||
MenuContribution,
|
|
||||||
MenuModelRegistry,
|
|
||||||
} from '@theia/core';
|
|
||||||
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
||||||
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
|
|
||||||
import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
|
|
||||||
import { CommonMenus } from '@theia/core/lib/browser/common-frontend-contribution';
|
|
||||||
import {
|
|
||||||
TabBarToolbarContribution,
|
|
||||||
TabBarToolbarRegistry,
|
|
||||||
} from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
||||||
import { nls } from '@theia/core/lib/common';
|
|
||||||
import {
|
|
||||||
CommandContribution,
|
|
||||||
CommandRegistry,
|
|
||||||
} from '@theia/core/lib/common/command';
|
|
||||||
import { MessageService } from '@theia/core/lib/common/message-service';
|
|
||||||
import { EditorCommands, EditorMainMenu } from '@theia/editor/lib/browser';
|
|
||||||
import { MonacoMenus } from '@theia/monaco/lib/browser/monaco-menu';
|
import { MonacoMenus } from '@theia/monaco/lib/browser/monaco-menu';
|
||||||
import { FileNavigatorCommands } from '@theia/navigator/lib/browser/navigator-contribution';
|
import { FileNavigatorCommands } from '@theia/navigator/lib/browser/navigator-contribution';
|
||||||
import { TerminalMenus } from '@theia/terminal/lib/browser/terminal-frontend-contribution';
|
import { TerminalMenus } from '@theia/terminal/lib/browser/terminal-frontend-contribution';
|
||||||
import { ElectronWindowPreferences } from '@theia/core/lib/electron-browser/window/electron-window-preferences';
|
|
||||||
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 { 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 { ArduinoToolbar } from './toolbar/arduino-toolbar';
|
|
||||||
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
|
||||||
import { SerialPlotterContribution } from './serial/plotter/plotter-frontend-contribution';
|
import { SerialPlotterContribution } from './serial/plotter/plotter-frontend-contribution';
|
||||||
|
import { ArduinoToolbar } from './toolbar/arduino-toolbar';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class ArduinoFrontendContribution
|
export class ArduinoFrontendContribution
|
||||||
@@ -44,7 +50,8 @@ export class ArduinoFrontendContribution
|
|||||||
TabBarToolbarContribution,
|
TabBarToolbarContribution,
|
||||||
CommandContribution,
|
CommandContribution,
|
||||||
MenuContribution,
|
MenuContribution,
|
||||||
ColorContribution
|
ColorContribution,
|
||||||
|
StylingParticipant
|
||||||
{
|
{
|
||||||
@inject(MessageService)
|
@inject(MessageService)
|
||||||
private readonly messageService: MessageService;
|
private readonly messageService: MessageService;
|
||||||
@@ -62,7 +69,7 @@ export class ArduinoFrontendContribution
|
|||||||
private readonly appStateService: FrontendApplicationStateService;
|
private readonly appStateService: FrontendApplicationStateService;
|
||||||
|
|
||||||
@postConstruct()
|
@postConstruct()
|
||||||
protected async init(): Promise<void> {
|
protected init(): void {
|
||||||
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(
|
||||||
@@ -80,8 +87,7 @@ export class ArduinoFrontendContribution
|
|||||||
switch (event.preferenceName) {
|
switch (event.preferenceName) {
|
||||||
case 'window.zoomLevel':
|
case '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;
|
||||||
}
|
}
|
||||||
@@ -89,10 +95,9 @@ export class ArduinoFrontendContribution
|
|||||||
});
|
});
|
||||||
this.appStateService.reachedState('ready').then(() =>
|
this.appStateService.reachedState('ready').then(() =>
|
||||||
this.electronWindowPreferences.ready.then(() => {
|
this.electronWindowPreferences.ready.then(() => {
|
||||||
const webContents = remote.getCurrentWebContents();
|
|
||||||
const zoomLevel =
|
const zoomLevel =
|
||||||
this.electronWindowPreferences.get('window.zoomLevel');
|
this.electronWindowPreferences.get('window.zoomLevel');
|
||||||
webContents.setZoomLevel(zoomLevel);
|
window.electronTheiaCore.setZoomLevel(zoomLevel);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -168,7 +173,8 @@ export class ArduinoFrontendContribution
|
|||||||
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.',
|
||||||
@@ -178,7 +184,8 @@ export class ArduinoFrontendContribution
|
|||||||
defaults: {
|
defaults: {
|
||||||
dark: 'button.hoverBackground',
|
dark: 'button.hoverBackground',
|
||||||
light: 'button.hoverBackground',
|
light: 'button.hoverBackground',
|
||||||
hc: 'button.background',
|
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.',
|
||||||
@@ -188,7 +195,8 @@ export class ArduinoFrontendContribution
|
|||||||
defaults: {
|
defaults: {
|
||||||
dark: 'secondaryButton.foreground',
|
dark: 'secondaryButton.foreground',
|
||||||
light: 'button.foreground',
|
light: 'button.foreground',
|
||||||
hc: 'activityBar.inactiveForeground',
|
hcDark: 'activityBar.inactiveForeground',
|
||||||
|
hcLight: 'activityBar.inactiveForeground',
|
||||||
},
|
},
|
||||||
description:
|
description:
|
||||||
'Foreground color of the toolbar items. Such as Serial Monitor and Serial Plotter',
|
'Foreground color of the toolbar items. Such as Serial Monitor and Serial Plotter',
|
||||||
@@ -198,7 +206,8 @@ export class ArduinoFrontendContribution
|
|||||||
defaults: {
|
defaults: {
|
||||||
dark: 'secondaryButton.hoverBackground',
|
dark: 'secondaryButton.hoverBackground',
|
||||||
light: 'button.hoverBackground',
|
light: 'button.hoverBackground',
|
||||||
hc: 'textLink.foreground',
|
hcDark: 'textLink.foreground',
|
||||||
|
hcLight: 'textLink.foreground',
|
||||||
},
|
},
|
||||||
description:
|
description:
|
||||||
'Background color of the toolbar items when hovering over them, such as "Serial Monitor" and "Serial Plotter"',
|
'Background color of the toolbar items when hovering over them, such as "Serial Monitor" and "Serial Plotter"',
|
||||||
@@ -208,7 +217,8 @@ export class ArduinoFrontendContribution
|
|||||||
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)',
|
||||||
@@ -218,37 +228,38 @@ export class ArduinoFrontendContribution
|
|||||||
defaults: {
|
defaults: {
|
||||||
dark: 'dropdown.border',
|
dark: 'dropdown.border',
|
||||||
light: 'dropdown.border',
|
light: 'dropdown.border',
|
||||||
hc: 'dropdown.border',
|
hcDark: 'dropdown.border',
|
||||||
|
hcLight: 'dropdown.border',
|
||||||
},
|
},
|
||||||
description: 'Border color of the Board Selector.',
|
description: 'Border color of the Board Selector.',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
id: 'arduino.toolbar.dropdown.borderActive',
|
id: 'arduino.toolbar.dropdown.borderActive',
|
||||||
defaults: {
|
defaults: {
|
||||||
dark: 'focusBorder',
|
dark: 'focusBorder',
|
||||||
light: 'focusBorder',
|
light: 'focusBorder',
|
||||||
hc: 'focusBorder',
|
hcDark: 'focusBorder',
|
||||||
|
hcLight: 'focusBorder',
|
||||||
},
|
},
|
||||||
description: "Border color of the Board Selector when it's active",
|
description: "Border color of the Board Selector when it's active",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
id: 'arduino.toolbar.dropdown.background',
|
id: 'arduino.toolbar.dropdown.background',
|
||||||
defaults: {
|
defaults: {
|
||||||
dark: 'tab.unfocusedActiveBackground',
|
dark: 'tab.unfocusedActiveBackground',
|
||||||
light: 'dropdown.background',
|
light: 'dropdown.background',
|
||||||
hc: 'dropdown.background',
|
hcDark: 'dropdown.background',
|
||||||
|
hcLight: 'dropdown.background',
|
||||||
},
|
},
|
||||||
description: 'Background color of the Board Selector.',
|
description: 'Background color of the Board Selector.',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
id: 'arduino.toolbar.dropdown.label',
|
id: 'arduino.toolbar.dropdown.label',
|
||||||
defaults: {
|
defaults: {
|
||||||
dark: 'dropdown.foreground',
|
dark: 'dropdown.foreground',
|
||||||
light: 'dropdown.foreground',
|
light: 'dropdown.foreground',
|
||||||
hc: 'dropdown.foreground',
|
hcDark: 'dropdown.foreground',
|
||||||
|
hcLight: 'dropdown.foreground',
|
||||||
},
|
},
|
||||||
description: 'Font color of the Board Selector.',
|
description: 'Font color of the Board Selector.',
|
||||||
},
|
},
|
||||||
@@ -257,7 +268,8 @@ export class ArduinoFrontendContribution
|
|||||||
defaults: {
|
defaults: {
|
||||||
dark: 'list.activeSelectionIconForeground',
|
dark: 'list.activeSelectionIconForeground',
|
||||||
light: 'list.activeSelectionIconForeground',
|
light: 'list.activeSelectionIconForeground',
|
||||||
hc: 'list.activeSelectionIconForeground',
|
hcDark: 'list.activeSelectionIconForeground',
|
||||||
|
hcLight: 'list.activeSelectionIconForeground',
|
||||||
},
|
},
|
||||||
description:
|
description:
|
||||||
'Color of the selected protocol icon in the Board Selector.',
|
'Color of the selected protocol icon in the Board Selector.',
|
||||||
@@ -267,7 +279,8 @@ export class ArduinoFrontendContribution
|
|||||||
defaults: {
|
defaults: {
|
||||||
dark: 'list.hoverBackground',
|
dark: 'list.hoverBackground',
|
||||||
light: 'list.hoverBackground',
|
light: 'list.hoverBackground',
|
||||||
hc: 'list.hoverBackground',
|
hcDark: 'list.hoverBackground',
|
||||||
|
hcLight: 'list.hoverBackground',
|
||||||
},
|
},
|
||||||
description: 'Background color on hover of the Board Selector options.',
|
description: 'Background color on hover of the Board Selector options.',
|
||||||
},
|
},
|
||||||
@@ -276,11 +289,191 @@ export class ArduinoFrontendContribution
|
|||||||
defaults: {
|
defaults: {
|
||||||
dark: 'list.activeSelectionBackground',
|
dark: 'list.activeSelectionBackground',
|
||||||
light: 'list.activeSelectionBackground',
|
light: 'list.activeSelectionBackground',
|
||||||
hc: 'list.activeSelectionBackground',
|
hcDark: 'list.activeSelectionBackground',
|
||||||
|
hcLight: 'list.activeSelectionBackground',
|
||||||
},
|
},
|
||||||
description:
|
description:
|
||||||
'Background color of the selected board in the Board Selector.',
|
'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};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,10 @@ 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';
|
||||||
@@ -61,7 +64,6 @@ 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';
|
||||||
@@ -100,7 +102,7 @@ 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/lib/common/logger';
|
import { ILogger } from '@theia/core/lib/common/logger';
|
||||||
import { bindContributionProvider } from '@theia/core/lib/common/contribution-provider';
|
import { bindContributionProvider } from '@theia/core/lib/common/contribution-provider';
|
||||||
@@ -178,7 +180,7 @@ import { TabBarRenderer } from './theia/core/tab-bars';
|
|||||||
import { EditorCommandContribution } from './theia/editor/editor-command';
|
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 { 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';
|
||||||
@@ -208,7 +210,6 @@ import {
|
|||||||
MonacoEditorFactory,
|
MonacoEditorFactory,
|
||||||
MonacoEditorProvider as TheiaMonacoEditorProvider,
|
MonacoEditorProvider as TheiaMonacoEditorProvider,
|
||||||
} from '@theia/monaco/lib/browser/monaco-editor-provider';
|
} from '@theia/monaco/lib/browser/monaco-editor-provider';
|
||||||
import { StorageWrapper } from './storage-wrapper';
|
|
||||||
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';
|
||||||
@@ -238,7 +239,6 @@ import {
|
|||||||
UploadFirmwareDialog,
|
UploadFirmwareDialog,
|
||||||
UploadFirmwareDialogProps,
|
UploadFirmwareDialogProps,
|
||||||
} 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,
|
||||||
@@ -271,8 +271,8 @@ import { MonitorModel } from './monitor-model';
|
|||||||
import { MonitorManagerProxyClientImpl } from './monitor-manager-proxy-client-impl';
|
import { MonitorManagerProxyClientImpl } from './monitor-manager-proxy-client-impl';
|
||||||
import { EditorManager as TheiaEditorManager } from '@theia/editor/lib/browser/editor-manager';
|
import { EditorManager as TheiaEditorManager } from '@theia/editor/lib/browser/editor-manager';
|
||||||
import { EditorManager } from './theia/editor/editor-manager';
|
import { EditorManager } from './theia/editor/editor-manager';
|
||||||
import { HostedPluginEvents } from './hosted-plugin-events';
|
import { HostedPluginEvents } from './hosted/hosted-plugin-events';
|
||||||
import { HostedPluginSupport } from './theia/plugin-ext/hosted-plugin';
|
import { HostedPluginSupportImpl } from './theia/plugin-ext/hosted-plugin';
|
||||||
import { HostedPluginSupport as TheiaHostedPluginSupport } from '@theia/plugin-ext/lib/hosted/browser/hosted-plugin';
|
import { HostedPluginSupport as TheiaHostedPluginSupport } from '@theia/plugin-ext/lib/hosted/browser/hosted-plugin';
|
||||||
import { Formatter, FormatterPath } from '../common/protocol/formatter';
|
import { Formatter, FormatterPath } from '../common/protocol/formatter';
|
||||||
import { Format } from './contributions/format';
|
import { Format } from './contributions/format';
|
||||||
@@ -296,7 +296,7 @@ import { CoreErrorHandler } from './contributions/core-error-handler';
|
|||||||
import { CompilerErrors } from './contributions/compiler-errors';
|
import { CompilerErrors } from './contributions/compiler-errors';
|
||||||
import { WidgetManager } from './theia/core/widget-manager';
|
import { WidgetManager } from './theia/core/widget-manager';
|
||||||
import { WidgetManager as TheiaWidgetManager } from '@theia/core/lib/browser/widget-manager';
|
import { WidgetManager as TheiaWidgetManager } from '@theia/core/lib/browser/widget-manager';
|
||||||
import { StartupTasks } from './contributions/startup-task';
|
import { StartupTasksExecutor } from './contributions/startup-tasks-executor';
|
||||||
import { IndexesUpdateProgress } from './contributions/indexes-update-progress';
|
import { IndexesUpdateProgress } from './contributions/indexes-update-progress';
|
||||||
import { Daemon } from './contributions/daemon';
|
import { Daemon } from './contributions/daemon';
|
||||||
import { FirstStartupInstaller } from './contributions/first-startup-installer';
|
import { FirstStartupInstaller } from './contributions/first-startup-installer';
|
||||||
@@ -328,9 +328,13 @@ import { NewCloudSketch } from './contributions/new-cloud-sketch';
|
|||||||
import { SketchbookCompositeWidget } from './widgets/sketchbook/sketchbook-composite-widget';
|
import { SketchbookCompositeWidget } from './widgets/sketchbook/sketchbook-composite-widget';
|
||||||
import { WindowTitleUpdater } from './theia/core/window-title-updater';
|
import { WindowTitleUpdater } from './theia/core/window-title-updater';
|
||||||
import { WindowTitleUpdater as TheiaWindowTitleUpdater } from '@theia/core/lib/browser/window/window-title-updater';
|
import { WindowTitleUpdater as TheiaWindowTitleUpdater } from '@theia/core/lib/browser/window/window-title-updater';
|
||||||
import { ThemeServiceWithDB } from './theia/core/theming';
|
import {
|
||||||
import { ThemeServiceWithDB as TheiaThemeServiceWithDB } from '@theia/monaco/lib/browser/monaco-indexed-db';
|
MonacoThemingService,
|
||||||
import { MonacoThemingService } from './theia/monaco/monaco-theming-service';
|
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 { MonacoThemingService as TheiaMonacoThemingService } from '@theia/monaco/lib/browser/monaco-theming-service';
|
||||||
import { TypeHierarchyServiceProvider } from './theia/typehierarchy/type-hierarchy-service';
|
import { TypeHierarchyServiceProvider } from './theia/typehierarchy/type-hierarchy-service';
|
||||||
import { TypeHierarchyServiceProvider as TheiaTypeHierarchyServiceProvider } from '@theia/typehierarchy/lib/browser/typehierarchy-service';
|
import { TypeHierarchyServiceProvider as TheiaTypeHierarchyServiceProvider } from '@theia/typehierarchy/lib/browser/typehierarchy-service';
|
||||||
@@ -338,16 +342,6 @@ import { TypeHierarchyContribution } from './theia/typehierarchy/type-hierarchy-
|
|||||||
import { TypeHierarchyContribution as TheiaTypeHierarchyContribution } from '@theia/typehierarchy/lib/browser/typehierarchy-contribution';
|
import { TypeHierarchyContribution as TheiaTypeHierarchyContribution } from '@theia/typehierarchy/lib/browser/typehierarchy-contribution';
|
||||||
import { DefaultDebugSessionFactory } from './theia/debug/debug-session-contribution';
|
import { DefaultDebugSessionFactory } from './theia/debug/debug-session-contribution';
|
||||||
import { DebugSessionFactory } from '@theia/debug/lib/browser/debug-session-contribution';
|
import { DebugSessionFactory } from '@theia/debug/lib/browser/debug-session-contribution';
|
||||||
import { DebugToolbar } from './theia/debug/debug-toolbar-widget';
|
|
||||||
import { DebugToolBar as TheiaDebugToolbar } from '@theia/debug/lib/browser/view/debug-toolbar-widget';
|
|
||||||
import { PluginMenuCommandAdapter } from './theia/plugin-ext/plugin-menu-command-adapter';
|
|
||||||
import { PluginMenuCommandAdapter as TheiaPluginMenuCommandAdapter } from '@theia/plugin-ext/lib/main/browser/menus/plugin-menu-command-adapter';
|
|
||||||
import { DebugSessionManager } from './theia/debug/debug-session-manager';
|
|
||||||
import { DebugSessionManager as TheiaDebugSessionManager } from '@theia/debug/lib/browser/debug-session-manager';
|
|
||||||
import { DebugWidget } from '@theia/debug/lib/browser/view/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/lib/browser/view/debug-configuration-widget';
|
|
||||||
import { ConfigServiceClient } from './config/config-service-client';
|
import { ConfigServiceClient } from './config/config-service-client';
|
||||||
import { ValidateSketch } from './contributions/validate-sketch';
|
import { ValidateSketch } from './contributions/validate-sketch';
|
||||||
import { RenameCloudSketch } from './contributions/rename-cloud-sketch';
|
import { RenameCloudSketch } from './contributions/rename-cloud-sketch';
|
||||||
@@ -356,15 +350,48 @@ import { Account } from './contributions/account';
|
|||||||
import { SidebarBottomMenuWidget } from './theia/core/sidebar-bottom-menu-widget';
|
import { SidebarBottomMenuWidget } from './theia/core/sidebar-bottom-menu-widget';
|
||||||
import { SidebarBottomMenuWidget as TheiaSidebarBottomMenuWidget } from '@theia/core/lib/browser/shell/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 { 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';
|
||||||
|
|
||||||
|
// Hack to fix copy/cut/paste issue after electron version update in Theia.
|
||||||
|
// https://github.com/eclipse-theia/theia/issues/12487
|
||||||
|
import('@theia/core/lib/browser/common-frontend-contribution.js').then(
|
||||||
|
(theiaCommonContribution) => {
|
||||||
|
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) => {
|
||||||
// Commands and toolbar items
|
// Commands, colors, theme adjustments, 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);
|
||||||
@@ -433,13 +460,14 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
bind(BoardsServiceProvider).toSelf().inSingletonScope();
|
bind(BoardsServiceProvider).toSelf().inSingletonScope();
|
||||||
bind(FrontendApplicationContribution).toService(BoardsServiceProvider);
|
bind(FrontendApplicationContribution).toService(BoardsServiceProvider);
|
||||||
bind(CommandContribution).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) => {
|
||||||
@@ -466,7 +494,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
bind(OpenHandler).toService(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(
|
title: nls.localize(
|
||||||
@@ -494,15 +521,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
bind(TabBarToolbarContribution).toService(MonitorViewContribution);
|
bind(TabBarToolbarContribution).toService(MonitorViewContribution);
|
||||||
bind(WidgetFactory).toDynamicValue((context) => ({
|
bind(WidgetFactory).toDynamicValue((context) => ({
|
||||||
id: MonitorWidget.ID,
|
id: MonitorWidget.ID,
|
||||||
createWidget: () => {
|
createWidget: () => context.container.get(MonitorWidget),
|
||||||
return new MonitorWidget(
|
|
||||||
context.container.get<MonitorModel>(MonitorModel),
|
|
||||||
context.container.get<MonitorManagerProxyClient>(
|
|
||||||
MonitorManagerProxyClient
|
|
||||||
),
|
|
||||||
context.container.get<BoardsServiceProvider>(BoardsServiceProvider)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
bind(MonitorManagerProxyFactory).toFactory(
|
bind(MonitorManagerProxyFactory).toFactory(
|
||||||
@@ -725,7 +744,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
Contribution.configure(bind, PlotterFrontendContribution);
|
Contribution.configure(bind, PlotterFrontendContribution);
|
||||||
Contribution.configure(bind, Format);
|
Contribution.configure(bind, Format);
|
||||||
Contribution.configure(bind, CompilerErrors);
|
Contribution.configure(bind, CompilerErrors);
|
||||||
Contribution.configure(bind, StartupTasks);
|
Contribution.configure(bind, StartupTasksExecutor);
|
||||||
Contribution.configure(bind, IndexesUpdateProgress);
|
Contribution.configure(bind, IndexesUpdateProgress);
|
||||||
Contribution.configure(bind, Daemon);
|
Contribution.configure(bind, Daemon);
|
||||||
Contribution.configure(bind, FirstStartupInstaller);
|
Contribution.configure(bind, FirstStartupInstaller);
|
||||||
@@ -746,10 +765,15 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
Contribution.configure(bind, Account);
|
Contribution.configure(bind, Account);
|
||||||
Contribution.configure(bind, CloudSketchbookContribution);
|
Contribution.configure(bind, CloudSketchbookContribution);
|
||||||
Contribution.configure(bind, CreateCloudCopy);
|
Contribution.configure(bind, CreateCloudCopy);
|
||||||
|
Contribution.configure(bind, UpdateArduinoState);
|
||||||
|
Contribution.configure(bind, BoardsDataMenuUpdater);
|
||||||
|
Contribution.configure(bind, AutoSelectProgrammer);
|
||||||
|
|
||||||
bindContributionProvider(bind, StartupTaskProvider);
|
bindContributionProvider(bind, StartupTaskProvider);
|
||||||
bind(StartupTaskProvider).toService(BoardsServiceProvider); // to reuse the boards config in another window
|
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.
|
// 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.
|
// Use the default VS Code behavior, and pick the first one. In the IDE2, clang-format has `exclusive` selectors.
|
||||||
bind(MonacoFormattingConflictsContribution).toSelf().inSingletonScope();
|
bind(MonacoFormattingConflictsContribution).toSelf().inSingletonScope();
|
||||||
@@ -792,10 +816,19 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
);
|
);
|
||||||
const iconThemeService =
|
const iconThemeService =
|
||||||
context.container.get<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
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -838,6 +871,28 @@ 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
|
// To avoid duplicate tabs use deepEqual instead of string equal: https://github.com/eclipse-theia/theia/issues/11309
|
||||||
bind(WidgetManager).toSelf().inSingletonScope();
|
bind(WidgetManager).toSelf().inSingletonScope();
|
||||||
@@ -874,9 +929,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();
|
||||||
@@ -969,8 +1021,9 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
})
|
})
|
||||||
.inSingletonScope();
|
.inSingletonScope();
|
||||||
|
|
||||||
bind(HostedPluginSupport).toSelf().inSingletonScope();
|
bind(HostedPluginSupportImpl).toSelf().inSingletonScope();
|
||||||
rebind(TheiaHostedPluginSupport).toService(HostedPluginSupport);
|
bind(HostedPluginSupport).toService(HostedPluginSupportImpl);
|
||||||
|
rebind(TheiaHostedPluginSupport).toService(HostedPluginSupportImpl);
|
||||||
bind(HostedPluginEvents).toSelf().inSingletonScope();
|
bind(HostedPluginEvents).toSelf().inSingletonScope();
|
||||||
bind(FrontendApplicationContribution).toService(HostedPluginEvents);
|
bind(FrontendApplicationContribution).toService(HostedPluginEvents);
|
||||||
|
|
||||||
@@ -979,11 +1032,17 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
rebind(TheiaWindowTitleUpdater).toService(WindowTitleUpdater);
|
rebind(TheiaWindowTitleUpdater).toService(WindowTitleUpdater);
|
||||||
|
|
||||||
// register Arduino themes
|
// register Arduino themes
|
||||||
bind(ThemeServiceWithDB).toSelf().inSingletonScope();
|
|
||||||
rebind(TheiaThemeServiceWithDB).toService(ThemeServiceWithDB);
|
|
||||||
bind(MonacoThemingService).toSelf().inSingletonScope();
|
bind(MonacoThemingService).toSelf().inSingletonScope();
|
||||||
rebind(TheiaMonacoThemingService).toService(MonacoThemingService);
|
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
|
// disable type-hierarchy support
|
||||||
// https://github.com/eclipse-theia/theia/commit/16c88a584bac37f5cf3cc5eb92ffdaa541bda5be
|
// https://github.com/eclipse-theia/theia/commit/16c88a584bac37f5cf3cc5eb92ffdaa541bda5be
|
||||||
bind(TypeHierarchyServiceProvider).toSelf().inSingletonScope();
|
bind(TypeHierarchyServiceProvider).toSelf().inSingletonScope();
|
||||||
@@ -993,37 +1052,8 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
bind(TypeHierarchyContribution).toSelf().inSingletonScope();
|
bind(TypeHierarchyContribution).toSelf().inSingletonScope();
|
||||||
rebind(TheiaTypeHierarchyContribution).toService(TypeHierarchyContribution);
|
rebind(TheiaTypeHierarchyContribution).toService(TypeHierarchyContribution);
|
||||||
|
|
||||||
// patched the debugger for `cortex-debug@1.5.1`
|
|
||||||
// https://github.com/eclipse-theia/theia/issues/11871
|
|
||||||
// https://github.com/eclipse-theia/theia/issues/11879
|
|
||||||
// https://github.com/eclipse-theia/theia/issues/11880
|
|
||||||
// https://github.com/eclipse-theia/theia/issues/11885
|
|
||||||
// https://github.com/eclipse-theia/theia/issues/11886
|
|
||||||
// https://github.com/eclipse-theia/theia/issues/11916
|
|
||||||
// based on: https://github.com/eclipse-theia/theia/compare/master...kittaakos:theia:%2311871
|
|
||||||
bind(DefaultDebugSessionFactory).toSelf().inSingletonScope();
|
bind(DefaultDebugSessionFactory).toSelf().inSingletonScope();
|
||||||
rebind(DebugSessionFactory).toService(DefaultDebugSessionFactory);
|
rebind(DebugSessionFactory).toService(DefaultDebugSessionFactory);
|
||||||
bind(DebugSessionManager).toSelf().inSingletonScope();
|
|
||||||
rebind(TheiaDebugSessionManager).toService(DebugSessionManager);
|
|
||||||
bind(DebugToolbar).toSelf().inSingletonScope();
|
|
||||||
rebind(TheiaDebugToolbar).toService(DebugToolbar);
|
|
||||||
bind(PluginMenuCommandAdapter).toSelf().inSingletonScope();
|
|
||||||
rebind(TheiaPluginMenuCommandAdapter).toService(PluginMenuCommandAdapter);
|
|
||||||
bind(WidgetFactory)
|
|
||||||
.toDynamicValue(({ container }) => ({
|
|
||||||
id: DebugWidget.ID,
|
|
||||||
createWidget: () => {
|
|
||||||
const child = new Container({ defaultScope: 'Singleton' });
|
|
||||||
child.parent = container;
|
|
||||||
child.bind(DebugViewModel).toSelf();
|
|
||||||
child.bind(DebugToolbar).toSelf(); // patched toolbar
|
|
||||||
child.bind(DebugSessionWidget).toSelf();
|
|
||||||
child.bind(DebugConfigurationWidget).toSelf();
|
|
||||||
child.bind(DebugWidget).toSelf();
|
|
||||||
return child.get(DebugWidget);
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
.inSingletonScope();
|
|
||||||
|
|
||||||
bind(SidebarBottomMenuWidget).toSelf();
|
bind(SidebarBottomMenuWidget).toSelf();
|
||||||
rebind(TheiaSidebarBottomMenuWidget).toService(SidebarBottomMenuWidget);
|
rebind(TheiaSidebarBottomMenuWidget).toService(SidebarBottomMenuWidget);
|
||||||
@@ -1034,4 +1064,22 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
bind(FrontendApplicationContribution).toService(DaemonPort);
|
bind(FrontendApplicationContribution).toService(DaemonPort);
|
||||||
bind(IsOnline).toSelf().inSingletonScope();
|
bind(IsOnline).toSelf().inSingletonScope();
|
||||||
bind(FrontendApplicationContribution).toService(IsOnline);
|
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
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
import { interfaces } from '@theia/core/shared/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 {
|
||||||
@@ -31,7 +34,7 @@ export const ErrorRevealStrategyLiterals = [
|
|||||||
*/
|
*/
|
||||||
'centerIfOutsideViewport',
|
'centerIfOutsideViewport',
|
||||||
] as const;
|
] as const;
|
||||||
export type ErrorRevealStrategy = typeof ErrorRevealStrategyLiterals[number];
|
export type ErrorRevealStrategy = (typeof ErrorRevealStrategyLiterals)[number];
|
||||||
export namespace ErrorRevealStrategy {
|
export namespace ErrorRevealStrategy {
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
||||||
export function is(arg: any): arg is ErrorRevealStrategy {
|
export function is(arg: any): arg is ErrorRevealStrategy {
|
||||||
@@ -40,230 +43,276 @@ export namespace ErrorRevealStrategy {
|
|||||||
export const Default: ErrorRevealStrategy = 'centerIfOutsideViewport';
|
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,
|
||||||
|
},
|
||||||
|
'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.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.survey.notification': {
|
||||||
|
type: 'boolean',
|
||||||
|
description: nls.localize(
|
||||||
|
'arduino/preferences/survey.notification',
|
||||||
|
'True if users should be notified if a survey is available. True by default.'
|
||||||
|
),
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
'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.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.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,
|
|
||||||
},
|
|
||||||
'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.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.survey.notification': {
|
|
||||||
type: 'boolean',
|
|
||||||
description: nls.localize(
|
|
||||||
'arduino/preferences/survey.notification',
|
|
||||||
'True if users should be notified if a survey is available. True by default.'
|
|
||||||
),
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
'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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ArduinoConfiguration {
|
export interface ArduinoConfiguration {
|
||||||
'arduino.language.log': boolean;
|
'arduino.language.log': boolean;
|
||||||
'arduino.language.realTimeDiagnostics': boolean;
|
'arduino.language.realTimeDiagnostics': boolean;
|
||||||
|
'arduino.language.asyncWorkers': number;
|
||||||
'arduino.compile.verbose': boolean;
|
'arduino.compile.verbose': boolean;
|
||||||
'arduino.compile.experimental': boolean;
|
'arduino.compile.experimental': boolean;
|
||||||
'arduino.compile.revealRange': ErrorRevealStrategy;
|
'arduino.compile.revealRange': ErrorRevealStrategy;
|
||||||
@@ -288,6 +337,7 @@ export interface ArduinoConfiguration {
|
|||||||
'arduino.cli.daemon.debug': boolean;
|
'arduino.cli.daemon.debug': boolean;
|
||||||
'arduino.sketch.inoBlueprint': string;
|
'arduino.sketch.inoBlueprint': string;
|
||||||
'arduino.checkForUpdates': boolean;
|
'arduino.checkForUpdates': boolean;
|
||||||
|
'arduino.monitor.dockPanel': MonitorWidgetDockPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ArduinoPreferences = Symbol('ArduinoPreferences');
|
export const ArduinoPreferences = Symbol('ArduinoPreferences');
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ import {
|
|||||||
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()
|
||||||
@@ -61,7 +61,7 @@ export class AuthenticationClientService
|
|||||||
|
|
||||||
setOptions(): Promise<void> {
|
setOptions(): Promise<void> {
|
||||||
return 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'],
|
||||||
|
|||||||
@@ -1,281 +1,229 @@
|
|||||||
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
||||||
import { MessageService } from '@theia/core/lib/common/message-service';
|
|
||||||
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application';
|
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application';
|
||||||
import {
|
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
||||||
BoardsService,
|
import { MessageService } from '@theia/core/lib/common/message-service';
|
||||||
BoardsPackage,
|
import { MessageType } from '@theia/core/lib/common/message-service-protocol';
|
||||||
Board,
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
Port,
|
import { notEmpty } from '@theia/core/lib/common/objects';
|
||||||
} from '../../common/protocol/boards-service';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { BoardsServiceProvider } from './boards-service-provider';
|
import { NotificationManager } from '@theia/messages/lib/browser/notifications-manager';
|
||||||
import { Installable, ResponseServiceClient } from '../../common/protocol';
|
|
||||||
import { BoardsListWidgetFrontendContribution } from './boards-widget-frontend-contribution';
|
|
||||||
import { nls } from '@theia/core/lib/common';
|
|
||||||
import { NotificationCenter } from '../notification-center';
|
|
||||||
import { InstallManually } from '../../common/nls';
|
import { InstallManually } from '../../common/nls';
|
||||||
|
import { Installable, ResponseServiceClient } from '../../common/protocol';
|
||||||
interface AutoInstallPromptAction {
|
import {
|
||||||
// isAcceptance, whether or not the action indicates acceptance of auto-install proposal
|
BoardIdentifier,
|
||||||
isAcceptance?: boolean;
|
BoardsPackage,
|
||||||
key: string;
|
BoardsService,
|
||||||
handler: (...args: unknown[]) => unknown;
|
createPlatformIdentifier,
|
||||||
}
|
isBoardIdentifierChangeEvent,
|
||||||
|
PlatformIdentifier,
|
||||||
type AutoInstallPromptActions = AutoInstallPromptAction[];
|
platformIdentifierEquals,
|
||||||
|
serializePlatformIdentifier,
|
||||||
|
} from '../../common/protocol/boards-service';
|
||||||
|
import { NotificationCenter } from '../notification-center';
|
||||||
|
import { BoardsServiceProvider } from './boards-service-provider';
|
||||||
|
import { BoardsListWidgetFrontendContribution } from './boards-widget-frontend-contribution';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// * Cases in which we do not show the auto-install prompt:
|
|
||||||
// 1. When a related platform is already installed
|
|
||||||
// 2. When a prompt is already showing in the UI
|
|
||||||
// 3. When a board is unplugged
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class BoardsAutoInstaller implements FrontendApplicationContribution {
|
export class BoardsAutoInstaller implements FrontendApplicationContribution {
|
||||||
@inject(NotificationCenter)
|
@inject(NotificationCenter)
|
||||||
private readonly notificationCenter: 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(ResponseServiceClient)
|
||||||
protected readonly responseService: ResponseServiceClient;
|
private readonly responseService: ResponseServiceClient;
|
||||||
|
|
||||||
@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;
|
||||||
// * "refusal" meaning a "prompt action" not accepting the auto-install offer ("X" or "install manually")
|
platformId: string;
|
||||||
// we can use "portSelectedOnLastRefusal" to deduce when a board is unplugged after a user has "refused"
|
notificationId: string;
|
||||||
// an auto-install prompt. Important to know as we do not want "an unplug" to trigger a "refused" prompt
|
}>[] = [];
|
||||||
// showing again
|
private readonly toDispose = new DisposableCollection();
|
||||||
private portSelectedOnLastRefusal: Port | undefined;
|
|
||||||
private lastRefusedPackageId: string | undefined;
|
|
||||||
|
|
||||||
onStart(): void {
|
onStart(): void {
|
||||||
const setEventListeners = () => {
|
this.toDispose.pushAll([
|
||||||
this.boardsServiceClient.onBoardsConfigChanged((config) => {
|
this.boardsServiceProvider.onBoardsConfigDidChange((event) => {
|
||||||
const { selectedBoard, selectedPort } = config;
|
if (isBoardIdentifierChangeEvent(event)) {
|
||||||
|
this.ensureCoreExists(event.selectedBoard);
|
||||||
const boardWasUnplugged =
|
|
||||||
!selectedPort && this.portSelectedOnLastRefusal;
|
|
||||||
|
|
||||||
this.clearLastRefusedPromptInfo();
|
|
||||||
|
|
||||||
if (
|
|
||||||
boardWasUnplugged ||
|
|
||||||
!selectedBoard ||
|
|
||||||
this.promptAlreadyShowingForBoard(selectedBoard)
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}),
|
||||||
this.ensureCoreExists(selectedBoard, selectedPort);
|
this.notificationCenter.onPlatformDidInstall((event) =>
|
||||||
});
|
this.clearAllNotificationForPlatform(event.item.id)
|
||||||
|
),
|
||||||
// we "clearRefusedPackageInfo" if a "refused" package is eventually
|
]);
|
||||||
// installed, though this is not strictly necessary. It's more of a
|
this.boardsServiceProvider.ready.then(() => {
|
||||||
// cleanup, to ensure the related variables are representative of
|
const { selectedBoard } = this.boardsServiceProvider.boardsConfig;
|
||||||
// current state.
|
this.ensureCoreExists(selectedBoard);
|
||||||
this.notificationCenter.onPlatformDidInstall((installed) => {
|
|
||||||
if (this.lastRefusedPackageId === installed.item.id) {
|
|
||||||
this.clearLastRefusedPromptInfo();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// we should invoke this.ensureCoreExists only once we're sure
|
|
||||||
// everything has been reconciled
|
|
||||||
this.boardsServiceClient.reconciled.then(() => {
|
|
||||||
const { selectedBoard, selectedPort } =
|
|
||||||
this.boardsServiceClient.boardsConfig;
|
|
||||||
|
|
||||||
if (selectedBoard) {
|
|
||||||
this.ensureCoreExists(selectedBoard, selectedPort);
|
|
||||||
}
|
|
||||||
|
|
||||||
setEventListeners();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private removeNotificationByBoard(selectedBoard: Board): void {
|
private async findPlatformToInstall(
|
||||||
const index = this.notifications.findIndex((notification) =>
|
selectedBoard: BoardIdentifier
|
||||||
Board.sameAs(notification, selectedBoard)
|
): Promise<BoardsPackage | undefined> {
|
||||||
);
|
const platformId = await this.findPlatformIdToInstall(selectedBoard);
|
||||||
if (index !== -1) {
|
if (!platformId) {
|
||||||
this.notifications.splice(index, 1);
|
return undefined;
|
||||||
}
|
}
|
||||||
|
const id = serializePlatformIdentifier(platformId);
|
||||||
|
const platform = await this.boardsService.getBoardPackage({ id });
|
||||||
|
if (!platform) {
|
||||||
|
console.warn(`Could not resolve platform for ID: ${id}`);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
if (platform.installedVersion) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
private clearLastRefusedPromptInfo(): void {
|
private async findPlatformIdToInstall(
|
||||||
this.lastRefusedPackageId = undefined;
|
selectedBoard: BoardIdentifier
|
||||||
this.portSelectedOnLastRefusal = undefined;
|
): Promise<PlatformIdentifier | undefined> {
|
||||||
}
|
const selectedBoardPlatformId = createPlatformIdentifier(selectedBoard);
|
||||||
|
// The board is installed or the FQBN is available from the `board list watch` for Arduino boards. The latter might change!
|
||||||
private setLastRefusedPromptInfo(
|
if (selectedBoardPlatformId) {
|
||||||
packageId: string,
|
const installedPlatforms =
|
||||||
selectedPort?: Port
|
await this.boardsService.getInstalledPlatforms();
|
||||||
): void {
|
const installedPlatformIds = installedPlatforms
|
||||||
this.lastRefusedPackageId = packageId;
|
.map((platform) => createPlatformIdentifier(platform.id))
|
||||||
this.portSelectedOnLastRefusal = selectedPort;
|
.filter(notEmpty);
|
||||||
}
|
if (
|
||||||
|
installedPlatformIds.every(
|
||||||
private promptAlreadyShowingForBoard(board: Board): boolean {
|
(installedPlatformId) =>
|
||||||
return Boolean(
|
!platformIdentifierEquals(
|
||||||
this.notifications.find((notification) =>
|
installedPlatformId,
|
||||||
Board.sameAs(notification, board)
|
selectedBoardPlatformId
|
||||||
)
|
)
|
||||||
);
|
)
|
||||||
}
|
) {
|
||||||
|
return selectedBoardPlatformId;
|
||||||
protected ensureCoreExists(selectedBoard: Board, selectedPort?: Port): void {
|
|
||||||
this.notifications.push(selectedBoard);
|
|
||||||
this.boardsService.search({}).then((packages) => {
|
|
||||||
const candidate = this.getInstallCandidate(packages, selectedBoard);
|
|
||||||
|
|
||||||
if (candidate) {
|
|
||||||
this.showAutoInstallPrompt(candidate, selectedBoard, selectedPort);
|
|
||||||
} else {
|
|
||||||
this.removeNotificationByBoard(selectedBoard);
|
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
|
// 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.
|
||||||
|
const platforms = await this.boardsService.search({});
|
||||||
|
for (const platform of platforms) {
|
||||||
|
// Ignore installed platforms
|
||||||
|
if (platform.installedVersion) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
platform.boards.some((board) => board.name === selectedBoard.name)
|
||||||
|
) {
|
||||||
|
const platformId = createPlatformIdentifier(platform.id);
|
||||||
|
if (platformId) {
|
||||||
|
return platformId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getInstallCandidate(
|
private async ensureCoreExists(
|
||||||
packages: BoardsPackage[],
|
selectedBoard: BoardIdentifier | undefined
|
||||||
selectedBoard: Board
|
): Promise<void> {
|
||||||
): BoardsPackage | undefined {
|
if (!selectedBoard) {
|
||||||
// filter packagesForBoard selecting matches from the cli (installed packages)
|
|
||||||
// and matches based on the board name
|
|
||||||
// NOTE: this ensures the Deprecated & new packages are all in the array
|
|
||||||
// so that we can check if any of the valid packages is already installed
|
|
||||||
const packagesForBoard = packages.filter(
|
|
||||||
(pkg) =>
|
|
||||||
BoardsPackage.contains(selectedBoard, pkg) ||
|
|
||||||
pkg.boards.some((board) => board.name === selectedBoard.name)
|
|
||||||
);
|
|
||||||
|
|
||||||
// check if one of the packages for the board is already installed. if so, no hint
|
|
||||||
if (packagesForBoard.some(({ installedVersion }) => !!installedVersion)) {
|
|
||||||
return;
|
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);
|
||||||
|
|
||||||
// filter the installable (not installed) packages,
|
|
||||||
// CLI returns the packages already sorted with the deprecated ones at the end of the list
|
|
||||||
// in order to ensure the new ones are preferred
|
|
||||||
const candidates = packagesForBoard.filter(
|
|
||||||
({ installedVersion }) => !installedVersion
|
|
||||||
);
|
|
||||||
|
|
||||||
return candidates[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private showAutoInstallPrompt(
|
|
||||||
candidate: BoardsPackage,
|
|
||||||
selectedBoard: Board,
|
|
||||||
selectedPort?: Port
|
|
||||||
): void {
|
|
||||||
const candidateName = candidate.name;
|
|
||||||
const version = candidate.availableVersions[0]
|
const version = candidate.availableVersions[0]
|
||||||
? `[v ${candidate.availableVersions[0]}]`
|
? `[v ${candidate.availableVersions[0]}]`
|
||||||
: '';
|
: '';
|
||||||
|
const yes = nls.localize('vscode/extensionsUtils/yes', 'Yes');
|
||||||
const info = this.generatePromptInfoText(
|
const message = nls.localize(
|
||||||
candidateName,
|
'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,
|
version,
|
||||||
selectedBoard.name
|
selectedBoard.name
|
||||||
);
|
);
|
||||||
|
const notificationId = this.notificationId(message, InstallManually, yes);
|
||||||
const actions = this.createPromptActions(candidate);
|
this.installNotificationInfos.push({
|
||||||
|
boardName: selectedBoardName,
|
||||||
const onRefuse = () => {
|
platformId: platformIdToInstall,
|
||||||
this.setLastRefusedPromptInfo(candidate.id, selectedPort);
|
notificationId,
|
||||||
};
|
});
|
||||||
const handleAction = this.createOnAnswerHandler(actions, onRefuse);
|
const answer = await this.messageService.info(
|
||||||
|
message,
|
||||||
const onAnswer = (answer: string) => {
|
InstallManually,
|
||||||
this.removeNotificationByBoard(selectedBoard);
|
yes
|
||||||
|
|
||||||
handleAction(answer);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.messageService
|
|
||||||
.info(info, ...actions.map((action) => action.key))
|
|
||||||
.then(onAnswer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private generatePromptInfoText(
|
|
||||||
candidateName: string,
|
|
||||||
version: string,
|
|
||||||
boardName: string
|
|
||||||
): string {
|
|
||||||
return 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?',
|
|
||||||
candidateName,
|
|
||||||
version,
|
|
||||||
boardName
|
|
||||||
);
|
);
|
||||||
}
|
if (answer) {
|
||||||
|
const index = this.installNotificationInfos.findIndex(
|
||||||
private createPromptActions(
|
({ boardName, platformId }) =>
|
||||||
candidate: BoardsPackage
|
platformIdToInstall === platformId && selectedBoardName === boardName
|
||||||
): AutoInstallPromptActions {
|
);
|
||||||
const yes = nls.localize('vscode/extensionsUtils/yes', 'Yes');
|
if (index !== -1) {
|
||||||
|
this.installNotificationInfos.splice(index, 1);
|
||||||
const actions: AutoInstallPromptActions = [
|
|
||||||
{
|
|
||||||
key: InstallManually,
|
|
||||||
handler: () => {
|
|
||||||
this.boardsManagerFrontendContribution
|
|
||||||
.openView({ reveal: true })
|
|
||||||
.then((widget) =>
|
|
||||||
widget.refresh({
|
|
||||||
query: candidate.name.toLocaleLowerCase(),
|
|
||||||
type: 'All',
|
|
||||||
})
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
isAcceptance: true,
|
|
||||||
key: yes,
|
|
||||||
handler: () => {
|
|
||||||
return Installable.installWithProgress({
|
|
||||||
installable: this.boardsService,
|
|
||||||
item: candidate,
|
|
||||||
messageService: this.messageService,
|
|
||||||
responseService: this.responseService,
|
|
||||||
version: candidate.availableVersions[0],
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return actions;
|
|
||||||
}
|
|
||||||
|
|
||||||
private createOnAnswerHandler(
|
|
||||||
actions: AutoInstallPromptActions,
|
|
||||||
onRefuse?: () => void
|
|
||||||
): (answer: string) => void {
|
|
||||||
return (answer) => {
|
|
||||||
const actionToHandle = actions.find((action) => action.key === answer);
|
|
||||||
actionToHandle?.handler();
|
|
||||||
|
|
||||||
if (!actionToHandle?.isAcceptance && onRefuse) {
|
|
||||||
onRefuse();
|
|
||||||
}
|
}
|
||||||
};
|
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,71 +0,0 @@
|
|||||||
import * as React from '@theia/core/shared/react';
|
|
||||||
import { injectable, inject } from '@theia/core/shared/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}
|
|
||||||
onAppStateDidChange={this.notificationCenter.onAppStateDidChange}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override onActivateRequest(msg: Message): void {
|
|
||||||
super.onActivateRequest(msg);
|
|
||||||
if (this.focusNode instanceof HTMLInputElement) {
|
|
||||||
this.focusNode.select();
|
|
||||||
}
|
|
||||||
(this.focusNode || this.node).focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
import {
|
|
||||||
injectable,
|
|
||||||
inject,
|
|
||||||
postConstruct,
|
|
||||||
} from '@theia/core/shared/inversify';
|
|
||||||
import { Message } from '@theia/core/shared/@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 override readonly props: BoardsConfigDialogProps
|
|
||||||
) {
|
|
||||||
super({ ...props, maxWidth: 500 });
|
|
||||||
|
|
||||||
this.node.id = 'select-board-dialog-container';
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
override 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 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 override 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 override onUpdateRequest(msg: Message): void {
|
|
||||||
super.onUpdateRequest(msg);
|
|
||||||
this.widget.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override onActivateRequest(msg: Message): void {
|
|
||||||
super.onActivateRequest(msg);
|
|
||||||
this.widget.activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override handleEnter(event: KeyboardEvent): boolean | void {
|
|
||||||
if (event.target instanceof HTMLTextAreaElement) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override 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,202 @@
|
|||||||
|
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(
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
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,432 +0,0 @@
|
|||||||
import * as React from '@theia/core/shared/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,
|
|
||||||
BoardConfig as ProtocolBoardConfig,
|
|
||||||
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';
|
|
||||||
import { FrontendApplicationState } from '@theia/core/lib/common/frontend-application-state';
|
|
||||||
|
|
||||||
export namespace BoardsConfig {
|
|
||||||
export type Config = ProtocolBoardConfig;
|
|
||||||
|
|
||||||
export interface Props {
|
|
||||||
readonly boardsServiceProvider: BoardsServiceProvider;
|
|
||||||
readonly notificationCenter: NotificationCenter;
|
|
||||||
readonly onConfigChange: (config: Config) => void;
|
|
||||||
readonly onFocusNodeSet: (element: HTMLElement | undefined) => void;
|
|
||||||
readonly onFilteredTextDidChangeEvent: Event<string>;
|
|
||||||
readonly onAppStateDidChange: Event<FrontendApplicationState>;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}> {
|
|
||||||
override 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,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
override componentDidMount(): void {
|
|
||||||
this.toDispose.pushAll([
|
|
||||||
this.props.onAppStateDidChange((state) => {
|
|
||||||
if (state === 'ready') {
|
|
||||||
this.updateBoards();
|
|
||||||
this.updatePorts(
|
|
||||||
this.props.boardsServiceProvider.availableBoards
|
|
||||||
.map(({ port }) => port)
|
|
||||||
.filter(notEmpty)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
this.props.boardsServiceProvider.onAvailablePortsChanged(
|
|
||||||
({ newState, oldState }) => {
|
|
||||||
const removedPorts = oldState.filter(
|
|
||||||
(oldPort) =>
|
|
||||||
!newState.find((newPort) => Port.sameAs(newPort, oldPort))
|
|
||||||
);
|
|
||||||
this.updatePorts(newState, removedPorts);
|
|
||||||
}
|
|
||||||
),
|
|
||||||
this.props.boardsServiceProvider.onBoardsConfigChanged(
|
|
||||||
({ selectedBoard, selectedPort }) => {
|
|
||||||
this.setState({ selectedBoard, selectedPort }, () =>
|
|
||||||
this.fireConfigChanged()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
),
|
|
||||||
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) =>
|
|
||||||
this.setState({ query }, () => this.updateBoards(this.state.query))
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
override componentWillUnmount(): void {
|
|
||||||
this.toDispose.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected fireConfigChanged(): void {
|
|
||||||
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);
|
|
||||||
};
|
|
||||||
|
|
||||||
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)
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const boardsList = 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}
|
|
||||||
/>
|
|
||||||
));
|
|
||||||
|
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected renderPorts(): React.ReactNode {
|
|
||||||
let ports = [] as Port[];
|
|
||||||
if (this.state.showAllPorts) {
|
|
||||||
ports = this.state.knownPorts;
|
|
||||||
} else {
|
|
||||||
ports = this.state.knownPorts.filter(
|
|
||||||
Port.visiblePorts(this.availableBoards)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return !ports.length ? (
|
|
||||||
<div className="no-result">
|
|
||||||
{nls.localize('arduino/board/noPortsDiscovered', 'No ports discovered')}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="ports list">
|
|
||||||
{ports.map((port) => (
|
|
||||||
<Item<Port>
|
|
||||||
key={`${Port.keyOf(port)}`}
|
|
||||||
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>
|
|
||||||
{nls.localize('arduino/board/showAllPorts', '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}` : ''}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,71 +1,168 @@
|
|||||||
import { injectable, inject, named } from '@theia/core/shared/inversify';
|
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application';
|
||||||
|
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,
|
|
||||||
LocalStorageService,
|
|
||||||
} from '@theia/core/lib/browser';
|
|
||||||
import { notEmpty } from '../../common/utils';
|
|
||||||
import {
|
import {
|
||||||
|
BoardDetails,
|
||||||
BoardsService,
|
BoardsService,
|
||||||
ConfigOption,
|
ConfigOption,
|
||||||
BoardDetails,
|
ConfigValue,
|
||||||
Programmer,
|
Programmer,
|
||||||
|
isBoardIdentifierChangeEvent,
|
||||||
|
isProgrammer,
|
||||||
} 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';
|
||||||
|
|
||||||
@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<string[]>();
|
this.onDidChangeEmitter
|
||||||
|
);
|
||||||
|
private _selectedBoardData: BoardsDataStoreChange | undefined;
|
||||||
|
|
||||||
onStart(): void {
|
onStart(): void {
|
||||||
this.notificationCenter.onPlatformDidInstall(async ({ item }) => {
|
this.toDispose.pushAll([
|
||||||
const dataDidChangePerFqbn: string[] = [];
|
this.boardsServiceProvider.onBoardsConfigDidChange((event) => {
|
||||||
for (const fqbn of item.boards
|
if (isBoardIdentifierChangeEvent(event)) {
|
||||||
.map(({ fqbn }) => fqbn)
|
this.updateSelectedBoardData(event.selectedBoard?.fqbn);
|
||||||
.filter(notEmpty)
|
}
|
||||||
.filter((fqbn) => !!fqbn)) {
|
}),
|
||||||
const key = this.getStorageKey(fqbn);
|
this.notificationCenter.onPlatformDidInstall(async ({ item }) => {
|
||||||
let data = await this.storageService.getData<
|
const boardsWithFqbn = item.boards
|
||||||
ConfigOption[] | undefined
|
.map(({ fqbn }) => fqbn)
|
||||||
>(key);
|
.filter(notEmpty);
|
||||||
if (!data || !data.length) {
|
const changes: BoardsDataStoreChange[] = [];
|
||||||
const details = await this.getBoardDetailsSafe(fqbn);
|
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 });
|
||||||
dataDidChangePerFqbn.push(fqbn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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(fqbn);
|
||||||
|
if (data === BoardsDataStore.Data.EMPTY) {
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
if (dataDidChangePerFqbn.length) {
|
return { fqbn, data };
|
||||||
this.fireChanged(...dataDidChangePerFqbn);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async updateSelectedBoardData(
|
||||||
|
fqbn: string | undefined
|
||||||
|
): Promise<void> {
|
||||||
|
this._selectedBoardData = await this.getSelectedBoardData(fqbn);
|
||||||
|
}
|
||||||
|
|
||||||
|
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<string[]> {
|
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;
|
||||||
@@ -80,53 +177,51 @@ 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 selectProgrammer({
|
||||||
{
|
fqbn,
|
||||||
fqbn,
|
selectedProgrammer,
|
||||||
selectedProgrammer,
|
}: {
|
||||||
}: { fqbn: string; selectedProgrammer: Programmer },
|
fqbn: string;
|
||||||
): Promise<boolean> {
|
selectedProgrammer: Programmer;
|
||||||
const data = deepClone(await this.getData(fqbn));
|
}): Promise<boolean> {
|
||||||
const { programmers } = data;
|
const storedData = deepClone(await this.getData(fqbn));
|
||||||
|
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 data = { ...storedData, selectedProgrammer };
|
||||||
fqbn,
|
await this.setData({ fqbn, data });
|
||||||
data: { ...data, selectedProgrammer },
|
this.fireChanged({ fqbn, data });
|
||||||
});
|
|
||||||
this.fireChanged(fqbn);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectConfigOption(
|
async selectConfigOption({
|
||||||
{
|
fqbn,
|
||||||
fqbn,
|
option,
|
||||||
option,
|
selectedValue,
|
||||||
selectedValue,
|
}: {
|
||||||
}: { fqbn: string; option: string; selectedValue: string }
|
fqbn: string;
|
||||||
): Promise<boolean> {
|
option: string;
|
||||||
|
selectedValue: string;
|
||||||
|
}): Promise<boolean> {
|
||||||
const data = deepClone(await this.getData(fqbn));
|
const data = deepClone(await this.getData(fqbn));
|
||||||
const { configOptions } = data;
|
const { configOptions } = data;
|
||||||
const configOption = configOptions.find((c) => c.option === option);
|
const configOption = configOptions.find((c) => c.option === option);
|
||||||
@@ -135,28 +230,24 @@ export class BoardsDataStore implements FrontendApplicationContribution {
|
|||||||
}
|
}
|
||||||
let updated = false;
|
let updated = false;
|
||||||
for (const value of configOption.values) {
|
for (const value of configOption.values) {
|
||||||
if (value.value === selectedValue) {
|
const mutable: Mutable<ConfigValue> = value;
|
||||||
(value as any).selected = true;
|
if (mutable.value === selectedValue) {
|
||||||
|
mutable.selected = true;
|
||||||
updated = true;
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
(value as any).selected = false;
|
mutable.selected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!updated) {
|
if (!updated) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
await this.setData({ fqbn, data });
|
await this.setData({ fqbn, data });
|
||||||
this.fireChanged(fqbn);
|
this.fireChanged({ fqbn, data });
|
||||||
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 +256,9 @@ export class BoardsDataStore implements FrontendApplicationContribution {
|
|||||||
return `.arduinoIDE-configOptions-${fqbn}`;
|
return `.arduinoIDE-configOptions-${fqbn}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getBoardDetailsSafe(
|
async loadBoardDetails(fqbn: string): Promise<BoardDetails | undefined> {
|
||||||
fqbn: string
|
|
||||||
): Promise<BoardDetails | undefined> {
|
|
||||||
try {
|
try {
|
||||||
const details = this.boardsService.getBoardDetails({ fqbn });
|
const details = await this.boardsService.getBoardDetails({ fqbn });
|
||||||
return details;
|
return details;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (
|
if (
|
||||||
@@ -190,8 +279,8 @@ export class BoardsDataStore implements FrontendApplicationContribution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fireChanged(...fqbn: string[]): void {
|
protected fireChanged(...changes: BoardsDataStoreChange[]): void {
|
||||||
this.onChangedEmitter.fire(fqbn);
|
this.onDidChangeEmitter.fire({ changes });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,20 +289,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',
|
||||||
|
};
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,21 @@
|
|||||||
import * as React from '@theia/core/shared/react';
|
import { TabBarToolbar } from '@theia/core/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar';
|
||||||
import * as ReactDOM from '@theia/core/shared/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 { OpenBoardsConfig } from '../contributions/open-boards-config';
|
|
||||||
import {
|
import {
|
||||||
BoardsServiceProvider,
|
Disposable,
|
||||||
AvailableBoard,
|
DisposableCollection,
|
||||||
} from './boards-service-provider';
|
} from '@theia/core/lib/common/disposable';
|
||||||
import { nls } from '@theia/core/lib/common';
|
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 classNames from 'classnames';
|
||||||
import { BoardsConfig } from './boards-config';
|
import { boardIdentifierLabel, Port } from '../../common/protocol';
|
||||||
|
import { BoardListItemUI } from '../../common/protocol/board-list';
|
||||||
|
import { assertUnreachable } from '../../common/utils';
|
||||||
|
import type {
|
||||||
|
BoardListUI,
|
||||||
|
BoardsServiceProvider,
|
||||||
|
} from './boards-service-provider';
|
||||||
|
|
||||||
export interface BoardsDropDownListCoords {
|
export interface BoardsDropDownListCoords {
|
||||||
readonly top: number;
|
readonly top: number;
|
||||||
@@ -22,18 +27,18 @@ 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>;
|
private listRef: React.RefObject<HTMLDivElement>;
|
||||||
|
|
||||||
constructor(props: BoardsDropDown.Props) {
|
constructor(props: BoardsDropDown.Props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.listRef = React.createRef();
|
this.listRef = React.createRef();
|
||||||
let list = document.getElementById('boards-dropdown-container');
|
let list = document.getElementById('boards-dropdown-container');
|
||||||
if (!list) {
|
if (!list) {
|
||||||
@@ -51,11 +56,14 @@ export class BoardsDropDown extends React.Component<BoardsDropDown.Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override render(): React.ReactNode {
|
override render(): React.ReactNode {
|
||||||
return ReactDOM.createPortal(this.renderNode(), this.dropdownElement);
|
return ReactDOM.createPortal(
|
||||||
|
this.renderBoardListItems(),
|
||||||
|
this.dropdownElement
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected renderNode(): React.ReactNode {
|
private renderBoardListItems(): React.ReactNode {
|
||||||
const { coords, items } = this.props;
|
const { coords, boardList } = this.props;
|
||||||
if (coords === 'hidden') {
|
if (coords === 'hidden') {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -74,14 +82,12 @@ export class BoardsDropDown extends React.Component<BoardsDropDown.Props> {
|
|||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
>
|
>
|
||||||
<div className="arduino-boards-dropdown-list--items-container">
|
<div className="arduino-boards-dropdown-list--items-container">
|
||||||
{items
|
{boardList.items.map((item, index) =>
|
||||||
.map(({ name, port, selected, onClick }) => ({
|
this.renderBoardListItem({
|
||||||
boardLabel: name,
|
item,
|
||||||
port,
|
selected: index === boardList.selectedIndex,
|
||||||
selected,
|
})
|
||||||
onClick,
|
)}
|
||||||
}))
|
|
||||||
.map(this.renderItem)}
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
key={footerLabel}
|
key={footerLabel}
|
||||||
@@ -95,31 +101,43 @@ export class BoardsDropDown extends React.Component<BoardsDropDown.Props> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected renderItem({
|
private readonly onDefaultAction = (item: BoardListItemUI): unknown => {
|
||||||
boardLabel,
|
const { boardList, hide } = this.props;
|
||||||
port,
|
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,
|
|
||||||
}: {
|
}: {
|
||||||
boardLabel: string;
|
item: BoardListItemUI;
|
||||||
port: Port;
|
selected: boolean;
|
||||||
selected?: boolean;
|
|
||||||
onClick: () => void;
|
|
||||||
}): React.ReactNode {
|
}): React.ReactNode {
|
||||||
const protocolIcon = iconNameFromProtocol(port.protocol);
|
const { boardLabel, portLabel, portProtocol, tooltip } = item.labels;
|
||||||
|
const port = item.port;
|
||||||
const onKeyUp = (e: React.KeyboardEvent) => {
|
const onKeyUp = (e: React.KeyboardEvent) => {
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Enter') {
|
||||||
onClick();
|
this.onDefaultAction(item);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={`board-item--${boardLabel}-${port.address}`}
|
key={`board-item--${Port.keyOf(port)}`}
|
||||||
className={classNames('arduino-boards-dropdown-item', {
|
className={classNames('arduino-boards-dropdown-item', {
|
||||||
'arduino-boards-dropdown-item--selected': selected,
|
'arduino-boards-dropdown-item--selected': selected,
|
||||||
})}
|
})}
|
||||||
onClick={onClick}
|
onClick={() => this.onDefaultAction(item)}
|
||||||
onKeyUp={onKeyUp}
|
onKeyUp={onKeyUp}
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
>
|
>
|
||||||
@@ -127,21 +145,81 @@ export class BoardsDropDown extends React.Component<BoardsDropDown.Props> {
|
|||||||
className={classNames(
|
className={classNames(
|
||||||
'arduino-boards-dropdown-item--protocol',
|
'arduino-boards-dropdown-item--protocol',
|
||||||
'fa',
|
'fa',
|
||||||
protocolIcon
|
iconNameFromProtocol(portProtocol)
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<div
|
<div className="arduino-boards-dropdown-item--label" title={tooltip}>
|
||||||
className="arduino-boards-dropdown-item--label"
|
<div className="arduino-boards-dropdown-item--board-header">
|
||||||
title={`${boardLabel}\n${port.address}`}
|
<div className="arduino-boards-dropdown-item--board-label noWrapInfo noselect">
|
||||||
>
|
{boardLabel}
|
||||||
<div className="arduino-boards-dropdown-item--board-label noWrapInfo noselect">
|
</div>
|
||||||
{boardLabel}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="arduino-boards-dropdown-item--port-label noWrapInfo noselect">
|
<div className="arduino-boards-dropdown-item--port-label noWrapInfo noselect">
|
||||||
{port.addressLabel}
|
{portLabel}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{selected ? <div className="fa fa-check" /> : ''}
|
{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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -153,26 +231,27 @@ 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.boardsServiceProvider;
|
|
||||||
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))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
override componentDidMount(): void {
|
override componentDidMount(): void {
|
||||||
this.props.boardsServiceProvider.onAvailableBoardsChanged(
|
this.toDispose.push(
|
||||||
(availableBoards) => this.setState({ availableBoards })
|
this.props.boardsServiceProvider.onBoardListDidChange((boardList) =>
|
||||||
|
this.setState({ boardList })
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +259,7 @@ export class BoardsToolBarItem extends React.Component<
|
|||||||
this.toDispose.dispose();
|
this.toDispose.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected readonly show = (event: React.MouseEvent<HTMLElement>): void => {
|
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') {
|
||||||
@@ -201,31 +280,26 @@ export class BoardsToolBarItem extends React.Component<
|
|||||||
event.nativeEvent.stopImmediatePropagation();
|
event.nativeEvent.stopImmediatePropagation();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private readonly hide = () => {
|
||||||
|
this.setState({ coords: 'hidden' });
|
||||||
|
};
|
||||||
|
|
||||||
override render(): React.ReactNode {
|
override render(): React.ReactNode {
|
||||||
const { coords, availableBoards } = this.state;
|
const { coords, boardList } = this.state;
|
||||||
const { selectedBoard, selectedPort } =
|
const { boardLabel, selected, portProtocol, tooltip } = boardList.labels;
|
||||||
this.props.boardsServiceProvider.boardsConfig;
|
const protocolIcon = portProtocol
|
||||||
|
? iconNameFromProtocol(portProtocol)
|
||||||
const boardLabel =
|
|
||||||
selectedBoard?.name ||
|
|
||||||
nls.localize('arduino/board/selectBoard', 'Select Board');
|
|
||||||
const selectedPortLabel = portLabel(selectedPort?.address);
|
|
||||||
|
|
||||||
const isConnected = Boolean(selectedBoard && selectedPort);
|
|
||||||
const protocolIcon = isConnected
|
|
||||||
? iconNameFromProtocol(selectedPort?.protocol || '')
|
|
||||||
: null;
|
: null;
|
||||||
const protocolIconClassNames = classNames(
|
const protocolIconClassNames = classNames(
|
||||||
'arduino-boards-toolbar-item--protocol',
|
'arduino-boards-toolbar-item--protocol',
|
||||||
'fa',
|
'fa',
|
||||||
protocolIcon
|
protocolIcon
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<div
|
<div
|
||||||
className="arduino-boards-toolbar-item-container"
|
className="arduino-boards-toolbar-item-container"
|
||||||
title={selectedPortLabel}
|
title={tooltip}
|
||||||
onClick={this.show}
|
onClick={this.show}
|
||||||
>
|
>
|
||||||
{protocolIcon && <div className={protocolIconClassNames} />}
|
{protocolIcon && <div className={protocolIconClassNames} />}
|
||||||
@@ -234,57 +308,22 @@ export class BoardsToolBarItem extends React.Component<
|
|||||||
'arduino-boards-toolbar-item--label',
|
'arduino-boards-toolbar-item--label',
|
||||||
'noWrapInfo',
|
'noWrapInfo',
|
||||||
'noselect',
|
'noselect',
|
||||||
{ 'arduino-boards-toolbar-item--label-connected': isConnected }
|
{ 'arduino-boards-toolbar-item--label-connected': selected }
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{boardLabel}
|
{boardLabel}
|
||||||
</div>
|
</div>
|
||||||
<div className="fa fa-caret-down caret" />
|
<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.fqbn) {
|
|
||||||
const previousBoardConfig =
|
|
||||||
this.props.boardsServiceProvider.boardsConfig;
|
|
||||||
this.props.boardsServiceProvider.boardsConfig = {
|
|
||||||
selectedPort: board.port,
|
|
||||||
};
|
|
||||||
this.openDialog(previousBoardConfig);
|
|
||||||
} else {
|
|
||||||
this.props.boardsServiceProvider.boardsConfig = {
|
|
||||||
selectedBoard: board,
|
|
||||||
selectedPort: board.port,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
this.setState({ coords: 'hidden' });
|
|
||||||
},
|
|
||||||
}))}
|
|
||||||
openBoardsConfig={this.openDialog}
|
|
||||||
></BoardsDropDown>
|
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected openDialog = async (
|
|
||||||
previousBoardConfig?: BoardsConfig.Config
|
|
||||||
): Promise<void> => {
|
|
||||||
const selectedBoardConfig =
|
|
||||||
await this.props.commands.executeCommand<BoardsConfig.Config>(
|
|
||||||
OpenBoardsConfig.Commands.OPEN_DIALOG.id
|
|
||||||
);
|
|
||||||
if (
|
|
||||||
previousBoardConfig &&
|
|
||||||
(!selectedBoardConfig?.selectedPort ||
|
|
||||||
!selectedBoardConfig?.selectedBoard)
|
|
||||||
) {
|
|
||||||
this.props.boardsServiceProvider.boardsConfig = previousBoardConfig;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
export namespace BoardsToolBarItem {
|
export namespace BoardsToolBarItem {
|
||||||
export interface Props {
|
export interface Props {
|
||||||
@@ -293,7 +332,7 @@ export namespace BoardsToolBarItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
availableBoards: AvailableBoard[];
|
boardList: BoardListUI;
|
||||||
coords: BoardsDropDownListCoords | 'hidden';
|
coords: BoardsDropDownListCoords | 'hidden';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -304,19 +343,10 @@ function iconNameFromProtocol(protocol: string): string {
|
|||||||
return 'fa-arduino-technology-usb';
|
return 'fa-arduino-technology-usb';
|
||||||
case 'network':
|
case 'network':
|
||||||
return 'fa-arduino-technology-connection';
|
return 'fa-arduino-technology-connection';
|
||||||
/*
|
// it is fine to assign dedicated icons to the protocols used by the official boards,
|
||||||
Bluetooth ports are not listed yet from the CLI;
|
// but other than that it is best to avoid implementing any special handling
|
||||||
Not sure about the naming ('bluetooth'); make sure it's correct before uncommenting the following lines
|
// for specific protocols in the IDE codebase.
|
||||||
*/
|
|
||||||
// case 'bluetooth':
|
|
||||||
// return 'fa-arduino-technology-bluetooth';
|
|
||||||
default:
|
default:
|
||||||
return 'fa-arduino-technology-3dimensionscube';
|
return 'fa-arduino-technology-3dimensionscube';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function portLabel(portName?: string): string {
|
|
||||||
return portName
|
|
||||||
? nls.localize('arduino/board/portLabel', 'Port: {0}', portName)
|
|
||||||
: nls.localize('arduino/board/disconnected', 'Disconnected');
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as React from '@theia/core/shared/react';
|
import React from '@theia/core/shared/react';
|
||||||
|
|
||||||
export type ProgressBarProps = {
|
export type ProgressBarProps = {
|
||||||
percent?: number;
|
percent?: number;
|
||||||
|
|||||||
@@ -1,26 +1,24 @@
|
|||||||
import { inject, injectable } from '@theia/core/shared/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)
|
||||||
@inject(ConfigService)
|
private readonly appService: AppService;
|
||||||
protected readonly configService: ConfigService;
|
|
||||||
|
|
||||||
override registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(About.Commands.ABOUT_APP, {
|
registry.registerCommand(About.Commands.ABOUT_APP, {
|
||||||
@@ -40,17 +38,18 @@ export class About extends Contribution {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async showAbout(): Promise<void> {
|
private async showAbout(): Promise<void> {
|
||||||
const version = await this.configService.getVersion();
|
const appInfo = await this.appService.info();
|
||||||
const buildDate = this.buildDate;
|
const { appVersion, cliVersion, buildDate } = appInfo;
|
||||||
|
|
||||||
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}\n\n{4}',
|
'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,
|
||||||
nls.localize(
|
nls.localize(
|
||||||
'arduino/about/copyright',
|
'arduino/about/copyright',
|
||||||
'Copyright © {0} Arduino SA',
|
'Copyright © {0} Arduino SA',
|
||||||
@@ -60,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');
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
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,
|
||||||
URI,
|
|
||||||
Sketch,
|
Sketch,
|
||||||
|
SketchContribution,
|
||||||
|
URI,
|
||||||
} from './contribution';
|
} from './contribution';
|
||||||
import { FileDialogService } from '@theia/filesystem/lib/browser';
|
|
||||||
import { nls } from '@theia/core/lib/common';
|
|
||||||
import { CurrentSketch } from '../sketches-service-client-impl';
|
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class AddFile extends SketchContribution {
|
export class AddFile extends SketchContribution {
|
||||||
@inject(FileDialogService)
|
@inject(FileDialogService)
|
||||||
private readonly fileDialogService: FileDialogService;
|
private readonly fileDialogService: FileDialogService; // TODO: use dialogService
|
||||||
|
|
||||||
override registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(AddFile.Commands.ADD_FILE, {
|
registry.registerCommand(AddFile.Commands.ADD_FILE, {
|
||||||
@@ -50,7 +49,7 @@ export class AddFile extends SketchContribution {
|
|||||||
const { uri: targetUri, filename } = this.resolveTarget(sketch, toAddUri);
|
const { uri: targetUri, filename } = this.resolveTarget(sketch, toAddUri);
|
||||||
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: [
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { inject, injectable } from '@theia/core/shared/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 { ArduinoMenus } from '../menu/arduino-menus';
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
@@ -42,23 +41,20 @@ export class AddZipLibrary extends SketchContribution {
|
|||||||
private 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({
|
||||||
remote.getCurrentWindow(),
|
title: nls.localize(
|
||||||
{
|
'arduino/selectZip',
|
||||||
title: nls.localize(
|
"Select a zip file containing the library you'd like to add"
|
||||||
'arduino/selectZip',
|
),
|
||||||
"Select a zip file containing the library you'd like to add"
|
defaultPath,
|
||||||
),
|
properties: ['openFile'],
|
||||||
defaultPath,
|
filters: [
|
||||||
properties: ['openFile'],
|
{
|
||||||
filters: [
|
name: nls.localize('arduino/library/zipLibrary', 'Library'),
|
||||||
{
|
extensions: ['zip'],
|
||||||
name: nls.localize('arduino/library/zipLibrary', 'Library'),
|
},
|
||||||
extensions: ['zip'],
|
],
|
||||||
},
|
});
|
||||||
],
|
|
||||||
}
|
|
||||||
);
|
|
||||||
if (!canceled && filePaths.length) {
|
if (!canceled && filePaths.length) {
|
||||||
const zipUri = await this.fileSystemExt.getUri(filePaths[0]);
|
const zipUri = await this.fileSystemExt.getUri(filePaths[0]);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { injectable } from '@theia/core/shared/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 { ArduinoMenus } from '../menu/arduino-menus';
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
import {
|
import {
|
||||||
SketchContribution,
|
SketchContribution,
|
||||||
@@ -39,16 +38,13 @@ export class ArchiveSketch extends SketchContribution {
|
|||||||
const defaultContainerUri = await this.defaultUri();
|
const defaultContainerUri = await this.defaultUri();
|
||||||
const defaultUri = defaultContainerUri.resolve(archiveBasename);
|
const defaultUri = defaultContainerUri.resolve(archiveBasename);
|
||||||
const defaultPath = await this.fileService.fsPath(defaultUri);
|
const defaultPath = await this.fileService.fsPath(defaultUri);
|
||||||
const { filePath, canceled } = await remote.dialog.showSaveDialog(
|
const { filePath, canceled } = await this.dialogService.showSaveDialog({
|
||||||
remote.getCurrentWindow(),
|
title: nls.localize(
|
||||||
{
|
'arduino/sketch/saveSketchAs',
|
||||||
title: nls.localize(
|
'Save sketch folder as...'
|
||||||
'arduino/sketch/saveSketchAs',
|
),
|
||||||
'Save sketch folder as...'
|
defaultPath,
|
||||||
),
|
});
|
||||||
defaultPath,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
if (!filePath || canceled) {
|
if (!filePath || canceled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,58 +1,58 @@
|
|||||||
import { inject, injectable } from '@theia/core/shared/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 { BoardsConfig } from '../boards/boards-config';
|
import { MenuModelRegistry } from '@theia/core/lib/common/menu/menu-model-registry';
|
||||||
|
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 { 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,
|
|
||||||
getBoardInfo,
|
|
||||||
} 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(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;
|
||||||
|
|
||||||
override 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 boardInfo = await getBoardInfo(
|
const boardInfo = await getBoardInfo(
|
||||||
this.boardsServiceProvider.boardsConfig.selectedPort,
|
this.boardsServiceProvider.boardList
|
||||||
this.boardsService.getState()
|
|
||||||
);
|
);
|
||||||
if (typeof boardInfo === 'string') {
|
if (typeof boardInfo === 'string') {
|
||||||
this.messageService.info(boardInfo);
|
this.messageService.info(boardInfo);
|
||||||
@@ -65,7 +65,7 @@ VID: ${VID}
|
|||||||
PID: ${PID}
|
PID: ${PID}
|
||||||
SN: ${SN}
|
SN: ${SN}
|
||||||
`.trim();
|
`.trim();
|
||||||
await remote.dialog.showMessageBox(remote.getCurrentWindow(), {
|
await this.dialogService.showMessageBox({
|
||||||
message: nls.localize('arduino/board/boardInfo', 'Board Info'),
|
message: nls.localize('arduino/board/boardInfo', 'Board Info'),
|
||||||
title: nls.localize('arduino/board/boardInfo', 'Board Info'),
|
title: nls.localize('arduino/board/boardInfo', 'Board Info'),
|
||||||
type: 'info',
|
type: 'info',
|
||||||
@@ -77,34 +77,35 @@ SN: ${SN}
|
|||||||
}
|
}
|
||||||
|
|
||||||
override onStart(): void {
|
override onStart(): void {
|
||||||
this.notificationCenter.onPlatformDidInstall(() => this.updateMenus());
|
this.notificationCenter.onPlatformDidInstall(() => this.updateMenus(true));
|
||||||
this.notificationCenter.onPlatformDidUninstall(() => this.updateMenus());
|
this.notificationCenter.onPlatformDidUninstall(() =>
|
||||||
this.boardsServiceProvider.onBoardsConfigChanged(() => this.updateMenus());
|
this.updateMenus(true)
|
||||||
this.boardsServiceProvider.onAvailableBoardsChanged(() =>
|
|
||||||
this.updateMenus()
|
|
||||||
);
|
|
||||||
this.boardsServiceProvider.onAvailablePortsChanged(() =>
|
|
||||||
this.updateMenus()
|
|
||||||
);
|
);
|
||||||
|
this.boardsServiceProvider.onBoardListDidChange(() => this.updateMenus());
|
||||||
}
|
}
|
||||||
|
|
||||||
override async onReady(): Promise<void> {
|
override async onReady(): Promise<void> {
|
||||||
this.updateMenus();
|
this.updateMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
@@ -113,7 +114,8 @@ SN: ${SN}
|
|||||||
...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(
|
||||||
@@ -133,7 +135,7 @@ SN: ${SN}
|
|||||||
|
|
||||||
// Ports submenu
|
// Ports submenu
|
||||||
const portsSubmenuPath = ArduinoMenus.TOOLS__PORTS_SUBMENU;
|
const portsSubmenuPath = ArduinoMenus.TOOLS__PORTS_SUBMENU;
|
||||||
const portsSubmenuLabel = config.selectedPort?.address;
|
const portsSubmenuLabel = selectedPort?.address;
|
||||||
this.menuModelRegistry.registerSubmenu(
|
this.menuModelRegistry.registerSubmenu(
|
||||||
portsSubmenuPath,
|
portsSubmenuPath,
|
||||||
nls.localize(
|
nls.localize(
|
||||||
@@ -172,69 +174,116 @@ SN: ${SN}
|
|||||||
label: `${BoardsListWidget.WIDGET_LABEL}...`,
|
label: `${BoardsListWidget.WIDGET_LABEL}...`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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) {
|
||||||
|
const { packageId, packageName } = board;
|
||||||
|
const { vendorId } = packageId;
|
||||||
|
let boardsPerPackageName = groupedBoards.get(packageName);
|
||||||
|
if (!boardsPerPackageName) {
|
||||||
|
boardsPerPackageName = {} as BoardsPerVendor;
|
||||||
|
groupedBoards.set(packageName, boardsPerPackageName);
|
||||||
|
}
|
||||||
|
let boardPerVendor: BoardWithPackage[] | undefined =
|
||||||
|
boardsPerPackageName[vendorId];
|
||||||
|
if (!boardPerVendor) {
|
||||||
|
boardPerVendor = [];
|
||||||
|
boardsPerPackageName[vendorId] = boardPerVendor;
|
||||||
|
}
|
||||||
|
boardPerVendor.push(board);
|
||||||
|
}
|
||||||
|
|
||||||
// Installed boards
|
// Installed boards
|
||||||
installedBoards.forEach((board, index) => {
|
Array.from(groupedBoards.entries()).forEach(
|
||||||
const { packageId, packageName, fqbn, name, manuallyInstalled } = board;
|
([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 packageLabel =
|
const id = `arduino-select-board--${fqbn}`;
|
||||||
packageName +
|
const command = { id };
|
||||||
`${
|
const handler = {
|
||||||
manuallyInstalled
|
execute: () =>
|
||||||
? nls.localize('arduino/board/inSketchbook', ' (in Sketchbook)')
|
this.boardsServiceProvider.updateConfig({
|
||||||
: ''
|
name: name,
|
||||||
}`;
|
fqbn: fqbn,
|
||||||
// Platform submenu
|
}),
|
||||||
const platformMenuPath = [...boardsPackagesGroup, packageId];
|
isToggled: () => fqbn === selectedBoard?.fqbn,
|
||||||
// Note: Registering the same submenu twice is a noop. No need to group the boards per platform.
|
|
||||||
this.menuModelRegistry.registerSubmenu(platformMenuPath, packageLabel, {
|
|
||||||
order: packageName.toLowerCase(),
|
|
||||||
});
|
|
||||||
|
|
||||||
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
|
// Board menu
|
||||||
const menuAction = {
|
const menuAction = {
|
||||||
commandId: id,
|
commandId: id,
|
||||||
label: name,
|
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
|
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.commandRegistry.registerCommand(command, handler);
|
||||||
this.toDisposeBeforeMenuRebuild.push(
|
this.toDisposeBeforeMenuRebuild.push(
|
||||||
Disposable.create(() => this.commandRegistry.unregisterCommand(command))
|
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.
|
);
|
||||||
});
|
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
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,46 +308,26 @@ SN: ${SN}
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// 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(
|
const portKey = Port.keyOf(port);
|
||||||
(left: string, right: string): number => {
|
|
||||||
const [, leftBoards] = ports[left];
|
|
||||||
const [, rightBoards] = ports[right];
|
|
||||||
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.addressLabel}`;
|
let label = `${port.addressLabel}`;
|
||||||
if (boards.length) {
|
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,
|
||||||
@@ -315,22 +344,12 @@ SN: ${SN}
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const grouped = AvailablePorts.groupByProtocol(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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,67 +1,66 @@
|
|||||||
import * as PQueue from 'p-queue';
|
|
||||||
import { inject, injectable } from '@theia/core/shared/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 {
|
||||||
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
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;
|
||||||
|
|
||||||
@inject(FrontendApplicationStateService)
|
private readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
|
||||||
private readonly appStateService: FrontendApplicationStateService;
|
private readonly toDisposeOnBoardChange = new DisposableCollection();
|
||||||
|
|
||||||
protected readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
|
override onStart(): void {
|
||||||
protected readonly toDisposeOnBoardChange = new DisposableCollection();
|
this.boardsDataStore.onDidChange(() =>
|
||||||
|
|
||||||
async onStart(): Promise<void> {
|
|
||||||
this.appStateService
|
|
||||||
.reachedState('ready')
|
|
||||||
.then(() =>
|
|
||||||
this.updateMenuActions(
|
|
||||||
this.boardsServiceClient.boardsConfig.selectedBoard
|
|
||||||
)
|
|
||||||
);
|
|
||||||
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) {
|
||||||
@@ -172,7 +171,7 @@ export class BoardsDataMenuUpdater implements FrontendApplicationContribution {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.mainMenuManager.update();
|
this.menuManager.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1,26 +1,26 @@
|
|||||||
import { injectable } from '@theia/core/shared/inversify';
|
import { Dialog } from '@theia/core/lib/browser/dialogs';
|
||||||
import { toArray } from '@theia/core/shared/@phosphor/algorithm';
|
|
||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
|
||||||
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
|
|
||||||
import type { MaybePromise } from '@theia/core/lib/common/types';
|
|
||||||
import type {
|
import type {
|
||||||
FrontendApplication,
|
FrontendApplication,
|
||||||
OnWillStopAction,
|
OnWillStopAction,
|
||||||
} from '@theia/core/lib/browser/frontend-application';
|
} from '@theia/core/lib/browser/frontend-application';
|
||||||
import { nls } from '@theia/core/lib/common/nls';
|
|
||||||
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
|
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
|
||||||
|
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 { 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,
|
Sketch,
|
||||||
|
SketchContribution,
|
||||||
URI,
|
URI,
|
||||||
} from './contribution';
|
} from './contribution';
|
||||||
import { Dialog } from '@theia/core/lib/browser/dialogs';
|
|
||||||
import { CurrentSketch } from '../sketches-service-client-impl';
|
|
||||||
import { SaveAsSketch } from './save-as-sketch';
|
import { SaveAsSketch } from './save-as-sketch';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,6 +28,9 @@ import { SaveAsSketch } from './save-as-sketch';
|
|||||||
*/
|
*/
|
||||||
@injectable()
|
@injectable()
|
||||||
export class Close extends SketchContribution {
|
export class Close extends SketchContribution {
|
||||||
|
@inject(WindowServiceExt)
|
||||||
|
private readonly windowServiceExt: WindowServiceExt;
|
||||||
|
|
||||||
private shell: ApplicationShell | undefined;
|
private shell: ApplicationShell | undefined;
|
||||||
|
|
||||||
override onStart(app: FrontendApplication): MaybePromise<void> {
|
override onStart(app: FrontendApplication): MaybePromise<void> {
|
||||||
@@ -56,7 +59,7 @@ export class Close extends SketchContribution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return remote.getCurrentWindow().close();
|
return this.windowServiceExt.close();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -150,26 +153,23 @@ export class Close extends SketchContribution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async prompt(isTemp: boolean): Promise<Prompt> {
|
private async prompt(isTemp: boolean): Promise<Prompt> {
|
||||||
const { response } = await remote.dialog.showMessageBox(
|
const { response } = await this.dialogService.showMessageBox({
|
||||||
remote.getCurrentWindow(),
|
message: nls.localize(
|
||||||
{
|
'arduino/sketch/saveSketch',
|
||||||
message: nls.localize(
|
'Save your sketch to open it again later.'
|
||||||
'arduino/sketch/saveSketch',
|
),
|
||||||
'Save your sketch to open it again later.'
|
title: nls.localize(
|
||||||
),
|
'theia/core/quitTitle',
|
||||||
title: nls.localize(
|
'Are you sure you want to quit?'
|
||||||
'theia/core/quitTitle',
|
),
|
||||||
'Are you sure you want to quit?'
|
type: 'question',
|
||||||
),
|
buttons: [
|
||||||
type: 'question',
|
nls.localizeByDefault("Don't Save"),
|
||||||
buttons: [
|
Dialog.CANCEL,
|
||||||
nls.localizeByDefault("Don't Save"),
|
nls.localizeByDefault(isTemp ? 'Save As...' : 'Save'),
|
||||||
Dialog.CANCEL,
|
],
|
||||||
nls.localizeByDefault(isTemp ? 'Save As...' : 'Save'),
|
defaultId: 2, // `Save`/`Save As...` button index is the default.
|
||||||
],
|
});
|
||||||
defaultId: 2, // `Save`/`Save As...` button index is the default.
|
|
||||||
}
|
|
||||||
);
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case 0:
|
case 0:
|
||||||
return Prompt.DoNotSave;
|
return Prompt.DoNotSave;
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ import {
|
|||||||
} from '@theia/core/shared/inversify';
|
} from '@theia/core/shared/inversify';
|
||||||
import URI from '@theia/core/lib/common/uri';
|
import URI from '@theia/core/lib/common/uri';
|
||||||
import { ILogger } from '@theia/core/lib/common/logger';
|
import { ILogger } from '@theia/core/lib/common/logger';
|
||||||
|
import {
|
||||||
|
Disposable,
|
||||||
|
DisposableCollection,
|
||||||
|
} from '@theia/core/lib/common/disposable';
|
||||||
import { Saveable } from '@theia/core/lib/browser/saveable';
|
import { Saveable } from '@theia/core/lib/browser/saveable';
|
||||||
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
||||||
import { MaybePromise } from '@theia/core/lib/common/types';
|
import { MaybePromise } from '@theia/core/lib/common/types';
|
||||||
@@ -62,6 +66,9 @@ import { MessageType } from '@theia/core/lib/common/message-service-protocol';
|
|||||||
import { WorkspaceService } from '../theia/workspace/workspace-service';
|
import { WorkspaceService } from '../theia/workspace/workspace-service';
|
||||||
import { MainMenuManager } from '../../common/main-menu-manager';
|
import { MainMenuManager } from '../../common/main-menu-manager';
|
||||||
import { ConfigServiceClient } from '../config/config-service-client';
|
import { ConfigServiceClient } from '../config/config-service-client';
|
||||||
|
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
|
||||||
|
import { DialogService } from '../dialog-service';
|
||||||
|
import { ApplicationConnectionStatusContribution } from '../theia/core/connection-status-service';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
Command,
|
Command,
|
||||||
@@ -110,6 +117,9 @@ export abstract class Contribution
|
|||||||
@inject(MainMenuManager)
|
@inject(MainMenuManager)
|
||||||
protected readonly menuManager: MainMenuManager;
|
protected readonly menuManager: MainMenuManager;
|
||||||
|
|
||||||
|
@inject(DialogService)
|
||||||
|
protected readonly dialogService: DialogService;
|
||||||
|
|
||||||
@postConstruct()
|
@postConstruct()
|
||||||
protected init(): void {
|
protected init(): void {
|
||||||
this.appStateService.reachedState('ready').then(() => this.onReady());
|
this.appStateService.reachedState('ready').then(() => this.onReady());
|
||||||
@@ -163,6 +173,9 @@ export abstract class SketchContribution extends Contribution {
|
|||||||
@inject(EnvVariablesServer)
|
@inject(EnvVariablesServer)
|
||||||
protected readonly envVariableServer: 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();
|
||||||
@@ -217,6 +230,9 @@ export abstract class CoreServiceContribution extends SketchContribution {
|
|||||||
@inject(NotificationManager)
|
@inject(NotificationManager)
|
||||||
private readonly notificationManager: NotificationManager;
|
private readonly notificationManager: NotificationManager;
|
||||||
|
|
||||||
|
@inject(ApplicationShell)
|
||||||
|
private readonly shell: ApplicationShell;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the internal (Theia) ID of the notification that is currently visible.
|
* 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.)
|
* It's stored here as a field to be able to close it before executing any new core command (such as verify, upload, etc.)
|
||||||
@@ -279,6 +295,9 @@ export abstract class CoreServiceContribution extends SketchContribution {
|
|||||||
keepOutput?: boolean;
|
keepOutput?: boolean;
|
||||||
task: (progressId: string, coreService: CoreService) => Promise<T>;
|
task: (progressId: string, coreService: CoreService) => Promise<T>;
|
||||||
}): Promise<T> {
|
}): Promise<T> {
|
||||||
|
const toDisposeOnComplete = new DisposableCollection(
|
||||||
|
this.maybeActivateMonitorWidget()
|
||||||
|
);
|
||||||
const { progressText, keepOutput, task } = options;
|
const { progressText, keepOutput, task } = options;
|
||||||
this.outputChannelManager
|
this.outputChannelManager
|
||||||
.getChannel('Arduino')
|
.getChannel('Arduino')
|
||||||
@@ -290,9 +309,24 @@ export abstract class CoreServiceContribution extends SketchContribution {
|
|||||||
run: ({ progressId }) => task(progressId, this.coreService),
|
run: ({ progressId }) => task(progressId, this.coreService),
|
||||||
keepOutput,
|
keepOutput,
|
||||||
});
|
});
|
||||||
|
toDisposeOnComplete.dispose();
|
||||||
return result;
|
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 {
|
private notificationId(message: string, ...actions: string[]): string {
|
||||||
return this.notificationManager['getMessageId']({
|
return this.notificationManager['getMessageId']({
|
||||||
text: message,
|
text: message,
|
||||||
|
|||||||
@@ -1,102 +1,173 @@
|
|||||||
|
import { Emitter, Event } from '@theia/core/lib/common/event';
|
||||||
|
import { MenuModelRegistry } from '@theia/core/lib/common/menu/menu-model-registry';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { MaybePromise } from '@theia/core/lib/common/types';
|
||||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { Event, Emitter } from '@theia/core/lib/common/event';
|
import { noBoardSelected } from '../../common/nls';
|
||||||
import { HostedPluginSupport } from '@theia/plugin-ext/lib/hosted/browser/hosted-plugin';
|
|
||||||
import { ArduinoToolbar } from '../toolbar/arduino-toolbar';
|
|
||||||
import { NotificationCenter } from '../notification-center';
|
|
||||||
import {
|
import {
|
||||||
Board,
|
BoardDetails,
|
||||||
|
BoardIdentifier,
|
||||||
BoardsService,
|
BoardsService,
|
||||||
|
CheckDebugEnabledParams,
|
||||||
ExecutableService,
|
ExecutableService,
|
||||||
Sketch,
|
SketchRef,
|
||||||
|
isBoardIdentifierChangeEvent,
|
||||||
|
isCompileSummary,
|
||||||
} from '../../common/protocol';
|
} from '../../common/protocol';
|
||||||
|
import { BoardsDataStore } from '../boards/boards-data-store';
|
||||||
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
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 { MaybePromise, MenuModelRegistry, nls } from '@theia/core/lib/common';
|
|
||||||
import { CurrentSketch } from '../sketches-service-client-impl';
|
|
||||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
|
||||||
|
|
||||||
const COMPILE_FOR_DEBUG_KEY = 'arduino-compile-for-debug';
|
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)
|
||||||
private readonly hostedPluginSupport: HostedPluginSupport;
|
private readonly hostedPluginSupport: HostedPluginSupport;
|
||||||
|
|
||||||
@inject(NotificationCenter)
|
@inject(NotificationCenter)
|
||||||
private readonly notificationCenter: NotificationCenter;
|
private readonly notificationCenter: NotificationCenter;
|
||||||
|
|
||||||
@inject(ExecutableService)
|
@inject(ExecutableService)
|
||||||
private readonly executableService: ExecutableService;
|
private readonly executableService: ExecutableService;
|
||||||
|
|
||||||
@inject(BoardsService)
|
@inject(BoardsService)
|
||||||
private readonly boardService: BoardsService;
|
private readonly boardService: BoardsService;
|
||||||
|
|
||||||
@inject(BoardsServiceProvider)
|
@inject(BoardsServiceProvider)
|
||||||
private 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.
|
||||||
*/
|
*/
|
||||||
private _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.
|
|
||||||
private disabledMessageDidChangeEmitter = new Emitter<string | undefined>();
|
|
||||||
private onDisabledMessageDidChange =
|
|
||||||
this.disabledMessageDidChangeEmitter.event;
|
|
||||||
|
|
||||||
private get disabledMessage(): string | undefined {
|
get message(): string | undefined {
|
||||||
return this._disabledMessages;
|
return this._message;
|
||||||
}
|
}
|
||||||
private 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
private 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>,
|
||||||
};
|
};
|
||||||
|
|
||||||
override 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
|
||||||
}`)
|
}`)
|
||||||
);
|
);
|
||||||
this.boardsServiceProvider.onBoardsConfigChanged(({ selectedBoard }) =>
|
this.boardsServiceProvider.onBoardsConfigDidChange((event) => {
|
||||||
this.refreshState(selectedBoard)
|
if (isBoardIdentifierChangeEvent(event)) {
|
||||||
);
|
this.updateMessage();
|
||||||
this.notificationCenter.onPlatformDidInstall(() => this.refreshState());
|
}
|
||||||
this.notificationCenter.onPlatformDidUninstall(() => this.refreshState());
|
});
|
||||||
|
this.notificationCenter.onPlatformDidInstall(() => this.updateMessage());
|
||||||
|
this.notificationCenter.onPlatformDidUninstall(() => this.updateMessage());
|
||||||
|
this.boardsDataStore.onDidChange((event) => {
|
||||||
|
const selectedFqbn =
|
||||||
|
this.boardsServiceProvider.boardsConfig.selectedBoard?.fqbn;
|
||||||
|
if (event.changes.find((change) => change.fqbn === selectedFqbn)) {
|
||||||
|
this.updateMessage();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.commandService.onDidExecuteCommand((event) => {
|
||||||
|
const { commandId, args } = event;
|
||||||
|
if (
|
||||||
|
commandId === 'arduino.languageserver.notifyBuildDidComplete' &&
|
||||||
|
isCompileSummary(args[0])
|
||||||
|
) {
|
||||||
|
this.updateMessage();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
override onReady(): MaybePromise<void> {
|
override onReady(): void {
|
||||||
this.refreshState();
|
this.boardsServiceProvider.ready.then(() => this.updateMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
override registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
@@ -104,7 +175,7 @@ export class Debug extends SketchContribution {
|
|||||||
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, {
|
registry.registerCommand(Debug.Commands.TOGGLE_OPTIMIZE_FOR_DEBUG, {
|
||||||
execute: () => this.toggleCompileForDebug(),
|
execute: () => this.toggleCompileForDebug(),
|
||||||
@@ -127,94 +198,56 @@ export class Debug extends SketchContribution {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async refreshState(
|
private async updateMessage(): Promise<void> {
|
||||||
board: Board | undefined = this.boardsServiceProvider.boardsConfig
|
try {
|
||||||
.selectedBoard
|
await this.isDebugEnabled();
|
||||||
): Promise<void> {
|
this.message = undefined;
|
||||||
if (!board) {
|
} catch (err) {
|
||||||
this.disabledMessage = nls.localize(
|
let message = String(err);
|
||||||
'arduino/common/noBoardSelected',
|
if (err instanceof Error) {
|
||||||
'No board selected'
|
message = err.message;
|
||||||
);
|
}
|
||||||
return;
|
this.message = message;
|
||||||
}
|
|
||||||
const fqbn = board.fqbn;
|
|
||||||
if (!fqbn) {
|
|
||||||
this.disabledMessage = nls.localize(
|
|
||||||
'arduino/debug/noPlatformInstalledFor',
|
|
||||||
"Platform is not installed for '{0}'",
|
|
||||||
board.name
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const details = await this.boardService.getBoardDetails({ fqbn });
|
|
||||||
if (!details) {
|
|
||||||
this.disabledMessage = nls.localize(
|
|
||||||
'arduino/debug/noPlatformInstalledFor',
|
|
||||||
"Platform is not installed for '{0}'",
|
|
||||||
board.name
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const { debuggingSupported } = details;
|
|
||||||
if (!debuggingSupported) {
|
|
||||||
this.disabledMessage = nls.localize(
|
|
||||||
'arduino/debug/debuggingNotSupported',
|
|
||||||
"Debugging is not supported by '{0}'",
|
|
||||||
board.name
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
this.disabledMessage = undefined;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async startDebug(
|
private async isDebugEnabled(
|
||||||
board: Board | undefined = this.boardsServiceProvider.boardsConfig
|
board: BoardIdentifier | undefined = this.boardsServiceProvider.boardsConfig
|
||||||
.selectedBoard
|
.selectedBoard
|
||||||
): Promise<void> {
|
): Promise<string> {
|
||||||
if (!board) {
|
const debugFqbn = await isDebugEnabled(
|
||||||
return;
|
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 { name, fqbn } = board;
|
const params = await this.createStartDebugParams(board);
|
||||||
if (!fqbn) {
|
if (!params) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
await this.hostedPluginSupport.didStart;
|
await this.hostedPluginSupport.didStart;
|
||||||
const [sketch, executables] = await Promise.all([
|
|
||||||
this.sketchServiceClient.currentSketch(),
|
|
||||||
this.executableService.list(),
|
|
||||||
]);
|
|
||||||
if (!CurrentSketch.isValid(sketch)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const ideTempFolderUri = await this.sketchesService.getIdeTempFolderUri(
|
|
||||||
sketch
|
|
||||||
);
|
|
||||||
const [cliPath, sketchPath, configPath] = await Promise.all([
|
|
||||||
this.fileService.fsPath(new URI(executables.cliUri)),
|
|
||||||
this.fileService.fsPath(new URI(sketch.uri)),
|
|
||||||
this.fileService.fsPath(new URI(ideTempFolderUri)),
|
|
||||||
]);
|
|
||||||
const config = {
|
|
||||||
cliPath,
|
|
||||||
board: {
|
|
||||||
fqbn,
|
|
||||||
name,
|
|
||||||
},
|
|
||||||
sketchPath,
|
|
||||||
configPath,
|
|
||||||
};
|
|
||||||
try {
|
try {
|
||||||
await this.commandService.executeCommand('arduino.debug.start', config);
|
const result = await this.debug(params);
|
||||||
|
return Boolean(result);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (await this.isSketchNotVerifiedError(err, sketch)) {
|
if (await this.isSketchNotVerifiedError(err, sketch)) {
|
||||||
const yes = nls.localize('vscode/extensionsUtils/yes', 'Yes');
|
const yes = nls.localize('vscode/extensionsUtils/yes', 'Yes');
|
||||||
const answer = await this.messageService.error(
|
const answer = await this.messageService.error(
|
||||||
nls.localize(
|
sketchIsNotCompiled(sketch.name),
|
||||||
'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?",
|
|
||||||
sketch.name
|
|
||||||
),
|
|
||||||
yes
|
yes
|
||||||
);
|
);
|
||||||
if (answer === yes) {
|
if (answer === yes) {
|
||||||
@@ -226,6 +259,16 @@ export class Debug extends SketchContribution {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async debug(
|
||||||
|
params: StartDebugParams
|
||||||
|
): Promise<StartDebugResult | undefined> {
|
||||||
|
return this.commandService.executeCommand<StartDebugResult>(
|
||||||
|
'arduino.debug.start',
|
||||||
|
params
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get compileForDebug(): boolean {
|
get compileForDebug(): boolean {
|
||||||
@@ -233,7 +276,7 @@ export class Debug extends SketchContribution {
|
|||||||
return value === 'true';
|
return value === 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
async toggleCompileForDebug(): Promise<void> {
|
private toggleCompileForDebug(): void {
|
||||||
const oldState = this.compileForDebug;
|
const oldState = this.compileForDebug;
|
||||||
const newState = !oldState;
|
const newState = !oldState;
|
||||||
window.localStorage.setItem(COMPILE_FOR_DEBUG_KEY, String(newState));
|
window.localStorage.setItem(COMPILE_FOR_DEBUG_KEY, String(newState));
|
||||||
@@ -242,7 +285,7 @@ export class Debug extends SketchContribution {
|
|||||||
|
|
||||||
private async isSketchNotVerifiedError(
|
private async isSketchNotVerifiedError(
|
||||||
err: unknown,
|
err: unknown,
|
||||||
sketch: Sketch
|
sketch: SketchRef
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
if (err instanceof Error) {
|
if (err instanceof Error) {
|
||||||
try {
|
try {
|
||||||
@@ -256,6 +299,48 @@ export class Debug extends SketchContribution {
|
|||||||
}
|
}
|
||||||
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.executableService.list(),
|
||||||
|
this.boardsDataStore.getData(board.fqbn),
|
||||||
|
]);
|
||||||
|
if (!CurrentSketch.isValid(sketch)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const ideTempFolderUri = await this.sketchesService.getIdeTempFolderUri(
|
||||||
|
sketch
|
||||||
|
);
|
||||||
|
const [cliPath, sketchPath, launchConfigsDirPath] = await Promise.all([
|
||||||
|
this.fileService.fsPath(new URI(executables.cliUri)),
|
||||||
|
this.fileService.fsPath(new URI(sketch.uri)),
|
||||||
|
this.fileService.fsPath(new URI(ideTempFolderUri)),
|
||||||
|
]);
|
||||||
|
return {
|
||||||
|
board: { fqbn: debugFqbn, name: board.name },
|
||||||
|
cliPath,
|
||||||
|
sketchPath,
|
||||||
|
launchConfigsDirPath,
|
||||||
|
programmer: boardsData.selectedProgrammer?.id,
|
||||||
|
title: nls.localize(
|
||||||
|
'arduino/debug/getDebugInfo',
|
||||||
|
'Getting debug info...'
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export namespace Debug {
|
export namespace Debug {
|
||||||
export namespace Commands {
|
export namespace Commands {
|
||||||
@@ -280,3 +365,78 @@ export namespace 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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
|
||||||
import { ipcRenderer } from '@theia/core/electron-shared/electron';
|
|
||||||
import { Dialog } from '@theia/core/lib/browser/dialogs';
|
import { Dialog } from '@theia/core/lib/browser/dialogs';
|
||||||
import { NavigatableWidget } from '@theia/core/lib/browser/navigatable-types';
|
import { NavigatableWidget } from '@theia/core/lib/browser/navigatable-types';
|
||||||
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
|
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
|
||||||
@@ -10,11 +8,11 @@ import URI from '@theia/core/lib/common/uri';
|
|||||||
import type { Widget } from '@theia/core/shared/@phosphor/widgets';
|
import type { Widget } from '@theia/core/shared/@phosphor/widgets';
|
||||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { SketchesError } from '../../common/protocol';
|
import { SketchesError } from '../../common/protocol';
|
||||||
import { SCHEDULE_DELETION_SIGNAL } from '../../electron-common/electron-messages';
|
|
||||||
import { Sketch } from '../contributions/contribution';
|
import { Sketch } from '../contributions/contribution';
|
||||||
import { isNotFound } from '../create/typings';
|
import { isNotFound } from '../create/typings';
|
||||||
import { Command, CommandRegistry } from './contribution';
|
import { Command, CommandRegistry } from './contribution';
|
||||||
import { CloudSketchContribution } from './cloud-contribution';
|
import { CloudSketchContribution } from './cloud-contribution';
|
||||||
|
import { AppService } from '../app-service';
|
||||||
|
|
||||||
export interface DeleteSketchParams {
|
export interface DeleteSketchParams {
|
||||||
/**
|
/**
|
||||||
@@ -38,6 +36,8 @@ export class DeleteSketch extends CloudSketchContribution {
|
|||||||
private readonly shell: ApplicationShell;
|
private readonly shell: ApplicationShell;
|
||||||
@inject(WindowService)
|
@inject(WindowService)
|
||||||
private readonly windowService: WindowService;
|
private readonly windowService: WindowService;
|
||||||
|
@inject(AppService)
|
||||||
|
private readonly appService: AppService;
|
||||||
|
|
||||||
override registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(DeleteSketch.Commands.DELETE_SKETCH, {
|
registry.registerCommand(DeleteSketch.Commands.DELETE_SKETCH, {
|
||||||
@@ -66,7 +66,7 @@ export class DeleteSketch extends CloudSketchContribution {
|
|||||||
}
|
}
|
||||||
const cloudUri = this.createFeatures.cloudUri(sketch);
|
const cloudUri = this.createFeatures.cloudUri(sketch);
|
||||||
if (willNavigateAway !== 'force') {
|
if (willNavigateAway !== 'force') {
|
||||||
const { response } = await remote.dialog.showMessageBox({
|
const { response } = await this.dialogService.showMessageBox({
|
||||||
title: nls.localizeByDefault('Delete'),
|
title: nls.localizeByDefault('Delete'),
|
||||||
type: 'question',
|
type: 'question',
|
||||||
buttons: [Dialog.CANCEL, Dialog.OK],
|
buttons: [Dialog.CANCEL, Dialog.OK],
|
||||||
@@ -120,7 +120,7 @@ export class DeleteSketch extends CloudSketchContribution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private scheduleDeletion(sketch: Sketch): void {
|
private scheduleDeletion(sketch: Sketch): void {
|
||||||
ipcRenderer.send(SCHEDULE_DELETION_SIGNAL, sketch);
|
this.appService.scheduleDeletion(sketch);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async loadSketch(uri: string): Promise<Sketch | undefined> {
|
private async loadSketch(uri: string): Promise<Sketch | undefined> {
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import * as PQueue from 'p-queue';
|
import PQueue from 'p-queue';
|
||||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { CommandHandler, CommandService } 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,
|
||||||
@@ -32,6 +28,8 @@ import {
|
|||||||
CoreService,
|
CoreService,
|
||||||
SketchesService,
|
SketchesService,
|
||||||
Sketch,
|
Sketch,
|
||||||
|
isBoardIdentifierChangeEvent,
|
||||||
|
BoardIdentifier,
|
||||||
} from '../../common/protocol';
|
} from '../../common/protocol';
|
||||||
import { nls } from '@theia/core/lib/common/nls';
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
import { unregisterSubmenu } from '../menu/arduino-menus';
|
import { unregisterSubmenu } from '../menu/arduino-menus';
|
||||||
@@ -112,7 +110,7 @@ export abstract class Examples extends SketchContribution {
|
|||||||
protected readonly coreService: CoreService;
|
protected readonly coreService: CoreService;
|
||||||
|
|
||||||
@inject(BoardsServiceProvider)
|
@inject(BoardsServiceProvider)
|
||||||
protected readonly boardsServiceClient: BoardsServiceProvider;
|
protected readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
|
||||||
@inject(NotificationCenter)
|
@inject(NotificationCenter)
|
||||||
protected readonly notificationCenter: NotificationCenter;
|
protected readonly notificationCenter: NotificationCenter;
|
||||||
@@ -121,12 +119,14 @@ export abstract class Examples extends SketchContribution {
|
|||||||
|
|
||||||
protected override init(): void {
|
protected override init(): void {
|
||||||
super.init();
|
super.init();
|
||||||
this.boardsServiceClient.onBoardsConfigChanged(({ selectedBoard }) =>
|
this.boardsServiceProvider.onBoardsConfigDidChange((event) => {
|
||||||
this.handleBoardChanged(selectedBoard)
|
if (isBoardIdentifierChangeEvent(event)) {
|
||||||
);
|
this.handleBoardChanged(event.selectedBoard);
|
||||||
|
}
|
||||||
|
});
|
||||||
this.notificationCenter.onDidReinitialize(() =>
|
this.notificationCenter.onDidReinitialize(() =>
|
||||||
this.update({
|
this.update({
|
||||||
board: this.boardsServiceClient.boardsConfig.selectedBoard,
|
board: this.boardsServiceProvider.boardsConfig.selectedBoard,
|
||||||
// No force refresh. The core client was already refreshed.
|
// No force refresh. The core client was already refreshed.
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -138,24 +138,11 @@ export abstract class Examples extends SketchContribution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract update(options?: {
|
protected abstract update(options?: {
|
||||||
board?: Board | undefined;
|
board?: BoardIdentifier | undefined;
|
||||||
forceRefresh?: boolean;
|
forceRefresh?: boolean;
|
||||||
}): void;
|
}): void;
|
||||||
|
|
||||||
override registerMenus(registry: MenuModelRegistry): void {
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
try {
|
|
||||||
// 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.
|
|
||||||
const index = ArduinoMenus.FILE__EXAMPLES_SUBMENU.length - 1;
|
|
||||||
const menuId = ArduinoMenus.FILE__EXAMPLES_SUBMENU[index];
|
|
||||||
const groupPath =
|
|
||||||
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(
|
||||||
@@ -242,7 +229,7 @@ export abstract class Examples extends SketchContribution {
|
|||||||
protected createHandler(uri: string): CommandHandler {
|
protected createHandler(uri: string): CommandHandler {
|
||||||
const forceUpdate = () =>
|
const forceUpdate = () =>
|
||||||
this.update({
|
this.update({
|
||||||
board: this.boardsServiceClient.boardsConfig.selectedBoard,
|
board: this.boardsServiceProvider.boardsConfig.selectedBoard,
|
||||||
forceRefresh: true,
|
forceRefresh: true,
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
@@ -313,8 +300,8 @@ export class LibraryExamples extends Examples {
|
|||||||
this.notificationCenter.onLibraryDidUninstall(() => this.update());
|
this.notificationCenter.onLibraryDidUninstall(() => this.update());
|
||||||
}
|
}
|
||||||
|
|
||||||
override async onReady(): Promise<void> {
|
override onReady(): void {
|
||||||
this.update(); // no `await`
|
this.boardsServiceProvider.ready.then(() => this.update());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override handleBoardChanged(board: Board | undefined): void {
|
protected override handleBoardChanged(board: Board | undefined): void {
|
||||||
@@ -323,7 +310,7 @@ export class LibraryExamples extends Examples {
|
|||||||
|
|
||||||
protected override async update(
|
protected override async update(
|
||||||
options: { board?: Board; forceRefresh?: boolean } = {
|
options: { board?: Board; forceRefresh?: boolean } = {
|
||||||
board: this.boardsServiceClient.boardsConfig.selectedBoard,
|
board: this.boardsServiceProvider.boardsConfig.selectedBoard,
|
||||||
}
|
}
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { board, forceRefresh } = options;
|
const { board, forceRefresh } = options;
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import * as PQueue from 'p-queue';
|
import PQueue from 'p-queue';
|
||||||
import { inject, injectable } from '@theia/core/shared/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,
|
||||||
@@ -22,31 +21,28 @@ 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 override 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();
|
||||||
|
|
||||||
override onStart(): void {
|
override onStart(): void {
|
||||||
this.boardsServiceClient.onBoardsConfigChanged(() =>
|
this.boardsServiceProvider.onBoardsConfigDidChange(() =>
|
||||||
this.updateMenuActions()
|
this.updateMenuActions()
|
||||||
);
|
);
|
||||||
this.notificationCenter.onLibraryDidInstall(() => this.updateMenuActions());
|
this.notificationCenter.onLibraryDidInstall(() => this.updateMenuActions());
|
||||||
@@ -56,8 +52,8 @@ export class IncludeLibrary extends SketchContribution {
|
|||||||
this.notificationCenter.onDidReinitialize(() => this.updateMenuActions());
|
this.notificationCenter.onDidReinitialize(() => this.updateMenuActions());
|
||||||
}
|
}
|
||||||
|
|
||||||
override async onReady(): Promise<void> {
|
override onReady(): void {
|
||||||
this.updateMenuActions();
|
this.boardsServiceProvider.ready.then(() => this.updateMenuActions());
|
||||||
}
|
}
|
||||||
|
|
||||||
override registerMenus(registry: MenuModelRegistry): void {
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
@@ -93,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 })));
|
||||||
@@ -139,7 +135,7 @@ export class IncludeLibrary extends SketchContribution {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected registerLibrary(
|
private registerLibrary(
|
||||||
libraryOrPlaceholder: LibraryPackage | string,
|
libraryOrPlaceholder: LibraryPackage | string,
|
||||||
menuPath: MenuPath
|
menuPath: MenuPath
|
||||||
): Disposable {
|
): Disposable {
|
||||||
@@ -172,7 +168,7 @@ 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 (!CurrentSketch.isValid(sketch)) {
|
if (!CurrentSketch.isValid(sketch)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,41 +1,111 @@
|
|||||||
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
import {
|
||||||
|
Disposable,
|
||||||
|
DisposableCollection,
|
||||||
|
} from '@theia/core/lib/common/disposable';
|
||||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { Mutex } from 'async-mutex';
|
import { Mutex } from 'async-mutex';
|
||||||
import {
|
import {
|
||||||
ArduinoDaemon,
|
ArduinoDaemon,
|
||||||
assertSanitizedFqbn,
|
BoardIdentifier,
|
||||||
BoardsService,
|
BoardsService,
|
||||||
ExecutableService,
|
ExecutableService,
|
||||||
|
assertSanitizedFqbn,
|
||||||
|
isBoardIdentifierChangeEvent,
|
||||||
sanitizeFqbn,
|
sanitizeFqbn,
|
||||||
} from '../../common/protocol';
|
} from '../../common/protocol';
|
||||||
import { CurrentSketch } from '../sketches-service-client-impl';
|
import {
|
||||||
import { BoardsConfig } from '../boards/boards-config';
|
defaultAsyncWorkers,
|
||||||
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
maxAsyncWorkers,
|
||||||
import { HostedPluginEvents } from '../hosted-plugin-events';
|
minAsyncWorkers,
|
||||||
import { NotificationCenter } from '../notification-center';
|
} from '../arduino-preferences';
|
||||||
import { SketchContribution, URI } from './contribution';
|
|
||||||
import { BoardsDataStore } from '../boards/boards-data-store';
|
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';
|
||||||
|
|
||||||
|
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()
|
@injectable()
|
||||||
export class InoLanguage extends SketchContribution {
|
export class InoLanguage extends SketchContribution {
|
||||||
@inject(HostedPluginEvents)
|
@inject(HostedPluginEvents)
|
||||||
private readonly hostedPluginEvents: HostedPluginEvents;
|
private readonly hostedPluginEvents: HostedPluginEvents;
|
||||||
|
|
||||||
@inject(ExecutableService)
|
@inject(ExecutableService)
|
||||||
private readonly executableService: ExecutableService;
|
private readonly executableService: ExecutableService;
|
||||||
|
|
||||||
@inject(ArduinoDaemon)
|
@inject(ArduinoDaemon)
|
||||||
private readonly daemon: ArduinoDaemon;
|
private readonly daemon: ArduinoDaemon;
|
||||||
|
|
||||||
@inject(BoardsService)
|
@inject(BoardsService)
|
||||||
private readonly boardsService: BoardsService;
|
private readonly boardsService: BoardsService;
|
||||||
|
|
||||||
@inject(BoardsServiceProvider)
|
@inject(BoardsServiceProvider)
|
||||||
private readonly boardsServiceProvider: BoardsServiceProvider;
|
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
|
||||||
@inject(NotificationCenter)
|
@inject(NotificationCenter)
|
||||||
private readonly notificationCenter: NotificationCenter;
|
private readonly notificationCenter: NotificationCenter;
|
||||||
|
|
||||||
@inject(BoardsDataStore)
|
@inject(BoardsDataStore)
|
||||||
private readonly boardDataStore: BoardsDataStore;
|
private readonly boardDataStore: BoardsDataStore;
|
||||||
|
|
||||||
@@ -45,7 +115,7 @@ export class InoLanguage extends SketchContribution {
|
|||||||
|
|
||||||
override onReady(): void {
|
override onReady(): void {
|
||||||
const start = (
|
const start = (
|
||||||
{ selectedBoard }: BoardsConfig.Config,
|
selectedBoard: BoardIdentifier | undefined,
|
||||||
forceStart = false
|
forceStart = false
|
||||||
) => {
|
) => {
|
||||||
if (selectedBoard) {
|
if (selectedBoard) {
|
||||||
@@ -56,12 +126,16 @@ export class InoLanguage extends SketchContribution {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const forceRestart = () => {
|
const forceRestart = () => {
|
||||||
start(this.boardsServiceProvider.boardsConfig, true);
|
start(this.boardsServiceProvider.boardsConfig.selectedBoard, true);
|
||||||
};
|
};
|
||||||
this.toDispose.pushAll([
|
this.toDispose.pushAll([
|
||||||
this.boardsServiceProvider.onBoardsConfigChanged(start),
|
this.boardsServiceProvider.onBoardsConfigDidChange((event) => {
|
||||||
|
if (isBoardIdentifierChangeEvent(event)) {
|
||||||
|
start(event.selectedBoard);
|
||||||
|
}
|
||||||
|
}),
|
||||||
this.hostedPluginEvents.onPluginsDidStart(() =>
|
this.hostedPluginEvents.onPluginsDidStart(() =>
|
||||||
start(this.boardsServiceProvider.boardsConfig)
|
start(this.boardsServiceProvider.boardsConfig.selectedBoard)
|
||||||
),
|
),
|
||||||
this.hostedPluginEvents.onPluginsWillUnload(
|
this.hostedPluginEvents.onPluginsWillUnload(
|
||||||
() => (this.languageServerFqbn = undefined)
|
() => (this.languageServerFqbn = undefined)
|
||||||
@@ -72,6 +146,7 @@ export class InoLanguage extends SketchContribution {
|
|||||||
switch (preferenceName) {
|
switch (preferenceName) {
|
||||||
case 'arduino.language.log':
|
case 'arduino.language.log':
|
||||||
case 'arduino.language.realTimeDiagnostics':
|
case 'arduino.language.realTimeDiagnostics':
|
||||||
|
case 'arduino.language.asyncWorkers':
|
||||||
forceRestart();
|
forceRestart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,7 +157,7 @@ export class InoLanguage extends SketchContribution {
|
|||||||
this.notificationCenter.onPlatformDidInstall(() => forceRestart()),
|
this.notificationCenter.onPlatformDidInstall(() => forceRestart()),
|
||||||
this.notificationCenter.onPlatformDidUninstall(() => forceRestart()),
|
this.notificationCenter.onPlatformDidUninstall(() => forceRestart()),
|
||||||
this.notificationCenter.onDidReinitialize(() => forceRestart()),
|
this.notificationCenter.onDidReinitialize(() => forceRestart()),
|
||||||
this.boardDataStore.onChanged((dataChangePerFqbn) => {
|
this.boardDataStore.onDidChange((event) => {
|
||||||
if (this.languageServerFqbn) {
|
if (this.languageServerFqbn) {
|
||||||
const sanitizedFqbn = sanitizeFqbn(this.languageServerFqbn);
|
const sanitizedFqbn = sanitizeFqbn(this.languageServerFqbn);
|
||||||
if (!sanitizeFqbn) {
|
if (!sanitizeFqbn) {
|
||||||
@@ -90,20 +165,25 @@ export class InoLanguage extends SketchContribution {
|
|||||||
`Failed to sanitize the FQBN of the running language server. FQBN with the board settings was: ${this.languageServerFqbn}`
|
`Failed to sanitize the FQBN of the running language server. FQBN with the board settings was: ${this.languageServerFqbn}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const matchingFqbn = dataChangePerFqbn.find(
|
const matchingChange = event.changes.find(
|
||||||
(fqbn) => sanitizedFqbn === fqbn
|
(change) => change.fqbn === sanitizedFqbn
|
||||||
);
|
);
|
||||||
const { boardsConfig } = this.boardsServiceProvider;
|
const { boardsConfig } = this.boardsServiceProvider;
|
||||||
if (
|
if (
|
||||||
matchingFqbn &&
|
matchingChange &&
|
||||||
boardsConfig.selectedBoard?.fqbn === matchingFqbn
|
boardsConfig.selectedBoard?.fqbn === matchingChange.fqbn
|
||||||
) {
|
) {
|
||||||
start(boardsConfig);
|
start(boardsConfig.selectedBoard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
start(this.boardsServiceProvider.boardsConfig);
|
Promise.all([
|
||||||
|
this.boardsServiceProvider.ready,
|
||||||
|
this.preferences.ready,
|
||||||
|
]).then(() => {
|
||||||
|
start(this.boardsServiceProvider.boardsConfig.selectedBoard);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onStop(): void {
|
onStop(): void {
|
||||||
@@ -119,7 +199,12 @@ export class InoLanguage extends SketchContribution {
|
|||||||
if (!port) {
|
if (!port) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const portNumber = Number.parseInt(port, 10); // TODO: IDE2 APIs should provide a number and not string
|
||||||
|
if (Number.isNaN(portNumber)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const release = await this.languageServerStartMutex.acquire();
|
const release = await this.languageServerStartMutex.acquire();
|
||||||
|
const toDisposeOnRelease = new DisposableCollection();
|
||||||
try {
|
try {
|
||||||
await this.hostedPluginEvents.didStart;
|
await this.hostedPluginEvents.didStart;
|
||||||
const details = await this.boardsService.getBoardDetails({ fqbn });
|
const details = await this.boardsService.getBoardDetails({ fqbn });
|
||||||
@@ -158,11 +243,16 @@ export class InoLanguage extends SketchContribution {
|
|||||||
// NOOP
|
// NOOP
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.logger.info(`Starting language server: ${fqbnWithConfig}`);
|
|
||||||
const log = this.preferences.get('arduino.language.log');
|
const log = this.preferences.get('arduino.language.log');
|
||||||
const realTimeDiagnostics = this.preferences.get(
|
const realTimeDiagnostics = this.preferences.get(
|
||||||
'arduino.language.realTimeDiagnostics'
|
'arduino.language.realTimeDiagnostics'
|
||||||
);
|
);
|
||||||
|
const jobs = this.getAsyncWorkersPreferenceSafe();
|
||||||
|
this.logger.info(
|
||||||
|
`Starting language server: ${fqbnWithConfig}${
|
||||||
|
jobs ? ` (async worker count: ${jobs})` : ''
|
||||||
|
}`
|
||||||
|
);
|
||||||
let currentSketchPath: string | undefined = undefined;
|
let currentSketchPath: string | undefined = undefined;
|
||||||
if (log) {
|
if (log) {
|
||||||
const currentSketch = await this.sketchServiceClient.currentSketch();
|
const currentSketch = await this.sketchServiceClient.currentSketch();
|
||||||
@@ -179,34 +269,61 @@ export class InoLanguage extends SketchContribution {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
this.languageServerFqbn = await Promise.race([
|
this.languageServerFqbn = await Promise.race([
|
||||||
new Promise<undefined>((_, reject) =>
|
new Promise<undefined>((_, reject) => {
|
||||||
setTimeout(
|
const timer = setTimeout(
|
||||||
() => reject(new Error(`Timeout after ${20_000} ms.`)),
|
() => reject(new Error(`Timeout after ${20_000} ms.`)),
|
||||||
20_000
|
20_000
|
||||||
)
|
);
|
||||||
),
|
toDisposeOnRelease.push(Disposable.create(() => clearTimeout(timer)));
|
||||||
this.commandService.executeCommand<string>(
|
}),
|
||||||
'arduino.languageserver.start',
|
this.start({
|
||||||
{
|
lsPath,
|
||||||
lsPath,
|
daemonAddress: {
|
||||||
cliDaemonAddr: `localhost:${port}`,
|
hostname: 'localhost',
|
||||||
clangdPath,
|
port: portNumber,
|
||||||
log: currentSketchPath ? currentSketchPath : log,
|
instance: 1, // TODO: get it from the backend
|
||||||
cliDaemonInstance: '1',
|
},
|
||||||
board: {
|
clangdPath,
|
||||||
fqbn: fqbnWithConfig,
|
log: currentSketchPath ? currentSketchPath : log,
|
||||||
name: name ? `"${name}"` : undefined,
|
board: {
|
||||||
},
|
fqbn: fqbnWithConfig,
|
||||||
realTimeDiagnostics,
|
name,
|
||||||
silentOutput: true,
|
},
|
||||||
}
|
realTimeDiagnostics,
|
||||||
),
|
silentOutput: true,
|
||||||
|
jobs,
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(`Failed to start language server. Original FQBN: ${fqbn}`, e);
|
console.log(`Failed to start language server. Original FQBN: ${fqbn}`, e);
|
||||||
this.languageServerFqbn = undefined;
|
this.languageServerFqbn = undefined;
|
||||||
} finally {
|
} finally {
|
||||||
|
toDisposeOnRelease.dispose();
|
||||||
release();
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
import { CommandRegistry, MaybePromise, nls } from '@theia/core/lib/common';
|
import { CommandRegistry, MaybePromise, nls } from '@theia/core/lib/common';
|
||||||
import { Settings } from '../dialogs/settings/settings';
|
import { Settings } from '../dialogs/settings/settings';
|
||||||
import debounce = require('lodash.debounce');
|
import debounce from 'lodash.debounce';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class InterfaceScale extends Contribution {
|
export class InterfaceScale extends Contribution {
|
||||||
|
|||||||
@@ -1,25 +1,18 @@
|
|||||||
import { CommandRegistry } from '@theia/core';
|
import type { Command, CommandRegistry } from '@theia/core/lib/common/command';
|
||||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import type { EditBoardsConfigActionParams } from '../../common/protocol/board-list';
|
||||||
import { BoardsConfigDialog } from '../boards/boards-config-dialog';
|
import { BoardsConfigDialog } from '../boards/boards-config-dialog';
|
||||||
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
import { Contribution } from './contribution';
|
||||||
import { Contribution, Command } from './contribution';
|
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class OpenBoardsConfig extends Contribution {
|
export class OpenBoardsConfig extends Contribution {
|
||||||
@inject(BoardsServiceProvider)
|
|
||||||
private readonly boardsServiceProvider: BoardsServiceProvider;
|
|
||||||
|
|
||||||
@inject(BoardsConfigDialog)
|
@inject(BoardsConfigDialog)
|
||||||
private readonly boardsConfigDialog: BoardsConfigDialog;
|
private readonly boardsConfigDialog: BoardsConfigDialog;
|
||||||
|
|
||||||
override registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(OpenBoardsConfig.Commands.OPEN_DIALOG, {
|
registry.registerCommand(OpenBoardsConfig.Commands.OPEN_DIALOG, {
|
||||||
execute: async (query?: string | undefined) => {
|
execute: async (params?: EditBoardsConfigActionParams) =>
|
||||||
const boardsConfig = await this.boardsConfigDialog.open(query);
|
this.boardsConfigDialog.open(params),
|
||||||
if (boardsConfig) {
|
|
||||||
return (this.boardsServiceProvider.boardsConfig = boardsConfig);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { injectable } from '@theia/core/shared/inversify';
|
import { 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 { ArduinoMenus } from '../menu/arduino-menus';
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
import {
|
import {
|
||||||
@@ -9,7 +8,7 @@ import {
|
|||||||
MenuModelRegistry,
|
MenuModelRegistry,
|
||||||
KeybindingRegistry,
|
KeybindingRegistry,
|
||||||
} from './contribution';
|
} from './contribution';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class OpenSketchExternal extends SketchContribution {
|
export class OpenSketchExternal extends SketchContribution {
|
||||||
@@ -41,7 +40,7 @@ export class OpenSketchExternal extends SketchContribution {
|
|||||||
if (exists) {
|
if (exists) {
|
||||||
const fsPath = await this.fileService.fsPath(new URI(uri));
|
const fsPath = await this.fileService.fsPath(new URI(uri));
|
||||||
if (fsPath) {
|
if (fsPath) {
|
||||||
remote.shell.showItemInFolder(fsPath);
|
window.electronTheiaCore.showItemInFolder(fsPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,11 @@ export class OpenSketchFiles extends SketchContribution {
|
|||||||
await this.ensureOpened(uri);
|
await this.ensureOpened(uri);
|
||||||
}
|
}
|
||||||
if (focusMainSketchFile) {
|
if (focusMainSketchFile) {
|
||||||
await this.ensureOpened(mainFileUri, true, { mode: 'activate' });
|
await this.ensureOpened(mainFileUri, true, {
|
||||||
|
mode: 'activate',
|
||||||
|
preview: false,
|
||||||
|
counter: 0,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (mainFileUri.endsWith('.pde')) {
|
if (mainFileUri.endsWith('.pde')) {
|
||||||
const message = nls.localize(
|
const message = nls.localize(
|
||||||
@@ -114,6 +118,7 @@ export class OpenSketchFiles extends SketchContribution {
|
|||||||
fileService: this.fileService,
|
fileService: this.fileService,
|
||||||
sketchesService: this.sketchesService,
|
sketchesService: this.sketchesService,
|
||||||
labelProvider: this.labelProvider,
|
labelProvider: this.labelProvider,
|
||||||
|
dialogService: this.dialogService,
|
||||||
});
|
});
|
||||||
if (movedSketch) {
|
if (movedSketch) {
|
||||||
this.workspaceService.open(new URI(movedSketch.uri), {
|
this.workspaceService.open(new URI(movedSketch.uri), {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
|
||||||
import { nls } from '@theia/core/lib/common/nls';
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
import { injectable } from '@theia/core/shared/inversify';
|
import { injectable } from '@theia/core/shared/inversify';
|
||||||
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
||||||
@@ -18,6 +17,7 @@ import {
|
|||||||
SketchContribution,
|
SketchContribution,
|
||||||
URI,
|
URI,
|
||||||
} from './contribution';
|
} from './contribution';
|
||||||
|
import { DialogService } from '../dialog-service';
|
||||||
|
|
||||||
export type SketchLocation = string | URI | SketchRef;
|
export type SketchLocation = string | URI | SketchRef;
|
||||||
export namespace SketchLocation {
|
export namespace SketchLocation {
|
||||||
@@ -83,19 +83,16 @@ export class OpenSketch extends SketchContribution {
|
|||||||
|
|
||||||
private async selectSketch(): Promise<Sketch | undefined> {
|
private async selectSketch(): Promise<Sketch | undefined> {
|
||||||
const defaultPath = await this.defaultPath();
|
const defaultPath = await this.defaultPath();
|
||||||
const { filePaths } = await remote.dialog.showOpenDialog(
|
const { filePaths } = await this.dialogService.showOpenDialog({
|
||||||
remote.getCurrentWindow(),
|
defaultPath,
|
||||||
{
|
properties: ['createDirectory', 'openFile'],
|
||||||
defaultPath,
|
filters: [
|
||||||
properties: ['createDirectory', 'openFile'],
|
{
|
||||||
filters: [
|
name: nls.localize('arduino/sketch/sketch', 'Sketch'),
|
||||||
{
|
extensions: ['ino', 'pde'],
|
||||||
name: nls.localize('arduino/sketch/sketch', 'Sketch'),
|
},
|
||||||
extensions: ['ino', 'pde'],
|
],
|
||||||
},
|
});
|
||||||
],
|
|
||||||
}
|
|
||||||
);
|
|
||||||
if (!filePaths.length) {
|
if (!filePaths.length) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -115,6 +112,7 @@ export class OpenSketch extends SketchContribution {
|
|||||||
fileService: this.fileService,
|
fileService: this.fileService,
|
||||||
sketchesService: this.sketchesService,
|
sketchesService: this.sketchesService,
|
||||||
labelProvider: this.labelProvider,
|
labelProvider: this.labelProvider,
|
||||||
|
dialogService: this.dialogService,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,14 +132,16 @@ export async function promptMoveSketch(
|
|||||||
fileService: FileService;
|
fileService: FileService;
|
||||||
sketchesService: SketchesService;
|
sketchesService: SketchesService;
|
||||||
labelProvider: LabelProvider;
|
labelProvider: LabelProvider;
|
||||||
|
dialogService: DialogService;
|
||||||
}
|
}
|
||||||
): Promise<Sketch | undefined> {
|
): Promise<Sketch | undefined> {
|
||||||
const { fileService, sketchesService, labelProvider } = options;
|
const { fileService, sketchesService, labelProvider, dialogService } =
|
||||||
|
options;
|
||||||
const uri =
|
const uri =
|
||||||
sketchFileUri instanceof URI ? sketchFileUri : new URI(sketchFileUri);
|
sketchFileUri instanceof URI ? sketchFileUri : new URI(sketchFileUri);
|
||||||
const name = uri.path.name;
|
const name = uri.path.name;
|
||||||
const nameWithExt = labelProvider.getName(uri);
|
const nameWithExt = labelProvider.getName(uri);
|
||||||
const { response } = await remote.dialog.showMessageBox({
|
const { response } = await dialogService.showMessageBox({
|
||||||
title: nls.localize('arduino/sketch/moving', 'Moving'),
|
title: nls.localize('arduino/sketch/moving', 'Moving'),
|
||||||
type: 'question',
|
type: 'question',
|
||||||
buttons: [
|
buttons: [
|
||||||
@@ -160,7 +160,7 @@ export async function promptMoveSketch(
|
|||||||
const newSketchUri = uri.parent.resolve(name);
|
const newSketchUri = uri.parent.resolve(name);
|
||||||
const exists = await fileService.exists(newSketchUri);
|
const exists = await fileService.exists(newSketchUri);
|
||||||
if (exists) {
|
if (exists) {
|
||||||
await remote.dialog.showMessageBox({
|
await dialogService.showMessageBox({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
title: nls.localize('vscode/dialog/dialogErrorMessage', 'Error'),
|
title: nls.localize('vscode/dialog/dialogErrorMessage', 'Error'),
|
||||||
message: nls.localize(
|
message: nls.localize(
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { injectable } from '@theia/core/shared/inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
|
||||||
import { isOSX } from '@theia/core/lib/common/os';
|
import { isOSX } from '@theia/core/lib/common/os';
|
||||||
import {
|
import {
|
||||||
Contribution,
|
Contribution,
|
||||||
@@ -9,14 +8,18 @@ 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';
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { AppService } from '../app-service';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class QuitApp extends Contribution {
|
export class QuitApp extends Contribution {
|
||||||
|
@inject(AppService)
|
||||||
|
private readonly appService: AppService;
|
||||||
|
|
||||||
override registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
if (!isOSX) {
|
if (!isOSX) {
|
||||||
registry.registerCommand(QuitApp.Commands.QUIT_APP, {
|
registry.registerCommand(QuitApp.Commands.QUIT_APP, {
|
||||||
execute: () => remote.app.quit(),
|
execute: () => this.appService.quit(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
|
||||||
import { Dialog } from '@theia/core/lib/browser/dialogs';
|
import { Dialog } from '@theia/core/lib/browser/dialogs';
|
||||||
import { NavigatableWidget } from '@theia/core/lib/browser/navigatable';
|
import { NavigatableWidget } from '@theia/core/lib/browser/navigatable';
|
||||||
import { Saveable } from '@theia/core/lib/browser/saveable';
|
import { Saveable } from '@theia/core/lib/browser/saveable';
|
||||||
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
|
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
|
||||||
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
||||||
|
import { ApplicationError } from '@theia/core/lib/common/application-error';
|
||||||
import { nls } from '@theia/core/lib/common/nls';
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
||||||
import { WorkspaceInput } from '@theia/workspace/lib/browser/workspace-service';
|
import { WorkspaceInput } from '@theia/workspace/lib/browser/workspace-service';
|
||||||
import { StartupTask } from '../../electron-common/startup-task';
|
import { SketchesError } from '../../common/protocol';
|
||||||
|
import { StartupTasks } from '../../electron-common/startup-task';
|
||||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
import { CurrentSketch } from '../sketches-service-client-impl';
|
import { CurrentSketch } from '../sketches-service-client-impl';
|
||||||
import { CloudSketchContribution } from './cloud-contribution';
|
import { CloudSketchContribution } from './cloud-contribution';
|
||||||
@@ -25,6 +26,7 @@ import {
|
|||||||
RenameCloudSketch,
|
RenameCloudSketch,
|
||||||
RenameCloudSketchParams,
|
RenameCloudSketchParams,
|
||||||
} from './rename-cloud-sketch';
|
} from './rename-cloud-sketch';
|
||||||
|
import { assertConnectedToBackend } from './save-sketch';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class SaveAsSketch extends CloudSketchContribution {
|
export class SaveAsSketch extends CloudSketchContribution {
|
||||||
@@ -35,7 +37,29 @@ export class SaveAsSketch extends CloudSketchContribution {
|
|||||||
|
|
||||||
override registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(SaveAsSketch.Commands.SAVE_AS_SKETCH, {
|
registry.registerCommand(SaveAsSketch.Commands.SAVE_AS_SKETCH, {
|
||||||
execute: (args) => this.saveAs(args),
|
execute: async (args) => {
|
||||||
|
try {
|
||||||
|
return await this.saveAs(args);
|
||||||
|
} catch (err) {
|
||||||
|
let message = String(err);
|
||||||
|
if (ApplicationError.is(err)) {
|
||||||
|
if (SketchesError.SketchAlreadyContainsThisFile.is(err)) {
|
||||||
|
message = nls.localize(
|
||||||
|
'arduino/sketch/sketchAlreadyContainsThisFileMessage',
|
||||||
|
'Failed to save sketch "{0}" as "{1}". {2}',
|
||||||
|
err.data.sourceSketchName,
|
||||||
|
err.data.targetSketchName,
|
||||||
|
err.message
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
message = err.message;
|
||||||
|
}
|
||||||
|
} else if (err instanceof Error) {
|
||||||
|
message = err.message;
|
||||||
|
}
|
||||||
|
this.messageService.error(message);
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,13 +82,18 @@ export class SaveAsSketch extends CloudSketchContribution {
|
|||||||
* Resolves `true` if the sketch was successfully saved as something.
|
* Resolves `true` if the sketch was successfully saved as something.
|
||||||
*/
|
*/
|
||||||
private async saveAs(
|
private async saveAs(
|
||||||
{
|
params = SaveAsSketch.Options.DEFAULT
|
||||||
|
): Promise<boolean> {
|
||||||
|
const {
|
||||||
execOnlyIfTemp,
|
execOnlyIfTemp,
|
||||||
openAfterMove,
|
openAfterMove,
|
||||||
wipeOriginal,
|
wipeOriginal,
|
||||||
markAsRecentlyOpened,
|
markAsRecentlyOpened,
|
||||||
}: SaveAsSketch.Options = SaveAsSketch.Options.DEFAULT
|
} = params;
|
||||||
): Promise<boolean> {
|
assertConnectedToBackend({
|
||||||
|
connectionStatusService: this.connectionStatusService,
|
||||||
|
messageService: this.messageService,
|
||||||
|
});
|
||||||
const sketch = await this.sketchServiceClient.currentSketch();
|
const sketch = await this.sketchServiceClient.currentSketch();
|
||||||
if (!CurrentSketch.isValid(sketch)) {
|
if (!CurrentSketch.isValid(sketch)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -95,7 +124,7 @@ export class SaveAsSketch extends CloudSketchContribution {
|
|||||||
if (markAsRecentlyOpened) {
|
if (markAsRecentlyOpened) {
|
||||||
this.sketchesService.markAsRecentlyOpened(newWorkspaceUri);
|
this.sketchesService.markAsRecentlyOpened(newWorkspaceUri);
|
||||||
}
|
}
|
||||||
const options: WorkspaceInput & StartupTask.Owner = {
|
const options: WorkspaceInput & StartupTasks = {
|
||||||
preserveWindow: true,
|
preserveWindow: true,
|
||||||
tasks: [],
|
tasks: [],
|
||||||
};
|
};
|
||||||
@@ -165,16 +194,13 @@ export class SaveAsSketch extends CloudSketchContribution {
|
|||||||
): Promise<string | undefined> {
|
): Promise<string | undefined> {
|
||||||
let sketchFolderDestinationUri: string | undefined;
|
let sketchFolderDestinationUri: string | undefined;
|
||||||
while (!sketchFolderDestinationUri) {
|
while (!sketchFolderDestinationUri) {
|
||||||
const { filePath } = await remote.dialog.showSaveDialog(
|
const { filePath } = await this.dialogService.showSaveDialog({
|
||||||
remote.getCurrentWindow(),
|
title: nls.localize(
|
||||||
{
|
'arduino/sketch/saveFolderAs',
|
||||||
title: nls.localize(
|
'Save sketch folder as...'
|
||||||
'arduino/sketch/saveFolderAs',
|
),
|
||||||
'Save sketch folder as...'
|
defaultPath,
|
||||||
),
|
});
|
||||||
defaultPath,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
if (!filePath) {
|
if (!filePath) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -225,13 +251,10 @@ ${dialogContent.details}
|
|||||||
|
|
||||||
${dialogContent.question}`.trim();
|
${dialogContent.question}`.trim();
|
||||||
defaultPath = filePath;
|
defaultPath = filePath;
|
||||||
const { response } = await remote.dialog.showMessageBox(
|
const { response } = await this.dialogService.showMessageBox({
|
||||||
remote.getCurrentWindow(),
|
message,
|
||||||
{
|
buttons: [Dialog.CANCEL, Dialog.YES],
|
||||||
message,
|
});
|
||||||
buttons: [Dialog.CANCEL, Dialog.YES],
|
|
||||||
}
|
|
||||||
);
|
|
||||||
// cancel
|
// cancel
|
||||||
if (response === 0) {
|
if (response === 0) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
import { 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 { MessageService } from '@theia/core/lib/common/message-service';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { injectable } from '@theia/core/shared/inversify';
|
||||||
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 { ApplicationConnectionStatusContribution } from '../theia/core/connection-status-service';
|
||||||
import {
|
import {
|
||||||
SketchContribution,
|
|
||||||
Command,
|
Command,
|
||||||
CommandRegistry,
|
CommandRegistry,
|
||||||
MenuModelRegistry,
|
|
||||||
KeybindingRegistry,
|
KeybindingRegistry,
|
||||||
|
MenuModelRegistry,
|
||||||
|
SketchContribution,
|
||||||
} from './contribution';
|
} from './contribution';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import { SaveAsSketch } from './save-as-sketch';
|
||||||
import { CurrentSketch } from '../sketches-service-client-impl';
|
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class SaveSketch extends SketchContribution {
|
export class SaveSketch extends SketchContribution {
|
||||||
@@ -36,6 +38,10 @@ export class SaveSketch extends SketchContribution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async saveSketch(): Promise<void> {
|
async saveSketch(): Promise<void> {
|
||||||
|
assertConnectedToBackend({
|
||||||
|
connectionStatusService: this.connectionStatusService,
|
||||||
|
messageService: this.messageService,
|
||||||
|
});
|
||||||
const sketch = await this.sketchServiceClient.currentSketch();
|
const sketch = await this.sketchServiceClient.currentSketch();
|
||||||
if (!CurrentSketch.isValid(sketch)) {
|
if (!CurrentSketch.isValid(sketch)) {
|
||||||
return;
|
return;
|
||||||
@@ -63,3 +69,18 @@ export namespace SaveSketch {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/arduino/arduino-ide/issues/2081
|
||||||
|
export function assertConnectedToBackend(param: {
|
||||||
|
connectionStatusService: ApplicationConnectionStatusContribution;
|
||||||
|
messageService: MessageService;
|
||||||
|
}): void {
|
||||||
|
if (param.connectionStatusService.offlineStatus === 'backend') {
|
||||||
|
const message = nls.localize(
|
||||||
|
'theia/core/couldNotSave',
|
||||||
|
'Could not save the sketch. Please copy your unsaved work into your favorite text editor, and restart the IDE.'
|
||||||
|
);
|
||||||
|
param.messageService.error(message);
|
||||||
|
throw new Error(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ import {
|
|||||||
} from '@theia/core/lib/browser/status-bar/status-bar';
|
} from '@theia/core/lib/browser/status-bar/status-bar';
|
||||||
import { nls } from '@theia/core/lib/common/nls';
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { BoardsConfig } from '../boards/boards-config';
|
import type {
|
||||||
|
BoardList,
|
||||||
|
BoardListItem,
|
||||||
|
} from '../../common/protocol/board-list';
|
||||||
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
||||||
import { Contribution } from './contribution';
|
import { Contribution } from './contribution';
|
||||||
|
|
||||||
@@ -12,21 +15,23 @@ import { Contribution } from './contribution';
|
|||||||
export class SelectedBoard extends Contribution {
|
export class SelectedBoard extends Contribution {
|
||||||
@inject(StatusBar)
|
@inject(StatusBar)
|
||||||
private readonly statusBar: StatusBar;
|
private readonly statusBar: StatusBar;
|
||||||
|
|
||||||
@inject(BoardsServiceProvider)
|
@inject(BoardsServiceProvider)
|
||||||
private readonly boardsServiceProvider: BoardsServiceProvider;
|
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
|
||||||
override onStart(): void {
|
override onStart(): void {
|
||||||
this.boardsServiceProvider.onBoardsConfigChanged((config) =>
|
this.boardsServiceProvider.onBoardListDidChange((boardList) =>
|
||||||
this.update(config)
|
this.update(boardList)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
override onReady(): void {
|
override onReady(): void {
|
||||||
this.update(this.boardsServiceProvider.boardsConfig);
|
this.boardsServiceProvider.ready.then(() => this.update());
|
||||||
}
|
}
|
||||||
|
|
||||||
private update({ selectedBoard, selectedPort }: BoardsConfig.Config): void {
|
private update(
|
||||||
|
boardList: BoardList = this.boardsServiceProvider.boardList
|
||||||
|
): void {
|
||||||
|
const { selectedBoard, selectedPort } = boardList.boardsConfig;
|
||||||
this.statusBar.setElement('arduino-selected-board', {
|
this.statusBar.setElement('arduino-selected-board', {
|
||||||
alignment: StatusBarAlignment.RIGHT,
|
alignment: StatusBarAlignment.RIGHT,
|
||||||
text: selectedBoard
|
text: selectedBoard
|
||||||
@@ -38,17 +43,30 @@ export class SelectedBoard extends Contribution {
|
|||||||
className: 'arduino-selected-board',
|
className: 'arduino-selected-board',
|
||||||
});
|
});
|
||||||
if (selectedBoard) {
|
if (selectedBoard) {
|
||||||
|
const notConnectedLabel = nls.localize(
|
||||||
|
'arduino/common/notConnected',
|
||||||
|
'[not connected]'
|
||||||
|
);
|
||||||
|
let portLabel = notConnectedLabel;
|
||||||
|
if (selectedPort) {
|
||||||
|
portLabel = nls.localize(
|
||||||
|
'arduino/common/selectedOn',
|
||||||
|
'on {0}',
|
||||||
|
selectedPort.address
|
||||||
|
);
|
||||||
|
const selectedItem: BoardListItem | undefined =
|
||||||
|
boardList.items[boardList.selectedIndex];
|
||||||
|
if (!selectedItem) {
|
||||||
|
portLabel += ` ${notConnectedLabel}`; // append ` [not connected]` when the port is selected but it's not detected by the CLI
|
||||||
|
}
|
||||||
|
}
|
||||||
this.statusBar.setElement('arduino-selected-port', {
|
this.statusBar.setElement('arduino-selected-port', {
|
||||||
alignment: StatusBarAlignment.RIGHT,
|
alignment: StatusBarAlignment.RIGHT,
|
||||||
text: selectedPort
|
text: portLabel,
|
||||||
? nls.localize(
|
|
||||||
'arduino/common/selectedOn',
|
|
||||||
'on {0}',
|
|
||||||
selectedPort.address
|
|
||||||
)
|
|
||||||
: nls.localize('arduino/common/notConnected', '[not connected]'),
|
|
||||||
className: 'arduino-selected-port',
|
className: 'arduino-selected-port',
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.statusBar.removeElement('arduino-selected-port');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
|
||||||
import type { IpcRendererEvent } from '@theia/core/electron-shared/electron';
|
|
||||||
import { ipcRenderer } from '@theia/core/electron-shared/electron';
|
|
||||||
import { injectable } from '@theia/core/shared/inversify';
|
|
||||||
import { StartupTask } from '../../electron-common/startup-task';
|
|
||||||
import { Contribution } from './contribution';
|
|
||||||
|
|
||||||
@injectable()
|
|
||||||
export class StartupTasks extends Contribution {
|
|
||||||
override onReady(): void {
|
|
||||||
ipcRenderer.once(
|
|
||||||
StartupTask.Messaging.STARTUP_TASKS_SIGNAL,
|
|
||||||
(_: IpcRendererEvent, args: unknown) => {
|
|
||||||
console.debug(
|
|
||||||
`Received the startup tasks from the electron main process. Args: ${JSON.stringify(
|
|
||||||
args
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
if (!StartupTask.has(args)) {
|
|
||||||
console.warn(`Could not detect 'tasks' from the signal. Skipping.`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const tasks = args.tasks;
|
|
||||||
if (tasks.length) {
|
|
||||||
console.log(`Executing startup tasks:`);
|
|
||||||
tasks.forEach(({ command, args = [] }) => {
|
|
||||||
console.log(
|
|
||||||
` - '${command}' ${
|
|
||||||
args.length ? `, args: ${JSON.stringify(args)}` : ''
|
|
||||||
}`
|
|
||||||
);
|
|
||||||
this.commandService
|
|
||||||
.executeCommand(command, ...args)
|
|
||||||
.catch((err) =>
|
|
||||||
console.error(
|
|
||||||
`Error occurred when executing the startup task '${command}'${
|
|
||||||
args?.length ? ` with args: '${JSON.stringify(args)}` : ''
|
|
||||||
}.`,
|
|
||||||
err
|
|
||||||
)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const { id } = remote.getCurrentWindow();
|
|
||||||
console.debug(
|
|
||||||
`Signalling app ready event to the electron main process. Sender ID: ${id}.`
|
|
||||||
);
|
|
||||||
ipcRenderer.send(StartupTask.Messaging.APP_READY_SIGNAL(id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
||||||
|
import {
|
||||||
|
inject,
|
||||||
|
injectable,
|
||||||
|
postConstruct,
|
||||||
|
} from '@theia/core/shared/inversify';
|
||||||
|
import {
|
||||||
|
hasStartupTasks,
|
||||||
|
StartupTasks,
|
||||||
|
} from '../../electron-common/startup-task';
|
||||||
|
import { AppService } from '../app-service';
|
||||||
|
import { Contribution } from './contribution';
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class StartupTasksExecutor extends Contribution {
|
||||||
|
@inject(AppService)
|
||||||
|
private readonly appService: AppService;
|
||||||
|
|
||||||
|
private readonly toDispose = new DisposableCollection();
|
||||||
|
|
||||||
|
@postConstruct()
|
||||||
|
protected override init(): void {
|
||||||
|
super.init();
|
||||||
|
this.toDispose.push(
|
||||||
|
this.appService.registerStartupTasksHandler((tasks) =>
|
||||||
|
this.handleStartupTasks(tasks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onStop(): void {
|
||||||
|
this.toDispose.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async handleStartupTasks(tasks: StartupTasks): Promise<void> {
|
||||||
|
console.debug(
|
||||||
|
`Received the startup tasks from the electron main process. Args: ${JSON.stringify(
|
||||||
|
tasks
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
if (!hasStartupTasks(tasks)) {
|
||||||
|
console.warn(`Could not detect 'tasks' from the signal. Skipping.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await this.appStateService.reachedState('ready');
|
||||||
|
console.log(`Executing startup tasks:`);
|
||||||
|
tasks.tasks.forEach(({ command, args = [] }) => {
|
||||||
|
console.log(
|
||||||
|
` - '${command}' ${
|
||||||
|
args.length ? `, args: ${JSON.stringify(args)}` : ''
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
this.commandService
|
||||||
|
.executeCommand(command, ...args)
|
||||||
|
.catch((err) =>
|
||||||
|
console.error(
|
||||||
|
`Error occurred when executing the startup task '${command}'${
|
||||||
|
args?.length ? ` with args: '${JSON.stringify(args)}` : ''
|
||||||
|
}.`,
|
||||||
|
err
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,184 @@
|
|||||||
|
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
||||||
|
import URI from '@theia/core/lib/common/uri';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { HostedPluginSupport } from '../hosted/hosted-plugin-support';
|
||||||
|
import type { ArduinoState } from 'vscode-arduino-api';
|
||||||
|
import {
|
||||||
|
BoardsService,
|
||||||
|
CompileSummary,
|
||||||
|
isCompileSummary,
|
||||||
|
BoardsConfig,
|
||||||
|
PortIdentifier,
|
||||||
|
resolveDetectedPort,
|
||||||
|
} from '../../common/protocol';
|
||||||
|
import {
|
||||||
|
toApiBoardDetails,
|
||||||
|
toApiCompileSummary,
|
||||||
|
toApiPort,
|
||||||
|
} from '../../common/protocol/arduino-context-mapper';
|
||||||
|
import { BoardsDataStore } from '../boards/boards-data-store';
|
||||||
|
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
||||||
|
import { CurrentSketch } from '../sketches-service-client-impl';
|
||||||
|
import { SketchContribution } from './contribution';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (non-API) exported for tests
|
||||||
|
*/
|
||||||
|
export interface UpdateStateParams<T extends ArduinoState = ArduinoState> {
|
||||||
|
readonly key: keyof T;
|
||||||
|
readonly value: T[keyof T];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contribution for updating the Arduino state, such as the FQBN, selected port, and sketch path changes via commands, so other VS Code extensions can access it.
|
||||||
|
* See [`vscode-arduino-api`](https://github.com/dankeboy36/vscode-arduino-api#api) for more details.
|
||||||
|
*/
|
||||||
|
@injectable()
|
||||||
|
export class UpdateArduinoState extends SketchContribution {
|
||||||
|
@inject(BoardsService)
|
||||||
|
private readonly boardsService: BoardsService;
|
||||||
|
@inject(BoardsServiceProvider)
|
||||||
|
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
@inject(BoardsDataStore)
|
||||||
|
private readonly boardsDataStore: BoardsDataStore;
|
||||||
|
@inject(HostedPluginSupport)
|
||||||
|
private readonly hostedPluginSupport: HostedPluginSupport;
|
||||||
|
|
||||||
|
private readonly toDispose = new DisposableCollection();
|
||||||
|
|
||||||
|
override onStart(): void {
|
||||||
|
this.toDispose.pushAll([
|
||||||
|
this.boardsServiceProvider.onBoardsConfigDidChange(() =>
|
||||||
|
this.updateBoardsConfig(this.boardsServiceProvider.boardsConfig)
|
||||||
|
),
|
||||||
|
this.sketchServiceClient.onCurrentSketchDidChange((sketch) =>
|
||||||
|
this.updateSketchPath(sketch)
|
||||||
|
),
|
||||||
|
this.configService.onDidChangeDataDirUri((dataDirUri) =>
|
||||||
|
this.updateDataDirPath(dataDirUri)
|
||||||
|
),
|
||||||
|
this.configService.onDidChangeSketchDirUri((userDirUri) =>
|
||||||
|
this.updateUserDirPath(userDirUri)
|
||||||
|
),
|
||||||
|
this.commandService.onDidExecuteCommand(({ commandId, args }) => {
|
||||||
|
if (
|
||||||
|
commandId === 'arduino.languageserver.notifyBuildDidComplete' &&
|
||||||
|
isCompileSummary(args[0])
|
||||||
|
) {
|
||||||
|
this.updateCompileSummary(args[0]);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
this.boardsDataStore.onDidChange((event) => {
|
||||||
|
const selectedFqbn =
|
||||||
|
this.boardsServiceProvider.boardsConfig.selectedBoard?.fqbn;
|
||||||
|
if (
|
||||||
|
selectedFqbn &&
|
||||||
|
event.changes.find((change) => change.fqbn === selectedFqbn)
|
||||||
|
) {
|
||||||
|
this.updateBoardDetails(selectedFqbn);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
override onReady(): void {
|
||||||
|
this.boardsServiceProvider.ready.then(() => {
|
||||||
|
this.updateBoardsConfig(this.boardsServiceProvider.boardsConfig);
|
||||||
|
});
|
||||||
|
this.updateSketchPath(this.sketchServiceClient.tryGetCurrentSketch());
|
||||||
|
this.updateUserDirPath(this.configService.tryGetSketchDirUri());
|
||||||
|
this.updateDataDirPath(this.configService.tryGetDataDirUri());
|
||||||
|
}
|
||||||
|
|
||||||
|
onStop(): void {
|
||||||
|
this.toDispose.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updateSketchPath(
|
||||||
|
sketch: CurrentSketch | undefined
|
||||||
|
): Promise<void> {
|
||||||
|
const sketchPath = CurrentSketch.isValid(sketch)
|
||||||
|
? new URI(sketch.uri).path.fsPath()
|
||||||
|
: undefined;
|
||||||
|
return this.updateState({ key: 'sketchPath', value: sketchPath });
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updateCompileSummary(
|
||||||
|
compileSummary: CompileSummary
|
||||||
|
): Promise<void> {
|
||||||
|
const apiCompileSummary = toApiCompileSummary(compileSummary);
|
||||||
|
return this.updateState({
|
||||||
|
key: 'compileSummary',
|
||||||
|
value: apiCompileSummary,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updateBoardsConfig(boardsConfig: BoardsConfig): Promise<void> {
|
||||||
|
const fqbn = boardsConfig.selectedBoard?.fqbn;
|
||||||
|
const port = boardsConfig.selectedPort;
|
||||||
|
await this.updateFqbn(fqbn);
|
||||||
|
await this.updateBoardDetails(fqbn);
|
||||||
|
await this.updatePort(port);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updateFqbn(fqbn: string | undefined): Promise<void> {
|
||||||
|
await this.updateState({ key: 'fqbn', value: fqbn });
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updateBoardDetails(fqbn: string | undefined): Promise<void> {
|
||||||
|
const unset = () =>
|
||||||
|
this.updateState({ key: 'boardDetails', value: undefined });
|
||||||
|
if (!fqbn) {
|
||||||
|
return unset();
|
||||||
|
}
|
||||||
|
const [details, persistedData] = await Promise.all([
|
||||||
|
this.boardsService.getBoardDetails({ fqbn }),
|
||||||
|
this.boardsDataStore.getData(fqbn),
|
||||||
|
]);
|
||||||
|
if (!details) {
|
||||||
|
return unset();
|
||||||
|
}
|
||||||
|
const apiBoardDetails = toApiBoardDetails({
|
||||||
|
...details,
|
||||||
|
configOptions:
|
||||||
|
BoardsDataStore.Data.EMPTY === persistedData
|
||||||
|
? details.configOptions
|
||||||
|
: persistedData.configOptions.slice(),
|
||||||
|
});
|
||||||
|
return this.updateState({
|
||||||
|
key: 'boardDetails',
|
||||||
|
value: apiBoardDetails,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updatePort(port: PortIdentifier | undefined): Promise<void> {
|
||||||
|
const resolvedPort =
|
||||||
|
port &&
|
||||||
|
resolveDetectedPort(port, this.boardsServiceProvider.detectedPorts);
|
||||||
|
const apiPort = resolvedPort && toApiPort(resolvedPort);
|
||||||
|
return this.updateState({ key: 'port', value: apiPort });
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updateUserDirPath(userDirUri: URI | undefined): Promise<void> {
|
||||||
|
const userDirPath = userDirUri?.path.fsPath();
|
||||||
|
return this.updateState({
|
||||||
|
key: 'userDirPath',
|
||||||
|
value: userDirPath,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updateDataDirPath(dataDirUri: URI | undefined): Promise<void> {
|
||||||
|
const dataDirPath = dataDirUri?.path.fsPath();
|
||||||
|
return this.updateState({
|
||||||
|
key: 'dataDirPath',
|
||||||
|
value: dataDirPath,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updateState<T extends ArduinoState>(
|
||||||
|
params: UpdateStateParams<T>
|
||||||
|
): Promise<void> {
|
||||||
|
await this.hostedPluginSupport.didStart;
|
||||||
|
return this.commandService.executeCommand('arduinoAPI.updateState', params);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,7 +16,10 @@ import {
|
|||||||
arduinoCert,
|
arduinoCert,
|
||||||
certificateList,
|
certificateList,
|
||||||
} from '../dialogs/certificate-uploader/utils';
|
} from '../dialogs/certificate-uploader/utils';
|
||||||
import { ArduinoFirmwareUploader } from '../../common/protocol/arduino-firmware-uploader';
|
import {
|
||||||
|
ArduinoFirmwareUploader,
|
||||||
|
UploadCertificateParams,
|
||||||
|
} from '../../common/protocol/arduino-firmware-uploader';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import { nls } from '@theia/core/lib/common';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
@@ -74,12 +77,8 @@ export class UploadCertificate extends Contribution {
|
|||||||
});
|
});
|
||||||
|
|
||||||
registry.registerCommand(UploadCertificate.Commands.UPLOAD_CERT, {
|
registry.registerCommand(UploadCertificate.Commands.UPLOAD_CERT, {
|
||||||
execute: async ({ fqbn, address, urls }) => {
|
execute: async (params: UploadCertificateParams) => {
|
||||||
return this.arduinoFirmwareUploader.uploadCertificates(
|
return this.arduinoFirmwareUploader.uploadCertificates(params);
|
||||||
`-b ${fqbn} -a ${address} ${urls
|
|
||||||
.map((url: string) => `-u ${url}`)
|
|
||||||
.join(' ')}`
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -45,10 +45,7 @@ export namespace UploadFirmware {
|
|||||||
export namespace Commands {
|
export namespace Commands {
|
||||||
export const OPEN: Command = {
|
export const OPEN: Command = {
|
||||||
id: 'arduino-upload-firmware-open',
|
id: 'arduino-upload-firmware-open',
|
||||||
label: nls.localize(
|
label: nls.localize('arduino/firmware/updater', 'Firmware Updater'),
|
||||||
'arduino/firmware/updater',
|
|
||||||
'WiFi101 / WiFiNINA Firmware Updater'
|
|
||||||
),
|
|
||||||
category: 'Arduino',
|
category: 'Arduino',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
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 { CoreService, Port, sanitizeFqbn } from '../../common/protocol';
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { CoreService, sanitizeFqbn } from '../../common/protocol';
|
||||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
|
import { CurrentSketch } from '../sketches-service-client-impl';
|
||||||
import { ArduinoToolbar } from '../toolbar/arduino-toolbar';
|
import { ArduinoToolbar } from '../toolbar/arduino-toolbar';
|
||||||
import {
|
import {
|
||||||
Command,
|
Command,
|
||||||
CommandRegistry,
|
CommandRegistry,
|
||||||
MenuModelRegistry,
|
|
||||||
KeybindingRegistry,
|
|
||||||
TabBarToolbarRegistry,
|
|
||||||
CoreServiceContribution,
|
CoreServiceContribution,
|
||||||
|
KeybindingRegistry,
|
||||||
|
MenuModelRegistry,
|
||||||
|
TabBarToolbarRegistry,
|
||||||
} from './contribution';
|
} from './contribution';
|
||||||
import { deepClone, nls } from '@theia/core/lib/common';
|
|
||||||
import { CurrentSketch } from '../sketches-service-client-impl';
|
|
||||||
import type { VerifySketchParams } from './verify-sketch';
|
|
||||||
import { UserFields } from './user-fields';
|
import { UserFields } from './user-fields';
|
||||||
|
import type { VerifySketchParams } from './verify-sketch';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class UploadSketch extends CoreServiceContribution {
|
export class UploadSketch extends CoreServiceContribution {
|
||||||
|
@inject(UserFields)
|
||||||
|
private readonly userFields: UserFields;
|
||||||
|
|
||||||
private readonly onDidChangeEmitter = new Emitter<void>();
|
private readonly onDidChangeEmitter = new Emitter<void>();
|
||||||
private readonly onDidChange = this.onDidChangeEmitter.event;
|
private readonly onDidChange = this.onDidChangeEmitter.event;
|
||||||
private uploadInProgress = false;
|
private uploadInProgress = false;
|
||||||
|
|
||||||
@inject(UserFields)
|
|
||||||
private readonly userFields: UserFields;
|
|
||||||
|
|
||||||
override registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(UploadSketch.Commands.UPLOAD_SKETCH, {
|
registry.registerCommand(UploadSketch.Commands.UPLOAD_SKETCH, {
|
||||||
execute: async () => {
|
execute: async () => {
|
||||||
@@ -107,7 +107,6 @@ export class UploadSketch extends CoreServiceContribution {
|
|||||||
// uploadInProgress will be set to false whether the upload fails or not
|
// uploadInProgress will be set to false whether the upload fails or not
|
||||||
this.uploadInProgress = true;
|
this.uploadInProgress = true;
|
||||||
this.menuManager.update();
|
this.menuManager.update();
|
||||||
this.boardsServiceProvider.snapshotBoardDiscoveryOnUpload();
|
|
||||||
this.onDidChangeEmitter.fire();
|
this.onDidChangeEmitter.fire();
|
||||||
this.clearVisibleNotification();
|
this.clearVisibleNotification();
|
||||||
|
|
||||||
@@ -135,12 +134,14 @@ export class UploadSketch extends CoreServiceContribution {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.doWithProgress({
|
const uploadResponse = await this.doWithProgress({
|
||||||
progressText: nls.localize('arduino/sketch/uploading', 'Uploading...'),
|
progressText: nls.localize('arduino/sketch/uploading', 'Uploading...'),
|
||||||
task: (progressId, coreService) =>
|
task: (progressId, coreService) =>
|
||||||
coreService.upload({ ...uploadOptions, progressId }),
|
coreService.upload({ ...uploadOptions, progressId }),
|
||||||
keepOutput: true,
|
keepOutput: true,
|
||||||
});
|
});
|
||||||
|
// the port update is NOOP if nothing has changed
|
||||||
|
this.boardsServiceProvider.updateConfig(uploadResponse.portAfterUpload);
|
||||||
|
|
||||||
this.messageService.info(
|
this.messageService.info(
|
||||||
nls.localize('arduino/sketch/doneUploading', 'Done uploading.'),
|
nls.localize('arduino/sketch/doneUploading', 'Done uploading.'),
|
||||||
@@ -150,9 +151,10 @@ export class UploadSketch extends CoreServiceContribution {
|
|||||||
this.userFields.notifyFailedWithError(e);
|
this.userFields.notifyFailedWithError(e);
|
||||||
this.handleError(e);
|
this.handleError(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
// TODO: here comes the port change if happened during the upload
|
||||||
|
// https://github.com/arduino/arduino-cli/issues/2245
|
||||||
this.uploadInProgress = false;
|
this.uploadInProgress = false;
|
||||||
this.menuManager.update();
|
this.menuManager.update();
|
||||||
this.boardsServiceProvider.attemptPostUploadAutoSelect();
|
|
||||||
this.onDidChangeEmitter.fire();
|
this.onDidChangeEmitter.fire();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,7 +176,7 @@ export class UploadSketch extends CoreServiceContribution {
|
|||||||
this.preferences.get('arduino.upload.verify'),
|
this.preferences.get('arduino.upload.verify'),
|
||||||
this.preferences.get('arduino.upload.verbose'),
|
this.preferences.get('arduino.upload.verbose'),
|
||||||
]);
|
]);
|
||||||
const port = this.maybeUpdatePortProperties(boardsConfig.selectedPort);
|
const port = boardsConfig.selectedPort;
|
||||||
return {
|
return {
|
||||||
sketch,
|
sketch,
|
||||||
fqbn,
|
fqbn,
|
||||||
@@ -185,28 +187,6 @@ export class UploadSketch extends CoreServiceContribution {
|
|||||||
userFields,
|
userFields,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a hack to ensure that the port object has the `properties` when uploading.(https://github.com/arduino/arduino-ide/issues/740)
|
|
||||||
* This method works around a bug when restoring a `port` persisted by an older version of IDE2. See the bug [here](https://github.com/arduino/arduino-ide/pull/1335#issuecomment-1224355236).
|
|
||||||
*
|
|
||||||
* Before the upload, this method checks the available ports and makes sure that the `properties` of an available port, and the port selected by the user have the same `properties`.
|
|
||||||
* This method does not update any state (for example, the `BoardsConfig.Config`) but uses the correct `properties` for the `upload`.
|
|
||||||
*/
|
|
||||||
private maybeUpdatePortProperties(port: Port | undefined): Port | undefined {
|
|
||||||
if (port) {
|
|
||||||
const key = Port.keyOf(port);
|
|
||||||
for (const candidate of this.boardsServiceProvider.availablePorts) {
|
|
||||||
if (key === Port.keyOf(candidate) && candidate.properties) {
|
|
||||||
return {
|
|
||||||
...port,
|
|
||||||
properties: deepClone(candidate.properties),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace UploadSketch {
|
export namespace UploadSketch {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { nls } from '@theia/core/lib/common';
|
|
||||||
import { BoardUserField, CoreError } from '../../common/protocol';
|
import { BoardUserField, CoreError } from '../../common/protocol';
|
||||||
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
import { BoardsServiceProvider } from '../boards/boards-service-provider';
|
||||||
import { UserFieldsDialog } from '../dialogs/user-fields/user-fields-dialog';
|
import { UserFieldsDialog } from '../dialogs/user-fields/user-fields-dialog';
|
||||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
import { MenuModelRegistry, Contribution } from './contribution';
|
import { Contribution, MenuModelRegistry } from './contribution';
|
||||||
import { UploadSketch } from './upload-sketch';
|
import { UploadSketch } from './upload-sketch';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
@@ -21,12 +21,11 @@ export class UserFields extends Contribution {
|
|||||||
|
|
||||||
protected override init(): void {
|
protected override init(): void {
|
||||||
super.init();
|
super.init();
|
||||||
this.boardsServiceProvider.onBoardsConfigChanged(async () => {
|
this.boardsServiceProvider.onBoardsConfigDidChange(() => this.refresh());
|
||||||
const userFields =
|
}
|
||||||
await this.boardsServiceProvider.selectedBoardUserFields();
|
|
||||||
this.boardRequiresUserFields = userFields.length > 0;
|
override onReady(): void {
|
||||||
this.menuManager.update();
|
this.boardsServiceProvider.ready.then(() => this.refresh());
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override registerMenus(registry: MenuModelRegistry): void {
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
@@ -37,16 +36,20 @@ export class UserFields extends Contribution {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async refresh(): Promise<void> {
|
||||||
|
const userFields =
|
||||||
|
await this.boardsServiceProvider.selectedBoardUserFields();
|
||||||
|
this.boardRequiresUserFields = userFields.length > 0;
|
||||||
|
this.menuManager.update();
|
||||||
|
}
|
||||||
|
|
||||||
private selectedFqbnAddress(): string | undefined {
|
private selectedFqbnAddress(): string | undefined {
|
||||||
const { boardsConfig } = this.boardsServiceProvider;
|
const { boardsConfig } = this.boardsServiceProvider;
|
||||||
const fqbn = boardsConfig.selectedBoard?.fqbn;
|
const fqbn = boardsConfig.selectedBoard?.fqbn;
|
||||||
if (!fqbn) {
|
if (!fqbn) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const address =
|
const address = boardsConfig.selectedPort?.address || '';
|
||||||
boardsConfig.selectedBoard?.port?.address ||
|
|
||||||
boardsConfig.selectedPort?.address ||
|
|
||||||
'';
|
|
||||||
return fqbn + '|' + address;
|
return fqbn + '|' + address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
|
||||||
import { Dialog } from '@theia/core/lib/browser/dialogs';
|
import { Dialog } from '@theia/core/lib/browser/dialogs';
|
||||||
import { nls } from '@theia/core/lib/common/nls';
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
import { Deferred, waitForEvent } from '@theia/core/lib/common/promise-util';
|
import { Deferred, waitForEvent } from '@theia/core/lib/common/promise-util';
|
||||||
@@ -180,15 +179,12 @@ export class ValidateSketch extends CloudSketchContribution {
|
|||||||
message: string,
|
message: string,
|
||||||
buttons: string[] = [Dialog.CANCEL, Dialog.OK]
|
buttons: string[] = [Dialog.CANCEL, Dialog.OK]
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const { response } = await remote.dialog.showMessageBox(
|
const { response } = await this.dialogService.showMessageBox({
|
||||||
remote.getCurrentWindow(),
|
title,
|
||||||
{
|
message,
|
||||||
title,
|
type: 'warning',
|
||||||
message,
|
buttons,
|
||||||
type: 'warning',
|
});
|
||||||
buttons,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
// cancel
|
// cancel
|
||||||
if (response === 0) {
|
if (response === 0) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -57,36 +57,63 @@ export class CreateApi {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `sketchPath` is not the POSIX path but the path with the user UUID, username, etc.
|
||||||
|
* See [Create.Resource#path](./typings.ts). If `cache` is `true` and a sketch exists with the path,
|
||||||
|
* the cache will be updated with the new state of the sketch.
|
||||||
|
*/
|
||||||
|
// TODO: no nulls in API
|
||||||
|
async sketchByPath(
|
||||||
|
sketchPath: string,
|
||||||
|
cache = false
|
||||||
|
): Promise<Create.Sketch | null> {
|
||||||
|
const url = new URL(`${this.domain()}/sketches/byPath/${sketchPath}`);
|
||||||
|
const headers = await this.headers();
|
||||||
|
const sketch = await this.run<Create.Sketch>(url, {
|
||||||
|
method: 'GET',
|
||||||
|
headers,
|
||||||
|
});
|
||||||
|
if (sketch && cache) {
|
||||||
|
this.sketchCache.addSketch(sketch);
|
||||||
|
const posixPath = createPaths.toPosixPath(sketch.path);
|
||||||
|
this.sketchCache.purgeByPath(posixPath);
|
||||||
|
}
|
||||||
|
return sketch;
|
||||||
|
}
|
||||||
|
|
||||||
async sketches(limit = 50): Promise<Create.Sketch[]> {
|
async sketches(limit = 50): Promise<Create.Sketch[]> {
|
||||||
const url = new URL(`${this.domain()}/sketches`);
|
const url = new URL(`${this.domain()}/sketches`);
|
||||||
url.searchParams.set('user_id', 'me');
|
url.searchParams.set('user_id', 'me');
|
||||||
url.searchParams.set('limit', limit.toString());
|
url.searchParams.set('limit', limit.toString());
|
||||||
const headers = await this.headers();
|
const headers = await this.headers();
|
||||||
const result: { sketches: Create.Sketch[] } = { sketches: [] };
|
const allSketches: Create.Sketch[] = [];
|
||||||
|
|
||||||
let partialSketches: Create.Sketch[] = [];
|
|
||||||
let currentOffset = 0;
|
let currentOffset = 0;
|
||||||
do {
|
while (true) {
|
||||||
url.searchParams.set('offset', currentOffset.toString());
|
url.searchParams.set('offset', currentOffset.toString());
|
||||||
partialSketches = (
|
const { sketches } = await this.run<{ sketches: Create.Sketch[] }>(url, {
|
||||||
await this.run<{ sketches: Create.Sketch[] }>(url, {
|
method: 'GET',
|
||||||
method: 'GET',
|
headers,
|
||||||
headers,
|
});
|
||||||
})
|
allSketches.push(...sketches);
|
||||||
).sketches;
|
if (sketches.length < limit) {
|
||||||
if (partialSketches.length !== 0) {
|
break;
|
||||||
result.sketches = result.sketches.concat(partialSketches);
|
|
||||||
}
|
}
|
||||||
currentOffset = currentOffset + limit;
|
currentOffset += limit;
|
||||||
} while (partialSketches.length !== 0);
|
// The create API doc show that there is `next` and `prev` pages, but it does not work
|
||||||
|
// https://api2.arduino.cc/create/docs#!/sketches95v2/sketches_v2_search
|
||||||
result.sketches.forEach((sketch) => this.sketchCache.addSketch(sketch));
|
// IF sketchCount mod limit === 0, an extra fetch must happen to detect the end of the pagination.
|
||||||
return result.sketches;
|
}
|
||||||
|
allSketches.forEach((sketch) => this.sketchCache.addSketch(sketch));
|
||||||
|
return allSketches;
|
||||||
}
|
}
|
||||||
|
|
||||||
async createSketch(
|
async createSketch(
|
||||||
posixPath: string,
|
posixPath: string,
|
||||||
contentProvider: MaybePromise<string> = this.sketchesService.defaultInoContent()
|
contentProvider: MaybePromise<string> = this.sketchesService.defaultInoContent(),
|
||||||
|
payloadOverride: Record<
|
||||||
|
string,
|
||||||
|
string | boolean | number | Record<string, unknown>
|
||||||
|
> = {}
|
||||||
): Promise<Create.Sketch> {
|
): Promise<Create.Sketch> {
|
||||||
const url = new URL(`${this.domain()}/sketches`);
|
const url = new URL(`${this.domain()}/sketches`);
|
||||||
const [headers, content] = await Promise.all([
|
const [headers, content] = await Promise.all([
|
||||||
@@ -97,6 +124,7 @@ export class CreateApi {
|
|||||||
ino: btoa(content),
|
ino: btoa(content),
|
||||||
path: posixPath,
|
path: posixPath,
|
||||||
user_id: 'me',
|
user_id: 'me',
|
||||||
|
...payloadOverride,
|
||||||
};
|
};
|
||||||
const init = {
|
const init = {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
@@ -151,7 +179,8 @@ export class CreateApi {
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch((reason) => {
|
.catch((reason) => {
|
||||||
if (reason?.status === 404) return [] as Create.Resource[];
|
if (reason?.status === 404)
|
||||||
|
return [] as Create.Resource[]; // TODO: must not swallow 404
|
||||||
else throw reason;
|
else throw reason;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -212,7 +241,17 @@ export class CreateApi {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sketch = this.sketchCache.getSketch(createPaths.parentPosix(path));
|
const posixPath = createPaths.parentPosix(path);
|
||||||
|
let sketch = this.sketchCache.getSketch(posixPath);
|
||||||
|
// Workaround for https://github.com/arduino/arduino-ide/issues/1999.
|
||||||
|
if (!sketch) {
|
||||||
|
// Convert the ordinary sketch POSIX path to the Create path.
|
||||||
|
// For example, `/sketch_apr6a` will be transformed to `8a694e4b83878cc53472bd75ee928053:kittaakos/sketches_v2/sketch_apr6a`.
|
||||||
|
const createPathPrefix = this.sketchCache.createPathPrefix;
|
||||||
|
if (createPathPrefix) {
|
||||||
|
sketch = await this.sketchByPath(createPathPrefix + posixPath, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
sketch &&
|
sketch &&
|
||||||
@@ -453,7 +492,6 @@ export class CreateApi {
|
|||||||
init: RequestInit | undefined,
|
init: RequestInit | undefined,
|
||||||
resultProvider: ResponseResultProvider = ResponseResultProvider.JSON
|
resultProvider: ResponseResultProvider = ResponseResultProvider.JSON
|
||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
console.debug(`HTTP ${init?.method}: ${requestInfo.toString()}`);
|
|
||||||
const response = await fetch(requestInfo.toString(), init);
|
const response = await fetch(requestInfo.toString(), init);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
let details: string | undefined = undefined;
|
let details: string | undefined = undefined;
|
||||||
|
|||||||
@@ -4,10 +4,14 @@ import { Emitter, Event } from '@theia/core/lib/common/event';
|
|||||||
import URI from '@theia/core/lib/common/uri';
|
import URI from '@theia/core/lib/common/uri';
|
||||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { Sketch } from '../../common/protocol';
|
import { Sketch } from '../../common/protocol';
|
||||||
import { AuthenticationSession } from '../../node/auth/types';
|
import { AuthenticationSession } from '../../common/protocol/authentication-service';
|
||||||
import { ArduinoPreferences } from '../arduino-preferences';
|
import { ArduinoPreferences } from '../arduino-preferences';
|
||||||
import { AuthenticationClientService } from '../auth/authentication-client-service';
|
import { AuthenticationClientService } from '../auth/authentication-client-service';
|
||||||
import { LocalCacheFsProvider } from '../local-cache/local-cache-fs-provider';
|
import { LocalCacheFsProvider } from '../local-cache/local-cache-fs-provider';
|
||||||
|
import {
|
||||||
|
ARDUINO_CLOUD_FOLDER,
|
||||||
|
REMOTE_SKETCHBOOK_FOLDER,
|
||||||
|
} from '../utils/constants';
|
||||||
import { CreateUri } from './create-uri';
|
import { CreateUri } from './create-uri';
|
||||||
|
|
||||||
export type CloudSketchState = 'push' | 'pull';
|
export type CloudSketchState = 'push' | 'pull';
|
||||||
@@ -128,8 +132,8 @@ export class CreateFeatures implements FrontendApplicationContribution {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return dataDirUri
|
return dataDirUri
|
||||||
.resolve('RemoteSketchbook')
|
.resolve(REMOTE_SKETCHBOOK_FOLDER)
|
||||||
.resolve('ArduinoCloud')
|
.resolve(ARDUINO_CLOUD_FOLDER)
|
||||||
.isEqualOrParent(new URI(sketch.uri));
|
.isEqualOrParent(new URI(sketch.uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,13 @@ export function isNotFound(err: unknown): err is NotFoundError {
|
|||||||
return isErrorWithStatusOf(err, 404);
|
return isErrorWithStatusOf(err, 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type UnprocessableContentError = CreateError & { status: 422 };
|
||||||
|
export function isUnprocessableContent(
|
||||||
|
err: unknown
|
||||||
|
): err is UnprocessableContentError {
|
||||||
|
return isErrorWithStatusOf(err, 422);
|
||||||
|
}
|
||||||
|
|
||||||
function isErrorWithStatusOf(
|
function isErrorWithStatusOf(
|
||||||
err: unknown,
|
err: unknown,
|
||||||
status: number
|
status: number
|
||||||
|
|||||||
15
arduino-ide-extension/src/browser/dialog-service.ts
Normal file
15
arduino-ide-extension/src/browser/dialog-service.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import type {
|
||||||
|
MessageBoxOptions,
|
||||||
|
MessageBoxReturnValue,
|
||||||
|
OpenDialogOptions,
|
||||||
|
OpenDialogReturnValue,
|
||||||
|
SaveDialogOptions,
|
||||||
|
SaveDialogReturnValue,
|
||||||
|
} from '../electron-common/electron-arduino';
|
||||||
|
|
||||||
|
export const DialogService = Symbol('DialogService');
|
||||||
|
export interface DialogService {
|
||||||
|
showMessageBox(options: MessageBoxOptions): Promise<MessageBoxReturnValue>;
|
||||||
|
showOpenDialog(options: OpenDialogOptions): Promise<OpenDialogReturnValue>;
|
||||||
|
showSaveDialog(options: SaveDialogOptions): Promise<SaveDialogReturnValue>;
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { nls } from '@theia/core/lib/common';
|
import { nls } from '@theia/core/lib/common';
|
||||||
import * as React from '@theia/core/shared/react';
|
import React from '@theia/core/shared/react';
|
||||||
|
|
||||||
export const CertificateAddComponent = ({
|
export const CertificateAddComponent = ({
|
||||||
addCertificate,
|
addCertificate,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as React from '@theia/core/shared/react';
|
import React from '@theia/core/shared/react';
|
||||||
|
|
||||||
export const CertificateListComponent = ({
|
export const CertificateListComponent = ({
|
||||||
certificates,
|
certificates,
|
||||||
|
|||||||
@@ -1,20 +1,27 @@
|
|||||||
import * as React from '@theia/core/shared/react';
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import React from '@theia/core/shared/react';
|
||||||
import Tippy from '@tippyjs/react';
|
import Tippy from '@tippyjs/react';
|
||||||
import { AvailableBoard } from '../../boards/boards-service-provider';
|
import type { BoardList } from '../../../common/protocol/board-list';
|
||||||
import { CertificateListComponent } from './certificate-list';
|
import {
|
||||||
import { SelectBoardComponent } from './select-board-components';
|
boardIdentifierEquals,
|
||||||
|
portIdentifierEquals,
|
||||||
|
} from '../../../common/protocol/boards-service';
|
||||||
import { CertificateAddComponent } from './certificate-add-new';
|
import { CertificateAddComponent } from './certificate-add-new';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import { CertificateListComponent } from './certificate-list';
|
||||||
|
import {
|
||||||
|
BoardOptionValue,
|
||||||
|
SelectBoardComponent,
|
||||||
|
} from './select-board-components';
|
||||||
|
|
||||||
export const CertificateUploaderComponent = ({
|
export const CertificateUploaderComponent = ({
|
||||||
availableBoards,
|
boardList,
|
||||||
certificates,
|
certificates,
|
||||||
addCertificate,
|
addCertificate,
|
||||||
updatableFqbns,
|
updatableFqbns,
|
||||||
uploadCertificates,
|
uploadCertificates,
|
||||||
openContextMenu,
|
openContextMenu,
|
||||||
}: {
|
}: {
|
||||||
availableBoards: AvailableBoard[];
|
boardList: BoardList;
|
||||||
certificates: string[];
|
certificates: string[];
|
||||||
addCertificate: (cert: string) => void;
|
addCertificate: (cert: string) => void;
|
||||||
updatableFqbns: string[];
|
updatableFqbns: string[];
|
||||||
@@ -33,11 +40,15 @@ export const CertificateUploaderComponent = ({
|
|||||||
|
|
||||||
const [selectedCerts, setSelectedCerts] = React.useState<string[]>([]);
|
const [selectedCerts, setSelectedCerts] = React.useState<string[]>([]);
|
||||||
|
|
||||||
const [selectedBoard, setSelectedBoard] =
|
const [selectedItem, setSelectedItem] =
|
||||||
React.useState<AvailableBoard | null>(null);
|
React.useState<BoardOptionValue | null>(null);
|
||||||
|
|
||||||
const installCertificates = async () => {
|
const installCertificates = async () => {
|
||||||
if (!selectedBoard || !selectedBoard.fqbn || !selectedBoard.port) {
|
if (!selectedItem) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const board = selectedItem.board;
|
||||||
|
if (!board.fqbn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,8 +56,8 @@ export const CertificateUploaderComponent = ({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await uploadCertificates(
|
await uploadCertificates(
|
||||||
selectedBoard.fqbn,
|
board.fqbn,
|
||||||
selectedBoard.port.address,
|
selectedItem.port.address,
|
||||||
selectedCerts
|
selectedCerts
|
||||||
);
|
);
|
||||||
setInstallFeedback('ok');
|
setInstallFeedback('ok');
|
||||||
@@ -55,17 +66,26 @@ export const CertificateUploaderComponent = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onBoardSelect = React.useCallback(
|
const onItemSelect = React.useCallback(
|
||||||
(board: AvailableBoard) => {
|
(item: BoardOptionValue | null) => {
|
||||||
const newFqbn = (board && board.fqbn) || null;
|
if (!item) {
|
||||||
const prevFqbn = (selectedBoard && selectedBoard.fqbn) || null;
|
setSelectedItem(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const board = item.board;
|
||||||
|
const port = item.port;
|
||||||
|
const selectedBoard = selectedItem?.board;
|
||||||
|
const selectedPort = selectedItem?.port;
|
||||||
|
|
||||||
if (newFqbn !== prevFqbn) {
|
if (
|
||||||
|
!boardIdentifierEquals(board, selectedBoard) ||
|
||||||
|
!portIdentifierEquals(port, selectedPort)
|
||||||
|
) {
|
||||||
setInstallFeedback(null);
|
setInstallFeedback(null);
|
||||||
setSelectedBoard(board);
|
setSelectedItem(item);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[selectedBoard]
|
[selectedItem]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -125,10 +145,10 @@ export const CertificateUploaderComponent = ({
|
|||||||
<div className="dialogRow">
|
<div className="dialogRow">
|
||||||
<div className="fl1">
|
<div className="fl1">
|
||||||
<SelectBoardComponent
|
<SelectBoardComponent
|
||||||
availableBoards={availableBoards}
|
boardList={boardList}
|
||||||
updatableFqbns={updatableFqbns}
|
updatableFqbns={updatableFqbns}
|
||||||
onBoardSelect={onBoardSelect}
|
onItemSelect={onItemSelect}
|
||||||
selectedBoard={selectedBoard}
|
selectedItem={selectedItem}
|
||||||
busy={installFeedback === 'installing'}
|
busy={installFeedback === 'installing'}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -167,7 +187,7 @@ export const CertificateUploaderComponent = ({
|
|||||||
type="button"
|
type="button"
|
||||||
className="theia-button primary install-cert-btn"
|
className="theia-button primary install-cert-btn"
|
||||||
onClick={installCertificates}
|
onClick={installCertificates}
|
||||||
disabled={selectedCerts.length === 0 || !selectedBoard}
|
disabled={selectedCerts.length === 0 || !selectedItem}
|
||||||
>
|
>
|
||||||
{nls.localize('arduino/certificate/upload', 'Upload')}
|
{nls.localize('arduino/certificate/upload', 'Upload')}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,62 +1,51 @@
|
|||||||
import * as React from '@theia/core/shared/react';
|
import { DialogProps } from '@theia/core/lib/browser/dialogs';
|
||||||
|
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
||||||
|
import {
|
||||||
|
PreferenceScope,
|
||||||
|
PreferenceService,
|
||||||
|
} from '@theia/core/lib/browser/preferences/preference-service';
|
||||||
|
import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget';
|
||||||
|
import { CommandRegistry } from '@theia/core/lib/common/command';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import type { Message } from '@theia/core/shared/@phosphor/messaging';
|
||||||
|
import { Widget } from '@theia/core/shared/@phosphor/widgets';
|
||||||
import {
|
import {
|
||||||
inject,
|
inject,
|
||||||
injectable,
|
injectable,
|
||||||
postConstruct,
|
postConstruct,
|
||||||
} from '@theia/core/shared/inversify';
|
} from '@theia/core/shared/inversify';
|
||||||
import { DialogProps } from '@theia/core/lib/browser/dialogs';
|
import React from '@theia/core/shared/react';
|
||||||
import { AbstractDialog } from '../../theia/dialogs/dialogs';
|
|
||||||
import { Widget } from '@theia/core/shared/@phosphor/widgets';
|
|
||||||
import { Message } from '@theia/core/shared/@phosphor/messaging';
|
|
||||||
import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget';
|
|
||||||
import {
|
|
||||||
AvailableBoard,
|
|
||||||
BoardsServiceProvider,
|
|
||||||
} from '../../boards/boards-service-provider';
|
|
||||||
import { CertificateUploaderComponent } from './certificate-uploader-component';
|
|
||||||
import { ArduinoPreferences } from '../../arduino-preferences';
|
|
||||||
import {
|
|
||||||
PreferenceScope,
|
|
||||||
PreferenceService,
|
|
||||||
} from '@theia/core/lib/browser/preferences/preference-service';
|
|
||||||
import { CommandRegistry } from '@theia/core/lib/common/command';
|
|
||||||
import { certificateList, sanifyCertString } from './utils';
|
|
||||||
import { ArduinoFirmwareUploader } from '../../../common/protocol/arduino-firmware-uploader';
|
import { ArduinoFirmwareUploader } from '../../../common/protocol/arduino-firmware-uploader';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import { createBoardList } from '../../../common/protocol/board-list';
|
||||||
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
import { ArduinoPreferences } from '../../arduino-preferences';
|
||||||
|
import { BoardsServiceProvider } from '../../boards/boards-service-provider';
|
||||||
|
import { AbstractDialog } from '../../theia/dialogs/dialogs';
|
||||||
|
import { CertificateUploaderComponent } from './certificate-uploader-component';
|
||||||
|
import { certificateList, sanifyCertString } from './utils';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class UploadCertificateDialogWidget extends ReactWidget {
|
export class UploadCertificateDialogWidget extends ReactWidget {
|
||||||
@inject(BoardsServiceProvider)
|
@inject(BoardsServiceProvider)
|
||||||
protected readonly boardsServiceClient: BoardsServiceProvider;
|
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
|
|
||||||
@inject(ArduinoPreferences)
|
@inject(ArduinoPreferences)
|
||||||
protected readonly arduinoPreferences: ArduinoPreferences;
|
private readonly arduinoPreferences: ArduinoPreferences;
|
||||||
|
|
||||||
@inject(PreferenceService)
|
@inject(PreferenceService)
|
||||||
protected readonly preferenceService: PreferenceService;
|
private readonly preferenceService: PreferenceService;
|
||||||
|
|
||||||
@inject(CommandRegistry)
|
@inject(CommandRegistry)
|
||||||
protected readonly commandRegistry: CommandRegistry;
|
private readonly commandRegistry: CommandRegistry;
|
||||||
|
|
||||||
@inject(ArduinoFirmwareUploader)
|
@inject(ArduinoFirmwareUploader)
|
||||||
protected readonly arduinoFirmwareUploader: ArduinoFirmwareUploader;
|
private readonly arduinoFirmwareUploader: ArduinoFirmwareUploader;
|
||||||
|
|
||||||
@inject(FrontendApplicationStateService)
|
@inject(FrontendApplicationStateService)
|
||||||
private readonly appStateService: FrontendApplicationStateService;
|
private readonly appStateService: FrontendApplicationStateService;
|
||||||
|
|
||||||
protected certificates: string[] = [];
|
private certificates: string[] = [];
|
||||||
protected updatableFqbns: string[] = [];
|
private updatableFqbns: string[] = [];
|
||||||
protected availableBoards: AvailableBoard[] = [];
|
private boardList = createBoardList({});
|
||||||
|
|
||||||
public busyCallback = (busy: boolean) => {
|
busyCallback = (busy: boolean) => {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@postConstruct()
|
@postConstruct()
|
||||||
protected init(): void {
|
protected init(): void {
|
||||||
this.arduinoPreferences.ready.then(() => {
|
this.arduinoPreferences.ready.then(() => {
|
||||||
@@ -81,8 +70,8 @@ export class UploadCertificateDialogWidget extends ReactWidget {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
this.boardsServiceClient.onAvailableBoardsChanged((availableBoards) => {
|
this.boardsServiceProvider.onBoardListDidChange((boardList) => {
|
||||||
this.availableBoards = availableBoards;
|
this.boardList = boardList;
|
||||||
this.update();
|
this.update();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -126,7 +115,7 @@ export class UploadCertificateDialogWidget extends ReactWidget {
|
|||||||
protected render(): React.ReactNode {
|
protected render(): React.ReactNode {
|
||||||
return (
|
return (
|
||||||
<CertificateUploaderComponent
|
<CertificateUploaderComponent
|
||||||
availableBoards={this.availableBoards}
|
boardList={this.boardList}
|
||||||
certificates={this.certificates}
|
certificates={this.certificates}
|
||||||
updatableFqbns={this.updatableFqbns}
|
updatableFqbns={this.updatableFqbns}
|
||||||
addCertificate={this.addCertificate.bind(this)}
|
addCertificate={this.addCertificate.bind(this)}
|
||||||
@@ -143,7 +132,7 @@ export class UploadCertificateDialogProps extends DialogProps {}
|
|||||||
@injectable()
|
@injectable()
|
||||||
export class UploadCertificateDialog extends AbstractDialog<void> {
|
export class UploadCertificateDialog extends AbstractDialog<void> {
|
||||||
@inject(UploadCertificateDialogWidget)
|
@inject(UploadCertificateDialogWidget)
|
||||||
protected readonly widget: UploadCertificateDialogWidget;
|
private readonly widget: UploadCertificateDialogWidget;
|
||||||
|
|
||||||
private busy = false;
|
private busy = false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +1,37 @@
|
|||||||
import { nls } from '@theia/core/lib/common';
|
import { nls } from '@theia/core/lib/common';
|
||||||
import * as React from '@theia/core/shared/react';
|
import React from '@theia/core/shared/react';
|
||||||
import { AvailableBoard } from '../../boards/boards-service-provider';
|
import {
|
||||||
|
boardListItemEquals,
|
||||||
|
type BoardList,
|
||||||
|
type BoardListItemWithBoard,
|
||||||
|
} from '../../../common/protocol/board-list';
|
||||||
import { ArduinoSelect } from '../../widgets/arduino-select';
|
import { ArduinoSelect } from '../../widgets/arduino-select';
|
||||||
|
|
||||||
type BoardOption = { value: string; label: string };
|
export type BoardOptionValue = BoardListItemWithBoard;
|
||||||
|
type BoardOption = { value: BoardOptionValue | undefined; label: string };
|
||||||
|
|
||||||
export const SelectBoardComponent = ({
|
export const SelectBoardComponent = ({
|
||||||
availableBoards,
|
boardList,
|
||||||
updatableFqbns,
|
updatableFqbns,
|
||||||
onBoardSelect,
|
onItemSelect,
|
||||||
selectedBoard,
|
selectedItem,
|
||||||
busy,
|
busy,
|
||||||
}: {
|
}: {
|
||||||
availableBoards: AvailableBoard[];
|
boardList: BoardList;
|
||||||
updatableFqbns: string[];
|
updatableFqbns: string[];
|
||||||
onBoardSelect: (board: AvailableBoard | null) => void;
|
onItemSelect: (item: BoardOptionValue | null) => void;
|
||||||
selectedBoard: AvailableBoard | null;
|
selectedItem: BoardOptionValue | null;
|
||||||
busy: boolean;
|
busy: boolean;
|
||||||
}): React.ReactElement => {
|
}): React.ReactElement => {
|
||||||
const [selectOptions, setSelectOptions] = React.useState<BoardOption[]>([]);
|
const [selectOptions, setSelectOptions] = React.useState<BoardOption[]>([]);
|
||||||
|
|
||||||
const [selectBoardPlaceholder, setSelectBoardPlaceholder] =
|
const [selectItemPlaceholder, setSelectBoardPlaceholder] = React.useState('');
|
||||||
React.useState('');
|
|
||||||
|
|
||||||
const selectOption = React.useCallback(
|
const selectOption = React.useCallback(
|
||||||
(boardOpt: BoardOption) => {
|
(boardOpt: BoardOption | null) => {
|
||||||
onBoardSelect(
|
onItemSelect(boardOpt?.value ?? null);
|
||||||
(boardOpt &&
|
|
||||||
availableBoards.find((board) => board.fqbn === boardOpt.value)) ||
|
|
||||||
null
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
[availableBoards, onBoardSelect]
|
[onItemSelect]
|
||||||
);
|
);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
@@ -44,26 +44,28 @@ export const SelectBoardComponent = ({
|
|||||||
'arduino/certificate/selectBoard',
|
'arduino/certificate/selectBoard',
|
||||||
'Select a board...'
|
'Select a board...'
|
||||||
);
|
);
|
||||||
|
const updatableBoards = boardList.boards.filter((item) => {
|
||||||
|
const fqbn = item.board.fqbn;
|
||||||
|
return fqbn && updatableFqbns.includes(fqbn);
|
||||||
|
});
|
||||||
let selBoard = -1;
|
let selBoard = -1;
|
||||||
const updatableBoards = availableBoards.filter(
|
|
||||||
(board) => board.port && board.fqbn && updatableFqbns.includes(board.fqbn)
|
const boardOptions: BoardOption[] = updatableBoards.map((item, i) => {
|
||||||
);
|
if (selectedItem === item) {
|
||||||
const boardsList: BoardOption[] = updatableBoards.map((board, i) => {
|
|
||||||
if (board.selected) {
|
|
||||||
selBoard = i;
|
selBoard = i;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
label: nls.localize(
|
label: nls.localize(
|
||||||
'arduino/certificate/boardAtPort',
|
'arduino/certificate/boardAtPort',
|
||||||
'{0} at {1}',
|
'{0} at {1}',
|
||||||
board.name,
|
item.board.name,
|
||||||
board.port?.address ?? ''
|
item.port.address ?? ''
|
||||||
),
|
),
|
||||||
value: board.fqbn || '',
|
value: item,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
if (boardsList.length === 0) {
|
if (boardOptions.length === 0) {
|
||||||
placeholderTxt = nls.localize(
|
placeholderTxt = nls.localize(
|
||||||
'arduino/certificate/noSupportedBoardConnected',
|
'arduino/certificate/noSupportedBoardConnected',
|
||||||
'No supported board connected'
|
'No supported board connected'
|
||||||
@@ -71,32 +73,31 @@ export const SelectBoardComponent = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
setSelectBoardPlaceholder(placeholderTxt);
|
setSelectBoardPlaceholder(placeholderTxt);
|
||||||
setSelectOptions(boardsList);
|
setSelectOptions(boardOptions);
|
||||||
|
|
||||||
if (selectedBoard) {
|
if (selectedItem) {
|
||||||
selBoard = boardsList
|
selBoard = updatableBoards.findIndex((board) =>
|
||||||
.map((boardOpt) => boardOpt.value)
|
boardListItemEquals(board, selectedItem)
|
||||||
.indexOf(selectedBoard.fqbn || '');
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
selectOption(boardsList[selBoard] || null);
|
selectOption(boardOptions[selBoard] || null);
|
||||||
}, [busy, availableBoards, selectOption, updatableFqbns, selectedBoard]);
|
}, [busy, boardList, selectOption, updatableFqbns, selectedItem]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ArduinoSelect
|
<ArduinoSelect
|
||||||
id="board-select"
|
id="board-select"
|
||||||
menuPosition="fixed"
|
menuPosition="fixed"
|
||||||
isDisabled={selectOptions.length === 0 || busy}
|
isDisabled={selectOptions.length === 0 || busy}
|
||||||
placeholder={selectBoardPlaceholder}
|
placeholder={selectItemPlaceholder}
|
||||||
options={selectOptions}
|
options={selectOptions}
|
||||||
value={
|
value={
|
||||||
(selectedBoard && {
|
(selectedItem && {
|
||||||
value: selectedBoard.fqbn,
|
value: selectedItem,
|
||||||
label: nls.localize(
|
label: nls.localize(
|
||||||
'arduino/certificate/boardAtPort',
|
'arduino/certificate/boardAtPort',
|
||||||
'{0} at {1}',
|
'{0} at {1}',
|
||||||
selectedBoard.name,
|
selectedItem.board.name,
|
||||||
selectedBoard.port?.address ?? ''
|
selectedItem.port.address ?? ''
|
||||||
),
|
),
|
||||||
}) ||
|
}) ||
|
||||||
null
|
null
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import * as React from '@theia/core/shared/react';
|
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
|
||||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
import { DialogProps } from '@theia/core/lib/browser/dialogs';
|
||||||
import { Widget } from '@theia/core/shared/@phosphor/widgets';
|
import { TreeNode } from '@theia/core/lib/browser/tree/tree';
|
||||||
|
import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
|
import { MaybePromise } from '@theia/core/lib/common/types';
|
||||||
import { Message } from '@theia/core/shared/@phosphor/messaging';
|
import { Message } from '@theia/core/shared/@phosphor/messaging';
|
||||||
import { clipboard } from '@theia/core/electron-shared/@electron/remote';
|
import { Widget } from '@theia/core/shared/@phosphor/widgets';
|
||||||
import { ReactWidget, DialogProps } from '@theia/core/lib/browser';
|
import React from '@theia/core/shared/react';
|
||||||
import { AbstractDialog } from '../theia/dialogs/dialogs';
|
|
||||||
import { CreateApi } from '../create/create-api';
|
import { CreateApi } from '../create/create-api';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import { AbstractDialog } from '../theia/dialogs/dialogs';
|
||||||
|
|
||||||
const RadioButton = (props: {
|
const RadioButton = (props: {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -35,15 +37,18 @@ export const ShareSketchComponent = ({
|
|||||||
treeNode,
|
treeNode,
|
||||||
createApi,
|
createApi,
|
||||||
domain = 'https://create.arduino.cc',
|
domain = 'https://create.arduino.cc',
|
||||||
|
writeClipboard,
|
||||||
}: {
|
}: {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
treeNode: any;
|
treeNode: any;
|
||||||
createApi: CreateApi;
|
createApi: CreateApi;
|
||||||
domain?: string;
|
domain?: string;
|
||||||
|
writeClipboard: (text: string) => MaybePromise<void>;
|
||||||
}): React.ReactElement => {
|
}): React.ReactElement => {
|
||||||
const [loading, setloading] = React.useState<boolean>(false);
|
const [loading, setLoading] = React.useState<boolean>(false);
|
||||||
|
|
||||||
const radioChangeHandler = async (event: React.BaseSyntheticEvent) => {
|
const radioChangeHandler = async (event: React.BaseSyntheticEvent) => {
|
||||||
setloading(true);
|
setLoading(true);
|
||||||
const sketch = await createApi.editSketch({
|
const sketch = await createApi.editSketch({
|
||||||
id: treeNode.sketchId,
|
id: treeNode.sketchId,
|
||||||
params: {
|
params: {
|
||||||
@@ -52,7 +57,7 @@ export const ShareSketchComponent = ({
|
|||||||
});
|
});
|
||||||
// setPublicVisibility(sketch.is_public);
|
// setPublicVisibility(sketch.is_public);
|
||||||
treeNode.isPublic = sketch.is_public;
|
treeNode.isPublic = sketch.is_public;
|
||||||
setloading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const sketchLink = `${domain}/editor/_/${treeNode.sketchId}/preview`;
|
const sketchLink = `${domain}/editor/_/${treeNode.sketchId}/preview`;
|
||||||
@@ -100,7 +105,7 @@ export const ShareSketchComponent = ({
|
|||||||
className="theia-input"
|
className="theia-input"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
onClick={() => clipboard.writeText(sketchLink)}
|
onClick={() => writeClipboard(sketchLink)}
|
||||||
value="copy"
|
value="copy"
|
||||||
className="theia-button secondary"
|
className="theia-button secondary"
|
||||||
>
|
>
|
||||||
@@ -121,44 +126,52 @@ export const ShareSketchComponent = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@injectable()
|
|
||||||
export class ShareSketchWidget extends ReactWidget {
|
export class ShareSketchWidget extends ReactWidget {
|
||||||
constructor(private treeNode: any, private createApi: CreateApi) {
|
private readonly writeClipboard = (text: string) =>
|
||||||
|
this.clipboardService.writeText(text);
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private treeNode: TreeNode,
|
||||||
|
private createApi: CreateApi,
|
||||||
|
private clipboardService: ClipboardService
|
||||||
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): React.ReactNode {
|
protected override render(): React.ReactNode {
|
||||||
return (
|
return (
|
||||||
<ShareSketchComponent
|
<ShareSketchComponent
|
||||||
treeNode={this.treeNode}
|
treeNode={this.treeNode}
|
||||||
createApi={this.createApi}
|
createApi={this.createApi}
|
||||||
|
writeClipboard={this.writeClipboard}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@injectable()
|
|
||||||
export class ShareSketchDialogProps extends DialogProps {
|
export class ShareSketchDialogProps extends DialogProps {
|
||||||
readonly node: any;
|
readonly node: TreeNode;
|
||||||
readonly createApi: CreateApi;
|
readonly createApi: CreateApi;
|
||||||
|
readonly clipboardService: ClipboardService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@injectable()
|
|
||||||
export class ShareSketchDialog extends AbstractDialog<void> {
|
export class ShareSketchDialog extends AbstractDialog<void> {
|
||||||
protected widget: ShareSketchWidget;
|
protected widget: ShareSketchWidget;
|
||||||
|
|
||||||
constructor(
|
constructor(protected override readonly props: ShareSketchDialogProps) {
|
||||||
@inject(ShareSketchDialogProps)
|
|
||||||
protected override readonly props: ShareSketchDialogProps
|
|
||||||
) {
|
|
||||||
super({ title: props.title });
|
super({ title: props.title });
|
||||||
this.contentNode.classList.add('arduino-share-sketch-dialog');
|
this.contentNode.classList.add('arduino-share-sketch-dialog');
|
||||||
this.widget = new ShareSketchWidget(props.node, props.createApi);
|
this.widget = new ShareSketchWidget(
|
||||||
|
props.node,
|
||||||
|
props.createApi,
|
||||||
|
props.clipboardService
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get value(): void {
|
override get value(): void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override onAfterAttach(msg: Message): void {
|
protected override onAfterAttach(msg: Message): void {
|
||||||
if (this.widget.isAttached) {
|
if (this.widget.isAttached) {
|
||||||
Widget.detach(this.widget);
|
Widget.detach(this.widget);
|
||||||
|
|||||||
@@ -1,24 +1,31 @@
|
|||||||
import { nls } from '@theia/core/lib/common';
|
import { nls } from '@theia/core/lib/common';
|
||||||
import * as React from '@theia/core/shared/react';
|
import React from '@theia/core/shared/react';
|
||||||
import { Port } from '../../../common/protocol';
|
import {
|
||||||
|
boardIdentifierEquals,
|
||||||
|
Port,
|
||||||
|
portIdentifierEquals,
|
||||||
|
} from '../../../common/protocol';
|
||||||
import {
|
import {
|
||||||
ArduinoFirmwareUploader,
|
ArduinoFirmwareUploader,
|
||||||
FirmwareInfo,
|
FirmwareInfo,
|
||||||
} from '../../../common/protocol/arduino-firmware-uploader';
|
} from '../../../common/protocol/arduino-firmware-uploader';
|
||||||
import { AvailableBoard } from '../../boards/boards-service-provider';
|
import type {
|
||||||
|
BoardList,
|
||||||
|
BoardListItemWithBoard,
|
||||||
|
} from '../../../common/protocol/board-list';
|
||||||
import { ArduinoSelect } from '../../widgets/arduino-select';
|
import { ArduinoSelect } from '../../widgets/arduino-select';
|
||||||
import { SelectBoardComponent } from '../certificate-uploader/select-board-components';
|
import { SelectBoardComponent } from '../certificate-uploader/select-board-components';
|
||||||
|
|
||||||
type FirmwareOption = { value: string; label: string };
|
type FirmwareOption = { value: string; label: string };
|
||||||
|
|
||||||
export const FirmwareUploaderComponent = ({
|
export const FirmwareUploaderComponent = ({
|
||||||
availableBoards,
|
boardList,
|
||||||
firmwareUploader,
|
firmwareUploader,
|
||||||
updatableFqbns,
|
updatableFqbns,
|
||||||
flashFirmware,
|
flashFirmware,
|
||||||
isOpen,
|
isOpen,
|
||||||
}: {
|
}: {
|
||||||
availableBoards: AvailableBoard[];
|
boardList: BoardList;
|
||||||
firmwareUploader: ArduinoFirmwareUploader;
|
firmwareUploader: ArduinoFirmwareUploader;
|
||||||
updatableFqbns: string[];
|
updatableFqbns: string[];
|
||||||
flashFirmware: (firmware: FirmwareInfo, port: Port) => Promise<any>;
|
flashFirmware: (firmware: FirmwareInfo, port: Port) => Promise<any>;
|
||||||
@@ -31,8 +38,8 @@ export const FirmwareUploaderComponent = ({
|
|||||||
'ok' | 'fail' | 'installing' | null
|
'ok' | 'fail' | 'installing' | null
|
||||||
>(null);
|
>(null);
|
||||||
|
|
||||||
const [selectedBoard, setSelectedBoard] =
|
const [selectedItem, setSelectedItem] =
|
||||||
React.useState<AvailableBoard | null>(null);
|
React.useState<BoardListItemWithBoard | null>(null);
|
||||||
|
|
||||||
const [availableFirmwares, setAvailableFirmwares] = React.useState<
|
const [availableFirmwares, setAvailableFirmwares] = React.useState<
|
||||||
FirmwareInfo[]
|
FirmwareInfo[]
|
||||||
@@ -50,13 +57,14 @@ export const FirmwareUploaderComponent = ({
|
|||||||
const fetchFirmwares = React.useCallback(async () => {
|
const fetchFirmwares = React.useCallback(async () => {
|
||||||
setInstallFeedback(null);
|
setInstallFeedback(null);
|
||||||
setFirmwaresFetching(true);
|
setFirmwaresFetching(true);
|
||||||
if (!selectedBoard) {
|
if (!selectedItem) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch the firmwares for the selected board
|
// fetch the firmwares for the selected board
|
||||||
|
const board = selectedItem.board;
|
||||||
const firmwaresForFqbn = await firmwareUploader.availableFirmwares(
|
const firmwaresForFqbn = await firmwareUploader.availableFirmwares(
|
||||||
selectedBoard.fqbn || ''
|
board.fqbn || ''
|
||||||
);
|
);
|
||||||
setAvailableFirmwares(firmwaresForFqbn);
|
setAvailableFirmwares(firmwaresForFqbn);
|
||||||
|
|
||||||
@@ -69,7 +77,7 @@ export const FirmwareUploaderComponent = ({
|
|||||||
|
|
||||||
if (firmwaresForFqbn.length > 0) setSelectedFirmware(firmwaresOpts[0]);
|
if (firmwaresForFqbn.length > 0) setSelectedFirmware(firmwaresOpts[0]);
|
||||||
setFirmwaresFetching(false);
|
setFirmwaresFetching(false);
|
||||||
}, [firmwareUploader, selectedBoard]);
|
}, [firmwareUploader, selectedItem]);
|
||||||
|
|
||||||
const installFirmware = React.useCallback(async () => {
|
const installFirmware = React.useCallback(async () => {
|
||||||
setInstallFeedback('installing');
|
setInstallFeedback('installing');
|
||||||
@@ -78,30 +86,42 @@ export const FirmwareUploaderComponent = ({
|
|||||||
(firmware) => firmware.firmware_version === selectedFirmware?.value
|
(firmware) => firmware.firmware_version === selectedFirmware?.value
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const selectedBoard = selectedItem?.board;
|
||||||
|
const selectedPort = selectedItem?.port;
|
||||||
try {
|
try {
|
||||||
const installStatus =
|
const installStatus =
|
||||||
!!firmwareToFlash &&
|
firmwareToFlash &&
|
||||||
!!selectedBoard?.port &&
|
selectedBoard &&
|
||||||
(await flashFirmware(firmwareToFlash, selectedBoard?.port));
|
selectedPort &&
|
||||||
|
(await flashFirmware(firmwareToFlash, selectedPort));
|
||||||
|
|
||||||
setInstallFeedback((installStatus && 'ok') || 'fail');
|
setInstallFeedback((installStatus && 'ok') || 'fail');
|
||||||
} catch {
|
} catch {
|
||||||
setInstallFeedback('fail');
|
setInstallFeedback('fail');
|
||||||
}
|
}
|
||||||
}, [firmwareUploader, selectedBoard, selectedFirmware, availableFirmwares]);
|
}, [selectedItem, selectedFirmware, availableFirmwares, flashFirmware]);
|
||||||
|
|
||||||
const onBoardSelect = React.useCallback(
|
const onItemSelect = React.useCallback(
|
||||||
(board: AvailableBoard) => {
|
(item: BoardListItemWithBoard | null) => {
|
||||||
const newFqbn = (board && board.fqbn) || null;
|
if (!item) {
|
||||||
const prevFqbn = (selectedBoard && selectedBoard.fqbn) || null;
|
setSelectedItem(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const board = item.board;
|
||||||
|
const port = item.port;
|
||||||
|
const selectedBoard = selectedItem?.board;
|
||||||
|
const selectedPort = selectedItem?.port;
|
||||||
|
|
||||||
if (newFqbn !== prevFqbn) {
|
if (
|
||||||
|
!boardIdentifierEquals(board, selectedBoard) ||
|
||||||
|
!portIdentifierEquals(port, selectedPort)
|
||||||
|
) {
|
||||||
setInstallFeedback(null);
|
setInstallFeedback(null);
|
||||||
setAvailableFirmwares([]);
|
setAvailableFirmwares([]);
|
||||||
setSelectedBoard(board);
|
setSelectedItem(item);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[selectedBoard]
|
[selectedItem]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -115,10 +135,10 @@ export const FirmwareUploaderComponent = ({
|
|||||||
<div className="dialogRow">
|
<div className="dialogRow">
|
||||||
<div className="fl1">
|
<div className="fl1">
|
||||||
<SelectBoardComponent
|
<SelectBoardComponent
|
||||||
availableBoards={availableBoards}
|
boardList={boardList}
|
||||||
updatableFqbns={updatableFqbns}
|
updatableFqbns={updatableFqbns}
|
||||||
onBoardSelect={onBoardSelect}
|
onItemSelect={onItemSelect}
|
||||||
selectedBoard={selectedBoard}
|
selectedItem={selectedItem}
|
||||||
busy={installFeedback === 'installing'}
|
busy={installFeedback === 'installing'}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -126,7 +146,7 @@ export const FirmwareUploaderComponent = ({
|
|||||||
type="button"
|
type="button"
|
||||||
className="theia-button secondary"
|
className="theia-button secondary"
|
||||||
disabled={
|
disabled={
|
||||||
selectedBoard === null ||
|
selectedItem === null ||
|
||||||
firmwaresFetching ||
|
firmwaresFetching ||
|
||||||
installFeedback === 'installing'
|
installFeedback === 'installing'
|
||||||
}
|
}
|
||||||
@@ -150,14 +170,14 @@ export const FirmwareUploaderComponent = ({
|
|||||||
id="firmware-select"
|
id="firmware-select"
|
||||||
menuPosition="fixed"
|
menuPosition="fixed"
|
||||||
isDisabled={
|
isDisabled={
|
||||||
!selectedBoard ||
|
!selectedItem ||
|
||||||
firmwaresFetching ||
|
firmwaresFetching ||
|
||||||
installFeedback === 'installing'
|
installFeedback === 'installing'
|
||||||
}
|
}
|
||||||
options={firmwareOptions}
|
options={firmwareOptions}
|
||||||
value={selectedFirmware}
|
value={selectedFirmware}
|
||||||
tabSelectsValue={false}
|
tabSelectsValue={false}
|
||||||
onChange={(value) => {
|
onChange={(value: FirmwareOption | null) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
setInstallFeedback(null);
|
setInstallFeedback(null);
|
||||||
setSelectedFirmware(value);
|
setSelectedFirmware(value);
|
||||||
|
|||||||
@@ -1,24 +1,21 @@
|
|||||||
import * as React from '@theia/core/shared/react';
|
import { DialogProps } from '@theia/core/lib/browser/dialogs';
|
||||||
|
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
||||||
|
import type { Message } from '@theia/core/shared/@phosphor/messaging';
|
||||||
import {
|
import {
|
||||||
inject,
|
inject,
|
||||||
injectable,
|
injectable,
|
||||||
postConstruct,
|
postConstruct,
|
||||||
} from '@theia/core/shared/inversify';
|
} from '@theia/core/shared/inversify';
|
||||||
import { DialogProps } from '@theia/core/lib/browser/dialogs';
|
import React from '@theia/core/shared/react';
|
||||||
import { ReactDialog } from '../../theia/dialogs/dialogs';
|
|
||||||
import { Message } from '@theia/core/shared/@phosphor/messaging';
|
|
||||||
import {
|
|
||||||
AvailableBoard,
|
|
||||||
BoardsServiceProvider,
|
|
||||||
} from '../../boards/boards-service-provider';
|
|
||||||
import {
|
import {
|
||||||
ArduinoFirmwareUploader,
|
ArduinoFirmwareUploader,
|
||||||
FirmwareInfo,
|
FirmwareInfo,
|
||||||
} from '../../../common/protocol/arduino-firmware-uploader';
|
} from '../../../common/protocol/arduino-firmware-uploader';
|
||||||
import { FirmwareUploaderComponent } from './firmware-uploader-component';
|
import type { Port } from '../../../common/protocol/boards-service';
|
||||||
|
import { BoardsServiceProvider } from '../../boards/boards-service-provider';
|
||||||
import { UploadFirmware } from '../../contributions/upload-firmware';
|
import { UploadFirmware } from '../../contributions/upload-firmware';
|
||||||
import { Port } from '../../../common/protocol';
|
import { ReactDialog } from '../../theia/dialogs/dialogs';
|
||||||
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
import { FirmwareUploaderComponent } from './firmware-uploader-component';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class UploadFirmwareDialogProps extends DialogProps {}
|
export class UploadFirmwareDialogProps extends DialogProps {}
|
||||||
@@ -26,14 +23,13 @@ export class UploadFirmwareDialogProps extends DialogProps {}
|
|||||||
@injectable()
|
@injectable()
|
||||||
export class UploadFirmwareDialog extends ReactDialog<void> {
|
export class UploadFirmwareDialog extends ReactDialog<void> {
|
||||||
@inject(BoardsServiceProvider)
|
@inject(BoardsServiceProvider)
|
||||||
private readonly boardsServiceClient: BoardsServiceProvider;
|
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||||
@inject(ArduinoFirmwareUploader)
|
@inject(ArduinoFirmwareUploader)
|
||||||
private readonly arduinoFirmwareUploader: ArduinoFirmwareUploader;
|
private readonly arduinoFirmwareUploader: ArduinoFirmwareUploader;
|
||||||
@inject(FrontendApplicationStateService)
|
@inject(FrontendApplicationStateService)
|
||||||
private readonly appStatusService: FrontendApplicationStateService;
|
private readonly appStateService: FrontendApplicationStateService;
|
||||||
|
|
||||||
private updatableFqbns: string[] = [];
|
private updatableFqbns: string[] = [];
|
||||||
private availableBoards: AvailableBoard[] = [];
|
|
||||||
private isOpen = new Object();
|
private isOpen = new Object();
|
||||||
private busy = false;
|
private busy = false;
|
||||||
|
|
||||||
@@ -49,16 +45,12 @@ export class UploadFirmwareDialog extends ReactDialog<void> {
|
|||||||
|
|
||||||
@postConstruct()
|
@postConstruct()
|
||||||
protected init(): void {
|
protected init(): void {
|
||||||
this.appStatusService.reachedState('ready').then(async () => {
|
this.appStateService.reachedState('ready').then(async () => {
|
||||||
const fqbns = await this.arduinoFirmwareUploader.updatableBoards();
|
const fqbns = await this.arduinoFirmwareUploader.updatableBoards();
|
||||||
this.updatableFqbns = fqbns;
|
this.updatableFqbns = fqbns;
|
||||||
this.update();
|
this.update();
|
||||||
});
|
});
|
||||||
|
this.boardsServiceProvider.onBoardListDidChange(() => this.update());
|
||||||
this.boardsServiceClient.onAvailableBoardsChanged((availableBoards) => {
|
|
||||||
this.availableBoards = availableBoards;
|
|
||||||
this.update();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get value(): void {
|
get value(): void {
|
||||||
@@ -70,7 +62,7 @@ export class UploadFirmwareDialog extends ReactDialog<void> {
|
|||||||
<div>
|
<div>
|
||||||
<form>
|
<form>
|
||||||
<FirmwareUploaderComponent
|
<FirmwareUploaderComponent
|
||||||
availableBoards={this.availableBoards}
|
boardList={this.boardsServiceProvider.boardList}
|
||||||
firmwareUploader={this.arduinoFirmwareUploader}
|
firmwareUploader={this.arduinoFirmwareUploader}
|
||||||
flashFirmware={this.flashFirmware.bind(this)}
|
flashFirmware={this.flashFirmware.bind(this)}
|
||||||
updatableFqbns={this.updatableFqbns}
|
updatableFqbns={this.updatableFqbns}
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
import { nls } from '@theia/core/lib/common';
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
import { shell } from '@theia/core/electron-shared/@electron/remote';
|
import React from '@theia/core/shared/react';
|
||||||
import * as React from '@theia/core/shared/react';
|
// @ts-expect-error see https://github.com/microsoft/TypeScript/issues/49721#issuecomment-1319854183
|
||||||
import ReactMarkdown from 'react-markdown';
|
import type { Options } from 'react-markdown';
|
||||||
import { ProgressInfo, UpdateInfo } from '../../../common/protocol/ide-updater';
|
import { ProgressInfo, UpdateInfo } from '../../../common/protocol/ide-updater';
|
||||||
import ProgressBar from '../../components/ProgressBar';
|
import ProgressBar from '../../components/ProgressBar';
|
||||||
|
|
||||||
|
const ReactMarkdown = React.lazy<React.ComponentType<Options>>(
|
||||||
|
// @ts-expect-error see above
|
||||||
|
() => import('react-markdown')
|
||||||
|
);
|
||||||
|
|
||||||
export interface UpdateProgress {
|
export interface UpdateProgress {
|
||||||
progressInfo?: ProgressInfo | undefined;
|
progressInfo?: ProgressInfo | undefined;
|
||||||
downloadFinished?: boolean;
|
downloadFinished?: boolean;
|
||||||
@@ -15,6 +20,7 @@ export interface UpdateProgress {
|
|||||||
export interface IDEUpdaterComponentProps {
|
export interface IDEUpdaterComponentProps {
|
||||||
updateInfo: UpdateInfo;
|
updateInfo: UpdateInfo;
|
||||||
updateProgress: UpdateProgress;
|
updateProgress: UpdateProgress;
|
||||||
|
openExternal: (url: string) => undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IDEUpdaterComponent = ({
|
export const IDEUpdaterComponent = ({
|
||||||
@@ -25,6 +31,7 @@ export const IDEUpdaterComponent = ({
|
|||||||
progressInfo,
|
progressInfo,
|
||||||
error,
|
error,
|
||||||
},
|
},
|
||||||
|
openExternal,
|
||||||
}: IDEUpdaterComponentProps): React.ReactElement => {
|
}: IDEUpdaterComponentProps): React.ReactElement => {
|
||||||
const { version, releaseNotes } = updateInfo;
|
const { version, releaseNotes } = updateInfo;
|
||||||
const [changelog, setChangelog] = React.useState<string>('');
|
const [changelog, setChangelog] = React.useState<string>('');
|
||||||
@@ -95,20 +102,25 @@ export const IDEUpdaterComponent = ({
|
|||||||
{changelog && (
|
{changelog && (
|
||||||
<div className="dialogRow changelog-container">
|
<div className="dialogRow changelog-container">
|
||||||
<div className="changelog">
|
<div className="changelog">
|
||||||
<ReactMarkdown
|
<React.Suspense
|
||||||
components={{
|
fallback={
|
||||||
a: ({ href, children, ...props }) => (
|
<div className="fallback">
|
||||||
<a
|
<div className="spinner" />
|
||||||
onClick={() => href && shell.openExternal(href)}
|
</div>
|
||||||
{...props}
|
}
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</a>
|
|
||||||
),
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{changelog}
|
<ReactMarkdown
|
||||||
</ReactMarkdown>
|
components={{
|
||||||
|
a: ({ href, children, ...props }) => (
|
||||||
|
<a onClick={() => href && openExternal(href)} {...props}>
|
||||||
|
{children}
|
||||||
|
</a>
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{changelog}
|
||||||
|
</ReactMarkdown>
|
||||||
|
</React.Suspense>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as React from '@theia/core/shared/react';
|
import React from '@theia/core/shared/react';
|
||||||
import {
|
import {
|
||||||
inject,
|
inject,
|
||||||
injectable,
|
injectable,
|
||||||
@@ -18,8 +18,6 @@ import {
|
|||||||
import { LocalStorageService } from '@theia/core/lib/browser';
|
import { LocalStorageService } from '@theia/core/lib/browser';
|
||||||
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
||||||
|
|
||||||
const DOWNLOAD_PAGE_URL = 'https://www.arduino.cc/en/software';
|
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class IDEUpdaterDialogProps extends DialogProps {}
|
export class IDEUpdaterDialogProps extends DialogProps {}
|
||||||
|
|
||||||
@@ -76,11 +74,15 @@ export class IDEUpdaterDialog extends ReactDialog<UpdateInfo | undefined> {
|
|||||||
<IDEUpdaterComponent
|
<IDEUpdaterComponent
|
||||||
updateInfo={this.updateInfo}
|
updateInfo={this.updateInfo}
|
||||||
updateProgress={this.updateProgress}
|
updateProgress={this.updateProgress}
|
||||||
|
openExternal={this.openExternal}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly openExternal = (url: string) =>
|
||||||
|
this.windowService.openNewWindow(url, { external: true });
|
||||||
|
|
||||||
get value(): UpdateInfo | undefined {
|
get value(): UpdateInfo | undefined {
|
||||||
return this.updateInfo;
|
return this.updateInfo;
|
||||||
}
|
}
|
||||||
@@ -164,7 +166,7 @@ export class IDEUpdaterDialog extends ReactDialog<UpdateInfo | undefined> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private openDownloadPage(): void {
|
private openDownloadPage(): void {
|
||||||
this.windowService.openNewWindow(DOWNLOAD_PAGE_URL, { external: true });
|
this.openExternal('https://www.arduino.cc/en/software');
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as React from '@theia/core/shared/react';
|
import React from '@theia/core/shared/react';
|
||||||
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
|
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
|
||||||
import 'react-tabs/style/react-tabs.css';
|
import 'react-tabs/style/react-tabs.css';
|
||||||
import { Disable } from 'react-disable';
|
import { Disable } from 'react-disable';
|
||||||
@@ -24,6 +24,12 @@ import {
|
|||||||
} from '@theia/core/lib/common/i18n/localization';
|
} from '@theia/core/lib/common/i18n/localization';
|
||||||
import SettingsStepInput from './settings-step-input';
|
import SettingsStepInput from './settings-step-input';
|
||||||
import { InterfaceScale } from '../../contributions/interface-scale';
|
import { InterfaceScale } from '../../contributions/interface-scale';
|
||||||
|
import {
|
||||||
|
userConfigurableThemes,
|
||||||
|
themeLabelForSettings,
|
||||||
|
arduinoThemeTypeOf,
|
||||||
|
} from '../../theia/core/theming';
|
||||||
|
import { Theme } from '@theia/core/lib/common/theme';
|
||||||
|
|
||||||
const maxScale = InterfaceScale.ZoomLevel.toPercentage(
|
const maxScale = InterfaceScale.ZoomLevel.toPercentage(
|
||||||
InterfaceScale.ZoomLevel.MAX
|
InterfaceScale.ZoomLevel.MAX
|
||||||
@@ -218,14 +224,10 @@ export class SettingsComponent extends React.Component<
|
|||||||
<div className="flex-line">
|
<div className="flex-line">
|
||||||
<select
|
<select
|
||||||
className="theia-select"
|
className="theia-select"
|
||||||
value={this.props.themeService.getCurrentTheme().label}
|
value={this.currentThemeLabel}
|
||||||
onChange={this.themeDidChange}
|
onChange={this.themeDidChange}
|
||||||
>
|
>
|
||||||
{this.props.themeService.getThemes().map(({ id, label }) => (
|
{this.themeSelectOptions}
|
||||||
<option key={id} value={label}>
|
|
||||||
{label}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-line">
|
<div className="flex-line">
|
||||||
@@ -333,6 +335,46 @@ export class SettingsComponent extends React.Component<
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private get currentThemeLabel(): string {
|
||||||
|
const currentTheme = this.props.themeService.getCurrentTheme();
|
||||||
|
return themeLabelForSettings(currentTheme);
|
||||||
|
}
|
||||||
|
|
||||||
|
private get separatedThemes(): (Theme | string)[] {
|
||||||
|
const separatedThemes: (Theme | string)[] = [];
|
||||||
|
const groupedThemes = userConfigurableThemes(this.props.themeService);
|
||||||
|
for (const group of groupedThemes) {
|
||||||
|
for (let i = 0; i < group.length; i++) {
|
||||||
|
const theme = group[i];
|
||||||
|
if (i === 0 && separatedThemes.length) {
|
||||||
|
const arduinoThemeType = arduinoThemeTypeOf(theme);
|
||||||
|
separatedThemes.push(`separator-${arduinoThemeType}`);
|
||||||
|
}
|
||||||
|
separatedThemes.push(theme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return separatedThemes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private get themeSelectOptions(): React.ReactNode[] {
|
||||||
|
return this.separatedThemes.map((item) => {
|
||||||
|
if (typeof item === 'string') {
|
||||||
|
return (
|
||||||
|
// ─ -> BOX DRAWINGS LIGHT HORIZONTAL
|
||||||
|
<option key={item} disabled>
|
||||||
|
──────────
|
||||||
|
</option>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const label = themeLabelForSettings(item);
|
||||||
|
return (
|
||||||
|
<option key={item.id} value={label}>
|
||||||
|
{label}
|
||||||
|
</option>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private toSelectOptions(language: string | LanguageInfo): JSX.Element {
|
private toSelectOptions(language: string | LanguageInfo): JSX.Element {
|
||||||
const plain = typeof language === 'string';
|
const plain = typeof language === 'string';
|
||||||
const key = plain ? language : language.languageId;
|
const key = plain ? language : language.languageId;
|
||||||
@@ -610,8 +652,8 @@ export class SettingsComponent extends React.Component<
|
|||||||
event: React.ChangeEvent<HTMLSelectElement>
|
event: React.ChangeEvent<HTMLSelectElement>
|
||||||
): void => {
|
): void => {
|
||||||
const { selectedIndex } = event.target.options;
|
const { selectedIndex } = event.target.options;
|
||||||
const theme = this.props.themeService.getThemes()[selectedIndex];
|
const theme = this.separatedThemes[selectedIndex];
|
||||||
if (theme) {
|
if (theme && typeof theme !== 'string') {
|
||||||
this.setState({ themeId: theme.id });
|
this.setState({ themeId: theme.id });
|
||||||
if (this.props.themeService.getCurrentTheme().id !== theme.id) {
|
if (this.props.themeService.getCurrentTheme().id !== theme.id) {
|
||||||
this.props.themeService.setCurrentTheme(theme.id);
|
this.props.themeService.setCurrentTheme(theme.id);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as React from '@theia/core/shared/react';
|
import React from '@theia/core/shared/react';
|
||||||
import {
|
import {
|
||||||
injectable,
|
injectable,
|
||||||
inject,
|
inject,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as React from '@theia/core/shared/react';
|
import React from '@theia/core/shared/react';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
|
||||||
interface SettingsStepInputProps {
|
interface SettingsStepInputProps {
|
||||||
|
|||||||
@@ -117,12 +117,23 @@ export class SettingsService {
|
|||||||
protected _settings: Settings;
|
protected _settings: Settings;
|
||||||
|
|
||||||
@postConstruct()
|
@postConstruct()
|
||||||
protected async init(): Promise<void> {
|
protected init(): void {
|
||||||
this.appStateService.reachedState('ready').then(async () => {
|
this.appStateService.reachedState('ready').then(async () => {
|
||||||
const settings = await this.loadSettings();
|
const settings = await this.loadSettings();
|
||||||
this._settings = deepClone(settings);
|
this._settings = deepClone(settings);
|
||||||
this.ready.resolve();
|
this.ready.resolve();
|
||||||
});
|
});
|
||||||
|
this.preferenceService.onPreferenceChanged(async (event) => {
|
||||||
|
await this.ready.promise;
|
||||||
|
const { preferenceName, newValue } = event;
|
||||||
|
if (
|
||||||
|
preferenceName === 'workbench.colorTheme' &&
|
||||||
|
typeof newValue === 'string' &&
|
||||||
|
this._settings.themeId !== newValue
|
||||||
|
) {
|
||||||
|
this.reset();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async loadSettings(): Promise<Settings> {
|
protected async loadSettings(): Promise<Settings> {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as React from '@theia/core/shared/react';
|
import React from '@theia/core/shared/react';
|
||||||
import { BoardUserField } from '../../../common/protocol';
|
import { BoardUserField } from '../../../common/protocol';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import { nls } from '@theia/core/lib/common';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as React from '@theia/core/shared/react';
|
import React from '@theia/core/shared/react';
|
||||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
import { DialogProps } from '@theia/core/lib/browser/dialogs';
|
import { DialogProps } from '@theia/core/lib/browser/dialogs';
|
||||||
import { Message } from '@theia/core/shared/@phosphor/messaging';
|
import { Message } from '@theia/core/shared/@phosphor/messaging';
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user