electron-incremental-update 2.0.0-beta.1 → 2.0.0-beta.10
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 +3 -3
- package/dist/chunk-4MH6ZXCY.js +81 -0
- package/dist/chunk-72ZAJ7AF.js +70 -0
- package/dist/chunk-KZSYEXLO.js +55 -0
- package/dist/index.cjs +161 -221
- package/dist/index.d.cts +71 -107
- package/dist/index.d.ts +71 -107
- package/dist/index.js +135 -156
- package/dist/provider.cjs +132 -127
- package/dist/provider.d.cts +92 -20
- package/dist/provider.d.ts +92 -20
- package/dist/provider.js +92 -51
- package/dist/types-Bnc4jz6R.d.ts +78 -0
- package/dist/types-DEYw5VrL.d.cts +78 -0
- package/dist/utils.cjs +133 -190
- package/dist/utils.d.cts +35 -30
- package/dist/utils.d.ts +35 -30
- package/dist/utils.js +3 -62
- package/dist/version-C4tF_trh.d.cts +62 -0
- package/dist/version-C4tF_trh.d.ts +62 -0
- package/dist/vite.d.ts +370 -0
- package/dist/vite.js +304 -265
- package/dist/zip-rm9ED9nU.d.cts +33 -0
- package/dist/zip-rm9ED9nU.d.ts +33 -0
- package/package.json +20 -14
- package/dist/chunk-RSLOPAIZ.js +0 -247
- package/dist/decrypt-BNBcodiO.d.cts +0 -4
- package/dist/decrypt-BNBcodiO.d.ts +0 -4
- package/dist/types-DxPmQmaq.d.cts +0 -61
- package/dist/types-seJf3Wbc.d.ts +0 -61
- package/dist/version-CffZWDhZ.d.cts +0 -32
- package/dist/version-CffZWDhZ.d.ts +0 -32
package/dist/utils.cjs
CHANGED
|
@@ -1,177 +1,122 @@
|
|
|
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
|
-
|
|
26
|
-
|
|
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');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
54
10
|
|
|
55
|
-
|
|
56
|
-
var
|
|
57
|
-
var
|
|
58
|
-
var
|
|
11
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
12
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
13
|
+
var zlib__default = /*#__PURE__*/_interopDefault(zlib);
|
|
14
|
+
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
15
|
+
|
|
16
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
17
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
18
|
+
}) : x)(function(x) {
|
|
19
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
20
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
21
|
+
});
|
|
59
22
|
var isDev = __EIU_IS_DEV__;
|
|
60
23
|
var isWin = process.platform === "win32";
|
|
61
24
|
var isMac = process.platform === "darwin";
|
|
62
25
|
var isLinux = process.platform === "linux";
|
|
63
|
-
function getPathFromAppNameAsar(...
|
|
64
|
-
return isDev ? "DEV.asar" :
|
|
26
|
+
function getPathFromAppNameAsar(...paths) {
|
|
27
|
+
return isDev ? "DEV.asar" : path__default.default.join(path__default.default.dirname(electron.app.getAppPath()), `${electron.app.name}.asar`, ...paths);
|
|
65
28
|
}
|
|
66
29
|
function getAppVersion() {
|
|
67
|
-
return isDev ? getEntryVersion() :
|
|
30
|
+
return isDev ? getEntryVersion() : fs__default.default.readFileSync(getPathFromAppNameAsar("version"), "utf-8");
|
|
68
31
|
}
|
|
69
32
|
function getEntryVersion() {
|
|
70
|
-
return
|
|
33
|
+
return electron.app.getVersion();
|
|
71
34
|
}
|
|
72
35
|
function requireNative(moduleName) {
|
|
73
|
-
return
|
|
36
|
+
return __require(path__default.default.join(electron.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, moduleName));
|
|
74
37
|
}
|
|
75
38
|
function restartApp() {
|
|
76
|
-
|
|
77
|
-
|
|
39
|
+
electron.app.relaunch();
|
|
40
|
+
electron.app.quit();
|
|
78
41
|
}
|
|
79
42
|
function setAppUserModelId(id) {
|
|
80
|
-
|
|
43
|
+
if (isWin) {
|
|
44
|
+
electron.app.setAppUserModelId(id ?? `org.${electron.app.name}`);
|
|
45
|
+
}
|
|
81
46
|
}
|
|
82
47
|
function disableHWAccForWin7() {
|
|
83
|
-
if (
|
|
84
|
-
|
|
48
|
+
if (__require("os").release().startsWith("6.1")) {
|
|
49
|
+
electron.app.disableHardwareAcceleration();
|
|
85
50
|
}
|
|
86
51
|
}
|
|
87
52
|
function singleInstance(window) {
|
|
88
|
-
const result =
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
window
|
|
92
|
-
|
|
93
|
-
window.
|
|
53
|
+
const result = electron.app.requestSingleInstanceLock();
|
|
54
|
+
if (result) {
|
|
55
|
+
electron.app.on("second-instance", () => {
|
|
56
|
+
if (window) {
|
|
57
|
+
window.show();
|
|
58
|
+
if (window.isMinimized()) {
|
|
59
|
+
window.restore();
|
|
60
|
+
}
|
|
61
|
+
window.focus();
|
|
94
62
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
63
|
+
});
|
|
64
|
+
} else {
|
|
65
|
+
electron.app.quit();
|
|
66
|
+
}
|
|
98
67
|
return result;
|
|
99
68
|
}
|
|
100
69
|
function setPortableAppDataPath(dirName = "data") {
|
|
101
|
-
const portablePath =
|
|
102
|
-
if (!
|
|
103
|
-
|
|
70
|
+
const portablePath = path__default.default.join(path__default.default.dirname(electron.app.getPath("exe")), dirName);
|
|
71
|
+
if (!fs__default.default.existsSync(portablePath)) {
|
|
72
|
+
fs__default.default.mkdirSync(portablePath);
|
|
104
73
|
}
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
function waitAppReady(timeout = 1e3) {
|
|
108
|
-
return import_electron.app.isReady() ? Promise.resolve() : new Promise((resolve, reject) => {
|
|
109
|
-
const _ = setTimeout(() => {
|
|
110
|
-
reject(new Error("app is not ready"));
|
|
111
|
-
}, timeout);
|
|
112
|
-
import_electron.app.whenReady().then(() => {
|
|
113
|
-
clearTimeout(_);
|
|
114
|
-
resolve();
|
|
115
|
-
});
|
|
116
|
-
});
|
|
74
|
+
electron.app.setPath("appData", portablePath);
|
|
117
75
|
}
|
|
118
76
|
function loadPage(win, htmlFilePath = "index.html") {
|
|
119
|
-
|
|
77
|
+
if (isDev) {
|
|
78
|
+
win.loadURL(process.env.VITE_DEV_SERVER_URL + htmlFilePath);
|
|
79
|
+
} else {
|
|
80
|
+
win.loadFile(getPathFromAppNameAsar("renderer", htmlFilePath));
|
|
81
|
+
}
|
|
120
82
|
}
|
|
121
83
|
function getPathFromPreload(...paths) {
|
|
122
|
-
return isDev ?
|
|
84
|
+
return isDev ? path__default.default.join(electron.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "preload", ...paths) : getPathFromAppNameAsar("preload", ...paths);
|
|
123
85
|
}
|
|
124
86
|
function getPathFromPublic(...paths) {
|
|
125
|
-
return isDev ?
|
|
87
|
+
return isDev ? path__default.default.join(electron.app.getAppPath(), "public", ...paths) : getPathFromAppNameAsar("renderer", ...paths);
|
|
126
88
|
}
|
|
127
89
|
function getPathFromEntryAsar(...paths) {
|
|
128
|
-
return
|
|
90
|
+
return path__default.default.join(electron.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, ...paths);
|
|
129
91
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
async function
|
|
135
|
-
if (!(0, import_node_fs2.existsSync)(filePath)) {
|
|
136
|
-
throw new Error(`path to be zipped not exist: ${filePath}`);
|
|
137
|
-
}
|
|
138
|
-
const buffer = (0, import_node_fs2.readFileSync)(filePath);
|
|
92
|
+
function handleUnexpectedErrors(callback) {
|
|
93
|
+
process.on("uncaughtException", callback);
|
|
94
|
+
process.on("unhandledRejection", callback);
|
|
95
|
+
}
|
|
96
|
+
async function defaultZipFile(buffer) {
|
|
139
97
|
return new Promise((resolve, reject) => {
|
|
140
|
-
|
|
98
|
+
zlib__default.default.brotliCompress(buffer, (err, buffer2) => {
|
|
141
99
|
if (err) {
|
|
142
100
|
reject(err);
|
|
101
|
+
} else {
|
|
102
|
+
resolve(buffer2);
|
|
143
103
|
}
|
|
144
|
-
(0, import_node_fs2.writeFileSync)(targetFilePath, buffer2);
|
|
145
|
-
resolve(null);
|
|
146
104
|
});
|
|
147
105
|
});
|
|
148
106
|
}
|
|
149
|
-
|
|
150
|
-
// src/utils/unzip.ts
|
|
151
|
-
var import_node_fs3 = require("fs");
|
|
152
|
-
var import_node_zlib2 = require("zlib");
|
|
153
|
-
async function unzipFile(gzipPath, targetFilePath = gzipPath.slice(0, -3)) {
|
|
154
|
-
if (!(0, import_node_fs3.existsSync)(gzipPath)) {
|
|
155
|
-
throw new Error(`path to zipped file not exist: ${gzipPath}`);
|
|
156
|
-
}
|
|
157
|
-
const compressedBuffer = (0, import_node_fs3.readFileSync)(gzipPath);
|
|
107
|
+
async function defaultUnzipFile(buffer) {
|
|
158
108
|
return new Promise((resolve, reject) => {
|
|
159
|
-
|
|
160
|
-
(0, import_node_fs3.rmSync)(gzipPath);
|
|
109
|
+
zlib__default.default.brotliDecompress(buffer, (err, buffer2) => {
|
|
161
110
|
if (err) {
|
|
162
111
|
reject(err);
|
|
112
|
+
} else {
|
|
113
|
+
resolve(buffer2);
|
|
163
114
|
}
|
|
164
|
-
(0, import_node_fs3.writeFileSync)(targetFilePath, buffer);
|
|
165
|
-
resolve(null);
|
|
166
115
|
});
|
|
167
116
|
});
|
|
168
117
|
}
|
|
169
118
|
|
|
170
119
|
// src/utils/version.ts
|
|
171
|
-
function handleUnexpectedErrors(callback) {
|
|
172
|
-
process.on("uncaughtException", callback);
|
|
173
|
-
process.on("unhandledRejection", callback);
|
|
174
|
-
}
|
|
175
120
|
function parseVersion(version) {
|
|
176
121
|
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?/i.exec(version);
|
|
177
122
|
if (!match) {
|
|
@@ -195,7 +140,7 @@ function parseVersion(version) {
|
|
|
195
140
|
}
|
|
196
141
|
return ret;
|
|
197
142
|
}
|
|
198
|
-
function
|
|
143
|
+
function defaultIsLowerVersion(oldVer, newVer) {
|
|
199
144
|
const oldV = parseVersion(oldVer);
|
|
200
145
|
const newV = parseVersion(newVer);
|
|
201
146
|
function compareStrings(str1, str2) {
|
|
@@ -216,78 +161,76 @@ function isLowerVersionDefault(oldVer, newVer) {
|
|
|
216
161
|
return false;
|
|
217
162
|
}
|
|
218
163
|
function isUpdateJSON(json) {
|
|
219
|
-
const is = (j) => !!(j && j.minimumVersion && j.signature && j.
|
|
164
|
+
const is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
220
165
|
return is(json) && is(json?.beta);
|
|
221
166
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
167
|
+
function defaultVersionJsonGenerator(existingJson, signature, version, minimumVersion) {
|
|
168
|
+
existingJson.beta = {
|
|
169
|
+
version,
|
|
170
|
+
minimumVersion,
|
|
171
|
+
signature
|
|
172
|
+
};
|
|
173
|
+
if (!parseVersion(version).stage) {
|
|
174
|
+
existingJson.version = version;
|
|
175
|
+
existingJson.minimumVersion = minimumVersion;
|
|
176
|
+
existingJson.signature = signature;
|
|
177
|
+
}
|
|
178
|
+
return existingJson;
|
|
179
|
+
}
|
|
180
|
+
function hashBuffer(data, length) {
|
|
181
|
+
const hash = crypto__default.default.createHash("SHA256").update(data).digest("binary");
|
|
230
182
|
return Buffer.from(hash).subarray(0, length);
|
|
231
183
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
return
|
|
184
|
+
function aesEncrypt(plainText, key, iv) {
|
|
185
|
+
const cipher = crypto__default.default.createCipheriv("aes-256-cbc", key, iv);
|
|
186
|
+
return cipher.update(plainText, "utf8", "base64url") + cipher.final("base64url");
|
|
187
|
+
}
|
|
188
|
+
function defaultSignature(buffer, privateKey, cert, version) {
|
|
189
|
+
const sig = crypto__default.default.createSign("RSA-SHA256").update(buffer).sign(crypto__default.default.createPrivateKey(privateKey), "base64");
|
|
190
|
+
return aesEncrypt(`${sig}%${version}`, hashBuffer(cert, 32), hashBuffer(buffer, 16));
|
|
191
|
+
}
|
|
192
|
+
function aesDecrypt(encryptedText, key, iv) {
|
|
193
|
+
const decipher = crypto__default.default.createDecipheriv("aes-256-cbc", key, iv);
|
|
194
|
+
return decipher.update(encryptedText, "base64url", "utf8") + decipher.final("utf8");
|
|
239
195
|
}
|
|
240
|
-
function
|
|
196
|
+
function defaultVerifySignature(buffer, version, signature, cert) {
|
|
241
197
|
try {
|
|
242
|
-
const [sig,
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
return
|
|
198
|
+
const [sig, ver] = aesDecrypt(signature, hashBuffer(cert, 32), hashBuffer(buffer, 16)).split("%");
|
|
199
|
+
if (ver !== version) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
return crypto__default.default.createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
|
|
203
|
+
} catch {
|
|
204
|
+
return false;
|
|
247
205
|
}
|
|
248
206
|
}
|
|
249
207
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
isUpdateJSON,
|
|
280
|
-
isWin,
|
|
281
|
-
loadPage,
|
|
282
|
-
parseVersion,
|
|
283
|
-
requireNative,
|
|
284
|
-
restartApp,
|
|
285
|
-
setAppUserModelId,
|
|
286
|
-
setPortableAppDataPath,
|
|
287
|
-
signature,
|
|
288
|
-
singleInstance,
|
|
289
|
-
unzipFile,
|
|
290
|
-
verifySignatureDefault,
|
|
291
|
-
waitAppReady,
|
|
292
|
-
zipFile
|
|
293
|
-
});
|
|
208
|
+
exports.aesDecrypt = aesDecrypt;
|
|
209
|
+
exports.aesEncrypt = aesEncrypt;
|
|
210
|
+
exports.defaultIsLowerVersion = defaultIsLowerVersion;
|
|
211
|
+
exports.defaultSignature = defaultSignature;
|
|
212
|
+
exports.defaultUnzipFile = defaultUnzipFile;
|
|
213
|
+
exports.defaultVerifySignature = defaultVerifySignature;
|
|
214
|
+
exports.defaultVersionJsonGenerator = defaultVersionJsonGenerator;
|
|
215
|
+
exports.defaultZipFile = defaultZipFile;
|
|
216
|
+
exports.disableHWAccForWin7 = disableHWAccForWin7;
|
|
217
|
+
exports.getAppVersion = getAppVersion;
|
|
218
|
+
exports.getEntryVersion = getEntryVersion;
|
|
219
|
+
exports.getPathFromAppNameAsar = getPathFromAppNameAsar;
|
|
220
|
+
exports.getPathFromEntryAsar = getPathFromEntryAsar;
|
|
221
|
+
exports.getPathFromPreload = getPathFromPreload;
|
|
222
|
+
exports.getPathFromPublic = getPathFromPublic;
|
|
223
|
+
exports.handleUnexpectedErrors = handleUnexpectedErrors;
|
|
224
|
+
exports.hashBuffer = hashBuffer;
|
|
225
|
+
exports.isDev = isDev;
|
|
226
|
+
exports.isLinux = isLinux;
|
|
227
|
+
exports.isMac = isMac;
|
|
228
|
+
exports.isUpdateJSON = isUpdateJSON;
|
|
229
|
+
exports.isWin = isWin;
|
|
230
|
+
exports.loadPage = loadPage;
|
|
231
|
+
exports.parseVersion = parseVersion;
|
|
232
|
+
exports.requireNative = requireNative;
|
|
233
|
+
exports.restartApp = restartApp;
|
|
234
|
+
exports.setAppUserModelId = setAppUserModelId;
|
|
235
|
+
exports.setPortableAppDataPath = setPortableAppDataPath;
|
|
236
|
+
exports.singleInstance = singleInstance;
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
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 defaultVerifySignature, d as defaultZipFile, h as hashBuffer } from './zip-rm9ED9nU.cjs';
|
|
3
|
+
export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, i as isUpdateJSON, p as parseVersion } from './version-C4tF_trh.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Compile time dev check
|
|
7
7
|
*/
|
|
8
8
|
declare const isDev: boolean;
|
|
9
9
|
declare const isWin: boolean;
|
|
10
10
|
declare const isMac: boolean;
|
|
11
11
|
declare const isLinux: boolean;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Get the absolute path of `${electron.app.name}.asar` (not `app.asar`)
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* If is in dev, **always** return `'DEV.asar'`
|
|
16
16
|
*/
|
|
17
|
-
declare function getPathFromAppNameAsar(...
|
|
17
|
+
declare function getPathFromAppNameAsar(...paths: string[]): string;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Get app version, if is in dev, return `getEntryVersion()`
|
|
20
20
|
*/
|
|
21
21
|
declare function getAppVersion(): string;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Get entry version
|
|
24
24
|
*/
|
|
25
25
|
declare function getEntryVersion(): string;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Use `require` to load native module from entry asar
|
|
28
28
|
* @param moduleName file name in entry
|
|
29
|
+
* @example
|
|
30
|
+
* requireNative<typeof import('../native/db')>('db')
|
|
29
31
|
*/
|
|
30
32
|
declare function requireNative<T = any>(moduleName: string): T;
|
|
31
33
|
/**
|
|
@@ -33,49 +35,52 @@ declare function requireNative<T = any>(moduleName: string): T;
|
|
|
33
35
|
*/
|
|
34
36
|
declare function restartApp(): void;
|
|
35
37
|
/**
|
|
36
|
-
*
|
|
38
|
+
* Fix app use model id, only for Windows
|
|
37
39
|
* @param id app id, default is `org.${electron.app.name}`
|
|
38
40
|
*/
|
|
39
41
|
declare function setAppUserModelId(id?: string): void;
|
|
40
42
|
/**
|
|
41
|
-
*
|
|
43
|
+
* Disable hardware acceleration for Windows 7
|
|
42
44
|
*/
|
|
43
45
|
declare function disableHWAccForWin7(): void;
|
|
44
46
|
/**
|
|
45
|
-
*
|
|
47
|
+
* Keep single electron instance and auto restore window on `second-instance` event
|
|
46
48
|
* @param window brwoser window to show
|
|
47
49
|
* @returns `false` if the app is running
|
|
48
50
|
*/
|
|
49
51
|
declare function singleInstance(window?: BrowserWindow): boolean;
|
|
50
52
|
/**
|
|
51
|
-
*
|
|
53
|
+
* Set `AppData` dir to the dir of .exe file
|
|
52
54
|
*
|
|
53
|
-
*
|
|
55
|
+
* Useful for portable Windows app
|
|
54
56
|
* @param dirName dir name, default to `data`
|
|
55
57
|
*/
|
|
56
58
|
declare function setPortableAppDataPath(dirName?: string): void;
|
|
57
59
|
/**
|
|
58
|
-
*
|
|
59
|
-
* @param timeout wait timeout, @default 1000
|
|
60
|
-
*/
|
|
61
|
-
declare function waitAppReady(timeout?: number): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
|
|
60
|
+
* Load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
|
|
64
61
|
* @param win window
|
|
65
62
|
* @param htmlFilePath html file path, default is `index.html`
|
|
66
63
|
*/
|
|
67
64
|
declare function loadPage(win: BrowserWindow, htmlFilePath?: string): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get joined path from preload dir
|
|
67
|
+
* @param paths rest paths
|
|
68
|
+
*/
|
|
68
69
|
declare function getPathFromPreload(...paths: string[]): string;
|
|
70
|
+
/**
|
|
71
|
+
* Get joined path from publich dir
|
|
72
|
+
* @param paths rest paths
|
|
73
|
+
*/
|
|
69
74
|
declare function getPathFromPublic(...paths: string[]): string;
|
|
75
|
+
/**
|
|
76
|
+
* Get joined path from entry asar
|
|
77
|
+
* @param paths rest paths
|
|
78
|
+
*/
|
|
70
79
|
declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
80
|
+
/**
|
|
81
|
+
* Handle all unhandled error
|
|
82
|
+
* @param callback callback function
|
|
83
|
+
*/
|
|
84
|
+
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
71
85
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
|
|
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;
|
|
80
|
-
|
|
81
|
-
export { disableHWAccForWin7, encrypt, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, hashString, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, signature, singleInstance, unzipFile, waitAppReady, zipFile };
|
|
86
|
+
export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
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 defaultVerifySignature, d as defaultZipFile, h as hashBuffer } from './zip-rm9ED9nU.js';
|
|
3
|
+
export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, i as isUpdateJSON, p as parseVersion } from './version-C4tF_trh.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Compile time dev check
|
|
7
7
|
*/
|
|
8
8
|
declare const isDev: boolean;
|
|
9
9
|
declare const isWin: boolean;
|
|
10
10
|
declare const isMac: boolean;
|
|
11
11
|
declare const isLinux: boolean;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Get the absolute path of `${electron.app.name}.asar` (not `app.asar`)
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* If is in dev, **always** return `'DEV.asar'`
|
|
16
16
|
*/
|
|
17
|
-
declare function getPathFromAppNameAsar(...
|
|
17
|
+
declare function getPathFromAppNameAsar(...paths: string[]): string;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Get app version, if is in dev, return `getEntryVersion()`
|
|
20
20
|
*/
|
|
21
21
|
declare function getAppVersion(): string;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Get entry version
|
|
24
24
|
*/
|
|
25
25
|
declare function getEntryVersion(): string;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Use `require` to load native module from entry asar
|
|
28
28
|
* @param moduleName file name in entry
|
|
29
|
+
* @example
|
|
30
|
+
* requireNative<typeof import('../native/db')>('db')
|
|
29
31
|
*/
|
|
30
32
|
declare function requireNative<T = any>(moduleName: string): T;
|
|
31
33
|
/**
|
|
@@ -33,49 +35,52 @@ declare function requireNative<T = any>(moduleName: string): T;
|
|
|
33
35
|
*/
|
|
34
36
|
declare function restartApp(): void;
|
|
35
37
|
/**
|
|
36
|
-
*
|
|
38
|
+
* Fix app use model id, only for Windows
|
|
37
39
|
* @param id app id, default is `org.${electron.app.name}`
|
|
38
40
|
*/
|
|
39
41
|
declare function setAppUserModelId(id?: string): void;
|
|
40
42
|
/**
|
|
41
|
-
*
|
|
43
|
+
* Disable hardware acceleration for Windows 7
|
|
42
44
|
*/
|
|
43
45
|
declare function disableHWAccForWin7(): void;
|
|
44
46
|
/**
|
|
45
|
-
*
|
|
47
|
+
* Keep single electron instance and auto restore window on `second-instance` event
|
|
46
48
|
* @param window brwoser window to show
|
|
47
49
|
* @returns `false` if the app is running
|
|
48
50
|
*/
|
|
49
51
|
declare function singleInstance(window?: BrowserWindow): boolean;
|
|
50
52
|
/**
|
|
51
|
-
*
|
|
53
|
+
* Set `AppData` dir to the dir of .exe file
|
|
52
54
|
*
|
|
53
|
-
*
|
|
55
|
+
* Useful for portable Windows app
|
|
54
56
|
* @param dirName dir name, default to `data`
|
|
55
57
|
*/
|
|
56
58
|
declare function setPortableAppDataPath(dirName?: string): void;
|
|
57
59
|
/**
|
|
58
|
-
*
|
|
59
|
-
* @param timeout wait timeout, @default 1000
|
|
60
|
-
*/
|
|
61
|
-
declare function waitAppReady(timeout?: number): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
|
|
60
|
+
* Load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
|
|
64
61
|
* @param win window
|
|
65
62
|
* @param htmlFilePath html file path, default is `index.html`
|
|
66
63
|
*/
|
|
67
64
|
declare function loadPage(win: BrowserWindow, htmlFilePath?: string): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get joined path from preload dir
|
|
67
|
+
* @param paths rest paths
|
|
68
|
+
*/
|
|
68
69
|
declare function getPathFromPreload(...paths: string[]): string;
|
|
70
|
+
/**
|
|
71
|
+
* Get joined path from publich dir
|
|
72
|
+
* @param paths rest paths
|
|
73
|
+
*/
|
|
69
74
|
declare function getPathFromPublic(...paths: string[]): string;
|
|
75
|
+
/**
|
|
76
|
+
* Get joined path from entry asar
|
|
77
|
+
* @param paths rest paths
|
|
78
|
+
*/
|
|
70
79
|
declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
80
|
+
/**
|
|
81
|
+
* Handle all unhandled error
|
|
82
|
+
* @param callback callback function
|
|
83
|
+
*/
|
|
84
|
+
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
71
85
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
|
|
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;
|
|
80
|
-
|
|
81
|
-
export { disableHWAccForWin7, encrypt, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, hashString, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, signature, singleInstance, unzipFile, waitAppReady, zipFile };
|
|
86
|
+
export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
|