chore: move registry & dispatchers to under server (#13370)

This commit is contained in:
Pavel Feldman 2022-04-06 21:21:27 -08:00 committed by GitHub
parent 32d30ae71d
commit bde7bf4ea9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 172 additions and 172 deletions

View File

@ -17,7 +17,7 @@
let install;
try {
install = require('playwright-core/lib/utils/registry').installBrowsersForNpmInstall;
install = require('playwright-core/lib/server').registry.installBrowsersForNpmInstall;
} catch (e) {
// Dev build, don't install browsers by default.
}

View File

@ -27,11 +27,11 @@
"./lib/utils/httpServer": "./lib/utils/httpServer.js",
"./lib/utils/multimap": "./lib/utils/multimap.js",
"./lib/utils/processLauncher": "./lib/utils/processLauncher.js",
"./lib/utils/registry": "./lib/utils/registry.js",
"./lib/utils/utils": "./lib/utils/utils.js",
"./lib/utils/stackTrace": "./lib/utils/stackTrace.js",
"./lib/remote/playwrightServer": "./lib/remote/playwrightServer.js",
"./lib/remote/playwrightClient": "./lib/remote/playwrightClient.js"
"./lib/remote/playwrightClient": "./lib/remote/playwrightClient.js",
"./lib/server": "./lib/server/index.js"
},
"types": "types/types.d.ts",
"bin": {

View File

@ -10,6 +10,7 @@
[cli.ts]
../server/trace/viewer/traceViewer.ts
../server/
[driver.ts]
../**

View File

@ -32,13 +32,12 @@ import type { Page } from '../client/page';
import type { BrowserType } from '../client/browserType';
import type { BrowserContextOptions, LaunchOptions } from '../client/types';
import { spawn } from 'child_process';
import type { Executable } from '../utils/registry';
import { registry } from '../utils/registry';
import { spawnAsync, getPlaywrightVersion, wrapInASCIIBox } from '../utils/utils';
import { writeDockerVersion } from '../utils/dependencies';
import { launchGridAgent } from '../grid/gridAgent';
import type { GridFactory } from '../grid/gridServer';
import { GridServer } from '../grid/gridServer';
import type { Executable } from '../server';
import { registry, writeDockerVersion } from '../server';
const packageJSON = require('../../package.json');

View File

@ -20,11 +20,9 @@ import fs from 'fs';
import * as playwright from '../..';
import type { BrowserType } from '../client/browserType';
import type { LaunchServerOptions } from '../client/types';
import { DispatcherConnection, Root } from '../dispatchers/dispatcher';
import { PlaywrightDispatcher } from '../dispatchers/playwrightDispatcher';
import { createPlaywright, DispatcherConnection, Root, PlaywrightDispatcher } from '../server';
import { IpcTransport, PipeTransport } from '../protocol/transport';
import { PlaywrightServer } from '../remote/playwrightServer';
import { createPlaywright } from '../server/playwright';
import { gracefullyCloseAll } from '../utils/processLauncher';
export function printApiJson() {

View File

@ -1,4 +0,0 @@
[*]
../protocol/
../server/**
../utils/

View File

@ -16,9 +16,7 @@
import WebSocket from 'ws';
import debug from 'debug';
import { DispatcherConnection, Root } from '../dispatchers/dispatcher';
import { PlaywrightDispatcher } from '../dispatchers/playwrightDispatcher';
import { createPlaywright } from '../server/playwright';
import { createPlaywright, PlaywrightDispatcher, DispatcherConnection, Root } from '../server';
import { gracefullyCloseAll } from '../utils/processLauncher';
import { SocksProxy } from '../utils/socksProxy';

View File

@ -14,10 +14,8 @@
* limitations under the License.
*/
import { DispatcherConnection, Root } from './dispatchers/dispatcher';
import { createPlaywright } from './server/playwright';
import type { Playwright as PlaywrightAPI } from './client/playwright';
import { PlaywrightDispatcher } from './dispatchers/playwrightDispatcher';
import { createPlaywright, DispatcherConnection, Root, PlaywrightDispatcher } from './server';
import { Connection } from './client/connection';
import { BrowserServerLauncherImpl } from './browserServerImpl';

View File

@ -15,15 +15,12 @@
*/
import type WebSocket from 'ws';
import type { DispatcherScope } from '../dispatchers/dispatcher';
import { DispatcherConnection, Root } from '../dispatchers/dispatcher';
import { PlaywrightDispatcher } from '../dispatchers/playwrightDispatcher';
import type { Playwright, DispatcherScope } from '../server';
import { createPlaywright, DispatcherConnection, Root, PlaywrightDispatcher } from '../server';
import { Browser } from '../server/browser';
import { serverSideCallMetadata } from '../server/instrumentation';
import type { Playwright } from '../server/playwright';
import { createPlaywright } from '../server/playwright';
import { gracefullyCloseAll } from '../utils/processLauncher';
import { registry } from '../utils/registry';
import { registry } from '../server';
import { SocksProxy } from '../utils/socksProxy';
export class PlaywrightConnection {

View File

@ -19,8 +19,8 @@ import * as os from 'os';
import path from 'path';
import type { BrowserContext } from './browserContext';
import { normalizeProxySettings, validateBrowserContextOptions } from './browserContext';
import type { BrowserName } from '../utils/registry';
import { registry } from '../utils/registry';
import type { BrowserName } from './registry';
import { registry } from './registry';
import type { ConnectionTransport } from './transport';
import { WebSocketTransport } from './transport';
import type { BrowserOptions, Browser, BrowserProcess, PlaywrightOptions } from './browser';

View File

@ -40,7 +40,7 @@ import { helper } from '../helper';
import type { CallMetadata } from '../instrumentation';
import http from 'http';
import https from 'https';
import { registry } from '../../utils/registry';
import { registry } from '../registry';
import { ManualPromise } from '../../utils/async';
const ARTIFACTS_FOLDER = path.join(os.tmpdir(), 'playwright-artifacts-');

View File

@ -18,7 +18,7 @@
import path from 'path';
import type { RegisteredListener } from '../../utils/eventsHelper';
import { eventsHelper } from '../../utils/eventsHelper';
import { registry } from '../../utils/registry';
import { registry } from '../registry';
import { rewriteErrorMessage } from '../../utils/stackTrace';
import { assert, createGuid, headersArrayToObject } from '../../utils/utils';
import * as dialog from '../dialog';

View File

@ -0,0 +1,4 @@
[*]
../../protocol/
../../utils/
../**

View File

@ -16,11 +16,11 @@
import type { DispatcherScope } from './dispatcher';
import { Dispatcher, existingDispatcher } from './dispatcher';
import type { Android, SocketBackend } from '../server/android/android';
import { AndroidDevice } from '../server/android/android';
import type * as channels from '../protocol/channels';
import type { Android, SocketBackend } from '../android/android';
import { AndroidDevice } from '../android/android';
import type * as channels from '../../protocol/channels';
import { BrowserContextDispatcher } from './browserContextDispatcher';
import type { CallMetadata } from '../server/instrumentation';
import type { CallMetadata } from '../instrumentation';
export class AndroidDispatcher extends Dispatcher<Android, channels.AndroidChannel> implements channels.AndroidChannel {
_type_Android = true;

View File

@ -14,13 +14,13 @@
* limitations under the License.
*/
import type * as channels from '../protocol/channels';
import type * as channels from '../../protocol/channels';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher } from './dispatcher';
import { StreamDispatcher } from './streamDispatcher';
import fs from 'fs';
import { mkdirIfNeeded } from '../utils/utils';
import type { Artifact } from '../server/artifact';
import { mkdirIfNeeded } from '../../utils/utils';
import type { Artifact } from '../artifact';
export class ArtifactDispatcher extends Dispatcher<Artifact, channels.ArtifactChannel> implements channels.ArtifactChannel {
_type_Artifact = true;

View File

@ -14,24 +14,24 @@
* limitations under the License.
*/
import { BrowserContext } from '../server/browserContext';
import { BrowserContext } from '../browserContext';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher, lookupDispatcher } from './dispatcher';
import { PageDispatcher, BindingCallDispatcher, WorkerDispatcher } from './pageDispatcher';
import type { FrameDispatcher } from './frameDispatcher';
import type * as channels from '../protocol/channels';
import type * as channels from '../../protocol/channels';
import { RouteDispatcher, RequestDispatcher, ResponseDispatcher, APIRequestContextDispatcher } from './networkDispatchers';
import { CRBrowserContext } from '../server/chromium/crBrowser';
import { CRBrowserContext } from '../chromium/crBrowser';
import { CDPSessionDispatcher } from './cdpSessionDispatcher';
import { RecorderSupplement } from '../server/supplements/recorderSupplement';
import type { CallMetadata } from '../server/instrumentation';
import { RecorderSupplement } from '../supplements/recorderSupplement';
import type { CallMetadata } from '../instrumentation';
import { ArtifactDispatcher } from './artifactDispatcher';
import type { Artifact } from '../server/artifact';
import type { Request, Response } from '../server/network';
import type { Artifact } from '../artifact';
import type { Request, Response } from '../network';
import { TracingDispatcher } from './tracingDispatcher';
import * as fs from 'fs';
import * as path from 'path';
import { createGuid } from '../utils/utils';
import { createGuid } from '../../utils/utils';
import { WritableStreamDispatcher } from './writableStreamDispatcher';
export class BrowserContextDispatcher extends Dispatcher<BrowserContext, channels.BrowserContextChannel> implements channels.BrowserContextChannel {

View File

@ -14,18 +14,18 @@
* limitations under the License.
*/
import { Browser } from '../server/browser';
import type * as channels from '../protocol/channels';
import { Browser } from '../browser';
import type * as channels from '../../protocol/channels';
import { BrowserContextDispatcher } from './browserContextDispatcher';
import { CDPSessionDispatcher } from './cdpSessionDispatcher';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher } from './dispatcher';
import type { CRBrowser } from '../server/chromium/crBrowser';
import type { CRBrowser } from '../chromium/crBrowser';
import type { PageDispatcher } from './pageDispatcher';
import type { CallMetadata } from '../server/instrumentation';
import { serverSideCallMetadata } from '../server/instrumentation';
import { BrowserContext } from '../server/browserContext';
import { Selectors } from '../server/selectors';
import type { CallMetadata } from '../instrumentation';
import { serverSideCallMetadata } from '../instrumentation';
import { BrowserContext } from '../browserContext';
import { Selectors } from '../selectors';
export class BrowserDispatcher extends Dispatcher<Browser, channels.BrowserChannel> implements channels.BrowserChannel {
_type_Browser = true;

View File

@ -14,19 +14,19 @@
* limitations under the License.
*/
import type { BrowserType } from '../server/browserType';
import type { BrowserType } from '../browserType';
import { BrowserDispatcher } from './browserDispatcher';
import type * as channels from '../protocol/channels';
import type * as channels from '../../protocol/channels';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher } from './dispatcher';
import { BrowserContextDispatcher } from './browserContextDispatcher';
import type { CallMetadata } from '../server/instrumentation';
import type { CallMetadata } from '../instrumentation';
import { JsonPipeDispatcher } from '../dispatchers/jsonPipeDispatcher';
import { getUserAgent } from '../utils/utils';
import * as socks from '../utils/socksProxy';
import { getUserAgent } from '../../utils/utils';
import * as socks from '../../utils/socksProxy';
import EventEmitter from 'events';
import { ProgressController } from '../server/progress';
import { WebSocketTransport } from '../server/transport';
import { ProgressController } from '../progress';
import { WebSocketTransport } from '../transport';
export class BrowserTypeDispatcher extends Dispatcher<BrowserType, channels.BrowserTypeChannel> implements channels.BrowserTypeChannel {
_type_BrowserType = true;

View File

@ -14,9 +14,9 @@
* limitations under the License.
*/
import type { CRSession } from '../server/chromium/crConnection';
import { CRSessionEvents } from '../server/chromium/crConnection';
import type * as channels from '../protocol/channels';
import type { CRSession } from '../chromium/crConnection';
import { CRSessionEvents } from '../chromium/crConnection';
import type * as channels from '../../protocol/channels';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher } from './dispatcher';

View File

@ -14,8 +14,8 @@
* limitations under the License.
*/
import type { ConsoleMessage } from '../server/console';
import type * as channels from '../protocol/channels';
import type { ConsoleMessage } from '../console';
import type * as channels from '../../protocol/channels';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher } from './dispatcher';
import { ElementHandleDispatcher } from './elementHandlerDispatcher';

