electron-incremental-update 1.3.0 → 2.0.0-beta.10
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 +7 -3
- package/dist/chunk-4MH6ZXCY.js +81 -0
- package/dist/chunk-72ZAJ7AF.js +70 -0
- package/dist/chunk-KZSYEXLO.js +55 -0
- package/dist/index.cjs +173 -386
- package/dist/index.d.cts +84 -213
- package/dist/index.d.ts +84 -213
- package/dist/index.js +142 -282
- package/dist/provider.cjs +232 -0
- package/dist/provider.d.cts +109 -0
- package/dist/provider.d.ts +109 -0
- package/dist/provider.js +139 -0
- package/dist/types-Bnc4jz6R.d.ts +78 -0
- package/dist/types-DEYw5VrL.d.cts +78 -0
- package/dist/utils.cjs +175 -208
- package/dist/utils.d.cts +47 -87
- package/dist/utils.d.ts +47 -87
- package/dist/utils.js +3 -38
- package/dist/version-C4tF_trh.d.cts +62 -0
- package/dist/version-C4tF_trh.d.ts +62 -0
- package/dist/vite.d.ts +93 -95
- package/dist/vite.js +342 -350
- package/dist/zip-rm9ED9nU.d.cts +33 -0
- package/dist/zip-rm9ED9nU.d.ts +33 -0
- package/package.json +28 -16
- package/provider.d.ts +1 -0
- package/provider.js +1 -0
- package/dist/chunk-7ET4GMTZ.js +0 -236
- package/dist/chunk-CXHA5TF7.js +0 -236
- package/dist/chunk-HWUYTDEF.js +0 -236
- package/dist/chunk-RQCTJY4L.js +0 -236
- package/dist/chunk-SBPTSLG7.js +0 -235
- package/dist/pure-GoN_3MEj.d.cts +0 -31
- package/dist/pure-GoN_3MEj.d.ts +0 -31
package/dist/vite.d.ts
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluginOption } from 'vite';
|
|
2
2
|
import { ElectronSimpleOptions } from 'vite-plugin-electron/simple';
|
|
3
3
|
import { Promisable } from '@subframe7536/type-utils';
|
|
4
4
|
import { BuildOptions } from 'esbuild';
|
|
5
|
+
export { isCI } from 'ci-info';
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Update info json
|
|
9
|
+
*/
|
|
6
10
|
type UpdateInfo = {
|
|
7
11
|
signature: string;
|
|
8
12
|
minimumVersion: string;
|
|
9
13
|
version: string;
|
|
10
|
-
size: number;
|
|
11
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* {@link UpdateInfo} with beta
|
|
17
|
+
*/
|
|
12
18
|
type UpdateJSON = UpdateInfo & {
|
|
13
19
|
beta: UpdateInfo;
|
|
14
20
|
};
|
|
15
21
|
|
|
16
|
-
|
|
22
|
+
interface PKG {
|
|
17
23
|
name: string;
|
|
18
24
|
version: string;
|
|
19
25
|
main: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
26
|
+
}
|
|
27
|
+
interface DistinguishedName {
|
|
22
28
|
countryName?: string;
|
|
23
29
|
stateOrProvinceName?: string;
|
|
24
30
|
localityName?: string;
|
|
@@ -30,30 +36,29 @@ type DistinguishedName = {
|
|
|
30
36
|
description?: string;
|
|
31
37
|
businessCategory?: string;
|
|
32
38
|
emailAddress?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
39
|
+
}
|
|
40
|
+
interface BuildEntryOption {
|
|
35
41
|
/**
|
|
36
|
-
*
|
|
42
|
+
* Override to minify on entry
|
|
37
43
|
* @default isBuild
|
|
38
44
|
*/
|
|
39
45
|
minify?: boolean;
|
|
40
46
|
/**
|
|
41
|
-
*
|
|
42
|
-
* @default isBuild
|
|
47
|
+
* Override to generate sourcemap on entry
|
|
43
48
|
*/
|
|
44
49
|
sourcemap?: boolean;
|
|
45
50
|
/**
|
|
46
|
-
*
|
|
51
|
+
* Path to app entry output file
|
|
47
52
|
* @default 'dist-entry'
|
|
48
53
|
*/
|
|
49
54
|
entryOutputDirPath?: string;
|
|
50
55
|
/**
|
|
51
|
-
*
|
|
56
|
+
* Path to app entry file
|
|
52
57
|
* @default 'electron/entry.ts'
|
|
53
58
|
*/
|
|
54
59
|
appEntryPath?: string;
|
|
55
60
|
/**
|
|
56
|
-
*
|
|
61
|
+
* Esbuild path map of native modules in entry directory
|
|
57
62
|
*
|
|
58
63
|
* @default {}
|
|
59
64
|
* @example
|
|
@@ -61,7 +66,7 @@ type BuildEntryOption = {
|
|
|
61
66
|
*/
|
|
62
67
|
nativeModuleEntryMap?: Record<string, string>;
|
|
63
68
|
/**
|
|
64
|
-
*
|
|
69
|
+
* Custom options for esbuild
|
|
65
70
|
* ```ts
|
|
66
71
|
* // default options
|
|
67
72
|
* const options = {
|
|
@@ -88,43 +93,43 @@ type BuildEntryOption = {
|
|
|
88
93
|
*/
|
|
89
94
|
overrideEsbuildOptions?: BuildOptions;
|
|
90
95
|
/**
|
|
91
|
-
*
|
|
96
|
+
* Resolve extra files on startup, such as `.node`
|
|
92
97
|
* @remark won't trigger will reload
|
|
93
98
|
*/
|
|
94
99
|
postBuild?: (args: {
|
|
95
100
|
/**
|
|
96
|
-
*
|
|
101
|
+
* Get path from `entryOutputDirPath`
|
|
97
102
|
*/
|
|
98
103
|
getPathFromEntryOutputDir: (...paths: string[]) => string;
|
|
99
104
|
/**
|
|
100
|
-
*
|
|
105
|
+
* Check exist and copy file to `entryOutputDirPath`
|
|
101
106
|
*
|
|
102
|
-
*
|
|
107
|
+
* If `to` absent, set to `basename(from)`
|
|
103
108
|
*
|
|
104
|
-
*
|
|
109
|
+
* If `skipIfExist` absent, skip copy if `to` exist
|
|
105
110
|
*/
|
|
106
111
|
copyToEntryOutputDir: (options: {
|
|
107
112
|
from: string;
|
|
108
113
|
to?: string;
|
|
109
114
|
/**
|
|
110
|
-
*
|
|
115
|
+
* Skip copy if `to` exist
|
|
111
116
|
* @default true
|
|
112
117
|
*/
|
|
113
118
|
skipIfExist?: boolean;
|
|
114
119
|
}) => void;
|
|
115
120
|
}) => Promisable<void>;
|
|
116
|
-
}
|
|
117
|
-
|
|
121
|
+
}
|
|
122
|
+
interface GeneratorOverrideFunctions {
|
|
118
123
|
/**
|
|
119
|
-
*
|
|
124
|
+
* Custom signature generate function
|
|
120
125
|
* @param buffer file buffer
|
|
121
126
|
* @param privateKey private key
|
|
122
127
|
* @param cert certificate string, **EOL must be '\n'**
|
|
123
128
|
* @param version current version
|
|
124
129
|
*/
|
|
125
|
-
generateSignature?: (buffer: Buffer, privateKey: string, cert: string, version: string) =>
|
|
130
|
+
generateSignature?: (buffer: Buffer, privateKey: string, cert: string, version: string) => Promisable<string>;
|
|
126
131
|
/**
|
|
127
|
-
*
|
|
132
|
+
* Custom generate version json function
|
|
128
133
|
* @param existingJson The existing JSON object.
|
|
129
134
|
* @param buffer file buffer
|
|
130
135
|
* @param signature generated signature
|
|
@@ -132,9 +137,14 @@ type GeneratorOverrideFunctions = {
|
|
|
132
137
|
* @param minVersion The minimum version
|
|
133
138
|
* @returns The updated version json
|
|
134
139
|
*/
|
|
135
|
-
generateVersionJson?: (existingJson: UpdateJSON,
|
|
136
|
-
|
|
137
|
-
|
|
140
|
+
generateVersionJson?: (existingJson: UpdateJSON, signature: string, version: string, minVersion: string) => Promisable<UpdateJSON>;
|
|
141
|
+
/**
|
|
142
|
+
* Custom generate zip file buffer
|
|
143
|
+
* @param buffer source buffer
|
|
144
|
+
*/
|
|
145
|
+
generateGzipFile?: (buffer: Buffer) => Promisable<Buffer>;
|
|
146
|
+
}
|
|
147
|
+
interface ElectronUpdaterOptions {
|
|
138
148
|
/**
|
|
139
149
|
* mini version of entry
|
|
140
150
|
* @default '0.0.0'
|
|
@@ -218,20 +228,23 @@ type ElectronUpdaterOptions = {
|
|
|
218
228
|
*/
|
|
219
229
|
days?: number;
|
|
220
230
|
};
|
|
221
|
-
overrideGenerator?: GeneratorOverrideFunctions;
|
|
222
231
|
};
|
|
223
|
-
|
|
232
|
+
overrideGenerator?: GeneratorOverrideFunctions;
|
|
233
|
+
}
|
|
224
234
|
|
|
225
|
-
|
|
235
|
+
interface BytecodeOptions {
|
|
236
|
+
enable: boolean;
|
|
226
237
|
/**
|
|
227
|
-
*
|
|
238
|
+
* Enable in preload script. Remember to set `sandbox: false` when creating window
|
|
228
239
|
*/
|
|
229
|
-
|
|
240
|
+
preload?: boolean;
|
|
230
241
|
/**
|
|
231
|
-
*
|
|
242
|
+
* Before transformed code compile function. If return `Falsy` value, it will be ignored
|
|
243
|
+
* @param code transformed code
|
|
244
|
+
* @param id file path
|
|
232
245
|
*/
|
|
233
|
-
|
|
234
|
-
}
|
|
246
|
+
beforeCompile?: (code: string, id: string) => Promisable<string | null | undefined | void>;
|
|
247
|
+
}
|
|
235
248
|
|
|
236
249
|
type MakeRequired<T, K extends keyof T> = Exclude<T, undefined> & {
|
|
237
250
|
[P in K]-?: T[P];
|
|
@@ -256,9 +269,21 @@ declare function debugStartup(args: {
|
|
|
256
269
|
startup: (argv?: string[]) => Promise<void>;
|
|
257
270
|
reload: () => void;
|
|
258
271
|
}): void;
|
|
259
|
-
type
|
|
272
|
+
type ExcludeOutputDirOptions = {
|
|
273
|
+
vite?: {
|
|
274
|
+
build?: {
|
|
275
|
+
outDir: never;
|
|
276
|
+
rollupOptions?: {
|
|
277
|
+
output?: {
|
|
278
|
+
dir: never;
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
interface ElectronWithUpdaterOptions {
|
|
260
285
|
/**
|
|
261
|
-
*
|
|
286
|
+
* Whether is in build mode
|
|
262
287
|
* ```ts
|
|
263
288
|
* export default defineConfig(({ command }) => {
|
|
264
289
|
* const isBuild = command === 'build'
|
|
@@ -267,106 +292,79 @@ type ElectronWithUpdaterOptions = {
|
|
|
267
292
|
*/
|
|
268
293
|
isBuild: boolean;
|
|
269
294
|
/**
|
|
270
|
-
*
|
|
295
|
+
* Manually setup package.json, read name, version and main,
|
|
296
|
+
* use `local-pkg` of `loadPackageJSON()` to load package.json by default
|
|
271
297
|
* ```ts
|
|
272
298
|
* import pkg from './package.json'
|
|
273
299
|
* ```
|
|
274
300
|
*/
|
|
275
301
|
pkg?: PKG;
|
|
276
302
|
/**
|
|
277
|
-
*
|
|
303
|
+
* Whether to generate sourcemap
|
|
278
304
|
* @default !isBuild
|
|
279
305
|
*/
|
|
280
306
|
sourcemap?: boolean;
|
|
281
307
|
/**
|
|
282
|
-
*
|
|
308
|
+
* Whether to minify the code
|
|
283
309
|
* @default isBuild
|
|
284
310
|
*/
|
|
285
311
|
minify?: boolean;
|
|
286
312
|
/**
|
|
287
|
-
*
|
|
313
|
+
* Whether to generate bytecode
|
|
288
314
|
*
|
|
289
|
-
* **
|
|
315
|
+
* **Only support CommonJS**
|
|
290
316
|
*
|
|
291
|
-
*
|
|
317
|
+
* 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
|
|
292
318
|
*/
|
|
293
319
|
bytecode?: boolean | BytecodeOptions;
|
|
294
320
|
/**
|
|
295
|
-
*
|
|
321
|
+
* Use `NotBundle()` plugin in main
|
|
296
322
|
* @default true
|
|
297
323
|
*/
|
|
298
324
|
useNotBundle?: boolean;
|
|
325
|
+
/**
|
|
326
|
+
* Whether to generate version json
|
|
327
|
+
* @default isCI
|
|
328
|
+
*/
|
|
329
|
+
buildVersionJson?: boolean;
|
|
299
330
|
/**
|
|
300
331
|
* Whether to log parsed options
|
|
301
332
|
*
|
|
302
|
-
*
|
|
333
|
+
* To show certificate and private keys, set `logParsedOptions: { showKeys: true }`
|
|
303
334
|
*/
|
|
304
335
|
logParsedOptions?: boolean | {
|
|
305
336
|
showKeys: boolean;
|
|
306
337
|
};
|
|
307
338
|
/**
|
|
308
|
-
*
|
|
339
|
+
* Main process options
|
|
340
|
+
*
|
|
341
|
+
* To change output directories, use `options.updater.paths.electronDistPath` instead
|
|
309
342
|
*/
|
|
310
|
-
main: MakeRequiredAndReplaceKey<ElectronSimpleOptions['main'], 'entry', 'files'
|
|
343
|
+
main: MakeRequiredAndReplaceKey<ElectronSimpleOptions['main'], 'entry', 'files'> & ExcludeOutputDirOptions;
|
|
311
344
|
/**
|
|
312
|
-
*
|
|
345
|
+
* Preload process options
|
|
346
|
+
*
|
|
347
|
+
* To change output directories, use `options.updater.paths.electronDistPath` instead
|
|
313
348
|
*/
|
|
314
|
-
preload: MakeRequiredAndReplaceKey<Exclude<ElectronSimpleOptions['preload'], undefined>, 'input', 'files'
|
|
349
|
+
preload: MakeRequiredAndReplaceKey<Exclude<ElectronSimpleOptions['preload'], undefined>, 'input', 'files'> & ExcludeOutputDirOptions;
|
|
315
350
|
/**
|
|
316
|
-
*
|
|
351
|
+
* Updater options
|
|
317
352
|
*/
|
|
318
353
|
updater?: ElectronUpdaterOptions;
|
|
319
|
-
}
|
|
354
|
+
}
|
|
320
355
|
/**
|
|
321
|
-
*
|
|
356
|
+
* Base on `vite-plugin-electron/simple`
|
|
322
357
|
* - integrate with updater
|
|
323
|
-
* -
|
|
324
|
-
* - remove old
|
|
358
|
+
* - no `renderer` config
|
|
359
|
+
* - remove old output file
|
|
325
360
|
* - externalize dependencies
|
|
326
361
|
* - auto restart when entry file changes
|
|
327
362
|
* - other configs in {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template}
|
|
328
|
-
* - no `vite-plugin-electron-renderer` config
|
|
329
363
|
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
* **Limitation**: entry file change cannot trigger auto restart
|
|
364
|
+
* You can override all the vite configs, except output directories (use `options.updater.paths.electronDistPath` instead)
|
|
333
365
|
*
|
|
334
366
|
* @example
|
|
335
|
-
* import { defineConfig } from 'vite'
|
|
336
|
-
* import { debugStartup, electronWithUpdater } from 'electron-incremental-update/vite'
|
|
337
|
-
* import pkg from './package.json'
|
|
338
|
-
*
|
|
339
|
-
* export default defineConfig(async ({ command }) => {
|
|
340
|
-
* const isBuild = command === 'build'
|
|
341
|
-
* return {
|
|
342
|
-
* plugins: [
|
|
343
|
-
* electronWithUpdater({
|
|
344
|
-
* pkg,
|
|
345
|
-
* isBuild,
|
|
346
|
-
* logParsedOptions: true,
|
|
347
|
-
* main: {
|
|
348
|
-
* files: ['./electron/main/index.ts', './electron/main/worker.ts'],
|
|
349
|
-
* // see https://github.com/electron-vite/electron-vite-vue/blob/85ed267c4851bf59f32888d766c0071661d4b94c/vite.config.ts#L22-L28
|
|
350
|
-
* onstart: debugStartup,
|
|
351
|
-
* },
|
|
352
|
-
* preload: {
|
|
353
|
-
* files: './electron/preload/index.ts',
|
|
354
|
-
* },
|
|
355
|
-
* updater: {
|
|
356
|
-
* // options
|
|
357
|
-
* }
|
|
358
|
-
* }),
|
|
359
|
-
* ],
|
|
360
|
-
* server: process.env.VSCODE_DEBUG && (() => {
|
|
361
|
-
* const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
|
|
362
|
-
* return {
|
|
363
|
-
* host: url.hostname,
|
|
364
|
-
* port: +url.port,
|
|
365
|
-
* }
|
|
366
|
-
* })(),
|
|
367
|
-
* }
|
|
368
|
-
* })
|
|
369
367
|
*/
|
|
370
|
-
declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<
|
|
368
|
+
declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<PluginOption[] | undefined>;
|
|
371
369
|
|
|
372
|
-
export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater };
|
|
370
|
+
export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater as default, electronWithUpdater };
|