mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-04-19 12:57:17 +00:00
feat: omit release details to speed up lib search
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
parent
0ab28266df
commit
9b49712669
@ -166,7 +166,7 @@
|
||||
"version": {
|
||||
"owner": "arduino",
|
||||
"repo": "arduino-cli",
|
||||
"commitish": "6992de7"
|
||||
"commitish": "71a8576"
|
||||
}
|
||||
},
|
||||
"fwuploader": {
|
||||
|
@ -406,6 +406,9 @@ export class LibrarySearchRequest extends jspb.Message {
|
||||
getQuery(): string;
|
||||
setQuery(value: string): LibrarySearchRequest;
|
||||
|
||||
getOmitReleasesDetails(): boolean;
|
||||
setOmitReleasesDetails(value: boolean): LibrarySearchRequest;
|
||||
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): LibrarySearchRequest.AsObject;
|
||||
@ -421,6 +424,7 @@ export namespace LibrarySearchRequest {
|
||||
export type AsObject = {
|
||||
instance?: cc_arduino_cli_commands_v1_common_pb.Instance.AsObject,
|
||||
query: string,
|
||||
omitReleasesDetails: boolean,
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,6 +469,11 @@ export class SearchedLibrary extends jspb.Message {
|
||||
getLatest(): LibraryRelease | undefined;
|
||||
setLatest(value?: LibraryRelease): SearchedLibrary;
|
||||
|
||||
clearAvailableVersionsList(): void;
|
||||
getAvailableVersionsList(): Array<string>;
|
||||
setAvailableVersionsList(value: Array<string>): SearchedLibrary;
|
||||
addAvailableVersions(value: string, index?: number): string;
|
||||
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): SearchedLibrary.AsObject;
|
||||
@ -482,6 +491,7 @@ export namespace SearchedLibrary {
|
||||
|
||||
releasesMap: Array<[string, LibraryRelease.AsObject]>,
|
||||
latest?: LibraryRelease.AsObject,
|
||||
availableVersionsList: Array<string>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ if (goog.DEBUG && !COMPILED) {
|
||||
* @constructor
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.v1.SearchedLibrary = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, proto.cc.arduino.cli.commands.v1.SearchedLibrary.repeatedFields_, null);
|
||||
};
|
||||
goog.inherits(proto.cc.arduino.cli.commands.v1.SearchedLibrary, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
@ -3202,7 +3202,8 @@ proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.prototype.toObject = funct
|
||||
proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
instance: (f = msg.getInstance()) && cc_arduino_cli_commands_v1_common_pb.Instance.toObject(includeInstance, f),
|
||||
query: jspb.Message.getFieldWithDefault(msg, 2, "")
|
||||
query: jspb.Message.getFieldWithDefault(msg, 2, ""),
|
||||
omitReleasesDetails: jspb.Message.getBooleanFieldWithDefault(msg, 3, false)
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
@ -3248,6 +3249,10 @@ proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.deserializeBinaryFromReade
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setQuery(value);
|
||||
break;
|
||||
case 3:
|
||||
var value = /** @type {boolean} */ (reader.readBool());
|
||||
msg.setOmitReleasesDetails(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
@ -3292,6 +3297,13 @@ proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.serializeBinaryToWriter =
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getOmitReleasesDetails();
|
||||
if (f) {
|
||||
writer.writeBool(
|
||||
3,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -3350,6 +3362,24 @@ proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.prototype.setQuery = funct
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional bool omit_releases_details = 3;
|
||||
* @return {boolean}
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.prototype.getOmitReleasesDetails = function() {
|
||||
return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {boolean} value
|
||||
* @return {!proto.cc.arduino.cli.commands.v1.LibrarySearchRequest} returns this
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.prototype.setOmitReleasesDetails = function(value) {
|
||||
return jspb.Message.setProto3BooleanField(this, 3, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* List of repeated fields within this message type.
|
||||
@ -3541,6 +3571,13 @@ proto.cc.arduino.cli.commands.v1.LibrarySearchResponse.prototype.setStatus = fun
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* List of repeated fields within this message type.
|
||||
* @private {!Array<number>}
|
||||
* @const
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.v1.SearchedLibrary.repeatedFields_ = [4];
|
||||
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
@ -3574,7 +3611,8 @@ proto.cc.arduino.cli.commands.v1.SearchedLibrary.toObject = function(includeInst
|
||||
var f, obj = {
|
||||
name: jspb.Message.getFieldWithDefault(msg, 1, ""),
|
||||
releasesMap: (f = msg.getReleasesMap()) ? f.toObject(includeInstance, proto.cc.arduino.cli.commands.v1.LibraryRelease.toObject) : [],
|
||||
latest: (f = msg.getLatest()) && proto.cc.arduino.cli.commands.v1.LibraryRelease.toObject(includeInstance, f)
|
||||
latest: (f = msg.getLatest()) && proto.cc.arduino.cli.commands.v1.LibraryRelease.toObject(includeInstance, f),
|
||||
availableVersionsList: (f = jspb.Message.getRepeatedField(msg, 4)) == null ? undefined : f
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
@ -3626,6 +3664,10 @@ proto.cc.arduino.cli.commands.v1.SearchedLibrary.deserializeBinaryFromReader = f
|
||||
reader.readMessage(value,proto.cc.arduino.cli.commands.v1.LibraryRelease.deserializeBinaryFromReader);
|
||||
msg.setLatest(value);
|
||||
break;
|
||||
case 4:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.addAvailableVersions(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
@ -3674,6 +3716,13 @@ proto.cc.arduino.cli.commands.v1.SearchedLibrary.serializeBinaryToWriter = funct
|
||||
proto.cc.arduino.cli.commands.v1.LibraryRelease.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = message.getAvailableVersionsList();
|
||||
if (f.length > 0) {
|
||||
writer.writeRepeatedString(
|
||||
4,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -3754,6 +3803,43 @@ proto.cc.arduino.cli.commands.v1.SearchedLibrary.prototype.hasLatest = function(
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* repeated string available_versions = 4;
|
||||
* @return {!Array<string>}
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.v1.SearchedLibrary.prototype.getAvailableVersionsList = function() {
|
||||
return /** @type {!Array<string>} */ (jspb.Message.getRepeatedField(this, 4));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {!Array<string>} value
|
||||
* @return {!proto.cc.arduino.cli.commands.v1.SearchedLibrary} returns this
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.v1.SearchedLibrary.prototype.setAvailableVersionsList = function(value) {
|
||||
return jspb.Message.setField(this, 4, value || []);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @param {number=} opt_index
|
||||
* @return {!proto.cc.arduino.cli.commands.v1.SearchedLibrary} returns this
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.v1.SearchedLibrary.prototype.addAvailableVersions = function(value, opt_index) {
|
||||
return jspb.Message.addToRepeatedField(this, 4, value, opt_index);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Clears the list making it empty but non-null.
|
||||
* @return {!proto.cc.arduino.cli.commands.v1.SearchedLibrary} returns this
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.v1.SearchedLibrary.prototype.clearAvailableVersionsList = function() {
|
||||
return this.setAvailableVersionsList([]);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* List of repeated fields within this message type.
|
||||
|
@ -79,6 +79,7 @@ export class LibraryServiceImpl
|
||||
const req = new LibrarySearchRequest();
|
||||
req.setQuery(options.query || '');
|
||||
req.setInstance(instance);
|
||||
req.setOmitReleasesDetails(true);
|
||||
const resp = await new Promise<LibrarySearchResponse>((resolve, reject) =>
|
||||
client.librarySearch(req, (err, resp) =>
|
||||
!!err ? reject(err) : resolve(resp)
|
||||
@ -88,11 +89,8 @@ export class LibraryServiceImpl
|
||||
.getLibrariesList()
|
||||
.filter((item) => !!item.getLatest())
|
||||
.map((item) => {
|
||||
// TODO: This seems to contain only the latest item instead of all of the items.
|
||||
const availableVersions = item
|
||||
.getReleasesMap()
|
||||
.getEntryList()
|
||||
.map(([key, _]) => key)
|
||||
.getAvailableVersionsList()
|
||||
.sort(Installable.Version.COMPARATOR)
|
||||
.reverse();
|
||||
let installedVersion: string | undefined;
|
||||
|
Loading…
x
Reference in New Issue
Block a user