devtools-tracing 1.1.1 → 1.2.1

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 (527) hide show
  1. package/dist/index.d.ts +4 -0
  2. package/dist/index.js +28854 -0
  3. package/package.json +11 -8
  4. package/generate.ts +0 -649
  5. package/index.ts +0 -17
  6. package/lib/extension-api/ExtensionAPI.d.ts +0 -357
  7. package/lib/front_end/core/common/App.ts +0 -7
  8. package/lib/front_end/core/common/AppProvider.ts +0 -32
  9. package/lib/front_end/core/common/Base64.ts +0 -47
  10. package/lib/front_end/core/common/CharacterIdMap.ts +0 -30
  11. package/lib/front_end/core/common/Color.ts +0 -2506
  12. package/lib/front_end/core/common/ColorConverter.ts +0 -402
  13. package/lib/front_end/core/common/ColorUtils.ts +0 -252
  14. package/lib/front_end/core/common/Console.ts +0 -114
  15. package/lib/front_end/core/common/Debouncer.ts +0 -15
  16. package/lib/front_end/core/common/EventTarget.ts +0 -52
  17. package/lib/front_end/core/common/Gzip.ts +0 -74
  18. package/lib/front_end/core/common/JavaScriptMetaData.ts +0 -29
  19. package/lib/front_end/core/common/Lazy.ts +0 -31
  20. package/lib/front_end/core/common/Linkifier.ts +0 -55
  21. package/lib/front_end/core/common/MapWithDefault.ts +0 -26
  22. package/lib/front_end/core/common/Mutex.ts +0 -55
  23. package/lib/front_end/core/common/Object.ts +0 -145
  24. package/lib/front_end/core/common/ParsedURL.ts +0 -554
  25. package/lib/front_end/core/common/Progress.ts +0 -180
  26. package/lib/front_end/core/common/QueryParamHandler.ts +0 -7
  27. package/lib/front_end/core/common/ResolverBase.ts +0 -85
  28. package/lib/front_end/core/common/ResourceType.ts +0 -588
  29. package/lib/front_end/core/common/ReturnToPanel.ts +0 -17
  30. package/lib/front_end/core/common/Revealer.ts +0 -192
  31. package/lib/front_end/core/common/Runnable.ts +0 -41
  32. package/lib/front_end/core/common/SegmentedRange.ts +0 -87
  33. package/lib/front_end/core/common/SettingRegistration.ts +0 -339
  34. package/lib/front_end/core/common/Settings.ts +0 -1497
  35. package/lib/front_end/core/common/SimpleHistoryManager.ts +0 -124
  36. package/lib/front_end/core/common/StringOutputStream.ts +0 -26
  37. package/lib/front_end/core/common/TextDictionary.ts +0 -48
  38. package/lib/front_end/core/common/Throttler.ts +0 -99
  39. package/lib/front_end/core/common/Trie.ts +0 -152
  40. package/lib/front_end/core/common/Worker.ts +0 -60
  41. package/lib/front_end/core/common/common.ts +0 -81
  42. package/lib/front_end/core/host/AidaClient.ts +0 -733
  43. package/lib/front_end/core/host/GdpClient.ts +0 -316
  44. package/lib/front_end/core/host/InspectorFrontendHost.ts +0 -648
  45. package/lib/front_end/core/host/InspectorFrontendHostAPI.ts +0 -551
  46. package/lib/front_end/core/host/Platform.ts +0 -76
  47. package/lib/front_end/core/host/ResourceLoader.ts +0 -282
  48. package/lib/front_end/core/host/UserMetrics.ts +0 -1230
  49. package/lib/front_end/core/host/host.ts +0 -23
  50. package/lib/front_end/core/i18n/ByteUtilities.ts +0 -82
  51. package/lib/front_end/core/i18n/DevToolsLocale.ts +0 -87
  52. package/lib/front_end/core/i18n/NumberFormatter.ts +0 -82
  53. package/lib/front_end/core/i18n/i18n.ts +0 -17
  54. package/lib/front_end/core/i18n/i18nImpl.ts +0 -204
  55. package/lib/front_end/core/i18n/i18nTypes.ts +0 -10
  56. package/lib/front_end/core/i18n/locales.js +0 -14
  57. package/lib/front_end/core/i18n/time-utilities.ts +0 -174
  58. package/lib/front_end/core/platform/ArrayUtilities.ts +0 -271
  59. package/lib/front_end/core/platform/Brand.ts +0 -23
  60. package/lib/front_end/core/platform/Constructor.ts +0 -10
  61. package/lib/front_end/core/platform/DOMUtilities.ts +0 -138
  62. package/lib/front_end/core/platform/DateUtilities.ts +0 -15
  63. package/lib/front_end/core/platform/DevToolsPath.ts +0 -53
  64. package/lib/front_end/core/platform/KeyboardUtilities.ts +0 -38
  65. package/lib/front_end/core/platform/MapUtilities.ts +0 -95
  66. package/lib/front_end/core/platform/MimeType.ts +0 -175
  67. package/lib/front_end/core/platform/NumberUtilities.ts +0 -80
  68. package/lib/front_end/core/platform/StringUtilities.ts +0 -588
  69. package/lib/front_end/core/platform/Timing.ts +0 -17
  70. package/lib/front_end/core/platform/TypedArrayUtilities.ts +0 -189
  71. package/lib/front_end/core/platform/TypescriptUtilities.ts +0 -86
  72. package/lib/front_end/core/platform/UIString.ts +0 -39
  73. package/lib/front_end/core/platform/UserVisibleError.ts +0 -28
  74. package/lib/front_end/core/platform/platform.ts +0 -45
  75. package/lib/front_end/core/protocol_client/ConnectionTransport.ts +0 -26
  76. package/lib/front_end/core/protocol_client/InspectorBackend.ts +0 -1050
  77. package/lib/front_end/core/protocol_client/NodeURL.ts +0 -42
  78. package/lib/front_end/core/protocol_client/protocol_client.ts +0 -13
  79. package/lib/front_end/core/root/Runtime.ts +0 -609
  80. package/lib/front_end/core/root/root.ts +0 -6
  81. package/lib/front_end/core/sdk/AccessibilityModel.ts +0 -353
  82. package/lib/front_end/core/sdk/AnimationModel.ts +0 -1041
  83. package/lib/front_end/core/sdk/AutofillModel.ts +0 -184
  84. package/lib/front_end/core/sdk/CPUProfilerModel.ts +0 -148
  85. package/lib/front_end/core/sdk/CPUThrottlingManager.ts +0 -282
  86. package/lib/front_end/core/sdk/CSSContainerQuery.ts +0 -139
  87. package/lib/front_end/core/sdk/CSSFontFace.ts +0 -40
  88. package/lib/front_end/core/sdk/CSSLayer.ts +0 -30
  89. package/lib/front_end/core/sdk/CSSMatchedStyles.ts +0 -1646
  90. package/lib/front_end/core/sdk/CSSMedia.ts +0 -121
  91. package/lib/front_end/core/sdk/CSSMetadata.ts +0 -1647
  92. package/lib/front_end/core/sdk/CSSModel.ts +0 -1128
  93. package/lib/front_end/core/sdk/CSSProperty.ts +0 -384
  94. package/lib/front_end/core/sdk/CSSPropertyParser.ts +0 -681
  95. package/lib/front_end/core/sdk/CSSPropertyParserMatchers.ts +0 -1395
  96. package/lib/front_end/core/sdk/CSSQuery.ts +0 -72
  97. package/lib/front_end/core/sdk/CSSRule.ts +0 -465
  98. package/lib/front_end/core/sdk/CSSScope.ts +0 -30
  99. package/lib/front_end/core/sdk/CSSStartingStyle.ts +0 -29
  100. package/lib/front_end/core/sdk/CSSStyleDeclaration.ts +0 -313
  101. package/lib/front_end/core/sdk/CSSStyleSheetHeader.ts +0 -196
  102. package/lib/front_end/core/sdk/CSSSupports.ts +0 -33
  103. package/lib/front_end/core/sdk/CategorizedBreakpoint.ts +0 -64
  104. package/lib/front_end/core/sdk/ChildTargetManager.ts +0 -314
  105. package/lib/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +0 -62
  106. package/lib/front_end/core/sdk/Connections.ts +0 -293
  107. package/lib/front_end/core/sdk/ConsoleModel.ts +0 -808
  108. package/lib/front_end/core/sdk/ConsoleModelTypes.ts +0 -15
  109. package/lib/front_end/core/sdk/Cookie.ts +0 -319
  110. package/lib/front_end/core/sdk/CookieModel.ts +0 -239
  111. package/lib/front_end/core/sdk/CookieParser.ts +0 -185
  112. package/lib/front_end/core/sdk/DOMDebuggerModel.ts +0 -787
  113. package/lib/front_end/core/sdk/DOMModel.ts +0 -1961
  114. package/lib/front_end/core/sdk/DebuggerModel.ts +0 -1605
  115. package/lib/front_end/core/sdk/EmulationModel.ts +0 -648
  116. package/lib/front_end/core/sdk/EnhancedTracesParser.ts +0 -515
  117. package/lib/front_end/core/sdk/EventBreakpointsModel.ts +0 -183
  118. package/lib/front_end/core/sdk/FrameAssociated.ts +0 -11
  119. package/lib/front_end/core/sdk/FrameManager.ts +0 -259
  120. package/lib/front_end/core/sdk/HeapProfilerModel.ts +0 -225
  121. package/lib/front_end/core/sdk/HttpReasonPhraseStrings.ts +0 -77
  122. package/lib/front_end/core/sdk/IOModel.ts +0 -91
  123. package/lib/front_end/core/sdk/IsolateManager.ts +0 -257
  124. package/lib/front_end/core/sdk/IssuesModel.ts +0 -70
  125. package/lib/front_end/core/sdk/LayerTreeBase.ts +0 -169
  126. package/lib/front_end/core/sdk/LogModel.ts +0 -56
  127. package/lib/front_end/core/sdk/NetworkManager.ts +0 -2823
  128. package/lib/front_end/core/sdk/NetworkRequest.ts +0 -2253
  129. package/lib/front_end/core/sdk/OverlayColorGenerator.ts +0 -52
  130. package/lib/front_end/core/sdk/OverlayModel.ts +0 -1011
  131. package/lib/front_end/core/sdk/OverlayPersistentHighlighter.ts +0 -522
  132. package/lib/front_end/core/sdk/PageLoad.ts +0 -35
  133. package/lib/front_end/core/sdk/PageResourceLoader.ts +0 -435
  134. package/lib/front_end/core/sdk/PaintProfiler.ts +0 -110
  135. package/lib/front_end/core/sdk/PerformanceMetricsModel.ts +0 -84
  136. package/lib/front_end/core/sdk/PreloadingModel.ts +0 -863
  137. package/lib/front_end/core/sdk/RehydratingConnection.ts +0 -386
  138. package/lib/front_end/core/sdk/RehydratingObject.ts +0 -66
  139. package/lib/front_end/core/sdk/RemoteObject.ts +0 -1160
  140. package/lib/front_end/core/sdk/Resource.ts +0 -232
  141. package/lib/front_end/core/sdk/ResourceTreeModel.ts +0 -1160
  142. package/lib/front_end/core/sdk/RuntimeModel.ts +0 -732
  143. package/lib/front_end/core/sdk/SDKModel.ts +0 -65
  144. package/lib/front_end/core/sdk/ScopeTreeCache.ts +0 -45
  145. package/lib/front_end/core/sdk/ScreenCaptureModel.ts +0 -255
  146. package/lib/front_end/core/sdk/Script.ts +0 -534
  147. package/lib/front_end/core/sdk/SecurityOriginManager.ts +0 -76
  148. package/lib/front_end/core/sdk/ServerSentEvents.ts +0 -80
  149. package/lib/front_end/core/sdk/ServerSentEventsProtocol.ts +0 -122
  150. package/lib/front_end/core/sdk/ServerTiming.ts +0 -260
  151. package/lib/front_end/core/sdk/ServiceWorkerCacheModel.ts +0 -377
  152. package/lib/front_end/core/sdk/ServiceWorkerManager.ts +0 -605
  153. package/lib/front_end/core/sdk/SourceMap.ts +0 -867
  154. package/lib/front_end/core/sdk/SourceMapCache.ts +0 -54
  155. package/lib/front_end/core/sdk/SourceMapFunctionRanges.ts +0 -156
  156. package/lib/front_end/core/sdk/SourceMapManager.ts +0 -239
  157. package/lib/front_end/core/sdk/SourceMapScopeChainEntry.ts +0 -189
  158. package/lib/front_end/core/sdk/SourceMapScopesInfo.ts +0 -508
  159. package/lib/front_end/core/sdk/StorageBucketsModel.ts +0 -204
  160. package/lib/front_end/core/sdk/StorageKeyManager.ts +0 -98
  161. package/lib/front_end/core/sdk/Target.ts +0 -332
  162. package/lib/front_end/core/sdk/TargetManager.ts +0 -453
  163. package/lib/front_end/core/sdk/TraceObject.ts +0 -61
  164. package/lib/front_end/core/sdk/WebAuthnModel.ts +0 -104
  165. package/lib/front_end/core/sdk/sdk.ts +0 -174
  166. package/lib/front_end/entrypoints/formatter_worker/FormatterActions.ts +0 -59
  167. package/lib/front_end/generated/InspectorBackendCommands.js +0 -1617
  168. package/lib/front_end/generated/SupportedCSSProperties.js +0 -7512
  169. package/lib/front_end/generated/protocol-proxy-api.d.ts +0 -5022
  170. package/lib/front_end/generated/protocol.ts +0 -22014
  171. package/lib/front_end/models/bindings/CSSWorkspaceBinding.ts +0 -318
  172. package/lib/front_end/models/bindings/CompilerScriptMapping.ts +0 -536
  173. package/lib/front_end/models/bindings/ContentProviderBasedProject.ts +0 -187
  174. package/lib/front_end/models/bindings/DebuggerLanguagePlugins.ts +0 -1197
  175. package/lib/front_end/models/bindings/DebuggerWorkspaceBinding.ts +0 -733
  176. package/lib/front_end/models/bindings/DefaultScriptMapping.ts +0 -141
  177. package/lib/front_end/models/bindings/FileUtils.ts +0 -228
  178. package/lib/front_end/models/bindings/LiveLocation.ts +0 -81
  179. package/lib/front_end/models/bindings/NetworkProject.ts +0 -157
  180. package/lib/front_end/models/bindings/PresentationConsoleMessageHelper.ts +0 -312
  181. package/lib/front_end/models/bindings/ResourceMapping.ts +0 -539
  182. package/lib/front_end/models/bindings/ResourceScriptMapping.ts +0 -491
  183. package/lib/front_end/models/bindings/ResourceUtils.ts +0 -103
  184. package/lib/front_end/models/bindings/SASSSourceMapping.ts +0 -222
  185. package/lib/front_end/models/bindings/StylesSourceMapping.ts +0 -316
  186. package/lib/front_end/models/bindings/TempFile.ts +0 -67
  187. package/lib/front_end/models/bindings/bindings.ts +0 -39
  188. package/lib/front_end/models/cpu_profile/CPUProfileDataModel.ts +0 -571
  189. package/lib/front_end/models/cpu_profile/ProfileTreeModel.ts +0 -103
  190. package/lib/front_end/models/cpu_profile/cpu_profile.ts +0 -11
  191. package/lib/front_end/models/formatter/FormatterWorkerPool.ts +0 -219
  192. package/lib/front_end/models/formatter/ScriptFormatter.ts +0 -112
  193. package/lib/front_end/models/formatter/formatter.ts +0 -8
  194. package/lib/front_end/models/source_map_scopes/NamesResolver.ts +0 -765
  195. package/lib/front_end/models/source_map_scopes/ScopeChainModel.ts +0 -84
  196. package/lib/front_end/models/source_map_scopes/source_map_scopes.ts +0 -11
  197. package/lib/front_end/models/stack_trace/StackTrace.ts +0 -53
  198. package/lib/front_end/models/stack_trace/StackTraceImpl.ts +0 -85
  199. package/lib/front_end/models/stack_trace/StackTraceModel.ts +0 -128
  200. package/lib/front_end/models/stack_trace/Trie.ts +0 -163
  201. package/lib/front_end/models/stack_trace/stack_trace.ts +0 -9
  202. package/lib/front_end/models/stack_trace/stack_trace_impl.ts +0 -13
  203. package/lib/front_end/models/text_utils/CodeMirrorUtils.ts +0 -37
  204. package/lib/front_end/models/text_utils/ContentData.ts +0 -199
  205. package/lib/front_end/models/text_utils/ContentProvider.ts +0 -68
  206. package/lib/front_end/models/text_utils/StaticContentProvider.ts +0 -49
  207. package/lib/front_end/models/text_utils/StreamingContentData.ts +0 -108
  208. package/lib/front_end/models/text_utils/Text.ts +0 -90
  209. package/lib/front_end/models/text_utils/TextCursor.ts +0 -44
  210. package/lib/front_end/models/text_utils/TextRange.ts +0 -266
  211. package/lib/front_end/models/text_utils/TextUtils.ts +0 -401
  212. package/lib/front_end/models/text_utils/WasmDisassembly.ts +0 -87
  213. package/lib/front_end/models/text_utils/text_utils.ts +0 -27
  214. package/lib/front_end/models/trace/EntityMapper.ts +0 -141
  215. package/lib/front_end/models/trace/EventsSerializer.ts +0 -101
  216. package/lib/front_end/models/trace/LanternComputationData.ts +0 -438
  217. package/lib/front_end/models/trace/ModelImpl.ts +0 -236
  218. package/lib/front_end/models/trace/Name.ts +0 -136
  219. package/lib/front_end/models/trace/Processor.ts +0 -652
  220. package/lib/front_end/models/trace/Styles.ts +0 -1138
  221. package/lib/front_end/models/trace/extras/FilmStrip.ts +0 -78
  222. package/lib/front_end/models/trace/extras/MainThreadActivity.ts +0 -86
  223. package/lib/front_end/models/trace/extras/ScriptDuplication.ts +0 -236
  224. package/lib/front_end/models/trace/extras/StackTraceForEvent.ts +0 -203
  225. package/lib/front_end/models/trace/extras/ThirdParties.ts +0 -164
  226. package/lib/front_end/models/trace/extras/TraceFilter.ts +0 -62
  227. package/lib/front_end/models/trace/extras/TraceTree.ts +0 -701
  228. package/lib/front_end/models/trace/extras/extras.ts +0 -11
  229. package/lib/front_end/models/trace/handlers/AnimationFramesHandler.ts +0 -128
  230. package/lib/front_end/models/trace/handlers/AnimationHandler.ts +0 -36
  231. package/lib/front_end/models/trace/handlers/AsyncJSCallsHandler.ts +0 -239
  232. package/lib/front_end/models/trace/handlers/AuctionWorkletsHandler.ts +0 -183
  233. package/lib/front_end/models/trace/handlers/DOMStatsHandler.ts +0 -31
  234. package/lib/front_end/models/trace/handlers/ExtensionTraceDataHandler.ts +0 -306
  235. package/lib/front_end/models/trace/handlers/FlowsHandler.ts +0 -175
  236. package/lib/front_end/models/trace/handlers/FramesHandler.ts +0 -571
  237. package/lib/front_end/models/trace/handlers/GPUHandler.ts +0 -50
  238. package/lib/front_end/models/trace/handlers/ImagePaintingHandler.ts +0 -183
  239. package/lib/front_end/models/trace/handlers/InitiatorsHandler.ts +0 -193
  240. package/lib/front_end/models/trace/handlers/InvalidationsHandler.ts +0 -168
  241. package/lib/front_end/models/trace/handlers/LargestImagePaintHandler.ts +0 -109
  242. package/lib/front_end/models/trace/handlers/LargestTextPaintHandler.ts +0 -35
  243. package/lib/front_end/models/trace/handlers/LayerTreeHandler.ts +0 -123
  244. package/lib/front_end/models/trace/handlers/LayoutShiftsHandler.ts +0 -573
  245. package/lib/front_end/models/trace/handlers/MemoryHandler.ts +0 -31
  246. package/lib/front_end/models/trace/handlers/MetaHandler.ts +0 -525
  247. package/lib/front_end/models/trace/handlers/ModelHandlers.ts +0 -34
  248. package/lib/front_end/models/trace/handlers/NetworkRequestsHandler.ts +0 -672
  249. package/lib/front_end/models/trace/handlers/PageFramesHandler.ts +0 -52
  250. package/lib/front_end/models/trace/handlers/PageLoadMetricsHandler.ts +0 -460
  251. package/lib/front_end/models/trace/handlers/RendererHandler.ts +0 -428
  252. package/lib/front_end/models/trace/handlers/SamplesHandler.ts +0 -271
  253. package/lib/front_end/models/trace/handlers/ScreenshotsHandler.ts +0 -122
  254. package/lib/front_end/models/trace/handlers/ScriptsHandler.ts +0 -336
  255. package/lib/front_end/models/trace/handlers/SelectorStatsHandler.ts +0 -110
  256. package/lib/front_end/models/trace/handlers/Threads.ts +0 -139
  257. package/lib/front_end/models/trace/handlers/UserInteractionsHandler.ts +0 -400
  258. package/lib/front_end/models/trace/handlers/UserTimingsHandler.ts +0 -233
  259. package/lib/front_end/models/trace/handlers/WarningsHandler.ts +0 -162
  260. package/lib/front_end/models/trace/handlers/WorkersHandler.ts +0 -45
  261. package/lib/front_end/models/trace/handlers/handlers.ts +0 -8
  262. package/lib/front_end/models/trace/handlers/helpers.ts +0 -196
  263. package/lib/front_end/models/trace/handlers/types.ts +0 -75
  264. package/lib/front_end/models/trace/helpers/Extensions.ts +0 -54
  265. package/lib/front_end/models/trace/helpers/Network.ts +0 -129
  266. package/lib/front_end/models/trace/helpers/SamplesIntegrator.ts +0 -544
  267. package/lib/front_end/models/trace/helpers/SyntheticEvents.ts +0 -87
  268. package/lib/front_end/models/trace/helpers/Timing.ts +0 -248
  269. package/lib/front_end/models/trace/helpers/Trace.ts +0 -928
  270. package/lib/front_end/models/trace/helpers/TreeHelpers.ts +0 -320
  271. package/lib/front_end/models/trace/helpers/helpers.ts +0 -11
  272. package/lib/front_end/models/trace/insights/CLSCulprits.ts +0 -668
  273. package/lib/front_end/models/trace/insights/Cache.ts +0 -269
  274. package/lib/front_end/models/trace/insights/Common.ts +0 -453
  275. package/lib/front_end/models/trace/insights/DOMSize.ts +0 -223
  276. package/lib/front_end/models/trace/insights/DocumentLatency.ts +0 -319
  277. package/lib/front_end/models/trace/insights/DuplicatedJavaScript.ts +0 -126
  278. package/lib/front_end/models/trace/insights/FontDisplay.ts +0 -119
  279. package/lib/front_end/models/trace/insights/ForcedReflow.ts +0 -220
  280. package/lib/front_end/models/trace/insights/INPBreakdown.ts +0 -171
  281. package/lib/front_end/models/trace/insights/ImageDelivery.ts +0 -348
  282. package/lib/front_end/models/trace/insights/LCPBreakdown.ts +0 -268
  283. package/lib/front_end/models/trace/insights/LCPDiscovery.ts +0 -237
  284. package/lib/front_end/models/trace/insights/LegacyJavaScript.ts +0 -138
  285. package/lib/front_end/models/trace/insights/Models.ts +0 -22
  286. package/lib/front_end/models/trace/insights/ModernHTTP.ts +0 -257
  287. package/lib/front_end/models/trace/insights/NetworkDependencyTree.ts +0 -726
  288. package/lib/front_end/models/trace/insights/RenderBlocking.ts +0 -257
  289. package/lib/front_end/models/trace/insights/SlowCSSSelector.ts +0 -175
  290. package/lib/front_end/models/trace/insights/Statistics.ts +0 -101
  291. package/lib/front_end/models/trace/insights/ThirdParties.ts +0 -130
  292. package/lib/front_end/models/trace/insights/Viewport.ts +0 -138
  293. package/lib/front_end/models/trace/insights/insights.ts +0 -10
  294. package/lib/front_end/models/trace/insights/types.ts +0 -157
  295. package/lib/front_end/models/trace/lantern/core/LanternError.ts +0 -7
  296. package/lib/front_end/models/trace/lantern/core/NetworkAnalyzer.ts +0 -619
  297. package/lib/front_end/models/trace/lantern/core/core.ts +0 -6
  298. package/lib/front_end/models/trace/lantern/graph/BaseNode.ts +0 -345
  299. package/lib/front_end/models/trace/lantern/graph/CPUNode.ts +0 -80
  300. package/lib/front_end/models/trace/lantern/graph/NetworkNode.ts +0 -101
  301. package/lib/front_end/models/trace/lantern/graph/PageDependencyGraph.ts +0 -636
  302. package/lib/front_end/models/trace/lantern/graph/graph.ts +0 -8
  303. package/lib/front_end/models/trace/lantern/lantern.ts +0 -17
  304. package/lib/front_end/models/trace/lantern/metrics/FirstContentfulPaint.ts +0 -187
  305. package/lib/front_end/models/trace/lantern/metrics/Interactive.ts +0 -88
  306. package/lib/front_end/models/trace/lantern/metrics/LargestContentfulPaint.ts +0 -92
  307. package/lib/front_end/models/trace/lantern/metrics/MaxPotentialFID.ts +0 -72
  308. package/lib/front_end/models/trace/lantern/metrics/Metric.ts +0 -126
  309. package/lib/front_end/models/trace/lantern/metrics/SpeedIndex.ts +0 -126
  310. package/lib/front_end/models/trace/lantern/metrics/TBTUtils.ts +0 -82
  311. package/lib/front_end/models/trace/lantern/metrics/TotalBlockingTime.ts +0 -112
  312. package/lib/front_end/models/trace/lantern/metrics/metrics.ts +0 -12
  313. package/lib/front_end/models/trace/lantern/simulation/ConnectionPool.ts +0 -150
  314. package/lib/front_end/models/trace/lantern/simulation/Constants.ts +0 -46
  315. package/lib/front_end/models/trace/lantern/simulation/DNSCache.ts +0 -61
  316. package/lib/front_end/models/trace/lantern/simulation/SimulationTimingMap.ts +0 -196
  317. package/lib/front_end/models/trace/lantern/simulation/Simulator.ts +0 -556
  318. package/lib/front_end/models/trace/lantern/simulation/TCPConnection.ts +0 -192
  319. package/lib/front_end/models/trace/lantern/simulation/simulation.ts +0 -10
  320. package/lib/front_end/models/trace/lantern/types/Lantern.ts +0 -220
  321. package/lib/front_end/models/trace/lantern/types/types.ts +0 -5
  322. package/lib/front_end/models/trace/trace.ts +0 -33
  323. package/lib/front_end/models/trace/types/Configuration.ts +0 -110
  324. package/lib/front_end/models/trace/types/Extensions.ts +0 -136
  325. package/lib/front_end/models/trace/types/File.ts +0 -281
  326. package/lib/front_end/models/trace/types/Overlays.ts +0 -138
  327. package/lib/front_end/models/trace/types/Timing.ts +0 -30
  328. package/lib/front_end/models/trace/types/TraceEvents.ts +0 -3277
  329. package/lib/front_end/models/trace/types/types.ts +0 -10
  330. package/lib/front_end/models/trace_source_maps_resolver/SourceMapsResolver.ts +0 -240
  331. package/lib/front_end/models/trace_source_maps_resolver/trace_source_maps_resolver.ts +0 -5
  332. package/lib/front_end/models/workspace/FileManager.ts +0 -97
  333. package/lib/front_end/models/workspace/IgnoreListManager.ts +0 -628
  334. package/lib/front_end/models/workspace/SearchConfig.ts +0 -149
  335. package/lib/front_end/models/workspace/UISourceCode.ts +0 -698
  336. package/lib/front_end/models/workspace/WorkspaceImpl.ts +0 -339
  337. package/lib/front_end/models/workspace/workspace.ts +0 -17
  338. package/lib/front_end/panels/timeline/TimelineUIUtils.ts +0 -1029
  339. package/lib/front_end/panels/timeline/extensions/ExtensionUI.ts +0 -49
  340. package/lib/front_end/panels/timeline/extensions/extensions.ts +0 -9
  341. package/lib/front_end/third_party/codemirror.next/LICENSE +0 -21
  342. package/lib/front_end/third_party/codemirror.next/README.chromium +0 -30
  343. package/lib/front_end/third_party/codemirror.next/bundle-tsconfig.json +0 -24
  344. package/lib/front_end/third_party/codemirror.next/bundle.ts +0 -135
  345. package/lib/front_end/third_party/codemirror.next/chunk/angular.js +0 -2
  346. package/lib/front_end/third_party/codemirror.next/chunk/angular.js.map +0 -1
  347. package/lib/front_end/third_party/codemirror.next/chunk/codemirror.js +0 -2
  348. package/lib/front_end/third_party/codemirror.next/chunk/codemirror.js.map +0 -1
  349. package/lib/front_end/third_party/codemirror.next/chunk/cpp.js +0 -2
  350. package/lib/front_end/third_party/codemirror.next/chunk/cpp.js.map +0 -1
  351. package/lib/front_end/third_party/codemirror.next/chunk/css.js +0 -2
  352. package/lib/front_end/third_party/codemirror.next/chunk/html.js +0 -4
  353. package/lib/front_end/third_party/codemirror.next/chunk/java.js +0 -2
  354. package/lib/front_end/third_party/codemirror.next/chunk/java.js.map +0 -1
  355. package/lib/front_end/third_party/codemirror.next/chunk/javascript.js +0 -2
  356. package/lib/front_end/third_party/codemirror.next/chunk/legacy.js +0 -2
  357. package/lib/front_end/third_party/codemirror.next/chunk/legacy.js.map +0 -1
  358. package/lib/front_end/third_party/codemirror.next/chunk/less.js +0 -2
  359. package/lib/front_end/third_party/codemirror.next/chunk/less.js.map +0 -1
  360. package/lib/front_end/third_party/codemirror.next/chunk/markdown.js +0 -2
  361. package/lib/front_end/third_party/codemirror.next/chunk/markdown.js.map +0 -1
  362. package/lib/front_end/third_party/codemirror.next/chunk/php.js +0 -2
  363. package/lib/front_end/third_party/codemirror.next/chunk/php.js.map +0 -1
  364. package/lib/front_end/third_party/codemirror.next/chunk/python.js +0 -2
  365. package/lib/front_end/third_party/codemirror.next/chunk/python.js.map +0 -1
  366. package/lib/front_end/third_party/codemirror.next/chunk/sass.js +0 -2
  367. package/lib/front_end/third_party/codemirror.next/chunk/sass.js.map +0 -1
  368. package/lib/front_end/third_party/codemirror.next/chunk/svelte.js +0 -2
  369. package/lib/front_end/third_party/codemirror.next/chunk/svelte.js.map +0 -1
  370. package/lib/front_end/third_party/codemirror.next/chunk/vue.js +0 -2
  371. package/lib/front_end/third_party/codemirror.next/chunk/vue.js.map +0 -1
  372. package/lib/front_end/third_party/codemirror.next/chunk/wast.js +0 -2
  373. package/lib/front_end/third_party/codemirror.next/chunk/wast.js.map +0 -1
  374. package/lib/front_end/third_party/codemirror.next/chunk/xml.js +0 -2
  375. package/lib/front_end/third_party/codemirror.next/chunk/xml.js.map +0 -1
  376. package/lib/front_end/third_party/codemirror.next/codemirror.next.d.ts +0 -8057
  377. package/lib/front_end/third_party/codemirror.next/codemirror.next.js +0 -2
  378. package/lib/front_end/third_party/codemirror.next/codemirror.next.js.map +0 -1
  379. package/lib/front_end/third_party/codemirror.next/package.json +0 -43
  380. package/lib/front_end/third_party/codemirror.next/rebuild.sh +0 -6
  381. package/lib/front_end/third_party/codemirror.next/rollup.config.mjs +0 -49
  382. package/lib/front_end/third_party/i18n/LICENSE +0 -202
  383. package/lib/front_end/third_party/i18n/README.chromium +0 -15
  384. package/lib/front_end/third_party/i18n/i18n-impl.ts +0 -61
  385. package/lib/front_end/third_party/i18n/i18n.ts +0 -11
  386. package/lib/front_end/third_party/i18n/localized-string-set.ts +0 -129
  387. package/lib/front_end/third_party/intl-messageformat/LICENSE +0 -33
  388. package/lib/front_end/third_party/intl-messageformat/README.chromium +0 -24
  389. package/lib/front_end/third_party/intl-messageformat/intl-messageformat-tsconfig.json +0 -16
  390. package/lib/front_end/third_party/intl-messageformat/intl-messageformat.ts +0 -6
  391. package/lib/front_end/third_party/intl-messageformat/package/LICENSE.md +0 -33
  392. package/lib/front_end/third_party/intl-messageformat/package/README.md +0 -3
  393. package/lib/front_end/third_party/intl-messageformat/package/index.d.ts +0 -6
  394. package/lib/front_end/third_party/intl-messageformat/package/index.d.ts.map +0 -1
  395. package/lib/front_end/third_party/intl-messageformat/package/index.js +0 -13
  396. package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.esm.d.ts +0 -5
  397. package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.esm.js +0 -1710
  398. package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.iife.js +0 -1815
  399. package/lib/front_end/third_party/intl-messageformat/package/lib/index.d.ts +0 -6
  400. package/lib/front_end/third_party/intl-messageformat/package/lib/index.d.ts.map +0 -1
  401. package/lib/front_end/third_party/intl-messageformat/package/lib/index.js +0 -10
  402. package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.d.ts +0 -34
  403. package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.d.ts.map +0 -1
  404. package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.js +0 -229
  405. package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.d.ts +0 -28
  406. package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.d.ts.map +0 -1
  407. package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.js +0 -48
  408. package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.d.ts +0 -34
  409. package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.d.ts.map +0 -1
  410. package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.js +0 -179
  411. package/lib/front_end/third_party/intl-messageformat/package/package.json +0 -42
  412. package/lib/front_end/third_party/intl-messageformat/package/src/core.d.ts +0 -34
  413. package/lib/front_end/third_party/intl-messageformat/package/src/core.d.ts.map +0 -1
  414. package/lib/front_end/third_party/intl-messageformat/package/src/core.js +0 -230
  415. package/lib/front_end/third_party/intl-messageformat/package/src/error.d.ts +0 -28
  416. package/lib/front_end/third_party/intl-messageformat/package/src/error.d.ts.map +0 -1
  417. package/lib/front_end/third_party/intl-messageformat/package/src/error.js +0 -51
  418. package/lib/front_end/third_party/intl-messageformat/package/src/formatters.d.ts +0 -34
  419. package/lib/front_end/third_party/intl-messageformat/package/src/formatters.d.ts.map +0 -1
  420. package/lib/front_end/third_party/intl-messageformat/package/src/formatters.js +0 -182
  421. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/error.d.ts +0 -79
  422. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/index.d.ts +0 -15
  423. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/parser.d.ts +0 -153
  424. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/types.d.ts +0 -139
  425. package/lib/front_end/third_party/legacy-javascript/LICENSE +0 -202
  426. package/lib/front_end/third_party/legacy-javascript/README.chromium +0 -13
  427. package/lib/front_end/third_party/legacy-javascript/legacy-javascript-tsconfig.json +0 -8
  428. package/lib/front_end/third_party/legacy-javascript/legacy-javascript.ts +0 -3
  429. package/lib/front_end/third_party/legacy-javascript/lib/legacy-javascript.d.ts +0 -18
  430. package/lib/front_end/third_party/legacy-javascript/lib/legacy-javascript.js +0 -943
  431. package/lib/front_end/third_party/legacy-javascript/package.json +0 -8
  432. package/lib/front_end/third_party/legacy-javascript/rebuild.sh +0 -9
  433. package/lib/front_end/third_party/source-map-scopes-codec/LICENSE +0 -26
  434. package/lib/front_end/third_party/source-map-scopes-codec/README.chromium +0 -31
  435. package/lib/front_end/third_party/source-map-scopes-codec/package/CONTRIBUTING.md +0 -33
  436. package/lib/front_end/third_party/source-map-scopes-codec/package/LICENSE +0 -26
  437. package/lib/front_end/third_party/source-map-scopes-codec/package/README.md +0 -64
  438. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts +0 -62
  439. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts.map +0 -1
  440. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts +0 -37
  441. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts.map +0 -1
  442. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts +0 -29
  443. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts.map +0 -1
  444. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts +0 -8
  445. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts.map +0 -1
  446. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts +0 -6
  447. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts.map +0 -1
  448. package/lib/front_end/third_party/source-map-scopes-codec/package/deno.json +0 -21
  449. package/lib/front_end/third_party/source-map-scopes-codec/package/package.json +0 -14
  450. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js +0 -196
  451. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js.map +0 -1
  452. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.ts +0 -262
  453. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js +0 -235
  454. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js.map +0 -1
  455. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.ts +0 -359
  456. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.js +0 -39
  457. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.js.map +0 -1
  458. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.ts +0 -53
  459. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js +0 -438
  460. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js.map +0 -1
  461. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.ts +0 -539
  462. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js +0 -23
  463. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js.map +0 -1
  464. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.ts +0 -35
  465. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js +0 -257
  466. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js.map +0 -1
  467. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.ts +0 -348
  468. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.js +0 -8
  469. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.js.map +0 -1
  470. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.ts +0 -20
  471. package/lib/front_end/third_party/source-map-scopes-codec/package/src/scopes-tsconfig.json +0 -8
  472. package/lib/front_end/third_party/source-map-scopes-codec/package/src/scopes.d.ts +0 -184
  473. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.js +0 -9
  474. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.js.map +0 -1
  475. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.ts +0 -12
  476. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.js +0 -82
  477. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.js.map +0 -1
  478. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.ts +0 -99
  479. package/lib/front_end/third_party/source-map-scopes-codec/source-map-scopes-codec.ts +0 -5
  480. package/lib/front_end/third_party/third-party-web/LICENSE +0 -20
  481. package/lib/front_end/third_party/third-party-web/README.chromium +0 -13
  482. package/lib/front_end/third_party/third-party-web/lib/nostats-subset.d.ts +0 -2
  483. package/lib/front_end/third_party/third-party-web/lib/nostats-subset.js +0 -149
  484. package/lib/front_end/third_party/third-party-web/package/LICENSE +0 -20
  485. package/lib/front_end/third_party/third-party-web/package/README.md +0 -929
  486. package/lib/front_end/third_party/third-party-web/package/dist/entities-httparchive-nostats.json +0 -1
  487. package/lib/front_end/third_party/third-party-web/package/dist/entities-httparchive.json +0 -1
  488. package/lib/front_end/third_party/third-party-web/package/dist/entities-nostats.json +0 -1
  489. package/lib/front_end/third_party/third-party-web/package/dist/entities.json +0 -1
  490. package/lib/front_end/third_party/third-party-web/package/facades.md +0 -46
  491. package/lib/front_end/third_party/third-party-web/package/httparchive-nostats-subset.d.ts +0 -1
  492. package/lib/front_end/third_party/third-party-web/package/httparchive-nostats-subset.js +0 -1
  493. package/lib/front_end/third_party/third-party-web/package/httparchive-subset.d.ts +0 -1
  494. package/lib/front_end/third_party/third-party-web/package/httparchive-subset.js +0 -1
  495. package/lib/front_end/third_party/third-party-web/package/lib/__snapshots__/index.test.js.snap +0 -1006
  496. package/lib/front_end/third_party/third-party-web/package/lib/create-entity-finder-api.js +0 -139
  497. package/lib/front_end/third_party/third-party-web/package/lib/create-entity-finder-api.test.js +0 -44
  498. package/lib/front_end/third_party/third-party-web/package/lib/entities.test.js +0 -27
  499. package/lib/front_end/third_party/third-party-web/package/lib/index.d.ts +0 -34
  500. package/lib/front_end/third_party/third-party-web/package/lib/index.js +0 -3
  501. package/lib/front_end/third_party/third-party-web/package/lib/index.test.js +0 -246
  502. package/lib/front_end/third_party/third-party-web/package/lib/markdown/faqs.partial.md +0 -36
  503. package/lib/front_end/third_party/third-party-web/package/lib/markdown/goals.partial.md +0 -9
  504. package/lib/front_end/third_party/third-party-web/package/lib/markdown/methodology.partial.md +0 -5
  505. package/lib/front_end/third_party/third-party-web/package/lib/markdown/template.md +0 -151
  506. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-02-01.md +0 -1
  507. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-03-01.md +0 -1
  508. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-05-06.md +0 -1
  509. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-05-13.md +0 -14
  510. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2021-01-01.md +0 -1
  511. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2024-07-01.md +0 -3
  512. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive-nostats.d.ts +0 -1
  513. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive-nostats.js +0 -3
  514. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive.d.ts +0 -1
  515. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive.js +0 -3
  516. package/lib/front_end/third_party/third-party-web/package/lib/subsets/nostats.d.ts +0 -1
  517. package/lib/front_end/third_party/third-party-web/package/lib/subsets/nostats.js +0 -3
  518. package/lib/front_end/third_party/third-party-web/package/nostats-subset.d.ts +0 -1
  519. package/lib/front_end/third_party/third-party-web/package/nostats-subset.js +0 -1
  520. package/lib/front_end/third_party/third-party-web/package/package.json +0 -46
  521. package/lib/front_end/third_party/third-party-web/package.json +0 -8
  522. package/lib/front_end/third_party/third-party-web/rebuild.sh +0 -13
  523. package/lib/front_end/third_party/third-party-web/third-party-web-tsconfig.json +0 -8
  524. package/lib/front_end/third_party/third-party-web/third-party-web.ts +0 -3
  525. package/lib/front_end/ui/legacy/theme_support/ThemeSupport.ts +0 -222
  526. package/lib/front_end/ui/legacy/theme_support/theme_support.ts +0 -5
  527. package/patches/chrome-devtools-frontend+1.0.1533544.patch +0 -1716
