effect-browser 0.3.0-beta.21 → 0.3.0-beta.23

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 (249) hide show
  1. package/README.md +130 -159
  2. package/dist/Action-24sLOubi.d.mts +110 -0
  3. package/dist/Action.d.mts +2 -0
  4. package/dist/Action.mjs +141 -0
  5. package/dist/Action.mjs.map +1 -0
  6. package/dist/ActionPort.d.mts +15 -0
  7. package/dist/ActionPort.mjs +101 -0
  8. package/dist/ActionPort.mjs.map +1 -0
  9. package/dist/Browser-BKPAbyys.mjs +4076 -0
  10. package/dist/Browser-BKPAbyys.mjs.map +1 -0
  11. package/dist/{Browser-CiXHT1yO.d.mts → Browser-wZhwZSlG.d.mts} +51 -13
  12. package/dist/Browser.d.mts +2 -2
  13. package/dist/Browser.mjs +1 -1
  14. package/dist/{BrowserError-Coy7EW1N.d.mts → BrowserError-BlcmLVzn.d.mts} +22 -7
  15. package/dist/BrowserError.d.mts +2 -2
  16. package/dist/BrowserError.mjs +46 -9
  17. package/dist/BrowserError.mjs.map +1 -1
  18. package/dist/{BrowserEvent-dq6FRT8w.d.mts → BrowserEvent-lLqJ3GJS.d.mts} +93 -37
  19. package/dist/BrowserEvent.d.mts +2 -2
  20. package/dist/BrowserEvent.mjs +29 -24
  21. package/dist/BrowserEvent.mjs.map +1 -1
  22. package/dist/{Change-DqING3tr.d.mts → Change-Ba7INmay.d.mts} +4 -6
  23. package/dist/Change.d.mts +2 -2
  24. package/dist/Change.mjs +97 -2
  25. package/dist/Change.mjs.map +1 -0
  26. package/dist/Clock.d.mts +57 -0
  27. package/dist/Clock.mjs +80 -0
  28. package/dist/Clock.mjs.map +1 -0
  29. package/dist/{Frame-DkNdjjjr.d.mts → Frame-UEH2hO5T.d.mts} +10 -3
  30. package/dist/Frame.d.mts +2 -2
  31. package/dist/Frame.mjs +10 -2
  32. package/dist/Frame.mjs.map +1 -1
  33. package/dist/{Motion-DND6I-64.d.mts → Geometry-DJx9qrYy.d.mts} +7 -10
  34. package/dist/Geometry.d.mts +2 -0
  35. package/dist/Geometry.mjs +32 -0
  36. package/dist/Geometry.mjs.map +1 -0
  37. package/dist/Matching.d.mts +37 -0
  38. package/dist/Matching.mjs +72 -0
  39. package/dist/Matching.mjs.map +1 -0
  40. package/dist/Page-BF5izr8R.mjs +795 -0
  41. package/dist/Page-BF5izr8R.mjs.map +1 -0
  42. package/dist/{Page-ku6j5t-v.d.mts → Page-CvsOEorc.d.mts} +158 -185
  43. package/dist/Page.d.mts +2 -2
  44. package/dist/Page.mjs +1 -1
  45. package/dist/Released-tURbFmal.d.mts +15 -0
  46. package/dist/{Snapshot-B34hZ4Jl.d.mts → Snapshot-CtBVOtuu.d.mts} +6 -1
  47. package/dist/Snapshot.d.mts +1 -1
  48. package/dist/Snapshot.mjs.map +1 -1
  49. package/dist/Stillness-CNlvayIo.mjs +136 -0
  50. package/dist/Stillness-CNlvayIo.mjs.map +1 -0
  51. package/dist/Style-AO4V7Czt.mjs +357 -0
  52. package/dist/Style-AO4V7Czt.mjs.map +1 -0
  53. package/dist/Style.d.mts +72 -0
  54. package/dist/Style.mjs +2 -0
  55. package/dist/Url.d.mts +26 -0
  56. package/dist/Url.mjs +74 -0
  57. package/dist/Url.mjs.map +1 -0
  58. package/dist/Window-CMddGMt1.d.mts +34 -0
  59. package/dist/Window.d.mts +2 -0
  60. package/dist/Window.mjs +35 -0
  61. package/dist/Window.mjs.map +1 -0
  62. package/dist/{cdp-DL7XfEj5.d.mts → connection-2KHI4_KN.d.mts} +4 -4
  63. package/dist/{cdp-BMpYMWYe.mjs → connection-CK83pvqP.mjs} +5 -6
  64. package/dist/connection-CK83pvqP.mjs.map +1 -0
  65. package/dist/index.d.mts +15 -18
  66. package/dist/index.mjs +11 -15
  67. package/dist/moment/Moment.d.mts +86 -0
  68. package/dist/{Moment.mjs → moment/Moment.mjs} +44 -38
  69. package/dist/moment/Moment.mjs.map +1 -0
  70. package/dist/{Plan-DJ4hEEna.d.mts → plan/index.d.mts} +169 -64
  71. package/dist/{Plan-BG1WifW2.mjs → plan/index.mjs} +122 -199
  72. package/dist/plan/index.mjs.map +1 -0
  73. package/dist/{Policy-BGWjbqCl.d.mts → policy/Policy.d.mts} +16 -20
  74. package/dist/{Policy.mjs → policy/Policy.mjs} +11 -21
  75. package/dist/policy/Policy.mjs.map +1 -0
  76. package/dist/presentation/Motion.d.mts +12 -0
  77. package/dist/{Motion.mjs → presentation/Motion.mjs} +4 -27
  78. package/dist/presentation/Motion.mjs.map +1 -0
  79. package/dist/presentation/Presentation.d.mts +30 -0
  80. package/dist/presentation/Presentation.mjs +105 -0
  81. package/dist/presentation/Presentation.mjs.map +1 -0
  82. package/dist/{Stage-NHp8N81k.d.mts → presentation/Stage.d.mts} +12 -15
  83. package/dist/{Stage.mjs → presentation/Stage.mjs} +68 -76
  84. package/dist/presentation/Stage.mjs.map +1 -0
  85. package/dist/presentation/feed.d.mts +20 -0
  86. package/dist/presentation/feed.mjs +18 -0
  87. package/dist/presentation/feed.mjs.map +1 -0
  88. package/dist/providers/Cdp.d.mts +9 -0
  89. package/dist/{Cdp.mjs → providers/Cdp.mjs} +3 -8
  90. package/dist/providers/Cdp.mjs.map +1 -0
  91. package/dist/{Chromium.d.mts → providers/Chromium.d.mts} +6 -7
  92. package/dist/{Chromium.mjs → providers/Chromium.mjs} +6 -15
  93. package/dist/providers/Chromium.mjs.map +1 -0
  94. package/dist/providers/Released.d.mts +2 -0
  95. package/dist/providers/Released.mjs +12 -0
  96. package/dist/providers/Released.mjs.map +1 -0
  97. package/dist/stillness/Stillness.d.mts +12 -0
  98. package/dist/stillness/Stillness.mjs +2 -0
  99. package/dist/supervisor/Supervisor.d.mts +104 -0
  100. package/dist/supervisor/Supervisor.mjs +515 -0
  101. package/dist/supervisor/Supervisor.mjs.map +1 -0
  102. package/dist/testing/index.d.mts +337 -0
  103. package/dist/testing/index.mjs +515 -0
  104. package/dist/testing/index.mjs.map +1 -0
  105. package/dist/workerd/Cdp.d.mts +8 -3
  106. package/dist/workerd/Cdp.mjs +2 -7
  107. package/dist/workerd/Cdp.mjs.map +1 -1
  108. package/package.json +89 -39
  109. package/src/Action.ts +127 -0
  110. package/src/ActionPort.ts +128 -0
  111. package/src/Browser.ts +352 -201
  112. package/src/BrowserError.ts +63 -6
  113. package/src/BrowserEvent.ts +26 -25
  114. package/src/Change.ts +0 -2
  115. package/src/{internal/pictures/clock.ts → Clock.ts} +17 -6
  116. package/src/Frame.ts +14 -0
  117. package/src/Geometry.ts +48 -0
  118. package/src/{internal/reading/match.inpage.ts → Matching.ts} +34 -4
  119. package/src/Page.ts +111 -92
  120. package/src/Snapshot.ts +5 -0
  121. package/src/{internal/input/style.ts → Style.ts} +121 -14
  122. package/src/Window.ts +30 -0
  123. package/src/index.ts +15 -6
  124. package/src/internal/input/actions.ts +61 -119
  125. package/src/internal/input/dispatch.ts +3 -3
  126. package/src/internal/input/gate.ts +21 -18
  127. package/src/internal/input/guard.inpage.ts +25 -58
  128. package/src/internal/input/guard.ts +11 -20
  129. package/src/internal/input/keyboard.ts +12 -3
  130. package/src/internal/input/perform.ts +78 -60
  131. package/src/internal/input/pointer.ts +4 -2
  132. package/src/internal/input/settle.ts +7 -5
  133. package/src/internal/input/targets.inpage.ts +1 -1
  134. package/src/internal/input/targets.ts +4 -9
  135. package/src/internal/page/bridge.ts +209 -113
  136. package/src/internal/page/context.ts +12 -59
  137. package/src/internal/page/dialogs.ts +58 -0
  138. package/src/internal/page/identity.ts +6 -5
  139. package/src/internal/page/lane.ts +14 -15
  140. package/src/internal/page/navigation.ts +50 -42
  141. package/src/internal/page/openings.ts +11 -5
  142. package/src/internal/page/page.ts +44 -81
  143. package/src/internal/page/port.ts +125 -0
  144. package/src/internal/{input → page}/replies.ts +1 -1
  145. package/src/internal/page/request-owner.ts +269 -0
  146. package/src/internal/page/requests.ts +357 -0
  147. package/src/internal/page/scripts.ts +124 -0
  148. package/src/internal/pictures/capture.ts +255 -332
  149. package/src/internal/pictures/dimensions.ts +162 -0
  150. package/src/internal/pictures/frame.ts +68 -0
  151. package/src/internal/pictures/pictures.ts +57 -23
  152. package/src/internal/pictures/quiescence.ts +1 -1
  153. package/src/internal/pictures/state.ts +26 -0
  154. package/src/internal/pictures/transport.ts +21 -4
  155. package/src/internal/reading/controls.inpage.ts +5 -70
  156. package/src/internal/reading/expect.inpage.ts +13 -17
  157. package/src/internal/reading/names.inpage.ts +89 -45
  158. package/src/internal/reading/outline.inpage.ts +6 -7
  159. package/src/internal/reading/reading.ts +144 -176
  160. package/src/internal/reading/ready.inpage.ts +6 -17
  161. package/src/internal/reading/ready.ts +13 -135
  162. package/src/internal/reading/subjects.inpage.ts +83 -43
  163. package/src/internal/reading/walk.inpage.ts +33 -13
  164. package/src/internal/timeline/changes.ts +55 -6
  165. package/src/internal/timeline/events.ts +15 -5
  166. package/src/internal/timeline/history.inpage.ts +1 -1
  167. package/src/internal/timeline/record.inpage.ts +4 -1
  168. package/src/internal/timeline/window.ts +2 -1
  169. package/src/{Moment.ts → moment/Moment.ts} +13 -31
  170. package/src/{internal/timeline → moment}/words.ts +2 -2
  171. package/src/{internal/reading → plan}/choose.ts +3 -3
  172. package/src/plan/data.ts +117 -0
  173. package/src/plan/execute.ts +411 -0
  174. package/src/plan/index.ts +36 -0
  175. package/src/plan/record.ts +71 -0
  176. package/src/plan/targets.ts +71 -0
  177. package/src/{Policy.ts → policy/Policy.ts} +13 -10
  178. package/src/{Motion.ts → presentation/Motion.ts} +12 -46
  179. package/src/presentation/Presentation.ts +176 -0
  180. package/src/{Stage.ts → presentation/Stage.ts} +147 -112
  181. package/src/presentation/feed.ts +21 -0
  182. package/src/{Cdp.ts → providers/Cdp.ts} +2 -2
  183. package/src/{Chromium.ts → providers/Chromium.ts} +7 -10
  184. package/src/providers/Released.ts +13 -0
  185. package/src/{internal/cdp.ts → providers/connection.ts} +2 -2
  186. package/src/{internal/pictures/motion.ts → stillness/Pixels.ts} +1 -1
  187. package/src/stillness/Stillness.ts +166 -0
  188. package/src/supervisor/Supervisor.ts +170 -0
  189. package/src/supervisor/contract.ts +105 -0
  190. package/src/supervisor/lifecycle.ts +272 -0
  191. package/src/supervisor/runtime.ts +238 -0
  192. package/src/testing/TestBrowser.ts +115 -0
  193. package/src/testing/TestPage.ts +10 -0
  194. package/src/testing/evidence.ts +154 -0
  195. package/src/testing/index.ts +3 -0
  196. package/src/testing/model.ts +222 -0
  197. package/src/testing/page.ts +360 -0
  198. package/src/workerd/Cdp.ts +2 -2
  199. package/dist/Browser-CxXUjxOp.mjs +0 -619
  200. package/dist/Browser-CxXUjxOp.mjs.map +0 -1
  201. package/dist/Cdp-CzCRnMlM.d.mts +0 -10
  202. package/dist/Cdp.d.mts +0 -11
  203. package/dist/Cdp.mjs.map +0 -1
  204. package/dist/Change-DNvztNLu.mjs +0 -138
  205. package/dist/Change-DNvztNLu.mjs.map +0 -1
  206. package/dist/Chromium.mjs.map +0 -1
  207. package/dist/Expect-u3P_ENLX.d.mts +0 -62
  208. package/dist/Expect.d.mts +0 -2
  209. package/dist/Expect.mjs +0 -114
  210. package/dist/Expect.mjs.map +0 -1
  211. package/dist/Moment.d.mts +0 -2
  212. package/dist/Moment.mjs.map +0 -1
  213. package/dist/Motion.d.mts +0 -2
  214. package/dist/Motion.mjs.map +0 -1
  215. package/dist/Page-BP02bmNv.mjs +0 -264
  216. package/dist/Page-BP02bmNv.mjs.map +0 -1
  217. package/dist/Plan-BG1WifW2.mjs.map +0 -1
  218. package/dist/Plan.d.mts +0 -2
  219. package/dist/Plan.mjs +0 -2
  220. package/dist/Policy.d.mts +0 -2
  221. package/dist/Policy.mjs.map +0 -1
  222. package/dist/Presentation-DxVikn9_.d.mts +0 -48
  223. package/dist/Presentation.d.mts +0 -2
  224. package/dist/Presentation.mjs +0 -118
  225. package/dist/Presentation.mjs.map +0 -1
  226. package/dist/Stage.d.mts +0 -2
  227. package/dist/Stage.mjs.map +0 -1
  228. package/dist/Supervisor-2mPjIYYs.mjs +0 -676
  229. package/dist/Supervisor-2mPjIYYs.mjs.map +0 -1
  230. package/dist/Supervisor-CfRxbaso.d.mts +0 -317
  231. package/dist/Supervisor.d.mts +0 -2
  232. package/dist/Supervisor.mjs +0 -2
  233. package/dist/cdp-BMpYMWYe.mjs.map +0 -1
  234. package/dist/context-EGhOqjNN.mjs +0 -335
  235. package/dist/context-EGhOqjNN.mjs.map +0 -1
  236. package/dist/page-PTM8m5wC.mjs +0 -4057
  237. package/dist/page-PTM8m5wC.mjs.map +0 -1
  238. package/dist/url-Bsp2y55M.mjs +0 -264
  239. package/dist/url-Bsp2y55M.mjs.map +0 -1
  240. package/dist/workerd/index.d.mts +0 -16
  241. package/dist/workerd/index.mjs +0 -17
  242. package/src/Expect.ts +0 -180
  243. package/src/Plan.ts +0 -674
  244. package/src/Presentation.ts +0 -196
  245. package/src/Supervisor.ts +0 -632
  246. package/src/internal/supervisor/lifecycle.ts +0 -484
  247. package/src/workerd/index.ts +0 -17
  248. /package/src/{internal/page/url.ts → Url.ts} +0 -0
  249. /package/src/{internal/pictures → stillness}/utilsBundle.d.ts +0 -0
