chore: split JSHandle.ts (#8551)

This commit is contained in:
jrandolf 2022-06-23 11:31:43 +02:00 committed by GitHub
parent 26c3acbb07
commit ebcb8a2760
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 1103 additions and 1075 deletions

View File

@ -14,9 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
import {CDPSession} from './Connection.js';
import {ElementHandle} from './JSHandle.js';
import {Protocol} from 'devtools-protocol'; import {Protocol} from 'devtools-protocol';
import {CDPSession} from './Connection.js';
import {ElementHandle} from './ElementHandle.js';
/** /**
* Represents a Node and the properties of it that are relevant to Accessibility. * Represents a Node and the properties of it that are relevant to Accessibility.

View File

@ -14,12 +14,13 @@
* limitations under the License. * limitations under the License.
*/ */
import {InternalQueryHandler} from './QueryHandler.js';
import {ElementHandle, JSHandle} from './JSHandle.js';
import {Protocol} from 'devtools-protocol'; import {Protocol} from 'devtools-protocol';
import {assert} from './assert.js';
import {CDPSession} from './Connection.js'; import {CDPSession} from './Connection.js';
import {DOMWorld, PageBinding, WaitForSelectorOptions} from './DOMWorld.js'; import {DOMWorld, PageBinding, WaitForSelectorOptions} from './DOMWorld.js';
import {assert} from './assert.js'; import {ElementHandle} from './ElementHandle.js';
import {JSHandle} from './JSHandle.js';
import {InternalQueryHandler} from './QueryHandler.js';
async function queryAXTree( async function queryAXTree(
client: CDPSession, client: CDPSession,

View File

@ -17,11 +17,12 @@
import {Protocol} from 'devtools-protocol'; import {Protocol} from 'devtools-protocol';
import {assert} from './assert.js'; import {assert} from './assert.js';
import {CDPSession} from './Connection.js'; import {CDPSession} from './Connection.js';
import {ElementHandle} from './ElementHandle.js';
import {TimeoutError} from './Errors.js'; import {TimeoutError} from './Errors.js';
import {ExecutionContext} from './ExecutionContext.js'; import {ExecutionContext} from './ExecutionContext.js';
import {Frame, FrameManager} from './FrameManager.js'; import {Frame, FrameManager} from './FrameManager.js';
import {MouseButton} from './Input.js'; import {MouseButton} from './Input.js';
import {ElementHandle, JSHandle} from './JSHandle.js'; import {JSHandle} from './JSHandle.js';
import {LifecycleWatcher, PuppeteerLifeCycleEvent} from './LifecycleWatcher.js'; import {LifecycleWatcher, PuppeteerLifeCycleEvent} from './LifecycleWatcher.js';
import {_getQueryHandlerAndSelector} from './QueryHandler.js'; import {_getQueryHandlerAndSelector} from './QueryHandler.js';
import {TimeoutSettings} from './TimeoutSettings.js'; import {TimeoutSettings} from './TimeoutSettings.js';

1048
src/common/ElementHandle.ts Normal file

File diff suppressed because it is too large Load Diff

View File

@ -20,8 +20,14 @@ import {CDPSession} from './Connection.js';
import {DOMWorld} from './DOMWorld.js'; import {DOMWorld} from './DOMWorld.js';
import {EvaluateFunc, HandleFor, EvaluateParams} from './types.js'; import {EvaluateFunc, HandleFor, EvaluateParams} from './types.js';
import {Frame} from './FrameManager.js'; import {Frame} from './FrameManager.js';
import {ElementHandle, JSHandle, _createJSHandle} from './JSHandle.js'; import {JSHandle} from './JSHandle.js';
import {getExceptionMessage, isString, valueFromRemoteObject} from './util.js'; import {ElementHandle} from './ElementHandle.js';
import {
getExceptionMessage,
_createJSHandle,
isString,
valueFromRemoteObject,
} from './util.js';
/** /**
* @public * @public

View File

@ -14,9 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
import {ElementHandle} from './JSHandle.js';
import {Protocol} from 'devtools-protocol'; import {Protocol} from 'devtools-protocol';
import {assert} from './assert.js'; import {assert} from './assert.js';
import {ElementHandle} from './ElementHandle.js';
/** /**
* File choosers let you react to the page requesting for a file. * File choosers let you react to the page requesting for a file.

View File

@ -22,7 +22,7 @@ import {EventEmitter} from './EventEmitter.js';
import {EVALUATION_SCRIPT_URL, ExecutionContext} from './ExecutionContext.js'; import {EVALUATION_SCRIPT_URL, ExecutionContext} from './ExecutionContext.js';
import {HTTPResponse} from './HTTPResponse.js'; import {HTTPResponse} from './HTTPResponse.js';
import {MouseButton} from './Input.js'; import {MouseButton} from './Input.js';
import {ElementHandle} from './JSHandle.js'; import {ElementHandle} from './ElementHandle.js';
import {LifecycleWatcher, PuppeteerLifeCycleEvent} from './LifecycleWatcher.js'; import {LifecycleWatcher, PuppeteerLifeCycleEvent} from './LifecycleWatcher.js';
import {NetworkManager} from './NetworkManager.js'; import {NetworkManager} from './NetworkManager.js';
import {Page} from './Page.js'; import {Page} from './Page.js';

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,7 @@ import {ConsoleMessage, ConsoleMessageType} from './ConsoleMessage.js';
import {Coverage} from './Coverage.js'; import {Coverage} from './Coverage.js';
import {Dialog} from './Dialog.js'; import {Dialog} from './Dialog.js';
import {WaitForSelectorOptions} from './DOMWorld.js'; import {WaitForSelectorOptions} from './DOMWorld.js';
import {ElementHandle} from './ElementHandle.js';
import {EmulationManager} from './EmulationManager.js'; import {EmulationManager} from './EmulationManager.js';
import {EventEmitter, Handler} from './EventEmitter.js'; import {EventEmitter, Handler} from './EventEmitter.js';
import {FileChooser} from './FileChooser.js'; import {FileChooser} from './FileChooser.js';
@ -35,7 +36,7 @@ import {
import {HTTPRequest} from './HTTPRequest.js'; import {HTTPRequest} from './HTTPRequest.js';
import {HTTPResponse} from './HTTPResponse.js'; import {HTTPResponse} from './HTTPResponse.js';
import {Keyboard, Mouse, MouseButton, Touchscreen} from './Input.js'; import {Keyboard, Mouse, MouseButton, Touchscreen} from './Input.js';
import {ElementHandle, JSHandle, _createJSHandle} from './JSHandle.js'; import {JSHandle} from './JSHandle.js';
import {PuppeteerLifeCycleEvent} from './LifecycleWatcher.js'; import {PuppeteerLifeCycleEvent} from './LifecycleWatcher.js';
import { import {
Credentials, Credentials,
@ -66,6 +67,7 @@ import {
valueFromRemoteObject, valueFromRemoteObject,
waitForEvent, waitForEvent,
waitWithTimeout, waitWithTimeout,
_createJSHandle,
} from './util.js'; } from './util.js';
import {WebWorker} from './WebWorker.js'; import {WebWorker} from './WebWorker.js';

View File

@ -15,8 +15,9 @@
*/ */
import {WaitForSelectorOptions, DOMWorld} from './DOMWorld.js'; import {WaitForSelectorOptions, DOMWorld} from './DOMWorld.js';
import {ElementHandle, JSHandle} from './JSHandle.js'; import {JSHandle} from './JSHandle.js';
import {ariaHandler} from './AriaQueryHandler.js'; import {ariaHandler} from './AriaQueryHandler.js';
import {ElementHandle} from './ElementHandle.js';
/** /**
* @internal * @internal

View File

@ -14,7 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
import {JSHandle, ElementHandle} from './JSHandle.js'; import {JSHandle} from './JSHandle.js';
import {ElementHandle} from './ElementHandle.js';
export type Awaitable<T> = T | PromiseLike<T>; export type Awaitable<T> = T | PromiseLike<T>;

View File

@ -20,8 +20,11 @@ import {isNode} from '../environment.js';
import {assert} from './assert.js'; import {assert} from './assert.js';
import {CDPSession} from './Connection.js'; import {CDPSession} from './Connection.js';
import {debug} from './Debug.js'; import {debug} from './Debug.js';
import {ElementHandle} from './ElementHandle.js';
import {TimeoutError} from './Errors.js'; import {TimeoutError} from './Errors.js';
import {CommonEventEmitter} from './EventEmitter.js'; import {CommonEventEmitter} from './EventEmitter.js';
import {ExecutionContext} from './ExecutionContext.js';
import {JSHandle} from './JSHandle.js';
export const debugError = debug('puppeteer:error'); export const debugError = debug('puppeteer:error');
@ -176,6 +179,28 @@ export async function waitForEvent<T>(
return result; return result;
} }
/**
* @internal
*/
export function _createJSHandle(
context: ExecutionContext,
remoteObject: Protocol.Runtime.RemoteObject
): JSHandle | ElementHandle {
const frame = context.frame();
if (remoteObject.subtype === 'node' && frame) {
const frameManager = frame._frameManager;
return new ElementHandle(
context,
context._client,
remoteObject,
frame,
frameManager.page(),
frameManager
);
}
return new JSHandle(context, context._client, remoteObject);
}
export function evaluationString( export function evaluationString(
fun: Function | string, fun: Function | string,
...args: unknown[] ...args: unknown[]

View File

@ -22,7 +22,7 @@ import {
describeChromeOnly, describeChromeOnly,
} from './mocha-utils.js'; } from './mocha-utils.js';
import {ElementHandle} from '../../lib/cjs/puppeteer/common/JSHandle.js'; import {ElementHandle} from '../../lib/cjs/puppeteer/common/ElementHandle.js';
import utils from './utils.js'; import utils from './utils.js';
import assert from 'assert'; import assert from 'assert';

View File

@ -15,7 +15,7 @@
*/ */
import expect from 'expect'; import expect from 'expect';
import {ElementHandle} from '../../lib/cjs/puppeteer/common/JSHandle.js'; import {ElementHandle} from '../../lib/cjs/puppeteer/common/ElementHandle.js';
import { import {
getTestState, getTestState,
setupTestBrowserHooks, setupTestBrowserHooks,