@absolutejs/beacon 0.6.32 → 0.6.33
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/README.md +11 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +92 -3
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -119,6 +119,13 @@ beacon.captureMessage("checkout started", "info");
|
|
|
119
119
|
scroll containers, and absolutely positioned escapees (badges, popovers,
|
|
120
120
|
drawers) are skipped by design; mark deliberate
|
|
121
121
|
bleeds with `data-beacon-overflow="allow"`.
|
|
122
|
+
- **Control-collision signals** — the same settled scan reports interactive
|
|
123
|
+
controls from separate layout groups whose border boxes overlap or render
|
|
124
|
+
with effectively no spacing. Same-parent rows, semantic control groups,
|
|
125
|
+
navigation, and positioned controls that merely touch are excluded so tabs,
|
|
126
|
+
segmented controls, and floating actions remain quiet. Tune the near-touch
|
|
127
|
+
threshold with `signals.controlCollisionGapPx`; intentional exceptions can
|
|
128
|
+
use `data-beacon-scan="allow"`.
|
|
122
129
|
- **Ambient watchdogs** — silent failures users abandon instead of reporting
|
|
123
130
|
become warning issues: scroll jail (a leaked modal scroll lock), stuck
|
|
124
131
|
loading (`aria-busy`/`role="progressbar"` that never resolves), occluded
|
|
@@ -138,7 +145,10 @@ beacon.captureMessage("checkout started", "info");
|
|
|
138
145
|
hidden, inert, transparent, and pointer-disabled control subtrees.
|
|
139
146
|
- **Theme and loading contracts** — mark an application boundary with
|
|
140
147
|
`data-beacon-theme="adaptive"` to report large opaque surfaces whose
|
|
141
|
-
luminance polarity contradicts the active light/dark mode.
|
|
148
|
+
luminance polarity contradicts the active light/dark mode. Interactive
|
|
149
|
+
controls use a smaller area threshold so light-only buttons do not disappear
|
|
150
|
+
inside an otherwise dark UI; tune it with
|
|
151
|
+
`signals.themeMismatchControlMinArea`. Intentional
|
|
142
152
|
inverted brand/media surfaces use `data-beacon-theme="allow"`. Loading UI
|
|
143
153
|
participates through native `aria-busy`/`role="progressbar"` semantics or
|
|
144
154
|
`data-beacon-loading`, without coupling the SDK to framework class names.
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export declare const BEACON_SIGNAL: {
|
|
|
28
28
|
readonly CAPABILITY_FAILURE: "capability_failure";
|
|
29
29
|
readonly BLANK_APP_ROOT: "blank_app_root";
|
|
30
30
|
readonly CONSOLE_ERROR: "console_error";
|
|
31
|
+
readonly CONTROL_COLLISION: "control_collision";
|
|
31
32
|
readonly CSP_VIOLATION: "csp_violation";
|
|
32
33
|
readonly CLIPBOARD_FAILURE: "clipboard_failure";
|
|
33
34
|
readonly DEAD_CLICK: "dead_click";
|
|
@@ -234,6 +235,13 @@ export type BeaconSignals = {
|
|
|
234
235
|
/** Rejected clipboard writes, including failures handled by application
|
|
235
236
|
* code. Clipboard contents are never captured. Default true. */
|
|
236
237
|
clipboardFailures?: boolean;
|
|
238
|
+
/** Interactive controls from separate layout groups that overlap or render
|
|
239
|
+
* with effectively no spacing. Intentional control groups and positioned
|
|
240
|
+
* controls that merely touch are excluded. Default true. */
|
|
241
|
+
controlCollisions?: boolean;
|
|
242
|
+
/** Maximum non-overlapping gap that counts as touching controls. Default
|
|
243
|
+
* 1px. */
|
|
244
|
+
controlCollisionGapPx?: number;
|
|
237
245
|
/** N rapid clicks in roughly the same spot. Default true. */
|
|
238
246
|
rageClicks?: boolean;
|
|
239
247
|
/** An interactive control clicked with no DOM/nav/scroll/focus/request response. Default true. */
|
|
@@ -379,6 +387,9 @@ export type BeaconSignals = {
|
|
|
379
387
|
/** Visible surface area required for theme-polarity checks. Default
|
|
380
388
|
* 10000px². */
|
|
381
389
|
themeMismatchMinArea?: number;
|
|
390
|
+
/** Visible area required when the opposite-polarity surface is itself an
|
|
391
|
+
* interactive control. Default 1500px². */
|
|
392
|
+
themeMismatchControlMinArea?: number;
|
|
382
393
|
/** Visible WebGL canvases whose context remains lost after a restoration
|
|
383
394
|
* grace period. Default true. */
|
|
384
395
|
webglContextLosses?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var BEACON_SIGNAL = {
|
|
|
15
15
|
CAPABILITY_FAILURE: "capability_failure",
|
|
16
16
|
BLANK_APP_ROOT: "blank_app_root",
|
|
17
17
|
CONSOLE_ERROR: "console_error",
|
|
18
|
+
CONTROL_COLLISION: "control_collision",
|
|
18
19
|
CSP_VIOLATION: "csp_violation",
|
|
19
20
|
CLIPBOARD_FAILURE: "clipboard_failure",
|
|
20
21
|
DEAD_CLICK: "dead_click",
|
|
@@ -723,10 +724,15 @@ var createBeacon = (options) => {
|
|
|
723
724
|
const VIEWPORT_BUCKET_XL_PX = 1440;
|
|
724
725
|
const OCCLUSION_SAMPLE_LIMIT = 25;
|
|
725
726
|
const OCCLUSION_COVERAGE_MIN = 0.9;
|
|
727
|
+
const CONTROL_COLLISION_SAMPLE_LIMIT = 80;
|
|
728
|
+
const CONTROL_COLLISION_DEFAULT_GAP_PX = 1;
|
|
729
|
+
const CONTROL_COLLISION_MIN_CROSS_AXIS_RATIO = 0.5;
|
|
730
|
+
const CONTROL_COLLISION_OVERLAP_TOLERANCE_PX = 1;
|
|
726
731
|
const INVISIBLE_TEXT_SAMPLE_LIMIT = 40;
|
|
727
732
|
const INVISIBLE_TEXT_CONTRAST_MAX = 1.2;
|
|
728
733
|
const THEME_SURFACE_SAMPLE_LIMIT = 200;
|
|
729
734
|
const THEME_MISMATCH_DEFAULT_MIN_AREA = 1e4;
|
|
735
|
+
const THEME_MISMATCH_CONTROL_DEFAULT_MIN_AREA = 1500;
|
|
730
736
|
const THEME_DARK_SURFACE_LUMINANCE_MAX = 0.12;
|
|
731
737
|
const THEME_LIGHT_SURFACE_LUMINANCE_MIN = 0.85;
|
|
732
738
|
const STUCK_LOADING_DEFAULT_MS = 20000;
|
|
@@ -1823,6 +1829,7 @@ var createBeacon = (options) => {
|
|
|
1823
1829
|
if (signals !== null && typeof document !== "undefined" && typeof window.getComputedStyle === "function") {
|
|
1824
1830
|
const detectOverflow = signals.layoutOverflows !== false;
|
|
1825
1831
|
const detectOcclusion = signals.occludedControls !== false;
|
|
1832
|
+
const detectControlCollision = signals.controlCollisions !== false;
|
|
1826
1833
|
const detectInvisibleText = signals.invisibleText !== false;
|
|
1827
1834
|
const detectStuckLoading = signals.stuckLoading !== false;
|
|
1828
1835
|
const detectThemeMismatch = signals.themeMismatches !== false;
|
|
@@ -1831,6 +1838,8 @@ var createBeacon = (options) => {
|
|
|
1831
1838
|
const overflowMaxReports = signals.layoutOverflowMaxReports ?? LAYOUT_OVERFLOW_MAX_REPORTS_DEFAULT;
|
|
1832
1839
|
const stuckLoadingMs = signals.stuckLoadingMs ?? STUCK_LOADING_DEFAULT_MS;
|
|
1833
1840
|
const themeMismatchMinArea = signals.themeMismatchMinArea ?? THEME_MISMATCH_DEFAULT_MIN_AREA;
|
|
1841
|
+
const themeMismatchControlMinArea = signals.themeMismatchControlMinArea ?? THEME_MISMATCH_CONTROL_DEFAULT_MIN_AREA;
|
|
1842
|
+
const controlCollisionGapPx = Math.max(0, signals.controlCollisionGapPx ?? CONTROL_COLLISION_DEFAULT_GAP_PX);
|
|
1834
1843
|
const seenOverflows = new Set;
|
|
1835
1844
|
let overflowReports = 0;
|
|
1836
1845
|
let overflowTimer;
|
|
@@ -1965,6 +1974,8 @@ var createBeacon = (options) => {
|
|
|
1965
1974
|
};
|
|
1966
1975
|
visit(body, null);
|
|
1967
1976
|
};
|
|
1977
|
+
const CONTROL_SELECTOR = 'a[href], button, input, select, textarea, [role="button"]';
|
|
1978
|
+
const INTENTIONAL_CONTROL_GROUP_SELECTOR = 'nav, [role="group"], [role="menu"], [role="radiogroup"], [role="tablist"], [role="toolbar"]';
|
|
1968
1979
|
const clipsAxis = (overflow) => overflow === "auto" || overflow === "scroll" || overflow === "hidden" || overflow === "clip";
|
|
1969
1980
|
const visibleControlRect = (control, rect, viewportWidth, viewportHeight) => {
|
|
1970
1981
|
const visible = {
|
|
@@ -2005,6 +2016,81 @@ var createBeacon = (options) => {
|
|
|
2005
2016
|
const source = element.getAttribute("src")?.trim().toLowerCase() ?? "";
|
|
2006
2017
|
return source.startsWith("chrome-extension:") || source.startsWith("moz-extension:") || source.startsWith("safari-web-extension:");
|
|
2007
2018
|
};
|
|
2019
|
+
const sharedIntentionalControlGroup = (first, second) => {
|
|
2020
|
+
const firstGroup = first.closest(INTENTIONAL_CONTROL_GROUP_SELECTOR);
|
|
2021
|
+
return firstGroup !== null && firstGroup === second.closest(INTENTIONAL_CONTROL_GROUP_SELECTOR);
|
|
2022
|
+
};
|
|
2023
|
+
const scanForControlCollisions = () => {
|
|
2024
|
+
const viewportWidth = document.documentElement.clientWidth;
|
|
2025
|
+
const viewportHeight = document.documentElement.clientHeight;
|
|
2026
|
+
const controls = [];
|
|
2027
|
+
for (const element of Array.from(document.querySelectorAll(CONTROL_SELECTOR))) {
|
|
2028
|
+
if (controls.length >= CONTROL_COLLISION_SAMPLE_LIMIT)
|
|
2029
|
+
break;
|
|
2030
|
+
if (isScanExempt(element) || hasHiddenAncestor(element, true))
|
|
2031
|
+
continue;
|
|
2032
|
+
const rect = element.getBoundingClientRect();
|
|
2033
|
+
if (rect.width === 0 || rect.height === 0)
|
|
2034
|
+
continue;
|
|
2035
|
+
const visible = visibleControlRect(element, rect, viewportWidth, viewportHeight);
|
|
2036
|
+
if (visible === null)
|
|
2037
|
+
continue;
|
|
2038
|
+
const position = window.getComputedStyle(element).position;
|
|
2039
|
+
controls.push({
|
|
2040
|
+
element,
|
|
2041
|
+
positioned: position === "absolute" || position === "fixed",
|
|
2042
|
+
rect: visible
|
|
2043
|
+
});
|
|
2044
|
+
}
|
|
2045
|
+
for (let firstIndex = 0;firstIndex < controls.length; firstIndex += 1) {
|
|
2046
|
+
const first = controls[firstIndex];
|
|
2047
|
+
if (first === undefined)
|
|
2048
|
+
continue;
|
|
2049
|
+
for (let secondIndex = firstIndex + 1;secondIndex < controls.length; secondIndex += 1) {
|
|
2050
|
+
const second = controls[secondIndex];
|
|
2051
|
+
if (second === undefined)
|
|
2052
|
+
continue;
|
|
2053
|
+
if (first.element.contains(second.element) || second.element.contains(first.element)) {
|
|
2054
|
+
continue;
|
|
2055
|
+
}
|
|
2056
|
+
const overlapX = Math.min(first.rect.right, second.rect.right) - Math.max(first.rect.left, second.rect.left);
|
|
2057
|
+
const overlapY = Math.min(first.rect.bottom, second.rect.bottom) - Math.max(first.rect.top, second.rect.top);
|
|
2058
|
+
const isOverlap = overlapX > CONTROL_COLLISION_OVERLAP_TOLERANCE_PX && overlapY > CONTROL_COLLISION_OVERLAP_TOLERANCE_PX;
|
|
2059
|
+
if (isOverlap) {
|
|
2060
|
+
const axis2 = overlapY <= overlapX ? "vertical" : "horizontal";
|
|
2061
|
+
reportScanIssue(first.element, BEACON_SIGNAL.CONTROL_COLLISION, `Control collision — ${describeElement(first.element)} overlaps ${describeElement(second.element)}`, {
|
|
2062
|
+
collidesWith: describeElement(second.element),
|
|
2063
|
+
collisionAxis: axis2,
|
|
2064
|
+
collisionKind: "overlap",
|
|
2065
|
+
overlapPx: String(Math.round(axis2 === "vertical" ? overlapY : overlapX))
|
|
2066
|
+
});
|
|
2067
|
+
continue;
|
|
2068
|
+
}
|
|
2069
|
+
if (first.element.parentElement === second.element.parentElement || sharedIntentionalControlGroup(first.element, second.element) || first.positioned || second.positioned) {
|
|
2070
|
+
continue;
|
|
2071
|
+
}
|
|
2072
|
+
const firstWidth = first.rect.right - first.rect.left;
|
|
2073
|
+
const secondWidth = second.rect.right - second.rect.left;
|
|
2074
|
+
const firstHeight = first.rect.bottom - first.rect.top;
|
|
2075
|
+
const secondHeight = second.rect.bottom - second.rect.top;
|
|
2076
|
+
const horizontalGap = Math.max(first.rect.left - second.rect.right, second.rect.left - first.rect.right, 0);
|
|
2077
|
+
const verticalGap = Math.max(first.rect.top - second.rect.bottom, second.rect.top - first.rect.bottom, 0);
|
|
2078
|
+
const horizontalOverlapRatio = Math.max(overlapX, 0) / Math.min(firstWidth, secondWidth);
|
|
2079
|
+
const verticalOverlapRatio = Math.max(overlapY, 0) / Math.min(firstHeight, secondHeight);
|
|
2080
|
+
const verticalTouch = verticalGap <= controlCollisionGapPx && horizontalOverlapRatio >= CONTROL_COLLISION_MIN_CROSS_AXIS_RATIO;
|
|
2081
|
+
const horizontalTouch = horizontalGap <= controlCollisionGapPx && verticalOverlapRatio >= CONTROL_COLLISION_MIN_CROSS_AXIS_RATIO;
|
|
2082
|
+
if (!verticalTouch && !horizontalTouch)
|
|
2083
|
+
continue;
|
|
2084
|
+
const axis = verticalTouch ? "vertical" : "horizontal";
|
|
2085
|
+
reportScanIssue(first.element, BEACON_SIGNAL.CONTROL_COLLISION, `Control collision — ${describeElement(first.element)} touches ${describeElement(second.element)}`, {
|
|
2086
|
+
collidesWith: describeElement(second.element),
|
|
2087
|
+
collisionAxis: axis,
|
|
2088
|
+
collisionKind: "touching",
|
|
2089
|
+
gapPx: String(Math.round(axis === "vertical" ? verticalGap : horizontalGap))
|
|
2090
|
+
});
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
};
|
|
2008
2094
|
const scanForOcclusion = () => {
|
|
2009
2095
|
if (typeof document.elementFromPoint !== "function")
|
|
2010
2096
|
return;
|
|
@@ -2012,7 +2098,7 @@ var createBeacon = (options) => {
|
|
|
2012
2098
|
return;
|
|
2013
2099
|
const viewportWidth = document.documentElement.clientWidth;
|
|
2014
2100
|
const viewportHeight = document.documentElement.clientHeight;
|
|
2015
|
-
const controls = document.querySelectorAll(
|
|
2101
|
+
const controls = document.querySelectorAll(CONTROL_SELECTOR);
|
|
2016
2102
|
let sampled = 0;
|
|
2017
2103
|
for (const control of Array.from(controls)) {
|
|
2018
2104
|
if (sampled >= OCCLUSION_SAMPLE_LIMIT)
|
|
@@ -2237,7 +2323,8 @@ var createBeacon = (options) => {
|
|
|
2237
2323
|
continue;
|
|
2238
2324
|
}
|
|
2239
2325
|
const rect = element.getBoundingClientRect();
|
|
2240
|
-
|
|
2326
|
+
const minimumArea = element.matches(CONTROL_SELECTOR) ? themeMismatchControlMinArea : themeMismatchMinArea;
|
|
2327
|
+
if (rect.width * rect.height < minimumArea)
|
|
2241
2328
|
continue;
|
|
2242
2329
|
if (rect.bottom < 0 || rect.top > viewportHeight || rect.right < 0 || rect.left > viewportWidth) {
|
|
2243
2330
|
continue;
|
|
@@ -2342,6 +2429,8 @@ var createBeacon = (options) => {
|
|
|
2342
2429
|
const runSettledScan = () => {
|
|
2343
2430
|
if (detectOverflow)
|
|
2344
2431
|
scanForOverflow();
|
|
2432
|
+
if (detectControlCollision)
|
|
2433
|
+
scanForControlCollisions();
|
|
2345
2434
|
if (detectOcclusion)
|
|
2346
2435
|
scanForOcclusion();
|
|
2347
2436
|
if (detectInvisibleText)
|
|
@@ -3963,5 +4052,5 @@ export {
|
|
|
3963
4052
|
BEACON_ATTRIBUTE
|
|
3964
4053
|
};
|
|
3965
4054
|
|
|
3966
|
-
//# debugId=
|
|
4055
|
+
//# debugId=65E8387E26687EFE64756E2164756E21
|
|
3967
4056
|
//# sourceMappingURL=index.js.map
|