electron-incremental-update 2.0.0-beta.1 → 2.0.0-beta.3

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/utils.cjs CHANGED
@@ -1,168 +1,106 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
19
2
 
20
- // src/utils/index.ts
21
- var utils_exports = {};
22
- __export(utils_exports, {
23
- decrypt: () => decrypt,
24
- disableHWAccForWin7: () => disableHWAccForWin7,
25
- encrypt: () => encrypt,
26
- getAppVersion: () => getAppVersion,
27
- getEntryVersion: () => getEntryVersion,
28
- getPathFromAppNameAsar: () => getPathFromAppNameAsar,
29
- getPathFromEntryAsar: () => getPathFromEntryAsar,
30
- getPathFromPreload: () => getPathFromPreload,
31
- getPathFromPublic: () => getPathFromPublic,
32
- handleUnexpectedErrors: () => handleUnexpectedErrors,
33
- hashString: () => hashString,
34
- isDev: () => isDev,
35
- isLinux: () => isLinux,
36
- isLowerVersionDefault: () => isLowerVersionDefault,
37
- isMac: () => isMac,
38
- isUpdateJSON: () => isUpdateJSON,
39
- isWin: () => isWin,
40
- loadPage: () => loadPage,
41
- parseVersion: () => parseVersion,
42
- requireNative: () => requireNative,
43
- restartApp: () => restartApp,
44
- setAppUserModelId: () => setAppUserModelId,
45
- setPortableAppDataPath: () => setPortableAppDataPath,
46
- signature: () => signature,
47
- singleInstance: () => singleInstance,
48
- unzipFile: () => unzipFile,
49
- verifySignatureDefault: () => verifySignatureDefault,
50
- waitAppReady: () => waitAppReady,
51
- zipFile: () => zipFile
52
- });
53
- module.exports = __toCommonJS(utils_exports);
3
+ var fs = require('fs');
4
+ var path = require('path');
5
+ var electron = require('electron');
6
+ var zlib = require('zlib');
7
+ var crypto = require('crypto');
54
8
 
