@atlaskit/react-ufo 1.1.0 → 2.0.0

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 (486) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +5 -0
  3. package/additional-payload/package.json +15 -0
  4. package/bundle-eval-timing/package.json +15 -0
  5. package/coinflip/package.json +15 -0
  6. package/common/package.json +5 -5
  7. package/config/package.json +15 -0
  8. package/create-payload/package.json +15 -0
  9. package/create-post-interaction-log-payload/package.json +15 -0
  10. package/custom-data/package.json +15 -0
  11. package/custom-mark/package.json +15 -0
  12. package/custom-spans/package.json +15 -0
  13. package/custom-timings/package.json +15 -0
  14. package/dist/cjs/additional-payload/index.js +25 -0
  15. package/dist/cjs/additional-payload/utils/cache-hit-ratio/index.js +69 -0
  16. package/dist/cjs/additional-payload/utils/lighthouse-metrics/cls/index.js +53 -0
  17. package/dist/cjs/additional-payload/utils/lighthouse-metrics/const.js +10 -0
  18. package/dist/cjs/additional-payload/utils/lighthouse-metrics/index.js +29 -0
  19. package/dist/cjs/additional-payload/utils/lighthouse-metrics/tbt/index.js +25 -0
  20. package/dist/cjs/additional-payload/utils/lighthouse-metrics/utils/buffer/index.js +38 -0
  21. package/dist/cjs/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +37 -0
  22. package/dist/cjs/bundle-eval-timing/index.js +48 -0
  23. package/dist/cjs/coinflip/index.js +22 -0
  24. package/dist/cjs/common/common/types.js +5 -0
  25. package/dist/cjs/common/constants.js +7 -0
  26. package/dist/cjs/common/index.js +1 -0
  27. package/dist/cjs/common/vc/types.js +11 -0
  28. package/dist/cjs/config/index.js +222 -0
  29. package/dist/cjs/create-payload/common/types.js +1 -0
  30. package/dist/cjs/create-payload/common/utils/index.js +15 -0
  31. package/dist/cjs/create-payload/index.js +784 -0
  32. package/dist/cjs/create-post-interaction-log-payload/index.js +207 -0
  33. package/dist/cjs/custom-data/index.js +31 -0
  34. package/dist/cjs/custom-data/types.js +5 -0
  35. package/dist/cjs/custom-mark/index.js +45 -0
  36. package/dist/cjs/custom-spans/index.js +14 -0
  37. package/dist/cjs/custom-timings/index.js +65 -0
  38. package/dist/cjs/experience-trace-id-context/index.js +40 -0
  39. package/dist/cjs/experience-trace-id-context/types.js +1 -0
  40. package/dist/cjs/experience-trace-id-context/utils/make-trace-http-request-headers/index.js +12 -0
  41. package/dist/cjs/feature-flags-accessed/common/constants.js +7 -0
  42. package/dist/cjs/feature-flags-accessed/common/types.js +5 -0
  43. package/dist/cjs/feature-flags-accessed/common/utils/index.js +38 -0
  44. package/dist/cjs/feature-flags-accessed/index.js +32 -0
  45. package/dist/cjs/generate-id/index.js +12 -0
  46. package/dist/cjs/global-error-handler/index.js +74 -0
  47. package/dist/cjs/hidden-timing/index.js +94 -0
  48. package/dist/cjs/initial-page-load-extra-timing/index.js +49 -0
  49. package/dist/cjs/interaction-context/index.js +14 -0
  50. package/dist/cjs/interaction-id-context/index.js +27 -0
  51. package/dist/cjs/interaction-metrics/common/constants.js +8 -0
  52. package/dist/cjs/interaction-metrics/index.js +810 -1
  53. package/dist/cjs/interaction-metrics/post-interaction-log.js +190 -0
  54. package/dist/cjs/interaction-metrics-init/index.js +89 -0
  55. package/dist/cjs/label/UFOLabel.js +45 -0
  56. package/dist/cjs/label/index.js +9 -0
  57. package/dist/cjs/load-hold/UFOLoadHold.js +76 -0
  58. package/dist/cjs/load-hold/index.js +9 -0
  59. package/dist/cjs/placeholder/Placeholder.js +34 -0
  60. package/dist/cjs/placeholder/index.js +9 -0
  61. package/dist/cjs/placeholder/loosely-lazy/index.js +19 -0
  62. package/dist/cjs/placeholder/loosely-lazy/lazy-suspense.js +80 -0
  63. package/dist/cjs/placeholder/loosely-lazy/types.js +5 -0
  64. package/dist/cjs/placeholder/loosely-lazy/wait-context.js +15 -0
  65. package/dist/cjs/resource-timing/common/types.js +1 -0
  66. package/dist/cjs/resource-timing/common/utils/config.js +70 -0
  67. package/dist/cjs/resource-timing/common/utils/resource-timing-buffer.js +111 -0
  68. package/dist/cjs/resource-timing/index.js +26 -0
  69. package/dist/cjs/resource-timing/main.js +141 -0
  70. package/dist/cjs/resource-timing/utils.js +10 -0
  71. package/dist/cjs/round-number/index.js +11 -0
  72. package/dist/cjs/route-name/index.js +12 -0
  73. package/dist/cjs/route-name-context/index.js +11 -0
  74. package/dist/cjs/segment/index.js +9 -0
  75. package/dist/cjs/segment/segment-highlight.js +40 -0
  76. package/dist/cjs/segment/segment.js +247 -0
  77. package/dist/cjs/set-interaction-error/index.js +17 -0
  78. package/dist/cjs/short-id/index.js +15 -0
  79. package/dist/cjs/ssr/index.js +70 -0
  80. package/dist/cjs/trace-interaction/index.js +48 -0
  81. package/dist/cjs/trace-pageload/index.js +58 -0
  82. package/dist/cjs/trace-press/index.js +34 -0
  83. package/dist/cjs/trace-redirect/index.js +17 -0
  84. package/dist/cjs/trace-transition/index.js +60 -0
  85. package/dist/cjs/trace-transition/utils/generate-span-id/index.js +11 -0
  86. package/dist/cjs/trace-transition/utils/set-interaction-active-trace/index.js +11 -0
  87. package/dist/cjs/typing-performance-tracing/index.js +262 -0
  88. package/dist/cjs/use-press-tracing/index.js +19 -0
  89. package/dist/cjs/vc/index.js +15 -0
  90. package/dist/cjs/vc/vc-observer/attachAbortListeners.js +40 -0
  91. package/dist/cjs/vc/vc-observer/getViewport.js +27 -0
  92. package/dist/cjs/vc/vc-observer/index.js +562 -0
  93. package/dist/cjs/vc/vc-observer/media-wrapper/index.js +15 -0
  94. package/dist/cjs/vc/vc-observer/media-wrapper/vc-utils.js +16 -0
  95. package/dist/cjs/vc/vc-observer/observers/index.js +270 -0
  96. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +183 -0
  97. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.js +22 -0
  98. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.js +20 -0
  99. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.js +19 -0
  100. package/dist/cjs/vc/vc-observer/observers/types.js +5 -0
  101. package/dist/es2019/additional-payload/index.js +2 -0
  102. package/dist/es2019/additional-payload/utils/cache-hit-ratio/index.js +63 -0
  103. package/dist/es2019/additional-payload/utils/lighthouse-metrics/cls/index.js +33 -0
  104. package/dist/es2019/additional-payload/utils/lighthouse-metrics/const.js +4 -0
  105. package/dist/es2019/additional-payload/utils/lighthouse-metrics/index.js +23 -0
  106. package/dist/es2019/additional-payload/utils/lighthouse-metrics/tbt/index.js +15 -0
  107. package/dist/es2019/additional-payload/utils/lighthouse-metrics/utils/buffer/index.js +23 -0
  108. package/dist/es2019/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +31 -0
  109. package/dist/es2019/bundle-eval-timing/index.js +43 -0
  110. package/dist/es2019/coinflip/index.js +16 -0
  111. package/dist/es2019/common/common/types.js +1 -0
  112. package/dist/es2019/common/constants.js +1 -0
  113. package/dist/es2019/common/vc/types.js +5 -0
  114. package/dist/es2019/config/index.js +215 -0
  115. package/dist/es2019/create-payload/common/types.js +0 -0
  116. package/dist/es2019/create-payload/common/utils/index.js +8 -0
  117. package/dist/es2019/create-payload/index.js +792 -0
  118. package/dist/es2019/create-post-interaction-log-payload/index.js +188 -0
  119. package/dist/es2019/custom-data/index.js +24 -0
  120. package/dist/es2019/custom-data/types.js +1 -0
  121. package/dist/es2019/custom-mark/index.js +38 -0
  122. package/dist/es2019/custom-spans/index.js +6 -0
  123. package/dist/es2019/custom-timings/index.js +57 -0
  124. package/dist/es2019/experience-trace-id-context/index.js +31 -0
  125. package/dist/es2019/experience-trace-id-context/types.js +0 -0
  126. package/dist/es2019/experience-trace-id-context/utils/make-trace-http-request-headers/index.js +4 -0
  127. package/dist/es2019/feature-flags-accessed/common/constants.js +1 -0
  128. package/dist/es2019/feature-flags-accessed/common/types.js +1 -0
  129. package/dist/es2019/feature-flags-accessed/common/utils/index.js +24 -0
  130. package/dist/es2019/feature-flags-accessed/index.js +21 -0
  131. package/dist/es2019/generate-id/index.js +6 -0
  132. package/dist/es2019/global-error-handler/index.js +64 -0
  133. package/dist/es2019/hidden-timing/index.js +87 -0
  134. package/dist/es2019/initial-page-load-extra-timing/index.js +43 -0
  135. package/dist/es2019/interaction-context/index.js +6 -0
  136. package/dist/es2019/interaction-id-context/index.js +18 -0
  137. package/dist/es2019/interaction-metrics/common/constants.js +2 -0
  138. package/dist/es2019/interaction-metrics/index.js +736 -0
  139. package/dist/es2019/interaction-metrics/post-interaction-log.js +158 -0
  140. package/dist/es2019/interaction-metrics-init/index.js +72 -0
  141. package/dist/es2019/label/UFOLabel.js +34 -0
  142. package/dist/es2019/label/index.js +2 -0
  143. package/dist/es2019/load-hold/UFOLoadHold.js +66 -0
  144. package/dist/es2019/load-hold/index.js +2 -0
  145. package/dist/es2019/placeholder/Placeholder.js +25 -0
  146. package/dist/es2019/placeholder/index.js +2 -0
  147. package/dist/es2019/placeholder/loosely-lazy/index.js +2 -0
  148. package/dist/es2019/placeholder/loosely-lazy/lazy-suspense.js +63 -0
  149. package/dist/es2019/placeholder/loosely-lazy/types.js +1 -0
  150. package/dist/es2019/placeholder/loosely-lazy/wait-context.js +5 -0
  151. package/dist/es2019/resource-timing/common/types.js +0 -0
  152. package/dist/es2019/resource-timing/common/utils/config.js +44 -0
  153. package/dist/es2019/resource-timing/common/utils/resource-timing-buffer.js +88 -0
  154. package/dist/es2019/resource-timing/index.js +3 -0
  155. package/dist/es2019/resource-timing/main.js +130 -0
  156. package/dist/es2019/resource-timing/utils.js +4 -0
  157. package/dist/es2019/round-number/index.js +4 -0
  158. package/dist/es2019/route-name/index.js +6 -0
  159. package/dist/es2019/route-name-context/index.js +5 -0
  160. package/dist/es2019/segment/index.js +2 -0
  161. package/dist/es2019/segment/segment-highlight.js +27 -0
  162. package/dist/es2019/segment/segment.js +218 -0
  163. package/dist/es2019/set-interaction-error/index.js +11 -0
  164. package/dist/es2019/short-id/index.js +8 -0
  165. package/dist/es2019/ssr/index.js +54 -0
  166. package/dist/es2019/trace-interaction/index.js +41 -0
  167. package/dist/es2019/trace-pageload/index.js +48 -0
  168. package/dist/es2019/trace-press/index.js +27 -0
  169. package/dist/es2019/trace-redirect/index.js +10 -0
  170. package/dist/es2019/trace-transition/index.js +48 -0
  171. package/dist/es2019/trace-transition/utils/generate-span-id/index.js +1 -0
  172. package/dist/es2019/trace-transition/utils/set-interaction-active-trace/index.js +5 -0
  173. package/dist/es2019/typing-performance-tracing/index.js +255 -0
  174. package/dist/es2019/use-press-tracing/index.js +12 -0
  175. package/dist/es2019/vc/index.js +8 -0
  176. package/dist/es2019/vc/vc-observer/attachAbortListeners.js +34 -0
  177. package/dist/es2019/vc/vc-observer/getViewport.js +18 -0
  178. package/dist/es2019/vc/vc-observer/index.js +522 -0
  179. package/dist/es2019/vc/vc-observer/media-wrapper/index.js +9 -0
  180. package/dist/es2019/vc/vc-observer/media-wrapper/vc-utils.js +10 -0
  181. package/dist/es2019/vc/vc-observer/observers/index.js +231 -0
  182. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +146 -0
  183. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.js +16 -0
  184. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.js +14 -0
  185. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.js +2 -0
  186. package/dist/es2019/vc/vc-observer/observers/types.js +1 -0
  187. package/dist/esm/additional-payload/index.js +2 -0
  188. package/dist/esm/additional-payload/utils/cache-hit-ratio/index.js +63 -0
  189. package/dist/esm/additional-payload/utils/lighthouse-metrics/cls/index.js +47 -0
  190. package/dist/esm/additional-payload/utils/lighthouse-metrics/cls/types.js +0 -0
  191. package/dist/esm/additional-payload/utils/lighthouse-metrics/const.js +4 -0
  192. package/dist/esm/additional-payload/utils/lighthouse-metrics/index.js +22 -0
  193. package/dist/esm/additional-payload/utils/lighthouse-metrics/tbt/index.js +19 -0
  194. package/dist/esm/additional-payload/utils/lighthouse-metrics/utils/buffer/index.js +31 -0
  195. package/dist/esm/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +31 -0
  196. package/dist/esm/bundle-eval-timing/index.js +41 -0
  197. package/dist/esm/coinflip/index.js +16 -0
  198. package/dist/esm/common/common/types.js +1 -0
  199. package/dist/esm/common/constants.js +1 -0
  200. package/dist/esm/common/index.js +0 -0
  201. package/dist/esm/common/vc/types.js +5 -0
  202. package/dist/esm/config/index.js +206 -0
  203. package/dist/esm/create-payload/common/types.js +0 -0
  204. package/dist/esm/create-payload/common/utils/index.js +8 -0
  205. package/dist/esm/create-payload/index.js +774 -0
  206. package/dist/esm/create-post-interaction-log-payload/index.js +200 -0
  207. package/dist/esm/custom-data/index.js +23 -0
  208. package/dist/esm/custom-data/types.js +1 -0
  209. package/dist/esm/custom-mark/index.js +36 -0
  210. package/dist/esm/custom-spans/index.js +8 -0
  211. package/dist/esm/custom-timings/index.js +56 -0
  212. package/dist/esm/experience-trace-id-context/index.js +34 -0
  213. package/dist/esm/experience-trace-id-context/types.js +0 -0
  214. package/dist/esm/experience-trace-id-context/utils/make-trace-http-request-headers/index.js +6 -0
  215. package/dist/esm/feature-flags-accessed/common/constants.js +1 -0
  216. package/dist/esm/feature-flags-accessed/common/types.js +1 -0
  217. package/dist/esm/feature-flags-accessed/common/utils/index.js +31 -0
  218. package/dist/esm/feature-flags-accessed/index.js +21 -0
  219. package/dist/esm/generate-id/index.js +6 -0
  220. package/dist/esm/global-error-handler/index.js +67 -0
  221. package/dist/esm/hidden-timing/index.js +87 -0
  222. package/dist/esm/initial-page-load-extra-timing/index.js +42 -0
  223. package/dist/esm/interaction-context/index.js +6 -0
  224. package/dist/esm/interaction-id-context/index.js +22 -0
  225. package/dist/esm/interaction-metrics/common/constants.js +2 -0
  226. package/dist/esm/interaction-metrics/index.js +773 -0
  227. package/dist/esm/interaction-metrics/post-interaction-log.js +184 -0
  228. package/dist/esm/interaction-metrics-init/index.js +77 -0
  229. package/dist/esm/label/UFOLabel.js +36 -0
  230. package/dist/esm/label/index.js +2 -0
  231. package/dist/esm/load-hold/UFOLoadHold.js +66 -0
  232. package/dist/esm/load-hold/index.js +2 -0
  233. package/dist/esm/placeholder/Placeholder.js +25 -0
  234. package/dist/esm/placeholder/index.js +2 -0
  235. package/dist/esm/placeholder/loosely-lazy/index.js +2 -0
  236. package/dist/esm/placeholder/loosely-lazy/lazy-suspense.js +70 -0
  237. package/dist/esm/placeholder/loosely-lazy/types.js +1 -0
  238. package/dist/esm/placeholder/loosely-lazy/wait-context.js +9 -0
  239. package/dist/esm/resource-timing/common/types.js +0 -0
  240. package/dist/esm/resource-timing/common/utils/config.js +62 -0
  241. package/dist/esm/resource-timing/common/utils/resource-timing-buffer.js +104 -0
  242. package/dist/esm/resource-timing/index.js +3 -0
  243. package/dist/esm/resource-timing/main.js +134 -0
  244. package/dist/esm/resource-timing/utils.js +4 -0
  245. package/dist/esm/round-number/index.js +5 -0
  246. package/dist/esm/route-name/index.js +6 -0
  247. package/dist/esm/route-name-context/index.js +5 -0
  248. package/dist/esm/segment/index.js +2 -0
  249. package/dist/esm/segment/segment-highlight.js +30 -0
  250. package/dist/esm/segment/segment.js +235 -0
  251. package/dist/esm/set-interaction-error/index.js +11 -0
  252. package/dist/esm/short-id/index.js +9 -0
  253. package/dist/esm/ssr/index.js +59 -0
  254. package/dist/esm/trace-interaction/index.js +41 -0
  255. package/dist/esm/trace-pageload/index.js +50 -0
  256. package/dist/esm/trace-press/index.js +27 -0
  257. package/dist/esm/trace-redirect/index.js +10 -0
  258. package/dist/esm/trace-transition/index.js +49 -0
  259. package/dist/esm/trace-transition/utils/generate-span-id/index.js +5 -0
  260. package/dist/esm/trace-transition/utils/set-interaction-active-trace/index.js +5 -0
  261. package/dist/esm/typing-performance-tracing/index.js +255 -0
  262. package/dist/esm/use-press-tracing/index.js +12 -0
  263. package/dist/esm/vc/index.js +9 -0
  264. package/dist/esm/vc/vc-observer/attachAbortListeners.js +34 -0
  265. package/dist/esm/vc/vc-observer/getViewport.js +20 -0
  266. package/dist/esm/vc/vc-observer/index.js +555 -0
  267. package/dist/esm/vc/vc-observer/media-wrapper/index.js +7 -0
  268. package/dist/esm/vc/vc-observer/media-wrapper/vc-utils.js +10 -0
  269. package/dist/esm/vc/vc-observer/observers/index.js +263 -0
  270. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +176 -0
  271. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.js +16 -0
  272. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.js +14 -0
  273. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.js +2 -0
  274. package/dist/esm/vc/vc-observer/observers/types.js +1 -0
  275. package/dist/types/additional-payload/index.d.ts +2 -0
  276. package/dist/types/additional-payload/utils/cache-hit-ratio/index.d.ts +8 -0
  277. package/dist/types/additional-payload/utils/lighthouse-metrics/cls/index.d.ts +2 -0
  278. package/dist/types/additional-payload/utils/lighthouse-metrics/cls/types.d.ts +3 -0
  279. package/dist/types/additional-payload/utils/lighthouse-metrics/const.d.ts +5 -0
  280. package/dist/types/additional-payload/utils/lighthouse-metrics/index.d.ts +7 -0
  281. package/dist/types/additional-payload/utils/lighthouse-metrics/tbt/index.d.ts +5 -0
  282. package/dist/types/additional-payload/utils/lighthouse-metrics/utils/buffer/index.d.ts +13 -0
  283. package/dist/types/additional-payload/utils/lighthouse-metrics/utils/observer/index.d.ts +2 -0
  284. package/dist/types/bundle-eval-timing/index.d.ts +16 -0
  285. package/dist/types/coinflip/index.d.ts +8 -0
  286. package/dist/types/common/common/types.d.ts +201 -0
  287. package/dist/types/common/constants.d.ts +1 -0
  288. package/dist/types/common/index.d.ts +5 -0
  289. package/dist/types/common/vc/types.d.ts +91 -0
  290. package/dist/types/config/index.d.ts +91 -0
  291. package/dist/types/create-payload/common/types.d.ts +4 -0
  292. package/dist/types/create-payload/common/utils/index.d.ts +3 -0
  293. package/dist/types/create-payload/index.d.ts +2969 -0
  294. package/dist/types/create-post-interaction-log-payload/index.d.ts +45 -0
  295. package/dist/types/custom-data/index.d.ts +5 -0
  296. package/dist/types/custom-data/types.d.ts +4 -0
  297. package/dist/types/custom-mark/index.d.ts +10 -0
  298. package/dist/types/custom-spans/index.d.ts +1 -0
  299. package/dist/types/custom-timings/index.d.ts +19 -0
  300. package/dist/types/experience-trace-id-context/index.d.ts +10 -0
  301. package/dist/types/experience-trace-id-context/types.d.ts +8 -0
  302. package/dist/types/experience-trace-id-context/utils/make-trace-http-request-headers/index.d.ts +4 -0
  303. package/dist/types/feature-flags-accessed/common/constants.d.ts +1 -0
  304. package/dist/types/feature-flags-accessed/common/types.d.ts +2 -0
  305. package/dist/types/feature-flags-accessed/common/utils/index.d.ts +3 -0
  306. package/dist/types/feature-flags-accessed/index.d.ts +14 -0
  307. package/dist/types/generate-id/index.d.ts +2 -0
  308. package/dist/types/global-error-handler/index.d.ts +3 -0
  309. package/dist/types/hidden-timing/index.d.ts +7 -0
  310. package/dist/types/initial-page-load-extra-timing/index.d.ts +9 -0
  311. package/dist/types/interaction-context/index.d.ts +33 -0
  312. package/dist/types/interaction-id-context/index.d.ts +9 -0
  313. package/dist/types/interaction-metrics/common/constants.d.ts +3 -0
  314. package/dist/types/interaction-metrics/index.d.ts +65 -1
  315. package/dist/types/interaction-metrics/post-interaction-log.d.ts +69 -0
  316. package/dist/types/interaction-metrics-init/index.d.ts +11 -0
  317. package/dist/types/label/UFOLabel.d.ts +13 -0
  318. package/dist/types/label/index.d.ts +2 -0
  319. package/dist/types/load-hold/UFOLoadHold.d.ts +53 -0
  320. package/dist/types/load-hold/index.d.ts +2 -0
  321. package/dist/types/placeholder/Placeholder.d.ts +13 -0
  322. package/dist/types/placeholder/index.d.ts +2 -0
  323. package/dist/types/placeholder/loosely-lazy/index.d.ts +3 -0
  324. package/dist/types/placeholder/loosely-lazy/lazy-suspense.d.ts +6 -0
  325. package/dist/types/placeholder/loosely-lazy/types.d.ts +20 -0
  326. package/dist/types/placeholder/loosely-lazy/wait-context.d.ts +3 -0
  327. package/dist/types/resource-timing/common/types.d.ts +41 -0
  328. package/dist/types/resource-timing/common/utils/config.d.ts +3 -0
  329. package/dist/types/resource-timing/common/utils/resource-timing-buffer.d.ts +11 -0
  330. package/dist/types/resource-timing/index.d.ts +4 -0
  331. package/dist/types/resource-timing/main.d.ts +2 -0
  332. package/dist/types/resource-timing/utils.d.ts +1 -0
  333. package/dist/types/round-number/index.d.ts +1 -0
  334. package/dist/types/route-name/index.d.ts +4 -0
  335. package/dist/types/route-name-context/index.d.ts +5 -0
  336. package/dist/types/segment/index.d.ts +2 -0
  337. package/dist/types/segment/segment-highlight.d.ts +6 -0
  338. package/dist/types/segment/segment.d.ts +8 -0
  339. package/dist/types/set-interaction-error/index.d.ts +4 -0
  340. package/dist/types/short-id/index.d.ts +1 -0
  341. package/dist/types/ssr/index.d.ts +21 -0
  342. package/dist/types/trace-interaction/index.d.ts +2 -0
  343. package/dist/types/trace-pageload/index.d.ts +2 -0
  344. package/dist/types/trace-press/index.d.ts +1 -0
  345. package/dist/types/trace-redirect/index.d.ts +1 -0
  346. package/dist/types/trace-transition/index.d.ts +2 -0
  347. package/dist/types/trace-transition/utils/generate-span-id/index.d.ts +1 -0
  348. package/dist/types/trace-transition/utils/set-interaction-active-trace/index.d.ts +1 -0
  349. package/dist/types/typing-performance-tracing/index.d.ts +2 -0
  350. package/dist/types/use-press-tracing/index.d.ts +1 -0
  351. package/dist/types/vc/index.d.ts +2 -0
  352. package/dist/types/vc/vc-observer/attachAbortListeners.d.ts +6 -0
  353. package/dist/types/vc/vc-observer/getViewport.d.ts +2 -0
  354. package/dist/types/vc/vc-observer/index.d.ts +98 -0
  355. package/dist/types/vc/vc-observer/media-wrapper/index.d.ts +7 -0
  356. package/dist/types/vc/vc-observer/media-wrapper/vc-utils.d.ts +1 -0
  357. package/dist/types/vc/vc-observer/observers/index.d.ts +39 -0
  358. package/dist/types/vc/vc-observer/observers/ssr-placeholders/index.d.ts +23 -0
  359. package/dist/types/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.d.ts +1 -0
  360. package/dist/types/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.d.ts +1 -0
  361. package/dist/types/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.d.ts +2 -0
  362. package/dist/types/vc/vc-observer/observers/types.d.ts +11 -0
  363. package/dist/types-ts4.5/additional-payload/index.d.ts +2 -0
  364. package/dist/types-ts4.5/additional-payload/utils/cache-hit-ratio/index.d.ts +8 -0
  365. package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/cls/index.d.ts +2 -0
  366. package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/cls/types.d.ts +3 -0
  367. package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/const.d.ts +5 -0
  368. package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/index.d.ts +7 -0
  369. package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/tbt/index.d.ts +5 -0
  370. package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/utils/buffer/index.d.ts +13 -0
  371. package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/utils/observer/index.d.ts +2 -0
  372. package/dist/types-ts4.5/bundle-eval-timing/index.d.ts +16 -0
  373. package/dist/types-ts4.5/coinflip/index.d.ts +8 -0
  374. package/dist/types-ts4.5/common/common/types.d.ts +201 -0
  375. package/dist/types-ts4.5/common/constants.d.ts +1 -0
  376. package/dist/types-ts4.5/common/index.d.ts +5 -0
  377. package/dist/types-ts4.5/common/vc/types.d.ts +91 -0
  378. package/dist/types-ts4.5/config/index.d.ts +95 -0
  379. package/dist/types-ts4.5/create-payload/common/types.d.ts +4 -0
  380. package/dist/types-ts4.5/create-payload/common/utils/index.d.ts +3 -0
  381. package/dist/types-ts4.5/create-payload/index.d.ts +2969 -0
  382. package/dist/types-ts4.5/create-post-interaction-log-payload/index.d.ts +45 -0
  383. package/dist/types-ts4.5/custom-data/index.d.ts +5 -0
  384. package/dist/types-ts4.5/custom-data/types.d.ts +4 -0
  385. package/dist/types-ts4.5/custom-mark/index.d.ts +10 -0
  386. package/dist/types-ts4.5/custom-spans/index.d.ts +1 -0
  387. package/dist/types-ts4.5/custom-timings/index.d.ts +19 -0
  388. package/dist/types-ts4.5/experience-trace-id-context/index.d.ts +10 -0
  389. package/dist/types-ts4.5/experience-trace-id-context/types.d.ts +8 -0
  390. package/dist/types-ts4.5/experience-trace-id-context/utils/make-trace-http-request-headers/index.d.ts +4 -0
  391. package/dist/types-ts4.5/feature-flags-accessed/common/constants.d.ts +1 -0
  392. package/dist/types-ts4.5/feature-flags-accessed/common/types.d.ts +2 -0
  393. package/dist/types-ts4.5/feature-flags-accessed/common/utils/index.d.ts +3 -0
  394. package/dist/types-ts4.5/feature-flags-accessed/index.d.ts +14 -0
  395. package/dist/types-ts4.5/generate-id/index.d.ts +2 -0
  396. package/dist/types-ts4.5/global-error-handler/index.d.ts +3 -0
  397. package/dist/types-ts4.5/hidden-timing/index.d.ts +7 -0
  398. package/dist/types-ts4.5/initial-page-load-extra-timing/index.d.ts +9 -0
  399. package/dist/types-ts4.5/interaction-context/index.d.ts +33 -0
  400. package/dist/types-ts4.5/interaction-id-context/index.d.ts +9 -0
  401. package/dist/types-ts4.5/interaction-metrics/common/constants.d.ts +3 -0
  402. package/dist/types-ts4.5/interaction-metrics/index.d.ts +65 -1
  403. package/dist/types-ts4.5/interaction-metrics/post-interaction-log.d.ts +69 -0
  404. package/dist/types-ts4.5/interaction-metrics-init/index.d.ts +11 -0
  405. package/dist/types-ts4.5/label/UFOLabel.d.ts +13 -0
  406. package/dist/types-ts4.5/label/index.d.ts +2 -0
  407. package/dist/types-ts4.5/load-hold/UFOLoadHold.d.ts +53 -0
  408. package/dist/types-ts4.5/load-hold/index.d.ts +2 -0
  409. package/dist/types-ts4.5/placeholder/Placeholder.d.ts +13 -0
  410. package/dist/types-ts4.5/placeholder/index.d.ts +2 -0
  411. package/dist/types-ts4.5/placeholder/loosely-lazy/index.d.ts +3 -0
  412. package/dist/types-ts4.5/placeholder/loosely-lazy/lazy-suspense.d.ts +6 -0
  413. package/dist/types-ts4.5/placeholder/loosely-lazy/types.d.ts +20 -0
  414. package/dist/types-ts4.5/placeholder/loosely-lazy/wait-context.d.ts +3 -0
  415. package/dist/types-ts4.5/resource-timing/common/types.d.ts +41 -0
  416. package/dist/types-ts4.5/resource-timing/common/utils/config.d.ts +3 -0
  417. package/dist/types-ts4.5/resource-timing/common/utils/resource-timing-buffer.d.ts +11 -0
  418. package/dist/types-ts4.5/resource-timing/index.d.ts +4 -0
  419. package/dist/types-ts4.5/resource-timing/main.d.ts +2 -0
  420. package/dist/types-ts4.5/resource-timing/utils.d.ts +1 -0
  421. package/dist/types-ts4.5/round-number/index.d.ts +1 -0
  422. package/dist/types-ts4.5/route-name/index.d.ts +4 -0
  423. package/dist/types-ts4.5/route-name-context/index.d.ts +5 -0
  424. package/dist/types-ts4.5/segment/index.d.ts +2 -0
  425. package/dist/types-ts4.5/segment/segment-highlight.d.ts +6 -0
  426. package/dist/types-ts4.5/segment/segment.d.ts +8 -0
  427. package/dist/types-ts4.5/set-interaction-error/index.d.ts +4 -0
  428. package/dist/types-ts4.5/short-id/index.d.ts +1 -0
  429. package/dist/types-ts4.5/ssr/index.d.ts +21 -0
  430. package/dist/types-ts4.5/trace-interaction/index.d.ts +2 -0
  431. package/dist/types-ts4.5/trace-pageload/index.d.ts +2 -0
  432. package/dist/types-ts4.5/trace-press/index.d.ts +1 -0
  433. package/dist/types-ts4.5/trace-redirect/index.d.ts +1 -0
  434. package/dist/types-ts4.5/trace-transition/index.d.ts +2 -0
  435. package/dist/types-ts4.5/trace-transition/utils/generate-span-id/index.d.ts +1 -0
  436. package/dist/types-ts4.5/trace-transition/utils/set-interaction-active-trace/index.d.ts +1 -0
  437. package/dist/types-ts4.5/typing-performance-tracing/index.d.ts +2 -0
  438. package/dist/types-ts4.5/use-press-tracing/index.d.ts +1 -0
  439. package/dist/types-ts4.5/vc/index.d.ts +2 -0
  440. package/dist/types-ts4.5/vc/vc-observer/attachAbortListeners.d.ts +6 -0
  441. package/dist/types-ts4.5/vc/vc-observer/getViewport.d.ts +2 -0
  442. package/dist/types-ts4.5/vc/vc-observer/index.d.ts +98 -0
  443. package/dist/types-ts4.5/vc/vc-observer/media-wrapper/index.d.ts +7 -0
  444. package/dist/types-ts4.5/vc/vc-observer/media-wrapper/vc-utils.d.ts +1 -0
  445. package/dist/types-ts4.5/vc/vc-observer/observers/index.d.ts +39 -0
  446. package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/index.d.ts +23 -0
  447. package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.d.ts +1 -0
  448. package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.d.ts +1 -0
  449. package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.d.ts +2 -0
  450. package/dist/types-ts4.5/vc/vc-observer/observers/types.d.ts +11 -0
  451. package/experience-trace-id-context/package.json +15 -0
  452. package/feature-flags-accessed/package.json +15 -0
  453. package/generate-id/package.json +15 -0
  454. package/global-error-handler/package.json +15 -0
  455. package/hidden-timing/package.json +15 -0
  456. package/initial-page-load-extra-timing/package.json +15 -0
  457. package/interaction-context/package.json +15 -0
  458. package/interaction-id-context/package.json +15 -0
  459. package/interaction-metrics-init/package.json +15 -0
  460. package/label/package.json +15 -0
  461. package/load-hold/package.json +15 -0
  462. package/package.json +55 -3
  463. package/placeholder/package.json +15 -0
  464. package/resource-timing/package.json +15 -0
  465. package/round-number/package.json +15 -0
  466. package/route-name/package.json +15 -0
  467. package/route-name-context/package.json +15 -0
  468. package/segment/package.json +15 -0
  469. package/set-interaction-error/package.json +15 -0
  470. package/short-id/package.json +15 -0
  471. package/ssr/package.json +15 -0
  472. package/ssr-scripts/package.json +15 -0
  473. package/trace-interaction/package.json +15 -0
  474. package/trace-pageload/package.json +15 -0
  475. package/trace-press/package.json +15 -0
  476. package/trace-redirect/package.json +15 -0
  477. package/trace-transition/package.json +15 -0
  478. package/typing-performance-tracing/package.json +15 -0
  479. package/use-press-tracing/package.json +15 -0
  480. package/vc/media/package.json +15 -0
  481. package/vc/package.json +15 -0
  482. package/dist/types/common/types.d.ts +0 -17
  483. package/dist/types-ts4.5/common/types.d.ts +0 -17
  484. /package/dist/cjs/{common → additional-payload/utils/lighthouse-metrics/cls}/types.js +0 -0
  485. /package/dist/es2019/{common → additional-payload/utils/lighthouse-metrics/cls}/types.js +0 -0
  486. /package/dist/{esm/common/types.js → es2019/common/index.js} +0 -0
