@paulirish/trace_engine 0.0.31 → 0.0.33

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 (283) hide show
  1. package/README.md +6 -10
  2. package/analyze-trace.mjs +9 -10
  3. package/core/platform/ArrayUtilities.js +1 -0
  4. package/core/platform/ArrayUtilities.js.map +1 -1
  5. package/core/platform/DevToolsPath.d.ts +1 -1
  6. package/core/platform/DevToolsPath.js.map +1 -1
  7. package/core/platform/MimeType.js +4 -2
  8. package/core/platform/MimeType.js.map +1 -1
  9. package/core/platform/NumberUtilities.js +8 -0
  10. package/core/platform/NumberUtilities.js.map +1 -1
  11. package/core/platform/ServerTiming.d.ts +31 -0
  12. package/core/platform/ServerTiming.js +212 -0
  13. package/core/platform/ServerTiming.js.map +1 -0
  14. package/core/platform/Timing.d.ts +1 -1
  15. package/core/platform/Timing.js.map +1 -1
  16. package/core/platform/TypescriptUtilities.d.ts +3 -0
  17. package/core/platform/TypescriptUtilities.js.map +1 -1
  18. package/core/platform/UIString.d.ts +1 -1
  19. package/core/platform/UIString.js.map +1 -1
  20. package/core/platform/UserVisibleError.d.ts +1 -1
  21. package/core/platform/UserVisibleError.js.map +1 -1
  22. package/core/platform/platform-tsconfig.json +1 -1
  23. package/core/platform/platform.d.ts +2 -2
  24. package/core/platform/platform.js +2 -2
  25. package/core/platform/platform.js.map +1 -1
  26. package/generated/protocol.d.ts +258 -14
  27. package/models/trace/LanternComputationData.d.ts +4 -4
  28. package/models/trace/LanternComputationData.js +22 -23
  29. package/models/trace/LanternComputationData.js.map +1 -1
  30. package/models/trace/ModelImpl.d.ts +11 -12
  31. package/models/trace/ModelImpl.js +22 -33
  32. package/models/trace/ModelImpl.js.map +1 -1
  33. package/models/trace/Processor.d.ts +21 -12
  34. package/models/trace/Processor.js +148 -67
  35. package/models/trace/Processor.js.map +1 -1
  36. package/models/trace/TracingManager.js.map +1 -1
  37. package/models/trace/extras/FetchNodes.d.ts +8 -8
  38. package/models/trace/extras/FetchNodes.js +16 -11
  39. package/models/trace/extras/FetchNodes.js.map +1 -1
  40. package/models/trace/extras/FilmStrip.d.ts +2 -2
  41. package/models/trace/extras/FilmStrip.js +8 -8
  42. package/models/trace/extras/FilmStrip.js.map +1 -1
  43. package/models/trace/extras/MainThreadActivity.d.ts +1 -1
  44. package/models/trace/extras/MainThreadActivity.js +1 -1
  45. package/models/trace/extras/MainThreadActivity.js.map +1 -1
  46. package/models/trace/extras/Metadata.js +2 -2
  47. package/models/trace/extras/Metadata.js.map +1 -1
  48. package/models/trace/extras/URLForEntry.d.ts +9 -1
  49. package/models/trace/extras/URLForEntry.js +18 -10
  50. package/models/trace/extras/URLForEntry.js.map +1 -1
  51. package/models/trace/extras/extras.js +1 -1
  52. package/models/trace/handlers/AnimationHandler.d.ts +2 -2
  53. package/models/trace/handlers/AnimationHandler.js +1 -1
  54. package/models/trace/handlers/AnimationHandler.js.map +1 -1
  55. package/models/trace/handlers/AuctionWorkletsHandler.d.ts +2 -2
  56. package/models/trace/handlers/AuctionWorkletsHandler.js +11 -11
  57. package/models/trace/handlers/AuctionWorkletsHandler.js.map +1 -1
  58. package/models/trace/handlers/ExtensionTraceDataHandler.d.ts +7 -5
  59. package/models/trace/handlers/ExtensionTraceDataHandler.js +16 -10
  60. package/models/trace/handlers/ExtensionTraceDataHandler.js.map +1 -1
  61. package/models/trace/handlers/FramesHandler.d.ts +24 -19
  62. package/models/trace/handlers/FramesHandler.js +46 -25
  63. package/models/trace/handlers/FramesHandler.js.map +1 -1
  64. package/models/trace/handlers/GPUHandler.d.ts +4 -4
  65. package/models/trace/handlers/GPUHandler.js +3 -3
  66. package/models/trace/handlers/GPUHandler.js.map +1 -1
  67. package/models/trace/handlers/ImagePaintingHandler.d.ts +3 -3
  68. package/models/trace/handlers/ImagePaintingHandler.js +6 -8
  69. package/models/trace/handlers/ImagePaintingHandler.js.map +1 -1
  70. package/models/trace/handlers/InitiatorsHandler.d.ts +3 -3
  71. package/models/trace/handlers/InitiatorsHandler.js +14 -14
  72. package/models/trace/handlers/InitiatorsHandler.js.map +1 -1
  73. package/models/trace/handlers/InvalidationsHandler.d.ts +4 -2
  74. package/models/trace/handlers/InvalidationsHandler.js +29 -11
  75. package/models/trace/handlers/InvalidationsHandler.js.map +1 -1
  76. package/models/trace/handlers/LargestImagePaintHandler.d.ts +2 -2
  77. package/models/trace/handlers/LargestImagePaintHandler.js +1 -1
  78. package/models/trace/handlers/LargestImagePaintHandler.js.map +1 -1
  79. package/models/trace/handlers/LargestTextPaintHandler.d.ts +2 -2
  80. package/models/trace/handlers/LargestTextPaintHandler.js +1 -1
  81. package/models/trace/handlers/LargestTextPaintHandler.js.map +1 -1
  82. package/models/trace/handlers/LayerTreeHandler.d.ts +6 -6
  83. package/models/trace/handlers/LayerTreeHandler.js +6 -6
  84. package/models/trace/handlers/LayerTreeHandler.js.map +1 -1
  85. package/models/trace/handlers/LayoutShiftsHandler.d.ts +12 -20
  86. package/models/trace/handlers/LayoutShiftsHandler.js +73 -12
  87. package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
  88. package/models/trace/handlers/MemoryHandler.d.ts +2 -2
  89. package/models/trace/handlers/MemoryHandler.js +1 -1
  90. package/models/trace/handlers/MemoryHandler.js.map +1 -1
  91. package/models/trace/handlers/MetaHandler.d.ts +15 -14
  92. package/models/trace/handlers/MetaHandler.js +32 -30
  93. package/models/trace/handlers/MetaHandler.js.map +1 -1
  94. package/models/trace/handlers/ModelHandlers.d.ts +1 -1
  95. package/models/trace/handlers/ModelHandlers.js +1 -1
  96. package/models/trace/handlers/ModelHandlers.js.map +1 -1
  97. package/models/trace/handlers/NetworkRequestsHandler.d.ts +13 -12
  98. package/models/trace/handlers/NetworkRequestsHandler.js +68 -66
  99. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
  100. package/models/trace/handlers/PageFramesHandler.d.ts +2 -2
  101. package/models/trace/handlers/PageFramesHandler.js +2 -2
  102. package/models/trace/handlers/PageFramesHandler.js.map +1 -1
  103. package/models/trace/handlers/PageLoadMetricsHandler.d.ts +7 -7
  104. package/models/trace/handlers/PageLoadMetricsHandler.js +21 -24
  105. package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -1
  106. package/models/trace/handlers/RendererHandler.d.ts +19 -19
  107. package/models/trace/handlers/RendererHandler.js +5 -5
  108. package/models/trace/handlers/RendererHandler.js.map +1 -1
  109. package/models/trace/handlers/SamplesHandler.d.ts +6 -6
  110. package/models/trace/handlers/SamplesHandler.js +4 -4
  111. package/models/trace/handlers/SamplesHandler.js.map +1 -1
  112. package/models/trace/handlers/ScreenshotsHandler.d.ts +6 -4
  113. package/models/trace/handlers/ScreenshotsHandler.js +11 -9
  114. package/models/trace/handlers/ScreenshotsHandler.js.map +1 -1
  115. package/models/trace/handlers/SelectorStatsHandler.d.ts +3 -3
  116. package/models/trace/handlers/SelectorStatsHandler.js +2 -2
  117. package/models/trace/handlers/SelectorStatsHandler.js.map +1 -1
  118. package/models/trace/handlers/ServerTimingsHandler.d.ts +10 -0
  119. package/models/trace/handlers/ServerTimingsHandler.js +118 -0
  120. package/models/trace/handlers/ServerTimingsHandler.js.map +1 -0
  121. package/models/trace/handlers/Threads.d.ts +7 -7
  122. package/models/trace/handlers/Threads.js +5 -5
  123. package/models/trace/handlers/Threads.js.map +1 -1
  124. package/models/trace/handlers/UserInteractionsHandler.d.ts +13 -11
  125. package/models/trace/handlers/UserInteractionsHandler.js +13 -7
  126. package/models/trace/handlers/UserInteractionsHandler.js.map +1 -1
  127. package/models/trace/handlers/UserTimingsHandler.d.ts +5 -5
  128. package/models/trace/handlers/UserTimingsHandler.js +52 -9
  129. package/models/trace/handlers/UserTimingsHandler.js.map +1 -1
  130. package/models/trace/handlers/WarningsHandler.d.ts +5 -5
  131. package/models/trace/handlers/WarningsHandler.js +4 -5
  132. package/models/trace/handlers/WarningsHandler.js.map +1 -1
  133. package/models/trace/handlers/WorkersHandler.d.ts +4 -4
  134. package/models/trace/handlers/WorkersHandler.js +1 -1
  135. package/models/trace/handlers/WorkersHandler.js.map +1 -1
  136. package/models/trace/handlers/handlers-tsconfig.json +1 -1
  137. package/models/trace/handlers/types.d.ts +7 -7
  138. package/models/trace/handlers/types.js.map +1 -1
  139. package/models/trace/helpers/Extensions.d.ts +5 -1
  140. package/models/trace/helpers/Extensions.js +5 -3
  141. package/models/trace/helpers/Extensions.js.map +1 -1
  142. package/models/trace/helpers/Network.d.ts +2 -2
  143. package/models/trace/helpers/Network.js +19 -2
  144. package/models/trace/helpers/Network.js.map +1 -1
  145. package/models/trace/helpers/SamplesIntegrator.d.ts +5 -5
  146. package/models/trace/helpers/SamplesIntegrator.js +10 -11
  147. package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
  148. package/models/trace/helpers/SyntheticEvents.d.ts +8 -14
  149. package/models/trace/helpers/SyntheticEvents.js +20 -31
  150. package/models/trace/helpers/SyntheticEvents.js.map +1 -1
  151. package/models/trace/helpers/Timing.d.ts +16 -5
  152. package/models/trace/helpers/Timing.js +33 -7
  153. package/models/trace/helpers/Timing.js.map +1 -1
  154. package/models/trace/helpers/Trace.d.ts +46 -33
  155. package/models/trace/helpers/Trace.js +53 -38
  156. package/models/trace/helpers/Trace.js.map +1 -1
  157. package/models/trace/helpers/TreeHelpers.d.ts +30 -8
  158. package/models/trace/helpers/TreeHelpers.js +91 -23
  159. package/models/trace/helpers/TreeHelpers.js.map +1 -1
  160. package/models/trace/insights/Common.d.ts +8 -2
  161. package/models/trace/insights/Common.js +33 -7
  162. package/models/trace/insights/Common.js.map +1 -1
  163. package/models/trace/insights/CumulativeLayoutShift.d.ts +34 -13
  164. package/models/trace/insights/CumulativeLayoutShift.js +151 -59
  165. package/models/trace/insights/CumulativeLayoutShift.js.map +1 -1
  166. package/models/trace/insights/DocumentLatency.d.ts +9 -4
  167. package/models/trace/insights/DocumentLatency.js +82 -7
  168. package/models/trace/insights/DocumentLatency.js.map +1 -1
  169. package/models/trace/insights/FontDisplay.d.ts +11 -0
  170. package/models/trace/insights/FontDisplay.js +44 -0
  171. package/models/trace/insights/FontDisplay.js.map +1 -0
  172. package/models/trace/insights/InsightRunners.d.ts +3 -0
  173. package/models/trace/insights/InsightRunners.js +3 -0
  174. package/models/trace/insights/InsightRunners.js.map +1 -1
  175. package/models/trace/insights/InteractionToNextPaint.d.ts +4 -5
  176. package/models/trace/insights/InteractionToNextPaint.js +5 -3
  177. package/models/trace/insights/InteractionToNextPaint.js.map +1 -1
  178. package/models/trace/insights/LargestContentfulPaint.d.ts +20 -7
  179. package/models/trace/insights/LargestContentfulPaint.js +57 -37
  180. package/models/trace/insights/LargestContentfulPaint.js.map +1 -1
  181. package/models/trace/insights/RenderBlocking.d.ts +3 -3
  182. package/models/trace/insights/RenderBlocking.js +29 -24
  183. package/models/trace/insights/RenderBlocking.js.map +1 -1
  184. package/models/trace/insights/SlowCSSSelector.d.ts +11 -0
  185. package/models/trace/insights/SlowCSSSelector.js +67 -0
  186. package/models/trace/insights/SlowCSSSelector.js.map +1 -0
  187. package/models/trace/insights/ThirdPartyWeb.d.ts +18 -0
  188. package/models/trace/insights/ThirdPartyWeb.js +174 -0
  189. package/models/trace/insights/ThirdPartyWeb.js.map +1 -0
  190. package/models/trace/insights/Viewport.d.ts +5 -2
  191. package/models/trace/insights/Viewport.js +14 -9
  192. package/models/trace/insights/Viewport.js.map +1 -1
  193. package/models/trace/insights/insights-tsconfig.json +9 -0
  194. package/models/trace/insights/insights.d.ts +1 -0
  195. package/models/trace/insights/insights.js +1 -0
  196. package/models/trace/insights/insights.js.map +1 -1
  197. package/models/trace/insights/types.d.ts +43 -25
  198. package/models/trace/insights/types.js.map +1 -1
  199. package/models/trace/lantern/core/NetworkAnalyzer.d.ts +6 -6
  200. package/models/trace/lantern/core/NetworkAnalyzer.js +12 -12
  201. package/models/trace/lantern/core/NetworkAnalyzer.js.map +1 -1
  202. package/models/trace/lantern/graph/BaseNode.d.ts +4 -4
  203. package/models/trace/lantern/graph/BaseNode.js +21 -21
  204. package/models/trace/lantern/graph/BaseNode.js.map +1 -1
  205. package/models/trace/lantern/graph/CPUNode.d.ts +1 -1
  206. package/models/trace/lantern/graph/CPUNode.js +5 -5
  207. package/models/trace/lantern/graph/CPUNode.js.map +1 -1
  208. package/models/trace/lantern/graph/PageDependencyGraph.d.ts +4 -4
  209. package/models/trace/lantern/graph/PageDependencyGraph.js +5 -5
  210. package/models/trace/lantern/graph/PageDependencyGraph.js.map +1 -1
  211. package/models/trace/lantern/simulation/ConnectionPool.d.ts +7 -7
  212. package/models/trace/lantern/simulation/ConnectionPool.js +26 -26
  213. package/models/trace/lantern/simulation/ConnectionPool.js.map +1 -1
  214. package/models/trace/lantern/simulation/DNSCache.d.ts +3 -3
  215. package/models/trace/lantern/simulation/DNSCache.js +11 -11
  216. package/models/trace/lantern/simulation/DNSCache.js.map +1 -1
  217. package/models/trace/lantern/simulation/SimulationTimingMap.d.ts +1 -1
  218. package/models/trace/lantern/simulation/SimulationTimingMap.js +15 -15
  219. package/models/trace/lantern/simulation/SimulationTimingMap.js.map +1 -1
  220. package/models/trace/lantern/simulation/Simulator.d.ts +28 -28
  221. package/models/trace/lantern/simulation/Simulator.js +113 -113
  222. package/models/trace/lantern/simulation/Simulator.js.map +1 -1
  223. package/models/trace/lantern/simulation/TCPConnection.d.ts +9 -9
  224. package/models/trace/lantern/simulation/TCPConnection.js +36 -36
  225. package/models/trace/lantern/simulation/TCPConnection.js.map +1 -1
  226. package/models/trace/root-causes/LayoutShift.d.ts +13 -13
  227. package/models/trace/root-causes/LayoutShift.js +7 -25
  228. package/models/trace/root-causes/LayoutShift.js.map +1 -1
  229. package/models/trace/types/Configuration.d.ts +16 -0
  230. package/models/trace/types/Configuration.js +1 -0
  231. package/models/trace/types/Configuration.js.map +1 -1
  232. package/models/trace/types/Extensions.d.ts +9 -12
  233. package/models/trace/types/Extensions.js +2 -1
  234. package/models/trace/types/Extensions.js.map +1 -1
  235. package/models/trace/types/File.d.ts +68 -25
  236. package/models/trace/types/File.js +15 -3
  237. package/models/trace/types/File.js.map +1 -1
  238. package/models/trace/types/TraceEvents.d.ts +819 -730
  239. package/models/trace/types/TraceEvents.js +270 -280
  240. package/models/trace/types/TraceEvents.js.map +1 -1
  241. package/models/trace/types/types.d.ts +1 -1
  242. package/models/trace/types/types.js +1 -1
  243. package/models/trace/types/types.js.map +1 -1
  244. package/package.json +4 -2
  245. package/test/test-trace-engine.mjs +47 -2
  246. package/third_party/third-party-web/third-party-web.js +1 -0
  247. package/core/platform/PromiseUtilities.d.ts +0 -10
  248. package/core/platform/PromiseUtilities.js +0 -18
  249. package/core/platform/PromiseUtilities.js.map +0 -1
  250. package/core/platform/SetUtilities.d.ts +0 -2
  251. package/core/platform/SetUtilities.js +0 -23
  252. package/core/platform/SetUtilities.js.map +0 -1
  253. package/models/trace/EntriesFilter.d.ts +0 -72
  254. package/models/trace/EntriesFilter.js +0 -296
  255. package/models/trace/EntriesFilter.js.map +0 -1
  256. package/models/trace/LegacyTracingModel.js.map +0 -1
  257. package/models/trace/handlers/EnhancedTracesHandler.d.ts +0 -48
  258. package/models/trace/handlers/EnhancedTracesHandler.js +0 -165
  259. package/models/trace/handlers/EnhancedTracesHandler.js.map +0 -1
  260. package/models/trace/lantern/BaseNode.d.ts +0 -91
  261. package/models/trace/lantern/BaseNode.js +0 -268
  262. package/models/trace/lantern/BaseNode.js.map +0 -1
  263. package/models/trace/lantern/CPUNode.d.ts +0 -24
  264. package/models/trace/lantern/CPUNode.js +0 -64
  265. package/models/trace/lantern/CPUNode.js.map +0 -1
  266. package/models/trace/lantern/LanternError.d.ts +0 -3
  267. package/models/trace/lantern/LanternError.js +0 -7
  268. package/models/trace/lantern/LanternError.js.map +0 -1
  269. package/models/trace/lantern/MetricsModule.d.ts +0 -11
  270. package/models/trace/lantern/MetricsModule.js +0 -14
  271. package/models/trace/lantern/MetricsModule.js.map +0 -1
  272. package/models/trace/lantern/NetworkNode.d.ts +0 -22
  273. package/models/trace/lantern/NetworkNode.js +0 -83
  274. package/models/trace/lantern/NetworkNode.js.map +0 -1
  275. package/models/trace/lantern/PageDependencyGraph.d.ts +0 -43
  276. package/models/trace/lantern/PageDependencyGraph.js +0 -509
  277. package/models/trace/lantern/PageDependencyGraph.js.map +0 -1
  278. package/models/trace/lantern/SimulationModule.d.ts +0 -17
  279. package/models/trace/lantern/SimulationModule.js +0 -13
  280. package/models/trace/lantern/SimulationModule.js.map +0 -1
  281. package/models/trace/lantern/simulation/NetworkAnalyzer.d.ts +0 -112
  282. package/models/trace/lantern/simulation/NetworkAnalyzer.js +0 -486
  283. package/models/trace/lantern/simulation/NetworkAnalyzer.js.map +0 -1
