@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
@@ -0,0 +1,527 @@
1
+ // Copyright 2023 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
+ var _a;
5
+ import * as Types from '../types/types.js';
6
+ import { milliToMicro } from './Timing.js';
7
+ import { extractSampleTraceId, makeProfileCall, mergeEventsInOrder, sortTraceEventsInPlace } from './Trace.js';
8
+ /**
9
+ * This is a helper that integrates CPU profiling data coming in the
10
+ * shape of samples, with trace events. Samples indicate what the JS
11
+ * stack trace looked at a given point in time, but they don't have
12
+ * duration. The SamplesIntegrator task is to make an approximation
13
+ * of what the duration of each JS call was, given the sample data and
14
+ * given the trace events profiled during that time. At the end of its
15
+ * execution, the SamplesIntegrator returns an array of ProfileCalls
16
+ * (under SamplesIntegrator::buildProfileCalls()), which
17
+ * represent JS calls, with a call frame and duration. These calls have
18
+ * the shape of a complete trace events and can be treated as flame
19
+ * chart entries in the timeline.
20
+ *
21
+ * The approach to build the profile calls consists in tracking the
22
+ * current stack as the following events happen (in order):
23
+ * 1. A sample was done.
24
+ * 2. A trace event started.
25
+ * 3. A trace event ended.
26
+ * Depending on the event and on the data that's coming with it the
27
+ * stack is updated by adding or removing JS calls to it and updating
28
+ * the duration of the calls in the tracking stack.
29
+ *
30
+ * note: Although this approach has been implemented since long ago, and
31
+ * is relatively efficient (adds a complexity over the trace parsing of
32
+ * O(n) where n is the number of samples) it has proven to be faulty.
33
+ * It might be worthwhile experimenting with improvements or with a
34
+ * completely different approach. Improving the approach is tracked in
35
+ * crbug.com/1417439
36
+ */
37
+ export class SamplesIntegrator {
38
+ /**
39
+ * The result of running the samples integrator. Holds the JS calls
40
+ * with their approximated duration after integrating samples into the
41
+ * trace event tree.
42
+ */
43
+ #constructedProfileCalls = [];
44
+ /**
45
+ * tracks the state of the JS stack at each point in time to update
46
+ * the profile call durations as new events arrive. This doesn't only
47
+ * happen with new profile calls (in which case we would compare the
48
+ * stack in them) but also with trace events (in which case we would
49
+ * update the duration of the events we are tracking at the moment).
50
+ */
51
+ #currentJSStack = [];
52
+ /**
53
+ * Process holding the CPU profile and trace events.
54
+ */
55
+ #processId;
56
+ /**
57
+ * Thread holding the CPU profile and trace events.
58
+ */
59
+ #threadId;
60
+ /**
61
+ * Tracks the depth of the JS stack at the moment a trace event starts
62
+ * or ends. It is assumed that for the duration of a trace event, the
63
+ * JS stack's depth cannot decrease, since JS calls that started
64
+ * before a trace event cannot end during the trace event. So as trace
65
+ * events arrive, we store the "locked" amount of JS frames that were
66
+ * in the stack before the event came.
67
+ */
68
+ #lockedJsStackDepth = [];
69
+ /**
70
+ * Used to keep track when samples should be integrated even if they
71
+ * are not children of invocation trace events. This is used in two cases:
72
+ * 1. We start tracing half-way through, so we miss the start of JS
73
+ * invocation events.
74
+ * 2. On threads (like Web Workers) without real JS invocation parent events,
75
+ * but where trace events (like SchedulePostMessage) integrate stack traces.
76
+ * Enabling fake JS mode allows subsequent samples to be processed and
77
+ * eventually correct the stack, preventing a deadlock.
78
+ */
79
+ #fakeJSInvocation = false;
80
+ /**
81
+ * The parsed CPU profile, holding the tree hierarchy of JS frames and
82
+ * the sample data.
83
+ */
84
+ #profileModel;
85
+ /**
86
+ * Because GC nodes don't have a stack, we artificially add a stack to
87
+ * them which corresponds to that of the previous sample. This map
88
+ * tracks which node is used for the stack of a GC call.
89
+ * Note that GC samples are not shown in the flamechart, however they
90
+ * are used during the construction of for profile calls, as we can
91
+ * infer information about the duration of the executed code when a
92
+ * GC node is sampled.
93
+ */
94
+ #nodeForGC = new Map();
95
+ #engineConfig;
96
+ #profileId;
97
+ /**
98
+ * Keeps track of the individual samples from the CPU Profile.
99
+ * Only used with Debug Mode experiment enabled.
100
+ */
101
+ jsSampleEvents = [];
102
+ constructor(profileModel, profileId, pid, tid, configuration) {
103
+ this.#profileModel = profileModel;
104
+ this.#threadId = tid;
105
+ this.#processId = pid;
106
+ this.#engineConfig = configuration || Types.Configuration.defaults();
107
+ this.#profileId = profileId;
108
+ }
109
+ buildProfileCalls(traceEvents) {
110
+ const mergedEvents = mergeEventsInOrder(traceEvents, this.callsFromProfileSamples());
111
+ const stack = [];
112
+ for (let i = 0; i < mergedEvents.length; i++) {
113
+ const event = mergedEvents[i];
114
+ // Because instant trace events have no duration, they don't provide
115
+ // useful information for possible changes in the duration of calls
116
+ // in the JS stack.
117
+ if (event.ph === Types.Events.Phase.INSTANT && !extractSampleTraceId(event)) {
118
+ continue;
119
+ }
120
+ if (stack.length === 0) {
121
+ if (Types.Events.isProfileCall(event)) {
122
+ this.#onProfileCall(event);
123
+ continue;
124
+ }
125
+ stack.push(event);
126
+ this.#onTraceEventStart(event);
127
+ continue;
128
+ }
129
+ const parentEvent = stack.at(-1);
130
+ if (parentEvent === undefined) {
131
+ continue;
132
+ }
133
+ const begin = event.ts;
134
+ const parentBegin = parentEvent.ts;
135
+ const parentDuration = parentEvent.dur || 0;
136
+ const parentEnd = parentBegin + parentDuration;
137
+ const startsAfterParent = begin >= parentEnd;
138
+ if (startsAfterParent) {
139
+ this.#onTraceEventEnd(parentEvent);
140
+ stack.pop();
141
+ i--;
142
+ continue;
143
+ }
144
+ if (Types.Events.isProfileCall(event)) {
145
+ this.#onProfileCall(event, parentEvent);
146
+ continue;
147
+ }
148
+ this.#onTraceEventStart(event, parentEvent);
149
+ stack.push(event);
150
+ }
151
+ while (stack.length) {
152
+ const last = stack.pop();
153
+ if (last) {
154
+ this.#onTraceEventEnd(last);
155
+ }
156
+ }
157
+ sortTraceEventsInPlace(this.jsSampleEvents);
158
+ return this.#constructedProfileCalls;
159
+ }
160
+ #onTraceEventStart(event, parent) {
161
+ // Top level events cannot be nested into JS frames so we reset
162
+ // the stack when we find one.
163
+ if (event.name === Types.Events.Name.RUN_MICROTASKS || event.name === Types.Events.Name.RUN_TASK) {
164
+ this.#lockedJsStackDepth = [];
165
+ this.#truncateJSStack(0, event.ts);
166
+ this.#fakeJSInvocation = false;
167
+ }
168
+ if (this.#fakeJSInvocation) {
169
+ this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, event.ts);
170
+ this.#fakeJSInvocation = false;
171
+ }
172
+ this.#extractStackTrace(event);
173
+ if (extractSampleTraceId(event)) {
174
+ const hasJSInvocationParent = parent && Types.Events.isJSInvocationEvent(parent);
175
+ if (!hasJSInvocationParent) {
176
+ // If the event has a sampleTraceId (meaning it has a stack trace) but
177
+ // no JS invocation parent, we enter fake JS mode. This ensures that
178
+ // subsequent samples on this thread are processed, allowing the stack
179
+ // to be correctly updated/truncated. Without this, subsequent samples
180
+ // would be ignored because the stack is non-empty but we are not
181
+ // considered to be in JS.
182
+ this.#fakeJSInvocation = true;
183
+ }
184
+ }
185
+ // Keep track of the call frames in the stack before the event
186
+ // happened. For the duration of this event, these frames cannot
187
+ // change (none can be terminated before this event finishes).
188
+ //
189
+ // Also, every frame that is opened after this event, is considered
190
+ // to be a descendant of the event. So once the event finishes, the
191
+ // frames that were opened after it, need to be closed (see
192
+ // onEndEvent).
193
+ //
194
+ // TODO(crbug.com/1417439):
195
+ // The assumption that every frame opened after an event is a
196
+ // descendant of the event is incorrect. For example, a JS call that
197
+ // parents a trace event might have been sampled after the event was
198
+ // dispatched. In this case the JS call would be discarded if this
199
+ // event isn't an invocation event, otherwise the call will be
200
+ // considered a child of the event. In both cases, the result would
201
+ // be incorrect.
202
+ this.#lockedJsStackDepth.push(this.#currentJSStack.length);
203
+ }
204
+ #onProfileCall(event, parent) {
205
+ if ((parent && Types.Events.isJSInvocationEvent(parent)) || this.#fakeJSInvocation) {
206
+ this.#extractStackTrace(event);
207
+ }
208
+ else if (Types.Events.isProfileCall(event) && this.#currentJSStack.length === 0) {
209
+ // Force JS Samples to show up even if we are not inside a JS
210
+ // invocation event, because we can be missing the start of JS
211
+ // invocation events if we start tracing half-way through. Pretend
212
+ // we have a top-level JS invocation event.
213
+ this.#fakeJSInvocation = true;
214
+ const stackDepthBefore = this.#currentJSStack.length;
215
+ this.#extractStackTrace(event);
216
+ this.#lockedJsStackDepth.push(stackDepthBefore);
217
+ }
218
+ }
219
+ #onTraceEventEnd(event) {
220
+ // Because the event has ended, any frames that happened after
221
+ // this event are terminated. Frames that are ancestors to this
222
+ // event are extended to cover its ending.
223
+ const endTime = Types.Timing.Micro(event.ts + (event.dur ?? 0));
224
+ this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, endTime);
225
+ }
226
+ /**
227
+ * Builds the initial calls with no duration from samples. Their
228
+ * purpose is to be merged with the trace event array being parsed so
229
+ * that they can be traversed in order with them and their duration
230
+ * can be updated as the SampleIntegrator callbacks are invoked.
231
+ */
232
+ callsFromProfileSamples() {
233
+ const samples = this.#profileModel.samples;
234
+ const timestamps = this.#profileModel.timestamps;
235
+ if (!samples) {
236
+ return [];
237
+ }
238
+ const calls = [];
239
+ let prevNode;
240
+ for (let i = 0; i < samples.length; i++) {
241
+ const node = this.#profileModel.nodeByIndex(i);
242
+ const timestamp = milliToMicro(Types.Timing.Milli(timestamps[i]));
243
+ if (!node) {
244
+ continue;
245
+ }
246
+ const call = makeProfileCall(node, this.#profileId, i, timestamp, this.#processId, this.#threadId);
247
+ calls.push(call);
248
+ if (this.#engineConfig.debugMode) {
249
+ const traceId = this.#profileModel.traceIds?.[i];
250
+ this.jsSampleEvents.push(this.#makeJSSampleEvent(call, timestamp, traceId));
251
+ }
252
+ if (node.id === this.#profileModel.gcNode?.id && prevNode) {
253
+ // GC samples have no stack, so we just put GC node on top of the
254
+ // last recorded sample. Cache the previous sample for future
255
+ // reference.
256
+ this.#nodeForGC.set(call, prevNode);
257
+ continue;
258
+ }
259
+ prevNode = node;
260
+ }
261
+ return calls;
262
+ }
263
+ /**
264
+ * Given a synthetic profile call, returns the profile nodes of the
265
+ * stack trace that profile call belongs to based on its nodeId,
266
+ * ordered from the bottom of the stack to the top. The root node is
267
+ * omitted. The node of the input profile call will be at the top of
268
+ * the returned stack (last position), meaning that any other frames
269
+ * that were effectively above it are omitted.
270
+ */
271
+ #stackNodesForProfileCall(profileCall) {
272
+ const sampledNode = this.#profileModel.nodeById(profileCall.nodeId);
273
+ let node = sampledNode;
274
+ const isGarbageCollection = node?.id === this.#profileModel.gcNode?.id;
275
+ if (isGarbageCollection) {
276
+ // Because GC don't have a stack, we use the stack of the previous
277
+ // sample.
278
+ node = this.#nodeForGC.get(profileCall) || null;
279
+ }
280
+ if (!sampledNode || !node) {
281
+ return [];
282
+ }
283
+ // `node.depth` is 0 based, so to set the size of the array we need
284
+ // to add 1 to its value.
285
+ const nodes = new Array(node.depth + 1 + Number(isGarbageCollection));
286
+ // Add the stack trace in reverse order (bottom first).
287
+ let i = nodes.length - 1;
288
+ if (isGarbageCollection) {
289
+ // Place the garbage collection node on top of the stack.
290
+ nodes[i--] = sampledNode;
291
+ }
292
+ // The root node has a depth of -1, so the loop stops before it.
293
+ while (node && i >= 0) {
294
+ nodes[i--] = node;
295
+ node = node.parent;
296
+ }
297
+ return nodes;
298
+ }
299
+ /**
300
+ * Returns a profile call for the node sampled with the given trace id,
301
+ * or null if the profile has no node for it.
302
+ */
303
+ #callForSampleTraceId(traceId, timestamp) {
304
+ const nodeId = this.#profileModel.traceIds?.[traceId];
305
+ const node = nodeId && this.#profileModel.nodeById(nodeId);
306
+ if (!node) {
307
+ return null;
308
+ }
309
+ const callForTraceId = makeProfileCall(node, this.#profileId, -1, timestamp, this.#processId, this.#threadId);
310
+ if (this.#engineConfig.debugMode) {
311
+ this.jsSampleEvents.push(this.#makeJSSampleEvent(callForTraceId, timestamp, traceId));
312
+ }
313
+ return callForTraceId;
314
+ }
315
+ /**
316
+ * Update tracked stack using this event's call stack.
317
+ */
318
+ #extractStackTrace(event) {
319
+ const traceId = extractSampleTraceId(event);
320
+ const callForTraceId = traceId ? this.#callForSampleTraceId(traceId, event.ts) : null;
321
+ const stackSource = callForTraceId ?? (Types.Events.isProfileCall(event) ? event : null);
322
+ if (!stackSource) {
323
+ // The event carries no stack of its own, so merging the tracked
324
+ // stack with itself only updates the durations of its frames.
325
+ this.#mergeWithCurrentStack(event, this.#currentJSStack);
326
+ return;
327
+ }
328
+ const stackNodes = this.#stackNodesForProfileCall(stackSource);
329
+ let i = this.#mergeWithCurrentStack(event, stackNodes);
330
+ for (; i < stackNodes.length; ++i) {
331
+ const node = stackNodes[i];
332
+ if (node.id === this.#profileModel.programNode?.id || node.id === this.#profileModel.root?.id ||
333
+ node.id === this.#profileModel.idleNode?.id || node.id === this.#profileModel.gcNode?.id) {
334
+ // Skip (root), (program) and (idle) frames, since this are not
335
+ // relevant for web profiling and we don't want to show them in
336
+ // the timeline.
337
+ continue;
338
+ }
339
+ // Profile calls are only created for the frames that are added to
340
+ // the tracked stack, rather than for every frame of every sample.
341
+ const call = makeProfileCall(node, stackSource.profileId, stackSource.sampleIndex, stackSource.ts, this.#processId, this.#threadId);
342
+ this.#currentJSStack.push(call);
343
+ this.#constructedProfileCalls.push(call);
344
+ }
345
+ }
346
+ /**
347
+ * Merges the given stack with the tracked stack: the durations of
348
+ * the shared frames are extended to cover the event, and the tracked
349
+ * stack is truncated where the two stacks differ.
350
+ * @returns the index of the first frame in the given stack that is
351
+ * not shared with the tracked stack.
352
+ */
353
+ #mergeWithCurrentStack(event, stackTrace) {
354
+ _a.filterStackFrames(stackTrace, this.#engineConfig);
355
+ const endTime = event.ts + (event.dur || 0);
356
+ const minFrames = Math.min(stackTrace.length, this.#currentJSStack.length);
357
+ let i;
358
+ // Merge a sample's stack frames with the stack frames we have
359
+ // so far if we detect they are equivalent.
360
+ // Graphically
361
+ // This:
362
+ // Current stack trace Sample
363
+ // [-------A------] [A]
364
+ // [-------B------] [B]
365
+ // [-------C------] [C]
366
+ // ^ t = x1 ^ t = x2
367
+ // Becomes this:
368
+ // New stack trace after merge
369
+ // [--------A-------]
370
+ // [--------B-------]
371
+ // [--------C-------]
372
+ // ^ t = x2
373
+ for (i = this.#lockedJsStackDepth.at(-1) || 0; i < minFrames; ++i) {
374
+ const newFrame = stackTrace[i].callFrame;
375
+ const oldFrame = this.#currentJSStack[i].callFrame;
376
+ if (!_a.framesAreEqual(newFrame, oldFrame)) {
377
+ break;
378
+ }
379
+ // Scoot the right edge of this callFrame to the right
380
+ this.#currentJSStack[i].dur =
381
+ Types.Timing.Micro(Math.max(this.#currentJSStack[i].dur || 0, endTime - this.#currentJSStack[i].ts));
382
+ }
383
+ // If there are call frames in the sample that differ with the stack
384
+ // we have, update the stack, but keeping the common frames in place
385
+ // Graphically
386
+ // This:
387
+ // Current stack trace Sample
388
+ // [-------A------] [A]
389
+ // [-------B------] [B]
390
+ // [-------C------] [C]
391
+ // [-------D------] [E]
392
+ // ^ t = x1 ^ t = x2
393
+ // Becomes this:
394
+ // New stack trace after merge
395
+ // [--------A-------]
396
+ // [--------B-------]
397
+ // [--------C-------]
398
+ // [E]
399
+ // ^ t = x2
400
+ // This method only truncates the tracked stack; the caller pushes
401
+ // the differing frames (E in the diagram above).
402
+ this.#truncateJSStack(i, event.ts);
403
+ return i;
404
+ }
405
+ /**
406
+ * When a call stack that differs from the one we are tracking has
407
+ * been detected in the samples, the latter is "truncated" by
408
+ * setting the ending time of its call frames and removing the top
409
+ * call frames that aren't shared with the new call stack. This way,
410
+ * we can update the tracked stack with the new call frames on top.
411
+ * @param depth the amount of call frames from bottom to top that
412
+ * should be kept in the tracking stack trace. AKA amount of shared
413
+ * call frames between two stacks.
414
+ * @param time the new end of the call frames in the stack.
415
+ */
416
+ #truncateJSStack(depth, time) {
417
+ if (this.#lockedJsStackDepth.length) {
418
+ const lockedDepth = this.#lockedJsStackDepth.at(-1);
419
+ if (lockedDepth && depth < lockedDepth) {
420
+ console.error(`Child stack is shallower (${depth}) than the parent stack (${lockedDepth}) at ${time}`);
421
+ depth = lockedDepth;
422
+ }
423
+ }
424
+ if (this.#currentJSStack.length < depth) {
425
+ console.error(`Trying to truncate higher than the current stack size at ${time}`);
426
+ depth = this.#currentJSStack.length;
427
+ }
428
+ for (let k = 0; k < this.#currentJSStack.length; ++k) {
429
+ this.#currentJSStack[k].dur = Types.Timing.Micro(Math.max(time - this.#currentJSStack[k].ts, 0));
430
+ }
431
+ this.#currentJSStack.length = depth;
432
+ }
433
+ #makeJSSampleEvent(call, timestamp, traceId) {
434
+ const JSSampleEvent = {
435
+ name: Types.Events.Name.JS_SAMPLE,
436
+ cat: 'devtools.timeline',
437
+ args: {
438
+ data: { traceId, stackTrace: this.#stackNodesForProfileCall(call).map(node => node.callFrame) },
439
+ },
440
+ ph: Types.Events.Phase.INSTANT,
441
+ ts: timestamp,
442
+ dur: Types.Timing.Micro(0),
443
+ pid: this.#processId,
444
+ tid: this.#threadId,
445
+ };
446
+ return JSSampleEvent;
447
+ }
448
+ static framesAreEqual(frame1, frame2) {
449
+ return frame1.scriptId === frame2.scriptId && frame1.functionName === frame2.functionName &&
450
+ frame1.lineNumber === frame2.lineNumber;
451
+ }
452
+ static showNativeName(name, runtimeCallStatsEnabled) {
453
+ return runtimeCallStatsEnabled && Boolean(_a.nativeGroup(name));
454
+ }
455
+ static nativeGroup(nativeName) {
456
+ if (nativeName.startsWith('Parse')) {
457
+ return _a.NativeGroups.PARSE;
458
+ }
459
+ if (nativeName.startsWith('Compile') || nativeName.startsWith('Recompile')) {
460
+ return _a.NativeGroups.COMPILE;
461
+ }
462
+ return null;
463
+ }
464
+ static isNativeRuntimeFrame(frame) {
465
+ return frame.url === 'native V8Runtime';
466
+ }
467
+ static filterStackFrames(stack, engineConfig) {
468
+ const showAllEvents = engineConfig.showAllEvents;
469
+ if (showAllEvents) {
470
+ return;
471
+ }
472
+ let j = 0;
473
+ for (let i = 0; i < stack.length; ++i) {
474
+ const frame = stack[i].callFrame;
475
+ const nativeRuntimeFrame = _a.isNativeRuntimeFrame(frame);
476
+ if (nativeRuntimeFrame) {
477
+ continue;
478
+ }
479
+ stack[j++] = stack[i];
480
+ }
481
+ stack.length = j;
482
+ }
483
+ static createFakeTraceFromCpuProfile(profile, tid) {
484
+ if (!profile) {
485
+ return { traceEvents: [], metadata: {} };
486
+ }
487
+ // The |Name.CPU_PROFILE| will let MetaHandler to set |traceIsGeneric| to false
488
+ // The start time and duration is important here because we'll use them to determine the traceBounds
489
+ // We use the start and end time of the profile (which is longer than all samples), so the Performance
490
+ // panel won't truncate this time period.
491
+ const cpuProfileEvent = {
492
+ cat: 'disabled-by-default-devtools.timeline',
493
+ name: Types.Events.Name.CPU_PROFILE,
494
+ ph: Types.Events.Phase.COMPLETE,
495
+ pid: Types.Events.ProcessID(1),
496
+ tid,
497
+ ts: Types.Timing.Micro(profile.startTime),
498
+ dur: Types.Timing.Micro(profile.endTime - profile.startTime),
499
+ args: { data: { cpuProfile: profile } },
500
+ // Create an arbitrary profile id.
501
+ id: '0x1',
502
+ };
503
+ return {
504
+ traceEvents: [cpuProfileEvent],
505
+ metadata: {
506
+ dataOrigin: Types.File.DataOrigin.CPU_PROFILE,
507
+ },
508
+ };
509
+ }
510
+ static extractCpuProfileFromFakeTrace(traceEvents) {
511
+ const profileEvent = traceEvents.find(e => Types.Events.isSyntheticCpuProfile(e));
512
+ const profile = profileEvent?.args.data.cpuProfile;
513
+ if (!profile) {
514
+ throw new Error('Missing cpuProfile data');
515
+ }
516
+ return profile;
517
+ }
518
+ }
519
+ _a = SamplesIntegrator;
520
+ (function (SamplesIntegrator) {
521
+ let NativeGroups;
522
+ (function (NativeGroups) {
523
+ NativeGroups["COMPILE"] = "Compile";
524
+ NativeGroups["PARSE"] = "Parse";
525
+ })(NativeGroups = SamplesIntegrator.NativeGroups || (SamplesIntegrator.NativeGroups = {}));
526
+ })(SamplesIntegrator || (SamplesIntegrator = {}));
527
+ //# sourceMappingURL=SamplesIntegrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SamplesIntegrator.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/SamplesIntegrator.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;;AAI7B,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EAAC,oBAAoB,EAAE,eAAe,EAAE,kBAAkB,EAAE,sBAAsB,EAAC,MAAM,YAAY,CAAC;AAE7G;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;;;OAIG;IACH,wBAAwB,GAAwC,EAAE,CAAC;IACnE;;;;;;OAMG;IACH,eAAe,GAAwC,EAAE,CAAC;IAC1D;;OAEG;IACH,UAAU,CAAyB;IACnC;;OAEG;IACH,SAAS,CAAwB;IACjC;;;;;;;OAOG;IACH,mBAAmB,GAAa,EAAE,CAAC;IACnC;;;;;;;;;OASG;IACH,iBAAiB,GAAG,KAAK,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAqD;IAClE;;;;;;;;OAQG;IACH,UAAU,GAAG,IAAI,GAAG,EAA8E,CAAC;IAEnG,aAAa,CAAoC;IACjD,UAAU,CAAyB;IAEnC;;;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,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;YAC5D,IAAI,EAAE,EAAC,IAAI,EAAE,EAAC,UAAU,EAAE,OAAO,EAAC,EAAC;YACnC,kCAAkC;YAClC,EAAE,EAAE,KAA+B;SACpC,CAAC;QAEF,OAAO;YACL,WAAW,EAAE,CAAC,eAAe,CAAC;YAC9B,QAAQ,EAAE;gBACR,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW;aAC9C;SACF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,8BAA8B,CAAC,WAA0C;QAC9E,MAAM,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;QAClF,MAAM,OAAO,GAAG,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;QACnD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;;AAED,WAAiB,iBAAiB;IAChC,IAAY,YAGX;IAHD,WAAY,YAAY;QACtB,mCAAmB,CAAA;QACnB,+BAAe,CAAA;IACjB,CAAC,EAHW,YAAY,GAAZ,kBAAA,YAAY,KAAZ,kBAAA,YAAY,QAGvB;AACH,CAAC,EALgB,iBAAiB,KAAjB,iBAAiB,QAKjC","sourcesContent":["// Copyright 2023 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as CPUProfile from '../../cpu_profile/cpu_profile.js';\nimport * as Types from '../types/types.js';\n\nimport {milliToMicro} from './Timing.js';\nimport {extractSampleTraceId, makeProfileCall, mergeEventsInOrder, sortTraceEventsInPlace} from './Trace.js';\n\n/**\n * This is a helper that integrates CPU profiling data coming in the\n * shape of samples, with trace events. Samples indicate what the JS\n * stack trace looked at a given point in time, but they don't have\n * duration. The SamplesIntegrator task is to make an approximation\n * of what the duration of each JS call was, given the sample data and\n * given the trace events profiled during that time. At the end of its\n * execution, the SamplesIntegrator returns an array of ProfileCalls\n * (under SamplesIntegrator::buildProfileCalls()), which\n * represent JS calls, with a call frame and duration. These calls have\n * the shape of a complete trace events and can be treated as flame\n * chart entries in the timeline.\n *\n * The approach to build the profile calls consists in tracking the\n * current stack as the following events happen (in order):\n * 1. A sample was done.\n * 2. A trace event started.\n * 3. A trace event ended.\n * Depending on the event and on the data that's coming with it the\n * stack is updated by adding or removing JS calls to it and updating\n * the duration of the calls in the tracking stack.\n *\n * note: Although this approach has been implemented since long ago, and\n * is relatively efficient (adds a complexity over the trace parsing of\n * O(n) where n is the number of samples) it has proven to be faulty.\n * It might be worthwhile experimenting with improvements or with a\n * completely different approach. Improving the approach is tracked in\n * crbug.com/1417439\n */\nexport class SamplesIntegrator {\n /**\n * The result of running the samples integrator. Holds the JS calls\n * with their approximated duration after integrating samples into the\n * trace event tree.\n */\n #constructedProfileCalls: Types.Events.SyntheticProfileCall[] = [];\n /**\n * tracks the state of the JS stack at each point in time to update\n * the profile call durations as new events arrive. This doesn't only\n * happen with new profile calls (in which case we would compare the\n * stack in them) but also with trace events (in which case we would\n * update the duration of the events we are tracking at the moment).\n */\n #currentJSStack: Types.Events.SyntheticProfileCall[] = [];\n /**\n * Process holding the CPU profile and trace events.\n */\n #processId: Types.Events.ProcessID;\n /**\n * Thread holding the CPU profile and trace events.\n */\n #threadId: Types.Events.ThreadID;\n /**\n * Tracks the depth of the JS stack at the moment a trace event starts\n * or ends. It is assumed that for the duration of a trace event, the\n * JS stack's depth cannot decrease, since JS calls that started\n * before a trace event cannot end during the trace event. So as trace\n * events arrive, we store the \"locked\" amount of JS frames that were\n * in the stack before the event came.\n */\n #lockedJsStackDepth: number[] = [];\n /**\n * Used to keep track when samples should be integrated even if they\n * are not children of invocation trace events. This is used in two cases:\n * 1. We start tracing half-way through, so we miss the start of JS\n * invocation events.\n * 2. On threads (like Web Workers) without real JS invocation parent events,\n * but where trace events (like SchedulePostMessage) integrate stack traces.\n * Enabling fake JS mode allows subsequent samples to be processed and\n * eventually correct the stack, preventing a deadlock.\n */\n #fakeJSInvocation = false;\n /**\n * The parsed CPU profile, holding the tree hierarchy of JS frames and\n * the sample data.\n */\n #profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel;\n /**\n * Because GC nodes don't have a stack, we artificially add a stack to\n * them which corresponds to that of the previous sample. This map\n * tracks which node is used for the stack of a GC call.\n * Note that GC samples are not shown in the flamechart, however they\n * are used during the construction of for profile calls, as we can\n * infer information about the duration of the executed code when a\n * GC node is sampled.\n */\n #nodeForGC = new Map<Types.Events.SyntheticProfileCall, CPUProfile.ProfileTreeModel.ProfileNode>();\n\n #engineConfig: Types.Configuration.Configuration;\n #profileId: Types.Events.ProfileID;\n\n /**\n * Keeps track of the individual samples from the CPU Profile.\n * Only used with Debug Mode experiment enabled.\n */\n jsSampleEvents: Types.Events.SyntheticJSSample[] = [];\n\n constructor(\n profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel, profileId: Types.Events.ProfileID,\n pid: Types.Events.ProcessID, tid: Types.Events.ThreadID, configuration?: Types.Configuration.Configuration) {\n this.#profileModel = profileModel;\n this.#threadId = tid;\n this.#processId = pid;\n this.#engineConfig = configuration || Types.Configuration.defaults();\n this.#profileId = profileId;\n }\n\n buildProfileCalls(traceEvents: Types.Events.Event[]): Types.Events.SyntheticProfileCall[] {\n const mergedEvents = mergeEventsInOrder(traceEvents, this.callsFromProfileSamples());\n const stack = [];\n for (let i = 0; i < mergedEvents.length; i++) {\n const event = mergedEvents[i];\n // Because instant trace events have no duration, they don't provide\n // useful information for possible changes in the duration of calls\n // in the JS stack.\n if (event.ph === Types.Events.Phase.INSTANT && !extractSampleTraceId(event)) {\n continue;\n }\n if (stack.length === 0) {\n if (Types.Events.isProfileCall(event)) {\n this.#onProfileCall(event);\n continue;\n }\n stack.push(event);\n this.#onTraceEventStart(event);\n continue;\n }\n\n const parentEvent = stack.at(-1);\n if (parentEvent === undefined) {\n continue;\n }\n const begin = event.ts;\n const parentBegin = parentEvent.ts;\n const parentDuration = parentEvent.dur || 0;\n const parentEnd = parentBegin + parentDuration;\n\n const startsAfterParent = begin >= parentEnd;\n if (startsAfterParent) {\n this.#onTraceEventEnd(parentEvent);\n stack.pop();\n i--;\n continue;\n }\n if (Types.Events.isProfileCall(event)) {\n this.#onProfileCall(event, parentEvent);\n continue;\n }\n this.#onTraceEventStart(event, parentEvent);\n stack.push(event);\n }\n while (stack.length) {\n const last = stack.pop();\n if (last) {\n this.#onTraceEventEnd(last);\n }\n }\n sortTraceEventsInPlace(this.jsSampleEvents);\n return this.#constructedProfileCalls;\n }\n\n #onTraceEventStart(event: Types.Events.Event, parent?: Types.Events.Event): void {\n // Top level events cannot be nested into JS frames so we reset\n // the stack when we find one.\n if (event.name === Types.Events.Name.RUN_MICROTASKS || event.name === Types.Events.Name.RUN_TASK) {\n this.#lockedJsStackDepth = [];\n this.#truncateJSStack(0, event.ts);\n this.#fakeJSInvocation = false;\n }\n\n if (this.#fakeJSInvocation) {\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, event.ts);\n this.#fakeJSInvocation = false;\n }\n this.#extractStackTrace(event);\n if (extractSampleTraceId(event)) {\n const hasJSInvocationParent = parent && Types.Events.isJSInvocationEvent(parent);\n if (!hasJSInvocationParent) {\n // If the event has a sampleTraceId (meaning it has a stack trace) but\n // no JS invocation parent, we enter fake JS mode. This ensures that\n // subsequent samples on this thread are processed, allowing the stack\n // to be correctly updated/truncated. Without this, subsequent samples\n // would be ignored because the stack is non-empty but we are not\n // considered to be in JS.\n this.#fakeJSInvocation = true;\n }\n }\n // Keep track of the call frames in the stack before the event\n // happened. For the duration of this event, these frames cannot\n // change (none can be terminated before this event finishes).\n //\n // Also, every frame that is opened after this event, is considered\n // to be a descendant of the event. So once the event finishes, the\n // frames that were opened after it, need to be closed (see\n // onEndEvent).\n //\n // TODO(crbug.com/1417439):\n // The assumption that every frame opened after an event is a\n // descendant of the event is incorrect. For example, a JS call that\n // parents a trace event might have been sampled after the event was\n // dispatched. In this case the JS call would be discarded if this\n // event isn't an invocation event, otherwise the call will be\n // considered a child of the event. In both cases, the result would\n // be incorrect.\n this.#lockedJsStackDepth.push(this.#currentJSStack.length);\n }\n\n #onProfileCall(event: Types.Events.SyntheticProfileCall, parent?: Types.Events.Event): void {\n if ((parent && Types.Events.isJSInvocationEvent(parent)) || this.#fakeJSInvocation) {\n this.#extractStackTrace(event);\n } else if (Types.Events.isProfileCall(event) && this.#currentJSStack.length === 0) {\n // Force JS Samples to show up even if we are not inside a JS\n // invocation event, because we can be missing the start of JS\n // invocation events if we start tracing half-way through. Pretend\n // we have a top-level JS invocation event.\n this.#fakeJSInvocation = true;\n const stackDepthBefore = this.#currentJSStack.length;\n this.#extractStackTrace(event);\n this.#lockedJsStackDepth.push(stackDepthBefore);\n }\n }\n\n #onTraceEventEnd(event: Types.Events.Event): void {\n // Because the event has ended, any frames that happened after\n // this event are terminated. Frames that are ancestors to this\n // event are extended to cover its ending.\n const endTime = Types.Timing.Micro(event.ts + (event.dur ?? 0));\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, endTime);\n }\n\n /**\n * Builds the initial calls with no duration from samples. Their\n * purpose is to be merged with the trace event array being parsed so\n * that they can be traversed in order with them and their duration\n * can be updated as the SampleIntegrator callbacks are invoked.\n */\n callsFromProfileSamples(): Types.Events.SyntheticProfileCall[] {\n const samples = this.#profileModel.samples;\n const timestamps = this.#profileModel.timestamps;\n if (!samples) {\n return [];\n }\n const calls: Types.Events.SyntheticProfileCall[] = [];\n let prevNode;\n for (let i = 0; i < samples.length; i++) {\n const node = this.#profileModel.nodeByIndex(i);\n const timestamp = milliToMicro(Types.Timing.Milli(timestamps[i]));\n if (!node) {\n continue;\n }\n const call = makeProfileCall(node, this.#profileId, i, timestamp, this.#processId, this.#threadId);\n calls.push(call);\n\n if (this.#engineConfig.debugMode) {\n const traceId = this.#profileModel.traceIds?.[i];\n this.jsSampleEvents.push(this.#makeJSSampleEvent(call, timestamp, traceId));\n }\n if (node.id === this.#profileModel.gcNode?.id && prevNode) {\n // GC samples have no stack, so we just put GC node on top of the\n // last recorded sample. Cache the previous sample for future\n // reference.\n this.#nodeForGC.set(call, prevNode);\n continue;\n }\n prevNode = node;\n }\n return calls;\n }\n\n /**\n * Given a synthetic profile call, returns the profile nodes of the\n * stack trace that profile call belongs to based on its nodeId,\n * ordered from the bottom of the stack to the top. The root node is\n * omitted. The node of the input profile call will be at the top of\n * the returned stack (last position), meaning that any other frames\n * that were effectively above it are omitted.\n */\n #stackNodesForProfileCall(profileCall: Types.Events.SyntheticProfileCall): CPUProfile.ProfileTreeModel.ProfileNode[] {\n const sampledNode = this.#profileModel.nodeById(profileCall.nodeId);\n let node = sampledNode;\n const isGarbageCollection = node?.id === this.#profileModel.gcNode?.id;\n if (isGarbageCollection) {\n // Because GC don't have a stack, we use the stack of the previous\n // sample.\n node = this.#nodeForGC.get(profileCall) || null;\n }\n if (!sampledNode || !node) {\n return [];\n }\n // `node.depth` is 0 based, so to set the size of the array we need\n // to add 1 to its value.\n const nodes = new Array<CPUProfile.ProfileTreeModel.ProfileNode>(node.depth + 1 + Number(isGarbageCollection));\n // Add the stack trace in reverse order (bottom first).\n let i = nodes.length - 1;\n if (isGarbageCollection) {\n // Place the garbage collection node on top of the stack.\n nodes[i--] = sampledNode;\n }\n // The root node has a depth of -1, so the loop stops before it.\n while (node && i >= 0) {\n nodes[i--] = node;\n node = node.parent;\n }\n return nodes;\n }\n\n /**\n * Returns a profile call for the node sampled with the given trace id,\n * or null if the profile has no node for it.\n */\n #callForSampleTraceId(traceId: number, timestamp: Types.Timing.Micro): Types.Events.SyntheticProfileCall|null {\n const nodeId = this.#profileModel.traceIds?.[traceId];\n const node = nodeId && this.#profileModel.nodeById(nodeId);\n if (!node) {\n return null;\n }\n const callForTraceId = makeProfileCall(node, this.#profileId, -1, timestamp, this.#processId, this.#threadId);\n if (this.#engineConfig.debugMode) {\n this.jsSampleEvents.push(this.#makeJSSampleEvent(callForTraceId, timestamp, traceId));\n }\n return callForTraceId;\n }\n\n /**\n * Update tracked stack using this event's call stack.\n */\n #extractStackTrace(event: Types.Events.Event): void {\n const traceId = extractSampleTraceId(event);\n const callForTraceId = traceId ? this.#callForSampleTraceId(traceId, event.ts) : null;\n const stackSource = callForTraceId ?? (Types.Events.isProfileCall(event) ? event : null);\n if (!stackSource) {\n // The event carries no stack of its own, so merging the tracked\n // stack with itself only updates the durations of its frames.\n this.#mergeWithCurrentStack(event, this.#currentJSStack);\n return;\n }\n\n const stackNodes = this.#stackNodesForProfileCall(stackSource);\n let i = this.#mergeWithCurrentStack(event, stackNodes);\n for (; i < stackNodes.length; ++i) {\n const node = stackNodes[i];\n if (node.id === this.#profileModel.programNode?.id || node.id === this.#profileModel.root?.id ||\n node.id === this.#profileModel.idleNode?.id || node.id === this.#profileModel.gcNode?.id) {\n // Skip (root), (program) and (idle) frames, since this are not\n // relevant for web profiling and we don't want to show them in\n // the timeline.\n continue;\n }\n // Profile calls are only created for the frames that are added to\n // the tracked stack, rather than for every frame of every sample.\n const call = makeProfileCall(node, stackSource.profileId, stackSource.sampleIndex, stackSource.ts,\n this.#processId, this.#threadId);\n this.#currentJSStack.push(call);\n this.#constructedProfileCalls.push(call);\n }\n }\n\n /**\n * Merges the given stack with the tracked stack: the durations of\n * the shared frames are extended to cover the event, and the tracked\n * stack is truncated where the two stacks differ.\n * @returns the index of the first frame in the given stack that is\n * not shared with the tracked stack.\n */\n #mergeWithCurrentStack<T extends {callFrame: Protocol.Runtime.CallFrame}>(event: Types.Events.Event,\n stackTrace: T[]): number {\n SamplesIntegrator.filterStackFrames(stackTrace, this.#engineConfig);\n\n const endTime = event.ts + (event.dur || 0);\n const minFrames = Math.min(stackTrace.length, this.#currentJSStack.length);\n let i;\n // Merge a sample's stack frames with the stack frames we have\n // so far if we detect they are equivalent.\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // ^ t = x1 ^ t = x2\n\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // ^ t = x2\n for (i = this.#lockedJsStackDepth.at(-1) || 0; i < minFrames; ++i) {\n const newFrame = stackTrace[i].callFrame;\n const oldFrame = this.#currentJSStack[i].callFrame;\n if (!SamplesIntegrator.framesAreEqual(newFrame, oldFrame)) {\n break;\n }\n // Scoot the right edge of this callFrame to the right\n this.#currentJSStack[i].dur =\n Types.Timing.Micro(Math.max(this.#currentJSStack[i].dur || 0, endTime - this.#currentJSStack[i].ts));\n }\n\n // If there are call frames in the sample that differ with the stack\n // we have, update the stack, but keeping the common frames in place\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // [-------D------] [E]\n // ^ t = x1 ^ t = x2\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // [E]\n // ^ t = x2\n // This method only truncates the tracked stack; the caller pushes\n // the differing frames (E in the diagram above).\n this.#truncateJSStack(i, event.ts);\n return i;\n }\n\n /**\n * When a call stack that differs from the one we are tracking has\n * been detected in the samples, the latter is \"truncated\" by\n * setting the ending time of its call frames and removing the top\n * call frames that aren't shared with the new call stack. This way,\n * we can update the tracked stack with the new call frames on top.\n * @param depth the amount of call frames from bottom to top that\n * should be kept in the tracking stack trace. AKA amount of shared\n * call frames between two stacks.\n * @param time the new end of the call frames in the stack.\n */\n #truncateJSStack(depth: number, time: Types.Timing.Micro): void {\n if (this.#lockedJsStackDepth.length) {\n const lockedDepth = this.#lockedJsStackDepth.at(-1);\n if (lockedDepth && depth < lockedDepth) {\n console.error(`Child stack is shallower (${depth}) than the parent stack (${lockedDepth}) at ${time}`);\n depth = lockedDepth;\n }\n }\n if (this.#currentJSStack.length < depth) {\n console.error(`Trying to truncate higher than the current stack size at ${time}`);\n depth = this.#currentJSStack.length;\n }\n for (let k = 0; k < this.#currentJSStack.length; ++k) {\n this.#currentJSStack[k].dur = Types.Timing.Micro(Math.max(time - this.#currentJSStack[k].ts, 0));\n }\n this.#currentJSStack.length = depth;\n }\n\n #makeJSSampleEvent(call: Types.Events.SyntheticProfileCall, timestamp: Types.Timing.Micro, traceId?: number):\n Types.Events.SyntheticJSSample {\n const JSSampleEvent: Types.Events.SyntheticJSSample = {\n name: Types.Events.Name.JS_SAMPLE,\n cat: 'devtools.timeline',\n args: {\n data: {traceId, stackTrace: this.#stackNodesForProfileCall(call).map(node => node.callFrame)},\n },\n ph: Types.Events.Phase.INSTANT,\n ts: timestamp,\n dur: Types.Timing.Micro(0),\n pid: this.#processId,\n tid: this.#threadId,\n };\n return JSSampleEvent;\n }\n\n static framesAreEqual(frame1: Protocol.Runtime.CallFrame, frame2: Protocol.Runtime.CallFrame): boolean {\n return frame1.scriptId === frame2.scriptId && frame1.functionName === frame2.functionName &&\n frame1.lineNumber === frame2.lineNumber;\n }\n\n static showNativeName(name: string, runtimeCallStatsEnabled: boolean): boolean {\n return runtimeCallStatsEnabled && Boolean(SamplesIntegrator.nativeGroup(name));\n }\n\n static nativeGroup(nativeName: string): SamplesIntegrator.NativeGroups|null {\n if (nativeName.startsWith('Parse')) {\n return SamplesIntegrator.NativeGroups.PARSE;\n }\n if (nativeName.startsWith('Compile') || nativeName.startsWith('Recompile')) {\n return SamplesIntegrator.NativeGroups.COMPILE;\n }\n return null;\n }\n\n static isNativeRuntimeFrame(frame: Protocol.Runtime.CallFrame): boolean {\n return frame.url === 'native V8Runtime';\n }\n\n static filterStackFrames<T extends {callFrame: Protocol.Runtime.CallFrame}>(\n stack: T[], engineConfig: Types.Configuration.Configuration): void {\n const showAllEvents = engineConfig.showAllEvents;\n if (showAllEvents) {\n return;\n }\n let j = 0;\n for (let i = 0; i < stack.length; ++i) {\n const frame = stack[i].callFrame;\n const nativeRuntimeFrame = SamplesIntegrator.isNativeRuntimeFrame(frame);\n if (nativeRuntimeFrame) {\n continue;\n }\n stack[j++] = stack[i];\n }\n stack.length = j;\n }\n\n static createFakeTraceFromCpuProfile(profile: Protocol.Profiler.Profile, tid: Types.Events.ThreadID):\n Types.File.TraceFile {\n if (!profile) {\n return {traceEvents: [], metadata: {}};\n }\n // The |Name.CPU_PROFILE| will let MetaHandler to set |traceIsGeneric| to false\n // The start time and duration is important here because we'll use them to determine the traceBounds\n // We use the start and end time of the profile (which is longer than all samples), so the Performance\n // panel won't truncate this time period.\n const cpuProfileEvent: Types.Events.SyntheticCpuProfile = {\n cat: 'disabled-by-default-devtools.timeline',\n name: Types.Events.Name.CPU_PROFILE,\n ph: Types.Events.Phase.COMPLETE,\n pid: Types.Events.ProcessID(1),\n tid,\n ts: Types.Timing.Micro(profile.startTime),\n dur: Types.Timing.Micro(profile.endTime - profile.startTime),\n args: {data: {cpuProfile: profile}},\n // Create an arbitrary profile id.\n id: '0x1' as Types.Events.ProfileID,\n };\n\n return {\n traceEvents: [cpuProfileEvent],\n metadata: {\n dataOrigin: Types.File.DataOrigin.CPU_PROFILE,\n },\n };\n }\n\n static extractCpuProfileFromFakeTrace(traceEvents: readonly Types.Events.Event[]): Protocol.Profiler.Profile {\n const profileEvent = traceEvents.find(e => Types.Events.isSyntheticCpuProfile(e));\n const profile = profileEvent?.args.data.cpuProfile;\n if (!profile) {\n throw new Error('Missing cpuProfile data');\n }\n return profile;\n }\n}\n\nexport namespace SamplesIntegrator {\n export enum NativeGroups {\n COMPILE = 'Compile',\n PARSE = 'Parse',\n }\n}\n"]}
@@ -7,14 +7,6 @@ export declare class SyntheticEventsManager {
7
7
  static reset(): void;
8
8
  static registerSyntheticEvent<T extends Types.Events.SyntheticBased>(syntheticEvent: Omit<T, '_tag'>): T;
9
9
  private constructor();
10
- /**
11
- * Clears the transient raw event index map.
12
- * During trace parsing, this map provides O(1) lookups for registering synthetic events.
13
- * Once parsing is complete, queries look up synthetic events exclusively by index in
14
- * `#syntheticTraces`, so this map is discarded to reclaim memory.
15
- */
16
- clearRegistrationIndex(): void;
17
10
  syntheticEventForRawEventIndex(rawEventIndex: number): Types.Events.SyntheticBased;
18
- getSyntheticTraces(): Types.Events.SyntheticBased[];
19
11
  getRawTraceEvents(): readonly Types.Events.Event[];
20
12
  }