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