chrome-devtools-frontend 1.0.1543082 → 1.0.1544076

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/AUTHORS +2 -0
  2. package/front_end/core/common/Gzip.ts +4 -4
  3. package/front_end/core/common/common.ts +0 -2
  4. package/front_end/core/host/AidaClient.ts +10 -7
  5. package/front_end/core/host/DispatchHttpRequestClient.ts +18 -3
  6. package/front_end/core/root/DevToolsContext.ts +60 -0
  7. package/front_end/core/root/Runtime.ts +8 -7
  8. package/front_end/core/root/root.ts +6 -1
  9. package/front_end/core/sdk/CPUThrottlingManager.ts +0 -4
  10. package/front_end/core/sdk/CSSMatchedStyles.ts +7 -9
  11. package/front_end/core/sdk/CSSModel.ts +1 -1
  12. package/front_end/core/sdk/CSSRule.ts +18 -6
  13. package/front_end/core/sdk/ChildTargetManager.ts +2 -2
  14. package/front_end/core/sdk/TargetManager.ts +5 -6
  15. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotLoader.ts +2 -0
  16. package/front_end/entrypoints/inspector_main/InspectorMain.ts +1 -13
  17. package/front_end/entrypoints/main/MainImpl.ts +2 -20
  18. package/front_end/foundation/Universe.ts +24 -1
  19. package/front_end/models/ai_assistance/agents/AiAgent.ts +10 -8
  20. package/front_end/models/ai_assistance/agents/PatchAgent.ts +7 -1
  21. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +0 -5
  22. package/front_end/models/ai_assistance/agents/StylingAgent.ts +4 -8
  23. package/front_end/models/ai_code_completion/AiCodeCompletion.ts +1 -1
  24. package/front_end/models/ai_code_generation/AiCodeGeneration.ts +5 -3
  25. package/front_end/models/bindings/CSSWorkspaceBinding.ts +8 -7
  26. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +19 -15
  27. package/front_end/models/bindings/ResourceMapping.ts +57 -15
  28. package/front_end/models/live-metrics/LiveMetrics.ts +12 -20
  29. package/front_end/models/trace/handlers/SamplesHandler.ts +64 -6
  30. package/front_end/models/trace/types/TraceEvents.ts +16 -0
  31. package/front_end/models/workspace/IgnoreListManager.ts +10 -9
  32. package/front_end/models/workspace/WorkspaceImpl.ts +5 -10
  33. package/front_end/panels/accessibility/AccessibilityNodeView.ts +6 -2
  34. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +1 -1
  35. package/front_end/panels/ai_assistance/components/ChatView.ts +2 -4
  36. package/front_end/panels/ai_assistance/components/PerformanceAgentMarkdownRenderer.ts +2 -1
  37. package/front_end/panels/animation/AnimationTimeline.ts +6 -6
  38. package/front_end/panels/application/ApplicationPanelSidebar.ts +0 -1
  39. package/front_end/panels/application/OpenedWindowDetailsView.ts +0 -2
  40. package/front_end/panels/application/ServiceWorkersView.ts +0 -2
  41. package/front_end/panels/application/StorageView.ts +0 -1
  42. package/front_end/panels/application/components/FrameDetailsView.ts +468 -447
  43. package/front_end/panels/application/components/ReportsGrid.ts +7 -2
  44. package/front_end/panels/application/components/SharedStorageAccessGrid.ts +5 -3
  45. package/front_end/panels/application/components/TrustTokensView.ts +7 -1
  46. package/front_end/panels/application/preloading/PreloadingView.ts +10 -4
  47. package/front_end/panels/application/preloading/components/PreloadingDisabledInfobar.ts +7 -11
  48. package/front_end/panels/application/preloading/components/UsedPreloadingView.ts +15 -3
  49. package/front_end/panels/browser_debugger/DOMBreakpointsSidebarPane.ts +12 -13
  50. package/front_end/panels/{elements → common}/DOMLinkifier.ts +6 -6
  51. package/front_end/panels/common/common.ts +1 -0
  52. package/front_end/panels/console/ConsoleView.ts +9 -7
  53. package/front_end/panels/console/ConsoleViewMessage.ts +23 -13
  54. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +2 -1
  55. package/front_end/panels/elements/ElementsTreeElement.ts +3 -1
  56. package/front_end/panels/elements/StylePropertiesSection.ts +52 -15
  57. package/front_end/panels/elements/StylePropertyTreeElement.ts +8 -3
  58. package/front_end/panels/elements/StylesSidebarPane.ts +24 -14
  59. package/front_end/panels/elements/elements-meta.ts +11 -2
  60. package/front_end/panels/elements/elements.ts +0 -3
  61. package/front_end/panels/explain/components/ConsoleInsight.ts +333 -318
  62. package/front_end/panels/issues/AffectedResourcesView.ts +2 -1
  63. package/front_end/panels/lighthouse/LighthouseReportRenderer.ts +2 -1
  64. package/front_end/panels/network/NetworkLogView.ts +1 -1
  65. package/front_end/panels/recorder/RecorderController.ts +7 -1
  66. package/front_end/panels/settings/SettingsScreen.ts +3 -6
  67. package/front_end/panels/settings/components/SyncSection.ts +218 -226
  68. package/front_end/panels/settings/components/syncSection.css +81 -80
  69. package/front_end/panels/sources/AiCodeCompletionPlugin.ts +42 -294
  70. package/front_end/panels/sources/DebuggerPausedMessage.ts +3 -3
  71. package/front_end/panels/sources/DebuggerPlugin.ts +3 -1
  72. package/front_end/panels/sources/ResourceOriginPlugin.ts +7 -3
  73. package/front_end/panels/sources/SourcesPanel.ts +5 -1
  74. package/front_end/panels/timeline/TimelinePanel.ts +0 -21
  75. package/front_end/panels/timeline/TimelineUIUtils.ts +3 -2
  76. package/front_end/panels/timeline/components/LiveMetricsView.ts +7 -4
  77. package/front_end/panels/timeline/components/insights/NodeLink.ts +3 -2
  78. package/front_end/third_party/puppeteer/README.chromium +2 -2
  79. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/HTTPRequest.d.ts +1 -0
  80. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/HTTPRequest.d.ts.map +1 -1
  81. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/HTTPRequest.js +4 -1
  82. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/HTTPRequest.js.map +1 -1
  83. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkEventManager.d.ts +1 -0
  84. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkEventManager.d.ts.map +1 -1
  85. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkEventManager.js +8 -0
  86. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkEventManager.js.map +1 -1
  87. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
  88. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkManager.js +22 -0
  89. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkManager.js.map +1 -1
  90. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
  91. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +3 -3
  92. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +3 -3
  93. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js.map +1 -1
  94. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
  95. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
  96. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
  97. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +34 -6
  98. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/HTTPRequest.d.ts +1 -0
  99. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/HTTPRequest.d.ts.map +1 -1
  100. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/HTTPRequest.js +4 -1
  101. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/HTTPRequest.js.map +1 -1
  102. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkEventManager.d.ts +1 -0
  103. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkEventManager.d.ts.map +1 -1
  104. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkEventManager.js +8 -0
  105. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkEventManager.js.map +1 -1
  106. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
  107. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkManager.js +22 -0
  108. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkManager.js.map +1 -1
  109. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +3 -3
  110. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +3 -3
  111. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js.map +1 -1
  112. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
  113. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
  114. package/front_end/third_party/puppeteer/package/package.json +2 -2
  115. package/front_end/third_party/puppeteer/package/src/cdp/HTTPRequest.ts +5 -1
  116. package/front_end/third_party/puppeteer/package/src/cdp/NetworkEventManager.ts +16 -1
  117. package/front_end/third_party/puppeteer/package/src/cdp/NetworkManager.ts +28 -0
  118. package/front_end/third_party/puppeteer/package/src/revisions.ts +3 -3
  119. package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
  120. package/front_end/ui/components/docs/component_docs.ts +0 -4
  121. package/front_end/ui/components/report_view/ReportView.ts +4 -1
  122. package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +8 -5
  123. package/front_end/ui/i18n/i18n.ts +16 -0
  124. package/front_end/ui/legacy/ReportView.ts +0 -5
  125. package/front_end/ui/legacy/TextPrompt.ts +65 -19
  126. package/front_end/ui/legacy/UIUtils.ts +1 -1
  127. package/front_end/ui/legacy/Widget.ts +56 -25
  128. package/front_end/ui/legacy/XLink.ts +0 -2
  129. package/front_end/ui/legacy/components/object_ui/JavaScriptREPL.ts +8 -4
  130. package/front_end/ui/legacy/components/object_ui/ObjectPopoverHelper.ts +3 -1
  131. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +239 -284
  132. package/front_end/ui/legacy/components/object_ui/RemoteObjectPreviewFormatter.ts +114 -184
  133. package/front_end/ui/legacy/components/utils/Linkifier.ts +1 -1
  134. package/front_end/ui/legacy/inspectorCommon.css +0 -4
  135. package/front_end/ui/{components/docs/theme_colors/basic.ts → legacy/theme_support/ThemeColors.docs.ts} +33 -23
  136. package/mcp/mcp.ts +1 -0
  137. package/package.json +1 -1
  138. package/front_end/core/common/QueryParamHandler.ts +0 -7
  139. package/front_end/ui/components/docs/input/basic.html +0 -31
  140. package/front_end/ui/components/docs/input/basic.ts +0 -12
  141. package/front_end/ui/components/docs/report/basic.html +0 -27
  142. package/front_end/ui/components/docs/report/basic.ts +0 -48
  143. package/front_end/ui/components/docs/theme_colors/basic.html +0 -56
  144. package/front_end/ui/components/docs/toggle_dark_mode.ts +0 -36
  145. package/front_end/ui/components/docs/toggle_fonts.ts +0 -74
  146. package/front_end/ui/components/docs/user_agent_client_hints/basic.html +0 -25
  147. package/front_end/ui/components/docs/user_agent_client_hints/basic.ts +0 -26
  148. package/front_end/ui/components/expandable_list/ExpandableList.docs.ts +0 -30
  149. /package/front_end/panels/{elements → common}/domLinkifier.css +0 -0
