@paulirish/trace_engine 0.0.65 → 0.0.67-beta.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 (720) hide show
  1. package/README.md +19 -17
  2. package/analyze-trace.mjs +6 -144
  3. package/core/common/Base64.d.ts +12 -0
  4. package/core/common/CharacterIdMap.d.ts +5 -0
  5. package/core/common/Color.d.ts +357 -0
  6. package/core/common/ColorConverter.d.ts +26 -0
  7. package/core/common/ColorUtils.d.ts +45 -0
  8. package/core/common/Console.d.ts +54 -0
  9. package/core/common/Debouncer.d.ts +8 -0
  10. package/core/common/EventTarget.d.ts +22 -0
  11. package/core/common/Gzip.d.ts +23 -0
  12. package/core/common/JavaScriptMetaData.d.ts +20 -0
  13. package/core/common/Lazy.d.ts +4 -0
  14. package/core/common/MapWithDefault.d.ts +9 -0
  15. package/core/common/Mutex.d.ts +13 -0
  16. package/core/common/Object.d.ts +20 -0
  17. package/core/common/ParsedURL.d.ts +87 -0
  18. package/core/common/Progress.d.ts +47 -0
  19. package/core/common/ResolverBase.d.ts +29 -0
  20. package/core/common/ResourceType.d.ts +52 -0
  21. package/core/common/ReturnToPanel.d.ts +10 -0
  22. package/core/common/Revealer.d.ts +66 -0
  23. package/core/common/Runnable.d.ts +14 -0
  24. package/core/common/SegmentedRange.d.ts +14 -0
  25. package/core/common/SettingRegistration.d.ts +136 -0
  26. package/core/common/Settings.d.ts +226 -0
  27. package/core/common/SimpleHistoryManager.d.ts +20 -0
  28. package/core/common/Srcset.d.ts +16 -0
  29. package/core/common/StringOutputStream.d.ts +10 -0
  30. package/core/common/TextDictionary.d.ts +11 -0
  31. package/core/common/Throttler.d.ts +12 -0
  32. package/core/common/Trie.d.ts +24 -0
  33. package/core/common/VersionController.d.ts +85 -0
  34. package/core/common/common.d.ts +33 -1
  35. package/core/host/AidaClient.d.ts +73 -0
  36. package/core/host/AidaClientTypes.d.ts +355 -0
  37. package/core/host/AidaGcaTranslation.d.ts +10 -0
  38. package/core/host/DispatchHttpRequestClient.d.ts +14 -0
  39. package/core/host/GcaClient.d.ts +14 -0
  40. package/core/host/GcaTypes.d.ts +411 -0
  41. package/core/host/GdpClient.d.ts +84 -0
  42. package/core/host/InspectorFrontendHost.d.ts +29 -0
  43. package/core/host/InspectorFrontendHostAPI.d.ts +425 -0
  44. package/core/host/InspectorFrontendHostStub.d.ts +151 -0
  45. package/core/host/Platform.d.ts +11 -0
  46. package/core/host/ResourceLoader.d.ts +15 -0
  47. package/core/host/UserMetrics.d.ts +116 -0
  48. package/core/host/UserMetricsEnums.d.ts +883 -0
  49. package/core/host/host.d.ts +13 -1
  50. package/core/i18n/ByteUtilities.d.ts +11 -0
  51. package/core/i18n/DevToolsLocale.d.ts +41 -0
  52. package/core/i18n/NumberFormatter.d.ts +11 -0
  53. package/core/i18n/i18n.d.ts +10 -0
  54. package/core/i18n/i18nImpl.d.ts +64 -0
  55. package/core/i18n/i18nTypes.d.ts +5 -0
  56. package/core/i18n/locales.d.ts +15 -0
  57. package/core/i18n/time-utilities.d.ts +16 -0
  58. package/core/platform/ArrayUtilities.d.ts +5 -0
  59. package/core/platform/HostRuntime.d.ts +1 -0
  60. package/core/platform/Size.d.ts +12 -0
  61. package/core/platform/StringUtilities.d.ts +28 -0
  62. package/core/platform/TypescriptUtilities.d.ts +0 -6
  63. package/core/platform/api/HostRuntime.d.ts +25 -0
  64. package/core/platform/platform.d.ts +2 -1
  65. package/core/protocol_client/CDPConnection.d.ts +77 -0
  66. package/core/protocol_client/ConnectionTransport.d.ts +9 -0
  67. package/core/protocol_client/DevToolsCDPConnection.d.ts +16 -0
  68. package/core/protocol_client/InspectorBackend.d.ts +223 -0
  69. package/core/protocol_client/protocol_client.d.ts +5 -0
  70. package/core/root/DevToolsContext.d.ts +34 -0
  71. package/core/root/ExperimentNames.d.ts +8 -0
  72. package/core/root/Runtime.d.ts +351 -0
  73. package/core/root/root.d.ts +4 -1
  74. package/core/sdk/AccessibilityModel.d.ts +76 -0
  75. package/core/sdk/AnimationModel.d.ts +161 -0
  76. package/core/sdk/AutofillModel.d.ts +23 -0
  77. package/core/sdk/CPUProfilerModel.d.ts +46 -0
  78. package/core/sdk/CPUThrottlingManager.d.ts +47 -0
  79. package/core/sdk/CSSContainerQuery.d.ts +42 -0
  80. package/core/sdk/CSSFontFace.d.ts +10 -0
  81. package/core/sdk/CSSLayer.d.ts +9 -0
  82. package/core/sdk/CSSLocation.d.ts +14 -0
  83. package/core/sdk/CSSMatchedStyles.d.ts +138 -0
  84. package/core/sdk/CSSMedia.d.ts +36 -0
  85. package/core/sdk/CSSMetadata.d.ts +87 -0
  86. package/core/sdk/CSSModel.d.ts +180 -0
  87. package/core/sdk/CSSNavigation.d.ts +10 -0
  88. package/core/sdk/CSSProperty.d.ts +53 -0
  89. package/core/sdk/CSSPropertyParser.d.ts +131 -0
  90. package/core/sdk/CSSPropertyParserMatchers.d.ts +442 -0
  91. package/core/sdk/CSSQuery.d.ts +22 -0
  92. package/core/sdk/CSSRule.d.ts +132 -0
  93. package/core/sdk/CSSScope.d.ts +9 -0
  94. package/core/sdk/CSSStartingStyle.d.ts +9 -0
  95. package/core/sdk/CSSStyleDeclaration.d.ts +38 -0
  96. package/core/sdk/CSSStyleSheetHeader.d.ts +53 -0
  97. package/core/sdk/CSSSupports.d.ts +10 -0
  98. package/core/sdk/CategorizedBreakpoint.d.ts +42 -0
  99. package/core/sdk/ChildTargetManager.d.ts +40 -0
  100. package/core/sdk/CompilerSourceMappingContentProvider.d.ts +12 -0
  101. package/core/sdk/Connections.d.ts +36 -0
  102. package/core/sdk/ConsoleModel.d.ts +127 -0
  103. package/core/sdk/ConsoleModelTypes.d.ts +6 -0
  104. package/core/sdk/Cookie.d.ts +68 -0
  105. package/core/sdk/CookieModel.d.ts +31 -0
  106. package/core/sdk/CookieParser.d.ts +14 -0
  107. package/core/sdk/CrashReportContextModel.d.ts +8 -0
  108. package/core/sdk/DOMDebuggerModel.d.ts +127 -0
  109. package/core/sdk/DOMModel.d.ts +436 -0
  110. package/core/sdk/DOMStorageModel.d.ts +79 -0
  111. package/core/sdk/DebuggerModel.d.ts +272 -0
  112. package/core/sdk/EmulationModel.d.ts +95 -0
  113. package/core/sdk/EnhancedTracesParser.d.ts +105 -0
  114. package/core/sdk/EventBreakpointsModel.d.ts +66 -0
  115. package/core/sdk/FrameAssociated.d.ts +6 -0
  116. package/core/sdk/FrameManager.d.ts +68 -0
  117. package/core/sdk/HeapProfilerModel.d.ts +75 -0
  118. package/core/sdk/HttpReasonPhraseStrings.d.ts +5 -0
  119. package/core/sdk/IOModel.d.ts +10 -0
  120. package/core/sdk/IsolateManager.d.ts +53 -0
  121. package/core/sdk/IssuesModel.d.ts +28 -0
  122. package/core/sdk/LayerTreeBase.d.ts +70 -0
  123. package/core/sdk/LogModel.d.ts +20 -0
  124. package/core/sdk/NetworkManager.d.ts +418 -0
  125. package/core/sdk/NetworkRequest.d.ts +469 -0
  126. package/core/sdk/NetworkRequestAccess.d.ts +91 -0
  127. package/core/sdk/OverlayColorGenerator.d.ts +14 -0
  128. package/core/sdk/OverlayModel.d.ts +186 -0
  129. package/core/sdk/OverlayPersistentHighlighter.d.ts +116 -0
  130. package/core/sdk/PageFunctions.d.ts +22 -0
  131. package/core/sdk/PageLoad.d.ts +14 -0
  132. package/core/sdk/PageResourceLoader.d.ts +111 -0
  133. package/core/sdk/PaintProfiler.d.ts +43 -0
  134. package/core/sdk/PerformanceMetricsModel.d.ts +12 -0
  135. package/core/sdk/PreloadingModel.d.ts +146 -0
  136. package/core/sdk/RehydratingConnection.d.ts +73 -0
  137. package/core/sdk/RehydratingObject.d.ts +59 -0
  138. package/core/sdk/RemoteObject.d.ts +210 -0
  139. package/core/sdk/Resource.d.ts +36 -0
  140. package/core/sdk/ResourceTreeModel.d.ts +278 -0
  141. package/core/sdk/RuntimeModel.d.ts +163 -0
  142. package/core/sdk/SDKModel.d.ts +30 -0
  143. package/core/sdk/SDKSettings.d.ts +53 -0
  144. package/core/sdk/ScopeTreeCache.d.ts +21 -0
  145. package/core/sdk/ScreenCaptureModel.d.ts +69 -0
  146. package/core/sdk/Script.d.ts +134 -0
  147. package/core/sdk/SecurityOrigin.d.ts +108 -0
  148. package/core/sdk/SecurityOriginManager.d.ts +23 -0
  149. package/core/sdk/ServerSentEvents.d.ts +18 -0
  150. package/core/sdk/ServerSentEventsProtocol.d.ts +18 -0
  151. package/core/sdk/ServerTiming.d.ts +24 -0
  152. package/core/sdk/ServiceWorkerCacheModel.d.ts +71 -0
  153. package/core/sdk/ServiceWorkerManager.d.ts +125 -0
  154. package/core/sdk/SourceMap.d.ts +197 -0
  155. package/core/sdk/SourceMapCache.d.ts +12 -0
  156. package/core/sdk/SourceMapFunctionRanges.d.ts +26 -0
  157. package/core/sdk/SourceMapManager.d.ts +46 -0
  158. package/core/sdk/SourceMapRangeMappings.d.ts +15 -0
  159. package/core/sdk/SourceMapScopeChainEntry.d.ts +23 -0
  160. package/core/sdk/SourceMapScopesInfo.d.ts +109 -0
  161. package/core/sdk/StorageBucketsModel.d.ts +48 -0
  162. package/core/sdk/StorageKeyManager.d.ts +38 -0
  163. package/core/sdk/Target.d.ts +79 -0
  164. package/core/sdk/TargetManager.d.ts +92 -0
  165. package/core/sdk/TraceObject.d.ts +43 -0
  166. package/core/sdk/WebAuthnModel.d.ts +29 -0
  167. package/core/sdk/sdk.d.ts +97 -1
  168. package/core/text_utils/CodeMirrorUtils.d.ts +3 -0
  169. package/core/text_utils/ContentData.d.ts +94 -0
  170. package/core/text_utils/ContentProvider.d.ts +42 -0
  171. package/core/text_utils/StaticContentProvider.d.ts +13 -0
  172. package/core/text_utils/StreamingContentData.d.ts +49 -0
  173. package/core/text_utils/Text.d.ts +19 -0
  174. package/core/text_utils/TextCursor.d.ts +9 -0
  175. package/core/text_utils/TextRange.d.ts +81 -0
  176. package/core/text_utils/TextUtils.d.ts +97 -0
  177. package/core/text_utils/WasmDisassembly.d.ts +29 -0
  178. package/core/text_utils/text_utils.d.ts +11 -0
  179. package/entrypoints/formatter_actions/formatter_actions.d.ts +48 -0
  180. package/generated/InspectorBackendCommands.d.ts +14 -0
  181. package/generated/SupportedCSSProperties.d.ts +18 -0
  182. package/generated/protocol-mapping.d.ts +5930 -0
  183. package/generated/protocol-proxy-api.d.ts +5396 -0
  184. package/generated/protocol.d.ts +736 -685
  185. package/index.js +6 -0
  186. package/locales/af.json +80 -62
  187. package/locales/am.json +363 -345
  188. package/locales/ar.json +364 -346
  189. package/locales/as.json +362 -344
  190. package/locales/az.json +353 -335
  191. package/locales/be.json +363 -345
  192. package/locales/bg.json +363 -345
  193. package/locales/bn.json +363 -345
  194. package/locales/bs.json +259 -241
  195. package/locales/ca.json +295 -277
  196. package/locales/cs.json +348 -330
  197. package/locales/cy.json +139 -121
  198. package/locales/da.json +222 -204
  199. package/locales/de.json +234 -216
  200. package/locales/el.json +348 -330
  201. package/locales/en-GB.json +36 -18
  202. package/locales/es-419.json +290 -272
  203. package/locales/es.json +292 -274
  204. package/locales/et.json +251 -233
  205. package/locales/eu.json +29 -11
  206. package/locales/fa.json +363 -345
  207. package/locales/fi.json +295 -277
  208. package/locales/fil.json +29 -11
  209. package/locales/fr-CA.json +320 -302
  210. package/locales/fr.json +317 -299
  211. package/locales/gl.json +276 -258
  212. package/locales/gu.json +364 -346
  213. package/locales/he.json +364 -346
  214. package/locales/hi.json +348 -330
  215. package/locales/hr.json +250 -232
  216. package/locales/hu.json +354 -336
  217. package/locales/hy.json +363 -345
  218. package/locales/id.json +27 -9
  219. package/locales/is.json +317 -299
  220. package/locales/it.json +154 -136
  221. package/locales/ja.json +363 -345
  222. package/locales/ka.json +364 -346
  223. package/locales/kk.json +364 -346
  224. package/locales/km.json +363 -345
  225. package/locales/kn.json +364 -346
  226. package/locales/ko.json +363 -345
  227. package/locales/ky.json +362 -344
  228. package/locales/lo.json +364 -346
  229. package/locales/lt.json +331 -313
  230. package/locales/lv.json +331 -313
  231. package/locales/mk.json +364 -346
  232. package/locales/ml.json +363 -345
  233. package/locales/mn.json +363 -345
  234. package/locales/mr.json +363 -345
  235. package/locales/ms.json +27 -9
  236. package/locales/my.json +362 -344
  237. package/locales/ne.json +348 -330
  238. package/locales/nl.json +84 -66
  239. package/locales/no.json +188 -170
  240. package/locales/or.json +363 -345
  241. package/locales/pa.json +363 -345
  242. package/locales/pl.json +322 -304
  243. package/locales/pt-PT.json +284 -266
  244. package/locales/pt.json +283 -265
  245. package/locales/ro.json +318 -300
  246. package/locales/ru.json +363 -345
  247. package/locales/si.json +364 -346
  248. package/locales/sk.json +345 -327
  249. package/locales/sl.json +231 -213
  250. package/locales/sq.json +329 -311
  251. package/locales/sr-Latn.json +267 -249
  252. package/locales/sr.json +364 -346
  253. package/locales/sv.json +296 -278
  254. package/locales/sw.json +35 -17
  255. package/locales/ta.json +364 -346
  256. package/locales/te.json +362 -344
  257. package/locales/th.json +364 -346
  258. package/locales/tr.json +337 -319
  259. package/locales/uk.json +363 -345
  260. package/locales/ur.json +364 -346
  261. package/locales/uz.json +175 -157
  262. package/locales/vi.json +364 -346
  263. package/locales/zh-HK.json +364 -346
  264. package/locales/zh-TW.json +363 -345
  265. package/locales/zh.json +363 -345
  266. package/locales/zu.json +35 -17
  267. package/models/crux-manager/CrUXManager.d.ts +107 -0
  268. package/models/crux-manager/crux-manager.d.ts +1 -0
  269. package/models/emulation/DeviceModeModel.d.ts +156 -0
  270. package/models/emulation/EmulatedDevices.d.ts +148 -0
  271. package/models/emulation/emulation.d.ts +3 -0
  272. package/models/formatter/FormatterWorkerPool.d.ts +58 -0
  273. package/models/formatter/ScriptFormatter.d.ts +11 -0
  274. package/models/formatter/formatter.d.ts +3 -0
  275. package/models/trace/ModelImpl.d.ts +2 -6
  276. package/models/trace/Processor.d.ts +2 -6
  277. package/models/trace/extras/StackTraceForEvent.d.ts +1 -1
  278. package/models/trace/extras/extras.d.ts +2 -7
  279. package/models/trace/handlers/FramesHandler.d.ts +1 -2
  280. package/models/trace/handlers/LayoutShiftsHandler.d.ts +2 -2
  281. package/models/trace/handlers/MetaHandler.d.ts +2 -3
  282. package/models/trace/handlers/ModelHandlers.d.ts +0 -1
  283. package/models/trace/handlers/PageLoadMetricsHandler.d.ts +2 -0
  284. package/models/trace/handlers/ScriptsHandler.d.ts +2 -2
  285. package/models/trace/handlers/Threads.d.ts +1 -3
  286. package/models/trace/handlers/UserTimingsHandler.d.ts +1 -1
  287. package/models/trace/helpers/Network.d.ts +3 -1
  288. package/models/trace/helpers/SyntheticEvents.d.ts +7 -0
  289. package/models/trace/insights/CLSCulprits.d.ts +6 -3
  290. package/models/trace/insights/Cache.d.ts +2 -1
  291. package/models/trace/insights/CharacterSet.d.ts +5 -4
  292. package/models/trace/insights/Common.d.ts +4 -4
  293. package/models/trace/insights/DOMSize.d.ts +4 -3
  294. package/models/trace/insights/DocumentLatency.d.ts +2 -1
  295. package/models/trace/insights/DuplicatedJavaScript.d.ts +9 -4
  296. package/models/trace/insights/FontDisplay.d.ts +11 -5
  297. package/models/trace/insights/ForcedReflow.d.ts +6 -6
  298. package/models/trace/insights/INPBreakdown.d.ts +5 -5
  299. package/models/trace/insights/ImageDelivery.d.ts +7 -7
  300. package/models/trace/insights/LCPBreakdown.d.ts +4 -3
  301. package/models/trace/insights/LCPDiscovery.d.ts +7 -6
  302. package/models/trace/insights/LegacyJavaScript.d.ts +9 -4
  303. package/models/trace/insights/ModernHTTP.d.ts +6 -6
  304. package/models/trace/insights/NetworkDependencyTree.d.ts +18 -96
  305. package/models/trace/insights/RenderBlocking.d.ts +4 -3
  306. package/models/trace/insights/SlowCSSSelector.d.ts +10 -9
  307. package/models/trace/insights/ThirdParties.d.ts +17 -8
  308. package/models/trace/insights/Viewport.d.ts +6 -4
  309. package/models/trace/insights/types.d.ts +10 -7
  310. package/models/trace/lantern/lantern.js +6 -8
  311. package/models/trace/lantern/simulation/Constants.d.ts +29 -28
  312. package/models/trace/trace.js +529 -18
  313. package/models/trace/types/Configuration.d.ts +12 -1
  314. package/models/trace/types/File.d.ts +6 -5
  315. package/models/trace/types/Overlays.d.ts +13 -3
  316. package/models/trace/types/Timing.js +6 -14
  317. package/models/trace/types/TraceEvents.d.ts +48 -18
  318. package/models/trace/types/TraceEvents.js +187 -884
  319. package/models/trace/types/types.js +6 -8
  320. package/package.json +30 -9
  321. package/third_party/codemirror.next/codemirror.next.d.ts +9196 -0
  322. package/third_party/i18n/i18n-impl.d.ts +25 -0
  323. package/third_party/i18n/i18n.d.ts +3 -0
  324. package/third_party/i18n/localized-string-set.d.ts +49 -0
  325. package/third_party/intl-messageformat/intl-messageformat.d.ts +1 -0
  326. package/third_party/legacy-javascript/legacy-javascript.d.ts +2 -1
  327. package/third_party/legacy-javascript/lib/legacy-javascript.d.ts +18 -0
  328. package/third_party/source-map-scopes-codec/package/src/builder/builder.d.ts +67 -0
  329. package/third_party/source-map-scopes-codec/package/src/builder/safe_builder.d.ts +38 -0
  330. package/third_party/source-map-scopes-codec/package/src/codec.d.ts +48 -0
  331. package/third_party/source-map-scopes-codec/package/src/decode/decode.d.ts +31 -0
  332. package/third_party/source-map-scopes-codec/package/src/encode/encode.d.ts +8 -0
  333. package/third_party/source-map-scopes-codec/package/src/encode/encoder.d.ts +6 -0
  334. package/third_party/source-map-scopes-codec/package/src/mod.d.ts +5 -0
  335. package/third_party/source-map-scopes-codec/package/src/scopes.d.ts +168 -0
  336. package/third_party/source-map-scopes-codec/package/src/util.d.ts +5 -0
  337. package/third_party/source-map-scopes-codec/package/src/vlq.d.ts +14 -0
  338. package/third_party/source-map-scopes-codec/source-map-scopes-codec.d.ts +1 -0
  339. package/third_party/third-party-web/lib/nostats-subset.d.ts +2 -0
  340. package/third_party/third-party-web/package/lib/index.d.ts +34 -0
  341. package/third_party/third-party-web/package/lib/subsets/nostats.d.ts +1 -0
  342. package/third_party/third-party-web/third-party-web.d.ts +2 -1
  343. package/.tmp/tsbuildinfo/analyze-inspector-issues.d.mts +0 -13
  344. package/.tmp/tsbuildinfo/analyze-inspector-issues.d.mts.map +0 -1
  345. package/.tmp/tsbuildinfo/analyze-trace.d.mts +0 -17
  346. package/.tmp/tsbuildinfo/analyze-trace.d.mts.map +0 -1
  347. package/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts +0 -4
  348. package/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts.map +0 -1
  349. package/.tmp/tsbuildinfo/test/test-trace-engine.d.mts +0 -2
  350. package/.tmp/tsbuildinfo/test/test-trace-engine.d.mts.map +0 -1
  351. package/.tmp/tsbuildinfo/third_party/third-party-web/third-party-web.d.ts +0 -3
  352. package/.tmp/tsbuildinfo/third_party/third-party-web/third-party-web.d.ts.map +0 -1
  353. package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +0 -1
  354. package/analyze-inspector-issues.mjs +0 -60
  355. package/core/common/common.js +0 -1
  356. package/core/host/host.js +0 -1
  357. package/core/platform/ArrayUtilities.js +0 -210
  358. package/core/platform/ArrayUtilities.js.map +0 -1
  359. package/core/platform/Brand.js +0 -5
  360. package/core/platform/Brand.js.map +0 -1
  361. package/core/platform/Constructor.js +0 -5
  362. package/core/platform/Constructor.js.map +0 -1
  363. package/core/platform/DateUtilities.js +0 -14
  364. package/core/platform/DateUtilities.js.map +0 -1
  365. package/core/platform/DevToolsPath.js +0 -28
  366. package/core/platform/DevToolsPath.js.map +0 -1
  367. package/core/platform/HostRuntime.js +0 -31
  368. package/core/platform/HostRuntime.js.map +0 -1
  369. package/core/platform/KeyboardUtilities.js +0 -22
  370. package/core/platform/KeyboardUtilities.js.map +0 -1
  371. package/core/platform/MapUtilities.js +0 -80
  372. package/core/platform/MapUtilities.js.map +0 -1
  373. package/core/platform/MimeType.js +0 -144
  374. package/core/platform/MimeType.js.map +0 -1
  375. package/core/platform/NumberUtilities.js +0 -73
  376. package/core/platform/NumberUtilities.js.map +0 -1
  377. package/core/platform/StringUtilities.js +0 -594
  378. package/core/platform/StringUtilities.js.map +0 -1
  379. package/core/platform/Timing.js +0 -10
  380. package/core/platform/Timing.js.map +0 -1
  381. package/core/platform/TypedArrayUtilities.js +0 -158
  382. package/core/platform/TypedArrayUtilities.js.map +0 -1
  383. package/core/platform/TypescriptUtilities.js +0 -25
  384. package/core/platform/TypescriptUtilities.js.map +0 -1
  385. package/core/platform/UIString.js +0 -5
  386. package/core/platform/UIString.js.map +0 -1
  387. package/core/platform/UserVisibleError.js +0 -23
  388. package/core/platform/UserVisibleError.js.map +0 -1
  389. package/core/platform/api/HostRuntime.js +0 -5
  390. package/core/platform/api/HostRuntime.js.map +0 -1
  391. package/core/platform/api/api-tsconfig.json +0 -43
  392. package/core/platform/api/api.js +0 -6
  393. package/core/platform/api/api.js.map +0 -1
  394. package/core/platform/api/api_node_typecheck-tsconfig.json +0 -48
  395. package/core/platform/api/bundle-tsconfig.json +0 -1
  396. package/core/platform/api/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  397. package/core/platform/browser/HostRuntime.js +0 -75
  398. package/core/platform/browser/HostRuntime.js.map +0 -1
  399. package/core/platform/browser/browser-tsconfig.json +0 -48
  400. package/core/platform/browser/browser.js +0 -6
  401. package/core/platform/browser/browser.js.map +0 -1
  402. package/core/platform/browser/bundle-tsconfig.json +0 -1
  403. package/core/platform/browser/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  404. package/core/platform/bundle-tsconfig.json +0 -1
  405. package/core/platform/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  406. package/core/platform/node/HostRuntime.js +0 -82
  407. package/core/platform/node/HostRuntime.js.map +0 -1
  408. package/core/platform/node/bundle-tsconfig.json +0 -1
  409. package/core/platform/node/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  410. package/core/platform/node/node-tsconfig.json +0 -52
  411. package/core/platform/node/node.js +0 -6
  412. package/core/platform/node/node.js.map +0 -1
  413. package/core/platform/platform-tsconfig.json +0 -69
  414. package/core/platform/platform.js +0 -27
  415. package/core/platform/platform.js.map +0 -1
  416. package/core/platform/platform_node_typecheck-tsconfig.json +0 -74
  417. package/core/root/root.js +0 -1
  418. package/core/sdk/sdk.js +0 -1
  419. package/generated/protocol.js +0 -5
  420. package/locales/en-US.json +0 -1046
  421. package/locales/en-XL.json +0 -1046
  422. package/models/cpu_profile/CPUProfileDataModel.js +0 -517
  423. package/models/cpu_profile/CPUProfileDataModel.js.map +0 -1
  424. package/models/cpu_profile/ProfileTreeModel.js +0 -90
  425. package/models/cpu_profile/ProfileTreeModel.js.map +0 -1
  426. package/models/cpu_profile/bundle-tsconfig.json +0 -1
  427. package/models/cpu_profile/cpu_profile-tsconfig.json +0 -52
  428. package/models/cpu_profile/cpu_profile.js +0 -7
  429. package/models/cpu_profile/cpu_profile.js.map +0 -1
  430. package/models/cpu_profile/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  431. package/models/issues_manager/CheckFormsIssuesTrigger.d.ts +0 -1
  432. package/models/issues_manager/CheckFormsIssuesTrigger.js +0 -1
  433. package/models/issues_manager/ContrastCheckTrigger.d.ts +0 -1
  434. package/models/issues_manager/ContrastCheckTrigger.js +0 -1
  435. package/models/issues_manager/DeprecationIssue.d.ts +0 -1
  436. package/models/issues_manager/DeprecationIssue.js +0 -1
  437. package/models/issues_manager/IssueResolver.d.ts +0 -1
  438. package/models/issues_manager/IssueResolver.js +0 -1
  439. package/models/issues_manager/RelatedIssue.d.ts +0 -1
  440. package/models/issues_manager/RelatedIssue.js +0 -1
  441. package/models/issues_manager/SourceFrameIssuesManager.d.ts +0 -1
  442. package/models/issues_manager/SourceFrameIssuesManager.js +0 -1
  443. package/models/trace/EntityMapper.js +0 -133
  444. package/models/trace/EntityMapper.js.map +0 -1
  445. package/models/trace/EventsSerializer.js +0 -90
  446. package/models/trace/EventsSerializer.js.map +0 -1
  447. package/models/trace/LanternComputationData.js +0 -367
  448. package/models/trace/LanternComputationData.js.map +0 -1
  449. package/models/trace/LegacyTracingModel.d.ts +0 -1
  450. package/models/trace/LegacyTracingModel.js +0 -1
  451. package/models/trace/ModelImpl.js +0 -170
  452. package/models/trace/ModelImpl.js.map +0 -1
  453. package/models/trace/Name.js +0 -115
  454. package/models/trace/Name.js.map +0 -1
  455. package/models/trace/Processor.js +0 -556
  456. package/models/trace/Processor.js.map +0 -1
  457. package/models/trace/Styles.js +0 -824
  458. package/models/trace/Styles.js.map +0 -1
  459. package/models/trace/TracingManager.d.ts +0 -1
  460. package/models/trace/TracingManager.js +0 -1
  461. package/models/trace/bundle-tsconfig.json +0 -1
  462. package/models/trace/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -66
  463. package/models/trace/extras/FilmStrip.js +0 -45
  464. package/models/trace/extras/FilmStrip.js.map +0 -1
  465. package/models/trace/extras/Initiators.js +0 -47
  466. package/models/trace/extras/Initiators.js.map +0 -1
  467. package/models/trace/extras/MainThreadActivity.js +0 -77
  468. package/models/trace/extras/MainThreadActivity.js.map +0 -1
  469. package/models/trace/extras/ScriptDuplication.js +0 -163
  470. package/models/trace/extras/ScriptDuplication.js.map +0 -1
  471. package/models/trace/extras/StackTraceForEvent.js +0 -192
  472. package/models/trace/extras/StackTraceForEvent.js.map +0 -1
  473. package/models/trace/extras/ThirdParties.js +0 -119
  474. package/models/trace/extras/ThirdParties.js.map +0 -1
  475. package/models/trace/extras/TraceFilter.js +0 -51
  476. package/models/trace/extras/TraceFilter.js.map +0 -1
  477. package/models/trace/extras/TraceTree.js +0 -621
  478. package/models/trace/extras/TraceTree.js.map +0 -1
  479. package/models/trace/extras/bundle-tsconfig.json +0 -1
  480. package/models/trace/extras/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  481. package/models/trace/extras/extras-tsconfig.json +0 -70
  482. package/models/trace/extras/extras.js +0 -13
  483. package/models/trace/extras/extras.js.map +0 -1
  484. package/models/trace/handlers/AnimationFramesHandler.js +0 -110
  485. package/models/trace/handlers/AnimationFramesHandler.js.map +0 -1
  486. package/models/trace/handlers/AnimationHandler.js +0 -27
  487. package/models/trace/handlers/AnimationHandler.js.map +0 -1
  488. package/models/trace/handlers/AsyncJSCallsHandler.js +0 -188
  489. package/models/trace/handlers/AsyncJSCallsHandler.js.map +0 -1
  490. package/models/trace/handlers/AuctionWorkletsHandler.d.ts +0 -8
  491. package/models/trace/handlers/AuctionWorkletsHandler.js +0 -163
  492. package/models/trace/handlers/AuctionWorkletsHandler.js.map +0 -1
  493. package/models/trace/handlers/DOMStatsHandler.js +0 -22
  494. package/models/trace/handlers/DOMStatsHandler.js.map +0 -1
  495. package/models/trace/handlers/ExtensionTraceDataHandler.js +0 -264
  496. package/models/trace/handlers/ExtensionTraceDataHandler.js.map +0 -1
  497. package/models/trace/handlers/FlowsHandler.js +0 -149
  498. package/models/trace/handlers/FlowsHandler.js.map +0 -1
  499. package/models/trace/handlers/FramesHandler.js +0 -492
  500. package/models/trace/handlers/FramesHandler.js.map +0 -1
  501. package/models/trace/handlers/GPUHandler.js +0 -36
  502. package/models/trace/handlers/GPUHandler.js.map +0 -1
  503. package/models/trace/handlers/ImagePaintingHandler.js +0 -148
  504. package/models/trace/handlers/ImagePaintingHandler.js.map +0 -1
  505. package/models/trace/handlers/InitiatorsHandler.js +0 -181
  506. package/models/trace/handlers/InitiatorsHandler.js.map +0 -1
  507. package/models/trace/handlers/InvalidationsHandler.js +0 -127
  508. package/models/trace/handlers/InvalidationsHandler.js.map +0 -1
  509. package/models/trace/handlers/LargestImagePaintHandler.js +0 -86
  510. package/models/trace/handlers/LargestImagePaintHandler.js.map +0 -1
  511. package/models/trace/handlers/LargestTextPaintHandler.js +0 -28
  512. package/models/trace/handlers/LargestTextPaintHandler.js.map +0 -1
  513. package/models/trace/handlers/LayerTreeHandler.js +0 -104
  514. package/models/trace/handlers/LayerTreeHandler.js.map +0 -1
  515. package/models/trace/handlers/LayoutShiftsHandler.js +0 -458
  516. package/models/trace/handlers/LayoutShiftsHandler.js.map +0 -1
  517. package/models/trace/handlers/MemoryHandler.js +0 -22
  518. package/models/trace/handlers/MemoryHandler.js.map +0 -1
  519. package/models/trace/handlers/MetaHandler.js +0 -411
  520. package/models/trace/handlers/MetaHandler.js.map +0 -1
  521. package/models/trace/handlers/ModelHandlers.js +0 -34
  522. package/models/trace/handlers/ModelHandlers.js.map +0 -1
  523. package/models/trace/handlers/NetworkRequestsHandler.js +0 -576
  524. package/models/trace/handlers/NetworkRequestsHandler.js.map +0 -1
  525. package/models/trace/handlers/PageFramesHandler.js +0 -43
  526. package/models/trace/handlers/PageFramesHandler.js.map +0 -1
  527. package/models/trace/handlers/PageLoadMetricsHandler.js +0 -423
  528. package/models/trace/handlers/PageLoadMetricsHandler.js.map +0 -1
  529. package/models/trace/handlers/RendererHandler.js +0 -347
  530. package/models/trace/handlers/RendererHandler.js.map +0 -1
  531. package/models/trace/handlers/SamplesHandler.js +0 -261
  532. package/models/trace/handlers/SamplesHandler.js.map +0 -1
  533. package/models/trace/handlers/ScreenshotsHandler.js +0 -98
  534. package/models/trace/handlers/ScreenshotsHandler.js.map +0 -1
  535. package/models/trace/handlers/ScriptsHandler.js +0 -286
  536. package/models/trace/handlers/ScriptsHandler.js.map +0 -1
  537. package/models/trace/handlers/SelectorStatsHandler.js +0 -72
  538. package/models/trace/handlers/SelectorStatsHandler.js.map +0 -1
  539. package/models/trace/handlers/Threads.js +0 -112
  540. package/models/trace/handlers/Threads.js.map +0 -1
  541. package/models/trace/handlers/UserInteractionsHandler.js +0 -319
  542. package/models/trace/handlers/UserInteractionsHandler.js.map +0 -1
  543. package/models/trace/handlers/UserTimingsHandler.js +0 -184
  544. package/models/trace/handlers/UserTimingsHandler.js.map +0 -1
  545. package/models/trace/handlers/WarningsHandler.js +0 -135
  546. package/models/trace/handlers/WarningsHandler.js.map +0 -1
  547. package/models/trace/handlers/WorkersHandler.js +0 -34
  548. package/models/trace/handlers/WorkersHandler.js.map +0 -1
  549. package/models/trace/handlers/bundle-tsconfig.json +0 -1
  550. package/models/trace/handlers/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  551. package/models/trace/handlers/handlers-tsconfig.json +0 -102
  552. package/models/trace/handlers/handlers.js +0 -8
  553. package/models/trace/handlers/handlers.js.map +0 -1
  554. package/models/trace/handlers/helpers.js +0 -164
  555. package/models/trace/handlers/helpers.js.map +0 -1
  556. package/models/trace/handlers/types.js +0 -2
  557. package/models/trace/handlers/types.js.map +0 -1
  558. package/models/trace/helpers/Extensions.js +0 -42
  559. package/models/trace/helpers/Extensions.js.map +0 -1
  560. package/models/trace/helpers/Network.js +0 -103
  561. package/models/trace/helpers/Network.js.map +0 -1
  562. package/models/trace/helpers/SamplesIntegrator.js +0 -496
  563. package/models/trace/helpers/SamplesIntegrator.js.map +0 -1
  564. package/models/trace/helpers/SyntheticEvents.js +0 -75
  565. package/models/trace/helpers/SyntheticEvents.js.map +0 -1
  566. package/models/trace/helpers/Timing.js +0 -194
  567. package/models/trace/helpers/Timing.js.map +0 -1
  568. package/models/trace/helpers/Trace.js +0 -817
  569. package/models/trace/helpers/Trace.js.map +0 -1
  570. package/models/trace/helpers/TreeHelpers.js +0 -255
  571. package/models/trace/helpers/TreeHelpers.js.map +0 -1
  572. package/models/trace/helpers/bundle-tsconfig.json +0 -1
  573. package/models/trace/helpers/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  574. package/models/trace/helpers/helpers-tsconfig.json +0 -69
  575. package/models/trace/helpers/helpers.js +0 -11
  576. package/models/trace/helpers/helpers.js.map +0 -1
  577. package/models/trace/insights/CLSCulprits.js +0 -518
  578. package/models/trace/insights/CLSCulprits.js.map +0 -1
  579. package/models/trace/insights/Cache.js +0 -210
  580. package/models/trace/insights/Cache.js.map +0 -1
  581. package/models/trace/insights/CharacterSet.js +0 -132
  582. package/models/trace/insights/CharacterSet.js.map +0 -1
  583. package/models/trace/insights/Common.js +0 -348
  584. package/models/trace/insights/Common.js.map +0 -1
  585. package/models/trace/insights/DOMSize.js +0 -182
  586. package/models/trace/insights/DOMSize.js.map +0 -1
  587. package/models/trace/insights/DocumentLatency.js +0 -259
  588. package/models/trace/insights/DocumentLatency.js.map +0 -1
  589. package/models/trace/insights/DuplicatedJavaScript.js +0 -95
  590. package/models/trace/insights/DuplicatedJavaScript.js.map +0 -1
  591. package/models/trace/insights/FontDisplay.js +0 -87
  592. package/models/trace/insights/FontDisplay.js.map +0 -1
  593. package/models/trace/insights/ForcedReflow.js +0 -162
  594. package/models/trace/insights/ForcedReflow.js.map +0 -1
  595. package/models/trace/insights/INPBreakdown.js +0 -130
  596. package/models/trace/insights/INPBreakdown.js.map +0 -1
  597. package/models/trace/insights/ImageDelivery.js +0 -264
  598. package/models/trace/insights/ImageDelivery.js.map +0 -1
  599. package/models/trace/insights/LCPBreakdown.js +0 -200
  600. package/models/trace/insights/LCPBreakdown.js.map +0 -1
  601. package/models/trace/insights/LCPDiscovery.js +0 -190
  602. package/models/trace/insights/LCPDiscovery.js.map +0 -1
  603. package/models/trace/insights/LegacyJavaScript.js +0 -95
  604. package/models/trace/insights/LegacyJavaScript.js.map +0 -1
  605. package/models/trace/insights/Models.js +0 -23
  606. package/models/trace/insights/Models.js.map +0 -1
  607. package/models/trace/insights/ModernHTTP.js +0 -201
  608. package/models/trace/insights/ModernHTTP.js.map +0 -1
  609. package/models/trace/insights/NetworkDependencyTree.js +0 -968
  610. package/models/trace/insights/NetworkDependencyTree.js.map +0 -1
  611. package/models/trace/insights/RenderBlocking.js +0 -193
  612. package/models/trace/insights/RenderBlocking.js.map +0 -1
  613. package/models/trace/insights/SlowCSSSelector.js +0 -137
  614. package/models/trace/insights/SlowCSSSelector.js.map +0 -1
  615. package/models/trace/insights/Statistics.js +0 -93
  616. package/models/trace/insights/Statistics.js.map +0 -1
  617. package/models/trace/insights/ThirdParties.js +0 -99
  618. package/models/trace/insights/ThirdParties.js.map +0 -1
  619. package/models/trace/insights/Viewport.js +0 -103
  620. package/models/trace/insights/Viewport.js.map +0 -1
  621. package/models/trace/insights/bundle-tsconfig.json +0 -1
  622. package/models/trace/insights/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  623. package/models/trace/insights/insights-tsconfig.json +0 -103
  624. package/models/trace/insights/insights.js +0 -10
  625. package/models/trace/insights/insights.js.map +0 -1
  626. package/models/trace/insights/types.js +0 -41
  627. package/models/trace/insights/types.js.map +0 -1
  628. package/models/trace/lantern/bundle-tsconfig.json +0 -1
  629. package/models/trace/lantern/core/LanternError.js +0 -7
  630. package/models/trace/lantern/core/LanternError.js.map +0 -1
  631. package/models/trace/lantern/core/NetworkAnalyzer.js +0 -484
  632. package/models/trace/lantern/core/NetworkAnalyzer.js.map +0 -1
  633. package/models/trace/lantern/core/bundle-tsconfig.json +0 -1
  634. package/models/trace/lantern/core/core-tsconfig.json +0 -49
  635. package/models/trace/lantern/core/core.js +0 -6
  636. package/models/trace/lantern/core/core.js.map +0 -1
  637. package/models/trace/lantern/core/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  638. package/models/trace/lantern/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -60
  639. package/models/trace/lantern/graph/BaseNode.js +0 -277
  640. package/models/trace/lantern/graph/BaseNode.js.map +0 -1
  641. package/models/trace/lantern/graph/CPUNode.js +0 -64
  642. package/models/trace/lantern/graph/CPUNode.js.map +0 -1
  643. package/models/trace/lantern/graph/NetworkNode.js +0 -83
  644. package/models/trace/lantern/graph/NetworkNode.js.map +0 -1
  645. package/models/trace/lantern/graph/PageDependencyGraph.js +0 -552
  646. package/models/trace/lantern/graph/PageDependencyGraph.js.map +0 -1
  647. package/models/trace/lantern/graph/bundle-tsconfig.json +0 -1
  648. package/models/trace/lantern/graph/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  649. package/models/trace/lantern/graph/graph-tsconfig.json +0 -54
  650. package/models/trace/lantern/graph/graph.js +0 -8
  651. package/models/trace/lantern/graph/graph.js.map +0 -1
  652. package/models/trace/lantern/lantern.js.map +0 -1
  653. package/models/trace/lantern/metrics/FirstContentfulPaint.js +0 -137
  654. package/models/trace/lantern/metrics/FirstContentfulPaint.js.map +0 -1
  655. package/models/trace/lantern/metrics/Interactive.js +0 -68
  656. package/models/trace/lantern/metrics/Interactive.js.map +0 -1
  657. package/models/trace/lantern/metrics/LargestContentfulPaint.js +0 -69
  658. package/models/trace/lantern/metrics/LargestContentfulPaint.js.map +0 -1
  659. package/models/trace/lantern/metrics/MaxPotentialFID.js +0 -49
  660. package/models/trace/lantern/metrics/MaxPotentialFID.js.map +0 -1
  661. package/models/trace/lantern/metrics/Metric.js +0 -69
  662. package/models/trace/lantern/metrics/Metric.js.map +0 -1
  663. package/models/trace/lantern/metrics/SpeedIndex.js +0 -102
  664. package/models/trace/lantern/metrics/SpeedIndex.js.map +0 -1
  665. package/models/trace/lantern/metrics/TBTUtils.js +0 -65
  666. package/models/trace/lantern/metrics/TBTUtils.js.map +0 -1
  667. package/models/trace/lantern/metrics/TotalBlockingTime.js +0 -79
  668. package/models/trace/lantern/metrics/TotalBlockingTime.js.map +0 -1
  669. package/models/trace/lantern/metrics/bundle-tsconfig.json +0 -1
  670. package/models/trace/lantern/metrics/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  671. package/models/trace/lantern/metrics/metrics-tsconfig.json +0 -64
  672. package/models/trace/lantern/metrics/metrics.js +0 -12
  673. package/models/trace/lantern/metrics/metrics.js.map +0 -1
  674. package/models/trace/lantern/simulation/ConnectionPool.js +0 -116
  675. package/models/trace/lantern/simulation/ConnectionPool.js.map +0 -1
  676. package/models/trace/lantern/simulation/Constants.js +0 -43
  677. package/models/trace/lantern/simulation/Constants.js.map +0 -1
  678. package/models/trace/lantern/simulation/DNSCache.js +0 -48
  679. package/models/trace/lantern/simulation/DNSCache.js.map +0 -1
  680. package/models/trace/lantern/simulation/SimulationTimingMap.js +0 -135
  681. package/models/trace/lantern/simulation/SimulationTimingMap.js.map +0 -1
  682. package/models/trace/lantern/simulation/Simulator.js +0 -451
  683. package/models/trace/lantern/simulation/Simulator.js.map +0 -1
  684. package/models/trace/lantern/simulation/TCPConnection.js +0 -155
  685. package/models/trace/lantern/simulation/TCPConnection.js.map +0 -1
  686. package/models/trace/lantern/simulation/bundle-tsconfig.json +0 -1
  687. package/models/trace/lantern/simulation/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  688. package/models/trace/lantern/simulation/simulation-tsconfig.json +0 -59
  689. package/models/trace/lantern/simulation/simulation.js +0 -10
  690. package/models/trace/lantern/simulation/simulation.js.map +0 -1
  691. package/models/trace/lantern/types/Lantern.js +0 -25
  692. package/models/trace/lantern/types/Lantern.js.map +0 -1
  693. package/models/trace/lantern/types/bundle-tsconfig.json +0 -1
  694. package/models/trace/lantern/types/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  695. package/models/trace/lantern/types/types-tsconfig.json +0 -48
  696. package/models/trace/lantern/types/types.js +0 -5
  697. package/models/trace/lantern/types/types.js.map +0 -1
  698. package/models/trace/trace-tsconfig.json +0 -78
  699. package/models/trace/trace.js.map +0 -1
  700. package/models/trace/types/Configuration.js +0 -18
  701. package/models/trace/types/Configuration.js.map +0 -1
  702. package/models/trace/types/Extensions.js +0 -38
  703. package/models/trace/types/Extensions.js.map +0 -1
  704. package/models/trace/types/File.js +0 -82
  705. package/models/trace/types/File.js.map +0 -1
  706. package/models/trace/types/Overlays.js +0 -5
  707. package/models/trace/types/Overlays.js.map +0 -1
  708. package/models/trace/types/Timing.js.map +0 -1
  709. package/models/trace/types/TraceEvents.js.map +0 -1
  710. package/models/trace/types/bundle-tsconfig.json +0 -1
  711. package/models/trace/types/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  712. package/models/trace/types/types-tsconfig.json +0 -65
  713. package/models/trace/types/types.js.map +0 -1
  714. package/test/invalid-animation-events.json.gz +0 -0
  715. package/test/test-trace-engine.mjs +0 -191
  716. package/third_party/legacy-javascript/legacy-javascript.js +0 -1
  717. package/third_party/marked/marked.d.ts +0 -1
  718. package/third_party/marked/marked.js +0 -1
  719. package/third_party/third-party-web/third-party-web.js +0 -1
  720. package/tsconfig.json +0 -29
