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