chrome-devtools-frontend 1.0.1690116 → 1.0.1690531

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 (146) hide show
  1. package/.gitmodules +4 -0
  2. package/front_end/core/root/Runtime.ts +1 -0
  3. package/front_end/core/sdk/NetworkRequest.ts +50 -4
  4. package/front_end/core/sdk/NetworkRequestAccess.ts +172 -0
  5. package/front_end/core/sdk/SecurityOrigin.ts +25 -0
  6. package/front_end/core/sdk/sdk.ts +2 -0
  7. package/front_end/generated/SupportedCSSProperties.ts +1 -1
  8. package/front_end/models/ai_assistance/AiAgent2.ts +4 -1
  9. package/front_end/models/ai_assistance/AiConversation.ts +29 -18
  10. package/front_end/panels/ai_assistance/components/chatMessage.css +3 -1
  11. package/front_end/panels/application/components/BackForwardCacheView.ts +1 -1
  12. package/front_end/panels/application/components/EndpointsGrid.ts +2 -1
  13. package/front_end/panels/application/components/PermissionsPolicySection.ts +1 -1
  14. package/front_end/panels/application/components/ServiceWorkerRouterView.ts +1 -1
  15. package/front_end/panels/application/components/TrustTokensView.ts +1 -1
  16. package/front_end/panels/application/preloading/components/PreloadingDetailsReportView.ts +2 -1
  17. package/front_end/panels/application/preloading/components/RuleSetDetailsView.ts +2 -1
  18. package/front_end/panels/application/preloading/components/UsedPreloadingView.ts +1 -1
  19. package/front_end/panels/common/CPUThrottlingOption.ts +12 -6
  20. package/front_end/panels/common/DOMLinkifier.ts +1 -1
  21. package/front_end/panels/common/ExtensionView.ts +2 -1
  22. package/front_end/panels/console/ConsolePinPane.ts +4 -2
  23. package/front_end/panels/console/ConsoleSidebar.ts +6 -2
  24. package/front_end/panels/console/PromptBuilder.ts +1 -1
  25. package/front_end/panels/coverage/CoverageListView.ts +1 -1
  26. package/front_end/panels/coverage/CoverageModel.ts +6 -4
  27. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +9 -9
  28. package/front_end/panels/css_overview/CSSOverviewPanel.ts +3 -3
  29. package/front_end/panels/css_overview/CSSOverviewProcessingView.ts +2 -2
  30. package/front_end/panels/css_overview/CSSOverviewSidebarPanel.ts +3 -3
  31. package/front_end/panels/css_overview/CSSOverviewStartView.ts +3 -3
  32. package/front_end/panels/developer_resources/DeveloperResourcesListView.ts +1 -1
  33. package/front_end/panels/elements/ComputedStyleWidget.ts +1 -1
  34. package/front_end/panels/elements/ElementsTreeElement.ts +4 -3
  35. package/front_end/panels/elements/ElementsTreeOutline.ts +2 -2
  36. package/front_end/panels/elements/MetricsSidebarPane.ts +1 -1
  37. package/front_end/panels/elements/PropertyNameCategories.ts +1 -1
  38. package/front_end/panels/elements/ShortcutTreeElement.ts +2 -1
  39. package/front_end/panels/elements/StandaloneStylesContainer.ts +1 -1
  40. package/front_end/panels/elements/StylePropertiesSection.ts +1 -1
  41. package/front_end/panels/elements/StylesSidebarPane.ts +3 -2
  42. package/front_end/panels/elements/components/StylePropertyEditor.ts +160 -148
  43. package/front_end/panels/emulation/MediaQueryInspector.ts +2 -1
  44. package/front_end/panels/issues/AffectedLazyLoadImagesView.ts +1 -1
  45. package/front_end/panels/linear_memory_inspector/components/linearMemoryInspector.css +2 -2
  46. package/front_end/panels/linear_memory_inspector/components/linearMemoryNavigator.css +1 -1
  47. package/front_end/panels/linear_memory_inspector/components/linearMemoryValueInterpreter.css +5 -5
  48. package/front_end/panels/linear_memory_inspector/components/linearMemoryViewer.css +6 -6
  49. package/front_end/panels/linear_memory_inspector/components/valueInterpreterDisplay.css +6 -6
  50. package/front_end/panels/linear_memory_inspector/components/valueInterpreterSettings.css +2 -2
  51. package/front_end/panels/network/NetworkDataGridNode.ts +11 -9
  52. package/front_end/panels/network/NetworkLogView.ts +4 -1
  53. package/front_end/panels/network/RequestConditionsDrawer.ts +2 -2
  54. package/front_end/panels/network/RequestHeadersView.ts +1 -1
  55. package/front_end/panels/network/RequestPayloadView.ts +1 -1
  56. package/front_end/panels/network/RequestResponseView.ts +1 -1
  57. package/front_end/panels/network/RequestTimingView.ts +1 -1
  58. package/front_end/panels/network/ShowMoreDetailsWidget.ts +1 -1
  59. package/front_end/panels/network/components/ResponseHeaderSection.ts +1 -1
  60. package/front_end/panels/sources/BreakpointEditDialog.ts +1 -1
  61. package/front_end/panels/sources/CallStackSidebarPane.ts +1 -1
  62. package/front_end/panels/sources/DebuggerPausedMessage.ts +8 -6
  63. package/front_end/panels/sources/ProfilePlugin.ts +2 -1
  64. package/front_end/panels/sources/ScopeChainSidebarPane.ts +1 -1
  65. package/front_end/panels/timeline/IsolateSelector.ts +1 -1
  66. package/front_end/panels/timeline/LayoutShiftsTrackAppender.ts +1 -1
  67. package/front_end/panels/timeline/NetworkTrackAppender.ts +1 -1
  68. package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +1 -1
  69. package/front_end/panels/timeline/TimelineHistoryManager.ts +1 -1
  70. package/front_end/panels/timeline/TimelinePaintProfilerView.ts +7 -3
  71. package/front_end/panels/timeline/TimelinePanel.ts +3 -3
  72. package/front_end/panels/timeline/TimelineTreeView.ts +1 -1
  73. package/front_end/panels/timeline/TimelineUIUtils.ts +4 -4
  74. package/front_end/panels/timeline/components/LayoutShiftDetails.ts +4 -3
  75. package/front_end/panels/timeline/components/LiveMetricsView.ts +1 -1
  76. package/front_end/panels/timeline/components/NetworkRequestDetails.ts +25 -24
  77. package/front_end/panels/timeline/components/RelatedInsightChips.ts +4 -3
  78. package/front_end/panels/timeline/components/Sidebar.ts +1 -1
  79. package/front_end/panels/timeline/components/SidebarAnnotationsTab.ts +4 -3
  80. package/front_end/panels/timeline/utils/Helpers.ts +1 -1
  81. package/front_end/panels/timeline/utils/ImageCache.ts +5 -3
  82. package/front_end/panels/web_audio/WebAudioView.ts +3 -3
  83. package/front_end/panels/webauthn/WebauthnPane.ts +5 -11
  84. package/front_end/third_party/acorn/acorn.ts +3 -3
  85. package/front_end/third_party/chromium/README.chromium +1 -1
  86. package/front_end/third_party/chromium/ahem/ahem.d.ts +1 -0
  87. package/front_end/third_party/csp_evaluator/package/csp.ts +4 -4
  88. package/front_end/third_party/csp_evaluator/package/parser.ts +3 -1
  89. package/front_end/third_party/csp_evaluator/package/utils.ts +1 -1
  90. package/front_end/third_party/diff/diff_match_patch.d.ts +10 -0
  91. package/front_end/third_party/json5/json5.ts +2 -2
  92. package/front_end/ui/components/buttons/floatingButton.css +25 -0
  93. package/front_end/ui/components/srgb_overlay/SrgbOverlay.ts +1 -1
  94. package/front_end/ui/components/suggestion_input/SuggestionInput.ts +45 -25
  95. package/front_end/ui/legacy/ContextMenu.ts +2 -2
  96. package/front_end/ui/legacy/DropTarget.ts +6 -1
  97. package/front_end/ui/legacy/EmptyWidget.ts +1 -1
  98. package/front_end/ui/legacy/GlassPane.ts +1 -1
  99. package/front_end/ui/legacy/ShortcutRegistry.ts +2 -2
  100. package/front_end/ui/legacy/SplitWidget.ts +2 -1
  101. package/front_end/ui/legacy/StackedPane.ts +1 -1
  102. package/front_end/ui/legacy/TargetCrashedScreen.ts +1 -1
  103. package/front_end/ui/legacy/TextPrompt.ts +2 -1
  104. package/front_end/ui/legacy/Toolbar.ts +1 -1
  105. package/front_end/ui/legacy/Treeoutline.ts +13 -37
  106. package/front_end/ui/legacy/UIUtils.ts +6 -3
  107. package/front_end/ui/legacy/ViewManager.ts +1 -1
  108. package/front_end/ui/legacy/Widget.ts +1 -1
  109. package/front_end/ui/legacy/components/color_picker/Spectrum.ts +7 -1
  110. package/front_end/ui/legacy/components/data_grid/DataGrid.ts +1 -1
  111. package/front_end/ui/legacy/components/data_grid/DataGridElement.ts +3 -2
  112. package/front_end/ui/legacy/components/inline_editor/AnimationTimingModel.ts +1 -1
  113. package/front_end/ui/legacy/components/inline_editor/BezierEditor.ts +48 -44
  114. package/front_end/ui/legacy/components/inline_editor/CSSAngleUtils.ts +1 -1
  115. package/front_end/ui/legacy/components/object_ui/CustomPreviewComponent.ts +141 -106
  116. package/front_end/ui/legacy/components/object_ui/ObjectPopoverHelper.ts +1 -1
  117. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +10 -10
  118. package/front_end/ui/legacy/components/perf_ui/pieChart.css +7 -5
  119. package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +8 -5
  120. package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +1 -1
  121. package/front_end/ui/legacy/components/utils/Linkifier.ts +5 -5
  122. package/front_end/ui/legacy/inspectorCommon.css +11 -0
  123. package/front_end/ui/visual_logging/Debugging.ts +2 -1
  124. package/front_end/ui/visual_logging/KnownContextValues.ts +1 -1
  125. package/front_end/ui/visual_logging/LoggingDriver.ts +3 -3
  126. package/front_end/ui/visual_logging/LoggingEvents.ts +5 -5
  127. package/front_end/ui/visual_logging/LoggingState.ts +1 -1
  128. package/front_end/ui/visual_logging/visual_logging.ts +67 -56
  129. package/package.json +2 -1
  130. package/front_end/third_party/acorn/acorn-tsconfig.json +0 -12
  131. package/front_end/third_party/acorn/estree-tsconfig.json +0 -8
  132. package/front_end/third_party/chromium/client-variations/client-variations-tsconfig.json +0 -8
  133. package/front_end/third_party/codemirror/codemirror-legacy-types-tsconfig.json +0 -8
  134. package/front_end/third_party/codemirror/codemirror-tsconfig.json +0 -15
  135. package/front_end/third_party/codemirror.next/bundle-tsconfig.json +0 -24
  136. package/front_end/third_party/intl-messageformat/intl-messageformat-tsconfig.json +0 -16
  137. package/front_end/third_party/json5/json5-tsconfig.json +0 -8
  138. package/front_end/third_party/legacy-javascript/legacy-javascript-tsconfig.json +0 -8
  139. package/front_end/third_party/lighthouse/lighthouse-tsconfig.json +0 -11
  140. package/front_end/third_party/lighthouse/report/bundle-tsconfig.json +0 -8
  141. package/front_end/third_party/lit/lit-tsconfig.json +0 -15
  142. package/front_end/third_party/marked/marked-tsconfig.json +0 -8
  143. package/front_end/third_party/puppeteer/puppeteer-tsconfig.json +0 -191
  144. package/front_end/third_party/third-party-web/third-party-web-tsconfig.json +0 -8
  145. package/front_end/third_party/wasmparser/wasmparser-tsconfig.json +0 -9
  146. package/front_end/third_party/web-vitals/web-vitals-tsconfig.json +0 -47
