devtools-tracing 1.0.0

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 (397) hide show
  1. package/generate.ts +643 -0
  2. package/index.ts +16 -0
  3. package/lib/front_end/core/common/App.ts +7 -0
  4. package/lib/front_end/core/common/AppProvider.ts +32 -0
  5. package/lib/front_end/core/common/Base64.ts +47 -0
  6. package/lib/front_end/core/common/CharacterIdMap.ts +30 -0
  7. package/lib/front_end/core/common/Color.ts +2506 -0
  8. package/lib/front_end/core/common/ColorConverter.ts +402 -0
  9. package/lib/front_end/core/common/ColorUtils.ts +252 -0
  10. package/lib/front_end/core/common/Console.ts +114 -0
  11. package/lib/front_end/core/common/Debouncer.ts +15 -0
  12. package/lib/front_end/core/common/EventTarget.ts +52 -0
  13. package/lib/front_end/core/common/Gzip.ts +74 -0
  14. package/lib/front_end/core/common/JavaScriptMetaData.ts +29 -0
  15. package/lib/front_end/core/common/Lazy.ts +31 -0
  16. package/lib/front_end/core/common/Linkifier.ts +55 -0
  17. package/lib/front_end/core/common/MapWithDefault.ts +26 -0
  18. package/lib/front_end/core/common/Mutex.ts +55 -0
  19. package/lib/front_end/core/common/Object.ts +145 -0
  20. package/lib/front_end/core/common/ParsedURL.ts +554 -0
  21. package/lib/front_end/core/common/Progress.ts +180 -0
  22. package/lib/front_end/core/common/QueryParamHandler.ts +7 -0
  23. package/lib/front_end/core/common/ResolverBase.ts +85 -0
  24. package/lib/front_end/core/common/ResourceType.ts +588 -0
  25. package/lib/front_end/core/common/ReturnToPanel.ts +17 -0
  26. package/lib/front_end/core/common/Revealer.ts +192 -0
  27. package/lib/front_end/core/common/Runnable.ts +41 -0
  28. package/lib/front_end/core/common/SegmentedRange.ts +87 -0
  29. package/lib/front_end/core/common/SettingRegistration.ts +339 -0
  30. package/lib/front_end/core/common/Settings.ts +1497 -0
  31. package/lib/front_end/core/common/SimpleHistoryManager.ts +124 -0
  32. package/lib/front_end/core/common/StringOutputStream.ts +26 -0
  33. package/lib/front_end/core/common/TextDictionary.ts +48 -0
  34. package/lib/front_end/core/common/Throttler.ts +99 -0
  35. package/lib/front_end/core/common/Trie.ts +152 -0
  36. package/lib/front_end/core/common/Worker.ts +60 -0
  37. package/lib/front_end/core/common/common.ts +81 -0
  38. package/lib/front_end/core/host/AidaClient.ts +733 -0
  39. package/lib/front_end/core/host/GdpClient.ts +316 -0
  40. package/lib/front_end/core/host/InspectorFrontendHost.ts +648 -0
  41. package/lib/front_end/core/host/InspectorFrontendHostAPI.ts +551 -0
  42. package/lib/front_end/core/host/Platform.ts +76 -0
  43. package/lib/front_end/core/host/ResourceLoader.ts +282 -0
  44. package/lib/front_end/core/host/UserMetrics.ts +1230 -0
  45. package/lib/front_end/core/host/host.ts +23 -0
  46. package/lib/front_end/core/i18n/ByteUtilities.ts +82 -0
  47. package/lib/front_end/core/i18n/DevToolsLocale.ts +87 -0
  48. package/lib/front_end/core/i18n/NumberFormatter.ts +82 -0
  49. package/lib/front_end/core/i18n/i18n.ts +17 -0
  50. package/lib/front_end/core/i18n/i18nImpl.ts +204 -0
  51. package/lib/front_end/core/i18n/i18nTypes.ts +10 -0
  52. package/lib/front_end/core/i18n/locales.js +14 -0
  53. package/lib/front_end/core/i18n/time-utilities.ts +174 -0
  54. package/lib/front_end/core/platform/ArrayUtilities.ts +271 -0
  55. package/lib/front_end/core/platform/Brand.ts +23 -0
  56. package/lib/front_end/core/platform/Constructor.ts +10 -0
  57. package/lib/front_end/core/platform/DOMUtilities.ts +138 -0
  58. package/lib/front_end/core/platform/DateUtilities.ts +15 -0
  59. package/lib/front_end/core/platform/DevToolsPath.ts +53 -0
  60. package/lib/front_end/core/platform/KeyboardUtilities.ts +38 -0
  61. package/lib/front_end/core/platform/MapUtilities.ts +95 -0
  62. package/lib/front_end/core/platform/MimeType.ts +175 -0
  63. package/lib/front_end/core/platform/NumberUtilities.ts +80 -0
  64. package/lib/front_end/core/platform/StringUtilities.ts +588 -0
  65. package/lib/front_end/core/platform/Timing.ts +17 -0
  66. package/lib/front_end/core/platform/TypedArrayUtilities.ts +189 -0
  67. package/lib/front_end/core/platform/TypescriptUtilities.ts +86 -0
  68. package/lib/front_end/core/platform/UIString.ts +39 -0
  69. package/lib/front_end/core/platform/UserVisibleError.ts +28 -0
  70. package/lib/front_end/core/platform/platform.ts +45 -0
  71. package/lib/front_end/core/protocol_client/ConnectionTransport.ts +26 -0
  72. package/lib/front_end/core/protocol_client/InspectorBackend.ts +1050 -0
  73. package/lib/front_end/core/protocol_client/NodeURL.ts +42 -0
  74. package/lib/front_end/core/protocol_client/protocol_client.ts +13 -0
  75. package/lib/front_end/core/root/Runtime.ts +609 -0
  76. package/lib/front_end/core/root/root.ts +6 -0
  77. package/lib/front_end/core/sdk/AccessibilityModel.ts +353 -0
  78. package/lib/front_end/core/sdk/AnimationModel.ts +1041 -0
  79. package/lib/front_end/core/sdk/AutofillModel.ts +184 -0
  80. package/lib/front_end/core/sdk/CPUProfilerModel.ts +148 -0
  81. package/lib/front_end/core/sdk/CPUThrottlingManager.ts +282 -0
  82. package/lib/front_end/core/sdk/CSSContainerQuery.ts +139 -0
  83. package/lib/front_end/core/sdk/CSSFontFace.ts +40 -0
  84. package/lib/front_end/core/sdk/CSSLayer.ts +30 -0
  85. package/lib/front_end/core/sdk/CSSMatchedStyles.ts +1646 -0
  86. package/lib/front_end/core/sdk/CSSMedia.ts +121 -0
  87. package/lib/front_end/core/sdk/CSSMetadata.ts +1647 -0
  88. package/lib/front_end/core/sdk/CSSModel.ts +1128 -0
  89. package/lib/front_end/core/sdk/CSSProperty.ts +384 -0
  90. package/lib/front_end/core/sdk/CSSPropertyParser.ts +681 -0
  91. package/lib/front_end/core/sdk/CSSPropertyParserMatchers.ts +1395 -0
  92. package/lib/front_end/core/sdk/CSSQuery.ts +72 -0
  93. package/lib/front_end/core/sdk/CSSRule.ts +465 -0
  94. package/lib/front_end/core/sdk/CSSScope.ts +30 -0
  95. package/lib/front_end/core/sdk/CSSStartingStyle.ts +29 -0
  96. package/lib/front_end/core/sdk/CSSStyleDeclaration.ts +313 -0
  97. package/lib/front_end/core/sdk/CSSStyleSheetHeader.ts +196 -0
  98. package/lib/front_end/core/sdk/CSSSupports.ts +33 -0
  99. package/lib/front_end/core/sdk/CategorizedBreakpoint.ts +64 -0
  100. package/lib/front_end/core/sdk/ChildTargetManager.ts +314 -0
  101. package/lib/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +62 -0
  102. package/lib/front_end/core/sdk/Connections.ts +293 -0
  103. package/lib/front_end/core/sdk/ConsoleModel.ts +808 -0
  104. package/lib/front_end/core/sdk/ConsoleModelTypes.ts +15 -0
  105. package/lib/front_end/core/sdk/Cookie.ts +319 -0
  106. package/lib/front_end/core/sdk/CookieModel.ts +239 -0
  107. package/lib/front_end/core/sdk/CookieParser.ts +185 -0
  108. package/lib/front_end/core/sdk/DOMDebuggerModel.ts +787 -0
  109. package/lib/front_end/core/sdk/DOMModel.ts +1961 -0
  110. package/lib/front_end/core/sdk/DebuggerModel.ts +1605 -0
  111. package/lib/front_end/core/sdk/EmulationModel.ts +648 -0
  112. package/lib/front_end/core/sdk/EnhancedTracesParser.ts +515 -0
  113. package/lib/front_end/core/sdk/EventBreakpointsModel.ts +183 -0
  114. package/lib/front_end/core/sdk/FrameAssociated.ts +11 -0
  115. package/lib/front_end/core/sdk/FrameManager.ts +259 -0
  116. package/lib/front_end/core/sdk/HeapProfilerModel.ts +225 -0
  117. package/lib/front_end/core/sdk/HttpReasonPhraseStrings.ts +77 -0
  118. package/lib/front_end/core/sdk/IOModel.ts +91 -0
  119. package/lib/front_end/core/sdk/IsolateManager.ts +257 -0
  120. package/lib/front_end/core/sdk/IssuesModel.ts +70 -0
  121. package/lib/front_end/core/sdk/LayerTreeBase.ts +169 -0
  122. package/lib/front_end/core/sdk/LogModel.ts +56 -0
  123. package/lib/front_end/core/sdk/NetworkManager.ts +2823 -0
  124. package/lib/front_end/core/sdk/NetworkRequest.ts +2253 -0
  125. package/lib/front_end/core/sdk/OverlayColorGenerator.ts +52 -0
  126. package/lib/front_end/core/sdk/OverlayModel.ts +1011 -0
  127. package/lib/front_end/core/sdk/OverlayPersistentHighlighter.ts +522 -0
  128. package/lib/front_end/core/sdk/PageLoad.ts +35 -0
  129. package/lib/front_end/core/sdk/PageResourceLoader.ts +435 -0
  130. package/lib/front_end/core/sdk/PaintProfiler.ts +110 -0
  131. package/lib/front_end/core/sdk/PerformanceMetricsModel.ts +84 -0
  132. package/lib/front_end/core/sdk/PreloadingModel.ts +863 -0
  133. package/lib/front_end/core/sdk/RehydratingConnection.ts +386 -0
  134. package/lib/front_end/core/sdk/RehydratingObject.ts +66 -0
  135. package/lib/front_end/core/sdk/RemoteObject.ts +1160 -0
  136. package/lib/front_end/core/sdk/Resource.ts +232 -0
  137. package/lib/front_end/core/sdk/ResourceTreeModel.ts +1160 -0
  138. package/lib/front_end/core/sdk/RuntimeModel.ts +732 -0
  139. package/lib/front_end/core/sdk/SDKModel.ts +65 -0
  140. package/lib/front_end/core/sdk/ScopeTreeCache.ts +45 -0
  141. package/lib/front_end/core/sdk/ScreenCaptureModel.ts +255 -0
  142. package/lib/front_end/core/sdk/Script.ts +534 -0
  143. package/lib/front_end/core/sdk/SecurityOriginManager.ts +76 -0
  144. package/lib/front_end/core/sdk/ServerSentEvents.ts +80 -0
  145. package/lib/front_end/core/sdk/ServerSentEventsProtocol.ts +122 -0
  146. package/lib/front_end/core/sdk/ServerTiming.ts +260 -0
  147. package/lib/front_end/core/sdk/ServiceWorkerCacheModel.ts +377 -0
  148. package/lib/front_end/core/sdk/ServiceWorkerManager.ts +605 -0
  149. package/lib/front_end/core/sdk/SourceMap.ts +867 -0
  150. package/lib/front_end/core/sdk/SourceMapCache.ts +54 -0
  151. package/lib/front_end/core/sdk/SourceMapFunctionRanges.ts +156 -0
  152. package/lib/front_end/core/sdk/SourceMapManager.ts +239 -0
  153. package/lib/front_end/core/sdk/SourceMapScopeChainEntry.ts +189 -0
  154. package/lib/front_end/core/sdk/SourceMapScopesInfo.ts +508 -0
  155. package/lib/front_end/core/sdk/StorageBucketsModel.ts +204 -0
  156. package/lib/front_end/core/sdk/StorageKeyManager.ts +98 -0
  157. package/lib/front_end/core/sdk/Target.ts +332 -0
  158. package/lib/front_end/core/sdk/TargetManager.ts +453 -0
  159. package/lib/front_end/core/sdk/TraceObject.ts +61 -0
  160. package/lib/front_end/core/sdk/WebAuthnModel.ts +104 -0
  161. package/lib/front_end/core/sdk/sdk.ts +174 -0
  162. package/lib/front_end/entrypoints/formatter_worker/FormatterActions.ts +59 -0
  163. package/lib/front_end/generated/InspectorBackendCommands.js +1617 -0
  164. package/lib/front_end/generated/SupportedCSSProperties.js +7512 -0
  165. package/lib/front_end/generated/protocol-proxy-api.d.ts +5022 -0
  166. package/lib/front_end/generated/protocol.ts +22014 -0
  167. package/lib/front_end/models/cpu_profile/CPUProfileDataModel.ts +571 -0
  168. package/lib/front_end/models/cpu_profile/ProfileTreeModel.ts +103 -0
  169. package/lib/front_end/models/cpu_profile/cpu_profile.ts +11 -0
  170. package/lib/front_end/models/formatter/FormatterWorkerPool.ts +219 -0
  171. package/lib/front_end/models/formatter/ScriptFormatter.ts +112 -0
  172. package/lib/front_end/models/formatter/formatter.ts +8 -0
  173. package/lib/front_end/models/text_utils/CodeMirrorUtils.ts +37 -0
  174. package/lib/front_end/models/text_utils/ContentData.ts +199 -0
  175. package/lib/front_end/models/text_utils/ContentProvider.ts +68 -0
  176. package/lib/front_end/models/text_utils/StaticContentProvider.ts +49 -0
  177. package/lib/front_end/models/text_utils/StreamingContentData.ts +108 -0
  178. package/lib/front_end/models/text_utils/Text.ts +90 -0
  179. package/lib/front_end/models/text_utils/TextCursor.ts +44 -0
  180. package/lib/front_end/models/text_utils/TextRange.ts +266 -0
  181. package/lib/front_end/models/text_utils/TextUtils.ts +401 -0
  182. package/lib/front_end/models/text_utils/WasmDisassembly.ts +87 -0
  183. package/lib/front_end/models/text_utils/text_utils.ts +27 -0
  184. package/lib/front_end/models/trace/EntityMapper.ts +141 -0
  185. package/lib/front_end/models/trace/EventsSerializer.ts +101 -0
  186. package/lib/front_end/models/trace/LanternComputationData.ts +438 -0
  187. package/lib/front_end/models/trace/ModelImpl.ts +236 -0
  188. package/lib/front_end/models/trace/Name.ts +136 -0
  189. package/lib/front_end/models/trace/Processor.ts +652 -0
  190. package/lib/front_end/models/trace/Styles.ts +1138 -0
  191. package/lib/front_end/models/trace/extras/FilmStrip.ts +78 -0
  192. package/lib/front_end/models/trace/extras/MainThreadActivity.ts +86 -0
  193. package/lib/front_end/models/trace/extras/ScriptDuplication.ts +236 -0
  194. package/lib/front_end/models/trace/extras/StackTraceForEvent.ts +203 -0
  195. package/lib/front_end/models/trace/extras/ThirdParties.ts +164 -0
  196. package/lib/front_end/models/trace/extras/TraceFilter.ts +62 -0
  197. package/lib/front_end/models/trace/extras/TraceTree.ts +701 -0
  198. package/lib/front_end/models/trace/extras/extras.ts +11 -0
  199. package/lib/front_end/models/trace/handlers/AnimationFramesHandler.ts +128 -0
  200. package/lib/front_end/models/trace/handlers/AnimationHandler.ts +36 -0
  201. package/lib/front_end/models/trace/handlers/AsyncJSCallsHandler.ts +239 -0
  202. package/lib/front_end/models/trace/handlers/AuctionWorkletsHandler.ts +183 -0
  203. package/lib/front_end/models/trace/handlers/DOMStatsHandler.ts +31 -0
  204. package/lib/front_end/models/trace/handlers/ExtensionTraceDataHandler.ts +306 -0
  205. package/lib/front_end/models/trace/handlers/FlowsHandler.ts +175 -0
  206. package/lib/front_end/models/trace/handlers/FramesHandler.ts +571 -0
  207. package/lib/front_end/models/trace/handlers/GPUHandler.ts +50 -0
  208. package/lib/front_end/models/trace/handlers/ImagePaintingHandler.ts +183 -0
  209. package/lib/front_end/models/trace/handlers/InitiatorsHandler.ts +193 -0
  210. package/lib/front_end/models/trace/handlers/InvalidationsHandler.ts +168 -0
  211. package/lib/front_end/models/trace/handlers/LargestImagePaintHandler.ts +109 -0
  212. package/lib/front_end/models/trace/handlers/LargestTextPaintHandler.ts +35 -0
  213. package/lib/front_end/models/trace/handlers/LayerTreeHandler.ts +123 -0
  214. package/lib/front_end/models/trace/handlers/LayoutShiftsHandler.ts +573 -0
  215. package/lib/front_end/models/trace/handlers/MemoryHandler.ts +31 -0
  216. package/lib/front_end/models/trace/handlers/MetaHandler.ts +525 -0
  217. package/lib/front_end/models/trace/handlers/ModelHandlers.ts +34 -0
  218. package/lib/front_end/models/trace/handlers/NetworkRequestsHandler.ts +672 -0
  219. package/lib/front_end/models/trace/handlers/PageFramesHandler.ts +52 -0
  220. package/lib/front_end/models/trace/handlers/PageLoadMetricsHandler.ts +460 -0
  221. package/lib/front_end/models/trace/handlers/RendererHandler.ts +428 -0
  222. package/lib/front_end/models/trace/handlers/SamplesHandler.ts +271 -0
  223. package/lib/front_end/models/trace/handlers/ScreenshotsHandler.ts +122 -0
  224. package/lib/front_end/models/trace/handlers/ScriptsHandler.ts +336 -0
  225. package/lib/front_end/models/trace/handlers/SelectorStatsHandler.ts +110 -0
  226. package/lib/front_end/models/trace/handlers/Threads.ts +139 -0
  227. package/lib/front_end/models/trace/handlers/UserInteractionsHandler.ts +400 -0
  228. package/lib/front_end/models/trace/handlers/UserTimingsHandler.ts +233 -0
  229. package/lib/front_end/models/trace/handlers/WarningsHandler.ts +162 -0
  230. package/lib/front_end/models/trace/handlers/WorkersHandler.ts +45 -0
  231. package/lib/front_end/models/trace/handlers/handlers.ts +8 -0
  232. package/lib/front_end/models/trace/handlers/helpers.ts +196 -0
  233. package/lib/front_end/models/trace/handlers/types.ts +75 -0
  234. package/lib/front_end/models/trace/helpers/Extensions.ts +54 -0
  235. package/lib/front_end/models/trace/helpers/Network.ts +129 -0
  236. package/lib/front_end/models/trace/helpers/SamplesIntegrator.ts +544 -0
  237. package/lib/front_end/models/trace/helpers/SyntheticEvents.ts +87 -0
  238. package/lib/front_end/models/trace/helpers/Timing.ts +248 -0
  239. package/lib/front_end/models/trace/helpers/Trace.ts +928 -0
  240. package/lib/front_end/models/trace/helpers/TreeHelpers.ts +320 -0
  241. package/lib/front_end/models/trace/helpers/helpers.ts +11 -0
  242. package/lib/front_end/models/trace/insights/CLSCulprits.ts +668 -0
  243. package/lib/front_end/models/trace/insights/Cache.ts +269 -0
  244. package/lib/front_end/models/trace/insights/Common.ts +453 -0
  245. package/lib/front_end/models/trace/insights/DOMSize.ts +223 -0
  246. package/lib/front_end/models/trace/insights/DocumentLatency.ts +319 -0
  247. package/lib/front_end/models/trace/insights/DuplicatedJavaScript.ts +126 -0
  248. package/lib/front_end/models/trace/insights/FontDisplay.ts +119 -0
  249. package/lib/front_end/models/trace/insights/ForcedReflow.ts +220 -0
  250. package/lib/front_end/models/trace/insights/INPBreakdown.ts +171 -0
  251. package/lib/front_end/models/trace/insights/ImageDelivery.ts +348 -0
  252. package/lib/front_end/models/trace/insights/LCPBreakdown.ts +268 -0
  253. package/lib/front_end/models/trace/insights/LCPDiscovery.ts +237 -0
  254. package/lib/front_end/models/trace/insights/LegacyJavaScript.ts +138 -0
  255. package/lib/front_end/models/trace/insights/Models.ts +22 -0
  256. package/lib/front_end/models/trace/insights/ModernHTTP.ts +257 -0
  257. package/lib/front_end/models/trace/insights/NetworkDependencyTree.ts +726 -0
  258. package/lib/front_end/models/trace/insights/RenderBlocking.ts +257 -0
  259. package/lib/front_end/models/trace/insights/SlowCSSSelector.ts +175 -0
  260. package/lib/front_end/models/trace/insights/Statistics.ts +101 -0
  261. package/lib/front_end/models/trace/insights/ThirdParties.ts +130 -0
  262. package/lib/front_end/models/trace/insights/Viewport.ts +138 -0
  263. package/lib/front_end/models/trace/insights/insights.ts +10 -0
  264. package/lib/front_end/models/trace/insights/types.ts +157 -0
  265. package/lib/front_end/models/trace/lantern/core/LanternError.ts +7 -0
  266. package/lib/front_end/models/trace/lantern/core/NetworkAnalyzer.ts +619 -0
  267. package/lib/front_end/models/trace/lantern/core/core.ts +6 -0
  268. package/lib/front_end/models/trace/lantern/graph/BaseNode.ts +345 -0
  269. package/lib/front_end/models/trace/lantern/graph/CPUNode.ts +80 -0
  270. package/lib/front_end/models/trace/lantern/graph/NetworkNode.ts +101 -0
  271. package/lib/front_end/models/trace/lantern/graph/PageDependencyGraph.ts +636 -0
  272. package/lib/front_end/models/trace/lantern/graph/graph.ts +8 -0
  273. package/lib/front_end/models/trace/lantern/lantern.ts +17 -0
  274. package/lib/front_end/models/trace/lantern/metrics/FirstContentfulPaint.ts +187 -0
  275. package/lib/front_end/models/trace/lantern/metrics/Interactive.ts +88 -0
  276. package/lib/front_end/models/trace/lantern/metrics/LargestContentfulPaint.ts +92 -0
  277. package/lib/front_end/models/trace/lantern/metrics/MaxPotentialFID.ts +72 -0
  278. package/lib/front_end/models/trace/lantern/metrics/Metric.ts +126 -0
  279. package/lib/front_end/models/trace/lantern/metrics/SpeedIndex.ts +126 -0
  280. package/lib/front_end/models/trace/lantern/metrics/TBTUtils.ts +82 -0
  281. package/lib/front_end/models/trace/lantern/metrics/TotalBlockingTime.ts +112 -0
  282. package/lib/front_end/models/trace/lantern/metrics/metrics.ts +12 -0
  283. package/lib/front_end/models/trace/lantern/simulation/ConnectionPool.ts +150 -0
  284. package/lib/front_end/models/trace/lantern/simulation/Constants.ts +46 -0
  285. package/lib/front_end/models/trace/lantern/simulation/DNSCache.ts +61 -0
  286. package/lib/front_end/models/trace/lantern/simulation/SimulationTimingMap.ts +196 -0
  287. package/lib/front_end/models/trace/lantern/simulation/Simulator.ts +556 -0
  288. package/lib/front_end/models/trace/lantern/simulation/TCPConnection.ts +192 -0
  289. package/lib/front_end/models/trace/lantern/simulation/simulation.ts +10 -0
  290. package/lib/front_end/models/trace/lantern/types/Lantern.ts +220 -0
  291. package/lib/front_end/models/trace/lantern/types/types.ts +5 -0
  292. package/lib/front_end/models/trace/trace.ts +33 -0
  293. package/lib/front_end/models/trace/types/Configuration.ts +110 -0
  294. package/lib/front_end/models/trace/types/Extensions.ts +136 -0
  295. package/lib/front_end/models/trace/types/File.ts +281 -0
  296. package/lib/front_end/models/trace/types/Overlays.ts +138 -0
  297. package/lib/front_end/models/trace/types/Timing.ts +30 -0
  298. package/lib/front_end/models/trace/types/TraceEvents.ts +3277 -0
  299. package/lib/front_end/models/trace/types/types.ts +10 -0
  300. package/lib/front_end/third_party/i18n/LICENSE +202 -0
  301. package/lib/front_end/third_party/i18n/README.chromium +15 -0
  302. package/lib/front_end/third_party/i18n/i18n-impl.ts +61 -0
  303. package/lib/front_end/third_party/i18n/i18n.ts +11 -0
  304. package/lib/front_end/third_party/i18n/localized-string-set.ts +129 -0
  305. package/lib/front_end/third_party/intl-messageformat/LICENSE +33 -0
  306. package/lib/front_end/third_party/intl-messageformat/README.chromium +24 -0
  307. package/lib/front_end/third_party/intl-messageformat/intl-messageformat-tsconfig.json +16 -0
  308. package/lib/front_end/third_party/intl-messageformat/intl-messageformat.ts +6 -0
  309. package/lib/front_end/third_party/intl-messageformat/package/LICENSE.md +33 -0
  310. package/lib/front_end/third_party/intl-messageformat/package/README.md +3 -0
  311. package/lib/front_end/third_party/intl-messageformat/package/index.d.ts +6 -0
  312. package/lib/front_end/third_party/intl-messageformat/package/index.d.ts.map +1 -0
  313. package/lib/front_end/third_party/intl-messageformat/package/index.js +13 -0
  314. package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.esm.d.ts +5 -0
  315. package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.esm.js +1710 -0
  316. package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.iife.js +1815 -0
  317. package/lib/front_end/third_party/intl-messageformat/package/lib/index.d.ts +6 -0
  318. package/lib/front_end/third_party/intl-messageformat/package/lib/index.d.ts.map +1 -0
  319. package/lib/front_end/third_party/intl-messageformat/package/lib/index.js +10 -0
  320. package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.d.ts +34 -0
  321. package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.d.ts.map +1 -0
  322. package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.js +229 -0
  323. package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.d.ts +28 -0
  324. package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.d.ts.map +1 -0
  325. package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.js +48 -0
  326. package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.d.ts +34 -0
  327. package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.d.ts.map +1 -0
  328. package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.js +179 -0
  329. package/lib/front_end/third_party/intl-messageformat/package/package.json +42 -0
  330. package/lib/front_end/third_party/intl-messageformat/package/src/core.d.ts +34 -0
  331. package/lib/front_end/third_party/intl-messageformat/package/src/core.d.ts.map +1 -0
  332. package/lib/front_end/third_party/intl-messageformat/package/src/core.js +230 -0
  333. package/lib/front_end/third_party/intl-messageformat/package/src/error.d.ts +28 -0
  334. package/lib/front_end/third_party/intl-messageformat/package/src/error.d.ts.map +1 -0
  335. package/lib/front_end/third_party/intl-messageformat/package/src/error.js +51 -0
  336. package/lib/front_end/third_party/intl-messageformat/package/src/formatters.d.ts +34 -0
  337. package/lib/front_end/third_party/intl-messageformat/package/src/formatters.d.ts.map +1 -0
  338. package/lib/front_end/third_party/intl-messageformat/package/src/formatters.js +182 -0
  339. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/error.d.ts +79 -0
  340. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/index.d.ts +15 -0
  341. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/parser.d.ts +153 -0
  342. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/types.d.ts +139 -0
  343. package/lib/front_end/third_party/legacy-javascript/LICENSE +202 -0
  344. package/lib/front_end/third_party/legacy-javascript/README.chromium +13 -0
  345. package/lib/front_end/third_party/legacy-javascript/legacy-javascript-tsconfig.json +8 -0
  346. package/lib/front_end/third_party/legacy-javascript/legacy-javascript.ts +3 -0
  347. package/lib/front_end/third_party/legacy-javascript/lib/legacy-javascript.d.ts +18 -0
  348. package/lib/front_end/third_party/legacy-javascript/lib/legacy-javascript.js +943 -0
  349. package/lib/front_end/third_party/legacy-javascript/package.json +8 -0
  350. package/lib/front_end/third_party/legacy-javascript/rebuild.sh +9 -0
  351. package/lib/front_end/third_party/third-party-web/LICENSE +20 -0
  352. package/lib/front_end/third_party/third-party-web/README.chromium +13 -0
  353. package/lib/front_end/third_party/third-party-web/lib/nostats-subset.d.ts +2 -0
  354. package/lib/front_end/third_party/third-party-web/lib/nostats-subset.js +149 -0
  355. package/lib/front_end/third_party/third-party-web/package/LICENSE +20 -0
  356. package/lib/front_end/third_party/third-party-web/package/README.md +929 -0
  357. package/lib/front_end/third_party/third-party-web/package/dist/entities-httparchive-nostats.json +1 -0
  358. package/lib/front_end/third_party/third-party-web/package/dist/entities-httparchive.json +1 -0
  359. package/lib/front_end/third_party/third-party-web/package/dist/entities-nostats.json +1 -0
  360. package/lib/front_end/third_party/third-party-web/package/dist/entities.json +1 -0
  361. package/lib/front_end/third_party/third-party-web/package/facades.md +46 -0
  362. package/lib/front_end/third_party/third-party-web/package/httparchive-nostats-subset.d.ts +1 -0
  363. package/lib/front_end/third_party/third-party-web/package/httparchive-nostats-subset.js +1 -0
  364. package/lib/front_end/third_party/third-party-web/package/httparchive-subset.d.ts +1 -0
  365. package/lib/front_end/third_party/third-party-web/package/httparchive-subset.js +1 -0
  366. package/lib/front_end/third_party/third-party-web/package/lib/__snapshots__/index.test.js.snap +1006 -0
  367. package/lib/front_end/third_party/third-party-web/package/lib/create-entity-finder-api.js +139 -0
  368. package/lib/front_end/third_party/third-party-web/package/lib/create-entity-finder-api.test.js +44 -0
  369. package/lib/front_end/third_party/third-party-web/package/lib/entities.test.js +27 -0
  370. package/lib/front_end/third_party/third-party-web/package/lib/index.d.ts +34 -0
  371. package/lib/front_end/third_party/third-party-web/package/lib/index.js +3 -0
  372. package/lib/front_end/third_party/third-party-web/package/lib/index.test.js +246 -0
  373. package/lib/front_end/third_party/third-party-web/package/lib/markdown/faqs.partial.md +36 -0
  374. package/lib/front_end/third_party/third-party-web/package/lib/markdown/goals.partial.md +9 -0
  375. package/lib/front_end/third_party/third-party-web/package/lib/markdown/methodology.partial.md +5 -0
  376. package/lib/front_end/third_party/third-party-web/package/lib/markdown/template.md +151 -0
  377. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-02-01.md +1 -0
  378. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-03-01.md +1 -0
  379. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-05-06.md +1 -0
  380. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-05-13.md +14 -0
  381. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2021-01-01.md +1 -0
  382. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2024-07-01.md +3 -0
  383. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive-nostats.d.ts +1 -0
  384. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive-nostats.js +3 -0
  385. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive.d.ts +1 -0
  386. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive.js +3 -0
  387. package/lib/front_end/third_party/third-party-web/package/lib/subsets/nostats.d.ts +1 -0
  388. package/lib/front_end/third_party/third-party-web/package/lib/subsets/nostats.js +3 -0
  389. package/lib/front_end/third_party/third-party-web/package/nostats-subset.d.ts +1 -0
  390. package/lib/front_end/third_party/third-party-web/package/nostats-subset.js +1 -0
  391. package/lib/front_end/third_party/third-party-web/package/package.json +46 -0
  392. package/lib/front_end/third_party/third-party-web/package.json +8 -0
  393. package/lib/front_end/third_party/third-party-web/rebuild.sh +13 -0
  394. package/lib/front_end/third_party/third-party-web/third-party-web-tsconfig.json +8 -0
  395. package/lib/front_end/third_party/third-party-web/third-party-web.ts +3 -0
  396. package/package.json +24 -0
  397. package/patches/chrome-devtools-frontend+1.0.1533544.patch +187 -0
