@absolutejs/beacon 0.6.20 → 0.6.22

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 CHANGED
@@ -683,6 +683,7 @@ var createBeacon = (options) => {
683
683
  const MEDIA_STALL_DEFAULT_MS = 1e4;
684
684
  const THRASHED_CURSOR_DEFAULT_REVERSALS = 8;
685
685
  const THRASHED_CURSOR_WINDOW_MS = 2000;
686
+ const THRASHED_CURSOR_REVERSAL_COSINE = -0.5;
686
687
  const NAVIGATION_RESPONSE_DEFAULT_MS = 8000;
687
688
  const LAYOUT_OVERFLOW_SETTLE_DEFAULT_MS = 600;
688
689
  const LAYOUT_OVERFLOW_MAX_REPORTS_DEFAULT = 5;
@@ -2184,7 +2185,18 @@ var createBeacon = (options) => {
2184
2185
  };
2185
2186
  const loadingFirstSeen = new WeakMap;
2186
2187
  const reportedStuckLoading = new WeakSet;
2188
+ const loadingIndicatorSelector = `[aria-busy="true"], [role="progressbar"], [${BEACON_ATTRIBUTE.LOADING}]`;
2187
2189
  const isPersistentDeterminateProgress = (indicator) => indicator.getAttribute("role") === "progressbar" && indicator.hasAttribute("aria-valuenow") && indicator.getAttribute("aria-busy") !== "true" && !indicator.hasAttribute(BEACON_ATTRIBUTE.LOADING);
2190
+ const hasTrackedLoadingAncestor = (indicator) => {
2191
+ let ancestor = indicator.parentElement?.closest(loadingIndicatorSelector);
2192
+ while (ancestor !== null && ancestor !== undefined) {
2193
+ if (!isPersistentDeterminateProgress(ancestor) && !isScanExempt(ancestor) && !hasHiddenAncestor(ancestor)) {
2194
+ return true;
2195
+ }
2196
+ ancestor = ancestor.parentElement?.closest(loadingIndicatorSelector);
2197
+ }
2198
+ return false;
2199
+ };
2188
2200
  const loadingDeadlineMs = (indicator) => {
2189
2201
  const configured = indicator.getAttribute(BEACON_ATTRIBUTE.LOADING_TIMEOUT)?.trim();
2190
2202
  if (!configured)
@@ -2195,13 +2207,17 @@ var createBeacon = (options) => {
2195
2207
  const checkStuckLoading = () => {
2196
2208
  if (document.visibilityState === "hidden")
2197
2209
  return;
2198
- const indicators = document.querySelectorAll(`[aria-busy="true"], [role="progressbar"], [${BEACON_ATTRIBUTE.LOADING}]`);
2210
+ const indicators = document.querySelectorAll(loadingIndicatorSelector);
2199
2211
  const now = Date.now();
2200
2212
  for (const indicator of Array.from(indicators)) {
2201
2213
  if (isPersistentDeterminateProgress(indicator))
2202
2214
  continue;
2203
2215
  if (isScanExempt(indicator))
2204
2216
  continue;
2217
+ if (hasHiddenAncestor(indicator))
2218
+ continue;
2219
+ if (hasTrackedLoadingAncestor(indicator))
2220
+ continue;
2205
2221
  const rect = indicator.getBoundingClientRect();
2206
2222
  if (rect.width === 0 && rect.height === 0)
2207
2223
  continue;
@@ -2892,7 +2908,9 @@ var createBeacon = (options) => {
2892
2908
  for (let index = 1;index < points.length; index += 1) {
2893
2909
  const prior = points[index - 1];
2894
2910
  const current = points[index];
2895
- if (prior.dx * current.dx < 0 || prior.dy * current.dy < 0)
2911
+ const dot = prior.dx * current.dx + prior.dy * current.dy;
2912
+ const magnitudeProduct = Math.hypot(prior.dx, prior.dy) * Math.hypot(current.dx, current.dy);
2913
+ if (dot / magnitudeProduct <= THRASHED_CURSOR_REVERSAL_COSINE)
2896
2914
  reversals += 1;
2897
2915
  }
2898
2916
  if (reversals < reversalThreshold)
@@ -3811,5 +3829,5 @@ export {
3811
3829
  BEACON_ATTRIBUTE
3812
3830
  };
3813
3831
 
3814
- //# debugId=55452890CDD1A21064756E2164756E21
3832
+ //# debugId=757A87482E13AD7364756E2164756E21
3815
3833
  //# sourceMappingURL=index.js.map