@motion-proto/live-tokens 0.97.0 → 0.99.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.
Files changed (191) hide show
  1. package/.claude/skills/live-tokens-check-compliance/SKILL.md +5 -0
  2. package/.claude/skills/live-tokens-create-component/SKILL.md +4 -3
  3. package/.claude/skills/live-tokens-create-component/references/contract-tests.md +71 -11
  4. package/CHANGELOG.md +339 -0
  5. package/README.md +2 -2
  6. package/bin/check-component.mjs +8 -0
  7. package/bin/check-page.mjs +6 -0
  8. package/bin/cli.mjs +36 -6
  9. package/bin/contractRunner.mjs +144 -19
  10. package/bin/lib/findings.mjs +20 -4
  11. package/bin/rules/a11y.mjs +53 -0
  12. package/dist-plugin/{chunk-A4TBP4MM.js → chunk-SLICH4IH.js} +2 -2
  13. package/dist-plugin/index.cjs +204 -3
  14. package/dist-plugin/index.js +306 -105
  15. package/dist-plugin/setColors/index.js +1 -1
  16. package/package.json +47 -2
  17. package/src/demo/LabeledSelect.svelte +1 -1
  18. package/src/editor/bootstrap.ts +5 -1
  19. package/src/editor/component-editor/BadgeEditor.svelte +13 -0
  20. package/src/editor/component-editor/ButtonEditor.svelte +33 -2
  21. package/src/editor/component-editor/CalloutEditor.svelte +13 -0
  22. package/src/editor/component-editor/CardEditor.svelte +12 -2
  23. package/src/editor/component-editor/CodeSnippetEditor.svelte +11 -1
  24. package/src/editor/component-editor/CollapsibleSectionEditor.svelte +18 -1
  25. package/src/editor/component-editor/CornerBadgeEditor.svelte +13 -0
  26. package/src/editor/component-editor/DialogEditor.svelte +15 -0
  27. package/src/editor/component-editor/IconButtonEditor.svelte +29 -1
  28. package/src/editor/component-editor/ImageEditor.svelte +20 -9
  29. package/src/editor/component-editor/ImageLightboxEditor.svelte +44 -0
  30. package/src/editor/component-editor/InlineEditActionsEditor.svelte +13 -1
  31. package/src/editor/component-editor/InputEditor.svelte +23 -0
  32. package/src/editor/component-editor/MenuSelectEditor.svelte +27 -1
  33. package/src/editor/component-editor/NotificationEditor.svelte +15 -0
  34. package/src/editor/component-editor/PanelEditor.svelte +1 -1
  35. package/src/editor/component-editor/ProgressBarEditor.svelte +13 -0
  36. package/src/editor/component-editor/RadioButtonEditor.svelte +20 -1
  37. package/src/editor/component-editor/SectionDividerEditor.svelte +40 -13
  38. package/src/editor/component-editor/SegmentedControlEditor.svelte +29 -1
  39. package/src/editor/component-editor/SideNavigationEditor.svelte +40 -1
  40. package/src/editor/component-editor/SlidePagerEditor.svelte +20 -0
  41. package/src/editor/component-editor/SliderEditor.svelte +33 -0
  42. package/src/editor/component-editor/TabBarEditor.svelte +23 -2
  43. package/src/editor/component-editor/TableEditor.svelte +14 -0
  44. package/src/editor/component-editor/ToggleEditor.svelte +17 -0
  45. package/src/editor/component-editor/TooltipEditor.svelte +11 -2
  46. package/src/editor/component-editor/VideoFrameEditor.svelte +8 -0
  47. package/src/editor/component-editor/VideoLightboxEditor.svelte +10 -0
  48. package/src/editor/component-editor/registration.ts +2 -1
  49. package/src/editor/component-editor/registry.ts +69 -27
  50. package/src/editor/component-editor/scaffolding/DemoHeader.svelte +2 -0
  51. package/src/editor/component-editor/scaffolding/StateBlock.svelte +19 -8
  52. package/src/editor/component-editor/scaffolding/TokenLayout.svelte +3 -0
  53. package/src/editor/component-editor/scaffolding/VariantGroup.svelte +70 -3
  54. package/src/editor/component-editor/scaffolding/editorContext.ts +7 -0
  55. package/src/editor/core/a11y/a11yReport.ts +164 -0
  56. package/src/editor/core/a11y/a11yReportTypes.ts +77 -0
  57. package/src/editor/core/a11y/contrastFailures.ts +22 -0
  58. package/src/editor/core/a11y/contrastFixes.ts +41 -0
  59. package/src/editor/core/components/contrastPairRegistry.ts +18 -0
  60. package/src/editor/core/palettes/contrast.ts +44 -0
  61. package/src/editor/core/palettes/contrastPairs.ts +82 -0
  62. package/src/editor/core/palettes/resolveColor.ts +77 -0
  63. package/src/editor/core/store/editorStore.ts +4 -0
  64. package/src/editor/core/store/editorViewStore.ts +2 -2
  65. package/src/editor/core/store/unsavedEdits.ts +10 -0
  66. package/src/editor/core/themes/liveStateStream.ts +7 -1
  67. package/src/editor/core/themes/parsers/gradient.ts +5 -2
  68. package/src/editor/docs/chapters.ts +1 -0
  69. package/src/editor/docs/content/accessibility.md +411 -0
  70. package/src/editor/docs/content/editing-tokens.md +32 -1
  71. package/src/editor/docs/content.generated.ts +2 -1
  72. package/src/editor/pages/ComponentEditorPage.svelte +11 -1
  73. package/src/editor/pages/EditorShell.svelte +98 -10
  74. package/src/editor/skill-atlas/skillSources.generated.ts +3 -3
  75. package/src/editor/skill-atlas/trees/check-compliance.ts +3 -3
  76. package/src/editor/skill-atlas/trees/create-component.ts +12 -12
  77. package/src/editor/styles/ui-editor.css +2 -0
  78. package/src/editor/ui/EditorViewSwitcher.svelte +15 -2
  79. package/src/editor/ui/GradientEditor.svelte +9 -1
  80. package/src/editor/ui/ThemePanel.svelte +4 -4
  81. package/src/editor/ui/UIContrastReadout.svelte +186 -0
  82. package/src/editor/ui/UIInfoPopover.svelte +16 -2
  83. package/src/editor/ui/UIPaletteSelector.svelte +9 -0
  84. package/src/editor/ui/UITokenSelector.svelte +26 -2
  85. package/src/editor/ui/a11y/A11yByEye.svelte +264 -0
  86. package/src/editor/ui/a11y/A11yComponentIssues.svelte +121 -0
  87. package/src/editor/ui/a11y/A11yFindingRow.svelte +119 -0
  88. package/src/editor/ui/a11y/A11yIssueRow.svelte +152 -0
  89. package/src/editor/ui/a11y/A11yOverview.svelte +246 -0
  90. package/src/editor/ui/a11y/A11yPanel.svelte +153 -0
  91. package/src/editor/ui/a11y/A11yPropertyMark.svelte +84 -0
  92. package/src/editor/ui/a11y/A11yRailMark.svelte +41 -0
  93. package/src/editor/ui/a11y/AccessibilityTab.svelte +321 -0
  94. package/src/editor/ui/a11y/a11yView.ts +257 -0
  95. package/src/editor/ui/contrastReadout.ts +45 -0
  96. package/src/live-tokens/data/colors-and-type/halloween.json +1 -1
  97. package/src/live-tokens/data/themes/autumn.json +35 -35
  98. package/src/live-tokens/data/themes/halloween.json +36 -36
  99. package/src/live-tokens/data/themes/midnight-study.json +35 -35
  100. package/src/live-tokens/data/themes/ocean.json +35 -35
  101. package/src/live-tokens/data/themes/royal-velvet.json +35 -35
  102. package/src/live-tokens/data/themes/sketchy.json +35 -35
  103. package/src/live-tokens/data/themes/spring-meadow.json +35 -35
  104. package/src/live-tokens/data/themes/sunset.json +35 -35
  105. package/src/system/components/Badge.svelte +3 -3
  106. package/src/system/components/Button.svelte +12 -6
  107. package/src/system/components/CodeSnippet.svelte +8 -1
  108. package/src/system/components/CornerBadge.svelte +3 -3
  109. package/src/system/components/Dialog.svelte +43 -14
  110. package/src/system/components/IconButton.svelte +1 -1
  111. package/src/system/components/Image.svelte +7 -0
  112. package/src/system/components/ImageLightbox.svelte +18 -25
  113. package/src/system/components/InlineEditActions.svelte +1 -1
  114. package/src/system/components/Input.svelte +9 -2
  115. package/src/system/components/MenuSelect.svelte +31 -3
  116. package/src/system/components/Notification.svelte +1 -1
  117. package/src/system/components/ProgressBar.svelte +7 -1
  118. package/src/system/components/RadioButton.svelte +36 -3
  119. package/src/system/components/SegmentedControl.svelte +36 -2
  120. package/src/system/components/SlidePager.svelte +3 -3
  121. package/src/system/components/Slider.svelte +19 -15
  122. package/src/system/components/TabBar.svelte +33 -3
  123. package/src/system/components/Toggle.svelte +3 -3
  124. package/src/system/components/VideoFrame.svelte +1 -1
  125. package/src/system/components/VideoLightbox.svelte +2 -2
  126. package/src/system/internal/focusTrap.ts +35 -0
  127. package/src/testing-js/__aria__/badge.yml +40 -0
  128. package/src/testing-js/__aria__/button.yml +88 -0
  129. package/src/testing-js/__aria__/callout.yml +12 -0
  130. package/src/testing-js/__aria__/card.yml +8 -0
  131. package/src/testing-js/__aria__/codesnippet.yml +21 -0
  132. package/src/testing-js/__aria__/collapsiblesection.yml +23 -0
  133. package/src/testing-js/__aria__/cornerbadge.yml +24 -0
  134. package/src/testing-js/__aria__/dialog.yml +42 -0
  135. package/src/testing-js/__aria__/iconbutton.yml +57 -0
  136. package/src/testing-js/__aria__/image.yml +10 -0
  137. package/src/testing-js/__aria__/imagelightbox.yml +50 -0
  138. package/src/testing-js/__aria__/inlineeditactions.yml +16 -0
  139. package/src/testing-js/__aria__/input.yml +61 -0
  140. package/src/testing-js/__aria__/menuselect.yml +30 -0
  141. package/src/testing-js/__aria__/notification.yml +30 -0
  142. package/src/testing-js/__aria__/panel.yml +2 -0
  143. package/src/testing-js/__aria__/progressbar.yml +2 -0
  144. package/src/testing-js/__aria__/radiobutton.yml +20 -0
  145. package/src/testing-js/__aria__/sectiondivider.yml +9 -0
  146. package/src/testing-js/__aria__/segmentedcontrol.yml +35 -0
  147. package/src/testing-js/__aria__/sidenavigation.yml +304 -0
  148. package/src/testing-js/__aria__/slidepager.yml +72 -0
  149. package/src/testing-js/__aria__/slider.yml +28 -0
  150. package/src/testing-js/__aria__/tabbar.yml +35 -0
  151. package/src/testing-js/__aria__/table.yml +144 -0
  152. package/src/testing-js/__aria__/toggle.yml +12 -0
  153. package/src/testing-js/__aria__/tooltip.yml +2 -0
  154. package/src/testing-js/__aria__/videoframe.yml +6 -0
  155. package/src/testing-js/__aria__/videolightbox.yml +12 -0
  156. package/src/testing-js/{chunk-WIZ6W7UT.js → chunk-3WCLMOM7.js} +2 -2
  157. package/src/testing-js/{chunk-NB3NZRBM.js → chunk-7CM5D7PF.js} +5 -1
  158. package/src/testing-js/chunk-7CM5D7PF.js.map +1 -0
  159. package/src/testing-js/{chunk-X6KHEVIG.js → chunk-7QXUJRSO.js} +97 -29
  160. package/src/testing-js/chunk-7QXUJRSO.js.map +1 -0
  161. package/src/testing-js/chunk-GZKUYLDW.js +193 -0
  162. package/src/testing-js/chunk-GZKUYLDW.js.map +1 -0
  163. package/src/testing-js/chunk-RTZQLW3F.js +649 -0
  164. package/src/testing-js/chunk-RTZQLW3F.js.map +1 -0
  165. package/src/testing-js/{chunk-SHBYZUPD.js → chunk-RWOT2XDB.js} +212 -15
  166. package/src/testing-js/chunk-RWOT2XDB.js.map +1 -0
  167. package/src/testing-js/{chunk-GKO27NGN.js → chunk-THWGMSRH.js} +2 -2
  168. package/src/testing-js/{chunk-3UKGXCDL.js → chunk-YVVR3GJZ.js} +1 -1
  169. package/src/testing-js/chunk-YVVR3GJZ.js.map +1 -0
  170. package/src/testing-js/component-a11y.contract.js +313 -0
  171. package/src/testing-js/component-a11y.contract.js.map +1 -0
  172. package/src/testing-js/component-alias.contract.js +2 -2
  173. package/src/testing-js/component-behavior.contract.js +2 -2
  174. package/src/testing-js/component-editor.contract.js +6 -5
  175. package/src/testing-js/component-editor.contract.js.map +1 -1
  176. package/src/testing-js/component-render.contract.js +10 -6
  177. package/src/testing-js/component-render.contract.js.map +1 -1
  178. package/src/testing-js/index.d.ts +44 -16
  179. package/src/testing-js/index.js +11 -11
  180. package/src/testing-js/index.js.map +1 -1
  181. package/src/testing-js/page-compliance.contract.js +132 -13
  182. package/src/testing-js/page-compliance.contract.js.map +1 -1
  183. package/src/testing-js/vitest.js +3 -3
  184. package/template/_gitignore +3 -0
  185. package/template/package.json +9 -0
  186. package/src/testing-js/chunk-3UKGXCDL.js.map +0 -1
  187. package/src/testing-js/chunk-NB3NZRBM.js.map +0 -1
  188. package/src/testing-js/chunk-SHBYZUPD.js.map +0 -1
  189. package/src/testing-js/chunk-X6KHEVIG.js.map +0 -1
  190. /package/src/testing-js/{chunk-WIZ6W7UT.js.map → chunk-3WCLMOM7.js.map} +0 -0
  191. /package/src/testing-js/{chunk-GKO27NGN.js.map → chunk-THWGMSRH.js.map} +0 -0
