electron-incremental-update 2.0.1 → 2.1.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
3
  "type": "module",
4
- "version": "2.0.1",
4
+ "version": "2.1.0",
5
5
  "description": "Electron incremental update tools with Vite plugin, support bytecode protection",
6
6
  "author": "subframe7536",
7
7
  "license": "MIT",
@@ -60,28 +60,28 @@
60
60
  "esbuild": "*"
61
61
  },
62
62
  "dependencies": {
63
- "@babel/core": "^7.24.9",
63
+ "@babel/core": "^7.25.2",
64
64
  "@babel/plugin-transform-arrow-functions": "^7.24.7",
65
65
  "@babel/plugin-transform-template-literals": "^7.24.7",
66
66
  "@subframe7536/type-utils": "^0.1.6",
67
67
  "ci-info": "^4.0.0",
68
68
  "local-pkg": "^0.5.0",
69
- "magic-string": "^0.30.10",
69
+ "magic-string": "^0.30.11",
70
70
  "selfsigned": "^2.4.1",
71
71
  "vite-plugin-electron": "^0.28.7"
72
72
  },
73
73
  "devDependencies": {
74
- "@subframe7536/eslint-config": "^0.7.3",
74
+ "@subframe7536/eslint-config": "^0.7.5",
75
75
  "@types/babel__core": "^7.20.5",
76
- "@types/node": "^20.14.12",
77
- "bumpp": "^9.4.1",
76
+ "@types/node": "^20.14.15",
77
+ "bumpp": "^9.5.1",
78
78
  "electron": "28.2.10",
79
- "eslint": "^9.7.0",
79
+ "eslint": "^9.9.0",
80
80
  "esno": "^4.7.0",
81
- "tsup": "^8.2.2",
81
+ "tsup": "^8.2.4",
82
82
  "typescript": "^5.5.4",
83
- "vite": "^5.3.4",
83
+ "vite": "^5.4.0",
84
84
  "vite-plugin-electron": "^0.28.7",
85
- "vitest": "^2.0.4"
85
+ "vitest": "^2.0.5"
86
86
  }
87
87
  }
