chrome-devtools-frontend 1.0.1616061 → 1.0.1621064

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 (318) hide show
  1. package/AUTHORS +1 -0
  2. package/docs/checklist/README.md +8 -7
  3. package/eslint.config.mjs +7 -0
  4. package/front_end/core/common/Object.ts +11 -2
  5. package/front_end/core/dom_extension/DOMExtension.ts +11 -8
  6. package/front_end/core/host/AidaClient.ts +8 -0
  7. package/front_end/core/host/AidaGcaTranslation.ts +1 -0
  8. package/front_end/core/host/UserMetrics.ts +0 -1
  9. package/front_end/core/platform/api/HostRuntime.ts +2 -2
  10. package/front_end/core/platform/browser/HostRuntime.ts +4 -2
  11. package/front_end/core/platform/node/HostRuntime.ts +2 -2
  12. package/front_end/core/root/ExperimentNames.ts +0 -1
  13. package/front_end/core/sdk/NetworkManager.ts +30 -4
  14. package/front_end/core/sdk/NetworkRequest.ts +2 -10
  15. package/front_end/core/sdk/Resource.ts +2 -1
  16. package/front_end/core/sdk/ServerSentEventsProtocol.ts +1 -1
  17. package/front_end/core/sdk/TraceObject.ts +7 -2
  18. package/front_end/entrypoint_template.html +1 -2
  19. package/front_end/entrypoints/greendev_floaty/FloatyEntrypoint.ts +119 -15
  20. package/front_end/entrypoints/greendev_floaty/greendev_floaty.ts +0 -2
  21. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +43 -33
  22. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotLoader.ts +2 -1
  23. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotWorkerDispatcher.ts +9 -6
  24. package/front_end/entrypoints/main/MainImpl.ts +0 -2
  25. package/front_end/generated/InspectorBackendCommands.ts +8 -7
  26. package/front_end/generated/SupportedCSSProperties.js +119 -100
  27. package/front_end/generated/protocol-mapping.d.ts +1 -9
  28. package/front_end/generated/protocol-proxy-api.d.ts +1 -9
  29. package/front_end/generated/protocol.ts +24 -1
  30. package/front_end/legacy/legacy-defs.d.ts +1 -1
  31. package/front_end/models/ai_assistance/AiConversation.ts +1 -0
  32. package/front_end/models/ai_assistance/AiHistoryStorage.ts +39 -0
  33. package/front_end/models/ai_assistance/agents/AiAgent.ts +2 -0
  34. package/front_end/models/ai_assistance/agents/ConversationSummaryAgent.ts +28 -16
  35. package/front_end/models/ai_assistance/agents/GreenDevAgent.ts +512 -0
  36. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +112 -145
  37. package/front_end/models/ai_assistance/agents/README.md +0 -5
  38. package/front_end/models/ai_assistance/agents/StylingAgent.ts +9 -16
  39. package/front_end/models/ai_assistance/ai_assistance.ts +2 -0
  40. package/front_end/models/ai_code_completion/AiCodeCompletion.ts +19 -1
  41. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +48 -13
  42. package/front_end/models/bindings/SymbolizedError.ts +95 -8
  43. package/front_end/models/emulation/DeviceModeModel.ts +42 -13
  44. package/front_end/models/emulation/EmulatedDevices.ts +1 -1
  45. package/front_end/models/issues_manager/IssuesManager.ts +13 -6
  46. package/front_end/models/issues_manager/IssuesManagerEvents.ts +1 -0
  47. package/front_end/models/javascript_metadata/NativeFunctions.js +2 -2
  48. package/front_end/models/live-metrics/web-vitals-injected/web-vitals-injected.ts +1 -0
  49. package/front_end/models/stack_trace/DetailedErrorStackParser.ts +49 -10
  50. package/front_end/models/stack_trace/ErrorStackParser.ts +18 -0
  51. package/front_end/models/stack_trace/StackTraceModel.ts +5 -1
  52. package/front_end/models/text_utils/ContentData.ts +71 -10
  53. package/front_end/models/trace/types/File.ts +8 -1
  54. package/front_end/models/web_mcp/WebMCPModel.ts +22 -0
  55. package/front_end/models/workspace/UISourceCode.ts +4 -4
  56. package/front_end/panels/accessibility/ARIAAttributesView.ts +4 -4
  57. package/front_end/panels/accessibility/AccessibilitySubPane.ts +3 -2
  58. package/front_end/panels/accessibility/SourceOrderView.ts +4 -4
  59. package/front_end/panels/ai_assistance/ai_assistance.ts +1 -0
  60. package/front_end/panels/ai_assistance/components/ChatInput.ts +66 -0
  61. package/front_end/panels/ai_assistance/components/ChatMessage.ts +144 -21
  62. package/front_end/panels/ai_assistance/components/ChatView.ts +43 -8
  63. package/front_end/panels/ai_assistance/components/ExportForAgentsDialog.ts +1 -0
  64. package/front_end/panels/ai_assistance/components/WalkthroughUtils.ts +74 -0
  65. package/front_end/panels/ai_assistance/components/WalkthroughView.ts +34 -5
  66. package/front_end/panels/ai_assistance/components/chatMessage.css +11 -0
  67. package/front_end/panels/ai_assistance/components/walkthroughView.css +7 -0
  68. package/front_end/panels/application/ApplicationPanelTreeElement.ts +1 -1
  69. package/front_end/panels/application/CookieItemsView.ts +8 -9
  70. package/front_end/panels/application/DOMStorageItemsView.ts +3 -3
  71. package/front_end/panels/application/DeviceBoundSessionsModel.ts +7 -0
  72. package/front_end/panels/application/DeviceBoundSessionsTreeElement.ts +21 -0
  73. package/front_end/panels/application/DeviceBoundSessionsView.ts +2 -2
  74. package/front_end/panels/application/ExtensionStorageItemsView.ts +1 -1
  75. package/front_end/panels/application/KeyValueStorageItemsView.ts +32 -14
  76. package/front_end/panels/application/ResourcesPanel.ts +5 -5
  77. package/front_end/panels/application/StorageItemsToolbar.ts +0 -19
  78. package/front_end/panels/application/WebMCPView.ts +285 -86
  79. package/front_end/panels/application/components/BounceTrackingMitigationsView.ts +4 -4
  80. package/front_end/panels/application/preloading/components/MismatchedPreloadingGrid.ts +4 -4
  81. package/front_end/panels/application/webMCPView.css +261 -182
  82. package/front_end/panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts +9 -5
  83. package/front_end/panels/changes/ChangesSidebar.ts +2 -2
  84. package/front_end/panels/changes/ChangesView.ts +9 -14
  85. package/front_end/panels/console/ConsolePanel.ts +10 -3
  86. package/front_end/panels/console/ConsoleSidebar.ts +5 -5
  87. package/front_end/panels/console/ConsoleView.ts +11 -4
  88. package/front_end/panels/console/ConsoleViewMessage.ts +1 -19
  89. package/front_end/panels/coverage/CoverageView.ts +4 -5
  90. package/front_end/panels/elements/ElementsPanel.ts +9 -12
  91. package/front_end/panels/elements/ElementsSidebarPane.ts +4 -5
  92. package/front_end/panels/elements/ElementsTreeElement.ts +61 -0
  93. package/front_end/panels/elements/ElementsTreeOutline.ts +46 -0
  94. package/front_end/panels/elements/LayersWidget.ts +2 -2
  95. package/front_end/panels/elements/MetricsSidebarPane.ts +5 -4
  96. package/front_end/panels/elements/StylePropertiesSection.ts +1 -1
  97. package/front_end/panels/elements/StylePropertyTreeElement.ts +11 -6
  98. package/front_end/panels/elements/StylesSidebarPane.ts +4 -1
  99. package/front_end/panels/elements/components/ElementsBreadcrumbs.ts +19 -20
  100. package/front_end/panels/elements/components/ElementsBreadcrumbsUtils.ts +29 -29
  101. package/front_end/panels/elements/components/QueryContainer.ts +5 -6
  102. package/front_end/panels/elements/components/components.ts +0 -2
  103. package/front_end/panels/emulation/MediaQueryInspector.ts +4 -7
  104. package/front_end/panels/layer_viewer/LayerDetailsView.ts +4 -7
  105. package/front_end/panels/layer_viewer/Layers3DView.ts +2 -2
  106. package/front_end/panels/lighthouse/LighthouseStartView.ts +2 -2
  107. package/front_end/panels/mobile_throttling/NetworkThrottlingSelector.ts +47 -66
  108. package/front_end/panels/network/NetworkConfigView.ts +11 -11
  109. package/front_end/panels/network/RequestConditionsDrawer.ts +6 -4
  110. package/front_end/panels/network/RequestCookiesView.ts +2 -2
  111. package/front_end/panels/network/RequestDeviceBoundSessionsView.ts +2 -2
  112. package/front_end/panels/network/RequestHeadersView.ts +2 -2
  113. package/front_end/panels/network/components/DirectSocketConnectionView.ts +4 -5
  114. package/front_end/panels/performance_monitor/PerformanceMonitor.ts +6 -9
  115. package/front_end/panels/profiler/HeapProfileView.ts +29 -4
  116. package/front_end/panels/profiler/ProfilesPanel.ts +1 -1
  117. package/front_end/panels/protocol_monitor/JSONEditor.css +8 -1
  118. package/front_end/panels/protocol_monitor/JSONEditor.ts +7 -2
  119. package/front_end/panels/protocol_monitor/ProtocolMonitor.ts +6 -4
  120. package/front_end/panels/recorder/components/ControlButton.ts +4 -4
  121. package/front_end/panels/recorder/components/StepView.ts +6 -6
  122. package/front_end/panels/search/SearchView.ts +4 -7
  123. package/front_end/panels/sources/DebuggerPausedMessage.ts +18 -22
  124. package/front_end/panels/sources/SourcesView.ts +1 -1
  125. package/front_end/panels/sources/TabbedEditorContainer.ts +2 -2
  126. package/front_end/panels/sources/ThreadsSidebarPane.ts +2 -4
  127. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +24 -20
  128. package/front_end/panels/timeline/StatusDialog.ts +5 -8
  129. package/front_end/panels/timeline/ThirdPartyTreeView.ts +10 -0
  130. package/front_end/panels/timeline/TimelineLoader.ts +3 -4
  131. package/front_end/panels/timeline/TimelineSelectorStatsView.ts +2 -2
  132. package/front_end/panels/timeline/components/TimelineRangeSummaryView.ts +2 -0
  133. package/front_end/panels/timeline/components/TimelineSummary.ts +9 -1
  134. package/front_end/panels/timeline/components/timelineSummary.css +4 -0
  135. package/front_end/panels/timeline/overlays/components/TimespanBreakdownOverlay.ts +2 -2
  136. package/front_end/panels/timeline/thirdPartyTreeView.css +8 -1
  137. package/front_end/panels/web_audio/WebAudioView.ts +5 -4
  138. package/front_end/panels/whats_new/ReleaseNoteText.ts +9 -9
  139. package/front_end/panels/whats_new/resources/WNDT.md +9 -6
  140. package/front_end/third_party/chromium/README.chromium +1 -1
  141. package/front_end/third_party/puppeteer/README.chromium +2 -2
  142. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/ElementHandle.d.ts +41 -2
  143. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/ElementHandle.d.ts.map +1 -1
  144. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/ElementHandle.js.map +1 -1
  145. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Extension.d.ts +13 -1
  146. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Extension.d.ts.map +1 -1
  147. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Extension.js +21 -1
  148. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Extension.js.map +1 -1
  149. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/ElementHandle.d.ts.map +1 -1
  150. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/ElementHandle.js +1 -0
  151. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/ElementHandle.js.map +1 -1
  152. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.d.ts +2 -2
  153. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.d.ts.map +1 -1
  154. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.js +5 -5
  155. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.js.map +1 -1
  156. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserConnector.d.ts.map +1 -1
  157. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserConnector.js +2 -2
  158. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserConnector.js.map +1 -1
  159. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/ElementHandle.d.ts.map +1 -1
  160. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/ElementHandle.js +1 -0
  161. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/ElementHandle.js.map +1 -1
  162. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Extension.d.ts +1 -1
  163. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Extension.d.ts.map +1 -1
  164. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Extension.js +2 -2
  165. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Extension.js.map +1 -1
  166. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.d.ts +1 -1
  167. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.d.ts.map +1 -1
  168. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.js +52 -1
  169. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.js.map +1 -1
  170. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/WebMCP.d.ts.map +1 -1
  171. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/WebMCP.js.map +1 -1
  172. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/ConnectOptions.d.ts +25 -0
  173. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/ConnectOptions.d.ts.map +1 -1
  174. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
  175. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
  176. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserLauncher.js +2 -2
  177. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserLauncher.js.map +1 -1
  178. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
  179. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.js +0 -1
  180. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.js.map +1 -1
  181. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +2 -2
  182. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +2 -2
  183. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
  184. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
  185. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
  186. package/front_end/third_party/puppeteer/package/lib/cjs/third_party/urlpattern-polyfill/urlpattern-polyfill.d.ts +1 -0
  187. package/front_end/third_party/puppeteer/package/lib/cjs/third_party/urlpattern-polyfill/urlpattern-polyfill.js +853 -0
  188. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.d.ts +91 -11
  189. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +1046 -33
  190. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/ElementHandle.d.ts +41 -2
  191. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/ElementHandle.d.ts.map +1 -1
  192. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/ElementHandle.js.map +1 -1
  193. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Extension.d.ts +13 -1
  194. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Extension.d.ts.map +1 -1
  195. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Extension.js +21 -1
  196. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Extension.js.map +1 -1
  197. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/ElementHandle.d.ts.map +1 -1
  198. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/ElementHandle.js +1 -0
  199. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/ElementHandle.js.map +1 -1
  200. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.d.ts +2 -2
  201. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.d.ts.map +1 -1
  202. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.js +5 -5
  203. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.js.map +1 -1
  204. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserConnector.d.ts.map +1 -1
  205. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserConnector.js +2 -2
  206. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserConnector.js.map +1 -1
  207. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/ElementHandle.d.ts.map +1 -1
  208. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/ElementHandle.js +1 -0
  209. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/ElementHandle.js.map +1 -1
  210. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Extension.d.ts +1 -1
  211. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Extension.d.ts.map +1 -1
  212. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Extension.js +2 -2
  213. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Extension.js.map +1 -1
  214. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.d.ts +1 -1
  215. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.d.ts.map +1 -1
  216. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.js +52 -1
  217. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.js.map +1 -1
  218. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/WebMCP.d.ts.map +1 -1
  219. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/WebMCP.js.map +1 -1
  220. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/ConnectOptions.d.ts +25 -0
  221. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/ConnectOptions.d.ts.map +1 -1
  222. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/injected/injected.d.ts +1 -1
  223. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
  224. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserLauncher.js +2 -2
  225. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserLauncher.js.map +1 -1
  226. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
  227. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.js +0 -1
  228. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.js.map +1 -1
  229. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +2 -2
  230. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +2 -2
  231. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/Mutex.d.ts +2 -2
  232. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
  233. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
  234. package/front_end/third_party/puppeteer/package/lib/esm/third_party/urlpattern-polyfill/urlpattern-polyfill.d.ts +1 -0
  235. package/front_end/third_party/puppeteer/package/lib/esm/third_party/urlpattern-polyfill/urlpattern-polyfill.js +805 -0
  236. package/front_end/third_party/puppeteer/package/lib/types.d.ts +91 -11
  237. package/front_end/third_party/puppeteer/package/package.json +3 -2
  238. package/front_end/third_party/puppeteer/package/src/api/ElementHandle.ts +53 -11
  239. package/front_end/third_party/puppeteer/package/src/api/Extension.ts +29 -1
  240. package/front_end/third_party/puppeteer/package/src/bidi/ElementHandle.ts +1 -0
  241. package/front_end/third_party/puppeteer/package/src/cdp/Browser.ts +6 -0
  242. package/front_end/third_party/puppeteer/package/src/cdp/BrowserConnector.ts +2 -0
  243. package/front_end/third_party/puppeteer/package/src/cdp/ElementHandle.ts +1 -0
  244. package/front_end/third_party/puppeteer/package/src/cdp/Extension.ts +9 -2
  245. package/front_end/third_party/puppeteer/package/src/cdp/TargetManager.ts +59 -0
  246. package/front_end/third_party/puppeteer/package/src/cdp/WebMCP.ts +6 -1
  247. package/front_end/third_party/puppeteer/package/src/common/ConnectOptions.ts +26 -0
  248. package/front_end/third_party/puppeteer/package/src/node/BrowserLauncher.ts +2 -0
  249. package/front_end/third_party/puppeteer/package/src/node/ChromeLauncher.ts +0 -1
  250. package/front_end/third_party/puppeteer/package/src/revisions.ts +2 -2
  251. package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
  252. package/front_end/third_party/puppeteer/puppeteer-tsconfig.json +2 -1
  253. package/front_end/third_party/web-vitals/README.chromium +2 -2
  254. package/front_end/third_party/web-vitals/package/README.md +21 -10
  255. package/front_end/third_party/web-vitals/package/dist/modules/attribution/onCLS.js +2 -4
  256. package/front_end/third_party/web-vitals/package/dist/modules/attribution/onFCP.js +1 -2
  257. package/front_end/third_party/web-vitals/package/dist/modules/attribution/onINP.d.ts +4 -0
  258. package/front_end/third_party/web-vitals/package/dist/modules/attribution/onINP.js +44 -39
  259. package/front_end/third_party/web-vitals/package/dist/modules/attribution/onLCP.js +25 -19
  260. package/front_end/third_party/web-vitals/package/dist/modules/attribution/onTTFB.js +1 -2
  261. package/front_end/third_party/web-vitals/package/dist/modules/lib/doubleRAF.js +1 -1
  262. package/front_end/third_party/web-vitals/package/dist/modules/lib/getActivationStart.js +1 -2
  263. package/front_end/third_party/web-vitals/package/dist/modules/lib/getLoadState.js +16 -18
  264. package/front_end/third_party/web-vitals/package/dist/modules/lib/getVisibilityWatcher.js +2 -1
  265. package/front_end/third_party/web-vitals/package/dist/modules/lib/initMetric.d.ts +1 -1
  266. package/front_end/third_party/web-vitals/package/dist/modules/lib/observe.js +1 -1
  267. package/front_end/third_party/web-vitals/package/dist/modules/lib/polyfills/interactionCountPolyfill.d.ts +1 -1
  268. package/front_end/third_party/web-vitals/package/dist/modules/lib/polyfills/interactionCountPolyfill.js +1 -3
  269. package/front_end/third_party/web-vitals/package/dist/modules/lib/whenActivated.js +1 -1
  270. package/front_end/third_party/web-vitals/package/dist/modules/lib/whenIdleOrHidden.js +11 -7
  271. package/front_end/third_party/web-vitals/package/dist/modules/onCLS.js +1 -1
  272. package/front_end/third_party/web-vitals/package/dist/modules/types/inp.d.ts +4 -0
  273. package/front_end/third_party/web-vitals/package/dist/modules/types.d.ts +1 -2
  274. package/front_end/third_party/web-vitals/package/dist/modules/types.js +0 -1
  275. package/front_end/third_party/web-vitals/package/package.json +24 -27
  276. package/front_end/third_party/web-vitals/package/src/attribution/onCLS.ts +2 -7
  277. package/front_end/third_party/web-vitals/package/src/attribution/onFCP.ts +1 -2
  278. package/front_end/third_party/web-vitals/package/src/attribution/onINP.ts +49 -43
  279. package/front_end/third_party/web-vitals/package/src/attribution/onLCP.ts +27 -24
  280. package/front_end/third_party/web-vitals/package/src/attribution/onTTFB.ts +1 -2
  281. package/front_end/third_party/web-vitals/package/src/lib/doubleRAF.ts +1 -1
  282. package/front_end/third_party/web-vitals/package/src/lib/getActivationStart.ts +1 -2
  283. package/front_end/third_party/web-vitals/package/src/lib/getLoadState.ts +21 -20
  284. package/front_end/third_party/web-vitals/package/src/lib/getVisibilityWatcher.ts +2 -3
  285. package/front_end/third_party/web-vitals/package/src/lib/observe.ts +1 -1
  286. package/front_end/third_party/web-vitals/package/src/lib/polyfills/interactionCountPolyfill.ts +2 -4
  287. package/front_end/third_party/web-vitals/package/src/lib/whenActivated.ts +1 -1
  288. package/front_end/third_party/web-vitals/package/src/lib/whenIdleOrHidden.ts +13 -7
  289. package/front_end/third_party/web-vitals/package/src/onCLS.ts +1 -1
  290. package/front_end/third_party/web-vitals/package/src/types/inp.ts +4 -0
  291. package/front_end/third_party/web-vitals/package/src/types.ts +1 -2
  292. package/front_end/third_party/web-vitals/patches/0001-Add-onEachInteraction-to-onINP-options.patch +13 -74
  293. package/front_end/third_party/web-vitals/rebuild.sh +3 -3
  294. package/front_end/third_party/web-vitals/web-vitals-tsconfig.json +0 -1
  295. package/front_end/ui/components/icon_button/iconButton.css +1 -0
  296. package/front_end/ui/components/legacy_wrapper/LegacyWrapper.ts +6 -6
  297. package/front_end/ui/components/lists/list.css +4 -0
  298. package/front_end/ui/legacy/Dialog.ts +21 -2
  299. package/front_end/ui/legacy/SoftContextMenu.ts +3 -3
  300. package/front_end/ui/legacy/SplitWidget.ts +9 -9
  301. package/front_end/ui/legacy/TabbedPane.ts +12 -12
  302. package/front_end/ui/legacy/View.ts +24 -22
  303. package/front_end/ui/legacy/ViewManager.ts +12 -12
  304. package/front_end/ui/legacy/ViewRegistration.ts +2 -2
  305. package/front_end/ui/legacy/Widget.ts +165 -119
  306. package/front_end/ui/legacy/components/source_frame/ImageView.ts +10 -5
  307. package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +9 -6
  308. package/front_end/ui/legacy/components/utils/Linkifier.ts +37 -11
  309. package/front_end/ui/legacy/components/utils/jsUtils.css +1 -0
  310. package/front_end/ui/legacy/inspectorCommon.css +0 -6
  311. package/front_end/ui/lit/render.ts +11 -9
  312. package/front_end/ui/visual_logging/KnownContextValues.ts +36 -0
  313. package/package.json +1 -1
  314. package/front_end/Images/src/dots-circle.svg +0 -10
  315. package/front_end/panels/elements/components/Helper.ts +0 -35
  316. package/front_end/third_party/web-vitals/package/dist/modules/types/polyfills.d.ts +0 -4
  317. package/front_end/third_party/web-vitals/package/dist/modules/types/polyfills.js +0 -16
  318. package/front_end/third_party/web-vitals/package/src/types/polyfills.ts +0 -24
