@absolutejs/beacon 0.6.6 → 0.6.8

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.d.ts CHANGED
@@ -359,6 +359,11 @@ export type BeaconSignals = {
359
359
  /** Quiet period before an open, visible EventSource counts as stalled.
360
360
  * Default 60000ms. */
361
361
  stalledStreamMs?: number;
362
+ /** Endpoints that are quiet by design — push topics that only emit when
363
+ * something changes, so silence is health, not failure. Streams whose URL
364
+ * matches a string prefix or RegExp here are exempt from the
365
+ * stalled-stream signal (flap detection still applies). */
366
+ quietStreams?: Array<RegExp | string>;
362
367
  /** An `aria-busy`/`role="status"`/`role="progressbar"` element still
363
368
  * visible after `stuckLoadingMs` — a load that silently hung.
364
369
  * Default true. */
package/dist/index.js CHANGED
@@ -1799,6 +1799,40 @@ var createBeacon = (options) => {
1799
1799
  };
1800
1800
  visit(body, null);
1801
1801
  };
1802
+ const clipsAxis = (overflow) => overflow === "auto" || overflow === "scroll" || overflow === "hidden" || overflow === "clip";
1803
+ const visibleControlRect = (control, rect, viewportWidth, viewportHeight) => {
1804
+ const visible = {
1805
+ bottom: Math.min(rect.bottom, viewportHeight),
1806
+ left: Math.max(rect.left, 0),
1807
+ right: Math.min(rect.right, viewportWidth),
1808
+ top: Math.max(rect.top, 0)
1809
+ };
1810
+ for (let ancestor = control.parentElement;ancestor; ancestor = ancestor.parentElement) {
1811
+ const style = window.getComputedStyle(ancestor);
1812
+ const clipX = clipsAxis(style.overflowX);
1813
+ const clipY = clipsAxis(style.overflowY);
1814
+ if (!clipX && !clipY)
1815
+ continue;
1816
+ const ancestorRect = ancestor.getBoundingClientRect();
1817
+ if (clipX) {
1818
+ visible.left = Math.max(visible.left, ancestorRect.left);
1819
+ visible.right = Math.min(visible.right, ancestorRect.right);
1820
+ }
1821
+ if (clipY) {
1822
+ visible.top = Math.max(visible.top, ancestorRect.top);
1823
+ visible.bottom = Math.min(visible.bottom, ancestorRect.bottom);
1824
+ }
1825
+ if (visible.left >= visible.right || visible.top >= visible.bottom) {
1826
+ return null;
1827
+ }
1828
+ }
1829
+ const centerX = (rect.left + rect.right) / 2;
1830
+ const centerY = (rect.top + rect.bottom) / 2;
1831
+ if (centerX < visible.left || centerX > visible.right || centerY < visible.top || centerY > visible.bottom) {
1832
+ return null;
1833
+ }
1834
+ return visible;
1835
+ };
1802
1836
  const scanForOcclusion = () => {
1803
1837
  if (typeof document.elementFromPoint !== "function")
1804
1838
  return;
@@ -1816,18 +1850,18 @@ var createBeacon = (options) => {
1816
1850
  const rect = control.getBoundingClientRect();
1817
1851
  if (rect.width === 0 || rect.height === 0)
1818
1852
  continue;
1819
- if (rect.left < 0 || rect.top < 0 || rect.right > viewportWidth || rect.bottom > viewportHeight) {
1853
+ const visibleRect = visibleControlRect(control, rect, viewportWidth, viewportHeight);
1854
+ if (visibleRect === null)
1820
1855
  continue;
1821
- }
1822
1856
  sampled += 1;
1823
- const top = document.elementFromPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2);
1857
+ const top = document.elementFromPoint((visibleRect.left + visibleRect.right) / 2, (visibleRect.top + visibleRect.bottom) / 2);
1824
1858
  if (top === null || top === control || control.contains(top) || top.contains(control)) {
1825
1859
  continue;
1826
1860
  }
1827
1861
  const topRect = top.getBoundingClientRect();
1828
- const overlapX = Math.min(rect.right, topRect.right) - Math.max(rect.left, topRect.left);
1829
- const overlapY = Math.min(rect.bottom, topRect.bottom) - Math.max(rect.top, topRect.top);
1830
- const coverage = Math.max(overlapX, 0) * Math.max(overlapY, 0) / (rect.width * rect.height);
1862
+ const overlapX = Math.min(visibleRect.right, topRect.right) - Math.max(visibleRect.left, topRect.left);
1863
+ const overlapY = Math.min(visibleRect.bottom, topRect.bottom) - Math.max(visibleRect.top, topRect.top);
1864
+ const coverage = Math.max(overlapX, 0) * Math.max(overlapY, 0) / ((visibleRect.right - visibleRect.left) * (visibleRect.bottom - visibleRect.top));
1831
1865
  if (coverage < OCCLUSION_COVERAGE_MIN)
1832
1866
  continue;
1833
1867
  reportScanIssue(control, BEACON_SIGNAL.OCCLUDED_CONTROL, `Occluded control — ${describeElement(control)} is covered by ${describeElement(top)}`, { coveredBy: describeElement(top) });
@@ -2967,7 +3001,8 @@ var createBeacon = (options) => {
2967
3001
  const reportedStreams = new Set;
2968
3002
  const errorsByEndpoint = new Map;
2969
3003
  const reportedFlappingStreams = new Set;
2970
- const instrumentSource = (source, endpointLabel) => {
3004
+ const quietStream = (url) => (signals.quietStreams ?? []).some((pattern) => typeof pattern === "string" ? url.startsWith(pattern) || shortUrl(url).startsWith(pattern) : pattern.test(url));
3005
+ const instrumentSource = (source, endpointLabel, sourceUrl) => {
2971
3006
  let stallTimer;
2972
3007
  const disarm = () => {
2973
3008
  if (stallTimer !== undefined)
@@ -2976,6 +3011,8 @@ var createBeacon = (options) => {
2976
3011
  const check = () => {
2977
3012
  if (signals.stalledStreams === false)
2978
3013
  return;
3014
+ if (quietStream(sourceUrl))
3015
+ return;
2979
3016
  if (source.readyState !== OriginalEventSource.OPEN)
2980
3017
  return;
2981
3018
  if (document.visibilityState === "hidden") {
@@ -3041,7 +3078,7 @@ var createBeacon = (options) => {
3041
3078
  const wrappedEventSource = new Proxy(OriginalEventSource, {
3042
3079
  construct(target, args) {
3043
3080
  const source = Reflect.construct(target, args);
3044
- instrumentSource(source, shortUrl(String(args[0])));
3081
+ instrumentSource(source, shortUrl(String(args[0])), String(args[0]));
3045
3082
  return source;
3046
3083
  }
3047
3084
  });
@@ -3580,5 +3617,5 @@ export {
3580
3617
  BEACON_ATTRIBUTE
3581
3618
  };
3582
3619
 
3583
- //# debugId=89339955D8F62E0E64756E2164756E21
3620
+ //# debugId=875797C6E48C710C64756E2164756E21
3584
3621
  //# sourceMappingURL=index.js.map