electron-incremental-update 2.0.0-beta.6 → 2.0.0-beta.7
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/core-DJdvtwvU.d.ts +134 -0
- package/dist/core-ZUlLHadf.d.cts +134 -0
- package/dist/index.d.cts +78 -0
- package/dist/index.d.ts +78 -0
- package/dist/provider.d.cts +76 -0
- package/dist/provider.d.ts +76 -0
- package/dist/types-CItP6bL-.d.cts +104 -0
- package/dist/types-CItP6bL-.d.ts +104 -0
- package/dist/utils.cjs +0 -5
- package/dist/utils.d.cts +80 -0
- package/dist/utils.d.ts +80 -0
- package/dist/utils.js +0 -1
- package/dist/vite.d.ts +402 -0
- package/dist/vite.js +17 -14
- package/dist/zip-DPF5IFkK.d.cts +10 -0
- package/dist/zip-DPF5IFkK.d.ts +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Promisable } from '@subframe7536/type-utils';
|
|
2
|
+
|
|
3
|
+
interface Version {
|
|
4
|
+
major: number;
|
|
5
|
+
minor: number;
|
|
6
|
+
patch: number;
|
|
7
|
+
stage: string;
|
|
8
|
+
stageVersion: number;
|
|
9
|
+
}
|
|
10
|
+
declare function parseVersion(version: string): Version;
|
|
11
|
+
declare function defaultIsLowerVersion(oldVer: string, newVer: string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* update info json
|
|
14
|
+
*/
|
|
15
|
+
type UpdateInfo = {
|
|
16
|
+
signature: string;
|
|
17
|
+
minimumVersion: string;
|
|
18
|
+
version: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* {@link UpdateInfo} with beta
|
|
22
|
+
*/
|
|
23
|
+
type UpdateJSON = UpdateInfo & {
|
|
24
|
+
beta: UpdateInfo;
|
|
25
|
+
};
|
|
26
|
+
declare function isUpdateJSON(json: any): json is UpdateJSON;
|
|
27
|
+
declare function defaultVersionJsonGenerator(existingJson: UpdateJSON, signature: string, version: string, minimumVersion: string): UpdateJSON;
|
|
28
|
+
|
|
29
|
+
type URLHandler = (url: URL, isDownloadAsar: boolean) => Promisable<URL | string | undefined | null>;
|
|
30
|
+
type OnDownloading = (progress: DownloadingInfo) => void;
|
|
31
|
+
interface DownloadingInfo {
|
|
32
|
+
/**
|
|
33
|
+
* download delta
|
|
34
|
+
*/
|
|
35
|
+
delta: number;
|
|
36
|
+
/**
|
|
37
|
+
* downloaded percent, 0 ~ 100
|
|
38
|
+
*
|
|
39
|
+
* If not `Content-Length` header, will be nagative
|
|
40
|
+
*/
|
|
41
|
+
percent: number;
|
|
42
|
+
/**
|
|
43
|
+
* total size
|
|
44
|
+
*
|
|
45
|
+
* If not `Content-Length` header, will be -1
|
|
46
|
+
*/
|
|
47
|
+
total: number;
|
|
48
|
+
/**
|
|
49
|
+
* downloaded size
|
|
50
|
+
*/
|
|
51
|
+
transferred: number;
|
|
52
|
+
/**
|
|
53
|
+
* download speed, bytes per second
|
|
54
|
+
*/
|
|
55
|
+
bps: number;
|
|
56
|
+
}
|
|
57
|
+
interface IProvider {
|
|
58
|
+
/**
|
|
59
|
+
* provider name
|
|
60
|
+
*/
|
|
61
|
+
name: string;
|
|
62
|
+
/**
|
|
63
|
+
* custom url handler
|
|
64
|
+
*
|
|
65
|
+
* for Github, there are some {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 public CDN links}
|
|
66
|
+
*/
|
|
67
|
+
urlHandler?: URLHandler;
|
|
68
|
+
onDownloading?: OnDownloading;
|
|
69
|
+
/**
|
|
70
|
+
* download update json
|
|
71
|
+
* @param versionPath parsed version path
|
|
72
|
+
*/
|
|
73
|
+
downloadJSON: (versionPath: string) => Promise<UpdateJSON>;
|
|
74
|
+
/**
|
|
75
|
+
* download update asar
|
|
76
|
+
* @param name app name
|
|
77
|
+
* @param updateInfo existing update info
|
|
78
|
+
* @param onDownloading hook for on downloading
|
|
79
|
+
*/
|
|
80
|
+
downloadAsar: (name: string, updateInfo: UpdateInfo, onDownloading?: (info: DownloadingInfo) => void) => Promise<Buffer>;
|
|
81
|
+
/**
|
|
82
|
+
* compare version
|
|
83
|
+
* @param oldVer old version string
|
|
84
|
+
* @param newVer new version string
|
|
85
|
+
* @returns if version1 < version2
|
|
86
|
+
*/
|
|
87
|
+
isLowerVersion: (oldVer: string, newVer: string) => boolean;
|
|
88
|
+
/**
|
|
89
|
+
* unzip file buffer
|
|
90
|
+
* @param buffer source buffer
|
|
91
|
+
*/
|
|
92
|
+
unzipFile: (buffer: Buffer) => Promise<Buffer>;
|
|
93
|
+
/**
|
|
94
|
+
* verify asar signature
|
|
95
|
+
* @param buffer file buffer
|
|
96
|
+
* @param version target version
|
|
97
|
+
* @param signature signature
|
|
98
|
+
* @param cert certificate
|
|
99
|
+
* @returns if signature is valid, returns the version, otherwise returns `undefined`
|
|
100
|
+
*/
|
|
101
|
+
verifySignaure: (buffer: Buffer, version: string, signature: string, cert: string) => Promisable<boolean>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { type DownloadingInfo as D, type IProvider as I, type OnDownloading as O, type UpdateInfo as U, type Version as V, type UpdateJSON as a, defaultVersionJsonGenerator as b, type URLHandler as c, defaultIsLowerVersion as d, isUpdateJSON as i, parseVersion as p };
|
package/dist/utils.cjs
CHANGED
|
@@ -5,7 +5,6 @@ var path = require('path');
|
|
|
5
5
|
var electron = require('electron');
|
|
6
6
|
var zlib = require('zlib');
|
|
7
7
|
var crypto = require('crypto');
|
|
8
|
-
var ciInfo = require('ci-info');
|
|
9
8
|
|
|
10
9
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
11
10
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
@@ -206,10 +205,6 @@ async function autoUpdate(updater) {
|
|
|
206
205
|
}
|
|
207
206
|
}
|
|
208
207
|
|
|
209
|
-
Object.defineProperty(exports, "isCI", {
|
|
210
|
-
enumerable: true,
|
|
211
|
-
get: function () { return ciInfo.isCI; }
|
|
212
|
-
});
|
|
213
208
|
exports.aesDecrypt = aesDecrypt;
|
|
214
209
|
exports.aesEncrypt = aesEncrypt;
|
|
215
210
|
exports.autoUpdate = autoUpdate;
|
package/dist/utils.d.cts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { BrowserWindow } from 'electron';
|
|
2
|
+
export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerifySignature, d as defaultZipFile, h as hashBuffer } from './zip-DPF5IFkK.cjs';
|
|
3
|
+
export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, i as isUpdateJSON, p as parseVersion } from './types-CItP6bL-.cjs';
|
|
4
|
+
import { U as Updater } from './core-ZUlLHadf.cjs';
|
|
5
|
+
import '@subframe7536/type-utils';
|
|
6
|
+
import 'node:events';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* compile time dev check
|
|
10
|
+
*/
|
|
11
|
+
declare const isDev: boolean;
|
|
12
|
+
declare const isWin: boolean;
|
|
13
|
+
declare const isMac: boolean;
|
|
14
|
+
declare const isLinux: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* get the absolute path of `${electron.app.name}.asar` (not `app.asar`)
|
|
17
|
+
*
|
|
18
|
+
* if is in dev, **always** return `'DEV.asar'`
|
|
19
|
+
*/
|
|
20
|
+
declare function getPathFromAppNameAsar(...path: string[]): string;
|
|
21
|
+
/**
|
|
22
|
+
* get app version, if is in dev, return `getEntryVersion()`
|
|
23
|
+
*/
|
|
24
|
+
declare function getAppVersion(): string;
|
|
25
|
+
/**
|
|
26
|
+
* get entry version
|
|
27
|
+
*/
|
|
28
|
+
declare function getEntryVersion(): string;
|
|
29
|
+
/**
|
|
30
|
+
* use `require` to load native module from entry
|
|
31
|
+
* @param moduleName file name in entry
|
|
32
|
+
*/
|
|
33
|
+
declare function requireNative<T = any>(moduleName: string): T;
|
|
34
|
+
/**
|
|
35
|
+
* Restarts the Electron app.
|
|
36
|
+
*/
|
|
37
|
+
declare function restartApp(): void;
|
|
38
|
+
/**
|
|
39
|
+
* fix app use model id, only for Windows
|
|
40
|
+
* @param id app id, default is `org.${electron.app.name}`
|
|
41
|
+
*/
|
|
42
|
+
declare function setAppUserModelId(id?: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* disable hardware acceleration for Windows 7
|
|
45
|
+
*/
|
|
46
|
+
declare function disableHWAccForWin7(): void;
|
|
47
|
+
/**
|
|
48
|
+
* keep single electron instance and auto restore window on `second-instance` event
|
|
49
|
+
* @param window brwoser window to show
|
|
50
|
+
* @returns `false` if the app is running
|
|
51
|
+
*/
|
|
52
|
+
declare function singleInstance(window?: BrowserWindow): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* set `AppData` dir to the dir of .exe file
|
|
55
|
+
*
|
|
56
|
+
* useful for portable Windows app
|
|
57
|
+
* @param dirName dir name, default to `data`
|
|
58
|
+
*/
|
|
59
|
+
declare function setPortableAppDataPath(dirName?: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
|
|
62
|
+
* @param win window
|
|
63
|
+
* @param htmlFilePath html file path, default is `index.html`
|
|
64
|
+
*/
|
|
65
|
+
declare function loadPage(win: BrowserWindow, htmlFilePath?: string): void;
|
|
66
|
+
declare function getPathFromPreload(...paths: string[]): string;
|
|
67
|
+
declare function getPathFromPublic(...paths: string[]): string;
|
|
68
|
+
declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
69
|
+
/**
|
|
70
|
+
* handle all unhandled error
|
|
71
|
+
* @param callback callback function
|
|
72
|
+
*/
|
|
73
|
+
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* auto check update, download and install
|
|
77
|
+
*/
|
|
78
|
+
declare function autoUpdate(updater: Updater): Promise<void>;
|
|
79
|
+
|
|
80
|
+
export { autoUpdate, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { BrowserWindow } from 'electron';
|
|
2
|
+
export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerifySignature, d as defaultZipFile, h as hashBuffer } from './zip-DPF5IFkK.js';
|
|
3
|
+
export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, b as defaultVersionJsonGenerator, i as isUpdateJSON, p as parseVersion } from './types-CItP6bL-.js';
|
|
4
|
+
import { U as Updater } from './core-DJdvtwvU.js';
|
|
5
|
+
import '@subframe7536/type-utils';
|
|
6
|
+
import 'node:events';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* compile time dev check
|
|
10
|
+
*/
|
|
11
|
+
declare const isDev: boolean;
|
|
12
|
+
declare const isWin: boolean;
|
|
13
|
+
declare const isMac: boolean;
|
|
14
|
+
declare const isLinux: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* get the absolute path of `${electron.app.name}.asar` (not `app.asar`)
|
|
17
|
+
*
|
|
18
|
+
* if is in dev, **always** return `'DEV.asar'`
|
|
19
|
+
*/
|
|
20
|
+
declare function getPathFromAppNameAsar(...path: string[]): string;
|
|
21
|
+
/**
|
|
22
|
+
* get app version, if is in dev, return `getEntryVersion()`
|
|
23
|
+
*/
|
|
24
|
+
declare function getAppVersion(): string;
|
|
25
|
+
/**
|
|
26
|
+
* get entry version
|
|
27
|
+
*/
|
|
28
|
+
declare function getEntryVersion(): string;
|
|
29
|
+
/**
|
|
30
|
+
* use `require` to load native module from entry
|
|
31
|
+
* @param moduleName file name in entry
|
|
32
|
+
*/
|
|
33
|
+
declare function requireNative<T = any>(moduleName: string): T;
|
|
34
|
+
/**
|
|
35
|
+
* Restarts the Electron app.
|
|
36
|
+
*/
|
|
37
|
+
declare function restartApp(): void;
|
|
38
|
+
/**
|
|
39
|
+
* fix app use model id, only for Windows
|
|
40
|
+
* @param id app id, default is `org.${electron.app.name}`
|
|
41
|
+
*/
|
|
42
|
+
declare function setAppUserModelId(id?: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* disable hardware acceleration for Windows 7
|
|
45
|
+
*/
|
|
46
|
+
declare function disableHWAccForWin7(): void;
|
|
47
|
+
/**
|
|
48
|
+
* keep single electron instance and auto restore window on `second-instance` event
|
|
49
|
+
* @param window brwoser window to show
|
|
50
|
+
* @returns `false` if the app is running
|
|
51
|
+
*/
|
|
52
|
+
declare function singleInstance(window?: BrowserWindow): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* set `AppData` dir to the dir of .exe file
|
|
55
|
+
*
|
|
56
|
+
* useful for portable Windows app
|
|
57
|
+
* @param dirName dir name, default to `data`
|
|
58
|
+
*/
|
|
59
|
+
declare function setPortableAppDataPath(dirName?: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
|
|
62
|
+
* @param win window
|
|
63
|
+
* @param htmlFilePath html file path, default is `index.html`
|
|
64
|
+
*/
|
|
65
|
+
declare function loadPage(win: BrowserWindow, htmlFilePath?: string): void;
|
|
66
|
+
declare function getPathFromPreload(...paths: string[]): string;
|
|
67
|
+
declare function getPathFromPublic(...paths: string[]): string;
|
|
68
|
+
declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
69
|
+
/**
|
|
70
|
+
* handle all unhandled error
|
|
71
|
+
* @param callback callback function
|
|
72
|
+
*/
|
|
73
|
+
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* auto check update, download and install
|
|
77
|
+
*/
|
|
78
|
+
declare function autoUpdate(updater: Updater): Promise<void>;
|
|
79
|
+
|
|
80
|
+
export { autoUpdate, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance };
|
package/dist/utils.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, isDev, isLinux, isMac, isWin, loadPage, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance } from './chunk-DFNDKSE6.js';
|
|
2
2
|
export { aesDecrypt, aesEncrypt, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultZipFile, hashBuffer } from './chunk-N77WQ5WB.js';
|
|
3
3
|
export { defaultIsLowerVersion, defaultVersionJsonGenerator, isUpdateJSON, parseVersion } from './chunk-72ZAJ7AF.js';
|
|
4
|
-
export { isCI } from 'ci-info';
|
|
5
4
|
|
|
6
5
|
// src/utils/updater.ts
|
|
7
6
|
async function autoUpdate(updater) {
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
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
|
+
* 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, 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 generate version json
|
|
324
|
+
* @default isCI
|
|
325
|
+
*/
|
|
326
|
+
buildVersionJson?: boolean;
|
|
327
|
+
/**
|
|
328
|
+
* Whether to log parsed options
|
|
329
|
+
*
|
|
330
|
+
* to show certificate and private keys, set `logParsedOptions: { showKeys: true }`
|
|
331
|
+
*/
|
|
332
|
+
logParsedOptions?: boolean | {
|
|
333
|
+
showKeys: boolean;
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* main process options
|
|
337
|
+
*
|
|
338
|
+
* to change output directories, use `options.updater.paths.electronDistPath` instead
|
|
339
|
+
*/
|
|
340
|
+
main: MakeRequiredAndReplaceKey<ElectronSimpleOptions['main'], 'entry', 'files'> & ExcludeOutputDirOptions;
|
|
341
|
+
/**
|
|
342
|
+
* preload process options
|
|
343
|
+
*
|
|
344
|
+
* to change output directories, use `options.updater.paths.electronDistPath` instead
|
|
345
|
+
*/
|
|
346
|
+
preload: MakeRequiredAndReplaceKey<Exclude<ElectronSimpleOptions['preload'], undefined>, 'input', 'files'> & ExcludeOutputDirOptions;
|
|
347
|
+
/**
|
|
348
|
+
* updater options
|
|
349
|
+
*/
|
|
350
|
+
updater?: ElectronUpdaterOptions;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* build options for `vite-plugin-electron/simple`
|
|
354
|
+
* - integrate with updater
|
|
355
|
+
* - only contains `main` and `preload` configs
|
|
356
|
+
* - remove old electron files
|
|
357
|
+
* - externalize dependencies
|
|
358
|
+
* - auto restart when entry file changes
|
|
359
|
+
* - other configs in {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template}
|
|
360
|
+
* - no `vite-plugin-electron-renderer` config
|
|
361
|
+
*
|
|
362
|
+
* you can override all the vite configs, except output directories (use `options.updater.paths.electronDistPath` instead)
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* import { defineConfig } from 'vite'
|
|
366
|
+
* import { debugStartup, electronWithUpdater } from 'electron-incremental-update/vite'
|
|
367
|
+
* import pkg from './package.json'
|
|
368
|
+
*
|
|
369
|
+
* export default defineConfig(async ({ command }) => {
|
|
370
|
+
* const isBuild = command === 'build'
|
|
371
|
+
* return {
|
|
372
|
+
* plugins: [
|
|
373
|
+
* electronWithUpdater({
|
|
374
|
+
* pkg,
|
|
375
|
+
* isBuild,
|
|
376
|
+
* logParsedOptions: true,
|
|
377
|
+
* main: {
|
|
378
|
+
* files: ['./electron/main/index.ts', './electron/main/worker.ts'],
|
|
379
|
+
* // see https://github.com/electron-vite/electron-vite-vue/blob/85ed267c4851bf59f32888d766c0071661d4b94c/vite.config.ts#L22-L28
|
|
380
|
+
* onstart: debugStartup,
|
|
381
|
+
* },
|
|
382
|
+
* preload: {
|
|
383
|
+
* files: './electron/preload/index.ts',
|
|
384
|
+
* },
|
|
385
|
+
* updater: {
|
|
386
|
+
* // options
|
|
387
|
+
* }
|
|
388
|
+
* }),
|
|
389
|
+
* ],
|
|
390
|
+
* server: process.env.VSCODE_DEBUG && (() => {
|
|
391
|
+
* const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
|
|
392
|
+
* return {
|
|
393
|
+
* host: url.hostname,
|
|
394
|
+
* port: +url.port,
|
|
395
|
+
* }
|
|
396
|
+
* })(),
|
|
397
|
+
* }
|
|
398
|
+
* })
|
|
399
|
+
*/
|
|
400
|
+
declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<PluginOption[] | undefined>;
|
|
401
|
+
|
|
402
|
+
export { type ElectronWithUpdaterOptions, debugStartup, electronWithUpdater };
|