@@ -42,10 +42,10 @@ const {html} = Lit;
42
42
 
43
43
  // Remember the original DOM mutation methods here, since we
44
44
  // will override them below to sanity check the Widget system.
45
- const originalAppendChild = Element.prototype.appendChild;
46
- const originalInsertBefore = Element.prototype.insertBefore;
47
- const originalRemoveChild = Element.prototype.removeChild;
48
- const originalRemoveChildren = Element.prototype.removeChildren;
45
+ const originalAppendChild = Node.prototype.appendChild;
46
+ const originalInsertBefore = Node.prototype.insertBefore;
47
+ const originalRemoveChild = Node.prototype.removeChild;
48
+ const originalRemoveChildren = Node.prototype.removeChildren;
49
49
 
50
50
  function assert(condition: unknown, message: string): void {
51
51
  if (!condition) {
@@ -53,17 +53,19 @@ function assert(condition: unknown, message: string): void {
53
53
  }
54
54
  }
55
55
 
56
- type WidgetConstructor<WidgetT extends Widget> = new (element: HTMLElement) => WidgetT;
57
- type WidgetProducer<WidgetT extends Widget> = (element: HTMLElement) => WidgetT;
58
- type WidgetFactory<WidgetT extends Widget> = WidgetConstructor<WidgetT>|WidgetProducer<WidgetT>;
56
+ export type AnyWidget = Widget<HTMLElement|DocumentFragment>;
57
+
58
+ type WidgetConstructor<WidgetT extends AnyWidget> = new (element: HTMLElement) => WidgetT;
59
+ type WidgetProducer<WidgetT extends AnyWidget> = (element: HTMLElement) => WidgetT;
60
+ type WidgetFactory<WidgetT extends AnyWidget> = WidgetConstructor<WidgetT>|WidgetProducer<WidgetT>;
59
61
  type InferWidgetTFromFactory<F> = F extends WidgetFactory<infer WidgetT>? WidgetT : never;
60
62
 
61
- export class WidgetConfig<WidgetT extends Widget> {
63
+ export class WidgetConfig<WidgetT extends AnyWidget> {
62
64
  constructor(readonly widgetClass: WidgetFactory<WidgetT>, readonly widgetParams?: Partial<WidgetT>) {
63
65
  }
64
66
  }
65
67
 
66
- export function widgetConfig<F extends WidgetFactory<Widget>, ParamKeys extends keyof InferWidgetTFromFactory<F>>(
68
+ export function widgetConfig<F extends WidgetFactory<AnyWidget>, ParamKeys extends keyof InferWidgetTFromFactory<F>>(
67
69
  widgetClass: F, widgetParams?: Pick<InferWidgetTFromFactory<F>, ParamKeys>&Partial<InferWidgetTFromFactory<F>>):
68
70
  // This is a workaround for https://github.com/runem/lit-analyzer/issues/163
69
71
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -71,13 +73,13 @@ export function widgetConfig<F extends WidgetFactory<Widget>, ParamKeys extends
71
73
  return new WidgetConfig(widgetClass, widgetParams);
72
74
  }
73
75
 
74
- let currentUpdateQueue: Map<Widget, PromiseWithResolvers<void>>|null = null;
75
- const currentlyProcessed = new Set<Widget>();
76
- let nextUpdateQueue = new Map<Widget, PromiseWithResolvers<void>>();
76
+ let currentUpdateQueue: Map<AnyWidget, PromiseWithResolvers<void>>|null = null;
77
+ const currentlyProcessed = new Set<AnyWidget>();
78
+ let nextUpdateQueue = new Map<AnyWidget, PromiseWithResolvers<void>>();
77
79
  let pendingAnimationFrame: number|null = null;
78
80
  let overallUpdatePromise: PromiseWithResolvers<void>|null = null;
79
81
 
80
- function enqueueIntoNextUpdateQueue(widget: Widget): Promise<void> {
82
+ function enqueueIntoNextUpdateQueue(widget: AnyWidget): Promise<void> {
81
83
  const scheduledUpdate = nextUpdateQueue.get(widget) ?? Promise.withResolvers<void>();
82
84
  nextUpdateQueue.delete(widget);
83
85
  nextUpdateQueue.set(widget, scheduledUpdate);
@@ -87,7 +89,7 @@ function enqueueIntoNextUpdateQueue(widget: Widget): Promise<void> {
87
89
  return scheduledUpdate.promise;
88
90
  }
89
91
 
90
- function enqueueWidgetUpdate(widget: Widget): Promise<void> {
92
+ function enqueueWidgetUpdate(widget: AnyWidget): Promise<void> {
91
93
  if (currentUpdateQueue) {
92
94
  if (currentlyProcessed.has(widget)) {
93
95
  return enqueueIntoNextUpdateQueue(widget);
@@ -100,7 +102,7 @@ function enqueueWidgetUpdate(widget: Widget): Promise<void> {
100
102
  return enqueueIntoNextUpdateQueue(widget);
101
103
  }
102
104
 
103
- function cancelUpdate(widget: Widget): void {
105
+ function cancelUpdate(widget: AnyWidget): void {
104
106
  widget.cancelUpdateController();
105
107
  if (currentUpdateQueue) {
106
108
  const scheduledUpdate = currentUpdateQueue.get(widget);
@@ -129,14 +131,14 @@ function runNextUpdate(): void {
129
131
  const controller = new AbortController();
130
132
  widget.addUpdateController(controller);
131
133
  await widget.performUpdate(controller.signal);
132
- } catch (e) {
133
- if (e.name !== 'AbortError') {
134
- throw e;
135
- }
136
134
  } finally {
137
135
  resolve();
138
136
  }
139
- })();
137
+ })().catch(e => {
138
+ if (e.name !== 'AbortError') {
139
+ console.error(`${widget.constructor.name}.performUpdate failed: `, e);
140
+ }
141
+ });
140
142
  }
141
143
  currentUpdateQueue.clear();
142
144
  queueMicrotask(() => {
@@ -156,7 +158,7 @@ function runNextUpdate(): void {
156
158
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
157
159
  const widgetConfigs = new WeakMap<HTMLElement, WidgetConfig<any>>();
158
160
 
159
- export function registerWidgetConfig<WidgetT extends Widget>(
161
+ export function registerWidgetConfig<WidgetT extends AnyWidget>(
160
162
  element: HTMLElement, config: WidgetConfig<WidgetT>): void {
161
163
  if (!widgetConfigs.has(element)) {
162
164
  setUpLifecycleTracking(element);
@@ -164,7 +166,8 @@ export function registerWidgetConfig<WidgetT extends Widget>(
164
166
  widgetConfigs.set(element, config);
165
167
  }
166
168
 
167
- function instantiateWidget<WidgetT extends Widget>(element: HTMLElement, widgetConfig: WidgetConfig<WidgetT>): WidgetT {
169
+ function instantiateWidget<WidgetT extends AnyWidget>(
170
+ element: HTMLElement, widgetConfig: WidgetConfig<WidgetT>): WidgetT {
168
171
  if (!widgetConfig.widgetClass) {
169
172
  throw new Error('No widgetClass defined');
170
173
  }
@@ -185,7 +188,7 @@ function instantiateWidget<WidgetT extends Widget>(element: HTMLElement, widgetC
185
188
  return newWidget;
186
189
  }
187
190
 
188
- function setUpLifecycleTracking<WidgetT extends Widget>(element: HTMLElement): void {
191
+ function setUpLifecycleTracking<WidgetT extends AnyWidget>(element: HTMLElement): void {
189
192
  let tracker: WidgetElement<WidgetT>;
190
193
  if (element instanceof WidgetElement) {
191
194
  tracker = element as WidgetElement<WidgetT>;
@@ -209,17 +212,19 @@ function setUpLifecycleTracking<WidgetT extends Widget>(element: HTMLElement): v
209
212
  if (!config) {
210
213
  throw new Error('No widgetConfig defined');
211
214
  }
212
- widget = instantiateWidget(element, config);
215
+ widget = instantiateWidget(element, config) as WidgetT;
213
216
  }
214
- const parent = element.parentElementOrShadowHost() as HTMLElement | null;
217
+ const parent =
218
+ (element.parentNode instanceof DocumentFragment) ? element.parentNode : element.parentElementOrShadowHost();
215
219
  if (!parent) {
216
220
  widget.markAsRoot();
221
+ } else {
222
+ widget.show(parent as HTMLElement, undefined, /* suppressOrphanWidgetError= */ true);
217
223
  }
218
- widget.show(parent as HTMLElement, undefined, /* suppressOrphanWidgetError= */ true);
219
224
  };
220
225
  }
221
226
 
222
- export class WidgetElement<WidgetT extends Widget> extends HTMLElement {
227
+ export class WidgetElement<WidgetT extends AnyWidget> extends HTMLElement {
223
228
  onDisconnect?: () => void;
224
229
  onConnect?: () => void;
225
230
  #disconnectTimeout?: ReturnType<typeof setTimeout>;
@@ -342,7 +347,7 @@ export class WidgetDirective extends Lit.Directive.Directive {
342
347
  return this.render(widgetClass, widgetParams);
343
348
  }
344
349
 
345
- render<F extends WidgetFactory<Widget>, ParamKeys extends keyof InferWidgetTFromFactory<F>>(
350
+ render<F extends WidgetFactory<AnyWidget>, ParamKeys extends keyof InferWidgetTFromFactory<F>>(
346
351
  widgetClass: F,
347
352
  widgetParams?: Pick<InferWidgetTFromFactory<F>, ParamKeys>&Partial<InferWidgetTFromFactory<F>>): unknown {
348
353
  if (this.#partType === Lit.Directive.PartType.ELEMENT) {
@@ -360,12 +365,12 @@ export class WidgetDirective extends Lit.Directive.Directive {
360
365
  }
361
366
 
362
367
  export const widget = Lit.Directive.directive(WidgetDirective) as
363
- <F extends WidgetFactory<Widget>, ParamKeys extends keyof InferWidgetTFromFactory<F>>(
368
+ <F extends WidgetFactory<AnyWidget>, ParamKeys extends keyof InferWidgetTFromFactory<F>>(
364
369
  widgetClass: F,
365
370
  widgetParams?: Pick<InferWidgetTFromFactory<F>, ParamKeys>&
366
371
  Partial<InferWidgetTFromFactory<F>>) => Lit.Directive.DirectiveResult<typeof WidgetDirective>;
367
372
 
368
- export function widgetRef<T extends Widget, Args extends unknown[]>(
373
+ export function widgetRef<T extends AnyWidget, Args extends unknown[]>(
369
374
  type: Platform.Constructor.Constructor<T, Args>, callback: (_: T) => void): ReturnType<typeof Lit.Directives.ref> {
370
375
  return Lit.Directives.ref((e?: Element) => {
371
376
  if (!(e instanceof HTMLElement)) {
@@ -380,18 +385,20 @@ export function widgetRef<T extends Widget, Args extends unknown[]>(
380
385
  }
381
386
 
382
387
  const widgetCounterMap = new WeakMap<Node, number>();
383
- const widgetMap = new WeakMap<Node, Widget>();
388
+ const widgetMap = new WeakMap<Node, AnyWidget>();
384
389
 
385
- function incrementWidgetCounter(parentElement: Element, childElement: Element): void {
386
- const count = (widgetCounterMap.get(childElement) || 0) + (widgetMap.get(childElement) ? 1 : 0);
387
- for (let el: Element|null = parentElement; el; el = el.parentElementOrShadowHost()) {
390
+ function incrementWidgetCounter(parentElement: Element|DocumentFragment, childElement: Element): void {
391
+ const count = (widgetCounterMap.get(childElement) || 0) + (Widget.get(childElement) ? 1 : 0);
392
+ for (let el: (Element|DocumentFragment|null) = parentElement; el;
393
+ el = el.parentElementOrShadowHost() as (Element | DocumentFragment | null)) {
388
394
  widgetCounterMap.set(el, (widgetCounterMap.get(el) || 0) + count);
389
395
  }
390
396
  }
391
397
 
392
- function decrementWidgetCounter(parentElement: Element, childElement: Element): void {
393
- const count = (widgetCounterMap.get(childElement) || 0) + (widgetMap.get(childElement) ? 1 : 0);
394
- for (let el: Element|null = parentElement; el; el = el.parentElementOrShadowHost()) {
398
+ function decrementWidgetCounter(parentElement: Element|DocumentFragment, childElement: Element): void {
399
+ const count = (widgetCounterMap.get(childElement) || 0) + (Widget.get(childElement) ? 1 : 0);
400
+ for (let el: (Element|DocumentFragment|null) = parentElement; el;
401
+ el = el.parentElementOrShadowHost() as (Element | DocumentFragment | null)) {
395
402
  const elCounter = widgetCounterMap.get(el);
396
403
  if (elCounter) {
397
404
  widgetCounterMap.set(el, elCounter - count);
@@ -408,18 +415,7 @@ const UPDATE_COMPLETE = Promise.resolve();
408
415
  * Additional options passed to the `Widget` constructor to configure the
409
416
  * behavior of the resulting instance.
410
417
  */
411
- export interface WidgetOptions {
412
- /**
413
- * If you pass `true` here, the `contentElement` of the resulting `Widget`
414
- * will be placed into the shadow DOM of its `element`. If the `element`
415
- * doesn't already have a `shadowRoot`, a new one will be created.
416
- *
417
- * Otherwise, the `contentElement` will be a regular child of the `element`.
418
- *
419
- * Its default value is `false`.
420
- */
421
- useShadowDom?: boolean;
422
-
418
+ export type WidgetOptions<ContentTypeT extends HTMLElement|DocumentFragment = HTMLElement> = {
423
419
  /**
424
420
  * A boolean that, when set to `true`, specifies behavior that mitigates
425
421
  * custom element issues around focusability. When a non-focusable part of
@@ -430,30 +426,51 @@ export interface WidgetOptions {
430
426
  *
431
427
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow
432
428
  */
433
- delegatesFocus?: boolean;
429
+ delegatesFocus?: boolean,
430
+ }&(ContentTypeT extends HTMLElement ? {
431
+ /**
432
+ * If you pass `true` here, the `contentElement` of the resulting `Widget`
433
+ * will be placed into the shadow DOM of its `element`. If the `element`
434
+ * doesn't already have a `shadowRoot`, a new one will be created.
435
+ *
436
+ * Otherwise, the `contentElement` will be a regular child of the `element`.
437
+ *
438
+ * Its default value is `false`.
439
+ */
440
+ useShadowDom?: boolean,
434
441
 
435
442
  /**
436
443
  * The Visual Logging configuration to put onto the `element` of the resulting
437
444
  * `Widget`.
438
445
  */
439
- jslog?: string;
446
+ jslog?: string,
447
+
440
448
  /**
441
449
  * The additional classes to put onto the `element` of the resulting `Widget`.
442
450
  */
443
- classes?: string[];
444
- }
445
- export class Widget {
451
+ classes?: string[],
452
+ } :
453
+ {
454
+ /**
455
+ * If you pass `'pure'`, the `contentElement` will be the shadow root itself.
456
+ */
457
+ useShadowDom: 'pure',
458
+ jslog?: never,
459
+ classes?: never,
460
+ });
461
+
462
+ export class Widget<ContentTypeT extends HTMLElement|DocumentFragment = HTMLElement> {
446
463
  readonly element: HTMLElement;
447
- contentElement: HTMLElement;
464
+ #contentElement: ContentTypeT;
448
465
  #shadowRoot: typeof Element.prototype.shadowRoot;
449
466
  #visible = false;
450
467
  #isRoot = false;
451
468
  #isShowing = false;
452
- readonly #children: Widget[] = [];
469
+ readonly #children: AnyWidget[] = [];
453
470
  #hideOnDetach = false;
454
471
  #notificationDepth = 0;
455
472
  #invalidationsSuspended = 0;
456
- #parentWidget: Widget|null = null;
473
+ #parentWidget: AnyWidget|null = null;
457
474
  #cachedConstraints?: Geometry.Constraints;
458
475
  #constraints?: Geometry.Constraints;
459
476
  #invalidationsRequested?: boolean;
@@ -463,30 +480,25 @@ export class Widget {
463
480
 
464
481
  /**
465
482
  * Constructs a new `Widget` with the given `options`.
466
- *
467
- * @param options optional settings to configure the behavior.
468
483
  */
469
- constructor(options?: WidgetOptions);
484
+ constructor(...args: ContentTypeT extends DocumentFragment?
485
+ [options: WidgetOptions<ContentTypeT>]: [options?: WidgetOptions<ContentTypeT>]);
470
486
 
471
487
  /**
472
488
  * Constructs a new `Widget` with the given `options` and attached to the
473
489
  * given `element`.
474
- *
475
- * If `element` is `undefined`, a new `<div>` element will be created instead
476
- * and the widget will be attached to that.
477
- *
478
- * @param element an (optional) `HTMLElement` to attach the `Widget` to.
479
- * @param options optional settings to configure the behavior.
480
490
  */
481
- constructor(element?: HTMLElement, options?: WidgetOptions);
491
+ constructor(...args: ContentTypeT extends DocumentFragment?
492
+ [element: HTMLElement|undefined, options: WidgetOptions<ContentTypeT>]:
493
+ [element?: HTMLElement, options?: WidgetOptions<ContentTypeT>]);
482
494
 
483
- constructor(elementOrOptions?: HTMLElement|WidgetOptions, options?: WidgetOptions) {
495
+ constructor(elementOrOptions?: HTMLElement|WidgetOptions<ContentTypeT>, options?: WidgetOptions<ContentTypeT>) {
484
496
  if (elementOrOptions instanceof HTMLElement) {
485
497
  this.element = elementOrOptions;
486
498
  } else {
487
499
  this.element = document.createElement('div');
488
500
  if (elementOrOptions !== undefined) {
489
- options = elementOrOptions;
501
+ options = elementOrOptions as WidgetOptions<ContentTypeT>;
490
502
  }
491
503
  }
492
504
  this.#shadowRoot = this.element.shadowRoot;
@@ -496,18 +508,28 @@ export class Widget {
496
508
  this.#shadowRoot = createShadowRootWithCoreStyles(this.element, {
497
509
  delegatesFocus: options?.delegatesFocus,
498
510
  });
499
- this.contentElement = document.createElement('div');
500
- this.#shadowRoot.appendChild(this.contentElement);
511
+ if (options.useShadowDom === 'pure') {
512
+ this.#contentElement = (this.#shadowRoot as unknown as ContentTypeT);
513
+ } else {
514
+ const div = document.createElement('div');
515
+ this.#shadowRoot.appendChild(div);
516
+ this.#contentElement = (div as unknown as ContentTypeT);
517
+ }
501
518
  } else {
502
- this.contentElement = this.element;
519
+ this.#contentElement = (this.element as unknown as ContentTypeT);
520
+ }
521
+ const legacyOptions = options as WidgetOptions<HTMLElement>| undefined;
522
+ if (legacyOptions?.classes) {
523
+ this.element.classList.add(...legacyOptions.classes);
503
524
  }
504
- if (options?.classes) {
505
- this.element.classList.add(...options.classes);
525
+ if (legacyOptions?.jslog) {
526
+ this.element.setAttribute('jslog', legacyOptions.jslog);
506
527
  }
507
- if (options?.jslog) {
508
- this.contentElement.setAttribute('jslog', options.jslog);
528
+ if (this.contentElement instanceof HTMLElement) {
529
+ this.contentElement.classList.add('widget');
530
+ } else if (options?.useShadowDom === 'pure') {
531
+ this.element.classList.add('widget');
509
532
  }
510
- this.contentElement.classList.add('widget');
511
533
  widgetMap.set(this.element, this);
512
534
  }
513
535
 
@@ -519,7 +541,7 @@ export class Widget {
519
541
  * @returns the {@link Widget} that is attached to the `node` or `undefined`.
520
542
  */
521
543
  static get(node: Node): Widget|undefined {
522
- return widgetMap.get(node);
544
+ return widgetMap.get(node) as Widget | undefined;
523
545
  }
524
546
 
525
547
  static get allUpdatesComplete(): Promise<void> {
@@ -537,11 +559,23 @@ export class Widget {
537
559
  if (widget) {
538
560
  return widget;
539
561
  }
540
- let config = widgetConfigs.get(element as WidgetElement<Widget>);
562
+ let config = widgetConfigs.get(element);
541
563
  if (!config) {
542
564
  config = widgetConfig(element => new Widget(element));
543
565
  }
544
- return instantiateWidget(element as WidgetElement<Widget>, config);
566
+ return instantiateWidget(element, config) as Widget;
567
+ }
568
+
569
+ get contentElement(): ContentTypeT {
570
+ return this.#contentElement;
571
+ }
572
+
573
+ protected set contentElement(contentElement: ContentTypeT) {
574
+ this.#contentElement = contentElement;
575
+ }
576
+
577
+ dispatchDOMEvent(event: Event): void {
578
+ this.element.dispatchEvent(event);
545
579
  }
546
580
 
547
581
  markAsRoot(): void {
@@ -550,14 +584,14 @@ export class Widget {
550
584
  }
551
585
 
552
586
  parentWidget(): Widget|null {
553
- return this.#parentWidget;
587
+ return this.#parentWidget as Widget | null;
554
588
  }
555
589
 
556
590
  children(): Widget[] {
557
- return this.#children;
591
+ return this.#children as Widget[];
558
592
  }
559
593
 
560
- childWasDetached(_widget: Widget): void {
594
+ childWasDetached(_widget: AnyWidget): void {
561
595
  }
562
596
 
563
597
  isShowing(): boolean {
@@ -594,7 +628,7 @@ export class Widget {
594
628
  return this.#parentWidget?.isShowing() ?? false;
595
629
  }
596
630
 
597
- protected callOnVisibleChildren(method: (this: Widget) => void): void {
631
+ protected callOnVisibleChildren(method: (this: AnyWidget) => void): void {
598
632
  const copy = this.#children.slice();
599
633
  for (let i = 0; i < copy.length; ++i) {
600
634
  if (copy[i].#parentWidget === this && copy[i].#visible) {
@@ -644,7 +678,7 @@ export class Widget {
644
678
  this.callOnVisibleChildren(this.processOnResize);
645
679
  }
646
680
 
647
- private notify(notification: (this: Widget) => void): void {
681
+ private notify(notification: (this: AnyWidget) => void): void {
648
682
  ++this.#notificationDepth;
649
683
  try {
650
684
  notification.call(this);
@@ -674,12 +708,12 @@ export class Widget {
674
708
  async ownerViewDisposed(): Promise<void> {
675
709
  }
676
710
 
677
- show(parentElement: Element, insertBefore?: Node|null, suppressOrphanWidgetError = false): void {
711
+ show(parentElement: Element|DocumentFragment, insertBefore?: Node|null, suppressOrphanWidgetError = false): void {
678
712
  assert(parentElement, 'Attempt to attach widget with no parent element');
679
713
 
680
714
  if (!this.#isRoot) {
681
715
  // Update widget hierarchy.
682
- let currentParent: Element|null = parentElement;
716
+ let currentParent: (Element|DocumentFragment|null) = parentElement;
683
717
  let currentWidget = undefined;
684
718
  while (!currentWidget) {
685
719
  if (!currentParent) {
@@ -698,7 +732,7 @@ export class Widget {
698
732
  this.#showWidget(parentElement, insertBefore);
699
733
  }
700
734
 
701
- private attach(parentWidget: Widget): void {
735
+ private attach(parentWidget: AnyWidget): void {
702
736
  if (parentWidget === this.#parentWidget) {
703
737
  return;
704
738
  }
@@ -720,10 +754,10 @@ export class Widget {
720
754
  this.#showWidget(this.element.parentElement, this.element.nextSibling);
721
755
  }
722
756
 
723
- #showWidget(parentElement: Element, insertBefore?: Node|null): void {
724
- let currentParent: Element|null = parentElement;
725
- while (currentParent && !widgetMap.get(currentParent)) {
726
- currentParent = currentParent.parentElementOrShadowHost();
757
+ #showWidget(parentElement: Element|DocumentFragment, insertBefore?: Node|null): void {
758
+ let currentParent: (Element|DocumentFragment|null) = parentElement;
759
+ while (currentParent && !Widget.get(currentParent)) {
760
+ currentParent = currentParent.parentElementOrShadowHost() as (Element | DocumentFragment | null);
727
761
  }
728
762
 
729
763
  if (this.#isRoot) {
@@ -735,7 +769,7 @@ export class Widget {
735
769
  }
736
770
 
737
771
  const wasVisible = this.#visible;
738
- if (wasVisible && this.element.parentElement === parentElement) {
772
+ if (wasVisible && this.element.parentNode === parentElement) {
739
773
  return;
740
774
  }
741
775
 
@@ -748,7 +782,7 @@ export class Widget {
748
782
  this.element.classList.remove('hidden');
749
783
 
750
784
  // Reparent
751
- if (this.element.parentElement !== parentElement) {
785
+ if (this.element.parentNode !== parentElement) {
752
786
  if (!this.#externallyManaged) {
753
787
  incrementWidgetCounter(parentElement, this.element);
754
788
  }
@@ -938,9 +972,10 @@ export class Widget {
938
972
 
939
973
  getDefaultFocusedElements(): HTMLElement[] {
940
974
  const autofocusElements = [...this.contentElement.querySelectorAll<HTMLElement>('[autofocus]')];
941
- if (this.contentElement !== this.element) {
942
- if (this.contentElement.hasAttribute('autofocus')) {
943
- autofocusElements.push(this.contentElement);
975
+ const contentElement = (this.contentElement as HTMLElement | DocumentFragment);
976
+ if (contentElement !== this.element) {
977
+ if (contentElement instanceof HTMLElement && contentElement.hasAttribute('autofocus')) {
978
+ autofocusElements.push(contentElement);
944
979
  }
945
980
  if (autofocusElements.length === 0) {
946
981
  autofocusElements.push(...this.element.querySelectorAll<HTMLElement>('[autofocus]'));
@@ -1158,13 +1193,13 @@ const storedScrollPositions = new WeakMap<Element, {
1158
1193
  scrollTop: number,
1159
1194
  }>();
1160
1195
 
1161
- export class VBox extends Widget {
1196
+ export class VBox<ContentTypeT extends HTMLElement|DocumentFragment = HTMLElement> extends Widget<ContentTypeT> {
1162
1197
  /**
1163
1198
  * Constructs a new `VBox` with the given `options`.
1164
1199
  *
1165
1200
  * @param options optional settings to configure the behavior.
1166
1201
  */
1167
- constructor(options?: WidgetOptions);
1202
+ constructor(options?: WidgetOptions<ContentTypeT>);
1168
1203
 
1169
1204
  /**
1170
1205
  * Constructs a new `VBox` with the given `options` and attached to the
@@ -1176,17 +1211,22 @@ export class VBox extends Widget {
1176
1211
  * @param element an (optional) `HTMLElement` to attach the `VBox` to.
1177
1212
  * @param options optional settings to configure the behavior.
1178
1213
  */
1179
- constructor(element?: HTMLElement, options?: WidgetOptions);
1214
+ constructor(element?: HTMLElement, options?: WidgetOptions<ContentTypeT>);
1180
1215
 
1181
- constructor() {
1182
- super(...arguments);
1183
- this.contentElement.classList.add('vbox');
1216
+ constructor(elementOrOptions?: HTMLElement|WidgetOptions<ContentTypeT>, options?: WidgetOptions<ContentTypeT>) {
1217
+ // @ts-expect-error
1218
+ super(elementOrOptions, options);
1219
+ if (this.contentElement instanceof HTMLElement) {
1220
+ this.contentElement.classList.add('vbox');
1221
+ } else {
1222
+ this.element.classList.add('vbox');
1223
+ }
1184
1224
  }
1185
1225
 
1186
1226
  override calculateConstraints(): Geometry.Constraints {
1187
1227
  let constraints: Geometry.Constraints = new Geometry.Constraints();
1188
1228
 
1189
- function updateForChild(this: Widget): void {
1229
+ function updateForChild(this: AnyWidget): void {
1190
1230
  const child = this.constraints();
1191
1231
  constraints = constraints.widthToMax(child);
1192
1232
  constraints = constraints.addHeight(child);
@@ -1197,13 +1237,13 @@ export class VBox extends Widget {
1197
1237
  }
1198
1238
  }
1199
1239
 
1200
- export class HBox extends Widget {
1240
+ export class HBox<ContentTypeT extends HTMLElement|DocumentFragment = HTMLElement> extends Widget<ContentTypeT> {
1201
1241
  /**
1202
1242
  * Constructs a new `HBox` with the given `options`.
1203
1243
  *
1204
1244
  * @param options optional settings to configure the behavior.
1205
1245
  */
1206
- constructor(options?: WidgetOptions);
1246
+ constructor(options?: WidgetOptions<ContentTypeT>);
1207
1247
 
1208
1248
  /**
1209
1249
  * Constructs a new `HBox` with the given `options` and attached to the
@@ -1215,17 +1255,23 @@ export class HBox extends Widget {
1215
1255
  * @param element an (optional) `HTMLElement` to attach the `HBox` to.
1216
1256
  * @param options optional settings to configure the behavior.
1217
1257
  */
1218
- constructor(element?: HTMLElement, options?: WidgetOptions);
1258
+ constructor(element?: HTMLElement, options?: WidgetOptions<ContentTypeT>);
1219
1259
 
1220
- constructor() {
1221
- super(...arguments);
1222
- this.contentElement.classList.add('hbox');
1260
+ constructor(elementOrOptions?: HTMLElement|WidgetOptions<ContentTypeT>, options?: WidgetOptions<ContentTypeT>) {
1261
+ // @ts-expect-error
1262
+ super(elementOrOptions, options);
1263
+ if (this.contentElement instanceof HTMLElement) {
1264
+ this.contentElement.classList.add('hbox');
1265
+ } else {
1266
+ this.element.classList.remove('vbox');
1267
+ this.element.classList.add('hbox');
1268
+ }
1223
1269
  }
1224
1270
 
1225
1271
  override calculateConstraints(): Geometry.Constraints {
1226
1272
  let constraints: Geometry.Constraints = new Geometry.Constraints();
1227
1273
 
1228
- function updateForChild(this: Widget): void {
1274
+ function updateForChild(this: AnyWidget): void {
1229
1275
  const child = this.constraints();
1230
1276
  constraints = constraints.addWidth(child);
1231
1277
  constraints = constraints.heightToMax(child);
@@ -1249,9 +1295,9 @@ export class VBoxWithResizeCallback extends VBox {
1249
1295
  }
1250
1296
 
1251
1297
  export class WidgetFocusRestorer {
1252
- private widget: Widget|null;
1298
+ private widget: AnyWidget|null;
1253
1299
  private previous: HTMLElement|null;
1254
- constructor(widget: Widget) {
1300
+ constructor(widget: AnyWidget) {
1255
1301
  this.widget = widget;
1256
1302
  this.previous = (deepActiveElement(widget.element.ownerDocument) as HTMLElement | null);
1257
1303
  widget.focus();
@@ -1273,28 +1319,28 @@ function domOperationError(funcName: 'appendChild'|'insertBefore'|'removeChild'|
1273
1319
  return new Error(`Attempt to modify widget with native DOM method \`${funcName}\``);
1274
1320
  }
1275
1321
 
1276
- Element.prototype.appendChild = function<T extends Node>(node: T): T {
1277
- if (widgetMap.get(node) && node.parentElement !== this) {
1322
+ Node.prototype.appendChild = function<T extends Node>(node: T): T {
1323
+ if (widgetMap.get(node) && node.parentNode !== this) {
1278
1324
  throw domOperationError('appendChild');
1279
1325
  }
1280
1326
  return originalAppendChild.call(this, node) as T;
1281
1327
  };
1282
1328
 
1283
- Element.prototype.insertBefore = function<T extends Node>(node: T, child: Node|null): T {
1284
- if (widgetMap.get(node) && node.parentElement !== this) {
1329
+ Node.prototype.insertBefore = function<T extends Node>(node: T, child: Node|null): T {
1330
+ if (widgetMap.get(node) && node.parentNode !== this) {
1285
1331
  throw domOperationError('insertBefore');
1286
1332
  }
1287
1333
  return originalInsertBefore.call(this, node, child) as T;
1288
1334
  };
1289
1335
 
1290
- Element.prototype.removeChild = function<T extends Node>(child: T): T {
1336
+ Node.prototype.removeChild = function<T extends Node>(child: T): T {
1291
1337
  if (widgetCounterMap.get(child) || widgetMap.get(child)) {
1292
1338
  throw domOperationError('removeChild');
1293
1339
  }
1294
1340
  return originalRemoveChild.call(this, child) as T;
1295
1341
  };
1296
1342
 
1297
- Element.prototype.removeChildren = function(): void {
1343
+ Node.prototype.removeChildren = function(): void {
1298
1344
  if (widgetCounterMap.get(this)) {
1299
1345
  throw domOperationError('removeChildren');
1300
1346
  }
@@ -102,7 +102,7 @@ export class ImageView extends UI.View.SimpleView {
102
102
  super({
103
103
  title: i18nString(UIStrings.image),
104
104
  viewId: 'image',
105
- jslog: `${VisualLogging.pane('image-view')}}`,
105
+ jslog: `${VisualLogging.pane('image-view')}`,
106
106
  });
107
107
  this.registerRequiredCSS(imageViewStyles);
108
108
  this.element.tabIndex = -1;
@@ -163,7 +163,10 @@ export class ImageView extends UI.View.SimpleView {
163
163
  }
164
164
 
165
165
  this.cachedContent = content;
166
- const imageSrc = content.asDataUrl() ?? this.url;
166
+ const imageSrc = content.asImagePreviewUrl();
167
+ if (imageSrc === null) {
168
+ return;
169
+ }
167
170
  const loadPromise = new Promise(x => {
168
171
  this.imagePreviewElement.onload = x;
169
172
  });
@@ -212,8 +215,7 @@ export class ImageView extends UI.View.SimpleView {
212
215
  }
213
216
 
214
217
  private async saveImage(): Promise<void> {
215
- const imageDataURL = this.cachedContent?.asDataUrl();
216
- if (!imageDataURL) {
218
+ if (!this.cachedContent) {
217
219
  return;
218
220
  }
219
221
 
@@ -228,7 +230,10 @@ export class ImageView extends UI.View.SimpleView {
228
230
  suggestedName = decodeURIComponent(this.parsedURL.displayName);
229
231
  }
230
232
 
231
- const blob = await fetch(imageDataURL).then(r => r.blob());
233
+ const blob = this.cachedContent.asBlob();
234
+ if (!blob) {
235
+ return;
236
+ }
232
237
  try {
233
238
  const handle = await window.showSaveFilePicker({suggestedName});
234
239
  const writable = await handle.createWritable();