electron-incremental-update 3.0.0-beta.5 → 3.0.0-beta.6

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/dist/vite.d.mts CHANGED
@@ -1,50 +1,18 @@
1
- import { InlineConfig, LibraryOptions, PluginOption, UserConfig, UserConfigFn, build } from "vite";
2
- import { SpawnOptions } from "node:child_process";
1
+ import { Plugin, UserConfig } from "vite";
2
+ import { MultiEnvElectronOptions } from "vite-plugin-electron/multi-env";
3
+ import { RolldownOrRollupOptions } from "vite-plugin-electron";
3
4
 
4
- //#region node_modules/@subframe7536/type-utils/index.d.ts
5
+ //#region src/utils/type.d.ts
5
6
  type Promisable<T> = T | Promise<T>;
6
- type AnyFunction<Return = any> = (...args: any[]) => Return;
7
- //#endregion
8
- //#region src/vite/electron/core.d.ts
9
- interface ElectronOptions {
10
- /**
11
- * Shortcut of `build.lib.entry`
12
- */
13
- entry?: LibraryOptions["entry"];
14
- vite?: InlineConfig;
15
- /**
16
- * Triggered when Vite is built every time -- `vite serve` command only.
17
- *
18
- * If this `onstart` is passed, Electron App will not start automatically.
19
- * However, you can start Electroo App via `startup` function.
20
- */
21
- onstart?: (args: {
22
- /**
23
- * Electron App startup function.
24
- * It will mount the Electron App child-process to `process.electronApp`.
25
- * - argv: electron startup arguments (default `['.', '--no-sandbox']`)
26
- * - options: options for `child_process.spawn`
27
- * - customElectronPkg: custom electron package name (default: `'electron'`)
28
- */
29
- startup: (argv?: string[], options?: SpawnOptions, customElectronPkg?: string) => Promise<void>; /** Reload Electron-Renderer */
30
- reload: () => void;
31
- }) => void | Promise<void>;
32
- }
7
+ type AnyFunction = (...args: any[]) => any;
33
8
  //#endregion
34
9
  //#region src/vite/startup.d.ts
35
- type StartupFn = NonNullable<ElectronOptions["onstart"]>;
36
- /**
37
- * Debug mode startup function
38
- * Automatically starts Electron in VSCode debug mode
39
- * @param args - Startup arguments
40
- */
41
- declare function debugStartup(args: Parameters<StartupFn>[0]): Promise<void>;
42
10
  /**
43
11
  * Filter error messages from stdout/stderr during startup
44
12
  * @param args - Startup arguments
45
13
  * @param filter - Filter function to determine which messages to show
46
14
  */
47
- declare function filterErrorMessageStartup(args: Parameters<StartupFn>[0], filter: (msg: string) => boolean): Promise<void>;
15
+ declare function filterErrorMessageStartup(filter: (msg: string) => boolean): Promise<void>;
48
16
  /**
49
17
  * Fix Windows character encoding by setting code page to UTF-8
50
18
  * @param fn - Function to wrap with encoding fix
@@ -83,8 +51,11 @@ type UpdateJSON = UpdateInfo & {
83
51
  //#region src/vite/bytecode/index.d.ts
84
52
  /** Options for bytecode compilation */