package/AUTHORS CHANGED
@@ -18,6 +18,7 @@ Alex Ho <wjhe1016@gmail.com>
18
18
  Alexander Stammbach <alexander@stammbach.io>
19
19
  Alexey Rodionov <fluorescent.hallucinogen@gmail.com>
20
20
  Ameen Basha <ameenbasha111@gmail.com>
21
+ Ankit Kumar Sahu <sahuankit.murhu@gmail.com>
21
22
  Ankit Mishra <ankit.mishra131990@gmail.com>
22
23
  Anna Agoha <annaagoha@gmail.com>
23
24
  Anthony Xie <anthonyxie64@gmail.com>
@@ -68,6 +69,7 @@ Michael Rienstra <mrienstra@gmail.com>
68
69
  Mostafa Aboalkasim <mostafa.aboalkasim.offical@gmail.com>
69
70
  Muhammad Mahad <mahadtxt@gmail.com>
70
71
  Naoto Ono <onoto1998@gmail.com>
72
+ Nourhan Hasan <nourhan.m.hasan@gmail.com>
71
73
  Paras Awasthi <awasthiparas6@gmail.com>
72
74
  Paul Fisher <paul@pfish.zone>
73
75
  Peng Zhou <zhoupeng.1996@bytedance.com>
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Quickly determine if gzipped, by seeing if the first 3 bytes of the file header match the gzip signature
7
7
  */
