@paulirish/trace_engine 0.0.67-beta.2 → 0.0.67

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 (759) hide show
  1. package/.tmp/tsbuildinfo/analyze-inspector-issues.d.mts +13 -0
  2. package/.tmp/tsbuildinfo/analyze-inspector-issues.d.mts.map +1 -0
  3. package/.tmp/tsbuildinfo/analyze-trace.d.mts +17 -0
  4. package/.tmp/tsbuildinfo/analyze-trace.d.mts.map +1 -0
  5. package/.tmp/tsbuildinfo/test/test-trace-engine.d.mts +2 -0
  6. package/.tmp/tsbuildinfo/test/test-trace-engine.d.mts.map +1 -0
  7. package/.tmp/tsbuildinfo/third_party/third-party-web/third-party-web.d.ts +3 -0
  8. package/.tmp/tsbuildinfo/third_party/third-party-web/third-party-web.d.ts.map +1 -0
  9. package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -0
  10. package/README.md +22 -62
  11. package/analyze-inspector-issues.mjs +60 -0
  12. package/analyze-trace.mjs +144 -6
  13. package/core/common/ParsedURL.js +512 -0
  14. package/core/common/ParsedURL.js.map +1 -0
  15. package/core/common/common.d.ts +8 -33
  16. package/core/common/common.js +2 -0
  17. package/core/host/host.d.ts +1 -13
  18. package/core/host/host.js +1 -0
  19. package/core/i18n/i18n.d.ts +20 -8
  20. package/core/i18n/i18n.js +15 -0
  21. package/core/platform/ArrayUtilities.js +224 -0
  22. package/core/platform/ArrayUtilities.js.map +1 -0
  23. package/core/platform/Brand.js +5 -0
  24. package/core/platform/Brand.js.map +1 -0
  25. package/core/platform/Constructor.js +5 -0
  26. package/core/platform/Constructor.js.map +1 -0
  27. package/core/platform/DateUtilities.js +14 -0
  28. package/core/platform/DateUtilities.js.map +1 -0
  29. package/core/platform/DevToolsPath.js +28 -0
  30. package/core/platform/DevToolsPath.js.map +1 -0
  31. package/core/platform/HostRuntime.js +8 -0
  32. package/core/platform/HostRuntime.js.map +1 -0
  33. package/core/platform/KeyboardUtilities.js +34 -0
  34. package/core/platform/KeyboardUtilities.js.map +1 -0
  35. package/core/platform/MapUtilities.js +80 -0
  36. package/core/platform/MapUtilities.js.map +1 -0
  37. package/core/platform/MimeType.js +157 -0
  38. package/core/platform/MimeType.js.map +1 -0
  39. package/core/platform/NumberUtilities.js +73 -0
  40. package/core/platform/NumberUtilities.js.map +1 -0
  41. package/core/platform/Size.js +36 -0
  42. package/core/platform/Size.js.map +1 -0
  43. package/core/platform/StringUtilities.js +731 -0
  44. package/core/platform/StringUtilities.js.map +1 -0
  45. package/core/platform/Timing.js +10 -0
  46. package/core/platform/Timing.js.map +1 -0
  47. package/core/platform/TypedArrayUtilities.js +158 -0
  48. package/core/platform/TypedArrayUtilities.js.map +1 -0
  49. package/core/platform/TypescriptUtilities.js +17 -0
  50. package/core/platform/TypescriptUtilities.js.map +1 -0
  51. package/core/platform/UIString.d.ts +5 -2
  52. package/core/platform/UIString.js +5 -0
  53. package/core/platform/UIString.js.map +1 -0
  54. package/core/platform/UserVisibleError.d.ts +1 -12
  55. package/core/platform/UserVisibleError.js +23 -0
  56. package/core/platform/UserVisibleError.js.map +1 -0
  57. package/core/platform/api/HostRuntime.d.ts +1 -0
  58. package/core/platform/api/HostRuntime.js +5 -0
  59. package/core/platform/api/HostRuntime.js.map +1 -0
  60. package/core/platform/api/api-tsconfig.json +58 -0
  61. package/core/platform/api/api-tsconfig.ref.json +26 -0
  62. package/core/platform/api/api.js +6 -0
  63. package/core/platform/api/api.js.map +1 -0
  64. package/core/platform/bundle-tsconfig.json +59 -0
  65. package/core/platform/bundle-tsconfig.ref.json +27 -0
  66. package/core/platform/foundation_unittests-tsconfig.json +73 -0
  67. package/core/platform/foundation_unittests-tsconfig.ref.json +40 -0
  68. package/core/platform/foundation_unittests_node_typecheck-tsconfig.json +69 -0
  69. package/core/platform/platform-tsconfig.json +81 -0
  70. package/core/platform/platform-tsconfig.ref.json +49 -0
  71. package/core/platform/platform.js +28 -0
  72. package/core/platform/platform.js.map +1 -0
  73. package/core/platform/platform_node_typecheck-tsconfig.json +78 -0
  74. package/core/platform/platform_node_typecheck.stamp +0 -0
  75. package/core/root/root.d.ts +1 -4
  76. package/core/root/root.js +1 -0
  77. package/core/sdk/sdk.d.ts +27 -97
  78. package/core/sdk/sdk.js +1 -0
  79. package/generated/protocol.js +3304 -0
  80. package/locales/af.json +86 -92
  81. package/locales/am.json +350 -356
  82. package/locales/ar.json +351 -357
  83. package/locales/as.json +349 -355
  84. package/locales/az.json +340 -346
  85. package/locales/be.json +350 -356
  86. package/locales/bg.json +350 -356
  87. package/locales/bn.json +350 -356
  88. package/locales/bs.json +243 -249
  89. package/locales/ca.json +279 -285
  90. package/locales/cs.json +335 -341
  91. package/locales/cy.json +114 -120
  92. package/locales/da.json +199 -205
  93. package/locales/de.json +219 -225
  94. package/locales/el.json +335 -341
  95. package/locales/en-GB.json +8 -14
  96. package/locales/en-US.json +249 -252
  97. package/locales/en-XL.json +1055 -0
  98. package/locales/es-419.json +275 -281
  99. package/locales/es.json +276 -282
  100. package/locales/et.json +231 -237
  101. package/locales/eu.json +119 -125
  102. package/locales/fa.json +350 -356
  103. package/locales/fi.json +280 -286
  104. package/locales/fil.json +1 -7
  105. package/locales/fr-CA.json +307 -313
  106. package/locales/fr.json +304 -310
  107. package/locales/gl.json +259 -265
  108. package/locales/gu.json +351 -357
  109. package/locales/he.json +351 -357
  110. package/locales/hi.json +335 -341
  111. package/locales/hr.json +234 -240
  112. package/locales/hu.json +341 -347
  113. package/locales/hy.json +350 -356
  114. package/locales/id.json +2 -8
  115. package/locales/is.json +302 -308
  116. package/locales/it.json +136 -142
  117. package/locales/ja.json +350 -356
  118. package/locales/ka.json +351 -357
  119. package/locales/kk.json +351 -357
  120. package/locales/km.json +350 -356
  121. package/locales/kn.json +351 -357
  122. package/locales/ko.json +350 -356
  123. package/locales/ky.json +349 -355
  124. package/locales/lo.json +351 -357
  125. package/locales/lt.json +319 -325
  126. package/locales/lv.json +316 -322
  127. package/locales/mk.json +351 -357
  128. package/locales/ml.json +350 -356
  129. package/locales/mn.json +350 -356
  130. package/locales/mr.json +350 -356
  131. package/locales/ms.json +2 -8
  132. package/locales/my.json +349 -355
  133. package/locales/ne.json +335 -341
  134. package/locales/nl.json +61 -67
  135. package/locales/no.json +169 -175
  136. package/locales/or.json +350 -356
  137. package/locales/pa.json +350 -356
  138. package/locales/pl.json +306 -312
  139. package/locales/pt-PT.json +271 -277
  140. package/locales/pt.json +265 -271
  141. package/locales/ro.json +305 -311
  142. package/locales/ru.json +350 -356
  143. package/locales/si.json +351 -357
  144. package/locales/sk.json +332 -338
  145. package/locales/sl.json +214 -220
  146. package/locales/sq.json +315 -321
  147. package/locales/sr-Latn.json +252 -258
  148. package/locales/sr.json +351 -357
  149. package/locales/sv.json +275 -281
  150. package/locales/sw.json +2 -8
  151. package/locales/ta.json +351 -357
  152. package/locales/te.json +349 -355
  153. package/locales/th.json +351 -357
  154. package/locales/tr.json +325 -331
  155. package/locales/uk.json +350 -356
  156. package/locales/ur.json +351 -357
  157. package/locales/uz.json +159 -165
  158. package/locales/vi.json +351 -357
  159. package/locales/zh-HK.json +351 -357
  160. package/locales/zh-TW.json +350 -356
  161. package/locales/zh.json +350 -356
  162. package/locales/zu.json +2 -8
  163. package/models/cpu_profile/CPUProfileDataModel.js +517 -0
  164. package/models/cpu_profile/CPUProfileDataModel.js.map +1 -0
  165. package/models/cpu_profile/ProfileTreeModel.js +90 -0
  166. package/models/cpu_profile/ProfileTreeModel.js.map +1 -0
  167. package/models/cpu_profile/bundle-tsconfig.json +59 -0
  168. package/models/cpu_profile/bundle-tsconfig.ref.json +27 -0
  169. package/models/cpu_profile/cpu_profile-tsconfig.json +63 -0
  170. package/models/cpu_profile/cpu_profile-tsconfig.ref.json +31 -0
  171. package/models/cpu_profile/cpu_profile.js +7 -0
  172. package/models/cpu_profile/cpu_profile.js.map +1 -0
  173. package/models/cpu_profile/cpu_profile_node_typecheck-tsconfig.json +60 -0
  174. package/models/cpu_profile/cpu_profile_node_typecheck.stamp +0 -0
  175. package/models/cpu_profile/foundation_unittests-tsconfig.json +63 -0
  176. package/models/cpu_profile/foundation_unittests-tsconfig.ref.json +30 -0
  177. package/models/cpu_profile/foundation_unittests_node_typecheck-tsconfig.json +59 -0
  178. package/models/crux-manager/crux-manager.d.ts +3 -1
  179. package/models/crux-manager/crux-manager.js +1 -0
  180. package/models/trace/EntityMapper.js +133 -0
  181. package/models/trace/EntityMapper.js.map +1 -0
  182. package/models/trace/EventsSerializer.d.ts +1 -0
  183. package/models/trace/EventsSerializer.js +118 -0
  184. package/models/trace/EventsSerializer.js.map +1 -0
  185. package/models/trace/LanternComputationData.js +368 -0
  186. package/models/trace/LanternComputationData.js.map +1 -0
  187. package/models/trace/ModelImpl.js +181 -0
  188. package/models/trace/ModelImpl.js.map +1 -0
  189. package/models/trace/Name.js +115 -0
  190. package/models/trace/Name.js.map +1 -0
  191. package/models/trace/Processor.js +616 -0
  192. package/models/trace/Processor.js.map +1 -0
  193. package/models/trace/Styles.d.ts +2 -2
  194. package/models/trace/Styles.js +836 -0
  195. package/models/trace/Styles.js.map +1 -0
  196. package/models/trace/bundle-tsconfig.json +77 -0
  197. package/models/trace/bundle-tsconfig.ref.json +45 -0
  198. package/models/trace/extras/FilmStrip.js +45 -0
  199. package/models/trace/extras/FilmStrip.js.map +1 -0
  200. package/models/trace/extras/Initiators.js +47 -0
  201. package/models/trace/extras/Initiators.js.map +1 -0
  202. package/models/trace/extras/MainThreadActivity.js +77 -0
  203. package/models/trace/extras/MainThreadActivity.js.map +1 -0
  204. package/models/trace/extras/ScriptDuplication.js +163 -0
  205. package/models/trace/extras/ScriptDuplication.js.map +1 -0
  206. package/models/trace/extras/StackTraceForEvent.js +192 -0
  207. package/models/trace/extras/StackTraceForEvent.js.map +1 -0
  208. package/models/trace/extras/ThirdParties.js +119 -0
  209. package/models/trace/extras/ThirdParties.js.map +1 -0
  210. package/models/trace/extras/TraceFilter.js +51 -0
  211. package/models/trace/extras/TraceFilter.js.map +1 -0
  212. package/models/trace/extras/TraceTree.js +652 -0
  213. package/models/trace/extras/TraceTree.js.map +1 -0
  214. package/models/trace/extras/bundle-tsconfig.json +59 -0
  215. package/models/trace/extras/bundle-tsconfig.ref.json +27 -0
  216. package/models/trace/extras/extras-tsconfig.json +81 -0
  217. package/models/trace/extras/extras-tsconfig.ref.json +49 -0
  218. package/models/trace/extras/extras.js +12 -0
  219. package/models/trace/extras/extras.js.map +1 -0
  220. package/models/trace/extras/extras_node_typecheck-tsconfig.json +78 -0
  221. package/models/trace/extras/extras_node_typecheck.stamp +0 -0
  222. package/models/trace/extras/foundation_unittests-tsconfig.json +91 -0
  223. package/models/trace/extras/foundation_unittests-tsconfig.ref.json +58 -0
  224. package/models/trace/extras/foundation_unittests_node_typecheck-tsconfig.json +87 -0
  225. package/models/trace/foundation_unittests-tsconfig.json +70 -0
  226. package/models/trace/foundation_unittests-tsconfig.ref.json +37 -0
  227. package/models/trace/foundation_unittests_node_typecheck-tsconfig.json +66 -0
  228. package/models/trace/handlers/AnimationFramesHandler.js +110 -0
  229. package/models/trace/handlers/AnimationFramesHandler.js.map +1 -0
  230. package/models/trace/handlers/AnimationHandler.js +27 -0
  231. package/models/trace/handlers/AnimationHandler.js.map +1 -0
  232. package/models/trace/handlers/AsyncJSCallsHandler.js +188 -0
  233. package/models/trace/handlers/AsyncJSCallsHandler.js.map +1 -0
  234. package/models/trace/handlers/DOMStatsHandler.js +22 -0
  235. package/models/trace/handlers/DOMStatsHandler.js.map +1 -0
  236. package/models/trace/handlers/ExtensionTraceDataHandler.js +264 -0
  237. package/models/trace/handlers/ExtensionTraceDataHandler.js.map +1 -0
  238. package/models/trace/handlers/FlowsHandler.js +149 -0
  239. package/models/trace/handlers/FlowsHandler.js.map +1 -0
  240. package/models/trace/handlers/FramesHandler.js +491 -0
  241. package/models/trace/handlers/FramesHandler.js.map +1 -0
  242. package/models/trace/handlers/GPUHandler.js +36 -0
  243. package/models/trace/handlers/GPUHandler.js.map +1 -0
  244. package/models/trace/handlers/ImagePaintingHandler.js +148 -0
  245. package/models/trace/handlers/ImagePaintingHandler.js.map +1 -0
  246. package/models/trace/handlers/InitiatorsHandler.js +181 -0
  247. package/models/trace/handlers/InitiatorsHandler.js.map +1 -0
  248. package/models/trace/handlers/InvalidationsHandler.js +125 -0
  249. package/models/trace/handlers/InvalidationsHandler.js.map +1 -0
  250. package/models/trace/handlers/LargestImagePaintHandler.js +86 -0
  251. package/models/trace/handlers/LargestImagePaintHandler.js.map +1 -0
  252. package/models/trace/handlers/LargestTextPaintHandler.js +28 -0
  253. package/models/trace/handlers/LargestTextPaintHandler.js.map +1 -0
  254. package/models/trace/handlers/LayerTreeHandler.js +104 -0
  255. package/models/trace/handlers/LayerTreeHandler.js.map +1 -0
  256. package/models/trace/handlers/LayoutShiftsHandler.js +453 -0
  257. package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -0
  258. package/models/trace/handlers/MemoryHandler.js +22 -0
  259. package/models/trace/handlers/MemoryHandler.js.map +1 -0
  260. package/models/trace/handlers/MetaHandler.js +442 -0
  261. package/models/trace/handlers/MetaHandler.js.map +1 -0
  262. package/models/trace/handlers/ModelHandlers.js +33 -0
  263. package/models/trace/handlers/ModelHandlers.js.map +1 -0
  264. package/models/trace/handlers/NetworkRequestsHandler.js +578 -0
  265. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -0
  266. package/models/trace/handlers/PageFramesHandler.js +43 -0
  267. package/models/trace/handlers/PageFramesHandler.js.map +1 -0
  268. package/models/trace/handlers/PageLoadMetricsHandler.js +463 -0
  269. package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -0
  270. package/models/trace/handlers/RendererHandler.js +346 -0
  271. package/models/trace/handlers/RendererHandler.js.map +1 -0
  272. package/models/trace/handlers/SamplesHandler.js +261 -0
  273. package/models/trace/handlers/SamplesHandler.js.map +1 -0
  274. package/models/trace/handlers/ScreenshotsHandler.js +56 -0
  275. package/models/trace/handlers/ScreenshotsHandler.js.map +1 -0
  276. package/models/trace/handlers/ScriptsHandler.js +277 -0
  277. package/models/trace/handlers/ScriptsHandler.js.map +1 -0
  278. package/models/trace/handlers/SelectorStatsHandler.js +72 -0
  279. package/models/trace/handlers/SelectorStatsHandler.js.map +1 -0
  280. package/models/trace/handlers/Threads.js +108 -0
  281. package/models/trace/handlers/Threads.js.map +1 -0
  282. package/models/trace/handlers/UserInteractionsHandler.js +319 -0
  283. package/models/trace/handlers/UserInteractionsHandler.js.map +1 -0
  284. package/models/trace/handlers/UserTimingsHandler.js +194 -0
  285. package/models/trace/handlers/UserTimingsHandler.js.map +1 -0
  286. package/models/trace/handlers/WarningsHandler.js +135 -0
  287. package/models/trace/handlers/WarningsHandler.js.map +1 -0
  288. package/models/trace/handlers/WorkersHandler.js +34 -0
  289. package/models/trace/handlers/WorkersHandler.js.map +1 -0
  290. package/models/trace/handlers/bundle-tsconfig.json +59 -0
  291. package/models/trace/handlers/bundle-tsconfig.ref.json +27 -0
  292. package/models/trace/handlers/foundation_unittests-tsconfig.json +102 -0
  293. package/models/trace/handlers/foundation_unittests-tsconfig.ref.json +69 -0
  294. package/models/trace/handlers/foundation_unittests_node_typecheck-tsconfig.json +98 -0
  295. package/models/trace/handlers/handlers-tsconfig.json +112 -0
  296. package/models/trace/handlers/handlers-tsconfig.ref.json +80 -0
  297. package/models/trace/handlers/handlers.js +8 -0
  298. package/models/trace/handlers/handlers.js.map +1 -0
  299. package/models/trace/handlers/handlers_node_typecheck-tsconfig.json +109 -0
  300. package/models/trace/handlers/handlers_node_typecheck.stamp +0 -0
  301. package/models/trace/handlers/helpers.js +167 -0
  302. package/models/trace/handlers/helpers.js.map +1 -0
  303. package/models/trace/handlers/types.js +2 -0
  304. package/models/trace/handlers/types.js.map +1 -0
  305. package/models/trace/helpers/Extensions.js +42 -0
  306. package/models/trace/helpers/Extensions.js.map +1 -0
  307. package/models/trace/helpers/Network.js +103 -0
  308. package/models/trace/helpers/Network.js.map +1 -0
  309. package/models/trace/helpers/SamplesIntegrator.js +527 -0
  310. package/models/trace/helpers/SamplesIntegrator.js.map +1 -0
  311. package/models/trace/helpers/SyntheticEvents.js +96 -0
  312. package/models/trace/helpers/SyntheticEvents.js.map +1 -0
  313. package/models/trace/helpers/Timing.js +200 -0
  314. package/models/trace/helpers/Timing.js.map +1 -0
  315. package/models/trace/helpers/Trace.js +844 -0
  316. package/models/trace/helpers/Trace.js.map +1 -0
  317. package/models/trace/helpers/TreeHelpers.js +255 -0
  318. package/models/trace/helpers/TreeHelpers.js.map +1 -0
  319. package/models/trace/helpers/bundle-tsconfig.json +59 -0
  320. package/models/trace/helpers/bundle-tsconfig.ref.json +27 -0
  321. package/models/trace/helpers/foundation_unittests-tsconfig.json +73 -0
  322. package/models/trace/helpers/foundation_unittests-tsconfig.ref.json +40 -0
  323. package/models/trace/helpers/foundation_unittests_node_typecheck-tsconfig.json +69 -0
  324. package/models/trace/helpers/helpers-tsconfig.json +77 -0
  325. package/models/trace/helpers/helpers-tsconfig.ref.json +45 -0
  326. package/models/trace/helpers/helpers.js +11 -0
  327. package/models/trace/helpers/helpers.js.map +1 -0
  328. package/models/trace/helpers/helpers_node_typecheck-tsconfig.json +74 -0
  329. package/models/trace/helpers/helpers_node_typecheck.stamp +0 -0
  330. package/models/trace/insights/CLSCulprits.d.ts +14 -14
  331. package/models/trace/insights/CLSCulprits.js +519 -0
  332. package/models/trace/insights/CLSCulprits.js.map +1 -0
  333. package/models/trace/insights/Cache.d.ts +6 -6
  334. package/models/trace/insights/Cache.js +210 -0
  335. package/models/trace/insights/Cache.js.map +1 -0
  336. package/models/trace/insights/CharacterSet.d.ts +8 -8
  337. package/models/trace/insights/CharacterSet.js +132 -0
  338. package/models/trace/insights/CharacterSet.js.map +1 -0
  339. package/models/trace/insights/Common.js +367 -0
  340. package/models/trace/insights/Common.js.map +1 -0
  341. package/models/trace/insights/DOMSize.d.ts +13 -13
  342. package/models/trace/insights/DOMSize.js +182 -0
  343. package/models/trace/insights/DOMSize.js.map +1 -0
  344. package/models/trace/insights/DocumentLatency.d.ts +11 -11
  345. package/models/trace/insights/DocumentLatency.js +259 -0
  346. package/models/trace/insights/DocumentLatency.js.map +1 -0
  347. package/models/trace/insights/DuplicatedJavaScript.d.ts +5 -5
  348. package/models/trace/insights/DuplicatedJavaScript.js +110 -0
  349. package/models/trace/insights/DuplicatedJavaScript.js.map +1 -0
  350. package/models/trace/insights/FontDisplay.d.ts +5 -5
  351. package/models/trace/insights/FontDisplay.js +93 -0
  352. package/models/trace/insights/FontDisplay.js.map +1 -0
  353. package/models/trace/insights/ForcedReflow.d.ts +7 -7
  354. package/models/trace/insights/ForcedReflow.js +162 -0
  355. package/models/trace/insights/ForcedReflow.js.map +1 -0
  356. package/models/trace/insights/INPBreakdown.d.ts +8 -8
  357. package/models/trace/insights/INPBreakdown.js +130 -0
  358. package/models/trace/insights/INPBreakdown.js.map +1 -0
  359. package/models/trace/insights/ImageDelivery.d.ts +12 -12
  360. package/models/trace/insights/ImageDelivery.js +264 -0
  361. package/models/trace/insights/ImageDelivery.js.map +1 -0
  362. package/models/trace/insights/LCPBreakdown.d.ts +11 -11
  363. package/models/trace/insights/LCPBreakdown.js +200 -0
  364. package/models/trace/insights/LCPBreakdown.js.map +1 -0
  365. package/models/trace/insights/LCPDiscovery.d.ts +10 -10
  366. package/models/trace/insights/LCPDiscovery.js +190 -0
  367. package/models/trace/insights/LCPDiscovery.js.map +1 -0
  368. package/models/trace/insights/LegacyJavaScript.d.ts +5 -5
  369. package/models/trace/insights/LegacyJavaScript.js +99 -0
  370. package/models/trace/insights/LegacyJavaScript.js.map +1 -0
  371. package/models/trace/insights/Models.js +23 -0
  372. package/models/trace/insights/Models.js.map +1 -0
  373. package/models/trace/insights/ModernHTTP.d.ts +5 -5
  374. package/models/trace/insights/ModernHTTP.js +205 -0
  375. package/models/trace/insights/ModernHTTP.js.map +1 -0
  376. package/models/trace/insights/NetworkDependencyTree.d.ts +19 -19
  377. package/models/trace/insights/NetworkDependencyTree.js +551 -0
  378. package/models/trace/insights/NetworkDependencyTree.js.map +1 -0
  379. package/models/trace/insights/RenderBlocking.d.ts +5 -5
  380. package/models/trace/insights/RenderBlocking.js +211 -0
  381. package/models/trace/insights/RenderBlocking.js.map +1 -0
  382. package/models/trace/insights/SlowCSSSelector.d.ts +10 -10
  383. package/models/trace/insights/SlowCSSSelector.js +140 -0
  384. package/models/trace/insights/SlowCSSSelector.js.map +1 -0
  385. package/models/trace/insights/Statistics.js +93 -0
  386. package/models/trace/insights/Statistics.js.map +1 -0
  387. package/models/trace/insights/ThirdParties.d.ts +6 -6
  388. package/models/trace/insights/ThirdParties.js +110 -0
  389. package/models/trace/insights/ThirdParties.js.map +1 -0
  390. package/models/trace/insights/Viewport.d.ts +3 -3
  391. package/models/trace/insights/Viewport.js +105 -0
  392. package/models/trace/insights/Viewport.js.map +1 -0
  393. package/models/trace/insights/bundle-tsconfig.json +59 -0
  394. package/models/trace/insights/bundle-tsconfig.ref.json +27 -0
  395. package/models/trace/insights/foundation_unittests-tsconfig.json +98 -0
  396. package/models/trace/insights/foundation_unittests-tsconfig.ref.json +65 -0
  397. package/models/trace/insights/foundation_unittests_node_typecheck-tsconfig.json +94 -0
  398. package/models/trace/insights/insights-tsconfig.json +114 -0
  399. package/models/trace/insights/insights-tsconfig.ref.json +82 -0
  400. package/models/trace/insights/insights.js +10 -0
  401. package/models/trace/insights/insights.js.map +1 -0
  402. package/models/trace/insights/insights_node_typecheck-tsconfig.json +111 -0
  403. package/models/trace/insights/insights_node_typecheck.stamp +0 -0
  404. package/models/trace/insights/types.d.ts +3 -3
  405. package/models/trace/insights/types.js +41 -0
  406. package/models/trace/insights/types.js.map +1 -0
  407. package/models/trace/lantern/bundle-tsconfig.json +71 -0
  408. package/models/trace/lantern/bundle-tsconfig.ref.json +39 -0
  409. package/models/trace/lantern/core/LanternError.js +7 -0
  410. package/models/trace/lantern/core/LanternError.js.map +1 -0
  411. package/models/trace/lantern/core/NetworkAnalyzer.js +496 -0
  412. package/models/trace/lantern/core/NetworkAnalyzer.js.map +1 -0
  413. package/models/trace/lantern/core/bundle-tsconfig.json +59 -0
  414. package/models/trace/lantern/core/bundle-tsconfig.ref.json +27 -0
  415. package/models/trace/lantern/core/core-tsconfig.json +60 -0
  416. package/models/trace/lantern/core/core-tsconfig.ref.json +28 -0
  417. package/models/trace/lantern/core/core.js +6 -0
  418. package/models/trace/lantern/core/core.js.map +1 -0
  419. package/models/trace/lantern/core/core_node_typecheck-tsconfig.json +57 -0
  420. package/models/trace/lantern/core/core_node_typecheck.stamp +0 -0
  421. package/models/trace/lantern/core/foundation_unittests-tsconfig.json +69 -0
  422. package/models/trace/lantern/core/foundation_unittests-tsconfig.ref.json +36 -0
  423. package/models/trace/lantern/core/foundation_unittests_node_typecheck-tsconfig.json +65 -0
  424. package/models/trace/lantern/graph/BaseNode.d.ts +2 -2
  425. package/models/trace/lantern/graph/BaseNode.js +277 -0
  426. package/models/trace/lantern/graph/BaseNode.js.map +1 -0
  427. package/models/trace/lantern/graph/CPUNode.js +80 -0
  428. package/models/trace/lantern/graph/CPUNode.js.map +1 -0
  429. package/models/trace/lantern/graph/NetworkNode.js +95 -0
  430. package/models/trace/lantern/graph/NetworkNode.js.map +1 -0
  431. package/models/trace/lantern/graph/PageDependencyGraph.js +574 -0
  432. package/models/trace/lantern/graph/PageDependencyGraph.js.map +1 -0
  433. package/models/trace/lantern/graph/bundle-tsconfig.json +59 -0
  434. package/models/trace/lantern/graph/bundle-tsconfig.ref.json +27 -0
  435. package/models/trace/lantern/graph/foundation_unittests-tsconfig.json +61 -0
  436. package/models/trace/lantern/graph/foundation_unittests-tsconfig.ref.json +28 -0
  437. package/models/trace/lantern/graph/foundation_unittests_node_typecheck-tsconfig.json +57 -0
  438. package/models/trace/lantern/graph/graph-tsconfig.json +65 -0
  439. package/models/trace/lantern/graph/graph-tsconfig.ref.json +33 -0
  440. package/models/trace/lantern/graph/graph.js +8 -0
  441. package/models/trace/lantern/graph/graph.js.map +1 -0
  442. package/models/trace/lantern/graph/graph_node_typecheck-tsconfig.json +62 -0
  443. package/models/trace/lantern/graph/graph_node_typecheck.stamp +0 -0
  444. package/models/trace/lantern/lantern.js +10 -0
  445. package/models/trace/lantern/lantern.js.map +1 -0
  446. package/models/trace/lantern/metrics/FirstContentfulPaint.js +137 -0
  447. package/models/trace/lantern/metrics/FirstContentfulPaint.js.map +1 -0
  448. package/models/trace/lantern/metrics/Interactive.js +68 -0
  449. package/models/trace/lantern/metrics/Interactive.js.map +1 -0
  450. package/models/trace/lantern/metrics/LargestContentfulPaint.js +75 -0
  451. package/models/trace/lantern/metrics/LargestContentfulPaint.js.map +1 -0
  452. package/models/trace/lantern/metrics/MaxPotentialFID.js +49 -0
  453. package/models/trace/lantern/metrics/MaxPotentialFID.js.map +1 -0
  454. package/models/trace/lantern/metrics/Metric.js +69 -0
  455. package/models/trace/lantern/metrics/Metric.js.map +1 -0
  456. package/models/trace/lantern/metrics/SpeedIndex.js +102 -0
  457. package/models/trace/lantern/metrics/SpeedIndex.js.map +1 -0
  458. package/models/trace/lantern/metrics/TBTUtils.js +65 -0
  459. package/models/trace/lantern/metrics/TBTUtils.js.map +1 -0
  460. package/models/trace/lantern/metrics/TotalBlockingTime.js +79 -0
  461. package/models/trace/lantern/metrics/TotalBlockingTime.js.map +1 -0
  462. package/models/trace/lantern/metrics/bundle-tsconfig.json +59 -0
  463. package/models/trace/lantern/metrics/bundle-tsconfig.ref.json +27 -0
  464. package/models/trace/lantern/metrics/foundation_unittests-tsconfig.json +76 -0
  465. package/models/trace/lantern/metrics/foundation_unittests-tsconfig.ref.json +43 -0
  466. package/models/trace/lantern/metrics/foundation_unittests_node_typecheck-tsconfig.json +72 -0
  467. package/models/trace/lantern/metrics/metrics-tsconfig.json +75 -0
  468. package/models/trace/lantern/metrics/metrics-tsconfig.ref.json +43 -0
  469. package/models/trace/lantern/metrics/metrics.js +12 -0
  470. package/models/trace/lantern/metrics/metrics.js.map +1 -0
  471. package/models/trace/lantern/metrics/metrics_node_typecheck-tsconfig.json +72 -0
  472. package/models/trace/lantern/metrics/metrics_node_typecheck.stamp +0 -0
  473. package/models/trace/lantern/simulation/ConnectionPool.js +116 -0
  474. package/models/trace/lantern/simulation/ConnectionPool.js.map +1 -0
  475. package/models/trace/lantern/simulation/Constants.js +45 -0
  476. package/models/trace/lantern/simulation/Constants.js.map +1 -0
  477. package/models/trace/lantern/simulation/DNSCache.js +48 -0
  478. package/models/trace/lantern/simulation/DNSCache.js.map +1 -0
  479. package/models/trace/lantern/simulation/SimulationTimingMap.js +135 -0
  480. package/models/trace/lantern/simulation/SimulationTimingMap.js.map +1 -0
  481. package/models/trace/lantern/simulation/Simulator.js +457 -0
  482. package/models/trace/lantern/simulation/Simulator.js.map +1 -0
  483. package/models/trace/lantern/simulation/TCPConnection.js +155 -0
  484. package/models/trace/lantern/simulation/TCPConnection.js.map +1 -0
  485. package/models/trace/lantern/simulation/bundle-tsconfig.json +59 -0
  486. package/models/trace/lantern/simulation/bundle-tsconfig.ref.json +27 -0
  487. package/models/trace/lantern/simulation/foundation_unittests-tsconfig.json +75 -0
  488. package/models/trace/lantern/simulation/foundation_unittests-tsconfig.ref.json +42 -0
  489. package/models/trace/lantern/simulation/foundation_unittests_node_typecheck-tsconfig.json +71 -0
  490. package/models/trace/lantern/simulation/simulation-tsconfig.json +70 -0
  491. package/models/trace/lantern/simulation/simulation-tsconfig.ref.json +38 -0
  492. package/models/trace/lantern/simulation/simulation.js +10 -0
  493. package/models/trace/lantern/simulation/simulation.js.map +1 -0
  494. package/models/trace/lantern/simulation/simulation_node_typecheck-tsconfig.json +67 -0
  495. package/models/trace/lantern/simulation/simulation_node_typecheck.stamp +0 -0
  496. package/models/trace/lantern/testing/bundle-tsconfig.json +60 -0
  497. package/models/trace/lantern/testing/bundle-tsconfig.ref.json +27 -0
  498. package/models/trace/lantern/testing/testing-tsconfig.json +63 -0
  499. package/models/trace/lantern/testing/testing-tsconfig.ref.json +30 -0
  500. package/models/trace/lantern/types/Lantern.d.ts +19 -19
  501. package/models/trace/lantern/types/Lantern.js +25 -0
  502. package/models/trace/lantern/types/Lantern.js.map +1 -0
  503. package/models/trace/lantern/types/bundle-tsconfig.json +59 -0
  504. package/models/trace/lantern/types/bundle-tsconfig.ref.json +27 -0
  505. package/models/trace/lantern/types/types-tsconfig.json +59 -0
  506. package/models/trace/lantern/types/types-tsconfig.ref.json +27 -0
  507. package/models/trace/lantern/types/types.js +5 -0
  508. package/models/trace/lantern/types/types.js.map +1 -0
  509. package/models/trace/lantern/types/types_node_typecheck-tsconfig.json +56 -0
  510. package/models/trace/lantern/types/types_node_typecheck.stamp +0 -0
  511. package/models/trace/trace-tsconfig.json +89 -0
  512. package/models/trace/trace-tsconfig.ref.json +57 -0
  513. package/models/trace/trace.js +16 -544
  514. package/models/trace/trace.js.map +1 -0
  515. package/models/trace/trace_node_typecheck-tsconfig.json +86 -0
  516. package/models/trace/trace_node_typecheck.stamp +0 -0
  517. package/models/trace/types/Configuration.d.ts +2 -2
  518. package/models/trace/types/Configuration.js +19 -0
  519. package/models/trace/types/Configuration.js.map +1 -0
  520. package/models/trace/types/Extensions.d.ts +1 -1
  521. package/models/trace/types/Extensions.js +38 -0
  522. package/models/trace/types/Extensions.js.map +1 -0
  523. package/models/trace/types/File.d.ts +9 -3
  524. package/models/trace/types/File.js +92 -0
  525. package/models/trace/types/File.js.map +1 -0
  526. package/models/trace/types/Overlays.js +5 -0
  527. package/models/trace/types/Overlays.js.map +1 -0
  528. package/models/trace/types/Timing.js +16 -0
  529. package/models/trace/types/Timing.js.map +1 -0
  530. package/models/trace/types/TraceEvents.d.ts +21 -16
  531. package/models/trace/types/TraceEvents.js +983 -0
  532. package/models/trace/types/TraceEvents.js.map +1 -0
  533. package/models/trace/types/bundle-tsconfig.json +59 -0
  534. package/models/trace/types/bundle-tsconfig.ref.json +27 -0
  535. package/models/trace/types/foundation_unittests-tsconfig.json +67 -0
  536. package/models/trace/types/foundation_unittests-tsconfig.ref.json +34 -0
  537. package/models/trace/types/foundation_unittests_node_typecheck-tsconfig.json +63 -0
  538. package/models/trace/types/types-tsconfig.json +76 -0
  539. package/models/trace/types/types-tsconfig.ref.json +44 -0
  540. package/models/trace/types/types.js +10 -0
  541. package/models/trace/types/types.js.map +1 -0
  542. package/models/trace/types/types_node_typecheck-tsconfig.json +73 -0
  543. package/models/trace/types/types_node_typecheck.stamp +0 -0
  544. package/package.json +8 -40
  545. package/test/invalid-animation-events.json.gz +0 -0
  546. package/test/test-trace-engine.mjs +191 -0
  547. package/third_party/legacy-javascript/bundle-tsconfig.json +59 -0
  548. package/third_party/legacy-javascript/bundle-tsconfig.ref.json +27 -0
  549. package/third_party/legacy-javascript/legacy-javascript-tsconfig.ref.json +15 -0
  550. package/third_party/legacy-javascript/legacy-javascript.js +3 -0
  551. package/third_party/legacy-javascript/legacy-javascript.js.map +1 -0
  552. package/third_party/legacy-javascript/lib/legacy-javascript.js +1119 -0
  553. package/third_party/marked/marked.d.ts +1 -2
  554. package/third_party/marked/marked.js +1 -0
  555. package/third_party/third-party-web/third-party-web.d.ts +1 -2
  556. package/third_party/third-party-web/third-party-web.js +1 -0
  557. package/tsconfig.json +29 -0
  558. package/core/common/Base64.d.ts +0 -12
  559. package/core/common/CharacterIdMap.d.ts +0 -5
  560. package/core/common/Color.d.ts +0 -357
  561. package/core/common/ColorConverter.d.ts +0 -26
  562. package/core/common/ColorUtils.d.ts +0 -45
  563. package/core/common/Console.d.ts +0 -54
  564. package/core/common/Debouncer.d.ts +0 -8
  565. package/core/common/EventTarget.d.ts +0 -22
  566. package/core/common/Gzip.d.ts +0 -23
  567. package/core/common/JavaScriptMetaData.d.ts +0 -20
  568. package/core/common/Lazy.d.ts +0 -4
  569. package/core/common/MapWithDefault.d.ts +0 -9
  570. package/core/common/Mutex.d.ts +0 -13
  571. package/core/common/Object.d.ts +0 -20
  572. package/core/common/Progress.d.ts +0 -47
  573. package/core/common/ResolverBase.d.ts +0 -29
  574. package/core/common/ResourceType.d.ts +0 -52
  575. package/core/common/ReturnToPanel.d.ts +0 -10
  576. package/core/common/Revealer.d.ts +0 -66
  577. package/core/common/Runnable.d.ts +0 -14
  578. package/core/common/SegmentedRange.d.ts +0 -14
  579. package/core/common/SettingRegistration.d.ts +0 -136
  580. package/core/common/Settings.d.ts +0 -228
  581. package/core/common/SimpleHistoryManager.d.ts +0 -20
  582. package/core/common/Srcset.d.ts +0 -16
  583. package/core/common/StringOutputStream.d.ts +0 -10
  584. package/core/common/TextDictionary.d.ts +0 -11
  585. package/core/common/Throttler.d.ts +0 -12
  586. package/core/common/Trie.d.ts +0 -24
  587. package/core/common/VersionController.d.ts +0 -85
  588. package/core/host/AidaClient.d.ts +0 -73
  589. package/core/host/AidaClientTypes.d.ts +0 -355
  590. package/core/host/AidaGcaTranslation.d.ts +0 -10
  591. package/core/host/DispatchHttpRequestClient.d.ts +0 -14
  592. package/core/host/GcaClient.d.ts +0 -14
  593. package/core/host/GcaTypes.d.ts +0 -411
  594. package/core/host/GdpClient.d.ts +0 -84
  595. package/core/host/InspectorFrontendHost.d.ts +0 -29
  596. package/core/host/InspectorFrontendHostAPI.d.ts +0 -425
  597. package/core/host/InspectorFrontendHostStub.d.ts +0 -151
  598. package/core/host/Platform.d.ts +0 -16
  599. package/core/host/ResourceLoader.d.ts +0 -15
  600. package/core/host/UserMetrics.d.ts +0 -116
  601. package/core/host/UserMetricsEnums.d.ts +0 -888
  602. package/core/i18n/ByteUtilities.d.ts +0 -11
  603. package/core/i18n/DevToolsLocale.d.ts +0 -41
  604. package/core/i18n/NumberFormatter.d.ts +0 -11
  605. package/core/i18n/i18nImpl.d.ts +0 -64
  606. package/core/i18n/i18nTypes.d.ts +0 -5
  607. package/core/i18n/locales.d.ts +0 -15
  608. package/core/i18n/time-utilities.d.ts +0 -16
  609. package/core/platform/browser/HostRuntime.d.ts +0 -2
  610. package/core/platform/browser/browser.d.ts +0 -2
  611. package/core/platform/node/HostRuntime.d.ts +0 -2
  612. package/core/platform/node/node.d.ts +0 -2
  613. package/core/protocol_client/CDPConnection.d.ts +0 -77
  614. package/core/protocol_client/ConnectionTransport.d.ts +0 -9
  615. package/core/protocol_client/DevToolsCDPConnection.d.ts +0 -16
  616. package/core/protocol_client/InspectorBackend.d.ts +0 -223
  617. package/core/protocol_client/protocol_client.d.ts +0 -5
  618. package/core/root/DevToolsContext.d.ts +0 -34
  619. package/core/root/ExperimentNames.d.ts +0 -9
  620. package/core/root/Runtime.d.ts +0 -353
  621. package/core/sdk/AccessibilityModel.d.ts +0 -76
  622. package/core/sdk/AnimationModel.d.ts +0 -161
  623. package/core/sdk/AutofillModel.d.ts +0 -23
  624. package/core/sdk/CPUProfilerModel.d.ts +0 -46
  625. package/core/sdk/CPUThrottlingManager.d.ts +0 -47
  626. package/core/sdk/CSSContainerQuery.d.ts +0 -42
  627. package/core/sdk/CSSFontFace.d.ts +0 -10
  628. package/core/sdk/CSSLayer.d.ts +0 -9
  629. package/core/sdk/CSSLocation.d.ts +0 -14
  630. package/core/sdk/CSSMatchedStyles.d.ts +0 -138
  631. package/core/sdk/CSSMedia.d.ts +0 -36
  632. package/core/sdk/CSSMetadata.d.ts +0 -87
  633. package/core/sdk/CSSModel.d.ts +0 -185
  634. package/core/sdk/CSSNavigation.d.ts +0 -10
  635. package/core/sdk/CSSProperty.d.ts +0 -53
  636. package/core/sdk/CSSPropertyParser.d.ts +0 -126
  637. package/core/sdk/CSSPropertyParserMatchers.d.ts +0 -442
  638. package/core/sdk/CSSQuery.d.ts +0 -22
  639. package/core/sdk/CSSRule.d.ts +0 -132
  640. package/core/sdk/CSSScope.d.ts +0 -9
  641. package/core/sdk/CSSStartingStyle.d.ts +0 -9
  642. package/core/sdk/CSSStyleDeclaration.d.ts +0 -38
  643. package/core/sdk/CSSStyleSheetHeader.d.ts +0 -53
  644. package/core/sdk/CSSSupports.d.ts +0 -10
  645. package/core/sdk/CategorizedBreakpoint.d.ts +0 -42
  646. package/core/sdk/ChildTargetManager.d.ts +0 -40
  647. package/core/sdk/CompilerSourceMappingContentProvider.d.ts +0 -12
  648. package/core/sdk/Connections.d.ts +0 -36
  649. package/core/sdk/ConsoleModel.d.ts +0 -127
  650. package/core/sdk/ConsoleModelTypes.d.ts +0 -6
  651. package/core/sdk/Cookie.d.ts +0 -68
  652. package/core/sdk/CookieModel.d.ts +0 -31
  653. package/core/sdk/CookieParser.d.ts +0 -14
  654. package/core/sdk/CrashReportContextModel.d.ts +0 -8
  655. package/core/sdk/DOMDebuggerModel.d.ts +0 -127
  656. package/core/sdk/DOMModel.d.ts +0 -440
  657. package/core/sdk/DOMStorageModel.d.ts +0 -79
  658. package/core/sdk/DebuggerModel.d.ts +0 -305
  659. package/core/sdk/EmulationModel.d.ts +0 -95
  660. package/core/sdk/EnhancedTracesParser.d.ts +0 -105
  661. package/core/sdk/EventBreakpointsModel.d.ts +0 -66
  662. package/core/sdk/FrameAssociated.d.ts +0 -6
  663. package/core/sdk/FrameManager.d.ts +0 -68
  664. package/core/sdk/HeapProfilerModel.d.ts +0 -75
  665. package/core/sdk/HttpReasonPhraseStrings.d.ts +0 -5
  666. package/core/sdk/IOModel.d.ts +0 -10
  667. package/core/sdk/IsolateManager.d.ts +0 -53
  668. package/core/sdk/IssuesModel.d.ts +0 -28
  669. package/core/sdk/LayerTreeBase.d.ts +0 -70
  670. package/core/sdk/LogModel.d.ts +0 -20
  671. package/core/sdk/NetworkManager.d.ts +0 -418
  672. package/core/sdk/NetworkRequest.d.ts +0 -497
  673. package/core/sdk/NetworkRequestAccess.d.ts +0 -91
  674. package/core/sdk/OverlayColorGenerator.d.ts +0 -14
  675. package/core/sdk/OverlayModel.d.ts +0 -186
  676. package/core/sdk/OverlayPersistentHighlighter.d.ts +0 -116
  677. package/core/sdk/PageFunctions.d.ts +0 -22
  678. package/core/sdk/PageLoad.d.ts +0 -14
  679. package/core/sdk/PageResourceLoader.d.ts +0 -111
  680. package/core/sdk/PaintProfiler.d.ts +0 -43
  681. package/core/sdk/PerformanceMetricsModel.d.ts +0 -12
  682. package/core/sdk/PreloadingModel.d.ts +0 -146
  683. package/core/sdk/RehydratingConnection.d.ts +0 -73
  684. package/core/sdk/RehydratingObject.d.ts +0 -59
  685. package/core/sdk/RemoteObject.d.ts +0 -210
  686. package/core/sdk/Resource.d.ts +0 -36
  687. package/core/sdk/ResourceTreeModel.d.ts +0 -280
  688. package/core/sdk/RuntimeModel.d.ts +0 -164
  689. package/core/sdk/SDKModel.d.ts +0 -30
  690. package/core/sdk/SDKSettings.d.ts +0 -54
  691. package/core/sdk/ScopeTreeCache.d.ts +0 -21
  692. package/core/sdk/ScreenCaptureModel.d.ts +0 -69
  693. package/core/sdk/Script.d.ts +0 -134
  694. package/core/sdk/SecurityOrigin.d.ts +0 -108
  695. package/core/sdk/SecurityOriginManager.d.ts +0 -23
  696. package/core/sdk/ServerSentEvents.d.ts +0 -18
  697. package/core/sdk/ServerSentEventsProtocol.d.ts +0 -18
  698. package/core/sdk/ServerTiming.d.ts +0 -24
  699. package/core/sdk/ServiceWorkerCacheModel.d.ts +0 -71
  700. package/core/sdk/ServiceWorkerManager.d.ts +0 -125
  701. package/core/sdk/SourceMap.d.ts +0 -211
  702. package/core/sdk/SourceMapCache.d.ts +0 -12
  703. package/core/sdk/SourceMapFunctionRanges.d.ts +0 -23
  704. package/core/sdk/SourceMapManager.d.ts +0 -46
  705. package/core/sdk/SourceMapRangeMappings.d.ts +0 -15
  706. package/core/sdk/SourceMapScopeChainEntry.d.ts +0 -23
  707. package/core/sdk/SourceMapScopesInfo.d.ts +0 -184
  708. package/core/sdk/StorageBucketsModel.d.ts +0 -48
  709. package/core/sdk/StorageKeyManager.d.ts +0 -38
  710. package/core/sdk/Target.d.ts +0 -79
  711. package/core/sdk/TargetManager.d.ts +0 -92
  712. package/core/sdk/TraceObject.d.ts +0 -43
  713. package/core/sdk/WebAuthnModel.d.ts +0 -29
  714. package/core/text_utils/CodeMirrorUtils.d.ts +0 -3
  715. package/core/text_utils/ContentData.d.ts +0 -94
  716. package/core/text_utils/ContentProvider.d.ts +0 -42
  717. package/core/text_utils/Markdown.d.ts +0 -13
  718. package/core/text_utils/StaticContentProvider.d.ts +0 -13
  719. package/core/text_utils/StreamingContentData.d.ts +0 -49
  720. package/core/text_utils/Text.d.ts +0 -19
  721. package/core/text_utils/TextCursor.d.ts +0 -9
  722. package/core/text_utils/TextRange.d.ts +0 -81
  723. package/core/text_utils/TextUtils.d.ts +0 -97
  724. package/core/text_utils/WasmDisassembly.d.ts +0 -29
  725. package/core/text_utils/text_utils.d.ts +0 -12
  726. package/entrypoints/formatter_actions/formatter_actions.d.ts +0 -65
  727. package/generated/InspectorBackendCommands.d.ts +0 -14
  728. package/generated/SupportedCSSProperties.d.ts +0 -18
  729. package/generated/protocol-mapping.d.ts +0 -5985
  730. package/generated/protocol-proxy-api.d.ts +0 -5447
  731. package/index.d.ts +0 -2
  732. package/index.js +0 -6
  733. package/models/crux-manager/CrUXManager.d.ts +0 -107
  734. package/models/emulation/DeviceModeModel.d.ts +0 -157
  735. package/models/emulation/EmulatedDevices.d.ts +0 -148
  736. package/models/emulation/emulation.d.ts +0 -3
  737. package/models/formatter/FormatterWorkerPool.d.ts +0 -58
  738. package/models/formatter/ScriptFormatter.d.ts +0 -11
  739. package/models/formatter/formatter.d.ts +0 -3
  740. package/third_party/codemirror.next/codemirror.next.d.ts +0 -9196
  741. package/third_party/i18n/i18n-impl.d.ts +0 -25
  742. package/third_party/i18n/i18n.d.ts +0 -3
  743. package/third_party/i18n/localized-string-set.d.ts +0 -49
  744. package/third_party/intl-messageformat/intl-messageformat.d.ts +0 -1
  745. package/third_party/marked/package/lib/marked.esm.d.ts +0 -760
  746. package/third_party/source-map-scopes-codec/package/src/builder/builder.d.ts +0 -70
  747. package/third_party/source-map-scopes-codec/package/src/builder/safe_builder.d.ts +0 -40
  748. package/third_party/source-map-scopes-codec/package/src/codec.d.ts +0 -49
  749. package/third_party/source-map-scopes-codec/package/src/decode/decode.d.ts +0 -33
  750. package/third_party/source-map-scopes-codec/package/src/encode/encode.d.ts +0 -8
  751. package/third_party/source-map-scopes-codec/package/src/encode/encoder.d.ts +0 -9
  752. package/third_party/source-map-scopes-codec/package/src/mod.d.ts +0 -5
  753. package/third_party/source-map-scopes-codec/package/src/scopes.d.ts +0 -169
  754. package/third_party/source-map-scopes-codec/package/src/util.d.ts +0 -5
  755. package/third_party/source-map-scopes-codec/package/src/vlq.d.ts +0 -14
  756. package/third_party/source-map-scopes-codec/source-map-scopes-codec.d.ts +0 -1
  757. package/third_party/third-party-web/lib/nostats-subset.d.ts +0 -2
  758. package/third_party/third-party-web/package/lib/index.d.ts +0 -34
  759. package/third_party/third-party-web/package/lib/subsets/nostats.d.ts +0 -1
