1 | import { AllPublishOptions, CancellationToken, PublishConfiguration, UpdateInfo, DownloadOptions, ProgressInfo } from "builder-util-runtime";
|
2 | import { OutgoingHttpHeaders } from "http";
|
3 | import { Lazy } from "lazy-val";
|
4 | import { SemVer } from "semver";
|
5 | import { AppAdapter } from "./AppAdapter";
|
6 | import { DownloadedUpdateHelper } from "./DownloadedUpdateHelper";
|
7 | import { LoginCallback } from "./electronHttpExecutor";
|
8 | import { Logger, Provider, ResolvedUpdateFileInfo, UpdateCheckResult, UpdateDownloadedEvent, UpdaterSignal } from "./main";
|
9 | import { ProviderPlatform } from "./providers/Provider";
|
10 | import type { TypedEmitter } from "tiny-typed-emitter";
|
11 | import Session = Electron.Session;
|
12 | import type { AuthInfo } from "electron";
|
13 | export type AppUpdaterEvents = {
|
14 | error: (error: Error, message?: string) => void;
|
15 | login: (info: AuthInfo, callback: LoginCallback) => void;
|
16 | "checking-for-update": () => void;
|
17 | "update-not-available": (info: UpdateInfo) => void;
|
18 | "update-available": (info: UpdateInfo) => void;
|
19 | "update-downloaded": (event: UpdateDownloadedEvent) => void;
|
20 | "download-progress": (info: ProgressInfo) => void;
|
21 | "update-cancelled": (info: UpdateInfo) => void;
|
22 | "appimage-filename-updated": (path: string) => void;
|
23 | };
|
24 | declare const AppUpdater_base: new () => TypedEmitter<AppUpdaterEvents>;
|
25 | export declare abstract class AppUpdater extends AppUpdater_base {
|
26 | |
27 |
|
28 |
|
29 | autoDownload: boolean;
|
30 | |
31 |
|
32 |
|
33 | autoInstallOnAppQuit: boolean;
|
34 | |
35 |
|
36 |
|
37 |
|
38 | autoRunAppAfterInstall: boolean;
|
39 | |
40 |
|
41 |
|
42 |
|
43 |
|
44 | allowPrerelease: boolean;
|
45 | |
46 |
|
47 |
|
48 |
|
49 | fullChangelog: boolean;
|
50 | |
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | allowDowngrade: boolean;
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | disableWebInstaller: boolean;
|
67 | |
68 |
|
69 |
|
70 |
|
71 |
|
72 | disableDifferentialDownload: boolean;
|
73 | |
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 | forceDevUpdateConfig: boolean;
|
81 | |
82 |
|
83 |
|
84 | readonly currentVersion: SemVer;
|
85 | private _channel;
|
86 | protected downloadedUpdateHelper: DownloadedUpdateHelper | null;
|
87 | |
88 |
|
89 |
|
90 | get channel(): string | null;
|
91 | |
92 |
|
93 |
|
94 |
|
95 |
|
96 | set channel(value: string | null);
|
97 | |
98 |
|
99 |
|
100 | requestHeaders: OutgoingHttpHeaders | null;
|
101 | |
102 |
|
103 |
|
104 | addAuthHeader(token: string): void;
|
105 | protected _logger: Logger;
|
106 | get netSession(): Session;
|
107 | |
108 |
|
109 |
|
110 |
|
111 | get logger(): Logger | null;
|
112 | set logger(value: Logger | null);
|
113 | |
114 |
|
115 |
|
116 | readonly signals: UpdaterSignal;
|
117 | private _appUpdateConfigPath;
|
118 | |
119 |
|
120 |
|
121 |
|
122 | set updateConfigPath(value: string | null);
|
123 | private clientPromise;
|
124 | protected readonly stagingUserIdPromise: Lazy<string>;
|
125 | private checkForUpdatesPromise;
|
126 | private downloadPromise;
|
127 | protected readonly app: AppAdapter;
|
128 | protected updateInfoAndProvider: UpdateInfoAndProvider | null;
|
129 | protected constructor(options: AllPublishOptions | null | undefined, app?: AppAdapter);
|
130 | getFeedURL(): string | null | undefined;
|
131 | /**
|
132 | * Configure update provider. If value is `string`, [GenericServerOptions](./publish.md#genericserveroptions) will be set with value as `url`.
|
133 | * @param options If you want to override configuration in the `app-update.yml`.
|
134 | */
|
135 | setFeedURL(options: PublishConfiguration | AllPublishOptions | string): void;
|
136 | /**
|
137 | * Asks the server whether there is an update.
|
138 | */
|
139 | checkForUpdates(): Promise<UpdateCheckResult | null>;
|
140 | isUpdaterActive(): boolean;
|
141 | checkForUpdatesAndNotify(downloadNotification?: DownloadNotification): Promise<UpdateCheckResult | null>;
|
142 | private static formatDownloadNotification;
|
143 | private isStagingMatch;
|
144 | private computeFinalHeaders;
|
145 | private isUpdateAvailable;
|
146 | protected getUpdateInfoAndProvider(): Promise<UpdateInfoAndProvider>;
|
147 | private createProviderRuntimeOptions;
|
148 | private doCheckForUpdates;
|
149 | protected onUpdateAvailable(updateInfo: UpdateInfo): void;
|
150 | /**
|
151 | * Start downloading update manually. You can use this method if `autoDownload` option is set to `false`.
|
152 | * @returns {Promise<Array<string>>} Paths to downloaded files.
|
153 | */
|
154 | downloadUpdate(cancellationToken?: CancellationToken): Promise<Array<string>>;
|
155 | protected dispatchError(e: Error): void;
|
156 | protected dispatchUpdateDownloaded(event: UpdateDownloadedEvent): void;
|
157 | protected abstract doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>>;
|
158 | |
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 | abstract quitAndInstall(isSilent?: boolean, isForceRunAfter?: boolean): void;
|
170 | private loadUpdateConfig;
|
171 | private computeRequestHeaders;
|
172 | private getOrCreateStagingUserId;
|
173 | private getOrCreateDownloadHelper;
|
174 | protected executeDownload(taskOptions: DownloadExecutorTask): Promise<Array<string>>;
|
175 | protected differentialDownloadInstaller(fileInfo: ResolvedUpdateFileInfo, downloadUpdateOptions: DownloadUpdateOptions, installerPath: string, provider: Provider<any>, oldInstallerFileName: string): Promise<boolean>;
|
176 | }
|
177 | export interface DownloadUpdateOptions {
|
178 | readonly updateInfoAndProvider: UpdateInfoAndProvider;
|
179 | readonly requestHeaders: OutgoingHttpHeaders;
|
180 | readonly cancellationToken: CancellationToken;
|
181 | readonly disableWebInstaller?: boolean;
|
182 | readonly disableDifferentialDownload?: boolean;
|
183 | }
|
184 |
|
185 | export declare class NoOpLogger implements Logger {
|
186 | info(message?: any): void;
|
187 | warn(message?: any): void;
|
188 | error(message?: any): void;
|
189 | }
|
190 | export interface UpdateInfoAndProvider {
|
191 | info: UpdateInfo;
|
192 | provider: Provider<any>;
|
193 | }
|
194 | export interface DownloadExecutorTask {
|
195 | readonly fileExtension: string;
|
196 | readonly fileInfo: ResolvedUpdateFileInfo;
|
197 | readonly downloadUpdateOptions: DownloadUpdateOptions;
|
198 | readonly task: (destinationFile: string, downloadOptions: DownloadOptions, packageFile: string | null, removeTempDirIfAny: () => Promise<any>) => Promise<any>;
|
199 | readonly done?: (event: UpdateDownloadedEvent) => Promise<any>;
|
200 | }
|
201 | export interface DownloadNotification {
|
202 | body: string;
|
203 | title: string;
|
204 | }
|
205 |
|
206 | export interface TestOnlyUpdaterOptions {
|
207 | platform: ProviderPlatform;
|
208 | isUseDifferentialDownload?: boolean;
|
209 | }
|
210 | export {};
|