docs: improve docs (#9988)
This commit is contained in:
parent
19852497a2
commit
7d1734a5fa
@ -7,14 +7,16 @@ sidebar_label: computeExecutablePath
|
|||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export declare function computeExecutablePath(options: Options): string;
|
export declare function computeExecutablePath(
|
||||||
|
options: ComputeExecutablePathOptions
|
||||||
|
): string;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
| Parameter | Type | Description |
|
||||||
| --------- | -------------------------------- | ----------- |
|
| --------- | ----------------------------------------------------- | ----------- |
|
||||||
| options | [Options](./browsers.options.md) | |
|
| options | [ComputeExecutablePathOptions](./browsers.options.md) | |
|
||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
|
@ -20,4 +20,4 @@ export declare function install(
|
|||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
Promise<InstalledBrowser>
|
Promise<[InstalledBrowser](./browsers.installedbrowser.md)>
|
||||||
|
18
docs/browsers-api/browsers.installedbrowser.md
Normal file
18
docs/browsers-api/browsers.installedbrowser.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: InstalledBrowser
|
||||||
|
---
|
||||||
|
|
||||||
|
# InstalledBrowser type
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
export type InstalledBrowser = {
|
||||||
|
path: string;
|
||||||
|
browser: Browser;
|
||||||
|
buildId: string;
|
||||||
|
platform: BrowserPlatform;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
**References:** [Browser](./browsers.browser.md), [BrowserPlatform](./browsers.browserplatform.md)
|
@ -18,4 +18,4 @@ export declare function launch(opts: LaunchOptions): Process;
|
|||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
Process
|
[Process](./browsers.process.md)
|
||||||
|
@ -7,7 +7,7 @@ sidebar_label: Options
|
|||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export interface Options
|
export interface ComputeExecutablePathOptions
|
||||||
```
|
```
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
21
docs/browsers-api/browsers.process._constructor_.md
Normal file
21
docs/browsers-api/browsers.process._constructor_.md
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: Process.(constructor)
|
||||||
|
---
|
||||||
|
|
||||||
|
# Process.(constructor)
|
||||||
|
|
||||||
|
Constructs a new instance of the `Process` class
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class Process {
|
||||||
|
constructor(opts: LaunchOptions);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
| Parameter | Type | Description |
|
||||||
|
| --------- | -------------------------------------------- | ----------- |
|
||||||
|
| opts | [LaunchOptions](./browsers.launchoptions.md) | |
|
17
docs/browsers-api/browsers.process.close.md
Normal file
17
docs/browsers-api/browsers.process.close.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: Process.close
|
||||||
|
---
|
||||||
|
|
||||||
|
# Process.close() method
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class Process {
|
||||||
|
close(): Promise<void>;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
Promise<void>
|
17
docs/browsers-api/browsers.process.hasclosed.md
Normal file
17
docs/browsers-api/browsers.process.hasclosed.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: Process.hasClosed
|
||||||
|
---
|
||||||
|
|
||||||
|
# Process.hasClosed() method
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class Process {
|
||||||
|
hasClosed(): Promise<void>;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
Promise<void>
|
17
docs/browsers-api/browsers.process.kill.md
Normal file
17
docs/browsers-api/browsers.process.kill.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: Process.kill
|
||||||
|
---
|
||||||
|
|
||||||
|
# Process.kill() method
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class Process {
|
||||||
|
kill(): void;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
void
|
32
docs/browsers-api/browsers.process.md
Normal file
32
docs/browsers-api/browsers.process.md
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: Process
|
||||||
|
---
|
||||||
|
|
||||||
|
# Process class
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
export declare class Process
|
||||||
|
```
|
||||||
|
|
||||||
|
## Constructors
|
||||||
|
|
||||||
|
| Constructor | Modifiers | Description |
|
||||||
|
| ---------------------------------------------------------- | --------- | ----------------------------------------------------------- |
|
||||||
|
| [(constructor)(opts)](./browsers.process._constructor_.md) | | Constructs a new instance of the <code>Process</code> class |
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Property | Modifiers | Type | Description |
|
||||||
|
| ----------- | --------------------- | ------------------------- | ----------- |
|
||||||
|
| nodeProcess | <code>readonly</code> | childProcess.ChildProcess | |
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
|
||||||
|
| Method | Modifiers | Description |
|
||||||
|
| ---------------------------------------------------------------------------- | --------- | ----------- |
|
||||||
|
| [close()](./browsers.process.close.md) | | |
|
||||||
|
| [hasClosed()](./browsers.process.hasclosed.md) | | |
|
||||||
|
| [kill()](./browsers.process.kill.md) | | |
|
||||||
|
| [waitForLineOutput(regex, timeout)](./browsers.process.waitforlineoutput.md) | | |
|
24
docs/browsers-api/browsers.process.waitforlineoutput.md
Normal file
24
docs/browsers-api/browsers.process.waitforlineoutput.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: Process.waitForLineOutput
|
||||||
|
---
|
||||||
|
|
||||||
|
# Process.waitForLineOutput() method
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class Process {
|
||||||
|
waitForLineOutput(regex: RegExp, timeout?: number): Promise<string>;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
| Parameter | Type | Description |
|
||||||
|
| --------- | ------ | ------------ |
|
||||||
|
| regex | RegExp | |
|
||||||
|
| timeout | number | _(Optional)_ |
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
Promise<string>
|
@ -9,6 +9,7 @@ sidebar_label: API
|
|||||||
| Class | Description |
|
| Class | Description |
|
||||||
| ------------------------------------------ | ----------- |
|
| ------------------------------------------ | ----------- |
|
||||||
| [CLI](./browsers.cli.md) | |
|
| [CLI](./browsers.cli.md) | |
|
||||||
|
| [Process](./browsers.process.md) | |
|
||||||
| [TimeoutError](./browsers.timeouterror.md) | |
|
| [TimeoutError](./browsers.timeouterror.md) | |
|
||||||
|
|
||||||
## Enumerations
|
## Enumerations
|
||||||
@ -51,6 +52,7 @@ sidebar_label: API
|
|||||||
|
|
||||||
## Type Aliases
|
## Type Aliases
|
||||||
|
|
||||||
| Type Alias | Description |
|
| Type Alias | Description |
|
||||||
| -------------------------------------------- | ----------- |
|
| -------------------------------------------------- | ----------- |
|
||||||
| [LaunchOptions](./browsers.launchoptions.md) | |
|
| [InstalledBrowser](./browsers.installedbrowser.md) | |
|
||||||
|
| [LaunchOptions](./browsers.launchoptions.md) | |
|
||||||
|
@ -62,6 +62,9 @@ type ClearArgs = {
|
|||||||
path?: string;
|
path?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export class CLI {
|
export class CLI {
|
||||||
#cachePath;
|
#cachePath;
|
||||||
#rl?: readline.Interface;
|
#rl?: readline.Interface;
|
||||||
@ -275,6 +278,9 @@ export class CLI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export function makeProgressCallback(
|
export function makeProgressCallback(
|
||||||
browser: Browser,
|
browser: Browser,
|
||||||
buildId: string
|
buildId: string
|
||||||
|
@ -47,6 +47,9 @@ export const executablePathByBrowser = {
|
|||||||
|
|
||||||
export {Browser, BrowserPlatform, ChromeReleaseChannel};
|
export {Browser, BrowserPlatform, ChromeReleaseChannel};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export async function resolveBuildId(
|
export async function resolveBuildId(
|
||||||
browser: Browser,
|
browser: Browser,
|
||||||
platform: BrowserPlatform,
|
platform: BrowserPlatform,
|
||||||
@ -74,6 +77,9 @@ export async function resolveBuildId(
|
|||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export async function createProfile(
|
export async function createProfile(
|
||||||
browser: Browser,
|
browser: Browser,
|
||||||
opts: ProfileOptions
|
opts: ProfileOptions
|
||||||
@ -87,6 +93,9 @@ export async function createProfile(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export function resolveSystemExecutablePath(
|
export function resolveSystemExecutablePath(
|
||||||
browser: Browser,
|
browser: Browser,
|
||||||
platform: BrowserPlatform,
|
platform: BrowserPlatform,
|
||||||
|
@ -19,6 +19,8 @@ import * as firefox from './firefox.js';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Supported browsers.
|
* Supported browsers.
|
||||||
|
*
|
||||||
|
* @public
|
||||||
*/
|
*/
|
||||||
export enum Browser {
|
export enum Browser {
|
||||||
CHROME = 'chrome',
|
CHROME = 'chrome',
|
||||||
@ -29,6 +31,8 @@ export enum Browser {
|
|||||||
/**
|
/**
|
||||||
* Platform names used to identify a OS platfrom x architecture combination in the way
|
* Platform names used to identify a OS platfrom x architecture combination in the way
|
||||||
* that is relevant for the browser download.
|
* that is relevant for the browser download.
|
||||||
|
*
|
||||||
|
* @public
|
||||||
*/
|
*/
|
||||||
export enum BrowserPlatform {
|
export enum BrowserPlatform {
|
||||||
LINUX = 'linux',
|
LINUX = 'linux',
|
||||||
@ -44,15 +48,24 @@ export const downloadUrls = {
|
|||||||
[Browser.FIREFOX]: firefox.resolveDownloadUrl,
|
[Browser.FIREFOX]: firefox.resolveDownloadUrl,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export enum BrowserTag {
|
export enum BrowserTag {
|
||||||
LATEST = 'latest',
|
LATEST = 'latest',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface ProfileOptions {
|
export interface ProfileOptions {
|
||||||
preferences: Record<string, unknown>;
|
preferences: Record<string, unknown>;
|
||||||
path: string;
|
path: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export enum ChromeReleaseChannel {
|
export enum ChromeReleaseChannel {
|
||||||
STABLE = 'stable',
|
STABLE = 'stable',
|
||||||
DEV = 'dev',
|
DEV = 'dev',
|
||||||
|
@ -18,6 +18,9 @@ import os from 'os';
|
|||||||
|
|
||||||
import {BrowserPlatform} from './browser-data/browser-data.js';
|
import {BrowserPlatform} from './browser-data/browser-data.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export function detectBrowserPlatform(): BrowserPlatform | undefined {
|
export function detectBrowserPlatform(): BrowserPlatform | undefined {
|
||||||
const platform = os.platform();
|
const platform = os.platform();
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
|
@ -97,6 +97,9 @@ export interface InstallOptions {
|
|||||||
unpack?: boolean;
|
unpack?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export type InstalledBrowser = {
|
export type InstalledBrowser = {
|
||||||
path: string;
|
path: string;
|
||||||
browser: Browser;
|
browser: Browser;
|
||||||
@ -104,6 +107,9 @@ export type InstalledBrowser = {
|
|||||||
platform: BrowserPlatform;
|
platform: BrowserPlatform;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export async function install(
|
export async function install(
|
||||||
options: InstallOptions
|
options: InstallOptions
|
||||||
): Promise<InstalledBrowser> {
|
): Promise<InstalledBrowser> {
|
||||||
@ -194,6 +200,9 @@ export async function install(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export async function canDownload(options: InstallOptions): Promise<boolean> {
|
export async function canDownload(options: InstallOptions): Promise<boolean> {
|
||||||
options.platform ??= detectBrowserPlatform();
|
options.platform ??= detectBrowserPlatform();
|
||||||
if (!options.platform) {
|
if (!options.platform) {
|
||||||
|
@ -36,7 +36,7 @@ const debugLaunch = debug('puppeteer:browsers:launcher');
|
|||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export interface Options {
|
export interface ComputeExecutablePathOptions {
|
||||||
/**
|
/**
|
||||||
* Root path to the storage directory.
|
* Root path to the storage directory.
|
||||||
*/
|
*/
|
||||||
@ -58,7 +58,12 @@ export interface Options {
|
|||||||
buildId: string;
|
buildId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function computeExecutablePath(options: Options): string {
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export function computeExecutablePath(
|
||||||
|
options: ComputeExecutablePathOptions
|
||||||
|
): string {
|
||||||
options.platform ??= detectBrowserPlatform();
|
options.platform ??= detectBrowserPlatform();
|
||||||
if (!options.platform) {
|
if (!options.platform) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -95,6 +100,10 @@ export interface SystemOptions {
|
|||||||
*/
|
*/
|
||||||
channel: ChromeReleaseChannel;
|
channel: ChromeReleaseChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export function computeSystemExecutablePath(options: SystemOptions): string {
|
export function computeSystemExecutablePath(options: SystemOptions): string {
|
||||||
options.platform ??= detectBrowserPlatform();
|
options.platform ??= detectBrowserPlatform();
|
||||||
if (!options.platform) {
|
if (!options.platform) {
|
||||||
@ -117,6 +126,9 @@ export function computeSystemExecutablePath(options: SystemOptions): string {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export type LaunchOptions = {
|
export type LaunchOptions = {
|
||||||
executablePath: string;
|
executablePath: string;
|
||||||
pipe?: boolean;
|
pipe?: boolean;
|
||||||
@ -130,16 +142,29 @@ export type LaunchOptions = {
|
|||||||
onExit?: () => Promise<void>;
|
onExit?: () => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export function launch(opts: LaunchOptions): Process {
|
export function launch(opts: LaunchOptions): Process {
|
||||||
return new Process(opts);
|
return new Process(opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export const CDP_WEBSOCKET_ENDPOINT_REGEX =
|
export const CDP_WEBSOCKET_ENDPOINT_REGEX =
|
||||||
/^DevTools listening on (ws:\/\/.*)$/;
|
/^DevTools listening on (ws:\/\/.*)$/;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export const WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX =
|
export const WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX =
|
||||||
/^WebDriver BiDi listening on (ws:\/\/.*)$/;
|
/^WebDriver BiDi listening on (ws:\/\/.*)$/;
|
||||||
|
|
||||||
class Process {
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export class Process {
|
||||||
#executablePath;
|
#executablePath;
|
||||||
#args: string[];
|
#args: string[];
|
||||||
#browserProcess: childProcess.ChildProcess;
|
#browserProcess: childProcess.ChildProcess;
|
||||||
@ -454,6 +479,9 @@ export function isErrnoException(obj: unknown): obj is NodeJS.ErrnoException {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export class TimeoutError extends Error {
|
export class TimeoutError extends Error {
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
@ -20,12 +20,18 @@ export {
|
|||||||
computeSystemExecutablePath,
|
computeSystemExecutablePath,
|
||||||
TimeoutError,
|
TimeoutError,
|
||||||
LaunchOptions,
|
LaunchOptions,
|
||||||
Options,
|
ComputeExecutablePathOptions as Options,
|
||||||
SystemOptions,
|
SystemOptions,
|
||||||
CDP_WEBSOCKET_ENDPOINT_REGEX,
|
CDP_WEBSOCKET_ENDPOINT_REGEX,
|
||||||
WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX,
|
WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX,
|
||||||
|
Process,
|
||||||
} from './launch.js';
|
} from './launch.js';
|
||||||
export {install, canDownload, InstallOptions} from './install.js';
|
export {
|
||||||
|
install,
|
||||||
|
canDownload,
|
||||||
|
InstallOptions,
|
||||||
|
InstalledBrowser,
|
||||||
|
} from './install.js';
|
||||||
export {detectBrowserPlatform} from './detectPlatform.js';
|
export {detectBrowserPlatform} from './detectPlatform.js';
|
||||||
export {
|
export {
|
||||||
resolveBuildId,
|
resolveBuildId,
|
||||||
|
Loading…
Reference in New Issue
Block a user