@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.
- package/CHANGELOG.md +24 -0
- package/README.md +5 -0
- package/additional-payload/package.json +15 -0
- package/bundle-eval-timing/package.json +15 -0
- package/coinflip/package.json +15 -0
- package/common/package.json +5 -5
- package/config/package.json +15 -0
- package/create-payload/package.json +15 -0
- package/create-post-interaction-log-payload/package.json +15 -0
- package/custom-data/package.json +15 -0
- package/custom-mark/package.json +15 -0
- package/custom-spans/package.json +15 -0
- package/custom-timings/package.json +15 -0
- package/dist/cjs/additional-payload/index.js +25 -0
- package/dist/cjs/additional-payload/utils/cache-hit-ratio/index.js +69 -0
- package/dist/cjs/additional-payload/utils/lighthouse-metrics/cls/index.js +53 -0
- package/dist/cjs/additional-payload/utils/lighthouse-metrics/const.js +10 -0
- package/dist/cjs/additional-payload/utils/lighthouse-metrics/index.js +29 -0
- package/dist/cjs/additional-payload/utils/lighthouse-metrics/tbt/index.js +25 -0
- package/dist/cjs/additional-payload/utils/lighthouse-metrics/utils/buffer/index.js +38 -0
- package/dist/cjs/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +37 -0
- package/dist/cjs/bundle-eval-timing/index.js +48 -0
- package/dist/cjs/coinflip/index.js +22 -0
- package/dist/cjs/common/common/types.js +5 -0
- package/dist/cjs/common/constants.js +7 -0
- package/dist/cjs/common/index.js +1 -0
- package/dist/cjs/common/vc/types.js +11 -0
- package/dist/cjs/config/index.js +222 -0
- package/dist/cjs/create-payload/common/types.js +1 -0
- package/dist/cjs/create-payload/common/utils/index.js +15 -0
- package/dist/cjs/create-payload/index.js +784 -0
- package/dist/cjs/create-post-interaction-log-payload/index.js +207 -0
- package/dist/cjs/custom-data/index.js +31 -0
- package/dist/cjs/custom-data/types.js +5 -0
- package/dist/cjs/custom-mark/index.js +45 -0
- package/dist/cjs/custom-spans/index.js +14 -0
- package/dist/cjs/custom-timings/index.js +65 -0
- package/dist/cjs/experience-trace-id-context/index.js +40 -0
- package/dist/cjs/experience-trace-id-context/types.js +1 -0
- package/dist/cjs/experience-trace-id-context/utils/make-trace-http-request-headers/index.js +12 -0
- package/dist/cjs/feature-flags-accessed/common/constants.js +7 -0
- package/dist/cjs/feature-flags-accessed/common/types.js +5 -0
- package/dist/cjs/feature-flags-accessed/common/utils/index.js +38 -0
- package/dist/cjs/feature-flags-accessed/index.js +32 -0
- package/dist/cjs/generate-id/index.js +12 -0
- package/dist/cjs/global-error-handler/index.js +74 -0
- package/dist/cjs/hidden-timing/index.js +94 -0
- package/dist/cjs/initial-page-load-extra-timing/index.js +49 -0
- package/dist/cjs/interaction-context/index.js +14 -0
- package/dist/cjs/interaction-id-context/index.js +27 -0
- package/dist/cjs/interaction-metrics/common/constants.js +8 -0
- package/dist/cjs/interaction-metrics/index.js +810 -1
- package/dist/cjs/interaction-metrics/post-interaction-log.js +190 -0
- package/dist/cjs/interaction-metrics-init/index.js +89 -0
- package/dist/cjs/label/UFOLabel.js +45 -0
- package/dist/cjs/label/index.js +9 -0
- package/dist/cjs/load-hold/UFOLoadHold.js +76 -0
- package/dist/cjs/load-hold/index.js +9 -0
- package/dist/cjs/placeholder/Placeholder.js +34 -0
- package/dist/cjs/placeholder/index.js +9 -0
- package/dist/cjs/placeholder/loosely-lazy/index.js +19 -0
- package/dist/cjs/placeholder/loosely-lazy/lazy-suspense.js +80 -0
- package/dist/cjs/placeholder/loosely-lazy/types.js +5 -0
- package/dist/cjs/placeholder/loosely-lazy/wait-context.js +15 -0
- package/dist/cjs/resource-timing/common/types.js +1 -0
- package/dist/cjs/resource-timing/common/utils/config.js +70 -0
- package/dist/cjs/resource-timing/common/utils/resource-timing-buffer.js +111 -0
- package/dist/cjs/resource-timing/index.js +26 -0
- package/dist/cjs/resource-timing/main.js +141 -0
- package/dist/cjs/resource-timing/utils.js +10 -0
- package/dist/cjs/round-number/index.js +11 -0
- package/dist/cjs/route-name/index.js +12 -0
- package/dist/cjs/route-name-context/index.js +11 -0
- package/dist/cjs/segment/index.js +9 -0
- package/dist/cjs/segment/segment-highlight.js +40 -0
- package/dist/cjs/segment/segment.js +247 -0
- package/dist/cjs/set-interaction-error/index.js +17 -0
- package/dist/cjs/short-id/index.js +15 -0
- package/dist/cjs/ssr/index.js +70 -0
- package/dist/cjs/trace-interaction/index.js +48 -0
- package/dist/cjs/trace-pageload/index.js +58 -0
- package/dist/cjs/trace-press/index.js +34 -0
- package/dist/cjs/trace-redirect/index.js +17 -0
- package/dist/cjs/trace-transition/index.js +60 -0
- package/dist/cjs/trace-transition/utils/generate-span-id/index.js +11 -0
- package/dist/cjs/trace-transition/utils/set-interaction-active-trace/index.js +11 -0
- package/dist/cjs/typing-performance-tracing/index.js +262 -0
- package/dist/cjs/use-press-tracing/index.js +19 -0
- package/dist/cjs/vc/index.js +15 -0
- package/dist/cjs/vc/vc-observer/attachAbortListeners.js +40 -0
- package/dist/cjs/vc/vc-observer/getViewport.js +27 -0
- package/dist/cjs/vc/vc-observer/index.js +562 -0
- package/dist/cjs/vc/vc-observer/media-wrapper/index.js +15 -0
- package/dist/cjs/vc/vc-observer/media-wrapper/vc-utils.js +16 -0
- package/dist/cjs/vc/vc-observer/observers/index.js +270 -0
- package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +183 -0
- package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.js +22 -0
- package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.js +20 -0
- package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.js +19 -0
- package/dist/cjs/vc/vc-observer/observers/types.js +5 -0
- package/dist/es2019/additional-payload/index.js +2 -0
- package/dist/es2019/additional-payload/utils/cache-hit-ratio/index.js +63 -0
- package/dist/es2019/additional-payload/utils/lighthouse-metrics/cls/index.js +33 -0
- package/dist/es2019/additional-payload/utils/lighthouse-metrics/const.js +4 -0
- package/dist/es2019/additional-payload/utils/lighthouse-metrics/index.js +23 -0
- package/dist/es2019/additional-payload/utils/lighthouse-metrics/tbt/index.js +15 -0
- package/dist/es2019/additional-payload/utils/lighthouse-metrics/utils/buffer/index.js +23 -0
- package/dist/es2019/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +31 -0
- package/dist/es2019/bundle-eval-timing/index.js +43 -0
- package/dist/es2019/coinflip/index.js +16 -0
- package/dist/es2019/common/common/types.js +1 -0
- package/dist/es2019/common/constants.js +1 -0
- package/dist/es2019/common/vc/types.js +5 -0
- package/dist/es2019/config/index.js +215 -0
- package/dist/es2019/create-payload/common/types.js +0 -0
- package/dist/es2019/create-payload/common/utils/index.js +8 -0
- package/dist/es2019/create-payload/index.js +792 -0
- package/dist/es2019/create-post-interaction-log-payload/index.js +188 -0
- package/dist/es2019/custom-data/index.js +24 -0
- package/dist/es2019/custom-data/types.js +1 -0
- package/dist/es2019/custom-mark/index.js +38 -0
- package/dist/es2019/custom-spans/index.js +6 -0
- package/dist/es2019/custom-timings/index.js +57 -0
- package/dist/es2019/experience-trace-id-context/index.js +31 -0
- package/dist/es2019/experience-trace-id-context/types.js +0 -0
- package/dist/es2019/experience-trace-id-context/utils/make-trace-http-request-headers/index.js +4 -0
- package/dist/es2019/feature-flags-accessed/common/constants.js +1 -0
- package/dist/es2019/feature-flags-accessed/common/types.js +1 -0
- package/dist/es2019/feature-flags-accessed/common/utils/index.js +24 -0
- package/dist/es2019/feature-flags-accessed/index.js +21 -0
- package/dist/es2019/generate-id/index.js +6 -0
- package/dist/es2019/global-error-handler/index.js +64 -0
- package/dist/es2019/hidden-timing/index.js +87 -0
- package/dist/es2019/initial-page-load-extra-timing/index.js +43 -0
- package/dist/es2019/interaction-context/index.js +6 -0
- package/dist/es2019/interaction-id-context/index.js +18 -0
- package/dist/es2019/interaction-metrics/common/constants.js +2 -0
- package/dist/es2019/interaction-metrics/index.js +736 -0
- package/dist/es2019/interaction-metrics/post-interaction-log.js +158 -0
- package/dist/es2019/interaction-metrics-init/index.js +72 -0
- package/dist/es2019/label/UFOLabel.js +34 -0
- package/dist/es2019/label/index.js +2 -0
- package/dist/es2019/load-hold/UFOLoadHold.js +66 -0
- package/dist/es2019/load-hold/index.js +2 -0
- package/dist/es2019/placeholder/Placeholder.js +25 -0
- package/dist/es2019/placeholder/index.js +2 -0
- package/dist/es2019/placeholder/loosely-lazy/index.js +2 -0
- package/dist/es2019/placeholder/loosely-lazy/lazy-suspense.js +63 -0
- package/dist/es2019/placeholder/loosely-lazy/types.js +1 -0
- package/dist/es2019/placeholder/loosely-lazy/wait-context.js +5 -0
- package/dist/es2019/resource-timing/common/types.js +0 -0
- package/dist/es2019/resource-timing/common/utils/config.js +44 -0
- package/dist/es2019/resource-timing/common/utils/resource-timing-buffer.js +88 -0
- package/dist/es2019/resource-timing/index.js +3 -0
- package/dist/es2019/resource-timing/main.js +130 -0
- package/dist/es2019/resource-timing/utils.js +4 -0
- package/dist/es2019/round-number/index.js +4 -0
- package/dist/es2019/route-name/index.js +6 -0
- package/dist/es2019/route-name-context/index.js +5 -0
- package/dist/es2019/segment/index.js +2 -0
- package/dist/es2019/segment/segment-highlight.js +27 -0
- package/dist/es2019/segment/segment.js +218 -0
- package/dist/es2019/set-interaction-error/index.js +11 -0
- package/dist/es2019/short-id/index.js +8 -0
- package/dist/es2019/ssr/index.js +54 -0
- package/dist/es2019/trace-interaction/index.js +41 -0
- package/dist/es2019/trace-pageload/index.js +48 -0
- package/dist/es2019/trace-press/index.js +27 -0
- package/dist/es2019/trace-redirect/index.js +10 -0
- package/dist/es2019/trace-transition/index.js +48 -0
- package/dist/es2019/trace-transition/utils/generate-span-id/index.js +1 -0
- package/dist/es2019/trace-transition/utils/set-interaction-active-trace/index.js +5 -0
- package/dist/es2019/typing-performance-tracing/index.js +255 -0
- package/dist/es2019/use-press-tracing/index.js +12 -0
- package/dist/es2019/vc/index.js +8 -0
- package/dist/es2019/vc/vc-observer/attachAbortListeners.js +34 -0
- package/dist/es2019/vc/vc-observer/getViewport.js +18 -0
- package/dist/es2019/vc/vc-observer/index.js +522 -0
- package/dist/es2019/vc/vc-observer/media-wrapper/index.js +9 -0
- package/dist/es2019/vc/vc-observer/media-wrapper/vc-utils.js +10 -0
- package/dist/es2019/vc/vc-observer/observers/index.js +231 -0
- package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +146 -0
- package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.js +16 -0
- package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.js +14 -0
- package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.js +2 -0
- package/dist/es2019/vc/vc-observer/observers/types.js +1 -0
- package/dist/esm/additional-payload/index.js +2 -0
- package/dist/esm/additional-payload/utils/cache-hit-ratio/index.js +63 -0
- package/dist/esm/additional-payload/utils/lighthouse-metrics/cls/index.js +47 -0
- package/dist/esm/additional-payload/utils/lighthouse-metrics/cls/types.js +0 -0
- package/dist/esm/additional-payload/utils/lighthouse-metrics/const.js +4 -0
- package/dist/esm/additional-payload/utils/lighthouse-metrics/index.js +22 -0
- package/dist/esm/additional-payload/utils/lighthouse-metrics/tbt/index.js +19 -0
- package/dist/esm/additional-payload/utils/lighthouse-metrics/utils/buffer/index.js +31 -0
- package/dist/esm/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +31 -0
- package/dist/esm/bundle-eval-timing/index.js +41 -0
- package/dist/esm/coinflip/index.js +16 -0
- package/dist/esm/common/common/types.js +1 -0
- package/dist/esm/common/constants.js +1 -0
- package/dist/esm/common/index.js +0 -0
- package/dist/esm/common/vc/types.js +5 -0
- package/dist/esm/config/index.js +206 -0
- package/dist/esm/create-payload/common/types.js +0 -0
- package/dist/esm/create-payload/common/utils/index.js +8 -0
- package/dist/esm/create-payload/index.js +774 -0
- package/dist/esm/create-post-interaction-log-payload/index.js +200 -0
- package/dist/esm/custom-data/index.js +23 -0
- package/dist/esm/custom-data/types.js +1 -0
- package/dist/esm/custom-mark/index.js +36 -0
- package/dist/esm/custom-spans/index.js +8 -0
- package/dist/esm/custom-timings/index.js +56 -0
- package/dist/esm/experience-trace-id-context/index.js +34 -0
- package/dist/esm/experience-trace-id-context/types.js +0 -0
- package/dist/esm/experience-trace-id-context/utils/make-trace-http-request-headers/index.js +6 -0
- package/dist/esm/feature-flags-accessed/common/constants.js +1 -0
- package/dist/esm/feature-flags-accessed/common/types.js +1 -0
- package/dist/esm/feature-flags-accessed/common/utils/index.js +31 -0
- package/dist/esm/feature-flags-accessed/index.js +21 -0
- package/dist/esm/generate-id/index.js +6 -0
- package/dist/esm/global-error-handler/index.js +67 -0
- package/dist/esm/hidden-timing/index.js +87 -0
- package/dist/esm/initial-page-load-extra-timing/index.js +42 -0
- package/dist/esm/interaction-context/index.js +6 -0
- package/dist/esm/interaction-id-context/index.js +22 -0
- package/dist/esm/interaction-metrics/common/constants.js +2 -0
- package/dist/esm/interaction-metrics/index.js +773 -0
- package/dist/esm/interaction-metrics/post-interaction-log.js +184 -0
- package/dist/esm/interaction-metrics-init/index.js +77 -0
- package/dist/esm/label/UFOLabel.js +36 -0
- package/dist/esm/label/index.js +2 -0
- package/dist/esm/load-hold/UFOLoadHold.js +66 -0
- package/dist/esm/load-hold/index.js +2 -0
- package/dist/esm/placeholder/Placeholder.js +25 -0
- package/dist/esm/placeholder/index.js +2 -0
- package/dist/esm/placeholder/loosely-lazy/index.js +2 -0
- package/dist/esm/placeholder/loosely-lazy/lazy-suspense.js +70 -0
- package/dist/esm/placeholder/loosely-lazy/types.js +1 -0
- package/dist/esm/placeholder/loosely-lazy/wait-context.js +9 -0
- package/dist/esm/resource-timing/common/types.js +0 -0
- package/dist/esm/resource-timing/common/utils/config.js +62 -0
- package/dist/esm/resource-timing/common/utils/resource-timing-buffer.js +104 -0
- package/dist/esm/resource-timing/index.js +3 -0
- package/dist/esm/resource-timing/main.js +134 -0
- package/dist/esm/resource-timing/utils.js +4 -0
- package/dist/esm/round-number/index.js +5 -0
- package/dist/esm/route-name/index.js +6 -0
- package/dist/esm/route-name-context/index.js +5 -0
- package/dist/esm/segment/index.js +2 -0
- package/dist/esm/segment/segment-highlight.js +30 -0
- package/dist/esm/segment/segment.js +235 -0
- package/dist/esm/set-interaction-error/index.js +11 -0
- package/dist/esm/short-id/index.js +9 -0
- package/dist/esm/ssr/index.js +59 -0
- package/dist/esm/trace-interaction/index.js +41 -0
- package/dist/esm/trace-pageload/index.js +50 -0
- package/dist/esm/trace-press/index.js +27 -0
- package/dist/esm/trace-redirect/index.js +10 -0
- package/dist/esm/trace-transition/index.js +49 -0
- package/dist/esm/trace-transition/utils/generate-span-id/index.js +5 -0
- package/dist/esm/trace-transition/utils/set-interaction-active-trace/index.js +5 -0
- package/dist/esm/typing-performance-tracing/index.js +255 -0
- package/dist/esm/use-press-tracing/index.js +12 -0
- package/dist/esm/vc/index.js +9 -0
- package/dist/esm/vc/vc-observer/attachAbortListeners.js +34 -0
- package/dist/esm/vc/vc-observer/getViewport.js +20 -0
- package/dist/esm/vc/vc-observer/index.js +555 -0
- package/dist/esm/vc/vc-observer/media-wrapper/index.js +7 -0
- package/dist/esm/vc/vc-observer/media-wrapper/vc-utils.js +10 -0
- package/dist/esm/vc/vc-observer/observers/index.js +263 -0
- package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +176 -0
- package/dist/esm/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.js +16 -0
- package/dist/esm/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.js +14 -0
- package/dist/esm/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.js +2 -0
- package/dist/esm/vc/vc-observer/observers/types.js +1 -0
- package/dist/types/additional-payload/index.d.ts +2 -0
- package/dist/types/additional-payload/utils/cache-hit-ratio/index.d.ts +8 -0
- package/dist/types/additional-payload/utils/lighthouse-metrics/cls/index.d.ts +2 -0
- package/dist/types/additional-payload/utils/lighthouse-metrics/cls/types.d.ts +3 -0
- package/dist/types/additional-payload/utils/lighthouse-metrics/const.d.ts +5 -0
- package/dist/types/additional-payload/utils/lighthouse-metrics/index.d.ts +7 -0
- package/dist/types/additional-payload/utils/lighthouse-metrics/tbt/index.d.ts +5 -0
- package/dist/types/additional-payload/utils/lighthouse-metrics/utils/buffer/index.d.ts +13 -0
- package/dist/types/additional-payload/utils/lighthouse-metrics/utils/observer/index.d.ts +2 -0
- package/dist/types/bundle-eval-timing/index.d.ts +16 -0
- package/dist/types/coinflip/index.d.ts +8 -0
- package/dist/types/common/common/types.d.ts +201 -0
- package/dist/types/common/constants.d.ts +1 -0
- package/dist/types/common/index.d.ts +5 -0
- package/dist/types/common/vc/types.d.ts +91 -0
- package/dist/types/config/index.d.ts +91 -0
- package/dist/types/create-payload/common/types.d.ts +4 -0
- package/dist/types/create-payload/common/utils/index.d.ts +3 -0
- package/dist/types/create-payload/index.d.ts +2969 -0
- package/dist/types/create-post-interaction-log-payload/index.d.ts +45 -0
- package/dist/types/custom-data/index.d.ts +5 -0
- package/dist/types/custom-data/types.d.ts +4 -0
- package/dist/types/custom-mark/index.d.ts +10 -0
- package/dist/types/custom-spans/index.d.ts +1 -0
- package/dist/types/custom-timings/index.d.ts +19 -0
- package/dist/types/experience-trace-id-context/index.d.ts +10 -0
- package/dist/types/experience-trace-id-context/types.d.ts +8 -0
- package/dist/types/experience-trace-id-context/utils/make-trace-http-request-headers/index.d.ts +4 -0
- package/dist/types/feature-flags-accessed/common/constants.d.ts +1 -0
- package/dist/types/feature-flags-accessed/common/types.d.ts +2 -0
- package/dist/types/feature-flags-accessed/common/utils/index.d.ts +3 -0
- package/dist/types/feature-flags-accessed/index.d.ts +14 -0
- package/dist/types/generate-id/index.d.ts +2 -0
- package/dist/types/global-error-handler/index.d.ts +3 -0
- package/dist/types/hidden-timing/index.d.ts +7 -0
- package/dist/types/initial-page-load-extra-timing/index.d.ts +9 -0
- package/dist/types/interaction-context/index.d.ts +33 -0
- package/dist/types/interaction-id-context/index.d.ts +9 -0
- package/dist/types/interaction-metrics/common/constants.d.ts +3 -0
- package/dist/types/interaction-metrics/index.d.ts +65 -1
- package/dist/types/interaction-metrics/post-interaction-log.d.ts +69 -0
- package/dist/types/interaction-metrics-init/index.d.ts +11 -0
- package/dist/types/label/UFOLabel.d.ts +13 -0
- package/dist/types/label/index.d.ts +2 -0
- package/dist/types/load-hold/UFOLoadHold.d.ts +53 -0
- package/dist/types/load-hold/index.d.ts +2 -0
- package/dist/types/placeholder/Placeholder.d.ts +13 -0
- package/dist/types/placeholder/index.d.ts +2 -0
- package/dist/types/placeholder/loosely-lazy/index.d.ts +3 -0
- package/dist/types/placeholder/loosely-lazy/lazy-suspense.d.ts +6 -0
- package/dist/types/placeholder/loosely-lazy/types.d.ts +20 -0
- package/dist/types/placeholder/loosely-lazy/wait-context.d.ts +3 -0
- package/dist/types/resource-timing/common/types.d.ts +41 -0
- package/dist/types/resource-timing/common/utils/config.d.ts +3 -0
- package/dist/types/resource-timing/common/utils/resource-timing-buffer.d.ts +11 -0
- package/dist/types/resource-timing/index.d.ts +4 -0
- package/dist/types/resource-timing/main.d.ts +2 -0
- package/dist/types/resource-timing/utils.d.ts +1 -0
- package/dist/types/round-number/index.d.ts +1 -0
- package/dist/types/route-name/index.d.ts +4 -0
- package/dist/types/route-name-context/index.d.ts +5 -0
- package/dist/types/segment/index.d.ts +2 -0
- package/dist/types/segment/segment-highlight.d.ts +6 -0
- package/dist/types/segment/segment.d.ts +8 -0
- package/dist/types/set-interaction-error/index.d.ts +4 -0
- package/dist/types/short-id/index.d.ts +1 -0
- package/dist/types/ssr/index.d.ts +21 -0
- package/dist/types/trace-interaction/index.d.ts +2 -0
- package/dist/types/trace-pageload/index.d.ts +2 -0
- package/dist/types/trace-press/index.d.ts +1 -0
- package/dist/types/trace-redirect/index.d.ts +1 -0
- package/dist/types/trace-transition/index.d.ts +2 -0
- package/dist/types/trace-transition/utils/generate-span-id/index.d.ts +1 -0
- package/dist/types/trace-transition/utils/set-interaction-active-trace/index.d.ts +1 -0
- package/dist/types/typing-performance-tracing/index.d.ts +2 -0
- package/dist/types/use-press-tracing/index.d.ts +1 -0
- package/dist/types/vc/index.d.ts +2 -0
- package/dist/types/vc/vc-observer/attachAbortListeners.d.ts +6 -0
- package/dist/types/vc/vc-observer/getViewport.d.ts +2 -0
- package/dist/types/vc/vc-observer/index.d.ts +98 -0
- package/dist/types/vc/vc-observer/media-wrapper/index.d.ts +7 -0
- package/dist/types/vc/vc-observer/media-wrapper/vc-utils.d.ts +1 -0
- package/dist/types/vc/vc-observer/observers/index.d.ts +39 -0
- package/dist/types/vc/vc-observer/observers/ssr-placeholders/index.d.ts +23 -0
- package/dist/types/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.d.ts +1 -0
- package/dist/types/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.d.ts +1 -0
- package/dist/types/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.d.ts +2 -0
- package/dist/types/vc/vc-observer/observers/types.d.ts +11 -0
- package/dist/types-ts4.5/additional-payload/index.d.ts +2 -0
- package/dist/types-ts4.5/additional-payload/utils/cache-hit-ratio/index.d.ts +8 -0
- package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/cls/index.d.ts +2 -0
- package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/cls/types.d.ts +3 -0
- package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/const.d.ts +5 -0
- package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/index.d.ts +7 -0
- package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/tbt/index.d.ts +5 -0
- package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/utils/buffer/index.d.ts +13 -0
- package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/utils/observer/index.d.ts +2 -0
- package/dist/types-ts4.5/bundle-eval-timing/index.d.ts +16 -0
- package/dist/types-ts4.5/coinflip/index.d.ts +8 -0
- package/dist/types-ts4.5/common/common/types.d.ts +201 -0
- package/dist/types-ts4.5/common/constants.d.ts +1 -0
- package/dist/types-ts4.5/common/index.d.ts +5 -0
- package/dist/types-ts4.5/common/vc/types.d.ts +91 -0
- package/dist/types-ts4.5/config/index.d.ts +95 -0
- package/dist/types-ts4.5/create-payload/common/types.d.ts +4 -0
- package/dist/types-ts4.5/create-payload/common/utils/index.d.ts +3 -0
- package/dist/types-ts4.5/create-payload/index.d.ts +2969 -0
- package/dist/types-ts4.5/create-post-interaction-log-payload/index.d.ts +45 -0
- package/dist/types-ts4.5/custom-data/index.d.ts +5 -0
- package/dist/types-ts4.5/custom-data/types.d.ts +4 -0
- package/dist/types-ts4.5/custom-mark/index.d.ts +10 -0
- package/dist/types-ts4.5/custom-spans/index.d.ts +1 -0
- package/dist/types-ts4.5/custom-timings/index.d.ts +19 -0
- package/dist/types-ts4.5/experience-trace-id-context/index.d.ts +10 -0
- package/dist/types-ts4.5/experience-trace-id-context/types.d.ts +8 -0
- package/dist/types-ts4.5/experience-trace-id-context/utils/make-trace-http-request-headers/index.d.ts +4 -0
- package/dist/types-ts4.5/feature-flags-accessed/common/constants.d.ts +1 -0
- package/dist/types-ts4.5/feature-flags-accessed/common/types.d.ts +2 -0
- package/dist/types-ts4.5/feature-flags-accessed/common/utils/index.d.ts +3 -0
- package/dist/types-ts4.5/feature-flags-accessed/index.d.ts +14 -0
- package/dist/types-ts4.5/generate-id/index.d.ts +2 -0
- package/dist/types-ts4.5/global-error-handler/index.d.ts +3 -0
- package/dist/types-ts4.5/hidden-timing/index.d.ts +7 -0
- package/dist/types-ts4.5/initial-page-load-extra-timing/index.d.ts +9 -0
- package/dist/types-ts4.5/interaction-context/index.d.ts +33 -0
- package/dist/types-ts4.5/interaction-id-context/index.d.ts +9 -0
- package/dist/types-ts4.5/interaction-metrics/common/constants.d.ts +3 -0
- package/dist/types-ts4.5/interaction-metrics/index.d.ts +65 -1
- package/dist/types-ts4.5/interaction-metrics/post-interaction-log.d.ts +69 -0
- package/dist/types-ts4.5/interaction-metrics-init/index.d.ts +11 -0
- package/dist/types-ts4.5/label/UFOLabel.d.ts +13 -0
- package/dist/types-ts4.5/label/index.d.ts +2 -0
- package/dist/types-ts4.5/load-hold/UFOLoadHold.d.ts +53 -0
- package/dist/types-ts4.5/load-hold/index.d.ts +2 -0
- package/dist/types-ts4.5/placeholder/Placeholder.d.ts +13 -0
- package/dist/types-ts4.5/placeholder/index.d.ts +2 -0
- package/dist/types-ts4.5/placeholder/loosely-lazy/index.d.ts +3 -0
- package/dist/types-ts4.5/placeholder/loosely-lazy/lazy-suspense.d.ts +6 -0
- package/dist/types-ts4.5/placeholder/loosely-lazy/types.d.ts +20 -0
- package/dist/types-ts4.5/placeholder/loosely-lazy/wait-context.d.ts +3 -0
- package/dist/types-ts4.5/resource-timing/common/types.d.ts +41 -0
- package/dist/types-ts4.5/resource-timing/common/utils/config.d.ts +3 -0
- package/dist/types-ts4.5/resource-timing/common/utils/resource-timing-buffer.d.ts +11 -0
- package/dist/types-ts4.5/resource-timing/index.d.ts +4 -0
- package/dist/types-ts4.5/resource-timing/main.d.ts +2 -0
- package/dist/types-ts4.5/resource-timing/utils.d.ts +1 -0
- package/dist/types-ts4.5/round-number/index.d.ts +1 -0
- package/dist/types-ts4.5/route-name/index.d.ts +4 -0
- package/dist/types-ts4.5/route-name-context/index.d.ts +5 -0
- package/dist/types-ts4.5/segment/index.d.ts +2 -0
- package/dist/types-ts4.5/segment/segment-highlight.d.ts +6 -0
- package/dist/types-ts4.5/segment/segment.d.ts +8 -0
- package/dist/types-ts4.5/set-interaction-error/index.d.ts +4 -0
- package/dist/types-ts4.5/short-id/index.d.ts +1 -0
- package/dist/types-ts4.5/ssr/index.d.ts +21 -0
- package/dist/types-ts4.5/trace-interaction/index.d.ts +2 -0
- package/dist/types-ts4.5/trace-pageload/index.d.ts +2 -0
- package/dist/types-ts4.5/trace-press/index.d.ts +1 -0
- package/dist/types-ts4.5/trace-redirect/index.d.ts +1 -0
- package/dist/types-ts4.5/trace-transition/index.d.ts +2 -0
- package/dist/types-ts4.5/trace-transition/utils/generate-span-id/index.d.ts +1 -0
- package/dist/types-ts4.5/trace-transition/utils/set-interaction-active-trace/index.d.ts +1 -0
- package/dist/types-ts4.5/typing-performance-tracing/index.d.ts +2 -0
- package/dist/types-ts4.5/use-press-tracing/index.d.ts +1 -0
- package/dist/types-ts4.5/vc/index.d.ts +2 -0
- package/dist/types-ts4.5/vc/vc-observer/attachAbortListeners.d.ts +6 -0
- package/dist/types-ts4.5/vc/vc-observer/getViewport.d.ts +2 -0
- package/dist/types-ts4.5/vc/vc-observer/index.d.ts +98 -0
- package/dist/types-ts4.5/vc/vc-observer/media-wrapper/index.d.ts +7 -0
- package/dist/types-ts4.5/vc/vc-observer/media-wrapper/vc-utils.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/index.d.ts +39 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/index.d.ts +23 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.d.ts +2 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/types.d.ts +11 -0
- package/experience-trace-id-context/package.json +15 -0
- package/feature-flags-accessed/package.json +15 -0
- package/generate-id/package.json +15 -0
- package/global-error-handler/package.json +15 -0
- package/hidden-timing/package.json +15 -0
- package/initial-page-load-extra-timing/package.json +15 -0
- package/interaction-context/package.json +15 -0
- package/interaction-id-context/package.json +15 -0
- package/interaction-metrics-init/package.json +15 -0
- package/label/package.json +15 -0
- package/load-hold/package.json +15 -0
- package/package.json +55 -3
- package/placeholder/package.json +15 -0
- package/resource-timing/package.json +15 -0
- package/round-number/package.json +15 -0
- package/route-name/package.json +15 -0
- package/route-name-context/package.json +15 -0
- package/segment/package.json +15 -0
- package/set-interaction-error/package.json +15 -0
- package/short-id/package.json +15 -0
- package/ssr/package.json +15 -0
- package/ssr-scripts/package.json +15 -0
- package/trace-interaction/package.json +15 -0
- package/trace-pageload/package.json +15 -0
- package/trace-press/package.json +15 -0
- package/trace-redirect/package.json +15 -0
- package/trace-transition/package.json +15 -0
- package/typing-performance-tracing/package.json +15 -0
- package/use-press-tracing/package.json +15 -0
- package/vc/media/package.json +15 -0
- package/vc/package.json +15 -0
- package/dist/types/common/types.d.ts +0 -17
- package/dist/types-ts4.5/common/types.d.ts +0 -17
- /package/dist/cjs/{common → additional-payload/utils/lighthouse-metrics/cls}/types.js +0 -0
- /package/dist/es2019/{common → additional-payload/utils/lighthouse-metrics/cls}/types.js +0 -0
- /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,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,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
|
+
});
|