chrome-devtools-frontend 1.0.1555174 → 1.0.1556696

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 (156) hide show
  1. package/front_end/core/protocol_client/InspectorBackend.ts +1 -1
  2. package/front_end/core/root/Runtime.ts +0 -4
  3. package/front_end/core/sdk/DOMModel.ts +101 -7
  4. package/front_end/entrypoints/formatter_worker/FormatterActions.ts +2 -0
  5. package/front_end/entrypoints/formatter_worker/ScopeParser.ts +75 -7
  6. package/front_end/entrypoints/formatter_worker/Substitute.ts +1 -1
  7. package/front_end/generated/InspectorBackendCommands.ts +1 -1
  8. package/front_end/generated/protocol.ts +0 -1
  9. package/front_end/models/ai_assistance/AiConversation.ts +71 -10
  10. package/front_end/models/ai_assistance/ArtifactsManager.ts +67 -0
  11. package/front_end/models/ai_assistance/ConversationHandler.ts +3 -2
  12. package/front_end/models/ai_assistance/agents/AiAgent.ts +17 -27
  13. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +152 -4
  14. package/front_end/models/ai_assistance/agents/StylingAgent.ts +2 -2
  15. package/front_end/models/ai_assistance/ai_assistance.ts +2 -0
  16. package/front_end/models/ai_assistance/data_formatters/NetworkRequestFormatter.ts +1 -1
  17. package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.ts +0 -2
  18. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +1 -1
  19. package/front_end/{ui/components → models}/annotations/AnnotationRepository.ts +4 -4
  20. package/front_end/models/annotations/README.md +7 -0
  21. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +8 -0
  22. package/front_end/models/greendev/Prototypes.ts +56 -0
  23. package/front_end/models/greendev/README.md +5 -0
  24. package/front_end/models/greendev/greendev.ts +5 -0
  25. package/front_end/models/stack_trace/StackTrace.ts +13 -2
  26. package/front_end/models/stack_trace/StackTraceImpl.ts +81 -6
  27. package/front_end/models/stack_trace/StackTraceModel.ts +35 -3
  28. package/front_end/models/trace/extras/TraceTree.ts +4 -2
  29. package/front_end/models/trace/insights/LCPDiscovery.ts +0 -2
  30. package/front_end/models/trace/types/TraceEvents.ts +0 -1
  31. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +116 -70
  32. package/front_end/panels/ai_assistance/aiAssistancePanel.css +16 -0
  33. package/front_end/panels/ai_assistance/components/ArtifactsViewer.ts +159 -0
  34. package/front_end/panels/ai_assistance/components/ChatView.ts +3 -2
  35. package/front_end/panels/ai_assistance/components/CollapsibleAssistanceContentWidget.ts +7 -8
  36. package/front_end/panels/ai_assistance/components/PerformanceAgentFlameChart.ts +15 -8
  37. package/front_end/panels/ai_assistance/components/PerformanceAgentMarkdownRenderer.ts +9 -9
  38. package/front_end/panels/ai_assistance/components/artifactsViewer.css +15 -0
  39. package/front_end/panels/ai_assistance/components/collapsibleAssistanceContentWidget.css +5 -6
  40. package/front_end/panels/application/AppManifestView.ts +263 -205
  41. package/front_end/panels/application/ApplicationPanelSidebar.ts +24 -57
  42. package/front_end/panels/application/OpenedWindowDetailsView.ts +2 -0
  43. package/front_end/panels/application/ServiceWorkersView.ts +2 -0
  44. package/front_end/panels/application/StorageView.ts +1 -0
  45. package/front_end/panels/application/appManifestView.css +48 -0
  46. package/front_end/panels/application/components/ProtocolHandlersView.ts +2 -2
  47. package/front_end/panels/application/preloading/PreloadingView.ts +12 -6
  48. package/front_end/panels/application/preloading/components/PreloadingDetailsReportView.ts +230 -237
  49. package/front_end/panels/application/preloading/components/PreloadingGrid.ts +96 -79
  50. package/front_end/panels/application/preloading/components/preloadingGrid.css +26 -29
  51. package/front_end/panels/application/preloading/preloadingView.css +6 -0
  52. package/front_end/panels/common/Annotation.ts +1 -1
  53. package/front_end/panels/common/AnnotationManager.ts +1 -1
  54. package/front_end/panels/common/ExtensionView.ts +1 -0
  55. package/front_end/panels/console/ConsoleContextSelector.ts +74 -9
  56. package/front_end/panels/console/consoleContextSelector.css +31 -29
  57. package/front_end/panels/coverage/coverageListView.css +59 -57
  58. package/front_end/panels/elements/ElementsPanel.ts +1 -1
  59. package/front_end/panels/elements/ElementsTreeElement.ts +39 -1
  60. package/front_end/panels/elements/ElementsTreeOutline.ts +23 -21
  61. package/front_end/panels/elements/TopLayerContainer.ts +26 -91
  62. package/front_end/panels/explain/components/ConsoleInsight.ts +3 -3
  63. package/front_end/panels/linear_memory_inspector/components/LinearMemoryInspector.ts +4 -8
  64. package/front_end/panels/linear_memory_inspector/components/LinearMemoryValueInterpreter.ts +148 -97
  65. package/front_end/panels/linear_memory_inspector/components/LinearMemoryViewer.ts +1 -1
  66. package/front_end/panels/linear_memory_inspector/components/linearMemoryValueInterpreter.css +37 -35
  67. package/front_end/panels/network/NetworkItemView.ts +1 -1
  68. package/front_end/panels/network/NetworkLogView.ts +1 -1
  69. package/front_end/panels/network/NetworkPanel.ts +1 -1
  70. package/front_end/panels/recorder/RecorderController.ts +0 -1
  71. package/front_end/panels/security/SecurityPanelSidebar.ts +5 -0
  72. package/front_end/panels/settings/SettingsScreen.ts +133 -1
  73. package/front_end/panels/settings/settings-meta.ts +24 -0
  74. package/front_end/panels/settings/settingsScreen.css +4 -0
  75. package/front_end/panels/sources/UISourceCodeFrame.ts +3 -17
  76. package/front_end/panels/timeline/TimelineUIUtils.ts +5 -8
  77. package/front_end/panels/timeline/components/TimelineSummary.ts +75 -54
  78. package/front_end/panels/timeline/components/insights/BaseInsightComponent.ts +18 -26
  79. package/front_end/panels/timeline/components/insights/Cache.ts +12 -8
  80. package/front_end/panels/timeline/components/insights/DOMSize.ts +25 -21
  81. package/front_end/panels/timeline/components/insights/DuplicatedJavaScript.ts +7 -7
  82. package/front_end/panels/timeline/components/insights/FontDisplay.ts +7 -5
  83. package/front_end/panels/timeline/components/insights/ForcedReflow.ts +11 -9
  84. package/front_end/panels/timeline/components/insights/INPBreakdown.ts +7 -6
  85. package/front_end/panels/timeline/components/insights/ImageDelivery.ts +7 -5
  86. package/front_end/panels/timeline/components/insights/InsightRenderer.ts +20 -18
  87. package/front_end/panels/timeline/components/insights/LCPBreakdown.ts +12 -12
  88. package/front_end/panels/timeline/components/insights/LegacyJavaScript.ts +7 -7
  89. package/front_end/panels/timeline/components/insights/ModernHTTP.ts +7 -5
  90. package/front_end/panels/timeline/components/insights/NetworkDependencyTree.ts +15 -13
  91. package/front_end/panels/timeline/components/insights/RenderBlocking.ts +2 -2
  92. package/front_end/panels/timeline/components/insights/SlowCSSSelector.ts +15 -14
  93. package/front_end/panels/timeline/components/insights/Table.ts +152 -130
  94. package/front_end/panels/timeline/components/insights/ThirdParties.ts +11 -9
  95. package/front_end/panels/timeline/components/timelineSummary.css +58 -57
  96. package/front_end/panels/timeline/thirdPartyTreeView.css +109 -0
  97. package/front_end/panels/timeline/timelineDetailsView.css +2 -4
  98. package/front_end/panels/timeline/timelinePanel.css +0 -110
  99. package/front_end/third_party/acorn/estree-legacy.d.ts +2 -0
  100. package/front_end/third_party/chromium/README.chromium +1 -1
  101. package/front_end/third_party/puppeteer/README.chromium +2 -2
  102. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/CDPSession.d.ts.map +1 -1
  103. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/CDPSession.js.map +1 -1
  104. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/ElementHandle.d.ts.map +1 -1
  105. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/ElementHandle.js.map +1 -1
  106. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Frame.d.ts.map +1 -1
  107. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Frame.js.map +1 -1
  108. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.d.ts.map +1 -1
  109. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.js.map +1 -1
  110. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/Connection.d.ts.map +1 -1
  111. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/BrowserConnector.js +21 -7
  112. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/BrowserConnector.js.map +1 -1
  113. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/EventEmitter.d.ts.map +1 -1
  114. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
  115. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
  116. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
  117. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
  118. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +15 -6
  119. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/CDPSession.d.ts.map +1 -1
  120. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/CDPSession.js.map +1 -1
  121. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/ElementHandle.d.ts.map +1 -1
  122. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/ElementHandle.js.map +1 -1
  123. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Frame.d.ts.map +1 -1
  124. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Frame.js.map +1 -1
  125. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.d.ts.map +1 -1
  126. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.js.map +1 -1
  127. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/Connection.d.ts.map +1 -1
  128. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/BrowserConnector.js +21 -7
  129. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/BrowserConnector.js.map +1 -1
  130. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/EventEmitter.d.ts.map +1 -1
  131. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
  132. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
  133. package/front_end/third_party/puppeteer/package/package.json +2 -2
  134. package/front_end/third_party/puppeteer/package/src/api/CDPSession.ts +1 -2
  135. package/front_end/third_party/puppeteer/package/src/api/ElementHandle.ts +2 -4
  136. package/front_end/third_party/puppeteer/package/src/api/Frame.ts +2 -4
  137. package/front_end/third_party/puppeteer/package/src/api/Page.ts +2 -4
  138. package/front_end/third_party/puppeteer/package/src/bidi/core/Connection.ts +3 -2
  139. package/front_end/third_party/puppeteer/package/src/common/BrowserConnector.ts +29 -10
  140. package/front_end/third_party/puppeteer/package/src/common/EventEmitter.ts +3 -3
  141. package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
  142. package/front_end/ui/components/report_view/ReportView.docs.ts +37 -0
  143. package/front_end/ui/components/report_view/ReportView.ts +1 -4
  144. package/front_end/ui/components/settings/SettingCheckbox.ts +1 -1
  145. package/front_end/ui/legacy/Floaty.ts +5 -9
  146. package/front_end/ui/legacy/InspectorView.ts +2 -1
  147. package/front_end/ui/legacy/ReportView.ts +5 -4
  148. package/front_end/ui/legacy/TabbedPane.ts +1 -1
  149. package/front_end/ui/legacy/ViewManager.ts +2 -32
  150. package/front_end/ui/legacy/Widget.ts +7 -0
  151. package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +0 -1
  152. package/front_end/ui/legacy/reportView.css +0 -24
  153. package/front_end/ui/visual_logging/KnownContextValues.ts +7 -0
  154. package/package.json +1 -1
  155. /package/front_end/{ui/components → models}/annotations/AnnotationType.ts +0 -0
  156. /package/front_end/{ui/components → models}/annotations/annotations.ts +0 -0
