@atlaskit/react-ufo 3.4.14 → 3.5.1

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 (405) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/additional-payload/utils/cache-hit-ratio/index.js +5 -4
  3. package/dist/cjs/additional-payload/utils/lighthouse-metrics/cls/index.js +3 -2
  4. package/dist/cjs/additional-payload/utils/lighthouse-metrics/index.js +6 -6
  5. package/dist/cjs/additional-payload/utils/lighthouse-metrics/tbt/index.js +3 -2
  6. package/dist/cjs/additional-payload/utils/lighthouse-metrics/utils/buffer/index.js +3 -0
  7. package/dist/cjs/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +9 -7
  8. package/dist/cjs/assets/index.js +17 -14
  9. package/dist/cjs/assets/utils.js +9 -8
  10. package/dist/cjs/bundle-eval-timing/index.js +8 -8
  11. package/dist/cjs/coinflip/index.js +5 -3
  12. package/dist/cjs/common/constants.js +3 -2
  13. package/dist/cjs/common/react-ufo-payload-schema.js +5 -0
  14. package/dist/cjs/config/index.js +30 -42
  15. package/dist/cjs/create-experimental-interaction-metrics-payload/index.js +29 -39
  16. package/dist/cjs/create-payload/common/utils/index.js +16 -20
  17. package/dist/cjs/create-payload/index.js +150 -140
  18. package/dist/cjs/create-payload/utils/get-interaction-status.js +5 -3
  19. package/dist/cjs/create-payload/utils/get-page-visibility-up-to-ttai.js +5 -3
  20. package/dist/cjs/create-payload/utils/get-ssr-done-time-value.js +5 -3
  21. package/dist/cjs/create-payload/utils/get-vc-metrics.js +10 -8
  22. package/dist/cjs/create-post-interaction-log-payload/index.js +15 -13
  23. package/dist/cjs/custom-data/index.js +4 -3
  24. package/dist/cjs/custom-mark/index.js +4 -3
  25. package/dist/cjs/custom-spans/index.js +4 -3
  26. package/dist/cjs/custom-timings/index.js +6 -6
  27. package/dist/cjs/experience-trace-id-context/index.js +15 -14
  28. package/dist/cjs/experience-trace-id-context/utils/make-trace-http-request-headers/index.js +3 -2
  29. package/dist/cjs/feature-flags-accessed/common/utils/index.js +11 -10
  30. package/dist/cjs/feature-flags-accessed/index.js +3 -2
  31. package/dist/cjs/generate-id/index.js +5 -3
  32. package/dist/cjs/global-error-handler/index.js +14 -13
  33. package/dist/cjs/initial-page-load-extra-timing/index.js +6 -6
  34. package/dist/cjs/interaction-metrics/index.js +110 -145
  35. package/dist/cjs/interaction-metrics/post-interaction-log.js +10 -0
  36. package/dist/cjs/interaction-metrics-init/index.js +17 -10
  37. package/dist/cjs/interaction-metrics-init/schedule-idle-callback.js +8 -4
  38. package/dist/cjs/resource-timing/common/utils/config.js +10 -10
  39. package/dist/cjs/resource-timing/common/utils/resource-timing-buffer.js +13 -12
  40. package/dist/cjs/resource-timing/main.js +27 -20
  41. package/dist/cjs/resource-timing/utils.js +4 -3
  42. package/dist/cjs/round-number/index.js +3 -2
  43. package/dist/cjs/route-name/index.js +5 -3
  44. package/dist/cjs/segment/schedule-on-paint.js +8 -5
  45. package/dist/cjs/segment/segment.js +9 -5
  46. package/dist/cjs/self-measurements/index.js +261 -0
  47. package/dist/cjs/set-interaction-error/index.js +4 -3
  48. package/dist/cjs/short-id/index.js +5 -3
  49. package/dist/cjs/ssr/index.js +18 -21
  50. package/dist/cjs/trace-interaction/index.js +7 -5
  51. package/dist/cjs/trace-pageload/index.js +7 -6
  52. package/dist/cjs/trace-press/index.js +5 -3
  53. package/dist/cjs/trace-redirect/index.js +5 -3
  54. package/dist/cjs/trace-transition/index.js +6 -4
  55. package/dist/cjs/trace-transition/utils/generate-span-id/index.js +3 -2
  56. package/dist/cjs/trace-transition/utils/set-interaction-active-trace/index.js +3 -2
  57. package/dist/cjs/vc/index.js +17 -6
  58. package/dist/cjs/vc/vc-observer/attachAbortListeners.js +3 -2
  59. package/dist/cjs/vc/vc-observer/getVCRevisionsData.js +41 -26
  60. package/dist/cjs/vc/vc-observer/getViewport.js +6 -6
  61. package/dist/cjs/vc/vc-observer/heatmap/heatmap.js +28 -12
  62. package/dist/cjs/vc/vc-observer/index.js +170 -133
  63. package/dist/cjs/vc/vc-observer/media-wrapper/vc-utils.js +3 -2
  64. package/dist/cjs/vc/vc-observer/observers/editor-lnv/index.js +17 -0
  65. package/dist/cjs/vc/vc-observer/observers/index.js +82 -25
  66. package/dist/cjs/vc/vc-observer/observers/non-visual-styles/is-non-visual-style-mutation.js +5 -8
  67. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +17 -2
  68. package/dist/cjs/vc/vc-observer/revisions/fy25_01.js +7 -7
  69. package/dist/cjs/vc/vc-observer/revisions/fy25_02.js +2 -0
  70. package/dist/cjs/vc/vc-observer/revisions/revisions.js +3 -2
  71. package/dist/cjs/vc/vc-observer-new/entries-timeline/index.js +9 -0
  72. package/dist/cjs/vc/vc-observer-new/get-element-name.js +5 -3
  73. package/dist/cjs/vc/vc-observer-new/get-unique-element-name.js +13 -11
  74. package/dist/cjs/vc/vc-observer-new/index.js +9 -0
  75. package/dist/cjs/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +2 -0
  76. package/dist/cjs/vc/vc-observer-new/metric-calculator/fy25_03/index.js +6 -1
  77. package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js +20 -12
  78. package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/index.js +27 -26
  79. package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/heatmap/heatmap.js +18 -6
  80. package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/heatmap/index.js +27 -14
  81. package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/index.js +10 -8
  82. package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/rect-sweeping-line/calc-union-area.js +50 -40
  83. package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/rect-sweeping-line/index.js +10 -8
  84. package/dist/cjs/vc/vc-observer-new/metric-calculator/utils/get-viewport-height.js +5 -3
  85. package/dist/cjs/vc/vc-observer-new/metric-calculator/utils/get-viewport-width.js +5 -3
  86. package/dist/cjs/vc/vc-observer-new/metric-calculator/utils/is-viewport-entry-data.js +5 -3
  87. package/dist/cjs/vc/vc-observer-new/metric-calculator/utils/task-yield.js +10 -8
  88. package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +15 -7
  89. package/dist/cjs/vc/vc-observer-new/viewport-observer/intersection-observer/index.js +15 -12
  90. package/dist/cjs/vc/vc-observer-new/viewport-observer/mutation-observer/index.js +16 -13
  91. package/dist/cjs/vc/vc-observer-new/viewport-observer/performance-observer/index.js +11 -9
  92. package/dist/cjs/vc/vc-observer-new/window-event-observer/index.js +7 -1
  93. package/dist/es2019/additional-payload/utils/cache-hit-ratio/index.js +6 -5
  94. package/dist/es2019/additional-payload/utils/lighthouse-metrics/cls/index.js +3 -2
  95. package/dist/es2019/additional-payload/utils/lighthouse-metrics/index.js +6 -5
  96. package/dist/es2019/additional-payload/utils/lighthouse-metrics/tbt/index.js +16 -13
  97. package/dist/es2019/additional-payload/utils/lighthouse-metrics/utils/buffer/index.js +3 -0
  98. package/dist/es2019/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +9 -7
  99. package/dist/es2019/assets/index.js +19 -14
  100. package/dist/es2019/assets/utils.js +11 -9
  101. package/dist/es2019/bundle-eval-timing/index.js +7 -6
  102. package/dist/es2019/coinflip/index.js +5 -2
  103. package/dist/es2019/common/constants.js +3 -2
  104. package/dist/es2019/common/react-ufo-payload-schema.js +1 -0
  105. package/dist/es2019/config/index.js +29 -28
  106. package/dist/es2019/create-experimental-interaction-metrics-payload/index.js +18 -15
  107. package/dist/es2019/create-payload/common/utils/index.js +15 -14
  108. package/dist/es2019/create-payload/index.js +87 -71
  109. package/dist/es2019/create-payload/utils/get-interaction-status.js +5 -2
  110. package/dist/es2019/create-payload/utils/get-page-visibility-up-to-ttai.js +4 -2
  111. package/dist/es2019/create-payload/utils/get-ssr-done-time-value.js +4 -2
  112. package/dist/es2019/create-payload/utils/get-vc-metrics.js +4 -2
  113. package/dist/es2019/create-post-interaction-log-payload/index.js +14 -12
  114. package/dist/es2019/custom-data/index.js +3 -2
  115. package/dist/es2019/custom-mark/index.js +3 -2
  116. package/dist/es2019/custom-spans/index.js +3 -2
  117. package/dist/es2019/custom-timings/index.js +5 -4
  118. package/dist/es2019/experience-trace-id-context/index.js +16 -13
  119. package/dist/es2019/experience-trace-id-context/utils/make-trace-http-request-headers/index.js +6 -3
  120. package/dist/es2019/feature-flags-accessed/common/utils/index.js +14 -7
  121. package/dist/es2019/feature-flags-accessed/index.js +3 -2
  122. package/dist/es2019/generate-id/index.js +4 -2
  123. package/dist/es2019/global-error-handler/index.js +15 -12
  124. package/dist/es2019/initial-page-load-extra-timing/index.js +5 -4
  125. package/dist/es2019/interaction-metrics/index.js +109 -108
  126. package/dist/es2019/interaction-metrics/post-interaction-log.js +10 -0
  127. package/dist/es2019/interaction-metrics-init/index.js +17 -10
  128. package/dist/es2019/interaction-metrics-init/schedule-idle-callback.js +7 -3
  129. package/dist/es2019/resource-timing/common/utils/config.js +10 -7
  130. package/dist/es2019/resource-timing/common/utils/resource-timing-buffer.js +14 -11
  131. package/dist/es2019/resource-timing/main.js +33 -18
  132. package/dist/es2019/resource-timing/utils.js +3 -2
  133. package/dist/es2019/round-number/index.js +3 -2
  134. package/dist/es2019/route-name/index.js +4 -2
  135. package/dist/es2019/segment/schedule-on-paint.js +7 -4
  136. package/dist/es2019/segment/segment.js +9 -5
  137. package/dist/es2019/self-measurements/index.js +213 -0
  138. package/dist/es2019/set-interaction-error/index.js +3 -2
  139. package/dist/es2019/short-id/index.js +4 -2
  140. package/dist/es2019/ssr/index.js +21 -16
  141. package/dist/es2019/trace-interaction/index.js +6 -4
  142. package/dist/es2019/trace-pageload/index.js +6 -4
  143. package/dist/es2019/trace-press/index.js +4 -2
  144. package/dist/es2019/trace-redirect/index.js +4 -2
  145. package/dist/es2019/trace-transition/index.js +5 -3
  146. package/dist/es2019/trace-transition/utils/generate-span-id/index.js +4 -1
  147. package/dist/es2019/trace-transition/utils/set-interaction-active-trace/index.js +3 -2
  148. package/dist/es2019/vc/index.js +16 -4
  149. package/dist/es2019/vc/vc-observer/attachAbortListeners.js +3 -2
  150. package/dist/es2019/vc/vc-observer/getVCRevisionsData.js +41 -25
  151. package/dist/es2019/vc/vc-observer/getViewport.js +5 -4
  152. package/dist/es2019/vc/vc-observer/heatmap/heatmap.js +28 -10
  153. package/dist/es2019/vc/vc-observer/index.js +158 -116
  154. package/dist/es2019/vc/vc-observer/media-wrapper/vc-utils.js +3 -2
  155. package/dist/es2019/vc/vc-observer/observers/editor-lnv/index.js +17 -0
  156. package/dist/es2019/vc/vc-observer/observers/index.js +80 -25
  157. package/dist/es2019/vc/vc-observer/observers/non-visual-styles/is-non-visual-style-mutation.js +4 -7
  158. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +17 -2
  159. package/dist/es2019/vc/vc-observer/revisions/fy25_01.js +7 -7
  160. package/dist/es2019/vc/vc-observer/revisions/fy25_02.js +2 -0
  161. package/dist/es2019/vc/vc-observer/revisions/revisions.js +3 -2
  162. package/dist/es2019/vc/vc-observer-new/entries-timeline/index.js +9 -0
  163. package/dist/es2019/vc/vc-observer-new/get-element-name.js +4 -2
  164. package/dist/es2019/vc/vc-observer-new/get-unique-element-name.js +12 -10
  165. package/dist/es2019/vc/vc-observer-new/index.js +9 -0
  166. package/dist/es2019/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +2 -0
  167. package/dist/es2019/vc/vc-observer-new/metric-calculator/fy25_03/index.js +3 -0
  168. package/dist/es2019/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js +14 -4
  169. package/dist/es2019/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/index.js +6 -4
  170. package/dist/es2019/vc/vc-observer-new/metric-calculator/percentile-calc/heatmap/heatmap.js +18 -6
  171. package/dist/es2019/vc/vc-observer-new/metric-calculator/percentile-calc/heatmap/index.js +21 -8
  172. package/dist/es2019/vc/vc-observer-new/metric-calculator/percentile-calc/index.js +4 -2
  173. package/dist/es2019/vc/vc-observer-new/metric-calculator/percentile-calc/rect-sweeping-line/calc-union-area.js +10 -8
  174. package/dist/es2019/vc/vc-observer-new/metric-calculator/percentile-calc/rect-sweeping-line/index.js +4 -2
  175. package/dist/es2019/vc/vc-observer-new/metric-calculator/utils/get-viewport-height.js +4 -2
  176. package/dist/es2019/vc/vc-observer-new/metric-calculator/utils/get-viewport-width.js +4 -2
  177. package/dist/es2019/vc/vc-observer-new/metric-calculator/utils/is-viewport-entry-data.js +4 -2
  178. package/dist/es2019/vc/vc-observer-new/metric-calculator/utils/task-yield.js +5 -2
  179. package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +15 -7
  180. package/dist/es2019/vc/vc-observer-new/viewport-observer/intersection-observer/index.js +15 -12
  181. package/dist/es2019/vc/vc-observer-new/viewport-observer/mutation-observer/index.js +15 -13
  182. package/dist/es2019/vc/vc-observer-new/viewport-observer/performance-observer/index.js +11 -9
  183. package/dist/es2019/vc/vc-observer-new/window-event-observer/index.js +7 -1
  184. package/dist/esm/additional-payload/utils/cache-hit-ratio/index.js +5 -4
  185. package/dist/esm/additional-payload/utils/lighthouse-metrics/cls/index.js +3 -2
  186. package/dist/esm/additional-payload/utils/lighthouse-metrics/index.js +5 -4
  187. package/dist/esm/additional-payload/utils/lighthouse-metrics/tbt/index.js +3 -2
  188. package/dist/esm/additional-payload/utils/lighthouse-metrics/utils/buffer/index.js +3 -0
  189. package/dist/esm/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +9 -7
  190. package/dist/esm/assets/index.js +17 -14
  191. package/dist/esm/assets/utils.js +10 -8
  192. package/dist/esm/bundle-eval-timing/index.js +7 -6
  193. package/dist/esm/coinflip/index.js +5 -2
  194. package/dist/esm/common/constants.js +3 -2
  195. package/dist/esm/common/react-ufo-payload-schema.js +1 -0
  196. package/dist/esm/config/index.js +29 -28
  197. package/dist/esm/create-experimental-interaction-metrics-payload/index.js +28 -35
  198. package/dist/esm/create-payload/common/utils/index.js +15 -14
  199. package/dist/esm/create-payload/index.js +149 -139
  200. package/dist/esm/create-payload/utils/get-interaction-status.js +5 -2
  201. package/dist/esm/create-payload/utils/get-page-visibility-up-to-ttai.js +4 -2
  202. package/dist/esm/create-payload/utils/get-ssr-done-time-value.js +4 -2
  203. package/dist/esm/create-payload/utils/get-vc-metrics.js +9 -7
  204. package/dist/esm/create-post-interaction-log-payload/index.js +14 -12
  205. package/dist/esm/custom-data/index.js +3 -2
  206. package/dist/esm/custom-mark/index.js +3 -2
  207. package/dist/esm/custom-spans/index.js +3 -2
  208. package/dist/esm/custom-timings/index.js +5 -4
  209. package/dist/esm/experience-trace-id-context/index.js +15 -14
  210. package/dist/esm/experience-trace-id-context/utils/make-trace-http-request-headers/index.js +3 -2
  211. package/dist/esm/feature-flags-accessed/common/utils/index.js +11 -10
  212. package/dist/esm/feature-flags-accessed/index.js +3 -2
  213. package/dist/esm/generate-id/index.js +4 -2
  214. package/dist/esm/global-error-handler/index.js +14 -13
  215. package/dist/esm/initial-page-load-extra-timing/index.js +5 -4
  216. package/dist/esm/interaction-metrics/index.js +109 -108
  217. package/dist/esm/interaction-metrics/post-interaction-log.js +10 -0
  218. package/dist/esm/interaction-metrics-init/index.js +17 -10
  219. package/dist/esm/interaction-metrics-init/schedule-idle-callback.js +7 -3
  220. package/dist/esm/resource-timing/common/utils/config.js +9 -8
  221. package/dist/esm/resource-timing/common/utils/resource-timing-buffer.js +13 -12
  222. package/dist/esm/resource-timing/main.js +27 -20
  223. package/dist/esm/resource-timing/utils.js +3 -2
  224. package/dist/esm/round-number/index.js +3 -2
  225. package/dist/esm/route-name/index.js +4 -2
  226. package/dist/esm/segment/schedule-on-paint.js +7 -4
  227. package/dist/esm/segment/segment.js +9 -5
  228. package/dist/esm/self-measurements/index.js +246 -0
  229. package/dist/esm/set-interaction-error/index.js +3 -2
  230. package/dist/esm/short-id/index.js +4 -2
  231. package/dist/esm/ssr/index.js +17 -16
  232. package/dist/esm/trace-interaction/index.js +6 -4
  233. package/dist/esm/trace-pageload/index.js +6 -4
  234. package/dist/esm/trace-press/index.js +4 -2
  235. package/dist/esm/trace-redirect/index.js +4 -2
  236. package/dist/esm/trace-transition/index.js +5 -3
  237. package/dist/esm/trace-transition/utils/generate-span-id/index.js +3 -2
  238. package/dist/esm/trace-transition/utils/set-interaction-active-trace/index.js +3 -2
  239. package/dist/esm/vc/index.js +16 -4
  240. package/dist/esm/vc/vc-observer/attachAbortListeners.js +3 -2
  241. package/dist/esm/vc/vc-observer/getVCRevisionsData.js +40 -25
  242. package/dist/esm/vc/vc-observer/getViewport.js +5 -4
  243. package/dist/esm/vc/vc-observer/heatmap/heatmap.js +28 -12
  244. package/dist/esm/vc/vc-observer/index.js +170 -133
  245. package/dist/esm/vc/vc-observer/media-wrapper/vc-utils.js +3 -2
  246. package/dist/esm/vc/vc-observer/observers/editor-lnv/index.js +17 -0
  247. package/dist/esm/vc/vc-observer/observers/index.js +82 -25
  248. package/dist/esm/vc/vc-observer/observers/non-visual-styles/is-non-visual-style-mutation.js +4 -7
  249. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +17 -2
  250. package/dist/esm/vc/vc-observer/revisions/fy25_01.js +7 -7
  251. package/dist/esm/vc/vc-observer/revisions/fy25_02.js +2 -0
  252. package/dist/esm/vc/vc-observer/revisions/revisions.js +3 -2
  253. package/dist/esm/vc/vc-observer-new/entries-timeline/index.js +9 -0
  254. package/dist/esm/vc/vc-observer-new/get-element-name.js +4 -2
  255. package/dist/esm/vc/vc-observer-new/get-unique-element-name.js +12 -10
  256. package/dist/esm/vc/vc-observer-new/index.js +9 -0
  257. package/dist/esm/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +2 -0
  258. package/dist/esm/vc/vc-observer-new/metric-calculator/fy25_03/index.js +6 -1
  259. package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js +19 -9
  260. package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/index.js +26 -24
  261. package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/heatmap/heatmap.js +18 -6
  262. package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/heatmap/index.js +26 -13
  263. package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/index.js +9 -7
  264. package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/rect-sweeping-line/calc-union-area.js +49 -39
  265. package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/rect-sweeping-line/index.js +9 -7
  266. package/dist/esm/vc/vc-observer-new/metric-calculator/utils/get-viewport-height.js +4 -2
  267. package/dist/esm/vc/vc-observer-new/metric-calculator/utils/get-viewport-width.js +4 -2
  268. package/dist/esm/vc/vc-observer-new/metric-calculator/utils/is-viewport-entry-data.js +4 -2
  269. package/dist/esm/vc/vc-observer-new/metric-calculator/utils/task-yield.js +10 -7
  270. package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +15 -7
  271. package/dist/esm/vc/vc-observer-new/viewport-observer/intersection-observer/index.js +15 -12
  272. package/dist/esm/vc/vc-observer-new/viewport-observer/mutation-observer/index.js +15 -12
  273. package/dist/esm/vc/vc-observer-new/viewport-observer/performance-observer/index.js +11 -7
  274. package/dist/esm/vc/vc-observer-new/window-event-observer/index.js +7 -1
  275. package/dist/types/additional-payload/utils/cache-hit-ratio/index.d.ts +1 -1
  276. package/dist/types/additional-payload/utils/lighthouse-metrics/index.d.ts +2 -2
  277. package/dist/types/assets/index.d.ts +3 -1
  278. package/dist/types/assets/utils.d.ts +1 -1
  279. package/dist/types/bundle-eval-timing/index.d.ts +2 -2
  280. package/dist/types/coinflip/index.d.ts +2 -1
  281. package/dist/types/common/index.d.ts +2 -1
  282. package/dist/types/common/react-ufo-payload-schema.d.ts +175 -0
  283. package/dist/types/common/vc/types.d.ts +20 -10
  284. package/dist/types/config/index.d.ts +14 -16
  285. package/dist/types/create-experimental-interaction-metrics-payload/index.d.ts +4 -3
  286. package/dist/types/create-payload/common/utils/index.d.ts +6 -7
  287. package/dist/types/create-payload/index.d.ts +1250 -1537
  288. package/dist/types/create-payload/utils/get-interaction-status.d.ts +2 -1
  289. package/dist/types/create-payload/utils/get-page-visibility-up-to-ttai.d.ts +2 -1
  290. package/dist/types/create-payload/utils/get-ssr-done-time-value.d.ts +2 -1
  291. package/dist/types/create-payload/utils/get-vc-metrics.d.ts +3 -2
  292. package/dist/types/create-post-interaction-log-payload/index.d.ts +3 -2
  293. package/dist/types/custom-data/index.d.ts +1 -1
  294. package/dist/types/custom-mark/index.d.ts +1 -1
  295. package/dist/types/custom-spans/index.d.ts +1 -1
  296. package/dist/types/custom-timings/index.d.ts +2 -2
  297. package/dist/types/generate-id/index.d.ts +2 -1
  298. package/dist/types/hidden-timing/index.d.ts +1 -1
  299. package/dist/types/initial-page-load-extra-timing/index.d.ts +2 -2
  300. package/dist/types/interaction-context/index.d.ts +3 -3
  301. package/dist/types/interaction-metrics/index.d.ts +42 -42
  302. package/dist/types/interaction-metrics/post-interaction-log.d.ts +1 -0
  303. package/dist/types/interaction-metrics-init/schedule-idle-callback.d.ts +2 -1
  304. package/dist/types/resource-timing/common/utils/config.d.ts +1 -1
  305. package/dist/types/resource-timing/utils.d.ts +1 -1
  306. package/dist/types/round-number/index.d.ts +1 -1
  307. package/dist/types/route-name/index.d.ts +4 -3
  308. package/dist/types/segment/schedule-on-paint.d.ts +2 -1
  309. package/dist/types/self-measurements/index.d.ts +57 -0
  310. package/dist/types/set-interaction-error/index.d.ts +1 -1
  311. package/dist/types/short-id/index.d.ts +2 -1
  312. package/dist/types/ssr/index.d.ts +5 -5
  313. package/dist/types/trace-interaction/index.d.ts +2 -1
  314. package/dist/types/trace-pageload/index.d.ts +3 -2
  315. package/dist/types/trace-press/index.d.ts +2 -1
  316. package/dist/types/trace-redirect/index.d.ts +2 -1
  317. package/dist/types/trace-transition/index.d.ts +2 -1
  318. package/dist/types/vc/index.d.ts +2 -2
  319. package/dist/types/vc/vc-observer/getVCRevisionsData.d.ts +7 -7
  320. package/dist/types/vc/vc-observer/getViewport.d.ts +2 -2
  321. package/dist/types/vc/vc-observer/heatmap/heatmap.d.ts +7 -4
  322. package/dist/types/vc/vc-observer/index.d.ts +4 -4
  323. package/dist/types/vc/vc-observer/observers/non-visual-styles/is-non-visual-style-mutation.d.ts +5 -4
  324. package/dist/types/vc/vc-observer/observers/types.d.ts +1 -1
  325. package/dist/types/vc/vc-observer-new/get-element-name.d.ts +2 -1
  326. package/dist/types/vc/vc-observer-new/get-unique-element-name.d.ts +2 -1
  327. package/dist/types/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.d.ts +2 -3
  328. package/dist/types/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/index.d.ts +3 -2
  329. package/dist/types/vc/vc-observer-new/metric-calculator/percentile-calc/heatmap/index.d.ts +3 -2
  330. package/dist/types/vc/vc-observer-new/metric-calculator/percentile-calc/index.d.ts +2 -1
  331. package/dist/types/vc/vc-observer-new/metric-calculator/percentile-calc/rect-sweeping-line/calc-union-area.d.ts +2 -1
  332. package/dist/types/vc/vc-observer-new/metric-calculator/percentile-calc/rect-sweeping-line/index.d.ts +3 -2
  333. package/dist/types/vc/vc-observer-new/metric-calculator/utils/get-viewport-height.d.ts +2 -1
  334. package/dist/types/vc/vc-observer-new/metric-calculator/utils/get-viewport-width.d.ts +2 -1
  335. package/dist/types/vc/vc-observer-new/metric-calculator/utils/is-viewport-entry-data.d.ts +2 -1
  336. package/dist/types/vc/vc-observer-new/metric-calculator/utils/task-yield.d.ts +2 -1
  337. package/dist/types/vc/vc-observer-new/viewport-observer/index.d.ts +1 -1
  338. package/dist/types/vc/vc-observer-new/viewport-observer/mutation-observer/index.d.ts +2 -1
  339. package/dist/types/vc/vc-observer-new/viewport-observer/performance-observer/index.d.ts +3 -3
  340. package/dist/types-ts4.5/additional-payload/utils/cache-hit-ratio/index.d.ts +1 -1
  341. package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/index.d.ts +2 -2
  342. package/dist/types-ts4.5/assets/index.d.ts +3 -1
  343. package/dist/types-ts4.5/assets/utils.d.ts +1 -1
  344. package/dist/types-ts4.5/bundle-eval-timing/index.d.ts +2 -2
  345. package/dist/types-ts4.5/coinflip/index.d.ts +2 -1
  346. package/dist/types-ts4.5/common/index.d.ts +2 -1
  347. package/dist/types-ts4.5/common/react-ufo-payload-schema.d.ts +177 -0
  348. package/dist/types-ts4.5/common/vc/types.d.ts +20 -10
  349. package/dist/types-ts4.5/config/index.d.ts +14 -20
  350. package/dist/types-ts4.5/create-experimental-interaction-metrics-payload/index.d.ts +4 -3
  351. package/dist/types-ts4.5/create-payload/common/utils/index.d.ts +6 -7
  352. package/dist/types-ts4.5/create-payload/index.d.ts +1250 -1537
  353. package/dist/types-ts4.5/create-payload/utils/get-interaction-status.d.ts +2 -1
  354. package/dist/types-ts4.5/create-payload/utils/get-page-visibility-up-to-ttai.d.ts +2 -1
  355. package/dist/types-ts4.5/create-payload/utils/get-ssr-done-time-value.d.ts +2 -1
  356. package/dist/types-ts4.5/create-payload/utils/get-vc-metrics.d.ts +3 -2
  357. package/dist/types-ts4.5/create-post-interaction-log-payload/index.d.ts +3 -2
  358. package/dist/types-ts4.5/custom-data/index.d.ts +1 -1
  359. package/dist/types-ts4.5/custom-mark/index.d.ts +1 -1
  360. package/dist/types-ts4.5/custom-spans/index.d.ts +1 -1
  361. package/dist/types-ts4.5/custom-timings/index.d.ts +2 -2
  362. package/dist/types-ts4.5/generate-id/index.d.ts +2 -1
  363. package/dist/types-ts4.5/hidden-timing/index.d.ts +1 -1
  364. package/dist/types-ts4.5/initial-page-load-extra-timing/index.d.ts +2 -2
  365. package/dist/types-ts4.5/interaction-context/index.d.ts +3 -3
  366. package/dist/types-ts4.5/interaction-metrics/index.d.ts +42 -42
  367. package/dist/types-ts4.5/interaction-metrics/post-interaction-log.d.ts +1 -0
  368. package/dist/types-ts4.5/interaction-metrics-init/schedule-idle-callback.d.ts +2 -1
  369. package/dist/types-ts4.5/resource-timing/common/utils/config.d.ts +1 -1
  370. package/dist/types-ts4.5/resource-timing/utils.d.ts +1 -1
  371. package/dist/types-ts4.5/round-number/index.d.ts +1 -1
  372. package/dist/types-ts4.5/route-name/index.d.ts +4 -3
  373. package/dist/types-ts4.5/segment/schedule-on-paint.d.ts +2 -1
  374. package/dist/types-ts4.5/self-measurements/index.d.ts +57 -0
  375. package/dist/types-ts4.5/set-interaction-error/index.d.ts +1 -1
  376. package/dist/types-ts4.5/short-id/index.d.ts +2 -1
  377. package/dist/types-ts4.5/ssr/index.d.ts +5 -5
  378. package/dist/types-ts4.5/trace-interaction/index.d.ts +2 -1
  379. package/dist/types-ts4.5/trace-pageload/index.d.ts +3 -2
  380. package/dist/types-ts4.5/trace-press/index.d.ts +2 -1
  381. package/dist/types-ts4.5/trace-redirect/index.d.ts +2 -1
  382. package/dist/types-ts4.5/trace-transition/index.d.ts +2 -1
  383. package/dist/types-ts4.5/vc/index.d.ts +2 -2
  384. package/dist/types-ts4.5/vc/vc-observer/getVCRevisionsData.d.ts +7 -7
  385. package/dist/types-ts4.5/vc/vc-observer/getViewport.d.ts +2 -2
  386. package/dist/types-ts4.5/vc/vc-observer/heatmap/heatmap.d.ts +7 -4
  387. package/dist/types-ts4.5/vc/vc-observer/index.d.ts +4 -4
  388. package/dist/types-ts4.5/vc/vc-observer/observers/non-visual-styles/is-non-visual-style-mutation.d.ts +5 -4
  389. package/dist/types-ts4.5/vc/vc-observer/observers/types.d.ts +1 -1
  390. package/dist/types-ts4.5/vc/vc-observer-new/get-element-name.d.ts +2 -1
  391. package/dist/types-ts4.5/vc/vc-observer-new/get-unique-element-name.d.ts +2 -1
  392. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.d.ts +2 -3
  393. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/index.d.ts +3 -2
  394. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/percentile-calc/heatmap/index.d.ts +3 -2
  395. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/percentile-calc/index.d.ts +2 -1
  396. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/percentile-calc/rect-sweeping-line/calc-union-area.d.ts +2 -1
  397. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/percentile-calc/rect-sweeping-line/index.d.ts +3 -2
  398. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/utils/get-viewport-height.d.ts +2 -1
  399. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/utils/get-viewport-width.d.ts +2 -1
  400. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/utils/is-viewport-entry-data.d.ts +2 -1
  401. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/utils/task-yield.d.ts +2 -1
  402. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/index.d.ts +1 -1
  403. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/mutation-observer/index.d.ts +2 -1
  404. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/performance-observer/index.d.ts +3 -3
  405. package/package.json +12 -12
