electron-incremental-update 2.4.3 → 3.0.0-beta.3

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.
Files changed (47) hide show
  1. package/README.md +48 -40
  2. package/dist/download-BN4uMS4_.d.mts +39 -0
  3. package/dist/download-DO7iuxEJ.d.cts +39 -0
  4. package/dist/electron-DH-Uyikp.cjs +321 -0
  5. package/dist/electron-OKQIYbcw.mjs +181 -0
  6. package/dist/index.cjs +261 -331
  7. package/dist/index.d.cts +179 -169
  8. package/dist/index.d.mts +204 -0
  9. package/dist/index.mjs +273 -0
  10. package/dist/provider.cjs +142 -330
  11. package/dist/provider.d.cts +113 -114
  12. package/dist/provider.d.mts +133 -0
  13. package/dist/provider.mjs +152 -0
  14. package/dist/types-BM9Jfu7q.d.cts +154 -0
  15. package/dist/types-DASqEPXE.d.mts +154 -0
  16. package/dist/utils.cjs +43 -381
  17. package/dist/utils.d.cts +120 -85
  18. package/dist/utils.d.mts +164 -0
  19. package/dist/utils.mjs +5 -0
  20. package/dist/version--eVB2A7n.mjs +72 -0
  21. package/dist/version-aPrLuz_-.cjs +129 -0
  22. package/dist/vite.d.mts +521 -0
  23. package/dist/vite.mjs +1094 -0
  24. package/dist/zip-BCC7FAQ_.cjs +264 -0
  25. package/dist/zip-Dwm7s1C9.mjs +185 -0
  26. package/package.json +66 -64
  27. package/dist/chunk-AAAM44NW.js +0 -70
  28. package/dist/chunk-IVHNGRZY.js +0 -122
  29. package/dist/chunk-PD4EV4MM.js +0 -147
  30. package/dist/index.d.ts +0 -194
  31. package/dist/index.js +0 -309
  32. package/dist/provider.d.ts +0 -134
  33. package/dist/provider.js +0 -152
  34. package/dist/types-CU7GyVez.d.cts +0 -151
  35. package/dist/types-CU7GyVez.d.ts +0 -151
  36. package/dist/utils.d.ts +0 -129
  37. package/dist/utils.js +0 -3
  38. package/dist/vite.d.ts +0 -533
  39. package/dist/vite.js +0 -945
  40. package/dist/zip-Blmn2vzE.d.cts +0 -71
  41. package/dist/zip-CnSv_Njj.d.ts +0 -71
  42. package/provider.d.ts +0 -1
  43. package/provider.js +0 -1
  44. package/utils.d.ts +0 -1
  45. package/utils.js +0 -1
  46. package/vite.d.ts +0 -1
  47. package/vite.js +0 -1
