electron-incremental-update 1.2.0 → 1.3.0

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.cjs CHANGED
@@ -20,12 +20,14 @@ 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,
24
- MinimumVersionError: () => MinimumVersionError,
23
+ ErrorInfo: () => ErrorInfo,
25
24
  Updater: () => Updater,
26
- VerifyFailedError: () => VerifyFailedError,
25
+ UpdaterError: () => UpdaterError,
27
26
  createUpdater: () => createUpdater,
27
+ downloadBufferDefault: () => downloadBufferDefault,
28
+ downloadJSONDefault: () => downloadJSONDefault,
28
29
  initApp: () => initApp,
30
+ isLowerVersionDefault: () => isLowerVersionDefault,
29
31
  startupWithUpdater: () => startupWithUpdater
30
32
  });
31
33
  module.exports = __toCommonJS(src_exports);
@@ -99,8 +101,7 @@ async function unzipFile(gzipPath, targetFilePath = gzipPath.slice(0, -3)) {
99
101
 
100
102
  // src/utils/pure.ts
101
103
  function parseVersion(version) {
102
- const semver = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?/i;
103
- const match = semver.exec(version);
104
+ const match = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?/i.exec(version);
104
105
  if (!match) {
105
106
  throw new TypeError(`invalid version: ${version}`);
106
107
  }
@@ -158,100 +159,67 @@ var verify = (buffer, signature, cert) => {
158
159
  var import_node_crypto3 = require("crypto");
159
160
 
160
161
  // src/updater/types.ts
161
- var MinimumVersionError = class extends Error {
162
- currentVersion;
163
- minVersion;
164
- constructor(version, minimumVersion) {
165
- super(`current entry version is ${version}, less than the minimumVersion ${minimumVersion}`);
166
- this.currentVersion = version;
167
- this.minVersion = minimumVersion;
168
- }
169
- };
170
- var VerifyFailedError = class extends Error {
171
- signature;
172
- cert;
173
- constructor(signature, cert) {
174
- super("verify failed, invalid signature or certificate");
175
- this.signature = signature;
176
- this.cert = cert;
177
- }
162
+ var ErrorInfo = {
163
+ downlaod: "Download failed",
164
+ validate: "Validate failed",
165
+ param: "Missing params",
166
+ version: "Unsatisfied version"
178
167
  };
179
- var DownloadError = class extends Error {
180
- constructor(msg) {
181
- super(`download update error, ${msg}`);
168
+ var UpdaterError = class extends Error {
169
+ constructor(msg, info) {
170
+ super(msg + ": " + info);
182
171
  }
183
172
  };
184
173
 
185
174
  // src/updater/defaultFunctions/download.ts
186
175
  var import_electron2 = require("electron");
187
- var downloadJSONDefault = async (url, headers) => {
176
+ async function downlaodFn(url, headers, onResponse) {
188
177
  await waitAppReady();
189
178
  return new Promise((resolve2, reject) => {
190
- const request = import_electron2.net.request({
191
- url,
192
- method: "GET",
193
- redirect: "follow"
194
- });
195
- Object.keys(headers).forEach((key) => {
196
- request.setHeader(key, headers[key]);
197
- });
198
- request.on("response", (res) => {
199
- let data = "";
200
- res.on("data", (chunk) => data += chunk);
201
- res.on("end", () => {
202
- try {
203
- const json = JSON.parse(data);
204
- if (isUpdateJSON(json)) {
205
- resolve2(json);
206
- } else {
207
- throw Error;
208
- }
209
- } catch (e) {
210
- reject(new Error("invalid json"));
179
+ const request = import_electron2.net.request({ url, method: "GET", redirect: "follow" });
180
+ Object.keys(headers).forEach((key) => request.setHeader(key, headers[key]));
181
+ request.on("response", (res) => onResponse(res, resolve2, reject));
182
+ request.on("error", reject);
183
+ request.end();
184
+ });
185
+ }
186
+ var downloadJSONDefault = async (url, headers) => {
187
+ return await downlaodFn(url, headers, (resp, resolve2, reject) => {
188
+ let data = "";
189
+ resp.on("data", (chunk) => data += chunk);
190
+ resp.on("end", () => {
191
+ try {
192
+ const json = JSON.parse(data);
193
+ if (isUpdateJSON(json)) {
194
+ resolve2(json);
195
+ } else {
196
+ throw Error;
211
197
  }
212
- });
213
- });
214
- request.on("error", (e) => {
215
- reject(e);
198
+ } catch (ignore) {
199
+ reject(new Error("invalid update json"));
200
+ }
216
201
  });
217
- request.end();
202
+ resp.on("aborted", () => reject(new Error("aborted")));
203
+ resp.on("error", () => reject(new Error("download error")));
218
204
  });
219
205
  };
220
206
  var downloadBufferDefault = async (url, headers, total, onDownloading) => {
221
- await waitAppReady();
222
207
  let current = 0;
223
- return new Promise((resolve2, reject) => {
224
- const request = import_electron2.net.request({
225
- url,
226
- method: "GET",
227
- redirect: "follow"
228
- });
229
- Object.keys(headers).forEach((key) => {
230
- request.setHeader(key, headers[key]);
231
- });
232
- request.on("response", (res) => {
233
- let data = [];
234
- res.on("data", (chunk) => {
235
- current += chunk.length;
236
- onDownloading?.({
237
- percent: `${+(current / total).toFixed(2) * 100}%`,
238
- total,
239
- current
240
- });
241
- data.push(chunk);
242
- });
243
- res.on("end", () => {
244
- resolve2(Buffer.concat(data));
245
- });
246
- }).on("error", (e) => {
247
- reject(e);
208
+ return await downlaodFn(url, headers, (resp, resolve2, reject) => {
209
+ let data = [];
210
+ resp.on("data", (chunk) => {
211
+ current += chunk.length;
212
+ onDownloading?.({ percent: `${+(current / total).toFixed(2) * 100}%`, total, current });
213
+ data.push(chunk);
248
214
  });
249
- request.end();
215
+ resp.on("end", () => resolve2(Buffer.concat(data)));
216
+ resp.on("aborted", () => reject(new Error("aborted")));
217
+ resp.on("error", () => reject(new Error("download error")));
250
218
  });
251
219
  };
252
220
 
253
221
  // src/updater/defaultFunctions/compareVersion.ts
254
- var compareVersionDefault = (version1, version2) => {
222
+ var isLowerVersionDefault = (version1, version2) => {
255
223
  const oldV = parseVersion(version1);
256
224
  const newV = parseVersion(version2);
257
225
  function compareStrings(str1, str2) {
@@ -316,13 +284,13 @@ var Updater = class {
316
284
  this.tmpFilePath = `${this.asarPath}.tmp`;
317
285
  }
318
286
  async needUpdate(version, minVersion) {
319
- const compare = this.option.overrideFunctions?.compareVersion ?? compareVersionDefault;
287
+ const isLowerVersion = this.option.overrideFunctions?.isLowerVersion ?? isLowerVersionDefault;
320
288
  const { appVersion, entryVersion } = getVersions();
321
- if (await compare(entryVersion, minVersion)) {
322
- throw new MinimumVersionError(entryVersion, minVersion);
289
+ if (await isLowerVersion(entryVersion, minVersion)) {
290
+ throw new UpdaterError(ErrorInfo.version, `entry version (${entryVersion}) < minimumVersion (${minVersion})`);
323
291
  }
324
292
  this.logger?.info(`check update: current version is ${appVersion}, new version is ${version}`);
325
- return await compare(appVersion, version);
293
+ return await isLowerVersion(appVersion, version);
326
294
  }
327
295
  async parseData(format, data) {
328
296
  if ((0, import_node_fs3.existsSync)(this.tmpFilePath)) {
@@ -333,14 +301,12 @@ var Updater = class {
333
301
  this.logger?.warn(`remove .gz file: ${this.gzipPath}`);
334
302
  (0, import_node_fs3.rmSync)(this.gzipPath);
335
303
  }
336
- if (!["string", "object", "undefined"].includes(typeof data)) {
337
- throw new TypeError(`invalid type at format '${format}': ${data}`);
338
- }
339
- if (typeof data === "object" && (format === "json" && isUpdateJSON(data) || format === "buffer" && Buffer.isBuffer(data))) {
340
- return data;
341
- }
342
304
  if (typeof data === "object") {
343
- throw new TypeError(`invalid type at format '${format}': ${data}`);
305
+ if (format === "json" && isUpdateJSON(data) || format === "buffer" && Buffer.isBuffer(data)) {
306
+ return data;
307
+ } else {
308
+ throw new UpdaterError(ErrorInfo.param, `invalid type at format '${format}': ${JSON.stringify(data)}`);
309
+ }
344
310
  }
345
311
  const ua = this.option.downloadConfig?.userAgent || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36";
346
312
  const headers = {
@@ -348,11 +314,11 @@ var Updater = class {
348
314
  UserAgent: ua,
349
315
  ...this.option.downloadConfig?.extraHeader
350
316
  };
351
- this.logger?.info(`download headers: ${JSON.stringify(headers, null, 2)}`);
317
+ this.logger?.debug(`download headers: ${JSON.stringify(headers)}`);
352
318
  const config = format === "json" ? {
353
319
  name: "updateJsonURL",
354
320
  url: this.option.updateJsonURL,
355
- repoFallback: `${this.option.repository.replace("github.com", "raw.githubusercontent.com")}/master/version.json`,
321
+ repoFallback: `${this.option.repository?.replace("github.com", "raw.githubusercontent.com")}/master/version.json`,
356
322
  fn: this.option.overrideFunctions?.downloadJSON ?? downloadJSONDefault
357
323
  } : {
358
324
  name: "releaseAsarURL",
@@ -364,32 +330,22 @@ var Updater = class {
364
330
  if (!data) {
365
331
  this.logger?.debug(`no ${config.name}, fallback to use repository`);
366
332
  if (!this.option.repository) {
367
- throw new Error(`${config.name} or repository are not set`);
333
+ throw new UpdaterError(ErrorInfo.param, `${config.name} or repository is not set`);
368
334
  }
369
335
  if (format === "buffer" && !this.info?.version) {
370
- throw new Error("version are not set");
336
+ throw new UpdaterError(ErrorInfo.param, "version is not set");
371
337
  }
372
338
  data = config.repoFallback;
373
339
  }
374
- this.logger?.info(`download ${format} from ${data}`);
340
+ this.logger?.debug(`download ${format} from ${data}`);
375
341
  try {
376
342
  const ret = format === "json" ? await config.fn(data, headers) : await config.fn(data, headers, this.info.size, this.onDownloading);
377
- this.logger?.info(`download ${format} success${format === "buffer" ? `, file size: ${ret.length}` : ""}`);
343
+ this.logger?.debug(`download ${format} success${format === "buffer" ? `, file size: ${ret.length}` : ""}`);
378
344
  return ret;
379
345
  } catch (e) {
380
- throw new DownloadError(e.toString());
346
+ throw new UpdaterError(ErrorInfo.downlaod, e.toString());
381
347
  }
382
348
  }
383
- /**
384
- * check update info
385
- *
386
- * if you want to update **offline**, you can set `data` and `sig` add update info
387
- * @param data custom download URL of `updatejson` or existing update json
388
- * @returns
389
- * - Available:`{size: number, version: string}`
390
- * - Unavailable: `undefined`
391
- * - Fail: `CheckResultError`
392
- */
393
349
  async checkUpdate(data) {
394
350
  try {
395
351
  let { signature, size, version, minimumVersion, beta } = await this.parseData("json", data);
@@ -399,7 +355,7 @@ var Updater = class {
399
355
  minimumVersion = beta.minimumVersion;
400
356
  size = beta.size;
401
357
  }
402
- this.logger?.info(`checked version: ${version}, size: ${size}, signature: ${signature}`);
358
+ this.logger?.debug(`checked version: ${version}, size: ${size}, signature: ${signature}`);
403
359
  if (!await this.needUpdate(version, minimumVersion)) {
404
360
  this.logger?.info(`update unavailable: ${version} is the latest version`);
405
361
  return void 0;
@@ -418,33 +374,23 @@ var Updater = class {
418
374
  return error;
419
375
  }
420
376
  }
421
- /**
422
- * download update
423
- *
424
- * if you want to update **offline**, you can set both `data` and `sig` to verify and install
425
- * @param data custom download URL of `asar.gz` or existing `asar.gz` buffer
426
- * @param sig signature
427
- * @returns
428
- * - `true`: success
429
- * - `DownloadResultError`: fail
430
- */
431
377
  async download(data, sig) {
432
378
  try {
433
379
  const _sig = sig ?? this.info?.signature;
434
380
  if (!_sig) {
435
- throw new Error("signature are not set, please checkUpdate first or set the second parameter");
381
+ throw new UpdaterError(ErrorInfo.param, "signature is empty");
436
382
  }
437
383
  const buffer = await this.parseData("buffer", data);
438
- this.logger?.info("verify start");
384
+ this.logger?.debug("verify start");
439
385
  const _verify = this.option.overrideFunctions?.verifySignaure ?? verify;
440
386
  const _ver = await _verify(buffer, _sig, this.CERT);
441
387
  if (!_ver) {
442
- throw new VerifyFailedError(_sig, this.CERT);
388
+ throw new UpdaterError(ErrorInfo.validate, "invalid signature or certificate");
443
389
  }
444
- this.logger?.info("verify success");
445
- this.logger?.info(`write to ${this.gzipPath}`);
390
+ this.logger?.debug("verify success");
391
+ this.logger?.debug(`write to ${this.gzipPath}`);
446
392
  (0, import_node_fs3.writeFileSync)(this.gzipPath, buffer);
447
- this.logger?.info(`extract to ${this.tmpFilePath}`);
393
+ this.logger?.debug(`extract to ${this.tmpFilePath}`);
448
394
  await unzipFile(this.gzipPath, this.tmpFilePath);
449
395
  this.logger?.info(`download success, version: ${_ver}`);
450
396
  this.info = void 0;
@@ -517,11 +463,13 @@ async function initApp(appOptions = {}) {
517
463
  }
518
464
  // Annotate the CommonJS export names for ESM import in node:
519
465
  0 && (module.exports = {
520
- DownloadError,
521
- MinimumVersionError,
466
+ ErrorInfo,
522
467
  Updater,
523
- VerifyFailedError,
468
+ UpdaterError,
524
469
  createUpdater,
470
+ downloadBufferDefault,
471
+ downloadJSONDefault,
525
472
  initApp,
473
+ isLowerVersionDefault,
526
474
  startupWithUpdater
527
475
  });
package/dist/index.d.cts CHANGED
@@ -1,22 +1,16 @@
1
1
  import { U as UpdateInfo, a as UpdateJSON } from './pure-GoN_3MEj.cjs';
2
2
 
3
- declare class MinimumVersionError extends Error {
4
- currentVersion: string;
5
- minVersion: string;
6
- constructor(version: string, minimumVersion: string);
7
- }
8
- declare class VerifyFailedError extends Error {
9
- signature: string;
10
- cert: string;
11
- constructor(signature: string, cert: string);
12
- }
13
- declare class DownloadError extends Error {
14
- constructor(msg: string);
3
+ declare const ErrorInfo: {
4
+ readonly downlaod: "Download failed";
5
+ readonly validate: "Validate failed";
6
+ readonly param: "Missing params";
7
+ readonly version: "Unsatisfied version";
8
+ };
9
+ declare class UpdaterError extends Error {
10
+ constructor(msg: typeof ErrorInfo[keyof typeof ErrorInfo], info: string);
15
11
  }
16
- type CheckResult = UpdateInfo | undefined | CheckResultError;
17
- type CheckResultError = MinimumVersionError | DownloadError | TypeError | Error;
18
- type DownloadResult = true | DownloadResultError;
19
- type DownloadResultError = DownloadError | VerifyFailedError | TypeError | Error;
12
+ type CheckResult = UpdateInfo | undefined | UpdaterError;
13
+ type DownloadResult = true | UpdaterError;
20
14
  type DownloadingInfo = {
21
15
  /**
22
16
  * downloaded percent, 0% - 100%
@@ -42,9 +36,9 @@ type UpdaterOverrideFunctions = {
42
36
  * custom version compare function
43
37
  * @param version1 old version string
44
38
  * @param version2 new version string
45
- * @returns whether version1 < version2
39
+ * @returns if version1 < version2
46
40
  */
47
- compareVersion?: (version1: string, version2: string) => boolean | Promise<boolean>;
41
+ isLowerVersion?: (version1: string, version2: string) => boolean | Promise<boolean>;
48
42
  /**
49
43
  * custom verify signature function
50
44
  * @param buffer file buffer
@@ -160,33 +154,67 @@ declare class Updater {
160
154
  */
161
155
  private parseData;
162
156
  /**
163
- * check update info
164
- *
165
- * if you want to update **offline**, you can set `data` and `sig` add update info
166
- * @param data custom download URL of `updatejson` or existing update json
157
+ * check update info using default options
158
+ * @returns
159
+ * - Available: `{size: number, version: string}`
160
+ * - Unavailable: `undefined`
161
+ * - Fail: `UpdaterError`
162
+ */
163
+ checkUpdate(): Promise<CheckResult>;
164
+ /**
165
+ * check update info using custom url
166
+ * @param url custom download URL of `updatejson`
167
167
  * @returns
168
168
  * - Available:`{size: number, version: string}`
169
169
  * - Unavailable: `undefined`
170
- * - Fail: `CheckResultError`
170
+ * - Fail: `UpdaterError`
171
171
  */
172
- checkUpdate(data?: string | UpdateJSON): Promise<CheckResult>;
172
+ checkUpdate(url: string): Promise<CheckResult>;
173
173
  /**
174
- * download update
175
- *
176
- * if you want to update **offline**, you can set both `data` and `sig` to verify and install
177
- * @param data custom download URL of `asar.gz` or existing `asar.gz` buffer
174
+ * check update info using existing update json
175
+ * @param data existing update json
176
+ * @returns
177
+ * - Available:`{size: number, version: string}`
178
+ * - Unavailable: `undefined`
179
+ * - Fail: `UpdaterError`
180
+ */
181
+ checkUpdate(data: UpdateJSON): Promise<CheckResult>;
182
+ /**
183
+ * download update using default options
184
+ * @returns
185
+ * - Success: `true`
186
+ * - Fail: `UpdaterError`
187
+ */
188
+ download(): Promise<DownloadResult>;
189
+ /**
190
+ * download update using custom url
191
+ * @param url custom download URL
192
+ * @returns
193
+ * - Success: `true`
194
+ * - Fail: `UpdaterError`
195
+ */
196
+ download(url: string): Promise<DownloadResult>;
197
+ /**
198
+ * download update using existing `asar.gz` buffer and signature
199
+ * @param data existing `asar.gz` buffer
178
200
  * @param sig signature
179
201
  * @returns
180
- * - `true`: success
181
- * - `DownloadResultError`: fail
202
+ * - Success: `true`
203
+ * - Fail: `UpdaterError`
182
204
  */
183
- download(data?: Buffer, sig?: string): Promise<DownloadResult>;
205
+ download(data: Buffer, sig: string): Promise<DownloadResult>;
184
206
  /**
185
207
  * quit App and install
186
208
  */
187
209
  quitAndInstall(): void;
188
210
  }
189
211
 
212
+ type Func = Required<UpdaterOverrideFunctions>;
213
+ declare const downloadJSONDefault: Func['downloadJSON'];
214
+ declare const downloadBufferDefault: Func['downloadBuffer'];
215
+
216
+ declare const isLowerVersionDefault: Func['isLowerVersion'];
217
+
190
218
  /**
191
219
  * create updater instance
192
220
  * @param option updater option
@@ -273,4 +301,4 @@ declare function startupWithUpdater(fn: (updater: Updater) => Promisable<void>):
273
301
  */
274
302
  declare function initApp(appOptions?: AppOption): Promise<void>;
275
303
 
276
- export { type AppOption, type CheckResult, type CheckResultError, DownloadError, type DownloadResult, type DownloadResultError, type DownloadingInfo, type Logger, MinimumVersionError, Updater, type UpdaterDownloadConfig, type UpdaterOption, type UpdaterOverrideFunctions, VerifyFailedError, createUpdater, initApp, startupWithUpdater };
304
+ export { type AppOption, type CheckResult, type DownloadResult, type DownloadingInfo, ErrorInfo, type Func, type Logger, Updater, type UpdaterDownloadConfig, UpdaterError, type UpdaterOption, type UpdaterOverrideFunctions, createUpdater, downloadBufferDefault, downloadJSONDefault, initApp, isLowerVersionDefault, startupWithUpdater };
package/dist/index.d.ts CHANGED
@@ -1,22 +1,16 @@
1
1
  import { U as UpdateInfo, a as UpdateJSON } from './pure-GoN_3MEj.js';
2
2
 
3
- declare class MinimumVersionError extends Error {
4
- currentVersion: string;
5
- minVersion: string;
6
- constructor(version: string, minimumVersion: string);
7
- }
8
- declare class VerifyFailedError extends Error {
9
- signature: string;
10
- cert: string;
11
- constructor(signature: string, cert: string);
12
- }
13
- declare class DownloadError extends Error {
14
- constructor(msg: string);
3
+ declare const ErrorInfo: {
4
+ readonly downlaod: "Download failed";
5
+ readonly validate: "Validate failed";
6
+ readonly param: "Missing params";
7
+ readonly version: "Unsatisfied version";
8
+ };
9
+ declare class UpdaterError extends Error {
10
+ constructor(msg: typeof ErrorInfo[keyof typeof ErrorInfo], info: string);
15
11
  }
16
- type CheckResult = UpdateInfo | undefined | CheckResultError;
17
- type CheckResultError = MinimumVersionError | DownloadError | TypeError | Error;
18
- type DownloadResult = true | DownloadResultError;
19
- type DownloadResultError = DownloadError | VerifyFailedError | TypeError | Error;
12
+ type CheckResult = UpdateInfo | undefined | UpdaterError;
13
+ type DownloadResult = true | UpdaterError;
20
14
  type DownloadingInfo = {
21
15
  /**
22
16
  * downloaded percent, 0% - 100%
@@ -42,9 +36,9 @@ type UpdaterOverrideFunctions = {
42
36
  * custom version compare function
43
37
  * @param version1 old version string
44
38
  * @param version2 new version string
45
- * @returns whether version1 < version2
39
+ * @returns if version1 < version2
46
40
  */
47
- compareVersion?: (version1: string, version2: string) => boolean | Promise<boolean>;
41
+ isLowerVersion?: (version1: string, version2: string) => boolean | Promise<boolean>;
48
42
  /**
49
43
  * custom verify signature function
50
44
  * @param buffer file buffer
@@ -160,33 +154,67 @@ declare class Updater {
160
154
  */
161
155
  private parseData;
162
156
  /**
163
- * check update info
164
- *
165
- * if you want to update **offline**, you can set `data` and `sig` add update info
166
- * @param data custom download URL of `updatejson` or existing update json
157
+ * check update info using default options
158
+ * @returns
159
+ * - Available: `{size: number, version: string}`
160
+ * - Unavailable: `undefined`
161
+ * - Fail: `UpdaterError`
162
+ */
163
+ checkUpdate(): Promise<CheckResult>;
164
+ /**
165
+ * check update info using custom url
166
+ * @param url custom download URL of `updatejson`
167
167
  * @returns
168
168
  * - Available:`{size: number, version: string}`
169
169
  * - Unavailable: `undefined`
170
- * - Fail: `CheckResultError`
170
+ * - Fail: `UpdaterError`
171
171
  */
172
- checkUpdate(data?: string | UpdateJSON): Promise<CheckResult>;
172
+ checkUpdate(url: string): Promise<CheckResult>;
173
173
  /**
174
- * download update
175
- *
176
- * if you want to update **offline**, you can set both `data` and `sig` to verify and install
177
- * @param data custom download URL of `asar.gz` or existing `asar.gz` buffer
174
+ * check update info using existing update json
175
+ * @param data existing update json
176
+ * @returns
177
+ * - Available:`{size: number, version: string}`
178
+ * - Unavailable: `undefined`
179
+ * - Fail: `UpdaterError`
180
+ */
181
+ checkUpdate(data: UpdateJSON): Promise<CheckResult>;
182
+ /**
183
+ * download update using default options
184
+ * @returns
185
+ * - Success: `true`
186
+ * - Fail: `UpdaterError`
187
+ */
188
+ download(): Promise<DownloadResult>;
189
+ /**
190
+ * download update using custom url
191
+ * @param url custom download URL
192
+ * @returns
193
+ * - Success: `true`
194
+ * - Fail: `UpdaterError`
195
+ */
196
+ download(url: string): Promise<DownloadResult>;
197
+ /**
198
+ * download update using existing `asar.gz` buffer and signature
199
+ * @param data existing `asar.gz` buffer
178
200
  * @param sig signature
179
201
  * @returns
180
- * - `true`: success
181
- * - `DownloadResultError`: fail
202
+ * - Success: `true`
203
+ * - Fail: `UpdaterError`
182
204
  */
183
- download(data?: Buffer, sig?: string): Promise<DownloadResult>;
205
+ download(data: Buffer, sig: string): Promise<DownloadResult>;
184
206
  /**
185
207
  * quit App and install
186
208
  */
187
209
  quitAndInstall(): void;
188
210
  }
189
211
 
212
+ type Func = Required<UpdaterOverrideFunctions>;
213
+ declare const downloadJSONDefault: Func['downloadJSON'];
214
+ declare const downloadBufferDefault: Func['downloadBuffer'];
215
+
216
+ declare const isLowerVersionDefault: Func['isLowerVersion'];
217
+
190
218
  /**
191
219
  * create updater instance
192
220
  * @param option updater option
@@ -273,4 +301,4 @@ declare function startupWithUpdater(fn: (updater: Updater) => Promisable<void>):
273
301
  */
274
302
  declare function initApp(appOptions?: AppOption): Promise<void>;
275
303
 
276
- export { type AppOption, type CheckResult, type CheckResultError, DownloadError, type DownloadResult, type DownloadResultError, type DownloadingInfo, type Logger, MinimumVersionError, Updater, type UpdaterDownloadConfig, type UpdaterOption, type UpdaterOverrideFunctions, VerifyFailedError, createUpdater, initApp, startupWithUpdater };
304
+ export { type AppOption, type CheckResult, type DownloadResult, type DownloadingInfo, ErrorInfo, type Func, type Logger, Updater, type UpdaterDownloadConfig, UpdaterError, type UpdaterOption, type UpdaterOverrideFunctions, createUpdater, downloadBufferDefault, downloadJSONDefault, initApp, isLowerVersionDefault, startupWithUpdater };