@@ -1,5 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ var _VCObserver;
2
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { markProfilingEnd, markProfilingStart, withProfiling } from '../../self-measurements';
3
5
  import { attachAbortListeners } from './attachAbortListeners';
4
6
  import { getVCRevisionsData } from './getVCRevisionsData';
5
7
  import { getViewportHeight, getViewportWidth } from './getViewport';
@@ -13,7 +15,7 @@ const abortReason = {
13
15
  error: 'error'
14
16
  };
15
17
  const UNUSED_SECTOR = 0;
16
- function filterComponentsLog(log) {
18
+ const filterComponentsLog = withProfiling(function filterComponentsLog(log) {
17
19
  return Object.fromEntries(Object.entries(log).map(([timestamp, entries]) => [Number(timestamp), entries.map(entry => {
18
20
  const {
19
21
  __debug__element,
@@ -21,7 +23,7 @@ function filterComponentsLog(log) {
21
23
  } = entry;
22
24
  return rest;
23
25
  })]));
24
- }
26
+ }, ['vc']);
25
27
  export class VCObserver {
26
28
  constructor(options) {
27
29
  /* abort logic */
@@ -310,7 +312,7 @@ export class VCObserver {
310
312
  [`${fullPrefix}vc:state`]: true,
311
313
  [`${fullPrefix}vc:clean`]: isVCClean,
312
314
  [`${fullPrefix}vc:dom`]: VCBox,
313
- [`${fullPrefix}vc:updates`]: VCEntries.rel.slice(0, 50),
315
+ [`${fullPrefix}vc:updates`]: fg('platform_ufo_vc_observer_new') ? undefined : VCEntries.rel.slice(0, 50),
314
316
  // max 50
315
317
  [`${fullPrefix}vc:size`]: viewport,
316
318
  [`${fullPrefix}vc:time`]: Math.round(totalTime + (stopTime - startTime)),
@@ -318,16 +320,17 @@ export class VCObserver {
318
320
  [`${fullPrefix}vc:ratios`]: ratios,
319
321
  ...outOfBoundary,
320
322
  [`${fullPrefix}vc:next`]: vcNext.VC,
321
- [`${fullPrefix}vc:next:updates`]: vcNext.VCEntries.rel.slice(0, 50),
323
+ [`${fullPrefix}vc:next:updates`]: fg('platform_ufo_vc_observer_new') ? undefined : vcNext.VCEntries.rel.slice(0, 50),
324
+ // max 50
322
325
  [`${fullPrefix}vc:next:dom`]: vcNext.VCBox,
323
326
  [`${fullPrefix}vc:ignored`]: this.getIgnoredElements(componentsLog),
324
327
  ...revisionsData,
325
328
  ...(isCalcSpeedIndexEnabled ? speedIndex : {})
326
329
  };
327
330
  });
328
- _defineProperty(this, "handleUpdate", (rawTime, intersectionRect, targetName, element, type, ignoreReason) => {
331
+ _defineProperty(this, "handleUpdate", (rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue) => {
329
332
  this.measureStart();
330
- this.legacyHandleUpdate(rawTime, intersectionRect, targetName, element, type, ignoreReason);
333
+ this.legacyHandleUpdate(rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue);
331
334
  if (!fg('platform_ufo_vc_observer_new')) {
332
335
  this.onViewportChangeDetected({
333
336
  timestamp: rawTime,
@@ -335,12 +338,15 @@ export class VCObserver {
335
338
  targetName,
336
339
  element,
337
340
  type,
338
- ignoreReason
341
+ ignoreReason,
342
+ attributeName,
343
+ oldValue,
344
+ newValue
339
345
  });
340
346
  }
341
347
  this.measureStop();
342
348
  });
343
- _defineProperty(this, "legacyHandleUpdate", (rawTime, intersectionRect, targetName, element, type, ignoreReason) => {
349
+ _defineProperty(this, "legacyHandleUpdate", (rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue) => {
344
350
  if (this.abortReason.reason === null || this.abortReason.blocking === false) {
345
351
  const time = Math.round(rawTime - this.startTime);
346
352
  const mappedValues = this.mapPixelsToHeatmap(intersectionRect.left, intersectionRect.top, intersectionRect.width, intersectionRect.height);
@@ -357,9 +363,13 @@ export class VCObserver {
357
363
  }
358
364
  this.componentsLog[time].push({
359
365
  __debug__element: this.devToolsEnabled ? new WeakRef(element) : null,
366
+ type,
360
367
  intersectionRect,
361
368
  targetName,
362
- ignoreReason
369
+ ignoreReason,
370
+ attributeName,
371
+ oldValue,
372
+ newValue
363
373
  });
364
374
  }
365
375
  });
@@ -369,7 +379,10 @@ export class VCObserver {
369
379
  ignoreReason,
370
380
  timestamp,
371
381
  targetName,
372
- intersectionRect
382
+ intersectionRect,
383
+ attributeName,
384
+ oldValue,
385
+ newValue
373
386
  }) => {
374
387
  if (this.multiHeatmap === null) {
375
388
  return;
@@ -393,7 +406,10 @@ export class VCObserver {
393
406
  classification: revisionsClassification,
394
407
  onError: error => {
395
408
  this.setAbortReason(abortReason.error, error.time, error.error);
396
- }
409
+ },
410
+ attributeName,
411
+ oldValue,
412
+ newValue
397
413
  });
398
414
  });
399
415
  _defineProperty(this, "mapPixelsToHeatmap", (left, top, width, height) => {
@@ -465,6 +481,7 @@ export class VCObserver {
465
481
  }
466
482
  this.unbind = unbinds;
467
483
  });
484
+ const operationTimer = markProfilingStart('VCObserver constructor');
468
485
  this.arraySize = options.heatmapSize || 200;
469
486
  this.devToolsEnabled = options.devToolsEnabled || false;
470
487
  this.oldDomUpdatesEnabled = options.oldDomUpdates || false;
@@ -485,6 +502,32 @@ export class VCObserver {
485
502
  devToolsEnabled: this.devToolsEnabled
486
503
  });
487
504
  this.isPostInteraction = options.isPostInteraction || false;
505
+ this.start = withProfiling(this.start.bind(this), ['vc']);
506
+ this.stop = withProfiling(this.stop.bind(this), ['vc']);
507
+ this.getAbortReasonInfo = withProfiling(this.getAbortReasonInfo.bind(this), ['vc']); // TODO: confirm correct value of `this`
508
+ this.getVCRawData = withProfiling(this.getVCRawData.bind(this), ['vc']); // TODO: confirm correct value of `this`
509
+ this.getIgnoredElements = withProfiling(this.getIgnoredElements.bind(this), ['vc']);
510
+ this.getVCResult = withProfiling(this.getVCResult.bind(this), ['vc']);
511
+ this.setSSRElement = withProfiling(this.setSSRElement.bind(this), ['vc']);
512
+ this.setReactRootRenderStart = withProfiling(this.setReactRootRenderStart.bind(this), ['vc']);
513
+ this.setReactRootRenderStop = withProfiling(this.setReactRootRenderStop.bind(this), ['vc']);
514
+ this.handleUpdate = withProfiling(this.handleUpdate.bind(this), ['vc']); // TODO: confirm correct value of `this`
515
+ this.legacyHandleUpdate = withProfiling(this.legacyHandleUpdate.bind(this), ['vc']); // TODO: confirm correct value of `this`
516
+ this.onViewportChangeDetected = withProfiling(this.onViewportChangeDetected.bind(this), ['vc']); // TODO: confirm correct value of `this`
517
+ this.setAbortReason = withProfiling(this.setAbortReason.bind(this), ['vc']);
518
+ this.resetState = withProfiling(this.resetState.bind(this), ['vc']);
519
+ this.setViewportSize = withProfiling(this.setViewportSize.bind(this), ['vc']);
520
+ this.mapPixelsToHeatmap = withProfiling(this.mapPixelsToHeatmap.bind(this), ['vc']); // TODO: confirm correct value of `this`
521
+ this.getElementRatio = withProfiling(this.getElementRatio.bind(this), ['vc']); // TODO: confirm correct value of `this`
522
+ this.applyChangesToHeatMap = withProfiling(this.applyChangesToHeatMap.bind(this), ['vc']);
523
+ this.abortReasonCallback = withProfiling(this.abortReasonCallback.bind(this), ['vc']); // TODO: confirm correct value of `this`
524
+ this.attachAbortListeners = withProfiling(this.attachAbortListeners.bind(this), ['vc']); // TODO: confirm correct value of `this`
525
+ this.detachAbortListeners = withProfiling(this.detachAbortListeners.bind(this), ['vc']);
526
+ this.measureStart = withProfiling(this.measureStart.bind(this), ['vc']);
527
+ this.measureStop = withProfiling(this.measureStop.bind(this), ['vc']);
528
+ markProfilingEnd(operationTimer, {
529
+ tags: ['vc']
530
+ });
488
531
  }
489
532
  start({
490
533
  startTime
@@ -516,103 +559,6 @@ export class VCObserver {
516
559
  ignoreReason
517
560
  }));
518
561
  }
519
- static calculateVC({
520
- heatmap,
521
- ssr = UNUSED_SECTOR,
522
- componentsLog,
523
- viewport
524
- }) {
525
- const lastUpdate = {};
526
- let totalPainted = 0;
527
- if (ssr !== UNUSED_SECTOR) {
528
- var _window$document;
529
- const element = {
530
- __debug__element: new WeakRef((_window$document = window.document) === null || _window$document === void 0 ? void 0 : _window$document.body),
531
- intersectionRect: {
532
- top: 0,
533
- left: 0,
534
- right: 0,
535
- bottom: 0,
536
- x: 0,
537
- y: 0,
538
- width: viewport.w,
539
- height: viewport.h,
540
- toJSON() {
541
- return {};
542
- }
543
- },
544
- targetName: 'SSR'
545
- };
546
- if (!componentsLog[ssr]) {
547
- componentsLog[ssr] = [];
548
- }
549
- componentsLog[ssr].push(element);
550
- }
551
- heatmap.forEach(line => {
552
- line.forEach(entry => {
553
- const rounded = Math.floor(entry === UNUSED_SECTOR && ssr !== UNUSED_SECTOR ? ssr : entry);
554
- totalPainted += rounded !== UNUSED_SECTOR ? 1 : 0;
555
- if (rounded !== UNUSED_SECTOR) {
556
- lastUpdate[rounded] = lastUpdate[rounded] ? lastUpdate[rounded] + 1 : 1;
557
- }
558
- });
559
- });
560
- const entries = Object.entries(lastUpdate).map(a => [parseInt(a[0], 10), a[1]]).sort((a, b) => a[0] > b[0] ? 1 : -1);
561
- const VC = VCObserver.makeVCReturnObj();
562
- const VCBox = VCObserver.makeVCReturnObj();
563
-
564
- // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
565
- const isCalcSpeedIndexEnabled = fg('ufo-calc-speed-index');
566
- const isFilterIgnoredItemsEnabled = fg('platform_ufo_vc_filter_ignored_items');
567
- entries.reduce((acc = 0, v) => {
568
- const currRatio = v[1] / totalPainted;
569
- let VCRatio = currRatio + acc;
570
- if (fg('platform_ufo_fix_vc_observer_rounding_error')) {
571
- const preciseCurrRatio = Math.round(100 * (v[1] / totalPainted));
572
- const preciseAccRatio = Math.round(acc * 100);
573
- VCRatio = (preciseCurrRatio + preciseAccRatio) / 100;
574
- }
575
- const time = v[0];
576
- VCObserver.VCParts.forEach(key => {
577
- const value = parseInt(key, 10);
578
- if ((VC[key] === null || VC[key] === undefined) && VCRatio >= value / 100) {
579
- var _componentsLog$time, _componentsLog$time2;
580
- VC[key] = time;
581
- VCBox[key] = isFilterIgnoredItemsEnabled ? [...new Set((_componentsLog$time = componentsLog[time]) === null || _componentsLog$time === void 0 ? void 0 : _componentsLog$time.filter(v => !v.ignoreReason).map(v => v.targetName))] : [...new Set((_componentsLog$time2 = componentsLog[time]) === null || _componentsLog$time2 === void 0 ? void 0 : _componentsLog$time2.map(v => v.targetName))];
582
- }
583
- });
584
- return VCRatio;
585
- }, 0);
586
- const VCEntries = entries.reduce((acc, [timestamp, entryPainted], i) => {
587
- var _acc$abs, _componentsLog$timest, _componentsLog$timest2, _acc$rel$vc, _acc$rel;
588
- const currentlyPainted = entryPainted + (((_acc$abs = acc.abs[i - 1]) === null || _acc$abs === void 0 ? void 0 : _acc$abs[1]) || 0);
589
- const currentlyPaintedRatio = Math.round(currentlyPainted / totalPainted * 1000) / 10;
590
- const logEntry = isFilterIgnoredItemsEnabled ? [...new Set((_componentsLog$timest = componentsLog[timestamp]) === null || _componentsLog$timest === void 0 ? void 0 : _componentsLog$timest.filter(v => !v.ignoreReason).map(v => v.targetName))] : [...new Set((_componentsLog$timest2 = componentsLog[timestamp]) === null || _componentsLog$timest2 === void 0 ? void 0 : _componentsLog$timest2.map(v => v.targetName))];
591
- const ratioDelta = (currentlyPaintedRatio - ((_acc$rel$vc = (_acc$rel = acc.rel[i - 1]) === null || _acc$rel === void 0 ? void 0 : _acc$rel.vc) !== null && _acc$rel$vc !== void 0 ? _acc$rel$vc : 0)) / 100;
592
- if (isCalcSpeedIndexEnabled) {
593
- const speedIndex = timestamp * ratioDelta;
594
- acc.speedIndex += speedIndex;
595
- }
596
- acc.abs.push([timestamp, currentlyPainted]);
597
- acc.rel.push({
598
- time: timestamp,
599
- vc: currentlyPaintedRatio,
600
- elements: logEntry
601
- });
602
- return acc;
603
- }, {
604
- abs: [],
605
- rel: [],
606
- speedIndex: 0
607
- });
608
- VCEntries.speedIndex = Math.round(VCEntries.speedIndex);
609
- return {
610
- VC,
611
- VCBox,
612
- VCEntries,
613
- totalPainted
614
- };
615
- }
616
562
  setSSRElement(element) {
617
563
  this.observers.setReactRootElement(element);
618
564
  }
@@ -682,13 +628,6 @@ export class VCObserver {
682
628
  }
683
629
  }