package/dist/vite.d.ts DELETED
@@ -1,533 +0,0 @@
1
- import { Promisable, AnyFunction } from '@subframe7536/type-utils';
2
- import { InlineConfig, PluginOption, UserConfig, UserConfigFn } from 'vite';
3
- import { ElectronOptions } from 'vite-plugin-electron';
4
- import { ElectronSimpleOptions } from 'vite-plugin-electron/simple';
5
- export { isCI } from 'ci-info';
6
- export { getPackageInfo, getPackageInfoSync, loadPackageJSON, resolveModule } from 'local-pkg';
7
-
8
- /**
9
- * Obfuscate string
10
- * @param code source code
11
- * @param sourcemap whether to generate sourcemap
12
- * @param offset custom offset
13
- */
14
- declare function convertLiteral(code: string, sourcemap?: boolean, offset?: number): {
15
- code: string;
16
- map?: any;
17
- };
18
-
19
- /**
20
- * Update info json
21
- */
22
- type UpdateInfo = {
23
- /**
24
- * Update Asar signature
25
- */
26
- signature: string;
27
- /**
28
- * Minimum version
29
- */
30
- minimumVersion: string;
31
- /**
32
- * Target version
33
- */
34
- version: string;
35
- };
36
- /**
37
- * {@link UpdateInfo} with beta
38
- */
39
- type UpdateJSON = UpdateInfo & {
40
- /**
41
- * Beta update info
42
- */
43
- beta: UpdateInfo;
44
- };
45
-
46
- interface BytecodeOptions {
47
- enable: boolean;
48
- /**
49
- * Enable in preload script. Remember to set `sandbox: false` when creating window
50
- */
51
- preload?: boolean;
52
- /**
53
- * Custom electron binary path
54
- */
55
- electronPath?: string;
56
- /**
57
- * Before transformed code compile function. If return `Falsy` value, it will be ignored
58
- * @param code transformed code
59
- * @param id file path
60
- */
61
- beforeCompile?: (code: string, id: string) => Promisable<string | null | undefined | void>;
62
- }
63
-
64
- interface DistinguishedName {
65
- countryName?: string;
66
- stateOrProvinceName?: string;
67
- localityName?: string;
68
- organizationName?: string;
69
- organizationalUnitName?: string;
70
- commonName?: string;
71
- serialNumber?: string;
72
- title?: string;
73
- description?: string;
74
- businessCategory?: string;
75
- emailAddress?: string;
76
- }
77
-
78
- interface PKG {
79
- name: string;
80
- version: string;
81
- main: string;
82
- type: 'commonjs' | 'module';
83
- }
84
- interface ViteOverride {
85
- /**
86
- * Override vite options
87
- */
88
- vite?: ElectronOptions['vite'] & {
89
- build?: {
90
- outDir: never;
91
- rollupOptions?: {
92
- output?: {
93
- dir: never;
94
- };
95
- };
96
- };
97
- };
98
- }
99
- interface ElectronWithUpdaterOptions {
100
- /**
101
- * Whether is in build mode
102
- * ```ts
103
- * export default defineConfig(({ command }) => {
104
- * const isBuild = command === 'build'
105
- * })
106
- * ```
107
- */
108
- isBuild: boolean;
109
- /**
110
- * Manually setup package.json, read name, version and main,
111
- * use `local-pkg` of `loadPackageJSON()` to load package.json by default
112
- * ```ts
113
- * import pkg from './package.json'
114
- * ```
115
- */
116
- pkg?: PKG;
117
- /**
118
- * Whether to generate sourcemap
119
- * @default !isBuild
120
- */
121
- sourcemap?: boolean;
122
- /**
123
- * Whether to minify the code
124
- * @default isBuild
125
- */
126
- minify?: boolean;
127
- /**
128
- * Whether to generate bytecode
129
- *
130
- * **Only support CommonJS**
131
- *
132
- * 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
133
- */
134
- bytecode?: boolean | BytecodeOptions;
135
- /**
136
- * Use `NotBundle()` plugin in main
137
- * @default true
138
- */
139
- useNotBundle?: boolean;
140
- /**
141
- * Whether to generate version json
142
- * @default isCI
143
- */
144
- buildVersionJson?: boolean;
145
- /**
146
- * Main process options
147
- *
148
- * To change output directories, use `options.updater.paths.electronDistPath` instead
149
- */
150
- main: {
151
- /**
152
- * Shortcut of `build.rollupOptions.input`
153
- */
154
- files: NonNullable<ElectronOptions['entry']>;
155
- /**
156
- * Electron App startup function.
157
- *
158
- * It will mount the Electron App child-process to `process.electronApp`.
159
- * @param argv default value `['.', '--no-sandbox']`
160
- * @param options options for `child_process.spawn`
161
- * @param customElectronPkg custom electron package name (default: 'electron')
162
- */
163
- onstart?: ElectronOptions['onstart'];
164
- } & ViteOverride;
165
- /**
166
- * Preload process options
167
- *
168
- * To change output directories, use `options.updater.paths.electronDistPath` instead
169
- */
170
- preload: {
171
- /**
172
- * Shortcut of `build.rollupOptions.input`.
173
- *
174
- * Preload scripts may contain Web assets, so use the `build.rollupOptions.input` instead `build.lib.entry`.
175
- */
176
- files: NonNullable<ElectronOptions['entry']>;
177
- } & ViteOverride;
178
- /**
179
- * Updater options
180
- */
181
- updater?: UpdaterOptions;
182
- }
183
- interface BuildEntryOption {
184
- /**
185
- * Override to minify on entry
186
- * @default isBuild
187
- */
188
- minify?: boolean;
189
- /**
190
- * Override to generate sourcemap on entry
191
- */
192
- sourcemap?: boolean;
193
- /**
194
- * Path to app entry output file
195
- * @default 'dist-entry'
196
- */
197
- entryOutputDirPath?: string;
198
- /**
199
- * Path to app entry file
200
- * @default 'electron/entry.ts'
201
- */
202
- appEntryPath?: string;
203
- /**
204
- * Vite input options of native modules in entry directory
205
- *
206
- * @default {}
207
- * @example
208
- * { db: './electron/native/db.ts' }
209
- */
210
- nativeModuleEntryMap?: Record<string, string>;
211
- /**
212
- * Skip process dynamic require
213
- *
214
- * Useful for `better-sqlite3` and other old packages
215
- */
216
- ignoreDynamicRequires?: boolean;
217
- /**
218
- * `external` option in `build.rollupOptions`,
219
- * default is node built-in modules or native modules.
220
- *
221
- * If is in dev and {@link postBuild} is not setup, will also
222
- * external `dependencies` in `package.json`
223
- */
224
- external?: NonNullable<NonNullable<InlineConfig['build']>['rollupOptions']>['external'];
225
- /**
226
- * Custom options for `vite` build
227
- * ```ts
228
- * const options = {
229
- * plugins: [esm(), bytecodePlugin()], // load on needed
230
- * build: {
231
- * sourcemap,
232
- * minify,
233
- * outDir: entryOutputDirPath,
234
- * commonjsOptions: { ignoreDynamicRequires },
235
- * rollupOptions: { external },
236
- * },
237
- * define,
238
- * }
239
- * ```
240
- */
241
- overrideViteOptions?: InlineConfig;
242
- /**
243
- * By default, all the unbundled modules will be packaged by packager like `electron-builder`.
244
- * If setup, all the `dependencies` in `package.json` will be bundled by default, and you need
245
- * to manually handle the native module files.
246
- *
247
- * If you are using `electron-buidler`, don't forget to append `'!node_modules/**'` in
248
- * electron-build config's `files` array
249
- */
250
- postBuild?: (args: {
251
- /**
252
- * Get path from `entryOutputDirPath`
253
- */
254
- getPathFromEntryOutputDir: (...paths: string[]) => string;
255
- /**
256
- * Check exist and copy file to `entryOutputDirPath`
257
- *
258
- * If `to` absent, set to `basename(from)`
259
- *
260
- * If `skipIfExist` absent, skip copy if `to` exist
261
- */
262
- copyToEntryOutputDir: (options: {
263
- from: string;
264
- to?: string;
265
- /**
266
- * Skip copy if `to` exist
267
- * @default true
268
- */
269
- skipIfExist?: boolean;
270
- }) => void;
271
- /**
272
- * Copy specified modules to entry output dir, just like `external` option in rollup
273
- */
274
- copyModules: (options: {
275
- /**
276
- * External Modules
277
- */
278
- modules: string[];
279
- /**
280
- * Skip copy if `to` exist
281
- * @default true
282
- */
283
- skipIfExist?: boolean;
284
- }) => void;
285
- }) => Promisable<void>;
286
- }
287
- interface GeneratorOverrideFunctions {
288
- /**
289
- * Custom signature generate function
290
- * @param buffer file buffer
291
- * @param privateKey private key
292
- * @param cert certificate string, **EOL must be `\n`**
293
- * @param version current version
294
- */
295
- generateSignature?: (buffer: Buffer, privateKey: string, cert: string, version: string) => Promisable<string>;
296
- /**
297
- * Custom generate update json function
298
- * @param existingJson The existing JSON object.
299
- * @param buffer file buffer
300
- * @param signature generated signature
301
- * @param version current version
302
- * @param minVersion The minimum version
303
- */
304
- generateUpdateJson?: (existingJson: UpdateJSON, signature: string, version: string, minVersion: string) => Promisable<UpdateJSON>;
305
- /**
306
- * Custom generate zip file buffer
307
- * @param buffer source buffer
308
- */
309
- generateGzipFile?: (buffer: Buffer) => Promisable<Buffer>;
310
- }
311
- interface UpdaterOptions {
312
- /**
313
- * Minimum version of entry
314
- * @default '0.0.0'
315
- */
316
- minimumVersion?: string;
317
- /**
318
- * Options for entry (app.asar)
319
- */
320
- entry?: BuildEntryOption;
321
- /**
322
- * Options for paths
323
- */
324
- paths?: {
325
- /**
326
- * Path to asar file
327
- * @default `release/${app.name}.asar`
328
- */
329
- asarOutputPath?: string;
330
- /**
331
- * Path to version info output, content is {@link UpdateJSON}
332
- * @default `version.json`
333
- */
334
- versionPath?: string;
335
- /**
336
- * Path to gzipped asar file
337
- * @default `release/${app.name}-${version}.asar.gz`
338
- */
339
- gzipPath?: string;
340
- /**
341
- * Path to electron build output
342
- * @default `dist-electron`
343
- */
344
- electronDistPath?: string;
345
- /**
346
- * Path to renderer build output
347
- * @default `dist`
348
- */
349
- rendererDistPath?: string;
350
- };
351
- /**
352
- * signature config
353
- */
354
- keys?: {
355
- /**
356
- * Path to the pem file that contains private key
357
- * If not ended with .pem, it will be appended
358
- *
359
- * **If `UPDATER_PK` is set, will read it instead of read from `privateKeyPath`**
360
- * @default 'keys/private.pem'
361
- */
362
- privateKeyPath?: string;
363
- /**
364
- * Path to the pem file that contains public key
365
- * If not ended with .pem, it will be appended
366
- *
367
- * **If `UPDATER_CERT` is set, will read it instead of read from `certPath`**
368
- * @default 'keys/cert.pem'
369
- */
370
- certPath?: string;
371
- /**
372
- * Length of the key
373
- * @default 2048
374
- */
375
- keyLength?: number;
376
- /**
377
- * X509 certificate info
378
- *
379
- * Only generate simple **self-signed** certificate **without extensions**
380
- */
381
- certInfo?: {
382
- /**
383
- * The subject of the certificate
384
- *
385
- * @default { commonName: `${app.name}`, organizationName: `org.${app.name}` }
386
- */
387
- subject?: DistinguishedName;
388
- /**
389
- * Expire days of the certificate
390
- *
391
- * @default 3650
392
- */
393
- days?: number;
394
- };
395
- };
396
- overrideGenerator?: GeneratorOverrideFunctions;
397
- }
398
-
399
- type StartupFn = NonNullable<NonNullable<ElectronSimpleOptions['main']>['onstart']>;
400
- /**
401
- * Startup function for debug
402
- * @see {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template}
403
- * @example
404
- * import { debugStartup, buildElectronPluginOptions } from 'electron-incremental-update/vite'
405
- * const options = buildElectronPluginOptions({
406
- * // ...
407
- * main: {
408
- * // ...
409
- * startup: debugStartup
410
- * },
411
- * })
412
- */
413
- declare const debugStartup: StartupFn;
414
- /**
415
- * Startup function to filter unwanted error message
416
- * @see {@link https://github.com/electron/electron/issues/46903#issuecomment-2848483520 reference}
417
- * @example
418
- * import { filterErrorMessageStartup, buildElectronPluginOptions } from 'electron-incremental-update/vite'
419
- * const options = buildElectronPluginOptions({
420
- * // ...
421
- * main: {
422
- * // ...
423
- * startup: args => filterErrorMessageStartup(
424
- * args,
425
- * // ignore error message when function returns false
426
- * msg => !/"code":-32601/.test(msg)
427
- * )
428
- * },
429
- * })
430
- */
431
- declare function filterErrorMessageStartup(args: Parameters<StartupFn>[0], filter: (msg: string) => boolean): Promise<void>;
432
- /**
433
- * Startup function util to fix Windows terminal charset
434
- * @example
435
- * import { debugStartup, fixWinCharEncoding, buildElectronPluginOptions } from 'electron-incremental-update/vite'
436
- * const options = buildElectronPluginOptions({
437
- * // ...
438
- * main: {
439
- * // ...
440
- * startup: fixWinCharEncoding(debugStartup)
441
- * },
442
- * })
443
- */
444
- declare function fixWinCharEncoding<T extends AnyFunction>(fn: T): T;
445
- /**
446
- * Base on `vite-plugin-electron/simple`
447
- * - integrate with updater
448
- * - no `renderer` config
449
- * - remove old output file
450
- * - externalize dependencies
451
- * - auto restart when entry file changes
452
- * - other configs in {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template}
453
- *
454
- * You can override all the vite configs, except output directories (use `options.updater.paths.electronDistPath` instead)
455
- *
456
- * @example
457
- * ```ts
458
- * import { defineConfig } from 'vite'
459
- * import { debugStartup, electronWithUpdater } from 'electron-incremental-update/vite'
460
- *
461
- * export default defineConfig(async ({ command }) => {
462
- * const isBuild = command === 'build'
463
- * return {
464
- * plugins: [
465
- * electronWithUpdater({
466
- * isBuild,
467
- * main: {
468
- * 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
- * },
472
- * preload: {
473
- * files: './electron/preload/index.ts',
474
- * },
475
- * updater: {
476
- * // options
477
- * }
478
- * }),
479
- * ],
480
- * server: process.env.VSCODE_DEBUG && (() => {
481
- * const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
482
- * return {
483
- * host: url.hostname,
484
- * port: +url.port,
485
- * }
486
- * })(),
487
- * }
488
- * })
489
- * ```
490
- */
491
- declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<PluginOption[] | undefined>;
492
-
493
- type MakeOptional<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
494
- interface ElectronViteHelperOptions extends MakeOptional<ElectronWithUpdaterOptions, 'isBuild'> {
495
- /**
496
- * Config for renderer process
497
- */
498
- renderer?: UserConfig;
499
- }
500
- /**
501
- * Vite config helper
502
- * @see {@link electronWithUpdater}
503
- * @example
504
- * ```ts
505
- * import { defineElectronConfig } from 'electron-incremental-update/vite'
506
- *
507
- * export default defineElectronConfig({
508
- * main: {
509
- * files: ['./electron/main/index.ts', './electron/main/worker.ts'],
510
- * // see https://github.com/electron-vite/electron-vite-vue/blob/85ed267c4851bf59f32888d766c0071661d4b94c/vite.config.ts#L22-L28
511
- * onstart: debugStartup,
512
- * },
513
- * preload: {
514
- * files: './electron/preload/index.ts',
515
- * },
516
- * updater: {
517
- * // options
518
- * },
519
- * renderer: {
520
- * server: process.env.VSCODE_DEBUG && (() => {
521
- * const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
522
- * return {
523
- * host: url.hostname,
524
- * port: +url.port,
525
- * }
526
- * })(),
527
- * }
528
- * })
529
- * ```
530
- */
531
- declare function defineElectronConfig(options: ElectronViteHelperOptions): UserConfigFn;
532
-
533
- export { type ElectronViteHelperOptions, type ElectronWithUpdaterOptions, convertLiteral, debugStartup, electronWithUpdater as default, defineElectronConfig, electronWithUpdater, filterErrorMessageStartup, fixWinCharEncoding };