@absolutejs/beacon 0.6.25 → 0.6.27
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 +55 -1
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -404,6 +404,27 @@ var resourceSourceOf = (url) => {
|
|
|
404
404
|
return "unknown source";
|
|
405
405
|
}
|
|
406
406
|
};
|
|
407
|
+
var isExtensionResourceUrl = (url) => {
|
|
408
|
+
if (url === undefined)
|
|
409
|
+
return false;
|
|
410
|
+
try {
|
|
411
|
+
const protocol = new URL(url, location.href).protocol;
|
|
412
|
+
return protocol === "chrome-extension:" || protocol === "moz-extension:";
|
|
413
|
+
} catch {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
var injectionMarkersOf = (element) => {
|
|
418
|
+
const markers = new Set;
|
|
419
|
+
for (let current = element;current; current = current.parentElement) {
|
|
420
|
+
for (const attribute of Array.from(current.attributes)) {
|
|
421
|
+
if (/^(?:data-darkreader|data-adguard|data-extension|data-gramm|data-lastpass|bis_)/u.test(attribute.name)) {
|
|
422
|
+
markers.add(attribute.name);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return markers.size === 0 ? undefined : Array.from(markers).sort().join(",");
|
|
427
|
+
};
|
|
407
428
|
var describeElement = (element) => {
|
|
408
429
|
const tag = element.tagName.toLowerCase();
|
|
409
430
|
const beaconName = element.getAttribute(BEACON_ATTRIBUTE.NAME)?.trim().replace(/[^a-zA-Z0-9:_-]+/g, "-").slice(0, 64);
|
|
@@ -1852,11 +1873,24 @@ var createBeacon = (options) => {
|
|
|
1852
1873
|
return;
|
|
1853
1874
|
seenOverflows.add(key);
|
|
1854
1875
|
overflowReports += 1;
|
|
1876
|
+
const rect = element.getBoundingClientRect();
|
|
1877
|
+
const resourceUrl = RESOURCE_ERROR_TAGS.has(element.tagName.toLowerCase()) ? resourceUrlOf(element) : undefined;
|
|
1878
|
+
const injectionMarkers = injectionMarkersOf(element);
|
|
1855
1879
|
emitSignal(`Layout overflow — ${describeElement(element)} ${detail} — ${shortUrl(location.href)} [${bucket}]`, {
|
|
1856
1880
|
overflowKind: kind,
|
|
1857
1881
|
signal: BEACON_SIGNAL.LAYOUT_OVERFLOW,
|
|
1858
1882
|
spillPx: String(Math.round(spillPx)),
|
|
1859
1883
|
target: describeElement(element),
|
|
1884
|
+
targetAncestor: element.parentElement === null ? "none" : describeElement(element.parentElement),
|
|
1885
|
+
targetBottomPx: String(Math.round(rect.bottom)),
|
|
1886
|
+
targetHeightPx: String(Math.round(rect.height)),
|
|
1887
|
+
targetLeftPx: String(Math.round(rect.left)),
|
|
1888
|
+
targetPosition: window.getComputedStyle(element).position,
|
|
1889
|
+
targetRightPx: String(Math.round(rect.right)),
|
|
1890
|
+
targetTopPx: String(Math.round(rect.top)),
|
|
1891
|
+
targetWidthPx: String(Math.round(rect.width)),
|
|
1892
|
+
...resourceUrl === undefined ? {} : { resourceSource: resourceSourceOf(resourceUrl) },
|
|
1893
|
+
...injectionMarkers === undefined ? {} : { injectionMarkers },
|
|
1860
1894
|
viewportBucket: bucket,
|
|
1861
1895
|
viewportWidth: String(document.documentElement.clientWidth)
|
|
1862
1896
|
});
|
|
@@ -1871,6 +1905,9 @@ var createBeacon = (options) => {
|
|
|
1871
1905
|
return;
|
|
1872
1906
|
if (element.getAttribute(BEACON_ATTRIBUTE.OVERFLOW) === "allow")
|
|
1873
1907
|
return;
|
|
1908
|
+
if (RESOURCE_ERROR_TAGS.has(element.tagName.toLowerCase()) && isExtensionResourceUrl(resourceUrlOf(element))) {
|
|
1909
|
+
return;
|
|
1910
|
+
}
|
|
1874
1911
|
const style = window.getComputedStyle(element);
|
|
1875
1912
|
if (hasHiddenAncestor(element))
|
|
1876
1913
|
return;
|
|
@@ -2843,6 +2880,8 @@ var createBeacon = (options) => {
|
|
|
2843
2880
|
let jailBurst = [];
|
|
2844
2881
|
let jailScroller = null;
|
|
2845
2882
|
let jailSettleTimer;
|
|
2883
|
+
let scrollActivityGeneration = 0;
|
|
2884
|
+
let jailStartingScrollGeneration = 0;
|
|
2846
2885
|
const reportedScrollers = new Set;
|
|
2847
2886
|
const clearJailSettle = () => {
|
|
2848
2887
|
if (jailSettleTimer === undefined)
|
|
@@ -2850,6 +2889,9 @@ var createBeacon = (options) => {
|
|
|
2850
2889
|
clearTimeout(jailSettleTimer);
|
|
2851
2890
|
jailSettleTimer = undefined;
|
|
2852
2891
|
};
|
|
2892
|
+
const onDocumentScroll = () => {
|
|
2893
|
+
scrollActivityGeneration += 1;
|
|
2894
|
+
};
|
|
2853
2895
|
const onWheel = (event) => {
|
|
2854
2896
|
clearJailSettle();
|
|
2855
2897
|
if (event.ctrlKey || event.defaultPrevented || event.deltaY === 0) {
|
|
@@ -2874,6 +2916,9 @@ var createBeacon = (options) => {
|
|
|
2874
2916
|
jailBurst = [];
|
|
2875
2917
|
}
|
|
2876
2918
|
jailBurst = jailBurst.filter((entry) => now - entry.at < SCROLL_JAIL_WINDOW_MS);
|
|
2919
|
+
if (jailBurst.length === 0) {
|
|
2920
|
+
jailStartingScrollGeneration = scrollActivityGeneration;
|
|
2921
|
+
}
|
|
2877
2922
|
jailBurst.push({ at: now, position: scroller.scrollTop });
|
|
2878
2923
|
if (jailBurst.length < SCROLL_JAIL_EVENT_COUNT)
|
|
2879
2924
|
return;
|
|
@@ -2887,6 +2932,8 @@ var createBeacon = (options) => {
|
|
|
2887
2932
|
jailSettleTimer = setTimeout(() => {
|
|
2888
2933
|
jailSettleTimer = undefined;
|
|
2889
2934
|
jailBurst = [];
|
|
2935
|
+
if (scrollActivityGeneration !== jailStartingScrollGeneration)
|
|
2936
|
+
return;
|
|
2890
2937
|
if (!scroller.isConnected || scroller.scrollTop !== startingPosition)
|
|
2891
2938
|
return;
|
|
2892
2939
|
const canStillMove = scrollingDown ? scroller.scrollTop + scroller.clientHeight < scroller.scrollHeight - SCROLL_JAIL_BOUNDARY_TOLERANCE_PX : scroller.scrollTop > SCROLL_JAIL_BOUNDARY_TOLERANCE_PX;
|
|
@@ -2901,8 +2948,15 @@ var createBeacon = (options) => {
|
|
|
2901
2948
|
emitSignal(`Scroll jail — ${descriptor} has scrollable content but never moves — ${shortUrl(location.href)}`, { signal: BEACON_SIGNAL.SCROLL_JAIL, target: descriptor });
|
|
2902
2949
|
}, SCROLL_JAIL_SETTLE_MS);
|
|
2903
2950
|
};
|
|
2951
|
+
document.addEventListener("scroll", onDocumentScroll, {
|
|
2952
|
+
capture: true,
|
|
2953
|
+
passive: true
|
|
2954
|
+
});
|
|
2904
2955
|
document.addEventListener("wheel", onWheel, { passive: true });
|
|
2905
2956
|
cleanups.push(() => {
|
|
2957
|
+
document.removeEventListener("scroll", onDocumentScroll, {
|
|
2958
|
+
capture: true
|
|
2959
|
+
});
|
|
2906
2960
|
document.removeEventListener("wheel", onWheel);
|
|
2907
2961
|
clearJailSettle();
|
|
2908
2962
|
});
|
|
@@ -3875,5 +3929,5 @@ export {
|
|
|
3875
3929
|
BEACON_ATTRIBUTE
|
|
3876
3930
|
};
|
|
3877
3931
|
|
|
3878
|
-
//# debugId=
|
|
3932
|
+
//# debugId=DBDAEE5BB5F38AFA64756E2164756E21
|
|
3879
3933
|
//# sourceMappingURL=index.js.map
|