684
630
  }
685
- static makeVCReturnObj() {
686
- const vc = {};
687
- VCObserver.VCParts.forEach(v => {
688
- vc[v] = null;
689
- });
690
- return vc;
691
- }
692
631
  detachAbortListeners() {
693
632
  this.unbind.forEach(fn => fn());
694
633
  this.unbind = [];
@@ -704,5 +643,108 @@ export class VCObserver {
704
643
  this._startMeasureTimestamp = -1;
705
644
  }
706
645
  }
646
+ _VCObserver = VCObserver;
707
647
  /** config * */
708
- _defineProperty(VCObserver, "VCParts", ['25', '50', '75', '80', '85', '90', '95', '98', '99']);
648
+ _defineProperty(VCObserver, "VCParts", ['25', '50', '75', '80', '85', '90', '95', '98', '99']);
649
+ _defineProperty(VCObserver, "calculateVC", withProfiling(function calculateVC({
650
+ heatmap,
651
+ ssr = UNUSED_SECTOR,
652
+ componentsLog,
653
+ viewport
654
+ }) {
655
+ const lastUpdate = {};
656
+ let totalPainted = 0;
657
+ if (ssr !== UNUSED_SECTOR) {
658
+ var _window$document;
659
+ const element = {
660
+ __debug__element: new WeakRef((_window$document = window.document) === null || _window$document === void 0 ? void 0 : _window$document.body),
661
+ intersectionRect: {
662
+ top: 0,
663
+ left: 0,
664
+ right: 0,
665
+ bottom: 0,
666
+ x: 0,
667
+ y: 0,
668
+ width: viewport.w,
669
+ height: viewport.h,
670
+ toJSON() {
671
+ return {};
672
+ }
673
+ },
674
+ targetName: 'SSR'
675
+ };
676
+ if (!componentsLog[ssr]) {
677
+ componentsLog[ssr] = [];
678
+ }
679
+ componentsLog[ssr].push(element);
680
+ }
681
+ heatmap.forEach(line => {
682
+ line.forEach(entry => {
683
+ const rounded = Math.floor(entry === UNUSED_SECTOR && ssr !== UNUSED_SECTOR ? ssr : entry);
684
+ totalPainted += rounded !== UNUSED_SECTOR ? 1 : 0;
685
+ if (rounded !== UNUSED_SECTOR) {
686
+ lastUpdate[rounded] = lastUpdate[rounded] ? lastUpdate[rounded] + 1 : 1;
687
+ }
688
+ });
689
+ });
690
+ const entries = Object.entries(lastUpdate).map(a => [parseInt(a[0], 10), a[1]]).sort((a, b) => a[0] > b[0] ? 1 : -1);
691
+ const VC = _VCObserver.makeVCReturnObj();
692
+ const VCBox = _VCObserver.makeVCReturnObj();
693
+
694
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
695
+ const isCalcSpeedIndexEnabled = fg('ufo-calc-speed-index');
696
+ const isFilterIgnoredItemsEnabled = fg('platform_ufo_vc_filter_ignored_items');
697
+ entries.reduce((acc = 0, v) => {
698
+ const currRatio = v[1] / totalPainted;
699
+ let VCRatio = currRatio + acc;
700
+ const preciseCurrRatio = Math.round(100 * (v[1] / totalPainted));
701
+ const preciseAccRatio = Math.round(acc * 100);
702
+ VCRatio = (preciseCurrRatio + preciseAccRatio) / 100;
703
+ const time = v[0];
704
+ _VCObserver.VCParts.forEach(key => {
705
+ const value = parseInt(key, 10);
706
+ if ((VC[key] === null || VC[key] === undefined) && VCRatio >= value / 100) {
707
+ var _componentsLog$time, _componentsLog$time2;
708
+ VC[key] = time;
709
+ VCBox[key] = isFilterIgnoredItemsEnabled ? [...new Set((_componentsLog$time = componentsLog[time]) === null || _componentsLog$time === void 0 ? void 0 : _componentsLog$time.filter(v => !v.ignoreReason).map(v => v.targetName))] : [...new Set((_componentsLog$time2 = componentsLog[time]) === null || _componentsLog$time2 === void 0 ? void 0 : _componentsLog$time2.map(v => v.targetName))];
710
+ }
711
+ });
712
+ return VCRatio;
713
+ }, 0);
714
+ const VCEntries = entries.reduce((acc, [timestamp, entryPainted], i) => {
715
+ var _acc$abs, _componentsLog$timest, _componentsLog$timest2, _acc$rel$vc, _acc$rel;
716
+ const currentlyPainted = entryPainted + (((_acc$abs = acc.abs[i - 1]) === null || _acc$abs === void 0 ? void 0 : _acc$abs[1]) || 0);
717
+ const currentlyPaintedRatio = Math.round(currentlyPainted / totalPainted * 1000) / 10;
718
+ const logEntry = isFilterIgnoredItemsEnabled ? [...new Set((_componentsLog$timest = componentsLog[timestamp]) === null || _componentsLog$timest === void 0 ? void 0 : _componentsLog$timest.filter(v => !v.ignoreReason).map(v => v.targetName))] : [...new Set((_componentsLog$timest2 = componentsLog[timestamp]) === null || _componentsLog$timest2 === void 0 ? void 0 : _componentsLog$timest2.map(v => v.targetName))];
719
+ const ratioDelta = (currentlyPaintedRatio - ((_acc$rel$vc = (_acc$rel = acc.rel[i - 1]) === null || _acc$rel === void 0 ? void 0 : _acc$rel.vc) !== null && _acc$rel$vc !== void 0 ? _acc$rel$vc : 0)) / 100;
720
+ if (isCalcSpeedIndexEnabled) {
721
+ const speedIndex = timestamp * ratioDelta;
722
+ acc.speedIndex += speedIndex;
723
+ }
724
+ acc.abs.push([timestamp, currentlyPainted]);
725
+ acc.rel.push({
726
+ time: timestamp,
727
+ vc: currentlyPaintedRatio,
728
+ elements: logEntry
729
+ });
730
+ return acc;
731
+ }, {
732
+ abs: [],
733
+ rel: [],
734
+ speedIndex: 0
735
+ });
736
+ VCEntries.speedIndex = Math.round(VCEntries.speedIndex);
737
+ return {
738
+ VC,
739
+ VCBox,
740
+ VCEntries,
741
+ totalPainted
742
+ };
743
+ }, ['vc']));
744
+ _defineProperty(VCObserver, "makeVCReturnObj", withProfiling(function makeVCReturnObj() {
745
+ const vc = {};
746
+ _VCObserver.VCParts.forEach(v => {
747
+ vc[v] = null;
748
+ });
749
+ return vc;
750
+ }, ['vc']));
@@ -1,5 +1,6 @@
1
+ import { withProfiling } from '../../../self-measurements';
1
2
  import { MEDIA_WRAPPER_TAG } from './index';
