electron-incremental-update 2.0.0-beta.5 → 2.0.0-beta.6

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/index.d.ts DELETED
@@ -1,78 +0,0 @@
1
- import { U as Updater, a as UpdaterOption, L as Logger } from './core-CXETH_bb.js';
2
- export { C as CheckResult, D as DownloadResult, E as ErrorInfo, b as UpdaterError } from './core-CXETH_bb.js';
3
- import { I as IProvider } from './types-C5P0h_bB.js';
4
- import 'node:events';
5
- import '@subframe7536/type-utils';
6
-
7
- type Promisable<T> = T | Promise<T>;
8
- /**
9
- * hooks on rename temp asar path to `${app.name}.asar`
10
- * @param install `() => renameSync(tempAsarPath, appNameAsarPath)`
11
- * @param tempAsarPath temp(updated) asar path
12
- * @param appNameAsarPath `${app.name}.asar` path
13
- * @param logger logger
14
- * @default install(); logger.info(`update success!`)
15
- */
16
- type OnInstallFunction = (install: VoidFunction, tempAsarPath: string, appNameAsarPath: string, logger?: Logger) => Promisable<void>;
17
- interface AppOption {
18
- /**
19
- * update provider
20
- */
21
- provider: IProvider;
22
- /**
23
- * updater options
24
- */
25
- updater?: (() => Promisable<Updater>) | UpdaterOption;
26
- /**
27
- * hooks on rename temp asar path to `${app.name}.asar`
28
- */
29
- onInstall?: OnInstallFunction;
30
- /**
31
- * hooks before app start up
32
- * @param mainFilePath main file path of `${app.name}.asar`
33
- * @param logger logger
34
- */
35
- beforeStart?: (mainFilePath: string, logger?: Logger) => Promisable<void>;
36
- /**
37
- * hooks on app start up error
38
- * @param err installing or startup error
39
- * @param logger logger
40
- */
41
- onStartError?: (err: unknown, logger?: Logger) => void;
42
- }
43
- /**
44
- * utils for startuping with updater
45
- * @param fn startup function
46
- * @example
47
- * // in electron/main/index.ts
48
- * export default startupWithUpdater((updater) => {
49
- * updater.checkUpdate()
50
- * })
51
- */
52
- declare function startupWithUpdater(fn: (updater: Updater) => Promisable<void>): (updater: Updater) => Promisable<void>;
53
- /**
54
- * initialize app
55
- * @example
56
- * ```ts
57
- * import { getGithubReleaseCdnGroup, initApp, parseGithubCdnURL } from 'electron-incremental-update'
58
- * import { repository } from '../package.json'
59
- *
60
- * const { cdnPrefix: asarPrefix } = getGithubReleaseCdnGroup()[0]
61
- * const { cdnPrefix: jsonPrefix } = getGithubFileCdnGroup()[0]
62
- *
63
- * initApp({
64
- * // can be updater option or function that return updater
65
- * updater: {
66
- * SIGNATURE_CERT: 'custom certificate',
67
- * repository,
68
- * updateJsonURL: parseGithubCdnURL(repository, jsonPrefix, 'version.json'),
69
- * releaseAsarURL: parseGithubCdnURL(repository, asarPrefix, `download/latest/${app.name}.asar.gz`),
70
- * receiveBeta: true,
71
- * },
72
- * onStart: console.log
73
- * })
74
- * ```
75
- */
76
- declare function initApp(appOptions: AppOption): Promise<void>;
77
-
78
- export { type AppOption, Logger, Updater, UpdaterOption, initApp, startupWithUpdater };
@@ -1,65 +0,0 @@
1
- import { I as IProvider, d as defaultIsLowerVersion, a as UpdateJSON, U as UpdateInfo, D as DownloadingInfo, c as URLHandler, O as OnDownloading } from './types-C5P0h_bB.cjs';
2
- import { f as defaultVerify, a as defaultUnzipFile } from './zip-WRrEMkgp.cjs';
3
- import { Arrayable } from '@subframe7536/type-utils';
4
-
5
- declare abstract class BaseProvider implements IProvider {
6
- name: string;
7
- isLowerVersion: typeof defaultIsLowerVersion;
8
- verifySignaure: typeof defaultVerify;
9
- unzipFile: typeof defaultUnzipFile;
10
- abstract downloadJSON(versionPath: string): Promise<UpdateJSON>;
11
- abstract downloadAsar(name: string, info: UpdateInfo, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
12
- }
13
-
14
- interface GitHubProviderOptions {
15
- /**
16
- * github user name
17
- */
18
- username: string;
19
- /**
20
- * github repo name
21
- */
22
- repo: string;
23
- /**
24
- * extra headers
25
- */
26
- extraHeaders?: Record<string, string>;
27
- /**
28
- * custom url handler
29
- *
30
- * for Github, there are some {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L40 public CDN links}
31
- * @example
32
- * (url, isDownloadAsar) => {
33
- * if (isDownloadAsar) {
34
- * url.hostname = 'mirror.ghproxy.com'
35
- * url.pathname = 'https://github.com' + url.pathname
36
- * return url
37
- * }
38
- * }
39
- */
40
- urlHandler?: URLHandler;
41
- }
42
- declare class GitHubProvider extends BaseProvider {
43
- name: string;
44
- private options;
45
- /**
46
- * Update Provider for Github repo
47
- * - download update json from `https://raw.githubusercontent.com/{user}/{repo}/HEAD/{versionPath}`
48
- * - download update asar from `https://github.com/{user}/{repo}/releases/download/v{version}/{name}-{version}.asar.gz`
49
- *
50
- * you can setup `urlHandler` in {@link GitHubProviderOptions} or `Updater` to modify url before request
51
- * @param options provider options
52
- */
53
- constructor(options: GitHubProviderOptions);
54
- get urlHandler(): URLHandler | undefined;
55
- set urlHandler(handler: URLHandler);
56
- private parseURL;
57
- downloadJSON(versionPath: string): Promise<UpdateJSON>;
58
- downloadAsar(name: string, info: UpdateInfo, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
59
- }
60
-
61
- declare function getHeader(response: Record<string, Arrayable<string>>, headerKey: any): any;
62
- declare function defaultDownloadUpdateJSON(url: string, headers: Record<string, any>): Promise<UpdateJSON>;
63
- declare function defaultDownloadAsar(url: string, headers: Record<string, any>, onDownloading?: OnDownloading): Promise<Buffer>;
64
-
65
- export { BaseProvider, DownloadingInfo, GitHubProvider, type GitHubProviderOptions, IProvider, OnDownloading, URLHandler, defaultDownloadAsar, defaultDownloadUpdateJSON, getHeader };
@@ -1,65 +0,0 @@
1
- import { I as IProvider, d as defaultIsLowerVersion, a as UpdateJSON, U as UpdateInfo, D as DownloadingInfo, c as URLHandler, O as OnDownloading } from './types-C5P0h_bB.js';
2
- import { f as defaultVerify, a as defaultUnzipFile } from './zip-WRrEMkgp.js';
3
- import { Arrayable } from '@subframe7536/type-utils';
4
-
5
- declare abstract class BaseProvider implements IProvider {
6
- name: string;
7
- isLowerVersion: typeof defaultIsLowerVersion;
8
- verifySignaure: typeof defaultVerify;
9
- unzipFile: typeof defaultUnzipFile;
10
- abstract downloadJSON(versionPath: string): Promise<UpdateJSON>;
11
- abstract downloadAsar(name: string, info: UpdateInfo, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
12
- }
13
-
14
- interface GitHubProviderOptions {
15
- /**
16
- * github user name
17
- */
18
- username: string;
19
- /**
20
- * github repo name
21
- */
22
- repo: string;
23
- /**
24
- * extra headers
25
- */
26
- extraHeaders?: Record<string, string>;
27
- /**
28
- * custom url handler
29
- *
30
- * for Github, there are some {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L40 public CDN links}
31
- * @example
32
- * (url, isDownloadAsar) => {
33
- * if (isDownloadAsar) {
34
- * url.hostname = 'mirror.ghproxy.com'
35
- * url.pathname = 'https://github.com' + url.pathname
36
- * return url
37
- * }
38
- * }
39
- */
40
- urlHandler?: URLHandler;
41
- }
42
- declare class GitHubProvider extends BaseProvider {
43
- name: string;
44
- private options;
45
- /**
46
- * Update Provider for Github repo
47
- * - download update json from `https://raw.githubusercontent.com/{user}/{repo}/HEAD/{versionPath}`
48
- * - download update asar from `https://github.com/{user}/{repo}/releases/download/v{version}/{name}-{version}.asar.gz`
49
- *
50
- * you can setup `urlHandler` in {@link GitHubProviderOptions} or `Updater` to modify url before request
51
- * @param options provider options
52
- */
53
- constructor(options: GitHubProviderOptions);
54
- get urlHandler(): URLHandler | undefined;
55
- set urlHandler(handler: URLHandler);
56
- private parseURL;
57
- downloadJSON(versionPath: string): Promise<UpdateJSON>;
58
- downloadAsar(name: string, info: UpdateInfo, onDownloading?: (info: DownloadingInfo) => void): Promise<Buffer>;
59
- }
60
-
61
- declare function getHeader(response: Record<string, Arrayable<string>>, headerKey: any): any;
62
- declare function defaultDownloadUpdateJSON(url: string, headers: Record<string, any>): Promise<UpdateJSON>;
63
- declare function defaultDownloadAsar(url: string, headers: Record<string, any>, onDownloading?: OnDownloading): Promise<Buffer>;
64
-
65
- export { BaseProvider, DownloadingInfo, GitHubProvider, type GitHubProviderOptions, IProvider, OnDownloading, URLHandler, defaultDownloadAsar, defaultDownloadUpdateJSON, getHeader };
@@ -1,103 +0,0 @@
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 signature signature
97
- * @param cert certificate
98
- * @returns if signature is valid, returns the version, otherwise returns `undefined`
99
- */
100
- verifySignaure: (buffer: Buffer, signature: string, cert: string) => Promisable<string | undefined>;
101
- }
102
-
103
- 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 };
@@ -1,103 +0,0 @@
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 signature signature
97
- * @param cert certificate
98
- * @returns if signature is valid, returns the version, otherwise returns `undefined`
99
- */
100
- verifySignaure: (buffer: Buffer, signature: string, cert: string) => Promisable<string | undefined>;
101
- }
102
-
103
- 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.d.cts DELETED
@@ -1,80 +0,0 @@
1
- import { BrowserWindow } from 'electron';
2
- export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerify, d as defaultZipFile, h as hashBuffer } from './zip-WRrEMkgp.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-C5P0h_bB.cjs';
4
- import { U as Updater } from './core-DmU2Vk_S.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 DELETED
@@ -1,80 +0,0 @@
1
- import { BrowserWindow } from 'electron';
2
- export { e as aesDecrypt, b as aesEncrypt, c as defaultSignature, a as defaultUnzipFile, f as defaultVerify, d as defaultZipFile, h as hashBuffer } from './zip-WRrEMkgp.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-C5P0h_bB.js';
4
- import { U as Updater } from './core-CXETH_bb.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 };