chore: move some files out of server/common (#11466)
This is a directory for sharing code between Node and Web.
This commit is contained in:
parent
ccbe41ec8a
commit
6928c84ac2
|
|
@ -23,7 +23,7 @@ import { rewriteErrorMessage } from '../../utils/stackTrace';
|
||||||
import { debugLogger, RecentLogsCollector } from '../../utils/debugLogger';
|
import { debugLogger, RecentLogsCollector } from '../../utils/debugLogger';
|
||||||
import { ProtocolLogger } from '../types';
|
import { ProtocolLogger } from '../types';
|
||||||
import { helper } from '../helper';
|
import { helper } from '../helper';
|
||||||
import { ProtocolError } from '../common/protocolError';
|
import { ProtocolError } from '../protocolError';
|
||||||
|
|
||||||
export const ConnectionEvents = {
|
export const ConnectionEvents = {
|
||||||
Disconnected: Symbol('ConnectionEvents.Disconnected')
|
Disconnected: Symbol('ConnectionEvents.Disconnected')
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import { Protocol } from './protocol';
|
||||||
import * as js from '../javascript';
|
import * as js from '../javascript';
|
||||||
import { rewriteErrorMessage } from '../../utils/stackTrace';
|
import { rewriteErrorMessage } from '../../utils/stackTrace';
|
||||||
import { parseEvaluationResultValue } from '../common/utilityScriptSerializers';
|
import { parseEvaluationResultValue } from '../common/utilityScriptSerializers';
|
||||||
import { isSessionClosedError } from '../common/protocolError';
|
import { isSessionClosedError } from '../protocolError';
|
||||||
|
|
||||||
export class CRExecutionContext implements js.ExecutionContextDelegate {
|
export class CRExecutionContext implements js.ExecutionContextDelegate {
|
||||||
_client: CRSession;
|
_client: CRSession;
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,15 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { InvalidSelectorError } from './selectorErrors';
|
|
||||||
import * as css from './cssTokenizer';
|
import * as css from './cssTokenizer';
|
||||||
|
|
||||||
|
export class InvalidSelectorError extends Error {
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isInvalidSelectorError(error: Error) {
|
||||||
|
return error instanceof InvalidSelectorError;
|
||||||
|
}
|
||||||
|
|
||||||
// Note: '>=' is used internally for text engine to preserve backwards compatibility.
|
// Note: '>=' is used internally for text engine to preserve backwards compatibility.
|
||||||
type ClauseCombinator = '' | '>' | '+' | '~' | '>=';
|
type ClauseCombinator = '' | '>' | '+' | '~' | '>=';
|
||||||
// TODO: consider
|
// TODO: consider
|
||||||
|
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (c) Microsoft Corporation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export class InvalidSelectorError extends Error {
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isInvalidSelectorError(error: Error) {
|
|
||||||
return error instanceof InvalidSelectorError;
|
|
||||||
}
|
|
||||||
|
|
@ -14,8 +14,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { InvalidSelectorError } from './selectorErrors';
|
import { InvalidSelectorError, CSSComplexSelectorList, parseCSS } from './cssParser';
|
||||||
import { CSSComplexSelectorList, parseCSS } from './cssParser';
|
export { InvalidSelectorError, isInvalidSelectorError } from './cssParser';
|
||||||
|
|
||||||
export type ParsedSelectorPart = {
|
export type ParsedSelectorPart = {
|
||||||
name: string,
|
name: string,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
import * as mime from 'mime';
|
import * as mime from 'mime';
|
||||||
import * as injectedScriptSource from '../generated/injectedScriptSource';
|
import * as injectedScriptSource from '../generated/injectedScriptSource';
|
||||||
import * as channels from '../protocol/channels';
|
import * as channels from '../protocol/channels';
|
||||||
import { isSessionClosedError } from './common/protocolError';
|
import { isSessionClosedError } from './protocolError';
|
||||||
import * as frames from './frames';
|
import * as frames from './frames';
|
||||||
import type { InjectedScript, InjectedScriptPoll, LogEntry, HitTargetInterceptionResult } from './injected/injectedScript';
|
import type { InjectedScript, InjectedScriptPoll, LogEntry, HitTargetInterceptionResult } from './injected/injectedScript';
|
||||||
import { CallMetadata } from './instrumentation';
|
import { CallMetadata } from './instrumentation';
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import { rewriteErrorMessage } from '../../utils/stackTrace';
|
||||||
import { debugLogger, RecentLogsCollector } from '../../utils/debugLogger';
|
import { debugLogger, RecentLogsCollector } from '../../utils/debugLogger';
|
||||||
import { ProtocolLogger } from '../types';
|
import { ProtocolLogger } from '../types';
|
||||||
import { helper } from '../helper';
|
import { helper } from '../helper';
|
||||||
import { ProtocolError } from '../common/protocolError';
|
import { ProtocolError } from '../protocolError';
|
||||||
|
|
||||||
export const ConnectionEvents = {
|
export const ConnectionEvents = {
|
||||||
Disconnected: Symbol('Disconnected'),
|
Disconnected: Symbol('Disconnected'),
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import { FFSession } from './ffConnection';
|
||||||
import { Protocol } from './protocol';
|
import { Protocol } from './protocol';
|
||||||
import { rewriteErrorMessage } from '../../utils/stackTrace';
|
import { rewriteErrorMessage } from '../../utils/stackTrace';
|
||||||
import { parseEvaluationResultValue } from '../common/utilityScriptSerializers';
|
import { parseEvaluationResultValue } from '../common/utilityScriptSerializers';
|
||||||
import { isSessionClosedError } from '../common/protocolError';
|
import { isSessionClosedError } from '../protocolError';
|
||||||
|
|
||||||
export class FFExecutionContext implements js.ExecutionContextDelegate {
|
export class FFExecutionContext implements js.ExecutionContextDelegate {
|
||||||
_session: FFSession;
|
_session: FFSession;
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,9 @@ import { debugLogger } from '../utils/debugLogger';
|
||||||
import { CallMetadata, internalCallMetadata, SdkObject } from './instrumentation';
|
import { CallMetadata, internalCallMetadata, SdkObject } from './instrumentation';
|
||||||
import type InjectedScript from './injected/injectedScript';
|
import type InjectedScript from './injected/injectedScript';
|
||||||
import type { ElementStateWithoutStable, FrameExpectParams, InjectedScriptPoll, InjectedScriptProgress } from './injected/injectedScript';
|
import type { ElementStateWithoutStable, FrameExpectParams, InjectedScriptPoll, InjectedScriptProgress } from './injected/injectedScript';
|
||||||
import { isSessionClosedError } from './common/protocolError';
|
import { isSessionClosedError } from './protocolError';
|
||||||
import { splitSelectorByFrame, stringifySelector } from './common/selectorParser';
|
import { isInvalidSelectorError, splitSelectorByFrame, stringifySelector } from './common/selectorParser';
|
||||||
import { SelectorInfo } from './selectors';
|
import { SelectorInfo } from './selectors';
|
||||||
import { isInvalidSelectorError } from './common/selectorErrors';
|
|
||||||
|
|
||||||
type ContextData = {
|
type ContextData = {
|
||||||
contextPromise: ManualPromise<dom.FrameExecutionContext | Error>;
|
contextPromise: ManualPromise<dom.FrameExecutionContext | Error>;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
import { SelectorEngine, SelectorRoot } from './selectorEngine';
|
import { SelectorEngine, SelectorRoot } from './selectorEngine';
|
||||||
import { isInsideScope } from './selectorEvaluator';
|
import { isInsideScope } from './selectorEvaluator';
|
||||||
import { checkComponentAttribute, parseComponentSelector } from '../common/componentUtils';
|
import { checkComponentAttribute, parseComponentSelector } from './componentUtils';
|
||||||
|
|
||||||
type ComponentNode = {
|
type ComponentNode = {
|
||||||
name: string,
|
name: string,
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
import { SelectorEngine, SelectorRoot } from './selectorEngine';
|
import { SelectorEngine, SelectorRoot } from './selectorEngine';
|
||||||
import { isInsideScope } from './selectorEvaluator';
|
import { isInsideScope } from './selectorEvaluator';
|
||||||
import { checkComponentAttribute, parseComponentSelector } from '../common/componentUtils';
|
import { checkComponentAttribute, parseComponentSelector } from './componentUtils';
|
||||||
|
|
||||||
type ComponentNode = {
|
type ComponentNode = {
|
||||||
name: string,
|
name: string,
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,7 @@ import * as dom from './dom';
|
||||||
import * as frames from './frames';
|
import * as frames from './frames';
|
||||||
import * as js from './javascript';
|
import * as js from './javascript';
|
||||||
import * as types from './types';
|
import * as types from './types';
|
||||||
import { ParsedSelector, parseSelector, stringifySelector } from './common/selectorParser';
|
import { InvalidSelectorError, ParsedSelector, parseSelector, stringifySelector } from './common/selectorParser';
|
||||||
import { InvalidSelectorError } from './common/selectorErrors';
|
|
||||||
import { createGuid } from '../utils/utils';
|
import { createGuid } from '../utils/utils';
|
||||||
|
|
||||||
export type SelectorInfo = {
|
export type SelectorInfo = {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import { debugLogger, RecentLogsCollector } from '../../utils/debugLogger';
|
||||||
import { ProtocolLogger } from '../types';
|
import { ProtocolLogger } from '../types';
|
||||||
import { helper } from '../helper';
|
import { helper } from '../helper';
|
||||||
import { kBrowserClosedError } from '../../utils/errors';
|
import { kBrowserClosedError } from '../../utils/errors';
|
||||||
import { ProtocolError } from '../common/protocolError';
|
import { ProtocolError } from '../protocolError';
|
||||||
|
|
||||||
// WKPlaywright uses this special id to issue Browser.close command which we
|
// WKPlaywright uses this special id to issue Browser.close command which we
|
||||||
// should ignore.
|
// should ignore.
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import { WKSession } from './wkConnection';
|
||||||
import { Protocol } from './protocol';
|
import { Protocol } from './protocol';
|
||||||
import * as js from '../javascript';
|
import * as js from '../javascript';
|
||||||
import { parseEvaluationResultValue } from '../common/utilityScriptSerializers';
|
import { parseEvaluationResultValue } from '../common/utilityScriptSerializers';
|
||||||
import { isSessionClosedError } from '../common/protocolError';
|
import { isSessionClosedError } from '../protocolError';
|
||||||
|
|
||||||
export class WKExecutionContext implements js.ExecutionContextDelegate {
|
export class WKExecutionContext implements js.ExecutionContextDelegate {
|
||||||
private readonly _session: WKSession;
|
private readonly _session: WKSession;
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { playwrightTest as it, expect } from './config/browserTest';
|
import { playwrightTest as it, expect } from './config/browserTest';
|
||||||
import type { ParsedComponentSelector } from '../packages/playwright-core/src/server/common/componentUtils';
|
import { ParsedComponentSelector, parseComponentSelector } from '../packages/playwright-core/src/server/injected/componentUtils';
|
||||||
import { parseComponentSelector } from '../packages/playwright-core/lib/server/common/componentUtils';
|
|
||||||
|
|
||||||
const parse = parseComponentSelector;
|
const parse = parseComponentSelector;
|
||||||
const serialize = (parsed: ParsedComponentSelector) => {
|
const serialize = (parsed: ParsedComponentSelector) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue