electron-incremental-update 1.2.0 → 2.0.0-beta.1
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 +131 -10
- package/dist/chunk-RSLOPAIZ.js +247 -0
- package/dist/decrypt-BNBcodiO.d.cts +4 -0
- package/dist/decrypt-BNBcodiO.d.ts +4 -0
- package/dist/index.cjs +131 -336
- package/dist/index.d.cts +96 -161
- package/dist/index.d.ts +96 -161
- package/dist/index.js +97 -269
- package/dist/provider.cjs +227 -0
- package/dist/provider.d.cts +37 -0
- package/dist/provider.d.ts +37 -0
- package/dist/provider.js +98 -0
- package/dist/types-DxPmQmaq.d.cts +61 -0
- package/dist/types-seJf3Wbc.d.ts +61 -0
- package/dist/utils.cjs +140 -117
- package/dist/utils.d.cts +31 -76
- package/dist/utils.d.ts +31 -76
- package/dist/utils.js +35 -11
- package/dist/{pure-GoN_3MEj.d.cts → version-CffZWDhZ.d.cts} +8 -7
- package/dist/{pure-GoN_3MEj.d.ts → version-CffZWDhZ.d.ts} +8 -7
- package/dist/vite.js +71 -119
- package/package.json +12 -6
- package/provider.d.ts +1 -0
- package/provider.js +1 -0
- package/dist/chunk-7ET4GMTZ.js +0 -236
- package/dist/chunk-CXHA5TF7.js +0 -236
- package/dist/chunk-HWUYTDEF.js +0 -236
- package/dist/chunk-RQCTJY4L.js +0 -236
- package/dist/vite.d.ts +0 -372
package/dist/utils.cjs
CHANGED
|
@@ -20,21 +20,33 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/utils/index.ts
|
|
21
21
|
var utils_exports = {};
|
|
22
22
|
__export(utils_exports, {
|
|
23
|
+
decrypt: () => decrypt,
|
|
23
24
|
disableHWAccForWin7: () => disableHWAccForWin7,
|
|
25
|
+
encrypt: () => encrypt,
|
|
26
|
+
getAppVersion: () => getAppVersion,
|
|
27
|
+
getEntryVersion: () => getEntryVersion,
|
|
24
28
|
getPathFromAppNameAsar: () => getPathFromAppNameAsar,
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
getPathFromEntryAsar: () => getPathFromEntryAsar,
|
|
30
|
+
getPathFromPreload: () => getPathFromPreload,
|
|
31
|
+
getPathFromPublic: () => getPathFromPublic,
|
|
27
32
|
handleUnexpectedErrors: () => handleUnexpectedErrors,
|
|
28
|
-
|
|
33
|
+
hashString: () => hashString,
|
|
34
|
+
isDev: () => isDev,
|
|
35
|
+
isLinux: () => isLinux,
|
|
36
|
+
isLowerVersionDefault: () => isLowerVersionDefault,
|
|
37
|
+
isMac: () => isMac,
|
|
29
38
|
isUpdateJSON: () => isUpdateJSON,
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
isWin: () => isWin,
|
|
40
|
+
loadPage: () => loadPage,
|
|
32
41
|
parseVersion: () => parseVersion,
|
|
42
|
+
requireNative: () => requireNative,
|
|
33
43
|
restartApp: () => restartApp,
|
|
34
44
|
setAppUserModelId: () => setAppUserModelId,
|
|
35
45
|
setPortableAppDataPath: () => setPortableAppDataPath,
|
|
46
|
+
signature: () => signature,
|
|
36
47
|
singleInstance: () => singleInstance,
|
|
37
48
|
unzipFile: () => unzipFile,
|
|
49
|
+
verifySignatureDefault: () => verifySignatureDefault,
|
|
38
50
|
waitAppReady: () => waitAppReady,
|
|
39
51
|
zipFile: () => zipFile
|
|
40
52
|
});
|
|
@@ -43,46 +55,32 @@ module.exports = __toCommonJS(utils_exports);
|
|
|
43
55
|
// src/utils/electron.ts
|
|
44
56
|
var import_node_fs = require("fs");
|
|
45
57
|
var import_node_path = require("path");
|
|
46
|
-
var import_node_os = require("os");
|
|
47
58
|
var import_electron = require("electron");
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
linux: process.platform === "linux"
|
|
53
|
-
};
|
|
59
|
+
var isDev = __EIU_IS_DEV__;
|
|
60
|
+
var isWin = process.platform === "win32";
|
|
61
|
+
var isMac = process.platform === "darwin";
|
|
62
|
+
var isLinux = process.platform === "linux";
|
|
54
63
|
function getPathFromAppNameAsar(...path) {
|
|
55
|
-
return
|
|
64
|
+
return isDev ? "DEV.asar" : (0, import_node_path.join)((0, import_node_path.dirname)(import_electron.app.getAppPath()), `${import_electron.app.name}.asar`, ...path);
|
|
56
65
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
appVersion: is.dev ? import_electron.app.getVersion() : (0, import_node_fs.readFileSync)(getPathFromAppNameAsar("version"), "utf-8"),
|
|
61
|
-
entryVersion: import_electron.app.getVersion(),
|
|
62
|
-
electronVersion: process.versions.electron,
|
|
63
|
-
nodeVersion: process.versions.node,
|
|
64
|
-
systemVersion: `${platform} ${(0, import_node_os.release)()}`
|
|
65
|
-
};
|
|
66
|
+
function getAppVersion() {
|
|
67
|
+
return isDev ? getEntryVersion() : (0, import_node_fs.readFileSync)(getPathFromAppNameAsar("version"), "utf-8");
|
|
66
68
|
}
|
|
67
|
-
function
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
} catch (error) {
|
|
73
|
-
console.error("fail to load module", error);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
69
|
+
function getEntryVersion() {
|
|
70
|
+
return import_electron.app.getVersion();
|
|
71
|
+
}
|
|
72
|
+
function requireNative(moduleName) {
|
|
73
|
+
return require((0, import_node_path.join)(import_electron.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, moduleName));
|
|
76
74
|
}
|
|
77
75
|
function restartApp() {
|
|
78
76
|
import_electron.app.relaunch();
|
|
79
77
|
import_electron.app.quit();
|
|
80
78
|
}
|
|
81
79
|
function setAppUserModelId(id) {
|
|
82
|
-
import_electron.app.setAppUserModelId(
|
|
80
|
+
isWin && import_electron.app.setAppUserModelId(id ?? `org.${import_electron.app.name}`);
|
|
83
81
|
}
|
|
84
82
|
function disableHWAccForWin7() {
|
|
85
|
-
if ((
|
|
83
|
+
if (require("os").release().startsWith("6.1")) {
|
|
86
84
|
import_electron.app.disableHardwareAcceleration();
|
|
87
85
|
}
|
|
88
86
|
}
|
|
@@ -117,112 +115,65 @@ function waitAppReady(timeout = 1e3) {
|
|
|
117
115
|
});
|
|
118
116
|
});
|
|
119
117
|
}
|
|
120
|
-
function
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
* ```ts
|
|
132
|
-
* devServerURL && win.loadURL(devServerURL)
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
devServerURL,
|
|
136
|
-
/**
|
|
137
|
-
* @example
|
|
138
|
-
* ```ts
|
|
139
|
-
* win.loadFile(indexHTMLPath)
|
|
140
|
-
* ```
|
|
141
|
-
*/
|
|
142
|
-
indexHTMLPath,
|
|
143
|
-
/**
|
|
144
|
-
* get path inside entry asar
|
|
145
|
-
* @param paths joined path
|
|
146
|
-
*/
|
|
147
|
-
getPathFromEntryAsar(...paths) {
|
|
148
|
-
return (0, import_node_path.join)(import_electron.app.getAppPath(), entryDirName, ...paths);
|
|
149
|
-
},
|
|
150
|
-
/**
|
|
151
|
-
* get path inside `${electron.app.name}.asar/main`
|
|
152
|
-
* @param paths joined path
|
|
153
|
-
*/
|
|
154
|
-
getPathFromMain(...paths) {
|
|
155
|
-
return (0, import_node_path.join)(mainDirPath, ...paths);
|
|
156
|
-
},
|
|
157
|
-
/**
|
|
158
|
-
* get path inside `${electron.app.name}.asar/preload`
|
|
159
|
-
* @param paths joined path
|
|
160
|
-
*/
|
|
161
|
-
getPathFromPreload(...paths) {
|
|
162
|
-
return (0, import_node_path.join)(preloadDirPath, ...paths);
|
|
163
|
-
},
|
|
164
|
-
/**
|
|
165
|
-
* get path inside public dir
|
|
166
|
-
* @param paths joined path
|
|
167
|
-
*/
|
|
168
|
-
getPathFromPublic(...paths) {
|
|
169
|
-
return (0, import_node_path.join)(publicDirPath, ...paths);
|
|
170
|
-
}
|
|
171
|
-
};
|
|
118
|
+
function loadPage(win, htmlFilePath = "index.html") {
|
|
119
|
+
isDev ? win.loadURL(process.env.VITE_DEV_SERVER_URL + htmlFilePath) : win.loadFile(getPathFromAppNameAsar("renderer", htmlFilePath));
|
|
120
|
+
}
|
|
121
|
+
function getPathFromPreload(...paths) {
|
|
122
|
+
return isDev ? (0, import_node_path.join)(import_electron.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "preload", ...paths) : getPathFromAppNameAsar("preload", ...paths);
|
|
123
|
+
}
|
|
124
|
+
function getPathFromPublic(...paths) {
|
|
125
|
+
return isDev ? (0, import_node_path.join)(import_electron.app.getAppPath(), "public", ...paths) : getPathFromAppNameAsar("renderer", ...paths);
|
|
126
|
+
}
|
|
127
|
+
function getPathFromEntryAsar(...paths) {
|
|
128
|
+
return (0, import_node_path.join)(import_electron.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, ...paths);
|
|
172
129
|
}
|
|
173
130
|
|
|
174
131
|
// src/utils/zip.ts
|
|
175
132
|
var import_node_fs2 = require("fs");
|
|
176
133
|
var import_node_zlib = require("zlib");
|
|
177
|
-
async function
|
|
178
|
-
if (!(0, import_node_fs2.existsSync)(
|
|
179
|
-
throw new Error(`path to zipped
|
|
134
|
+
async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
|
|
135
|
+
if (!(0, import_node_fs2.existsSync)(filePath)) {
|
|
136
|
+
throw new Error(`path to be zipped not exist: ${filePath}`);
|
|
180
137
|
}
|
|
181
|
-
const
|
|
138
|
+
const buffer = (0, import_node_fs2.readFileSync)(filePath);
|
|
182
139
|
return new Promise((resolve, reject) => {
|
|
183
|
-
(0, import_node_zlib.
|
|
184
|
-
(0, import_node_fs2.rmSync)(gzipPath);
|
|
140
|
+
(0, import_node_zlib.brotliCompress)(buffer, (err, buffer2) => {
|
|
185
141
|
if (err) {
|
|
186
142
|
reject(err);
|
|
187
143
|
}
|
|
188
|
-
(0, import_node_fs2.writeFileSync)(targetFilePath,
|
|
144
|
+
(0, import_node_fs2.writeFileSync)(targetFilePath, buffer2);
|
|
189
145
|
resolve(null);
|
|
190
146
|
});
|
|
191
147
|
});
|
|
192
148
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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}`);
|
|
196
156
|
}
|
|
197
|
-
const
|
|
157
|
+
const compressedBuffer = (0, import_node_fs3.readFileSync)(gzipPath);
|
|
198
158
|
return new Promise((resolve, reject) => {
|
|
199
|
-
(0,
|
|
159
|
+
(0, import_node_zlib2.brotliDecompress)(compressedBuffer, (err, buffer) => {
|
|
160
|
+
(0, import_node_fs3.rmSync)(gzipPath);
|
|
200
161
|
if (err) {
|
|
201
162
|
reject(err);
|
|
202
163
|
}
|
|
203
|
-
(0,
|
|
164
|
+
(0, import_node_fs3.writeFileSync)(targetFilePath, buffer);
|
|
204
165
|
resolve(null);
|
|
205
166
|
});
|
|
206
167
|
});
|
|
207
168
|
}
|
|
208
169
|
|
|
209
|
-
// src/utils/
|
|
210
|
-
function parseGithubCdnURL(originRepoURL, cdnPrefix, relativeFilePath) {
|
|
211
|
-
if (!originRepoURL.startsWith("https://github.com/")) {
|
|
212
|
-
throw new Error("origin url must start with https://github.com/");
|
|
213
|
-
}
|
|
214
|
-
originRepoURL = originRepoURL.trim().replace(/\/?$/, "/").trim();
|
|
215
|
-
relativeFilePath = relativeFilePath.trim().replace(/^\/|\/?$/g, "").trim();
|
|
216
|
-
cdnPrefix = cdnPrefix.trim().replace(/^\/?|\/?$/g, "").trim();
|
|
217
|
-
return originRepoURL.replace("github.com", cdnPrefix) + relativeFilePath;
|
|
218
|
-
}
|
|
170
|
+
// src/utils/version.ts
|
|
219
171
|
function handleUnexpectedErrors(callback) {
|
|
220
172
|
process.on("uncaughtException", callback);
|
|
221
173
|
process.on("unhandledRejection", callback);
|
|
222
174
|
}
|
|
223
175
|
function parseVersion(version) {
|
|
224
|
-
const
|
|
225
|
-
const match = semver.exec(version);
|
|
176
|
+
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?/i.exec(version);
|
|
226
177
|
if (!match) {
|
|
227
178
|
throw new TypeError(`invalid version: ${version}`);
|
|
228
179
|
}
|
|
@@ -244,27 +195,99 @@ function parseVersion(version) {
|
|
|
244
195
|
}
|
|
245
196
|
return ret;
|
|
246
197
|
}
|
|
198
|
+
function isLowerVersionDefault(oldVer, newVer) {
|
|
199
|
+
const oldV = parseVersion(oldVer);
|
|
200
|
+
const newV = parseVersion(newVer);
|
|
201
|
+
function compareStrings(str1, str2) {
|
|
202
|
+
if (str1 === "") {
|
|
203
|
+
return str2 !== "";
|
|
204
|
+
} else if (str2 === "") {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
return str1 < str2;
|
|
208
|
+
}
|
|
209
|
+
for (let key of Object.keys(oldV)) {
|
|
210
|
+
if (key === "stage" && compareStrings(oldV[key], newV[key])) {
|
|
211
|
+
return true;
|
|
212
|
+
} else if (oldV[key] !== newV[key]) {
|
|
213
|
+
return oldV[key] < newV[key];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
247
218
|
function isUpdateJSON(json) {
|
|
248
|
-
const
|
|
249
|
-
return
|
|
219
|
+
const is = (j) => !!(j && j.minimumVersion && j.signature && j.size && j.version);
|
|
220
|
+
return is(json) && is(json?.beta);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// src/utils/crypto/decrypt.ts
|
|
224
|
+
var import_node_crypto2 = require("crypto");
|
|
225
|
+
|
|
226
|
+
// src/utils/crypto/utils.ts
|
|
227
|
+
var import_node_crypto = require("crypto");
|
|
228
|
+
function hashString(data, length) {
|
|
229
|
+
const hash = (0, import_node_crypto.createHash)("SHA256").update(data).digest("binary");
|
|
230
|
+
return Buffer.from(hash).subarray(0, length);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// src/utils/crypto/decrypt.ts
|
|
234
|
+
function decrypt(encryptedText, key, iv) {
|
|
235
|
+
const decipher = (0, import_node_crypto2.createDecipheriv)("aes-256-cbc", key, iv);
|
|
236
|
+
let decrypted = decipher.update(encryptedText, "base64url", "utf8");
|
|
237
|
+
decrypted += decipher.final("utf8");
|
|
238
|
+
return decrypted;
|
|
239
|
+
}
|
|
240
|
+
function verifySignatureDefault(buffer, signature2, cert) {
|
|
241
|
+
try {
|
|
242
|
+
const [sig, version] = decrypt(signature2, hashString(cert, 32), hashString(buffer, 16)).split("%");
|
|
243
|
+
const result = (0, import_node_crypto2.createVerify)("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
|
|
244
|
+
return result ? version : void 0;
|
|
245
|
+
} catch (error) {
|
|
246
|
+
return void 0;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// src/utils/crypto/encrypt.ts
|
|
251
|
+
var import_node_crypto3 = require("crypto");
|
|
252
|
+
function encrypt(plainText, key, iv) {
|
|
253
|
+
const cipher = (0, import_node_crypto3.createCipheriv)("aes-256-cbc", key, iv);
|
|
254
|
+
let encrypted = cipher.update(plainText, "utf8", "base64url");
|
|
255
|
+
encrypted += cipher.final("base64url");
|
|
256
|
+
return encrypted;
|
|
257
|
+
}
|
|
258
|
+
function signature(buffer, privateKey, cert, version) {
|
|
259
|
+
const sig = (0, import_node_crypto3.createSign)("RSA-SHA256").update(buffer).sign((0, import_node_crypto3.createPrivateKey)(privateKey), "base64");
|
|
260
|
+
return encrypt(`${sig}%${version}`, hashString(cert, 32), hashString(buffer, 16));
|
|
250
261
|
}
|
|
251
262
|
// Annotate the CommonJS export names for ESM import in node:
|
|
252
263
|
0 && (module.exports = {
|
|
264
|
+
decrypt,
|
|
253
265
|
disableHWAccForWin7,
|
|
266
|
+
encrypt,
|
|
267
|
+
getAppVersion,
|
|
268
|
+
getEntryVersion,
|
|
254
269
|
getPathFromAppNameAsar,
|
|
255
|
-
|
|
256
|
-
|
|
270
|
+
getPathFromEntryAsar,
|
|
271
|
+
getPathFromPreload,
|
|
272
|
+
getPathFromPublic,
|
|
257
273
|
handleUnexpectedErrors,
|
|
258
|
-
|
|
274
|
+
hashString,
|
|
275
|
+
isDev,
|
|
276
|
+
isLinux,
|
|
277
|
+
isLowerVersionDefault,
|
|
278
|
+
isMac,
|
|
259
279
|
isUpdateJSON,
|
|
260
|
-
|
|
261
|
-
|
|
280
|
+
isWin,
|
|
281
|
+
loadPage,
|
|
262
282
|
parseVersion,
|
|
283
|
+
requireNative,
|
|
263
284
|
restartApp,
|
|
264
285
|
setAppUserModelId,
|
|
265
286
|
setPortableAppDataPath,
|
|
287
|
+
signature,
|
|
266
288
|
singleInstance,
|
|
267
289
|
unzipFile,
|
|
290
|
+
verifySignatureDefault,
|
|
268
291
|
waitAppReady,
|
|
269
292
|
zipFile
|
|
270
293
|
});
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,60 +1,40 @@
|
|
|
1
1
|
import { BrowserWindow } from 'electron';
|
|
2
|
-
export {
|
|
2
|
+
export { a as UpdateInfo, U as UpdateJSON, V as Version, h as handleUnexpectedErrors, i as isLowerVersionDefault, b as isUpdateJSON, p as parseVersion } from './version-CffZWDhZ.cjs';
|
|
3
|
+
export { d as decrypt, v as verifySignatureDefault } from './decrypt-BNBcodiO.cjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
+
* compile time dev check
|
|
6
7
|
*/
|
|
7
|
-
declare const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
readonly linux: boolean;
|
|
12
|
-
};
|
|
8
|
+
declare const isDev: boolean;
|
|
9
|
+
declare const isWin: boolean;
|
|
10
|
+
declare const isMac: boolean;
|
|
11
|
+
declare const isLinux: boolean;
|
|
13
12
|
/**
|
|
14
13
|
* get the absolute path of `${electron.app.name}.asar` (not `app.asar`)
|
|
15
14
|
*
|
|
16
|
-
* if is in dev, return `'DEV.asar'`
|
|
15
|
+
* if is in dev, **always** return `'DEV.asar'`
|
|
17
16
|
*/
|
|
18
17
|
declare function getPathFromAppNameAsar(...path: string[]): string;
|
|
19
18
|
/**
|
|
20
|
-
* get
|
|
21
|
-
*
|
|
22
|
-
* App version is read from `version` file in `${electron.app.name}.asar`
|
|
23
|
-
*
|
|
24
|
-
* Entry version is read from `package.json`
|
|
25
|
-
*
|
|
26
|
-
* SystemVersion: `${platform} ${os.release()}`
|
|
19
|
+
* get app version, if is in dev, return `getEntryVersion()`
|
|
27
20
|
*/
|
|
28
|
-
declare function
|
|
29
|
-
appVersion: string;
|
|
30
|
-
entryVersion: string;
|
|
31
|
-
electronVersion: string;
|
|
32
|
-
nodeVersion: string;
|
|
33
|
-
systemVersion: string;
|
|
34
|
-
};
|
|
21
|
+
declare function getAppVersion(): string;
|
|
35
22
|
/**
|
|
36
|
-
*
|
|
37
|
-
* @param moduleName file name in entry
|
|
23
|
+
* get entry version
|
|
38
24
|
*/
|
|
39
|
-
|
|
25
|
+
declare function getEntryVersion(): string;
|
|
40
26
|
/**
|
|
41
|
-
* load module from entry
|
|
42
|
-
* @
|
|
43
|
-
* @param devEntryDirPath entry directory path when dev, default `../../dist-entry`
|
|
44
|
-
* @param entryDirPath entry directory path when not dev, default `join(app.getAppPath(), basename(devEntryDirPath))`
|
|
45
|
-
* @example
|
|
46
|
-
* const requireNative = loadNativeModuleFromEntry()
|
|
47
|
-
* const db = requireNative<typeof import('../native/db')>('db')
|
|
48
|
-
* db.test()
|
|
27
|
+
* use `require` to load native module from entry
|
|
28
|
+
* @param moduleName file name in entry
|
|
49
29
|
*/
|
|
50
|
-
declare function
|
|
30
|
+
declare function requireNative<T = any>(moduleName: string): T;
|
|
51
31
|
/**
|
|
52
32
|
* Restarts the Electron app.
|
|
53
33
|
*/
|
|
54
34
|
declare function restartApp(): void;
|
|
55
35
|
/**
|
|
56
36
|
* fix app use model id, only for Windows
|
|
57
|
-
* @param id app id
|
|
37
|
+
* @param id app id, default is `org.${electron.app.name}`
|
|
58
38
|
*/
|
|
59
39
|
declare function setAppUserModelId(id?: string): void;
|
|
60
40
|
/**
|
|
@@ -80,47 +60,22 @@ declare function setPortableAppDataPath(dirName?: string): void;
|
|
|
80
60
|
*/
|
|
81
61
|
declare function waitAppReady(timeout?: number): Promise<void>;
|
|
82
62
|
/**
|
|
83
|
-
*
|
|
84
|
-
* @param
|
|
63
|
+
* load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
|
|
64
|
+
* @param win window
|
|
65
|
+
* @param htmlFilePath html file path, default is `index.html`
|
|
85
66
|
*/
|
|
86
|
-
declare function
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
* devServerURL && win.loadURL(devServerURL)
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
devServerURL: string | undefined;
|
|
94
|
-
/**
|
|
95
|
-
* @example
|
|
96
|
-
* ```ts
|
|
97
|
-
* win.loadFile(indexHTMLPath)
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
indexHTMLPath: string;
|
|
101
|
-
/**
|
|
102
|
-
* get path inside entry asar
|
|
103
|
-
* @param paths joined path
|
|
104
|
-
*/
|
|
105
|
-
getPathFromEntryAsar(...paths: string[]): string;
|
|
106
|
-
/**
|
|
107
|
-
* get path inside `${electron.app.name}.asar/main`
|
|
108
|
-
* @param paths joined path
|
|
109
|
-
*/
|
|
110
|
-
getPathFromMain(...paths: string[]): string;
|
|
111
|
-
/**
|
|
112
|
-
* get path inside `${electron.app.name}.asar/preload`
|
|
113
|
-
* @param paths joined path
|
|
114
|
-
*/
|
|
115
|
-
getPathFromPreload(...paths: string[]): string;
|
|
116
|
-
/**
|
|
117
|
-
* get path inside public dir
|
|
118
|
-
* @param paths joined path
|
|
119
|
-
*/
|
|
120
|
-
getPathFromPublic(...paths: string[]): string;
|
|
121
|
-
};
|
|
67
|
+
declare function loadPage(win: BrowserWindow, htmlFilePath?: string): void;
|
|
68
|
+
declare function getPathFromPreload(...paths: string[]): string;
|
|
69
|
+
declare function getPathFromPublic(...paths: string[]): string;
|
|
70
|
+
declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
122
71
|
|
|
123
|
-
declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
|
|
124
72
|
declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
|
|
125
73
|
|
|
126
|
-
|
|
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 };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,60 +1,40 @@
|
|
|
1
1
|
import { BrowserWindow } from 'electron';
|
|
2
|
-
export {
|
|
2
|
+
export { a as UpdateInfo, U as UpdateJSON, V as Version, h as handleUnexpectedErrors, i as isLowerVersionDefault, b as isUpdateJSON, p as parseVersion } from './version-CffZWDhZ.js';
|
|
3
|
+
export { d as decrypt, v as verifySignatureDefault } from './decrypt-BNBcodiO.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
+
* compile time dev check
|
|
6
7
|
*/
|
|
7
|
-
declare const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
readonly linux: boolean;
|
|
12
|
-
};
|
|
8
|
+
declare const isDev: boolean;
|
|
9
|
+
declare const isWin: boolean;
|
|
10
|
+
declare const isMac: boolean;
|
|
11
|
+
declare const isLinux: boolean;
|
|
13
12
|
/**
|
|
14
13
|
* get the absolute path of `${electron.app.name}.asar` (not `app.asar`)
|
|
15
14
|
*
|
|
16
|
-
* if is in dev, return `'DEV.asar'`
|
|
15
|
+
* if is in dev, **always** return `'DEV.asar'`
|
|
17
16
|
*/
|
|
18
17
|
declare function getPathFromAppNameAsar(...path: string[]): string;
|
|
19
18
|
/**
|
|
20
|
-
* get
|
|
21
|
-
*
|
|
22
|
-
* App version is read from `version` file in `${electron.app.name}.asar`
|
|
23
|
-
*
|
|
24
|
-
* Entry version is read from `package.json`
|
|
25
|
-
*
|
|
26
|
-
* SystemVersion: `${platform} ${os.release()}`
|
|
19
|
+
* get app version, if is in dev, return `getEntryVersion()`
|
|
27
20
|
*/
|
|
28
|
-
declare function
|
|
29
|
-
appVersion: string;
|
|
30
|
-
entryVersion: string;
|
|
31
|
-
electronVersion: string;
|
|
32
|
-
nodeVersion: string;
|
|
33
|
-
systemVersion: string;
|
|
34
|
-
};
|
|
21
|
+
declare function getAppVersion(): string;
|
|
35
22
|
/**
|
|
36
|
-
*
|
|
37
|
-
* @param moduleName file name in entry
|
|
23
|
+
* get entry version
|
|
38
24
|
*/
|
|
39
|
-
|
|
25
|
+
declare function getEntryVersion(): string;
|
|
40
26
|
/**
|
|
41
|
-
* load module from entry
|
|
42
|
-
* @
|
|
43
|
-
* @param devEntryDirPath entry directory path when dev, default `../../dist-entry`
|
|
44
|
-
* @param entryDirPath entry directory path when not dev, default `join(app.getAppPath(), basename(devEntryDirPath))`
|
|
45
|
-
* @example
|
|
46
|
-
* const requireNative = loadNativeModuleFromEntry()
|
|
47
|
-
* const db = requireNative<typeof import('../native/db')>('db')
|
|
48
|
-
* db.test()
|
|
27
|
+
* use `require` to load native module from entry
|
|
28
|
+
* @param moduleName file name in entry
|
|
49
29
|
*/
|
|
50
|
-
declare function
|
|
30
|
+
declare function requireNative<T = any>(moduleName: string): T;
|
|
51
31
|
/**
|
|
52
32
|
* Restarts the Electron app.
|
|
53
33
|
*/
|
|
54
34
|
declare function restartApp(): void;
|
|
55
35
|
/**
|
|
56
36
|
* fix app use model id, only for Windows
|
|
57
|
-
* @param id app id
|
|
37
|
+
* @param id app id, default is `org.${electron.app.name}`
|
|
58
38
|
*/
|
|
59
39
|
declare function setAppUserModelId(id?: string): void;
|
|
60
40
|
/**
|
|
@@ -80,47 +60,22 @@ declare function setPortableAppDataPath(dirName?: string): void;
|
|
|
80
60
|
*/
|
|
81
61
|
declare function waitAppReady(timeout?: number): Promise<void>;
|
|
82
62
|
/**
|
|
83
|
-
*
|
|
84
|
-
* @param
|
|
63
|
+
* load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
|
|
64
|
+
* @param win window
|
|
65
|
+
* @param htmlFilePath html file path, default is `index.html`
|
|
85
66
|
*/
|
|
86
|
-
declare function
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
* devServerURL && win.loadURL(devServerURL)
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
devServerURL: string | undefined;
|
|
94
|
-
/**
|
|
95
|
-
* @example
|
|
96
|
-
* ```ts
|
|
97
|
-
* win.loadFile(indexHTMLPath)
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
indexHTMLPath: string;
|
|
101
|
-
/**
|
|
102
|
-
* get path inside entry asar
|
|
103
|
-
* @param paths joined path
|
|
104
|
-
*/
|
|
105
|
-
getPathFromEntryAsar(...paths: string[]): string;
|
|
106
|
-
/**
|
|
107
|
-
* get path inside `${electron.app.name}.asar/main`
|
|
108
|
-
* @param paths joined path
|
|
109
|
-
*/
|
|
110
|
-
getPathFromMain(...paths: string[]): string;
|
|
111
|
-
/**
|
|
112
|
-
* get path inside `${electron.app.name}.asar/preload`
|
|
113
|
-
* @param paths joined path
|
|
114
|
-
*/
|
|
115
|
-
getPathFromPreload(...paths: string[]): string;
|
|
116
|
-
/**
|
|
117
|
-
* get path inside public dir
|
|
118
|
-
* @param paths joined path
|
|
119
|
-
*/
|
|
120
|
-
getPathFromPublic(...paths: string[]): string;
|
|
121
|
-
};
|
|
67
|
+
declare function loadPage(win: BrowserWindow, htmlFilePath?: string): void;
|
|
68
|
+
declare function getPathFromPreload(...paths: string[]): string;
|
|
69
|
+
declare function getPathFromPublic(...paths: string[]): string;
|
|
70
|
+
declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
122
71
|
|
|
123
|
-
declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
|
|
124
72
|
declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
|
|
125
73
|
|
|
126
|
-
|
|
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 };
|