@paulirish/trace_engine 0.0.67-beta.2 → 0.0.68

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 (766) 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.d.ts +0 -2
  14. package/core/common/ParsedURL.js +512 -0
  15. package/core/common/ParsedURL.js.map +1 -0
  16. package/core/common/common.d.ts +8 -33
  17. package/core/common/common.js +2 -0
  18. package/core/host/host.d.ts +1 -13
  19. package/core/host/host.js +1 -0
  20. package/core/i18n/i18n.d.ts +20 -8
  21. package/core/i18n/i18n.js +15 -0
  22. package/core/platform/ArrayUtilities.js +224 -0
  23. package/core/platform/ArrayUtilities.js.map +1 -0
  24. package/core/platform/Brand.js +5 -0
  25. package/core/platform/Brand.js.map +1 -0
  26. package/core/platform/Constructor.js +5 -0
  27. package/core/platform/Constructor.js.map +1 -0
  28. package/core/platform/DateUtilities.js +14 -0
  29. package/core/platform/DateUtilities.js.map +1 -0
  30. package/core/platform/DevToolsPath.js +28 -0
  31. package/core/platform/DevToolsPath.js.map +1 -0
  32. package/core/platform/HostRuntime.js +8 -0
  33. package/core/platform/HostRuntime.js.map +1 -0
  34. package/core/platform/KeyboardUtilities.js +34 -0
  35. package/core/platform/KeyboardUtilities.js.map +1 -0
  36. package/core/platform/MapUtilities.js +80 -0
  37. package/core/platform/MapUtilities.js.map +1 -0
  38. package/core/platform/MimeType.js +157 -0
  39. package/core/platform/MimeType.js.map +1 -0
  40. package/core/platform/NumberUtilities.js +73 -0
  41. package/core/platform/NumberUtilities.js.map +1 -0
  42. package/core/platform/Size.js +36 -0
  43. package/core/platform/Size.js.map +1 -0
  44. package/core/platform/StringUtilities.d.ts +15 -4
  45. package/core/platform/StringUtilities.js +767 -0
  46. package/core/platform/StringUtilities.js.map +1 -0
  47. package/core/platform/Timing.js +10 -0
  48. package/core/platform/Timing.js.map +1 -0
  49. package/core/platform/TypedArrayUtilities.js +158 -0
  50. package/core/platform/TypedArrayUtilities.js.map +1 -0
  51. package/core/platform/TypescriptUtilities.js +17 -0
  52. package/core/platform/TypescriptUtilities.js.map +1 -0
  53. package/core/platform/UIString.d.ts +5 -2
  54. package/core/platform/UIString.js +5 -0
  55. package/core/platform/UIString.js.map +1 -0
  56. package/core/platform/UserVisibleError.d.ts +1 -12
  57. package/core/platform/UserVisibleError.js +23 -0
  58. package/core/platform/UserVisibleError.js.map +1 -0
  59. package/core/platform/api/HostRuntime.d.ts +1 -0
  60. package/core/platform/api/HostRuntime.js +5 -0
  61. package/core/platform/api/HostRuntime.js.map +1 -0
  62. package/core/platform/api/api-tsconfig.json +58 -0
  63. package/core/platform/api/api-tsconfig.ref.json +26 -0
  64. package/core/platform/api/api.js +6 -0
  65. package/core/platform/api/api.js.map +1 -0
  66. package/core/platform/bundle-tsconfig.json +59 -0
  67. package/core/platform/bundle-tsconfig.ref.json +27 -0
  68. package/core/platform/foundation_unittests-tsconfig.json +73 -0
  69. package/core/platform/foundation_unittests-tsconfig.ref.json +40 -0
  70. package/core/platform/foundation_unittests_node_typecheck-tsconfig.json +69 -0
  71. package/core/platform/platform-tsconfig.json +81 -0
  72. package/core/platform/platform-tsconfig.ref.json +49 -0
  73. package/core/platform/platform.js +28 -0
  74. package/core/platform/platform.js.map +1 -0
  75. package/core/platform/platform_node_typecheck-tsconfig.json +78 -0
  76. package/core/platform/platform_node_typecheck.stamp +0 -0
  77. package/core/root/root.d.ts +1 -4
  78. package/core/root/root.js +1 -0
  79. package/core/sdk/sdk.d.ts +27 -97
  80. package/core/sdk/sdk.js +1 -0
  81. package/generated/protocol.d.ts +34 -6
  82. package/generated/protocol.js +3312 -0
  83. package/locales/af.json +94 -97
  84. package/locales/am.json +353 -356
  85. package/locales/ar.json +354 -357
  86. package/locales/as.json +352 -355
  87. package/locales/az.json +343 -346
  88. package/locales/be.json +353 -356
  89. package/locales/bg.json +353 -356
  90. package/locales/bn.json +353 -356
  91. package/locales/bs.json +247 -250
  92. package/locales/ca.json +285 -288
  93. package/locales/cs.json +338 -341
  94. package/locales/cy.json +124 -127
  95. package/locales/da.json +202 -205
  96. package/locales/de.json +222 -225
  97. package/locales/el.json +338 -341
  98. package/locales/en-GB.json +78 -81
  99. package/locales/en-US.json +250 -256
  100. package/locales/en-XL.json +1052 -0
  101. package/locales/es-419.json +278 -281
  102. package/locales/es.json +279 -282
  103. package/locales/et.json +237 -240
  104. package/locales/eu.json +124 -127
  105. package/locales/fa.json +353 -356
  106. package/locales/fi.json +283 -286
  107. package/locales/fil.json +32 -35
  108. package/locales/fr-CA.json +310 -313
  109. package/locales/fr.json +307 -310
  110. package/locales/gl.json +263 -266
  111. package/locales/gu.json +354 -357
  112. package/locales/he.json +354 -357
  113. package/locales/hi.json +338 -341
  114. package/locales/hr.json +238 -241
  115. package/locales/hu.json +344 -347
  116. package/locales/hy.json +353 -356
  117. package/locales/id.json +67 -70
  118. package/locales/is.json +305 -308
  119. package/locales/it.json +175 -178
  120. package/locales/ja.json +353 -356
  121. package/locales/ka.json +354 -357
  122. package/locales/kk.json +354 -357
  123. package/locales/km.json +353 -356
  124. package/locales/kn.json +354 -357
  125. package/locales/ko.json +353 -356
  126. package/locales/ky.json +352 -355
  127. package/locales/lo.json +354 -357
  128. package/locales/lt.json +322 -325
  129. package/locales/lv.json +319 -322
  130. package/locales/mk.json +354 -357
  131. package/locales/ml.json +353 -356
  132. package/locales/mn.json +353 -356
  133. package/locales/mr.json +353 -356
  134. package/locales/ms.json +14 -17
  135. package/locales/my.json +352 -355
  136. package/locales/ne.json +338 -341
  137. package/locales/nl.json +91 -94
  138. package/locales/no.json +179 -182
  139. package/locales/or.json +353 -356
  140. package/locales/pa.json +353 -356
  141. package/locales/pl.json +309 -312
  142. package/locales/pt-PT.json +275 -278
  143. package/locales/pt.json +268 -271
  144. package/locales/ro.json +309 -312
  145. package/locales/ru.json +353 -356
  146. package/locales/si.json +354 -357
  147. package/locales/sk.json +335 -338
  148. package/locales/sl.json +220 -223
  149. package/locales/sq.json +318 -321
  150. package/locales/sr-Latn.json +255 -258
  151. package/locales/sr.json +354 -357
  152. package/locales/sv.json +281 -284
  153. package/locales/sw.json +68 -71
  154. package/locales/ta.json +354 -357
  155. package/locales/te.json +352 -355
  156. package/locales/th.json +354 -357
  157. package/locales/tr.json +328 -331
  158. package/locales/uk.json +353 -356
  159. package/locales/ur.json +354 -357
  160. package/locales/uz.json +168 -171
  161. package/locales/vi.json +354 -357
  162. package/locales/zh-HK.json +354 -357
  163. package/locales/zh-TW.json +353 -356
  164. package/locales/zh.json +353 -356
  165. package/locales/zu.json +52 -55
  166. package/models/cpu_profile/CPUProfileDataModel.d.ts +0 -33
  167. package/models/cpu_profile/CPUProfileDataModel.js +517 -0
  168. package/models/cpu_profile/CPUProfileDataModel.js.map +1 -0
  169. package/models/cpu_profile/ProfileTreeModel.d.ts +1 -2
  170. package/models/cpu_profile/ProfileTreeModel.js +90 -0
  171. package/models/cpu_profile/ProfileTreeModel.js.map +1 -0
  172. package/models/cpu_profile/bundle-tsconfig.json +59 -0
  173. package/models/cpu_profile/bundle-tsconfig.ref.json +27 -0
  174. package/models/cpu_profile/cpu_profile-tsconfig.json +63 -0
  175. package/models/cpu_profile/cpu_profile-tsconfig.ref.json +31 -0
  176. package/models/cpu_profile/cpu_profile.js +7 -0
  177. package/models/cpu_profile/cpu_profile.js.map +1 -0
  178. package/models/cpu_profile/cpu_profile_node_typecheck-tsconfig.json +60 -0
  179. package/models/cpu_profile/cpu_profile_node_typecheck.stamp +0 -0
  180. package/models/cpu_profile/foundation_unittests-tsconfig.json +63 -0
  181. package/models/cpu_profile/foundation_unittests-tsconfig.ref.json +30 -0
  182. package/models/cpu_profile/foundation_unittests_node_typecheck-tsconfig.json +59 -0
  183. package/models/crux-manager/crux-manager.d.ts +3 -1
  184. package/models/crux-manager/crux-manager.js +1 -0
  185. package/models/trace/EntityMapper.js +133 -0
  186. package/models/trace/EntityMapper.js.map +1 -0
  187. package/models/trace/EventsSerializer.d.ts +1 -0
  188. package/models/trace/EventsSerializer.js +113 -0
  189. package/models/trace/EventsSerializer.js.map +1 -0
  190. package/models/trace/LanternComputationData.js +394 -0
  191. package/models/trace/LanternComputationData.js.map +1 -0
  192. package/models/trace/ModelImpl.js +179 -0
  193. package/models/trace/ModelImpl.js.map +1 -0
  194. package/models/trace/Name.js +115 -0
  195. package/models/trace/Name.js.map +1 -0
  196. package/models/trace/Processor.js +616 -0
  197. package/models/trace/Processor.js.map +1 -0
  198. package/models/trace/Styles.d.ts +2 -2
  199. package/models/trace/Styles.js +836 -0
  200. package/models/trace/Styles.js.map +1 -0
  201. package/models/trace/bundle-tsconfig.json +77 -0
  202. package/models/trace/bundle-tsconfig.ref.json +45 -0
  203. package/models/trace/extras/FilmStrip.js +45 -0
  204. package/models/trace/extras/FilmStrip.js.map +1 -0
  205. package/models/trace/extras/Initiators.js +47 -0
  206. package/models/trace/extras/Initiators.js.map +1 -0
  207. package/models/trace/extras/MainThreadActivity.js +77 -0
  208. package/models/trace/extras/MainThreadActivity.js.map +1 -0
  209. package/models/trace/extras/ScriptDuplication.js +163 -0
  210. package/models/trace/extras/ScriptDuplication.js.map +1 -0
  211. package/models/trace/extras/StackTraceForEvent.js +192 -0
  212. package/models/trace/extras/StackTraceForEvent.js.map +1 -0
  213. package/models/trace/extras/ThirdParties.js +119 -0
  214. package/models/trace/extras/ThirdParties.js.map +1 -0
  215. package/models/trace/extras/TraceFilter.js +51 -0
  216. package/models/trace/extras/TraceFilter.js.map +1 -0
  217. package/models/trace/extras/TraceTree.js +678 -0
  218. package/models/trace/extras/TraceTree.js.map +1 -0
  219. package/models/trace/extras/bundle-tsconfig.json +59 -0
  220. package/models/trace/extras/bundle-tsconfig.ref.json +27 -0
  221. package/models/trace/extras/extras-tsconfig.json +81 -0
  222. package/models/trace/extras/extras-tsconfig.ref.json +49 -0
  223. package/models/trace/extras/extras.js +12 -0
  224. package/models/trace/extras/extras.js.map +1 -0
  225. package/models/trace/extras/extras_node_typecheck-tsconfig.json +78 -0
  226. package/models/trace/extras/extras_node_typecheck.stamp +0 -0
  227. package/models/trace/extras/foundation_unittests-tsconfig.json +91 -0
  228. package/models/trace/extras/foundation_unittests-tsconfig.ref.json +58 -0
  229. package/models/trace/extras/foundation_unittests_node_typecheck-tsconfig.json +87 -0
  230. package/models/trace/foundation_unittests-tsconfig.json +70 -0
  231. package/models/trace/foundation_unittests-tsconfig.ref.json +37 -0
  232. package/models/trace/foundation_unittests_node_typecheck-tsconfig.json +66 -0
  233. package/models/trace/handlers/AnimationFramesHandler.js +110 -0
  234. package/models/trace/handlers/AnimationFramesHandler.js.map +1 -0
  235. package/models/trace/handlers/AnimationHandler.js +27 -0
  236. package/models/trace/handlers/AnimationHandler.js.map +1 -0
  237. package/models/trace/handlers/AsyncJSCallsHandler.js +188 -0
  238. package/models/trace/handlers/AsyncJSCallsHandler.js.map +1 -0
  239. package/models/trace/handlers/DOMStatsHandler.js +22 -0
  240. package/models/trace/handlers/DOMStatsHandler.js.map +1 -0
  241. package/models/trace/handlers/ExtensionTraceDataHandler.js +264 -0
  242. package/models/trace/handlers/ExtensionTraceDataHandler.js.map +1 -0
  243. package/models/trace/handlers/FlowsHandler.js +155 -0
  244. package/models/trace/handlers/FlowsHandler.js.map +1 -0
  245. package/models/trace/handlers/FramesHandler.js +491 -0
  246. package/models/trace/handlers/FramesHandler.js.map +1 -0
  247. package/models/trace/handlers/GPUHandler.js +36 -0
  248. package/models/trace/handlers/GPUHandler.js.map +1 -0
  249. package/models/trace/handlers/ImagePaintingHandler.js +148 -0
  250. package/models/trace/handlers/ImagePaintingHandler.js.map +1 -0
  251. package/models/trace/handlers/InitiatorsHandler.js +169 -0
  252. package/models/trace/handlers/InitiatorsHandler.js.map +1 -0
  253. package/models/trace/handlers/InvalidationsHandler.js +125 -0
  254. package/models/trace/handlers/InvalidationsHandler.js.map +1 -0
  255. package/models/trace/handlers/LargestImagePaintHandler.js +86 -0
  256. package/models/trace/handlers/LargestImagePaintHandler.js.map +1 -0
  257. package/models/trace/handlers/LargestTextPaintHandler.js +28 -0
  258. package/models/trace/handlers/LargestTextPaintHandler.js.map +1 -0
  259. package/models/trace/handlers/LayerTreeHandler.js +104 -0
  260. package/models/trace/handlers/LayerTreeHandler.js.map +1 -0
  261. package/models/trace/handlers/LayoutShiftsHandler.js +449 -0
  262. package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -0
  263. package/models/trace/handlers/MemoryHandler.js +22 -0
  264. package/models/trace/handlers/MemoryHandler.js.map +1 -0
  265. package/models/trace/handlers/MetaHandler.js +442 -0
  266. package/models/trace/handlers/MetaHandler.js.map +1 -0
  267. package/models/trace/handlers/ModelHandlers.js +33 -0
  268. package/models/trace/handlers/ModelHandlers.js.map +1 -0
  269. package/models/trace/handlers/NetworkRequestsHandler.js +584 -0
  270. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -0
  271. package/models/trace/handlers/PageFramesHandler.js +43 -0
  272. package/models/trace/handlers/PageFramesHandler.js.map +1 -0
  273. package/models/trace/handlers/PageLoadMetricsHandler.js +463 -0
  274. package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -0
  275. package/models/trace/handlers/RendererHandler.js +346 -0
  276. package/models/trace/handlers/RendererHandler.js.map +1 -0
  277. package/models/trace/handlers/SamplesHandler.js +264 -0
  278. package/models/trace/handlers/SamplesHandler.js.map +1 -0
  279. package/models/trace/handlers/ScreenshotsHandler.js +56 -0
  280. package/models/trace/handlers/ScreenshotsHandler.js.map +1 -0
  281. package/models/trace/handlers/ScriptsHandler.js +277 -0
  282. package/models/trace/handlers/ScriptsHandler.js.map +1 -0
  283. package/models/trace/handlers/SelectorStatsHandler.js +72 -0
  284. package/models/trace/handlers/SelectorStatsHandler.js.map +1 -0
  285. package/models/trace/handlers/Threads.js +108 -0
  286. package/models/trace/handlers/Threads.js.map +1 -0
  287. package/models/trace/handlers/UserInteractionsHandler.js +319 -0
  288. package/models/trace/handlers/UserInteractionsHandler.js.map +1 -0
  289. package/models/trace/handlers/UserTimingsHandler.js +194 -0
  290. package/models/trace/handlers/UserTimingsHandler.js.map +1 -0
  291. package/models/trace/handlers/WarningsHandler.js +135 -0
  292. package/models/trace/handlers/WarningsHandler.js.map +1 -0
  293. package/models/trace/handlers/WorkersHandler.js +34 -0
  294. package/models/trace/handlers/WorkersHandler.js.map +1 -0
  295. package/models/trace/handlers/bundle-tsconfig.json +59 -0
  296. package/models/trace/handlers/bundle-tsconfig.ref.json +27 -0
  297. package/models/trace/handlers/foundation_unittests-tsconfig.json +102 -0
  298. package/models/trace/handlers/foundation_unittests-tsconfig.ref.json +69 -0
  299. package/models/trace/handlers/foundation_unittests_node_typecheck-tsconfig.json +98 -0
  300. package/models/trace/handlers/handlers-tsconfig.json +112 -0
  301. package/models/trace/handlers/handlers-tsconfig.ref.json +80 -0
  302. package/models/trace/handlers/handlers.js +8 -0
  303. package/models/trace/handlers/handlers.js.map +1 -0
  304. package/models/trace/handlers/handlers_node_typecheck-tsconfig.json +109 -0
  305. package/models/trace/handlers/handlers_node_typecheck.stamp +0 -0
  306. package/models/trace/handlers/helpers.js +167 -0
  307. package/models/trace/handlers/helpers.js.map +1 -0
  308. package/models/trace/handlers/types.js +2 -0
  309. package/models/trace/handlers/types.js.map +1 -0
  310. package/models/trace/helpers/Extensions.js +42 -0
  311. package/models/trace/helpers/Extensions.js.map +1 -0
  312. package/models/trace/helpers/Network.js +103 -0
  313. package/models/trace/helpers/Network.js.map +1 -0
  314. package/models/trace/helpers/SamplesIntegrator.js +527 -0
  315. package/models/trace/helpers/SamplesIntegrator.js.map +1 -0
  316. package/models/trace/helpers/SyntheticEvents.d.ts +0 -8
  317. package/models/trace/helpers/SyntheticEvents.js +73 -0
  318. package/models/trace/helpers/SyntheticEvents.js.map +1 -0
  319. package/models/trace/helpers/Timing.js +200 -0
  320. package/models/trace/helpers/Timing.js.map +1 -0
  321. package/models/trace/helpers/Trace.js +844 -0
  322. package/models/trace/helpers/Trace.js.map +1 -0
  323. package/models/trace/helpers/TreeHelpers.js +255 -0
  324. package/models/trace/helpers/TreeHelpers.js.map +1 -0
  325. package/models/trace/helpers/bundle-tsconfig.json +59 -0
  326. package/models/trace/helpers/bundle-tsconfig.ref.json +27 -0
  327. package/models/trace/helpers/foundation_unittests-tsconfig.json +73 -0
  328. package/models/trace/helpers/foundation_unittests-tsconfig.ref.json +40 -0
  329. package/models/trace/helpers/foundation_unittests_node_typecheck-tsconfig.json +69 -0
  330. package/models/trace/helpers/helpers-tsconfig.json +77 -0
  331. package/models/trace/helpers/helpers-tsconfig.ref.json +45 -0
  332. package/models/trace/helpers/helpers.js +11 -0
  333. package/models/trace/helpers/helpers.js.map +1 -0
  334. package/models/trace/helpers/helpers_node_typecheck-tsconfig.json +74 -0
  335. package/models/trace/helpers/helpers_node_typecheck.stamp +0 -0
  336. package/models/trace/insights/CLSCulprits.d.ts +14 -14
  337. package/models/trace/insights/CLSCulprits.js +519 -0
  338. package/models/trace/insights/CLSCulprits.js.map +1 -0
  339. package/models/trace/insights/Cache.d.ts +6 -6
  340. package/models/trace/insights/Cache.js +210 -0
  341. package/models/trace/insights/Cache.js.map +1 -0
  342. package/models/trace/insights/CharacterSet.d.ts +8 -8
  343. package/models/trace/insights/CharacterSet.js +132 -0
  344. package/models/trace/insights/CharacterSet.js.map +1 -0
  345. package/models/trace/insights/Common.js +367 -0
  346. package/models/trace/insights/Common.js.map +1 -0
  347. package/models/trace/insights/DOMSize.d.ts +13 -13
  348. package/models/trace/insights/DOMSize.js +182 -0
  349. package/models/trace/insights/DOMSize.js.map +1 -0
  350. package/models/trace/insights/DocumentLatency.d.ts +11 -11
  351. package/models/trace/insights/DocumentLatency.js +259 -0
  352. package/models/trace/insights/DocumentLatency.js.map +1 -0
  353. package/models/trace/insights/DuplicatedJavaScript.d.ts +5 -5
  354. package/models/trace/insights/DuplicatedJavaScript.js +110 -0
  355. package/models/trace/insights/DuplicatedJavaScript.js.map +1 -0
  356. package/models/trace/insights/FontDisplay.d.ts +5 -5
  357. package/models/trace/insights/FontDisplay.js +93 -0
  358. package/models/trace/insights/FontDisplay.js.map +1 -0
  359. package/models/trace/insights/ForcedReflow.d.ts +7 -7
  360. package/models/trace/insights/ForcedReflow.js +162 -0
  361. package/models/trace/insights/ForcedReflow.js.map +1 -0
  362. package/models/trace/insights/INPBreakdown.d.ts +8 -8
  363. package/models/trace/insights/INPBreakdown.js +130 -0
  364. package/models/trace/insights/INPBreakdown.js.map +1 -0
  365. package/models/trace/insights/ImageDelivery.d.ts +12 -12
  366. package/models/trace/insights/ImageDelivery.js +264 -0
  367. package/models/trace/insights/ImageDelivery.js.map +1 -0
  368. package/models/trace/insights/LCPBreakdown.d.ts +11 -11
  369. package/models/trace/insights/LCPBreakdown.js +200 -0
  370. package/models/trace/insights/LCPBreakdown.js.map +1 -0
  371. package/models/trace/insights/LCPDiscovery.d.ts +10 -10
  372. package/models/trace/insights/LCPDiscovery.js +190 -0
  373. package/models/trace/insights/LCPDiscovery.js.map +1 -0
  374. package/models/trace/insights/LegacyJavaScript.d.ts +5 -5
  375. package/models/trace/insights/LegacyJavaScript.js +99 -0
  376. package/models/trace/insights/LegacyJavaScript.js.map +1 -0
  377. package/models/trace/insights/Models.js +23 -0
  378. package/models/trace/insights/Models.js.map +1 -0
  379. package/models/trace/insights/ModernHTTP.d.ts +5 -5
  380. package/models/trace/insights/ModernHTTP.js +205 -0
  381. package/models/trace/insights/ModernHTTP.js.map +1 -0
  382. package/models/trace/insights/NetworkDependencyTree.d.ts +19 -19
  383. package/models/trace/insights/NetworkDependencyTree.js +551 -0
  384. package/models/trace/insights/NetworkDependencyTree.js.map +1 -0
  385. package/models/trace/insights/RenderBlocking.d.ts +5 -5
  386. package/models/trace/insights/RenderBlocking.js +213 -0
  387. package/models/trace/insights/RenderBlocking.js.map +1 -0
  388. package/models/trace/insights/SlowCSSSelector.d.ts +10 -10
  389. package/models/trace/insights/SlowCSSSelector.js +140 -0
  390. package/models/trace/insights/SlowCSSSelector.js.map +1 -0
  391. package/models/trace/insights/Statistics.js +93 -0
  392. package/models/trace/insights/Statistics.js.map +1 -0
  393. package/models/trace/insights/ThirdParties.d.ts +6 -6
  394. package/models/trace/insights/ThirdParties.js +110 -0
  395. package/models/trace/insights/ThirdParties.js.map +1 -0
  396. package/models/trace/insights/Viewport.d.ts +3 -3
  397. package/models/trace/insights/Viewport.js +105 -0
  398. package/models/trace/insights/Viewport.js.map +1 -0
  399. package/models/trace/insights/bundle-tsconfig.json +59 -0
  400. package/models/trace/insights/bundle-tsconfig.ref.json +27 -0
  401. package/models/trace/insights/foundation_unittests-tsconfig.json +98 -0
  402. package/models/trace/insights/foundation_unittests-tsconfig.ref.json +65 -0
  403. package/models/trace/insights/foundation_unittests_node_typecheck-tsconfig.json +94 -0
  404. package/models/trace/insights/insights-tsconfig.json +114 -0
  405. package/models/trace/insights/insights-tsconfig.ref.json +82 -0
  406. package/models/trace/insights/insights.js +10 -0
  407. package/models/trace/insights/insights.js.map +1 -0
  408. package/models/trace/insights/insights_node_typecheck-tsconfig.json +111 -0
  409. package/models/trace/insights/insights_node_typecheck.stamp +0 -0
  410. package/models/trace/insights/types.d.ts +3 -3
  411. package/models/trace/insights/types.js +41 -0
  412. package/models/trace/insights/types.js.map +1 -0
  413. package/models/trace/lantern/bundle-tsconfig.json +71 -0
  414. package/models/trace/lantern/bundle-tsconfig.ref.json +39 -0
  415. package/models/trace/lantern/core/LanternError.js +7 -0
  416. package/models/trace/lantern/core/LanternError.js.map +1 -0
  417. package/models/trace/lantern/core/NetworkAnalyzer.js +496 -0
  418. package/models/trace/lantern/core/NetworkAnalyzer.js.map +1 -0
  419. package/models/trace/lantern/core/bundle-tsconfig.json +59 -0
  420. package/models/trace/lantern/core/bundle-tsconfig.ref.json +27 -0
  421. package/models/trace/lantern/core/core-tsconfig.json +60 -0
  422. package/models/trace/lantern/core/core-tsconfig.ref.json +28 -0
  423. package/models/trace/lantern/core/core.js +6 -0
  424. package/models/trace/lantern/core/core.js.map +1 -0
  425. package/models/trace/lantern/core/core_node_typecheck-tsconfig.json +57 -0
  426. package/models/trace/lantern/core/core_node_typecheck.stamp +0 -0
  427. package/models/trace/lantern/core/foundation_unittests-tsconfig.json +69 -0
  428. package/models/trace/lantern/core/foundation_unittests-tsconfig.ref.json +36 -0
  429. package/models/trace/lantern/core/foundation_unittests_node_typecheck-tsconfig.json +65 -0
  430. package/models/trace/lantern/graph/BaseNode.d.ts +2 -2
  431. package/models/trace/lantern/graph/BaseNode.js +277 -0
  432. package/models/trace/lantern/graph/BaseNode.js.map +1 -0
  433. package/models/trace/lantern/graph/CPUNode.js +80 -0
  434. package/models/trace/lantern/graph/CPUNode.js.map +1 -0
  435. package/models/trace/lantern/graph/NetworkNode.js +95 -0
  436. package/models/trace/lantern/graph/NetworkNode.js.map +1 -0
  437. package/models/trace/lantern/graph/PageDependencyGraph.js +574 -0
  438. package/models/trace/lantern/graph/PageDependencyGraph.js.map +1 -0
  439. package/models/trace/lantern/graph/bundle-tsconfig.json +59 -0
  440. package/models/trace/lantern/graph/bundle-tsconfig.ref.json +27 -0
  441. package/models/trace/lantern/graph/foundation_unittests-tsconfig.json +61 -0
  442. package/models/trace/lantern/graph/foundation_unittests-tsconfig.ref.json +28 -0
  443. package/models/trace/lantern/graph/foundation_unittests_node_typecheck-tsconfig.json +57 -0
  444. package/models/trace/lantern/graph/graph-tsconfig.json +65 -0
  445. package/models/trace/lantern/graph/graph-tsconfig.ref.json +33 -0
  446. package/models/trace/lantern/graph/graph.js +8 -0
  447. package/models/trace/lantern/graph/graph.js.map +1 -0
  448. package/models/trace/lantern/graph/graph_node_typecheck-tsconfig.json +62 -0
  449. package/models/trace/lantern/graph/graph_node_typecheck.stamp +0 -0
  450. package/models/trace/lantern/lantern.js +10 -0
  451. package/models/trace/lantern/lantern.js.map +1 -0
  452. package/models/trace/lantern/metrics/FirstContentfulPaint.js +137 -0
  453. package/models/trace/lantern/metrics/FirstContentfulPaint.js.map +1 -0
  454. package/models/trace/lantern/metrics/Interactive.js +68 -0
  455. package/models/trace/lantern/metrics/Interactive.js.map +1 -0
  456. package/models/trace/lantern/metrics/LargestContentfulPaint.d.ts +5 -1
  457. package/models/trace/lantern/metrics/LargestContentfulPaint.js +187 -0
  458. package/models/trace/lantern/metrics/LargestContentfulPaint.js.map +1 -0
  459. package/models/trace/lantern/metrics/MaxPotentialFID.js +49 -0
  460. package/models/trace/lantern/metrics/MaxPotentialFID.js.map +1 -0
  461. package/models/trace/lantern/metrics/Metric.js +69 -0
  462. package/models/trace/lantern/metrics/Metric.js.map +1 -0
  463. package/models/trace/lantern/metrics/SpeedIndex.js +102 -0
  464. package/models/trace/lantern/metrics/SpeedIndex.js.map +1 -0
  465. package/models/trace/lantern/metrics/TBTUtils.js +65 -0
  466. package/models/trace/lantern/metrics/TBTUtils.js.map +1 -0
  467. package/models/trace/lantern/metrics/TotalBlockingTime.js +79 -0
  468. package/models/trace/lantern/metrics/TotalBlockingTime.js.map +1 -0
  469. package/models/trace/lantern/metrics/bundle-tsconfig.json +59 -0
  470. package/models/trace/lantern/metrics/bundle-tsconfig.ref.json +27 -0
  471. package/models/trace/lantern/metrics/foundation_unittests-tsconfig.json +76 -0
  472. package/models/trace/lantern/metrics/foundation_unittests-tsconfig.ref.json +43 -0
  473. package/models/trace/lantern/metrics/foundation_unittests_node_typecheck-tsconfig.json +72 -0
  474. package/models/trace/lantern/metrics/metrics-tsconfig.json +75 -0
  475. package/models/trace/lantern/metrics/metrics-tsconfig.ref.json +43 -0
  476. package/models/trace/lantern/metrics/metrics.js +12 -0
  477. package/models/trace/lantern/metrics/metrics.js.map +1 -0
  478. package/models/trace/lantern/metrics/metrics_node_typecheck-tsconfig.json +72 -0
  479. package/models/trace/lantern/metrics/metrics_node_typecheck.stamp +0 -0
  480. package/models/trace/lantern/simulation/ConnectionPool.js +116 -0
  481. package/models/trace/lantern/simulation/ConnectionPool.js.map +1 -0
  482. package/models/trace/lantern/simulation/Constants.js +45 -0
  483. package/models/trace/lantern/simulation/Constants.js.map +1 -0
  484. package/models/trace/lantern/simulation/DNSCache.js +48 -0
  485. package/models/trace/lantern/simulation/DNSCache.js.map +1 -0
  486. package/models/trace/lantern/simulation/SimulationTimingMap.js +135 -0
  487. package/models/trace/lantern/simulation/SimulationTimingMap.js.map +1 -0
  488. package/models/trace/lantern/simulation/Simulator.js +461 -0
  489. package/models/trace/lantern/simulation/Simulator.js.map +1 -0
  490. package/models/trace/lantern/simulation/TCPConnection.js +155 -0
  491. package/models/trace/lantern/simulation/TCPConnection.js.map +1 -0
  492. package/models/trace/lantern/simulation/bundle-tsconfig.json +59 -0
  493. package/models/trace/lantern/simulation/bundle-tsconfig.ref.json +27 -0
  494. package/models/trace/lantern/simulation/foundation_unittests-tsconfig.json +75 -0
  495. package/models/trace/lantern/simulation/foundation_unittests-tsconfig.ref.json +42 -0
  496. package/models/trace/lantern/simulation/foundation_unittests_node_typecheck-tsconfig.json +71 -0
  497. package/models/trace/lantern/simulation/simulation-tsconfig.json +70 -0
  498. package/models/trace/lantern/simulation/simulation-tsconfig.ref.json +38 -0
  499. package/models/trace/lantern/simulation/simulation.js +10 -0
  500. package/models/trace/lantern/simulation/simulation.js.map +1 -0
  501. package/models/trace/lantern/simulation/simulation_node_typecheck-tsconfig.json +67 -0
  502. package/models/trace/lantern/simulation/simulation_node_typecheck.stamp +0 -0
  503. package/models/trace/lantern/testing/bundle-tsconfig.json +60 -0
  504. package/models/trace/lantern/testing/bundle-tsconfig.ref.json +27 -0
  505. package/models/trace/lantern/testing/testing-tsconfig.json +63 -0
  506. package/models/trace/lantern/testing/testing-tsconfig.ref.json +30 -0
  507. package/models/trace/lantern/types/Lantern.d.ts +23 -19
  508. package/models/trace/lantern/types/Lantern.js +25 -0
  509. package/models/trace/lantern/types/Lantern.js.map +1 -0
  510. package/models/trace/lantern/types/bundle-tsconfig.json +59 -0
  511. package/models/trace/lantern/types/bundle-tsconfig.ref.json +27 -0
  512. package/models/trace/lantern/types/types-tsconfig.json +59 -0
  513. package/models/trace/lantern/types/types-tsconfig.ref.json +27 -0
  514. package/models/trace/lantern/types/types.js +5 -0
  515. package/models/trace/lantern/types/types.js.map +1 -0
  516. package/models/trace/lantern/types/types_node_typecheck-tsconfig.json +56 -0
  517. package/models/trace/lantern/types/types_node_typecheck.stamp +0 -0
  518. package/models/trace/trace-tsconfig.json +89 -0
  519. package/models/trace/trace-tsconfig.ref.json +57 -0
  520. package/models/trace/trace.js +16 -544
  521. package/models/trace/trace.js.map +1 -0
  522. package/models/trace/trace_node_typecheck-tsconfig.json +86 -0
  523. package/models/trace/trace_node_typecheck.stamp +0 -0
  524. package/models/trace/types/Configuration.d.ts +2 -2
  525. package/models/trace/types/Configuration.js +19 -0
  526. package/models/trace/types/Configuration.js.map +1 -0
  527. package/models/trace/types/Extensions.d.ts +1 -1
  528. package/models/trace/types/Extensions.js +38 -0
  529. package/models/trace/types/Extensions.js.map +1 -0
  530. package/models/trace/types/File.d.ts +9 -3
  531. package/models/trace/types/File.js +92 -0
  532. package/models/trace/types/File.js.map +1 -0
  533. package/models/trace/types/Overlays.js +5 -0
  534. package/models/trace/types/Overlays.js.map +1 -0
  535. package/models/trace/types/Timing.js +16 -0
  536. package/models/trace/types/Timing.js.map +1 -0
  537. package/models/trace/types/TraceEvents.d.ts +21 -16
  538. package/models/trace/types/TraceEvents.js +983 -0
  539. package/models/trace/types/TraceEvents.js.map +1 -0
  540. package/models/trace/types/bundle-tsconfig.json +59 -0
  541. package/models/trace/types/bundle-tsconfig.ref.json +27 -0
  542. package/models/trace/types/foundation_unittests-tsconfig.json +67 -0
  543. package/models/trace/types/foundation_unittests-tsconfig.ref.json +34 -0
  544. package/models/trace/types/foundation_unittests_node_typecheck-tsconfig.json +63 -0
  545. package/models/trace/types/types-tsconfig.json +76 -0
  546. package/models/trace/types/types-tsconfig.ref.json +44 -0
  547. package/models/trace/types/types.js +10 -0
  548. package/models/trace/types/types.js.map +1 -0
  549. package/models/trace/types/types_node_typecheck-tsconfig.json +73 -0
  550. package/models/trace/types/types_node_typecheck.stamp +0 -0
  551. package/package.json +8 -40
  552. package/test/invalid-animation-events.json.gz +0 -0
  553. package/test/test-trace-engine.mjs +191 -0
  554. package/third_party/legacy-javascript/bundle-tsconfig.json +59 -0
  555. package/third_party/legacy-javascript/bundle-tsconfig.ref.json +27 -0
  556. package/third_party/legacy-javascript/legacy-javascript-tsconfig.ref.json +15 -0
  557. package/third_party/legacy-javascript/legacy-javascript.js +3 -0
  558. package/third_party/legacy-javascript/legacy-javascript.js.map +1 -0
  559. package/third_party/legacy-javascript/lib/legacy-javascript.js +1119 -0
  560. package/third_party/marked/marked.d.ts +1 -2
  561. package/third_party/marked/marked.js +1 -0
  562. package/third_party/third-party-web/third-party-web.d.ts +1 -2
  563. package/third_party/third-party-web/third-party-web.js +1 -0
  564. package/tsconfig.json +29 -0
  565. package/core/common/Base64.d.ts +0 -12
  566. package/core/common/CharacterIdMap.d.ts +0 -5
  567. package/core/common/Color.d.ts +0 -357
  568. package/core/common/ColorConverter.d.ts +0 -26
  569. package/core/common/ColorUtils.d.ts +0 -45
  570. package/core/common/Console.d.ts +0 -54
  571. package/core/common/Debouncer.d.ts +0 -8
  572. package/core/common/EventTarget.d.ts +0 -22
  573. package/core/common/Gzip.d.ts +0 -23
  574. package/core/common/JavaScriptMetaData.d.ts +0 -20
  575. package/core/common/Lazy.d.ts +0 -4
  576. package/core/common/MapWithDefault.d.ts +0 -9
  577. package/core/common/Mutex.d.ts +0 -13
  578. package/core/common/Object.d.ts +0 -20
  579. package/core/common/Progress.d.ts +0 -47
  580. package/core/common/ResolverBase.d.ts +0 -29
  581. package/core/common/ResourceType.d.ts +0 -52
  582. package/core/common/ReturnToPanel.d.ts +0 -10
  583. package/core/common/Revealer.d.ts +0 -66
  584. package/core/common/Runnable.d.ts +0 -14
  585. package/core/common/SegmentedRange.d.ts +0 -14
  586. package/core/common/SettingRegistration.d.ts +0 -136
  587. package/core/common/Settings.d.ts +0 -228
  588. package/core/common/SimpleHistoryManager.d.ts +0 -20
  589. package/core/common/Srcset.d.ts +0 -16
  590. package/core/common/StringOutputStream.d.ts +0 -10
  591. package/core/common/TextDictionary.d.ts +0 -11
  592. package/core/common/Throttler.d.ts +0 -12
  593. package/core/common/Trie.d.ts +0 -24
  594. package/core/common/VersionController.d.ts +0 -85
  595. package/core/host/AidaClient.d.ts +0 -73
  596. package/core/host/AidaClientTypes.d.ts +0 -355
  597. package/core/host/AidaGcaTranslation.d.ts +0 -10
  598. package/core/host/DispatchHttpRequestClient.d.ts +0 -14
  599. package/core/host/GcaClient.d.ts +0 -14
  600. package/core/host/GcaTypes.d.ts +0 -411
  601. package/core/host/GdpClient.d.ts +0 -84
  602. package/core/host/InspectorFrontendHost.d.ts +0 -29
  603. package/core/host/InspectorFrontendHostAPI.d.ts +0 -425
  604. package/core/host/InspectorFrontendHostStub.d.ts +0 -151
  605. package/core/host/Platform.d.ts +0 -16
  606. package/core/host/ResourceLoader.d.ts +0 -15
  607. package/core/host/UserMetrics.d.ts +0 -116
  608. package/core/host/UserMetricsEnums.d.ts +0 -888
  609. package/core/i18n/ByteUtilities.d.ts +0 -11
  610. package/core/i18n/DevToolsLocale.d.ts +0 -41
  611. package/core/i18n/NumberFormatter.d.ts +0 -11
  612. package/core/i18n/i18nImpl.d.ts +0 -64
  613. package/core/i18n/i18nTypes.d.ts +0 -5
  614. package/core/i18n/locales.d.ts +0 -15
  615. package/core/i18n/time-utilities.d.ts +0 -16
  616. package/core/platform/browser/HostRuntime.d.ts +0 -2
  617. package/core/platform/browser/browser.d.ts +0 -2
  618. package/core/platform/node/HostRuntime.d.ts +0 -2
  619. package/core/platform/node/node.d.ts +0 -2
  620. package/core/protocol_client/CDPConnection.d.ts +0 -77
  621. package/core/protocol_client/ConnectionTransport.d.ts +0 -9
  622. package/core/protocol_client/DevToolsCDPConnection.d.ts +0 -16
  623. package/core/protocol_client/InspectorBackend.d.ts +0 -223
  624. package/core/protocol_client/protocol_client.d.ts +0 -5
  625. package/core/root/DevToolsContext.d.ts +0 -34
  626. package/core/root/ExperimentNames.d.ts +0 -9
  627. package/core/root/Runtime.d.ts +0 -353
  628. package/core/sdk/AccessibilityModel.d.ts +0 -76
  629. package/core/sdk/AnimationModel.d.ts +0 -161
  630. package/core/sdk/AutofillModel.d.ts +0 -23
  631. package/core/sdk/CPUProfilerModel.d.ts +0 -46
  632. package/core/sdk/CPUThrottlingManager.d.ts +0 -47
  633. package/core/sdk/CSSContainerQuery.d.ts +0 -42
  634. package/core/sdk/CSSFontFace.d.ts +0 -10
  635. package/core/sdk/CSSLayer.d.ts +0 -9
  636. package/core/sdk/CSSLocation.d.ts +0 -14
  637. package/core/sdk/CSSMatchedStyles.d.ts +0 -138
  638. package/core/sdk/CSSMedia.d.ts +0 -36
  639. package/core/sdk/CSSMetadata.d.ts +0 -87
  640. package/core/sdk/CSSModel.d.ts +0 -185
  641. package/core/sdk/CSSNavigation.d.ts +0 -10
  642. package/core/sdk/CSSProperty.d.ts +0 -53
  643. package/core/sdk/CSSPropertyParser.d.ts +0 -126
  644. package/core/sdk/CSSPropertyParserMatchers.d.ts +0 -442
  645. package/core/sdk/CSSQuery.d.ts +0 -22
  646. package/core/sdk/CSSRule.d.ts +0 -132
  647. package/core/sdk/CSSScope.d.ts +0 -9
  648. package/core/sdk/CSSStartingStyle.d.ts +0 -9
  649. package/core/sdk/CSSStyleDeclaration.d.ts +0 -38
  650. package/core/sdk/CSSStyleSheetHeader.d.ts +0 -53
  651. package/core/sdk/CSSSupports.d.ts +0 -10
  652. package/core/sdk/CategorizedBreakpoint.d.ts +0 -42
  653. package/core/sdk/ChildTargetManager.d.ts +0 -40
  654. package/core/sdk/CompilerSourceMappingContentProvider.d.ts +0 -12
  655. package/core/sdk/Connections.d.ts +0 -36
  656. package/core/sdk/ConsoleModel.d.ts +0 -127
  657. package/core/sdk/ConsoleModelTypes.d.ts +0 -6
  658. package/core/sdk/Cookie.d.ts +0 -68
  659. package/core/sdk/CookieModel.d.ts +0 -31
  660. package/core/sdk/CookieParser.d.ts +0 -14
  661. package/core/sdk/CrashReportContextModel.d.ts +0 -8
  662. package/core/sdk/DOMDebuggerModel.d.ts +0 -127
  663. package/core/sdk/DOMModel.d.ts +0 -440
  664. package/core/sdk/DOMStorageModel.d.ts +0 -79
  665. package/core/sdk/DebuggerModel.d.ts +0 -305
  666. package/core/sdk/EmulationModel.d.ts +0 -95
  667. package/core/sdk/EnhancedTracesParser.d.ts +0 -105
  668. package/core/sdk/EventBreakpointsModel.d.ts +0 -66
  669. package/core/sdk/FrameAssociated.d.ts +0 -6
  670. package/core/sdk/FrameManager.d.ts +0 -68
  671. package/core/sdk/HeapProfilerModel.d.ts +0 -75
  672. package/core/sdk/HttpReasonPhraseStrings.d.ts +0 -5
  673. package/core/sdk/IOModel.d.ts +0 -10
  674. package/core/sdk/IsolateManager.d.ts +0 -53
  675. package/core/sdk/IssuesModel.d.ts +0 -28
  676. package/core/sdk/LayerTreeBase.d.ts +0 -70
  677. package/core/sdk/LogModel.d.ts +0 -20
  678. package/core/sdk/NetworkManager.d.ts +0 -418
  679. package/core/sdk/NetworkRequest.d.ts +0 -497
  680. package/core/sdk/NetworkRequestAccess.d.ts +0 -91
  681. package/core/sdk/OverlayColorGenerator.d.ts +0 -14
  682. package/core/sdk/OverlayModel.d.ts +0 -186
  683. package/core/sdk/OverlayPersistentHighlighter.d.ts +0 -116
  684. package/core/sdk/PageFunctions.d.ts +0 -22
  685. package/core/sdk/PageLoad.d.ts +0 -14
  686. package/core/sdk/PageResourceLoader.d.ts +0 -111
  687. package/core/sdk/PaintProfiler.d.ts +0 -43
  688. package/core/sdk/PerformanceMetricsModel.d.ts +0 -12
  689. package/core/sdk/PreloadingModel.d.ts +0 -146
  690. package/core/sdk/RehydratingConnection.d.ts +0 -73
  691. package/core/sdk/RehydratingObject.d.ts +0 -59
  692. package/core/sdk/RemoteObject.d.ts +0 -210
  693. package/core/sdk/Resource.d.ts +0 -36
  694. package/core/sdk/ResourceTreeModel.d.ts +0 -280
  695. package/core/sdk/RuntimeModel.d.ts +0 -164
  696. package/core/sdk/SDKModel.d.ts +0 -30
  697. package/core/sdk/SDKSettings.d.ts +0 -54
  698. package/core/sdk/ScopeTreeCache.d.ts +0 -21
  699. package/core/sdk/ScreenCaptureModel.d.ts +0 -69
  700. package/core/sdk/Script.d.ts +0 -134
  701. package/core/sdk/SecurityOrigin.d.ts +0 -108
  702. package/core/sdk/SecurityOriginManager.d.ts +0 -23
  703. package/core/sdk/ServerSentEvents.d.ts +0 -18
  704. package/core/sdk/ServerSentEventsProtocol.d.ts +0 -18
  705. package/core/sdk/ServerTiming.d.ts +0 -24
  706. package/core/sdk/ServiceWorkerCacheModel.d.ts +0 -71
  707. package/core/sdk/ServiceWorkerManager.d.ts +0 -125
  708. package/core/sdk/SourceMap.d.ts +0 -211
  709. package/core/sdk/SourceMapCache.d.ts +0 -12
  710. package/core/sdk/SourceMapFunctionRanges.d.ts +0 -23
  711. package/core/sdk/SourceMapManager.d.ts +0 -46
  712. package/core/sdk/SourceMapRangeMappings.d.ts +0 -15
  713. package/core/sdk/SourceMapScopeChainEntry.d.ts +0 -23
  714. package/core/sdk/SourceMapScopesInfo.d.ts +0 -184
  715. package/core/sdk/StorageBucketsModel.d.ts +0 -48
  716. package/core/sdk/StorageKeyManager.d.ts +0 -38
  717. package/core/sdk/Target.d.ts +0 -79
  718. package/core/sdk/TargetManager.d.ts +0 -92
  719. package/core/sdk/TraceObject.d.ts +0 -43
  720. package/core/sdk/WebAuthnModel.d.ts +0 -29
  721. package/core/text_utils/CodeMirrorUtils.d.ts +0 -3
  722. package/core/text_utils/ContentData.d.ts +0 -94
  723. package/core/text_utils/ContentProvider.d.ts +0 -42
  724. package/core/text_utils/Markdown.d.ts +0 -13
  725. package/core/text_utils/StaticContentProvider.d.ts +0 -13
  726. package/core/text_utils/StreamingContentData.d.ts +0 -49
  727. package/core/text_utils/Text.d.ts +0 -19
  728. package/core/text_utils/TextCursor.d.ts +0 -9
  729. package/core/text_utils/TextRange.d.ts +0 -81
  730. package/core/text_utils/TextUtils.d.ts +0 -97
  731. package/core/text_utils/WasmDisassembly.d.ts +0 -29
  732. package/core/text_utils/text_utils.d.ts +0 -12
  733. package/entrypoints/formatter_actions/formatter_actions.d.ts +0 -65
  734. package/generated/InspectorBackendCommands.d.ts +0 -14
  735. package/generated/SupportedCSSProperties.d.ts +0 -18
  736. package/generated/protocol-mapping.d.ts +0 -5985
  737. package/generated/protocol-proxy-api.d.ts +0 -5447
  738. package/index.d.ts +0 -2
  739. package/index.js +0 -6
  740. package/models/crux-manager/CrUXManager.d.ts +0 -107
  741. package/models/emulation/DeviceModeModel.d.ts +0 -157
  742. package/models/emulation/EmulatedDevices.d.ts +0 -148
  743. package/models/emulation/emulation.d.ts +0 -3
  744. package/models/formatter/FormatterWorkerPool.d.ts +0 -58
  745. package/models/formatter/ScriptFormatter.d.ts +0 -11
  746. package/models/formatter/formatter.d.ts +0 -3
  747. package/third_party/codemirror.next/codemirror.next.d.ts +0 -9196
  748. package/third_party/i18n/i18n-impl.d.ts +0 -25
  749. package/third_party/i18n/i18n.d.ts +0 -3
  750. package/third_party/i18n/localized-string-set.d.ts +0 -49
  751. package/third_party/intl-messageformat/intl-messageformat.d.ts +0 -1
  752. package/third_party/marked/package/lib/marked.esm.d.ts +0 -760
  753. package/third_party/source-map-scopes-codec/package/src/builder/builder.d.ts +0 -70
  754. package/third_party/source-map-scopes-codec/package/src/builder/safe_builder.d.ts +0 -40
  755. package/third_party/source-map-scopes-codec/package/src/codec.d.ts +0 -49
  756. package/third_party/source-map-scopes-codec/package/src/decode/decode.d.ts +0 -33
  757. package/third_party/source-map-scopes-codec/package/src/encode/encode.d.ts +0 -8
  758. package/third_party/source-map-scopes-codec/package/src/encode/encoder.d.ts +0 -9
  759. package/third_party/source-map-scopes-codec/package/src/mod.d.ts +0 -5
  760. package/third_party/source-map-scopes-codec/package/src/scopes.d.ts +0 -169
  761. package/third_party/source-map-scopes-codec/package/src/util.d.ts +0 -5
  762. package/third_party/source-map-scopes-codec/package/src/vlq.d.ts +0 -14
  763. package/third_party/source-map-scopes-codec/source-map-scopes-codec.d.ts +0 -1
  764. package/third_party/third-party-web/lib/nostats-subset.d.ts +0 -2
  765. package/third_party/third-party-web/package/lib/index.d.ts +0 -34
  766. 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,213 @@
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
+ let queuedTime = nodeTiming.queuedTime;
56
+ for (const redirect of node.request.redirects ?? []) {
57
+ const redirectTiming = timingByNodeId.get(redirect.requestId);
58
+ if (redirectTiming) {
59
+ duration += redirectTiming.duration;
60
+ startTime = Math.min(startTime, redirectTiming.startTime);
61
+ queuedTime = Math.min(queuedTime, redirectTiming.queuedTime);
62
+ }
63
+ }
64
+ const backendRequestId = node.request.rawRequest?.args.data.requestId ?? node.request.requestId;
65
+ requestIdToNode.set(backendRequestId, {
66
+ node,
67
+ nodeTiming: { startTime, endTime: nodeTiming.endTime, queuedTime, duration },
68
+ });
69
+ }
70
+ return requestIdToNode;
71
+ }
72
+ function estimateSavingsWithGraphs(deferredIds, lanternContext) {
73
+ const simulator = lanternContext.simulator;
74
+ const fcpGraph = lanternContext.metrics.firstContentfulPaint.optimisticGraph;
75
+ const { nodeTimings } = lanternContext.simulator.simulate(fcpGraph);
76
+ const adjustedNodeTimings = new Map(nodeTimings);
77
+ const totalChildNetworkBytes = 0;
78
+ const minimalFCPGraph = fcpGraph.cloneWithRelationships(node => {
79
+ // If a node can be deferred, exclude it from the new FCP graph
80
+ const canDeferRequest = deferredIds.has(node.id);
81
+ return !canDeferRequest;
82
+ });
83
+ if (minimalFCPGraph.type !== 'network') {
84
+ throw new Error('minimalFCPGraph not a NetworkNode');
85
+ }
86
+ // Recalculate the "before" time based on our adjusted node timings.
87
+ const estimateBeforeInline = Math.max(...Array.from(Array.from(adjustedNodeTimings).map(timing => timing[1].endTime)));
88
+ // Add the inlined bytes to the HTML response
89
+ const originalTransferSize = minimalFCPGraph.request.transferSize;
90
+ const safeTransferSize = originalTransferSize || 0;
91
+ minimalFCPGraph.request.transferSize = safeTransferSize + totalChildNetworkBytes;
92
+ const estimateAfterInline = simulator.simulate(minimalFCPGraph).timeInMs;
93
+ minimalFCPGraph.request.transferSize = originalTransferSize;
94
+ return Math.round(Math.max(estimateBeforeInline - estimateAfterInline, 0));
95
+ }
96
+ function hasImageLCP(data, context) {
97
+ return data.LargestImagePaint.lcpRequestByNavigationId.has(context.navigationId);
98
+ }
99
+ function computeSavings(data, context, renderBlockingRequests) {
100
+ if (!context.lantern) {
101
+ return;
102
+ }
103
+ const nodesAndTimingsByRequestId = getNodesAndTimingByRequestId(context.lantern.metrics.firstContentfulPaint.optimisticEstimate.nodeTimings);
104
+ const metricSavings = { FCP: 0, LCP: 0 };
105
+ const requestIdToWastedMs = new Map();
106
+ const deferredNodeIds = new Set();
107
+ for (const request of renderBlockingRequests) {
108
+ const nodeAndTiming = nodesAndTimingsByRequestId.get(request.args.data.requestId);
109
+ if (!nodeAndTiming) {
110
+ continue;
111
+ }
112
+ const { node, nodeTiming } = nodeAndTiming;
113
+ // Mark this node, any redirects leading to it, and all its dependents as deferrable
114
+ for (const redirect of node.request.redirects ?? []) {
115
+ deferredNodeIds.add(redirect.requestId);
116
+ }
117
+ node.traverse(node => deferredNodeIds.add(node.id));
118
+ // "wastedMs" is the download time of the network request, responseReceived - requestSent
119
+ const wastedMs = Math.round(nodeTiming.duration);
120
+ if (wastedMs < MINIMUM_WASTED_MS) {
121
+ continue;
122
+ }
123
+ requestIdToWastedMs.set(request.args.data.requestId, wastedMs);
124
+ }
125
+ if (requestIdToWastedMs.size) {
126
+ metricSavings.FCP = estimateSavingsWithGraphs(deferredNodeIds, context.lantern);
127
+ // In most cases, render-blocking resources only affect LCP if LCP isn't an image.
128
+ if (!hasImageLCP(data, context)) {
129
+ metricSavings.LCP = metricSavings.FCP;
130
+ }
131
+ }
132
+ return { metricSavings, requestIdToWastedMs };
133
+ }
134
+ function finalize(partialModel) {
135
+ return {
136
+ insightKey: InsightKeys.RENDER_BLOCKING,
137
+ strings: UIStrings,
138
+ title: i18nString(UIStrings.title),
139
+ description: i18nString(UIStrings.description),
140
+ docs: 'https://developer.chrome.com/docs/performance/insights/render-blocking',
141
+ category: InsightCategory.LCP,
142
+ state: partialModel.renderBlockingRequests.length > 0 ? 'fail' : 'pass',
143
+ ...partialModel,
144
+ };
145
+ }
146
+ export function generateInsight(data, context) {
147
+ if (!context.navigation || !('navigationId' in context)) {
148
+ return finalize({
149
+ renderBlockingRequests: [],
150
+ });
151
+ }
152
+ const firstPaintTs = data.PageLoadMetrics.metricScoresByFrameId.get(context.frameId)
153
+ ?.get(context.navigation)
154
+ ?.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.FP)
155
+ ?.event?.ts;
156
+ if (!firstPaintTs) {
157
+ return finalize({
158
+ renderBlockingRequests: [],
159
+ warnings: [InsightWarning.NO_FP],
160
+ });
161
+ }
162
+ let renderBlockingRequests = [];
163
+ for (const req of data.NetworkRequests.byTime) {
164
+ if (req.args.data.frame !== context.frameId) {
165
+ continue;
166
+ }
167
+ if (!Helpers.Network.isSyntheticNetworkRequestEventRenderBlocking(req)) {
168
+ continue;
169
+ }
170
+ if (req.args.data.syntheticData.finishTime > firstPaintTs) {
171
+ continue;
172
+ }
173
+ // If a request is marked `in_body_parser_blocking` it should only be considered render-blocking if it is a
174
+ // high enough priority. Some requests (e.g. scripts) are not marked as high priority if they are fetched
175
+ // after a non-preloaded image. (See "early" definition in https://web.dev/articles/fetch-priority)
176
+ //
177
+ // There are edge cases and exceptions (e.g. priority hints) but this gives us the best approximation
178
+ // of render-blocking resources in the document body.
179
+ if (req.args.data.renderBlocking === 'in_body_parser_blocking') {
180
+ const priority = req.args.data.priority;
181
+ const isScript = req.args.data.resourceType === "Script" /* Protocol.Network.ResourceType.Script */;
182
+ const isBlockingScript = isScript && priority === "High" /* Protocol.Network.ResourcePriority.High */;
183
+ if (priority !== "VeryHigh" /* Protocol.Network.ResourcePriority.VeryHigh */ && !isBlockingScript) {
184
+ continue;
185
+ }
186
+ }
187
+ const navigation = Helpers.Trace.getNavigationForTraceEvent(req, context.frameId, data.Meta.navigationsByFrameId);
188
+ if (navigation === context.navigation) {
189
+ renderBlockingRequests.push(req);
190
+ }
191
+ }
192
+ const savings = computeSavings(data, context, renderBlockingRequests);
193
+ // Sort by request duration for insights.
194
+ renderBlockingRequests = renderBlockingRequests.sort((a, b) => {
195
+ return b.dur - a.dur;
196
+ });
197
+ return finalize({
198
+ relatedEvents: renderBlockingRequests,
199
+ renderBlockingRequests,
200
+ ...savings,
201
+ });
202
+ }
203
+ export function createOverlayForRequest(request) {
204
+ return {
205
+ type: 'ENTRY_OUTLINE',
206
+ entry: request,
207
+ outlineReason: 'ERROR',
208
+ };
209
+ }
210
+ export function createOverlays(model) {
211
+ return model.renderBlockingRequests.map(request => createOverlayForRequest(request));
212
+ }
213
+ //# 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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AI,CAAC,oBAAoB,CAAC,CAAC;QAClH,IAAI,UAAU,KAAK,OAAO,CAAC,UAAU,EAAE,CAAC;YACtC,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC;IAEtE,yCAAyC;IACzC,sBAAsB,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC5D,OAAO,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;QACd,aAAa,EAAE,sBAAsB;QACrC,sBAAsB;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 let queuedTime = nodeTiming.queuedTime;\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 queuedTime = Math.min(queuedTime, redirectTiming.queuedTime);\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, queuedTime, 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":"SlowCSSSelector.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/SlowCSSSelector.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AAEnD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EACL,eAAe,EACf,WAAW,GAIZ,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,oBAAoB;IAE3B;;OAEG;IACH,WAAW,EACP,4UAA4U;IAChV;;OAEG;IACH,aAAa,EAAE,gBAAgB;IAC/B;;OAEG;IACH,UAAU,EAAE,aAAa;IACzB;;OAEG;IACH,OAAO,EAAE,cAAc;IACvB;;OAEG;IACH,YAAY,EAAE,eAAe;IAC7B;;OAEG;IACH,KAAK,EAAE,OAAO;IACd;;OAEG;IACH,kBAAkB,EACd,0GAA0G;IAC9G;;OAE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KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAG,wBAAwB,EAAE,CAAC;YAC7F,oBAAoB,GAAG,IAAI,CAAC;QAC9B,CAAC;QAED,6CAA6C;QAC7C,wBAAwB,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACzD,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACH,CAAC,CAAC;QACjH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;QACd,yEAAyE;QACzE,aAAa,EAAE,EAAE;QACjB,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,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,q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,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"]}