chrome-devtools-frontend 1.0.1544076 → 1.0.1547147

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 (178) hide show
  1. package/config/typescript/tsconfig.eslint.json +1 -0
  2. package/docs/styleguide/ux/styles.md +1 -1
  3. package/eslint.config.mjs +1 -1
  4. package/front_end/Images/src/arrow-down.svg +8 -1
  5. package/front_end/Images/src/arrow-up.svg +8 -1
  6. package/front_end/core/common/ParsedURL.ts +1 -1
  7. package/front_end/core/common/common.ts +0 -2
  8. package/front_end/core/host/AidaClient.ts +1 -1
  9. package/front_end/core/host/InspectorFrontendHostAPI.ts +0 -1
  10. package/front_end/core/host/UserMetrics.ts +0 -5
  11. package/front_end/core/platform/HostRuntime.ts +18 -0
  12. package/front_end/core/platform/KeyboardUtilities.ts +2 -2
  13. package/front_end/core/platform/StringUtilities.ts +1 -1
  14. package/front_end/core/platform/api/HostRuntime.ts +20 -0
  15. package/front_end/core/platform/api/api.ts +7 -0
  16. package/front_end/core/platform/browser/HostRuntime.ts +14 -0
  17. package/front_end/core/platform/browser/browser.ts +7 -0
  18. package/front_end/core/platform/node/HostRuntime.ts +13 -0
  19. package/front_end/core/platform/node/node.ts +7 -0
  20. package/front_end/core/platform/platform.ts +2 -2
  21. package/front_end/core/protocol_client/CDPConnection.ts +3 -3
  22. package/front_end/core/protocol_client/DevToolsCDPConnection.ts +2 -1
  23. package/front_end/core/sdk/CSSMetadata.ts +17 -5
  24. package/front_end/core/sdk/NetworkManager.ts +6 -8
  25. package/front_end/core/sdk/NetworkRequest.ts +4 -0
  26. package/front_end/core/sdk/SDKModel.ts +4 -2
  27. package/front_end/core/sdk/SourceMapScopesInfo.ts +141 -23
  28. package/front_end/core/sdk/Target.ts +5 -14
  29. package/front_end/core/sdk/TargetManager.ts +39 -18
  30. package/front_end/core/sdk/sdk-meta.ts +62 -0
  31. package/front_end/devtools_compatibility.js +0 -1
  32. package/front_end/entrypoints/main/MainImpl.ts +2 -2
  33. package/front_end/foundation/Universe.ts +2 -2
  34. package/front_end/generated/Deprecation.ts +11 -0
  35. package/front_end/generated/InspectorBackendCommands.ts +3 -6
  36. package/front_end/generated/SupportedCSSProperties.js +4 -25
  37. package/front_end/generated/protocol-mapping.d.ts +0 -15
  38. package/front_end/generated/protocol-proxy-api.d.ts +0 -11
  39. package/front_end/generated/protocol.ts +5 -36
  40. package/front_end/models/ai_assistance/AiConversation.ts +188 -0
  41. package/front_end/models/ai_assistance/AiHistoryStorage.ts +1 -172
  42. package/front_end/models/ai_assistance/ConversationHandler.ts +5 -5
  43. package/front_end/models/ai_assistance/agents/AiAgent.ts +1 -3
  44. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +6 -2
  45. package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +1 -1
  46. package/front_end/models/ai_assistance/agents/StylingAgent.ts +3 -9
  47. package/front_end/models/ai_assistance/ai_assistance.ts +2 -0
  48. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +313 -313
  49. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +8 -6
  50. package/front_end/models/ai_assistance/performance/AICallTree.snapshot.txt +33 -33
  51. package/front_end/models/ai_assistance/performance/AICallTree.ts +9 -3
  52. package/front_end/models/bindings/CSSWorkspaceBinding.ts +5 -3
  53. package/front_end/models/bindings/SASSSourceMapping.ts +6 -4
  54. package/front_end/models/cpu_profile/CPUProfileDataModel.ts +10 -7
  55. package/front_end/models/crux-manager/CrUXManager.ts +7 -4
  56. package/front_end/models/issues_manager/GenericIssue.ts +12 -9
  57. package/front_end/models/javascript_metadata/NativeFunctions.js +4 -0
  58. package/front_end/models/trace/handlers/SamplesHandler.ts +3 -0
  59. package/front_end/models/trace/helpers/Trace.ts +13 -0
  60. package/front_end/models/trace/types/TraceEvents.ts +2 -1
  61. package/front_end/models/trace_source_maps_resolver/SourceMapsResolver.ts +29 -0
  62. package/front_end/models/workspace/IgnoreListManager.ts +1 -2
  63. package/front_end/models/workspace/UISourceCode.ts +50 -0
  64. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +11 -10
  65. package/front_end/panels/ai_assistance/ai_assistance-meta.ts +8 -0
  66. package/front_end/panels/ai_assistance/components/ChatView.ts +2 -2
  67. package/front_end/panels/ai_assistance/components/UserActionRow.ts +2 -1
  68. package/front_end/panels/animation/AnimationTimeline.ts +0 -8
  69. package/front_end/panels/application/ApplicationPanelSidebar.ts +6 -7
  70. package/front_end/panels/application/{components/FrameDetailsView.ts → FrameDetailsView.ts} +140 -171
  71. package/front_end/panels/application/{components/OriginTrialTreeView.ts → OriginTrialTreeView.ts} +9 -9
  72. package/front_end/panels/application/application.ts +4 -0
  73. package/front_end/panels/application/components/StackTrace.ts +89 -88
  74. package/front_end/panels/application/components/components.ts +2 -4
  75. package/front_end/panels/application/{components/frameDetailsReportView.css → frameDetailsReportView.css} +5 -1
  76. package/front_end/panels/common/AiCodeGenerationTeaser.ts +80 -0
  77. package/front_end/panels/common/BadgeNotification.ts +2 -1
  78. package/front_end/panels/common/DOMLinkifier.ts +7 -2
  79. package/front_end/panels/common/GdpSignUpDialog.ts +2 -1
  80. package/front_end/panels/common/common.ts +2 -1
  81. package/front_end/panels/console/ConsolePrompt.ts +3 -1
  82. package/front_end/panels/console/ConsoleViewport.ts +1 -2
  83. package/front_end/panels/elements/ElementIssueUtils.ts +2 -2
  84. package/front_end/panels/elements/ElementStatePaneWidget.ts +2 -1
  85. package/front_end/panels/elements/StylePropertiesSection.ts +1 -1
  86. package/front_end/panels/elements/StylePropertyTreeElement.ts +23 -19
  87. package/front_end/panels/elements/StylesSidebarPane.ts +1 -1
  88. package/front_end/panels/elements/cssValueTraceView.css +1 -1
  89. package/front_end/panels/elements/elements-meta.ts +1 -22
  90. package/front_end/panels/explain/components/ConsoleInsight.ts +44 -57
  91. package/front_end/panels/explain/components/consoleInsight.css +46 -1
  92. package/front_end/panels/layer_viewer/LayerTreeOutline.ts +1 -2
  93. package/front_end/panels/lighthouse/LighthouseProtocolService.ts +3 -6
  94. package/front_end/panels/mobile_throttling/NetworkThrottlingSelector.ts +19 -0
  95. package/front_end/panels/network/RequestConditionsDrawer.ts +54 -24
  96. package/front_end/panels/network/networkLogView.css +11 -0
  97. package/front_end/panels/network/networkTimingTable.css +8 -6
  98. package/front_end/panels/network/requestConditionsDrawer.css +10 -1
  99. package/front_end/panels/profiler/ProfilesPanel.ts +1 -2
  100. package/front_end/panels/settings/FrameworkIgnoreListSettingsTab.ts +2 -1
  101. package/front_end/panels/settings/KeybindsSettingsTab.ts +20 -21
  102. package/front_end/panels/settings/SettingsScreen.ts +3 -2
  103. package/front_end/panels/sources/CoveragePlugin.ts +5 -5
  104. package/front_end/panels/sources/Plugin.ts +1 -1
  105. package/front_end/panels/sources/ProfilePlugin.ts +22 -14
  106. package/front_end/panels/sources/UISourceCodeFrame.ts +2 -1
  107. package/front_end/panels/sources/sources-meta.ts +0 -62
  108. package/front_end/panels/timeline/README.md +1 -9
  109. package/front_end/panels/timeline/ThreadAppender.ts +0 -7
  110. package/front_end/panels/timeline/TimelinePanel.ts +1 -1
  111. package/front_end/panels/timeline/TimelineUIUtils.ts +2 -0
  112. package/front_end/panels/timeline/components/ExportTraceOptions.ts +15 -1
  113. package/front_end/panels/timeline/components/LiveMetricsView.ts +51 -6
  114. package/front_end/panels/timeline/components/MetricCard.ts +2 -2
  115. package/front_end/panels/timeline/components/exportTraceOptions.css +11 -2
  116. package/front_end/panels/timeline/components/insights/NodeLink.ts +2 -3
  117. package/front_end/panels/timeline/overlays/components/EntryLabelOverlay.ts +2 -1
  118. package/front_end/panels/timeline/timeline-meta.ts +0 -10
  119. package/front_end/panels/timeline/timeline.ts +0 -2
  120. package/front_end/panels/whats_new/ReleaseNoteView.ts +2 -1
  121. package/front_end/panels/whats_new/WhatsNewImpl.ts +3 -2
  122. package/front_end/third_party/chromium/README.chromium +1 -1
  123. package/front_end/tsconfig.json +1 -0
  124. package/front_end/ui/components/buttons/Button.docs.ts +6 -5
  125. package/front_end/ui/components/markdown_view/MarkdownLinksMap.ts +1 -0
  126. package/front_end/ui/components/snackbars/Snackbars.docs.ts +1 -1
  127. package/front_end/ui/components/spinners/Spinners.docs.ts +1 -1
  128. package/front_end/ui/components/survey_link/SurveyLink.docs.ts +2 -1
  129. package/front_end/ui/components/switch/Switch.docs.ts +1 -1
  130. package/front_end/ui/components/tooltips/Tooltip.docs.ts +3 -3
  131. package/front_end/ui/helpers/OpenInNewTab.ts +87 -0
  132. package/front_end/ui/helpers/helpers.ts +5 -0
  133. package/front_end/ui/legacy/ARIAUtils.ts +2 -2
  134. package/front_end/ui/legacy/ActionRegistration.ts +11 -0
  135. package/front_end/ui/legacy/ContextMenu.docs.ts +12 -11
  136. package/front_end/ui/legacy/RadioButton.docs.ts +1 -1
  137. package/front_end/ui/legacy/SelectMenu.docs.ts +1 -1
  138. package/front_end/ui/legacy/Slider.docs.ts +1 -1
  139. package/front_end/ui/legacy/SoftDropDown.ts +2 -2
  140. package/front_end/ui/legacy/TextPrompt.ts +3 -2
  141. package/front_end/ui/legacy/Treeoutline.ts +2 -1
  142. package/front_end/ui/legacy/UIUtils.ts +11 -43
  143. package/front_end/ui/legacy/Widget.ts +3 -2
  144. package/front_end/ui/legacy/XLink.ts +4 -4
  145. package/front_end/ui/legacy/components/color_picker/ContrastDetails.ts +2 -1
  146. package/front_end/ui/legacy/components/data_grid/DataGrid.ts +2 -2
  147. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +144 -143
  148. package/front_end/ui/legacy/components/perf_ui/LineLevelProfile.ts +62 -39
  149. package/front_end/ui/legacy/components/perf_ui/OverviewGrid.ts +1 -1
  150. package/front_end/ui/legacy/components/perf_ui/TimelineGrid.ts +2 -2
  151. package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +2 -7
  152. package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +1 -2
  153. package/front_end/ui/legacy/components/utils/Linkifier.ts +2 -1
  154. package/front_end/ui/legacy/inspectorCommon.css +2 -2
  155. package/front_end/ui/legacy/legacy.ts +2 -0
  156. package/front_end/ui/visual_logging/KnownContextValues.ts +1 -0
  157. package/mcp/tsconfig.json +16 -0
  158. package/package.json +2 -2
  159. package/front_end/core/common/Linkifier.ts +0 -55
  160. package/front_end/panels/explain/components/consoleInsightSourcesList.css +0 -51
  161. package/front_end/panels/timeline/CLSLinkifier.ts +0 -58
  162. package/front_end/ui/components/docs/README.md +0 -6
  163. package/front_end/ui/components/docs/building-ui-documentation/ComponentEvents.md +0 -54
  164. package/front_end/ui/components/docs/building-ui-documentation/ComponentPerformance.md +0 -136
  165. package/front_end/ui/components/docs/building-ui-documentation/CreatingComponents.md +0 -242
  166. package/front_end/ui/components/docs/building-ui-documentation/README.md +0 -23
  167. package/front_end/ui/components/docs/building-ui-documentation/StylingComponents.md +0 -66
  168. package/front_end/ui/components/docs/building-ui-documentation/TestingComponents.md +0 -111
  169. package/front_end/ui/components/docs/component_docs.ts +0 -24
  170. package/front_end/ui/components/docs/component_docs_styles.css +0 -53
  171. package/front_end/ui/components/docs/create_breadcrumbs.ts +0 -44
  172. package/front_end/ui/components/docs/slider/basic.html +0 -20
  173. package/front_end/ui/components/docs/switch/basic.html +0 -20
  174. /package/front_end/models/issues_manager/descriptions/{genericFormAriaLabelledByToNonExistingId.md → genericFormAriaLabelledByToNonExistingIdError.md} +0 -0
  175. /package/front_end/models/issues_manager/descriptions/{genericFormLabelHasNeitherForNorNestedInput.md → genericFormLabelHasNeitherForNorNestedInputError.md} +0 -0
  176. /package/front_end/panels/application/{components/originTrialTokenRows.css → originTrialTokenRows.css} +0 -0
  177. /package/front_end/panels/application/{components/originTrialTreeView.css → originTrialTreeView.css} +0 -0
  178. /package/front_end/{core/platform → ui/legacy}/DOMUtilities.ts +0 -0
