@absolutejs/beacon 0.6.43 → 0.6.45

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
@@ -267,6 +267,9 @@ export type BeaconSignals = {
267
267
  /** `FontFace` loads that end in `status: "error"` — icon fonts falling back
268
268
  * to raw ligature text, custom faces silently missing. Default true. */
269
269
  fontFailures?: boolean;
270
+ /** Time a visible failed face must remain unavailable before it is reported.
271
+ * The face is retried at both ends of the window. Default 5000ms. */
272
+ fontFailureConfirmMs?: number;
270
273
  /** The same form submitted or failing native validation repeatedly within a
271
274
  * minute — the quiet sibling of a rage click. Default true. */
272
275
  formFrustration?: boolean;
package/dist/index.js CHANGED
@@ -754,6 +754,7 @@ var createBeacon = (options) => {
754
754
  const EMBEDDED_CONTENT_STALL_DEFAULT_MS = 15000;
755
755
  const WEBGL_RESTORE_GRACE_DEFAULT_MS = 2000;
756
756
  const FOCUSED_CONTROL_SETTLE_DEFAULT_MS = 500;
757
+ const FONT_FAILURE_CONFIRM_DEFAULT_MS = 5000;
757
758
  const KEYBOARD_VIEWPORT_HEIGHT_RATIO_MAX = 0.8;
758
759
  const SCROLL_JAIL_EVENT_COUNT = 8;
759
760
  const SCROLL_JAIL_WINDOW_MS = 2000;
@@ -2143,7 +2144,7 @@ var createBeacon = (options) => {
2143
2144
  continue;
2144
2145
  sampled += 1;
2145
2146
  const top = document.elementFromPoint((visibleRect.left + visibleRect.right) / 2, (visibleRect.top + visibleRect.bottom) / 2);
2146
- if (top === null || top === control || control.contains(top) || top.contains(control) || isExtensionOwnedCover(top)) {
2147
+ if (top === null || top === control || control.contains(top) || top.contains(control) || crossesDialogBoundary(control, top) || isExtensionOwnedCover(top)) {
2147
2148
  continue;
2148
2149
  }
2149
2150
  const topRect = top.getBoundingClientRect();
@@ -3918,6 +3919,7 @@ var createBeacon = (options) => {
3918
3919
  if (signals !== null && signals.fontFailures !== false && typeof document !== "undefined" && "fonts" in document && (typeof navigator === "undefined" || navigator.webdriver !== true)) {
3919
3920
  const reportedFonts = new Set;
3920
3921
  const checkingFonts = new Set;
3922
+ const confirmationMs = Math.max(0, signals.fontFailureConfirmMs ?? FONT_FAILURE_CONFIRM_DEFAULT_MS);
3921
3923
  const normalizedFamily = (family) => family.trim().replace(/^(['"])(.*)\1$/u, "$2").toLowerCase();
3922
3924
  const isRendered = (element) => {
3923
3925
  for (let current = element;current !== null; current = current.parentElement) {
@@ -3960,16 +3962,38 @@ var createBeacon = (options) => {
3960
3962
  if (element === null)
3961
3963
  return;
3962
3964
  checkingFonts.add(key);
3963
- const sample = element.textContent?.trim().slice(0, 64) || "BESbswy";
3964
- const font = `${face.style} ${face.weight} ${face.stretch} 16px ${JSON.stringify(face.family)}`;
3965
+ const fontAvailable = async (consumer) => {
3966
+ const sample = consumer.textContent?.trim().slice(0, 64) || "BESbswy";
3967
+ const font = `${face.style} ${face.weight} ${face.stretch} 16px ${JSON.stringify(face.family)}`;
3968
+ try {
3969
+ await document.fonts.load(font, sample);
3970
+ return document.fonts.check(font, sample);
3971
+ } catch {
3972
+ return false;
3973
+ }
3974
+ };
3965
3975
  try {
3966
- await document.fonts.load(font, sample);
3967
- if (document.fonts.check(font, sample))
3976
+ if (await fontAvailable(element))
3968
3977
  return;
3969
- } catch {} finally {
3978
+ if (confirmationMs > 0) {
3979
+ await new Promise((resolve) => {
3980
+ const timer2 = window.setTimeout(resolve, confirmationMs);
3981
+ cleanups.push(() => window.clearTimeout(timer2));
3982
+ });
3983
+ if (document.visibilityState === "hidden")
3984
+ return;
3985
+ const confirmedElement = affectedElement(face.family);
3986
+ if (confirmedElement === null)
3987
+ return;
3988
+ if (await fontAvailable(confirmedElement))
3989
+ return;
3990
+ reportFontFailure(face, confirmedElement, key);
3991
+ return;
3992
+ }
3993
+ reportFontFailure(face, element, key);
3994
+ } finally {
3970
3995
  checkingFonts.delete(key);
3971
3996
  }
3972
- reportFontFailure(face, element, key);
3973
3997
  };
3974
3998
  const sweepFonts = () => {
3975
3999
  document.fonts.forEach((face) => {
@@ -4271,5 +4295,5 @@ export {
4271
4295
  BEACON_ATTRIBUTE
4272
4296
  };
4273
4297
 
4274
- //# debugId=BA5DCA321E271C2D64756E2164756E21
4298
+ //# debugId=DEE1AFDA72425FCF64756E2164756E21
4275
4299
  //# sourceMappingURL=index.js.map