View File

@ -14,8 +14,8 @@
* limitations under the License.
*/
import type { Dialog } from '../server/dialog';
import type * as channels from '../protocol/channels';
import type { Dialog } from '../dialog';
import type * as channels from '../../protocol/channels';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher } from './dispatcher';

View File

@ -15,16 +15,16 @@
*/
import { EventEmitter } from 'events';
import type * as channels from '../protocol/channels';
import { serializeError } from '../protocol/serializers';
import type { Validator } from '../protocol/validator';
import { createScheme, ValidationError } from '../protocol/validator';
import { assert, debugAssert, isUnderTest, monotonicTime } from '../utils/utils';
import { tOptional } from '../protocol/validatorPrimitives';
import { kBrowserOrContextClosedError } from '../utils/errors';
import type { CallMetadata } from '../server/instrumentation';
import { SdkObject } from '../server/instrumentation';
import { rewriteErrorMessage } from '../utils/stackTrace';
import type * as channels from '../../protocol/channels';
import { serializeError } from '../../protocol/serializers';
import type { Validator } from '../../protocol/validator';
import { createScheme, ValidationError } from '../../protocol/validator';
import { assert, debugAssert, isUnderTest, monotonicTime } from '../../utils/utils';
import { tOptional } from '../../protocol/validatorPrimitives';
import { kBrowserOrContextClosedError } from '../../utils/errors';
import type { CallMetadata } from '../instrumentation';
import { SdkObject } from '../instrumentation';
import { rewriteErrorMessage } from '../../utils/stackTrace';
import type { PlaywrightDispatcher } from './playwrightDispatcher';
export const dispatcherSymbol = Symbol('dispatcher');

