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,82 @@
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
+ const BLOCKING_TIME_THRESHOLD = 50;
6
+
7
+ /**
8
+ * For TBT, We only want to consider tasks that fall in our time range
9
+ * - FCP and TTI for navigation mode
10
+ * - Trace start and trace end for timespan mode
11
+ *
12
+ * FCP is picked as `startTimeMs` because there is little risk of user input happening
13
+ * before FCP so Long Queuing Qelay regions do not harm user experience. Developers should be
14
+ * optimizing to reach FCP as fast as possible without having to worry about task lengths.
15
+ *
16
+ * TTI is picked as `endTimeMs` because we want a well defined end point for page load.
17
+ *
18
+ * @param startTimeMs Should be FCP in navigation mode and the trace start time in timespan mode
19
+ * @param endTimeMs Should be TTI in navigation mode and the trace end time in timespan mode
20
+ * @param topLevelEvent Leave unset if `event` is top level. Has no effect if `event` has the same duration as `topLevelEvent`.
21
+ */
22
+ function calculateTbtImpactForEvent(
23
+ event: {start: number, end: number, duration: number}, startTimeMs: number, endTimeMs: number,
24
+ topLevelEvent?: {start: number, end: number, duration: number}): number {
25
+ let threshold = BLOCKING_TIME_THRESHOLD;
26
+
27
+ // If a task is not top level, it doesn't make sense to subtract the entire 50ms
28
+ // blocking threshold from the event.
29
+ //
30
+ // e.g. A 80ms top level task with two 40ms children should attribute some blocking
31
+ // time to the 40ms tasks even though they do not meet the 50ms threshold.
32
+ //
33
+ // The solution is to scale the threshold for child events to be considered blocking.
34
+ if (topLevelEvent) {
35
+ threshold *= (event.duration / topLevelEvent.duration);
36
+ }
37
+
38
+ if (event.duration < threshold) {
39
+ return 0;
40
+ }
41
+ if (event.end < startTimeMs) {
42
+ return 0;
43
+ }
44
+ if (event.start > endTimeMs) {
45
+ return 0;
46
+ }
47
+
48
+ // Perform the clipping and then calculate Blocking Region. So if we have a 150ms task
49
+ // [0, 150] and `startTimeMs` is at 50ms, we first clip the task to [50, 150], and then
50
+ // calculate the Blocking Region to be [100, 150]. The rational here is that tasks before
51
+ // the start time are unimportant, so we care whether the main thread is busy more than
52
+ // 50ms at a time only after the start time.
53
+ const clippedStart = Math.max(event.start, startTimeMs);
54
+ const clippedEnd = Math.min(event.end, endTimeMs);
55
+ const clippedDuration = clippedEnd - clippedStart;
56
+ if (clippedDuration < threshold) {
57
+ return 0;
58
+ }
59
+
60
+ return clippedDuration - threshold;
61
+ }
62
+
63
+ function calculateSumOfBlockingTime(
64
+ topLevelEvents: Array<{start: number, end: number, duration: number}>, startTimeMs: number,
65
+ endTimeMs: number): number {
66
+ if (endTimeMs <= startTimeMs) {
67
+ return 0;
68
+ }
69
+
70
+ let sumBlockingTime = 0;
71
+ for (const event of topLevelEvents) {
72
+ sumBlockingTime += calculateTbtImpactForEvent(event, startTimeMs, endTimeMs);
73
+ }
74
+
75
+ return sumBlockingTime;
76
+ }
77
+
78
+ export {
79
+ BLOCKING_TIME_THRESHOLD,
80
+ calculateSumOfBlockingTime,
81
+ calculateTbtImpactForEvent,
82
+ };
@@ -0,0 +1,112 @@
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 Core from '../core/core.js';
6
+ import * as Graph from '../graph/graph.js';
7
+ import type * as Simulation from '../simulation/simulation.js';
8
+
9
+ import {
10
+ type Extras,
11
+ Metric,
12
+ type MetricCoefficients,
13
+ type MetricComputationDataInput,
14
+ type MetricResult,
15
+ } from './Metric.js';
16
+ import {BLOCKING_TIME_THRESHOLD, calculateSumOfBlockingTime} from './TBTUtils.js';
17
+
18
+ class TotalBlockingTime extends Metric {
19
+ static override get coefficients(): MetricCoefficients {
20
+ return {
21
+ intercept: 0,
22
+ optimistic: 0.5,
23
+ pessimistic: 0.5,
24
+ };
25
+ }
26
+
27
+ static override getOptimisticGraph(dependencyGraph: Graph.Node): Graph.Node {
28
+ return dependencyGraph;
29
+ }
30
+
31
+ static override getPessimisticGraph(dependencyGraph: Graph.Node): Graph.Node {
32
+ return dependencyGraph;
33
+ }
34
+
35
+ static override getEstimateFromSimulation(simulation: Simulation.Result, extras: Extras): Simulation.Result {
36
+ if (!extras.fcpResult) {
37
+ throw new Core.LanternError('missing fcpResult');
38
+ }
39
+ if (!extras.interactiveResult) {
40
+ throw new Core.LanternError('missing interactiveResult');
41
+ }
42
+
43
+ // Intentionally use the opposite FCP estimate. A pessimistic FCP is higher than equal to an
44
+ // optimistic FCP, which means potentially more tasks are excluded from the Total Blocking Time
45
+ // computation. So a more pessimistic FCP gives a more optimistic Total Blocking Time for the
46
+ // same work.
47
+ const fcpTimeInMs = extras.optimistic ? extras.fcpResult.pessimisticEstimate.timeInMs :
48
+ extras.fcpResult.optimisticEstimate.timeInMs;
49
+
50
+ // Similarly, we always have pessimistic TTI >= optimistic TTI. Therefore, picking optimistic
51
+ // TTI means our window of interest is smaller and thus potentially more tasks are excluded from
52
+ // Total Blocking Time computation, yielding a lower (more optimistic) Total Blocking Time value
53
+ // for the same work.
54
+ const interactiveTimeMs = extras.optimistic ? extras.interactiveResult.optimisticEstimate.timeInMs :
55
+ extras.interactiveResult.pessimisticEstimate.timeInMs;
56
+
57
+ const minDurationMs = BLOCKING_TIME_THRESHOLD;
58
+
59
+ const events = TotalBlockingTime.getTopLevelEvents(
60
+ simulation.nodeTimings,
61
+ minDurationMs,
62
+ );
63
+
64
+ return {
65
+ timeInMs: calculateSumOfBlockingTime(
66
+ events,
67
+ fcpTimeInMs,
68
+ interactiveTimeMs,
69
+ ),
70
+ nodeTimings: simulation.nodeTimings,
71
+ };
72
+ }
73
+
74
+ static override compute(data: MetricComputationDataInput, extras?: Omit<Extras, 'optimistic'>): MetricResult {
75
+ const fcpResult = extras?.fcpResult;
76
+ if (!fcpResult) {
77
+ throw new Core.LanternError('FCP is required to calculate the TBT metric');
78
+ }
79
+
80
+ const interactiveResult = extras?.fcpResult;
81
+ if (!interactiveResult) {
82
+ throw new Core.LanternError('Interactive is required to calculate the TBT metric');
83
+ }
84
+
85
+ return super.compute(data, extras);
86
+ }
87
+
88
+ static getTopLevelEvents(nodeTimings: Simulation.Result['nodeTimings'], minDurationMs: number):
89
+ Array<{start: number, end: number, duration: number}> {
90
+ const events: Array<{start: number, end: number, duration: number}> = [];
91
+
92
+ for (const [node, timing] of nodeTimings.entries()) {
93
+ if (node.type !== Graph.BaseNode.types.CPU) {
94
+ continue;
95
+ }
96
+ // Filtering out events below minimum duration.
97
+ if (timing.duration < minDurationMs) {
98
+ continue;
99
+ }
100
+
101
+ events.push({
102
+ start: timing.startTime,
103
+ end: timing.endTime,
104
+ duration: timing.duration,
105
+ });
106
+ }
107
+
108
+ return events;
109
+ }
110
+ }
111
+
112
+ export {TotalBlockingTime};
@@ -0,0 +1,12 @@
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
+ export * from './FirstContentfulPaint.js';
6
+ export * from './Interactive.js';
7
+ export * from './LargestContentfulPaint.js';
8
+ export * from './MaxPotentialFID.js';
9
+ export * from './Metric.js';
10
+ export * from './SpeedIndex.js';
11
+ export * from './TotalBlockingTime.js';
12
+ export * as TBTUtils from './TBTUtils.js';
@@ -0,0 +1,150 @@
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 Core from '../core/core.js';
6
+ import type * as Lantern from '../types/types.js';
7
+
8
+ import {TCPConnection} from './TCPConnection.js';
9
+
10
+ const DEFAULT_SERVER_RESPONSE_TIME = 30;
11
+ const TLS_SCHEMES = ['https', 'wss'];
12
+
13
+ // Each origin can have 6 simultaneous connections open
14
+ // https://cs.chromium.org/chromium/src/net/socket/client_socket_pool_manager.cc?type=cs&q="int+g_max_sockets_per_group"
15
+ const CONNECTIONS_PER_ORIGIN = 6;
16
+
17
+ export class ConnectionPool {
18
+ options: Required<Lantern.Simulation.Options>;
19
+ records: Lantern.NetworkRequest[];
20
+ connectionsByOrigin: Map<string, TCPConnection[]>;
21
+ connectionsByRequest: Map<Lantern.NetworkRequest, TCPConnection>;
22
+ _connectionsInUse: Set<TCPConnection>;
23
+ connectionReusedByRequestId: Map<string, boolean>;
24
+
25
+ constructor(records: Lantern.NetworkRequest[], options: Required<Lantern.Simulation.Options>) {
26
+ this.options = options;
27
+
28
+ this.records = records;
29
+ this.connectionsByOrigin = new Map();
30
+ this.connectionsByRequest = new Map();
31
+ this._connectionsInUse = new Set();
32
+ this.connectionReusedByRequestId = Core.NetworkAnalyzer.estimateIfConnectionWasReused(records, {
33
+ forceCoarseEstimates: true,
34
+ });
35
+
36
+ this.initializeConnections();
37
+ }
38
+
39
+ connectionsInUse(): TCPConnection[] {
40
+ return Array.from(this._connectionsInUse);
41
+ }
42
+
43
+ initializeConnections(): void {
44
+ const connectionReused = this.connectionReusedByRequestId;
45
+ const additionalRttByOrigin = this.options.additionalRttByOrigin;
46
+ const serverResponseTimeByOrigin = this.options.serverResponseTimeByOrigin;
47
+
48
+ const recordsByOrigin = Core.NetworkAnalyzer.groupByOrigin(this.records);
49
+ for (const [origin, requests] of recordsByOrigin.entries()) {
50
+ const connections = [];
51
+ const additionalRtt = additionalRttByOrigin.get(origin) || 0;
52
+ const responseTime = serverResponseTimeByOrigin.get(origin) || DEFAULT_SERVER_RESPONSE_TIME;
53
+
54
+ for (const request of requests) {
55
+ if (connectionReused.get(request.requestId)) {
56
+ continue;
57
+ }
58
+
59
+ const isTLS = TLS_SCHEMES.includes(request.parsedURL.scheme);
60
+ const isH2 = request.protocol === 'h2';
61
+ const connection = new TCPConnection(
62
+ this.options.rtt + additionalRtt,
63
+ this.options.throughput,
64
+ responseTime,
65
+ isTLS,
66
+ isH2,
67
+ );
68
+
69
+ connections.push(connection);
70
+ }
71
+
72
+ if (!connections.length) {
73
+ throw new Core.LanternError(`Could not find a connection for origin: ${origin}`);
74
+ }
75
+
76
+ // Make sure each origin has minimum number of connections available for max throughput.
77
+ // But only if it's not over H2 which maximizes throughput already.
78
+ const minConnections = connections[0].isH2() ? 1 : CONNECTIONS_PER_ORIGIN;
79
+ while (connections.length < minConnections) {
80
+ connections.push(connections[0].clone());
81
+ }
82
+
83
+ this.connectionsByOrigin.set(origin, connections);
84
+ }
85
+ }
86
+
87
+ findAvailableConnectionWithLargestCongestionWindow(connections: TCPConnection[]): TCPConnection|null {
88
+ let maxConnection: TCPConnection|null = null;
89
+ for (let i = 0; i < connections.length; i++) {
90
+ const connection = connections[i];
91
+
92
+ // Connections that are in use are never available.
93
+ if (this._connectionsInUse.has(connection)) {
94
+ continue;
95
+ }
96
+
97
+ // This connection is a match and is available! Update our max if it has a larger congestionWindow
98
+ const currentMax = (maxConnection?.congestionWindow) || -Infinity;
99
+ if (connection.congestionWindow > currentMax) {
100
+ maxConnection = connection;
101
+ }
102
+ }
103
+
104
+ return maxConnection;
105
+ }
106
+
107
+ /**
108
+ * This method finds an available connection to the origin specified by the network request or null
109
+ * if no connection was available. If returned, connection will not be available for other network
110
+ * records until release is called.
111
+ */
112
+ acquire(request: Lantern.NetworkRequest): TCPConnection|null {
113
+ if (this.connectionsByRequest.has(request)) {
114
+ throw new Core.LanternError('Record already has a connection');
115
+ }
116
+
117
+ const origin = request.parsedURL.securityOrigin;
118
+ const connections = this.connectionsByOrigin.get(origin) || [];
119
+ const connectionToUse = this.findAvailableConnectionWithLargestCongestionWindow(connections);
120
+
121
+ if (!connectionToUse) {
122
+ return null;
123
+ }
124
+
125
+ this._connectionsInUse.add(connectionToUse);
126
+ this.connectionsByRequest.set(request, connectionToUse);
127
+ return connectionToUse;
128
+ }
129
+
130
+ /**
131
+ * Return the connection currently being used to fetch a request. If no connection
132
+ * currently being used for this request, an error will be thrown.
133
+ */
134
+ acquireActiveConnectionFromRequest(request: Lantern.NetworkRequest): TCPConnection {
135
+ const activeConnection = this.connectionsByRequest.get(request);
136
+ if (!activeConnection) {
137
+ throw new Core.LanternError('Could not find an active connection for request');
138
+ }
139
+
140
+ return activeConnection;
141
+ }
142
+
143
+ release(request: Lantern.NetworkRequest): void {
144
+ const connection = this.connectionsByRequest.get(request);
145
+ this.connectionsByRequest.delete(request);
146
+ if (connection) {
147
+ this._connectionsInUse.delete(connection);
148
+ }
149
+ }
150
+ }
@@ -0,0 +1,46 @@
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
+ const DEVTOOLS_RTT_ADJUSTMENT_FACTOR = 3.75;
6
+ const DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR = 0.9;
7
+
8
+ const throttling = {
9
+ DEVTOOLS_RTT_ADJUSTMENT_FACTOR,
10
+ DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,
11
+ // These values align with WebPageTest's definition of "Fast 3G"
12
+ // But offer similar characteristics to roughly the 75th percentile of 4G connections.
13
+ mobileSlow4G: {
14
+ rttMs: 150,
15
+ throughputKbps: 1.6 * 1024,
16
+ requestLatencyMs: 150 * DEVTOOLS_RTT_ADJUSTMENT_FACTOR,
17
+ downloadThroughputKbps: 1.6 * 1024 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,
18
+ uploadThroughputKbps: 750 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,
19
+ cpuSlowdownMultiplier: 4,
20
+ },
21
+ // These values partially align with WebPageTest's definition of "Regular 3G".
22
+ // These values are meant to roughly align with Chrome UX report's 3G definition which are based
23
+ // on HTTP RTT of 300-1400ms and downlink throughput of <700kbps.
24
+ mobileRegular3G: {
25
+ rttMs: 300,
26
+ throughputKbps: 700,
27
+ requestLatencyMs: 300 * DEVTOOLS_RTT_ADJUSTMENT_FACTOR,
28
+ downloadThroughputKbps: 700 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,
29
+ uploadThroughputKbps: 700 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,
30
+ cpuSlowdownMultiplier: 4,
31
+ },
32
+ // Using a "broadband" connection type
33
+ // Corresponds to "Dense 4G 25th percentile" in https://docs.google.com/document/d/1Ft1Bnq9-t4jK5egLSOc28IL4TvR-Tt0se_1faTA4KTY/edit#heading=h.bb7nfy2x9e5v
34
+ desktopDense4G: {
35
+ rttMs: 40,
36
+ throughputKbps: 10 * 1024,
37
+ cpuSlowdownMultiplier: 1,
38
+ requestLatencyMs: 0, // 0 means unset
39
+ downloadThroughputKbps: 0,
40
+ uploadThroughputKbps: 0,
41
+ },
42
+ };
43
+
44
+ const Constants = {throttling};
45
+
46
+ export {Constants};
@@ -0,0 +1,61 @@
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 type * as Lantern from '../types/types.js';
6
+
7
+ // A DNS lookup will usually take ~1-2 roundtrips of connection latency plus the extra DNS routing time.
8
+ // Example: https://www.webpagetest.org/result/180703_3A_e33ec79747c002ed4d7bcbfc81462203/1/details/#waterfall_view_step1
9
+ // Example: https://www.webpagetest.org/result/180707_1M_89673eb633b5d98386de95dfcf9b33d5/1/details/#waterfall_view_step1
10
+ // DNS is highly variable though, many times it's a little more than 1, but can easily be 4-5x RTT.
11
+ // We'll use 2 since it seems to give the most accurate results on average, but this can be tweaked.
12
+ const DNS_RESOLUTION_RTT_MULTIPLIER = 2;
13
+
14
+ class DNSCache {
15
+ static rttMultiplier = DNS_RESOLUTION_RTT_MULTIPLIER;
16
+
17
+ rtt: number;
18
+ resolvedDomainNames: Map<string, {resolvedAt: number}>;
19
+
20
+ constructor({rtt}: {rtt: number}) {
21
+ this.rtt = rtt;
22
+ this.resolvedDomainNames = new Map();
23
+ }
24
+
25
+ getTimeUntilResolution(
26
+ request: Lantern.NetworkRequest, options?: {requestedAt?: number, shouldUpdateCache?: boolean}): number {
27
+ const {requestedAt = 0, shouldUpdateCache = false} = options || {};
28
+
29
+ const domain = request.parsedURL.host;
30
+ const cacheEntry = this.resolvedDomainNames.get(domain);
31
+ let timeUntilResolved = this.rtt * DNSCache.rttMultiplier;
32
+ if (cacheEntry) {
33
+ const timeUntilCachedIsResolved = Math.max(cacheEntry.resolvedAt - requestedAt, 0);
34
+ timeUntilResolved = Math.min(timeUntilCachedIsResolved, timeUntilResolved);
35
+ }
36
+
37
+ const resolvedAt = requestedAt + timeUntilResolved;
38
+ if (shouldUpdateCache) {
39
+ this.updateCacheResolvedAtIfNeeded(request, resolvedAt);
40
+ }
41
+
42
+ return timeUntilResolved;
43
+ }
44
+
45
+ updateCacheResolvedAtIfNeeded(request: Lantern.NetworkRequest, resolvedAt: number): void {
46
+ const domain = request.parsedURL.host;
47
+ const cacheEntry = this.resolvedDomainNames.get(domain) || {resolvedAt};
48
+ cacheEntry.resolvedAt = Math.min(cacheEntry.resolvedAt, resolvedAt);
49
+ this.resolvedDomainNames.set(domain, cacheEntry);
50
+ }
51
+
52
+ /**
53
+ * Forcefully sets the DNS resolution time for a request.
54
+ * Useful for testing and alternate execution simulations.
55
+ */
56
+ setResolvedAt(domain: string, resolvedAt: number): void {
57
+ this.resolvedDomainNames.set(domain, {resolvedAt});
58
+ }
59
+ }
60
+
61
+ export {DNSCache};
@@ -0,0 +1,196 @@
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
+ /**
6
+ * @file
7
+ *
8
+ * This class encapsulates the type-related validation logic for moving timing information for nodes
9
+ * through the different simulation phases. Methods here ensure that the invariants of simulation hold
10
+ * as nodes are queued, partially simulated, and completed.
11
+ */
12
+
13
+ import * as Core from '../core/core.js';
14
+ import * as Graph from '../graph/graph.js';
15
+
16
+ interface NodeTimingComplete {
17
+ startTime: number;
18
+ endTime: number;
19
+ queuedTime: number;
20
+ estimatedTimeElapsed: number;
21
+ timeElapsed: number;
22
+ timeElapsedOvershoot: number;
23
+ bytesDownloaded: number;
24
+ }
25
+
26
+ type NodeTimingQueued = Pick<NodeTimingComplete, 'queuedTime'>;
27
+
28
+ type CpuNodeTimingStarted = NodeTimingQueued&Pick<NodeTimingComplete, 'startTime'|'timeElapsed'>;
29
+ type NetworkNodeTimingStarted = CpuNodeTimingStarted&Pick<NodeTimingComplete, 'timeElapsedOvershoot'|'bytesDownloaded'>;
30
+
31
+ type CpuNodeTimingInProgress = CpuNodeTimingStarted&Pick<NodeTimingComplete, 'estimatedTimeElapsed'>;
32
+ type NetworkNodeTimingInProgress = NetworkNodeTimingStarted&Pick<NodeTimingComplete, 'estimatedTimeElapsed'>;
33
+
34
+ export type CpuNodeTimingComplete = CpuNodeTimingInProgress&Pick<NodeTimingComplete, 'endTime'>;
35
+ export type NetworkNodeTimingComplete =
36
+ NetworkNodeTimingInProgress&Pick<NodeTimingComplete, 'endTime'>&{connectionTiming: ConnectionTiming};
37
+ export type CompleteNodeTiming = CpuNodeTimingComplete|NetworkNodeTimingComplete;
38
+
39
+ type NodeTimingData = NodeTimingQueued|CpuNodeTimingStarted|NetworkNodeTimingStarted|CpuNodeTimingInProgress|
40
+ NetworkNodeTimingInProgress|CpuNodeTimingComplete|NetworkNodeTimingComplete;
41
+
42
+ export interface ConnectionTiming {
43
+ dnsResolutionTime?: number;
44
+ connectionTime?: number;
45
+ sslTime?: number;
46
+ timeToFirstByte: number;
47
+ }
48
+
49
+ class SimulatorTimingMap {
50
+ nodeTimings: Map<Graph.Node, NodeTimingData>;
51
+
52
+ constructor() {
53
+ this.nodeTimings = new Map<Graph.Node, NodeTimingData>();
54
+ }
55
+
56
+ getNodes(): Graph.Node[] {
57
+ return Array.from(this.nodeTimings.keys());
58
+ }
59
+
60
+ setReadyToStart(node: Graph.Node, values: {queuedTime: number}): void {
61
+ this.nodeTimings.set(node, values);
62
+ }
63
+
64
+ setInProgress(node: Graph.Node, values: {startTime: number}): void {
65
+ const nodeTiming = {
66
+ ...this.getQueued(node),
67
+ startTime: values.startTime,
68
+ timeElapsed: 0,
69
+ };
70
+
71
+ this.nodeTimings.set(
72
+ node,
73
+ node.type === Graph.BaseNode.types.NETWORK ? {...nodeTiming, timeElapsedOvershoot: 0, bytesDownloaded: 0} :
74
+ nodeTiming,
75
+ );
76
+ }
77
+
78
+ setCompleted(node: Graph.Node, values: {endTime: number, connectionTiming?: ConnectionTiming}): void {
79
+ const nodeTiming = {
80
+ ...this.getInProgress(node),
81
+ endTime: values.endTime,
82
+ connectionTiming: values.connectionTiming,
83
+ };
84
+
85
+ this.nodeTimings.set(node, nodeTiming);
86
+ }
87
+
88
+ setCpu(node: Graph.CPUNode, values: {timeElapsed: number}): void {
89
+ const nodeTiming = {
90
+ ...this.getCpuStarted(node),
91
+ timeElapsed: values.timeElapsed,
92
+ };
93
+
94
+ this.nodeTimings.set(node, nodeTiming);
95
+ }
96
+
97
+ setCpuEstimated(node: Graph.CPUNode, values: {estimatedTimeElapsed: number}): void {
98
+ const nodeTiming = {
99
+ ...this.getCpuStarted(node),
100
+ estimatedTimeElapsed: values.estimatedTimeElapsed,
101
+ };
102
+
103
+ this.nodeTimings.set(node, nodeTiming);
104
+ }
105
+
106
+ setNetwork(
107
+ node: Graph.NetworkNode,
108
+ values: {timeElapsed: number, timeElapsedOvershoot: number, bytesDownloaded: number}): void {
109
+ const nodeTiming = {
110
+ ...this.getNetworkStarted(node),
111
+ timeElapsed: values.timeElapsed,
112
+ timeElapsedOvershoot: values.timeElapsedOvershoot,
113
+ bytesDownloaded: values.bytesDownloaded,
114
+ };
115
+
116
+ this.nodeTimings.set(node, nodeTiming);
117
+ }
118
+
119
+ setNetworkEstimated(node: Graph.NetworkNode, values: {estimatedTimeElapsed: number}): void {
120
+ const nodeTiming = {
121
+ ...this.getNetworkStarted(node),
122
+ estimatedTimeElapsed: values.estimatedTimeElapsed,
123
+ };
124
+
125
+ this.nodeTimings.set(node, nodeTiming);
126
+ }
127
+
128
+ getQueued(node: Graph.Node): NodeTimingData {
129
+ const timing = this.nodeTimings.get(node);
130
+ if (!timing) {
131
+ throw new Core.LanternError(`Node ${node.id} not yet queued`);
132
+ }
133
+ return timing;
134
+ }
135
+
136
+ getCpuStarted(node: Graph.CPUNode): CpuNodeTimingStarted {
137
+ const timing = this.nodeTimings.get(node);
138
+ if (!timing) {
139
+ throw new Core.LanternError(`Node ${node.id} not yet queued`);
140
+ }
141
+ if (!('startTime' in timing)) {
142
+ throw new Core.LanternError(`Node ${node.id} not yet started`);
143
+ }
144
+ if ('bytesDownloaded' in timing) {
145
+ throw new Core.LanternError(`Node ${node.id} timing not valid`);
146
+ }
147
+ return timing;
148
+ }
149
+
150
+ getNetworkStarted(node: Graph.NetworkNode): NetworkNodeTimingStarted {
151
+ const timing = this.nodeTimings.get(node);
152
+ if (!timing) {
153
+ throw new Core.LanternError(`Node ${node.id} not yet queued`);
154
+ }
155
+ if (!('startTime' in timing)) {
156
+ throw new Core.LanternError(`Node ${node.id} not yet started`);
157
+ }
158
+ if (!('bytesDownloaded' in timing)) {
159
+ throw new Core.LanternError(`Node ${node.id} timing not valid`);
160
+ }
161
+ return timing;
162
+ }
163
+
164
+ getInProgress(node: Graph.Node): CpuNodeTimingInProgress|NetworkNodeTimingInProgress {
165
+ const timing = this.nodeTimings.get(node);
166
+ if (!timing) {
167
+ throw new Core.LanternError(`Node ${node.id} not yet queued`);
168
+ }
169
+ if (!('startTime' in timing)) {
170
+ throw new Core.LanternError(`Node ${node.id} not yet started`);
171
+ }
172
+ if (!('estimatedTimeElapsed' in timing)) {
173
+ throw new Core.LanternError(`Node ${node.id} not yet in progress`);
174
+ }
175
+ return timing;
176
+ }
177
+
178
+ getCompleted(node: Graph.Node): CpuNodeTimingComplete|NetworkNodeTimingComplete {
179
+ const timing = this.nodeTimings.get(node);
180
+ if (!timing) {
181
+ throw new Core.LanternError(`Node ${node.id} not yet queued`);
182
+ }
183
+ if (!('startTime' in timing)) {
184
+ throw new Core.LanternError(`Node ${node.id} not yet started`);
185
+ }
186
+ if (!('estimatedTimeElapsed' in timing)) {
187
+ throw new Core.LanternError(`Node ${node.id} not yet in progress`);
188
+ }
189
+ if (!('endTime' in timing)) {
190
+ throw new Core.LanternError(`Node ${node.id} not yet completed`);
191
+ }
192
+ return timing;
193
+ }
194
+ }
195
+
196
+ export {SimulatorTimingMap};