@@ -0,0 +1,649 @@
1
+ // src/testing/support/traceProperties.ts
2
+ var BOX_SIZE = ["width", "height", "min-*", "inline-size", "block-size", "padding*"];
3
+ var FOCUS = ["focus", "focus-visible"];
4
+ var BORDER_PAINT = ["border-block*", "border-inline*", ...["", "-top", "-right", "-bottom", "-left"].flatMap((side) => [`border${side}`, `border${side}-color`, `border${side}-width`, `border${side}-style`])];
5
+ var MOTION = [
6
+ "animation",
7
+ "animation-name",
8
+ "animation-duration",
9
+ "animation-delay",
10
+ "animation-iteration-count",
11
+ "transition",
12
+ "transition-property",
13
+ "transition-duration",
14
+ "transition-delay"
15
+ ];
16
+ var TRACE_AXES = {
17
+ "color-contrast": {
18
+ target: ["color", "background*", "opacity", "text-shadow"],
19
+ pseudoElements: ["*"],
20
+ ancestors: ["background*", "opacity"]
21
+ },
22
+ "SIA-R65": {
23
+ target: ["outline*", "box-shadow", "border*", "background*", "color", "text-decoration*"],
24
+ pseudoElements: [],
25
+ ancestors: [],
26
+ force: FOCUS
27
+ },
28
+ "target-size": { target: BOX_SIZE, pseudoElements: BOX_SIZE, ancestors: [] },
29
+ "focus-indicator-contrast": {
30
+ target: ["outline*", "box-shadow", ...BORDER_PAINT, "background*", "color"],
31
+ pseudoElements: [],
32
+ ancestors: ["background*"],
33
+ force: FOCUS
34
+ },
35
+ "control-boundary-contrast": {
36
+ target: [...BORDER_PAINT, "outline", "outline-color", "outline-width", "outline-style", "background*"],
37
+ pseudoElements: [],
38
+ ancestors: ["background*"]
39
+ },
40
+ // Every element's line height is 1.5 under the override, so the theme's own cannot cause the overflow.
41
+ "text-spacing": {
42
+ target: ["height", "max-height", "width", "max-width", "padding*", "overflow*", "white-space"],
43
+ pseudoElements: [],
44
+ ancestors: []
45
+ },
46
+ // A pseudo-element that does not display does not move, so its display gates the motion, as Button's shimmer does.
47
+ "prefers-reduced-motion": { target: MOTION, pseudoElements: [...MOTION, "display"], ancestors: [] }
48
+ };
49
+ var sessions = /* @__PURE__ */ new WeakMap();
50
+ function cdpSession(page) {
51
+ let session = sessions.get(page);
52
+ if (!session) {
53
+ session = (async () => {
54
+ const cdp = await page.context().newCDPSession(page);
55
+ await cdp.send("DOM.enable");
56
+ await cdp.send("CSS.enable");
57
+ return cdp;
58
+ })();
59
+ sessions.set(page, session);
60
+ }
61
+ return session;
62
+ }
63
+ function onAxis(property, axis) {
64
+ return axis.some((name) => name.endsWith("*") ? property.startsWith(name.slice(0, -1)) : property === name);
65
+ }
66
+ function authored(style) {
67
+ return (style?.cssProperties ?? []).filter((declaration) => declaration.text);
68
+ }
69
+ function regularRules(styles) {
70
+ return (styles.matchedCSSRules ?? []).filter(({ rule }) => rule.origin === "regular").map(({ rule }) => rule);
71
+ }
72
+ function declarations(styles) {
73
+ return [authored(styles.inlineStyle), ...regularRules(styles).map((rule) => authored(rule.style))].flat();
74
+ }
75
+ function cascadeOrder(styles) {
76
+ return [...regularRules(styles).flatMap((rule) => authored(rule.style)), ...authored(styles.inlineStyle)];
77
+ }
78
+ function winning(ordered, name) {
79
+ const all = ordered.filter((d) => d.name === name);
80
+ return all.filter((d) => d.important || /!\s*important\s*$/i.test(d.value)).at(-1) ?? all.at(-1);
81
+ }
82
+ function ruleKey(rule) {
83
+ return JSON.stringify([rule.styleSheetId, rule.selectorList.text, rule.style.range]);
84
+ }
85
+ function longhandsIn(page) {
86
+ return async (names) => new Map(await page.evaluate((names2) => names2.map((name) => {
87
+ if (name.startsWith("--")) return [name, [name]];
88
+ const style = document.createElement("div").style;
89
+ style.setProperty(name, "initial");
90
+ return [name, style.length ? Array.from({ length: style.length }, (_, i) => style.item(i)) : [name]];
91
+ }), names));
92
+ }
93
+ async function forcedDeclarations(plain, forced, longhands) {
94
+ const before = new Set(regularRules(plain).map(ruleKey));
95
+ const cascade = [
96
+ ...regularRules(forced).map((rule) => ({ forcedOnly: !before.has(ruleKey(rule)), declarations: authored(rule.style) })),
97
+ { forcedOnly: false, declarations: authored(forced.inlineStyle) }
98
+ ];
99
+ const expanded = await longhands([...new Set(cascade.flatMap((entry) => entry.declarations.map((d) => d.name)))]);
100
+ const changed = /* @__PURE__ */ new Set();
101
+ const kept = [];
102
+ for (const { forcedOnly, declarations: declarations2 } of cascade) {
103
+ for (const d of declarations2) {
104
+ const sets = expanded.get(d.name) ?? [d.name];
105
+ if (forcedOnly) sets.forEach((name) => changed.add(name));
106
+ if (forcedOnly || sets.some((name) => changed.has(name))) kept.push(d);
107
+ }
108
+ }
109
+ return kept;
110
+ }
111
+ function references(value) {
112
+ return [...value.matchAll(/var\(\s*(--[\w-]+)/g)].map((match) => match[1]);
113
+ }
114
+ function scopeDepths(page, selector, scope) {
115
+ return page.evaluate(({ selector: selector2, scope: scope2 }) => [...document.querySelectorAll(selector2)].map((element) => {
116
+ let depth = 0;
117
+ for (let node = element; node; node = node.parentElement, depth++) {
118
+ if (node.matches(scope2)) return depth;
119
+ }
120
+ return -1;
121
+ }), { selector, scope });
122
+ }
123
+ async function matchedStyles(cdp, nodeId, force = [], forceNodeId = nodeId) {
124
+ const forcePseudoState = (forcedPseudoClasses) => cdp.send("CSS.forcePseudoState", { nodeId: forceNodeId, forcedPseudoClasses });
125
+ if (force.length === 0) return cdp.send("CSS.getMatchedStylesForNode", { nodeId });
126
+ await forcePseudoState(force);
127
+ return cdp.send("CSS.getMatchedStylesForNode", { nodeId }).finally(() => forcePseudoState([]));
128
+ }
129
+ async function traceNode(cdp, node, axes, known, longhands) {
130
+ const matched = await matchedStyles(cdp, node.nodeId, axes.force, node.forceNodeId);
131
+ const own = axes.force ? await forcedDeclarations(await matchedStyles(cdp, node.nodeId), matched, longhands) : declarations(matched);
132
+ const pseudo = (matched.pseudoElements ?? []).flatMap(({ matches }) => declarations({ matchedCSSRules: matches }));
133
+ const chain = (matched.inherited ?? []).slice(0, node.depth);
134
+ const PSEUDO = -1;
135
+ const levels = [cascadeOrder(matched), ...chain.map(cascadeOrder)];
136
+ const pseudoCustom = pseudo.filter((d) => d.name.startsWith("--"));
137
+ const from = Math.max(node.ancestorsFrom - 1, 0);
138
+ const pending = [
139
+ ...own.filter((d) => onAxis(d.name, axes.target)).map((d) => ({ d, level: 0 })),
140
+ ...pseudo.filter((d) => onAxis(d.name, axes.pseudoElements)).map((d) => ({ d, level: PSEUDO })),
141
+ ...chain.slice(from).flatMap((entry, i) => declarations(entry).filter((d) => onAxis(d.name, axes.ancestors)).map((d) => ({ d, level: from + i + 1 })))
142
+ ].flatMap(({ d, level }) => references(d.value).map((name) => ({ name, level })));
143
+ const resolve = (name, level) => {
144
+ if (level === PSEUDO) {
145
+ const own2 = pseudoCustom.filter((d) => d.name === name);
146
+ if (own2.length > 0) return { declarations: own2, level: PSEUDO };
147
+ }
148
+ for (let at = Math.max(level, 0); at < levels.length; at++) {
149
+ const won = winning(levels[at], name);
150
+ if (won) return { declarations: [won], level: at };
151
+ }
152
+ return { declarations: [], level };
153
+ };
154
+ const found = /* @__PURE__ */ new Set();
155
+ const followed = /* @__PURE__ */ new Set();
156
+ for (let next = pending.pop(); next !== void 0; next = pending.pop()) {
157
+ const { name, level } = next;
158
+ const key = `${name}@${level}`;
159
+ if (known.has(name)) found.add(name);
160
+ else if (!followed.has(key)) {
161
+ followed.add(key);
162
+ const resolved = resolve(name, level);
163
+ for (const d of resolved.declarations) pending.push(...references(d.value).map((ref) => ({ name: ref, level: resolved.level })));
164
+ }
165
+ }
166
+ return [...found];
167
+ }
168
+ async function traceProperties(page, target, axes, known) {
169
+ let depths;
170
+ let forceDepths = [];
171
+ try {
172
+ depths = await scopeDepths(page, target.selector, target.scope);
173
+ if (target.forceOn) forceDepths = await scopeDepths(page, target.forceOn, target.scope);
174
+ } catch {
175
+ return [];
176
+ }
177
+ const cdp = await cdpSession(page);
178
+ const { root } = await cdp.send("DOM.getDocument", { depth: 0 });
179
+ const query = async (selector) => (await cdp.send("DOM.querySelectorAll", { nodeId: root.nodeId, selector })).nodeIds;
180
+ const nodeIds = await query(target.selector);
181
+ const forceNodeId = target.forceOn ? (await query(target.forceOn)).find((_, index) => forceDepths[index] >= 0) : void 0;
182
+ if (target.forceOn && forceNodeId === void 0) return [];
183
+ const longhands = longhandsIn(page);
184
+ const found = /* @__PURE__ */ new Set();
185
+ for (const [index, nodeId] of nodeIds.entries()) {
186
+ if (depths[index] < 0) continue;
187
+ const node = { nodeId, depth: depths[index], forceNodeId, ancestorsFrom: target.ancestorsFrom ?? 1 };
188
+ for (const name of await traceNode(cdp, node, axes, known, longhands)) found.add(name);
189
+ }
190
+ return [...found].sort();
191
+ }
192
+
193
+ // src/testing/support/nonTextContrast.ts
194
+ var FOCUS_INDICATOR_RULE = "focus-indicator-contrast";
195
+ var BOUNDARY_RULE = "control-boundary-contrast";
196
+ var NON_TEXT_URL = "https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html";
197
+ var FOCUS_ATTR = "data-lt-focus-probe";
198
+ var NO_TRANSITION_ID = "lt-focus-probe-no-transition";
199
+ var FORCE = ["focus", "focus-visible"];
200
+ var SIBLING_FOCUS_ATTR = "data-lt-focus-sibling";
201
+ function inPage(request) {
202
+ const scopes = [...document.querySelectorAll("scope" in request && request.scope || ":not(*)")];
203
+ const excluded = (el) => "exclude" in request && request.exclude.some((selector) => el.closest(selector));
204
+ const inScope2 = (el) => scopes.some((scope) => scope.contains(el)) && !excluded(el);
205
+ const canvas = document.createElement("canvas");
206
+ canvas.width = canvas.height = 1;
207
+ const ctx = canvas.getContext("2d", { willReadFrequently: true });
208
+ const paint = (layers) => {
209
+ ctx.clearRect(0, 0, 1, 1);
210
+ for (const layer of ["#fff", ...layers]) {
211
+ ctx.fillStyle = "transparent";
212
+ ctx.fillStyle = layer;
213
+ ctx.fillRect(0, 0, 1, 1);
214
+ }
215
+ return [...ctx.getImageData(0, 0, 1, 1).data.slice(0, 3)];
216
+ };
217
+ const alpha = (color) => {
218
+ ctx.clearRect(0, 0, 1, 1);
219
+ ctx.fillStyle = "transparent";
220
+ ctx.fillStyle = color;
221
+ ctx.fillRect(0, 0, 1, 1);
222
+ return ctx.getImageData(0, 0, 1, 1).data[3] / 255;
223
+ };
224
+ const rgb = (channels) => `rgb(${channels.join(" ")})`;
225
+ const luminance = (channels) => {
226
+ const [r, g, b] = channels.map((c) => {
227
+ const s = c / 255;
228
+ return s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
229
+ });
230
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
231
+ };
232
+ const contrast = (a, b) => {
233
+ const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);
234
+ return (hi + 0.05) / (lo + 0.05);
235
+ };
236
+ const selectorFor = (el) => {
237
+ const count = (selector) => scopes.reduce((n, scope) => n + (scope.matches(selector) ? 1 : 0) + scope.querySelectorAll(selector).length, 0);
238
+ const own = (e) => e.tagName.toLowerCase() + [...e.classList].filter((name) => !name.startsWith("svelte-") && /^[\w-]+$/.test(name)).map((name) => `.${name}`).join("");
239
+ const path = [];
240
+ for (let e = el; e; e = e.parentElement) {
241
+ const step = own(e);
242
+ path.unshift(step);
243
+ if (count(path.join(" > ")) === 1) break;
244
+ const same = [...e.parentElement?.children ?? []].filter((c) => c.tagName === e.tagName);
245
+ if (same.length > 1) path[0] = `${step}:nth-of-type(${same.indexOf(e) + 1})`;
246
+ if (count(path.join(" > ")) === 1 || scopes.includes(e)) break;
247
+ }
248
+ return path.join(" > ");
249
+ };
250
+ const backdrop = (from, ring) => {
251
+ const layers = [];
252
+ let level = 0;
253
+ let first = -1;
254
+ for (let e = from; e; e = e.parentElement, level++) {
255
+ const box = e.getBoundingClientRect();
256
+ const isScope = scopes.includes(e);
257
+ const contains = isScope || box.left <= ring.left + 0.5 && box.top <= ring.top + 0.5 && box.right >= ring.right - 0.5 && box.bottom >= ring.bottom - 0.5;
258
+ if (!contains) continue;
259
+ if (first < 0) first = level;
260
+ const style = getComputedStyle(e);
261
+ if (style.backgroundImage !== "none") return { color: null, first };
262
+ const a = alpha(style.backgroundColor);
263
+ if (a > 0) layers.unshift(style.backgroundColor);
264
+ if (a >= 1) break;
265
+ if (isScope) {
266
+ const page = getComputedStyle(document.documentElement).getPropertyValue("--page-bg").trim();
267
+ if (/gradient|url\(/.test(page)) return { color: null, first };
268
+ if (page) layers.unshift(page);
269
+ break;
270
+ }
271
+ }
272
+ return { color: paint(layers), first: Math.max(first, 0) };
273
+ };
274
+ const inflate = (box, by) => new DOMRect(box.x - by, box.y - by, box.width + 2 * by, box.height + 2 * by);
275
+ const px = (value) => parseFloat(value) || 0;
276
+ const html = (el) => el.outerHTML.replace(/\s+/g, " ").slice(0, 300);
277
+ const SIDES = ["Top", "Right", "Bottom", "Left"];
278
+ const visibleSide = (style, side) => {
279
+ const s = style;
280
+ return !["none", "hidden"].includes(s[`border${side}Style`]) && px(s[`border${side}Width`]) >= 0.99 ? s[`border${side}Color`] : null;
281
+ };
282
+ const candidates = (target) => {
283
+ const list = [target, ...target.querySelectorAll("*")];
284
+ for (const sibling of target.parentElement?.children ?? []) {
285
+ if (sibling !== target) list.push(sibling, ...sibling.querySelectorAll("*"));
286
+ }
287
+ return list.filter(inScope2);
288
+ };
289
+ const signature = (el) => {
290
+ const s = getComputedStyle(el);
291
+ return JSON.stringify([
292
+ [s.outlineStyle, s.outlineWidth, s.outlineColor, s.outlineOffset],
293
+ s.boxShadow,
294
+ SIDES.map((side) => visibleSide(s, side))
295
+ ]);
296
+ };
297
+ const indicatorOf = (el, before) => {
298
+ const [outlineBefore, shadowBefore, bordersBefore] = JSON.parse(before);
299
+ const s = getComputedStyle(el);
300
+ const outline = [s.outlineStyle, s.outlineWidth, s.outlineColor, s.outlineOffset];
301
+ if (JSON.stringify(outline) !== JSON.stringify(outlineBefore) && s.outlineStyle !== "none" && px(s.outlineWidth) > 0) {
302
+ if (s.outlineStyle === "auto") return { channel: "browser", color: "", extent: 0 };
303
+ if (alpha(s.outlineColor) > 0) return { channel: "outline", color: s.outlineColor, extent: px(s.outlineOffset) + px(s.outlineWidth) };
304
+ }
305
+ if (s.boxShadow !== shadowBefore && s.boxShadow !== "none") {
306
+ const shadows = s.boxShadow.split(/,(?![^(]*\))/).map((part) => part.trim());
307
+ for (const shadow of shadows) {
308
+ if (/\binset\b/.test(shadow)) continue;
309
+ const color = /^(?:[a-z-]+\([^)]*\)|#[\da-f]+|[a-z]+)/i.exec(shadow)?.[0] ?? "";
310
+ if (!color || alpha(color) === 0) continue;
311
+ const [x = 0, y = 0, blur = 0, spread = 0] = (shadow.slice(color.length).match(/-?[\d.]+px/g) ?? []).map(px);
312
+ return { channel: "shadow", color, extent: Math.max(Math.abs(x), Math.abs(y)) + blur + spread };
313
+ }
314
+ }
315
+ const borders = SIDES.map((side) => visibleSide(s, side));
316
+ for (const [i, color] of borders.entries()) {
317
+ if (color && color !== bordersBefore[i] && alpha(color) > 0) return { channel: "border", color, extent: 0 };
318
+ }
319
+ return null;
320
+ };
321
+ switch (request.kind) {
322
+ case "focusables": {
323
+ const style = document.createElement("style");
324
+ style.id = request.styleId;
325
+ style.textContent = "*, *::before, *::after { transition: none !important; }";
326
+ document.head.append(style);
327
+ for (const el of document.querySelectorAll(`[${request.marker}]`)) el.removeAttribute(request.marker);
328
+ const focusable = 'a[href], area[href], button, input:not([type="hidden"]), select, textarea, summary, iframe, [tabindex], [contenteditable]:not([contenteditable="false"])';
329
+ const found = scopes.flatMap((scope) => [scope, ...scope.querySelectorAll(focusable)]).filter((el, i, all) => all.indexOf(el) === i && el.matches(focusable) && inScope2(el)).filter((el) => el.tabIndex >= 0 && !el.matches(":disabled") && el.checkVisibility({ visibilityProperty: true }));
330
+ found.forEach((el, i) => el.setAttribute(request.attr, String(i)));
331
+ return found.length;
332
+ }
333
+ case "snapshot": {
334
+ const target = document.querySelector(`[${request.attr}="${request.index}"]`);
335
+ return candidates(target).map(signature);
336
+ }
337
+ case "measure": {
338
+ const target = document.querySelector(`[${request.attr}="${request.index}"]`);
339
+ const list = candidates(target);
340
+ for (const [i, el] of list.entries()) {
341
+ if (request.before[i] === void 0 || request.before[i] === signature(el)) continue;
342
+ const found = indicatorOf(el, request.before[i]);
343
+ if (!found) continue;
344
+ if (el !== target && !target.contains(el)) target.setAttribute(request.marker, "");
345
+ if (found.channel === "browser") return { kind: "browser" };
346
+ const ring = inflate(el.getBoundingClientRect(), Math.max(found.extent, 0));
347
+ const behind = backdrop(found.channel === "border" ? el.parentElement : el, found.extent < 0 ? el.getBoundingClientRect() : ring);
348
+ const offset = found.channel === "border" ? 1 : 0;
349
+ const common = {
350
+ channel: found.channel,
351
+ target: selectorFor(target),
352
+ indicator: selectorFor(el),
353
+ html: html(target),
354
+ ancestorsFrom: behind.first + offset
355
+ };
356
+ if (!behind.color) return { kind: "review", ...common };
357
+ const ratio = contrast(paint([rgb(behind.color), found.color]), behind.color);
358
+ return ratio < 3 ? { kind: "fail", ratio, ...common } : { kind: "pass" };
359
+ }
360
+ return { kind: "none" };
361
+ }
362
+ case "cleanup": {
363
+ document.getElementById(request.styleId)?.remove();
364
+ for (const el of document.querySelectorAll(`[${request.attr}]`)) el.removeAttribute(request.attr);
365
+ return null;
366
+ }
367
+ case "boundaries": {
368
+ const outcomes = [];
369
+ const control = "button, input, select, textarea, [aria-disabled]";
370
+ const inactive = (el) => {
371
+ const root = el.closest(request.root) ?? el;
372
+ const controls = [root, ...root.querySelectorAll(control)].filter((c) => c.matches(control));
373
+ return controls.length > 0 && controls.every((c) => c.matches(":disabled") || c.getAttribute("aria-disabled") === "true");
374
+ };
375
+ for (const part of request.parts) {
376
+ const elements = scopes.flatMap((scope) => [scope, ...scope.querySelectorAll(part.selector)]).filter((el, i, all) => all.indexOf(el) === i && el.matches(part.selector) && inScope2(el)).filter((el) => !part.when || el.matches(part.when)).filter((el) => el.checkVisibility({ visibilityProperty: true }) && el.getBoundingClientRect().width > 0 && !inactive(el));
377
+ for (const el of elements) {
378
+ const style = getComputedStyle(el);
379
+ const behind = backdrop(el.parentElement, el.getBoundingClientRect());
380
+ const common = { label: part.label, target: selectorFor(el), html: html(el), ancestorsFrom: behind.first + 1 };
381
+ if (!behind.color) {
382
+ outcomes.push({ kind: "review", edge: null, surface: null, ...common });
383
+ continue;
384
+ }
385
+ const surfaceColor = paint([rgb(behind.color), style.backgroundColor]);
386
+ const surface = style.backgroundImage === "none" ? contrast(surfaceColor, behind.color) : null;
387
+ const edges = [];
388
+ const borderUnder = style.backgroundClip === "border-box" ? surfaceColor : behind.color;
389
+ for (const side of SIDES) {
390
+ const color = visibleSide(style, side);
391
+ if (color) edges.push({ channel: "border", color, under: borderUnder });
392
+ }
393
+ if (!["none", "auto"].includes(style.outlineStyle) && px(style.outlineWidth) >= 0.99) {
394
+ edges.push({ channel: "outline", color: style.outlineColor, under: px(style.outlineOffset) < 0 ? surfaceColor : behind.color });
395
+ }
396
+ const edge = edges.map(({ channel, color, under }) => ({ channel, ratio: contrast(paint([rgb(under), color]), behind.color) })).reduce((best, next) => best && best.ratio >= next.ratio ? best : next, null);
397
+ if ((edge?.ratio ?? 0) >= 3 || (surface ?? 0) >= 3) continue;
398
+ outcomes.push({ kind: surface === null ? "review" : "fail", edge, surface, ...common });
399
+ }
400
+ }
401
+ return outcomes;
402
+ }
403
+ case "describe": {
404
+ return request.values.map((value) => {
405
+ const el = document.querySelector(`[${request.attr}="${value}"]`);
406
+ return { target: selectorFor(el), html: html(el) };
407
+ });
408
+ }
409
+ }
410
+ }
411
+ function run(page, request) {
412
+ return page.evaluate(inPage, request);
413
+ }
414
+ function describeTagged(page, scope, exclude, attr, values) {
415
+ return run(page, { kind: "describe", scope, exclude, attr, values });
416
+ }
417
+ function ratioText(ratio) {
418
+ return `${Math.floor(ratio * 100) / 100}:1`;
419
+ }
420
+ async function scanFocusIndicators(page, scope, exclude) {
421
+ const cdp = await cdpSession(page);
422
+ const count = await run(page, { kind: "focusables", scope, exclude, attr: FOCUS_ATTR, styleId: NO_TRANSITION_ID, marker: SIBLING_FOCUS_ATTR });
423
+ const checked = [];
424
+ try {
425
+ const { root } = await cdp.send("DOM.getDocument", { depth: 0 });
426
+ for (let index = 0; index < count; index++) {
427
+ const { nodeId } = await cdp.send("DOM.querySelector", { nodeId: root.nodeId, selector: `[${FOCUS_ATTR}="${index}"]` });
428
+ const before = await run(page, { kind: "snapshot", attr: FOCUS_ATTR, index, scope, exclude });
429
+ await cdp.send("CSS.forcePseudoState", { nodeId, forcedPseudoClasses: FORCE });
430
+ let outcome;
431
+ try {
432
+ outcome = await run(page, { kind: "measure", attr: FOCUS_ATTR, index, scope, exclude, before, marker: SIBLING_FOCUS_ATTR });
433
+ } finally {
434
+ await cdp.send("CSS.forcePseudoState", { nodeId, forcedPseudoClasses: [] });
435
+ }
436
+ if (outcome.kind !== "fail" && outcome.kind !== "review") continue;
437
+ const where = outcome.indicator === outcome.target ? "" : ` on ${outcome.indicator}`;
438
+ checked.push({
439
+ result: {
440
+ rule: outcome.kind === "fail" ? "a11y-component" : "a11y-review",
441
+ engineRule: FOCUS_INDICATOR_RULE,
442
+ impact: null,
443
+ target: outcome.target,
444
+ html: outcome.html,
445
+ help: outcome.kind === "fail" ? `Focus ${outcome.channel}${where} ${ratioText(outcome.ratio)} against the backdrop, needs 3:1` : `Focus ${outcome.channel}${where} sits over a gradient or image. Check by eye that it contrasts 3:1 with the backdrop`,
446
+ helpUrl: NON_TEXT_URL
447
+ },
448
+ trace: { selector: outcome.indicator, forceOn: outcome.target, ancestorsFrom: outcome.ancestorsFrom }
449
+ });
450
+ }
451
+ } finally {
452
+ await run(page, { kind: "cleanup", attr: FOCUS_ATTR, styleId: NO_TRANSITION_ID });
453
+ }
454
+ return checked;
455
+ }
456
+ async function scanBoundaries(page, scope, exclude, parts, root) {
457
+ if (parts.length === 0) return [];
458
+ const outcomes = await run(page, { kind: "boundaries", scope, exclude, parts, root });
459
+ return outcomes.map((outcome) => {
460
+ const edge = outcome.edge === null ? "no border" : `${outcome.edge.channel} ${ratioText(outcome.edge.ratio)}`;
461
+ return {
462
+ result: {
463
+ rule: outcome.kind === "fail" ? "a11y-component" : "a11y-review",
464
+ engineRule: BOUNDARY_RULE,
465
+ impact: null,
466
+ target: outcome.target,
467
+ html: outcome.html,
468
+ help: outcome.kind === "fail" ? `${outcome.label} ${edge} and surface ${ratioText(outcome.surface)} against the backdrop, needs 3:1` : `${outcome.label} sits on or carries a gradient or image. Check by eye that its edge contrasts 3:1 with the backdrop`,
469
+ helpUrl: NON_TEXT_URL
470
+ },
471
+ trace: { selector: outcome.target, ancestorsFrom: outcome.ancestorsFrom }
472
+ };
473
+ });
474
+ }
475
+
476
+ // src/testing/support/a11y.ts
477
+ import { test } from "@playwright/test";
478
+ var A11Y_ANNOTATION = "a11y";
479
+ var AXE_TAGS = ["wcag2a", "wcag2aa", "wcag21aa", "wcag22aa"];
480
+ var SCOPE_ATTR = "data-lt-a11y-scope";
481
+ var EXCLUDE_ATTR = "data-lt-a11y-exclude";
482
+ var HTML_LIMIT = 300;
483
+ var EngineMissing = class extends Error {
484
+ };
485
+ async function importEngine(packageName, load) {
486
+ try {
487
+ return await load();
488
+ } catch (error) {
489
+ if (error.code === "ERR_MODULE_NOT_FOUND") throw new EngineMissing(`${packageName} is not installed`);
490
+ throw error;
491
+ }
492
+ }
493
+ var axeModules = null;
494
+ async function importAxe() {
495
+ await importEngine("axe-core", () => import("axe-core"));
496
+ const { AxeBuilder } = await importEngine("@axe-core/playwright", () => import("@axe-core/playwright"));
497
+ return { AxeBuilder };
498
+ }
499
+ var loadAxe = () => axeModules ??= importAxe();
500
+ var alfaModules = null;
501
+ async function importAlfa() {
502
+ const { Audit, Outcome } = await importEngine("@siteimprove/alfa-act", () => import("@siteimprove/alfa-act"));
503
+ const { Rules } = await importEngine("@siteimprove/alfa-rules", () => import("@siteimprove/alfa-rules"));
504
+ const { Node } = await importEngine("@siteimprove/alfa-dom", () => import("@siteimprove/alfa-dom"));
505
+ const { Native: DomNative } = await importEngine("@siteimprove/alfa-dom", () => import("@siteimprove/alfa-dom/native"));
506
+ const { Device } = await importEngine("@siteimprove/alfa-device", () => import("@siteimprove/alfa-device"));
507
+ const { Native: DeviceNative } = await importEngine("@siteimprove/alfa-device", () => import("@siteimprove/alfa-device/native"));
508
+ const { Page: AlfaPage } = await importEngine("@siteimprove/alfa-web", () => import("@siteimprove/alfa-web"));
509
+ const http = await importEngine("@siteimprove/alfa-http", () => import("@siteimprove/alfa-http"));
510
+ const { URL } = await importEngine("@siteimprove/alfa-url", () => import("@siteimprove/alfa-url"));
511
+ return {
512
+ Audit,
513
+ Outcome,
514
+ R65: Rules.get("R65").getUnsafe(),
515
+ Node,
516
+ DomNative,
517
+ Device,
518
+ DeviceNative,
519
+ AlfaPage,
520
+ http,
521
+ URL
522
+ };
523
+ }
524
+ var loadAlfa = () => alfaModules ??= importAlfa();
525
+ async function missingEngine(engines) {
526
+ try {
527
+ for (const name of engines) await (name === "axe" ? loadAxe() : loadAlfa());
528
+ return null;
529
+ } catch (error) {
530
+ if (error instanceof EngineMissing) return error.message;
531
+ throw error;
532
+ }
533
+ }
534
+ function axeResults(rule, results, withReasons) {
535
+ return results.flatMap(
536
+ (result) => result.nodes.map((node) => {
537
+ const reasons = withReasons ? [...new Set([...node.any, ...node.all, ...node.none].map((check) => check.message).filter(Boolean))] : [];
538
+ return {
539
+ rule,
540
+ engineRule: result.id,
541
+ impact: node.impact ?? result.impact ?? null,
542
+ target: node.target.map((part) => Array.isArray(part) ? part.join(" >>> ") : String(part)).join(" | "),
543
+ html: node.html.slice(0, HTML_LIMIT),
544
+ help: [result.help, ...reasons].join(". "),
545
+ helpUrl: result.helpUrl
546
+ };
547
+ })
548
+ );
549
+ }
550
+ async function scanAxe(page, scope, exclude, rule, only) {
551
+ const { AxeBuilder } = await loadAxe();
552
+ let builder = new AxeBuilder({ page }).include(scope);
553
+ builder = only ? builder.withRules(only) : builder.withTags(AXE_TAGS);
554
+ for (const selector of exclude) builder = builder.exclude(selector);
555
+ if (rule === "a11y-page") builder = builder.disableRules(["color-contrast"]);
556
+ const result = await builder.analyze();
557
+ return [
558
+ ...axeResults(rule, result.violations, false),
559
+ ...axeResults("a11y-review", result.incomplete, true)
560
+ ];
561
+ }
562
+ function pruneToScope(node) {
563
+ if (node.type === "element" && node.attributes?.some((a) => a.name === SCOPE_ATTR)) return true;
564
+ if (!node.children) return false;
565
+ if (node.type === "element" && node.name === "head") return true;
566
+ node.children = node.children.filter((child) => child.type === "type" || pruneToScope(child));
567
+ return node.type === "document" || node.children.some((child) => child.type === "element");
568
+ }
569
+ var FOCUS_HELP = {
570
+ failed: "Focusing the element changes nothing visible",
571
+ cantTell: "Focusing the element changes no style on it, its descendants, or its ancestors"
572
+ };
573
+ async function scanFocusVisible(page, scope, exclude) {
574
+ const alfa = await loadAlfa();
575
+ await page.evaluate(({ scope: scope2, exclude: exclude2, scopeAttr, excludeAttr }) => {
576
+ for (const element of document.querySelectorAll(scope2)) element.setAttribute(scopeAttr, "");
577
+ for (const selector of exclude2) {
578
+ for (const element of document.querySelectorAll(selector)) element.setAttribute(excludeAttr, "");
579
+ }
580
+ }, { scope, exclude, scopeAttr: SCOPE_ATTR, excludeAttr: EXCLUDE_ATTR });
581
+ let json;
582
+ try {
583
+ const handle = await page.evaluateHandle(() => document);
584
+ json = await handle.evaluate(alfa.DomNative.fromNode);
585
+ await handle.dispose();
586
+ } finally {
587
+ await page.evaluate((attrs) => {
588
+ for (const attr of attrs) for (const element of document.querySelectorAll(`[${attr}]`)) element.removeAttribute(attr);
589
+ }, [SCOPE_ATTR, EXCLUDE_ATTR]);
590
+ }
591
+ pruneToScope(json);
592
+ const fromWindow = alfa.DeviceNative.fromWindow;
593
+ const device = alfa.Device.from(await page.evaluate(fromWindow));
594
+ const url = alfa.URL.parse(page.url()).getUnsafe();
595
+ const { Request, Response, Headers, Header } = alfa.http;
596
+ const alfaPage = alfa.AlfaPage.of(
597
+ Request.of("GET", url),
598
+ Response.of(url, 200, Headers.of([Header.of("Content-Type", "text/html")])),
599
+ alfa.Node.from(json, device),
600
+ device
601
+ );
602
+ const results = [];
603
+ for (const outcome of await alfa.Audit.of(alfaPage, [alfa.R65]).evaluate()) {
604
+ const kind = alfa.Outcome.isFailed(outcome) ? "failed" : alfa.Outcome.isCantTell(outcome) ? "cantTell" : null;
605
+ if (!kind) continue;
606
+ const target = outcome.target;
607
+ if (!inScope(target)) continue;
608
+ if (kind === "cantTell" && target.attribute?.(SIBLING_FOCUS_ATTR).isSome()) continue;
609
+ results.push({
610
+ rule: "a11y-focus-visible",
611
+ engineRule: "SIA-R65",
612
+ impact: null,
613
+ target: elementLabel(target),
614
+ html: target.toString().replace(/\s+/g, " ").slice(0, HTML_LIMIT),
615
+ help: FOCUS_HELP[kind],
616
+ helpUrl: alfa.R65.uri
617
+ });
618
+ }
619
+ return results;
620
+ }
621
+ function inScope(target) {
622
+ for (const node of target.inclusiveAncestors()) {
623
+ if (typeof node.attribute !== "function") continue;
624
+ if (node.attribute(EXCLUDE_ATTR).isSome()) return false;
625
+ if (node.attribute(SCOPE_ATTR).isSome()) return true;
626
+ }
627
+ return false;
628
+ }
629
+ function elementLabel(target) {
630
+ const id = target.id.isSome() ? `#${target.id.get()}` : "";
631
+ return `${target.name}${id}${[...target.classes].map((name) => `.${name}`).join("")}`;
632
+ }
633
+ function recordA11y(results) {
634
+ if (results.length === 0) return;
635
+ test.info().annotations.push({ type: A11Y_ANNOTATION, description: JSON.stringify(results) });
636
+ }
637
+
638
+ export {
639
+ TRACE_AXES,
640
+ traceProperties,
641
+ describeTagged,
642
+ scanFocusIndicators,
643
+ scanBoundaries,
644
+ missingEngine,
645
+ scanAxe,
646
+ scanFocusVisible,
647
+ recordA11y
648
+ };
649
+ //# sourceMappingURL=chunk-RTZQLW3F.js.map