@@ -0,0 +1,270 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.Observers = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ var _vcUtils = require("../media-wrapper/vc-utils");
12
+ var _ssrPlaceholders = require("./ssr-placeholders");
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+ var state = {
16
+ normal: 1,
17
+ waitingForFirstRender: 2,
18
+ ignoring: 3
19
+ };
20
+ var Observers = exports.Observers = /*#__PURE__*/function () {
21
+ function Observers(opts) {
22
+ var _this = this;
23
+ (0, _classCallCheck2.default)(this, Observers);
24
+ (0, _defineProperty2.default)(this, "observedMutations", new WeakMap());
25
+ (0, _defineProperty2.default)(this, "elementsInView", new Set());
26
+ (0, _defineProperty2.default)(this, "callbacks", new Set());
27
+ (0, _defineProperty2.default)(this, "totalTime", 0);
28
+ (0, _defineProperty2.default)(this, "_startMeasureTimestamp", -1);
29
+ (0, _defineProperty2.default)(this, "ssr", {
30
+ state: state.normal,
31
+ reactRootElement: null,
32
+ renderStart: -1,
33
+ renderStop: -1
34
+ });
35
+ (0, _defineProperty2.default)(this, "selectorConfig", {
36
+ id: false,
37
+ testId: false,
38
+ role: false,
39
+ className: true,
40
+ dataVC: true
41
+ });
42
+ (0, _defineProperty2.default)(this, "subscribeResults", function (cb) {
43
+ _this.callbacks.add(cb);
44
+ });
45
+ (0, _defineProperty2.default)(this, "observeElement", function (node, mutation, _type, ignoreReason) {
46
+ var _this$intersectionObs;
47
+ (_this$intersectionObs = _this.intersectionObserver) === null || _this$intersectionObs === void 0 || _this$intersectionObs.observe(node);
48
+ _this.observedMutations.set(node, {
49
+ mutation: mutation,
50
+ ignoreReason: ignoreReason
51
+ });
52
+ });
53
+ this.selectorConfig = _objectSpread(_objectSpread({}, this.selectorConfig), opts.selectorConfig);
54
+ this.intersectionObserver = this.getIntersectionObserver();
55
+ this.mutationObserver = this.getMutationObserver();
56
+ this.ssrPlaceholderHandler = new _ssrPlaceholders.SSRPlaceholderHandlers();
57
+ }
58
+ (0, _createClass2.default)(Observers, [{
59
+ key: "isBrowserSupported",
60
+ value: function isBrowserSupported() {
61
+ return typeof window.IntersectionObserver === 'function' && typeof window.MutationObserver === 'function';
62
+ }
63
+ }, {
64
+ key: "observe",
65
+ value: function observe() {
66
+ var _this$mutationObserve;
67
+ this.totalTime = 0;
68
+ this.ssr = {
69
+ state: state.normal,
70
+ reactRootElement: null,
71
+ renderStart: -1,
72
+ renderStop: -1
73
+ };
74
+ (_this$mutationObserve = this.mutationObserver) === null || _this$mutationObserve === void 0 || _this$mutationObserve.observe(document.body, {
75
+ attributeFilter: ['hidden', 'style', 'src'],
76
+ attributeOldValue: true,
77
+ attributes: true,
78
+ childList: true,
79
+ subtree: true
80
+ });
81
+ }
82
+ }, {
83
+ key: "disconnect",
84
+ value: function disconnect() {
85
+ var _this$mutationObserve2, _this$intersectionObs2;
86
+ (_this$mutationObserve2 = this.mutationObserver) === null || _this$mutationObserve2 === void 0 || _this$mutationObserve2.disconnect();
87
+ (_this$intersectionObs2 = this.intersectionObserver) === null || _this$intersectionObs2 === void 0 || _this$intersectionObs2.disconnect();
88
+ this.observedMutations = new WeakMap();
89
+ this.elementsInView = new Set();
90
+ this.callbacks = new Set();
91
+ this.ssr.reactRootElement = null;
92
+ this.ssrPlaceholderHandler.clear();
93
+ }
94
+ }, {
95
+ key: "getTotalTime",
96
+ value: function getTotalTime() {
97
+ return this.totalTime;
98
+ }
99
+ }, {
100
+ key: "setReactRootElement",
101
+ value: function setReactRootElement(element) {
102
+ this.ssr.reactRootElement = element;
103
+ }
104
+ }, {
105
+ key: "setReactRootRenderStart",
106
+ value: function setReactRootRenderStart() {
107
+ var startTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : performance.now();
108
+ this.ssr.renderStart = startTime;
109
+ this.ssr.state = state.waitingForFirstRender;
110
+ }
111
+ }, {
112
+ key: "setReactRootRenderStop",
113
+ value: function setReactRootRenderStop() {
114
+ var stopTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : performance.now();
115
+ this.ssr.renderStop = stopTime;
116
+ }
117
+ }, {
118
+ key: "getMutationObserver",
119
+ value: function getMutationObserver() {
120
+ var _this2 = this;
121
+ return this.isBrowserSupported() ? new MutationObserver(function (mutations) {
122
+ _this2.measureStart();
123
+ mutations.forEach(function (mutation) {
124
+ // patching element if timestamp not automatically added
125
+ // eslint-disable-next-line no-param-reassign
126
+ mutation.timestamp = mutation.timestamp === undefined ? performance.now() : mutation.timestamp;
127
+ var ignoreReason = '';
128
+ if (_this2.ssr.state === state.waitingForFirstRender && mutation.timestamp > _this2.ssr.renderStart && mutation.target === _this2.ssr.reactRootElement) {
129
+ _this2.ssr.state = state.ignoring;
130
+ if (_this2.ssr.renderStop === -1) {
131
+ // arbitrary 500ms DOM update window
132
+ _this2.ssr.renderStop = mutation.timestamp + 500;
133
+ }
134
+ ignoreReason = 'ssr-hydration';
135
+ }
136
+ if (_this2.ssr.state === state.ignoring && mutation.timestamp > _this2.ssr.renderStart && mutation.target === _this2.ssr.reactRootElement) {
137
+ if (mutation.timestamp <= _this2.ssr.renderStop) {
138
+ ignoreReason = 'ssr-hydration';
139
+ } else {
140
+ _this2.ssr.state = state.normal;
141
+ }
142
+ }
143
+ if (mutation.type === 'childList') {
144
+ mutation.addedNodes.forEach(function (node) {
145
+ if ((0, _vcUtils.isContainedWithinMediaWrapper)(node)) {
146
+ ignoreReason = 'image';
147
+ }
148
+ if (node instanceof HTMLElement
149
+ /* && !node instanceof HTMLStyleElement && !node instanceof HTMLScriptElement && !node instanceof HTMLLinkElement */) {
150
+ if (_this2.ssrPlaceholderHandler.isPlaceholder(node) || _this2.ssrPlaceholderHandler.isPlaceholderIgnored(node)) {
151
+ _this2.ssrPlaceholderHandler.checkIfExistedAndSizeMatching(node).then(function (result) {
152
+ if (result === false) {
153
+ _this2.observeElement(node, mutation, 'html', ignoreReason);
154
+ }
155
+ });
156
+ return;
157
+ }
158
+ if (_this2.ssrPlaceholderHandler.isPlaceholderReplacement(node) || _this2.ssrPlaceholderHandler.isPlaceholderIgnored(node)) {
159
+ _this2.ssrPlaceholderHandler.validateReactComponentMatchToPlaceholder(node).then(function (result) {
160
+ if (result === false) {
161
+ _this2.observeElement(node, mutation, 'html', ignoreReason);
162
+ }
163
+ });
164
+ return;
165
+ }
166
+ _this2.observeElement(node, mutation, 'html', ignoreReason);
167
+ }
168
+ if (node instanceof Text && node.parentElement != null) {
169
+ _this2.observeElement(node.parentElement, mutation, 'text', ignoreReason);
170
+ }
171
+ });
172
+ mutation.removedNodes.forEach(function (node) {
173
+ if (node instanceof Element) {
174
+ var _this2$intersectionOb;
175
+ _this2.elementsInView.delete(node);
176
+ (_this2$intersectionOb = _this2.intersectionObserver) === null || _this2$intersectionOb === void 0 || _this2$intersectionOb.unobserve(node);
177
+ }
178
+ });
179
+ } else if (mutation.type === 'attributes') {
180
+ mutation.addedNodes.forEach(function (node) {
181
+ if (node instanceof HTMLElement) {
182
+ _this2.observeElement(node, mutation, 'attr', ignoreReason);
183
+ }
184
+ });
185
+ }
186
+ });
187
+ _this2.measureStop();
188
+ }) : null;
189
+ }
190
+ }, {
191
+ key: "getElementName",
192
+ value: function getElementName(element) {
193
+ try {
194
+ var tagName = element.localName;
195
+ var dataVCAttr = element.getAttribute('data-vc');
196
+ var dataVC = this.selectorConfig.dataVC && dataVCAttr ? "[data-vc=\"".concat(dataVCAttr, "\"]") : '';
197
+ var id = this.selectorConfig.id && element.id ? "#".concat(element.id) : '';
198
+ var testId = this.selectorConfig.testId ? element.getAttribute('data-testid') || element.getAttribute('data-test-id') : '';
199
+ testId = testId ? "[testid=".concat(testId, "]") : '';
200
+ var role = this.selectorConfig.role ? element.getAttribute('role') : '';
201
+ role = role ? "[role=".concat(role, "]") : '';
202
+ var classList = this.selectorConfig.className ? Array.from(element.classList).join('.') : '';
203
+ classList = classList === '' ? '' : ".".concat(classList);
204
+ var attrs = dataVC ? dataVC : [id, testId, role].join('');
205
+ var idString = '';
206
+ if (attrs === '' && classList === '') {
207
+ var parent = element.parentElement ? this.getElementName(element.parentElement) : 'unknown';
208
+ idString = "".concat(parent, " > ").concat(tagName);
209
+ } else {
210
+ idString = [tagName, attrs || classList].join('');
211
+ }
212
+ return idString;
213
+ } catch (e) {
214
+ return 'error';
215
+ }
216
+ }
217
+ }, {
218
+ key: "getIntersectionObserver",
219
+ value: function getIntersectionObserver() {
220
+ var _this3 = this;
221
+ return this.isBrowserSupported() ? new IntersectionObserver(function (entries) {
222
+ _this3.measureStart();
223
+ entries.forEach(function (_ref) {
224
+ var isIntersecting = _ref.isIntersecting,
225
+ ir = _ref.intersectionRect,
226
+ target = _ref.target;
227
+ var data = _this3.observedMutations.get(target);
228
+ _this3.observedMutations.delete(target);
229
+ if (isIntersecting && ir.width > 0 && ir.height > 0) {
230
+ if (!(target instanceof HTMLElement)) {
231
+ return;
232
+ }
233
+ if (!(data !== null && data !== void 0 && data.mutation)) {
234
+ // ignore intersection report without recent mutation
235
+ return;
236
+ }
237
+ _this3.callbacks.forEach(function (callback) {
238
+ var elementName;
239
+ try {
240
+ elementName = _this3.getElementName(target);
241
+ } catch (e) {
242
+ elementName = 'error';
243
+ }
244
+ callback(data.mutation.timestamp || performance.now(), ir, elementName, target, data.ignoreReason);
245
+ });
246
+ _this3.elementsInView.add(target);
247
+ } else {
248
+ _this3.elementsInView.delete(target);
249
+ }
250
+ });
251
+ _this3.measureStop();
252
+ }) : null;
253
+ }
254
+ }, {
255
+ key: "measureStart",
256
+ value: function measureStart() {
257
+ this._startMeasureTimestamp = performance.now();
258
+ }
259
+ }, {
260
+ key: "measureStop",
261
+ value: function measureStop() {
262
+ if (this._startMeasureTimestamp === -1) {
263
+ return;
264
+ }
265
+ this.totalTime += performance.now() - this._startMeasureTimestamp;
266
+ this._startMeasureTimestamp = -1;
267
+ }
268
+ }]);
269
+ return Observers;
270
+ }();
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.SSRPlaceholderHandlers = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
+ var EQUALITY_THRESHOLD = 0.1;
13
+ var ANCESTOR_LOOKUP_LIMIT = 10;
14
+ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/function () {
15
+ function SSRPlaceholderHandlers() {
16
+ var _this = this;
17
+ (0, _classCallCheck2.default)(this, SSRPlaceholderHandlers);
18
+ (0, _defineProperty2.default)(this, "staticPlaceholders", new Map());
19
+ (0, _defineProperty2.default)(this, "callbacks", new Map());
20
+ (0, _defineProperty2.default)(this, "getSizeCallbacks", new Map());
21
+ (0, _defineProperty2.default)(this, "reactValidateCallbacks", new Map());
22
+ (0, _defineProperty2.default)(this, "intersectionObserverCallback", function (_ref) {
23
+ var target = _ref.target,
24
+ boundingClientRect = _ref.boundingClientRect;
25
+ _this.intersectionObserver.unobserve(target);
26
+ if (!(target instanceof HTMLElement)) {
27
+ // impossible case - keep typescript healthy
28
+ return;
29
+ }
30
+ var staticKey = target.dataset.ssrPlaceholder || '';
31
+ if (staticKey) {
32
+ if (_this.staticPlaceholders.has(staticKey) && _this.callbacks.has(staticKey)) {
33
+ // validation
34
+ var _resolve = _this.callbacks.get(staticKey);
35
+ if (!_resolve) {
36
+ return;
37
+ }
38
+ var rect = _this.staticPlaceholders.get(staticKey);
39
+ var hasSameSizePosition = _this.hasSameSizePosition(rect, boundingClientRect);
40
+ _resolve(hasSameSizePosition);
41
+ _this.callbacks.delete(staticKey);
42
+ }
43
+ } else {
44
+ // react component check
45
+ var key = target.dataset.ssrPlaceholderReplace || '';
46
+ var _resolve2 = _this.reactValidateCallbacks.get(key);
47
+ if (!_resolve2) {
48
+ return;
49
+ }
50
+ var _rect = _this.staticPlaceholders.get(key);
51
+ var _hasSameSizePosition = _this.hasSameSizePosition(_rect, boundingClientRect);
52
+ _resolve2(_hasSameSizePosition);
53
+ _this.staticPlaceholders.delete(staticKey);
54
+ _this.reactValidateCallbacks.delete(staticKey);
55
+ }
56
+ });
57
+ this.intersectionObserver = new IntersectionObserver(function (entries) {
58
+ return (0, _platformFeatureFlags.fg)('no_ssr_placeholder_check_when_not_intersecting') ? entries.filter(function (entry) {
59
+ return entry.intersectionRatio > 0;
60
+ }).forEach(_this.intersectionObserverCallback) : entries.forEach(_this.intersectionObserverCallback);
61
+ });
62
+ if (window.document) {
63
+ try {
64
+ var existingElements = document.querySelectorAll('[data-ssr-placeholder]');
65
+ existingElements.forEach(function (el) {
66
+ var _el$dataset;
67
+ if (el instanceof HTMLElement && el !== null && el !== void 0 && (_el$dataset = el.dataset) !== null && _el$dataset !== void 0 && _el$dataset.ssrPlaceholder) {
68
+ var _window$__SSR_PLACEHO;
69
+ var width = -1;
70
+ var height = -1;
71
+ var x = -1;
72
+ var y = -1;
73
+ var boundingClientRect = (_window$__SSR_PLACEHO = window.__SSR_PLACEHOLDERS_DIMENSIONS__) === null || _window$__SSR_PLACEHO === void 0 ? void 0 : _window$__SSR_PLACEHO[el.dataset.ssrPlaceholder];
74
+ if (boundingClientRect) {
75
+ width = boundingClientRect.width;
76
+ height = boundingClientRect.height;
77
+ x = boundingClientRect.x;
78
+ y = boundingClientRect.y;
79
+ }
80
+ _this.staticPlaceholders.set(el.dataset.ssrPlaceholder, {
81
+ width: width,
82
+ height: height,
83
+ x: x,
84
+ y: y
85
+ });
86
+ _this.intersectionObserver.observe(el);
87
+ }
88
+ });
89
+ } catch (e) {} finally {
90
+ delete window.__SSR_PLACEHOLDERS_DIMENSIONS__;
91
+ }
92
+ }
93
+ }
94
+ (0, _createClass2.default)(SSRPlaceholderHandlers, [{
95
+ key: "clear",
96
+ value: function clear() {
97
+ this.staticPlaceholders = new Map();
98
+ this.callbacks = new Map();
99
+ this.getSizeCallbacks = new Map();
100
+ this.reactValidateCallbacks = new Map();
101
+ }
102
+ }, {
103
+ key: "isPlaceholder",
104
+ value: function isPlaceholder(element) {
105
+ return Boolean(element.dataset.ssrPlaceholder);
106
+ }
107
+ }, {
108
+ key: "isPlaceholderReplacement",
109
+ value: function isPlaceholderReplacement(element) {
110
+ return Boolean(element.dataset.ssrPlaceholderReplace);
111
+ }
112
+ }, {
113
+ key: "isPlaceholderIgnored",
114
+ value: function isPlaceholderIgnored(element) {
115
+ // data-ssr-placeholder-ignored doesn't have a value.
116
+ return 'ssrPlaceholderIgnored' in element.dataset;
117
+ }
118
+ }, {
119
+ key: "findNearestPlaceholderContainerIfIgnored",
120
+ value: function findNearestPlaceholderContainerIfIgnored(element) {
121
+ if (!this.isPlaceholderIgnored(element)) {
122
+ return element;
123
+ }
124
+ var ancestor = element.parentElement;
125
+ var i = 0;
126
+ while (ancestor && i < ANCESTOR_LOOKUP_LIMIT) {
127
+ if (this.isPlaceholder(ancestor) || this.isPlaceholderReplacement(ancestor)) {
128
+ return ancestor;
129
+ }
130
+ ancestor = ancestor.parentElement;
131
+ i++;
132
+ }
133
+ return element;
134
+ }
135
+ }, {
136
+ key: "checkIfExistedAndSizeMatching",
137
+ value: function checkIfExistedAndSizeMatching(el) {
138
+ var _this2 = this;
139
+ el = this.findNearestPlaceholderContainerIfIgnored(el);
140
+ var id = el.dataset.ssrPlaceholder || '';
141
+ return new Promise(function (resolve) {
142
+ if (!_this2.staticPlaceholders.has(id)) {
143
+ resolve(false);
144
+ return;
145
+ } else {
146
+ _this2.callbacks.set(id, resolve);
147
+ _this2.intersectionObserver.observe(el);
148
+ }
149
+ });
150
+ }
151
+ }, {
152
+ key: "getSize",
153
+ value: function getSize(el) {
154
+ var _this3 = this;
155
+ return new Promise(function (resolve) {
156
+ _this3.getSizeCallbacks.set(el.dataset.ssrPlaceholder || '', resolve);
157
+ _this3.intersectionObserver.observe(el);
158
+ });
159
+ }
160
+ }, {
161
+ key: "validateReactComponentMatchToPlaceholder",
162
+ value: function validateReactComponentMatchToPlaceholder(el) {
163
+ var _this4 = this;
164
+ el = this.findNearestPlaceholderContainerIfIgnored(el);
165
+ var id = el.dataset.ssrPlaceholderReplace || '';
166
+ return new Promise(function (resolve) {
167
+ if (!_this4.staticPlaceholders.has(id)) {
168
+ resolve(false);
169
+ return;
170
+ } else {
171
+ _this4.reactValidateCallbacks.set(id, resolve);
172
+ _this4.intersectionObserver.observe(el);
173
+ }
174
+ });
175
+ }
176
+ }, {
177
+ key: "hasSameSizePosition",
178
+ value: function hasSameSizePosition(rect, boundingClientRect) {
179
+ return rect && Math.abs(rect.x - boundingClientRect.x) < EQUALITY_THRESHOLD && Math.abs(rect.y - boundingClientRect.y) < EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < EQUALITY_THRESHOLD || false;
180
+ }
181
+ }]);
182
+ return SSRPlaceholderHandlers;
183
+ }();
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.bindAbortListeners = bindAbortListeners;
7
+ var _attachAbortListeners = require("../../../attachAbortListeners");
8
+ var _getViewport = require("../../../getViewport");
9
+ function bindAbortListeners(document, window) {
10
+ var viewport = {
11
+ w: (0, _getViewport.getViewportWidth)(document),
12
+ h: (0, _getViewport.getViewportHeight)(document)
13
+ };
14
+ var aborts = {};
15
+ var unbinds = (0, _attachAbortListeners.attachAbortListeners)(window, viewport, function (key, time) {
16
+ aborts[key] = time;
17
+ });
18
+ window.__SSR_ABORT_LISTENERS__ = {
19
+ unbinds: unbinds,
20
+ aborts: aborts
21
+ };
22
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectSSRPlaceholderDimensions = collectSSRPlaceholderDimensions;
7
+ // lightweight script to scan the SSR response and collect all elements with data-ssr-placeholder attribute
8
+ // and save their size/positions in a map __SSR_PLACEHOLDERS_DIMENSIONS__ on the Window object. Each placeholderId is
9
+ // unique and maps to its corresponding elements bounding client rectangle dimensions.
10
+ function collectSSRPlaceholderDimensions(document, window) {
11
+ var ssrPlaceholders = document === null || document === void 0 ? void 0 : document.querySelectorAll('[data-ssr-placeholder]');
12
+ ssrPlaceholders.forEach(function (elem) {
13
+ var placeholderId = elem.getAttribute('data-ssr-placeholder');
14
+ var boundingClient = elem.getBoundingClientRect();
15
+ if (placeholderId) {
16
+ window.__SSR_PLACEHOLDERS_DIMENSIONS__ = window.__SSR_PLACEHOLDERS_DIMENSIONS__ || {};
17
+ window.__SSR_PLACEHOLDERS_DIMENSIONS__[placeholderId] = boundingClient;
18
+ }
19
+ });
20
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "bindAbortListeners", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _bindAbortListeners.bindAbortListeners;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "collectSSRPlaceholderDimensions", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _collectSSRPlaceholderDimensions.collectSSRPlaceholderDimensions;
16
+ }
17
+ });
18
+ var _collectSSRPlaceholderDimensions = require("./collectSSRPlaceholderDimensions");
19
+ var _bindAbortListeners = require("./bindAbortListeners");
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,2 @@
1
+ export { startLighthouseObserver, getLighthouseMetrics } from './utils/lighthouse-metrics';
2
+ export { getCacheHitRatio } from './utils/cache-hit-ratio';
@@ -0,0 +1,63 @@
1
+ /* Borrowed from https://bitbucket.org/atlassian/atlassian-frontend/src/master/packages/performance/browser-metrics/src/plugins/timings/resource.ts */
2
+ const cacheableTypes = ['script', 'link'];
3
+ const CACHE_NETWORK = 'network';
4
+ const CACHE_MEMORY = 'memory';
5
+ const CACHE_DISK = 'disk';
6
+ const calculateTransferType = (type, duration, size) => {
7
+ if (!cacheableTypes.includes(type)) {
8
+ return CACHE_NETWORK;
9
+ }
10
+ if ((size === undefined || size === 0) && duration === 0) {
11
+ return CACHE_MEMORY;
12
+ }
13
+ if (size === 0 && duration > 0) {
14
+ return CACHE_DISK;
15
+ }
16
+ if (size === undefined) {
17
+ return null;
18
+ }
19
+ return CACHE_NETWORK;
20
+ };
21
+ export const getCacheHitRatio = ({
22
+ start
23
+ }) => {
24
+ let fromCache = 0;
25
+ let preloadFromCache = 0;
26
+ let total = 0;
27
+ let totalPreload = 0;
28
+
29
+ // initial load only
30
+ if (start !== 0) {
31
+ return {};
32
+ }
33
+ try {
34
+ for (const entry of performance.getEntriesByType('resource')) {
35
+ // The BM3 resource timing collector checks for whether the timing information is available,
36
+ // but we can make the assumption that it is for this Jira specific collector.
37
+ const transferType = calculateTransferType(entry.initiatorType, entry.duration, entry.transferSize);
38
+ const isPreload = entry.initiatorType === 'link';
39
+ if (transferType === 'disk' || transferType === 'memory') {
40
+ fromCache += 1;
41
+ if (isPreload) {
42
+ preloadFromCache += 1;
43
+ }
44
+ }
45
+ if (transferType !== null) {
46
+ total += 1;
47
+ if (isPreload) {
48
+ totalPreload += 1;
49
+ }
50
+ }
51
+ }
52
+ const result = {};
53
+ if (total > 0) {
54
+ result.cacheHitRatio = fromCache / total;
55
+ }
56
+ if (totalPreload > 0) {
57
+ result.preloadCacheHitRatio = preloadFromCache / totalPreload;
58
+ }
59
+ return result;
60
+ } catch (e) {
61
+ return {};
62
+ }
63
+ };
@@ -0,0 +1,33 @@
1
+ export const getCLS = (start, stop, buffer) => {
2
+ const layoutShifts = buffer.getAll().filter(entry => entry.startTime >= start && entry.startTime <= stop);
3
+ const sessionWindows = [];
4
+ let currentWindow = null;
5
+
6
+ // Group layout shifts into session windows
7
+ for (const shift of layoutShifts) {
8
+ const {
9
+ startTime
10
+ } = shift;
11
+ const endTime = shift.startTime + shift.duration;
12
+ const score = shift.value;
13
+ if (currentWindow === null || startTime - currentWindow.endTime > 1000 || endTime - currentWindow.startTime > 5000) {
14
+ // Start a new session window
15
+ currentWindow = {
16
+ startTime,
17
+ endTime,
18
+ score
19
+ };
20
+ sessionWindows.push(currentWindow);
21
+ } else {
22
+ // Add layout shift to current session window
23
+ currentWindow.endTime = endTime;
24
+ currentWindow.score += score;
25
+ }
26
+ }
27
+
28
+ // Find session window with highest cumulative score
29
+ const maxScore = sessionWindows.reduce((max, sessionWindow) => sessionWindow.score > max ? sessionWindow.score : max, 0);
30
+
31
+ // Return score of largest burst as CLS metric
32
+ return Math.round(maxScore * 10000) / 10000;
33
+ };
@@ -0,0 +1,4 @@
1
+ export const PerformanceObserverEntryTypes = {
2
+ LayoutShift: 'layout-shift',
3
+ LongTask: 'longtask'
4
+ };
@@ -0,0 +1,23 @@
1
+ import { getCLS } from './cls';
2
+ import { PerformanceObserverEntryTypes } from './const';
3
+ import { getTBT } from './tbt';
4
+ import { EntriesBuffer } from './utils/buffer';
5
+ import { startLSObserver, startLTObserver } from './utils/observer';
6
+ export function startLighthouseObserver() {
7
+ startLSObserver();
8
+ startLTObserver();
9
+ }
10
+ export const getLighthouseMetrics = ({
11
+ start,
12
+ stop
13
+ }) => {
14
+ const tbt = getTBT(start, stop, EntriesBuffer[PerformanceObserverEntryTypes.LongTask]);
15
+
16
+ // no round as CLS is usually 0-1
17
+ const cls = getCLS(start, stop, EntriesBuffer[PerformanceObserverEntryTypes.LayoutShift]);
18
+ return {
19
+ 'metric:tbt': Math.round(tbt.total),
20
+ 'metric:tbt:observed': Math.round(tbt.observed),
21
+ 'metric:cls': cls
22
+ };
23
+ };
@@ -0,0 +1,15 @@
1
+ const MAX_ACCEPTABLE_TASK_DURATION = 50;
2
+ export const getTBT = (start, stop, buffer) => buffer.getAll().filter(entry => entry.startTime <= stop && entry.duration > MAX_ACCEPTABLE_TASK_DURATION && (entry.startTime >= start || entry.startTime + entry.duration >= start || entry.startTime <= start && entry.startTime + entry.duration >= stop)).reduce((tbt, entry) => {
3
+ const longTaskStop = entry.startTime + entry.duration;
4
+ const intersectStart = Math.max(entry.startTime + MAX_ACCEPTABLE_TASK_DURATION, start);
5
+ const intersectStop = Math.min(longTaskStop, stop);
6
+ const longTaskIncluded = Math.max(intersectStop - intersectStart, 0);
7
+ // eslint-disable-next-line no-param-reassign
8
+ tbt.observed += entry.duration - MAX_ACCEPTABLE_TASK_DURATION;
9
+ // eslint-disable-next-line no-param-reassign
10
+ tbt.total += longTaskIncluded;
11
+ return tbt;
12
+ }, {
13
+ total: 0,
14
+ observed: 0
15
+ });