electron-incremental-update 0.7.7 → 0.7.9

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.mjs CHANGED
@@ -2,12 +2,19 @@ import {
2
2
  verify
3
3
  } from "./chunk-Q2K52LOG.mjs";
4
4
  import {
5
- __require,
6
5
  getEntryVersion,
7
6
  getProductAsarPath,
7
+ getProductVersion,
8
+ parseVersion,
8
9
  unzipFile,
9
10
  waitAppReady
10
- } from "./chunk-67MCNA7W.mjs";
11
+ } from "./chunk-4TION32M.mjs";
12
+ import {
13
+ isUpdateJSON
14
+ } from "./chunk-2JVXVTC5.mjs";
15
+ import {
16
+ __require
17
+ } from "./chunk-ZFXKCRJC.mjs";
11
18
 
12
19
  // src/index.ts
13
20
  import { resolve } from "node:path";
@@ -15,22 +22,14 @@ import { existsSync as existsSync2, renameSync } from "node:fs";
15
22
  import { app } from "electron";
16
23
 
17
24
  // src/updater/index.ts
18
- import { EventEmitter } from "node:events";
19
- import { Buffer as Buffer2 } from "node:buffer";
20
25
  import { existsSync } from "node:fs";
26
+ import { Buffer as Buffer2 } from "node:buffer";
21
27
  import { rm, writeFile } from "node:fs/promises";
22
28
 
23
29
  // src/updater/defaultFunctions.ts
24
30
  import { Buffer } from "node:buffer";
25
31
  import { net } from "electron";
