electron-incremental-update 2.1.2 → 2.2.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 +33 -17
- package/dist/{bytecode-I4PMYUGT.js → bytecode-7V24FFYI.js} +5 -7
- package/dist/{chunk-AUY7A2FL.js → chunk-7JCGLFGU.js} +49 -4
- package/dist/{chunk-RCRKUKFX.js → chunk-AAAM44NW.js} +9 -9
- package/dist/{chunk-2XSFM3E5.js → chunk-JI27JWJN.js} +1 -1
- package/dist/chunk-TPTWE33H.js +23 -0
- package/dist/{chunk-5CE27A6G.js → esm-UJAQJA65.js} +22 -2
- package/dist/index.cjs +7 -8
- package/dist/index.d.cts +41 -4
- package/dist/index.d.ts +41 -4
- package/dist/index.js +6 -11
- package/dist/provider.cjs +10 -10
- package/dist/provider.d.cts +4 -4
- package/dist/provider.d.ts +4 -4
- package/dist/provider.js +2 -2
- package/dist/{types-DQKdsHc_.d.ts → types-C6lSLZWB.d.cts} +2 -40
- package/dist/{types-BPH66pNz.d.cts → types-nE_pIMPo.d.ts} +2 -40
- package/dist/utils.cjs +9 -9
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +2 -2
- package/dist/{version-DcFMG3pT.d.ts → version-BYVQ367i.d.cts} +1 -1
- package/dist/{version-DcFMG3pT.d.cts → version-BYVQ367i.d.ts} +1 -1
- package/dist/vite.d.ts +54 -26
- package/dist/vite.js +88 -119
- package/package.json +87 -87
- package/dist/chunk-7IRGAAL2.js +0 -5
- package/dist/chunk-7M7DIMDN.js +0 -43
- package/dist/chunk-WYQ5DRO7.js +0 -12
- package/dist/code-P5OANH3Q.js +0 -1
- package/dist/esm-ZFXJ56BN.js +0 -26
- package/dist/utils-JZ4CMTJG.js +0 -4
- package/dist/utils-KPSYP7HQ.js +0 -5
- package/dist/{zip-rm9ED9nU.d.ts → crypto-Zynscwmj.d.cts} +11 -11
- package/dist/{zip-rm9ED9nU.d.cts → crypto-Zynscwmj.d.ts} +11 -11
package/README.md
CHANGED
|
@@ -840,30 +840,32 @@ export interface BuildEntryOption {
|
|
|
840
840
|
*/
|
|
841
841
|
nativeModuleEntryMap?: Record<string, string>
|
|
842
842
|
/**
|
|
843
|
-
*
|
|
843
|
+
* Skip process dynamic require
|
|
844
|
+
*
|
|
845
|
+
* Useful for `better-sqlite3` and other old packages
|
|
846
|
+
*/
|
|
847
|
+
ignoreDynamicRequires?: boolean
|
|
848
|
+
/**
|
|
849
|
+
* `external` option in `build.rollupOptions`, external `.node` by default
|
|
850
|
+
*/
|
|
851
|
+
external?: string | string[] | ((source: string, importer: string | undefined, isResolved: boolean) => boolean | null | undefined | void)
|
|
852
|
+
/**
|
|
853
|
+
* Custom options for `vite` build
|
|
844
854
|
* ```ts
|
|
845
|
-
* // default options
|
|
846
855
|
* const options = {
|
|
847
|
-
*
|
|
848
|
-
*
|
|
849
|
-
*
|
|
850
|
-
*
|
|
851
|
-
*
|
|
852
|
-
*
|
|
853
|
-
*
|
|
854
|
-
* minify,
|
|
855
|
-
* sourcemap,
|
|
856
|
-
* entryNames: '[dir]/[name]',
|
|
857
|
-
* assetNames: '[dir]/[name]',
|
|
858
|
-
* external: ['electron', 'original-fs'],
|
|
859
|
-
* loader: {
|
|
860
|
-
* '.node': 'empty',
|
|
856
|
+
* plugins: [esm(), bytecodePlugin()], // load on needed
|
|
857
|
+
* build: {
|
|
858
|
+
* sourcemap,
|
|
859
|
+
* minify,
|
|
860
|
+
* outDir: entryOutputDirPath,
|
|
861
|
+
* commonjsOptions: { ignoreDynamicRequires },
|
|
862
|
+
* rollupOptions: { external },
|
|
861
863
|
* },
|
|
862
864
|
* define,
|
|
863
865
|
* }
|
|
864
866
|
* ```
|
|
865
867
|
*/
|
|
866
|
-
|
|
868
|
+
overrideViteOptions?: InlineConfig
|
|
867
869
|
/**
|
|
868
870
|
* Resolve extra files on startup, such as `.node`
|
|
869
871
|
* @remark won't trigger will reload
|
|
@@ -889,6 +891,20 @@ export interface BuildEntryOption {
|
|
|
889
891
|
*/
|
|
890
892
|
skipIfExist?: boolean
|
|
891
893
|
}) => void
|
|
894
|
+
/**
|
|
895
|
+
* Copy specified modules to entry output dir, just like `external` option in rollup
|
|
896
|
+
*/
|
|
897
|
+
copyModules: (options: {
|
|
898
|
+
/**
|
|
899
|
+
* External Modules
|
|
900
|
+
*/
|
|
901
|
+
modules: string[]
|
|
902
|
+
/**
|
|
903
|
+
* Skip copy if `to` exist
|
|
904
|
+
* @default true
|
|
905
|
+
*/
|
|
906
|
+
skipIfExist?: boolean
|
|
907
|
+
}) => void
|
|
892
908
|
}) => Promisable<void>
|
|
893
909
|
}
|
|
894
910
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { readableSize } from './chunk-
|
|
2
|
-
import { convertLiteral, bytecodeModuleLoader, convertArrowFunctionAndTemplate, compileToBytecode, useStrict, toRelativePath } from './chunk-
|
|
3
|
-
import './chunk-7M7DIMDN.js';
|
|
1
|
+
import { readableSize } from './chunk-TPTWE33H.js';
|
|
2
|
+
import { convertLiteral, bytecodeModuleLoaderCode, bytecodeModuleLoader, convertArrowFunctionAndTemplate, compileToBytecode, useStrict, toRelativePath } from './chunk-7JCGLFGU.js';
|
|
4
3
|
import { bytecodeLog, bytecodeId } from './chunk-5NKEXGI3.js';
|
|
5
|
-
import { bytecodeModuleLoaderCode } from './chunk-7IRGAAL2.js';
|
|
6
4
|
import path from 'node:path';
|
|
7
5
|
import fs from 'node:fs';
|
|
8
6
|
import { createFilter, normalizePath } from 'vite';
|
|
9
7
|
import MagicString from 'magic-string';
|
|
10
8
|
|
|
9
|
+
function getBytecodeLoaderBlock(chunkFileName) {
|
|
10
|
+
return `require("${toRelativePath(bytecodeModuleLoader, normalizePath(chunkFileName))}");`;
|
|
11
|
+
}
|
|
11
12
|
function bytecodePlugin(env, options) {
|
|
12
13
|
const {
|
|
13
14
|
enable,
|
|
@@ -77,9 +78,6 @@ function bytecodePlugin(env, options) {
|
|
|
77
78
|
const nonEntryChunks = chunks.filter((chunk) => !chunk.isEntry).map((chunk) => path.basename(chunk.fileName));
|
|
78
79
|
const pattern = nonEntryChunks.map((chunk) => `(${chunk})`).join("|");
|
|
79
80
|
const bytecodeRE = pattern ? new RegExp(`require\\(\\S*(?=(${pattern})\\S*\\))`, "g") : null;
|
|
80
|
-
const getBytecodeLoaderBlock = (chunkFileName) => {
|
|
81
|
-
return `require("${toRelativePath(bytecodeModuleLoader, normalizePath(chunkFileName))}");`;
|
|
82
|
-
};
|
|
83
81
|
await Promise.all(
|
|
84
82
|
bundles.map(async (name) => {
|
|
85
83
|
const chunk = output[name];
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { parseVersion } from './chunk-7M7DIMDN.js';
|
|
2
1
|
import { bytecodeLog } from './chunk-5NKEXGI3.js';
|
|
3
|
-
import { bytecodeGeneratorScript } from './chunk-7IRGAAL2.js';
|
|
4
2
|
import path from 'node:path';
|
|
5
3
|
import fs from 'node:fs';
|
|
6
4
|
import cp from 'node:child_process';
|
|
@@ -8,6 +6,53 @@ import * as babel from '@babel/core';
|
|
|
8
6
|
import MagicString from 'magic-string';
|
|
9
7
|
import { getPackageInfoSync } from 'local-pkg';
|
|
10
8
|
|
|
9
|
+
// src/vite/bytecode/code.ts
|
|
10
|
+
var bytecodeGeneratorScript = "const vm = require('vm')\nconst v8 = require('v8')\nconst wrap = require('module').wrap\nv8.setFlagsFromString('--no-lazy')\nv8.setFlagsFromString('--no-flush-bytecode')\nlet code = ''\nprocess.stdin.setEncoding('utf-8')\nprocess.stdin.on('readable', () => {\n const data = process.stdin.read()\n if (data !== null) {\n code += data\n }\n})\nprocess.stdin.on('end', () => {\n try {\n if (typeof code !== 'string') {\n throw new Error('javascript code must be string.')\n }\n const script = new vm.Script(wrap(code), { produceCachedData: true })\n const bytecodeBuffer = script.createCachedData()\n process.stdout.write(bytecodeBuffer)\n } catch (error) {\n console.error(error)\n }\n})\n";
|
|
11
|
+
var bytecodeModuleLoaderCode = '"use strict";\nconst fs = require("fs");\nconst path = require("path");\nconst vm = require("vm");\nconst v8 = require("v8");\nconst Module = require("module");\nv8.setFlagsFromString("--no-lazy");\nv8.setFlagsFromString("--no-flush-bytecode");\nconst FLAG_HASH_OFFSET = 12;\nconst SOURCE_HASH_OFFSET = 8;\nlet dummyBytecode;\nfunction setFlagHashHeader(bytecodeBuffer) {\n if (!dummyBytecode) {\n const script = new vm.Script("", {\n produceCachedData: true\n });\n dummyBytecode = script.createCachedData();\n }\n dummyBytecode.slice(FLAG_HASH_OFFSET, FLAG_HASH_OFFSET + 4).copy(bytecodeBuffer, FLAG_HASH_OFFSET);\n};\nfunction getSourceHashHeader(bytecodeBuffer) {\n return bytecodeBuffer.slice(SOURCE_HASH_OFFSET, SOURCE_HASH_OFFSET + 4);\n};\nfunction buffer2Number(buffer) {\n let ret = 0;\n ret |= buffer[3] << 24;\n ret |= buffer[2] << 16;\n ret |= buffer[1] << 8;\n ret |= buffer[0];\n return ret;\n};\nModule._extensions[".jsc"] = Module._extensions[".cjsc"] = function (module, filename) {\n const bytecodeBuffer = fs.readFileSync(filename);\n if (!Buffer.isBuffer(bytecodeBuffer)) {\n throw new Error("BytecodeBuffer must be a buffer object.");\n }\n setFlagHashHeader(bytecodeBuffer);\n const length = buffer2Number(getSourceHashHeader(bytecodeBuffer));\n let dummyCode = "";\n if (length > 1) {\n dummyCode = "\\"" + "\\u200b".repeat(length - 2) + "\\"";\n }\n const script = new vm.Script(dummyCode, {\n filename: filename,\n lineOffset: 0,\n displayErrors: true,\n cachedData: bytecodeBuffer\n });\n if (script.cachedDataRejected) {\n throw new Error("Invalid or incompatible cached data (cachedDataRejected)");\n }\n const require = function (id) {\n return module.require(id);\n };\n require.resolve = function (request, options) {\n return Module._resolveFilename(request, module, false, options);\n };\n if (process.mainModule) {\n require.main = process.mainModule;\n }\n require.extensions = Module._extensions;\n require.cache = Module._cache;\n const compiledWrapper = script.runInThisContext({\n filename: filename,\n lineOffset: 0,\n columnOffset: 0,\n displayErrors: true\n });\n const dirname = path.dirname(filename);\n const args = [module.exports, require, module, filename, dirname, process, global];\n return compiledWrapper.apply(module.exports, args);\n};\n';
|
|
12
|
+
|
|
13
|
+
// src/utils/version.ts
|
|
14
|
+
function parseVersion(version) {
|
|
15
|
+
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?/i.exec(version);
|
|
16
|
+
if (!match) {
|
|
17
|
+
throw new TypeError(`invalid version: ${version}`);
|
|
18
|
+
}
|
|
19
|
+
const [major, minor, patch] = match.slice(1, 4).map(Number);
|
|
20
|
+
const ret = {
|
|
21
|
+
major,
|
|
22
|
+
minor,
|
|
23
|
+
patch,
|
|
24
|
+
stage: "",
|
|
25
|
+
stageVersion: -1
|
|
26
|
+
};
|
|
27
|
+
if (match[4]) {
|
|
28
|
+
let [stage, _v] = match[4].split(".");
|
|
29
|
+
ret.stage = stage;
|
|
30
|
+
ret.stageVersion = Number(_v) || -1;
|
|
31
|
+
}
|
|
32
|
+
if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch) || Number.isNaN(ret.stageVersion)) {
|
|
33
|
+
throw new TypeError(`Invalid version: ${version}`);
|
|
34
|
+
}
|
|
35
|
+
return ret;
|
|
36
|
+
}
|
|
37
|
+
var is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
38
|
+
function isUpdateJSON(json) {
|
|
39
|
+
return is(json) && is(json?.beta);
|
|
40
|
+
}
|
|
41
|
+
function defaultVersionJsonGenerator(existingJson, signature, version, minimumVersion) {
|
|
42
|
+
existingJson.beta = {
|
|
43
|
+
version,
|
|
44
|
+
minimumVersion,
|
|
45
|
+
signature
|
|
46
|
+
};
|
|
47
|
+
if (!parseVersion(version).stage) {
|
|
48
|
+
existingJson.version = version;
|
|
49
|
+
existingJson.minimumVersion = minimumVersion;
|
|
50
|
+
existingJson.signature = signature;
|
|
51
|
+
}
|
|
52
|
+
return existingJson;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/vite/bytecode/utils.ts
|
|
11
56
|
var electronModule = getPackageInfoSync("electron");
|
|
12
57
|
var electronMajorVersion = parseVersion(electronModule.version).major;
|
|
13
58
|
var useStrict = "'use strict';";
|
|
@@ -44,9 +89,9 @@ function toRelativePath(filename, importer) {
|
|
|
44
89
|
const relPath = path.posix.relative(path.dirname(importer), filename);
|
|
45
90
|
return relPath.startsWith(".") ? relPath : `./${relPath}`;
|
|
46
91
|
}
|
|
92
|
+
var logErr = (...args) => bytecodeLog.error(args.join(" "), { timestamp: true });
|
|
47
93
|
function compileToBytecode(code, electronPath = getElectronPath()) {
|
|
48
94
|
let data = Buffer.from([]);
|
|
49
|
-
const logErr = (...args) => bytecodeLog.error(args.join(" "), { timestamp: true });
|
|
50
95
|
const bytecodePath = getBytecodeCompilerPath();
|
|
51
96
|
return new Promise((resolve, reject) => {
|
|
52
97
|
const proc = cp.spawn(electronPath, [bytecodePath], {
|
|
@@ -144,4 +189,4 @@ function convertLiteral(code, sourcemap, offset) {
|
|
|
144
189
|
};
|
|
145
190
|
}
|
|
146
191
|
|
|
147
|
-
export { bytecodeModuleLoader, compileToBytecode, convertArrowFunctionAndTemplate, convertLiteral,
|
|
192
|
+
export { bytecodeModuleLoader, bytecodeModuleLoaderCode, compileToBytecode, convertArrowFunctionAndTemplate, convertLiteral, defaultVersionJsonGenerator, electronMajorVersion, isUpdateJSON, toRelativePath, useStrict };
|
|
@@ -29,17 +29,17 @@ function parseVersion(version) {
|
|
|
29
29
|
}
|
|
30
30
|
return ret;
|
|
31
31
|
}
|
|
32
|
+
function compareStrings(str1, str2) {
|
|
33
|
+
if (str1 === "") {
|
|
34
|
+
return str2 !== "";
|
|
35
|
+
} else if (str2 === "") {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return str1 < str2;
|
|
39
|
+
}
|
|
32
40
|
function defaultIsLowerVersion(oldVer, newVer) {
|
|
33
41
|
const oldV = parseVersion(oldVer);
|
|
34
42
|
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
43
|
for (let key of Object.keys(oldV)) {
|
|
44
44
|
if (key === "stage" && compareStrings(oldV[key], newV[key])) {
|
|
45
45
|
return true;
|
|
@@ -49,8 +49,8 @@ function defaultIsLowerVersion(oldVer, newVer) {
|
|
|
49
49
|
}
|
|
50
50
|
return false;
|
|
51
51
|
}
|
|
52
|
+
var is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
52
53
|
function isUpdateJSON(json) {
|
|
53
|
-
const is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
54
54
|
return is(json) && is(json?.beta);
|
|
55
55
|
}
|
|
56
56
|
function defaultVersionJsonGenerator(existingJson, signature, version, minimumVersion) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { log } from './chunk-5NKEXGI3.js';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
|
|
4
|
+
function readableSize(size) {
|
|
5
|
+
const units = ["B", "KB", "MB", "GB"];
|
|
6
|
+
let i = 0;
|
|
7
|
+
while (size >= 1024 && i < units.length - 1) {
|
|
8
|
+
size /= 1024;
|
|
9
|
+
i++;
|
|
10
|
+
}
|
|
11
|
+
return `${size.toFixed(2)} ${units[i]}`;
|
|
12
|
+
}
|
|
13
|
+
function copyAndSkipIfExist(from, to, skipIfExist) {
|
|
14
|
+
if (!skipIfExist || !fs.existsSync(to)) {
|
|
15
|
+
try {
|
|
16
|
+
fs.cpSync(from, to, { recursive: true });
|
|
17
|
+
} catch (error) {
|
|
18
|
+
log.warn(`Copy failed: ${error}`, { timestamp: true });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { copyAndSkipIfExist, readableSize };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { electronMajorVersion } from './chunk-
|
|
1
|
+
import { electronMajorVersion } from './chunk-7JCGLFGU.js';
|
|
2
|
+
import { esmId } from './chunk-5NKEXGI3.js';
|
|
2
3
|
import MagicString from 'magic-string';
|
|
3
4
|
|
|
4
5
|
// src/vite/esm/constant.ts
|
|
@@ -41,4 +42,23 @@ function insertCJSShim(code, sourcemap, insertPosition = 0) {
|
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
// src/vite/esm/index.ts
|
|
46
|
+
function esm() {
|
|
47
|
+
let sourcemap;
|
|
48
|
+
return {
|
|
49
|
+
name: esmId,
|
|
50
|
+
enforce: "post",
|
|
51
|
+
configResolved(config) {
|
|
52
|
+
sourcemap = config.build.sourcemap;
|
|
53
|
+
},
|
|
54
|
+
renderChunk(code, _chunk, options) {
|
|
55
|
+
if (options.format === "es") {
|
|
56
|
+
const lastESMImport = findStaticImports(code).pop();
|
|
57
|
+
const pos = lastESMImport ? lastESMImport.end : 0;
|
|
58
|
+
return insertCJSShim(code, sourcemap, pos);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { esm };
|
package/dist/index.cjs
CHANGED
|
@@ -19,8 +19,8 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
// src/utils/version.ts
|
|
22
|
+
var is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
22
23
|
function isUpdateJSON(json) {
|
|
23
|
-
const is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
24
24
|
return is(json) && is(json?.beta);
|
|
25
25
|
}
|
|
26
26
|
var isDev = __EIU_IS_DEV__;
|
|
@@ -40,6 +40,9 @@ function restartApp() {
|
|
|
40
40
|
electron__default.default.app.relaunch();
|
|
41
41
|
electron__default.default.app.quit();
|
|
42
42
|
}
|
|
43
|
+
function getPathFromMain(...paths) {
|
|
44
|
+
return isDev ? path__default.default.join(electron__default.default.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "main", ...paths) : getPathFromAppNameAsar("main", ...paths);
|
|
45
|
+
}
|
|
43
46
|
|
|
44
47
|
// src/entry/types.ts
|
|
45
48
|
var UpdaterError = class extends Error {
|
|
@@ -103,7 +106,7 @@ var Updater = class extends events.EventEmitter {
|
|
|
103
106
|
}
|
|
104
107
|
this.logger?.debug(`Download from \`${this.provider.name}\``);
|
|
105
108
|
try {
|
|
106
|
-
const result = format === "json" ? await this.provider.downloadJSON(
|
|
109
|
+
const result = format === "json" ? await this.provider.downloadJSON(electron__default.default.app.name, __EIU_VERSION_PATH__, this.controller.signal) : await this.provider.downloadAsar(this.info, this.controller.signal, (info) => this.emit("download-progress", info));
|
|
107
110
|
this.logger?.debug(`Download ${format} success${format === "buffer" ? `, file size: ${result.length}` : ""}`);
|
|
108
111
|
return result;
|
|
109
112
|
} catch (e) {
|
|
@@ -232,11 +235,7 @@ var defaultOnInstall = (install, _, __, logger) => {
|
|
|
232
235
|
async function createElectronApp(appOptions = {}) {
|
|
233
236
|
const appNameAsarPath = getPathFromAppNameAsar();
|
|
234
237
|
const {
|
|
235
|
-
mainPath =
|
|
236
|
-
isDev ? path__default.default.join(electron.app.getAppPath(), __EIU_MAIN_DEV_DIR__) : appNameAsarPath,
|
|
237
|
-
"main",
|
|
238
|
-
__EIU_MAIN_FILE__
|
|
239
|
-
),
|
|
238
|
+
mainPath = getPathFromMain(__EIU_MAIN_FILE__),
|
|
240
239
|
updater,
|
|
241
240
|
onInstall = defaultOnInstall,
|
|
242
241
|
beforeStart,
|
|
@@ -259,7 +258,7 @@ async function createElectronApp(appOptions = {}) {
|
|
|
259
258
|
} catch (error) {
|
|
260
259
|
logger?.error("startup error", error);
|
|
261
260
|
onStartError?.(error, logger);
|
|
262
|
-
|
|
261
|
+
electron__default.default.app.quit();
|
|
263
262
|
}
|
|
264
263
|
}
|
|
265
264
|
var initApp = createElectronApp;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,46 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
|
-
import { U as
|
|
3
|
-
import {
|
|
4
|
-
export { f as UpdateInfoWithURL, e as UpdaterErrorCode } from './types-BPH66pNz.cjs';
|
|
2
|
+
import { U as UpdateInfo, a as UpdateJSON } from './version-BYVQ367i.cjs';
|
|
3
|
+
import { I as IProvider, D as DownloadingInfo, U as UpdateJSONWithURL } from './types-C6lSLZWB.cjs';
|
|
5
4
|
import { Promisable } from '@subframe7536/type-utils';
|
|
6
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
|
+
type UpdateInfoWithExtraVersion = UpdateInfo & {
|
|
40
|
+
appVersion: string;
|
|
41
|
+
entryVersion: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
7
44
|
declare class Updater extends EventEmitter<{
|
|
8
45
|
'checking': any;
|
|
9
46
|
'update-available': [data: UpdateInfoWithExtraVersion];
|
|
@@ -143,4 +180,4 @@ declare function createElectronApp(appOptions?: AppOption): Promise<void>;
|
|
|
143
180
|
*/
|
|
144
181
|
declare const initApp: typeof createElectronApp;
|
|
145
182
|
|
|
146
|
-
export { type AppOption, Logger, UpdateInfoWithExtraVersion, Updater, UpdaterError, UpdaterOption, UpdaterUnavailableCode, autoUpdate, createElectronApp, initApp, startupWithUpdater };
|
|
183
|
+
export { type AppOption, type Logger, type UpdateInfoWithExtraVersion, Updater, UpdaterError, type UpdaterErrorCode, type UpdaterOption, type UpdaterUnavailableCode, autoUpdate, createElectronApp, initApp, startupWithUpdater };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,46 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
|
-
import { U as
|
|
3
|
-
import {
|
|
4
|
-
export { f as UpdateInfoWithURL, e as UpdaterErrorCode } from './types-DQKdsHc_.js';
|
|
2
|
+
import { U as UpdateInfo, a as UpdateJSON } from './version-BYVQ367i.js';
|
|
3
|
+
import { I as IProvider, D as DownloadingInfo, U as UpdateJSONWithURL } from './types-nE_pIMPo.js';
|
|
5
4
|
import { Promisable } from '@subframe7536/type-utils';
|
|
6
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
|
+
type UpdateInfoWithExtraVersion = UpdateInfo & {
|
|
40
|
+
appVersion: string;
|
|
41
|
+
entryVersion: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
7
44
|
declare class Updater extends EventEmitter<{
|
|
8
45
|
'checking': any;
|
|
9
46
|
'update-available': [data: UpdateInfoWithExtraVersion];
|
|
@@ -143,4 +180,4 @@ declare function createElectronApp(appOptions?: AppOption): Promise<void>;
|
|
|
143
180
|
*/
|
|
144
181
|
declare const initApp: typeof createElectronApp;
|
|
145
182
|
|
|
146
|
-
export { type AppOption, Logger, UpdateInfoWithExtraVersion, Updater, UpdaterError, UpdaterOption, UpdaterUnavailableCode, autoUpdate, createElectronApp, initApp, startupWithUpdater };
|
|
183
|
+
export { type AppOption, type Logger, type UpdateInfoWithExtraVersion, Updater, UpdaterError, type UpdaterErrorCode, type UpdaterOption, type UpdaterUnavailableCode, autoUpdate, createElectronApp, initApp, startupWithUpdater };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { isDev, getAppVersion, getEntryVersion, getPathFromAppNameAsar, restartApp } from './chunk-
|
|
2
|
-
import { isUpdateJSON, __require } from './chunk-
|
|
1
|
+
import { isDev, getAppVersion, getEntryVersion, getPathFromAppNameAsar, restartApp, getPathFromMain } from './chunk-JI27JWJN.js';
|
|
2
|
+
import { isUpdateJSON, __require } from './chunk-AAAM44NW.js';
|
|
3
3
|
import fs2 from 'node:fs';
|
|
4
4
|
import { EventEmitter } from 'node:events';
|
|
5
|
-
import
|
|
6
|
-
import path from 'node:path';
|
|
5
|
+
import electron from 'electron';
|
|
7
6
|
|
|
8
7
|
// src/entry/types.ts
|
|
9
8
|
var UpdaterError = class extends Error {
|
|
@@ -67,7 +66,7 @@ var Updater = class extends EventEmitter {
|
|
|
67
66
|
}
|
|
68
67
|
this.logger?.debug(`Download from \`${this.provider.name}\``);
|
|
69
68
|
try {
|
|
70
|
-
const result = format === "json" ? await this.provider.downloadJSON(app.name, __EIU_VERSION_PATH__, this.controller.signal) : await this.provider.downloadAsar(this.info, this.controller.signal, (info) => this.emit("download-progress", info));
|
|
69
|
+
const result = format === "json" ? await this.provider.downloadJSON(electron.app.name, __EIU_VERSION_PATH__, this.controller.signal) : await this.provider.downloadAsar(this.info, this.controller.signal, (info) => this.emit("download-progress", info));
|
|
71
70
|
this.logger?.debug(`Download ${format} success${format === "buffer" ? `, file size: ${result.length}` : ""}`);
|
|
72
71
|
return result;
|
|
73
72
|
} catch (e) {
|
|
@@ -196,11 +195,7 @@ var defaultOnInstall = (install, _, __, logger) => {
|
|
|
196
195
|
async function createElectronApp(appOptions = {}) {
|
|
197
196
|
const appNameAsarPath = getPathFromAppNameAsar();
|
|
198
197
|
const {
|
|
199
|
-
mainPath =
|
|
200
|
-
isDev ? path.join(app.getAppPath(), __EIU_MAIN_DEV_DIR__) : appNameAsarPath,
|
|
201
|
-
"main",
|
|
202
|
-
__EIU_MAIN_FILE__
|
|
203
|
-
),
|
|
198
|
+
mainPath = getPathFromMain(__EIU_MAIN_FILE__),
|
|
204
199
|
updater,
|
|
205
200
|
onInstall = defaultOnInstall,
|
|
206
201
|
beforeStart,
|
|
@@ -223,7 +218,7 @@ async function createElectronApp(appOptions = {}) {
|
|
|
223
218
|
} catch (error) {
|
|
224
219
|
logger?.error("startup error", error);
|
|
225
220
|
onStartError?.(error, logger);
|
|
226
|
-
app.quit();
|
|
221
|
+
electron.app.quit();
|
|
227
222
|
}
|
|
228
223
|
}
|
|
229
224
|
var initApp = createElectronApp;
|
package/dist/provider.cjs
CHANGED
|
@@ -37,17 +37,17 @@ function parseVersion(version) {
|
|
|
37
37
|
}
|
|
38
38
|
return ret;
|
|
39
39
|
}
|
|
40
|
+
function compareStrings(str1, str2) {
|
|
41
|
+
if (str1 === "") {
|
|
42
|
+
return str2 !== "";
|
|
43
|
+
} else if (str2 === "") {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return str1 < str2;
|
|
47
|
+
}
|
|
40
48
|
function defaultIsLowerVersion(oldVer, newVer) {
|
|
41
49
|
const oldV = parseVersion(oldVer);
|
|
42
50
|
const newV = parseVersion(newVer);
|
|
43
|
-
function compareStrings(str1, str2) {
|
|
44
|
-
if (str1 === "") {
|
|
45
|
-
return str2 !== "";
|
|
46
|
-
} else if (str2 === "") {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
return str1 < str2;
|
|
50
|
-
}
|
|
51
51
|
for (let key of Object.keys(oldV)) {
|
|
52
52
|
if (key === "stage" && compareStrings(oldV[key], newV[key])) {
|
|
53
53
|
return true;
|
|
@@ -57,8 +57,8 @@ function defaultIsLowerVersion(oldVer, newVer) {
|
|
|
57
57
|
}
|
|
58
58
|
return false;
|
|
59
59
|
}
|
|
60
|
+
var is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
60
61
|
function isUpdateJSON(json) {
|
|
61
|
-
const is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
62
62
|
return is(json) && is(json?.beta);
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -141,7 +141,7 @@ async function defaultDownloadAsar(url, headers, signal, onDownloading) {
|
|
|
141
141
|
transferred += delta;
|
|
142
142
|
const current = Date.now();
|
|
143
143
|
onDownloading?.({
|
|
144
|
-
percent: total ? +(transferred / total).toFixed(2) * 100 : -1,
|
|
144
|
+
percent: total > 0 ? +(transferred / total).toFixed(2) * 100 : -1,
|
|
145
145
|
total,
|
|
146
146
|
transferred,
|
|
147
147
|
delta,
|
package/dist/provider.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { I as IProvider,
|
|
2
|
-
import { f as defaultVerifySignature, a as defaultUnzipFile } from './
|
|
3
|
-
import { d as defaultIsLowerVersion,
|
|
1
|
+
import { I as IProvider, U as UpdateJSONWithURL, a as UpdateInfoWithURL, D as DownloadingInfo, b as URLHandler, O as OnDownloading } from './types-C6lSLZWB.cjs';
|
|
2
|
+
import { f as defaultVerifySignature, a as defaultUnzipFile } from './crypto-Zynscwmj.cjs';
|
|
3
|
+
import { d as defaultIsLowerVersion, a as UpdateJSON } from './version-BYVQ367i.cjs';
|
|
4
4
|
import { Arrayable } from '@subframe7536/type-utils';
|
|
5
5
|
|
|
6
6
|
declare abstract class BaseProvider implements IProvider {
|
|
@@ -163,4 +163,4 @@ declare function defaultDownloadUpdateJSON(url: string, headers: Record<string,
|
|
|
163
163
|
*/
|
|
164
164
|
declare function defaultDownloadAsar(url: string, headers: Record<string, any>, signal: AbortSignal, onDownloading?: OnDownloading): Promise<Buffer>;
|
|
165
165
|
|
|
166
|
-
export { BaseProvider, DownloadingInfo, GitHubApiProvider, type GitHubApiProviderOptions, GitHubProvider, type GitHubProviderOptions, IProvider, OnDownloading, URLHandler, UpdateJSONWithURL, defaultDownloadAsar, defaultDownloadJSON, defaultDownloadUpdateJSON, getHeader };
|
|
166
|
+
export { BaseProvider, DownloadingInfo, GitHubApiProvider, type GitHubApiProviderOptions, GitHubProvider, type GitHubProviderOptions, IProvider, OnDownloading, URLHandler, UpdateInfoWithURL, UpdateJSONWithURL, defaultDownloadAsar, defaultDownloadJSON, defaultDownloadUpdateJSON, getHeader };
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { I as IProvider,
|
|
2
|
-
import { f as defaultVerifySignature, a as defaultUnzipFile } from './
|
|
3
|
-
import { d as defaultIsLowerVersion,
|
|
1
|
+
import { I as IProvider, U as UpdateJSONWithURL, a as UpdateInfoWithURL, D as DownloadingInfo, b as URLHandler, O as OnDownloading } from './types-nE_pIMPo.js';
|
|
2
|
+
import { f as defaultVerifySignature, a as defaultUnzipFile } from './crypto-Zynscwmj.js';
|
|
3
|
+
import { d as defaultIsLowerVersion, a as UpdateJSON } from './version-BYVQ367i.js';
|
|
4
4
|
import { Arrayable } from '@subframe7536/type-utils';
|
|
5
5
|
|
|
6
6
|
declare abstract class BaseProvider implements IProvider {
|
|
@@ -163,4 +163,4 @@ declare function defaultDownloadUpdateJSON(url: string, headers: Record<string,
|
|
|
163
163
|
*/
|
|
164
164
|
declare function defaultDownloadAsar(url: string, headers: Record<string, any>, signal: AbortSignal, onDownloading?: OnDownloading): Promise<Buffer>;
|
|
165
165
|
|
|
166
|
-
export { BaseProvider, DownloadingInfo, GitHubApiProvider, type GitHubApiProviderOptions, GitHubProvider, type GitHubProviderOptions, IProvider, OnDownloading, URLHandler, UpdateJSONWithURL, defaultDownloadAsar, defaultDownloadJSON, defaultDownloadUpdateJSON, getHeader };
|
|
166
|
+
export { BaseProvider, DownloadingInfo, GitHubApiProvider, type GitHubApiProviderOptions, GitHubProvider, type GitHubProviderOptions, IProvider, OnDownloading, URLHandler, UpdateInfoWithURL, UpdateJSONWithURL, defaultDownloadAsar, defaultDownloadJSON, defaultDownloadUpdateJSON, getHeader };
|
package/dist/provider.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defaultVerifySignature, defaultUnzipFile } from './chunk-PUVBFHOK.js';
|
|
2
|
-
import { isUpdateJSON, defaultIsLowerVersion } from './chunk-
|
|
2
|
+
import { isUpdateJSON, defaultIsLowerVersion } from './chunk-AAAM44NW.js';
|
|
3
3
|
import { URL } from 'node:url';
|
|
4
4
|
import electron from 'electron';
|
|
5
5
|
|
|
@@ -81,7 +81,7 @@ async function defaultDownloadAsar(url, headers, signal, onDownloading) {
|
|
|
81
81
|
transferred += delta;
|
|
82
82
|
const current = Date.now();
|
|
83
83
|
onDownloading?.({
|
|
84
|
-
percent: total ? +(transferred / total).toFixed(2) * 100 : -1,
|
|
84
|
+
percent: total > 0 ? +(transferred / total).toFixed(2) * 100 : -1,
|
|
85
85
|
total,
|
|
86
86
|
transferred,
|
|
87
87
|
delta,
|
|
@@ -1,47 +1,9 @@
|
|
|
1
1
|
import { Promisable } from '@subframe7536/type-utils';
|
|
2
|
-
import {
|
|
2
|
+
import { U as UpdateInfo } from './version-BYVQ367i.cjs';
|
|
3
3
|
|
|
4
|
-
type UpdaterErrorCode = 'ERR_DOWNLOAD' | 'ERR_VALIDATE' | 'ERR_PARAM' | 'ERR_NETWORK';
|
|
5
|
-
type UpdaterUnavailableCode = 'UNAVAILABLE_ERROR' | 'UNAVAILABLE_DEV' | 'UNAVAILABLE_VERSION';
|
|
6
|
-
declare class UpdaterError extends Error {
|
|
7
|
-
code: UpdaterErrorCode;
|
|
8
|
-
constructor(code: UpdaterErrorCode, 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
4
|
type UpdateInfoWithURL = UpdateInfo & {
|
|
38
5
|
url: string;
|
|
39
6
|
};
|
|
40
|
-
type UpdateInfoWithExtraVersion = UpdateInfo & {
|
|
41
|
-
appVersion: string;
|
|
42
|
-
entryVersion: string;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
7
|
type OnDownloading = (progress: DownloadingInfo) => void;
|
|
46
8
|
interface DownloadingInfo {
|
|
47
9
|
/**
|
|
@@ -114,4 +76,4 @@ interface IProvider {
|
|
|
114
76
|
}
|
|
115
77
|
type URLHandler = (url: URL) => Promisable<URL | string | undefined | null>;
|
|
116
78
|
|
|
117
|
-
export {
|
|
79
|
+
export type { DownloadingInfo as D, IProvider as I, OnDownloading as O, UpdateJSONWithURL as U, UpdateInfoWithURL as a, URLHandler as b };
|