@@ -7,8 +7,8 @@
7
7
  import * as Common from '../../core/common/common.js';
8
8
  import * as Host from '../../core/host/host.js';
9
9
  import * as i18n from '../../core/i18n/i18n.js';
10
- import * as Root from '../../core/root/root.js';
11
10
  import * as FormatterActions from '../../entrypoints/formatter_worker/FormatterActions.js'; // eslint-disable-line @devtools/es-modules-import
11
+ import * as AiCodeCompletion from '../../models/ai_code_completion/ai_code_completion.js';
12
12
  import * as IssuesManager from '../../models/issues_manager/issues_manager.js';
13
13
  import * as Persistence from '../../models/persistence/persistence.js';
14
14
  import * as TextUtils from '../../models/text_utils/text_utils.js';
@@ -321,7 +321,8 @@ export class UISourceCodeFrame extends Common.ObjectWrapper
321
321
  AiWarningInfobarPlugin,
322
322
  ];
323
323
 
324
- if (this.#isAiCodeCompletionEnabled()) {
324
+ const devtoolsLocale = i18n.DevToolsLocale.DevToolsLocale.instance();
325
+ if (AiCodeCompletion.AiCodeCompletion.AiCodeCompletion.isAiCodeCompletionEnabled(devtoolsLocale.locale)) {
325
326
  sourceFramePluginsList.push(AiCodeCompletionPlugin);
326
327
  }
327
328
  return sourceFramePluginsList;
@@ -511,21 +512,6 @@ export class UISourceCodeFrame extends Common.ObjectWrapper
511
512
  this.#uiSourceCode.url().startsWith('debugger://'));
512
513
  Host.userMetrics.sourcesPanelFileOpened(mediaType);
513
514
  }
