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

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 ADDED
@@ -0,0 +1,397 @@
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
+ size: number;
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
+ * whether to minify
43
+ * @default isBuild
44
+ */
45
+ minify?: boolean;
46
+ /**
47
+ * whether to generate sourcemap
48
+ * @default isBuild
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
+ * __SIGNATURE_CERT__: JSON.stringify(cert),
91
+ * },
92
+ * }
93
+ * ```
94
+ */
95
+ overrideEsbuildOptions?: BuildOptions;
96
+ /**
97
+ * resolve extra files on startup, such as `.node`
98
+ * @remark won't trigger will reload
99
+ */
100
+ postBuild?: (args: {
101
+ /**
102
+ * get path from `entryOutputDirPath`
103
+ */
104
+ getPathFromEntryOutputDir: (...paths: string[]) => string;
105
+ /**
106
+ * check exist and copy file to `entryOutputDirPath`
107
+ *
108
+ * if `to` absent, set to `basename(from)`
109
+ *
110
+ * if `skipIfExist` absent, skip copy if `to` exist
111
+ */
112
+ copyToEntryOutputDir: (options: {
113
+ from: string;
114
+ to?: string;
115
+ /**
116
+ * skip copy if `to` exist
117
+ * @default true
118
+ */
119
+ skipIfExist?: boolean;
120
+ }) => void;
121
+ }) => Promisable<void>;
122
+ }
123
+ interface GeneratorOverrideFunctions {
124
+ /**
125
+ * custom signature generate function
126
+ * @param buffer file buffer
127
+ * @param privateKey private key
128
+ * @param cert certificate string, **EOL must be '\n'**
129
+ * @param version current version
130
+ */
131
+ generateSignature?: (buffer: Buffer, privateKey: string, cert: string, version: string) => string | Promise<string>;
132
+ /**
133
+ * custom generate version json function
134
+ * @param existingJson The existing JSON object.
135
+ * @param buffer file buffer
136
+ * @param signature generated signature
137
+ * @param version current version
138
+ * @param minVersion The minimum version
139
+ * @returns The updated version json
140
+ */
141
+ generateVersionJson?: (existingJson: UpdateJSON, buffer: Buffer, signature: string, version: string, minVersion: string) => UpdateJSON | Promise<UpdateJSON>;
142
+ /**
143
+ * custom generate zip file buffer
144
+ * @param buffer source buffer
145
+ */
146
+ generateGzipFile?: (buffer: Buffer) => Promise<Buffer>;
147
+ }
148
+ interface ElectronUpdaterOptions {
149
+ /**
150
+ * mini version of entry
151
+ * @default '0.0.0'
152
+ */
153
+ minimumVersion?: string;
154
+ /**
155
+ * config for entry (app.asar)
156
+ */
157
+ entry?: BuildEntryOption;
158
+ /**
159
+ * paths config
160
+ */
161
+ paths?: {
162
+ /**
163
+ * Path to asar file
164
+ * @default `release/${app.name}.asar`
165
+ */
166
+ asarOutputPath?: string;
167
+ /**
168
+ * Path to version info output, content is {@link UpdateJSON}
169
+ * @default `version.json`
170
+ */
171
+ versionPath?: string;
172
+ /**
173
+ * Path to gzipped asar file
174
+ * @default `release/${app.name}-${version}.asar.gz`
175
+ */
176
+ gzipPath?: string;
177
+ /**
178
+ * Path to electron build output
179
+ * @default `dist-electron`
180
+ */
181
+ electronDistPath?: string;
182
+ /**
183
+ * Path to renderer build output
184
+ * @default `dist`
185
+ */
186
+ rendererDistPath?: string;
187
+ };
188
+ /**
189
+ * signature config
190
+ */
191
+ keys?: {
192
+ /**
193
+ * path to the pem file that contains private key
194
+ * if not ended with .pem, it will be appended
195
+ *
196
+ * **if `UPDATER_PK` is set, will read it instead of read from `privateKeyPath`**
197
+ * @default 'keys/private.pem'
198
+ */
199
+ privateKeyPath?: string;
200
+ /**
201
+ * path to the pem file that contains public key
202
+ * if not ended with .pem, it will be appended
203
+ *
204
+ * **if `UPDATER_CERT` is set, will read it instead of read from `certPath`**
205
+ * @default 'keys/cert.pem'
206
+ */
207
+ certPath?: string;
208
+ /**
209
+ * length of the key
210
+ * @default 2048
211
+ */
212
+ keyLength?: number;
213
+ /**
214
+ * X509 certificate info
215
+ *
216
+ * only generate simple **self-signed** certificate **without extensions**
217
+ */
218
+ certInfo?: {
219
+ /**
220
+ * the subject of the certificate
221
+ *
222
+ * @default { commonName: `${app.name}`, organizationName: `org.${app.name}` }
223
+ */
224
+ subject?: DistinguishedName;
225
+ /**
226
+ * expire days of the certificate
227
+ *
228
+ * @default 3650
229
+ */
230
+ days?: number;
231
+ };
232
+ };
233
+ overrideGenerator?: GeneratorOverrideFunctions;
234
+ }
235
+
236
+ interface BytecodeOptions {
237
+ /**
238
+ * strings that should be transformed
239
+ */
240
+ protectedStrings?: string[];
241
+ /**
242
+ * Remember to set `sandbox: false` when creating window
243
+ */
244
+ enablePreload?: boolean;
245
+ }
246
+
247
+ type MakeRequired<T, K extends keyof T> = Exclude<T, undefined> & {
248
+ [P in K]-?: T[P];
249
+ };
250
+ type ReplaceKey<T, Key extends keyof T, NewKey extends string> = Omit<T, Key> & {
251
+ [P in NewKey]: T[Key];
252
+ };
253
+ type MakeRequiredAndReplaceKey<T, K extends keyof T, NewKey extends string> = MakeRequired<ReplaceKey<T, K, NewKey>, NewKey>;
254
+ /**
255
+ * startup function for debug (see {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template})
256
+ * @example
257
+ * import { debugStartup, buildElectronPluginOptions } from 'electron-incremental-update/vite'
258
+ * const options = buildElectronPluginOptions({
259
+ * // ...
260
+ * main: {
261
+ * // ...
262
+ * startup: debugStartup
263
+ * },
264
+ * })
265
+ */
266
+ declare function debugStartup(args: {
267
+ startup: (argv?: string[]) => Promise<void>;
268
+ reload: () => void;
269
+ }): void;
270
+ type ExcludeOutputDirOptions = {
271
+ vite?: {
272
+ build?: {
273
+ outDir: never;
274
+ rollupOptions?: {
275
+ output?: {
276
+ dir: never;
277
+ };
278
+ };
279
+ };
280
+ };
281
+ };
282
+ interface ElectronWithUpdaterOptions {
283
+ /**
284
+ * whether is in build mode
285
+ * ```ts
286
+ * export default defineConfig(({ command }) => {
287
+ * const isBuild = command === 'build'
288
+ * })
289
+ * ```
290
+ */
291
+ isBuild: boolean;
292
+ /**
293
+ * manually setup package.json, read name, version and main
294
+ * ```ts
295
+ * import pkg from './package.json'
296
+ * ```
297
+ */
298
+ pkg?: PKG;
299
+ /**
300
+ * whether to generate sourcemap
301
+ * @default !isBuild
302
+ */
303
+ sourcemap?: boolean;
304
+ /**
305
+ * whether to minify the code
306
+ * @default isBuild
307
+ */
308
+ minify?: boolean;
309
+ /**
310
+ * whether to generate bytecode
311
+ *
312
+ * **only support commonjs**
313
+ *
314
+ * 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
315
+ */
316
+ bytecode?: boolean | BytecodeOptions;
317
+ /**
318
+ * use NotBundle() plugin in main
319
+ * @default true
320
+ */
321
+ useNotBundle?: boolean;
322
+ /**
323
+ * Whether to log parsed options
324
+ *
325
+ * to show certificate and private keys, set `logParsedOptions: { showKeys: true }`
326
+ */
327
+ logParsedOptions?: boolean | {
328
+ showKeys: boolean;
329
+ };
330
+ /**
331
+ * main process options
332
+ *
333
+ * to change output directories, use `options.updater.paths.electronDistPath` instead
334
+ */
335
+ main: MakeRequiredAndReplaceKey<ElectronSimpleOptions['main'], 'entry', 'files'> & ExcludeOutputDirOptions;
336
+ /**
337
+ * preload process options
338
+ *
339
+ * to change output directories, use `options.updater.paths.electronDistPath` instead
340
+ */
341
+ preload: MakeRequiredAndReplaceKey<Exclude<ElectronSimpleOptions['preload'], undefined>, 'input', 'files'> & ExcludeOutputDirOptions;
342
+ /**
343
+ * updater options
344
+ */
345
+ updater?: ElectronUpdaterOptions;
346
+ }
347
+ /**
348
+ * build options for `vite-plugin-electron/simple`
349
+ * - integrate with updater
350
+ * - only contains `main` and `preload` configs
351
+ * - remove old electron files
352
+ * - externalize dependencies
353
+ * - auto restart when entry file changes
354
+ * - other configs in {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template}
355
+ * - no `vite-plugin-electron-renderer` config
356
+ *
357
+ * you can override all the vite configs, except output directories (use `options.updater.paths.electronDistPath` instead)
358
+ *
359
+ * @example
360
+ * import { defineConfig } from 'vite'
361
+ * import { debugStartup, electronWithUpdater } from 'electron-incremental-update/vite'
362
+ * import pkg from './package.json'
363
+ *
364
+ * export default defineConfig(async ({ command }) => {
365
+ * const isBuild = command === 'build'
366
+ * return {
367
+ * plugins: [
368
+ * electronWithUpdater({
369
+ * pkg,
370
+ * isBuild,
371
+ * logParsedOptions: true,
372
+ * main: {
373
+ * files: ['./electron/main/index.ts', './electron/main/worker.ts'],
374
+ * // see https://github.com/electron-vite/electron-vite-vue/blob/85ed267c4851bf59f32888d766c0071661d4b94c/vite.config.ts#L22-L28
375
+ * onstart: debugStartup,
376
+ * },
377
+ * preload: {
378
+ * files: './electron/preload/index.ts',
379
+ * },
380
+ * updater: {
381
+ * // options
382
+ * }
383
+ * }),
384
+ * ],
385
+ * server: process.env.VSCODE_DEBUG && (() => {
386
+ * const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
387
+ * return {
388
+ * host: url.hostname,
389
+ * port: +url.port,
390
+ * }
391
+ * })(),
392
+ * }
393
+ * })
394
+ */
395
+ declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<PluginOption[] | undefined>;
396
+
397
+ export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater };
package/dist/vite.js CHANGED
@@ -171,10 +171,11 @@ async function buildAsar({
171
171
  renameSync(rendererDistPath, join(electronDistPath, "renderer"));
172
172
  writeFileSync(join(electronDistPath, "version"), version);
173
173
  await Asar.createPackage(electronDistPath, asarOutputPath);
174
- await generateGzipFile(readFileSync(asarOutputPath), gzipPath);
174
+ const buf = await generateGzipFile(readFileSync(asarOutputPath));
175
+ writeFileSync(gzipPath, buf);
176
+ return buf;
175
177
  }
176
178
  async function buildVersion({
177
- gzipPath,
178
179
  versionPath,
179
180
  privateKey,
180
181
  cert,
@@ -182,7 +183,7 @@ async function buildVersion({
182
183
  minimumVersion,
183
184
  generateSignature,
184
185
  generateVersionJson
185
- }) {
186
+ }, asarBuffer) {
186
187
  let _json = {
187
188
  beta: {
188
189
  minimumVersion: version,
@@ -201,14 +202,13 @@ async function buildVersion({
201
202
  if (isUpdateJSON(oldVersionJson)) {
202
203
  _json = oldVersionJson;
203
204
  } else {
204
- log.warn("old version json is invalid, ignore it");
205
+ log.warn("old version json is invalid, ignore it", { timestamp: true });
205
206
  }
206
207
  } catch {
207
208
  }
208
209
  }
209
- const buffer = readFileSync(gzipPath);
210
- const sig = await generateSignature(buffer, privateKey, cert, version);
211
- _json = await generateVersionJson(_json, buffer, sig, version, minimumVersion);
210
+ const sig = await generateSignature(asarBuffer, privateKey, cert, version);
211
+ _json = await generateVersionJson(_json, asarBuffer, sig, version, minimumVersion);
212
212
  if (!isUpdateJSON(_json)) {
213
213
  throw new Error("invalid version info");
214
214
  }
@@ -280,14 +280,14 @@ function getCert(code) {
280
280
  const cert = code.match(/-----BEGIN CERTIFICATE-----[\s\S]*-----END CERTIFICATE-----\\n/)?.[0];
281
281
  return cert ? [cert] : [];
282
282
  }
283
- async function defaultZipFile(buffer, targetFilePath) {
283
+ async function defaultZipFile(buffer) {
284
284
  return new Promise((resolve2, reject) => {
285
285
  brotliCompress(buffer, (err, buffer2) => {
286
286
  if (err) {
287
287
  reject(err);
288
+ } else {
289
+ resolve2(buffer2);
288
290
  }
289
- writeFileSync(targetFilePath, buffer2);
290
- resolve2();
291
291
  });
292
292
  });
293
293
  }
@@ -328,15 +328,21 @@ function parseKeys({
328
328
  days
329
329
  }) {
330
330
  const keysDir = dirname(privateKeyPath);
331
+ let privateKey = process.env.UPDATER_PK;
332
+ let cert = process.env.UPDATER_CERT;
333
+ if (privateKey && cert) {
334
+ log.info("use UPDATER_PK and UPDATER_CERT from environment variables", { timestamp: true });
335
+ return { privateKey, cert };
336
+ }
331
337
  if (!existsSync(keysDir)) {
332
338
  mkdirSync(keysDir);
333
339
  }
334
340
  if (!existsSync(privateKeyPath) || !existsSync(certPath)) {
335
- log.warn("no key pair found, generate new key pair");
341
+ log.info("no key pair found, generate new key pair", { timestamp: true });
336
342
  generateKeyPair(keyLength, parseSubjects(subject), days, privateKeyPath, certPath);
337
343
  }
338
- const privateKey = process.env.UPDATER_PK || readFileSync(privateKeyPath, "utf-8");
339
- const cert = process.env.UPDATER_CERT || readFileSync(certPath, "utf-8");
344
+ privateKey = readFileSync(privateKeyPath, "utf-8");
345
+ cert = readFileSync(certPath, "utf-8");
340
346
  return { privateKey, cert };
341
347
  }
342
348
  function parseSubjects(subject) {
@@ -367,7 +373,13 @@ function parseOptions(pkg, sourcemap = false, minify = false, options = {}) {
367
373
  privateKeyPath = "keys/private.pem",
368
374
  certPath = "keys/cert.pem",
369
375
  keyLength = 2048,
370
- certInfo = {}
376
+ certInfo: {
377
+ subject = {
378
+ commonName: pkg.name,
379
+ organizationName: `org.${pkg.name}`
380
+ },
381
+ days = 3650
382
+ } = {}
371
383
  } = {},
372
384
  overrideGenerator: {
373
385
  generateGzipFile = defaultZipFile,
@@ -375,13 +387,6 @@ function parseOptions(pkg, sourcemap = false, minify = false, options = {}) {
375
387
  generateVersionJson = defaultVersionJsonGenerator
376
388
  } = {}
377
389
  } = options;
378
- let {
379
- subject = {
380
- commonName: pkg.name,
381
- organizationName: `org.${pkg.name}`
382
- },
383
- days = 3650
384
- } = certInfo;
385
390
  const buildAsarOption = {
386
391
  version: pkg.version,
387
392
  asarOutputPath,
@@ -408,7 +413,6 @@ function parseOptions(pkg, sourcemap = false, minify = false, options = {}) {
408
413
  const buildVersionOption = {
409
414
  version: pkg.version,
410
415
  minimumVersion,
411
- gzipPath,
412
416
  privateKey,
413
417
  cert,
414
418
  versionPath,
@@ -417,6 +421,19 @@ function parseOptions(pkg, sourcemap = false, minify = false, options = {}) {
417
421
  };
418
422
  return { buildAsarOption, buildEntryOption, buildVersionOption, postBuild, cert };
419
423
  }
424
+
425
+ // src/build-plugins/utils.ts
426
+ function readableSize(size) {
427
+ const units = ["B", "KB", "MB", "GB"];
428
+ let i = 0;
429
+ while (size >= 1024 && i < units.length - 1) {
430
+ size /= 1024;
431
+ i++;
432
+ }
433
+ return `${size.toFixed(2)} ${units[i]}`;
434
+ }
435
+
436
+ // src/build-plugins/bytecode/index.ts
420
437
  function bytecodePlugin(isBuild, env, options = {}) {
421
438
  if (!isBuild) {
422
439
  return null;
@@ -553,9 +570,8 @@ ${bytecodeLoaderBlock}`) : _code;
553
570
  closeBundle() {
554
571
  const outDir = `${normalizePath(path2.relative(config.root, path2.resolve(config.root, config.build.outDir)))}/`;
555
572
  bytecodeFiles.forEach((file) => {
556
- const kbs = file.size / 1e3;
557
573
  bytecodeLog.info(
558
- `${outDir}${file.name} => ${kbs.toFixed(2)} kB`,
574
+ `${outDir}${file.name} => ${readableSize(file.size)}`,
559
575
  { timestamp: true }
560
576
  );
561
577
  });
@@ -641,7 +657,7 @@ async function electronWithUpdater(options) {
641
657
  __EIU_MAIN_DEV_DIR__: JSON.stringify(buildAsarOption.electronDistPath),
642
658
  __EIU_MAIN_FILE__: JSON.stringify(getMainFilePath(_main.files)),
643
659
  __EIU_SIGNATURE_CERT__: JSON.stringify(cert),
644
- __EUI_VERSION_PATH__: JSON.stringify(parseVersionPath(buildVersionOption.versionPath))
660
+ __EIU_VERSION_PATH__: JSON.stringify(parseVersionPath(buildVersionOption.versionPath))
645
661
  };
646
662
  const _buildEntry = async () => {
647
663
  await buildEntry(
@@ -721,9 +737,9 @@ async function electronWithUpdater(options) {
721
737
  async closeBundle() {
722
738
  await _buildEntry();
723
739
  await _postBuild();
724
- await buildAsar(buildAsarOption);
725
- log.info(`build asar to '${buildAsarOption.asarOutputPath}'`, { timestamp: true });
726
- await buildVersion(buildVersionOption);
740
+ const buffer = await buildAsar(buildAsarOption);
741
+ log.info(`build update asar to '${buildAsarOption.gzipPath}' => ${readableSize(buffer.length)}`, { timestamp: true });
742
+ await buildVersion(buildVersionOption, buffer);
727
743
  log.info(`build version info to '${buildVersionOption.versionPath}'`, { timestamp: true });
728
744
  }
729
745
  }
@@ -4,6 +4,7 @@ declare function defaultSignature(buffer: Buffer, privateKey: string, cert: stri
4
4
  declare function aesDecrypt(encryptedText: string, key: Buffer, iv: Buffer): string;
5
5
  declare function defaultVerify(buffer: Buffer, signature: string, cert: string): string | undefined;
6
6
 
7
- declare function defaultUnzipFile(buffer: Buffer, targetFilePath: string): Promise<void>;
7
+ declare function defaultZipFile(buffer: Buffer): Promise<Buffer>;
8
+ declare function defaultUnzipFile(buffer: Buffer): Promise<Buffer>;
8
9
 
9
- export { aesEncrypt as a, defaultSignature as b, aesDecrypt as c, defaultUnzipFile as d, defaultVerify as e, hashBuffer as h };
10
+ export { defaultUnzipFile as a, aesEncrypt as b, defaultSignature as c, defaultZipFile as d, aesDecrypt as e, defaultVerify as f, hashBuffer as h };
@@ -4,6 +4,7 @@ declare function defaultSignature(buffer: Buffer, privateKey: string, cert: stri
4
4
  declare function aesDecrypt(encryptedText: string, key: Buffer, iv: Buffer): string;
5
5
  declare function defaultVerify(buffer: Buffer, signature: string, cert: string): string | undefined;
6
6
 
7
- declare function defaultUnzipFile(buffer: Buffer, targetFilePath: string): Promise<void>;
7
+ declare function defaultZipFile(buffer: Buffer): Promise<Buffer>;
8
+ declare function defaultUnzipFile(buffer: Buffer): Promise<Buffer>;
8
9
 
9
- export { aesEncrypt as a, defaultSignature as b, aesDecrypt as c, defaultUnzipFile as d, defaultVerify as e, hashBuffer as h };
10
+ export { defaultUnzipFile as a, aesEncrypt as b, defaultSignature as c, defaultZipFile as d, aesDecrypt as e, defaultVerify as f, hashBuffer as h };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.3",
4
+ "version": "2.0.0-beta.4",
5
5
  "description": "electron incremental update tools, powered by vite",
6
6
  "author": "subframe7536",
7
7
  "license": "MIT",
@@ -78,4 +78,4 @@
78
78
  "vite-plugin-electron": "^0.28.7",
79
79
  "vitest": "^2.0.3"
80
80
  }
81
- }
81
+ }
@@ -1,33 +0,0 @@
1
- /**
2
- * handle all unhandled error
3
- * @param callback callback function
4
- */
5
- declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
6
- interface Version {
7
- major: number;
8
- minor: number;
9
- patch: number;
10
- stage: string;
11
- stageVersion: number;
12
- }
13
- declare function parseVersion(version: string): Version;
14
- declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
15
- /**
16
- * update info json
17
- */
18
- type UpdateInfo = {
19
- signature: string;
20
- minimumVersion: string;
21
- version: string;
22
- size: number;
23
- };
24
- /**
25
- * {@link UpdateInfo} with beta
26
- */
27
- type UpdateJSON = UpdateInfo & {
28
- beta: UpdateInfo;
29
- };
30
- declare function isUpdateJSON(json: any): json is UpdateJSON;
31
- declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, buffer: Buffer, signature: string, version: string, minimumVersion: string): UpdateJSON;
32
-
33
- export { type UpdateJSON as U, type Version as V, type UpdateInfo as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, handleUnexpectedErrors as h, isUpdateJSON as i, parseVersion as p };
@@ -1,33 +0,0 @@
1
- /**
2
- * handle all unhandled error
3
- * @param callback callback function
4
- */
5
- declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
6
- interface Version {
7
- major: number;
8
- minor: number;
9
- patch: number;
10
- stage: string;
11
- stageVersion: number;
12
- }
13
- declare function parseVersion(version: string): Version;
14
- declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
15
- /**
16
- * update info json
17
- */
18
- type UpdateInfo = {
19
- signature: string;
20
- minimumVersion: string;
21
- version: string;
22
- size: number;
23
- };
24
- /**
25
- * {@link UpdateInfo} with beta
26
- */
27
- type UpdateJSON = UpdateInfo & {
28
- beta: UpdateInfo;
29
- };
30
- declare function isUpdateJSON(json: any): json is UpdateJSON;
31
- declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, buffer: Buffer, signature: string, version: string, minimumVersion: string): UpdateJSON;
32
-
33
- export { type UpdateJSON as U, type Version as V, type UpdateInfo as a, defaultVersionJsonGenerator as b, defaultIsLowerVersion as d, handleUnexpectedErrors as h, isUpdateJSON as i, parseVersion as p };