@@ -1,348 +0,0 @@
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
- import * as Helpers from '../helpers/helpers.js';
5
- import * as Types from '../types/types.js';
6
- import { getLogNormalScore } from './Statistics.js';
7
- import { InsightKeys, } from './types.js';
8
- const GRAPH_SAVINGS_PRECISION = 50;
9
- export function getInsight(insightName, insightSet) {
10
- return insightSet.model[insightName];
11
- }
12
- export function isInsightKey(key) {
13
- return Object.values(InsightKeys).includes(key);
14
- }
15
- export function getLCP(insightSet) {
16
- const insight = getInsight(InsightKeys.LCP_BREAKDOWN, insightSet);
17
- if (!insight || !insight.lcpMs || !insight.lcpEvent) {
18
- return null;
19
- }
20
- const value = Helpers.Timing.milliToMicro(insight.lcpMs);
21
- return { value, event: insight.lcpEvent };
22
- }
23
- export function getINP(insightSet) {
24
- const insight = getInsight(InsightKeys.INP_BREAKDOWN, insightSet);
25
- if (!insight?.longestInteractionEvent?.dur) {
26
- return null;
27
- }
28
- const value = insight.longestInteractionEvent.dur;
29
- return { value, event: insight.longestInteractionEvent };
30
- }
31
- export function getCLS(insightSet) {
32
- const insight = getInsight(InsightKeys.CLS_CULPRITS, insightSet);
33
- if (!insight) {
34
- // Unlike the other metrics, there is always a value for CLS even with no data.
35
- return { value: 0, worstClusterEvent: null };
36
- }
37
- // TODO(cjamcl): the CLS insight should be doing this for us.
38
- let maxScore = 0;
39
- let worstCluster;
40
- for (const cluster of insight.clusters) {
41
- if (cluster.clusterCumulativeScore > maxScore) {
42
- maxScore = cluster.clusterCumulativeScore;
43
- worstCluster = cluster;
44
- }
45
- }
46
- return { value: maxScore, worstClusterEvent: worstCluster ?? null };
47
- }
48
- export function evaluateLCPMetricScore(value) {
49
- return getLogNormalScore({ p10: 2500, median: 4000 }, value);
50
- }
51
- export function evaluateINPMetricScore(value) {
52
- return getLogNormalScore({ p10: 200, median: 500 }, value);
53
- }
54
- export function evaluateCLSMetricScore(value) {
55
- return getLogNormalScore({ p10: 0.1, median: 0.25 }, value);
56
- }
57
- function getPageResult(cruxFieldData, url, origin, scope = null) {
58
- return cruxFieldData.find(result => {
59
- const key = scope ? result[`${scope.pageScope}-${scope.deviceScope}`]?.record.key :
60
- (result['url-ALL'] || result['origin-ALL'])?.record.key;
61
- return (key?.url && key.url === url) || (key?.origin && key.origin === origin);
62
- });
63
- }
64
- function getMetricResult(pageResult, name, scope = null) {
65
- const scopes = [];
66
- if (scope) {
67
- scopes.push(scope);
68
- }
69
- else {
70
- scopes.push({ pageScope: 'url', deviceScope: 'ALL' });
71
- scopes.push({ pageScope: 'origin', deviceScope: 'ALL' });
72
- }
73
- for (const scope of scopes) {
74
- const key = `${scope.pageScope}-${scope.deviceScope}`;
75
- let value = pageResult[key]?.record.metrics[name]?.percentiles?.p75;
76
- if (typeof value === 'string') {
77
- value = Number(value);
78
- }
79
- if (typeof value === 'number' && Number.isFinite(value)) {
80
- return { value, pageScope: scope.pageScope };
81
- }
82
- }
83
- return null;
84
- }
85
- function getMetricTimingResult(pageResult, name, scope = null) {
86
- const result = getMetricResult(pageResult, name, scope);
87
- if (result) {
88
- const valueMs = result.value;
89
- return { value: Helpers.Timing.milliToMicro(valueMs), pageScope: result.pageScope };
90
- }
91
- return null;
92
- }
93
- export function getFieldMetricsForInsightSet(insightSet, metadata, scope = null) {
94
- const cruxFieldData = metadata?.cruxFieldData;
95
- if (!cruxFieldData) {
96
- return null;
97
- }
98
- const pageResult = getPageResult(cruxFieldData, insightSet.url.href, insightSet.url.origin, scope);
99
- if (!pageResult) {
100
- return null;
101
- }
102
- return {
103
- fcp: getMetricTimingResult(pageResult, 'first_contentful_paint', scope),
104
- lcp: getMetricTimingResult(pageResult, 'largest_contentful_paint', scope),
105
- inp: getMetricTimingResult(pageResult, 'interaction_to_next_paint', scope),
106
- cls: getMetricResult(pageResult, 'cumulative_layout_shift', scope),
107
- lcpBreakdown: {
108
- ttfb: getMetricTimingResult(pageResult, 'largest_contentful_paint_image_time_to_first_byte', scope),
109
- loadDelay: getMetricTimingResult(pageResult, 'largest_contentful_paint_image_resource_load_delay', scope),
110
- loadDuration: getMetricTimingResult(pageResult, 'largest_contentful_paint_image_resource_load_duration', scope),
111
- renderDelay: getMetricTimingResult(pageResult, 'largest_contentful_paint_image_element_render_delay', scope),
112
- }
113
- };
114
- }
115
- export function calculateMetricWeightsForSorting(insightSet, metadata) {
116
- const weights = {
117
- lcp: 1 / 3,
118
- inp: 1 / 3,
119
- cls: 1 / 3,
120
- };
121
- const cruxFieldData = metadata?.cruxFieldData;
122
- if (!cruxFieldData) {
123
- return weights;
124
- }
125
- const fieldMetrics = getFieldMetricsForInsightSet(insightSet, metadata);
126
- if (!fieldMetrics) {
127
- return weights;
128
- }
129
- const fieldLcp = fieldMetrics.lcp?.value ?? null;
130
- const fieldInp = fieldMetrics.inp?.value ?? null;
131
- const fieldCls = fieldMetrics.cls?.value ?? null;
132
- const fieldLcpScore = fieldLcp !== null ? evaluateLCPMetricScore(Helpers.Timing.microToMilli(fieldLcp)) : 0;
133
- const fieldInpScore = fieldInp !== null ? evaluateINPMetricScore(Helpers.Timing.microToMilli(fieldInp)) : 0;
134
- const fieldClsScore = fieldCls !== null ? evaluateCLSMetricScore(fieldCls) : 0;
135
- const fieldLcpScoreInverted = 1 - fieldLcpScore;
136
- const fieldInpScoreInverted = 1 - fieldInpScore;
137
- const fieldClsScoreInverted = 1 - fieldClsScore;
138
- const invertedSum = fieldLcpScoreInverted + fieldInpScoreInverted + fieldClsScoreInverted;
139
- if (!invertedSum) {
140
- return weights;
141
- }
142
- weights.lcp = fieldLcpScoreInverted / invertedSum;
143
- weights.inp = fieldInpScoreInverted / invertedSum;
144
- weights.cls = fieldClsScoreInverted / invertedSum;
145
- return weights;
146
- }
147
- /**
148
- * Simulates the provided graph before and after the byte savings from `wastedBytesByRequestId` are applied.
149
- */
150
- function estimateSavingsWithGraphs(wastedBytesByRequestId, simulator, graph) {
151
- const simulationBeforeChanges = simulator.simulate(graph);
152
- const originalTransferSizes = new Map();
153
- graph.traverse(node => {
154
- if (node.type !== 'network') {
155
- return;
156
- }
157
- const wastedBytes = wastedBytesByRequestId.get(node.request.requestId);
158
- if (!wastedBytes) {
159
- return;
160
- }
161
- const original = node.request.transferSize;
162
- originalTransferSizes.set(node.request.requestId, original);
163
- node.request.transferSize = Math.max(original - wastedBytes, 0);
164
- });
165
- const simulationAfterChanges = simulator.simulate(graph);
166
- // Restore the original transfer size after we've done our simulation
167
- graph.traverse(node => {
168
- if (node.type !== 'network') {
169
- return;
170
- }
171
- const originalTransferSize = originalTransferSizes.get(node.request.requestId);
172
- if (originalTransferSize === undefined) {
173
- return;
174
- }
175
- node.request.transferSize = originalTransferSize;
176
- });
177
- let savings = simulationBeforeChanges.timeInMs - simulationAfterChanges.timeInMs;
178
- savings = Math.round(savings / GRAPH_SAVINGS_PRECISION) * GRAPH_SAVINGS_PRECISION;
179
- return Types.Timing.Milli(savings);
180
- }
181
- /**
182
- * Estimates the FCP & LCP savings for wasted bytes in `wastedBytesByRequestId`.
183
- */
184
- export function metricSavingsForWastedBytes(wastedBytesByRequestId, context) {
185
- if (!context.navigation || !context.lantern) {
186
- return;
187
- }
188
- if (!wastedBytesByRequestId.size) {
189
- return { FCP: Types.Timing.Milli(0), LCP: Types.Timing.Milli(0) };
190
- }
191
- const simulator = context.lantern.simulator;
192
- const fcpGraph = context.lantern.metrics.firstContentfulPaint.optimisticGraph;
193
- const lcpGraph = context.lantern.metrics.largestContentfulPaint.optimisticGraph;
194
- return {
195
- FCP: estimateSavingsWithGraphs(wastedBytesByRequestId, simulator, fcpGraph),
196
- LCP: estimateSavingsWithGraphs(wastedBytesByRequestId, simulator, lcpGraph),
197
- };
198
- }
199
- /**
200
- * Returns whether the network request was sent encoded.
201
- */
202
- export function isRequestCompressed(request) {
203
- if (!request.args.data.responseHeaders) {
204
- return false;
205
- }
206
- // FYI: In Lighthouse, older devtools logs (like our test fixtures) seems to be
207
- // lower case, while modern logs are Cased-Like-This.
208
- const patterns = [
209
- /^content-encoding$/i, /^x-content-encoding-over-network$/i,
210
- /^x-original-content-encoding$/i, // Lightrider.
211
- ];
212
- const compressionTypes = ['gzip', 'br', 'deflate', 'zstd'];
213
- return request.args.data.responseHeaders.some(header => patterns.some(p => header.name.match(p)) && compressionTypes.includes(header.value));
214
- }
215
- export function isRequestServedFromBrowserCache(request) {
216
- if (!request.args.data.responseHeaders || request.args.data.failed) {
217
- return false;
218
- }
219
- // Not Modified?
220
- if (request.args.data.statusCode === 304) {
221
- return true;
222
- }
223
- // TODO: for some reason ResourceReceiveResponse events never show a 304 status
224
- // code, so the above is never gonna work. For now, fall back to a dirty check of
225
- // looking at the ratio of transfer size and resource size. If it's really small,
226
- // we certainly did not use the network to fetch it.
227
- const { transferSize, resourceSize } = getRequestSizes(request);
228
- const ratio = resourceSize ? transferSize / resourceSize : 0;
229
- if (ratio < 0.01) {
230
- return true;
231
- }
232
- return false;
233
- }
234
- function getRequestSizes(request) {
235
- const resourceSize = request.args.data.decodedBodyLength;
236
- const transferSize = request.args.data.encodedDataLength;
237
- return { resourceSize, transferSize };
238
- }
239
- /**
240
- * Estimates the number of bytes the content of this network record would have consumed on the network based on the
241
- * uncompressed size (totalBytes). Uses the actual transfer size from the network record if applicable,
242
- * minus the size of the response headers.
243
- *
244
- * @param totalBytes Uncompressed size of the resource
245
- */
246
- export function estimateCompressedContentSize(request, totalBytes, resourceType) {
247
- if (!request || isRequestServedFromBrowserCache(request)) {
248
- // We don't know how many bytes this asset used on the network, but we can guess it was
249
- // roughly the size of the content gzipped.
250
- // See https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/optimize-encoding-and-transfer for specific CSS/Script examples
251
- // See https://discuss.httparchive.org/t/file-size-and-compression-savings/145 for fallback multipliers
252
- switch (resourceType) {
253
- case 'Stylesheet':
254
- // Stylesheets tend to compress extremely well.
255
- return Math.round(totalBytes * 0.2);
256
- case 'Script':
257
- case 'Document':
258
- // Scripts and HTML compress fairly well too.
259
- return Math.round(totalBytes * 0.33);
260
- default:
261
- // Otherwise we'll just fallback to the average savings in HTTPArchive
262
- return Math.round(totalBytes * 0.5);
263
- }
264
- }
265
- // Get the size of the response body on the network.
266
- const { transferSize, resourceSize } = getRequestSizes(request);
267
- let contentTransferSize = transferSize;
268
- if (!isRequestCompressed(request)) {
269
- // This is not compressed, so we can use resourceSize directly.
270
- // This would be equivalent to transfer size minus headers transfer size, but transfer size
271
- // may also include bytes for SSL connection etc.
272
- contentTransferSize = resourceSize;
273
- }
274
- // TODO(cjamcl): Get "responseHeadersTransferSize" in Network handler.
275
- // else if (request.responseHeadersTransferSize) {
276
- // // Subtract the size of the encoded headers.
277
- // contentTransferSize =
278
- // Math.max(0, contentTransferSize - request.responseHeadersTransferSize);
279
- // }
280
- if (request.args.data.resourceType === resourceType) {
281
- // This was a regular standalone asset, just use the transfer size.
282
- return contentTransferSize;
283
- }
284
- // This was an asset that was inlined in a different resource type (e.g. HTML document).
285
- // Use the compression ratio of the resource to estimate the total transferred bytes.
286
- // Get the compression ratio, if it's an invalid number, assume no compression.
287
- const compressionRatio = Number.isFinite(resourceSize) && resourceSize > 0 ? (contentTransferSize / resourceSize) : 1;
288
- return Math.round(totalBytes * compressionRatio);
289
- }
290
- /**
291
- * Utility function to estimate the ratio of the compression of a script.
292
- * This excludes the size of the response headers.
293
- */
294
- export function estimateCompressionRatioForScript(script) {
295
- if (!script.request) {
296
- // Can't find request, so just use 1.
297
- return 1;
298
- }
299
- const request = script.request;
300
- const contentLength = request.args.data.decodedBodyLength ?? script.content?.length ?? 0;
301
- const compressedSize = estimateCompressedContentSize(request, contentLength, "Script" /* Protocol.Network.ResourceType.Script */);
302
- if (contentLength === 0 || compressedSize === 0) {
303
- return 1;
304
- }
305
- const compressionRatio = compressedSize / contentLength;
306
- return compressionRatio;
307
- }
308
- export function calculateDocFirstByteTs(docRequest) {
309
- if (docRequest.args.data.protocol === 'file') {
310
- // file: requests do not have timings
311
- return docRequest.ts;
312
- }
313
- // @ts-expect-error
314
- const isLightrider = globalThis.isLightrider;
315
- if (isLightrider) {
316
- const lrServerResponseTime = docRequest.args.data.lrServerResponseTime;
317
- if (lrServerResponseTime !== undefined) {
318
- return Types.Timing.Micro(docRequest.ts + Helpers.Timing.milliToMicro(lrServerResponseTime));
319
- }
320
- }
321
- const timing = docRequest.args.data.timing;
322
- if (!timing) {
323
- // Older traces do not have timings.
324
- return null;
325
- }
326
- // Time that first byte (headers) are received.
327
- // For older traces, receiveHeadersStart can be missing (ex: web.dev.json.gz).
328
- // In that case use the headers end timing, which should be pretty close to when
329
- // the headers start.
330
- return Types.Timing.Micro(Helpers.Timing.secondsToMicro(timing.requestTime) +
331
- Helpers.Timing.milliToMicro(timing.receiveHeadersStart ?? timing.receiveHeadersEnd));
332
- }
333
- /**
334
- * Calculates the trace bounds for the given insight that are relevant.
335
- *
336
- * Uses the insight's overlays to determine the relevant trace bounds. If there are
337
- * no overlays, falls back to the insight set's navigation bounds.
338
- */
339
- export function insightBounds(insight, insightSetBounds) {
340
- const overlays = insight.createOverlays?.() ?? [];
341
- const windows = overlays.map(Helpers.Timing.traceWindowFromOverlay).filter(bounds => !!bounds);
342
- const overlaysBounds = Helpers.Timing.combineTraceWindowsMicro(windows);
343
- if (overlaysBounds) {
344
- return overlaysBounds;
345
- }
346
- return insightSetBounds;
347
- }
348
- //# sourceMappingURL=Common.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Common.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/Common.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAK7B,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAEjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,WAAW,GAMZ,MAAM,YAAY,CAAC;AAEpB,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,MAAM,UAAU,UAAU,CACtB,WAAwB,EAAE,UAAsB;IAClD,OAAO,UAAU,CAAC,KAAK,C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OAAO,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC;IAClD,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC/F,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACxE,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Protocol from '../../../generated/protocol.js';\nimport type * as CrUXManager from '../../crux-manager/crux-manager.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Lantern from '../lantern/lantern.js';\nimport * as Types from '../types/types.js';\n\nimport {getLogNormalScore} from './Statistics.js';\nimport {\n InsightKeys,\n type InsightModel,\n type InsightModels,\n type InsightSet,\n type InsightSetContext,\n type MetricSavings,\n} from './types.js';\n\nconst GRAPH_SAVINGS_PRECISION = 50;\n\nexport function getInsight<InsightName extends keyof InsightModels>(\n insightName: InsightName, insightSet: InsightSet): InsightModels[InsightName] {\n return insightSet.model[insightName];\n}\n\nexport function isInsightKey(key: string): key is InsightKeys {\n return Object.values(InsightKeys).includes(key as InsightKeys);\n}\n\nexport function getLCP(insightSet: InsightSet):\n {value: Types.Timing.Micro, event: Types.Events.AnyLargestContentfulPaintCandidate}|null {\n const insight = getInsight(InsightKeys.LCP_BREAKDOWN, insightSet);\n if (!insight || !insight.lcpMs || !insight.lcpEvent) {\n return null;\n }\n\n const value = Helpers.Timing.milliToMicro(insight.lcpMs);\n return {value, event: insight.lcpEvent};\n}\n\nexport function getINP(insightSet: InsightSet):\n {value: Types.Timing.Micro, event: Types.Events.SyntheticInteractionPair}|null {\n const insight = getInsight(InsightKeys.INP_BREAKDOWN, insightSet);\n if (!insight?.longestInteractionEvent?.dur) {\n return null;\n }\n\n const value = insight.longestInteractionEvent.dur;\n return {value, event: insight.longestInteractionEvent};\n}\n\nexport function getCLS(insightSet: InsightSet): {value: number, worstClusterEvent: Types.Events.Event|null} {\n const insight = getInsight(InsightKeys.CLS_CULPRITS, insightSet);\n if (!insight) {\n // Unlike the other metrics, there is always a value for CLS even with no data.\n return {value: 0, worstClusterEvent: null};\n }\n\n // TODO(cjamcl): the CLS insight should be doing this for us.\n let maxScore = 0;\n let worstCluster;\n for (const cluster of insight.clusters) {\n if (cluster.clusterCumulativeScore > maxScore) {\n maxScore = cluster.clusterCumulativeScore;\n worstCluster = cluster;\n }\n }\n\n return {value: maxScore, worstClusterEvent: worstCluster ?? null};\n}\n\nexport function evaluateLCPMetricScore(value: Types.Timing.Milli): number {\n return getLogNormalScore({p10: 2500, median: 4000}, value);\n}\n\nexport function evaluateINPMetricScore(value: Types.Timing.Milli): number {\n return getLogNormalScore({p10: 200, median: 500}, value);\n}\n\nexport function evaluateCLSMetricScore(value: number): number {\n return getLogNormalScore({p10: 0.1, median: 0.25}, value);\n}\n\nexport interface CrUXFieldMetricTimingResult {\n value: Types.Timing.Micro;\n pageScope: CrUXManager.PageScope;\n}\nexport interface CrUXFieldMetricNumberResult {\n value: number;\n pageScope: CrUXManager.PageScope;\n}\nexport interface CrUXFieldMetricResults {\n fcp: CrUXFieldMetricTimingResult|null;\n lcp: CrUXFieldMetricTimingResult|null;\n inp: CrUXFieldMetricTimingResult|null;\n cls: CrUXFieldMetricNumberResult|null;\n lcpBreakdown: {\n ttfb: CrUXFieldMetricTimingResult|null,\n loadDelay: CrUXFieldMetricTimingResult|null,\n loadDuration: CrUXFieldMetricTimingResult|null,\n renderDelay: CrUXFieldMetricTimingResult|null,\n };\n}\n\nfunction getPageResult(\n cruxFieldData: CrUXManager.PageResult[], url: string, origin: string,\n scope: CrUXManager.Scope|null = null): CrUXManager.PageResult|undefined {\n return cruxFieldData.find(result => {\n const key = scope ? result[`${scope.pageScope}-${scope.deviceScope}`]?.record.key :\n (result['url-ALL'] || result['origin-ALL'])?.record.key;\n return (key?.url && key.url === url) || (key?.origin && key.origin === origin);\n });\n}\n\nfunction getMetricResult(\n pageResult: CrUXManager.PageResult, name: CrUXManager.StandardMetricNames,\n scope: CrUXManager.Scope|null = null): CrUXFieldMetricNumberResult|null {\n const scopes: Array<{pageScope: CrUXManager.PageScope, deviceScope: CrUXManager.DeviceScope}> = [];\n if (scope) {\n scopes.push(scope);\n } else {\n scopes.push({pageScope: 'url', deviceScope: 'ALL'});\n scopes.push({pageScope: 'origin', deviceScope: 'ALL'});\n }\n\n for (const scope of scopes) {\n const key = `${scope.pageScope}-${scope.deviceScope}` as const;\n let value = pageResult[key]?.record.metrics[name]?.percentiles?.p75;\n if (typeof value === 'string') {\n value = Number(value);\n }\n if (typeof value === 'number' && Number.isFinite(value)) {\n return {value, pageScope: scope.pageScope};\n }\n }\n\n return null;\n}\n\nfunction getMetricTimingResult(\n pageResult: CrUXManager.PageResult, name: CrUXManager.StandardMetricNames,\n scope: CrUXManager.Scope|null = null): CrUXFieldMetricTimingResult|null {\n const result = getMetricResult(pageResult, name, scope);\n if (result) {\n const valueMs = result.value as Types.Timing.Milli;\n return {value: Helpers.Timing.milliToMicro(valueMs), pageScope: result.pageScope};\n }\n\n return null;\n}\n\nexport function getFieldMetricsForInsightSet(\n insightSet: InsightSet, metadata: Types.File.MetaData|null,\n scope: CrUXManager.Scope|null = null): CrUXFieldMetricResults|null {\n const cruxFieldData = metadata?.cruxFieldData;\n if (!cruxFieldData) {\n return null;\n }\n\n const pageResult = getPageResult(cruxFieldData, insightSet.url.href, insightSet.url.origin, scope);\n if (!pageResult) {\n return null;\n }\n\n return {\n fcp: getMetricTimingResult(pageResult, 'first_contentful_paint', scope),\n lcp: getMetricTimingResult(pageResult, 'largest_contentful_paint', scope),\n inp: getMetricTimingResult(pageResult, 'interaction_to_next_paint', scope),\n cls: getMetricResult(pageResult, 'cumulative_layout_shift', scope),\n lcpBreakdown: {\n ttfb: getMetricTimingResult(pageResult, 'largest_contentful_paint_image_time_to_first_byte', scope),\n loadDelay: getMetricTimingResult(pageResult, 'largest_contentful_paint_image_resource_load_delay', scope),\n loadDuration: getMetricTimingResult(pageResult, 'largest_contentful_paint_image_resource_load_duration', scope),\n renderDelay: getMetricTimingResult(pageResult, 'largest_contentful_paint_image_element_render_delay', scope),\n }\n };\n}\n\nexport function calculateMetricWeightsForSorting(\n insightSet: InsightSet, metadata: Types.File.MetaData|null): {lcp: number, inp: number, cls: number} {\n const weights = {\n lcp: 1 / 3,\n inp: 1 / 3,\n cls: 1 / 3,\n };\n\n const cruxFieldData = metadata?.cruxFieldData;\n if (!cruxFieldData) {\n return weights;\n }\n\n const fieldMetrics = getFieldMetricsForInsightSet(insightSet, metadata);\n if (!fieldMetrics) {\n return weights;\n }\n\n const fieldLcp = fieldMetrics.lcp?.value ?? null;\n const fieldInp = fieldMetrics.inp?.value ?? null;\n const fieldCls = fieldMetrics.cls?.value ?? null;\n const fieldLcpScore = fieldLcp !== null ? evaluateLCPMetricScore(Helpers.Timing.microToMilli(fieldLcp)) : 0;\n const fieldInpScore = fieldInp !== null ? evaluateINPMetricScore(Helpers.Timing.microToMilli(fieldInp)) : 0;\n const fieldClsScore = fieldCls !== null ? evaluateCLSMetricScore(fieldCls) : 0;\n const fieldLcpScoreInverted = 1 - fieldLcpScore;\n const fieldInpScoreInverted = 1 - fieldInpScore;\n const fieldClsScoreInverted = 1 - fieldClsScore;\n const invertedSum = fieldLcpScoreInverted + fieldInpScoreInverted + fieldClsScoreInverted;\n if (!invertedSum) {\n return weights;\n }\n\n weights.lcp = fieldLcpScoreInverted / invertedSum;\n weights.inp = fieldInpScoreInverted / invertedSum;\n weights.cls = fieldClsScoreInverted / invertedSum;\n\n return weights;\n}\n\n/**\n * Simulates the provided graph before and after the byte savings from `wastedBytesByRequestId` are applied.\n */\nfunction estimateSavingsWithGraphs(\n wastedBytesByRequestId: Map<string, number>, simulator: Lantern.Simulation.Simulator,\n graph: Lantern.Graph.Node): Types.Timing.Milli {\n const simulationBeforeChanges = simulator.simulate(graph);\n\n const originalTransferSizes = new Map<string, number>();\n graph.traverse(node => {\n if (node.type !== 'network') {\n return;\n }\n const wastedBytes = wastedBytesByRequestId.get(node.request.requestId);\n if (!wastedBytes) {\n return;\n }\n\n const original = node.request.transferSize;\n originalTransferSizes.set(node.request.requestId, original);\n\n node.request.transferSize = Math.max(original - wastedBytes, 0);\n });\n\n const simulationAfterChanges = simulator.simulate(graph);\n\n // Restore the original transfer size after we've done our simulation\n graph.traverse(node => {\n if (node.type !== 'network') {\n return;\n }\n const originalTransferSize = originalTransferSizes.get(node.request.requestId);\n if (originalTransferSize === undefined) {\n return;\n }\n node.request.transferSize = originalTransferSize;\n });\n\n let savings = simulationBeforeChanges.timeInMs - simulationAfterChanges.timeInMs;\n savings = Math.round(savings / GRAPH_SAVINGS_PRECISION) * GRAPH_SAVINGS_PRECISION;\n return Types.Timing.Milli(savings);\n}\n\n/**\n * Estimates the FCP & LCP savings for wasted bytes in `wastedBytesByRequestId`.\n */\nexport function metricSavingsForWastedBytes(\n wastedBytesByRequestId: Map<string, number>, context: InsightSetContext): MetricSavings|undefined {\n if (!context.navigation || !context.lantern) {\n return;\n }\n\n if (!wastedBytesByRequestId.size) {\n return {FCP: Types.Timing.Milli(0), LCP: Types.Timing.Milli(0)};\n }\n\n const simulator = context.lantern.simulator;\n const fcpGraph = context.lantern.metrics.firstContentfulPaint.optimisticGraph;\n const lcpGraph = context.lantern.metrics.largestContentfulPaint.optimisticGraph;\n\n return {\n FCP: estimateSavingsWithGraphs(wastedBytesByRequestId, simulator, fcpGraph),\n LCP: estimateSavingsWithGraphs(wastedBytesByRequestId, simulator, lcpGraph),\n };\n}\n\n/**\n * Returns whether the network request was sent encoded.\n */\nexport function isRequestCompressed(request: Types.Events.SyntheticNetworkRequest): boolean {\n if (!request.args.data.responseHeaders) {\n return false;\n }\n\n // FYI: In Lighthouse, older devtools logs (like our test fixtures) seems to be\n // lower case, while modern logs are Cased-Like-This.\n const patterns = [\n /^content-encoding$/i, /^x-content-encoding-over-network$/i,\n /^x-original-content-encoding$/i, // Lightrider.\n ];\n const compressionTypes = ['gzip', 'br', 'deflate', 'zstd'];\n return request.args.data.responseHeaders.some(\n header => patterns.some(p => header.name.match(p)) && compressionTypes.includes(header.value));\n}\n\nexport function isRequestServedFromBrowserCache(request: Types.Events.SyntheticNetworkRequest): boolean {\n if (!request.args.data.responseHeaders || request.args.data.failed) {\n return false;\n }\n\n // Not Modified?\n if (request.args.data.statusCode === 304) {\n return true;\n }\n\n // TODO: for some reason ResourceReceiveResponse events never show a 304 status\n // code, so the above is never gonna work. For now, fall back to a dirty check of\n // looking at the ratio of transfer size and resource size. If it's really small,\n // we certainly did not use the network to fetch it.\n\n const {transferSize, resourceSize} = getRequestSizes(request);\n const ratio = resourceSize ? transferSize / resourceSize : 0;\n if (ratio < 0.01) {\n return true;\n }\n\n return false;\n}\n\nfunction getRequestSizes(request: Types.Events.SyntheticNetworkRequest): {resourceSize: number, transferSize: number} {\n const resourceSize = request.args.data.decodedBodyLength;\n const transferSize = request.args.data.encodedDataLength;\n return {resourceSize, transferSize};\n}\n\n/**\n * Estimates the number of bytes the content of this network record would have consumed on the network based on the\n * uncompressed size (totalBytes). Uses the actual transfer size from the network record if applicable,\n * minus the size of the response headers.\n *\n * @param totalBytes Uncompressed size of the resource\n */\nexport function estimateCompressedContentSize(\n request: Types.Events.SyntheticNetworkRequest|undefined, totalBytes: number,\n resourceType: Protocol.Network.ResourceType): number {\n if (!request || isRequestServedFromBrowserCache(request)) {\n // We don't know how many bytes this asset used on the network, but we can guess it was\n // roughly the size of the content gzipped.\n // See https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/optimize-encoding-and-transfer for specific CSS/Script examples\n // See https://discuss.httparchive.org/t/file-size-and-compression-savings/145 for fallback multipliers\n switch (resourceType) {\n case 'Stylesheet':\n // Stylesheets tend to compress extremely well.\n return Math.round(totalBytes * 0.2);\n case 'Script':\n case 'Document':\n // Scripts and HTML compress fairly well too.\n return Math.round(totalBytes * 0.33);\n default:\n // Otherwise we'll just fallback to the average savings in HTTPArchive\n return Math.round(totalBytes * 0.5);\n }\n }\n\n // Get the size of the response body on the network.\n const {transferSize, resourceSize} = getRequestSizes(request);\n let contentTransferSize = transferSize;\n if (!isRequestCompressed(request)) {\n // This is not compressed, so we can use resourceSize directly.\n // This would be equivalent to transfer size minus headers transfer size, but transfer size\n // may also include bytes for SSL connection etc.\n contentTransferSize = resourceSize;\n }\n // TODO(cjamcl): Get \"responseHeadersTransferSize\" in Network handler.\n // else if (request.responseHeadersTransferSize) {\n // // Subtract the size of the encoded headers.\n // contentTransferSize =\n // Math.max(0, contentTransferSize - request.responseHeadersTransferSize);\n // }\n\n if (request.args.data.resourceType === resourceType) {\n // This was a regular standalone asset, just use the transfer size.\n return contentTransferSize;\n }\n\n // This was an asset that was inlined in a different resource type (e.g. HTML document).\n // Use the compression ratio of the resource to estimate the total transferred bytes.\n // Get the compression ratio, if it's an invalid number, assume no compression.\n const compressionRatio = Number.isFinite(resourceSize) && resourceSize > 0 ? (contentTransferSize / resourceSize) : 1;\n return Math.round(totalBytes * compressionRatio);\n}\n\n/**\n * Utility function to estimate the ratio of the compression of a script.\n * This excludes the size of the response headers.\n */\nexport function estimateCompressionRatioForScript(script: Handlers.ModelHandlers.Scripts.Script): number {\n if (!script.request) {\n // Can't find request, so just use 1.\n return 1;\n }\n\n const request = script.request;\n const contentLength = request.args.data.decodedBodyLength ?? script.content?.length ?? 0;\n const compressedSize = estimateCompressedContentSize(request, contentLength, Protocol.Network.ResourceType.Script);\n if (contentLength === 0 || compressedSize === 0) {\n return 1;\n }\n\n const compressionRatio = compressedSize / contentLength;\n return compressionRatio;\n}\n\nexport function calculateDocFirstByteTs(docRequest: Types.Events.SyntheticNetworkRequest): Types.Timing.Micro|null {\n if (docRequest.args.data.protocol === 'file') {\n // file: requests do not have timings\n return docRequest.ts;\n }\n\n // @ts-expect-error\n const isLightrider = globalThis.isLightrider;\n if (isLightrider) {\n const lrServerResponseTime = docRequest.args.data.lrServerResponseTime;\n if (lrServerResponseTime !== undefined) {\n return Types.Timing.Micro(docRequest.ts + Helpers.Timing.milliToMicro(lrServerResponseTime));\n }\n }\n\n const timing = docRequest.args.data.timing;\n if (!timing) {\n // Older traces do not have timings.\n return null;\n }\n\n // Time that first byte (headers) are received.\n // For older traces, receiveHeadersStart can be missing (ex: web.dev.json.gz).\n // In that case use the headers end timing, which should be pretty close to when\n // the headers start.\n return Types.Timing.Micro(\n Helpers.Timing.secondsToMicro(timing.requestTime) +\n Helpers.Timing.milliToMicro(timing.receiveHeadersStart ?? timing.receiveHeadersEnd));\n}\n\n/**\n * Calculates the trace bounds for the given insight that are relevant.\n *\n * Uses the insight's overlays to determine the relevant trace bounds. If there are\n * no overlays, falls back to the insight set's navigation bounds.\n */\nexport function insightBounds(\n insight: InsightModel, insightSetBounds: Types.Timing.TraceWindowMicro): Types.Timing.TraceWindowMicro {\n const overlays = insight.createOverlays?.() ?? [];\n const windows = overlays.map(Helpers.Timing.traceWindowFromOverlay).filter(bounds => !!bounds);\n const overlaysBounds = Helpers.Timing.combineTraceWindowsMicro(windows);\n if (overlaysBounds) {\n return overlaysBounds;\n }\n\n return insightSetBounds;\n}\n"]}
@@ -1,182 +0,0 @@
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
- // import * as i18n from '../../../core/i18n/i18n.js';
5
- import * as Handlers from '../handlers/handlers.js';
6
- import * as Helpers from '../helpers/helpers.js';
7
- import * as Types from '../types/types.js';
8
- import { InsightCategory, InsightKeys, } from './types.js';
9
- export const UIStrings = {
10
- /**
11
- * @description Title of an insight that recommends reducing the size of the DOM tree as a means to improve page responsiveness. "DOM" is an acronym and should not be translated.
12
- */
13
- title: 'Optimize DOM size',
14
- /**
15
- * @description Description of an insight that recommends reducing the size of the DOM tree as a means to improve page responsiveness. "DOM" is an acronym and should not be translated. "layout reflows" are when the browser will recompute the layout of content on the page.
16
- */
17
- description: 'A large DOM can increase the duration of style calculations and layout reflows, impacting page responsiveness. A large DOM will also increase memory usage. [Learn how to avoid an excessive DOM size](https://developer.chrome.com/docs/performance/insights/dom-size).',
18
- /**
19
- * @description Header for a column containing the names of statistics as opposed to the actual statistic values.
20
- */
21
- statistic: 'Statistic',
22
- /**
23
- * @description Header for a column containing the value of a statistic.
24
- */
25
- value: 'Value',
26
- /**
27
- * @description Header for a column containing the page element related to a statistic.
28
- */
29
- element: 'Element',
30
- /**
31
- * @description Label for a value representing the total number of elements on the page.
32
- */
33
- totalElements: 'Total elements',
34
- /**
35
- * @description Label for a value representing the maximum depth of the Document Object Model (DOM). "DOM" is a acronym and should not be translated.
36
- */
37
- maxDOMDepth: 'DOM depth',
38
- /**
39
- * @description Label for a value representing the maximum number of child elements of any parent element on the page.
40
- */
41
- maxChildren: 'Most children',
42
- /**
43
- * @description Text for a section.
44
- */
45
- topUpdatesDescription: 'These are the largest layout and style recalculation events. Their performance impact may be reduced by making the DOM simpler.',
46
- /**
47
- * @description Label used for a time duration.
48
- */
49
- duration: 'Duration',
50
- /**
51
- * @description Message displayed in a table detailing how big a layout (rendering) is.
52
- * @example {134} PH1
53
- */
54
- largeLayout: 'Layout ({PH1} objects)',
55
- /**
56
- * @description Message displayed in a table detailing how big a style recalculation (rendering) is.
57
- * @example {134} PH1
58
- */
59
- largeStyleRecalc: 'Style recalculation ({PH1} elements)',
60
- };
61
- // const str_ = i18n.i18n.registerUIStrings('models/trace/insights/DOMSize.ts', UIStrings);
62
- export const i18nString = (i18nId, values) => ({i18nId, values}); // i18n.i18n.getLocalizedString.bind(undefined, str_);
63
- const DOM_SIZE_DURATION_THRESHOLD = Helpers.Timing.milliToMicro(Types.Timing.Milli(40));
64
- // These thresholds were selected to maximize the number of long (>40ms) events above
65
- // the threshold while maximizing the number of short (<40ms) events below the threshold.
66
- // See go/rpp-dom-size-thresholds for the analysis that produced these thresholds.
67
- const LAYOUT_OBJECTS_THRESHOLD = 100;
68
- const STYLE_RECALC_ELEMENTS_THRESHOLD = 300;
69
- function finalize(partialModel) {
70
- const relatedEvents = [...partialModel.largeLayoutUpdates, ...partialModel.largeStyleRecalcs];
71
- return {
72
- insightKey: InsightKeys.DOM_SIZE,
73
- strings: UIStrings,
74
- title: i18nString(UIStrings.title),
75
- description: i18nString(UIStrings.description),
76
- docs: 'https://developer.chrome.com/docs/performance/insights/dom-size',
77
- category: InsightCategory.INP,
78
- state: relatedEvents.length > 0 ? 'informative' : 'pass',
79
- ...partialModel,
80
- relatedEvents,
81
- };
82
- }
83
- export function isDomSizeInsight(model) {
84
- return model.insightKey === InsightKeys.DOM_SIZE;
85
- }
86
- export function generateInsight(data, context) {
87
- const isWithinContext = (event) => Helpers.Timing.eventIsInBounds(event, context.bounds);
88
- const mainTid = context.navigation?.tid;
89
- const largeLayoutUpdates = [];
90
- const largeStyleRecalcs = [];
91
- const threads = Handlers.Threads.threadsInRenderer(data.Renderer, data.AuctionWorklets);
92
- for (const thread of threads) {
93
- if (thread.type !== Handlers.Threads.ThreadType.MAIN_THREAD) {
94
- continue;
95
- }
96
- if (mainTid === undefined) {
97
- // We won't have a specific thread ID to reference if the context does not have a navigation.
98
- // In this case, we'll just filter out any OOPIFs threads.
99
- if (!thread.processIsOnMainFrame) {
100
- continue;
101
- }
102
- }
103
- else if (thread.tid !== mainTid) {
104
- continue;
105
- }
106
- const rendererThread = data.Renderer.processes.get(thread.pid)?.threads.get(thread.tid);
107
- if (!rendererThread) {
108
- continue;
109
- }
110
- const { entries, layoutEvents, recalcStyleEvents } = rendererThread;
111
- if (!entries.length) {
112
- continue;
113
- }
114
- const first = entries[0];
115
- const last = entries[entries.length - 1];
116
- const timeRange = Helpers.Timing.traceWindowFromMicroSeconds(first.ts, Types.Timing.Micro(last.ts + (last.dur ?? 0)));
117
- if (!Helpers.Timing.boundsIncludeTimeRange({ timeRange, bounds: context.bounds })) {
118
- continue;
119
- }
120
- for (const event of layoutEvents) {
121
- if (event.dur < DOM_SIZE_DURATION_THRESHOLD || !isWithinContext(event)) {
122
- continue;
123
- }
124
- const { dirtyObjects } = event.args.beginData;
125
- if (dirtyObjects > LAYOUT_OBJECTS_THRESHOLD) {
126
- largeLayoutUpdates.push(event);
127
- }
128
- }
129
- for (const event of recalcStyleEvents) {
130
- if (event.dur < DOM_SIZE_DURATION_THRESHOLD || !isWithinContext(event)) {
131
- continue;
132
- }
133
- const { elementCount } = event.args;
134
- if (elementCount > STYLE_RECALC_ELEMENTS_THRESHOLD) {
135
- largeStyleRecalcs.push(event);
136
- }
137
- }
138
- }
139
- const largeUpdates = [
140
- ...largeLayoutUpdates.map(event => {
141
- const duration = (event.dur / 1000);
142
- const size = event.args.beginData.dirtyObjects;
143
- const label = i18nString(UIStrings.largeLayout, { PH1: size });
144
- return { label, duration, size, event };
145
- }),
146
- ...largeStyleRecalcs.map(event => {
147
- const duration = (event.dur / 1000);
148
- const size = event.args.elementCount;
149
- const label = i18nString(UIStrings.largeStyleRecalc, { PH1: size });
150
- return { label, duration, size, event };
151
- }),
152
- ].sort((a, b) => b.duration - a.duration).slice(0, 5);
153
- const domStatsEvents = data.DOMStats.domStatsByFrameId.get(context.frameId)?.filter(isWithinContext) ?? [];
154
- let maxDOMStats;
155
- for (const domStats of domStatsEvents) {
156
- // While recording a cross-origin navigation, there can be overlapping dom stats from before & after
157
- // the navigation which share a frameId. In this case we should also ensure the pid matches up with
158
- // the navigation we care about (i.e. from after the navigation event).
159
- const navigationPid = context.navigation?.pid;
160
- if (navigationPid && domStats.pid !== navigationPid) {
161
- continue;
162
- }
163
- if (!maxDOMStats || domStats.args.data.totalElements > maxDOMStats.args.data.totalElements) {
164
- maxDOMStats = domStats;
165
- }
166
- }
167
- return finalize({
168
- largeLayoutUpdates,
169
- largeStyleRecalcs,
170
- largeUpdates,
171
- maxDOMStats,
172
- });
173
- }
174
- export function createOverlays(model) {
175
- const entries = [...model.largeStyleRecalcs, ...model.largeLayoutUpdates];
176
- return entries.map(entry => ({
177
- type: 'ENTRY_OUTLINE',
178
- entry,
179
- outlineReason: 'ERROR',
180
- }));
181
- }
182
- //# sourceMappingURL=DOMSize.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DOMSize.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/DOMSize.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAG7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EACL,eAAe,EACf,WAAW,GAIZ,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,mBAAmB;IAC1B;;OAEG;IACH,WAAW,EACP,0QAA0Q;IAC9Q;;OAEG;IACH,SAAS,EAAE,WAAW;IACtB;;OAEG;IACH,KAAK,EAAE,OAAO;IACd;;OAEG;IACH,OAAO,EAAE,SAAS;IAClB;;OAEG;IACH,aAAa,EAAE,gBAAgB;IAC/B;;OAEG;IACH,WAAW,EAAE,WAAW;IACxB;;OAEG;IACH,WAAW,EAAE,eAAe;IAC5B;;OAEG;IACH,qBAAqB,EACjB,iIAAiI;IACrI;;OAEG;IACH,QAAQ,EAAE,UAAU;IACpB;;;OAGG;IACH,WAAW,EAAE,wBAAwB;IACrC;;;OAGG;IACH,gBAAgB,EAAE,sCAAsC;CAChD,CAAC;AAEX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,kCAAkC,EAAE,SAAS,CAAC,CAAC;AACx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CAAC;YAC3F,WAAW,GAAG,QAAQ,CAAC;QACzB,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;QACd,kBAAkB;QAClB,iBAAiB;QACjB,YAAY;QACZ,WAAW;KACZ,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,iBAAiB,EAAE,GAAG,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC1E,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACR,IAAI,EAAE,eAAe;QACrB,KAAK;QACL,aAAa,EAAE,OAAO;KACvB,CAAC,CAAC,CAAC;AACzB,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Common from '../../../core/common/common.js';\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n * @description Title of an insight that recommends reducing the size of the DOM tree as a means to improve page responsiveness. \"DOM\" is an acronym and should not be translated.\n */\n title: 'Optimize DOM size',\n /**\n * @description Description of an insight that recommends reducing the size of the DOM tree as a means to improve page responsiveness. \"DOM\" is an acronym and should not be translated. \"layout reflows\" are when the browser will recompute the layout of content on the page.\n */\n description:\n 'A large DOM can increase the duration of style calculations and layout reflows, impacting page responsiveness. A large DOM will also increase memory usage. [Learn how to avoid an excessive DOM size](https://developer.chrome.com/docs/performance/insights/dom-size).',\n /**\n * @description Header for a column containing the names of statistics as opposed to the actual statistic values.\n */\n statistic: 'Statistic',\n /**\n * @description Header for a column containing the value of a statistic.\n */\n value: 'Value',\n /**\n * @description Header for a column containing the page element related to a statistic.\n */\n element: 'Element',\n /**\n * @description Label for a value representing the total number of elements on the page.\n */\n totalElements: 'Total elements',\n /**\n * @description Label for a value representing the maximum depth of the Document Object Model (DOM). \"DOM\" is a acronym and should not be translated.\n */\n maxDOMDepth: 'DOM depth',\n /**\n * @description Label for a value representing the maximum number of child elements of any parent element on the page.\n */\n maxChildren: 'Most children',\n /**\n * @description Text for a section.\n */\n topUpdatesDescription:\n 'These are the largest layout and style recalculation events. Their performance impact may be reduced by making the DOM simpler.',\n /**\n * @description Label used for a time duration.\n */\n duration: 'Duration',\n /**\n * @description Message displayed in a table detailing how big a layout (rendering) is.\n * @example {134} PH1\n */\n largeLayout: 'Layout ({PH1} objects)',\n /**\n * @description Message displayed in a table detailing how big a style recalculation (rendering) is.\n * @example {134} PH1\n */\n largeStyleRecalc: 'Style recalculation ({PH1} elements)',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/DOMSize.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nconst DOM_SIZE_DURATION_THRESHOLD = Helpers.Timing.milliToMicro(Types.Timing.Milli(40));\n\n// These thresholds were selected to maximize the number of long (>40ms) events above\n// the threshold while maximizing the number of short (<40ms) events below the threshold.\n// See go/rpp-dom-size-thresholds for the analysis that produced these thresholds.\nconst LAYOUT_OBJECTS_THRESHOLD = 100;\nconst STYLE_RECALC_ELEMENTS_THRESHOLD = 300;\n\nexport type DOMSizeInsightModel = InsightModel<typeof UIStrings, {\n largeLayoutUpdates: Types.Events.Layout[],\n largeStyleRecalcs: Types.Events.RecalcStyle[],\n largeUpdates: Array<\n {label: Common.UIString.LocalizedString, duration: Types.Timing.Milli, size: number, event: Types.Events.Event}>,\n maxDOMStats?: Types.Events.DOMStats,\n}>;\n\nfunction finalize(partialModel: PartialInsightModel<DOMSizeInsightModel>): DOMSizeInsightModel {\n const relatedEvents = [...partialModel.largeLayoutUpdates, ...partialModel.largeStyleRecalcs];\n return {\n insightKey: InsightKeys.DOM_SIZE,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n docs: 'https://developer.chrome.com/docs/performance/insights/dom-size',\n category: InsightCategory.INP,\n state: relatedEvents.length > 0 ? 'informative' : 'pass',\n ...partialModel,\n relatedEvents,\n };\n}\n\nexport function isDomSizeInsight(model: InsightModel): model is DOMSizeInsightModel {\n return model.insightKey === InsightKeys.DOM_SIZE;\n}\n\nexport function generateInsight(data: Handlers.Types.HandlerData, context: InsightSetContext): DOMSizeInsightModel {\n const isWithinContext = (event: Types.Events.Event): boolean => Helpers.Timing.eventIsInBounds(event, context.bounds);\n\n const mainTid = context.navigation?.tid;\n\n const largeLayoutUpdates: Types.Events.Layout[] = [];\n const largeStyleRecalcs: Types.Events.RecalcStyle[] = [];\n\n const threads = Handlers.Threads.threadsInRenderer(data.Renderer, data.AuctionWorklets);\n for (const thread of threads) {\n if (thread.type !== Handlers.Threads.ThreadType.MAIN_THREAD) {\n continue;\n }\n\n if (mainTid === undefined) {\n // We won't have a specific thread ID to reference if the context does not have a navigation.\n // In this case, we'll just filter out any OOPIFs threads.\n if (!thread.processIsOnMainFrame) {\n continue;\n }\n } else if (thread.tid !== mainTid) {\n continue;\n }\n\n const rendererThread = data.Renderer.processes.get(thread.pid)?.threads.get(thread.tid);\n if (!rendererThread) {\n continue;\n }\n\n const {entries, layoutEvents, recalcStyleEvents} = rendererThread;\n if (!entries.length) {\n continue;\n }\n\n const first = entries[0];\n const last = entries[entries.length - 1];\n const timeRange =\n Helpers.Timing.traceWindowFromMicroSeconds(first.ts, Types.Timing.Micro(last.ts + (last.dur ?? 0)));\n if (!Helpers.Timing.boundsIncludeTimeRange({timeRange, bounds: context.bounds})) {\n continue;\n }\n\n for (const event of layoutEvents) {\n if (event.dur < DOM_SIZE_DURATION_THRESHOLD || !isWithinContext(event)) {\n continue;\n }\n\n const {dirtyObjects} = event.args.beginData;\n if (dirtyObjects > LAYOUT_OBJECTS_THRESHOLD) {\n largeLayoutUpdates.push(event);\n }\n }\n\n for (const event of recalcStyleEvents) {\n if (event.dur < DOM_SIZE_DURATION_THRESHOLD || !isWithinContext(event)) {\n continue;\n }\n\n const {elementCount} = event.args;\n if (elementCount > STYLE_RECALC_ELEMENTS_THRESHOLD) {\n largeStyleRecalcs.push(event);\n }\n }\n }\n\n const largeUpdates: DOMSizeInsightModel['largeUpdates'] = [\n ...largeLayoutUpdates.map(event => {\n const duration = (event.dur / 1000) as Types.Timing.Milli;\n const size = event.args.beginData.dirtyObjects;\n const label = i18nString(UIStrings.largeLayout, {PH1: size});\n return {label, duration, size, event};\n }),\n ...largeStyleRecalcs.map(event => {\n const duration = (event.dur / 1000) as Types.Timing.Milli;\n const size = event.args.elementCount;\n const label = i18nString(UIStrings.largeStyleRecalc, {PH1: size});\n return {label, duration, size, event};\n }),\n ].sort((a, b) => b.duration - a.duration).slice(0, 5);\n\n const domStatsEvents = data.DOMStats.domStatsByFrameId.get(context.frameId)?.filter(isWithinContext) ?? [];\n let maxDOMStats: Types.Events.DOMStats|undefined;\n for (const domStats of domStatsEvents) {\n // While recording a cross-origin navigation, there can be overlapping dom stats from before & after\n // the navigation which share a frameId. In this case we should also ensure the pid matches up with\n // the navigation we care about (i.e. from after the navigation event).\n const navigationPid = context.navigation?.pid;\n if (navigationPid && domStats.pid !== navigationPid) {\n continue;\n }\n\n if (!maxDOMStats || domStats.args.data.totalElements > maxDOMStats.args.data.totalElements) {\n maxDOMStats = domStats;\n }\n }\n\n return finalize({\n largeLayoutUpdates,\n largeStyleRecalcs,\n largeUpdates,\n maxDOMStats,\n });\n}\n\nexport function createOverlays(model: DOMSizeInsightModel): Types.Overlays.Overlay[] {\n const entries = [...model.largeStyleRecalcs, ...model.largeLayoutUpdates];\n return entries.map(entry => ({\n type: 'ENTRY_OUTLINE',\n entry,\n outlineReason: 'ERROR',\n }));\n}\n"]}