electron-incremental-update 2.0.0-beta.2 → 2.0.0-beta.4
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/chunk-BVFQWBLK.js +76 -0
- package/dist/chunk-JSYIRKTR.js +53 -0
- package/dist/chunk-PNYRQYFC.js +77 -0
- package/dist/core-CW7TMqi7.d.cts +134 -0
- package/dist/core-D6QlpOgp.d.ts +134 -0
- package/dist/index.cjs +83 -152
- package/dist/index.d.cts +8 -133
- package/dist/index.d.ts +8 -133
- package/dist/index.js +60 -84
- package/dist/provider.cjs +85 -123
- package/dist/provider.d.cts +44 -17
- package/dist/provider.d.ts +44 -17
- package/dist/provider.js +50 -44
- package/dist/{types-CPq1MrYZ.d.ts → types-Bz1VD18z.d.cts} +39 -3
- package/dist/{types-COqp44eg.d.cts → types-Bz1VD18z.d.ts} +39 -3
- package/dist/utils.cjs +108 -174
- package/dist/utils.d.cts +10 -16
- package/dist/utils.d.ts +10 -16
- package/dist/utils.js +12 -62
- package/dist/vite.d.ts +397 -0
- package/dist/vite.js +138 -155
- package/dist/zip-WRrEMkgp.d.cts +10 -0
- package/dist/zip-WRrEMkgp.d.ts +10 -0
- package/package.json +7 -7
- package/dist/chunk-BG22XZAB.js +0 -257
- package/dist/decrypt-D9WdXYjH.d.cts +0 -4
- package/dist/decrypt-D9WdXYjH.d.ts +0 -4
- package/dist/version-CffZWDhZ.d.cts +0 -32
- package/dist/version-CffZWDhZ.d.ts +0 -32
|
@@ -1,7 +1,38 @@
|
|
|
1
1
|
import { Promisable } from '@subframe7536/type-utils';
|
|
2
|
-
import { U as UpdateJSON, a as UpdateInfo } from './version-CffZWDhZ.cjs';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* handle all unhandled error
|
|
5
|
+
* @param callback callback function
|
|
6
|
+
*/
|
|
7
|
+
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
8
|
+
interface Version {
|
|
9
|
+
major: number;
|
|
10
|
+
minor: number;
|
|
11
|
+
patch: number;
|
|
12
|
+
stage: string;
|
|
13
|
+
stageVersion: number;
|
|
14
|
+
}
|
|
15
|
+
declare function parseVersion(version: string): Version;
|
|
16
|
+
declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* update info json
|
|
19
|
+
*/
|
|
20
|
+
type UpdateInfo = {
|
|
21
|
+
signature: string;
|
|
22
|
+
minimumVersion: string;
|
|
23
|
+
version: string;
|
|
24
|
+
size: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* {@link UpdateInfo} with beta
|
|
28
|
+
*/
|
|
29
|
+
type UpdateJSON = UpdateInfo & {
|
|
30
|
+
beta: UpdateInfo;
|
|
31
|
+
};
|
|
32
|
+
declare function isUpdateJSON(json: any): json is UpdateJSON;
|
|
33
|
+
declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, buffer: Buffer, signature: string, version: string, minimumVersion: string): UpdateJSON;
|
|
34
|
+
|
|
35
|
+
type URLHandler = (url: URL, isDownloadAsar: boolean) => Promisable<URL | string | undefined | null>;
|
|
5
36
|
type OnDownloading = (progress: DownloadingInfo) => void;
|
|
6
37
|
interface DownloadingInfo {
|
|
7
38
|
/**
|
|
@@ -56,6 +87,11 @@ interface IProvider {
|
|
|
56
87
|
* @returns if version1 < version2
|
|
57
88
|
*/
|
|
58
89
|
isLowerVersion: (oldVer: string, newVer: string) => boolean;
|
|
90
|
+
/**
|
|
91
|
+
* unzip file buffer
|
|
92
|
+
* @param buffer source buffer
|
|
93
|
+
*/
|
|
94
|
+
unzipFile: (buffer: Buffer) => Promise<Buffer>;
|
|
59
95
|
/**
|
|
60
96
|
* verify asar signature
|
|
61
97
|
* @param buffer file buffer
|
|
@@ -66,4 +102,4 @@ interface IProvider {
|
|
|
66
102
|
verifySignaure: (buffer: Buffer, signature: string, cert: string) => Promisable<string | undefined>;
|
|
67
103
|
}
|
|
68
104
|
|
|
69
|
-
export type
|
|
105
|
+
export { type DownloadingInfo as D, type IProvider as I, type OnDownloading as O, type UpdateInfo as U, type Version as V, type UpdateJSON as a, defaultVersionJsonGenerator as b, type URLHandler as c, defaultIsLowerVersion as d, handleUnexpectedErrors as h, isUpdateJSON as i, parseVersion as p };
|
package/dist/utils.cjs
CHANGED
|
@@ -1,95 +1,51 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
encrypt: () => encrypt,
|
|
26
|
-
getAppVersion: () => getAppVersion,
|
|
27
|
-
getEntryVersion: () => getEntryVersion,
|
|
28
|
-
getPathFromAppNameAsar: () => getPathFromAppNameAsar,
|
|
29
|
-
getPathFromEntryAsar: () => getPathFromEntryAsar,
|
|
30
|
-
getPathFromPreload: () => getPathFromPreload,
|
|
31
|
-
getPathFromPublic: () => getPathFromPublic,
|
|
32
|
-
handleUnexpectedErrors: () => handleUnexpectedErrors,
|
|
33
|
-
hashString: () => hashString,
|
|
34
|
-
isDev: () => isDev,
|
|
35
|
-
isLinux: () => isLinux,
|
|
36
|
-
isLowerVersionDefault: () => isLowerVersionDefault,
|
|
37
|
-
isMac: () => isMac,
|
|
38
|
-
isUpdateJSON: () => isUpdateJSON,
|
|
39
|
-
isWin: () => isWin,
|
|
40
|
-
loadPage: () => loadPage,
|
|
41
|
-
parseVersion: () => parseVersion,
|
|
42
|
-
requireNative: () => requireNative,
|
|
43
|
-
restartApp: () => restartApp,
|
|
44
|
-
setAppUserModelId: () => setAppUserModelId,
|
|
45
|
-
setPortableAppDataPath: () => setPortableAppDataPath,
|
|
46
|
-
signature: () => signature,
|
|
47
|
-
singleInstance: () => singleInstance,
|
|
48
|
-
unzipFile: () => unzipFile,
|
|
49
|
-
verifySignatureDefault: () => verifySignatureDefault,
|
|
50
|
-
waitAppReady: () => waitAppReady,
|
|
51
|
-
zipFile: () => zipFile
|
|
52
|
-
});
|
|
53
|
-
module.exports = __toCommonJS(utils_exports);
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
var electron = require('electron');
|
|
6
|
+
var zlib = require('zlib');
|
|
7
|
+
var crypto = require('crypto');
|
|
54
8
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
9
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
10
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
+
}) : x)(function(x) {
|
|
12
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
+
});
|
|
59
15
|
var isDev = __EIU_IS_DEV__;
|
|
60
16
|
var isWin = process.platform === "win32";
|
|
61
17
|
var isMac = process.platform === "darwin";
|
|
62
18
|
var isLinux = process.platform === "linux";
|
|
63
|
-
function getPathFromAppNameAsar(...path) {
|
|
64
|
-
return isDev ? "DEV.asar" :
|
|
19
|
+
function getPathFromAppNameAsar(...path$1) {
|
|
20
|
+
return isDev ? "DEV.asar" : path.join(path.dirname(electron.app.getAppPath()), `${electron.app.name}.asar`, ...path$1);
|
|
65
21
|
}
|
|
66
22
|
function getAppVersion() {
|
|
67
|
-
return isDev ? getEntryVersion() :
|
|
23
|
+
return isDev ? getEntryVersion() : fs.readFileSync(getPathFromAppNameAsar("version"), "utf-8");
|
|
68
24
|
}
|
|
69
25
|
function getEntryVersion() {
|
|
70
|
-
return
|
|
26
|
+
return electron.app.getVersion();
|
|
71
27
|
}
|
|
72
28
|
function requireNative(moduleName) {
|
|
73
|
-
return
|
|
29
|
+
return __require(path.join(electron.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, moduleName));
|
|
74
30
|
}
|
|
75
31
|
function restartApp() {
|
|
76
|
-
|
|
77
|
-
|
|
32
|
+
electron.app.relaunch();
|
|
33
|
+
electron.app.quit();
|
|
78
34
|
}
|
|
79
35
|
function setAppUserModelId(id) {
|
|
80
36
|
if (isWin) {
|
|
81
|
-
|
|
37
|
+
electron.app.setAppUserModelId(id ?? `org.${electron.app.name}`);
|
|
82
38
|
}
|
|
83
39
|
}
|
|
84
40
|
function disableHWAccForWin7() {
|
|
85
|
-
if (
|
|
86
|
-
|
|
41
|
+
if (__require("os").release().startsWith("6.1")) {
|
|
42
|
+
electron.app.disableHardwareAcceleration();
|
|
87
43
|
}
|
|
88
44
|
}
|
|
89
45
|
function singleInstance(window) {
|
|
90
|
-
const result =
|
|
46
|
+
const result = electron.app.requestSingleInstanceLock();
|
|
91
47
|
if (result) {
|
|
92
|
-
|
|
48
|
+
electron.app.on("second-instance", () => {
|
|
93
49
|
if (window) {
|
|
94
50
|
window.show();
|
|
95
51
|
if (window.isMinimized()) {
|
|
@@ -99,27 +55,16 @@ function singleInstance(window) {
|
|
|
99
55
|
}
|
|
100
56
|
});
|
|
101
57
|
} else {
|
|
102
|
-
|
|
58
|
+
electron.app.quit();
|
|
103
59
|
}
|
|
104
60
|
return result;
|
|
105
61
|
}
|
|
106
62
|
function setPortableAppDataPath(dirName = "data") {
|
|
107
|
-
const portablePath =
|
|
108
|
-
if (!
|
|
109
|
-
|
|
63
|
+
const portablePath = path.join(path.dirname(electron.app.getPath("exe")), dirName);
|
|
64
|
+
if (!fs.existsSync(portablePath)) {
|
|
65
|
+
fs.mkdirSync(portablePath);
|
|
110
66
|
}
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
function waitAppReady(timeout = 1e3) {
|
|
114
|
-
return import_electron.app.isReady() ? Promise.resolve() : new Promise((resolve, reject) => {
|
|
115
|
-
const _ = setTimeout(() => {
|
|
116
|
-
reject(new Error("app is not ready"));
|
|
117
|
-
}, timeout);
|
|
118
|
-
import_electron.app.whenReady().then(() => {
|
|
119
|
-
clearTimeout(_);
|
|
120
|
-
resolve();
|
|
121
|
-
});
|
|
122
|
-
});
|
|
67
|
+
electron.app.setPath("appData", portablePath);
|
|
123
68
|
}
|
|
124
69
|
function loadPage(win, htmlFilePath = "index.html") {
|
|
125
70
|
if (isDev) {
|
|
@@ -129,50 +74,33 @@ function loadPage(win, htmlFilePath = "index.html") {
|
|
|
129
74
|
}
|
|
130
75
|
}
|
|
131
76
|
function getPathFromPreload(...paths) {
|
|
132
|
-
return isDev ?
|
|
77
|
+
return isDev ? path.join(electron.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "preload", ...paths) : getPathFromAppNameAsar("preload", ...paths);
|
|
133
78
|
}
|
|
134
79
|
function getPathFromPublic(...paths) {
|
|
135
|
-
return isDev ?
|
|
80
|
+
return isDev ? path.join(electron.app.getAppPath(), "public", ...paths) : getPathFromAppNameAsar("renderer", ...paths);
|
|
136
81
|
}
|
|
137
82
|
function getPathFromEntryAsar(...paths) {
|
|
138
|
-
return
|
|
83
|
+
return path.join(electron.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, ...paths);
|
|
139
84
|
}
|
|
140
|
-
|
|
141
|
-
// src/utils/zip.ts
|
|
142
|
-
var import_node_fs2 = require("fs");
|
|
143
|
-
var import_node_zlib = require("zlib");
|
|
144
|
-
async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
|
|
145
|
-
if (!(0, import_node_fs2.existsSync)(filePath)) {
|
|
146
|
-
throw new Error(`path to be zipped not exist: ${filePath}`);
|
|
147
|
-
}
|
|
148
|
-
const buffer = (0, import_node_fs2.readFileSync)(filePath);
|
|
85
|
+
async function defaultZipFile(buffer) {
|
|
149
86
|
return new Promise((resolve, reject) => {
|
|
150
|
-
|
|
87
|
+
zlib.brotliCompress(buffer, (err, buffer2) => {
|
|
151
88
|
if (err) {
|
|
152
89
|
reject(err);
|
|
90
|
+
} else {
|
|
91
|
+
resolve(buffer2);
|
|
153
92
|
}
|
|
154
|
-
(0, import_node_fs2.writeFileSync)(targetFilePath, buffer2);
|
|
155
|
-
resolve();
|
|
156
93
|
});
|
|
157
94
|
});
|
|
158
95
|
}
|
|
159
|
-
|
|
160
|
-
// src/utils/unzip.ts
|
|
161
|
-
var import_node_fs3 = require("fs");
|
|
162
|
-
var import_node_zlib2 = require("zlib");
|
|
163
|
-
async function unzipFile(gzipPath, targetFilePath = gzipPath.slice(0, -3)) {
|
|
164
|
-
if (!(0, import_node_fs3.existsSync)(gzipPath)) {
|
|
165
|
-
throw new Error(`path to zipped file not exist: ${gzipPath}`);
|
|
166
|
-
}
|
|
167
|
-
const compressedBuffer = (0, import_node_fs3.readFileSync)(gzipPath);
|
|
96
|
+
async function defaultUnzipFile(buffer) {
|
|
168
97
|
return new Promise((resolve, reject) => {
|
|
169
|
-
|
|
170
|
-
(0, import_node_fs3.rmSync)(gzipPath);
|
|
98
|
+
zlib.brotliDecompress(buffer, (err, buffer2) => {
|
|
171
99
|
if (err) {
|
|
172
100
|
reject(err);
|
|
101
|
+
} else {
|
|
102
|
+
resolve(buffer2);
|
|
173
103
|
}
|
|
174
|
-
(0, import_node_fs3.writeFileSync)(targetFilePath, buffer);
|
|
175
|
-
resolve();
|
|
176
104
|
});
|
|
177
105
|
});
|
|
178
106
|
}
|
|
@@ -205,7 +133,7 @@ function parseVersion(version) {
|
|
|
205
133
|
}
|
|
206
134
|
return ret;
|
|
207
135
|
}
|
|
208
|
-
function
|
|
136
|
+
function defaultIsLowerVersion(oldVer, newVer) {
|
|
209
137
|
const oldV = parseVersion(oldVer);
|
|
210
138
|
const newV = parseVersion(newVer);
|
|
211
139
|
function compareStrings(str1, str2) {
|
|
@@ -229,75 +157,81 @@ function isUpdateJSON(json) {
|
|
|
229
157
|
const is = (j) => !!(j && j.minimumVersion && j.signature && j.size && j.version);
|
|
230
158
|
return is(json) && is(json?.beta);
|
|
231
159
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
160
|
+
function defaultVersionJsonGenerator(existingJson, buffer, signature, version, minimumVersion) {
|
|
161
|
+
existingJson.beta = {
|
|
162
|
+
version,
|
|
163
|
+
minimumVersion,
|
|
164
|
+
signature,
|
|
165
|
+
size: buffer.length
|
|
166
|
+
};
|
|
167
|
+
if (!parseVersion(version).stage) {
|
|
168
|
+
existingJson.version = version;
|
|
169
|
+
existingJson.minimumVersion = minimumVersion;
|
|
170
|
+
existingJson.signature = signature;
|
|
171
|
+
existingJson.size = buffer.length;
|
|
172
|
+
}
|
|
173
|
+
return existingJson;
|
|
174
|
+
}
|
|
175
|
+
function hashBuffer(data, length) {
|
|
176
|
+
const hash = crypto.createHash("SHA256").update(data).digest("binary");
|
|
240
177
|
return Buffer.from(hash).subarray(0, length);
|
|
241
178
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
return
|
|
179
|
+
function aesEncrypt(plainText, key, iv) {
|
|
180
|
+
const cipher = crypto.createCipheriv("aes-256-cbc", key, iv);
|
|
181
|
+
return cipher.update(plainText, "utf8", "base64url") + cipher.final("base64url");
|
|
182
|
+
}
|
|
183
|
+
function defaultSignature(buffer, privateKey, cert, version) {
|
|
184
|
+
const sig = crypto.createSign("RSA-SHA256").update(buffer).sign(crypto.createPrivateKey(privateKey), "base64");
|
|
185
|
+
return aesEncrypt(`${sig}%${version}`, hashBuffer(cert, 32), hashBuffer(buffer, 16));
|
|
249
186
|
}
|
|
250
|
-
function
|
|
187
|
+
function aesDecrypt(encryptedText, key, iv) {
|
|
188
|
+
const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
|
|
189
|
+
return decipher.update(encryptedText, "base64url", "utf8") + decipher.final("utf8");
|
|
190
|
+
}
|
|
191
|
+
function defaultVerify(buffer, signature, cert) {
|
|
251
192
|
try {
|
|
252
|
-
const [sig, version] =
|
|
253
|
-
const result =
|
|
193
|
+
const [sig, version] = aesDecrypt(signature, hashBuffer(cert, 32), hashBuffer(buffer, 16)).split("%");
|
|
194
|
+
const result = crypto.createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
|
|
254
195
|
return result ? version : void 0;
|
|
255
196
|
} catch {
|
|
256
197
|
return void 0;
|
|
257
198
|
}
|
|
258
199
|
}
|
|
259
200
|
|
|
260
|
-
// src/utils/
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
encrypted += cipher.final("base64url");
|
|
266
|
-
return encrypted;
|
|
267
|
-
}
|
|
268
|
-
function signature(buffer, privateKey, cert, version) {
|
|
269
|
-
const sig = (0, import_node_crypto3.createSign)("RSA-SHA256").update(buffer).sign((0, import_node_crypto3.createPrivateKey)(privateKey), "base64");
|
|
270
|
-
return encrypt(`${sig}%${version}`, hashString(cert, 32), hashString(buffer, 16));
|
|
201
|
+
// src/utils/updater.ts
|
|
202
|
+
async function autoUpdate(updater) {
|
|
203
|
+
if (await updater.checkUpdate() && await updater.downloadUpdate()) {
|
|
204
|
+
updater.quitAndInstall();
|
|
205
|
+
}
|
|
271
206
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
});
|
|
207
|
+
|
|
208
|
+
exports.aesDecrypt = aesDecrypt;
|
|
209
|
+
exports.aesEncrypt = aesEncrypt;
|
|
210
|
+
exports.autoUpdate = autoUpdate;
|
|
211
|
+
exports.defaultIsLowerVersion = defaultIsLowerVersion;
|
|
212
|
+
exports.defaultSignature = defaultSignature;
|
|
213
|
+
exports.defaultUnzipFile = defaultUnzipFile;
|
|
214
|
+
exports.defaultVerify = defaultVerify;
|
|
215
|
+
exports.defaultVersionJsonGenerator = defaultVersionJsonGenerator;
|
|
216
|
+
exports.defaultZipFile = defaultZipFile;
|
|
217
|
+
exports.disableHWAccForWin7 = disableHWAccForWin7;
|
|
218
|
+
exports.getAppVersion = getAppVersion;
|
|
219
|
+
exports.getEntryVersion = getEntryVersion;
|
|
220
|
+
exports.getPathFromAppNameAsar = getPathFromAppNameAsar;
|
|
221
|
+
exports.getPathFromEntryAsar = getPathFromEntryAsar;
|
|
222
|
+
exports.getPathFromPreload = getPathFromPreload;
|
|
223
|
+
exports.getPathFromPublic = getPathFromPublic;
|
|
224
|
+
exports.handleUnexpectedErrors = handleUnexpectedErrors;
|
|
225
|
+
exports.hashBuffer = hashBuffer;
|
|
226
|
+
exports.isDev = isDev;
|
|
227
|
+
exports.isLinux = isLinux;
|
|
228
|
+
exports.isMac = isMac;
|
|
229
|
+
exports.isUpdateJSON = isUpdateJSON;
|
|
230
|
+
exports.isWin = isWin;
|
|
231
|
+
exports.loadPage = loadPage;
|
|
232
|
+
exports.parseVersion = parseVersion;
|
|
233
|
+
exports.requireNative = requireNative;
|
|
234
|
+
exports.restartApp = restartApp;
|
|
235
|
+
exports.setAppUserModelId = setAppUserModelId;
|
|
236
|
+
exports.setPortableAppDataPath = setPortableAppDataPath;
|
|
237
|
+
exports.singleInstance = singleInstance;
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { BrowserWindow } from 'electron';
|
|
2
|
-
export {
|
|
3
|
-
export { d as
|
|
2
|
+
export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerify, d as defaultZipFile, h as hashBuffer } from './zip-WRrEMkgp.cjs';
|
|
3
|
+
export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, h as handleUnexpectedErrors, i as isUpdateJSON, p as parseVersion } from './types-Bz1VD18z.cjs';
|
|
4
|
+
import { U as Updater } from './core-CW7TMqi7.cjs';
|
|
5
|
+
import '@subframe7536/type-utils';
|
|
6
|
+
import 'node:events';
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* compile time dev check
|
|
@@ -54,11 +57,6 @@ declare function singleInstance(window?: BrowserWindow): boolean;
|
|
|
54
57
|
* @param dirName dir name, default to `data`
|
|
55
58
|
*/
|
|
56
59
|
declare function setPortableAppDataPath(dirName?: string): void;
|
|
57
|
-
/**
|
|
58
|
-
* ensure app is ready.
|
|
59
|
-
* @param timeout wait timeout, @default 1000
|
|
60
|
-
*/
|
|
61
|
-
declare function waitAppReady(timeout?: number): Promise<void>;
|
|
62
60
|
/**
|
|
63
61
|
* load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
|
|
64
62
|
* @param win window
|
|
@@ -69,13 +67,9 @@ declare function getPathFromPreload(...paths: string[]): string;
|
|
|
69
67
|
declare function getPathFromPublic(...paths: string[]): string;
|
|
70
68
|
declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
declare function encrypt(plainText: string, key: Buffer, iv: Buffer): string;
|
|
77
|
-
declare function signature(buffer: Buffer, privateKey: string, cert: string, version: string): string;
|
|
78
|
-
|
|
79
|
-
declare function hashString(data: string | Buffer, length: number): Buffer;
|
|
70
|
+
/**
|
|
71
|
+
* auto check update, download and install
|
|
72
|
+
*/
|
|
73
|
+
declare function autoUpdate(updater: Updater): Promise<void>;
|
|
80
74
|
|
|
81
|
-
export {
|
|
75
|
+
export { autoUpdate, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { BrowserWindow } from 'electron';
|
|
2
|
-
export {
|
|
3
|
-
export { d as
|
|
2
|
+
export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerify, d as defaultZipFile, h as hashBuffer } from './zip-WRrEMkgp.js';
|
|
3
|
+
export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, h as handleUnexpectedErrors, i as isUpdateJSON, p as parseVersion } from './types-Bz1VD18z.js';
|
|
4
|
+
import { U as Updater } from './core-D6QlpOgp.js';
|
|
5
|
+
import '@subframe7536/type-utils';
|
|
6
|
+
import 'node:events';
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* compile time dev check
|
|
@@ -54,11 +57,6 @@ declare function singleInstance(window?: BrowserWindow): boolean;
|
|
|
54
57
|
* @param dirName dir name, default to `data`
|
|
55
58
|
*/
|
|
56
59
|
declare function setPortableAppDataPath(dirName?: string): void;
|
|
57
|
-
/**
|
|
58
|
-
* ensure app is ready.
|
|
59
|
-
* @param timeout wait timeout, @default 1000
|
|
60
|
-
*/
|
|
61
|
-
declare function waitAppReady(timeout?: number): Promise<void>;
|
|
62
60
|
/**
|
|
63
61
|
* load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
|
|
64
62
|
* @param win window
|
|
@@ -69,13 +67,9 @@ declare function getPathFromPreload(...paths: string[]): string;
|
|
|
69
67
|
declare function getPathFromPublic(...paths: string[]): string;
|
|
70
68
|
declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
declare function encrypt(plainText: string, key: Buffer, iv: Buffer): string;
|
|
77
|
-
declare function signature(buffer: Buffer, privateKey: string, cert: string, version: string): string;
|
|
78
|
-
|
|
79
|
-
declare function hashString(data: string | Buffer, length: number): Buffer;
|
|
70
|
+
/**
|
|
71
|
+
* auto check update, download and install
|
|
72
|
+
*/
|
|
73
|
+
declare function autoUpdate(updater: Updater): Promise<void>;
|
|
80
74
|
|
|
81
|
-
export {
|
|
75
|
+
export { autoUpdate, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
|
package/dist/utils.js
CHANGED
|
@@ -1,62 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
isDev,
|
|
14
|
-
isLinux,
|
|
15
|
-
isLowerVersionDefault,
|
|
16
|
-
isMac,
|
|
17
|
-
isUpdateJSON,
|
|
18
|
-
isWin,
|
|
19
|
-
loadPage,
|
|
20
|
-
parseVersion,
|
|
21
|
-
requireNative,
|
|
22
|
-
restartApp,
|
|
23
|
-
setAppUserModelId,
|
|
24
|
-
setPortableAppDataPath,
|
|
25
|
-
signature,
|
|
26
|
-
singleInstance,
|
|
27
|
-
unzipFile,
|
|
28
|
-
verifySignatureDefault,
|
|
29
|
-
waitAppReady,
|
|
30
|
-
zipFile
|
|
31
|
-
} from "./chunk-BG22XZAB.js";
|
|
32
|
-
export {
|
|
33
|
-
decrypt,
|
|
34
|
-
disableHWAccForWin7,
|
|
35
|
-
encrypt,
|
|
36
|
-
getAppVersion,
|
|
37
|
-
getEntryVersion,
|
|
38
|
-
getPathFromAppNameAsar,
|
|
39
|
-
getPathFromEntryAsar,
|
|
40
|
-
getPathFromPreload,
|
|
41
|
-
getPathFromPublic,
|
|
42
|
-
handleUnexpectedErrors,
|
|
43
|
-
hashString,
|
|
44
|
-
isDev,
|
|
45
|
-
isLinux,
|
|
46
|
-
isLowerVersionDefault,
|
|
47
|
-
isMac,
|
|
48
|
-
isUpdateJSON,
|
|
49
|
-
isWin,
|
|
50
|
-
loadPage,
|
|
51
|
-
parseVersion,
|
|
52
|
-
requireNative,
|
|
53
|
-
restartApp,
|
|
54
|
-
setAppUserModelId,
|
|
55
|
-
setPortableAppDataPath,
|
|
56
|
-
signature,
|
|
57
|
-
singleInstance,
|
|
58
|
-
unzipFile,
|
|
59
|
-
verifySignatureDefault,
|
|
60
|
-
waitAppReady,
|
|
61
|
-
zipFile
|
|
62
|
-
};
|
|
1
|
+
export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance } from './chunk-PNYRQYFC.js';
|
|
2
|
+
export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerify, defaultZipFile, hashBuffer } from './chunk-JSYIRKTR.js';
|
|
3
|
+
export { defaultIsLowerVersion, defaultVersionJsonGenerator, handleUnexpectedErrors, isUpdateJSON, parseVersion } from './chunk-BVFQWBLK.js';
|
|
4
|
+
|
|
5
|
+
// src/utils/updater.ts
|
|
6
|
+
async function autoUpdate(updater) {
|
|
7
|
+
if (await updater.checkUpdate() && await updater.downloadUpdate()) {
|
|
8
|
+
updater.quitAndInstall();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { autoUpdate };
|