@@ -1,87 +0,0 @@
1
- import { __require } from './chunk-RCRKUKFX.js';
2
- import fs from 'node:fs';
3
- import path from 'node: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
- if (__EIU_IS_ESM__) {
21
- throw new Error(`Cannot require "${path.join(__EIU_ENTRY_DIST_PATH__, moduleName)}", \`requireNative\` only support CommonJS`);
22
- }
23
- return __require(getPathFromEntryAsar(moduleName));
24
- }
25
- function restartApp() {
26
- electron.app.relaunch();
27
- electron.app.quit();
28
- }
29
- function setAppUserModelId(id) {
30
- if (isWin) {
31
- electron.app.setAppUserModelId(id ?? `org.${electron.app.name}`);
32
- }
33
- }
34
- function disableHWAccForWin7() {
35
- if (!__EIU_IS_ESM__ && __require("node:os").release().startsWith("6.1")) {
36
- electron.app.disableHardwareAcceleration();
37
- }
38
- }
39
- function singleInstance(window) {
40
- const result = electron.app.requestSingleInstanceLock();
41
- if (result) {
42
- electron.app.on("second-instance", () => {
43
- if (window) {
44
- window.show();
45
- if (window.isMinimized()) {
46
- window.restore();
47
- }
48
- window.focus();
49
- }
50
- });
51
- } else {
52
- electron.app.quit();
53
- }
54
- return result;
55
- }
56
- function setPortableAppDataPath(dirName = "data") {
57
- const portablePath = path.join(path.dirname(electron.app.getPath("exe")), dirName);
58
- if (!fs.existsSync(portablePath)) {
59
- fs.mkdirSync(portablePath);
60
- }
61
- electron.app.setPath("appData", portablePath);
62
- }
63
- function loadPage(win, htmlFilePath = "index.html") {
64
- if (isDev) {
65
- win.loadURL(process.env.VITE_DEV_SERVER_URL + htmlFilePath);
66
- } else {
67
- win.loadFile(getPathFromAppNameAsar("renderer", htmlFilePath));
68
- }
69
- }
70
- function getPathFromMain(...paths) {
71
- return isDev ? path.join(electron.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "main", ...paths) : getPathFromAppNameAsar("main", ...paths);
72
- }
73
- function getPathFromPreload(...paths) {
74
- return isDev ? path.join(electron.app.getAppPath(), __EIU_ELECTRON_DIST_PATH__, "preload", ...paths) : getPathFromAppNameAsar("preload", ...paths);
75
- }
76
- function getPathFromPublic(...paths) {
77
- return isDev ? path.join(electron.app.getAppPath(), "public", ...paths) : getPathFromAppNameAsar("renderer", ...paths);
78
- }
79
- function getPathFromEntryAsar(...paths) {
80
- return path.join(electron.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, ...paths);
81
- }
82
- function handleUnexpectedErrors(callback) {
83
- process.on("uncaughtException", callback);
84
- process.on("unhandledRejection", callback);
85
- }
86
-
87
- export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromMain, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
@@ -1,72 +0,0 @@
1
- import { Promisable } from '@subframe7536/type-utils';
2
- import { a as UpdateJSON, U as UpdateInfo } from './version-BYVQ367i.js';
3
-
4
- type OnDownloading = (progress: DownloadingInfo) => void;
5
- interface DownloadingInfo {
6
- /**
7
- * Download buffer delta
8
- */
9
- delta: number;
10
- /**
11
- * Downloaded percent, 0 ~ 100
12
- *
13
- * If no `Content-Length` header, will be -1
14
- */
15
- percent: number;
16
- /**
17
- * Total size
18
- *
19
- * If not `Content-Length` header, will be -1
20
- */
21
- total: number;
22
- /**
23
- * Downloaded size
24
- */
25
- transferred: number;
26
- /**
27
- * Download speed, bytes per second
28
- */
29
- bps: number;
30
- }
31
- interface IProvider {
32
- /**
33
- * Provider name
34
- */
35
- name: string;
36
- /**
37
- * Download update json
38
- * @param versionPath parsed version path in project
39
- * @param signal abort signal
40
- */
41
- downloadJSON: (versionPath: string, signal: AbortSignal) => Promise<UpdateJSON>;
42
- /**
43
- * Download update asar
44
- * @param name app name
45
- * @param updateInfo existing update info
46
- * @param signal abort signal
47
- * @param onDownloading hook for on downloading
48
- */
49
- downloadAsar: (name: string, updateInfo: UpdateInfo, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void) => Promise<Buffer>;
50
- /**
51
- * Check the old version is less than new version
52
- * @param oldVer old version string
53
- * @param newVer new version string
54
- */
55
- isLowerVersion: (oldVer: string, newVer: string) => boolean;
56
- /**
57
- * Function to decompress file using brotli
58
- * @param buffer compressed file buffer
59
- */
60
- unzipFile: (buffer: Buffer) => Promise<Buffer>;
61
- /**
62
- * Verify asar signature,
63
- * if signature is valid, returns the version, otherwise returns `undefined`
64
- * @param buffer file buffer
65
- * @param version target version
66
- * @param signature signature
67
- * @param cert certificate
68
- */
69
- verifySignaure: (buffer: Buffer, version: string, signature: string, cert: string) => Promisable<boolean>;
70
- }
71
-
72
- export type { DownloadingInfo as D, IProvider as I, OnDownloading as O };
@@ -1,72 +0,0 @@
1
- import { Promisable } from '@subframe7536/type-utils';
2
- import { a as UpdateJSON, U as UpdateInfo } from './version-BYVQ367i.cjs';
3
-
4
- type OnDownloading = (progress: DownloadingInfo) => void;
5
- interface DownloadingInfo {
6
- /**
7
- * Download buffer delta
8
- */
9
- delta: number;
10
- /**
11
- * Downloaded percent, 0 ~ 100
12
- *
13
- * If no `Content-Length` header, will be -1
14
- */
15
- percent: number;
16
- /**
17
- * Total size
18
- *
19
- * If not `Content-Length` header, will be -1
20
- */
21
- total: number;
22
- /**
23
- * Downloaded size
24
- */
25
- transferred: number;
26
- /**
27
- * Download speed, bytes per second
28
- */
29
- bps: number;
30
- }
31
- interface IProvider {
32
- /**
33
- * Provider name
34
- */
35
- name: string;
36
- /**
37
- * Download update json
38
- * @param versionPath parsed version path in project
39
- * @param signal abort signal
40
- */
41
- downloadJSON: (versionPath: string, signal: AbortSignal) => Promise<UpdateJSON>;
42
- /**
43
- * Download update asar
44
- * @param name app name
45
- * @param updateInfo existing update info
46
- * @param signal abort signal
47
- * @param onDownloading hook for on downloading
48
- */
49
- downloadAsar: (name: string, updateInfo: UpdateInfo, signal: AbortSignal, onDownloading?: (info: DownloadingInfo) => void) => Promise<Buffer>;
50
- /**
51
- * Check the old version is less than new version
52
- * @param oldVer old version string
53
- * @param newVer new version string
54
- */
55
- isLowerVersion: (oldVer: string, newVer: string) => boolean;
56
- /**
57
- * Function to decompress file using brotli
58
- * @param buffer compressed file buffer
59
- */
60
- unzipFile: (buffer: Buffer) => Promise<Buffer>;
61
- /**
62
- * Verify asar signature,
63
- * if signature is valid, returns the version, otherwise returns `undefined`
64
- * @param buffer file buffer
65
- * @param version target version
66
- * @param signature signature
67
- * @param cert certificate
68
- */
69
- verifySignaure: (buffer: Buffer, version: string, signature: string, cert: string) => Promisable<boolean>;
70
- }
71
-
72
- export type { DownloadingInfo as D, IProvider as I, OnDownloading as O };