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

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, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance } from './chunk-4MH6ZXCY.js';
2
+ export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultZipFile, hashBuffer } from './chunk-KZSYEXLO.js';
3
+ export { defaultIsLowerVersion, defaultVersionJsonGenerator, isUpdateJSON, parseVersion } from './chunk-72ZAJ7AF.js';
@@ -0,0 +1,62 @@
1
+ interface Version {
2
+ /**
3
+ * `2` of `2.1.0-beta.10`
4
+ */
5
+ major: number;
6
+ /**
7
+ * `1` of `2.1.0-beta.10`
8
+ */
9
+ minor: number;
10
+ /**
11
+ * `0` of `2.1.0-beta.10`
12
+ */
13
+ patch: number;
14
+ /**
15
+ * `beta` of `2.1.0-beta.10`
16
+ */
17
+ stage: string;
18
+ /**
19
+ * `10` of `2.1.0-beta.10`
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
+ * `2` of `2.1.0-beta.10`
4
+ */
5
+ major: number;
6
+ /**
7
+ * `1` of `2.1.0-beta.10`
8
+ */
9
+ minor: number;
10
+ /**
11
+ * `0` of `2.1.0-beta.10`
12
+ */
13
+ patch: number;
14
+ /**
15
+ * `beta` of `2.1.0-beta.10`
16
+ */
17
+ stage: string;
18
+ /**
19
+ * `10` of `2.1.0-beta.10`
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,370 @@
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
+ }
27
+ interface DistinguishedName {
28
+ countryName?: string;
29
+ stateOrProvinceName?: string;
30
+ localityName?: string;
31
+ organizationName?: string;
32
+ organizationalUnitName?: string;
33
+ commonName?: string;
34
+ serialNumber?: string;
35
+ title?: string;
36
+ description?: string;
37
+ businessCategory?: string;
38
+ emailAddress?: string;
39
+ }
40
+ interface BuildEntryOption {
41
+ /**
42
+ * Override to minify on entry
43
+ * @default isBuild
44
+ */
45
+ minify?: boolean;
46
+ /**
47
+ * Override to generate sourcemap on entry
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) => Promisable<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) => Promisable<UpdateJSON>;
141
+ /**
142
+ * Custom generate zip file buffer
143
+ * @param buffer source buffer
144
+ */
145
+ generateGzipFile?: (buffer: Buffer) => Promisable<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
+ enable: boolean;
237
+ /**
238
+ * Enable in preload script. Remember to set `sandbox: false` when creating window
239
+ */
240
+ preload?: boolean;
241
+ /**
242
+ * Before transformed code compile function. If return `Falsy` value, it will be ignored
243
+ * @param code transformed code
244
+ * @param id file path
245
+ */
246
+ beforeCompile?: (code: string, id: string) => Promisable<string | null | undefined | void>;
247
+ }
248
+
249
+ type MakeRequired<T, K extends keyof T> = Exclude<T, undefined> & {
250
+ [P in K]-?: T[P];
251
+ };
252
+ type ReplaceKey<T, Key extends keyof T, NewKey extends string> = Omit<T, Key> & {
253
+ [P in NewKey]: T[Key];
254
+ };
255
+ type MakeRequiredAndReplaceKey<T, K extends keyof T, NewKey extends string> = MakeRequired<ReplaceKey<T, K, NewKey>, NewKey>;
256
+ /**
257
+ * startup function for debug (see {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template})
258
+ * @example
259
+ * import { debugStartup, buildElectronPluginOptions } from 'electron-incremental-update/vite'
260
+ * const options = buildElectronPluginOptions({
261
+ * // ...
262
+ * main: {
263
+ * // ...
264
+ * startup: debugStartup
265
+ * },
266
+ * })
267
+ */
268
+ declare function debugStartup(args: {
269
+ startup: (argv?: string[]) => Promise<void>;
270
+ reload: () => void;
271
+ }): void;
272
+ type ExcludeOutputDirOptions = {
273
+ vite?: {
274
+ build?: {
275
+ outDir: never;
276
+ rollupOptions?: {
277
+ output?: {
278
+ dir: never;
279
+ };
280
+ };
281
+ };
282
+ };
283
+ };
284
+ interface ElectronWithUpdaterOptions {
285
+ /**
286
+ * Whether is in build mode
287
+ * ```ts
288
+ * export default defineConfig(({ command }) => {
289
+ * const isBuild = command === 'build'
290
+ * })
291
+ * ```
292
+ */
293
+ isBuild: boolean;
294
+ /**
295
+ * Manually setup package.json, read name, version and main,
296
+ * use `local-pkg` of `loadPackageJSON()` to load package.json by default
297
+ * ```ts
298
+ * import pkg from './package.json'
299
+ * ```
300
+ */
301
+ pkg?: PKG;
302
+ /**
303
+ * Whether to generate sourcemap
304
+ * @default !isBuild
305
+ */
306
+ sourcemap?: boolean;
307
+ /**
308
+ * Whether to minify the code
309
+ * @default isBuild
310
+ */
311
+ minify?: boolean;
312
+ /**
313
+ * Whether to generate bytecode
314
+ *
315
+ * **Only support CommonJS**
316
+ *
317
+ * 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
318
+ */
319
+ bytecode?: boolean | BytecodeOptions;
320
+ /**
321
+ * Use `NotBundle()` plugin in main
322
+ * @default true
323
+ */
324
+ useNotBundle?: boolean;
325
+ /**
326
+ * Whether to generate version json
327
+ * @default isCI
328
+ */
329
+ buildVersionJson?: boolean;
330
+ /**
331
+ * Whether to log parsed options
332
+ *
333
+ * To show certificate and private keys, set `logParsedOptions: { showKeys: true }`
334
+ */
335
+ logParsedOptions?: boolean | {
336
+ showKeys: boolean;
337
+ };
338
+ /**
339
+ * Main process options
340
+ *
341
+ * To change output directories, use `options.updater.paths.electronDistPath` instead
342
+ */
343
+ main: MakeRequiredAndReplaceKey<ElectronSimpleOptions['main'], 'entry', 'files'> & ExcludeOutputDirOptions;
344
+ /**
345
+ * Preload process options
346
+ *
347
+ * To change output directories, use `options.updater.paths.electronDistPath` instead
348
+ */
349
+ preload: MakeRequiredAndReplaceKey<Exclude<ElectronSimpleOptions['preload'], undefined>, 'input', 'files'> & ExcludeOutputDirOptions;
350
+ /**
351
+ * Updater options
352
+ */
353
+ updater?: ElectronUpdaterOptions;
354
+ }
355
+ /**
356
+ * Base on `vite-plugin-electron/simple`
357
+ * - integrate with updater
358
+ * - no `renderer` config
359
+ * - remove old output file
360
+ * - externalize dependencies
361
+ * - auto restart when entry file changes
362
+ * - other configs in {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template}
363
+ *
364
+ * You can override all the vite configs, except output directories (use `options.updater.paths.electronDistPath` instead)
365
+ *
366
+ * @example
367
+ */
368
+ declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<PluginOption[] | undefined>;
369
+
370
+ export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater as default, electronWithUpdater };