@onekeyfe/hd-web-sdk 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13902,6 +13902,25 @@ var MessagesJSON = {
13902
13902
  nested: nested
13903
13903
  };
13904
13904
 
13905
+ const getReleaseStatus = (releases, currentVersion) => {
13906
+ const newVersions = releases.filter(r => semver__default["default"].gt(r.version.join('.'), currentVersion));
13907
+
13908
+ if (newVersions.length === 0) {
13909
+ return 'valid';
13910
+ }
13911
+
13912
+ if (newVersions.some(r => r.required)) {
13913
+ return 'required';
13914
+ }
13915
+
13916
+ return 'outdated';
13917
+ };
13918
+
13919
+ const getReleaseChangelog = (releases, currentVersion) => {
13920
+ const newVersions = releases.filter(r => semver__default["default"].gt(r.version.join('.'), currentVersion));
13921
+ return newVersions.map(r => r.changelog);
13922
+ };
13923
+
13905
13924
  var _a;
13906
13925
 
13907
13926
  class DataManager {
@@ -13981,17 +14000,31 @@ DataManager.getFirmwareStatus = features => {
13981
14000
  }
13982
14001
 
13983
14002
  const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b.firmware) !== null && _c !== void 0 ? _c : [];
13984
- const latestFirmware = targetDeviceConfigList[targetDeviceConfigList.length - 1];
13985
- if (!latestFirmware) return 'valid';
13986
- const latestVersion = latestFirmware.version.join('.');
13987
14003
  const currentVersion = deviceFirmwareVersion.join('.');
14004
+ return getReleaseStatus(targetDeviceConfigList, currentVersion);
14005
+ };
13988
14006
 
13989
- if (semver__default["default"].gt(latestVersion, currentVersion)) {
13990
- if (latestFirmware.required) return 'required';
13991
- return 'outdated';
14007
+ DataManager.getFirmwareChangelog = features => {
14008
+ var _b, _c;
14009
+
14010
+ const deviceType = getDeviceType(features);
14011
+ const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
14012
+
14013
+ if (features.firmware_present === false || deviceType === 'classic' && features.bootloader_mode) {
14014
+ return [];
13992
14015
  }
13993
14016
 
13994
- return 'valid';
14017
+ const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b.firmware) !== null && _c !== void 0 ? _c : [];
14018
+ const currentVersion = deviceFirmwareVersion.join('.');
14019
+ return getReleaseChangelog(targetDeviceConfigList, currentVersion);
14020
+ };
14021
+
14022
+ DataManager.getFirmwareLeatestRelease = features => {
14023
+ var _b, _c;
14024
+
14025
+ const deviceType = getDeviceType(features);
14026
+ const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b.firmware) !== null && _c !== void 0 ? _c : [];
14027
+ return targetDeviceConfigList[targetDeviceConfigList.length - 1];
13995
14028
  };
13996
14029
 
13997
14030
  DataManager.getBLEFirmwareStatus = features => {
@@ -14005,17 +14038,31 @@ DataManager.getBLEFirmwareStatus = features => {
14005
14038
  }
14006
14039
 
14007
14040
  const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b.ble) !== null && _c !== void 0 ? _c : [];
14008
- const latestBLEFirmware = targetDeviceConfigList[targetDeviceConfigList.length - 1];
14009
- if (!latestBLEFirmware) return 'valid';
14010
- const latestVersion = latestBLEFirmware.version.join('.');
14011
14041
  const currentVersion = deviceBLEFirmwareVersion.join('.');
14042
+ return getReleaseStatus(targetDeviceConfigList, currentVersion);
14043
+ };
14044
+
14045
+ DataManager.getBleFirmwareChangelog = features => {
14046
+ var _b, _c;
14012
14047
 
14013
- if (semver__default["default"].gt(latestVersion, currentVersion)) {
14014
- if (latestBLEFirmware.required) return 'required';
14015
- return 'outdated';
14048
+ const deviceType = getDeviceType(features);
14049
+ const deviceBLEFirmwareVersion = getDeviceBLEFirmwareVersion(features);
14050
+
14051
+ if (!deviceBLEFirmwareVersion) {
14052
+ return [];
14016
14053
  }
14017
14054
 
14018
- return 'valid';
14055
+ const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b.ble) !== null && _c !== void 0 ? _c : [];
14056
+ const currentVersion = deviceBLEFirmwareVersion.join('.');
14057
+ return getReleaseChangelog(targetDeviceConfigList, currentVersion);
14058
+ };
14059
+
14060
+ DataManager.getBleFirmwareLeatestRelease = features => {
14061
+ var _b, _c;
14062
+
14063
+ const deviceType = getDeviceType(features);
14064
+ const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b.ble) !== null && _c !== void 0 ? _c : [];
14065
+ return targetDeviceConfigList[targetDeviceConfigList.length - 1];
14019
14066
  };
14020
14067
 
14021
14068
  DataManager.getTransportStatus = localVersion => {
@@ -16232,7 +16279,13 @@ class CheckFirmwareRelease extends BaseMethod {
16232
16279
  run() {
16233
16280
  if (this.device.features) {
16234
16281
  const firmwareStatus = DataManager.getFirmwareStatus(this.device.features);
16235
- return Promise.resolve(firmwareStatus);
16282
+ const changelog = DataManager.getFirmwareChangelog(this.device.features);
16283
+ const release = DataManager.getFirmwareLeatestRelease(this.device.features);
16284
+ return Promise.resolve({
16285
+ status: firmwareStatus,
16286
+ changelog,
16287
+ release
16288
+ });
16236
16289
  }
16237
16290
 
16238
16291
  return Promise.resolve(null);
@@ -16248,7 +16301,13 @@ class CheckBLEFirmwareRelease extends BaseMethod {
16248
16301
  run() {
16249
16302
  if (this.device.features) {
16250
16303
  const firmwareStatus = DataManager.getBLEFirmwareStatus(this.device.features);
16251
- return Promise.resolve(firmwareStatus);
16304
+ const changelog = DataManager.getBleFirmwareChangelog(this.device.features);
16305
+ const release = DataManager.getBleFirmwareLeatestRelease(this.device.features);
16306
+ return Promise.resolve({
16307
+ status: firmwareStatus,
16308
+ changelog,
16309
+ release
16310
+ });
16252
16311
  }
16253
16312
 
16254
16313
  return Promise.resolve(null);