mirror of
https://github.com/ChromeDevTools/chrome-devtools-mcp.git
synced 2026-09-14 19:45:30 +08:00
refactor: move files to folders that better represent their use (#2564)
This commit is contained in:
+5
-5
@@ -10,17 +10,17 @@ import path from 'node:path';
|
||||
import {fileURLToPath, pathToFileURL} from 'node:url';
|
||||
|
||||
import {overrideDevToolsGlobals} from './devtools/DevtoolsUtils.js';
|
||||
import {HeapSnapshotManager} from './HeapSnapshotManager.js';
|
||||
import {HeapSnapshotManager} from './processors/HeapSnapshotManager.js';
|
||||
import type {
|
||||
HeapSnapshotAggregateData,
|
||||
HeapSnapshotClassDiff,
|
||||
HeapSnapshotDetailedClassDiff,
|
||||
DuplicateStringGroup,
|
||||
HeapEdgesQueryOptions,
|
||||
} from './HeapSnapshotManager.js';
|
||||
} from './processors/HeapSnapshotManager.js';
|
||||
import {McpPage} from './McpPage.js';
|
||||
import {type UncaughtError} from './PageCollector.js';
|
||||
import {ServiceWorkerConsoleCollector} from './ServiceWorkerCollector.js';
|
||||
import {type UncaughtError} from './collectors/PageCollector.js';
|
||||
import {ServiceWorkerConsoleCollector} from './collectors/ServiceWorkerCollector.js';
|
||||
import {
|
||||
Locator,
|
||||
type Browser,
|
||||
@@ -45,7 +45,7 @@ import type {
|
||||
DevToolsData,
|
||||
SupportedExtensions,
|
||||
} from './tools/ToolDefinition.js';
|
||||
import type {TraceResult} from './trace-processing/parse.js';
|
||||
import type {TraceResult} from './processors/PerformanceTrace.js';
|
||||
import type {Logger} from './types.js';
|
||||
import type {ExtensionServiceWorker} from './types.js';
|
||||
import {getTempFilePath, resolveCanonicalPath} from './utils/files.js';
|
||||
|
||||
+2
-2
@@ -64,7 +64,7 @@ import {
|
||||
NetworkCollector,
|
||||
type ListenerMap,
|
||||
type UncaughtError,
|
||||
} from './PageCollector.js';
|
||||
} from './collectors/PageCollector.js';
|
||||
import {TextSnapshot} from './TextSnapshot.js';
|
||||
import type {Locator} from './third_party/index.js';
|
||||
import {
|
||||
@@ -100,7 +100,7 @@ import {
|
||||
WaitForHelper,
|
||||
type WaitForEventsResult,
|
||||
type DialogAction,
|
||||
} from './WaitForHelper.js';
|
||||
} from './utils/WaitForHelper.js';
|
||||
|
||||
/**
|
||||
* Per-page state wrapper. Consolidates dialog, snapshot, emulation,
|
||||
|
||||
+19
-7
@@ -21,10 +21,10 @@ import type {
|
||||
HeapSnapshotClassDiff,
|
||||
HeapSnapshotDetailedClassDiff,
|
||||
DuplicateStringGroup,
|
||||
} from './HeapSnapshotManager.js';
|
||||
} from './processors/HeapSnapshotManager.js';
|
||||
import type {McpContext} from './McpContext.js';
|
||||
import type {McpPage} from './McpPage.js';
|
||||
import {UncaughtError} from './PageCollector.js';
|
||||
import {UncaughtError} from './collectors/PageCollector.js';
|
||||
import {TextSnapshot} from './TextSnapshot.js';
|
||||
import {DevTools, getToonEncode, getGcfEncode} from './third_party/index.js';
|
||||
import type {
|
||||
@@ -45,13 +45,17 @@ import type {
|
||||
Response,
|
||||
SnapshotParams,
|
||||
} from './tools/ToolDefinition.js';
|
||||
import type {InsightName, TraceResult} from './trace-processing/parse.js';
|
||||
import {getInsightOutput, getTraceSummary} from './trace-processing/parse.js';
|
||||
import {
|
||||
type InsightName,
|
||||
type TraceResult,
|
||||
getInsightOutput,
|
||||
getTraceSummary,
|
||||
} from './processors/PerformanceTrace.js';
|
||||
import type {PaginationOptions} from './types.js';
|
||||
import type {WithSymbolId} from './utils/id.js';
|
||||
import {stableIdSymbol} from './utils/id.js';
|
||||
import {paginate} from './utils/pagination.js';
|
||||
import type {WaitForEventsResult} from './WaitForHelper.js';
|
||||
import type {WaitForEventsResult} from './utils/WaitForHelper.js';
|
||||
|
||||
const {formatBytesToKb} = DevTools.I18n.ByteUtilities;
|
||||
|
||||
@@ -755,7 +759,10 @@ export class McpResponse implements Response {
|
||||
consoleMessage?: object;
|
||||
consoleMessages?: object[];
|
||||
traceSummary?: string;
|
||||
traceInsights?: Array<{insightName: string; insightKey: string}>;
|
||||
traceInsights?: Array<{
|
||||
insightName: string;
|
||||
insightKey: string | undefined;
|
||||
}>;
|
||||
lighthouseResult?: object;
|
||||
extensions?: object[];
|
||||
thirdPartyDeveloperTools?: object[];
|
||||
@@ -1013,7 +1020,12 @@ Call ${handleDialog.name} to handle it before continuing.`);
|
||||
for (const [insightName, model] of Object.entries(insightSet.model)) {
|
||||
structuredContent.traceInsights.push({
|
||||
insightName,
|
||||
insightKey: model.insightKey,
|
||||
insightKey:
|
||||
typeof model === 'object' &&
|
||||
model !== null &&
|
||||
'insightKey' in model
|
||||
? model.insightKey
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,27 +4,27 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import {FakeIssuesManager} from './devtools/DevtoolsUtils.js';
|
||||
import {FakeIssuesManager} from '../devtools/DevtoolsUtils.js';
|
||||
import type {
|
||||
CDPSession,
|
||||
ConsoleMessage,
|
||||
Protocol,
|
||||
Issue,
|
||||
} from './third_party/index.js';
|
||||
import {DevTools} from './third_party/index.js';
|
||||
} from '../third_party/index.js';
|
||||
import {DevTools} from '../third_party/index.js';
|
||||
import {
|
||||
type Frame,
|
||||
type Handler,
|
||||
type HTTPRequest,
|
||||
type Page,
|
||||
type PageEvents as PuppeteerPageEvents,
|
||||
} from './third_party/index.js';
|
||||
} from '../third_party/index.js';
|
||||
import {
|
||||
createIdGenerator,
|
||||
stableIdSymbol,
|
||||
type WithSymbolId,
|
||||
} from './utils/id.js';
|
||||
import {logger} from './utils/logger.js';
|
||||
} from '../utils/id.js';
|
||||
import {logger} from '../utils/logger.js';
|
||||
|
||||
export class UncaughtError {
|
||||
readonly details: Protocol.Runtime.ExceptionDetails;
|
||||
@@ -12,10 +12,10 @@ import type {
|
||||
CDPSession,
|
||||
Protocol,
|
||||
Browser,
|
||||
} from './third_party/index.js';
|
||||
import type {ExtensionServiceWorker} from './types.js';
|
||||
import type {WithSymbolId} from './utils/id.js';
|
||||
import {createIdGenerator, stableIdSymbol} from './utils/id.js';
|
||||
} from '../third_party/index.js';
|
||||
import type {ExtensionServiceWorker} from '../types.js';
|
||||
import type {WithSymbolId} from '../utils/id.js';
|
||||
import {createIdGenerator, stableIdSymbol} from '../utils/id.js';
|
||||
|
||||
const CHROME_EXTENSION_PREFIX = 'chrome-extension://';
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
type TargetUniverse,
|
||||
SymbolizedError,
|
||||
} from '../devtools/DevtoolsUtils.js';
|
||||
import {UncaughtError} from '../PageCollector.js';
|
||||
import {UncaughtError} from '../collectors/PageCollector.js';
|
||||
import * as DevTools from '../third_party/index.js';
|
||||
import type {ConsoleMessage} from '../third_party/index.js';
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import type {
|
||||
HeapSnapshotClassDiff,
|
||||
HeapSnapshotDetailedClassDiff,
|
||||
DuplicateStringGroup,
|
||||
} from '../HeapSnapshotManager.js';
|
||||
} from '../processors/HeapSnapshotManager.js';
|
||||
import {DevTools} from '../third_party/index.js';
|
||||
import {stableIdSymbol} from '../utils/id.js';
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
import fsSync from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
import {DevTools} from './third_party/index.js';
|
||||
import {DevTools} from '../third_party/index.js';
|
||||
import {
|
||||
createIdGenerator,
|
||||
stableIdSymbol,
|
||||
type WithSymbolId,
|
||||
} from './utils/id.js';
|
||||
} from '../utils/id.js';
|
||||
|
||||
export type AggregatedInfoWithId =
|
||||
WithSymbolId<DevTools.HeapSnapshotModel.HeapSnapshotModel.AggregatedInfo>;
|
||||
@@ -366,7 +366,7 @@ export class HeapSnapshotManager {
|
||||
/* noop */
|
||||
},
|
||||
DevTools.Common.Console.Console.instance(),
|
||||
import.meta.resolve('./third_party/devtools-heap-snapshot-worker.js'),
|
||||
import.meta.resolve('../third_party/devtools-heap-snapshot-worker.js'),
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -11,7 +11,7 @@ import type {
|
||||
HeapSnapshotDetailedClassDiff,
|
||||
DuplicateStringGroup,
|
||||
HeapEdgesQueryOptions,
|
||||
} from '../HeapSnapshotManager.js';
|
||||
} from '../processors/HeapSnapshotManager.js';
|
||||
import type {McpPage} from '../McpPage.js';
|
||||
import {zod} from '../third_party/index.js';
|
||||
import type {
|
||||
@@ -29,14 +29,17 @@ import type {
|
||||
Protocol,
|
||||
Page,
|
||||
} from '../third_party/index.js';
|
||||
import type {InsightName, TraceResult} from '../trace-processing/parse.js';
|
||||
import type {InsightName, TraceResult} from '../processors/PerformanceTrace.js';
|
||||
import type {
|
||||
TextSnapshotNode,
|
||||
GeolocationOptions,
|
||||
ExtensionServiceWorker,
|
||||
} from '../types.js';
|
||||
import type {PaginationOptions} from '../types.js';
|
||||
import type {WaitForEventsResult, DialogAction} from '../WaitForHelper.js';
|
||||
import type {
|
||||
WaitForEventsResult,
|
||||
DialogAction,
|
||||
} from '../utils/WaitForHelper.js';
|
||||
|
||||
import type {ToolCategory} from './categories.js';
|
||||
import type {ToolGroups} from './thirdPartyDeveloper.js';
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import type {ElementHandle, KeyInput} from '../third_party/index.js';
|
||||
import type {TextSnapshotNode} from '../types.js';
|
||||
import {parseKey} from '../utils/keyboard.js';
|
||||
import {logger} from '../utils/logger.js';
|
||||
import type {WaitForEventsResult} from '../WaitForHelper.js';
|
||||
import type {WaitForEventsResult} from '../utils/WaitForHelper.js';
|
||||
|
||||
import {ToolCategory} from './categories.js';
|
||||
import type {ContextPage} from './ToolDefinition.js';
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
import zlib from 'node:zlib';
|
||||
|
||||
import {zod, DevTools} from '../third_party/index.js';
|
||||
import type {InsightName, TraceResult} from '../trace-processing/parse.js';
|
||||
import type {InsightName, TraceResult} from '../processors/PerformanceTrace.js';
|
||||
import {
|
||||
parseRawTraceBuffer,
|
||||
traceResultIsSuccess,
|
||||
} from '../trace-processing/parse.js';
|
||||
} from '../processors/PerformanceTrace.js';
|
||||
import {logger} from '../utils/logger.js';
|
||||
|
||||
import {ToolCategory} from './categories.js';
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import type {Page, Protocol, CdpPage, Dialog} from './third_party/index.js';
|
||||
import type {PredefinedNetworkConditions} from './third_party/index.js';
|
||||
import {logger} from './utils/logger.js';
|
||||
import type {Page, Protocol, CdpPage, Dialog} from '../third_party/index.js';
|
||||
import type {PredefinedNetworkConditions} from '../third_party/index.js';
|
||||
import {logger} from './logger.js';
|
||||
|
||||
export type DialogAction = 'accept' | 'dismiss' | string;
|
||||
|
||||
@@ -20,7 +20,7 @@ import {McpContext} from '../src/McpContext.js';
|
||||
import {McpPage} from '../src/McpPage.js';
|
||||
import {TextSnapshot} from '../src/TextSnapshot.js';
|
||||
import {type HTTPResponse} from '../src/third_party/index.js';
|
||||
import type {TraceResult} from '../src/trace-processing/parse.js';
|
||||
import type {TraceResult} from '../src/processors/PerformanceTrace.js';
|
||||
|
||||
import {
|
||||
getMockRequest,
|
||||
|
||||
@@ -23,11 +23,11 @@ import {
|
||||
newPage,
|
||||
selectPage,
|
||||
} from '../src/tools/pages.js';
|
||||
import type {InsightName} from '../src/trace-processing/parse.js';
|
||||
import type {InsightName} from '../src/processors/PerformanceTrace.js';
|
||||
import {
|
||||
parseRawTraceBuffer,
|
||||
traceResultIsSuccess,
|
||||
} from '../src/trace-processing/parse.js';
|
||||
} from '../src/processors/PerformanceTrace.js';
|
||||
|
||||
import {serverHooks} from './server.js';
|
||||
import {loadTraceAsBuffer} from './trace-processing/fixtures/load.js';
|
||||
|
||||
@@ -10,15 +10,15 @@ import {afterEach, beforeEach, describe, it} from 'node:test';
|
||||
import type {Frame, HTTPRequest, Protocol} from 'puppeteer-core';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import type {ListenerMap} from '../src/PageCollector.js';
|
||||
import type {ListenerMap} from '../../src/collectors/PageCollector.js';
|
||||
import {
|
||||
ConsoleCollector,
|
||||
NetworkCollector,
|
||||
PageCollector,
|
||||
} from '../src/PageCollector.js';
|
||||
import {DevTools} from '../src/third_party/index.js';
|
||||
} from '../../src/collectors/PageCollector.js';
|
||||
import {DevTools} from '../../src/third_party/index.js';
|
||||
|
||||
import {getMockRequest, getMockBrowser} from './utils.js';
|
||||
import {getMockRequest, getMockBrowser} from '../utils.js';
|
||||
|
||||
describe('PageCollector', () => {
|
||||
it('works', async () => {
|
||||
+4
-4
@@ -7,10 +7,10 @@
|
||||
import assert from 'node:assert';
|
||||
import {describe, it} from 'node:test';
|
||||
|
||||
import {UncaughtError} from '../src/PageCollector.js';
|
||||
import {ServiceWorkerConsoleCollector} from '../src/ServiceWorkerCollector.js';
|
||||
import type {Protocol} from '../src/third_party/index.js';
|
||||
import {stableIdSymbol} from '../src/utils/id.js';
|
||||
import {UncaughtError} from '../../src/collectors/PageCollector.js';
|
||||
import {ServiceWorkerConsoleCollector} from '../../src/collectors/ServiceWorkerCollector.js';
|
||||
import type {Protocol} from '../../src/third_party/index.js';
|
||||
import {stableIdSymbol} from '../../src/utils/id.js';
|
||||
|
||||
describe('ServiceWorkerConsoleCollector', () => {
|
||||
it('limits logs to 1000 per extension', () => {
|
||||
@@ -8,7 +8,7 @@ import {describe, it} from 'node:test';
|
||||
|
||||
import {SymbolizedError} from '../../src/devtools/DevtoolsUtils.js';
|
||||
import {ConsoleFormatter} from '../../src/formatters/ConsoleFormatter.js';
|
||||
import {UncaughtError} from '../../src/PageCollector.js';
|
||||
import {UncaughtError} from '../../src/collectors/PageCollector.js';
|
||||
import type {ConsoleMessage, Protocol} from '../../src/third_party/index.js';
|
||||
import type {DevTools} from '../../src/third_party/index.js';
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import {describe, it, afterEach} from 'node:test';
|
||||
|
||||
import sinon from 'sinon';
|
||||
|
||||
import {HeapSnapshotManager} from '../src/HeapSnapshotManager.js';
|
||||
import {DevTools} from '../src/third_party/index.js';
|
||||
import {HeapSnapshotManager} from '../../src/processors/HeapSnapshotManager.js';
|
||||
import {DevTools} from '../../src/third_party/index.js';
|
||||
|
||||
describe('HeapSnapshotManager', () => {
|
||||
afterEach(() => {
|
||||
@@ -15,11 +15,11 @@ import {
|
||||
startTrace,
|
||||
stopTrace,
|
||||
} from '../../src/tools/performance.js';
|
||||
import type {TraceResult} from '../../src/trace-processing/parse.js';
|
||||
import {
|
||||
parseRawTraceBuffer,
|
||||
type TraceResult,
|
||||
traceResultIsSuccess,
|
||||
} from '../../src/trace-processing/parse.js';
|
||||
} from '../../src/processors/PerformanceTrace.js';
|
||||
import {loadTraceAsBuffer} from '../trace-processing/fixtures/load.js';
|
||||
import {withMcpContext} from '../utils.js';
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import type {ParsedArguments} from '../../src/bin/chrome-devtools-mcp-cli-option
|
||||
import {TextSnapshot} from '../../src/TextSnapshot.js';
|
||||
import {installExtension} from '../../src/tools/extensions.js';
|
||||
import {evaluateScript} from '../../src/tools/script.js';
|
||||
import {WaitForHelper} from '../../src/WaitForHelper.js';
|
||||
import {WaitForHelper} from '../../src/utils/WaitForHelper.js';
|
||||
import {serverHooks} from '../server.js';
|
||||
import {
|
||||
assertNoServiceWorkerReported,
|
||||
|
||||
@@ -10,7 +10,7 @@ import {describe, it} from 'node:test';
|
||||
import {
|
||||
getTraceSummary,
|
||||
parseRawTraceBuffer,
|
||||
} from '../../src/trace-processing/parse.js';
|
||||
} from '../../src/processors/PerformanceTrace.js';
|
||||
|
||||
import {loadTraceAsBuffer} from './fixtures/load.js';
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
import assert from 'node:assert';
|
||||
import {describe, it} from 'node:test';
|
||||
|
||||
import {serverHooks} from './server.js';
|
||||
import {html, withMcpContext} from './utils.js';
|
||||
import {serverHooks} from '../server.js';
|
||||
import {html, withMcpContext} from '../utils.js';
|
||||
|
||||
describe('WaitForHelper', () => {
|
||||
const server = serverHooks();
|
||||
@@ -16,8 +16,8 @@ import sinon from 'sinon';
|
||||
import {
|
||||
checkForUpdates,
|
||||
resetUpdateCheckFlagForTesting,
|
||||
} from '../src/utils/check-for-updates.js';
|
||||
import {VERSION} from '../src/version.js';
|
||||
} from '../../src/utils/check-for-updates.js';
|
||||
import {VERSION} from '../../src/version.js';
|
||||
|
||||
describe('checkForUpdates', () => {
|
||||
beforeEach(() => {
|
||||
Reference in New Issue
Block a user