@absolutejs/beacon 0.6.36 → 0.6.38
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 +67 -9
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2024,6 +2024,11 @@ var createBeacon = (options) => {
|
|
|
2024
2024
|
const firstGroup = first.closest(INTENTIONAL_CONTROL_GROUP_SELECTOR);
|
|
2025
2025
|
return firstGroup !== null && firstGroup === second.closest(INTENTIONAL_CONTROL_GROUP_SELECTOR);
|
|
2026
2026
|
};
|
|
2027
|
+
const crossesDialogBoundary = (first, second) => {
|
|
2028
|
+
const firstDialog = first.closest('[role="dialog"], dialog');
|
|
2029
|
+
const secondDialog = second.closest('[role="dialog"], dialog');
|
|
2030
|
+
return firstDialog === null !== (secondDialog === null);
|
|
2031
|
+
};
|
|
2027
2032
|
const scanForControlCollisions = () => {
|
|
2028
2033
|
const viewportWidth = document.documentElement.clientWidth;
|
|
2029
2034
|
const viewportHeight = document.documentElement.clientHeight;
|
|
@@ -2054,7 +2059,7 @@ var createBeacon = (options) => {
|
|
|
2054
2059
|
const second = controls[secondIndex];
|
|
2055
2060
|
if (second === undefined)
|
|
2056
2061
|
continue;
|
|
2057
|
-
if (first.element.contains(second.element) || second.element.contains(first.element)) {
|
|
2062
|
+
if (first.element.contains(second.element) || second.element.contains(first.element) || crossesDialogBoundary(first.element, second.element)) {
|
|
2058
2063
|
continue;
|
|
2059
2064
|
}
|
|
2060
2065
|
const overlapX = Math.min(first.rect.right, second.rect.right) - Math.max(first.rect.left, second.rect.left);
|
|
@@ -3800,14 +3805,66 @@ var createBeacon = (options) => {
|
|
|
3800
3805
|
localStorage.setItem(STALE_RELEASE_STORAGE_KEY, JSON.stringify(trimmed));
|
|
3801
3806
|
} catch {}
|
|
3802
3807
|
}
|
|
3803
|
-
if (signals !== null && signals.fontFailures !== false && typeof document !== "undefined" && "fonts" in document) {
|
|
3808
|
+
if (signals !== null && signals.fontFailures !== false && typeof document !== "undefined" && "fonts" in document && (typeof navigator === "undefined" || navigator.webdriver !== true)) {
|
|
3804
3809
|
const reportedFonts = new Set;
|
|
3810
|
+
const checkingFonts = new Set;
|
|
3811
|
+
const normalizedFamily = (family) => family.trim().replace(/^(['"])(.*)\1$/u, "$2").toLowerCase();
|
|
3812
|
+
const isRendered = (element) => {
|
|
3813
|
+
for (let current = element;current !== null; current = current.parentElement) {
|
|
3814
|
+
const style = window.getComputedStyle(current);
|
|
3815
|
+
if (style.display === "none" || style.visibility === "hidden" || style.visibility === "collapse" || Number.parseFloat(style.opacity || "1") <= 0.01) {
|
|
3816
|
+
return false;
|
|
3817
|
+
}
|
|
3818
|
+
}
|
|
3819
|
+
const rect = element.getBoundingClientRect();
|
|
3820
|
+
return rect.width > 0 && rect.height > 0;
|
|
3821
|
+
};
|
|
3822
|
+
const affectedElement = (family) => {
|
|
3823
|
+
const expected = normalizedFamily(family);
|
|
3824
|
+
for (const element of document.querySelectorAll("body *")) {
|
|
3825
|
+
if (!isRendered(element))
|
|
3826
|
+
continue;
|
|
3827
|
+
const style = window.getComputedStyle(element);
|
|
3828
|
+
const families = style.fontFamily.split(",").map(normalizedFamily);
|
|
3829
|
+
if (families.includes(expected))
|
|
3830
|
+
return element;
|
|
3831
|
+
}
|
|
3832
|
+
return null;
|
|
3833
|
+
};
|
|
3834
|
+
const reportFontFailure = (face, element, key) => {
|
|
3835
|
+
reportedFonts.add(key);
|
|
3836
|
+
emitSignal(`Font failure — ${face.family} failed to load — ${shortUrl(location.href)}`, {
|
|
3837
|
+
fontFamily: face.family,
|
|
3838
|
+
fontStretch: face.stretch,
|
|
3839
|
+
fontStyle: face.style,
|
|
3840
|
+
fontWeight: face.weight,
|
|
3841
|
+
signal: BEACON_SIGNAL.FONT_FAILURE,
|
|
3842
|
+
target: describeElement(element)
|
|
3843
|
+
});
|
|
3844
|
+
};
|
|
3845
|
+
const verifyFontFailure = async (face) => {
|
|
3846
|
+
const key = [face.family, face.style, face.weight, face.stretch].join("|");
|
|
3847
|
+
if (reportedFonts.has(key) || checkingFonts.has(key))
|
|
3848
|
+
return;
|
|
3849
|
+
const element = affectedElement(face.family);
|
|
3850
|
+
if (element === null)
|
|
3851
|
+
return;
|
|
3852
|
+
checkingFonts.add(key);
|
|
3853
|
+
const sample = element.textContent?.trim().slice(0, 64) || "BESbswy";
|
|
3854
|
+
const font = `${face.style} ${face.weight} ${face.stretch} 16px ${JSON.stringify(face.family)}`;
|
|
3855
|
+
try {
|
|
3856
|
+
await document.fonts.load(font, sample);
|
|
3857
|
+
if (document.fonts.check(font, sample))
|
|
3858
|
+
return;
|
|
3859
|
+
} catch {} finally {
|
|
3860
|
+
checkingFonts.delete(key);
|
|
3861
|
+
}
|
|
3862
|
+
reportFontFailure(face, element, key);
|
|
3863
|
+
};
|
|
3805
3864
|
const sweepFonts = () => {
|
|
3806
3865
|
document.fonts.forEach((face) => {
|
|
3807
|
-
if (face.status
|
|
3808
|
-
|
|
3809
|
-
reportedFonts.add(face.family);
|
|
3810
|
-
emitSignal(`Font failure — ${face.family} failed to load — ${shortUrl(location.href)}`, { fontFamily: face.family, signal: BEACON_SIGNAL.FONT_FAILURE });
|
|
3866
|
+
if (face.status === "error")
|
|
3867
|
+
verifyFontFailure(face);
|
|
3811
3868
|
});
|
|
3812
3869
|
};
|
|
3813
3870
|
const fontsReady = document.fonts.ready;
|
|
@@ -3817,8 +3874,9 @@ var createBeacon = (options) => {
|
|
|
3817
3874
|
});
|
|
3818
3875
|
}
|
|
3819
3876
|
if (typeof document.fonts.addEventListener === "function") {
|
|
3820
|
-
|
|
3821
|
-
|
|
3877
|
+
const handleLoadingError = () => sweepFonts();
|
|
3878
|
+
document.fonts.addEventListener("loadingerror", handleLoadingError);
|
|
3879
|
+
cleanups.push(() => document.fonts.removeEventListener("loadingerror", handleLoadingError));
|
|
3822
3880
|
}
|
|
3823
3881
|
}
|
|
3824
3882
|
if (signals !== null && signals.requestStorms !== false) {
|
|
@@ -4081,5 +4139,5 @@ export {
|
|
|
4081
4139
|
BEACON_ATTRIBUTE
|
|
4082
4140
|
};
|
|
4083
4141
|
|
|
4084
|
-
//# debugId=
|
|
4142
|
+
//# debugId=F7889DDF767C94DD64756E2164756E21
|
|
4085
4143
|
//# sourceMappingURL=index.js.map
|