@@ -1,1050 +0,0 @@
1
- // Copyright 2011 The Chromium Authors
2
- // Use of this source code is governed by a BSD-style license that can be
3
- // found in the LICENSE file.
4
-
5
- import * as InspectorBackendCommands from '../../generated/InspectorBackendCommands.js';
6
- import type * as ProtocolProxyApi from '../../generated/protocol-proxy-api.js';
7
- import type * as Protocol from '../../generated/protocol.js';
8
- import type * as Platform from '../platform/platform.js';
9
-
10
- import {ConnectionTransport} from './ConnectionTransport.js';
11
- import {NodeURL} from './NodeURL.js';
12
-
13
- export const DevToolsStubErrorCode = -32015;
14
- // TODO(dgozman): we are not reporting generic errors in tests, but we should
15
- // instead report them and just have some expected errors in test expectations.
16
- const GenericErrorCode = -32000;
17
- const ConnectionClosedErrorCode = -32001;
18
-
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- type MessageParams = Record<string, any>;
21
-
22
- type ProtocolDomainName = ProtocolProxyApi.ProtocolDomainName;
23
-
24
- export interface MessageError {
25
- code: number;
26
- message: string;
27
- data?: string|null;
28
- }
29
-
30
- export interface Message {
31
- sessionId?: string;
32
- url?: Platform.DevToolsPath.UrlString;
33
- id?: number;
34
- error?: MessageError|null;
35
- result?: Object|null;
36
- method?: QualifiedName;
37
- params?: MessageParams|null;
38
- }
39
-
40
- interface EventMessage extends Message {
41
- method: QualifiedName;
42
- params?: MessageParams|null;
43
- }
44
-
45
- /** A qualified name, e.g. Domain.method */
46
- export type QualifiedName = string&{qualifiedEventNameTag: string | undefined};
47
- /** A qualified name, e.g. method */
48
- export type UnqualifiedName = string&{unqualifiedEventNameTag: string | undefined};
49
-
50
- export const splitQualifiedName = (string: QualifiedName): [string, UnqualifiedName] => {
51
- const [domain, eventName] = string.split('.');
52
- return [domain, eventName as UnqualifiedName];
53
- };
54
-
55
- export const qualifyName = (domain: string, name: UnqualifiedName): QualifiedName => {
56
- return `${domain}.${name}` as QualifiedName;
57
- };
58
-
59
- type EventParameterNames = Map<QualifiedName, string[]>;
60
- type ReadonlyEventParameterNames = ReadonlyMap<QualifiedName, string[]>;
61
-
62
- interface CommandParameter {
63
- name: string;
64
- type: string;
65
- optional: boolean;
66
- description: string;
67
- }
68
-
69
- type Callback = (error: MessageError|null, arg1: Object|null) => void;
70
-
71
- interface CallbackWithDebugInfo {
72
- callback: Callback;
73
- method: string;
74
- }
75
-
76
- export class InspectorBackend {
77
- readonly agentPrototypes = new Map<ProtocolDomainName, AgentPrototype>();
78
- #initialized = false;
79
- #eventParameterNamesForDomain = new Map<ProtocolDomainName, EventParameterNames>();
80
- readonly typeMap = new Map<QualifiedName, CommandParameter[]>();
81
- readonly enumMap = new Map<QualifiedName, Record<string, string>>();
82
-
83
- constructor() {
84
- // Create the global here because registering commands will involve putting
85
- // items onto the global.
86
- // @ts-expect-error Global namespace instantiation
87
- globalThis.Protocol ||= {};
88
-
89
- InspectorBackendCommands.registerCommands(this);
90
- }
91
-
92
- private getOrCreateEventParameterNamesForDomain(domain: ProtocolDomainName): EventParameterNames {
93
- let map = this.#eventParameterNamesForDomain.get(domain);
94
- if (!map) {
95
- map = new Map();
96
- this.#eventParameterNamesForDomain.set(domain, map);
97
- }
98
- return map;
99
- }
100
-
101
- getOrCreateEventParameterNamesForDomainForTesting(domain: ProtocolDomainName): EventParameterNames {
102
- return this.getOrCreateEventParameterNamesForDomain(domain);
103
- }
104
-
105
- getEventParameterNames(): ReadonlyMap<ProtocolDomainName, ReadonlyEventParameterNames> {
106
- return this.#eventParameterNamesForDomain;
107
- }
108
-
109
- static reportProtocolError(error: string, messageObject: Object): void {
110
- console.error(error + ': ' + JSON.stringify(messageObject));
111
- }
112
-
113
- static reportProtocolWarning(error: string, messageObject: Object): void {
114
- console.warn(error + ': ' + JSON.stringify(messageObject));
115
- }
116
-
117
- isInitialized(): boolean {
118
- return this.#initialized;
119
- }
120
-
121
- private agentPrototype(domain: ProtocolDomainName): AgentPrototype {
122
- let prototype = this.agentPrototypes.get(domain);
123
- if (!prototype) {
124
- prototype = new AgentPrototype(domain);
125
- this.agentPrototypes.set(domain, prototype);
126
- }
127
- return prototype;
128
- }
129
-
130
- registerCommand(method: QualifiedName, parameters: CommandParameter[], replyArgs: string[], description: string):
131
- void {
132
- const [domain, command] = splitQualifiedName(method);
133
- this.agentPrototype(domain as ProtocolDomainName).registerCommand(command, parameters, replyArgs, description);
134
- this.#initialized = true;
135
- }
136
-
137
- registerEnum(type: QualifiedName, values: Record<string, string>): void {
138
- const [domain, name] = splitQualifiedName(type);
139
- // @ts-expect-error globalThis global namespace pollution
140
- if (!globalThis.Protocol[domain]) {
141
- // @ts-expect-error globalThis global namespace pollution
142
- globalThis.Protocol[domain] = {};
143
- }
144
-
145
- // @ts-expect-error globalThis global namespace pollution
146
- globalThis.Protocol[domain][name] = values;
147
- this.enumMap.set(type, values);
148
- this.#initialized = true;
149
- }
150
-
151
- registerType(method: QualifiedName, parameters: CommandParameter[]): void {
152
- this.typeMap.set(method, parameters);
153
- this.#initialized = true;
154
- }
155
-
156
- registerEvent(eventName: QualifiedName, params: string[]): void {
157
- const domain = eventName.split('.')[0];
158
- const eventParameterNames = this.getOrCreateEventParameterNamesForDomain(domain as ProtocolDomainName);
159
- eventParameterNames.set(eventName, params);
160
- this.#initialized = true;
161
- }
162
- }
163
-
164
- type SendRawMessageCallback = (...args: unknown[]) => void;
165
-
166
- export const test = {
167
- /**
168
- * This will get called for every protocol message.
169
- * ProtocolClient.test.dumpProtocol = console.log
170
- */
171
- dumpProtocol: null as ((arg0: string) => void) | null,
172
-
173
- /**
174
- * Runs a function when no protocol activity is present.
175
- * ProtocolClient.test.deprecatedRunAfterPendingDispatches(() => console.log('done'))
176
- */
177
- deprecatedRunAfterPendingDispatches: null as ((arg0: () => void) => void) | null,
178
-
179
- /**
180
- * Sends a raw message over main connection.
181
- * ProtocolClient.test.sendRawMessage('Page.enable', {}, console.log)
182
- */
183
- sendRawMessage: null as ((method: QualifiedName, args: Object|null, arg2: SendRawMessageCallback) => void) | null,
184
-
185
- /**
186
- * Set to true to not log any errors.
187
- */
188
- suppressRequestErrors: false as boolean,
189
-
190
- /**
191
- * Set to get notified about any messages sent over protocol.
192
- */
193
- onMessageSent: null as
194
- ((message: {domain: string, method: string, params: Object, id: number, sessionId?: string}) => void) |
195
- null,
196
-
197
- /**
198
- * Set to get notified about any messages received over protocol.
199
- */
200
- onMessageReceived: null as ((message: Object) => void) | null,
201
- };
202
-
203
- const LongPollingMethods = new Set<string>(['CSS.takeComputedStyleUpdates']);
204
-
205
- export class SessionRouter {
206
- readonly #connection: ConnectionTransport;
207
- #lastMessageId = 1;
208
- #pendingResponsesCount = 0;
209
- readonly #pendingLongPollingMessageIds = new Set<number>();
210
- readonly #sessions = new Map<string, {
211
- target: TargetBase,
212
- callbacks: Map<number, CallbackWithDebugInfo>,
213
- proxyConnection: ConnectionTransport|undefined|null,
214
- }>();
215
- #pendingScripts: Array<() => void> = [];
216
-
217
- constructor(connection: ConnectionTransport) {
218
- this.#connection = connection;
219
-
220
- test.deprecatedRunAfterPendingDispatches = this.deprecatedRunAfterPendingDispatches.bind(this);
221
- test.sendRawMessage = this.sendRawMessageForTesting.bind(this);
222
-
223
- this.#connection.setOnMessage(this.onMessage.bind(this));
224
-
225
- this.#connection.setOnDisconnect(reason => {
226
- const session = this.#sessions.get('');
227
- if (session) {
228
- session.target.dispose(reason);
229
- }
230
- });
231
- }
232
-
233
- registerSession(target: TargetBase, sessionId: string, proxyConnection?: ConnectionTransport|null): void {
234
- // Only the Audits panel uses proxy connections. If it is ever possible to have multiple active at the
235
- // same time, it should be tested thoroughly.
236
- if (proxyConnection) {
237
- for (const session of this.#sessions.values()) {
238
- if (session.proxyConnection) {
239
- console.error('Multiple simultaneous proxy connections are currently unsupported');
240
- break;
241
- }
242
- }
243
- }
244
-
245
- this.#sessions.set(sessionId, {target, callbacks: new Map(), proxyConnection});
246
- }
247
-
248
- unregisterSession(sessionId: string): void {
249
- const session = this.#sessions.get(sessionId);
250
- if (!session) {
251
- return;
252
- }
253
- for (const callback of session.callbacks.values()) {
254
- SessionRouter.dispatchUnregisterSessionError(callback);
255
- }
256
- this.#sessions.delete(sessionId);
257
- }
258
-
259
- private nextMessageId(): number {
260
- return this.#lastMessageId++;
261
- }
262
-
263
- connection(): ConnectionTransport {
264
- return this.#connection;
265
- }
266
-
267
- sendMessage(sessionId: string, domain: string, method: QualifiedName, params: Object|null, callback: Callback): void {
268
- const messageId = this.nextMessageId();
269
- const messageObject: Message = {
270
- id: messageId,
271
- method,
272
- };
273
-
274
- if (params) {
275
- messageObject.params = params;
276
- }
277
- if (sessionId) {
278
- messageObject.sessionId = sessionId;
279
- }
280
-
281
- if (test.dumpProtocol) {
282
- test.dumpProtocol('frontend: ' + JSON.stringify(messageObject));
283
- }
284
-
285
- if (test.onMessageSent) {
286
- const paramsObject = JSON.parse(JSON.stringify(params || {}));
287
- test.onMessageSent({domain, method, params: (paramsObject as Object), id: messageId, sessionId});
288
- }
289
-
290
- ++this.#pendingResponsesCount;
291
- if (LongPollingMethods.has(method)) {
292
- this.#pendingLongPollingMessageIds.add(messageId);
293
- }
294
-
295
- const session = this.#sessions.get(sessionId);
296
- if (!session) {
297
- return;
298
- }
299
- session.callbacks.set(messageId, {callback, method});
300
- this.#connection.sendRawMessage(JSON.stringify(messageObject));
301
- }
302
-
303
- private sendRawMessageForTesting(method: QualifiedName, params: Object|null, callback: Callback|null, sessionId = ''):
304
- void {
305
- const domain = method.split('.')[0];
306
- this.sendMessage(sessionId, domain, method, params, callback || (() => {}));
307
- }
308
-
309
- private onMessage(message: string|Object): void {
310
- if (test.dumpProtocol) {
311
- test.dumpProtocol('backend: ' + ((typeof message === 'string') ? message : JSON.stringify(message)));
312
- }
313
-
314
- if (test.onMessageReceived) {
315
- const messageObjectCopy = JSON.parse((typeof message === 'string') ? message : JSON.stringify(message));
316
- test.onMessageReceived(messageObjectCopy);
317
- }
318
-
319
- const messageObject = ((typeof message === 'string') ? JSON.parse(message) : message) as Message;
320
-
321
- // Send all messages to proxy connections.
322
- let suppressUnknownMessageErrors = false;
323
- for (const session of this.#sessions.values()) {
324
- if (!session.proxyConnection) {
325
- continue;
326
- }
327
-
328
- if (!session.proxyConnection.onMessage) {
329
- InspectorBackend.reportProtocolError(
330
- 'Protocol Error: the session has a proxyConnection with no _onMessage', messageObject);
331
- continue;
332
- }
333
-
334
- session.proxyConnection.onMessage(messageObject);
335
- suppressUnknownMessageErrors = true;
336
- }
337
-
338
- const sessionId = messageObject.sessionId || '';
339
- const session = this.#sessions.get(sessionId);
340
- if (!session) {
341
- // In the DevTools MCP case, we may share the transport with puppeteer so we silently
342
- // ignore unknown sessions.
343
- return;
344
- }
345
-
346
- // If this message is directly for the target controlled by the proxy connection, don't handle it.
347
- if (session.proxyConnection) {
348
- return;
349
- }
350
-
351
- if (session.target.getNeedsNodeJSPatching()) {
352
- NodeURL.patch(messageObject);
353
- }
354
-
355
- if (messageObject.id !== undefined) { // just a response for some request
356
- const callback = session.callbacks.get(messageObject.id);
357
- session.callbacks.delete(messageObject.id);
358
- if (!callback) {
359
- if (messageObject.error?.code === ConnectionClosedErrorCode) {
360
- // Ignore the errors that are sent as responses after the session closes.
361
- return;
362
- }
363
- if (!suppressUnknownMessageErrors) {
364
- InspectorBackend.reportProtocolError('Protocol Error: the message with wrong id', messageObject);
365
- }
366
- return;
367
- }
368
-
369
- callback.callback(messageObject.error || null, messageObject.result || null);
370
- --this.#pendingResponsesCount;
371
- this.#pendingLongPollingMessageIds.delete(messageObject.id);
372
-
373
- if (this.#pendingScripts.length && !this.hasOutstandingNonLongPollingRequests()) {
374
- this.deprecatedRunAfterPendingDispatches();
375
- }
376
- } else {
377
- if (messageObject.method === undefined) {
378
- InspectorBackend.reportProtocolError('Protocol Error: the message without method', messageObject);
379
- return;
380
- }
381
- // This cast is justified as we just checked for the presence of messageObject.method.
382
- const eventMessage = messageObject as EventMessage;
383
- session.target.dispatch(eventMessage);
384
- }
385
- }
386
-
387
- private hasOutstandingNonLongPollingRequests(): boolean {
388
- return this.#pendingResponsesCount - this.#pendingLongPollingMessageIds.size > 0;
389
- }
390
-
391
- private deprecatedRunAfterPendingDispatches(script?: (() => void)): void {
392
- if (script) {
393
- this.#pendingScripts.push(script);
394
- }
395
-
396
- // Execute all promises.
397
- window.setTimeout(() => {
398
- if (!this.hasOutstandingNonLongPollingRequests()) {
399
- this.executeAfterPendingDispatches();
400
- } else {
401
- this.deprecatedRunAfterPendingDispatches();
402
- }
403
- }, 0);
404
- }
405
-
406
- private executeAfterPendingDispatches(): void {
407
- if (!this.hasOutstandingNonLongPollingRequests()) {
408
- const scripts = this.#pendingScripts;
409
- this.#pendingScripts = [];
410
- for (let id = 0; id < scripts.length; ++id) {
411
- scripts[id]();
412
- }
413
- }
414
- }
415
-
416
- static dispatchConnectionError(callback: Callback, method: string): void {
417
- const error = {
418
- message: `Connection is closed, can\'t dispatch pending call to ${method}`,
419
- code: ConnectionClosedErrorCode,
420
- data: null,
421
- };
422
- window.setTimeout(() => callback(error, null), 0);
423
- }
424
-
425
- static dispatchUnregisterSessionError({callback, method}: CallbackWithDebugInfo): void {
426
- const error = {
427
- message: `Session is unregistering, can\'t dispatch pending call to ${method}`,
428
- code: ConnectionClosedErrorCode,
429
- data: null,
430
- };
431
- window.setTimeout(() => callback(error, null), 0);
432
- }
433
- }
434
-
435
- /**
436
- * Make sure that `Domain` in get/set is only ever instantiated with one protocol domain
437
- * name, because if `Domain` allows multiple domains, the type is unsound.
438
- */
439
- interface AgentsMap extends Map<ProtocolDomainName, ProtocolProxyApi.ProtocolApi[ProtocolDomainName]> {
440
- get<Domain extends ProtocolDomainName>(key: Domain): ProtocolProxyApi.ProtocolApi[Domain]|undefined;
441
- set<Domain extends ProtocolDomainName>(key: Domain, value: ProtocolProxyApi.ProtocolApi[Domain]): this;
442
- }
443
-
444
- /**
445
- * Make sure that `Domain` in get/set is only ever instantiated with one protocol domain
446
- * name, because if `Domain` allows multiple domains, the type is unsound.
447
- */
448
- interface DispatcherMap extends Map<ProtocolDomainName, ProtocolProxyApi.ProtocolDispatchers[ProtocolDomainName]> {
449
- get<Domain extends ProtocolDomainName>(key: Domain): DispatcherManager<Domain>|undefined;
450
- set<Domain extends ProtocolDomainName>(key: Domain, value: DispatcherManager<Domain>): this;
451
- }
452
-
453
- export class TargetBase {
454
- needsNodeJSPatching: boolean;
455
- readonly sessionId: string;
456
- #router: SessionRouter|null;
457
- #agents: AgentsMap = new Map();
458
- #dispatchers: DispatcherMap = new Map();
459
-
460
- constructor(
461
- needsNodeJSPatching: boolean, parentTarget: TargetBase|null, sessionId: string,
462
- connection: ConnectionTransport|null) {
463
- this.needsNodeJSPatching = needsNodeJSPatching;
464
- this.sessionId = sessionId;
465
-
466
- if (parentTarget && !sessionId) {
467
- throw new Error('Specifying a parent target requires a session ID');
468
- }
469
-
470
- let router: SessionRouter;
471
- if (parentTarget && parentTarget.#router) {
472
- router = parentTarget.#router;
473
- } else if (connection) {
474
- router = new SessionRouter(connection);
475
- } else {
476
- router = new SessionRouter(ConnectionTransport.getFactory()());
477
- }
478
-
479
- this.#router = router;
480
-
481
- router.registerSession(this, this.sessionId);
482
-
483
- for (const [domain, agentPrototype] of inspectorBackend.agentPrototypes) {
484
- const agent = Object.create((agentPrototype));
485
- agent.target = this;
486
- this.#agents.set(domain, agent);
487
- }
488
-
489
- for (const [domain, eventParameterNames] of inspectorBackend.getEventParameterNames().entries()) {
490
- this.#dispatchers.set(domain, new DispatcherManager(eventParameterNames));
491
- }
492
- }
493
-
494
- dispatch(eventMessage: EventMessage): void {
495
- const [domainName, method] = splitQualifiedName(eventMessage.method);
496
- const dispatcher = this.#dispatchers.get(domainName as ProtocolDomainName);
497
- if (!dispatcher) {
498
- InspectorBackend.reportProtocolError(
499
- `Protocol Error: the message ${eventMessage.method} is for non-existing domain '${domainName}'`,
500
- eventMessage);
501
- return;
502
- }
503
- dispatcher.dispatch(method, eventMessage);
504
- }
505
-
506
- dispose(_reason: string): void {
507
- if (!this.#router) {
508
- return;
509
- }
510
- this.#router.unregisterSession(this.sessionId);
511
- this.#router = null;
512
- }
513
-
514
- isDisposed(): boolean {
515
- return !this.#router;
516
- }
517
-
518
- markAsNodeJSForTest(): void {
519
- this.needsNodeJSPatching = true;
520
- }
521
-
522
- router(): SessionRouter|null {
523
- return this.#router;
524
- }
525
-
526
- // Agent accessors, keep alphabetically sorted.
527
-
528
- /**
529
- * Make sure that `Domain` is only ever instantiated with one protocol domain
530
- * name, because if `Domain` allows multiple domains, the type is unsound.
531
- */
532
- private getAgent<Domain extends ProtocolDomainName>(domain: Domain): ProtocolProxyApi.ProtocolApi[Domain] {
533
- const agent = this.#agents.get<Domain>(domain);
534
- if (!agent) {
535
- throw new Error('Accessing undefined agent');
536
- }
537
- return agent;
538
- }
539
-
540
- accessibilityAgent(): ProtocolProxyApi.AccessibilityApi {
541
- return this.getAgent('Accessibility');
542
- }
543
-
544
- animationAgent(): ProtocolProxyApi.AnimationApi {
545
- return this.getAgent('Animation');
546
- }
547
-
548
- auditsAgent(): ProtocolProxyApi.AuditsApi {
549
- return this.getAgent('Audits');
550
- }
551
-
552
- autofillAgent(): ProtocolProxyApi.AutofillApi {
553
- return this.getAgent('Autofill');
554
- }
555
-
556
- browserAgent(): ProtocolProxyApi.BrowserApi {
557
- return this.getAgent('Browser');
558
- }
559
-
560
- backgroundServiceAgent(): ProtocolProxyApi.BackgroundServiceApi {
561
- return this.getAgent('BackgroundService');
562
- }
563
-
564
- cacheStorageAgent(): ProtocolProxyApi.CacheStorageApi {
565
- return this.getAgent('CacheStorage');
566
- }
567
-
568
- cssAgent(): ProtocolProxyApi.CSSApi {
569
- return this.getAgent('CSS');
570
- }
571
-
572
- debuggerAgent(): ProtocolProxyApi.DebuggerApi {
573
- return this.getAgent('Debugger');
574
- }
575
-
576
- deviceOrientationAgent(): ProtocolProxyApi.DeviceOrientationApi {
577
- return this.getAgent('DeviceOrientation');
578
- }
579
-
580
- domAgent(): ProtocolProxyApi.DOMApi {
581
- return this.getAgent('DOM');
582
- }
583
-
584
- domdebuggerAgent(): ProtocolProxyApi.DOMDebuggerApi {
585
- return this.getAgent('DOMDebugger');
586
- }
587
-
588
- domsnapshotAgent(): ProtocolProxyApi.DOMSnapshotApi {
589
- return this.getAgent('DOMSnapshot');
590
- }
591
-
592
- domstorageAgent(): ProtocolProxyApi.DOMStorageApi {
593
- return this.getAgent('DOMStorage');
594
- }
595
-
596
- emulationAgent(): ProtocolProxyApi.EmulationApi {
597
- return this.getAgent('Emulation');
598
- }
599
-
600
- eventBreakpointsAgent(): ProtocolProxyApi.EventBreakpointsApi {
601
- return this.getAgent('EventBreakpoints');
602
- }
603
-
604
- extensionsAgent(): ProtocolProxyApi.ExtensionsApi {
605
- return this.getAgent('Extensions');
606
- }
607
-
608
- fetchAgent(): ProtocolProxyApi.FetchApi {
609
- return this.getAgent('Fetch');
610
- }
611
-
612
- heapProfilerAgent(): ProtocolProxyApi.HeapProfilerApi {
613
- return this.getAgent('HeapProfiler');
614
- }
615
-
616
- indexedDBAgent(): ProtocolProxyApi.IndexedDBApi {
617
- return this.getAgent('IndexedDB');
618
- }
619
-
620
- inputAgent(): ProtocolProxyApi.InputApi {
621
- return this.getAgent('Input');
622
- }
623
-
624
- ioAgent(): ProtocolProxyApi.IOApi {
625
- return this.getAgent('IO');
626
- }
627
-
628
- inspectorAgent(): ProtocolProxyApi.InspectorApi {
629
- return this.getAgent('Inspector');
630
- }
631
-
632
- layerTreeAgent(): ProtocolProxyApi.LayerTreeApi {
633
- return this.getAgent('LayerTree');
634
- }
635
-
636
- logAgent(): ProtocolProxyApi.LogApi {
637
- return this.getAgent('Log');
638
- }
639
-
640
- mediaAgent(): ProtocolProxyApi.MediaApi {
641
- return this.getAgent('Media');
642
- }
643
-
644
- memoryAgent(): ProtocolProxyApi.MemoryApi {
645
- return this.getAgent('Memory');
646
- }
647
-
648
- networkAgent(): ProtocolProxyApi.NetworkApi {
649
- return this.getAgent('Network');
650
- }
651
-
652
- overlayAgent(): ProtocolProxyApi.OverlayApi {
653
- return this.getAgent('Overlay');
654
- }
655
-
656
- pageAgent(): ProtocolProxyApi.PageApi {
657
- return this.getAgent('Page');
658
- }
659
-
660
- preloadAgent(): ProtocolProxyApi.PreloadApi {
661
- return this.getAgent('Preload');
662
- }
663
-
664
- profilerAgent(): ProtocolProxyApi.ProfilerApi {
665
- return this.getAgent('Profiler');
666
- }
667
-
668
- performanceAgent(): ProtocolProxyApi.PerformanceApi {
669
- return this.getAgent('Performance');
670
- }
671
-
672
- runtimeAgent(): ProtocolProxyApi.RuntimeApi {
673
- return this.getAgent('Runtime');
674
- }
675
-
676
- securityAgent(): ProtocolProxyApi.SecurityApi {
677
- return this.getAgent('Security');
678
- }
679
-
680
- serviceWorkerAgent(): ProtocolProxyApi.ServiceWorkerApi {
681
- return this.getAgent('ServiceWorker');
682
- }
683
-
684
- storageAgent(): ProtocolProxyApi.StorageApi {
685
- return this.getAgent('Storage');
686
- }
687
-
688
- systemInfo(): ProtocolProxyApi.SystemInfoApi {
689
- return this.getAgent('SystemInfo');
690
- }
691
-
692
- targetAgent(): ProtocolProxyApi.TargetApi {
693
- return this.getAgent('Target');
694
- }
695
-
696
- tracingAgent(): ProtocolProxyApi.TracingApi {
697
- return this.getAgent('Tracing');
698
- }
699
-
700
- webAudioAgent(): ProtocolProxyApi.WebAudioApi {
701
- return this.getAgent('WebAudio');
702
- }
703
-
704
- webAuthnAgent(): ProtocolProxyApi.WebAuthnApi {
705
- return this.getAgent('WebAuthn');
706
- }
707
-
708
- // Dispatcher registration and de-registration, keep alphabetically sorted.
709
-
710
- /**
711
- * Make sure that `Domain` is only ever instantiated with one protocol domain
712
- * name, because if `Domain` allows multiple domains, the type is unsound.
713
- */
714
- private registerDispatcher<Domain extends ProtocolDomainName>(
715
- domain: Domain, dispatcher: ProtocolProxyApi.ProtocolDispatchers[Domain]): void {
716
- const manager = this.#dispatchers.get(domain);
717
- if (!manager) {
718
- return;
719
- }
720
- manager.addDomainDispatcher(dispatcher);
721
- }
722
-
723
- /**
724
- * Make sure that `Domain` is only ever instantiated with one protocol domain
725
- * name, because if `Domain` allows multiple domains, the type is unsound.
726
- */
727
- private unregisterDispatcher<Domain extends ProtocolDomainName>(
728
- domain: Domain, dispatcher: ProtocolProxyApi.ProtocolDispatchers[Domain]): void {
729
- const manager = this.#dispatchers.get(domain);
730
- if (!manager) {
731
- return;
732
- }
733
- manager.removeDomainDispatcher(dispatcher);
734
- }
735
-
736
- registerAccessibilityDispatcher(dispatcher: ProtocolProxyApi.AccessibilityDispatcher): void {
737
- this.registerDispatcher('Accessibility', dispatcher);
738
- }
739
-
740
- registerAutofillDispatcher(dispatcher: ProtocolProxyApi.AutofillDispatcher): void {
741
- this.registerDispatcher('Autofill', dispatcher);
742
- }
743
-
744
- registerAnimationDispatcher(dispatcher: ProtocolProxyApi.AnimationDispatcher): void {
745
- this.registerDispatcher('Animation', dispatcher);
746
- }
747
-
748
- registerAuditsDispatcher(dispatcher: ProtocolProxyApi.AuditsDispatcher): void {
749
- this.registerDispatcher('Audits', dispatcher);
750
- }
751
-
752
- registerCSSDispatcher(dispatcher: ProtocolProxyApi.CSSDispatcher): void {
753
- this.registerDispatcher('CSS', dispatcher);
754
- }
755
-
756
- registerBackgroundServiceDispatcher(dispatcher: ProtocolProxyApi.BackgroundServiceDispatcher): void {
757
- this.registerDispatcher('BackgroundService', dispatcher);
758
- }
759
-
760
- registerDebuggerDispatcher(dispatcher: ProtocolProxyApi.DebuggerDispatcher): void {
761
- this.registerDispatcher('Debugger', dispatcher);
762
- }
763
-
764
- unregisterDebuggerDispatcher(dispatcher: ProtocolProxyApi.DebuggerDispatcher): void {
765
- this.unregisterDispatcher('Debugger', dispatcher);
766
- }
767
-
768
- registerDOMDispatcher(dispatcher: ProtocolProxyApi.DOMDispatcher): void {
769
- this.registerDispatcher('DOM', dispatcher);
770
- }
771
-
772
- registerDOMStorageDispatcher(dispatcher: ProtocolProxyApi.DOMStorageDispatcher): void {
773
- this.registerDispatcher('DOMStorage', dispatcher);
774
- }
775
-
776
- registerFetchDispatcher(dispatcher: ProtocolProxyApi.FetchDispatcher): void {
777
- this.registerDispatcher('Fetch', dispatcher);
778
- }
779
-
780
- registerHeapProfilerDispatcher(dispatcher: ProtocolProxyApi.HeapProfilerDispatcher): void {
781
- this.registerDispatcher('HeapProfiler', dispatcher);
782
- }
783
-
784
- registerInspectorDispatcher(dispatcher: ProtocolProxyApi.InspectorDispatcher): void {
785
- this.registerDispatcher('Inspector', dispatcher);
786
- }
787
-
788
- registerLayerTreeDispatcher(dispatcher: ProtocolProxyApi.LayerTreeDispatcher): void {
789
- this.registerDispatcher('LayerTree', dispatcher);
790
- }
791
-
792
- registerLogDispatcher(dispatcher: ProtocolProxyApi.LogDispatcher): void {
793
- this.registerDispatcher('Log', dispatcher);
794
- }
795
-
796
- registerMediaDispatcher(dispatcher: ProtocolProxyApi.MediaDispatcher): void {
797
- this.registerDispatcher('Media', dispatcher);
798
- }
799
-
800
- registerNetworkDispatcher(dispatcher: ProtocolProxyApi.NetworkDispatcher): void {
801
- this.registerDispatcher('Network', dispatcher);
802
- }
803
-
804
- registerOverlayDispatcher(dispatcher: ProtocolProxyApi.OverlayDispatcher): void {
805
- this.registerDispatcher('Overlay', dispatcher);
806
- }
807
-
808
- registerPageDispatcher(dispatcher: ProtocolProxyApi.PageDispatcher): void {
809
- this.registerDispatcher('Page', dispatcher);
810
- }
811
-
812
- registerPreloadDispatcher(dispatcher: ProtocolProxyApi.PreloadDispatcher): void {
813
- this.registerDispatcher('Preload', dispatcher);
814
- }
815
-
816
- registerProfilerDispatcher(dispatcher: ProtocolProxyApi.ProfilerDispatcher): void {
817
- this.registerDispatcher('Profiler', dispatcher);
818
- }
819
-
820
- registerRuntimeDispatcher(dispatcher: ProtocolProxyApi.RuntimeDispatcher): void {
821
- this.registerDispatcher('Runtime', dispatcher);
822
- }
823
-
824
- registerSecurityDispatcher(dispatcher: ProtocolProxyApi.SecurityDispatcher): void {
825
- this.registerDispatcher('Security', dispatcher);
826
- }
827
-
828
- registerServiceWorkerDispatcher(dispatcher: ProtocolProxyApi.ServiceWorkerDispatcher): void {
829
- this.registerDispatcher('ServiceWorker', dispatcher);
830
- }
831
-
832
- registerStorageDispatcher(dispatcher: ProtocolProxyApi.StorageDispatcher): void {
833
- this.registerDispatcher('Storage', dispatcher);
834
- }
835
-
836
- registerTargetDispatcher(dispatcher: ProtocolProxyApi.TargetDispatcher): void {
837
- this.registerDispatcher('Target', dispatcher);
838
- }
839
-
840
- registerTracingDispatcher(dispatcher: ProtocolProxyApi.TracingDispatcher): void {
841
- this.registerDispatcher('Tracing', dispatcher);
842
- }
843
-
844
- registerWebAudioDispatcher(dispatcher: ProtocolProxyApi.WebAudioDispatcher): void {
845
- this.registerDispatcher('WebAudio', dispatcher);
846
- }
847
-
848
- registerWebAuthnDispatcher(dispatcher: ProtocolProxyApi.WebAuthnDispatcher): void {
849
- this.registerDispatcher('WebAuthn', dispatcher);
850
- }
851
-
852
- getNeedsNodeJSPatching(): boolean {
853
- return this.needsNodeJSPatching;
854
- }
855
- }
856
-
857
- /**
858
- * This is a class that serves as the prototype for a domains #agents (every target
859
- * has it's own set of #agents). The InspectorBackend keeps an instance of this class
860
- * per domain, and each TargetBase creates its #agents (via Object.create) and installs
861
- * this instance as prototype.
862
- *
863
- * The reasons this is done is so that on the prototypes we can install the implementations
864
- * of the invoke_enable, etc. methods that the front-end uses.
865
- */
866
- class AgentPrototype {
867
- replyArgs: Record<string, string[]>;
868
- description = '';
869
- metadata: Record<string, {parameters: CommandParameter[], description: string, replyArgs: string[]}>;
870
- readonly domain: string;
871
- target!: TargetBase;
872
- constructor(domain: string) {
873
- this.replyArgs = {};
874
- this.domain = domain;
875
- this.metadata = {};
876
- }
877
-
878
- registerCommand(
879
- methodName: UnqualifiedName, parameters: CommandParameter[], replyArgs: string[], description: string): void {
880
- const domainAndMethod = qualifyName(this.domain, methodName);
881
- function sendMessagePromise(this: AgentPrototype, ...args: unknown[]): Promise<unknown> {
882
- return AgentPrototype.prototype.sendMessageToBackendPromise.call(this, domainAndMethod, parameters, args);
883
- }
884
- // @ts-expect-error Method code generation
885
- this[methodName] = sendMessagePromise;
886
- this.metadata[domainAndMethod] = {parameters, description, replyArgs};
887
-
888
- function invoke(this: AgentPrototype, request: Object|undefined = {}): Promise<Protocol.ProtocolResponseWithError> {
889
- return this.invoke(domainAndMethod, request);
890
- }
891
-
892
- // @ts-expect-error Method code generation
893
- this['invoke_' + methodName] = invoke;
894
- this.replyArgs[domainAndMethod] = replyArgs;
895
- }
896
-
897
- private prepareParameters(
898
- method: string, parameters: CommandParameter[], args: unknown[], errorCallback: (arg0: string) => void): Object
899
- |null {
900
- const params: Record<string, unknown> = {};
901
- let hasParams = false;
902
-
903
- for (const param of parameters) {
904
- const paramName = param.name;
905
- const typeName = param.type;
906
- const optionalFlag = param.optional;
907
-
908
- if (!args.length && !optionalFlag) {
909
- errorCallback(
910
- `Protocol Error: Invalid number of arguments for method '${method}' call. ` +
911
- `It must have the following arguments ${JSON.stringify(parameters)}'.`);
912
- return null;
913
- }
914
-
915
- const value = args.shift();
916
- if (optionalFlag && typeof value === 'undefined') {
917
- continue;
918
- }
919
- const expectedJSType = typeName === 'array' ? 'object' : typeName;
920
- if (typeof value !== expectedJSType) {
921
- errorCallback(
922
- `Protocol Error: Invalid type of argument '${paramName}' for method '${method}' call. ` +
923
- `It must be '${typeName}' but it is '${typeof value}'.`);
924
- return null;
925
- }
926
-
927
- params[paramName] = value;
928
- hasParams = true;
929
- }
930
-
931
- if (args.length) {
932
- errorCallback(`Protocol Error: Extra ${args.length} arguments in a call to method '${method}'.`);
933
- return null;
934
- }
935
-
936
- return hasParams ? params : null;
937
- }
938
-
939
- private sendMessageToBackendPromise(method: QualifiedName, parameters: CommandParameter[], args: unknown[]):
940
- Promise<unknown> {
941
- let errorMessage;
942
- function onError(message: string): void {
943
- console.error(message);
944
- errorMessage = message;
945
- }
946
- const params = this.prepareParameters(method, parameters, args, onError);
947
- if (errorMessage) {
948
- return Promise.resolve(null);
949
- }
950
-
951
- return new Promise(resolve => {
952
- // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration
953
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
954
- const callback: Callback = (error: MessageError|null, result: any|null): void => {
955
- if (error) {
956
- if (!test.suppressRequestErrors && error.code !== DevToolsStubErrorCode && error.code !== GenericErrorCode &&
957
- error.code !== ConnectionClosedErrorCode) {
958
- console.error('Request ' + method + ' failed. ' + JSON.stringify(error));
959
- }
960
-
961
- resolve(null);
962
- return;
963
- }
964
-
965
- const args = this.replyArgs[method];
966
- resolve(result && args.length ? result[args[0]] : undefined);
967
- };
968
-
969
- const router = this.target.router();
970
- if (!router) {
971
- SessionRouter.dispatchConnectionError(callback, method);
972
- } else {
973
- router.sendMessage(this.target.sessionId, this.domain, method, params, callback);
974
- }
975
- });
976
- }
977
-
978
- private invoke(method: QualifiedName, request: Object|null): Promise<Protocol.ProtocolResponseWithError> {
979
- return new Promise(fulfill => {
980
- const callback: Callback = (error: MessageError|undefined|null, result: Object|null): void => {
981
- if (error && !test.suppressRequestErrors && error.code !== DevToolsStubErrorCode &&
982
- error.code !== GenericErrorCode && error.code !== ConnectionClosedErrorCode) {
983
- console.error('Request ' + method + ' failed. ' + JSON.stringify(error));
984
- }
985
-
986
- const errorMessage = error?.message;
987
- fulfill({...result, getError: () => errorMessage});
988
- };
989
-
990
- const router = this.target.router();
991
- if (!router) {
992
- SessionRouter.dispatchConnectionError(callback, method);
993
- } else {
994
- router.sendMessage(this.target.sessionId, this.domain, method, request, callback);
995
- }
996
- });
997
- }
998
- }
999
-
1000
- /**
1001
- * A `DispatcherManager` has a collection of #dispatchers that implement one of the
1002
- * `ProtocolProxyApi.{Foo}Dispatcher` interfaces. Each target uses one of these per
1003
- * domain to manage the registered #dispatchers. The class knows the parameter names
1004
- * of the events via `#eventArgs`, which is a map managed by the inspector back-end
1005
- * so that there is only one map per domain that is shared among all DispatcherManagers.
1006
- */
1007
- class DispatcherManager<Domain extends ProtocolDomainName> {
1008
- readonly #eventArgs: ReadonlyEventParameterNames;
1009
- readonly #dispatchers: Array<ProtocolProxyApi.ProtocolDispatchers[Domain]> = [];
1010
-
1011
- constructor(eventArgs: ReadonlyEventParameterNames) {
1012
- this.#eventArgs = eventArgs;
1013
- }
1014
-
1015
- addDomainDispatcher(dispatcher: ProtocolProxyApi.ProtocolDispatchers[Domain]): void {
1016
- this.#dispatchers.push(dispatcher);
1017
- }
1018
-
1019
- removeDomainDispatcher(dispatcher: ProtocolProxyApi.ProtocolDispatchers[Domain]): void {
1020
- const index = this.#dispatchers.indexOf(dispatcher);
1021
- if (index === -1) {
1022
- return;
1023
- }
1024
- this.#dispatchers.splice(index, 1);
1025
- }
1026
-
1027
- dispatch(event: UnqualifiedName, messageObject: EventMessage): void {
1028
- if (!this.#dispatchers.length) {
1029
- return;
1030
- }
1031
-
1032
- if (!this.#eventArgs.has(messageObject.method)) {
1033
- InspectorBackend.reportProtocolWarning(
1034
- `Protocol Warning: Attempted to dispatch an unspecified event '${messageObject.method}'`, messageObject);
1035
- return;
1036
- }
1037
-
1038
- for (let index = 0; index < this.#dispatchers.length; ++index) {
1039
- const dispatcher = this.#dispatchers[index];
1040
-
1041
- if (event in dispatcher) {
1042
- const f = dispatcher[event as string as keyof ProtocolProxyApi.ProtocolDispatchers[Domain]];
1043
- // @ts-expect-error Can't type check the dispatch.
1044
- f.call(dispatcher, messageObject.params);
1045
- }
1046
- }
1047
- }
1048
- }
1049
-
1050
- export const inspectorBackend = new InspectorBackend();