electron-incremental-update 0.9.1 → 1.0.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/README.md +159 -111
- package/dist/{chunk-CMBFI77K.mjs → chunk-GB6VLKJZ.mjs} +48 -28
- package/dist/{chunk-5BZLJPHJ.mjs → chunk-GXZSAUBR.mjs} +1 -8
- package/dist/chunk-OUZLSVQC.mjs +148 -0
- package/dist/index.d.mts +102 -80
- package/dist/index.d.ts +102 -80
- package/dist/index.js +134 -71
- package/dist/index.mjs +97 -43
- package/dist/noDep-TvZoKVF8.d.mts +31 -0
- package/dist/noDep-TvZoKVF8.d.ts +31 -0
- package/dist/utils.d.mts +85 -48
- package/dist/utils.d.ts +85 -48
- package/dist/utils.js +127 -86
- package/dist/utils.mjs +14 -20
- package/dist/vite.d.mts +208 -41
- package/dist/vite.d.ts +208 -41
- package/dist/vite.js +243 -122
- package/dist/vite.mjs +220 -98
- package/package.json +18 -11
- package/dist/chunk-SPZL37O5.mjs +0 -124
- package/dist/updateJson-synsK-Pt.d.mts +0 -11
- package/dist/updateJson-synsK-Pt.d.ts +0 -11
package/dist/utils.mjs
CHANGED
|
@@ -1,41 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
|
-
DEFAULT_APP_NAME,
|
|
3
|
-
NoSuchNativeModuleError,
|
|
4
2
|
disableHWAccForWin7,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
getProductAsarPath,
|
|
9
|
-
handleUnexpectedErrors,
|
|
3
|
+
getPathFromAppNameAsar,
|
|
4
|
+
getPaths,
|
|
5
|
+
getVersions,
|
|
10
6
|
is,
|
|
11
|
-
|
|
12
|
-
parseGithubCdnURL,
|
|
13
|
-
requireNative,
|
|
7
|
+
loadNativeModuleFromEntry,
|
|
14
8
|
restartApp,
|
|
15
9
|
setAppUserModelId,
|
|
16
10
|
setPortableAppDataPath,
|
|
17
11
|
singleInstance,
|
|
18
12
|
waitAppReady
|
|
19
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-OUZLSVQC.mjs";
|
|
20
14
|
import {
|
|
15
|
+
handleUnexpectedErrors,
|
|
16
|
+
isUpdateJSON,
|
|
17
|
+
parseGithubCdnURL,
|
|
21
18
|
parseVersion,
|
|
22
19
|
unzipFile,
|
|
23
20
|
zipFile
|
|
24
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-GB6VLKJZ.mjs";
|
|
25
22
|
export {
|
|
26
|
-
DEFAULT_APP_NAME,
|
|
27
|
-
NoSuchNativeModuleError,
|
|
28
23
|
disableHWAccForWin7,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
getProductAsarPath,
|
|
24
|
+
getPathFromAppNameAsar,
|
|
25
|
+
getPaths,
|
|
26
|
+
getVersions,
|
|
33
27
|
handleUnexpectedErrors,
|
|
34
28
|
is,
|
|
35
|
-
|
|
29
|
+
isUpdateJSON,
|
|
30
|
+
loadNativeModuleFromEntry,
|
|
36
31
|
parseGithubCdnURL,
|
|
37
32
|
parseVersion,
|
|
38
|
-
requireNative,
|
|
39
33
|
restartApp,
|
|
40
34
|
setAppUserModelId,
|
|
41
35
|
setPortableAppDataPath,
|
package/dist/vite.d.mts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
|
-
import {
|
|
2
|
+
import { ElectronSimpleOptions } from 'vite-plugin-electron/simple';
|
|
3
|
+
import { Promisable, Prettify } from '@subframe7536/type-utils';
|
|
4
|
+
import { BuildOptions } from 'esbuild';
|
|
5
|
+
import { a as UpdateJSON } from './noDep-TvZoKVF8.mjs';
|
|
3
6
|
|
|
7
|
+
type PKG = {
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
main: string;
|
|
11
|
+
};
|
|
4
12
|
type DistinguishedName = {
|
|
5
13
|
countryName?: string;
|
|
6
14
|
stateOrProvinceName?: string;
|
|
@@ -14,6 +22,85 @@ type DistinguishedName = {
|
|
|
14
22
|
businessCategory?: string;
|
|
15
23
|
emailAddress?: string;
|
|
16
24
|
};
|
|
25
|
+
type BuildEntryOption = {
|
|
26
|
+
/**
|
|
27
|
+
* whether to minify
|
|
28
|
+
* @default isBuild
|
|
29
|
+
*/
|
|
30
|
+
minify: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Whether to generate sourcemap
|
|
33
|
+
* @default isBuild
|
|
34
|
+
*/
|
|
35
|
+
sourcemap: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* path to app entry output file
|
|
38
|
+
* @default 'dist-entry'
|
|
39
|
+
*/
|
|
40
|
+
entryOutputDirPath: string;
|
|
41
|
+
/**
|
|
42
|
+
* path to app entry file
|
|
43
|
+
* @default 'electron/entry.ts'
|
|
44
|
+
*/
|
|
45
|
+
appEntryPath: string;
|
|
46
|
+
/**
|
|
47
|
+
* esbuild path map of native modules in entry directory
|
|
48
|
+
*
|
|
49
|
+
* @default {}
|
|
50
|
+
* @example
|
|
51
|
+
* { db: './electron/native/db.ts' }
|
|
52
|
+
*/
|
|
53
|
+
nativeModuleEntryMap?: Record<string, string>;
|
|
54
|
+
/**
|
|
55
|
+
* custom options for esbuild
|
|
56
|
+
* ```ts
|
|
57
|
+
* // default options
|
|
58
|
+
* const options = {
|
|
59
|
+
* entryPoints: {
|
|
60
|
+
* entry: appEntryPath,
|
|
61
|
+
* ...moduleEntryMap,
|
|
62
|
+
* },
|
|
63
|
+
* bundle: true,
|
|
64
|
+
* platform: 'node',
|
|
65
|
+
* outdir: entryOutputDirPath,
|
|
66
|
+
* minify,
|
|
67
|
+
* sourcemap,
|
|
68
|
+
* entryNames: '[dir]/[name]',
|
|
69
|
+
* assetNames: '[dir]/[name]',
|
|
70
|
+
* external: ['electron', 'original-fs'],
|
|
71
|
+
* loader: {
|
|
72
|
+
* '.node': 'empty',
|
|
73
|
+
* },
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
overrideEsbuildOptions?: BuildOptions;
|
|
78
|
+
/**
|
|
79
|
+
* resolve extra files, such as `.node`
|
|
80
|
+
*/
|
|
81
|
+
postBuild?: (args: {
|
|
82
|
+
/**
|
|
83
|
+
* get path from `entryOutputDirPath`
|
|
84
|
+
*/
|
|
85
|
+
getPathFromEntryOutputDir: (...paths: string[]) => string;
|
|
86
|
+
/**
|
|
87
|
+
* copy file to `entryOutputDirPath`
|
|
88
|
+
*
|
|
89
|
+
* if `to` absent, set to `basename(from)`
|
|
90
|
+
*
|
|
91
|
+
* if `skipIfExist` absent, skip copy if `to` exist
|
|
92
|
+
*/
|
|
93
|
+
existsAndCopyToEntryOutputDir: (options: {
|
|
94
|
+
from: string;
|
|
95
|
+
to?: string;
|
|
96
|
+
/**
|
|
97
|
+
* skip copy if `to` exist
|
|
98
|
+
* @default true
|
|
99
|
+
*/
|
|
100
|
+
skipIfExist?: boolean;
|
|
101
|
+
}) => void;
|
|
102
|
+
}) => Promisable<void>;
|
|
103
|
+
};
|
|
17
104
|
type GeneratorOverrideFunctions = {
|
|
18
105
|
/**
|
|
19
106
|
* custom signature generate function
|
|
@@ -34,49 +121,23 @@ type GeneratorOverrideFunctions = {
|
|
|
34
121
|
*/
|
|
35
122
|
generateVersionJson?: (existingJson: UpdateJSON, buffer: Buffer, signature: string, version: string, minVersion: string) => UpdateJSON | Promise<UpdateJSON>;
|
|
36
123
|
};
|
|
37
|
-
type
|
|
38
|
-
/**
|
|
39
|
-
* whether is in build mode
|
|
40
|
-
*/
|
|
41
|
-
isBuild: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* the name of you application
|
|
44
|
-
*
|
|
45
|
-
* you can set as 'name' in `package.json`
|
|
46
|
-
*/
|
|
47
|
-
productName: string;
|
|
48
|
-
/**
|
|
49
|
-
* the version of you application
|
|
50
|
-
*
|
|
51
|
-
* you can set as 'version' in `package.json`
|
|
52
|
-
*/
|
|
53
|
-
version: string;
|
|
124
|
+
type ElectronUpdaterOptions = {
|
|
54
125
|
/**
|
|
55
126
|
* mini version of entry
|
|
56
|
-
* @default
|
|
127
|
+
* @default '0.0.0'
|
|
57
128
|
*/
|
|
58
129
|
minimumVersion?: string;
|
|
59
130
|
/**
|
|
60
|
-
*
|
|
131
|
+
* config for entry (app.asar)
|
|
61
132
|
*/
|
|
62
|
-
|
|
133
|
+
entry?: Partial<BuildEntryOption>;
|
|
63
134
|
/**
|
|
64
135
|
* paths config
|
|
65
136
|
*/
|
|
66
137
|
paths?: {
|
|
67
|
-
/**
|
|
68
|
-
* Path to app entry file
|
|
69
|
-
* @default 'electron/app.ts'
|
|
70
|
-
*/
|
|
71
|
-
entryPath?: string;
|
|
72
|
-
/**
|
|
73
|
-
* Path to app entry output file
|
|
74
|
-
* @default 'app.js'
|
|
75
|
-
*/
|
|
76
|
-
entryOutputPath?: string;
|
|
77
138
|
/**
|
|
78
139
|
* Path to asar file
|
|
79
|
-
* @default `release/${
|
|
140
|
+
* @default `release/${app.name}.asar`
|
|
80
141
|
*/
|
|
81
142
|
asarOutputPath?: string;
|
|
82
143
|
/**
|
|
@@ -86,7 +147,7 @@ type Options = {
|
|
|
86
147
|
versionPath?: string;
|
|
87
148
|
/**
|
|
88
149
|
* Path to gzipped asar file
|
|
89
|
-
* @default `release/${
|
|
150
|
+
* @default `release/${app.name}-${version}.asar.gz`
|
|
90
151
|
*/
|
|
91
152
|
gzipPath?: string;
|
|
92
153
|
/**
|
|
@@ -105,19 +166,23 @@ type Options = {
|
|
|
105
166
|
*/
|
|
106
167
|
keys?: {
|
|
107
168
|
/**
|
|
108
|
-
*
|
|
169
|
+
* path to the pem file that contains private key
|
|
109
170
|
* if not ended with .pem, it will be appended
|
|
171
|
+
*
|
|
172
|
+
* **if `UPDATER_PK` is set, will read it instead of read from `privateKeyPath`**
|
|
110
173
|
* @default 'keys/private.pem'
|
|
111
174
|
*/
|
|
112
175
|
privateKeyPath?: string;
|
|
113
176
|
/**
|
|
114
|
-
*
|
|
177
|
+
* path to the pem file that contains public key
|
|
115
178
|
* if not ended with .pem, it will be appended
|
|
179
|
+
*
|
|
180
|
+
* **if `UPDATER_CERT` is set, will read it instead of read from `certPath`**
|
|
116
181
|
* @default 'keys/cert.pem'
|
|
117
182
|
*/
|
|
118
183
|
certPath?: string;
|
|
119
184
|
/**
|
|
120
|
-
*
|
|
185
|
+
* length of the key
|
|
121
186
|
* @default 2048
|
|
122
187
|
*/
|
|
123
188
|
keyLength?: number;
|
|
@@ -130,20 +195,122 @@ type Options = {
|
|
|
130
195
|
/**
|
|
131
196
|
* the subject of the certificate
|
|
132
197
|
*
|
|
133
|
-
* @default { commonName:
|
|
198
|
+
* @default { commonName: `${app.name}`, organizationName: `org.${app.name}` }
|
|
134
199
|
*/
|
|
135
200
|
subject?: DistinguishedName;
|
|
136
201
|
/**
|
|
137
202
|
* expire days of the certificate
|
|
138
203
|
*
|
|
139
|
-
* @default
|
|
204
|
+
* @default 3650
|
|
140
205
|
*/
|
|
141
206
|
days?: number;
|
|
142
207
|
};
|
|
143
|
-
|
|
208
|
+
overrideGenerator?: GeneratorOverrideFunctions;
|
|
144
209
|
};
|
|
145
210
|
};
|
|
146
211
|
|
|
147
|
-
|
|
212
|
+
type MakeRequired<T, K extends keyof T> = Exclude<T, undefined> & {
|
|
213
|
+
[P in K]-?: T[P];
|
|
214
|
+
};
|
|
215
|
+
type ReplaceKey<T, Key extends keyof T, NewKey extends string> = Omit<T, Key> & {
|
|
216
|
+
[P in NewKey]: T[Key];
|
|
217
|
+
};
|
|
218
|
+
type MakeRequiredAndReplaceKey<T, K extends keyof T, NewKey extends string> = MakeRequired<ReplaceKey<T, K, NewKey>, NewKey>;
|
|
219
|
+
/**
|
|
220
|
+
* startup function for debug (see {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template})
|
|
221
|
+
* @example
|
|
222
|
+
* import { debugStartup, buildElectronPluginOptions } from 'electron-incremental-update/vite'
|
|
223
|
+
* const options = buildElectronPluginOptions({
|
|
224
|
+
* // ...
|
|
225
|
+
* main: {
|
|
226
|
+
* // ...
|
|
227
|
+
* startup: debugStartup
|
|
228
|
+
* },
|
|
229
|
+
* })
|
|
230
|
+
*/
|
|
231
|
+
declare function debugStartup(args: {
|
|
232
|
+
startup: (argv?: string[]) => Promise<void>;
|
|
233
|
+
reload: () => void;
|
|
234
|
+
}): void;
|
|
235
|
+
type ElectronWithUpdaterOptions = {
|
|
236
|
+
/**
|
|
237
|
+
* whether is in build mode
|
|
238
|
+
* ```ts
|
|
239
|
+
* export default defineConfig(({ command }) => {
|
|
240
|
+
* const isBuild = command === 'build'
|
|
241
|
+
* })
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
isBuild: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* name, version and main in `package.json`
|
|
247
|
+
* ```ts
|
|
248
|
+
* import pkg from './package.json'
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
pkg: PKG;
|
|
252
|
+
/**
|
|
253
|
+
* main options
|
|
254
|
+
*/
|
|
255
|
+
main: Prettify<MakeRequiredAndReplaceKey<ElectronSimpleOptions['main'], 'entry', 'files'>>;
|
|
256
|
+
/**
|
|
257
|
+
* preload options
|
|
258
|
+
*/
|
|
259
|
+
preload: Prettify<MakeRequiredAndReplaceKey<Exclude<ElectronSimpleOptions['preload'], undefined>, 'input', 'files'>>;
|
|
260
|
+
/**
|
|
261
|
+
* updater options
|
|
262
|
+
*/
|
|
263
|
+
updater?: ElectronUpdaterOptions;
|
|
264
|
+
/**
|
|
265
|
+
* use NotBundle() plugin in main
|
|
266
|
+
* @default true
|
|
267
|
+
*/
|
|
268
|
+
useNotBundle?: boolean;
|
|
269
|
+
/**
|
|
270
|
+
* Whether to log parsed options
|
|
271
|
+
*/
|
|
272
|
+
logParsedOptions?: boolean;
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* build options for `vite-plugin-electron/simple`
|
|
276
|
+
* - integrate with updater
|
|
277
|
+
* - only contains `main` and `preload` configs
|
|
278
|
+
* - remove old electron files
|
|
279
|
+
* - externalize dependencies
|
|
280
|
+
* - auto restart when entry file changes
|
|
281
|
+
* - other configs in {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template}
|
|
282
|
+
* - no `vite-plugin-electron-renderer` config
|
|
283
|
+
*
|
|
284
|
+
* you can override all the configs
|
|
285
|
+
*
|
|
286
|
+
* **Limitation**: entry file change cannot trigger auto restart
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* import { defineConfig } from 'vite'
|
|
290
|
+
* import electronSimple from 'vite-plugin-electron/simple'
|
|
291
|
+
* import { buildElectronPluginOptions } from 'electron-incremental-update/vite'
|
|
292
|
+
* import pkg from './package.json'
|
|
293
|
+
*
|
|
294
|
+
* export default defineConfig(({ command }) => {
|
|
295
|
+
* const electronOptions = buildElectronPluginOptions({
|
|
296
|
+
* isBuild: command === 'build',
|
|
297
|
+
* pkg,
|
|
298
|
+
* main: {
|
|
299
|
+
* files: ['./electron/main/index.ts', './electron/main/worker.ts'],
|
|
300
|
+
* },
|
|
301
|
+
* preload: {
|
|
302
|
+
* files: './electron/preload/index.ts',
|
|
303
|
+
* },
|
|
304
|
+
* })
|
|
305
|
+
* return {
|
|
306
|
+
* plugins: [electronSimple(electronOptions)],
|
|
307
|
+
* server: process.env.VSCODE_DEBUG && (() => {
|
|
308
|
+
* const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
|
|
309
|
+
* return { host: url.hostname, port: +url.port }
|
|
310
|
+
* })()
|
|
311
|
+
* }
|
|
312
|
+
* })
|
|
313
|
+
*/
|
|
314
|
+
declare function electronWithUpdater(options: ElectronWithUpdaterOptions): (Plugin<any> | Promise<Plugin<any>[]> | undefined)[];
|
|
148
315
|
|
|
149
|
-
export {
|
|
316
|
+
export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater };
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
|
-
import {
|
|
2
|
+
import { ElectronSimpleOptions } from 'vite-plugin-electron/simple';
|
|
3
|
+
import { Promisable, Prettify } from '@subframe7536/type-utils';
|
|
4
|
+
import { BuildOptions } from 'esbuild';
|
|
5
|
+
import { a as UpdateJSON } from './noDep-TvZoKVF8.js';
|
|
3
6
|
|
|
7
|
+
type PKG = {
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
main: string;
|
|
11
|
+
};
|
|
4
12
|
type DistinguishedName = {
|
|
5
13
|
countryName?: string;
|
|
6
14
|
stateOrProvinceName?: string;
|
|
@@ -14,6 +22,85 @@ type DistinguishedName = {
|
|
|
14
22
|
businessCategory?: string;
|
|
15
23
|
emailAddress?: string;
|
|
16
24
|
};
|
|
25
|
+
type BuildEntryOption = {
|
|
26
|
+
/**
|
|
27
|
+
* whether to minify
|
|
28
|
+
* @default isBuild
|
|
29
|
+
*/
|
|
30
|
+
minify: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Whether to generate sourcemap
|
|
33
|
+
* @default isBuild
|
|
34
|
+
*/
|
|
35
|
+
sourcemap: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* path to app entry output file
|
|
38
|
+
* @default 'dist-entry'
|
|
39
|
+
*/
|
|
40
|
+
entryOutputDirPath: string;
|
|
41
|
+
/**
|
|
42
|
+
* path to app entry file
|
|
43
|
+
* @default 'electron/entry.ts'
|
|
44
|
+
*/
|
|
45
|
+
appEntryPath: string;
|
|
46
|
+
/**
|
|
47
|
+
* esbuild path map of native modules in entry directory
|
|
48
|
+
*
|
|
49
|
+
* @default {}
|
|
50
|
+
* @example
|
|
51
|
+
* { db: './electron/native/db.ts' }
|
|
52
|
+
*/
|
|
53
|
+
nativeModuleEntryMap?: Record<string, string>;
|
|
54
|
+
/**
|
|
55
|
+
* custom options for esbuild
|
|
56
|
+
* ```ts
|
|
57
|
+
* // default options
|
|
58
|
+
* const options = {
|
|
59
|
+
* entryPoints: {
|
|
60
|
+
* entry: appEntryPath,
|
|
61
|
+
* ...moduleEntryMap,
|
|
62
|
+
* },
|
|
63
|
+
* bundle: true,
|
|
64
|
+
* platform: 'node',
|
|
65
|
+
* outdir: entryOutputDirPath,
|
|
66
|
+
* minify,
|
|
67
|
+
* sourcemap,
|
|
68
|
+
* entryNames: '[dir]/[name]',
|
|
69
|
+
* assetNames: '[dir]/[name]',
|
|
70
|
+
* external: ['electron', 'original-fs'],
|
|
71
|
+
* loader: {
|
|
72
|
+
* '.node': 'empty',
|
|
73
|
+
* },
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
overrideEsbuildOptions?: BuildOptions;
|
|
78
|
+
/**
|
|
79
|
+
* resolve extra files, such as `.node`
|
|
80
|
+
*/
|
|
81
|
+
postBuild?: (args: {
|
|
82
|
+
/**
|
|
83
|
+
* get path from `entryOutputDirPath`
|
|
84
|
+
*/
|
|
85
|
+
getPathFromEntryOutputDir: (...paths: string[]) => string;
|
|
86
|
+
/**
|
|
87
|
+
* copy file to `entryOutputDirPath`
|
|
88
|
+
*
|
|
89
|
+
* if `to` absent, set to `basename(from)`
|
|
90
|
+
*
|
|
91
|
+
* if `skipIfExist` absent, skip copy if `to` exist
|
|
92
|
+
*/
|
|
93
|
+
existsAndCopyToEntryOutputDir: (options: {
|
|
94
|
+
from: string;
|
|
95
|
+
to?: string;
|
|
96
|
+
/**
|
|
97
|
+
* skip copy if `to` exist
|
|
98
|
+
* @default true
|
|
99
|
+
*/
|
|
100
|
+
skipIfExist?: boolean;
|
|
101
|
+
}) => void;
|
|
102
|
+
}) => Promisable<void>;
|
|
103
|
+
};
|
|
17
104
|
type GeneratorOverrideFunctions = {
|
|
18
105
|
/**
|
|
19
106
|
* custom signature generate function
|
|
@@ -34,49 +121,23 @@ type GeneratorOverrideFunctions = {
|
|
|
34
121
|
*/
|
|
35
122
|
generateVersionJson?: (existingJson: UpdateJSON, buffer: Buffer, signature: string, version: string, minVersion: string) => UpdateJSON | Promise<UpdateJSON>;
|
|
36
123
|
};
|
|
37
|
-
type
|
|
38
|
-
/**
|
|
39
|
-
* whether is in build mode
|
|
40
|
-
*/
|
|
41
|
-
isBuild: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* the name of you application
|
|
44
|
-
*
|
|
45
|
-
* you can set as 'name' in `package.json`
|
|
46
|
-
*/
|
|
47
|
-
productName: string;
|
|
48
|
-
/**
|
|
49
|
-
* the version of you application
|
|
50
|
-
*
|
|
51
|
-
* you can set as 'version' in `package.json`
|
|
52
|
-
*/
|
|
53
|
-
version: string;
|
|
124
|
+
type ElectronUpdaterOptions = {
|
|
54
125
|
/**
|
|
55
126
|
* mini version of entry
|
|
56
|
-
* @default
|
|
127
|
+
* @default '0.0.0'
|
|
57
128
|
*/
|
|
58
129
|
minimumVersion?: string;
|
|
59
130
|
/**
|
|
60
|
-
*
|
|
131
|
+
* config for entry (app.asar)
|
|
61
132
|
*/
|
|
62
|
-
|
|
133
|
+
entry?: Partial<BuildEntryOption>;
|
|
63
134
|
/**
|
|
64
135
|
* paths config
|
|
65
136
|
*/
|
|
66
137
|
paths?: {
|
|
67
|
-
/**
|
|
68
|
-
* Path to app entry file
|
|
69
|
-
* @default 'electron/app.ts'
|
|
70
|
-
*/
|
|
71
|
-
entryPath?: string;
|
|
72
|
-
/**
|
|
73
|
-
* Path to app entry output file
|
|
74
|
-
* @default 'app.js'
|
|
75
|
-
*/
|
|
76
|
-
entryOutputPath?: string;
|
|
77
138
|
/**
|
|
78
139
|
* Path to asar file
|
|
79
|
-
* @default `release/${
|
|
140
|
+
* @default `release/${app.name}.asar`
|
|
80
141
|
*/
|
|
81
142
|
asarOutputPath?: string;
|
|
82
143
|
/**
|
|
@@ -86,7 +147,7 @@ type Options = {
|
|
|
86
147
|
versionPath?: string;
|
|
87
148
|
/**
|
|
88
149
|
* Path to gzipped asar file
|
|
89
|
-
* @default `release/${
|
|
150
|
+
* @default `release/${app.name}-${version}.asar.gz`
|
|
90
151
|
*/
|
|
91
152
|
gzipPath?: string;
|
|
92
153
|
/**
|
|
@@ -105,19 +166,23 @@ type Options = {
|
|
|
105
166
|
*/
|
|
106
167
|
keys?: {
|
|
107
168
|
/**
|
|
108
|
-
*
|
|
169
|
+
* path to the pem file that contains private key
|
|
109
170
|
* if not ended with .pem, it will be appended
|
|
171
|
+
*
|
|
172
|
+
* **if `UPDATER_PK` is set, will read it instead of read from `privateKeyPath`**
|
|
110
173
|
* @default 'keys/private.pem'
|
|
111
174
|
*/
|
|
112
175
|
privateKeyPath?: string;
|
|
113
176
|
/**
|
|
114
|
-
*
|
|
177
|
+
* path to the pem file that contains public key
|
|
115
178
|
* if not ended with .pem, it will be appended
|
|
179
|
+
*
|
|
180
|
+
* **if `UPDATER_CERT` is set, will read it instead of read from `certPath`**
|
|
116
181
|
* @default 'keys/cert.pem'
|
|
117
182
|
*/
|
|
118
183
|
certPath?: string;
|
|
119
184
|
/**
|
|
120
|
-
*
|
|
185
|
+
* length of the key
|
|
121
186
|
* @default 2048
|
|
122
187
|
*/
|
|
123
188
|
keyLength?: number;
|
|
@@ -130,20 +195,122 @@ type Options = {
|
|
|
130
195
|
/**
|
|
131
196
|
* the subject of the certificate
|
|
132
197
|
*
|
|
133
|
-
* @default { commonName:
|
|
198
|
+
* @default { commonName: `${app.name}`, organizationName: `org.${app.name}` }
|
|
134
199
|
*/
|
|
135
200
|
subject?: DistinguishedName;
|
|
136
201
|
/**
|
|
137
202
|
* expire days of the certificate
|
|
138
203
|
*
|
|
139
|
-
* @default
|
|
204
|
+
* @default 3650
|
|
140
205
|
*/
|
|
141
206
|
days?: number;
|
|
142
207
|
};
|
|
143
|
-
|
|
208
|
+
overrideGenerator?: GeneratorOverrideFunctions;
|
|
144
209
|
};
|
|
145
210
|
};
|
|
146
211
|
|
|
147
|
-
|
|
212
|
+
type MakeRequired<T, K extends keyof T> = Exclude<T, undefined> & {
|
|
213
|
+
[P in K]-?: T[P];
|
|
214
|
+
};
|
|
215
|
+
type ReplaceKey<T, Key extends keyof T, NewKey extends string> = Omit<T, Key> & {
|
|
216
|
+
[P in NewKey]: T[Key];
|
|
217
|
+
};
|
|
218
|
+
type MakeRequiredAndReplaceKey<T, K extends keyof T, NewKey extends string> = MakeRequired<ReplaceKey<T, K, NewKey>, NewKey>;
|
|
219
|
+
/**
|
|
220
|
+
* startup function for debug (see {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template})
|
|
221
|
+
* @example
|
|
222
|
+
* import { debugStartup, buildElectronPluginOptions } from 'electron-incremental-update/vite'
|
|
223
|
+
* const options = buildElectronPluginOptions({
|
|
224
|
+
* // ...
|
|
225
|
+
* main: {
|
|
226
|
+
* // ...
|
|
227
|
+
* startup: debugStartup
|
|
228
|
+
* },
|
|
229
|
+
* })
|
|
230
|
+
*/
|
|
231
|
+
declare function debugStartup(args: {
|
|
232
|
+
startup: (argv?: string[]) => Promise<void>;
|
|
233
|
+
reload: () => void;
|
|
234
|
+
}): void;
|
|
235
|
+
type ElectronWithUpdaterOptions = {
|
|
236
|
+
/**
|
|
237
|
+
* whether is in build mode
|
|
238
|
+
* ```ts
|
|
239
|
+
* export default defineConfig(({ command }) => {
|
|
240
|
+
* const isBuild = command === 'build'
|
|
241
|
+
* })
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
isBuild: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* name, version and main in `package.json`
|
|
247
|
+
* ```ts
|
|
248
|
+
* import pkg from './package.json'
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
pkg: PKG;
|
|
252
|
+
/**
|
|
253
|
+
* main options
|
|
254
|
+
*/
|
|
255
|
+
main: Prettify<MakeRequiredAndReplaceKey<ElectronSimpleOptions['main'], 'entry', 'files'>>;
|
|
256
|
+
/**
|
|
257
|
+
* preload options
|
|
258
|
+
*/
|
|
259
|
+
preload: Prettify<MakeRequiredAndReplaceKey<Exclude<ElectronSimpleOptions['preload'], undefined>, 'input', 'files'>>;
|
|
260
|
+
/**
|
|
261
|
+
* updater options
|
|
262
|
+
*/
|
|
263
|
+
updater?: ElectronUpdaterOptions;
|
|
264
|
+
/**
|
|
265
|
+
* use NotBundle() plugin in main
|
|
266
|
+
* @default true
|
|
267
|
+
*/
|
|
268
|
+
useNotBundle?: boolean;
|
|
269
|
+
/**
|
|
270
|
+
* Whether to log parsed options
|
|
271
|
+
*/
|
|
272
|
+
logParsedOptions?: boolean;
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* build options for `vite-plugin-electron/simple`
|
|
276
|
+
* - integrate with updater
|
|
277
|
+
* - only contains `main` and `preload` configs
|
|
278
|
+
* - remove old electron files
|
|
279
|
+
* - externalize dependencies
|
|
280
|
+
* - auto restart when entry file changes
|
|
281
|
+
* - other configs in {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template}
|
|
282
|
+
* - no `vite-plugin-electron-renderer` config
|
|
283
|
+
*
|
|
284
|
+
* you can override all the configs
|
|
285
|
+
*
|
|
286
|
+
* **Limitation**: entry file change cannot trigger auto restart
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* import { defineConfig } from 'vite'
|
|
290
|
+
* import electronSimple from 'vite-plugin-electron/simple'
|
|
291
|
+
* import { buildElectronPluginOptions } from 'electron-incremental-update/vite'
|
|
292
|
+
* import pkg from './package.json'
|
|
293
|
+
*
|
|
294
|
+
* export default defineConfig(({ command }) => {
|
|
295
|
+
* const electronOptions = buildElectronPluginOptions({
|
|
296
|
+
* isBuild: command === 'build',
|
|
297
|
+
* pkg,
|
|
298
|
+
* main: {
|
|
299
|
+
* files: ['./electron/main/index.ts', './electron/main/worker.ts'],
|
|
300
|
+
* },
|
|
301
|
+
* preload: {
|
|
302
|
+
* files: './electron/preload/index.ts',
|
|
303
|
+
* },
|
|
304
|
+
* })
|
|
305
|
+
* return {
|
|
306
|
+
* plugins: [electronSimple(electronOptions)],
|
|
307
|
+
* server: process.env.VSCODE_DEBUG && (() => {
|
|
308
|
+
* const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
|
|
309
|
+
* return { host: url.hostname, port: +url.port }
|
|
310
|
+
* })()
|
|
311
|
+
* }
|
|
312
|
+
* })
|
|
313
|
+
*/
|
|
314
|
+
declare function electronWithUpdater(options: ElectronWithUpdaterOptions): (Plugin<any> | Promise<Plugin<any>[]> | undefined)[];
|
|
148
315
|
|
|
149
|
-
export {
|
|
316
|
+
export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater };
|