26
-
27
- // src/updater/types.ts
28
- function isUpdateJSON(json) {
29
- return "signature" in json && "version" in json && "size" in json;
30
- }
31
-
32
- // src/updater/defaultFunctions.ts
33
- async function downloadJSONDefault(url, updater, headers) {
32
+ var downloadJSONDefault = async (url, headers) => {
34
33
  await waitAppReady();
35
34
  return new Promise((resolve2, reject) => {
36
35
  const request = net.request({
@@ -62,10 +61,10 @@ async function downloadJSONDefault(url, updater, headers) {
62
61
  });
63
62
  request.end();
64
63
  });
65
- }
66
- async function downloadBufferDefault(url, updater, headers) {
64
+ };
65
+ var downloadBufferDefault = async (url, headers, total, onDownloading) => {
67
66
  await waitAppReady();
68
- let progress = 0;
67
+ let current = 0;
69
68
  return new Promise((resolve2, reject) => {
70
69
  const request = net.request({
71
70
  url,
@@ -78,8 +77,12 @@ async function downloadBufferDefault(url, updater, headers) {
78
77
  request.on("response", (res) => {
79
78
  let data = [];
80
79
  res.on("data", (chunk) => {
81
- progress += chunk.length;
82
- updater.emit("downloading", progress);
80
+ current += chunk.length;
81
+ onDownloading?.({
82
+ percent: `${+(current / total).toFixed(2) * 100}%`,
83
+ total,
84
+ current
85
+ });
83
86
  data.push(chunk);
84
87
  });
85
88
  res.on("end", () => {
@@ -90,168 +93,192 @@ async function downloadBufferDefault(url, updater, headers) {
90
93
  });
91
94
  request.end();
92
95
  });
93
- }
94
- var compareVersionDefault = (oldVersion, newVersion) => {
95
- if (!oldVersion || !newVersion || typeof oldVersion !== "string" || typeof newVersion !== "string") {
96
- throw new TypeError("invalid version");
97
- }
98
- const parseVersion = (version) => {
99
- const [versionNumber, stage] = version.split("-", 2);
100
- if (!versionNumber || !versionNumber.includes(".")) {
101
- throw new TypeError("invalid version");
102
- }
103
- const [major, minor, patch] = versionNumber.split(".").map(Number);
104
- if (isNaN(major) || isNaN(minor) || isNaN(patch)) {
105
- throw new TypeError("invalid version");
96
+ };
97
+ var compareVersionDefault = (version1, version2) => {
98
+ const oldV = parseVersion(version1);
99
+ const newV = parseVersion(version2);
100
+ function compareStrings(str1, str2) {
101
+ if (str1 === "") {
102
+ return str2 !== "";
103
+ } else if (str2 === "") {
104
+ return true;
106
105
  }
107
- return { major, minor, patch, stage };
108
- };
109
- const oldV = parseVersion(oldVersion);
110
- const newV = parseVersion(newVersion);
111
- if (oldV.major < newV.major || oldV.major === newV.major && oldV.minor < newV.minor || oldV.major === newV.major && oldV.minor === newV.minor && oldV.patch < newV.patch) {
112
- return true;
106
+ return str1 < str2;
113
107
  }
114
- if (oldV.stage < newV.stage || !newV.stage && oldV.stage) {
115
- return true;
108
+ for (let key of Object.keys(oldV)) {
109
+ if (key === "stage" && compareStrings(oldV[key], newV[key])) {
110
+ return true;
111
+ } else if (oldV[key] !== newV[key]) {
112
+ return oldV[key] < newV[key];
113
+ }
116
114
  }
117
115
  return false;
118
116
  };
119
117
 
120
118
  // src/updater/index.ts
121
- function createUpdater(updaterOptions) {
122
- const {
123
- SIGNATURE_CERT,
124
- repository,
125
- productName,
126
- releaseAsarURL: _release,
127
- updateJsonURL: _update,
128
- debug = false,
129
- downloadConfig: { extraHeader, userAgent } = {},
130
- overrideFunctions: {
131
- compareVersion,
132
- verifySignaure,
133
- downloadBuffer,
134
- downloadJSON
135
- } = {}
136
- } = updaterOptions;
137
- const updater = new EventEmitter();
138
- let signature;
139
- let version;
140
- const asarPath = getProductAsarPath(productName);
141
- const gzipPath = `${asarPath}.gz`;
142
- const tmpFilePath = `${asarPath}.tmp`;
143
- function log(msg) {
144
- debug && updater.emit("debug", msg);
119
+ var MinimumVersionError = class extends Error {
120
+ currentVersion;
121
+ minVersion;
122
+ constructor(version, minimumVersion) {
123
+ super(`current entry version is ${version}, less than the minimumVersion ${minimumVersion}`);
124
+ this.currentVersion = version;
125
+ this.minVersion = minimumVersion;
145
126
  }
146
- function needUpdate(version2) {
147
- const currentVersion = getEntryVersion();
148
- log(`check update: current version is ${currentVersion}, new version is ${version2}`);
149
- const _compare = compareVersion ?? compareVersionDefault;
150
- return _compare(currentVersion, version2);
127
+ };
128
+ var VerifyFailedError = class extends Error {
129
+ signature;
130
+ cert;
131
+ constructor(signature, cert) {
132
+ super("verify failed, invalid signature or certificate");
133
+ this.signature = signature;
134
+ this.cert = cert;
151
135
  }
152
- async function parseData(format, data, version2) {
153
- if (existsSync(tmpFilePath)) {
154
- log(`remove tmp file: ${tmpFilePath}`);
155
- await rm(tmpFilePath);
136
+ };
137
+ var IncrementalUpdater = class {
138
+ info;
139
+ option;
140
+ asarPath;
141
+ gzipPath;
142
+ tmpFilePath;
143
+ logger;
144
+ onDownloading;
145
+ get productName() {
146
+ return this.option.productName;
147
+ }
148
+ set productName(name) {
149
+ this.option.productName = name;
150
+ }
151
+ get receiveBeta() {
152
+ return !!this.option.receiveBeta;
153
+ }
154
+ set receiveBeta(receiveBeta) {
155
+ this.option.receiveBeta = receiveBeta;
156
+ }
157
+ constructor(option) {
158
+ this.option = option;
159
+ this.asarPath = getProductAsarPath(this.productName);
160
+ this.gzipPath = `${this.asarPath}.gz`;
161
+ this.tmpFilePath = `${this.asarPath}.tmp`;
162
+ }
163
+ async needUpdate(version, minVersion) {
164
+ const compare = this.option.overrideFunctions?.compareVersion ?? compareVersionDefault;
165
+ const productVersion = getProductVersion(this.option.productName);
166
+ const entryVersion = getEntryVersion();
167
+ if (await compare(entryVersion, minVersion)) {
168
+ throw new MinimumVersionError(entryVersion, minVersion);
156
169
  }
157
- if (existsSync(gzipPath)) {
158
- log(`remove .gz file: ${gzipPath}`);
159
- await rm(gzipPath);
170
+ this.logger?.info(`check update: current version is ${productVersion}, new version is ${version}`);
171
+ return await compare(productVersion, version);
172
+ }
173
+ async parseData(format, data) {
174
+ if (existsSync(this.tmpFilePath)) {
175
+ this.logger?.warn(`remove tmp file: ${this.tmpFilePath}`);
176
+ await rm(this.tmpFilePath);
177
+ }
178
+ if (existsSync(this.gzipPath)) {
179
+ this.logger?.warn(`remove .gz file: ${this.gzipPath}`);
180
+ await rm(this.gzipPath);
181
+ }
182
+ if (!["string", "object", "undefined"].includes(typeof data)) {
183
+ throw new TypeError(`invalid type at format '${format}': ${data}`);
184
+ }
185
+ if (typeof data === "object" && (format === "json" && isUpdateJSON(data) || format === "buffer" && Buffer2.isBuffer(data))) {
186
+ return data;
160
187
  }
161
188
  if (typeof data === "object") {
162
- if (format === "json" && isUpdateJSON(data) || format === "buffer" && Buffer2.isBuffer(data)) {
163
- return data;
164
- } else {
165
- throw new Error(`invalid type at format '${format}': ${data}`);
166
- }
167
- } else if (["string", "undefined"].includes(typeof data)) {
168
- const ua = userAgent || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36";
169
- const headers = {
170
- Accept: `application/${format === "json" ? "json" : "octet-stream"}`,
171
- UserAgent: ua,
172
- ...extraHeader
173
- };
174
- log(`download headers: ${JSON.stringify(headers, null, 2)}`);
175
- const info = format === "json" ? {
176
- name: "updateJsonURL",
177
- url: _update,
178
- repoFallback: `${repository.replace("github.com", "raw.githubusercontent.com")}/master/version.json`,
179
- fn: downloadJSON ?? downloadJSONDefault
180
- } : {
181
- name: "releaseAsarURL",
182
- url: _release,
183
- repoFallback: `${repository}/releases/download/v${version2}/${productName}-${version2}.asar.gz`,
184
- fn: downloadBuffer ?? downloadBufferDefault
185
- };
186
- data ??= info.url;
187
- if (!data) {
188
- log(`no ${info.name}, fallback to use repository`);
189
- if (!repository) {
190
- throw new Error(`${info.name} or repository are not set`);
191
- }
192
- if (format === "buffer" && !version2) {
193
- throw new Error("version are not set");
194
- }
195
- data = info.repoFallback;
189
+ throw new TypeError(`invalid type at format '${format}': ${data}`);
190
+ }
191
+ 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";
192
+ const headers = {
193
+ Accept: `application/${format === "json" ? "json" : "octet-stream"}`,
194
+ UserAgent: ua,
195
+ ...this.option.downloadConfig?.extraHeader
196
+ };
197
+ this.logger?.info(`download headers: ${JSON.stringify(headers, null, 2)}`);
198
+ const config = format === "json" ? {
199
+ name: "updateJsonURL",
200
+ url: this.option.updateJsonURL,
201
+ repoFallback: `${this.option.repository.replace("github.com", "raw.githubusercontent.com")}/master/version.json`,
202
+ fn: this.option.overrideFunctions?.downloadJSON ?? downloadJSONDefault
203
+ } : {
204
+ name: "releaseAsarURL",
205
+ url: this.option.releaseAsarURL,
206
+ repoFallback: `${this.option.repository}/releases/download/v${this.info?.version}/${this.productName}-${this.info?.version}.asar.gz`,
207
+ fn: this.option.overrideFunctions?.downloadBuffer ?? downloadBufferDefault
208
+ };
209
+ data ??= config.url;
210
+ if (!data) {
211
+ this.logger?.debug(`no ${config.name}, fallback to use repository`);
212
+ if (!this.option.repository) {
213
+ throw new Error(`${config.name} or repository are not set`);
196
214
  }
197
- log(`download ${format} from ${data}`);
198
- const ret = await info.fn(data, updater, headers);
199
- log(`download ${format} success${format === "buffer" ? `, file size: ${ret.length}` : ""}`);
200
- if (format === "buffer") {
201
- updater.emit("downloadBuffer", ret);
215
+ if (format === "buffer" && !this.info?.version) {
216
+ throw new Error("version are not set");
202
217
  }
203
- return ret;
204
- } else {
205
- throw new Error(`invalid type at format '${format}': ${data}`);
218
+ data = config.repoFallback;
206
219
  }
220
+ 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;
207
224
  }
208
- updater.productName = productName;
209
- updater.debugMode = debug;
210
- updater.checkUpdate = async (data) => {
225
+ async checkUpdate(data) {
211
226
  try {
212
- const { signature: _sig, size, version: _ver } = await parseData("json", data);
213
- log(`checked version: ${_ver}, size: ${size}, signature: ${_sig}`);
214
- if (!needUpdate(_ver)) {
215
- log(`update unavailable: ${_ver}`);
227
+ let { signature, size, version, minimumVersion, beta } = await this.parseData("json", data);
228
+ if (this.receiveBeta) {
229
+ version = beta.version;
230
+ signature = beta.signature;
231
+ minimumVersion = beta.minimumVersion;
232
+ size = beta.size;
233
+ }
234
+ this.logger?.info(`checked version: ${version}, size: ${size}, signature: ${signature}`);
235
+ if (!await this.needUpdate(version, minimumVersion)) {
236
+ this.logger?.info(`update unavailable: ${version} is the latest version`);
216
237
  return void 0;
217
238
  } else {
218
- log(`update available: ${_ver}`);
219
- signature = _sig;
220
- version = _ver;
221
- return { size, version: _ver };
239
+ this.logger?.info(`update available: ${version}`);
240
+ this.info = {
241
+ signature,
242
+ minimumVersion,
243
+ version,
244
+ size
245
+ };
246
+ return { size, version };
222
247
  }
223
248
  } catch (error) {
224
- log(error);
249
+ this.logger?.error("check update failed", error);
225
250
  return error;
226
251
  }
227
- };
228
- updater.download = async (data, sig) => {
252
+ }
253
+ async download(data, sig) {
229
254
  try {
230
- const _sig = sig ?? signature;
255
+ const _sig = sig ?? this.info?.signature;
231
256
  if (!_sig) {
232
257
  throw new Error("signature are not set, please checkUpdate first or set the second parameter");
233
258
  }
234
- const buffer = await parseData("buffer", data, version);
235
- log("verify start");
236
- const _verify = verifySignaure ?? verify;
237
- const _ver = _verify(buffer, _sig, SIGNATURE_CERT);
259
+ const buffer = await this.parseData("buffer", data);
260
+ this.logger?.info("verify start");
261
+ const _verify = this.option.overrideFunctions?.verifySignaure ?? verify;
262
+ const _ver = await _verify(buffer, _sig, this.option.SIGNATURE_CERT);
238
263
  if (!_ver) {
239
- throw new Error("verify failed, invalid signature");
264
+ throw new VerifyFailedError(_sig, this.option.SIGNATURE_CERT);
240
265
  }
241
- log("verify success");
242
- log(`write to ${gzipPath}`);
243
- await writeFile(gzipPath, buffer);
244
- log(`extract to ${tmpFilePath}`);
245
- await unzipFile(gzipPath, tmpFilePath);
246
- log(`download success, version: ${_ver}`);
247
- signature = "";
266
+ this.logger?.info("verify success");
267
+ this.logger?.info(`write to ${this.gzipPath}`);
268
+ await writeFile(this.gzipPath, buffer);
269
+ this.logger?.info(`extract to ${this.tmpFilePath}`);
270
+ await unzipFile(this.gzipPath, this.tmpFilePath);
271
+ this.logger?.info(`download success${typeof _ver === "string" ? `, version: ${_ver}` : ""}`);
272
+ this.info = void 0;
248
273
  return true;
249
274
  } catch (error) {
250
- log(error);
275
+ this.logger?.error("download asar failed", error);
251
276
  return error;
252
277
  }
253
- };
254
- return updater;
278
+ }
279
+ };
280
+ function createUpdater(option) {
281
+ return new IncrementalUpdater(option);
255
282
  }
256
283
 
257
284
  // src/index.ts
@@ -297,6 +324,9 @@ function initApp(appOptions) {
297
324
  };
298
325
  }
299
326
  export {
327
+ IncrementalUpdater,
328
+ MinimumVersionError,
329
+ VerifyFailedError,
300
330
  createUpdater,
301
331
  initApp
302
332
  };
@@ -0,0 +1,12 @@
1
+ type UpdateInfo = {
2
+ signature: string;
3
+ minimumVersion: string;
4
+ version: string;
5
+ size: number;
6
+ };
7
+ type UpdateJSON = UpdateInfo & {
8
+ beta: UpdateInfo;
9
+ };
10
+ declare function isUpdateJSON(json: any): json is UpdateJSON;
11
+
12
+ export { UpdateInfo, UpdateJSON, isUpdateJSON };
@@ -0,0 +1,12 @@
1
+ type UpdateInfo = {
2
+ signature: string;
3
+ minimumVersion: string;
4
+ version: string;
5
+ size: number;
6
+ };
7
+ type UpdateJSON = UpdateInfo & {
8
+ beta: UpdateInfo;
9
+ };
10
+ declare function isUpdateJSON(json: any): json is UpdateJSON;
11
+
12
+ export { UpdateInfo, UpdateJSON, isUpdateJSON };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/updateJson.ts
21
+ var updateJson_exports = {};
22
+ __export(updateJson_exports, {
23
+ isUpdateJSON: () => isUpdateJSON
24
+ });
25
+ module.exports = __toCommonJS(updateJson_exports);
26
+ function isUpdateJSON(json) {
27
+ const is = (j) => "signature" in j && "version" in j && "size" in j && "minimumVersion" in j;
28
+ return is(json) && "beta" in json && is(json.beta);
29
+ }
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ isUpdateJSON
33
+ });
@@ -0,0 +1,7 @@
1
+ import {
2
+ isUpdateJSON
3
+ } from "./chunk-2JVXVTC5.mjs";
4
+ import "./chunk-ZFXKCRJC.mjs";
5
+ export {
6
+ isUpdateJSON
7
+ };
package/dist/utils.d.mts CHANGED
@@ -9,20 +9,27 @@ declare function getProductAsarPath(name: string): string;
9
9
  declare function getEntryVersion(): string;
10
10
  /**
11
11
  * get the version of application (name.asar)
12
+ *
13
+ * if is dev, return {@link getEntryVersion}
12
14
  * @param name - The name of the application
13
15
  */
14
16
  declare function getProductVersion(name: string): string;
17
+ declare class NoSuchNativeModuleError extends Error {
18
+ moduleName: string;
19
+ constructor(moduleName: string);
20
+ }
15
21
  /**
16
22
  * require native package from app.asar
17
23
  * @param packageName native package name
24
+ * @throws error: {@link NoSuchNativeModuleError}
18
25
  */
19
26
  declare function requireNative<T = any>(packageName: string): T;
20
27
  /**
21
- * get github version.json CDN URL for accelerating the speed of downloading version info
28
+ * parse Github CDN URL for accelerating the speed of downloading
22
29
  */
23
30
  declare function parseGithubCdnURL(repository: string, cdnPrefix: string, relativeFilePath: string): string;
24
31
  /**
25
- * get group of github file CDN prefix for accelerating the speed of downloading release
32
+ * get group of Github file CDN prefix for accelerating the speed of downloading project files
26
33
  */
27
34
  declare function getGithubFileCdnGroup(): {
28
35
  cdnPrefix: string;
@@ -35,10 +42,24 @@ declare function getGithubReleaseCdnGroup(): {
35
42
  cdnPrefix: string;
36
43
  source: string;
37
44
  }[];
45
+ /**
46
+ * Restarts the Electron app.
47
+ */
38
48
  declare function restartApp(): void;
39
- declare function waitAppReady(duration?: number): Promise<unknown>;
40
- declare function unzipFile(gzipPath: string, targetFilePath: string): Promise<unknown>;
49
+ /**
50
+ * ensure app is ready.
51
+ */
52
+ declare function waitAppReady(duration?: number): Promise<void>;
53
+ declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
41
54
  declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
42
55
  declare function handleUnexpectedErrors(callback: (err: Error) => void): void;
56
+ interface Version {
57
+ major: number;
58
+ minor: number;
59
+ patch: number;
60
+ stage: string;
61
+ stageVersion: number;
62
+ }
63
+ declare function parseVersion(version: string): Version;
43
64
 
44
- export { getEntryVersion, getGithubFileCdnGroup, getGithubReleaseCdnGroup, getProductAsarPath, getProductVersion, handleUnexpectedErrors, parseGithubCdnURL, requireNative, restartApp, unzipFile, waitAppReady, zipFile };
65
+ export { NoSuchNativeModuleError, Version, getEntryVersion, getGithubFileCdnGroup, getGithubReleaseCdnGroup, getProductAsarPath, getProductVersion, handleUnexpectedErrors, parseGithubCdnURL, parseVersion, requireNative, restartApp, unzipFile, waitAppReady, zipFile };
package/dist/utils.d.ts CHANGED
@@ -9,20 +9,27 @@ declare function getProductAsarPath(name: string): string;
9
9
  declare function getEntryVersion(): string;
10
10
  /**
11
11
  * get the version of application (name.asar)
12
+ *
13
+ * if is dev, return {@link getEntryVersion}
12
14
  * @param name - The name of the application
13
15
  */
14
16
  declare function getProductVersion(name: string): string;
17
+ declare class NoSuchNativeModuleError extends Error {
18
+ moduleName: string;
19
+ constructor(moduleName: string);
20
+ }
15
21
  /**
16
22
  * require native package from app.asar
17
23
  * @param packageName native package name
24
+ * @throws error: {@link NoSuchNativeModuleError}
18
25
  */
19
26
  declare function requireNative<T = any>(packageName: string): T;
20
27
  /**
21
- * get github version.json CDN URL for accelerating the speed of downloading version info
28
+ * parse Github CDN URL for accelerating the speed of downloading
22
29
  */
23
30
  declare function parseGithubCdnURL(repository: string, cdnPrefix: string, relativeFilePath: string): string;
24
31
  /**
25
- * get group of github file CDN prefix for accelerating the speed of downloading release
32
+ * get group of Github file CDN prefix for accelerating the speed of downloading project files
26
33
  */
27
34
  declare function getGithubFileCdnGroup(): {
28
35
  cdnPrefix: string;
@@ -35,10 +42,24 @@ declare function getGithubReleaseCdnGroup(): {
35
42
  cdnPrefix: string;
36
43
  source: string;
37
44
  }[];
45
+ /**
46
+ * Restarts the Electron app.
47
+ */
38
48
  declare function restartApp(): void;
39
- declare function waitAppReady(duration?: number): Promise<unknown>;
40
- declare function unzipFile(gzipPath: string, targetFilePath: string): Promise<unknown>;
49
+ /**
50
+ * ensure app is ready.
51
+ */
52
+ declare function waitAppReady(duration?: number): Promise<void>;
53
+ declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
41
54
  declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
42
55
  declare function handleUnexpectedErrors(callback: (err: Error) => void): void;
56
+ interface Version {
57
+ major: number;
58
+ minor: number;
59
+ patch: number;
60
+ stage: string;
61
+ stageVersion: number;
62
+ }
63
+ declare function parseVersion(version: string): Version;
43
64
 
44
- export { getEntryVersion, getGithubFileCdnGroup, getGithubReleaseCdnGroup, getProductAsarPath, getProductVersion, handleUnexpectedErrors, parseGithubCdnURL, requireNative, restartApp, unzipFile, waitAppReady, zipFile };
65
+ export { NoSuchNativeModuleError, Version, getEntryVersion, getGithubFileCdnGroup, getGithubReleaseCdnGroup, getProductAsarPath, getProductVersion, handleUnexpectedErrors, parseGithubCdnURL, parseVersion, requireNative, restartApp, unzipFile, waitAppReady, zipFile };