electron-incremental-update 2.2.0 → 2.2.2
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 +39 -21
- package/dist/{bytecode-Z5ZF4YGN.js → bytecode-R2B4KTMV.js} +4 -5
- package/dist/{chunk-I2EHKJU4.js → chunk-LR7LR5WG.js} +48 -5
- package/dist/chunk-TPTWE33H.js +23 -0
- package/dist/{chunk-PUVBFHOK.js → chunk-XGWQQVIZ.js} +12 -12
- package/dist/{esm-5YR6V7VN.js → esm-4S4XCVEW.js} +1 -2
- package/dist/index.cjs +16 -16
- package/dist/index.d.cts +55 -9
- package/dist/index.d.ts +55 -9
- package/dist/index.js +12 -8
- package/dist/provider.cjs +45 -49
- package/dist/provider.d.cts +37 -36
- package/dist/provider.d.ts +37 -36
- package/dist/provider.js +20 -23
- package/dist/{types-DQKdsHc_.d.ts → types-CStrrQPl.d.ts} +5 -42
- package/dist/{types-BPH66pNz.d.cts → types-CWtySwqA.d.cts} +5 -42
- package/dist/utils.cjs +37 -37
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +1 -1
- package/dist/{version-DcFMG3pT.d.ts → version-Bl_0oO5f.d.cts} +13 -1
- package/dist/{version-DcFMG3pT.d.cts → version-Bl_0oO5f.d.ts} +13 -1
- package/dist/vite.d.ts +94 -32
- package/dist/vite.js +64 -36
- package/dist/{zip-rm9ED9nU.d.cts → zip-DQdr8pFv.d.cts} +1 -1
- package/dist/{zip-rm9ED9nU.d.ts → zip-DQdr8pFv.d.ts} +1 -1
- package/package.json +15 -16
- package/dist/chunk-CTUEQCKL.js +0 -43
- package/dist/chunk-WYQ5DRO7.js +0 -12
|
@@ -35,14 +35,26 @@ declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
|
|
|
35
35
|
* Update info json
|
|
36
36
|
*/
|
|
37
37
|
type UpdateInfo = {
|
|
38
|
+
/**
|
|
39
|
+
* Update Asar signature
|
|
40
|
+
*/
|
|
38
41
|
signature: string;
|
|
42
|
+
/**
|
|
43
|
+
* Minimum version
|
|
44
|
+
*/
|
|
39
45
|
minimumVersion: string;
|
|
46
|
+
/**
|
|
47
|
+
* Target version
|
|
48
|
+
*/
|
|
40
49
|
version: string;
|
|
41
50
|
};
|
|
42
51
|
/**
|
|
43
52
|
* {@link UpdateInfo} with beta
|
|
44
53
|
*/
|
|
45
54
|
type UpdateJSON = UpdateInfo & {
|
|
55
|
+
/**
|
|
56
|
+
* Beta update info
|
|
57
|
+
*/
|
|
46
58
|
beta: UpdateInfo;
|
|
47
59
|
};
|
|
48
60
|
/**
|
|
@@ -59,4 +71,4 @@ declare function isUpdateJSON(json: any): json is UpdateJSON;
|
|
|
59
71
|
*/
|
|
60
72
|
declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
|
|
61
73
|
|
|
62
|
-
export { type
|
|
74
|
+
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 };
|
|
@@ -35,14 +35,26 @@ declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
|
|
|
35
35
|
* Update info json
|
|
36
36
|
*/
|
|
37
37
|
type UpdateInfo = {
|
|
38
|
+
/**
|
|
39
|
+
* Update Asar signature
|
|
40
|
+
*/
|
|
38
41
|
signature: string;
|
|
42
|
+
/**
|
|
43
|
+
* Minimum version
|
|
44
|
+
*/
|
|
39
45
|
minimumVersion: string;
|
|
46
|
+
/**
|
|
47
|
+
* Target version
|
|
48
|
+
*/
|
|
40
49
|
version: string;
|
|
41
50
|
};
|
|
42
51
|
/**
|
|
43
52
|
* {@link UpdateInfo} with beta
|
|
44
53
|
*/
|
|
45
54
|
type UpdateJSON = UpdateInfo & {
|
|
55
|
+
/**
|
|
56
|
+
* Beta update info
|
|
57
|
+
*/
|
|
46
58
|
beta: UpdateInfo;
|
|
47
59
|
};
|
|
48
60
|
/**
|
|
@@ -59,4 +71,4 @@ declare function isUpdateJSON(json: any): json is UpdateJSON;
|
|
|
59
71
|
*/
|
|
60
72
|
declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
|
|
61
73
|
|
|
62
|
-
export { type
|
|
74
|
+
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
|
@@ -2,28 +2,53 @@ import { InlineConfig, PluginOption } from 'vite';
|
|
|
2
2
|
import { ElectronSimpleOptions } from 'vite-plugin-electron/simple';
|
|
3
3
|
import { Promisable } from '@subframe7536/type-utils';
|
|
4
4
|
export { isCI } from 'ci-info';
|
|
5
|
+
export { getPackageInfo, getPackageInfoSync, loadPackageJSON, resolveModule } from 'local-pkg';
|
|
6
|
+
|
|
7
|
+
interface BytecodeOptions {
|
|
8
|
+
enable: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Enable in preload script. Remember to set `sandbox: false` when creating window
|
|
11
|
+
*/
|
|
12
|
+
preload?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Custom electron binary path
|
|
15
|
+
*/
|
|
16
|
+
electronPath?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Before transformed code compile function. If return `Falsy` value, it will be ignored
|
|
19
|
+
* @param code transformed code
|
|
20
|
+
* @param id file path
|
|
21
|
+
*/
|
|
22
|
+
beforeCompile?: (code: string, id: string) => Promisable<string | null | undefined | void>;
|
|
23
|
+
}
|
|
5
24
|
|
|
6
25
|
/**
|
|
7
26
|
* Update info json
|
|
8
27
|
*/
|
|
9
28
|
type UpdateInfo = {
|
|
29
|
+
/**
|
|
30
|
+
* Update Asar signature
|
|
31
|
+
*/
|
|
10
32
|
signature: string;
|
|
33
|
+
/**
|
|
34
|
+
* Minimum version
|
|
35
|
+
*/
|
|
11
36
|
minimumVersion: string;
|
|
37
|
+
/**
|
|
38
|
+
* Target version
|
|
39
|
+
*/
|
|
12
40
|
version: string;
|
|
13
41
|
};
|
|
14
42
|
/**
|
|
15
43
|
* {@link UpdateInfo} with beta
|
|
16
44
|
*/
|
|
17
45
|
type UpdateJSON = UpdateInfo & {
|
|
46
|
+
/**
|
|
47
|
+
* Beta update info
|
|
48
|
+
*/
|
|
18
49
|
beta: UpdateInfo;
|
|
19
50
|
};
|
|
20
51
|
|
|
21
|
-
interface PKG {
|
|
22
|
-
name: string;
|
|
23
|
-
version: string;
|
|
24
|
-
main: string;
|
|
25
|
-
type: 'commonjs' | 'module';
|
|
26
|
-
}
|
|
27
52
|
interface DistinguishedName {
|
|
28
53
|
countryName?: string;
|
|
29
54
|
stateOrProvinceName?: string;
|
|
@@ -37,6 +62,13 @@ interface DistinguishedName {
|
|
|
37
62
|
businessCategory?: string;
|
|
38
63
|
emailAddress?: string;
|
|
39
64
|
}
|
|
65
|
+
|
|
66
|
+
interface PKG {
|
|
67
|
+
name: string;
|
|
68
|
+
version: string;
|
|
69
|
+
main: string;
|
|
70
|
+
type: 'commonjs' | 'module';
|
|
71
|
+
}
|
|
40
72
|
interface BuildEntryOption {
|
|
41
73
|
/**
|
|
42
74
|
* Override to minify on entry
|
|
@@ -72,12 +104,24 @@ interface BuildEntryOption {
|
|
|
72
104
|
*/
|
|
73
105
|
ignoreDynamicRequires?: boolean;
|
|
74
106
|
/**
|
|
75
|
-
* `external` option in `build.rollupOptions`
|
|
76
|
-
* @default source => source.endsWith('.node')
|
|
107
|
+
* `external` option in `build.rollupOptions`, external `.node` by default
|
|
77
108
|
*/
|
|
78
|
-
external?: (source: string, importer: string | undefined, isResolved: boolean) => boolean | null | undefined | void;
|
|
109
|
+
external?: string | string[] | ((source: string, importer: string | undefined, isResolved: boolean) => boolean | null | undefined | void);
|
|
79
110
|
/**
|
|
80
111
|
* Custom options for `vite` build
|
|
112
|
+
* ```ts
|
|
113
|
+
* const options = {
|
|
114
|
+
* plugins: [esm(), bytecodePlugin()], // load on needed
|
|
115
|
+
* build: {
|
|
116
|
+
* sourcemap,
|
|
117
|
+
* minify,
|
|
118
|
+
* outDir: entryOutputDirPath,
|
|
119
|
+
* commonjsOptions: { ignoreDynamicRequires },
|
|
120
|
+
* rollupOptions: { external },
|
|
121
|
+
* },
|
|
122
|
+
* define,
|
|
123
|
+
* }
|
|
124
|
+
* ```
|
|
81
125
|
*/
|
|
82
126
|
overrideViteOptions?: InlineConfig;
|
|
83
127
|
/**
|
|
@@ -105,6 +149,20 @@ interface BuildEntryOption {
|
|
|
105
149
|
*/
|
|
106
150
|
skipIfExist?: boolean;
|
|
107
151
|
}) => void;
|
|
152
|
+
/**
|
|
153
|
+
* Copy specified modules to entry output dir, just like `external` option in rollup
|
|
154
|
+
*/
|
|
155
|
+
copyModules: (options: {
|
|
156
|
+
/**
|
|
157
|
+
* External Modules
|
|
158
|
+
*/
|
|
159
|
+
modules: string[];
|
|
160
|
+
/**
|
|
161
|
+
* Skip copy if `to` exist
|
|
162
|
+
* @default true
|
|
163
|
+
*/
|
|
164
|
+
skipIfExist?: boolean;
|
|
165
|
+
}) => void;
|
|
108
166
|
}) => Promisable<void>;
|
|
109
167
|
}
|
|
110
168
|
interface GeneratorOverrideFunctions {
|
|
@@ -220,23 +278,16 @@ interface ElectronUpdaterOptions {
|
|
|
220
278
|
overrideGenerator?: GeneratorOverrideFunctions;
|
|
221
279
|
}
|
|
222
280
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Before transformed code compile function. If return `Falsy` value, it will be ignored
|
|
235
|
-
* @param code transformed code
|
|
236
|
-
* @param id file path
|
|
237
|
-
*/
|
|
238
|
-
beforeCompile?: (code: string, id: string) => Promisable<string | null | undefined | void>;
|
|
239
|
-
}
|
|
281
|
+
/**
|
|
282
|
+
* Obfuscate string
|
|
283
|
+
* @param code source code
|
|
284
|
+
* @param sourcemap whether to generate sourcemap
|
|
285
|
+
* @param offset custom offset
|
|
286
|
+
*/
|
|
287
|
+
declare function convertLiteral(code: string, sourcemap?: boolean, offset?: number): {
|
|
288
|
+
code: string;
|
|
289
|
+
map?: any;
|
|
290
|
+
};
|
|
240
291
|
|
|
241
292
|
type MakeRequired<T, K extends keyof T> = Exclude<T, undefined> & {
|
|
242
293
|
[P in K]-?: T[P];
|
|
@@ -245,8 +296,9 @@ type ReplaceKey<T, Key extends keyof T, NewKey extends string> = Omit<T, Key> &
|
|
|
245
296
|
[P in NewKey]: T[Key];
|
|
246
297
|
};
|
|
247
298
|
type MakeRequiredAndReplaceKey<T, K extends keyof T, NewKey extends string> = MakeRequired<ReplaceKey<T, K, NewKey>, NewKey>;
|
|
299
|
+
type StartupFn = Exclude<Exclude<ElectronSimpleOptions['preload'], undefined>['onstart'], undefined>;
|
|
248
300
|
/**
|
|
249
|
-
*
|
|
301
|
+
* Startup function for debug (see {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template})
|
|
250
302
|
* @example
|
|
251
303
|
* import { debugStartup, buildElectronPluginOptions } from 'electron-incremental-update/vite'
|
|
252
304
|
* const options = buildElectronPluginOptions({
|
|
@@ -257,10 +309,20 @@ type MakeRequiredAndReplaceKey<T, K extends keyof T, NewKey extends string> = Ma
|
|
|
257
309
|
* },
|
|
258
310
|
* })
|
|
259
311
|
*/
|
|
260
|
-
declare
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
312
|
+
declare const debugStartup: StartupFn;
|
|
313
|
+
/**
|
|
314
|
+
* Startup function util to fix Windows terminal charset
|
|
315
|
+
* @example
|
|
316
|
+
* import { debugStartup, fixWinCharEncoding, buildElectronPluginOptions } from 'electron-incremental-update/vite'
|
|
317
|
+
* const options = buildElectronPluginOptions({
|
|
318
|
+
* // ...
|
|
319
|
+
* main: {
|
|
320
|
+
* // ...
|
|
321
|
+
* startup: fixWinCharEncoding(debugStartup)
|
|
322
|
+
* },
|
|
323
|
+
* })
|
|
324
|
+
*/
|
|
325
|
+
declare function fixWinCharEncoding(fn: StartupFn): StartupFn;
|
|
264
326
|
type ExcludeOutputDirOptions = {
|
|
265
327
|
vite?: {
|
|
266
328
|
build?: {
|
|
@@ -393,4 +455,4 @@ interface ElectronWithUpdaterOptions {
|
|
|
393
455
|
*/
|
|
394
456
|
declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<PluginOption[] | undefined>;
|
|
395
457
|
|
|
396
|
-
export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater as default, electronWithUpdater };
|
|
458
|
+
export { type ElectronWithUpdaterOptions, convertLiteral, debugStartup, electronWithUpdater as default, electronWithUpdater, fixWinCharEncoding };
|
package/dist/vite.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { readableSize } from './chunk-
|
|
2
|
-
import { isUpdateJSON, defaultVersionJsonGenerator } from './chunk-
|
|
1
|
+
import { readableSize, copyAndSkipIfExist } from './chunk-TPTWE33H.js';
|
|
2
|
+
import { isUpdateJSON, defaultVersionJsonGenerator } from './chunk-LR7LR5WG.js';
|
|
3
|
+
export { convertLiteral } from './chunk-LR7LR5WG.js';
|
|
3
4
|
import { log, id } from './chunk-5NKEXGI3.js';
|
|
4
|
-
import path3 from 'node:path';
|
|
5
5
|
import fs2 from 'node:fs';
|
|
6
|
+
import path3 from 'node:path';
|
|
7
|
+
import { isCI } from 'ci-info';
|
|
8
|
+
export { isCI } from 'ci-info';
|
|
9
|
+
import { loadPackageJSON, getPackageInfoSync } from 'local-pkg';
|
|
10
|
+
export { getPackageInfo, getPackageInfoSync, loadPackageJSON, resolveModule } from 'local-pkg';
|
|
6
11
|
import { normalizePath, mergeConfig } from 'vite';
|
|
7
|
-
import ElectronSimple from 'vite-plugin-electron/simple';
|
|
8
12
|
import { startup, build } from 'vite-plugin-electron';
|
|
9
13
|
import { notBundle } from 'vite-plugin-electron/plugin';
|
|
10
|
-
import
|
|
11
|
-
import { isCI } from 'ci-info';
|
|
12
|
-
export { isCI } from 'ci-info';
|
|
14
|
+
import ElectronSimple from 'vite-plugin-electron/simple';
|
|
13
15
|
import Asar from '@electron/asar';
|
|
14
|
-
import zlib from 'node:zlib';
|
|
15
16
|
import crypto from 'node:crypto';
|
|
17
|
+
import zlib from 'node:zlib';
|
|
16
18
|
import { generate } from 'selfsigned';
|
|
17
19
|
|
|
18
20
|
async function buildAsar({
|
|
@@ -86,29 +88,20 @@ async function buildEntry({
|
|
|
86
88
|
},
|
|
87
89
|
vite: mergeConfig({
|
|
88
90
|
plugins: [
|
|
89
|
-
isESM && await import('./esm-
|
|
90
|
-
bytecodeOptions && await import('./bytecode-
|
|
91
|
+
isESM && await import('./esm-4S4XCVEW.js').then((m) => m.esm()),
|
|
92
|
+
bytecodeOptions && await import('./bytecode-R2B4KTMV.js').then((m) => m.bytecodePlugin("main", bytecodeOptions))
|
|
91
93
|
],
|
|
92
94
|
build: {
|
|
93
95
|
sourcemap,
|
|
94
96
|
minify,
|
|
95
97
|
outDir: entryOutputDirPath,
|
|
96
|
-
commonjsOptions: {
|
|
97
|
-
|
|
98
|
-
},
|
|
99
|
-
rollupOptions: {
|
|
100
|
-
external
|
|
101
|
-
}
|
|
98
|
+
commonjsOptions: { ignoreDynamicRequires },
|
|
99
|
+
rollupOptions: { external }
|
|
102
100
|
},
|
|
103
101
|
define
|
|
104
102
|
}, overrideViteOptions ?? {})
|
|
105
103
|
});
|
|
106
104
|
}
|
|
107
|
-
async function defaultZipFile(buffer) {
|
|
108
|
-
return new Promise((resolve, reject) => {
|
|
109
|
-
zlib.brotliCompress(buffer, (err, buffer2) => err ? reject(err) : resolve(buffer2));
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
105
|
function hashBuffer(data, length) {
|
|
113
106
|
const hash = crypto.createHash("SHA256").update(data).digest("binary");
|
|
114
107
|
return Buffer.from(hash).subarray(0, length);
|
|
@@ -121,6 +114,11 @@ function defaultSignature(buffer, privateKey, cert, version) {
|
|
|
121
114
|
const sig = crypto.createSign("RSA-SHA256").update(buffer).sign(crypto.createPrivateKey(privateKey), "base64");
|
|
122
115
|
return aesEncrypt(`${sig}%${version}`, hashBuffer(cert, 32), hashBuffer(buffer, 16));
|
|
123
116
|
}
|
|
117
|
+
async function defaultZipFile(buffer) {
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
zlib.brotliCompress(buffer, (err, buffer2) => err ? reject(err) : resolve(buffer2));
|
|
120
|
+
});
|
|
121
|
+
}
|
|
124
122
|
function generateKeyPair(keyLength, subject, days, privateKeyPath, certPath) {
|
|
125
123
|
const privateKeyDir = path3.dirname(privateKeyPath);
|
|
126
124
|
if (!fs2.existsSync(privateKeyDir)) {
|
|
@@ -179,7 +177,7 @@ function parseOptions(pkg, sourcemap = false, minify = false, options = {}) {
|
|
|
179
177
|
nativeModuleEntryMap = {},
|
|
180
178
|
postBuild,
|
|
181
179
|
ignoreDynamicRequires = false,
|
|
182
|
-
external
|
|
180
|
+
external,
|
|
183
181
|
overrideViteOptions = {}
|
|
184
182
|
} = {},
|
|
185
183
|
paths: {
|
|
@@ -223,7 +221,21 @@ function parseOptions(pkg, sourcemap = false, minify = false, options = {}) {
|
|
|
223
221
|
nativeModuleEntryMap,
|
|
224
222
|
overrideViteOptions,
|
|
225
223
|
ignoreDynamicRequires,
|
|
226
|
-
external
|
|
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
|
+
}
|
|
227
239
|
};
|
|
228
240
|
const { privateKey, cert } = parseKeys({
|
|
229
241
|
keyLength,
|
|
@@ -243,12 +255,20 @@ function parseOptions(pkg, sourcemap = false, minify = false, options = {}) {
|
|
|
243
255
|
};
|
|
244
256
|
return { buildAsarOption, buildEntryOption, buildVersionOption, postBuild, cert };
|
|
245
257
|
}
|
|
246
|
-
|
|
258
|
+
var debugStartup = (args) => {
|
|
247
259
|
if (process.env.VSCODE_DEBUG) {
|
|
248
260
|
console.log("[startup] Electron App");
|
|
249
261
|
} else {
|
|
250
262
|
args.startup();
|
|
251
263
|
}
|
|
264
|
+
};
|
|
265
|
+
function fixWinCharEncoding(fn) {
|
|
266
|
+
return async (...args) => {
|
|
267
|
+
if (process.platform === "win32") {
|
|
268
|
+
(await import('node:child_process')).spawnSync("chcp", ["65001"]);
|
|
269
|
+
}
|
|
270
|
+
await fn(...args);
|
|
271
|
+
};
|
|
252
272
|
}
|
|
253
273
|
function getMainFileBaseName(options) {
|
|
254
274
|
let mainFilePath;
|
|
@@ -320,6 +340,7 @@ async function electronWithUpdater(options) {
|
|
|
320
340
|
throw new Error(`Wrong "main" field in package.json: "${pkg.main}", it should be "${_appPath}"`);
|
|
321
341
|
}
|
|
322
342
|
const define = {
|
|
343
|
+
__EIU_ASAR_BASE_NAME__: JSON.stringify(path3.basename(buildAsarOption.asarOutputPath)),
|
|
323
344
|
__EIU_ELECTRON_DIST_PATH__: JSON.stringify(normalizePath(buildAsarOption.electronDistPath)),
|
|
324
345
|
__EIU_ENTRY_DIST_PATH__: JSON.stringify(normalizePath(buildEntryOption.entryOutputDirPath)),
|
|
325
346
|
__EIU_IS_DEV__: JSON.stringify(!isBuild),
|
|
@@ -342,15 +363,22 @@ async function electronWithUpdater(options) {
|
|
|
342
363
|
return path3.join(entryOutputDirPath, ...paths);
|
|
343
364
|
},
|
|
344
365
|
copyToEntryOutputDir({ from, to, skipIfExist = true }) {
|
|
345
|
-
if (fs2.existsSync(from)) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
366
|
+
if (!fs2.existsSync(from)) {
|
|
367
|
+
log.warn(`${from} not found`, { timestamp: true });
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
const target = path3.join(entryOutputDirPath, to ?? path3.basename(from));
|
|
371
|
+
copyAndSkipIfExist(from, target, skipIfExist);
|
|
372
|
+
},
|
|
373
|
+
copyModules({ modules, skipIfExist = true }) {
|
|
374
|
+
const nodeModulesPath = path3.join(entryOutputDirPath, "node_modules");
|
|
375
|
+
for (const m of modules) {
|
|
376
|
+
const { rootPath } = getPackageInfoSync(m) || {};
|
|
377
|
+
if (!rootPath) {
|
|
378
|
+
log.warn(`Package '${m}' not found`, { timestamp: true });
|
|
379
|
+
continue;
|
|
353
380
|
}
|
|
381
|
+
copyAndSkipIfExist(rootPath, path3.join(nodeModulesPath, m), skipIfExist);
|
|
354
382
|
}
|
|
355
383
|
}
|
|
356
384
|
}) : async () => {
|
|
@@ -360,7 +388,7 @@ async function electronWithUpdater(options) {
|
|
|
360
388
|
external: (src) => src.startsWith("node:") || Object.keys("dependencies" in pkg ? pkg.dependencies : {}).includes(src) || src === "original-fs",
|
|
361
389
|
treeshake: true
|
|
362
390
|
};
|
|
363
|
-
const esmShimPlugin = isESM ? (await import('./esm-
|
|
391
|
+
const esmShimPlugin = isESM ? (await import('./esm-4S4XCVEW.js')).esm() : void 0;
|
|
364
392
|
const electronPluginOptions = {
|
|
365
393
|
main: {
|
|
366
394
|
entry: _main.files,
|
|
@@ -380,7 +408,7 @@ async function electronWithUpdater(options) {
|
|
|
380
408
|
{
|
|
381
409
|
plugins: [
|
|
382
410
|
!isBuild && useNotBundle ? notBundle() : void 0,
|
|
383
|
-
bytecodeOptions && await import('./bytecode-
|
|
411
|
+
bytecodeOptions && await import('./bytecode-R2B4KTMV.js').then((m) => m.bytecodePlugin("main", bytecodeOptions)),
|
|
384
412
|
esmShimPlugin
|
|
385
413
|
],
|
|
386
414
|
build: {
|
|
@@ -400,7 +428,7 @@ async function electronWithUpdater(options) {
|
|
|
400
428
|
vite: mergeConfig(
|
|
401
429
|
{
|
|
402
430
|
plugins: [
|
|
403
|
-
bytecodeOptions && (await import('./bytecode-
|
|
431
|
+
bytecodeOptions && (await import('./bytecode-R2B4KTMV.js')).bytecodePlugin("preload", bytecodeOptions),
|
|
404
432
|
esmShimPlugin,
|
|
405
433
|
{
|
|
406
434
|
name: `${id}-build`,
|
|
@@ -472,4 +500,4 @@ async function electronWithUpdater(options) {
|
|
|
472
500
|
}
|
|
473
501
|
var vite_default = electronWithUpdater;
|
|
474
502
|
|
|
475
|
-
export { debugStartup, vite_default as default, electronWithUpdater };
|
|
503
|
+
export { debugStartup, vite_default as default, electronWithUpdater, fixWinCharEncoding };
|
|
@@ -30,4 +30,4 @@ declare function defaultZipFile(buffer: Buffer): Promise<Buffer>;
|
|
|
30
30
|
*/
|
|
31
31
|
declare function defaultUnzipFile(buffer: Buffer): Promise<Buffer>;
|
|
32
32
|
|
|
33
|
-
export {
|
|
33
|
+
export { aesEncrypt as a, aesDecrypt as b, defaultVerifySignature as c, defaultSignature as d, defaultZipFile as e, defaultUnzipFile as f, hashBuffer as h };
|
|
@@ -30,4 +30,4 @@ declare function defaultZipFile(buffer: Buffer): Promise<Buffer>;
|
|
|
30
30
|
*/
|
|
31
31
|
declare function defaultUnzipFile(buffer: Buffer): Promise<Buffer>;
|
|
32
32
|
|
|
33
|
-
export {
|
|
33
|
+
export { aesEncrypt as a, aesDecrypt as b, defaultVerifySignature as c, defaultSignature as d, defaultZipFile as e, defaultUnzipFile as f, hashBuffer as h };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-incremental-update",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.2",
|
|
5
5
|
"description": "Electron incremental update tools with Vite plugin, support bytecode protection",
|
|
6
6
|
"author": "subframe7536",
|
|
7
7
|
"license": "MIT",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
],
|
|
46
46
|
"scripts": {
|
|
47
47
|
"dev": "tsup --watch",
|
|
48
|
-
"build": "tsup &&
|
|
48
|
+
"build": "tsup && node fix-module.cjs",
|
|
49
49
|
"release": "pnpm test && pnpm run build && bumpp --all && npm publish",
|
|
50
50
|
"test": "vitest --run",
|
|
51
51
|
"test:dev": "vitest",
|
|
@@ -60,28 +60,27 @@
|
|
|
60
60
|
"esbuild": "*"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@babel/core": "^7.25.
|
|
64
|
-
"@babel/plugin-transform-arrow-functions": "^7.
|
|
65
|
-
"@babel/plugin-transform-template-literals": "^7.
|
|
63
|
+
"@babel/core": "^7.25.7",
|
|
64
|
+
"@babel/plugin-transform-arrow-functions": "^7.25.7",
|
|
65
|
+
"@babel/plugin-transform-template-literals": "^7.25.7",
|
|
66
66
|
"@subframe7536/type-utils": "^0.1.6",
|
|
67
67
|
"ci-info": "^4.0.0",
|
|
68
68
|
"local-pkg": "^0.5.0",
|
|
69
69
|
"magic-string": "^0.30.11",
|
|
70
70
|
"selfsigned": "^2.4.1",
|
|
71
|
-
"vite-plugin-electron": "^0.28.
|
|
71
|
+
"vite-plugin-electron": "^0.28.8"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@subframe7536/eslint-config": "^0.
|
|
74
|
+
"@subframe7536/eslint-config": "^0.9.4",
|
|
75
75
|
"@types/babel__core": "^7.20.5",
|
|
76
|
-
"@types/node": "^20.16.
|
|
77
|
-
"bumpp": "^9.
|
|
76
|
+
"@types/node": "^20.16.11",
|
|
77
|
+
"bumpp": "^9.6.1",
|
|
78
78
|
"electron": "28.2.10",
|
|
79
|
-
"eslint": "^9.
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"vite": "^
|
|
84
|
-
"
|
|
85
|
-
"vitest": "^2.0.5"
|
|
79
|
+
"eslint": "^9.12.0",
|
|
80
|
+
"tsup": "^8.3.0",
|
|
81
|
+
"typescript": "^5.6.3",
|
|
82
|
+
"vite": "^5.4.8",
|
|
83
|
+
"vite-plugin-electron": "^0.28.8",
|
|
84
|
+
"vitest": "^2.1.2"
|
|
86
85
|
}
|
|
87
86
|
}
|
package/dist/chunk-CTUEQCKL.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// src/utils/version.ts
|
|
2
|
-
function parseVersion(version) {
|
|
3
|
-
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?/i.exec(version);
|
|
4
|
-
if (!match) {
|
|
5
|
-
throw new TypeError(`invalid version: ${version}`);
|
|
6
|
-
}
|
|
7
|
-
const [major, minor, patch] = match.slice(1, 4).map(Number);
|
|
8
|
-
const ret = {
|
|
9
|
-
major,
|
|
10
|
-
minor,
|
|
11
|
-
patch,
|
|
12
|
-
stage: "",
|
|
13
|
-
stageVersion: -1
|
|
14
|
-
};
|
|
15
|
-
if (match[4]) {
|
|
16
|
-
let [stage, _v] = match[4].split(".");
|
|
17
|
-
ret.stage = stage;
|
|
18
|
-
ret.stageVersion = Number(_v) || -1;
|
|
19
|
-
}
|
|
20
|
-
if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch) || Number.isNaN(ret.stageVersion)) {
|
|
21
|
-
throw new TypeError(`Invalid version: ${version}`);
|
|
22
|
-
}
|
|
23
|
-
return ret;
|
|
24
|
-
}
|
|
25
|
-
var is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
|
|
26
|
-
function isUpdateJSON(json) {
|
|
27
|
-
return is(json) && is(json?.beta);
|
|
28
|
-
}
|
|
29
|
-
function defaultVersionJsonGenerator(existingJson, signature, version, minimumVersion) {
|
|
30
|
-
existingJson.beta = {
|
|
31
|
-
version,
|
|
32
|
-
minimumVersion,
|
|
33
|
-
signature
|
|
34
|
-
};
|
|
35
|
-
if (!parseVersion(version).stage) {
|
|
36
|
-
existingJson.version = version;
|
|
37
|
-
existingJson.minimumVersion = minimumVersion;
|
|
38
|
-
existingJson.signature = signature;
|
|
39
|
-
}
|
|
40
|
-
return existingJson;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { defaultVersionJsonGenerator, isUpdateJSON, parseVersion };
|
package/dist/chunk-WYQ5DRO7.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// src/vite/utils.ts
|
|
2
|
-
function readableSize(size) {
|
|
3
|
-
const units = ["B", "KB", "MB", "GB"];
|
|
4
|
-
let i = 0;
|
|
5
|
-
while (size >= 1024 && i < units.length - 1) {
|
|
6
|
-
size /= 1024;
|
|
7
|
-
i++;
|
|
8
|
-
}
|
|
9
|
-
return `${size.toFixed(2)} ${units[i]}`;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { readableSize };
|