Skip to content

Commit 2f7d26d

Browse files
author
Christian Weichel
committed
Implemented library search and installation
1 parent 50c1c7d commit 2f7d26d

File tree

13 files changed

+739
-95
lines changed

13 files changed

+739
-95
lines changed
29.3 KB
Binary file not shown.
24.1 KB
Binary file not shown.

arduino-ide-extension/src/browser/components/component-list/component-list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class ComponentList extends React.Component<ComponentList.Props> {
77

88
render(): React.ReactNode {
99
return <div>
10-
{this.props.items.map(item => <ComponentListItem key={item.name} item={item} windowService={this.props.windowService} install={this.props.install} />)}
10+
{this.props.items.map((item, idx) => <ComponentListItem key={idx} item={item} windowService={this.props.windowService} install={this.props.install} />)}
1111
</div>;
1212
}
1313

arduino-ide-extension/src/browser/components/component-list/filterable-list-container.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ export class FilterableListContainer extends React.Component<FilterableListConta
3939
const { items } = result;
4040
this.setState({
4141
filterText,
42-
items
42+
items: items.sort((a, b) => {
43+
if (a.name < b.name) {
44+
return -1;
45+
} else if (a.name === b.name) {
46+
return 0;
47+
} else {
48+
return 1;
49+
}
50+
})
4351
});
4452
});
4553
}

arduino-ide-extension/src/common/protocol/library-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const LibraryServicePath = '/services/library-service';
44
export const LibraryService = Symbol('LibraryService');
55
export interface LibraryService {
66
search(options: { query?: string }): Promise<{ items: Library[] }>;
7-
install(board: Library): Promise<void>;
7+
install(library: Library): Promise<void>;
88
}
99

1010
export interface Library extends ArduinoComponent {

arduino-ide-extension/src/node/boards-service-impl.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,6 @@ export class BoardsServiceImpl implements BoardsService {
8080
installedVersion,
8181
}
8282
return result;
83-
}).sort((a, b) => {
84-
if (a.name < b.name) {
85-
return -1;
86-
} else if (a.name === b.name) {
87-
return 0;
88-
} else {
89-
return 1;
90-
}
9183
});
9284

9385
return { items };

arduino-ide-extension/src/node/cli-protocol/commands_grpc_pb.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ interface IArduinoCoreService extends grpc.ServiceDefinition<grpc.UntypedService
3232
libraryUninstall: IArduinoCoreService_ILibraryUninstall;
3333
libraryUpgradeAll: IArduinoCoreService_ILibraryUpgradeAll;
3434
librarySearch: IArduinoCoreService_ILibrarySearch;
35+
libraryList: IArduinoCoreService_ILibraryList;
3536
}
3637

3738
interface IArduinoCoreService_IInit extends grpc.MethodDefinition<commands_pb.InitReq, commands_pb.InitResp> {
@@ -205,6 +206,15 @@ interface IArduinoCoreService_ILibrarySearch extends grpc.MethodDefinition<lib_p
205206
responseSerialize: grpc.serialize<lib_pb.LibrarySearchResp>;
206207
responseDeserialize: grpc.deserialize<lib_pb.LibrarySearchResp>;
207208
}
209+
interface IArduinoCoreService_ILibraryList extends grpc.MethodDefinition<lib_pb.LibraryListReq, lib_pb.LibraryListResp> {
210+
path: string; // "/arduino.ArduinoCore/LibraryList"
211+
requestStream: boolean; // false
212+
responseStream: boolean; // false
213+
requestSerialize: grpc.serialize<lib_pb.LibraryListReq>;
214+
requestDeserialize: grpc.deserialize<lib_pb.LibraryListReq>;
215+
responseSerialize: grpc.serialize<lib_pb.LibraryListResp>;
216+
responseDeserialize: grpc.deserialize<lib_pb.LibraryListResp>;
217+
}
208218

209219
export const ArduinoCoreService: IArduinoCoreService;
210220

@@ -228,6 +238,7 @@ export interface IArduinoCoreServer {
228238
libraryUninstall: grpc.handleServerStreamingCall<lib_pb.LibraryUninstallReq, lib_pb.LibraryUninstallResp>;
229239
libraryUpgradeAll: grpc.handleServerStreamingCall<lib_pb.LibraryUpgradeAllReq, lib_pb.LibraryUpgradeAllResp>;
230240
librarySearch: grpc.handleUnaryCall<lib_pb.LibrarySearchReq, lib_pb.LibrarySearchResp>;
241+
libraryList: grpc.handleUnaryCall<lib_pb.LibraryListReq, lib_pb.LibraryListResp>;
231242
}
232243

