chore: separate code to semantic folders (#10914)

This commit is contained in:
jrandolf 2023-09-16 22:56:40 +02:00 committed by GitHub
parent b7bcc9a733
commit 09207a71b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
87 changed files with 394 additions and 373 deletions

View File

@ -127,7 +127,7 @@ sidebar_label: API
| [SerializedAXNode](./puppeteer.serializedaxnode.md) | Represents a Node and the properties of it that are relevant to Accessibility. |
| [SnapshotOptions](./puppeteer.snapshotoptions.md) | |
| [TracingOptions](./puppeteer.tracingoptions.md) | |
| [Viewport](./puppeteer.viewport.md) | Sets the viewport of the page. |
| [Viewport](./puppeteer.viewport.md) | |
| [WaitForOptions](./puppeteer.waitforoptions.md) | |
| [WaitForSelectorOptions](./puppeteer.waitforselectoroptions.md) | |
| [WaitForTargetOptions](./puppeteer.waitfortargetoptions.md) | |

View File

@ -4,8 +4,6 @@ sidebar_label: Viewport
# Viewport interface
Sets the viewport of the page.
#### Signature:
```typescript

View File

@ -1,6 +1,6 @@
import type {ProtocolMapping} from 'devtools-protocol/types/protocol-mapping.js';
import type {Connection} from '../common/Connection.js';
import type {Connection} from '../cdp/Connection.js';
import {EventEmitter, type EventType} from '../common/EventEmitter.js';
/**

View File

@ -18,7 +18,6 @@ import {type Protocol} from 'devtools-protocol';
import {type Frame} from '../api/Frame.js';
import {getQueryHandlerAndSelector} from '../common/GetQueryHandler.js';
import {type WaitForSelectorOptions} from '../common/IsolatedWorld.js';
import {LazyArg} from '../common/LazyArg.js';
import {
type ElementFor,
@ -39,7 +38,7 @@ import {
type MouseClickOptions,
} from './Input.js';
import {JSHandle} from './JSHandle.js';
import {type ScreenshotOptions} from './Page.js';
import {type ScreenshotOptions, type WaitForSelectorOptions} from './Page.js';
/**
* @public

View File

@ -18,17 +18,18 @@ import type Protocol from 'devtools-protocol';
import {type ClickOptions, type ElementHandle} from '../api/ElementHandle.js';
import {type HTTPResponse} from '../api/HTTPResponse.js';
import {type Page, type WaitTimeoutOptions} from '../api/Page.js';
import {type DeviceRequestPrompt} from '../common/DeviceRequestPrompt.js';
import {
type Page,
type WaitForSelectorOptions,
type WaitTimeoutOptions,
} from '../api/Page.js';
import {type DeviceRequestPrompt} from '../cdp/DeviceRequestPrompt.js';
import {type IsolatedWorldChart} from '../cdp/IsolatedWorld.js';
import {type PuppeteerLifeCycleEvent} from '../cdp/LifecycleWatcher.js';
import {EventEmitter, type EventType} from '../common/EventEmitter.js';
import {getQueryHandlerAndSelector} from '../common/GetQueryHandler.js';
import {transposeIterableHandle} from '../common/HandleIterator.js';
import {
type IsolatedWorldChart,
type WaitForSelectorOptions,
} from '../common/IsolatedWorld.js';
import {LazyArg} from '../common/LazyArg.js';
import {type PuppeteerLifeCycleEvent} from '../common/LifecycleWatcher.js';
import {
type Awaitable,
type EvaluateFunc,

View File

@ -36,12 +36,21 @@ import {
} from '../../third_party/rxjs/rxjs.js';
import type {HTTPRequest} from '../api/HTTPRequest.js';
import type {HTTPResponse} from '../api/HTTPResponse.js';
import type {Accessibility} from '../common/Accessibility.js';
import type {BidiNetworkManager} from '../common/bidi/NetworkManager.js';
import type {BidiNetworkManager} from '../bidi/NetworkManager.js';
import type {Accessibility} from '../cdp/Accessibility.js';
import type {Coverage} from '../cdp/Coverage.js';
import {type DeviceRequestPrompt} from '../cdp/DeviceRequestPrompt.js';
import type {PuppeteerLifeCycleEvent} from '../cdp/LifecycleWatcher.js';
import {
type NetworkManager as CdpNetworkManager,
type Credentials,
type NetworkConditions,
NetworkManagerEvent,
} from '../cdp/NetworkManager.js';
import type {Tracing} from '../cdp/Tracing.js';
import type {WebWorker} from '../cdp/WebWorker.js';
import type {ConsoleMessage} from '../common/ConsoleMessage.js';
import type {Coverage} from '../common/Coverage.js';
import {type Device} from '../common/Device.js';
import {type DeviceRequestPrompt} from '../common/DeviceRequestPrompt.js';
import {TargetCloseError} from '../common/Errors.js';
import {
EventEmitter,
@ -50,22 +59,12 @@ import {
type Handler,
} from '../common/EventEmitter.js';
import type {FileChooser} from '../common/FileChooser.js';
import type {WaitForSelectorOptions} from '../common/IsolatedWorld.js';
import type {PuppeteerLifeCycleEvent} from '../common/LifecycleWatcher.js';
import {
type NetworkManager as CdpNetworkManager,
type Credentials,
type NetworkConditions,
NetworkManagerEvent,
} from '../common/NetworkManager.js';
import {
type LowerCasePaperFormat,
paperFormats,
type ParsedPDFOptions,
type PDFOptions,
} from '../common/PDFOptions.js';
import type {Viewport} from '../common/PuppeteerViewport.js';
import type {Tracing} from '../common/Tracing.js';
import type {
Awaitable,
EvaluateFunc,
@ -81,7 +80,7 @@ import {
timeout,
withSourcePuppeteerURLIfNone,
} from '../common/util.js';
import type {WebWorker} from '../common/WebWorker.js';
import type {Viewport} from '../common/Viewport.js';
import {assert} from '../util/assert.js';
import {type Deferred} from '../util/Deferred.js';
@ -162,6 +161,38 @@ export interface WaitForOptions {
waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
}
/**
* @public
*/
export interface WaitForSelectorOptions {
/**
* Wait for the selected element to be present in DOM and to be visible, i.e.
* to not have `display: none` or `visibility: hidden` CSS properties.
*
* @defaultValue `false`
*/
visible?: boolean;
/**
* Wait for the selected element to not be found in the DOM or to be hidden,
* i.e. have `display: none` or `visibility: hidden` CSS properties.
*
* @defaultValue `false`
*/
hidden?: boolean;
/**
* Maximum time to wait in milliseconds. Pass `0` to disable timeout.
*
* The default value can be changed by using {@link Page.setDefaultTimeout}
*
* @defaultValue `30_000` (30 seconds)
*/
timeout?: number;
/**
* A signal object that allows you to cancel a waitForSelector call.
*/
signal?: AbortSignal;
}
/**
* @public
*/

View File

@ -17,7 +17,7 @@
import type {Browser} from '../api/Browser.js';
import type {BrowserContext} from '../api/BrowserContext.js';
import {type Page} from '../api/Page.js';
import {type WebWorker} from '../common/WebWorker.js';
import {type WebWorker} from '../cdp/WebWorker.js';
import {type CDPSession} from './CDPSession.js';

View File

@ -15,7 +15,7 @@
*/
import {type Observable} from '../../../third_party/rxjs/rxjs.js';
import {type HandleFor} from '../../common/common.js';
import {type HandleFor} from '../../common/types.js';
import {Locator, type VisibilityOption} from './locators.js';

View File

@ -22,7 +22,7 @@ import {
mergeMap,
throwIfEmpty,
} from '../../../third_party/rxjs/rxjs.js';
import {type Awaitable, type HandleFor} from '../../common/common.js';
import {type Awaitable, type HandleFor} from '../../common/types.js';
import {DelegatedLocator} from './DelegatedLocator.js';
import {type ActionOptions, type Locator} from './locators.js';

View File

@ -19,7 +19,7 @@ import {
from,
mergeMap,
} from '../../../third_party/rxjs/rxjs.js';
import {type Awaitable, type HandleFor} from '../../common/common.js';
import {type Awaitable, type HandleFor} from '../../common/types.js';
import {
type ActionOptions,

View File

@ -15,7 +15,7 @@
*/
import {type Observable, race} from '../../../third_party/rxjs/rxjs.js';
import {type HandleFor} from '../../puppeteer-core.js';
import {type HandleFor} from '../../common/types.js';
import {type ActionOptions, Locator} from './locators.js';

View File

@ -18,10 +18,10 @@ import * as BidiMapper from 'chromium-bidi/lib/cjs/bidiMapper/bidiMapper.js';
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import type {ProtocolMapping} from 'devtools-protocol/types/protocol-mapping.js';
import {type CDPEvents, type CDPSession} from '../../api/CDPSession.js';
import {type Connection as CdpConnection} from '../Connection.js';
import {TargetCloseError} from '../Errors.js';
import {type Handler} from '../EventEmitter.js';
import {type CDPEvents, type CDPSession} from '../api/CDPSession.js';
import {type Connection as CdpConnection} from '../cdp/Connection.js';
import {TargetCloseError} from '../common/Errors.js';
import {type Handler} from '../common/EventEmitter.js';
import {BidiConnection} from './Connection.js';

View File

@ -23,12 +23,12 @@ import {
type BrowserCloseCallback,
type BrowserContextOptions,
BrowserEvent,
} from '../../api/Browser.js';
import {BrowserContextEvent} from '../../api/BrowserContext.js';
import {type Page} from '../../api/Page.js';
import {type Target} from '../../api/Target.js';
import {type Handler} from '../EventEmitter.js';
import {type Viewport} from '../PuppeteerViewport.js';
} from '../api/Browser.js';
import {BrowserContextEvent} from '../api/BrowserContext.js';
import {type Page} from '../api/Page.js';
import {type Target} from '../api/Target.js';
import {type Handler} from '../common/EventEmitter.js';
import {type Viewport} from '../common/Viewport.js';
import {BidiBrowserContext} from './BrowserContext.js';
import {BrowsingContext, BrowsingContextEvent} from './BrowsingContext.js';
@ -39,7 +39,7 @@ import {
BiDiPageTarget,
type BidiTarget,
} from './Target.js';
import {debugError} from './utils.js';
import {debugError} from './util.js';
/**
* @internal

View File

@ -16,10 +16,10 @@
import * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import {BrowserContext} from '../../api/BrowserContext.js';
import {type Page} from '../../api/Page.js';
import {type Target} from '../../api/Target.js';
import {type Viewport} from '../PuppeteerViewport.js';
import {BrowserContext} from '../api/BrowserContext.js';
import {type Page} from '../api/Page.js';
import {type Target} from '../api/Target.js';
import {type Viewport} from '../common/Viewport.js';
import {type BidiBrowser} from './Browser.js';
import {type BidiConnection} from './Connection.js';

View File

@ -1,19 +1,23 @@
import * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import type ProtocolMapping from 'devtools-protocol/types/protocol-mapping.js';
import {CDPSession} from '../../api/CDPSession.js';
import {type WaitForOptions} from '../../api/Page.js';
import {assert} from '../../util/assert.js';
import {Deferred} from '../../util/Deferred.js';
import {type Connection as CdpConnection} from '../Connection.js';
import {ProtocolError, TargetCloseError, TimeoutError} from '../Errors.js';
import {type EventType} from '../EventEmitter.js';
import {type PuppeteerLifeCycleEvent} from '../LifecycleWatcher.js';
import {setPageContent, waitWithTimeout} from '../util.js';
import {CDPSession} from '../api/CDPSession.js';
import {type WaitForOptions} from '../api/Page.js';
import {type Connection as CdpConnection} from '../cdp/Connection.js';
import {type PuppeteerLifeCycleEvent} from '../cdp/LifecycleWatcher.js';
import {
ProtocolError,
TargetCloseError,
TimeoutError,
} from '../common/Errors.js';
import {type EventType} from '../common/EventEmitter.js';
import {setPageContent, waitWithTimeout} from '../common/util.js';
import {assert} from '../util/assert.js';
import {Deferred} from '../util/Deferred.js';
import {type BidiConnection} from './Connection.js';
import {Realm} from './Realm.js';
import {debugError} from './utils.js';
import {debugError} from './util.js';
/**
* @internal

View File

@ -18,7 +18,7 @@ import {describe, it} from 'node:test';
import expect from 'expect';
import {type ConnectionTransport} from '../ConnectionTransport.js';
import {type ConnectionTransport} from '../common/ConnectionTransport.js';
import {BidiConnection} from './Connection.js';

View File

@ -16,13 +16,13 @@
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import {CallbackRegistry} from '../Connection.js';
import {type ConnectionTransport} from '../ConnectionTransport.js';
import {debug} from '../Debug.js';
import {EventEmitter} from '../EventEmitter.js';
import {CallbackRegistry} from '../cdp/Connection.js';
import {type ConnectionTransport} from '../common/ConnectionTransport.js';
import {debug} from '../common/Debug.js';
import {EventEmitter} from '../common/EventEmitter.js';
import {type BrowsingContext, cdpSessions} from './BrowsingContext.js';
import {debugError} from './utils.js';
import {debugError} from './util.js';
const debugProtocolSend = debug('puppeteer:webDriverBiDi:SEND ►');
const debugProtocolReceive = debug('puppeteer:webDriverBiDi:RECV ◀');

View File

@ -16,7 +16,7 @@
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import {Dialog} from '../../api/Dialog.js';
import {Dialog} from '../api/Dialog.js';
import {type BrowsingContext} from './BrowsingContext.js';

View File

@ -16,8 +16,8 @@
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import {type AutofillData, ElementHandle} from '../../api/ElementHandle.js';
import {throwIfDisposed} from '../../util/decorators.js';
import {type AutofillData, ElementHandle} from '../api/ElementHandle.js';
import {throwIfDisposed} from '../util/decorators.js';
import {type BidiFrame} from './Frame.js';
import {BidiJSHandle} from './JSHandle.js';

View File

@ -16,15 +16,15 @@
import * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import {assert} from '../../util/assert.js';
import {Deferred} from '../../util/Deferred.js';
import {interpolateFunction, stringifyFunction} from '../../util/Function.js';
import {type Awaitable, type FlattenHandle} from '../types.js';
import {type Awaitable, type FlattenHandle} from '../common/types.js';
import {assert} from '../util/assert.js';
import {Deferred} from '../util/Deferred.js';
import {interpolateFunction, stringifyFunction} from '../util/Function.js';
import {type BidiConnection} from './Connection.js';
import {type BidiFrame} from './Frame.js';
import {BidiSerializer} from './Serializer.js';
import {debugError} from './utils.js';
import {debugError} from './util.js';
type SendArgsChannel<Args> = (value: [id: number, args: Args]) => void;
type SendResolveChannel<Ret> = (

View File

@ -16,14 +16,14 @@
import * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import {type CDPSession} from '../../api/CDPSession.js';
import {Frame, throwIfDetached} from '../../api/Frame.js';
import {Deferred} from '../../util/Deferred.js';
import {UTILITY_WORLD_NAME} from '../FrameManager.js';
import {type PuppeteerLifeCycleEvent} from '../LifecycleWatcher.js';
import {type TimeoutSettings} from '../TimeoutSettings.js';
import {type Awaitable} from '../types.js';
import {waitForEvent} from '../util.js';
import {type CDPSession} from '../api/CDPSession.js';
import {Frame, throwIfDetached} from '../api/Frame.js';
import {UTILITY_WORLD_NAME} from '../cdp/FrameManager.js';
import {type PuppeteerLifeCycleEvent} from '../cdp/LifecycleWatcher.js';
import {type TimeoutSettings} from '../common/TimeoutSettings.js';
import {type Awaitable} from '../common/types.js';
import {waitForEvent} from '../common/util.js';
import {Deferred} from '../util/Deferred.js';
import {
type BrowsingContext,

View File

@ -15,8 +15,8 @@
*/
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import {type Frame} from '../../api/Frame.js';
import {HTTPRequest, type ResourceType} from '../../api/HTTPRequest.js';
import {type Frame} from '../api/Frame.js';
import {HTTPRequest, type ResourceType} from '../api/HTTPRequest.js';
import {type BidiHTTPResponse} from './HTTPResponse.js';

View File

@ -16,11 +16,11 @@
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import type Protocol from 'devtools-protocol';
import {type Frame} from '../../api/Frame.js';
import {type Frame} from '../api/Frame.js';
import {
HTTPResponse as HTTPResponse,
type RemoteAddress,
} from '../../api/HTTPResponse.js';
} from '../api/HTTPResponse.js';
import {type BidiHTTPRequest} from './HTTPRequest.js';

View File

@ -16,7 +16,7 @@
import * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import {type Point} from '../../api/ElementHandle.js';
import {type Point} from '../api/ElementHandle.js';
import {
Keyboard as BaseKeyboard,
Mouse as BaseMouse,
@ -29,8 +29,8 @@ import {
type MouseMoveOptions,
type MouseOptions,
type MouseWheelOptions,
} from '../../api/Input.js';
import {type KeyInput} from '../USKeyboardLayout.js';
} from '../api/Input.js';
import {type KeyInput} from '../common/USKeyboardLayout.js';
import {type BrowsingContext} from './BrowsingContext.js';

View File

@ -17,13 +17,13 @@
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import type Protocol from 'devtools-protocol';
import {type ElementHandle} from '../../api/ElementHandle.js';
import {JSHandle} from '../../api/JSHandle.js';
import {type ElementHandle} from '../api/ElementHandle.js';
import {JSHandle} from '../api/JSHandle.js';
import {type Realm} from './Realm.js';
import {type Sandbox} from './Sandbox.js';
import {BidiSerializer} from './Serializer.js';
import {releaseReference} from './utils.js';
import {releaseReference} from './util.js';
/**
* @internal

View File

@ -16,12 +16,12 @@
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import {NetworkManagerEvent} from '../cdp/NetworkManager.js';
import {
EventEmitter,
EventSubscription,
type EventType,
} from '../EventEmitter.js';
import {NetworkManagerEvent} from '../NetworkManager.js';
} from '../common/EventEmitter.js';
import {type BidiConnection} from './Connection.js';
import {type BidiFrame} from './Frame.js';

View File

@ -19,7 +19,7 @@ import type {Readable} from 'stream';
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import type Protocol from 'devtools-protocol';
import {type CDPSession} from '../../api/CDPSession.js';
import {type CDPSession} from '../api/CDPSession.js';
import {
type GeolocationOptions,
type MediaFeature,
@ -28,25 +28,22 @@ import {
PageEvent,
type ScreenshotOptions,
type WaitForOptions,
} from '../../api/Page.js';
import {assert} from '../../util/assert.js';
import {Deferred} from '../../util/Deferred.js';
import {Accessibility} from '../Accessibility.js';
} from '../api/Page.js';
import {Accessibility} from '../cdp/Accessibility.js';
import {Coverage} from '../cdp/Coverage.js';
import {EmulationManager as CdpEmulationManager} from '../cdp/EmulationManager.js';
import {FrameTree} from '../cdp/FrameTree.js';
import {NetworkManagerEvent} from '../cdp/NetworkManager.js';
import {Tracing} from '../cdp/Tracing.js';
import {
ConsoleMessage,
type ConsoleMessageLocation,
} from '../ConsoleMessage.js';
import {Coverage} from '../Coverage.js';
import {EmulationManager as CdpEmulationManager} from '../EmulationManager.js';
import {TargetCloseError} from '../Errors.js';
import {type Handler} from '../EventEmitter.js';
import {FrameTree} from '../FrameTree.js';
import {NetworkManagerEvent} from '../NetworkManager.js';
import {type PDFOptions} from '../PDFOptions.js';
import {type Viewport} from '../PuppeteerViewport.js';
import {TimeoutSettings} from '../TimeoutSettings.js';
import {Tracing} from '../Tracing.js';
import {type Awaitable} from '../types.js';
} from '../common/ConsoleMessage.js';
import {TargetCloseError} from '../common/Errors.js';
import {type Handler} from '../common/EventEmitter.js';
import {type PDFOptions} from '../common/PDFOptions.js';
import {TimeoutSettings} from '../common/TimeoutSettings.js';
import {type Awaitable} from '../common/types.js';
import {
debugError,
evaluationString,
@ -54,7 +51,10 @@ import {
validateDialogType,
waitForEvent,
waitWithTimeout,
} from '../util.js';
} from '../common/util.js';
import {type Viewport} from '../common/Viewport.js';
import {assert} from '../util/assert.js';
import {Deferred} from '../util/Deferred.js';
import {type BidiBrowser} from './Browser.js';
import {type BidiBrowserContext} from './BrowserContext.js';

View File

@ -1,22 +1,22 @@
import * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import type PuppeteerUtil from '../../injected/injected.js';
import {stringifyFunction} from '../../util/Function.js';
import {EventEmitter, type EventType} from '../EventEmitter.js';
import {scriptInjector} from '../ScriptInjector.js';
import {type EvaluateFunc, type HandleFor} from '../types.js';
import {EventEmitter, type EventType} from '../common/EventEmitter.js';
import {scriptInjector} from '../common/ScriptInjector.js';
import {type EvaluateFunc, type HandleFor} from '../common/types.js';
import {
PuppeteerURL,
getSourcePuppeteerURLIfAvailable,
isString,
} from '../util.js';
} from '../common/util.js';
import type PuppeteerUtil from '../injected/injected.js';
import {stringifyFunction} from '../util/Function.js';
import {type BidiConnection} from './Connection.js';
import {BidiElementHandle} from './ElementHandle.js';
import {BidiJSHandle} from './JSHandle.js';
import {type Sandbox} from './Sandbox.js';
import {BidiSerializer} from './Serializer.js';
import {createEvaluationError} from './utils.js';
import {createEvaluationError} from './util.js';
export const SOURCE_URL_REGEX = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m;

View File

@ -14,11 +14,11 @@
* limitations under the License.
*/
import {type JSHandle} from '../../api/JSHandle.js';
import {Realm} from '../../api/Realm.js';
import {type TimeoutSettings} from '../TimeoutSettings.js';
import {type EvaluateFunc, type HandleFor} from '../types.js';
import {withSourcePuppeteerURLIfNone} from '../util.js';
import {type JSHandle} from '../api/JSHandle.js';
import {Realm} from '../api/Realm.js';
import {type TimeoutSettings} from '../common/TimeoutSettings.js';
import {type EvaluateFunc, type HandleFor} from '../common/types.js';
import {withSourcePuppeteerURLIfNone} from '../common/util.js';
import {type BrowsingContext} from './BrowsingContext.js';
import {type BidiFrame} from './Frame.js';

View File

@ -16,8 +16,8 @@
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import {LazyArg} from '../LazyArg.js';
import {debugError, isDate, isPlainObject, isRegExp} from '../util.js';
import {LazyArg} from '../common/LazyArg.js';
import {debugError, isDate, isPlainObject, isRegExp} from '../common/util.js';
import {BidiElementHandle} from './ElementHandle.js';
import {BidiJSHandle} from './JSHandle.js';

View File

@ -14,9 +14,9 @@
* limitations under the License.
*/
import {type CDPSession} from '../../api/CDPSession.js';
import {Target, TargetType} from '../../api/Target.js';
import type {WebWorker} from '../WebWorker.js';
import {type CDPSession} from '../api/CDPSession.js';
import {Target, TargetType} from '../api/Target.js';
import type {WebWorker} from '../cdp/WebWorker.js';
import {type BidiBrowser} from './Browser.js';
import {type BidiBrowserContext} from './BrowserContext.js';

View File

@ -16,8 +16,8 @@
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import {debug} from '../Debug.js';
import {PuppeteerURL} from '../util.js';
import {debug} from '../common/Debug.js';
import {PuppeteerURL} from '../common/util.js';
import {type Realm} from './Realm.js';
import {BidiSerializer} from './Serializer.js';
@ -26,6 +26,7 @@ import {BidiSerializer} from './Serializer.js';
* @internal
*/
export const debugError = debug('puppeteer:error');
/**
* @internal
*/

View File

@ -18,12 +18,12 @@ import {type Protocol} from 'devtools-protocol';
import {type CDPSession} from '../api/CDPSession.js';
import {type ElementHandle} from '../api/ElementHandle.js';
import {QueryHandler, type QuerySelector} from '../common/QueryHandler.js';
import {type AwaitableIterable} from '../common/types.js';
import {assert} from '../util/assert.js';
import {AsyncIterableUtil} from '../util/AsyncIterableUtil.js';
import {type IsolatedWorld} from './IsolatedWorld.js';
import {QueryHandler, type QuerySelector} from './QueryHandler.js';
import {type AwaitableIterable} from './types.js';
const queryAXTree = async (
client: CDPSession,

View File

@ -1,8 +1,8 @@
import {JSHandle} from '../api/JSHandle.js';
import {debugError} from '../common/util.js';
import {isErrorLike} from '../util/ErrorLike.js';
import {type ExecutionContext} from './ExecutionContext.js';
import {debugError} from './util.js';
/**
* @internal

View File

@ -32,13 +32,14 @@ import {BrowserContext, BrowserContextEvent} from '../api/BrowserContext.js';
import {type CDPSession, CDPSessionEvent} from '../api/CDPSession.js';
import {type Page} from '../api/Page.js';
import {type Target} from '../api/Target.js';
import {TaskQueue} from '../common/TaskQueue.js';
import {type Viewport} from '../common/Viewport.js';
import {USE_TAB_TARGET} from '../environment.js';
import {assert} from '../util/assert.js';
import {ChromeTargetManager} from './ChromeTargetManager.js';
import {type Connection} from './Connection.js';
import {FirefoxTargetManager} from './FirefoxTargetManager.js';
import {type Viewport} from './PuppeteerViewport.js';
import {
type CdpTarget,
DevToolsTarget,
@ -48,7 +49,6 @@ import {
WorkerTarget,
} from './Target.js';
import {type TargetManager, TargetManagerEvent} from './TargetManager.js';
import {TaskQueue} from './TaskQueue.js';
/**
* @internal

View File

@ -18,17 +18,17 @@ import {
type IsPageTargetCallback,
type TargetFilterCallback,
} from '../api/Browser.js';
import {type ConnectionTransport} from '../common/ConnectionTransport.js';
import {getFetch} from '../common/fetch.js';
import {debugError} from '../common/util.js';
import {type Viewport} from '../common/Viewport.js';
import {isNode} from '../environment.js';
import {assert} from '../util/assert.js';
import {isErrorLike} from '../util/ErrorLike.js';
import {CdpBrowser} from './Browser.js';
import {Connection} from './Connection.js';
import {type ConnectionTransport} from './ConnectionTransport.js';
import {getFetch} from './fetch.js';
import type {ConnectOptions} from './Puppeteer.js';
import {type Viewport} from './PuppeteerViewport.js';
import {debugError} from './util.js';
/**
* Generic browser options that can be passed when launching any browser or when
* connecting to an existing browser instance.
@ -72,8 +72,8 @@ export interface BrowserConnectOptions {
const getWebSocketTransportClass = async () => {
return isNode
? (await import('./NodeWebSocketTransport.js')).NodeWebSocketTransport
: (await import('./BrowserWebSocketTransport.js'))
? (await import('../node/NodeWebSocketTransport.js')).NodeWebSocketTransport
: (await import('../common/BrowserWebSocketTransport.js'))
.BrowserWebSocketTransport;
};

View File

@ -5,6 +5,7 @@ import {
CDPSession,
CDPSessionEvent,
} from '../api/CDPSession.js';
import {TargetCloseError} from '../common/Errors.js';
import {assert} from '../util/assert.js';
import {
@ -12,7 +13,6 @@ import {
type Connection,
createProtocolErrorMessage,
} from './Connection.js';
import {TargetCloseError} from './Errors.js';
import {type CdpTarget} from './Target.js';
/**

View File

@ -19,11 +19,12 @@ import {type Protocol} from 'devtools-protocol';
import {type TargetFilterCallback} from '../api/Browser.js';
import {CDPSession, CDPSessionEvent} from '../api/CDPSession.js';
import {TargetType} from '../api/Target.js';
import {EventEmitter} from '../common/EventEmitter.js';
import {debugError} from '../common/util.js';
import {assert} from '../util/assert.js';
import {Deferred} from '../util/Deferred.js';
import {type Connection} from './Connection.js';
import {EventEmitter} from './EventEmitter.js';
import {CdpTarget, InitializationStatus} from './Target.js';
import {
type TargetFactory,
@ -31,7 +32,6 @@ import {
TargetManagerEvent,
type TargetManagerEvents,
} from './TargetManager.js';
import {debugError} from './util.js';
function isTargetExposed(target: CdpTarget): boolean {
return target.type() !== TargetType.TAB && !target._subtype();

View File

@ -22,14 +22,14 @@ import {
CDPSessionEvent,
type CDPSessionEvents,
} from '../api/CDPSession.js';
import {ConnectionTransport} from '../common/ConnectionTransport.js';
import {debug} from '../common/Debug.js';
import {ProtocolError, TargetCloseError} from '../common/Errors.js';
import {EventEmitter} from '../common/EventEmitter.js';
import {debugError} from '../common/util.js';
import {Deferred} from '../util/Deferred.js';
import {CdpCDPSession} from './CDPSession.js';
import {ConnectionTransport} from './ConnectionTransport.js';
import {debug} from './Debug.js';
import {ProtocolError, TargetCloseError} from './Errors.js';
import {EventEmitter} from './EventEmitter.js';
import {debugError} from './util.js';
const debugProtocolSend = debug('puppeteer:protocol:SEND ►');
const debugProtocolReceive = debug('puppeteer:protocol:RECV ◀');

View File

@ -17,11 +17,10 @@
import {type Protocol} from 'devtools-protocol';
import {type CDPSession} from '../api/CDPSession.js';
import {EventSubscription} from '../common/EventEmitter.js';
import {debugError, PuppeteerURL} from '../common/util.js';
import {assert} from '../util/assert.js';
import {EventSubscription} from './EventEmitter.js';
import {debugError, PuppeteerURL} from './util.js';
/**
* The CoverageEntry class represents one entry of the coverage report.
* @public

View File

@ -19,15 +19,15 @@ import {describe, it} from 'node:test';
import expect from 'expect';
import {type CDPSessionEvents} from '../api/CDPSession.js';
import {TimeoutError} from '../common/Errors.js';
import {EventEmitter} from '../common/EventEmitter.js';
import {TimeoutSettings} from '../common/TimeoutSettings.js';
import {
DeviceRequestPrompt,
DeviceRequestPromptDevice,
DeviceRequestPromptManager,
} from './DeviceRequestPrompt.js';
import {TimeoutError} from './Errors.js';
import {EventEmitter} from './EventEmitter.js';
import {TimeoutSettings} from './TimeoutSettings.js';
class MockCDPSession extends EventEmitter<CDPSessionEvents> {
async send(): Promise<any> {}

View File

@ -18,11 +18,10 @@ import type Protocol from 'devtools-protocol';
import {type CDPSession} from '../api/CDPSession.js';
import {type WaitTimeoutOptions} from '../api/Page.js';
import {type TimeoutSettings} from '../common/TimeoutSettings.js';
import {assert} from '../util/assert.js';
import {Deferred} from '../util/Deferred.js';
import {type TimeoutSettings} from './TimeoutSettings.js';
/**
* Device in a request prompt.
*

View File

@ -19,6 +19,7 @@ import {type Protocol} from 'devtools-protocol';
import {type CDPSession} from '../api/CDPSession.js';
import {type AutofillData, ElementHandle} from '../api/ElementHandle.js';
import {type Page, type ScreenshotOptions} from '../api/Page.js';
import {debugError} from '../common/util.js';
import {assert} from '../util/assert.js';
import {throwIfDisposed} from '../util/decorators.js';
@ -26,7 +27,6 @@ import {type CdpFrame} from './Frame.js';
import {type FrameManager} from './FrameManager.js';
import {type IsolatedWorld} from './IsolatedWorld.js';
import {CdpJSHandle} from './JSHandle.js';
import {debugError} from './util.js';
/**
* The CdpElementHandle extends ElementHandle now to keep compatibility

View File

@ -17,13 +17,12 @@ import {type Protocol} from 'devtools-protocol';
import {type CDPSession, CDPSessionEvent} from '../api/CDPSession.js';
import {type GeolocationOptions, type MediaFeature} from '../api/Page.js';
import {debugError} from '../common/util.js';
import {type Viewport} from '../common/Viewport.js';
import {assert} from '../util/assert.js';
import {invokeAtMostOnceForArguments} from '../util/decorators.js';
import {isErrorLike} from '../util/ErrorLike.js';
import {type Viewport} from './PuppeteerViewport.js';
import {debugError} from './util.js';
interface ViewportState {
viewport?: Viewport;
active: boolean;

View File

@ -19,6 +19,17 @@ import {type Protocol} from 'devtools-protocol';
import {type CDPSession} from '../api/CDPSession.js';
import type {ElementHandle} from '../api/ElementHandle.js';
import {type JSHandle} from '../api/JSHandle.js';
import {LazyArg} from '../common/LazyArg.js';
import {scriptInjector} from '../common/ScriptInjector.js';
import {type EvaluateFunc, type HandleFor} from '../common/types.js';
import {
PuppeteerURL,
createEvaluationError,
debugError,
getSourcePuppeteerURLIfAvailable,
isString,
valueFromRemoteObject,
} from '../common/util.js';
import type PuppeteerUtil from '../injected/injected.js';
import {AsyncIterableUtil} from '../util/AsyncIterableUtil.js';
import {stringifyFunction} from '../util/Function.js';
@ -28,17 +39,6 @@ import {Binding} from './Binding.js';
import {CdpElementHandle} from './ElementHandle.js';
import {type IsolatedWorld} from './IsolatedWorld.js';
import {CdpJSHandle} from './JSHandle.js';
import {LazyArg} from './LazyArg.js';
import {scriptInjector} from './ScriptInjector.js';
import {type EvaluateFunc, type HandleFor} from './types.js';
import {
PuppeteerURL,
createEvaluationError,
createCdpHandle,
getSourcePuppeteerURLIfAvailable,
isString,
valueFromRemoteObject,
} from './util.js';
const SOURCE_URL_REGEX = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m;
@ -391,3 +391,35 @@ const rewriteError = (error: Error): Protocol.Runtime.EvaluateResponse => {
}
throw error;
};
/**
* @internal
*/
export function createCdpHandle(
realm: IsolatedWorld,
remoteObject: Protocol.Runtime.RemoteObject
): JSHandle | ElementHandle<Node> {
if (remoteObject.subtype === 'node') {
return new CdpElementHandle(realm, remoteObject);
}
return new CdpJSHandle(realm, remoteObject);
}
/**
* @internal
*/
export async function releaseObject(
client: CDPSession,
remoteObject: Protocol.Runtime.RemoteObject
): Promise<void> {
if (!remoteObject.objectId) {
return;
}
await client
.send('Runtime.releaseObject', {objectId: remoteObject.objectId})
.catch(error => {
// Exceptions might happen in case of a page been navigated or closed.
// Swallow these since they are harmless and we don't leak anything in this case.
debugError(error);
});
}

View File

@ -18,11 +18,11 @@ import {type Protocol} from 'devtools-protocol';
import {type TargetFilterCallback} from '../api/Browser.js';
import {type CDPSession, CDPSessionEvent} from '../api/CDPSession.js';
import {EventEmitter} from '../common/EventEmitter.js';
import {assert} from '../util/assert.js';
import {Deferred} from '../util/Deferred.js';
import {type Connection} from './Connection.js';
import {EventEmitter} from './EventEmitter.js';
import {type CdpTarget} from './Target.js';
import {
type TargetFactory,

View File

@ -20,6 +20,7 @@ import {type CDPSession} from '../api/CDPSession.js';
import {Frame, FrameEvent, throwIfDetached} from '../api/Frame.js';
import {type HTTPResponse} from '../api/HTTPResponse.js';
import {type Page, type WaitTimeoutOptions} from '../api/Page.js';
import {setPageContent} from '../common/util.js';
import {assert} from '../util/assert.js';
import {Deferred} from '../util/Deferred.js';
import {isErrorLike} from '../util/ErrorLike.js';
@ -35,7 +36,6 @@ import {
LifecycleWatcher,
type PuppeteerLifeCycleEvent,
} from './LifecycleWatcher.js';
import {setPageContent} from './util.js';
/**
* @internal

View File

@ -19,6 +19,9 @@ import {type Protocol} from 'devtools-protocol';
import {type CDPSession, CDPSessionEvent} from '../api/CDPSession.js';
import {FrameEvent} from '../api/Frame.js';
import {type Page} from '../api/Page.js';
import {EventEmitter, type EventType} from '../common/EventEmitter.js';
import {type TimeoutSettings} from '../common/TimeoutSettings.js';
import {debugError, PuppeteerURL} from '../common/util.js';
import {assert} from '../util/assert.js';
import {Deferred} from '../util/Deferred.js';
import {isErrorLike} from '../util/ErrorLike.js';
@ -26,7 +29,6 @@ import {isErrorLike} from '../util/ErrorLike.js';
import {CdpCDPSession} from './CDPSession.js';
import {isTargetClosedError} from './Connection.js';
import {DeviceRequestPromptManager} from './DeviceRequestPrompt.js';
import {EventEmitter, type EventType} from './EventEmitter.js';
import {ExecutionContext} from './ExecutionContext.js';
import {CdpFrame} from './Frame.js';
import {FrameTree} from './FrameTree.js';
@ -34,8 +36,6 @@ import {type IsolatedWorld} from './IsolatedWorld.js';
import {MAIN_WORLD, PUPPETEER_WORLD} from './IsolatedWorlds.js';
import {NetworkManager} from './NetworkManager.js';
import {type CdpTarget} from './Target.js';
import {type TimeoutSettings} from './TimeoutSettings.js';
import {debugError, PuppeteerURL} from './util.js';
/**
* @internal

View File

@ -29,11 +29,10 @@ import {
STATUS_TEXTS,
} from '../api/HTTPRequest.js';
import {type HTTPResponse} from '../api/HTTPResponse.js';
import {type ProtocolError} from '../common/Errors.js';
import {debugError, isString} from '../common/util.js';
import {assert} from '../util/assert.js';
import {type ProtocolError} from './Errors.js';
import {debugError, isString} from './util.js';
/**
* @internal
*/

View File

@ -18,11 +18,11 @@ import {type Protocol} from 'devtools-protocol';
import {type CDPSession} from '../api/CDPSession.js';
import {type Frame} from '../api/Frame.js';
import {HTTPResponse, type RemoteAddress} from '../api/HTTPResponse.js';
import {ProtocolError} from '../common/Errors.js';
import {SecurityDetails} from '../common/SecurityDetails.js';
import {Deferred} from '../util/Deferred.js';
import {ProtocolError} from './Errors.js';
import {type CdpHTTPRequest} from './HTTPRequest.js';
import {SecurityDetails} from './SecurityDetails.js';
/**
* @internal

View File

@ -31,13 +31,12 @@ import {
Touchscreen,
type KeyboardTypeOptions,
} from '../api/Input.js';
import {assert} from '../util/assert.js';
import {
_keyDefinitions,
type KeyDefinition,
type KeyInput,
} from './USKeyboardLayout.js';
} from '../common/USKeyboardLayout.js';
import {assert} from '../util/assert.js';
type KeyDescription = Required<
Pick<KeyDefinition, 'keyCode' | 'key' | 'text' | 'code' | 'location'>

View File

@ -19,58 +19,25 @@ import {type Protocol} from 'devtools-protocol';
import {type CDPSession} from '../api/CDPSession.js';
import {type JSHandle} from '../api/JSHandle.js';
import {Realm} from '../api/Realm.js';
import {Deferred} from '../util/Deferred.js';
import {type Binding} from './Binding.js';
import {type ExecutionContext} from './ExecutionContext.js';
import {CdpFrame} from './Frame.js';
import {type MAIN_WORLD, type PUPPETEER_WORLD} from './IsolatedWorlds.js';
import {type TimeoutSettings} from './TimeoutSettings.js';
import {type TimeoutSettings} from '../common/TimeoutSettings.js';
import {
type BindingPayload,
type EvaluateFunc,
type HandleFor,
} from './types.js';
} from '../common/types.js';
import {
addPageBinding,
createCdpHandle,
debugError,
Mutex,
addPageBinding,
debugError,
withSourcePuppeteerURLIfNone,
} from './util.js';
import {type WebWorker} from './WebWorker.js';
} from '../common/util.js';
import {Deferred} from '../util/Deferred.js';
/**
* @public
*/
export interface WaitForSelectorOptions {
/**
* Wait for the selected element to be present in DOM and to be visible, i.e.
* to not have `display: none` or `visibility: hidden` CSS properties.
*
* @defaultValue `false`
*/
visible?: boolean;
/**
* Wait for the selected element to not be found in the DOM or to be hidden,
* i.e. have `display: none` or `visibility: hidden` CSS properties.
*
* @defaultValue `false`
*/
hidden?: boolean;
/**
* Maximum time to wait in milliseconds. Pass `0` to disable timeout.
*
* The default value can be changed by using {@link Page.setDefaultTimeout}
*
* @defaultValue `30_000` (30 seconds)
*/
timeout?: number;
/**
* A signal object that allows you to cancel a waitForSelector call.
*/
signal?: AbortSignal;
}
import {type Binding} from './Binding.js';
import {type ExecutionContext, createCdpHandle} from './ExecutionContext.js';
import {CdpFrame} from './Frame.js';
import {type MAIN_WORLD, type PUPPETEER_WORLD} from './IsolatedWorlds.js';
import {type WebWorker} from './WebWorker.js';
/**
* @internal

View File

@ -18,10 +18,11 @@ import {type Protocol} from 'devtools-protocol';
import {type CDPSession} from '../api/CDPSession.js';
import {JSHandle} from '../api/JSHandle.js';
import {valueFromRemoteObject} from '../common/util.js';
import type {CdpElementHandle} from './ElementHandle.js';
import {releaseObject} from './ExecutionContext.js';
import {type IsolatedWorld} from './IsolatedWorld.js';
import {releaseObject, valueFromRemoteObject} from './util.js';
/**
* @internal

View File

@ -18,11 +18,11 @@ import type Protocol from 'devtools-protocol';
import {type Frame, FrameEvent} from '../api/Frame.js';
import {type HTTPResponse} from '../api/HTTPResponse.js';
import {type TimeoutError} from '../common/Errors.js';
import {EventSubscription} from '../common/EventEmitter.js';
import {assert} from '../util/assert.js';
import {Deferred} from '../util/Deferred.js';
import {type TimeoutError} from './Errors.js';
import {EventSubscription} from './EventEmitter.js';
import {type CdpFrame} from './Frame.js';
import {FrameManagerEvent} from './FrameManager.js';
import {type CdpHTTPRequest} from './HTTPRequest.js';

View File

@ -21,8 +21,8 @@ import expect from 'expect';
import {type CDPSessionEvents} from '../api/CDPSession.js';
import {type HTTPRequest} from '../api/HTTPRequest.js';
import {type HTTPResponse} from '../api/HTTPResponse.js';
import {EventEmitter} from '../common/EventEmitter.js';
import {EventEmitter} from './EventEmitter.js';
import {type CdpFrame} from './Frame.js';
import {NetworkManager, NetworkManagerEvent} from './NetworkManager.js';

View File

@ -18,20 +18,20 @@ import type {Protocol} from 'devtools-protocol';
import {type CDPSession, CDPSessionEvent} from '../api/CDPSession.js';
import type {Frame} from '../api/Frame.js';
import {assert} from '../util/assert.js';
import {
EventEmitter,
EventSubscription,
type EventType,
} from './EventEmitter.js';
} from '../common/EventEmitter.js';
import {debugError, isString} from '../common/util.js';
import {assert} from '../util/assert.js';
import {CdpHTTPRequest} from './HTTPRequest.js';
import {CdpHTTPResponse} from './HTTPResponse.js';
import {
type FetchRequestId,
NetworkEventManager,
} from './NetworkEventManager.js';
import {debugError, isString} from './util.js';
/**
* @public
@ -52,6 +52,7 @@ export interface NetworkConditions {
// Latency (ms)
latency: number;
}
/**
* @public
*/

View File

@ -38,6 +38,30 @@ import {
type WaitForOptions,
type WaitTimeoutOptions,
} from '../api/Page.js';
import {
ConsoleMessage,
type ConsoleMessageType,
} from '../common/ConsoleMessage.js';
import {TargetCloseError} from '../common/Errors.js';
import {FileChooser} from '../common/FileChooser.js';
import {type PDFOptions} from '../common/PDFOptions.js';
import {type TaskQueue} from '../common/TaskQueue.js';
import {TimeoutSettings} from '../common/TimeoutSettings.js';
import {type BindingPayload, type HandleFor} from '../common/types.js';
import {
createClientError,
debugError,
evaluationString,
getReadableAsBuffer,
getReadableFromProtocolStream,
isString,
pageBindingInitString,
validateDialogType,
valueFromRemoteObject,
waitForEvent,
waitWithTimeout,
} from '../common/util.js';
import {type Viewport} from '../common/Viewport.js';
import {assert} from '../util/assert.js';
import {Deferred} from '../util/Deferred.js';
import {isErrorLike} from '../util/ErrorLike.js';
@ -46,13 +70,11 @@ import {Accessibility} from './Accessibility.js';
import {Binding} from './Binding.js';
import {CdpCDPSession} from './CDPSession.js';
import {isTargetClosedError} from './Connection.js';
import {ConsoleMessage, type ConsoleMessageType} from './ConsoleMessage.js';
import {Coverage} from './Coverage.js';
import {type DeviceRequestPrompt} from './DeviceRequestPrompt.js';
import {CdpDialog} from './Dialog.js';
import {EmulationManager} from './EmulationManager.js';
import {TargetCloseError} from './Errors.js';
import {FileChooser} from './FileChooser.js';
import {createCdpHandle, releaseObject} from './ExecutionContext.js';
import {type CdpFrame} from './Frame.js';
import {FrameManager, FrameManagerEvent} from './FrameManager.js';
import {CdpKeyboard, CdpMouse, CdpTouchscreen} from './Input.js';
@ -62,29 +84,9 @@ import {
type NetworkConditions,
NetworkManagerEvent,
} from './NetworkManager.js';
import {type PDFOptions} from './PDFOptions.js';
import {type Viewport} from './PuppeteerViewport.js';
import {type CdpTarget} from './Target.js';
import {TargetManagerEvent} from './TargetManager.js';
import {type TaskQueue} from './TaskQueue.js';
import {TimeoutSettings} from './TimeoutSettings.js';
import {Tracing} from './Tracing.js';
import {type BindingPayload, type HandleFor} from './types.js';
import {
createCdpHandle,
createClientError,
debugError,
evaluationString,
getReadableAsBuffer,
getReadableFromProtocolStream,
isString,
pageBindingInitString,
releaseObject,
validateDialogType,
valueFromRemoteObject,
waitForEvent,
waitWithTimeout,
} from './util.js';
import {WebWorker} from './WebWorker.js';
/**

View File

@ -15,16 +15,16 @@
*/
import {type Browser} from '../api/Browser.js';
import {type ConnectionTransport} from '../common/ConnectionTransport.js';
import {
type CustomQueryHandler,
customQueryHandlers,
} from '../common/CustomQueryHandler.js';
import {
type BrowserConnectOptions,
_connectToCdpBrowser,
} from './BrowserConnector.js';
import {type ConnectionTransport} from './ConnectionTransport.js';
import {
type CustomQueryHandler,
customQueryHandlers,
} from './CustomQueryHandler.js';
/**
* Settings that are common to the Puppeteer class, regardless of environment.

View File

@ -21,14 +21,14 @@ import type {BrowserContext} from '../api/BrowserContext.js';
import {type CDPSession} from '../api/CDPSession.js';
import {type Page, PageEvent} from '../api/Page.js';
import {Target, TargetType} from '../api/Target.js';
import {type TaskQueue} from '../common/TaskQueue.js';
import {debugError} from '../common/util.js';
import {type Viewport} from '../common/Viewport.js';
import {Deferred} from '../util/Deferred.js';
import {CdpCDPSession} from './CDPSession.js';
import {CdpPage} from './Page.js';
import {type Viewport} from './PuppeteerViewport.js';
import {type TargetManager} from './TargetManager.js';
import {type TaskQueue} from './TaskQueue.js';
import {debugError} from './util.js';
import {WebWorker} from './WebWorker.js';
/**

View File

@ -17,8 +17,8 @@
import {type Protocol} from 'devtools-protocol';
import {type CDPSession} from '../api/CDPSession.js';
import {type EventEmitter, type EventType} from '../common/EventEmitter.js';
import {type EventEmitter, type EventType} from './EventEmitter.js';
import {type CdpTarget} from './Target.js';
/**

View File

@ -14,12 +14,14 @@
* limitations under the License.
*/
import {type CDPSession} from '../api/CDPSession.js';
import {
getReadableAsBuffer,
getReadableFromProtocolStream,
} from '../common/util.js';
import {assert} from '../util/assert.js';
import {Deferred} from '../util/Deferred.js';
import {isErrorLike} from '../util/ErrorLike.js';
import {getReadableAsBuffer, getReadableFromProtocolStream} from './util.js';
/**
* @public
*/

View File

@ -17,15 +17,15 @@ import {type Protocol} from 'devtools-protocol';
import {type CDPSession} from '../api/CDPSession.js';
import {type Realm} from '../api/Realm.js';
import {type ConsoleMessageType} from '../common/ConsoleMessage.js';
import {EventEmitter, type EventType} from '../common/EventEmitter.js';
import {TimeoutSettings} from '../common/TimeoutSettings.js';
import {type EvaluateFunc, type HandleFor} from '../common/types.js';
import {debugError, withSourcePuppeteerURLIfNone} from '../common/util.js';
import {type ConsoleMessageType} from './ConsoleMessage.js';
import {EventEmitter, type EventType} from './EventEmitter.js';
import {ExecutionContext} from './ExecutionContext.js';
import {IsolatedWorld} from './IsolatedWorld.js';
import {CdpJSHandle} from './JSHandle.js';
import {TimeoutSettings} from './TimeoutSettings.js';
import {type EvaluateFunc, type HandleFor} from './types.js';
import {debugError, withSourcePuppeteerURLIfNone} from './util.js';
/**
* @internal

View File

@ -0,0 +1,51 @@
/**
* Copyright 2023 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './Accessibility.js';
export * from './AriaQueryHandler.js';
export * from './Binding.js';
export * from './Browser.js';
export * from './BrowserConnector.js';
export * from './CDPSession.js';
export * from './ChromeTargetManager.js';
export * from './Connection.js';
export * from './Coverage.js';
export * from './DeviceRequestPrompt.js';
export * from './Dialog.js';
export * from './ElementHandle.js';
export * from './EmulationManager.js';
export * from './ExecutionContext.js';
export * from './FirefoxTargetManager.js';
export * from './Frame.js';
export * from './FrameManager.js';
export * from './FrameTree.js';
export * from './HTTPRequest.js';
export * from './HTTPResponse.js';
export * from './Input.js';
export * from './IsolatedWorld.js';
export * from './IsolatedWorlds.js';
export * from './JSHandle.js';
export * from './LifecycleWatcher.js';
export * from './NetworkEventManager.js';
export * from './NetworkManager.js';
export * from './Page.js';
export * from './PredefinedNetworkConditions.js';
export * from './Puppeteer.js';
export * from './Target.js';
export * from './TargetManager.js';
export * from './Tracing.js';
export * from './WebWorker.js';
export * from './cdp.js';

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
import {type Viewport} from './PuppeteerViewport.js';
import {type Viewport} from './Viewport.js';
/**
* @public

View File

@ -14,7 +14,8 @@
* limitations under the License.
*/
import {ARIAQueryHandler} from './AriaQueryHandler.js';
import {ARIAQueryHandler} from '../cdp/AriaQueryHandler.js';
import {customQueryHandlers} from './CustomQueryHandler.js';
import {PierceQueryHandler} from './PierceQueryHandler.js';
import {PQueryHandler} from './PQueryHandler.js';
@ -22,6 +23,9 @@ import type {QueryHandler} from './QueryHandler.js';
import {TextQueryHandler} from './TextQueryHandler.js';
import {XPathQueryHandler} from './XPathQueryHandler.js';
/**
* @internal
*/
export const BUILTIN_QUERY_HANDLERS = Object.freeze({
aria: ARIAQueryHandler,
pierce: PierceQueryHandler,

View File

@ -16,12 +16,12 @@
import {ElementHandle} from '../api/ElementHandle.js';
import type {Frame} from '../api/Frame.js';
import type {WaitForSelectorOptions} from '../api/Page.js';
import type PuppeteerUtil from '../injected/injected.js';
import {isErrorLike} from '../util/ErrorLike.js';
import {interpolateFunction, stringifyFunction} from '../util/Function.js';
import {transposeIterableHandle} from './HandleIterator.js';
import type {WaitForSelectorOptions} from './IsolatedWorld.js';
import {LazyArg} from './LazyArg.js';
import type {Awaitable, AwaitableIterable} from './types.js';

View File

@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* Sets the viewport of the page.
* @public
*/
export interface Viewport {

View File

@ -14,61 +14,34 @@
* limitations under the License.
*/
export * from './Accessibility.js';
export * from './AriaQueryHandler.js';
export * from './Binding.js';
export * from './Browser.js';
export * from './BrowserConnector.js';
export * from './BrowserWebSocketTransport.js';
export * from './CDPSession.js';
export * from './ChromeTargetManager.js';
export * from './Configuration.js';
export * from './Connection.js';
export * from './ConnectionTransport.js';
export * from './ConsoleMessage.js';
export * from './Coverage.js';
export * from './CustomQueryHandler.js';
export * from './Debug.js';
export * from './Device.js';
export * from './DeviceRequestPrompt.js';
export * from './Dialog.js';
export * from './ElementHandle.js';
export * from './EmulationManager.js';
export * from './Errors.js';
export * from './EventEmitter.js';
export * from './ExecutionContext.js';
export * from './FileChooser.js';
export * from './FirefoxTargetManager.js';
export * from './Frame.js';
export * from './FrameManager.js';
export * from './FrameTree.js';
export * from './HTTPRequest.js';
export * from './HTTPResponse.js';
export * from './Input.js';
export * from './IsolatedWorld.js';
export * from './IsolatedWorlds.js';
export * from './JSHandle.js';
export * from './GetQueryHandler.js';
export * from './HandleIterator.js';
export * from './LazyArg.js';
export * from './LifecycleWatcher.js';
export * from './NetworkEventManager.js';
export * from './NetworkManager.js';
export * from './NodeWebSocketTransport.js';
export * from './PDFOptions.js';
export * from './Page.js';
export * from './PredefinedNetworkConditions.js';
export * from './PQueryHandler.js';
export * from './PierceQueryHandler.js';
export * from './Product.js';
export * from './Puppeteer.js';
export * from './PuppeteerViewport.js';
export * from './QueryHandler.js';
export * from './ScriptInjector.js';
export * from './SecurityDetails.js';
export * from './Target.js';
export * from './TargetManager.js';
export * from './TaskQueue.js';
export * from './TextQueryHandler.js';
export * from './TimeoutSettings.js';
export * from './Tracing.js';
export * from './USKeyboardLayout.js';
export * from './Viewport.js';
export * from './WaitTask.js';
export * from './WebWorker.js';
export * from './XPathQueryHandler.js';
export * from './common.js';
export * from './fetch.js';
export * from './types.js';
export * from './util.js';

View File

@ -25,8 +25,6 @@ import {
type Observable,
} from '../../third_party/rxjs/rxjs.js';
import type {CDPSession} from '../api/CDPSession.js';
import type {ElementHandle} from '../api/ElementHandle.js';
import type {JSHandle} from '../api/JSHandle.js';
import {type Page} from '../api/Page.js';
import {isNode} from '../environment.js';
import {assert} from '../util/assert.js';
@ -34,11 +32,8 @@ import {Deferred} from '../util/Deferred.js';
import {isErrorLike} from '../util/ErrorLike.js';
import {debug} from './Debug.js';
import {CdpElementHandle} from './ElementHandle.js';
import {TimeoutError} from './Errors.js';
import {EventSubscription} from './EventEmitter.js';
import {type IsolatedWorld} from './IsolatedWorld.js';
import {CdpJSHandle} from './JSHandle.js';
import {type Awaitable} from './types.js';
/**
@ -293,25 +288,6 @@ export function valueFromRemoteObject(
return remoteObject.value;
}
/**
* @internal
*/
export async function releaseObject(
client: CDPSession,
remoteObject: Protocol.Runtime.RemoteObject
): Promise<void> {
if (!remoteObject.objectId) {
return;
}
await client
.send('Runtime.releaseObject', {objectId: remoteObject.objectId})
.catch(error => {
// Exceptions might happen in case of a page been navigated or closed.
// Swallow these since they are harmless and we don't leak anything in this case.
debugError(error);
});
}
/**
* @internal
*/
@ -380,19 +356,6 @@ export async function waitForEvent<T>(
}
}
/**
* @internal
*/
export function createCdpHandle(
realm: IsolatedWorld,
remoteObject: Protocol.Runtime.RemoteObject
): JSHandle | ElementHandle<Node> {
if (remoteObject.subtype === 'node') {
return new CdpElementHandle(realm, remoteObject);
}
return new CdpJSHandle(realm, remoteObject);
}
/**
* @internal
*/

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
import {type BrowserConnectOptions} from '../common/BrowserConnector.js';
import {type BrowserConnectOptions} from '../cdp/BrowserConnector.js';
import {type Product} from '../common/Product.js';
/**

View File

@ -27,19 +27,19 @@ import {
} from '@puppeteer/browsers';
import {type Browser, type BrowserCloseCallback} from '../api/Browser.js';
import {CdpBrowser} from '../common/Browser.js';
import {Connection} from '../common/Connection.js';
import {CdpBrowser} from '../cdp/Browser.js';
import {Connection} from '../cdp/Connection.js';
import {TimeoutError} from '../common/Errors.js';
import {NodeWebSocketTransport as WebSocketTransport} from '../common/NodeWebSocketTransport.js';
import {type Product} from '../common/Product.js';
import {type Viewport} from '../common/PuppeteerViewport.js';
import {debugError} from '../common/util.js';
import {type Viewport} from '../common/Viewport.js';
import {
type BrowserLaunchArgumentOptions,
type ChromeReleaseChannel,
type PuppeteerNodeLaunchOptions,
} from './LaunchOptions.js';
import {NodeWebSocketTransport as WebSocketTransport} from './NodeWebSocketTransport.js';
import {PipeTransport} from './PipeTransport.js';
import {type PuppeteerNode} from './PuppeteerNode.js';
@ -335,9 +335,7 @@ export class ProductLauncher {
}
): Promise<Browser> {
// TODO: use other options too.
const BiDi = await import(
/* webpackIgnore: true */ '../common/bidi/bidi.js'
);
const BiDi = await import(/* webpackIgnore: true */ '../bidi/bidi.js');
const bidiConnection = await BiDi.connectBidiOverCdp(connection);
return await BiDi.BidiBrowser.create({
connection: bidiConnection,
@ -368,9 +366,7 @@ export class ProductLauncher {
opts.timeout
)) + '/session';
const transport = await WebSocketTransport.create(browserWSEndpoint);
const BiDi = await import(
/* webpackIgnore: true */ '../common/bidi/bidi.js'
);
const BiDi = await import(/* webpackIgnore: true */ '../bidi/bidi.js');
const bidiConnection = new BiDi.BidiConnection(
browserWSEndpoint,
transport,

View File

@ -23,14 +23,14 @@ import {
} from '@puppeteer/browsers';
import {type Browser} from '../api/Browser.js';
import {type BrowserConnectOptions} from '../common/BrowserConnector.js';
import {type Configuration} from '../common/Configuration.js';
import {type Product} from '../common/Product.js';
import {type BrowserConnectOptions} from '../cdp/BrowserConnector.js';
import {
type CommonPuppeteerSettings,
type ConnectOptions,
Puppeteer,
} from '../common/Puppeteer.js';
} from '../cdp/Puppeteer.js';
import {type Configuration} from '../common/Configuration.js';
import {type Product} from '../common/Product.js';
import {PUPPETEER_REVISIONS} from '../revisions.js';
import {ChromeLauncher} from './ChromeLauncher.js';

View File

@ -17,6 +17,7 @@
export {Protocol} from 'devtools-protocol';
export * from './api/api.js';
export * from './cdp/cdp.js';
export * from './common/common.js';
export * from './node/node.js';
export * from './revisions.js';

View File

@ -15,7 +15,7 @@
*/
import expect from 'expect';
import {type CdpBrowser} from 'puppeteer-core/internal/common/Browser.js';
import {type CdpBrowser} from 'puppeteer-core/internal/cdp/Browser.js';
import {getTestState, launch} from './mocha-utils.js';
import {attachFrame} from './utils.js';

View File

@ -17,7 +17,7 @@
import assert from 'assert';
import expect from 'expect';
import {type SerializedAXNode} from 'puppeteer-core/internal/common/Accessibility.js';
import {type SerializedAXNode} from 'puppeteer-core/internal/cdp/Accessibility.js';
import {getTestState, setupTestBrowserHooks} from './mocha-utils.js';

View File

@ -16,7 +16,7 @@
import expect from 'expect';
import {type BrowserContext} from 'puppeteer-core/internal/api/BrowserContext.js';
import {type CdpTarget} from 'puppeteer-core/internal/common/Target.js';
import {type CdpTarget} from 'puppeteer-core/internal/cdp/Target.js';
import {describeWithDebugLogs, getTestState, launch} from './mocha-utils.js';
import {attachFrame, detachFrame, navigateFrame} from './utils.js';

View File

@ -22,8 +22,8 @@ import expect from 'expect';
import {KnownDevices, TimeoutError} from 'puppeteer';
import {CDPSession} from 'puppeteer-core/internal/api/CDPSession.js';
import {type Metrics, type Page} from 'puppeteer-core/internal/api/Page.js';
import {type CdpPage} from 'puppeteer-core/internal/cdp/Page.js';
import {type ConsoleMessage} from 'puppeteer-core/internal/common/ConsoleMessage.js';
import {type CdpPage} from 'puppeteer-core/internal/common/Page.js';
import sinon from 'sinon';
import {getTestState, setupTestBrowserHooks} from './mocha-utils.js';

View File

@ -15,8 +15,8 @@
*/
import expect from 'expect';
import {type WebWorker} from 'puppeteer-core/internal/cdp/WebWorker.js';
import {type ConsoleMessage} from 'puppeteer-core/internal/common/ConsoleMessage.js';
import {type WebWorker} from 'puppeteer-core/internal/common/WebWorker.js';
import {getTestState, setupTestBrowserHooks} from './mocha-utils.js';
import {waitEvent} from './utils.js';