electron-incremental-update 1.3.0 → 2.0.0-beta.10

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/dist/utils.d.cts CHANGED
@@ -1,126 +1,86 @@
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 './pure-GoN_3MEj.cjs';
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-C4tF_trh.cjs';
3
4
 
4
5
  /**
5
- * app info
6
+ * Compile time dev check
6
7
  */
7
- declare const is: {
8
- readonly dev: boolean;
9
- readonly win: boolean;
10
- readonly mac: boolean;
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
- * get the absolute path of `${electron.app.name}.asar` (not `app.asar`)
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
- declare function getPathFromAppNameAsar(...path: string[]): string;
17
+ declare function getPathFromAppNameAsar(...paths: string[]): string;
19
18
  /**
20
- * get versions of App, Entry, Electron, Node and System
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 getVersions(): {
29
- appVersion: string;
30
- entryVersion: string;
31
- electronVersion: string;
32
- nodeVersion: string;
33
- systemVersion: string;
34
- };
21
+ declare function getAppVersion(): string;
35
22
  /**
36
- * load native module from entry
37
- * @param moduleName file name in entry
23
+ * Get entry version
38
24
  */
39
- type RequireNative = <T = any>(moduleName: string) => T;
25
+ declare function getEntryVersion(): string;
40
26
  /**
41
- * load module from entry, **only for main and preload**
42
- * @remark use `require`, only support **CommonJS**
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))`
27
+ * Use `require` to load native module from entry asar
28
+ * @param moduleName file name in entry
45
29
  * @example
46
- * const requireNative = loadNativeModuleFromEntry()
47
- * const db = requireNative<typeof import('../native/db')>('db')
48
- * db.test()
30
+ * requireNative<typeof import('../native/db')>('db')
49
31
  */
50
- declare function loadNativeModuleFromEntry(devEntryDirPath?: string, entryDirPath?: string): RequireNative;
32
+ declare function requireNative<T = any>(moduleName: string): T;
51
33
  /**
52
34
  * Restarts the Electron app.
53
35
  */
54
36
  declare function restartApp(): void;
55
37
  /**
56
- * fix app use model id, only for Windows
57
- * @param id app id @default `org.${electron.app.name}`
38
+ * Fix app use model id, only for Windows
39
+ * @param id app id, default is `org.${electron.app.name}`
58
40
  */
59
41
  declare function setAppUserModelId(id?: string): void;
60
42
  /**
61
- * disable hardware acceleration for Windows 7
43
+ * Disable hardware acceleration for Windows 7
62
44
  */
63
45
  declare function disableHWAccForWin7(): void;
64
46
  /**
65
- * keep single electron instance and auto restore window on `second-instance` event
47
+ * Keep single electron instance and auto restore window on `second-instance` event
66
48
  * @param window brwoser window to show
67
49
  * @returns `false` if the app is running
68
50
  */
69
51
  declare function singleInstance(window?: BrowserWindow): boolean;
70
52
  /**
71
- * set `AppData` dir to the dir of .exe file
53
+ * Set `AppData` dir to the dir of .exe file
72
54
  *
73
- * useful for portable Windows app
55
+ * Useful for portable Windows app
74
56
  * @param dirName dir name, default to `data`
75
57
  */
76
58
  declare function setPortableAppDataPath(dirName?: string): void;
77
59
  /**
78
- * ensure app is ready.
79
- * @param timeout wait timeout, @default 1000
60
+ * Load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
61
+ * @param win window
62
+ * @param htmlFilePath html file path, default is `index.html`
80
63
  */
81
- declare function waitAppReady(timeout?: number): Promise<void>;
64
+ declare function loadPage(win: BrowserWindow, htmlFilePath?: string): void;
82
65
  /**
83
- * get paths, **only for main and preload**
84
- * @param entryDirName entry dir name, default to `dist-entry`
66
+ * Get joined path from preload dir
67
+ * @param paths rest paths
85
68
  */
86
- declare function getPaths(entryDirName?: string): {
87
- /**
88
- * @example
89
- * ```ts
90
- * devServerURL && win.loadURL(devServerURL)
91
- * ```
92
- */
93
- devServerURL: string | undefined;
94
- /**
95
- * @example
96
- * ```ts
97
- * win.loadFile(indexHTMLPath)
98
- * ```
99
- */
100
- indexHTMLPath: string;
101
- /**
102
- * get path inside entry asar
103
- * @param paths joined path
104
- */
105
- getPathFromEntryAsar(...paths: string[]): string;
106
- /**
107
- * get path inside `${electron.app.name}.asar/main`
108
- * @param paths joined path
109
- */
110
- getPathFromMain(...paths: string[]): string;
111
- /**
112
- * get path inside `${electron.app.name}.asar/preload`
113
- * @param paths joined path
114
- */
115
- getPathFromPreload(...paths: string[]): string;
116
- /**
117
- * get path inside public dir
118
- * @param paths joined path
119
- */
120
- getPathFromPublic(...paths: string[]): string;
121
- };
122
-
123
- declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
124
- declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
69
+ declare function getPathFromPreload(...paths: string[]): string;
70
+ /**
71
+ * Get joined path from publich dir
72
+ * @param paths rest paths
73
+ */
74
+ declare function getPathFromPublic(...paths: string[]): string;
75
+ /**
76
+ * Get joined path from entry asar
77
+ * @param paths rest paths
78
+ */
79
+ declare function getPathFromEntryAsar(...paths: string[]): string;
80
+ /**
81
+ * Handle all unhandled error
82
+ * @param callback callback function
83
+ */
84
+ declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
125
85
 
126
- export { disableHWAccForWin7, getPathFromAppNameAsar, getPaths, getVersions, is, loadNativeModuleFromEntry, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance, unzipFile, waitAppReady, zipFile };
86
+ export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
package/dist/utils.d.ts CHANGED
@@ -1,126 +1,86 @@
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 './pure-GoN_3MEj.js';
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-C4tF_trh.js';
3
4
 
4
5
  /**
5
- * app info
6
+ * Compile time dev check
6
7
  */
7
- declare const is: {
8
- readonly dev: boolean;
9
- readonly win: boolean;
10
- readonly mac: boolean;
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
- * get the absolute path of `${electron.app.name}.asar` (not `app.asar`)
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
- declare function getPathFromAppNameAsar(...path: string[]): string;
17
+ declare function getPathFromAppNameAsar(...paths: string[]): string;
19
18
  /**
20
- * get versions of App, Entry, Electron, Node and System
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 getVersions(): {
29
- appVersion: string;
30
- entryVersion: string;
31
- electronVersion: string;
32
- nodeVersion: string;
33
- systemVersion: string;
34
- };
21
+ declare function getAppVersion(): string;
35
22
  /**
36
- * load native module from entry
37
- * @param moduleName file name in entry
23
+ * Get entry version
38
24
  */
39
- type RequireNative = <T = any>(moduleName: string) => T;
25
+ declare function getEntryVersion(): string;
40
26
  /**
41
- * load module from entry, **only for main and preload**
42
- * @remark use `require`, only support **CommonJS**
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))`
27
+ * Use `require` to load native module from entry asar
28
+ * @param moduleName file name in entry
45
29
  * @example
46
- * const requireNative = loadNativeModuleFromEntry()
47
- * const db = requireNative<typeof import('../native/db')>('db')
48
- * db.test()
30
+ * requireNative<typeof import('../native/db')>('db')
49
31
  */
50
- declare function loadNativeModuleFromEntry(devEntryDirPath?: string, entryDirPath?: string): RequireNative;
32
+ declare function requireNative<T = any>(moduleName: string): T;
51
33
  /**
52
34
  * Restarts the Electron app.
53
35
  */
54
36
  declare function restartApp(): void;
55
37
  /**
56
- * fix app use model id, only for Windows
57
- * @param id app id @default `org.${electron.app.name}`
38
+ * Fix app use model id, only for Windows
39
+ * @param id app id, default is `org.${electron.app.name}`
58
40
  */
59
41
  declare function setAppUserModelId(id?: string): void;
60
42
  /**
61
- * disable hardware acceleration for Windows 7
43
+ * Disable hardware acceleration for Windows 7
62
44
  */
63
45
  declare function disableHWAccForWin7(): void;
64
46
  /**
65
- * keep single electron instance and auto restore window on `second-instance` event
47
+ * Keep single electron instance and auto restore window on `second-instance` event
66
48
  * @param window brwoser window to show
67
49
  * @returns `false` if the app is running
68
50
  */
69
51
  declare function singleInstance(window?: BrowserWindow): boolean;
70
52
  /**
71
- * set `AppData` dir to the dir of .exe file
53
+ * Set `AppData` dir to the dir of .exe file
72
54
  *
73
- * useful for portable Windows app
55
+ * Useful for portable Windows app
74
56
  * @param dirName dir name, default to `data`
75
57
  */
76
58
  declare function setPortableAppDataPath(dirName?: string): void;
77
59
  /**
78
- * ensure app is ready.
79
- * @param timeout wait timeout, @default 1000
60
+ * Load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
61
+ * @param win window
62
+ * @param htmlFilePath html file path, default is `index.html`
80
63
  */
81
- declare function waitAppReady(timeout?: number): Promise<void>;
64
+ declare function loadPage(win: BrowserWindow, htmlFilePath?: string): void;
82
65
  /**
83
- * get paths, **only for main and preload**
84
- * @param entryDirName entry dir name, default to `dist-entry`
66
+ * Get joined path from preload dir
67
+ * @param paths rest paths
85
68
  */
86
- declare function getPaths(entryDirName?: string): {
87
- /**
88
- * @example
89
- * ```ts
90
- * devServerURL && win.loadURL(devServerURL)
91
- * ```
92
- */
93
- devServerURL: string | undefined;
94
- /**
95
- * @example
96
- * ```ts
97
- * win.loadFile(indexHTMLPath)
98
- * ```
99
- */
100
- indexHTMLPath: string;
101
- /**
102
- * get path inside entry asar
103
- * @param paths joined path
104
- */
105
- getPathFromEntryAsar(...paths: string[]): string;
106
- /**
107
- * get path inside `${electron.app.name}.asar/main`
108
- * @param paths joined path
109
- */
110
- getPathFromMain(...paths: string[]): string;
111
- /**
112
- * get path inside `${electron.app.name}.asar/preload`
113
- * @param paths joined path
114
- */
115
- getPathFromPreload(...paths: string[]): string;
116
- /**
117
- * get path inside public dir
118
- * @param paths joined path
119
- */
120
- getPathFromPublic(...paths: string[]): string;
121
- };
122
-
123
- declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
124
- declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
69
+ declare function getPathFromPreload(...paths: string[]): string;
70
+ /**
71
+ * Get joined path from publich dir
72
+ * @param paths rest paths
73
+ */
74
+ declare function getPathFromPublic(...paths: string[]): string;
75
+ /**
76
+ * Get joined path from entry asar
77
+ * @param paths rest paths
78
+ */
79
+ declare function getPathFromEntryAsar(...paths: string[]): string;
80
+ /**
81
+ * Handle all unhandled error
82
+ * @param callback callback function
83
+ */
84
+ declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
125
85
 
126
- export { disableHWAccForWin7, getPathFromAppNameAsar, getPaths, getVersions, is, loadNativeModuleFromEntry, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance, unzipFile, waitAppReady, zipFile };
86
+ export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
package/dist/utils.js CHANGED
@@ -1,38 +1,3 @@
1
- import {
2
- disableHWAccForWin7,
3
- getPathFromAppNameAsar,
4
- getPaths,
5
- getVersions,
6
- handleUnexpectedErrors,
7
- is,
8
- isUpdateJSON,
9
- loadNativeModuleFromEntry,
10
- parseGithubCdnURL,
11
- parseVersion,
12
- restartApp,
13
- setAppUserModelId,
14
- setPortableAppDataPath,
15
- singleInstance,
16
- unzipFile,
17
- waitAppReady,
18
- zipFile
19
- } from "./chunk-SBPTSLG7.js";
20
- export {
21
- disableHWAccForWin7,
22
- getPathFromAppNameAsar,
23
- getPaths,
24
- getVersions,
25
- handleUnexpectedErrors,
26
- is,
27
- isUpdateJSON,
28
- loadNativeModuleFromEntry,
29
- parseGithubCdnURL,
30
- parseVersion,
31
- restartApp,
32
- setAppUserModelId,
33
- setPortableAppDataPath,
34
- singleInstance,
35
- unzipFile,
36
- waitAppReady,
37
- zipFile
38
- };
1
+ export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance } from './chunk-4MH6ZXCY.js';
2
+ export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultZipFile, hashBuffer } from './chunk-KZSYEXLO.js';
3
+ export { defaultIsLowerVersion, defaultVersionJsonGenerator, isUpdateJSON, parseVersion } from './chunk-72ZAJ7AF.js';
@@ -0,0 +1,62 @@
1
+ interface Version {
2
+ /**
3
+ * `2` of `2.1.0-beta.10`
4
+ */
5
+ major: number;
6
+ /**
7
+ * `1` of `2.1.0-beta.10`
8
+ */
9
+ minor: number;
10
+ /**
11
+ * `0` of `2.1.0-beta.10`
12
+ */
13
+ patch: number;
14
+ /**
15
+ * `beta` of `2.1.0-beta.10`
16
+ */
17
+ stage: string;
18
+ /**
19
+ * `10` of `2.1.0-beta.10`
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
+ * `2` of `2.1.0-beta.10`
4
+ */
5
+ major: number;
6
+ /**
7
+ * `1` of `2.1.0-beta.10`
8
+ */
9
+ minor: number;
10
+ /**
11
+ * `0` of `2.1.0-beta.10`
12
+ */
13
+ patch: number;
14
+ /**
15
+ * `beta` of `2.1.0-beta.10`
16
+ */
17
+ stage: string;
18
+ /**
19
+ * `10` of `2.1.0-beta.10`
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 };