233244
export interface IArduinoCoreClient {
@@ -277,6 +288,9 @@ export interface IArduinoCoreClient {
277288
librarySearch(request: lib_pb.LibrarySearchReq, callback: (error: grpc.ServiceError | null, response: lib_pb.LibrarySearchResp) => void): grpc.ClientUnaryCall;
278289
librarySearch(request: lib_pb.LibrarySearchReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: lib_pb.LibrarySearchResp) => void): grpc.ClientUnaryCall;
279290
librarySearch(request: lib_pb.LibrarySearchReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: lib_pb.LibrarySearchResp) => void): grpc.ClientUnaryCall;
291+
libraryList(request: lib_pb.LibraryListReq, callback: (error: grpc.ServiceError | null, response: lib_pb.LibraryListResp) => void): grpc.ClientUnaryCall;
292+
libraryList(request: lib_pb.LibraryListReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: lib_pb.LibraryListResp) => void): grpc.ClientUnaryCall;
293+
libraryList(request: lib_pb.LibraryListReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: lib_pb.LibraryListResp) => void): grpc.ClientUnaryCall;
280294
}
281295

282296
export class ArduinoCoreClient extends grpc.Client implements IArduinoCoreClient {
@@ -327,4 +341,7 @@ export class ArduinoCoreClient extends grpc.Client implements IArduinoCoreClient
327341
public librarySearch(request: lib_pb.LibrarySearchReq, callback: (error: grpc.ServiceError | null, response: lib_pb.LibrarySearchResp) => void): grpc.ClientUnaryCall;
328342
public librarySearch(request: lib_pb.LibrarySearchReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: lib_pb.LibrarySearchResp) => void): grpc.ClientUnaryCall;
329343
public librarySearch(request: lib_pb.LibrarySearchReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: lib_pb.LibrarySearchResp) => void): grpc.ClientUnaryCall;
344+
public libraryList(request: lib_pb.LibraryListReq, callback: (error: grpc.ServiceError | null, response: lib_pb.LibraryListResp) => void): grpc.ClientUnaryCall;
345+
public libraryList(request: lib_pb.LibraryListReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: lib_pb.LibraryListResp) => void): grpc.ClientUnaryCall;
346+
public libraryList(request: lib_pb.LibraryListReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: lib_pb.LibraryListResp) => void): grpc.ClientUnaryCall;
330347
}

arduino-ide-extension/src/node/cli-protocol/commands_grpc_pb.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,28 @@ function deserialize_arduino_LibraryInstallResp(buffer_arg) {
182182
return lib_pb.LibraryInstallResp.deserializeBinary(new Uint8Array(buffer_arg));
183183
}
184184

185+
function serialize_arduino_LibraryListReq(arg) {
186+
if (!(arg instanceof lib_pb.LibraryListReq)) {
187+
throw new Error('Expected argument of type arduino.LibraryListReq');
188+
}
189+
return Buffer.from(arg.serializeBinary());
190+
}
191+
192+
function deserialize_arduino_LibraryListReq(buffer_arg) {
193+
return lib_pb.LibraryListReq.deserializeBinary(new Uint8Array(buffer_arg));
194+
}
195+
196+
function serialize_arduino_LibraryListResp(arg) {
197+
if (!(arg instanceof lib_pb.LibraryListResp)) {
198+
throw new Error('Expected argument of type arduino.LibraryListResp');
199+
}
200+
return Buffer.from(arg.serializeBinary());
201+
}
202+
203+
function deserialize_arduino_LibraryListResp(buffer_arg) {
204+
return lib_pb.LibraryListResp.deserializeBinary(new Uint8Array(buffer_arg));
205+
}
206+
185207
function serialize_arduino_LibrarySearchReq(arg) {
186208
if (!(arg instanceof lib_pb.LibrarySearchReq)) {
187209
throw new Error('Expected argument of type arduino.LibrarySearchReq');
@@ -666,6 +688,17 @@ var ArduinoCoreService = exports.ArduinoCoreService = {
666688
responseSerialize: serialize_arduino_LibrarySearchResp,
667689
responseDeserialize: deserialize_arduino_LibrarySearchResp,
668690
},
691+
libraryList: {
692+
path: '/arduino.ArduinoCore/LibraryList',
693+
requestStream: false,
694+
responseStream: false,
695+
requestType: lib_pb.LibraryListReq,
696+
responseType: lib_pb.LibraryListResp,
697+
requestSerialize: serialize_arduino_LibraryListReq,
698+
requestDeserialize: deserialize_arduino_LibraryListReq,
699+
responseSerialize: serialize_arduino_LibraryListResp,
700+
responseDeserialize: deserialize_arduino_LibraryListResp,
701+
},
669702
};
670703

671704
exports.ArduinoCoreClient = grpc.makeGenericClientConstructor(ArduinoCoreService);

arduino-ide-extension/src/node/cli-protocol/lib_pb.d.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,81 @@ export namespace SearchLibraryOutput {
325325
}
326326
}
327327

