electron-incremental-update 0.7.6 → 0.7.7
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/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -11
- package/dist/index.mjs +8 -11
- package/dist/vite.js +2 -28
- package/dist/vite.mjs +2 -18
- package/package.json +2 -3
package/dist/index.d.mts
CHANGED
|
@@ -4,6 +4,7 @@ type CheckResultType = Omit<UpdateJSON, 'signature'> | undefined | Error;
|
|
|
4
4
|
type InstallResult = true | Error;
|
|
5
5
|
type UpdateEvents = {
|
|
6
6
|
downloading: [progress: number];
|
|
7
|
+
downloadBuffer: [buffer: Buffer];
|
|
7
8
|
debug: [msg: string | Error];
|
|
8
9
|
};
|
|
9
10
|
type UpdateJSON = {
|
|
@@ -40,7 +41,7 @@ interface TypedUpdater<T extends Record<string | symbol, MaybeArray<any>>, Event
|
|
|
40
41
|
* - `Error`: fail
|
|
41
42
|
*/
|
|
42
43
|
download(data?: string | Buffer, sig?: string): Promise<InstallResult>;
|
|
43
|
-
|
|
44
|
+
debugMode: boolean;
|
|
44
45
|
productName: string;
|
|
45
46
|
}
|
|
46
47
|
type FunctionVerifySignature = (buffer: Buffer, signature: string, cert: string) => string | false;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ type CheckResultType = Omit<UpdateJSON, 'signature'> | undefined | Error;
|
|
|
4
4
|
type InstallResult = true | Error;
|
|
5
5
|
type UpdateEvents = {
|
|
6
6
|
downloading: [progress: number];
|
|
7
|
+
downloadBuffer: [buffer: Buffer];
|
|
7
8
|
debug: [msg: string | Error];
|
|
8
9
|
};
|
|
9
10
|
type UpdateJSON = {
|
|
@@ -40,7 +41,7 @@ interface TypedUpdater<T extends Record<string | symbol, MaybeArray<any>>, Event
|
|
|
40
41
|
* - `Error`: fail
|
|
41
42
|
*/
|
|
42
43
|
download(data?: string | Buffer, sig?: string): Promise<InstallResult>;
|
|
43
|
-
|
|
44
|
+
debugMode: boolean;
|
|
44
45
|
productName: string;
|
|
45
46
|
}
|
|
46
47
|
type FunctionVerifySignature = (buffer: Buffer, signature: string, cert: string) => string | false;
|
package/dist/index.js
CHANGED
|
@@ -26,14 +26,13 @@ __export(src_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(src_exports);
|
|
27
27
|
var import_node_path2 = require("path");
|
|
28
28
|
var import_node_fs3 = require("fs");
|
|
29
|
-
var
|
|
29
|
+
var import_electron3 = require("electron");
|
|
30
30
|
|
|
31
31
|
// src/updater/index.ts
|
|
32
32
|
var import_node_events = require("events");
|
|
33
33
|
var import_node_buffer3 = require("buffer");
|
|
34
34
|
var import_node_fs2 = require("fs");
|
|
35
35
|
var import_promises = require("fs/promises");
|
|
36
|
-
var import_electron3 = require("electron");
|
|
37
36
|
|
|
38
37
|
// src/crypto.ts
|
|
39
38
|
var import_node_crypto = require("crypto");
|
|
@@ -214,18 +213,13 @@ function createUpdater(updaterOptions) {
|
|
|
214
213
|
const updater = new import_node_events.EventEmitter();
|
|
215
214
|
let signature;
|
|
216
215
|
let version;
|
|
217
|
-
let _debug = debug;
|
|
218
216
|
const asarPath = getProductAsarPath(productName);
|
|
219
217
|
const gzipPath = `${asarPath}.gz`;
|
|
220
218
|
const tmpFilePath = `${asarPath}.tmp`;
|
|
221
219
|
function log(msg) {
|
|
222
|
-
|
|
220
|
+
debug && updater.emit("debug", msg);
|
|
223
221
|
}
|
|
224
222
|
function needUpdate(version2) {
|
|
225
|
-
if (!import_electron3.app.isPackaged) {
|
|
226
|
-
log("in dev mode, no need to update");
|
|
227
|
-
return false;
|
|
228
|
-
}
|
|
229
223
|
const currentVersion = getEntryVersion();
|
|
230
224
|
log(`check update: current version is ${currentVersion}, new version is ${version2}`);
|
|
231
225
|
const _compare = compareVersion ?? compareVersionDefault;
|
|
@@ -279,13 +273,16 @@ function createUpdater(updaterOptions) {
|
|
|
279
273
|
log(`download ${format} from ${data}`);
|
|
280
274
|
const ret = await info.fn(data, updater, headers);
|
|
281
275
|
log(`download ${format} success${format === "buffer" ? `, file size: ${ret.length}` : ""}`);
|
|
276
|
+
if (format === "buffer") {
|
|
277
|
+
updater.emit("downloadBuffer", ret);
|
|
278
|
+
}
|
|
282
279
|
return ret;
|
|
283
280
|
} else {
|
|
284
281
|
throw new Error(`invalid type at format '${format}': ${data}`);
|
|
285
282
|
}
|
|
286
283
|
}
|
|
287
284
|
updater.productName = productName;
|
|
288
|
-
updater.
|
|
285
|
+
updater.debugMode = debug;
|
|
289
286
|
updater.checkUpdate = async (data) => {
|
|
290
287
|
try {
|
|
291
288
|
const { signature: _sig, size, version: _ver } = await parseData("json", data);
|
|
@@ -343,7 +340,7 @@ function initApp(appOptions) {
|
|
|
343
340
|
} = appOptions || {};
|
|
344
341
|
function handleError(msg) {
|
|
345
342
|
onStartError?.(new Error(msg));
|
|
346
|
-
|
|
343
|
+
import_electron3.app.quit();
|
|
347
344
|
}
|
|
348
345
|
function startup(updater) {
|
|
349
346
|
try {
|
|
@@ -351,7 +348,7 @@ function initApp(appOptions) {
|
|
|
351
348
|
if ((0, import_node_fs3.existsSync)(`${asarPath}.tmp`)) {
|
|
352
349
|
(0, import_node_fs3.renameSync)(`${asarPath}.tmp`, asarPath);
|
|
353
350
|
}
|
|
354
|
-
const mainDir =
|
|
351
|
+
const mainDir = import_electron3.app.isPackaged ? asarPath : electronDevDistPath;
|
|
355
352
|
const entry = (0, import_node_path2.resolve)(__dirname, mainDir, mainPath);
|
|
356
353
|
onStart?.(entry);
|
|
357
354
|
require(entry)(updater);
|
package/dist/index.mjs
CHANGED
|
@@ -12,14 +12,13 @@ import {
|
|
|
12
12
|
// src/index.ts
|
|
13
13
|
import { resolve } from "node:path";
|
|
14
14
|
import { existsSync as existsSync2, renameSync } from "node:fs";
|
|
15
|
-
import { app
|
|
15
|
+
import { app } from "electron";
|
|
16
16
|
|
|
17
17
|
// src/updater/index.ts
|
|
18
18
|
import { EventEmitter } from "node:events";
|
|
19
19
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
20
20
|
import { existsSync } from "node:fs";
|
|
21
21
|
import { rm, writeFile } from "node:fs/promises";
|
|
22
|
-
import { app } from "electron";
|
|
23
22
|
|
|
24
23
|
// src/updater/defaultFunctions.ts
|
|
25
24
|
import { Buffer } from "node:buffer";
|
|
@@ -138,18 +137,13 @@ function createUpdater(updaterOptions) {
|
|
|
138
137
|
const updater = new EventEmitter();
|
|
139
138
|
let signature;
|
|
140
139
|
let version;
|
|
141
|
-
let _debug = debug;
|
|
142
140
|
const asarPath = getProductAsarPath(productName);
|
|
143
141
|
const gzipPath = `${asarPath}.gz`;
|
|
144
142
|
const tmpFilePath = `${asarPath}.tmp`;
|
|
145
143
|
function log(msg) {
|
|
146
|
-
|
|
144
|
+
debug && updater.emit("debug", msg);
|
|
147
145
|
}
|
|
148
146
|
function needUpdate(version2) {
|
|
149
|
-
if (!app.isPackaged) {
|
|
150
|
-
log("in dev mode, no need to update");
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
147
|
const currentVersion = getEntryVersion();
|
|
154
148
|
log(`check update: current version is ${currentVersion}, new version is ${version2}`);
|
|
155
149
|
const _compare = compareVersion ?? compareVersionDefault;
|
|
@@ -203,13 +197,16 @@ function createUpdater(updaterOptions) {
|
|
|
203
197
|
log(`download ${format} from ${data}`);
|
|
204
198
|
const ret = await info.fn(data, updater, headers);
|
|
205
199
|
log(`download ${format} success${format === "buffer" ? `, file size: ${ret.length}` : ""}`);
|
|
200
|
+
if (format === "buffer") {
|
|
201
|
+
updater.emit("downloadBuffer", ret);
|
|
202
|
+
}
|
|
206
203
|
return ret;
|
|
207
204
|
} else {
|
|
208
205
|
throw new Error(`invalid type at format '${format}': ${data}`);
|
|
209
206
|
}
|
|
210
207
|
}
|
|
211
208
|
updater.productName = productName;
|
|
212
|
-
updater.
|
|
209
|
+
updater.debugMode = debug;
|
|
213
210
|
updater.checkUpdate = async (data) => {
|
|
214
211
|
try {
|
|
215
212
|
const { signature: _sig, size, version: _ver } = await parseData("json", data);
|
|
@@ -267,7 +264,7 @@ function initApp(appOptions) {
|
|
|
267
264
|
} = appOptions || {};
|
|
268
265
|
function handleError(msg) {
|
|
269
266
|
onStartError?.(new Error(msg));
|
|
270
|
-
|
|
267
|
+
app.quit();
|
|
271
268
|
}
|
|
272
269
|
function startup(updater) {
|
|
273
270
|
try {
|
|
@@ -275,7 +272,7 @@ function initApp(appOptions) {
|
|
|
275
272
|
if (existsSync2(`${asarPath}.tmp`)) {
|
|
276
273
|
renameSync(`${asarPath}.tmp`, asarPath);
|
|
277
274
|
}
|
|
278
|
-
const mainDir =
|
|
275
|
+
const mainDir = app.isPackaged ? asarPath : electronDevDistPath;
|
|
279
276
|
const entry = resolve(__dirname, mainDir, mainPath);
|
|
280
277
|
onStart?.(entry);
|
|
281
278
|
__require(entry)(updater);
|
package/dist/vite.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/vite.ts
|
|
@@ -37,6 +27,7 @@ var import_vite = require("vite");
|
|
|
37
27
|
|
|
38
28
|
// src/build-plugins/build.ts
|
|
39
29
|
var import_promises = require("fs/promises");
|
|
30
|
+
var import_asar = require("@electron/asar");
|
|
40
31
|
var import_esbuild = require("esbuild");
|
|
41
32
|
|
|
42
33
|
// src/crypto.ts
|
|
@@ -79,23 +70,6 @@ async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
|
|
|
79
70
|
}
|
|
80
71
|
|
|
81
72
|
// src/build-plugins/build.ts
|
|
82
|
-
async function pack(dir, target) {
|
|
83
|
-
let asar = null;
|
|
84
|
-
try {
|
|
85
|
-
asar = await import("asar");
|
|
86
|
-
} catch (ignore) {
|
|
87
|
-
}
|
|
88
|
-
if (!asar) {
|
|
89
|
-
try {
|
|
90
|
-
asar = await import("@electron/asar");
|
|
91
|
-
} catch (ignore) {
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (!asar) {
|
|
95
|
-
throw new Error("no asar, please install @electron/asar");
|
|
96
|
-
}
|
|
97
|
-
await asar.createPackage(dir, target);
|
|
98
|
-
}
|
|
99
73
|
async function buildAsar({
|
|
100
74
|
version,
|
|
101
75
|
asarOutputPath,
|
|
@@ -105,7 +79,7 @@ async function buildAsar({
|
|
|
105
79
|
}) {
|
|
106
80
|
await (0, import_promises.rename)(rendererDistPath, `${electronDistPath}/renderer`);
|
|
107
81
|
await (0, import_promises.writeFile)(`${electronDistPath}/version`, version);
|
|
108
|
-
await
|
|
82
|
+
await (0, import_asar.createPackage)(electronDistPath, asarOutputPath);
|
|
109
83
|
await zipFile(asarOutputPath, gzipPath);
|
|
110
84
|
}
|
|
111
85
|
async function buildVersion({
|
package/dist/vite.mjs
CHANGED
|
@@ -10,24 +10,8 @@ import { createLogger } from "vite";
|
|
|
10
10
|
|
|
11
11
|
// src/build-plugins/build.ts
|
|
12
12
|
import { readFile, rename, writeFile } from "node:fs/promises";
|
|
13
|
+
import { createPackage } from "@electron/asar";
|
|
13
14
|
import { build } from "esbuild";
|
|
14
|
-
async function pack(dir, target) {
|
|
15
|
-
let asar = null;
|
|
16
|
-
try {
|
|
17
|
-
asar = await import("asar");
|
|
18
|
-
} catch (ignore) {
|
|
19
|
-
}
|
|
20
|
-
if (!asar) {
|
|
21
|
-
try {
|
|
22
|
-
asar = await import("@electron/asar");
|
|
23
|
-
} catch (ignore) {
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (!asar) {
|
|
27
|
-
throw new Error("no asar, please install @electron/asar");
|
|
28
|
-
}
|
|
29
|
-
await asar.createPackage(dir, target);
|
|
30
|
-
}
|
|
31
15
|
async function buildAsar({
|
|
32
16
|
version,
|
|
33
17
|
asarOutputPath,
|
|
@@ -37,7 +21,7 @@ async function buildAsar({
|
|
|
37
21
|
}) {
|
|
38
22
|
await rename(rendererDistPath, `${electronDistPath}/renderer`);
|
|
39
23
|
await writeFile(`${electronDistPath}/version`, version);
|
|
40
|
-
await
|
|
24
|
+
await createPackage(electronDistPath, asarOutputPath);
|
|
41
25
|
await zipFile(asarOutputPath, gzipPath);
|
|
42
26
|
}
|
|
43
27
|
async function buildVersion({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-incremental-update",
|
|
3
3
|
"author": "subframe7536",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.7",
|
|
5
5
|
"description": "electron incremental update tools, powered by vite",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsup && node fix-module.js",
|
|
@@ -43,10 +43,8 @@
|
|
|
43
43
|
"updater"
|
|
44
44
|
],
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@electron/asar": "^3.2.4",
|
|
47
46
|
"@subframe7536/eslint-config": "^0.1.9",
|
|
48
47
|
"@types/node": "^20.3.2",
|
|
49
|
-
"asar": "^3.2.0",
|
|
50
48
|
"bumpp": "^9.1.1",
|
|
51
49
|
"electron": "^25.2.0",
|
|
52
50
|
"eslint": "^8.43.0",
|
|
@@ -56,6 +54,7 @@
|
|
|
56
54
|
"vitest": "^0.32.2"
|
|
57
55
|
},
|
|
58
56
|
"dependencies": {
|
|
57
|
+
"@electron/asar": "^3.2.4",
|
|
59
58
|
"ci-info": "^3.8.0",
|
|
60
59
|
"selfsigned": "^2.1.1"
|
|
61
60
|
}
|