514
-
515
- static #isAiCodeCompletionEnabled(): boolean {
516
- const devtoolsLocale = i18n.DevToolsLocale.DevToolsLocale.instance();
517
- const aidaAvailability = Root.Runtime.hostConfig.aidaAvailability;
518
- if (!devtoolsLocale.locale.startsWith('en-')) {
519
- return false;
520
- }
521
- if (aidaAvailability?.blockedByGeo) {
522
- return false;
523
- }
524
- if (aidaAvailability?.blockedByAge) {
525
- return false;
526
- }
527
- return Boolean(aidaAvailability?.enabled && Root.Runtime.hostConfig.devToolsAiCodeCompletion?.enabled);
528
- }
529
515
  }
530
516
 
531
517
  function getIconDataForLevel(level: Workspace.UISourceCode.Message.Level): IconWithName {
@@ -2138,14 +2138,11 @@ export class TimelineUIUtils {
2138
2138
  const start = Trace.Types.Timing.Milli(rangeStart);
2139
2139
  const end = Trace.Types.Timing.Milli(rangeEnd);
2140
2140
  const categorySummaryTable = new TimelineComponents.TimelineSummary.CategorySummary();
2141
- categorySummaryTable.data = {
2142
- rangeStart: start,
2143
- rangeEnd: end,
2144
- total,
2145
- categories,
2146
- selectedEvents,
2147
- };
2148
- element.append(categorySummaryTable);
2141
+ categorySummaryTable.rangeStart = start;
2142
+ categorySummaryTable.rangeEnd = end;
2143
+ categorySummaryTable.total = total;
2144
+ categorySummaryTable.categories = categories;
2145
+ element.append(categorySummaryTable.contentElement);
2149
2146
  // Add the 3p datagrid
2150
2147
  const treeView = new ThirdPartyTreeView.ThirdPartyTreeElement();
2151
2148
  treeView.treeView = thirdPartyTree;
@@ -1,10 +1,9 @@
1
1
  // Copyright 2024 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
- /* eslint-disable @devtools/no-lit-render-outside-of-view */
5
4
 
6
5
  import * as i18n from '../../../core/i18n/i18n.js';
7
- import type * as Trace from '../../../models/trace/trace.js';
6
+ import * as Buttons from '../../../ui/components/buttons/buttons.js';
8
7
  import * as UI from '../../../ui/legacy/legacy.js';
9
8
  import * as Lit from '../../../ui/lit/lit.js';
10
9
 
@@ -33,74 +32,96 @@ export interface CategoryData {
33
32
  title: string;
34
33
  }
35
34
 
36
- export interface SummaryTableData {
37
- total: number;
35
+ interface ViewInput {
38
36
  rangeStart: number;
39
37
  rangeEnd: number;
38
+ total: number;
40
39
  categories: CategoryData[];
41
- selectedEvents: Trace.Types.Events.Event[];
42
40
  }
43
41
 
44
- export class CategorySummary extends HTMLElement {
45
- readonly #shadow =
46
- UI.UIUtils.createShadowRootWithCoreStyles(this, {cssFile: timelineSummaryStyles, delegatesFocus: undefined});
42
+ type View = (input: ViewInput, output: undefined, target: HTMLElement) => void;
43
+
44
+ export const CATEGORY_SUMMARY_DEFAULT_VIEW: View = (input, _output, target): void => {
45
+ // clang-format off
46
+ render(html`
47
+ <style>${timelineSummaryStyles}</style>
48
+ <style>@scope to (devtools-widget > *) { ${UI.inspectorCommonStyles} }</style>
49
+ <style>@scope to (devtools-widget > *) { ${Buttons.textButtonStyles} }</style>
50
+ <div class="timeline-summary">
51
+ <div class="summary-range">${i18nString(UIStrings.rangeSS, {PH1: i18n.TimeUtilities.millisToString(input.rangeStart), PH2: i18n.TimeUtilities.millisToString(input.rangeEnd)})}</div>
52
+ <div class="category-summary">
53
+ ${input.categories.map(category => {
54
+ return html`
55
+ <div class="category-row">
56
+ <div class="category-swatch" style="background-color: ${category.color};"></div>
57
+ <div class="category-name">${category.title}</div>
58
+ <div class="category-value">
59
+ ${i18n.TimeUtilities.preciseMillisToString(category.value)}
60
+ <div class="background-bar-container">
61
+ <div class="background-bar" style='width: ${(category.value * 100 / input.total).toFixed(1)}%;'></div>
62
+ </div>
63
+ </div>
64
+ </div>`;
65
+ })}
66
+ <div class="category-row">
67
+ <div class="category-swatch"></div>
68
+ <div class="category-name">${i18nString(UIStrings.total)}</div>
69
+ <div class="category-value">
70
+ ${i18n.TimeUtilities.preciseMillisToString(input.total)}
71
+ <div class="background-bar-container">
72
+ <div class="background-bar"></div>
73
+ </div>
74
+ </div>
75
+ </div>
76
+ </div>
77
+ </div>
78
+ </div>
79
+
80
+ </div>`, target);
81
+ // clang-format on
82
+ };
83
+
84
+ export class CategorySummary extends UI.Widget.Widget {
85
+ #view: View;
47
86
 
48
87
  #rangeStart = 0;
49
88
  #rangeEnd = 0;
50
89
  #total = 0;
51
90
  #categories: CategoryData[] = [];
52
91
 
53
- set data(data: SummaryTableData) {
54
- this.#total = data.total;
55
- this.#categories = data.categories;
56
- this.#rangeStart = data.rangeStart;
57
- this.#rangeEnd = data.rangeEnd;
58
- this.#render();
92
+ constructor(view?: View) {
93
+ super();
94
+ this.#view = view ?? CATEGORY_SUMMARY_DEFAULT_VIEW;
95
+ this.requestUpdate();
59
96
  }
60
97
 
61
- #render(): void {
62
- // clang-format off
63
- const output = html`
64
- <div class="timeline-summary">
65
- <div class="summary-range">${i18nString(UIStrings.rangeSS, {PH1: i18n.TimeUtilities.millisToString(this.#rangeStart), PH2: i18n.TimeUtilities.millisToString(this.#rangeEnd)})}</div>
66
- <div class="category-summary">
67
- ${this.#categories.map(category => {
68
- return html`
69
- <div class="category-row">
70
- <div class="category-swatch" style="background-color: ${category.color};"></div>
71
- <div class="category-name">${category.title}</div>
72
- <div class="category-value">
73
- ${i18n.TimeUtilities.preciseMillisToString(category.value)}
74
- <div class="background-bar-container">
75
- <div class="background-bar" style='width: ${(category.value * 100 / this.#total).toFixed(1)}%;'></div>
76
- </div>
77
- </div>
78
- </div>`;
79
- })}
80
- <div class="category-row">
81
- <div class="category-swatch"></div>
82
- <div class="category-name">${i18nString(UIStrings.total)}</div>
83
- <div class="category-value">
84
- ${i18n.TimeUtilities.preciseMillisToString(this.#total)}
85
- <div class="background-bar-container">
86
- <div class="background-bar"></div>
87
- </div>
88
- </div>
89
- </div>
90
- </div>
91
- </div>
92
- </div>
98
+ set total(total: number) {
99
+ this.#total = total;
100
+ this.requestUpdate();
101
+ }
93
102
 
94
- </div>`;
95
- // clang-format on
96
- render(output, this.#shadow, {host: this});
103
+ set rangeStart(rangeStart: number) {
104
+ this.#rangeStart = rangeStart;
105
+ this.requestUpdate();
97
106
  }
98
- }
99
107
 
100
- customElements.define('devtools-performance-timeline-summary', CategorySummary);
108
+ set rangeEnd(rangeEnd: number) {
109
+ this.#rangeEnd = rangeEnd;
110
+ this.requestUpdate();
111
+ }
112
+
113
+ set categories(categories: CategoryData[]) {
114
+ this.#categories = categories;
115
+ this.requestUpdate();
116
+ }
101
117
 
102
- declare global {
103
- interface HTMLElementTagNameMap {
104
- 'devtools-performance-timeline-summary': CategorySummary;
118
+ override performUpdate(): void {
119
+ const viewInput: ViewInput = {
120
+ rangeStart: this.#rangeStart,
121
+ rangeEnd: this.#rangeEnd,
122
+ total: this.#total,
123
+ categories: this.#categories,
124
+ };
125
+ this.#view(viewInput, undefined, this.contentElement);
105
126
  }
106
127
  }
@@ -1,7 +1,6 @@
1
1
  // Copyright 2024 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
- /* eslint-disable @devtools/no-imperative-dom-api */
5
4
 
6
5
  import '../../../../ui/components/markdown_view/markdown_view.js';
7
6
 
@@ -9,6 +8,7 @@ import * as i18n from '../../../../core/i18n/i18n.js';
9
8
  import * as Root from '../../../../core/root/root.js';
10
9
  import * as AIAssistance from '../../../../models/ai_assistance/ai_assistance.js';
11
10
  import * as Badges from '../../../../models/badges/badges.js';
11
+ import * as GreenDev from '../../../../models/greendev/greendev.js';
12
12
  import type {InsightModel} from '../../../../models/trace/insights/types.js';
13
13
  import type * as Trace from '../../../../models/trace/trace.js';
14
14
  import * as Buttons from '../../../../ui/components/buttons/buttons.js';
@@ -70,7 +70,7 @@ interface ViewInput {
70
70
  model: InsightModel;
71
71
  selected: boolean;
72
72
  isAIAssistanceContext: boolean;
73
- canShowAskAI: boolean;
73
+ showAskAI: boolean;
74
74
  estimatedSavingsString: string|null;
75
75
  estimatedSavingsAriaLabel: string|null;
76
76
  renderContent: () => Lit.LitTemplate;
@@ -89,7 +89,7 @@ const DEFAULT_VIEW: View = (input, output, target) => {
89
89
  estimatedSavingsString,
90
90
  estimatedSavingsAriaLabel,
91
91
  isAIAssistanceContext,
92
- canShowAskAI,
92
+ showAskAI,
93
93
  dispatchInsightToggle,
94
94
  renderContent,
95
95
  onHeaderKeyDown,
@@ -122,7 +122,7 @@ const DEFAULT_VIEW: View = (input, output, target) => {
122
122
  <div class="insight-body">
123
123
  <div class="insight-description">${md(model.description)}</div>
124
124
  <div class="insight-content">${content}</div>
125
- ${canShowAskAI ? html`
125
+ ${showAskAI ? html`
126
126
  <div class="ask-ai-btn-wrap">
127
127
  <devtools-button class="ask-ai"
128
128
  .variant=${Buttons.Button.Variant.OUTLINED}
@@ -206,9 +206,6 @@ export abstract class BaseInsightComponent<T extends InsightModel> extends UI.Wi
206
206
  #view: View;
207
207
  abstract internalName: string;
208
208
 
209
- // This flag tracks if the Insights AI feature is enabled within Chrome for
210
- // the active user.
211
- #askAiEnabled = false;
212
209
  // Tracks if this component is rendered withing the AI assistance panel.
213
210
  // Currently only relevant to GreenDev.
214
211
  #isAIAssistanceContext = false;
@@ -246,16 +243,6 @@ export abstract class BaseInsightComponent<T extends InsightModel> extends UI.Wi
246
243
  return false;
247
244
  }
248
245
 
249
- override wasShown(): void {
250
- super.wasShown();
251
-
252
- // Used for unit test purposes when querying the DOM.
253
- this.element.dataset.insightName = this.internalName;
254
-
255
- const {devToolsAiAssistancePerformanceAgent} = Root.Runtime.hostConfig;
256
- this.#askAiEnabled = Boolean(devToolsAiAssistancePerformanceAgent?.enabled);
257
- }
258
-
259
246
  set isAIAssistanceContext(isAIAssistanceContext: boolean) {
260
247
  this.#isAIAssistanceContext = isAIAssistanceContext;
261
248
  this.requestUpdate();
@@ -300,11 +287,11 @@ export abstract class BaseInsightComponent<T extends InsightModel> extends UI.Wi
300
287
  this.requestUpdate();
301
288
  }
302
289
 
303
- set agentFocus(agentFocus: AIAssistance.AIContext.AgentFocus) {
290
+ set agentFocus(agentFocus: AIAssistance.AIContext.AgentFocus|null) {
304
291
  this.#agentFocus = agentFocus;
305
292
  }
306
293
 
307
- set fieldMetrics(fieldMetrics: Trace.Insights.Common.CrUXFieldMetricResults) {
294
+ set fieldMetrics(fieldMetrics: Trace.Insights.Common.CrUXFieldMetricResults|null) {
308
295
  this.#fieldMetrics = fieldMetrics;
309
296
  }
310
297
 
@@ -322,7 +309,7 @@ export abstract class BaseInsightComponent<T extends InsightModel> extends UI.Wi
322
309
  return;
323
310
  }
324
311
 
325
- if (this.#parsedTrace && UI.Floaty.enabled()) {
312
+ if (this.#parsedTrace && GreenDev.Prototypes.instance().isEnabled('inDevToolsFloaty')) {
326
313
  const floatyHandled = UI.Floaty.onFloatyClick({
327
314
  type: UI.Floaty.FloatyContextTypes.PERFORMANCE_INSIGHT,
328
315
  data: {
@@ -422,7 +409,7 @@ export abstract class BaseInsightComponent<T extends InsightModel> extends UI.Wi
422
409
  estimatedSavingsString: this.getEstimatedSavingsString(),
423
410
  estimatedSavingsAriaLabel: this.#getEstimatedSavingsAriaLabel(),
424
411
  isAIAssistanceContext: this.#isAIAssistanceContext,
425
- canShowAskAI: this.#canShowAskAI(),
412
+ showAskAI: this.#canShowAskAI(),
426
413
  dispatchInsightToggle: () => this.#dispatchInsightToggle(),
427
414
  renderContent: () => this.renderContent(),
428
415
  onHeaderKeyDown: () => this.#onHeaderKeyDown,
@@ -527,14 +514,19 @@ export abstract class BaseInsightComponent<T extends InsightModel> extends UI.Wi
527
514
  }
528
515
 
529
516
  #canShowAskAI(): boolean {
530
- if (this.#isAIAssistanceContext) {
517
+ if (this.#isAIAssistanceContext || !this.hasAskAiSupport()) {
531
518
  return false;
532
519
  }
533
520
 
534
- const aiAvailable = Root.Runtime.hostConfig.aidaAvailability?.enterprisePolicyValue !==
535
- Root.Runtime.GenAiEnterprisePolicyValue.DISABLE &&
536
- this.#askAiEnabled && Root.Runtime.hostConfig.aidaAvailability?.enabled === true;
521
+ // Check if the Insights AI feature enabled within Chrome for the active user.
522
+ const {devToolsAiAssistancePerformanceAgent} = Root.Runtime.hostConfig;
523
+ const askAiEnabled = Boolean(devToolsAiAssistancePerformanceAgent?.enabled);
524
+ if (!askAiEnabled) {
525
+ return false;
526
+ }
537
527
 
538
- return aiAvailable && this.hasAskAiSupport();
528
+ const {aidaAvailability} = Root.Runtime.hostConfig;
529
+ return aidaAvailability?.enterprisePolicyValue !== Root.Runtime.GenAiEnterprisePolicyValue.DISABLE &&
530
+ aidaAvailability?.enabled === true;
539
531
  }
540
532
  }
@@ -7,15 +7,17 @@ import './Table.js';
7
7
  import * as i18n from '../../../../core/i18n/i18n.js';
8
8
  import type {CacheInsightModel} from '../../../../models/trace/insights/Cache.js';
9
9
  import * as Trace from '../../../../models/trace/trace.js';
10
+ import * as UI from '../../../../ui/legacy/legacy.js';
10
11
  import * as Lit from '../../../../ui/lit/lit.js';
11
12
 
12
13
  import {BaseInsightComponent} from './BaseInsightComponent.js';
13
14
  import {eventRef} from './EventRef.js';
14
- import {createLimitedRows, renderOthersLabel, type TableData, type TableDataRow} from './Table.js';
15
+ import {createLimitedRows, renderOthersLabel, Table, type TableDataRow} from './Table.js';
15
16
 
16
17
  const {UIStrings, i18nString, createOverlayForRequest} = Trace.Insights.Models.Cache;
17
18
 
18
19
  const {html} = Lit;
20
+ const {widgetConfig} = UI.Widget;
19
21
 
20
22
  export class Cache extends BaseInsightComponent<CacheInsightModel> {
21
23
  override internalName = 'cache';
@@ -56,13 +58,15 @@ export class Cache extends BaseInsightComponent<CacheInsightModel> {
56
58
  // clang-format off
57
59
  return html`
58
60
  <div class="insight-section">
59
- <devtools-performance-table
60
- .data=${{
61
- insight: this,
62
- headers: [i18nString(UIStrings.requestColumn), i18nString(UIStrings.cacheTTL)],
63
- rows,
64
- } as TableData}>
65
- </devtools-performance-table>
61
+ <devtools-widget
62
+ .widgetConfig=${widgetConfig(Table, {
63
+ data: {
64
+ insight: this,
65
+ headers: [i18nString(UIStrings.requestColumn), i18nString(UIStrings.cacheTTL)],
66
+ rows,
67
+ },
68
+ })}>
69
+ </devtools-widget>
66
70
  </div>`;
67
71
  // clang-format on
68
72
  }
@@ -8,17 +8,19 @@ import './Table.js';
8
8
  import * as i18n from '../../../../core/i18n/i18n.js';
9
9
  import type {DOMSizeInsightModel} from '../../../../models/trace/insights/DOMSize.js';
10
10
  import * as Trace from '../../../../models/trace/trace.js';
11
+ import * as UI from '../../../../ui/legacy/legacy.js';
11
12
  import * as Lit from '../../../../ui/lit/lit.js';
12
13
 
13
14
  import {BaseInsightComponent} from './BaseInsightComponent.js';
14
15
  import {eventRef} from './EventRef.js';
15
16
  import {md} from './Helpers.js';
16
17
  import {nodeLink} from './NodeLink.js';
17
- import type {TableData, TableDataRow} from './Table.js';
18
+ import {Table, type TableDataRow} from './Table.js';
18
19
 
19
20
  const {UIStrings, i18nString} = Trace.Insights.Models.DOMSize;
20
21
 
21
22
  const {html} = Lit;
23
+ const {widgetConfig} = UI.Widget;
22
24
 
23
25
  export class DOMSize extends BaseInsightComponent<DOMSizeInsightModel> {
24
26
  override internalName = 'dom-size';
@@ -28,7 +30,7 @@ export class DOMSize extends BaseInsightComponent<DOMSizeInsightModel> {
28
30
  }
29
31
 
30
32
  #renderNodeTable(domStatsData: Trace.Types.Events.DOMStats['args']['data']): Lit.LitTemplate {
31
- const rows: TableData['rows'] = [];
33
+ const rows: TableDataRow[] = [];
32
34
 
33
35
  if (domStatsData.maxDepth) {
34
36
  const {nodeId, nodeName} = domStatsData.maxDepth;
@@ -56,13 +58,13 @@ export class DOMSize extends BaseInsightComponent<DOMSizeInsightModel> {
56
58
 
57
59
  // clang-format off
58
60
  return html`<div class="insight-section">
59
- <devtools-performance-table
60
- .data=${{
61
+ <devtools-widget .widgetConfig=${widgetConfig(Table, {
62
+ data: {
61
63
  insight: this,
62
64
  headers: [i18nString(UIStrings.statistic), i18nString(UIStrings.element)],
63
65
  rows,
64
- } as TableData}>
65
- </devtools-performance-table>
66
+ }})}>
67
+ </devtools-widget>
66
68
  </div>`;
67
69
  // clang-format on
68
70
  }
@@ -86,13 +88,13 @@ export class DOMSize extends BaseInsightComponent<DOMSizeInsightModel> {
86
88
  // clang-format off
87
89
  return html`<div class="insight-section">
88
90
  <div class="insight-description">${md(i18nString(UIStrings.topUpdatesDescription))}</div>
89
- <devtools-performance-table
90
- .data=${{
91
+ <devtools-widget .widgetConfig=${widgetConfig(Table, {
92
+ data: {
91
93
  insight: this,
92
94
  headers: ['', i18nString(UIStrings.duration)],
93
95
  rows,
94
- } as TableData}>
95
- </devtools-performance-table>
96
+ }})}>
97
+ </devtools-widget>
96
98
  </div>`;
97
99
  // clang-format on
98
100
  }
@@ -109,17 +111,19 @@ export class DOMSize extends BaseInsightComponent<DOMSizeInsightModel> {
109
111
 
110
112
  // clang-format off
111
113
  return html`<div class="insight-section">
112
- <devtools-performance-table
113
- .data=${{
114
- insight: this,
115
- headers: [i18nString(UIStrings.statistic), i18nString(UIStrings.value)],
116
- rows: [
117
- {values: [i18nString(UIStrings.totalElements), domStatsData.totalElements]},
118
- {values: [i18nString(UIStrings.maxDOMDepth), domStatsData.maxDepth?.depth ?? 0]},
119
- {values: [i18nString(UIStrings.maxChildren), domStatsData.maxChildren?.numChildren ?? 0]},
120
- ],
121
- } as TableData}>
122
- </devtools-performance-table>
114
+ <devtools-widget
115
+ .widgetConfig=${widgetConfig(Table, {
116
+ data: {
117
+ insight: this,
118
+ headers: [i18nString(UIStrings.statistic), i18nString(UIStrings.value)],
119
+ rows: [
120
+ {values: [i18nString(UIStrings.totalElements), domStatsData.totalElements]},
121
+ {values: [i18nString(UIStrings.maxDOMDepth), domStatsData.maxDepth?.depth ?? 0]},
122
+ {values: [i18nString(UIStrings.maxChildren), domStatsData.maxChildren?.numChildren ?? 0]},
123
+ ],
124
+ },
125
+ })}>
126
+ </devtools-widget>
123
127
  </div>
124
128
  ${this.#renderNodeTable(domStatsData)}
125
129
  ${this.#renderLargeUpdatesTable()}
@@ -2,23 +2,23 @@
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
4
 
5
- import './Table.js';
6
-
7
5
  import * as i18n from '../../../../core/i18n/i18n.js';
8
6
  import type {DuplicatedJavaScriptInsightModel} from '../../../../models/trace/insights/DuplicatedJavaScript.js';
9
7
  import * as Trace from '../../../../models/trace/trace.js';
10
8
  import * as Buttons from '../../../../ui/components/buttons/buttons.js';
9
+ import * as UI from '../../../../ui/legacy/legacy.js';
11
10
  import * as Lit from '../../../../ui/lit/lit.js';
12
11
  import * as VisualLogging from '../../../../ui/visual_logging/visual_logging.js';
13
12
  import * as Utils from '../../utils/utils.js';
14
13
 
15
14
  import {BaseInsightComponent} from './BaseInsightComponent.js';
16
15
  import {scriptRef} from './ScriptRef.js';
17
- import type {TableData, TableDataRow} from './Table.js';
16
+ import {Table, type TableDataRow} from './Table.js';
18
17
 
19
18
  const {UIStrings, i18nString} = Trace.Insights.Models.DuplicatedJavaScript;
20
19
 
21
20
  const {html} = Lit;
21
+ const {widgetConfig} = UI.Widget;
22
22
 
23
23
  export class DuplicatedJavaScript extends BaseInsightComponent<DuplicatedJavaScriptInsightModel> {
24
24
  override internalName = 'duplicated-javascript';
@@ -105,13 +105,13 @@ export class DuplicatedJavaScript extends BaseInsightComponent<DuplicatedJavaScr
105
105
  return html`
106
106
  ${treemapButton}
107
107
  <div class="insight-section">
108
- <devtools-performance-table
109
- .data=${{
108
+ <devtools-widget .widgetConfig=${widgetConfig(Table, {
109
+ data: {
110
110
  insight: this,
111
111
  headers: [i18nString(UIStrings.columnSource), i18nString(UIStrings.columnDuplicatedBytes)],
112
112
  rows,
113
- } as TableData}>
114
- </devtools-performance-table>
113
+ }})}>
114
+ </devtools-widget>
115
115
  </div>
116
116
  `;
117
117
  // clang-format on
@@ -7,15 +7,17 @@ import './Table.js';
7
7
  import * as i18n from '../../../../core/i18n/i18n.js';
8
8
  import type {FontDisplayInsightModel} from '../../../../models/trace/insights/FontDisplay.js';
9
9
  import * as Trace from '../../../../models/trace/trace.js';
10
+ import * as UI from '../../../../ui/legacy/legacy.js';
10
11
  import * as Lit from '../../../../ui/lit/lit.js';
11
12
 
12
13
  import {BaseInsightComponent} from './BaseInsightComponent.js';
13
14
  import {eventRef} from './EventRef.js';
14
- import {createLimitedRows, renderOthersLabel, type TableData, type TableDataRow} from './Table.js';
15
+ import {createLimitedRows, renderOthersLabel, Table, type TableDataRow} from './Table.js';
15
16
 
16
17
  const {UIStrings, i18nString} = Trace.Insights.Models.FontDisplay;
17
18
 
18
19
  const {html} = Lit;
20
+ const {widgetConfig} = UI.Widget;
19
21
 
20
22
  export class FontDisplay extends BaseInsightComponent<FontDisplayInsightModel> {
21
23
  override internalName = 'font-display';
@@ -76,13 +78,13 @@ export class FontDisplay extends BaseInsightComponent<FontDisplayInsightModel> {
76
78
  // clang-format off
77
79
  return html`
78
80
  <div class="insight-section">
79
- ${html`<devtools-performance-table
80
- .data=${{
81
+ ${html`<devtools-widget .widgetConfig=${widgetConfig(Table, {
82
+ data: {
81
83
  insight: this,
82
84
  headers: [i18nString(UIStrings.fontColumn), i18nString(UIStrings.wastedTimeColumn)],
83
85
  rows,
84
- } as TableData}>
85
- </devtools-performance-table>`}
86
+ }})}>
87
+ </devtools-widget>`}
86
88
  </div>`;
87
89
  // clang-format on
88
90
  }
@@ -9,14 +9,16 @@ import type * as Protocol from '../../../../generated/protocol.js';
9
9
  import type {ForcedReflowInsightModel} from '../../../../models/trace/insights/ForcedReflow.js';
10
10
  import * as Trace from '../../../../models/trace/trace.js';
11
11
  import * as LegacyComponents from '../../../../ui/legacy/components/utils/utils.js';
12
+ import * as UI from '../../../../ui/legacy/legacy.js';
12
13
  import * as Lit from '../../../../ui/lit/lit.js';
13
14
 
14
15
  import {BaseInsightComponent} from './BaseInsightComponent.js';
15
- import {createLimitedRows, renderOthersLabel, type TableData, type TableDataRow} from './Table.js';
16
+ import {createLimitedRows, renderOthersLabel, Table, type TableDataRow} from './Table.js';
16
17
 
17
18
  const {UIStrings, i18nString, createOverlayForEvents} = Trace.Insights.Models.ForcedReflow;
18
19
 
19
20
  const {html, nothing} = Lit;
21
+ const {widgetConfig} = UI.Widget;
20
22
 
21
23
  export class ForcedReflow extends BaseInsightComponent<ForcedReflowInsightModel> {
22
24
  override internalName = 'forced-reflow';
@@ -85,8 +87,8 @@ export class ForcedReflow extends BaseInsightComponent<ForcedReflowInsightModel>
85
87
  return html`
86
88
  ${topLevelFunctionCallData ? html`
87
89
  <div class="insight-section">
88
- <devtools-performance-table
89
- .data=${{
90
+ <devtools-widget .widgetConfig=${widgetConfig(Table, {
91
+ data: {
90
92
  insight: this,
91
93
  headers: [i18nString(UIStrings.topTimeConsumingFunctionCall), i18nString(UIStrings.totalReflowTime)],
92
94
  rows: [{
@@ -96,18 +98,18 @@ export class ForcedReflow extends BaseInsightComponent<ForcedReflowInsightModel>
96
98
  ],
97
99
  overlays: createOverlayForEvents(topLevelFunctionCallData.topLevelFunctionCallEvents, 'INFO'),
98
100
  }],
99
- } as TableData}>
100
- </devtools-performance-table>
101
+ }})}>
102
+ </devtools-widget>
101
103
  </div>
102
104
  ` : nothing}
103
105
  <div class="insight-section">
104
- <devtools-performance-table
105
- .data=${{
106
+ <devtools-widget .widgetConfig=${widgetConfig(Table, {
107
+ data: {
106
108
  insight: this,
107
109
  headers: [i18nString(UIStrings.reflowCallFrames)],
108
110
  rows,
109
- } as TableData}>
110
- </devtools-performance-table>
111
+ }})}>
112
+ </devtools-widget>
111
113
  </div>`;
112
114
  // clang-format on
113
115
  }