@paulirish/trace_engine 0.0.54 → 0.0.56

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 (288) hide show
  1. package/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts +4 -0
  2. package/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts.map +1 -0
  3. package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
  4. package/core/platform/MimeType.d.ts +3 -2
  5. package/core/platform/MimeType.js +4 -3
  6. package/core/platform/MimeType.js.map +1 -1
  7. package/core/platform/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
  8. package/core/platform/platform.prebundle.d.ts +18 -0
  9. package/core/platform/platform.prebundle.js +53 -0
  10. package/core/platform/platform.prebundle.js.map +1 -0
  11. package/core/platform/platform.prebundle.ts +71 -0
  12. package/generated/protocol.d.ts +115 -16
  13. package/locales/af.json +52 -10
  14. package/locales/am.json +52 -10
  15. package/locales/ar.json +51 -9
  16. package/locales/as.json +52 -10
  17. package/locales/az.json +52 -10
  18. package/locales/be.json +52 -10
  19. package/locales/bg.json +52 -10
  20. package/locales/bn.json +52 -10
  21. package/locales/bs.json +52 -10
  22. package/locales/ca.json +52 -10
  23. package/locales/cs.json +52 -10
  24. package/locales/cy.json +52 -10
  25. package/locales/da.json +52 -10
  26. package/locales/de.json +52 -10
  27. package/locales/el.json +52 -10
  28. package/locales/en-GB.json +52 -10
  29. package/locales/en-US.json +70 -58
  30. package/locales/en-XL.json +70 -58
  31. package/locales/es-419.json +52 -10
  32. package/locales/es.json +50 -8
  33. package/locales/et.json +52 -10
  34. package/locales/eu.json +52 -10
  35. package/locales/fa.json +51 -9
  36. package/locales/fi.json +52 -10
  37. package/locales/fil.json +52 -10
  38. package/locales/fr-CA.json +52 -10
  39. package/locales/fr.json +52 -10
  40. package/locales/gl.json +52 -10
  41. package/locales/gu.json +52 -10
  42. package/locales/he.json +52 -10
  43. package/locales/hi.json +52 -10
  44. package/locales/hr.json +52 -10
  45. package/locales/hu.json +51 -9
  46. package/locales/hy.json +51 -9
  47. package/locales/id.json +52 -10
  48. package/locales/is.json +53 -11
  49. package/locales/it.json +51 -9
  50. package/locales/ja.json +52 -10
  51. package/locales/ka.json +53 -11
  52. package/locales/kk.json +51 -9
  53. package/locales/km.json +52 -10
  54. package/locales/kn.json +52 -10
  55. package/locales/ko.json +52 -10
  56. package/locales/ky.json +51 -9
  57. package/locales/lo.json +52 -10
  58. package/locales/lt.json +52 -10
  59. package/locales/lv.json +51 -9
  60. package/locales/mk.json +52 -10
  61. package/locales/ml.json +53 -11
  62. package/locales/mn.json +52 -10
  63. package/locales/mr.json +52 -10
  64. package/locales/ms.json +52 -10
  65. package/locales/my.json +51 -9
  66. package/locales/ne.json +52 -10
  67. package/locales/nl.json +52 -10
  68. package/locales/no.json +52 -10
  69. package/locales/or.json +53 -11
  70. package/locales/pa.json +53 -11
  71. package/locales/pl.json +51 -9
  72. package/locales/pt-PT.json +52 -10
  73. package/locales/pt.json +52 -10
  74. package/locales/ro.json +52 -10
  75. package/locales/ru.json +53 -11
  76. package/locales/si.json +52 -10
  77. package/locales/sk.json +51 -9
  78. package/locales/sl.json +51 -9
  79. package/locales/sq.json +52 -10
  80. package/locales/sr-Latn.json +52 -10
  81. package/locales/sr.json +52 -10
  82. package/locales/sv.json +52 -10
  83. package/locales/sw.json +51 -9
  84. package/locales/ta.json +52 -10
  85. package/locales/te.json +52 -10
  86. package/locales/th.json +51 -9
  87. package/locales/tr.json +52 -10
  88. package/locales/uk.json +52 -10
  89. package/locales/ur.json +52 -10
  90. package/locales/uz.json +51 -9
  91. package/locales/vi.json +52 -10
  92. package/locales/zh-HK.json +52 -10
  93. package/locales/zh-TW.json +51 -9
  94. package/locales/zh.json +52 -10
  95. package/locales/zu.json +52 -10
  96. package/models/cpu_profile/CPUProfileDataModel.d.ts +4 -2
  97. package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
  98. package/models/cpu_profile/ProfileTreeModel.d.ts +0 -1
  99. package/models/cpu_profile/ProfileTreeModel.js +0 -2
  100. package/models/cpu_profile/ProfileTreeModel.js.map +1 -1
  101. package/models/cpu_profile/cpu_profile.prebundle.d.ts +3 -0
  102. package/models/cpu_profile/cpu_profile.prebundle.js +7 -0
  103. package/models/cpu_profile/cpu_profile.prebundle.js.map +1 -0
  104. package/models/cpu_profile/cpu_profile.prebundle.ts +11 -0
  105. package/models/cpu_profile/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
  106. package/models/trace/LanternComputationData.js +7 -6
  107. package/models/trace/LanternComputationData.js.map +1 -1
  108. package/models/trace/Processor.js +25 -18
  109. package/models/trace/Processor.js.map +1 -1
  110. package/models/trace/devtools_entrypoint-bundle-tsconfig-tsconfig.json +61 -0
  111. package/models/trace/{root-causes/devtools_entrypoint-bundle-typescript-tsconfig.json → extras/devtools_entrypoint-bundle-tsconfig-tsconfig.json} +5 -4
  112. package/models/trace/extras/extras-tsconfig.json +0 -2
  113. package/models/trace/extras/extras.js.map +1 -1
  114. package/models/trace/extras/extras.prebundle.d.ts +7 -0
  115. package/models/trace/extras/extras.prebundle.js +11 -0
  116. package/models/trace/extras/extras.prebundle.js.map +1 -0
  117. package/models/trace/extras/extras.prebundle.ts +11 -0
  118. package/models/trace/handlers/ImagePaintingHandler.d.ts +7 -1
  119. package/models/trace/handlers/ImagePaintingHandler.js +33 -1
  120. package/models/trace/handlers/ImagePaintingHandler.js.map +1 -1
  121. package/models/trace/handlers/MetaHandler.js +2 -0
  122. package/models/trace/handlers/MetaHandler.js.map +1 -1
  123. package/models/trace/handlers/NetworkRequestsHandler.d.ts +0 -5
  124. package/models/trace/handlers/NetworkRequestsHandler.js +61 -20
  125. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
  126. package/models/trace/handlers/SamplesHandler.js +7 -2
  127. package/models/trace/handlers/SamplesHandler.js.map +1 -1
  128. package/models/trace/handlers/ScriptsHandler.js.map +1 -1
  129. package/models/trace/{root-causes/root-causes-tsconfig.json → handlers/devtools_entrypoint-bundle-tsconfig-tsconfig.json} +5 -17
  130. package/models/trace/handlers/handlers.prebundle.d.ts +4 -0
  131. package/models/trace/handlers/handlers.prebundle.js +8 -0
  132. package/models/trace/handlers/handlers.prebundle.js.map +1 -0
  133. package/models/trace/handlers/handlers.prebundle.ts +8 -0
  134. package/models/trace/helpers/SamplesIntegrator.js +8 -13
  135. package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
  136. package/models/trace/helpers/Trace.js +0 -7
  137. package/models/trace/helpers/Trace.js.map +1 -1
  138. package/models/trace/helpers/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
  139. package/models/trace/helpers/helpers.prebundle.d.ts +7 -0
  140. package/models/trace/helpers/helpers.prebundle.js +11 -0
  141. package/models/trace/helpers/helpers.prebundle.js.map +1 -0
  142. package/models/trace/helpers/helpers.prebundle.ts +11 -0
  143. package/models/trace/insights/CLSCulprits.d.ts +27 -7
  144. package/models/trace/insights/CLSCulprits.js +34 -15
  145. package/models/trace/insights/CLSCulprits.js.map +1 -1
  146. package/models/trace/insights/Common.d.ts +1 -1
  147. package/models/trace/insights/Common.js +3 -3
  148. package/models/trace/insights/Common.js.map +1 -1
  149. package/models/trace/insights/DOMSize.d.ts +26 -1
  150. package/models/trace/insights/DOMSize.js +34 -1
  151. package/models/trace/insights/DOMSize.js.map +1 -1
  152. package/models/trace/insights/DocumentLatency.d.ts +2 -2
  153. package/models/trace/insights/DocumentLatency.js +3 -3
  154. package/models/trace/insights/DocumentLatency.js.map +1 -1
  155. package/models/trace/insights/ForcedReflow.d.ts +1 -1
  156. package/models/trace/insights/ForcedReflow.js +1 -1
  157. package/models/trace/insights/ForcedReflow.js.map +1 -1
  158. package/models/trace/insights/{InteractionToNextPaint.d.ts → INPBreakdown.d.ts} +8 -8
  159. package/models/trace/insights/{InteractionToNextPaint.js → INPBreakdown.js} +10 -10
  160. package/models/trace/insights/INPBreakdown.js.map +1 -0
  161. package/models/trace/insights/ImageDelivery.js +18 -7
  162. package/models/trace/insights/ImageDelivery.js.map +1 -1
  163. package/models/trace/insights/{LCPPhases.d.ts → LCPBreakdown.d.ts} +26 -22
  164. package/models/trace/insights/{LCPPhases.js → LCPBreakdown.js} +56 -46
  165. package/models/trace/insights/LCPBreakdown.js.map +1 -0
  166. package/models/trace/insights/LCPDiscovery.js +1 -1
  167. package/models/trace/insights/LCPDiscovery.js.map +1 -1
  168. package/models/trace/insights/Models.d.ts +2 -2
  169. package/models/trace/insights/Models.js +2 -2
  170. package/models/trace/insights/Models.js.map +1 -1
  171. package/models/trace/insights/NetworkDependencyTree.d.ts +34 -8
  172. package/models/trace/insights/NetworkDependencyTree.js +144 -18
  173. package/models/trace/insights/NetworkDependencyTree.js.map +1 -1
  174. package/models/trace/insights/Viewport.d.ts +8 -2
  175. package/models/trace/insights/Viewport.js +16 -1
  176. package/models/trace/insights/Viewport.js.map +1 -1
  177. package/models/trace/insights/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
  178. package/models/trace/insights/insights-tsconfig.json +2 -2
  179. package/models/trace/insights/insights.prebundle.d.ts +4 -0
  180. package/models/trace/insights/insights.prebundle.js +8 -0
  181. package/models/trace/insights/insights.prebundle.js.map +1 -0
  182. package/models/trace/insights/insights.prebundle.ts +8 -0
  183. package/models/trace/insights/types.d.ts +2 -2
  184. package/models/trace/insights/types.js +2 -2
  185. package/models/trace/insights/types.js.map +1 -1
  186. package/models/trace/lantern/core/core.prebundle.d.ts +2 -0
  187. package/models/trace/lantern/core/core.prebundle.js +6 -0
  188. package/models/trace/lantern/core/core.prebundle.js.map +1 -0
  189. package/models/trace/lantern/core/core.prebundle.ts +6 -0
  190. package/models/trace/lantern/core/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
  191. package/models/trace/lantern/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
  192. package/models/trace/lantern/graph/BaseNode.d.ts +5 -2
  193. package/models/trace/lantern/graph/BaseNode.js +8 -5
  194. package/models/trace/lantern/graph/BaseNode.js.map +1 -1
  195. package/models/trace/lantern/graph/PageDependencyGraph.js +46 -3
  196. package/models/trace/lantern/graph/PageDependencyGraph.js.map +1 -1
  197. package/models/trace/lantern/graph/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
  198. package/models/trace/lantern/graph/graph.prebundle.d.ts +4 -0
  199. package/models/trace/lantern/graph/graph.prebundle.js +8 -0
  200. package/models/trace/lantern/graph/graph.prebundle.js.map +1 -0
  201. package/models/trace/lantern/graph/graph.prebundle.ts +8 -0
  202. package/models/trace/lantern/lantern.prebundle.d.ts +6 -0
  203. package/models/trace/lantern/lantern.prebundle.js +10 -0
  204. package/models/trace/lantern/lantern.prebundle.js.map +1 -0
  205. package/models/trace/lantern/lantern.prebundle.ts +17 -0
  206. package/models/trace/lantern/metrics/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
  207. package/models/trace/lantern/metrics/metrics.prebundle.d.ts +8 -0
  208. package/models/trace/lantern/metrics/metrics.prebundle.js +12 -0
  209. package/models/trace/lantern/metrics/metrics.prebundle.js.map +1 -0
  210. package/models/trace/lantern/metrics/metrics.prebundle.ts +12 -0
  211. package/models/trace/lantern/simulation/Simulator.js +1 -1
  212. package/models/trace/lantern/simulation/Simulator.js.map +1 -1
  213. package/models/trace/lantern/simulation/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
  214. package/models/trace/lantern/simulation/simulation.prebundle.d.ts +6 -0
  215. package/models/trace/lantern/simulation/simulation.prebundle.js +10 -0
  216. package/models/trace/lantern/simulation/simulation.prebundle.js.map +1 -0
  217. package/models/trace/lantern/simulation/simulation.prebundle.ts +10 -0
  218. package/models/trace/lantern/types/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
  219. package/models/trace/lantern/types/types.prebundle.d.ts +1 -0
  220. package/models/trace/lantern/types/types.prebundle.js +5 -0
  221. package/models/trace/lantern/types/types.prebundle.js.map +1 -0
  222. package/models/trace/lantern/types/types.prebundle.ts +5 -0
  223. package/models/trace/trace-tsconfig.json +0 -1
  224. package/models/trace/trace.d.ts +1 -2
  225. package/models/trace/trace.js +1 -2
  226. package/models/trace/trace.js.map +1 -1
  227. package/models/trace/trace.prebundle.d.ts +10 -0
  228. package/models/trace/trace.prebundle.js +14 -0
  229. package/models/trace/trace.prebundle.js.map +1 -0
  230. package/models/trace/trace.prebundle.ts +25 -0
  231. package/models/trace/types/Extensions.d.ts +6 -1
  232. package/models/trace/types/Extensions.js.map +1 -1
  233. package/models/trace/types/File.d.ts +16 -1
  234. package/models/trace/types/File.js.map +1 -1
  235. package/models/trace/types/Timing.js.map +1 -1
  236. package/models/trace/types/TraceEvents.d.ts +7 -4
  237. package/models/trace/types/TraceEvents.js +4 -3
  238. package/models/trace/types/TraceEvents.js.map +1 -1
  239. package/models/trace/types/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
  240. package/models/trace/types/types.prebundle.d.ts +5 -0
  241. package/models/trace/types/types.prebundle.js +9 -0
  242. package/models/trace/types/types.prebundle.js.map +1 -0
  243. package/models/trace/types/types.prebundle.ts +9 -0
  244. package/package.json +1 -1
  245. package/test/test-trace-engine.mjs +2 -2
  246. package/core/platform/ServerTiming.d.ts +0 -31
  247. package/core/platform/ServerTiming.js +0 -212
  248. package/core/platform/ServerTiming.js.map +0 -1
  249. package/models/trace/TracingManager.js.map +0 -1
  250. package/models/trace/extras/FetchNodes.d.ts +0 -61
  251. package/models/trace/extras/FetchNodes.js +0 -214
  252. package/models/trace/extras/FetchNodes.js.map +0 -1
  253. package/models/trace/extras/Metadata.d.ts +0 -3
  254. package/models/trace/extras/Metadata.js +0 -71
  255. package/models/trace/extras/Metadata.js.map +0 -1
  256. package/models/trace/extras/TimelineJSProfile.d.ts +0 -13
  257. package/models/trace/extras/TimelineJSProfile.js +0 -55
  258. package/models/trace/extras/TimelineJSProfile.js.map +0 -1
  259. package/models/trace/extras/URLForEntry.d.ts +0 -12
  260. package/models/trace/extras/URLForEntry.js +0 -43
  261. package/models/trace/extras/URLForEntry.js.map +0 -1
  262. package/models/trace/handlers/ServerTimingsHandler.d.ts +0 -9
  263. package/models/trace/handlers/ServerTimingsHandler.js +0 -106
  264. package/models/trace/handlers/ServerTimingsHandler.js.map +0 -1
  265. package/models/trace/insights/CumulativeLayoutShift.d.ts +0 -57
  266. package/models/trace/insights/CumulativeLayoutShift.js +0 -335
  267. package/models/trace/insights/CumulativeLayoutShift.js.map +0 -1
  268. package/models/trace/insights/InsightRunners.d.ts +0 -9
  269. package/models/trace/insights/InsightRunners.js +0 -13
  270. package/models/trace/insights/InsightRunners.js.map +0 -1
  271. package/models/trace/insights/InteractionToNextPaint.js.map +0 -1
  272. package/models/trace/insights/LCPPhases.js.map +0 -1
  273. package/models/trace/insights/LargestContentfulPaint.d.ts +0 -38
  274. package/models/trace/insights/LargestContentfulPaint.js +0 -113
  275. package/models/trace/insights/LargestContentfulPaint.js.map +0 -1
  276. package/models/trace/insights/ThirdPartyWeb.d.ts +0 -13
  277. package/models/trace/insights/ThirdPartyWeb.js +0 -42
  278. package/models/trace/insights/ThirdPartyWeb.js.map +0 -1
  279. package/models/trace/root-causes/LayoutShift.d.ts +0 -125
  280. package/models/trace/root-causes/LayoutShift.js +0 -519
  281. package/models/trace/root-causes/LayoutShift.js.map +0 -1
  282. package/models/trace/root-causes/RootCauses.d.ts +0 -15
  283. package/models/trace/root-causes/RootCauses.js +0 -12
  284. package/models/trace/root-causes/RootCauses.js.map +0 -1
  285. package/models/trace/root-causes/bundle-tsconfig.json +0 -1
  286. package/models/trace/root-causes/root-causes.d.ts +0 -1
  287. package/models/trace/root-causes/root-causes.js +0 -5
  288. package/models/trace/root-causes/root-causes.js.map +0 -1
