electron-incremental-update 2.0.0-beta.9 → 2.0.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 +326 -198
- package/dist/chunk-GTDMND3I.js +87 -0
- package/dist/{chunk-72ZAJ7AF.js → chunk-RCRKUKFX.js} +1 -1
- package/dist/index.cjs +91 -71
- package/dist/index.d.cts +64 -80
- package/dist/index.d.ts +64 -80
- package/dist/index.js +88 -70
- package/dist/provider.cjs +72 -52
- package/dist/provider.d.cts +47 -30
- package/dist/provider.d.ts +47 -30
- package/dist/provider.js +72 -53
- package/dist/{types-D7OK98ln.d.ts → types-BLdN9rkY.d.ts} +20 -27
- package/dist/{types-mEfMjnlV.d.cts → types-DkCn03M3.d.cts} +20 -27
- package/dist/utils.cjs +25 -17
- package/dist/utils.d.cts +37 -16
- package/dist/utils.d.ts +37 -16
- package/dist/utils.js +2 -2
- package/dist/version-BYVQ367i.d.cts +62 -0
- package/dist/version-BYVQ367i.d.ts +62 -0
- package/dist/vite.d.ts +62 -94
- package/dist/vite.js +61 -43
- package/dist/{zip-DPF5IFkK.d.ts → zip-rm9ED9nU.d.cts} +23 -0
- package/dist/{zip-DPF5IFkK.d.cts → zip-rm9ED9nU.d.ts} +23 -0
- package/package.json +10 -7
- package/dist/chunk-4MH6ZXCY.js +0 -81
- package/dist/version-DgfjJQUx.d.cts +0 -27
- package/dist/version-DgfjJQUx.d.ts +0 -27
|
@@ -1,79 +1,72 @@
|
|
|
1
1
|
import { Promisable } from '@subframe7536/type-utils';
|
|
2
|
-
import {
|
|
2
|
+
import { a as UpdateJSON, U as UpdateInfo } from './version-BYVQ367i.js';
|
|
3
3
|
|
|
4
|
-
type URLHandler = (url: URL, isDownloadAsar: boolean) => Promisable<URL | string | undefined | null>;
|
|
5
4
|
type OnDownloading = (progress: DownloadingInfo) => void;
|
|
6
5
|
interface DownloadingInfo {
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* Download buffer delta
|
|
9
8
|
*/
|
|
10
9
|
delta: number;
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
11
|
+
* Downloaded percent, 0 ~ 100
|
|
13
12
|
*
|
|
14
|
-
* If
|
|
13
|
+
* If no `Content-Length` header, will be -1
|
|
15
14
|
*/
|
|
16
15
|
percent: number;
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
17
|
+
* Total size
|
|
19
18
|
*
|
|
20
19
|
* If not `Content-Length` header, will be -1
|
|
21
20
|
*/
|
|
22
21
|
total: number;
|
|
23
22
|
/**
|
|
24
|
-
*
|
|
23
|
+
* Downloaded size
|
|
25
24
|
*/
|
|
26
25
|
transferred: number;
|
|
27
26
|
/**
|
|
28
|
-
*
|
|
27
|
+
* Download speed, bytes per second
|
|
29
28
|
*/
|
|
30
29
|
bps: number;
|
|
31
30
|
}
|
|
32
31
|
interface IProvider {
|
|
33
32
|
/**
|
|
34
|
-
*
|
|
33
|
+
* Provider name
|
|
35
34
|
*/
|
|
36
35
|
name: string;
|
|
37
36
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* for Github, there are some {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 public CDN links}
|
|
41
|
-
*/
|
|
42
|
-
urlHandler?: URLHandler;
|
|
43
|
-
onDownloading?: OnDownloading;
|
|
44
|
-
/**
|
|
45
|
-
* download update json
|
|
37
|
+
* Download update json
|
|
46
38
|
* @param versionPath parsed version path in project
|
|
39
|
+
* @param signal abort signal
|
|
47
40
|
*/
|
|
48
|
-
downloadJSON: (versionPath: string) => Promise<UpdateJSON>;
|
|
41
|
+
downloadJSON: (versionPath: string, signal: AbortSignal) => Promise<UpdateJSON>;
|
|
49
42
|
/**
|
|
50
|
-
*
|
|
43
|
+
* Download update asar
|
|
51
44
|
* @param name app name
|
|
52
45
|
* @param updateInfo existing update info
|
|
46
|
+
* @param signal abort signal
|
|
53
47
|
* @param onDownloading hook for on downloading
|
|
54
48
|
*/
|
|
55
|
-
downloadAsar: (name: string, updateInfo: UpdateInfo, onDownloading?: (info: DownloadingInfo) => void) => Promise<Buffer>;
|
|
49
|
+
downloadAsar: (name: string, updateInfo: UpdateInfo, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void) => Promise<Buffer>;
|
|
56
50
|
/**
|
|
57
|
-
*
|
|
51
|
+
* Check the old version is less than new version
|
|
58
52
|
* @param oldVer old version string
|
|
59
53
|
* @param newVer new version string
|
|
60
|
-
* @returns if version1 < version2
|
|
61
54
|
*/
|
|
62
55
|
isLowerVersion: (oldVer: string, newVer: string) => boolean;
|
|
63
56
|
/**
|
|
64
|
-
*
|
|
65
|
-
* @param buffer
|
|
57
|
+
* Function to decompress file using brotli
|
|
58
|
+
* @param buffer compressed file buffer
|
|
66
59
|
*/
|
|
67
60
|
unzipFile: (buffer: Buffer) => Promise<Buffer>;
|
|
68
61
|
/**
|
|
69
|
-
*
|
|
62
|
+
* Verify asar signature,
|
|
63
|
+
* if signature is valid, returns the version, otherwise returns `undefined`
|
|
70
64
|
* @param buffer file buffer
|
|
71
65
|
* @param version target version
|
|
72
66
|
* @param signature signature
|
|
73
67
|
* @param cert certificate
|
|
74
|
-
* @returns if signature is valid, returns the version, otherwise returns `undefined`
|
|
75
68
|
*/
|
|
76
69
|
verifySignaure: (buffer: Buffer, version: string, signature: string, cert: string) => Promisable<boolean>;
|
|
77
70
|
}
|
|
78
71
|
|
|
79
|
-
export type { DownloadingInfo as D, IProvider as I, OnDownloading as O
|
|
72
|
+
export type { DownloadingInfo as D, IProvider as I, OnDownloading as O };
|
|
@@ -1,79 +1,72 @@
|
|
|
1
1
|
import { Promisable } from '@subframe7536/type-utils';
|
|
2
|
-
import {
|
|
2
|
+
import { a as UpdateJSON, U as UpdateInfo } from './version-BYVQ367i.cjs';
|
|
3
3
|
|
|
4
|
-
type URLHandler = (url: URL, isDownloadAsar: boolean) => Promisable<URL | string | undefined | null>;
|
|
5
4
|
type OnDownloading = (progress: DownloadingInfo) => void;
|
|
6
5
|
interface DownloadingInfo {
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* Download buffer delta
|
|
9
8
|
*/
|
|
10
9
|
delta: number;
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
11
|
+
* Downloaded percent, 0 ~ 100
|
|
13
12
|
*
|
|
14
|
-
* If
|
|
13
|
+
* If no `Content-Length` header, will be -1
|
|
15
14
|
*/
|
|
16
15
|
percent: number;
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
17
|
+
* Total size
|
|
19
18
|
*
|
|
20
19
|
* If not `Content-Length` header, will be -1
|
|
21
20
|
*/
|
|
22
21
|
total: number;
|
|
23
22
|
/**
|
|
24
|
-
*
|
|
23
|
+
* Downloaded size
|
|
25
24
|
*/
|
|
26
25
|
transferred: number;
|
|
27
26
|
/**
|
|
28
|
-
*
|
|
27
|
+
* Download speed, bytes per second
|
|
29
28
|
*/
|
|
30
29
|
bps: number;
|
|
31
30
|
}
|
|
32
31
|
interface IProvider {
|
|
33
32
|
/**
|
|
34
|
-
*
|
|
33
|
+
* Provider name
|
|
35
34
|
*/
|
|
36
35
|
name: string;
|
|
37
36
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* for Github, there are some {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 public CDN links}
|
|
41
|
-
*/
|
|
42
|
-
urlHandler?: URLHandler;
|
|
43
|
-
onDownloading?: OnDownloading;
|
|
44
|
-
/**
|
|
45
|
-
* download update json
|
|
37
|
+
* Download update json
|
|
46
38
|
* @param versionPath parsed version path in project
|
|
39
|
+
* @param signal abort signal
|
|
47
40
|
*/
|
|
48
|
-
downloadJSON: (versionPath: string) => Promise<UpdateJSON>;
|
|
41
|
+
downloadJSON: (versionPath: string, signal: AbortSignal) => Promise<UpdateJSON>;
|
|
49
42
|
/**
|
|
50
|
-
*
|
|
43
|
+
* Download update asar
|
|
51
44
|
* @param name app name
|
|
52
45
|
* @param updateInfo existing update info
|
|
46
|
+
* @param signal abort signal
|
|
53
47
|
* @param onDownloading hook for on downloading
|
|
54
48
|
*/
|
|
55
|
-
downloadAsar: (name: string, updateInfo: UpdateInfo, onDownloading?: (info: DownloadingInfo) => void) => Promise<Buffer>;
|
|
49
|
+
downloadAsar: (name: string, updateInfo: UpdateInfo, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void) => Promise<Buffer>;
|
|
56
50
|
/**
|
|
57
|
-
*
|
|
51
|
+
* Check the old version is less than new version
|
|
58
52
|
* @param oldVer old version string
|
|
59
53
|
* @param newVer new version string
|
|
60
|
-
* @returns if version1 < version2
|
|
61
54
|
*/
|
|
62
55
|
isLowerVersion: (oldVer: string, newVer: string) => boolean;
|
|
63
56
|
/**
|
|
64
|
-
*
|
|
65
|
-
* @param buffer
|
|
57
|
+
* Function to decompress file using brotli
|
|
58
|
+
* @param buffer compressed file buffer
|
|
66
59
|
*/
|
|
67
60
|
unzipFile: (buffer: Buffer) => Promise<Buffer>;
|
|
68
61
|
/**
|
|
69
|
-
*
|
|
62
|
+
* Verify asar signature,
|
|
63
|
+
* if signature is valid, returns the version, otherwise returns `undefined`
|
|
70
64
|
* @param buffer file buffer
|
|
71
65
|
* @param version target version
|
|
72
66
|
* @param signature signature
|
|
73
67
|
* @param cert certificate
|
|
74
|
-
* @returns if signature is valid, returns the version, otherwise returns `undefined`
|
|
75
68
|
*/
|
|
76
69
|
verifySignaure: (buffer: Buffer, version: string, signature: string, cert: string) => Promisable<boolean>;
|
|
77
70
|
}
|
|
78
71
|
|
|
79
|
-
export type { DownloadingInfo as D, IProvider as I, OnDownloading as O
|
|
72
|
+
export type { DownloadingInfo as D, IProvider as I, OnDownloading as O };
|
package/dist/utils.cjs
CHANGED
|
@@ -10,6 +10,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
10
10
|
|
|
11
11
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
12
12
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
13
|
+
var electron__default = /*#__PURE__*/_interopDefault(electron);
|
|
13
14
|
var zlib__default = /*#__PURE__*/_interopDefault(zlib);
|
|
14
15
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
15
16
|
|
|
@@ -24,35 +25,38 @@ var isWin = process.platform === "win32";
|
|
|
24
25
|
var isMac = process.platform === "darwin";
|
|
25
26
|
var isLinux = process.platform === "linux";
|
|
26
27
|
function getPathFromAppNameAsar(...paths) {
|
|
27
|
-
return isDev ? "DEV.asar" : path__default.default.join(path__default.default.dirname(
|
|
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);
|
|
28
29
|
}
|
|
29
30
|
function getAppVersion() {
|
|
30
31
|
return isDev ? getEntryVersion() : fs__default.default.readFileSync(getPathFromAppNameAsar("version"), "utf-8");
|
|
31
32
|
}
|
|
32
33
|
function getEntryVersion() {
|
|
33
|
-
return
|
|
34
|
+
return electron__default.default.app.getVersion();
|
|
34
35
|
}
|
|
35
36
|
function requireNative(moduleName) {
|
|
36
|
-
|
|
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(getPathFromEntryAsar(moduleName));
|
|
37
41
|
}
|
|
38
42
|
function restartApp() {
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
electron__default.default.app.relaunch();
|
|
44
|
+
electron__default.default.app.quit();
|
|
41
45
|
}
|
|
42
46
|
function setAppUserModelId(id) {
|
|
43
47
|
if (isWin) {
|
|
44
|
-
|
|
48
|
+
electron__default.default.app.setAppUserModelId(id ?? `org.${electron__default.default.app.name}`);
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
function disableHWAccForWin7() {
|
|
48
|
-
if (__require("os").release().startsWith("6.1")) {
|
|
49
|
-
|
|
52
|
+
if (!__EIU_IS_ESM__ && __require("os").release().startsWith("6.1")) {
|
|
53
|
+
electron__default.default.app.disableHardwareAcceleration();
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
function singleInstance(window) {
|
|
53
|
-
const result =
|
|
57
|
+
const result = electron__default.default.app.requestSingleInstanceLock();
|
|
54
58
|
if (result) {
|
|
55
|
-
|
|
59
|
+
electron__default.default.app.on("second-instance", () => {
|
|
56
60
|
if (window) {
|
|
57
61
|
window.show();
|
|
58
62
|
if (window.isMinimized()) {
|
|
@@ -62,16 +66,16 @@ function singleInstance(window) {
|
|
|
62
66
|
}
|
|
63
67
|
});
|
|
64
68
|
} else {
|
|
65
|
-
|
|
69
|
+
electron__default.default.app.quit();
|
|
66
70
|
}
|
|
67
71
|
return result;
|
|
68
72
|
}
|
|
69
73
|
function setPortableAppDataPath(dirName = "data") {
|
|
70
|
-
const portablePath = path__default.default.join(path__default.default.dirname(
|
|
74
|
+
const portablePath = path__default.default.join(path__default.default.dirname(electron__default.default.app.getPath("exe")), dirName);
|
|
71
75
|
if (!fs__default.default.existsSync(portablePath)) {
|
|
72
76
|
fs__default.default.mkdirSync(portablePath);
|
|
73
77
|
}
|
|
74
|
-
|
|
78
|
+
electron__default.default.app.setPath("appData", portablePath);
|
|
75
79
|
}
|
|
76
80
|
function loadPage(win, htmlFilePath = "index.html") {
|
|
77
81
|
if (isDev) {
|
|
@@ -80,14 +84,17 @@ function loadPage(win, htmlFilePath = "index.html") {
|
|
|
80
84
|
win.loadFile(getPathFromAppNameAsar("renderer", htmlFilePath));
|
|
81
85
|
}
|
|
82
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);
|
|
89
|
+
}
|
|
83
90
|
function getPathFromPreload(...paths) {
|
|
84
|
-
return isDev ? path__default.default.join(
|
|
91
|
+
return isDev ? path__default.default.join(electron__default.default.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "preload", ...paths) : getPathFromAppNameAsar("preload", ...paths);
|
|
85
92
|
}
|
|
86
93
|
function getPathFromPublic(...paths) {
|
|
87
|
-
return isDev ? path__default.default.join(
|
|
94
|
+
return isDev ? path__default.default.join(electron__default.default.app.getAppPath(), "public", ...paths) : getPathFromAppNameAsar("renderer", ...paths);
|
|
88
95
|
}
|
|
89
96
|
function getPathFromEntryAsar(...paths) {
|
|
90
|
-
return path__default.default.join(
|
|
97
|
+
return path__default.default.join(electron__default.default.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, ...paths);
|
|
91
98
|
}
|
|
92
99
|
function handleUnexpectedErrors(callback) {
|
|
93
100
|
process.on("uncaughtException", callback);
|
|
@@ -136,7 +143,7 @@ function parseVersion(version) {
|
|
|
136
143
|
ret.stageVersion = Number(_v) || -1;
|
|
137
144
|
}
|
|
138
145
|
if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch) || Number.isNaN(ret.stageVersion)) {
|
|
139
|
-
throw new TypeError(`
|
|
146
|
+
throw new TypeError(`Invalid version: ${version}`);
|
|
140
147
|
}
|
|
141
148
|
return ret;
|
|
142
149
|
}
|
|
@@ -218,6 +225,7 @@ exports.getAppVersion = getAppVersion;
|
|
|
218
225
|
exports.getEntryVersion = getEntryVersion;
|
|
219
226
|
exports.getPathFromAppNameAsar = getPathFromAppNameAsar;
|
|
220
227
|
exports.getPathFromEntryAsar = getPathFromEntryAsar;
|
|
228
|
+
exports.getPathFromMain = getPathFromMain;
|
|
221
229
|
exports.getPathFromPreload = getPathFromPreload;
|
|
222
230
|
exports.getPathFromPublic = getPathFromPublic;
|
|
223
231
|
exports.handleUnexpectedErrors = handleUnexpectedErrors;
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import { BrowserWindow } from 'electron';
|
|
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-
|
|
3
|
-
export {
|
|
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
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,40 +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
|
-
*
|
|
62
|
+
* Load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
|
|
59
63
|
* @param win window
|
|
60
64
|
* @param htmlFilePath html file path, default is `index.html`
|
|
61
65
|
*/
|
|
62
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
|
+
*/
|
|
63
76
|
declare function getPathFromPreload(...paths: string[]): string;
|
|
77
|
+
/**
|
|
78
|
+
* Get joined path from publich dir
|
|
79
|
+
* @param paths rest paths
|
|
80
|
+
*/
|
|
64
81
|
declare function getPathFromPublic(...paths: string[]): string;
|
|
82
|
+
/**
|
|
83
|
+
* Get joined path from entry asar
|
|
84
|
+
* @param paths rest paths
|
|
85
|
+
*/
|
|
65
86
|
declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
66
87
|
/**
|
|
67
|
-
*
|
|
88
|
+
* Handle all unhandled error
|
|
68
89
|
* @param callback callback function
|
|
69
90
|
*/
|
|
70
91
|
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
71
92
|
|
|
72
|
-
export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
|
|
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 { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerifySignature, d as defaultZipFile, h as hashBuffer } from './zip-
|
|
3
|
-
export {
|
|
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
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,40 +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
|
-
*
|
|
62
|
+
* Load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
|
|
59
63
|
* @param win window
|
|
60
64
|
* @param htmlFilePath html file path, default is `index.html`
|
|
61
65
|
*/
|
|
62
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
|
+
*/
|
|
63
76
|
declare function getPathFromPreload(...paths: string[]): string;
|
|
77
|
+
/**
|
|
78
|
+
* Get joined path from publich dir
|
|
79
|
+
* @param paths rest paths
|
|
80
|
+
*/
|
|
64
81
|
declare function getPathFromPublic(...paths: string[]): string;
|
|
82
|
+
/**
|
|
83
|
+
* Get joined path from entry asar
|
|
84
|
+
* @param paths rest paths
|
|
85
|
+
*/
|
|
65
86
|
declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
66
87
|
/**
|
|
67
|
-
*
|
|
88
|
+
* Handle all unhandled error
|
|
68
89
|
* @param callback callback function
|
|
69
90
|
*/
|
|
70
91
|
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
71
92
|
|
|
72
|
-
export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
|
|
93
|
+
export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromMain, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
|
package/dist/utils.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance } from './chunk-
|
|
1
|
+
export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromMain, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance } from './chunk-GTDMND3I.js';
|
|
2
2
|
export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultZipFile, hashBuffer } from './chunk-KZSYEXLO.js';
|
|
3
|
-
export { defaultIsLowerVersion, defaultVersionJsonGenerator, isUpdateJSON, parseVersion } from './chunk-
|
|
3
|
+
export { defaultIsLowerVersion, defaultVersionJsonGenerator, isUpdateJSON, parseVersion } from './chunk-RCRKUKFX.js';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
interface Version {
|
|
2
|
+
/**
|
|
3
|
+
* `4` of `4.3.2-beta.1`
|
|
4
|
+
*/
|
|
5
|
+
major: number;
|
|
6
|
+
/**
|
|
7
|
+
* `3` of `4.3.2-beta.1`
|
|
8
|
+
*/
|
|
9
|
+
minor: number;
|
|
10
|
+
/**
|
|
11
|
+
* `2` of `4.3.2-beta.1`
|
|
12
|
+
*/
|
|
13
|
+
patch: number;
|
|
14
|
+
/**
|
|
15
|
+
* `beta` of `4.3.2-beta.1`
|
|
16
|
+
*/
|
|
17
|
+
stage: string;
|
|
18
|
+
/**
|
|
19
|
+
* `1` of `4.3.2-beta.1`
|
|
20
|
+
*/
|
|
21
|
+
stageVersion: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parse version string to {@link Version}, like `0.2.0-beta.1`
|
|
25
|
+
* @param version version string
|
|
26
|
+
*/
|
|
27
|
+
declare function parseVersion(version: string): Version;
|
|
28
|
+
/**
|
|
29
|
+
* Default function to check the old version is less than new version
|
|
30
|
+
* @param oldVer old version string
|
|
31
|
+
* @param newVer new version string
|
|
32
|
+
*/
|
|
33
|
+
declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Update info json
|
|
36
|
+
*/
|
|
37
|
+
type UpdateInfo = {
|
|
38
|
+
signature: string;
|
|
39
|
+
minimumVersion: string;
|
|
40
|
+
version: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* {@link UpdateInfo} with beta
|
|
44
|
+
*/
|
|
45
|
+
type UpdateJSON = UpdateInfo & {
|
|
46
|
+
beta: UpdateInfo;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Check is `UpdateJSON`
|
|
50
|
+
* @param json any variable
|
|
51
|
+
*/
|
|
52
|
+
declare function isUpdateJSON(json: any): json is UpdateJSON;
|
|
53
|
+
/**
|
|
54
|
+
* Default function to generate `UpdateJSON`
|
|
55
|
+
* @param existingJson exising update json
|
|
56
|
+
* @param signature sigature
|
|
57
|
+
* @param version target version
|
|
58
|
+
* @param minimumVersion minimum version
|
|
59
|
+
*/
|
|
60
|
+
declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
|
|
61
|
+
|
|
62
|
+
export { type UpdateInfo as U, type Version as V, type UpdateJSON as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
interface Version {
|
|
2
|
+
/**
|
|
3
|
+
* `4` of `4.3.2-beta.1`
|
|
4
|
+
*/
|
|
5
|
+
major: number;
|
|
6
|
+
/**
|
|
7
|
+
* `3` of `4.3.2-beta.1`
|
|
8
|
+
*/
|
|
9
|
+
minor: number;
|
|
10
|
+
/**
|
|
11
|
+
* `2` of `4.3.2-beta.1`
|
|
12
|
+
*/
|
|
13
|
+
patch: number;
|
|
14
|
+
/**
|
|
15
|
+
* `beta` of `4.3.2-beta.1`
|
|
16
|
+
*/
|
|
17
|
+
stage: string;
|
|
18
|
+
/**
|
|
19
|
+
* `1` of `4.3.2-beta.1`
|
|
20
|
+
*/
|
|
21
|
+
stageVersion: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parse version string to {@link Version}, like `0.2.0-beta.1`
|
|
25
|
+
* @param version version string
|
|
26
|
+
*/
|
|
27
|
+
declare function parseVersion(version: string): Version;
|
|
28
|
+
/**
|
|
29
|
+
* Default function to check the old version is less than new version
|
|
30
|
+
* @param oldVer old version string
|
|
31
|
+
* @param newVer new version string
|
|
32
|
+
*/
|
|
33
|
+
declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Update info json
|
|
36
|
+
*/
|
|
37
|
+
type UpdateInfo = {
|
|
38
|
+
signature: string;
|
|
39
|
+
minimumVersion: string;
|
|
40
|
+
version: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* {@link UpdateInfo} with beta
|
|
44
|
+
*/
|
|
45
|
+
type UpdateJSON = UpdateInfo & {
|
|
46
|
+
beta: UpdateInfo;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Check is `UpdateJSON`
|
|
50
|
+
* @param json any variable
|
|
51
|
+
*/
|
|
52
|
+
declare function isUpdateJSON(json: any): json is UpdateJSON;
|
|
53
|
+
/**
|
|
54
|
+
* Default function to generate `UpdateJSON`
|
|
55
|
+
* @param existingJson exising update json
|
|
56
|
+
* @param signature sigature
|
|
57
|
+
* @param version target version
|
|
58
|
+
* @param minimumVersion minimum version
|
|
59
|
+
*/
|
|
60
|
+
declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
|
|
61
|
+
|
|
62
|
+
export { type UpdateInfo as U, type Version as V, type UpdateJSON as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
|