electron-incremental-update 2.0.0-beta.3 → 2.0.0-beta.4
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/dist/{chunk-5WFXC5GU.js → chunk-JSYIRKTR.js} +17 -7
- package/dist/core-CW7TMqi7.d.cts +134 -0
- package/dist/core-D6QlpOgp.d.ts +134 -0
- package/dist/index.cjs +6 -12
- package/dist/index.d.cts +5 -135
- package/dist/index.d.ts +5 -135
- package/dist/index.js +8 -14
- package/dist/provider.cjs +20 -24
- package/dist/provider.d.cts +11 -10
- package/dist/provider.d.ts +11 -10
- package/dist/provider.js +17 -20
- package/dist/{types-DxhNaNgR.d.ts → types-Bz1VD18z.d.cts} +35 -5
- package/dist/{types-Tequ_V2o.d.cts → types-Bz1VD18z.d.ts} +35 -5
- package/dist/utils.cjs +14 -6
- package/dist/utils.d.cts +10 -4
- package/dist/utils.d.ts +10 -4
- package/dist/utils.js +7 -14
- package/dist/vite.d.ts +397 -0
- package/dist/vite.js +44 -28
- package/dist/{unzip-JjYLjJkH.d.ts → zip-WRrEMkgp.d.cts} +3 -2
- package/dist/{unzip-JjYLjJkH.d.cts → zip-WRrEMkgp.d.ts} +3 -2
- package/package.json +2 -2
- package/dist/version-CemSHimT.d.cts +0 -33
- package/dist/version-CemSHimT.d.ts +0 -33
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { isDev,
|
|
1
|
+
import { isDev, getEntryVersion, getAppVersion, getPathFromAppNameAsar, restartApp } from './chunk-PNYRQYFC.js';
|
|
2
2
|
import { isUpdateJSON, __require } from './chunk-BVFQWBLK.js';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import {
|
|
4
|
+
import { writeFileSync, existsSync, renameSync } from 'node:fs';
|
|
5
5
|
import { app } from 'electron';
|
|
6
6
|
import { EventEmitter } from 'node:events';
|
|
7
7
|
|
|
@@ -24,8 +24,6 @@ var UpdaterError = class extends Error {
|
|
|
24
24
|
var Updater = class extends EventEmitter {
|
|
25
25
|
CERT = __EIU_SIGNATURE_CERT__;
|
|
26
26
|
info;
|
|
27
|
-
asarPath;
|
|
28
|
-
tmpFilePath;
|
|
29
27
|
provider;
|
|
30
28
|
/**
|
|
31
29
|
* updater logger
|
|
@@ -63,14 +61,8 @@ var Updater = class extends EventEmitter {
|
|
|
63
61
|
};
|
|
64
62
|
this.logger.info("no logger set, enable dev-only logger");
|
|
65
63
|
}
|
|
66
|
-
this.asarPath = getPathFromAppNameAsar();
|
|
67
|
-
this.tmpFilePath = `${this.asarPath}.tmp`;
|
|
68
64
|
}
|
|
69
65
|
async fetch(format, data) {
|
|
70
|
-
if (existsSync(this.tmpFilePath)) {
|
|
71
|
-
this.logger?.warn(`remove tmp file: ${this.tmpFilePath}`);
|
|
72
|
-
rmSync(this.tmpFilePath);
|
|
73
|
-
}
|
|
74
66
|
if (typeof data === "object") {
|
|
75
67
|
if (format === "json" && isUpdateJSON(data) || format === "buffer" && Buffer.isBuffer(data)) {
|
|
76
68
|
return data;
|
|
@@ -132,7 +124,7 @@ var Updater = class extends EventEmitter {
|
|
|
132
124
|
this.emit("update-available", this.info);
|
|
133
125
|
return true;
|
|
134
126
|
}
|
|
135
|
-
async
|
|
127
|
+
async downloadUpdate(data, sig) {
|
|
136
128
|
const _sig = sig ?? this.info?.signature;
|
|
137
129
|
if (!_sig) {
|
|
138
130
|
this.err("download failed", "param", "no update signature, please call `checkUpdate` first");
|
|
@@ -151,8 +143,9 @@ var Updater = class extends EventEmitter {
|
|
|
151
143
|
}
|
|
152
144
|
this.logger?.debug("verify success");
|
|
153
145
|
try {
|
|
154
|
-
|
|
155
|
-
|
|
146
|
+
const tmpFilePath = getPathFromAppNameAsar() + ".tmp";
|
|
147
|
+
this.logger?.debug(`install to ${tmpFilePath}`);
|
|
148
|
+
writeFileSync(tmpFilePath, await this.provider.unzipFile(buffer));
|
|
156
149
|
this.logger?.info(`download success, version: ${_ver}`);
|
|
157
150
|
this.info = void 0;
|
|
158
151
|
this.emit("update-downloaded");
|
|
@@ -175,7 +168,8 @@ var Updater = class extends EventEmitter {
|
|
|
175
168
|
* @example
|
|
176
169
|
* updater.setURLHandler((url, isDownloadingAsar) => {
|
|
177
170
|
* if (isDownloadingAsar) {
|
|
178
|
-
*
|
|
171
|
+
* url.hostname = 'https://cdn.jsdelivr.net/gh'
|
|
172
|
+
* return url
|
|
179
173
|
* }
|
|
180
174
|
* })
|
|
181
175
|
*/
|
package/dist/provider.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var url = require('url');
|
|
3
4
|
var electron = require('electron');
|
|
4
5
|
var crypto = require('crypto');
|
|
5
|
-
var fs = require('fs');
|
|
6
6
|
var zlib = require('zlib');
|
|
7
7
|
|
|
8
|
-
// src/provider/
|
|
8
|
+
// src/provider/github.ts
|
|
9
9
|
|
|
10
10
|
// src/utils/version.ts
|
|
11
11
|
function parseVersion(version) {
|
|
@@ -127,14 +127,14 @@ function defaultVerify(buffer, signature, cert) {
|
|
|
127
127
|
return void 0;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
async function defaultUnzipFile(buffer
|
|
130
|
+
async function defaultUnzipFile(buffer) {
|
|
131
131
|
return new Promise((resolve, reject) => {
|
|
132
132
|
zlib.brotliDecompress(buffer, (err, buffer2) => {
|
|
133
133
|
if (err) {
|
|
134
134
|
reject(err);
|
|
135
|
+
} else {
|
|
136
|
+
resolve(buffer2);
|
|
135
137
|
}
|
|
136
|
-
fs.writeFileSync(targetFilePath, buffer2);
|
|
137
|
-
resolve();
|
|
138
138
|
});
|
|
139
139
|
});
|
|
140
140
|
}
|
|
@@ -149,11 +149,8 @@ var BaseProvider = class {
|
|
|
149
149
|
|
|
150
150
|
// src/provider/github.ts
|
|
151
151
|
var GitHubProvider = class extends BaseProvider {
|
|
152
|
-
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36";
|
|
153
152
|
name = "GithubProvider";
|
|
154
|
-
|
|
155
|
-
url;
|
|
156
|
-
extraHeaders;
|
|
153
|
+
options;
|
|
157
154
|
/**
|
|
158
155
|
* Update Provider for Github repo
|
|
159
156
|
* - download update json from `https://raw.githubusercontent.com/{user}/{repo}/HEAD/{versionPath}`
|
|
@@ -164,32 +161,31 @@ var GitHubProvider = class extends BaseProvider {
|
|
|
164
161
|
*/
|
|
165
162
|
constructor(options) {
|
|
166
163
|
super();
|
|
167
|
-
this.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
this.url += "/";
|
|
175
|
-
}
|
|
164
|
+
this.options = options;
|
|
165
|
+
}
|
|
166
|
+
get urlHandler() {
|
|
167
|
+
return this.options.urlHandler;
|
|
168
|
+
}
|
|
169
|
+
set urlHandler(handler) {
|
|
170
|
+
this.options.urlHandler = handler;
|
|
176
171
|
}
|
|
177
172
|
async parseURL(isDownloadAsar, extraPath) {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
173
|
+
const url$1 = new url.URL(
|
|
174
|
+
`/${this.options.username}/${this.options.repo}/${extraPath}`,
|
|
175
|
+
"https://" + (isDownloadAsar ? "github.com" : "raw.githubusercontent.com")
|
|
176
|
+
);
|
|
177
|
+
return (await this.urlHandler?.(url$1, isDownloadAsar) || url$1).toString();
|
|
182
178
|
}
|
|
183
179
|
async downloadJSON(versionPath) {
|
|
184
180
|
return await defaultDownloadUpdateJSON(
|
|
185
181
|
await this.parseURL(false, `HEAD/${versionPath}`),
|
|
186
|
-
{
|
|
182
|
+
{ accept: "application/json", ...this.options.extraHeaders }
|
|
187
183
|
);
|
|
188
184
|
}
|
|
189
185
|
async downloadAsar(name, { version, size }, onDownloading) {
|
|
190
186
|
return await defaultDownloadAsar(
|
|
191
187
|
await this.parseURL(true, `releases/download/v${version}/${name}-${version}.asar.gz`),
|
|
192
|
-
{
|
|
188
|
+
{ accept: "application/octet-stream", ...this.options.extraHeaders },
|
|
193
189
|
size,
|
|
194
190
|
onDownloading
|
|
195
191
|
);
|
package/dist/provider.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { d as defaultIsLowerVersion,
|
|
2
|
-
import {
|
|
3
|
-
import { e as defaultVerify, d as defaultUnzipFile } from './unzip-JjYLjJkH.cjs';
|
|
1
|
+
import { I as IProvider, d as defaultIsLowerVersion, a as UpdateJSON, U as UpdateInfo, D as DownloadingInfo, c as URLHandler, O as OnDownloading } from './types-Bz1VD18z.cjs';
|
|
2
|
+
import { f as defaultVerify, a as defaultUnzipFile } from './zip-WRrEMkgp.cjs';
|
|
4
3
|
import '@subframe7536/type-utils';
|
|
5
4
|
|
|
6
5
|
declare abstract class BaseProvider implements IProvider {
|
|
@@ -14,10 +13,13 @@ declare abstract class BaseProvider implements IProvider {
|
|
|
14
13
|
|
|
15
14
|
interface GitHubProviderOptions {
|
|
16
15
|
/**
|
|
17
|
-
* github
|
|
18
|
-
* @example 'https://github.com/electron/electron/'
|
|
16
|
+
* github user name
|
|
19
17
|
*/
|
|
20
|
-
|
|
18
|
+
username: string;
|
|
19
|
+
/**
|
|
20
|
+
* github repo name
|
|
21
|
+
*/
|
|
22
|
+
repo: string;
|
|
21
23
|
/**
|
|
22
24
|
* extra headers
|
|
23
25
|
*/
|
|
@@ -38,11 +40,8 @@ interface GitHubProviderOptions {
|
|
|
38
40
|
urlHandler?: URLHandler;
|
|
39
41
|
}
|
|
40
42
|
declare class GitHubProvider extends BaseProvider {
|
|
41
|
-
private ua;
|
|
42
43
|
name: string;
|
|
43
|
-
|
|
44
|
-
private url;
|
|
45
|
-
private extraHeaders?;
|
|
44
|
+
private options;
|
|
46
45
|
/**
|
|
47
46
|
* Update Provider for Github repo
|
|
48
47
|
* - download update json from `https://raw.githubusercontent.com/{user}/{repo}/HEAD/{versionPath}`
|
|
@@ -52,6 +51,8 @@ declare class GitHubProvider extends BaseProvider {
|
|
|
52
51
|
* @param options provider options
|
|
53
52
|
*/
|
|
54
53
|
constructor(options: GitHubProviderOptions);
|
|
54
|
+
get urlHandler(): URLHandler | undefined;
|
|
55
|
+
set urlHandler(handler: URLHandler);
|
|
55
56
|
private parseURL;
|
|
56
57
|
downloadJSON(versionPath: string): Promise<UpdateJSON>;
|
|
57
58
|
downloadAsar(name: string, { version, size }: UpdateInfo, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { d as defaultIsLowerVersion,
|
|
2
|
-
import {
|
|
3
|
-
import { e as defaultVerify, d as defaultUnzipFile } from './unzip-JjYLjJkH.js';
|
|
1
|
+
import { I as IProvider, d as defaultIsLowerVersion, a as UpdateJSON, U as UpdateInfo, D as DownloadingInfo, c as URLHandler, O as OnDownloading } from './types-Bz1VD18z.js';
|
|
2
|
+
import { f as defaultVerify, a as defaultUnzipFile } from './zip-WRrEMkgp.js';
|
|
4
3
|
import '@subframe7536/type-utils';
|
|
5
4
|
|
|
6
5
|
declare abstract class BaseProvider implements IProvider {
|
|
@@ -14,10 +13,13 @@ declare abstract class BaseProvider implements IProvider {
|
|
|
14
13
|
|
|
15
14
|
interface GitHubProviderOptions {
|
|
16
15
|
/**
|
|
17
|
-
* github
|
|
18
|
-
* @example 'https://github.com/electron/electron/'
|
|
16
|
+
* github user name
|
|
19
17
|
*/
|
|
20
|
-
|
|
18
|
+
username: string;
|
|
19
|
+
/**
|
|
20
|
+
* github repo name
|
|
21
|
+
*/
|
|
22
|
+
repo: string;
|
|
21
23
|
/**
|
|
22
24
|
* extra headers
|
|
23
25
|
*/
|
|
@@ -38,11 +40,8 @@ interface GitHubProviderOptions {
|
|
|
38
40
|
urlHandler?: URLHandler;
|
|
39
41
|
}
|
|
40
42
|
declare class GitHubProvider extends BaseProvider {
|
|
41
|
-
private ua;
|
|
42
43
|
name: string;
|
|
43
|
-
|
|
44
|
-
private url;
|
|
45
|
-
private extraHeaders?;
|
|
44
|
+
private options;
|
|
46
45
|
/**
|
|
47
46
|
* Update Provider for Github repo
|
|
48
47
|
* - download update json from `https://raw.githubusercontent.com/{user}/{repo}/HEAD/{versionPath}`
|
|
@@ -52,6 +51,8 @@ declare class GitHubProvider extends BaseProvider {
|
|
|
52
51
|
* @param options provider options
|
|
53
52
|
*/
|
|
54
53
|
constructor(options: GitHubProviderOptions);
|
|
54
|
+
get urlHandler(): URLHandler | undefined;
|
|
55
|
+
set urlHandler(handler: URLHandler);
|
|
55
56
|
private parseURL;
|
|
56
57
|
downloadJSON(versionPath: string): Promise<UpdateJSON>;
|
|
57
58
|
downloadAsar(name: string, { version, size }: UpdateInfo, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
|
package/dist/provider.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { defaultVerify, defaultUnzipFile } from './chunk-
|
|
1
|
+
import { defaultVerify, defaultUnzipFile } from './chunk-JSYIRKTR.js';
|
|
2
2
|
import { defaultIsLowerVersion, isUpdateJSON } from './chunk-BVFQWBLK.js';
|
|
3
|
+
import { URL } from 'node:url';
|
|
3
4
|
import { app, net } from 'electron';
|
|
4
5
|
|
|
5
6
|
async function downloadFn(url, headers, onResponse) {
|
|
@@ -66,11 +67,8 @@ var BaseProvider = class {
|
|
|
66
67
|
|
|
67
68
|
// src/provider/github.ts
|
|
68
69
|
var GitHubProvider = class extends BaseProvider {
|
|
69
|
-
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36";
|
|
70
70
|
name = "GithubProvider";
|
|
71
|
-
|
|
72
|
-
url;
|
|
73
|
-
extraHeaders;
|
|
71
|
+
options;
|
|
74
72
|
/**
|
|
75
73
|
* Update Provider for Github repo
|
|
76
74
|
* - download update json from `https://raw.githubusercontent.com/{user}/{repo}/HEAD/{versionPath}`
|
|
@@ -81,32 +79,31 @@ var GitHubProvider = class extends BaseProvider {
|
|
|
81
79
|
*/
|
|
82
80
|
constructor(options) {
|
|
83
81
|
super();
|
|
84
|
-
this.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
this.url += "/";
|
|
92
|
-
}
|
|
82
|
+
this.options = options;
|
|
83
|
+
}
|
|
84
|
+
get urlHandler() {
|
|
85
|
+
return this.options.urlHandler;
|
|
86
|
+
}
|
|
87
|
+
set urlHandler(handler) {
|
|
88
|
+
this.options.urlHandler = handler;
|
|
93
89
|
}
|
|
94
90
|
async parseURL(isDownloadAsar, extraPath) {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
const url = new URL(
|
|
92
|
+
`/${this.options.username}/${this.options.repo}/${extraPath}`,
|
|
93
|
+
"https://" + (isDownloadAsar ? "github.com" : "raw.githubusercontent.com")
|
|
94
|
+
);
|
|
95
|
+
return (await this.urlHandler?.(url, isDownloadAsar) || url).toString();
|
|
99
96
|
}
|
|
100
97
|
async downloadJSON(versionPath) {
|
|
101
98
|
return await defaultDownloadUpdateJSON(
|
|
102
99
|
await this.parseURL(false, `HEAD/${versionPath}`),
|
|
103
|
-
{
|
|
100
|
+
{ accept: "application/json", ...this.options.extraHeaders }
|
|
104
101
|
);
|
|
105
102
|
}
|
|
106
103
|
async downloadAsar(name, { version, size }, onDownloading) {
|
|
107
104
|
return await defaultDownloadAsar(
|
|
108
105
|
await this.parseURL(true, `releases/download/v${version}/${name}-${version}.asar.gz`),
|
|
109
|
-
{
|
|
106
|
+
{ accept: "application/octet-stream", ...this.options.extraHeaders },
|
|
110
107
|
size,
|
|
111
108
|
onDownloading
|
|
112
109
|
);
|
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
import { Promisable } from '@subframe7536/type-utils';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* handle all unhandled error
|
|
5
|
+
* @param callback callback function
|
|
6
|
+
*/
|
|
7
|
+
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
8
|
+
interface Version {
|
|
9
|
+
major: number;
|
|
10
|
+
minor: number;
|
|
11
|
+
patch: number;
|
|
12
|
+
stage: string;
|
|
13
|
+
stageVersion: number;
|
|
14
|
+
}
|
|
15
|
+
declare function parseVersion(version: string): Version;
|
|
16
|
+
declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* update info json
|
|
19
|
+
*/
|
|
20
|
+
type UpdateInfo = {
|
|
21
|
+
signature: string;
|
|
22
|
+
minimumVersion: string;
|
|
23
|
+
version: string;
|
|
24
|
+
size: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* {@link UpdateInfo} with beta
|
|
28
|
+
*/
|
|
29
|
+
type UpdateJSON = UpdateInfo & {
|
|
30
|
+
beta: UpdateInfo;
|
|
31
|
+
};
|
|
32
|
+
declare function isUpdateJSON(json: any): json is UpdateJSON;
|
|
33
|
+
declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, buffer: Buffer, signature: string, version: string, minimumVersion: string): UpdateJSON;
|
|
3
34
|
|
|
4
35
|
type URLHandler = (url: URL, isDownloadAsar: boolean) => Promisable<URL | string | undefined | null>;
|
|
5
36
|
type OnDownloading = (progress: DownloadingInfo) => void;
|
|
@@ -57,11 +88,10 @@ interface IProvider {
|
|
|
57
88
|
*/
|
|
58
89
|
isLowerVersion: (oldVer: string, newVer: string) => boolean;
|
|
59
90
|
/**
|
|
60
|
-
* unzip file
|
|
91
|
+
* unzip file buffer
|
|
61
92
|
* @param buffer source buffer
|
|
62
|
-
* @param targetFilePath target file path
|
|
63
93
|
*/
|
|
64
|
-
unzipFile: (buffer: Buffer
|
|
94
|
+
unzipFile: (buffer: Buffer) => Promise<Buffer>;
|
|
65
95
|
/**
|
|
66
96
|
* verify asar signature
|
|
67
97
|
* @param buffer file buffer
|
|
@@ -72,4 +102,4 @@ interface IProvider {
|
|
|
72
102
|
verifySignaure: (buffer: Buffer, signature: string, cert: string) => Promisable<string | undefined>;
|
|
73
103
|
}
|
|
74
104
|
|
|
75
|
-
export type
|
|
105
|
+
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, handleUnexpectedErrors as h, isUpdateJSON as i, parseVersion as p };
|
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
import { Promisable } from '@subframe7536/type-utils';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* handle all unhandled error
|
|
5
|
+
* @param callback callback function
|
|
6
|
+
*/
|
|
7
|
+
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
8
|
+
interface Version {
|
|
9
|
+
major: number;
|
|
10
|
+
minor: number;
|
|
11
|
+
patch: number;
|
|
12
|
+
stage: string;
|
|
13
|
+
stageVersion: number;
|
|
14
|
+
}
|
|
15
|
+
declare function parseVersion(version: string): Version;
|
|
16
|
+
declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* update info json
|
|
19
|
+
*/
|
|
20
|
+
type UpdateInfo = {
|
|
21
|
+
signature: string;
|
|
22
|
+
minimumVersion: string;
|
|
23
|
+
version: string;
|
|
24
|
+
size: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* {@link UpdateInfo} with beta
|
|
28
|
+
*/
|
|
29
|
+
type UpdateJSON = UpdateInfo & {
|
|
30
|
+
beta: UpdateInfo;
|
|
31
|
+
};
|
|
32
|
+
declare function isUpdateJSON(json: any): json is UpdateJSON;
|
|
33
|
+
declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, buffer: Buffer, signature: string, version: string, minimumVersion: string): UpdateJSON;
|
|
3
34
|
|
|
4
35
|
type URLHandler = (url: URL, isDownloadAsar: boolean) => Promisable<URL | string | undefined | null>;
|
|
5
36
|
type OnDownloading = (progress: DownloadingInfo) => void;
|
|
@@ -57,11 +88,10 @@ interface IProvider {
|
|
|
57
88
|
*/
|
|
58
89
|
isLowerVersion: (oldVer: string, newVer: string) => boolean;
|
|
59
90
|
/**
|
|
60
|
-
* unzip file
|
|
91
|
+
* unzip file buffer
|
|
61
92
|
* @param buffer source buffer
|
|
62
|
-
* @param targetFilePath target file path
|
|
63
93
|
*/
|
|
64
|
-
unzipFile: (buffer: Buffer
|
|
94
|
+
unzipFile: (buffer: Buffer) => Promise<Buffer>;
|
|
65
95
|
/**
|
|
66
96
|
* verify asar signature
|
|
67
97
|
* @param buffer file buffer
|
|
@@ -72,4 +102,4 @@ interface IProvider {
|
|
|
72
102
|
verifySignaure: (buffer: Buffer, signature: string, cert: string) => Promisable<string | undefined>;
|
|
73
103
|
}
|
|
74
104
|
|
|
75
|
-
export type
|
|
105
|
+
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, handleUnexpectedErrors as h, isUpdateJSON as i, parseVersion as p };
|
package/dist/utils.cjs
CHANGED
|
@@ -82,25 +82,25 @@ function getPathFromPublic(...paths) {
|
|
|
82
82
|
function getPathFromEntryAsar(...paths) {
|
|
83
83
|
return path.join(electron.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, ...paths);
|
|
84
84
|
}
|
|
85
|
-
async function defaultZipFile(buffer
|
|
85
|
+
async function defaultZipFile(buffer) {
|
|
86
86
|
return new Promise((resolve, reject) => {
|
|
87
87
|
zlib.brotliCompress(buffer, (err, buffer2) => {
|
|
88
88
|
if (err) {
|
|
89
89
|
reject(err);
|
|
90
|
+
} else {
|
|
91
|
+
resolve(buffer2);
|
|
90
92
|
}
|
|
91
|
-
fs.writeFileSync(targetFilePath, buffer2);
|
|
92
|
-
resolve();
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
async function defaultUnzipFile(buffer
|
|
96
|
+
async function defaultUnzipFile(buffer) {
|
|
97
97
|
return new Promise((resolve, reject) => {
|
|
98
98
|
zlib.brotliDecompress(buffer, (err, buffer2) => {
|
|
99
99
|
if (err) {
|
|
100
100
|
reject(err);
|
|
101
|
+
} else {
|
|
102
|
+
resolve(buffer2);
|
|
101
103
|
}
|
|
102
|
-
fs.writeFileSync(targetFilePath, buffer2);
|
|
103
|
-
resolve();
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
106
|
}
|
|
@@ -198,8 +198,16 @@ function defaultVerify(buffer, signature, cert) {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
// src/utils/updater.ts
|
|
202
|
+
async function autoUpdate(updater) {
|
|
203
|
+
if (await updater.checkUpdate() && await updater.downloadUpdate()) {
|
|
204
|
+
updater.quitAndInstall();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
201
208
|
exports.aesDecrypt = aesDecrypt;
|
|
202
209
|
exports.aesEncrypt = aesEncrypt;
|
|
210
|
+
exports.autoUpdate = autoUpdate;
|
|
203
211
|
exports.defaultIsLowerVersion = defaultIsLowerVersion;
|
|
204
212
|
exports.defaultSignature = defaultSignature;
|
|
205
213
|
exports.defaultUnzipFile = defaultUnzipFile;
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { BrowserWindow } from 'electron';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
2
|
+
export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerify, d as defaultZipFile, h as hashBuffer } from './zip-WRrEMkgp.cjs';
|
|
3
|
+
export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, h as handleUnexpectedErrors, i as isUpdateJSON, p as parseVersion } from './types-Bz1VD18z.cjs';
|
|
4
|
+
import { U as Updater } from './core-CW7TMqi7.cjs';
|
|
5
|
+
import '@subframe7536/type-utils';
|
|
6
|
+
import 'node:events';
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* compile time dev check
|
|
@@ -64,6 +67,9 @@ declare function getPathFromPreload(...paths: string[]): string;
|
|
|
64
67
|
declare function getPathFromPublic(...paths: string[]): string;
|
|
65
68
|
declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
66
69
|
|
|
67
|
-
|
|
70
|
+
/**
|
|
71
|
+
* auto check update, download and install
|
|
72
|
+
*/
|
|
73
|
+
declare function autoUpdate(updater: Updater): Promise<void>;
|
|
68
74
|
|
|
69
|
-
export {
|
|
75
|
+
export { autoUpdate, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { BrowserWindow } from 'electron';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
2
|
+
export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerify, d as defaultZipFile, h as hashBuffer } from './zip-WRrEMkgp.js';
|
|
3
|
+
export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, h as handleUnexpectedErrors, i as isUpdateJSON, p as parseVersion } from './types-Bz1VD18z.js';
|
|
4
|
+
import { U as Updater } from './core-D6QlpOgp.js';
|
|
5
|
+
import '@subframe7536/type-utils';
|
|
6
|
+
import 'node:events';
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* compile time dev check
|
|
@@ -64,6 +67,9 @@ declare function getPathFromPreload(...paths: string[]): string;
|
|
|
64
67
|
declare function getPathFromPublic(...paths: string[]): string;
|
|
65
68
|
declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
66
69
|
|
|
67
|
-
|
|
70
|
+
/**
|
|
71
|
+
* auto check update, download and install
|
|
72
|
+
*/
|
|
73
|
+
declare function autoUpdate(updater: Updater): Promise<void>;
|
|
68
74
|
|
|
69
|
-
export {
|
|
75
|
+
export { autoUpdate, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
|
package/dist/utils.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance } from './chunk-PNYRQYFC.js';
|
|
2
|
-
export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerify, hashBuffer } from './chunk-
|
|
2
|
+
export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerify, defaultZipFile, hashBuffer } from './chunk-JSYIRKTR.js';
|
|
3
3
|
export { defaultIsLowerVersion, defaultVersionJsonGenerator, handleUnexpectedErrors, isUpdateJSON, parseVersion } from './chunk-BVFQWBLK.js';
|
|
4
|
-
import { writeFileSync } from 'node:fs';
|
|
5
|
-
import { brotliCompress } from 'node:zlib';
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
writeFileSync(targetFilePath, buffer2);
|
|
14
|
-
resolve();
|
|
15
|
-
});
|
|
16
|
-
});
|
|
5
|
+
// src/utils/updater.ts
|
|
6
|
+
async function autoUpdate(updater) {
|
|
7
|
+
if (await updater.checkUpdate() && await updater.downloadUpdate()) {
|
|
8
|
+
updater.quitAndInstall();
|
|
9
|
+
}
|
|
17
10
|
}
|
|
18
11
|
|
|
19
|
-
export {
|
|
12
|
+
export { autoUpdate };
|