@@ -6,23 +6,23 @@ export declare const UIStrings: {
6
6
  /**
7
7
  * @description Title of an insight that provides the user with the list of network requests that blocked and therefore slowed down the page rendering and becoming visible to the user.
8
8
  */
9
- readonly title: "Render-blocking requests";
9
+ readonly title: 'Render-blocking requests';
10
10
  /**
11
11
  * @description Text to describe that there are requests blocking rendering, which may affect LCP.
12
12
  */
13
- readonly description: "Requests are blocking the page’s initial render, which may delay LCP. [Deferring or inlining](https://developer.chrome.com/docs/performance/insights/render-blocking) can move these network requests out of the critical path.";
13
+ readonly description: `Requests are blocking the page’s initial render, which may delay LCP. [Deferring or inlining](https://developer.chrome.com/docs/performance/insights/render-blocking) can move these network requests out of the critical path.`;
14
14
  /**
15
15
  * @description Label to describe a network request (that happens to be render-blocking).
16
16
  */
17
- readonly renderBlockingRequest: "Request";
17
+ readonly renderBlockingRequest: 'Request';
18
18
  /**
19
19
  * @description Label used for a time duration.
20
20
  */
21
- readonly duration: "Duration";
21
+ readonly duration: 'Duration';
22
22
  /**
23
23
  * @description Text status indicating that no requests blocked the initial render of a navigation.
24
24
  */
25
- readonly noRenderBlocking: "No render-blocking requests for this navigation";
25
+ readonly noRenderBlocking: 'No render-blocking requests for this navigation';
26
26
  };