2
- export const isContainedWithinMediaWrapper = node => {
3
+ export const isContainedWithinMediaWrapper = withProfiling(function isContainedWithinMediaWrapper(node) {
3
4
  while (node) {
4
5
  if (node instanceof Element && node.hasAttribute(MEDIA_WRAPPER_TAG)) {
5
6
  return true;
@@ -7,4 +8,4 @@ export const isContainedWithinMediaWrapper = node => {
7
8
  node = node.parentNode;
8
9
  }
9
10
  return false;
10
- };
11
+ });
@@ -1,4 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { markProfilingEnd, markProfilingStart, withProfiling } from '../../../../self-measurements';
2
3
  const placeholderDataKey = 'editorLnvPlaceholder'; // data-editor-lnv-placeholder
3
4
  const replaceDataKey = 'editorLnvPlaceholderReplace'; // data-editor-lnv-placeholder-replace
4
5
 
@@ -63,7 +64,23 @@ export class EditorLnvHandler {
63
64
  return;
64
65
  }
65
66
  });
67
+ const operationTimer = markProfilingStart('EditorLnvHandler constructor');
66
68
  this.intersectionObserver = new IntersectionObserver(entries => entries.filter(entry => entry.intersectionRatio > 0).forEach(this.intersectionObserverCallback));
