electron-incremental-update 2.0.0-beta.3 → 2.0.0-beta.5

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.
@@ -1,5 +1,30 @@
1
1
  import { Promisable } from '@subframe7536/type-utils';
2
- import { U as UpdateJSON, a as UpdateInfo } from './version-CemSHimT.js';
2
+
3
+ interface Version {
4
+ major: number;
5
+ minor: number;
6
+ patch: number;
7
+ stage: string;
8
+ stageVersion: number;
9
+ }
10
+ declare function parseVersion(version: string): Version;
11
+ declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
12
+ /**
13
+ * update info json
14
+ */
15
+ type UpdateInfo = {
16
+ signature: string;
17
+ minimumVersion: string;
18
+ version: string;
19
+ };
20
+ /**
21
+ * {@link UpdateInfo} with beta
22
+ */
23
+ type UpdateJSON = UpdateInfo & {
24
+ beta: UpdateInfo;
25
+ };
26
+ declare function isUpdateJSON(json: any): json is UpdateJSON;
27
+ declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
3
28
 
4
29
  type URLHandler = (url: URL, isDownloadAsar: boolean) => Promisable<URL | string | undefined | null>;
5
30
  type OnDownloading = (progress: DownloadingInfo) => void;
@@ -10,10 +35,14 @@ interface DownloadingInfo {
10
35
  delta: number;
11
36
  /**
12
37
  * downloaded percent, 0 ~ 100
38
+ *
39
+ * If not `Content-Length` header, will be nagative
13
40
  */
14
41
  percent: number;
15
42
  /**
16
43
  * total size
44
+ *
45
+ * If not `Content-Length` header, will be -1
17
46
  */
18
47
  total: number;
19
48
  /**
@@ -57,11 +86,10 @@ interface IProvider {
57
86
  */
58
87
  isLowerVersion: (oldVer: string, newVer: string) => boolean;
59
88
  /**
60
- * unzip file
89
+ * unzip file buffer
61
90
  * @param buffer source buffer
62
- * @param targetFilePath target file path
63
91
  */
64
- unzipFile: (buffer: Buffer, targetFilePath: string) => Promise<void>;
92
+ unzipFile: (buffer: Buffer) => Promise<Buffer>;
65
93
  /**
66
94
  * verify asar signature
67
95
  * @param buffer file buffer
@@ -72,4 +100,4 @@ interface IProvider {
72
100
  verifySignaure: (buffer: Buffer, signature: string, cert: string) => Promisable<string | undefined>;
73
101
  }
74
102
 
75
- export type { DownloadingInfo as D, IProvider as I, OnDownloading as O, URLHandler as U };
103
+ export { type DownloadingInfo as D, type IProvider as I, type OnDownloading as O, type UpdateInfo as U, type Version as V, type UpdateJSON as a, defaultVersionJsonGenerator as b, type URLHandler as c, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
package/dist/utils.cjs CHANGED
@@ -82,34 +82,34 @@ function getPathFromPublic(...paths) {
82
82
  function getPathFromEntryAsar(...paths) {
83
83
  return path.join(electron.app.getAppPath(), __EIU_ENTRY_DIST_PATH__, ...paths);
84
84
  }
85
- async function defaultZipFile(buffer, targetFilePath) {
85
+ function handleUnexpectedErrors(callback) {
86
+ process.on("uncaughtException", callback);
87
+ process.on("unhandledRejection", callback);
88
+ }
89
+ async function defaultZipFile(buffer) {
86
90
  return new Promise((resolve, reject) => {
87
91
  zlib.brotliCompress(buffer, (err, buffer2) => {
88
92
  if (err) {
89
93
  reject(err);
94
+ } else {
95
+ resolve(buffer2);
90
96
  }
91
- fs.writeFileSync(targetFilePath, buffer2);
92
- resolve();
93
97
  });
94
98
  });
95
99
  }
96
- async function defaultUnzipFile(buffer, targetFilePath) {
100
+ async function defaultUnzipFile(buffer) {
97
101
  return new Promise((resolve, reject) => {
98
102
  zlib.brotliDecompress(buffer, (err, buffer2) => {
99
103
  if (err) {
100
104
  reject(err);
105
+ } else {
106
+ resolve(buffer2);
101
107
  }
102
- fs.writeFileSync(targetFilePath, buffer2);
103
- resolve();
104
108
  });
105
109
  });
106
110
  }
107
111
 
108
112
  // src/utils/version.ts
109
- function handleUnexpectedErrors(callback) {
110
- process.on("uncaughtException", callback);
111
- process.on("unhandledRejection", callback);
112
- }
113
113
  function parseVersion(version) {
114
114
  const match = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?/i.exec(version);
115
115
  if (!match) {
@@ -154,21 +154,19 @@ function defaultIsLowerVersion(oldVer, newVer) {
154
154
  return false;
155
155
  }
156
156
  function isUpdateJSON(json) {
157
- const is = (j) => !!(j && j.minimumVersion && j.signature && j.size && j.version);
157
+ const is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
158
158
  return is(json) && is(json?.beta);
159
159
  }
160
- function defaultVersionJsonGenerator(existingJson, buffer, signature, version, minimumVersion) {
160
+ function defaultVersionJsonGenerator(existingJson, signature, version, minimumVersion) {
161
161
  existingJson.beta = {
162
162
  version,
163
163
  minimumVersion,
164
- signature,
165
- size: buffer.length
164
+ signature
166
165
  };
167
166
  if (!parseVersion(version).stage) {
168
167
  existingJson.version = version;
169
168
  existingJson.minimumVersion = minimumVersion;
170
169
  existingJson.signature = signature;
171
- existingJson.size = buffer.length;
172
170
  }
173
171
  return existingJson;
174
172
  }
@@ -198,8 +196,16 @@ function defaultVerify(buffer, signature, cert) {
198
196
  }
199
197
  }
200
198
 
199
+ // src/utils/updater.ts
200
+ async function autoUpdate(updater) {
201
+ if (await updater.checkUpdate() && await updater.downloadUpdate()) {
202
+ updater.quitAndInstall();
203
+ }
204
+ }
205
+
201
206
  exports.aesDecrypt = aesDecrypt;
202
207
  exports.aesEncrypt = aesEncrypt;
208
+ exports.autoUpdate = autoUpdate;
203
209
  exports.defaultIsLowerVersion = defaultIsLowerVersion;
204
210
  exports.defaultSignature = defaultSignature;
205
211
  exports.defaultUnzipFile = defaultUnzipFile;
package/dist/utils.d.cts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { BrowserWindow } from 'electron';
2
- export { c as aesDecrypt, a as aesEncrypt, b as defaultSignature, d as defaultUnzipFile, e as defaultVerify, h as hashBuffer } from './unzip-JjYLjJkH.cjs';
3
- export { a as UpdateInfo, U as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, h as handleUnexpectedErrors, i as isUpdateJSON, p as parseVersion } from './version-CemSHimT.cjs';
2
+ export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerify, d as defaultZipFile, h as hashBuffer } from './zip-WRrEMkgp.cjs';
3
+ export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, i as isUpdateJSON, p as parseVersion } from './types-C5P0h_bB.cjs';
4
+ import { U as Updater } from './core-DmU2Vk_S.cjs';
5
+ import '@subframe7536/type-utils';
6
+ import 'node:events';
4
7
 
5
8
  /**
6
9
  * compile time dev check
@@ -63,7 +66,15 @@ declare function loadPage(win: BrowserWindow, htmlFilePath?: string): void;
63
66
  declare function getPathFromPreload(...paths: string[]): string;
64
67
  declare function getPathFromPublic(...paths: string[]): string;
65
68
  declare function getPathFromEntryAsar(...paths: string[]): string;
69
+ /**
70
+ * handle all unhandled error
71
+ * @param callback callback function
72
+ */
73
+ declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
66
74
 
67
- declare function defaultZipFile(buffer: Buffer, targetFilePath: string): Promise<void>;
75
+ /**
76
+ * auto check update, download and install
77
+ */
78
+ declare function autoUpdate(updater: Updater): Promise<void>;
68
79
 
69
- export { defaultZipFile, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
80
+ export { autoUpdate, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { BrowserWindow } from 'electron';
2
- export { c as aesDecrypt, a as aesEncrypt, b as defaultSignature, d as defaultUnzipFile, e as defaultVerify, h as hashBuffer } from './unzip-JjYLjJkH.js';
3
- export { a as UpdateInfo, U as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, h as handleUnexpectedErrors, i as isUpdateJSON, p as parseVersion } from './version-CemSHimT.js';
2
+ export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerify, d as defaultZipFile, h as hashBuffer } from './zip-WRrEMkgp.js';
3
+ export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, i as isUpdateJSON, p as parseVersion } from './types-C5P0h_bB.js';
4
+ import { U as Updater } from './core-CXETH_bb.js';
5
+ import '@subframe7536/type-utils';
6
+ import 'node:events';
4
7
 
5
8
  /**
6
9
  * compile time dev check
@@ -63,7 +66,15 @@ declare function loadPage(win: BrowserWindow, htmlFilePath?: string): void;
63
66
  declare function getPathFromPreload(...paths: string[]): string;
64
67
  declare function getPathFromPublic(...paths: string[]): string;
65
68
  declare function getPathFromEntryAsar(...paths: string[]): string;
69
+ /**
70
+ * handle all unhandled error
71
+ * @param callback callback function
72
+ */
73
+ declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
66
74
 
67
- declare function defaultZipFile(buffer: Buffer, targetFilePath: string): Promise<void>;
75
+ /**
76
+ * auto check update, download and install
77
+ */
78
+ declare function autoUpdate(updater: Updater): Promise<void>;
68
79
 
69
- export { defaultZipFile, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
80
+ export { autoUpdate, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
package/dist/utils.js CHANGED
@@ -1,19 +1,12 @@
1
- export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance } from './chunk-PNYRQYFC.js';
2
- export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerify, hashBuffer } from './chunk-5WFXC5GU.js';
3
- export { defaultIsLowerVersion, defaultVersionJsonGenerator, handleUnexpectedErrors, isUpdateJSON, parseVersion } from './chunk-BVFQWBLK.js';
4
- import { writeFileSync } from 'node:fs';
5
- import { brotliCompress } from 'node:zlib';
1
+ export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance } from './chunk-DFNDKSE6.js';
2
+ export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerify, defaultZipFile, hashBuffer } from './chunk-JSYIRKTR.js';
3
+ export { defaultIsLowerVersion, defaultVersionJsonGenerator, isUpdateJSON, parseVersion } from './chunk-72ZAJ7AF.js';
6
4
 