View File

@ -16,9 +16,9 @@
import type { DispatcherScope } from './dispatcher';
import { Dispatcher } from './dispatcher';
import type { Electron } from '../server/electron/electron';
import { ElectronApplication } from '../server/electron/electron';
import type * as channels from '../protocol/channels';
import type { Electron } from '../electron/electron';
import { ElectronApplication } from '../electron/electron';
import type * as channels from '../../protocol/channels';
import { BrowserContextDispatcher } from './browserContextDispatcher';
import type { PageDispatcher } from './pageDispatcher';
import { parseArgument, serializeResult } from './jsHandleDispatcher';

View File

@ -14,15 +14,15 @@
* limitations under the License.
*/
import type { ElementHandle } from '../server/dom';
import type { Frame } from '../server/frames';
import type * as js from '../server/javascript';
import type * as channels from '../protocol/channels';
import type { ElementHandle } from '../dom';
import type { Frame } from '../frames';
import type * as js from '../javascript';
import type * as channels from '../../protocol/channels';
import type { DispatcherScope } from './dispatcher';
import { existingDispatcher, lookupNullableDispatcher } from './dispatcher';
import { JSHandleDispatcher, serializeResult, parseArgument } from './jsHandleDispatcher';
import type { FrameDispatcher } from './frameDispatcher';
import type { CallMetadata } from '../server/instrumentation';
import type { CallMetadata } from '../instrumentation';
import type { WritableStreamDispatcher } from './writableStreamDispatcher';
export class ElementHandleDispatcher extends JSHandleDispatcher implements channels.ElementHandleChannel {

View File

@ -14,16 +14,16 @@
* limitations under the License.
*/
import type { NavigationEvent } from '../server/frames';
import { Frame } from '../server/frames';
import type * as channels from '../protocol/channels';
import type { NavigationEvent } from '../frames';
import { Frame } from '../frames';
import type * as channels from '../../protocol/channels';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher, lookupNullableDispatcher, existingDispatcher } from './dispatcher';
import { ElementHandleDispatcher } from './elementHandlerDispatcher';
import { parseArgument, serializeResult } from './jsHandleDispatcher';
import type { ResponseDispatcher } from './networkDispatchers';
import { RequestDispatcher } from './networkDispatchers';
import type { CallMetadata } from '../server/instrumentation';
import type { CallMetadata } from '../instrumentation';
import type { WritableStreamDispatcher } from './writableStreamDispatcher';
export class FrameDispatcher extends Dispatcher<Frame, channels.FrameChannel> implements channels.FrameChannel {

View File

@ -14,12 +14,12 @@
* limitations under the License.
*/
import type * as js from '../server/javascript';
import type * as channels from '../protocol/channels';
import type * as js from '../javascript';
import type * as channels from '../../protocol/channels';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher } from './dispatcher';
import { ElementHandleDispatcher } from './elementHandlerDispatcher';
import { parseSerializedValue, serializeValue } from '../protocol/serializers';
import { parseSerializedValue, serializeValue } from '../../protocol/serializers';
export class JSHandleDispatcher extends Dispatcher<js.JSHandle, channels.JSHandleChannel> implements channels.JSHandleChannel {
_type_JSHandle = true;

View File

@ -14,11 +14,11 @@
* limitations under the License.
*/
import type * as channels from '../protocol/channels';
import type * as channels from '../../protocol/channels';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher } from './dispatcher';
import { createGuid } from '../utils/utils';
import { serializeError } from '../protocol/serializers';
import { createGuid } from '../../utils/utils';
import { serializeError } from '../../protocol/serializers';
export class JsonPipeDispatcher extends Dispatcher<{ guid: string }, channels.JsonPipeChannel> implements channels.JsonPipeChannel {
_type_JsonPipe = true;

View File

@ -19,9 +19,9 @@ import fs from 'fs';
import path from 'path';
import yauzl from 'yauzl';
import yazl from 'yazl';
import type * as channels from '../protocol/channels';
import { ManualPromise } from '../utils/async';
import { assert, createGuid } from '../utils/utils';
import type * as channels from '../../protocol/channels';
import { ManualPromise } from '../../utils/async';
import { assert, createGuid } from '../../utils/utils';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher } from './dispatcher';