69
+ this.shouldHandleAddedNode = withProfiling(this.shouldHandleAddedNode.bind(this), ['vc']);
70
+ this.handleAddedNode = withProfiling(this.handleAddedNode.bind(this), ['vc']);
71
+ this.clear = withProfiling(this.clear.bind(this), ['vc']);
72
+ this.handleAddedPlaceholderNode = withProfiling(this.handleAddedPlaceholderNode.bind(this), ['vc']);
73
+ this.handleAddedReplaceNode = withProfiling(this.handleAddedReplaceNode.bind(this), ['vc']);
74
+ this.isExistingPlaceholder = withProfiling(this.isExistingPlaceholder.bind(this), ['vc']);
75
+ this.registerPlaceholder = withProfiling(this.registerPlaceholder.bind(this), ['vc']);
76
+ this.getSize = withProfiling(this.getSize.bind(this), ['vc']);
77
+ this.isAddedPlaceholderMatchingSize = withProfiling(this.isAddedPlaceholderMatchingSize.bind(this), ['vc']);
78
+ this.isAddedReplaceMatchingSize = withProfiling(this.isAddedReplaceMatchingSize.bind(this), ['vc']);
79
+ this.areRectsSameSize = withProfiling(this.areRectsSameSize.bind(this), ['vc']);
80
+ this.intersectionObserverCallback = withProfiling(this.intersectionObserverCallback.bind(this), ['vc']);
81
+ markProfilingEnd(operationTimer, {
82
+ tags: ['vc']
83
+ });
67
84
  }
