@absolutejs/beacon 0.7.0-beta.21 → 0.7.0-beta.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/CHANGELOG.md +6 -0
- package/changelog.json +14 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +61 -39
- package/dist/index.js.map +3 -3
- package/dist/outbox.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,12 @@ This file is generated by `absolute-changelog` from the entries in
|
|
|
6
6
|
`changelog/`. Edit an entry, not this file — and add new ones under
|
|
7
7
|
`changelog/unreleased/`.
|
|
8
8
|
|
|
9
|
+
## 0.7.0-beta.22 — 2026-10-27
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- **Reuse geometry and computed styles within each layout scan, reducing repeated DOM reads while preserving fresh measurements on subsequent scans.** (`createBeacon`, `BEACON_SDK_VERSION`)
|
|
14
|
+
|
|
9
15
|
## 0.7.0-beta.21 — 2026-10-27
|
|
10
16
|
|
|
11
17
|
### Fixed
|
package/changelog.json
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
"contract": 1,
|
|
3
3
|
"name": "@absolutejs/beacon",
|
|
4
4
|
"releases": [
|
|
5
|
+
{
|
|
6
|
+
"changes": [
|
|
7
|
+
{
|
|
8
|
+
"kind": "fixed",
|
|
9
|
+
"summary": "Reuse geometry and computed styles within each layout scan, reducing repeated DOM reads while preserving fresh measurements on subsequent scans.",
|
|
10
|
+
"symbols": [
|
|
11
|
+
"createBeacon",
|
|
12
|
+
"BEACON_SDK_VERSION"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"date": "2026-10-27",
|
|
17
|
+
"version": "0.7.0-beta.22"
|
|
18
|
+
},
|
|
5
19
|
{
|
|
6
20
|
"changes": [
|
|
7
21
|
{
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export type BeaconLevel = "fatal" | "error" | "warning" | "info";
|
|
|
25
25
|
/** Response header used to correlate a browser signal with its server request. */
|
|
26
26
|
export declare const BEACON_TRACE_HEADER = "x-absolute-trace-id";
|
|
27
27
|
/** Beacon package version retained with every captured event. */
|
|
28
|
-
export declare const BEACON_SDK_VERSION = "0.7.0-beta.
|
|
28
|
+
export declare const BEACON_SDK_VERSION = "0.7.0-beta.22";
|
|
29
29
|
/** Arbitrary event tags, with Beacon's reserved `signal` tag type-checked. */
|
|
30
30
|
export type BeaconTags = Record<string, string> & {
|
|
31
31
|
signal?: BeaconSignal;
|
package/dist/index.js
CHANGED
|
@@ -192,7 +192,7 @@ var consumeEarlyLayoutShiftBuffer = () => {
|
|
|
192
192
|
|
|
193
193
|
// src/index.ts
|
|
194
194
|
var BEACON_TRACE_HEADER = "x-absolute-trace-id";
|
|
195
|
-
var BEACON_SDK_VERSION = "0.7.0-beta.
|
|
195
|
+
var BEACON_SDK_VERSION = "0.7.0-beta.22";
|
|
196
196
|
var inBrowser = () => typeof window !== "undefined";
|
|
197
197
|
var newId = () => {
|
|
198
198
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
@@ -2255,6 +2255,23 @@ var createBeacon = (options) => {
|
|
|
2255
2255
|
});
|
|
2256
2256
|
}
|
|
2257
2257
|
if (signals !== null && typeof document !== "undefined" && typeof window.getComputedStyle === "function") {
|
|
2258
|
+
let scanReads = null;
|
|
2259
|
+
const scanStyle = (element) => {
|
|
2260
|
+
const cached = scanReads?.styles.get(element);
|
|
2261
|
+
if (cached)
|
|
2262
|
+
return cached;
|
|
2263
|
+
const style = window.getComputedStyle(element);
|
|
2264
|
+
scanReads?.styles.set(element, style);
|
|
2265
|
+
return style;
|
|
2266
|
+
};
|
|
2267
|
+
const scanRect = (element) => {
|
|
2268
|
+
const cached = scanReads?.rects.get(element);
|
|
2269
|
+
if (cached)
|
|
2270
|
+
return cached;
|
|
2271
|
+
const rect = element.getBoundingClientRect();
|
|
2272
|
+
scanReads?.rects.set(element, rect);
|
|
2273
|
+
return rect;
|
|
2274
|
+
};
|
|
2258
2275
|
const detectOverflow = signals.layoutOverflows !== false;
|
|
2259
2276
|
const detectOcclusion = signals.occludedControls !== false;
|
|
2260
2277
|
const detectControlCollision = signals.controlCollisions !== false;
|
|
@@ -2293,7 +2310,7 @@ var createBeacon = (options) => {
|
|
|
2293
2310
|
if (current.hasAttribute("hidden") || current.hasAttribute("inert") || current.getAttribute("aria-hidden") === "true") {
|
|
2294
2311
|
return true;
|
|
2295
2312
|
}
|
|
2296
|
-
const style =
|
|
2313
|
+
const style = scanStyle(current);
|
|
2297
2314
|
if (style.display === "none" || style.visibility === "hidden" || style.visibility === "collapse" || Number.parseFloat(style.opacity || "1") <= 0.01 || requirePointerEvents && style.pointerEvents === "none") {
|
|
2298
2315
|
return true;
|
|
2299
2316
|
}
|
|
@@ -2329,7 +2346,7 @@ var createBeacon = (options) => {
|
|
|
2329
2346
|
return;
|
|
2330
2347
|
seenOverflows.add(key);
|
|
2331
2348
|
overflowReports += 1;
|
|
2332
|
-
const rect = element
|
|
2349
|
+
const rect = scanRect(element);
|
|
2333
2350
|
const resourceUrl = RESOURCE_ERROR_TAGS.has(element.tagName.toLowerCase()) ? resourceUrlOf(element) : undefined;
|
|
2334
2351
|
const injectionMarkers = injectionMarkersOf(element);
|
|
2335
2352
|
emitSignal(`Layout overflow — ${describeElement(element)} ${detail} — ${shortUrl(location.href)} [${bucket}]`, {
|
|
@@ -2341,7 +2358,7 @@ var createBeacon = (options) => {
|
|
|
2341
2358
|
targetBottomPx: String(Math.round(rect.bottom)),
|
|
2342
2359
|
targetHeightPx: String(Math.round(rect.height)),
|
|
2343
2360
|
targetLeftPx: String(Math.round(rect.left)),
|
|
2344
|
-
targetPosition:
|
|
2361
|
+
targetPosition: scanStyle(element).position,
|
|
2345
2362
|
targetRightPx: String(Math.round(rect.right)),
|
|
2346
2363
|
targetTopPx: String(Math.round(rect.top)),
|
|
2347
2364
|
targetWidthPx: String(Math.round(rect.width)),
|
|
@@ -2364,10 +2381,10 @@ var createBeacon = (options) => {
|
|
|
2364
2381
|
if (RESOURCE_ERROR_TAGS.has(element.tagName.toLowerCase()) && isExtensionResourceUrl(resourceUrlOf(element))) {
|
|
2365
2382
|
return;
|
|
2366
2383
|
}
|
|
2367
|
-
const style =
|
|
2384
|
+
const style = scanStyle(element);
|
|
2368
2385
|
if (hasHiddenAncestor(element))
|
|
2369
2386
|
return;
|
|
2370
|
-
const rect = element
|
|
2387
|
+
const rect = scanRect(element);
|
|
2371
2388
|
if (rect.width === 0 && rect.height === 0)
|
|
2372
2389
|
return;
|
|
2373
2390
|
if (rect.width <= 2 && rect.height <= 2 && (style.overflowX === "hidden" || style.overflowX === "clip" || style.overflowY === "hidden" || style.overflowY === "clip")) {
|
|
@@ -2421,12 +2438,12 @@ var createBeacon = (options) => {
|
|
|
2421
2438
|
top: Math.max(rect.top, 0)
|
|
2422
2439
|
};
|
|
2423
2440
|
for (let ancestor = control.parentElement;ancestor; ancestor = ancestor.parentElement) {
|
|
2424
|
-
const style =
|
|
2441
|
+
const style = scanStyle(ancestor);
|
|
2425
2442
|
const clipX = clipsAxis(style.overflowX);
|
|
2426
2443
|
const clipY = clipsAxis(style.overflowY);
|
|
2427
2444
|
if (!clipX && !clipY)
|
|
2428
2445
|
continue;
|
|
2429
|
-
const ancestorRect = ancestor
|
|
2446
|
+
const ancestorRect = scanRect(ancestor);
|
|
2430
2447
|
if (clipX) {
|
|
2431
2448
|
visible.left = Math.max(visible.left, ancestorRect.left);
|
|
2432
2449
|
visible.right = Math.min(visible.right, ancestorRect.right);
|
|
@@ -2469,9 +2486,9 @@ var createBeacon = (options) => {
|
|
|
2469
2486
|
};
|
|
2470
2487
|
const scanLayoutContext = (target, other) => {
|
|
2471
2488
|
const geometry = (element) => {
|
|
2472
|
-
const rect = element
|
|
2489
|
+
const rect = scanRect(element);
|
|
2473
2490
|
let positionedAncestor = element;
|
|
2474
|
-
while (positionedAncestor !== null && !["fixed", "sticky"].includes(
|
|
2491
|
+
while (positionedAncestor !== null && !["fixed", "sticky"].includes(scanStyle(positionedAncestor).position)) {
|
|
2475
2492
|
positionedAncestor = positionedAncestor.parentElement;
|
|
2476
2493
|
}
|
|
2477
2494
|
return {
|
|
@@ -2483,10 +2500,10 @@ var createBeacon = (options) => {
|
|
|
2483
2500
|
width: rect.width,
|
|
2484
2501
|
height: rect.height
|
|
2485
2502
|
},
|
|
2486
|
-
position:
|
|
2503
|
+
position: scanStyle(element).position,
|
|
2487
2504
|
...positionedAncestor ? {
|
|
2488
2505
|
positionedAncestor: describeElement(positionedAncestor),
|
|
2489
|
-
ancestorPosition:
|
|
2506
|
+
ancestorPosition: scanStyle(positionedAncestor).position
|
|
2490
2507
|
} : {}
|
|
2491
2508
|
};
|
|
2492
2509
|
};
|
|
@@ -2508,13 +2525,13 @@ var createBeacon = (options) => {
|
|
|
2508
2525
|
break;
|
|
2509
2526
|
if (isScanExempt(element) || hasHiddenAncestor(element, true))
|
|
2510
2527
|
continue;
|
|
2511
|
-
const rect = element
|
|
2528
|
+
const rect = scanRect(element);
|
|
2512
2529
|
if (rect.width === 0 || rect.height === 0)
|
|
2513
2530
|
continue;
|
|
2514
2531
|
const visible = visibleControlRect(element, rect, viewportWidth, viewportHeight);
|
|
2515
2532
|
if (visible === null)
|
|
2516
2533
|
continue;
|
|
2517
|
-
const position =
|
|
2534
|
+
const position = scanStyle(element).position;
|
|
2518
2535
|
controls.push({
|
|
2519
2536
|
element,
|
|
2520
2537
|
positioned: position === "absolute" || position === "fixed",
|
|
@@ -2587,7 +2604,7 @@ var createBeacon = (options) => {
|
|
|
2587
2604
|
return;
|
|
2588
2605
|
if (isScanExempt(control) || hasHiddenAncestor(control, true))
|
|
2589
2606
|
continue;
|
|
2590
|
-
const rect = control
|
|
2607
|
+
const rect = scanRect(control);
|
|
2591
2608
|
if (rect.width === 0 || rect.height === 0)
|
|
2592
2609
|
continue;
|
|
2593
2610
|
const visibleRect = visibleControlRect(control, rect, viewportWidth, viewportHeight);
|
|
@@ -2598,7 +2615,7 @@ var createBeacon = (options) => {
|
|
|
2598
2615
|
if (top === null || top === control || control.contains(top) || top.contains(control) || crossesDialogBoundary(control, top) || isExtensionOwnedCover(top)) {
|
|
2599
2616
|
continue;
|
|
2600
2617
|
}
|
|
2601
|
-
const topRect = top
|
|
2618
|
+
const topRect = scanRect(top);
|
|
2602
2619
|
const overlapX = Math.min(visibleRect.right, topRect.right) - Math.max(visibleRect.left, topRect.left);
|
|
2603
2620
|
const overlapY = Math.min(visibleRect.bottom, topRect.bottom) - Math.max(visibleRect.top, topRect.top);
|
|
2604
2621
|
const coverage = Math.max(overlapX, 0) * Math.max(overlapY, 0) / ((visibleRect.right - visibleRect.left) * (visibleRect.bottom - visibleRect.top));
|
|
@@ -2712,7 +2729,7 @@ var createBeacon = (options) => {
|
|
|
2712
2729
|
let accumulated = null;
|
|
2713
2730
|
let node = element;
|
|
2714
2731
|
while (node !== null) {
|
|
2715
|
-
const style =
|
|
2732
|
+
const style = scanStyle(node);
|
|
2716
2733
|
if (style.backgroundImage !== "none" && style.backgroundImage !== "") {
|
|
2717
2734
|
return null;
|
|
2718
2735
|
}
|
|
@@ -2745,13 +2762,13 @@ var createBeacon = (options) => {
|
|
|
2745
2762
|
continue;
|
|
2746
2763
|
if ((element.textContent ?? "").trim() === "")
|
|
2747
2764
|
continue;
|
|
2748
|
-
const rect = element
|
|
2765
|
+
const rect = scanRect(element);
|
|
2749
2766
|
if (rect.width === 0 || rect.height === 0)
|
|
2750
2767
|
continue;
|
|
2751
2768
|
if (rect.bottom < 0 || rect.top > viewportHeight || rect.right < 0 || rect.left > viewportWidth) {
|
|
2752
2769
|
continue;
|
|
2753
2770
|
}
|
|
2754
|
-
const style =
|
|
2771
|
+
const style = scanStyle(element);
|
|
2755
2772
|
if (Number(style.opacity || "1") < 0.1)
|
|
2756
2773
|
continue;
|
|
2757
2774
|
const foreground = parseColor(style.color);
|
|
@@ -2781,7 +2798,7 @@ var createBeacon = (options) => {
|
|
|
2781
2798
|
};
|
|
2782
2799
|
const activeTheme = () => {
|
|
2783
2800
|
const root = document.documentElement;
|
|
2784
|
-
const declared =
|
|
2801
|
+
const declared = scanStyle(root).colorScheme.trim();
|
|
2785
2802
|
if (declared === "dark")
|
|
2786
2803
|
return "dark";
|
|
2787
2804
|
if (declared === "light")
|
|
@@ -2809,7 +2826,7 @@ var createBeacon = (options) => {
|
|
|
2809
2826
|
if (element.closest(`[${BEACON_ATTRIBUTE.THEME}="allow"]`) !== null || isScanExempt(element) || element.matches("canvas, iframe, img, picture, svg, video")) {
|
|
2810
2827
|
continue;
|
|
2811
2828
|
}
|
|
2812
|
-
const rect = element
|
|
2829
|
+
const rect = scanRect(element);
|
|
2813
2830
|
const minimumArea = element.matches(CONTROL_SELECTOR) ? themeMismatchControlMinArea : themeMismatchMinArea;
|
|
2814
2831
|
if (rect.width * rect.height < minimumArea)
|
|
2815
2832
|
continue;
|
|
@@ -2819,7 +2836,7 @@ var createBeacon = (options) => {
|
|
|
2819
2836
|
const hasContent = (element.textContent ?? "").trim() !== "" || element.querySelector("button, input, select, textarea, [role=button]") !== null;
|
|
2820
2837
|
if (!hasContent)
|
|
2821
2838
|
continue;
|
|
2822
|
-
const style =
|
|
2839
|
+
const style = scanStyle(element);
|
|
2823
2840
|
if (style.display === "none" || style.visibility === "hidden" || style.backgroundImage !== "none" && style.backgroundImage !== "") {
|
|
2824
2841
|
continue;
|
|
2825
2842
|
}
|
|
@@ -2903,7 +2920,7 @@ var createBeacon = (options) => {
|
|
|
2903
2920
|
resetLoadingIndicator(indicator);
|
|
2904
2921
|
continue;
|
|
2905
2922
|
}
|
|
2906
|
-
const rect = indicator
|
|
2923
|
+
const rect = scanRect(indicator);
|
|
2907
2924
|
if (rect.width === 0 && rect.height === 0) {
|
|
2908
2925
|
resetLoadingIndicator(indicator);
|
|
2909
2926
|
continue;
|
|
@@ -2935,7 +2952,7 @@ var createBeacon = (options) => {
|
|
|
2935
2952
|
for (const root of Array.from(roots)) {
|
|
2936
2953
|
if (isScanExempt(root))
|
|
2937
2954
|
continue;
|
|
2938
|
-
const rect = root
|
|
2955
|
+
const rect = scanRect(root);
|
|
2939
2956
|
if (rect.width === 0 || rect.height === 0)
|
|
2940
2957
|
continue;
|
|
2941
2958
|
const text = (root.textContent ?? "").trim();
|
|
@@ -2967,23 +2984,28 @@ var createBeacon = (options) => {
|
|
|
2967
2984
|
];
|
|
2968
2985
|
return utilityExpectations.every(([selector, property, expected]) => {
|
|
2969
2986
|
const sample = document.querySelector(selector);
|
|
2970
|
-
return sample === null ||
|
|
2987
|
+
return sample === null || scanStyle(sample)[property] === expected;
|
|
2971
2988
|
});
|
|
2972
2989
|
};
|
|
2973
2990
|
const runSettledScan = () => {
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2991
|
+
scanReads = { styles: new WeakMap, rects: new WeakMap };
|
|
2992
|
+
try {
|
|
2993
|
+
const geometryReady = documentStylesAreReady() && !mobileKeyboardViewportActive() && !visualViewportHorizontallyShifted();
|
|
2994
|
+
if (detectOverflow && geometryReady)
|
|
2995
|
+
scanForOverflow();
|
|
2996
|
+
if (detectControlCollision && geometryReady)
|
|
2997
|
+
scanForControlCollisions();
|
|
2998
|
+
if (detectOcclusion && geometryReady)
|
|
2999
|
+
scanForOcclusion();
|
|
3000
|
+
if (detectInvisibleText && geometryReady)
|
|
3001
|
+
scanForInvisibleText();
|
|
3002
|
+
if (detectThemeMismatch && geometryReady)
|
|
3003
|
+
scanForThemeMismatch();
|
|
3004
|
+
if (detectStuckLoading)
|
|
3005
|
+
checkStuckLoading();
|
|
3006
|
+
} finally {
|
|
3007
|
+
scanReads = null;
|
|
3008
|
+
}
|
|
2987
3009
|
};
|
|
2988
3010
|
const scheduleOverflowScan = () => {
|
|
2989
3011
|
if (overflowTimer !== undefined)
|
|
@@ -5044,5 +5066,5 @@ export {
|
|
|
5044
5066
|
redactBeaconEvent
|
|
5045
5067
|
};
|
|
5046
5068
|
|
|
5047
|
-
//# debugId=
|
|
5069
|
+
//# debugId=58612BFF269FAD0A64756E2164756E21
|
|
5048
5070
|
//# sourceMappingURL=index.js.map
|