@absolutejs/beacon 0.6.13 → 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 +26 -4
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -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;
|
|
@@ -3733,5 +3755,5 @@ export {
|
|
|
3733
3755
|
BEACON_ATTRIBUTE
|
|
3734
3756
|
};
|
|
3735
3757
|
|
|
3736
|
-
//# debugId=
|
|
3758
|
+
//# debugId=E73AD95316DDFA6564756E2164756E21
|
|
3737
3759
|
//# sourceMappingURL=index.js.map
|