electron-incremental-update 2.4.3 → 3.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/README.md +48 -40
- package/dist/download-BN4uMS4_.d.mts +39 -0
- package/dist/download-DO7iuxEJ.d.cts +39 -0
- package/dist/electron-DH-Uyikp.cjs +321 -0
- package/dist/electron-OKQIYbcw.mjs +181 -0
- package/dist/index.cjs +261 -331
- package/dist/index.d.cts +179 -169
- package/dist/index.d.mts +204 -0
- package/dist/index.mjs +273 -0
- package/dist/provider.cjs +142 -330
- package/dist/provider.d.cts +113 -114
- package/dist/provider.d.mts +133 -0
- package/dist/provider.mjs +152 -0
- package/dist/types-BM9Jfu7q.d.cts +154 -0
- package/dist/types-DASqEPXE.d.mts +154 -0
- package/dist/utils.cjs +43 -381
- package/dist/utils.d.cts +120 -85
- package/dist/utils.d.mts +164 -0
- package/dist/utils.mjs +5 -0
- package/dist/version--eVB2A7n.mjs +72 -0
- package/dist/version-aPrLuz_-.cjs +129 -0
- package/dist/vite.d.mts +521 -0
- package/dist/vite.mjs +1094 -0
- package/dist/zip-BCC7FAQ_.cjs +264 -0
- package/dist/zip-Dwm7s1C9.mjs +185 -0
- package/package.json +66 -64
- package/dist/chunk-AAAM44NW.js +0 -70
- package/dist/chunk-IVHNGRZY.js +0 -122
- package/dist/chunk-PD4EV4MM.js +0 -147
- package/dist/index.d.ts +0 -194
- package/dist/index.js +0 -309
- package/dist/provider.d.ts +0 -134
- package/dist/provider.js +0 -152
- package/dist/types-CU7GyVez.d.cts +0 -151
- package/dist/types-CU7GyVez.d.ts +0 -151
- package/dist/utils.d.ts +0 -129
- package/dist/utils.js +0 -3
- package/dist/vite.d.ts +0 -533
- package/dist/vite.js +0 -945
- package/dist/zip-Blmn2vzE.d.cts +0 -71
- package/dist/zip-CnSv_Njj.d.ts +0 -71
- package/provider.d.ts +0 -1
- package/provider.js +0 -1
- package/utils.d.ts +0 -1
- package/utils.js +0 -1
- package/vite.d.ts +0 -1
- package/vite.js +0 -1
package/dist/chunk-IVHNGRZY.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { __require } from './chunk-AAAM44NW.js';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import electron 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(electron.app.getAppPath()), `${electron.app.name}.asar`, ...paths);
|
|
12
|
-
}
|
|
13
|
-
function getAppVersion() {
|
|
14
|
-
return isDev ? getEntryVersion() : fs.readFileSync(getPathFromAppNameAsar("version"), "utf-8");
|
|
15
|
-
}
|
|
16
|
-
function getEntryVersion() {
|
|
17
|
-
return electron.app.getVersion();
|
|
18
|
-
}
|
|
19
|
-
function requireNative(moduleName) {
|
|
20
|
-
const m = getPathFromEntryAsar(moduleName);
|
|
21
|
-
if (__EIU_IS_ESM__) {
|
|
22
|
-
throw new Error(`Cannot require "${m}", \`requireNative\` only support CommonJS, use \`importNative\` instead`);
|
|
23
|
-
}
|
|
24
|
-
return __require(m);
|
|
25
|
-
}
|
|
26
|
-
async function importNative(moduleName) {
|
|
27
|
-
const m = getPathFromEntryAsar(moduleName);
|
|
28
|
-
if (!__EIU_IS_ESM__) {
|
|
29
|
-
throw new Error(`Cannot import "${m}", \`importNative\` only support ESModule, use \`requireNative\` instead`);
|
|
30
|
-
}
|
|
31
|
-
return await import(`file://${m}.js`);
|
|
32
|
-
}
|
|
33
|
-
function restartApp() {
|
|
34
|
-
electron.app.relaunch();
|
|
35
|
-
electron.app.quit();
|
|
36
|
-
}
|
|
37
|
-
function setAppUserModelId(id) {
|
|
38
|
-
if (isWin) {
|
|
39
|
-
electron.app.setAppUserModelId(id ?? `org.${electron.app.name}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function disableHWAccForWin7() {
|
|
43
|
-
if (!__EIU_IS_ESM__ && __require("os").release().startsWith("6.1")) {
|
|
44
|
-
electron.app.disableHardwareAcceleration();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function singleInstance(window) {
|
|
48
|
-
electron.app.on("second-instance", () => {
|
|
49
|
-
if (window) {
|
|
50
|
-
window.show();
|
|
51
|
-
if (window.isMinimized()) {
|
|
52
|
-
window.restore();
|
|
53
|
-
}
|
|
54
|
-
window.focus();
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
function setPortableDataPath(dirName = "data", create = true) {
|
|
59
|
-
if (electron.app.isReady()) {
|
|
60
|
-
throw new Error("Portable app data dir must be setup before app is ready");
|
|
61
|
-
}
|
|
62
|
-
const portableDir = path.join(path.dirname(electron.app.getPath("exe")), dirName);
|
|
63
|
-
if (create) {
|
|
64
|
-
if (!fs.existsSync(portableDir)) {
|
|
65
|
-
fs.mkdirSync(portableDir);
|
|
66
|
-
} else if (!fs.statSync(portableDir).isDirectory()) {
|
|
67
|
-
fs.rmSync(portableDir);
|
|
68
|
-
fs.mkdirSync(portableDir);
|
|
69
|
-
}
|
|
70
|
-
} else if (!fs.existsSync(portableDir)) {
|
|
71
|
-
throw new Error("Portable app data dir does not exists");
|
|
72
|
-
}
|
|
73
|
-
electron.app.setPath("userData", portableDir);
|
|
74
|
-
}
|
|
75
|
-
var setPortableAppDataPath = setPortableDataPath;
|
|
76
|
-
function loadPage(win, htmlFilePath = "index.html") {
|
|
77
|
-
if (isDev) {
|
|
78
|
-
win.loadURL(process.env.VITE_DEV_SERVER_URL + htmlFilePath);
|
|
79
|
-
} else {
|
|
80
|
-
win.loadFile(getPathFromAppNameAsar("renderer", htmlFilePath));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function beautifyDevTools(win, options) {
|
|
84
|
-
const { mono, sans, scrollbar = true } = options;
|
|
85
|
-
win.webContents.on("devtools-opened", async () => {
|
|
86
|
-
let css = `:root{--sans:${sans};--mono:${mono}}:root,body{--source-code-font-family:var(--mono)!important;--source-code-font-size:12px!important;--monospace-font-family:var(--mono)!important;--monospace-font-size:12px!important;--default-font-family:var(--sans), sans-serif!important;--default-font-size:12px!important}button,input,select,.undisplayable-text,.expandable-inline-button{font-family:var(--sans)!important}`;
|
|
87
|
-
if (scrollbar) {
|
|
88
|
-
css += ":root{--scrollbar-width:max(.85vw,10px)}@media (prefers-color-scheme:light){:root{--scrollbar-color-rgb:0,0,0}}@media (prefers-color-scheme:dark){:root{--scrollbar-color-rgb:255,255,255}}*::-webkit-scrollbar{width:var(--scrollbar-width)!important;height:var(--scrollbar-width)!important}*::-webkit-scrollbar-track{background-color:transparent!important;border-radius:var(--scrollbar-width)!important;box-shadow:none!important}*::-webkit-scrollbar-thumb{box-shadow:inset 0 0 0 var(--scrollbar-width)!important;border-radius:var(--scrollbar-width)!important;border:calc(var(--scrollbar-width) * 2/9) solid transparent!important;background-clip:content-box;background-color:transparent!important;color:rgba(var(--scrollbar-color-rgb),30%)!important}*::-webkit-scrollbar-thumb:hover{color:rgba(var(--scrollbar-color-rgb),45%)!important}*::-webkit-scrollbar-thumb:active{color:rgba(var(--scrollbar-color-rgb),60%)!important}@supports not selector(::-webkit-scrollbar){html{scrollbar-color:rgb(var(--scrollbar-color-rgb));scrollbar-width:thin}}";
|
|
89
|
-
}
|
|
90
|
-
const js = `${'function run(n){let d=document.createElement("style");d.innerHTML=n,document.body.append(d),["platform-windows","platform-mac","platform-linux"].forEach(e=>document.querySelectorAll(`.${e}`).forEach(o=>o.classList.remove(e))),l();const r=new MutationObserver(e=>{for(const o of e)if(o.type==="childList")for(let t=0;t<o.addedNodes.length;t++)o.addedNodes[t].classList.contains("editor-tooltip-host")&&l()});r.observe(document.body,{childList:!0});function l(){document.querySelectorAll(".editor-tooltip-host").forEach(e=>{if(e?.shadowRoot?.querySelectorAll(\'[data-key="overridden-dev-tools-font"]\').length===0){const o=document.createElement("style");o.setAttribute("data-key","overridden-dev-tools-font"),o.innerHTML=`${n}.cm-tooltip-autocomplete ul[role=listbox]{font-family:var(--mono)!important;}`,e.shadowRoot.append(o)}})}window.onbeforeunload=()=>r.disconnect()}'};run(\`${css}\`)`;
|
|
91
|
-
await win?.webContents.devToolsWebContents?.executeJavaScript(js);
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
function getPathFromMain(...paths) {
|
|
95
|
-
return isDev ? path.join(electron.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "main", ...paths) : getPathFromAppNameAsar("main", ...paths);
|
|
96
|
-
}
|
|
97
|
-
function getPathFromPreload(...paths) {
|
|
98
|
-
return isDev ? path.join(electron.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "preload", ...paths) : getPathFromAppNameAsar("preload", ...paths);
|
|
99
|
-
}
|
|
100
|
-
function getPathFromPublic(...paths) {
|
|
101
|
-
return isDev ? path.join(electron.app.getAppPath(), "public", ...paths) : getPathFromAppNameAsar("renderer", ...paths);
|
|
102
|
-
}
|
|
103
|
-
function getPathFromEntryAsar(...paths) {
|
|
104
|
-
return path.join(electron.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, ...paths);
|
|
105
|
-
}
|
|
106
|
-
function handleUnexpectedErrors(callback) {
|
|
107
|
-
process.on("uncaughtException", callback);
|
|
108
|
-
process.on("unhandledRejection", callback);
|
|
109
|
-
}
|
|
110
|
-
function reloadOnPreloadScriptChanged() {
|
|
111
|
-
if (isDev) {
|
|
112
|
-
process.on("message", (msg) => {
|
|
113
|
-
if (msg === "electron-vite&type=hot-reload") {
|
|
114
|
-
for (const window of electron.BrowserWindow.getAllWindows()) {
|
|
115
|
-
window.reload();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export { beautifyDevTools, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromMain, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, importNative, isDev, isLinux, isMac, isWin, loadPage, reloadOnPreloadScriptChanged, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, setPortableDataPath, singleInstance };
|
package/dist/chunk-PD4EV4MM.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { isUpdateJSON } from './chunk-AAAM44NW.js';
|
|
2
|
-
import crypto from 'crypto';
|
|
3
|
-
import electron from 'electron';
|
|
4
|
-
import zlib from 'zlib';
|
|
5
|
-
|
|
6
|
-
function hashBuffer(data, length) {
|
|
7
|
-
const hash = crypto.createHash("SHA256").update(data).digest("binary");
|
|
8
|
-
return Buffer.from(hash).subarray(0, length);
|
|
9
|
-
}
|
|
10
|
-
function aesEncrypt(plainText, key, iv) {
|
|
11
|
-
const cipher = crypto.createCipheriv("aes-256-cbc", key, iv);
|
|
12
|
-
return cipher.update(plainText, "utf8", "base64url") + cipher.final("base64url");
|
|
13
|
-
}
|
|
14
|
-
function defaultSignature(buffer, privateKey, cert, version) {
|
|
15
|
-
const sig = crypto.createSign("RSA-SHA256").update(buffer).sign(crypto.createPrivateKey(privateKey), "base64");
|
|
16
|
-
return aesEncrypt(`${sig}%${version}`, hashBuffer(cert, 32), hashBuffer(buffer, 16));
|
|
17
|
-
}
|
|
18
|
-
function aesDecrypt(encryptedText, key, iv) {
|
|
19
|
-
const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
|
|
20
|
-
return decipher.update(encryptedText, "base64url", "utf8") + decipher.final("utf8");
|
|
21
|
-
}
|
|
22
|
-
function defaultVerifySignature(buffer, version, signature, cert) {
|
|
23
|
-
try {
|
|
24
|
-
const [sig, ver] = aesDecrypt(signature, hashBuffer(cert, 32), hashBuffer(buffer, 16)).split("%");
|
|
25
|
-
if (ver !== version) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
return crypto.createVerify("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
|
|
29
|
-
} catch {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function getHeader(headers, key) {
|
|
34
|
-
const value = headers[key];
|
|
35
|
-
if (Array.isArray(value)) {
|
|
36
|
-
return value.length === 0 ? null : value[value.length - 1];
|
|
37
|
-
} else {
|
|
38
|
-
return value;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async function downloadUtil(url, headers, onResponse) {
|
|
42
|
-
await electron.app.whenReady();
|
|
43
|
-
return new Promise((resolve, reject) => {
|
|
44
|
-
const request = electron.net.request({
|
|
45
|
-
cache: "no-cache",
|
|
46
|
-
headers,
|
|
47
|
-
method: "GET",
|
|
48
|
-
redirect: "follow",
|
|
49
|
-
url
|
|
50
|
-
});
|
|
51
|
-
request.on("response", (resp) => {
|
|
52
|
-
resp.on("aborted", () => reject(new Error("Aborted")));
|
|
53
|
-
resp.on("error", reject);
|
|
54
|
-
onResponse(request, resp, resolve, reject);
|
|
55
|
-
});
|
|
56
|
-
request.on("error", reject);
|
|
57
|
-
request.end();
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
function trimData(data) {
|
|
61
|
-
return data.trim().slice(0, 5e3).replace(/\s+/g, " ");
|
|
62
|
-
}
|
|
63
|
-
var resolveJson = (data, resolve, reject) => {
|
|
64
|
-
try {
|
|
65
|
-
resolve(JSON.parse(data));
|
|
66
|
-
} catch {
|
|
67
|
-
reject(new Error(`Invalid json, "${trimData(data)}"`));
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
async function defaultDownloadText(url, headers, signal, resolveData) {
|
|
71
|
-
return await downloadUtil(
|
|
72
|
-
url,
|
|
73
|
-
headers,
|
|
74
|
-
(request, resp, resolve, reject) => {
|
|
75
|
-
let data = "";
|
|
76
|
-
resp.on("data", (chunk) => data += chunk);
|
|
77
|
-
resp.on("end", () => resolveData(data, resolve, reject));
|
|
78
|
-
signal.addEventListener("abort", () => {
|
|
79
|
-
request.abort();
|
|
80
|
-
data = null;
|
|
81
|
-
}, { once: true });
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
async function defaultDownloadUpdateJSON(url, headers, signal) {
|
|
86
|
-
return await defaultDownloadText(
|
|
87
|
-
url,
|
|
88
|
-
headers,
|
|
89
|
-
signal,
|
|
90
|
-
(data, resolve, reject) => {
|
|
91
|
-
try {
|
|
92
|
-
const json = JSON.parse(data);
|
|
93
|
-
if (isUpdateJSON(json)) {
|
|
94
|
-
resolve(json);
|
|
95
|
-
} else {
|
|
96
|
-
throw Error;
|
|
97
|
-
}
|
|
98
|
-
} catch {
|
|
99
|
-
reject(new Error(`Invalid update json, "${trimData(data)}"`));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
async function defaultDownloadAsar(url, headers, signal, onDownloading) {
|
|
105
|
-
let transferred = 0;
|
|
106
|
-
let time = Date.now();
|
|
107
|
-
return await downloadUtil(
|
|
108
|
-
url,
|
|
109
|
-
headers,
|
|
110
|
-
(request, resp, resolve) => {
|
|
111
|
-
const total = +getHeader(resp.headers, "content-length") || -1;
|
|
112
|
-
let data = [];
|
|
113
|
-
resp.on("data", (chunk) => {
|
|
114
|
-
const delta = chunk.length;
|
|
115
|
-
transferred += delta;
|
|
116
|
-
const current = Date.now();
|
|
117
|
-
onDownloading?.({
|
|
118
|
-
bps: delta / (current - time),
|
|
119
|
-
delta,
|
|
120
|
-
percent: total > 0 ? +(transferred / total).toFixed(2) * 100 : -1,
|
|
121
|
-
total,
|
|
122
|
-
transferred
|
|
123
|
-
});
|
|
124
|
-
time = current;
|
|
125
|
-
data.push(chunk);
|
|
126
|
-
});
|
|
127
|
-
resp.on("end", () => resolve(Buffer.concat(data)));
|
|
128
|
-
signal.addEventListener("abort", () => {
|
|
129
|
-
request.abort();
|
|
130
|
-
data.length = 0;
|
|
131
|
-
data = null;
|
|
132
|
-
}, { once: true });
|
|
133
|
-
}
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
async function defaultZipFile(buffer) {
|
|
137
|
-
return new Promise((resolve, reject) => {
|
|
138
|
-
zlib.brotliCompress(buffer, (err, buffer2) => err ? reject(err) : resolve(buffer2));
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
async function defaultUnzipFile(buffer) {
|
|
142
|
-
return new Promise((resolve, reject) => {
|
|
143
|
-
zlib.brotliDecompress(buffer, (err, buffer2) => err ? reject(err) : resolve(buffer2));
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export { aesDecrypt, aesEncrypt, defaultDownloadAsar, defaultDownloadText, defaultDownloadUpdateJSON, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultZipFile, downloadUtil, getHeader, hashBuffer, resolveJson };
|
package/dist/index.d.ts
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { U as UpdateInfo, I as IProvider, D as DownloadingInfo, a as UpdateJSON, b as UpdateJSONWithURL } from './types-CU7GyVez.js';
|
|
2
|
-
import { Promisable } from '@subframe7536/type-utils';
|
|
3
|
-
import { EventEmitter } from 'node:events';
|
|
4
|
-
import 'node:url';
|
|
5
|
-
|
|
6
|
-
type UpdaterErrorCode = 'ERR_DOWNLOAD' | 'ERR_VALIDATE' | 'ERR_PARAM' | 'ERR_NETWORK';
|
|
7
|
-
type UpdaterUnavailableCode = 'UNAVAILABLE_ERROR' | 'UNAVAILABLE_DEV' | 'UNAVAILABLE_VERSION';
|
|
8
|
-
declare class UpdaterError extends Error {
|
|
9
|
-
code: UpdaterErrorCode;
|
|
10
|
-
constructor(code: UpdaterErrorCode, info: string);
|
|
11
|
-
}
|
|
12
|
-
interface Logger {
|
|
13
|
-
info: (msg: string) => void;
|
|
14
|
-
debug: (msg: string) => void;
|
|
15
|
-
warn: (msg: string) => void;
|
|
16
|
-
error: (msg: string, e?: unknown) => void;
|
|
17
|
-
}
|
|
18
|
-
interface UpdaterOption {
|
|
19
|
-
/**
|
|
20
|
-
* Update provider
|
|
21
|
-
*
|
|
22
|
-
* If you will not setup `UpdateJSON` or `Buffer` in params when checking update or download, this option is **required**
|
|
23
|
-
*/
|
|
24
|
-
provider?: IProvider;
|
|
25
|
-
/**
|
|
26
|
-
* Certifaction key of signature, which will be auto generated by plugin,
|
|
27
|
-
* generate by `selfsigned` if not set
|
|
28
|
-
*/
|
|
29
|
-
SIGNATURE_CERT?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Whether to receive beta update
|
|
32
|
-
*/
|
|
33
|
-
receiveBeta?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Updater logger
|
|
36
|
-
*/
|
|
37
|
-
logger?: Logger;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Update info with current app version and entry version
|
|
41
|
-
*/
|
|
42
|
-
type UpdateInfoWithExtraVersion = UpdateInfo & {
|
|
43
|
-
/**
|
|
44
|
-
* Current app version
|
|
45
|
-
*/
|
|
46
|
-
appVersion: string;
|
|
47
|
-
/**
|
|
48
|
-
* Current entry version
|
|
49
|
-
*/
|
|
50
|
-
entryVersion: string;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
declare class Updater<T extends UpdateInfoWithExtraVersion = UpdateInfoWithExtraVersion> extends EventEmitter<{
|
|
54
|
-
'update-available': [data: T];
|
|
55
|
-
'update-not-available': [code: UpdaterUnavailableCode, msg: string, info?: T];
|
|
56
|
-
'error': [error: UpdaterError];
|
|
57
|
-
'download-progress': [info: DownloadingInfo];
|
|
58
|
-
'update-downloaded': [];
|
|
59
|
-
'update-cancelled': [];
|
|
60
|
-
}> {
|
|
61
|
-
private CERT;
|
|
62
|
-
private controller;
|
|
63
|
-
private info?;
|
|
64
|
-
private tmpFilePath?;
|
|
65
|
-
private processing;
|
|
66
|
-
provider?: IProvider;
|
|
67
|
-
/**
|
|
68
|
-
* Updater logger
|
|
69
|
-
*/
|
|
70
|
-
logger?: Logger;
|
|
71
|
-
/**
|
|
72
|
-
* Whether to receive beta update
|
|
73
|
-
*/
|
|
74
|
-
receiveBeta?: boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Whether force update in DEV
|
|
77
|
-
*/
|
|
78
|
-
forceUpdate?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Initialize incremental updater
|
|
81
|
-
* @param options UpdaterOption
|
|
82
|
-
*/
|
|
83
|
-
constructor(options?: UpdaterOption);
|
|
84
|
-
/**
|
|
85
|
-
* This function is used to parse download data.
|
|
86
|
-
*
|
|
87
|
-
* if data is absent, download URL from provider and return it,
|
|
88
|
-
* else if data is `UpdateJSON`, return it
|
|
89
|
-
*/
|
|
90
|
-
private fetch;
|
|
91
|
-
private cleanup;
|
|
92
|
-
/**
|
|
93
|
-
* Handle error message and emit error event
|
|
94
|
-
*/
|
|
95
|
-
private err;
|
|
96
|
-
/**
|
|
97
|
-
* Check update info using default options
|
|
98
|
-
*/
|
|
99
|
-
checkForUpdates(): Promise<boolean>;
|
|
100
|
-
/**
|
|
101
|
-
* Check update info using existing update json
|
|
102
|
-
* @param data existing update json
|
|
103
|
-
*/
|
|
104
|
-
checkForUpdates(data: UpdateJSON | UpdateJSONWithURL): Promise<boolean>;
|
|
105
|
-
/**
|
|
106
|
-
* Download update using default options
|
|
107
|
-
*/
|
|
108
|
-
downloadUpdate(): Promise<boolean>;
|
|
109
|
-
/**
|
|
110
|
-
* Download update using existing `asar.gz` buffer and signature
|
|
111
|
-
* @param data existing `asar.gz` buffer
|
|
112
|
-
* @param info update info
|
|
113
|
-
*/
|
|
114
|
-
downloadUpdate(data: Uint8Array, info: Omit<UpdateInfo, 'minimumVersion'>): Promise<boolean>;
|
|
115
|
-
/**
|
|
116
|
-
* quit App and install
|
|
117
|
-
*/
|
|
118
|
-
quitAndInstall(): void;
|
|
119
|
-
cancel(): void;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Auto check update, download and install
|
|
123
|
-
*/
|
|
124
|
-
declare function autoUpdate(updater: Updater): Promise<void>;
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Hooks on rename temp asar path to `${app.name}.asar`
|
|
128
|
-
* @param install `() => renameSync(tempAsarPath, appNameAsarPath)`
|
|
129
|
-
* @param tempAsarPath temp(updated) asar path
|
|
130
|
-
* @param appNameAsarPath `${app.name}.asar` path
|
|
131
|
-
* @param logger logger
|
|
132
|
-
* @default install(); logger.info('update success!')
|
|
133
|
-
*/
|
|
134
|
-
type OnInstallFunction = (install: VoidFunction, tempAsarPath: string, appNameAsarPath: string, logger?: Logger) => Promisable<void>;
|
|
135
|
-
interface AppOption {
|
|
136
|
-
/**
|
|
137
|
-
* Path to index file that make {@link startupWithUpdater} as default export
|
|
138
|
-
*
|
|
139
|
-
* Generate from plugin configuration by default
|
|
140
|
-
*/
|
|
141
|
-
mainPath?: string;
|
|
142
|
-
/**
|
|
143
|
-
* Updater options
|
|
144
|
-
*/
|
|
145
|
-
updater?: (() => Promisable<Updater>) | UpdaterOption;
|
|
146
|
-
/**
|
|
147
|
-
* Hooks on rename temp asar path to `${app.name}.asar`
|
|
148
|
-
*/
|
|
149
|
-
onInstall?: OnInstallFunction;
|
|
150
|
-
/**
|
|
151
|
-
* Hooks before app startup
|
|
152
|
-
* @param mainFilePath main file path of `${app.name}.asar`
|
|
153
|
-
* @param logger logger
|
|
154
|
-
*/
|
|
155
|
-
beforeStart?: (mainFilePath: string, logger?: Logger) => Promisable<void>;
|
|
156
|
-
/**
|
|
157
|
-
* Hooks on app startup error
|
|
158
|
-
* @param err installing or startup error
|
|
159
|
-
* @param logger logger
|
|
160
|
-
*/
|
|
161
|
-
onStartError?: (err: unknown, logger?: Logger) => void;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Utils to startup with updater
|
|
165
|
-
* @param fn startup function
|
|
166
|
-
* @example
|
|
167
|
-
* // in electron/main/index.ts
|
|
168
|
-
* export default startupWithUpdater((updater) => {
|
|
169
|
-
* updater.checkUpdate()
|
|
170
|
-
* })
|
|
171
|
-
*/
|
|
172
|
-
declare function startupWithUpdater(fn: (updater: Updater) => Promisable<void>): (updater: Updater) => Promisable<void>;
|
|
173
|
-
/**
|
|
174
|
-
* Initialize Electron with updater
|
|
175
|
-
* @example
|
|
176
|
-
* createElectronApp({
|
|
177
|
-
* updater: {
|
|
178
|
-
* provider: new GitHubProvider({
|
|
179
|
-
* username: 'yourname',
|
|
180
|
-
* repo: 'electron',
|
|
181
|
-
* }),
|
|
182
|
-
* },
|
|
183
|
-
* beforeStart(mainFilePath, logger) {
|
|
184
|
-
* logger?.debug(mainFilePath)
|
|
185
|
-
* },
|
|
186
|
-
* })
|
|
187
|
-
*/
|
|
188
|
-
declare function createElectronApp(appOptions?: AppOption): Promise<void>;
|
|
189
|
-
/**
|
|
190
|
-
* @alias {@link createElectronApp}
|
|
191
|
-
*/
|
|
192
|
-
declare const initApp: typeof createElectronApp;
|
|
193
|
-
|
|
194
|
-
export { type AppOption, type Logger, type UpdateInfoWithExtraVersion, Updater, UpdaterError, type UpdaterErrorCode, type UpdaterOption, type UpdaterUnavailableCode, autoUpdate, createElectronApp, initApp, startupWithUpdater };
|