mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: tweaks after protocol separation (#10917)
This commit is contained in:
parent
09207a71b8
commit
1283ca5bcf
@ -44,7 +44,7 @@ import {debugError} from './util.js';
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
interface Options {
|
export interface BidiBrowserOptions {
|
||||||
process?: ChildProcess;
|
process?: ChildProcess;
|
||||||
closeCallback?: BrowserCloseCallback;
|
closeCallback?: BrowserCloseCallback;
|
||||||
connection: BidiConnection;
|
connection: BidiConnection;
|
||||||
@ -75,7 +75,7 @@ export class BidiBrowser extends Browser {
|
|||||||
'cdp.Debugger.scriptParsed',
|
'cdp.Debugger.scriptParsed',
|
||||||
];
|
];
|
||||||
|
|
||||||
static async create(opts: Options): Promise<BidiBrowser> {
|
static async create(opts: BidiBrowserOptions): Promise<BidiBrowser> {
|
||||||
let browserName = '';
|
let browserName = '';
|
||||||
let browserVersion = '';
|
let browserVersion = '';
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ export class BidiBrowser extends Browser {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
opts: Options & {
|
opts: BidiBrowserOptions & {
|
||||||
browserName: string;
|
browserName: string;
|
||||||
browserVersion: string;
|
browserVersion: string;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,10 @@ import {type BidiBrowser} from './Browser.js';
|
|||||||
import {type BidiConnection} from './Connection.js';
|
import {type BidiConnection} from './Connection.js';
|
||||||
import {type BidiPage} from './Page.js';
|
import {type BidiPage} from './Page.js';
|
||||||
|
|
||||||
interface BrowserContextOptions {
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export interface BidiBrowserContextOptions {
|
||||||
defaultViewport: Viewport | null;
|
defaultViewport: Viewport | null;
|
||||||
isDefault: boolean;
|
isDefault: boolean;
|
||||||
}
|
}
|
||||||
@ -39,7 +42,7 @@ export class BidiBrowserContext extends BrowserContext {
|
|||||||
#defaultViewport: Viewport | null;
|
#defaultViewport: Viewport | null;
|
||||||
#isDefault = false;
|
#isDefault = false;
|
||||||
|
|
||||||
constructor(browser: BidiBrowser, options: BrowserContextOptions) {
|
constructor(browser: BidiBrowser, options: BidiBrowserContextOptions) {
|
||||||
super();
|
super();
|
||||||
this.#browser = browser;
|
this.#browser = browser;
|
||||||
this.#connection = this.#browser.connection;
|
this.#connection = this.#browser.connection;
|
||||||
|
@ -16,7 +16,7 @@ import {assert} from '../util/assert.js';
|
|||||||
import {Deferred} from '../util/Deferred.js';
|
import {Deferred} from '../util/Deferred.js';
|
||||||
|
|
||||||
import {type BidiConnection} from './Connection.js';
|
import {type BidiConnection} from './Connection.js';
|
||||||
import {Realm} from './Realm.js';
|
import {BidiRealm} from './Realm.js';
|
||||||
import {debugError} from './util.js';
|
import {debugError} from './util.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,7 +150,7 @@ export interface BrowsingContextEvents extends Record<EventType, unknown> {
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export class BrowsingContext extends Realm {
|
export class BrowsingContext extends BidiRealm {
|
||||||
#id: string;
|
#id: string;
|
||||||
#url: string;
|
#url: string;
|
||||||
#cdpSession: CDPSession;
|
#cdpSession: CDPSession;
|
||||||
@ -182,8 +182,8 @@ export class BrowsingContext extends Realm {
|
|||||||
this.#url = info.url;
|
this.#url = info.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
createRealmForSandbox(): Realm {
|
createRealmForSandbox(): BidiRealm {
|
||||||
return new Realm(this.connection);
|
return new BidiRealm(this.connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
get url(): string {
|
get url(): string {
|
||||||
|
@ -30,7 +30,7 @@ const debugProtocolReceive = debug('puppeteer:webDriverBiDi:RECV ◀');
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
interface Commands {
|
export interface Commands {
|
||||||
'script.evaluate': {
|
'script.evaluate': {
|
||||||
params: Bidi.Script.EvaluateParameters;
|
params: Bidi.Script.EvaluateParameters;
|
||||||
returnType: Bidi.Script.EvaluateResult;
|
returnType: Bidi.Script.EvaluateResult;
|
||||||
@ -93,6 +93,10 @@ interface Commands {
|
|||||||
params: Bidi.BrowsingContext.HandleUserPromptParameters;
|
params: Bidi.BrowsingContext.HandleUserPromptParameters;
|
||||||
returnType: Bidi.EmptyResult;
|
returnType: Bidi.EmptyResult;
|
||||||
};
|
};
|
||||||
|
'browsingContext.setViewport': {
|
||||||
|
params: Bidi.BrowsingContext.SetViewportParameters;
|
||||||
|
returnType: Bidi.EmptyResult;
|
||||||
|
};
|
||||||
|
|
||||||
'input.performActions': {
|
'input.performActions': {
|
||||||
params: Bidi.Input.PerformActionsParameters;
|
params: Bidi.Input.PerformActionsParameters;
|
||||||
|
@ -21,7 +21,7 @@ import {throwIfDisposed} from '../util/decorators.js';
|
|||||||
|
|
||||||
import {type BidiFrame} from './Frame.js';
|
import {type BidiFrame} from './Frame.js';
|
||||||
import {BidiJSHandle} from './JSHandle.js';
|
import {BidiJSHandle} from './JSHandle.js';
|
||||||
import {type Realm} from './Realm.js';
|
import {type BidiRealm} from './Realm.js';
|
||||||
import {type Sandbox} from './Sandbox.js';
|
import {type Sandbox} from './Sandbox.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +44,7 @@ export class BidiElementHandle<
|
|||||||
return this.realm.environment;
|
return this.realm.environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
context(): Realm {
|
context(): BidiRealm {
|
||||||
return this.handle.context();
|
return this.handle.context();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,14 +13,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
|
||||||
|
|
||||||
import {type BrowsingContext} from './BrowsingContext.js';
|
import {type BrowsingContext} from './BrowsingContext.js';
|
||||||
|
|
||||||
interface Viewport {
|
|
||||||
width: number;
|
|
||||||
height: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
@ -31,13 +27,12 @@ export class EmulationManager {
|
|||||||
this.#browsingContext = browsingContext;
|
this.#browsingContext = browsingContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
async emulateViewport(viewport: Viewport): Promise<void> {
|
async emulateViewport(
|
||||||
await this.#browsingContext.connection.send(
|
viewport: Bidi.BrowsingContext.Viewport
|
||||||
'browsingContext.setViewport' as any,
|
): Promise<void> {
|
||||||
{
|
await this.#browsingContext.connection.send('browsingContext.setViewport', {
|
||||||
context: this.#browsingContext.id,
|
context: this.#browsingContext.id,
|
||||||
viewport,
|
viewport,
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,10 @@ import * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
|
|||||||
|
|
||||||
import {type CDPSession} from '../api/CDPSession.js';
|
import {type CDPSession} from '../api/CDPSession.js';
|
||||||
import {Frame, throwIfDetached} from '../api/Frame.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 PuppeteerLifeCycleEvent} from '../cdp/LifecycleWatcher.js';
|
||||||
import {type TimeoutSettings} from '../common/TimeoutSettings.js';
|
import {type TimeoutSettings} from '../common/TimeoutSettings.js';
|
||||||
import {type Awaitable} from '../common/types.js';
|
import {type Awaitable} from '../common/types.js';
|
||||||
import {waitForEvent} from '../common/util.js';
|
import {UTILITY_WORLD_NAME, waitForEvent} from '../common/util.js';
|
||||||
import {Deferred} from '../util/Deferred.js';
|
import {Deferred} from '../util/Deferred.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -18,9 +18,9 @@ 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 {
|
import {
|
||||||
Keyboard as BaseKeyboard,
|
Keyboard,
|
||||||
Mouse as BaseMouse,
|
Mouse,
|
||||||
Touchscreen as BaseTouchscreen,
|
Touchscreen,
|
||||||
type KeyDownOptions,
|
type KeyDownOptions,
|
||||||
type KeyPressOptions,
|
type KeyPressOptions,
|
||||||
type KeyboardTypeOptions,
|
type KeyboardTypeOptions,
|
||||||
@ -284,7 +284,7 @@ const getBidiKeyValue = (key: KeyInput) => {
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export class Keyboard extends BaseKeyboard {
|
export class BidiKeyboard extends Keyboard {
|
||||||
#context: BrowsingContext;
|
#context: BrowsingContext;
|
||||||
|
|
||||||
constructor(context: BrowsingContext) {
|
constructor(context: BrowsingContext) {
|
||||||
@ -420,21 +420,21 @@ export class Keyboard extends BaseKeyboard {
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
interface BidiMouseClickOptions extends MouseClickOptions {
|
export interface BidiMouseClickOptions extends MouseClickOptions {
|
||||||
origin?: Bidi.Input.Origin;
|
origin?: Bidi.Input.Origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
interface BidiMouseMoveOptions extends MouseMoveOptions {
|
export interface BidiMouseMoveOptions extends MouseMoveOptions {
|
||||||
origin?: Bidi.Input.Origin;
|
origin?: Bidi.Input.Origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
interface BidiTouchMoveOptions {
|
export interface BidiTouchMoveOptions {
|
||||||
origin?: Bidi.Input.Origin;
|
origin?: Bidi.Input.Origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,7 +456,7 @@ const getBidiButton = (button: MouseButton) => {
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export class Mouse extends BaseMouse {
|
export class BidiMouse extends Mouse {
|
||||||
#context: BrowsingContext;
|
#context: BrowsingContext;
|
||||||
#lastMovePoint?: Point;
|
#lastMovePoint?: Point;
|
||||||
|
|
||||||
@ -610,7 +610,7 @@ export class Mouse extends BaseMouse {
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export class Touchscreen extends BaseTouchscreen {
|
export class BidiTouchscreen extends Touchscreen {
|
||||||
#context: BrowsingContext;
|
#context: BrowsingContext;
|
||||||
|
|
||||||
constructor(context: BrowsingContext) {
|
constructor(context: BrowsingContext) {
|
||||||
|
@ -15,12 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
|
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 {type ElementHandle} from '../api/ElementHandle.js';
|
||||||
import {JSHandle} from '../api/JSHandle.js';
|
import {JSHandle} from '../api/JSHandle.js';
|
||||||
|
|
||||||
import {type Realm} from './Realm.js';
|
import {type BidiRealm} from './Realm.js';
|
||||||
import {type Sandbox} from './Sandbox.js';
|
import {type Sandbox} from './Sandbox.js';
|
||||||
import {BidiSerializer} from './Serializer.js';
|
import {BidiSerializer} from './Serializer.js';
|
||||||
import {releaseReference} from './util.js';
|
import {releaseReference} from './util.js';
|
||||||
@ -39,7 +38,7 @@ export class BidiJSHandle<T = unknown> extends JSHandle<T> {
|
|||||||
this.#remoteValue = remoteValue;
|
this.#remoteValue = remoteValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
context(): Realm {
|
context(): BidiRealm {
|
||||||
return this.realm.environment.context();
|
return this.realm.environment.context();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +104,7 @@ export class BidiJSHandle<T = unknown> extends JSHandle<T> {
|
|||||||
return this.#remoteValue;
|
return this.#remoteValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
override remoteObject(): Protocol.Runtime.RemoteObject {
|
override remoteObject(): never {
|
||||||
throw new Error('Not available in WebDriver BiDi');
|
throw new Error('Not available in WebDriver BiDi');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ import {type BidiPage} from './Page.js';
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export interface NetworkManagerEvents extends Record<EventType, unknown> {
|
export interface BidiNetworkManagerEvents extends Record<EventType, unknown> {
|
||||||
[NetworkManagerEvent.Request]: BidiHTTPRequest;
|
[NetworkManagerEvent.Request]: BidiHTTPRequest;
|
||||||
[NetworkManagerEvent.RequestServedFromCache]: BidiHTTPRequest;
|
[NetworkManagerEvent.RequestServedFromCache]: BidiHTTPRequest;
|
||||||
[NetworkManagerEvent.Response]: BidiHTTPResponse;
|
[NetworkManagerEvent.Response]: BidiHTTPResponse;
|
||||||
@ -43,7 +43,7 @@ export interface NetworkManagerEvents extends Record<EventType, unknown> {
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export class BidiNetworkManager extends EventEmitter<NetworkManagerEvents> {
|
export class BidiNetworkManager extends EventEmitter<BidiNetworkManagerEvents> {
|
||||||
#connection: BidiConnection;
|
#connection: BidiConnection;
|
||||||
#page: BidiPage;
|
#page: BidiPage;
|
||||||
#subscriptions = new DisposableStack();
|
#subscriptions = new DisposableStack();
|
||||||
|
@ -69,7 +69,7 @@ import {EmulationManager} from './EmulationManager.js';
|
|||||||
import {BidiFrame} from './Frame.js';
|
import {BidiFrame} from './Frame.js';
|
||||||
import {type BidiHTTPRequest} from './HTTPRequest.js';
|
import {type BidiHTTPRequest} from './HTTPRequest.js';
|
||||||
import {type BidiHTTPResponse} from './HTTPResponse.js';
|
import {type BidiHTTPResponse} from './HTTPResponse.js';
|
||||||
import {Keyboard, Mouse, Touchscreen} from './Input.js';
|
import {BidiKeyboard, BidiMouse, BidiTouchscreen} from './Input.js';
|
||||||
import {BidiNetworkManager} from './NetworkManager.js';
|
import {BidiNetworkManager} from './NetworkManager.js';
|
||||||
import {createBidiHandle} from './Realm.js';
|
import {createBidiHandle} from './Realm.js';
|
||||||
import {BidiSerializer} from './Serializer.js';
|
import {BidiSerializer} from './Serializer.js';
|
||||||
@ -139,9 +139,9 @@ export class BidiPage extends Page {
|
|||||||
#coverage: Coverage;
|
#coverage: Coverage;
|
||||||
#cdpEmulationManager: CdpEmulationManager;
|
#cdpEmulationManager: CdpEmulationManager;
|
||||||
#emulationManager: EmulationManager;
|
#emulationManager: EmulationManager;
|
||||||
#mouse: Mouse;
|
#mouse: BidiMouse;
|
||||||
#touchscreen: Touchscreen;
|
#touchscreen: BidiTouchscreen;
|
||||||
#keyboard: Keyboard;
|
#keyboard: BidiKeyboard;
|
||||||
#browsingContext: BrowsingContext;
|
#browsingContext: BrowsingContext;
|
||||||
#browserContext: BidiBrowserContext;
|
#browserContext: BidiBrowserContext;
|
||||||
|
|
||||||
@ -192,9 +192,9 @@ export class BidiPage extends Page {
|
|||||||
this.mainFrame().context().cdpSession
|
this.mainFrame().context().cdpSession
|
||||||
);
|
);
|
||||||
this.#emulationManager = new EmulationManager(browsingContext);
|
this.#emulationManager = new EmulationManager(browsingContext);
|
||||||
this.#mouse = new Mouse(this.mainFrame().context());
|
this.#mouse = new BidiMouse(this.mainFrame().context());
|
||||||
this.#touchscreen = new Touchscreen(this.mainFrame().context());
|
this.#touchscreen = new BidiTouchscreen(this.mainFrame().context());
|
||||||
this.#keyboard = new Keyboard(this.mainFrame().context());
|
this.#keyboard = new BidiKeyboard(this.mainFrame().context());
|
||||||
}
|
}
|
||||||
|
|
||||||
_setBrowserContext(browserContext: BidiBrowserContext): void {
|
_setBrowserContext(browserContext: BidiBrowserContext): void {
|
||||||
@ -213,15 +213,15 @@ export class BidiPage extends Page {
|
|||||||
return this.#coverage;
|
return this.#coverage;
|
||||||
}
|
}
|
||||||
|
|
||||||
override get mouse(): Mouse {
|
override get mouse(): BidiMouse {
|
||||||
return this.#mouse;
|
return this.#mouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
override get touchscreen(): Touchscreen {
|
override get touchscreen(): BidiTouchscreen {
|
||||||
return this.#touchscreen;
|
return this.#touchscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
override get keyboard(): Keyboard {
|
override get keyboard(): BidiKeyboard {
|
||||||
return this.#keyboard;
|
return this.#keyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,9 @@ import {scriptInjector} from '../common/ScriptInjector.js';
|
|||||||
import {type EvaluateFunc, type HandleFor} from '../common/types.js';
|
import {type EvaluateFunc, type HandleFor} from '../common/types.js';
|
||||||
import {
|
import {
|
||||||
PuppeteerURL,
|
PuppeteerURL,
|
||||||
|
SOURCE_URL_REGEX,
|
||||||
getSourcePuppeteerURLIfAvailable,
|
getSourcePuppeteerURLIfAvailable,
|
||||||
|
getSourceUrlComment,
|
||||||
isString,
|
isString,
|
||||||
} from '../common/util.js';
|
} from '../common/util.js';
|
||||||
import type PuppeteerUtil from '../injected/injected.js';
|
import type PuppeteerUtil from '../injected/injected.js';
|
||||||
@ -18,16 +20,10 @@ import {type Sandbox} from './Sandbox.js';
|
|||||||
import {BidiSerializer} from './Serializer.js';
|
import {BidiSerializer} from './Serializer.js';
|
||||||
import {createEvaluationError} from './util.js';
|
import {createEvaluationError} from './util.js';
|
||||||
|
|
||||||
export const SOURCE_URL_REGEX = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m;
|
|
||||||
|
|
||||||
export const getSourceUrlComment = (url: string): string => {
|
|
||||||
return `//# sourceURL=${url}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export class Realm extends EventEmitter<Record<EventType, any>> {
|
export class BidiRealm extends EventEmitter<Record<EventType, any>> {
|
||||||
readonly connection: BidiConnection;
|
readonly connection: BidiConnection;
|
||||||
|
|
||||||
#id!: string;
|
#id!: string;
|
||||||
|
@ -22,7 +22,7 @@ import {withSourcePuppeteerURLIfNone} from '../common/util.js';
|
|||||||
|
|
||||||
import {type BrowsingContext} from './BrowsingContext.js';
|
import {type BrowsingContext} from './BrowsingContext.js';
|
||||||
import {type BidiFrame} from './Frame.js';
|
import {type BidiFrame} from './Frame.js';
|
||||||
import {type Realm as BidiRealm} from './Realm.js';
|
import {type BidiRealm as BidiRealm} from './Realm.js';
|
||||||
/**
|
/**
|
||||||
* A unique key for {@link SandboxChart} to denote the default world.
|
* A unique key for {@link SandboxChart} to denote the default world.
|
||||||
* Realms are automatically created in the default sandbox.
|
* Realms are automatically created in the default sandbox.
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
import {type CDPSession} from '../api/CDPSession.js';
|
import {type CDPSession} from '../api/CDPSession.js';
|
||||||
import {Target, TargetType} from '../api/Target.js';
|
import {Target, TargetType} from '../api/Target.js';
|
||||||
import type {WebWorker} from '../cdp/WebWorker.js';
|
|
||||||
|
|
||||||
import {type BidiBrowser} from './Browser.js';
|
import {type BidiBrowser} from './Browser.js';
|
||||||
import {type BidiBrowserContext} from './BrowserContext.js';
|
import {type BidiBrowserContext} from './BrowserContext.js';
|
||||||
@ -34,7 +33,7 @@ export class BidiTarget extends Target {
|
|||||||
this._browserContext = browserContext;
|
this._browserContext = browserContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
override async worker(): Promise<WebWorker | null> {
|
override async worker(): Promise<null> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,16 @@
|
|||||||
export * from './BidiOverCdp.js';
|
export * from './BidiOverCdp.js';
|
||||||
export * from './Browser.js';
|
export * from './Browser.js';
|
||||||
export * from './BrowserContext.js';
|
export * from './BrowserContext.js';
|
||||||
|
export * from './BrowsingContext.js';
|
||||||
export * from './Connection.js';
|
export * from './Connection.js';
|
||||||
|
export * from './ElementHandle.js';
|
||||||
|
export * from './Frame.js';
|
||||||
|
export * from './HTTPRequest.js';
|
||||||
|
export * from './HTTPResponse.js';
|
||||||
|
export * from './Input.js';
|
||||||
|
export * from './JSHandle.js';
|
||||||
export * from './NetworkManager.js';
|
export * from './NetworkManager.js';
|
||||||
export * from './Page.js';
|
export * from './Page.js';
|
||||||
|
export * from './Realm.js';
|
||||||
|
export * from './Sandbox.js';
|
||||||
|
export * from './Target.js';
|
||||||
|
@ -19,7 +19,7 @@ import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
|
|||||||
import {debug} from '../common/Debug.js';
|
import {debug} from '../common/Debug.js';
|
||||||
import {PuppeteerURL} from '../common/util.js';
|
import {PuppeteerURL} from '../common/util.js';
|
||||||
|
|
||||||
import {type Realm} from './Realm.js';
|
import {type BidiRealm} from './Realm.js';
|
||||||
import {BidiSerializer} from './Serializer.js';
|
import {BidiSerializer} from './Serializer.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,7 +31,7 @@ export const debugError = debug('puppeteer:error');
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export async function releaseReference(
|
export async function releaseReference(
|
||||||
client: Realm,
|
client: BidiRealm,
|
||||||
remoteReference: Bidi.Script.RemoteReference
|
remoteReference: Bidi.Script.RemoteReference
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (!remoteReference.handle) {
|
if (!remoteReference.handle) {
|
||||||
|
@ -24,9 +24,11 @@ import {scriptInjector} from '../common/ScriptInjector.js';
|
|||||||
import {type EvaluateFunc, type HandleFor} from '../common/types.js';
|
import {type EvaluateFunc, type HandleFor} from '../common/types.js';
|
||||||
import {
|
import {
|
||||||
PuppeteerURL,
|
PuppeteerURL,
|
||||||
|
SOURCE_URL_REGEX,
|
||||||
createEvaluationError,
|
createEvaluationError,
|
||||||
debugError,
|
debugError,
|
||||||
getSourcePuppeteerURLIfAvailable,
|
getSourcePuppeteerURLIfAvailable,
|
||||||
|
getSourceUrlComment,
|
||||||
isString,
|
isString,
|
||||||
valueFromRemoteObject,
|
valueFromRemoteObject,
|
||||||
} from '../common/util.js';
|
} from '../common/util.js';
|
||||||
@ -40,12 +42,6 @@ import {CdpElementHandle} from './ElementHandle.js';
|
|||||||
import {type IsolatedWorld} from './IsolatedWorld.js';
|
import {type IsolatedWorld} from './IsolatedWorld.js';
|
||||||
import {CdpJSHandle} from './JSHandle.js';
|
import {CdpJSHandle} from './JSHandle.js';
|
||||||
|
|
||||||
const SOURCE_URL_REGEX = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m;
|
|
||||||
|
|
||||||
const getSourceUrlComment = (url: string) => {
|
|
||||||
return `//# sourceURL=${url}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
|
@ -21,7 +21,7 @@ import {FrameEvent} from '../api/Frame.js';
|
|||||||
import {type Page} from '../api/Page.js';
|
import {type Page} from '../api/Page.js';
|
||||||
import {EventEmitter, type EventType} from '../common/EventEmitter.js';
|
import {EventEmitter, type EventType} from '../common/EventEmitter.js';
|
||||||
import {type TimeoutSettings} from '../common/TimeoutSettings.js';
|
import {type TimeoutSettings} from '../common/TimeoutSettings.js';
|
||||||
import {debugError, PuppeteerURL} from '../common/util.js';
|
import {debugError, PuppeteerURL, UTILITY_WORLD_NAME} from '../common/util.js';
|
||||||
import {assert} from '../util/assert.js';
|
import {assert} from '../util/assert.js';
|
||||||
import {Deferred} from '../util/Deferred.js';
|
import {Deferred} from '../util/Deferred.js';
|
||||||
import {isErrorLike} from '../util/ErrorLike.js';
|
import {isErrorLike} from '../util/ErrorLike.js';
|
||||||
@ -37,11 +37,6 @@ import {MAIN_WORLD, PUPPETEER_WORLD} from './IsolatedWorlds.js';
|
|||||||
import {NetworkManager} from './NetworkManager.js';
|
import {NetworkManager} from './NetworkManager.js';
|
||||||
import {type CdpTarget} from './Target.js';
|
import {type CdpTarget} from './Target.js';
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
export const UTILITY_WORLD_NAME = '__puppeteer_utility_world__';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We use symbols to prevent external parties listening to these events.
|
* We use symbols to prevent external parties listening to these events.
|
||||||
* They are internal to Puppeteer.
|
* They are internal to Puppeteer.
|
||||||
|
@ -80,7 +80,7 @@ export namespace NetworkManagerEvent {
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export interface NetworkManagerEvents extends Record<EventType, unknown> {
|
export interface CdpNetworkManagerEvents extends Record<EventType, unknown> {
|
||||||
[NetworkManagerEvent.Request]: CdpHTTPRequest;
|
[NetworkManagerEvent.Request]: CdpHTTPRequest;
|
||||||
[NetworkManagerEvent.RequestServedFromCache]: CdpHTTPRequest | undefined;
|
[NetworkManagerEvent.RequestServedFromCache]: CdpHTTPRequest | undefined;
|
||||||
[NetworkManagerEvent.Response]: CdpHTTPResponse;
|
[NetworkManagerEvent.Response]: CdpHTTPResponse;
|
||||||
@ -98,7 +98,7 @@ export interface FrameProvider {
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export class NetworkManager extends EventEmitter<NetworkManagerEvents> {
|
export class NetworkManager extends EventEmitter<CdpNetworkManagerEvents> {
|
||||||
#ignoreHTTPSErrors: boolean;
|
#ignoreHTTPSErrors: boolean;
|
||||||
#frameManager: FrameProvider;
|
#frameManager: FrameProvider;
|
||||||
#networkEventManager = new NetworkEventManager();
|
#networkEventManager = new NetworkEventManager();
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import {source as injectedSource} from '../generated/injected.js';
|
import {source as injectedSource} from '../generated/injected.js';
|
||||||
|
|
||||||
class ScriptInjector {
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export class ScriptInjector {
|
||||||
#updated = false;
|
#updated = false;
|
||||||
#amendments = new Set<string>();
|
#amendments = new Set<string>();
|
||||||
|
|
||||||
@ -17,7 +20,7 @@ class ScriptInjector {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
inject(inject: (script: string) => void, force = false) {
|
inject(inject: (script: string) => void, force = false): void {
|
||||||
if (this.#updated || force) {
|
if (this.#updated || force) {
|
||||||
inject(this.#get());
|
inject(this.#get());
|
||||||
}
|
}
|
||||||
|
@ -654,3 +654,19 @@ export function timeout(ms: number): Observable<never> {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export const UTILITY_WORLD_NAME = '__puppeteer_utility_world__';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export const SOURCE_URL_REGEX = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m;
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export function getSourceUrlComment(url: string): string {
|
||||||
|
return `//# sourceURL=${url}`;
|
||||||
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
export {Protocol} from 'devtools-protocol';
|
export {Protocol} from 'devtools-protocol';
|
||||||
|
|
||||||
export * from './api/api.js';
|
export * from './api/api.js';
|
||||||
|
export * from './bidi/bidi.js';
|
||||||
export * from './cdp/cdp.js';
|
export * from './cdp/cdp.js';
|
||||||
export * from './common/common.js';
|
export * from './common/common.js';
|
||||||
export * from './node/node.js';
|
export * from './node/node.js';
|
||||||
|
Loading…
Reference in New Issue
Block a user