electron-incremental-update 1.3.0 → 2.0.0-beta.2

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.ts DELETED
@@ -1,372 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { ElectronSimpleOptions } from 'vite-plugin-electron/simple';
3
- import { Promisable } from '@subframe7536/type-utils';
4
- import { BuildOptions } from 'esbuild';
5
-
6
- type UpdateInfo = {
7
- signature: string;
8
- minimumVersion: string;
9
- version: string;
10
- size: number;
11
- };
12
- type UpdateJSON = UpdateInfo & {
13
- beta: UpdateInfo;
14
- };
15
-
16
- type PKG = {
17
- name: string;
18
- version: string;
19
- main: string;
20
- };
21
- type DistinguishedName = {
22
- countryName?: string;
23
- stateOrProvinceName?: string;
24
- localityName?: string;
25
- organizationName?: string;
26
- organizationalUnitName?: string;
27
- commonName?: string;
28
- serialNumber?: string;
29
- title?: string;
30
- description?: string;
31
- businessCategory?: string;
32
- emailAddress?: string;
33
- };
34
- type BuildEntryOption = {
35
- /**
36
- * whether to minify
37
- * @default isBuild
38
- */
39
- minify?: boolean;
40
- /**
41
- * whether to generate sourcemap
42
- * @default isBuild
43
- */
44
- sourcemap?: boolean;
45
- /**
46
- * path to app entry output file
47
- * @default 'dist-entry'
48
- */
49
- entryOutputDirPath?: string;
50
- /**
51
- * path to app entry file
52
- * @default 'electron/entry.ts'
53
- */
54
- appEntryPath?: string;
55
- /**
56
- * esbuild path map of native modules in entry directory
57
- *
58
- * @default {}
59
- * @example
60
- * { db: './electron/native/db.ts' }
61
- */
62
- nativeModuleEntryMap?: Record<string, string>;
63
- /**
64
- * custom options for esbuild
65
- * ```ts
66
- * // default options
67
- * const options = {
68
- * entryPoints: {
69
- * entry: appEntryPath,
70
- * ...moduleEntryMap,
71
- * },
72
- * bundle: true,
73
- * platform: 'node',
74
- * outdir: entryOutputDirPath,
75
- * minify,
76
- * sourcemap,
77
- * entryNames: '[dir]/[name]',
78
- * assetNames: '[dir]/[name]',
79
- * external: ['electron', 'original-fs'],
80
- * loader: {
81
- * '.node': 'empty',
82
- * },
83
- * define: {
84
- * __SIGNATURE_CERT__: JSON.stringify(cert),
85
- * },
86
- * }
87
- * ```
88
- */
89
- overrideEsbuildOptions?: BuildOptions;
90
- /**
91
- * resolve extra files on startup, such as `.node`
92
- * @remark won't trigger will reload
93
- */
94
- postBuild?: (args: {
95
- /**
96
- * get path from `entryOutputDirPath`
97
- */
98
- getPathFromEntryOutputDir: (...paths: string[]) => string;
99
- /**
100
- * check exist and copy file to `entryOutputDirPath`
101
- *
102
- * if `to` absent, set to `basename(from)`
103
- *
104
- * if `skipIfExist` absent, skip copy if `to` exist
105
- */
106
- copyToEntryOutputDir: (options: {
107
- from: string;
108
- to?: string;
109
- /**
110
- * skip copy if `to` exist
111
- * @default true
112
- */
113
- skipIfExist?: boolean;
114
- }) => void;
115
- }) => Promisable<void>;
116
- };
117
- type GeneratorOverrideFunctions = {
118
- /**
119
- * custom signature generate function
120
- * @param buffer file buffer
121
- * @param privateKey private key
122
- * @param cert certificate string, **EOL must be '\n'**
123
- * @param version current version
124
- */
125
- generateSignature?: (buffer: Buffer, privateKey: string, cert: string, version: string) => string | Promise<string>;
126
- /**
127
- * custom generate version json function
128
- * @param existingJson The existing JSON object.
129
- * @param buffer file buffer
130
- * @param signature generated signature
131
- * @param version current version
132
- * @param minVersion The minimum version
133
- * @returns The updated version json
134
- */
135
- generateVersionJson?: (existingJson: UpdateJSON, buffer: Buffer, signature: string, version: string, minVersion: string) => UpdateJSON | Promise<UpdateJSON>;
136
- };
137
- type ElectronUpdaterOptions = {
138
- /**
139
- * mini version of entry
140
- * @default '0.0.0'
141
- */
142
- minimumVersion?: string;
143
- /**
144
- * config for entry (app.asar)
145
- */
146
- entry?: BuildEntryOption;
147
- /**
148
- * paths config
149
- */
150
- paths?: {
151
- /**
152
- * Path to asar file
153
- * @default `release/${app.name}.asar`
154
- */
155
- asarOutputPath?: string;
156
- /**
157
- * Path to version info output, content is {@link UpdateJSON}
158
- * @default `version.json`
159
- */
160
- versionPath?: string;
161
- /**
162
- * Path to gzipped asar file
163
- * @default `release/${app.name}-${version}.asar.gz`
164
- */
165
- gzipPath?: string;
166
- /**
167
- * Path to electron build output
168
- * @default `dist-electron`
169
- */
170
- electronDistPath?: string;
171
- /**
172
- * Path to renderer build output
173
- * @default `dist`
174
- */
175
- rendererDistPath?: string;
176
- };
177
- /**
178
- * signature config
179
- */
180
- keys?: {
181
- /**
182
- * path to the pem file that contains private key
183
- * if not ended with .pem, it will be appended
184
- *
185
- * **if `UPDATER_PK` is set, will read it instead of read from `privateKeyPath`**
186
- * @default 'keys/private.pem'
187
- */
188
- privateKeyPath?: string;
189
- /**
190
- * path to the pem file that contains public key
191
- * if not ended with .pem, it will be appended
192
- *
193
- * **if `UPDATER_CERT` is set, will read it instead of read from `certPath`**
194
- * @default 'keys/cert.pem'
195
- */
196
- certPath?: string;
197
- /**
198
- * length of the key
199
- * @default 2048
200
- */
201
- keyLength?: number;
202
- /**
203
- * X509 certificate info
204
- *
205
- * only generate simple **self-signed** certificate **without extensions**
206
- */
207
- certInfo?: {
208
- /**
209
- * the subject of the certificate
210
- *
211
- * @default { commonName: `${app.name}`, organizationName: `org.${app.name}` }
212
- */
213
- subject?: DistinguishedName;
214
- /**
215
- * expire days of the certificate
216
- *
217
- * @default 3650
218
- */
219
- days?: number;
220
- };
221
- overrideGenerator?: GeneratorOverrideFunctions;
222
- };
223
- };
224
-
225
- type BytecodeOptions = {
226
- /**
227
- * strings that should be transformed
228
- */
229
- protectedStrings?: string[];
230
- /**
231
- * Remember to set `sandbox: false` when creating window
232
- */
233
- enablePreload?: boolean;
234
- };
235
-
236
- type MakeRequired<T, K extends keyof T> = Exclude<T, undefined> & {
237
- [P in K]-?: T[P];
238
- };
239
- type ReplaceKey<T, Key extends keyof T, NewKey extends string> = Omit<T, Key> & {
240
- [P in NewKey]: T[Key];
241
- };
242
- type MakeRequiredAndReplaceKey<T, K extends keyof T, NewKey extends string> = MakeRequired<ReplaceKey<T, K, NewKey>, NewKey>;
243
- /**
244
- * startup function for debug (see {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template})
245
- * @example
246
- * import { debugStartup, buildElectronPluginOptions } from 'electron-incremental-update/vite'
247
- * const options = buildElectronPluginOptions({
248
- * // ...
249
- * main: {
250
- * // ...
251
- * startup: debugStartup
252
- * },
253
- * })
254
- */
255
- declare function debugStartup(args: {
256
- startup: (argv?: string[]) => Promise<void>;
257
- reload: () => void;
258
- }): void;
259
- type ElectronWithUpdaterOptions = {
260
- /**
261
- * whether is in build mode
262
- * ```ts
263
- * export default defineConfig(({ command }) => {
264
- * const isBuild = command === 'build'
265
- * })
266
- * ```
267
- */
268
- isBuild: boolean;
269
- /**
270
- * manually setup package.json, read name, version and main
271
- * ```ts
272
- * import pkg from './package.json'
273
- * ```
274
- */
275
- pkg?: PKG;
276
- /**
277
- * whether to generate sourcemap
278
- * @default !isBuild
279
- */
280
- sourcemap?: boolean;
281
- /**
282
- * whether to minify the code
283
- * @default isBuild
284
- */
285
- minify?: boolean;
286
- /**
287
- * whether to generate bytecode
288
- *
289
- * **only support commonjs**
290
- *
291
- * 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
- */
293
- bytecode?: boolean | BytecodeOptions;
294
- /**
295
- * use NotBundle() plugin in main
296
- * @default true
297
- */
298
- useNotBundle?: boolean;
299
- /**
300
- * Whether to log parsed options
301
- *
302
- * to show certificate and private keys, set `logParsedOptions: { showKeys: true }`
303
- */
304
- logParsedOptions?: boolean | {
305
- showKeys: boolean;
306
- };
307
- /**
308
- * main options
309
- */
310
- main: MakeRequiredAndReplaceKey<ElectronSimpleOptions['main'], 'entry', 'files'>;
311
- /**
312
- * preload options
313
- */
314
- preload: MakeRequiredAndReplaceKey<Exclude<ElectronSimpleOptions['preload'], undefined>, 'input', 'files'>;
315
- /**
316
- * updater options
317
- */
318
- updater?: ElectronUpdaterOptions;
319
- };
320
- /**
321
- * build options for `vite-plugin-electron/simple`
322
- * - integrate with updater
323
- * - only contains `main` and `preload` configs
324
- * - remove old electron files
325
- * - externalize dependencies
326
- * - auto restart when entry file changes
327
- * - 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
- *
330
- * you can override all the configs
331
- *
332
- * **Limitation**: entry file change cannot trigger auto restart
333
- *
334
- * @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
- */
370
- declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<(Plugin<any> | Promise<Plugin<any>[]> | undefined)[] | null>;
371
-
372
- export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater };