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.
*/
import {CDPSession} from './Connection.js';
import {ElementHandle} from './JSHandle.js';
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.

View File

@ -14,12 +14,13 @@
* limitations under the License.
*/
import {InternalQueryHandler} from './QueryHandler.js';
import {ElementHandle, JSHandle} from './JSHandle.js';
import {Protocol} from 'devtools-protocol';
import {assert} from './assert.js';
import {CDPSession} from './Connection.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(
client: CDPSession,

View File

@ -17,11 +17,12 @@
import {Protocol} from 'devtools-protocol';
import {assert} from './assert.js';
import {CDPSession} from './Connection.js';
import {ElementHandle} from './ElementHandle.js';
import {TimeoutError} from './Errors.js';
import {ExecutionContext} from './ExecutionContext.js';
import {Frame, FrameManager} from './FrameManager.js';
import {MouseButton} from './Input.js';
import {ElementHandle, JSHandle} from './JSHandle.js';
import {JSHandle} from './JSHandle.js';
import {LifecycleWatcher, PuppeteerLifeCycleEvent} from './LifecycleWatcher.js';
import {_getQueryHandlerAndSelector} from './QueryHandler.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 {EvaluateFunc, HandleFor, EvaluateParams} from './types.js';
import {Frame} from './FrameManager.js';
import {ElementHandle, JSHandle, _createJSHandle} from './JSHandle.js';
import {getExceptionMessage, isString, valueFromRemoteObject} from './util.js';
import {JSHandle} from './JSHandle.js';
import {ElementHandle} from './ElementHandle.js';
import {
getExceptionMessage,
_createJSHandle,
isString,
valueFromRemoteObject,
} from './util.js';
/**
* @public

View File

@ -14,9 +14,9 @@
* limitations under the License.
*/
import {ElementHandle} from './JSHandle.js';
import {Protocol} from 'devtools-protocol';
import {assert} from './assert.js';
import {ElementHandle} from './ElementHandle.js';
/**
* 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 {HTTPResponse} from './HTTPResponse.js';
import {MouseButton} from './Input.js';
import {ElementHandle} from './JSHandle.js';
import {ElementHandle} from './ElementHandle.js';
import {LifecycleWatcher, PuppeteerLifeCycleEvent} from './LifecycleWatcher.js';
import {NetworkManager} from './NetworkManager.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 {Dialog} from './Dialog.js';
import {WaitForSelectorOptions} from './DOMWorld.js';
import {ElementHandle} from './ElementHandle.js';
import {EmulationManager} from './EmulationManager.js';
import {EventEmitter, Handler} from './EventEmitter.js';
import {FileChooser} from './FileChooser.js';
@ -35,7 +36,7 @@ import {
import {HTTPRequest} from './HTTPRequest.js';
import {HTTPResponse} from './HTTPResponse.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 {
Credentials,
@ -66,6 +67,7 @@ import {
valueFromRemoteObject,
waitForEvent,
waitWithTimeout,
_createJSHandle,
} from './util.js';
import {WebWorker} from './WebWorker.js';

View File

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

View File

@ -14,7 +14,8 @@
* 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>;

View File

@ -20,8 +20,11 @@ import {isNode} from '../environment.js';
import {assert} from './assert.js';
import {CDPSession} from './Connection.js';
import {debug} from './Debug.js';
import {ElementHandle} from './ElementHandle.js';
import {TimeoutError} from './Errors.js';
import {CommonEventEmitter} from './EventEmitter.js';
import {ExecutionContext} from './ExecutionContext.js';
import {JSHandle} from './JSHandle.js';
export const debugError = debug('puppeteer:error');
@ -176,6 +179,28 @@ export async function waitForEvent<T>(
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(
fun: Function | string,
...args: unknown[]

View File

@ -22,7 +22,7 @@ import {
describeChromeOnly,
} 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 assert from 'assert';

View File

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