electron-incremental-update 2.0.0-beta.1 → 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/README.md +3 -3
- package/dist/chunk-4MH6ZXCY.js +81 -0
- package/dist/chunk-72ZAJ7AF.js +70 -0
- package/dist/chunk-KZSYEXLO.js +55 -0
- package/dist/index.cjs +161 -221
- package/dist/index.d.cts +71 -107
- package/dist/index.d.ts +71 -107
- package/dist/index.js +135 -156
- package/dist/provider.cjs +132 -127
- package/dist/provider.d.cts +92 -20
- package/dist/provider.d.ts +92 -20
- package/dist/provider.js +92 -51
- package/dist/types-Bnc4jz6R.d.ts +78 -0
- package/dist/types-DEYw5VrL.d.cts +78 -0
- package/dist/utils.cjs +133 -190
- package/dist/utils.d.cts +35 -30
- package/dist/utils.d.ts +35 -30
- package/dist/utils.js +3 -62
- package/dist/version-C4tF_trh.d.cts +62 -0
- package/dist/version-C4tF_trh.d.ts +62 -0
- package/dist/vite.d.ts +370 -0
- package/dist/vite.js +304 -265
- package/dist/zip-rm9ED9nU.d.cts +33 -0
- package/dist/zip-rm9ED9nU.d.ts +33 -0
- package/package.json +20 -14
- package/dist/chunk-RSLOPAIZ.js +0 -247
- package/dist/decrypt-BNBcodiO.d.cts +0 -4
- package/dist/decrypt-BNBcodiO.d.ts +0 -4
- package/dist/types-DxPmQmaq.d.cts +0 -61
- package/dist/types-seJf3Wbc.d.ts +0 -61
- package/dist/version-CffZWDhZ.d.cts +0 -32
- package/dist/version-CffZWDhZ.d.ts +0 -32
package/dist/index.d.cts
CHANGED
|
@@ -1,35 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { U as UpdateInfo, a as UpdateJSON } from './version-C4tF_trh.cjs';
|
|
3
|
+
import { I as IProvider, D as DownloadingInfo } from './types-DEYw5VrL.cjs';
|
|
3
4
|
import '@subframe7536/type-utils';
|
|
4
5
|
|
|
5
6
|
declare const ErrorInfo: {
|
|
6
|
-
readonly download: "Download
|
|
7
|
-
readonly validate: "Validate
|
|
8
|
-
readonly param: "Missing
|
|
9
|
-
readonly
|
|
7
|
+
readonly download: "Download Failed";
|
|
8
|
+
readonly validate: "Validate Failed";
|
|
9
|
+
readonly param: "Missing Params";
|
|
10
|
+
readonly network: "Network Error";
|
|
10
11
|
};
|
|
11
12
|
declare class UpdaterError extends Error {
|
|
12
|
-
|
|
13
|
+
code: keyof typeof ErrorInfo;
|
|
14
|
+
constructor(msg: keyof typeof ErrorInfo, info: string);
|
|
13
15
|
}
|
|
14
|
-
type CheckResult<T extends UpdateJSON> = {
|
|
15
|
-
success: true;
|
|
16
|
-
data: Omit<T, 'beta'>;
|
|
17
|
-
} | {
|
|
18
|
-
success: false;
|
|
19
|
-
/**
|
|
20
|
-
* minimal version that can update
|
|
21
|
-
*/
|
|
22
|
-
data: string;
|
|
23
|
-
} | {
|
|
24
|
-
success: false;
|
|
25
|
-
data: UpdaterError;
|
|
26
|
-
};
|
|
27
|
-
type DownloadResult = {
|
|
28
|
-
success: true;
|
|
29
|
-
} | {
|
|
30
|
-
success: false;
|
|
31
|
-
data: UpdaterError;
|
|
32
|
-
};
|
|
33
16
|
interface Logger {
|
|
34
17
|
info: (msg: string) => void;
|
|
35
18
|
debug: (msg: string) => void;
|
|
@@ -38,60 +21,55 @@ interface Logger {
|
|
|
38
21
|
}
|
|
39
22
|
interface UpdaterOption {
|
|
40
23
|
/**
|
|
41
|
-
*
|
|
24
|
+
* Update provider, call setup later
|
|
25
|
+
*/
|
|
26
|
+
provider?: IProvider;
|
|
27
|
+
/**
|
|
28
|
+
* Certifaction key of signature, which will be auto generated by plugin,
|
|
42
29
|
* generate by `selfsigned` if not set
|
|
43
30
|
*/
|
|
44
31
|
SIGNATURE_CERT?: string;
|
|
45
32
|
/**
|
|
46
|
-
*
|
|
33
|
+
* Whether to receive beta update
|
|
47
34
|
*/
|
|
48
35
|
receiveBeta?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Updater logger
|
|
38
|
+
*/
|
|
49
39
|
logger?: Logger;
|
|
50
40
|
}
|
|
51
41
|
|
|
52
|
-
declare class Updater {
|
|
42
|
+
declare class Updater extends EventEmitter<{
|
|
43
|
+
'checking': any;
|
|
44
|
+
'update-available': [data: UpdateInfo];
|
|
45
|
+
'update-unavailable': [reason: string];
|
|
46
|
+
'error': [error: UpdaterError];
|
|
47
|
+
'download-progress': [info: DownloadingInfo];
|
|
48
|
+
'update-downloaded': any;
|
|
49
|
+
}> {
|
|
53
50
|
private CERT;
|
|
54
51
|
private info?;
|
|
55
|
-
|
|
56
|
-
private asarPath;
|
|
57
|
-
private gzipPath;
|
|
58
|
-
private tmpFilePath;
|
|
59
|
-
private provider;
|
|
52
|
+
provider?: IProvider;
|
|
60
53
|
/**
|
|
61
|
-
*
|
|
54
|
+
* Updater logger
|
|
62
55
|
*/
|
|
63
56
|
logger?: Logger;
|
|
64
57
|
/**
|
|
65
|
-
*
|
|
66
|
-
* @param progress download progress
|
|
67
|
-
* @example
|
|
68
|
-
* updater.onDownloading = ({ percent, total, current }) => {
|
|
69
|
-
* console.log(`download progress: ${percent}, total: ${total}, current: ${current}`)
|
|
70
|
-
* }
|
|
71
|
-
*/
|
|
72
|
-
onDownloading?: OnDownloading;
|
|
73
|
-
/**
|
|
74
|
-
* URL handler hook
|
|
75
|
-
*
|
|
76
|
-
* for Github, there are some {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 public CDN links}
|
|
77
|
-
* @param url source url
|
|
78
|
-
* @param isDownloadAsar whether is download asar
|
|
58
|
+
* Whether to receive beta update
|
|
79
59
|
*/
|
|
80
|
-
|
|
60
|
+
receiveBeta?: boolean;
|
|
81
61
|
/**
|
|
82
|
-
*
|
|
62
|
+
* Whether force update in DEV
|
|
83
63
|
*/
|
|
84
|
-
|
|
85
|
-
set receiveBeta(receiveBeta: boolean);
|
|
64
|
+
forceUpdate?: boolean;
|
|
86
65
|
/**
|
|
87
|
-
*
|
|
88
|
-
* @param
|
|
89
|
-
* @param option UpdaterOption
|
|
66
|
+
* Initialize incremental updater
|
|
67
|
+
* @param options UpdaterOption
|
|
90
68
|
*/
|
|
91
|
-
constructor(
|
|
92
|
-
private
|
|
69
|
+
constructor(options?: UpdaterOption);
|
|
70
|
+
private checkProvider;
|
|
93
71
|
/**
|
|
94
|
-
*
|
|
72
|
+
* This function is used to parse download data.
|
|
95
73
|
* - if format is `'json'`
|
|
96
74
|
* - if data is `UpdateJSON`, return it
|
|
97
75
|
* - if data is string or absent, download URL data and return it
|
|
@@ -101,80 +79,74 @@ declare class Updater {
|
|
|
101
79
|
* @param format 'json' or 'buffer'
|
|
102
80
|
* @param data download URL or update json or buffer
|
|
103
81
|
*/
|
|
104
|
-
private
|
|
82
|
+
private fetch;
|
|
105
83
|
/**
|
|
106
|
-
*
|
|
84
|
+
* Handle error message and emit error event
|
|
107
85
|
*/
|
|
108
|
-
|
|
86
|
+
private err;
|
|
109
87
|
/**
|
|
110
|
-
*
|
|
111
|
-
* @param url custom download URL of `updatejson`
|
|
88
|
+
* Check update info using default options
|
|
112
89
|
*/
|
|
113
|
-
checkUpdate
|
|
90
|
+
checkUpdate(): Promise<boolean>;
|
|
114
91
|
/**
|
|
115
|
-
*
|
|
92
|
+
* Check update info using existing update json
|
|
116
93
|
* @param data existing update json
|
|
117
94
|
*/
|
|
118
|
-
checkUpdate
|
|
119
|
-
/**
|
|
120
|
-
* download update using default options
|
|
121
|
-
*/
|
|
122
|
-
download(): Promise<DownloadResult>;
|
|
95
|
+
checkUpdate(data: UpdateJSON): Promise<boolean>;
|
|
123
96
|
/**
|
|
124
|
-
*
|
|
125
|
-
* @param url custom download URL
|
|
97
|
+
* Download update using default options
|
|
126
98
|
*/
|
|
127
|
-
|
|
99
|
+
downloadUpdate(): Promise<boolean>;
|
|
128
100
|
/**
|
|
129
|
-
*
|
|
101
|
+
* Download update using existing `asar.gz` buffer and signature
|
|
130
102
|
* @param data existing `asar.gz` buffer
|
|
131
|
-
* @param
|
|
103
|
+
* @param info update info
|
|
132
104
|
*/
|
|
133
|
-
|
|
105
|
+
downloadUpdate(data: Uint8Array, info: Omit<UpdateInfo, 'minimumVersion'>): Promise<boolean>;
|
|
134
106
|
/**
|
|
135
107
|
* quit App and install
|
|
136
108
|
*/
|
|
137
109
|
quitAndInstall(): void;
|
|
138
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Auto check update, download and install
|
|
113
|
+
*/
|
|
114
|
+
declare function autoUpdate(updater: Updater): Promise<void>;
|
|
139
115
|
|
|
140
116
|
type Promisable<T> = T | Promise<T>;
|
|
141
117
|
/**
|
|
142
|
-
*
|
|
118
|
+
* Hooks on rename temp asar path to `${app.name}.asar`
|
|
143
119
|
* @param install `() => renameSync(tempAsarPath, appNameAsarPath)`
|
|
144
120
|
* @param tempAsarPath temp(updated) asar path
|
|
145
121
|
* @param appNameAsarPath `${app.name}.asar` path
|
|
146
122
|
* @param logger logger
|
|
147
123
|
* @default install(); logger.info(`update success!`)
|
|
148
124
|
*/
|
|
149
|
-
type OnInstallFunction = (install: VoidFunction, tempAsarPath: string, appNameAsarPath: string, logger
|
|
125
|
+
type OnInstallFunction = (install: VoidFunction, tempAsarPath: string, appNameAsarPath: string, logger?: Logger) => Promisable<void>;
|
|
150
126
|
interface AppOption {
|
|
151
127
|
/**
|
|
152
|
-
*
|
|
153
|
-
*/
|
|
154
|
-
provider: IProvider;
|
|
155
|
-
/**
|
|
156
|
-
* updater options
|
|
128
|
+
* Updater options
|
|
157
129
|
*/
|
|
158
130
|
updater?: (() => Promisable<Updater>) | UpdaterOption;
|
|
159
131
|
/**
|
|
160
|
-
*
|
|
132
|
+
* Hooks on rename temp asar path to `${app.name}.asar`
|
|
161
133
|
*/
|
|
162
134
|
onInstall?: OnInstallFunction;
|
|
163
135
|
/**
|
|
164
|
-
*
|
|
136
|
+
* Hooks before app start up
|
|
165
137
|
* @param mainFilePath main file path of `${app.name}.asar`
|
|
166
138
|
* @param logger logger
|
|
167
139
|
*/
|
|
168
|
-
beforeStart?: (mainFilePath: string, logger
|
|
140
|
+
beforeStart?: (mainFilePath: string, logger?: Logger) => Promisable<void>;
|
|
169
141
|
/**
|
|
170
|
-
*
|
|
142
|
+
* Hooks on app start up error
|
|
171
143
|
* @param err installing or startup error
|
|
172
144
|
* @param logger logger
|
|
173
145
|
*/
|
|
174
|
-
onStartError?: (err: unknown, logger
|
|
146
|
+
onStartError?: (err: unknown, logger?: Logger) => void;
|
|
175
147
|
}
|
|
176
148
|
/**
|
|
177
|
-
*
|
|
149
|
+
* Utils to startup with updater
|
|
178
150
|
* @param fn startup function
|
|
179
151
|
* @example
|
|
180
152
|
* // in electron/main/index.ts
|
|
@@ -186,26 +158,18 @@ declare function startupWithUpdater(fn: (updater: Updater) => Promisable<void>):
|
|
|
186
158
|
/**
|
|
187
159
|
* initialize app
|
|
188
160
|
* @example
|
|
189
|
-
* ```ts
|
|
190
|
-
* import { getGithubReleaseCdnGroup, initApp, parseGithubCdnURL } from 'electron-incremental-update'
|
|
191
|
-
* import { repository } from '../package.json'
|
|
192
|
-
*
|
|
193
|
-
* const { cdnPrefix: asarPrefix } = getGithubReleaseCdnGroup()[0]
|
|
194
|
-
* const { cdnPrefix: jsonPrefix } = getGithubFileCdnGroup()[0]
|
|
195
|
-
*
|
|
196
161
|
* initApp({
|
|
197
|
-
* // can be updater option or function that return updater
|
|
198
162
|
* updater: {
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
163
|
+
* provider: new GitHubProvider({
|
|
164
|
+
* username: 'jerry7536',
|
|
165
|
+
* repo: 'electron2',
|
|
166
|
+
* }),
|
|
167
|
+
* },
|
|
168
|
+
* beforeStart(mainFilePath, logger) {
|
|
169
|
+
* logger?.debug(mainFilePath)
|
|
204
170
|
* },
|
|
205
|
-
* onStart: console.log
|
|
206
171
|
* })
|
|
207
|
-
* ```
|
|
208
172
|
*/
|
|
209
|
-
declare function initApp(appOptions
|
|
173
|
+
declare function initApp(appOptions?: AppOption): Promise<void>;
|
|
210
174
|
|
|
211
|
-
export { type AppOption,
|
|
175
|
+
export { type AppOption, ErrorInfo, type Logger, Updater, UpdaterError, type UpdaterOption, autoUpdate, initApp, startupWithUpdater };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,35 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { U as UpdateInfo, a as UpdateJSON } from './version-C4tF_trh.js';
|
|
3
|
+
import { I as IProvider, D as DownloadingInfo } from './types-Bnc4jz6R.js';
|
|
3
4
|
import '@subframe7536/type-utils';
|
|
4
5
|
|
|
5
6
|
declare const ErrorInfo: {
|
|
6
|
-
readonly download: "Download
|
|
7
|
-
readonly validate: "Validate
|
|
8
|
-
readonly param: "Missing
|
|
9
|
-
readonly
|
|
7
|
+
readonly download: "Download Failed";
|
|
8
|
+
readonly validate: "Validate Failed";
|
|
9
|
+
readonly param: "Missing Params";
|
|
10
|
+
readonly network: "Network Error";
|
|
10
11
|
};
|
|
11
12
|
declare class UpdaterError extends Error {
|
|
12
|
-
|
|
13
|
+
code: keyof typeof ErrorInfo;
|
|
14
|
+
constructor(msg: keyof typeof ErrorInfo, info: string);
|
|
13
15
|
}
|
|
14
|
-
type CheckResult<T extends UpdateJSON> = {
|
|
15
|
-
success: true;
|
|
16
|
-
data: Omit<T, 'beta'>;
|
|
17
|
-
} | {
|
|
18
|
-
success: false;
|
|
19
|
-
/**
|
|
20
|
-
* minimal version that can update
|
|
21
|
-
*/
|
|
22
|
-
data: string;
|
|
23
|
-
} | {
|
|
24
|
-
success: false;
|
|
25
|
-
data: UpdaterError;
|
|
26
|
-
};
|
|
27
|
-
type DownloadResult = {
|
|
28
|
-
success: true;
|
|
29
|
-
} | {
|
|
30
|
-
success: false;
|
|
31
|
-
data: UpdaterError;
|
|
32
|
-
};
|
|
33
16
|
interface Logger {
|
|
34
17
|
info: (msg: string) => void;
|
|
35
18
|
debug: (msg: string) => void;
|
|
@@ -38,60 +21,55 @@ interface Logger {
|
|
|
38
21
|
}
|
|
39
22
|
interface UpdaterOption {
|
|
40
23
|
/**
|
|
41
|
-
*
|
|
24
|
+
* Update provider, call setup later
|
|
25
|
+
*/
|
|
26
|
+
provider?: IProvider;
|
|
27
|
+
/**
|
|
28
|
+
* Certifaction key of signature, which will be auto generated by plugin,
|
|
42
29
|
* generate by `selfsigned` if not set
|
|
43
30
|
*/
|
|
44
31
|
SIGNATURE_CERT?: string;
|
|
45
32
|
/**
|
|
46
|
-
*
|
|
33
|
+
* Whether to receive beta update
|
|
47
34
|
*/
|
|
48
35
|
receiveBeta?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Updater logger
|
|
38
|
+
*/
|
|
49
39
|
logger?: Logger;
|
|
50
40
|
}
|
|
51
41
|
|
|
52
|
-
declare class Updater {
|
|
42
|
+
declare class Updater extends EventEmitter<{
|
|
43
|
+
'checking': any;
|
|
44
|
+
'update-available': [data: UpdateInfo];
|
|
45
|
+
'update-unavailable': [reason: string];
|
|
46
|
+
'error': [error: UpdaterError];
|
|
47
|
+
'download-progress': [info: DownloadingInfo];
|
|
48
|
+
'update-downloaded': any;
|
|
49
|
+
}> {
|
|
53
50
|
private CERT;
|
|
54
51
|
private info?;
|
|
55
|
-
|
|
56
|
-
private asarPath;
|
|
57
|
-
private gzipPath;
|
|
58
|
-
private tmpFilePath;
|
|
59
|
-
private provider;
|
|
52
|
+
provider?: IProvider;
|
|
60
53
|
/**
|
|
61
|
-
*
|
|
54
|
+
* Updater logger
|
|
62
55
|
*/
|
|
63
56
|
logger?: Logger;
|
|
64
57
|
/**
|
|
65
|
-
*
|
|
66
|
-
* @param progress download progress
|
|
67
|
-
* @example
|
|
68
|
-
* updater.onDownloading = ({ percent, total, current }) => {
|
|
69
|
-
* console.log(`download progress: ${percent}, total: ${total}, current: ${current}`)
|
|
70
|
-
* }
|
|
71
|
-
*/
|
|
72
|
-
onDownloading?: OnDownloading;
|
|
73
|
-
/**
|
|
74
|
-
* URL handler hook
|
|
75
|
-
*
|
|
76
|
-
* for Github, there are some {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 public CDN links}
|
|
77
|
-
* @param url source url
|
|
78
|
-
* @param isDownloadAsar whether is download asar
|
|
58
|
+
* Whether to receive beta update
|
|
79
59
|
*/
|
|
80
|
-
|
|
60
|
+
receiveBeta?: boolean;
|
|
81
61
|
/**
|
|
82
|
-
*
|
|
62
|
+
* Whether force update in DEV
|
|
83
63
|
*/
|
|
84
|
-
|
|
85
|
-
set receiveBeta(receiveBeta: boolean);
|
|
64
|
+
forceUpdate?: boolean;
|
|
86
65
|
/**
|
|
87
|
-
*
|
|
88
|
-
* @param
|
|
89
|
-
* @param option UpdaterOption
|
|
66
|
+
* Initialize incremental updater
|
|
67
|
+
* @param options UpdaterOption
|
|
90
68
|
*/
|
|
91
|
-
constructor(
|
|
92
|
-
private
|
|
69
|
+
constructor(options?: UpdaterOption);
|
|
70
|
+
private checkProvider;
|
|
93
71
|
/**
|
|
94
|
-
*
|
|
72
|
+
* This function is used to parse download data.
|
|
95
73
|
* - if format is `'json'`
|
|
96
74
|
* - if data is `UpdateJSON`, return it
|
|
97
75
|
* - if data is string or absent, download URL data and return it
|
|
@@ -101,80 +79,74 @@ declare class Updater {
|
|
|
101
79
|
* @param format 'json' or 'buffer'
|
|
102
80
|
* @param data download URL or update json or buffer
|
|
103
81
|
*/
|
|
104
|
-
private
|
|
82
|
+
private fetch;
|
|
105
83
|
/**
|
|
106
|
-
*
|
|
84
|
+
* Handle error message and emit error event
|
|
107
85
|
*/
|
|
108
|
-
|
|
86
|
+
private err;
|
|
109
87
|
/**
|
|
110
|
-
*
|
|
111
|
-
* @param url custom download URL of `updatejson`
|
|
88
|
+
* Check update info using default options
|
|
112
89
|
*/
|
|
113
|
-
checkUpdate
|
|
90
|
+
checkUpdate(): Promise<boolean>;
|
|
114
91
|
/**
|
|
115
|
-
*
|
|
92
|
+
* Check update info using existing update json
|
|
116
93
|
* @param data existing update json
|
|
117
94
|
*/
|
|
118
|
-
checkUpdate
|
|
119
|
-
/**
|
|
120
|
-
* download update using default options
|
|
121
|
-
*/
|
|
122
|
-
download(): Promise<DownloadResult>;
|
|
95
|
+
checkUpdate(data: UpdateJSON): Promise<boolean>;
|
|
123
96
|
/**
|
|
124
|
-
*
|
|
125
|
-
* @param url custom download URL
|
|
97
|
+
* Download update using default options
|
|
126
98
|
*/
|
|
127
|
-
|
|
99
|
+
downloadUpdate(): Promise<boolean>;
|
|
128
100
|
/**
|
|
129
|
-
*
|
|
101
|
+
* Download update using existing `asar.gz` buffer and signature
|
|
130
102
|
* @param data existing `asar.gz` buffer
|
|
131
|
-
* @param
|
|
103
|
+
* @param info update info
|
|
132
104
|
*/
|
|
133
|
-
|
|
105
|
+
downloadUpdate(data: Uint8Array, info: Omit<UpdateInfo, 'minimumVersion'>): Promise<boolean>;
|
|
134
106
|
/**
|
|
135
107
|
* quit App and install
|
|
136
108
|
*/
|
|
137
109
|
quitAndInstall(): void;
|
|
138
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Auto check update, download and install
|
|
113
|
+
*/
|
|
114
|
+
declare function autoUpdate(updater: Updater): Promise<void>;
|
|
139
115
|
|
|
140
116
|
type Promisable<T> = T | Promise<T>;
|
|
141
117
|
/**
|
|
142
|
-
*
|
|
118
|
+
* Hooks on rename temp asar path to `${app.name}.asar`
|
|
143
119
|
* @param install `() => renameSync(tempAsarPath, appNameAsarPath)`
|
|
144
120
|
* @param tempAsarPath temp(updated) asar path
|
|
145
121
|
* @param appNameAsarPath `${app.name}.asar` path
|
|
146
122
|
* @param logger logger
|
|
147
123
|
* @default install(); logger.info(`update success!`)
|
|
148
124
|
*/
|
|
149
|
-
type OnInstallFunction = (install: VoidFunction, tempAsarPath: string, appNameAsarPath: string, logger
|
|
125
|
+
type OnInstallFunction = (install: VoidFunction, tempAsarPath: string, appNameAsarPath: string, logger?: Logger) => Promisable<void>;
|
|
150
126
|
interface AppOption {
|
|
151
127
|
/**
|
|
152
|
-
*
|
|
153
|
-
*/
|
|
154
|
-
provider: IProvider;
|
|
155
|
-
/**
|
|
156
|
-
* updater options
|
|
128
|
+
* Updater options
|
|
157
129
|
*/
|
|
158
130
|
updater?: (() => Promisable<Updater>) | UpdaterOption;
|
|
159
131
|
/**
|
|
160
|
-
*
|
|
132
|
+
* Hooks on rename temp asar path to `${app.name}.asar`
|
|
161
133
|
*/
|
|
162
134
|
onInstall?: OnInstallFunction;
|
|
163
135
|
/**
|
|
164
|
-
*
|
|
136
|
+
* Hooks before app start up
|
|
165
137
|
* @param mainFilePath main file path of `${app.name}.asar`
|
|
166
138
|
* @param logger logger
|
|
167
139
|
*/
|
|
168
|
-
beforeStart?: (mainFilePath: string, logger
|
|
140
|
+
beforeStart?: (mainFilePath: string, logger?: Logger) => Promisable<void>;
|
|
169
141
|
/**
|
|
170
|
-
*
|
|
142
|
+
* Hooks on app start up error
|
|
171
143
|
* @param err installing or startup error
|
|
172
144
|
* @param logger logger
|
|
173
145
|
*/
|
|
174
|
-
onStartError?: (err: unknown, logger
|
|
146
|
+
onStartError?: (err: unknown, logger?: Logger) => void;
|
|
175
147
|
}
|
|
176
148
|
/**
|
|
177
|
-
*
|
|
149
|
+
* Utils to startup with updater
|
|
178
150
|
* @param fn startup function
|
|
179
151
|
* @example
|
|
180
152
|
* // in electron/main/index.ts
|
|
@@ -186,26 +158,18 @@ declare function startupWithUpdater(fn: (updater: Updater) => Promisable<void>):
|
|
|
186
158
|
/**
|
|
187
159
|
* initialize app
|
|
188
160
|
* @example
|
|
189
|
-
* ```ts
|
|
190
|
-
* import { getGithubReleaseCdnGroup, initApp, parseGithubCdnURL } from 'electron-incremental-update'
|
|
191
|
-
* import { repository } from '../package.json'
|
|
192
|
-
*
|
|
193
|
-
* const { cdnPrefix: asarPrefix } = getGithubReleaseCdnGroup()[0]
|
|
194
|
-
* const { cdnPrefix: jsonPrefix } = getGithubFileCdnGroup()[0]
|
|
195
|
-
*
|
|
196
161
|
* initApp({
|
|
197
|
-
* // can be updater option or function that return updater
|
|
198
162
|
* updater: {
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
163
|
+
* provider: new GitHubProvider({
|
|
164
|
+
* username: 'jerry7536',
|
|
165
|
+
* repo: 'electron2',
|
|
166
|
+
* }),
|
|
167
|
+
* },
|
|
168
|
+
* beforeStart(mainFilePath, logger) {
|
|
169
|
+
* logger?.debug(mainFilePath)
|
|
204
170
|
* },
|
|
205
|
-
* onStart: console.log
|
|
206
171
|
* })
|
|
207
|
-
* ```
|
|
208
172
|
*/
|
|
209
|
-
declare function initApp(appOptions
|
|
173
|
+
declare function initApp(appOptions?: AppOption): Promise<void>;
|
|
210
174
|
|
|
211
|
-
export { type AppOption,
|
|
175
|
+
export { type AppOption, ErrorInfo, type Logger, Updater, UpdaterError, type UpdaterOption, autoUpdate, initApp, startupWithUpdater };
|