chore: move injected scripts into packages/injected (#35483)

This commit is contained in:
Yury Semikhatsky 2025-04-03 16:09:03 -07:00 committed by GitHub
parent 43622f567f
commit b8a0d5f6cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
53 changed files with 90 additions and 86 deletions

View File

@ -380,7 +380,7 @@ export default [
}, },
{ {
files: [ files: [
"packages/playwright-core/src/server/injected/**/*.ts", "packages/injected/src/**/*.ts",
"packages/playwright-core/src/server/pageBinding.ts", "packages/playwright-core/src/server/pageBinding.ts",
"packages/playwright-core/src/server/storageScript.ts", "packages/playwright-core/src/server/storageScript.ts",
], ],

View File

@ -1,4 +1,3 @@
# Files in this folder are used in browser environment, they can only depend on isomorphic files. # Files in this folder are used in browser environment, they can only depend on isomorphic files.
[*] [*]
../isomorphic/ @isomorphic/**
../../utils/isomorphic

View File

@ -0,0 +1,5 @@
# Injected
This directory contains helper sources which are injected into the page.
These sources are bundled with the ebuild into `src/generated` as compile-time source constants. See `utils/generate_injected` for details.

View File

@ -21,7 +21,7 @@ import * as roleUtils from './roleUtils';
import { yamlEscapeKeyIfNeeded, yamlEscapeValueIfNeeded } from './yaml'; import { yamlEscapeKeyIfNeeded, yamlEscapeValueIfNeeded } from './yaml';
import type { AriaProps, AriaRegex, AriaRole, AriaTemplateNode, AriaTemplateRoleNode, AriaTemplateTextNode } from '@isomorphic/ariaSnapshot'; import type { AriaProps, AriaRegex, AriaRole, AriaTemplateNode, AriaTemplateRoleNode, AriaTemplateTextNode } from '@isomorphic/ariaSnapshot';
import type { Builtins } from '../../utils/isomorphic/builtins'; import type { Builtins } from '@isomorphic/builtins';
export type AriaNode = AriaProps & { export type AriaNode = AriaProps & {
role: AriaRole | 'fragment' | 'iframe'; role: AriaRole | 'fragment' | 'iframe';

View File

@ -10,9 +10,9 @@
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
import { ensureBuiltins } from '../../utils/isomorphic/builtins'; import { ensureBuiltins } from '@isomorphic/builtins';
import type { Builtins } from '../../utils/isomorphic/builtins'; import type { Builtins } from '@isomorphic/builtins';
export type ClockMethods = { export type ClockMethods = {
Date: DateConstructor; Date: DateConstructor;

View File

@ -14,13 +14,13 @@
* limitations under the License. * limitations under the License.
*/ */
import { asLocator } from '../../utils/isomorphic/locatorGenerators'; import { asLocator } from '@isomorphic/locatorGenerators';
import { getByAltTextSelector, getByLabelSelector, getByPlaceholderSelector, getByRoleSelector, getByTestIdSelector, getByTextSelector, getByTitleSelector } from '../../utils/isomorphic/locatorUtils'; import { getByAltTextSelector, getByLabelSelector, getByPlaceholderSelector, getByRoleSelector, getByTestIdSelector, getByTextSelector, getByTitleSelector } from '@isomorphic/locatorUtils';
import { escapeForTextSelector } from '../../utils/isomorphic/stringUtils'; import { escapeForTextSelector } from '@isomorphic/stringUtils';
import type { InjectedScript } from './injectedScript'; import type { InjectedScript } from './injectedScript';
import type { Language } from '../../utils/isomorphic/locatorGenerators'; import type { Language } from '@isomorphic/locatorGenerators';
import type { ByRoleOptions } from '../../utils/isomorphic/locatorUtils'; import type { ByRoleOptions } from '@isomorphic/locatorUtils';
const selectorSymbol = Symbol('selector'); const selectorSymbol = Symbol('selector');

View File

@ -14,13 +14,14 @@
* limitations under the License. * limitations under the License.
*/ */
import highlightCSS from './highlight.css?inline'; import { asLocator } from '@isomorphic/locatorGenerators';
import { asLocator } from '../../utils/isomorphic/locatorGenerators'; import { stringifySelector } from '@isomorphic/selectorParser';
import { stringifySelector } from '../../utils/isomorphic/selectorParser';
import highlightCSS from './highlight.css?inline';
import type { Language } from '@isomorphic/locatorGenerators';
import type { ParsedSelector } from '@isomorphic/selectorParser';
import type { InjectedScript } from './injectedScript'; import type { InjectedScript } from './injectedScript';
import type { Language } from '../../utils/isomorphic/locatorGenerators';
import type { ParsedSelector } from '../../utils/isomorphic/selectorParser';
type RenderedHighlightEntry = { type RenderedHighlightEntry = {

View File

@ -15,36 +15,35 @@
*/ */
import { parseAriaSnapshot } from '@isomorphic/ariaSnapshot'; import { parseAriaSnapshot } from '@isomorphic/ariaSnapshot';
import { ensureBuiltins } from '@isomorphic/builtins';
import { asLocator } from '@isomorphic/locatorGenerators';
import { parseAttributeSelector, parseSelector, stringifySelector, visitAllSelectorParts } from '@isomorphic/selectorParser';
import { cacheNormalizedWhitespaces, normalizeWhiteSpace, trimStringWithEllipsis } from '@isomorphic/stringUtils';
import { ensureBuiltins } from '../../utils/isomorphic/builtins';
import { generateAriaTree, getAllByAria, matchesAriaTree, renderAriaTree } from './ariaSnapshot'; import { generateAriaTree, getAllByAria, matchesAriaTree, renderAriaTree } from './ariaSnapshot';
import { enclosingShadowRootOrDocument, isElementVisible, isInsideScope, parentElementOrShadowHost, setBrowserName } from './domUtils'; import { enclosingShadowRootOrDocument, isElementVisible, isInsideScope, parentElementOrShadowHost, setBrowserName } from './domUtils';
import { Highlight } from './highlight'; import { Highlight } from './highlight';
import { kLayoutSelectorNames, layoutSelectorScore } from './layoutSelectorUtils'; import { kLayoutSelectorNames, layoutSelectorScore } from './layoutSelectorUtils';
import { createReactEngine } from './reactSelectorEngine'; import { createReactEngine } from './reactSelectorEngine';
import { createRoleEngine } from './roleSelectorEngine'; import { createRoleEngine } from './roleSelectorEngine';
import { getAriaDisabled, getAriaRole, getCheckedAllowMixed, getCheckedWithoutMixed, getElementAccessibleDescription, getElementAccessibleErrorMessage, getElementAccessibleName, getReadonly } from './roleUtils'; import { getAriaDisabled, getAriaRole, getCheckedAllowMixed, getCheckedWithoutMixed, getElementAccessibleDescription, getElementAccessibleErrorMessage, getElementAccessibleName, getReadonly } from './roleUtils';
import { SelectorEvaluatorImpl, sortInDOMOrder } from './selectorEvaluator'; import { SelectorEvaluatorImpl, sortInDOMOrder } from './selectorEvaluator';
import { generateSelector } from './selectorGenerator'; import { generateSelector } from './selectorGenerator';
import { elementMatchesText, elementText, getElementLabels } from './selectorUtils'; import { elementMatchesText, elementText, getElementLabels } from './selectorUtils';
import { createVueEngine } from './vueSelectorEngine'; import { createVueEngine } from './vueSelectorEngine';
import { XPathEngine } from './xpathSelectorEngine'; import { XPathEngine } from './xpathSelectorEngine';
import { asLocator } from '../../utils/isomorphic/locatorGenerators';
import { parseAttributeSelector } from '../../utils/isomorphic/selectorParser';
import { parseSelector, stringifySelector, visitAllSelectorParts } from '../../utils/isomorphic/selectorParser';
import { cacheNormalizedWhitespaces, normalizeWhiteSpace, trimStringWithEllipsis } from '../../utils/isomorphic/stringUtils';
import type { AriaTemplateNode } from '@isomorphic/ariaSnapshot';
import type { Builtins } from '@isomorphic/builtins';
import type { CSSComplexSelectorList } from '@isomorphic/cssParser';
import type { Language } from '@isomorphic/locatorGenerators';
import type { NestedSelectorBody, ParsedSelector, ParsedSelectorPart } from '@isomorphic/selectorParser';
import type * as channels from '@protocol/channels';
import type { AriaSnapshot } from './ariaSnapshot'; import type { AriaSnapshot } from './ariaSnapshot';
import type { Builtins } from '../../utils/isomorphic/builtins';
import type { LayoutSelectorName } from './layoutSelectorUtils'; import type { LayoutSelectorName } from './layoutSelectorUtils';
import type { SelectorEngine, SelectorRoot } from './selectorEngine'; import type { SelectorEngine, SelectorRoot } from './selectorEngine';
import type { GenerateSelectorOptions } from './selectorGenerator'; import type { GenerateSelectorOptions } from './selectorGenerator';
import type { ElementText, TextMatcher } from './selectorUtils'; import type { ElementText, TextMatcher } from './selectorUtils';
import type { CSSComplexSelectorList } from '../../utils/isomorphic/cssParser';
import type { Language } from '../../utils/isomorphic/locatorGenerators';
import type { NestedSelectorBody, ParsedSelector, ParsedSelectorPart } from '../../utils/isomorphic/selectorParser';
import type { AriaTemplateNode } from '@isomorphic/ariaSnapshot';
import type * as channels from '@protocol/channels';
export type FrameExpectParams = Omit<channels.FrameExpectParams, 'expectedValue'> & { expectedValue?: any }; export type FrameExpectParams = Omit<channels.FrameExpectParams, 'expectedValue'> & { expectedValue?: any };

View File

@ -14,12 +14,13 @@
* limitations under the License. * limitations under the License.
*/ */
import { parseAttributeSelector } from '@isomorphic/selectorParser';
import { isInsideScope } from './domUtils'; import { isInsideScope } from './domUtils';
import { matchesComponentAttribute } from './selectorUtils'; import { matchesComponentAttribute } from './selectorUtils';
import { parseAttributeSelector } from '../../utils/isomorphic/selectorParser';
import type { Builtins } from '@isomorphic/builtins';
import type { SelectorEngine, SelectorRoot } from './selectorEngine'; import type { SelectorEngine, SelectorRoot } from './selectorEngine';
import type { Builtins } from '../../utils/isomorphic/builtins';
type ComponentNode = { type ComponentNode = {
key?: any, key?: any,

View File

Before

Width:  |  Height:  |  Size: 243 B

After

Width:  |  Height:  |  Size: 243 B

View File

Before

Width:  |  Height:  |  Size: 288 B

After

Width:  |  Height:  |  Size: 288 B

View File

Before

Width:  |  Height:  |  Size: 934 B

After

Width:  |  Height:  |  Size: 934 B

View File

Before

Width:  |  Height:  |  Size: 429 B

After

Width:  |  Height:  |  Size: 429 B

View File

Before

Width:  |  Height:  |  Size: 187 B

After

Width:  |  Height:  |  Size: 187 B

View File

Before

Width:  |  Height:  |  Size: 273 B

After

Width:  |  Height:  |  Size: 273 B

View File

Before

Width:  |  Height:  |  Size: 620 B

After

Width:  |  Height:  |  Size: 620 B

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -16,14 +16,14 @@
import clipPaths from './clipPaths'; import clipPaths from './clipPaths';
import type { Point } from '../../../utils/isomorphic/types'; import type { Point } from '@isomorphic/types';
import type { Highlight, HighlightEntry } from '../highlight'; import type { Highlight, HighlightEntry } from '../highlight';
import type { InjectedScript } from '../injectedScript'; import type { InjectedScript } from '../injectedScript';
import type { ElementText } from '../selectorUtils'; import type { ElementText } from '../selectorUtils';
import type * as actions from '@recorder/actions'; import type * as actions from '@recorder/actions';
import type { ElementInfo, Mode, OverlayState, UIState } from '@recorder/recorderTypes'; import type { ElementInfo, Mode, OverlayState, UIState } from '@recorder/recorderTypes';
import type { Language } from '@isomorphic/locatorGenerators'; import type { Language } from '@isomorphic/locatorGenerators';
import type { Builtins } from '../../../utils/isomorphic/builtins'; import type { Builtins } from '@isomorphic/builtins';
const HighlightColors = { const HighlightColors = {
multiple: '#f6b26b7f', multiple: '#f6b26b7f',

View File

@ -14,14 +14,15 @@
* limitations under the License. * limitations under the License.
*/ */
import { parseAttributeSelector } from '@isomorphic/selectorParser';
import { normalizeWhiteSpace } from '@isomorphic/stringUtils';
import { beginAriaCaches, endAriaCaches, getAriaChecked, getAriaDisabled, getAriaExpanded, getAriaLevel, getAriaPressed, getAriaRole, getAriaSelected, getElementAccessibleName, isElementHiddenForAria, kAriaCheckedRoles, kAriaExpandedRoles, kAriaLevelRoles, kAriaPressedRoles, kAriaSelectedRoles } from './roleUtils'; import { beginAriaCaches, endAriaCaches, getAriaChecked, getAriaDisabled, getAriaExpanded, getAriaLevel, getAriaPressed, getAriaRole, getAriaSelected, getElementAccessibleName, isElementHiddenForAria, kAriaCheckedRoles, kAriaExpandedRoles, kAriaLevelRoles, kAriaPressedRoles, kAriaSelectedRoles } from './roleUtils';
import { matchesAttributePart } from './selectorUtils'; import { matchesAttributePart } from './selectorUtils';
import { parseAttributeSelector } from '../../utils/isomorphic/selectorParser';
import { normalizeWhiteSpace } from '../../utils/isomorphic/stringUtils';
import type { Builtins } from '../../utils/isomorphic/builtins'; import type { Builtins } from '@isomorphic/builtins';
import type { AttributeSelectorOperator, AttributeSelectorPart } from '@isomorphic/selectorParser';
import type { SelectorEngine, SelectorRoot } from './selectorEngine'; import type { SelectorEngine, SelectorRoot } from './selectorEngine';
import type { AttributeSelectorOperator, AttributeSelectorPart } from '../../utils/isomorphic/selectorParser';
type RoleEngineOptions = { type RoleEngineOptions = {
role: string; role: string;

View File

@ -17,7 +17,7 @@
import { closestCrossShadow, elementSafeTagName, enclosingShadowRootOrDocument, getElementComputedStyle, isElementStyleVisibilityVisible, isVisibleTextNode, parentElementOrShadowHost } from './domUtils'; import { closestCrossShadow, elementSafeTagName, enclosingShadowRootOrDocument, getElementComputedStyle, isElementStyleVisibilityVisible, isVisibleTextNode, parentElementOrShadowHost } from './domUtils';
import type { AriaRole } from '@isomorphic/ariaSnapshot'; import type { AriaRole } from '@isomorphic/ariaSnapshot';
import type { Builtins } from '../../utils/isomorphic/builtins'; import type { Builtins } from '@isomorphic/builtins';
function hasExplicitAccessibleName(e: Element) { function hasExplicitAccessibleName(e: Element) {
return e.hasAttribute('aria-label') || e.hasAttribute('aria-labelledby'); return e.hasAttribute('aria-label') || e.hasAttribute('aria-labelledby');

View File

@ -14,16 +14,17 @@
* limitations under the License. * limitations under the License.
*/ */
import { isElementVisible, parentElementOrShadowHost } from './domUtils'; import { customCSSNames } from '@isomorphic/selectorParser';
import { layoutSelectorScore } from './layoutSelectorUtils'; import { normalizeWhiteSpace } from '@isomorphic/stringUtils';
import { elementMatchesText, elementText, shouldSkipForTextMatching } from './selectorUtils';
import { customCSSNames } from '../../utils/isomorphic/selectorParser';
import { normalizeWhiteSpace } from '../../utils/isomorphic/stringUtils';
import { isElementVisible, parentElementOrShadowHost } from './domUtils';
import { layoutSelectorScore } from './layoutSelectorUtils';
import { elementMatchesText, elementText, shouldSkipForTextMatching } from './selectorUtils';
import type { Builtins } from '@isomorphic/builtins';
import type { CSSComplexSelector, CSSComplexSelectorList, CSSFunctionArgument, CSSSimpleSelector } from '@isomorphic/cssParser';
import type { LayoutSelectorName } from './layoutSelectorUtils'; import type { LayoutSelectorName } from './layoutSelectorUtils';
import type { ElementText } from './selectorUtils'; import type { ElementText } from './selectorUtils';
import type { CSSComplexSelector, CSSComplexSelectorList, CSSFunctionArgument, CSSSimpleSelector } from '../../utils/isomorphic/cssParser';
import type { Builtins } from '../../utils/isomorphic/builtins';
type QueryContext = { type QueryContext = {
scope: Element | Document; scope: Element | Document;

View File

@ -14,13 +14,14 @@
* limitations under the License. * limitations under the License.
*/ */
import { cssEscape, escapeForAttributeSelector, escapeForTextSelector, escapeRegExp, quoteCSSAttributeValue } from '@isomorphic/stringUtils';
import { closestCrossShadow, isElementVisible, isInsideScope, parentElementOrShadowHost } from './domUtils'; import { closestCrossShadow, isElementVisible, isInsideScope, parentElementOrShadowHost } from './domUtils';
import { beginAriaCaches, endAriaCaches, getAriaRole, getElementAccessibleName } from './roleUtils'; import { beginAriaCaches, endAriaCaches, getAriaRole, getElementAccessibleName } from './roleUtils';
import { elementText, getElementLabels } from './selectorUtils'; import { elementText, getElementLabels } from './selectorUtils';
import { cssEscape, escapeForAttributeSelector, escapeForTextSelector, escapeRegExp, quoteCSSAttributeValue } from '../../utils/isomorphic/stringUtils';
import type { Builtins } from '@isomorphic/builtins';
import type { InjectedScript } from './injectedScript'; import type { InjectedScript } from './injectedScript';
import type { Builtins } from '../../utils/isomorphic/builtins';
type SelectorToken = { type SelectorToken = {
engine: string; engine: string;

View File

@ -14,11 +14,12 @@
* limitations under the License. * limitations under the License.
*/ */
import { getAriaLabelledByElements } from './roleUtils'; import { normalizeWhiteSpace } from '@isomorphic/stringUtils';
import { normalizeWhiteSpace } from '../../utils/isomorphic/stringUtils';
import type { AttributeSelectorPart } from '../../utils/isomorphic/selectorParser'; import { getAriaLabelledByElements } from './roleUtils';
import type { Builtins } from '../../utils/isomorphic/builtins';
import type { Builtins } from '@isomorphic/builtins';
import type { AttributeSelectorPart } from '@isomorphic/selectorParser';
export function matchesComponentAttribute(obj: any, attr: AttributeSelectorPart) { export function matchesComponentAttribute(obj: any, attr: AttributeSelectorPart) {
for (const token of attr.jsonPath) { for (const token of attr.jsonPath) {

View File

@ -14,10 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
import { ensureBuiltins } from '../../utils/isomorphic/builtins'; import { ensureBuiltins } from '@isomorphic/builtins';
import { source } from '../../utils/isomorphic/utilityScriptSerializers'; import { source } from '@isomorphic/utilityScriptSerializers';
import type { Builtins } from '../../utils/isomorphic/builtins'; import type { Builtins } from '@isomorphic/builtins';
export class UtilityScript { export class UtilityScript {
constructor(isUnderTest: boolean) { constructor(isUnderTest: boolean) {

View File

@ -14,12 +14,13 @@
* limitations under the License. * limitations under the License.
*/ */
import { parseAttributeSelector } from '@isomorphic/selectorParser';
import { isInsideScope } from './domUtils'; import { isInsideScope } from './domUtils';
import { matchesComponentAttribute } from './selectorUtils'; import { matchesComponentAttribute } from './selectorUtils';
import { parseAttributeSelector } from '../../utils/isomorphic/selectorParser';
import type { Builtins } from '@isomorphic/builtins';
import type { SelectorEngine, SelectorRoot } from './selectorEngine'; import type { SelectorEngine, SelectorRoot } from './selectorEngine';
import type { Builtins } from '../../utils/isomorphic/builtins';
type ComponentNode = { type ComponentNode = {
name: string, name: string,

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { ensureBuiltins } from '../../utils/isomorphic/builtins'; import { ensureBuiltins } from '@isomorphic/builtins';
export type WebSocketMessage = string | ArrayBufferLike | Blob | ArrayBufferView; export type WebSocketMessage = string | ArrayBufferLike | Blob | ArrayBufferView;
export type WSData = { data: string, isBase64: boolean }; export type WSData = { data: string, isBase64: boolean };

View File

@ -12,7 +12,7 @@
!lib/**/*.ttf !lib/**/*.ttf
!lib/utilsBundleImpl/xdg-open !lib/utilsBundleImpl/xdg-open
# Exclude injected files. A preprocessed version of these is included via lib/generated. # Exclude injected files. A preprocessed version of these is included via lib/generated.
# See src/server/injected/README.md. # See packages/injected/src/README.md.
lib/**/injected/ lib/**/injected/
# Include all binaries that we ship with the package. # Include all binaries that we ship with the package.
!bin/**/* !bin/**/*

View File

@ -6,7 +6,6 @@
../utilsBundle.ts ../utilsBundle.ts
../zipBundle.ts ../zipBundle.ts
./ ./
./injected/
./isomorphic/ ./isomorphic/
./har/ ./har/
./recorder/ ./recorder/

View File

@ -25,7 +25,7 @@ import { eventsHelper } from '../utils/eventsHelper';
import type { BrowserContextDispatcher } from './browserContextDispatcher'; import type { BrowserContextDispatcher } from './browserContextDispatcher';
import type { BrowserContext } from '../browserContext'; import type { BrowserContext } from '../browserContext';
import type { Frame } from '../frames'; import type { Frame } from '../frames';
import type * as ws from '../injected/webSocketMock'; import type * as ws from '@injected/webSocketMock';
import type * as channels from '@protocol/channels'; import type * as channels from '@protocol/channels';
export class WebSocketRouteDispatcher extends Dispatcher<{ guid: string }, channels.WebSocketRouteChannel, PageDispatcher | BrowserContextDispatcher> implements channels.WebSocketRouteChannel { export class WebSocketRouteDispatcher extends Dispatcher<{ guid: string }, channels.WebSocketRouteChannel, PageDispatcher | BrowserContextDispatcher> implements channels.WebSocketRouteChannel {

View File

@ -24,7 +24,7 @@ import { isSessionClosedError } from './protocolError';
import * as injectedScriptSource from '../generated/injectedScriptSource'; import * as injectedScriptSource from '../generated/injectedScriptSource';
import type * as frames from './frames'; import type * as frames from './frames';
import type { ElementState, HitTargetInterceptionResult, InjectedScript } from './injected/injectedScript'; import type { ElementState, HitTargetInterceptionResult, InjectedScript } from '@injected/injectedScript';
import type { CallMetadata } from './instrumentation'; import type { CallMetadata } from './instrumentation';
import type { Page } from './page'; import type { Page } from './page';
import type { Progress } from './progress'; import type { Progress } from './progress';

View File

@ -19,7 +19,7 @@ import { InvalidSelectorError, splitSelectorByFrame, stringifySelector, visitAl
import type { ElementHandle, FrameExecutionContext } from './dom'; import type { ElementHandle, FrameExecutionContext } from './dom';
import type { Frame } from './frames'; import type { Frame } from './frames';
import type { InjectedScript } from './injected/injectedScript'; import type { InjectedScript } from '@injected/injectedScript';
import type { JSHandle } from './javascript'; import type { JSHandle } from './javascript';
import type * as types from './types'; import type * as types from './types';
import type { ParsedSelector } from '../utils/isomorphic/selectorParser'; import type { ParsedSelector } from '../utils/isomorphic/selectorParser';

View File

@ -37,7 +37,7 @@ import { compressCallLog } from './callLog';
import type { ConsoleMessage } from './console'; import type { ConsoleMessage } from './console';
import type { Dialog } from './dialog'; import type { Dialog } from './dialog';
import type { ElementStateWithoutStable, FrameExpectParams, InjectedScript } from './injected/injectedScript'; import type { ElementStateWithoutStable, FrameExpectParams, InjectedScript } from '@injected/injectedScript';
import type { CallMetadata } from './instrumentation'; import type { CallMetadata } from './instrumentation';
import type { Progress } from './progress'; import type { Progress } from './progress';
import type { ScreenshotOptions } from './screenshotter'; import type { ScreenshotOptions } from './screenshotter';

View File

@ -1,5 +0,0 @@
# Injected
This directory contains helper sources which are injected into the page.
These sources are bundled with webpack to `src/generated` to be used as a compile-time source constants. See `*.webpack.config.js` for configs.

View File

@ -22,7 +22,7 @@ import { source } from '../utils/isomorphic/utilityScriptSerializers';
import { LongStandingScope } from '../utils/isomorphic/manualPromise'; import { LongStandingScope } from '../utils/isomorphic/manualPromise';
import type * as dom from './dom'; import type * as dom from './dom';
import type { UtilityScript } from './injected/utilityScript'; import type { UtilityScript } from '@injected/utilityScript';
interface TaggedAsJSHandle<T> { interface TaggedAsJSHandle<T> {
__jshandle: T; __jshandle: T;

View File

@ -16,7 +16,7 @@
"jsx": "react-jsx", "jsx": "react-jsx",
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@injected/*": ["../playwright-core/src/server/injected/*"], "@injected/*": ["../injected/src/*"],
"@isomorphic/*": ["../playwright-core/src/utils/isomorphic/*"], "@isomorphic/*": ["../playwright-core/src/utils/isomorphic/*"],
"@protocol/*": ["../protocol/src/*"], "@protocol/*": ["../protocol/src/*"],
"@recorder/*": ["../recorder/src/*"], "@recorder/*": ["../recorder/src/*"],

View File

@ -33,7 +33,7 @@ export default defineConfig({
}, },
resolve: { resolve: {
alias: { alias: {
'@injected': path.resolve(__dirname, '../playwright-core/src/server/injected'), '@injected': path.resolve(__dirname, '../injected/src'),
'@isomorphic': path.resolve(__dirname, '../playwright-core/src/utils/isomorphic'), '@isomorphic': path.resolve(__dirname, '../playwright-core/src/utils/isomorphic'),
'@protocol': path.resolve(__dirname, '../protocol/src'), '@protocol': path.resolve(__dirname, '../protocol/src'),
'@testIsomorphic': path.resolve(__dirname, '../playwright/src/isomorphic'), '@testIsomorphic': path.resolve(__dirname, '../playwright/src/isomorphic'),

View File

@ -15,8 +15,8 @@
*/ */
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { createClock as rawCreateClock, install as rawInstall } from '../../../packages/playwright-core/src/server/injected/clock'; import { createClock as rawCreateClock, install as rawInstall } from '../../../packages/injected/src/clock';
import type { InstallConfig, ClockController, ClockMethods } from '../../../packages/playwright-core/src/server/injected/clock'; import type { InstallConfig, ClockController, ClockMethods } from '../../../packages/injected/src/clock';
const createClock = (now?: number): ClockController & ClockMethods => { const createClock = (now?: number): ClockController & ClockMethods => {
const { clock, api } = rawCreateClock(globalThis); const { clock, api } = rawCreateClock(globalThis);

View File

@ -11,7 +11,7 @@
- .../lib/* means require dependency - .../lib/* means require dependency
*/ */
"@html-reporter/*": ["./packages/html-reporter/src/*"], "@html-reporter/*": ["./packages/html-reporter/src/*"],
"@injected/*": ["./packages/playwright-core/src/server/injected/*"], "@injected/*": ["./packages/injected/src/*"],
"@isomorphic/*": ["./packages/playwright-core/src/utils/isomorphic/*"], "@isomorphic/*": ["./packages/playwright-core/src/utils/isomorphic/*"],
"@protocol/*": ["./packages/protocol/src/*"], "@protocol/*": ["./packages/protocol/src/*"],
"@recorder/*": ["./packages/recorder/src/*"], "@recorder/*": ["./packages/recorder/src/*"],

View File

@ -255,7 +255,6 @@ for (const pkg of workspace.packages()) {
...(withSourceMaps ? ['--source-maps'] : []), ...(withSourceMaps ? ['--source-maps'] : []),
'--extensions', '.ts', '--extensions', '.ts',
'--out-dir', quotePath(path.join(pkg.path, 'lib')), '--out-dir', quotePath(path.join(pkg.path, 'lib')),
'--ignore', '"packages/playwright-core/src/server/injected/**/*"',
quotePath(path.join(pkg.path, 'src')), quotePath(path.join(pkg.path, 'src')),
], ],
shell: true, shell: true,
@ -370,7 +369,7 @@ if (watchMode) {
// Generate injected. // Generate injected.
onChanges.push({ onChanges.push({
inputs: [ inputs: [
'packages/playwright-core/src/server/injected/**', 'packages/injected/src/**',
'packages/playwright-core/src/third_party/**', 'packages/playwright-core/src/third_party/**',
'packages/playwright-ct-core/src/injected/**', 'packages/playwright-ct-core/src/injected/**',
'packages/playwright-core/src/utils/isomorphic/**', 'packages/playwright-core/src/utils/isomorphic/**',

View File

@ -27,7 +27,7 @@ const packagesDir = path.resolve(path.join(__dirname, '..', 'packages'));
const packages = new Map(); const packages = new Map();
packages.set('web', packagesDir + '/web/src/'); packages.set('web', packagesDir + '/web/src/');
packages.set('injected', packagesDir + '/playwright-core/src/server/injected/'); packages.set('injected', packagesDir + '/injected/src/');
packages.set('isomorphic', packagesDir + '/playwright-core/src/utils/isomorphic/'); packages.set('isomorphic', packagesDir + '/playwright-core/src/utils/isomorphic/');
packages.set('testIsomorphic', packagesDir + '/playwright/src/isomorphic/'); packages.set('testIsomorphic', packagesDir + '/playwright/src/isomorphic/');
@ -43,6 +43,7 @@ async function checkDeps() {
await innerCheckDeps(path.join(packagesDir, 'trace-viewer')); await innerCheckDeps(path.join(packagesDir, 'trace-viewer'));
await innerCheckDeps(path.join(packagesDir, 'trace')); await innerCheckDeps(path.join(packagesDir, 'trace'));
await innerCheckDeps(path.join(packagesDir, 'web')); await innerCheckDeps(path.join(packagesDir, 'web'));
await innerCheckDeps(path.join(packagesDir, 'injected'));
const corePackageJson = await innerCheckDeps(path.join(packagesDir, 'playwright-core')); const corePackageJson = await innerCheckDeps(path.join(packagesDir, 'playwright-core'));
const playwrightPackageJson = await innerCheckDeps(path.join(packagesDir, 'playwright')); const playwrightPackageJson = await innerCheckDeps(path.join(packagesDir, 'playwright'));

View File

@ -51,8 +51,8 @@ const HEADER = `/*
import type { SvgJson } from './recorder'; import type { SvgJson } from './recorder';
`; `;
const iconsDir = path.join(ROOT, 'packages', 'playwright-core', 'src', 'server', 'injected', 'recorder', 'icons'); const iconsDir = path.join(ROOT, 'packages', 'injected', 'src', 'recorder', 'icons');
const outFile = path.join(ROOT, 'packages', 'playwright-core', 'src', 'server', 'injected', 'recorder', 'clipPaths.ts'); const outFile = path.join(ROOT, 'packages', 'injected', 'src', 'recorder', 'clipPaths.ts');
const iconNames = [ const iconNames = [
'gripper', 'gripper',

View File

@ -27,37 +27,37 @@ const esbuild = require('esbuild');
*/ */
const injectedScripts = [ const injectedScripts = [
[ [
path.join(ROOT, 'packages', 'playwright-core', 'src', 'server', 'injected', 'utilityScript.ts'), path.join(ROOT, 'packages', 'injected', 'src', 'utilityScript.ts'),
path.join(ROOT, 'packages', 'playwright-core', 'lib', 'server', 'injected', 'packed'), path.join(ROOT, 'packages', 'playwright-core', 'lib', 'server', 'injected', 'packed'),
path.join(ROOT, 'packages', 'playwright-core', 'src', 'generated'), path.join(ROOT, 'packages', 'playwright-core', 'src', 'generated'),
true, true,
], ],
[ [
path.join(ROOT, 'packages', 'playwright-core', 'src', 'server', 'injected', 'injectedScript.ts'), path.join(ROOT, 'packages', 'injected', 'src', 'injectedScript.ts'),
path.join(ROOT, 'packages', 'playwright-core', 'lib', 'server', 'injected', 'packed'), path.join(ROOT, 'packages', 'playwright-core', 'lib', 'server', 'injected', 'packed'),
path.join(ROOT, 'packages', 'playwright-core', 'src', 'generated'), path.join(ROOT, 'packages', 'playwright-core', 'src', 'generated'),
true, true,
], ],
[ [
path.join(ROOT, 'packages', 'playwright-core', 'src', 'server', 'injected', 'consoleApi.ts'), path.join(ROOT, 'packages', 'injected', 'src', 'consoleApi.ts'),
path.join(ROOT, 'packages', 'playwright-core', 'lib', 'server', 'injected', 'packed'), path.join(ROOT, 'packages', 'playwright-core', 'lib', 'server', 'injected', 'packed'),
path.join(ROOT, 'packages', 'playwright-core', 'src', 'generated'), path.join(ROOT, 'packages', 'playwright-core', 'src', 'generated'),
true, true,
], ],
[ [
path.join(ROOT, 'packages', 'playwright-core', 'src', 'server', 'injected', 'recorder', 'pollingRecorder.ts'), path.join(ROOT, 'packages', 'injected', 'src', 'recorder', 'pollingRecorder.ts'),
path.join(ROOT, 'packages', 'playwright-core', 'lib', 'server', 'injected', 'packed'), path.join(ROOT, 'packages', 'playwright-core', 'lib', 'server', 'injected', 'packed'),
path.join(ROOT, 'packages', 'playwright-core', 'src', 'generated'), path.join(ROOT, 'packages', 'playwright-core', 'src', 'generated'),
true, true,
], ],
[ [
path.join(ROOT, 'packages', 'playwright-core', 'src', 'server', 'injected', 'clock.ts'), path.join(ROOT, 'packages', 'injected', 'src', 'clock.ts'),
path.join(ROOT, 'packages', 'playwright-core', 'lib', 'server', 'injected', 'packed'), path.join(ROOT, 'packages', 'playwright-core', 'lib', 'server', 'injected', 'packed'),
path.join(ROOT, 'packages', 'playwright-core', 'src', 'generated'), path.join(ROOT, 'packages', 'playwright-core', 'src', 'generated'),
true, true,
], ],
[ [
path.join(ROOT, 'packages', 'playwright-core', 'src', 'server', 'injected', 'webSocketMock.ts'), path.join(ROOT, 'packages', 'injected', 'src', 'webSocketMock.ts'),
path.join(ROOT, 'packages', 'playwright-core', 'lib', 'server', 'injected', 'packed'), path.join(ROOT, 'packages', 'playwright-core', 'lib', 'server', 'injected', 'packed'),
path.join(ROOT, 'packages', 'playwright-core', 'src', 'generated'), path.join(ROOT, 'packages', 'playwright-core', 'src', 'generated'),
true, true,