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

This commit is contained in:
Dmitry Gozman 2020-08-23 20:25:59 -07:00 коммит произвёл GitHub
Родитель baa6b64efd
Коммит 73e53b21df
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
25 изменённых файлов: 32 добавлений и 53 удалений

Просмотреть файл

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