electron-incremental-update 2.0.0-beta.8 → 2.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.
@@ -1,134 +0,0 @@
1
- import { EventEmitter } from 'node:events';
2
- import { a as UpdateJSON, U as UpdateInfo, D as DownloadingInfo, I as IProvider, c as URLHandler } from './types-CItP6bL-.js';
3
-
4
- declare const ErrorInfo: {
5
- readonly download: "Download failed";
6
- readonly validate: "Validate failed";
7
- readonly param: "Missing params";
8
- readonly network: "Network error";
9
- };
10
- declare class UpdaterError extends Error {
11
- code: keyof typeof ErrorInfo;
12
- constructor(msg: keyof typeof ErrorInfo, info: string);
13
- }
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
- interface Logger {
34
- info: (msg: string) => void;
35
- debug: (msg: string) => void;
36
- warn: (msg: string) => void;
37
- error: (msg: string, e?: unknown) => void;
38
- }
39
- interface UpdaterOption {
40
- /**
41
- * public key of signature, which will be auto generated by plugin,
42
- * generate by `selfsigned` if not set
43
- */
44
- SIGNATURE_CERT?: string;
45
- /**
46
- * whether to receive beta update
47
- */
48
- receiveBeta?: boolean;
49
- logger?: Logger;
50
- }
51
-
52
- declare class Updater extends EventEmitter<{
53
- 'checking': any;
54
- 'update-available': [data: UpdateInfo];
55
- 'update-unavailable': [reason: string];
56
- 'error': [error: UpdaterError];
57
- 'download-progress': [info: DownloadingInfo];
58
- 'update-downloaded': any;
59
- }> {
60
- private CERT;
61
- private info?;
62
- private provider;
63
- /**
64
- * updater logger
65
- */
66
- logger?: Logger;
67
- /**
68
- * whether to receive beta update
69
- */
70
- receiveBeta?: boolean;
71
- /**
72
- * whether force update in DEV
73
- */
74
- forceUpdate?: boolean;
75
- /**
76
- * initialize incremental updater
77
- * @param provider update provider
78
- * @param option UpdaterOption
79
- */
80
- constructor(provider: IProvider, option?: UpdaterOption);
81
- /**
82
- * this function is used to parse download data.
83
- * - if format is `'json'`
84
- * - if data is `UpdateJSON`, return it
85
- * - if data is string or absent, download URL data and return it
86
- * - if format is `'buffer'`
87
- * - if data is `Buffer`, return it
88
- * - if data is string or absent, download URL data and return it
89
- * @param format 'json' or 'buffer'
90
- * @param data download URL or update json or buffer
91
- */
92
- private fetch;
93
- /**
94
- * handle error message and emit error event
95
- */
96
- private err;
97
- /**
98
- * check update info using default options
99
- */
100
- checkUpdate(): Promise<boolean>;
101
- /**
102
- * check update info using existing update json
103
- * @param data existing update json
104
- */
105
- checkUpdate(data: UpdateJSON): Promise<boolean>;
106
- /**
107
- * download update using default options
108
- */
109
- downloadUpdate(): Promise<boolean>;
110
- /**
111
- * download update using existing `asar.gz` buffer and signature
112
- * @param data existing `asar.gz` buffer
113
- * @param info update info
114
- */
115
- downloadUpdate(data: Uint8Array, info: Omit<UpdateInfo, 'minimumVersion'>): Promise<boolean>;
116
- /**
117
- * quit App and install
118
- */
119
- quitAndInstall(): void;
120
- /**
121
- * setup provider URL handler
122
- *
123
- * @example
124
- * updater.setURLHandler((url, isDownloadingAsar) => {
125
- * if (isDownloadingAsar) {
126
- * url.hostname = 'https://cdn.jsdelivr.net/gh'
127
- * return url
128
- * }
129
- * })
130
- */
131
- setURLHandler(handler: URLHandler): void;
132
- }
133
-
134
- export { type CheckResult as C, type DownloadResult as D, ErrorInfo as E, type Logger as L, Updater as U, type UpdaterOption as a, UpdaterError as b };
@@ -1,134 +0,0 @@
1
- import { EventEmitter } from 'node:events';
2
- import { a as UpdateJSON, U as UpdateInfo, D as DownloadingInfo, I as IProvider, c as URLHandler } from './types-CItP6bL-.cjs';
3
-
4
- declare const ErrorInfo: {
5
- readonly download: "Download failed";
6
- readonly validate: "Validate failed";
7
- readonly param: "Missing params";
8
- readonly network: "Network error";
9
- };
10
- declare class UpdaterError extends Error {
11
- code: keyof typeof ErrorInfo;
12
- constructor(msg: keyof typeof ErrorInfo, info: string);
13
- }
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
- interface Logger {
34
- info: (msg: string) => void;
35
- debug: (msg: string) => void;
36
- warn: (msg: string) => void;
37
- error: (msg: string, e?: unknown) => void;
38
- }
39
- interface UpdaterOption {
40
- /**
41
- * public key of signature, which will be auto generated by plugin,
42
- * generate by `selfsigned` if not set
43
- */
44
- SIGNATURE_CERT?: string;
45
- /**
46
- * whether to receive beta update
47
- */
48
- receiveBeta?: boolean;
49
- logger?: Logger;
50
- }
51
-
52
- declare class Updater extends EventEmitter<{
53
- 'checking': any;
54
- 'update-available': [data: UpdateInfo];
55
- 'update-unavailable': [reason: string];
56
- 'error': [error: UpdaterError];
57
- 'download-progress': [info: DownloadingInfo];
58
- 'update-downloaded': any;
59
- }> {
60
- private CERT;
61
- private info?;
62
- private provider;
63
- /**
64
- * updater logger
65
- */
66
- logger?: Logger;
67
- /**
68
- * whether to receive beta update
69
- */
70
- receiveBeta?: boolean;
71
- /**
72
- * whether force update in DEV
73
- */
74
- forceUpdate?: boolean;
75
- /**
76
- * initialize incremental updater
77
- * @param provider update provider
78
- * @param option UpdaterOption
79
- */
80
- constructor(provider: IProvider, option?: UpdaterOption);
81
- /**
82
- * this function is used to parse download data.
83
- * - if format is `'json'`
84
- * - if data is `UpdateJSON`, return it
85
- * - if data is string or absent, download URL data and return it
86
- * - if format is `'buffer'`
87
- * - if data is `Buffer`, return it
88
- * - if data is string or absent, download URL data and return it
89
- * @param format 'json' or 'buffer'
90
- * @param data download URL or update json or buffer
91
- */
92
- private fetch;
93
- /**
94
- * handle error message and emit error event
95
- */
96
- private err;
97
- /**
98
- * check update info using default options
99
- */
100
- checkUpdate(): Promise<boolean>;
101
- /**
102
- * check update info using existing update json
103
- * @param data existing update json
104
- */
105
- checkUpdate(data: UpdateJSON): Promise<boolean>;
106
- /**
107
- * download update using default options
108
- */
109
- downloadUpdate(): Promise<boolean>;
110
- /**
111
- * download update using existing `asar.gz` buffer and signature
112
- * @param data existing `asar.gz` buffer
113
- * @param info update info
114
- */
115
- downloadUpdate(data: Uint8Array, info: Omit<UpdateInfo, 'minimumVersion'>): Promise<boolean>;
116
- /**
117
- * quit App and install
118
- */
119
- quitAndInstall(): void;
120
- /**
121
- * setup provider URL handler
122
- *
123
- * @example
124
- * updater.setURLHandler((url, isDownloadingAsar) => {
125
- * if (isDownloadingAsar) {
126
- * url.hostname = 'https://cdn.jsdelivr.net/gh'
127
- * return url
128
- * }
129
- * })
130
- */
131
- setURLHandler(handler: URLHandler): void;
132
- }
133
-
134
- export { type CheckResult as C, type DownloadResult as D, ErrorInfo as E, type Logger as L, Updater as U, type UpdaterOption as a, UpdaterError as b };
@@ -1,104 +0,0 @@
1
- import { Promisable } from '@subframe7536/type-utils';
2
-
3
- interface Version {
4
- major: number;
5
- minor: number;
6
- patch: number;
7
- stage: string;
8
- stageVersion: number;
9
- }
10
- declare function parseVersion(version: string): Version;
11
- declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
12
- /**
13
- * update info json
14
- */
15
- type UpdateInfo = {
16
- signature: string;
17
- minimumVersion: string;
18
- version: string;
19
- };
20
- /**
21
- * {@link UpdateInfo} with beta
22
- */
23
- type UpdateJSON = UpdateInfo & {
24
- beta: UpdateInfo;
25
- };
26
- declare function isUpdateJSON(json: any): json is UpdateJSON;
27
- declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
28
-
29
- type URLHandler = (url: URL, isDownloadAsar: boolean) => Promisable<URL | string | undefined | null>;
30
- type OnDownloading = (progress: DownloadingInfo) => void;
31
- interface DownloadingInfo {
32
- /**
33
- * download delta
34
- */
35
- delta: number;
36
- /**
37
- * downloaded percent, 0 ~ 100
38
- *
39
- * If not `Content-Length` header, will be nagative
40
- */
41
- percent: number;
42
- /**
43
- * total size
44
- *
45
- * If not `Content-Length` header, will be -1
46
- */
47
- total: number;
48
- /**
49
- * downloaded size
50
- */
51
- transferred: number;
52
- /**
53
- * download speed, bytes per second
54
- */
55
- bps: number;
56
- }
57
- interface IProvider {
58
- /**
59
- * provider name
60
- */
61
- name: string;
62
- /**
63
- * custom url handler
64
- *
65
- * for Github, there are some {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 public CDN links}
66
- */
67
- urlHandler?: URLHandler;
68
- onDownloading?: OnDownloading;
69
- /**
70
- * download update json
71
- * @param versionPath parsed version path
72
- */
73
- downloadJSON: (versionPath: string) => Promise<UpdateJSON>;
74
- /**
75
- * download update asar
76
- * @param name app name
77
- * @param updateInfo existing update info
78
- * @param onDownloading hook for on downloading
79
- */
80
- downloadAsar: (name: string, updateInfo: UpdateInfo, onDownloading?: (info: DownloadingInfo) => void) => Promise<Buffer>;
81
- /**
82
- * compare version
83
- * @param oldVer old version string
84
- * @param newVer new version string
85
- * @returns if version1 < version2
86
- */
87
- isLowerVersion: (oldVer: string, newVer: string) => boolean;
88
- /**
89
- * unzip file buffer
90
- * @param buffer source buffer
91
- */
92
- unzipFile: (buffer: Buffer) => Promise<Buffer>;
93
- /**
94
- * verify asar signature
95
- * @param buffer file buffer
96
- * @param version target version
97
- * @param signature signature
98
- * @param cert certificate
99
- * @returns if signature is valid, returns the version, otherwise returns `undefined`
100
- */
101
- verifySignaure: (buffer: Buffer, version: string, signature: string, cert: string) => Promisable<boolean>;
102
- }
103
-
104
- export { type DownloadingInfo as D, type IProvider as I, type OnDownloading as O, type UpdateInfo as U, type Version as V, type UpdateJSON as a, defaultVersionJsonGenerator as b, type URLHandler as c, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
@@ -1,104 +0,0 @@
1
- import { Promisable } from '@subframe7536/type-utils';
2
-
3
- interface Version {
4
- major: number;
5
- minor: number;
6
- patch: number;
7
- stage: string;
8
- stageVersion: number;
9
- }
10
- declare function parseVersion(version: string): Version;
11
- declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
12
- /**
13
- * update info json
14
- */
15
- type UpdateInfo = {
16
- signature: string;
17
- minimumVersion: string;
18
- version: string;
19
- };
20
- /**
21
- * {@link UpdateInfo} with beta
22
- */
23
- type UpdateJSON = UpdateInfo & {
24
- beta: UpdateInfo;
25
- };
26
- declare function isUpdateJSON(json: any): json is UpdateJSON;
27
- declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
28
-
29
- type URLHandler = (url: URL, isDownloadAsar: boolean) => Promisable<URL | string | undefined | null>;
30
- type OnDownloading = (progress: DownloadingInfo) => void;
31
- interface DownloadingInfo {
32
- /**
33
- * download delta
34
- */
35
- delta: number;
36
- /**
37
- * downloaded percent, 0 ~ 100
38
- *
39
- * If not `Content-Length` header, will be nagative
40
- */
41
- percent: number;
42
- /**
43
- * total size
44
- *
45
- * If not `Content-Length` header, will be -1
46
- */
47
- total: number;
48
- /**
49
- * downloaded size
50
- */
51
- transferred: number;
52
- /**
53
- * download speed, bytes per second
54
- */
55
- bps: number;
56
- }
57
- interface IProvider {
58
- /**
59
- * provider name
60
- */
61
- name: string;
62
- /**
63
- * custom url handler
64
- *
65
- * for Github, there are some {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 public CDN links}
66
- */
67
- urlHandler?: URLHandler;
68
- onDownloading?: OnDownloading;
69
- /**
70
- * download update json
71
- * @param versionPath parsed version path
72
- */
73
- downloadJSON: (versionPath: string) => Promise<UpdateJSON>;
74
- /**
75
- * download update asar
76
- * @param name app name
77
- * @param updateInfo existing update info
78
- * @param onDownloading hook for on downloading
79
- */
80
- downloadAsar: (name: string, updateInfo: UpdateInfo, onDownloading?: (info: DownloadingInfo) => void) => Promise<Buffer>;
81
- /**
82
- * compare version
83
- * @param oldVer old version string
84
- * @param newVer new version string
85
- * @returns if version1 < version2
86
- */
87
- isLowerVersion: (oldVer: string, newVer: string) => boolean;
88
- /**
89
- * unzip file buffer
90
- * @param buffer source buffer
91
- */
92
- unzipFile: (buffer: Buffer) => Promise<Buffer>;
93
- /**
94
- * verify asar signature
95
- * @param buffer file buffer
96
- * @param version target version
97
- * @param signature signature
98
- * @param cert certificate
99
- * @returns if signature is valid, returns the version, otherwise returns `undefined`
100
- */
101
- verifySignaure: (buffer: Buffer, version: string, signature: string, cert: string) => Promisable<boolean>;
102
- }
103
-
104
- export { type DownloadingInfo as D, type IProvider as I, type OnDownloading as O, type UpdateInfo as U, type Version as V, type UpdateJSON as a, defaultVersionJsonGenerator as b, type URLHandler as c, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };