chore: organize client imports (1)
This commit is contained in:
parent
11e1b8f30a
commit
e7334b65ad
|
|
@ -15,20 +15,23 @@
|
|||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import { isString, isRegExp, monotonicTime } from '../utils';
|
||||
import type * as channels from '@protocol/channels';
|
||||
|
||||
import { isString, isRegExp } from '../utils/isomorphic/rtti';
|
||||
import { monotonicTime } from '../utils/isomorphic/time';
|
||||
import { Events } from './events';
|
||||
import { BrowserContext, prepareBrowserContextParams } from './browserContext';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import type * as api from '../../types/types';
|
||||
import type * as types from './types';
|
||||
import type { Page } from './page';
|
||||
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||
import { Waiter } from './waiter';
|
||||
import { EventEmitter } from 'events';
|
||||
import { Connection } from './connection';
|
||||
import { isTargetClosedError, TargetClosedError } from './errors';
|
||||
import { raceAgainstDeadline } from '../utils/timeoutRunner';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type * as api from '../../types/types';
|
||||
import type * as types from './types';
|
||||
import type { Page } from './page';
|
||||
import type { AndroidServerLauncherImpl } from '../androidServerImpl';
|
||||
|
||||
type Direction = 'down' | 'up' | 'left' | 'right';
|
||||
|
|
|
|||
|
|
@ -14,11 +14,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import * as fs from 'fs';
|
||||
import fs from 'fs';
|
||||
|
||||
import { Stream } from './stream';
|
||||
import { mkdirIfNeeded } from '../utils/fileUtils';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { Readable } from 'stream';
|
||||
|
||||
export class Artifact extends ChannelOwner<channels.ArtifactChannel> {
|
||||
|
|
|
|||
|
|
@ -15,18 +15,20 @@
|
|||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import type * as channels from '@protocol/channels';
|
||||
|
||||
import { BrowserContext, prepareBrowserContextParams } from './browserContext';
|
||||
import type { Page } from './page';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import { Events } from './events';
|
||||
import type { LaunchOptions, BrowserContextOptions, HeadersArray } from './types';
|
||||
import { isTargetClosedError } from './errors';
|
||||
import type * as api from '../../types/types';
|
||||
import { CDPSession } from './cdpSession';
|
||||
import type { BrowserType } from './browserType';
|
||||
import { Artifact } from './artifact';
|
||||
import { mkdirIfNeeded } from '../utils';
|
||||
import { mkdirIfNeeded } from '../utils/fileUtils';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { Page } from './page';
|
||||
import type { LaunchOptions, BrowserContextOptions, HeadersArray } from './types';
|
||||
import type * as api from '../../types/types';
|
||||
import type { BrowserType } from './browserType';
|
||||
|
||||
export class Browser extends ChannelOwner<channels.BrowserChannel> implements api.Browser {
|
||||
readonly _contexts = new Set<BrowserContext>();
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { Page, BindingCall } from './page';
|
||||
import { Frame } from './frame';
|
||||
import * as network from './network';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import { evaluationScript } from './clientHelper';
|
||||
import { Browser } from './browser';
|
||||
|
|
@ -28,13 +28,8 @@ import { Worker } from './worker';
|
|||
import { Events } from './events';
|
||||
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||
import { Waiter } from './waiter';
|
||||
import type { Headers, WaitForEventOptions, BrowserContextOptions, LaunchOptions, StorageState } from './types';
|
||||
import { type URLMatch, headersObjectToArray, isRegExp, isString, urlMatchesEqual, mkdirIfNeeded } from '../utils';
|
||||
import type * as api from '../../types/types';
|
||||
import type * as structs from '../../types/structs';
|
||||
import { CDPSession } from './cdpSession';
|
||||
import { Tracing } from './tracing';
|
||||
import type { BrowserType } from './browserType';
|
||||
import { Artifact } from './artifact';
|
||||
import { APIRequestContext } from './fetch';
|
||||
import { rewriteErrorMessage } from '../utils/stackTrace';
|
||||
|
|
@ -44,6 +39,18 @@ import { Dialog } from './dialog';
|
|||
import { WebError } from './webError';
|
||||
import { TargetClosedError, parseError } from './errors';
|
||||
import { Clock } from './clock';
|
||||
import { isRegExp, isString } from '../utils/isomorphic/rtti';
|
||||
import { headersObjectToArray } from '../utils/isomorphic/headers';
|
||||
import { urlMatchesEqual } from '../utils/isomorphic/urlMatch';
|
||||
import { mkdirIfNeeded } from '../utils/fileUtils';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { Headers, WaitForEventOptions, BrowserContextOptions, LaunchOptions, StorageState } from './types';
|
||||
import type * as api from '../../types/types';
|
||||
import type * as structs from '../../types/structs';
|
||||
import type { BrowserType } from './browserType';
|
||||
|
||||
import type { URLMatch } from '../utils';
|
||||
|
||||
export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel> implements api.BrowserContext {
|
||||
_pages = new Set<Page>();
|
||||
|
|
|
|||
|
|
@ -14,18 +14,21 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { Browser } from './browser';
|
||||
import { BrowserContext, prepareBrowserContextParams } from './browserContext';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import type { LaunchOptions, LaunchServerOptions, ConnectOptions, LaunchPersistentContextOptions, BrowserContextOptions, Logger } from './types';
|
||||
import { Connection } from './connection';
|
||||
import { Events } from './events';
|
||||
import type { ChildProcess } from 'child_process';
|
||||
import { envObjectToArray } from './clientHelper';
|
||||
import { assert, headersObjectToArray, monotonicTime } from '../utils';
|
||||
import type * as api from '../../types/types';
|
||||
import { assert } from '../utils/debug';
|
||||
import { headersObjectToArray } from '../utils/isomorphic/headers';
|
||||
import { monotonicTime } from '../utils/isomorphic/time';
|
||||
import { raceAgainstDeadline } from '../utils/timeoutRunner';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { LaunchOptions, LaunchServerOptions, ConnectOptions, LaunchPersistentContextOptions, BrowserContextOptions, Logger } from './types';
|
||||
import type { ChildProcess } from 'child_process';
|
||||
import type * as api from '../../types/types';
|
||||
import type { Playwright } from './playwright';
|
||||
|
||||
export interface BrowserServerLauncher {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { Protocol } from '../server/chromium/protocol';
|
||||
import type * as api from '../../types/types';
|
||||
|
||||
|
|
|
|||
|
|
@ -15,12 +15,13 @@
|
|||
*/
|
||||
|
||||
import { EventEmitter } from './eventEmitter';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { maybeFindValidator, ValidationError, type ValidatorContext } from '../protocol/validator';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { captureLibraryStackTrace, stringifyStackFrames } from '../utils/stackTrace';
|
||||
import { isUnderTest } from '../utils';
|
||||
import { isUnderTest } from '../utils/debug';
|
||||
import { zones } from '../utils/zones';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { ClientInstrumentation } from './clientInstrumentation';
|
||||
import type { Connection } from './connection';
|
||||
import type { Logger } from './types';
|
||||
|
|
|
|||
|
|
@ -15,9 +15,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type * as types from './types';
|
||||
import fs from 'fs';
|
||||
import { isString } from '../utils';
|
||||
|
||||
import { isString } from '../utils/isomorphic/stringUtils';
|
||||
|
||||
import type * as types from './types';
|
||||
|
||||
export function envObjectToArray(env: types.Env): { name: string, value: string }[] {
|
||||
const result: { name: string, value: string }[] = [];
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import { parseError, TargetClosedError } from './errors';
|
|||
import { CDPSession } from './cdpSession';
|
||||
import { Playwright } from './playwright';
|
||||
import { Electron, ElectronApplication } from './electron';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { Stream } from './stream';
|
||||
import { WritableStream } from './writableStream';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
|
|
@ -43,8 +42,11 @@ import { LocalUtils } from './localUtils';
|
|||
import { Tracing } from './tracing';
|
||||
import { findValidator, ValidationError, type ValidatorContext } from '../protocol/validator';
|
||||
import { createInstrumentation } from './clientInstrumentation';
|
||||
import { formatCallLog, rewriteErrorMessage } from '../utils/stackTrace';
|
||||
import { zones } from '../utils/zones';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { ClientInstrumentation } from './clientInstrumentation';
|
||||
import { formatCallLog, rewriteErrorMessage, zones } from '../utils';
|
||||
|
||||
class Root extends ChannelOwner<channels.RootChannel> {
|
||||
constructor(connection: Connection) {
|
||||
|
|
|
|||
|
|
@ -14,11 +14,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import * as util from 'util';
|
||||
import util from 'util';
|
||||
|
||||
import { JSHandle } from './jsHandle';
|
||||
import { Page } from './page';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type * as api from '../../types/types';
|
||||
import { Page } from './page';
|
||||
|
||||
type ConsoleMessageLocation = channels.BrowserContextConsoleEvent['location'];
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import type * as api from '../../types/types';
|
||||
import { Page } from './page';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type * as api from '../../types/types';
|
||||
|
||||
export class Dialog extends ChannelOwner<channels.DialogChannel> implements api.Dialog {
|
||||
static from(dialog: channels.DialogChannel): Dialog {
|
||||
return (dialog as any)._object;
|
||||
|
|
|
|||
|
|
@ -14,23 +14,24 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { BrowserWindow } from 'electron';
|
||||
import type * as childProcess from 'child_process';
|
||||
import type * as structs from '../../types/structs';
|
||||
import type * as api from '../../types/types';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||
import { BrowserContext, prepareBrowserContextParams } from './browserContext';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import { envObjectToArray } from './clientHelper';
|
||||
import { Events } from './events';
|
||||
import { JSHandle, parseResult, serializeArgument } from './jsHandle';
|
||||
import type { Page } from './page';
|
||||
import { ConsoleMessage } from './consoleMessage';
|
||||
import type { Env, WaitForEventOptions, Headers, BrowserContextOptions } from './types';
|
||||
import { Waiter } from './waiter';
|
||||
import { TargetClosedError, isTargetClosedError } from './errors';
|
||||
|
||||
import type { BrowserWindow } from 'electron';
|
||||
import type * as childProcess from 'child_process';
|
||||
import type * as structs from '../../types/structs';
|
||||
import type * as api from '../../types/types';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { Page } from './page';
|
||||
import type { Env, WaitForEventOptions, Headers, BrowserContextOptions } from './types';
|
||||
|
||||
type ElectronOptions = Omit<channels.ElectronLaunchOptions, 'env'|'extraHTTPHeaders'|'recordHar'|'colorScheme'|'acceptDownloads'> & {
|
||||
env?: Env,
|
||||
extraHTTPHeaders?: Headers,
|
||||
|
|
|
|||
|
|
@ -13,25 +13,27 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { Frame } from './frame';
|
||||
import type { Locator } from './locator';
|
||||
import { JSHandle, serializeArgument, parseResult } from './jsHandle';
|
||||
import type { ChannelOwner } from './channelOwner';
|
||||
import type { SelectOption, FilePayload, Rect, SelectOptionOptions } from './types';
|
||||
import fs from 'fs';
|
||||
import { mime } from '../utilsBundle';
|
||||
import path from 'path';
|
||||
import { assert, isString } from '../utils';
|
||||
|
||||
import { Frame } from './frame';
|
||||
import { JSHandle, serializeArgument, parseResult } from './jsHandle';
|
||||
import { mime } from '../utilsBundle';
|
||||
import { assert } from '../utils/debug';
|
||||
import { isString } from '../utils/isomorphic/rtti';
|
||||
import { fileUploadSizeLimit, mkdirIfNeeded } from '../utils/fileUtils';
|
||||
import type * as api from '../../types/types';
|
||||
import type * as structs from '../../types/structs';
|
||||
import type { BrowserContext } from './browserContext';
|
||||
import { WritableStream } from './writableStream';
|
||||
import { pipeline } from 'stream';
|
||||
import { promisify } from 'util';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { Locator } from './locator';
|
||||
import type { ChannelOwner } from './channelOwner';
|
||||
import type { SelectOption, FilePayload, Rect, SelectOptionOptions } from './types';
|
||||
import type * as api from '../../types/types';
|
||||
import type * as structs from '../../types/structs';
|
||||
import type { BrowserContext } from './browserContext';
|
||||
|
||||
const pipelineAsync = promisify(pipeline);
|
||||
|
||||
export class ElementHandle<T extends Node = Node> extends JSHandle<T> implements api.ElementHandle {
|
||||
|
|
|
|||
|
|
@ -14,10 +14,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { SerializedError } from '@protocol/channels';
|
||||
import { isError } from '../utils';
|
||||
import { isError } from '../utils/isomorphic/rtti';
|
||||
import { parseSerializedValue, serializeValue } from '../protocol/serializers';
|
||||
|
||||
import type { SerializedError } from '@protocol/channels';
|
||||
|
||||
export class TimeoutError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
|
|
|
|||
|
|
@ -22,12 +22,14 @@
|
|||
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { EventEmitter as OriginalEventEmitter } from 'events';
|
||||
import { isUnderTest } from '../utils/debug';
|
||||
|
||||
import type { EventEmitter as EventEmitterType } from 'events';
|
||||
|
||||
type EventType = string | symbol;
|
||||
type Listener = (...args: any[]) => any;
|
||||
type EventMap = Record<EventType, Listener | Listener[]>;
|
||||
import { EventEmitter as OriginalEventEmitter } from 'events';
|
||||
import type { EventEmitter as EventEmitterType } from 'events';
|
||||
import { isUnderTest } from '../utils';
|
||||
|
||||
export class EventEmitter implements EventEmitterType {
|
||||
|
||||
|
|
|
|||
|
|
@ -16,20 +16,24 @@
|
|||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import * as util from 'util';
|
||||
import util from 'util';
|
||||
|
||||
import { assert } from '../utils/debug';
|
||||
import { headersObjectToArray } from '../utils/isomorphic/headers';
|
||||
import { isString } from '../utils/isomorphic/rtti';
|
||||
import { mkdirIfNeeded } from '../utils/fileUtils';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import { RawHeaders } from './network';
|
||||
import { Tracing } from './tracing';
|
||||
import { TargetClosedError, isTargetClosedError } from './errors';
|
||||
import { toClientCertificatesProtocol } from './browserContext';
|
||||
|
||||
import type { Serializable } from '../../types/structs';
|
||||
import type * as api from '../../types/types';
|
||||
import type { HeadersArray, NameValue } from '../common/types';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { assert, headersObjectToArray, isString } from '../utils';
|
||||
import { mkdirIfNeeded } from '../utils/fileUtils';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import { RawHeaders } from './network';
|
||||
import type { ClientCertificate, FilePayload, Headers, StorageState } from './types';
|
||||
import type { Playwright } from './playwright';
|
||||
import { Tracing } from './tracing';
|
||||
import { TargetClosedError, isTargetClosedError } from './errors';
|
||||
import { toClientCertificatesProtocol } from './browserContext';
|
||||
|
||||
export type FetchOptions = {
|
||||
params?: { [key: string]: string | number | boolean; } | URLSearchParams | string,
|
||||
|
|
|
|||
|
|
@ -15,27 +15,30 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { assert } from '../utils';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import fs from 'fs';
|
||||
|
||||
import { assert } from '../utils/debug';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import { FrameLocator, Locator, testIdAttributeName } from './locator';
|
||||
import type { LocatorOptions } from './locator';
|
||||
import { getByAltTextSelector, getByLabelSelector, getByPlaceholderSelector, getByRoleSelector, getByTestIdSelector, getByTextSelector, getByTitleSelector } from '../utils/isomorphic/locatorUtils';
|
||||
import type { ByRoleOptions } from '../utils/isomorphic/locatorUtils';
|
||||
import { ElementHandle, convertSelectOptionValues, convertInputFiles } from './elementHandle';
|
||||
import { assertMaxArguments, JSHandle, serializeArgument, parseResult } from './jsHandle';
|
||||
import fs from 'fs';
|
||||
import * as network from './network';
|
||||
import type { Page } from './page';
|
||||
import { EventEmitter } from 'events';
|
||||
import { Waiter } from './waiter';
|
||||
import { Events } from './events';
|
||||
import type { LifecycleEvent, SelectOption, SelectOptionOptions, FilePayload, WaitForFunctionOptions, StrictOptions } from './types';
|
||||
import { kLifecycleEvents } from './types';
|
||||
import { type URLMatch, urlMatches } from '../utils';
|
||||
import { urlMatches } from '../utils/isomorphic/urlMatch';
|
||||
import { addSourceUrlToScript } from './clientHelper';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { LocatorOptions } from './locator';
|
||||
import type { ByRoleOptions } from '../utils/isomorphic/locatorUtils';
|
||||
import type { Page } from './page';
|
||||
import type { LifecycleEvent, SelectOption, SelectOptionOptions, FilePayload, WaitForFunctionOptions, StrictOptions } from './types';
|
||||
import type * as api from '../../types/types';
|
||||
import type * as structs from '../../types/structs';
|
||||
import { addSourceUrlToScript } from './clientHelper';
|
||||
import type { URLMatch } from '../utils';
|
||||
|
||||
export type WaitForNavigationOptions = {
|
||||
timeout?: number,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
|
||||
import type { BrowserContext } from './browserContext';
|
||||
import type { LocalUtils } from './localUtils';
|
||||
import type { Route } from './network';
|
||||
|
|
|
|||
|
|
@ -14,12 +14,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import { parseSerializedValue, serializeValue } from '../protocol/serializers';
|
||||
import { isTargetClosedError } from './errors';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type * as api from '../../types/types';
|
||||
import type * as structs from '../../types/structs';
|
||||
import { isTargetClosedError } from './errors';
|
||||
|
||||
export class JSHandle<T = any> extends ChannelOwner<channels.JSHandleChannel> implements api.JSHandle {
|
||||
private _preview: string;
|
||||
|
|
|
|||
|
|
@ -14,9 +14,10 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
|
||||
export class JsonPipe extends ChannelOwner<channels.JsonPipeChannel> {
|
||||
static from(jsonPipe: channels.JsonPipeChannel): JsonPipe {
|
||||
return (jsonPipe as any)._object;
|
||||
|
|
|
|||
|
|
@ -14,8 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { Size } from './types';
|
||||
|
||||
type DeviceDescriptor = {
|
||||
|
|
|
|||
|
|
@ -14,18 +14,22 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import util from 'util';
|
||||
|
||||
import { isString } from '../utils/isomorphic/stringUtils';
|
||||
import { monotonicTime } from '../utils/isomorphic/time';
|
||||
import { asLocator } from '../utils/isomorphic/locatorGenerators';
|
||||
import { ElementHandle } from './elementHandle';
|
||||
import { parseResult, serializeArgument } from './jsHandle';
|
||||
import { escapeForTextSelector } from '../utils/isomorphic/stringUtils';
|
||||
import { getByAltTextSelector, getByLabelSelector, getByPlaceholderSelector, getByRoleSelector, getByTestIdSelector, getByTextSelector, getByTitleSelector } from '../utils/isomorphic/locatorUtils';
|
||||
|
||||
import type * as structs from '../../types/structs';
|
||||
import type * as api from '../../types/types';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import * as util from 'util';
|
||||
import { asLocator, isString, monotonicTime } from '../utils';
|
||||
import { ElementHandle } from './elementHandle';
|
||||
import type { Frame } from './frame';
|
||||
import type { FilePayload, FrameExpectParams, Rect, SelectOption, SelectOptionOptions, TimeoutOptions } from './types';
|
||||
import { parseResult, serializeArgument } from './jsHandle';
|
||||
import { escapeForTextSelector } from '../utils/isomorphic/stringUtils';
|
||||
import type { ByRoleOptions } from '../utils/isomorphic/locatorUtils';
|
||||
import { getByAltTextSelector, getByLabelSelector, getByPlaceholderSelector, getByRoleSelector, getByTestIdSelector, getByTextSelector, getByTitleSelector } from '../utils/isomorphic/locatorUtils';
|
||||
|
||||
export type LocatorOptions = {
|
||||
hasText?: string | RegExp;
|
||||
|
|
|
|||
|
|
@ -14,26 +14,33 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { URLSearchParams } from 'url';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import fs from 'fs';
|
||||
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import { Frame } from './frame';
|
||||
import { Worker } from './worker';
|
||||
import type { Headers, RemoteAddr, SecurityDetails, WaitForEventOptions } from './types';
|
||||
import fs from 'fs';
|
||||
import { mime } from '../utilsBundle';
|
||||
import { assert, isString, headersObjectToArray, isRegExp, rewriteErrorMessage, MultiMap, urlMatches, zones } from '../utils';
|
||||
import type { URLMatch, Zone } from '../utils';
|
||||
import { assert } from '../utils/debug';
|
||||
import { headersObjectToArray } from '../utils/isomorphic/headers';
|
||||
import { isString, isRegExp } from '../utils/isomorphic/rtti';
|
||||
import { MultiMap } from '../utils/isomorphic/multimap';
|
||||
import { urlMatches } from '../utils/isomorphic/urlMatch';
|
||||
import { rewriteErrorMessage } from '../utils/stackTrace';
|
||||
import { zones } from '../utils/zones';
|
||||
import { ManualPromise, LongStandingScope } from '../utils/manualPromise';
|
||||
import { Events } from './events';
|
||||
import type { Page } from './page';
|
||||
import { Waiter } from './waiter';
|
||||
import { APIResponse } from './fetch';
|
||||
import { isTargetClosedError } from './errors';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { Headers, RemoteAddr, SecurityDetails, WaitForEventOptions } from './types';
|
||||
import type { URLMatch, Zone } from '../utils';
|
||||
import type { Page } from './page';
|
||||
import type * as api from '../../types/types';
|
||||
import type { HeadersArray } from '../common/types';
|
||||
import { APIResponse } from './fetch';
|
||||
import type { Serializable } from '../../types/structs';
|
||||
import type { BrowserContext } from './browserContext';
|
||||
import { isTargetClosedError } from './errors';
|
||||
|
||||
export type NetworkCookie = {
|
||||
name: string,
|
||||
|
|
|
|||
|
|
@ -17,36 +17,48 @@
|
|||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import type * as structs from '../../types/structs';
|
||||
import type * as api from '../../types/types';
|
||||
|
||||
import { serializeError, isTargetClosedError, TargetClosedError } from './errors';
|
||||
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { assert, headersObjectToArray, isObject, isRegExp, isString, LongStandingScope, urlMatches, urlMatchesEqual, mkdirIfNeeded, trimStringWithEllipsis, type URLMatch } from '../utils';
|
||||
|
||||
import { assert } from '../utils/debug';
|
||||
import { isObject, isRegExp, isString } from '../utils/isomorphic/rtti';
|
||||
import { headersObjectToArray } from '../utils/isomorphic/headers';
|
||||
import { urlMatches, urlMatchesEqual } from '../utils/isomorphic/urlMatch';
|
||||
import { LongStandingScope } from '../utils/manualPromise';
|
||||
import { trimStringWithEllipsis } from '../utils/isomorphic/stringUtils';
|
||||
import { mkdirIfNeeded } from '../utils/fileUtils';
|
||||
|
||||
import { Accessibility } from './accessibility';
|
||||
import { Artifact } from './artifact';
|
||||
import type { BrowserContext } from './browserContext';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import { evaluationScript } from './clientHelper';
|
||||
import { Coverage } from './coverage';
|
||||
import { Download } from './download';
|
||||
import { determineScreenshotType, ElementHandle } from './elementHandle';
|
||||
import { Events } from './events';
|
||||
import type { APIRequestContext } from './fetch';
|
||||
import { FileChooser } from './fileChooser';
|
||||
import type { WaitForNavigationOptions } from './frame';
|
||||
import { Frame, verifyLoadState } from './frame';
|
||||
import { Keyboard, Mouse, Touchscreen } from './input';
|
||||
import { assertMaxArguments, JSHandle, parseResult, serializeArgument } from './jsHandle';
|
||||
import type { FrameLocator, Locator, LocatorOptions } from './locator';
|
||||
import type { ByRoleOptions } from '../utils/isomorphic/locatorUtils';
|
||||
import { type RouteHandlerCallback, type Request, Response, Route, RouteHandler, validateHeaders, WebSocket, type WebSocketRouteHandlerCallback, WebSocketRoute, WebSocketRouteHandler } from './network';
|
||||
import type { FilePayload, Headers, LifecycleEvent, SelectOption, SelectOptionOptions, Size, WaitForEventOptions, WaitForFunctionOptions } from './types';
|
||||
import { Video } from './video';
|
||||
import { Waiter } from './waiter';
|
||||
import { Worker } from './worker';
|
||||
import { HarRouter } from './harRouter';
|
||||
import { Response, Route, RouteHandler, validateHeaders, WebSocket, WebSocketRoute, WebSocketRouteHandler } from './network';
|
||||
|
||||
import type * as structs from '../../types/structs';
|
||||
import type * as api from '../../types/types';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { BrowserContext } from './browserContext';
|
||||
import type { APIRequestContext } from './fetch';
|
||||
import type { WaitForNavigationOptions } from './frame';
|
||||
import type { FrameLocator, Locator, LocatorOptions } from './locator';
|
||||
import type { ByRoleOptions } from '../utils/isomorphic/locatorUtils';
|
||||
import type { RouteHandlerCallback, Request, WebSocketRouteHandlerCallback } from './network';
|
||||
import type { FilePayload, Headers, LifecycleEvent, SelectOption, SelectOptionOptions, Size, WaitForEventOptions, WaitForFunctionOptions } from './types';
|
||||
import type { Clock } from './clock';
|
||||
import type { URLMatch } from '../utils';
|
||||
|
||||
type PDFOptions = Omit<channels.PagePdfParams, 'width' | 'height' | 'margin'> & {
|
||||
width?: string | number,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { TimeoutError } from './errors';
|
||||
import { Android } from './android';
|
||||
import { BrowserType } from './browserType';
|
||||
|
|
@ -23,6 +22,8 @@ import { Electron } from './electron';
|
|||
import { APIRequest } from './fetch';
|
||||
import { Selectors, SelectorsOwner } from './selectors';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
|
||||
export class Playwright extends ChannelOwner<channels.PlaywrightChannel> {
|
||||
readonly _android: Android;
|
||||
readonly _electron: Electron;
|
||||
|
|
|
|||
|
|
@ -15,11 +15,12 @@
|
|||
*/
|
||||
|
||||
import { evaluationScript } from './clientHelper';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import { setTestIdAttribute, testIdAttributeName } from './locator';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { SelectorEngine } from './types';
|
||||
import type * as api from '../../types/types';
|
||||
import { setTestIdAttribute, testIdAttributeName } from './locator';
|
||||
|
||||
export class Selectors implements api.Selectors {
|
||||
private _channels = new Set<SelectorsOwner>();
|
||||
|
|
|
|||
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
|
||||
import { Readable } from 'stream';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
|
||||
export class Stream extends ChannelOwner<channels.StreamChannel> {
|
||||
static from(Stream: channels.StreamChannel): Stream {
|
||||
return (Stream as any)._object;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type * as api from '../../types/types';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { Artifact } from './artifact';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
|
||||
import type * as api from '../../types/types';
|
||||
import type * as channels from '@protocol/channels';
|
||||
|
||||
export class Tracing extends ChannelOwner<channels.TracingChannel> implements api.Tracing {
|
||||
private _includeSources = false;
|
||||
_tracesDir: string | undefined;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ManualPromise } from '../utils/manualPromise';
|
||||
|
||||
import type { Page } from './page';
|
||||
import type * as api from '../../types/types';
|
||||
import type { Artifact } from './artifact';
|
||||
import type { Connection } from './connection';
|
||||
import { ManualPromise } from '../utils';
|
||||
|
||||
export class Video implements api.Video {
|
||||
private _artifact: Promise<Artifact | null> | null = null;
|
||||
|
|
|
|||
|
|
@ -14,10 +14,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { EventEmitter } from 'events';
|
||||
import { rewriteErrorMessage } from '../utils/stackTrace';
|
||||
import { TimeoutError } from './errors';
|
||||
import { createGuid, zones } from '../utils';
|
||||
import { createGuid } from '../utils/crypto';
|
||||
import { zones } from '../utils/zones';
|
||||
|
||||
import type { EventEmitter } from 'events';
|
||||
import type { Zone } from '../utils';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { ChannelOwner } from './channelOwner';
|
||||
|
|
|
|||
|
|
@ -15,15 +15,16 @@
|
|||
*/
|
||||
|
||||
import { Events } from './events';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import { assertMaxArguments, JSHandle, parseResult, serializeArgument } from './jsHandle';
|
||||
import { LongStandingScope } from '../utils/manualPromise';
|
||||
import { TargetClosedError } from './errors';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { Page } from './page';
|
||||
import type { BrowserContext } from './browserContext';
|
||||
import type * as api from '../../types/types';
|
||||
import type * as structs from '../../types/structs';
|
||||
import { LongStandingScope } from '../utils';
|
||||
import { TargetClosedError } from './errors';
|
||||
|
||||
export class Worker extends ChannelOwner<channels.WorkerChannel> implements api.Worker {
|
||||
_page: Page | undefined; // Set for web workers.
|
||||
|
|
|
|||
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
|
||||
import { Writable } from 'stream';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
|
||||
export class WritableStream extends ChannelOwner<channels.WritableStreamChannel> {
|
||||
static from(Stream: channels.WritableStreamChannel): WritableStream {
|
||||
return (Stream as any)._object;
|
||||
|
|
|
|||
|
|
@ -15,11 +15,14 @@
|
|||
*/
|
||||
|
||||
import EventEmitter from 'events';
|
||||
import type { AddressInfo } from 'net';
|
||||
import net from 'net';
|
||||
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { createSocket } from '../utils/happy-eyeballs';
|
||||
import { assert, createGuid, } from '../utils';
|
||||
import { createGuid } from '../utils/crypto';
|
||||
import { assert } from '../utils/debug';
|
||||
|
||||
import type { AddressInfo } from 'net';
|
||||
|
||||
// https://tools.ietf.org/html/rfc1928
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { debugMode } from '../utils';
|
||||
import { debugMode } from '../utils/debug';
|
||||
|
||||
export const DEFAULT_TIMEOUT = 30000;
|
||||
export const DEFAULT_LAUNCH_TIMEOUT = 3 * 60 * 1000; // 3 minutes
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import type { Frame } from '../frames';
|
|||
import type { Page } from '../page';
|
||||
import type { Signal } from '../../../../recorder/src/actions';
|
||||
import type * as actions from '@recorder/actions';
|
||||
import { monotonicTime } from '../../utils/time';
|
||||
import { monotonicTime } from '../../utils/isomorphic/time';
|
||||
import { collapseActions } from './recorderUtils';
|
||||
import { performAction } from './recorderRunner';
|
||||
import { isUnderTest } from '../../utils/debug';
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import type { ParsedSelector } from '../utils/isomorphic/selectorParser';
|
|||
import type * as types from './types';
|
||||
import type { Progress } from './progress';
|
||||
import { assert } from '../utils';
|
||||
import { MultiMap } from '../utils/multimap';
|
||||
import { MultiMap } from '../utils/isomorphic/multimap';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
|
|
|
|||
|
|
@ -3,4 +3,5 @@
|
|||
../third_party/pixelmatch
|
||||
../image_tools/compare.ts
|
||||
../utilsBundle.ts
|
||||
./isomorphic
|
||||
../zipBundle.ts
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
|
||||
import type { ExpectedTextValue } from '@protocol/channels';
|
||||
import { isRegExp, isString } from './rtti';
|
||||
import { isRegExp, isString } from './isomorphic/rtti';
|
||||
|
||||
export function serializeExpectedTextValues(items: (string | RegExp)[], options: { matchSubstring?: boolean, normalizeWhiteSpace?: boolean, ignoreCase?: boolean } = {}): ExpectedTextValue[] {
|
||||
return items.map(i => ({
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import * as net from 'net';
|
|||
import * as tls from 'tls';
|
||||
import { ManualPromise } from './manualPromise';
|
||||
import { assert } from './debug';
|
||||
import { monotonicTime } from './time';
|
||||
import { monotonicTime } from './isomorphic/time';
|
||||
|
||||
// Implementation(partial) of Happy Eyeballs 2 algorithm described in
|
||||
// https://www.rfc-editor.org/rfc/rfc8305
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export * from './env';
|
|||
export * from './eventsHelper';
|
||||
export * from './expectUtils';
|
||||
export * from './fileUtils';
|
||||
export * from './headers';
|
||||
export * from './isomorphic/headers';
|
||||
export * from './hostPlatform';
|
||||
export * from './httpServer';
|
||||
export * from './manualPromise';
|
||||
|
|
@ -31,16 +31,16 @@ export * from './isomorphic/locatorGenerators';
|
|||
export * from './isomorphic/mimeType';
|
||||
export * from './isomorphic/stringUtils';
|
||||
export * from './isomorphic/urlMatch';
|
||||
export * from './multimap';
|
||||
export * from './isomorphic/multimap';
|
||||
export * from './network';
|
||||
export * from './processLauncher';
|
||||
export * from './profiler';
|
||||
export * from './rtti';
|
||||
export * from './isomorphic/rtti';
|
||||
export * from './semaphore';
|
||||
export * from './spawnAsync';
|
||||
export * from './stackTrace';
|
||||
export * from './task';
|
||||
export * from './time';
|
||||
export * from './isomorphic/time';
|
||||
export * from './timeoutRunner';
|
||||
export * from './traceUtils';
|
||||
export * from './userAgent';
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export { isString } from './isomorphic/stringUtils';
|
||||
export { isString } from './stringUtils';
|
||||
|
||||
export function isRegExp(obj: any): obj is RegExp {
|
||||
return obj instanceof RegExp || Object.prototype.toString.call(obj) === '[object RegExp]';
|
||||
19
packages/playwright-core/src/utils/isomorphic/time.ts
Normal file
19
packages/playwright-core/src/utils/isomorphic/time.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* 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 function monotonicTime(): number {
|
||||
return (performance.now() * 1000 | 0) / 1000;
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// The `process.hrtime()` returns a time from some arbitrary
|
||||
// date in the past; on certain systems, this is the time from the system boot.
|
||||
// The `monotonicTime()` converts this to milliseconds.
|
||||
//
|
||||
// For a Linux server with uptime of 36 days, the `monotonicTime()` value
|
||||
// will be 36 * 86400 * 1000 = 3_110_400_000, which is larger than
|
||||
// the maximum value that `setTimeout` accepts as an argument: 2_147_483_647.
|
||||
//
|
||||
// To make the `monotonicTime()` a reasonable value, we anchor
|
||||
// it to the time of the first import of this utility.
|
||||
const initialTime = process.hrtime();
|
||||
|
||||
export function monotonicTime(): number {
|
||||
const [seconds, nanoseconds] = process.hrtime(initialTime);
|
||||
return seconds * 1000 + (nanoseconds / 1000 | 0) / 1000;
|
||||
}
|
||||
|
|
@ -14,7 +14,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { URLSearchParams } from 'url';
|
||||
import type { SnapshotRenderer } from './snapshotRenderer';
|
||||
import type { SnapshotStorage } from './snapshotStorage';
|
||||
import type { ResourceSnapshot } from '@trace/snapshot';
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { MultiMap } from '../../packages/playwright-core/lib/utils/multimap';
|
||||
import { MultiMap } from '../../packages/playwright-core/lib/utils/isomorphic/multimap';
|
||||
import { test, expect } from './pageTest';
|
||||
|
||||
function leakedJSHandles(): string {
|
||||
|
|
|
|||
Loading…
Reference in a new issue