electron-incremental-update 2.4.2 → 3.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 +72 -43
- package/dist/download-BN4uMS4_.d.mts +39 -0
- package/dist/download-DO7iuxEJ.d.cts +39 -0
- package/dist/electron-BFoZUBhU.cjs +320 -0
- package/dist/electron-CJIoO4ny.mjs +180 -0
- package/dist/index.cjs +259 -331
- package/dist/index.d.cts +179 -169
- package/dist/index.d.mts +204 -0
- package/dist/index.mjs +271 -0
- package/dist/provider.cjs +142 -356
- package/dist/provider.d.cts +116 -117
- package/dist/provider.d.mts +133 -0
- package/dist/provider.mjs +152 -0
- package/dist/types-BM9Jfu7q.d.cts +154 -0
- package/dist/types-DASqEPXE.d.mts +154 -0
- package/dist/utils.cjs +43 -381
- package/dist/utils.d.cts +117 -85
- package/dist/utils.d.mts +161 -0
- package/dist/utils.mjs +5 -0
- package/dist/version--eVB2A7n.mjs +72 -0
- package/dist/version-aPrLuz_-.cjs +129 -0
- package/dist/vite.d.mts +565 -0
- package/dist/vite.mjs +1222 -0
- package/dist/zip-BCC7FAQ_.cjs +264 -0
- package/dist/zip-Dwm7s1C9.mjs +185 -0
- package/package.json +65 -65
- package/dist/chunk-AAAM44NW.js +0 -70
- package/dist/chunk-IVHNGRZY.js +0 -122
- package/dist/chunk-PD4EV4MM.js +0 -147
- package/dist/index.d.ts +0 -194
- package/dist/index.js +0 -309
- package/dist/provider.d.ts +0 -134
- package/dist/provider.js +0 -178
- package/dist/types-CU7GyVez.d.cts +0 -151
- package/dist/types-CU7GyVez.d.ts +0 -151
- package/dist/utils.d.ts +0 -129
- package/dist/utils.js +0 -3
- package/dist/vite.d.ts +0 -533
- package/dist/vite.js +0 -945
- package/dist/zip-Blmn2vzE.d.cts +0 -71
- package/dist/zip-CnSv_Njj.d.ts +0 -71
- package/provider.d.ts +0 -1
- package/provider.js +0 -1
- package/utils.d.ts +0 -1
- package/utils.js +0 -1
- package/vite.d.ts +0 -1
- package/vite.js +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,194 +1,204 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { EventEmitter } from 'node:events';
|
|
4
|
-
import 'node:url';
|
|
1
|
+
import { a as UpdateJSONWithURL, m as Promisable, n as IProvider, o as UpdateInfo, s as UpdateJSON, t as DownloadingInfo } from "./types-BM9Jfu7q.cjs";
|
|
2
|
+
import { EventEmitter } from "node:events";
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
type
|
|
4
|
+
//#region src/entry/types.d.ts
|
|
5
|
+
type UpdaterErrorCode = "ERR_DOWNLOAD" | "ERR_VALIDATE" | "ERR_PARAM" | "ERR_NETWORK";
|
|
6
|
+
type UpdaterUnavailableCode = "UNAVAILABLE_ERROR" | "UNAVAILABLE_DEV" | "UNAVAILABLE_VERSION";
|
|
8
7
|
declare class UpdaterError extends Error {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
code: UpdaterErrorCode;
|
|
9
|
+
constructor(code: UpdaterErrorCode, info: string);
|
|
11
10
|
}
|
|
12
11
|
interface Logger {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
info: (msg: string) => void;
|
|
13
|
+
debug: (msg: string) => void;
|
|
14
|
+
warn: (msg: string) => void;
|
|
15
|
+
error: (msg: string, e?: unknown) => void;
|
|
17
16
|
}
|
|
18
17
|
interface UpdaterOption {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Update provider
|
|
20
|
+
*
|
|
21
|
+
* If you will not setup `UpdateJSON` or `Buffer` in params when checking update or download, this option is **required**
|
|
22
|
+
*/
|
|
23
|
+
provider?: IProvider;
|
|
24
|
+
/**
|
|
25
|
+
* Certifaction key of signature, which will be auto generated by plugin,
|
|
26
|
+
* generate by `selfsigned` if not set
|
|
27
|
+
*/
|
|
28
|
+
SIGNATURE_CERT?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to receive beta update
|
|
31
|
+
*/
|
|
32
|
+
receiveBeta?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Updater logger
|
|
35
|
+
*/
|
|
36
|
+
logger?: Logger;
|
|
38
37
|
}
|
|
39
38
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
* Update info with current app version and entry version
|
|
40
|
+
*/
|
|
42
41
|
type UpdateInfoWithExtraVersion = UpdateInfo & {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Current app version
|
|
44
|
+
*/
|
|
45
|
+
appVersion: string;
|
|
46
|
+
/**
|
|
47
|
+
* Current entry version
|
|
48
|
+
*/
|
|
49
|
+
entryVersion: string;
|
|
51
50
|
};
|
|
52
|
-
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/entry/updater.d.ts
|
|
53
53
|
declare class Updater<T extends UpdateInfoWithExtraVersion = UpdateInfoWithExtraVersion> extends EventEmitter<{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
"update-available": [data: T];
|
|
55
|
+
"update-not-available": [code: UpdaterUnavailableCode, msg: string, info?: T];
|
|
56
|
+
error: [error: UpdaterError];
|
|
57
|
+
"download-progress": [info: DownloadingInfo];
|
|
58
|
+
"update-downloaded": [];
|
|
59
|
+
"update-cancelled": [];
|
|
60
60
|
}> {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
61
|
+
private CERT;
|
|
62
|
+
private controller;
|
|
63
|
+
private info?;
|
|
64
|
+
private tmpFilePath?;
|
|
65
|
+
private processing;
|
|
66
|
+
provider?: IProvider;
|
|
67
|
+
/**
|
|
68
|
+
* Updater logger
|
|
69
|
+
*/
|
|
70
|
+
logger?: Logger;
|
|
71
|
+
/**
|
|
72
|
+
* Whether to receive beta update
|
|
73
|
+
*/
|
|
74
|
+
receiveBeta?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Whether force update in DEV
|
|
77
|
+
*/
|
|
78
|
+
forceUpdate?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Initialize incremental updater
|
|
81
|
+
* @param options UpdaterOption
|
|
82
|
+
*/
|
|
83
|
+
constructor(options?: UpdaterOption);
|
|
84
|
+
/**
|
|
85
|
+
* This function is used to parse download data.
|
|
86
|
+
*
|
|
87
|
+
* if data is absent, download URL from provider and return it,
|
|
88
|
+
* else if data is `UpdateJSON`, return it
|
|
89
|
+
*/
|
|
90
|
+
private fetch;
|
|
91
|
+
/**
|
|
92
|
+
* This function is used to parse download data.
|
|
93
|
+
*
|
|
94
|
+
* if data is absent, download URL from provider and return it,
|
|
95
|
+
* else if data is `Buffer`, return it
|
|
96
|
+
* @param format 'json' or 'buffer'
|
|
97
|
+
* @param data download URL or update json or buffer
|
|
98
|
+
*/
|
|
99
|
+
private fetch;
|
|
100
|
+
private cleanup;
|
|
101
|
+
/**
|
|
102
|
+
* Handle error message and emit error event
|
|
103
|
+
*/
|
|
104
|
+
private err;
|
|
105
|
+
/**
|
|
106
|
+
* Check update info using default options
|
|
107
|
+
*/
|
|
108
|
+
checkForUpdates(): Promise<boolean>;
|
|
109
|
+
/**
|
|
110
|
+
* Check update info using existing update json
|
|
111
|
+
* @param data existing update json
|
|
112
|
+
*/
|
|
113
|
+
checkForUpdates(data: UpdateJSON | UpdateJSONWithURL): Promise<boolean>;
|
|
114
|
+
/**
|
|
115
|
+
* Download update using default options
|
|
116
|
+
*/
|
|
117
|
+
downloadUpdate(): Promise<boolean>;
|
|
118
|
+
/**
|
|
119
|
+
* Download update using existing `asar.gz` buffer and signature
|
|
120
|
+
* @param data existing `asar.gz` buffer
|
|
121
|
+
* @param info update info
|
|
122
|
+
*/
|
|
123
|
+
downloadUpdate(data: Uint8Array, info: Omit<UpdateInfo, "minimumVersion">): Promise<boolean>;
|
|
124
|
+
/**
|
|
125
|
+
* quit App and install
|
|
126
|
+
*/
|
|
127
|
+
quitAndInstall(): void;
|
|
128
|
+
cancel(): void;
|
|
120
129
|
}
|
|
121
130
|
/**
|
|
122
|
-
|
|
123
|
-
|
|
131
|
+
* Auto check update, download and install
|
|
132
|
+
*/
|
|
124
133
|
declare function autoUpdate(updater: Updater): Promise<void>;
|
|
125
|
-
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/entry/core.d.ts
|
|
126
136
|
/**
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
137
|
+
* Hooks on rename temp asar path to `${app.name}.asar`
|
|
138
|
+
* @param install `() => renameSync(tempAsarPath, appNameAsarPath)`
|
|
139
|
+
* @param tempAsarPath temp(updated) asar path
|
|
140
|
+
* @param appNameAsarPath `${app.name}.asar` path
|
|
141
|
+
* @param logger logger
|
|
142
|
+
* @default install(); logger.info('update success!')
|
|
143
|
+
*/
|
|
134
144
|
type OnInstallFunction = (install: VoidFunction, tempAsarPath: string, appNameAsarPath: string, logger?: Logger) => Promisable<void>;
|
|
135
145
|
interface AppOption {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
146
|
+
/**
|
|
147
|
+
* Path to index file that make {@link startupWithUpdater} as default export
|
|
148
|
+
*
|
|
149
|
+
* Generate from plugin configuration by default
|
|
150
|
+
*/
|
|
151
|
+
mainPath?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Updater options
|
|
154
|
+
*/
|
|
155
|
+
updater?: (() => Promisable<Updater>) | UpdaterOption;
|
|
156
|
+
/**
|
|
157
|
+
* Hooks on rename temp asar path to `${app.name}.asar`
|
|
158
|
+
*/
|
|
159
|
+
onInstall?: OnInstallFunction;
|
|
160
|
+
/**
|
|
161
|
+
* Hooks before app startup
|
|
162
|
+
* @param mainFilePath main file path of `${app.name}.asar`
|
|
163
|
+
* @param logger logger
|
|
164
|
+
*/
|
|
165
|
+
beforeStart?: (mainFilePath: string, logger?: Logger) => Promisable<void>;
|
|
166
|
+
/**
|
|
167
|
+
* Hooks on app startup error
|
|
168
|
+
* @param err installing or startup error
|
|
169
|
+
* @param logger logger
|
|
170
|
+
*/
|
|
171
|
+
onStartError?: (err: unknown, logger?: Logger) => void;
|
|
162
172
|
}
|
|
163
173
|
/**
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
174
|
+
* Utils to startup with updater
|
|
175
|
+
* @param fn startup function
|
|
176
|
+
* @example
|
|
177
|
+
* // in electron/main/index.ts
|
|
178
|
+
* export default startupWithUpdater((updater) => {
|
|
179
|
+
* updater.checkUpdate()
|
|
180
|
+
* })
|
|
181
|
+
*/
|
|
172
182
|
declare function startupWithUpdater(fn: (updater: Updater) => Promisable<void>): (updater: Updater) => Promisable<void>;
|
|
173
183
|
/**
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
* Initialize Electron with updater
|
|
185
|
+
* @example
|
|
186
|
+
* createElectronApp({
|
|
187
|
+
* updater: {
|
|
188
|
+
* provider: new GitHubProvider({
|
|
189
|
+
* username: 'yourname',
|
|
190
|
+
* repo: 'electron',
|
|
191
|
+
* }),
|
|
192
|
+
* },
|
|
193
|
+
* beforeStart(mainFilePath, logger) {
|
|
194
|
+
* logger?.debug(mainFilePath)
|
|
195
|
+
* },
|
|
196
|
+
* })
|
|
197
|
+
*/
|
|
188
198
|
declare function createElectronApp(appOptions?: AppOption): Promise<void>;
|
|
189
199
|
/**
|
|
190
|
-
|
|
191
|
-
|
|
200
|
+
* @deprecated Use {@link createElectronApp} instead
|
|
201
|
+
*/
|
|
192
202
|
declare const initApp: typeof createElectronApp;
|
|
193
|
-
|
|
194
|
-
export {
|
|
203
|
+
//#endregion
|
|
204
|
+
export { AppOption, Logger, UpdateInfoWithExtraVersion, Updater, UpdaterError, UpdaterErrorCode, UpdaterOption, UpdaterUnavailableCode, autoUpdate, createElectronApp, initApp, startupWithUpdater };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { a as UpdateJSONWithURL, m as Promisable, n as IProvider, o as UpdateInfo, s as UpdateJSON, t as DownloadingInfo } from "./types-DASqEPXE.mjs";
|
|
2
|
+
import { EventEmitter } from "node:events";
|
|
3
|
+
|
|
4
|
+
//#region src/entry/types.d.ts
|
|
5
|
+
type UpdaterErrorCode = "ERR_DOWNLOAD" | "ERR_VALIDATE" | "ERR_PARAM" | "ERR_NETWORK";
|
|
6
|
+
type UpdaterUnavailableCode = "UNAVAILABLE_ERROR" | "UNAVAILABLE_DEV" | "UNAVAILABLE_VERSION";
|
|
7
|
+
declare class UpdaterError extends Error {
|
|
8
|
+
code: UpdaterErrorCode;
|
|
9
|
+
constructor(code: UpdaterErrorCode, info: string);
|
|
10
|
+
}
|
|
11
|
+
interface Logger {
|
|
12
|
+
info: (msg: string) => void;
|
|
13
|
+
debug: (msg: string) => void;
|
|
14
|
+
warn: (msg: string) => void;
|
|
15
|
+
error: (msg: string, e?: unknown) => void;
|
|
16
|
+
}
|
|
17
|
+
interface UpdaterOption {
|
|
18
|
+
/**
|
|
19
|
+
* Update provider
|
|
20
|
+
*
|
|
21
|
+
* If you will not setup `UpdateJSON` or `Buffer` in params when checking update or download, this option is **required**
|
|
22
|
+
*/
|
|
23
|
+
provider?: IProvider;
|
|
24
|
+
/**
|
|
25
|
+
* Certifaction key of signature, which will be auto generated by plugin,
|
|
26
|
+
* generate by `selfsigned` if not set
|
|
27
|
+
*/
|
|
28
|
+
SIGNATURE_CERT?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to receive beta update
|
|
31
|
+
*/
|
|
32
|
+
receiveBeta?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Updater logger
|
|
35
|
+
*/
|
|
36
|
+
logger?: Logger;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Update info with current app version and entry version
|
|
40
|
+
*/
|
|
41
|
+
type UpdateInfoWithExtraVersion = UpdateInfo & {
|
|
42
|
+
/**
|
|
43
|
+
* Current app version
|
|
44
|
+
*/
|
|
45
|
+
appVersion: string;
|
|
46
|
+
/**
|
|
47
|
+
* Current entry version
|
|
48
|
+
*/
|
|
49
|
+
entryVersion: string;
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/entry/updater.d.ts
|
|
53
|
+
declare class Updater<T extends UpdateInfoWithExtraVersion = UpdateInfoWithExtraVersion> extends EventEmitter<{
|
|
54
|
+
"update-available": [data: T];
|
|
55
|
+
"update-not-available": [code: UpdaterUnavailableCode, msg: string, info?: T];
|
|
56
|
+
error: [error: UpdaterError];
|
|
57
|
+
"download-progress": [info: DownloadingInfo];
|
|
58
|
+
"update-downloaded": [];
|
|
59
|
+
"update-cancelled": [];
|
|
60
|
+
}> {
|
|
61
|
+
private CERT;
|
|
62
|
+
private controller;
|
|
63
|
+
private info?;
|
|
64
|
+
private tmpFilePath?;
|
|
65
|
+
private processing;
|
|
66
|
+
provider?: IProvider;
|
|
67
|
+
/**
|
|
68
|
+
* Updater logger
|
|
69
|
+
*/
|
|
70
|
+
logger?: Logger;
|
|
71
|
+
/**
|
|
72
|
+
* Whether to receive beta update
|
|
73
|
+
*/
|
|
74
|
+
receiveBeta?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Whether force update in DEV
|
|
77
|
+
*/
|
|
78
|
+
forceUpdate?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Initialize incremental updater
|
|
81
|
+
* @param options UpdaterOption
|
|
82
|
+
*/
|
|
83
|
+
constructor(options?: UpdaterOption);
|
|
84
|
+
/**
|
|
85
|
+
* This function is used to parse download data.
|
|
86
|
+
*
|
|
87
|
+
* if data is absent, download URL from provider and return it,
|
|
88
|
+
* else if data is `UpdateJSON`, return it
|
|
89
|
+
*/
|
|
90
|
+
private fetch;
|
|
91
|
+
/**
|
|
92
|
+
* This function is used to parse download data.
|
|
93
|
+
*
|
|
94
|
+
* if data is absent, download URL from provider and return it,
|
|
95
|
+
* else if data is `Buffer`, return it
|
|
96
|
+
* @param format 'json' or 'buffer'
|
|
97
|
+
* @param data download URL or update json or buffer
|
|
98
|
+
*/
|
|
99
|
+
private fetch;
|
|
100
|
+
private cleanup;
|
|
101
|
+
/**
|
|
102
|
+
* Handle error message and emit error event
|
|
103
|
+
*/
|
|
104
|
+
private err;
|
|
105
|
+
/**
|
|
106
|
+
* Check update info using default options
|
|
107
|
+
*/
|
|
108
|
+
checkForUpdates(): Promise<boolean>;
|
|
109
|
+
/**
|
|
110
|
+
* Check update info using existing update json
|
|
111
|
+
* @param data existing update json
|
|
112
|
+
*/
|
|
113
|
+
checkForUpdates(data: UpdateJSON | UpdateJSONWithURL): Promise<boolean>;
|
|
114
|
+
/**
|
|
115
|
+
* Download update using default options
|
|
116
|
+
*/
|
|
117
|
+
downloadUpdate(): Promise<boolean>;
|
|
118
|
+
/**
|
|
119
|
+
* Download update using existing `asar.gz` buffer and signature
|
|
120
|
+
* @param data existing `asar.gz` buffer
|
|
121
|
+
* @param info update info
|
|
122
|
+
*/
|
|
123
|
+
downloadUpdate(data: Uint8Array, info: Omit<UpdateInfo, "minimumVersion">): Promise<boolean>;
|
|
124
|
+
/**
|
|
125
|
+
* quit App and install
|
|
126
|
+
*/
|
|
127
|
+
quitAndInstall(): void;
|
|
128
|
+
cancel(): void;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Auto check update, download and install
|
|
132
|
+
*/
|
|
133
|
+
declare function autoUpdate(updater: Updater): Promise<void>;
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/entry/core.d.ts
|
|
136
|
+
/**
|
|
137
|
+
* Hooks on rename temp asar path to `${app.name}.asar`
|
|
138
|
+
* @param install `() => renameSync(tempAsarPath, appNameAsarPath)`
|
|
139
|
+
* @param tempAsarPath temp(updated) asar path
|
|
140
|
+
* @param appNameAsarPath `${app.name}.asar` path
|
|
141
|
+
* @param logger logger
|
|
142
|
+
* @default install(); logger.info('update success!')
|
|
143
|
+
*/
|
|
144
|
+
type OnInstallFunction = (install: VoidFunction, tempAsarPath: string, appNameAsarPath: string, logger?: Logger) => Promisable<void>;
|
|
145
|
+
interface AppOption {
|
|
146
|
+
/**
|
|
147
|
+
* Path to index file that make {@link startupWithUpdater} as default export
|
|
148
|
+
*
|
|
149
|
+
* Generate from plugin configuration by default
|
|
150
|
+
*/
|
|
151
|
+
mainPath?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Updater options
|
|
154
|
+
*/
|
|
155
|
+
updater?: (() => Promisable<Updater>) | UpdaterOption;
|
|
156
|
+
/**
|
|
157
|
+
* Hooks on rename temp asar path to `${app.name}.asar`
|
|
158
|
+
*/
|
|
159
|
+
onInstall?: OnInstallFunction;
|
|
160
|
+
/**
|
|
161
|
+
* Hooks before app startup
|
|
162
|
+
* @param mainFilePath main file path of `${app.name}.asar`
|
|
163
|
+
* @param logger logger
|
|
164
|
+
*/
|
|
165
|
+
beforeStart?: (mainFilePath: string, logger?: Logger) => Promisable<void>;
|
|
166
|
+
/**
|
|
167
|
+
* Hooks on app startup error
|
|
168
|
+
* @param err installing or startup error
|
|
169
|
+
* @param logger logger
|
|
170
|
+
*/
|
|
171
|
+
onStartError?: (err: unknown, logger?: Logger) => void;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Utils to startup with updater
|
|
175
|
+
* @param fn startup function
|
|
176
|
+
* @example
|
|
177
|
+
* // in electron/main/index.ts
|
|
178
|
+
* export default startupWithUpdater((updater) => {
|
|
179
|
+
* updater.checkUpdate()
|
|
180
|
+
* })
|
|
181
|
+
*/
|
|
182
|
+
declare function startupWithUpdater(fn: (updater: Updater) => Promisable<void>): (updater: Updater) => Promisable<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Initialize Electron with updater
|
|
185
|
+
* @example
|
|
186
|
+
* createElectronApp({
|
|
187
|
+
* updater: {
|
|
188
|
+
* provider: new GitHubProvider({
|
|
189
|
+
* username: 'yourname',
|
|
190
|
+
* repo: 'electron',
|
|
191
|
+
* }),
|
|
192
|
+
* },
|
|
193
|
+
* beforeStart(mainFilePath, logger) {
|
|
194
|
+
* logger?.debug(mainFilePath)
|
|
195
|
+
* },
|
|
196
|
+
* })
|
|
197
|
+
*/
|
|
198
|
+
declare function createElectronApp(appOptions?: AppOption): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* @deprecated Use {@link createElectronApp} instead
|
|
201
|
+
*/
|
|
202
|
+
declare const initApp: typeof createElectronApp;
|
|
203
|
+
//#endregion
|
|
204
|
+
export { AppOption, Logger, UpdateInfoWithExtraVersion, Updater, UpdaterError, UpdaterErrorCode, UpdaterOption, UpdaterUnavailableCode, autoUpdate, createElectronApp, initApp, startupWithUpdater };
|