UNPKG

2.04 kBTypeScriptView Raw
1import { CancellationToken, UpdateFileInfo, UpdateInfo } from "builder-util-runtime";
2import { OutgoingHttpHeaders, RequestOptions } from "http";
3import { URL } from "url";
4import { ElectronHttpExecutor } from "../electronHttpExecutor";
5import { ResolvedUpdateFileInfo } from "../main";
6export type ProviderPlatform = "darwin" | "linux" | "win32";
7export interface ProviderRuntimeOptions {
8 isUseMultipleRangeRequest: boolean;
9 platform: ProviderPlatform;
10 executor: ElectronHttpExecutor;
11}
12export declare abstract class Provider<T extends UpdateInfo> {
13 private readonly runtimeOptions;
14 private requestHeaders;
15 protected readonly executor: ElectronHttpExecutor;
16 protected constructor(runtimeOptions: ProviderRuntimeOptions);
17 get isUseMultipleRangeRequest(): boolean;
18 private getChannelFilePrefix;
19 protected getDefaultChannelName(): string;
20 protected getCustomChannelName(channel: string): string;
21 get fileExtraDownloadHeaders(): OutgoingHttpHeaders | null;
22 setRequestHeaders(value: OutgoingHttpHeaders | null): void;
23 abstract getLatestVersion(): Promise<T>;
24 abstract resolveFiles(updateInfo: T): Array<ResolvedUpdateFileInfo>;
25 /**
26 * Method to perform API request only to resolve update info, but not to download update.
27 */
28 protected httpRequest(url: URL, headers?: OutgoingHttpHeaders | null, cancellationToken?: CancellationToken): Promise<string | null>;
29 protected createRequestOptions(url: URL, headers?: OutgoingHttpHeaders | null): RequestOptions;
30}
31export declare function findFile(files: Array<ResolvedUpdateFileInfo>, extension: string, not?: Array<string>): ResolvedUpdateFileInfo | null | undefined;
32export declare function parseUpdateInfo(rawData: string | null, channelFile: string, channelFileUrl: URL): UpdateInfo;
33export declare function getFileList(updateInfo: UpdateInfo): Array<UpdateFileInfo>;
34export declare function resolveFiles(updateInfo: UpdateInfo, baseUrl: URL, pathTransformer?: (p: string) => string): Array<ResolvedUpdateFileInfo>;