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
|
@@ -1,47 +1,9 @@
|
|
|
1
1
|
import { Promisable } from '@subframe7536/type-utils';
|
|
2
|
-
import {
|
|
2
|
+
import { U as UpdateInfo } from './version-BYVQ367i.js';
|
|
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 };
|
package/dist/utils.cjs
CHANGED
|
@@ -148,17 +148,17 @@ function parseVersion(version) {
|
|
|
148
148
|
}
|
|
149
149
|
return ret;
|
|
150
150
|
}
|
|
151
|
+
function compareStrings(str1, str2) {
|
|
152
|
+
if (str1 === "") {
|
|
153
|
+
return str2 !== "";
|
|
154
|
+
} else if (str2 === "") {
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return str1 < str2;
|
|
158
|
+
}
|
|
151
159
|
function defaultIsLowerVersion(oldVer, newVer) {
|
|
152
160
|
const oldV = parseVersion(oldVer);
|
|
153
161
|
const newV = parseVersion(newVer);
|
|
154
|
-
function compareStrings(str1, str2) {
|
|
155
|
-
if (str1 === "") {
|
|
156
|
-
return str2 !== "";
|
|
157
|
-
} else if (str2 === "") {
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
return str1 < str2;
|
|
161
|
-
}
|
|
162
162
|
for (let key of Object.keys(oldV)) {
|
|
163
163
|
if (key === "stage" && compareStrings(oldV[key], newV[key])) {
|
|
164
164
|
return true;
|
|
@@ -168,8 +168,8 @@ function defaultIsLowerVersion(oldVer, newVer) {
|
|
|
168
168
|
}
|
|
169
169
|
return false;
|
|
170
170
|
}
|
|
171
|
+
var is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
171
172
|
function isUpdateJSON(json) {
|
|
172
|
-
const is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
173
173
|
return is(json) && is(json?.beta);
|
|
174
174
|
}
|
|
175
175
|
function defaultVersionJsonGenerator(existingJson, signature, version, minimumVersion) {
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BrowserWindow } from 'electron';
|
|
2
|
-
export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerifySignature, d as defaultZipFile, h as hashBuffer } from './
|
|
3
|
-
export {
|
|
2
|
+
export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerifySignature, d as defaultZipFile, h as hashBuffer } from './crypto-Zynscwmj.cjs';
|
|
3
|
+
export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, i as isUpdateJSON, p as parseVersion } from './version-BYVQ367i.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Compile time dev check
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BrowserWindow } from 'electron';
|
|
2
|
-
export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerifySignature, d as defaultZipFile, h as hashBuffer } from './
|
|
3
|
-
export {
|
|
2
|
+
export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerifySignature, d as defaultZipFile, h as hashBuffer } from './crypto-Zynscwmj.js';
|
|
3
|
+
export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, i as isUpdateJSON, p as parseVersion } from './version-BYVQ367i.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Compile time dev check
|
package/dist/utils.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { beautifyDevTools, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromMain, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, importNative, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance } from './chunk-
|
|
1
|
+
export { beautifyDevTools, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromMain, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, importNative, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance } from './chunk-JI27JWJN.js';
|
|
2
2
|
export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultZipFile, hashBuffer } from './chunk-PUVBFHOK.js';
|
|
3
|
-
export { defaultIsLowerVersion, defaultVersionJsonGenerator, isUpdateJSON, parseVersion } from './chunk-
|
|
3
|
+
export { defaultIsLowerVersion, defaultVersionJsonGenerator, isUpdateJSON, parseVersion } from './chunk-AAAM44NW.js';
|
|
@@ -59,4 +59,4 @@ declare function isUpdateJSON(json: any): json is UpdateJSON;
|
|
|
59
59
|
*/
|
|
60
60
|
declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
|
|
61
61
|
|
|
62
|
-
export { type
|
|
62
|
+
export { type UpdateInfo as U, type Version as V, type UpdateJSON as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
|
|
@@ -59,4 +59,4 @@ declare function isUpdateJSON(json: any): json is UpdateJSON;
|
|
|
59
59
|
*/
|
|
60
60
|
declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
|
|
61
61
|
|
|
62
|
-
export { type
|
|
62
|
+
export { type UpdateInfo as U, type Version as V, type UpdateJSON as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PluginOption } from 'vite';
|
|
1
|
+
import { InlineConfig, PluginOption } from 'vite';
|
|
2
2
|
import { ElectronSimpleOptions } from 'vite-plugin-electron/simple';
|
|
3
3
|
import { Promisable } from '@subframe7536/type-utils';
|
|
4
|
-
import { BuildOptions } from 'esbuild';
|
|
5
4
|
export { isCI } from 'ci-info';
|
|
5
|
+
export { getPackageInfo, getPackageInfoSync, loadPackageJSON, resolveModule } from 'local-pkg';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Update info json
|
|
@@ -19,12 +19,6 @@ type UpdateJSON = UpdateInfo & {
|
|
|
19
19
|
beta: UpdateInfo;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
interface PKG {
|
|
23
|
-
name: string;
|
|
24
|
-
version: string;
|
|
25
|
-
main: string;
|
|
26
|
-
type: 'commonjs' | 'module';
|
|
27
|
-
}
|
|
28
22
|
interface DistinguishedName {
|
|
29
23
|
countryName?: string;
|
|
30
24
|
stateOrProvinceName?: string;
|
|
@@ -38,6 +32,13 @@ interface DistinguishedName {
|
|
|
38
32
|
businessCategory?: string;
|
|
39
33
|
emailAddress?: string;
|
|
40
34
|
}
|
|
35
|
+
|
|
36
|
+
interface PKG {
|
|
37
|
+
name: string;
|
|
38
|
+
version: string;
|
|
39
|
+
main: string;
|
|
40
|
+
type: 'commonjs' | 'module';
|
|
41
|
+
}
|
|
41
42
|
interface BuildEntryOption {
|
|
42
43
|
/**
|
|
43
44
|
* Override to minify on entry
|
|
@@ -67,30 +68,32 @@ interface BuildEntryOption {
|
|
|
67
68
|
*/
|
|
68
69
|
nativeModuleEntryMap?: Record<string, string>;
|
|
69
70
|
/**
|
|
70
|
-
*
|
|
71
|
+
* Skip process dynamic require
|
|
72
|
+
*
|
|
73
|
+
* Useful for `better-sqlite3` and other old packages
|
|
74
|
+
*/
|
|
75
|
+
ignoreDynamicRequires?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* `external` option in `build.rollupOptions`, external `.node` by default
|
|
78
|
+
*/
|
|
79
|
+
external?: string | string[] | ((source: string, importer: string | undefined, isResolved: boolean) => boolean | null | undefined | void);
|
|
80
|
+
/**
|
|
81
|
+
* Custom options for `vite` build
|
|
71
82
|
* ```ts
|
|
72
|
-
* // default options
|
|
73
83
|
* const options = {
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* minify,
|
|
82
|
-
* sourcemap,
|
|
83
|
-
* entryNames: '[dir]/[name]',
|
|
84
|
-
* assetNames: '[dir]/[name]',
|
|
85
|
-
* external: ['electron', 'original-fs'],
|
|
86
|
-
* loader: {
|
|
87
|
-
* '.node': 'empty',
|
|
84
|
+
* plugins: [esm(), bytecodePlugin()], // load on needed
|
|
85
|
+
* build: {
|
|
86
|
+
* sourcemap,
|
|
87
|
+
* minify,
|
|
88
|
+
* outDir: entryOutputDirPath,
|
|
89
|
+
* commonjsOptions: { ignoreDynamicRequires },
|
|
90
|
+
* rollupOptions: { external },
|
|
88
91
|
* },
|
|
89
92
|
* define,
|
|
90
93
|
* }
|
|
91
94
|
* ```
|
|
92
95
|
*/
|
|
93
|
-
|
|
96
|
+
overrideViteOptions?: InlineConfig;
|
|
94
97
|
/**
|
|
95
98
|
* Resolve extra files on startup, such as `.node`
|
|
96
99
|
* @remark won't trigger will reload
|
|
@@ -116,6 +119,20 @@ interface BuildEntryOption {
|
|
|
116
119
|
*/
|
|
117
120
|
skipIfExist?: boolean;
|
|
118
121
|
}) => void;
|
|
122
|
+
/**
|
|
123
|
+
* Copy specified modules to entry output dir, just like `external` option in rollup
|
|
124
|
+
*/
|
|
125
|
+
copyModules: (options: {
|
|
126
|
+
/**
|
|
127
|
+
* External Modules
|
|
128
|
+
*/
|
|
129
|
+
modules: string[];
|
|
130
|
+
/**
|
|
131
|
+
* Skip copy if `to` exist
|
|
132
|
+
* @default true
|
|
133
|
+
*/
|
|
134
|
+
skipIfExist?: boolean;
|
|
135
|
+
}) => void;
|
|
119
136
|
}) => Promisable<void>;
|
|
120
137
|
}
|
|
121
138
|
interface GeneratorOverrideFunctions {
|
|
@@ -249,6 +266,17 @@ interface BytecodeOptions {
|
|
|
249
266
|
beforeCompile?: (code: string, id: string) => Promisable<string | null | undefined | void>;
|
|
250
267
|
}
|
|
251
268
|
|
|
269
|
+
/**
|
|
270
|
+
* Obfuscate string
|
|
271
|
+
* @param code source code
|
|
272
|
+
* @param sourcemap whether to generate sourcemap
|
|
273
|
+
* @param offset custom offset
|
|
274
|
+
*/
|
|
275
|
+
declare function convertLiteral(code: string, sourcemap?: boolean, offset?: number): {
|
|
276
|
+
code: string;
|
|
277
|
+
map?: any;
|
|
278
|
+
};
|
|
279
|
+
|
|
252
280
|
type MakeRequired<T, K extends keyof T> = Exclude<T, undefined> & {
|
|
253
281
|
[P in K]-?: T[P];
|
|
254
282
|
};
|
|
@@ -404,4 +432,4 @@ interface ElectronWithUpdaterOptions {
|
|
|
404
432
|
*/
|
|
405
433
|
declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<PluginOption[] | undefined>;
|
|
406
434
|
|
|
407
|
-
export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater as default, electronWithUpdater };
|
|
435
|
+
export { type ElectronWithUpdaterOptions, convertLiteral, debugStartup, electronWithUpdater as default, electronWithUpdater };
|
package/dist/vite.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { readableSize } from './chunk-
|
|
2
|
-
import { isUpdateJSON, defaultVersionJsonGenerator } from './chunk-
|
|
3
|
-
|
|
1
|
+
import { readableSize, copyAndSkipIfExist } from './chunk-TPTWE33H.js';
|
|
2
|
+
import { isUpdateJSON, defaultVersionJsonGenerator } from './chunk-7JCGLFGU.js';
|
|
3
|
+
export { convertLiteral } from './chunk-7JCGLFGU.js';
|
|
4
|
+
import { log, id } from './chunk-5NKEXGI3.js';
|
|
4
5
|
import path3 from 'node:path';
|
|
5
|
-
import
|
|
6
|
+
import fs2 from 'node:fs';
|
|
7
|
+
import { loadPackageJSON, getPackageInfoSync } from 'local-pkg';
|
|
8
|
+
export { getPackageInfo, getPackageInfoSync, loadPackageJSON, resolveModule } from 'local-pkg';
|
|
6
9
|
import { normalizePath, mergeConfig } from 'vite';
|
|
7
10
|
import ElectronSimple from 'vite-plugin-electron/simple';
|
|
8
|
-
import { startup } from 'vite-plugin-electron';
|
|
11
|
+
import { startup, build } from 'vite-plugin-electron';
|
|
9
12
|
import { notBundle } from 'vite-plugin-electron/plugin';
|
|
10
|
-
import { loadPackageJSON } from 'local-pkg';
|
|
11
13
|
import { isCI } from 'ci-info';
|
|
12
14
|
export { isCI } from 'ci-info';
|
|
13
15
|
import Asar from '@electron/asar';
|
|
14
|
-
import { build } from 'esbuild';
|
|
15
16
|
import zlib from 'node:zlib';
|
|
16
17
|
import crypto from 'node:crypto';
|
|
17
18
|
import { generate } from 'selfsigned';
|
|
@@ -24,11 +25,11 @@ async function buildAsar({
|
|
|
24
25
|
rendererDistPath,
|
|
25
26
|
generateGzipFile
|
|
26
27
|
}) {
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
fs2.renameSync(rendererDistPath, path3.join(electronDistPath, "renderer"));
|
|
29
|
+
fs2.writeFileSync(path3.join(electronDistPath, "version"), version);
|
|
29
30
|
await Asar.createPackage(electronDistPath, asarOutputPath);
|
|
30
|
-
const buf = await generateGzipFile(
|
|
31
|
-
|
|
31
|
+
const buf = await generateGzipFile(fs2.readFileSync(asarOutputPath));
|
|
32
|
+
fs2.writeFileSync(gzipPath, buf);
|
|
32
33
|
log.info(`Build update asar to '${gzipPath}' [${readableSize(buf.length)}]`, { timestamp: true });
|
|
33
34
|
return buf;
|
|
34
35
|
}
|
|
@@ -51,9 +52,9 @@ async function buildVersion({
|
|
|
51
52
|
signature: "",
|
|
52
53
|
version
|
|
53
54
|
};
|
|
54
|
-
if (
|
|
55
|
+
if (fs2.existsSync(versionPath)) {
|
|
55
56
|
try {
|
|
56
|
-
const oldVersionJson = JSON.parse(
|
|
57
|
+
const oldVersionJson = JSON.parse(fs2.readFileSync(versionPath, "utf-8"));
|
|
57
58
|
if (isUpdateJSON(oldVersionJson)) {
|
|
58
59
|
_json = oldVersionJson;
|
|
59
60
|
} else {
|
|
@@ -67,7 +68,7 @@ async function buildVersion({
|
|
|
67
68
|
if (!isUpdateJSON(_json)) {
|
|
68
69
|
throw new Error("Invalid version info");
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
+
fs2.writeFileSync(versionPath, JSON.stringify(_json, null, 2));
|
|
71
72
|
log.info(`build version info to '${versionPath}'`, { timestamp: true });
|
|
72
73
|
}
|
|
73
74
|
async function buildEntry({
|
|
@@ -76,86 +77,30 @@ async function buildEntry({
|
|
|
76
77
|
appEntryPath,
|
|
77
78
|
entryOutputDirPath,
|
|
78
79
|
nativeModuleEntryMap,
|
|
79
|
-
|
|
80
|
+
ignoreDynamicRequires,
|
|
81
|
+
external,
|
|
82
|
+
overrideViteOptions
|
|
80
83
|
}, isESM, define, bytecodeOptions) {
|
|
81
|
-
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
...nativeModuleEntryMap
|
|
86
|
-
},
|
|
87
|
-
bundle: true,
|
|
88
|
-
metafile: true,
|
|
89
|
-
platform: "node",
|
|
90
|
-
outdir: entryOutputDirPath,
|
|
91
|
-
minify,
|
|
92
|
-
sourcemap,
|
|
93
|
-
entryNames: "[dir]/[name]",
|
|
94
|
-
assetNames: "[dir]/[name]",
|
|
95
|
-
external: ["electron", "original-fs"],
|
|
96
|
-
treeShaking: true,
|
|
97
|
-
loader: {
|
|
98
|
-
".node": "empty"
|
|
99
|
-
},
|
|
100
|
-
define,
|
|
101
|
-
format: isESM ? "esm" : "cjs",
|
|
102
|
-
write: !isESM,
|
|
103
|
-
plugins: isESM ? [
|
|
104
|
-
{
|
|
105
|
-
name: "entry-esm-shim",
|
|
106
|
-
setup(build2) {
|
|
107
|
-
build2.onEnd(async ({ outputFiles }) => {
|
|
108
|
-
const parse = (await import('./utils-KPSYP7HQ.js')).insertCJSShim;
|
|
109
|
-
fs.mkdirSync(entryOutputDirPath, { recursive: true });
|
|
110
|
-
outputFiles?.filter((file) => file.path.endsWith(".js")).forEach((file) => {
|
|
111
|
-
const output = parse(file.text, sourcemap);
|
|
112
|
-
fs.writeFileSync(file.path, output?.code || file.text, "utf-8");
|
|
113
|
-
if (sourcemap && output?.map) {
|
|
114
|
-
fs.writeFileSync(`${file.path}.map`, output.map.toString(), "utf-8");
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
] : void 0
|
|
84
|
+
await build({
|
|
85
|
+
entry: {
|
|
86
|
+
entry: appEntryPath,
|
|
87
|
+
...nativeModuleEntryMap
|
|
121
88
|
},
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
let code = fs.readFileSync(filePath, "utf-8");
|
|
138
|
-
const fileName = path3.basename(filePath);
|
|
139
|
-
const isEntry = fileName.endsWith("entry.js");
|
|
140
|
-
let transformedCode = convertLiteral(convertArrowFunctionAndTemplate(code).code).code;
|
|
141
|
-
if (bytecodeOptions.beforeCompile) {
|
|
142
|
-
const result = await bytecodeOptions.beforeCompile(transformedCode, filePath);
|
|
143
|
-
if (result) {
|
|
144
|
-
transformedCode = result;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
const buffer = await compileToBytecode(transformedCode, bytecodeOptions.electronPath);
|
|
148
|
-
fs.writeFileSync(
|
|
149
|
-
filePath,
|
|
150
|
-
`${isEntry ? bytecodeModuleLoaderCode : useStrict}${isEntry ? "" : "module.exports = "}require("./${fileName}c")`
|
|
151
|
-
);
|
|
152
|
-
fs.writeFileSync(`${filePath}c`, buffer);
|
|
153
|
-
bytecodeLog.info(
|
|
154
|
-
`${filePath} [${(buffer.byteLength / 1e3).toFixed(2)} kB]`,
|
|
155
|
-
{ timestamp: true }
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
bytecodeLog.info(`${filePaths.length} file${filePaths.length > 1 ? "s" : ""} compiled into bytecode`, { timestamp: true });
|
|
89
|
+
vite: mergeConfig({
|
|
90
|
+
plugins: [
|
|
91
|
+
isESM && await import('./esm-UJAQJA65.js').then((m) => m.esm()),
|
|
92
|
+
bytecodeOptions && await import('./bytecode-7V24FFYI.js').then((m) => m.bytecodePlugin("main", bytecodeOptions))
|
|
93
|
+
],
|
|
94
|
+
build: {
|
|
95
|
+
sourcemap,
|
|
96
|
+
minify,
|
|
97
|
+
outDir: entryOutputDirPath,
|
|
98
|
+
commonjsOptions: { ignoreDynamicRequires },
|
|
99
|
+
rollupOptions: { external }
|
|
100
|
+
},
|
|
101
|
+
define
|
|
102
|
+
}, overrideViteOptions ?? {})
|
|
103
|
+
});
|
|
159
104
|
}
|
|
160
105
|
async function defaultZipFile(buffer) {
|
|
161
106
|
return new Promise((resolve, reject) => {
|
|
@@ -176,20 +121,20 @@ function defaultSignature(buffer, privateKey, cert, version) {
|
|
|
176
121
|
}
|
|
177
122
|
function generateKeyPair(keyLength, subject, days, privateKeyPath, certPath) {
|
|
178
123
|
const privateKeyDir = path3.dirname(privateKeyPath);
|
|
179
|
-
if (!
|
|
180
|
-
|
|
124
|
+
if (!fs2.existsSync(privateKeyDir)) {
|
|
125
|
+
fs2.mkdirSync(privateKeyDir, { recursive: true });
|
|
181
126
|
}
|
|
182
127
|
const certDir = path3.dirname(certPath);
|
|
183
|
-
if (!
|
|
184
|
-
|
|
128
|
+
if (!fs2.existsSync(certDir)) {
|
|
129
|
+
fs2.mkdirSync(certDir, { recursive: true });
|
|
185
130
|
}
|
|
186
131
|
const { cert, private: privateKey } = generate(subject, {
|
|
187
132
|
keySize: keyLength,
|
|
188
133
|
algorithm: "sha256",
|
|
189
134
|
days
|
|
190
135
|
});
|
|
191
|
-
|
|
192
|
-
|
|
136
|
+
fs2.writeFileSync(privateKeyPath, privateKey.replace(/\r\n?/g, "\n"));
|
|
137
|
+
fs2.writeFileSync(certPath, cert.replace(/\r\n?/g, "\n"));
|
|
193
138
|
}
|
|
194
139
|
function parseKeys({
|
|
195
140
|
keyLength,
|
|
@@ -205,15 +150,15 @@ function parseKeys({
|
|
|
205
150
|
log.info("Use `UPDATER_PK` and `UPDATER_CERT` from environment variables", { timestamp: true });
|
|
206
151
|
return { privateKey, cert };
|
|
207
152
|
}
|
|
208
|
-
if (!
|
|
209
|
-
|
|
153
|
+
if (!fs2.existsSync(keysDir)) {
|
|
154
|
+
fs2.mkdirSync(keysDir);
|
|
210
155
|
}
|
|
211
|
-
if (!
|
|
156
|
+
if (!fs2.existsSync(privateKeyPath) || !fs2.existsSync(certPath)) {
|
|
212
157
|
log.info("No key pair found, generate new key pair", { timestamp: true });
|
|
213
158
|
generateKeyPair(keyLength, parseSubjects(subject), days, privateKeyPath, certPath);
|
|
214
159
|
}
|
|
215
|
-
privateKey =
|
|
216
|
-
cert =
|
|
160
|
+
privateKey = fs2.readFileSync(privateKeyPath, "utf-8");
|
|
161
|
+
cert = fs2.readFileSync(certPath, "utf-8");
|
|
217
162
|
return { privateKey, cert };
|
|
218
163
|
}
|
|
219
164
|
function parseSubjects(subject) {
|
|
@@ -231,7 +176,9 @@ function parseOptions(pkg, sourcemap = false, minify = false, options = {}) {
|
|
|
231
176
|
appEntryPath = "electron/entry.ts",
|
|
232
177
|
nativeModuleEntryMap = {},
|
|
233
178
|
postBuild,
|
|
234
|
-
|
|
179
|
+
ignoreDynamicRequires = false,
|
|
180
|
+
external,
|
|
181
|
+
overrideViteOptions = {}
|
|
235
182
|
} = {},
|
|
236
183
|
paths: {
|
|
237
184
|
asarOutputPath = `release/${pkg.name}.asar`,
|
|
@@ -272,7 +219,23 @@ function parseOptions(pkg, sourcemap = false, minify = false, options = {}) {
|
|
|
272
219
|
entryOutputDirPath,
|
|
273
220
|
appEntryPath,
|
|
274
221
|
nativeModuleEntryMap,
|
|
275
|
-
|
|
222
|
+
overrideViteOptions,
|
|
223
|
+
ignoreDynamicRequires,
|
|
224
|
+
external: (source, importer, isResolved) => {
|
|
225
|
+
if (source.endsWith(".node")) {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
if (!external) {
|
|
229
|
+
return void 0;
|
|
230
|
+
}
|
|
231
|
+
if (typeof external === "string") {
|
|
232
|
+
return source === external;
|
|
233
|
+
}
|
|
234
|
+
if (Array.isArray(external)) {
|
|
235
|
+
return external.includes(source);
|
|
236
|
+
}
|
|
237
|
+
return external(source, importer, isResolved);
|
|
238
|
+
}
|
|
276
239
|
};
|
|
277
240
|
const { privateKey, cert } = parseKeys({
|
|
278
241
|
keyLength,
|
|
@@ -358,8 +321,8 @@ async function electronWithUpdater(options) {
|
|
|
358
321
|
} = parseOptions(pkg, sourcemap, minify, updater);
|
|
359
322
|
const { entryOutputDirPath, nativeModuleEntryMap, appEntryPath } = buildEntryOption;
|
|
360
323
|
try {
|
|
361
|
-
|
|
362
|
-
|
|
324
|
+
fs2.rmSync(buildAsarOption.electronDistPath, { recursive: true, force: true });
|
|
325
|
+
fs2.rmSync(entryOutputDirPath, { recursive: true, force: true });
|
|
363
326
|
} catch {
|
|
364
327
|
}
|
|
365
328
|
log.info(`Clear cache files`, { timestamp: true });
|
|
@@ -373,7 +336,6 @@ async function electronWithUpdater(options) {
|
|
|
373
336
|
__EIU_ENTRY_DIST_PATH__: JSON.stringify(normalizePath(buildEntryOption.entryOutputDirPath)),
|
|
374
337
|
__EIU_IS_DEV__: JSON.stringify(!isBuild),
|
|
375
338
|
__EIU_IS_ESM__: JSON.stringify(isESM),
|
|
376
|
-
__EIU_MAIN_DEV_DIR__: JSON.stringify(normalizePath(buildAsarOption.electronDistPath)),
|
|
377
339
|
__EIU_MAIN_FILE__: JSON.stringify(getMainFileBaseName(_main.files)),
|
|
378
340
|
__EIU_SIGNATURE_CERT__: JSON.stringify(cert),
|
|
379
341
|
__EIU_VERSION_PATH__: JSON.stringify(parseVersionPath(normalizePath(buildVersionOption.versionPath)))
|
|
@@ -392,15 +354,22 @@ async function electronWithUpdater(options) {
|
|
|
392
354
|
return path3.join(entryOutputDirPath, ...paths);
|
|
393
355
|
},
|
|
394
356
|
copyToEntryOutputDir({ from, to, skipIfExist = true }) {
|
|
395
|
-
if (
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
357
|
+
if (!fs2.existsSync(from)) {
|
|
358
|
+
log.warn(`${from} not found`, { timestamp: true });
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
const target = path3.join(entryOutputDirPath, to ?? path3.basename(from));
|
|
362
|
+
copyAndSkipIfExist(from, target, skipIfExist);
|
|
363
|
+
},
|
|
364
|
+
copyModules({ modules, skipIfExist = true }) {
|
|
365
|
+
const nodeModulesPath = path3.join(entryOutputDirPath, "node_modules");
|
|
366
|
+
for (const m of modules) {
|
|
367
|
+
const { rootPath } = getPackageInfoSync(m) || {};
|
|
368
|
+
if (!rootPath) {
|
|
369
|
+
log.warn(`Package '${m}' not found`, { timestamp: true });
|
|
370
|
+
continue;
|
|
403
371
|
}
|
|
372
|
+
copyAndSkipIfExist(rootPath, path3.join(nodeModulesPath, m), skipIfExist);
|
|
404
373
|
}
|
|
405
374
|
}
|
|
406
375
|
}) : async () => {
|
|
@@ -410,7 +379,7 @@ async function electronWithUpdater(options) {
|
|
|
410
379
|
external: (src) => src.startsWith("node:") || Object.keys("dependencies" in pkg ? pkg.dependencies : {}).includes(src) || src === "original-fs",
|
|
411
380
|
treeshake: true
|
|
412
381
|
};
|
|
413
|
-
const esmShimPlugin = isESM ? (await import('./esm-
|
|
382
|
+
const esmShimPlugin = isESM ? (await import('./esm-UJAQJA65.js')).esm() : void 0;
|
|
414
383
|
const electronPluginOptions = {
|
|
415
384
|
main: {
|
|
416
385
|
entry: _main.files,
|
|
@@ -430,7 +399,7 @@ async function electronWithUpdater(options) {
|
|
|
430
399
|
{
|
|
431
400
|
plugins: [
|
|
432
401
|
!isBuild && useNotBundle ? notBundle() : void 0,
|
|
433
|
-
bytecodeOptions &&
|
|
402
|
+
bytecodeOptions && await import('./bytecode-7V24FFYI.js').then((m) => m.bytecodePlugin("main", bytecodeOptions)),
|
|
434
403
|
esmShimPlugin
|
|
435
404
|
],
|
|
436
405
|
build: {
|
|
@@ -450,7 +419,7 @@ async function electronWithUpdater(options) {
|
|
|
450
419
|
vite: mergeConfig(
|
|
451
420
|
{
|
|
452
421
|
plugins: [
|
|
453
|
-
bytecodeOptions && (await import('./bytecode-
|
|
422
|
+
bytecodeOptions && (await import('./bytecode-7V24FFYI.js')).bytecodePlugin("preload", bytecodeOptions),
|
|
454
423
|
esmShimPlugin,
|
|
455
424
|
{
|
|
456
425
|
name: `${id}-build`,
|