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/README.md +9 -10
- package/dist/chunk-2JVXVTC5.mjs +9 -0
- package/dist/{chunk-67MCNA7W.mjs → chunk-4TION32M.mjs} +44 -12
- package/dist/chunk-ZFXKCRJC.mjs +11 -0
- package/dist/index.d.mts +127 -84
- package/dist/index.d.ts +127 -84
- package/dist/index.js +226 -167
- package/dist/index.mjs +176 -146
- package/dist/updateJson.d.mts +12 -0
- package/dist/updateJson.d.ts +12 -0
- package/dist/updateJson.js +33 -0
- package/dist/updateJson.mjs +7 -0
- package/dist/utils.d.mts +26 -5
- package/dist/utils.d.ts +26 -5
- package/dist/utils.js +42 -3
- package/dist/utils.mjs +6 -1
- package/dist/vite.d.mts +32 -15
- package/dist/vite.d.ts +32 -15
- package/dist/vite.js +90 -20
- package/dist/vite.mjs +60 -15
- package/package.json +2 -2
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-
|
|
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
|
|
64
|
+
};
|
|
65
|
+
var downloadBufferDefault = async (url, headers, total, onDownloading) => {
|
|
67
66
|
await waitAppReady();
|
|
68
|
-
let
|
|
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
|
-
|
|
82
|
-
|
|
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 = (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (
|
|
101
|
-
|
|
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
|
|
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
|
-
|
|
115
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
|
|
198
|
-
|
|
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
|
-
|
|
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
|
-
|
|
209
|
-
updater.debugMode = debug;
|
|
210
|
-
updater.checkUpdate = async (data) => {
|
|
225
|
+
async checkUpdate(data) {
|
|
211
226
|
try {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
-
|
|
249
|
+
this.logger?.error("check update failed", error);
|
|
225
250
|
return error;
|
|
226
251
|
}
|
|
227
|
-
}
|
|
228
|
-
|
|
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
|
|
235
|
-
|
|
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
|
|
264
|
+
throw new VerifyFailedError(_sig, this.option.SIGNATURE_CERT);
|
|
240
265
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
await writeFile(gzipPath, buffer);
|
|
244
|
-
|
|
245
|
-
await unzipFile(gzipPath, tmpFilePath);
|
|
246
|
-
|
|
247
|
-
|
|
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
|
-
|
|
275
|
+
this.logger?.error("download asar failed", error);
|
|
251
276
|
return error;
|
|
252
277
|
}
|
|
253
|
-
}
|
|
254
|
-
|
|
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
|
+
});
|
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
|
-
*
|
|
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
|
|
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
|
-
|
|
40
|
-
|
|
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
|
-
*
|
|
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
|
|
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
|
-
|
|
40
|
-
|
|
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 };
|