electron-incremental-update 2.0.0-beta.5 → 2.0.0-beta.6

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.
@@ -40,14 +40,16 @@ function aesDecrypt(encryptedText, key, iv) {
40
40
  const decipher = createDecipheriv("aes-256-cbc", key, iv);
41
41
  return decipher.update(encryptedText, "base64url", "utf8") + decipher.final("utf8");
42
42
  }
43
- function defaultVerify(buffer, signature, cert) {
43
+ function defaultVerifySignature(buffer, version, signature, cert) {
44
44
  try {
45
- const [sig, version] = aesDecrypt(signature, hashBuffer(cert, 32), hashBuffer(buffer, 16)).split("%");
46
- const result = createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
47
- return result ? version : void 0;
45
+ const [sig, ver] = aesDecrypt(signature, hashBuffer(cert, 32), hashBuffer(buffer, 16)).split("%");
46
+ if (ver !== version) {
47
+ return false;
48
+ }
49
+ return createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
48
50
  } catch {
49
- return void 0;
51
+ return false;
50
52
  }
51
53
  }
52
54
 
53
- export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerify, defaultZipFile, hashBuffer };
55
+ export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultZipFile, hashBuffer };
package/dist/index.cjs CHANGED
@@ -153,10 +153,11 @@ var Updater = class extends events.EventEmitter {
153
153
  this.emit("update-available", this.info);
154
154
  return true;
155
155
  }
