Spaces:
Sleeping
Sleeping
File size: 1,373 Bytes
c2b7eb3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | /**
* @license
* Copyright 2026 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type {Browser, BrowserPlatform} from './browser-data/browser-data.js';
import {
downloadUrls,
executablePathByBrowser,
} from './browser-data/browser-data.js';
import type {BrowserProvider, DownloadOptions} from './provider.js';
/**
* Default provider implementation that uses default sources.
* This is the standard provider used by Puppeteer.
*
* @public
*/
export class DefaultProvider implements BrowserProvider {
#baseUrl?: string;
constructor(baseUrl?: string) {
this.#baseUrl = baseUrl;
}
supports(_options: DownloadOptions): boolean {
// Default provider supports all browsers
return true;
}
getDownloadUrl(options: DownloadOptions): URL {
return this.#getDownloadUrl(
options.browser,
options.platform,
options.buildId,
);
}
#getDownloadUrl(
browser: Browser,
platform: BrowserPlatform,
buildId: string,
): URL {
return new URL(downloadUrls[browser](platform, buildId, this.#baseUrl));
}
getExecutablePath(options: {
browser: Browser;
buildId: string;
platform: BrowserPlatform;
}): string {
return executablePathByBrowser[options.browser](
options.platform,
options.buildId,
);
}
getName(): string {
return 'DefaultProvider';
}
}
|