@@ -1,113 +0,0 @@
1
- // Copyright 2024 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 Handlers from '../handlers/handlers.js';
5
- import * as Helpers from '../helpers/helpers.js';
6
- import * as Types from '../types/types.js';
7
- import { findLCPRequest } from './Common.js';
8
- import { InsightWarning } from './types.js';
9
- export function deps() {
10
- return ['NetworkRequests', 'PageLoadMetrics', 'LargestImagePaint', 'Meta'];
11
- }
12
- function anyValuesNaN(...values) {
13
- return values.some(v => Number.isNaN(v));
14
- }
15
- /**
16
- * Calculates the 4 phases of an LCP and the timings of each.
17
- * Will return `null` if any required values were missing. We don't ever expect
18
- * them to be missing on newer traces, but old trace files may lack some of the
19
- * data we rely on, so we want to handle that case.
20
- */
21
- function breakdownPhases(nav, docRequest, lcpMs, lcpRequest) {
22
- const docReqTiming = docRequest.args.data.timing;
23
- if (!docReqTiming) {
24
- throw new Error('no timing for document request');
25
- }
26
- const firstDocByteTs = Helpers.Timing.secondsToMicroseconds(docReqTiming.requestTime) +
27
- Helpers.Timing.millisecondsToMicroseconds(docReqTiming.receiveHeadersStart);
28
- const firstDocByteTiming = Types.Timing.MicroSeconds(firstDocByteTs - nav.ts);
29
- const ttfb = Helpers.Timing.microSecondsToMilliseconds(firstDocByteTiming);
30
- let renderDelay = Types.Timing.MilliSeconds(lcpMs - ttfb);
31
- if (!lcpRequest) {
32
- if (anyValuesNaN(ttfb, renderDelay)) {
33
- return null;
34
- }
35
- return { ttfb, renderDelay };
36
- }
37
- const lcpStartTs = Types.Timing.MicroSeconds(lcpRequest.ts - nav.ts);
38
- const requestStart = Helpers.Timing.microSecondsToMilliseconds(lcpStartTs);
39
- const lcpReqEndTs = Types.Timing.MicroSeconds(lcpRequest.args.data.syntheticData.finishTime - nav.ts);
40
- const requestEnd = Helpers.Timing.microSecondsToMilliseconds(lcpReqEndTs);
41
- const loadDelay = Types.Timing.MilliSeconds(requestStart - ttfb);
42
- const loadTime = Types.Timing.MilliSeconds(requestEnd - requestStart);
43
- renderDelay = Types.Timing.MilliSeconds(lcpMs - requestEnd);
44
- if (anyValuesNaN(ttfb, loadDelay, loadTime, renderDelay)) {
45
- return null;
46
- }
47
- return {
48
- ttfb,
49
- loadDelay,
50
- loadTime,
51
- renderDelay,
52
- };
53
- }
54
- export function generateInsight(parsedTrace, context) {
55
- if (!context.navigation) {
56
- return {};
57
- }
58
- const networkRequests = parsedTrace.NetworkRequests;
59
- const frameMetrics = parsedTrace.PageLoadMetrics.metricScoresByFrameId.get(context.frameId);
60
- if (!frameMetrics) {
61
- throw new Error('no frame metrics');
62
- }
63
- const navMetrics = frameMetrics.get(context.navigationId);
64
- if (!navMetrics) {
65
- throw new Error('no navigation metrics');
66
- }
67
- const metricScore = navMetrics.get("LCP" /* Handlers.ModelHandlers.PageLoadMetrics.MetricName.LCP */);
68
- const lcpEvent = metricScore?.event;
69
- if (!lcpEvent || !Types.Events.isLargestContentfulPaintCandidate(lcpEvent)) {
70
- return { warnings: [InsightWarning.NO_LCP] };
71
- }
72
- // This helps calculate the phases.
73
- const lcpMs = Helpers.Timing.microSecondsToMilliseconds(metricScore.timing);
74
- // This helps position things on the timeline's UI accurately for a trace.
75
- const lcpTs = metricScore.event?.ts ? Helpers.Timing.microSecondsToMilliseconds(metricScore.event?.ts) : undefined;
76
- const lcpRequest = findLCPRequest(parsedTrace, context, lcpEvent);
77
- const docRequest = networkRequests.byTime.find(req => req.args.data.requestId === context.navigationId);
78
- if (!docRequest) {
79
- return { lcpMs, lcpTs, lcpEvent, warnings: [InsightWarning.NO_DOCUMENT_REQUEST] };
80
- }
81
- if (!lcpRequest) {
82
- return {
83
- lcpMs,
84
- lcpTs,
85
- lcpEvent,
86
- phases: breakdownPhases(context.navigation, docRequest, lcpMs, lcpRequest) ?? undefined,
87
- };
88
- }
89
- const initiatorUrl = lcpRequest.args.data.initiator?.url;
90
- // TODO(b/372319476): Explore using trace event HTMLDocumentParser::FetchQueuedPreloads to determine if the request
91
- // is discovered by the preload scanner.
92
- const initiatedByMainDoc = lcpRequest?.args.data.initiator?.type === 'parser' && docRequest.args.data.url === initiatorUrl;
93
- const imgPreloadedOrFoundInHTML = lcpRequest?.args.data.isLinkPreload || initiatedByMainDoc;
94
- const imageLoadingAttr = lcpEvent.args.data?.loadingAttr;
95
- const imageFetchPriorityHint = lcpRequest?.args.data.fetchPriorityHint;
96
- // This is the earliest discovery time an LCP request could have - it's TTFB.
97
- const earliestDiscoveryTime = docRequest && docRequest.args.data.timing ?
98
- Helpers.Timing.secondsToMicroseconds(docRequest.args.data.timing.requestTime) +
99
- Helpers.Timing.millisecondsToMicroseconds(docRequest.args.data.timing.receiveHeadersStart) :
100
- undefined;
101
- return {
102
- lcpMs,
103
- lcpTs,
104
- lcpEvent,
105
- phases: breakdownPhases(context.navigation, docRequest, lcpMs, lcpRequest) ?? undefined,
106
- shouldRemoveLazyLoading: imageLoadingAttr === 'lazy',
107
- shouldIncreasePriorityHint: imageFetchPriorityHint !== 'high',
108
- shouldPreloadImage: !imgPreloadedOrFoundInHTML,
109
- lcpRequest,
110
- earliestDiscoveryTimeTs: earliestDiscoveryTime ? Types.Timing.MicroSeconds(earliestDiscoveryTime) : undefined,
111
- };
112
- }
113
- //# sourceMappingURL=LargestContentfulPaint.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LargestContentfulPaint.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/LargestContentfulPaint.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC;AAC3C,OAAO,EAA6C,cAAc,EAAoB,MAAM,YAAY,CAAC;AAEzG,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,CAAC,CAAC;AAC7E,CAAC;AAqCD,SAAS,YAAY,CAAC,GAAG,MAAgB;IACvC,OAAO,MAAM,CAAC,IAAI,CAAC,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","sourcesContent":["// Copyright 2024 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\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {findLCPRequest} from './Common.js';\nimport {type InsightResult, type InsightSetContext, InsightWarning, type RequiredData} from './types.js';\n\nexport function deps(): ['NetworkRequests', 'PageLoadMetrics', 'LargestImagePaint', 'Meta'] {\n return ['NetworkRequests', 'PageLoadMetrics', 'LargestImagePaint', 'Meta'];\n}\n\ninterface LCPPhases {\n /**\n * The time between when the user initiates loading the page until when\n * the browser receives the first byte of the html response.\n */\n ttfb: Types.Timing.MilliSeconds;\n /**\n * The time between ttfb and the LCP request request being started.\n * For a text LCP, this is undefined given no request is loaded.\n */\n loadDelay?: Types.Timing.MilliSeconds;\n /**\n * The time it takes to load the LCP request.\n */\n loadTime?: Types.Timing.MilliSeconds;\n /**\n * The time between when the LCP request finishes loading and when\n * the LCP element is rendered.\n */\n renderDelay: Types.Timing.MilliSeconds;\n}\n\nexport type LCPInsightResult = InsightResult<{\n lcpMs?: Types.Timing.MilliSeconds,\n lcpTs?: Types.Timing.MilliSeconds,\n lcpEvent?: Types.Events.LargestContentfulPaintCandidate,\n phases?: LCPPhases,\n shouldRemoveLazyLoading?: boolean,\n shouldIncreasePriorityHint?: boolean,\n shouldPreloadImage?: boolean,\n /** The network request for the LCP image, if there was one. */\n lcpRequest?: Types.Events.SyntheticNetworkRequest,\n earliestDiscoveryTimeTs?: Types.Timing.MicroSeconds,\n}>;\n\nfunction anyValuesNaN(...values: number[]): boolean {\n return values.some(v => Number.isNaN(v));\n}\n/**\n * Calculates the 4 phases of an LCP and the timings of each.\n * Will return `null` if any required values were missing. We don't ever expect\n * them to be missing on newer traces, but old trace files may lack some of the\n * data we rely on, so we want to handle that case.\n */\nfunction breakdownPhases(\n nav: Types.Events.NavigationStart, docRequest: Types.Events.SyntheticNetworkRequest,\n lcpMs: Types.Timing.MilliSeconds, lcpRequest: Types.Events.SyntheticNetworkRequest|null): LCPPhases|null {\n const docReqTiming = docRequest.args.data.timing;\n if (!docReqTiming) {\n throw new Error('no timing for document request');\n }\n const firstDocByteTs = Helpers.Timing.secondsToMicroseconds(docReqTiming.requestTime) +\n Helpers.Timing.millisecondsToMicroseconds(docReqTiming.receiveHeadersStart);\n\n const firstDocByteTiming = Types.Timing.MicroSeconds(firstDocByteTs - nav.ts);\n const ttfb = Helpers.Timing.microSecondsToMilliseconds(firstDocByteTiming);\n let renderDelay = Types.Timing.MilliSeconds(lcpMs - ttfb);\n\n if (!lcpRequest) {\n if (anyValuesNaN(ttfb, renderDelay)) {\n return null;\n }\n return {ttfb, renderDelay};\n }\n\n const lcpStartTs = Types.Timing.MicroSeconds(lcpRequest.ts - nav.ts);\n const requestStart = Helpers.Timing.microSecondsToMilliseconds(lcpStartTs);\n\n const lcpReqEndTs = Types.Timing.MicroSeconds(lcpRequest.args.data.syntheticData.finishTime - nav.ts);\n const requestEnd = Helpers.Timing.microSecondsToMilliseconds(lcpReqEndTs);\n\n const loadDelay = Types.Timing.MilliSeconds(requestStart - ttfb);\n const loadTime = Types.Timing.MilliSeconds(requestEnd - requestStart);\n renderDelay = Types.Timing.MilliSeconds(lcpMs - requestEnd);\n if (anyValuesNaN(ttfb, loadDelay, loadTime, renderDelay)) {\n return null;\n }\n\n return {\n ttfb,\n loadDelay,\n loadTime,\n renderDelay,\n };\n}\n\nexport function generateInsight(parsedTrace: RequiredData<typeof deps>, context: InsightSetContext): LCPInsightResult {\n if (!context.navigation) {\n return {};\n }\n\n const networkRequests = parsedTrace.NetworkRequests;\n\n const frameMetrics = parsedTrace.PageLoadMetrics.metricScoresByFrameId.get(context.frameId);\n if (!frameMetrics) {\n throw new Error('no frame metrics');\n }\n\n const navMetrics = frameMetrics.get(context.navigationId);\n if (!navMetrics) {\n throw new Error('no navigation metrics');\n }\n const metricScore = navMetrics.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.LCP);\n const lcpEvent = metricScore?.event;\n if (!lcpEvent || !Types.Events.isLargestContentfulPaintCandidate(lcpEvent)) {\n return {warnings: [InsightWarning.NO_LCP]};\n }\n\n // This helps calculate the phases.\n const lcpMs = Helpers.Timing.microSecondsToMilliseconds(metricScore.timing);\n // This helps position things on the timeline's UI accurately for a trace.\n const lcpTs = metricScore.event?.ts ? Helpers.Timing.microSecondsToMilliseconds(metricScore.event?.ts) : undefined;\n const lcpRequest = findLCPRequest(parsedTrace, context, lcpEvent);\n const docRequest = networkRequests.byTime.find(req => req.args.data.requestId === context.navigationId);\n if (!docRequest) {\n return {lcpMs, lcpTs, lcpEvent, warnings: [InsightWarning.NO_DOCUMENT_REQUEST]};\n }\n\n if (!lcpRequest) {\n return {\n lcpMs,\n lcpTs,\n lcpEvent,\n phases: breakdownPhases(context.navigation, docRequest, lcpMs, lcpRequest) ?? undefined,\n };\n }\n\n const initiatorUrl = lcpRequest.args.data.initiator?.url;\n // TODO(b/372319476): Explore using trace event HTMLDocumentParser::FetchQueuedPreloads to determine if the request\n // is discovered by the preload scanner.\n const initiatedByMainDoc =\n lcpRequest?.args.data.initiator?.type === 'parser' && docRequest.args.data.url === initiatorUrl;\n const imgPreloadedOrFoundInHTML = lcpRequest?.args.data.isLinkPreload || initiatedByMainDoc;\n\n const imageLoadingAttr = lcpEvent.args.data?.loadingAttr;\n const imageFetchPriorityHint = lcpRequest?.args.data.fetchPriorityHint;\n // This is the earliest discovery time an LCP request could have - it's TTFB.\n const earliestDiscoveryTime = docRequest && docRequest.args.data.timing ?\n Helpers.Timing.secondsToMicroseconds(docRequest.args.data.timing.requestTime) +\n Helpers.Timing.millisecondsToMicroseconds(docRequest.args.data.timing.receiveHeadersStart) :\n undefined;\n\n return {\n lcpMs,\n lcpTs,\n lcpEvent,\n phases: breakdownPhases(context.navigation, docRequest, lcpMs, lcpRequest) ?? undefined,\n shouldRemoveLazyLoading: imageLoadingAttr === 'lazy',\n shouldIncreasePriorityHint: imageFetchPriorityHint !== 'high',\n shouldPreloadImage: !imgPreloadedOrFoundInHTML,\n lcpRequest,\n earliestDiscoveryTimeTs: earliestDiscoveryTime ? Types.Timing.MicroSeconds(earliestDiscoveryTime) : undefined,\n };\n}\n"]}
@@ -1,13 +0,0 @@
1
- import * as Extras from '../extras/extras.js';
2
- import type * as Types from '../types/types.js';
3
- import type { InsightResult, InsightSetContext, RequiredData } from './types.js';
4
- export declare function deps(): ['Meta', 'NetworkRequests', 'Renderer', 'ImagePainting'];
5
- export type ThirdPartyWebInsightResult = InsightResult<{
6
- entityByRequest: Map<Types.Events.SyntheticNetworkRequest, Extras.ThirdParties.Entity>;
7
- requestsByEntity: Map<Extras.ThirdParties.Entity, Types.Events.SyntheticNetworkRequest[]>;
8
- summaryByRequest: Map<Types.Events.SyntheticNetworkRequest, Extras.ThirdParties.Summary>;
9
- summaryByEntity: Map<Extras.ThirdParties.Entity, Extras.ThirdParties.Summary>;
10
- /** The entity for this navigation's URL. Any other entity is from a third party. */
11
- firstPartyEntity?: Extras.ThirdParties.Entity;
12
- }>;
13
- export declare function generateInsight(parsedTrace: RequiredData<typeof deps>, context: InsightSetContext): ThirdPartyWebInsightResult;
@@ -1,42 +0,0 @@
1
- // Copyright 2024 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 ThirdPartyWeb from '../../../third_party/third-party-web/third-party-web.js';
5
- import * as Extras from '../extras/extras.js';
6
- import * as Helpers from '../helpers/helpers.js';
7
- export function deps() {
8
- return ['Meta', 'NetworkRequests', 'Renderer', 'ImagePainting'];
9
- }
10
- function getRelatedEvents(summaries, firstPartyEntity) {
11
- const events = [];
12
- for (const [entity, requests] of summaries.requestsByEntity.entries()) {
13
- if (entity !== firstPartyEntity) {
14
- events.push(...requests);
15
- }
16
- }
17
- return events;
18
- }
19
- export function generateInsight(parsedTrace, context) {
20
- const networkRequests = parsedTrace.NetworkRequests.byTime.filter(event => {
21
- if (!context.navigation) {
22
- return false;
23
- }
24
- if (event.args.data.frame !== context.frameId) {
25
- return false;
26
- }
27
- return Helpers.Timing.eventIsInBounds(event, context.bounds);
28
- });
29
- const { entityByRequest, madeUpEntityCache, summaries } = Extras.ThirdParties.getSummariesAndEntitiesForTraceBounds(parsedTrace, context.bounds, networkRequests);
30
- const firstPartyUrl = context.navigation?.args.data?.documentLoaderURL ?? parsedTrace.Meta.mainFrameURL;
31
- const firstPartyEntity = ThirdPartyWeb.ThirdPartyWeb.getEntity(firstPartyUrl) ||
32
- Extras.ThirdParties.makeUpEntity(madeUpEntityCache, firstPartyUrl);
33
- return {
34
- relatedEvents: getRelatedEvents(summaries, firstPartyEntity),
35
- entityByRequest,
36
- requestsByEntity: summaries.requestsByEntity,
37
- summaryByRequest: summaries.byRequest,
38
- summaryByEntity: summaries.byEntity,
39
- firstPartyEntity,
40
- };
41
- }
42
- //# sourceMappingURL=ThirdPartyWeb.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ThirdPartyWeb.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/ThirdPartyWeb.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,aAAa,MAAM,yDAAyD,CAAC;AACzF,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAE9C,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAKjD,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;AAClE,CAAC;AAWD,SAAS,gBAAgB,CACrB,SAA0C,EAC1C,gBAAsD;IACxD,MAAM,MAAM,GAAG,EAAE,CAAC;IAElB,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,EAAE,CAAC;QACtE,IAAI,MAAM,KAAK,gBAAgB,EAAE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ACjB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2024 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\nimport * as ThirdPartyWeb from '../../../third_party/third-party-web/third-party-web.js';\nimport * as Extras from '../extras/extras.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Types from '../types/types.js';\n\nimport type {InsightResult, InsightSetContext, RequiredData} from './types.js';\n\nexport function deps(): ['Meta', 'NetworkRequests', 'Renderer', 'ImagePainting'] {\n return ['Meta', 'NetworkRequests', 'Renderer', 'ImagePainting'];\n}\n\nexport type ThirdPartyWebInsightResult = InsightResult<{\n entityByRequest: Map<Types.Events.SyntheticNetworkRequest, Extras.ThirdParties.Entity>,\n requestsByEntity: Map<Extras.ThirdParties.Entity, Types.Events.SyntheticNetworkRequest[]>,\n summaryByRequest: Map<Types.Events.SyntheticNetworkRequest, Extras.ThirdParties.Summary>,\n summaryByEntity: Map<Extras.ThirdParties.Entity, Extras.ThirdParties.Summary>,\n /** The entity for this navigation's URL. Any other entity is from a third party. */\n firstPartyEntity?: Extras.ThirdParties.Entity,\n}>;\n\nfunction getRelatedEvents(\n summaries: Extras.ThirdParties.SummaryMaps,\n firstPartyEntity: Extras.ThirdParties.Entity|undefined): Types.Events.Event[] {\n const events = [];\n\n for (const [entity, requests] of summaries.requestsByEntity.entries()) {\n if (entity !== firstPartyEntity) {\n events.push(...requests);\n }\n }\n\n return events;\n}\n\nexport function generateInsight(\n parsedTrace: RequiredData<typeof deps>, context: InsightSetContext): ThirdPartyWebInsightResult {\n const networkRequests = parsedTrace.NetworkRequests.byTime.filter(event => {\n if (!context.navigation) {\n return false;\n }\n\n if (event.args.data.frame !== context.frameId) {\n return false;\n }\n\n return Helpers.Timing.eventIsInBounds(event, context.bounds);\n });\n\n const {entityByRequest, madeUpEntityCache, summaries} = Extras.ThirdParties.getSummariesAndEntitiesForTraceBounds(\n parsedTrace as Handlers.Types.ParsedTrace, context.bounds, networkRequests);\n\n const firstPartyUrl = context.navigation?.args.data?.documentLoaderURL ?? parsedTrace.Meta.mainFrameURL;\n const firstPartyEntity = ThirdPartyWeb.ThirdPartyWeb.getEntity(firstPartyUrl) ||\n Extras.ThirdParties.makeUpEntity(madeUpEntityCache, firstPartyUrl);\n\n return {\n relatedEvents: getRelatedEvents(summaries, firstPartyEntity),\n entityByRequest,\n requestsByEntity: summaries.requestsByEntity,\n summaryByRequest: summaries.byRequest,\n summaryByEntity: summaries.byEntity,\n firstPartyEntity,\n };\n}\n"]}
@@ -1,125 +0,0 @@
1
- import type * as Protocol from '../../../generated/protocol.js';
2
- import type { ParsedTrace } from '../handlers/types.js';
3
- import * as Types from '../types/types.js';
4
- import type { RootCauseProtocolInterface } from './RootCauses.js';
5
- export type CSSDimensions = {
6
- width?: string;
7
- height?: string;
8
- aspectRatio?: string;
9
- };
10
- export interface UnsizedMedia {
11
- node: Protocol.DOM.Node;
12
- authoredDimensions?: CSSDimensions;
13
- computedDimensions: CSSDimensions;
14
- }
15
- export interface InjectedIframe {
16
- iframe: Protocol.DOM.Node;
17
- }
18
- export interface RootCauseRequest {
19
- request: Types.Events.SyntheticNetworkRequest;
20
- initiator?: Protocol.Network.Initiator;
21
- }
22
- export interface FontChange extends RootCauseRequest {
23
- fontFace: Protocol.CSS.FontFace;
24
- }
25
- export interface RenderBlockingRequest extends RootCauseRequest {
26
- }
27
- export interface LayoutShiftRootCausesData {
28
- unsizedMedia: UnsizedMedia[];
29
- iframes: InjectedIframe[];
30
- fontChanges: FontChange[];
31
- renderBlockingRequests: RenderBlockingRequest[];
32
- scriptStackTrace: Types.Events.CallFrame[];
33
- }
34
- interface Options {
35
- /** Checking iframe root causes can be an expensive operation, so it is disabled by default. */
36
- enableIframeRootCauses?: boolean;
37
- }
38
- export declare class LayoutShiftRootCauses {
39
- #private;
40
- constructor(protocolInterface: RootCauseProtocolInterface, options?: Options);
41
- /**
42
- * Calculates the potential root causes for a given layout shift event. Once
43
- * calculated, this data is cached.
44
- * Note: because you need all layout shift data at once to calculate these
45
- * correctly, this function will parse the root causes for _all_ layout shift
46
- * events the first time that it's called. That then populates the cache for
47
- * each shift, so any subsequent calls are just a constant lookup.
48
- */
49
- rootCausesForEvent(modelData: ParsedTrace, event: Types.Events.LayoutShift): Promise<Readonly<LayoutShiftRootCausesData> | null>;
50
- /**
51
- * Determines potential root causes for shifts
52
- */
53
- blameShifts(layoutShifts: Types.Events.LayoutShift[], modelData: ParsedTrace): Promise<void>;
54
- /**
55
- * "LayoutInvalidations" are a set of trace events dispatched in Blink under the name
56
- * "layoutInvalidationTracking", which track invalidations on the "Layout"stage of the
57
- * rendering pipeline. This function utilizes this event to flag potential root causes
58
- * to layout shifts.
59
- */
60
- linkShiftsToLayoutInvalidations(layoutShifts: Types.Events.LayoutShift[], modelData: ParsedTrace): Promise<void>;
61
- /**
62
- * For every shift looks up the initiator of its corresponding Layout event. This initiator
63
- * is assigned by the RendererHandler and contains the stack trace of the point in a script
64
- * that caused a style recalculation or a relayout. This stack trace is added to the shift's
65
- * potential root causes.
66
- * Note that a Layout cannot always be linked to a script, in that case, we cannot add a
67
- * "script causing reflow" as a potential root cause to the corresponding shift.
68
- */
69
- linkShiftsToLayoutEvents(layoutShifts: Types.Events.LayoutShift[], modelData: ParsedTrace): void;
70
- /**
71
- * Given a LayoutInvalidation trace event, determines if it was dispatched
72
- * because a media element without dimensions was resized.
73
- */
74
- getUnsizedMediaRootCause(layoutInvalidation: Types.Events.LayoutInvalidationTracking, layoutInvalidationNodeId: Protocol.DOM.NodeId): Promise<UnsizedMedia | null>;
75
- /**
76
- * Given a LayoutInvalidation trace event, determines if it was dispatched
77
- * because a node, which is an ancestor to an iframe, was injected.
78
- */
79
- getIframeRootCause(layoutInvalidation: Types.Events.LayoutInvalidationTracking, layoutInvalidationNodeId: Protocol.DOM.NodeId): Promise<InjectedIframe | null>;
80
- getNodeDetails(nodeId: Protocol.DOM.NodeId): Promise<Protocol.DOM.Node | null>;
81
- /**
82
- * Given a layout invalidation event and a sorted array, returns the subset of requests that arrived within a
83
- * 500ms window before the layout invalidation.
84
- */
85
- requestsInInvalidationWindow(layoutInvalidation: Types.Events.LayoutInvalidationTracking | Types.Events.ScheduleStyleInvalidationTracking, modelData: ParsedTrace): RootCauseRequest[];
86
- /**
87
- * Given a LayoutInvalidation trace event, determines if it was dispatched
88
- * because fonts were changed and if so returns the information of all network
89
- * request with which the fonts were possibly fetched, if any. The computed
90
- * network requests are cached for the corresponding prepaint event, meaning
91
- * that other LayoutInvalidation events that correspond to the same prepaint
92
- * are not processed and the cached network requests for the prepaint is
93
- * returned instead.
94
- */
95
- getFontChangeRootCause(layoutInvalidation: Types.Events.LayoutInvalidationTracking | Types.Events.ScheduleStyleInvalidationTracking, nextPrePaint: Types.Events.PrePaint, modelData: ParsedTrace): FontChange[] | null;
96
- /**
97
- * Given the requests that arrived within a 500ms window before the layout invalidation, returns the font
98
- * requests of them.
99
- */
100
- getFontRequestsInInvalidationWindow(requestsInInvalidationWindow: RootCauseRequest[]): FontChange[];
101
- /**
102
- * Given a LayoutInvalidation trace event, determines if it arrived within a 500ms window before the layout
103
- * invalidation and if so returns the information of all network request, if any. The computed network
104
- * requests are cached for the corresponding prepaint event, meaning that other LayoutInvalidation events
105
- * that correspond to the same prepaint are not processed and the cached network requests for the prepaint is
106
- * returned instead.
107
- */
108
- getRenderBlockRootCause(layoutInvalidation: Types.Events.LayoutInvalidationTracking | Types.Events.ScheduleStyleInvalidationTracking, nextPrePaint: Types.Events.PrePaint, modelData: ParsedTrace): RenderBlockingRequest[] | null;
109
- /**
110
- * Returns a function that retrieves the active value of a given
111
- * CSS property within the matched styles of the param node.
112
- * The first occurence within the matched styles is returned and the
113
- * value is looked up in the following order, which follows CSS
114
- * specificity:
115
- * 1. Inline styles.
116
- * 2. CSS rules matching this node, from all applicable stylesheets.
117
- * 3. Attribute defined styles.
118
- */
119
- nodeMatchedStylesPropertyGetter(node: Protocol.DOM.Node): Promise<((property: string) => string | null)>;
120
- /**
121
- * Returns the CSS dimensions set to the node from its matched styles.
122
- */
123
- getNodeAuthoredDimensions(node: Protocol.DOM.Node): Promise<CSSDimensions>;
124
- }
125
- export {};