From a090dfe99c653effd6e6e6a67cb104b8f100a330 Mon Sep 17 00:00:00 2001 From: Silvano Cerza <3314350+silvanocerza@users.noreply.github.com> Date: Thu, 25 Nov 2021 18:22:51 +0100 Subject: [PATCH] Add dialog to insert user fields for board that require them to upload (#550) * Rebuild gRPC protocol interfaces * Implement methods to get user fields for board/port combination * Implement dialog to input board user fields * Add configure and upload step when uploading to board requiring user fields * Disable Sketch > Configure and Upload menu if board doesn't support user fields * Fix serial upload not working with all boards * Update i18n source file * fix user fields UI * regenerate cli protocol * fix localisation * check if user fields are empty Co-authored-by: Alberto Iannaccone --- .../browser/arduino-frontend-contribution.tsx | 2 +- .../browser/arduino-ide-frontend-module.ts | 11 + .../browser/boards/boards-service-provider.ts | 85 ++-- .../browser/contributions/upload-sketch.ts | 158 ++++++- .../browser/contributions/verify-sketch.ts | 2 +- .../user-fields/user-fields-component.tsx | 98 +++++ .../user-fields/user-fields-dialog.tsx | 121 ++++++ .../src/browser/style/index.css | 81 ++-- .../src/browser/style/user-fields-dialog.css | 32 ++ .../src/common/protocol/boards-service.ts | 9 + .../src/common/protocol/core-service.ts | 2 + .../src/node/boards-service-impl.ts | 32 ++ .../cli/commands/v1/commands_grpc_pb.d.ts | 51 --- .../cli/commands/v1/commands_grpc_pb.js | 103 ----- .../arduino/cli/commands/v1/commands_pb.d.ts | 54 --- .../cc/arduino/cli/commands/v1/commands_pb.js | 387 ------------------ .../src/node/core-service-impl.ts | 5 + i18n/en.json | 6 + yarn.lock | 8 +- 19 files changed, 568 insertions(+), 679 deletions(-) create mode 100644 arduino-ide-extension/src/browser/dialogs/user-fields/user-fields-component.tsx create mode 100644 arduino-ide-extension/src/browser/dialogs/user-fields/user-fields-dialog.tsx create mode 100644 arduino-ide-extension/src/browser/style/user-fields-dialog.css diff --git a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx index f9ec9ccbf..55e70a2c2 100644 --- a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx +++ b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx @@ -445,7 +445,7 @@ export class ArduinoFrontendContribution 'arduino/debug/optimizeForDebugging', 'Optimize for Debugging' ), - order: '4', + order: '5', }); } diff --git a/arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts b/arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts index 459e6be39..00a1ae5ad 100644 --- a/arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts +++ b/arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts @@ -254,6 +254,11 @@ import { UploadCertificateDialogWidget, } from './dialogs/certificate-uploader/certificate-uploader-dialog'; import { PlotterFrontendContribution } from './serial/plotter/plotter-frontend-contribution'; +import { + UserFieldsDialog, + UserFieldsDialogProps, + UserFieldsDialogWidget, +} from './dialogs/user-fields/user-fields-dialog'; import { nls } from '@theia/core/lib/browser/nls'; const ElementQueries = require('css-element-queries/src/ElementQueries'); @@ -739,4 +744,10 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { bind(UploadCertificateDialogProps).toConstantValue({ title: 'UploadCertificate', }); + + bind(UserFieldsDialogWidget).toSelf().inSingletonScope(); + bind(UserFieldsDialog).toSelf().inSingletonScope(); + bind(UserFieldsDialogProps).toConstantValue({ + title: 'UserFields', + }); }); diff --git a/arduino-ide-extension/src/browser/boards/boards-service-provider.ts b/arduino-ide-extension/src/browser/boards/boards-service-provider.ts index 97c660e87..295891c8f 100644 --- a/arduino-ide-extension/src/browser/boards/boards-service-provider.ts +++ b/arduino-ide-extension/src/browser/boards/boards-service-provider.ts @@ -12,6 +12,7 @@ import { BoardsPackage, AttachedBoardsChangeEvent, BoardWithPackage, + BoardUserField, } from '../../common/protocol'; import { BoardsConfig } from './boards-config'; import { naturalCompare } from '../../common/utils'; @@ -68,7 +69,8 @@ export class BoardsServiceProvider implements FrontendApplicationContribution { * This event is also emitted when the board package for the currently selected board was uninstalled. */ readonly onBoardsConfigChanged = this.onBoardsConfigChangedEmitter.event; - readonly onAvailableBoardsChanged = this.onAvailableBoardsChangedEmitter.event; + readonly onAvailableBoardsChanged = + this.onAvailableBoardsChangedEmitter.event; readonly onAvailablePortsChanged = this.onAvailablePortsChangedEmitter.event; onStart(): void { @@ -183,8 +185,8 @@ export class BoardsServiceProvider implements FrontendApplicationContribution { const selectedAvailableBoard = AvailableBoard.is(selectedBoard) ? selectedBoard : this._availableBoards.find((availableBoard) => - Board.sameAs(availableBoard, selectedBoard) - ); + Board.sameAs(availableBoard, selectedBoard) + ); if ( selectedAvailableBoard && selectedAvailableBoard.selected && @@ -274,6 +276,18 @@ export class BoardsServiceProvider implements FrontendApplicationContribution { return boards; } + async selectedBoardUserFields(): Promise { + if (!this._boardsConfig.selectedBoard || !this._boardsConfig.selectedPort) { + return []; + } + const fqbn = this._boardsConfig.selectedBoard.fqbn; + if (!fqbn) { + return []; + } + const protocol = this._boardsConfig.selectedPort.protocol; + return await this.boardsService.getBoardUserFields({ fqbn, protocol }); + } + /** * `true` if the `config.selectedBoard` is defined; hence can compile against the board. Otherwise, `false`. */ @@ -361,14 +375,14 @@ export class BoardsServiceProvider implements FrontendApplicationContribution { const timeoutTask = !!timeout && timeout > 0 ? new Promise((_, reject) => - setTimeout( - () => reject(new Error(`Timeout after ${timeout} ms.`)), - timeout + setTimeout( + () => reject(new Error(`Timeout after ${timeout} ms.`)), + timeout + ) ) - ) : new Promise(() => { - /* never */ - }); + /* never */ + }); const waitUntilTask = new Promise((resolve) => { let candidate = find(what, this.availableBoards); if (candidate) { @@ -406,7 +420,7 @@ export class BoardsServiceProvider implements FrontendApplicationContribution { const availableBoards: AvailableBoard[] = []; const attachedBoards = this._attachedBoards.filter(({ port }) => !!port); const availableBoardPorts = availablePorts.filter((port) => { - if (port.protocol === "serial") { + if (port.protocol === 'serial') { // We always show all serial ports, even if there // is no recognized board connected to it return true; @@ -424,8 +438,12 @@ export class BoardsServiceProvider implements FrontendApplicationContribution { }); for (const boardPort of availableBoardPorts) { - let board = attachedBoards.find(({ port }) => Port.sameAs(boardPort, port)); - const lastSelectedBoard = await this.getLastSelectedBoardOnPort(boardPort); + const board = attachedBoards.find(({ port }) => + Port.sameAs(boardPort, port) + ); + const lastSelectedBoard = await this.getLastSelectedBoardOnPort( + boardPort + ); let availableBoard = {} as AvailableBoard; if (board) { @@ -454,11 +472,16 @@ export class BoardsServiceProvider implements FrontendApplicationContribution { availableBoards.push(availableBoard); } - if (boardsConfig.selectedBoard && !availableBoards.some(({ selected }) => selected)) { + if ( + boardsConfig.selectedBoard && + !availableBoards.some(({ selected }) => selected) + ) { // 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. - const found = availableBoards.findIndex(board => board.port?.address === boardsConfig.selectedPort?.address); + const found = availableBoards.findIndex( + (board) => board.port?.address === boardsConfig.selectedPort?.address + ); if (found >= 0) { availableBoards.splice(found, 1); } @@ -475,7 +498,9 @@ export class BoardsServiceProvider implements FrontendApplicationContribution { let hasChanged = availableBoards.length !== currentAvailableBoards.length; for (let i = 0; !hasChanged && i < availableBoards.length; i++) { const [left, right] = [availableBoards[i], currentAvailableBoards[i]]; - hasChanged = !!AvailableBoard.compare(left, right) || left.selected !== right.selected; + hasChanged = + !!AvailableBoard.compare(left, right) || + left.selected !== right.selected; } if (hasChanged) { this._availableBoards = availableBoards; @@ -483,7 +508,9 @@ export class BoardsServiceProvider implements FrontendApplicationContribution { } } - protected async getLastSelectedBoardOnPort(port: Port): Promise { + protected async getLastSelectedBoardOnPort( + port: Port + ): Promise { const key = this.getLastSelectedBoardOnPortKey(port); return this.getData(key); } @@ -504,8 +531,11 @@ export class BoardsServiceProvider implements FrontendApplicationContribution { ]); } - protected getLastSelectedBoardOnPortKey(port: Port): string { - return `last-selected-board-on-port:${Port.toString(port)}`; + protected getLastSelectedBoardOnPortKey(port: Port | string): string { + // TODO: we lose the port's `protocol` info (`serial`, `network`, etc.) here if the `port` is a `string`. + return `last-selected-board-on-port:${ + typeof port === 'string' ? port : Port.toString(port) + }`; } protected async loadState(): Promise { @@ -596,13 +626,22 @@ export namespace AvailableBoard { // 4. Network with recognized boards // 5. Other protocols with recognized boards export const compare = (left: AvailableBoard, right: AvailableBoard) => { - if (left.port?.protocol === "serial" && right.port?.protocol !== "serial") { + if (left.port?.protocol === 'serial' && right.port?.protocol !== 'serial') { return -1; - } else if (left.port?.protocol !== "serial" && right.port?.protocol === "serial") { + } else if ( + left.port?.protocol !== 'serial' && + right.port?.protocol === 'serial' + ) { return 1; - } else if (left.port?.protocol === "network" && right.port?.protocol !== "network") { + } else if ( + left.port?.protocol === 'network' && + right.port?.protocol !== 'network' + ) { return -1; - } else if (left.port?.protocol !== "network" && right.port?.protocol === "network") { + } else if ( + left.port?.protocol !== 'network' && + right.port?.protocol === 'network' + ) { return 1; } else if (left.port?.protocol === right.port?.protocol) { // We show all ports, including those that have guessed @@ -614,5 +653,5 @@ export namespace AvailableBoard { } } return naturalCompare(left.port?.address!, right.port?.address!); - } + }; } diff --git a/arduino-ide-extension/src/browser/contributions/upload-sketch.ts b/arduino-ide-extension/src/browser/contributions/upload-sketch.ts index c464ec811..af3e033f5 100644 --- a/arduino-ide-extension/src/browser/contributions/upload-sketch.ts +++ b/arduino-ide-extension/src/browser/contributions/upload-sketch.ts @@ -1,7 +1,7 @@ -import { inject, injectable } from 'inversify'; +import { inject, injectable, postConstruct } from 'inversify'; import { Emitter } from '@theia/core/lib/common/event'; -import { CoreService } from '../../common/protocol'; -import { ArduinoMenus } from '../menu/arduino-menus'; +import { BoardUserField, CoreService } from '../../common/protocol'; +import { ArduinoMenus, PlaceholderMenuNode } from '../menu/arduino-menus'; import { ArduinoToolbar } from '../toolbar/arduino-toolbar'; import { BoardsDataStore } from '../boards/boards-data-store'; import { SerialConnectionManager } from '../serial/serial-connection-manager'; @@ -14,7 +14,9 @@ import { KeybindingRegistry, TabBarToolbarRegistry, } from './contribution'; +import { UserFieldsDialog } from '../dialogs/user-fields/user-fields-dialog'; import { nls } from '@theia/core/lib/browser/nls'; +import { DisposableCollection } from '@theia/core'; @injectable() export class UploadSketch extends SketchContribution { @@ -24,22 +26,96 @@ export class UploadSketch extends SketchContribution { @inject(SerialConnectionManager) protected readonly serialConnection: SerialConnectionManager; + @inject(MenuModelRegistry) + protected readonly menuRegistry: MenuModelRegistry; + @inject(BoardsDataStore) protected readonly boardsDataStore: BoardsDataStore; @inject(BoardsServiceProvider) protected readonly boardsServiceClientImpl: BoardsServiceProvider; + @inject(UserFieldsDialog) + protected readonly userFieldsDialog: UserFieldsDialog; + + protected cachedUserFields: Map = new Map(); + protected readonly onDidChangeEmitter = new Emitter>(); readonly onDidChange = this.onDidChangeEmitter.event; protected uploadInProgress = false; + protected boardRequiresUserFields = false; + + protected readonly menuActionsDisposables = new DisposableCollection(); + + @postConstruct() + protected init(): void { + this.boardsServiceClientImpl.onBoardsConfigChanged(async () => { + const userFields = + await this.boardsServiceClientImpl.selectedBoardUserFields(); + this.boardRequiresUserFields = userFields.length > 0; + this.registerMenus(this.menuRegistry); + }); + } + + private selectedFqbnAddress(): string { + const { boardsConfig } = this.boardsServiceClientImpl; + const fqbn = boardsConfig.selectedBoard?.fqbn; + if (!fqbn) { + return ''; + } + const address = boardsConfig.selectedBoard?.port?.address; + if (!address) { + return ''; + } + return fqbn + '|' + address; + } registerCommands(registry: CommandRegistry): void { registry.registerCommand(UploadSketch.Commands.UPLOAD_SKETCH, { - execute: () => this.uploadSketch(), + execute: async () => { + const key = this.selectedFqbnAddress(); + if (!key) { + return; + } + if (this.boardRequiresUserFields && !this.cachedUserFields.has(key)) { + // Deep clone the array of board fields to avoid editing the cached ones + this.userFieldsDialog.value = ( + await this.boardsServiceClientImpl.selectedBoardUserFields() + ).map((f) => ({ ...f })); + const result = await this.userFieldsDialog.open(); + if (!result) { + return; + } + this.cachedUserFields.set(key, result); + } + this.uploadSketch(); + }, isEnabled: () => !this.uploadInProgress, }); + registry.registerCommand(UploadSketch.Commands.UPLOAD_WITH_CONFIGURATION, { + execute: async () => { + const key = this.selectedFqbnAddress(); + if (!key) { + return; + } + + const cached = this.cachedUserFields.get(key); + // Deep clone the array of board fields to avoid editing the cached ones + this.userFieldsDialog.value = ( + cached ?? + (await this.boardsServiceClientImpl.selectedBoardUserFields()) + ).map((f) => ({ ...f })); + + const result = await this.userFieldsDialog.open(); + if (!result) { + return; + } + this.cachedUserFields.set(key, result); + this.uploadSketch(); + }, + isEnabled: () => !this.uploadInProgress && this.boardRequiresUserFields, + }); registry.registerCommand( UploadSketch.Commands.UPLOAD_SKETCH_USING_PROGRAMMER, { @@ -58,19 +134,46 @@ export class UploadSketch extends SketchContribution { } registerMenus(registry: MenuModelRegistry): void { - registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { - commandId: UploadSketch.Commands.UPLOAD_SKETCH.id, - label: nls.localize('arduino/sketch/upload', 'Upload'), - order: '1', - }); - registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { - commandId: UploadSketch.Commands.UPLOAD_SKETCH_USING_PROGRAMMER.id, - label: nls.localize( - 'arduino/sketch/uploadUsingProgrammer', - 'Upload Using Programmer' - ), - order: '2', - }); + this.menuActionsDisposables.dispose(); + + this.menuActionsDisposables.push( + registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { + commandId: UploadSketch.Commands.UPLOAD_SKETCH.id, + label: nls.localize('arduino/sketch/upload', 'Upload'), + order: '1', + }) + ); + if (this.boardRequiresUserFields) { + this.menuActionsDisposables.push( + registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { + commandId: UploadSketch.Commands.UPLOAD_WITH_CONFIGURATION.id, + label: UploadSketch.Commands.UPLOAD_WITH_CONFIGURATION.label, + order: '2', + }) + ); + } else { + this.menuActionsDisposables.push( + registry.registerMenuNode( + ArduinoMenus.SKETCH__MAIN_GROUP, + new PlaceholderMenuNode( + ArduinoMenus.SKETCH__MAIN_GROUP, + // commandId: UploadSketch.Commands.UPLOAD_WITH_CONFIGURATION.id, + UploadSketch.Commands.UPLOAD_WITH_CONFIGURATION.label!, + { order: '2' } + ) + ) + ); + } + this.menuActionsDisposables.push( + registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { + commandId: UploadSketch.Commands.UPLOAD_SKETCH_USING_PROGRAMMER.id, + label: nls.localize( + 'arduino/sketch/uploadUsingProgrammer', + 'Upload Using Programmer' + ), + order: '3', + }) + ); } registerKeybindings(registry: KeybindingRegistry): void { @@ -127,6 +230,17 @@ export class UploadSketch extends SketchContribution { const optimizeForDebug = this.editorMode.compileForDebug; const { selectedPort } = boardsConfig; const port = selectedPort; + const userFields = + this.cachedUserFields.get(this.selectedFqbnAddress()) ?? []; + if (userFields.length === 0 && this.boardRequiresUserFields) { + this.messageService.error( + nls.localize( + 'arduino/sketch/userFieldsNotFoundError', + "Can't find user fields for connected board" + ) + ); + return; + } if (usingProgrammer) { const programmer = selectedProgrammer; @@ -139,6 +253,7 @@ export class UploadSketch extends SketchContribution { verbose, verify, sourceOverride, + userFields, }; } else { options = { @@ -149,6 +264,7 @@ export class UploadSketch extends SketchContribution { verbose, verify, sourceOverride, + userFields, }; } this.outputChannelManager.getChannel('Arduino').clear(); @@ -197,6 +313,14 @@ export namespace UploadSketch { export const UPLOAD_SKETCH: Command = { id: 'arduino-upload-sketch', }; + export const UPLOAD_WITH_CONFIGURATION: Command = { + id: 'arduino-upload-with-configuration-sketch', + label: nls.localize( + 'arduino/sketch/configureAndUpload', + 'Configure And Upload' + ), + category: 'Arduino', + }; export const UPLOAD_SKETCH_USING_PROGRAMMER: Command = { id: 'arduino-upload-sketch-using-programmer', }; diff --git a/arduino-ide-extension/src/browser/contributions/verify-sketch.ts b/arduino-ide-extension/src/browser/contributions/verify-sketch.ts index f8e1e1a00..299655087 100644 --- a/arduino-ide-extension/src/browser/contributions/verify-sketch.ts +++ b/arduino-ide-extension/src/browser/contributions/verify-sketch.ts @@ -62,7 +62,7 @@ export class VerifySketch extends SketchContribution { 'arduino/sketch/exportBinary', 'Export Compiled Binary' ), - order: '3', + order: '4', }); } diff --git a/arduino-ide-extension/src/browser/dialogs/user-fields/user-fields-component.tsx b/arduino-ide-extension/src/browser/dialogs/user-fields/user-fields-component.tsx new file mode 100644 index 000000000..0278a1b00 --- /dev/null +++ b/arduino-ide-extension/src/browser/dialogs/user-fields/user-fields-component.tsx @@ -0,0 +1,98 @@ +import * as React from 'react'; +import { BoardUserField } from '../../../common/protocol'; +import { nls } from '@theia/core/lib/browser/nls'; + +export const UserFieldsComponent = ({ + initialBoardUserFields, + updateUserFields, + cancel, + accept, +}: { + initialBoardUserFields: BoardUserField[]; + updateUserFields: (userFields: BoardUserField[]) => void; + cancel: () => void; + accept: () => Promise; +}): React.ReactElement => { + const [boardUserFields, setBoardUserFields] = React.useState< + BoardUserField[] + >(initialBoardUserFields); + + const [uploadButtonDisabled, setUploadButtonDisabled] = + React.useState(true); + + React.useEffect(() => { + setBoardUserFields(initialBoardUserFields); + }, [initialBoardUserFields]); + + const updateUserField = + (index: number) => (e: React.ChangeEvent) => { + const newBoardUserFields = [...boardUserFields]; + newBoardUserFields[index].value = e.target.value; + setBoardUserFields(newBoardUserFields); + }; + + const allFieldsHaveValues = (userFields: BoardUserField[]): boolean => { + return ( + userFields && + userFields.length > 0 && + userFields + .map((field: BoardUserField): boolean => { + return field.value.length > 0; + }) + .reduce((previous: boolean, current: boolean): boolean => { + return previous && current; + }) + ); + }; + + React.useEffect(() => { + updateUserFields(boardUserFields); + setUploadButtonDisabled(!allFieldsHaveValues(boardUserFields)); + }, [boardUserFields]); + + return ( +
+
+
+ {boardUserFields.map((field, index) => { + return ( +
+
+ +
+
+ +
+
+ ); + })} +
+
+
+
+ + +
+
+
+ ); +}; diff --git a/arduino-ide-extension/src/browser/dialogs/user-fields/user-fields-dialog.tsx b/arduino-ide-extension/src/browser/dialogs/user-fields/user-fields-dialog.tsx new file mode 100644 index 000000000..aa1bd2646 --- /dev/null +++ b/arduino-ide-extension/src/browser/dialogs/user-fields/user-fields-dialog.tsx @@ -0,0 +1,121 @@ +import * as React from 'react'; +import { inject, injectable } from 'inversify'; +import { + AbstractDialog, + DialogProps, + ReactWidget, +} from '@theia/core/lib/browser'; +import { Widget } from '@phosphor/widgets'; +import { Message } from '@phosphor/messaging'; +import { UploadSketch } from '../../contributions/upload-sketch'; +import { UserFieldsComponent } from './user-fields-component'; +import { BoardUserField } from '../../../common/protocol'; + +@injectable() +export class UserFieldsDialogWidget extends ReactWidget { + protected _currentUserFields: BoardUserField[] = []; + + constructor(private cancel: () => void, private accept: () => Promise) { + super(); + } + + set currentUserFields(userFields: BoardUserField[]) { + this.setUserFields(userFields); + } + + get currentUserFields(): BoardUserField[] { + return this._currentUserFields; + } + + resetUserFieldsValue(): void { + this._currentUserFields = this._currentUserFields.map((field) => { + field.value = ''; + return field; + }); + } + + protected setUserFields(userFields: BoardUserField[]): void { + this._currentUserFields = userFields; + } + + protected render(): React.ReactNode { + return ( +
+ + + ); + } +} + +@injectable() +export class UserFieldsDialogProps extends DialogProps {} + +@injectable() +export class UserFieldsDialog extends AbstractDialog { + protected readonly widget: UserFieldsDialogWidget; + + constructor( + @inject(UserFieldsDialogProps) + protected readonly props: UserFieldsDialogProps + ) { + super({ + title: UploadSketch.Commands.UPLOAD_WITH_CONFIGURATION.label || '', + }); + this.titleNode.classList.add('user-fields-dialog-title'); + this.contentNode.classList.add('user-fields-dialog-content'); + this.acceptButton = undefined; + this.widget = new UserFieldsDialogWidget( + this.close.bind(this), + this.accept.bind(this) + ); + } + + set value(userFields: BoardUserField[]) { + this.widget.currentUserFields = userFields; + } + + get value(): BoardUserField[] { + return this.widget.currentUserFields; + } + + protected onAfterAttach(msg: Message): void { + if (this.widget.isAttached) { + Widget.detach(this.widget); + } + Widget.attach(this.widget, this.contentNode); + super.onAfterAttach(msg); + this.update(); + } + + protected onUpdateRequest(msg: Message): void { + super.onUpdateRequest(msg); + this.widget.update(); + } + + protected onActivateRequest(msg: Message): void { + super.onActivateRequest(msg); + this.widget.activate(); + } + + protected async accept(): Promise { + // If the user presses enter and at least + // a field is empty don't accept the input + for (const field of this.value) { + if (field.value.length === 0) { + return; + } + } + return super.accept(); + } + + close(): void { + this.widget.resetUserFieldsValue(); + this.widget.close(); + super.close(); + } +} diff --git a/arduino-ide-extension/src/browser/style/index.css b/arduino-ide-extension/src/browser/style/index.css index 9ce6b8062..9e52aeb07 100644 --- a/arduino-ide-extension/src/browser/style/index.css +++ b/arduino-ide-extension/src/browser/style/index.css @@ -10,6 +10,7 @@ @import './settings-dialog.css'; @import './firmware-uploader-dialog.css'; @import './certificate-uploader-dialog.css'; +@import './user-fields-dialog.css'; @import './debug.css'; @import './sketchbook.css'; @import './cloud-sketchbook.css'; @@ -17,87 +18,91 @@ @import './custom-codicon.css'; .theia-input.warning:focus { - outline-width: 1px; - outline-style: solid; - outline-offset: -1px; - opacity: 1 !important; - color: var(--theia-warningForeground); - background-color: var(--theia-warningBackground); + outline-width: 1px; + outline-style: solid; + outline-offset: -1px; + opacity: 1 !important; + color: var(--theia-warningForeground); + background-color: var(--theia-warningBackground); } .theia-input.warning { - background-color: var(--theia-warningBackground); + background-color: var(--theia-warningBackground); } -.theia-input.warning::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */ - color: var(--theia-warningForeground); - background-color: var(--theia-warningBackground); - opacity: 1; /* Firefox */ +.theia-input.warning::placeholder { + /* Chrome, Firefox, Opera, Safari 10.1+ */ + color: var(--theia-warningForeground); + background-color: var(--theia-warningBackground); + opacity: 1; /* Firefox */ } -.theia-input.warning:-ms-input-placeholder { /* Internet Explorer 10-11 */ - color: var(--theia-warningForeground); - background-color: var(--theia-warningBackground); +.theia-input.warning:-ms-input-placeholder { + /* Internet Explorer 10-11 */ + color: var(--theia-warningForeground); + background-color: var(--theia-warningBackground); } -.theia-input.warning::-ms-input-placeholder { /* Microsoft Edge */ - color: var(--theia-warningForeground); - background-color: var(--theia-warningBackground); +.theia-input.warning::-ms-input-placeholder { + /* Microsoft Edge */ + color: var(--theia-warningForeground); + background-color: var(--theia-warningBackground); } -/* Makes the sidepanel a bit wider when opening the widget */ +/* Makes the sidepanel a bit wider when opening the widget */ .p-DockPanel-widget { - min-width: 200px; - min-height: 200px; + min-width: 200px; + min-height: 200px; } /* Overrule the default Theia CSS button styles. */ button.theia-button, .theia-button { - border: 1px solid var(--theia-dropdown-border); + border: 1px solid var(--theia-dropdown-border); } button.theia-button:hover, .theia-button:hover { - border: 1px solid var(--theia-focusBorder); + border: 1px solid var(--theia-focusBorder); } button.theia-button { - height: 31px; + height: 31px; } button.theia-button.secondary { - background-color: var(--theia-secondaryButton-background); - color: var(--theia-secondaryButton-foreground); + background-color: var(--theia-secondaryButton-background); + color: var(--theia-secondaryButton-foreground); } button.theia-button.main { - color: var(--theia-button-foreground); + color: var(--theia-button-foreground); } /* To make the progress-bar slightly thicker, and use the color from the status bar */ .theia-progress-bar-container { - width: 100%; - height: 4px; + width: 100%; + height: 4px; } .theia-progress-bar { - height: 4px; - width: 3%; - animation: progress-animation 1.3s 0s infinite cubic-bezier(0.645, 0.045, 0.355, 1); + height: 4px; + width: 3%; + animation: progress-animation 1.3s 0s infinite + cubic-bezier(0.645, 0.045, 0.355, 1); } .theia-notification-item-progressbar { - height: 4px; - width: 66%; + height: 4px; + width: 66%; } .flex-line { - display: flex; - align-items: center; - white-space: nowrap; + display: flex; + align-items: center; + white-space: nowrap; } .fa-reload { - font-size: 14px; -} \ No newline at end of file + font-size: 14px; +} diff --git a/arduino-ide-extension/src/browser/style/user-fields-dialog.css b/arduino-ide-extension/src/browser/style/user-fields-dialog.css new file mode 100644 index 000000000..48e4960ca --- /dev/null +++ b/arduino-ide-extension/src/browser/style/user-fields-dialog.css @@ -0,0 +1,32 @@ +.user-fields-container { + max-height: 332px; + overflow: auto; + padding: 2px; +} + +.user-fields-list { + margin: 16px 0; +} + +.user-fields-dialog-content { + width: 408px; + max-height: 491px; +} + +.user-fields-dialog-content .field-label { + color: #2c353a; + font-size: 14px; + font-style: normal; + font-weight: 400; + line-height: 21px; + letter-spacing: 0.01em; + text-align: left; +} + +.user-fields-dialog-content .theia-input { + flex-grow: 1; +} + +.user-fields-dialog-content .button-container { + justify-content: flex-end; +} \ No newline at end of file diff --git a/arduino-ide-extension/src/common/protocol/boards-service.ts b/arduino-ide-extension/src/common/protocol/boards-service.ts index 714b00374..b0ef9fe75 100644 --- a/arduino-ide-extension/src/common/protocol/boards-service.ts +++ b/arduino-ide-extension/src/common/protocol/boards-service.ts @@ -143,6 +143,7 @@ export interface BoardsService fqbn: string; }): Promise; searchBoards({ query }: { query?: string }): Promise; + getBoardUserFields(options: { fqbn: string, protocol: string }): Promise; } export interface Port { @@ -251,6 +252,14 @@ export interface Board { readonly port?: Port; } +export interface BoardUserField { + readonly toolId: string; + readonly name: string; + readonly label: string; + readonly secret: boolean; + value: string; +} + export interface BoardWithPackage extends Board { readonly packageName: string; readonly packageId: string; diff --git a/arduino-ide-extension/src/common/protocol/core-service.ts b/arduino-ide-extension/src/common/protocol/core-service.ts index 7e252bc2a..f8216f504 100644 --- a/arduino-ide-extension/src/common/protocol/core-service.ts +++ b/arduino-ide-extension/src/common/protocol/core-service.ts @@ -1,3 +1,4 @@ +import { BoardUserField } from '.'; import { Port } from '../../common/protocol/boards-service'; import { Programmer } from './boards-service'; @@ -44,6 +45,7 @@ export namespace CoreService { readonly port?: Port | undefined; readonly programmer?: Programmer | undefined; readonly verify: boolean; + readonly userFields: BoardUserField[]; } } diff --git a/arduino-ide-extension/src/node/boards-service-impl.ts b/arduino-ide-extension/src/node/boards-service-impl.ts index 20dfdc6ef..acb4a7315 100644 --- a/arduino-ide-extension/src/node/boards-service-impl.ts +++ b/arduino-ide-extension/src/node/boards-service-impl.ts @@ -16,6 +16,7 @@ import { NotificationServiceServer, AvailablePorts, BoardWithPackage, + BoardUserField, } from '../common/protocol'; import { PlatformInstallRequest, @@ -36,6 +37,8 @@ import { import { ListProgrammersAvailableForUploadRequest, ListProgrammersAvailableForUploadResponse, + SupportedUserFieldsRequest, + SupportedUserFieldsResponse, } from './cli-protocol/cc/arduino/cli/commands/v1/upload_pb'; import { InstallWithProgress } from './grpc-installable'; @@ -244,6 +247,35 @@ export class BoardsServiceImpl return boards; } + async getBoardUserFields(options: { fqbn: string, protocol: string }): Promise { + await this.coreClientProvider.initialized; + const coreClient = await this.coreClient(); + const { client, instance } = coreClient; + + const supportedUserFieldsReq = new SupportedUserFieldsRequest(); + supportedUserFieldsReq.setInstance(instance); + supportedUserFieldsReq.setFqbn(options.fqbn); + supportedUserFieldsReq.setProtocol(options.protocol); + + const supportedUserFieldsResp = await new Promise( + (resolve, reject) => { + client.supportedUserFields(supportedUserFieldsReq, (err, resp) => { + (!!err ? reject : resolve)(!!err ? err : resp) + }) + } + ); + return supportedUserFieldsResp.getUserFieldsList().map(e => { + return { + toolId: e.getToolId(), + name: e.getName(), + label: e.getLabel(), + secret: e.getSecret(), + value: "", + }; + }); + } + + async search(options: { query?: string }): Promise { await this.coreClientProvider.initialized; const coreClient = await this.coreClient(); diff --git a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb.d.ts b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb.d.ts index 9f34ff24f..511bf22d1 100644 --- a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb.d.ts +++ b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb.d.ts @@ -12,7 +12,6 @@ import * as cc_arduino_cli_commands_v1_common_pb from "../../../../../cc/arduino import * as cc_arduino_cli_commands_v1_board_pb from "../../../../../cc/arduino/cli/commands/v1/board_pb"; import * as cc_arduino_cli_commands_v1_compile_pb from "../../../../../cc/arduino/cli/commands/v1/compile_pb"; import * as cc_arduino_cli_commands_v1_core_pb from "../../../../../cc/arduino/cli/commands/v1/core_pb"; -import * as cc_arduino_cli_commands_v1_monitor_pb from "../../../../../cc/arduino/cli/commands/v1/monitor_pb"; import * as cc_arduino_cli_commands_v1_upload_pb from "../../../../../cc/arduino/cli/commands/v1/upload_pb"; import * as cc_arduino_cli_commands_v1_lib_pb from "../../../../../cc/arduino/cli/commands/v1/lib_pb"; @@ -26,7 +25,6 @@ interface IArduinoCoreServiceService extends grpc.ServiceDefinition { @@ -141,15 +137,6 @@ interface IArduinoCoreServiceService_IVersion extends grpc.MethodDefinition; responseDeserialize: grpc.deserialize; } -interface IArduinoCoreServiceService_INewSketch extends grpc.MethodDefinition { - path: "/cc.arduino.cli.commands.v1.ArduinoCoreService/NewSketch"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} interface IArduinoCoreServiceService_ILoadSketch extends grpc.MethodDefinition { path: "/cc.arduino.cli.commands.v1.ArduinoCoreService/LoadSketch"; requestStream: false; @@ -411,24 +398,6 @@ interface IArduinoCoreServiceService_ILibraryList extends grpc.MethodDefinition< responseSerialize: grpc.serialize; responseDeserialize: grpc.deserialize; } -interface IArduinoCoreServiceService_IMonitor extends grpc.MethodDefinition { - path: "/cc.arduino.cli.commands.v1.ArduinoCoreService/Monitor"; - requestStream: true; - responseStream: true; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} -interface IArduinoCoreServiceService_IEnumerateMonitorPortSettings extends grpc.MethodDefinition { - path: "/cc.arduino.cli.commands.v1.ArduinoCoreService/EnumerateMonitorPortSettings"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} export const ArduinoCoreServiceService: IArduinoCoreServiceService; @@ -442,7 +411,6 @@ export interface IArduinoCoreServiceServer { outdated: grpc.handleUnaryCall; upgrade: grpc.handleServerStreamingCall; version: grpc.handleUnaryCall; - newSketch: grpc.handleUnaryCall; loadSketch: grpc.handleUnaryCall; archiveSketch: grpc.handleUnaryCall; boardDetails: grpc.handleUnaryCall; @@ -472,8 +440,6 @@ export interface IArduinoCoreServiceServer { libraryResolveDependencies: grpc.handleUnaryCall; librarySearch: grpc.handleUnaryCall; libraryList: grpc.handleUnaryCall; - monitor: grpc.handleBidiStreamingCall; - enumerateMonitorPortSettings: grpc.handleUnaryCall; } export interface IArduinoCoreServiceClient { @@ -499,9 +465,6 @@ export interface IArduinoCoreServiceClient { version(request: cc_arduino_cli_commands_v1_commands_pb.VersionRequest, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.VersionResponse) => void): grpc.ClientUnaryCall; version(request: cc_arduino_cli_commands_v1_commands_pb.VersionRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.VersionResponse) => void): grpc.ClientUnaryCall; version(request: cc_arduino_cli_commands_v1_commands_pb.VersionRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.VersionResponse) => void): grpc.ClientUnaryCall; - newSketch(request: cc_arduino_cli_commands_v1_commands_pb.NewSketchRequest, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.NewSketchResponse) => void): grpc.ClientUnaryCall; - newSketch(request: cc_arduino_cli_commands_v1_commands_pb.NewSketchRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.NewSketchResponse) => void): grpc.ClientUnaryCall; - newSketch(request: cc_arduino_cli_commands_v1_commands_pb.NewSketchRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.NewSketchResponse) => void): grpc.ClientUnaryCall; loadSketch(request: cc_arduino_cli_commands_v1_commands_pb.LoadSketchRequest, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.LoadSketchResponse) => void): grpc.ClientUnaryCall; loadSketch(request: cc_arduino_cli_commands_v1_commands_pb.LoadSketchRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.LoadSketchResponse) => void): grpc.ClientUnaryCall; loadSketch(request: cc_arduino_cli_commands_v1_commands_pb.LoadSketchRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.LoadSketchResponse) => void): grpc.ClientUnaryCall; @@ -574,12 +537,6 @@ export interface IArduinoCoreServiceClient { libraryList(request: cc_arduino_cli_commands_v1_lib_pb.LibraryListRequest, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_lib_pb.LibraryListResponse) => void): grpc.ClientUnaryCall; libraryList(request: cc_arduino_cli_commands_v1_lib_pb.LibraryListRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_lib_pb.LibraryListResponse) => void): grpc.ClientUnaryCall; libraryList(request: cc_arduino_cli_commands_v1_lib_pb.LibraryListRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_lib_pb.LibraryListResponse) => void): grpc.ClientUnaryCall; - monitor(): grpc.ClientDuplexStream; - monitor(options: Partial): grpc.ClientDuplexStream; - monitor(metadata: grpc.Metadata, options?: Partial): grpc.ClientDuplexStream; - enumerateMonitorPortSettings(request: cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsRequest, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsResponse) => void): grpc.ClientUnaryCall; - enumerateMonitorPortSettings(request: cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsResponse) => void): grpc.ClientUnaryCall; - enumerateMonitorPortSettings(request: cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsResponse) => void): grpc.ClientUnaryCall; } export class ArduinoCoreServiceClient extends grpc.Client implements IArduinoCoreServiceClient { @@ -606,9 +563,6 @@ export class ArduinoCoreServiceClient extends grpc.Client implements IArduinoCor public version(request: cc_arduino_cli_commands_v1_commands_pb.VersionRequest, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.VersionResponse) => void): grpc.ClientUnaryCall; public version(request: cc_arduino_cli_commands_v1_commands_pb.VersionRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.VersionResponse) => void): grpc.ClientUnaryCall; public version(request: cc_arduino_cli_commands_v1_commands_pb.VersionRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.VersionResponse) => void): grpc.ClientUnaryCall; - public newSketch(request: cc_arduino_cli_commands_v1_commands_pb.NewSketchRequest, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.NewSketchResponse) => void): grpc.ClientUnaryCall; - public newSketch(request: cc_arduino_cli_commands_v1_commands_pb.NewSketchRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.NewSketchResponse) => void): grpc.ClientUnaryCall; - public newSketch(request: cc_arduino_cli_commands_v1_commands_pb.NewSketchRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.NewSketchResponse) => void): grpc.ClientUnaryCall; public loadSketch(request: cc_arduino_cli_commands_v1_commands_pb.LoadSketchRequest, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.LoadSketchResponse) => void): grpc.ClientUnaryCall; public loadSketch(request: cc_arduino_cli_commands_v1_commands_pb.LoadSketchRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.LoadSketchResponse) => void): grpc.ClientUnaryCall; public loadSketch(request: cc_arduino_cli_commands_v1_commands_pb.LoadSketchRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_commands_pb.LoadSketchResponse) => void): grpc.ClientUnaryCall; @@ -680,9 +634,4 @@ export class ArduinoCoreServiceClient extends grpc.Client implements IArduinoCor public libraryList(request: cc_arduino_cli_commands_v1_lib_pb.LibraryListRequest, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_lib_pb.LibraryListResponse) => void): grpc.ClientUnaryCall; public libraryList(request: cc_arduino_cli_commands_v1_lib_pb.LibraryListRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_lib_pb.LibraryListResponse) => void): grpc.ClientUnaryCall; public libraryList(request: cc_arduino_cli_commands_v1_lib_pb.LibraryListRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_lib_pb.LibraryListResponse) => void): grpc.ClientUnaryCall; - public monitor(options?: Partial): grpc.ClientDuplexStream; - public monitor(metadata?: grpc.Metadata, options?: Partial): grpc.ClientDuplexStream; - public enumerateMonitorPortSettings(request: cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsRequest, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsResponse) => void): grpc.ClientUnaryCall; - public enumerateMonitorPortSettings(request: cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsResponse) => void): grpc.ClientUnaryCall; - public enumerateMonitorPortSettings(request: cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsResponse) => void): grpc.ClientUnaryCall; } diff --git a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb.js b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb.js index 8358c89e2..182fd17f4 100644 --- a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb.js +++ b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb.js @@ -23,7 +23,6 @@ var cc_arduino_cli_commands_v1_common_pb = require('../../../../../cc/arduino/cl var cc_arduino_cli_commands_v1_board_pb = require('../../../../../cc/arduino/cli/commands/v1/board_pb.js'); var cc_arduino_cli_commands_v1_compile_pb = require('../../../../../cc/arduino/cli/commands/v1/compile_pb.js'); var cc_arduino_cli_commands_v1_core_pb = require('../../../../../cc/arduino/cli/commands/v1/core_pb.js'); -var cc_arduino_cli_commands_v1_monitor_pb = require('../../../../../cc/arduino/cli/commands/v1/monitor_pb.js'); var cc_arduino_cli_commands_v1_upload_pb = require('../../../../../cc/arduino/cli/commands/v1/upload_pb.js'); var cc_arduino_cli_commands_v1_lib_pb = require('../../../../../cc/arduino/cli/commands/v1/lib_pb.js'); @@ -269,28 +268,6 @@ function deserialize_cc_arduino_cli_commands_v1_DestroyResponse(buffer_arg) { return cc_arduino_cli_commands_v1_commands_pb.DestroyResponse.deserializeBinary(new Uint8Array(buffer_arg)); } -function serialize_cc_arduino_cli_commands_v1_EnumerateMonitorPortSettingsRequest(arg) { - if (!(arg instanceof cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsRequest)) { - throw new Error('Expected argument of type cc.arduino.cli.commands.v1.EnumerateMonitorPortSettingsRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_cc_arduino_cli_commands_v1_EnumerateMonitorPortSettingsRequest(buffer_arg) { - return cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_cc_arduino_cli_commands_v1_EnumerateMonitorPortSettingsResponse(arg) { - if (!(arg instanceof cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsResponse)) { - throw new Error('Expected argument of type cc.arduino.cli.commands.v1.EnumerateMonitorPortSettingsResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_cc_arduino_cli_commands_v1_EnumerateMonitorPortSettingsResponse(buffer_arg) { - return cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - function serialize_cc_arduino_cli_commands_v1_GitLibraryInstallRequest(arg) { if (!(arg instanceof cc_arduino_cli_commands_v1_lib_pb.GitLibraryInstallRequest)) { throw new Error('Expected argument of type cc.arduino.cli.commands.v1.GitLibraryInstallRequest'); @@ -533,50 +510,6 @@ function deserialize_cc_arduino_cli_commands_v1_LoadSketchResponse(buffer_arg) { return cc_arduino_cli_commands_v1_commands_pb.LoadSketchResponse.deserializeBinary(new Uint8Array(buffer_arg)); } -function serialize_cc_arduino_cli_commands_v1_MonitorRequest(arg) { - if (!(arg instanceof cc_arduino_cli_commands_v1_monitor_pb.MonitorRequest)) { - throw new Error('Expected argument of type cc.arduino.cli.commands.v1.MonitorRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_cc_arduino_cli_commands_v1_MonitorRequest(buffer_arg) { - return cc_arduino_cli_commands_v1_monitor_pb.MonitorRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_cc_arduino_cli_commands_v1_MonitorResponse(arg) { - if (!(arg instanceof cc_arduino_cli_commands_v1_monitor_pb.MonitorResponse)) { - throw new Error('Expected argument of type cc.arduino.cli.commands.v1.MonitorResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_cc_arduino_cli_commands_v1_MonitorResponse(buffer_arg) { - return cc_arduino_cli_commands_v1_monitor_pb.MonitorResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_cc_arduino_cli_commands_v1_NewSketchRequest(arg) { - if (!(arg instanceof cc_arduino_cli_commands_v1_commands_pb.NewSketchRequest)) { - throw new Error('Expected argument of type cc.arduino.cli.commands.v1.NewSketchRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_cc_arduino_cli_commands_v1_NewSketchRequest(buffer_arg) { - return cc_arduino_cli_commands_v1_commands_pb.NewSketchRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_cc_arduino_cli_commands_v1_NewSketchResponse(arg) { - if (!(arg instanceof cc_arduino_cli_commands_v1_commands_pb.NewSketchResponse)) { - throw new Error('Expected argument of type cc.arduino.cli.commands.v1.NewSketchResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_cc_arduino_cli_commands_v1_NewSketchResponse(buffer_arg) { - return cc_arduino_cli_commands_v1_commands_pb.NewSketchResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - function serialize_cc_arduino_cli_commands_v1_OutdatedRequest(arg) { if (!(arg instanceof cc_arduino_cli_commands_v1_commands_pb.OutdatedRequest)) { throw new Error('Expected argument of type cc.arduino.cli.commands.v1.OutdatedRequest'); @@ -1041,18 +974,6 @@ version: { responseSerialize: serialize_cc_arduino_cli_commands_v1_VersionResponse, responseDeserialize: deserialize_cc_arduino_cli_commands_v1_VersionResponse, }, - // Create a new Sketch -newSketch: { - path: '/cc.arduino.cli.commands.v1.ArduinoCoreService/NewSketch', - requestStream: false, - responseStream: false, - requestType: cc_arduino_cli_commands_v1_commands_pb.NewSketchRequest, - responseType: cc_arduino_cli_commands_v1_commands_pb.NewSketchResponse, - requestSerialize: serialize_cc_arduino_cli_commands_v1_NewSketchRequest, - requestDeserialize: deserialize_cc_arduino_cli_commands_v1_NewSketchRequest, - responseSerialize: serialize_cc_arduino_cli_commands_v1_NewSketchResponse, - responseDeserialize: deserialize_cc_arduino_cli_commands_v1_NewSketchResponse, - }, // Returns all files composing a Sketch loadSketch: { path: '/cc.arduino.cli.commands.v1.ArduinoCoreService/LoadSketch', @@ -1410,30 +1331,6 @@ libraryList: { responseSerialize: serialize_cc_arduino_cli_commands_v1_LibraryListResponse, responseDeserialize: deserialize_cc_arduino_cli_commands_v1_LibraryListResponse, }, - // Open a monitor connection to a board port -monitor: { - path: '/cc.arduino.cli.commands.v1.ArduinoCoreService/Monitor', - requestStream: true, - responseStream: true, - requestType: cc_arduino_cli_commands_v1_monitor_pb.MonitorRequest, - responseType: cc_arduino_cli_commands_v1_monitor_pb.MonitorResponse, - requestSerialize: serialize_cc_arduino_cli_commands_v1_MonitorRequest, - requestDeserialize: deserialize_cc_arduino_cli_commands_v1_MonitorRequest, - responseSerialize: serialize_cc_arduino_cli_commands_v1_MonitorResponse, - responseDeserialize: deserialize_cc_arduino_cli_commands_v1_MonitorResponse, - }, - // Returns the parameters that can be set in the MonitorRequest calls -enumerateMonitorPortSettings: { - path: '/cc.arduino.cli.commands.v1.ArduinoCoreService/EnumerateMonitorPortSettings', - requestStream: false, - responseStream: false, - requestType: cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsRequest, - responseType: cc_arduino_cli_commands_v1_monitor_pb.EnumerateMonitorPortSettingsResponse, - requestSerialize: serialize_cc_arduino_cli_commands_v1_EnumerateMonitorPortSettingsRequest, - requestDeserialize: deserialize_cc_arduino_cli_commands_v1_EnumerateMonitorPortSettingsRequest, - responseSerialize: serialize_cc_arduino_cli_commands_v1_EnumerateMonitorPortSettingsResponse, - responseDeserialize: deserialize_cc_arduino_cli_commands_v1_EnumerateMonitorPortSettingsResponse, - }, }; // BOOTSTRAP COMMANDS diff --git a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.d.ts b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.d.ts index 94ceab14f..f1f2e7ae6 100644 --- a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.d.ts +++ b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.d.ts @@ -10,7 +10,6 @@ import * as cc_arduino_cli_commands_v1_common_pb from "../../../../../cc/arduino import * as cc_arduino_cli_commands_v1_board_pb from "../../../../../cc/arduino/cli/commands/v1/board_pb"; import * as cc_arduino_cli_commands_v1_compile_pb from "../../../../../cc/arduino/cli/commands/v1/compile_pb"; import * as cc_arduino_cli_commands_v1_core_pb from "../../../../../cc/arduino/cli/commands/v1/core_pb"; -import * as cc_arduino_cli_commands_v1_monitor_pb from "../../../../../cc/arduino/cli/commands/v1/monitor_pb"; import * as cc_arduino_cli_commands_v1_upload_pb from "../../../../../cc/arduino/cli/commands/v1/upload_pb"; import * as cc_arduino_cli_commands_v1_lib_pb from "../../../../../cc/arduino/cli/commands/v1/lib_pb"; @@ -490,59 +489,6 @@ export namespace VersionResponse { } } -export class NewSketchRequest extends jspb.Message { - - hasInstance(): boolean; - clearInstance(): void; - getInstance(): cc_arduino_cli_commands_v1_common_pb.Instance | undefined; - setInstance(value?: cc_arduino_cli_commands_v1_common_pb.Instance): NewSketchRequest; - - getSketchName(): string; - setSketchName(value: string): NewSketchRequest; - - getSketchDir(): string; - setSketchDir(value: string): NewSketchRequest; - - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): NewSketchRequest.AsObject; - static toObject(includeInstance: boolean, msg: NewSketchRequest): NewSketchRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: NewSketchRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): NewSketchRequest; - static deserializeBinaryFromReader(message: NewSketchRequest, reader: jspb.BinaryReader): NewSketchRequest; -} - -export namespace NewSketchRequest { - export type AsObject = { - instance?: cc_arduino_cli_commands_v1_common_pb.Instance.AsObject, - sketchName: string, - sketchDir: string, - } -} - -export class NewSketchResponse extends jspb.Message { - getMainFile(): string; - setMainFile(value: string): NewSketchResponse; - - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): NewSketchResponse.AsObject; - static toObject(includeInstance: boolean, msg: NewSketchResponse): NewSketchResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: NewSketchResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): NewSketchResponse; - static deserializeBinaryFromReader(message: NewSketchResponse, reader: jspb.BinaryReader): NewSketchResponse; -} - -export namespace NewSketchResponse { - export type AsObject = { - mainFile: string, - } -} - export class LoadSketchRequest extends jspb.Message { hasInstance(): boolean; diff --git a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.js b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.js index 1937aa229..8f9cb0b78 100644 --- a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.js +++ b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.js @@ -25,8 +25,6 @@ var cc_arduino_cli_commands_v1_compile_pb = require('../../../../../cc/arduino/c goog.object.extend(proto, cc_arduino_cli_commands_v1_compile_pb); var cc_arduino_cli_commands_v1_core_pb = require('../../../../../cc/arduino/cli/commands/v1/core_pb.js'); goog.object.extend(proto, cc_arduino_cli_commands_v1_core_pb); -var cc_arduino_cli_commands_v1_monitor_pb = require('../../../../../cc/arduino/cli/commands/v1/monitor_pb.js'); -goog.object.extend(proto, cc_arduino_cli_commands_v1_monitor_pb); var cc_arduino_cli_commands_v1_upload_pb = require('../../../../../cc/arduino/cli/commands/v1/upload_pb.js'); goog.object.extend(proto, cc_arduino_cli_commands_v1_upload_pb); var cc_arduino_cli_commands_v1_lib_pb = require('../../../../../cc/arduino/cli/commands/v1/lib_pb.js'); @@ -43,8 +41,6 @@ goog.exportSymbol('proto.cc.arduino.cli.commands.v1.InitResponse.MessageCase', n goog.exportSymbol('proto.cc.arduino.cli.commands.v1.InitResponse.Progress', null, global); goog.exportSymbol('proto.cc.arduino.cli.commands.v1.LoadSketchRequest', null, global); goog.exportSymbol('proto.cc.arduino.cli.commands.v1.LoadSketchResponse', null, global); -goog.exportSymbol('proto.cc.arduino.cli.commands.v1.NewSketchRequest', null, global); -goog.exportSymbol('proto.cc.arduino.cli.commands.v1.NewSketchResponse', null, global); goog.exportSymbol('proto.cc.arduino.cli.commands.v1.OutdatedRequest', null, global); goog.exportSymbol('proto.cc.arduino.cli.commands.v1.OutdatedResponse', null, global); goog.exportSymbol('proto.cc.arduino.cli.commands.v1.UpdateCoreLibrariesIndexRequest', null, global); @@ -456,48 +452,6 @@ if (goog.DEBUG && !COMPILED) { */ proto.cc.arduino.cli.commands.v1.VersionResponse.displayName = 'proto.cc.arduino.cli.commands.v1.VersionResponse'; } -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.cc.arduino.cli.commands.v1.NewSketchRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.cc.arduino.cli.commands.v1.NewSketchRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.cc.arduino.cli.commands.v1.NewSketchRequest.displayName = 'proto.cc.arduino.cli.commands.v1.NewSketchRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.cc.arduino.cli.commands.v1.NewSketchResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.cc.arduino.cli.commands.v1.NewSketchResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.cc.arduino.cli.commands.v1.NewSketchResponse.displayName = 'proto.cc.arduino.cli.commands.v1.NewSketchResponse'; -} /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -3554,347 +3508,6 @@ proto.cc.arduino.cli.commands.v1.VersionResponse.prototype.setVersion = function -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.cc.arduino.cli.commands.v1.NewSketchRequest.prototype.toObject = function(opt_includeInstance) { - return proto.cc.arduino.cli.commands.v1.NewSketchRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.cc.arduino.cli.commands.v1.NewSketchRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.cc.arduino.cli.commands.v1.NewSketchRequest.toObject = function(includeInstance, msg) { - var f, obj = { - instance: (f = msg.getInstance()) && cc_arduino_cli_commands_v1_common_pb.Instance.toObject(includeInstance, f), - sketchName: jspb.Message.getFieldWithDefault(msg, 2, ""), - sketchDir: jspb.Message.getFieldWithDefault(msg, 3, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.cc.arduino.cli.commands.v1.NewSketchRequest} - */ -proto.cc.arduino.cli.commands.v1.NewSketchRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.cc.arduino.cli.commands.v1.NewSketchRequest; - return proto.cc.arduino.cli.commands.v1.NewSketchRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.cc.arduino.cli.commands.v1.NewSketchRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.cc.arduino.cli.commands.v1.NewSketchRequest} - */ -proto.cc.arduino.cli.commands.v1.NewSketchRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new cc_arduino_cli_commands_v1_common_pb.Instance; - reader.readMessage(value,cc_arduino_cli_commands_v1_common_pb.Instance.deserializeBinaryFromReader); - msg.setInstance(value); - break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setSketchName(value); - break; - case 3: - var value = /** @type {string} */ (reader.readString()); - msg.setSketchDir(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.cc.arduino.cli.commands.v1.NewSketchRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.cc.arduino.cli.commands.v1.NewSketchRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.cc.arduino.cli.commands.v1.NewSketchRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.cc.arduino.cli.commands.v1.NewSketchRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getInstance(); - if (f != null) { - writer.writeMessage( - 1, - f, - cc_arduino_cli_commands_v1_common_pb.Instance.serializeBinaryToWriter - ); - } - f = message.getSketchName(); - if (f.length > 0) { - writer.writeString( - 2, - f - ); - } - f = message.getSketchDir(); - if (f.length > 0) { - writer.writeString( - 3, - f - ); - } -}; - - -/** - * optional Instance instance = 1; - * @return {?proto.cc.arduino.cli.commands.v1.Instance} - */ -proto.cc.arduino.cli.commands.v1.NewSketchRequest.prototype.getInstance = function() { - return /** @type{?proto.cc.arduino.cli.commands.v1.Instance} */ ( - jspb.Message.getWrapperField(this, cc_arduino_cli_commands_v1_common_pb.Instance, 1)); -}; - - -/** - * @param {?proto.cc.arduino.cli.commands.v1.Instance|undefined} value - * @return {!proto.cc.arduino.cli.commands.v1.NewSketchRequest} returns this -*/ -proto.cc.arduino.cli.commands.v1.NewSketchRequest.prototype.setInstance = function(value) { - return jspb.Message.setWrapperField(this, 1, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.cc.arduino.cli.commands.v1.NewSketchRequest} returns this - */ -proto.cc.arduino.cli.commands.v1.NewSketchRequest.prototype.clearInstance = function() { - return this.setInstance(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.cc.arduino.cli.commands.v1.NewSketchRequest.prototype.hasInstance = function() { - return jspb.Message.getField(this, 1) != null; -}; - - -/** - * optional string sketch_name = 2; - * @return {string} - */ -proto.cc.arduino.cli.commands.v1.NewSketchRequest.prototype.getSketchName = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); -}; - - -/** - * @param {string} value - * @return {!proto.cc.arduino.cli.commands.v1.NewSketchRequest} returns this - */ -proto.cc.arduino.cli.commands.v1.NewSketchRequest.prototype.setSketchName = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); -}; - - -/** - * optional string sketch_dir = 3; - * @return {string} - */ -proto.cc.arduino.cli.commands.v1.NewSketchRequest.prototype.getSketchDir = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); -}; - - -/** - * @param {string} value - * @return {!proto.cc.arduino.cli.commands.v1.NewSketchRequest} returns this - */ -proto.cc.arduino.cli.commands.v1.NewSketchRequest.prototype.setSketchDir = function(value) { - return jspb.Message.setProto3StringField(this, 3, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.cc.arduino.cli.commands.v1.NewSketchResponse.prototype.toObject = function(opt_includeInstance) { - return proto.cc.arduino.cli.commands.v1.NewSketchResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.cc.arduino.cli.commands.v1.NewSketchResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.cc.arduino.cli.commands.v1.NewSketchResponse.toObject = function(includeInstance, msg) { - var f, obj = { - mainFile: jspb.Message.getFieldWithDefault(msg, 1, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.cc.arduino.cli.commands.v1.NewSketchResponse} - */ -proto.cc.arduino.cli.commands.v1.NewSketchResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.cc.arduino.cli.commands.v1.NewSketchResponse; - return proto.cc.arduino.cli.commands.v1.NewSketchResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.cc.arduino.cli.commands.v1.NewSketchResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.cc.arduino.cli.commands.v1.NewSketchResponse} - */ -proto.cc.arduino.cli.commands.v1.NewSketchResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setMainFile(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.cc.arduino.cli.commands.v1.NewSketchResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.cc.arduino.cli.commands.v1.NewSketchResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.cc.arduino.cli.commands.v1.NewSketchResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.cc.arduino.cli.commands.v1.NewSketchResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getMainFile(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } -}; - - -/** - * optional string main_file = 1; - * @return {string} - */ -proto.cc.arduino.cli.commands.v1.NewSketchResponse.prototype.getMainFile = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.cc.arduino.cli.commands.v1.NewSketchResponse} returns this - */ -proto.cc.arduino.cli.commands.v1.NewSketchResponse.prototype.setMainFile = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - - - - if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. diff --git a/arduino-ide-extension/src/node/core-service-impl.ts b/arduino-ide-extension/src/node/core-service-impl.ts index f5ebe270c..59535662b 100644 --- a/arduino-ide-extension/src/node/core-service-impl.ts +++ b/arduino-ide-extension/src/node/core-service-impl.ts @@ -153,6 +153,11 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService { } req.setVerbose(options.verbose); req.setVerify(options.verify); + + options.userFields.forEach(e => { + req.getUserFieldsMap().set(e.name, e.value); + }); + const result = responseHandler(client, req); try { diff --git a/i18n/en.json b/i18n/en.json index 0e3c12b68..8b8a06495 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -180,8 +180,10 @@ "sketchbook": "Sketchbook", "upload": "Upload", "uploadUsingProgrammer": "Upload Using Programmer", + "userFieldsNotFoundError": "Can't find user fields for connected board", "doneUploading": "Done uploading.", "couldNotConnectToSerial": "Could not reconnect to serial port. {0}", + "configureAndUpload": "Configure And Upload", "verifyOrCompile": "Verify/Compile", "exportBinary": "Export Compiled Binary", "verify": "Verify", @@ -255,6 +257,10 @@ "dialog": { "dontAskAgain": "Don't ask again" }, + "userFields": { + "cancel": "Cancel", + "upload": "Upload" + }, "serial": { "toggleTimestamp": "Toggle Timestamp", "autoscroll": "Autoscroll", diff --git a/yarn.lock b/yarn.lock index dee18a725..36bc181db 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4109,10 +4109,10 @@ archive-type@^4.0.0: dependencies: file-type "^4.2.0" -arduino-serial-plotter-webapp@0.0.13: - version "0.0.13" - resolved "https://registry.yarnpkg.com/arduino-serial-plotter-webapp/-/arduino-serial-plotter-webapp-0.0.13.tgz#b8d943a39f2c218bca36bb81bb6c5cabe4695ad7" - integrity sha512-Rn1shl6c1pUt1vtcdsAzhHIlHuHAmC829z0nR4JW4mYdYA+1MEY2VbbhfDf/tXiAFm8XAGfH63f//h1t99eGWQ== +arduino-serial-plotter-webapp@0.0.15: + version "0.0.15" + resolved "https://registry.yarnpkg.com/arduino-serial-plotter-webapp/-/arduino-serial-plotter-webapp-0.0.15.tgz#dfb7007ccf76a783fe9704e397bba1a00353ade1" + integrity sha512-LEftjqdCNS1TbezYIaWeMrM7KreKuOg2bY5cFd0nayKMVRV2A/ieldwvHUzYZSDJ6xyNhBddcmjMRU87vDJ0mw== are-we-there-yet@~1.1.2: version "1.1.5"