27
27
  export declare const i18nString: i18n.LocalizeString;
28
28
  export declare function isRenderBlockingInsight(insight: InsightModel): insight is RenderBlockingInsightModel;
@@ -0,0 +1,211 @@
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 { InsightCategory, InsightKeys, InsightWarning, } from './types.js';
8
+ export const UIStrings = {
9
+ /**
10
+ * @description Title of an insight that provides the user with the list of network requests that blocked and therefore slowed down the page rendering and becoming visible to the user.
11
+ */
12
+ title: 'Render-blocking requests',
13
+ /**
14
+ * @description Text to describe that there are requests blocking rendering, which may affect LCP.
15
+ */
16
+ description: `Requests are blocking the page’s initial render, which may delay LCP. [Deferring or inlining](https://developer.chrome.com/docs/performance/insights/render-blocking) can move these network requests out of the critical path.`,
17
+ /**
18
+ * @description Label to describe a network request (that happens to be render-blocking).
19
+ */
20
+ renderBlockingRequest: 'Request',
21
+ /**
22
+ * @description Label used for a time duration.
23
+ */
24
+ duration: 'Duration',
25
+ /**
26
+ * @description Text status indicating that no requests blocked the initial render of a navigation.
27
+ */
28
+ noRenderBlocking: 'No render-blocking requests for this navigation',
29
+ };
30
+ const str_ = i18n.i18n.registerUIStrings('models/trace/insights/RenderBlocking.ts', UIStrings);
31
+ export const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
32
+ export function isRenderBlockingInsight(insight) {
33
+ return insight.insightKey === 'RenderBlocking';
34
+ }
35
+ // Because of the way we detect blocking stylesheets, asynchronously loaded
36
+ // CSS with link[rel=preload] and an onload handler (see https://github.com/filamentgroup/loadCSS)
37
+ // can be falsely flagged as blocking. Therefore, ignore stylesheets that loaded fast enough
38
+ // to possibly be non-blocking (and they have minimal impact anyway).
39
+ const MINIMUM_WASTED_MS = 50;
40
+ /**
41
+ * Given a simulation's nodeTimings, return an object with the nodes/timing keyed by network URL
42
+ */
43
+ function getNodesAndTimingByRequestId(nodeTimings) {
44
+ const timingByNodeId = new Map();
45
+ for (const [node, nodeTiming] of nodeTimings) {
46
+ timingByNodeId.set(node.id, nodeTiming);
47
+ }
48
+ const requestIdToNode = new Map();
49
+ for (const [node, nodeTiming] of nodeTimings) {
50
+ if (node.type !== 'network' || node.request.redirectDestination) {
51
+ continue;
52
+ }
53
+ let duration = nodeTiming.duration;
54
+ let startTime = nodeTiming.startTime;
55
+ for (const redirect of node.request.redirects ?? []) {
56
+ const redirectTiming = timingByNodeId.get(redirect.requestId);
57
+ if (redirectTiming) {
58
+ duration += redirectTiming.duration;
59
+ startTime = Math.min(startTime, redirectTiming.startTime);
60
+ }
61
+ }
62
+ const backendRequestId = node.request.rawRequest?.args.data.requestId ?? node.request.requestId;
63
+ requestIdToNode.set(backendRequestId, {
64
+ node,
65
+ nodeTiming: { startTime, endTime: nodeTiming.endTime, duration },
66
+ });
67
+ }
68
+ return requestIdToNode;
69
+ }
70
+ function estimateSavingsWithGraphs(deferredIds, lanternContext) {
71
+ const simulator = lanternContext.simulator;
72
+ const fcpGraph = lanternContext.metrics.firstContentfulPaint.optimisticGraph;
73
+ const { nodeTimings } = lanternContext.simulator.simulate(fcpGraph);
74
+ const adjustedNodeTimings = new Map(nodeTimings);
75
+ const totalChildNetworkBytes = 0;
76
+ const minimalFCPGraph = fcpGraph.cloneWithRelationships(node => {
77
+ // If a node can be deferred, exclude it from the new FCP graph
78
+ const canDeferRequest = deferredIds.has(node.id);
79
+ return !canDeferRequest;
80
+ });
81
+ if (minimalFCPGraph.type !== 'network') {
82
+ throw new Error('minimalFCPGraph not a NetworkNode');
83
+ }
84
+ // Recalculate the "before" time based on our adjusted node timings.
85
+ const estimateBeforeInline = Math.max(...Array.from(Array.from(adjustedNodeTimings).map(timing => timing[1].endTime)));
86
+ // Add the inlined bytes to the HTML response
87
+ const originalTransferSize = minimalFCPGraph.request.transferSize;
88
+ const safeTransferSize = originalTransferSize || 0;
89
+ minimalFCPGraph.request.transferSize = safeTransferSize + totalChildNetworkBytes;
90
+ const estimateAfterInline = simulator.simulate(minimalFCPGraph).timeInMs;
91
+ minimalFCPGraph.request.transferSize = originalTransferSize;
92
+ return Math.round(Math.max(estimateBeforeInline - estimateAfterInline, 0));
93
+ }
94
+ function hasImageLCP(data, context) {
95
+ return data.LargestImagePaint.lcpRequestByNavigationId.has(context.navigationId);
96
+ }
97
+ function computeSavings(data, context, renderBlockingRequests) {
98
+ if (!context.lantern) {
99
+ return;
100
+ }
101
+ const nodesAndTimingsByRequestId = getNodesAndTimingByRequestId(context.lantern.metrics.firstContentfulPaint.optimisticEstimate.nodeTimings);
102
+ const metricSavings = { FCP: 0, LCP: 0 };
103
+ const requestIdToWastedMs = new Map();
104
+ const deferredNodeIds = new Set();
105
+ for (const request of renderBlockingRequests) {
106
+ const nodeAndTiming = nodesAndTimingsByRequestId.get(request.args.data.requestId);
107
+ if (!nodeAndTiming) {
108
+ continue;
109
+ }
110
+ const { node, nodeTiming } = nodeAndTiming;
111
+ // Mark this node, any redirects leading to it, and all its dependents as deferrable
112
+ for (const redirect of node.request.redirects ?? []) {
113
+ deferredNodeIds.add(redirect.requestId);
114
+ }
115
+ node.traverse(node => deferredNodeIds.add(node.id));
116
+ // "wastedMs" is the download time of the network request, responseReceived - requestSent
117
+ const wastedMs = Math.round(nodeTiming.duration);
118
+ if (wastedMs < MINIMUM_WASTED_MS) {
119
+ continue;
120
+ }
121
+ requestIdToWastedMs.set(request.args.data.requestId, wastedMs);
122
+ }
123
+ if (requestIdToWastedMs.size) {
124
+ metricSavings.FCP = estimateSavingsWithGraphs(deferredNodeIds, context.lantern);
125
+ // In most cases, render-blocking resources only affect LCP if LCP isn't an image.
126
+ if (!hasImageLCP(data, context)) {
127
+ metricSavings.LCP = metricSavings.FCP;
128
+ }
129
+ }
130
+ return { metricSavings, requestIdToWastedMs };
131
+ }
132
+ function finalize(partialModel) {
133
+ return {
134
+ insightKey: InsightKeys.RENDER_BLOCKING,
135
+ strings: UIStrings,
136
+ title: i18nString(UIStrings.title),
137
+ description: i18nString(UIStrings.description),
138
+ docs: 'https://developer.chrome.com/docs/performance/insights/render-blocking',
139
+ category: InsightCategory.LCP,
140
+ state: partialModel.renderBlockingRequests.length > 0 ? 'fail' : 'pass',
141
+ ...partialModel,
142
+ };
143
+ }
144
+ export function generateInsight(data, context) {
145
+ if (!context.navigation || !('navigationId' in context)) {
146
+ return finalize({
147
+ renderBlockingRequests: [],
148
+ });
149
+ }
150
+ const firstPaintTs = data.PageLoadMetrics.metricScoresByFrameId.get(context.frameId)
151
+ ?.get(context.navigation)
152
+ ?.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.FP)
153
+ ?.event?.ts;
154
+ if (!firstPaintTs) {
155
+ return finalize({
156
+ renderBlockingRequests: [],
157
+ warnings: [InsightWarning.NO_FP],
158
+ });
159
+ }
160
+ let renderBlockingRequests = [];
161
+ for (const req of data.NetworkRequests.byTime) {
162
+ if (req.args.data.frame !== context.frameId) {
163
+ continue;
164
+ }
165
+ if (!Helpers.Network.isSyntheticNetworkRequestEventRenderBlocking(req)) {
166
+ continue;
167
+ }
168
+ if (req.args.data.syntheticData.finishTime > firstPaintTs) {
169
+ continue;
170
+ }
171
+ // If a request is marked `in_body_parser_blocking` it should only be considered render-blocking if it is a
172
+ // high enough priority. Some requests (e.g. scripts) are not marked as high priority if they are fetched
173
+ // after a non-preloaded image. (See "early" definition in https://web.dev/articles/fetch-priority)
174
+ //
175
+ // There are edge cases and exceptions (e.g. priority hints) but this gives us the best approximation
176
+ // of render-blocking resources in the document body.
177
+ if (req.args.data.renderBlocking === 'in_body_parser_blocking') {
178
+ const priority = req.args.data.priority;
179
+ const isScript = req.args.data.resourceType === "Script" /* Protocol.Network.ResourceType.Script */;
180
+ const isBlockingScript = isScript && priority === "High" /* Protocol.Network.ResourcePriority.High */;
181
+ if (priority !== "VeryHigh" /* Protocol.Network.ResourcePriority.VeryHigh */ && !isBlockingScript) {
182
+ continue;
183
+ }
184
+ }
185
+ const navigation = Helpers.Trace.getNavigationForTraceEvent(req, context.frameId, data.Meta.navigationsByFrameId);
186
+ if (navigation === context.navigation) {
187
+ renderBlockingRequests.push(req);
188
+ }
189
+ }
190
+ const savings = computeSavings(data, context, renderBlockingRequests);
191
+ // Sort by request duration for insights.
192
+ renderBlockingRequests = renderBlockingRequests.sort((a, b) => {
193
+ return b.dur - a.dur;
194
+ });
195
+ return finalize({
196
+ relatedEvents: renderBlockingRequests,
197
+ renderBlockingRequests,
198
+ ...savings,
199
+ });
200
+ }
201
+ export function createOverlayForRequest(request) {
202
+ return {
203
+ type: 'ENTRY_OUTLINE',
204
+ entry: request,
205
+ outlineReason: 'ERROR',
206
+ };
207
+ }
208
+ export function createOverlays(model) {
209
+ return model.renderBlockingRequests.map(request => createOverlayForRequest(request));
210
+ }
211
+ //# sourceMappingURL=RenderBlocking.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenderBlocking.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/RenderBlocking.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AAEnD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAIjD,OAAO,EACL,eAAe,EACf,WAAW,EAIX,cAAc,GAGf,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,0BAA0B;IACjC;;OAEG;IACH,WAAW,EACP,iOAAiO;IACrO;;OAEG;IACH,qBAAqB,EAAE,SAAS;IAChC;;OAEG;IACH,QAAQ,EAAE,UAAU;IACpB;;OAEG;IACH,gBAAgB,EAAE,iDAAiD;CAC3D,CAAC;AAEX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,yCAAyC,EAAE,SAAS,CAAC,CAAC;AAC/F,MAAM,CAAC,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QACtB,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAA6C;IACnF,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,OAAO;QACd,aAAa,EAAE,OAAO;KACvB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAiC;IAC9D,OAAO,KAAK,CAAC,sBAAsB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC,CAAC;AACvF,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 i18n from '../../../core/i18n/i18n.js';\nimport * as Protocol from '../../../generated/protocol.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Lantern from '../lantern/lantern.js';\nimport type * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type InsightSetContextWithNavigation,\n InsightWarning,\n type LanternContext,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n * @description Title of an insight that provides the user with the list of network requests that blocked and therefore slowed down the page rendering and becoming visible to the user.\n */\n title: 'Render-blocking requests',\n /**\n * @description Text to describe that there are requests blocking rendering, which may affect LCP.\n */\n description:\n `Requests are blocking the page’s initial render, which may delay LCP. [Deferring or inlining](https://developer.chrome.com/docs/performance/insights/render-blocking) can move these network requests out of the critical path.`,\n /**\n * @description Label to describe a network request (that happens to be render-blocking).\n */\n renderBlockingRequest: 'Request',\n /**\n * @description Label used for a time duration.\n */\n duration: 'Duration',\n /**\n * @description Text status indicating that no requests blocked the initial render of a navigation.\n */\n noRenderBlocking: 'No render-blocking requests for this navigation',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/RenderBlocking.ts', UIStrings);\nexport const i18nString: i18n.LocalizeString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport function isRenderBlockingInsight(insight: InsightModel): insight is RenderBlockingInsightModel {\n return insight.insightKey === 'RenderBlocking';\n}\n\nexport type RenderBlockingInsightModel = InsightModel<typeof UIStrings, {\n renderBlockingRequests: Types.Events.SyntheticNetworkRequest[],\n requestIdToWastedMs?: Map<string, number>,\n}>;\n\n// Because of the way we detect blocking stylesheets, asynchronously loaded\n// CSS with link[rel=preload] and an onload handler (see https://github.com/filamentgroup/loadCSS)\n// can be falsely flagged as blocking. Therefore, ignore stylesheets that loaded fast enough\n// to possibly be non-blocking (and they have minimal impact anyway).\nconst MINIMUM_WASTED_MS = 50;\n\n/**\n * Given a simulation's nodeTimings, return an object with the nodes/timing keyed by network URL\n */\nfunction getNodesAndTimingByRequestId(nodeTimings: Lantern.Simulation.Result['nodeTimings']):\n Map<string, {node: Lantern.Graph.NetworkNode, nodeTiming: Lantern.Types.Simulation.NodeTiming}> {\n const timingByNodeId = new Map<string, Lantern.Types.Simulation.NodeTiming>();\n for (const [node, nodeTiming] of nodeTimings) {\n timingByNodeId.set(node.id, nodeTiming);\n }\n\n const requestIdToNode =\n new Map<string, {node: Lantern.Graph.NetworkNode, nodeTiming: Lantern.Types.Simulation.NodeTiming}>();\n\n for (const [node, nodeTiming] of nodeTimings) {\n if (node.type !== 'network' || node.request.redirectDestination) {\n continue;\n }\n\n let duration = nodeTiming.duration;\n let startTime = nodeTiming.startTime;\n for (const redirect of node.request.redirects ?? []) {\n const redirectTiming = timingByNodeId.get(redirect.requestId);\n if (redirectTiming) {\n duration += redirectTiming.duration;\n startTime = Math.min(startTime, redirectTiming.startTime);\n }\n }\n\n const backendRequestId = node.request.rawRequest?.args.data.requestId ?? node.request.requestId;\n requestIdToNode.set(backendRequestId, {\n node,\n nodeTiming: {startTime, endTime: nodeTiming.endTime, duration},\n });\n }\n\n return requestIdToNode;\n}\n\nfunction estimateSavingsWithGraphs(deferredIds: Set<string>, lanternContext: LanternContext): Types.Timing.Milli {\n const simulator = lanternContext.simulator;\n const fcpGraph = lanternContext.metrics.firstContentfulPaint.optimisticGraph;\n const {nodeTimings} = lanternContext.simulator.simulate(fcpGraph);\n const adjustedNodeTimings = new Map(nodeTimings);\n\n const totalChildNetworkBytes = 0;\n const minimalFCPGraph = fcpGraph.cloneWithRelationships(node => {\n // If a node can be deferred, exclude it from the new FCP graph\n const canDeferRequest = deferredIds.has(node.id);\n return !canDeferRequest;\n });\n\n if (minimalFCPGraph.type !== 'network') {\n throw new Error('minimalFCPGraph not a NetworkNode');\n }\n\n // Recalculate the \"before\" time based on our adjusted node timings.\n const estimateBeforeInline = Math.max(...Array.from(\n Array.from(adjustedNodeTimings).map(timing => timing[1].endTime),\n ));\n\n // Add the inlined bytes to the HTML response\n const originalTransferSize = minimalFCPGraph.request.transferSize;\n const safeTransferSize = originalTransferSize || 0;\n minimalFCPGraph.request.transferSize = safeTransferSize + totalChildNetworkBytes;\n const estimateAfterInline = simulator.simulate(minimalFCPGraph).timeInMs;\n minimalFCPGraph.request.transferSize = originalTransferSize;\n return Math.round(Math.max(estimateBeforeInline - estimateAfterInline, 0)) as Types.Timing.Milli;\n}\n\nfunction hasImageLCP(data: Handlers.Types.HandlerData, context: InsightSetContextWithNavigation): boolean {\n return data.LargestImagePaint.lcpRequestByNavigationId.has(context.navigationId);\n}\n\nfunction computeSavings(\n data: Handlers.Types.HandlerData, context: InsightSetContextWithNavigation,\n renderBlockingRequests: Types.Events.SyntheticNetworkRequest[]):\n Pick<RenderBlockingInsightModel, 'metricSavings'|'requestIdToWastedMs'>|undefined {\n if (!context.lantern) {\n return;\n }\n\n const nodesAndTimingsByRequestId =\n getNodesAndTimingByRequestId(context.lantern.metrics.firstContentfulPaint.optimisticEstimate.nodeTimings);\n\n const metricSavings = {FCP: 0 as Types.Timing.Milli, LCP: 0 as Types.Timing.Milli};\n const requestIdToWastedMs = new Map<string, number>();\n const deferredNodeIds = new Set<string>();\n for (const request of renderBlockingRequests) {\n const nodeAndTiming = nodesAndTimingsByRequestId.get(request.args.data.requestId);\n if (!nodeAndTiming) {\n continue;\n }\n\n const {node, nodeTiming} = nodeAndTiming;\n\n // Mark this node, any redirects leading to it, and all its dependents as deferrable\n for (const redirect of node.request.redirects ?? []) {\n deferredNodeIds.add(redirect.requestId);\n }\n node.traverse(node => deferredNodeIds.add(node.id));\n\n // \"wastedMs\" is the download time of the network request, responseReceived - requestSent\n const wastedMs = Math.round(nodeTiming.duration);\n if (wastedMs < MINIMUM_WASTED_MS) {\n continue;\n }\n\n requestIdToWastedMs.set(request.args.data.requestId, wastedMs);\n }\n\n if (requestIdToWastedMs.size) {\n metricSavings.FCP = estimateSavingsWithGraphs(deferredNodeIds, context.lantern);\n\n // In most cases, render-blocking resources only affect LCP if LCP isn't an image.\n if (!hasImageLCP(data, context)) {\n metricSavings.LCP = metricSavings.FCP;\n }\n }\n\n return {metricSavings, requestIdToWastedMs};\n}\n\nfunction finalize(partialModel: PartialInsightModel<RenderBlockingInsightModel>): RenderBlockingInsightModel {\n return {\n insightKey: InsightKeys.RENDER_BLOCKING,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n docs: 'https://developer.chrome.com/docs/performance/insights/render-blocking',\n category: InsightCategory.LCP,\n state: partialModel.renderBlockingRequests.length > 0 ? 'fail' : 'pass',\n ...partialModel,\n };\n}\n\nexport function generateInsight(\n data: Handlers.Types.HandlerData, context: InsightSetContext): RenderBlockingInsightModel {\n if (!context.navigation || !('navigationId' in context)) {\n return finalize({\n renderBlockingRequests: [],\n });\n }\n\n const firstPaintTs = data.PageLoadMetrics.metricScoresByFrameId.get(context.frameId)\n ?.get(context.navigation)\n ?.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.FP)\n ?.event?.ts;\n if (!firstPaintTs) {\n return finalize({\n renderBlockingRequests: [],\n warnings: [InsightWarning.NO_FP],\n });\n }\n\n let renderBlockingRequests: Types.Events.SyntheticNetworkRequest[] = [];\n for (const req of data.NetworkRequests.byTime) {\n if (req.args.data.frame !== context.frameId) {\n continue;\n }\n\n if (!Helpers.Network.isSyntheticNetworkRequestEventRenderBlocking(req)) {\n continue;\n }\n\n if (req.args.data.syntheticData.finishTime > firstPaintTs) {\n continue;\n }\n\n // If a request is marked `in_body_parser_blocking` it should only be considered render-blocking if it is a\n // high enough priority. Some requests (e.g. scripts) are not marked as high priority if they are fetched\n // after a non-preloaded image. (See \"early\" definition in https://web.dev/articles/fetch-priority)\n //\n // There are edge cases and exceptions (e.g. priority hints) but this gives us the best approximation\n // of render-blocking resources in the document body.\n if (req.args.data.renderBlocking === 'in_body_parser_blocking') {\n const priority = req.args.data.priority;\n const isScript = req.args.data.resourceType === Protocol.Network.ResourceType.Script;\n const isBlockingScript = isScript && priority === Protocol.Network.ResourcePriority.High;\n if (priority !== Protocol.Network.ResourcePriority.VeryHigh && !isBlockingScript) {\n continue;\n }\n }\n\n const navigation = Helpers.Trace.getNavigationForTraceEvent(req, context.frameId, data.Meta.navigationsByFrameId);\n if (navigation === context.navigation) {\n renderBlockingRequests.push(req);\n }\n }\n\n const savings = computeSavings(data, context, renderBlockingRequests);\n\n // Sort by request duration for insights.\n renderBlockingRequests = renderBlockingRequests.sort((a, b) => {\n return b.dur - a.dur;\n });\n\n return finalize({\n relatedEvents: renderBlockingRequests,\n renderBlockingRequests,\n ...savings,\n });\n}\n\nexport function createOverlayForRequest(request: Types.Events.SyntheticNetworkRequest): Types.Overlays.EntryOutline {\n return {\n type: 'ENTRY_OUTLINE',\n entry: request,\n outlineReason: 'ERROR',\n };\n}\n\nexport function createOverlays(model: RenderBlockingInsightModel): Types.Overlays.Overlay[] {\n return model.renderBlockingRequests.map(request => createOverlayForRequest(request));\n}\n"]}
@@ -6,43 +6,43 @@ export declare const UIStrings: {
6
6
  /**
7
7
  * @description Title of an insight that provides details about slow CSS selectors.
8
8
  */
9
- readonly title: "CSS selector costs";
9
+ readonly title: 'CSS selector costs';
10
10
  /**
11
11
  * @description Text to describe how to improve the performance of CSS selectors.
12
12
  */
13
- readonly description: "If recalculate style costs remain high, selector optimization can reduce them. [Optimize the selectors](https://developer.chrome.com/docs/performance/insights/slow-css-selector) with both high elapsed time and high slow-path %. Simpler selectors, fewer selectors, a smaller DOM, and a shallower DOM will all reduce matching costs.";
13
+ readonly description: 'If recalculate style costs remain high, selector optimization can reduce them. [Optimize the selectors](https://developer.chrome.com/docs/performance/insights/slow-css-selector) with both high elapsed time and high slow-path %. Simpler selectors, fewer selectors, a smaller DOM, and a shallower DOM will all reduce matching costs.';
14
14
  /**
15
15
  * @description Column name for count of elements that the engine attempted to match against a style rule.
16
16
  */
17
- readonly matchAttempts: "Match attempts";
17
+ readonly matchAttempts: 'Match attempts';
18
18
  /**
19
19
  * @description Column name for count of elements that matched a style rule.
20
20
  */
21
- readonly matchCount: "Match count";
21
+ readonly matchCount: 'Match count';
22
22
  /**
23
23
  * @description Column name for elapsed time spent computing a style rule.
24
24
  */
25
- readonly elapsed: "Elapsed time";
25
+ readonly elapsed: 'Elapsed time';
26
26
  /**
27
27
  * @description Column name for the selectors that took the longest amount of time/effort.
28
28
  */
29
- readonly topSelectors: "Top selectors";
29
+ readonly topSelectors: 'Top selectors';
30
30
  /**
31
31
  * @description Column name for a total sum.
32
32
  */
33
- readonly total: "Total";
33
+ readonly total: 'Total';
34
34
  /**
35
35
  * @description Text status indicating that no CSS selector data was found.
36
36
  */
37
- readonly enableSelectorData: "No CSS selector data was found. CSS selector stats need to be enabled in the Performance panel settings.";
37
+ readonly enableSelectorData: 'No CSS selector data was found. CSS selector stats need to be enabled in the Performance panel settings.';
38
38
  /**
39
39
  * @description Top CSS selector when ranked by elapsed time in ms.
40
40
  */
41
- readonly topSelectorElapsedTime: "Top selector elapsed time";
41
+ readonly topSelectorElapsedTime: 'Top selector elapsed time';
42
42
  /**
43
43
  * @description Top CSS selector when ranked by match attempt.
44
44
  */
45
- readonly topSelectorMatchAttempt: "Top selector match attempt";
45
+ readonly topSelectorMatchAttempt: 'Top selector match attempt';
46
46
  };