@@ -17,6 +17,7 @@
17
17
  },
18
18
  "include": [
19
19
  "../../front_end/**/*.ts",
20
+ "../../mcp/**/*.ts",
20
21
  "../../inspector_overlay/**/*.ts",
21
22
  "../../scripts/**/*.ts",
22
23
  "../../test/**/*.ts",
@@ -29,7 +29,7 @@ tokens**](https://crsrc.org/c/third_party/devtools-frontend/src/front_end/design
29
29
  name e.g. `--sys-color-error-container`). They reference palette tokens and
30
30
  incorporate light / dark mode switches and should be used in the code directly.
31
31
  You can view all system tokens in their light and dark variant when running the
32
- component server with `npm run components-server` under *Theme Colors*.
32
+ component server on our [component documentation page](https://chromedevtools.github.io/devtools-frontend/#ThemeColors).
33
33
 
34
34
  [**Application
35
35
  tokens**](https://crsrc.org/c/third_party/devtools-frontend/src/front_end/application_tokens.css)
package/eslint.config.mjs CHANGED
@@ -60,7 +60,7 @@ export default defineConfig([
60
60
  'scripts/protocol_typescript/*.js',
61
61
  'scripts/deps/tests/fixtures',
62
62
  'test/**/fixtures/',
63
- 'test/e2e/**/*.js',
63
+ 'test/e2e_non_hosted/**/*.js',
64
64
  'test/shared/**/*.js',
65
65
  ]),
66
66
  {
@@ -1,3 +1,10 @@
1
1
  <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M9.25 3V14.125L7.062 11.938L6 13L10 17L14 13L12.938 11.938L10.75 14.125V3H9.25Z" fill="black"/>
2
+ <g clip-path="url(#clip0_4041_3016)">
3
+ <path d="M9.25 4H10.75V13.125L14.9375 8.9375L16 10L10 16L4 10L5.0625 8.9375L9.25 13.125V4Z" fill="black"/>
4
+ </g>
5
+ <defs>
6
+ <clipPath id="clip0_4041_3016">
7
+ <rect width="20" height="20" fill="white"/>
8
+ </clipPath>
9
+ </defs>
3
10
  </svg>
@@ -1,3 +1,10 @@
1
1
  <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M9.25 17V5.875L7.062 8.062L6 7L10 3L14 7L12.938 8.062L10.75 5.875V17H9.25Z" fill="black"/>
2
+ <g clip-path="url(#clip0_4041_3013)">
3
+ <path d="M9.25 16V6.875L5.0625 11.0625L4 10L10 4L16 10L14.9375 11.0625L10.75 6.875V16H9.25Z" fill="black"/>
4
+ </g>
5
+ <defs>
6
+ <clipPath id="clip0_4041_3013">
7
+ <rect width="20" height="20" fill="white"/>
8
+ </clipPath>
9
+ </defs>
3
10
  </svg>
@@ -38,7 +38,7 @@ export function normalizePath(path: string): string {
38
38
  return normalizedPath;
39
39
  }
40
40
 
41
- export function schemeIs(url: Platform.DevToolsPath.UrlString, scheme: string): boolean {
41
+ export function schemeIs(url: Platform.DevToolsPath.UrlString|URL, scheme: string): boolean {
42
42
  try {
43
43
  return (new URL(url)).protocol === scheme;
44
44
  } catch {
@@ -15,7 +15,6 @@ import * as EventTarget from './EventTarget.js';
15
15
  import * as Gzip from './Gzip.js';
16
16
  import * as JavaScriptMetaData from './JavaScriptMetaData.js';
17
17
  import * as Lazy from './Lazy.js';
18
- import * as Linkifier from './Linkifier.js';
19
18
  import * as MapWithDefault from './MapWithDefault.js';
20
19
  import * as Mutex from './Mutex.js';
21
20
  import * as ObjectWrapper from './Object.js';
@@ -56,7 +55,6 @@ export {
56
55
  Gzip,
57
56
  JavaScriptMetaData,
58
57
  Lazy,
59
- Linkifier,
60
58
  MapWithDefault,
61
59
  Mutex,
62
60
  ObjectWrapper,
@@ -733,7 +733,7 @@ export function convertToUserTierEnum(userTier: string|undefined): UserTier {
733
733
  return UserTier.PUBLIC;
734
734
  }
735
735
  }
736
- return UserTier.BETA;
736
+ return UserTier.PUBLIC;
737
737
  }
738
738
 
739
739
  let hostConfigTrackerInstance: HostConfigTracker|undefined;
@@ -549,7 +549,6 @@ export const enum EnumeratedHistogram {
549
549
  LighthouseModeRun = 'DevTools.LighthouseModeRun',
550
550
  LighthouseCategoryUsed = 'DevTools.LighthouseCategoryUsed',
551
551
  SwatchActivated = 'DevTools.SwatchActivated',
552
- AnimationPlaybackRateChanged = 'DevTools.AnimationPlaybackRateChanged',
553
552
  BuiltInAiAvailability = 'DevTools.BuiltInAiAvailability',
554
553
  // LINT.ThenChange(/front_end/devtools_compatibility.js:EnumeratedHistogram)
555
554
  }
@@ -269,11 +269,6 @@ export class UserMetrics {
269
269
  EnumeratedHistogram.SwatchActivated, swatch, SwatchType.MAX_VALUE);
270
270
  }
271
271
 
272
- animationPlaybackRateChanged(playbackRate: AnimationsPlaybackRate): void {
273
- InspectorFrontendHostInstance.recordEnumeratedHistogram(
274
- EnumeratedHistogram.AnimationPlaybackRateChanged, playbackRate, AnimationsPlaybackRate.MAX_VALUE);
275
- }
276
-
277
272
  workspacesPopulated(wallClockTimeInMilliseconds: number): void {
278
273
  InspectorFrontendHostInstance.recordPerformanceHistogram(
279
274
  'DevTools.Workspaces.PopulateWallClocktime', wallClockTimeInMilliseconds);
@@ -0,0 +1,18 @@
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
+ import type * as Api from './api/api.js';
6
+ import * as Browser from './browser/browser.js';
7
+ import * as Node from './node/node.js';
8
+
9
+ export const HOST_RUNTIME = ((): Api.HostRuntime.HostRuntime => {
10
+ if (Node.HostRuntime.IS_NODE) {
11
+ return Node.HostRuntime.HOST_RUNTIME;
12
+ }
13
+ if (Browser.HostRuntime.IS_BROWSER) {
14
+ return Browser.HostRuntime.HOST_RUNTIME;
15
+ }
16
+
17
+ throw new Error('Unknown runtime!');
18
+ })();
@@ -29,10 +29,10 @@ export function keyIsArrowKey(key: string): key is ArrowKey {
29
29
  return ARROW_KEYS.has(key as ArrowKey);
30
30
  }
31
31
 
32
- export function isEscKey(event: KeyboardEvent): boolean {
32
+ export function isEscKey(event: {readonly key: string}): boolean {
33
33
  return event.key === 'Escape';
34
34
  }
35
35
 
36
- export function isEnterOrSpaceKey(event: KeyboardEvent): boolean {
36
+ export function isEnterOrSpaceKey(event: {readonly key: string}): boolean {
37
37
  return event.key === 'Enter' || event.key === ' ';
38
38
  }
@@ -584,5 +584,5 @@ export const concatBase64 = function(lhs: string, rhs: string): string {
584
584
  }
585
585
  const lhsLeaveAsIs = lhs.substring(0, lhs.length - 4);
586
586
  const lhsToDecode = lhs.substring(lhs.length - 4);
587
- return lhsLeaveAsIs + window.btoa(window.atob(lhsToDecode) + window.atob(rhs));
587
+ return lhsLeaveAsIs + globalThis.btoa(globalThis.atob(lhsToDecode) + globalThis.atob(rhs));
588
588
  };
@@ -0,0 +1,20 @@
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
+ /**
6
+ * Provides abstractions for host features that require different implementations depending
7
+ * on whether DevTools runs in the browser or Node.js
8
+ */
9
+ export interface HostRuntime {
10
+ createWorker(url: string): Worker;
11
+ }
12
+
13
+ /**
14
+ * Abstracts away the differences between browser web workers and Node.js worker threads.
15
+ */
16
+ export interface Worker {
17
+ // TODO(crbug.com/461952544): Actually add some methods here.
18
+ // Leave one marker method to make this non-empty.
19
+ dispose?(): void;
20
+ }
@@ -0,0 +1,7 @@
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
+ import * as HostRuntime from './HostRuntime.js';
6
+
7
+ export {HostRuntime};
@@ -0,0 +1,14 @@
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
+ import type * as Api from '../api/api.js';
6
+
7
+ export const IS_BROWSER =
8
+ typeof window !== 'undefined' || (typeof self !== 'undefined' && typeof self.postMessage === 'function');
9
+
10
+ export const HOST_RUNTIME: Api.HostRuntime.HostRuntime = {
11
+ createWorker(): Api.HostRuntime.Worker {
12
+ throw new Error('unimplemented');
13
+ }
14
+ };
@@ -0,0 +1,7 @@
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
+ import * as HostRuntime from './HostRuntime.js';
6
+
7
+ export {HostRuntime};
@@ -0,0 +1,13 @@
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
+ import type * as Api from '../api/api.js';
6
+
7
+ export const IS_NODE = typeof (process as unknown) !== 'undefined' && process.versions?.node !== null;
8
+
9
+ export const HOST_RUNTIME: Api.HostRuntime.HostRuntime = {
10
+ createWorker(): Api.HostRuntime.Worker {
11
+ throw new Error('unimplemented');
12
+ }
13
+ };
@@ -0,0 +1,7 @@
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
+ import * as HostRuntime from './HostRuntime.js';
6
+
7
+ export {HostRuntime};
@@ -7,7 +7,7 @@ import * as Brand from './Brand.js';
7
7
  import * as Constructor from './Constructor.js';
8
8
  import * as DateUtilities from './DateUtilities.js';
9
9
  import * as DevToolsPath from './DevToolsPath.js';
10
- import * as DOMUtilities from './DOMUtilities.js';
10
+ import * as HostRuntime from './HostRuntime.js';
11
11
  import * as KeyboardUtilities from './KeyboardUtilities.js';
12
12
  import * as MapUtilities from './MapUtilities.js';
13
13
  import * as MimeType from './MimeType.js';
@@ -31,7 +31,7 @@ export {
31
31
  Constructor,
32
32
  DateUtilities,
33
33
  DevToolsPath,
34
- DOMUtilities,
34
+ HostRuntime,
35
35
  KeyboardUtilities,
36
36
  MapUtilities,
37
37
  MimeType,
@@ -5,10 +5,10 @@
5
5
  import type {ProtocolMapping} from '../../generated/protocol-mapping.js';
6
6
 
7
7
  export type Command = keyof ProtocolMapping.Commands;
8
- export type CommandParams<T extends keyof ProtocolMapping.Commands> = ProtocolMapping.Commands[T]['paramsType'][0];
9
- export type CommandResult<T extends keyof ProtocolMapping.Commands> = ProtocolMapping.Commands[T]['returnType'];
8
+ export type CommandParams<T extends Command> = ProtocolMapping.Commands[T]['paramsType'][0];
9
+ export type CommandResult<T extends Command> = Omit<ProtocolMapping.Commands[T]['returnType'], 'getError'>;
10
10
  export type Event = keyof ProtocolMapping.Events;
11
- export type EventParams<T extends keyof ProtocolMapping.Events> = ProtocolMapping.Events[T];
11
+ export type EventParams<T extends keyof ProtocolMapping.Events> = ProtocolMapping.Events[T][0];
12
12
 
13
13
  export interface CDPBaseMessage {
14
14
  sessionId?: string;
@@ -17,7 +17,8 @@ import type {ConnectionTransport} from './ConnectionTransport.js';
17
17
  import {InspectorBackend, type MessageError, type QualifiedName, test} from './InspectorBackend.js';
18
18
 
19
19
  interface CallbackWithDebugInfo {
20
- resolve: (response: Awaited<ReturnType<CDPConnection['send']>>) => void;
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ resolve: (response: {result: CommandResult<any>}|{error: CDPError}) => void;
21
22
  method: string;
22
23
  sessionId: string|undefined;
23
24
  }
@@ -455,11 +455,8 @@ const cornerShapeValuePresetMap = new Map([
455
455
  ]);
456
456
 
457
457
  const valuePresets = new Map([
458
- ['filter', filterValuePresetMap],
459
- ['backdrop-filter', filterValuePresetMap],
460
- ['background', imageValuePresetMap],
461
- ['background-image', imageValuePresetMap],
462
- ['-webkit-mask-image', imageValuePresetMap],
458
+ ['filter', filterValuePresetMap], ['backdrop-filter', filterValuePresetMap], ['background', imageValuePresetMap],
459
+ ['background-image', imageValuePresetMap], ['-webkit-mask-image', imageValuePresetMap],
463
460
  [
464
461
  'transform',
465
462
  new Map([
@@ -486,6 +483,17 @@ const valuePresets = new Map([
486
483
  ]),
487
484
  ],
488
485
  ['corner-shape', cornerShapeValuePresetMap],
486
+ [
487
+ 'font-variant-alternates',
488
+ new Map([
489
+ ['stylistic', 'stylistic(||)'],
490
+ ['styleset', 'styleset(||)'],
491
+ ['character-variant', 'character-variant(||)'],
492
+ ['swash', 'swash(||)'],
493
+ ['ornaments', 'ornaments(||)'],
494
+ ['annotation', 'annotation(||)'],
495
+ ]),
496
+ ]
489
497
  ]);
490
498
 
491
499
  const distanceProperties = new Set<string>([
@@ -766,6 +774,10 @@ const extraPropertyValues = new Map<string, Set<string>>([
766
774
  'ruby',
767
775
  ]),
768
776
  ],
777
+ [
778
+ 'font-variant-alternates',
779
+ new Set(['historical-forms', 'stylistic', 'styleset', 'character-variant', 'swash', 'ornaments', 'annotation'])
780
+ ],
769
781
  ['vertical-align', new Set(['top', 'bottom', '-webkit-baseline-middle'])],
770
782
  ['page-break-after', new Set(['left', 'right', 'always', 'avoid'])],
771
783
  ['text-emphasis-style', textEmphasisStyle],
@@ -383,14 +383,6 @@ export class NetworkManager extends SDKModel<EventTypes> {
383
383
  return result.status;
384
384
  }
385
385
 
386
- async getIpProtectionProxyStatus(): Promise<Protocol.Network.IpProxyStatus|null> {
387
- const result = await this.#networkAgent.invoke_getIPProtectionProxyStatus();
388
- if (result.getError()) {
389
- return null;
390
- }
391
- return result.status;
392
- }
393
-
394
386
  async enableReportingApi(enable = true): Promise<Promise<Protocol.ProtocolResponseWithError>> {
395
387
  return await this.#networkAgent.invoke_enableReportingApi({enable});
396
388
  }
@@ -1043,6 +1035,12 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
1043
1035
  appliedNetworkConditionsId,
1044
1036
  };
1045
1037
  this.getExtraInfoBuilder(requestId).addRequestExtraInfo(extraRequestInfo);
1038
+
1039
+ const networkRequest = this.#requestsById.get(requestId);
1040
+ if (appliedNetworkConditionsId && networkRequest) {
1041
+ networkRequest.setAppliedNetworkConditions(appliedNetworkConditionsId);
1042
+ this.updateNetworkRequest(networkRequest);
1043
+ }
1046
1044
  }
1047
1045
 
1048
1046
  responseReceivedEarlyHints({
@@ -1629,6 +1629,10 @@ export class NetworkRequest extends Common.ObjectWrapper.ObjectWrapper<EventType
1629
1629
  );
1630
1630
  }
1631
1631
 
1632
+ setAppliedNetworkConditions(appliedNetworkConditionsId: string): void {
1633
+ this.#appliedNetworkConditionsId = appliedNetworkConditionsId;
1634
+ }
1635
+
1632
1636
  hasExtraRequestInfo(): boolean {
1633
1637
  return this.#hasExtraRequestInfo;
1634
1638
  }
@@ -12,7 +12,9 @@ export interface RegistrationInfo {
12
12
  early?: boolean;
13
13
  }
14
14
 
15
- const registeredModels = new Map<new (arg1: Target) => SDKModel, RegistrationInfo>();
15
+ export type SDKModelConstructor<T extends SDKModel = SDKModel> = new (target: Target) => T;
16
+
17
+ const registeredModels = new Map<SDKModelConstructor, RegistrationInfo>();
16
18
 
17
19
  // TODO(crbug.com/1228674) Remove defaults for generic type parameters once
18
20
  // all event emitters and sinks have been migrated.
@@ -52,7 +54,7 @@ export class SDKModel<Events = any> extends Common.ObjectWrapper.ObjectWrapper<E
52
54
  dispose(): void {
53
55
  }
54
56
 
55
- static register(modelClass: new(arg1: Target) => SDKModel, registrationInfo: RegistrationInfo): void {
57
+ static register(modelClass: SDKModelConstructor, registrationInfo: RegistrationInfo): void {
56
58
  if (registrationInfo.early && !registrationInfo.autostart) {
57
59
  throw new Error(`Error registering model ${modelClass.name}: early models must be autostarted.`);
58
60
  }
@@ -26,35 +26,114 @@ export class SourceMapScopesInfo {
26
26
  }
27
27
 
28
28
  /**
29
- * If the source map does not contain any scopes information, this factory function attempts to create bare bones scope information
29
+ * If the source map does not contain any scopes information, this factory function attempts to create scope information
30
30
  * via the script's AST combined with the mappings.
31
31
  *
32
32
  * We create the generated ranges from the scope tree and for each range we create an original scope that matches the bounds 1:1.
33
- * We don't map the bounds via mappings as mappings are often iffy and it's not strictly required to translate stack traces where we
34
- * map call-sites separately.
35
33
  */
36
34
  static createFromAst(
37
35
  sourceMap: SourceMap, scopeTree: Formatter.FormatterWorkerPool.ScopeTreeNode,
38
36
  text: TextUtils.Text.Text): SourceMapScopesInfo {
39
- const {scope, range} = convertScope(scopeTree, undefined, undefined);
40
- return new SourceMapScopesInfo(sourceMap, {scopes: [scope], ranges: [range]});
37
+ const numSourceUrls = sourceMap.sourceURLs().length;
38
+ const scopeBySourceUrl: ScopesCodec.OriginalScope[] = [];
39
+ for (let i = 0; i < numSourceUrls; i++) {
40
+ const scope: ScopesCodec.OriginalScope = {
41
+ start: {line: 0, column: 0},
42
+ end: {line: Number.POSITIVE_INFINITY, column: Number.POSITIVE_INFINITY},
43
+ isStackFrame: false,
44
+ variables: [],
45
+ children: [],
46
+ };
47
+ scopeBySourceUrl.push(scope);
48
+ }
49
+
50
+ // Convert the entire scopeTree. Returns a root range that encompasses everything,
51
+ // and inserts scopes by sourceIndex into the above scopeBySourceUrl.
52
+ const {range} = convertScope(scopeTree, undefined);
53
+ return new SourceMapScopesInfo(sourceMap, {scopes: scopeBySourceUrl, ranges: [range]});
54
+
55
+ /**
56
+ * Recursively finds the correct place in the tree to insert the new scope.
57
+ * Maintains the invariant that children are sorted and contained by their parent.
58
+ */
59
+ function insertInScope(parent: ScopesCodec.OriginalScope, newScope: ScopesCodec.OriginalScope): void {
60
+ // Check if the newScope fits strictly inside any of the existing children.
61
+ for (const child of parent.children) {
62
+ if (contains(child, newScope)) {
63
+ insertInScope(child, newScope);
64
+ return;
65
+ }
66
+ }
67
+
68
+ // When here, newScope belongs directly in parent.
69
+ // However, newScope might encompass some of parent's existing children (due
70
+ // to compiler transform quirks or arbitrary insertion order). We must move
71
+ // those children inside newScope.
72
+ const childrenToKeep: ScopesCodec.OriginalScope[] = [];
73
+ for (const child of parent.children) {
74
+ if (contains(newScope, child)) {
75
+ // child is actually inside newScope, so re-parent it.
76
+ newScope.children.push(child);
77
+ child.parent = newScope;
78
+ } else {
79
+ childrenToKeep.push(child);
80
+ }
81
+ }
82
+
83
+ // Find the correct index in the remaining children to insert newScope.
84
+ // We look for the first child that starts after the new scope.
85
+ const insertIndex = childrenToKeep.findIndex(child => compareScopes(newScope, child) < 0);
86
+ if (insertIndex === -1) {
87
+ // If no child starts after, it goes at the end.
88
+ childrenToKeep.push(newScope);
89
+ } else {
90
+ childrenToKeep.splice(insertIndex, 0, newScope);
91
+ }
92
+
93
+ // Update parent's children to only be the ones that don't belong to newScope.
94
+ parent.children = childrenToKeep;
95
+ newScope.parent = parent;
96
+ }
97
+
98
+ function contains(outer: ScopesCodec.OriginalScope, inner: ScopesCodec.OriginalScope): boolean {
99
+ return comparePositions(outer.start, inner.start) <= 0 && comparePositions(outer.end, inner.end) >= 0;
100
+ }
101
+
102
+ function compareScopes(a: ScopesCodec.OriginalScope, b: ScopesCodec.OriginalScope): number {
103
+ return comparePositions(a.start, b.start);
104
+ }
105
+
106
+ function comparePositions(a: ScopesCodec.Position, b: ScopesCodec.Position): number {
107
+ if (a.line !== b.line) {
108
+ return a.line - b.line;
109
+ }
110
+ return a.column - b.column;
111
+ }
41
112
 
42
113
  function convertScope(
43
- node: Formatter.FormatterWorkerPool.ScopeTreeNode, parentScope: ScopesCodec.OriginalScope|undefined,
44
- parentRange: ScopesCodec.GeneratedRange|
45
- undefined): {scope: ScopesCodec.OriginalScope, range: ScopesCodec.GeneratedRange} {
114
+ node: Formatter.FormatterWorkerPool.ScopeTreeNode,
115
+ parentRange: ScopesCodec.GeneratedRange|undefined): {range: ScopesCodec.GeneratedRange} {
46
116
  const start = positionFromOffset(node.start);
47
117
  const end = positionFromOffset(node.end);
118
+ const startEntry = sourceMap.findEntry(start.line, start.column);
119
+ const endEntry = sourceMap.findEntry(end.line, end.column);
120
+ const sourceIndex = startEntry?.sourceIndex;
121
+ const canMapOriginalPosition = startEntry && endEntry && sourceIndex !== undefined &&
122
+ startEntry.sourceIndex === endEntry.sourceIndex && startEntry.sourceIndex !== undefined && sourceIndex >= 0 &&
123
+ sourceIndex < numSourceUrls;
48
124
  const isStackFrame = node.kind === Formatter.FormatterWorkerPool.ScopeKind.FUNCTION;
49
125
 
50
- const scope: ScopesCodec.OriginalScope = {
51
- start,
52
- end,
53
- name: sourceMap.findEntry(start.line, start.column, 0)?.name,
54
- isStackFrame,
55
- variables: [],
56
- children: [],
57
- };
126
+ let scope: ScopesCodec.OriginalScope|undefined;
127
+ if (canMapOriginalPosition) {
128
+ scope = {
129
+ start: {line: startEntry.sourceLineNumber, column: startEntry.sourceColumnNumber},
130
+ end: {line: endEntry.sourceLineNumber, column: endEntry.sourceColumnNumber},
131
+ name: startEntry.name,
132
+ isStackFrame,
133
+ variables: [],
134
+ children: [],
135
+ };
136
+ }
58
137
 
59
138
  const range: ScopesCodec.GeneratedRange = {
60
139
  start,
@@ -67,11 +146,14 @@ export class SourceMapScopesInfo {
67
146
  };
68
147
 
69
148
  parentRange?.children.push(range);
70
- parentScope?.children.push(scope);
149
+ if (canMapOriginalPosition && scope) {
150
+ const rootScope = scopeBySourceUrl[sourceIndex];
151
+ insertInScope(rootScope, scope);
152
+ }
71
153
 
72
- node.children.forEach(child => convertScope(child, scope, range));
154
+ node.children.forEach(child => convertScope(child, range));
73
155
 
74
- return {scope, range};
156
+ return {range};
75
157
  }
76
158
 
77
159
  function positionFromOffset(offset: number): ScopesCodec.Position {
@@ -347,7 +429,16 @@ export class SourceMapScopesInfo {
347
429
  /**
348
430
  * Returns the authored function name of the function containing the provided generated position.
349
431
  */
350
- findOriginalFunctionName({line, column}: ScopesCodec.Position): string|null {
432
+ findOriginalFunctionName(position: ScopesCodec.Position): string|null {
433
+ const originalInnerMostScope = this.findOriginalFunctionScope(position)?.scope ?? undefined;
434
+ return this.#findFunctionNameInOriginalScopeChain(originalInnerMostScope);
435
+ }
436
+
437
+ /**
438
+ * Returns the authored function scope of the function containing the provided generated position.
439
+ */
440
+ findOriginalFunctionScope({line, column}: ScopesCodec.Position):
441
+ {scope: ScopesCodec.OriginalScope, url?: Platform.DevToolsPath.UrlString}|null {
351
442
  // There are 2 approaches:
352
443
  // 1) Find the inner-most generated range containing the provided generated position
353
444
  // and use it's OriginalScope (then walk it outwards until we hit a function).
@@ -376,7 +467,24 @@ export class SourceMapScopesInfo {
376
467
  .at(-1);
377
468
  }
378
469
 
379
- return this.#findFunctionNameInOriginalScopeChain(originalInnerMostScope) ?? null;
470
+ if (!originalInnerMostScope) {
471
+ return null;
472
+ }
473
+
474
+ const functionScope = this.#findFunctionScopeInOriginalScopeChain(originalInnerMostScope);
475
+ if (!functionScope) {
476
+ return null;
477
+ }
478
+
479
+ // Find the root scope for some given original source, to get the source url.
480
+ let rootScope: ScopesCodec.OriginalScope = functionScope;
481
+ while (rootScope.parent) {
482
+ rootScope = rootScope.parent;
483
+ }
484
+ const sourceIndex = this.#originalScopes.indexOf(rootScope);
485
+ const url = sourceIndex !== -1 ? this.#sourceMap.sourceURLForSourceIndex(sourceIndex) : undefined;
486
+
487
+ return functionScope ? {scope: functionScope, url} : null;
380
488
  }
381
489
 
382
490
  /**
@@ -403,15 +511,25 @@ export class SourceMapScopesInfo {
403
511
  return result;
404
512
  }
405
513
 
406
- #findFunctionNameInOriginalScopeChain(innerOriginalScope: ScopesCodec.OriginalScope|undefined): string|null {
514
+ #findFunctionScopeInOriginalScopeChain(innerOriginalScope: ScopesCodec.OriginalScope|undefined):
515
+ ScopesCodec.OriginalScope|null {
407
516
  for (let originalScope = innerOriginalScope; originalScope; originalScope = originalScope.parent) {
408
517
  if (originalScope.isStackFrame) {
409
- return originalScope.name ?? '';
518
+ return originalScope;
410
519
  }
411
520
  }
412
521
  return null;
413
522
  }
414
523
 
524
+ #findFunctionNameInOriginalScopeChain(innerOriginalScope: ScopesCodec.OriginalScope|undefined): string|null {
525
+ const functionScope = this.#findFunctionScopeInOriginalScopeChain(innerOriginalScope);
526
+ if (!functionScope) {
527
+ return null;
528
+ }
529
+
530
+ return functionScope.name ?? '';
531
+ }
532
+
415
533
  /**
416
534
  * Returns one or more original stack frames for this single "raw frame" or call-site.
417
535
  *
@@ -7,7 +7,7 @@ import * as Common from '../common/common.js';
7
7
  import * as Platform from '../platform/platform.js';
8
8
  import * as ProtocolClient from '../protocol_client/protocol_client.js';
9
9
 
10
- import {SDKModel} from './SDKModel.js';
10
+ import {SDKModel, type SDKModelConstructor} from './SDKModel.js';
11
11
  import type {TargetManager} from './TargetManager.js';
12
12
 
13
13
  export class Target extends ProtocolClient.InspectorBackend.TargetBase {
@@ -111,20 +111,11 @@ export class Target extends ProtocolClient.InspectorBackend.TargetBase {
111
111
  this.#targetInfo = targetInfo;
112
112
  }
113
113
 
114
- createModels(required: Set<new(arg1: Target) => SDKModel>): void {
114
+ /** Creates the models in the order in which they are provided */
115
+ createModels(models: SDKModelConstructor[]): void {
115
116
  this.#creatingModels = true;
116
- const registeredModels = Array.from(SDKModel.registeredModels.entries());
117
- // Create early models.
118
- for (const [modelClass, info] of registeredModels) {
119
- if (info.early) {
120
- this.model(modelClass);
121
- }
122
- }
123
- // Create autostart and required models.
124
- for (const [modelClass, info] of registeredModels) {
125
- if (info.autostart || required.has(modelClass)) {
126
- this.model(modelClass);
127
- }
117
+ for (const model of models) {
118
+ this.model(model);
128
119
  }
129
120
  this.#creatingModels = false;
130
121
  }