diff --git a/docs/api/puppeteer.createbrowserfetcher.md b/docs/api/puppeteer.createbrowserfetcher.md index 29251c6f..6521b6a0 100644 --- a/docs/api/puppeteer.createbrowserfetcher.md +++ b/docs/api/puppeteer.createbrowserfetcher.md @@ -8,8 +8,10 @@ sidebar_label: createBrowserFetcher ```typescript createBrowserFetcher: ( - options: Partial< - import('puppeteer-core/internal/puppeteer-core.js').BrowserFetcherOptions - > + options?: + | Partial< + import('puppeteer-core/internal/puppeteer-core.js').BrowserFetcherOptions + > + | undefined ) => import('puppeteer-core/internal/puppeteer-core.js').BrowserFetcher; ``` diff --git a/docs/api/puppeteer.puppeteernode.createbrowserfetcher.md b/docs/api/puppeteer.puppeteernode.createbrowserfetcher.md index ba9c70ec..13e43c84 100644 --- a/docs/api/puppeteer.puppeteernode.createbrowserfetcher.md +++ b/docs/api/puppeteer.puppeteernode.createbrowserfetcher.md @@ -8,15 +8,17 @@ sidebar_label: PuppeteerNode.createBrowserFetcher ```typescript class PuppeteerNode { - createBrowserFetcher(options: Partial): BrowserFetcher; + createBrowserFetcher( + options?: Partial + ): BrowserFetcher; } ``` ## Parameters -| Parameter | Type | Description | -| --------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -| options | Partial<[BrowserFetcherOptions](./puppeteer.browserfetcheroptions.md)> | Set of configurable options to specify the settings of the BrowserFetcher. | +| Parameter | Type | Description | +| --------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| options | Partial<[BrowserFetcherOptions](./puppeteer.browserfetcheroptions.md)> | (Optional) Set of configurable options to specify the settings of the BrowserFetcher. | **Returns:** diff --git a/packages/puppeteer-core/src/node/PuppeteerNode.ts b/packages/puppeteer-core/src/node/PuppeteerNode.ts index 81c8614b..ca16645e 100644 --- a/packages/puppeteer-core/src/node/PuppeteerNode.ts +++ b/packages/puppeteer-core/src/node/PuppeteerNode.ts @@ -289,7 +289,7 @@ export class PuppeteerNode extends Puppeteer { * @returns A new BrowserFetcher instance. */ createBrowserFetcher( - options: Partial + options: Partial = {} ): BrowserFetcher { const downloadPath = this.defaultDownloadPath; if (downloadPath) { @@ -304,6 +304,9 @@ export class PuppeteerNode extends Puppeteer { if (this.configuration.downloadHost) { options.host = this.configuration.downloadHost; } + if (this.configuration.defaultProduct) { + options.product = this.configuration.defaultProduct; + } return new BrowserFetcher(options as BrowserFetcherOptions); } } diff --git a/packages/puppeteer/src/node/install.ts b/packages/puppeteer/src/node/install.ts index 76c9414d..25b31705 100644 --- a/packages/puppeteer/src/node/install.ts +++ b/packages/puppeteer/src/node/install.ts @@ -16,10 +16,9 @@ import https, {RequestOptions} from 'https'; import createHttpsProxyAgent, {HttpsProxyAgentOptions} from 'https-proxy-agent'; -import {join} from 'path'; import ProgressBar from 'progress'; import {getProxyForUrl} from 'proxy-from-env'; -import {BrowserFetcher} from 'puppeteer-core'; +import {PuppeteerNode} from 'puppeteer-core/internal/node/PuppeteerNode.js'; import {PUPPETEER_REVISIONS} from 'puppeteer-core/internal/revisions.js'; import URL from 'url'; import {getConfiguration} from '../getConfiguration.js'; @@ -42,14 +41,10 @@ export async function downloadBrowser(): Promise { return; } + const puppeteer = new PuppeteerNode({configuration, isPuppeteerCore: false}); + const product = configuration.defaultProduct!; - const browserFetcher = new BrowserFetcher({ - product, - host: configuration.downloadHost, - path: - configuration.downloadPath ?? - join(configuration.cacheDirectory!, product), - }); + const browserFetcher = puppeteer.createBrowserFetcher(); let revision = configuration.browserRevision;