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