156
- async downloadUpdate(data, sig) {
157
- const _sig = sig ?? this.info?.signature;
158
- if (!_sig) {
159
- this.err("download failed", "param", "no update signature, please call `checkUpdate` first");
156
+ async downloadUpdate(data, info) {
157
+ const _sig = info?.signature ?? this.info?.signature;
158
+ const _version = info?.version ?? this.info?.version;
159
+ if (!_sig || !_version) {
160
+ this.err("download failed", "param", "no update signature, please call `checkUpdate` first or manually setup params");
160
161
  return false;
161
162
  }
162
163
  const buffer = await this.fetch("buffer", data ? Buffer.from(data) : void 0);
@@ -165,8 +166,7 @@ var Updater = class extends events.EventEmitter {
165
166
  return false;
166
167
  }
167
168
  this.logger?.debug("verify start");
168
- const _ver = await this.provider.verifySignaure(buffer, _sig, this.CERT);
169
- if (!_ver) {
169
+ if (!await this.provider.verifySignaure(buffer, _version, _sig, this.CERT)) {
170
170
  this.err("download failed", "validate", "invalid signature / certificate pair");
171
171
  return false;
172
172
  }
@@ -175,7 +175,7 @@ var Updater = class extends events.EventEmitter {
175
175
  const tmpFilePath = getPathFromAppNameAsar() + ".tmp";
176
176
  this.logger?.debug(`install to ${tmpFilePath}`);
177
177
  fs.writeFileSync(tmpFilePath, await this.provider.unzipFile(buffer));
178
- this.logger?.info(`download success, version: ${_ver}`);
178
+ this.logger?.info(`download success, version: ${_version}`);
179
179
  this.info = void 0;
180
180
  this.emit("update-downloaded");
181
181
  return true;
package/dist/index.js CHANGED
@@ -123,10 +123,11 @@ var Updater = class extends EventEmitter {
123
123
  this.emit("update-available", this.info);
124
124
  return true;
125
125
  }
126
- async downloadUpdate(data, sig) {
127
- const _sig = sig ?? this.info?.signature;
128
- if (!_sig) {
129
- this.err("download failed", "param", "no update signature, please call `checkUpdate` first");
126
+ async downloadUpdate(data, info) {
127
+ const _sig = info?.signature ?? this.info?.signature;
128
+ const _version = info?.version ?? this.info?.version;
129
+ if (!_sig || !_version) {
130
+ this.err("download failed", "param", "no update signature, please call `checkUpdate` first or manually setup params");
130
131
  return false;
131
132
  }
132
133
  const buffer = await this.fetch("buffer", data ? Buffer.from(data) : void 0);
@@ -135,8 +136,7 @@ var Updater = class extends EventEmitter {
135
136
  return false;
136
137
  }
137
138
  this.logger?.debug("verify start");
138
- const _ver = await this.provider.verifySignaure(buffer, _sig, this.CERT);
139
- if (!_ver) {
139
+ if (!await this.provider.verifySignaure(buffer, _version, _sig, this.CERT)) {
140
140
  this.err("download failed", "validate", "invalid signature / certificate pair");
141
141
  return false;
142
142
  }
@@ -145,7 +145,7 @@ var Updater = class extends EventEmitter {
145
145
  const tmpFilePath = getPathFromAppNameAsar() + ".tmp";
146
146
  this.logger?.debug(`install to ${tmpFilePath}`);
147
147
  writeFileSync(tmpFilePath, await this.provider.unzipFile(buffer));
148
- this.logger?.info(`download success, version: ${_ver}`);
148
+ this.logger?.info(`download success, version: ${_version}`);
149
149
  this.info = void 0;
150
150
  this.emit("update-downloaded");
151
151
  return true;
package/dist/provider.cjs CHANGED
@@ -104,14 +104,15 @@ async function defaultDownloadAsar(url, headers, onDownloading) {
104
104
  const total = getHeader(resp.headers, "content-length") || -1;
105
105
  let data = [];
106
106
  resp.on("data", (chunk) => {
107
- transferred += chunk.length;
107
+ const delta = chunk.length;
108
+ transferred += delta;
108
109
  const current = Date.now();
109
110
  onDownloading?.({
110
111
  percent: +(transferred / total).toFixed(2) * 100,
111
112
  total,
112
113
  transferred,
113
- delta: chunk.length,
114
- bps: chunk.length / ((current - time) * 1e3)
114
+ delta,
115
+ bps: delta / ((current - time) * 1e3)
115
116
  });
116
117
  time = current;
117
118
  data.push(chunk);
@@ -127,13 +128,15 @@ function aesDecrypt(encryptedText, key, iv) {
127
128
  const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
128
129
  return decipher.update(encryptedText, "base64url", "utf8") + decipher.final("utf8");
129
130
  }
130
- function defaultVerify(buffer, signature, cert) {
131
+ function defaultVerifySignature(buffer, version, signature, cert) {
131
132
  try {
132
- const [sig, version] = aesDecrypt(signature, hashBuffer(cert, 32), hashBuffer(buffer, 16)).split("%");
133
- const result = crypto.createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
134
- return result ? version : void 0;
133
+ const [sig, ver] = aesDecrypt(signature, hashBuffer(cert, 32), hashBuffer(buffer, 16)).split("%");
134
+ if (ver !== version) {
135
+ return false;
136
+ }
137
+ return crypto.createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
135
138
  } catch {
136
- return void 0;
139
+ return false;
137
140
  }
138
141
  }
139
142
  async function defaultUnzipFile(buffer) {
@@ -152,7 +155,7 @@ async function defaultUnzipFile(buffer) {
152
155
  var BaseProvider = class {
153
156
  name = "BaseProvider";
154
157
  isLowerVersion = defaultIsLowerVersion;
155
- verifySignaure = defaultVerify;
158
+ verifySignaure = defaultVerifySignature;
156
159
  unzipFile = defaultUnzipFile;
157
160
  };
158
161
 
@@ -187,7 +190,7 @@ var GitHubProvider = class extends BaseProvider {
187
190
  }
188
191
  async downloadJSON(versionPath) {
189
192
  return await defaultDownloadUpdateJSON(
190
- await this.parseURL(false, `HEAD/${versionPath}`),
193
+ await this.parseURL(false, `${this.options.branch ?? "HEAD"}/${versionPath}`),
191
194
  { accept: "application/json", ...this.options.extraHeaders }
192
195
  );
193
196
  }
package/dist/provider.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defaultVerify, defaultUnzipFile } from './chunk-JSYIRKTR.js';
1
+ import { defaultVerifySignature, defaultUnzipFile } from './chunk-N77WQ5WB.js';
2
2
  import { defaultIsLowerVersion, isUpdateJSON } from './chunk-72ZAJ7AF.js';
3
3
  import { URL } from 'node:url';
4
4
  import { app, net } from 'electron';
@@ -50,14 +50,15 @@ async function defaultDownloadAsar(url, headers, onDownloading) {
50
50
  const total = getHeader(resp.headers, "content-length") || -1;
51
51
  let data = [];
52
52
  resp.on("data", (chunk) => {
53
- transferred += chunk.length;
53
+ const delta = chunk.length;
54
+ transferred += delta;
54
55
  const current = Date.now();
55
56
  onDownloading?.({
56
57
  percent: +(transferred / total).toFixed(2) * 100,
57
58
  total,
58
59
  transferred,
59
- delta: chunk.length,
60
- bps: chunk.length / ((current - time) * 1e3)
60
+ delta,
61
+ bps: delta / ((current - time) * 1e3)
61
62
  });
62
63
  time = current;
63
64
  data.push(chunk);
@@ -70,7 +71,7 @@ async function defaultDownloadAsar(url, headers, onDownloading) {
70
71
  var BaseProvider = class {
71
72
  name = "BaseProvider";
72
73
  isLowerVersion = defaultIsLowerVersion;
73
- verifySignaure = defaultVerify;
74
+ verifySignaure = defaultVerifySignature;
74
75
  unzipFile = defaultUnzipFile;
75
76
  };
76
77
 
@@ -105,7 +106,7 @@ var GitHubProvider = class extends BaseProvider {
105
106
  }
106
107
  async downloadJSON(versionPath) {
107
108
  return await defaultDownloadUpdateJSON(
108
- await this.parseURL(false, `HEAD/${versionPath}`),
109
+ await this.parseURL(false, `${this.options.branch ?? "HEAD"}/${versionPath}`),
109
110
  { accept: "application/json", ...this.options.extraHeaders }
110
111
  );
111
112
  }
package/dist/utils.cjs CHANGED
@@ -5,6 +5,7 @@ var path = require('path');
5
5
  var electron = require('electron');
6
6
  var zlib = require('zlib');
7
7
  var crypto = require('crypto');
8
+ var ciInfo = require('ci-info');
8
9
 
9
10
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
11
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -186,13 +187,15 @@ function aesDecrypt(encryptedText, key, iv) {
186
187
  const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
187
188
  return decipher.update(encryptedText, "base64url", "utf8") + decipher.final("utf8");
188
189
  }
189
- function defaultVerify(buffer, signature, cert) {
190
+ function defaultVerifySignature(buffer, version, signature, cert) {
190
191
  try {
191
- const [sig, version] = aesDecrypt(signature, hashBuffer(cert, 32), hashBuffer(buffer, 16)).split("%");
192
- const result = crypto.createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
193
- return result ? version : void 0;
192
+ const [sig, ver] = aesDecrypt(signature, hashBuffer(cert, 32), hashBuffer(buffer, 16)).split("%");
193
+ if (ver !== version) {
194
+ return false;
195
+ }
196
+ return crypto.createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
194
197
  } catch {
195
- return void 0;
198
+ return false;
196
199
  }
197
200
  }
198
201
 
@@ -203,13 +206,17 @@ async function autoUpdate(updater) {
203
206
  }
204
207
  }
205
208
 
209
+ Object.defineProperty(exports, "isCI", {
210
+ enumerable: true,
211
+ get: function () { return ciInfo.isCI; }
212
+ });
206
213
  exports.aesDecrypt = aesDecrypt;
207
214
  exports.aesEncrypt = aesEncrypt;
208
215
  exports.autoUpdate = autoUpdate;
209
216
  exports.defaultIsLowerVersion = defaultIsLowerVersion;
210
217
  exports.defaultSignature = defaultSignature;
211
218
  exports.defaultUnzipFile = defaultUnzipFile;
212
- exports.defaultVerify = defaultVerify;
219
+ exports.defaultVerifySignature = defaultVerifySignature;
213
220
  exports.defaultVersionJsonGenerator = defaultVersionJsonGenerator;
214
221
  exports.defaultZipFile = defaultZipFile;
215
222
  exports.disableHWAccForWin7 = disableHWAccForWin7;
package/dist/utils.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance } from './chunk-DFNDKSE6.js';
2
- export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerify, defaultZipFile, hashBuffer } from './chunk-JSYIRKTR.js';
2
+ export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultZipFile, hashBuffer } from './chunk-N77WQ5WB.js';
3
3
  export { defaultIsLowerVersion, defaultVersionJsonGenerator, isUpdateJSON, parseVersion } from './chunk-72ZAJ7AF.js';
4
+ export { isCI } from 'ci-info';
4
5
 
5
6
  // src/utils/updater.ts
6
7
  async function autoUpdate(updater) {
package/dist/vite.js CHANGED
@@ -280,7 +280,7 @@ async function buildEntry({
280
280
  `${isEntry ? bytecodeModuleLoaderCode : useStrict}${isEntry ? "" : "module.exports = "}require("./${fileName}c")`
281
281
  );
282
282
  bytecodeLog.info(
283
- `${filePath} => ${(buffer.byteLength / 1e3).toFixed(2)} kB`,
283
+ `${filePath} [${(buffer.byteLength / 1e3).toFixed(2)} kB]`,
284
284
  { timestamp: true }
285
285
  );
286
286
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.5",
4
+ "version": "2.0.0-beta.6",
5
5
  "description": "electron incremental update tools, powered by vite",
6
6
  "author": "subframe7536",
7
7
  "license": "MIT",
@@ -1,134 +0,0 @@
1
- import { EventEmitter } from 'node:events';
2
- import { a as UpdateJSON, U as UpdateInfo, D as DownloadingInfo, I as IProvider, c as URLHandler } from './types-C5P0h_bB.js';
3
-
4
- declare const ErrorInfo: {
5
- readonly download: "Download failed";
6
- readonly validate: "Validate failed";
7
- readonly param: "Missing params";
8
- readonly network: "Network error";
9
- };
10
- declare class UpdaterError extends Error {
11
- code: keyof typeof ErrorInfo;
12
- constructor(msg: keyof typeof ErrorInfo, info: string);
13
- }
14
- type CheckResult<T extends UpdateJSON> = {
15
- success: true;
16
- data: Omit<T, 'beta'>;
17
- } | {
18
- success: false;
19
- /**
20
- * minimal version that can update
21
- */
22
- data: string;
23
- } | {
24
- success: false;
25
- data: UpdaterError;
26
- };
27
- type DownloadResult = {
28
- success: true;
29
- } | {
30
- success: false;
31
- data: UpdaterError;
32
- };
33
- interface Logger {
34
- info: (msg: string) => void;
35
- debug: (msg: string) => void;
36
- warn: (msg: string) => void;
37
- error: (msg: string, e?: unknown) => void;
38
- }
39
- interface UpdaterOption {
40
- /**
41
- * public key of signature, which will be auto generated by plugin,
42
- * generate by `selfsigned` if not set
43
- */
44
- SIGNATURE_CERT?: string;
45
- /**
46
- * whether to receive beta update
47
- */
48
- receiveBeta?: boolean;
49
- logger?: Logger;
50
- }
51
-
52
- declare class Updater extends EventEmitter<{
53
- 'checking': any;
54
- 'update-available': [data: UpdateInfo];
55
- 'update-unavailable': [reason: string];
56
- 'error': [error: UpdaterError];
57
- 'download-progress': [info: DownloadingInfo];
58
- 'update-downloaded': any;
59
- }> {
60
- private CERT;
61
- private info?;
62
- private provider;
63
- /**
64
- * updater logger
65
- */
66
- logger?: Logger;
67
- /**
68
- * whether to receive beta update
69
- */
70
- receiveBeta?: boolean;
71
- /**
72
- * whether force update in DEV
73
- */
74
- forceUpdate?: boolean;
75
- /**
76
- * initialize incremental updater
77
- * @param provider update provider
78
- * @param option UpdaterOption
79
- */
80
- constructor(provider: IProvider, option?: UpdaterOption);
81
- /**
82
- * this function is used to parse download data.
83
- * - if format is `'json'`
84
- * - if data is `UpdateJSON`, return it
85
- * - if data is string or absent, download URL data and return it
86
- * - if format is `'buffer'`
87
- * - if data is `Buffer`, return it
88
- * - if data is string or absent, download URL data and return it
89
- * @param format 'json' or 'buffer'
90
- * @param data download URL or update json or buffer
91
- */
92
- private fetch;
93
- /**
94
- * handle error message and emit error event
95
- */
96
- private err;
97
- /**
98
- * check update info using default options
99
- */
100
- checkUpdate(): Promise<boolean>;
101
- /**
102
- * check update info using existing update json
103
- * @param data existing update json
104
- */
105
- checkUpdate(data: UpdateJSON): Promise<boolean>;
106
- /**
107
- * download update using default options
108
- */
109
- downloadUpdate(): Promise<boolean>;
110
- /**
111
- * download update using existing `asar.gz` buffer and signature
112
- * @param data existing `asar.gz` buffer
113
- * @param sig signature
114
- */
115
- downloadUpdate(data: Uint8Array | Buffer, sig: string): Promise<boolean>;
116
- /**
117
- * quit App and install
118
- */
119
- quitAndInstall(): void;
120
- /**
121
- * setup provider URL handler
122
- *
123
- * @example
124
- * updater.setURLHandler((url, isDownloadingAsar) => {
125
- * if (isDownloadingAsar) {
126
- * url.hostname = 'https://cdn.jsdelivr.net/gh'
127
- * return url
128
- * }
129
- * })
130
- */
131
- setURLHandler(handler: URLHandler): void;
132
- }
133
-
134
- export { type CheckResult as C, type DownloadResult as D, ErrorInfo as E, type Logger as L, Updater as U, type UpdaterOption as a, UpdaterError as b };
@@ -1,134 +0,0 @@
1
- import { EventEmitter } from 'node:events';
2
- import { a as UpdateJSON, U as UpdateInfo, D as DownloadingInfo, I as IProvider, c as URLHandler } from './types-C5P0h_bB.cjs';
3
-
4
- declare const ErrorInfo: {
5
- readonly download: "Download failed";
6
- readonly validate: "Validate failed";
7
- readonly param: "Missing params";
8
- readonly network: "Network error";
9
- };
10
- declare class UpdaterError extends Error {
11
- code: keyof typeof ErrorInfo;
12
- constructor(msg: keyof typeof ErrorInfo, info: string);
13
- }
14
- type CheckResult<T extends UpdateJSON> = {
15
- success: true;
16
- data: Omit<T, 'beta'>;
17
- } | {
18
- success: false;
19
- /**
20
- * minimal version that can update
21
- */
22
- data: string;
23
- } | {
24
- success: false;
25
- data: UpdaterError;
26
- };
27
- type DownloadResult = {
28
- success: true;
29
- } | {
30
- success: false;
31
- data: UpdaterError;
32
- };
33
- interface Logger {
34
- info: (msg: string) => void;
35
- debug: (msg: string) => void;
36
- warn: (msg: string) => void;
37
- error: (msg: string, e?: unknown) => void;
38
- }
39
- interface UpdaterOption {
40
- /**
41
- * public key of signature, which will be auto generated by plugin,
42
- * generate by `selfsigned` if not set
43
- */
44
- SIGNATURE_CERT?: string;
45
- /**
46
- * whether to receive beta update
47
- */
48
- receiveBeta?: boolean;
49
- logger?: Logger;
50
- }
51
-
52
- declare class Updater extends EventEmitter<{
53
- 'checking': any;
54
- 'update-available': [data: UpdateInfo];
55
- 'update-unavailable': [reason: string];
56
- 'error': [error: UpdaterError];
57
- 'download-progress': [info: DownloadingInfo];
58
- 'update-downloaded': any;
59
- }> {
60
- private CERT;
61
- private info?;
62
- private provider;
63
- /**
64
- * updater logger
65
- */
66
- logger?: Logger;
67
- /**
68
- * whether to receive beta update
69
- */
70
- receiveBeta?: boolean;
71
- /**
72
- * whether force update in DEV
73
- */
74
- forceUpdate?: boolean;
75
- /**
76
- * initialize incremental updater
77
- * @param provider update provider
78
- * @param option UpdaterOption
79
- */
80
- constructor(provider: IProvider, option?: UpdaterOption);
81
- /**
82
- * this function is used to parse download data.
83
- * - if format is `'json'`
84
- * - if data is `UpdateJSON`, return it
85
- * - if data is string or absent, download URL data and return it
86
- * - if format is `'buffer'`
87
- * - if data is `Buffer`, return it
88
- * - if data is string or absent, download URL data and return it
89
- * @param format 'json' or 'buffer'
90
- * @param data download URL or update json or buffer
91
- */
92
- private fetch;
93
- /**
94
- * handle error message and emit error event
95
- */
96
- private err;
97
- /**
98
- * check update info using default options
99
- */
100
- checkUpdate(): Promise<boolean>;
101
- /**
102
- * check update info using existing update json
103
- * @param data existing update json
104
- */
105
- checkUpdate(data: UpdateJSON): Promise<boolean>;
106
- /**
107
- * download update using default options
108
- */
109
- downloadUpdate(): Promise<boolean>;
110
- /**
111
- * download update using existing `asar.gz` buffer and signature
112
- * @param data existing `asar.gz` buffer
113
- * @param sig signature
114
- */
115
- downloadUpdate(data: Uint8Array | Buffer, sig: string): Promise<boolean>;
116
- /**
117
- * quit App and install
118
- */
119
- quitAndInstall(): void;
120
- /**
121
- * setup provider URL handler
122
- *
123
- * @example
124
- * updater.setURLHandler((url, isDownloadingAsar) => {
125
- * if (isDownloadingAsar) {
126
- * url.hostname = 'https://cdn.jsdelivr.net/gh'
127
- * return url
128
- * }
129
- * })
130
- */
131
- setURLHandler(handler: URLHandler): void;
132
- }
133
-
134
- export { type CheckResult as C, type DownloadResult as D, ErrorInfo as E, type Logger as L, Updater as U, type UpdaterOption as a, UpdaterError as b };
package/dist/index.d.cts DELETED
@@ -1,78 +0,0 @@
1
- import { U as Updater, a as UpdaterOption, L as Logger } from './core-DmU2Vk_S.cjs';
2
- export { C as CheckResult, D as DownloadResult, E as ErrorInfo, b as UpdaterError } from './core-DmU2Vk_S.cjs';
3
- import { I as IProvider } from './types-C5P0h_bB.cjs';
4
- import 'node:events';
5
- import '@subframe7536/type-utils';
6
-
7
- type Promisable<T> = T | Promise<T>;
8
- /**
9
- * hooks on rename temp asar path to `${app.name}.asar`
10
- * @param install `() => renameSync(tempAsarPath, appNameAsarPath)`
11
- * @param tempAsarPath temp(updated) asar path
12
- * @param appNameAsarPath `${app.name}.asar` path
13
- * @param logger logger
14
- * @default install(); logger.info(`update success!`)
15
- */
16
- type OnInstallFunction = (install: VoidFunction, tempAsarPath: string, appNameAsarPath: string, logger?: Logger) => Promisable<void>;
17
- interface AppOption {
18
- /**
19
- * update provider
20
- */
21
- provider: IProvider;
22
- /**
23
- * updater options
24
- */
25
- updater?: (() => Promisable<Updater>) | UpdaterOption;
26
- /**
27
- * hooks on rename temp asar path to `${app.name}.asar`
28
- */
29
- onInstall?: OnInstallFunction;
30
- /**
31
- * hooks before app start up
32
- * @param mainFilePath main file path of `${app.name}.asar`
33
- * @param logger logger
34
- */
35
- beforeStart?: (mainFilePath: string, logger?: Logger) => Promisable<void>;
36
- /**
37
- * hooks on app start up error
38
- * @param err installing or startup error
39
- * @param logger logger
40
- */
41
- onStartError?: (err: unknown, logger?: Logger) => void;
42
- }
43
- /**
44
- * utils for startuping with updater
45
- * @param fn startup function
46
- * @example
47
- * // in electron/main/index.ts
48
- * export default startupWithUpdater((updater) => {
49
- * updater.checkUpdate()
50
- * })
51
- */
52
- declare function startupWithUpdater(fn: (updater: Updater) => Promisable<void>): (updater: Updater) => Promisable<void>;
53
- /**
54
- * initialize app
55
- * @example
56
- * ```ts
57
- * import { getGithubReleaseCdnGroup, initApp, parseGithubCdnURL } from 'electron-incremental-update'
58
- * import { repository } from '../package.json'
59
- *
60
- * const { cdnPrefix: asarPrefix } = getGithubReleaseCdnGroup()[0]
61
- * const { cdnPrefix: jsonPrefix } = getGithubFileCdnGroup()[0]
62
- *
63
- * initApp({
64
- * // can be updater option or function that return updater
65
- * updater: {
66
- * SIGNATURE_CERT: 'custom certificate',
67
- * repository,
68
- * updateJsonURL: parseGithubCdnURL(repository, jsonPrefix, 'version.json'),
69
- * releaseAsarURL: parseGithubCdnURL(repository, asarPrefix, `download/latest/${app.name}.asar.gz`),
70
- * receiveBeta: true,
71
- * },
72
- * onStart: console.log
73
- * })
74
- * ```
75
- */
76
- declare function initApp(appOptions: AppOption): Promise<void>;
77
-
78
- export { type AppOption, Logger, Updater, UpdaterOption, initApp, startupWithUpdater };