7
- async function defaultZipFile(buffer, targetFilePath) {
8
- return new Promise((resolve, reject) => {
9
- brotliCompress(buffer, (err, buffer2) => {
10
- if (err) {
11
- reject(err);
12
- }
13
- writeFileSync(targetFilePath, buffer2);
14
- resolve();
15
- });
16
- });
5
+ // src/utils/updater.ts
6
+ async function autoUpdate(updater) {
7
+ if (await updater.checkUpdate() && await updater.downloadUpdate()) {
8
+ updater.quitAndInstall();
9
+ }
17
10
  }
18
11
 
19
- export { defaultZipFile };
12
+ export { autoUpdate };
package/dist/vite.d.ts ADDED
@@ -0,0 +1,401 @@
1
+ import { PluginOption } from 'vite';
2
+ import { ElectronSimpleOptions } from 'vite-plugin-electron/simple';
3
+ import { Promisable } from '@subframe7536/type-utils';
4
+ import { BuildOptions } from 'esbuild';
5
+
6
+ /**
7
+ * update info json
8
+ */
9
+ type UpdateInfo = {
10
+ signature: string;
11
+ minimumVersion: string;
12
+ version: string;
13
+ };
14
+ /**
15
+ * {@link UpdateInfo} with beta
16
+ */
17
+ type UpdateJSON = UpdateInfo & {
18
+ beta: UpdateInfo;
19
+ };
20
+
21
+ interface PKG {
22
+ name: string;
23
+ version: string;
24
+ main: string;
25
+ }
26
+ interface DistinguishedName {
27
+ countryName?: string;
28
+ stateOrProvinceName?: string;
29
+ localityName?: string;
30
+ organizationName?: string;
31
+ organizationalUnitName?: string;
32
+ commonName?: string;
33
+ serialNumber?: string;
34
+ title?: string;
35
+ description?: string;
36
+ businessCategory?: string;
37
+ emailAddress?: string;
38
+ }
39
+ interface BuildEntryOption {
40
+ /**
41
+ * whether to minify
42
+ * @default isBuild
43
+ */
44
+ minify?: boolean;
45
+ /**
46
+ * whether to generate sourcemap
47
+ * @default isBuild
48
+ */
49
+ sourcemap?: boolean;
50
+ /**
51
+ * path to app entry output file
52
+ * @default 'dist-entry'
53
+ */
54
+ entryOutputDirPath?: string;
55
+ /**
56
+ * path to app entry file
57
+ * @default 'electron/entry.ts'
58
+ */
59
+ appEntryPath?: string;
60
+ /**
61
+ * esbuild path map of native modules in entry directory
62
+ *
63
+ * @default {}
64
+ * @example
65
+ * { db: './electron/native/db.ts' }
66
+ */
67
+ nativeModuleEntryMap?: Record<string, string>;
68
+ /**
69
+ * custom options for esbuild
70
+ * ```ts
71
+ * // default options
72
+ * const options = {
73
+ * entryPoints: {
74
+ * entry: appEntryPath,
75
+ * ...moduleEntryMap,
76
+ * },
77
+ * bundle: true,
78
+ * platform: 'node',
79
+ * outdir: entryOutputDirPath,
80
+ * minify,
81
+ * sourcemap,
82
+ * entryNames: '[dir]/[name]',
83
+ * assetNames: '[dir]/[name]',
84
+ * external: ['electron', 'original-fs'],
85
+ * loader: {
86
+ * '.node': 'empty',
87
+ * },
88
+ * define: {
89
+ * __SIGNATURE_CERT__: JSON.stringify(cert),
90
+ * },
91
+ * }
92
+ * ```
93
+ */
94
+ overrideEsbuildOptions?: BuildOptions;
95
+ /**
96
+ * resolve extra files on startup, such as `.node`
97
+ * @remark won't trigger will reload
98
+ */
99
+ postBuild?: (args: {
100
+ /**
101
+ * get path from `entryOutputDirPath`
102
+ */
103
+ getPathFromEntryOutputDir: (...paths: string[]) => string;
104
+ /**
105
+ * check exist and copy file to `entryOutputDirPath`
106
+ *
107
+ * if `to` absent, set to `basename(from)`
108
+ *
109
+ * if `skipIfExist` absent, skip copy if `to` exist
110
+ */
111
+ copyToEntryOutputDir: (options: {
112
+ from: string;
113
+ to?: string;
114
+ /**
115
+ * skip copy if `to` exist
116
+ * @default true
117
+ */
118
+ skipIfExist?: boolean;
119
+ }) => void;
120
+ }) => Promisable<void>;
121
+ }
122
+ interface GeneratorOverrideFunctions {
123
+ /**
124
+ * custom signature generate function
125
+ * @param buffer file buffer
126
+ * @param privateKey private key
127
+ * @param cert certificate string, **EOL must be '\n'**
128
+ * @param version current version
129
+ */
130
+ generateSignature?: (buffer: Buffer, privateKey: string, cert: string, version: string) => string | Promise<string>;
131
+ /**
132
+ * custom generate version json function
133
+ * @param existingJson The existing JSON object.
134
+ * @param buffer file buffer
135
+ * @param signature generated signature
136
+ * @param version current version
137
+ * @param minVersion The minimum version
138
+ * @returns The updated version json
139
+ */
140
+ generateVersionJson?: (existingJson: UpdateJSON, signature: string, version: string, minVersion: string) => UpdateJSON | Promise<UpdateJSON>;
141
+ /**
142
+ * custom generate zip file buffer
143
+ * @param buffer source buffer
144
+ */
145
+ generateGzipFile?: (buffer: Buffer) => Promise<Buffer>;
146
+ }
147
+ interface ElectronUpdaterOptions {
148
+ /**
149
+ * mini version of entry
150
+ * @default '0.0.0'
151
+ */
152
+ minimumVersion?: string;
153
+ /**
154
+ * config for entry (app.asar)
155
+ */
156
+ entry?: BuildEntryOption;
157
+ /**
158
+ * paths config
159
+ */
160
+ paths?: {
161
+ /**
162
+ * Path to asar file
163
+ * @default `release/${app.name}.asar`
164
+ */
165
+ asarOutputPath?: string;
166
+ /**
167
+ * Path to version info output, content is {@link UpdateJSON}
168
+ * @default `version.json`
169
+ */
170
+ versionPath?: string;
171
+ /**
172
+ * Path to gzipped asar file
173
+ * @default `release/${app.name}-${version}.asar.gz`
174
+ */
175
+ gzipPath?: string;
176
+ /**
177
+ * Path to electron build output
178
+ * @default `dist-electron`
179
+ */
180
+ electronDistPath?: string;
181
+ /**
182
+ * Path to renderer build output
183
+ * @default `dist`
184
+ */
185
+ rendererDistPath?: string;
186
+ };
187
+ /**
188
+ * signature config
189
+ */
190
+ keys?: {
191
+ /**
192
+ * path to the pem file that contains private key
193
+ * if not ended with .pem, it will be appended
194
+ *
195
+ * **if `UPDATER_PK` is set, will read it instead of read from `privateKeyPath`**
196
+ * @default 'keys/private.pem'
197
+ */
198
+ privateKeyPath?: string;
199
+ /**
200
+ * path to the pem file that contains public key
201
+ * if not ended with .pem, it will be appended
202
+ *
203
+ * **if `UPDATER_CERT` is set, will read it instead of read from `certPath`**
204
+ * @default 'keys/cert.pem'
205
+ */
206
+ certPath?: string;
207
+ /**
208
+ * length of the key
209
+ * @default 2048
210
+ */
211
+ keyLength?: number;
212
+ /**
213
+ * X509 certificate info
214
+ *
215
+ * only generate simple **self-signed** certificate **without extensions**
216
+ */
217
+ certInfo?: {
218
+ /**
219
+ * the subject of the certificate
220
+ *
221
+ * @default { commonName: `${app.name}`, organizationName: `org.${app.name}` }
222
+ */
223
+ subject?: DistinguishedName;
224
+ /**
225
+ * expire days of the certificate
226
+ *
227
+ * @default 3650
228
+ */
229
+ days?: number;
230
+ };
231
+ };
232
+ overrideGenerator?: GeneratorOverrideFunctions;
233
+ }
234
+
235
+ interface BytecodeOptions {
236
+ /**
237
+ * strings that should be transformed
238
+ */
239
+ protectedStrings?: string[];
240
+ /**
241
+ * Remember to set `sandbox: false` when creating window
242
+ */
243
+ enablePreload?: boolean;
244
+ }
245
+
246
+ type MakeRequired<T, K extends keyof T> = Exclude<T, undefined> & {
247
+ [P in K]-?: T[P];
248
+ };
249
+ type ReplaceKey<T, Key extends keyof T, NewKey extends string> = Omit<T, Key> & {
250
+ [P in NewKey]: T[Key];
251
+ };
252
+ type MakeRequiredAndReplaceKey<T, K extends keyof T, NewKey extends string> = MakeRequired<ReplaceKey<T, K, NewKey>, NewKey>;
253
+ /**
254
+ * startup function for debug (see {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template})
255
+ * @example
256
+ * import { debugStartup, buildElectronPluginOptions } from 'electron-incremental-update/vite'
257
+ * const options = buildElectronPluginOptions({
258
+ * // ...
259
+ * main: {
260
+ * // ...
261
+ * startup: debugStartup
262
+ * },
263
+ * })
264
+ */
265
+ declare function debugStartup(args: {
266
+ startup: (argv?: string[]) => Promise<void>;
267
+ reload: () => void;
268
+ }): void;
269
+ type ExcludeOutputDirOptions = {
270
+ vite?: {
271
+ build?: {
272
+ outDir: never;
273
+ rollupOptions?: {
274
+ output?: {
275
+ dir: never;
276
+ };
277
+ };
278
+ };
279
+ };
280
+ };
281
+ interface ElectronWithUpdaterOptions {
282
+ /**
283
+ * whether is in build mode
284
+ * ```ts
285
+ * export default defineConfig(({ command }) => {
286
+ * const isBuild = command === 'build'
287
+ * })
288
+ * ```
289
+ */
290
+ isBuild: boolean;
291
+ /**
292
+ * manually setup package.json, read name, version and main
293
+ * ```ts
294
+ * import pkg from './package.json'
295
+ * ```
296
+ */
297
+ pkg?: PKG;
298
+ /**
299
+ * whether to generate sourcemap
300
+ * @default !isBuild
301
+ */
302
+ sourcemap?: boolean;
303
+ /**
304
+ * whether to minify the code
305
+ * @default isBuild
306
+ */
307
+ minify?: boolean;
308
+ /**
309
+ * whether to generate bytecode
310
+ *
311
+ * **only support commonjs**
312
+ *
313
+ * 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
314
+ */
315
+ bytecode?: boolean | BytecodeOptions;
316
+ /**
317
+ * use NotBundle() plugin in main
318
+ * @default true
319
+ */
320
+ useNotBundle?: boolean;
321
+ /**
322
+ * whether to generate version json
323
+ * @default isCI
324
+ */
325
+ buildVersionJson?: boolean;
326
+ /**
327
+ * Whether to log parsed options
328
+ *
329
+ * to show certificate and private keys, set `logParsedOptions: { showKeys: true }`
330
+ */
331
+ logParsedOptions?: boolean | {
332
+ showKeys: boolean;
333
+ };
334
+ /**
335
+ * main process options
336
+ *
337
+ * to change output directories, use `options.updater.paths.electronDistPath` instead
338
+ */
339
+ main: MakeRequiredAndReplaceKey<ElectronSimpleOptions['main'], 'entry', 'files'> & ExcludeOutputDirOptions;
340
+ /**
341
+ * preload process options
342
+ *
343
+ * to change output directories, use `options.updater.paths.electronDistPath` instead
344
+ */
345
+ preload: MakeRequiredAndReplaceKey<Exclude<ElectronSimpleOptions['preload'], undefined>, 'input', 'files'> & ExcludeOutputDirOptions;
346
+ /**
347
+ * updater options
348
+ */
349
+ updater?: ElectronUpdaterOptions;
350
+ }
351
+ /**
352
+ * build options for `vite-plugin-electron/simple`
353
+ * - integrate with updater
354
+ * - only contains `main` and `preload` configs
355
+ * - remove old electron files
356
+ * - externalize dependencies
357
+ * - auto restart when entry file changes
358
+ * - other configs in {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template}
359
+ * - no `vite-plugin-electron-renderer` config
360
+ *
361
+ * you can override all the vite configs, except output directories (use `options.updater.paths.electronDistPath` instead)
362
+ *
363
+ * @example
364
+ * import { defineConfig } from 'vite'
365
+ * import { debugStartup, electronWithUpdater } from 'electron-incremental-update/vite'
366
+ * import pkg from './package.json'
367
+ *
368
+ * export default defineConfig(async ({ command }) => {
369
+ * const isBuild = command === 'build'
370
+ * return {
371
+ * plugins: [
372
+ * electronWithUpdater({
373
+ * pkg,
374
+ * isBuild,
375
+ * logParsedOptions: true,
376
+ * main: {
377
+ * files: ['./electron/main/index.ts', './electron/main/worker.ts'],
378
+ * // see https://github.com/electron-vite/electron-vite-vue/blob/85ed267c4851bf59f32888d766c0071661d4b94c/vite.config.ts#L22-L28
379
+ * onstart: debugStartup,
380
+ * },
381
+ * preload: {
382
+ * files: './electron/preload/index.ts',
383
+ * },
384
+ * updater: {
385
+ * // options
386
+ * }
387
+ * }),
388
+ * ],
389
+ * server: process.env.VSCODE_DEBUG && (() => {
390
+ * const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
391
+ * return {
392
+ * host: url.hostname,
393
+ * port: +url.port,
394
+ * }
395
+ * })(),
396
+ * }
397
+ * })
398
+ */
399
+ declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<PluginOption[] | undefined>;
400
+
401
+ export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater };