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