accessibility-plugin-react 2.28.0 → 2.29.0
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/NOTICE +24 -0
- package/README.md +6 -0
- package/dist/index.d.mts +36 -2
- package/dist/index.d.ts +36 -2
- package/dist/index.js +338 -128
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +334 -128
- package/dist/index.mjs.map +1 -1
- package/docs/API.md +21 -3
- package/docs/BUILD_AND_RELEASE_PLAN.md +6 -6
- package/docs/FEATURES.md +10 -0
- package/docs/LARGE_DOCUMENT_PROFILING.md +120 -0
- package/docs/PERFORMANCE_PROFILING.md +107 -0
- package/docs/PROJECT_STATUS.md +27 -18
- package/docs/PUBLISH_REHEARSAL.md +72 -0
- package/docs/RELEASE_PROPOSAL_M5.md +100 -0
- package/docs/ROADMAP.md +31 -25
- package/docs/SCOPED_EFFECTS.md +129 -0
- package/docs/SECURITY_AUDIT.md +83 -0
- package/docs/SUPPORTED_MATRIX.md +150 -0
- package/docs/TROUBLESHOOTING.md +21 -21
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -75,6 +75,7 @@ __export(index_exports, {
|
|
|
75
75
|
LetterSpacingController: () => LetterSpacingController,
|
|
76
76
|
LineHeightController: () => LineHeightController,
|
|
77
77
|
LinkHighlightController: () => LinkHighlightController,
|
|
78
|
+
MAX_HOST_ELEMENTS: () => MAX_HOST_ELEMENTS,
|
|
78
79
|
MAX_NODES_PER_TRANSLATION_BATCH: () => MAX_NODES_PER_TRANSLATION_BATCH,
|
|
79
80
|
MAX_READING_MASK_HEIGHT: () => MAX_READING_MASK_HEIGHT,
|
|
80
81
|
MAX_TEXT_LENGTH_PER_NODE: () => MAX_TEXT_LENGTH_PER_NODE,
|
|
@@ -123,6 +124,8 @@ __export(index_exports, {
|
|
|
123
124
|
VoiceNavigationController: () => VoiceNavigationController,
|
|
124
125
|
WordSpacingController: () => WordSpacingController,
|
|
125
126
|
applyCustomPresetToStore: () => applyCustomPresetToStore,
|
|
127
|
+
applyPage: () => applyPage,
|
|
128
|
+
applyPageSession: () => applyPageSession,
|
|
126
129
|
applyProfileToStore: () => applyProfileToStore,
|
|
127
130
|
applySmartContrast: () => applySmartContrast,
|
|
128
131
|
applyTranslations: () => applyTranslations,
|
|
@@ -195,6 +198,7 @@ __export(index_exports, {
|
|
|
195
198
|
recordProfileOverride: () => recordProfileOverride,
|
|
196
199
|
registerLocale: () => registerLocale,
|
|
197
200
|
resolveActiveShortcut: () => resolveActiveShortcut,
|
|
201
|
+
resolveEffectScope: () => resolveEffectScope,
|
|
198
202
|
resolveEffectiveBackdrop: () => resolveEffectiveBackdrop,
|
|
199
203
|
resolveEffectivePreferences: () => resolveEffectivePreferences,
|
|
200
204
|
resolveLocaleStrings: () => resolveLocaleStrings,
|
|
@@ -1053,7 +1057,7 @@ function applySmartContrast(options = {}) {
|
|
|
1053
1057
|
|
|
1054
1058
|
// src/core/effects.ts
|
|
1055
1059
|
var EXCLUDED = "[data-arap-ui], [data-arap-ui] *, script, style, link, meta, noscript, template";
|
|
1056
|
-
var MAX_HOST_ELEMENTS =
|
|
1060
|
+
var MAX_HOST_ELEMENTS = 8e3;
|
|
1057
1061
|
var cursor = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M4 2v32l9-9 7 13 6-3-7-12h14z' fill='black' stroke='white' stroke-width='2'/%3E%3C/svg%3E") 4 2, auto`;
|
|
1058
1062
|
function isForcedColorsActive() {
|
|
1059
1063
|
if (typeof window === "undefined" || !window.matchMedia) return false;
|
|
@@ -1633,24 +1637,35 @@ function isEligibleDecorativeImage(el) {
|
|
|
1633
1637
|
}
|
|
1634
1638
|
return false;
|
|
1635
1639
|
}
|
|
1636
|
-
function
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
return;
|
|
1646
|
-
if (previous) element.style.setProperty(property, previous, priority);
|
|
1647
|
-
else element.style.removeProperty(property);
|
|
1648
|
-
});
|
|
1640
|
+
function resolveEffectScope(scope) {
|
|
1641
|
+
if (typeof document === "undefined") return null;
|
|
1642
|
+
if (!scope) return document.body ?? null;
|
|
1643
|
+
if (typeof scope === "string") {
|
|
1644
|
+
try {
|
|
1645
|
+
return document.querySelector(scope) ?? document.body ?? null;
|
|
1646
|
+
} catch {
|
|
1647
|
+
return document.body ?? null;
|
|
1648
|
+
}
|
|
1649
1649
|
}
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1650
|
+
if (typeof scope === "object") {
|
|
1651
|
+
if ("nodeType" in scope && scope.nodeType === 1) {
|
|
1652
|
+
return scope;
|
|
1653
|
+
}
|
|
1654
|
+
if ("current" in scope) {
|
|
1655
|
+
return scope.current ?? document.body ?? null;
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
return document.body ?? null;
|
|
1659
|
+
}
|
|
1660
|
+
function applyToElements(elements, values, undo, styledElements, isFinePointer, set) {
|
|
1661
|
+
const targetElements = [];
|
|
1662
|
+
for (const el of elements) {
|
|
1663
|
+
if (!styledElements.has(el)) {
|
|
1664
|
+
styledElements.add(el);
|
|
1665
|
+
targetElements.push(el);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
if (targetElements.length === 0) return;
|
|
1654
1669
|
const fontScaleValue = typeof values.fontScale === "number" && values.fontScale !== 1 ? values.fontScale : typeof values.textScale === "number" && values.textScale !== 1 ? values.textScale : void 0;
|
|
1655
1670
|
const fontSizeScale = typeof values.fontSize === "number" && values.fontSize !== 100 ? values.fontSize / 100 : void 0;
|
|
1656
1671
|
const font = fontScaleValue ?? fontSizeScale ?? 1;
|
|
@@ -1659,7 +1674,7 @@ function applyPage(values) {
|
|
|
1659
1674
|
const fontActive = font !== 1;
|
|
1660
1675
|
const lineActive = lineRatio !== 1;
|
|
1661
1676
|
if (fontActive || lineActive) {
|
|
1662
|
-
const measurements =
|
|
1677
|
+
const measurements = targetElements.filter(
|
|
1663
1678
|
(el) => !isProtectedFromTextScale(el) || !isProtectedFromTextSpacing(el)
|
|
1664
1679
|
).map((el) => {
|
|
1665
1680
|
const computed = getComputedStyle(el);
|
|
@@ -1695,26 +1710,10 @@ function applyPage(values) {
|
|
|
1695
1710
|
}
|
|
1696
1711
|
}
|
|
1697
1712
|
}
|
|
1698
|
-
const filter = composeFilter(values);
|
|
1699
|
-
for (const el of Array.from(document.body.children)) {
|
|
1700
|
-
if (!(el instanceof HTMLElement) || el.matches(EXCLUDED) || !filter)
|
|
1701
|
-
continue;
|
|
1702
|
-
const computed = getComputedStyle(el);
|
|
1703
|
-
if (computed.backgroundColor === "rgba(0, 0, 0, 0)" || computed.backgroundColor === "transparent") {
|
|
1704
|
-
const bodyColor = getComputedStyle(document.body).backgroundColor;
|
|
1705
|
-
set(
|
|
1706
|
-
el,
|
|
1707
|
-
"background-color",
|
|
1708
|
-
bodyColor && bodyColor !== "rgba(0, 0, 0, 0)" && bodyColor !== "transparent" ? bodyColor : "#ffffff"
|
|
1709
|
-
);
|
|
1710
|
-
}
|
|
1711
|
-
const base = computed.filter;
|
|
1712
|
-
set(el, "filter", `${base && base !== "none" ? base + " " : ""}${filter}`);
|
|
1713
|
-
}
|
|
1714
1713
|
const letterSpacingVal = typeof values.letterSpacing === "number" && values.letterSpacing > 0 ? values.letterSpacing : 0;
|
|
1715
1714
|
const letterSpacingEmVal = typeof values.letterSpacingEm === "number" && values.letterSpacingEm > 0 ? values.letterSpacingEm : null;
|
|
1716
1715
|
if (letterSpacingVal > 0 || letterSpacingEmVal !== null) {
|
|
1717
|
-
for (const el of
|
|
1716
|
+
for (const el of targetElements) {
|
|
1718
1717
|
if (isProtectedFromTextSpacing(el)) {
|
|
1719
1718
|
if (el.matches(
|
|
1720
1719
|
"table, [role='table'], td, th, pre, code, kbd, samp, var, button, input, select, textarea, [data-arap-ui]"
|
|
@@ -1751,7 +1750,7 @@ function applyPage(values) {
|
|
|
1751
1750
|
const wordSpacingVal = typeof values.wordSpacing === "number" && values.wordSpacing > 0 ? values.wordSpacing : 0;
|
|
1752
1751
|
const wordSpacingEmVal = typeof values.wordSpacingEm === "number" && values.wordSpacingEm > 0 ? values.wordSpacingEm : null;
|
|
1753
1752
|
if (wordSpacingVal > 0 || wordSpacingEmVal !== null) {
|
|
1754
|
-
for (const el of
|
|
1753
|
+
for (const el of targetElements) {
|
|
1755
1754
|
if (isProtectedFromTextSpacing(el)) {
|
|
1756
1755
|
if (el.matches(
|
|
1757
1756
|
"table, [role='table'], td, th, pre, code, kbd, samp, var, button, input, select, textarea, [data-arap-ui]"
|
|
@@ -1770,7 +1769,7 @@ function applyPage(values) {
|
|
|
1770
1769
|
const paragraphSpacingVal = typeof values.paragraphSpacing === "number" && values.paragraphSpacing > 0 ? values.paragraphSpacing : 0;
|
|
1771
1770
|
const paragraphSpacingEmVal = typeof values.paragraphSpacingEm === "number" && values.paragraphSpacingEm > 0 ? values.paragraphSpacingEm : null;
|
|
1772
1771
|
if (paragraphSpacingVal > 0 || paragraphSpacingEmVal !== null) {
|
|
1773
|
-
for (const el of
|
|
1772
|
+
for (const el of targetElements) {
|
|
1774
1773
|
if (isProtectedFromTextSpacing(el)) continue;
|
|
1775
1774
|
if (el.matches("p, [role='paragraph']")) {
|
|
1776
1775
|
const computed = getComputedStyle(el);
|
|
@@ -1782,7 +1781,7 @@ function applyPage(values) {
|
|
|
1782
1781
|
}
|
|
1783
1782
|
const textAlignVal = values.textAlign ? String(values.textAlign) : "default";
|
|
1784
1783
|
if (textAlignVal !== "default" && textAlignVal !== "original") {
|
|
1785
|
-
for (const el of
|
|
1784
|
+
for (const el of targetElements) {
|
|
1786
1785
|
if (isProtectedFromTextAlign(el)) continue;
|
|
1787
1786
|
if (el.matches(TEXT_ALIGN_BLOCK_SELECTOR)) {
|
|
1788
1787
|
set(el, "text-align", textAlignVal);
|
|
@@ -1792,7 +1791,7 @@ function applyPage(values) {
|
|
|
1792
1791
|
const fontFamilyVal = values.fontFamily ? String(values.fontFamily) : "default";
|
|
1793
1792
|
if (fontFamilyVal !== "default" && fontFamilyVal !== "original") {
|
|
1794
1793
|
const targetStack = fontFamilyVal === "dyslexia-option" || fontFamilyVal === "dyslexia" ? DYSLEXIA_FONT_STACK : LEGIBLE_FONT_STACK;
|
|
1795
|
-
for (const el of
|
|
1794
|
+
for (const el of targetElements) {
|
|
1796
1795
|
if (isProtectedFromFontFamily(el)) {
|
|
1797
1796
|
if (el.matches("pre, code, kbd, samp, var")) {
|
|
1798
1797
|
const previous = el.style.getPropertyValue("font-family");
|
|
@@ -1811,19 +1810,16 @@ function applyPage(values) {
|
|
|
1811
1810
|
}
|
|
1812
1811
|
const isInvert = Boolean(values.invertColors) || values.contrast === "invert" || values.contrastMode === "invert";
|
|
1813
1812
|
if (isInvert && !isForcedColorsActive()) {
|
|
1814
|
-
const
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
).filter((el) => !el.closest("[data-arap-ui]"));
|
|
1819
|
-
for (const mediaEl of mediaElements) {
|
|
1820
|
-
set(mediaEl, "filter", "invert(1)");
|
|
1813
|
+
for (const el of targetElements) {
|
|
1814
|
+
if (el.matches("img, video, canvas, picture, [role='img']") && !el.closest("[data-arap-ui]")) {
|
|
1815
|
+
set(el, "filter", "invert(1)");
|
|
1816
|
+
}
|
|
1821
1817
|
}
|
|
1822
1818
|
}
|
|
1823
1819
|
const activeContrastKey = values.contrastMode && values.contrastMode !== "off" && values.contrastMode !== "original" ? String(values.contrastMode) : values.contrast !== void 0 && values.contrast !== 0 && values.contrast !== "0" && values.contrast !== "off" && values.contrast !== "original" ? String(values.contrast) : null;
|
|
1824
1820
|
const activePalette = activeContrastKey && !isForcedColorsActive() ? CONTRAST_PALETTES[activeContrastKey] : null;
|
|
1825
1821
|
if (activePalette) {
|
|
1826
|
-
for (const el of
|
|
1822
|
+
for (const el of targetElements) {
|
|
1827
1823
|
if (isProtectedFromContrast(el)) continue;
|
|
1828
1824
|
set(el, "color", activePalette.text);
|
|
1829
1825
|
if (el.matches("a[href]") && activePalette.link) {
|
|
@@ -1841,6 +1837,116 @@ function applyPage(values) {
|
|
|
1841
1837
|
}
|
|
1842
1838
|
}
|
|
1843
1839
|
}
|
|
1840
|
+
for (const el of targetElements) {
|
|
1841
|
+
if (values.bigCursor && isFinePointer) set(el, "cursor", cursor);
|
|
1842
|
+
if (values.hideImages) {
|
|
1843
|
+
if (isEligibleDecorativeImage(el)) {
|
|
1844
|
+
set(el, "visibility", "hidden");
|
|
1845
|
+
}
|
|
1846
|
+
if (!isFunctionalOrMeaningfulImage(el)) {
|
|
1847
|
+
const inlineBg = el.style.backgroundImage;
|
|
1848
|
+
if (inlineBg && inlineBg !== "none") {
|
|
1849
|
+
set(el, "background-image", "none");
|
|
1850
|
+
} else {
|
|
1851
|
+
try {
|
|
1852
|
+
const computedBg = getComputedStyle(el).backgroundImage;
|
|
1853
|
+
if (computedBg && computedBg !== "none") {
|
|
1854
|
+
set(el, "background-image", "none");
|
|
1855
|
+
}
|
|
1856
|
+
} catch {
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
if (values.hideVideos && el.matches(
|
|
1862
|
+
'video, iframe[src*="youtube.com/embed/"], iframe[src*="youtube-nocookie.com/embed/"], iframe[src*="player.vimeo.com/video/"]'
|
|
1863
|
+
))
|
|
1864
|
+
set(el, "visibility", "hidden");
|
|
1865
|
+
const colors = palette[String(values.contrast)];
|
|
1866
|
+
if (colors && !activePalette && !isForcedColorsActive()) {
|
|
1867
|
+
set(el, "color", colors[0]);
|
|
1868
|
+
set(el, "background-color", colors[1]);
|
|
1869
|
+
}
|
|
1870
|
+
if (values.linkHighlight && el.matches("a[href]") && !el.closest("[data-arap-ui]")) {
|
|
1871
|
+
const isDisabled = el.getAttribute("aria-disabled") === "true" || el.hasAttribute("disabled") || el.classList.contains("disabled");
|
|
1872
|
+
if (!isDisabled) {
|
|
1873
|
+
if (isForcedColorsActive()) {
|
|
1874
|
+
set(el, "color", "LinkText");
|
|
1875
|
+
set(el, "text-decoration", "underline");
|
|
1876
|
+
set(el, "text-decoration-thickness", "2px");
|
|
1877
|
+
set(el, "text-underline-offset", "3px");
|
|
1878
|
+
} else {
|
|
1879
|
+
const colors2 = palette[String(values.linkHighlight)] ?? [
|
|
1880
|
+
"#111827",
|
|
1881
|
+
"#fef08a"
|
|
1882
|
+
];
|
|
1883
|
+
set(el, "color", colors2[0]);
|
|
1884
|
+
set(el, "background-color", colors2[1]);
|
|
1885
|
+
set(el, "text-decoration", "underline");
|
|
1886
|
+
set(el, "text-decoration-thickness", "2px");
|
|
1887
|
+
set(el, "text-underline-offset", "3px");
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
function applyPageSession(values, optionsOrScope) {
|
|
1894
|
+
let effectScope = void 0;
|
|
1895
|
+
let nonce = void 0;
|
|
1896
|
+
if (optionsOrScope && typeof optionsOrScope === "object") {
|
|
1897
|
+
if ("nodeType" in optionsOrScope) {
|
|
1898
|
+
effectScope = optionsOrScope;
|
|
1899
|
+
} else if ("current" in optionsOrScope && !("effectScope" in optionsOrScope)) {
|
|
1900
|
+
effectScope = optionsOrScope;
|
|
1901
|
+
} else {
|
|
1902
|
+
const opts = optionsOrScope;
|
|
1903
|
+
effectScope = opts.effectScope;
|
|
1904
|
+
nonce = opts.nonce;
|
|
1905
|
+
}
|
|
1906
|
+
} else if (typeof optionsOrScope === "string") {
|
|
1907
|
+
effectScope = optionsOrScope;
|
|
1908
|
+
}
|
|
1909
|
+
const targetRoot = resolveEffectScope(effectScope);
|
|
1910
|
+
const undo = [];
|
|
1911
|
+
const styledElements = /* @__PURE__ */ new WeakSet();
|
|
1912
|
+
let totalStyled = 0;
|
|
1913
|
+
const isFinePointer = hasFinePointer();
|
|
1914
|
+
function set(element, property, value) {
|
|
1915
|
+
const previous = element.style.getPropertyValue(property);
|
|
1916
|
+
const priority = element.style.getPropertyPriority(property);
|
|
1917
|
+
element.style.setProperty(property, value, "important");
|
|
1918
|
+
const applied = element.style.getPropertyValue(property);
|
|
1919
|
+
undo.push(() => {
|
|
1920
|
+
if (element.style.getPropertyValue(property) !== applied || element.style.getPropertyPriority(property) !== "important")
|
|
1921
|
+
return;
|
|
1922
|
+
if (previous) element.style.setProperty(property, previous, priority);
|
|
1923
|
+
else element.style.removeProperty(property);
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1926
|
+
const filter = composeFilter(values);
|
|
1927
|
+
function applyContainerFilter(el) {
|
|
1928
|
+
if (el.matches(EXCLUDED) || !filter) return;
|
|
1929
|
+
const computed = getComputedStyle(el);
|
|
1930
|
+
if (computed.backgroundColor === "rgba(0, 0, 0, 0)" || computed.backgroundColor === "transparent") {
|
|
1931
|
+
const bodyColor = typeof document !== "undefined" && document.body ? getComputedStyle(document.body).backgroundColor : "#ffffff";
|
|
1932
|
+
set(
|
|
1933
|
+
el,
|
|
1934
|
+
"background-color",
|
|
1935
|
+
bodyColor && bodyColor !== "rgba(0, 0, 0, 0)" && bodyColor !== "transparent" ? bodyColor : "#ffffff"
|
|
1936
|
+
);
|
|
1937
|
+
}
|
|
1938
|
+
const base = computed.filter;
|
|
1939
|
+
set(el, "filter", `${base && base !== "none" ? base + " " : ""}${filter}`);
|
|
1940
|
+
}
|
|
1941
|
+
if (filter && targetRoot) {
|
|
1942
|
+
if (targetRoot === (typeof document !== "undefined" ? document.body : null)) {
|
|
1943
|
+
for (const el of Array.from(document.body.children)) {
|
|
1944
|
+
if (el instanceof HTMLElement) applyContainerFilter(el);
|
|
1945
|
+
}
|
|
1946
|
+
} else {
|
|
1947
|
+
applyContainerFilter(targetRoot);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1844
1950
|
const smartContrastVal = values.smartContrast;
|
|
1845
1951
|
if ((smartContrastVal === true || smartContrastVal === "aa" || smartContrastVal === "aaa") && !isForcedColorsActive()) {
|
|
1846
1952
|
const targetLevel = smartContrastVal === "aaa" ? "aaa" : "aa";
|
|
@@ -1856,6 +1962,10 @@ function applyPage(values) {
|
|
|
1856
1962
|
styleEl = document.createElement("style");
|
|
1857
1963
|
styleEl.id = FOCUS_STYLE_ID;
|
|
1858
1964
|
styleEl.dataset.arapUi = "";
|
|
1965
|
+
if (nonce) {
|
|
1966
|
+
styleEl.nonce = nonce;
|
|
1967
|
+
styleEl.setAttribute("nonce", nonce);
|
|
1968
|
+
}
|
|
1859
1969
|
styleEl.textContent = `
|
|
1860
1970
|
*:not([data-arap-ui]):not([data-arap-ui] *):focus-visible {
|
|
1861
1971
|
outline: 3px solid #2563eb !important;
|
|
@@ -1890,6 +2000,10 @@ function applyPage(values) {
|
|
|
1890
2000
|
styleEl = document.createElement("style");
|
|
1891
2001
|
styleEl.id = MOTION_STYLE_ID;
|
|
1892
2002
|
styleEl.dataset.arapUi = "";
|
|
2003
|
+
if (nonce) {
|
|
2004
|
+
styleEl.nonce = nonce;
|
|
2005
|
+
styleEl.setAttribute("nonce", nonce);
|
|
2006
|
+
}
|
|
1893
2007
|
styleEl.textContent = `
|
|
1894
2008
|
*:not([data-arap-ui]):not([data-arap-ui] *),
|
|
1895
2009
|
*:not([data-arap-ui]):not([data-arap-ui] *)::before,
|
|
@@ -1946,66 +2060,84 @@ function applyPage(values) {
|
|
|
1946
2060
|
}
|
|
1947
2061
|
});
|
|
1948
2062
|
}
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
if (
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
2063
|
+
if (values.bigCursor && isFinePointer && typeof document !== "undefined" && targetRoot) {
|
|
2064
|
+
set(targetRoot, "cursor", cursor);
|
|
2065
|
+
}
|
|
2066
|
+
if (typeof document !== "undefined" && targetRoot) {
|
|
2067
|
+
const allElements = [];
|
|
2068
|
+
if (targetRoot !== document.body && !targetRoot.matches(EXCLUDED)) {
|
|
2069
|
+
allElements.push(targetRoot);
|
|
2070
|
+
}
|
|
2071
|
+
const descendants = Array.from(
|
|
2072
|
+
targetRoot.querySelectorAll("*")
|
|
2073
|
+
).filter((el) => el instanceof HTMLElement && !el.matches(EXCLUDED));
|
|
2074
|
+
allElements.push(...descendants);
|
|
2075
|
+
for (const el of descendants) {
|
|
2076
|
+
if (allElements.length >= MAX_HOST_ELEMENTS) break;
|
|
2077
|
+
if (el.shadowRoot && el.shadowRoot.mode === "open") {
|
|
2078
|
+
const shadowDescendants = Array.from(
|
|
2079
|
+
el.shadowRoot.querySelectorAll("*")
|
|
2080
|
+
).filter((s) => s instanceof HTMLElement && !s.matches(EXCLUDED));
|
|
2081
|
+
allElements.push(...shadowDescendants);
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
const elements = allElements.length > MAX_HOST_ELEMENTS ? allElements.slice(0, MAX_HOST_ELEMENTS) : allElements;
|
|
2085
|
+
totalStyled = elements.length;
|
|
2086
|
+
applyToElements(elements, values, undo, styledElements, isFinePointer, set);
|
|
2087
|
+
}
|
|
2088
|
+
function applyIncremental(addedNodes) {
|
|
2089
|
+
if (typeof document === "undefined" || !targetRoot) return;
|
|
2090
|
+
const candidateElements = [];
|
|
2091
|
+
for (const root of addedNodes) {
|
|
2092
|
+
if (root.matches(EXCLUDED)) continue;
|
|
2093
|
+
if (targetRoot !== document.body && !targetRoot.contains(root) && root !== targetRoot) {
|
|
2094
|
+
continue;
|
|
1958
2095
|
}
|
|
1959
|
-
if (
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
2096
|
+
if (filter && (targetRoot === document.body ? root.parentElement === document.body : root === targetRoot || root.parentElement === targetRoot)) {
|
|
2097
|
+
applyContainerFilter(root);
|
|
2098
|
+
}
|
|
2099
|
+
candidateElements.push(root);
|
|
2100
|
+
const descendants = Array.from(
|
|
2101
|
+
root.querySelectorAll("*")
|
|
2102
|
+
).filter((el) => el instanceof HTMLElement && !el.matches(EXCLUDED));
|
|
2103
|
+
candidateElements.push(...descendants);
|
|
2104
|
+
for (const el of descendants) {
|
|
2105
|
+
if (el.shadowRoot && el.shadowRoot.mode === "open") {
|
|
2106
|
+
const shadowDescendants = Array.from(
|
|
2107
|
+
el.shadowRoot.querySelectorAll("*")
|
|
2108
|
+
).filter((s) => s instanceof HTMLElement && !s.matches(EXCLUDED));
|
|
2109
|
+
candidateElements.push(...shadowDescendants);
|
|
1971
2110
|
}
|
|
1972
2111
|
}
|
|
1973
2112
|
}
|
|
1974
|
-
if (
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
set(el, "color", "LinkText");
|
|
1988
|
-
set(el, "text-decoration", "underline");
|
|
1989
|
-
set(el, "text-decoration-thickness", "2px");
|
|
1990
|
-
set(el, "text-underline-offset", "3px");
|
|
1991
|
-
} else {
|
|
1992
|
-
const colors2 = palette[String(values.linkHighlight)] ?? [
|
|
1993
|
-
"#111827",
|
|
1994
|
-
"#fef08a"
|
|
1995
|
-
];
|
|
1996
|
-
set(el, "color", colors2[0]);
|
|
1997
|
-
set(el, "background-color", colors2[1]);
|
|
1998
|
-
set(el, "text-decoration", "underline");
|
|
1999
|
-
set(el, "text-decoration-thickness", "2px");
|
|
2000
|
-
set(el, "text-underline-offset", "3px");
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2113
|
+
if (candidateElements.length > 0) {
|
|
2114
|
+
const remainingQuota = MAX_HOST_ELEMENTS - totalStyled;
|
|
2115
|
+
if (remainingQuota <= 0) return;
|
|
2116
|
+
const elementsToStyle = candidateElements.length > remainingQuota ? candidateElements.slice(0, remainingQuota) : candidateElements;
|
|
2117
|
+
totalStyled += elementsToStyle.length;
|
|
2118
|
+
applyToElements(
|
|
2119
|
+
elementsToStyle,
|
|
2120
|
+
values,
|
|
2121
|
+
undo,
|
|
2122
|
+
styledElements,
|
|
2123
|
+
isFinePointer,
|
|
2124
|
+
set
|
|
2125
|
+
);
|
|
2003
2126
|
}
|
|
2004
2127
|
}
|
|
2005
|
-
return
|
|
2006
|
-
|
|
2128
|
+
return {
|
|
2129
|
+
undo: () => {
|
|
2130
|
+
for (const restore of undo.reverse()) restore();
|
|
2131
|
+
},
|
|
2132
|
+
applyIncremental,
|
|
2133
|
+
styledCount: () => totalStyled,
|
|
2134
|
+
targetRoot
|
|
2007
2135
|
};
|
|
2008
2136
|
}
|
|
2137
|
+
function applyPage(values, optionsOrScope) {
|
|
2138
|
+
const session = applyPageSession(values, optionsOrScope);
|
|
2139
|
+
return session.undo;
|
|
2140
|
+
}
|
|
2009
2141
|
function nudgeReadingAid(feature, delta) {
|
|
2010
2142
|
if (typeof document !== "undefined") {
|
|
2011
2143
|
try {
|
|
@@ -2135,45 +2267,113 @@ function readingAid(mask, height = 100, onDisable) {
|
|
|
2135
2267
|
el.remove();
|
|
2136
2268
|
};
|
|
2137
2269
|
}
|
|
2138
|
-
function useBuiltinEffects(values, onDisable) {
|
|
2270
|
+
function useBuiltinEffects(values, onDisable, optionsOrScope) {
|
|
2139
2271
|
(0, import_react3.useEffect)(() => {
|
|
2140
2272
|
if (!Object.entries(values).some(
|
|
2141
2273
|
([key, value]) => key in builtins && value !== builtins[key].defaultValue
|
|
2142
2274
|
))
|
|
2143
2275
|
return;
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2276
|
+
const targetRoot = resolveEffectScope(
|
|
2277
|
+
optionsOrScope && typeof optionsOrScope === "object" && "effectScope" in optionsOrScope ? optionsOrScope.effectScope : optionsOrScope
|
|
2278
|
+
);
|
|
2279
|
+
let activeSession = applyPageSession(values, optionsOrScope);
|
|
2280
|
+
let refreshTimer = null;
|
|
2281
|
+
let incrementalTimer = null;
|
|
2282
|
+
let pendingAddedNodes = [];
|
|
2283
|
+
const flushIncremental = () => {
|
|
2284
|
+
if (pendingAddedNodes.length === 0) return;
|
|
2285
|
+
const nodes = pendingAddedNodes;
|
|
2286
|
+
pendingAddedNodes = [];
|
|
2287
|
+
activeSession.applyIncremental(nodes);
|
|
2288
|
+
};
|
|
2289
|
+
const scheduleFullRefresh = (delay = 25) => {
|
|
2290
|
+
if (refreshTimer) clearTimeout(refreshTimer);
|
|
2291
|
+
refreshTimer = setTimeout(() => {
|
|
2292
|
+
activeSession.undo();
|
|
2293
|
+
activeSession = applyPageSession(values, optionsOrScope);
|
|
2294
|
+
}, delay);
|
|
2295
|
+
};
|
|
2147
2296
|
const observer = new MutationObserver((records) => {
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
)
|
|
2152
|
-
|
|
2297
|
+
let hasRootAttributeChange = false;
|
|
2298
|
+
const added = [];
|
|
2299
|
+
for (const record of records) {
|
|
2300
|
+
if (record.type === "attributes") {
|
|
2301
|
+
if (record.target === document.documentElement || record.target === document.body || record.target === targetRoot) {
|
|
2302
|
+
hasRootAttributeChange = true;
|
|
2303
|
+
}
|
|
2304
|
+
} else if (record.type === "childList") {
|
|
2305
|
+
if (record.target instanceof Element && record.target.closest("[data-arap-ui]")) {
|
|
2306
|
+
continue;
|
|
2307
|
+
}
|
|
2308
|
+
for (const node of record.addedNodes) {
|
|
2309
|
+
if (node instanceof HTMLElement && !node.matches("[data-arap-ui]")) {
|
|
2310
|
+
added.push(node);
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
if (hasRootAttributeChange) {
|
|
2316
|
+
scheduleFullRefresh(25);
|
|
2153
2317
|
return;
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2318
|
+
}
|
|
2319
|
+
if (added.length > 0) {
|
|
2320
|
+
pendingAddedNodes.push(...added);
|
|
2321
|
+
if (incrementalTimer) clearTimeout(incrementalTimer);
|
|
2322
|
+
incrementalTimer = setTimeout(flushIncremental, 16);
|
|
2323
|
+
}
|
|
2159
2324
|
});
|
|
2160
|
-
|
|
2325
|
+
const observerOptions = {
|
|
2326
|
+
childList: true,
|
|
2327
|
+
subtree: true,
|
|
2328
|
+
attributes: true,
|
|
2329
|
+
attributeFilter: ["class", "data-theme", "dir", "lang"]
|
|
2330
|
+
};
|
|
2331
|
+
if (targetRoot) {
|
|
2332
|
+
observer.observe(targetRoot, observerOptions);
|
|
2333
|
+
}
|
|
2334
|
+
if (typeof document !== "undefined" && document.body && targetRoot !== document.body) {
|
|
2335
|
+
observer.observe(document.body, {
|
|
2336
|
+
attributes: true,
|
|
2337
|
+
attributeFilter: ["class", "data-theme", "dir", "lang"]
|
|
2338
|
+
});
|
|
2339
|
+
}
|
|
2340
|
+
if (typeof document !== "undefined" && document.documentElement) {
|
|
2341
|
+
observer.observe(document.documentElement, {
|
|
2342
|
+
attributes: true,
|
|
2343
|
+
attributeFilter: ["class", "data-theme", "dir", "lang"]
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
const fontCleanups = [];
|
|
2347
|
+
if (typeof document !== "undefined" && "fonts" in document && document.fonts) {
|
|
2348
|
+
const fonts = document.fonts;
|
|
2349
|
+
const handleFontLoad = () => {
|
|
2350
|
+
scheduleFullRefresh(50);
|
|
2351
|
+
};
|
|
2352
|
+
if (fonts.status === "loading") {
|
|
2353
|
+
fonts.ready.then(handleFontLoad).catch(() => {
|
|
2354
|
+
});
|
|
2355
|
+
}
|
|
2356
|
+
try {
|
|
2357
|
+
fonts.addEventListener("loadingdone", handleFontLoad);
|
|
2358
|
+
fontCleanups.push(() => {
|
|
2359
|
+
fonts.removeEventListener("loadingdone", handleFontLoad);
|
|
2360
|
+
});
|
|
2361
|
+
} catch {
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2161
2364
|
const resize = () => {
|
|
2162
|
-
|
|
2163
|
-
resizeTimer = setTimeout(() => {
|
|
2164
|
-
undo();
|
|
2165
|
-
undo = applyPage(values);
|
|
2166
|
-
}, 50);
|
|
2365
|
+
scheduleFullRefresh(50);
|
|
2167
2366
|
};
|
|
2168
2367
|
window.addEventListener("resize", resize);
|
|
2169
2368
|
return () => {
|
|
2170
|
-
if (
|
|
2171
|
-
if (
|
|
2369
|
+
if (refreshTimer) clearTimeout(refreshTimer);
|
|
2370
|
+
if (incrementalTimer) clearTimeout(incrementalTimer);
|
|
2172
2371
|
observer.disconnect();
|
|
2372
|
+
for (const cleanup of fontCleanups) cleanup();
|
|
2173
2373
|
window.removeEventListener("resize", resize);
|
|
2174
|
-
undo();
|
|
2374
|
+
activeSession.undo();
|
|
2175
2375
|
};
|
|
2176
|
-
}, [values]);
|
|
2376
|
+
}, [values, optionsOrScope]);
|
|
2177
2377
|
(0, import_react3.useEffect)(() => {
|
|
2178
2378
|
if (!values.readingMask) return;
|
|
2179
2379
|
const height = typeof values.readingMaskHeight === "number" ? values.readingMaskHeight : typeof values.readingMask === "number" ? values.readingMask : 100;
|
|
@@ -3026,7 +3226,9 @@ function AccessibilityPlugin({
|
|
|
3026
3226
|
statementUrl,
|
|
3027
3227
|
largeControls,
|
|
3028
3228
|
diagnostics,
|
|
3029
|
-
onFeatureEvent
|
|
3229
|
+
onFeatureEvent,
|
|
3230
|
+
effectScope,
|
|
3231
|
+
nonce
|
|
3030
3232
|
}) {
|
|
3031
3233
|
const [isOpen, setIsOpen] = (0, import_react4.useState)(false);
|
|
3032
3234
|
const [store] = (0, import_react4.useState)(
|
|
@@ -3240,7 +3442,7 @@ function AccessibilityPlugin({
|
|
|
3240
3442
|
return () => document.removeEventListener("arap:disable-feature", handler);
|
|
3241
3443
|
}, [handleDisable]);
|
|
3242
3444
|
const effectiveLocale = locale || (typeof document !== "undefined" ? document.documentElement.lang : void 0) || void 0;
|
|
3243
|
-
useBuiltinEffects(active, handleDisable);
|
|
3445
|
+
useBuiltinEffects(active, handleDisable, { effectScope, nonce });
|
|
3244
3446
|
const value = (0, import_react4.useMemo)(
|
|
3245
3447
|
() => ({
|
|
3246
3448
|
state: { isOpen, features },
|
|
@@ -3259,7 +3461,9 @@ function AccessibilityPlugin({
|
|
|
3259
3461
|
unregisterReset,
|
|
3260
3462
|
locale: effectiveLocale,
|
|
3261
3463
|
statementUrl,
|
|
3262
|
-
largeControls
|
|
3464
|
+
largeControls,
|
|
3465
|
+
effectScope,
|
|
3466
|
+
nonce
|
|
3263
3467
|
}),
|
|
3264
3468
|
[
|
|
3265
3469
|
isOpen,
|
|
@@ -3278,7 +3482,9 @@ function AccessibilityPlugin({
|
|
|
3278
3482
|
unregisterReset,
|
|
3279
3483
|
effectiveLocale,
|
|
3280
3484
|
statementUrl,
|
|
3281
|
-
largeControls
|
|
3485
|
+
largeControls,
|
|
3486
|
+
effectScope,
|
|
3487
|
+
nonce
|
|
3282
3488
|
]
|
|
3283
3489
|
);
|
|
3284
3490
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AccessibilityContext.Provider, { value, children: [
|
|
@@ -13795,6 +14001,7 @@ function useDiagnostics(config = {}) {
|
|
|
13795
14001
|
LetterSpacingController,
|
|
13796
14002
|
LineHeightController,
|
|
13797
14003
|
LinkHighlightController,
|
|
14004
|
+
MAX_HOST_ELEMENTS,
|
|
13798
14005
|
MAX_NODES_PER_TRANSLATION_BATCH,
|
|
13799
14006
|
MAX_READING_MASK_HEIGHT,
|
|
13800
14007
|
MAX_TEXT_LENGTH_PER_NODE,
|
|
@@ -13843,6 +14050,8 @@ function useDiagnostics(config = {}) {
|
|
|
13843
14050
|
VoiceNavigationController,
|
|
13844
14051
|
WordSpacingController,
|
|
13845
14052
|
applyCustomPresetToStore,
|
|
14053
|
+
applyPage,
|
|
14054
|
+
applyPageSession,
|
|
13846
14055
|
applyProfileToStore,
|
|
13847
14056
|
applySmartContrast,
|
|
13848
14057
|
applyTranslations,
|
|
@@ -13915,6 +14124,7 @@ function useDiagnostics(config = {}) {
|
|
|
13915
14124
|
recordProfileOverride,
|
|
13916
14125
|
registerLocale,
|
|
13917
14126
|
resolveActiveShortcut,
|
|
14127
|
+
resolveEffectScope,
|
|
13918
14128
|
resolveEffectiveBackdrop,
|
|
13919
14129
|
resolveEffectivePreferences,
|
|
13920
14130
|
resolveLocaleStrings,
|