1 | import { Downloader } from './Downloader';
|
2 | import { GotDownloader, GotDownloaderOptions } from './GotDownloader';
|
3 | export { Downloader, GotDownloader, GotDownloaderOptions };
|
4 | /**
|
5 | * Custom downloaders can implement any set of options.
|
6 | * @category Downloader
|
7 | */
|
8 | export type DownloadOptions = any;
|
9 | /**
|
10 | * Options for specifying an alternative download mirror for Electron.
|
11 | *
|
12 | * @category Utility
|
13 | * @example
|
14 | *
|
15 | * To download the Electron v4.0.4 release for x64 Linux from
|
16 | * https://github.com/electron/electron/releases/download/v4.0.4/electron-v4.0.4-linux-x64.zip
|
17 | *
|
18 | * ```js
|
19 | * const opts = {
|
20 | * mirror: 'https://github.com/electron/electron/releases/download',
|
21 | * customDir: 'v4.0.4',
|
22 | * customFilename: 'electron-v4.0.4-linux-x64.zip',
|
23 | * }
|
24 | * ```
|
25 | */
|
26 | export interface MirrorOptions {
|
27 | /**
|
28 | * @deprecated
|
29 | * @see {@link MirrorOptions.nightlyMirror}
|
30 | */
|
31 | nightly_mirror?: string;
|
32 | /**
|
33 | * The mirror URL for [`electron-nightly`](https://npmjs.com/package/electron-nightly),
|
34 | * which lives in a separate npm package.
|
35 | */
|
36 | nightlyMirror?: string;
|
37 | /**
|
38 | * The base URL of the mirror to download from.
|
39 | * e.g https://github.com/electron/electron/releases/download
|
40 | */
|
41 | mirror?: string;
|
42 | /**
|
43 | * The name of the directory to download from,
|
44 | * often scoped by version number e.g 'v4.0.4'
|
45 | */
|
46 | customDir?: string;
|
47 | /**
|
48 | * The name of the asset to download,
|
49 | * e.g 'electron-v4.0.4-linux-x64.zip'
|
50 | */
|
51 | customFilename?: string;
|
52 | /**
|
53 | * The version of the asset to download,
|
54 | * e.g '4.0.4'
|
55 | */
|
56 | customVersion?: string;
|
57 | /**
|
58 | * A function allowing customization of the url returned
|
59 | * from getArtifactRemoteURL().
|
60 | */
|
61 | resolveAssetURL?: (opts: DownloadOptions) => Promise<string>;
|
62 | }
|
63 | /**
|
64 | * @category Download Artifact
|
65 | * @internal
|
66 | */
|
67 | export interface ElectronDownloadRequest {
|
68 | /**
|
69 | * The version of Electron associated with the artifact.
|
70 | */
|
71 | version: string;
|
72 | /**
|
73 | * The type of artifact. For example:
|
74 | * * `electron`
|
75 | * * `ffmpeg`
|
76 | */
|
77 | artifactName: string;
|
78 | }
|
79 | export declare enum ElectronDownloadCacheMode {
|
80 | /**
|
81 | * Reads from the cache if present
|
82 | * Writes to the cache after fetch if not present
|
83 | */
|
84 | ReadWrite = 0,
|
85 | /**
|
86 | * Reads from the cache if present
|
87 | * Will **not** write back to the cache after fetching missing artifact
|
88 | */
|
89 | ReadOnly = 1,
|
90 | /**
|
91 | * Skips reading from the cache
|
92 | * Will write back into the cache, overwriting anything currently in the cache after fetch
|
93 | */
|
94 | WriteOnly = 2,
|
95 | /**
|
96 | * Bypasses the cache completely, neither reads from nor writes to the cache
|
97 | */
|
98 | Bypass = 3
|
99 | }
|
100 | /**
|
101 | * @category Download Electron
|
102 | */
|
103 | export interface ElectronDownloadRequestOptions {
|
104 | /**
|
105 | * Whether to download an artifact regardless of whether it's in the cache directory.
|
106 | *
|
107 | * @defaultValue `false`
|
108 | * @deprecated This option is deprecated and directly maps to {@link cacheMode | `cacheMode: ElectronDownloadCacheMode.WriteOnly`}
|
109 | */
|
110 | force?: boolean;
|
111 | /**
|
112 | * When set to `true`, disables checking that the artifact download completed successfully
|
113 | * with the correct payload.
|
114 | *
|
115 | * @defaultValue `false`
|
116 | */
|
117 | unsafelyDisableChecksums?: boolean;
|
118 | /**
|
119 | * Provides checksums for the artifact as strings.
|
120 | * Can be used if you already know the checksums of the Electron artifact
|
121 | * you are downloading and want to skip the checksum file download
|
122 | * without skipping the checksum validation.
|
123 | *
|
124 | * This should be an object whose keys are the file names of the artifacts and
|
125 | * the values are their respective SHA256 checksums.
|
126 | *
|
127 | * @example
|
128 | * ```json
|
129 | * {
|
130 | * "electron-v4.0.4-linux-x64.zip": "877617029f4c0f2b24f3805a1c3554ba166fda65c4e88df9480ae7b6ffa26a22"
|
131 | * }
|
132 | * ```
|
133 | */
|
134 | checksums?: Record<string, string>;
|
135 | /**
|
136 | * The directory that caches Electron artifact downloads.
|
137 | *
|
138 | * @defaultValue The default value is dependent upon the host platform:
|
139 | *
|
140 | * * Linux: `$XDG_CACHE_HOME` or `~/.cache/electron/`
|
141 | * * MacOS: `~/Library/Caches/electron/`
|
142 | * * Windows: `%LOCALAPPDATA%/electron/Cache` or `~/AppData/Local/electron/Cache/`
|
143 | */
|
144 | cacheRoot?: string;
|
145 | /**
|
146 | * Options passed to the downloader module.
|
147 | *
|
148 | * @see {@link GotDownloaderOptions} for options for the default {@link GotDownloader}.
|
149 | */
|
150 | downloadOptions?: DownloadOptions;
|
151 | /**
|
152 | * Options related to specifying an artifact mirror.
|
153 | */
|
154 | mirrorOptions?: MirrorOptions;
|
155 | /**
|
156 | * A custom {@link Downloader} class used to download artifacts. Defaults to the
|
157 | * built-in {@link GotDownloader}.
|
158 | */
|
159 | downloader?: Downloader<DownloadOptions>;
|
160 | /**
|
161 | * A temporary directory for downloads.
|
162 | * It is used before artifacts are put into cache.
|
163 | *
|
164 | * @defaultValue the OS default temporary directory via [`os.tmpdir()`](https://nodejs.org/api/os.html#ostmpdir)
|
165 | */
|
166 | tempDirectory?: string;
|
167 | /**
|
168 | * Controls the cache read and write behavior.
|
169 | *
|
170 | * When set to either {@link ElectronDownloadCacheMode.ReadOnly | ReadOnly} or
|
171 | * {@link ElectronDownloadCacheMode.Bypass | Bypass}, the caller is responsible
|
172 | * for cleaning up the returned file path once they are done using it
|
173 | * (e.g. via `fs.remove(path.dirname(pathFromElectronGet))`).
|
174 | *
|
175 | * When set to either {@link ElectronDownloadCacheMode.WriteOnly | WriteOnly} or
|
176 | * {@link ElectronDownloadCacheMode.ReadWrite | ReadWrite} (the default), the caller
|
177 | * should not move or delete the file path that is returned as the path
|
178 | * points directly to the disk cache.
|
179 | *
|
180 | * This option cannot be used in conjunction with {@link ElectronDownloadRequestOptions.force}.
|
181 | *
|
182 | * @defaultValue {@link ElectronDownloadCacheMode.ReadWrite}
|
183 | */
|
184 | cacheMode?: ElectronDownloadCacheMode;
|
185 | }
|
186 | /**
|
187 | * @category Download Artifact
|
188 | * @internal
|
189 | */
|
190 | export type ElectronPlatformArtifactDetails = {
|
191 | /**
|
192 | * The target artifact platform. These are Node-style platform names, for example:
|
193 | * * `win32`
|
194 | * * `darwin`
|
195 | * * `linux`
|
196 | *
|
197 | * @see Node.js {@link https://nodejs.org/api/process.html#processplatform | process.platform} docs
|
198 | */
|
199 | platform: string;
|
200 | /**
|
201 | * The target artifact architecture. These are Node-style architecture names, for example:
|
202 | * * `ia32`
|
203 | * * `x64`
|
204 | * * `armv7l`
|
205 | *
|
206 | * @see Node.js {@link https://nodejs.org/api/process.html#processarch | process.arch} docs
|
207 | */
|
208 | arch: string;
|
209 | artifactSuffix?: string;
|
210 | isGeneric?: false;
|
211 | } & ElectronDownloadRequest & ElectronDownloadRequestOptions;
|
212 | /**
|
213 | * Options to download a generic (i.e. platform and architecture-agnostic)
|
214 | * Electron artifact. Contains all options from {@link ElectronDownloadRequestOptions},
|
215 | * but specifies a `version` and `artifactName` for the artifact to download.
|
216 | *
|
217 | * @category Download Artifact
|
218 | * @interface
|
219 | */
|
220 | export type ElectronGenericArtifactDetails = {
|
221 | isGeneric: true;
|
222 | } & ElectronDownloadRequest & ElectronDownloadRequestOptions;
|
223 | /**
|
224 | * @category Download Artifact
|
225 | * @internal
|
226 | */
|
227 | export type ElectronArtifactDetails = ElectronPlatformArtifactDetails | ElectronGenericArtifactDetails;
|
228 | /**
|
229 | * Options to download a platform and architecture-specific Electron artifact.
|
230 | * Contains all options from {@link ElectronDownloadRequestOptions}, but
|
231 | * specifies a `version` and `artifactName` for the artifact to download.
|
232 | *
|
233 | * If `platform` and `arch` are omitted, they will be inferred using the host
|
234 | * system platform and architecture.
|
235 | *
|
236 | * @category Download Artifact
|
237 | * @interface
|
238 | */
|
239 | export type ElectronPlatformArtifactDetailsWithDefaults = Omit<ElectronPlatformArtifactDetails, 'platform' | 'arch'> & {
|
240 | /**
|
241 | * The target artifact platform. These are Node-style platform names, for example:
|
242 | * * `win32`
|
243 | * * `darwin`
|
244 | * * `linux`
|
245 | *
|
246 | * @see Node.js {@link https://nodejs.org/api/process.html#processplatform | process.platform} docs
|
247 | */
|
248 | platform?: string;
|
249 | /**
|
250 | * The target artifact architecture. These are Node-style architecture names, for example:
|
251 | * * `ia32`
|
252 | * * `x64`
|
253 | * * `armv7l`
|
254 | *
|
255 | * @see Node.js {@link https://nodejs.org/api/process.html#processarch | process.arch} docs
|
256 | */
|
257 | arch?: string;
|
258 | };
|