electron-incremental-update 1.3.0 → 2.0.0-beta.2
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 +7 -3
- package/dist/chunk-BG22XZAB.js +257 -0
- package/dist/decrypt-D9WdXYjH.d.cts +4 -0
- package/dist/decrypt-D9WdXYjH.d.ts +4 -0
- package/dist/index.cjs +164 -303
- package/dist/index.d.cts +81 -182
- package/dist/index.d.ts +81 -182
- package/dist/index.js +132 -237
- package/dist/provider.cjs +236 -0
- package/dist/provider.d.cts +37 -0
- package/dist/provider.d.ts +37 -0
- package/dist/provider.js +107 -0
- package/dist/types-COqp44eg.d.cts +69 -0
- package/dist/types-CPq1MrYZ.d.ts +69 -0
- package/dist/utils.cjs +159 -125
- package/dist/utils.d.cts +32 -77
- package/dist/utils.d.ts +32 -77
- 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 +101 -136
- package/package.json +13 -7
- 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/chunk-SBPTSLG7.js +0 -235
- 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,60 +55,52 @@ 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
|
-
|
|
80
|
+
if (isWin) {
|
|
81
|
+
import_electron.app.setAppUserModelId(id ?? `org.${import_electron.app.name}`);
|
|
82
|
+
}
|
|
83
83
|
}
|
|
84
84
|
function disableHWAccForWin7() {
|
|
85
|
-
if ((
|
|
85
|
+
if (require("os").release().startsWith("6.1")) {
|
|
86
86
|
import_electron.app.disableHardwareAcceleration();
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
function singleInstance(window) {
|
|
90
90
|
const result = import_electron.app.requestSingleInstanceLock();
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
window
|
|
94
|
-
|
|
95
|
-
window.
|
|
91
|
+
if (result) {
|
|
92
|
+
import_electron.app.on("second-instance", () => {
|
|
93
|
+
if (window) {
|
|
94
|
+
window.show();
|
|
95
|
+
if (window.isMinimized()) {
|
|
96
|
+
window.restore();
|
|
97
|
+
}
|
|
98
|
+
window.focus();
|
|
96
99
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
});
|
|
101
|
+
} else {
|
|
102
|
+
import_electron.app.quit();
|
|
103
|
+
}
|
|
100
104
|
return result;
|
|
101
105
|
}
|
|
102
106
|
function setPortableAppDataPath(dirName = "data") {
|
|
@@ -117,79 +121,26 @@ function waitAppReady(timeout = 1e3) {
|
|
|
117
121
|
});
|
|
118
122
|
});
|
|
119
123
|
}
|
|
120
|
-
function
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
};
|
|
124
|
+
function loadPage(win, htmlFilePath = "index.html") {
|
|
125
|
+
if (isDev) {
|
|
126
|
+
win.loadURL(process.env.VITE_DEV_SERVER_URL + htmlFilePath);
|
|
127
|
+
} else {
|
|
128
|
+
win.loadFile(getPathFromAppNameAsar("renderer", htmlFilePath));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function getPathFromPreload(...paths) {
|
|
132
|
+
return isDev ? (0, import_node_path.join)(import_electron.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "preload", ...paths) : getPathFromAppNameAsar("preload", ...paths);
|
|
133
|
+
}
|
|
134
|
+
function getPathFromPublic(...paths) {
|
|
135
|
+
return isDev ? (0, import_node_path.join)(import_electron.app.getAppPath(), "public", ...paths) : getPathFromAppNameAsar("renderer", ...paths);
|
|
136
|
+
}
|
|
137
|
+
function getPathFromEntryAsar(...paths) {
|
|
138
|
+
return (0, import_node_path.join)(import_electron.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, ...paths);
|
|
172
139
|
}
|
|
173
140
|
|
|
174
141
|
// src/utils/zip.ts
|
|
175
142
|
var import_node_fs2 = require("fs");
|
|
176
143
|
var import_node_zlib = require("zlib");
|
|
177
|
-
async function unzipFile(gzipPath, targetFilePath = gzipPath.slice(0, -3)) {
|
|
178
|
-
if (!(0, import_node_fs2.existsSync)(gzipPath)) {
|
|
179
|
-
throw new Error(`path to zipped file not exist: ${gzipPath}`);
|
|
180
|
-
}
|
|
181
|
-
const compressedBuffer = (0, import_node_fs2.readFileSync)(gzipPath);
|
|
182
|
-
return new Promise((resolve, reject) => {
|
|
183
|
-
(0, import_node_zlib.brotliDecompress)(compressedBuffer, (err, buffer) => {
|
|
184
|
-
(0, import_node_fs2.rmSync)(gzipPath);
|
|
185
|
-
if (err) {
|
|
186
|
-
reject(err);
|
|
187
|
-
}
|
|
188
|
-
(0, import_node_fs2.writeFileSync)(targetFilePath, buffer);
|
|
189
|
-
resolve(null);
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
144
|
async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
|
|
194
145
|
if (!(0, import_node_fs2.existsSync)(filePath)) {
|
|
195
146
|
throw new Error(`path to be zipped not exist: ${filePath}`);
|
|
@@ -201,21 +152,32 @@ async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
|
|
|
201
152
|
reject(err);
|
|
202
153
|
}
|
|
203
154
|
(0, import_node_fs2.writeFileSync)(targetFilePath, buffer2);
|
|
204
|
-
resolve(
|
|
155
|
+
resolve();
|
|
205
156
|
});
|
|
206
157
|
});
|
|
207
158
|
}
|
|
208
159
|
|
|
209
|
-
// src/utils/
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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}`);
|
|
213
166
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
167
|
+
const compressedBuffer = (0, import_node_fs3.readFileSync)(gzipPath);
|
|
168
|
+
return new Promise((resolve, reject) => {
|
|
169
|
+
(0, import_node_zlib2.brotliDecompress)(compressedBuffer, (err, buffer) => {
|
|
170
|
+
(0, import_node_fs3.rmSync)(gzipPath);
|
|
171
|
+
if (err) {
|
|
172
|
+
reject(err);
|
|
173
|
+
}
|
|
174
|
+
(0, import_node_fs3.writeFileSync)(targetFilePath, buffer);
|
|
175
|
+
resolve();
|
|
176
|
+
});
|
|
177
|
+
});
|
|
218
178
|
}
|
|
179
|
+
|
|
180
|
+
// src/utils/version.ts
|
|
219
181
|
function handleUnexpectedErrors(callback) {
|
|
220
182
|
process.on("uncaughtException", callback);
|
|
221
183
|
process.on("unhandledRejection", callback);
|
|
@@ -243,27 +205,99 @@ function parseVersion(version) {
|
|
|
243
205
|
}
|
|
244
206
|
return ret;
|
|
245
207
|
}
|
|
208
|
+
function isLowerVersionDefault(oldVer, newVer) {
|
|
209
|
+
const oldV = parseVersion(oldVer);
|
|
210
|
+
const newV = parseVersion(newVer);
|
|
211
|
+
function compareStrings(str1, str2) {
|
|
212
|
+
if (str1 === "") {
|
|
213
|
+
return str2 !== "";
|
|
214
|
+
} else if (str2 === "") {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
return str1 < str2;
|
|
218
|
+
}
|
|
219
|
+
for (let key of Object.keys(oldV)) {
|
|
220
|
+
if (key === "stage" && compareStrings(oldV[key], newV[key])) {
|
|
221
|
+
return true;
|
|
222
|
+
} else if (oldV[key] !== newV[key]) {
|
|
223
|
+
return oldV[key] < newV[key];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
246
228
|
function isUpdateJSON(json) {
|
|
247
|
-
const
|
|
248
|
-
return
|
|
229
|
+
const is = (j) => !!(j && j.minimumVersion && j.signature && j.size && j.version);
|
|
230
|
+
return is(json) && is(json?.beta);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// src/utils/crypto/decrypt.ts
|
|
234
|
+
var import_node_crypto2 = require("crypto");
|
|
235
|
+
|
|
236
|
+
// src/utils/crypto/utils.ts
|
|
237
|
+
var import_node_crypto = require("crypto");
|
|
238
|
+
function hashString(data, length) {
|
|
239
|
+
const hash = (0, import_node_crypto.createHash)("SHA256").update(data).digest("binary");
|
|
240
|
+
return Buffer.from(hash).subarray(0, length);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// src/utils/crypto/decrypt.ts
|
|
244
|
+
function decrypt(encryptedText, key, iv) {
|
|
245
|
+
const decipher = (0, import_node_crypto2.createDecipheriv)("aes-256-cbc", key, iv);
|
|
246
|
+
let decrypted = decipher.update(encryptedText, "base64url", "utf8");
|
|
247
|
+
decrypted += decipher.final("utf8");
|
|
248
|
+
return decrypted;
|
|
249
|
+
}
|
|
250
|
+
function verifySignatureDefault(buffer, signature2, cert) {
|
|
251
|
+
try {
|
|
252
|
+
const [sig, version] = decrypt(signature2, hashString(cert, 32), hashString(buffer, 16)).split("%");
|
|
253
|
+
const result = (0, import_node_crypto2.createVerify)("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
|
|
254
|
+
return result ? version : void 0;
|
|
255
|
+
} catch {
|
|
256
|
+
return void 0;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// src/utils/crypto/encrypt.ts
|
|
261
|
+
var import_node_crypto3 = require("crypto");
|
|
262
|
+
function encrypt(plainText, key, iv) {
|
|
263
|
+
const cipher = (0, import_node_crypto3.createCipheriv)("aes-256-cbc", key, iv);
|
|
264
|
+
let encrypted = cipher.update(plainText, "utf8", "base64url");
|
|
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));
|
|
249
271
|
}
|
|
250
272
|
// Annotate the CommonJS export names for ESM import in node:
|
|
251
273
|
0 && (module.exports = {
|
|
274
|
+
decrypt,
|
|
252
275
|
disableHWAccForWin7,
|
|
276
|
+
encrypt,
|
|
277
|
+
getAppVersion,
|
|
278
|
+
getEntryVersion,
|
|
253
279
|
getPathFromAppNameAsar,
|
|
254
|
-
|
|
255
|
-
|
|
280
|
+
getPathFromEntryAsar,
|
|
281
|
+
getPathFromPreload,
|
|
282
|
+
getPathFromPublic,
|
|
256
283
|
handleUnexpectedErrors,
|
|
257
|
-
|
|
284
|
+
hashString,
|
|
285
|
+
isDev,
|
|
286
|
+
isLinux,
|
|
287
|
+
isLowerVersionDefault,
|
|
288
|
+
isMac,
|
|
258
289
|
isUpdateJSON,
|
|
259
|
-
|
|
260
|
-
|
|
290
|
+
isWin,
|
|
291
|
+
loadPage,
|
|
261
292
|
parseVersion,
|
|
293
|
+
requireNative,
|
|
262
294
|
restartApp,
|
|
263
295
|
setAppUserModelId,
|
|
264
296
|
setPortableAppDataPath,
|
|
297
|
+
signature,
|
|
265
298
|
singleInstance,
|
|
266
299
|
unzipFile,
|
|
300
|
+
verifySignatureDefault,
|
|
267
301
|
waitAppReady,
|
|
268
302
|
zipFile
|
|
269
303
|
});
|
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-D9WdXYjH.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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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;
|
|
71
|
+
|
|
72
|
+
declare function zipFile(filePath: string, targetFilePath?: string): Promise<void>;
|
|
73
|
+
|
|
74
|
+
declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<void>;
|
|
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;
|
|
122
78
|
|
|
123
|
-
declare function
|
|
124
|
-
declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
|
|
79
|
+
declare function hashString(data: string | Buffer, length: number): Buffer;
|
|
125
80
|
|
|
126
|
-
export { disableHWAccForWin7, getPathFromAppNameAsar,
|
|
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-D9WdXYjH.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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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;
|
|
71
|
+
|
|
72
|
+
declare function zipFile(filePath: string, targetFilePath?: string): Promise<void>;
|
|
73
|
+
|
|
74
|
+
declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<void>;
|
|
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;
|
|
122
78
|
|
|
123
|
-
declare function
|
|
124
|
-
declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
|
|
79
|
+
declare function hashString(data: string | Buffer, length: number): Buffer;
|
|
125
80
|
|
|
126
|
-
export { disableHWAccForWin7, getPathFromAppNameAsar,
|
|
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 };
|