electron-incremental-update 0.8.4 → 0.8.6
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 +240 -234
- package/dist/{chunk-GXZSAUBR.mjs → chunk-5BZLJPHJ.mjs} +8 -1
- package/dist/chunk-CMBFI77K.mjs +75 -0
- package/dist/chunk-MFFH2NRM.mjs +118 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +42 -41
- package/dist/index.mjs +17 -19
- package/dist/{updateJson.d.mts → updateJson-7e45d9e1.d.ts} +1 -2
- package/dist/utils.d.mts +31 -16
- package/dist/utils.d.ts +31 -16
- package/dist/utils.js +76 -71
- package/dist/utils.mjs +13 -10
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +20 -22
- package/dist/vite.mjs +16 -16
- package/package.json +10 -9
- package/dist/chunk-2JVXVTC5.mjs +0 -9
- package/dist/chunk-CR6HTU6P.mjs +0 -170
- package/dist/chunk-ZFXKCRJC.mjs +0 -11
- package/dist/updateJson.d.ts +0 -12
- package/dist/updateJson.js +0 -33
- package/dist/updateJson.mjs +0 -7
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__require
|
|
3
|
+
} from "./chunk-CMBFI77K.mjs";
|
|
4
|
+
|
|
5
|
+
// src/utils/core.ts
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
import { release } from "node:os";
|
|
9
|
+
import { app } from "electron";
|
|
10
|
+
function getAppInfo() {
|
|
11
|
+
return {
|
|
12
|
+
dev: !app.isPackaged,
|
|
13
|
+
win: process.platform === "win32",
|
|
14
|
+
mac: process.platform === "darwin",
|
|
15
|
+
linux: process.platform === "linux",
|
|
16
|
+
electronVersion: getElectronVersion(),
|
|
17
|
+
system: release(),
|
|
18
|
+
locale: app.isReady() ? app.getLocale() : void 0
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function getProductAsarPath(name) {
|
|
22
|
+
return !app.isPackaged ? "DEV.asar" : join(dirname(app.getAppPath()), `${name}.asar`);
|
|
23
|
+
}
|
|
24
|
+
function getElectronVersion() {
|
|
25
|
+
return app.getVersion();
|
|
26
|
+
}
|
|
27
|
+
function getAppVersion(name) {
|
|
28
|
+
return app.isPackaged ? readFileSync(join(getProductAsarPath(name), "version"), "utf-8") : getElectronVersion();
|
|
29
|
+
}
|
|
30
|
+
var NoSuchNativeModuleError = class extends Error {
|
|
31
|
+
moduleName;
|
|
32
|
+
constructor(moduleName) {
|
|
33
|
+
super(`no such native module: ${moduleName}`);
|
|
34
|
+
this.moduleName = moduleName;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function isNoSuchNativeModuleError(e) {
|
|
38
|
+
return e instanceof NoSuchNativeModuleError;
|
|
39
|
+
}
|
|
40
|
+
function requireNative(packageName) {
|
|
41
|
+
const path = app.isPackaged ? join(app.getAppPath(), "node_modules", packageName) : packageName;
|
|
42
|
+
try {
|
|
43
|
+
return __require(path);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
return new NoSuchNativeModuleError(packageName);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function parseGithubCdnURL(repository, cdnPrefix, relativeFilePath) {
|
|
49
|
+
if (!repository.startsWith("https://github.com/")) {
|
|
50
|
+
throw new Error("url must start with https://github.com/");
|
|
51
|
+
}
|
|
52
|
+
repository = repository.trim().replace(/\/?$/, "/").trim();
|
|
53
|
+
relativeFilePath = relativeFilePath.trim().replace(/^\/|\/?$/g, "").trim();
|
|
54
|
+
cdnPrefix = cdnPrefix.trim().replace(/^\/?|\/?$/g, "").trim();
|
|
55
|
+
return repository.replace("github.com", cdnPrefix) + relativeFilePath;
|
|
56
|
+
}
|
|
57
|
+
function getGithubFileCdnGroup() {
|
|
58
|
+
return [
|
|
59
|
+
{ cdnPrefix: "cdn.jsdelivr.net/gh", source: "jsdelivr" },
|
|
60
|
+
{ cdnPrefix: "fastly.jsdelivr.net/gh", source: "jsdelivr-fastly" },
|
|
61
|
+
{ cdnPrefix: "cdn.statically.io/gh", source: "statically" },
|
|
62
|
+
{ cdnPrefix: "rawcdn.githack.com/gh", source: "githack" },
|
|
63
|
+
{ cdnPrefix: "raw.githack.com/gh", source: "githack-dev" }
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
function getGithubReleaseCdnGroup() {
|
|
67
|
+
return [
|
|
68
|
+
{ cdnPrefix: "gh.gh2233.ml", source: "@X.I.U/XIU2" },
|
|
69
|
+
{ cdnPrefix: "ghproxy.com", source: "gh-proxy" },
|
|
70
|
+
{ cdnPrefix: "gh.ddlc.top", source: "@mtr-static-official" },
|
|
71
|
+
{ cdnPrefix: "ghdl.feizhuqwq.cf", source: "feizhuqwq.com" },
|
|
72
|
+
{ cdnPrefix: "slink.ltd", source: "\u77E5\u4E86\u5C0F\u7AD9" },
|
|
73
|
+
{ cdnPrefix: "git.xfj0.cn", source: "anonymous1" },
|
|
74
|
+
{ cdnPrefix: "gh.con.sh", source: "anonymous2" },
|
|
75
|
+
{ cdnPrefix: "ghps.cc", source: "anonymous3" },
|
|
76
|
+
{ cdnPrefix: "cors.isteed.cc/github.com", source: "Lufs's" },
|
|
77
|
+
{ cdnPrefix: "hub.gitmirror.com", source: "GitMirror" },
|
|
78
|
+
{ cdnPrefix: "js.xxooo.ml", source: "\u996D\u592A\u786C" },
|
|
79
|
+
{ cdnPrefix: "download.njuu.cf", source: "LibraryCloud-njuu" },
|
|
80
|
+
{ cdnPrefix: "download.yzuu.cf", source: "LibraryCloud-yzuu" },
|
|
81
|
+
{ cdnPrefix: "download.nuaa.cf", source: "LibraryCloud-nuaa" }
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
function restartApp() {
|
|
85
|
+
app.relaunch();
|
|
86
|
+
app.quit();
|
|
87
|
+
}
|
|
88
|
+
function waitAppReady(duration = 1e3) {
|
|
89
|
+
return new Promise((resolve, reject) => {
|
|
90
|
+
const timeout = setTimeout(() => {
|
|
91
|
+
reject(new Error("app is not ready"));
|
|
92
|
+
}, duration);
|
|
93
|
+
app.whenReady().then(() => {
|
|
94
|
+
clearTimeout(timeout);
|
|
95
|
+
resolve();
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function handleUnexpectedErrors(callback) {
|
|
100
|
+
process.on("uncaughtException", callback);
|
|
101
|
+
process.on("unhandledRejection", callback);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
getAppInfo,
|
|
106
|
+
getProductAsarPath,
|
|
107
|
+
getElectronVersion,
|
|
108
|
+
getAppVersion,
|
|
109
|
+
NoSuchNativeModuleError,
|
|
110
|
+
isNoSuchNativeModuleError,
|
|
111
|
+
requireNative,
|
|
112
|
+
parseGithubCdnURL,
|
|
113
|
+
getGithubFileCdnGroup,
|
|
114
|
+
getGithubReleaseCdnGroup,
|
|
115
|
+
restartApp,
|
|
116
|
+
waitAppReady,
|
|
117
|
+
handleUnexpectedErrors
|
|
118
|
+
};
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -36,59 +36,40 @@ __export(src_exports, {
|
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(src_exports);
|
|
38
38
|
var import_node_path2 = require("path");
|
|
39
|
-
var
|
|
39
|
+
var import_node_fs4 = require("fs");
|
|
40
40
|
var import_electron3 = __toESM(require("electron"));
|
|
41
41
|
|
|
42
42
|
// src/updater/index.ts
|
|
43
|
-
var
|
|
43
|
+
var import_node_fs3 = require("fs");
|
|
44
44
|
var import_promises = require("fs/promises");
|
|
45
45
|
|
|
46
|
-
// src/utils.ts
|
|
46
|
+
// src/utils/core.ts
|
|
47
47
|
var import_node_fs = require("fs");
|
|
48
48
|
var import_node_path = require("path");
|
|
49
|
-
var
|
|
50
|
-
var import_electron =
|
|
51
|
-
var info = {
|
|
52
|
-
dev: !import_electron.default.app?.isPackaged,
|
|
53
|
-
platform: process.platform === "win32" ? "win" : process.platform === "darwin" ? "mac" : "linux",
|
|
54
|
-
appPath: import_electron.default.app?.getAppPath()
|
|
55
|
-
};
|
|
49
|
+
var import_node_os = require("os");
|
|
50
|
+
var import_electron = require("electron");
|
|
56
51
|
function getProductAsarPath(name) {
|
|
57
|
-
return
|
|
52
|
+
return !import_electron.app.isPackaged ? "DEV.asar" : (0, import_node_path.join)((0, import_node_path.dirname)(import_electron.app.getAppPath()), `${name}.asar`);
|
|
58
53
|
}
|
|
59
|
-
function
|
|
60
|
-
return import_electron.
|
|
54
|
+
function getElectronVersion() {
|
|
55
|
+
return import_electron.app.getVersion();
|
|
61
56
|
}
|
|
62
|
-
function
|
|
63
|
-
return
|
|
57
|
+
function getAppVersion(name) {
|
|
58
|
+
return import_electron.app.isPackaged ? (0, import_node_fs.readFileSync)((0, import_node_path.join)(getProductAsarPath(name), "version"), "utf-8") : getElectronVersion();
|
|
64
59
|
}
|
|
65
60
|
function waitAppReady(duration = 1e3) {
|
|
66
61
|
return new Promise((resolve2, reject) => {
|
|
67
62
|
const timeout = setTimeout(() => {
|
|
68
63
|
reject(new Error("app is not ready"));
|
|
69
64
|
}, duration);
|
|
70
|
-
import_electron.
|
|
65
|
+
import_electron.app.whenReady().then(() => {
|
|
71
66
|
clearTimeout(timeout);
|
|
72
67
|
resolve2();
|
|
73
68
|
});
|
|
74
69
|
});
|
|
75
70
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
throw new Error(`path to zipped file not exist: ${gzipPath}`);
|
|
79
|
-
}
|
|
80
|
-
const compressedBuffer = (0, import_node_fs.readFileSync)(gzipPath);
|
|
81
|
-
return new Promise((resolve2, reject) => {
|
|
82
|
-
(0, import_node_zlib.gunzip)(compressedBuffer, (err, buffer) => {
|
|
83
|
-
(0, import_node_fs.rmSync)(gzipPath);
|
|
84
|
-
if (err) {
|
|
85
|
-
reject(err);
|
|
86
|
-
}
|
|
87
|
-
(0, import_node_fs.writeFileSync)(targetFilePath, buffer);
|
|
88
|
-
resolve2(null);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
}
|
|
71
|
+
|
|
72
|
+
// src/utils/version.ts
|
|
92
73
|
function parseVersion(version) {
|
|
93
74
|
const semver = /^(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z0-9\.-]+))?/i;
|
|
94
75
|
const match = semver.exec(version);
|
|
@@ -114,6 +95,26 @@ function parseVersion(version) {
|
|
|
114
95
|
return ret;
|
|
115
96
|
}
|
|
116
97
|
|
|
98
|
+
// src/utils/zip.ts
|
|
99
|
+
var import_node_fs2 = require("fs");
|
|
100
|
+
var import_node_zlib = require("zlib");
|
|
101
|
+
async function unzipFile(gzipPath, targetFilePath = gzipPath.slice(0, -3)) {
|
|
102
|
+
if (!(0, import_node_fs2.existsSync)(gzipPath)) {
|
|
103
|
+
throw new Error(`path to zipped file not exist: ${gzipPath}`);
|
|
104
|
+
}
|
|
105
|
+
const compressedBuffer = (0, import_node_fs2.readFileSync)(gzipPath);
|
|
106
|
+
return new Promise((resolve2, reject) => {
|
|
107
|
+
(0, import_node_zlib.gunzip)(compressedBuffer, (err, buffer) => {
|
|
108
|
+
(0, import_node_fs2.rmSync)(gzipPath);
|
|
109
|
+
if (err) {
|
|
110
|
+
reject(err);
|
|
111
|
+
}
|
|
112
|
+
(0, import_node_fs2.writeFileSync)(targetFilePath, buffer);
|
|
113
|
+
resolve2(null);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
117
118
|
// src/crypto.ts
|
|
118
119
|
var import_node_crypto = require("crypto");
|
|
119
120
|
function decrypt(encryptedText, key2, iv) {
|
|
@@ -168,11 +169,11 @@ var DownloadError = class extends Error {
|
|
|
168
169
|
};
|
|
169
170
|
|
|
170
171
|
// src/updater/defaultFunctions.ts
|
|
171
|
-
var import_electron2 =
|
|
172
|
+
var import_electron2 = require("electron");
|
|
172
173
|
var downloadJSONDefault = async (url, headers) => {
|
|
173
174
|
await waitAppReady();
|
|
174
175
|
return new Promise((resolve2, reject) => {
|
|
175
|
-
const request = import_electron2.
|
|
176
|
+
const request = import_electron2.net.request({
|
|
176
177
|
url,
|
|
177
178
|
method: "GET",
|
|
178
179
|
redirect: "follow"
|
|
@@ -206,7 +207,7 @@ var downloadBufferDefault = async (url, headers, total, onDownloading) => {
|
|
|
206
207
|
await waitAppReady();
|
|
207
208
|
let current = 0;
|
|
208
209
|
return new Promise((resolve2, reject) => {
|
|
209
|
-
const request = import_electron2.
|
|
210
|
+
const request = import_electron2.net.request({
|
|
210
211
|
url,
|
|
211
212
|
method: "GET",
|
|
212
213
|
redirect: "follow"
|
|
@@ -284,8 +285,8 @@ var IncrementalUpdater = class {
|
|
|
284
285
|
}
|
|
285
286
|
async needUpdate(version, minVersion) {
|
|
286
287
|
const compare = this.option.overrideFunctions?.compareVersion ?? compareVersionDefault;
|
|
287
|
-
const productVersion =
|
|
288
|
-
const entryVersion =
|
|
288
|
+
const productVersion = getAppVersion(this.option.productName);
|
|
289
|
+
const entryVersion = getElectronVersion();
|
|
289
290
|
if (await compare(entryVersion, minVersion)) {
|
|
290
291
|
throw new MinimumVersionError(entryVersion, minVersion);
|
|
291
292
|
}
|
|
@@ -293,11 +294,11 @@ var IncrementalUpdater = class {
|
|
|
293
294
|
return await compare(productVersion, version);
|
|
294
295
|
}
|
|
295
296
|
async parseData(format, data) {
|
|
296
|
-
if ((0,
|
|
297
|
+
if ((0, import_node_fs3.existsSync)(this.tmpFilePath)) {
|
|
297
298
|
this.logger?.warn(`remove tmp file: ${this.tmpFilePath}`);
|
|
298
299
|
await (0, import_promises.rm)(this.tmpFilePath);
|
|
299
300
|
}
|
|
300
|
-
if ((0,
|
|
301
|
+
if ((0, import_node_fs3.existsSync)(this.gzipPath)) {
|
|
301
302
|
this.logger?.warn(`remove .gz file: ${this.gzipPath}`);
|
|
302
303
|
await (0, import_promises.rm)(this.gzipPath);
|
|
303
304
|
}
|
|
@@ -427,9 +428,9 @@ function initApp(appOptions) {
|
|
|
427
428
|
try {
|
|
428
429
|
const asarPath = getProductAsarPath(updater.productName);
|
|
429
430
|
const updateAsarPath = `${asarPath}.tmp`;
|
|
430
|
-
if ((0,
|
|
431
|
+
if ((0, import_node_fs4.existsSync)(updateAsarPath)) {
|
|
431
432
|
await beforeDoUpdate?.(asarPath, updateAsarPath);
|
|
432
|
-
(0,
|
|
433
|
+
(0, import_node_fs4.renameSync)(updateAsarPath, asarPath);
|
|
433
434
|
}
|
|
434
435
|
const mainDir = import_electron3.default.app.isPackaged ? asarPath : electronDevDistPath;
|
|
435
436
|
const entry = (0, import_node_path2.resolve)(__dirname, mainDir, mainPath);
|
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
|
+
isUpdateJSON,
|
|
2
3
|
verify
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5BZLJPHJ.mjs";
|
|
4
5
|
import {
|
|
5
|
-
|
|
6
|
+
getAppVersion,
|
|
7
|
+
getElectronVersion,
|
|
6
8
|
getProductAsarPath,
|
|
7
|
-
getProductVersion,
|
|
8
|
-
parseVersion,
|
|
9
|
-
unzipFile,
|
|
10
9
|
waitAppReady
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import {
|
|
13
|
-
isUpdateJSON
|
|
14
|
-
} from "./chunk-2JVXVTC5.mjs";
|
|
10
|
+
} from "./chunk-MFFH2NRM.mjs";
|
|
15
11
|
import {
|
|
16
|
-
__require
|
|
17
|
-
|
|
12
|
+
__require,
|
|
13
|
+
parseVersion,
|
|
14
|
+
unzipFile
|
|
15
|
+
} from "./chunk-CMBFI77K.mjs";
|
|
18
16
|
|
|
19
17
|
// src/index.ts
|
|
20
18
|
import { resolve } from "node:path";
|
|
21
19
|
import { existsSync as existsSync2, renameSync } from "node:fs";
|
|
22
|
-
import
|
|
20
|
+
import Electron from "electron";
|
|
23
21
|
|
|
24
22
|
// src/updater/index.ts
|
|
25
23
|
import { existsSync } from "node:fs";
|
|
@@ -51,11 +49,11 @@ var DownloadError = class extends Error {
|
|
|
51
49
|
};
|
|
52
50
|
|
|
53
51
|
// src/updater/defaultFunctions.ts
|
|
54
|
-
import
|
|
52
|
+
import { net } from "electron";
|
|
55
53
|
var downloadJSONDefault = async (url, headers) => {
|
|
56
54
|
await waitAppReady();
|
|
57
55
|
return new Promise((resolve2, reject) => {
|
|
58
|
-
const request =
|
|
56
|
+
const request = net.request({
|
|
59
57
|
url,
|
|
60
58
|
method: "GET",
|
|
61
59
|
redirect: "follow"
|
|
@@ -89,7 +87,7 @@ var downloadBufferDefault = async (url, headers, total, onDownloading) => {
|
|
|
89
87
|
await waitAppReady();
|
|
90
88
|
let current = 0;
|
|
91
89
|
return new Promise((resolve2, reject) => {
|
|
92
|
-
const request =
|
|
90
|
+
const request = net.request({
|
|
93
91
|
url,
|
|
94
92
|
method: "GET",
|
|
95
93
|
redirect: "follow"
|
|
@@ -167,8 +165,8 @@ var IncrementalUpdater = class {
|
|
|
167
165
|
}
|
|
168
166
|
async needUpdate(version, minVersion) {
|
|
169
167
|
const compare = this.option.overrideFunctions?.compareVersion ?? compareVersionDefault;
|
|
170
|
-
const productVersion =
|
|
171
|
-
const entryVersion =
|
|
168
|
+
const productVersion = getAppVersion(this.option.productName);
|
|
169
|
+
const entryVersion = getElectronVersion();
|
|
172
170
|
if (await compare(entryVersion, minVersion)) {
|
|
173
171
|
throw new MinimumVersionError(entryVersion, minVersion);
|
|
174
172
|
}
|
|
@@ -304,7 +302,7 @@ function initApp(appOptions) {
|
|
|
304
302
|
} = hooks || {};
|
|
305
303
|
function handleError(msg) {
|
|
306
304
|
onStartError?.(new Error(msg));
|
|
307
|
-
|
|
305
|
+
Electron.app.quit();
|
|
308
306
|
}
|
|
309
307
|
async function startup(updater) {
|
|
310
308
|
try {
|
|
@@ -314,7 +312,7 @@ function initApp(appOptions) {
|
|
|
314
312
|
await beforeDoUpdate?.(asarPath, updateAsarPath);
|
|
315
313
|
renameSync(updateAsarPath, asarPath);
|
|
316
314
|
}
|
|
317
|
-
const mainDir =
|
|
315
|
+
const mainDir = Electron.app.isPackaged ? asarPath : electronDevDistPath;
|
|
318
316
|
const entry = resolve(__dirname, mainDir, mainPath);
|
|
319
317
|
await beforeStart?.(entry);
|
|
320
318
|
__require(entry)(updater);
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,36 +1,49 @@
|
|
|
1
1
|
type Info = {
|
|
2
2
|
dev: boolean;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
win: boolean;
|
|
4
|
+
mac: boolean;
|
|
5
|
+
linux: boolean;
|
|
6
|
+
electronVersion: string;
|
|
7
|
+
/**
|
|
8
|
+
* `os.release()`
|
|
9
|
+
*/
|
|
10
|
+
system: string;
|
|
11
|
+
/**
|
|
12
|
+
* system locale, `undefined` when `!app.isReady()`
|
|
13
|
+
*/
|
|
14
|
+
locale: string | undefined;
|
|
5
15
|
};
|
|
6
|
-
declare const info: Info;
|
|
7
16
|
/**
|
|
8
|
-
* get
|
|
17
|
+
* get app info
|
|
18
|
+
*/
|
|
19
|
+
declare function getAppInfo(): Info;
|
|
20
|
+
/**
|
|
21
|
+
* get the application asar absolute path (not `app.asar`),
|
|
22
|
+
* if is in dev, return `'DEV.asar'`
|
|
9
23
|
* @param name The name of the application
|
|
10
|
-
* @todo support v8 bytecode
|
|
11
24
|
*/
|
|
12
25
|
declare function getProductAsarPath(name: string): string;
|
|
13
26
|
/**
|
|
14
|
-
* get the version of
|
|
27
|
+
* get the version of Electron runtime
|
|
15
28
|
*/
|
|
16
|
-
declare function
|
|
29
|
+
declare function getElectronVersion(): string;
|
|
17
30
|
/**
|
|
18
31
|
* get the version of application (name.asar)
|
|
19
32
|
*
|
|
20
|
-
* if is dev, return {@link
|
|
33
|
+
* if is dev, return {@link getElectronVersion}
|
|
21
34
|
* @param name - The name of the application
|
|
22
35
|
*/
|
|
23
|
-
declare function
|
|
36
|
+
declare function getAppVersion(name: string): string;
|
|
24
37
|
declare class NoSuchNativeModuleError extends Error {
|
|
25
38
|
moduleName: string;
|
|
26
39
|
constructor(moduleName: string);
|
|
27
40
|
}
|
|
41
|
+
declare function isNoSuchNativeModuleError(e: unknown): e is NoSuchNativeModuleError;
|
|
28
42
|
/**
|
|
29
|
-
* require native package
|
|
43
|
+
* require native package, if not found, return {@link NoSuchNativeModuleError}
|
|
30
44
|
* @param packageName native package name
|
|
31
|
-
* @throws error: {@link NoSuchNativeModuleError}
|
|
32
45
|
*/
|
|
33
|
-
declare function requireNative<T = any>(packageName: string): T;
|
|
46
|
+
declare function requireNative<T = any>(packageName: string): T | NoSuchNativeModuleError;
|
|
34
47
|
/**
|
|
35
48
|
* parse Github CDN URL for accelerating the speed of downloading
|
|
36
49
|
*/
|
|
@@ -57,9 +70,8 @@ declare function restartApp(): void;
|
|
|
57
70
|
* ensure app is ready.
|
|
58
71
|
*/
|
|
59
72
|
declare function waitAppReady(duration?: number): Promise<void>;
|
|
60
|
-
declare function
|
|
61
|
-
|
|
62
|
-
declare function handleUnexpectedErrors(callback: (err: Error) => void): void;
|
|
73
|
+
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
74
|
+
|
|
63
75
|
interface Version {
|
|
64
76
|
major: number;
|
|
65
77
|
minor: number;
|
|
@@ -69,4 +81,7 @@ interface Version {
|
|
|
69
81
|
}
|
|
70
82
|
declare function parseVersion(version: string): Version;
|
|
71
83
|
|
|
72
|
-
|
|
84
|
+
declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
|
|
85
|
+
declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
|
|
86
|
+
|
|
87
|
+
export { NoSuchNativeModuleError, Version, getAppInfo, getAppVersion, getElectronVersion, getGithubFileCdnGroup, getGithubReleaseCdnGroup, getProductAsarPath, handleUnexpectedErrors, isNoSuchNativeModuleError, parseGithubCdnURL, parseVersion, requireNative, restartApp, unzipFile, waitAppReady, zipFile };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,36 +1,49 @@
|
|
|
1
1
|
type Info = {
|
|
2
2
|
dev: boolean;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
win: boolean;
|
|
4
|
+
mac: boolean;
|
|
5
|
+
linux: boolean;
|
|
6
|
+
electronVersion: string;
|
|
7
|
+
/**
|
|
8
|
+
* `os.release()`
|
|
9
|
+
*/
|
|
10
|
+
system: string;
|
|
11
|
+
/**
|
|
12
|
+
* system locale, `undefined` when `!app.isReady()`
|
|
13
|
+
*/
|
|
14
|
+
locale: string | undefined;
|
|
5
15
|
};
|
|
6
|
-
declare const info: Info;
|
|
7
16
|
/**
|
|
8
|
-
* get
|
|
17
|
+
* get app info
|
|
18
|
+
*/
|
|
19
|
+
declare function getAppInfo(): Info;
|
|
20
|
+
/**
|
|
21
|
+
* get the application asar absolute path (not `app.asar`),
|
|
22
|
+
* if is in dev, return `'DEV.asar'`
|
|
9
23
|
* @param name The name of the application
|
|
10
|
-
* @todo support v8 bytecode
|
|
11
24
|
*/
|
|
12
25
|
declare function getProductAsarPath(name: string): string;
|
|
13
26
|
/**
|
|
14
|
-
* get the version of
|
|
27
|
+
* get the version of Electron runtime
|
|
15
28
|
*/
|
|
16
|
-
declare function
|
|
29
|
+
declare function getElectronVersion(): string;
|
|
17
30
|
/**
|
|
18
31
|
* get the version of application (name.asar)
|
|
19
32
|
*
|
|
20
|
-
* if is dev, return {@link
|
|
33
|
+
* if is dev, return {@link getElectronVersion}
|
|
21
34
|
* @param name - The name of the application
|
|
22
35
|
*/
|
|
23
|
-
declare function
|
|
36
|
+
declare function getAppVersion(name: string): string;
|
|
24
37
|
declare class NoSuchNativeModuleError extends Error {
|
|
25
38
|
moduleName: string;
|
|
26
39
|
constructor(moduleName: string);
|
|
27
40
|
}
|
|
41
|
+
declare function isNoSuchNativeModuleError(e: unknown): e is NoSuchNativeModuleError;
|
|
28
42
|
/**
|
|
29
|
-
* require native package
|
|
43
|
+
* require native package, if not found, return {@link NoSuchNativeModuleError}
|
|
30
44
|
* @param packageName native package name
|
|
31
|
-
* @throws error: {@link NoSuchNativeModuleError}
|
|
32
45
|
*/
|
|
33
|
-
declare function requireNative<T = any>(packageName: string): T;
|
|
46
|
+
declare function requireNative<T = any>(packageName: string): T | NoSuchNativeModuleError;
|
|
34
47
|
/**
|
|
35
48
|
* parse Github CDN URL for accelerating the speed of downloading
|
|
36
49
|
*/
|
|
@@ -57,9 +70,8 @@ declare function restartApp(): void;
|
|
|
57
70
|
* ensure app is ready.
|
|
58
71
|
*/
|
|
59
72
|
declare function waitAppReady(duration?: number): Promise<void>;
|
|
60
|
-
declare function
|
|
61
|
-
|
|
62
|
-
declare function handleUnexpectedErrors(callback: (err: Error) => void): void;
|
|
73
|
+
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
74
|
+
|
|
63
75
|
interface Version {
|
|
64
76
|
major: number;
|
|
65
77
|
minor: number;
|
|
@@ -69,4 +81,7 @@ interface Version {
|
|
|
69
81
|
}
|
|
70
82
|
declare function parseVersion(version: string): Version;
|
|
71
83
|
|
|
72
|
-
|
|
84
|
+
declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
|
|
85
|
+
declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
|
|
86
|
+
|
|
87
|
+
export { NoSuchNativeModuleError, Version, getAppInfo, getAppVersion, getElectronVersion, getGithubFileCdnGroup, getGithubReleaseCdnGroup, getProductAsarPath, handleUnexpectedErrors, isNoSuchNativeModuleError, parseGithubCdnURL, parseVersion, requireNative, restartApp, unzipFile, waitAppReady, zipFile };
|