electron-incremental-update 0.7.9 → 0.7.10

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.
package/dist/index.d.mts CHANGED
@@ -11,6 +11,9 @@ declare class VerifyFailedError extends Error {
11
11
  cert: string;
12
12
  constructor(signature: string, cert: string);
13
13
  }
14
+ declare class DownloadError extends Error {
15
+ constructor();
16
+ }
14
17
  declare class IncrementalUpdater implements Updater {
15
18
  private info?;
16
19
  private option;
@@ -36,11 +39,13 @@ declare class IncrementalUpdater implements Updater {
36
39
  */
37
40
  declare function createUpdater(option: UpdaterOption): IncrementalUpdater;
38
41
 
42
+ type CheckResultError = MinimumVersionError | DownloadError | TypeError | Error;
43
+ type DownloadResultError = DownloadError | VerifyFailedError | TypeError | Error;
39
44
  type CheckResultType = {
40
45
  size: number;
41
46
  version: string;
42
- } | undefined | Error | MinimumVersionError | TypeError;
43
- type DownloadResult = true | Error | VerifyFailedError | TypeError;
47
+ } | undefined | CheckResultError;
48
+ type DownloadResult = true | DownloadResultError;
44
49
  type DownloadingInfo = {
45
50
  /**
46
51
  * downloaded percent, 0% - 100%
@@ -69,8 +74,8 @@ interface Updater {
69
74
  * @param data update json url or object
70
75
  * @returns
71
76
  * - `{size: number, version: string}`: available
72
- * - `false`: unavailable
73
- * - `Error`: fail ({@link MinimumVersionError} or other)
77
+ * - `undefined`: unavailable
78
+ * - `CheckResultError`: fail
74
79
  */
75
80
  checkUpdate: (data?: string | UpdateJSON) => Promise<CheckResultType>;
76
81
  /**
@@ -81,7 +86,7 @@ interface Updater {
81
86
  * @param sig signature
82
87
  * @returns
83
88
  * - `true`: success
84
- * - `Error`: fail ({@link VerifyFailedError} or other)
89
+ * - `DownloadResultError`: fail
85
90
  */
86
91
  download: (data?: string | Buffer, sig?: string) => Promise<DownloadResult>;
87
92
  /**
@@ -237,4 +242,4 @@ type SetUpdater = {
237
242
  */
238
243
  declare function initApp(appOptions?: AppOption): SetUpdater;
239
244
 
240
- export { AppOption, IncrementalUpdater, MinimumVersionError, StartupWithUpdater, Updater, UpdaterOption, VerifyFailedError, createUpdater, initApp };
245
+ export { AppOption, DownloadError, IncrementalUpdater, MinimumVersionError, StartupWithUpdater, Updater, UpdaterOption, VerifyFailedError, createUpdater, initApp };
package/dist/index.d.ts CHANGED
@@ -11,6 +11,9 @@ declare class VerifyFailedError extends Error {
11
11
  cert: string;
12
12
  constructor(signature: string, cert: string);
13
13
  }
14
+ declare class DownloadError extends Error {
15
+ constructor();
16
+ }
14
17
  declare class IncrementalUpdater implements Updater {
15
18
  private info?;
16
19
  private option;
@@ -36,11 +39,13 @@ declare class IncrementalUpdater implements Updater {
36
39
  */
37
40
  declare function createUpdater(option: UpdaterOption): IncrementalUpdater;
38
41
 
42
+ type CheckResultError = MinimumVersionError | DownloadError | TypeError | Error;
43
+ type DownloadResultError = DownloadError | VerifyFailedError | TypeError | Error;
39
44
  type CheckResultType = {
40
45
  size: number;
41
46
  version: string;
42
- } | undefined | Error | MinimumVersionError | TypeError;
43
- type DownloadResult = true | Error | VerifyFailedError | TypeError;
47
+ } | undefined | CheckResultError;
48
+ type DownloadResult = true | DownloadResultError;
44
49
  type DownloadingInfo = {
45
50
  /**
46
51
  * downloaded percent, 0% - 100%
@@ -69,8 +74,8 @@ interface Updater {
69
74
  * @param data update json url or object
70
75
  * @returns
71
76
  * - `{size: number, version: string}`: available
72
- * - `false`: unavailable
73
- * - `Error`: fail ({@link MinimumVersionError} or other)
77
+ * - `undefined`: unavailable
78
+ * - `CheckResultError`: fail
74
79
  */
75
80
  checkUpdate: (data?: string | UpdateJSON) => Promise<CheckResultType>;
76
81
  /**
@@ -81,7 +86,7 @@ interface Updater {
81
86
  * @param sig signature
82
87
  * @returns
83
88
  * - `true`: success
84
- * - `Error`: fail ({@link VerifyFailedError} or other)
89
+ * - `DownloadResultError`: fail
85
90
  */
86
91
  download: (data?: string | Buffer, sig?: string) => Promise<DownloadResult>;
87
92
  /**
@@ -237,4 +242,4 @@ type SetUpdater = {
237
242
  */
238
243
  declare function initApp(appOptions?: AppOption): SetUpdater;
239
244
 
240
- export { AppOption, IncrementalUpdater, MinimumVersionError, StartupWithUpdater, Updater, UpdaterOption, VerifyFailedError, createUpdater, initApp };
245
+ export { AppOption, DownloadError, IncrementalUpdater, MinimumVersionError, StartupWithUpdater, Updater, UpdaterOption, VerifyFailedError, createUpdater, initApp };
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
+ DownloadError: () => DownloadError,
23
24
  IncrementalUpdater: () => IncrementalUpdater,
24
25
  MinimumVersionError: () => MinimumVersionError,
25
26
  VerifyFailedError: () => VerifyFailedError,
@@ -239,6 +240,11 @@ var VerifyFailedError = class extends Error {
239
240
  this.cert = cert;
240
241
  }
241
242
  };
243
+ var DownloadError = class extends Error {
244
+ constructor() {
245
+ super("download update error");
246
+ }
247
+ };
242
248
  var IncrementalUpdater = class {
243
249
  info;
244
250
  option;
@@ -323,9 +329,13 @@ var IncrementalUpdater = class {
323
329
  data = config.repoFallback;
324
330
  }
325
331
  this.logger?.info(`download ${format} from ${data}`);
326
- const ret = format === "json" ? await config.fn(data, headers) : await config.fn(data, headers, this.info.size, this.onDownloading);
327
- this.logger?.info(`download ${format} success${format === "buffer" ? `, file size: ${ret.length}` : ""}`);
328
- return ret;
332
+ try {
333
+ const ret = format === "json" ? await config.fn(data, headers) : await config.fn(data, headers, this.info.size, this.onDownloading);
334
+ this.logger?.info(`download ${format} success${format === "buffer" ? `, file size: ${ret.length}` : ""}`);
335
+ return ret;
336
+ } catch (e) {
337
+ throw new DownloadError();
338
+ }
329
339
  }
330
340
  async checkUpdate(data) {
331
341
  try {
@@ -430,6 +440,7 @@ function initApp(appOptions) {
430
440
  }
431
441
  // Annotate the CommonJS export names for ESM import in node:
432
442
  0 && (module.exports = {
443
+ DownloadError,
433
444
  IncrementalUpdater,
434
445
  MinimumVersionError,
435
446
  VerifyFailedError,
package/dist/index.mjs CHANGED
@@ -134,6 +134,11 @@ var VerifyFailedError = class extends Error {
134
134
  this.cert = cert;
135
135
  }
136
136
  };
137
+ var DownloadError = class extends Error {
138
+ constructor() {
139
+ super("download update error");
140
+ }
141
+ };
137
142
  var IncrementalUpdater = class {
138
143
  info;
139
144
  option;
@@ -218,9 +223,13 @@ var IncrementalUpdater = class {
218
223
  data = config.repoFallback;
219
224
  }
220
225
  this.logger?.info(`download ${format} from ${data}`);
221
- const ret = format === "json" ? await config.fn(data, headers) : await config.fn(data, headers, this.info.size, this.onDownloading);
222
- this.logger?.info(`download ${format} success${format === "buffer" ? `, file size: ${ret.length}` : ""}`);
223
- return ret;
226
+ try {
227
+ const ret = format === "json" ? await config.fn(data, headers) : await config.fn(data, headers, this.info.size, this.onDownloading);
228
+ this.logger?.info(`download ${format} success${format === "buffer" ? `, file size: ${ret.length}` : ""}`);
229
+ return ret;
230
+ } catch (e) {
231
+ throw new DownloadError();
232
+ }
224
233
  }
225
234
  async checkUpdate(data) {
226
235
  try {
@@ -324,6 +333,7 @@ function initApp(appOptions) {
324
333
  };
325
334
  }
326
335
  export {
336
+ DownloadError,
327
337
  IncrementalUpdater,
328
338
  MinimumVersionError,
329
339
  VerifyFailedError,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
3
  "author": "subframe7536",
4
- "version": "0.7.9",
4
+ "version": "0.7.10",
5
5
  "description": "electron incremental update tools, powered by vite",
6
6
  "scripts": {
7
7
  "build": "tsup && node fix-module.js",
@@ -58,4 +58,4 @@
58
58
  "ci-info": "^3.8.0",
59
59
  "selfsigned": "^2.1.1"
60
60
  }
61
- }
61
+ }