85
53
  interface BytecodeOptions {
86
- /** Enable bytecode compilation */
87
- enable: boolean;
54
+ /**
55
+ * Enable bytecode compilation
56
+ * @default true
57
+ */
58
+ enable?: boolean;
88
59
  /**
89
60
  * Enable in preload script. Remember to set `sandbox: false` when creating window
90
61
  */
@@ -131,16 +102,16 @@ interface DistinguishedName {
131
102
  emailAddress?: string;
132
103
  }
133
104
  //#endregion
134
- //#region src/vite/option.d.ts
105
+ //#region src/vite/types.d.ts
135
106
  interface CommonBuildOption {
136
107
  /**
137
108
  * Shortcut of `build.rolldownOptions.input`
138
109
  */
139
- files: NonNullable<ElectronOptions["entry"]>;
110
+ files: NonNullable<MultiEnvElectronOptions["input"]>;
140
111
  /**
141
112
  * Override vite options
142
113
  */
143
- vite?: ElectronOptions["vite"] & {
114
+ options?: MultiEnvElectronOptions["options"] & {
144
115
  build?: {
145
116
  outDir: never;
146
117
  sourcemap: never;
@@ -154,21 +125,6 @@ interface CommonBuildOption {
154
125
  };
155
126
  }
156
127
  interface ElectronWithUpdaterOptions {
157
- /**
158
- * Whether is in build mode
159
- * ```ts
160
- * export default defineConfig(({ command }) => {
161
- * const isBuild = command === 'build'
162
- * })
163
- * ```
164
- */
165
- isBuild: boolean;
166
- /**
167
- * Project root directory. Can be an absolute path, or a path relative from
168
- * the location of the config file itself.
169
- * @default process.cwd()
170
- */
171
- root?: string;
172
128
  /**
173
129
  * Whether to generate sourcemap
174
130
  * @default !isBuild || !!process.env.VSCODE_DEBUG
@@ -188,9 +144,15 @@ interface ElectronWithUpdaterOptions {
188
144
  */
189
145
  bytecode?: boolean | BytecodeOptions;
190
146
  /**
191
- * Use `NotBundle()` plugin in main
147
+ * Faster dev startup by externalize all node modules in entry and main.
148
+ *
149
+ * Only works in development (`isBuild === false`).
192
150
  * @default true
193
151
  */
152
+ notBundle?: boolean | RolldownOrRollupOptions["external"];
153
+ /**
154
+ * @deprecated use `notBundle` instead
155
+ */
194
156
  useNotBundle?: boolean;
195
157
  /**
196
158
  * Whether to generate version json
@@ -198,12 +160,21 @@ interface ElectronWithUpdaterOptions {
198
160
  */
199
161
  buildVersionJson?: boolean;
200
162
  /**
163
+ * Generate and serve a local update package during dev startup.
164
+ *
165
+ * This is useful for testing update checks, simulated download progress,
166
+ * and restart/install behavior without publishing a remote release.
167
+ *
168
+ * @default false
169
+ */
170
+ localDevUpdate?: boolean | LocalDevUpdateOptions;
171
+ /**
201
172
  * Addtional `external` option in `build.rolldownOptions`,
202
173
  *
203
- * If is in dev and `entry.postBuild` is not setup,
174
+ * If equals `true`,
204
175
  * external `dependencies` in `package.json` by default
205
176
  */
206
- external?: (string | RegExp)[];
177
+ external?: (string | RegExp)[] | boolean;
207
178
  /**
208
179
  * Options for entry (app.asar)
209
180
  *
@@ -273,7 +244,7 @@ interface ElectronWithUpdaterOptions {
273
244
  * @param options options for `child_process.spawn`
274
245
  * @param customElectronPkg custom electron package name (default: 'electron')
275
246
  */
276
- onstart?: ElectronOptions["onstart"];
247
+ onstart?: MultiEnvElectronOptions["onstart"];
277
248
  } & CommonBuildOption;
278
249
  /**
279
250
  * Preload process options
@@ -286,29 +257,37 @@ interface ElectronWithUpdaterOptions {
286
257
  */
287
258
  updater?: UpdaterOptions;
288
259
  }
289
- interface GeneratorOverrideFunctions {
260
+ interface LocalDevUpdateOptions {
290
261
  /**
291
- * Custom signature generate function
292
- * @param buffer file buffer
293
- * @param privateKey private key
294
- * @param cert certificate string, **EOL must be `\n`**
295
- * @param version current version
262
+ * Package file used for local dev update name/version.
263
+ *
264
+ * This is useful when the Electron app package is not the project root
265
+ * package, such as a playground or example app.
266
+ *
267
+ * @default project package.json
296
268
  */
297
- generateSignature?: (buffer: Buffer, privateKey: string, cert: string, version: string) => Promisable<string>;
269
+ packageJsonPath?: string;
298
270
  /**
299
- * Custom generate update json function
300
- * @param existingJson The existing JSON object.
301
- * @param buffer file buffer
302
- * @param signature generated signature
303
- * @param version current version
304
- * @param minVersion The minimum version
271
+ * Directory that contains local update resources.
272
+ *
273
+ * The generated version file is written under `{baseDir}/{versionPath}` and
274
+ * update archives are written as `{baseDir}/{name}-{version}.asar.gz`.
275
+ *
276
+ * @default 'release/local-update'
305
277
  */
306
- generateUpdateJson?: (existingJson: UpdateJSON, signature: string, version: string, minVersion: string) => Promisable<UpdateJSON>;
278
+ baseDir?: string;
307
279
  /**
308
- * Custom generate zip file buffer
309
- * @param buffer source buffer
280
+ * Local read chunk size for simulated download progress.
281
+ *
282
+ * @default LocalDevProvider default
310
283
  */
311
- generateGzipFile?: (buffer: Buffer) => Promisable<Buffer>;
284
+ chunkSize?: number;
285
+ /**
286
+ * Delay between simulated progress chunks in milliseconds.
287
+ *
288
+ * @default LocalDevProvider default
289
+ */
290
+ chunkDelay?: number;
312
291
  }
313
292
  interface UpdaterOptions {
314
293
  /**
@@ -332,7 +311,7 @@ interface UpdaterOptions {
332
311
  entryOutDir?: string;
333
312
  /**
334
313
  * Path to version info output, content is {@link UpdateJSON}
335
- * @default `version.json`
314
+ * @default `release/version.json`
336
315
  */
337
316
  versionPath?: string;
338
317
  /**
@@ -398,23 +377,45 @@ interface UpdaterOptions {
398
377
  };
399
378
  overrideGenerator?: GeneratorOverrideFunctions;
400
379
  }
380
+ interface GeneratorOverrideFunctions {
381
+ /**
382
+ * Custom signature generate function
383
+ * @param buffer file buffer
384
+ * @param privateKey private key
385
+ * @param cert certificate string, **EOL must be `\n`**
386
+ * @param version current version
387
+ */
388
+ generateSignature?: (buffer: Buffer, privateKey: string, cert: string, version: string) => Promisable<string>;
389
+ /**
390
+ * Custom generate update json function
391
+ * @param existingJson The existing JSON object.
392
+ * @param signature generated signature
393
+ * @param version current version
394
+ * @param minVersion The minimum version
395
+ */
396
+ generateUpdateJson?: (existingJson: UpdateJSON, signature: string, version: string, minVersion: string) => Promisable<UpdateJSON>;
397
+ /**
398
+ * Custom generate zip file buffer
399
+ * @param buffer source buffer
400
+ */
401
+ generateGzipFile?: (buffer: Buffer) => Promisable<Buffer>;
402
+ }
401
403
  //#endregion
402
404
  //#region src/vite/core.d.ts
403
405
  /**
404
- * Base on `./electron/simple`
406
+ * Base on `vite-plugin-electron/multi-env`
405
407
  * - integrate with updater
406
408
  * - no `renderer` config
407
409
  * - remove old output file
408
410
  * - externalize dependencies
409
411
  * - auto restart when entry file changes
410
- * - other configs in {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template}
411
412
  *
412
- * You can override all the vite configs, except output directories (use `options.updater.paths.electronDistPath` instead)
413
+ * You can override all the environment configs, except output directories (use `options.updater.paths.electronDistPath` instead)
413
414
  *
414
415
  * @example
415
416
  * ```ts
416
417
  * import { defineConfig } from 'vite'
417
- * import { debugStartup, electronWithUpdater } from 'electron-incremental-update/vite'
418
+ * import { electronWithUpdater } from 'electron-incremental-update/vite'
418
419
  *
419
420
  * export default defineConfig(async ({ command }) => {
420
421
  * const isBuild = command === 'build'
@@ -424,8 +425,6 @@ interface UpdaterOptions {
424
425
  * isBuild,
425
426
  * main: {
426
427
  * files: ['./electron/main/index.ts', './electron/main/worker.ts'],
427
- * // see https://github.com/electron-vite/electron-vite-vue/blob/85ed267c4851bf59f32888d766c0071661d4b94c/vite.config.ts#L22-L28
428
- * onstart: debugStartup,
429
428
  * },
430
429
  * preload: {
431
430
  * files: './electron/preload/index.ts',
@@ -435,26 +434,18 @@ interface UpdaterOptions {
435
434
  * }
436
435
  * }),
437
436
  * ],
438
- * server: process.env.VSCODE_DEBUG && (() => {
439
- * const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
440
- * return {
441
- * host: url.hostname,
442
- * port: +url.port,
443
- * }
444
- * })(),
445
437
  * }
446
438
  * })
447
439
  * ```
448
440
  */
449
- declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<PluginOption[] | undefined>;
441
+ declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<Plugin[] | undefined>;
450
442
  //#endregion
451
443
  //#region src/vite/define.d.ts
452
- type MakeOptional<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
453
- interface ElectronViteHelperOptions extends MakeOptional<ElectronWithUpdaterOptions, "isBuild"> {
444
+ interface ElectronViteHelperOptions extends ElectronWithUpdaterOptions {
454
445
  /**
455
446
  * Config for renderer process
456
447
  */
457
- renderer?: Omit<UserConfig, "root">;
448
+ renderer?: UserConfig;
458
449
  }
459
450
  /**
460
451
  * Vite config helper
@@ -466,8 +457,6 @@ interface ElectronViteHelperOptions extends MakeOptional<ElectronWithUpdaterOpti
466
457
  * export default defineElectronConfig({
467
458
  * main: {
468
459
  * files: ['./electron/main/index.ts', './electron/main/worker.ts'],
469
- * // see https://github.com/electron-vite/electron-vite-vue/blob/85ed267c4851bf59f32888d766c0071661d4b94c/vite.config.ts#L22-L28
470
- * onstart: debugStartup,
471
460
  * },
472
461
  * preload: {
473
462
  * files: './electron/preload/index.ts',
@@ -487,6 +476,6 @@ interface ElectronViteHelperOptions extends MakeOptional<ElectronWithUpdaterOpti
487
476
  * })
488
477
  * ```
489
478
  */
490
- declare function defineElectronConfig(options: ElectronViteHelperOptions): UserConfigFn;
479
+ declare function defineElectronConfig(options: ElectronViteHelperOptions): UserConfig;
491
480
  //#endregion
492
- export { type ElectronViteHelperOptions, type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater as default, electronWithUpdater, defineElectronConfig, filterErrorMessageStartup, fixWinCharEncoding };
481
+ export { type ElectronViteHelperOptions, type ElectronWithUpdaterOptions, type LocalDevUpdateOptions, electronWithUpdater as default, electronWithUpdater, defineElectronConfig, filterErrorMessageStartup, fixWinCharEncoding };