chore: move utils that are user in server to server/utils (2) (#34736)

This commit is contained in:
Pavel Feldman 2025-02-11 17:19:27 -08:00 committed by GitHub
parent 25a168fae5
commit bd74fc4964
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
61 changed files with 171 additions and 185 deletions

View File

@ -31,7 +31,7 @@
"./lib/server/utils/image_tools/imageChannel": "./lib/server/utils/image_tools/imageChannel.js",
"./lib/server/utils/image_tools/colorUtils": "./lib/server/utils/image_tools/colorUtils.js",
"./lib/server/registry/index": "./lib/server/registry/index.js",
"./lib/utils": "./lib/utils/index.js",
"./lib/utils": "./lib/utils.js",
"./lib/utilsBundle": "./lib/utilsBundle.js",
"./lib/zipBundle": "./lib/zipBundle.js",
"./types/protocol": "./types/protocol.d.ts",

View File

@ -15,7 +15,7 @@
*/
import { envObjectToArray } from './client/clientHelper';
import { SocksProxy } from './common/socksProxy';
import { SocksProxy } from './server/utils/socksProxy';
import { PlaywrightServer } from './remote/playwrightServer';
import { helper } from './server/helper';
import { serverSideCallMetadata } from './server/instrumentation';

View File

@ -23,7 +23,8 @@ import * as path from 'path';
import * as playwright from '../..';
import { launchBrowserServer, printApiJson, runDriver, runServer } from './driver';
import { isTargetClosedError } from '../client/errors';
import { gracefullyProcessExitDoNotHang, registry, writeDockerVersion } from '../server';
import { registry, writeDockerVersion } from '../server';
import { gracefullyProcessExitDoNotHang } from '../utils';
import { runTraceInBrowser, runTraceViewerApp } from '../server/trace/viewer/traceViewer';
import { assert, getPackageManagerExecCommand, isLikelyNpxGlobal } from '../utils';
import { wrapInASCIIBox } from '../server/utils/ascii';

View File

@ -16,7 +16,7 @@
/* eslint-disable no-console */
import { gracefullyProcessExitDoNotHang } from '../server';
import { gracefullyProcessExitDoNotHang } from '../server/utils/processLauncher';
import { getPackageManager } from '../utils';
import { program } from './program';
export { program } from './program';

View File

@ -14,14 +14,14 @@
* limitations under the License.
*/
import { SocksProxy } from '../common/socksProxy';
import { SocksProxy } from '../server/utils/socksProxy';
import { DispatcherConnection, PlaywrightDispatcher, RootDispatcher, createPlaywright } from '../server';
import { AndroidDevice } from '../server/android/android';
import { Browser } from '../server/browser';
import { DebugControllerDispatcher } from '../server/dispatchers/debugControllerDispatcher';
import { serverSideCallMetadata } from '../server/instrumentation';
import { assert, isUnderTest } from '../utils';
import { startProfiling, stopProfiling } from '../utils';
import { startProfiling, stopProfiling } from '../server/utils/profiler';
import { monotonicTime } from '../utils';
import { debugLogger } from '../utils/debugLogger';

View File

@ -18,12 +18,12 @@ import { PlaywrightConnection } from './playwrightConnection';
import { createPlaywright } from '../server/playwright';
import { debugLogger } from '../utils/debugLogger';
import { Semaphore } from '../utils/semaphore';
import { WSServer } from '../utils/wsServer';
import { WSServer } from '../server/utils/wsServer';
import { wrapInASCIIBox } from '../server/utils/ascii';
import { getPlaywrightVersion } from '../utils/userAgent';
import type { ClientType } from './playwrightConnection';
import type { SocksProxy } from '../common/socksProxy';
import type { SocksProxy } from '../server/utils/socksProxy';
import type { AndroidDevice } from '../server/android/android';
import type { Browser } from '../server/browser';
import type { Playwright } from '../server/playwright';

View File

@ -27,7 +27,7 @@ import { debugMode, headersArrayToObject, headersObjectToArray, } from '../../ut
import { wrapInASCIIBox } from '../utils/ascii';
import { RecentLogsCollector } from '../../utils/debugLogger';
import { ManualPromise } from '../../utils/manualPromise';
import { fetchData } from '../../utils/network';
import { fetchData } from '../utils/network';
import { getUserAgent } from '../../utils/userAgent';
import { validateBrowserContextOptions } from '../browserContext';
import { BrowserType, kNoXServerRunningError } from '../browserType';
@ -41,7 +41,7 @@ import { removeFolders } from '../utils/fileUtils';
import { gracefullyCloseSet } from '../utils/processLauncher';
import { ProgressController } from '../progress';
import type { HTTPRequestParams } from '../../utils/network';
import type { HTTPRequestParams } from '../utils/network';
import type { BrowserOptions, BrowserProcess } from '../browser';
import type { CallMetadata, SdkObject } from '../instrumentation';
import type { Env } from '../utils/processLauncher';

View File

@ -21,15 +21,18 @@ import { nodePlatform } from '../../utils/platform';
import { getUserAgent } from '../../utils/userAgent';
import { deviceDescriptors as descriptors } from '../deviceDescriptors';
import { JsonPipeDispatcher } from '../dispatchers/jsonPipeDispatcher';
import { ProgressController } from '../progress';
import { Progress, ProgressController } from '../progress';
import { SocksInterceptor } from '../socksInterceptor';
import { WebSocketTransport } from '../transport';
import { fetchData } from '../utils/network';
import type { HarBackend } from '../../utils/harBackend';
import type { CallMetadata } from '../instrumentation';
import type { Playwright } from '../playwright';
import type { RootDispatcher } from './dispatcher';
import type * as channels from '@protocol/channels';
import type * as http from 'http';
import type { HTTPRequestParams } from '../utils/network';
export class LocalUtilsDispatcher extends Dispatcher<{ guid: string }, channels.LocalUtilsChannel, RootDispatcher> implements channels.LocalUtilsChannel {
_type_LocalUtils: boolean;
@ -87,7 +90,7 @@ export class LocalUtilsDispatcher extends Dispatcher<{ guid: string }, channels.
'x-playwright-proxy': params.exposeNetwork ?? '',
...params.headers,
};
const wsEndpoint = await localUtils.urlToWSEndpoint(progress, params.wsEndpoint);
const wsEndpoint = await urlToWSEndpoint(progress, params.wsEndpoint);
const transport = await WebSocketTransport.connect(progress, wsEndpoint, wsHeaders, true, 'x-playwright-debug-log');
const socksInterceptor = new SocksInterceptor(transport, params.exposeNetwork, params.socksProxyRedirectPortForTest);
@ -119,3 +122,34 @@ export class LocalUtilsDispatcher extends Dispatcher<{ guid: string }, channels.
}, params.timeout || 0);
}
}
async function urlToWSEndpoint(progress: Progress | undefined, endpointURL: string): Promise<string> {
if (endpointURL.startsWith('ws'))
return endpointURL;
progress?.log(`<ws preparing> retrieving websocket url from ${endpointURL}`);
const fetchUrl = new URL(endpointURL);
if (!fetchUrl.pathname.endsWith('/'))
fetchUrl.pathname += '/';
fetchUrl.pathname += 'json';
const json = await fetchData({
url: fetchUrl.toString(),
method: 'GET',
timeout: progress?.timeUntilDeadline() ?? 30_000,
headers: { 'User-Agent': getUserAgent() },
}, async (params: HTTPRequestParams, response: http.IncomingMessage) => {
return new Error(`Unexpected status ${response.statusCode} when connecting to ${fetchUrl.toString()}.\n` +
`This does not look like a Playwright server, try connecting via ws://.`);
});
progress?.throwIfAborted();
const wsUrl = new URL(endpointURL);
let wsEndpointPath = JSON.parse(json).wsEndpointPath;
if (wsEndpointPath.startsWith('/'))
wsEndpointPath = wsEndpointPath.substring(1);
if (!wsUrl.pathname.endsWith('/'))
wsUrl.pathname += '/';
wsUrl.pathname += wsEndpointPath;
wsUrl.protocol = wsUrl.protocol === 'https:' ? 'wss:' : 'ws:';
return wsUrl.toString();
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { SocksProxy } from '../../common/socksProxy';
import { SocksProxy } from '../utils/socksProxy';
import { GlobalAPIRequestContext } from '../fetch';
import { AndroidDispatcher } from './androidDispatcher';
import { AndroidDeviceDispatcher } from './androidDispatcher';
@ -29,7 +29,7 @@ import { createGuid } from '../../utils';
import { eventsHelper } from '../../utils/eventsHelper';
import type { RootDispatcher } from './dispatcher';
import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from '../../common/socksProxy';
import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from '../utils/socksProxy';
import type { RegisteredListener } from '../../utils/eventsHelper';
import type { AndroidDevice } from '../android/android';
import type { Browser } from '../browser';

View File

@ -31,7 +31,7 @@ import { MultipartFormData } from './formData';
import { SdkObject } from './instrumentation';
import { ProgressController } from './progress';
import { getMatchingTLSOptionsForOrigin, rewriteOpenSSLErrorIfNeeded } from './socksClientCertificatesInterceptor';
import { httpHappyEyeballsAgent, httpsHappyEyeballsAgent, timingForSocket } from '../utils/happy-eyeballs';
import { httpHappyEyeballsAgent, httpsHappyEyeballsAgent, timingForSocket } from './utils/happyEyeballs';
import { Tracing } from './trace/recorder/tracing';
import type { CallMetadata } from './instrumentation';

View File

@ -17,7 +17,8 @@
import * as fs from 'fs';
import * as path from 'path';
import { assert, fileUploadSizeLimit } from '../utils';
import { assert } from '../utils/debug';
import { fileUploadSizeLimit } from '../utils/fileUtils';
import { mime } from '../utilsBundle';
import type { WritableStreamDispatcher } from './dispatchers/writableStreamDispatcher';

View File

@ -30,8 +30,3 @@ export type { DispatcherScope } from './dispatchers/dispatcher';
export type { Playwright } from './playwright';
export { installRootRedirect, openTraceInBrowser, openTraceViewerApp, runTraceViewerApp, startTraceViewerServer } from './trace/viewer/traceViewer';
export { serverSideCallMetadata } from './instrumentation';
export { SocksProxy } from '../common/socksProxy';
export * from './utils/processLauncher';
export * from './utils/ascii';
export * from './utils/comparators';
export * from './utils/fileUtils';

View File

@ -22,7 +22,7 @@ import * as path from 'path';
import { deps } from './nativeDeps';
import { wrapInASCIIBox } from '../utils/ascii';
import { hostPlatform, isOfficiallySupportedPlatform } from '../../utils/hostPlatform';
import { spawnAsync } from '../../utils/spawnAsync';
import { spawnAsync } from '../utils/spawnAsync';
import { getPlaywrightVersion } from '../../utils/userAgent';
import { buildPlaywrightCLICommand, registry } from '.';

View File

@ -27,8 +27,8 @@ import { calculateSha1, getAsBooleanFromENV, getFromENV, getPackageManagerExecCo
import { wrapInASCIIBox } from '../utils/ascii';
import { debugLogger } from '../../utils/debugLogger';
import { hostPlatform, isOfficiallySupportedPlatform } from '../../utils/hostPlatform';
import { fetchData } from '../../utils/network';
import { spawnAsync } from '../../utils/spawnAsync';
import { fetchData } from '../utils/network';
import { spawnAsync } from '../utils/spawnAsync';
import { getEmbedderName } from '../../utils/userAgent';
import { lockfile } from '../../utilsBundle';
import { canAccessFile, existsAsync, removeFolders } from '../utils/fileUtils';

View File

@ -18,7 +18,7 @@ import * as fs from 'fs';
import * as path from 'path';
import { ManualPromise } from '../../utils/manualPromise';
import { httpRequest } from '../../utils/network';
import { httpRequest } from '../utils/network';
import { extract } from '../../zipBundle';
export type DownloadParams = {

View File

@ -20,15 +20,15 @@ import * as net from 'net';
import * as stream from 'stream';
import * as tls from 'tls';
import { SocksProxy } from '../common/socksProxy';
import { SocksProxy } from './utils/socksProxy';
import { ManualPromise, escapeHTML, generateSelfSignedCertificate, rewriteErrorMessage } from '../utils';
import { verifyClientCertificates } from './browserContext';
import { createProxyAgent } from './fetch';
import { debugLogger } from '../utils/debugLogger';
import { createSocket, createTLSSocket } from '../utils/happy-eyeballs';
import { createSocket, createTLSSocket } from './utils/happyEyeballs';
import type * as types from './types';
import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from '../common/socksProxy';
import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from './utils/socksProxy';
import type https from 'https';
let dummyServerTlsOptions: tls.TlsOptions | undefined = undefined;

View File

@ -16,7 +16,7 @@
import EventEmitter from 'events';
import * as socks from '../common/socksProxy';
import * as socks from './utils/socksProxy';
import { ValidationError, findValidator } from '../protocol/validator';
import type { WebSocketTransport } from './transport';

View File

@ -1,5 +1,6 @@
[*]
../../
../../utils/
../../registry/
../../../generated/
../../../utils/

View File

@ -17,9 +17,9 @@
import * as fs from 'fs';
import * as path from 'path';
import { gracefullyProcessExitDoNotHang } from '../../../server';
import { gracefullyProcessExitDoNotHang } from '../../../utils';
import { isUnderTest } from '../../../utils';
import { HttpServer } from '../../../utils/httpServer';
import { HttpServer } from '../../utils/httpServer';
import { open } from '../../../utilsBundle';
import { serverSideCallMetadata } from '../../instrumentation';
import { syncLocalStorageWithSettings } from '../../launchApp';
@ -27,7 +27,7 @@ import { launchApp } from '../../launchApp';
import { createPlaywright } from '../../playwright';
import { ProgressController } from '../../progress';
import type { Transport } from '../../../utils/httpServer';
import type { Transport } from '../../utils/httpServer';
import type { BrowserType } from '../../browserType';
import type { Page } from '../../page';

View File

@ -16,7 +16,7 @@
*/
import { makeWaitForNextTask } from '../utils';
import { httpHappyEyeballsAgent, httpsHappyEyeballsAgent } from '../utils/happy-eyeballs';
import { httpHappyEyeballsAgent, httpsHappyEyeballsAgent } from './utils/happyEyeballs';
import { ws } from '../utilsBundle';
import type { WebSocket } from '../utilsBundle';

View File

@ -20,9 +20,9 @@ import * as https from 'https';
import * as net from 'net';
import * as tls from 'tls';
import { assert } from './debug';
import { ManualPromise } from './manualPromise';
import { monotonicTime } from './time';
import { assert } from '../../utils/debug';
import { ManualPromise } from '../../utils/manualPromise';
import { monotonicTime } from '../../utils/time';
// Implementation(partial) of Happy Eyeballs 2 algorithm described in
// https://www.rfc-editor.org/rfc/rfc8305

View File

@ -17,10 +17,10 @@
import * as fs from 'fs';
import * as path from 'path';
import { mime, wsServer } from '../utilsBundle';
import { createGuid } from './crypto';
import { assert } from './debug';
import { ManualPromise } from './manualPromise';
import { mime, wsServer } from '../../utilsBundle';
import { createGuid } from '../../utils/crypto';
import { assert } from '../../utils/debug';
import { ManualPromise } from '../../utils/manualPromise';
import { createHttpServer } from './network';
import type http from 'http';

View File

@ -20,9 +20,8 @@ import * as http2 from 'http2';
import * as https from 'https';
import * as url from 'url';
import { getProxyForUrl } from '../utilsBundle';
import { HttpsProxyAgent } from '../utilsBundle';
import { httpHappyEyeballsAgent, httpsHappyEyeballsAgent } from './happy-eyeballs';
import { HttpsProxyAgent, getProxyForUrl } from '../../utilsBundle';
import { httpHappyEyeballsAgent, httpsHappyEyeballsAgent } from './happyEyeballs';
import type net from 'net';

View File

@ -17,9 +17,9 @@
import EventEmitter from 'events';
import * as net from 'net';
import { assert, createGuid, } from '../utils';
import { debugLogger } from '../utils/debugLogger';
import { createSocket } from '../utils/happy-eyeballs';
import { assert, createGuid, } from '../../utils';
import { debugLogger } from '../../utils/debugLogger';
import { createSocket } from './happyEyeballs';
import type { AddressInfo } from 'net';

View File

@ -14,11 +14,11 @@
* limitations under the License.
*/
import { createHttpServer } from '../utils';
import { wsServer } from '../utilsBundle';
import { debugLogger } from './debugLogger';
import { createHttpServer } from './network';
import { wsServer } from '../../utilsBundle';
import { debugLogger } from '../../utils/debugLogger';
import type { WebSocket, WebSocketServer } from '../utilsBundle';
import type { WebSocket, WebSocketServer } from '../../utilsBundle';
import type http from 'http';
import type stream from 'stream';

View File

@ -0,0 +1,51 @@
/**
* 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 * from './utils/crypto';
export * from './utils/debug';
export * from './utils/debugLogger';
export * from './utils/env';
export * from './utils/eventsHelper';
export * from './utils/expectUtils';
export * from './utils/headers';
export * from './utils/hostPlatform';
export * from './utils/manualPromise';
export * from './utils/isomorphic/locatorGenerators';
export * from './utils/isomorphic/mimeType';
export * from './utils/isomorphic/stringUtils';
export * from './utils/isomorphic/urlMatch';
export * from './utils/multimap';
export * from './utils/rtti';
export * from './utils/semaphore';
export * from './utils/stackTrace';
export * from './utils/task';
export * from './utils/time';
export * from './utils/timeoutRunner';
export * from './utils/traceUtils';
export * from './utils/userAgent';
export * from './utils/zipFile';
export * from './utils/zones';
export * from './server/utils/socksProxy';
export * from './server/utils/processLauncher';
export * from './server/utils/ascii';
export * from './server/utils/comparators';
export * from './server/utils/fileUtils';
export * from './server/utils/httpServer';
export * from './server/utils/network';
export * from './server/utils/profiler';
export * from './server/utils/wsServer';
export * from './server/utils/spawnAsync';

View File

@ -1,46 +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.
*/
export * from './crypto';
export * from './debug';
export * from './debugLogger';
export * from './env';
export * from './eventsHelper';
export * from './expectUtils';
export * from './fileUtils';
export * from './headers';
export * from './hostPlatform';
export * from './httpServer';
export * from './manualPromise';
export * from './isomorphic/locatorGenerators';
export * from './isomorphic/mimeType';
export * from './isomorphic/stringUtils';
export * from './isomorphic/urlMatch';
export * from './multimap';
export * from './network';
export * from './profiler';
export * from './rtti';
export * from './semaphore';
export * from './spawnAsync';
export * from './stackTrace';
export * from './task';
export * from './time';
export * from './timeoutRunner';
export * from './traceUtils';
export * from './userAgent';
export * from './wsServer';
export * from './zipFile';
export * from './zones';

View File

@ -21,21 +21,15 @@ import * as path from 'path';
import { removeFolders } from './fileUtils';
import { HarBackend } from './harBackend';
import { ManualPromise } from './manualPromise';
import { fetchData } from './network';
import { getUserAgent } from './userAgent';
import { ZipFile } from './zipFile';
import { yauzl, yazl } from '../zipBundle';
import { serializeClientSideCallMetadata } from '../utils';
import { assert, calculateSha1 } from '../utils';
import { serializeClientSideCallMetadata } from '.';
import { assert, calculateSha1 } from '.';
import type { HTTPRequestParams } from './network';
import type { Platform } from './platform';
import type { Progress } from '../common/progress';
import type * as channels from '@protocol/channels';
import type * as har from '@trace/har';
import type EventEmitter from 'events';
import type http from 'http';
export type StackSession = {
@ -215,34 +209,3 @@ export async function addStackToTracingNoReply(stackSessions: Map<string, StackS
}
}
}
export async function urlToWSEndpoint(progress: Progress | undefined, endpointURL: string): Promise<string> {
if (endpointURL.startsWith('ws'))
return endpointURL;
progress?.log(`<ws preparing> retrieving websocket url from ${endpointURL}`);
const fetchUrl = new URL(endpointURL);
if (!fetchUrl.pathname.endsWith('/'))
fetchUrl.pathname += '/';
fetchUrl.pathname += 'json';
const json = await fetchData({
url: fetchUrl.toString(),
method: 'GET',
timeout: progress?.timeUntilDeadline() ?? 30_000,
headers: { 'User-Agent': getUserAgent() },
}, async (params: HTTPRequestParams, response: http.IncomingMessage) => {
return new Error(`Unexpected status ${response.statusCode} when connecting to ${fetchUrl.toString()}.\n` +
`This does not look like a Playwright server, try connecting via ws://.`);
});
progress?.throwIfAborted();
const wsUrl = new URL(endpointURL);
let wsEndpointPath = JSON.parse(json).wsEndpointPath;
if (wsEndpointPath.startsWith('/'))
wsEndpointPath = wsEndpointPath.substring(1);
if (!wsUrl.pathname.endsWith('/'))
wsUrl.pathname += '/';
wsUrl.pathname += wsEndpointPath;
wsUrl.protocol = wsUrl.protocol === 'https:' ? 'wss:' : 'ws:';
return wsUrl.toString();
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { monotonicTime } from './';
import { monotonicTime } from '../utils';
export async function raceAgainstDeadline<T>(cb: () => Promise<T>, deadline: number): Promise<{ result: T, timedOut: false } | { timedOut: true }> {
let timer: NodeJS.Timeout | undefined;

View File

@ -21,7 +21,8 @@ import { setExternalDependencies } from 'playwright/lib/transform/compilationCac
import { resolveHook } from 'playwright/lib/transform/transform';
import { removeDirAndLogToConsole } from 'playwright/lib/util';
import { stoppable } from 'playwright/lib/utilsBundle';
import { assert, calculateSha1, getPlaywrightVersion, isURLAvailable } from 'playwright-core/lib/utils';
import { isURLAvailable } from 'playwright-core/lib/utils';
import { assert, calculateSha1, getPlaywrightVersion } from 'playwright-core/lib/utils';
import { debug } from 'playwright-core/lib/utilsBundle';
import { runDevServer } from './devServer';

View File

@ -17,7 +17,7 @@
import * as fs from 'fs';
import * as path from 'path';
import { gracefullyProcessExitDoNotHang } from 'playwright-core/lib/server';
import { gracefullyProcessExitDoNotHang } from 'playwright-core/lib/utils';
import { isRegExp } from 'playwright-core/lib/utils';
import { requireOrImport, setSingleTSConfig, setTransformConfig } from '../transform/transform';

View File

@ -16,8 +16,7 @@
import * as path from 'path';
import { toPosixPath } from 'playwright-core/lib/server';
import { calculateSha1 } from 'playwright-core/lib/utils';
import { calculateSha1, toPosixPath } from 'playwright-core/lib/utils';
import { createFileMatcher } from '../util';

View File

@ -18,8 +18,7 @@ import * as fs from 'fs';
import * as path from 'path';
import * as playwrightLibrary from 'playwright-core';
import { jsonStringifyForceASCII } from 'playwright-core/lib/server';
import { addInternalStackPrefix, asLocator, createGuid, debugMode, isString, zones } from 'playwright-core/lib/utils';
import { addInternalStackPrefix, asLocator, createGuid, debugMode, isString, jsonStringifyForceASCII, zones } from 'playwright-core/lib/utils';
import { currentTestInfo } from './common/globals';
import { rootTestType } from './common/testType';

View File

@ -18,8 +18,7 @@
import * as fs from 'fs';
import * as path from 'path';
import { sanitizeForFilePath } from 'playwright-core/lib/server';
import { escapeTemplateString, isString } from 'playwright-core/lib/utils';
import { escapeTemplateString, isString, sanitizeForFilePath } from 'playwright-core/lib/utils';
import { kNoElementsFoundError, matcherHint } from './matcherHint';
import { EXPECTED_COLOR } from '../common/expectBundle';

View File

@ -17,9 +17,7 @@
import * as fs from 'fs';
import * as path from 'path';
import { sanitizeForFilePath } from 'playwright-core/lib/server';
import { compareBuffersOrStrings, getComparator } from 'playwright-core/lib/server';
import { isString } from 'playwright-core/lib/utils';
import { compareBuffersOrStrings, getComparator, isString, sanitizeForFilePath } from 'playwright-core/lib/utils';
import { colors } from 'playwright-core/lib/utilsBundle';
import { mime } from 'playwright-core/lib/utilsBundle';
@ -38,7 +36,7 @@ import type { FullProjectInternal } from '../common/config';
import type { TestInfoImpl, TestStepInfoImpl } from '../worker/testInfo';
import type { Locator, Page } from 'playwright-core';
import type { ExpectScreenshotOptions, Page as PageEx } from 'playwright-core/lib/client/page';
import type { Comparator, ImageComparatorOptions } from 'playwright-core/lib/server';
import type { Comparator, ImageComparatorOptions } from 'playwright-core/lib/utils';
type NameOrSegments = string | string[];
const snapshotNamesSymbol = Symbol('snapshotNames');

View File

@ -16,8 +16,7 @@
import * as net from 'net';
import * as path from 'path';
import { launchProcess } from 'playwright-core/lib/server';
import { isURLAvailable, monotonicTime, raceAgainstDeadline } from 'playwright-core/lib/utils';
import { launchProcess, isURLAvailable, monotonicTime, raceAgainstDeadline } from 'playwright-core/lib/utils';
import { colors, debug } from 'playwright-core/lib/utilsBundle';
import type { TestRunnerPlugin } from '.';

View File

@ -20,8 +20,7 @@ import * as fs from 'fs';
import * as path from 'path';
import { program } from 'playwright-core/lib/cli/program';
import { gracefullyProcessExitDoNotHang } from 'playwright-core/lib/server';
import { startProfiling, stopProfiling } from 'playwright-core/lib/utils';
import { gracefullyProcessExitDoNotHang, startProfiling, stopProfiling } from 'playwright-core/lib/utils';
import { builtInReporters, defaultReporter, defaultTimeout } from './common/config';
import { loadConfigFromFileRestartIfNeeded, loadEmptyConfigForMergeReports, resolveConfigLocation } from './common/configLoader';

View File

@ -18,7 +18,7 @@ import * as fs from 'fs';
import * as path from 'path';
import { Readable } from 'stream';
import { removeFolders, sanitizeForFilePath } from 'playwright-core/lib/server';
import { removeFolders, sanitizeForFilePath } from 'playwright-core/lib/utils';
import { ManualPromise, calculateSha1, createGuid, getUserAgent } from 'playwright-core/lib/utils';
import { mime } from 'playwright-core/lib/utilsBundle';
import { yazl } from 'playwright-core/lib/zipBundle';

View File

@ -18,8 +18,7 @@ import * as fs from 'fs';
import * as path from 'path';
import { Transform } from 'stream';
import { copyFileAndMakeWritable, gracefullyProcessExitDoNotHang, removeFolders, sanitizeForFilePath, toPosixPath } from 'playwright-core/lib/server';
import { HttpServer, MultiMap, assert, calculateSha1, getPackageManagerExecCommand } from 'playwright-core/lib/utils';
import { HttpServer, MultiMap, assert, calculateSha1, getPackageManagerExecCommand, copyFileAndMakeWritable, gracefullyProcessExitDoNotHang, removeFolders, sanitizeForFilePath, toPosixPath } from 'playwright-core/lib/utils';
import { colors, open } from 'playwright-core/lib/utilsBundle';
import { mime } from 'playwright-core/lib/utilsBundle';
import { yazl } from 'playwright-core/lib/zipBundle';

View File

@ -17,8 +17,7 @@
import * as fs from 'fs';
import * as path from 'path';
import { toPosixPath } from 'playwright-core/lib/server';
import { MultiMap } from 'playwright-core/lib/utils';
import { toPosixPath, MultiMap } from 'playwright-core/lib/utils';
import { formatError, nonTerminalScreen, prepareErrorStack, resolveOutputFile } from './base';
import { getProjectId } from '../common/config';

View File

@ -18,8 +18,7 @@ import * as fs from 'fs';
import * as path from 'path';
import { promisify } from 'util';
import { removeFolders } from 'playwright-core/lib/server';
import { monotonicTime } from 'playwright-core/lib/utils';
import { monotonicTime, removeFolders } from 'playwright-core/lib/utils';
import { debug } from 'playwright-core/lib/utilsBundle';
import { Dispatcher } from './dispatcher';

View File

@ -17,8 +17,8 @@
import * as fs from 'fs';
import * as path from 'path';
import { gracefullyProcessExitDoNotHang, installRootRedirect, openTraceInBrowser, openTraceViewerApp, registry, startTraceViewerServer } from 'playwright-core/lib/server';
import { ManualPromise, isUnderTest } from 'playwright-core/lib/utils';
import { installRootRedirect, openTraceInBrowser, openTraceViewerApp, registry, startTraceViewerServer } from 'playwright-core/lib/server';
import { ManualPromise, isUnderTest, gracefullyProcessExitDoNotHang } from 'playwright-core/lib/utils';
import { open } from 'playwright-core/lib/utilsBundle';
import { createErrorCollectingReporter, createReporterForTestServer, createReporters } from './reporters';

View File

@ -17,7 +17,7 @@
import * as fs from 'fs';
import * as path from 'path';
import { removeFolders } from 'playwright-core/lib/server';
import { removeFolders } from 'playwright-core/lib/utils';
import { ProcessHost } from './processHost';
import { stdioChunkToParams } from '../common/ipc';

View File

@ -19,7 +19,7 @@ import * as path from 'path';
import * as url from 'url';
import util from 'util';
import { sanitizeForFilePath } from 'playwright-core/lib/server';
import { sanitizeForFilePath } from 'playwright-core/lib/utils';
import { calculateSha1, formatCallLog, isRegExp, isString, stringifyStackFrames } from 'playwright-core/lib/utils';
import { parseStackTraceLine } from 'playwright-core/lib/utils';
import { debug, mime, minimatch } from 'playwright-core/lib/utilsBundle';

View File

@ -17,8 +17,7 @@
import * as fs from 'fs';
import * as path from 'path';
import { sanitizeForFilePath } from 'playwright-core/lib/server';
import { captureRawStack, monotonicTime, stringifyStackFrames, zones } from 'playwright-core/lib/utils';
import { captureRawStack, monotonicTime, sanitizeForFilePath, stringifyStackFrames, zones } from 'playwright-core/lib/utils';
import { TimeoutManager, TimeoutManagerError, kMaxDeadline } from './timeoutManager';
import { debugTest, filteredStackTrace, formatLocation, getContainedPath, normalizeAndSaveAttachment, trimLongString, windowsFilesystemFriendlyLength } from '../util';

View File

@ -17,8 +17,7 @@
import * as fs from 'fs';
import * as path from 'path';
import { SerializedFS } from 'playwright-core/lib/server';
import { ManualPromise, calculateSha1, createGuid, monotonicTime } from 'playwright-core/lib/utils';
import { ManualPromise, SerializedFS, calculateSha1, createGuid, monotonicTime } from 'playwright-core/lib/utils';
import { yauzl, yazl } from 'playwright-core/lib/zipBundle';
import { filteredStackTrace } from '../util';

View File

@ -14,9 +14,7 @@
* limitations under the License.
*/
import { removeFolders } from 'playwright-core/lib/server';
import { gracefullyCloseAll } from 'playwright-core/lib/server';
import { ManualPromise } from 'playwright-core/lib/utils';
import { ManualPromise, gracefullyCloseAll, removeFolders } from 'playwright-core/lib/utils';
import { colors } from 'playwright-core/lib/utilsBundle';
import { deserializeConfig } from '../common/configLoader';

View File

@ -18,8 +18,8 @@ import type { IncomingMessage } from 'http';
import type { ProxyServer } from '../third_party/proxy';
import { createProxy } from '../third_party/proxy';
import net from 'net';
import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from '../../packages/playwright-core/src/common/socksProxy';
import { SocksProxy } from '../../packages/playwright-core/lib/common/socksProxy';
import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from 'playwright-core/src/server/utils/socksProxy';
import { SocksProxy } from '../../packages/playwright-core/lib/server/utils/socksProxy';
// Certain browsers perform telemetry requests which we want to ignore.
const kConnectHostsToIgnore = new Set([

View File

@ -18,9 +18,9 @@ import type { Fixtures } from '@playwright/test';
import path from 'path';
import { TestServer } from './testserver';
import { TestProxy } from './proxy';
import type { SocksSocketRequestedPayload } from '../../packages/playwright-core/src/common/socksProxy';
import type { SocksSocketRequestedPayload } from 'playwright-core/src/server/utils/socksProxy';
import { SocksProxy } from '../../packages/playwright-core/lib/common/socksProxy';
import { SocksProxy } from '../../packages/playwright-core/lib/server/utils/socksProxy';
export type ServerWorkerOptions = {
loopback?: string;

View File

@ -25,7 +25,7 @@ import util from 'util';
import type stream from 'stream';
import ws from 'ws';
import zlib, { gzip } from 'zlib';
import { createHttpServer, createHttpsServer } from '../../../packages/playwright-core/lib/utils/network';
import { createHttpServer, createHttpsServer } from '../../../packages/playwright-core/lib/server/utils/network';
const fulfillSymbol = Symbol('fulfil callback');
const rejectSymbol = Symbol('reject callback');

View File

@ -15,7 +15,7 @@
*/
import assert from 'assert';
import { spawnAsync } from '../../packages/playwright-core/lib/utils/spawnAsync';
import { spawnAsync } from '../../packages/playwright-core/lib/server/utils/spawnAsync';
export default async () => {
const result = await spawnAsync('npx', ['electron', require.resolve('./electron-print-chromium-version.js'), '--no-sandbox'], {

View File

@ -16,7 +16,7 @@
import path from 'path';
import fs from 'fs';
import { spawnAsync } from '../../packages/playwright-core/lib/utils/spawnAsync';
import { spawnAsync } from '../../packages/playwright-core/lib/server/utils/spawnAsync';
import { removeFolders } from '../../packages/playwright-core/lib/server/utils/fileUtils';
import { TMP_WORKSPACES } from './npmTest';

View File

@ -23,7 +23,7 @@ import { Registry } from './registry';
import type { CommonFixtures, CommonWorkerFixtures } from '../config/commonFixtures';
import { commonFixtures } from '../config/commonFixtures';
import { removeFolders } from '../../packages/playwright-core/lib/server/utils/fileUtils';
import { spawnAsync } from '../../packages/playwright-core/lib/utils/spawnAsync';
import { spawnAsync } from '../../packages/playwright-core/lib/server/utils/spawnAsync';
import type { SpawnOptions } from 'child_process';
export const TMP_WORKSPACES = path.join(os.platform() === 'darwin' ? '/tmp' : os.tmpdir(), 'pwt', 'workspaces');

View File

@ -19,8 +19,8 @@ import type { Server } from 'http';
import type http from 'http';
import https from 'https';
import path from 'path';
import { spawnAsync } from '../../packages/playwright-core/lib/utils/spawnAsync';
import { createHttpServer } from '../../packages/playwright-core/lib/utils/network';
import { spawnAsync } from '../../packages/playwright-core/lib/server/utils/spawnAsync';
import { createHttpServer } from '../../packages/playwright-core/lib/server/utils/network';
const kPublicNpmRegistry = 'https://registry.npmjs.org';
const kContentTypeAbbreviatedMetadata = 'application/vnd.npm.install-v1+json';

View File

@ -25,7 +25,7 @@ import { expect, playwrightTest } from '../config/browserTest';
import { parseTrace, suppressCertificateWarning } from '../config/utils';
import formidable from 'formidable';
import type { Browser, ConnectOptions } from 'playwright-core';
import { createHttpServer } from '../../packages/playwright-core/lib/utils/network';
import { createHttpServer } from '../../packages/playwright-core/lib/server/utils/network';
import { kTargetClosedErrorMessage } from '../config/errors';
import { RunServer } from '../config/remoteServer';

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { parsePattern } from '../../packages/playwright-core/lib/common/socksProxy';
import { parsePattern } from '../../packages/playwright-core/lib/server/utils/socksProxy';
import { playwrightTest as test, expect } from '../config/browserTest';
test('socks proxy patter matcher', async ({}) => {

View File

@ -18,7 +18,7 @@ import * as fs from 'fs';
import type { PlaywrightTestConfig } from '@playwright/test';
import path from 'path';
import url from 'url';
import type { HttpServer } from '../../packages/playwright-core/src/utils';
import type { HttpServer } from '../../packages/playwright-core/lib/server/utils/httpServer';
import { startHtmlReportServer } from '../../packages/playwright/lib/reporters/html';
import { expect as baseExpect, test as baseTest, stripAnsi } from './playwright-test-fixtures';
import extractZip from '../../packages/playwright-core/bundles/zip/node_modules/extract-zip';

View File

@ -18,7 +18,7 @@ import fs from 'fs';
import path from 'path';
import url from 'url';
import { test as baseTest, expect as baseExpect, createImage } from './playwright-test-fixtures';
import type { HttpServer } from '../../packages/playwright-core/src/utils';
import type { HttpServer } from '../../packages/playwright-core/lib/server/utils/httpServer';
import { startHtmlReportServer } from '../../packages/playwright/lib/reporters/html';
import { msToString } from '../../packages/web/src/uiUtils';
const { spawnAsync } = require('../../packages/playwright-core/lib/utils');

View File

@ -18,7 +18,7 @@ import type http from 'http';
import path from 'path';
import { test, expect, parseTestRunnerOutput } from './playwright-test-fixtures';
import type { RunResult } from './playwright-test-fixtures';
import { createHttpServer } from '../../packages/playwright-core/lib/utils/network';
import { createHttpServer } from '../../packages/playwright-core/lib/server/utils/network';
const SIMPLE_SERVER_PATH = path.join(__dirname, 'assets', 'simple-server.js');