@absolutejs/beacon 0.6.38 → 0.6.39
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
|
@@ -2364,7 +2364,31 @@ var createBeacon = (options) => {
|
|
|
2364
2364
|
};
|
|
2365
2365
|
const loadingFirstSeen = new WeakMap;
|
|
2366
2366
|
const reportedStuckLoading = new WeakSet;
|
|
2367
|
+
const trackedLoadingIndicators = new Set;
|
|
2367
2368
|
const loadingIndicatorSelector = `[aria-busy="true"], [role="progressbar"], [${BEACON_ATTRIBUTE.LOADING}]`;
|
|
2369
|
+
const resetLoadingIndicator = (indicator) => {
|
|
2370
|
+
loadingFirstSeen.delete(indicator);
|
|
2371
|
+
reportedStuckLoading.delete(indicator);
|
|
2372
|
+
trackedLoadingIndicators.delete(indicator);
|
|
2373
|
+
};
|
|
2374
|
+
const loadingLifecycleObserver = new MutationObserver((records) => {
|
|
2375
|
+
for (const record of records) {
|
|
2376
|
+
if (!(record.target instanceof Element))
|
|
2377
|
+
continue;
|
|
2378
|
+
resetLoadingIndicator(record.target);
|
|
2379
|
+
}
|
|
2380
|
+
});
|
|
2381
|
+
loadingLifecycleObserver.observe(document.documentElement, {
|
|
2382
|
+
attributeFilter: [
|
|
2383
|
+
"aria-busy",
|
|
2384
|
+
"role",
|
|
2385
|
+
BEACON_ATTRIBUTE.LOADING,
|
|
2386
|
+
BEACON_ATTRIBUTE.LOADING_TIMEOUT
|
|
2387
|
+
],
|
|
2388
|
+
attributes: true,
|
|
2389
|
+
subtree: true
|
|
2390
|
+
});
|
|
2391
|
+
cleanups.push(() => loadingLifecycleObserver.disconnect());
|
|
2368
2392
|
const isPersistentDeterminateProgress = (indicator) => indicator.getAttribute("role") === "progressbar" && indicator.hasAttribute("aria-valuenow") && indicator.getAttribute("aria-busy") !== "true" && !indicator.hasAttribute(BEACON_ATTRIBUTE.LOADING);
|
|
2369
2393
|
const hasTrackedLoadingAncestor = (indicator) => {
|
|
2370
2394
|
let ancestor = indicator.parentElement?.closest(loadingIndicatorSelector);
|
|
@@ -2386,23 +2410,27 @@ var createBeacon = (options) => {
|
|
|
2386
2410
|
const checkStuckLoading = () => {
|
|
2387
2411
|
if (document.visibilityState === "hidden")
|
|
2388
2412
|
return;
|
|
2389
|
-
const indicators = document.querySelectorAll(loadingIndicatorSelector);
|
|
2413
|
+
const indicators = Array.from(document.querySelectorAll(loadingIndicatorSelector));
|
|
2414
|
+
const activeIndicators = new Set(indicators);
|
|
2415
|
+
for (const tracked of trackedLoadingIndicators) {
|
|
2416
|
+
if (!activeIndicators.has(tracked))
|
|
2417
|
+
resetLoadingIndicator(tracked);
|
|
2418
|
+
}
|
|
2390
2419
|
const now = Date.now();
|
|
2391
|
-
for (const indicator of
|
|
2392
|
-
if (isPersistentDeterminateProgress(indicator))
|
|
2393
|
-
|
|
2394
|
-
if (isScanExempt(indicator))
|
|
2395
|
-
continue;
|
|
2396
|
-
if (hasHiddenAncestor(indicator))
|
|
2397
|
-
continue;
|
|
2398
|
-
if (hasTrackedLoadingAncestor(indicator))
|
|
2420
|
+
for (const indicator of indicators) {
|
|
2421
|
+
if (isPersistentDeterminateProgress(indicator) || isScanExempt(indicator) || hasHiddenAncestor(indicator) || hasTrackedLoadingAncestor(indicator)) {
|
|
2422
|
+
resetLoadingIndicator(indicator);
|
|
2399
2423
|
continue;
|
|
2424
|
+
}
|
|
2400
2425
|
const rect = indicator.getBoundingClientRect();
|
|
2401
|
-
if (rect.width === 0 && rect.height === 0)
|
|
2426
|
+
if (rect.width === 0 && rect.height === 0) {
|
|
2427
|
+
resetLoadingIndicator(indicator);
|
|
2402
2428
|
continue;
|
|
2429
|
+
}
|
|
2403
2430
|
const firstSeen = loadingFirstSeen.get(indicator);
|
|
2404
2431
|
if (firstSeen === undefined) {
|
|
2405
2432
|
loadingFirstSeen.set(indicator, now);
|
|
2433
|
+
trackedLoadingIndicators.add(indicator);
|
|
2406
2434
|
continue;
|
|
2407
2435
|
}
|
|
2408
2436
|
const deadlineMs = loadingDeadlineMs(indicator);
|
|
@@ -4139,5 +4167,5 @@ export {
|
|
|
4139
4167
|
BEACON_ATTRIBUTE
|
|
4140
4168
|
};
|
|
4141
4169
|
|
|
4142
|
-
//# debugId=
|
|
4170
|
+
//# debugId=D84461A5205D5FA564756E2164756E21
|
|
4143
4171
|
//# sourceMappingURL=index.js.map
|