electron-incremental-update 0.9.0 → 1.0.0
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 +159 -111
- package/dist/{chunk-CMBFI77K.mjs → chunk-GB6VLKJZ.mjs} +48 -28
- package/dist/{chunk-5BZLJPHJ.mjs → chunk-GXZSAUBR.mjs} +1 -8
- package/dist/chunk-OUZLSVQC.mjs +148 -0
- package/dist/index.d.mts +102 -80
- package/dist/index.d.ts +102 -80
- package/dist/index.js +156 -95
- package/dist/index.mjs +100 -44
- package/dist/noDep-TvZoKVF8.d.mts +31 -0
- package/dist/noDep-TvZoKVF8.d.ts +31 -0
- package/dist/utils.d.mts +91 -46
- package/dist/utils.d.ts +91 -46
- package/dist/utils.js +153 -99
- package/dist/utils.mjs +18 -20
- package/dist/vite.d.mts +208 -41
- package/dist/vite.d.ts +208 -41
- package/dist/vite.js +249 -124
- package/dist/vite.mjs +226 -100
- package/package.json +21 -10
- package/dist/chunk-6UZHBPFT.mjs +0 -113
- package/dist/updateJson-synsK-Pt.d.mts +0 -11
- package/dist/updateJson-synsK-Pt.d.ts +0 -11
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* parse Github CDN URL for accelerating the speed of downloading
|
|
3
|
+
*
|
|
4
|
+
* {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 some public CDN links}
|
|
5
|
+
*/
|
|
6
|
+
declare function parseGithubCdnURL(originRepoURL: string, cdnPrefix: string, relativeFilePath: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* handle all unhandled error
|
|
9
|
+
* @param callback callback function
|
|
10
|
+
*/
|
|
11
|
+
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
12
|
+
interface Version {
|
|
13
|
+
major: number;
|
|
14
|
+
minor: number;
|
|
15
|
+
patch: number;
|
|
16
|
+
stage: string;
|
|
17
|
+
stageVersion: number;
|
|
18
|
+
}
|
|
19
|
+
declare function parseVersion(version: string): Version;
|
|
20
|
+
type UpdateInfo = {
|
|
21
|
+
signature: string;
|
|
22
|
+
minimumVersion: string;
|
|
23
|
+
version: string;
|
|
24
|
+
size: number;
|
|
25
|
+
};
|
|
26
|
+
type UpdateJSON = UpdateInfo & {
|
|
27
|
+
beta: UpdateInfo;
|
|
28
|
+
};
|
|
29
|
+
declare function isUpdateJSON(json: any): json is UpdateJSON;
|
|
30
|
+
|
|
31
|
+
export { type UpdateInfo as U, type Version as V, type UpdateJSON as a, parseVersion as b, handleUnexpectedErrors as h, isUpdateJSON as i, parseGithubCdnURL as p };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* parse Github CDN URL for accelerating the speed of downloading
|
|
3
|
+
*
|
|
4
|
+
* {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 some public CDN links}
|
|
5
|
+
*/
|
|
6
|
+
declare function parseGithubCdnURL(originRepoURL: string, cdnPrefix: string, relativeFilePath: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* handle all unhandled error
|
|
9
|
+
* @param callback callback function
|
|
10
|
+
*/
|
|
11
|
+
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
12
|
+
interface Version {
|
|
13
|
+
major: number;
|
|
14
|
+
minor: number;
|
|
15
|
+
patch: number;
|
|
16
|
+
stage: string;
|
|
17
|
+
stageVersion: number;
|
|
18
|
+
}
|
|
19
|
+
declare function parseVersion(version: string): Version;
|
|
20
|
+
type UpdateInfo = {
|
|
21
|
+
signature: string;
|
|
22
|
+
minimumVersion: string;
|
|
23
|
+
version: string;
|
|
24
|
+
size: number;
|
|
25
|
+
};
|
|
26
|
+
type UpdateJSON = UpdateInfo & {
|
|
27
|
+
beta: UpdateInfo;
|
|
28
|
+
};
|
|
29
|
+
declare function isUpdateJSON(json: any): json is UpdateJSON;
|
|
30
|
+
|
|
31
|
+
export { type UpdateInfo as U, type Version as V, type UpdateJSON as a, parseVersion as b, handleUnexpectedErrors as h, isUpdateJSON as i, parseGithubCdnURL as p };
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { BrowserWindow } from 'electron';
|
|
2
|
+
export { U as UpdateInfo, a as UpdateJSON, V as Version, h as handleUnexpectedErrors, i as isUpdateJSON, p as parseGithubCdnURL, b as parseVersion } from './noDep-TvZoKVF8.mjs';
|
|
3
|
+
|
|
2
4
|
type Is = {
|
|
3
5
|
dev: boolean;
|
|
4
6
|
win: boolean;
|
|
@@ -9,75 +11,118 @@ type Is = {
|
|
|
9
11
|
* get app info
|
|
10
12
|
*/
|
|
11
13
|
declare const is: Is;
|
|
12
|
-
declare function getLocale(): string | undefined;
|
|
13
14
|
/**
|
|
14
|
-
* get the
|
|
15
|
+
* get the absolute path of `${app.name}.asar` (not `app.asar`)
|
|
16
|
+
*
|
|
15
17
|
* if is in dev, return `'DEV.asar'`
|
|
16
|
-
* @
|
|
17
|
-
*/
|
|
18
|
-
declare function getProductAsarPath(name?: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* get the version of Electron runtime
|
|
18
|
+
* @todo change a better function name or merge into {@link getPaths}
|
|
21
19
|
*/
|
|
22
|
-
declare function
|
|
20
|
+
declare function getPathFromAppNameAsar(...path: string[]): string;
|
|
23
21
|
/**
|
|
24
|
-
* get
|
|
22
|
+
* get versions of App, Entry, Electron, Node and System
|
|
23
|
+
*
|
|
24
|
+
* App version is read from `version` file in `${app.name}.asar`
|
|
25
|
+
*
|
|
26
|
+
* Entry version is read from `package.json`
|
|
25
27
|
*
|
|
26
|
-
*
|
|
27
|
-
* @param name - The name of the application
|
|
28
|
+
* SystemVersion: `${platform} ${os.release()}`
|
|
28
29
|
*/
|
|
29
|
-
declare function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
declare function getVersions(): {
|
|
31
|
+
appVersion: string;
|
|
32
|
+
entryVersion: string;
|
|
33
|
+
electronVersion: string;
|
|
34
|
+
nodeVersion: string;
|
|
35
|
+
systemVersion: string;
|
|
36
|
+
};
|
|
35
37
|
/**
|
|
36
|
-
*
|
|
37
|
-
* @param
|
|
38
|
+
* load native module from entry
|
|
39
|
+
* @param moduleName file name in entry
|
|
38
40
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
interface Version {
|
|
42
|
-
major: number;
|
|
43
|
-
minor: number;
|
|
44
|
-
patch: number;
|
|
45
|
-
stage: string;
|
|
46
|
-
stageVersion: number;
|
|
47
|
-
}
|
|
48
|
-
declare function parseVersion(version: string): Version;
|
|
49
|
-
|
|
50
|
-
declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
|
|
51
|
-
declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
|
|
52
|
-
|
|
41
|
+
type RequireNative = <T = any>(moduleName: string) => T;
|
|
53
42
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
43
|
+
* load module from entry, **only for main and preload**
|
|
44
|
+
* @remark use `require`, only support **CommonJS**
|
|
45
|
+
* @param devEntryDirPath entry directory path when dev, default `../../dist-entry`
|
|
46
|
+
* @param entryDirPath entry directory path when not dev, default `join(app.getAppPath(), basename(devEntryDirPath))`
|
|
47
|
+
* @example
|
|
48
|
+
* const requireNative = loadNativeModuleFromEntry()
|
|
49
|
+
* const db = requireNative<typeof import('../native/db')>('db')
|
|
50
|
+
* db.test()
|
|
57
51
|
*/
|
|
58
|
-
declare function
|
|
52
|
+
declare function loadNativeModuleFromEntry(devEntryDirPath?: string, entryDirPath?: string): RequireNative;
|
|
59
53
|
/**
|
|
60
54
|
* Restarts the Electron app.
|
|
61
55
|
*/
|
|
62
56
|
declare function restartApp(): void;
|
|
63
57
|
/**
|
|
64
58
|
* fix app use model id, only for Windows
|
|
65
|
-
* @param id app id
|
|
59
|
+
* @param id app id @default `org.${app.name}`
|
|
60
|
+
*/
|
|
61
|
+
declare function setAppUserModelId(id?: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* disable hardware acceleration for Windows 7
|
|
66
64
|
*/
|
|
67
|
-
declare function
|
|
65
|
+
declare function disableHWAccForWin7(): void;
|
|
68
66
|
/**
|
|
69
|
-
*
|
|
67
|
+
* keep single electron instance and auto restore window on `second-instance` event
|
|
68
|
+
* @param window brwoser window to show
|
|
69
|
+
* @returns `false` if the app is running
|
|
70
70
|
*/
|
|
71
|
-
declare function
|
|
71
|
+
declare function singleInstance(window?: BrowserWindow): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* set `AppData` dir to the dir of .exe file
|
|
74
|
+
*
|
|
75
|
+
* useful for portable Windows app
|
|
76
|
+
* @param dirName dir name, default to `data`
|
|
77
|
+
*/
|
|
78
|
+
declare function setPortableAppDataPath(dirName?: string): void;
|
|
72
79
|
/**
|
|
73
80
|
* ensure app is ready.
|
|
74
81
|
* @param timeout wait timeout, @default 1000
|
|
75
82
|
*/
|
|
76
83
|
declare function waitAppReady(timeout?: number): Promise<void>;
|
|
77
84
|
/**
|
|
78
|
-
*
|
|
79
|
-
* @param
|
|
85
|
+
* get paths, **only for main and preload**
|
|
86
|
+
* @param entryDirName entry dir name, default to `dist-entry`
|
|
80
87
|
*/
|
|
81
|
-
declare function
|
|
88
|
+
declare function getPaths(entryDirName?: string): {
|
|
89
|
+
/**
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* devServerURL && win.loadURL(devServerURL)
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
devServerURL: string | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* win.loadFile(indexHTMLPath)
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
indexHTMLPath: string;
|
|
103
|
+
/**
|
|
104
|
+
* get path inside entry asar
|
|
105
|
+
* @param paths joined path
|
|
106
|
+
*/
|
|
107
|
+
getPathFromEntryAsar(...paths: string[]): string;
|
|
108
|
+
/**
|
|
109
|
+
* get path inside `${app.name}.asar/main`
|
|
110
|
+
* @param paths joined path
|
|
111
|
+
*/
|
|
112
|
+
getPathFromMain(...paths: string[]): string;
|
|
113
|
+
/**
|
|
114
|
+
* get path inside `${app.name}.asar/preload`
|
|
115
|
+
* @param paths joined path
|
|
116
|
+
*/
|
|
117
|
+
getPathFromPreload(...paths: string[]): string;
|
|
118
|
+
/**
|
|
119
|
+
* get path inside public dir
|
|
120
|
+
* @param paths joined path
|
|
121
|
+
*/
|
|
122
|
+
getPathFromPublic(...paths: string[]): string;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
|
|
126
|
+
declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
|
|
82
127
|
|
|
83
|
-
export {
|
|
128
|
+
export { disableHWAccForWin7, getPathFromAppNameAsar, getPaths, getVersions, is, loadNativeModuleFromEntry, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance, unzipFile, waitAppReady, zipFile };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { BrowserWindow } from 'electron';
|
|
2
|
+
export { U as UpdateInfo, a as UpdateJSON, V as Version, h as handleUnexpectedErrors, i as isUpdateJSON, p as parseGithubCdnURL, b as parseVersion } from './noDep-TvZoKVF8.js';
|
|
3
|
+
|
|
2
4
|
type Is = {
|
|
3
5
|
dev: boolean;
|
|
4
6
|
win: boolean;
|
|
@@ -9,75 +11,118 @@ type Is = {
|
|
|
9
11
|
* get app info
|
|
10
12
|
*/
|
|
11
13
|
declare const is: Is;
|
|
12
|
-
declare function getLocale(): string | undefined;
|
|
13
14
|
/**
|
|
14
|
-
* get the
|
|
15
|
+
* get the absolute path of `${app.name}.asar` (not `app.asar`)
|
|
16
|
+
*
|
|
15
17
|
* if is in dev, return `'DEV.asar'`
|
|
16
|
-
* @
|
|
17
|
-
*/
|
|
18
|
-
declare function getProductAsarPath(name?: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* get the version of Electron runtime
|
|
18
|
+
* @todo change a better function name or merge into {@link getPaths}
|
|
21
19
|
*/
|
|
22
|
-
declare function
|
|
20
|
+
declare function getPathFromAppNameAsar(...path: string[]): string;
|
|
23
21
|
/**
|
|
24
|
-
* get
|
|
22
|
+
* get versions of App, Entry, Electron, Node and System
|
|
23
|
+
*
|
|
24
|
+
* App version is read from `version` file in `${app.name}.asar`
|
|
25
|
+
*
|
|
26
|
+
* Entry version is read from `package.json`
|
|
25
27
|
*
|
|
26
|
-
*
|
|
27
|
-
* @param name - The name of the application
|
|
28
|
+
* SystemVersion: `${platform} ${os.release()}`
|
|
28
29
|
*/
|
|
29
|
-
declare function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
declare function getVersions(): {
|
|
31
|
+
appVersion: string;
|
|
32
|
+
entryVersion: string;
|
|
33
|
+
electronVersion: string;
|
|
34
|
+
nodeVersion: string;
|
|
35
|
+
systemVersion: string;
|
|
36
|
+
};
|
|
35
37
|
/**
|
|
36
|
-
*
|
|
37
|
-
* @param
|
|
38
|
+
* load native module from entry
|
|
39
|
+
* @param moduleName file name in entry
|
|
38
40
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
interface Version {
|
|
42
|
-
major: number;
|
|
43
|
-
minor: number;
|
|
44
|
-
patch: number;
|
|
45
|
-
stage: string;
|
|
46
|
-
stageVersion: number;
|
|
47
|
-
}
|
|
48
|
-
declare function parseVersion(version: string): Version;
|
|
49
|
-
|
|
50
|
-
declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
|
|
51
|
-
declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
|
|
52
|
-
|
|
41
|
+
type RequireNative = <T = any>(moduleName: string) => T;
|
|
53
42
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
43
|
+
* load module from entry, **only for main and preload**
|
|
44
|
+
* @remark use `require`, only support **CommonJS**
|
|
45
|
+
* @param devEntryDirPath entry directory path when dev, default `../../dist-entry`
|
|
46
|
+
* @param entryDirPath entry directory path when not dev, default `join(app.getAppPath(), basename(devEntryDirPath))`
|
|
47
|
+
* @example
|
|
48
|
+
* const requireNative = loadNativeModuleFromEntry()
|
|
49
|
+
* const db = requireNative<typeof import('../native/db')>('db')
|
|
50
|
+
* db.test()
|
|
57
51
|
*/
|
|
58
|
-
declare function
|
|
52
|
+
declare function loadNativeModuleFromEntry(devEntryDirPath?: string, entryDirPath?: string): RequireNative;
|
|
59
53
|
/**
|
|
60
54
|
* Restarts the Electron app.
|
|
61
55
|
*/
|
|
62
56
|
declare function restartApp(): void;
|
|
63
57
|
/**
|
|
64
58
|
* fix app use model id, only for Windows
|
|
65
|
-
* @param id app id
|
|
59
|
+
* @param id app id @default `org.${app.name}`
|
|
60
|
+
*/
|
|
61
|
+
declare function setAppUserModelId(id?: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* disable hardware acceleration for Windows 7
|
|
66
64
|
*/
|
|
67
|
-
declare function
|
|
65
|
+
declare function disableHWAccForWin7(): void;
|
|
68
66
|
/**
|
|
69
|
-
*
|
|
67
|
+
* keep single electron instance and auto restore window on `second-instance` event
|
|
68
|
+
* @param window brwoser window to show
|
|
69
|
+
* @returns `false` if the app is running
|
|
70
70
|
*/
|
|
71
|
-
declare function
|
|
71
|
+
declare function singleInstance(window?: BrowserWindow): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* set `AppData` dir to the dir of .exe file
|
|
74
|
+
*
|
|
75
|
+
* useful for portable Windows app
|
|
76
|
+
* @param dirName dir name, default to `data`
|
|
77
|
+
*/
|
|
78
|
+
declare function setPortableAppDataPath(dirName?: string): void;
|
|
72
79
|
/**
|
|
73
80
|
* ensure app is ready.
|
|
74
81
|
* @param timeout wait timeout, @default 1000
|
|
75
82
|
*/
|
|
76
83
|
declare function waitAppReady(timeout?: number): Promise<void>;
|
|
77
84
|
/**
|
|
78
|
-
*
|
|
79
|
-
* @param
|
|
85
|
+
* get paths, **only for main and preload**
|
|
86
|
+
* @param entryDirName entry dir name, default to `dist-entry`
|
|
80
87
|
*/
|
|
81
|
-
declare function
|
|
88
|
+
declare function getPaths(entryDirName?: string): {
|
|
89
|
+
/**
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* devServerURL && win.loadURL(devServerURL)
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
devServerURL: string | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* win.loadFile(indexHTMLPath)
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
indexHTMLPath: string;
|
|
103
|
+
/**
|
|
104
|
+
* get path inside entry asar
|
|
105
|
+
* @param paths joined path
|
|
106
|
+
*/
|
|
107
|
+
getPathFromEntryAsar(...paths: string[]): string;
|
|
108
|
+
/**
|
|
109
|
+
* get path inside `${app.name}.asar/main`
|
|
110
|
+
* @param paths joined path
|
|
111
|
+
*/
|
|
112
|
+
getPathFromMain(...paths: string[]): string;
|
|
113
|
+
/**
|
|
114
|
+
* get path inside `${app.name}.asar/preload`
|
|
115
|
+
* @param paths joined path
|
|
116
|
+
*/
|
|
117
|
+
getPathFromPreload(...paths: string[]): string;
|
|
118
|
+
/**
|
|
119
|
+
* get path inside public dir
|
|
120
|
+
* @param paths joined path
|
|
121
|
+
*/
|
|
122
|
+
getPathFromPublic(...paths: string[]): string;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
|
|
126
|
+
declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
|
|
82
127
|
|
|
83
|
-
export {
|
|
128
|
+
export { disableHWAccForWin7, getPathFromAppNameAsar, getPaths, getVersions, is, loadNativeModuleFromEntry, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance, unzipFile, waitAppReady, zipFile };
|