68
85
  shouldHandleAddedNode(el) {
69
86
  var _el$dataset, _el$dataset2;
@@ -1,6 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
3
  import { shouldHandleEditorLnv } from '../../../config';
4
+ import { markProfilingEnd, markProfilingStart, withProfiling } from '../../../self-measurements';
4
5
  import { isContainedWithinMediaWrapper } from '../media-wrapper/vc-utils';
5
6
  import { EditorLnvHandler } from './editor-lnv';
6
7
  import isNonVisualStyleMutation from './non-visual-styles/is-non-visual-style-mutation';
@@ -10,7 +11,7 @@ const state = {
10
11
  waitingForFirstRender: 2,
11
12
  ignoring: 3
12
13
  };
13
- function isElementVisible(target) {
14
+ const isElementVisible = withProfiling(function isElementVisible(target) {
14
15
  if (!target || typeof target.checkVisibility !== 'function') {
15
16
  return true;
16
17
  }
@@ -20,13 +21,13 @@ function isElementVisible(target) {
20
21
  visibilityProperty: true
21
22
  });
22
23
  return isVisible;
23
- }
24
- function isInsideEditorContainer(target) {
24
+ }, ['vc']);
25
+ const isInsideEditorContainer = withProfiling(function isInsideEditorContainer(target) {
25
26
  if (!target || typeof target.closest !== 'function') {
26
27
  return false;
27
28
  }
28
29
  return Boolean(target.closest('.ProseMirror'));
29
- }
30
+ }, ['vc']);
30
31
  export class Observers {
31
32
  constructor(opts) {
32
33
  _defineProperty(this, "observedMutations", new WeakMap());
@@ -50,15 +51,27 @@ export class Observers {
50
51
  _defineProperty(this, "subscribeResults", cb => {
51
52
  this.callbacks.add(cb);
52
53
  });
53
- _defineProperty(this, "observeElement", (node, mutation, type, ignoreReason) => {
54
+ _defineProperty(this, "observeElement", (node, mutation, type, ignoreReason, attributeName, oldValue = null, newValue = null) => {
54
55
  var _this$intersectionObs;
55
56
  (_this$intersectionObs = this.intersectionObserver) === null || _this$intersectionObs === void 0 ? void 0 : _this$intersectionObs.observe(node);
56
- this.observedMutations.set(node, {
57
- mutation,
58
- ignoreReason,
59
- type
60
- });
57
+ if (fg('platform_ufo_log_attr_mutation_values')) {
58
+ this.observedMutations.set(node, {
59
+ mutation,
60
+ ignoreReason,
61
+ type,
62
+ attributeName,
63
+ oldValue,
64
+ newValue
65
+ });
66
+ } else {
67
+ this.observedMutations.set(node, {
68
+ mutation,
69
+ ignoreReason,
70
+ type
71
+ });
72
+ }
61
73
  });
74
+ const operationTimer = markProfilingStart('Observers constructor');
62
75
  this.selectorConfig = {
63
76
  ...this.selectorConfig,
64
77
  ...opts.selectorConfig
@@ -67,6 +80,23 @@ export class Observers {
67
80
  this.mutationObserver = this.getMutationObserver();
68
81
  this.ssrPlaceholderHandler = new SSRPlaceholderHandlers();
69
82
  this.editorLnvHandler = new EditorLnvHandler();
83
+ this.isBrowserSupported = withProfiling(this.isBrowserSupported.bind(this), ['vc']);
84
+ this.observe = withProfiling(this.observe.bind(this), ['vc']);
85
+ this.disconnect = withProfiling(this.disconnect.bind(this), ['vc']);
86
+ this.subscribeResults = withProfiling(this.subscribeResults.bind(this), ['vc']);
87
+ this.getTotalTime = withProfiling(this.getTotalTime.bind(this), ['vc']);
88
+ this.setReactRootElement = withProfiling(this.setReactRootElement.bind(this), ['vc']);
89
+ this.setReactRootRenderStart = withProfiling(this.setReactRootRenderStart.bind(this), ['vc']);
90
+ this.setReactRootRenderStop = withProfiling(this.setReactRootRenderStop.bind(this), ['vc']);
91
+ this.observeElement = withProfiling(this.observeElement.bind(this), ['vc']);
92
+ this.getMutationObserver = withProfiling(this.getMutationObserver.bind(this), ['vc']);
93
+ this.getElementName = withProfiling(this.getElementName.bind(this), ['vc']);
94
+ this.getIntersectionObserver = withProfiling(this.getIntersectionObserver.bind(this), ['vc']);
95
+ this.measureStart = withProfiling(this.measureStart.bind(this), ['vc']);
96
+ this.measureStop = withProfiling(this.measureStop.bind(this), ['vc']);
97
+ markProfilingEnd(operationTimer, {
98
+ tags: ['vc']
99
+ });
70
100
  }
71
101
  isBrowserSupported() {
72
102
  return typeof window.IntersectionObserver === 'function' && typeof window.MutationObserver === 'function';
@@ -113,8 +143,12 @@ export class Observers {
113
143
  this.ssr.renderStop = stopTime;
114
144
  }
115
145
  getMutationObserver() {
146
+ if (!this.isBrowserSupported()) {
147
+ return null;
148
+ }
116
149
  const shouldHandleEditorLnvLocal = shouldHandleEditorLnv();
117
- return this.isBrowserSupported() ? new MutationObserver(mutations => {
150
+ return new MutationObserver(mutations => {
151
+ const operationTimer = markProfilingStart('mutationObserverCallback');
118
152
  this.measureStart();
119
153
  mutations.forEach(mutation => {
120
154
  // patching element if timestamp not automatically added
@@ -184,34 +218,48 @@ export class Observers {
184
218
  });
185
219
  } else if (mutation.type === 'attributes') {
186
220
  if (mutation.target instanceof HTMLElement) {
221
+ const attributeName = mutation.attributeName;
187
222
  if (fg('platform_ufo_vc_ignore_same_value_mutation')) {
188
223
  var _mutation$oldValue;
189
224
  /*
190
- "MutationObserver was explicitly designed to work that way, but I can't now recall the reasoning.
191
- I think it might have been something along the lines that for consistency every setAttribute call should create a record.
192
- Conceptually there is after all a mutation: there is an old value replaced with a new one,
193
- and whether or not they are the same doesn't really matter.
194
- And Custom elements should work the same way as MutationObserver."
195
- https://github.com/whatwg/dom/issues/520#issuecomment-336574796
196
- */
225
+ "MutationObserver was explicitly designed to work that way, but I can't now recall the reasoning.
226
+ I think it might have been something along the lines that for consistency every setAttribute call should create a record.
227
+ Conceptually there is after all a mutation: there is an old value replaced with a new one,
228
+ and whether or not they are the same doesn't really matter.
229
+ And Custom elements should work the same way as MutationObserver."
230
+ https://github.com/whatwg/dom/issues/520#issuecomment-336574796
231
+ */
197
232
  const oldValue = (_mutation$oldValue = mutation.oldValue) !== null && _mutation$oldValue !== void 0 ? _mutation$oldValue : undefined;
198
- const newValue = mutation.attributeName ? mutation.target.getAttribute(mutation.attributeName) : undefined;
233
+ const newValue = attributeName ? mutation.target.getAttribute(attributeName) : undefined;
199
234
  if (oldValue !== newValue) {
200
235
  if (isNonVisualStyleMutation(mutation)) {
201
236
  ignoreReason = 'non-visual-style';
202
237
  }
203
- this.observeElement(mutation.target, mutation, 'attr', ignoreReason);
238
+ if (fg('platform_ufo_vc_fix_ignore_image_mutation')) {
239
+ if (isContainedWithinMediaWrapper(mutation.target)) {
240
+ ignoreReason = 'image';
241
+ }
242
+ }
243
+ this.observeElement(mutation.target, mutation, 'attr', ignoreReason, attributeName, oldValue, newValue);
204
244
  }
205
245
  } else {
206
246
  if (isNonVisualStyleMutation(mutation)) {
207
247
  ignoreReason = 'non-visual-style';
208
248
  }
209
- this.observeElement(mutation.target, mutation, 'attr', ignoreReason);
249
+ if (fg('platform_ufo_vc_fix_ignore_image_mutation')) {
250
+ if (isContainedWithinMediaWrapper(mutation.target)) {
251
+ ignoreReason = 'image';
252
+ }
253
+ }
254
+ this.observeElement(mutation.target, mutation, 'attr', ignoreReason, attributeName);
210
255
  }
211
256
  }
212
257
  }
213
258
  });
214
- }) : null;
259
+ markProfilingEnd(operationTimer, {
260
+ tags: ['vc']
261
+ });
262
+ });
215
263
  }
216
264
  getElementName(element) {
217
265
  try {
@@ -239,7 +287,11 @@ export class Observers {
239
287
  }
240
288
  }
241
289
  getIntersectionObserver() {
242
- return this.isBrowserSupported() ? new IntersectionObserver(entries => {
290
+ if (!this.isBrowserSupported()) {
291
+ return null;
292
+ }
293
+ return new IntersectionObserver(entries => {
294
+ const operationTimer = markProfilingStart('intersectionObserverCallback');
243
295
  this.measureStart();
244
296
  entries.forEach(({
245
297
  isIntersecting,
@@ -271,7 +323,7 @@ export class Observers {
271
323
  } catch (e) {
272
324
  elementName = 'error';
273
325
  }
274
- callback(data.mutation.timestamp || performance.now(), ir, elementName, target, data.type, data.ignoreReason);
326
+ callback(data.mutation.timestamp || performance.now(), ir, elementName, target, data.type, data.ignoreReason, data.attributeName, data.oldValue, data.newValue);
275
327
  });
276
328
  this.elementsInView.add(target);
277
329
  } else {
@@ -279,7 +331,10 @@ export class Observers {
279
331
  }
280
332
  });
281
333
  this.measureStop();
282
- }) : null;
334
+ markProfilingEnd(operationTimer, {
335
+ tags: ['vc']
336
+ });
337
+ });
283
338
  }
284
339
  measureStart() {
285
340
  this._startMeasureTimestamp = performance.now();
@@ -1,4 +1,4 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
1
+ import { withProfiling } from '../../../../self-measurements';
2
2
 
3
3
  /**
4
4
  * Checks if a mutation record represents a non-visual style change
@@ -10,14 +10,10 @@ import { fg } from '@atlaskit/platform-feature-flags';
10
10
  * - The changed attribute is either 'class' or 'style'
11
11
  */
12
12
 
13
- export default function isNonVisualStyleMutation({
13
+ const isNonVisualStyleMutation = withProfiling(function isNonVisualStyleMutation({
14
14
  target,
15
15
  attributeName
16
16
  }) {
17
- const isNonVisualStyleMutationEnabled = fg('platform_ufo_non_visual_style_mutation');
18
- if (!isNonVisualStyleMutationEnabled) {
19
- return false;
20
- }
21
17
  if (!(target instanceof Element)) {
22
18
  return false;
23
19
  }
@@ -28,4 +24,5 @@ export default function isNonVisualStyleMutation({
28
24
  return false;
29
25
  }
30
26
  return true;
31
- }
27
+ }, ['vc']);
28
+ export default isNonVisualStyleMutation;