diff --git a/.github/workflows/pr_check_client_side_changes.yml b/.github/workflows/pr_check_client_side_changes.yml index 8a7a1e3c5f307..db33f2ae6315a 100644 --- a/.github/workflows/pr_check_client_side_changes.yml +++ b/.github/workflows/pr_check_client_side_changes.yml @@ -6,7 +6,7 @@ on: paths: - 'docs/src/api/**/*' - 'packages/playwright-core/src/client/**/*' - - 'packages/playwright-core/src/utils/isomorphic/**/*' + - 'packages/isomorphic/**/*' - 'packages/playwright/src/matchers/matchers.ts' - 'packages/protocol/src/protocol.yml' jobs: diff --git a/eslint.config.mjs b/eslint.config.mjs index f699bbcca92bf..9ac28172f4531 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -427,7 +427,7 @@ export default [ }, { files: [ - "packages/playwright-core/src/utils/**/*.ts", + "packages/isomorphic/**/*.ts", ], languageOptions: languageOptionsWithTsConfig, rules: { @@ -472,6 +472,7 @@ export default [ { files: [ "packages/playwright-core/src/server/**/*.ts", + "packages/utils/**/*.ts", ], plugins: { "progress": progressPlugin, diff --git a/packages/dashboard/vite.config.ts b/packages/dashboard/vite.config.ts index 3bf1c2bea6166..6ee0b0c660192 100644 --- a/packages/dashboard/vite.config.ts +++ b/packages/dashboard/vite.config.ts @@ -26,7 +26,7 @@ export default defineConfig({ ], resolve: { alias: { - '@isomorphic': path.resolve(__dirname, '../playwright-core/src/utils/isomorphic'), + '@isomorphic': path.resolve(__dirname, '../isomorphic'), '@protocol': path.resolve(__dirname, '../protocol/src'), '@web': path.resolve(__dirname, '../web/src'), }, diff --git a/packages/html-reporter/vite.config.ts b/packages/html-reporter/vite.config.ts index fe96d45f1f752..767608dd639ea 100644 --- a/packages/html-reporter/vite.config.ts +++ b/packages/html-reporter/vite.config.ts @@ -29,7 +29,7 @@ export default defineConfig({ resolve: { alias: { '@web': path.resolve(__dirname, '../web/src'), - '@isomorphic': path.resolve(__dirname, '../playwright-core/src/utils/isomorphic'), + '@isomorphic': path.resolve(__dirname, '../isomorphic'), }, }, build: { diff --git a/packages/playwright-core/src/utils/isomorphic/ariaSnapshot.ts b/packages/isomorphic/ariaSnapshot.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/ariaSnapshot.ts rename to packages/isomorphic/ariaSnapshot.ts diff --git a/packages/playwright-core/src/utils/isomorphic/assert.ts b/packages/isomorphic/assert.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/assert.ts rename to packages/isomorphic/assert.ts diff --git a/packages/playwright-core/src/utils/isomorphic/colors.ts b/packages/isomorphic/colors.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/colors.ts rename to packages/isomorphic/colors.ts diff --git a/packages/playwright-core/src/utils/isomorphic/cssParser.ts b/packages/isomorphic/cssParser.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/cssParser.ts rename to packages/isomorphic/cssParser.ts diff --git a/packages/playwright-core/src/utils/isomorphic/cssTokenizer.ts b/packages/isomorphic/cssTokenizer.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/cssTokenizer.ts rename to packages/isomorphic/cssTokenizer.ts diff --git a/packages/playwright-core/src/utils/isomorphic/expectUtils.ts b/packages/isomorphic/expectUtils.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/expectUtils.ts rename to packages/isomorphic/expectUtils.ts diff --git a/packages/playwright-core/src/utils/isomorphic/formatUtils.ts b/packages/isomorphic/formatUtils.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/formatUtils.ts rename to packages/isomorphic/formatUtils.ts diff --git a/packages/playwright-core/src/utils/isomorphic/headers.ts b/packages/isomorphic/headers.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/headers.ts rename to packages/isomorphic/headers.ts diff --git a/packages/playwright-core/src/utils/isomorphic/imageUtils.ts b/packages/isomorphic/imageUtils.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/imageUtils.ts rename to packages/isomorphic/imageUtils.ts diff --git a/packages/playwright-core/src/utils/isomorphic/index.ts b/packages/isomorphic/index.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/index.ts rename to packages/isomorphic/index.ts diff --git a/packages/playwright-core/src/utils/isomorphic/jsonSchema.ts b/packages/isomorphic/jsonSchema.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/jsonSchema.ts rename to packages/isomorphic/jsonSchema.ts diff --git a/packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts b/packages/isomorphic/locatorGenerators.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts rename to packages/isomorphic/locatorGenerators.ts diff --git a/packages/playwright-core/src/utils/isomorphic/locatorParser.ts b/packages/isomorphic/locatorParser.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/locatorParser.ts rename to packages/isomorphic/locatorParser.ts diff --git a/packages/playwright-core/src/utils/isomorphic/locatorUtils.ts b/packages/isomorphic/locatorUtils.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/locatorUtils.ts rename to packages/isomorphic/locatorUtils.ts diff --git a/packages/playwright-core/src/utils/isomorphic/lruCache.ts b/packages/isomorphic/lruCache.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/lruCache.ts rename to packages/isomorphic/lruCache.ts diff --git a/packages/playwright-core/src/utils/isomorphic/manualPromise.ts b/packages/isomorphic/manualPromise.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/manualPromise.ts rename to packages/isomorphic/manualPromise.ts diff --git a/packages/playwright-core/src/utils/isomorphic/mimeType.ts b/packages/isomorphic/mimeType.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/mimeType.ts rename to packages/isomorphic/mimeType.ts diff --git a/packages/playwright-core/src/utils/isomorphic/multimap.ts b/packages/isomorphic/multimap.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/multimap.ts rename to packages/isomorphic/multimap.ts diff --git a/packages/playwright-core/src/client/platform.ts b/packages/isomorphic/platform.ts similarity index 98% rename from packages/playwright-core/src/client/platform.ts rename to packages/isomorphic/platform.ts index 7f6e1f9efb106..7c27221cc47d7 100644 --- a/packages/playwright-core/src/client/platform.ts +++ b/packages/isomorphic/platform.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { webColors } from '@isomorphic/colors'; +import { webColors } from './colors'; import type * as fs from 'fs'; import type * as path from 'path'; diff --git a/packages/playwright-core/src/utils/isomorphic/protocolFormatter.ts b/packages/isomorphic/protocolFormatter.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/protocolFormatter.ts rename to packages/isomorphic/protocolFormatter.ts diff --git a/packages/playwright-core/src/utils/isomorphic/protocolMetainfo.ts b/packages/isomorphic/protocolMetainfo.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/protocolMetainfo.ts rename to packages/isomorphic/protocolMetainfo.ts diff --git a/packages/playwright-core/src/utils/isomorphic/rtti.ts b/packages/isomorphic/rtti.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/rtti.ts rename to packages/isomorphic/rtti.ts diff --git a/packages/playwright-core/src/utils/isomorphic/selectorParser.ts b/packages/isomorphic/selectorParser.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/selectorParser.ts rename to packages/isomorphic/selectorParser.ts diff --git a/packages/playwright-core/src/utils/isomorphic/semaphore.ts b/packages/isomorphic/semaphore.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/semaphore.ts rename to packages/isomorphic/semaphore.ts diff --git a/packages/playwright-core/src/utils/isomorphic/stackTrace.ts b/packages/isomorphic/stackTrace.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/stackTrace.ts rename to packages/isomorphic/stackTrace.ts diff --git a/packages/playwright-core/src/utils/isomorphic/stringUtils.ts b/packages/isomorphic/stringUtils.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/stringUtils.ts rename to packages/isomorphic/stringUtils.ts diff --git a/packages/playwright-core/src/utils/isomorphic/time.ts b/packages/isomorphic/time.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/time.ts rename to packages/isomorphic/time.ts diff --git a/packages/playwright-core/src/utils/isomorphic/timeoutRunner.ts b/packages/isomorphic/timeoutRunner.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/timeoutRunner.ts rename to packages/isomorphic/timeoutRunner.ts diff --git a/packages/playwright-core/src/utils/isomorphic/trace/DEPS.list b/packages/isomorphic/trace/DEPS.list similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/trace/DEPS.list rename to packages/isomorphic/trace/DEPS.list diff --git a/packages/playwright-core/src/utils/isomorphic/trace/entries.ts b/packages/isomorphic/trace/entries.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/trace/entries.ts rename to packages/isomorphic/trace/entries.ts diff --git a/packages/playwright-core/src/utils/isomorphic/trace/snapshotRenderer.ts b/packages/isomorphic/trace/snapshotRenderer.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/trace/snapshotRenderer.ts rename to packages/isomorphic/trace/snapshotRenderer.ts diff --git a/packages/playwright-core/src/utils/isomorphic/trace/snapshotServer.ts b/packages/isomorphic/trace/snapshotServer.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/trace/snapshotServer.ts rename to packages/isomorphic/trace/snapshotServer.ts diff --git a/packages/playwright-core/src/utils/isomorphic/trace/snapshotStorage.ts b/packages/isomorphic/trace/snapshotStorage.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/trace/snapshotStorage.ts rename to packages/isomorphic/trace/snapshotStorage.ts diff --git a/packages/playwright-core/src/utils/isomorphic/trace/traceLoader.ts b/packages/isomorphic/trace/traceLoader.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/trace/traceLoader.ts rename to packages/isomorphic/trace/traceLoader.ts diff --git a/packages/playwright-core/src/utils/isomorphic/trace/traceModel.ts b/packages/isomorphic/trace/traceModel.ts similarity index 99% rename from packages/playwright-core/src/utils/isomorphic/trace/traceModel.ts rename to packages/isomorphic/trace/traceModel.ts index 5cf326ca1b4c3..ea8381f910c26 100644 --- a/packages/playwright-core/src/utils/isomorphic/trace/traceModel.ts +++ b/packages/isomorphic/trace/traceModel.ts @@ -20,7 +20,7 @@ import type { Language } from '../locatorGenerators'; import type { ResourceSnapshot } from '@trace/snapshot'; import type * as trace from '@trace/trace'; import type { ActionTraceEvent } from '@trace/trace'; -import type { ActionEntry, ContextEntry, PageEntry } from '../trace/entries'; +import type { ActionEntry, ContextEntry, PageEntry } from './entries'; import type { StackFrame } from '@protocol/channels'; import type { ActionGroup } from '../protocolFormatter'; diff --git a/packages/playwright-core/src/utils/isomorphic/trace/traceModernizer.ts b/packages/isomorphic/trace/traceModernizer.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/trace/traceModernizer.ts rename to packages/isomorphic/trace/traceModernizer.ts diff --git a/packages/playwright-core/src/utils/isomorphic/trace/traceUtils.ts b/packages/isomorphic/trace/traceUtils.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/trace/traceUtils.ts rename to packages/isomorphic/trace/traceUtils.ts diff --git a/packages/playwright-core/src/utils/isomorphic/trace/versions/traceV3.ts b/packages/isomorphic/trace/versions/traceV3.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/trace/versions/traceV3.ts rename to packages/isomorphic/trace/versions/traceV3.ts diff --git a/packages/playwright-core/src/utils/isomorphic/trace/versions/traceV4.ts b/packages/isomorphic/trace/versions/traceV4.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/trace/versions/traceV4.ts rename to packages/isomorphic/trace/versions/traceV4.ts diff --git a/packages/playwright-core/src/utils/isomorphic/trace/versions/traceV5.ts b/packages/isomorphic/trace/versions/traceV5.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/trace/versions/traceV5.ts rename to packages/isomorphic/trace/versions/traceV5.ts diff --git a/packages/playwright-core/src/utils/isomorphic/trace/versions/traceV6.ts b/packages/isomorphic/trace/versions/traceV6.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/trace/versions/traceV6.ts rename to packages/isomorphic/trace/versions/traceV6.ts diff --git a/packages/playwright-core/src/utils/isomorphic/trace/versions/traceV7.ts b/packages/isomorphic/trace/versions/traceV7.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/trace/versions/traceV7.ts rename to packages/isomorphic/trace/versions/traceV7.ts diff --git a/packages/playwright-core/src/utils/isomorphic/trace/versions/traceV8.ts b/packages/isomorphic/trace/versions/traceV8.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/trace/versions/traceV8.ts rename to packages/isomorphic/trace/versions/traceV8.ts diff --git a/packages/playwright-core/src/utils/isomorphic/types.ts b/packages/isomorphic/types.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/types.ts rename to packages/isomorphic/types.ts diff --git a/packages/playwright-core/src/utils/isomorphic/urlMatch.ts b/packages/isomorphic/urlMatch.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/urlMatch.ts rename to packages/isomorphic/urlMatch.ts diff --git a/packages/playwright-core/src/utils/isomorphic/utilityScriptSerializers.ts b/packages/isomorphic/utilityScriptSerializers.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/utilityScriptSerializers.ts rename to packages/isomorphic/utilityScriptSerializers.ts diff --git a/packages/playwright-core/src/utils/isomorphic/yaml.ts b/packages/isomorphic/yaml.ts similarity index 100% rename from packages/playwright-core/src/utils/isomorphic/yaml.ts rename to packages/isomorphic/yaml.ts diff --git a/packages/playwright-client/src/webPlatform.ts b/packages/playwright-client/src/webPlatform.ts index e7d64817ecfe2..5cbcd6e85449b 100644 --- a/packages/playwright-client/src/webPlatform.ts +++ b/packages/playwright-client/src/webPlatform.ts @@ -15,9 +15,9 @@ * limitations under the License. */ -import { emptyPlatform } from '../../playwright-core/src/client/platform'; +import { emptyPlatform } from '@isomorphic/platform'; -import type { Platform } from '../../playwright-core/src/client/platform'; +import type { Platform } from '@isomorphic/platform'; export const webPlatform: Platform = { ...emptyPlatform, diff --git a/packages/playwright-core/ThirdPartyNotices.txt b/packages/playwright-core/ThirdPartyNotices.txt index dc3e89beb52a0..369e2025a75bc 100644 --- a/packages/playwright-core/ThirdPartyNotices.txt +++ b/packages/playwright-core/ThirdPartyNotices.txt @@ -9,3 +9,5 @@ bundle, together with the full license text for each. For example: - lib/utilsBundle.js.LICENSE + +This project incorporates components from the projects listed below. The original copyright notices and the licenses under which Microsoft received such components are set forth below. Microsoft reserves all rights not expressly granted herein, whether by implication, estoppel or otherwise. diff --git a/packages/playwright-core/src/DEPS.list b/packages/playwright-core/src/DEPS.list index 5911ff5f292cd..0b88a2b5c2f31 100644 --- a/packages/playwright-core/src/DEPS.list +++ b/packages/playwright-core/src/DEPS.list @@ -17,6 +17,7 @@ server/ [inprocess.ts] ** +@utils/** [outofprocess.ts] client/ diff --git a/packages/playwright-core/src/browserServerImpl.ts b/packages/playwright-core/src/browserServerImpl.ts index cfe203239c073..be65d80bab37b 100644 --- a/packages/playwright-core/src/browserServerImpl.ts +++ b/packages/playwright-core/src/browserServerImpl.ts @@ -18,11 +18,11 @@ import EventEmitter from 'events'; import { createGuid } from '@utils/crypto'; import { isUnderTest } from '@utils/debug'; +import { rewriteErrorMessage } from '@isomorphic/stackTrace'; +import { DEFAULT_PLAYWRIGHT_LAUNCH_TIMEOUT } from '@isomorphic/time'; import { PlaywrightServer } from './remote/playwrightServer'; import { helper } from './server/helper'; import { createPlaywright } from './server/playwright'; -import { rewriteErrorMessage } from './utils/isomorphic/stackTrace'; -import { DEFAULT_PLAYWRIGHT_LAUNCH_TIMEOUT } from './utils/isomorphic/time'; import * as validatorPrimitives from './protocol/validatorPrimitives'; import { ProgressController } from './server/progress'; diff --git a/packages/playwright-core/src/cli/DEPS.list b/packages/playwright-core/src/cli/DEPS.list index c3059dbd74a9b..17191792c1a86 100644 --- a/packages/playwright-core/src/cli/DEPS.list +++ b/packages/playwright-core/src/cli/DEPS.list @@ -1,9 +1,10 @@ [*] +@isomorphic/** +@utils/** ../inprocess.ts ../package.ts ../server/ ../server/registry/ -@utils/** ../remote/ ../utils/** ../utilsBundle.ts diff --git a/packages/playwright-core/src/client/android.ts b/packages/playwright-core/src/client/android.ts index 530b0d75520cf..9a63c601ef988 100644 --- a/packages/playwright-core/src/client/android.ts +++ b/packages/playwright-core/src/client/android.ts @@ -30,7 +30,7 @@ import type { Page } from './page'; import type * as types from './types'; import type * as api from '../../types/types'; import type { AndroidServerLauncherImpl } from '../androidServerImpl'; -import type { Platform } from './platform'; +import type { Platform } from '@isomorphic/platform'; import type * as channels from '@protocol/channels'; import type { Playwright } from './playwright'; diff --git a/packages/playwright-core/src/client/browserContext.ts b/packages/playwright-core/src/client/browserContext.ts index efd47ef528c9f..dd2b371fc0870 100644 --- a/packages/playwright-core/src/client/browserContext.ts +++ b/packages/playwright-core/src/client/browserContext.ts @@ -47,7 +47,7 @@ import type { BrowserContextOptions, Headers, SetStorageState, StorageState, Wai import type * as structs from '../../types/structs'; import type * as api from '../../types/types'; import type { URLMatch } from '@isomorphic/urlMatch'; -import type { Platform } from './platform'; +import type { Platform } from '@isomorphic/platform'; import type * as channels from '@protocol/channels'; import type * as actions from '@recorder/actions'; diff --git a/packages/playwright-core/src/client/channelOwner.ts b/packages/playwright-core/src/client/channelOwner.ts index 92b4fd94f9a08..75422652542e7 100644 --- a/packages/playwright-core/src/client/channelOwner.ts +++ b/packages/playwright-core/src/client/channelOwner.ts @@ -24,7 +24,7 @@ import type { ClientInstrumentation } from './clientInstrumentation'; import type { Connection } from './connection'; import type { Logger } from './types'; import type { ValidatorContext } from '../protocol/validator'; -import type { Platform } from './platform'; +import type { Platform } from '@isomorphic/platform'; import type * as channels from '@protocol/channels'; type Listener = (...args: any[]) => void; diff --git a/packages/playwright-core/src/client/clientHelper.ts b/packages/playwright-core/src/client/clientHelper.ts index eae632a7d3ce2..a58dc4a79354a 100644 --- a/packages/playwright-core/src/client/clientHelper.ts +++ b/packages/playwright-core/src/client/clientHelper.ts @@ -17,7 +17,7 @@ import { isString } from '@isomorphic/rtti'; -import type { Platform } from './platform'; +import type { Platform } from '@isomorphic/platform'; export function envObjectToArray(env: NodeJS.ProcessEnv): { name: string, value: string }[] { const result: { name: string, value: string }[] = []; diff --git a/packages/playwright-core/src/client/clientStackTrace.ts b/packages/playwright-core/src/client/clientStackTrace.ts index afb24d3e49f08..6c4456c293a26 100644 --- a/packages/playwright-core/src/client/clientStackTrace.ts +++ b/packages/playwright-core/src/client/clientStackTrace.ts @@ -16,7 +16,7 @@ import { captureRawStack, parseStackFrame } from '@isomorphic/stackTrace'; -import type { Platform } from './platform'; +import type { Platform } from '@isomorphic/platform'; import type { StackFrame } from '@isomorphic/stackTrace'; export function captureLibraryStackTrace(platform: Platform): { frames: StackFrame[], apiName: string } { diff --git a/packages/playwright-core/src/client/connection.ts b/packages/playwright-core/src/client/connection.ts index b2ba72309ae88..15db5e3d1c598 100644 --- a/packages/playwright-core/src/client/connection.ts +++ b/packages/playwright-core/src/client/connection.ts @@ -46,7 +46,7 @@ import { ValidationError, findValidator } from '../protocol/validator'; import type { ClientInstrumentation } from './clientInstrumentation'; import type { HeadersArray } from './types'; import type { ValidatorContext } from '../protocol/validator'; -import type { Platform } from './platform'; +import type { Platform } from '@isomorphic/platform'; import type * as channels from '@protocol/channels'; class Root extends ChannelOwner { diff --git a/packages/playwright-core/src/client/consoleMessage.ts b/packages/playwright-core/src/client/consoleMessage.ts index 3bf4e098ae558..0900ece4a5dbd 100644 --- a/packages/playwright-core/src/client/consoleMessage.ts +++ b/packages/playwright-core/src/client/consoleMessage.ts @@ -17,7 +17,7 @@ import { JSHandle } from './jsHandle'; import type * as api from '../../types/types'; -import type { Platform } from './platform'; +import type { Platform } from '@isomorphic/platform'; import type * as channels from '@protocol/channels'; import type { Page } from './page'; import type { Worker } from './worker'; diff --git a/packages/playwright-core/src/client/elementHandle.ts b/packages/playwright-core/src/client/elementHandle.ts index 0c95a4911d114..99e3c555d9411 100644 --- a/packages/playwright-core/src/client/elementHandle.ts +++ b/packages/playwright-core/src/client/elementHandle.ts @@ -28,7 +28,7 @@ import type { Locator } from './locator'; import type { FilePayload, Rect, SelectOption, SelectOptionOptions, TimeoutOptions } from './types'; import type * as structs from '../../types/structs'; import type * as api from '../../types/types'; -import type { Platform } from './platform'; +import type { Platform } from '@isomorphic/platform'; import type * as channels from '@protocol/channels'; export class ElementHandle extends JSHandle implements api.ElementHandle { diff --git a/packages/playwright-core/src/client/eventEmitter.ts b/packages/playwright-core/src/client/eventEmitter.ts index e1c08619ec901..45fb486eb9bf2 100644 --- a/packages/playwright-core/src/client/eventEmitter.ts +++ b/packages/playwright-core/src/client/eventEmitter.ts @@ -23,7 +23,7 @@ */ import type { EventEmitter as EventEmitterType } from 'events'; -import type { Platform } from './platform'; +import type { Platform } from '@isomorphic/platform'; type EventType = string | symbol; type Listener = (...args: any[]) => any; diff --git a/packages/playwright-core/src/client/fetch.ts b/packages/playwright-core/src/client/fetch.ts index 2f04ff5fefee4..6909a75776bb0 100644 --- a/packages/playwright-core/src/client/fetch.ts +++ b/packages/playwright-core/src/client/fetch.ts @@ -30,7 +30,7 @@ import type { ClientCertificate, FilePayload, Headers, SetStorageState, StorageS import type { Serializable } from '../../types/structs'; import type * as api from '../../types/types'; import type { HeadersArray, NameValue } from '@isomorphic/types'; -import type { Platform } from './platform'; +import type { Platform } from '@isomorphic/platform'; import type * as channels from '@protocol/channels'; import type * as fs from 'fs'; diff --git a/packages/playwright-core/src/client/fileUtils.ts b/packages/playwright-core/src/client/fileUtils.ts index 1eb483394655c..a291046c9f42e 100644 --- a/packages/playwright-core/src/client/fileUtils.ts +++ b/packages/playwright-core/src/client/fileUtils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import type { Platform } from './platform'; +import type { Platform } from '@isomorphic/platform'; // Keep in sync with the server. export const fileUploadSizeLimit = 50 * 1024 * 1024; diff --git a/packages/playwright-core/src/client/network.ts b/packages/playwright-core/src/client/network.ts index 688796e69cba7..146d0679da057 100644 --- a/packages/playwright-core/src/client/network.ts +++ b/packages/playwright-core/src/client/network.ts @@ -38,7 +38,7 @@ import type * as api from '../../types/types'; import type { HeadersArray } from '@isomorphic/types'; import type { URLMatch } from '@isomorphic/urlMatch'; import type * as channels from '@protocol/channels'; -import type { Platform, Zone } from './platform'; +import type { Platform, Zone } from '@isomorphic/platform'; export type NetworkCookie = { name: string, diff --git a/packages/playwright-core/src/client/selectors.ts b/packages/playwright-core/src/client/selectors.ts index 3e6fc905c4802..c287ed989d717 100644 --- a/packages/playwright-core/src/client/selectors.ts +++ b/packages/playwright-core/src/client/selectors.ts @@ -21,7 +21,7 @@ import type { SelectorEngine } from './types'; import type * as api from '../../types/types'; import type * as channels from '@protocol/channels'; import type { BrowserContext } from './browserContext'; -import type { Platform } from './platform'; +import type { Platform } from '@isomorphic/platform'; export class Selectors implements api.Selectors { private _platform: Platform; diff --git a/packages/playwright-core/src/client/timeoutSettings.ts b/packages/playwright-core/src/client/timeoutSettings.ts index e51f45da89055..ee384b24cb36e 100644 --- a/packages/playwright-core/src/client/timeoutSettings.ts +++ b/packages/playwright-core/src/client/timeoutSettings.ts @@ -17,7 +17,7 @@ import { DEFAULT_PLAYWRIGHT_LAUNCH_TIMEOUT, DEFAULT_PLAYWRIGHT_TIMEOUT } from '@isomorphic/time'; -import type { Platform } from './platform'; +import type { Platform } from '@isomorphic/platform'; export class TimeoutSettings { private _parent: TimeoutSettings | undefined; diff --git a/packages/playwright-core/src/client/waiter.ts b/packages/playwright-core/src/client/waiter.ts index 668943f85c8af..61c3172f90dc2 100644 --- a/packages/playwright-core/src/client/waiter.ts +++ b/packages/playwright-core/src/client/waiter.ts @@ -20,7 +20,7 @@ import { TimeoutError } from './errors'; import type { ChannelOwner } from './channelOwner'; import type * as channels from '@protocol/channels'; import type { EventEmitter } from 'events'; -import type { Zone } from './platform'; +import type { Zone } from '@isomorphic/platform'; export class Waiter { private _dispose: (() => void)[]; diff --git a/packages/playwright-core/src/coreBundle.ts b/packages/playwright-core/src/coreBundle.ts index 61d125e671e83..6aa199f14d6be 100644 --- a/packages/playwright-core/src/coreBundle.ts +++ b/packages/playwright-core/src/coreBundle.ts @@ -14,14 +14,15 @@ * limitations under the License. */ +export * as iso from '@isomorphic/index'; +export * as utils from '@utils/index'; export * as client from './client'; -export * as iso from './utils/isomorphic'; -export * as utils from './server/utils/index'; export * as libCli from './cli/program'; export * as libCliTestStub from './cli/programWithTestStub'; export * as inprocess from './inprocess'; export * as oop from './outofprocess'; export * as remote from './remote/playwrightServer'; export * as registry from './server/registry/index'; -export * as sever from './server/index'; +export * as server from './server/index'; export * as tools from './tools'; +export { getUserAgent, getPlaywrightVersion } from './server/userAgent'; diff --git a/packages/playwright-core/src/inprocess.ts b/packages/playwright-core/src/inprocess.ts index 5f4f91ae154c5..14d9572edc129 100644 --- a/packages/playwright-core/src/inprocess.ts +++ b/packages/playwright-core/src/inprocess.ts @@ -19,13 +19,14 @@ import { AndroidServerLauncherImpl } from './androidServerImpl'; import { BrowserServerLauncherImpl } from './browserServerImpl'; import { DispatcherConnection, PlaywrightDispatcher, RootDispatcher, createPlaywright } from './server'; import { Connection } from './client/connection'; +import { packageRoot } from './package'; import type { Playwright as PlaywrightAPI } from './client/playwright'; import type { Language } from '@isomorphic/locatorGenerators'; function createInProcessPlaywright(): PlaywrightAPI { const playwright = createPlaywright({ sdkLanguage: (process.env.PW_LANG_NAME as Language | undefined) || 'javascript' }); - const clientConnection = new Connection(nodePlatform); + const clientConnection = new Connection(nodePlatform(packageRoot)); clientConnection.useRawBuffers(); const dispatcherConnection = new DispatcherConnection(true /* local */); diff --git a/packages/playwright-core/src/outofprocess.ts b/packages/playwright-core/src/outofprocess.ts index b9beddbc4a1fc..fd1cbef350bee 100644 --- a/packages/playwright-core/src/outofprocess.ts +++ b/packages/playwright-core/src/outofprocess.ts @@ -19,9 +19,9 @@ import path from 'path'; import { PipeTransport } from '@utils/pipeTransport'; import { nodePlatform } from '@utils/nodePlatform'; +import { ManualPromise } from '@isomorphic/manualPromise'; import { Connection } from './client/connection'; import { packageRoot } from './package'; -import { ManualPromise } from './utils/isomorphic/manualPromise'; import type { Playwright } from './client/playwright'; @@ -51,7 +51,7 @@ class PlaywrightClient { // eslint-disable-next-line no-restricted-properties this._driverProcess.stderr!.on('data', data => process.stderr.write(data)); - const connection = new Connection(nodePlatform); + const connection = new Connection(nodePlatform(packageRoot)); const transport = new PipeTransport(this._driverProcess.stdin!, this._driverProcess.stdout!); connection.onmessage = message => transport.send(JSON.stringify(message)); transport.onmessage = message => connection.dispatch(JSON.parse(message)); diff --git a/packages/playwright-core/src/remote/playwrightServer.ts b/packages/playwright-core/src/remote/playwrightServer.ts index 5ba3c4b759905..c3b005859665f 100644 --- a/packages/playwright-core/src/remote/playwrightServer.ts +++ b/packages/playwright-core/src/remote/playwrightServer.ts @@ -18,10 +18,10 @@ import { Semaphore } from '@isomorphic/semaphore'; import { DEFAULT_PLAYWRIGHT_LAUNCH_TIMEOUT } from '@isomorphic/time'; import { WSServer } from '@utils/wsServer'; import { wrapInASCIIBox } from '@utils/ascii'; -import { getPlaywrightVersion } from '@utils/userAgent'; import { SocksProxy } from '@utils/socksProxy'; import { debugLogger } from '@utils/debugLogger'; import { isUnderTest } from '@utils/debug'; +import { getPlaywrightVersion } from '../server/userAgent'; import { PlaywrightConnection, PlaywrightInitializeResult } from './playwrightConnection'; import { WebSocketServerTransport } from './serverTransport'; import { createPlaywright } from '../server/playwright'; diff --git a/packages/playwright-core/src/server/DEPS.list b/packages/playwright-core/src/server/DEPS.list index 5829d0dd1edd9..89daa5f713a5c 100644 --- a/packages/playwright-core/src/server/DEPS.list +++ b/packages/playwright-core/src/server/DEPS.list @@ -1,9 +1,10 @@ [*] +@isomorphic/** +@utils/** ../generated/ ../package.ts ../protocol/ ../utils -@isomorphic/** ../utilsBundle.ts ./ ./codegen/ @@ -12,7 +13,6 @@ ./recorder/ ./registry/ ./trace/recorder/tracing.ts -./utils/ node_modules/jpeg-js node_modules/mime node_modules/pngjs diff --git a/packages/playwright-core/src/server/android/DEPS.list b/packages/playwright-core/src/server/android/DEPS.list index 2baec8bd40c47..facdfb55d51d2 100644 --- a/packages/playwright-core/src/server/android/DEPS.list +++ b/packages/playwright-core/src/server/android/DEPS.list @@ -1,7 +1,8 @@ [*] +@isomorphic/** +@utils/** ../ ../../protocol/ -@isomorphic/** ../../utilsBundle.ts ../chromium/ ../utils diff --git a/packages/playwright-core/src/server/bidi/DEPS.list b/packages/playwright-core/src/server/bidi/DEPS.list index 312e1a0583f9a..b7afb4d4b25d7 100644 --- a/packages/playwright-core/src/server/bidi/DEPS.list +++ b/packages/playwright-core/src/server/bidi/DEPS.list @@ -1,5 +1,5 @@ [*] -../../utils/** +@utils/** @isomorphic/** ../ ../isomorphic/ diff --git a/packages/playwright-core/src/server/chromium/chromium.ts b/packages/playwright-core/src/server/chromium/chromium.ts index cb162d334e578..75cdfc39d89e6 100644 --- a/packages/playwright-core/src/server/chromium/chromium.ts +++ b/packages/playwright-core/src/server/chromium/chromium.ts @@ -22,12 +22,12 @@ import path from 'path'; import { ManualPromise } from '@isomorphic/manualPromise'; import { wrapInASCIIBox } from '@utils/ascii'; import { RecentLogsCollector } from '@utils/debugLogger'; -import { fetchData } from '@utils/network'; -import { getUserAgent } from '@utils/userAgent'; import { removeFolders } from '@utils/fileUtils'; import { gracefullyCloseSet } from '@utils/processLauncher'; import { debugMode } from '@utils/debug'; import { headersArrayToObject, headersObjectToArray } from '@isomorphic/headers'; +import { fetchData } from '../utils'; +import { getUserAgent } from '../userAgent'; import { chromiumSwitches } from './chromiumSwitches'; import { shouldProxyLoopback, CRBrowser } from './crBrowser'; import { kBrowserCloseMessageId } from './crConnection'; diff --git a/packages/playwright-core/src/server/codegen/DEPS.list b/packages/playwright-core/src/server/codegen/DEPS.list index 2a5dd1a135bf6..c95fe3ff089fd 100644 --- a/packages/playwright-core/src/server/codegen/DEPS.list +++ b/packages/playwright-core/src/server/codegen/DEPS.list @@ -1,3 +1,4 @@ [*] -../../utils/** +@isomorphic/** +@utils/** ../deviceDescriptors.ts diff --git a/packages/playwright-core/src/server/dispatchers/DEPS.list b/packages/playwright-core/src/server/dispatchers/DEPS.list index e83bc932b6db0..1015a3e35ab90 100644 --- a/packages/playwright-core/src/server/dispatchers/DEPS.list +++ b/packages/playwright-core/src/server/dispatchers/DEPS.list @@ -1,7 +1,7 @@ [*] ../../generated/ ../../protocol/ -../../utils/** +@utils/** @isomorphic/** ../** node_modules/yaml diff --git a/packages/playwright-core/src/server/dispatchers/localUtilsDispatcher.ts b/packages/playwright-core/src/server/dispatchers/localUtilsDispatcher.ts index 7b30d75e761d5..e98254eb71a98 100644 --- a/packages/playwright-core/src/server/dispatchers/localUtilsDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/localUtilsDispatcher.ts @@ -16,10 +16,10 @@ import net from 'net'; import { resolveGlobToRegexPattern } from '@isomorphic/urlMatch'; -import { getUserAgent } from '@utils/userAgent'; -import { fetchData } from '@utils/network'; +import { fetchData } from '../utils'; +import { getUserAgent } from '../userAgent'; import { Dispatcher } from './dispatcher'; -import { SdkObject } from '../../server/instrumentation'; +import { SdkObject } from '../instrumentation'; import * as localUtils from '../localUtils'; import { deviceDescriptors as descriptors } from '../deviceDescriptors'; import { JsonPipeDispatcher } from '../dispatchers/jsonPipeDispatcher'; diff --git a/packages/playwright-core/src/server/electron/DEPS.list b/packages/playwright-core/src/server/electron/DEPS.list index ad3aea548bc2e..df64932cb0016 100644 --- a/packages/playwright-core/src/server/electron/DEPS.list +++ b/packages/playwright-core/src/server/electron/DEPS.list @@ -1,7 +1,7 @@ [*] ../ ../../package.ts -../../utils/** +@utils/** @isomorphic/** ../chromium/ ../utils \ No newline at end of file diff --git a/packages/playwright-core/src/server/fetch.ts b/packages/playwright-core/src/server/fetch.ts index a10875113c0d4..54fc6c1cdee16 100644 --- a/packages/playwright-core/src/server/fetch.ts +++ b/packages/playwright-core/src/server/fetch.ts @@ -21,13 +21,13 @@ import { TLSSocket } from 'tls'; import * as zlib from 'zlib'; import { createGuid } from '@utils/crypto'; -import { getUserAgent } from '@utils/userAgent'; import { httpHappyEyeballsAgent, httpsHappyEyeballsAgent, timingForSocket } from '@utils/happyEyeballs'; import { assert } from '@isomorphic/assert'; import { constructURLBasedOnBaseURL } from '@isomorphic/urlMatch'; -import { createProxyAgent } from '@utils/network'; import { eventsHelper } from '@utils/eventsHelper'; import { monotonicTime } from '@isomorphic/time'; +import { createProxyAgent } from '@utils/network'; +import { getUserAgent } from './userAgent'; import { BrowserContext, verifyClientCertificates } from './browserContext'; import { Cookie, CookieStore, domainMatches, parseRawCookie } from './cookieStore'; import { MultipartFormData } from './formData'; diff --git a/packages/playwright-core/src/server/har/harTracer.ts b/packages/playwright-core/src/server/har/harTracer.ts index b16cf0729ee55..4281e7b686e21 100644 --- a/packages/playwright-core/src/server/har/harTracer.ts +++ b/packages/playwright-core/src/server/har/harTracer.ts @@ -20,9 +20,9 @@ import { eventsHelper } from '@utils/eventsHelper'; import { assert } from '@isomorphic/assert'; import { calculateSha1 } from '@utils/crypto'; import { monotonicTime } from '@isomorphic/time'; -import { getPlaywrightVersion } from '@utils/userAgent'; import { isTextualMimeType } from '@isomorphic/mimeType'; import { urlMatches } from '@isomorphic/urlMatch'; +import { getPlaywrightVersion } from '../userAgent'; import { BrowserContext } from '../browserContext'; import { APIRequestContext } from '../fetch'; import { Frame } from '../frames'; diff --git a/packages/playwright-core/src/server/index.ts b/packages/playwright-core/src/server/index.ts index 50b78bf74b2f4..194e61817385a 100644 --- a/packages/playwright-core/src/server/index.ts +++ b/packages/playwright-core/src/server/index.ts @@ -26,9 +26,9 @@ export { Page } from './page'; export { createPlaywright } from './playwright'; export { nullProgress } from './progress'; export { WebSocketTransport } from './transport'; +export { installRootRedirect, openTraceInBrowser, openTraceViewerApp, startTraceViewerServer, runTraceViewerApp } from './trace/viewer/traceViewer'; export type { DispatcherScope } from './dispatchers/dispatcher'; export type { Frame } from './frames'; export type { Playwright } from './playwright'; export type { TraceViewerRedirectOptions, TraceViewerServerOptions } from './trace/viewer/traceViewer'; -export { installRootRedirect, openTraceInBrowser, openTraceViewerApp, startTraceViewerServer, runTraceViewerApp } from './trace/viewer/traceViewer'; diff --git a/packages/playwright-core/src/server/recorder/DEPS.list b/packages/playwright-core/src/server/recorder/DEPS.list index 2f7a6575bece3..da2c4f3372797 100644 --- a/packages/playwright-core/src/server/recorder/DEPS.list +++ b/packages/playwright-core/src/server/recorder/DEPS.list @@ -1,12 +1,11 @@ [*] +@isomorphic/** +@utils/** ../ ../codegen/language.ts ../codegen/languages.ts -../isomorphic/** ../registry/** -../utils/** ../../generated/pollingRecorderSource.ts ../../package.ts ../../protocol/ -../../utils/** node_modules/mime diff --git a/packages/playwright-core/src/server/registry/DEPS.list b/packages/playwright-core/src/server/registry/DEPS.list index c073ba8febe17..a6f38b8e7591b 100644 --- a/packages/playwright-core/src/server/registry/DEPS.list +++ b/packages/playwright-core/src/server/registry/DEPS.list @@ -1,9 +1,9 @@ [*] -../../package.ts -../../utils/** +@utils/** @isomorphic/** ../../utilsBundle.ts -../utils/** -./ +../../package.ts +../utils.ts +../userAgent.ts node_modules/colors/safe node_modules/progress diff --git a/packages/playwright-core/src/server/registry/browserFetcher.ts b/packages/playwright-core/src/server/registry/browserFetcher.ts index b2a6638b11bfb..107b0917a80c5 100644 --- a/packages/playwright-core/src/server/registry/browserFetcher.ts +++ b/packages/playwright-core/src/server/registry/browserFetcher.ts @@ -24,8 +24,8 @@ import ProgressBar from 'progress'; import colors from 'colors/safe'; import { ManualPromise } from '@isomorphic/manualPromise'; import { debugLogger } from '@utils/debugLogger'; -import { getUserAgent } from '@utils/userAgent'; import { existsAsync, removeFolders } from '@utils/fileUtils'; +import { getUserAgent } from '../userAgent'; import { libPath } from '../../package'; import { browserDirectoryToMarkerFilePath } from '.'; diff --git a/packages/playwright-core/src/server/registry/dependencies.ts b/packages/playwright-core/src/server/registry/dependencies.ts index 658cfd48d72bf..48e96f58c900a 100644 --- a/packages/playwright-core/src/server/registry/dependencies.ts +++ b/packages/playwright-core/src/server/registry/dependencies.ts @@ -22,7 +22,7 @@ import path from 'path'; import { wrapInASCIIBox } from '@utils/ascii'; import { hostPlatform, isOfficiallySupportedPlatform } from '@utils/hostPlatform'; import { spawnAsync } from '@utils/spawnAsync'; -import { getPlaywrightVersion } from '@utils/userAgent'; +import { getPlaywrightVersion } from '../userAgent'; import { deps } from './nativeDeps'; import { packageJSON, binPath } from '../../package'; diff --git a/packages/playwright-core/src/server/registry/index.ts b/packages/playwright-core/src/server/registry/index.ts index 02eb1335d770f..4248759086d74 100644 --- a/packages/playwright-core/src/server/registry/index.ts +++ b/packages/playwright-core/src/server/registry/index.ts @@ -23,13 +23,14 @@ import * as util from 'util'; import { wrapInASCIIBox } from '@utils/ascii'; import { debugLogger } from '@utils/debugLogger'; import { shortPlatform, hostPlatform, isOfficiallySupportedPlatform } from '@utils/hostPlatform'; -import { fetchData, NET_DEFAULT_TIMEOUT } from '@utils/network'; +import { NET_DEFAULT_TIMEOUT } from '@utils/network'; import { spawnAsync } from '@utils/spawnAsync'; -import { getEmbedderName } from '@utils/userAgent'; import { canAccessFile, existsAsync, removeFolders } from '@utils/fileUtils'; import { calculateSha1 } from '@utils/crypto'; import { getAsBooleanFromENV, getFromENV, getPackageManagerExecCommand } from '@utils/env'; import { lock } from '@utils/third_party/lockfile'; +import { fetchData } from '../utils'; +import { getEmbedderName } from '../userAgent'; import { installDependenciesLinux, installDependenciesWindows, validateDependenciesLinux, validateDependenciesWindows } from './dependencies'; import { dockerVersion, readDockerVersionSync, transformCommandsForRoot } from './dependencies'; import { downloadBrowserWithProgressBar, logPolitely } from './browserFetcher'; diff --git a/packages/playwright-core/src/server/socksClientCertificatesInterceptor.ts b/packages/playwright-core/src/server/socksClientCertificatesInterceptor.ts index 90ffb72194e2e..fea2a0df53db2 100644 --- a/packages/playwright-core/src/server/socksClientCertificatesInterceptor.ts +++ b/packages/playwright-core/src/server/socksClientCertificatesInterceptor.ts @@ -22,12 +22,12 @@ import tls from 'tls'; import { getProxyForUrl } from 'proxy-from-env'; import { SocksProxy } from '@utils/socksProxy'; -import { createProxyAgent } from '@utils/network'; import { debugLogger } from '@utils/debugLogger'; import { createSocket } from '@utils/happyEyeballs'; import { escapeHTML } from '@isomorphic/stringUtils'; import { generateSelfSignedCertificate } from '@utils/crypto'; import { rewriteErrorMessage } from '@isomorphic/stackTrace'; +import { createProxyAgent } from '@utils/network'; import { verifyClientCertificates } from './browserContext'; import type * as types from './types'; import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from '@utils/socksProxy'; diff --git a/packages/playwright-core/src/server/trace/recorder/DEPS.list b/packages/playwright-core/src/server/trace/recorder/DEPS.list index 20c549c7c0ca1..8f4dddaa6e558 100644 --- a/packages/playwright-core/src/server/trace/recorder/DEPS.list +++ b/packages/playwright-core/src/server/trace/recorder/DEPS.list @@ -1,8 +1,9 @@ [*] +@isomorphic/** +@utils/** ../../ ../../har/ ../../../protocol/ -@isomorphic/** ../../dispatchers/dispatcher.ts ../../utils ../common/ diff --git a/packages/playwright-core/src/server/trace/recorder/tracing.ts b/packages/playwright-core/src/server/trace/recorder/tracing.ts index 231bd9019eef2..452f31329461b 100644 --- a/packages/playwright-core/src/server/trace/recorder/tracing.ts +++ b/packages/playwright-core/src/server/trace/recorder/tracing.ts @@ -24,8 +24,9 @@ import { monotonicTime } from '@isomorphic/time'; import { ManualPromise } from '@isomorphic/manualPromise'; import { eventsHelper } from '@utils/eventsHelper'; import { createGuid } from '@utils/crypto'; -import { getPlaywrightVersion } from '@utils/userAgent'; -import { SerializedFS, removeFolders } from '@utils/fileUtils'; +import { removeFolders } from '@utils/fileUtils'; +import { SerializedFS } from '@utils/serializedFS'; +import { getPlaywrightVersion } from '../../userAgent'; import { Snapshotter } from './snapshotter'; import { Artifact } from '../../artifact'; import { BrowserContext } from '../../browserContext'; diff --git a/packages/playwright-core/src/server/trace/viewer/DEPS.list b/packages/playwright-core/src/server/trace/viewer/DEPS.list index fbb5428e46001..b667fa3405f7b 100644 --- a/packages/playwright-core/src/server/trace/viewer/DEPS.list +++ b/packages/playwright-core/src/server/trace/viewer/DEPS.list @@ -1,8 +1,8 @@ [*] ../../ -../../utils/** +@utils/** ../../registry/ ../../../generated/ ../../../package.ts -../../../utils/** +@utils/** node_modules/open diff --git a/packages/playwright-core/src/server/types.ts b/packages/playwright-core/src/server/types.ts index 08c04be8ecef0..8b663e51efe03 100644 --- a/packages/playwright-core/src/server/types.ts +++ b/packages/playwright-core/src/server/types.ts @@ -18,6 +18,7 @@ import type { HeadersArray, Point, Size } from '@isomorphic/types'; export type { HeadersArray, Point, Quad, Rect, Size } from '@isomorphic/types'; import type * as channels from '@protocol/channels'; +import type { ProxySettings } from '@utils/network'; export type StrictOptions = { strict?: boolean, @@ -101,13 +102,7 @@ export type DeviceDescriptor = { defaultBrowserType: 'chromium' | 'firefox' | 'webkit' }; export type Devices = { [name: string]: DeviceDescriptor }; - -export type ProxySettings = { - server: string, - bypass?: string, - username?: string, - password?: string -}; +export type { ProxySettings } from '@utils/network'; export type KeyboardModifier = 'Alt' | 'Control' | 'Meta' | 'Shift'; export type SmartKeyboardModifier = KeyboardModifier | 'ControlOrMeta'; diff --git a/packages/playwright-core/src/server/utils/userAgent.ts b/packages/playwright-core/src/server/userAgent.ts similarity index 96% rename from packages/playwright-core/src/server/utils/userAgent.ts rename to packages/playwright-core/src/server/userAgent.ts index 25e930453b4b6..bc8069dcd4a7e 100644 --- a/packages/playwright-core/src/server/utils/userAgent.ts +++ b/packages/playwright-core/src/server/userAgent.ts @@ -17,8 +17,8 @@ import { execSync } from 'child_process'; import os from 'os'; -import { packageJSON } from '../../package'; -import { getLinuxDistributionInfoSync } from '../utils/linuxUtils'; +import { getLinuxDistributionInfoSync } from '@utils/linuxUtils'; +import { packageJSON } from '../package'; let cachedUserAgent: string | undefined; diff --git a/packages/playwright-core/src/server/utils.ts b/packages/playwright-core/src/server/utils.ts new file mode 100644 index 0000000000000..b9097960990d6 --- /dev/null +++ b/packages/playwright-core/src/server/utils.ts @@ -0,0 +1,45 @@ +/** + * 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. + */ + +import http from 'http'; +import { ManualPromise } from '@isomorphic/manualPromise'; +import { httpRequest } from '@utils/network'; + +import type { HTTPRequestParams } from '@utils/network'; +import type { Progress } from './progress'; + +export async function fetchData(progress: Progress | undefined, params: HTTPRequestParams, onError?: (params: HTTPRequestParams, response: http.IncomingMessage) => Promise): Promise { + const promise = new ManualPromise(); + const { cancel } = httpRequest(params, async response => { + if (response.statusCode !== 200) { + const error = onError ? await onError(params, response) : new Error(`fetch failed: server returned code ${response.statusCode}. URL: ${params.url}`); + promise.reject(error); + return; + } + let body = ''; + response.on('data', (chunk: string) => body += chunk); + response.on('error', (error: any) => promise.reject(error)); + response.on('end', () => promise.resolve(body)); + }, error => promise.reject(error)); + if (!progress) + return promise; + try { + return await progress.race(promise); + } catch (error) { + cancel(error); + throw error; + } +} diff --git a/packages/playwright-core/src/tools/backend/DEPS.list b/packages/playwright-core/src/tools/backend/DEPS.list index a7f42394ab32b..0e9ba37d4584f 100644 --- a/packages/playwright-core/src/tools/backend/DEPS.list +++ b/packages/playwright-core/src/tools/backend/DEPS.list @@ -2,7 +2,7 @@ ../../.. ../.. @utils/** -../../utils/** +@utils/** @isomorphic/** ../utils/** node_modules/@modelcontextprotocol/sdk/types.js diff --git a/packages/playwright-core/src/tools/cli-daemon/DEPS.list b/packages/playwright-core/src/tools/cli-daemon/DEPS.list index f935c1e3d9052..9362d7c6587e5 100644 --- a/packages/playwright-core/src/tools/cli-daemon/DEPS.list +++ b/packages/playwright-core/src/tools/cli-daemon/DEPS.list @@ -5,7 +5,7 @@ ../backend/ ../mcp/ ../../utilsBundle.ts -../../utils/** +@utils/** ../../server/registry/index.ts @utils/** ../../serverRegistry.ts diff --git a/packages/playwright-core/src/tools/dashboard/DEPS.list b/packages/playwright-core/src/tools/dashboard/DEPS.list index 11da601b9e881..d6d3af79f7661 100644 --- a/packages/playwright-core/src/tools/dashboard/DEPS.list +++ b/packages/playwright-core/src/tools/dashboard/DEPS.list @@ -5,6 +5,6 @@ ../../server/registry/index.ts @utils/** ../../serverRegistry.ts -../../utils/** +@utils/** ../cli-client/registry.ts ../utils/** diff --git a/packages/playwright-core/src/tools/mcp/DEPS.list b/packages/playwright-core/src/tools/mcp/DEPS.list index 54e62c13c4fa5..4e148131bb74b 100644 --- a/packages/playwright-core/src/tools/mcp/DEPS.list +++ b/packages/playwright-core/src/tools/mcp/DEPS.list @@ -3,7 +3,7 @@ ../../ ../utils/mcp/ ../backend/ -../../utils/** +@utils/** @isomorphic/** ../../utilsBundle.ts ../../server/ diff --git a/packages/playwright-core/src/tools/utils/mcp/DEPS.list b/packages/playwright-core/src/tools/utils/mcp/DEPS.list index cf776078ddcf4..f5833b09a35c3 100644 --- a/packages/playwright-core/src/tools/utils/mcp/DEPS.list +++ b/packages/playwright-core/src/tools/utils/mcp/DEPS.list @@ -1,5 +1,5 @@ [*] -@utils/network.ts +@utils/** node_modules/@modelcontextprotocol/sdk/server/index.js node_modules/@modelcontextprotocol/sdk/server/sse.js node_modules/@modelcontextprotocol/sdk/server/stdio.js diff --git a/packages/playwright-core/src/utilsBundle.ts b/packages/playwright-core/src/utilsBundle.ts index b36605bb0cd1c..3d70e0eb1d08b 100644 --- a/packages/playwright-core/src/utilsBundle.ts +++ b/packages/playwright-core/src/utilsBundle.ts @@ -14,8 +14,6 @@ * limitations under the License. */ -/* eslint-disable import/order */ - import colorsLibrary from 'colors/safe'; export const colors = colorsLibrary; @@ -102,6 +100,12 @@ export const onExit = onExitLibrary; import getStreamLibrary from 'get-stream'; export const getStream = getStreamLibrary; +import httpProxyAgentLibrary from 'https-proxy-agent'; +export const httpProxyAgent = httpProxyAgentLibrary; + +import socksProxyAgentLibrary from 'socks-proxy-agent'; +export const socksProxyAgent = socksProxyAgentLibrary; + export * as z from 'zod'; export { Client } from '@modelcontextprotocol/sdk/client/index.js'; diff --git a/packages/playwright-ct-core/src/vitePlugin.ts b/packages/playwright-ct-core/src/vitePlugin.ts index 488d0156238c1..0228b2e2600d0 100644 --- a/packages/playwright-ct-core/src/vitePlugin.ts +++ b/packages/playwright-ct-core/src/vitePlugin.ts @@ -17,7 +17,7 @@ import fs from 'fs'; import path from 'path'; -import { iso, utils } from 'playwright-core/lib/coreBundle'; +import { iso, utils, getPlaywrightVersion } from 'playwright-core/lib/coreBundle'; import { colors, debug, stoppable } from 'playwright-core/lib/utilsBundle'; import { cc, transform } from 'playwright/lib/common'; import { removeDirAndLogToConsole } from 'playwright/lib/util'; @@ -38,7 +38,7 @@ import type { ComponentRegistry } from './viteUtils'; const log = debug('pw:vite'); let stoppableServer: any; -const playwrightVersion = utils.getPlaywrightVersion(); +const playwrightVersion = getPlaywrightVersion(); export function createPlugin(): TestRunnerPlugin { let configDir: string; diff --git a/packages/playwright/ThirdPartyNotices.txt b/packages/playwright/ThirdPartyNotices.txt index 69ef51375dfce..f9ee0a552ec42 100644 --- a/packages/playwright/ThirdPartyNotices.txt +++ b/packages/playwright/ThirdPartyNotices.txt @@ -10,3 +10,5 @@ bundle, together with the full license text for each. For example: - lib/common/index.js.LICENSE - lib/matchers/expect.js.LICENSE + +This project incorporates components from the projects listed below. The original copyright notices and the licenses under which Microsoft received such components are set forth below. Microsoft reserves all rights not expressly granted herein, whether by implication, estoppel or otherwise. diff --git a/packages/playwright/src/common/testType.ts b/packages/playwright/src/common/testType.ts index 293fbf54faad0..f08eb29b7ee01 100644 --- a/packages/playwright/src/common/testType.ts +++ b/packages/playwright/src/common/testType.ts @@ -14,8 +14,6 @@ * limitations under the License. */ -import { errors } from 'playwright-core'; - import { monotonicTime } from '@isomorphic/time'; import { raceAgainstDeadline } from '@isomorphic/timeoutRunner'; import { getPackageManagerExecCommand } from '@utils/env'; @@ -294,7 +292,7 @@ export class TestTypeImpl { } }, options.timeout ? monotonicTime() + options.timeout : 0); if (result.timedOut) - throw new errors.TimeoutError(`Step timeout of ${options.timeout}ms exceeded.`); + throw new TimeoutError(`Step timeout of ${options.timeout}ms exceeded.`); step.complete({}); return result.result; } catch (error) { @@ -339,3 +337,10 @@ export function mergeTests(...tests: TestType[]) { } return result.test; } + +class TimeoutError extends Error { + constructor(message: string) { + super(message); + this.name = 'TimeoutError'; + } +} diff --git a/packages/playwright/src/reporters/blob.ts b/packages/playwright/src/reporters/blob.ts index 25bc6e31d0d43..9590a9e1b2489 100644 --- a/packages/playwright/src/reporters/blob.ts +++ b/packages/playwright/src/reporters/blob.ts @@ -23,7 +23,7 @@ import * as yazl from 'yazl'; import { ManualPromise } from '@isomorphic/manualPromise'; import { calculateSha1, createGuid } from '@utils/crypto'; import { removeFolders, sanitizeForFilePath } from '@utils/fileUtils'; -import { getUserAgent } from '@utils/userAgent'; +import { getUserAgent } from 'playwright-core/lib/coreBundle'; import { resolveOutputFile, CommonReporterOptions } from './base'; import { TeleReporterEmitter } from './teleEmitter'; diff --git a/packages/playwright/src/runner/testServer.ts b/packages/playwright/src/runner/testServer.ts index 8e74453ff62de..e5cb70a98e5cd 100644 --- a/packages/playwright/src/runner/testServer.ts +++ b/packages/playwright/src/runner/testServer.ts @@ -15,10 +15,10 @@ */ import util from 'util'; - -import { sever } from 'playwright-core/lib/coreBundle'; import debug from 'debug'; import open from 'open'; + +import { server as coreServer } from 'playwright-core/lib/coreBundle'; import { ManualPromise } from '@isomorphic/manualPromise'; import { isUnderTest } from '@utils/debug'; import { HttpServer } from '@utils/httpServer'; @@ -38,8 +38,8 @@ import type { ConfigLocation } from '../common'; import type { ReportEntry, TestServerInterface, TestServerInterfaceEventEmitters } from '../isomorphic/testServerInterface'; import type { ReporterV2 } from '../reporters/reporterV2'; -type TraceViewerRedirectOptions = sever.TraceViewerRedirectOptions; -type TraceViewerServerOptions = sever.TraceViewerServerOptions; +type TraceViewerRedirectOptions = coreServer.TraceViewerRedirectOptions; +type TraceViewerServerOptions = coreServer.TraceViewerServerOptions; const originalDebugLog = debug.log; // eslint-disable-next-line no-restricted-properties @@ -61,7 +61,7 @@ class TestServer { async start(options: { host?: string, port?: number }): Promise { this._dispatcher = new TestServerDispatcher(this._configLocation, this._configCLIOverrides); - return await sever.startTraceViewerServer({ ...options, transport: this._dispatcher.transport }); + return await coreServer.startTraceViewerServer({ ...options, transport: this._dispatcher.transport }); } async stop() { @@ -263,12 +263,12 @@ export class TestServerDispatcher implements TestServerInterface { export async function runUIMode(configFile: string | undefined, configCLIOverrides: ipc.ConfigCLIOverrides, options: TraceViewerServerOptions & TraceViewerRedirectOptions): Promise { const configLocation = configLoader.resolveConfigLocation(configFile); return await innerRunTestServer(configLocation, configCLIOverrides, options, async (server: HttpServer, cancelPromise: ManualPromise) => { - await sever.installRootRedirect(server, undefined, { ...options, webApp: 'uiMode.html' }); + await coreServer.installRootRedirect(server, undefined, { ...options, webApp: 'uiMode.html' }); if (options.host !== undefined || options.port !== undefined) { - await sever.openTraceInBrowser(server.urlPrefix('human-readable')); + await coreServer.openTraceInBrowser(server.urlPrefix('human-readable')); } else { const channel = await installedChromiumChannelForUI(configLocation, configCLIOverrides); - const page = await sever.openTraceViewerApp(server.urlPrefix('precise'), 'chromium', { + const page = await coreServer.openTraceViewerApp(server.urlPrefix('precise'), 'chromium', { headless: isUnderTest() && process.env.PWTEST_HEADED_FOR_TEST !== '1', persistentContextOptions: { handleSIGINT: false, diff --git a/packages/playwright/src/worker/testTracing.ts b/packages/playwright/src/worker/testTracing.ts index 22d98fa5afb29..303ec1a66d3af 100644 --- a/packages/playwright/src/worker/testTracing.ts +++ b/packages/playwright/src/worker/testTracing.ts @@ -22,8 +22,8 @@ import * as yauzl from 'yauzl'; import { ManualPromise } from '@isomorphic/manualPromise'; import { monotonicTime } from '@isomorphic/time'; import { calculateSha1, createGuid } from '@utils/crypto'; -import { SerializedFS } from '@utils/fileUtils'; -import { getPlaywrightVersion } from '@utils/userAgent'; +import { SerializedFS } from '@utils/serializedFS'; +import { getPlaywrightVersion } from 'playwright-core/lib/coreBundle'; import { filteredStackTrace } from '../util'; diff --git a/packages/recorder/src/recorderTypes.d.ts b/packages/recorder/src/recorderTypes.d.ts index 0b65768d1b9c8..512905f754e99 100644 --- a/packages/recorder/src/recorderTypes.d.ts +++ b/packages/recorder/src/recorderTypes.d.ts @@ -14,7 +14,7 @@ limitations under the License. */ -import type { Language } from '../../playwright-core/src/utils/isomorphic/locatorGenerators'; +import type { Language } from '@isomorphic/locatorGenerators'; import type { AriaTemplateNode } from '@isomorphic/ariaSnapshot'; export type Point = { x: number; y: number }; diff --git a/packages/recorder/vite.config.ts b/packages/recorder/vite.config.ts index b26956d0425b3..921cb4b575c34 100644 --- a/packages/recorder/vite.config.ts +++ b/packages/recorder/vite.config.ts @@ -26,7 +26,7 @@ export default defineConfig({ ], resolve: { alias: { - '@isomorphic': path.resolve(__dirname, '../playwright-core/src/utils/isomorphic'), + '@isomorphic': path.resolve(__dirname, '../isomorphic'), '@protocol': path.resolve(__dirname, '../protocol/src'), '@web': path.resolve(__dirname, '../web/src'), }, diff --git a/packages/trace-viewer/vite.config.ts b/packages/trace-viewer/vite.config.ts index 1d6ceb1fe4a1f..f88f723d05f7c 100644 --- a/packages/trace-viewer/vite.config.ts +++ b/packages/trace-viewer/vite.config.ts @@ -35,7 +35,7 @@ export default defineConfig({ resolve: { alias: { '@injected': path.resolve(__dirname, '../injected/src'), - '@isomorphic': path.resolve(__dirname, '../playwright-core/src/utils/isomorphic'), + '@isomorphic': path.resolve(__dirname, '../isomorphic'), '@protocol': path.resolve(__dirname, '../protocol/src'), '@testIsomorphic': path.resolve(__dirname, '../playwright/src/isomorphic'), '@trace': path.resolve(__dirname, '../trace/src'), diff --git a/packages/trace-viewer/vite.sw.config.ts b/packages/trace-viewer/vite.sw.config.ts index 6f55ec04cee9c..1c53ac27db404 100644 --- a/packages/trace-viewer/vite.sw.config.ts +++ b/packages/trace-viewer/vite.sw.config.ts @@ -30,9 +30,9 @@ export default defineConfig({ ], resolve: { alias: { - '@isomorphic': path.resolve(__dirname, '../playwright-core/src/utils/isomorphic'), + '@isomorphic': path.resolve(__dirname, '../isomorphic'), '@protocol': path.resolve(__dirname, '../protocol/src'), - '@testIsomorphic': path.resolve(__dirname, '../playwright-core/src/utils/testIsomorphic'), + '@testIsomorphic': path.resolve(__dirname, '../playwright/src/isomorphic'), '@trace': path.resolve(__dirname, '../trace/src'), '@web': path.resolve(__dirname, '../web/src'), }, diff --git a/packages/playwright-core/src/server/utils/DEPS.list b/packages/utils/DEPS.list similarity index 94% rename from packages/playwright-core/src/server/utils/DEPS.list rename to packages/utils/DEPS.list index 3985396fedf0d..6567ca502c06d 100644 --- a/packages/playwright-core/src/server/utils/DEPS.list +++ b/packages/utils/DEPS.list @@ -22,4 +22,4 @@ node_modules/yazl [comparators.ts] ./image_tools -../../third_party/pixelmatch +./third_party/pixelmatch diff --git a/packages/playwright-core/src/server/utils/ascii.ts b/packages/utils/ascii.ts similarity index 100% rename from packages/playwright-core/src/server/utils/ascii.ts rename to packages/utils/ascii.ts diff --git a/packages/playwright-core/src/server/utils/comparators.ts b/packages/utils/comparators.ts similarity index 99% rename from packages/playwright-core/src/server/utils/comparators.ts rename to packages/utils/comparators.ts index bfd8bae4da557..8e76ad0342136 100644 --- a/packages/playwright-core/src/server/utils/comparators.ts +++ b/packages/utils/comparators.ts @@ -21,7 +21,7 @@ import * as diff from 'diff'; import { PNG } from 'pngjs'; import { padImageToSize } from '@isomorphic/imageUtils'; // @ts-ignore -import pixelmatch from '../../third_party/pixelmatch'; +import pixelmatch from './third_party/pixelmatch'; import { compare } from './image_tools/compare'; import type { ImageData } from '@isomorphic/imageUtils'; diff --git a/packages/playwright-core/src/server/utils/crypto.ts b/packages/utils/crypto.ts similarity index 100% rename from packages/playwright-core/src/server/utils/crypto.ts rename to packages/utils/crypto.ts diff --git a/packages/playwright-core/src/server/utils/debug.ts b/packages/utils/debug.ts similarity index 100% rename from packages/playwright-core/src/server/utils/debug.ts rename to packages/utils/debug.ts diff --git a/packages/playwright-core/src/server/utils/debugLogger.ts b/packages/utils/debugLogger.ts similarity index 100% rename from packages/playwright-core/src/server/utils/debugLogger.ts rename to packages/utils/debugLogger.ts diff --git a/packages/playwright-core/src/server/utils/disposable.ts b/packages/utils/disposable.ts similarity index 100% rename from packages/playwright-core/src/server/utils/disposable.ts rename to packages/utils/disposable.ts diff --git a/packages/playwright-core/src/server/utils/env.ts b/packages/utils/env.ts similarity index 100% rename from packages/playwright-core/src/server/utils/env.ts rename to packages/utils/env.ts diff --git a/packages/playwright-core/src/server/utils/eventsHelper.ts b/packages/utils/eventsHelper.ts similarity index 100% rename from packages/playwright-core/src/server/utils/eventsHelper.ts rename to packages/utils/eventsHelper.ts diff --git a/packages/utils/fileUtils.ts b/packages/utils/fileUtils.ts new file mode 100644 index 0000000000000..37d0549b3c1aa --- /dev/null +++ b/packages/utils/fileUtils.ts @@ -0,0 +1,76 @@ +/** + * 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. + */ + +import fs from 'fs'; +import os from 'os'; +import path from 'path'; + +import { calculateSha1 } from './crypto'; + +export const existsAsync = (path: string): Promise => new Promise(resolve => fs.stat(path, err => resolve(!err))); + +export async function mkdirIfNeeded(filePath: string) { + // This will harmlessly throw on windows if the dirname is the root directory. + await fs.promises.mkdir(path.dirname(filePath), { recursive: true }).catch(() => {}); +} + +export async function removeFolders(dirs: string[]): Promise<(Error| undefined)[]> { + return await Promise.all(dirs.map((dir: string) => + fs.promises.rm(dir, { recursive: true, force: true, maxRetries: 10 }).catch(e => e) + )); +} + +export function canAccessFile(file: string) { + if (!file) + return false; + + try { + fs.accessSync(file); + return true; + } catch (e) { + return false; + } +} + +export async function copyFileAndMakeWritable(from: string, to: string) { + await fs.promises.copyFile(from, to); + await fs.promises.chmod(to, 0o664); +} + +export function addSuffixToFilePath(filePath: string, suffix: string): string { + const ext = path.extname(filePath); + const base = filePath.substring(0, filePath.length - ext.length); + return base + suffix + ext; +} + +export function sanitizeForFilePath(s: string) { + return s.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, '-'); +} + +export function toPosixPath(aPath: string): string { + return aPath.split(path.sep).join(path.posix.sep); +} + +export function makeSocketPath(domain: string, name: string): string { + const userNameHash = calculateSha1(process.env.USERNAME || process.env.USER || 'default').slice(0, 8); + if (process.platform === 'win32') + return `\\\\.\\pipe\\pw-${userNameHash}-${domain}-${name}`; + const baseDir = process.env.PLAYWRIGHT_SOCKETS_DIR || path.join(os.tmpdir(), `pw-${userNameHash}`); + const dir = path.join(baseDir, domain); + const result = path.join(dir, `${name}.sock`); + fs.mkdirSync(dir, { recursive: true }); + return result; +} diff --git a/packages/playwright-core/src/server/utils/happyEyeballs.ts b/packages/utils/happyEyeballs.ts similarity index 100% rename from packages/playwright-core/src/server/utils/happyEyeballs.ts rename to packages/utils/happyEyeballs.ts diff --git a/packages/playwright-core/src/server/utils/hostPlatform.ts b/packages/utils/hostPlatform.ts similarity index 100% rename from packages/playwright-core/src/server/utils/hostPlatform.ts rename to packages/utils/hostPlatform.ts diff --git a/packages/playwright-core/src/server/utils/httpServer.ts b/packages/utils/httpServer.ts similarity index 100% rename from packages/playwright-core/src/server/utils/httpServer.ts rename to packages/utils/httpServer.ts diff --git a/packages/playwright-core/src/server/utils/image_tools/colorUtils.ts b/packages/utils/image_tools/colorUtils.ts similarity index 100% rename from packages/playwright-core/src/server/utils/image_tools/colorUtils.ts rename to packages/utils/image_tools/colorUtils.ts diff --git a/packages/playwright-core/src/server/utils/image_tools/compare.ts b/packages/utils/image_tools/compare.ts similarity index 100% rename from packages/playwright-core/src/server/utils/image_tools/compare.ts rename to packages/utils/image_tools/compare.ts diff --git a/packages/playwright-core/src/server/utils/image_tools/imageChannel.ts b/packages/utils/image_tools/imageChannel.ts similarity index 100% rename from packages/playwright-core/src/server/utils/image_tools/imageChannel.ts rename to packages/utils/image_tools/imageChannel.ts diff --git a/packages/playwright-core/src/server/utils/image_tools/stats.ts b/packages/utils/image_tools/stats.ts similarity index 100% rename from packages/playwright-core/src/server/utils/image_tools/stats.ts rename to packages/utils/image_tools/stats.ts diff --git a/packages/playwright-core/src/server/utils/index.ts b/packages/utils/index.ts similarity index 97% rename from packages/playwright-core/src/server/utils/index.ts rename to packages/utils/index.ts index 4574fb6e18262..b2e95d7651765 100644 --- a/packages/playwright-core/src/server/utils/index.ts +++ b/packages/utils/index.ts @@ -28,10 +28,10 @@ export * from './network'; export * from './nodePlatform'; export * from './processLauncher'; export * from './profiler'; +export * from './serializedFS'; export * from './socksProxy'; export * from './spawnAsync'; export * from './task'; -export * from './userAgent'; export * from './wsServer'; export * from './zipFile'; export * from './zones'; diff --git a/packages/playwright-core/src/server/utils/linuxUtils.ts b/packages/utils/linuxUtils.ts similarity index 100% rename from packages/playwright-core/src/server/utils/linuxUtils.ts rename to packages/utils/linuxUtils.ts diff --git a/packages/playwright-core/src/server/utils/network.ts b/packages/utils/network.ts similarity index 89% rename from packages/playwright-core/src/server/utils/network.ts rename to packages/utils/network.ts index c23eacb61fd81..c21027290b906 100644 --- a/packages/playwright-core/src/server/utils/network.ts +++ b/packages/utils/network.ts @@ -26,8 +26,13 @@ import { ManualPromise } from '@isomorphic/manualPromise'; import { httpHappyEyeballsAgent, httpsHappyEyeballsAgent } from './happyEyeballs'; import type net from 'net'; -import type { ProxySettings } from '../types'; -import type { Progress } from '../progress'; + +export type ProxySettings = { + server: string, + bypass?: string, + username?: string, + password?: string +}; export type HTTPRequestParams = { url: string, @@ -94,29 +99,6 @@ export function httpRequest(params: HTTPRequestParams, onResponse: (r: http.Inco return { cancel: e => cancelRequest(e) }; } -export async function fetchData(progress: Progress | undefined, params: HTTPRequestParams, onError?: (params: HTTPRequestParams, response: http.IncomingMessage) => Promise): Promise { - const promise = new ManualPromise(); - const { cancel } = httpRequest(params, async response => { - if (response.statusCode !== 200) { - const error = onError ? await onError(params, response) : new Error(`fetch failed: server returned code ${response.statusCode}. URL: ${params.url}`); - promise.reject(error); - return; - } - let body = ''; - response.on('data', (chunk: string) => body += chunk); - response.on('error', (error: any) => promise.reject(error)); - response.on('end', () => promise.resolve(body)); - }, error => promise.reject(error)); - if (!progress) - return promise; - try { - return await progress.race(promise); - } catch (error) { - cancel(error); - throw error; - } -} - function shouldBypassProxy(url: URL, bypass?: string): boolean { if (!bypass) return false; diff --git a/packages/playwright-core/src/server/utils/nodePlatform.ts b/packages/utils/nodePlatform.ts similarity index 96% rename from packages/playwright-core/src/server/utils/nodePlatform.ts rename to packages/utils/nodePlatform.ts index 4468d888d3350..9c3f8b38f65c8 100644 --- a/packages/playwright-core/src/server/utils/nodePlatform.ts +++ b/packages/utils/nodePlatform.ts @@ -25,9 +25,8 @@ import colors from 'colors/safe'; import { debugLogger } from './debugLogger'; import { currentZone, emptyZone } from './zones'; import { debugMode, isUnderTest } from './debug'; -import { packageRoot as coreDir } from '../../package'; -import type { Platform, Zone } from '../../client/platform'; +import type { Platform, Zone } from '@isomorphic/platform'; import type { Zone as ZoneImpl } from './zones'; import type * as channels from '@protocol/channels'; @@ -62,7 +61,7 @@ export function setBoxedStackPrefixes(prefixes: string[]) { boxedStackPrefixes = prefixes; } -export const nodePlatform: Platform = { +export const nodePlatform: (coreDir: string) => Platform = coreDir => ({ name: 'node', boxedStackPrefixes: () => { @@ -126,7 +125,7 @@ export const nodePlatform: Platform = { current: () => new NodeZone(currentZone()), empty: new NodeZone(emptyZone), } -}; +}); class ReadableStreamImpl extends Readable { private _channel: channels.StreamChannel; diff --git a/packages/playwright-core/src/server/utils/pipeTransport.ts b/packages/utils/pipeTransport.ts similarity index 100% rename from packages/playwright-core/src/server/utils/pipeTransport.ts rename to packages/utils/pipeTransport.ts diff --git a/packages/playwright-core/src/server/utils/processLauncher.ts b/packages/utils/processLauncher.ts similarity index 100% rename from packages/playwright-core/src/server/utils/processLauncher.ts rename to packages/utils/processLauncher.ts diff --git a/packages/playwright-core/src/server/utils/profiler.ts b/packages/utils/profiler.ts similarity index 100% rename from packages/playwright-core/src/server/utils/profiler.ts rename to packages/utils/profiler.ts diff --git a/packages/playwright-core/src/server/utils/fileUtils.ts b/packages/utils/serializedFS.ts similarity index 72% rename from packages/playwright-core/src/server/utils/fileUtils.ts rename to packages/utils/serializedFS.ts index 9a4e60922f5d8..711d13126ab2d 100644 --- a/packages/playwright-core/src/server/utils/fileUtils.ts +++ b/packages/utils/serializedFS.ts @@ -15,70 +15,12 @@ */ import fs from 'fs'; -import os from 'os'; -import path from 'path'; import * as yazl from 'yazl'; import { ManualPromise } from '@isomorphic/manualPromise'; -import { calculateSha1 } from './crypto'; import type { EventEmitter } from 'events'; -export const existsAsync = (path: string): Promise => new Promise(resolve => fs.stat(path, err => resolve(!err))); - -export async function mkdirIfNeeded(filePath: string) { - // This will harmlessly throw on windows if the dirname is the root directory. - await fs.promises.mkdir(path.dirname(filePath), { recursive: true }).catch(() => {}); -} - -export async function removeFolders(dirs: string[]): Promise<(Error| undefined)[]> { - return await Promise.all(dirs.map((dir: string) => - fs.promises.rm(dir, { recursive: true, force: true, maxRetries: 10 }).catch(e => e) - )); -} - -export function canAccessFile(file: string) { - if (!file) - return false; - - try { - fs.accessSync(file); - return true; - } catch (e) { - return false; - } -} - -export async function copyFileAndMakeWritable(from: string, to: string) { - await fs.promises.copyFile(from, to); - await fs.promises.chmod(to, 0o664); -} - -export function addSuffixToFilePath(filePath: string, suffix: string): string { - const ext = path.extname(filePath); - const base = filePath.substring(0, filePath.length - ext.length); - return base + suffix + ext; -} - -export function sanitizeForFilePath(s: string) { - return s.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, '-'); -} - -export function toPosixPath(aPath: string): string { - return aPath.split(path.sep).join(path.posix.sep); -} - -export function makeSocketPath(domain: string, name: string): string { - const userNameHash = calculateSha1(process.env.USERNAME || process.env.USER || 'default').slice(0, 8); - if (process.platform === 'win32') - return `\\\\.\\pipe\\pw-${userNameHash}-${domain}-${name}`; - const baseDir = process.env.PLAYWRIGHT_SOCKETS_DIR || path.join(os.tmpdir(), `pw-${userNameHash}`); - const dir = path.join(baseDir, domain); - const result = path.join(dir, `${name}.sock`); - fs.mkdirSync(dir, { recursive: true }); - return result; -} - type NameValue = { name: string, value: string }; type SerializedFSOperation = { op: 'mkdir', dir: string, diff --git a/packages/playwright-core/src/server/utils/socksProxy.ts b/packages/utils/socksProxy.ts similarity index 100% rename from packages/playwright-core/src/server/utils/socksProxy.ts rename to packages/utils/socksProxy.ts diff --git a/packages/playwright-core/src/server/utils/spawnAsync.ts b/packages/utils/spawnAsync.ts similarity index 100% rename from packages/playwright-core/src/server/utils/spawnAsync.ts rename to packages/utils/spawnAsync.ts diff --git a/packages/playwright-core/src/server/utils/task.ts b/packages/utils/task.ts similarity index 100% rename from packages/playwright-core/src/server/utils/task.ts rename to packages/utils/task.ts diff --git a/packages/playwright-core/src/server/utils/third_party/extractZip.ts b/packages/utils/third_party/extractZip.ts similarity index 100% rename from packages/playwright-core/src/server/utils/third_party/extractZip.ts rename to packages/utils/third_party/extractZip.ts diff --git a/packages/playwright-core/src/server/utils/third_party/lockfile.ts b/packages/utils/third_party/lockfile.ts similarity index 100% rename from packages/playwright-core/src/server/utils/third_party/lockfile.ts rename to packages/utils/third_party/lockfile.ts diff --git a/packages/playwright-core/src/third_party/pixelmatch.js b/packages/utils/third_party/pixelmatch.js similarity index 100% rename from packages/playwright-core/src/third_party/pixelmatch.js rename to packages/utils/third_party/pixelmatch.js diff --git a/packages/playwright-core/src/server/utils/wsServer.ts b/packages/utils/wsServer.ts similarity index 100% rename from packages/playwright-core/src/server/utils/wsServer.ts rename to packages/utils/wsServer.ts diff --git a/packages/playwright-core/src/server/utils/zipFile.ts b/packages/utils/zipFile.ts similarity index 100% rename from packages/playwright-core/src/server/utils/zipFile.ts rename to packages/utils/zipFile.ts diff --git a/packages/playwright-core/src/server/utils/zones.ts b/packages/utils/zones.ts similarity index 100% rename from packages/playwright-core/src/server/utils/zones.ts rename to packages/utils/zones.ts diff --git a/tests/library/browsercontext-har.spec.ts b/tests/library/browsercontext-har.spec.ts index a04e3df74d696..98c3e1fe04feb 100644 --- a/tests/library/browsercontext-har.spec.ts +++ b/tests/library/browsercontext-har.spec.ts @@ -17,7 +17,7 @@ import { browserTest as it, expect } from '../config/browserTest'; import fs from 'fs'; import path from 'path'; -import { extractZip } from '../../packages/playwright-core/src/server/utils/third_party/extractZip'; +import { extractZip } from '../../packages/utils/third_party/extractZip'; it('should context.routeFromHAR, matching the method and following redirects', async ({ context, asset }) => { const path = asset('har-fulfill.har'); diff --git a/tests/library/browsercontext-viewport.spec.ts b/tests/library/browsercontext-viewport.spec.ts index 255bec61b2735..a3e4fefb42311 100644 --- a/tests/library/browsercontext-viewport.spec.ts +++ b/tests/library/browsercontext-viewport.spec.ts @@ -19,8 +19,8 @@ import { devices } from '@playwright/test'; import { contextTest as it, expect } from '../config/browserTest'; import { browserTest } from '../config/browserTest'; import { verifyViewport } from '../config/utils'; -import { sever } from '../../packages/playwright-core/lib/coreBundle'; -const { deviceDescriptors } = sever; +import { server as coreServer } from '../../packages/playwright-core/lib/coreBundle'; +const { deviceDescriptors } = coreServer; it('should get the proper default viewport size', async ({ page, server }) => { await verifyViewport(page, 1280, 720); diff --git a/tests/library/browsertype-connect.spec.ts b/tests/library/browsertype-connect.spec.ts index 5cdb2f98c993e..ee2a5b3dc462d 100644 --- a/tests/library/browsertype-connect.spec.ts +++ b/tests/library/browsertype-connect.spec.ts @@ -19,14 +19,14 @@ import fs from 'fs'; import type http from 'http'; import type net from 'net'; import * as path from 'path'; -import { utils } from '../../packages/playwright-core/lib/coreBundle'; +import { utils, getUserAgent, getPlaywrightVersion } from '../../packages/playwright-core/lib/coreBundle'; import WebSocket from 'ws'; import { expect, playwrightTest } from '../config/browserTest'; import { ensureSomeFrames, parseTraceRaw, suppressCertificateWarning } from '../config/utils'; import formidable from 'formidable'; import type { Browser, ConnectOptions } from 'playwright-core'; -const { getUserAgent, getPlaywrightVersion, createHttpServer } = utils; +const { createHttpServer } = utils; import { kTargetClosedErrorMessage } from '../config/errors'; import { RunServer } from '../config/remoteServer'; diff --git a/tests/library/chromium/connect-over-cdp.spec.ts b/tests/library/chromium/connect-over-cdp.spec.ts index b7f4434f83526..ffad00656f89b 100644 --- a/tests/library/chromium/connect-over-cdp.spec.ts +++ b/tests/library/chromium/connect-over-cdp.spec.ts @@ -18,12 +18,11 @@ import { playwrightTest as test, expect } from '../../config/browserTest'; import http from 'http'; import fs from 'fs'; -import { utils, sever } from '../../../packages/playwright-core/lib/coreBundle'; +import { getUserAgent, server as coreServer } from '../../../packages/playwright-core/lib/coreBundle'; import { suppressCertificateWarning } from '../../config/utils'; -const { getUserAgent } = utils; -const { WebSocketTransport, nullProgress } = sever; -type Frame = sever.Frame; +const { WebSocketTransport, nullProgress } = coreServer; +type Frame = coreServer.Frame; test.skip(({ mode }) => mode === 'service2'); diff --git a/tests/library/events/utils.ts b/tests/library/events/utils.ts index 3bdae7bf2e6f4..6e213792401f0 100644 --- a/tests/library/events/utils.ts +++ b/tests/library/events/utils.ts @@ -51,6 +51,6 @@ export const mustCall = (fn?: Function, exact?: number) => { /** as any breaks long TS resolution chain that makes tests unhappy */ export class EventEmitter extends (client as any).EventEmitter { constructor() { - super(nodePlatform); + super(nodePlatform(process.cwd())); } } diff --git a/tests/library/global-fetch.spec.ts b/tests/library/global-fetch.spec.ts index 9a119e06f6d41..4b57ceeddae2a 100644 --- a/tests/library/global-fetch.spec.ts +++ b/tests/library/global-fetch.spec.ts @@ -16,12 +16,10 @@ import os from 'os'; import * as util from 'util'; -import { utils } from '../../packages/playwright-core/lib/coreBundle'; +import { getPlaywrightVersion } from '../../packages/playwright-core/lib/coreBundle'; import { expect, playwrightTest as base } from '../config/browserTest'; import { kTargetClosedErrorMessage } from '../config/errors'; -const { getPlaywrightVersion } = utils; - const it = base.extend({ context: async ({}, use) => { throw new Error('global fetch tests should not use context'); diff --git a/tests/library/trace-viewer.spec.ts b/tests/library/trace-viewer.spec.ts index fd0bd0e97edd1..ad4d67d9890bd 100644 --- a/tests/library/trace-viewer.spec.ts +++ b/tests/library/trace-viewer.spec.ts @@ -19,7 +19,7 @@ import type { TraceViewerFixtures } from '../config/traceViewerFixtures'; import { traceViewerFixtures } from '../config/traceViewerFixtures'; -import { extractZip } from '../../packages/playwright-core/src/server/utils/third_party/extractZip'; +import { extractZip } from '../../packages/utils/third_party/extractZip'; import fs from 'fs'; import path from 'path'; import type http from 'http'; diff --git a/tests/library/unit/sequence.spec.ts b/tests/library/unit/sequence.spec.ts index 8a469eaee7501..de236c8801c62 100644 --- a/tests/library/unit/sequence.spec.ts +++ b/tests/library/unit/sequence.spec.ts @@ -16,8 +16,8 @@ import { test as it, expect } from '@playwright/test'; -import { sever } from '../../../packages/playwright-core/lib/coreBundle'; -const { findRepeatedSubsequencesForTest: findRepeatedSubsequences } = sever; +import { server as coreServer } from '../../../packages/playwright-core/lib/coreBundle'; +const { findRepeatedSubsequencesForTest: findRepeatedSubsequences } = coreServer; it('should return an empty array when the input is empty', () => { const input = []; diff --git a/tests/page/page-leaks.spec.ts b/tests/page/page-leaks.spec.ts index 1df64c52eeedd..d38488932f62f 100644 --- a/tests/page/page-leaks.spec.ts +++ b/tests/page/page-leaks.spec.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import { iso, sever } from '../../packages/playwright-core/lib/coreBundle'; -const { nullProgress } = sever; +import { iso, server as coreServer } from '../../packages/playwright-core/lib/coreBundle'; +const { nullProgress } = coreServer; import { test, expect } from './pageTest'; const { MultiMap } = iso; diff --git a/tests/page/page-set-content.spec.ts b/tests/page/page-set-content.spec.ts index 399240e1ede3d..d64d3b79462e2 100644 --- a/tests/page/page-set-content.spec.ts +++ b/tests/page/page-set-content.spec.ts @@ -16,8 +16,8 @@ */ import { test as it, expect } from './pageTest'; -import { sever } from '../../packages/playwright-core/lib/coreBundle'; -const { nullProgress } = sever; +import { server as coreServer } from '../../packages/playwright-core/lib/coreBundle'; +const { nullProgress } = coreServer; const expectedOutput = '
hello
'; diff --git a/tests/playwright-test/reporter-blob.spec.ts b/tests/playwright-test/reporter-blob.spec.ts index 260be5362aa76..cf5064a97be4d 100644 --- a/tests/playwright-test/reporter-blob.spec.ts +++ b/tests/playwright-test/reporter-blob.spec.ts @@ -20,14 +20,13 @@ import path from 'path'; import { html } from '../../packages/playwright/lib/runner'; const { startHtmlReportServer } = html; import { expect as baseExpect, test as baseTest, stripAnsi } from './playwright-test-fixtures'; -import { extractZip } from '../../packages/playwright-core/src/server/utils/third_party/extractZip'; +import { extractZip } from '../../packages/utils/third_party/extractZip'; import * as yazl from 'yazl'; -import { utils } from '../../packages/playwright-core/lib/coreBundle'; +import { utils, getUserAgent } from '../../packages/playwright-core/lib/coreBundle'; import { Readable } from 'stream'; import type { FullResult, JSONReportTestResult } from '../../packages/playwright-test/reporter'; type HttpServer = utils.HttpServer; -const { getUserAgent } = utils; const DOES_NOT_SUPPORT_UTF8_IN_TERMINAL = process.platform === 'win32' && process.env.TERM_PROGRAM !== 'vscode' && !process.env.WT_SESSION; const POSITIVE_STATUS_MARK = DOES_NOT_SUPPORT_UTF8_IN_TERMINAL ? 'ok' : '✓ '; diff --git a/tests/playwright-test/test-step.spec.ts b/tests/playwright-test/test-step.spec.ts index 66ddbd247017c..b23541dec3a37 100644 --- a/tests/playwright-test/test-step.spec.ts +++ b/tests/playwright-test/test-step.spec.ts @@ -445,22 +445,6 @@ test('step timeout includes interrupted action errors', async ({ runInlineTest } expect.soft(result.output).toContain('> 5 | await page.waitForTimeout(100_000);'); }); -test('step timeout is errors.TimeoutError', async ({ runInlineTest }) => { - const result = await runInlineTest({ - 'a.test.ts': ` - import { test, expect, errors } from '@playwright/test'; - test('step timeout error type', async () => { - const e = await test.step('my step', async () => { - await new Promise(() => {}); - }, { timeout: 100 }).catch(e => e); - expect(e).toBeInstanceOf(errors.TimeoutError); - }); - ` - }, { reporter: '', workers: 1 }); - expect(result.exitCode).toBe(0); - expect(result.passed).toBe(1); -}); - test('should mark step as failed when soft expect fails', async ({ runInlineTest }) => { const result = await runInlineTest({ 'reporter.ts': stepIndentReporter, diff --git a/tests/stress/frames.spec.ts b/tests/stress/frames.spec.ts index e2cb18b2fca62..a2002f41a733a 100644 --- a/tests/stress/frames.spec.ts +++ b/tests/stress/frames.spec.ts @@ -15,12 +15,12 @@ */ import { contextTest as test, expect } from '../config/browserTest'; -import { sever } from '../../packages/playwright-core/lib/coreBundle'; +import { server as coreServer } from '../../packages/playwright-core/lib/coreBundle'; test.slow(); test('cycle frames', async ({ page, server }) => { - sever.setMaxDispatchersForTest(100); + coreServer.setMaxDispatchersForTest(100); const kFrameCount = 310; @@ -47,7 +47,7 @@ test('cycle frames', async ({ page, server }) => { await promise; await page.waitForTimeout(500); - sever.setMaxDispatchersForTest(null); + coreServer.setMaxDispatchersForTest(null); }); test('cycle handles', async ({ page, server }) => { diff --git a/tests/stress/heap.spec.ts b/tests/stress/heap.spec.ts index 0fc528967795f..938dd46a0b478 100644 --- a/tests/stress/heap.spec.ts +++ b/tests/stress/heap.spec.ts @@ -15,7 +15,7 @@ */ import { contextTest as test, expect } from '../config/browserTest'; -import { sever } from '../../packages/playwright-core/lib/coreBundle'; +import { server as coreServer } from '../../packages/playwright-core/lib/coreBundle'; import { queryObjectCount } from '../config/queryObjects'; test.describe.configure({ mode: 'serial' }); @@ -44,10 +44,10 @@ test('should not leak fixtures w/o page', async ({}) => { }); test('should not leak server-side objects', async ({ page }) => { - expect(await queryObjectCount(sever.Page)).toBe(1); + expect(await queryObjectCount(coreServer.Page)).toBe(1); // 4 is because v8 heap creates objects for descendant classes, so WKContext, CRContext, FFContext, BidiBrowserContext and our context instance. - expect(await queryObjectCount(sever.BrowserContext)).toBe(5); - expect(await queryObjectCount(sever.Browser)).toBe(5); + expect(await queryObjectCount(coreServer.BrowserContext)).toBe(5); + expect(await queryObjectCount(coreServer.Browser)).toBe(5); }); test('should not leak dispatchers after closing page', async ({ context, server }) => { @@ -64,27 +64,27 @@ test('should not leak dispatchers after closing page', async ({ context, server pages.push(page); } - expect(await queryObjectCount(sever.Page)).toBe(COUNT); - expect(await queryObjectCount(sever.RequestDispatcher)).toBe(COUNT); - expect(await queryObjectCount(sever.ResponseDispatcher)).toBe(COUNT); + expect(await queryObjectCount(coreServer.Page)).toBe(COUNT); + expect(await queryObjectCount(coreServer.RequestDispatcher)).toBe(COUNT); + expect(await queryObjectCount(coreServer.ResponseDispatcher)).toBe(COUNT); for (const page of pages) await page.close(); pages.length = 0; - expect(await queryObjectCount(sever.Page)).toBe(0); - expect(await queryObjectCount(sever.RequestDispatcher)).toBe(0); - expect(await queryObjectCount(sever.ResponseDispatcher)).toBe(0); + expect(await queryObjectCount(coreServer.Page)).toBe(0); + expect(await queryObjectCount(coreServer.RequestDispatcher)).toBe(0); + expect(await queryObjectCount(coreServer.ResponseDispatcher)).toBe(0); expect(await queryObjectCount(require('../../packages/playwright-core/lib/client/page').Page)).toBeLessThan(COUNT); - expect(await queryObjectCount(sever.Page)).toBe(0); + expect(await queryObjectCount(coreServer.Page)).toBe(0); expect(await queryObjectCount(require('../../packages/playwright-core/lib/client/network').Request)).toBe(0); expect(await queryObjectCount(require('../../packages/playwright-core/lib/client/network').Response)).toBe(0); }); test.describe(() => { test.beforeEach(() => { - sever.setMaxDispatchersForTest(100); + coreServer.setMaxDispatchersForTest(100); }); test('should collect stale handles', async ({ page, server }) => { @@ -102,10 +102,10 @@ test.describe(() => { const counts = [ { count: await queryObjectCount(require('../../packages/playwright-core/lib/client/network').Request), message: 'client.Request' }, { count: await queryObjectCount(require('../../packages/playwright-core/lib/client/network').Response), message: 'client.Response' }, - { count: await queryObjectCount(sever.Request), message: 'server.Request' }, - { count: await queryObjectCount(sever.Response), message: 'server.Response' }, - { count: await queryObjectCount(sever.RequestDispatcher), message: 'dispatchers.RequestDispatcher' }, - { count: await queryObjectCount(sever.ResponseDispatcher), message: 'dispatchers.ResponseDispatcher' }, + { count: await queryObjectCount(coreServer.Request), message: 'server.Request' }, + { count: await queryObjectCount(coreServer.Response), message: 'server.Response' }, + { count: await queryObjectCount(coreServer.RequestDispatcher), message: 'dispatchers.RequestDispatcher' }, + { count: await queryObjectCount(coreServer.ResponseDispatcher), message: 'dispatchers.ResponseDispatcher' }, ]; for (const { count, message } of counts) { expect(count, { message }).toBeGreaterThan(50); @@ -114,6 +114,6 @@ test.describe(() => { }); test.afterEach(() => { - sever.setMaxDispatchersForTest(null); + coreServer.setMaxDispatchersForTest(null); }); }); diff --git a/tests/tsconfig.json b/tests/tsconfig.json index 2ed521bceacd1..3904a25f3d561 100644 --- a/tests/tsconfig.json +++ b/tests/tsconfig.json @@ -13,7 +13,8 @@ "@dashboard/*": ["packages/dashboard/src/*"], "@dvtools/*": ["packages/devtools/src/*"], "@injected/*": ["packages/injected/src/*"], - "@isomorphic/*": ["packages/playwright-core/src/utils/isomorphic/*"], + "@isomorphic/*": ["packages/isomorphic/*"], + "@utils/*": ["packages/utils/*"], "@testIsomorphic/*": ["packages/playwright/src/isomorphic/*"], "@protocol/*": ["packages/protocol/src/*"], "@recorder/*": ["packages/recorder/src/*"], diff --git a/tsconfig.json b/tsconfig.json index 4a9a210739ad6..cc2f5082a63ce 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,8 +13,8 @@ "@dashboard/*": ["./packages/dashboard/src/*"], "@html-reporter/*": ["./packages/html-reporter/src/*"], "@injected/*": ["./packages/injected/src/*"], - "@isomorphic/*": ["./packages/playwright-core/src/utils/isomorphic/*"], - "@utils/*": ["./packages/playwright-core/src/server/utils/*"], + "@isomorphic/*": ["./packages/isomorphic/*"], + "@utils/*": ["./packages/utils/*"], "@protocol/*": ["./packages/protocol/src/*"], "@recorder/*": ["./packages/recorder/src/*"], "@testIsomorphic/*": ["./packages/playwright/src/isomorphic/*"], diff --git a/utils/build/build.js b/utils/build/build.js index 40d92976ab01f..34c88e803ac90 100644 --- a/utils/build/build.js +++ b/utils/build/build.js @@ -590,6 +590,13 @@ const externalizeUtilsBundlePlugin = { name: 'externalize-utilsBundle', setup(build) { build.onResolve({ filter: /utilsBundle/ }, args => { + // Bare absolute specifier used by the dynamic-import-to-require + // plugin for source files that live OUTSIDE playwright-core/src + // (e.g., packages/utils/*.ts). These end up inlined into + // coreBundle.js, so the runtime path resolves correctly against + // lib/coreBundle.js's sibling lib/utilsBundle.js. + if (args.path === 'playwright-core/lib/utilsBundle') + return { path: './utilsBundle', external: true }; if (!args.path.startsWith('.')) return; // Match `/utilsBundle` or `/utilsBundle.js` so @@ -698,8 +705,6 @@ steps.push(new EsbuildStep({ platform: 'node', format: 'cjs', external: [ - 'playwright-core', - 'playwright-core/*', '../package', ], plugins: [dynamicImportToRequirePlugin], @@ -718,6 +723,7 @@ steps.push(new EsbuildStep({ 'playwright-core/*', '../globals', '../package', + '../babelBundle', ], plugins: [dynamicImportToRequirePlugin], }, [filePath('packages/playwright/src')])); @@ -915,7 +921,7 @@ onChanges.push({ 'packages/injected/src/**', 'packages/playwright-core/src/third_party/**', 'packages/playwright-ct-core/src/injected/**', - 'packages/playwright-core/src/utils/isomorphic/**', + 'packages/isomorphic/**', 'utils/generate_injected_builtins.js', 'utils/generate_injected.js', ], diff --git a/utils/build/utilsBundleMapping.js b/utils/build/utilsBundleMapping.js index a7ab8d8c15394..64753c7f1693c 100644 --- a/utils/build/utilsBundleMapping.js +++ b/utils/build/utilsBundleMapping.js @@ -13,7 +13,7 @@ const MAPPING = { 'diff': { namespace: 'diff' }, 'dotenv': { default: 'dotenv' }, 'proxy-from-env': { named: { getProxyForUrl: 'getProxyForUrl' } }, - 'https-proxy-agent': { named: { HttpsProxyAgent: 'HttpsProxyAgent' } }, + 'https-proxy-agent': { default: 'httpProxyAgent', named: { HttpsProxyAgent: 'HttpsProxyAgent' } }, 'jpeg-js': { default: 'jpegjs' }, 'mime': { default: 'mime' }, 'minimatch': { default: 'minimatch' }, @@ -21,7 +21,7 @@ const MAPPING = { 'pngjs': { named: { PNG: 'PNG' } }, 'commander': { named: { program: 'program', Option: 'ProgramOption' } }, 'progress': { default: 'progress' }, - 'socks-proxy-agent': { named: { SocksProxyAgent: 'SocksProxyAgent' } }, + 'socks-proxy-agent': { default: 'socksProxyAgent', named: { SocksProxyAgent: 'SocksProxyAgent' } }, 'ws': { default: 'ws', named: { WebSocketServer: 'wsServer' }, diff --git a/utils/check_deps.js b/utils/check_deps.js index 32f3f332fa9c7..8c4557ec21ecb 100644 --- a/utils/check_deps.js +++ b/utils/check_deps.js @@ -28,8 +28,8 @@ const packagesDir = path.resolve(path.join(__dirname, '..', 'packages')); const packages = new Map(); packages.set('web', packagesDir + '/web/src/'); packages.set('injected', packagesDir + '/injected/src/'); -packages.set('isomorphic', packagesDir + '/playwright-core/src/utils/isomorphic/'); -packages.set('utils', packagesDir + '/playwright-core/src/server/utils/'); +packages.set('isomorphic', packagesDir + '/isomorphic/'); +packages.set('utils', packagesDir + '/utils/'); packages.set('testIsomorphic', packagesDir + '/playwright/src/isomorphic/'); const peerDependencies = ['electron', 'react', 'react-dom', 'react-dom/client', '@zip.js/zip.js', 'zod', 'zod/v3']; diff --git a/utils/generate_channels.js b/utils/generate_channels.js index 3bc621d5d42cb..627ca3a9533f8 100755 --- a/utils/generate_channels.js +++ b/utils/generate_channels.js @@ -374,6 +374,6 @@ function writeFile(filePath, content) { } writeFile(path.join(__dirname, '..', 'packages', 'protocol', 'src', 'channels.d.ts'), channels_ts.join('\n') + '\n'); -writeFile(path.join(__dirname, '..', 'packages', 'playwright-core', 'src', 'utils', 'isomorphic', 'protocolMetainfo.ts'), metainfo_ts.join('\n') + '\n'); +writeFile(path.join(__dirname, '..', 'packages', 'isomorphic', 'protocolMetainfo.ts'), metainfo_ts.join('\n') + '\n'); writeFile(path.join(__dirname, '..', 'packages', 'playwright-core', 'src', 'protocol', 'validator.ts'), validator_ts.join('\n') + '\n'); process.exit(hasChanges ? 1 : 0);