electron-incremental-update 2.0.0-beta.1 → 2.0.0-beta.11
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-IABBXJFB.js +87 -0
- package/dist/chunk-KZSYEXLO.js +55 -0
- package/dist/chunk-RCRKUKFX.js +70 -0
- package/dist/index.cjs +193 -233
- package/dist/index.d.cts +89 -117
- package/dist/index.d.ts +89 -117
- package/dist/index.js +166 -169
- package/dist/provider.cjs +165 -146
- package/dist/provider.d.cts +94 -22
- package/dist/provider.d.ts +94 -22
- package/dist/provider.js +125 -71
- package/dist/types-C8JhnJjU.d.ts +80 -0
- package/dist/types-CGSkHX4Y.d.cts +80 -0
- package/dist/utils.cjs +142 -191
- package/dist/utils.d.cts +42 -30
- package/dist/utils.d.ts +42 -30
- package/dist/utils.js +3 -62
- package/dist/version-BYVQ367i.d.cts +62 -0
- package/dist/version-BYVQ367i.d.ts +62 -0
- package/dist/vite.d.ts +372 -0
- package/dist/vite.js +326 -274
- package/dist/zip-rm9ED9nU.d.cts +33 -0
- package/dist/zip-rm9ED9nU.d.ts +33 -0
- package/package.json +21 -15
- 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,129 @@
|
|
|
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 electron__default = /*#__PURE__*/_interopDefault(electron);
|
|
14
|
+
var zlib__default = /*#__PURE__*/_interopDefault(zlib);
|
|
15
|
+
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
16
|
+
|
|
17
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
18
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
19
|
+
}) : x)(function(x) {
|
|
20
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
21
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
22
|
+
});
|
|
59
23
|
var isDev = __EIU_IS_DEV__;
|
|
60
24
|
var isWin = process.platform === "win32";
|
|
61
25
|
var isMac = process.platform === "darwin";
|
|
62
26
|
var isLinux = process.platform === "linux";
|
|
63
|
-
function getPathFromAppNameAsar(...
|
|
64
|
-
return isDev ? "DEV.asar" :
|
|
27
|
+
function getPathFromAppNameAsar(...paths) {
|
|
28
|
+
return isDev ? "DEV.asar" : path__default.default.join(path__default.default.dirname(electron__default.default.app.getAppPath()), `${electron__default.default.app.name}.asar`, ...paths);
|
|
65
29
|
}
|
|
66
30
|
function getAppVersion() {
|
|
67
|
-
return isDev ? getEntryVersion() :
|
|
31
|
+
return isDev ? getEntryVersion() : fs__default.default.readFileSync(getPathFromAppNameAsar("version"), "utf-8");
|
|
68
32
|
}
|
|
69
33
|
function getEntryVersion() {
|
|
70
|
-
return
|
|
34
|
+
return electron__default.default.app.getVersion();
|
|
71
35
|
}
|
|
72
36
|
function requireNative(moduleName) {
|
|
73
|
-
|
|
37
|
+
if (__EIU_IS_ESM__) {
|
|
38
|
+
throw new Error(`Cannot require "${path__default.default.join(__EIU_ENTRY_DIST_PATH__, moduleName)}", \`requireNative\` only support CommonJS`);
|
|
39
|
+
}
|
|
40
|
+
return __require(path__default.default.join(electron__default.default.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, moduleName));
|
|
74
41
|
}
|
|
75
42
|
function restartApp() {
|
|
76
|
-
|
|
77
|
-
|
|
43
|
+
electron__default.default.app.relaunch();
|
|
44
|
+
electron__default.default.app.quit();
|
|
78
45
|
}
|
|
79
46
|
function setAppUserModelId(id) {
|
|
80
|
-
|
|
47
|
+
if (isWin) {
|
|
48
|
+
electron__default.default.app.setAppUserModelId(id ?? `org.${electron__default.default.app.name}`);
|
|
49
|
+
}
|
|
81
50
|
}
|
|
82
51
|
function disableHWAccForWin7() {
|
|
83
|
-
if (
|
|
84
|
-
|
|
52
|
+
if (!__EIU_IS_ESM__ && __require("os").release().startsWith("6.1")) {
|
|
53
|
+
electron__default.default.app.disableHardwareAcceleration();
|
|
85
54
|
}
|
|
86
55
|
}
|
|
87
56
|
function singleInstance(window) {
|
|
88
|
-
const result =
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
window
|
|
92
|
-
|
|
93
|
-
window.
|
|
57
|
+
const result = electron__default.default.app.requestSingleInstanceLock();
|
|
58
|
+
if (result) {
|
|
59
|
+
electron__default.default.app.on("second-instance", () => {
|
|
60
|
+
if (window) {
|
|
61
|
+
window.show();
|
|
62
|
+
if (window.isMinimized()) {
|
|
63
|
+
window.restore();
|
|
64
|
+
}
|
|
65
|
+
window.focus();
|
|
94
66
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
electron__default.default.app.quit();
|
|
70
|
+
}
|
|
98
71
|
return result;
|
|
99
72
|
}
|
|
100
73
|
function setPortableAppDataPath(dirName = "data") {
|
|
101
|
-
const portablePath =
|
|
102
|
-
if (!
|
|
103
|
-
|
|
74
|
+
const portablePath = path__default.default.join(path__default.default.dirname(electron__default.default.app.getPath("exe")), dirName);
|
|
75
|
+
if (!fs__default.default.existsSync(portablePath)) {
|
|
76
|
+
fs__default.default.mkdirSync(portablePath);
|
|
104
77
|
}
|
|
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
|
-
});
|
|
78
|
+
electron__default.default.app.setPath("appData", portablePath);
|
|
117
79
|
}
|
|
118
80
|
function loadPage(win, htmlFilePath = "index.html") {
|
|
119
|
-
|
|
81
|
+
if (isDev) {
|
|
82
|
+
win.loadURL(process.env.VITE_DEV_SERVER_URL + htmlFilePath);
|
|
83
|
+
} else {
|
|
84
|
+
win.loadFile(getPathFromAppNameAsar("renderer", htmlFilePath));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function getPathFromMain(...paths) {
|
|
88
|
+
return isDev ? path__default.default.join(electron__default.default.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "main", ...paths) : getPathFromAppNameAsar("main", ...paths);
|
|
120
89
|
}
|
|
121
90
|
function getPathFromPreload(...paths) {
|
|
122
|
-
return isDev ?
|
|
91
|
+
return isDev ? path__default.default.join(electron__default.default.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "preload", ...paths) : getPathFromAppNameAsar("preload", ...paths);
|
|
123
92
|
}
|
|
124
93
|
function getPathFromPublic(...paths) {
|
|
125
|
-
return isDev ?
|
|
94
|
+
return isDev ? path__default.default.join(electron__default.default.app.getAppPath(), "public", ...paths) : getPathFromAppNameAsar("renderer", ...paths);
|
|
126
95
|
}
|
|
127
96
|
function getPathFromEntryAsar(...paths) {
|
|
128
|
-
return
|
|
97
|
+
return path__default.default.join(electron__default.default.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, ...paths);
|
|
129
98
|
}
|
|
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);
|
|
99
|
+
function handleUnexpectedErrors(callback) {
|
|
100
|
+
process.on("uncaughtException", callback);
|
|
101
|
+
process.on("unhandledRejection", callback);
|
|
102
|
+
}
|
|
103
|
+
async function defaultZipFile(buffer) {
|
|
139
104
|
return new Promise((resolve, reject) => {
|
|
140
|
-
|
|
105
|
+
zlib__default.default.brotliCompress(buffer, (err, buffer2) => {
|
|
141
106
|
if (err) {
|
|
142
107
|
reject(err);
|
|
108
|
+
} else {
|
|
109
|
+
resolve(buffer2);
|
|
143
110
|
}
|
|
144
|
-
(0, import_node_fs2.writeFileSync)(targetFilePath, buffer2);
|
|
145
|
-
resolve(null);
|
|
146
111
|
});
|
|
147
112
|
});
|
|
148
113
|
}
|
|
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);
|
|
114
|
+
async function defaultUnzipFile(buffer) {
|
|
158
115
|
return new Promise((resolve, reject) => {
|
|
159
|
-
|
|
160
|
-
(0, import_node_fs3.rmSync)(gzipPath);
|
|
116
|
+
zlib__default.default.brotliDecompress(buffer, (err, buffer2) => {
|
|
161
117
|
if (err) {
|
|
162
118
|
reject(err);
|
|
119
|
+
} else {
|
|
120
|
+
resolve(buffer2);
|
|
163
121
|
}
|
|
164
|
-
(0, import_node_fs3.writeFileSync)(targetFilePath, buffer);
|
|
165
|
-
resolve(null);
|
|
166
122
|
});
|
|
167
123
|
});
|
|
168
124
|
}
|
|
169
125
|
|
|
170
126
|
// src/utils/version.ts
|
|
171
|
-
function handleUnexpectedErrors(callback) {
|
|
172
|
-
process.on("uncaughtException", callback);
|
|
173
|
-
process.on("unhandledRejection", callback);
|
|
174
|
-
}
|
|
175
127
|
function parseVersion(version) {
|
|
176
128
|
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?/i.exec(version);
|
|
177
129
|
if (!match) {
|
|
@@ -191,11 +143,11 @@ function parseVersion(version) {
|
|
|
191
143
|
ret.stageVersion = Number(_v) || -1;
|
|
192
144
|
}
|
|
193
145
|
if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch) || Number.isNaN(ret.stageVersion)) {
|
|
194
|
-
throw new TypeError(`
|
|
146
|
+
throw new TypeError(`Invalid version: ${version}`);
|
|
195
147
|
}
|
|
196
148
|
return ret;
|
|
197
149
|
}
|
|
198
|
-
function
|
|
150
|
+
function defaultIsLowerVersion(oldVer, newVer) {
|
|
199
151
|
const oldV = parseVersion(oldVer);
|
|
200
152
|
const newV = parseVersion(newVer);
|
|
201
153
|
function compareStrings(str1, str2) {
|
|
@@ -216,78 +168,77 @@ function isLowerVersionDefault(oldVer, newVer) {
|
|
|
216
168
|
return false;
|
|
217
169
|
}
|
|
218
170
|
function isUpdateJSON(json) {
|
|
219
|
-
const is = (j) => !!(j && j.minimumVersion && j.signature && j.
|
|
171
|
+
const is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
220
172
|
return is(json) && is(json?.beta);
|
|
221
173
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
174
|
+
function defaultVersionJsonGenerator(existingJson, signature, version, minimumVersion) {
|
|
175
|
+
existingJson.beta = {
|
|
176
|
+
version,
|
|
177
|
+
minimumVersion,
|
|
178
|
+
signature
|
|
179
|
+
};
|
|
180
|
+
if (!parseVersion(version).stage) {
|
|
181
|
+
existingJson.version = version;
|
|
182
|
+
existingJson.minimumVersion = minimumVersion;
|
|
183
|
+
existingJson.signature = signature;
|
|
184
|
+
}
|
|
185
|
+
return existingJson;
|
|
186
|
+
}
|
|
187
|
+
function hashBuffer(data, length) {
|
|
188
|
+
const hash = crypto__default.default.createHash("SHA256").update(data).digest("binary");
|
|
230
189
|
return Buffer.from(hash).subarray(0, length);
|
|
231
190
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
return
|
|
191
|
+
function aesEncrypt(plainText, key, iv) {
|
|
192
|
+
const cipher = crypto__default.default.createCipheriv("aes-256-cbc", key, iv);
|
|
193
|
+
return cipher.update(plainText, "utf8", "base64url") + cipher.final("base64url");
|
|
194
|
+
}
|
|
195
|
+
function defaultSignature(buffer, privateKey, cert, version) {
|
|
196
|
+
const sig = crypto__default.default.createSign("RSA-SHA256").update(buffer).sign(crypto__default.default.createPrivateKey(privateKey), "base64");
|
|
197
|
+
return aesEncrypt(`${sig}%${version}`, hashBuffer(cert, 32), hashBuffer(buffer, 16));
|
|
239
198
|
}
|
|
240
|
-
function
|
|
199
|
+
function aesDecrypt(encryptedText, key, iv) {
|
|
200
|
+
const decipher = crypto__default.default.createDecipheriv("aes-256-cbc", key, iv);
|
|
201
|
+
return decipher.update(encryptedText, "base64url", "utf8") + decipher.final("utf8");
|
|
202
|
+
}
|
|
203
|
+
function defaultVerifySignature(buffer, version, signature, cert) {
|
|
241
204
|
try {
|
|
242
|
-
const [sig,
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
return
|
|
205
|
+
const [sig, ver] = aesDecrypt(signature, hashBuffer(cert, 32), hashBuffer(buffer, 16)).split("%");
|
|
206
|
+
if (ver !== version) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
return crypto__default.default.createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
|
|
210
|
+
} catch {
|
|
211
|
+
return false;
|
|
247
212
|
}
|
|
248
213
|
}
|
|
249
214
|
|
|
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
|
-
|
|
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
|
-
});
|
|
215
|
+
exports.aesDecrypt = aesDecrypt;
|
|
216
|
+
exports.aesEncrypt = aesEncrypt;
|
|
217
|
+
exports.defaultIsLowerVersion = defaultIsLowerVersion;
|
|
218
|
+
exports.defaultSignature = defaultSignature;
|
|
219
|
+
exports.defaultUnzipFile = defaultUnzipFile;
|
|
220
|
+
exports.defaultVerifySignature = defaultVerifySignature;
|
|
221
|
+
exports.defaultVersionJsonGenerator = defaultVersionJsonGenerator;
|
|
222
|
+
exports.defaultZipFile = defaultZipFile;
|
|
223
|
+
exports.disableHWAccForWin7 = disableHWAccForWin7;
|
|
224
|
+
exports.getAppVersion = getAppVersion;
|
|
225
|
+
exports.getEntryVersion = getEntryVersion;
|
|
226
|
+
exports.getPathFromAppNameAsar = getPathFromAppNameAsar;
|
|
227
|
+
exports.getPathFromEntryAsar = getPathFromEntryAsar;
|
|
228
|
+
exports.getPathFromMain = getPathFromMain;
|
|
229
|
+
exports.getPathFromPreload = getPathFromPreload;
|
|
230
|
+
exports.getPathFromPublic = getPathFromPublic;
|
|
231
|
+
exports.handleUnexpectedErrors = handleUnexpectedErrors;
|
|
232
|
+
exports.hashBuffer = hashBuffer;
|
|
233
|
+
exports.isDev = isDev;
|
|
234
|
+
exports.isLinux = isLinux;
|
|
235
|
+
exports.isMac = isMac;
|
|
236
|
+
exports.isUpdateJSON = isUpdateJSON;
|
|
237
|
+
exports.isWin = isWin;
|
|
238
|
+
exports.loadPage = loadPage;
|
|
239
|
+
exports.parseVersion = parseVersion;
|
|
240
|
+
exports.requireNative = requireNative;
|
|
241
|
+
exports.restartApp = restartApp;
|
|
242
|
+
exports.setAppUserModelId = setAppUserModelId;
|
|
243
|
+
exports.setPortableAppDataPath = setPortableAppDataPath;
|
|
244
|
+
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-BYVQ367i.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 joined 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,59 @@ 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
|
|
44
|
+
*
|
|
45
|
+
* Only support CommonJS
|
|
42
46
|
*/
|
|
43
47
|
declare function disableHWAccForWin7(): void;
|
|
44
48
|
/**
|
|
45
|
-
*
|
|
49
|
+
* Keep single electron instance and auto restore window on `second-instance` event
|
|
46
50
|
* @param window brwoser window to show
|
|
47
51
|
* @returns `false` if the app is running
|
|
48
52
|
*/
|
|
49
53
|
declare function singleInstance(window?: BrowserWindow): boolean;
|
|
50
54
|
/**
|
|
51
|
-
*
|
|
55
|
+
* Set `AppData` dir to the dir of .exe file
|
|
52
56
|
*
|
|
53
|
-
*
|
|
57
|
+
* Useful for portable Windows app
|
|
54
58
|
* @param dirName dir name, default to `data`
|
|
55
59
|
*/
|
|
56
60
|
declare function setPortableAppDataPath(dirName?: string): void;
|
|
57
61
|
/**
|
|
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
|
|
62
|
+
* Load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
|
|
64
63
|
* @param win window
|
|
65
64
|
* @param htmlFilePath html file path, default is `index.html`
|
|
66
65
|
*/
|
|
67
66
|
declare function loadPage(win: BrowserWindow, htmlFilePath?: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* Get joined path from preload dir
|
|
69
|
+
* @param paths rest paths
|
|
70
|
+
*/
|
|
71
|
+
declare function getPathFromMain(...paths: string[]): string;
|
|
72
|
+
/**
|
|
73
|
+
* Get joined path from preload dir
|
|
74
|
+
* @param paths rest paths
|
|
75
|
+
*/
|
|
68
76
|
declare function getPathFromPreload(...paths: string[]): string;
|
|
77
|
+
/**
|
|
78
|
+
* Get joined path from publich dir
|
|
79
|
+
* @param paths rest paths
|
|
80
|
+
*/
|
|
69
81
|
declare function getPathFromPublic(...paths: string[]): string;
|
|
82
|
+
/**
|
|
83
|
+
* Get joined path from entry asar
|
|
84
|
+
* @param paths rest paths
|
|
85
|
+
*/
|
|
70
86
|
declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
87
|
+
/**
|
|
88
|
+
* Handle all unhandled error
|
|
89
|
+
* @param callback callback function
|
|
90
|
+
*/
|
|
91
|
+
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
71
92
|
|
|
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 };
|
|
93
|
+
export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromMain, 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-BYVQ367i.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 joined 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,59 @@ 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
|
|
44
|
+
*
|
|
45
|
+
* Only support CommonJS
|
|
42
46
|
*/
|
|
43
47
|
declare function disableHWAccForWin7(): void;
|
|
44
48
|
/**
|
|
45
|
-
*
|
|
49
|
+
* Keep single electron instance and auto restore window on `second-instance` event
|
|
46
50
|
* @param window brwoser window to show
|
|
47
51
|
* @returns `false` if the app is running
|
|
48
52
|
*/
|
|
49
53
|
declare function singleInstance(window?: BrowserWindow): boolean;
|
|
50
54
|
/**
|
|
51
|
-
*
|
|
55
|
+
* Set `AppData` dir to the dir of .exe file
|
|
52
56
|
*
|
|
53
|
-
*
|
|
57
|
+
* Useful for portable Windows app
|
|
54
58
|
* @param dirName dir name, default to `data`
|
|
55
59
|
*/
|
|
56
60
|
declare function setPortableAppDataPath(dirName?: string): void;
|
|
57
61
|
/**
|
|
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
|
|
62
|
+
* Load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
|
|
64
63
|
* @param win window
|
|
65
64
|
* @param htmlFilePath html file path, default is `index.html`
|
|
66
65
|
*/
|
|
67
66
|
declare function loadPage(win: BrowserWindow, htmlFilePath?: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* Get joined path from preload dir
|
|
69
|
+
* @param paths rest paths
|
|
70
|
+
*/
|
|
71
|
+
declare function getPathFromMain(...paths: string[]): string;
|
|
72
|
+
/**
|
|
73
|
+
* Get joined path from preload dir
|
|
74
|
+
* @param paths rest paths
|
|
75
|
+
*/
|
|
68
76
|
declare function getPathFromPreload(...paths: string[]): string;
|
|
77
|
+
/**
|
|
78
|
+
* Get joined path from publich dir
|
|
79
|
+
* @param paths rest paths
|
|
80
|
+
*/
|
|
69
81
|
declare function getPathFromPublic(...paths: string[]): string;
|
|
82
|
+
/**
|
|
83
|
+
* Get joined path from entry asar
|
|
84
|
+
* @param paths rest paths
|
|
85
|
+
*/
|
|
70
86
|
declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
87
|
+
/**
|
|
88
|
+
* Handle all unhandled error
|
|
89
|
+
* @param callback callback function
|
|
90
|
+
*/
|
|
91
|
+
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
71
92
|
|
|
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 };
|
|
93
|
+
export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromMain, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
|