mirror of
https://github.com/microsoft/playwright.git
synced 2024-09-11 20:37:54 +03:00
chore: move injected and debug to src/server (#3591)
This commit is contained in:
parent
baa6b64efd
commit
73e53b21df
@ -9,8 +9,8 @@
|
||||
# Include sources from lib, but not map files.
|
||||
!lib/**/*.js
|
||||
# Exclude injected files. A preprocessed version of these is included via lib/generated.
|
||||
# See src/injected/README.md.
|
||||
lib/injected/
|
||||
# See src/server/injected/README.md.
|
||||
lib/server/injected/
|
||||
# Include Windows dependency checker executable.
|
||||
!bin/PrintDeps.exe
|
||||
# Include generated types and entrypoint.
|
||||
|
@ -27,7 +27,7 @@ import { Download } from './download';
|
||||
import { Browser } from './browser';
|
||||
import { EventEmitter } from 'events';
|
||||
import { Progress } from './progress';
|
||||
import { DebugController } from './debug/debugController';
|
||||
import { DebugController } from './server/debug/debugController';
|
||||
import { isDebugMode } from './utils/utils';
|
||||
|
||||
export class Screencast {
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import * as frames from './frames';
|
||||
import { assert } from './utils/utils';
|
||||
import InjectedScript from './injected/injectedScript';
|
||||
import type InjectedScript from './server/injected/injectedScript';
|
||||
import * as injectedScriptSource from './generated/injectedScriptSource';
|
||||
import * as debugScriptSource from './generated/debugScriptSource';
|
||||
import * as js from './javascript';
|
||||
@ -24,7 +24,7 @@ import { Page } from './page';
|
||||
import { selectors, SelectorInfo } from './selectors';
|
||||
import * as types from './types';
|
||||
import { Progress } from './progress';
|
||||
import DebugScript from './debug/injected/debugScript';
|
||||
import type DebugScript from './server/debug/injected/debugScript';
|
||||
import { FatalDOMError, RetargetableDOMError } from './common/domErrors';
|
||||
|
||||
export class FrameExecutionContext extends js.ExecutionContext {
|
||||
|
@ -18,7 +18,7 @@ import * as dom from './dom';
|
||||
import * as utilityScriptSource from './generated/utilityScriptSource';
|
||||
import * as sourceMap from './utils/sourceMap';
|
||||
import { serializeAsCallArgument } from './common/utilityScriptSerializers';
|
||||
import UtilityScript from './injected/utilityScript';
|
||||
import type UtilityScript from './server/injected/utilityScript';
|
||||
|
||||
type ObjectId = string;
|
||||
export type RemoteObject = {
|
||||
|
@ -60,7 +60,7 @@ export class CRConnection extends EventEmitter {
|
||||
if (sessionId)
|
||||
message.sessionId = sessionId;
|
||||
if (debugLogger.isEnabled('protocol'))
|
||||
debugLogger.log('protocol', 'SEND ► ' + rewriteInjectedScriptEvaluationLog(message));
|
||||
debugLogger.log('protocol', 'SEND ► ' + JSON.stringify(message));
|
||||
this._transport.send(message);
|
||||
return id;
|
||||
}
|
||||
@ -209,11 +209,3 @@ function createProtocolError(error: Error, method: string, protocolError: { mess
|
||||
message += ` ${protocolError.data}`;
|
||||
return rewriteErrorMessage(error, message);
|
||||
}
|
||||
|
||||
function rewriteInjectedScriptEvaluationLog(message: ProtocolRequest): string {
|
||||
// Injected script is very long and clutters protocol logs.
|
||||
// To increase development velocity, we skip replace it with short description in the log.
|
||||
if (message.method === 'Runtime.evaluate' && message.params && message.params.expression && message.params.expression.includes('src/injected/injected.ts'))
|
||||
return `{"id":${message.id} [evaluate injected script]}`;
|
||||
return JSON.stringify(message);
|
||||
}
|
||||
|
@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { BrowserContext } from '../browserContext';
|
||||
import * as frames from '../frames';
|
||||
import * as js from '../javascript';
|
||||
import { Page } from '../page';
|
||||
import DebugScript from './injected/debugScript';
|
||||
import { BrowserContext } from '../../browserContext';
|
||||
import * as frames from '../../frames';
|
||||
import * as js from '../../javascript';
|
||||
import { Page } from '../../page';
|
||||
import type DebugScript from './injected/debugScript';
|
||||
|
||||
export class DebugController {
|
||||
constructor(context: BrowserContext) {
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ParsedSelector, parseSelector } from '../../common/selectorParser';
|
||||
import { ParsedSelector, parseSelector } from '../../../common/selectorParser';
|
||||
import type InjectedScript from '../../injected/injectedScript';
|
||||
import { html } from './html';
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import { ConsoleAPI } from './consoleApi';
|
||||
import InjectedScript from '../../injected/injectedScript';
|
||||
import type InjectedScript from '../../injected/injectedScript';
|
||||
|
||||
export default class DebugScript {
|
||||
consoleAPI: ConsoleAPI | undefined;
|
@ -38,9 +38,9 @@ module.exports = {
|
||||
output: {
|
||||
libraryTarget: 'var',
|
||||
filename: 'debugScriptSource.js',
|
||||
path: path.resolve(__dirname, '../../../lib/injected/packed')
|
||||
path: path.resolve(__dirname, '../../../../lib/server/injected/packed')
|
||||
},
|
||||
plugins: [
|
||||
new InlineSource(path.join(__dirname, '..', '..', 'generated', 'debugScriptSource.ts')),
|
||||
new InlineSource(path.join(__dirname, '..', '..', '..', 'generated', 'debugScriptSource.ts')),
|
||||
]
|
||||
};
|
@ -78,7 +78,7 @@ export class FFConnection extends EventEmitter {
|
||||
|
||||
_rawSend(message: ProtocolRequest) {
|
||||
if (debugLogger.isEnabled('protocol'))
|
||||
debugLogger.log('protocol', 'SEND ► ' + rewriteInjectedScriptEvaluationLog(message));
|
||||
debugLogger.log('protocol', 'SEND ► ' + JSON.stringify(message));
|
||||
this._transport.send(message);
|
||||
}
|
||||
|
||||
@ -217,11 +217,3 @@ function createProtocolError(error: Error, method: string, protocolError: { mess
|
||||
message += ` ${protocolError.data}`;
|
||||
return rewriteErrorMessage(error, message);
|
||||
}
|
||||
|
||||
function rewriteInjectedScriptEvaluationLog(message: ProtocolRequest): string {
|
||||
// Injected script is very long and clutters protocol logs.
|
||||
// To increase development velocity, we skip replace it with short description in the log.
|
||||
if (message.method === 'Runtime.evaluate' && message.params && message.params.expression && message.params.expression.includes('src/injected/injected.ts'))
|
||||
return `{"id":${message.id} [evaluate injected script]}`;
|
||||
return JSON.stringify(message);
|
||||
}
|
||||
|
@ -14,14 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import * as types from '../types';
|
||||
import type * as types from '../../types';
|
||||
import { createAttributeEngine } from './attributeSelectorEngine';
|
||||
import { createCSSEngine } from './cssSelectorEngine';
|
||||
import { SelectorEngine, SelectorRoot } from './selectorEngine';
|
||||
import { createTextSelector } from './textSelectorEngine';
|
||||
import { XPathEngine } from './xpathSelectorEngine';
|
||||
import { ParsedSelector } from '../common/selectorParser';
|
||||
import { FatalDOMError } from '../common/domErrors';
|
||||
import { ParsedSelector } from '../../common/selectorParser';
|
||||
import { FatalDOMError } from '../../common/domErrors';
|
||||
|
||||
type Predicate<T> = (progress: types.InjectedScriptProgress, continuePolling: symbol) => T | symbol;
|
||||
|
@ -37,9 +37,9 @@ module.exports = {
|
||||
},
|
||||
output: {
|
||||
filename: 'injectedScriptSource.js',
|
||||
path: path.resolve(__dirname, '../../lib/injected/packed')
|
||||
path: path.resolve(__dirname, '../../../lib/server/injected/packed')
|
||||
},
|
||||
plugins: [
|
||||
new InlineSource(path.join(__dirname, '..', 'generated', 'injectedScriptSource.ts')),
|
||||
new InlineSource(path.join(__dirname, '..', '..', 'generated', 'injectedScriptSource.ts')),
|
||||
]
|
||||
};
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { serializeAsCallArgument, parseEvaluationResultValue } from '../common/utilityScriptSerializers';
|
||||
import { serializeAsCallArgument, parseEvaluationResultValue } from '../../common/utilityScriptSerializers';
|
||||
|
||||
export default class UtilityScript {
|
||||
evaluate(returnByValue: boolean, expression: string) {
|
@ -38,9 +38,9 @@ module.exports = {
|
||||
output: {
|
||||
libraryTarget: 'var',
|
||||
filename: 'utilityScriptSource.js',
|
||||
path: path.resolve(__dirname, '../../lib/injected/packed')
|
||||
path: path.resolve(__dirname, '../../../lib/server/injected/packed')
|
||||
},
|
||||
plugins: [
|
||||
new InlineSource(path.join(__dirname, '..', 'generated', 'utilityScriptSource.ts')),
|
||||
new InlineSource(path.join(__dirname, '..', '..', 'generated', 'utilityScriptSource.ts')),
|
||||
]
|
||||
};
|
@ -54,7 +54,7 @@ export class WKConnection {
|
||||
|
||||
rawSend(message: ProtocolRequest) {
|
||||
if (debugLogger.isEnabled('protocol'))
|
||||
debugLogger.log('protocol', 'SEND ► ' + rewriteInjectedScriptEvaluationLog(message));
|
||||
debugLogger.log('protocol', 'SEND ► ' + JSON.stringify(message));
|
||||
this._transport.send(message);
|
||||
}
|
||||
|
||||
@ -181,11 +181,3 @@ export function createProtocolError(error: Error, method: string, protocolError:
|
||||
export function isSwappedOutError(e: Error) {
|
||||
return e.message.includes('Target was swapped out.');
|
||||
}
|
||||
|
||||
function rewriteInjectedScriptEvaluationLog(message: any): string {
|
||||
// Injected script is very long and clutters protocol logs.
|
||||
// To increase development velocity, we skip replace it with short description in the log.
|
||||
if (message.params && message.params.message && message.params.message.includes('Runtime.evaluate') && message.params.message.includes('src/injected/injected.ts'))
|
||||
return `{"id":${message.id},"method":"${message.method}","params":{"message":[evaluate injected script],"targetId":"${message.params.targetId}"},"pageProxyId":${message.pageProxyId}}`;
|
||||
return JSON.stringify(message);
|
||||
}
|
||||
|
@ -74,6 +74,9 @@ const DEPS = new Map([
|
||||
['src/common/', ['src/common/']],
|
||||
['src/protocol/', ['src/protocol/', 'src/utils/']],
|
||||
['src/install/', ['src/install/', 'src/utils/']],
|
||||
['src/server/debug/', ['src/server/debug/', 'src/common/', 'src/server/injected/', 'src/', 'src/server/debug/injected/']],
|
||||
// TODO: reverse the injected->types dependency.
|
||||
['src/server/injected/', ['src/server/injected/', 'src/common/', 'src/types.ts']],
|
||||
['src/server/chromium/', ['src/server/chromium/', 'src/utils/', 'src/', 'src/common/', 'src/server/']],
|
||||
['src/server/electron/', ['src/server/electron/', 'src/server/chromium/', 'src/utils/', 'src/', 'src/server/']],
|
||||
['src/server/firefox/', ['src/server/firefox/', 'src/utils/', 'src/', 'src/common/', 'src/server/']],
|
||||
|
@ -18,9 +18,9 @@ const child_process = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
const files = [
|
||||
path.join('src', 'injected', 'injectedScript.webpack.config.js'),
|
||||
path.join('src', 'injected', 'utilityScript.webpack.config.js'),
|
||||
path.join('src', 'debug', 'injected', 'debugScript.webpack.config.js'),
|
||||
path.join('src', 'server', 'injected', 'injectedScript.webpack.config.js'),
|
||||
path.join('src', 'server', 'injected', 'utilityScript.webpack.config.js'),
|
||||
path.join('src', 'server', 'debug', 'injected', 'debugScript.webpack.config.js'),
|
||||
];
|
||||
|
||||
function runOne(runner, file) {
|
||||
|
Loading…
Reference in New Issue
Block a user