chore: move injected and debug to src/server (#3591)

This commit is contained in:
Dmitry Gozman 2020-08-23 20:25:59 -07:00 committed by GitHub
parent baa6b64efd
commit 73e53b21df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 32 additions and 53 deletions

View File

@ -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.

View File

@ -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 {

View File

@ -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 {

View File

@ -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 = {

View File

@ -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);
}

View File

@ -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) {

View File

@ -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';

View File

@ -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;

View File

@ -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')),
]
};

View File

@ -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);
}

View File

@ -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;

View File

@ -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')),
]
};

View File

@ -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) {

View File

@ -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')),
]
};

View File

@ -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);
}

View File

@ -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/']],

View File

@ -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) {