electron-incremental-update 2.0.0-beta.1 → 2.0.0-beta.11
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-IABBXJFB.js +87 -0
- package/dist/chunk-KZSYEXLO.js +55 -0
- package/dist/chunk-RCRKUKFX.js +70 -0
- package/dist/index.cjs +193 -233
- package/dist/index.d.cts +89 -117
- package/dist/index.d.ts +89 -117
- package/dist/index.js +166 -169
- package/dist/provider.cjs +165 -146
- package/dist/provider.d.cts +94 -22
- package/dist/provider.d.ts +94 -22
- package/dist/provider.js +125 -71
- package/dist/types-C8JhnJjU.d.ts +80 -0
- package/dist/types-CGSkHX4Y.d.cts +80 -0
- package/dist/utils.cjs +142 -191
- package/dist/utils.d.cts +42 -30
- package/dist/utils.d.ts +42 -30
- package/dist/utils.js +3 -62
- package/dist/version-BYVQ367i.d.cts +62 -0
- package/dist/version-BYVQ367i.d.ts +62 -0
- package/dist/vite.d.ts +372 -0
- package/dist/vite.js +326 -274
- package/dist/zip-rm9ED9nU.d.cts +33 -0
- package/dist/zip-rm9ED9nU.d.ts +33 -0
- package/package.json +21 -15
- 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 {
|
|
3
|
-
import '
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { U as UpdateInfo, a as UpdateJSON } from './version-BYVQ367i.cjs';
|
|
3
|
+
import { I as IProvider, D as DownloadingInfo } from './types-CGSkHX4Y.cjs';
|
|
4
|
+
import { Promisable } from '@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,143 +21,136 @@ interface Logger {
|
|
|
38
21
|
}
|
|
39
22
|
interface UpdaterOption {
|
|
40
23
|
/**
|
|
41
|
-
*
|
|
24
|
+
* Update provider
|
|
25
|
+
*
|
|
26
|
+
* If you will not setup `UpdateJSON` or `Buffer` in params when checking update or download, this option is **required**
|
|
27
|
+
*/
|
|
28
|
+
provider?: IProvider;
|
|
29
|
+
/**
|
|
30
|
+
* Certifaction key of signature, which will be auto generated by plugin,
|
|
42
31
|
* generate by `selfsigned` if not set
|
|
43
32
|
*/
|
|
44
33
|
SIGNATURE_CERT?: string;
|
|
45
34
|
/**
|
|
46
|
-
*
|
|
35
|
+
* Whether to receive beta update
|
|
47
36
|
*/
|
|
48
37
|
receiveBeta?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Updater logger
|
|
40
|
+
*/
|
|
49
41
|
logger?: Logger;
|
|
50
42
|
}
|
|
51
43
|
|
|
52
|
-
declare class Updater {
|
|
44
|
+
declare class Updater extends EventEmitter<{
|
|
45
|
+
'checking': any;
|
|
46
|
+
'update-available': [data: UpdateInfo];
|
|
47
|
+
'update-not-available': [reason: string];
|
|
48
|
+
'error': [error: UpdaterError];
|
|
49
|
+
'download-progress': [info: DownloadingInfo];
|
|
50
|
+
'update-downloaded': any;
|
|
51
|
+
'update-cancelled': any;
|
|
52
|
+
}> {
|
|
53
53
|
private CERT;
|
|
54
|
+
private controller;
|
|
54
55
|
private info?;
|
|
55
|
-
|
|
56
|
-
private asarPath;
|
|
57
|
-
private gzipPath;
|
|
58
|
-
private tmpFilePath;
|
|
59
|
-
private provider;
|
|
56
|
+
provider?: IProvider;
|
|
60
57
|
/**
|
|
61
|
-
*
|
|
58
|
+
* Updater logger
|
|
62
59
|
*/
|
|
63
60
|
logger?: Logger;
|
|
64
61
|
/**
|
|
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
|
|
62
|
+
* Whether to receive beta update
|
|
79
63
|
*/
|
|
80
|
-
|
|
64
|
+
receiveBeta?: boolean;
|
|
81
65
|
/**
|
|
82
|
-
*
|
|
66
|
+
* Whether force update in DEV
|
|
83
67
|
*/
|
|
84
|
-
|
|
85
|
-
set receiveBeta(receiveBeta: boolean);
|
|
68
|
+
forceUpdate?: boolean;
|
|
86
69
|
/**
|
|
87
|
-
*
|
|
88
|
-
* @param
|
|
89
|
-
* @param option UpdaterOption
|
|
70
|
+
* Initialize incremental updater
|
|
71
|
+
* @param options UpdaterOption
|
|
90
72
|
*/
|
|
91
|
-
constructor(
|
|
92
|
-
private needUpdate;
|
|
73
|
+
constructor(options?: UpdaterOption);
|
|
93
74
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* - if format is `'buffer'`
|
|
99
|
-
* - if data is `Buffer`, return it
|
|
100
|
-
* - if data is string or absent, download URL data and return it
|
|
101
|
-
* @param format 'json' or 'buffer'
|
|
102
|
-
* @param data download URL or update json or buffer
|
|
75
|
+
* This function is used to parse download data.
|
|
76
|
+
*
|
|
77
|
+
* if data is absent, download URL from provider and return it,
|
|
78
|
+
* else if data is `UpdateJSON`, return it
|
|
103
79
|
*/
|
|
104
|
-
private
|
|
80
|
+
private fetch;
|
|
105
81
|
/**
|
|
106
|
-
*
|
|
82
|
+
* Handle error message and emit error event
|
|
107
83
|
*/
|
|
108
|
-
|
|
84
|
+
private err;
|
|
109
85
|
/**
|
|
110
|
-
*
|
|
111
|
-
* @param url custom download URL of `updatejson`
|
|
86
|
+
* Check update info using default options
|
|
112
87
|
*/
|
|
113
|
-
|
|
88
|
+
checkForUpdates(): Promise<boolean>;
|
|
114
89
|
/**
|
|
115
|
-
*
|
|
90
|
+
* Check update info using existing update json
|
|
116
91
|
* @param data existing update json
|
|
117
92
|
*/
|
|
118
|
-
|
|
93
|
+
checkForUpdates(data: UpdateJSON): Promise<boolean>;
|
|
119
94
|
/**
|
|
120
|
-
*
|
|
95
|
+
* Download update using default options
|
|
121
96
|
*/
|
|
122
|
-
|
|
97
|
+
downloadUpdate(): Promise<boolean>;
|
|
123
98
|
/**
|
|
124
|
-
*
|
|
125
|
-
* @param url custom download URL
|
|
126
|
-
*/
|
|
127
|
-
download(url: string): Promise<DownloadResult>;
|
|
128
|
-
/**
|
|
129
|
-
* download update using existing `asar.gz` buffer and signature
|
|
99
|
+
* Download update using existing `asar.gz` buffer and signature
|
|
130
100
|
* @param data existing `asar.gz` buffer
|
|
131
|
-
* @param
|
|
101
|
+
* @param info update info
|
|
132
102
|
*/
|
|
133
|
-
|
|
103
|
+
downloadUpdate(data: Uint8Array, info: Omit<UpdateInfo, 'minimumVersion'>): Promise<boolean>;
|
|
134
104
|
/**
|
|
135
105
|
* quit App and install
|
|
136
106
|
*/
|
|
137
107
|
quitAndInstall(): void;
|
|
108
|
+
cancel(): void;
|
|
138
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Auto check update, download and install
|
|
112
|
+
*/
|
|
113
|
+
declare function autoUpdate(updater: Updater): Promise<void>;
|
|
139
114
|
|
|
140
|
-
type Promisable<T> = T | Promise<T>;
|
|
141
115
|
/**
|
|
142
|
-
*
|
|
116
|
+
* Hooks on rename temp asar path to `${app.name}.asar`
|
|
143
117
|
* @param install `() => renameSync(tempAsarPath, appNameAsarPath)`
|
|
144
118
|
* @param tempAsarPath temp(updated) asar path
|
|
145
119
|
* @param appNameAsarPath `${app.name}.asar` path
|
|
146
120
|
* @param logger logger
|
|
147
121
|
* @default install(); logger.info(`update success!`)
|
|
148
122
|
*/
|
|
149
|
-
type OnInstallFunction = (install: VoidFunction, tempAsarPath: string, appNameAsarPath: string, logger
|
|
123
|
+
type OnInstallFunction = (install: VoidFunction, tempAsarPath: string, appNameAsarPath: string, logger?: Logger) => Promisable<void>;
|
|
150
124
|
interface AppOption {
|
|
151
125
|
/**
|
|
152
|
-
*
|
|
126
|
+
* Path to index file that make {@link startupWithUpdater} as default export
|
|
127
|
+
*
|
|
128
|
+
* Generate from plugin configuration by default
|
|
153
129
|
*/
|
|
154
|
-
|
|
130
|
+
mainPath?: string;
|
|
155
131
|
/**
|
|
156
|
-
*
|
|
132
|
+
* Updater options
|
|
157
133
|
*/
|
|
158
134
|
updater?: (() => Promisable<Updater>) | UpdaterOption;
|
|
159
135
|
/**
|
|
160
|
-
*
|
|
136
|
+
* Hooks on rename temp asar path to `${app.name}.asar`
|
|
161
137
|
*/
|
|
162
138
|
onInstall?: OnInstallFunction;
|
|
163
139
|
/**
|
|
164
|
-
*
|
|
140
|
+
* Hooks before app startup
|
|
165
141
|
* @param mainFilePath main file path of `${app.name}.asar`
|
|
166
142
|
* @param logger logger
|
|
167
143
|
*/
|
|
168
|
-
beforeStart?: (mainFilePath: string, logger
|
|
144
|
+
beforeStart?: (mainFilePath: string, logger?: Logger) => Promisable<void>;
|
|
169
145
|
/**
|
|
170
|
-
*
|
|
146
|
+
* Hooks on app startup error
|
|
171
147
|
* @param err installing or startup error
|
|
172
148
|
* @param logger logger
|
|
173
149
|
*/
|
|
174
|
-
onStartError?: (err: unknown, logger
|
|
150
|
+
onStartError?: (err: unknown, logger?: Logger) => void;
|
|
175
151
|
}
|
|
176
152
|
/**
|
|
177
|
-
*
|
|
153
|
+
* Utils to startup with updater
|
|
178
154
|
* @param fn startup function
|
|
179
155
|
* @example
|
|
180
156
|
* // in electron/main/index.ts
|
|
@@ -184,28 +160,24 @@ interface AppOption {
|
|
|
184
160
|
*/
|
|
185
161
|
declare function startupWithUpdater(fn: (updater: Updater) => Promisable<void>): (updater: Updater) => Promisable<void>;
|
|
186
162
|
/**
|
|
187
|
-
*
|
|
163
|
+
* Initialize Electron with updater
|
|
188
164
|
* @example
|
|
189
|
-
*
|
|
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
|
-
* initApp({
|
|
197
|
-
* // can be updater option or function that return updater
|
|
165
|
+
* createElectronApp({
|
|
198
166
|
* updater: {
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
167
|
+
* provider: new GitHubProvider({
|
|
168
|
+
* username: 'yourname',
|
|
169
|
+
* repo: 'electron',
|
|
170
|
+
* }),
|
|
171
|
+
* },
|
|
172
|
+
* beforeStart(mainFilePath, logger) {
|
|
173
|
+
* logger?.debug(mainFilePath)
|
|
204
174
|
* },
|
|
205
|
-
* onStart: console.log
|
|
206
175
|
* })
|
|
207
|
-
* ```
|
|
208
176
|
*/
|
|
209
|
-
declare function
|
|
177
|
+
declare function createElectronApp(appOptions?: AppOption): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* @alias {@link createElectronApp}
|
|
180
|
+
*/
|
|
181
|
+
declare const initApp: typeof createElectronApp;
|
|
210
182
|
|
|
211
|
-
export { type AppOption,
|
|
183
|
+
export { type AppOption, ErrorInfo, type Logger, Updater, UpdaterError, type UpdaterOption, autoUpdate, createElectronApp, initApp, startupWithUpdater };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,35 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { U as UpdateInfo, a as UpdateJSON } from './version-BYVQ367i.js';
|
|
3
|
+
import { I as IProvider, D as DownloadingInfo } from './types-C8JhnJjU.js';
|
|
4
|
+
import { Promisable } from '@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,143 +21,136 @@ interface Logger {
|
|
|
38
21
|
}
|
|
39
22
|
interface UpdaterOption {
|
|
40
23
|
/**
|
|
41
|
-
*
|
|
24
|
+
* Update provider
|
|
25
|
+
*
|
|
26
|
+
* If you will not setup `UpdateJSON` or `Buffer` in params when checking update or download, this option is **required**
|
|
27
|
+
*/
|
|
28
|
+
provider?: IProvider;
|
|
29
|
+
/**
|
|
30
|
+
* Certifaction key of signature, which will be auto generated by plugin,
|
|
42
31
|
* generate by `selfsigned` if not set
|
|
43
32
|
*/
|
|
44
33
|
SIGNATURE_CERT?: string;
|
|
45
34
|
/**
|
|
46
|
-
*
|
|
35
|
+
* Whether to receive beta update
|
|
47
36
|
*/
|
|
48
37
|
receiveBeta?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Updater logger
|
|
40
|
+
*/
|
|
49
41
|
logger?: Logger;
|
|
50
42
|
}
|
|
51
43
|
|
|
52
|
-
declare class Updater {
|
|
44
|
+
declare class Updater extends EventEmitter<{
|
|
45
|
+
'checking': any;
|
|
46
|
+
'update-available': [data: UpdateInfo];
|
|
47
|
+
'update-not-available': [reason: string];
|
|
48
|
+
'error': [error: UpdaterError];
|
|
49
|
+
'download-progress': [info: DownloadingInfo];
|
|
50
|
+
'update-downloaded': any;
|
|
51
|
+
'update-cancelled': any;
|
|
52
|
+
}> {
|
|
53
53
|
private CERT;
|
|
54
|
+
private controller;
|
|
54
55
|
private info?;
|
|
55
|
-
|
|
56
|
-
private asarPath;
|
|
57
|
-
private gzipPath;
|
|
58
|
-
private tmpFilePath;
|
|
59
|
-
private provider;
|
|
56
|
+
provider?: IProvider;
|
|
60
57
|
/**
|
|
61
|
-
*
|
|
58
|
+
* Updater logger
|
|
62
59
|
*/
|
|
63
60
|
logger?: Logger;
|
|
64
61
|
/**
|
|
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
|
|
62
|
+
* Whether to receive beta update
|
|
79
63
|
*/
|
|
80
|
-
|
|
64
|
+
receiveBeta?: boolean;
|
|
81
65
|
/**
|
|
82
|
-
*
|
|
66
|
+
* Whether force update in DEV
|
|
83
67
|
*/
|
|
84
|
-
|
|
85
|
-
set receiveBeta(receiveBeta: boolean);
|
|
68
|
+
forceUpdate?: boolean;
|
|
86
69
|
/**
|
|
87
|
-
*
|
|
88
|
-
* @param
|
|
89
|
-
* @param option UpdaterOption
|
|
70
|
+
* Initialize incremental updater
|
|
71
|
+
* @param options UpdaterOption
|
|
90
72
|
*/
|
|
91
|
-
constructor(
|
|
92
|
-
private needUpdate;
|
|
73
|
+
constructor(options?: UpdaterOption);
|
|
93
74
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* - if format is `'buffer'`
|
|
99
|
-
* - if data is `Buffer`, return it
|
|
100
|
-
* - if data is string or absent, download URL data and return it
|
|
101
|
-
* @param format 'json' or 'buffer'
|
|
102
|
-
* @param data download URL or update json or buffer
|
|
75
|
+
* This function is used to parse download data.
|
|
76
|
+
*
|
|
77
|
+
* if data is absent, download URL from provider and return it,
|
|
78
|
+
* else if data is `UpdateJSON`, return it
|
|
103
79
|
*/
|
|
104
|
-
private
|
|
80
|
+
private fetch;
|
|
105
81
|
/**
|
|
106
|
-
*
|
|
82
|
+
* Handle error message and emit error event
|
|
107
83
|
*/
|
|
108
|
-
|
|
84
|
+
private err;
|
|
109
85
|
/**
|
|
110
|
-
*
|
|
111
|
-
* @param url custom download URL of `updatejson`
|
|
86
|
+
* Check update info using default options
|
|
112
87
|
*/
|
|
113
|
-
|
|
88
|
+
checkForUpdates(): Promise<boolean>;
|
|
114
89
|
/**
|
|
115
|
-
*
|
|
90
|
+
* Check update info using existing update json
|
|
116
91
|
* @param data existing update json
|
|
117
92
|
*/
|
|
118
|
-
|
|
93
|
+
checkForUpdates(data: UpdateJSON): Promise<boolean>;
|
|
119
94
|
/**
|
|
120
|
-
*
|
|
95
|
+
* Download update using default options
|
|
121
96
|
*/
|
|
122
|
-
|
|
97
|
+
downloadUpdate(): Promise<boolean>;
|
|
123
98
|
/**
|
|
124
|
-
*
|
|
125
|
-
* @param url custom download URL
|
|
126
|
-
*/
|
|
127
|
-
download(url: string): Promise<DownloadResult>;
|
|
128
|
-
/**
|
|
129
|
-
* download update using existing `asar.gz` buffer and signature
|
|
99
|
+
* Download update using existing `asar.gz` buffer and signature
|
|
130
100
|
* @param data existing `asar.gz` buffer
|
|
131
|
-
* @param
|
|
101
|
+
* @param info update info
|
|
132
102
|
*/
|
|
133
|
-
|
|
103
|
+
downloadUpdate(data: Uint8Array, info: Omit<UpdateInfo, 'minimumVersion'>): Promise<boolean>;
|
|
134
104
|
/**
|
|
135
105
|
* quit App and install
|
|
136
106
|
*/
|
|
137
107
|
quitAndInstall(): void;
|
|
108
|
+
cancel(): void;
|
|
138
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Auto check update, download and install
|
|
112
|
+
*/
|
|
113
|
+
declare function autoUpdate(updater: Updater): Promise<void>;
|
|
139
114
|
|
|
140
|
-
type Promisable<T> = T | Promise<T>;
|
|
141
115
|
/**
|
|
142
|
-
*
|
|
116
|
+
* Hooks on rename temp asar path to `${app.name}.asar`
|
|
143
117
|
* @param install `() => renameSync(tempAsarPath, appNameAsarPath)`
|
|
144
118
|
* @param tempAsarPath temp(updated) asar path
|
|
145
119
|
* @param appNameAsarPath `${app.name}.asar` path
|
|
146
120
|
* @param logger logger
|
|
147
121
|
* @default install(); logger.info(`update success!`)
|
|
148
122
|
*/
|
|
149
|
-
type OnInstallFunction = (install: VoidFunction, tempAsarPath: string, appNameAsarPath: string, logger
|
|
123
|
+
type OnInstallFunction = (install: VoidFunction, tempAsarPath: string, appNameAsarPath: string, logger?: Logger) => Promisable<void>;
|
|
150
124
|
interface AppOption {
|
|
151
125
|
/**
|
|
152
|
-
*
|
|
126
|
+
* Path to index file that make {@link startupWithUpdater} as default export
|
|
127
|
+
*
|
|
128
|
+
* Generate from plugin configuration by default
|
|
153
129
|
*/
|
|
154
|
-
|
|
130
|
+
mainPath?: string;
|
|
155
131
|
/**
|
|
156
|
-
*
|
|
132
|
+
* Updater options
|
|
157
133
|
*/
|
|
158
134
|
updater?: (() => Promisable<Updater>) | UpdaterOption;
|
|
159
135
|
/**
|
|
160
|
-
*
|
|
136
|
+
* Hooks on rename temp asar path to `${app.name}.asar`
|
|
161
137
|
*/
|
|
162
138
|
onInstall?: OnInstallFunction;
|
|
163
139
|
/**
|
|
164
|
-
*
|
|
140
|
+
* Hooks before app startup
|
|
165
141
|
* @param mainFilePath main file path of `${app.name}.asar`
|
|
166
142
|
* @param logger logger
|
|
167
143
|
*/
|
|
168
|
-
beforeStart?: (mainFilePath: string, logger
|
|
144
|
+
beforeStart?: (mainFilePath: string, logger?: Logger) => Promisable<void>;
|
|
169
145
|
/**
|
|
170
|
-
*
|
|
146
|
+
* Hooks on app startup error
|
|
171
147
|
* @param err installing or startup error
|
|
172
148
|
* @param logger logger
|
|
173
149
|
*/
|
|
174
|
-
onStartError?: (err: unknown, logger
|
|
150
|
+
onStartError?: (err: unknown, logger?: Logger) => void;
|
|
175
151
|
}
|
|
176
152
|
/**
|
|
177
|
-
*
|
|
153
|
+
* Utils to startup with updater
|
|
178
154
|
* @param fn startup function
|
|
179
155
|
* @example
|
|
180
156
|
* // in electron/main/index.ts
|
|
@@ -184,28 +160,24 @@ interface AppOption {
|
|
|
184
160
|
*/
|
|
185
161
|
declare function startupWithUpdater(fn: (updater: Updater) => Promisable<void>): (updater: Updater) => Promisable<void>;
|
|
186
162
|
/**
|
|
187
|
-
*
|
|
163
|
+
* Initialize Electron with updater
|
|
188
164
|
* @example
|
|
189
|
-
*
|
|
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
|
-
* initApp({
|
|
197
|
-
* // can be updater option or function that return updater
|
|
165
|
+
* createElectronApp({
|
|
198
166
|
* updater: {
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
167
|
+
* provider: new GitHubProvider({
|
|
168
|
+
* username: 'yourname',
|
|
169
|
+
* repo: 'electron',
|
|
170
|
+
* }),
|
|
171
|
+
* },
|
|
172
|
+
* beforeStart(mainFilePath, logger) {
|
|
173
|
+
* logger?.debug(mainFilePath)
|
|
204
174
|
* },
|
|
205
|
-
* onStart: console.log
|
|
206
175
|
* })
|
|
207
|
-
* ```
|
|
208
176
|
*/
|
|
209
|
-
declare function
|
|
177
|
+
declare function createElectronApp(appOptions?: AppOption): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* @alias {@link createElectronApp}
|
|
180
|
+
*/
|
|
181
|
+
declare const initApp: typeof createElectronApp;
|
|
210
182
|
|
|
211
|
-
export { type AppOption,
|
|
183
|
+
export { type AppOption, ErrorInfo, type Logger, Updater, UpdaterError, type UpdaterOption, autoUpdate, createElectronApp, initApp, startupWithUpdater };
|