44 * SPDX-License-Identifier: Apache-2.0
55 */
66
7- import {
8- type Issue ,
9- type AggregatedIssue ,
10- type IssuesManagerEventTypes ,
11- type Target ,
12- DebuggerModel ,
13- Foundation ,
14- TargetManager ,
15- MarkdownIssueDescription ,
16- Marked ,
17- ProtocolClient ,
18- Common ,
19- I18n ,
20- } from '../node_modules/chrome-devtools-frontend/mcp/mcp.js' ;
21-
227import { PuppeteerDevToolsConnection } from './DevToolsConnectionAdapter.js' ;
238import { ISSUE_UTILS } from './issue-descriptions.js' ;
249import { logger } from './logger.js' ;
2510import { Mutex } from './Mutex.js' ;
11+ import { DevTools } from './third_party/index.js' ;
2612import type {
2713 Browser ,
2814 Page ,
@@ -88,14 +74,14 @@ function normalizeUrl(url: string): string {
8874 * A mock implementation of an issues manager that only implements the methods
8975 * that are actually used by the IssuesAggregator
9076 */
91- export class FakeIssuesManager extends Common . ObjectWrapper
92- . ObjectWrapper < IssuesManagerEventTypes > {
93- issues ( ) : Issue [ ] {
77+ export class FakeIssuesManager extends DevTools . Common . ObjectWrapper
78+ . ObjectWrapper < DevTools . IssuesManagerEventTypes > {
79+ issues ( ) : DevTools . Issue [ ] {
9480 return [ ] ;
9581 }
9682}
9783
98- export function mapIssueToMessageObject ( issue : AggregatedIssue ) {
84+ export function mapIssueToMessageObject ( issue : DevTools . AggregatedIssue ) {
9985 const count = issue . getAggregatedIssuesCount ( ) ;
10086 const markdownDescription = issue . getDescription ( ) ;
10187 const filename = markdownDescription ?. file ;
@@ -114,12 +100,14 @@ export function mapIssueToMessageObject(issue: AggregatedIssue) {
114100 let title : string | null ;
115101
116102 try {
117- processedMarkdown = MarkdownIssueDescription . substitutePlaceholders (
118- rawMarkdown ,
119- markdownDescription . substitutions ,
120- ) ;
121- const markdownAst = Marked . Marked . lexer ( processedMarkdown ) ;
122- title = MarkdownIssueDescription . findTitleFromMarkdownAst ( markdownAst ) ;
103+ processedMarkdown =
104+ DevTools . MarkdownIssueDescription . substitutePlaceholders (
105+ rawMarkdown ,
106+ markdownDescription . substitutions ,
107+ ) ;
108+ const markdownAst = DevTools . Marked . Marked . lexer ( processedMarkdown ) ;
109+ title =
110+ DevTools . MarkdownIssueDescription . findTitleFromMarkdownAst ( markdownAst ) ;
123111 } catch {
124112 logger ( 'error parsing markdown for issue ' + issue . code ( ) ) ;
125113 return null ;
@@ -138,22 +126,22 @@ export function mapIssueToMessageObject(issue: AggregatedIssue) {
138126}
139127
140128// DevTools CDP errors can get noisy.
141- ProtocolClient . InspectorBackend . test . suppressRequestErrors = true ;
129+ DevTools . ProtocolClient . InspectorBackend . test . suppressRequestErrors = true ;
142130
143- I18n . DevToolsLocale . DevToolsLocale . instance ( {
131+ DevTools . I18n . DevToolsLocale . DevToolsLocale . instance ( {
144132 create : true ,
145133 data : {
146134 navigatorLanguage : 'en-US' ,
147135 settingLanguage : 'en-US' ,
148136 lookupClosestDevToolsLocale : l => l ,
149137 } ,
150138} ) ;
151- I18n . i18n . registerLocaleDataForTest ( 'en-US' , { } ) ;
139+ DevTools . I18n . i18n . registerLocaleDataForTest ( 'en-US' , { } ) ;
152140
153141export interface TargetUniverse {
154142 /** The DevTools target corresponding to the puppeteer Page */
155- target : Target ;
156- universe : Foundation . Universe . Universe ;
143+ target : DevTools . SDKTarget ;
144+ universe : DevTools . Foundation . Universe . Universe ;
157145}
158146export type TargetUniverseFactoryFn = ( page : Page ) => Promise < TargetUniverse > ;
159147
@@ -232,22 +220,23 @@ export class UniverseManager {
232220}
233221
234222const DEFAULT_FACTORY : TargetUniverseFactoryFn = async ( page : Page ) => {
235- const settingStorage = new Common . Settings . SettingsStorage ( { } ) ;
236- const universe = new Foundation . Universe . Universe ( {
223+ const settingStorage = new DevTools . Common . Settings . SettingsStorage ( { } ) ;
224+ const universe = new DevTools . Foundation . Universe . Universe ( {
237225 settingsCreationOptions : {
238226 syncedStorage : settingStorage ,
239227 globalStorage : settingStorage ,
240228 localStorage : settingStorage ,
241- settingRegistrations : Common . SettingRegistration . getRegisteredSettings ( ) ,
229+ settingRegistrations :
230+ DevTools . Common . SettingRegistration . getRegisteredSettings ( ) ,
242231 } ,
243- overrideAutoStartModels : new Set ( [ DebuggerModel ] ) ,
232+ overrideAutoStartModels : new Set ( [ DevTools . DebuggerModel ] ) ,
244233 } ) ;
245234
246235 const session = await page . createCDPSession ( ) ;
247236 const connection = new PuppeteerDevToolsConnection ( session ) ;
248237
249- const targetManager = universe . context . get ( TargetManager ) ;
250- targetManager . observeModels ( DebuggerModel , SKIP_ALL_PAUSES ) ;
238+ const targetManager = universe . context . get ( DevTools . TargetManager ) ;
239+ targetManager . observeModels ( DevTools . DebuggerModel , SKIP_ALL_PAUSES ) ;
251240
252241 const target = targetManager . createTarget (
253242 'main' ,
@@ -267,7 +256,7 @@ const DEFAULT_FACTORY: TargetUniverseFactoryFn = async (page: Page) => {
267256// sent. This means DevTools can still pause, step and do whatever. We just won't
268257// see the `Debugger.paused`/`Debugger.resumed` events on the MCP side.
269258const SKIP_ALL_PAUSES = {
270- modelAdded ( model : DebuggerModel ) : void {
259+ modelAdded ( model : DevTools . DebuggerModel ) : void {
271260 void model . agent . invoke_setSkipAllPauses ( { skip : true } ) ;
272261 } ,
273262
0 commit comments