8
- export function isGzip(ab: ArrayBuffer): boolean {
8
+ export function isGzip(ab: ArrayBufferLike): boolean {
9
9
  const buf = new Uint8Array(ab);
10
10
  if (!buf || buf.length < 3) {
11
11
  return false;
@@ -15,7 +15,7 @@ export function isGzip(ab: ArrayBuffer): boolean {
15
15
  }
16
16
 
17
17
  /** Decode a gzipped _or_ plain text ArrayBuffer to a decoded string */
18
- export async function arrayBufferToString(ab: ArrayBuffer): Promise<string> {
18
+ export async function arrayBufferToString(ab: ArrayBufferLike): Promise<string> {
19
19
  if (isGzip(ab)) {
20
20
  return await decompress(ab);
21
21
  }
@@ -37,7 +37,7 @@ export async function fileToString(file: File): Promise<string> {
37
37
  * Decompress a gzipped ArrayBuffer to a string.
38
38
  * Consider using `arrayBufferToString` instead, which can handle both gzipped and plain text buffers.
39
39
  */
40
- export async function decompress(gzippedBuffer: ArrayBuffer): Promise<string> {
40
+ export async function decompress(gzippedBuffer: ArrayBufferLike): Promise<string> {
41
41
  const buffer = await gzipCodec(gzippedBuffer, new DecompressionStream('gzip'));
42
42
  const str = new TextDecoder('utf-8').decode(buffer);
43
43
  return str;
@@ -50,7 +50,7 @@ export async function compress(str: string): Promise<ArrayBuffer> {
50
50
 
51
51
  /** Private coder/decoder **/
52
52
  async function gzipCodec(
53
- buffer: Uint8Array<ArrayBufferLike>|ArrayBuffer,
53
+ buffer: Uint8Array<ArrayBufferLike>|ArrayBufferLike,
54
54
  codecStream: CompressionStream|DecompressionStream): Promise<ArrayBuffer> {
55
55
  const readable = new ReadableStream({
56
56
  start(controller) {
@@ -21,7 +21,6 @@ import * as Mutex from './Mutex.js';
21
21
  import * as ObjectWrapper from './Object.js';
22
22
  import * as ParsedURL from './ParsedURL.js';
23
23
  import * as Progress from './Progress.js';
24
- import * as QueryParamHandler from './QueryParamHandler.js';
25
24
  import * as ResolverBase from './ResolverBase.js';
26
25
  import * as ResourceType from './ResourceType.js';
27
26
  import * as ReturnToPanel from './ReturnToPanel.js';
@@ -63,7 +62,6 @@ export {
63
62
  ObjectWrapper,
64
63
  ParsedURL,
65
64
  Progress,
66
- QueryParamHandler,
67
65
  ResolverBase,
68
66
  ResourceType,
69
67
  ReturnToPanel,
@@ -707,13 +707,16 @@ export class AidaClient {
707
707
  return {generatedSamples, metadata};
708
708
  }
709
709
 
710
- async generateCode(request: GenerateCodeRequest): Promise<GenerateCodeResponse|null> {
711
- const response = await DispatchHttpRequestClient.makeHttpRequest<GenerateCodeResponse>({
712
- service: SERVICE_NAME,
713
- path: '/v1/aida:generateCode',
714
- method: 'POST',
715
- body: JSON.stringify(request),
716
- });
710
+ async generateCode(request: GenerateCodeRequest, options?: {signal?: AbortSignal}):
711
+ Promise<GenerateCodeResponse|null> {
712
+ const response = await DispatchHttpRequestClient.makeHttpRequest<GenerateCodeResponse>(
713
+ {
714
+ service: SERVICE_NAME,
715
+ path: '/v1/aida:generateCode',
716
+ method: 'POST',
717
+ body: JSON.stringify(request),
718
+ },
719
+ options);
717
720
 
718
721
  return response;
719
722
  }
@@ -8,6 +8,7 @@ import type {DispatchHttpRequestRequest, DispatchHttpRequestResult} from './Insp
8
8
  export enum ErrorType {
9
9
  HTTP_RESPONSE_UNAVAILABLE = 'HTTP_RESPONSE_UNAVAILABLE',
10
10
  NOT_FOUND = 'NOT_FOUND',
11
+ ABORT = 'ABORT',
11
12
  }
12
13
 
13
14
  export class DispatchHttpRequestError extends Error {
@@ -16,9 +17,23 @@ export class DispatchHttpRequestError extends Error {
16
17
  }
17
18
  }
18
19
 
19
- export async function makeHttpRequest<R>(request: DispatchHttpRequestRequest): Promise<R> {
20
- const response = await new Promise<DispatchHttpRequestResult>(resolve => {
21
- InspectorFrontendHostInstance.dispatchHttpRequest(request, resolve);
20
+ export async function makeHttpRequest<R>(
21
+ request: DispatchHttpRequestRequest, options?: {signal?: AbortSignal}): Promise<R> {
22
+ const signal = options?.signal;
23
+ if (signal?.aborted) {
24
+ throw new DispatchHttpRequestError(ErrorType.ABORT);
25
+ }
26
+
27
+ const response = await new Promise<DispatchHttpRequestResult>((resolve, reject) => {
28
+ const onAbort = (): void => {
29
+ reject(new DispatchHttpRequestError(ErrorType.ABORT));
30
+ };
31
+
32
+ signal?.addEventListener('abort', onAbort, {once: true});
33
+ InspectorFrontendHostInstance.dispatchHttpRequest(request, result => {
34
+ signal?.removeEventListener('abort', onAbort);
35
+ resolve(result);
36
+ });
22
37
  });
23
38
 
24
39
  debugLog({request, response});
@@ -0,0 +1,60 @@
1
+ // Copyright 2025 The Chromium Authors
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ export type ConstructorT<T> = new (...args: any[]) => T;
6
+
7
+ /**
8
+ * Container for singletons scoped to a single DevTools universe.
9
+ */
10
+ export class DevToolsContext {
11
+ readonly #instances = new Map<ConstructorT<unknown>, unknown>();
12
+
13
+ get<T>(ctor: ConstructorT<T>): T {
14
+ const instance = this.#instances.get(ctor) as T | undefined;
15
+ if (!instance) {
16
+ throw new Error(`No instance for ${ctor.name}. Ensure the bootstrapper creates it.`);
17
+ }
18
+ return instance;
19
+ }
20
+
21
+ /** @deprecated Should only be used by existing `instance` accessors. */
22
+ has<T>(ctor: ConstructorT<T>): boolean {
23
+ return this.#instances.has(ctor);
24
+ }
25
+
26
+ /**
27
+ * @deprecated Should only be used by existing `instance` accessors and the bootstrapper.
28
+ * Exists on the public interface only for migration purposes for now.
29
+ */
30
+ set<T>(ctor: ConstructorT<T>, instance: T): void {
31
+ // TODO(crbug.com/458180550): We need to throw here if an instance was already set!
32
+ this.#instances.set(ctor, instance);
33
+ }
34
+
35
+ /** @deprecated Should only be used by existing `removeInstance` static methods. */
36
+ delete<T>(ctor: ConstructorT<T>): void {
37
+ this.#instances.delete(ctor);
38
+ }
39
+ }
40
+
41
+ let gInstance: DevToolsContext|null = null;
42
+
43
+ /**
44
+ * @deprecated Exists to migrate instance() methods.
45
+ */
46
+ export function globalInstance(): DevToolsContext {
47
+ if (!gInstance) {
48
+ // TODO(crbug.com/458180550): This should really throw to prevent side-effects and globals
49
+ // from leaking all over the place.
50
+ gInstance = new DevToolsContext();
51
+ }
52
+ return gInstance;
53
+ }
54
+
55
+ /**
56
+ * @deprecated Should only be called by test setup and MainImpl
57
+ */
58
+ export function setGlobalInstance(context: DevToolsContext|null): void {
59
+ gInstance = context;
60
+ }
@@ -70,21 +70,22 @@ export class Runtime {
70
70
  runtimeInstance = undefined;
71
71
  }
72
72
 
73
- static queryParamsObject: URLSearchParams;
73
+ static #queryParamsObject: URLSearchParams;
74
74
 
75
- static getSearchParams(): URLSearchParams {
76
- if (!Runtime.queryParamsObject) {
77
- Runtime.queryParamsObject = new URLSearchParams(location.search);
75
+ static #getSearchParams(): URLSearchParams|null {
76
+ // TODO(crbug.com/451502260): Find a more explicit way to support running in Node.js
77
+ if (!Runtime.#queryParamsObject && 'location' in globalThis) {
78
+ Runtime.#queryParamsObject = new URLSearchParams(location.search);
78
79
  }
79
- return Runtime.queryParamsObject;
80
+ return Runtime.#queryParamsObject;
80
81
  }
81
82
 
82
83
  static queryParam(name: string): string|null {
83
- return Runtime.getSearchParams().get(name);
84
+ return Runtime.#getSearchParams()?.get(name) ?? null;
84
85
  }
85
86
 
86
87
  static setQueryParamForTesting(name: string, value: string): void {
87
- Runtime.getSearchParams().set(name, value);
88
+ Runtime.#getSearchParams()?.set(name, value);
88
89
  }
89
90
 
90
91
  static isNode(): boolean {
@@ -1,6 +1,11 @@
1
1
  // Copyright 2020 The Chromium Authors
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
+
5
+ import * as DevToolsContext from './DevToolsContext.js';
4
6
  import * as Runtime from './Runtime.js';
5
7
 
6
- export {Runtime};
8
+ export {
9
+ DevToolsContext,
10
+ Runtime,
11
+ };
@@ -184,10 +184,6 @@ export interface EventTypes {
184
184
  [Events.HARDWARE_CONCURRENCY_CHANGED]: number;
185
185
  }
186
186
 
187
- export function throttlingManager(): CPUThrottlingManager {
188
- return CPUThrottlingManager.instance();
189
- }
190
-
191
187
  export enum CPUThrottlingRates {
192
188
  NO_THROTTLING = 1,
193
189
  MID_TIER_MOBILE = 4,
@@ -41,7 +41,7 @@ import {
41
41
  VariableMatcher
42
42
  } from './CSSPropertyParserMatchers.js';
43
43
  import {
44
- CSSFontPaletteValuesRule,
44
+ CSSAtRule,
45
45
  CSSFunctionRule,
46
46
  CSSKeyframeRule,
47
47
  CSSKeyframesRule,
@@ -210,7 +210,7 @@ export interface CSSMatchedStylesPayload {
210
210
  positionTryRules: Protocol.CSS.CSSPositionTryRule[];
211
211
  propertyRules: Protocol.CSS.CSSPropertyRule[];
212
212
  cssPropertyRegistrations: Protocol.CSS.CSSPropertyRegistration[];
213
- fontPaletteValuesRule: Protocol.CSS.CSSFontPaletteValuesRule|undefined;
213
+ atRules: Protocol.CSS.CSSAtRule[];
214
214
  animationStylesPayload: Protocol.CSS.CSSAnimationStyle[];
215
215
  transitionsStylePayload: Protocol.CSS.CSSStyle|null;
216
216
  inheritedAnimatedPayload: Protocol.CSS.InheritedAnimatedStyleEntry[];
@@ -305,8 +305,8 @@ export class CSSMatchedStyles {
305
305
  #pseudoDOMCascades?: Map<Protocol.DOM.PseudoType, DOMInheritanceCascade>;
306
306
  #customHighlightPseudoDOMCascades?: Map<string, DOMInheritanceCascade>;
307
307
  #functionRules: CSSFunctionRule[];
308
+ #atRules: CSSAtRule[];
308
309
  #functionRuleMap = new Map<string, CSSFunctionRule>();
309
- readonly #fontPaletteValuesRule: CSSFontPaletteValuesRule|undefined;
310
310
  #environmentVariables: Record<string, string> = {};
311
311
 
312
312
  static async create(payload: CSSMatchedStylesPayload): Promise<CSSMatchedStyles> {
@@ -323,9 +323,9 @@ export class CSSMatchedStyles {
323
323
  positionTryRules,
324
324
  propertyRules,
325
325
  cssPropertyRegistrations,
326
- fontPaletteValuesRule,
327
326
  activePositionFallbackIndex,
328
327
  functionRules,
328
+ atRules,
329
329
  }: CSSMatchedStylesPayload) {
330
330
  this.#cssModel = cssModel;
331
331
  this.#node = node;
@@ -338,11 +338,9 @@ export class CSSMatchedStyles {
338
338
  }
339
339
  this.#positionTryRules = positionTryRules.map(rule => new CSSPositionTryRule(cssModel, rule));
340
340
  this.#parentLayoutNodeId = parentLayoutNodeId;
341
- this.#fontPaletteValuesRule =
342
- fontPaletteValuesRule ? new CSSFontPaletteValuesRule(cssModel, fontPaletteValuesRule) : undefined;
343
-
344
341
  this.#activePositionFallbackIndex = activePositionFallbackIndex;
345
342
  this.#functionRules = functionRules.map(rule => new CSSFunctionRule(cssModel, rule));
343
+ this.#atRules = atRules.map(rule => new CSSAtRule(cssModel, rule));
346
344
  }
347
345
 
348
346
  private async init({
@@ -799,8 +797,8 @@ export class CSSMatchedStyles {
799
797
  return this.#functionRules;
800
798
  }
801
799
 
802
- fontPaletteValuesRule(): CSSFontPaletteValuesRule|undefined {
803
- return this.#fontPaletteValuesRule;
800
+ atRules(): CSSAtRule[] {
801
+ return this.#atRules;
804
802
  }
805
803
 
806
804
  keyframes(): CSSKeyframesRule[] {
@@ -358,7 +358,7 @@ export class CSSModel extends SDKModel<EventTypes> {
358
358
  propertyRules: matchedStylesResponse.cssPropertyRules ?? [],
359
359
  functionRules: matchedStylesResponse.cssFunctionRules ?? [],
360
360
  cssPropertyRegistrations: matchedStylesResponse.cssPropertyRegistrations ?? [],
361
- fontPaletteValuesRule: matchedStylesResponse.cssFontPaletteValuesRule,
361
+ atRules: matchedStylesResponse.cssAtRules ?? [],
362
362
  activePositionFallbackIndex: matchedStylesResponse.activePositionFallbackIndex ?? -1,
363
363
  animationStylesPayload: animatedStylesResponse?.animationStyles || [],
364
364
  inheritedAnimatedPayload: animatedStylesResponse?.inherited || [],
@@ -268,20 +268,32 @@ export class CSSPropertyRule extends CSSRule {
268
268
  }
269
269
  }
270
270
 
271
- export class CSSFontPaletteValuesRule extends CSSRule {
272
- readonly #paletteName: CSSValue;
273
- constructor(cssModel: CSSModel, payload: Protocol.CSS.CSSFontPaletteValuesRule) {
271
+ export class CSSAtRule extends CSSRule {
272
+ readonly #name: CSSValue|null;
273
+ readonly #type: string;
274
+ readonly #subsection: string|null;
275
+ constructor(cssModel: CSSModel, payload: Protocol.CSS.CSSAtRule) {
274
276
  super(cssModel, {
275
277
  origin: payload.origin,
276
278
  style: payload.style,
277
279
  header: styleSheetHeaderForRule(cssModel, payload),
278
280
  originTreeScopeNodeId: undefined
279
281
  });
280
- this.#paletteName = new CSSValue(payload.fontPaletteName);
282
+ this.#name = payload.name ? new CSSValue(payload.name) : null;
283
+ this.#type = payload.type;
284
+ this.#subsection = payload.subsection ?? null;
281
285
  }
282
286
 
283
- name(): CSSValue {
284
- return this.#paletteName;
287
+ name(): CSSValue|null {
288
+ return this.#name;
289
+ }
290
+
291
+ type(): string {
292
+ return this.#type;
293
+ }
294
+
295
+ subsection(): string|null {
296
+ return this.#subsection;
285
297
  }
286
298
  }
287
299
 
@@ -13,7 +13,7 @@ import {SDKModel} from './SDKModel.js';
13
13
  import {SecurityOriginManager} from './SecurityOriginManager.js';
14
14
  import {StorageKeyManager} from './StorageKeyManager.js';
15
15
  import {Capability, type Target, Type} from './Target.js';
16
- import {Events as TargetManagerEvents, TargetManager} from './TargetManager.js';
16
+ import {Events as TargetManagerEvents, type TargetManager} from './TargetManager.js';
17
17
 
18
18
  const UIStrings = {
19
19
  /**
@@ -126,7 +126,7 @@ export class ChildTargetManager extends SDKModel<EventTypes> implements Protocol
126
126
  }
127
127
 
128
128
  private fireAvailableTargetsChanged(): void {
129
- TargetManager.instance().dispatchEventToListeners(
129
+ this.#targetManager.dispatchEventToListeners(
130
130
  TargetManagerEvents.AVAILABLE_TARGETS_CHANGED, [...this.#targetInfos.values()]);
131
131
  }
132
132
 
@@ -13,7 +13,6 @@ import * as Root from '../root/root.js';
13
13
  import {SDKModel} from './SDKModel.js';
14
14
  import {Target, Type as TargetType} from './Target.js';
15
15
 
16
- let targetManagerInstance: TargetManager|undefined;
17
16
  type ModelClass<T = SDKModel> = new (arg1: Target) => T;
18
17
 
19
18
  export class TargetManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
@@ -35,7 +34,7 @@ export class TargetManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes
35
34
  #defaultScopeSet: boolean;
36
35
  readonly #scopeChangeListeners: Set<() => void>;
37
36
 
38
- private constructor() {
37
+ constructor() {
39
38
  super();
40
39
  this.#targets = new Set();
41
40
  this.#observers = new Set();
@@ -52,15 +51,15 @@ export class TargetManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes
52
51
  static instance({forceNew}: {
53
52
  forceNew: boolean,
54
53
  } = {forceNew: false}): TargetManager {
55
- if (!targetManagerInstance || forceNew) {
56
- targetManagerInstance = new TargetManager();
54
+ if (!Root.DevToolsContext.globalInstance().has(TargetManager) || forceNew) {
55
+ Root.DevToolsContext.globalInstance().set(TargetManager, new TargetManager());
57
56
  }
58
57
 
59
- return targetManagerInstance;
58
+ return Root.DevToolsContext.globalInstance().get(TargetManager);
60
59
  }
61
60
 
62
61
  static removeInstance(): void {
63
- targetManagerInstance = undefined;
62
+ Root.DevToolsContext.globalInstance().delete(TargetManager);
64
63
  }
65
64
 
66
65
  onInspectedURLChange(target: Target): void {
@@ -46,6 +46,8 @@ export class HeapSnapshotLoader {
46
46
  }
47
47
 
48
48
  async buildSnapshot(secondWorker: MessagePort): Promise<JSHeapSnapshot> {
49
+ await this.parsingComplete;
50
+
49
51
  this.#snapshot = this.#snapshot || {};
50
52
 
51
53
  this.#progress.updateStatus('Processing snapshot…');
@@ -46,20 +46,8 @@ const UIStrings = {
46
46
  } as const;
47
47
  const str_ = i18n.i18n.registerUIStrings('entrypoints/inspector_main/InspectorMain.ts', UIStrings);
48
48
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
49
- let inspectorMainImplInstance: InspectorMainImpl;
50
49
 
51
50
  export class InspectorMainImpl implements Common.Runnable.Runnable {
52
- static instance(opts: {
53
- forceNew: boolean|null,
54
- } = {forceNew: null}): InspectorMainImpl {
55
- const {forceNew} = opts;
56
- if (!inspectorMainImplInstance || forceNew) {
57
- inspectorMainImplInstance = new InspectorMainImpl();
58
- }
59
-
60
- return inspectorMainImplInstance;
61
- }
62
-
63
51
  async run(): Promise<void> {
64
52
  let firstCall = true;
65
53
  await SDK.Connections.initMainConnection(async () => {
@@ -162,7 +150,7 @@ export class InspectorMainImpl implements Common.Runnable.Runnable {
162
150
  }
163
151
  }
164
152
 
165
- Common.Runnable.registerEarlyInitializationRunnable(InspectorMainImpl.instance);
153
+ Common.Runnable.registerEarlyInitializationRunnable(() => new InspectorMainImpl());
166
154
 
167
155
  export class ReloadActionDelegate implements UI.ActionRegistration.ActionDelegate {
168
156
  handleAction(_context: UI.Context.Context, actionId: string): boolean {
@@ -175,7 +175,8 @@ export class MainImpl {
175
175
  runSettingsMigration: !Host.InspectorFrontendHost.isUnderTest(),
176
176
  },
177
177
  };
178
- new Foundation.Universe.Universe(creationOptions);
178
+ const universe = new Foundation.Universe.Universe(creationOptions);
179
+ Root.DevToolsContext.setGlobalInstance(universe.context);
179
180
 
180
181
  await this.requestAndRegisterLocaleData();
181
182
 
@@ -445,28 +446,9 @@ export class MainImpl {
445
446
  SDK.TargetManager.Events.SUSPEND_STATE_CHANGED, this.#onSuspendStateChanged.bind(this));
446
447
 
447
448
  Workspace.FileManager.FileManager.instance({forceNew: true});
448
- Workspace.Workspace.WorkspaceImpl.instance();
449
449
 
450
450
  Bindings.NetworkProject.NetworkProjectManager.instance();
451
- const resourceMapping = new Bindings.ResourceMapping.ResourceMapping(
452
- targetManager,
453
- Workspace.Workspace.WorkspaceImpl.instance(),
454
- );
455
451
  new Bindings.PresentationConsoleMessageHelper.PresentationConsoleMessageManager();
456
- Bindings.CSSWorkspaceBinding.CSSWorkspaceBinding.instance({
457
- forceNew: true,
458
- resourceMapping,
459
- targetManager,
460
- });
461
- Workspace.IgnoreListManager.IgnoreListManager.instance({
462
- forceNew: true,
463
- });
464
- Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance({
465
- forceNew: true,
466
- resourceMapping,
467
- targetManager,
468
- ignoreListManager: Workspace.IgnoreListManager.IgnoreListManager.instance(),
469
- });
470
452
  targetManager.setScopeTarget(targetManager.primaryPageTarget());
471
453
  UI.Context.Context.instance().addFlavorChangeListener(SDK.Target.Target, ({data}) => {
472
454
  const outermostTarget = data?.outermostTarget();
@@ -3,6 +3,10 @@
3
3
  // found in the LICENSE file.
4
4
 
5
5
  import * as Common from '../core/common/common.js';
6
+ import * as Root from '../core/root/root.js';
7
+ import * as SDK from '../core/sdk/sdk.js';
8
+ import * as Bindings from '../models/bindings/bindings.js';
9
+ import * as Workspace from '../models/workspace/workspace.js';
6
10
 
7
11
  export interface CreationOptions {
8
12
  // Settings things
@@ -10,12 +14,31 @@ export interface CreationOptions {
10
14
  }
11
15
 
12
16
  export class Universe {
17
+ readonly context = new Root.DevToolsContext.DevToolsContext();
18
+
13
19
  constructor(options: CreationOptions) {
14
20
  // TODO(crbug.com/458180550): Store instance on a "DevToolsContext" instead.
15
21
  // For now the global is fine as we don't anticipate the MCP server to change settings.
16
- Common.Settings.Settings.instance({
22
+ const settings = Common.Settings.Settings.instance({
17
23
  forceNew: true,
18
24
  ...options.settingsCreationOptions,
19
25
  });
26
+
27
+ const targetManager = new SDK.TargetManager.TargetManager();
28
+ this.context.set(SDK.TargetManager.TargetManager, targetManager);
29
+
30
+ const workspace = new Workspace.Workspace.WorkspaceImpl();
31
+ this.context.set(Workspace.Workspace.WorkspaceImpl, workspace);
32
+
33
+ const ignoreListManager = new Workspace.IgnoreListManager.IgnoreListManager(settings, targetManager);
34
+ this.context.set(Workspace.IgnoreListManager.IgnoreListManager, ignoreListManager);
35
+
36
+ const resourceMapping = new Bindings.ResourceMapping.ResourceMapping(targetManager, workspace);
37
+ const cssWorkspaceBinding = new Bindings.CSSWorkspaceBinding.CSSWorkspaceBinding(resourceMapping, targetManager);
38
+ this.context.set(Bindings.CSSWorkspaceBinding.CSSWorkspaceBinding, cssWorkspaceBinding);
39
+
40
+ const debuggerWorkspaceBinding = new Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding(
41
+ resourceMapping, targetManager, ignoreListManager, workspace);
42
+ this.context.set(Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding, debuggerWorkspaceBinding);
20
43
  }
21
44
  }
@@ -204,6 +204,15 @@ export type FunctionCallHandlerResult<Result> = {
204
204
  requiresApproval: true,
205
205
  }|{error: string};
206
206
 
207
+ export interface FunctionHandlerOptions {
208
+ /**
209
+ * Shows that the user approved
210
+ * the execution if it was required
211
+ */
212
+ approved?: boolean;
213
+ signal?: AbortSignal;
214
+ }
215
+
207
216
  export interface FunctionDeclaration<Args extends Record<string, unknown>, ReturnType> {
208
217
  /**
209
218
  * Description of function, this is send to the LLM
@@ -228,14 +237,7 @@ export interface FunctionDeclaration<Args extends Record<string, unknown>, Retur
228
237
  /**
229
238
  * Function implementation that the LLM will try to execute,
230
239
  */
231
- handler: (args: Args, options?: {
232
- /**
233
- * Shows that the user approved
234
- * the execution if it was required
235
- */
236
- approved?: boolean,
237
- signal?: AbortSignal,
238
- }) => Promise<FunctionCallHandlerResult<ReturnType>>;
240
+ handler: (args: Args, options?: FunctionHandlerOptions) => Promise<FunctionCallHandlerResult<ReturnType>>;
239
241
  }
240
242
 
241
243
  interface AidaFetchResult {
@@ -151,7 +151,13 @@ export class PatchAgent extends AiAgent<Workspace.Workspace.Project> {
151
151
  return {
152
152
  result: {
153
153
  matches: await this.#project.searchFiles(
154
- args.query, args.caseSensitive, args.isRegex, {signal: options?.signal}),
154
+ args.query,
155
+ args.caseSensitive,
156
+ args.isRegex,
157
+ {
158
+ signal: options?.signal,
159
+ },
160
+ ),
155
161
  }
156
162
  };
157
163
  },
@@ -10,7 +10,6 @@ import * as Root from '../../../core/root/root.js';
10
10
  import * as SDK from '../../../core/sdk/sdk.js';
11
11
  import * as Tracing from '../../../services/tracing/tracing.js';
12
12
  import * as Trace from '../../trace/trace.js';
13
- import {ConversationType} from '../AiHistoryStorage.js';
14
13
  import {
15
14
  PerformanceInsightFormatter,
16
15
  } from '../data_formatters/PerformanceInsightFormatter.js';
@@ -323,10 +322,6 @@ export class PerformanceAgent extends AiAgent<AgentFocus> {
323
322
  };
324
323
  }
325
324
 
326
- getConversationType(): ConversationType {
327
- return ConversationType.PERFORMANCE;
328
- }
329
-
330
325
  async *
331
326
  handleContextDetails(context: ConversationContext<AgentFocus>|null): AsyncGenerator<ContextResponse, void, void> {
332
327
  if (!context) {
@@ -21,9 +21,10 @@ import {
21
21
  ConversationContext,
22
22
  type ConversationSuggestions,
23
23
  type FunctionCallHandlerResult,
24
+ type FunctionHandlerOptions,
24
25
  MultimodalInputType,
25
26
  type RequestOptions,
26
- ResponseType,
27
+ ResponseType
27
28
  } from './AiAgent.js';
28
29
 
29
30
  /*
@@ -268,11 +269,7 @@ export class StylingAgent extends AiAgent<SDK.DOMModel.DOMNode> {
268
269
  #createExtensionScope: CreateExtensionScopeFunction;
269
270
 
270
271
  constructor(opts: AgentOptions) {
271
- super({
272
- aidaClient: opts.aidaClient,
273
- serverSideLoggingEnabled: opts.serverSideLoggingEnabled,
274
- confirmSideEffectForTest: opts.confirmSideEffectForTest,
275
- });
272
+ super(opts);
276
273
 
277
274
  this.#changes = opts.changeManager || new ChangeManager();
278
275
  this.#execJs = opts.execJs ?? executeJsCode;
@@ -633,8 +630,7 @@ const data = {
633
630
  };
634
631
  }
635
632
 
636
- async executeAction(action: string, options?: {signal?: AbortSignal, approved?: boolean}):
637
- Promise<FunctionCallHandlerResult<unknown>> {
633
+ async executeAction(action: string, options?: FunctionHandlerOptions): Promise<FunctionCallHandlerResult<unknown>> {
638
634
  debugLog(`Action to execute: ${action}`);
639
635
 
640
636
  if (options?.approved === false) {
@@ -46,7 +46,7 @@ export interface Callbacks {
46
46
  }
47
47
 
48
48
  /* clang-format off */
49
- const consoleAdditionalContextFileContent = `/**
49
+ export const consoleAdditionalContextFileContent = `/**
50
50
  * This file describes the execution environment of the Chrome DevTools Console.
51
51
  * The code is JavaScript, but with special global functions and variables.
52
52
  * Top-level await is available.