electron-incremental-update 2.0.1 → 2.1.1
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 +1 -1
- package/dist/bytecode-I4PMYUGT.js +166 -0
- package/dist/chunk-5CE27A6G.js +44 -0
- package/dist/chunk-5NKEXGI3.js +10 -0
- package/dist/chunk-7IRGAAL2.js +5 -0
- package/dist/chunk-7M7DIMDN.js +43 -0
- package/dist/chunk-AUY7A2FL.js +147 -0
- package/dist/chunk-WYQ5DRO7.js +12 -0
- package/dist/chunk-ZM5CIZ4L.js +106 -0
- package/dist/code-P5OANH3Q.js +1 -0
- package/dist/constant-ME27JB5D.js +1 -0
- package/dist/esm-ZFXJ56BN.js +26 -0
- package/dist/index.cjs +38 -38
- package/dist/index.d.cts +7 -44
- package/dist/index.d.ts +7 -44
- package/dist/index.js +41 -40
- package/dist/provider.cjs +140 -18
- package/dist/provider.d.cts +67 -10
- package/dist/provider.d.ts +67 -10
- package/dist/provider.js +140 -20
- package/dist/types-BVcfNRXE.d.ts +117 -0
- package/dist/types-DADYYy6C.d.cts +117 -0
- package/dist/utils-JZ4CMTJG.js +4 -0
- package/dist/utils-KPSYP7HQ.js +5 -0
- package/dist/utils.cjs +23 -2
- package/dist/utils.d.cts +14 -2
- package/dist/utils.d.ts +14 -2
- package/dist/utils.js +1 -1
- package/dist/{version-BYVQ367i.d.ts → version-DcFMG3pT.d.cts} +1 -1
- package/dist/{version-BYVQ367i.d.cts → version-DcFMG3pT.d.ts} +1 -1
- package/dist/vite.js +82 -404
- package/package.json +10 -10
- package/dist/chunk-GTDMND3I.js +0 -87
- package/dist/types-BLdN9rkY.d.ts +0 -72
- package/dist/types-DkCn03M3.d.cts +0 -72
package/dist/provider.d.cts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Promisable, Arrayable } from '@subframe7536/type-utils';
|
|
3
|
-
import { d as defaultIsLowerVersion, a as UpdateJSON, U as UpdateInfo } from './version-BYVQ367i.cjs';
|
|
4
|
-
import { I as IProvider, D as DownloadingInfo, O as OnDownloading } from './types-DkCn03M3.cjs';
|
|
1
|
+
import { I as IProvider, d as UpdateJSONWithURL, e as UpdateInfoWithURL, D as DownloadingInfo, f as URLHandler, O as OnDownloading } from './types-DADYYy6C.cjs';
|
|
5
2
|
import { f as defaultVerifySignature, a as defaultUnzipFile } from './zip-rm9ED9nU.cjs';
|
|
3
|
+
import { d as defaultIsLowerVersion, U as UpdateJSON } from './version-DcFMG3pT.cjs';
|
|
4
|
+
import { Arrayable } from '@subframe7536/type-utils';
|
|
6
5
|
|
|
7
6
|
declare abstract class BaseProvider implements IProvider {
|
|
8
7
|
name: string;
|
|
@@ -21,14 +20,13 @@ declare abstract class BaseProvider implements IProvider {
|
|
|
21
20
|
/**
|
|
22
21
|
* @inheritdoc
|
|
23
22
|
*/
|
|
24
|
-
abstract downloadJSON(versionPath: string, signal: AbortSignal): Promise<
|
|
23
|
+
abstract downloadJSON(name: string, versionPath: string, signal: AbortSignal): Promise<UpdateJSONWithURL>;
|
|
25
24
|
/**
|
|
26
25
|
* @inheritdoc
|
|
27
26
|
*/
|
|
28
|
-
abstract downloadAsar(
|
|
27
|
+
abstract downloadAsar(info: UpdateInfoWithURL, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
type URLHandler = (url: URL) => Promisable<URL | string | undefined | null>;
|
|
32
30
|
interface GitHubProviderOptions {
|
|
33
31
|
/**
|
|
34
32
|
* Github user name
|
|
@@ -73,14 +71,64 @@ declare class GitHubProvider extends BaseProvider {
|
|
|
73
71
|
get urlHandler(): URLHandler | undefined;
|
|
74
72
|
set urlHandler(handler: URLHandler);
|
|
75
73
|
private parseURL;
|
|
74
|
+
private getHeaders;
|
|
76
75
|
/**
|
|
77
76
|
* @inheritdoc
|
|
78
77
|
*/
|
|
79
|
-
downloadJSON(versionPath: string, signal: AbortSignal): Promise<
|
|
78
|
+
downloadJSON(name: string, versionPath: string, signal: AbortSignal): Promise<UpdateJSONWithURL>;
|
|
80
79
|
/**
|
|
81
80
|
* @inheritdoc
|
|
82
81
|
*/
|
|
83
|
-
downloadAsar(
|
|
82
|
+
downloadAsar(info: UpdateInfoWithURL, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface GitHubApiProviderOptions {
|
|
86
|
+
/**
|
|
87
|
+
* Github user name
|
|
88
|
+
*/
|
|
89
|
+
user: string;
|
|
90
|
+
/**
|
|
91
|
+
* Github repo name
|
|
92
|
+
*/
|
|
93
|
+
repo: string;
|
|
94
|
+
/**
|
|
95
|
+
* Github access token
|
|
96
|
+
*/
|
|
97
|
+
token?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Extra headers
|
|
100
|
+
*/
|
|
101
|
+
extraHeaders?: Record<string, string>;
|
|
102
|
+
/**
|
|
103
|
+
* Custom url handler
|
|
104
|
+
*/
|
|
105
|
+
urlHandler?: URLHandler;
|
|
106
|
+
}
|
|
107
|
+
declare class GitHubApiProvider extends BaseProvider {
|
|
108
|
+
name: string;
|
|
109
|
+
private options;
|
|
110
|
+
/**
|
|
111
|
+
* Update Provider for Github API, you need to upload `version.json` to release as well
|
|
112
|
+
* - check update from `https://api.github.com/repos/{user}/{repo}/releases?per_page=1`
|
|
113
|
+
* - download update json and get version and download url
|
|
114
|
+
* - download update asar from update info
|
|
115
|
+
*
|
|
116
|
+
* you can setup `urlHandler` in {@link GitHubApiProviderOptions} to modify url before request
|
|
117
|
+
* @param options provider options
|
|
118
|
+
*/
|
|
119
|
+
constructor(options: GitHubApiProviderOptions);
|
|
120
|
+
get urlHandler(): URLHandler | undefined;
|
|
121
|
+
set urlHandler(handler: URLHandler);
|
|
122
|
+
private parseURL;
|
|
123
|
+
private getHeaders;
|
|
124
|
+
/**
|
|
125
|
+
* @inheritdoc
|
|
126
|
+
*/
|
|
127
|
+
downloadJSON(name: string, versionPath: string, signal: AbortSignal): Promise<UpdateJSONWithURL>;
|
|
128
|
+
/**
|
|
129
|
+
* @inheritdoc
|
|
130
|
+
*/
|
|
131
|
+
downloadAsar(info: UpdateInfoWithURL, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
|
|
84
132
|
}
|
|
85
133
|
|
|
86
134
|
/**
|
|
@@ -89,6 +137,15 @@ declare class GitHubProvider extends BaseProvider {
|
|
|
89
137
|
* @param key target header key
|
|
90
138
|
*/
|
|
91
139
|
declare function getHeader(headers: Record<string, Arrayable<string>>, key: any): any;
|
|
140
|
+
type ResolveDataFn = (data: string, resolve: (data: any) => void, reject: (e: any) => void) => void;
|
|
141
|
+
/**
|
|
142
|
+
* Default function to download json and parse to UpdateJson
|
|
143
|
+
* @param url target url
|
|
144
|
+
* @param headers extra headers
|
|
145
|
+
* @param signal abort signal
|
|
146
|
+
* @param resolveData on resolve
|
|
147
|
+
*/
|
|
148
|
+
declare function defaultDownloadJSON<T>(url: string, headers: Record<string, any>, signal: AbortSignal, resolveData?: ResolveDataFn): Promise<T>;
|
|
92
149
|
/**
|
|
93
150
|
* Default function to download json and parse to UpdateJson
|
|
94
151
|
* @param url target url
|
|
@@ -106,4 +163,4 @@ declare function defaultDownloadUpdateJSON(url: string, headers: Record<string,
|
|
|
106
163
|
*/
|
|
107
164
|
declare function defaultDownloadAsar(url: string, headers: Record<string, any>, signal: AbortSignal, onDownloading?: OnDownloading): Promise<Buffer>;
|
|
108
165
|
|
|
109
|
-
export { BaseProvider, DownloadingInfo, GitHubProvider, type GitHubProviderOptions, IProvider, OnDownloading,
|
|
166
|
+
export { BaseProvider, DownloadingInfo, GitHubApiProvider, type GitHubApiProviderOptions, GitHubProvider, type GitHubProviderOptions, IProvider, OnDownloading, URLHandler, UpdateJSONWithURL, defaultDownloadAsar, defaultDownloadJSON, defaultDownloadUpdateJSON, getHeader };
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Promisable, Arrayable } from '@subframe7536/type-utils';
|
|
3
|
-
import { d as defaultIsLowerVersion, a as UpdateJSON, U as UpdateInfo } from './version-BYVQ367i.js';
|
|
4
|
-
import { I as IProvider, D as DownloadingInfo, O as OnDownloading } from './types-BLdN9rkY.js';
|
|
1
|
+
import { I as IProvider, d as UpdateJSONWithURL, e as UpdateInfoWithURL, D as DownloadingInfo, f as URLHandler, O as OnDownloading } from './types-BVcfNRXE.js';
|
|
5
2
|
import { f as defaultVerifySignature, a as defaultUnzipFile } from './zip-rm9ED9nU.js';
|
|
3
|
+
import { d as defaultIsLowerVersion, U as UpdateJSON } from './version-DcFMG3pT.js';
|
|
4
|
+
import { Arrayable } from '@subframe7536/type-utils';
|
|
6
5
|
|
|
7
6
|
declare abstract class BaseProvider implements IProvider {
|
|
8
7
|
name: string;
|
|
@@ -21,14 +20,13 @@ declare abstract class BaseProvider implements IProvider {
|
|
|
21
20
|
/**
|
|
22
21
|
* @inheritdoc
|
|
23
22
|
*/
|
|
24
|
-
abstract downloadJSON(versionPath: string, signal: AbortSignal): Promise<
|
|
23
|
+
abstract downloadJSON(name: string, versionPath: string, signal: AbortSignal): Promise<UpdateJSONWithURL>;
|
|
25
24
|
/**
|
|
26
25
|
* @inheritdoc
|
|
27
26
|
*/
|
|
28
|
-
abstract downloadAsar(
|
|
27
|
+
abstract downloadAsar(info: UpdateInfoWithURL, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
type URLHandler = (url: URL) => Promisable<URL | string | undefined | null>;
|
|
32
30
|
interface GitHubProviderOptions {
|
|
33
31
|
/**
|
|
34
32
|
* Github user name
|
|
@@ -73,14 +71,64 @@ declare class GitHubProvider extends BaseProvider {
|
|
|
73
71
|
get urlHandler(): URLHandler | undefined;
|
|
74
72
|
set urlHandler(handler: URLHandler);
|
|
75
73
|
private parseURL;
|
|
74
|
+
private getHeaders;
|
|
76
75
|
/**
|
|
77
76
|
* @inheritdoc
|
|
78
77
|
*/
|
|
79
|
-
downloadJSON(versionPath: string, signal: AbortSignal): Promise<
|
|
78
|
+
downloadJSON(name: string, versionPath: string, signal: AbortSignal): Promise<UpdateJSONWithURL>;
|
|
80
79
|
/**
|
|
81
80
|
* @inheritdoc
|
|
82
81
|
*/
|
|
83
|
-
downloadAsar(
|
|
82
|
+
downloadAsar(info: UpdateInfoWithURL, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface GitHubApiProviderOptions {
|
|
86
|
+
/**
|
|
87
|
+
* Github user name
|
|
88
|
+
*/
|
|
89
|
+
user: string;
|
|
90
|
+
/**
|
|
91
|
+
* Github repo name
|
|
92
|
+
*/
|
|
93
|
+
repo: string;
|
|
94
|
+
/**
|
|
95
|
+
* Github access token
|
|
96
|
+
*/
|
|
97
|
+
token?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Extra headers
|
|
100
|
+
*/
|
|
101
|
+
extraHeaders?: Record<string, string>;
|
|
102
|
+
/**
|
|
103
|
+
* Custom url handler
|
|
104
|
+
*/
|
|
105
|
+
urlHandler?: URLHandler;
|
|
106
|
+
}
|
|
107
|
+
declare class GitHubApiProvider extends BaseProvider {
|
|
108
|
+
name: string;
|
|
109
|
+
private options;
|
|
110
|
+
/**
|
|
111
|
+
* Update Provider for Github API, you need to upload `version.json` to release as well
|
|
112
|
+
* - check update from `https://api.github.com/repos/{user}/{repo}/releases?per_page=1`
|
|
113
|
+
* - download update json and get version and download url
|
|
114
|
+
* - download update asar from update info
|
|
115
|
+
*
|
|
116
|
+
* you can setup `urlHandler` in {@link GitHubApiProviderOptions} to modify url before request
|
|
117
|
+
* @param options provider options
|
|
118
|
+
*/
|
|
119
|
+
constructor(options: GitHubApiProviderOptions);
|
|
120
|
+
get urlHandler(): URLHandler | undefined;
|
|
121
|
+
set urlHandler(handler: URLHandler);
|
|
122
|
+
private parseURL;
|
|
123
|
+
private getHeaders;
|
|
124
|
+
/**
|
|
125
|
+
* @inheritdoc
|
|
126
|
+
*/
|
|
127
|
+
downloadJSON(name: string, versionPath: string, signal: AbortSignal): Promise<UpdateJSONWithURL>;
|
|
128
|
+
/**
|
|
129
|
+
* @inheritdoc
|
|
130
|
+
*/
|
|
131
|
+
downloadAsar(info: UpdateInfoWithURL, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
|
|
84
132
|
}
|
|
85
133
|
|
|
86
134
|
/**
|
|
@@ -89,6 +137,15 @@ declare class GitHubProvider extends BaseProvider {
|
|
|
89
137
|
* @param key target header key
|
|
90
138
|
*/
|
|
91
139
|
declare function getHeader(headers: Record<string, Arrayable<string>>, key: any): any;
|
|
140
|
+
type ResolveDataFn = (data: string, resolve: (data: any) => void, reject: (e: any) => void) => void;
|
|
141
|
+
/**
|
|
142
|
+
* Default function to download json and parse to UpdateJson
|
|
143
|
+
* @param url target url
|
|
144
|
+
* @param headers extra headers
|
|
145
|
+
* @param signal abort signal
|
|
146
|
+
* @param resolveData on resolve
|
|
147
|
+
*/
|
|
148
|
+
declare function defaultDownloadJSON<T>(url: string, headers: Record<string, any>, signal: AbortSignal, resolveData?: ResolveDataFn): Promise<T>;
|
|
92
149
|
/**
|
|
93
150
|
* Default function to download json and parse to UpdateJson
|
|
94
151
|
* @param url target url
|
|
@@ -106,4 +163,4 @@ declare function defaultDownloadUpdateJSON(url: string, headers: Record<string,
|
|
|
106
163
|
*/
|
|
107
164
|
declare function defaultDownloadAsar(url: string, headers: Record<string, any>, signal: AbortSignal, onDownloading?: OnDownloading): Promise<Buffer>;
|
|
108
165
|
|
|
109
|
-
export { BaseProvider, DownloadingInfo, GitHubProvider, type GitHubProviderOptions, IProvider, OnDownloading,
|
|
166
|
+
export { BaseProvider, DownloadingInfo, GitHubApiProvider, type GitHubApiProviderOptions, GitHubProvider, type GitHubProviderOptions, IProvider, OnDownloading, URLHandler, UpdateJSONWithURL, defaultDownloadAsar, defaultDownloadJSON, defaultDownloadUpdateJSON, getHeader };
|
package/dist/provider.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defaultVerifySignature, defaultUnzipFile } from './chunk-KZSYEXLO.js';
|
|
2
|
-
import {
|
|
2
|
+
import { isUpdateJSON, defaultIsLowerVersion } from './chunk-RCRKUKFX.js';
|
|
3
3
|
import { URL } from 'node:url';
|
|
4
4
|
import electron from 'electron';
|
|
5
5
|
|
|
@@ -25,7 +25,17 @@ async function downloadFn(url, headers, signal, onResponse) {
|
|
|
25
25
|
request.end();
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
function trimData(data) {
|
|
29
|
+
return data.trim().slice(0, 5e3).replace(/\s+/g, " ");
|
|
30
|
+
}
|
|
31
|
+
var defaultResolveDataFn = (data, resolve, reject) => {
|
|
32
|
+
try {
|
|
33
|
+
resolve(JSON.parse(data));
|
|
34
|
+
} catch {
|
|
35
|
+
reject(new Error(`Invalid json, "${trimData(data)}"`));
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
async function defaultDownloadJSON(url, headers, signal, resolveData = defaultResolveDataFn) {
|
|
29
39
|
return await downloadFn(
|
|
30
40
|
url,
|
|
31
41
|
headers,
|
|
@@ -33,18 +43,26 @@ async function defaultDownloadUpdateJSON(url, headers, signal) {
|
|
|
33
43
|
(resp, resolve, reject) => {
|
|
34
44
|
let data = "";
|
|
35
45
|
resp.on("data", (chunk) => data += chunk);
|
|
36
|
-
resp.on("end", () =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
resp.on("end", () => resolveData(data, resolve, reject));
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
async function defaultDownloadUpdateJSON(url, headers, signal) {
|
|
51
|
+
return await defaultDownloadJSON(
|
|
52
|
+
url,
|
|
53
|
+
headers,
|
|
54
|
+
signal,
|
|
55
|
+
(data, resolve, reject) => {
|
|
56
|
+
try {
|
|
57
|
+
const json = JSON.parse(data);
|
|
58
|
+
if (isUpdateJSON(json)) {
|
|
59
|
+
resolve(json);
|
|
60
|
+
} else {
|
|
61
|
+
throw Error;
|
|
46
62
|
}
|
|
47
|
-
}
|
|
63
|
+
} catch {
|
|
64
|
+
reject(new Error(`Invalid update json, "${trimData(data)}"`));
|
|
65
|
+
}
|
|
48
66
|
}
|
|
49
67
|
);
|
|
50
68
|
}
|
|
@@ -126,27 +144,129 @@ var GitHubProvider = class extends BaseProvider {
|
|
|
126
144
|
);
|
|
127
145
|
return (await this.urlHandler?.(url) || url).toString();
|
|
128
146
|
}
|
|
147
|
+
getHeaders(accept) {
|
|
148
|
+
return { Accept: `application/${accept}`, ...this.options.extraHeaders };
|
|
149
|
+
}
|
|
129
150
|
/**
|
|
130
151
|
* @inheritdoc
|
|
131
152
|
*/
|
|
132
|
-
async downloadJSON(versionPath, signal) {
|
|
133
|
-
|
|
153
|
+
async downloadJSON(name, versionPath, signal) {
|
|
154
|
+
const { beta, version, ...info } = await defaultDownloadUpdateJSON(
|
|
134
155
|
await this.parseURL(`raw/${this.options.branch}/${versionPath}`),
|
|
135
|
-
|
|
156
|
+
this.getHeaders("json"),
|
|
136
157
|
signal
|
|
137
158
|
);
|
|
159
|
+
const getURL = (ver) => this.parseURL(`releases/download/v${ver}/${name}-${ver}.asar.gz`);
|
|
160
|
+
return {
|
|
161
|
+
...info,
|
|
162
|
+
version,
|
|
163
|
+
url: await getURL(version),
|
|
164
|
+
beta: {
|
|
165
|
+
...beta,
|
|
166
|
+
url: await getURL(beta.version)
|
|
167
|
+
}
|
|
168
|
+
};
|
|
138
169
|
}
|
|
139
170
|
/**
|
|
140
171
|
* @inheritdoc
|
|
141
172
|
*/
|
|
142
|
-
async downloadAsar(
|
|
173
|
+
async downloadAsar(info, signal, onDownloading) {
|
|
174
|
+
return await defaultDownloadAsar(
|
|
175
|
+
info.url,
|
|
176
|
+
this.getHeaders("octet-stream"),
|
|
177
|
+
signal,
|
|
178
|
+
onDownloading
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
var ERROR_MSG = "Cannot find UpdateJSON in latest release";
|
|
183
|
+
var GitHubApiProvider = class extends BaseProvider {
|
|
184
|
+
name = "GithubApiProvider";
|
|
185
|
+
options;
|
|
186
|
+
/**
|
|
187
|
+
* Update Provider for Github API, you need to upload `version.json` to release as well
|
|
188
|
+
* - check update from `https://api.github.com/repos/{user}/{repo}/releases?per_page=1`
|
|
189
|
+
* - download update json and get version and download url
|
|
190
|
+
* - download update asar from update info
|
|
191
|
+
*
|
|
192
|
+
* you can setup `urlHandler` in {@link GitHubApiProviderOptions} to modify url before request
|
|
193
|
+
* @param options provider options
|
|
194
|
+
*/
|
|
195
|
+
constructor(options) {
|
|
196
|
+
super();
|
|
197
|
+
this.options = options;
|
|
198
|
+
}
|
|
199
|
+
get urlHandler() {
|
|
200
|
+
return this.options.urlHandler;
|
|
201
|
+
}
|
|
202
|
+
set urlHandler(handler) {
|
|
203
|
+
this.options.urlHandler = handler;
|
|
204
|
+
}
|
|
205
|
+
async parseURL(url) {
|
|
206
|
+
const _url = new URL(url);
|
|
207
|
+
return (await this.urlHandler?.(_url) || _url).toString();
|
|
208
|
+
}
|
|
209
|
+
getHeaders(accept) {
|
|
210
|
+
return {
|
|
211
|
+
Accept: `application/${accept}`,
|
|
212
|
+
...this.options.token ? { Authorization: `token ${this.options.token}` } : {},
|
|
213
|
+
...this.options.extraHeaders
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* @inheritdoc
|
|
218
|
+
*/
|
|
219
|
+
async downloadJSON(name, versionPath, signal) {
|
|
220
|
+
const basename = versionPath.slice(versionPath.lastIndexOf("/") + 1);
|
|
221
|
+
const data = await defaultDownloadJSON(
|
|
222
|
+
await this.parseURL(`https://api.github.com/repos/${this.options.user}/${this.options.repo}/releases?per_page=1`),
|
|
223
|
+
this.getHeaders("vnd.github.v3+json"),
|
|
224
|
+
signal
|
|
225
|
+
);
|
|
226
|
+
const versionAssets = data[0]?.assets.find((asset) => asset.name === basename);
|
|
227
|
+
if (!versionAssets) {
|
|
228
|
+
throw new Error(`${ERROR_MSG}, ${"message" in data ? data.message : "please check the release assets"}`);
|
|
229
|
+
}
|
|
230
|
+
const { beta, version, ...info } = await defaultDownloadUpdateJSON(
|
|
231
|
+
versionAssets.browser_download_url,
|
|
232
|
+
this.getHeaders("json"),
|
|
233
|
+
signal
|
|
234
|
+
);
|
|
235
|
+
const getURL = (ver) => {
|
|
236
|
+
const _ver = data.find((r) => r.tag_name === ver);
|
|
237
|
+
if (!_ver) {
|
|
238
|
+
throw new Error(ERROR_MSG);
|
|
239
|
+
}
|
|
240
|
+
const asset = _ver.assets.find((a) => a.name === `${name}-${ver}.asar.gz`);
|
|
241
|
+
if (!asset) {
|
|
242
|
+
throw new Error(ERROR_MSG);
|
|
243
|
+
}
|
|
244
|
+
return this.parseURL(asset.browser_download_url);
|
|
245
|
+
};
|
|
246
|
+
return {
|
|
247
|
+
...info,
|
|
248
|
+
version,
|
|
249
|
+
url: await getURL(version),
|
|
250
|
+
beta: {
|
|
251
|
+
...beta,
|
|
252
|
+
url: await getURL(beta.version)
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* @inheritdoc
|
|
258
|
+
*/
|
|
259
|
+
async downloadAsar(info, signal, onDownloading) {
|
|
260
|
+
if (!info.url) {
|
|
261
|
+
throw new Error("Cannot download asar without url");
|
|
262
|
+
}
|
|
143
263
|
return await defaultDownloadAsar(
|
|
144
|
-
|
|
145
|
-
|
|
264
|
+
info.url,
|
|
265
|
+
this.getHeaders("octet-stream"),
|
|
146
266
|
signal,
|
|
147
267
|
onDownloading
|
|
148
268
|
);
|
|
149
269
|
}
|
|
150
270
|
};
|
|
151
271
|
|
|
152
|
-
export { BaseProvider, GitHubProvider, defaultDownloadAsar, defaultDownloadUpdateJSON, getHeader };
|
|
272
|
+
export { BaseProvider, GitHubApiProvider, GitHubProvider, defaultDownloadAsar, defaultDownloadJSON, defaultDownloadUpdateJSON, getHeader };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Promisable } from '@subframe7536/type-utils';
|
|
2
|
+
import { a as UpdateInfo } from './version-DcFMG3pT.js';
|
|
3
|
+
|
|
4
|
+
type ErrorCode = 'ERR_DOWNLOAD' | 'ERR_VALIDATE' | 'ERR_PARAM' | 'ERR_NETWORK';
|
|
5
|
+
type UnavailableCode = 'UNAVAILABLE_ERROR' | 'UNAVAILABLE_DEV' | 'UNAVAILABLE_VERSION';
|
|
6
|
+
declare class UpdaterError extends Error {
|
|
7
|
+
code: ErrorCode;
|
|
8
|
+
constructor(code: ErrorCode, info: string);
|
|
9
|
+
}
|
|
10
|
+
interface Logger {
|
|
11
|
+
info: (msg: string) => void;
|
|
12
|
+
debug: (msg: string) => void;
|
|
13
|
+
warn: (msg: string) => void;
|
|
14
|
+
error: (msg: string, e?: unknown) => void;
|
|
15
|
+
}
|
|
16
|
+
interface UpdaterOption {
|
|
17
|
+
/**
|
|
18
|
+
* Update provider
|
|
19
|
+
*
|
|
20
|
+
* If you will not setup `UpdateJSON` or `Buffer` in params when checking update or download, this option is **required**
|
|
21
|
+
*/
|
|
22
|
+
provider?: IProvider;
|
|
23
|
+
/**
|
|
24
|
+
* Certifaction key of signature, which will be auto generated by plugin,
|
|
25
|
+
* generate by `selfsigned` if not set
|
|
26
|
+
*/
|
|
27
|
+
SIGNATURE_CERT?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Whether to receive beta update
|
|
30
|
+
*/
|
|
31
|
+
receiveBeta?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Updater logger
|
|
34
|
+
*/
|
|
35
|
+
logger?: Logger;
|
|
36
|
+
}
|
|
37
|
+
type UpdateInfoWithURL = UpdateInfo & {
|
|
38
|
+
url: string;
|
|
39
|
+
};
|
|
40
|
+
type UpdateInfoWithExtraVersion = UpdateInfo & {
|
|
41
|
+
appVersion: string;
|
|
42
|
+
entryVersion: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type OnDownloading = (progress: DownloadingInfo) => void;
|
|
46
|
+
interface DownloadingInfo {
|
|
47
|
+
/**
|
|
48
|
+
* Download buffer delta
|
|
49
|
+
*/
|
|
50
|
+
delta: number;
|
|
51
|
+
/**
|
|
52
|
+
* Downloaded percent, 0 ~ 100
|
|
53
|
+
*
|
|
54
|
+
* If no `Content-Length` header, will be -1
|
|
55
|
+
*/
|
|
56
|
+
percent: number;
|
|
57
|
+
/**
|
|
58
|
+
* Total size
|
|
59
|
+
*
|
|
60
|
+
* If not `Content-Length` header, will be -1
|
|
61
|
+
*/
|
|
62
|
+
total: number;
|
|
63
|
+
/**
|
|
64
|
+
* Downloaded size
|
|
65
|
+
*/
|
|
66
|
+
transferred: number;
|
|
67
|
+
/**
|
|
68
|
+
* Download speed, bytes per second
|
|
69
|
+
*/
|
|
70
|
+
bps: number;
|
|
71
|
+
}
|
|
72
|
+
type UpdateJSONWithURL = UpdateInfoWithURL & {
|
|
73
|
+
beta: UpdateInfoWithURL;
|
|
74
|
+
};
|
|
75
|
+
interface IProvider {
|
|
76
|
+
/**
|
|
77
|
+
* Provider name
|
|
78
|
+
*/
|
|
79
|
+
name: string;
|
|
80
|
+
/**
|
|
81
|
+
* Download update json
|
|
82
|
+
* @param name app name
|
|
83
|
+
* @param versionPath normalized version path in project
|
|
84
|
+
* @param signal abort signal
|
|
85
|
+
*/
|
|
86
|
+
downloadJSON: (name: string, versionPath: string, signal: AbortSignal) => Promise<UpdateJSONWithURL>;
|
|
87
|
+
/**
|
|
88
|
+
* Download update asar
|
|
89
|
+
* @param updateInfo existing update info
|
|
90
|
+
* @param signal abort signal
|
|
91
|
+
* @param onDownloading hook for on downloading
|
|
92
|
+
*/
|
|
93
|
+
downloadAsar: (updateInfo: UpdateInfoWithURL, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void) => Promise<Buffer>;
|
|
94
|
+
/**
|
|
95
|
+
* Check the old version is less than new version
|
|
96
|
+
* @param oldVer old version string
|
|
97
|
+
* @param newVer new version string
|
|
98
|
+
*/
|
|
99
|
+
isLowerVersion: (oldVer: string, newVer: string) => boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Function to decompress file using brotli
|
|
102
|
+
* @param buffer compressed file buffer
|
|
103
|
+
*/
|
|
104
|
+
unzipFile: (buffer: Buffer) => Promise<Buffer>;
|
|
105
|
+
/**
|
|
106
|
+
* Verify asar signature,
|
|
107
|
+
* if signature is valid, returns the version, otherwise returns `undefined`
|
|
108
|
+
* @param buffer file buffer
|
|
109
|
+
* @param version target version
|
|
110
|
+
* @param signature signature
|
|
111
|
+
* @param cert certificate
|
|
112
|
+
*/
|
|
113
|
+
verifySignaure: (buffer: Buffer, version: string, signature: string, cert: string) => Promisable<boolean>;
|
|
114
|
+
}
|
|
115
|
+
type URLHandler = (url: URL) => Promisable<URL | string | undefined | null>;
|
|
116
|
+
|
|
117
|
+
export { type DownloadingInfo as D, type ErrorCode as E, type IProvider as I, type Logger as L, type OnDownloading as O, type UpdateInfoWithExtraVersion as U, type UnavailableCode as a, UpdaterError as b, type UpdaterOption as c, type UpdateJSONWithURL as d, type UpdateInfoWithURL as e, type URLHandler as f };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Promisable } from '@subframe7536/type-utils';
|
|
2
|
+
import { a as UpdateInfo } from './version-DcFMG3pT.cjs';
|
|
3
|
+
|
|
4
|
+
type ErrorCode = 'ERR_DOWNLOAD' | 'ERR_VALIDATE' | 'ERR_PARAM' | 'ERR_NETWORK';
|
|
5
|
+
type UnavailableCode = 'UNAVAILABLE_ERROR' | 'UNAVAILABLE_DEV' | 'UNAVAILABLE_VERSION';
|
|
6
|
+
declare class UpdaterError extends Error {
|
|
7
|
+
code: ErrorCode;
|
|
8
|
+
constructor(code: ErrorCode, info: string);
|
|
9
|
+
}
|
|
10
|
+
interface Logger {
|
|
11
|
+
info: (msg: string) => void;
|
|
12
|
+
debug: (msg: string) => void;
|
|
13
|
+
warn: (msg: string) => void;
|
|
14
|
+
error: (msg: string, e?: unknown) => void;
|
|
15
|
+
}
|
|
16
|
+
interface UpdaterOption {
|
|
17
|
+
/**
|
|
18
|
+
* Update provider
|
|
19
|
+
*
|
|
20
|
+
* If you will not setup `UpdateJSON` or `Buffer` in params when checking update or download, this option is **required**
|
|
21
|
+
*/
|
|
22
|
+
provider?: IProvider;
|
|
23
|
+
/**
|
|
24
|
+
* Certifaction key of signature, which will be auto generated by plugin,
|
|
25
|
+
* generate by `selfsigned` if not set
|
|
26
|
+
*/
|
|
27
|
+
SIGNATURE_CERT?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Whether to receive beta update
|
|
30
|
+
*/
|
|
31
|
+
receiveBeta?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Updater logger
|
|
34
|
+
*/
|
|
35
|
+
logger?: Logger;
|
|
36
|
+
}
|
|
37
|
+
type UpdateInfoWithURL = UpdateInfo & {
|
|
38
|
+
url: string;
|
|
39
|
+
};
|
|
40
|
+
type UpdateInfoWithExtraVersion = UpdateInfo & {
|
|
41
|
+
appVersion: string;
|
|
42
|
+
entryVersion: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type OnDownloading = (progress: DownloadingInfo) => void;
|
|
46
|
+
interface DownloadingInfo {
|
|
47
|
+
/**
|
|
48
|
+
* Download buffer delta
|
|
49
|
+
*/
|
|
50
|
+
delta: number;
|
|
51
|
+
/**
|
|
52
|
+
* Downloaded percent, 0 ~ 100
|
|
53
|
+
*
|
|
54
|
+
* If no `Content-Length` header, will be -1
|
|
55
|
+
*/
|
|
56
|
+
percent: number;
|
|
57
|
+
/**
|
|
58
|
+
* Total size
|
|
59
|
+
*
|
|
60
|
+
* If not `Content-Length` header, will be -1
|
|
61
|
+
*/
|
|
62
|
+
total: number;
|
|
63
|
+
/**
|
|
64
|
+
* Downloaded size
|
|
65
|
+
*/
|
|
66
|
+
transferred: number;
|
|
67
|
+
/**
|
|
68
|
+
* Download speed, bytes per second
|
|
69
|
+
*/
|
|
70
|
+
bps: number;
|
|
71
|
+
}
|
|
72
|
+
type UpdateJSONWithURL = UpdateInfoWithURL & {
|
|
73
|
+
beta: UpdateInfoWithURL;
|
|
74
|
+
};
|
|
75
|
+
interface IProvider {
|
|
76
|
+
/**
|
|
77
|
+
* Provider name
|
|
78
|
+
*/
|
|
79
|
+
name: string;
|
|
80
|
+
/**
|
|
81
|
+
* Download update json
|
|
82
|
+
* @param name app name
|
|
83
|
+
* @param versionPath normalized version path in project
|
|
84
|
+
* @param signal abort signal
|
|
85
|
+
*/
|
|
86
|
+
downloadJSON: (name: string, versionPath: string, signal: AbortSignal) => Promise<UpdateJSONWithURL>;
|
|
87
|
+
/**
|
|
88
|
+
* Download update asar
|
|
89
|
+
* @param updateInfo existing update info
|
|
90
|
+
* @param signal abort signal
|
|
91
|
+
* @param onDownloading hook for on downloading
|
|
92
|
+
*/
|
|
93
|
+
downloadAsar: (updateInfo: UpdateInfoWithURL, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void) => Promise<Buffer>;
|
|
94
|
+
/**
|
|
95
|
+
* Check the old version is less than new version
|
|
96
|
+
* @param oldVer old version string
|
|
97
|
+
* @param newVer new version string
|
|
98
|
+
*/
|
|
99
|
+
isLowerVersion: (oldVer: string, newVer: string) => boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Function to decompress file using brotli
|
|
102
|
+
* @param buffer compressed file buffer
|
|
103
|
+
*/
|
|
104
|
+
unzipFile: (buffer: Buffer) => Promise<Buffer>;
|
|
105
|
+
/**
|
|
106
|
+
* Verify asar signature,
|
|
107
|
+
* if signature is valid, returns the version, otherwise returns `undefined`
|
|
108
|
+
* @param buffer file buffer
|
|
109
|
+
* @param version target version
|
|
110
|
+
* @param signature signature
|
|
111
|
+
* @param cert certificate
|
|
112
|
+
*/
|
|
113
|
+
verifySignaure: (buffer: Buffer, version: string, signature: string, cert: string) => Promisable<boolean>;
|
|
114
|
+
}
|
|
115
|
+
type URLHandler = (url: URL) => Promisable<URL | string | undefined | null>;
|
|
116
|
+
|
|
117
|
+
export { type DownloadingInfo as D, type ErrorCode as E, type IProvider as I, type Logger as L, type OnDownloading as O, type UpdateInfoWithExtraVersion as U, type UnavailableCode as a, UpdaterError as b, type UpdaterOption as c, type UpdateJSONWithURL as d, type UpdateInfoWithURL as e, type URLHandler as f };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { bytecodeModuleLoader, compileToBytecode, convertArrowFunctionAndTemplate, convertLiteral, decodeFn, electronMajorVersion, electronModule, obfuscateString, toRelativePath, useStrict } from './chunk-AUY7A2FL.js';
|
|
2
|
+
import './chunk-7M7DIMDN.js';
|
|
3
|
+
import './chunk-5NKEXGI3.js';
|
|
4
|
+
import './chunk-7IRGAAL2.js';
|