@@ -8,11 +8,11 @@ import test from 'node:test';
8
8
  import {analyzeTrace} from '../analyze-trace.mjs';
9
9
 
10
10
  const filename = './test/invalid-animation-events.json.gz';
11
- const data = await analyzeTrace(filename);
11
+ const {parsedTrace: data, insights} = await analyzeTrace(filename);
12
12
 
13
13
  test('key values are populated', t => {
14
14
  assert.equal(data.Renderer.allTraceEntries.length > 90_000, true);
15
- assert.equal(data.Screenshots.length > 2, true);
15
+ assert.equal(data.Screenshots.all.length > 2, true);
16
16
  assert.equal(data.Meta.threadsInProcess.size > 2, true);
17
17
  assert.equal(data.Meta.mainFrameNavigations.length > 0, true);
18
18
  });
@@ -50,3 +50,48 @@ test('string values are set and look legit', t => {
50
50
  assert.equal(datum.length > 10, true);
51
51
  }
52
52
  });
53
+
54
+ test('insights look ok', t => {
55
+ if (insights === null) {
56
+ throw new Error('insights null');
57
+ }
58
+ // First insightset with a navigation on it, to skip over the NO_NAV one.
59
+ const insightSet = Array.from(insights.values()).find(is => is.navigation);
60
+
61
+ const keys = Object.keys(insightSet.data);
62
+ assert.deepStrictEqual(keys, [
63
+ 'CumulativeLayoutShift',
64
+ 'DocumentLatency',
65
+ 'FontDisplay',
66
+ 'InteractionToNextPaint',
67
+ 'LargestContentfulPaint',
68
+ 'RenderBlocking',
69
+ 'SlowCSSSelector',
70
+ 'ThirdPartyWeb',
71
+ 'Viewport',
72
+ ]);
73
+ for (const key of keys) {
74
+ assert.ok(insightSet.data[key] instanceof Error === false, `key ${key} is an error`);
75
+ assert.ok(typeof insightSet.data[key] === 'object', `key ${key} is not an object`);
76
+ }
77
+
78
+ const entityNames = Array.from(insightSet.data.ThirdPartyWeb.summaryByEntity.keys()).map(e => e.name);
79
+ const values = Array.from(insightSet.data.ThirdPartyWeb.summaryByEntity.values());
80
+ const simplified = Object.fromEntries(values.map((v, i) => [entityNames[i], v]));
81
+
82
+ const expected = {
83
+ 'Google Fonts': {
84
+ mainThreadTime: 0,
85
+ transferSize: 74145,
86
+ },
87
+ 'paulirish.com': {
88
+ mainThreadTime: 5545,
89
+ transferSize: 142142,
90
+ },
91
+ Disqus: {
92
+ mainThreadTime: 413,
93
+ transferSize: 1550,
94
+ },
95
+ };
96
+ assert.deepStrictEqual(simplified, expected);
97
+ });
@@ -0,0 +1 @@
1
+ import ThirdPartyWeb from 'third-party-web'; export {ThirdPartyWeb};
@@ -1,10 +0,0 @@
1
- /**
2
- * Returns a new pending promise together with it's resolve and reject functions.
3
- *
4
- * Polyfill for https://github.com/tc39/proposal-promise-with-resolvers.
5
- */
6
- export declare function promiseWithResolvers<T = unknown>(): {
7
- promise: Promise<T>;
8
- resolve: (value: T | PromiseLike<T>) => void;
9
- reject: (error?: Error) => void;
10
- };
@@ -1,18 +0,0 @@
1
- // Copyright 2023 The Chromium Authors. All rights reserved.
2
- // Use of this source code is governed by a BSD-style license that can be
3
- // found in the LICENSE file.
4
- /**
5
- * Returns a new pending promise together with it's resolve and reject functions.
6
- *
7
- * Polyfill for https://github.com/tc39/proposal-promise-with-resolvers.
8
- */
9
- export function promiseWithResolvers() {
10
- let resolve;
11
- let reject;
12
- const promise = new Promise((res, rej) => {
13
- resolve = res;
14
- reject = rej;
15
- });
16
- return { promise, resolve, reject };
17
- }
18
- //# sourceMappingURL=PromiseUtilities.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PromiseUtilities.js","sourceRoot":"","sources":["../../../../../../front_end/core/platform/PromiseUtilities.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAKlC,IAAI,OAA2C,CAAC;IAChD,IAAI,MAAgC,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC1C,OAAO,GAAG,GAAG,CAAC;QACd,MAAM,GAAG,GAAG,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAC,CAAC;AACpC,CAAC","sourcesContent":["// Copyright 2023 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * Returns a new pending promise together with it's resolve and reject functions.\n *\n * Polyfill for https://github.com/tc39/proposal-promise-with-resolvers.\n */\nexport function promiseWithResolvers<T = unknown>(): {\n promise: Promise<T>,\n resolve: (value: T|PromiseLike<T>) => void,\n reject: (error?: Error) => void,\n} {\n let resolve!: (value: T|PromiseLike<T>) => void;\n let reject!: (error?: Error) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return {promise, resolve, reject};\n}\n"]}
@@ -1,2 +0,0 @@
1
- export declare const addAll: <T>(set: Set<T>, iterable: Iterable<T>) => void;
2
- export declare const isEqual: <T>(setA: Set<T>, setB: Set<T>) => boolean;
@@ -1,23 +0,0 @@
1
- // Copyright (c) 2020 The Chromium Authors. All rights reserved.
2
- // Use of this source code is governed by a BSD-style license that can be
3
- // found in the LICENSE file.
4
- export const addAll = function (set, iterable) {
5
- for (const item of iterable) {
6
- set.add(item);
7
- }
8
- };
9
- export const isEqual = function (setA, setB) {
10
- if (setA === setB) {
11
- return true;
12
- }
13
- if (setA.size !== setB.size) {
14
- return false;
15
- }
16
- for (const item of setA) {
17
- if (!setB.has(item)) {
18
- return false;
19
- }
20
- }
21
- return true;
22
- };
23
- //# sourceMappingURL=SetUtilities.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SetUtilities.js","sourceRoot":"","sources":["../../../../../../front_end/core/platform/SetUtilities.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,yEAAyE;AACzE,6BAA6B;AAE7B,MAAM,CAAC,MAAM,MAAM,GAAG,UAAY,GAAW,EAAE,QAAqB;IAClE,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,UAAY,IAAY,EAAE,IAAY;IAC3D,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACpB,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["// Copyright (c) 2020 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nexport const addAll = function<T>(set: Set<T>, iterable: Iterable<T>): void {\n for (const item of iterable) {\n set.add(item);\n }\n};\n\nexport const isEqual = function<T>(setA: Set<T>, setB: Set<T>): boolean {\n if (setA === setB) {\n return true;\n }\n if (setA.size !== setB.size) {\n return false;\n }\n for (const item of setA) {\n if (!setB.has(item)) {\n return false;\n }\n }\n return true;\n};\n"]}
@@ -1,72 +0,0 @@
1
- import * as Helpers from './helpers/helpers.js';
2
- import * as Types from './types/types.js';
3
- type EntryToNodeMap = Map<Types.TraceEvents.SyntheticTraceEntry, Helpers.TreeHelpers.TraceEntryNode>;
4
- export declare const enum FilterAction {
5
- MERGE_FUNCTION = "MERGE_FUNCTION",
6
- COLLAPSE_FUNCTION = "COLLAPSE_FUNCTION",
7
- COLLAPSE_REPEATING_DESCENDANTS = "COLLAPSE_REPEATING_DESCENDANTS",
8
- RESET_CHILDREN = "RESET_CHILDREN",
9
- UNDO_ALL_ACTIONS = "UNDO_ALL_ACTIONS"
10
- }
11
- export interface UserFilterAction {
12
- type: FilterAction;
13
- entry: Types.TraceEvents.SyntheticTraceEntry;
14
- }
15
- export interface PossibleFilterActions {
16
- [FilterAction.MERGE_FUNCTION]: boolean;
17
- [FilterAction.COLLAPSE_FUNCTION]: boolean;
18
- [FilterAction.COLLAPSE_REPEATING_DESCENDANTS]: boolean;
19
- [FilterAction.RESET_CHILDREN]: boolean;
20
- [FilterAction.UNDO_ALL_ACTIONS]: boolean;
21
- }
22
- /**
23
- * This class can take in a thread that has been generated by the
24
- * RendererHandler and apply certain actions to it in order to modify what is
25
- * shown to the user. These actions can be automatically applied by DevTools or
26
- * applied by the user.
27
- *
28
- * Once actions are applied, the invisibleEntries() method will return the
29
- * entries that are invisible, and this is the list of entries that should be
30
- * removed before rendering the resulting thread on the timeline.
31
- */
32
- export declare class EntriesFilter {
33
- #private;
34
- constructor(entryToNodeMap: EntryToNodeMap);
35
- /**
36
- * Checks which actions can be applied on an entry. This allows us to only show possible actions in the Context Menu.
37
- * For example, if an entry has no children, COLLAPSE_FUNCTION will not change the FlameChart, therefore there is no need to show this action as an option.
38
- */
39
- findPossibleActions(entry: Types.TraceEvents.SyntheticTraceEntry): PossibleFilterActions;
40
- /**
41
- * Returns the amount of entry descendants that belong to the hidden entries array.
42
- * */
43
- findHiddenDescendantsAmount(entry: Types.TraceEvents.SyntheticTraceEntry): number;
44
- /**
45
- * Returns the set of entries that are invisible given the set of applied actions.
46
- */
47
- invisibleEntries(): Types.TraceEvents.TraceEventData[];
48
- /**
49
- * Sets hidden and expandable. Called when a trace with modifications is loaded and some entries are set as hidden and expandable.
50
- * Both arrays are set together because if there is one, the other must be present too.
51
- */
52
- setHiddenAndExpandableEntries(invisibleEntries: Types.TraceEvents.TraceEventData[], expandableEntries: Types.TraceEvents.TraceEventData[]): void;
53
- inEntryInvisible(entry: Types.TraceEvents.TraceEventData): boolean;
54
- /**
55
- * Returns the array of entries that have a sign indicating that entries below are hidden,
56
- * and so that they can be "expanded" to reveal their hidden children.
57
- */
58
- expandableEntries(): Types.TraceEvents.TraceEventData[];
59
- /**
60
- * Applies an action to hide entries or removes entries
61
- * from hidden entries array depending on the action.
62
- */
63
- applyFilterAction(action: UserFilterAction): Types.TraceEvents.TraceEventData[];
64
- /**
65
- * If an entry was selected from a link instead of clicking on it,
66
- * it might be in the invisible entries array.
67
- * If it is, reveal it by resetting clidren the closest expandable entry,
68
- */
69
- revealEntry(entry: Types.TraceEvents.SyntheticTraceEntry): void;
70
- isEntryExpandable(event: Types.TraceEvents.TraceEventData): boolean;
71
- }
72
- export {};
@@ -1,296 +0,0 @@
1
- // Copyright 2023 The Chromium Authors. All rights reserved.
2
- // Use of this source code is governed by a BSD-style license that can be
3
- // found in the LICENSE file.
4
- import * as Platform from '../../core/platform/platform.js';
5
- import * as Helpers from './helpers/helpers.js';
6
- import * as Types from './types/types.js';
7
- /**
8
- * This class can take in a thread that has been generated by the
9
- * RendererHandler and apply certain actions to it in order to modify what is
10
- * shown to the user. These actions can be automatically applied by DevTools or
11
- * applied by the user.
12
- *
13
- * Once actions are applied, the invisibleEntries() method will return the
14
- * entries that are invisible, and this is the list of entries that should be
15
- * removed before rendering the resulting thread on the timeline.
16
- */
17
- export class EntriesFilter {
18
- // Maps from an individual TraceEvent entry to its representation as a
19
- // RendererEntryNode. We need this so we can then parse the tree structure
20
- // generated by the RendererHandler.
21
- #entryToNode;
22
- // Track the set of invisible entries.
23
- #invisibleEntries = [];
24
- // List of entries whose children are hidden. This list is used to
25
- // keep track of entries that should be identified in the UI as "expandable",
26
- // since they can be clicked to reveal their hidden children.
27
- #expandableEntries = [];
28
- // Cache for descendants of entry that have already been gathered. The descendants
29
- // will never change so we can avoid running the potentially expensive search again.
30
- #entryToDescendantsMap = new Map();
31
- constructor(entryToNodeMap) {
32
- this.#entryToNode = entryToNodeMap;
33
- }
34
- /**
35
- * Checks which actions can be applied on an entry. This allows us to only show possible actions in the Context Menu.
36
- * For example, if an entry has no children, COLLAPSE_FUNCTION will not change the FlameChart, therefore there is no need to show this action as an option.
37
- */
38
- findPossibleActions(entry) {
39
- const entryNode = this.#entryToNode.get(entry);
40
- if (!entryNode) {
41
- // Invalid node was given, return no possible actions.
42
- return {
43
- ["MERGE_FUNCTION" /* FilterAction.MERGE_FUNCTION */]: false,
44
- ["COLLAPSE_FUNCTION" /* FilterAction.COLLAPSE_FUNCTION */]: false,
45
- ["COLLAPSE_REPEATING_DESCENDANTS" /* FilterAction.COLLAPSE_REPEATING_DESCENDANTS */]: false,
46
- ["RESET_CHILDREN" /* FilterAction.RESET_CHILDREN */]: false,
47
- ["UNDO_ALL_ACTIONS" /* FilterAction.UNDO_ALL_ACTIONS */]: false,
48
- };
49
- }
50
- const entryParent = entryNode.parent;
51
- const allVisibleDescendants = this.#findAllDescendantsOfNode(entryNode).filter(descendant => !this.#invisibleEntries.includes(descendant));
52
- const allVisibleRepeatingDescendants = this.#findAllRepeatingDescendantsOfNext(entryNode).filter(descendant => !this.#invisibleEntries.includes(descendant));
53
- const allInVisibleDescendants = this.#findAllDescendantsOfNode(entryNode).filter(descendant => this.#invisibleEntries.includes(descendant));
54
- // If there are children to hide, indicate action as possible
55
- const possibleActions = {
56
- ["MERGE_FUNCTION" /* FilterAction.MERGE_FUNCTION */]: entryParent !== null,
57
- ["COLLAPSE_FUNCTION" /* FilterAction.COLLAPSE_FUNCTION */]: allVisibleDescendants.length > 0,
58
- ["COLLAPSE_REPEATING_DESCENDANTS" /* FilterAction.COLLAPSE_REPEATING_DESCENDANTS */]: allVisibleRepeatingDescendants.length > 0,
59
- ["RESET_CHILDREN" /* FilterAction.RESET_CHILDREN */]: allInVisibleDescendants.length > 0,
60
- ["UNDO_ALL_ACTIONS" /* FilterAction.UNDO_ALL_ACTIONS */]: this.#invisibleEntries.length > 0,
61
- };
62
- return possibleActions;
63
- }
64
- /**
65
- * Returns the amount of entry descendants that belong to the hidden entries array.
66
- * */
67
- findHiddenDescendantsAmount(entry) {
68
- const entryNode = this.#entryToNode.get(entry);
69
- if (!entryNode) {
70
- return 0;
71
- }
72
- const allDescendants = this.#findAllDescendantsOfNode(entryNode);
73
- return allDescendants.filter(descendant => this.invisibleEntries().includes(descendant)).length;
74
- }
75
- /**
76
- * Returns the set of entries that are invisible given the set of applied actions.
77
- */
78
- invisibleEntries() {
79
- return this.#invisibleEntries;
80
- }
81
- /**
82
- * Sets hidden and expandable. Called when a trace with modifications is loaded and some entries are set as hidden and expandable.
83
- * Both arrays are set together because if there is one, the other must be present too.
84
- */
85
- setHiddenAndExpandableEntries(invisibleEntries, expandableEntries) {
86
- this.#invisibleEntries.push(...invisibleEntries);
87
- this.#expandableEntries.push(...expandableEntries);
88
- }
89
- inEntryInvisible(entry) {
90
- return this.#invisibleEntries.includes(entry);
91
- }
92
- /**
93
- * Returns the array of entries that have a sign indicating that entries below are hidden,
94
- * and so that they can be "expanded" to reveal their hidden children.
95
- */
96
- expandableEntries() {
97
- return this.#expandableEntries;
98
- }
99
- /**
100
- * Applies an action to hide entries or removes entries
101
- * from hidden entries array depending on the action.
102
- */
103
- applyFilterAction(action) {
104
- // We apply new user action to the set of all entries, and mark
105
- // any that should be hidden by adding them to this set.
106
- // Another approach would be to use splice() to remove items from the
107
- // array, but doing this would be a mutation of the arry for every hidden
108
- // event. Instead, we add entries to this set and return it as an array at the end.
109
- const entriesToHide = new Set();
110
- switch (action.type) {
111
- case "MERGE_FUNCTION" /* FilterAction.MERGE_FUNCTION */: {
112
- // The entry that was clicked on is merged into its parent. All its
113
- // children remain visible, so we just have to hide the entry that was
114
- // selected.
115
- entriesToHide.add(action.entry);
116
- // If parent node exists, add it to expandableEntries, so it would be possible to uncollapse its children.
117
- const actionNode = this.#entryToNode.get(action.entry) || null;
118
- const parentNode = actionNode && this.#findNextVisibleParent(actionNode);
119
- if (parentNode) {
120
- this.#addExpandableEntry(parentNode.entry);
121
- }
122
- break;
123
- }
124
- case "COLLAPSE_FUNCTION" /* FilterAction.COLLAPSE_FUNCTION */: {
125
- // The entry itself remains visible, but all of its descendants are hidden.
126
- const entryNode = this.#entryToNode.get(action.entry);
127
- if (!entryNode) {
128
- // Invalid node was given, just ignore and move on.
129
- break;
130
- }
131
- const allDescendants = this.#findAllDescendantsOfNode(entryNode);
132
- allDescendants.forEach(descendant => entriesToHide.add(descendant));
133
- this.#addExpandableEntry(action.entry);
134
- break;
135
- }
136
- case "COLLAPSE_REPEATING_DESCENDANTS" /* FilterAction.COLLAPSE_REPEATING_DESCENDANTS */: {
137
- const entryNode = this.#entryToNode.get(action.entry);
138
- if (!entryNode) {
139
- // Invalid node was given, just ignore and move on.
140
- break;
141
- }
142
- const allRepeatingDescendants = this.#findAllRepeatingDescendantsOfNext(entryNode);
143
- allRepeatingDescendants.forEach(descendant => entriesToHide.add(descendant));
144
- if (entriesToHide.size > 0) {
145
- this.#addExpandableEntry(action.entry);
146
- }
147
- break;
148
- }
149
- case "UNDO_ALL_ACTIONS" /* FilterAction.UNDO_ALL_ACTIONS */: {
150
- this.#invisibleEntries = [];
151
- this.#expandableEntries = [];
152
- break;
153
- }
154
- case "RESET_CHILDREN" /* FilterAction.RESET_CHILDREN */: {
155
- this.#makeEntryChildrenVisible(action.entry);
156
- break;
157
- }
158
- default:
159
- Platform.assertNever(action.type, `Unknown EntriesFilter action: ${action.type}`);
160
- }
161
- this.#invisibleEntries.push(...entriesToHide);
162
- return this.#invisibleEntries;
163
- }
164
- /**
165
- * Add an entry to the array of entries that have a sign indicating that entries below are hidden.
166
- * Also, remove all of the child entries of the new expandable entry from the expandable array. Do that because
167
- * to draw the initiator from the closest visible entry, we need to get the closest entry that is
168
- * marked as expandable and we do not want to get some that are hidden.
169
- */
170
- #addExpandableEntry(entry) {
171
- this.#expandableEntries.push(entry);
172
- const entryNode = this.#entryToNode.get(entry);
173
- if (!entryNode) {
174
- // Invalid node was given, just ignore and move on.
175
- return;
176
- }
177
- const allDescendants = this.#findAllDescendantsOfNode(entryNode);
178
- if (allDescendants.length > 0) {
179
- this.#expandableEntries = this.#expandableEntries.filter(entry => {
180
- return !allDescendants.includes(entry);
181
- });
182
- }
183
- }
184
- // The direct parent might be hidden by other actions, therefore we look for the next visible parent.
185
- #findNextVisibleParent(node) {
186
- let parent = node.parent;
187
- while (parent && this.#invisibleEntries.includes(parent.entry)) {
188
- parent = parent.parent;
189
- }
190
- return parent;
191
- }
192
- #findAllDescendantsOfNode(root) {
193
- const cachedDescendants = this.#entryToDescendantsMap.get(root);
194
- if (cachedDescendants) {
195
- return cachedDescendants;
196
- }
197
- const descendants = [];
198
- // Walk through all the descendants, starting at the root node.
199
- const children = [...root.children];
200
- while (children.length > 0) {
201
- const childNode = children.shift();
202
- if (childNode) {
203
- descendants.push(childNode.entry);
204
- const childNodeCachedDescendants = this.#entryToDescendantsMap.get(childNode);
205
- // If the descendants of a child are cached, get them from the cache instead of iterating through them again
206
- if (childNodeCachedDescendants) {
207
- descendants.push(...childNodeCachedDescendants);
208
- }
209
- else {
210
- children.push(...childNode.children);
211
- }
212
- }
213
- }
214
- this.#entryToDescendantsMap.set(root, descendants);
215
- return descendants;
216
- }
217
- #findAllRepeatingDescendantsOfNext(root) {
218
- // Walk through all the ancestors, starting at the root node.
219
- const children = [...root.children];
220
- const repeatingNodes = [];
221
- const rootIsProfileCall = Types.TraceEvents.isProfileCall(root.entry);
222
- while (children.length > 0) {
223
- const childNode = children.shift();
224
- if (childNode) {
225
- const childIsProfileCall = Types.TraceEvents.isProfileCall(childNode.entry);
226
- if ( /* Handle SyntheticProfileCalls */rootIsProfileCall && childIsProfileCall) {
227
- const rootNodeEntry = root.entry;
228
- const childNodeEntry = childNode.entry;
229
- if (Helpers.SamplesIntegrator.SamplesIntegrator.framesAreEqual(rootNodeEntry.callFrame, childNodeEntry.callFrame)) {
230
- repeatingNodes.push(childNode.entry);
231
- }
232
- } /* Handle SyntheticRendererEvents */
233
- else if (!rootIsProfileCall && !childIsProfileCall) {
234
- if (root.entry.name === childNode.entry.name) {
235
- repeatingNodes.push(childNode.entry);
236
- }
237
- }
238
- children.push(...childNode.children);
239
- }
240
- }
241
- return repeatingNodes;
242
- }
243
- /**
244
- * If an entry was selected from a link instead of clicking on it,
245
- * it might be in the invisible entries array.
246
- * If it is, reveal it by resetting clidren the closest expandable entry,
247
- */
248
- revealEntry(entry) {
249
- const entryNode = this.#entryToNode.get(entry);
250
- if (!entryNode) {
251
- // Invalid node was given, just ignore and move on.
252
- return;
253
- }
254
- let closestExpandableParent = entryNode;
255
- while (closestExpandableParent.parent && !this.#expandableEntries.includes(closestExpandableParent.entry)) {
256
- closestExpandableParent = closestExpandableParent.parent;
257
- }
258
- this.#makeEntryChildrenVisible(closestExpandableParent.entry);
259
- }
260
- /**
261
- * Removes all of the entry children from the
262
- * invisible entries array to make them visible.
263
- */
264
- #makeEntryChildrenVisible(entry) {
265
- const entryNode = this.#entryToNode.get(entry);
266
- if (!entryNode) {
267
- // Invalid node was given, just ignore and move on.
268
- return;
269
- }
270
- const descendants = this.#findAllDescendantsOfNode(entryNode);
271
- /**
272
- * Filter out all descendant of the node
273
- * from the invisible entries list.
274
- */
275
- this.#invisibleEntries = this.#invisibleEntries.filter(entry => {
276
- if (descendants.includes(entry)) {
277
- return false;
278
- }
279
- return true;
280
- });
281
- /**
282
- * Filter out all descentants and entry from expandable entries
283
- * list to not show that some entries below those are hidden.
284
- */
285
- this.#expandableEntries = this.#expandableEntries.filter(iterEntry => {
286
- if (descendants.includes(iterEntry) || iterEntry === entry) {
287
- return false;
288
- }
289
- return true;
290
- });
291
- }
292
- isEntryExpandable(event) {
293
- return this.#expandableEntries.includes(event);
294
- }
295
- }
296
- //# sourceMappingURL=EntriesFilter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EntriesFilter.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/EntriesFilter.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAC7B,OAAO,KAAK,QAAQ,MAAM,iCAAiC,CAAC;AAE5D,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AA0B1C;;;;;;;;;GASG;AACH,MAAM,OAAO,aAAa;IACxB,sEAAsE;IACtE,0EAA0E;IAC1E,oCAAoC;IACpC,YAAY,CAAiB;IAE7B,sCAAsC;IACtC,iBAAiB,GAAuC,EAAE,CAAC;IAC3D,kEAAkE;IAClE,6EAA6E;IAC7E,6DAA6D;IAC7D,kBAAkB,GAAuC,EAAE,CAAC;IAC5D,kFAAkF;IAClF,oFAAoF;IACpF,sBAAsB,GAAgF,IAAI,GAAG,EAAE,CAAC;IAEhH,YAAY,cAA8B;QACxC,IAAI,CAAC,YAAY,GAAG,cAAc,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,mBAAmB,CAAC,KAA4C;QAC9D,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,sDAAsD;YACtD,OAAO;gBACL,oDAA6B,EAAE,KAAK;gBACpC,0DAAgC,EAAE,KAAK;gBACvC,oFAA6C,EAAE,KAAK;gBACpD,oDAA6B,EAAE,KAAK;gBACpC,wDAA+B,EAAE,KAAK;aACvC,CAAC;QACJ,CAAC;QACD,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC;QACrC,MAAM,qBAAqB,GACvB,IAAI,CAAC,yBAAyB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,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;IACH,yBAAyB,CAAC,KAA4C;QACpE,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,mDAAmD;YACnD,OAAO;QACT,CAAC;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,yBAAyB,CAAC,SAAS,CAAC,CAAC;QAE9D;;;WAGG;QACH,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YAC7D,IAAI,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAChC,OAAO,KAAK,CAAC;YACf,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QAEH;;;WAGG;QACH,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;YACnE,IAAI,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;gBAC3D,OAAO,KAAK,CAAC;YACf,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;IAED,iBAAiB,CAAC,KAAuC;QACvD,OAAO,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;CACF","sourcesContent":["// Copyright 2023 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\nimport * as Platform from '../../core/platform/platform.js';\n\nimport * as Helpers from './helpers/helpers.js';\nimport * as Types from './types/types.js';\n\ntype EntryToNodeMap = Map<Types.TraceEvents.SyntheticTraceEntry, Helpers.TreeHelpers.TraceEntryNode>;\n\nexport const enum FilterAction {\n MERGE_FUNCTION = 'MERGE_FUNCTION',\n COLLAPSE_FUNCTION = 'COLLAPSE_FUNCTION',\n COLLAPSE_REPEATING_DESCENDANTS = 'COLLAPSE_REPEATING_DESCENDANTS',\n RESET_CHILDREN = 'RESET_CHILDREN',\n UNDO_ALL_ACTIONS = 'UNDO_ALL_ACTIONS',\n}\n\nexport interface UserFilterAction {\n type: FilterAction;\n entry: Types.TraceEvents.SyntheticTraceEntry;\n}\n\n// Object used to indicate to the Context Menu if an action is possible on the selected entry.\nexport interface PossibleFilterActions {\n [FilterAction.MERGE_FUNCTION]: boolean;\n [FilterAction.COLLAPSE_FUNCTION]: boolean;\n [FilterAction.COLLAPSE_REPEATING_DESCENDANTS]: boolean;\n [FilterAction.RESET_CHILDREN]: boolean;\n [FilterAction.UNDO_ALL_ACTIONS]: boolean;\n}\n\n/**\n * This class can take in a thread that has been generated by the\n * RendererHandler and apply certain actions to it in order to modify what is\n * shown to the user. These actions can be automatically applied by DevTools or\n * applied by the user.\n *\n * Once actions are applied, the invisibleEntries() method will return the\n * entries that are invisible, and this is the list of entries that should be\n * removed before rendering the resulting thread on the timeline.\n */\nexport class EntriesFilter {\n // Maps from an individual TraceEvent entry to its representation as a\n // RendererEntryNode. We need this so we can then parse the tree structure\n // generated by the RendererHandler.\n #entryToNode: EntryToNodeMap;\n\n // Track the set of invisible entries.\n #invisibleEntries: Types.TraceEvents.TraceEventData[] = [];\n // List of entries whose children are hidden. This list is used to\n // keep track of entries that should be identified in the UI as \"expandable\",\n // since they can be clicked to reveal their hidden children.\n #expandableEntries: Types.TraceEvents.TraceEventData[] = [];\n // Cache for descendants of entry that have already been gathered. The descendants\n // will never change so we can avoid running the potentially expensive search again.\n #entryToDescendantsMap: Map<Helpers.TreeHelpers.TraceEntryNode, Types.TraceEvents.TraceEventData[]> = new Map();\n\n constructor(entryToNodeMap: EntryToNodeMap) {\n this.#entryToNode = entryToNodeMap;\n }\n\n /**\n * Checks which actions can be applied on an entry. This allows us to only show possible actions in the Context Menu.\n * For example, if an entry has no children, COLLAPSE_FUNCTION will not change the FlameChart, therefore there is no need to show this action as an option.\n */\n findPossibleActions(entry: Types.TraceEvents.SyntheticTraceEntry): PossibleFilterActions {\n const entryNode = this.#entryToNode.get(entry);\n if (!entryNode) {\n // Invalid node was given, return no possible actions.\n return {\n [FilterAction.MERGE_FUNCTION]: false,\n [FilterAction.COLLAPSE_FUNCTION]: false,\n [FilterAction.COLLAPSE_REPEATING_DESCENDANTS]: false,\n [FilterAction.RESET_CHILDREN]: false,\n [FilterAction.UNDO_ALL_ACTIONS]: false,\n };\n }\n const entryParent = entryNode.parent;\n const allVisibleDescendants =\n this.#findAllDescendantsOfNode(entryNode).filter(descendant => !this.#invisibleEntries.includes(descendant));\n const allVisibleRepeatingDescendants = this.#findAllRepeatingDescendantsOfNext(entryNode).filter(\n descendant => !this.#invisibleEntries.includes(descendant));\n const allInVisibleDescendants =\n this.#findAllDescendantsOfNode(entryNode).filter(descendant => this.#invisibleEntries.includes(descendant));\n\n // If there are children to hide, indicate action as possible\n const possibleActions: PossibleFilterActions = {\n [FilterAction.MERGE_FUNCTION]: entryParent !== null,\n [FilterAction.COLLAPSE_FUNCTION]: allVisibleDescendants.length > 0,\n [FilterAction.COLLAPSE_REPEATING_DESCENDANTS]: allVisibleRepeatingDescendants.length > 0,\n [FilterAction.RESET_CHILDREN]: allInVisibleDescendants.length > 0,\n [FilterAction.UNDO_ALL_ACTIONS]: this.#invisibleEntries.length > 0,\n };\n return possibleActions;\n }\n\n /**\n * Returns the amount of entry descendants that belong to the hidden entries array.\n * */\n findHiddenDescendantsAmount(entry: Types.TraceEvents.SyntheticTraceEntry): number {\n const entryNode = this.#entryToNode.get(entry);\n if (!entryNode) {\n return 0;\n }\n const allDescendants = this.#findAllDescendantsOfNode(entryNode);\n return allDescendants.filter(descendant => this.invisibleEntries().includes(descendant)).length;\n }\n\n /**\n * Returns the set of entries that are invisible given the set of applied actions.\n */\n invisibleEntries(): Types.TraceEvents.TraceEventData[] {\n return this.#invisibleEntries;\n }\n\n /**\n * Sets hidden and expandable. Called when a trace with modifications is loaded and some entries are set as hidden and expandable.\n * Both arrays are set together because if there is one, the other must be present too.\n */\n setHiddenAndExpandableEntries(\n invisibleEntries: Types.TraceEvents.TraceEventData[],\n expandableEntries: Types.TraceEvents.TraceEventData[]): void {\n this.#invisibleEntries.push(...invisibleEntries);\n this.#expandableEntries.push(...expandableEntries);\n }\n\n inEntryInvisible(entry: Types.TraceEvents.TraceEventData): boolean {\n return this.#invisibleEntries.includes(entry);\n }\n\n /**\n * Returns the array of entries that have a sign indicating that entries below are hidden,\n * and so that they can be \"expanded\" to reveal their hidden children.\n */\n expandableEntries(): Types.TraceEvents.TraceEventData[] {\n return this.#expandableEntries;\n }\n\n /**\n * Applies an action to hide entries or removes entries\n * from hidden entries array depending on the action.\n */\n applyFilterAction(action: UserFilterAction): Types.TraceEvents.TraceEventData[] {\n // We apply new user action to the set of all entries, and mark\n // any that should be hidden by adding them to this set.\n // Another approach would be to use splice() to remove items from the\n // array, but doing this would be a mutation of the arry for every hidden\n // event. Instead, we add entries to this set and return it as an array at the end.\n const entriesToHide = new Set<Types.TraceEvents.TraceEventData>();\n\n switch (action.type) {\n case FilterAction.MERGE_FUNCTION: {\n // The entry that was clicked on is merged into its parent. All its\n // children remain visible, so we just have to hide the entry that was\n // selected.\n entriesToHide.add(action.entry);\n // If parent node exists, add it to expandableEntries, so it would be possible to uncollapse its children.\n const actionNode = this.#entryToNode.get(action.entry) || null;\n const parentNode = actionNode && this.#findNextVisibleParent(actionNode);\n if (parentNode) {\n this.#addExpandableEntry(parentNode.entry);\n }\n break;\n }\n case FilterAction.COLLAPSE_FUNCTION: {\n // The entry itself remains visible, but all of its descendants are hidden.\n const entryNode = this.#entryToNode.get(action.entry);\n if (!entryNode) {\n // Invalid node was given, just ignore and move on.\n break;\n }\n const allDescendants = this.#findAllDescendantsOfNode(entryNode);\n allDescendants.forEach(descendant => entriesToHide.add(descendant));\n this.#addExpandableEntry(action.entry);\n break;\n }\n case FilterAction.COLLAPSE_REPEATING_DESCENDANTS: {\n const entryNode = this.#entryToNode.get(action.entry);\n if (!entryNode) {\n // Invalid node was given, just ignore and move on.\n break;\n }\n const allRepeatingDescendants = this.#findAllRepeatingDescendantsOfNext(entryNode);\n allRepeatingDescendants.forEach(descendant => entriesToHide.add(descendant));\n if (entriesToHide.size > 0) {\n this.#addExpandableEntry(action.entry);\n }\n break;\n }\n case FilterAction.UNDO_ALL_ACTIONS: {\n this.#invisibleEntries = [];\n this.#expandableEntries = [];\n break;\n }\n case FilterAction.RESET_CHILDREN: {\n this.#makeEntryChildrenVisible(action.entry);\n break;\n }\n default:\n Platform.assertNever(action.type, `Unknown EntriesFilter action: ${action.type}`);\n }\n\n this.#invisibleEntries.push(...entriesToHide);\n\n return this.#invisibleEntries;\n }\n\n /**\n * Add an entry to the array of entries that have a sign indicating that entries below are hidden.\n * Also, remove all of the child entries of the new expandable entry from the expandable array. Do that because\n * to draw the initiator from the closest visible entry, we need to get the closest entry that is\n * marked as expandable and we do not want to get some that are hidden.\n */\n #addExpandableEntry(entry: Types.TraceEvents.TraceEventData): void {\n this.#expandableEntries.push(entry);\n const entryNode = this.#entryToNode.get(entry);\n if (!entryNode) {\n // Invalid node was given, just ignore and move on.\n return;\n }\n const allDescendants = this.#findAllDescendantsOfNode(entryNode);\n if (allDescendants.length > 0) {\n this.#expandableEntries = this.#expandableEntries.filter(entry => {\n return !allDescendants.includes(entry);\n });\n }\n }\n\n // The direct parent might be hidden by other actions, therefore we look for the next visible parent.\n #findNextVisibleParent(node: Helpers.TreeHelpers.TraceEntryNode): Helpers.TreeHelpers.TraceEntryNode|null {\n let parent = node.parent;\n while (parent && this.#invisibleEntries.includes(parent.entry)) {\n parent = parent.parent;\n }\n return parent;\n }\n\n #findAllDescendantsOfNode(root: Helpers.TreeHelpers.TraceEntryNode): Types.TraceEvents.TraceEventData[] {\n const cachedDescendants = this.#entryToDescendantsMap.get(root);\n if (cachedDescendants) {\n return cachedDescendants;\n }\n\n const descendants: Types.TraceEvents.TraceEventData[] = [];\n\n // Walk through all the descendants, starting at the root node.\n const children: Helpers.TreeHelpers.TraceEntryNode[] = [...root.children];\n while (children.length > 0) {\n const childNode = children.shift();\n if (childNode) {\n descendants.push(childNode.entry);\n const childNodeCachedDescendants = this.#entryToDescendantsMap.get(childNode);\n // If the descendants of a child are cached, get them from the cache instead of iterating through them again\n if (childNodeCachedDescendants) {\n descendants.push(...childNodeCachedDescendants);\n } else {\n children.push(...childNode.children);\n }\n }\n }\n\n this.#entryToDescendantsMap.set(root, descendants);\n return descendants;\n }\n\n #findAllRepeatingDescendantsOfNext(root: Helpers.TreeHelpers.TraceEntryNode):\n Types.TraceEvents.SyntheticTraceEntry[] {\n // Walk through all the ancestors, starting at the root node.\n const children: Helpers.TreeHelpers.TraceEntryNode[] = [...root.children];\n const repeatingNodes: Types.TraceEvents.SyntheticTraceEntry[] = [];\n const rootIsProfileCall = Types.TraceEvents.isProfileCall(root.entry);\n\n while (children.length > 0) {\n const childNode = children.shift();\n if (childNode) {\n const childIsProfileCall = Types.TraceEvents.isProfileCall(childNode.entry);\n if (/* Handle SyntheticProfileCalls */ rootIsProfileCall && childIsProfileCall) {\n const rootNodeEntry = root.entry as Types.TraceEvents.SyntheticProfileCall;\n const childNodeEntry = childNode.entry as Types.TraceEvents.SyntheticProfileCall;\n\n if (Helpers.SamplesIntegrator.SamplesIntegrator.framesAreEqual(\n rootNodeEntry.callFrame, childNodeEntry.callFrame)) {\n repeatingNodes.push(childNode.entry);\n }\n } /* Handle SyntheticRendererEvents */ else if (!rootIsProfileCall && !childIsProfileCall) {\n if (root.entry.name === childNode.entry.name) {\n repeatingNodes.push(childNode.entry);\n }\n }\n children.push(...childNode.children);\n }\n }\n\n return repeatingNodes;\n }\n\n /**\n * If an entry was selected from a link instead of clicking on it,\n * it might be in the invisible entries array.\n * If it is, reveal it by resetting clidren the closest expandable entry,\n */\n revealEntry(entry: Types.TraceEvents.SyntheticTraceEntry): void {\n const entryNode = this.#entryToNode.get(entry);\n if (!entryNode) {\n // Invalid node was given, just ignore and move on.\n return;\n }\n let closestExpandableParent = entryNode;\n while (closestExpandableParent.parent && !this.#expandableEntries.includes(closestExpandableParent.entry)) {\n closestExpandableParent = closestExpandableParent.parent;\n }\n this.#makeEntryChildrenVisible(closestExpandableParent.entry);\n }\n\n /**\n * Removes all of the entry children from the\n * invisible entries array to make them visible.\n */\n #makeEntryChildrenVisible(entry: Types.TraceEvents.SyntheticTraceEntry): void {\n const entryNode = this.#entryToNode.get(entry);\n if (!entryNode) {\n // Invalid node was given, just ignore and move on.\n return;\n }\n const descendants = this.#findAllDescendantsOfNode(entryNode);\n\n /**\n * Filter out all descendant of the node\n * from the invisible entries list.\n */\n this.#invisibleEntries = this.#invisibleEntries.filter(entry => {\n if (descendants.includes(entry)) {\n return false;\n }\n return true;\n });\n\n /**\n * Filter out all descentants and entry from expandable entries\n * list to not show that some entries below those are hidden.\n */\n this.#expandableEntries = this.#expandableEntries.filter(iterEntry => {\n if (descendants.includes(iterEntry) || iterEntry === entry) {\n return false;\n }\n return true;\n });\n }\n\n isEntryExpandable(event: Types.TraceEvents.TraceEventData): boolean {\n return this.#expandableEntries.includes(event);\n }\n}\n"]}