47
47
  export declare const i18nString: i18n.LocalizeString;
48
48
  export type SlowCSSSelectorInsightModel = InsightModel<typeof UIStrings, {
@@ -0,0 +1,140 @@
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 Helpers from '../helpers/helpers.js';
6
+ import * as Types from '../types/types.js';
7
+ import { InsightCategory, InsightKeys, } from './types.js';
8
+ export const UIStrings = {
9
+ /**
10
+ * @description Title of an insight that provides details about slow CSS selectors.
11
+ */
12
+ title: 'CSS selector costs',
13
+ /**
14
+ * @description Text to describe how to improve the performance of CSS selectors.
15
+ */
16
+ description: 'If recalculate style costs remain high, selector optimization can reduce them. [Optimize the selectors](https://developer.chrome.com/docs/performance/insights/slow-css-selector) with both high elapsed time and high slow-path %. Simpler selectors, fewer selectors, a smaller DOM, and a shallower DOM will all reduce matching costs.',
17
+ /**
18
+ * @description Column name for count of elements that the engine attempted to match against a style rule.
19
+ */
20
+ matchAttempts: 'Match attempts',
21
+ /**
22
+ * @description Column name for count of elements that matched a style rule.
23
+ */
24
+ matchCount: 'Match count',
25
+ /**
26
+ * @description Column name for elapsed time spent computing a style rule.
27
+ */
28
+ elapsed: 'Elapsed time',
29
+ /**
30
+ * @description Column name for the selectors that took the longest amount of time/effort.
31
+ */
32
+ topSelectors: 'Top selectors',
33
+ /**
34
+ * @description Column name for a total sum.
35
+ */
36
+ total: 'Total',
37
+ /**
38
+ * @description Text status indicating that no CSS selector data was found.
39
+ */
40
+ enableSelectorData: 'No CSS selector data was found. CSS selector stats need to be enabled in the Performance panel settings.',
41
+ /**
42
+ * @description Top CSS selector when ranked by elapsed time in ms.
43
+ */
44
+ topSelectorElapsedTime: 'Top selector elapsed time',
45
+ /**
46
+ * @description Top CSS selector when ranked by match attempt.
47
+ */
48
+ topSelectorMatchAttempt: 'Top selector match attempt',
49
+ };
50
+ const str_ = i18n.i18n.registerUIStrings('models/trace/insights/SlowCSSSelector.ts', UIStrings);
51
+ export const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
52
+ const slowCSSSelectorThreshold = 500; // 500us threshold for slow selectors
53
+ function aggregateSelectorStats(data, context) {
54
+ const selectorMap = new Map();
55
+ for (const [event, value] of data.dataForRecalcStyleEvent) {
56
+ if (event.args.beginData?.frame !== context.frameId) {
57
+ continue;
58
+ }
59
+ if (!Helpers.Timing.eventIsInBounds(event, context.bounds)) {
60
+ continue;
61
+ }
62
+ for (const timing of value.timings) {
63
+ const key = timing[Types.Events.SelectorTimingsKey.Selector] + '_' + timing[Types.Events.SelectorTimingsKey.StyleSheetId];
64
+ const findTiming = selectorMap.get(key);
65
+ if (findTiming !== undefined) {
66
+ findTiming[Types.Events.SelectorTimingsKey.Elapsed] += timing[Types.Events.SelectorTimingsKey.Elapsed];
67
+ findTiming[Types.Events.SelectorTimingsKey.FastRejectCount] +=
68
+ timing[Types.Events.SelectorTimingsKey.FastRejectCount];
69
+ findTiming[Types.Events.SelectorTimingsKey.MatchAttempts] +=
70
+ timing[Types.Events.SelectorTimingsKey.MatchAttempts];
71
+ findTiming[Types.Events.SelectorTimingsKey.MatchCount] += timing[Types.Events.SelectorTimingsKey.MatchCount];
72
+ }
73
+ else {
74
+ selectorMap.set(key, { ...timing });
75
+ }
76
+ }
77
+ }
78
+ return [...selectorMap.values()];
79
+ }
80
+ function finalize(partialModel) {
81
+ return {
82
+ insightKey: InsightKeys.SLOW_CSS_SELECTOR,
83
+ strings: UIStrings,
84
+ title: i18nString(UIStrings.title),
85
+ description: i18nString(UIStrings.description),
86
+ docs: 'https://developer.chrome.com/docs/performance/insights/slow-css-selector',
87
+ category: InsightCategory.ALL,
88
+ state: partialModel.topSelectorElapsedMs && partialModel.topSelectorMatchAttempts ? 'informative' : 'pass',
89
+ ...partialModel,
90
+ };
91
+ }
92
+ export function isSlowCSSSelectorInsight(model) {
93
+ return model.insightKey === InsightKeys.SLOW_CSS_SELECTOR;
94
+ }
95
+ export function generateInsight(data, context) {
96
+ const selectorStatsData = data.SelectorStats;
97
+ if (!selectorStatsData) {
98
+ throw new Error('no selector stats data');
99
+ }
100
+ const selectorTimings = aggregateSelectorStats(selectorStatsData, context);
101
+ let totalElapsedUs = 0;
102
+ let totalMatchAttempts = 0;
103
+ let totalMatchCount = 0;
104
+ selectorTimings.map(timing => {
105
+ totalElapsedUs += timing[Types.Events.SelectorTimingsKey.Elapsed];
106
+ totalMatchAttempts += timing[Types.Events.SelectorTimingsKey.MatchAttempts];
107
+ totalMatchCount += timing[Types.Events.SelectorTimingsKey.MatchCount];
108
+ });
109
+ let topSelectorElapsedMs = null;
110
+ let topSelectorMatchAttempts = null;
111
+ if (selectorTimings.length > 0) {
112
+ // find the selector with most elapsed time
113
+ topSelectorElapsedMs = selectorTimings.reduce((a, b) => {
114
+ return a[Types.Events.SelectorTimingsKey.Elapsed] > b[Types.Events.SelectorTimingsKey.Elapsed] ? a : b;
115
+ });
116
+ // check if the slowest selector is slow enough to trigger insights info
117
+ if (topSelectorElapsedMs &&
118
+ topSelectorElapsedMs[Types.Events.SelectorTimingsKey.Elapsed] < slowCSSSelectorThreshold) {
119
+ topSelectorElapsedMs = null;
120
+ }
121
+ // find the selector with most match attempts
122
+ topSelectorMatchAttempts = selectorTimings.reduce((a, b) => {
123
+ return a[Types.Events.SelectorTimingsKey.MatchAttempts] > b[Types.Events.SelectorTimingsKey.MatchAttempts] ? a :
124
+ b;
125
+ });
126
+ }
127
+ return finalize({
128
+ // TODO: should we identify RecalcStyle events as linked to this insight?
129
+ relatedEvents: [],
130
+ totalElapsedMs: Types.Timing.Milli(totalElapsedUs / 1000.0),
131
+ totalMatchAttempts,
132
+ totalMatchCount,
133
+ topSelectorElapsedMs,
134
+ topSelectorMatchAttempts,
135
+ });
136
+ }
137
+ export function createOverlays(_) {
138
+ return [];
139
+ }
140
+ //# sourceMappingURL=SlowCSSSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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K,CAAC,cAAc,GAAG,MAAM,CAAC;QAC3D,kBAAkB;QAClB,eAAe;QACf,oBAAoB;QACpB,wBAAwB;KACzB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAA8B;IAC3D,OAAO,EAAE,CAAC;AACZ,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 i18n from '../../../core/i18n/i18n.js';\nimport type * 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 provides details about slow CSS selectors.\n */\n title: 'CSS selector costs',\n\n /**\n * @description Text to describe how to improve the performance of CSS selectors.\n */\n description:\n 'If recalculate style costs remain high, selector optimization can reduce them. [Optimize the selectors](https://developer.chrome.com/docs/performance/insights/slow-css-selector) with both high elapsed time and high slow-path %. Simpler selectors, fewer selectors, a smaller DOM, and a shallower DOM will all reduce matching costs.',\n /**\n * @description Column name for count of elements that the engine attempted to match against a style rule.\n */\n matchAttempts: 'Match attempts',\n /**\n * @description Column name for count of elements that matched a style rule.\n */\n matchCount: 'Match count',\n /**\n * @description Column name for elapsed time spent computing a style rule.\n */\n elapsed: 'Elapsed time',\n /**\n * @description Column name for the selectors that took the longest amount of time/effort.\n */\n topSelectors: 'Top selectors',\n /**\n * @description Column name for a total sum.\n */\n total: 'Total',\n /**\n * @description Text status indicating that no CSS selector data was found.\n */\n enableSelectorData:\n 'No CSS selector data was found. CSS selector stats need to be enabled in the Performance panel settings.',\n /**\n * @description Top CSS selector when ranked by elapsed time in ms.\n */\n topSelectorElapsedTime: 'Top selector elapsed time',\n /**\n * @description Top CSS selector when ranked by match attempt.\n */\n topSelectorMatchAttempt: 'Top selector match attempt',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/SlowCSSSelector.ts', UIStrings);\nexport const i18nString: i18n.LocalizeString = i18n.i18n.getLocalizedString.bind(undefined, str_);\nconst slowCSSSelectorThreshold = 500; // 500us threshold for slow selectors\n\nexport type SlowCSSSelectorInsightModel = InsightModel<typeof UIStrings, {\n totalElapsedMs: Types.Timing.Milli,\n totalMatchAttempts: number,\n totalMatchCount: number,\n topSelectorElapsedMs: Types.Events.SelectorTiming | null,\n topSelectorMatchAttempts: Types.Events.SelectorTiming | null,\n}>;\n\nfunction aggregateSelectorStats(data: Handlers.ModelHandlers.SelectorStats.SelectorStatsData,\n context: InsightSetContext): Types.Events.SelectorTiming[] {\n const selectorMap = new Map<String, Types.Events.SelectorTiming>();\n\n for (const [event, value] of data.dataForRecalcStyleEvent) {\n if (event.args.beginData?.frame !== context.frameId) {\n continue;\n }\n if (!Helpers.Timing.eventIsInBounds(event, context.bounds)) {\n continue;\n }\n for (const timing of value.timings) {\n const key =\n timing[Types.Events.SelectorTimingsKey.Selector] + '_' + timing[Types.Events.SelectorTimingsKey.StyleSheetId];\n const findTiming = selectorMap.get(key);\n if (findTiming !== undefined) {\n findTiming[Types.Events.SelectorTimingsKey.Elapsed] += timing[Types.Events.SelectorTimingsKey.Elapsed];\n findTiming[Types.Events.SelectorTimingsKey.FastRejectCount] +=\n timing[Types.Events.SelectorTimingsKey.FastRejectCount];\n findTiming[Types.Events.SelectorTimingsKey.MatchAttempts] +=\n timing[Types.Events.SelectorTimingsKey.MatchAttempts];\n findTiming[Types.Events.SelectorTimingsKey.MatchCount] += timing[Types.Events.SelectorTimingsKey.MatchCount];\n } else {\n selectorMap.set(key, {...timing});\n }\n }\n }\n\n return [...selectorMap.values()];\n}\n\nfunction finalize(partialModel: PartialInsightModel<SlowCSSSelectorInsightModel>): SlowCSSSelectorInsightModel {\n return {\n insightKey: InsightKeys.SLOW_CSS_SELECTOR,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n docs: 'https://developer.chrome.com/docs/performance/insights/slow-css-selector',\n category: InsightCategory.ALL,\n state: partialModel.topSelectorElapsedMs && partialModel.topSelectorMatchAttempts ? 'informative' : 'pass',\n ...partialModel,\n };\n}\n\nexport function isSlowCSSSelectorInsight(model: InsightModel): model is SlowCSSSelectorInsightModel {\n return model.insightKey === InsightKeys.SLOW_CSS_SELECTOR;\n}\n\nexport function generateInsight(\n data: Handlers.Types.HandlerData, context: InsightSetContext): SlowCSSSelectorInsightModel {\n const selectorStatsData = data.SelectorStats;\n\n if (!selectorStatsData) {\n throw new Error('no selector stats data');\n }\n\n const selectorTimings = aggregateSelectorStats(selectorStatsData, context);\n\n let totalElapsedUs = 0;\n let totalMatchAttempts = 0;\n let totalMatchCount = 0;\n\n selectorTimings.map(timing => {\n totalElapsedUs += timing[Types.Events.SelectorTimingsKey.Elapsed];\n totalMatchAttempts += timing[Types.Events.SelectorTimingsKey.MatchAttempts];\n totalMatchCount += timing[Types.Events.SelectorTimingsKey.MatchCount];\n });\n\n let topSelectorElapsedMs: Types.Events.SelectorTiming|null = null;\n let topSelectorMatchAttempts: Types.Events.SelectorTiming|null = null;\n\n if (selectorTimings.length > 0) {\n // find the selector with most elapsed time\n topSelectorElapsedMs = selectorTimings.reduce((a, b) => {\n return a[Types.Events.SelectorTimingsKey.Elapsed] > b[Types.Events.SelectorTimingsKey.Elapsed] ? a : b;\n });\n\n // check if the slowest selector is slow enough to trigger insights info\n if (topSelectorElapsedMs &&\n topSelectorElapsedMs[Types.Events.SelectorTimingsKey.Elapsed] < slowCSSSelectorThreshold) {\n topSelectorElapsedMs = null;\n }\n\n // find the selector with most match attempts\n topSelectorMatchAttempts = selectorTimings.reduce((a, b) => {\n return a[Types.Events.SelectorTimingsKey.MatchAttempts] > b[Types.Events.SelectorTimingsKey.MatchAttempts] ? a :\n b;\n });\n }\n\n return finalize({\n // TODO: should we identify RecalcStyle events as linked to this insight?\n relatedEvents: [],\n totalElapsedMs: Types.Timing.Milli(totalElapsedUs / 1000.0),\n totalMatchAttempts,\n totalMatchCount,\n topSelectorElapsedMs,\n topSelectorMatchAttempts,\n });\n}\n\nexport function createOverlays(_: SlowCSSSelectorInsightModel): Types.Overlays.Overlay[] {\n return [];\n}\n"]}
@@ -0,0 +1,93 @@
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
+ // Lifted from Lighthouse: https://github.com/GoogleChrome/lighthouse/blob/36cac182a6c637b1671c57326d7c0241633d0076/shared/statistics.js
5
+ /**
6
+ * @license
7
+ * Copyright 2017 Google LLC
8
+ * SPDX-License-Identifier: Apache-2.0
9
+ */
10
+ // The exact double values for the max and min scores possible in each range.
11
+ const MIN_PASSING_SCORE = 0.90000000000000002220446049250313080847263336181640625;
12
+ const MAX_AVERAGE_SCORE = 0.899999999999999911182158029987476766109466552734375;
13
+ const MIN_AVERAGE_SCORE = 0.5;
14
+ const MAX_FAILING_SCORE = 0.499999999999999944488848768742172978818416595458984375;
15
+ /**
16
+ * Approximates the Gauss error function, the probability that a random variable
17
+ * from the standard normal distribution lies within [-x, x]. Moved from
18
+ * traceviewer.b.math.erf, based on Abramowitz and Stegun, formula 7.1.26.
19
+ */
20
+ function erf(x) {
21
+ // erf(-x) = -erf(x);
22
+ const sign = Math.sign(x);
23
+ x = Math.abs(x);
24
+ const a1 = 0.254829592;
25
+ const a2 = -0.284496736;
26
+ const a3 = 1.421413741;
27
+ const a4 = -1.453152027;
28
+ const a5 = 1.061405429;
29
+ const p = 0.3275911;
30
+ const t = 1 / (1 + p * x);
31
+ const y = t * (a1 + t * (a2 + t * (a3 + t * (a4 + t * a5))));
32
+ return sign * (1 - y * Math.exp(-x * x));
33
+ }
34
+ /**
35
+ * Returns the score (1 - percentile) of `value` in a log-normal distribution
36
+ * specified by the `median` value, at which the score will be 0.5, and a 10th
37
+ * percentile value, at which the score will be 0.9. The score represents the
38
+ * amount of the distribution greater than `value`. All values should be in the
39
+ * same units (e.g. milliseconds). See
40
+ * https://www.desmos.com/calculator/o98tbeyt1t
41
+ * for an interactive view of the relationship between these parameters and the
42
+ * typical parameterization (location and shape) of the log-normal distribution.
43
+ */
44
+ export function getLogNormalScore({ median, p10 }, value) {
45
+ // Required for the log-normal distribution.
46
+ if (median <= 0) {
47
+ throw new Error('median must be greater than zero');
48
+ }
49
+ if (p10 <= 0) {
50
+ throw new Error('p10 must be greater than zero');
51
+ }
52
+ // Not strictly required, but if p10 > median, it flips around and becomes the p90 point.
53
+ if (p10 >= median) {
54
+ throw new Error('p10 must be less than the median');
55
+ }
56
+ // Non-positive values aren't in the distribution, so always 1.
57
+ if (value <= 0) {
58
+ return 1;
59
+ }
60
+ // Closest double to `erfc-1(1/5)`.
61
+ const INVERSE_ERFC_ONE_FIFTH = 0.9061938024368232;
62
+ // Shape (σ) is `|log(p10/median) / (sqrt(2)*erfc^-1(1/5))|` and
63
+ // standardizedX is `1/2 erfc(log(value/median) / (sqrt(2)*σ))`, so simplify a bit.
64
+ const xRatio = Math.max(Number.MIN_VALUE, value / median); // value and median are > 0, so is ratio.
65
+ const xLogRatio = Math.log(xRatio);
66
+ const p10Ratio = Math.max(Number.MIN_VALUE, p10 / median); // p10 and median are > 0, so is ratio.
67
+ const p10LogRatio = -Math.log(p10Ratio); // negate to keep σ positive.
68
+ const standardizedX = xLogRatio * INVERSE_ERFC_ONE_FIFTH / p10LogRatio;
69
+ const complementaryPercentile = (1 - erf(standardizedX)) / 2;
70
+ // Clamp to avoid floating-point out-of-bounds issues and keep score in expected range.
71
+ let score;
72
+ if (value <= p10) {
73
+ // Passing. Clamp to [0.9, 1].
74
+ score = Math.max(MIN_PASSING_SCORE, Math.min(1, complementaryPercentile));
75
+ }
76
+ else if (value <= median) {
77
+ // Average. Clamp to [0.5, 0.9).
78
+ score = Math.max(MIN_AVERAGE_SCORE, Math.min(MAX_AVERAGE_SCORE, complementaryPercentile));
79
+ }
80
+ else {
81
+ // Failing. Clamp to [0, 0.5).
82
+ score = Math.max(0, Math.min(MAX_FAILING_SCORE, complementaryPercentile));
83
+ }
84
+ return score;
85
+ }
86
+ /**
87
+ * Interpolates the y value at a point x on the line defined by (x0, y0) and (x1, y1)
88
+ */
89
+ export function linearInterpolation(x0, y0, x1, y1, x) {
90
+ const slope = (y1 - y0) / (x1 - x0);
91
+ return y0 + (x - x0) * slope;
92
+ }
93
+ //# sourceMappingURL=Statistics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Statistics.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/Statistics.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,wIAAwI;AAExI;;;;GAIG;AAEH,6EAA6E;AAC7E,MAAM,iBAAiB,GAAG,uDAAuD,CAAC;AAClF,MAAM,iBAAiB,GAAG,qDAAqD,CAAC;AAChF,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,iBAAiB,GAAG,wDAAwD,CAAC;AAEnF;;;;GAIG;AACH,SAAS,GAAG,CAAC,CAAS;IACpB,qBAAqB;IACrB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAEhB,MAAM,EAAE,GAAG,WAAW,CAAC;IACvB,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC;IACxB,MAAM,EAAE,GAAG,WAAW,CAAC;IACvB,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC;IACxB,MAAM,EAAE,GAAG,WAAW,CAAC;IACvB,MAAM,CAAC,GAAG,SAAS,CAAC;IACpB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,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Aa,GAAG,SAAS,GAAG,sBAAsB,GAAG,WAAW,CAAC;IACvE,MAAM,uBAAuB,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC;IAE7D,uFAAuF;IACvF,IAAI,KAAK,CAAC;IACV,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;QACjB,8BAA8B;QAC9B,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC;IAC5E,CAAC;SAAM,IAAI,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,gCAAgC;QAChC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,uBAAuB,CAAC,CAAC,CAAC;IAC5F,CAAC;SAAM,CAAC;QACN,8BAA8B;QAC9B,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,uBAAuB,CAAC,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,CAAS;IAC3F,MAAM,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IACpC,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC;AAC/B,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\n// Lifted from Lighthouse: https://github.com/GoogleChrome/lighthouse/blob/36cac182a6c637b1671c57326d7c0241633d0076/shared/statistics.js\n\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// The exact double values for the max and min scores possible in each range.\nconst MIN_PASSING_SCORE = 0.90000000000000002220446049250313080847263336181640625;\nconst MAX_AVERAGE_SCORE = 0.899999999999999911182158029987476766109466552734375;\nconst MIN_AVERAGE_SCORE = 0.5;\nconst MAX_FAILING_SCORE = 0.499999999999999944488848768742172978818416595458984375;\n\n/**\n * Approximates the Gauss error function, the probability that a random variable\n * from the standard normal distribution lies within [-x, x]. Moved from\n * traceviewer.b.math.erf, based on Abramowitz and Stegun, formula 7.1.26.\n */\nfunction erf(x: number): number {\n // erf(-x) = -erf(x);\n const sign = Math.sign(x);\n x = Math.abs(x);\n\n const a1 = 0.254829592;\n const a2 = -0.284496736;\n const a3 = 1.421413741;\n const a4 = -1.453152027;\n const a5 = 1.061405429;\n const p = 0.3275911;\n const t = 1 / (1 + p * x);\n const y = t * (a1 + t * (a2 + t * (a3 + t * (a4 + t * a5))));\n return sign * (1 - y * Math.exp(-x * x));\n}\n\n/**\n * Returns the score (1 - percentile) of `value` in a log-normal distribution\n * specified by the `median` value, at which the score will be 0.5, and a 10th\n * percentile value, at which the score will be 0.9. The score represents the\n * amount of the distribution greater than `value`. All values should be in the\n * same units (e.g. milliseconds). See\n * https://www.desmos.com/calculator/o98tbeyt1t\n * for an interactive view of the relationship between these parameters and the\n * typical parameterization (location and shape) of the log-normal distribution.\n */\nexport function getLogNormalScore({median, p10}: {median: number, p10: number}, value: number): number {\n // Required for the log-normal distribution.\n if (median <= 0) {\n throw new Error('median must be greater than zero');\n }\n if (p10 <= 0) {\n throw new Error('p10 must be greater than zero');\n }\n // Not strictly required, but if p10 > median, it flips around and becomes the p90 point.\n if (p10 >= median) {\n throw new Error('p10 must be less than the median');\n }\n\n // Non-positive values aren't in the distribution, so always 1.\n if (value <= 0) {\n return 1;\n }\n\n // Closest double to `erfc-1(1/5)`.\n const INVERSE_ERFC_ONE_FIFTH = 0.9061938024368232;\n\n // Shape (σ) is `|log(p10/median) / (sqrt(2)*erfc^-1(1/5))|` and\n // standardizedX is `1/2 erfc(log(value/median) / (sqrt(2)*σ))`, so simplify a bit.\n const xRatio = Math.max(Number.MIN_VALUE, value / median); // value and median are > 0, so is ratio.\n const xLogRatio = Math.log(xRatio);\n const p10Ratio = Math.max(Number.MIN_VALUE, p10 / median); // p10 and median are > 0, so is ratio.\n const p10LogRatio = -Math.log(p10Ratio); // negate to keep σ positive.\n const standardizedX = xLogRatio * INVERSE_ERFC_ONE_FIFTH / p10LogRatio;\n const complementaryPercentile = (1 - erf(standardizedX)) / 2;\n\n // Clamp to avoid floating-point out-of-bounds issues and keep score in expected range.\n let score;\n if (value <= p10) {\n // Passing. Clamp to [0.9, 1].\n score = Math.max(MIN_PASSING_SCORE, Math.min(1, complementaryPercentile));\n } else if (value <= median) {\n // Average. Clamp to [0.5, 0.9).\n score = Math.max(MIN_AVERAGE_SCORE, Math.min(MAX_AVERAGE_SCORE, complementaryPercentile));\n } else {\n // Failing. Clamp to [0, 0.5).\n score = Math.max(0, Math.min(MAX_FAILING_SCORE, complementaryPercentile));\n }\n return score;\n}\n\n/**\n * Interpolates the y value at a point x on the line defined by (x0, y0) and (x1, y1)\n */\nexport function linearInterpolation(x0: number, y0: number, x1: number, y1: number, x: number): number {\n const slope = (y1 - y0) / (x1 - x0);\n return y0 + (x - x0) * slope;\n}\n"]}