electron-incremental-update 2.0.0-beta.1 → 2.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/chunk-4MH6ZXCY.js +81 -0
- package/dist/chunk-72ZAJ7AF.js +70 -0
- package/dist/chunk-KZSYEXLO.js +55 -0
- package/dist/index.cjs +161 -221
- package/dist/index.d.cts +71 -107
- package/dist/index.d.ts +71 -107
- package/dist/index.js +135 -156
- package/dist/provider.cjs +132 -127
- package/dist/provider.d.cts +92 -20
- package/dist/provider.d.ts +92 -20
- package/dist/provider.js +92 -51
- package/dist/types-Bnc4jz6R.d.ts +78 -0
- package/dist/types-DEYw5VrL.d.cts +78 -0
- package/dist/utils.cjs +133 -190
- package/dist/utils.d.cts +35 -30
- package/dist/utils.d.ts +35 -30
- package/dist/utils.js +3 -62
- package/dist/version-C4tF_trh.d.cts +62 -0
- package/dist/version-C4tF_trh.d.ts +62 -0
- package/dist/vite.d.ts +370 -0
- package/dist/vite.js +304 -265
- package/dist/zip-rm9ED9nU.d.cts +33 -0
- package/dist/zip-rm9ED9nU.d.ts +33 -0
- package/package.json +20 -14
- package/dist/chunk-RSLOPAIZ.js +0 -247
- package/dist/decrypt-BNBcodiO.d.cts +0 -4
- package/dist/decrypt-BNBcodiO.d.ts +0 -4
- package/dist/types-DxPmQmaq.d.cts +0 -61
- package/dist/types-seJf3Wbc.d.ts +0 -61
- package/dist/version-CffZWDhZ.d.cts +0 -32
- package/dist/version-CffZWDhZ.d.ts +0 -32
package/README.md
CHANGED
|
@@ -181,7 +181,7 @@ initApp({
|
|
|
181
181
|
in `electron/main/index.ts`
|
|
182
182
|
|
|
183
183
|
```ts
|
|
184
|
-
import {
|
|
184
|
+
import { UpdaterError, startupWithUpdater } from 'electron-incremental-update'
|
|
185
185
|
import { getPathFromAppNameAsar, getVersions } from 'electron-incremental-update/utils'
|
|
186
186
|
import { app } from 'electron'
|
|
187
187
|
|
|
@@ -199,7 +199,7 @@ export default startupWithUpdater((updater) => {
|
|
|
199
199
|
}
|
|
200
200
|
updater.logger = console
|
|
201
201
|
updater.receiveBeta = true
|
|
202
|
-
|
|
202
|
+
|
|
203
203
|
updater.checkUpdate().then(async (result) => {
|
|
204
204
|
if (result === undefined) {
|
|
205
205
|
console.log('Update Unavailable')
|
|
@@ -276,7 +276,7 @@ import Database from 'better-sqlite3'
|
|
|
276
276
|
|
|
277
277
|
const db = new Database(':memory:', { nativeBinding: './better_sqlite3.node' })
|
|
278
278
|
|
|
279
|
-
export function test() {
|
|
279
|
+
export function test(): void {
|
|
280
280
|
db.exec(
|
|
281
281
|
'DROP TABLE IF EXISTS employees; '
|
|
282
282
|
+ 'CREATE TABLE IF NOT EXISTS employees (name TEXT, salary INTEGER)',
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { __require } from './chunk-72ZAJ7AF.js';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { app } from 'electron';
|
|
5
|
+
|
|
6
|
+
var isDev = __EIU_IS_DEV__;
|
|
7
|
+
var isWin = process.platform === "win32";
|
|
8
|
+
var isMac = process.platform === "darwin";
|
|
9
|
+
var isLinux = process.platform === "linux";
|
|
10
|
+
function getPathFromAppNameAsar(...paths) {
|
|
11
|
+
return isDev ? "DEV.asar" : path.join(path.dirname(app.getAppPath()), `${app.name}.asar`, ...paths);
|
|
12
|
+
}
|
|
13
|
+
function getAppVersion() {
|
|
14
|
+
return isDev ? getEntryVersion() : fs.readFileSync(getPathFromAppNameAsar("version"), "utf-8");
|
|
15
|
+
}
|
|
16
|
+
function getEntryVersion() {
|
|
17
|
+
return app.getVersion();
|
|
18
|
+
}
|
|
19
|
+
function requireNative(moduleName) {
|
|
20
|
+
return __require(path.join(app.getAppPath(), __EIU_ENTRY_DIST_PATH__, moduleName));
|
|
21
|
+
}
|
|
22
|
+
function restartApp() {
|
|
23
|
+
app.relaunch();
|
|
24
|
+
app.quit();
|
|
25
|
+
}
|
|
26
|
+
function setAppUserModelId(id) {
|
|
27
|
+
if (isWin) {
|
|
28
|
+
app.setAppUserModelId(id ?? `org.${app.name}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function disableHWAccForWin7() {
|
|
32
|
+
if (__require("node:os").release().startsWith("6.1")) {
|
|
33
|
+
app.disableHardwareAcceleration();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function singleInstance(window) {
|
|
37
|
+
const result = app.requestSingleInstanceLock();
|
|
38
|
+
if (result) {
|
|
39
|
+
app.on("second-instance", () => {
|
|
40
|
+
if (window) {
|
|
41
|
+
window.show();
|
|
42
|
+
if (window.isMinimized()) {
|
|
43
|
+
window.restore();
|
|
44
|
+
}
|
|
45
|
+
window.focus();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
app.quit();
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
function setPortableAppDataPath(dirName = "data") {
|
|
54
|
+
const portablePath = path.join(path.dirname(app.getPath("exe")), dirName);
|
|
55
|
+
if (!fs.existsSync(portablePath)) {
|
|
56
|
+
fs.mkdirSync(portablePath);
|
|
57
|
+
}
|
|
58
|
+
app.setPath("appData", portablePath);
|
|
59
|
+
}
|
|
60
|
+
function loadPage(win, htmlFilePath = "index.html") {
|
|
61
|
+
if (isDev) {
|
|
62
|
+
win.loadURL(process.env.VITE_DEV_SERVER_URL + htmlFilePath);
|
|
63
|
+
} else {
|
|
64
|
+
win.loadFile(getPathFromAppNameAsar("renderer", htmlFilePath));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function getPathFromPreload(...paths) {
|
|
68
|
+
return isDev ? path.join(app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "preload", ...paths) : getPathFromAppNameAsar("preload", ...paths);
|
|
69
|
+
}
|
|
70
|
+
function getPathFromPublic(...paths) {
|
|
71
|
+
return isDev ? path.join(app.getAppPath(), "public", ...paths) : getPathFromAppNameAsar("renderer", ...paths);
|
|
72
|
+
}
|
|
73
|
+
function getPathFromEntryAsar(...paths) {
|
|
74
|
+
return path.join(app.getAppPath(), __EIU_ENTRY_DIST_PATH__, ...paths);
|
|
75
|
+
}
|
|
76
|
+
function handleUnexpectedErrors(callback) {
|
|
77
|
+
process.on("uncaughtException", callback);
|
|
78
|
+
process.on("unhandledRejection", callback);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
// src/utils/version.ts
|
|
9
|
+
function parseVersion(version) {
|
|
10
|
+
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?/i.exec(version);
|
|
11
|
+
if (!match) {
|
|
12
|
+
throw new TypeError(`invalid version: ${version}`);
|
|
13
|
+
}
|
|
14
|
+
const [major, minor, patch] = match.slice(1, 4).map(Number);
|
|
15
|
+
const ret = {
|
|
16
|
+
major,
|
|
17
|
+
minor,
|
|
18
|
+
patch,
|
|
19
|
+
stage: "",
|
|
20
|
+
stageVersion: -1
|
|
21
|
+
};
|
|
22
|
+
if (match[4]) {
|
|
23
|
+
let [stage, _v] = match[4].split(".");
|
|
24
|
+
ret.stage = stage;
|
|
25
|
+
ret.stageVersion = Number(_v) || -1;
|
|
26
|
+
}
|
|
27
|
+
if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch) || Number.isNaN(ret.stageVersion)) {
|
|
28
|
+
throw new TypeError(`invalid version: ${version}`);
|
|
29
|
+
}
|
|
30
|
+
return ret;
|
|
31
|
+
}
|
|
32
|
+
function defaultIsLowerVersion(oldVer, newVer) {
|
|
33
|
+
const oldV = parseVersion(oldVer);
|
|
34
|
+
const newV = parseVersion(newVer);
|
|
35
|
+
function compareStrings(str1, str2) {
|
|
36
|
+
if (str1 === "") {
|
|
37
|
+
return str2 !== "";
|
|
38
|
+
} else if (str2 === "") {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return str1 < str2;
|
|
42
|
+
}
|
|
43
|
+
for (let key of Object.keys(oldV)) {
|
|
44
|
+
if (key === "stage" && compareStrings(oldV[key], newV[key])) {
|
|
45
|
+
return true;
|
|
46
|
+
} else if (oldV[key] !== newV[key]) {
|
|
47
|
+
return oldV[key] < newV[key];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
function isUpdateJSON(json) {
|
|
53
|
+
const is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
54
|
+
return is(json) && is(json?.beta);
|
|
55
|
+
}
|
|
56
|
+
function defaultVersionJsonGenerator(existingJson, signature, version, minimumVersion) {
|
|
57
|
+
existingJson.beta = {
|
|
58
|
+
version,
|
|
59
|
+
minimumVersion,
|
|
60
|
+
signature
|
|
61
|
+
};
|
|
62
|
+
if (!parseVersion(version).stage) {
|
|
63
|
+
existingJson.version = version;
|
|
64
|
+
existingJson.minimumVersion = minimumVersion;
|
|
65
|
+
existingJson.signature = signature;
|
|
66
|
+
}
|
|
67
|
+
return existingJson;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { __require, defaultIsLowerVersion, defaultVersionJsonGenerator, isUpdateJSON, parseVersion };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import zlib from 'node:zlib';
|
|
2
|
+
import crypto from 'node:crypto';
|
|
3
|
+
|
|
4
|
+
// src/utils/zip.ts
|
|
5
|
+
async function defaultZipFile(buffer) {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
zlib.brotliCompress(buffer, (err, buffer2) => {
|
|
8
|
+
if (err) {
|
|
9
|
+
reject(err);
|
|
10
|
+
} else {
|
|
11
|
+
resolve(buffer2);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
async function defaultUnzipFile(buffer) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
zlib.brotliDecompress(buffer, (err, buffer2) => {
|
|
19
|
+
if (err) {
|
|
20
|
+
reject(err);
|
|
21
|
+
} else {
|
|
22
|
+
resolve(buffer2);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function hashBuffer(data, length) {
|
|
28
|
+
const hash = crypto.createHash("SHA256").update(data).digest("binary");
|
|
29
|
+
return Buffer.from(hash).subarray(0, length);
|
|
30
|
+
}
|
|
31
|
+
function aesEncrypt(plainText, key, iv) {
|
|
32
|
+
const cipher = crypto.createCipheriv("aes-256-cbc", key, iv);
|
|
33
|
+
return cipher.update(plainText, "utf8", "base64url") + cipher.final("base64url");
|
|
34
|
+
}
|
|
35
|
+
function defaultSignature(buffer, privateKey, cert, version) {
|
|
36
|
+
const sig = crypto.createSign("RSA-SHA256").update(buffer).sign(crypto.createPrivateKey(privateKey), "base64");
|
|
37
|
+
return aesEncrypt(`${sig}%${version}`, hashBuffer(cert, 32), hashBuffer(buffer, 16));
|
|
38
|
+
}
|
|
39
|
+
function aesDecrypt(encryptedText, key, iv) {
|
|
40
|
+
const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
|
|
41
|
+
return decipher.update(encryptedText, "base64url", "utf8") + decipher.final("utf8");
|
|
42
|
+
}
|
|
43
|
+
function defaultVerifySignature(buffer, version, signature, cert) {
|
|
44
|
+
try {
|
|
45
|
+
const [sig, ver] = aesDecrypt(signature, hashBuffer(cert, 32), hashBuffer(buffer, 16)).split("%");
|
|
46
|
+
if (ver !== version) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return crypto.createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
|
|
50
|
+
} catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultZipFile, hashBuffer };
|