@absolutejs/beacon 0.6.12 → 0.6.14
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/dist/index.js +39 -11
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -690,7 +690,7 @@ var createBeacon = (options) => {
|
|
|
690
690
|
const KEYBOARD_VIEWPORT_HEIGHT_RATIO_MAX = 0.8;
|
|
691
691
|
const SCROLL_JAIL_EVENT_COUNT = 8;
|
|
692
692
|
const SCROLL_JAIL_WINDOW_MS = 2000;
|
|
693
|
-
const SCROLL_JAIL_SETTLE_MS =
|
|
693
|
+
const SCROLL_JAIL_SETTLE_MS = 500;
|
|
694
694
|
const SCROLL_JAIL_BOUNDARY_TOLERANCE_PX = 2;
|
|
695
695
|
const AUTH_FAILURE_STORM_DEFAULT_COUNT = 4;
|
|
696
696
|
const AUTH_FAILURE_STORM_DEFAULT_WINDOW_MS = 30000;
|
|
@@ -714,6 +714,8 @@ var createBeacon = (options) => {
|
|
|
714
714
|
const FORM_FRUSTRATION_THRESHOLD = 3;
|
|
715
715
|
const FORM_FRUSTRATION_WINDOW_MS = 60000;
|
|
716
716
|
const LAYOUT_SHIFT_RECENT_INTERACTION_MS = 500;
|
|
717
|
+
const LAYOUT_SHIFT_VIEWPORT_RESIZE_SETTLE_MS = 500;
|
|
718
|
+
const VIEWPORT_RESIZE_HISTORY_LIMIT = 8;
|
|
717
719
|
const FORM_INVALID_BURST_GAP_MS = 100;
|
|
718
720
|
const SIGNAL_TEXT_MAX = 180;
|
|
719
721
|
const NON_TEXT_ENTRY_INPUT_TYPES = new Set([
|
|
@@ -2241,13 +2243,26 @@ var createBeacon = (options) => {
|
|
|
2241
2243
|
if (signals !== null && signals.disruptiveLayoutShifts !== false && typeof PerformanceObserver !== "undefined") {
|
|
2242
2244
|
const minimum = signals.disruptiveLayoutShiftMin ?? DISRUPTIVE_LAYOUT_SHIFT_DEFAULT_MIN;
|
|
2243
2245
|
const reported = new Set;
|
|
2246
|
+
let viewportResizeTimes = [];
|
|
2247
|
+
const recordViewportResize = () => {
|
|
2248
|
+
viewportResizeTimes.push(performance.now());
|
|
2249
|
+
if (viewportResizeTimes.length > VIEWPORT_RESIZE_HISTORY_LIMIT) {
|
|
2250
|
+
viewportResizeTimes = viewportResizeTimes.slice(-VIEWPORT_RESIZE_HISTORY_LIMIT);
|
|
2251
|
+
}
|
|
2252
|
+
};
|
|
2253
|
+
window.addEventListener("resize", recordViewportResize);
|
|
2254
|
+
window.visualViewport?.addEventListener("resize", recordViewportResize);
|
|
2244
2255
|
try {
|
|
2245
2256
|
const observer = new PerformanceObserver((list) => {
|
|
2246
2257
|
for (const raw of list.getEntries()) {
|
|
2247
2258
|
const entry = raw;
|
|
2248
2259
|
const interactionAgeMs = recentInteraction === undefined ? undefined : entry.startTime - recentInteraction.performanceAt;
|
|
2249
2260
|
const beaconSawRecentInput = interactionAgeMs !== undefined && interactionAgeMs >= 0 && interactionAgeMs <= LAYOUT_SHIFT_RECENT_INTERACTION_MS;
|
|
2250
|
-
|
|
2261
|
+
const resizeAdjacent = viewportResizeTimes.some((resizedAt) => {
|
|
2262
|
+
const resizeAgeMs = entry.startTime - resizedAt;
|
|
2263
|
+
return resizeAgeMs >= 0 && resizeAgeMs <= LAYOUT_SHIFT_VIEWPORT_RESIZE_SETTLE_MS;
|
|
2264
|
+
});
|
|
2265
|
+
if (entry.hadRecentInput === true || beaconSawRecentInput || resizeAdjacent || mobileKeyboardViewportActive() || (entry.value ?? 0) < minimum)
|
|
2251
2266
|
continue;
|
|
2252
2267
|
const targets = (entry.sources ?? []).map(({ node }) => node instanceof Element ? describeElement(node) : undefined).filter((target) => target !== undefined).slice(0, 5);
|
|
2253
2268
|
const key = targets.join(",") || "unknown";
|
|
@@ -2262,8 +2277,15 @@ var createBeacon = (options) => {
|
|
|
2262
2277
|
}
|
|
2263
2278
|
});
|
|
2264
2279
|
observer.observe({ buffered: true, type: "layout-shift" });
|
|
2265
|
-
cleanups.push(() =>
|
|
2266
|
-
|
|
2280
|
+
cleanups.push(() => {
|
|
2281
|
+
observer.disconnect();
|
|
2282
|
+
window.removeEventListener("resize", recordViewportResize);
|
|
2283
|
+
window.visualViewport?.removeEventListener("resize", recordViewportResize);
|
|
2284
|
+
});
|
|
2285
|
+
} catch {
|
|
2286
|
+
window.removeEventListener("resize", recordViewportResize);
|
|
2287
|
+
window.visualViewport?.removeEventListener("resize", recordViewportResize);
|
|
2288
|
+
}
|
|
2267
2289
|
}
|
|
2268
2290
|
if (signals !== null && signals.slowInteractions !== false && typeof PerformanceObserver !== "undefined") {
|
|
2269
2291
|
const minimum = signals.slowInteractionMs ?? SLOW_INTERACTION_DEFAULT_MS;
|
|
@@ -2732,7 +2754,14 @@ var createBeacon = (options) => {
|
|
|
2732
2754
|
let jailScroller = null;
|
|
2733
2755
|
let jailSettleTimer;
|
|
2734
2756
|
const reportedScrollers = new Set;
|
|
2757
|
+
const clearJailSettle = () => {
|
|
2758
|
+
if (jailSettleTimer === undefined)
|
|
2759
|
+
return;
|
|
2760
|
+
clearTimeout(jailSettleTimer);
|
|
2761
|
+
jailSettleTimer = undefined;
|
|
2762
|
+
};
|
|
2735
2763
|
const onWheel = (event) => {
|
|
2764
|
+
clearJailSettle();
|
|
2736
2765
|
if (event.ctrlKey || event.defaultPrevented || event.deltaY === 0) {
|
|
2737
2766
|
jailBurst = [];
|
|
2738
2767
|
return;
|
|
@@ -2760,14 +2789,14 @@ var createBeacon = (options) => {
|
|
|
2760
2789
|
return;
|
|
2761
2790
|
const first = jailBurst[0];
|
|
2762
2791
|
const moved = first === undefined || jailBurst.some((entry) => entry.position !== first.position) || scroller.scrollTop !== first.position;
|
|
2763
|
-
|
|
2764
|
-
|
|
2792
|
+
if (moved) {
|
|
2793
|
+
jailBurst = [];
|
|
2765
2794
|
return;
|
|
2795
|
+
}
|
|
2766
2796
|
const startingPosition = first.position;
|
|
2767
|
-
if (jailSettleTimer !== undefined)
|
|
2768
|
-
clearTimeout(jailSettleTimer);
|
|
2769
2797
|
jailSettleTimer = setTimeout(() => {
|
|
2770
2798
|
jailSettleTimer = undefined;
|
|
2799
|
+
jailBurst = [];
|
|
2771
2800
|
if (!scroller.isConnected || scroller.scrollTop !== startingPosition)
|
|
2772
2801
|
return;
|
|
2773
2802
|
const canStillMove = scrollingDown ? scroller.scrollTop + scroller.clientHeight < scroller.scrollHeight - SCROLL_JAIL_BOUNDARY_TOLERANCE_PX : scroller.scrollTop > SCROLL_JAIL_BOUNDARY_TOLERANCE_PX;
|
|
@@ -2785,8 +2814,7 @@ var createBeacon = (options) => {
|
|
|
2785
2814
|
document.addEventListener("wheel", onWheel, { passive: true });
|
|
2786
2815
|
cleanups.push(() => {
|
|
2787
2816
|
document.removeEventListener("wheel", onWheel);
|
|
2788
|
-
|
|
2789
|
-
clearTimeout(jailSettleTimer);
|
|
2817
|
+
clearJailSettle();
|
|
2790
2818
|
});
|
|
2791
2819
|
}
|
|
2792
2820
|
if (signals.thrashedCursors !== false) {
|
|
@@ -3727,5 +3755,5 @@ export {
|
|
|
3727
3755
|
BEACON_ATTRIBUTE
|
|
3728
3756
|
};
|
|
3729
3757
|
|
|
3730
|
-
//# debugId=
|
|
3758
|
+
//# debugId=E73AD95316DDFA6564756E2164756E21
|
|
3731
3759
|
//# sourceMappingURL=index.js.map
|