@@ -2,7 +2,7 @@
2
2
  * In the page: the wait an expectation takes on what `find` matches, and the mark that stands for
3
3
  * what the matches show. See `names.inpage.ts` for what a page-side part may use.
4
4
  */
5
- import type { FindRequest } from "./match.inpage.ts";
5
+ import type { FindRequest, Match } from "../../Matching.ts";
6
6
  import type { Names } from "./names.inpage.ts";
7
7
  import type { Subjects } from "./subjects.inpage.ts";
8
8
 
@@ -12,29 +12,23 @@ import type { Subjects } from "./subjects.inpage.ts";
12
12
  */
13
13
  export type Want = "some" | "none" | { readonly other: string };
14
14
 
15
- export const expectations = (names: Names, subjected: Subjects) => {
15
+ export const expectations = (names: Names, subjected: Subjects, matching: Match) => {
16
16
  const { isInput, isSelect, isTextArea, roleOf, textOf } = names;
17
17
  const { elementsOf, stateOf } = subjected;
18
18
 
19
19
  // What matched elements show, their text, values and states but focus, as a mark that carries
20
20
  // none of it: a count and FNV-1a over each in turn.
21
- const markOf = (elements: ReadonlyArray<Element>) => {
22
- let hash = 0x811c9dc5;
21
+ const markOf = (elements: ReadonlyArray<Element>) =>
22
+ matching.mark(
23
+ elements.map((element) => {
24
+ const { focused: _focused, ...state } = stateOf(element, roleOf(element));
23
25
 
24
- for (const element of elements) {
25
- const { focused: _focused, ...state } = stateOf(element, roleOf(element));
26
+ const value =
27
+ isInput(element) || isSelect(element) || isTextArea(element) ? element.value : "";
26
28
 
27
- const value =
28
- isInput(element) || isSelect(element) || isTextArea(element) ? element.value : "";
29
-
30
- const shown = `${textOf(element)}\u0000${value}\u0000${JSON.stringify(state)}\u0001`;
31
-
32
- for (let index = 0; index < shown.length; index++)
33
- hash = Math.imul(hash ^ shown.charCodeAt(index), 0x01000193);
34
- }
35
-
36
- return `${elements.length}:${(hash >>> 0).toString(16)}`;
37
- };
29
+ return `${textOf(element)}\u0000${value}\u0000${JSON.stringify(state)}\u0001`;
30
+ }),
31
+ );
38
32
 
39
33
  /**
40
34
  * What `find` matches, looked at every 100 ms until `want` holds of it or `millis` have passed,
@@ -45,6 +39,8 @@ export const expectations = (names: Names, subjected: Subjects) => {
45
39
 
46
40
  for (;;) {
47
41
  const elements = elementsOf(request);
42
+
43
+ if ("invalid" in elements) return elements;
48
44
  const mark = markOf(elements);
49
45
 
50
46
  const met =
@@ -6,27 +6,7 @@
6
6
  * stay self-contained: it uses only its parameters, the DOM and what it defines itself.
7
7
  */
8
8
 
9
- export const names = () => {
10
- const byElement = new WeakMap<Element, string>();
11
- const byRef = new Map<string, WeakRef<Element>>();
12
- const refs = { next: 1 };
13
-
14
- const interactiveRoles = new Set(
15
- "button link checkbox radio tab menuitem menuitemcheckbox menuitemradio option switch slider combobox listbox textbox searchbox spinbutton treeitem".split(
16
- " ",
17
- ),
18
- );
19
-
20
- const containers: Record<string, string> = {
21
- HEADER: "banner",
22
- NAV: "navigation",
23
- MAIN: "main",
24
- ASIDE: "complementary",
25
- FOOTER: "contentinfo",
26
- FORM: "form",
27
- DIALOG: "dialog",
28
- };
29
-
9
+ export const elements = () => {
30
10
  // Elements of a same-origin frame come from another realm, so tag names decide, not instanceof.
31
11
  const isInput = (element: Element): element is HTMLInputElement => element.tagName === "INPUT";
32
12
 
@@ -47,6 +27,68 @@ export const names = () => {
47
27
  const isElement = (node: Node): node is Element => node.nodeType === Node.ELEMENT_NODE;
48
28
  const isDocument = (node: Node): node is Document => node.nodeType === Node.DOCUMENT_NODE;
49
29
 
30
+ /** The native fields and editable regions that can receive typed text. */
31
+ const textEntry = (element: Element): boolean =>
32
+ (isInput(element) &&
33
+ ![
34
+ "button",
35
+ "reset",
36
+ "submit",
37
+ "image",
38
+ "checkbox",
39
+ "radio",
40
+ "file",
41
+ "range",
42
+ "color",
43
+ "hidden",
44
+ ].includes(element.type)) ||
45
+ isTextArea(element) ||
46
+ (isHtml(element) && element.isContentEditable);
47
+
48
+ const clean = (value: string | null | undefined, max = 160): string => {
49
+ const text = (value ?? "").replace(/\s+/g, " ").trim();
50
+
51
+ return text.length > max ? `${text.slice(0, max - 1)}…` : text;
52
+ };
53
+
54
+ return {
55
+ clean,
56
+ isInput,
57
+ isTextArea,
58
+ isSelect,
59
+ isFrame,
60
+ isHtml,
61
+ isButton,
62
+ isLabel,
63
+ textOf,
64
+ isElement,
65
+ isDocument,
66
+ textEntry,
67
+ };
68
+ };
69
+
70
+ export const names = (native: ReturnType<typeof elements>) => {
71
+ const { clean, isInput, isTextArea, isSelect, isFrame, textOf, isElement } = native;
72
+ const byElement = new WeakMap<Element, string>();
73
+ const byRef = new Map<string, WeakRef<Element>>();
74
+ const refs = { next: 1 };
75
+
76
+ const interactiveRoles = new Set(
77
+ "button link checkbox radio tab menuitem menuitemcheckbox menuitemradio option switch slider combobox listbox textbox searchbox spinbutton treeitem".split(
78
+ " ",
79
+ ),
80
+ );
81
+
82
+ const containers: Record<string, string> = {
83
+ HEADER: "banner",
84
+ NAV: "navigation",
85
+ MAIN: "main",
86
+ ASIDE: "complementary",
87
+ FOOTER: "contentinfo",
88
+ FORM: "form",
89
+ DIALOG: "dialog",
90
+ };
91
+
50
92
  // Controls whose text is a value or a choice, not words of a label around them.
51
93
  const valueRoles = new Set(
52
94
  "combobox listbox option textbox searchbox spinbutton slider".split(" "),
@@ -76,13 +118,7 @@ export const names = () => {
76
118
  return text;
77
119
  };
78
120
 
79
- const clean = (value: string | null | undefined, max = 160): string => {
80
- const text = (value ?? "").replace(/\s+/g, " ").trim();
81
-
82
- return text.length > max ? `${text.slice(0, max - 1)}…` : text;
83
- };
84
-
85
- const roleOf = (element: Element): string | null => {
121
+ const roleOf = (element: Element, structural = false): string | null => {
86
122
  const explicit = element.getAttribute("role");
87
123
 
88
124
  if (explicit !== null && explicit.trim() !== "") return explicit.trim().split(/\s+/)[0] ?? null;
@@ -95,7 +131,7 @@ export const names = () => {
95
131
  if (isInput(element)) {
96
132
  const type = element.type;
97
133
 
98
- if (type === "hidden") return null;
134
+ if (type === "hidden" || type === "color" || type === "file") return null;
99
135
  if (type === "checkbox" || type === "radio") return type;
100
136
  if (type === "range") return "slider";
101
137
  if (type === "number") return "spinbutton";
@@ -110,14 +146,30 @@ export const names = () => {
110
146
  if (tag === "CANVAS") return "canvas";
111
147
  if (tag === "IFRAME") return "iframe";
112
148
  if (element.getAttribute("contenteditable") === "true") return "textbox";
149
+ if (structural) {
150
+ if (tag === "TH")
151
+ return element.getAttribute("scope") === "row" ? "rowheader" : "columnheader";
152
+
153
+ const roles: Record<string, string> = {
154
+ TABLE: "table",
155
+ TR: "row",
156
+ TD: "cell",
157
+ TBODY: "rowgroup",
158
+ THEAD: "rowgroup",
159
+ TFOOT: "rowgroup",
160
+ UL: "list",
161
+ OL: "list",
162
+ MENU: "list",
163
+ LI: "listitem",
164
+ };
165
+
166
+ if (roles[tag] !== undefined) return roles[tag];
167
+ }
113
168
 
114
169
  return containers[tag] ?? null;
115
170
  };
116
171
 
117
172
  const nameOf = (element: Element, role: string | null): string => {
118
- const label = element.getAttribute("aria-label");
119
-
120
- if (label !== null && clean(label) !== "") return clean(label);
121
173
  const labelledBy = element.getAttribute("aria-labelledby");
122
174
 
123
175
  if (labelledBy !== null) {
@@ -132,6 +184,9 @@ export const names = () => {
132
184
 
133
185
  if (clean(text) !== "") return clean(text);
134
186
  }
187
+ const label = element.getAttribute("aria-label");
188
+
189
+ if (label !== null && clean(label) !== "") return clean(label);
135
190
  if (isInput(element) || isTextArea(element) || isSelect(element)) {
136
191
  const labels = element.labels === null ? "" : Array.from(element.labels, labelText).join(" ");
137
192
 
@@ -174,8 +229,7 @@ export const names = () => {
174
229
  };
175
230
 
176
231
  const isDisabled = (element: Element): boolean =>
177
- ("disabled" in element && element.disabled === true) ||
178
- element.getAttribute("aria-disabled") === "true";
232
+ element.matches(":disabled") || element.getAttribute("aria-disabled") === "true";
179
233
 
180
234
  const refFor = (element: Element): string => {
181
235
  const known = byElement.get(element);
@@ -275,31 +329,21 @@ export const names = () => {
275
329
  };
276
330
 
277
331
  return {
332
+ ...native,
278
333
  activeElement,
279
- clean,
280
334
  containers,
281
335
  describe,
282
336
  inCurrentDocument,
283
337
  interactiveRoles,
284
- isButton,
285
338
  isDisabled,
286
- isDocument,
287
- isElement,
288
- isFrame,
289
- isHtml,
290
- isInput,
291
- isLabel,
292
339
  isRoot,
293
340
  isSecret,
294
- isSelect,
295
- isTextArea,
296
341
  lookup,
297
342
  nameOf,
298
343
  parentOf,
299
344
  refFor,
300
345
  refs,
301
346
  roleOf,
302
- textOf,
303
347
  };
304
348
  };
305
349
 
@@ -5,7 +5,7 @@
5
5
  import { Schema } from "effect";
6
6
 
7
7
  import { type Control, Snapshot } from "../../Snapshot.ts";
8
- import type { addresses } from "../page/url.ts";
8
+ import type { addresses } from "../../Url.ts";
9
9
  import type { Controls } from "./controls.inpage.ts";
10
10
  import type { Names } from "./names.inpage.ts";
11
11
  import type { Subjects } from "./subjects.inpage.ts";
@@ -18,7 +18,8 @@ export interface SnapshotRequest {
18
18
  /** A CSS selector: only what is inside the elements it matches is read. */
19
19
  readonly within: string | null;
20
20
  readonly maxChars: number;
21
- readonly firstRef: number;
21
+ /** Give every control's box, not only a canvas's or a frame's. */
22
+ readonly boxes: boolean;
22
23
  }
23
24
 
24
25
  /**
@@ -38,7 +39,7 @@ export const outline = (
38
39
  controlling: Controls,
39
40
  url: Url,
40
41
  ) => {
41
- const { clean, containers, isFrame, nameOf, refFor, refs, roleOf, textOf } = names;
42
+ const { clean, containers, isFrame, nameOf, refFor, roleOf, textOf } = names;
42
43
  const { visit } = walked;
43
44
  const { isControl } = subjects;
44
45
  const { cut } = texts;
@@ -86,7 +87,6 @@ export const outline = (
86
87
  const roots = request.within === null ? [null] : controlling.rootsOf(request.within);
87
88
 
88
89
  if ("invalid" in roots) return roots;
89
- if (refs.next < request.firstRef) refs.next = request.firstRef;
90
90
  const width = window.innerWidth;
91
91
  const height = window.innerHeight;
92
92
  const query = request.query === null ? null : request.query.toLowerCase();
@@ -126,7 +126,7 @@ export const outline = (
126
126
  const kind = role ?? "clickable";
127
127
 
128
128
  const box =
129
- role === "canvas" || role === "iframe"
129
+ request.boxes || role === "canvas" || role === "iframe"
130
130
  ? ` ${Math.round(rect.width)}x${Math.round(rect.height)} at (${Math.round(rect.x)},${Math.round(rect.y)})`
131
131
  : "";
132
132
 
@@ -241,7 +241,6 @@ export const outline = (
241
241
  // Only the controls whose lines were kept.
242
242
  controls: controls.filter((control) => outlined.text.includes(`[ref=${control.ref}]`)),
243
243
  },
244
- nextRef: refs.next,
245
244
  };
246
245
  };
247
246
 
@@ -253,7 +252,7 @@ export const outline = (
253
252
  export type Outline = ReturnType<typeof outline>;
254
253
 
255
254
  export const SnapshotResultSchema = Schema.Union([
256
- Schema.Struct({ snapshot: Snapshot, nextRef: Schema.Finite }),
255
+ Schema.Struct({ snapshot: Snapshot }),
257
256
  Schema.Struct({ invalid: Schema.String }),
258
257
  ]);
259
258