mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-06-13 23:56:33 +00:00

- Updated `@theia/*` to `1.37.0`. - Fixed all `yarn audit` security vulnerabilities. - Updated to `electron@23.2.4`: - `contextIsolation` is `true`, - `nodeIntegration` is `false`, and the - `webpack` target is moved from `electron-renderer` to `web`. - Updated to `typescript@4.9.3`. - Updated the `eslint` plugins. - Added the new `Light High Contrast` theme to the IDE2. - High contrast themes use Theia APIs for style adjustments. - Support for ESM modules: `"moduleResolution": "node16"`. - Node.js >= 16.14 is required. - VISX langage packs were bumped to `1.70.0`. - Removed undesired editor context menu items. (Closes #1394) Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
101 lines
2.9 KiB
TypeScript
101 lines
2.9 KiB
TypeScript
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
import {
|
|
MonitorManagerProxy,
|
|
MonitorManagerProxyClient,
|
|
MonitorSettings,
|
|
PluggableMonitorSettings,
|
|
} from '../common/protocol';
|
|
import { Board, Port } from '../common/protocol';
|
|
import { MonitorManager } from './monitor-manager';
|
|
|
|
@injectable()
|
|
export class MonitorManagerProxyImpl implements MonitorManagerProxy {
|
|
protected client: MonitorManagerProxyClient;
|
|
|
|
constructor(
|
|
@inject(MonitorManager)
|
|
protected readonly manager: MonitorManager
|
|
) {}
|
|
|
|
dispose(): void {
|
|
this.client?.disconnect();
|
|
}
|
|
|
|
/**
|
|
* Start a pluggable monitor and/or change its settings.
|
|
* If settings are defined they'll be set before starting the monitor,
|
|
* otherwise default ones will be used by the monitor.
|
|
* @param board board connected to port
|
|
* @param port port to monitor
|
|
* @param settings map of supported configuration by the monitor
|
|
*/
|
|
async startMonitor(
|
|
board: Board,
|
|
port: Port,
|
|
settings?: PluggableMonitorSettings
|
|
): Promise<void> {
|
|
if (settings) {
|
|
await this.changeMonitorSettings(board, port, settings);
|
|
}
|
|
|
|
const connectToClient = async () => {
|
|
const address = this.manager.getWebsocketAddressPort(board, port);
|
|
if (!this.client) {
|
|
throw new Error(
|
|
`No client was connected to this monitor manager. Board: ${
|
|
board.fqbn ?? board.name
|
|
}, port: ${port.address}, address: ${address}`
|
|
);
|
|
}
|
|
await this.client.connect(address);
|
|
};
|
|
return this.manager.startMonitor(board, port, connectToClient);
|
|
}
|
|
|
|
/**
|
|
* Changes the settings of a running pluggable monitor, if that monitor is not
|
|
* started this function is a noop.
|
|
* @param board board connected to port
|
|
* @param port port monitored
|
|
* @param settings map of supported configuration by the monitor
|
|
*/
|
|
async changeMonitorSettings(
|
|
board: Board,
|
|
port: Port,
|
|
settings: PluggableMonitorSettings
|
|
): Promise<void> {
|
|
if (!this.manager.isStarted(board, port)) {
|
|
// Monitor is not running, no need to change settings
|
|
return;
|
|
}
|
|
return this.manager.changeMonitorSettings(board, port, settings);
|
|
}
|
|
|
|
/**
|
|
* Stops a running pluggable monitor.
|
|
* @param board board connected to port
|
|
* @param port port monitored
|
|
*/
|
|
async stopMonitor(board: Board, port: Port): Promise<void> {
|
|
return this.manager.stopMonitor(board, port);
|
|
}
|
|
|
|
/**
|
|
* Returns the current settings by the pluggable monitor connected to specified
|
|
* by board/port combination.
|
|
* @param board board connected to port
|
|
* @param port port monitored
|
|
* @returns a map of MonitorSetting
|
|
*/
|
|
getCurrentSettings(board: Board, port: Port): Promise<MonitorSettings> {
|
|
return this.manager.currentMonitorSettings(board, port);
|
|
}
|
|
|
|
setClient(client: MonitorManagerProxyClient | undefined): void {
|
|
if (!client) {
|
|
return;
|
|
}
|
|
this.client = client;
|
|
}
|
|
}
|