electron-incremental-update 2.0.0-beta.9 → 2.0.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 +326 -198
- package/dist/chunk-GTDMND3I.js +87 -0
- package/dist/{chunk-72ZAJ7AF.js → chunk-RCRKUKFX.js} +1 -1
- package/dist/index.cjs +91 -71
- package/dist/index.d.cts +64 -80
- package/dist/index.d.ts +64 -80
- package/dist/index.js +88 -70
- package/dist/provider.cjs +72 -52
- package/dist/provider.d.cts +47 -30
- package/dist/provider.d.ts +47 -30
- package/dist/provider.js +72 -53
- package/dist/{types-D7OK98ln.d.ts → types-BLdN9rkY.d.ts} +20 -27
- package/dist/{types-mEfMjnlV.d.cts → types-DkCn03M3.d.cts} +20 -27
- package/dist/utils.cjs +25 -17
- package/dist/utils.d.cts +37 -16
- package/dist/utils.d.ts +37 -16
- package/dist/utils.js +2 -2
- package/dist/version-BYVQ367i.d.cts +62 -0
- package/dist/version-BYVQ367i.d.ts +62 -0
- package/dist/vite.d.ts +62 -94
- package/dist/vite.js +61 -43
- package/dist/{zip-DPF5IFkK.d.ts → zip-rm9ED9nU.d.cts} +23 -0
- package/dist/{zip-DPF5IFkK.d.cts → zip-rm9ED9nU.d.ts} +23 -0
- package/package.json +10 -7
- package/dist/chunk-4MH6ZXCY.js +0 -81
- package/dist/version-DgfjJQUx.d.cts +0 -27
- package/dist/version-DgfjJQUx.d.ts +0 -27
package/dist/vite.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { BuildOptions } from 'esbuild';
|
|
|
5
5
|
export { isCI } from 'ci-info';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Update info json
|
|
9
9
|
*/
|
|
10
10
|
type UpdateInfo = {
|
|
11
11
|
signature: string;
|
|
@@ -23,6 +23,7 @@ interface PKG {
|
|
|
23
23
|
name: string;
|
|
24
24
|
version: string;
|
|
25
25
|
main: string;
|
|
26
|
+
type: 'commonjs' | 'module';
|
|
26
27
|
}
|
|
27
28
|
interface DistinguishedName {
|
|
28
29
|
countryName?: string;
|
|
@@ -39,27 +40,26 @@ interface DistinguishedName {
|
|
|
39
40
|
}
|
|
40
41
|
interface BuildEntryOption {
|
|
41
42
|
/**
|
|
42
|
-
*
|
|
43
|
+
* Override to minify on entry
|
|
43
44
|
* @default isBuild
|
|
44
45
|
*/
|
|
45
46
|
minify?: boolean;
|
|
46
47
|
/**
|
|
47
|
-
*
|
|
48
|
-
* @default isBuild
|
|
48
|
+
* Override to generate sourcemap on entry
|
|
49
49
|
*/
|
|
50
50
|
sourcemap?: boolean;
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* Path to app entry output file
|
|
53
53
|
* @default 'dist-entry'
|
|
54
54
|
*/
|
|
55
55
|
entryOutputDirPath?: string;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* Path to app entry file
|
|
58
58
|
* @default 'electron/entry.ts'
|
|
59
59
|
*/
|
|
60
60
|
appEntryPath?: string;
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* Esbuild path map of native modules in entry directory
|
|
63
63
|
*
|
|
64
64
|
* @default {}
|
|
65
65
|
* @example
|
|
@@ -67,7 +67,7 @@ interface BuildEntryOption {
|
|
|
67
67
|
*/
|
|
68
68
|
nativeModuleEntryMap?: Record<string, string>;
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
70
|
+
* Custom options for esbuild
|
|
71
71
|
* ```ts
|
|
72
72
|
* // default options
|
|
73
73
|
* const options = {
|
|
@@ -86,34 +86,32 @@ interface BuildEntryOption {
|
|
|
86
86
|
* loader: {
|
|
87
87
|
* '.node': 'empty',
|
|
88
88
|
* },
|
|
89
|
-
* define
|
|
90
|
-
* __SIGNATURE_CERT__: JSON.stringify(cert),
|
|
91
|
-
* },
|
|
89
|
+
* define,
|
|
92
90
|
* }
|
|
93
91
|
* ```
|
|
94
92
|
*/
|
|
95
93
|
overrideEsbuildOptions?: BuildOptions;
|
|
96
94
|
/**
|
|
97
|
-
*
|
|
95
|
+
* Resolve extra files on startup, such as `.node`
|
|
98
96
|
* @remark won't trigger will reload
|
|
99
97
|
*/
|
|
100
98
|
postBuild?: (args: {
|
|
101
99
|
/**
|
|
102
|
-
*
|
|
100
|
+
* Get path from `entryOutputDirPath`
|
|
103
101
|
*/
|
|
104
102
|
getPathFromEntryOutputDir: (...paths: string[]) => string;
|
|
105
103
|
/**
|
|
106
|
-
*
|
|
104
|
+
* Check exist and copy file to `entryOutputDirPath`
|
|
107
105
|
*
|
|
108
|
-
*
|
|
106
|
+
* If `to` absent, set to `basename(from)`
|
|
109
107
|
*
|
|
110
|
-
*
|
|
108
|
+
* If `skipIfExist` absent, skip copy if `to` exist
|
|
111
109
|
*/
|
|
112
110
|
copyToEntryOutputDir: (options: {
|
|
113
111
|
from: string;
|
|
114
112
|
to?: string;
|
|
115
113
|
/**
|
|
116
|
-
*
|
|
114
|
+
* Skip copy if `to` exist
|
|
117
115
|
* @default true
|
|
118
116
|
*/
|
|
119
117
|
skipIfExist?: boolean;
|
|
@@ -122,15 +120,15 @@ interface BuildEntryOption {
|
|
|
122
120
|
}
|
|
123
121
|
interface GeneratorOverrideFunctions {
|
|
124
122
|
/**
|
|
125
|
-
*
|
|
123
|
+
* Custom signature generate function
|
|
126
124
|
* @param buffer file buffer
|
|
127
125
|
* @param privateKey private key
|
|
128
126
|
* @param cert certificate string, **EOL must be '\n'**
|
|
129
127
|
* @param version current version
|
|
130
128
|
*/
|
|
131
|
-
generateSignature?: (buffer: Buffer, privateKey: string, cert: string, version: string) =>
|
|
129
|
+
generateSignature?: (buffer: Buffer, privateKey: string, cert: string, version: string) => Promisable<string>;
|
|
132
130
|
/**
|
|
133
|
-
*
|
|
131
|
+
* Custom generate version json function
|
|
134
132
|
* @param existingJson The existing JSON object.
|
|
135
133
|
* @param buffer file buffer
|
|
136
134
|
* @param signature generated signature
|
|
@@ -138,25 +136,25 @@ interface GeneratorOverrideFunctions {
|
|
|
138
136
|
* @param minVersion The minimum version
|
|
139
137
|
* @returns The updated version json
|
|
140
138
|
*/
|
|
141
|
-
generateVersionJson?: (existingJson: UpdateJSON, signature: string, version: string, minVersion: string) =>
|
|
139
|
+
generateVersionJson?: (existingJson: UpdateJSON, signature: string, version: string, minVersion: string) => Promisable<UpdateJSON>;
|
|
142
140
|
/**
|
|
143
|
-
*
|
|
141
|
+
* Custom generate zip file buffer
|
|
144
142
|
* @param buffer source buffer
|
|
145
143
|
*/
|
|
146
|
-
generateGzipFile?: (buffer: Buffer) =>
|
|
144
|
+
generateGzipFile?: (buffer: Buffer) => Promisable<Buffer>;
|
|
147
145
|
}
|
|
148
146
|
interface ElectronUpdaterOptions {
|
|
149
147
|
/**
|
|
150
|
-
*
|
|
148
|
+
* Minimum version of entry
|
|
151
149
|
* @default '0.0.0'
|
|
152
150
|
*/
|
|
153
151
|
minimumVersion?: string;
|
|
154
152
|
/**
|
|
155
|
-
*
|
|
153
|
+
* Options for entry (app.asar)
|
|
156
154
|
*/
|
|
157
155
|
entry?: BuildEntryOption;
|
|
158
156
|
/**
|
|
159
|
-
* paths
|
|
157
|
+
* Options for paths
|
|
160
158
|
*/
|
|
161
159
|
paths?: {
|
|
162
160
|
/**
|
|
@@ -190,40 +188,40 @@ interface ElectronUpdaterOptions {
|
|
|
190
188
|
*/
|
|
191
189
|
keys?: {
|
|
192
190
|
/**
|
|
193
|
-
*
|
|
194
|
-
*
|
|
191
|
+
* Path to the pem file that contains private key
|
|
192
|
+
* If not ended with .pem, it will be appended
|
|
195
193
|
*
|
|
196
|
-
* **
|
|
194
|
+
* **If `UPDATER_PK` is set, will read it instead of read from `privateKeyPath`**
|
|
197
195
|
* @default 'keys/private.pem'
|
|
198
196
|
*/
|
|
199
197
|
privateKeyPath?: string;
|
|
200
198
|
/**
|
|
201
|
-
*
|
|
202
|
-
*
|
|
199
|
+
* Path to the pem file that contains public key
|
|
200
|
+
* If not ended with .pem, it will be appended
|
|
203
201
|
*
|
|
204
|
-
* **
|
|
202
|
+
* **If `UPDATER_CERT` is set, will read it instead of read from `certPath`**
|
|
205
203
|
* @default 'keys/cert.pem'
|
|
206
204
|
*/
|
|
207
205
|
certPath?: string;
|
|
208
206
|
/**
|
|
209
|
-
*
|
|
207
|
+
* Length of the key
|
|
210
208
|
* @default 2048
|
|
211
209
|
*/
|
|
212
210
|
keyLength?: number;
|
|
213
211
|
/**
|
|
214
212
|
* X509 certificate info
|
|
215
213
|
*
|
|
216
|
-
*
|
|
214
|
+
* Only generate simple **self-signed** certificate **without extensions**
|
|
217
215
|
*/
|
|
218
216
|
certInfo?: {
|
|
219
217
|
/**
|
|
220
|
-
*
|
|
218
|
+
* The subject of the certificate
|
|
221
219
|
*
|
|
222
220
|
* @default { commonName: `${app.name}`, organizationName: `org.${app.name}` }
|
|
223
221
|
*/
|
|
224
222
|
subject?: DistinguishedName;
|
|
225
223
|
/**
|
|
226
|
-
*
|
|
224
|
+
* Expire days of the certificate
|
|
227
225
|
*
|
|
228
226
|
* @default 3650
|
|
229
227
|
*/
|
|
@@ -236,15 +234,19 @@ interface ElectronUpdaterOptions {
|
|
|
236
234
|
interface BytecodeOptions {
|
|
237
235
|
enable: boolean;
|
|
238
236
|
/**
|
|
239
|
-
* Remember to set `sandbox: false` when creating window
|
|
237
|
+
* Enable in preload script. Remember to set `sandbox: false` when creating window
|
|
240
238
|
*/
|
|
241
239
|
preload?: boolean;
|
|
242
240
|
/**
|
|
243
|
-
*
|
|
241
|
+
* Custom electron binary path
|
|
242
|
+
*/
|
|
243
|
+
electronPath?: string;
|
|
244
|
+
/**
|
|
245
|
+
* Before transformed code compile function. If return `Falsy` value, it will be ignored
|
|
244
246
|
* @param code transformed code
|
|
245
247
|
* @param id file path
|
|
246
248
|
*/
|
|
247
|
-
beforeCompile?: (code: string, id: string) => Promisable<string | null | undefined>;
|
|
249
|
+
beforeCompile?: (code: string, id: string) => Promisable<string | null | undefined | void>;
|
|
248
250
|
}
|
|
249
251
|
|
|
250
252
|
type MakeRequired<T, K extends keyof T> = Exclude<T, undefined> & {
|
|
@@ -284,7 +286,7 @@ type ExcludeOutputDirOptions = {
|
|
|
284
286
|
};
|
|
285
287
|
interface ElectronWithUpdaterOptions {
|
|
286
288
|
/**
|
|
287
|
-
*
|
|
289
|
+
* Whether is in build mode
|
|
288
290
|
* ```ts
|
|
289
291
|
* export default defineConfig(({ command }) => {
|
|
290
292
|
* const isBuild = command === 'build'
|
|
@@ -293,113 +295,79 @@ interface ElectronWithUpdaterOptions {
|
|
|
293
295
|
*/
|
|
294
296
|
isBuild: boolean;
|
|
295
297
|
/**
|
|
296
|
-
*
|
|
298
|
+
* Manually setup package.json, read name, version and main,
|
|
299
|
+
* use `local-pkg` of `loadPackageJSON()` to load package.json by default
|
|
297
300
|
* ```ts
|
|
298
301
|
* import pkg from './package.json'
|
|
299
302
|
* ```
|
|
300
303
|
*/
|
|
301
304
|
pkg?: PKG;
|
|
302
305
|
/**
|
|
303
|
-
*
|
|
306
|
+
* Whether to generate sourcemap
|
|
304
307
|
* @default !isBuild
|
|
305
308
|
*/
|
|
306
309
|
sourcemap?: boolean;
|
|
307
310
|
/**
|
|
308
|
-
*
|
|
311
|
+
* Whether to minify the code
|
|
309
312
|
* @default isBuild
|
|
310
313
|
*/
|
|
311
314
|
minify?: boolean;
|
|
312
315
|
/**
|
|
313
|
-
*
|
|
316
|
+
* Whether to generate bytecode
|
|
314
317
|
*
|
|
315
|
-
* **
|
|
318
|
+
* **Only support CommonJS**
|
|
316
319
|
*
|
|
317
|
-
*
|
|
320
|
+
* Only main process by default, if you want to use in preload script, please use `electronWithUpdater({ bytecode: { enablePreload: true } })` and set `sandbox: false` when creating window
|
|
318
321
|
*/
|
|
319
322
|
bytecode?: boolean | BytecodeOptions;
|
|
320
323
|
/**
|
|
321
|
-
*
|
|
324
|
+
* Use `NotBundle()` plugin in main
|
|
322
325
|
* @default true
|
|
323
326
|
*/
|
|
324
327
|
useNotBundle?: boolean;
|
|
325
328
|
/**
|
|
326
|
-
*
|
|
329
|
+
* Whether to generate version json
|
|
327
330
|
* @default isCI
|
|
328
331
|
*/
|
|
329
332
|
buildVersionJson?: boolean;
|
|
330
333
|
/**
|
|
331
334
|
* Whether to log parsed options
|
|
332
335
|
*
|
|
333
|
-
*
|
|
336
|
+
* To show certificate and private keys, set `logParsedOptions: { showKeys: true }`
|
|
334
337
|
*/
|
|
335
338
|
logParsedOptions?: boolean | {
|
|
336
339
|
showKeys: boolean;
|
|
337
340
|
};
|
|
338
341
|
/**
|
|
339
|
-
*
|
|
342
|
+
* Main process options
|
|
340
343
|
*
|
|
341
|
-
*
|
|
344
|
+
* To change output directories, use `options.updater.paths.electronDistPath` instead
|
|
342
345
|
*/
|
|
343
346
|
main: MakeRequiredAndReplaceKey<ElectronSimpleOptions['main'], 'entry', 'files'> & ExcludeOutputDirOptions;
|
|
344
347
|
/**
|
|
345
|
-
*
|
|
348
|
+
* Preload process options
|
|
346
349
|
*
|
|
347
|
-
*
|
|
350
|
+
* To change output directories, use `options.updater.paths.electronDistPath` instead
|
|
348
351
|
*/
|
|
349
352
|
preload: MakeRequiredAndReplaceKey<Exclude<ElectronSimpleOptions['preload'], undefined>, 'input', 'files'> & ExcludeOutputDirOptions;
|
|
350
353
|
/**
|
|
351
|
-
*
|
|
354
|
+
* Updater options
|
|
352
355
|
*/
|
|
353
356
|
updater?: ElectronUpdaterOptions;
|
|
354
357
|
}
|
|
355
358
|
/**
|
|
356
|
-
*
|
|
359
|
+
* Base on `vite-plugin-electron/simple`
|
|
357
360
|
* - integrate with updater
|
|
358
|
-
* -
|
|
359
|
-
* - remove old
|
|
361
|
+
* - no `renderer` config
|
|
362
|
+
* - remove old output file
|
|
360
363
|
* - externalize dependencies
|
|
361
364
|
* - auto restart when entry file changes
|
|
362
365
|
* - other configs in {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template}
|
|
363
|
-
* - no `vite-plugin-electron-renderer` config
|
|
364
366
|
*
|
|
365
|
-
*
|
|
367
|
+
* You can override all the vite configs, except output directories (use `options.updater.paths.electronDistPath` instead)
|
|
366
368
|
*
|
|
367
369
|
* @example
|
|
368
|
-
* import { defineConfig } from 'vite'
|
|
369
|
-
* import { debugStartup, electronWithUpdater } from 'electron-incremental-update/vite'
|
|
370
|
-
* import pkg from './package.json'
|
|
371
|
-
*
|
|
372
|
-
* export default defineConfig(async ({ command }) => {
|
|
373
|
-
* const isBuild = command === 'build'
|
|
374
|
-
* return {
|
|
375
|
-
* plugins: [
|
|
376
|
-
* electronWithUpdater({
|
|
377
|
-
* pkg,
|
|
378
|
-
* isBuild,
|
|
379
|
-
* logParsedOptions: true,
|
|
380
|
-
* main: {
|
|
381
|
-
* files: ['./electron/main/index.ts', './electron/main/worker.ts'],
|
|
382
|
-
* // see https://github.com/electron-vite/electron-vite-vue/blob/85ed267c4851bf59f32888d766c0071661d4b94c/vite.config.ts#L22-L28
|
|
383
|
-
* onstart: debugStartup,
|
|
384
|
-
* },
|
|
385
|
-
* preload: {
|
|
386
|
-
* files: './electron/preload/index.ts',
|
|
387
|
-
* },
|
|
388
|
-
* updater: {
|
|
389
|
-
* // options
|
|
390
|
-
* }
|
|
391
|
-
* }),
|
|
392
|
-
* ],
|
|
393
|
-
* server: process.env.VSCODE_DEBUG && (() => {
|
|
394
|
-
* const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
|
|
395
|
-
* return {
|
|
396
|
-
* host: url.hostname,
|
|
397
|
-
* port: +url.port,
|
|
398
|
-
* }
|
|
399
|
-
* })(),
|
|
400
|
-
* }
|
|
401
|
-
* })
|
|
402
370
|
*/
|
|
403
371
|
declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<PluginOption[] | undefined>;
|
|
404
372
|
|
|
405
|
-
export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater };
|
|
373
|
+
export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater as default, electronWithUpdater };
|