@@ -1645,7 +1645,13 @@ const MaterialPaletteShades = new Map([
1645
1645
  ],
1646
1646
  ]);
1647
1647
 
1648
- export const MaterialPalette = {
1648
+ export const MaterialPalette: {
1649
+ title: string,
1650
+ mutable: boolean,
1651
+ matchUserFormat: boolean,
1652
+ colors: string[],
1653
+ colorNames: string[],
1654
+ } = {
1649
1655
  title: 'Material',
1650
1656
  mutable: false,
1651
1657
  matchUserFormat: true,
@@ -1756,7 +1756,7 @@ export class DataGridNode<T> {
1756
1756
  selectable = true;
1757
1757
  isRoot = false;
1758
1758
  nodeAccessibleText = '';
1759
- cellAccessibleTextMap = new Map<string, string>();
1759
+ cellAccessibleTextMap: Map<string, string> = new Map<string, string>();
1760
1760
  isCreationNode = false;
1761
1761
  #data: DataGridData;
1762
1762
  #hasChildren: boolean;
@@ -58,7 +58,7 @@ type DataGridElementNode = SortableNode|DynamicHeightNode;
58
58
  const elementToNode = new WeakMap<Element, DataGridElementNode>();
59
59
 
60
60
  export class DataGridElement extends UI.UIUtils.HTMLElementWithLightDOMTemplate {
61
- static readonly observedAttributes = ['striped', 'name', 'inline', 'resize', 'highlight'];
61
+ static readonly observedAttributes: string[] = ['striped', 'name', 'inline', 'resize', 'highlight'];
62
62
 
63
63
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
64
  #dataGrid!: DataGridImpl<any>;
@@ -805,7 +805,8 @@ class IfExpandedDirective extends Lit.Directive.Directive {
805
805
  return node.expanded;
806
806
  }
807
807
  }
808
- export const ifExpanded = Lit.Directive.directive(IfExpandedDirective);
808
+ export const ifExpanded: (content: Lit.LitTemplate|Iterable<Lit.LitTemplate>) =>
809
+ Lit.DirectiveResult<typeof IfExpandedDirective> = Lit.Directive.directive(IfExpandedDirective);
809
810
 
810
811
  function getNode(element: Element|undefined): DataGridElementNode|undefined {
811
812
  return element ? elementToNode.get(element) : undefined;
@@ -27,4 +27,4 @@ export abstract class AnimationTimingModel {
27
27
  }
28
28
  }
29
29
 
30
- export const LINEAR_BEZIER = Geometry.LINEAR_BEZIER;
30
+ export const LINEAR_BEZIER: Geometry.CubicBezier = Geometry.LINEAR_BEZIER;
@@ -245,50 +245,54 @@ export interface EventTypes {
245
245
  [Events.BEZIER_CHANGED]: string;
246
246
  }
247
247
 
248
- export const Presets = [
249
- [
250
- {name: 'linear', value: 'linear'},
251
- {
252
- name: 'elastic',
253
- value:
254
- 'linear(0 0%, 0.22 2.1%, 0.86 6.5%, 1.11 8.6%, 1.3 10.7%, 1.35 11.8%, 1.37 12.9%, 1.37 13.7%, 1.36 14.5%, 1.32 16.2%, 1.03 21.8%, 0.94 24%, 0.89 25.9%, 0.88 26.85%, 0.87 27.8%, 0.87 29.25%, 0.88 30.7%, 0.91 32.4%, 0.98 36.4%, 1.01 38.3%, 1.04 40.5%, 1.05 42.7%, 1.05 44.1%, 1.04 45.7%, 1 53.3%, 0.99 55.4%, 0.98 57.5%, 0.99 60.7%, 1 68.1%, 1.01 72.2%, 1 86.7%, 1 100%)',
255
- },
256
- {
257
- name: 'bounce',
258
- value:
259
- 'linear(0 0%, 0 2.27%, 0.02 4.53%, 0.04 6.8%, 0.06 9.07%, 0.1 11.33%, 0.14 13.6%, 0.25 18.15%, 0.39 22.7%, 0.56 27.25%, 0.77 31.8%, 1 36.35%, 0.89 40.9%, 0.85 43.18%, 0.81 45.45%, 0.79 47.72%, 0.77 50%, 0.75 52.27%, 0.75 54.55%, 0.75 56.82%, 0.77 59.1%, 0.79 61.38%, 0.81 63.65%, 0.85 65.93%, 0.89 68.2%, 1 72.7%, 0.97 74.98%, 0.95 77.25%, 0.94 79.53%, 0.94 81.8%, 0.94 84.08%, 0.95 86.35%, 0.97 88.63%, 1 90.9%, 0.99 93.18%, 0.98 95.45%, 0.99 97.73%, 1 100%)',
260
- },
261
- {
262
- name: 'emphasized',
263
- value:
264
- 'linear(0 0%, 0 1.8%, 0.01 3.6%, 0.03 6.35%, 0.07 9.1%, 0.13 11.4%, 0.19 13.4%, 0.27 15%, 0.34 16.1%, 0.54 18.35%, 0.66 20.6%, 0.72 22.4%, 0.77 24.6%, 0.81 27.3%, 0.85 30.4%, 0.88 35.1%, 0.92 40.6%, 0.94 47.2%, 0.96 55%, 0.98 64%, 0.99 74.4%, 1 86.4%, 1 100%)',
265
- },
266
- ],
267
- [
268
- {name: 'ease-in-out', value: 'ease-in-out'},
269
- {name: 'In Out · Sine', value: 'cubic-bezier(0.45, 0.05, 0.55, 0.95)'},
270
- {name: 'In Out · Quadratic', value: 'cubic-bezier(0.46, 0.03, 0.52, 0.96)'},
271
- {name: 'In Out · Cubic', value: 'cubic-bezier(0.65, 0.05, 0.36, 1)'},
272
- {name: 'Fast Out, Slow In', value: 'cubic-bezier(0.4, 0, 0.2, 1)'},
273
- {name: 'In Out · Back', value: 'cubic-bezier(0.68, -0.55, 0.27, 1.55)'},
274
- ],
275
- [
276
- {name: 'Fast Out, Linear In', value: 'cubic-bezier(0.4, 0, 1, 1)'},
277
- {name: 'ease-in', value: 'ease-in'},
278
- {name: 'In · Sine', value: 'cubic-bezier(0.47, 0, 0.75, 0.72)'},
279
- {name: 'In · Quadratic', value: 'cubic-bezier(0.55, 0.09, 0.68, 0.53)'},
280
- {name: 'In · Cubic', value: 'cubic-bezier(0.55, 0.06, 0.68, 0.19)'},
281
- {name: 'In · Back', value: 'cubic-bezier(0.6, -0.28, 0.74, 0.05)'},
282
- ],
283
- [
284
- {name: 'ease-out', value: 'ease-out'},
285
- {name: 'Out · Sine', value: 'cubic-bezier(0.39, 0.58, 0.57, 1)'},
286
- {name: 'Out · Quadratic', value: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)'},
287
- {name: 'Out · Cubic', value: 'cubic-bezier(0.22, 0.61, 0.36, 1)'},
288
- {name: 'Linear Out, Slow In', value: 'cubic-bezier(0, 0, 0.2, 1)'},
289
- {name: 'Out · Back', value: 'cubic-bezier(0.18, 0.89, 0.32, 1.28)'},
290
- ],
291
- ];
248
+ export const Presets: Array<Array<{
249
+ name: string,
250
+ value: string,
251
+ }>> =
252
+ [
253
+ [
254
+ {name: 'linear', value: 'linear'},
255
+ {
256
+ name: 'elastic',
257
+ value:
258
+ 'linear(0 0%, 0.22 2.1%, 0.86 6.5%, 1.11 8.6%, 1.3 10.7%, 1.35 11.8%, 1.37 12.9%, 1.37 13.7%, 1.36 14.5%, 1.32 16.2%, 1.03 21.8%, 0.94 24%, 0.89 25.9%, 0.88 26.85%, 0.87 27.8%, 0.87 29.25%, 0.88 30.7%, 0.91 32.4%, 0.98 36.4%, 1.01 38.3%, 1.04 40.5%, 1.05 42.7%, 1.05 44.1%, 1.04 45.7%, 1 53.3%, 0.99 55.4%, 0.98 57.5%, 0.99 60.7%, 1 68.1%, 1.01 72.2%, 1 86.7%, 1 100%)',
259
+ },
260
+ {
261
+ name: 'bounce',
262
+ value:
263
+ 'linear(0 0%, 0 2.27%, 0.02 4.53%, 0.04 6.8%, 0.06 9.07%, 0.1 11.33%, 0.14 13.6%, 0.25 18.15%, 0.39 22.7%, 0.56 27.25%, 0.77 31.8%, 1 36.35%, 0.89 40.9%, 0.85 43.18%, 0.81 45.45%, 0.79 47.72%, 0.77 50%, 0.75 52.27%, 0.75 54.55%, 0.75 56.82%, 0.77 59.1%, 0.79 61.38%, 0.81 63.65%, 0.85 65.93%, 0.89 68.2%, 1 72.7%, 0.97 74.98%, 0.95 77.25%, 0.94 79.53%, 0.94 81.8%, 0.94 84.08%, 0.95 86.35%, 0.97 88.63%, 1 90.9%, 0.99 93.18%, 0.98 95.45%, 0.99 97.73%, 1 100%)',
264
+ },
265
+ {
266
+ name: 'emphasized',
267
+ value:
268
+ 'linear(0 0%, 0 1.8%, 0.01 3.6%, 0.03 6.35%, 0.07 9.1%, 0.13 11.4%, 0.19 13.4%, 0.27 15%, 0.34 16.1%, 0.54 18.35%, 0.66 20.6%, 0.72 22.4%, 0.77 24.6%, 0.81 27.3%, 0.85 30.4%, 0.88 35.1%, 0.92 40.6%, 0.94 47.2%, 0.96 55%, 0.98 64%, 0.99 74.4%, 1 86.4%, 1 100%)',
269
+ },
270
+ ],
271
+ [
272
+ {name: 'ease-in-out', value: 'ease-in-out'},
273
+ {name: 'In Out · Sine', value: 'cubic-bezier(0.45, 0.05, 0.55, 0.95)'},
274
+ {name: 'In Out · Quadratic', value: 'cubic-bezier(0.46, 0.03, 0.52, 0.96)'},
275
+ {name: 'In Out · Cubic', value: 'cubic-bezier(0.65, 0.05, 0.36, 1)'},
276
+ {name: 'Fast Out, Slow In', value: 'cubic-bezier(0.4, 0, 0.2, 1)'},
277
+ {name: 'In Out · Back', value: 'cubic-bezier(0.68, -0.55, 0.27, 1.55)'},
278
+ ],
279
+ [
280
+ {name: 'Fast Out, Linear In', value: 'cubic-bezier(0.4, 0, 1, 1)'},
281
+ {name: 'ease-in', value: 'ease-in'},
282
+ {name: 'In · Sine', value: 'cubic-bezier(0.47, 0, 0.75, 0.72)'},
283
+ {name: 'In · Quadratic', value: 'cubic-bezier(0.55, 0.09, 0.68, 0.53)'},
284
+ {name: 'In · Cubic', value: 'cubic-bezier(0.55, 0.06, 0.68, 0.19)'},
285
+ {name: 'In · Back', value: 'cubic-bezier(0.6, -0.28, 0.74, 0.05)'},
286
+ ],
287
+ [
288
+ {name: 'ease-out', value: 'ease-out'},
289
+ {name: 'Out · Sine', value: 'cubic-bezier(0.39, 0.58, 0.57, 1)'},
290
+ {name: 'Out · Quadratic', value: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)'},
291
+ {name: 'Out · Cubic', value: 'cubic-bezier(0.22, 0.61, 0.36, 1)'},
292
+ {name: 'Linear Out, Slow In', value: 'cubic-bezier(0, 0, 0.2, 1)'},
293
+ {name: 'Out · Back', value: 'cubic-bezier(0.18, 0.89, 0.32, 1.28)'},
294
+ ],
295
+ ];
292
296
  export interface PresetCategory {
293
297
  presets: Array<{
294
298
  name: string,
@@ -6,7 +6,7 @@ import * as Platform from '../../../../core/platform/platform.js';
6
6
  import * as Geometry from '../../../../models/geometry/geometry.js';
7
7
  import * as UI from '../../legacy.js';
8
8
 
9
- export const CSSAngleRegex = /(?<value>[+-]?\d*\.?\d+)(?<unit>deg|grad|rad|turn)/;
9
+ const CSSAngleRegex = /(?<value>[+-]?\d*\.?\d+)(?<unit>deg|grad|rad|turn)/;
10
10
 
11
11
  export const enum AngleUnit {
12
12
  DEG = 'deg',
@@ -19,8 +19,6 @@ import {
19
19
  ObjectTree,
20
20
  } from './ObjectPropertiesSection.js';
21
21
 
22
- const {widget} = UI.Widget;
23
-
24
22
  const UIStrings = {
25
23
  /**
26
24
  * @description Context menu item to show a custom formatted object as a standard JavaScript object.
@@ -30,18 +28,38 @@ const UIStrings = {
30
28
  const str_ = i18n.i18n.registerUIStrings('ui/legacy/components/object_ui/CustomPreviewComponent.ts', UIStrings);
31
29
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
32
30
 
33
- export class CustomPreviewSection {
34
- private readonly sectionElement: HTMLSpanElement;
35
- private readonly object: SDK.RemoteObject.RemoteObject;
31
+ export class CustomPreviewSection extends UI.Widget.Widget {
32
+ #object?: SDK.RemoteObject.RemoteObject;
36
33
  private expanded = false;
37
- private cachedContent?: unknown|ObjectTree|null;
34
+ private cachedContent?: unknown|ObjectTree;
38
35
  private headerJsonML?: unknown;
39
- constructor(object: SDK.RemoteObject.RemoteObject) {
40
- this.sectionElement = document.createElement('span');
41
- this.sectionElement.classList.add('custom-expandable-section');
42
- this.object = object;
43
- const customPreview = object.customPreview();
36
+ private readonly view: View;
37
+
38
+ constructor(element?: HTMLElement, view: View = DEFAULT_VIEW) {
39
+ super(element);
40
+ this.view = view;
41
+ }
42
+
43
+ get object(): SDK.RemoteObject.RemoteObject|undefined {
44
+ return this.#object;
45
+ }
44
46
 
47
+ set object(object: SDK.RemoteObject.RemoteObject|undefined) {
48
+ if (this.#object === object) {
49
+ return;
50
+ }
51
+ this.#object = object;
52
+ this.headerJsonML = undefined;
53
+ this.cachedContent = undefined;
54
+ this.expanded = false;
55
+ this.parseHeader();
56
+ // CustomPreviewComponent is used synchronously by ConsoleViewMessage. We must render synchronously
57
+ // so ConsoleViewport can measure the true row height upon insertion.
58
+ this.performUpdate();
59
+ }
60
+
61
+ private parseHeader(): void {
62
+ const customPreview = this.#object?.customPreview();
45
63
  if (!customPreview) {
46
64
  return;
47
65
  }
@@ -50,74 +68,88 @@ export class CustomPreviewSection {
50
68
  this.headerJsonML = JSON.parse(customPreview.header);
51
69
  } catch (e) {
52
70
  Common.Console.Console.instance().error('Broken formatter: header is invalid json ' + e);
53
- return;
54
71
  }
55
- this.render();
56
72
  }
57
73
 
58
- private render(): void {
59
- const customPreview = this.object.customPreview();
60
- if (!customPreview || !this.headerJsonML) {
61
- return;
74
+ override performUpdate(): void {
75
+ this.view({
76
+ object: this.#object,
77
+ headerJsonML: this.headerJsonML,
78
+ expanded: this.expanded,
79
+ cachedContent: this.cachedContent,
80
+ toggleExpanded: this.toggleExpanded,
81
+ },
82
+ undefined, this.contentElement);
83
+ }
84
+
85
+ private toggleExpanded = (): void => {
86
+ if (this.cachedContent !== undefined) {
87
+ this.toggleExpand();
88
+ } else {
89
+ void this.loadBody();
62
90
  }
91
+ };
63
92
 
64
- const headerTemplate = this.renderJSONMLTag(this.headerJsonML);
65
- if (customPreview.bodyGetterId) {
66
- let bodyContent: LitTemplate|Node|undefined;
67
- if (this.cachedContent instanceof ObjectTree) {
68
- bodyContent = html`<devtools-widget class="custom-expandable-section-default-body" ${
69
- widget(ObjectPropertiesSectionWidget, {
70
- objectTree: this.cachedContent,
71
- showOverflow: false,
72
- })}></devtools-widget>`;
73
- } else if (this.cachedContent !== undefined) {
74
- bodyContent = this.renderJSONMLTag(this.cachedContent);
75
- }
93
+ private toggleExpand(): void {
94
+ this.expanded = !this.expanded;
95
+ this.performUpdate();
96
+ }
76
97
 
77
- // eslint-disable-next-line @devtools/no-lit-render-outside-of-view
78
- render(
79
- html`
80
- <span class=${
81
- Directives.classMap({'custom-expandable-section-header': true,
82
- expanded: this.expanded})} @click=${(event: Event) => this.onClick(event)}>
83
- <devtools-icon name=${
84
- this.expanded ? 'triangle-down' : 'triangle-right'} class="custom-expand-icon"></devtools-icon>
85
- ${headerTemplate}
86
- </span>
87
- ${
88
- bodyContent ?
89
- html`<span class="custom-expandable-section-body" ?hidden=${!this.expanded}>${bodyContent}</span>` :
90
- nothing}
91
- `,
92
- this.sectionElement);
98
+ async loadBody(): Promise<void> {
99
+ const customPreview = this.#object?.customPreview();
100
+ if (!this.#object || !customPreview?.bodyGetterId) {
101
+ return;
102
+ }
103
+
104
+ const bodyJsonML =
105
+ await this.#object.callFunctionJSON(bodyGetter => bodyGetter(), [{objectId: customPreview.bodyGetterId}]);
106
+ if (bodyJsonML === null) {
107
+ // Per https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html#custom-formatter-structure
108
+ // we are supposed to fall back to the default format when the `body()` callback returns `null`.
109
+ const objectTree = new ObjectTree(this.#object, {
110
+ readOnly: true,
111
+ propertiesMode: ObjectPropertiesMode.OWN_AND_INTERNAL_AND_INHERITED,
112
+ });
113
+ objectTree.expanded = true;
114
+ this.cachedContent = objectTree;
93
115
  } else {
94
- // eslint-disable-next-line @devtools/no-lit-render-outside-of-view
95
- render(html`${headerTemplate}`, this.sectionElement);
116
+ this.cachedContent = bodyJsonML;
96
117
  }
97
- }
98
118
 
99
- element(): Element {
100
- return this.sectionElement;
119
+ this.expanded = true;
120
+ this.performUpdate();
101
121
  }
122
+ }
123
+
124
+ const ALLOWED_TAGS = ['span', 'div', 'ol', 'li', 'table', 'tr', 'td'];
125
+
126
+ export interface ViewInput {
127
+ object?: SDK.RemoteObject.RemoteObject;
128
+ headerJsonML?: unknown;
129
+ expanded: boolean;
130
+ cachedContent?: unknown|ObjectTree|null;
131
+ toggleExpanded: () => void;
132
+ }
102
133
 
103
- private renderJSONMLTag(jsonML: unknown): LitTemplate {
134
+ export const DEFAULT_VIEW = (input: ViewInput, _output: undefined, target: HTMLElement): void => {
135
+ const renderJSONMLTag = (object: SDK.RemoteObject.RemoteObject, jsonML: unknown): LitTemplate => {
104
136
  if (!Array.isArray(jsonML)) {
105
137
  return html`${String(jsonML)}`;
106
138
  }
107
139
 
108
140
  if (jsonML[0] !== 'object') {
109
- return this.renderElement(jsonML);
141
+ return renderElement(object, jsonML);
110
142
  }
111
143
  if (jsonML.length !== 2) {
112
144
  Common.Console.Console.instance().error('Broken formatter: object reference must contain exactly two elements');
113
145
  return html`<span></span>`;
114
146
  }
115
- return this.layoutObjectTag(jsonML);
116
- }
147
+ return layoutObjectTag(object, jsonML);
148
+ };
117
149
 
118
150
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
119
- private renderElement(object: any[]): LitTemplate {
120
- const it = object[Symbol.iterator]();
151
+ const renderElement = (object: SDK.RemoteObject.RemoteObject, jsonML: any[]): LitTemplate => {
152
+ const it = jsonML[Symbol.iterator]();
121
153
  const tagName = it.next().value as string;
122
154
  if (!ALLOWED_TAGS.includes(tagName)) {
123
155
  Common.Console.Console.instance().error('Broken formatter: element ' + tagName + ' is not allowed!');
@@ -145,7 +177,7 @@ export class CustomPreviewSection {
145
177
 
146
178
  const children: LitTemplate[] = [];
147
179
  while (!next.done) {
148
- children.push(this.renderJSONMLTag(next.value));
180
+ children.push(renderJSONMLTag(object, next.value));
149
181
  next = it.next();
150
182
  }
151
183
  const style = Directives.styleMap(stylePropertyMap);
@@ -168,65 +200,65 @@ export class CustomPreviewSection {
168
200
  default:
169
201
  return html`<span>${children}</span>`;
170
202
  }
171
- }
203
+ };
172
204
 
173
- private layoutObjectTag(objectTag: unknown[]): LitTemplate {
205
+ const layoutObjectTag = (object: SDK.RemoteObject.RemoteObject, objectTag: unknown[]): LitTemplate => {
174
206
  const it = objectTag[Symbol.iterator]();
175
207
  it.next(); // skip 'object'
176
208
  const attributes = it.next().value;
177
- const remoteObject = this.object.runtimeModel().createRemoteObject((attributes as Protocol.Runtime.RemoteObject));
209
+ const remoteObject = object.runtimeModel().createRemoteObject((attributes as Protocol.Runtime.RemoteObject));
178
210
  if (remoteObject.customPreview()) {
179
- return html`${(new CustomPreviewSection(remoteObject)).element()}`;
211
+ return html`${UI.Widget.widget(CustomPreviewSection, {object: remoteObject})}`;
180
212
  }
181
213
 
182
214
  return defaultObjectPresentation(remoteObject, undefined, undefined, undefined,
183
215
  {'custom-expandable-section-standard-section': remoteObject.hasChildren});
184
- }
216
+ };
185
217
 
186
- private onClick(event: Event): void {
218
+ const onClick = (event: Event): void => {
187
219
  event.consume(true);
188
- if (this.cachedContent !== undefined) {
189
- this.toggleExpand();
190
- } else {
191
- void this.loadBody();
192
- }
193
- }
220
+ input.toggleExpanded();
221
+ };
194
222
 
195
- private toggleExpand(): void {
196
- this.expanded = !this.expanded;
197
- this.render();
223
+ const object = input.object;
224
+ const customPreview = object?.customPreview();
225
+ if (!object || !customPreview || !input.headerJsonML) {
226
+ render(nothing, target);
227
+ return;
198
228
  }
199
229
 
200
- async loadBody(): Promise<void> {
201
- const customPreview = this.object.customPreview();
202
-
203
- if (!customPreview) {
204
- return;
230
+ const headerTemplate = renderJSONMLTag(object, input.headerJsonML);
231
+ if (customPreview.bodyGetterId) {
232
+ let bodyContent: LitTemplate|Node|undefined;
233
+ if (input.cachedContent instanceof ObjectTree) {
234
+ bodyContent = html`<devtools-widget class="custom-expandable-section-default-body" ${
235
+ UI.Widget.widget(ObjectPropertiesSectionWidget, {
236
+ objectTree: input.cachedContent,
237
+ showOverflow: false,
238
+ })}></devtools-widget>`;
239
+ } else if (input.cachedContent) {
240
+ bodyContent = renderJSONMLTag(object, input.cachedContent);
205
241
  }
206
242
 
207
- if (customPreview.bodyGetterId) {
208
- const bodyJsonML =
209
- await this.object.callFunctionJSON(bodyGetter => bodyGetter(), [{objectId: customPreview.bodyGetterId}]);
210
- if (bodyJsonML === null) {
211
- // Per https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html#custom-formatter-structure
212
- // we are supposed to fall back to the default format when the `body()` callback returns `null`.
213
- const objectTree = new ObjectTree(this.object, {
214
- readOnly: true,
215
- propertiesMode: ObjectPropertiesMode.OWN_AND_INTERNAL_AND_INHERITED,
216
- });
217
- objectTree.expanded = true;
218
- this.cachedContent = objectTree;
219
- } else {
220
- this.cachedContent = bodyJsonML;
221
- }
222
-
223
- this.expanded = true;
224
- this.render();
225
- }
243
+ render(html`
244
+ <span class=${Directives.classMap({'custom-expandable-section-header': true,
245
+ expanded: input.expanded})} @click=${onClick}>
246
+ <devtools-icon name=${
247
+ input.expanded ? 'triangle-down' : 'triangle-right'} class="custom-expand-icon"></devtools-icon>
248
+ ${headerTemplate}
249
+ </span>
250
+ ${
251
+ bodyContent ?
252
+ html`<span class="custom-expandable-section-body" ?hidden=${!input.expanded}>${bodyContent}</span>` :
253
+ nothing}
254
+ `,
255
+ target, {container: {classes: ['custom-expandable-section']}});
256
+ } else {
257
+ render(html`${headerTemplate}`, target, {container: {classes: ['custom-expandable-section']}});
226
258
  }
227
- }
259
+ };
228
260
 
229
- const ALLOWED_TAGS = ['span', 'div', 'ol', 'li', 'table', 'tr', 'td'];
261
+ export type View = typeof DEFAULT_VIEW;
230
262
 
231
263
  export class CustomPreviewComponent {
232
264
  private readonly object: SDK.RemoteObject.RemoteObject;
@@ -234,27 +266,27 @@ export class CustomPreviewComponent {
234
266
  element: HTMLSpanElement;
235
267
  constructor(object: SDK.RemoteObject.RemoteObject) {
236
268
  this.object = object;
237
- this.customPreviewSection = new CustomPreviewSection(object);
269
+ this.customPreviewSection = new CustomPreviewSection();
270
+ this.customPreviewSection.object = object;
238
271
  this.element = document.createElement('span');
239
272
  this.element.classList.add('source-code');
240
273
  const shadowRoot = UI.UIUtils.createShadowRootWithCoreStyles(this.element, {cssFile: customPreviewComponentStyles});
241
274
  this.element.addEventListener('contextmenu', this.contextMenuEventFired.bind(this), false);
242
- shadowRoot.appendChild(this.customPreviewSection.element());
275
+ this.customPreviewSection.show(shadowRoot, undefined, /* suppressOrphanWidgetError= */ true);
243
276
  }
244
277
 
245
- expandIfPossible(): void {
278
+ async expandIfPossible(): Promise<void> {
246
279
  const customPreview = this.object.customPreview();
247
280
  if (customPreview && customPreview.bodyGetterId && this.customPreviewSection) {
248
- void this.customPreviewSection.loadBody();
281
+ await this.customPreviewSection.loadBody();
249
282
  }
250
283
  }
251
284
 
252
285
  private contextMenuEventFired(event: Event): void {
253
286
  const contextMenu = new UI.ContextMenu.ContextMenu(event);
254
287
  if (this.customPreviewSection) {
255
- contextMenu.revealSection().appendItem(
256
- i18nString(UIStrings.showAsJavascriptObject), this.disassemble.bind(this),
257
- {jslogContext: 'show-as-javascript-object'});
288
+ contextMenu.revealSection().appendItem(i18nString(UIStrings.showAsJavascriptObject), this.disassemble.bind(this),
289
+ {jslogContext: 'show-as-javascript-object'});
258
290
  }
259
291
  contextMenu.appendApplicableItems(this.object);
260
292
  void contextMenu.show();
@@ -262,8 +294,11 @@ export class CustomPreviewComponent {
262
294
 
263
295
  private disassemble(): void {
264
296
  if (this.element.shadowRoot) {
297
+ if (this.customPreviewSection) {
298
+ this.customPreviewSection.detach();
299
+ this.customPreviewSection = null;
300
+ }
265
301
  this.element.shadowRoot.textContent = '';
266
- this.customPreviewSection = null;
267
302
  // eslint-disable-next-line @devtools/no-lit-render-outside-of-view
268
303
  render(defaultObjectPresentation(this.object), this.element.shadowRoot);
269
304
  }
@@ -58,7 +58,7 @@ export class ObjectPopoverHelper {
58
58
 
59
59
  if (result.customPreview()) {
60
60
  const customPreviewComponent = new CustomPreviewComponent(result);
61
- customPreviewComponent.expandIfPossible();
61
+ void customPreviewComponent.expandIfPossible();
62
62
  popoverContentElement = customPreviewComponent.element;
63
63
  } else {
64
64
  popoverContentElement = document.createElement('div');
@@ -1301,7 +1301,7 @@ export function populateObjectTreeContextMenu(
1301
1301
  {checked: object.includeNullOrUndefinedValues, jslogContext: 'show-all'});
1302
1302
  }
1303
1303
 
1304
- interface ObjectTreeViewInput {
1304
+ export interface ObjectTreeViewInput {
1305
1305
  renderAsSubtree: boolean;
1306
1306
  objectTree?: ObjectTree;
1307
1307
  linkifier?: Components.Linkifier.Linkifier;
@@ -1309,7 +1309,7 @@ interface ObjectTreeViewInput {
1309
1309
  skipProto: boolean;
1310
1310
  onExpand: (expanded: boolean) => void;
1311
1311
  }
1312
- type ObjectTreeView = (input: ObjectTreeViewInput, output: object, target: HTMLElement) => void;
1312
+ export type ObjectTreeView = (input: ObjectTreeViewInput, output: object, target: HTMLElement) => void;
1313
1313
  export const OBJECT_TREE_DEFAULT_VIEW: ObjectTreeView = (input, output, target) => {
1314
1314
  const objectTree = input.objectTree;
1315
1315
  if (!objectTree) {
@@ -1351,7 +1351,7 @@ export class ObjectTreeWidget extends UI.Widget.Widget {
1351
1351
  #skipProto = false;
1352
1352
  readonly #view: ObjectTreeView;
1353
1353
 
1354
- constructor(element?: HTMLElement, view = OBJECT_TREE_DEFAULT_VIEW) {
1354
+ constructor(element?: HTMLElement, view: ObjectTreeView = OBJECT_TREE_DEFAULT_VIEW) {
1355
1355
  super(element);
1356
1356
  this.#view = view;
1357
1357
  }
@@ -1676,12 +1676,12 @@ export interface ObjectPropertyViewInput {
1676
1676
  node: ObjectTreeNode;
1677
1677
  search?: UI.TreeOutline.TreeSearch<ObjectTreeNodeBase>;
1678
1678
  }
1679
- interface ObjectPropertyViewOutput {
1679
+ export interface ObjectPropertyViewOutput {
1680
1680
  valueElement: Element|undefined;
1681
1681
  nameElement: Element|undefined;
1682
1682
  }
1683
- type ObjectPropertyView = (input: ObjectPropertyViewInput, output: ObjectPropertyViewOutput, target: HTMLElement) =>
1684
- void;
1683
+ export type ObjectPropertyView =
1684
+ (input: ObjectPropertyViewInput, output: ObjectPropertyViewOutput, target: HTMLElement) => void;
1685
1685
  export const OBJECT_PROPERTY_DEFAULT_VIEW: ObjectPropertyView = (input, output, target) => {
1686
1686
  const {property} = input.node;
1687
1687
  const isInternalEntries = property.synthetic && input.node.name === '[[Entries]]';
@@ -1807,7 +1807,7 @@ export class ObjectPropertyWidget extends UI.Widget.Widget {
1807
1807
  #editable = false;
1808
1808
  #search?: UI.TreeOutline.TreeSearch<ObjectTreeNodeBase>;
1809
1809
 
1810
- constructor(target?: HTMLElement, view = OBJECT_PROPERTY_DEFAULT_VIEW) {
1810
+ constructor(target?: HTMLElement, view: ObjectPropertyView = OBJECT_PROPERTY_DEFAULT_VIEW) {
1811
1811
  super(target);
1812
1812
  this.#view = view;
1813
1813
  }
@@ -2522,7 +2522,7 @@ export class ArrayGroupingTreeElement extends UI.TreeOutline.TreeElement {
2522
2522
  static sparseIterationThreshold = 250000;
2523
2523
  }
2524
2524
 
2525
- interface ExpandableTextViewInput {
2525
+ export interface ExpandableTextViewInput {
2526
2526
  copyText: () => void;
2527
2527
  expandText: () => void;
2528
2528
  expanded: boolean;
@@ -2530,7 +2530,7 @@ interface ExpandableTextViewInput {
2530
2530
  byteCount: number;
2531
2531
  text: string;
2532
2532
  }
2533
- type ExpandableTextView = (input: ExpandableTextViewInput, output: object, target: HTMLElement) => void;
2533
+ export type ExpandableTextView = (input: ExpandableTextViewInput, output: object, target: HTMLElement) => void;
2534
2534
  export const EXPANDABLE_TEXT_DEFAULT_VIEW: ExpandableTextView = (input, output, target) => {
2535
2535
  const totalBytesText = i18n.ByteUtilities.bytesToString(input.byteCount);
2536
2536
  const canExpand = input.text.length < ExpandableTextPropertyValue.MAX_DISPLAYABLE_TEXT_LENGTH;
@@ -2588,7 +2588,7 @@ export class ExpandableTextPropertyValue extends UI.Widget.Widget {
2588
2588
  #maxLength = ExpandableTextPropertyValue.EXPANDABLE_MAX_LENGTH;
2589
2589
  readonly #view: ExpandableTextView;
2590
2590
 
2591
- constructor(target?: HTMLElement, view = EXPANDABLE_TEXT_DEFAULT_VIEW) {
2591
+ constructor(target?: HTMLElement, view: ExpandableTextView = EXPANDABLE_TEXT_DEFAULT_VIEW) {
2592
2592
  super(target);
2593
2593
  this.#view = view;
2594
2594
  }
@@ -4,10 +4,16 @@
4
4
  * found in the LICENSE file.
5
5
  */
6
6
 
7
+ :host {
8
+ display: block;
9
+ }
10
+
7
11
  .root {
8
12
  align-items: flex-start; /* keep chart at top so it doesnt change position as the legend changes height */
13
+ gap: var(--sys-size-6) 30px;
9
14
  display: flex;
10
- min-width: fit-content;
15
+ flex-wrap: wrap;
16
+ justify-content: flex-start;
11
17
  white-space: nowrap;
12
18
  }
13
19
 
@@ -48,10 +54,6 @@
48
54
  stroke-linejoin: round;
49
55
  }
50
56
 
51
- .pie-chart-legend {
52
- margin-left: 30px;
53
- }
54
-
55
57
  .pie-chart-legend-row {
56
58
  margin: 5px var(--sys-size-2) 5px auto;
57
59
  padding-right: 25px;