a few bugfixes. updated grpc dependencies.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta 2019-11-30 18:39:09 +01:00
parent eb7b3ad683
commit 80549db289
13 changed files with 769 additions and 71 deletions

View File

@ -7,7 +7,7 @@
"node": ">=10.10.0"
},
"dependencies": {
"@grpc/grpc-js": "^0.4.0",
"@grpc/grpc-js": "^0.6.12",
"@theia/application-package": "next",
"@theia/core": "next",
"@theia/cpp": "next",
@ -56,8 +56,8 @@
"decompress-targz": "^4.1.1",
"decompress-unzip": "^4.0.1",
"download": "^7.1.0",
"grpc-tools": "^1.7.3",
"grpc_tools_node_protoc_ts": "^2.5.0",
"grpc-tools": "^1.8.0",
"grpc_tools_node_protoc_ts": "^2.5.8",
"moment": "^2.24.0",
"ncp": "^2.0.0",
"rimraf": "^2.6.1",

View File

@ -171,6 +171,7 @@ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Un
// Serial Monitor
bind(MonitorModel).toSelf().inSingletonScope();
bind(FrontendApplicationContribution).toService(MonitorModel);
bind(MonitorWidget).toSelf();
bindViewContribution(bind, MonitorViewContribution);
bind(TabBarToolbarContribution).toService(MonitorViewContribution);

View File

@ -96,11 +96,11 @@ export class MonitorConnection {
const result = await this.monitorService.disconnect(this.state.connectionId);
if (result) {
console.log(`<<< Disposed connection. Was: ${MonitorConnection.State.toString(this.state)}`);
this.state = undefined;
this.onConnectionChangedEmitter.fire(undefined);
} else {
console.warn(`<<< Could not dispose connection. Activate connection: ${MonitorConnection.State.toString(this.state)}`);
}
this.state = undefined;
this.onConnectionChangedEmitter.fire(undefined);
return result;
}

View File

@ -1,9 +1,15 @@
import { injectable } from 'inversify';
import { injectable, inject } from 'inversify';
import { Emitter, Event } from '@theia/core/lib/common/event';
import { MonitorConfig } from '../../common/protocol/monitor-service';
import { FrontendApplicationContribution, LocalStorageService } from '@theia/core/lib/browser';
@injectable()
export class MonitorModel {
export class MonitorModel implements FrontendApplicationContribution {
protected static STORAGE_ID = 'arduino-monitor-model';
@inject(LocalStorageService)
protected readonly localStorageService: LocalStorageService;
protected readonly onChangeEmitter: Emitter<void>;
protected _autoscroll: boolean;
@ -19,6 +25,14 @@ export class MonitorModel {
this.onChangeEmitter = new Emitter<void>();
}
onStart(): void {
this.localStorageService.getData<MonitorModel.State>(MonitorModel.STORAGE_ID).then(state => {
if (state) {
this.restoreState(state);
}
});
}
get onChange(): Event<void> {
return this.onChangeEmitter.event;
}
@ -29,6 +43,7 @@ export class MonitorModel {
toggleAutoscroll(): void {
this._autoscroll = !this._autoscroll;
this.storeState();
}
get timestamp(): boolean {
@ -37,6 +52,7 @@ export class MonitorModel {
toggleTimestamp(): void {
this._timestamp = !this._timestamp;
this.storeState();
}
get baudRate(): MonitorConfig.BaudRate {
@ -45,7 +61,7 @@ export class MonitorModel {
set baudRate(baudRate: MonitorConfig.BaudRate) {
this._baudRate = baudRate;
this.onChangeEmitter.fire(undefined);
this.storeState().then(() => this.onChangeEmitter.fire(undefined));
}
get lineEnding(): MonitorModel.EOL {
@ -54,10 +70,10 @@ export class MonitorModel {
set lineEnding(lineEnding: MonitorModel.EOL) {
this._lineEnding = lineEnding;
this.onChangeEmitter.fire(undefined);
this.storeState().then(() => this.onChangeEmitter.fire(undefined));
}
restore(state: MonitorModel.State) {
protected restoreState(state: MonitorModel.State) {
this._autoscroll = state.autoscroll;
this._timestamp = state.timestamp;
this._baudRate = state.baudRate;
@ -65,13 +81,13 @@ export class MonitorModel {
this.onChangeEmitter.fire(undefined);
}
store(): MonitorModel.State {
return {
protected async storeState(): Promise<void> {
this.localStorageService.setData(MonitorModel.STORAGE_ID, {
autoscroll: this._autoscroll,
timestamp: this._timestamp,
baudRate: this._baudRate,
lineEnding: this._lineEnding
}
});
}
}

View File

@ -54,7 +54,7 @@ export class MonitorViewContribution extends AbstractViewContribution<MonitorWid
}
}
async registerToolbarItems(registry: TabBarToolbarRegistry) {
registerToolbarItems(registry: TabBarToolbarRegistry): void {
registry.registerItem({
id: 'monitor-autoscroll',
render: () => this.renderAutoScrollButton(),
@ -106,7 +106,7 @@ export class MonitorViewContribution extends AbstractViewContribution<MonitorWid
}
protected readonly toggleAutoScroll = () => this.doToggleAutoScroll();
protected async doToggleAutoScroll() {
protected async doToggleAutoScroll(): Promise<void> {
this.model.toggleAutoscroll();
}
@ -121,7 +121,7 @@ export class MonitorViewContribution extends AbstractViewContribution<MonitorWid
}
protected readonly toggleTimestamp = () => this.doToggleTimestamp();
protected async doToggleTimestamp() {
protected async doToggleTimestamp(): Promise<void> {
this.model.toggleTimestamp();
}

View File

@ -6,7 +6,7 @@ import { OptionsType } from 'react-select/src/types';
import Select from 'react-select';
import { Styles } from 'react-select/src/styles';
import { MessageService } from '@theia/core/lib/common/message-service';
import { ReactWidget, Message, Widget, StatefulWidget } from '@theia/core/lib/browser';
import { ReactWidget, Message, Widget } from '@theia/core/lib/browser';
import { MonitorServiceClientImpl } from './monitor-service-client-impl';
import { MonitorConfig, MonitorService } from '../../common/protocol/monitor-service';
import { AttachedSerialBoard, BoardsService } from '../../common/protocol/boards-service';
@ -111,7 +111,7 @@ export interface SelectOption<T> {
}
@injectable()
export class MonitorWidget extends ReactWidget implements StatefulWidget {
export class MonitorWidget extends ReactWidget {
static readonly ID = 'serial-monitor';
@ -155,7 +155,6 @@ export class MonitorWidget extends ReactWidget implements StatefulWidget {
this.lines = [];
this.chunk = '';
this.scrollOptions = undefined;
// TODO onError
}
@postConstruct()
@ -176,6 +175,7 @@ export class MonitorWidget extends ReactWidget implements StatefulWidget {
if (selectedBoard && selectedPort) {
this.boardsService.getAttachedBoards().then(({ boards }) => {
if (boards.filter(AttachedSerialBoard.is).some(board => BoardsConfig.Config.sameAs(config, board))) {
this.clearConsole();
this.connect();
}
});
@ -190,14 +190,6 @@ export class MonitorWidget extends ReactWidget implements StatefulWidget {
this.update();
}
storeState(): MonitorModel.State {
return this.model.store();
}
restoreState(oldState: MonitorModel.State): void {
this.model.restore(oldState);
}
onBeforeAttach(msg: Message): void {
super.onBeforeAttach(msg);
this.clearConsole();

View File

@ -69,6 +69,6 @@ export namespace MonitorError {
/**
* Another serial monitor was opened on this port. For another electron-instance, Java IDE.
*/
export const interrupted_system_call = 3;
export const interrupted_system_call = 4;
}
}

View File

@ -36,6 +36,7 @@ interface IArduinoCoreService extends grpc.ServiceDefinition<grpc.UntypedService
libraryInstall: IArduinoCoreService_ILibraryInstall;
libraryUninstall: IArduinoCoreService_ILibraryUninstall;
libraryUpgradeAll: IArduinoCoreService_ILibraryUpgradeAll;
libraryResolveDependencies: IArduinoCoreService_ILibraryResolveDependencies;
librarySearch: IArduinoCoreService_ILibrarySearch;
libraryList: IArduinoCoreService_ILibraryList;
}
@ -238,6 +239,15 @@ interface IArduinoCoreService_ILibraryUpgradeAll extends grpc.MethodDefinition<c
responseSerialize: grpc.serialize<commands_lib_pb.LibraryUpgradeAllResp>;
responseDeserialize: grpc.deserialize<commands_lib_pb.LibraryUpgradeAllResp>;
}
interface IArduinoCoreService_ILibraryResolveDependencies extends grpc.MethodDefinition<commands_lib_pb.LibraryResolveDependenciesReq, commands_lib_pb.LibraryResolveDependenciesResp> {
path: string; // "/cc.arduino.cli.commands.ArduinoCore/LibraryResolveDependencies"
requestStream: boolean; // false
responseStream: boolean; // false
requestSerialize: grpc.serialize<commands_lib_pb.LibraryResolveDependenciesReq>;
requestDeserialize: grpc.deserialize<commands_lib_pb.LibraryResolveDependenciesReq>;
responseSerialize: grpc.serialize<commands_lib_pb.LibraryResolveDependenciesResp>;
responseDeserialize: grpc.deserialize<commands_lib_pb.LibraryResolveDependenciesResp>;
}
interface IArduinoCoreService_ILibrarySearch extends grpc.MethodDefinition<commands_lib_pb.LibrarySearchReq, commands_lib_pb.LibrarySearchResp> {
path: string; // "/cc.arduino.cli.commands.ArduinoCore/LibrarySearch"
requestStream: boolean; // false
@ -282,6 +292,7 @@ export interface IArduinoCoreServer {
libraryInstall: grpc.handleServerStreamingCall<commands_lib_pb.LibraryInstallReq, commands_lib_pb.LibraryInstallResp>;
libraryUninstall: grpc.handleServerStreamingCall<commands_lib_pb.LibraryUninstallReq, commands_lib_pb.LibraryUninstallResp>;
libraryUpgradeAll: grpc.handleServerStreamingCall<commands_lib_pb.LibraryUpgradeAllReq, commands_lib_pb.LibraryUpgradeAllResp>;
libraryResolveDependencies: grpc.handleUnaryCall<commands_lib_pb.LibraryResolveDependenciesReq, commands_lib_pb.LibraryResolveDependenciesResp>;
librarySearch: grpc.handleUnaryCall<commands_lib_pb.LibrarySearchReq, commands_lib_pb.LibrarySearchResp>;
libraryList: grpc.handleUnaryCall<commands_lib_pb.LibraryListReq, commands_lib_pb.LibraryListResp>;
}
@ -339,6 +350,9 @@ export interface IArduinoCoreClient {
libraryUninstall(request: commands_lib_pb.LibraryUninstallReq, metadata?: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<commands_lib_pb.LibraryUninstallResp>;
libraryUpgradeAll(request: commands_lib_pb.LibraryUpgradeAllReq, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<commands_lib_pb.LibraryUpgradeAllResp>;
libraryUpgradeAll(request: commands_lib_pb.LibraryUpgradeAllReq, metadata?: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<commands_lib_pb.LibraryUpgradeAllResp>;
libraryResolveDependencies(request: commands_lib_pb.LibraryResolveDependenciesReq, callback: (error: grpc.ServiceError | null, response: commands_lib_pb.LibraryResolveDependenciesResp) => void): grpc.ClientUnaryCall;
libraryResolveDependencies(request: commands_lib_pb.LibraryResolveDependenciesReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: commands_lib_pb.LibraryResolveDependenciesResp) => void): grpc.ClientUnaryCall;
libraryResolveDependencies(request: commands_lib_pb.LibraryResolveDependenciesReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: commands_lib_pb.LibraryResolveDependenciesResp) => void): grpc.ClientUnaryCall;
librarySearch(request: commands_lib_pb.LibrarySearchReq, callback: (error: grpc.ServiceError | null, response: commands_lib_pb.LibrarySearchResp) => void): grpc.ClientUnaryCall;
librarySearch(request: commands_lib_pb.LibrarySearchReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: commands_lib_pb.LibrarySearchResp) => void): grpc.ClientUnaryCall;
librarySearch(request: commands_lib_pb.LibrarySearchReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: commands_lib_pb.LibrarySearchResp) => void): grpc.ClientUnaryCall;
@ -401,6 +415,9 @@ export class ArduinoCoreClient extends grpc.Client implements IArduinoCoreClient
public libraryUninstall(request: commands_lib_pb.LibraryUninstallReq, metadata?: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<commands_lib_pb.LibraryUninstallResp>;
public libraryUpgradeAll(request: commands_lib_pb.LibraryUpgradeAllReq, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<commands_lib_pb.LibraryUpgradeAllResp>;
public libraryUpgradeAll(request: commands_lib_pb.LibraryUpgradeAllReq, metadata?: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<commands_lib_pb.LibraryUpgradeAllResp>;
public libraryResolveDependencies(request: commands_lib_pb.LibraryResolveDependenciesReq, callback: (error: grpc.ServiceError | null, response: commands_lib_pb.LibraryResolveDependenciesResp) => void): grpc.ClientUnaryCall;
public libraryResolveDependencies(request: commands_lib_pb.LibraryResolveDependenciesReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: commands_lib_pb.LibraryResolveDependenciesResp) => void): grpc.ClientUnaryCall;
public libraryResolveDependencies(request: commands_lib_pb.LibraryResolveDependenciesReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: commands_lib_pb.LibraryResolveDependenciesResp) => void): grpc.ClientUnaryCall;
public librarySearch(request: commands_lib_pb.LibrarySearchReq, callback: (error: grpc.ServiceError | null, response: commands_lib_pb.LibrarySearchResp) => void): grpc.ClientUnaryCall;
public librarySearch(request: commands_lib_pb.LibrarySearchReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: commands_lib_pb.LibrarySearchResp) => void): grpc.ClientUnaryCall;
public librarySearch(request: commands_lib_pb.LibrarySearchReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: commands_lib_pb.LibrarySearchResp) => void): grpc.ClientUnaryCall;

View File

@ -248,6 +248,28 @@ function deserialize_cc_arduino_cli_commands_LibraryListResp(buffer_arg) {
return commands_lib_pb.LibraryListResp.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_cc_arduino_cli_commands_LibraryResolveDependenciesReq(arg) {
if (!(arg instanceof commands_lib_pb.LibraryResolveDependenciesReq)) {
throw new Error('Expected argument of type cc.arduino.cli.commands.LibraryResolveDependenciesReq');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_cc_arduino_cli_commands_LibraryResolveDependenciesReq(buffer_arg) {
return commands_lib_pb.LibraryResolveDependenciesReq.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_cc_arduino_cli_commands_LibraryResolveDependenciesResp(arg) {
if (!(arg instanceof commands_lib_pb.LibraryResolveDependenciesResp)) {
throw new Error('Expected argument of type cc.arduino.cli.commands.LibraryResolveDependenciesResp');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_cc_arduino_cli_commands_LibraryResolveDependenciesResp(buffer_arg) {
return commands_lib_pb.LibraryResolveDependenciesResp.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_cc_arduino_cli_commands_LibrarySearchReq(arg) {
if (!(arg instanceof commands_lib_pb.LibrarySearchReq)) {
throw new Error('Expected argument of type cc.arduino.cli.commands.LibrarySearchReq');
@ -810,6 +832,17 @@ var ArduinoCoreService = exports.ArduinoCoreService = {
responseSerialize: serialize_cc_arduino_cli_commands_LibraryUpgradeAllResp,
responseDeserialize: deserialize_cc_arduino_cli_commands_LibraryUpgradeAllResp,
},
libraryResolveDependencies: {
path: '/cc.arduino.cli.commands.ArduinoCore/LibraryResolveDependencies',
requestStream: false,
responseStream: false,
requestType: commands_lib_pb.LibraryResolveDependenciesReq,
responseType: commands_lib_pb.LibraryResolveDependenciesResp,
requestSerialize: serialize_cc_arduino_cli_commands_LibraryResolveDependenciesReq,
requestDeserialize: deserialize_cc_arduino_cli_commands_LibraryResolveDependenciesReq,
responseSerialize: serialize_cc_arduino_cli_commands_LibraryResolveDependenciesResp,
responseDeserialize: deserialize_cc_arduino_cli_commands_LibraryResolveDependenciesResp,
},
librarySearch: {
path: '/cc.arduino.cli.commands.ArduinoCore/LibrarySearch',
requestStream: false,

View File

@ -237,6 +237,90 @@ export namespace LibraryUpgradeAllResp {
}
}
export class LibraryResolveDependenciesReq extends jspb.Message {
hasInstance(): boolean;
clearInstance(): void;
getInstance(): commands_common_pb.Instance | undefined;
setInstance(value?: commands_common_pb.Instance): void;
getName(): string;
setName(value: string): void;
getVersion(): string;
setVersion(value: string): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): LibraryResolveDependenciesReq.AsObject;
static toObject(includeInstance: boolean, msg: LibraryResolveDependenciesReq): LibraryResolveDependenciesReq.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: LibraryResolveDependenciesReq, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): LibraryResolveDependenciesReq;
static deserializeBinaryFromReader(message: LibraryResolveDependenciesReq, reader: jspb.BinaryReader): LibraryResolveDependenciesReq;
}
export namespace LibraryResolveDependenciesReq {
export type AsObject = {
instance?: commands_common_pb.Instance.AsObject,
name: string,
version: string,
}
}
export class LibraryResolveDependenciesResp extends jspb.Message {
clearDependenciesList(): void;
getDependenciesList(): Array<LibraryDependencyStatus>;
setDependenciesList(value: Array<LibraryDependencyStatus>): void;
addDependencies(value?: LibraryDependencyStatus, index?: number): LibraryDependencyStatus;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): LibraryResolveDependenciesResp.AsObject;
static toObject(includeInstance: boolean, msg: LibraryResolveDependenciesResp): LibraryResolveDependenciesResp.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: LibraryResolveDependenciesResp, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): LibraryResolveDependenciesResp;
static deserializeBinaryFromReader(message: LibraryResolveDependenciesResp, reader: jspb.BinaryReader): LibraryResolveDependenciesResp;
}
export namespace LibraryResolveDependenciesResp {
export type AsObject = {
dependenciesList: Array<LibraryDependencyStatus.AsObject>,
}
}
export class LibraryDependencyStatus extends jspb.Message {
getName(): string;
setName(value: string): void;
getVersionrequired(): string;
setVersionrequired(value: string): void;
getVersioninstalled(): string;
setVersioninstalled(value: string): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): LibraryDependencyStatus.AsObject;
static toObject(includeInstance: boolean, msg: LibraryDependencyStatus): LibraryDependencyStatus.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: LibraryDependencyStatus, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): LibraryDependencyStatus;
static deserializeBinaryFromReader(message: LibraryDependencyStatus, reader: jspb.BinaryReader): LibraryDependencyStatus;
}
export namespace LibraryDependencyStatus {
export type AsObject = {
name: string,
versionrequired: string,
versioninstalled: string,
}
}
export class LibrarySearchReq extends jspb.Message {
hasInstance(): boolean;

View File

@ -16,6 +16,7 @@ goog.object.extend(proto, commands_common_pb);
goog.exportSymbol('proto.cc.arduino.cli.commands.DownloadResource', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.InstalledLibrary', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.Library', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.LibraryDependencyStatus', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.LibraryDownloadReq', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.LibraryDownloadResp', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.LibraryInstallReq', null, global);
@ -25,6 +26,8 @@ goog.exportSymbol('proto.cc.arduino.cli.commands.LibraryListReq', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.LibraryListResp', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.LibraryLocation', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.LibraryRelease', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.LibrarySearchReq', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.LibrarySearchResp', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.LibraryUninstallReq', null, global);
@ -1555,6 +1558,583 @@ proto.cc.arduino.cli.commands.LibraryUpgradeAllResp.prototype.hasTaskProgress =
/**
* 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.LibraryResolveDependenciesReq = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.displayName = 'proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.prototype.toObject = function(opt_includeInstance) {
return proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.toObject = function(includeInstance, msg) {
var f, obj = {
instance: (f = msg.getInstance()) && commands_common_pb.Instance.toObject(includeInstance, f),
name: jspb.Message.getFieldWithDefault(msg, 2, ""),
version: 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.LibraryResolveDependenciesReq}
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq;
return proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.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.LibraryResolveDependenciesReq} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq}
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = new commands_common_pb.Instance;
reader.readMessage(value,commands_common_pb.Instance.deserializeBinaryFromReader);
msg.setInstance(value);
break;
case 2:
var value = /** @type {string} */ (reader.readString());
msg.setName(value);
break;
case 3:
var value = /** @type {string} */ (reader.readString());
msg.setVersion(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.LibraryResolveDependenciesReq.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.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.LibraryResolveDependenciesReq} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getInstance();
if (f != null) {
writer.writeMessage(
1,
f,
commands_common_pb.Instance.serializeBinaryToWriter
);
}
f = message.getName();
if (f.length > 0) {
writer.writeString(
2,
f
);
}
f = message.getVersion();
if (f.length > 0) {
writer.writeString(
3,
f
);
}
};
/**
* optional Instance instance = 1;
* @return {?proto.cc.arduino.cli.commands.Instance}
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.prototype.getInstance = function() {
return /** @type{?proto.cc.arduino.cli.commands.Instance} */ (
jspb.Message.getWrapperField(this, commands_common_pb.Instance, 1));
};
/** @param {?proto.cc.arduino.cli.commands.Instance|undefined} value */
proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.prototype.setInstance = function(value) {
jspb.Message.setWrapperField(this, 1, value);
};
proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.prototype.clearInstance = function() {
this.setInstance(undefined);
};
/**
* Returns whether this field is set.
* @return {boolean}
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.prototype.hasInstance = function() {
return jspb.Message.getField(this, 1) != null;
};
/**
* optional string name = 2;
* @return {string}
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.prototype.getName = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};
/** @param {string} value */
proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.prototype.setName = function(value) {
jspb.Message.setProto3StringField(this, 2, value);
};
/**
* optional string version = 3;
* @return {string}
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.prototype.getVersion = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
};
/** @param {string} value */
proto.cc.arduino.cli.commands.LibraryResolveDependenciesReq.prototype.setVersion = function(value) {
jspb.Message.setProto3StringField(this, 3, value);
};
/**
* 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.LibraryResolveDependenciesResp = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp.repeatedFields_, null);
};
goog.inherits(proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp.displayName = 'proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp';
}
/**
* List of repeated fields within this message type.
* @private {!Array<number>}
* @const
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp.repeatedFields_ = [1];
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp.prototype.toObject = function(opt_includeInstance) {
return proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp.toObject = function(includeInstance, msg) {
var f, obj = {
dependenciesList: jspb.Message.toObjectList(msg.getDependenciesList(),
proto.cc.arduino.cli.commands.LibraryDependencyStatus.toObject, includeInstance)
};
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.LibraryResolveDependenciesResp}
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp;
return proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp.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.LibraryResolveDependenciesResp} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp}
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = new proto.cc.arduino.cli.commands.LibraryDependencyStatus;
reader.readMessage(value,proto.cc.arduino.cli.commands.LibraryDependencyStatus.deserializeBinaryFromReader);
msg.addDependencies(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.LibraryResolveDependenciesResp.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp.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.LibraryResolveDependenciesResp} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getDependenciesList();
if (f.length > 0) {
writer.writeRepeatedMessage(
1,
f,
proto.cc.arduino.cli.commands.LibraryDependencyStatus.serializeBinaryToWriter
);
}
};
/**
* repeated LibraryDependencyStatus dependencies = 1;
* @return {!Array<!proto.cc.arduino.cli.commands.LibraryDependencyStatus>}
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp.prototype.getDependenciesList = function() {
return /** @type{!Array<!proto.cc.arduino.cli.commands.LibraryDependencyStatus>} */ (
jspb.Message.getRepeatedWrapperField(this, proto.cc.arduino.cli.commands.LibraryDependencyStatus, 1));
};
/** @param {!Array<!proto.cc.arduino.cli.commands.LibraryDependencyStatus>} value */
proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp.prototype.setDependenciesList = function(value) {
jspb.Message.setRepeatedWrapperField(this, 1, value);
};
/**
* @param {!proto.cc.arduino.cli.commands.LibraryDependencyStatus=} opt_value
* @param {number=} opt_index
* @return {!proto.cc.arduino.cli.commands.LibraryDependencyStatus}
*/
proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp.prototype.addDependencies = function(opt_value, opt_index) {
return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.cc.arduino.cli.commands.LibraryDependencyStatus, opt_index);
};
proto.cc.arduino.cli.commands.LibraryResolveDependenciesResp.prototype.clearDependenciesList = function() {
this.setDependenciesList([]);
};
/**
* 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.LibraryDependencyStatus = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.cc.arduino.cli.commands.LibraryDependencyStatus, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.cc.arduino.cli.commands.LibraryDependencyStatus.displayName = 'proto.cc.arduino.cli.commands.LibraryDependencyStatus';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.cc.arduino.cli.commands.LibraryDependencyStatus.prototype.toObject = function(opt_includeInstance) {
return proto.cc.arduino.cli.commands.LibraryDependencyStatus.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.cc.arduino.cli.commands.LibraryDependencyStatus} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.cc.arduino.cli.commands.LibraryDependencyStatus.toObject = function(includeInstance, msg) {
var f, obj = {
name: jspb.Message.getFieldWithDefault(msg, 1, ""),
versionrequired: jspb.Message.getFieldWithDefault(msg, 2, ""),
versioninstalled: 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.LibraryDependencyStatus}
*/
proto.cc.arduino.cli.commands.LibraryDependencyStatus.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.cc.arduino.cli.commands.LibraryDependencyStatus;
return proto.cc.arduino.cli.commands.LibraryDependencyStatus.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.LibraryDependencyStatus} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.cc.arduino.cli.commands.LibraryDependencyStatus}
*/
proto.cc.arduino.cli.commands.LibraryDependencyStatus.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.setName(value);
break;
case 2:
var value = /** @type {string} */ (reader.readString());
msg.setVersionrequired(value);
break;
case 3:
var value = /** @type {string} */ (reader.readString());
msg.setVersioninstalled(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.LibraryDependencyStatus.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.cc.arduino.cli.commands.LibraryDependencyStatus.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.LibraryDependencyStatus} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.cc.arduino.cli.commands.LibraryDependencyStatus.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getName();
if (f.length > 0) {
writer.writeString(
1,
f
);
}
f = message.getVersionrequired();
if (f.length > 0) {
writer.writeString(
2,
f
);
}
f = message.getVersioninstalled();
if (f.length > 0) {
writer.writeString(
3,
f
);
}
};
/**
* optional string name = 1;
* @return {string}
*/
proto.cc.arduino.cli.commands.LibraryDependencyStatus.prototype.getName = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/** @param {string} value */
proto.cc.arduino.cli.commands.LibraryDependencyStatus.prototype.setName = function(value) {
jspb.Message.setProto3StringField(this, 1, value);
};
/**
* optional string versionRequired = 2;
* @return {string}
*/
proto.cc.arduino.cli.commands.LibraryDependencyStatus.prototype.getVersionrequired = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};
/** @param {string} value */
proto.cc.arduino.cli.commands.LibraryDependencyStatus.prototype.setVersionrequired = function(value) {
jspb.Message.setProto3StringField(this, 2, value);
};
/**
* optional string versionInstalled = 3;
* @return {string}
*/
proto.cc.arduino.cli.commands.LibraryDependencyStatus.prototype.getVersioninstalled = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
};
/** @param {string} value */
proto.cc.arduino.cli.commands.LibraryDependencyStatus.prototype.setVersioninstalled = function(value) {
jspb.Message.setProto3StringField(this, 3, value);
};
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a

View File

@ -24,42 +24,20 @@ namespace ErrorWithCode {
}
export function toMonitorError(error: Error, connectionId: string, config: MonitorConfig): MonitorError | undefined {
if (is(error)) {
const { code, message } = error;
// TODO: apply a regex on the `message`, and use enums instead of a numbers for the error codes.
if (code === 1 && message === 'Cancelled on client') {
// TODO: const `mapping`. Use regex for the `message`.
const mapping = new Map<string, number>();
mapping.set('1 CANCELLED: Cancelled on client', MonitorError.ErrorCodes.CLIENT_CANCEL);
mapping.set('2 UNKNOWN: device not configured', MonitorError.ErrorCodes.DEVICE_NOT_CONFIGURED);
mapping.set('2 UNKNOWN: error opening serial monitor: Serial port busy', MonitorError.ErrorCodes.DEVICE_BUSY);
mapping.set('2 UNKNOWN: interrupted system call', MonitorError.ErrorCodes.interrupted_system_call);
const { message } = error;
const code = mapping.get(message);
if (typeof code === 'number') {
return {
connectionId,
message,
code: MonitorError.ErrorCodes.CLIENT_CANCEL,
code,
config
};
}
if (code === 2) {
switch (message) {
case 'device not configured': {
return {
connectionId,
message,
code: MonitorError.ErrorCodes.DEVICE_NOT_CONFIGURED,
config
}
}
case 'error opening serial monitor: Serial port busy': {
return {
connectionId,
message,
code: MonitorError.ErrorCodes.DEVICE_BUSY,
config
}
}
case 'interrupted system call': {
return {
connectionId,
message,
code: MonitorError.ErrorCodes.interrupted_system_call,
config
}
}
}
}
console.warn(`Unhandled error with code:`, error);
@ -120,10 +98,6 @@ export class MonitorServiceImpl implements MonitorService {
return;
}
}
if (error.message === 'interrupted system call') {
this.logger.info('TODO: reduce to debug, INTERRUPTED SYSTEM CALL');
return; // Continue.
}
if (!toDispose.disposed) {
toDispose.dispose();
}
@ -134,6 +108,7 @@ export class MonitorServiceImpl implements MonitorService {
if (this.client) {
const raw = resp.getData();
const data = typeof raw === 'string' ? raw : new TextDecoder('utf8').decode(raw);
this.logger.info('NOTIFY READ', data);
this.client.notifyRead({ connectionId, data });
}
}).bind(this));

View File

@ -818,12 +818,12 @@
unique-filename "^1.1.1"
which "^1.3.1"
"@grpc/grpc-js@^0.4.0":
version "0.4.3"
resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-0.4.3.tgz#d2d71278d42709631793f4a451b7398197d44033"
integrity sha512-09qiFMBh90YZ4P5RFzvpSUvBi9DmftvTaP+mmmTzigps0It5YxuwQNqDAo9pI7SWom/6A5ybxv2CUGNk86+FCg==
"@grpc/grpc-js@^0.6.12":
version "0.6.12"
resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-0.6.12.tgz#1893d9b061f04e72bea2dc2ca3b753775ba56abe"
integrity sha512-/Yd/gOPyMpGfkIOJdr3ePJv/9DgDNUUEHZ2FciTiUFdlT36jvq7Z9S5c2uFQ81U12hCyj6rNnGoHwLkttn8gsw==
dependencies:
semver "^6.0.0"
semver "^6.2.0"
"@lerna/add@3.19.0":
version "3.19.0"
@ -7045,14 +7045,14 @@ grouped-queue@^0.3.3:
dependencies:
lodash "^4.17.2"
grpc-tools@^1.7.3:
grpc-tools@^1.8.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/grpc-tools/-/grpc-tools-1.8.0.tgz#db438dbd0cfb43d412dc02a767d5fb2193636847"
integrity sha512-GzYHjPQ/sbV/DmnNRksapMlLj26Tvq2Qppmzjmd+lHYZNeWM1feiGsYCduzJLyy295P+3uYIPy2/w/1thAnOow==
dependencies:
node-pre-gyp "^0.12.0"
grpc_tools_node_protoc_ts@^2.5.0:
grpc_tools_node_protoc_ts@^2.5.8:
version "2.5.8"
resolved "https://registry.yarnpkg.com/grpc_tools_node_protoc_ts/-/grpc_tools_node_protoc_ts-2.5.8.tgz#8b920fbc3ad7e39540199c7ab5326ecce785888c"
integrity sha512-3fJ/PXsMkgUg6LWcrEfDV6MGouh219qnBMxIpS9lFIT7l7SteV8DqqlfSBThA2dgi3OPusxRUfeHABC3pzvFUg==