328+
export class LibraryListReq extends jspb.Message {
329+
330+
hasInstance(): boolean;
331+
clearInstance(): void;
332+
getInstance(): common_pb.Instance | undefined;
333+
setInstance(value?: common_pb.Instance): void;
334+
335+
336+
serializeBinary(): Uint8Array;
337+
toObject(includeInstance?: boolean): LibraryListReq.AsObject;
338+
static toObject(includeInstance: boolean, msg: LibraryListReq): LibraryListReq.AsObject;
339+
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
340+
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
341+
static serializeBinaryToWriter(message: LibraryListReq, writer: jspb.BinaryWriter): void;
342+
static deserializeBinary(bytes: Uint8Array): LibraryListReq;
343+
static deserializeBinaryFromReader(message: LibraryListReq, reader: jspb.BinaryReader): LibraryListReq;
344+
}
345+
346+
export namespace LibraryListReq {
347+
export type AsObject = {
348+
instance?: common_pb.Instance.AsObject,
349+
}
350+
}
351+
352+
export class LibraryListResp extends jspb.Message {
353+
clearLibrariesList(): void;
354+
getLibrariesList(): Array<InstalledLibrary>;
355+
setLibrariesList(value: Array<InstalledLibrary>): void;
356+
addLibraries(value?: InstalledLibrary, index?: number): InstalledLibrary;
357+
358+
359+
serializeBinary(): Uint8Array;
360+
toObject(includeInstance?: boolean): LibraryListResp.AsObject;
361+
static toObject(includeInstance: boolean, msg: LibraryListResp): LibraryListResp.AsObject;
362+
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
363+
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
364+
static serializeBinaryToWriter(message: LibraryListResp, writer: jspb.BinaryWriter): void;
365+
static deserializeBinary(bytes: Uint8Array): LibraryListResp;
366+
static deserializeBinaryFromReader(message: LibraryListResp, reader: jspb.BinaryReader): LibraryListResp;
367+
}
368+
369+
export namespace LibraryListResp {
370+
export type AsObject = {
371+
librariesList: Array<InstalledLibrary.AsObject>,
372+
}
373+
}
374+
375+
export class InstalledLibrary extends jspb.Message {
376+
getName(): string;
377+
setName(value: string): void;
378+
379+
380+
hasInstalled(): boolean;
381+
clearInstalled(): void;
382+
getInstalled(): LibraryRelease | undefined;
383+
setInstalled(value?: LibraryRelease): void;
384+
385+
386+
serializeBinary(): Uint8Array;
387+
toObject(includeInstance?: boolean): InstalledLibrary.AsObject;
388+
static toObject(includeInstance: boolean, msg: InstalledLibrary): InstalledLibrary.AsObject;
389+
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
390+
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
391+
static serializeBinaryToWriter(message: InstalledLibrary, writer: jspb.BinaryWriter): void;
392+
static deserializeBinary(bytes: Uint8Array): InstalledLibrary;
393+
static deserializeBinaryFromReader(message: InstalledLibrary, reader: jspb.BinaryReader): InstalledLibrary;
394+
}
395+
396+
export namespace InstalledLibrary {
397+
export type AsObject = {
398+
name: string,
399+
installed?: LibraryRelease.AsObject,
400+
}
401+
}
402+
328403
export class LibraryRelease extends jspb.Message {
329404
getAuthor(): string;
330405
setAuthor(value: string): void;

0 commit comments

Comments
 (0)