@@ -0,0 +1,508 @@
1
+ // Copyright 2024 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 Protocol from '../../generated/protocol.js';
6
+ import * as Formatter from '../../models/formatter/formatter.js';
7
+ import type * as TextUtils from '../../models/text_utils/text_utils.js';
8
+ import type * as ScopesCodec from '../../third_party/source-map-scopes-codec/source-map-scopes-codec.js';
9
+ import type * as Platform from '../platform/platform.js';
10
+
11
+ import type {CallFrame, ScopeChainEntry} from './DebuggerModel.js';
12
+ import type {SourceMap} from './SourceMap.js';
13
+ import {SourceMapScopeChainEntry} from './SourceMapScopeChainEntry.js';
14
+
15
+ export class SourceMapScopesInfo {
16
+ readonly #sourceMap: SourceMap;
17
+ readonly #originalScopes: Array<ScopesCodec.OriginalScope|null>;
18
+ readonly #generatedRanges: ScopesCodec.GeneratedRange[];
19
+
20
+ #cachedVariablesAndBindingsPresent: boolean|null = null;
21
+
22
+ constructor(sourceMap: SourceMap, scopeInfo: ScopesCodec.ScopeInfo) {
23
+ this.#sourceMap = sourceMap;
24
+ this.#originalScopes = scopeInfo.scopes;
25
+ this.#generatedRanges = scopeInfo.ranges;
26
+ }
27
+
28
+ /**
29
+ * If the source map does not contain any scopes information, this factory function attempts to create bare bones scope information
30
+ * via the script's AST combined with the mappings.
31
+ *
32
+ * We create the generated ranges from the scope tree and for each range we create an original scope that matches the bounds 1:1.
33
+ * We don't map the bounds via mappings as mappings are often iffy and it's not strictly required to translate stack traces where we
34
+ * map call-sites separately.
35
+ */
36
+ static createFromAst(
37
+ sourceMap: SourceMap, scopeTree: Formatter.FormatterWorkerPool.ScopeTreeNode,
38
+ text: TextUtils.Text.Text): SourceMapScopesInfo {
39
+ const {scope, range} = convertScope(scopeTree, undefined, undefined);
40
+ return new SourceMapScopesInfo(sourceMap, {scopes: [scope], ranges: [range]});
41
+
42
+ function convertScope(
43
+ node: Formatter.FormatterWorkerPool.ScopeTreeNode, parentScope: ScopesCodec.OriginalScope|undefined,
44
+ parentRange: ScopesCodec.GeneratedRange|
45
+ undefined): {scope: ScopesCodec.OriginalScope, range: ScopesCodec.GeneratedRange} {
46
+ const start = positionFromOffset(node.start);
47
+ const end = positionFromOffset(node.end);
48
+ const isStackFrame = node.kind === Formatter.FormatterWorkerPool.ScopeKind.FUNCTION;
49
+
50
+ const scope: ScopesCodec.OriginalScope = {
51
+ start,
52
+ end,
53
+ name: sourceMap.findEntry(start.line, start.column, 0)?.name,
54
+ isStackFrame,
55
+ variables: [],
56
+ children: [],
57
+ };
58
+
59
+ const range: ScopesCodec.GeneratedRange = {
60
+ start,
61
+ end,
62
+ originalScope: scope,
63
+ isStackFrame,
64
+ isHidden: false,
65
+ values: [],
66
+ children: [],
67
+ };
68
+
69
+ parentRange?.children.push(range);
70
+ parentScope?.children.push(scope);
71
+
72
+ node.children.forEach(child => convertScope(child, scope, range));
73
+
74
+ return {scope, range};
75
+ }
76
+
77
+ function positionFromOffset(offset: number): ScopesCodec.Position {
78
+ const location = text.positionFromOffset(offset);
79
+ return {line: location.lineNumber, column: location.columnNumber};
80
+ }
81
+ }
82
+
83
+ addOriginalScopes(scopes: Array<ScopesCodec.OriginalScope|null>): void {
84
+ for (const scope of scopes) {
85
+ this.#originalScopes.push(scope);
86
+ }
87
+ }
88
+
89
+ addGeneratedRanges(ranges: ScopesCodec.GeneratedRange[]): void {
90
+ for (const range of ranges) {
91
+ this.#generatedRanges.push(range);
92
+ }
93
+ }
94
+
95
+ hasOriginalScopes(sourceIdx: number): boolean {
96
+ return Boolean(this.#originalScopes[sourceIdx]);
97
+ }
98
+
99
+ isEmpty(): boolean {
100
+ return !this.#originalScopes.length && !this.#generatedRanges.length;
101
+ }
102
+
103
+ addOriginalScopesAtIndex(sourceIdx: number, scope: ScopesCodec.OriginalScope): void {
104
+ if (!this.#originalScopes[sourceIdx]) {
105
+ this.#originalScopes[sourceIdx] = scope;
106
+ } else {
107
+ throw new Error(`Trying to re-augment existing scopes for source at index: ${sourceIdx}`);
108
+ }
109
+ }
110
+
111
+ /**
112
+ * @returns true, iff the function surrounding the provided position is marked as "hidden".
113
+ */
114
+ isOutlinedFrame(generatedLine: number, generatedColumn: number): boolean {
115
+ const rangeChain = this.#findGeneratedRangeChain(generatedLine, generatedColumn);
116
+ return this.#isOutlinedFrame(rangeChain);
117
+ }
118
+
119
+ #isOutlinedFrame(rangeChain: ScopesCodec.GeneratedRange[]): boolean {
120
+ for (let i = rangeChain.length - 1; i >= 0; --i) {
121
+ if (rangeChain[i].isStackFrame) {
122
+ return rangeChain[i].isHidden;
123
+ }
124
+ }
125
+ return false;
126
+ }
127
+
128
+ /**
129
+ * @returns true, iff the range surrounding the provided position contains multiple
130
+ * inlined original functions.
131
+ */
132
+ hasInlinedFrames(generatedLine: number, generatedColumn: number): boolean {
133
+ const rangeChain = this.#findGeneratedRangeChain(generatedLine, generatedColumn);
134
+ for (let i = rangeChain.length - 1; i >= 0; --i) {
135
+ if (rangeChain[i].isStackFrame) {
136
+ // We stop looking for inlined original functions once we reach the current frame.
137
+ return false;
138
+ }
139
+ if (rangeChain[i].callSite) {
140
+ return true;
141
+ }
142
+ }
143
+ return false;
144
+ }
145
+
146
+ /**
147
+ * Given a generated position, returns the original name of the surrounding function as well as
148
+ * all the original function names that got inlined into the surrounding generated function and their
149
+ * respective callsites in the original code (ordered from inner to outer).
150
+ *
151
+ * @returns a list with inlined functions. Every entry in the list has a callsite in the orignal code,
152
+ * except the last function (since the last function didn't get inlined).
153
+ */
154
+ findInlinedFunctions(generatedLine: number, generatedColumn: number): InlineInfo {
155
+ const rangeChain = this.#findGeneratedRangeChain(generatedLine, generatedColumn);
156
+ const result: InlineInfo = {
157
+ inlinedFunctions: [],
158
+ originalFunctionName: '',
159
+ };
160
+
161
+ // Walk the generated ranges from the innermost containing range outwards as long as we don't
162
+ // encounter a range that is a scope in the generated code and a function scope originally.
163
+ for (let i = rangeChain.length - 1; i >= 0; --i) {
164
+ const range = rangeChain[i];
165
+
166
+ if (range.callSite) {
167
+ // Record the name and call-site if the range corresponds to an inlined function.
168
+ result.inlinedFunctions.push({
169
+ name: range.originalScope?.name ?? '',
170
+ callsite: {...range.callSite, sourceURL: this.#sourceMap.sourceURLForSourceIndex(range.callSite.sourceIndex)}
171
+ });
172
+ }
173
+ if (range.isStackFrame) {
174
+ // We arrived at an actual generated JS function, don't go further.
175
+ // The corresponding original scope could not actually be a function
176
+ // (e.g. a block scope transpiled down to a JS function), but we'll
177
+ // filter that out later.
178
+ result.originalFunctionName = range.originalScope?.name ?? '';
179
+ break;
180
+ }
181
+ }
182
+
183
+ return result;
184
+ }
185
+
186
+ /**
187
+ * Takes a V8 provided call frame and expands any inlined frames into virtual call frames.
188
+ *
189
+ * For call frames where nothing was inlined, the result contains only a single element,
190
+ * the provided frame but with the original name.
191
+ *
192
+ * For call frames where we are paused in inlined code, this function returns a list of
193
+ * call frames from "inner to outer". This is the call frame at index 0
194
+ * signifies the top of this stack trace fragment.
195
+ *
196
+ * The rest are "virtual" call frames and will have an "inlineFrameIndex" set in ascending
197
+ * order, so the condition `result[index] === result[index].inlineFrameIndex` always holds.
198
+ */
199
+ expandCallFrame(callFrame: CallFrame): CallFrame[] {
200
+ const {originalFunctionName, inlinedFunctions} =
201
+ this.findInlinedFunctions(callFrame.location().lineNumber, callFrame.location().columnNumber);
202
+ const result: CallFrame[] = [];
203
+ for (const [index, fn] of inlinedFunctions.entries()) {
204
+ result.push(callFrame.createVirtualCallFrame(index, fn.name));
205
+ }
206
+ result.push(callFrame.createVirtualCallFrame(result.length, originalFunctionName));
207
+ return result;
208
+ }
209
+
210
+ /**
211
+ * Given a generated position, this returns all the surrounding generated ranges from outer
212
+ * to inner.
213
+ */
214
+ #findGeneratedRangeChain(line: number, column: number): ScopesCodec.GeneratedRange[] {
215
+ const result: ScopesCodec.GeneratedRange[] = [];
216
+
217
+ (function walkRanges(ranges: ScopesCodec.GeneratedRange[]) {
218
+ for (const range of ranges) {
219
+ if (!contains(range, line, column)) {
220
+ continue;
221
+ }
222
+ result.push(range);
223
+ walkRanges(range.children);
224
+ }
225
+ })(this.#generatedRanges);
226
+
227
+ return result;
228
+ }
229
+
230
+ /**
231
+ * @returns true if we have enough info (i.e. variable and binding expressions) to build
232
+ * a scope view.
233
+ */
234
+ hasVariablesAndBindings(): boolean {
235
+ if (this.#cachedVariablesAndBindingsPresent === null) {
236
+ this.#cachedVariablesAndBindingsPresent = this.#areVariablesAndBindingsPresent();
237
+ }
238
+ return this.#cachedVariablesAndBindingsPresent;
239
+ }
240
+
241
+ #areVariablesAndBindingsPresent(): boolean {
242
+ // We check whether any original scope has a non-empty list of variables, and
243
+ // generated ranges with a non-empty binding list.
244
+
245
+ function walkTree(nodes: Array<ScopesCodec.OriginalScope|null>|ScopesCodec.GeneratedRange[]): boolean {
246
+ for (const node of nodes) {
247
+ if (!node) {
248
+ continue;
249
+ }
250
+
251
+ if ('variables' in node && node.variables.length > 0) {
252
+ return true;
253
+ }
254
+
255
+ if ('values' in node && node.values.some(v => v !== null)) {
256
+ return true;
257
+ }
258
+
259
+ if (walkTree(node.children)) {
260
+ return true;
261
+ }
262
+ }
263
+ return false;
264
+ }
265
+ return walkTree(this.#originalScopes) && walkTree(this.#generatedRanges);
266
+ }
267
+
268
+ /**
269
+ * Constructs a scope chain based on the CallFrame's paused position.
270
+ *
271
+ * The algorithm to obtain the original scope chain is straight-forward:
272
+ *
273
+ * 1) Find the inner-most generated range that contains the CallFrame's
274
+ * paused position.
275
+ *
276
+ * 2) Does the found range have an associated original scope?
277
+ *
278
+ * 2a) If no, return null. This is a "hidden" range and technically
279
+ * we shouldn't be pausing here in the first place. This code doesn't
280
+ * correspond to anything in the authored code.
281
+ *
282
+ * 2b) If yes, the associated original scope is the inner-most
283
+ * original scope in the resulting scope chain.
284
+ *
285
+ * 3) Walk the parent chain of the found original scope outwards. This is
286
+ * our scope view. For each original scope we also try to find a
287
+ * corresponding generated range that contains the CallFrame's
288
+ * paused position. We need the generated range to resolve variable
289
+ * values.
290
+ */
291
+ resolveMappedScopeChain(callFrame: CallFrame): ScopeChainEntry[]|null {
292
+ const rangeChain = this.#findGeneratedRangeChainForFrame(callFrame);
293
+ const innerMostOriginalScope = rangeChain.at(-1)?.originalScope;
294
+ if (innerMostOriginalScope === undefined) {
295
+ return null;
296
+ }
297
+
298
+ // TODO(crbug.com/40277685): Add a sanity check here where we map the paused position using
299
+ // the source map's mappings, find the inner-most original scope with that mapped paused
300
+ // position and compare that result with `innerMostOriginalScope`. If they don't match we
301
+ // should emit a warning about the broken source map as mappings and scopes are inconsistent
302
+ // w.r.t. each other.
303
+
304
+ let seenFunctionScope = false;
305
+ const result: SourceMapScopeChainEntry[] = [];
306
+ // Walk the original scope chain outwards and try to find the corresponding generated range along the way.
307
+ for (let originalScope = rangeChain.at(-1)?.originalScope; originalScope; originalScope = originalScope.parent) {
308
+ const range = rangeChain.findLast(r => r.originalScope === originalScope);
309
+ const isFunctionScope = originalScope.kind === 'function';
310
+ const isInnerMostFunction = isFunctionScope && !seenFunctionScope;
311
+ const returnValue = isInnerMostFunction ? callFrame.returnValue() : null;
312
+ result.push(
313
+ new SourceMapScopeChainEntry(callFrame, originalScope, range, isInnerMostFunction, returnValue ?? undefined));
314
+ seenFunctionScope ||= isFunctionScope;
315
+ }
316
+
317
+ // If we are paused on a return statement, we need to drop inner block scopes. This is because V8 only emits a
318
+ // single return bytecode and "gotos" at the functions' end, where we are now paused.
319
+ if (callFrame.returnValue() !== null) {
320
+ while (result.length && result[0].type() !== Protocol.Debugger.ScopeType.Local) {
321
+ result.shift();
322
+ }
323
+ }
324
+
325
+ return result;
326
+ }
327
+
328
+ /** Similar to #findGeneratedRangeChain, but takes inlineFrameIndex of virtual call frames into account */
329
+ #findGeneratedRangeChainForFrame(callFrame: CallFrame): ScopesCodec.GeneratedRange[] {
330
+ const rangeChain =
331
+ this.#findGeneratedRangeChain(callFrame.location().lineNumber, callFrame.location().columnNumber);
332
+ if (callFrame.inlineFrameIndex === 0) {
333
+ return rangeChain;
334
+ }
335
+
336
+ // Drop ranges in the chain until we reach our desired inlined range.
337
+ for (let inlineIndex = 0; inlineIndex < callFrame.inlineFrameIndex;) {
338
+ const range = rangeChain.pop();
339
+ if (range?.callSite) {
340
+ ++inlineIndex;
341
+ }
342
+ }
343
+
344
+ return rangeChain;
345
+ }
346
+
347
+ /**
348
+ * Returns the authored function name of the function containing the provided generated position.
349
+ */
350
+ findOriginalFunctionName({line, column}: ScopesCodec.Position): string|null {
351
+ // There are 2 approaches:
352
+ // 1) Find the inner-most generated range containing the provided generated position
353
+ // and use it's OriginalScope (then walk it outwards until we hit a function).
354
+ // 2) Use the mappings to turn the generated position into an original position.
355
+ // Then find the inner-most original scope containing that original position.
356
+ // Then walk it outwards until we hit a function.
357
+ //
358
+ // Both approaches should yield the same result (assuming the mappings are spec compliant
359
+ // w.r.t. generated ranges). But in the case of "pasta" scopes and extension provided
360
+ // scope info, we only have the OriginalScope parts and mappings without GeneratedRanges.
361
+
362
+ let originalInnerMostScope: ScopesCodec.OriginalScope|undefined;
363
+
364
+ if (this.#generatedRanges.length > 0) {
365
+ const rangeChain = this.#findGeneratedRangeChain(line, column);
366
+ originalInnerMostScope = rangeChain.at(-1)?.originalScope;
367
+ } else {
368
+ // No GeneratedRanges. Try to use mappings.
369
+ const entry = this.#sourceMap.findEntry(line, column);
370
+ if (entry?.sourceIndex === undefined) {
371
+ return null;
372
+ }
373
+ originalInnerMostScope =
374
+ this.#findOriginalScopeChain(
375
+ {sourceIndex: entry.sourceIndex, line: entry.sourceLineNumber, column: entry.sourceColumnNumber})
376
+ .at(-1);
377
+ }
378
+
379
+ return this.#findFunctionNameInOriginalScopeChain(originalInnerMostScope) ?? null;
380
+ }
381
+
382
+ /**
383
+ * Given an original position, this returns all the surrounding original scopes from outer
384
+ * to inner.
385
+ */
386
+ #findOriginalScopeChain({sourceIndex, line, column}: ScopesCodec.OriginalPosition): ScopesCodec.OriginalScope[] {
387
+ const scope = this.#originalScopes[sourceIndex];
388
+ if (!scope) {
389
+ return [];
390
+ }
391
+
392
+ const result: ScopesCodec.OriginalScope[] = [];
393
+ (function walkScopes(scopes: ScopesCodec.OriginalScope[]) {
394
+ for (const scope of scopes) {
395
+ if (!contains(scope, line, column)) {
396
+ continue;
397
+ }
398
+ result.push(scope);
399
+ walkScopes(scope.children);
400
+ }
401
+ })([scope]);
402
+
403
+ return result;
404
+ }
405
+
406
+ #findFunctionNameInOriginalScopeChain(innerOriginalScope: ScopesCodec.OriginalScope|undefined): string|null {
407
+ for (let originalScope = innerOriginalScope; originalScope; originalScope = originalScope.parent) {
408
+ if (originalScope.isStackFrame) {
409
+ return originalScope.name ?? '';
410
+ }
411
+ }
412
+ return null;
413
+ }
414
+
415
+ /**
416
+ * Returns one or more original stack frames for this single "raw frame" or call-site.
417
+ *
418
+ * @returns An empty array if no mapping at the call-site was found, or the resulting frames
419
+ * in top-to-bottom order in case of inlining.
420
+ * @throws If this range is marked "hidden". Outlining needs to be handled externally as
421
+ * outlined function segments in stack traces can span across bundles.
422
+ */
423
+ translateCallSite(generatedLine: number, generatedColumn: number): TranslatedFrame[] {
424
+ const rangeChain = this.#findGeneratedRangeChain(generatedLine, generatedColumn);
425
+ if (this.#isOutlinedFrame(rangeChain)) {
426
+ throw new Error('SourceMapScopesInfo is unable to translate an outlined function by itself');
427
+ }
428
+
429
+ const mapping = this.#sourceMap.findEntry(generatedLine, generatedColumn);
430
+ if (mapping?.sourceIndex === undefined) {
431
+ return [];
432
+ }
433
+
434
+ // The top-most frame is translated the same even if we have inlined functions.
435
+ const result: TranslatedFrame[] = [{
436
+ line: mapping.sourceLineNumber,
437
+ column: mapping.sourceColumnNumber,
438
+ name: this.findOriginalFunctionName({line: generatedLine, column: generatedColumn}) ?? undefined,
439
+ url: mapping.sourceURL,
440
+ }];
441
+
442
+ // Walk the range chain inside out until we find a generated function and for each inlined function add a frame.
443
+ for (let i = rangeChain.length - 1; i >= 0 && !rangeChain[i].isStackFrame; --i) {
444
+ const range = rangeChain[i];
445
+ if (!range.callSite) {
446
+ continue;
447
+ }
448
+
449
+ const originalScopeChain = this.#findOriginalScopeChain(range.callSite);
450
+ result.push({
451
+ line: range.callSite.line,
452
+ column: range.callSite.column,
453
+ name: this.#findFunctionNameInOriginalScopeChain(originalScopeChain.at(-1)) ?? undefined,
454
+ url: this.#sourceMap.sourceURLForSourceIndex(range.callSite.sourceIndex),
455
+ });
456
+ }
457
+
458
+ return result;
459
+ }
460
+ }
461
+
462
+ /**
463
+ * Represents a stack frame in original terms. It closely aligns with StackTrace.StackTrace.Frame,
464
+ * but since we can't import that type here we mirror it here somewhat.
465
+ *
466
+ * Equivalent to Pick<StackTrace.StackTrace.Frame, 'line'|'column'|'name'|'url'>.
467
+ */
468
+ export interface TranslatedFrame {
469
+ line: number;
470
+ column: number;
471
+ name?: string;
472
+ url?: Platform.DevToolsPath.UrlString;
473
+ }
474
+
475
+ /**
476
+ * Represents the inlining information for a given generated position.
477
+ *
478
+ * It contains a list of all the inlined original functions at the generated position
479
+ * as well as the original function name of the generated position's surrounding
480
+ * function.
481
+ *
482
+ * The inlined functions are sorted from inner to outer (or top to bottom on the stack).
483
+ */
484
+ export interface InlineInfo {
485
+ inlinedFunctions: Array<{
486
+ name: string,
487
+ callsite: {
488
+ line: number,
489
+ column: number,
490
+ sourceIndex: number,
491
+ sourceURL?: Platform.DevToolsPath.UrlString,
492
+ },
493
+ }>;
494
+ originalFunctionName: string;
495
+ }
496
+
497
+ export function contains(
498
+ range: Pick<ScopesCodec.GeneratedRange, 'start'|'end'>, line: number, column: number): boolean {
499
+ if (range.start.line > line || (range.start.line === line && range.start.column > column)) {
500
+ return false;
501
+ }
502
+
503
+ if (range.end.line < line || (range.end.line === line && range.end.column <= column)) {
504
+ return false;
505
+ }
506
+
507
+ return true;
508
+ }