electron-incremental-update 0.8.5 → 0.8.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/README.md +17 -10
- package/dist/{chunk-GXZSAUBR.mjs → chunk-5BZLJPHJ.mjs} +8 -1
- package/dist/chunk-CMBFI77K.mjs +75 -0
- package/dist/chunk-OGAOUYV3.mjs +99 -0
- package/dist/index.d.mts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +74 -57
- package/dist/index.mjs +21 -22
- package/dist/{updateJson.d.mts → updateJson-7e45d9e1.d.ts} +1 -2
- package/dist/utils.d.mts +43 -40
- package/dist/utils.d.ts +43 -40
- package/dist/utils.js +106 -120
- package/dist/utils.mjs +17 -14
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +7 -13
- package/dist/vite.mjs +3 -7
- package/package.json +1 -1
- package/dist/chunk-2JVXVTC5.mjs +0 -9
- package/dist/chunk-CR6HTU6P.mjs +0 -170
- package/dist/chunk-ZFXKCRJC.mjs +0 -11
- package/dist/updateJson.d.ts +0 -12
- package/dist/updateJson.js +0 -33
- package/dist/updateJson.mjs +0 -7
package/dist/utils.d.mts
CHANGED
|
@@ -1,54 +1,67 @@
|
|
|
1
|
+
declare const DEFAULT_APP_NAME = "product";
|
|
1
2
|
type Info = {
|
|
2
3
|
dev: boolean;
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
win: boolean;
|
|
5
|
+
mac: boolean;
|
|
6
|
+
linux: boolean;
|
|
7
|
+
electronVersion: string;
|
|
8
|
+
appVersion: (name?: string) => string;
|
|
9
|
+
/**
|
|
10
|
+
* `os.release()`
|
|
11
|
+
*/
|
|
12
|
+
systemVersion: string;
|
|
5
13
|
};
|
|
6
|
-
declare const info: Info;
|
|
7
14
|
/**
|
|
8
|
-
* get
|
|
15
|
+
* get app info
|
|
16
|
+
*/
|
|
17
|
+
declare const appInfo: Info;
|
|
18
|
+
declare function getLocale(): string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* get the application asar absolute path (not `app.asar`),
|
|
21
|
+
* if is in dev, return `'DEV.asar'`
|
|
9
22
|
* @param name The name of the application
|
|
10
|
-
* @todo support v8 bytecode
|
|
11
23
|
*/
|
|
12
|
-
declare function getProductAsarPath(name
|
|
24
|
+
declare function getProductAsarPath(name?: string): string;
|
|
13
25
|
/**
|
|
14
|
-
* get the version of
|
|
26
|
+
* get the version of Electron runtime
|
|
15
27
|
*/
|
|
16
|
-
declare function
|
|
28
|
+
declare function getElectronVersion(): string;
|
|
17
29
|
/**
|
|
18
30
|
* get the version of application (name.asar)
|
|
19
31
|
*
|
|
20
|
-
* if is dev, return {@link
|
|
32
|
+
* if is dev, return {@link getElectronVersion}
|
|
21
33
|
* @param name - The name of the application
|
|
22
34
|
*/
|
|
23
|
-
declare function
|
|
35
|
+
declare function getAppVersion(name?: string): string;
|
|
24
36
|
declare class NoSuchNativeModuleError extends Error {
|
|
25
37
|
moduleName: string;
|
|
26
38
|
constructor(moduleName: string);
|
|
27
39
|
}
|
|
40
|
+
declare function isNoSuchNativeModuleError(e: unknown): e is NoSuchNativeModuleError;
|
|
28
41
|
/**
|
|
29
|
-
* require native package
|
|
42
|
+
* require native package, if not found, return {@link NoSuchNativeModuleError}
|
|
30
43
|
* @param packageName native package name
|
|
31
|
-
* @throws error: {@link NoSuchNativeModuleError}
|
|
32
44
|
*/
|
|
33
|
-
declare function requireNative<T = any>(packageName: string): T;
|
|
45
|
+
declare function requireNative<T = any>(packageName: string): T | NoSuchNativeModuleError;
|
|
46
|
+
|
|
47
|
+
interface Version {
|
|
48
|
+
major: number;
|
|
49
|
+
minor: number;
|
|
50
|
+
patch: number;
|
|
51
|
+
stage: string;
|
|
52
|
+
stageVersion: number;
|
|
53
|
+
}
|
|
54
|
+
declare function parseVersion(version: string): Version;
|
|
55
|
+
|
|
56
|
+
declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
|
|
57
|
+
declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
|
|
58
|
+
|
|
34
59
|
/**
|
|
35
60
|
* parse Github CDN URL for accelerating the speed of downloading
|
|
61
|
+
*
|
|
62
|
+
* {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 some public CDN links}
|
|
36
63
|
*/
|
|
37
|
-
declare function parseGithubCdnURL(
|
|
38
|
-
/**
|
|
39
|
-
* get group of Github file CDN prefix for accelerating the speed of downloading project files
|
|
40
|
-
*/
|
|
41
|
-
declare function getGithubFileCdnGroup(): {
|
|
42
|
-
cdnPrefix: string;
|
|
43
|
-
source: string;
|
|
44
|
-
}[];
|
|
45
|
-
/**
|
|
46
|
-
* get group of github release CDN prefix for accelerating the speed of downloading release
|
|
47
|
-
*/
|
|
48
|
-
declare function getGithubReleaseCdnGroup(): {
|
|
49
|
-
cdnPrefix: string;
|
|
50
|
-
source: string;
|
|
51
|
-
}[];
|
|
64
|
+
declare function parseGithubCdnURL(originRepoURL: string, cdnPrefix: string, relativeFilePath: string): string;
|
|
52
65
|
/**
|
|
53
66
|
* Restarts the Electron app.
|
|
54
67
|
*/
|
|
@@ -57,16 +70,6 @@ declare function restartApp(): void;
|
|
|
57
70
|
* ensure app is ready.
|
|
58
71
|
*/
|
|
59
72
|
declare function waitAppReady(duration?: number): Promise<void>;
|
|
60
|
-
declare function
|
|
61
|
-
declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
|
|
62
|
-
declare function handleUnexpectedErrors(callback: (err: Error) => void): void;
|
|
63
|
-
interface Version {
|
|
64
|
-
major: number;
|
|
65
|
-
minor: number;
|
|
66
|
-
patch: number;
|
|
67
|
-
stage: string;
|
|
68
|
-
stageVersion: number;
|
|
69
|
-
}
|
|
70
|
-
declare function parseVersion(version: string): Version;
|
|
73
|
+
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
71
74
|
|
|
72
|
-
export { NoSuchNativeModuleError, Version,
|
|
75
|
+
export { DEFAULT_APP_NAME, NoSuchNativeModuleError, Version, appInfo, getAppVersion, getElectronVersion, getLocale, getProductAsarPath, handleUnexpectedErrors, isNoSuchNativeModuleError, parseGithubCdnURL, parseVersion, requireNative, restartApp, unzipFile, waitAppReady, zipFile };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,54 +1,67 @@
|
|
|
1
|
+
declare const DEFAULT_APP_NAME = "product";
|
|
1
2
|
type Info = {
|
|
2
3
|
dev: boolean;
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
win: boolean;
|
|
5
|
+
mac: boolean;
|
|
6
|
+
linux: boolean;
|
|
7
|
+
electronVersion: string;
|
|
8
|
+
appVersion: (name?: string) => string;
|
|
9
|
+
/**
|
|
10
|
+
* `os.release()`
|
|
11
|
+
*/
|
|
12
|
+
systemVersion: string;
|
|
5
13
|
};
|
|
6
|
-
declare const info: Info;
|
|
7
14
|
/**
|
|
8
|
-
* get
|
|
15
|
+
* get app info
|
|
16
|
+
*/
|
|
17
|
+
declare const appInfo: Info;
|
|
18
|
+
declare function getLocale(): string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* get the application asar absolute path (not `app.asar`),
|
|
21
|
+
* if is in dev, return `'DEV.asar'`
|
|
9
22
|
* @param name The name of the application
|
|
10
|
-
* @todo support v8 bytecode
|
|
11
23
|
*/
|
|
12
|
-
declare function getProductAsarPath(name
|
|
24
|
+
declare function getProductAsarPath(name?: string): string;
|
|
13
25
|
/**
|
|
14
|
-
* get the version of
|
|
26
|
+
* get the version of Electron runtime
|
|
15
27
|
*/
|
|
16
|
-
declare function
|
|
28
|
+
declare function getElectronVersion(): string;
|
|
17
29
|
/**
|
|
18
30
|
* get the version of application (name.asar)
|
|
19
31
|
*
|
|
20
|
-
* if is dev, return {@link
|
|
32
|
+
* if is dev, return {@link getElectronVersion}
|
|
21
33
|
* @param name - The name of the application
|
|
22
34
|
*/
|
|
23
|
-
declare function
|
|
35
|
+
declare function getAppVersion(name?: string): string;
|
|
24
36
|
declare class NoSuchNativeModuleError extends Error {
|
|
25
37
|
moduleName: string;
|
|
26
38
|
constructor(moduleName: string);
|
|
27
39
|
}
|
|
40
|
+
declare function isNoSuchNativeModuleError(e: unknown): e is NoSuchNativeModuleError;
|
|
28
41
|
/**
|
|
29
|
-
* require native package
|
|
42
|
+
* require native package, if not found, return {@link NoSuchNativeModuleError}
|
|
30
43
|
* @param packageName native package name
|
|
31
|
-
* @throws error: {@link NoSuchNativeModuleError}
|
|
32
44
|
*/
|
|
33
|
-
declare function requireNative<T = any>(packageName: string): T;
|
|
45
|
+
declare function requireNative<T = any>(packageName: string): T | NoSuchNativeModuleError;
|
|
46
|
+
|
|
47
|
+
interface Version {
|
|
48
|
+
major: number;
|
|
49
|
+
minor: number;
|
|
50
|
+
patch: number;
|
|
51
|
+
stage: string;
|
|
52
|
+
stageVersion: number;
|
|
53
|
+
}
|
|
54
|
+
declare function parseVersion(version: string): Version;
|
|
55
|
+
|
|
56
|
+
declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
|
|
57
|
+
declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
|
|
58
|
+
|
|
34
59
|
/**
|
|
35
60
|
* parse Github CDN URL for accelerating the speed of downloading
|
|
61
|
+
*
|
|
62
|
+
* {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 some public CDN links}
|
|
36
63
|
*/
|
|
37
|
-
declare function parseGithubCdnURL(
|
|
38
|
-
/**
|
|
39
|
-
* get group of Github file CDN prefix for accelerating the speed of downloading project files
|
|
40
|
-
*/
|
|
41
|
-
declare function getGithubFileCdnGroup(): {
|
|
42
|
-
cdnPrefix: string;
|
|
43
|
-
source: string;
|
|
44
|
-
}[];
|
|
45
|
-
/**
|
|
46
|
-
* get group of github release CDN prefix for accelerating the speed of downloading release
|
|
47
|
-
*/
|
|
48
|
-
declare function getGithubReleaseCdnGroup(): {
|
|
49
|
-
cdnPrefix: string;
|
|
50
|
-
source: string;
|
|
51
|
-
}[];
|
|
64
|
+
declare function parseGithubCdnURL(originRepoURL: string, cdnPrefix: string, relativeFilePath: string): string;
|
|
52
65
|
/**
|
|
53
66
|
* Restarts the Electron app.
|
|
54
67
|
*/
|
|
@@ -57,16 +70,6 @@ declare function restartApp(): void;
|
|
|
57
70
|
* ensure app is ready.
|
|
58
71
|
*/
|
|
59
72
|
declare function waitAppReady(duration?: number): Promise<void>;
|
|
60
|
-
declare function
|
|
61
|
-
declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
|
|
62
|
-
declare function handleUnexpectedErrors(callback: (err: Error) => void): void;
|
|
63
|
-
interface Version {
|
|
64
|
-
major: number;
|
|
65
|
-
minor: number;
|
|
66
|
-
patch: number;
|
|
67
|
-
stage: string;
|
|
68
|
-
stageVersion: number;
|
|
69
|
-
}
|
|
70
|
-
declare function parseVersion(version: string): Version;
|
|
73
|
+
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
71
74
|
|
|
72
|
-
export { NoSuchNativeModuleError, Version,
|
|
75
|
+
export { DEFAULT_APP_NAME, NoSuchNativeModuleError, Version, appInfo, getAppVersion, getElectronVersion, getLocale, getProductAsarPath, handleUnexpectedErrors, isNoSuchNativeModuleError, parseGithubCdnURL, parseVersion, requireNative, restartApp, unzipFile, waitAppReady, zipFile };
|
package/dist/utils.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,27 +15,20 @@ 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
|
-
// src/utils.ts
|
|
20
|
+
// src/utils/index.ts
|
|
31
21
|
var utils_exports = {};
|
|
32
22
|
__export(utils_exports, {
|
|
23
|
+
DEFAULT_APP_NAME: () => DEFAULT_APP_NAME,
|
|
33
24
|
NoSuchNativeModuleError: () => NoSuchNativeModuleError,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
appInfo: () => appInfo,
|
|
26
|
+
getAppVersion: () => getAppVersion,
|
|
27
|
+
getElectronVersion: () => getElectronVersion,
|
|
28
|
+
getLocale: () => getLocale,
|
|
37
29
|
getProductAsarPath: () => getProductAsarPath,
|
|
38
|
-
getProductVersion: () => getProductVersion,
|
|
39
30
|
handleUnexpectedErrors: () => handleUnexpectedErrors,
|
|
40
|
-
|
|
31
|
+
isNoSuchNativeModuleError: () => isNoSuchNativeModuleError,
|
|
41
32
|
parseGithubCdnURL: () => parseGithubCdnURL,
|
|
42
33
|
parseVersion: () => parseVersion,
|
|
43
34
|
requireNative: () => requireNative,
|
|
@@ -47,23 +38,33 @@ __export(utils_exports, {
|
|
|
47
38
|
zipFile: () => zipFile
|
|
48
39
|
});
|
|
49
40
|
module.exports = __toCommonJS(utils_exports);
|
|
41
|
+
|
|
42
|
+
// src/utils/core.ts
|
|
50
43
|
var import_node_fs = require("fs");
|
|
51
44
|
var import_node_path = require("path");
|
|
52
|
-
var
|
|
53
|
-
var import_electron =
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
45
|
+
var import_node_os = require("os");
|
|
46
|
+
var import_electron = require("electron");
|
|
47
|
+
var DEFAULT_APP_NAME = "product";
|
|
48
|
+
var appInfo = {
|
|
49
|
+
dev: !import_electron.app.isPackaged,
|
|
50
|
+
win: process.platform === "win32",
|
|
51
|
+
mac: process.platform === "darwin",
|
|
52
|
+
linux: process.platform === "linux",
|
|
53
|
+
electronVersion: getElectronVersion(),
|
|
54
|
+
appVersion: getAppVersion,
|
|
55
|
+
systemVersion: (0, import_node_os.release)()
|
|
58
56
|
};
|
|
59
|
-
function
|
|
60
|
-
return
|
|
57
|
+
function getLocale() {
|
|
58
|
+
return import_electron.app.isReady() ? import_electron.app.getLocale() : void 0;
|
|
59
|
+
}
|
|
60
|
+
function getProductAsarPath(name = DEFAULT_APP_NAME) {
|
|
61
|
+
return !import_electron.app.isPackaged ? "DEV.asar" : (0, import_node_path.join)((0, import_node_path.dirname)(import_electron.app.getAppPath()), `${name}.asar`);
|
|
61
62
|
}
|
|
62
|
-
function
|
|
63
|
-
return import_electron.
|
|
63
|
+
function getElectronVersion() {
|
|
64
|
+
return import_electron.app.getVersion();
|
|
64
65
|
}
|
|
65
|
-
function
|
|
66
|
-
return
|
|
66
|
+
function getAppVersion(name = DEFAULT_APP_NAME) {
|
|
67
|
+
return import_electron.app.isPackaged ? (0, import_node_fs.readFileSync)((0, import_node_path.join)(getProductAsarPath(name), "version"), "utf-8") : getElectronVersion();
|
|
67
68
|
}
|
|
68
69
|
var NoSuchNativeModuleError = class extends Error {
|
|
69
70
|
moduleName;
|
|
@@ -72,138 +73,123 @@ var NoSuchNativeModuleError = class extends Error {
|
|
|
72
73
|
this.moduleName = moduleName;
|
|
73
74
|
}
|
|
74
75
|
};
|
|
76
|
+
function isNoSuchNativeModuleError(e) {
|
|
77
|
+
return e instanceof NoSuchNativeModuleError;
|
|
78
|
+
}
|
|
75
79
|
function requireNative(packageName) {
|
|
76
|
-
const path =
|
|
80
|
+
const path = import_electron.app.isPackaged ? (0, import_node_path.join)(import_electron.app.getAppPath(), "node_modules", packageName) : packageName;
|
|
77
81
|
try {
|
|
78
82
|
return require(path);
|
|
79
83
|
} catch (error) {
|
|
80
|
-
|
|
84
|
+
return new NoSuchNativeModuleError(packageName);
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
|
|
88
|
+
// src/utils/version.ts
|
|
89
|
+
function parseVersion(version) {
|
|
90
|
+
const semver = /^(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z0-9\.-]+))?/i;
|
|
91
|
+
const match = semver.exec(version);
|
|
92
|
+
if (!match) {
|
|
93
|
+
throw new TypeError(`invalid version: ${version}`);
|
|
86
94
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
{ cdnPrefix: "ghproxy.com", source: "gh-proxy" },
|
|
105
|
-
{ cdnPrefix: "gh.ddlc.top", source: "@mtr-static-official" },
|
|
106
|
-
{ cdnPrefix: "ghdl.feizhuqwq.cf", source: "feizhuqwq.com" },
|
|
107
|
-
{ cdnPrefix: "slink.ltd", source: "\u77E5\u4E86\u5C0F\u7AD9" },
|
|
108
|
-
{ cdnPrefix: "git.xfj0.cn", source: "anonymous1" },
|
|
109
|
-
{ cdnPrefix: "gh.con.sh", source: "anonymous2" },
|
|
110
|
-
{ cdnPrefix: "ghps.cc", source: "anonymous3" },
|
|
111
|
-
{ cdnPrefix: "cors.isteed.cc/github.com", source: "Lufs's" },
|
|
112
|
-
{ cdnPrefix: "hub.gitmirror.com", source: "GitMirror" },
|
|
113
|
-
{ cdnPrefix: "js.xxooo.ml", source: "\u996D\u592A\u786C" },
|
|
114
|
-
{ cdnPrefix: "download.njuu.cf", source: "LibraryCloud-njuu" },
|
|
115
|
-
{ cdnPrefix: "download.yzuu.cf", source: "LibraryCloud-yzuu" },
|
|
116
|
-
{ cdnPrefix: "download.nuaa.cf", source: "LibraryCloud-nuaa" }
|
|
117
|
-
];
|
|
118
|
-
}
|
|
119
|
-
function restartApp() {
|
|
120
|
-
import_electron.default.app.relaunch();
|
|
121
|
-
import_electron.default.app.quit();
|
|
122
|
-
}
|
|
123
|
-
function waitAppReady(duration = 1e3) {
|
|
124
|
-
return new Promise((resolve, reject) => {
|
|
125
|
-
const timeout = setTimeout(() => {
|
|
126
|
-
reject(new Error("app is not ready"));
|
|
127
|
-
}, duration);
|
|
128
|
-
import_electron.default.app.whenReady().then(() => {
|
|
129
|
-
clearTimeout(timeout);
|
|
130
|
-
resolve();
|
|
131
|
-
});
|
|
132
|
-
});
|
|
95
|
+
const [major, minor, patch] = match.slice(1, 4).map(Number);
|
|
96
|
+
const ret = {
|
|
97
|
+
major,
|
|
98
|
+
minor,
|
|
99
|
+
patch,
|
|
100
|
+
stage: "",
|
|
101
|
+
stageVersion: -1
|
|
102
|
+
};
|
|
103
|
+
if (match[4]) {
|
|
104
|
+
let [stage, _v] = match[4].split(".");
|
|
105
|
+
ret.stage = stage;
|
|
106
|
+
ret.stageVersion = Number(_v) || -1;
|
|
107
|
+
}
|
|
108
|
+
if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch) || Number.isNaN(ret.stageVersion)) {
|
|
109
|
+
throw new TypeError(`invalid version: ${version}`);
|
|
110
|
+
}
|
|
111
|
+
return ret;
|
|
133
112
|
}
|
|
113
|
+
|
|
114
|
+
// src/utils/zip.ts
|
|
115
|
+
var import_node_fs2 = require("fs");
|
|
116
|
+
var import_node_zlib = require("zlib");
|
|
134
117
|
async function unzipFile(gzipPath, targetFilePath = gzipPath.slice(0, -3)) {
|
|
135
|
-
if (!(0,
|
|
118
|
+
if (!(0, import_node_fs2.existsSync)(gzipPath)) {
|
|
136
119
|
throw new Error(`path to zipped file not exist: ${gzipPath}`);
|
|
137
120
|
}
|
|
138
|
-
const compressedBuffer = (0,
|
|
121
|
+
const compressedBuffer = (0, import_node_fs2.readFileSync)(gzipPath);
|
|
139
122
|
return new Promise((resolve, reject) => {
|
|
140
123
|
(0, import_node_zlib.gunzip)(compressedBuffer, (err, buffer) => {
|
|
141
|
-
(0,
|
|
124
|
+
(0, import_node_fs2.rmSync)(gzipPath);
|
|
142
125
|
if (err) {
|
|
143
126
|
reject(err);
|
|
144
127
|
}
|
|
145
|
-
(0,
|
|
128
|
+
(0, import_node_fs2.writeFileSync)(targetFilePath, buffer);
|
|
146
129
|
resolve(null);
|
|
147
130
|
});
|
|
148
131
|
});
|
|
149
132
|
}
|
|
150
133
|
async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
|
|
151
|
-
if (!(0,
|
|
134
|
+
if (!(0, import_node_fs2.existsSync)(filePath)) {
|
|
152
135
|
throw new Error(`path to be zipped not exist: ${filePath}`);
|
|
153
136
|
}
|
|
154
|
-
const buffer = (0,
|
|
137
|
+
const buffer = (0, import_node_fs2.readFileSync)(filePath);
|
|
155
138
|
return new Promise((resolve, reject) => {
|
|
156
139
|
(0, import_node_zlib.gzip)(buffer, (err, buffer2) => {
|
|
157
140
|
if (err) {
|
|
158
141
|
reject(err);
|
|
159
142
|
}
|
|
160
|
-
(0,
|
|
143
|
+
(0, import_node_fs2.writeFileSync)(targetFilePath, buffer2);
|
|
161
144
|
resolve(null);
|
|
162
145
|
});
|
|
163
146
|
});
|
|
164
147
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
process.on("unhandledRejection", listener);
|
|
172
|
-
}
|
|
173
|
-
function parseVersion(version) {
|
|
174
|
-
const semver = /^(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z0-9\.-]+))?/i;
|
|
175
|
-
const match = semver.exec(version);
|
|
176
|
-
if (!match) {
|
|
177
|
-
throw new TypeError(`invalid version: ${version}`);
|
|
178
|
-
}
|
|
179
|
-
const [major, minor, patch] = match.slice(1, 4).map(Number);
|
|
180
|
-
const ret = {
|
|
181
|
-
major,
|
|
182
|
-
minor,
|
|
183
|
-
patch,
|
|
184
|
-
stage: "",
|
|
185
|
-
stageVersion: -1
|
|
186
|
-
};
|
|
187
|
-
if (match[4]) {
|
|
188
|
-
let [stage, _v] = match[4].split(".");
|
|
189
|
-
ret.stage = stage;
|
|
190
|
-
ret.stageVersion = Number(_v) || -1;
|
|
148
|
+
|
|
149
|
+
// src/utils/utils.ts
|
|
150
|
+
var import_electron2 = require("electron");
|
|
151
|
+
function parseGithubCdnURL(originRepoURL, cdnPrefix, relativeFilePath) {
|
|
152
|
+
if (!originRepoURL.startsWith("https://github.com/")) {
|
|
153
|
+
throw new Error("origin url must start with https://github.com/");
|
|
191
154
|
}
|
|
192
|
-
|
|
193
|
-
|
|
155
|
+
originRepoURL = originRepoURL.trim().replace(/\/?$/, "/").trim();
|
|
156
|
+
relativeFilePath = relativeFilePath.trim().replace(/^\/|\/?$/g, "").trim();
|
|
157
|
+
cdnPrefix = cdnPrefix.trim().replace(/^\/?|\/?$/g, "").trim();
|
|
158
|
+
return originRepoURL.replace("github.com", cdnPrefix) + relativeFilePath;
|
|
159
|
+
}
|
|
160
|
+
function restartApp() {
|
|
161
|
+
import_electron2.app.relaunch();
|
|
162
|
+
import_electron2.app.quit();
|
|
163
|
+
}
|
|
164
|
+
function waitAppReady(duration = 1e3) {
|
|
165
|
+
if (import_electron2.app.isReady()) {
|
|
166
|
+
return Promise.resolve();
|
|
194
167
|
}
|
|
195
|
-
return
|
|
168
|
+
return new Promise((resolve, reject) => {
|
|
169
|
+
const timeout = setTimeout(() => {
|
|
170
|
+
reject(new Error("app is not ready"));
|
|
171
|
+
}, duration);
|
|
172
|
+
import_electron2.app.whenReady().then(() => {
|
|
173
|
+
clearTimeout(timeout);
|
|
174
|
+
resolve();
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function handleUnexpectedErrors(callback) {
|
|
179
|
+
process.on("uncaughtException", callback);
|
|
180
|
+
process.on("unhandledRejection", callback);
|
|
196
181
|
}
|
|
197
182
|
// Annotate the CommonJS export names for ESM import in node:
|
|
198
183
|
0 && (module.exports = {
|
|
184
|
+
DEFAULT_APP_NAME,
|
|
199
185
|
NoSuchNativeModuleError,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
186
|
+
appInfo,
|
|
187
|
+
getAppVersion,
|
|
188
|
+
getElectronVersion,
|
|
189
|
+
getLocale,
|
|
203
190
|
getProductAsarPath,
|
|
204
|
-
getProductVersion,
|
|
205
191
|
handleUnexpectedErrors,
|
|
206
|
-
|
|
192
|
+
isNoSuchNativeModuleError,
|
|
207
193
|
parseGithubCdnURL,
|
|
208
194
|
parseVersion,
|
|
209
195
|
requireNative,
|
package/dist/utils.mjs
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DEFAULT_APP_NAME,
|
|
2
3
|
NoSuchNativeModuleError,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
appInfo,
|
|
5
|
+
getAppVersion,
|
|
6
|
+
getElectronVersion,
|
|
7
|
+
getLocale,
|
|
6
8
|
getProductAsarPath,
|
|
7
|
-
getProductVersion,
|
|
8
9
|
handleUnexpectedErrors,
|
|
9
|
-
|
|
10
|
+
isNoSuchNativeModuleError,
|
|
10
11
|
parseGithubCdnURL,
|
|
11
|
-
parseVersion,
|
|
12
12
|
requireNative,
|
|
13
13
|
restartApp,
|
|
14
|
+
waitAppReady
|
|
15
|
+
} from "./chunk-OGAOUYV3.mjs";
|
|
16
|
+
import {
|
|
17
|
+
parseVersion,
|
|
14
18
|
unzipFile,
|
|
15
|
-
waitAppReady,
|
|
16
19
|
zipFile
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-ZFXKCRJC.mjs";
|
|
20
|
+
} from "./chunk-CMBFI77K.mjs";
|
|
19
21
|
export {
|
|
22
|
+
DEFAULT_APP_NAME,
|
|
20
23
|
NoSuchNativeModuleError,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
appInfo,
|
|
25
|
+
getAppVersion,
|
|
26
|
+
getElectronVersion,
|
|
27
|
+
getLocale,
|
|
24
28
|
getProductAsarPath,
|
|
25
|
-
getProductVersion,
|
|
26
29
|
handleUnexpectedErrors,
|
|
27
|
-
|
|
30
|
+
isNoSuchNativeModuleError,
|
|
28
31
|
parseGithubCdnURL,
|
|
29
32
|
parseVersion,
|
|
30
33
|
requireNative,
|
package/dist/vite.d.mts
CHANGED
package/dist/vite.d.ts
CHANGED
package/dist/vite.js
CHANGED
|
@@ -58,16 +58,9 @@ var signature = (buffer, privateKey, cert, version) => {
|
|
|
58
58
|
return encrypt(`${sig}%${version}`, key(cert, 32), key(buffer, 16));
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
// src/utils.ts
|
|
61
|
+
// src/utils/zip.ts
|
|
62
62
|
var import_node_fs = require("fs");
|
|
63
|
-
var import_node_path = require("path");
|
|
64
63
|
var import_node_zlib = require("zlib");
|
|
65
|
-
var import_electron = __toESM(require("electron"));
|
|
66
|
-
var info = {
|
|
67
|
-
dev: !import_electron.default.app?.isPackaged,
|
|
68
|
-
platform: process.platform === "win32" ? "win" : process.platform === "darwin" ? "mac" : "linux",
|
|
69
|
-
appPath: import_electron.default.app?.getAppPath()
|
|
70
|
-
};
|
|
71
64
|
async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
|
|
72
65
|
if (!(0, import_node_fs.existsSync)(filePath)) {
|
|
73
66
|
throw new Error(`path to be zipped not exist: ${filePath}`);
|
|
@@ -83,6 +76,8 @@ async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
|
|
|
83
76
|
});
|
|
84
77
|
});
|
|
85
78
|
}
|
|
79
|
+
|
|
80
|
+
// src/utils/version.ts
|
|
86
81
|
function parseVersion(version) {
|
|
87
82
|
const semver = /^(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z0-9\.-]+))?/i;
|
|
88
83
|
const match = semver.exec(version);
|
|
@@ -199,12 +194,12 @@ var import_ci_info = require("ci-info");
|
|
|
199
194
|
|
|
200
195
|
// src/build-plugins/key.ts
|
|
201
196
|
var import_node_fs3 = require("fs");
|
|
202
|
-
var
|
|
197
|
+
var import_node_path = require("path");
|
|
203
198
|
var import_selfsigned = require("selfsigned");
|
|
204
199
|
function generateKeyPair(keyLength, subject, days, privateKeyPath, certPath) {
|
|
205
|
-
const privateKeyDir = (0,
|
|
200
|
+
const privateKeyDir = (0, import_node_path.dirname)(privateKeyPath);
|
|
206
201
|
(0, import_node_fs3.existsSync)(privateKeyDir) || (0, import_node_fs3.mkdirSync)(privateKeyDir, { recursive: true });
|
|
207
|
-
const certDir = (0,
|
|
202
|
+
const certDir = (0, import_node_path.dirname)(certPath);
|
|
208
203
|
(0, import_node_fs3.existsSync)(certDir) || (0, import_node_fs3.mkdirSync)(certDir, { recursive: true });
|
|
209
204
|
const { cert, private: privateKey } = (0, import_selfsigned.generate)(subject, {
|
|
210
205
|
keySize: keyLength,
|
|
@@ -240,7 +235,6 @@ function writeCertToMain(entryPath, cert) {
|
|
|
240
235
|
!isMatched && lines.push(r);
|
|
241
236
|
replaced = lines.join(eol);
|
|
242
237
|
}
|
|
243
|
-
console.log(JSON.stringify(replaced));
|
|
244
238
|
(0, import_node_fs3.writeFileSync)(entryPath, replaced);
|
|
245
239
|
}
|
|
246
240
|
function parseKeys({
|
|
@@ -251,7 +245,7 @@ function parseKeys({
|
|
|
251
245
|
subject,
|
|
252
246
|
days
|
|
253
247
|
}) {
|
|
254
|
-
const keysDir = (0,
|
|
248
|
+
const keysDir = (0, import_node_path.dirname)(privateKeyPath);
|
|
255
249
|
!(0, import_node_fs3.existsSync)(keysDir) && (0, import_node_fs3.mkdirSync)(keysDir);
|
|
256
250
|
if (!(0, import_node_fs3.existsSync)(privateKeyPath) || !(0, import_node_fs3.existsSync)(certPath)) {
|
|
257
251
|
generateKeyPair(keyLength, parseSubjects(subject), days, privateKeyPath, certPath);
|