electron-incremental-update 2.0.0-beta.1 → 2.0.0-beta.11

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/utils.js CHANGED
@@ -1,62 +1,3 @@
1
- import {
2
- decrypt,
3
- disableHWAccForWin7,
4
- encrypt,
5
- getAppVersion,
6
- getEntryVersion,
7
- getPathFromAppNameAsar,
8
- getPathFromEntryAsar,
9
- getPathFromPreload,
10
- getPathFromPublic,
11
- handleUnexpectedErrors,
12
- hashString,
13
- isDev,
14
- isLinux,
15
- isLowerVersionDefault,
16
- isMac,
17
- isUpdateJSON,
18
- isWin,
19
- loadPage,
20
- parseVersion,
21
- requireNative,
22
- restartApp,
23
- setAppUserModelId,
24
- setPortableAppDataPath,
25
- signature,
26
- singleInstance,
27
- unzipFile,
28
- verifySignatureDefault,
29
- waitAppReady,
30
- zipFile
31
- } from "./chunk-RSLOPAIZ.js";
32
- export {
33
- decrypt,
34
- disableHWAccForWin7,
35
- encrypt,
36
- getAppVersion,
37
- getEntryVersion,
38
- getPathFromAppNameAsar,
39
- getPathFromEntryAsar,
40
- getPathFromPreload,
41
- getPathFromPublic,
42
- handleUnexpectedErrors,
43
- hashString,
44
- isDev,
45
- isLinux,
46
- isLowerVersionDefault,
47
- isMac,
48
- isUpdateJSON,
49
- isWin,
50
- loadPage,
51
- parseVersion,
52
- requireNative,
53
- restartApp,
54
- setAppUserModelId,
55
- setPortableAppDataPath,
56
- signature,
57
- singleInstance,
58
- unzipFile,
59
- verifySignatureDefault,
60
- waitAppReady,
61
- zipFile
62
- };
1
+ export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromMain, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance } from './chunk-IABBXJFB.js';
2
+ export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultZipFile, hashBuffer } from './chunk-KZSYEXLO.js';
3
+ export { defaultIsLowerVersion, defaultVersionJsonGenerator, isUpdateJSON, parseVersion } from './chunk-RCRKUKFX.js';
@@ -0,0 +1,62 @@
1
+ interface Version {
2
+ /**
3
+ * `4` of `4.3.2-beta.1`
4
+ */
5
+ major: number;
6
+ /**
7
+ * `3` of `4.3.2-beta.1`
8
+ */
9
+ minor: number;
10
+ /**
11
+ * `2` of `4.3.2-beta.1`
12
+ */
13
+ patch: number;
14
+ /**
15
+ * `beta` of `4.3.2-beta.1`
16
+ */
17
+ stage: string;
18
+ /**
19
+ * `1` of `4.3.2-beta.1`
20
+ */
21
+ stageVersion: number;
22
+ }
23
+ /**
24
+ * Parse version string to {@link Version}, like `0.2.0-beta.1`
25
+ * @param version version string
26
+ */
27
+ declare function parseVersion(version: string): Version;
28
+ /**
29
+ * Default function to check the old version is less than new version
30
+ * @param oldVer old version string
31
+ * @param newVer new version string
32
+ */
33
+ declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
34
+ /**
35
+ * Update info json
36
+ */
37
+ type UpdateInfo = {
38
+ signature: string;
39
+ minimumVersion: string;
40
+ version: string;
41
+ };
42
+ /**
43
+ * {@link UpdateInfo} with beta
44
+ */
45
+ type UpdateJSON = UpdateInfo & {
46
+ beta: UpdateInfo;
47
+ };
48
+ /**
49
+ * Check is `UpdateJSON`
50
+ * @param json any variable
51
+ */
52
+ declare function isUpdateJSON(json: any): json is UpdateJSON;
53
+ /**
54
+ * Default function to generate `UpdateJSON`
55
+ * @param existingJson exising update json
56
+ * @param signature sigature
57
+ * @param version target version
58
+ * @param minimumVersion minimum version
59
+ */
60
+ declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
61
+
62
+ export { type UpdateInfo as U, type Version as V, type UpdateJSON as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
@@ -0,0 +1,62 @@
1
+ interface Version {
2
+ /**
3
+ * `4` of `4.3.2-beta.1`
4
+ */
5
+ major: number;
6
+ /**
7
+ * `3` of `4.3.2-beta.1`
8
+ */
9
+ minor: number;
10
+ /**
11
+ * `2` of `4.3.2-beta.1`
12
+ */
13
+ patch: number;
14
+ /**
15
+ * `beta` of `4.3.2-beta.1`
16
+ */
17
+ stage: string;
18
+ /**
19
+ * `1` of `4.3.2-beta.1`
20
+ */
21
+ stageVersion: number;
22
+ }
23
+ /**
24
+ * Parse version string to {@link Version}, like `0.2.0-beta.1`
25
+ * @param version version string
26
+ */
27
+ declare function parseVersion(version: string): Version;
28
+ /**
29
+ * Default function to check the old version is less than new version
30
+ * @param oldVer old version string
31
+ * @param newVer new version string
32
+ */
33
+ declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
34
+ /**
35
+ * Update info json
36
+ */
37
+ type UpdateInfo = {
38
+ signature: string;
39
+ minimumVersion: string;
40
+ version: string;
41
+ };
42
+ /**
43
+ * {@link UpdateInfo} with beta
44
+ */
45
+ type UpdateJSON = UpdateInfo & {
46
+ beta: UpdateInfo;
47
+ };
48
+ /**
49
+ * Check is `UpdateJSON`
50
+ * @param json any variable
51
+ */
52
+ declare function isUpdateJSON(json: any): json is UpdateJSON;
53
+ /**
54
+ * Default function to generate `UpdateJSON`
55
+ * @param existingJson exising update json
56
+ * @param signature sigature
57
+ * @param version target version
58
+ * @param minimumVersion minimum version
59
+ */
60
+ declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
61
+
62
+ export { type UpdateInfo as U, type Version as V, type UpdateJSON as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
package/dist/vite.d.ts ADDED
@@ -0,0 +1,372 @@
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
+ export { isCI } from 'ci-info';
6
+
7
+ /**
8
+ * Update info json
9
+ */
10
+ type UpdateInfo = {
11
+ signature: string;
12
+ minimumVersion: string;
13
+ version: string;
14
+ };
15
+ /**
16
+ * {@link UpdateInfo} with beta
17
+ */
18
+ type UpdateJSON = UpdateInfo & {
19
+ beta: UpdateInfo;
20
+ };
21
+
22
+ interface PKG {
23
+ name: string;
24
+ version: string;
25
+ main: string;
26
+ type: 'commonjs' | 'module';
27
+ }
28
+ interface DistinguishedName {
29
+ countryName?: string;
30
+ stateOrProvinceName?: string;
31
+ localityName?: string;
32
+ organizationName?: string;
33
+ organizationalUnitName?: string;
34
+ commonName?: string;
35
+ serialNumber?: string;
36
+ title?: string;
37
+ description?: string;
38
+ businessCategory?: string;
39
+ emailAddress?: string;
40
+ }
41
+ interface BuildEntryOption {
42
+ /**
43
+ * Override to minify on entry
44
+ * @default isBuild
45
+ */
46
+ minify?: boolean;
47
+ /**
48
+ * Override to generate sourcemap on entry
49
+ */
50
+ sourcemap?: boolean;
51
+ /**
52
+ * Path to app entry output file
53
+ * @default 'dist-entry'
54
+ */
55
+ entryOutputDirPath?: string;
56
+ /**
57
+ * Path to app entry file
58
+ * @default 'electron/entry.ts'
59
+ */
60
+ appEntryPath?: string;
61
+ /**
62
+ * Esbuild path map of native modules in entry directory
63
+ *
64
+ * @default {}
65
+ * @example
66
+ * { db: './electron/native/db.ts' }
67
+ */
68
+ nativeModuleEntryMap?: Record<string, string>;
69
+ /**
70
+ * Custom options for esbuild
71
+ * ```ts
72
+ * // default options
73
+ * const options = {
74
+ * entryPoints: {
75
+ * entry: appEntryPath,
76
+ * ...moduleEntryMap,
77
+ * },
78
+ * bundle: true,
79
+ * platform: 'node',
80
+ * outdir: entryOutputDirPath,
81
+ * minify,
82
+ * sourcemap,
83
+ * entryNames: '[dir]/[name]',
84
+ * assetNames: '[dir]/[name]',
85
+ * external: ['electron', 'original-fs'],
86
+ * loader: {
87
+ * '.node': 'empty',
88
+ * },
89
+ * define: {
90
+ * __EIU_SIGNATURE_CERT__: JSON.stringify(cert),
91
+ * // ...
92
+ * },
93
+ * }
94
+ * ```
95
+ */
96
+ overrideEsbuildOptions?: BuildOptions;
97
+ /**
98
+ * Resolve extra files on startup, such as `.node`
99
+ * @remark won't trigger will reload
100
+ */
101
+ postBuild?: (args: {
102
+ /**
103
+ * Get path from `entryOutputDirPath`
104
+ */
105
+ getPathFromEntryOutputDir: (...paths: string[]) => string;
106
+ /**
107
+ * Check exist and copy file to `entryOutputDirPath`
108
+ *
109
+ * If `to` absent, set to `basename(from)`
110
+ *
111
+ * If `skipIfExist` absent, skip copy if `to` exist
112
+ */
113
+ copyToEntryOutputDir: (options: {
114
+ from: string;
115
+ to?: string;
116
+ /**
117
+ * Skip copy if `to` exist
118
+ * @default true
119
+ */
120
+ skipIfExist?: boolean;
121
+ }) => void;
122
+ }) => Promisable<void>;
123
+ }
124
+ interface GeneratorOverrideFunctions {
125
+ /**
126
+ * Custom signature generate function
127
+ * @param buffer file buffer
128
+ * @param privateKey private key
129
+ * @param cert certificate string, **EOL must be '\n'**
130
+ * @param version current version
131
+ */
132
+ generateSignature?: (buffer: Buffer, privateKey: string, cert: string, version: string) => Promisable<string>;
133
+ /**
134
+ * Custom generate version json function
135
+ * @param existingJson The existing JSON object.
136
+ * @param buffer file buffer
137
+ * @param signature generated signature
138
+ * @param version current version
139
+ * @param minVersion The minimum version
140
+ * @returns The updated version json
141
+ */
142
+ generateVersionJson?: (existingJson: UpdateJSON, signature: string, version: string, minVersion: string) => Promisable<UpdateJSON>;
143
+ /**
144
+ * Custom generate zip file buffer
145
+ * @param buffer source buffer
146
+ */
147
+ generateGzipFile?: (buffer: Buffer) => Promisable<Buffer>;
148
+ }
149
+ interface ElectronUpdaterOptions {
150
+ /**
151
+ * mini version of entry
152
+ * @default '0.0.0'
153
+ */
154
+ minimumVersion?: string;
155
+ /**
156
+ * config for entry (app.asar)
157
+ */
158
+ entry?: BuildEntryOption;
159
+ /**
160
+ * paths config
161
+ */
162
+ paths?: {
163
+ /**
164
+ * Path to asar file
165
+ * @default `release/${app.name}.asar`
166
+ */
167
+ asarOutputPath?: string;
168
+ /**
169
+ * Path to version info output, content is {@link UpdateJSON}
170
+ * @default `version.json`
171
+ */
172
+ versionPath?: string;
173
+ /**
174
+ * Path to gzipped asar file
175
+ * @default `release/${app.name}-${version}.asar.gz`
176
+ */
177
+ gzipPath?: string;
178
+ /**
179
+ * Path to electron build output
180
+ * @default `dist-electron`
181
+ */
182
+ electronDistPath?: string;
183
+ /**
184
+ * Path to renderer build output
185
+ * @default `dist`
186
+ */
187
+ rendererDistPath?: string;
188
+ };
189
+ /**
190
+ * signature config
191
+ */
192
+ keys?: {
193
+ /**
194
+ * path to the pem file that contains private key
195
+ * if not ended with .pem, it will be appended
196
+ *
197
+ * **if `UPDATER_PK` is set, will read it instead of read from `privateKeyPath`**
198
+ * @default 'keys/private.pem'
199
+ */
200
+ privateKeyPath?: string;
201
+ /**
202
+ * path to the pem file that contains public key
203
+ * if not ended with .pem, it will be appended
204
+ *
205
+ * **if `UPDATER_CERT` is set, will read it instead of read from `certPath`**
206
+ * @default 'keys/cert.pem'
207
+ */
208
+ certPath?: string;
209
+ /**
210
+ * length of the key
211
+ * @default 2048
212
+ */
213
+ keyLength?: number;
214
+ /**
215
+ * X509 certificate info
216
+ *
217
+ * only generate simple **self-signed** certificate **without extensions**
218
+ */
219
+ certInfo?: {
220
+ /**
221
+ * the subject of the certificate
222
+ *
223
+ * @default { commonName: `${app.name}`, organizationName: `org.${app.name}` }
224
+ */
225
+ subject?: DistinguishedName;
226
+ /**
227
+ * expire days of the certificate
228
+ *
229
+ * @default 3650
230
+ */
231
+ days?: number;
232
+ };
233
+ };
234
+ overrideGenerator?: GeneratorOverrideFunctions;
235
+ }
236
+
237
+ interface BytecodeOptions {
238
+ enable: boolean;
239
+ /**
240
+ * Enable in preload script. Remember to set `sandbox: false` when creating window
241
+ */
242
+ preload?: boolean;
243
+ /**
244
+ * Before transformed code compile function. If return `Falsy` value, it will be ignored
245
+ * @param code transformed code
246
+ * @param id file path
247
+ */
248
+ beforeCompile?: (code: string, id: string) => Promisable<string | null | undefined | void>;
249
+ }
250
+
251
+ type MakeRequired<T, K extends keyof T> = Exclude<T, undefined> & {
252
+ [P in K]-?: T[P];
253
+ };
254
+ type ReplaceKey<T, Key extends keyof T, NewKey extends string> = Omit<T, Key> & {
255
+ [P in NewKey]: T[Key];
256
+ };
257
+ type MakeRequiredAndReplaceKey<T, K extends keyof T, NewKey extends string> = MakeRequired<ReplaceKey<T, K, NewKey>, NewKey>;
258
+ /**
259
+ * startup function for debug (see {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template})
260
+ * @example
261
+ * import { debugStartup, buildElectronPluginOptions } from 'electron-incremental-update/vite'
262
+ * const options = buildElectronPluginOptions({
263
+ * // ...
264
+ * main: {
265
+ * // ...
266
+ * startup: debugStartup
267
+ * },
268
+ * })
269
+ */
270
+ declare function debugStartup(args: {
271
+ startup: (argv?: string[]) => Promise<void>;
272
+ reload: () => void;
273
+ }): void;
274
+ type ExcludeOutputDirOptions = {
275
+ vite?: {
276
+ build?: {
277
+ outDir: never;
278
+ rollupOptions?: {
279
+ output?: {
280
+ dir: never;
281
+ };
282
+ };
283
+ };
284
+ };
285
+ };
286
+ interface ElectronWithUpdaterOptions {
287
+ /**
288
+ * Whether is in build mode
289
+ * ```ts
290
+ * export default defineConfig(({ command }) => {
291
+ * const isBuild = command === 'build'
292
+ * })
293
+ * ```
294
+ */
295
+ isBuild: boolean;
296
+ /**
297
+ * Manually setup package.json, read name, version and main,
298
+ * use `local-pkg` of `loadPackageJSON()` to load package.json by default
299
+ * ```ts
300
+ * import pkg from './package.json'
301
+ * ```
302
+ */
303
+ pkg?: PKG;
304
+ /**
305
+ * Whether to generate sourcemap
306
+ * @default !isBuild
307
+ */
308
+ sourcemap?: boolean;
309
+ /**
310
+ * Whether to minify the code
311
+ * @default isBuild
312
+ */
313
+ minify?: boolean;
314
+ /**
315
+ * Whether to generate bytecode
316
+ *
317
+ * **Only support CommonJS**
318
+ *
319
+ * 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
320
+ */
321
+ bytecode?: boolean | BytecodeOptions;
322
+ /**
323
+ * Use `NotBundle()` plugin in main
324
+ * @default true
325
+ */
326
+ useNotBundle?: boolean;
327
+ /**
328
+ * Whether to generate version json
329
+ * @default isCI
330
+ */
331
+ buildVersionJson?: boolean;
332
+ /**
333
+ * Whether to log parsed options
334
+ *
335
+ * To show certificate and private keys, set `logParsedOptions: { showKeys: true }`
336
+ */
337
+ logParsedOptions?: boolean | {
338
+ showKeys: boolean;
339
+ };
340
+ /**
341
+ * Main process options
342
+ *
343
+ * To change output directories, use `options.updater.paths.electronDistPath` instead
344
+ */
345
+ main: MakeRequiredAndReplaceKey<ElectronSimpleOptions['main'], 'entry', 'files'> & ExcludeOutputDirOptions;
346
+ /**
347
+ * Preload process options
348
+ *
349
+ * To change output directories, use `options.updater.paths.electronDistPath` instead
350
+ */
351
+ preload: MakeRequiredAndReplaceKey<Exclude<ElectronSimpleOptions['preload'], undefined>, 'input', 'files'> & ExcludeOutputDirOptions;
352
+ /**
353
+ * Updater options
354
+ */
355
+ updater?: ElectronUpdaterOptions;
356
+ }
357
+ /**
358
+ * Base on `vite-plugin-electron/simple`
359
+ * - integrate with updater
360
+ * - no `renderer` config
361
+ * - remove old output file
362
+ * - externalize dependencies
363
+ * - auto restart when entry file changes
364
+ * - other configs in {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template}
365
+ *
366
+ * You can override all the vite configs, except output directories (use `options.updater.paths.electronDistPath` instead)
367
+ *
368
+ * @example
369
+ */
370
+ declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<PluginOption[] | undefined>;
371
+
372
+ export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater as default, electronWithUpdater };