View File

@ -14,11 +14,11 @@
* limitations under the License.
*/
import type * as channels from '../protocol/channels';
import { APIRequestContext } from '../server/fetch';
import type { CallMetadata } from '../server/instrumentation';
import type { Request, Response, Route } from '../server/network';
import { WebSocket } from '../server/network';
import type * as channels from '../../protocol/channels';
import { APIRequestContext } from '../fetch';
import type { CallMetadata } from '../instrumentation';
import type { Request, Response, Route } from '../network';
import { WebSocket } from '../network';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher, existingDispatcher, lookupNullableDispatcher } from './dispatcher';
import { FrameDispatcher } from './frameDispatcher';

View File

@ -14,13 +14,13 @@
* limitations under the License.
*/
import type { BrowserContext } from '../server/browserContext';
import type { Frame } from '../server/frames';
import { Page, Worker } from '../server/page';
import type * as channels from '../protocol/channels';
import type { BrowserContext } from '../browserContext';
import type { Frame } from '../frames';
import { Page, Worker } from '../page';
import type * as channels from '../../protocol/channels';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher, existingDispatcher, lookupDispatcher, lookupNullableDispatcher } from './dispatcher';
import { parseError, serializeError } from '../protocol/serializers';
import { parseError, serializeError } from '../../protocol/serializers';
import { ConsoleMessageDispatcher } from './consoleMessageDispatcher';
import { DialogDispatcher } from './dialogDispatcher';
import { FrameDispatcher } from './frameDispatcher';
@ -28,14 +28,14 @@ import type { ResponseDispatcher } from './networkDispatchers';
import { RequestDispatcher, RouteDispatcher, WebSocketDispatcher } from './networkDispatchers';
import { serializeResult, parseArgument } from './jsHandleDispatcher';
import { ElementHandleDispatcher } from './elementHandlerDispatcher';
import type { FileChooser } from '../server/fileChooser';
import type { CRCoverage } from '../server/chromium/crCoverage';
import type { JSHandle } from '../server/javascript';
import type { CallMetadata } from '../server/instrumentation';
import type { Artifact } from '../server/artifact';
import type { FileChooser } from '../fileChooser';
import type { CRCoverage } from '../chromium/crCoverage';
import type { JSHandle } from '../javascript';
import type { CallMetadata } from '../instrumentation';
import type { Artifact } from '../artifact';
import { ArtifactDispatcher } from './artifactDispatcher';
import type { Download } from '../server/download';
import { createGuid } from '../utils/utils';
import type { Download } from '../download';
import { createGuid } from '../../utils/utils';
export class PageDispatcher extends Dispatcher<Page, channels.PageChannel> implements channels.PageChannel {
_type_EventTarget = true;

View File

@ -14,13 +14,13 @@
* limitations under the License.
*/
import type * as channels from '../protocol/channels';
import type { Browser } from '../server/browser';
import { GlobalAPIRequestContext } from '../server/fetch';
import type { Playwright } from '../server/playwright';
import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from '../utils/socksProxy';
import { SocksProxy } from '../utils/socksProxy';
import type * as types from '../server/types';
import type * as channels from '../../protocol/channels';
import type { Browser } from '../browser';
import { GlobalAPIRequestContext } from '../fetch';
import type { Playwright } from '../playwright';
import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from '../../utils/socksProxy';
import { SocksProxy } from '../../utils/socksProxy';
import type * as types from '../types';
import { AndroidDispatcher } from './androidDispatcher';
import { BrowserTypeDispatcher } from './browserTypeDispatcher';
import type { DispatcherScope } from './dispatcher';
@ -30,14 +30,14 @@ import { LocalUtilsDispatcher } from './localUtilsDispatcher';
import { APIRequestContextDispatcher } from './networkDispatchers';
import { SelectorsDispatcher } from './selectorsDispatcher';
import { ConnectedBrowserDispatcher } from './browserDispatcher';
import { createGuid } from '../utils/utils';
import { createGuid } from '../../utils/utils';
export class PlaywrightDispatcher extends Dispatcher<Playwright, channels.PlaywrightChannel> implements channels.PlaywrightChannel {
_type_Playwright;
private _browserDispatcher: ConnectedBrowserDispatcher | undefined;
constructor(scope: DispatcherScope, playwright: Playwright, socksProxy?: SocksProxy, preLaunchedBrowser?: Browser) {
const descriptors = require('../server/deviceDescriptors') as types.Devices;
const descriptors = require('../deviceDescriptors') as types.Devices;
const deviceDescriptors = Object.entries(descriptors)
.map(([name, descriptor]) => ({ name, descriptor }));
const browserDispatcher = preLaunchedBrowser ? new ConnectedBrowserDispatcher(scope, preLaunchedBrowser) : undefined;

View File

@ -16,8 +16,8 @@
import type { DispatcherScope } from './dispatcher';
import { Dispatcher } from './dispatcher';
import type * as channels from '../protocol/channels';
import type { Selectors } from '../server/selectors';
import type * as channels from '../../protocol/channels';
import type { Selectors } from '../selectors';
export class SelectorsDispatcher extends Dispatcher<Selectors, channels.SelectorsChannel> implements channels.SelectorsChannel {
_type_Selectors = true;

View File

@ -14,11 +14,11 @@
* limitations under the License.
*/
import type * as channels from '../protocol/channels';
import type * as channels from '../../protocol/channels';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher } from './dispatcher';
import type * as stream from 'stream';
import { createGuid } from '../utils/utils';
import { createGuid } from '../../utils/utils';
export class StreamDispatcher extends Dispatcher<{ guid: string, stream: stream.Readable }, channels.StreamChannel> implements channels.StreamChannel {
_type_Stream = true;

View File

@ -14,8 +14,8 @@
* limitations under the License.
*/
import type * as channels from '../protocol/channels';
import { Tracing } from '../server/trace/recorder/tracing';
import type * as channels from '../../protocol/channels';
import { Tracing } from '../trace/recorder/tracing';
import { ArtifactDispatcher } from './artifactDispatcher';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher, existingDispatcher } from './dispatcher';

View File

@ -14,11 +14,11 @@
* limitations under the License.
*/
import type * as channels from '../protocol/channels';
import type * as channels from '../../protocol/channels';
import type { DispatcherScope } from './dispatcher';
import { Dispatcher } from './dispatcher';
import type * as fs from 'fs';
import { createGuid } from '../utils/utils';
import { createGuid } from '../../utils/utils';
export class WritableStreamDispatcher extends Dispatcher<{ guid: string, stream: fs.WriteStream }, channels.WritableStreamChannel> implements channels.WritableStreamChannel {
_type_WritableStream = true;

View File

@ -0,0 +1,25 @@
/**
* 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 type { Executable } from './registry';
export { registry, writeDockerVersion, Registry, registryDirectory } from './registry';
export { DispatcherConnection, Root } from './dispatchers/dispatcher';
export { PlaywrightDispatcher } from './dispatchers/playwrightDispatcher';
export { createPlaywright } from './playwright';
export type { DispatcherScope } from './dispatchers/dispatcher';
export type { Playwright } from './playwright';

View File

@ -19,8 +19,8 @@ import extract from 'extract-zip';
import fs from 'fs';
import os from 'os';
import path from 'path';
import { existsAsync, download, getUserAgent } from './utils';
import { debugLogger } from './debugLogger';
import { existsAsync, download, getUserAgent } from '../../utils/utils';
import { debugLogger } from '../../utils/debugLogger';
export async function downloadBrowserWithProgressBar(title: string, browserDirectory: string, executablePath: string, downloadURL: string, downloadFileName: string): Promise<boolean> {
const progressBarName = `Playwright build of ${title}`;

View File

@ -18,13 +18,13 @@ import fs from 'fs';
import path from 'path';
import * as os from 'os';
import childProcess from 'child_process';
import * as utils from './utils';
import { buildPlaywrightCLICommand } from './registry';
import * as utils from '../../utils/utils';
import { buildPlaywrightCLICommand } from '.';
import { deps } from './nativeDeps';
import { getUbuntuVersion } from './ubuntuVersion';
import { getUbuntuVersion } from '../../utils/ubuntuVersion';
const BIN_DIRECTORY = path.join(__dirname, '..', '..', 'bin');
const packageJSON = require('../../package.json');
const BIN_DIRECTORY = path.join(__dirname, '..', '..', '..', 'bin');
const packageJSON = require('../../../package.json');
const dockerVersionFilePath = '/ms-playwright/.docker-info';
export async function writeDockerVersion(dockerImageNameTemplate: string) {
@ -284,7 +284,7 @@ async function executablesOrSharedLibraries(directoryPath: string): Promise<stri
}
async function missingFileDependenciesWindows(filePath: string): Promise<Array<string>> {
const executable = path.join(__dirname, '..', '..', 'bin', 'PrintDeps.exe');
const executable = path.join(__dirname, '..', '..', '..', 'bin', 'PrintDeps.exe');
const dirname = path.dirname(filePath);
const { stdout, code } = await utils.spawnAsync(executable, [filePath], {
cwd: dirname,

View File

@ -20,14 +20,15 @@ import path from 'path';
import * as util from 'util';
import * as fs from 'fs';
import lockfile from 'proper-lockfile';
import { getUbuntuVersion } from './ubuntuVersion';
import { getFromENV, getAsBooleanFromENV, getClientLanguage, calculateSha1, removeFolders, existsAsync, hostPlatform, canAccessFile, spawnAsync, fetchData, wrapInASCIIBox, transformCommandsForRoot } from './utils';
import { getUbuntuVersion } from '../../utils/ubuntuVersion';
import { getFromENV, getAsBooleanFromENV, getClientLanguage, calculateSha1, removeFolders, existsAsync, hostPlatform, canAccessFile, spawnAsync, fetchData, wrapInASCIIBox, transformCommandsForRoot } from '../../utils/utils';
import type { DependencyGroup } from './dependencies';
import { installDependenciesLinux, installDependenciesWindows, validateDependenciesLinux, validateDependenciesWindows } from './dependencies';
import { downloadBrowserWithProgressBar, logPolitely } from './browserFetcher';
export { writeDockerVersion } from './dependencies';
const PACKAGE_PATH = path.join(__dirname, '..', '..');
const BIN_PATH = path.join(__dirname, '..', '..', 'bin');
const PACKAGE_PATH = path.join(__dirname, '..', '..', '..');
const BIN_PATH = path.join(__dirname, '..', '..', '..', 'bin');
const EXECUTABLE_PATHS = {
'chromium': {
@ -162,7 +163,7 @@ export const registryDirectory = (() => {
const envDefined = getFromENV('PLAYWRIGHT_BROWSERS_PATH');
if (envDefined === '0') {
result = path.join(__dirname, '..', '..', '.local-browsers');
result = path.join(__dirname, '..', '..', '..', '.local-browsers');
} else if (envDefined) {
result = envDefined;
} else {
@ -820,4 +821,4 @@ export function findChromiumChannel(sdkLanguage: string): string | undefined {
return channel;
}
export const registry = new Registry(require('../../browsers.json'));
export const registry = new Registry(require('../../../browsers.json'));

View File

@ -24,7 +24,7 @@ import type { CallLog, EventData, Mode, Source } from './recorderTypes';
import { isUnderTest } from '../../../utils/utils';
import * as mime from 'mime';
import { installAppIcon } from '../../chromium/crApp';
import { findChromiumChannel } from '../../../utils/registry';
import { findChromiumChannel } from '../../registry';
declare global {
interface Window {

View File

@ -18,7 +18,7 @@ import path from 'path';
import fs from 'fs';
import * as consoleApiSource from '../../../generated/consoleApiSource';
import { HttpServer } from '../../../utils/httpServer';
import { findChromiumChannel } from '../../../utils/registry';
import { findChromiumChannel } from '../../registry';
import { isUnderTest } from '../../../utils/utils';
import type { BrowserContext } from '../../browserContext';
import { installAppIcon } from '../../chromium/crApp';

View File

@ -20,7 +20,6 @@ import path from 'path';
import { Server as WebSocketServer } from 'ws';
import * as mime from 'mime';
import { assert } from './utils';
import type { VirtualFileSystem } from './vfs';
export type ServerRouteHandler = (request: http.IncomingMessage, response: http.ServerResponse) => boolean;
@ -151,22 +150,6 @@ export class HttpServer {
readable.pipe(response);
}
async serveVirtualFile(response: http.ServerResponse, vfs: VirtualFileSystem, entry: string, headers?: { [name: string]: string }) {
try {
const content = await vfs.read(entry);
response.statusCode = 200;
const contentType = mime.getType(path.extname(entry)) || 'application/octet-stream';
response.setHeader('Content-Type', contentType);
response.setHeader('Content-Length', content.byteLength);
for (const [name, value] of Object.entries(headers || {}))
response.setHeader(name, value);
response.end(content);
return true;
} catch (e) {
return false;
}
}
private _onRequest(request: http.IncomingMessage, response: http.ServerResponse) {
response.setHeader('Access-Control-Allow-Origin', '*');
response.setHeader('Access-Control-Request-Method', '*');

View File

@ -17,7 +17,7 @@
let install;
try {
install = require('playwright-core/lib/utils/registry').installBrowsersForNpmInstall;
install = require('playwright-core/lib/server').registry.installBrowsersForNpmInstall;
} catch (e) {
// Dev build, don't install browsers by default.
}

View File

@ -17,7 +17,7 @@
let install;
try {
install = require('playwright-core/lib/utils/registry').installBrowsersForNpmInstall;
install = require('playwright-core/lib/server').registry.installBrowsersForNpmInstall;
} catch (e) {
// Dev build, don't install browsers by default.
}

View File

@ -17,7 +17,7 @@
let install;
try {
install = require('playwright-core/lib/utils/registry').installDefaultBrowsersForNpmInstall;
install = require('playwright-core/lib/server').registry.installDefaultBrowsersForNpmInstall;
} catch (e) {
// Dev build, don't install browsers by default.
}

View File

@ -16,7 +16,7 @@
import { expect } from '@playwright/test';
import type { Frame, Page } from 'playwright-core';
import { ZipFileSystem } from '../../packages/playwright-core/lib/utils/vfs';
import { ZipFileSystem } from './vfs';
export async function attachFrame(page: Page, frameId: string, url: string): Promise<Frame> {
const handle = await page.evaluateHandle(async ({ frameId, url }) => {

View File

@ -19,7 +19,7 @@ import fs from 'fs';
import path from 'path';
import { spawnSync } from 'child_process';
import { PNG } from 'pngjs';
import { registry } from '../../packages/playwright-core/lib/utils/registry';
import { registry } from '../../packages/playwright-core/lib/server';
const ffmpeg = registry.findExecutable('ffmpeg')!.executablePath('javascript');

View File

@ -18,7 +18,7 @@ import { test, expect, stripAnsi } from './playwright-test-fixtures';
import fs from 'fs';
import path from 'path';
import { spawnSync } from 'child_process';
import { registry } from '../../packages/playwright-core/lib/utils/registry';
import { registry } from '../../packages/playwright-core/lib/server';
const ffmpeg = registry.findExecutable('ffmpeg')!.executablePath();

View File

@ -15,7 +15,7 @@
*/
import { test, expect } from './playwright-test-fixtures';
import { ZipFileSystem } from '../../packages/playwright-core/lib/utils/vfs';
import { ZipFileSystem } from '../config/vfs';
import fs from 'fs';
test('should stop tracing with trace: on-first-retry, when not retrying', async ({ runInlineTest }, testInfo) => {

View File

@ -4,7 +4,7 @@ const fs = require('fs');
const util = require('util');
const path = require('path');
const {spawn} = require('child_process');
const {registryDirectory} = require('playwright-core/lib/utils/registry');
const {registryDirectory} = require('playwright-core/lib/server');
const readdirAsync = util.promisify(fs.readdir.bind(fs));
const readFileAsync = util.promisify(fs.readFile.bind(fs));

View File

@ -17,7 +17,7 @@
*/
const path = require('path');
const {Registry} = require('../packages/playwright-core/lib/utils/registry');
const { Registry } = require('../packages/playwright-core/lib/server');
const fs = require('fs');
const protocolGenerator = require('./protocol-types-generator');
const {execSync} = require('child_process');