electron-incremental-update 2.0.0-beta.8 → 2.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 +307 -198
- package/dist/chunk-IABBXJFB.js +87 -0
- package/dist/{chunk-72ZAJ7AF.js → chunk-RCRKUKFX.js} +1 -1
- package/dist/index.cjs +110 -104
- package/dist/index.d.cts +139 -34
- package/dist/index.d.ts +139 -34
- package/dist/index.js +105 -102
- package/dist/provider.cjs +85 -54
- package/dist/provider.d.cts +62 -29
- package/dist/provider.d.ts +62 -29
- package/dist/provider.js +85 -55
- package/dist/types-BLdN9rkY.d.ts +72 -0
- package/dist/types-DkCn03M3.d.cts +72 -0
- package/dist/utils.cjs +25 -25
- package/dist/utils.d.cts +37 -24
- package/dist/utils.d.ts +37 -24
- package/dist/utils.js +2 -11
- package/dist/version-BYVQ367i.d.cts +62 -0
- package/dist/version-BYVQ367i.d.ts +62 -0
- package/dist/vite.d.ts +58 -94
- package/dist/vite.js +67 -55
- package/dist/{zip-DPF5IFkK.d.cts → zip-rm9ED9nU.d.cts} +23 -0
- package/dist/{zip-DPF5IFkK.d.ts → zip-rm9ED9nU.d.ts} +23 -0
- package/package.json +10 -7
- package/dist/chunk-4MH6ZXCY.js +0 -81
- package/dist/core-DJdvtwvU.d.ts +0 -134
- package/dist/core-ZUlLHadf.d.cts +0 -134
- package/dist/types-CItP6bL-.d.cts +0 -104
- package/dist/types-CItP6bL-.d.ts +0 -104
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,15 @@ 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
|
+
* Before transformed code compile function. If return `Falsy` value, it will be ignored
|
|
244
242
|
* @param code transformed code
|
|
245
243
|
* @param id file path
|
|
246
244
|
*/
|
|
247
|
-
beforeCompile?: (code: string, id: string) => Promisable<string | null | undefined>;
|
|
245
|
+
beforeCompile?: (code: string, id: string) => Promisable<string | null | undefined | void>;
|
|
248
246
|
}
|
|
249
247
|
|
|
250
248
|
type MakeRequired<T, K extends keyof T> = Exclude<T, undefined> & {
|
|
@@ -284,7 +282,7 @@ type ExcludeOutputDirOptions = {
|
|
|
284
282
|
};
|
|
285
283
|
interface ElectronWithUpdaterOptions {
|
|
286
284
|
/**
|
|
287
|
-
*
|
|
285
|
+
* Whether is in build mode
|
|
288
286
|
* ```ts
|
|
289
287
|
* export default defineConfig(({ command }) => {
|
|
290
288
|
* const isBuild = command === 'build'
|
|
@@ -293,113 +291,79 @@ interface ElectronWithUpdaterOptions {
|
|
|
293
291
|
*/
|
|
294
292
|
isBuild: boolean;
|
|
295
293
|
/**
|
|
296
|
-
*
|
|
294
|
+
* Manually setup package.json, read name, version and main,
|
|
295
|
+
* use `local-pkg` of `loadPackageJSON()` to load package.json by default
|
|
297
296
|
* ```ts
|
|
298
297
|
* import pkg from './package.json'
|
|
299
298
|
* ```
|
|
300
299
|
*/
|
|
301
300
|
pkg?: PKG;
|
|
302
301
|
/**
|
|
303
|
-
*
|
|
302
|
+
* Whether to generate sourcemap
|
|
304
303
|
* @default !isBuild
|
|
305
304
|
*/
|
|
306
305
|
sourcemap?: boolean;
|
|
307
306
|
/**
|
|
308
|
-
*
|
|
307
|
+
* Whether to minify the code
|
|
309
308
|
* @default isBuild
|
|
310
309
|
*/
|
|
311
310
|
minify?: boolean;
|
|
312
311
|
/**
|
|
313
|
-
*
|
|
312
|
+
* Whether to generate bytecode
|
|
314
313
|
*
|
|
315
|
-
* **
|
|
314
|
+
* **Only support CommonJS**
|
|
316
315
|
*
|
|
317
|
-
*
|
|
316
|
+
* 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
317
|
*/
|
|
319
318
|
bytecode?: boolean | BytecodeOptions;
|
|
320
319
|
/**
|
|
321
|
-
*
|
|
320
|
+
* Use `NotBundle()` plugin in main
|
|
322
321
|
* @default true
|
|
323
322
|
*/
|
|
324
323
|
useNotBundle?: boolean;
|
|
325
324
|
/**
|
|
326
|
-
*
|
|
325
|
+
* Whether to generate version json
|
|
327
326
|
* @default isCI
|
|
328
327
|
*/
|
|
329
328
|
buildVersionJson?: boolean;
|
|
330
329
|
/**
|
|
331
330
|
* Whether to log parsed options
|
|
332
331
|
*
|
|
333
|
-
*
|
|
332
|
+
* To show certificate and private keys, set `logParsedOptions: { showKeys: true }`
|
|
334
333
|
*/
|
|
335
334
|
logParsedOptions?: boolean | {
|
|
336
335
|
showKeys: boolean;
|
|
337
336
|
};
|
|
338
337
|
/**
|
|
339
|
-
*
|
|
338
|
+
* Main process options
|
|
340
339
|
*
|
|
341
|
-
*
|
|
340
|
+
* To change output directories, use `options.updater.paths.electronDistPath` instead
|
|
342
341
|
*/
|
|
343
342
|
main: MakeRequiredAndReplaceKey<ElectronSimpleOptions['main'], 'entry', 'files'> & ExcludeOutputDirOptions;
|
|
344
343
|
/**
|
|
345
|
-
*
|
|
344
|
+
* Preload process options
|
|
346
345
|
*
|
|
347
|
-
*
|
|
346
|
+
* To change output directories, use `options.updater.paths.electronDistPath` instead
|
|
348
347
|
*/
|
|
349
348
|
preload: MakeRequiredAndReplaceKey<Exclude<ElectronSimpleOptions['preload'], undefined>, 'input', 'files'> & ExcludeOutputDirOptions;
|
|
350
349
|
/**
|
|
351
|
-
*
|
|
350
|
+
* Updater options
|
|
352
351
|
*/
|
|
353
352
|
updater?: ElectronUpdaterOptions;
|
|
354
353
|
}
|
|
355
354
|
/**
|
|
356
|
-
*
|
|
355
|
+
* Base on `vite-plugin-electron/simple`
|
|
357
356
|
* - integrate with updater
|
|
358
|
-
* -
|
|
359
|
-
* - remove old
|
|
357
|
+
* - no `renderer` config
|
|
358
|
+
* - remove old output file
|
|
360
359
|
* - externalize dependencies
|
|
361
360
|
* - auto restart when entry file changes
|
|
362
361
|
* - 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
362
|
*
|
|
365
|
-
*
|
|
363
|
+
* You can override all the vite configs, except output directories (use `options.updater.paths.electronDistPath` instead)
|
|
366
364
|
*
|
|
367
365
|
* @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
366
|
*/
|
|
403
367
|
declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<PluginOption[] | undefined>;
|
|
404
368
|
|
|
405
|
-
export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater };
|
|
369
|
+
export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater as default, electronWithUpdater };
|