Compare commits
14 Commits
2.0.0
...
open-recen
Author | SHA1 | Date | |
---|---|---|---|
![]() |
750486a8f0 | ||
![]() |
a04527d3b8 | ||
![]() |
33ec67109b | ||
![]() |
4e590ab618 | ||
![]() |
026e80e7fc | ||
![]() |
fdf6f0f9c8 | ||
![]() |
0151e4c224 | ||
![]() |
e8b0ea4f2d | ||
![]() |
7c1ca04c75 | ||
![]() |
0ba88d5ab6 | ||
![]() |
96e229d803 | ||
![]() |
d07d83fdfe | ||
![]() |
5f82577bc1 | ||
![]() |
35fcfb89c1 |
@@ -17,7 +17,6 @@ module.exports = {
|
||||
'scripts/*',
|
||||
'electron/*',
|
||||
'electron-app/*',
|
||||
'browser-app/*',
|
||||
'plugins/*',
|
||||
'arduino-ide-extension/src/node/cli-protocol',
|
||||
],
|
||||
|
6
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -8,6 +8,12 @@ contact_links:
|
||||
- name: Support request
|
||||
url: https://forum.arduino.cc/
|
||||
about: We can help you out on the Arduino Forum!
|
||||
- name: Issue report guide
|
||||
url: https://github.com/arduino/arduino-ide/blob/main/docs/issues.md#issue-report-guide
|
||||
about: Learn about submitting issue reports to this repository.
|
||||
- name: Contributor guide
|
||||
url: https://github.com/arduino/arduino-ide/blob/main/docs/CONTRIBUTING.md#contributor-guide
|
||||
about: Learn about contributing to this project.
|
||||
- name: Discuss development work on the project
|
||||
url: https://groups.google.com/a/arduino.cc/g/developers
|
||||
about: Arduino Developers Mailing List
|
||||
|
31
.vscode/launch.json
vendored
@@ -80,37 +80,6 @@
|
||||
"port": 9222,
|
||||
"webRoot": "${workspaceFolder}/electron-app"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "App (Browser)",
|
||||
"program": "${workspaceRoot}/browser-app/src-gen/backend/main.js",
|
||||
"args": [
|
||||
"--hostname=0.0.0.0",
|
||||
"--port=3000",
|
||||
"--no-cluster",
|
||||
"--no-app-auto-install",
|
||||
"--plugins=local-dir:plugins"
|
||||
],
|
||||
"windows": {
|
||||
"env": {
|
||||
"NODE_ENV": "development",
|
||||
"NODE_PRESERVE_SYMLINKS": "1"
|
||||
}
|
||||
},
|
||||
"env": {
|
||||
"NODE_ENV": "development"
|
||||
},
|
||||
"sourceMaps": true,
|
||||
"outFiles": [
|
||||
"${workspaceRoot}/browser-app/src-gen/backend/*.js",
|
||||
"${workspaceRoot}/browser-app/lib/**/*.js",
|
||||
"${workspaceRoot}/arduino-ide-extension/lib/**/*.js"
|
||||
],
|
||||
"smartStep": true,
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"outputCapture": "std"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
|
30
.vscode/tasks.json
vendored
@@ -12,17 +12,6 @@
|
||||
"clear": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Arduino IDE - Start Browser App",
|
||||
"type": "shell",
|
||||
"command": "yarn --cwd ./browser-app start",
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "new",
|
||||
"clear": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Arduino IDE - Watch IDE Extension",
|
||||
"type": "shell",
|
||||
@@ -34,17 +23,6 @@
|
||||
"clear": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Arduino IDE - Watch Browser App",
|
||||
"type": "shell",
|
||||
"command": "yarn --cwd ./browser-app watch",
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "new",
|
||||
"clear": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Arduino IDE - Watch Electron App",
|
||||
"type": "shell",
|
||||
@@ -56,14 +34,6 @@
|
||||
"clear": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Arduino IDE - Watch All [Browser]",
|
||||
"type": "shell",
|
||||
"dependsOn": [
|
||||
"Arduino IDE - Watch IDE Extension",
|
||||
"Arduino IDE - Watch Browser App"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "Arduino IDE - Watch All [Electron]",
|
||||
"type": "shell",
|
||||
|
121
BUILDING.md
@@ -1,120 +1,3 @@
|
||||
# Development
|
||||
|
||||
This page includes technical documentation for developers who want to build the IDE locally and contribute to the project.
|
||||
|
||||
## Architecture overview
|
||||
|
||||
The IDE consists of three major parts:
|
||||
- the _Electron main_ process,
|
||||
- the _backend_, and
|
||||
- the _frontend_.
|
||||
|
||||
The _Electron main_ process is responsible for:
|
||||
- creating the application,
|
||||
- managing the application lifecycle via listeners, and
|
||||
- creating and managing the web pages for the app.
|
||||
|
||||
In Electron, the process that runs the main entry JavaScript file is called the main process. The _Electron main_ process can display a GUI by creating web pages. An Electron app always has exactly one main process.
|
||||
|
||||
By default, whenever the _Electron main_ process creates a web page, it will instantiate a new `BrowserWindow` instance. Since Electron uses Chromium for displaying web pages, Chromium's multi-process architecture is also used. Each web page in Electron runs in its own process, which is called the renderer process. Each `BrowserWindow` instance runs the web page in its own renderer process. When a `BrowserWindow` instance is destroyed, the corresponding renderer process is also terminated. The main process manages all web pages and their corresponding renderer processes. Each renderer process is isolated and only cares about the web page running in it.<sup>[[1]]</sup>
|
||||
|
||||
In normal browsers, web pages usually run in a sandboxed environment, and accessing native resources are disallowed. However, Electron has the power to use Node.js APIs in the web pages allowing lower-level OS interactions. Due to security reasons, accessing native resources is an undesired behavior in the IDE. So by convention, we do not use Node.js APIs. (Note: the Node.js integration is [not yet disabled](https://github.com/eclipse-theia/theia/issues/2018) although it is not used). In the IDE, only the _backend_ allows OS interaction.
|
||||
|
||||
The _backend_ process is responsible for:
|
||||
- providing access to the filesystem,
|
||||
- communicating with the [Arduino CLI](https://github.com/arduino/arduino-cli) via gRPC,
|
||||
- running your terminal,
|
||||
- exposing additional RESTful APIs,
|
||||
- performing the Git commands in the local repositories,
|
||||
- hosting and running any VS Code extensions, or
|
||||
- executing VS Code tasks<sup>[[2]]</sup>.
|
||||
|
||||
The _Electron main_ process spawns the _backend_ process. There is always exactly one _backend_ process. However, due to performance considerations, the _backend_ spawns several sub-processes for the filesystem watching, Git repository discovery, etc. The communication between the _backend_ process and its sub-processes is established via IPC. Besides spawning sub-processes, the _backend_ will start an HTTP server on a random available port, and serves the web application as static content. When the sub-processes are up and running, and the HTTP server is also listening, the _backend_ process sends the HTTP server port to the _Electron main_ process via IPC. The _Electron main_ process will load the _backend_'s endpoint in the `BrowserWindow`.
|
||||
|
||||
The _frontend_ is running as an Electron renderer process and can invoke services implemented on the _backend_. The communication between the _backend_ and the _frontend_ is done via JSON-RPC over a websocket connection. This means, the services running in the _frontend_ are all proxies, and will ask the corresponding service implementation on the _backend_.
|
||||
|
||||
[1]: https://www.electronjs.org/docs/tutorial/application-architecture#differences-between-main-process-and-renderer-process
|
||||
[2]: https://code.visualstudio.com/Docs/editor/tasks
|
||||
|
||||
|
||||
## Build from source
|
||||
|
||||
If you’re familiar with TypeScript, the [Theia IDE](https://theia-ide.org/), and if you want to contribute to the
|
||||
project, you should be able to build the Arduino IDE locally.
|
||||
Please refer to the [Theia IDE prerequisites](https://github.com/eclipse-theia/theia/blob/master/doc/Developing.md#prerequisites) documentation for the setup instructions.
|
||||
> **Note**: Node.js 14 must be used instead of the version 12 recommended at the link above.
|
||||
|
||||
Once you have all the tools installed, you can build the editor following these steps
|
||||
|
||||
1. Install the dependencies and build
|
||||
```sh
|
||||
yarn
|
||||
```
|
||||
|
||||
2. Rebuild the dependencies
|
||||
```sh
|
||||
yarn rebuild:browser
|
||||
```
|
||||
|
||||
3. Rebuild the electron dependencies
|
||||
```sh
|
||||
yarn rebuild:electron
|
||||
```
|
||||
|
||||
4. Start the application
|
||||
```sh
|
||||
yarn start
|
||||
```
|
||||
|
||||
### Notes for Windows contributors
|
||||
Windows requires the Microsoft Visual C++ (MSVC) compiler toolset to be installed on your development machine.
|
||||
|
||||
In case it's not already present, it can be downloaded from the "**Tools for Visual Studio 20XX**" section of the Visual Studio [downloads page](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) via the "**Build Tools for Visual Studio 20XX**" (e.g., "**Build Tools for Visual Studio 2022**") download link.
|
||||
|
||||
Select "**Desktop development with C++**" from the "**Workloads**" tab during the installation procedure.
|
||||
|
||||
### CI
|
||||
|
||||
This project is built on [GitHub Actions](https://github.com/arduino/arduino-ide/actions).
|
||||
|
||||
- _Snapshot_ builds run when changes are pushed to the `main` branch, or when a PR is created against the `main` branch. For the sake of the review and verification process, the build artifacts for each operating system can be downloaded from the GitHub Actions page.
|
||||
- _Nightly_ builds run every day at 03:00 GMT from the `main` branch.
|
||||
- _Release_ builds run when a new tag is pushed to the remote. The tag must follow the [semver](https://semver.org/). For instance, `1.2.3` is a correct tag, but `v2.3.4` won't work. Steps to trigger a new release build:
|
||||
- Create a local tag:
|
||||
```sh
|
||||
git tag -a 1.2.3 -m "Creating a new tag for the `1.2.3` release."
|
||||
```
|
||||
- Push it to the remote:
|
||||
```sh
|
||||
git push origin 1.2.3
|
||||
```
|
||||
|
||||
## Notes for macOS contributors
|
||||
Beginning in macOS 10.14.5, the software [must be notarized to run](https://developer.apple.com/documentation/xcode/notarizing_macos_software_before_distribution). The signing and notarization processes for the Arduino IDE are managed by our Continuous Integration (CI) workflows, implemented with GitHub Actions. On every push and pull request, the Arduino IDE is built and saved to a workflow artifact. These artifacts can be used by contributors and beta testers who don't want to set up a build system locally.
|
||||
For security reasons, signing and notarization are disabled for workflow runs for pull requests from forks of this repository. This means that macOS will block you from running those artifacts.
|
||||
Due to this limitation, Mac users have two options for testing contributions from forks:
|
||||
|
||||
### The Safe approach (recommended)
|
||||
|
||||
Follow [the instructions above](#build-from-source) to create the build environment locally, then build the code you want to test.
|
||||
|
||||
### The Risky approach
|
||||
|
||||
*Please note that this approach is risky as you are lowering the security on your system, therefore we strongly discourage you from following it.*
|
||||
1. Use [this guide](https://help.apple.com/xcode/mac/10.2/index.html?localePath=en.lproj#/dev9b7736b0e), in order to disable Gatekeeper (at your own risk!).
|
||||
1. Download the unsigned artifact provided by the CI workflow run related to the Pull Request at each push.
|
||||
1. Re-enable Gatekeeper after tests are done, following the guide linked above.
|
||||
|
||||
## FAQ
|
||||
|
||||
* *Can I manually change the version of the [`arduino-cli`](https://github.com/arduino/arduino-cli/) used by the IDE?*
|
||||
|
||||
Yes. It is possible but not recommended. The CLI exposes a set of functionality via [gRPC](https://github.com/arduino/arduino-cli/tree/master/rpc) and the IDE uses this API to communicate with the CLI. Before we build a new version of IDE, we pin a specific version of CLI and use the corresponding `proto` files to generate TypeScript modules for gRPC. This means, a particular version of IDE is compliant only with the pinned version of CLI. Mismatching IDE and CLI versions might not be able to communicate with each other. This could cause unpredictable IDE behavior.
|
||||
|
||||
* *I have understood that not all versions of the CLI are compatible with my version of IDE but how can I manually update the `arduino-cli` inside the IDE?*
|
||||
|
||||
[Get](https://arduino.github.io/arduino-cli/installation) the desired version of `arduino-cli` for your platform and manually replace the one inside the IDE. The CLI can be found inside the IDE at:
|
||||
- Windows: `C:\path\to\Arduino IDE\resources\app\node_modules\arduino-ide-extension\build\arduino-cli.exe`,
|
||||
- macOS: `/path/to/Arduino IDE.app/Contents/Resources/app/node_modules/arduino-ide-extension/build/arduino-cli`, and
|
||||
- Linux: `/path/to/Arduino IDE/resources/app/node_modules/arduino-ide-extension/build/arduino-cli`.
|
||||
# Development Guide
|
||||
|
||||
This documentation has been moved [**here**](docs/development.md#development-guide).
|
||||
|
18
README.md
@@ -20,10 +20,9 @@ If you need assistance, see the [Help Center](https://support.arduino.cc/hc/en-u
|
||||
|
||||
## Bugs & Issues
|
||||
|
||||
If you want to report an issue, you can submit it to the [issue tracker](https://github.com/arduino/arduino-ide/issues) of this repository. A few rules apply:
|
||||
If you want to report an issue, you can submit it to the [issue tracker](https://github.com/arduino/arduino-ide/issues) of this repository.
|
||||
|
||||
- Before posting, please check if the same problem has been already reported by someone else to avoid duplicates.
|
||||
- Remember to include as much detail as you can about your hardware set-up, code and steps for reproducing the issue. Make sure you're using an original Arduino board.
|
||||
See [**the issue report guide**](docs/contributor-guide/issues.md#issue-report-guide) for instructions.
|
||||
|
||||
### Security
|
||||
|
||||
@@ -35,16 +34,15 @@ e-mail contact: security@arduino.cc
|
||||
|
||||
## Contributions and development
|
||||
|
||||
Contributions are very welcome! You can browse the list of open issues to see what's needed and then you can submit your code using a Pull Request. Please provide detailed descriptions. We also appreciate any help in testing issues and patches contributed by other users.
|
||||
Contributions are very welcome! There are several ways to participate in this project, including:
|
||||
|
||||
This repository contains the main code, but two more repositories are included during the build process:
|
||||
- Fixing bugs
|
||||
- Beta testing
|
||||
- Translation
|
||||
|
||||
- [vscode-arduino-tools](https://github.com/arduino/vscode-arduino-tools): provides support for the language server and the debugger
|
||||
- [arduino-language-server](https://github.com/arduino/arduino-language-server): provides the language server that parses Arduino code
|
||||
See [**the contributor guide**](docs/CONTRIBUTING.md#contributor-guide) for more information.
|
||||
|
||||
See the [BUILDING.md](BUILDING.md) for a technical overview of the application and instructions for building the code.
|
||||
|
||||
You can help with the translation of the Arduino IDE to your language here: [Arduino IDE on Transifex](https://www.transifex.com/arduino-1/ide2/dashboard/).
|
||||
See the [**development guide**](docs/development.md) for a technical overview of the application and instructions for building the code.
|
||||
|
||||
## Donations
|
||||
|
||||
|
@@ -147,11 +147,9 @@
|
||||
"frontend": "lib/browser/arduino-ide-frontend-module"
|
||||
},
|
||||
{
|
||||
"frontend": "lib/browser/theia/core/browser-menu-module",
|
||||
"frontendElectron": "lib/electron-browser/theia/core/electron-menu-module"
|
||||
},
|
||||
{
|
||||
"frontend": "lib/browser/theia/core/browser-window-module",
|
||||
"frontendElectron": "lib/electron-browser/theia/core/electron-window-module"
|
||||
},
|
||||
{
|
||||
|
@@ -105,7 +105,8 @@ import {
|
||||
} from '@theia/core/lib/browser/connection-status-service';
|
||||
import { BoardsDataMenuUpdater } from './boards/boards-data-menu-updater';
|
||||
import { BoardsDataStore } from './boards/boards-data-store';
|
||||
import { ILogger } from '@theia/core';
|
||||
import { ILogger } from '@theia/core/lib/common/logger';
|
||||
import { bindContributionProvider } from '@theia/core/lib/common/contribution-provider';
|
||||
import {
|
||||
FileSystemExt,
|
||||
FileSystemExtPath,
|
||||
@@ -308,7 +309,7 @@ import { CoreErrorHandler } from './contributions/core-error-handler';
|
||||
import { CompilerErrors } from './contributions/compiler-errors';
|
||||
import { WidgetManager } from './theia/core/widget-manager';
|
||||
import { WidgetManager as TheiaWidgetManager } from '@theia/core/lib/browser/widget-manager';
|
||||
import { StartupTasks } from './widgets/sketchbook/startup-task';
|
||||
import { StartupTasks } from './contributions/startup-task';
|
||||
import { IndexesUpdateProgress } from './contributions/indexes-update-progress';
|
||||
import { Daemon } from './contributions/daemon';
|
||||
import { FirstStartupInstaller } from './contributions/first-startup-installer';
|
||||
@@ -334,6 +335,8 @@ import {
|
||||
} from './widgets/component-list/filter-renderer';
|
||||
import { CheckForUpdates } from './contributions/check-for-updates';
|
||||
import { OutputEditorFactory } from './theia/output/output-editor-factory';
|
||||
import { StartupTaskProvider } from '../electron-common/startup-task';
|
||||
import { DeleteSketch } from './contributions/delete-sketch';
|
||||
|
||||
const registerArduinoThemes = () => {
|
||||
const themes: MonacoThemeJson[] = [
|
||||
@@ -433,6 +436,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
||||
// Boards service client to receive and delegate notifications from the backend.
|
||||
bind(BoardsServiceProvider).toSelf().inSingletonScope();
|
||||
bind(FrontendApplicationContribution).toService(BoardsServiceProvider);
|
||||
bind(CommandContribution).toService(BoardsServiceProvider);
|
||||
|
||||
// To be able to track, and update the menu based on the core settings (aka. board details) of the currently selected board.
|
||||
bind(FrontendApplicationContribution)
|
||||
@@ -757,6 +761,10 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
||||
Contribution.configure(bind, OpenBoardsConfig);
|
||||
Contribution.configure(bind, SketchFilesTracker);
|
||||
Contribution.configure(bind, CheckForUpdates);
|
||||
Contribution.configure(bind, DeleteSketch);
|
||||
|
||||
bindContributionProvider(bind, StartupTaskProvider);
|
||||
bind(StartupTaskProvider).toService(BoardsServiceProvider); // to reuse the boards config in another window
|
||||
|
||||
// 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.
|
||||
|
@@ -413,53 +413,5 @@ export namespace BoardsConfig {
|
||||
const { name } = selectedBoard;
|
||||
return `${name}${port ? ` at ${port.address}` : ''}`;
|
||||
}
|
||||
|
||||
export function setConfig(
|
||||
config: Config | undefined,
|
||||
urlToAttachTo: URL
|
||||
): URL {
|
||||
const copy = new URL(urlToAttachTo.toString());
|
||||
if (!config) {
|
||||
copy.searchParams.delete('boards-config');
|
||||
return copy;
|
||||
}
|
||||
|
||||
const selectedBoard = config.selectedBoard
|
||||
? {
|
||||
name: config.selectedBoard.name,
|
||||
fqbn: config.selectedBoard.fqbn,
|
||||
}
|
||||
: undefined;
|
||||
const selectedPort = config.selectedPort
|
||||
? {
|
||||
protocol: config.selectedPort.protocol,
|
||||
address: config.selectedPort.address,
|
||||
}
|
||||
: undefined;
|
||||
const jsonConfig = JSON.stringify({ selectedBoard, selectedPort });
|
||||
copy.searchParams.set('boards-config', encodeURIComponent(jsonConfig));
|
||||
return copy;
|
||||
}
|
||||
|
||||
export function getConfig(url: URL): Config | undefined {
|
||||
const encoded = url.searchParams.get('boards-config');
|
||||
if (!encoded) {
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
const raw = decodeURIComponent(encoded);
|
||||
const candidate = JSON.parse(raw);
|
||||
if (typeof candidate === 'object') {
|
||||
return candidate;
|
||||
}
|
||||
console.warn(
|
||||
`Expected candidate to be an object. It was ${typeof candidate}. URL was: ${url}`
|
||||
);
|
||||
return undefined;
|
||||
} catch (e) {
|
||||
console.log(`Could not get board config from URL: ${url}.`, e);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,12 @@
|
||||
import { injectable, inject } from '@theia/core/shared/inversify';
|
||||
import { Emitter } from '@theia/core/lib/common/event';
|
||||
import { ILogger } from '@theia/core/lib/common/logger';
|
||||
import { CommandService } from '@theia/core/lib/common/command';
|
||||
import {
|
||||
Command,
|
||||
CommandContribution,
|
||||
CommandRegistry,
|
||||
CommandService,
|
||||
} from '@theia/core/lib/common/command';
|
||||
import { MessageService } from '@theia/core/lib/common/message-service';
|
||||
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application';
|
||||
import { RecursiveRequired } from '../../common/types';
|
||||
@@ -23,9 +28,18 @@ import { nls } from '@theia/core/lib/common';
|
||||
import { Deferred } from '@theia/core/lib/common/promise-util';
|
||||
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
||||
import { Unknown } from '../../common/nls';
|
||||
import {
|
||||
StartupTask,
|
||||
StartupTaskProvider,
|
||||
} from '../../electron-common/startup-task';
|
||||
|
||||
@injectable()
|
||||
export class BoardsServiceProvider implements FrontendApplicationContribution {
|
||||
export class BoardsServiceProvider
|
||||
implements
|
||||
FrontendApplicationContribution,
|
||||
StartupTaskProvider,
|
||||
CommandContribution
|
||||
{
|
||||
@inject(ILogger)
|
||||
protected logger: ILogger;
|
||||
|
||||
@@ -50,6 +64,7 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
|
||||
AvailableBoard[]
|
||||
>();
|
||||
protected readonly onAvailablePortsChangedEmitter = new Emitter<Port[]>();
|
||||
private readonly inheritedConfig = new Deferred<BoardsConfig.Config>();
|
||||
|
||||
/**
|
||||
* Used for the auto-reconnecting. Sometimes, the attached board gets disconnected after uploading something to it.
|
||||
@@ -115,6 +130,13 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
|
||||
});
|
||||
}
|
||||
|
||||
registerCommands(registry: CommandRegistry): void {
|
||||
registry.registerCommand(USE_INHERITED_CONFIG, {
|
||||
execute: (inheritedConfig: BoardsConfig.Config) =>
|
||||
this.inheritedConfig.resolve(inheritedConfig),
|
||||
});
|
||||
}
|
||||
|
||||
get reconciled(): Promise<void> {
|
||||
return this._reconciled.promise;
|
||||
}
|
||||
@@ -578,6 +600,7 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
|
||||
boardsConfig.selectedBoard &&
|
||||
availableBoards.every(({ selected }) => !selected)
|
||||
) {
|
||||
let port = boardsConfig.selectedPort
|
||||
// If the selected board has the same port of an unknown board
|
||||
// that is already in availableBoards we might get a duplicate port.
|
||||
// So we remove the one already in the array and add the selected one.
|
||||
@@ -585,11 +608,15 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
|
||||
(board) => board.port?.address === boardsConfig.selectedPort?.address
|
||||
);
|
||||
if (found >= 0) {
|
||||
// get the "Unknown board port" that we will substitute,
|
||||
// then we can include it in the "availableBoard object"
|
||||
// pushed below; to ensure addressLabel is included
|
||||
port = availableBoards[found].port
|
||||
availableBoards.splice(found, 1);
|
||||
}
|
||||
availableBoards.push({
|
||||
...boardsConfig.selectedBoard,
|
||||
port: boardsConfig.selectedPort,
|
||||
port,
|
||||
selected: true,
|
||||
state: AvailableBoard.State.incomplete,
|
||||
});
|
||||
@@ -655,11 +682,14 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
|
||||
let storedLatestBoardsConfig = await this.getData<
|
||||
BoardsConfig.Config | undefined
|
||||
>('latest-boards-config');
|
||||
// Try to get from the URL if it was not persisted.
|
||||
// Try to get from the startup task. Wait for it, then timeout. Maybe it never arrives.
|
||||
if (!storedLatestBoardsConfig) {
|
||||
storedLatestBoardsConfig = BoardsConfig.Config.getConfig(
|
||||
new URL(window.location.href)
|
||||
);
|
||||
storedLatestBoardsConfig = await Promise.race([
|
||||
this.inheritedConfig.promise,
|
||||
new Promise<undefined>((resolve) =>
|
||||
setTimeout(() => resolve(undefined), 2_000)
|
||||
),
|
||||
]);
|
||||
}
|
||||
if (storedLatestBoardsConfig) {
|
||||
this.latestBoardsConfig = storedLatestBoardsConfig;
|
||||
@@ -682,8 +712,31 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
|
||||
key
|
||||
);
|
||||
}
|
||||
|
||||
tasks(): StartupTask[] {
|
||||
return [
|
||||
{
|
||||
command: USE_INHERITED_CONFIG.id,
|
||||
args: [this.boardsConfig],
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* It should be neither visible nor called from outside.
|
||||
*
|
||||
* This service creates a startup task with the current board config and
|
||||
* passes the task to the electron-main process so that the new window
|
||||
* can inherit the boards config state of this service.
|
||||
*
|
||||
* Note that the state is always set, but new windows might ignore it.
|
||||
* For example, the new window already has a valid boards config persisted to the local storage.
|
||||
*/
|
||||
const USE_INHERITED_CONFIG: Command = {
|
||||
id: 'arduino-use-inherited-boards-config',
|
||||
};
|
||||
|
||||
/**
|
||||
* Representation of a ready-to-use board, either the user has configured it or was automatically recognized by the CLI.
|
||||
* An available board was not necessarily recognized by the CLI (e.g.: it is a 3rd party board) or correctly configured but ready for `verify`.
|
||||
|
@@ -0,0 +1,45 @@
|
||||
import { injectable } from '@theia/core/shared/inversify';
|
||||
import { SketchesError } from '../../common/protocol';
|
||||
import {
|
||||
Command,
|
||||
CommandRegistry,
|
||||
SketchContribution,
|
||||
Sketch,
|
||||
} from './contribution';
|
||||
|
||||
@injectable()
|
||||
export class DeleteSketch extends SketchContribution {
|
||||
override registerCommands(registry: CommandRegistry): void {
|
||||
registry.registerCommand(DeleteSketch.Commands.DELETE_SKETCH, {
|
||||
execute: (uri: string) => this.deleteSketch(uri),
|
||||
});
|
||||
}
|
||||
|
||||
private async deleteSketch(uri: string): Promise<void> {
|
||||
const sketch = await this.loadSketch(uri);
|
||||
if (!sketch) {
|
||||
console.info(`Sketch not found at ${uri}. Skipping deletion.`);
|
||||
return;
|
||||
}
|
||||
return this.sketchService.deleteSketch(sketch);
|
||||
}
|
||||
|
||||
private async loadSketch(uri: string): Promise<Sketch | undefined> {
|
||||
try {
|
||||
const sketch = await this.sketchService.loadSketch(uri);
|
||||
return sketch;
|
||||
} catch (err) {
|
||||
if (SketchesError.NotFound.is(err)) {
|
||||
return undefined;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
export namespace DeleteSketch {
|
||||
export namespace Commands {
|
||||
export const DELETE_SKETCH: Command = {
|
||||
id: 'arduino-delete-sketch',
|
||||
};
|
||||
}
|
||||
}
|
@@ -19,10 +19,11 @@ import {
|
||||
SketchContribution,
|
||||
CommandRegistry,
|
||||
MenuModelRegistry,
|
||||
URI,
|
||||
} from './contribution';
|
||||
import { NotificationCenter } from '../notification-center';
|
||||
import { Board, SketchRef, SketchContainer } from '../../common/protocol';
|
||||
import { nls } from '@theia/core/lib/common';
|
||||
import { nls } from '@theia/core/lib/common/nls';
|
||||
|
||||
@injectable()
|
||||
export abstract class Examples extends SketchContribution {
|
||||
@@ -150,10 +151,13 @@ export abstract class Examples extends SketchContribution {
|
||||
return {
|
||||
execute: async () => {
|
||||
const sketch = await this.sketchService.cloneExample(uri);
|
||||
return this.commandService.executeCommand(
|
||||
OpenSketch.Commands.OPEN_SKETCH.id,
|
||||
sketch
|
||||
);
|
||||
return this.commandService
|
||||
.executeCommand(OpenSketch.Commands.OPEN_SKETCH.id, sketch)
|
||||
.then((result) => {
|
||||
const name = new URI(uri).path.base;
|
||||
this.sketchService.markAsRecentlyOpened({ name, sourceUri: uri }); // no await
|
||||
return result;
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ import { MainMenuManager } from '../../common/main-menu-manager';
|
||||
import { OpenSketch } from './open-sketch';
|
||||
import { NotificationCenter } from '../notification-center';
|
||||
import { nls } from '@theia/core/lib/common';
|
||||
import { ExampleRef } from '../../common/protocol';
|
||||
|
||||
@injectable()
|
||||
export class OpenRecentSketch extends SketchContribution {
|
||||
@@ -55,26 +56,30 @@ export class OpenRecentSketch extends SketchContribution {
|
||||
);
|
||||
}
|
||||
|
||||
private refreshMenu(sketches: Sketch[]): void {
|
||||
private refreshMenu(sketches: (Sketch | ExampleRef)[]): void {
|
||||
this.register(sketches);
|
||||
this.mainMenuManager.update();
|
||||
}
|
||||
|
||||
protected register(sketches: Sketch[]): void {
|
||||
protected register(sketches: (Sketch | ExampleRef)[]): void {
|
||||
const order = 0;
|
||||
for (const sketch of sketches) {
|
||||
const { uri } = sketch;
|
||||
const uri = Sketch.is(sketch) ? sketch.uri : sketch.sourceUri;
|
||||
const toDispose = this.toDisposeBeforeRegister.get(uri);
|
||||
if (toDispose) {
|
||||
toDispose.dispose();
|
||||
}
|
||||
const command = { id: `arduino-open-recent--${uri}` };
|
||||
const handler = {
|
||||
execute: () =>
|
||||
execute: async () => {
|
||||
const toOpen = Sketch.is(sketch)
|
||||
? sketch
|
||||
: await this.sketchService.cloneExample(sketch.sourceUri);
|
||||
this.commandRegistry.executeCommand(
|
||||
OpenSketch.Commands.OPEN_SKETCH.id,
|
||||
sketch
|
||||
),
|
||||
toOpen
|
||||
);
|
||||
},
|
||||
};
|
||||
this.commandRegistry.registerCommand(command, handler);
|
||||
this.menuRegistry.registerMenuAction(
|
||||
@@ -86,7 +91,7 @@ export class OpenRecentSketch extends SketchContribution {
|
||||
}
|
||||
);
|
||||
this.toDisposeBeforeRegister.set(
|
||||
sketch.uri,
|
||||
uri,
|
||||
new DisposableCollection(
|
||||
Disposable.create(() =>
|
||||
this.commandRegistry.unregisterCommand(command)
|
||||
|
@@ -12,21 +12,19 @@ import {
|
||||
} from './contribution';
|
||||
import { nls } from '@theia/core/lib/common';
|
||||
import { ApplicationShell, NavigatableWidget, Saveable } from '@theia/core/lib/browser';
|
||||
import { EditorManager } from '@theia/editor/lib/browser';
|
||||
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
||||
import { CurrentSketch } from '../../common/protocol/sketches-service-client-impl';
|
||||
import { WorkspaceInput } from '@theia/workspace/lib/browser';
|
||||
import { StartupTask } from '../../electron-common/startup-task';
|
||||
import { DeleteSketch } from './delete-sketch';
|
||||
|
||||
@injectable()
|
||||
export class SaveAsSketch extends SketchContribution {
|
||||
|
||||
@inject(ApplicationShell)
|
||||
protected readonly applicationShell: ApplicationShell;
|
||||
|
||||
@inject(EditorManager)
|
||||
protected override readonly editorManager: EditorManager;
|
||||
private readonly applicationShell: ApplicationShell;
|
||||
|
||||
@inject(WindowService)
|
||||
protected readonly windowService: WindowService;
|
||||
private readonly windowService: WindowService;
|
||||
|
||||
override registerCommands(registry: CommandRegistry): void {
|
||||
registry.registerCommand(SaveAsSketch.Commands.SAVE_AS_SKETCH, {
|
||||
@@ -107,21 +105,19 @@ export class SaveAsSketch extends SketchContribution {
|
||||
this.sketchService.markAsRecentlyOpened(workspaceUri);
|
||||
}
|
||||
}
|
||||
const options: WorkspaceInput & StartupTask.Owner = {
|
||||
preserveWindow: true,
|
||||
tasks: [],
|
||||
};
|
||||
if (workspaceUri && openAfterMove) {
|
||||
this.windowService.setSafeToShutDown();
|
||||
if (wipeOriginal || (openAfterMove && execOnlyIfTemp)) {
|
||||
// This window will navigate away.
|
||||
// Explicitly stop the contribution to dispose the file watcher before deleting the temp sketch.
|
||||
// Otherwise, users might see irrelevant _Unable to watch for file changes in this large workspace._ notification.
|
||||
// https://github.com/arduino/arduino-ide/issues/39.
|
||||
this.sketchServiceClient.onStop();
|
||||
// TODO: consider implementing the temp sketch deletion the following way:
|
||||
// Open the other sketch with a `delete the temp sketch` startup-task.
|
||||
this.sketchService.notifyDeleteSketch(sketch); // This is a notification and will execute on the backend.
|
||||
options.tasks.push({
|
||||
command: DeleteSketch.Commands.DELETE_SKETCH.id,
|
||||
args: [sketch.uri],
|
||||
});
|
||||
}
|
||||
this.workspaceService.open(new URI(workspaceUri), {
|
||||
preserveWindow: true,
|
||||
});
|
||||
this.workspaceService.open(new URI(workspaceUri), options);
|
||||
}
|
||||
return !!workspaceUri;
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ import { inject, injectable } from '@theia/core/shared/inversify';
|
||||
import { FileSystemFrontendContribution } from '@theia/filesystem/lib/browser/filesystem-frontend-contribution';
|
||||
import { FileChangeType } from '@theia/filesystem/lib/common/files';
|
||||
import { CurrentSketch } from '../../common/protocol/sketches-service-client-impl';
|
||||
import { Sketch, SketchContribution, URI } from './contribution';
|
||||
import { Sketch, SketchContribution } from './contribution';
|
||||
import { OpenSketchFiles } from './open-sketch-files';
|
||||
|
||||
@injectable()
|
||||
@@ -31,7 +31,6 @@ export class SketchFilesTracker extends SketchContribution {
|
||||
override onReady(): void {
|
||||
this.sketchServiceClient.currentSketch().then(async (sketch) => {
|
||||
if (CurrentSketch.isValid(sketch)) {
|
||||
this.toDisposeOnStop.push(this.fileService.watch(new URI(sketch.uri)));
|
||||
this.toDisposeOnStop.push(
|
||||
this.fileService.onDidFilesChange(async (event) => {
|
||||
for (const { type, resource } of event.changes) {
|
||||
|
@@ -0,0 +1,52 @@
|
||||
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));
|
||||
}
|
||||
}
|
@@ -20,8 +20,7 @@ import {
|
||||
import { LocalStorageService } from '@theia/core/lib/browser';
|
||||
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
||||
|
||||
const DOWNLOAD_PAGE_URL =
|
||||
'https://www.arduino.cc/en/software#experimental-software';
|
||||
const DOWNLOAD_PAGE_URL = 'https://www.arduino.cc/en/software';
|
||||
|
||||
@injectable()
|
||||
export class IDEUpdaterDialogWidget extends ReactWidget {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import * as React from '@theia/core/shared/react';
|
||||
import { Key, KeyCode } from '@theia/core/lib/browser/keys';
|
||||
import { Board } from '../../../common/protocol/boards-service';
|
||||
import { isOSX } from '@theia/core/lib/common/os';
|
||||
import { DisposableCollection, nls } from '@theia/core/lib/common';
|
||||
import { BoardsServiceProvider } from '../../boards/boards-service-provider';
|
||||
import { MonitorModel } from '../../monitor-model';
|
||||
@@ -81,8 +80,7 @@ export class SerialMonitorSendInput extends React.Component<
|
||||
const port = this.props.boardsServiceProvider.boardsConfig.selectedPort;
|
||||
return nls.localize(
|
||||
'arduino/serial/message',
|
||||
"Message ({0} + Enter to send message to '{1}' on '{2}')",
|
||||
isOSX ? '⌘' : nls.localize('vscode/keybindingLabels/ctrlKey', 'Ctrl'),
|
||||
"Message (Enter to send message to '{0}' on '{1}')",
|
||||
board
|
||||
? Board.toString(board, {
|
||||
useFqbn: false,
|
||||
@@ -110,8 +108,8 @@ export class SerialMonitorSendInput extends React.Component<
|
||||
protected onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
const keyCode = KeyCode.createKeyCode(event.nativeEvent);
|
||||
if (keyCode) {
|
||||
const { key, meta, ctrl } = keyCode;
|
||||
if (key === Key.ENTER && ((isOSX && meta) || (!isOSX && ctrl))) {
|
||||
const { key } = keyCode;
|
||||
if (key === Key.ENTER) {
|
||||
this.onSend();
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,10 @@ import { MonitorManagerProxyClient } from '../../../common/protocol';
|
||||
import { BoardsServiceProvider } from '../../boards/boards-service-provider';
|
||||
import { MonitorModel } from '../../monitor-model';
|
||||
import { ArduinoToolbar } from '../../toolbar/arduino-toolbar';
|
||||
import {
|
||||
CLOSE_PLOTTER_WINDOW,
|
||||
SHOW_PLOTTER_WINDOW,
|
||||
} from '../../../common/ipc-communication';
|
||||
|
||||
const queryString = require('query-string');
|
||||
|
||||
@@ -58,7 +62,7 @@ export class PlotterFrontendContribution extends Contribution {
|
||||
override onStart(app: FrontendApplication): MaybePromise<void> {
|
||||
this.url = new Endpoint({ path: '/plotter' }).getRestUrl().toString();
|
||||
|
||||
ipcRenderer.on('CLOSE_CHILD_WINDOW', async () => {
|
||||
ipcRenderer.on(CLOSE_PLOTTER_WINDOW, async () => {
|
||||
if (!!this.window) {
|
||||
this.window = null;
|
||||
}
|
||||
@@ -96,7 +100,7 @@ export class PlotterFrontendContribution extends Contribution {
|
||||
async startPlotter(): Promise<void> {
|
||||
await this.monitorManagerProxy.startMonitor();
|
||||
if (!!this.window) {
|
||||
this.window.focus();
|
||||
ipcRenderer.send(SHOW_PLOTTER_WINDOW);
|
||||
return;
|
||||
}
|
||||
const wsPort = this.monitorManagerProxy.getWebSocketPort();
|
||||
|
@@ -1,26 +0,0 @@
|
||||
import { injectable } from '@theia/core/shared/inversify';
|
||||
import {
|
||||
BrowserMainMenuFactory as TheiaBrowserMainMenuFactory,
|
||||
MenuBarWidget,
|
||||
} from '@theia/core/lib/browser/menu/browser-menu-plugin';
|
||||
import { MainMenuManager } from '../../../common/main-menu-manager';
|
||||
|
||||
@injectable()
|
||||
export class BrowserMainMenuFactory
|
||||
extends TheiaBrowserMainMenuFactory
|
||||
implements MainMenuManager
|
||||
{
|
||||
protected menuBar: MenuBarWidget | undefined;
|
||||
|
||||
override createMenuBar(): MenuBarWidget {
|
||||
this.menuBar = super.createMenuBar();
|
||||
return this.menuBar;
|
||||
}
|
||||
|
||||
update(): void {
|
||||
if (this.menuBar) {
|
||||
this.menuBar.clearMenus();
|
||||
this.fillMenuBar(this.menuBar);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
import '../../../../src/browser/style/browser-menu.css';
|
||||
import { ContainerModule } from '@theia/core/shared/inversify';
|
||||
import {
|
||||
BrowserMenuBarContribution,
|
||||
BrowserMainMenuFactory as TheiaBrowserMainMenuFactory,
|
||||
} from '@theia/core/lib/browser/menu/browser-menu-plugin';
|
||||
import { MainMenuManager } from '../../../common/main-menu-manager';
|
||||
import { ArduinoMenuContribution } from './browser-menu-plugin';
|
||||
import { BrowserMainMenuFactory } from './browser-main-menu-factory';
|
||||
|
||||
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
||||
bind(BrowserMainMenuFactory).toSelf().inSingletonScope();
|
||||
bind(MainMenuManager).toService(BrowserMainMenuFactory);
|
||||
rebind(TheiaBrowserMainMenuFactory).toService(BrowserMainMenuFactory);
|
||||
rebind(BrowserMenuBarContribution)
|
||||
.to(ArduinoMenuContribution)
|
||||
.inSingletonScope();
|
||||
});
|
@@ -1,10 +0,0 @@
|
||||
import { DefaultWindowService as TheiaDefaultWindowService } from '@theia/core/lib/browser/window/default-window-service';
|
||||
import { ContainerModule } from '@theia/core/shared/inversify';
|
||||
import { DefaultWindowService } from './default-window-service';
|
||||
import { WindowServiceExt } from './window-service-ext';
|
||||
|
||||
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
||||
bind(DefaultWindowService).toSelf().inSingletonScope();
|
||||
rebind(TheiaDefaultWindowService).toService(DefaultWindowService);
|
||||
bind(WindowServiceExt).toService(DefaultWindowService);
|
||||
});
|
@@ -1,17 +0,0 @@
|
||||
import { DefaultWindowService as TheiaDefaultWindowService } from '@theia/core/lib/browser/window/default-window-service';
|
||||
import { injectable } from '@theia/core/shared/inversify';
|
||||
import { WindowServiceExt } from './window-service-ext';
|
||||
|
||||
@injectable()
|
||||
export class DefaultWindowService
|
||||
extends TheiaDefaultWindowService
|
||||
implements WindowServiceExt
|
||||
{
|
||||
/**
|
||||
* The default implementation always resolves to `true`.
|
||||
* IDE2 does not use it. It's currently an electron-only app.
|
||||
*/
|
||||
async isFirstWindow(): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -1,7 +1,10 @@
|
||||
import type { StartupTask } from '../../../electron-common/startup-task';
|
||||
|
||||
export const WindowServiceExt = Symbol('WindowServiceExt');
|
||||
export interface WindowServiceExt {
|
||||
/**
|
||||
* Returns with a promise that resolves to `true` if the current window is the first window.
|
||||
*/
|
||||
isFirstWindow(): Promise<boolean>;
|
||||
reload(options?: StartupTask.Owner): void;
|
||||
}
|
||||
|
@@ -1,54 +1,41 @@
|
||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
||||
import { injectable, inject } from '@theia/core/shared/inversify';
|
||||
import { injectable, inject, named } from '@theia/core/shared/inversify';
|
||||
import URI from '@theia/core/lib/common/uri';
|
||||
import { EditorWidget } from '@theia/editor/lib/browser';
|
||||
import { LabelProvider } from '@theia/core/lib/browser/label-provider';
|
||||
import { MessageService } from '@theia/core/lib/common/message-service';
|
||||
import { ApplicationServer } from '@theia/core/lib/common/application-protocol';
|
||||
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
|
||||
import { FocusTracker, Widget } from '@theia/core/lib/browser';
|
||||
import { DEFAULT_WINDOW_HASH } from '@theia/core/lib/common/window';
|
||||
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
||||
import {
|
||||
DEFAULT_WINDOW_HASH,
|
||||
NewWindowOptions,
|
||||
} from '@theia/core/lib/common/window';
|
||||
import {
|
||||
WorkspaceInput,
|
||||
WorkspaceService as TheiaWorkspaceService,
|
||||
} from '@theia/workspace/lib/browser/workspace-service';
|
||||
import { ConfigService } from '../../../common/protocol/config-service';
|
||||
import {
|
||||
SketchesService,
|
||||
Sketch,
|
||||
} from '../../../common/protocol/sketches-service';
|
||||
import { BoardsServiceProvider } from '../../boards/boards-service-provider';
|
||||
import { BoardsConfig } from '../../boards/boards-config';
|
||||
import { FileStat } from '@theia/filesystem/lib/common/files';
|
||||
import {
|
||||
StartupTask,
|
||||
StartupTasks,
|
||||
} from '../../widgets/sketchbook/startup-task';
|
||||
import { setURL } from '../../utils/window';
|
||||
StartupTaskProvider,
|
||||
} from '../../../electron-common/startup-task';
|
||||
import { WindowServiceExt } from '../core/window-service-ext';
|
||||
import { ContributionProvider } from '@theia/core/lib/common/contribution-provider';
|
||||
|
||||
@injectable()
|
||||
export class WorkspaceService extends TheiaWorkspaceService {
|
||||
@inject(SketchesService)
|
||||
protected readonly sketchService: SketchesService;
|
||||
|
||||
@inject(ConfigService)
|
||||
protected readonly configService: ConfigService;
|
||||
|
||||
@inject(LabelProvider)
|
||||
protected override readonly labelProvider: LabelProvider;
|
||||
|
||||
@inject(MessageService)
|
||||
protected override readonly messageService: MessageService;
|
||||
|
||||
private readonly sketchService: SketchesService;
|
||||
@inject(ApplicationServer)
|
||||
protected readonly applicationServer: ApplicationServer;
|
||||
|
||||
@inject(FrontendApplicationStateService)
|
||||
protected readonly appStateService: FrontendApplicationStateService;
|
||||
|
||||
@inject(BoardsServiceProvider)
|
||||
protected readonly boardsServiceProvider: BoardsServiceProvider;
|
||||
private readonly applicationServer: ApplicationServer;
|
||||
@inject(WindowServiceExt)
|
||||
private readonly windowServiceExt: WindowServiceExt;
|
||||
@inject(ContributionProvider)
|
||||
@named(StartupTaskProvider)
|
||||
private readonly providers: ContributionProvider<StartupTaskProvider>;
|
||||
|
||||
private version?: string;
|
||||
|
||||
@@ -156,27 +143,33 @@ export class WorkspaceService extends TheiaWorkspaceService {
|
||||
}
|
||||
|
||||
protected override reloadWindow(options?: WorkspaceInput): void {
|
||||
if (StartupTasks.WorkspaceInput.is(options)) {
|
||||
setURL(StartupTask.append(options.tasks, new URL(window.location.href)));
|
||||
}
|
||||
super.reloadWindow();
|
||||
const tasks = this.tasks(options);
|
||||
this.setURLFragment(this._workspace?.resource.path.toString() || '');
|
||||
this.windowServiceExt.reload({ tasks });
|
||||
}
|
||||
|
||||
protected override openNewWindow(
|
||||
workspacePath: string,
|
||||
options?: WorkspaceInput
|
||||
): void {
|
||||
const { boardsConfig } = this.boardsServiceProvider;
|
||||
let url = BoardsConfig.Config.setConfig(
|
||||
boardsConfig,
|
||||
new URL(window.location.href)
|
||||
); // Set the current boards config for the new browser window.
|
||||
url.hash = workspacePath;
|
||||
if (StartupTasks.WorkspaceInput.is(options)) {
|
||||
url = StartupTask.append(options.tasks, url);
|
||||
}
|
||||
const tasks = this.tasks(options);
|
||||
const url = new URL(window.location.href);
|
||||
url.hash = encodeURI(workspacePath);
|
||||
this.windowService.openNewWindow(
|
||||
url.toString(),
|
||||
Object.assign({} as NewWindowOptions, { tasks })
|
||||
);
|
||||
}
|
||||
|
||||
this.windowService.openNewWindow(url.toString());
|
||||
private tasks(options?: WorkspaceInput): StartupTask[] {
|
||||
const tasks = this.providers
|
||||
.getContributions()
|
||||
.map((contribution) => contribution.tasks())
|
||||
.reduce((prev, curr) => prev.concat(curr), []);
|
||||
if (StartupTask.has(options)) {
|
||||
tasks.push(...options.tasks);
|
||||
}
|
||||
return tasks;
|
||||
}
|
||||
|
||||
protected onCurrentWidgetChange({
|
||||
|
@@ -1,92 +0,0 @@
|
||||
import { injectable } from '@theia/core/shared/inversify';
|
||||
import { WorkspaceInput as TheiaWorkspaceInput } from '@theia/workspace/lib/browser';
|
||||
import { Contribution } from '../../contributions/contribution';
|
||||
import { setURL } from '../../utils/window';
|
||||
|
||||
@injectable()
|
||||
export class StartupTasks extends Contribution {
|
||||
override onReady(): void {
|
||||
const tasks = StartupTask.get(new URL(window.location.href));
|
||||
console.log(`Executing startup tasks: ${JSON.stringify(tasks)}`);
|
||||
tasks.forEach(({ command, 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
|
||||
)
|
||||
)
|
||||
);
|
||||
if (tasks.length) {
|
||||
// Remove the startup tasks after the execution.
|
||||
// Otherwise, IDE2 executes them again on a window reload event.
|
||||
setURL(StartupTask.set([], new URL(window.location.href)));
|
||||
console.info(`Removed startup tasks from URL.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface StartupTask {
|
||||
command: string;
|
||||
/**
|
||||
* Must be JSON serializable.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
args?: any[];
|
||||
}
|
||||
export namespace StartupTask {
|
||||
const QUERY = 'startupTasks';
|
||||
export function is(arg: unknown): arg is StartupTasks {
|
||||
if (typeof arg === 'object') {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const object = arg as any;
|
||||
return 'command' in object && typeof object['command'] === 'string';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export function get(url: URL): StartupTask[] {
|
||||
const { searchParams } = url;
|
||||
const encodedTasks = searchParams.get(QUERY);
|
||||
if (encodedTasks) {
|
||||
const rawTasks = decodeURIComponent(encodedTasks);
|
||||
const tasks = JSON.parse(rawTasks);
|
||||
if (Array.isArray(tasks)) {
|
||||
return tasks.filter((task) => {
|
||||
if (StartupTask.is(task)) {
|
||||
return true;
|
||||
}
|
||||
console.warn(`Was not a task: ${JSON.stringify(task)}. Ignoring.`);
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
debugger;
|
||||
console.warn(`Startup tasks was not an array: ${rawTasks}. Ignoring.`);
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
export function set(tasks: StartupTask[], url: URL): URL {
|
||||
const copy = new URL(url);
|
||||
copy.searchParams.set(QUERY, encodeURIComponent(JSON.stringify(tasks)));
|
||||
return copy;
|
||||
}
|
||||
export function append(tasks: StartupTask[], url: URL): URL {
|
||||
return set([...get(url), ...tasks], url);
|
||||
}
|
||||
}
|
||||
|
||||
export namespace StartupTasks {
|
||||
export interface WorkspaceInput extends TheiaWorkspaceInput {
|
||||
tasks: StartupTask[];
|
||||
}
|
||||
export namespace WorkspaceInput {
|
||||
export function is(
|
||||
input: (TheiaWorkspaceInput & Partial<WorkspaceInput>) | undefined
|
||||
): input is WorkspaceInput {
|
||||
return !!input && !!input.tasks;
|
||||
}
|
||||
}
|
||||
}
|
2
arduino-ide-extension/src/common/ipc-communication.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export const SHOW_PLOTTER_WINDOW = 'SHOW_PLOTTER_WINDOW';
|
||||
export const CLOSE_PLOTTER_WINDOW = 'CLOSE_PLOTTER_WINDOW';
|
@@ -5,6 +5,7 @@ import type {
|
||||
Config,
|
||||
ProgressMessage,
|
||||
Sketch,
|
||||
ExampleRef,
|
||||
} from '../protocol';
|
||||
import type { LibraryPackage } from './library-service';
|
||||
|
||||
@@ -27,7 +28,9 @@ export interface NotificationServiceClient {
|
||||
notifyLibraryDidInstall(event: { item: LibraryPackage }): void;
|
||||
notifyLibraryDidUninstall(event: { item: LibraryPackage }): void;
|
||||
notifyAttachedBoardsDidChange(event: AttachedBoardsChangeEvent): void;
|
||||
notifyRecentSketchesDidChange(event: { sketches: Sketch[] }): void;
|
||||
notifyRecentSketchesDidChange(event: {
|
||||
sketches: (Sketch | ExampleRef)[];
|
||||
}): void;
|
||||
}
|
||||
|
||||
export const NotificationServicePath = '/services/notification-service';
|
||||
|
@@ -165,15 +165,6 @@ export class SketchesServiceClientImpl
|
||||
.reachedState('started_contributions')
|
||||
.then(async () => {
|
||||
const currentSketch = await this.loadCurrentSketch();
|
||||
if (CurrentSketch.isValid(currentSketch)) {
|
||||
this.toDispose.pushAll([
|
||||
// Watch the file changes of the current sketch
|
||||
this.fileService.watch(new URI(currentSketch.uri), {
|
||||
recursive: true,
|
||||
excludes: [],
|
||||
}),
|
||||
]);
|
||||
}
|
||||
this.useCurrentSketch(currentSketch);
|
||||
});
|
||||
}
|
||||
|
@@ -78,12 +78,12 @@ export interface SketchesService {
|
||||
/**
|
||||
* Marks the sketch with the given URI as recently opened. It does nothing if the sketch is temp or not valid.
|
||||
*/
|
||||
markAsRecentlyOpened(uri: string): Promise<void>;
|
||||
markAsRecentlyOpened(uriOrRef: string | ExampleRef): Promise<void>;
|
||||
|
||||
/**
|
||||
* Resolves to an array of sketches in inverse chronological order. The newest is the first.
|
||||
*/
|
||||
recentlyOpenedSketches(): Promise<Sketch[]>;
|
||||
recentlyOpenedSketches(): Promise<(Sketch | ExampleRef)[]>;
|
||||
|
||||
/**
|
||||
* Archives the sketch, resolves to the archive URI.
|
||||
@@ -97,9 +97,30 @@ export interface SketchesService {
|
||||
getIdeTempFolderUri(sketch: Sketch): Promise<string>;
|
||||
|
||||
/**
|
||||
* Notifies the backend to recursively delete the sketch folder with all its content.
|
||||
* Recursively deletes the sketch folder with all its content.
|
||||
*/
|
||||
notifyDeleteSketch(sketch: Sketch): void;
|
||||
deleteSketch(sketch: Sketch): Promise<void>;
|
||||
}
|
||||
|
||||
export interface ExampleRef {
|
||||
/**
|
||||
* Name of the example.
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* This is the location where the example is. IDE2 will clone the sketch from this location.
|
||||
*/
|
||||
readonly sourceUri: string;
|
||||
}
|
||||
export namespace ExampleRef {
|
||||
export function is(arg: unknown): arg is ExampleRef {
|
||||
return (
|
||||
(arg as ExampleRef).name !== undefined &&
|
||||
typeof (arg as ExampleRef).name === 'string' &&
|
||||
(arg as ExampleRef).sourceUri !== undefined &&
|
||||
typeof (arg as ExampleRef).sourceUri === 'string'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export interface SketchRef {
|
||||
|
@@ -1,10 +1,14 @@
|
||||
import * as remote from '@theia/core/electron-shared/@electron/remote';
|
||||
import { ipcRenderer } from '@theia/core/electron-shared/electron';
|
||||
import {
|
||||
ConnectionStatus,
|
||||
ConnectionStatusService,
|
||||
} from '@theia/core/lib/browser/connection-status-service';
|
||||
import { nls } from '@theia/core/lib/common';
|
||||
import { Deferred } from '@theia/core/lib/common/promise-util';
|
||||
import { NewWindowOptions } from '@theia/core/lib/common/window';
|
||||
import { ElectronWindowService as TheiaElectronWindowService } from '@theia/core/lib/electron-browser/window/electron-window-service';
|
||||
import { RELOAD_REQUESTED_SIGNAL } from '@theia/core/lib/electron-common/messaging/electron-messages';
|
||||
import {
|
||||
inject,
|
||||
injectable,
|
||||
@@ -12,6 +16,7 @@ import {
|
||||
} from '@theia/core/shared/inversify';
|
||||
import { WindowServiceExt } from '../../../browser/theia/core/window-service-ext';
|
||||
import { ElectronMainWindowServiceExt } from '../../../electron-common/electron-main-window-service-ext';
|
||||
import { StartupTask } from '../../../electron-common/startup-task';
|
||||
|
||||
@injectable()
|
||||
export class ElectronWindowService
|
||||
@@ -60,14 +65,30 @@ export class ElectronWindowService
|
||||
return response === 0; // 'Yes', close the window.
|
||||
}
|
||||
|
||||
private _firstWindow: boolean | undefined;
|
||||
private _firstWindow: Deferred<boolean> | undefined;
|
||||
async isFirstWindow(): Promise<boolean> {
|
||||
if (this._firstWindow === undefined) {
|
||||
this._firstWindow = new Deferred<boolean>();
|
||||
const windowId = remote.getCurrentWindow().id; // This is expensive and synchronous so we check it once per FE.
|
||||
this._firstWindow = await this.mainWindowServiceExt.isFirstWindow(
|
||||
windowId
|
||||
);
|
||||
this.mainWindowServiceExt
|
||||
.isFirstWindow(windowId)
|
||||
.then((firstWindow) => this._firstWindow?.resolve(firstWindow));
|
||||
}
|
||||
return this._firstWindow.promise;
|
||||
}
|
||||
|
||||
// Overridden because the default Theia implementation destroys the additional properties of the `options` arg, such as `tasks`.
|
||||
override openNewWindow(url: string, options?: NewWindowOptions): undefined {
|
||||
return this.delegate.openNewWindow(url, options);
|
||||
}
|
||||
|
||||
// Overridden to support optional task owner params and make `tsc` happy.
|
||||
override reload(options?: StartupTask.Owner): void {
|
||||
if (options?.tasks && options.tasks.length) {
|
||||
const { tasks } = options;
|
||||
ipcRenderer.send(RELOAD_REQUESTED_SIGNAL, { tasks });
|
||||
} else {
|
||||
ipcRenderer.send(RELOAD_REQUESTED_SIGNAL);
|
||||
}
|
||||
return this._firstWindow;
|
||||
}
|
||||
}
|
||||
|
50
arduino-ide-extension/src/electron-common/startup-task.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
export interface StartupTask {
|
||||
command: string;
|
||||
/**
|
||||
* Must be JSON serializable.
|
||||
* See the restrictions [here](https://www.electronjs.org/docs/latest/api/web-contents#contentssendchannel-args).
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
args?: any[];
|
||||
}
|
||||
export namespace StartupTask {
|
||||
export function is(arg: unknown): arg is StartupTask {
|
||||
if (typeof arg === 'object') {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const object = arg as any;
|
||||
return (
|
||||
'command' in object &&
|
||||
typeof object['command'] === 'string' &&
|
||||
(!('args' in object) || Array.isArray(object['args']))
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export function has(arg: unknown): arg is unknown & Owner {
|
||||
if (typeof arg === 'object') {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const object = arg as any;
|
||||
return (
|
||||
'tasks' in object &&
|
||||
Array.isArray(object['tasks']) &&
|
||||
object['tasks'].every(is)
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export namespace Messaging {
|
||||
export const STARTUP_TASKS_SIGNAL = 'arduino/startupTasks';
|
||||
export function APP_READY_SIGNAL(id: number): string {
|
||||
return `arduino/appReady${id}`;
|
||||
}
|
||||
}
|
||||
|
||||
export interface Owner {
|
||||
readonly tasks: StartupTask[];
|
||||
}
|
||||
}
|
||||
|
||||
export const StartupTaskProvider = Symbol('StartupTaskProvider');
|
||||
export interface StartupTaskProvider {
|
||||
tasks(): StartupTask[];
|
||||
}
|
@@ -12,12 +12,8 @@ import {
|
||||
IDEUpdaterClient,
|
||||
IDEUpdaterPath,
|
||||
} from '../common/protocol/ide-updater';
|
||||
import {
|
||||
ElectronMainWindowServiceExt,
|
||||
electronMainWindowServiceExtPath,
|
||||
} from '../electron-common/electron-main-window-service-ext';
|
||||
import { electronMainWindowServiceExtPath } from '../electron-common/electron-main-window-service-ext';
|
||||
import { IsTempSketch } from '../node/is-temp-sketch';
|
||||
import { ElectronMainWindowServiceExtImpl } from './electron-main-window-service-ext-impl';
|
||||
import { IDEUpdaterImpl } from './ide-updater/ide-updater-impl';
|
||||
import { ElectronMainApplication } from './theia/electron-main-application';
|
||||
import { ElectronMainWindowServiceImpl } from './theia/electron-main-window-service';
|
||||
@@ -52,14 +48,11 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
||||
bind(TheiaElectronWindow).toSelf();
|
||||
rebind(DefaultTheiaElectronWindow).toService(TheiaElectronWindow);
|
||||
|
||||
bind(ElectronMainWindowServiceExt)
|
||||
.to(ElectronMainWindowServiceExtImpl)
|
||||
.inSingletonScope();
|
||||
bind(ElectronConnectionHandler)
|
||||
.toDynamicValue(
|
||||
(context) =>
|
||||
new JsonRpcConnectionHandler(electronMainWindowServiceExtPath, () =>
|
||||
context.container.get(ElectronMainWindowServiceExt)
|
||||
context.container.get(ElectronMainWindowServiceImpl)
|
||||
)
|
||||
)
|
||||
.inSingletonScope();
|
||||
|
@@ -1,15 +0,0 @@
|
||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||
import { ElectronMainWindowServiceExt } from '../electron-common/electron-main-window-service-ext';
|
||||
import { ElectronMainApplication } from './theia/electron-main-application';
|
||||
|
||||
@injectable()
|
||||
export class ElectronMainWindowServiceExtImpl
|
||||
implements ElectronMainWindowServiceExt
|
||||
{
|
||||
@inject(ElectronMainApplication)
|
||||
private readonly app: ElectronMainApplication;
|
||||
|
||||
async isFirstWindow(windowId: number): Promise<boolean> {
|
||||
return this.app.firstWindowId === windowId;
|
||||
}
|
||||
}
|
@@ -23,6 +23,10 @@ import * as os from '@theia/core/lib/common/os';
|
||||
import { Restart } from '@theia/core/lib/electron-common/messaging/electron-messages';
|
||||
import { TheiaBrowserWindowOptions } from '@theia/core/lib/electron-main/theia-electron-window';
|
||||
import { IsTempSketch } from '../../node/is-temp-sketch';
|
||||
import {
|
||||
CLOSE_PLOTTER_WINDOW,
|
||||
SHOW_PLOTTER_WINDOW,
|
||||
} from '../../common/ipc-communication';
|
||||
|
||||
app.commandLine.appendSwitch('disable-http-cache');
|
||||
|
||||
@@ -324,15 +328,21 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
|
||||
webPreferences: {
|
||||
devTools: true,
|
||||
nativeWindowOpen: true,
|
||||
openerId: electronWindow?.webContents.id,
|
||||
openerId: electronWindow.webContents.id,
|
||||
},
|
||||
});
|
||||
event.newGuest = new BrowserWindow(options);
|
||||
|
||||
const showPlotterWindow = () => {
|
||||
event.newGuest?.show();
|
||||
};
|
||||
ipcMain.on(SHOW_PLOTTER_WINDOW, showPlotterWindow);
|
||||
event.newGuest.setMenu(null);
|
||||
event.newGuest?.on('closed', () => {
|
||||
electronWindow?.webContents.send('CLOSE_CHILD_WINDOW');
|
||||
event.newGuest.on('closed', () => {
|
||||
ipcMain.removeListener(SHOW_PLOTTER_WINDOW, showPlotterWindow);
|
||||
electronWindow.webContents.send(CLOSE_PLOTTER_WINDOW);
|
||||
});
|
||||
event.newGuest?.loadURL(url);
|
||||
event.newGuest.loadURL(url);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@@ -1,34 +1,63 @@
|
||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||
import type { NewWindowOptions } from '@theia/core/lib/common/window';
|
||||
import type { BrowserWindow } from '@theia/core/electron-shared/electron';
|
||||
import { ElectronMainWindowServiceImpl as TheiaElectronMainWindowService } from '@theia/core/lib/electron-main/electron-main-window-service-impl';
|
||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||
import { ElectronMainWindowServiceExt } from '../../electron-common/electron-main-window-service-ext';
|
||||
import { StartupTask } from '../../electron-common/startup-task';
|
||||
import { ElectronMainApplication } from './electron-main-application';
|
||||
import { NewWindowOptions } from '@theia/core/lib/common/window';
|
||||
import { load } from './window';
|
||||
|
||||
@injectable()
|
||||
export class ElectronMainWindowServiceImpl extends TheiaElectronMainWindowService {
|
||||
export class ElectronMainWindowServiceImpl
|
||||
extends TheiaElectronMainWindowService
|
||||
implements ElectronMainWindowServiceExt
|
||||
{
|
||||
@inject(ElectronMainApplication)
|
||||
protected override readonly app: ElectronMainApplication;
|
||||
|
||||
override openNewWindow(url: string, { external }: NewWindowOptions): undefined {
|
||||
if (!external) {
|
||||
const sanitizedUrl = this.sanitize(url);
|
||||
const existing = this.app.browserWindows.find(
|
||||
(window) => this.sanitize(window.webContents.getURL()) === sanitizedUrl
|
||||
);
|
||||
if (existing) {
|
||||
existing.focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
return super.openNewWindow(url, { external });
|
||||
async isFirstWindow(windowId: number): Promise<boolean> {
|
||||
return this.app.firstWindowId === windowId;
|
||||
}
|
||||
|
||||
private sanitize(url: string): string {
|
||||
const copy = new URL(url);
|
||||
const searchParams: string[] = [];
|
||||
copy.searchParams.forEach((_, key) => searchParams.push(key));
|
||||
for (const param of searchParams) {
|
||||
copy.searchParams.delete(param);
|
||||
override openNewWindow(url: string, options: NewWindowOptions): undefined {
|
||||
// External window has highest precedence.
|
||||
if (options?.external) {
|
||||
return super.openNewWindow(url, options);
|
||||
}
|
||||
return copy.toString();
|
||||
|
||||
// Look for existing window with the same URL and focus it.
|
||||
const existing = this.app.browserWindows.find(
|
||||
({ webContents }) => webContents.getURL() === url
|
||||
);
|
||||
if (existing) {
|
||||
existing.focus();
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Create new window and share the startup tasks.
|
||||
if (StartupTask.has(options)) {
|
||||
const { tasks } = options;
|
||||
this.app.createWindow().then((electronWindow) => {
|
||||
this.loadURL(electronWindow, url).then(() => {
|
||||
electronWindow.webContents.send(
|
||||
StartupTask.Messaging.STARTUP_TASKS_SIGNAL,
|
||||
{ tasks }
|
||||
);
|
||||
});
|
||||
});
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Default.
|
||||
return super.openNewWindow(url, options);
|
||||
}
|
||||
|
||||
private loadURL(
|
||||
electronWindow: BrowserWindow,
|
||||
url: string
|
||||
): Promise<BrowserWindow> {
|
||||
return load(electronWindow, (electronWindow) =>
|
||||
electronWindow.loadURL(url)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,15 @@
|
||||
import { injectable } from '@theia/core/shared/inversify';
|
||||
import { ipcMain, IpcMainEvent } from '@theia/electron/shared/electron';
|
||||
import { StopReason } from '@theia/core/lib/electron-common/messaging/electron-messages';
|
||||
import {
|
||||
RELOAD_REQUESTED_SIGNAL,
|
||||
StopReason,
|
||||
} from '@theia/core/lib/electron-common/messaging/electron-messages';
|
||||
import { TheiaElectronWindow as DefaultTheiaElectronWindow } from '@theia/core/lib/electron-main/theia-electron-window';
|
||||
import { FileUri } from '@theia/core/lib/node';
|
||||
import URI from '@theia/core/lib/common/uri';
|
||||
import { FrontendApplicationState } from '@theia/core/lib/common/frontend-application-state';
|
||||
import { createDisposableListener } from '@theia/core/lib/electron-main/event-utils';
|
||||
import { APPLICATION_STATE_CHANGE_SIGNAL } from '@theia/core/lib/electron-common/messaging/electron-messages';
|
||||
import { StartupTask } from '../../electron-common/startup-task';
|
||||
import { load } from './window';
|
||||
|
||||
@injectable()
|
||||
export class TheiaElectronWindow extends DefaultTheiaElectronWindow {
|
||||
@@ -38,30 +41,42 @@ export class TheiaElectronWindow extends DefaultTheiaElectronWindow {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Note: does the same as the Theia impl, but logs state changes.
|
||||
protected override trackApplicationState(): void {
|
||||
protected override reload(tasks?: StartupTask[]): void {
|
||||
this.handleStopRequest(() => {
|
||||
this.applicationState = 'init';
|
||||
if (tasks && tasks.length) {
|
||||
load(this._window, (electronWindow) => electronWindow.reload()).then(
|
||||
(electronWindow) =>
|
||||
electronWindow.webContents.send(
|
||||
StartupTask.Messaging.STARTUP_TASKS_SIGNAL,
|
||||
{ tasks }
|
||||
)
|
||||
);
|
||||
} else {
|
||||
this._window.reload();
|
||||
}
|
||||
}, StopReason.Reload);
|
||||
}
|
||||
|
||||
protected override attachReloadListener(): void {
|
||||
createDisposableListener(
|
||||
ipcMain,
|
||||
APPLICATION_STATE_CHANGE_SIGNAL,
|
||||
(e: IpcMainEvent, state: FrontendApplicationState) => {
|
||||
console.log(
|
||||
'app-state-change',
|
||||
`>>> new app state <${state} was received from sender <${e.sender.id}>. current window ID: ${this._window.id}`
|
||||
);
|
||||
RELOAD_REQUESTED_SIGNAL,
|
||||
(e: IpcMainEvent, arg: unknown) => {
|
||||
if (this.isSender(e)) {
|
||||
this.applicationState = state;
|
||||
console.log(
|
||||
'app-state-change',
|
||||
`<<< new app state is <${this.applicationState}> for window <${this._window.id}>`
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
'app-state-change',
|
||||
`<<< new app state <${state}> is ignored from <${e.sender.id}>. current window ID is <${this._window.id}>`
|
||||
);
|
||||
if (StartupTask.has(arg)) {
|
||||
this.reload(arg.tasks);
|
||||
} else {
|
||||
this.reload();
|
||||
}
|
||||
}
|
||||
},
|
||||
this.toDispose
|
||||
);
|
||||
}
|
||||
|
||||
// https://github.com/eclipse-theia/theia/issues/11600#issuecomment-1240657481
|
||||
protected override isSender(e: IpcMainEvent): boolean {
|
||||
return e.sender.id === this._window.webContents.id;
|
||||
}
|
||||
}
|
||||
|
33
arduino-ide-extension/src/electron-main/theia/window.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { MaybePromise } from '@theia/core';
|
||||
import type { IpcMainEvent } from '@theia/core/electron-shared/electron';
|
||||
import { BrowserWindow, ipcMain } from '@theia/core/electron-shared/electron';
|
||||
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
||||
import { createDisposableListener } from '@theia/core/lib/electron-main/event-utils';
|
||||
import { StartupTask } from '../../electron-common/startup-task';
|
||||
|
||||
/**
|
||||
* Should be used to load (URL) or reload a window. The returning promise will resolve
|
||||
* when the app is ready to receive startup tasks.
|
||||
*/
|
||||
export async function load(
|
||||
electronWindow: BrowserWindow,
|
||||
doLoad: (electronWindow: BrowserWindow) => MaybePromise<void>
|
||||
): Promise<BrowserWindow> {
|
||||
const { id } = electronWindow;
|
||||
const toDispose = new DisposableCollection();
|
||||
const channel = StartupTask.Messaging.APP_READY_SIGNAL(id);
|
||||
return new Promise<BrowserWindow>((resolve, reject) => {
|
||||
toDispose.push(
|
||||
createDisposableListener(
|
||||
ipcMain,
|
||||
channel,
|
||||
({ sender: webContents }: IpcMainEvent) => {
|
||||
if (webContents.id === electronWindow.webContents.id) {
|
||||
resolve(electronWindow);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
Promise.resolve(doLoad(electronWindow)).catch(reject);
|
||||
}).finally(() => toDispose.dispose());
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
import { ContainerModule } from '@theia/core/shared/inversify';
|
||||
import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
|
||||
import { ArduinoDaemonImpl } from './arduino-daemon-impl';
|
||||
import {
|
||||
ArduinoFirmwareUploader,
|
||||
@@ -110,6 +110,7 @@ import {
|
||||
SurveyNotificationServicePath,
|
||||
} from '../common/protocol/survey-service';
|
||||
import { IsTempSketch } from './is-temp-sketch';
|
||||
import { rebindNsfwFileSystemWatcher } from './theia/filesystem/nsfw-watcher/nsfw-bindings';
|
||||
|
||||
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
||||
bind(BackendApplication).toSelf().inSingletonScope();
|
||||
@@ -288,6 +289,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
||||
)
|
||||
)
|
||||
.inSingletonScope();
|
||||
rebindNsfwFileSystemWatcher(rebind);
|
||||
|
||||
// Output service per connection.
|
||||
bind(ConnectionContainerModule).toConstantValue(
|
||||
@@ -325,58 +327,14 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
||||
})
|
||||
);
|
||||
|
||||
// Logger for the Arduino daemon
|
||||
bind(ILogger)
|
||||
.toDynamicValue((ctx) => {
|
||||
const parentLogger = ctx.container.get<ILogger>(ILogger);
|
||||
return parentLogger.child('daemon');
|
||||
})
|
||||
.inSingletonScope()
|
||||
.whenTargetNamed('daemon');
|
||||
|
||||
// Logger for the Arduino daemon
|
||||
bind(ILogger)
|
||||
.toDynamicValue((ctx) => {
|
||||
const parentLogger = ctx.container.get<ILogger>(ILogger);
|
||||
return parentLogger.child('fwuploader');
|
||||
})
|
||||
.inSingletonScope()
|
||||
.whenTargetNamed('fwuploader');
|
||||
|
||||
// Logger for the "serial discovery".
|
||||
bind(ILogger)
|
||||
.toDynamicValue((ctx) => {
|
||||
const parentLogger = ctx.container.get<ILogger>(ILogger);
|
||||
return parentLogger.child('discovery-log'); // TODO: revert
|
||||
})
|
||||
.inSingletonScope()
|
||||
.whenTargetNamed('discovery-log'); // TODO: revert
|
||||
|
||||
// Logger for the CLI config service. From the CLI config (FS path aware), we make a URI-aware app config.
|
||||
bind(ILogger)
|
||||
.toDynamicValue((ctx) => {
|
||||
const parentLogger = ctx.container.get<ILogger>(ILogger);
|
||||
return parentLogger.child('config');
|
||||
})
|
||||
.inSingletonScope()
|
||||
.whenTargetNamed('config');
|
||||
|
||||
// Logger for the monitor manager and its services
|
||||
bind(ILogger)
|
||||
.toDynamicValue((ctx) => {
|
||||
const parentLogger = ctx.container.get<ILogger>(ILogger);
|
||||
return parentLogger.child(MonitorManagerName);
|
||||
})
|
||||
.inSingletonScope()
|
||||
.whenTargetNamed(MonitorManagerName);
|
||||
|
||||
bind(ILogger)
|
||||
.toDynamicValue((ctx) => {
|
||||
const parentLogger = ctx.container.get<ILogger>(ILogger);
|
||||
return parentLogger.child(MonitorServiceName);
|
||||
})
|
||||
.inSingletonScope()
|
||||
.whenTargetNamed(MonitorServiceName);
|
||||
[
|
||||
'daemon', // Logger for the Arduino daemon
|
||||
'fwuploader', // Arduino Firmware uploader
|
||||
'discovery-log', // Boards discovery
|
||||
'config', // Logger for the CLI config reading and manipulation
|
||||
MonitorManagerName, // Logger for the monitor manager and its services
|
||||
MonitorServiceName,
|
||||
].forEach((name) => bindChildLogger(bind, name));
|
||||
|
||||
// Remote sketchbook bindings
|
||||
bind(AuthenticationServiceImpl).toSelf().inSingletonScope();
|
||||
@@ -423,3 +381,12 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
||||
|
||||
bind(IsTempSketch).toSelf().inSingletonScope();
|
||||
});
|
||||
|
||||
function bindChildLogger(bind: interfaces.Bind, name: string): void {
|
||||
bind(ILogger)
|
||||
.toDynamicValue(({ container }) =>
|
||||
container.get<ILogger>(ILogger).child(name)
|
||||
)
|
||||
.inSingletonScope()
|
||||
.whenTargetNamed(name);
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ import type {
|
||||
Config,
|
||||
Sketch,
|
||||
ProgressMessage,
|
||||
ExampleRef,
|
||||
} from '../common/protocol';
|
||||
|
||||
@injectable()
|
||||
@@ -76,7 +77,9 @@ export class NotificationServiceServerImpl
|
||||
this.clients.forEach((client) => client.notifyConfigDidChange(event));
|
||||
}
|
||||
|
||||
notifyRecentSketchesDidChange(event: { sketches: Sketch[] }): void {
|
||||
notifyRecentSketchesDidChange(event: {
|
||||
sketches: (Sketch | ExampleRef)[];
|
||||
}): void {
|
||||
this.clients.forEach((client) =>
|
||||
client.notifyRecentSketchesDidChange(event)
|
||||
);
|
||||
|
@@ -16,6 +16,7 @@ import {
|
||||
SketchRef,
|
||||
SketchContainer,
|
||||
SketchesError,
|
||||
ExampleRef,
|
||||
} from '../common/protocol/sketches-service';
|
||||
import { NotificationServiceServerImpl } from './notification-service-server';
|
||||
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
|
||||
@@ -257,9 +258,7 @@ export class SketchesServiceImpl
|
||||
.then((uri) => path.join(FileUri.fsPath(uri), 'recent-sketches.json'));
|
||||
}
|
||||
|
||||
private async loadRecentSketches(
|
||||
fsPath: string
|
||||
): Promise<Record<string, number>> {
|
||||
private async loadRecentSketches(fsPath: string): Promise<RecentSketches> {
|
||||
let data: Record<string, number> = {};
|
||||
try {
|
||||
const raw = await promisify(fs.readFile)(fsPath, {
|
||||
@@ -270,7 +269,9 @@ export class SketchesServiceImpl
|
||||
return data;
|
||||
}
|
||||
|
||||
async markAsRecentlyOpened(uri: string): Promise<void> {
|
||||
async markAsRecentlyOpened(uriOrRef: string | ExampleRef): Promise<void> {
|
||||
const isExample = typeof uriOrRef !== 'string';
|
||||
const uri = isExample ? uriOrRef.sourceUri : uriOrRef;
|
||||
let sketch: Sketch | undefined = undefined;
|
||||
try {
|
||||
sketch = await this.loadSketch(uri);
|
||||
@@ -284,15 +285,23 @@ export class SketchesServiceImpl
|
||||
const fsPath = await this.recentSketchesFsPath;
|
||||
const data = await this.loadRecentSketches(fsPath);
|
||||
const now = Date.now();
|
||||
data[sketch.uri] = now;
|
||||
data[sketch.uri] = isExample ? { type: 'example', mtimeMs: now } : now;
|
||||
|
||||
let toDeleteUri: string | undefined = undefined;
|
||||
if (Object.keys(data).length > 10) {
|
||||
let min = Number.MAX_SAFE_INTEGER;
|
||||
for (const uri of Object.keys(data)) {
|
||||
if (min > data[uri]) {
|
||||
min = data[uri];
|
||||
toDeleteUri = uri;
|
||||
const value = data[uri];
|
||||
if (typeof value === 'number') {
|
||||
if (min > value) {
|
||||
min = value;
|
||||
toDeleteUri = uri;
|
||||
}
|
||||
} else {
|
||||
if (min > value.mtimeMs) {
|
||||
min = value.mtimeMs;
|
||||
toDeleteUri = uri;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,13 +316,13 @@ export class SketchesServiceImpl
|
||||
);
|
||||
}
|
||||
|
||||
async recentlyOpenedSketches(): Promise<Sketch[]> {
|
||||
async recentlyOpenedSketches(): Promise<(Sketch | ExampleRef)[]> {
|
||||
const configDirUri = await this.envVariableServer.getConfigDirUri();
|
||||
const fsPath = path.join(
|
||||
FileUri.fsPath(configDirUri),
|
||||
'recent-sketches.json'
|
||||
);
|
||||
let data: Record<string, number> = {};
|
||||
let data: RecentSketches = {};
|
||||
try {
|
||||
const raw = await promisify(fs.readFile)(fsPath, {
|
||||
encoding: 'utf8',
|
||||
@@ -321,14 +330,25 @@ export class SketchesServiceImpl
|
||||
data = JSON.parse(raw);
|
||||
} catch {}
|
||||
|
||||
const sketches: SketchWithDetails[] = [];
|
||||
for (const uri of Object.keys(data).sort(
|
||||
(left, right) => data[right] - data[left]
|
||||
)) {
|
||||
try {
|
||||
const sketch = await this.loadSketch(uri);
|
||||
sketches.push(sketch);
|
||||
} catch {}
|
||||
const sketches: (Sketch | ExampleRef)[] = [];
|
||||
for (const uri of Object.keys(data).sort((left, right) => {
|
||||
const leftValue = data[left];
|
||||
const rightValue = data[right];
|
||||
const leftMtimeMs =
|
||||
typeof leftValue === 'number' ? leftValue : leftValue.mtimeMs;
|
||||
const rightMtimeMs =
|
||||
typeof rightValue === 'number' ? rightValue : rightValue.mtimeMs;
|
||||
return leftMtimeMs - rightMtimeMs;
|
||||
})) {
|
||||
const value = data[uri];
|
||||
if (typeof value === 'number') {
|
||||
try {
|
||||
const sketch = await this.loadSketch(uri);
|
||||
sketches.push(sketch);
|
||||
} catch {}
|
||||
} else {
|
||||
sketches.push({ name: new URI(uri).path.base, sourceUri: uri });
|
||||
}
|
||||
}
|
||||
|
||||
return sketches;
|
||||
@@ -417,9 +437,9 @@ void loop() {
|
||||
* For example, on Windows, instead of getting an [8.3 filename](https://en.wikipedia.org/wiki/8.3_filename), callers will get a fully resolved path.
|
||||
* `C:\\Users\\KITTAA~1\\AppData\\Local\\Temp\\.arduinoIDE-unsaved2022615-21100-iahybb.yyvh\\sketch_jul15a` will be `C:\\Users\\kittaakos\\AppData\\Local\\Temp\\.arduinoIDE-unsaved2022615-21100-iahybb.yyvh\\sketch_jul15a`
|
||||
*/
|
||||
private createTempFolder(): Promise<string> {
|
||||
private createTempFolder(prefix: string = TempSketchPrefix): Promise<string> {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
temp.mkdir({ prefix: TempSketchPrefix }, (createError, dirPath) => {
|
||||
temp.mkdir({ prefix }, (createError, dirPath) => {
|
||||
if (createError) {
|
||||
reject(createError);
|
||||
return;
|
||||
@@ -561,14 +581,18 @@ void loop() {
|
||||
return path.join(os.tmpdir(), `arduino-ide2-${suffix}`);
|
||||
}
|
||||
|
||||
notifyDeleteSketch(sketch: Sketch): void {
|
||||
const sketchPath = FileUri.fsPath(sketch.uri);
|
||||
fs.rm(sketchPath, { recursive: true, maxRetries: 5 }, (error) => {
|
||||
if (error) {
|
||||
console.error(`Failed to delete sketch at ${sketchPath}.`, error);
|
||||
} else {
|
||||
console.error(`Successfully delete sketch at ${sketchPath}.`);
|
||||
}
|
||||
async deleteSketch(sketch: Sketch): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const sketchPath = FileUri.fsPath(sketch.uri);
|
||||
fs.rm(sketchPath, { recursive: true, maxRetries: 5 }, (error) => {
|
||||
if (error) {
|
||||
console.error(`Failed to delete sketch at ${sketchPath}.`, error);
|
||||
reject(error);
|
||||
} else {
|
||||
console.log(`Successfully deleted sketch at ${sketchPath}.`);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -630,3 +654,8 @@ function sketchIndexToLetters(num: number): string {
|
||||
} while (pow > 0);
|
||||
return out;
|
||||
}
|
||||
|
||||
type RecentSketches = Record<
|
||||
string,
|
||||
number | { type: 'example'; mtimeMs: number }
|
||||
>;
|
||||
|
@@ -0,0 +1,31 @@
|
||||
import * as yargs from '@theia/core/shared/yargs';
|
||||
import { JsonRpcProxyFactory } from '@theia/core';
|
||||
import { NoDelayDisposalTimeoutNsfwFileSystemWatcherService } from './nsfw-filesystem-service';
|
||||
import type { IPCEntryPoint } from '@theia/core/lib/node/messaging/ipc-protocol';
|
||||
import type { FileSystemWatcherServiceClient } from '@theia/filesystem/lib/common/filesystem-watcher-protocol';
|
||||
|
||||
const options: {
|
||||
verbose: boolean;
|
||||
} = yargs
|
||||
.option('verbose', {
|
||||
default: false,
|
||||
alias: 'v',
|
||||
type: 'boolean',
|
||||
})
|
||||
.option('nsfwOptions', {
|
||||
alias: 'o',
|
||||
type: 'string',
|
||||
coerce: JSON.parse,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
}).argv as any;
|
||||
|
||||
export default <IPCEntryPoint>((connection) => {
|
||||
const server = new NoDelayDisposalTimeoutNsfwFileSystemWatcherService(
|
||||
options
|
||||
);
|
||||
const factory = new JsonRpcProxyFactory<FileSystemWatcherServiceClient>(
|
||||
server
|
||||
);
|
||||
server.setClient(factory.createProxy());
|
||||
factory.listen(connection);
|
||||
});
|
@@ -0,0 +1,42 @@
|
||||
import { join } from 'path';
|
||||
import { interfaces } from '@theia/core/shared/inversify';
|
||||
import {
|
||||
NsfwFileSystemWatcherServiceProcessOptions,
|
||||
NSFW_SINGLE_THREADED,
|
||||
spawnNsfwFileSystemWatcherServiceProcess,
|
||||
} from '@theia/filesystem/lib/node/filesystem-backend-module';
|
||||
import { FileSystemWatcherService } from '@theia/filesystem/lib/common/filesystem-watcher-protocol';
|
||||
import { NsfwFileSystemWatcherServerOptions } from '@theia/filesystem/lib/node/nsfw-watcher/nsfw-filesystem-service';
|
||||
import { FileSystemWatcherServiceDispatcher } from '@theia/filesystem/lib/node/filesystem-watcher-dispatcher';
|
||||
import { NoDelayDisposalTimeoutNsfwFileSystemWatcherService } from './nsfw-filesystem-service';
|
||||
|
||||
export function rebindNsfwFileSystemWatcher(rebind: interfaces.Rebind): void {
|
||||
rebind<NsfwFileSystemWatcherServiceProcessOptions>(
|
||||
NsfwFileSystemWatcherServiceProcessOptions
|
||||
).toConstantValue({
|
||||
entryPoint: join(__dirname, 'index.js'),
|
||||
});
|
||||
rebind<FileSystemWatcherService>(FileSystemWatcherService)
|
||||
.toDynamicValue((context) =>
|
||||
NSFW_SINGLE_THREADED
|
||||
? createNsfwFileSystemWatcherService(context)
|
||||
: spawnNsfwFileSystemWatcherServiceProcess(context)
|
||||
)
|
||||
.inSingletonScope();
|
||||
}
|
||||
|
||||
function createNsfwFileSystemWatcherService({
|
||||
container,
|
||||
}: interfaces.Context): FileSystemWatcherService {
|
||||
const options = container.get<NsfwFileSystemWatcherServerOptions>(
|
||||
NsfwFileSystemWatcherServerOptions
|
||||
);
|
||||
const dispatcher = container.get<FileSystemWatcherServiceDispatcher>(
|
||||
FileSystemWatcherServiceDispatcher
|
||||
);
|
||||
const server = new NoDelayDisposalTimeoutNsfwFileSystemWatcherService(
|
||||
options
|
||||
);
|
||||
server.setClient(dispatcher);
|
||||
return server;
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
import { Minimatch } from 'minimatch';
|
||||
import type { WatchOptions } from '@theia/filesystem/lib/common/filesystem-watcher-protocol';
|
||||
import {
|
||||
NsfwFileSystemWatcherService,
|
||||
NsfwWatcher,
|
||||
} from '@theia/filesystem/lib/node/nsfw-watcher/nsfw-filesystem-service';
|
||||
|
||||
// Dispose the watcher immediately when the last reference is removed. By default, Theia waits 10 sec.
|
||||
// https://github.com/eclipse-theia/theia/issues/11639#issuecomment-1238980708
|
||||
const NoDelay = 0;
|
||||
|
||||
export class NoDelayDisposalTimeoutNsfwFileSystemWatcherService extends NsfwFileSystemWatcherService {
|
||||
protected override createWatcher(
|
||||
clientId: number,
|
||||
fsPath: string,
|
||||
options: WatchOptions
|
||||
): NsfwWatcher {
|
||||
const watcherOptions = {
|
||||
ignored: options.ignored.map(
|
||||
(pattern) => new Minimatch(pattern, { dot: true })
|
||||
),
|
||||
};
|
||||
return new NsfwWatcher(
|
||||
clientId,
|
||||
fsPath,
|
||||
watcherOptions,
|
||||
this.options,
|
||||
this.maybeClient,
|
||||
NoDelay
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,62 +0,0 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "browser-app",
|
||||
"version": "2.0.0",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@theia/core": "1.25.0",
|
||||
"@theia/debug": "1.25.0",
|
||||
"@theia/editor": "1.25.0",
|
||||
"@theia/file-search": "1.25.0",
|
||||
"@theia/filesystem": "1.25.0",
|
||||
"@theia/keymaps": "1.25.0",
|
||||
"@theia/messages": "1.25.0",
|
||||
"@theia/monaco": "1.25.0",
|
||||
"@theia/navigator": "1.25.0",
|
||||
"@theia/plugin-ext": "1.25.0",
|
||||
"@theia/plugin-ext-vscode": "1.25.0",
|
||||
"@theia/preferences": "1.25.0",
|
||||
"@theia/process": "1.25.0",
|
||||
"@theia/terminal": "1.25.0",
|
||||
"@theia/workspace": "1.25.0",
|
||||
"arduino-ide-extension": "2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@theia/cli": "1.25.0"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "theia build --mode development",
|
||||
"start": "theia start --plugins=local-dir:../plugins",
|
||||
"watch": "theia build --watch --mode development"
|
||||
},
|
||||
"theia": {
|
||||
"frontend": {
|
||||
"config": {
|
||||
"applicationName": "Arduino IDE",
|
||||
"defaultTheme": "arduino-theme",
|
||||
"preferences": {
|
||||
"files.autoSave": "afterDelay",
|
||||
"editor.minimap.enabled": false,
|
||||
"editor.tabSize": 2,
|
||||
"editor.scrollBeyondLastLine": false,
|
||||
"editor.quickSuggestions": {
|
||||
"other": false,
|
||||
"comments": false,
|
||||
"strings": false
|
||||
},
|
||||
"breadcrumbs.enabled": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"backend": {
|
||||
"config": {
|
||||
"configDirName": ".arduinoIDE"
|
||||
}
|
||||
},
|
||||
"generator": {
|
||||
"config": {
|
||||
"preloadTemplate": "<div class='theia-preload' style='background-color: rgb(237, 241, 242);'></div>"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
/**
|
||||
* This file can be edited to customize webpack configuration.
|
||||
* To reset delete this file and rerun theia build again.
|
||||
*/
|
||||
// @ts-check
|
||||
const config = require('./gen-webpack.config.js');
|
||||
|
||||
config.resolve.fallback['http'] = false;
|
||||
config.resolve.fallback['fs'] = false;
|
||||
|
||||
/**
|
||||
* Expose bundled modules on window.theia.moduleName namespace, e.g.
|
||||
* window['theia']['@theia/core/lib/common/uri'].
|
||||
* Such syntax can be used by external code, for instance, for testing.
|
||||
config.module.rules.push({
|
||||
test: /\.js$/,
|
||||
loader: require.resolve('@theia/application-manager/lib/expose-loader')
|
||||
}); */
|
||||
|
||||
module.exports = config;
|
29
docs/CONTRIBUTING.md
Normal file
@@ -0,0 +1,29 @@
|
||||
<!-- Source: https://github.com/arduino/tooling-project-assets/blob/main/documentation-templates/contributor-guide/general/CONTRIBUTING.md -->
|
||||
|
||||
# Contributor Guide
|
||||
|
||||
Thanks for your interest in contributing to this project!
|
||||
|
||||
There are several ways you can get involved:
|
||||
|
||||
| Type of contribution | Contribution method |
|
||||
| ----------------------------------------- | -------------------------------------------------------------------------------- |
|
||||
| - Support<br/>- Question<br/>- Discussion | Post on the [**Arduino Forum**][forum] |
|
||||
| - Bug report<br/>- Feature request | Issue report (see the guide [**here**][issues]) |
|
||||
| Testing | Beta testing, PR review (see the guide [**here**][beta-testing]) |
|
||||
| Translation | [Transifex project][translate] |
|
||||
| - Bug fix<br/>- Enhancement | Pull request (see the guide [**here**][prs]) |
|
||||
| Monetary | - [Donate][donate]<br/>- [Sponsor][sponsor]<br/>- [Buy official products][store] |
|
||||
|
||||
[forum]: https://forum.arduino.cc
|
||||
[issues]: contributor-guide/issues.md#issue-report-guide
|
||||
[beta-testing]: contributor-guide/beta-testing.md#beta-testing-guide
|
||||
[translate]: https://www.transifex.com/arduino-1/ide2/dashboard/
|
||||
[prs]: contributor-guide/pull-requests.md#pull-request-guide
|
||||
[donate]: https://www.arduino.cc/en/donate/
|
||||
[sponsor]: https://github.com/sponsors/arduino
|
||||
[store]: https://store.arduino.cc
|
||||
|
||||
## Resources
|
||||
|
||||
- [**Development Guide**](development.md#development-guide)
|
@@ -1,7 +1,7 @@
|
||||
# Remote Sketchbook
|
||||
|
||||
Arduino IDE provides a Remote Sketchbook feature that can be used to upload sketches to Arduino Cloud.
|
||||

|
||||

|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ A developer could use the content of this repo to create a customized version of
|
||||
|
||||
### 1. Changing remote connection parameters in the Preferences panel (be careful while editing the Preferences panel!)
|
||||
Here a screenshot of the Preferences panel
|
||||

|
||||

|
||||
- The settings under _Arduino > Auth_ should be edited to match the OAuth2 configuration of your custom remote sketchbook storage
|
||||
- The setting under _Arduino > Sketch Sync Endpoint_ should be edited to point to your custom remote sketchbook storage service
|
||||
### 2. Implementing the Arduino Cloud Store APIs for your custom remote sketchbook storage
|
||||
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 83 KiB |
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 98 KiB |
BIN
docs/contributor-guide/assets/checks-tab.png
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
docs/contributor-guide/assets/checks.png
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
docs/contributor-guide/assets/tester-build-artifacts.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
docs/contributor-guide/assets/tester-build-link.png
Normal file
After Width: | Height: | Size: 20 KiB |
108
docs/contributor-guide/beta-testing.md
Normal file
@@ -0,0 +1,108 @@
|
||||
<!-- Source: https://github.com/arduino/tooling-project-assets/blob/main/documentation-templates/contributor-guide/application/contributor-guide/beta-testing.md -->
|
||||
|
||||
# Beta Testing Guide
|
||||
|
||||
Beta testing of development versions is a valuable contribution to the project. You can help to ensure the quality of the production release that will be distributed to the user community.
|
||||
|
||||
Builds of the project are automatically created after every relevant change to the project in order to make it easy for anyone to participate in the testing effort.
|
||||
|
||||
---
|
||||
|
||||
❗ Make sure to always download the newest available tester build in order to ensure effective results from your beta testing efforts.
|
||||
|
||||
---
|
||||
|
||||
Beta testing is done during both the proposal (pull request) and pre-release (nightly build) phases of development:
|
||||
|
||||
## Testing Pull Requests
|
||||
|
||||
Tester builds are automatically created for every [pull request](https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) (PR) that proposes a relevant change.
|
||||
|
||||
The builds are updated if the author pushes changes to the PR.
|
||||
|
||||
### Installation
|
||||
|
||||
The tester build for a PR can be downloaded by following these instructions:
|
||||
|
||||
1. Sign in to your [**GitHub**](https://github.com/) account.<br />
|
||||
(GitHub only allows downloads of the tester builds when you are signed in.)
|
||||
1. Open the PR you are interested in.<br />
|
||||
They are listed here:<br />
|
||||
https://github.com/arduino/arduino-ide/pulls
|
||||
1. Click the "**Checks**" tab at the top of the PR's page.
|
||||
1. From the list on the left side of the page, click on "**Arduino IDE**".
|
||||
1. Scroll down to the "**Artifacts**" section of the page that opens.
|
||||
1. Click the download link for your operating system.<br />
|
||||
**ⓘ** For example, if you are using Windows, click the "**Windows_X86-64_zip**" link.
|
||||
1. Wait for the download to finish.
|
||||
1. Extract or install the downloaded file as usual.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
#### Notes for macOS
|
||||
|
||||
Beginning in macOS 10.14.5, the software [must be notarized to run](https://developer.apple.com/documentation/xcode/notarizing_macos_software_before_distribution).
|
||||
|
||||
For security reasons, signing and notarization are disabled when creating tester builds for pull requests from forks of this repository. This means that macOS will block you from running the tester builds for those PRs.
|
||||
|
||||
Due to this limitation, Mac users have two options for testing PRs from forks:
|
||||
|
||||
##### The Safe Approach
|
||||
|
||||
Build the version of the Arduino IDE you want to test from source instead of using the automatically created tester build.
|
||||
|
||||
[Instructions for building the project](../development.md#build-from-source)
|
||||
|
||||
##### The Risky Approach
|
||||
|
||||
---
|
||||
|
||||
⚠ Please note that this approach is risky as you are lowering the security on your system, therefore we strongly discourage you from following it.
|
||||
|
||||
---
|
||||
|
||||
1. Start the tester build.<br />
|
||||
A warning will appear:
|
||||
> "Arduino IDE" cannot be opened because the developer cannot be verified.
|
||||
1. Follow the instructions from the "**If you want to open an app that hasn't been notarized or is from an unidentified developer**" section of this page to bypass the security restriction:<br />
|
||||
[https://support.apple.com/en-us/HT202491](https://support.apple.com/en-us/HT202491#:~:text=If%20you%20want%20to%20open%20an%20app%20that%20hasn%E2%80%99t%20been%20notarized%20or%20is%20from%20an%20unidentified%20developer)
|
||||
|
||||
### Feedback
|
||||
|
||||
Feedback after beta testing a pull request is always valuable, regardless of which categories your findings fall under:
|
||||
|
||||
- working as expected
|
||||
- problems encountered
|
||||
- areas for improvement
|
||||
|
||||
Please submit feedback related to the changes made in the pull request as a PR review:
|
||||
|
||||
https://docs.github.com/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/about-pull-request-reviews
|
||||
|
||||
---
|
||||
|
||||
If you discover problems or areas for improvement that are unrelated to the changes made by the PR (i.e., they also occur when using the [nightly build](#testing-nightly-build)), please submit that feedback as an issue report instead of a review.
|
||||
|
||||
[More information on issue reports](issues.md#issue-report-guide)
|
||||
|
||||
## Testing Nightly Build
|
||||
|
||||
Builds of the project's production branch are produced daily. This build represents the current pre-release state of the project, which is planned for distribution in the next release.
|
||||
|
||||
### Installation
|
||||
|
||||
1. Open Arduino's "**Software**" page:<br />
|
||||
https://www.arduino.cc/en/software#nightly-builds
|
||||
1. Select the appropriate download link from the "**Nightly Builds**" section of the page.
|
||||
1. Wait for the download to finish.
|
||||
1. Extract or install the downloaded file as usual.
|
||||
|
||||
### Feedback
|
||||
|
||||
If you discover any problems or areas for improvement please submit an issue report.
|
||||
|
||||
[More information on issue reports](issues.md#issue-report-guide)
|
33
docs/contributor-guide/issues.md
Normal file
@@ -0,0 +1,33 @@
|
||||
<!-- Source: https://github.com/arduino/tooling-project-assets/blob/main/documentation-templates/contributor-guide/general/contributor-guide/issues.md -->
|
||||
|
||||
# Issue Report Guide
|
||||
|
||||
---
|
||||
|
||||
❗ Do you need help or have a question about using this project? Support requests should be made to the [Arduino Forum](https://forum.arduino.cc).
|
||||
|
||||
---
|
||||
|
||||
High quality bug reports and feature requests are valuable contributions to this project. These can be made by submitting an issue report to the project's GitHub repository:
|
||||
|
||||
https://github.com/arduino/arduino-ide/issues/new/choose
|
||||
|
||||
## Before Reporting an Issue
|
||||
|
||||
- Give the latest development version a test drive to see if your issue was already resolved:<br />
|
||||
https://www.arduino.cc/en/software#nightly-builds
|
||||
- Search [existing pull requests and issues](https://github.com/arduino/arduino-ide/issues?q=) to see if it was already reported.<br />
|
||||
If you have additional information to provide about an existing issue, please comment there instead of creating a duplicate. You can use [GitHub's "Reactions" feature](https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) if you only want to express support 👍.
|
||||
|
||||
## Qualities of an Excellent Report
|
||||
|
||||
- Concise and descriptive issue title.<br />
|
||||
Vague titles make it difficult to decipher the purpose of the issue when looking through the list of reports, which might result in your issue not being given proper attention.
|
||||
- Describe the issue and what behavior you were expecting.<br />
|
||||
Include the full and exact text of any relevant error or warning messages you might have encountered.
|
||||
- Provide a full set of steps necessary to reproduce the issue.<br />
|
||||
Demonstration code or commands should be complete and simplified to the minimum necessary to reproduce the issue.
|
||||
- Be responsive.<br />
|
||||
We may need you to provide additional information in order to investigate and resolve the issue.<br />
|
||||
Make sure your GitHub account is configured so that you will receive notifications of responses to your issue report.
|
||||
- If you find a solution to your problem, please comment on your issue report with an explanation of how you were able to fix it, then close the issue.
|
199
docs/contributor-guide/pull-requests.md
Normal file
@@ -0,0 +1,199 @@
|
||||
<!-- Source: https://github.com/arduino/tooling-project-assets/blob/main/documentation-templates/contributor-guide/general/contributor-guide/pull-requests.md -->
|
||||
|
||||
# Pull Request Guide
|
||||
|
||||
A [**pull request**](https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) (PR) is the mechanism used to propose changes to the content of this project's repository.
|
||||
|
||||
If you are looking for ideas of what to work on, check [the list of open issue reports](https://github.com/arduino/arduino-ide/issues). Pull requests addressing any of those bug reports and feature requests are welcome.
|
||||
|
||||
## Contribution Workflow
|
||||
|
||||
Each contribution travels through a formal process which allows it to be efficiently incorporated into the project.
|
||||
|
||||
### 1. Plan
|
||||
|
||||
#### Research
|
||||
|
||||
Start by searching the repository for existing pull requests and issues related to your planned contribution so you can see any related conversations and proposals and avoid duplicate effort:
|
||||
|
||||
https://github.com/arduino/arduino-ide/issues?q=
|
||||
|
||||
#### Discussion
|
||||
|
||||
It can sometimes be useful to get feedback from others during the planning process. There are a couple good options for discussing planned development work:
|
||||
|
||||
- Talk with the user community on the [Arduino Forum](https://forum.arduino.cc/).
|
||||
- Talk with Arduino developers on the [Arduino Developers Mailing List](https://groups.google.com/a/arduino.cc/g/developers).
|
||||
|
||||
### 2. Fork
|
||||
|
||||
Forking a GitHub repository creates a copy of it under your account. You will stage contributions in your fork of this project.
|
||||
|
||||
[More information about forking repositories](https://docs.github.com/get-started/quickstart/fork-a-repo)
|
||||
|
||||
#### Enabling CI in Your Fork
|
||||
|
||||
The repository is configured to run automated [continuous integration](https://wikipedia.org/wiki/Continuous_integration) (CI) checks and tests. It's a good idea to enable CI in your fork so you can make sure your work will pass the checks before you submit a pull request:
|
||||
|
||||
1. Open the homepage of your fork in the browser.
|
||||
1. Click the "**Actions**" tab.
|
||||
1. Click the <kbd>**I understand my workflows, go ahead and enable them**</kbd> button.
|
||||
1. Some of the workflows will now need to be activated individually. Perform the following steps for each of the useful workflows listed on the left side of the page that have a "**!**" icon:
|
||||
1. Click on the workflow name.
|
||||
1. Click the <kbd>**Enable workflow**</kbd> button.
|
||||
|
||||
### 3. Clone
|
||||
|
||||
Cloning a repository creates a copy of it on your computer.
|
||||
|
||||
It is possible to make simple changes to your repository using the GitHub web interface without cloning the repository. However, the GitHub web interface is quite limiting so you will likely find the need to work with a clone (using **Git** directly or your choice of [Git client software](https://git-scm.com/downloads/guis)) for any significant development work.
|
||||
|
||||
[More information about cloning repositories](https://git-scm.com/docs/git-clone)
|
||||
|
||||
### 4. Branch
|
||||
|
||||
Create a branch in your fork to contain the changes for your contribution. You must make a separate branch in your fork for each pull request you submit.
|
||||
|
||||
[More information about branches](https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches)
|
||||
|
||||
### 5. Make a change
|
||||
|
||||
Some things to keep in mind:
|
||||
|
||||
- Make sure your change complies with the project's established style conventions.
|
||||
- Remember to also update the documentation content in the repository if required by your changes.
|
||||
- If the project contains a test suite, update or add tests according to your change as appropriate.
|
||||
|
||||
See [the development guide](../development.md#development-guide) for more information.
|
||||
|
||||
### 6. Test
|
||||
|
||||
Test your change carefully to make sure it works correctly and did not break other components of the project.
|
||||
|
||||
As a supplement for general testing, the project is set up with automated checks and tests to facilitate development.
|
||||
|
||||
See [the development guide](../development.md#development-guide) for instructions.
|
||||
|
||||
### 7. Commit
|
||||
|
||||
Once the work on your change is complete, add it to the revision history of the Git repository by making a commit.
|
||||
|
||||
Make sure to follow the [Commit Guidelines](#commit-guidelines).
|
||||
|
||||
[More information about commits](https://git-scm.com/docs/git-commit)
|
||||
|
||||
### 8. Push
|
||||
|
||||
If you're working from a [clone](#3-clone), you will need to push your commit to your fork on GitHub.
|
||||
|
||||
[More information about pushing commits](https://git-scm.com/docs/git-push)
|
||||
|
||||
#### Checking CI Results
|
||||
|
||||
If you have [enabled CI in your repository](#enabling-ci-in-your-fork), GitHub will run the relevant checks automatically every time you push a commit to your fork.
|
||||
|
||||
You can see the results of these checks by doing either of the following:
|
||||
|
||||
- Clicking the status icon (✔️ or ❌) shown to the right of a commit.
|
||||
- Opening the repository's "**Actions**" tab.
|
||||
|
||||
### 9. Pull request
|
||||
|
||||
A pull request (PR) is a proposal to make a change in a repository. The repository maintainer is able to accept the changes you propose in a pull request by simply clicking a button.
|
||||
|
||||
[More information about pull requests](https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests)
|
||||
|
||||
#### Scope
|
||||
|
||||
Each pull request should address a single bug fix or enhancement. If you have multiple unrelated fixes or enhancements to contribute, submit them as separate pull requests.
|
||||
|
||||
#### Description
|
||||
|
||||
Pull request title and description should follow [the same guidelines as commit messages](#commit-message).
|
||||
|
||||
If your pull request fixes an issue in the issue tracker, use [a closing keyword](https://docs.github.com/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) in the body to indicate this.
|
||||
|
||||
In some cases, it might make sense to request feedback on a proposal before it is ready to be merged. You can indicate this by starting the pull request title with **[WIP]** (work in progress). Once the pull request is ready to be merged, edit the title and remove the "[WIP]".
|
||||
|
||||
#### Cross-repository Contributions
|
||||
|
||||
Some proposals may require changes to multiple repositories. Pull requests should be submitted in parallel to each repository.
|
||||
|
||||
Clearly note any dependencies on other PRs in the description so that these can be evaluated by the reviewer and the merges coordinated.
|
||||
|
||||
---
|
||||
|
||||
Please check whether any changes are required to the related documentation content hosted in the separate dedicated repositories:
|
||||
|
||||
- [**arduino/docs-content**](https://github.com/arduino/docs-content)
|
||||
- [**arduino/help-center-content**](https://github.com/arduino/help-center-content)
|
||||
|
||||
### 10. Resolve CI failures
|
||||
|
||||
Relevant checks will run automatically once you have submitted the pull request. Once these checks are finished, you can see a summary of the results near the bottom of the pull request page:
|
||||
|
||||

|
||||
|
||||
Failed checks will be indicated with an ❌. If any checks failed, please fix whatever caused it to fail. Click the "**Details**" link to the right of the check name to open the logs, which provide details about the failure.
|
||||
|
||||
---
|
||||
|
||||
**ⓘ** In some rare cases, a CI failure may be unrelated to the changes made in your pull request. So if the information in the logs doesn't seem relevant, please comment on the pull request to ask a maintainer to take a look.
|
||||
|
||||
---
|
||||
|
||||
When you push to the branch of your fork the pull request was submitted from, the commit is automatically added to the pull request. Don't create a new pull request to fix problems; update the existing pull request.
|
||||
|
||||
### 11. Resolve changes requested from reviews
|
||||
|
||||
Interested parties may review your pull request and suggest improvements.
|
||||
|
||||
To act on general review suggestions, you can add commits to the branch you submitted the pull request from, which will automatically be added to the pull request. Don't create a new pull request to act on review suggestions; update the existing pull request.
|
||||
|
||||
Reviewers may suggest specific changes, which can be applied by [clicking the <kbd>**Commit suggestion**</kbd> button](https://docs.github.com/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/incorporating-feedback-in-your-pull-request#applying-suggested-changes).
|
||||
|
||||
[More information about pull request reviews](https://docs.github.com/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/about-pull-request-reviews)
|
||||
|
||||
### 12. Merge
|
||||
|
||||
One of the repository maintainers can now choose to accept your proposed change. Once the pull request is [merged](https://docs.github.com/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/merging-a-pull-request), you can delete the branch you created in your fork for the pull request and delete the fork as well if you like.
|
||||
|
||||
Thanks so much for your contribution!
|
||||
|
||||
---
|
||||
|
||||
It is possible that the maintainers may decide a pull request doesn't align with Arduino's goals for the project and close it rather than merging. A record of the proposed changes will always be available on GitHub for future reference. If you think your modifications will be of use to others, you are welcome to maintain your own fork of the repository.
|
||||
|
||||
---
|
||||
|
||||
## Commit Guidelines
|
||||
|
||||
The commit history of a repository is an important resource for developers. Repositories may accumulate thousands of commits over the course of decades. Each individual commit contributes either to the commit history being pleasant and efficient to work with, or to it being a confusing mess. For this reason, it's essential for contributors to create clean, high quality commits.
|
||||
|
||||
### Scope
|
||||
|
||||
Commits must be "atomic". This means that the commit completely accomplishes a single task. Each commit should result in fully functional code. Multiple tasks should not be combined in a single commit, but a single task should not be split over multiple commits (e.g., one commit per file modified is not a good practice).
|
||||
|
||||
[More information about atomic commits](https://www.freshconsulting.com/insights/blog/atomic-commits/)
|
||||
|
||||
### Commit Message
|
||||
|
||||
The commit message documents what the change was and why it was done. A little effort now writing a good commit message can save future developers from wasted time and frustration trying to understand the purpose of a poorly documented commit.
|
||||
|
||||
#### Commit Message Title
|
||||
|
||||
- Use the [imperative mood](https://cbea.ms/git-commit/#imperative) in the title.<br />
|
||||
For example:
|
||||
> Use LED_BUILTIN macro in LED pin definition
|
||||
- Capitalize the title.
|
||||
- Do not end the title with punctuation.
|
||||
- Do not use GitHub's default commit titles (e.g., "Update examples/Foo/Foo.ino").
|
||||
|
||||
#### Commit Message Body
|
||||
|
||||
- Separate title from the body with a blank line. If you're committing via GitHub or [GitHub Desktop](https://desktop.github.com/) this will be done automatically.
|
||||
- Wrap body at 120 characters.
|
||||
- Completely explain the purpose of the commit.<br />
|
||||
Include a rationale for the change, any caveats, side-effects, etc.
|
||||
|
||||
[More information on commit messages](https://cbea.ms/git-commit/)
|
116
docs/development.md
Normal file
@@ -0,0 +1,116 @@
|
||||
# Development Guide
|
||||
|
||||
This page includes technical documentation for developers who want to build the IDE locally and contribute to the project.
|
||||
|
||||
## Architecture overview
|
||||
|
||||
The IDE consists of three major parts:
|
||||
- the _Electron main_ process,
|
||||
- the _backend_, and
|
||||
- the _frontend_.
|
||||
|
||||
The _Electron main_ process is responsible for:
|
||||
- creating the application,
|
||||
- managing the application lifecycle via listeners, and
|
||||
- creating and managing the web pages for the app.
|
||||
|
||||
In Electron, the process that runs the main entry JavaScript file is called the main process. The _Electron main_ process can display a GUI by creating web pages. An Electron app always has exactly one main process.
|
||||
|
||||
By default, whenever the _Electron main_ process creates a web page, it will instantiate a new `BrowserWindow` instance. Since Electron uses Chromium for displaying web pages, Chromium's multi-process architecture is also used. Each web page in Electron runs in its own process, which is called the renderer process. Each `BrowserWindow` instance runs the web page in its own renderer process. When a `BrowserWindow` instance is destroyed, the corresponding renderer process is also terminated. The main process manages all web pages and their corresponding renderer processes. Each renderer process is isolated and only cares about the web page running in it.<sup>[[1]]</sup>
|
||||
|
||||
In normal browsers, web pages usually run in a sandboxed environment, and accessing native resources are disallowed. However, Electron has the power to use Node.js APIs in the web pages allowing lower-level OS interactions. Due to security reasons, accessing native resources is an undesired behavior in the IDE. So by convention, we do not use Node.js APIs. (Note: the Node.js integration is [not yet disabled](https://github.com/eclipse-theia/theia/issues/2018) although it is not used). In the IDE, only the _backend_ allows OS interaction.
|
||||
|
||||
The _backend_ process is responsible for:
|
||||
- providing access to the filesystem,
|
||||
- communicating with the [Arduino CLI](https://github.com/arduino/arduino-cli) via gRPC,
|
||||
- running your terminal,
|
||||
- exposing additional RESTful APIs,
|
||||
- performing the Git commands in the local repositories,
|
||||
- hosting and running any VS Code extensions, or
|
||||
- executing VS Code tasks<sup>[[2]]</sup>.
|
||||
|
||||
The _Electron main_ process spawns the _backend_ process. There is always exactly one _backend_ process. However, due to performance considerations, the _backend_ spawns several sub-processes for the filesystem watching, Git repository discovery, etc. The communication between the _backend_ process and its sub-processes is established via IPC. Besides spawning sub-processes, the _backend_ will start an HTTP server on a random available port, and serves the web application as static content. When the sub-processes are up and running, and the HTTP server is also listening, the _backend_ process sends the HTTP server port to the _Electron main_ process via IPC. The _Electron main_ process will load the _backend_'s endpoint in the `BrowserWindow`.
|
||||
|
||||
The _frontend_ is running as an Electron renderer process and can invoke services implemented on the _backend_. The communication between the _backend_ and the _frontend_ is done via JSON-RPC over a websocket connection. This means, the services running in the _frontend_ are all proxies, and will ask the corresponding service implementation on the _backend_.
|
||||
|
||||
[1]: https://www.electronjs.org/docs/tutorial/application-architecture#differences-between-main-process-and-renderer-process
|
||||
[2]: https://code.visualstudio.com/Docs/editor/tasks
|
||||
|
||||
### Additional Components
|
||||
|
||||
This repository contains the main code, but two more repositories are included during the build process:
|
||||
|
||||
- [vscode-arduino-tools](https://github.com/arduino/vscode-arduino-tools): provides support for the language server and the debugger
|
||||
- [arduino-language-server](https://github.com/arduino/arduino-language-server): provides the language server that parses Arduino code
|
||||
|
||||
## Build from source
|
||||
|
||||
---
|
||||
|
||||
**ⓘ** If you only want to test an existing version of the project, automatically generated builds are available for download without building from source. See the instructions in the [**beta testing guide**](contributor-guide/beta-testing.md#beta-testing-guide).
|
||||
|
||||
---
|
||||
|
||||
If you’re familiar with TypeScript, the [Theia IDE](https://theia-ide.org/), and if you want to contribute to the
|
||||
project, you should be able to build the Arduino IDE locally.
|
||||
Please refer to the [Theia IDE prerequisites](https://github.com/eclipse-theia/theia/blob/master/doc/Developing.md#prerequisites) documentation for the setup instructions.
|
||||
> **Note**: Node.js 14 must be used instead of the version 12 recommended at the link above.
|
||||
|
||||
Once you have all the tools installed, you can build the editor following these steps
|
||||
|
||||
1. Install the dependencies and build
|
||||
```sh
|
||||
yarn
|
||||
```
|
||||
|
||||
2. Rebuild the dependencies
|
||||
```sh
|
||||
yarn rebuild:browser
|
||||
```
|
||||
|
||||
3. Rebuild the electron dependencies
|
||||
```sh
|
||||
yarn rebuild:electron
|
||||
```
|
||||
|
||||
4. Start the application
|
||||
```sh
|
||||
yarn start
|
||||
```
|
||||
|
||||
### Notes for Windows contributors
|
||||
Windows requires the Microsoft Visual C++ (MSVC) compiler toolset to be installed on your development machine.
|
||||
|
||||
In case it's not already present, it can be downloaded from the "**Tools for Visual Studio 20XX**" section of the Visual Studio [downloads page](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) via the "**Build Tools for Visual Studio 20XX**" (e.g., "**Build Tools for Visual Studio 2022**") download link.
|
||||
|
||||
Select "**Desktop development with C++**" from the "**Workloads**" tab during the installation procedure.
|
||||
|
||||
### CI
|
||||
|
||||
This project is built on [GitHub Actions](https://github.com/arduino/arduino-ide/actions).
|
||||
|
||||
- _Snapshot_ builds run when changes are pushed to the `main` branch, or when a PR is created against the `main` branch. For the sake of the review and verification process, the build artifacts for each operating system can be downloaded from the GitHub Actions page.
|
||||
- _Nightly_ builds run every day at 03:00 GMT from the `main` branch.
|
||||
- _Release_ builds run when a new tag is pushed to the remote. The tag must follow the [semver](https://semver.org/). For instance, `1.2.3` is a correct tag, but `v2.3.4` won't work. Steps to trigger a new release build:
|
||||
- Create a local tag:
|
||||
```sh
|
||||
git tag -a 1.2.3 -m "Creating a new tag for the `1.2.3` release."
|
||||
```
|
||||
- Push it to the remote:
|
||||
```sh
|
||||
git push origin 1.2.3
|
||||
```
|
||||
|
||||
## FAQ
|
||||
|
||||
* *Can I manually change the version of the [`arduino-cli`](https://github.com/arduino/arduino-cli/) used by the IDE?*
|
||||
|
||||
Yes. It is possible but not recommended. The CLI exposes a set of functionality via [gRPC](https://github.com/arduino/arduino-cli/tree/master/rpc) and the IDE uses this API to communicate with the CLI. Before we build a new version of IDE, we pin a specific version of CLI and use the corresponding `proto` files to generate TypeScript modules for gRPC. This means, a particular version of IDE is compliant only with the pinned version of CLI. Mismatching IDE and CLI versions might not be able to communicate with each other. This could cause unpredictable IDE behavior.
|
||||
|
||||
* *I have understood that not all versions of the CLI are compatible with my version of IDE but how can I manually update the `arduino-cli` inside the IDE?*
|
||||
|
||||
[Get](https://arduino.github.io/arduino-cli/installation) the desired version of `arduino-cli` for your platform and manually replace the one inside the IDE. The CLI can be found inside the IDE at:
|
||||
- Windows: `C:\path\to\Arduino IDE\resources\app\node_modules\arduino-ide-extension\build\arduino-cli.exe`,
|
||||
- macOS: `/path/to/Arduino IDE.app/Contents/Resources/app/node_modules/arduino-ide-extension/build/arduino-cli`, and
|
||||
- Linux: `/path/to/Arduino IDE/resources/app/node_modules/arduino-ide-extension/build/arduino-cli`.
|
||||
|
@@ -41,7 +41,7 @@ Building the Pro IDE on Linux `armv7l` (aka `armhf`) and `aarch64` (aka `arm64`)
|
||||
- `libx11-dev`, and
|
||||
- `libxkbfile-dev`
|
||||
|
||||
4. [Build it](../../BUILDING.md#build-from-source) from the source:
|
||||
4. [Build it](../development.md#build-from-source) from the source:
|
||||
```
|
||||
git clone https://github.com/arduino/arduino-ide.git \
|
||||
&& cd arduino-ide \
|
||||
|
@@ -12,7 +12,7 @@ https://github.com/arduino/arduino-ide/pulls/app%2Fgithub-actions
|
||||
|
||||
## ⚙ Create the release on GitHub
|
||||
|
||||
First of all, you need to **set the new version in all the `package.json` files** across the app (`./package.json`, `./arduino-ide-extension/package.json`, `./browser-app/package.json`, `./electron-app/package.json`), create a PR, and merge it on the `main` branch.
|
||||
First of all, you need to **set the new version in all the `package.json` files** across the app (`./package.json`, `./arduino-ide-extension/package.json`, and `./electron-app/package.json`), create a PR, and merge it on the `main` branch.
|
||||
|
||||
To do so, you can make use of the `update:version` script.
|
||||
|
||||
|
@@ -119,14 +119,14 @@
|
||||
}
|
||||
verifyVersions(allDependencies);
|
||||
|
||||
//-------------------------------------------------------------+
|
||||
// Save some time: no need to build the `browser-app` example. |
|
||||
//-------------------------------------------------------------+
|
||||
//---------------------------------------------------------------------------------------------------+
|
||||
// Save some time: no need to build the projects that are not needed in final app. Currently unused. |
|
||||
//---------------------------------------------------------------------------------------------------+
|
||||
//@ts-ignore
|
||||
let pkg = require('../working-copy/package.json');
|
||||
const workspaces = pkg.workspaces;
|
||||
// We cannot remove the `electron-app`. Otherwise, there is not way to collect the unused dependencies.
|
||||
const dependenciesToRemove = ['browser-app'];
|
||||
const dependenciesToRemove = [];
|
||||
for (const dependencyToRemove of dependenciesToRemove) {
|
||||
const index = workspaces.indexOf(dependencyToRemove);
|
||||
if (index !== -1) {
|
||||
|
@@ -336,7 +336,7 @@
|
||||
"serial": {
|
||||
"autoscroll": "Autoscroll",
|
||||
"carriageReturn": "Carriage Return",
|
||||
"message": "Message ({0} + Enter to send message to '{1}' on '{2}')",
|
||||
"message": "Message (Enter to send message to '{0}' on '{1}')",
|
||||
"newLine": "New Line",
|
||||
"newLineCarriageReturn": "Both NL & CR",
|
||||
"noLineEndings": "No Line Ending",
|
||||
|
@@ -41,7 +41,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "lerna run prepare && yarn download:plugins",
|
||||
"cleanup": "npx rimraf ./**/node_modules && rm -rf ./node_modules ./.browser_modules ./arduino-ide-extension/build ./arduino-ide-extension/downloads ./arduino-ide-extension/Examples ./arduino-ide-extension/lib ./browser-app/lib ./browser-app/src-gen ./browser-app/gen-webpack.config.js ./electron-app/lib ./electron-app/src-gen ./electron-app/gen-webpack.config.js",
|
||||
"cleanup": "npx rimraf ./**/node_modules && rm -rf ./node_modules ./.browser_modules ./arduino-ide-extension/build ./arduino-ide-extension/downloads ./arduino-ide-extension/Examples ./arduino-ide-extension/lib ./electron-app/lib ./electron-app/src-gen ./electron-app/gen-webpack.config.js",
|
||||
"rebuild:browser": "theia rebuild:browser",
|
||||
"rebuild:electron": "theia rebuild:electron",
|
||||
"start": "yarn --cwd ./electron-app start",
|
||||
@@ -49,7 +49,7 @@
|
||||
"test": "lerna run test",
|
||||
"download:plugins": "theia download:plugins",
|
||||
"update:version": "node ./scripts/update-version.js",
|
||||
"i18n:generate": "theia nls-extract -e vscode -f \"+(arduino-ide-extension|browser-app|electron-app|plugins)/**/*.ts?(x)\" -o ./i18n/en.json",
|
||||
"i18n:generate": "theia nls-extract -e vscode -f \"+(arduino-ide-extension|electron-app|plugins)/**/*.ts?(x)\" -o ./i18n/en.json",
|
||||
"i18n:check": "yarn i18n:generate && git add -N ./i18n && git diff --exit-code ./i18n",
|
||||
"i18n:push": "node ./scripts/i18n/transifex-push.js ./i18n/en.json",
|
||||
"i18n:pull": "node ./scripts/i18n/transifex-pull.js ./i18n/",
|
||||
@@ -69,8 +69,7 @@
|
||||
},
|
||||
"workspaces": [
|
||||
"arduino-ide-extension",
|
||||
"electron-app",
|
||||
"browser-app"
|
||||
"electron-app"
|
||||
],
|
||||
"theiaPluginsDir": "plugins",
|
||||
"theiaPlugins": {
|
||||
|
@@ -27,7 +27,6 @@ console.log(`🛠️ Updating current version from '${currentVersion}' to '${tar
|
||||
for (const toUpdate of [
|
||||
path.join(repoRootPath, 'package.json'),
|
||||
path.join(repoRootPath, 'electron-app', 'package.json'),
|
||||
path.join(repoRootPath, 'browser-app', 'package.json'),
|
||||
path.join(repoRootPath, 'arduino-ide-extension', 'package.json')
|
||||
]) {
|
||||
process.stdout.write(` Updating ${toUpdate}'...`);
|
||||
|