55
- // src/utils/electron.ts
56
- var import_node_fs = require("fs");
57
- var import_node_path = require("path");
58
- var import_electron = require("electron");
9
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
+ }) : x)(function(x) {
12
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
59
15
  var isDev = __EIU_IS_DEV__;
60
16
  var isWin = process.platform === "win32";
61
17
  var isMac = process.platform === "darwin";
62
18
  var isLinux = process.platform === "linux";
63
- function getPathFromAppNameAsar(...path) {
64
- return isDev ? "DEV.asar" : (0, import_node_path.join)((0, import_node_path.dirname)(import_electron.app.getAppPath()), `${import_electron.app.name}.asar`, ...path);
19
+ function getPathFromAppNameAsar(...path$1) {
20
+ return isDev ? "DEV.asar" : path.join(path.dirname(electron.app.getAppPath()), `${electron.app.name}.asar`, ...path$1);
65
21
  }
66
22
  function getAppVersion() {
67
- return isDev ? getEntryVersion() : (0, import_node_fs.readFileSync)(getPathFromAppNameAsar("version"), "utf-8");
23
+ return isDev ? getEntryVersion() : fs.readFileSync(getPathFromAppNameAsar("version"), "utf-8");
68
24
  }
69
25
  function getEntryVersion() {
70
- return import_electron.app.getVersion();
26
+ return electron.app.getVersion();
71
27
  }
72
28
  function requireNative(moduleName) {
73
- return require((0, import_node_path.join)(import_electron.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, moduleName));
29
+ return __require(path.join(electron.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, moduleName));
74
30
  }
75
31
  function restartApp() {
76
- import_electron.app.relaunch();
77
- import_electron.app.quit();
32
+ electron.app.relaunch();
33
+ electron.app.quit();
78
34
  }
79
35
  function setAppUserModelId(id) {
80
- isWin && import_electron.app.setAppUserModelId(id ?? `org.${import_electron.app.name}`);
36
+ if (isWin) {
37
+ electron.app.setAppUserModelId(id ?? `org.${electron.app.name}`);
38
+ }
81
39
  }
82
40
  function disableHWAccForWin7() {
83
- if (require("os").release().startsWith("6.1")) {
84
- import_electron.app.disableHardwareAcceleration();
41
+ if (__require("os").release().startsWith("6.1")) {
42
+ electron.app.disableHardwareAcceleration();
85
43
  }
86
44
  }
87
45
  function singleInstance(window) {
88
- const result = import_electron.app.requestSingleInstanceLock();
89
- result ? import_electron.app.on("second-instance", () => {
90
- if (window) {
91
- window.show();
92
- if (window.isMinimized()) {
93
- window.restore();
46
+ const result = electron.app.requestSingleInstanceLock();
47
+ if (result) {
48
+ electron.app.on("second-instance", () => {
49
+ if (window) {
50
+ window.show();
51
+ if (window.isMinimized()) {
52
+ window.restore();
53
+ }
54
+ window.focus();
94
55
  }
95
- window.focus();
96
- }
97
- }) : import_electron.app.quit();
56
+ });
57
+ } else {
58
+ electron.app.quit();
59
+ }
98
60
  return result;
99
61
  }
100
62
  function setPortableAppDataPath(dirName = "data") {
101
- const portablePath = (0, import_node_path.join)((0, import_node_path.dirname)(import_electron.app.getPath("exe")), dirName);
102
- if (!(0, import_node_fs.existsSync)(portablePath)) {
103
- (0, import_node_fs.mkdirSync)(portablePath);
63
+ const portablePath = path.join(path.dirname(electron.app.getPath("exe")), dirName);
64
+ if (!fs.existsSync(portablePath)) {
65
+ fs.mkdirSync(portablePath);
104
66
  }
105
- import_electron.app.setPath("appData", portablePath);
106
- }
107
- function waitAppReady(timeout = 1e3) {
108
- return import_electron.app.isReady() ? Promise.resolve() : new Promise((resolve, reject) => {
109
- const _ = setTimeout(() => {
110
- reject(new Error("app is not ready"));
111
- }, timeout);
112
- import_electron.app.whenReady().then(() => {
113
- clearTimeout(_);
114
- resolve();
115
- });
116
- });
67
+ electron.app.setPath("appData", portablePath);
117
68
  }
118
69
  function loadPage(win, htmlFilePath = "index.html") {
119
- isDev ? win.loadURL(process.env.VITE_DEV_SERVER_URL + htmlFilePath) : win.loadFile(getPathFromAppNameAsar("renderer", htmlFilePath));
70
+ if (isDev) {
71
+ win.loadURL(process.env.VITE_DEV_SERVER_URL + htmlFilePath);
72
+ } else {
73
+ win.loadFile(getPathFromAppNameAsar("renderer", htmlFilePath));
74
+ }
120
75
  }
121
76
  function getPathFromPreload(...paths) {
122
- return isDev ? (0, import_node_path.join)(import_electron.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "preload", ...paths) : getPathFromAppNameAsar("preload", ...paths);
77
+ return isDev ? path.join(electron.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "preload", ...paths) : getPathFromAppNameAsar("preload", ...paths);
123
78
  }
124
79
  function getPathFromPublic(...paths) {
125
- return isDev ? (0, import_node_path.join)(import_electron.app.getAppPath(), "public", ...paths) : getPathFromAppNameAsar("renderer", ...paths);
80
+ return isDev ? path.join(electron.app.getAppPath(), "public", ...paths) : getPathFromAppNameAsar("renderer", ...paths);
126
81
  }
127
82
  function getPathFromEntryAsar(...paths) {
128
- return (0, import_node_path.join)(import_electron.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, ...paths);
83
+ return path.join(electron.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, ...paths);
129
84
  }
130
-
131
- // src/utils/zip.ts
132
- var import_node_fs2 = require("fs");
133
- var import_node_zlib = require("zlib");
134
- async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
135
- if (!(0, import_node_fs2.existsSync)(filePath)) {
136
- throw new Error(`path to be zipped not exist: ${filePath}`);
137
- }
138
- const buffer = (0, import_node_fs2.readFileSync)(filePath);
85
+ async function defaultZipFile(buffer, targetFilePath) {
139
86
  return new Promise((resolve, reject) => {
140
- (0, import_node_zlib.brotliCompress)(buffer, (err, buffer2) => {
87
+ zlib.brotliCompress(buffer, (err, buffer2) => {
141
88
  if (err) {
142
89
  reject(err);
143
90
  }
144
- (0, import_node_fs2.writeFileSync)(targetFilePath, buffer2);
145
- resolve(null);
91
+ fs.writeFileSync(targetFilePath, buffer2);
92
+ resolve();
146
93
  });
147
94
  });
148
95
  }
149
-
150
- // src/utils/unzip.ts
151
- var import_node_fs3 = require("fs");
152
- var import_node_zlib2 = require("zlib");
153
- async function unzipFile(gzipPath, targetFilePath = gzipPath.slice(0, -3)) {
154
- if (!(0, import_node_fs3.existsSync)(gzipPath)) {
155
- throw new Error(`path to zipped file not exist: ${gzipPath}`);
156
- }
157
- const compressedBuffer = (0, import_node_fs3.readFileSync)(gzipPath);
96
+ async function defaultUnzipFile(buffer, targetFilePath) {
158
97
  return new Promise((resolve, reject) => {
159
- (0, import_node_zlib2.brotliDecompress)(compressedBuffer, (err, buffer) => {
160
- (0, import_node_fs3.rmSync)(gzipPath);
98
+ zlib.brotliDecompress(buffer, (err, buffer2) => {
161
99
  if (err) {
162
100
  reject(err);
163
101
  }
164
- (0, import_node_fs3.writeFileSync)(targetFilePath, buffer);
165
- resolve(null);
102
+ fs.writeFileSync(targetFilePath, buffer2);
103
+ resolve();
166
104
  });
167
105
  });
168
106
  }
@@ -195,7 +133,7 @@ function parseVersion(version) {
195
133
  }
196
134
  return ret;
197
135
  }
198
- function isLowerVersionDefault(oldVer, newVer) {
136
+ function defaultIsLowerVersion(oldVer, newVer) {
199
137
  const oldV = parseVersion(oldVer);
200
138
  const newV = parseVersion(newVer);
201
139
  function compareStrings(str1, str2) {
@@ -219,75 +157,73 @@ function isUpdateJSON(json) {
219
157
  const is = (j) => !!(j && j.minimumVersion && j.signature && j.size && j.version);
220
158
  return is(json) && is(json?.beta);
221
159
  }
222
-
223
- // src/utils/crypto/decrypt.ts
224
- var import_node_crypto2 = require("crypto");
225
-
226
- // src/utils/crypto/utils.ts
227
- var import_node_crypto = require("crypto");
228
- function hashString(data, length) {
229
- const hash = (0, import_node_crypto.createHash)("SHA256").update(data).digest("binary");
160
+ function defaultVersionJsonGenerator(existingJson, buffer, signature, version, minimumVersion) {
161
+ existingJson.beta = {
162
+ version,
163
+ minimumVersion,
164
+ signature,
165
+ size: buffer.length
166
+ };
167
+ if (!parseVersion(version).stage) {
168
+ existingJson.version = version;
169
+ existingJson.minimumVersion = minimumVersion;
170
+ existingJson.signature = signature;
171
+ existingJson.size = buffer.length;
172
+ }
173
+ return existingJson;
174
+ }
175
+ function hashBuffer(data, length) {
176
+ const hash = crypto.createHash("SHA256").update(data).digest("binary");
230
177
  return Buffer.from(hash).subarray(0, length);
231
178
  }
232
-
233
- // src/utils/crypto/decrypt.ts
234
- function decrypt(encryptedText, key, iv) {
235
- const decipher = (0, import_node_crypto2.createDecipheriv)("aes-256-cbc", key, iv);
236
- let decrypted = decipher.update(encryptedText, "base64url", "utf8");
237
- decrypted += decipher.final("utf8");
238
- return decrypted;
179
+ function aesEncrypt(plainText, key, iv) {
180
+ const cipher = crypto.createCipheriv("aes-256-cbc", key, iv);
181
+ return cipher.update(plainText, "utf8", "base64url") + cipher.final("base64url");
182
+ }
183
+ function defaultSignature(buffer, privateKey, cert, version) {
184
+ const sig = crypto.createSign("RSA-SHA256").update(buffer).sign(crypto.createPrivateKey(privateKey), "base64");
185
+ return aesEncrypt(`${sig}%${version}`, hashBuffer(cert, 32), hashBuffer(buffer, 16));
186
+ }
187
+ function aesDecrypt(encryptedText, key, iv) {
188
+ const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
189
+ return decipher.update(encryptedText, "base64url", "utf8") + decipher.final("utf8");
239
190
  }
240
- function verifySignatureDefault(buffer, signature2, cert) {
191
+ function defaultVerify(buffer, signature, cert) {
241
192
  try {
242
- const [sig, version] = decrypt(signature2, hashString(cert, 32), hashString(buffer, 16)).split("%");
243
- const result = (0, import_node_crypto2.createVerify)("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
193
+ const [sig, version] = aesDecrypt(signature, hashBuffer(cert, 32), hashBuffer(buffer, 16)).split("%");
194
+ const result = crypto.createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
244
195
  return result ? version : void 0;
245
- } catch (error) {
196
+ } catch {
246
197
  return void 0;
247
198
  }
248
199
  }
249
200
 
250
- // src/utils/crypto/encrypt.ts
251
- var import_node_crypto3 = require("crypto");
252
- function encrypt(plainText, key, iv) {
253
- const cipher = (0, import_node_crypto3.createCipheriv)("aes-256-cbc", key, iv);
254
- let encrypted = cipher.update(plainText, "utf8", "base64url");
255
- encrypted += cipher.final("base64url");
256
- return encrypted;
257
- }
258
- function signature(buffer, privateKey, cert, version) {
259
- const sig = (0, import_node_crypto3.createSign)("RSA-SHA256").update(buffer).sign((0, import_node_crypto3.createPrivateKey)(privateKey), "base64");
260
- return encrypt(`${sig}%${version}`, hashString(cert, 32), hashString(buffer, 16));
261
- }
262
- // Annotate the CommonJS export names for ESM import in node:
263
- 0 && (module.exports = {
264
- decrypt,
265
- disableHWAccForWin7,
266
- encrypt,
267
- getAppVersion,
268
- getEntryVersion,
269
- getPathFromAppNameAsar,
270
- getPathFromEntryAsar,
271
- getPathFromPreload,
272
- getPathFromPublic,
273
- handleUnexpectedErrors,
274
- hashString,
275
- isDev,
276
- isLinux,
277
- isLowerVersionDefault,
278
- isMac,
279
- isUpdateJSON,
280
- isWin,
281
- loadPage,
282
- parseVersion,
283
- requireNative,
284
- restartApp,
285
- setAppUserModelId,
286
- setPortableAppDataPath,
287
- signature,
288
- singleInstance,
289
- unzipFile,
290
- verifySignatureDefault,
291
- waitAppReady,
292
- zipFile
293
- });
201
+ exports.aesDecrypt = aesDecrypt;
202
+ exports.aesEncrypt = aesEncrypt;
203
+ exports.defaultIsLowerVersion = defaultIsLowerVersion;
204
+ exports.defaultSignature = defaultSignature;
205
+ exports.defaultUnzipFile = defaultUnzipFile;
206
+ exports.defaultVerify = defaultVerify;
207
+ exports.defaultVersionJsonGenerator = defaultVersionJsonGenerator;
208
+ exports.defaultZipFile = defaultZipFile;
209
+ exports.disableHWAccForWin7 = disableHWAccForWin7;
210
+ exports.getAppVersion = getAppVersion;
211
+ exports.getEntryVersion = getEntryVersion;
212
+ exports.getPathFromAppNameAsar = getPathFromAppNameAsar;
213
+ exports.getPathFromEntryAsar = getPathFromEntryAsar;
214
+ exports.getPathFromPreload = getPathFromPreload;
215
+ exports.getPathFromPublic = getPathFromPublic;
216
+ exports.handleUnexpectedErrors = handleUnexpectedErrors;
217
+ exports.hashBuffer = hashBuffer;
218
+ exports.isDev = isDev;
219
+ exports.isLinux = isLinux;
220
+ exports.isMac = isMac;
221
+ exports.isUpdateJSON = isUpdateJSON;
222
+ exports.isWin = isWin;
223
+ exports.loadPage = loadPage;
224
+ exports.parseVersion = parseVersion;
225
+ exports.requireNative = requireNative;
226
+ exports.restartApp = restartApp;
227
+ exports.setAppUserModelId = setAppUserModelId;
228
+ exports.setPortableAppDataPath = setPortableAppDataPath;
229
+ exports.singleInstance = singleInstance;
package/dist/utils.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { BrowserWindow } from 'electron';
2
- export { a as UpdateInfo, U as UpdateJSON, V as Version, h as handleUnexpectedErrors, i as isLowerVersionDefault, b as isUpdateJSON, p as parseVersion } from './version-CffZWDhZ.cjs';
3
- export { d as decrypt, v as verifySignatureDefault } from './decrypt-BNBcodiO.cjs';
2
+ export { c as aesDecrypt, a as aesEncrypt, b as defaultSignature, d as defaultUnzipFile, e as defaultVerify, h as hashBuffer } from './unzip-JjYLjJkH.cjs';
3
+ export { a as UpdateInfo, U as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, h as handleUnexpectedErrors, i as isUpdateJSON, p as parseVersion } from './version-CemSHimT.cjs';
4
4
 
5
5
  /**
6
6
  * compile time dev check
@@ -54,11 +54,6 @@ declare function singleInstance(window?: BrowserWindow): boolean;
54
54
  * @param dirName dir name, default to `data`
55
55
  */
56
56
  declare function setPortableAppDataPath(dirName?: string): void;
57
- /**
58
- * ensure app is ready.
59
- * @param timeout wait timeout, @default 1000
60
- */
61
- declare function waitAppReady(timeout?: number): Promise<void>;
62
57
  /**
63
58
  * load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
64
59
  * @param win window
@@ -69,13 +64,6 @@ declare function getPathFromPreload(...paths: string[]): string;
69
64
  declare function getPathFromPublic(...paths: string[]): string;
70
65
  declare function getPathFromEntryAsar(...paths: string[]): string;
71
66
 
72
- declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
73
-
74
- declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
75
-
76
- declare function encrypt(plainText: string, key: Buffer, iv: Buffer): string;
77
- declare function signature(buffer: Buffer, privateKey: string, cert: string, version: string): string;
78
-
79
- declare function hashString(data: string | Buffer, length: number): Buffer;
67
+ declare function defaultZipFile(buffer: Buffer, targetFilePath: string): Promise<void>;
80
68
 
81
- export { disableHWAccForWin7, encrypt, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, hashString, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, signature, singleInstance, unzipFile, waitAppReady, zipFile };
69
+ export { defaultZipFile, 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,6 @@
1
1
  import { BrowserWindow } from 'electron';
2
- export { a as UpdateInfo, U as UpdateJSON, V as Version, h as handleUnexpectedErrors, i as isLowerVersionDefault, b as isUpdateJSON, p as parseVersion } from './version-CffZWDhZ.js';
3
- export { d as decrypt, v as verifySignatureDefault } from './decrypt-BNBcodiO.js';
2
+ export { c as aesDecrypt, a as aesEncrypt, b as defaultSignature, d as defaultUnzipFile, e as defaultVerify, h as hashBuffer } from './unzip-JjYLjJkH.js';
3
+ export { a as UpdateInfo, U as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, h as handleUnexpectedErrors, i as isUpdateJSON, p as parseVersion } from './version-CemSHimT.js';
4
4
 
5
5
  /**
6
6
  * compile time dev check
@@ -54,11 +54,6 @@ declare function singleInstance(window?: BrowserWindow): boolean;
54
54
  * @param dirName dir name, default to `data`
55
55
  */
56
56
  declare function setPortableAppDataPath(dirName?: string): void;
57
- /**
58
- * ensure app is ready.
59
- * @param timeout wait timeout, @default 1000
60
- */
61
- declare function waitAppReady(timeout?: number): Promise<void>;
62
57
  /**
63
58
  * load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
64
59
  * @param win window
@@ -69,13 +64,6 @@ declare function getPathFromPreload(...paths: string[]): string;
69
64
  declare function getPathFromPublic(...paths: string[]): string;
70
65
  declare function getPathFromEntryAsar(...paths: string[]): string;
71
66
 
72
- declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
73
-
74
- declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
75
-
76
- declare function encrypt(plainText: string, key: Buffer, iv: Buffer): string;
77
- declare function signature(buffer: Buffer, privateKey: string, cert: string, version: string): string;
78
-
79
- declare function hashString(data: string | Buffer, length: number): Buffer;
67
+ declare function defaultZipFile(buffer: Buffer, targetFilePath: string): Promise<void>;
80
68
 
81
- export { disableHWAccForWin7, encrypt, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, hashString, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, signature, singleInstance, unzipFile, waitAppReady, zipFile };
69
+ export { defaultZipFile, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
package/dist/utils.js CHANGED
@@ -1,62 +1,19 @@
1
- import {
2
- decrypt,
3
- disableHWAccForWin7,
4
- encrypt,
5
- getAppVersion,
6
- getEntryVersion,
7
- getPathFromAppNameAsar,
8
- getPathFromEntryAsar,
9
- getPathFromPreload,
10
- getPathFromPublic,
11
- handleUnexpectedErrors,
12
- hashString,
13
- isDev,
14
- isLinux,
15
- isLowerVersionDefault,
16
- isMac,
17
- isUpdateJSON,
18
- isWin,
19
- loadPage,
20
- parseVersion,
21
- requireNative,
22
- restartApp,
23
- setAppUserModelId,
24
- setPortableAppDataPath,
25
- signature,
26
- singleInstance,
27
- unzipFile,
28
- verifySignatureDefault,
29
- waitAppReady,
30
- zipFile
31
- } from "./chunk-RSLOPAIZ.js";
32
- export {
33
- decrypt,
34
- disableHWAccForWin7,
35
- encrypt,
36
- getAppVersion,
37
- getEntryVersion,
38
- getPathFromAppNameAsar,
39
- getPathFromEntryAsar,
40
- getPathFromPreload,
41
- getPathFromPublic,
42
- handleUnexpectedErrors,
43
- hashString,
44
- isDev,
45
- isLinux,
46
- isLowerVersionDefault,
47
- isMac,
48
- isUpdateJSON,
49
- isWin,
50
- loadPage,
51
- parseVersion,
52
- requireNative,
53
- restartApp,
54
- setAppUserModelId,
55
- setPortableAppDataPath,
56
- signature,
57
- singleInstance,
58
- unzipFile,
59
- verifySignatureDefault,
60
- waitAppReady,
61
- zipFile
62
- };
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-5WFXC5GU.js';
3
+ export { defaultIsLowerVersion, defaultVersionJsonGenerator, handleUnexpectedErrors, isUpdateJSON, parseVersion } from './chunk-BVFQWBLK.js';
4
+ import { writeFileSync } from 'node:fs';
5
+ import { brotliCompress } from 'node:zlib';
6
+
7
+ async function defaultZipFile(buffer, targetFilePath) {
8
+ return new Promise((resolve, reject) => {
9
+ brotliCompress(buffer, (err, buffer2) => {
10
+ if (err) {
11
+ reject(err);
12
+ }
13
+ writeFileSync(targetFilePath, buffer2);
14
+ resolve();
15
+ });
16
+ });
17
+ }
18
+
19
+ export { defaultZipFile };
@@ -11,7 +11,7 @@ interface Version {
11
11
  stageVersion: number;
12
12
  }
13
13
  declare function parseVersion(version: string): Version;
14
- declare function isLowerVersionDefault(oldVer: string, newVer: string): boolean;
14
+ declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
15
15
  /**
16
16
  * update info json
17
17
  */
@@ -28,5 +28,6 @@ type UpdateJSON = UpdateInfo & {
28
28
  beta: UpdateInfo;
29
29
  };
30
30
  declare function isUpdateJSON(json: any): json is UpdateJSON;
31
+ declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, buffer: Buffer, signature: string, version: string, minimumVersion: string): UpdateJSON;
31
32
 
32
- export { type UpdateJSON as U, type Version as V, type UpdateInfo as a, isUpdateJSON as b, handleUnexpectedErrors as h, isLowerVersionDefault as i, parseVersion as p };
33
+ export { type UpdateJSON as U, type Version as V, type UpdateInfo as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, handleUnexpectedErrors as h, isUpdateJSON as i, parseVersion as p };
@@ -11,7 +11,7 @@ interface Version {
11
11
  stageVersion: number;
12
12
  }
13
13
  declare function parseVersion(version: string): Version;
14
- declare function isLowerVersionDefault(oldVer: string, newVer: string): boolean;
14
+ declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
15
15
  /**
16
16
  * update info json
17
17
  */
@@ -28,5 +28,6 @@ type UpdateJSON = UpdateInfo & {
28
28
  beta: UpdateInfo;
29
29
  };
30
30
  declare function isUpdateJSON(json: any): json is UpdateJSON;
31
+ declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, buffer: Buffer, signature: string, version: string, minimumVersion: string): UpdateJSON;
31
32
 
32
- export { type UpdateJSON as U, type Version as V, type UpdateInfo as a, isUpdateJSON as b, handleUnexpectedErrors as h, isLowerVersionDefault as i, parseVersion as p };
33
+ export { type UpdateJSON as U, type Version as V, type UpdateInfo as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, handleUnexpectedErrors as h, isUpdateJSON as i, parseVersion as p };