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

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 (348) hide show
  1. package/README.md +437 -142
  2. package/dist/Action.d.mts +1 -1
  3. package/dist/Action.mjs +61 -9
  4. package/dist/Action.mjs.map +1 -1
  5. package/dist/Browser.d.mts +2 -2
  6. package/dist/Browser.mjs +2 -2
  7. package/dist/BrowserError.d.mts +2 -2
  8. package/dist/BrowserError.mjs +194 -41
  9. package/dist/BrowserError.mjs.map +1 -1
  10. package/dist/BrowserEvent.d.mts +2 -2
  11. package/dist/BrowserEvent.mjs +185 -35
  12. package/dist/BrowserEvent.mjs.map +1 -1
  13. package/dist/Cdp.d.mts +15 -0
  14. package/dist/Cdp.mjs +22 -0
  15. package/dist/Cdp.mjs.map +1 -0
  16. package/dist/Change.d.mts +2 -2
  17. package/dist/Change.mjs +40 -7
  18. package/dist/Change.mjs.map +1 -1
  19. package/dist/Frame.d.mts +2 -2
  20. package/dist/Frame.mjs +132 -14
  21. package/dist/Frame.mjs.map +1 -1
  22. package/dist/InputStyle.d.mts +153 -0
  23. package/dist/InputStyle.mjs +2 -0
  24. package/dist/Layout.d.mts +2 -0
  25. package/dist/Layout.mjs +123 -0
  26. package/dist/Layout.mjs.map +1 -0
  27. package/dist/Overlay.d.mts +2 -0
  28. package/dist/Overlay.mjs +58 -0
  29. package/dist/Overlay.mjs.map +1 -0
  30. package/dist/Page.d.mts +2 -2
  31. package/dist/Page.mjs +2 -2
  32. package/dist/PageTime.d.mts +2 -0
  33. package/dist/PageTime.mjs +17 -0
  34. package/dist/PageTime.mjs.map +1 -0
  35. package/dist/Pose.d.mts +2 -0
  36. package/dist/Pose.mjs +65 -0
  37. package/dist/Pose.mjs.map +1 -0
  38. package/dist/Site.d.mts +984 -0
  39. package/dist/Site.mjs +110 -0
  40. package/dist/Site.mjs.map +1 -0
  41. package/dist/Snapshot.d.mts +2 -2
  42. package/dist/Snapshot.mjs +87 -6
  43. package/dist/Snapshot.mjs.map +1 -1
  44. package/dist/Text.d.mts +2 -0
  45. package/dist/Text.mjs +45 -0
  46. package/dist/Text.mjs.map +1 -0
  47. package/dist/Window.d.mts +2 -2
  48. package/dist/Window.mjs +31 -6
  49. package/dist/Window.mjs.map +1 -1
  50. package/dist/ai/BrowserTools.d.mts +4987 -0
  51. package/dist/ai/BrowserTools.mjs +3 -0
  52. package/dist/ai/PageControl.d.mts +286 -0
  53. package/dist/ai/PageControl.mjs +426 -0
  54. package/dist/ai/PageControl.mjs.map +1 -0
  55. package/dist/ai/PromptCache.d.mts +16 -0
  56. package/dist/ai/PromptCache.mjs +72 -0
  57. package/dist/ai/PromptCache.mjs.map +1 -0
  58. package/dist/ai/Tabs.d.mts +2 -0
  59. package/dist/ai/Tabs.mjs +72 -0
  60. package/dist/ai/Tabs.mjs.map +1 -0
  61. package/dist/ai/ToolError.d.mts +34 -0
  62. package/dist/ai/ToolError.mjs +2 -0
  63. package/dist/ai/index.d.mts +6 -0
  64. package/dist/ai/index.mjs +6 -0
  65. package/dist/index.d.mts +7 -15
  66. package/dist/index.mjs +9 -8
  67. package/dist/{Action-24sLOubi.d.mts → internal/Action-CkanNTUw.d.mts} +64 -4
  68. package/dist/{Browser-wZhwZSlG.d.mts → internal/Browser-DD9Vm1c-.d.mts} +80 -10
  69. package/dist/{Browser-BKPAbyys.mjs → internal/Browser-vzD7i2oj.mjs} +658 -495
  70. package/dist/internal/Browser-vzD7i2oj.mjs.map +1 -0
  71. package/dist/{BrowserError-BlcmLVzn.d.mts → internal/BrowserError-CsuRYcDX.d.mts} +187 -28
  72. package/dist/{BrowserEvent-lLqJ3GJS.d.mts → internal/BrowserEvent-tGPYYf6R.d.mts} +197 -18
  73. package/dist/internal/BrowserTools-Yi3lOX4h.mjs +497 -0
  74. package/dist/internal/BrowserTools-Yi3lOX4h.mjs.map +1 -0
  75. package/dist/{Style-AO4V7Czt.mjs → internal/InputStyle-CPzxoN4g.mjs} +94 -16
  76. package/dist/internal/InputStyle-CPzxoN4g.mjs.map +1 -0
  77. package/dist/{moment/Moment.mjs → internal/Moment-CstaX1mR.mjs} +49 -16
  78. package/dist/internal/Moment-CstaX1mR.mjs.map +1 -0
  79. package/dist/{moment/Moment.d.mts → internal/Moment-DOcldBdf.d.mts} +54 -21
  80. package/dist/internal/Page-BfGxn7oN.d.mts +1553 -0
  81. package/dist/{Page-BF5izr8R.mjs → internal/Page-DqF-tuTx.mjs} +62 -72
  82. package/dist/internal/Page-DqF-tuTx.mjs.map +1 -0
  83. package/dist/internal/Release-CFONkPDP.d.mts +39 -0
  84. package/dist/internal/Stage-D5ymSXDT.mjs +298 -0
  85. package/dist/internal/Stage-D5ymSXDT.mjs.map +1 -0
  86. package/dist/internal/Stillness-DCPeAN1a.mjs +1124 -0
  87. package/dist/internal/Stillness-DCPeAN1a.mjs.map +1 -0
  88. package/dist/internal/Supervisor-BcY_QNIY.d.mts +108 -0
  89. package/dist/internal/Supervisor-BcglY23c.mjs +531 -0
  90. package/dist/internal/Supervisor-BcglY23c.mjs.map +1 -0
  91. package/dist/internal/Tabs-dXMscIUQ.d.mts +52 -0
  92. package/dist/internal/TestPage-CYiYbh63.d.mts +159 -0
  93. package/dist/internal/ToolError-DArsRS2m.mjs +117 -0
  94. package/dist/internal/ToolError-DArsRS2m.mjs.map +1 -0
  95. package/dist/{plan/index.d.mts → internal/Walk-BNXcfZ2z.d.mts} +59 -35
  96. package/dist/{plan/index.mjs → internal/Walk-C5ky7uSf.mjs} +83 -51
  97. package/dist/internal/Walk-C5ky7uSf.mjs.map +1 -0
  98. package/dist/{ActionPort.mjs → internal/action-port-B5EkeGOR.mjs} +6 -12
  99. package/dist/internal/action-port-B5EkeGOR.mjs.map +1 -0
  100. package/dist/internal/cdp/workerd.d.mts +13 -0
  101. package/dist/internal/cdp/workerd.mjs +19 -0
  102. package/dist/internal/cdp/workerd.mjs.map +1 -0
  103. package/dist/{Clock.mjs → internal/clock-BKSAEf00.mjs} +13 -13
  104. package/dist/internal/clock-BKSAEf00.mjs.map +1 -0
  105. package/dist/{connection-2KHI4_KN.d.mts → internal/connection-BaB0vp1o.d.mts} +6 -6
  106. package/dist/{connection-CK83pvqP.mjs → internal/connection-C2X4GmXM.mjs} +19 -15
  107. package/dist/internal/connection-C2X4GmXM.mjs.map +1 -0
  108. package/dist/internal/events-DzCrww-y.mjs +72 -0
  109. package/dist/internal/events-DzCrww-y.mjs.map +1 -0
  110. package/dist/internal/fold.inpage-CyVZQHZL.d.mts +49 -0
  111. package/dist/internal/fold.inpage-uhrT-dOB.mjs +49 -0
  112. package/dist/internal/fold.inpage-uhrT-dOB.mjs.map +1 -0
  113. package/dist/internal/functions-jBOs6GKv.mjs +27 -0
  114. package/dist/internal/functions-jBOs6GKv.mjs.map +1 -0
  115. package/dist/{Geometry-DJx9qrYy.d.mts → internal/geometry-Dhj_ztJs.d.mts} +3 -3
  116. package/dist/{Geometry.mjs → internal/geometry-Lxyflb9J.mjs} +3 -12
  117. package/dist/internal/geometry-Lxyflb9J.mjs.map +1 -0
  118. package/dist/{Matching.mjs → internal/matching-Cs-UeOY0.mjs} +24 -19
  119. package/dist/internal/matching-Cs-UeOY0.mjs.map +1 -0
  120. package/dist/internal/page-DFQb-YOK.mjs +436 -0
  121. package/dist/internal/page-DFQb-YOK.mjs.map +1 -0
  122. package/dist/internal/pose.inpage-CBFeWcVa.mjs +1996 -0
  123. package/dist/internal/pose.inpage-CBFeWcVa.mjs.map +1 -0
  124. package/dist/{Url.mjs → internal/url-DB0pQYk6.mjs} +3 -12
  125. package/dist/internal/url-DB0pQYk6.mjs.map +1 -0
  126. package/dist/policy/Policy.d.mts +60 -6
  127. package/dist/policy/Policy.mjs +52 -9
  128. package/dist/policy/Policy.mjs.map +1 -1
  129. package/dist/policy/index.d.mts +2 -0
  130. package/dist/policy/index.mjs +2 -0
  131. package/dist/presentation/Film.d.mts +332 -0
  132. package/dist/presentation/Film.mjs +298 -0
  133. package/dist/presentation/Film.mjs.map +1 -0
  134. package/dist/presentation/Motion.d.mts +5 -1
  135. package/dist/presentation/Motion.mjs +16 -2
  136. package/dist/presentation/Motion.mjs.map +1 -1
  137. package/dist/presentation/Presentation.d.mts +48 -6
  138. package/dist/presentation/Presentation.mjs +28 -9
  139. package/dist/presentation/Presentation.mjs.map +1 -1
  140. package/dist/presentation/Stage.d.mts +40 -6
  141. package/dist/presentation/Stage.mjs +1 -262
  142. package/dist/presentation/index.d.mts +5 -0
  143. package/dist/presentation/index.mjs +5 -0
  144. package/dist/supervisor/Release.d.mts +2 -0
  145. package/dist/supervisor/Release.mjs +40 -0
  146. package/dist/supervisor/Release.mjs.map +1 -0
  147. package/dist/supervisor/Supervisor.d.mts +2 -104
  148. package/dist/supervisor/Supervisor.mjs +2 -515
  149. package/dist/supervisor/index.d.mts +3 -0
  150. package/dist/supervisor/index.mjs +3 -0
  151. package/dist/testing/HttpCassette.d.mts +98 -0
  152. package/dist/testing/HttpCassette.mjs +146 -0
  153. package/dist/testing/HttpCassette.mjs.map +1 -0
  154. package/dist/testing/Story.d.mts +31 -0
  155. package/dist/testing/Story.mjs +76 -0
  156. package/dist/testing/Story.mjs.map +1 -0
  157. package/dist/testing/TestBrowser.d.mts +191 -0
  158. package/dist/testing/TestBrowser.mjs +105 -0
  159. package/dist/testing/TestBrowser.mjs.map +1 -0
  160. package/dist/testing/TestModel.d.mts +133 -0
  161. package/dist/testing/TestModel.mjs +209 -0
  162. package/dist/testing/TestModel.mjs.map +1 -0
  163. package/dist/testing/TestPage.d.mts +2 -0
  164. package/dist/testing/TestPage.mjs +47 -0
  165. package/dist/testing/TestPage.mjs.map +1 -0
  166. package/dist/testing/index.d.mts +6 -337
  167. package/dist/testing/index.mjs +6 -515
  168. package/dist/timeline/Moment.d.mts +3 -0
  169. package/dist/timeline/Moment.mjs +3 -0
  170. package/dist/timeline/Stillness.d.mts +34 -0
  171. package/dist/timeline/Stillness.mjs +2 -0
  172. package/dist/timeline/index.d.mts +3 -0
  173. package/dist/timeline/index.mjs +3 -0
  174. package/dist/walk/Walk.d.mts +2 -0
  175. package/dist/walk/Walk.mjs +2 -0
  176. package/dist/walk/index.d.mts +2 -0
  177. package/dist/walk/index.mjs +2 -0
  178. package/package.json +54 -133
  179. package/src/Action.ts +73 -8
  180. package/src/Browser.ts +85 -14
  181. package/src/BrowserError.ts +258 -63
  182. package/src/BrowserEvent.ts +264 -48
  183. package/src/Cdp.ts +42 -0
  184. package/src/Change.ts +75 -4
  185. package/src/Frame.ts +247 -14
  186. package/src/{Style.ts → InputStyle.ts} +130 -18
  187. package/src/Layout.ts +187 -0
  188. package/src/Overlay.ts +76 -0
  189. package/src/Page.ts +144 -275
  190. package/src/PageTime.ts +72 -0
  191. package/src/Pose.ts +81 -0
  192. package/src/Site.ts +136 -0
  193. package/src/Snapshot.ts +179 -3
  194. package/src/Text.ts +60 -0
  195. package/src/Window.ts +53 -3
  196. package/src/ai/BrowserTools.ts +778 -0
  197. package/src/ai/PageControl.ts +702 -0
  198. package/src/ai/PromptCache.ts +87 -0
  199. package/src/ai/Tabs.ts +84 -0
  200. package/src/ai/ToolError.ts +50 -0
  201. package/src/ai/index.ts +36 -0
  202. package/src/ai/internal/crops.ts +38 -0
  203. package/src/ai/internal/points.ts +57 -0
  204. package/src/ai/internal/receipts.ts +107 -0
  205. package/src/index.ts +87 -6
  206. package/src/{ActionPort.ts → internal/action-port.ts} +3 -3
  207. package/src/{providers → internal/cdp}/connection.ts +19 -12
  208. package/src/internal/cdp/workerd.ts +36 -0
  209. package/src/{Clock.ts → internal/clock.ts} +20 -0
  210. package/src/internal/input/actions.ts +1 -1
  211. package/src/internal/input/dispatch.ts +2 -2
  212. package/src/internal/input/guard.inpage.ts +1 -1
  213. package/src/internal/input/guard.ts +1 -1
  214. package/src/internal/input/perform.ts +35 -7
  215. package/src/internal/input/pointer.ts +9 -6
  216. package/src/internal/input/targets.inpage.ts +3 -3
  217. package/src/internal/input/targets.ts +1 -1
  218. package/src/{Matching.ts → internal/matching.ts} +28 -19
  219. package/src/internal/page/bridge.ts +67 -35
  220. package/src/internal/page/clock.inpage.ts +306 -0
  221. package/src/internal/page/compose.inpage.ts +101 -0
  222. package/src/internal/page/context.ts +4 -2
  223. package/src/internal/page/functions.ts +84 -0
  224. package/src/internal/page/navigation.ts +1 -1
  225. package/src/internal/page/openings.ts +2 -2
  226. package/src/internal/page/overlay.inpage.ts +96 -0
  227. package/src/internal/page/overlay.ts +89 -0
  228. package/src/internal/page/page.ts +39 -29
  229. package/src/internal/page/port.ts +14 -8
  230. package/src/internal/page/pose.inpage.ts +200 -0
  231. package/src/internal/page/pose.ts +80 -0
  232. package/src/internal/page/replies.ts +1 -1
  233. package/src/internal/page/requests.ts +1 -1
  234. package/src/internal/page/scripts.ts +1 -1
  235. package/src/internal/page/time.inpage.ts +49 -0
  236. package/src/internal/page/time.ts +122 -0
  237. package/src/internal/page/viewport.ts +3 -2
  238. package/src/internal/pictures/capture.ts +1 -4
  239. package/src/internal/pictures/dimensions.ts +1 -1
  240. package/src/internal/pictures/frame.ts +1 -1
  241. package/src/internal/pictures/pictures.ts +144 -91
  242. package/src/internal/reading/context.inpage.ts +2 -2
  243. package/src/internal/reading/expect.inpage.ts +1 -1
  244. package/src/internal/reading/layout.inpage.ts +193 -0
  245. package/src/internal/reading/layout.ts +101 -0
  246. package/src/internal/reading/names.inpage.ts +15 -0
  247. package/src/internal/reading/outline.inpage.ts +5 -21
  248. package/src/internal/reading/reading.ts +33 -21
  249. package/src/internal/reading/ready.inpage.ts +21 -26
  250. package/src/internal/reading/ready.ts +26 -5
  251. package/src/internal/reading/subjects.inpage.ts +3 -3
  252. package/src/internal/reading/text.inpage.ts +3 -16
  253. package/src/internal/reading/walk.inpage.ts +1 -1
  254. package/src/internal/timeline/changes.inpage.ts +7 -15
  255. package/src/internal/timeline/changes.ts +17 -5
  256. package/src/internal/timeline/record.inpage.ts +15 -6
  257. package/src/internal/timeline/sight.inpage.ts +2 -2
  258. package/src/internal/timeline/window.ts +3 -4
  259. package/src/policy/Policy.ts +70 -16
  260. package/src/policy/index.ts +12 -0
  261. package/src/presentation/Film.ts +451 -0
  262. package/src/presentation/Motion.ts +45 -3
  263. package/src/presentation/Presentation.ts +60 -14
  264. package/src/presentation/Stage.ts +73 -35
  265. package/src/presentation/index.ts +30 -0
  266. package/src/presentation/{feed.ts → internal/feed.ts} +1 -1
  267. package/src/supervisor/Release.ts +45 -0
  268. package/src/supervisor/Supervisor.ts +80 -5
  269. package/src/supervisor/index.ts +18 -0
  270. package/src/supervisor/{contract.ts → internal/contract.ts} +14 -10
  271. package/src/supervisor/{lifecycle.ts → internal/lifecycle.ts} +7 -7
  272. package/src/supervisor/{runtime.ts → internal/runtime.ts} +7 -7
  273. package/src/testing/HttpCassette.ts +260 -0
  274. package/src/testing/Story.ts +103 -0
  275. package/src/testing/TestBrowser.ts +14 -4
  276. package/src/testing/TestModel.ts +297 -0
  277. package/src/testing/TestPage.ts +92 -4
  278. package/src/testing/index.ts +35 -1
  279. package/src/testing/{evidence.ts → internal/evidence.ts} +19 -11
  280. package/src/testing/{model.ts → internal/model.ts} +14 -8
  281. package/src/testing/{page.ts → internal/page.ts} +55 -51
  282. package/src/{moment → timeline}/Moment.ts +79 -29
  283. package/src/{stillness → timeline}/Stillness.ts +89 -46
  284. package/src/timeline/index.ts +18 -0
  285. package/src/{stillness/Pixels.ts → timeline/internal/pixels.ts} +27 -1
  286. package/src/{moment → timeline/internal}/words.ts +2 -2
  287. package/src/walk/Walk.ts +165 -0
  288. package/src/walk/index.ts +12 -0
  289. package/src/{plan → walk/internal}/choose.ts +23 -14
  290. package/src/{plan → walk/internal}/data.ts +37 -14
  291. package/src/{plan → walk/internal}/execute.ts +79 -36
  292. package/src/{plan → walk/internal}/record.ts +6 -6
  293. package/src/{plan → walk/internal}/targets.ts +35 -25
  294. package/dist/ActionPort.d.mts +0 -15
  295. package/dist/ActionPort.mjs.map +0 -1
  296. package/dist/Browser-BKPAbyys.mjs.map +0 -1
  297. package/dist/Change-Ba7INmay.d.mts +0 -69
  298. package/dist/Clock.d.mts +0 -57
  299. package/dist/Clock.mjs.map +0 -1
  300. package/dist/Frame-UEH2hO5T.d.mts +0 -124
  301. package/dist/Geometry.d.mts +0 -2
  302. package/dist/Geometry.mjs.map +0 -1
  303. package/dist/Matching.d.mts +0 -37
  304. package/dist/Matching.mjs.map +0 -1
  305. package/dist/Page-BF5izr8R.mjs.map +0 -1
  306. package/dist/Page-CvsOEorc.d.mts +0 -566
  307. package/dist/Released-tURbFmal.d.mts +0 -15
  308. package/dist/Snapshot-CtBVOtuu.d.mts +0 -73
  309. package/dist/Stillness-CNlvayIo.mjs +0 -136
  310. package/dist/Stillness-CNlvayIo.mjs.map +0 -1
  311. package/dist/Style-AO4V7Czt.mjs.map +0 -1
  312. package/dist/Style.d.mts +0 -72
  313. package/dist/Style.mjs +0 -2
  314. package/dist/Url.d.mts +0 -26
  315. package/dist/Url.mjs.map +0 -1
  316. package/dist/Window-CMddGMt1.d.mts +0 -34
  317. package/dist/connection-CK83pvqP.mjs.map +0 -1
  318. package/dist/moment/Moment.mjs.map +0 -1
  319. package/dist/plan/index.mjs.map +0 -1
  320. package/dist/presentation/Stage.mjs.map +0 -1
  321. package/dist/presentation/feed.d.mts +0 -20
  322. package/dist/presentation/feed.mjs +0 -18
  323. package/dist/presentation/feed.mjs.map +0 -1
  324. package/dist/providers/Cdp.d.mts +0 -9
  325. package/dist/providers/Cdp.mjs +0 -15
  326. package/dist/providers/Cdp.mjs.map +0 -1
  327. package/dist/providers/Chromium.d.mts +0 -32
  328. package/dist/providers/Chromium.mjs +0 -55
  329. package/dist/providers/Chromium.mjs.map +0 -1
  330. package/dist/providers/Released.d.mts +0 -2
  331. package/dist/providers/Released.mjs +0 -12
  332. package/dist/providers/Released.mjs.map +0 -1
  333. package/dist/stillness/Stillness.d.mts +0 -12
  334. package/dist/stillness/Stillness.mjs +0 -2
  335. package/dist/supervisor/Supervisor.mjs.map +0 -1
  336. package/dist/testing/index.mjs.map +0 -1
  337. package/dist/workerd/Cdp.d.mts +0 -8
  338. package/dist/workerd/Cdp.mjs +0 -13
  339. package/dist/workerd/Cdp.mjs.map +0 -1
  340. package/src/plan/index.ts +0 -36
  341. package/src/providers/Cdp.ts +0 -16
  342. package/src/providers/Chromium.ts +0 -99
  343. package/src/providers/Released.ts +0 -13
  344. package/src/workerd/Cdp.ts +0 -11
  345. /package/dist/{rolldown-runtime-D7D4PA-g.mjs → internal/rolldown-runtime-D7D4PA-g.mjs} +0 -0
  346. /package/src/{Geometry.ts → internal/geometry.ts} +0 -0
  347. /package/src/{Url.ts → internal/url.ts} +0 -0
  348. /package/src/{stillness → timeline/internal}/utilsBundle.d.ts +0 -0
@@ -0,0 +1,193 @@
1
+ /**
2
+ * In the page: where chosen things are. Each pick is a `find` query; of the elements it finds, one
3
+ * is chosen, and its box is read unrounded, with the boxes of words in it that the pick asks for,
4
+ * each from a `Range` over its text. A pick with a selector takes what the selector selects, an
5
+ * icon drawn in SVG among it, where `find`'s walk leaves drawings out. The viewport, the scroll and the scale are read in the same
6
+ * call, so the boxes and the scroll describe one moment. See `names.inpage.ts` for what a
7
+ * page-side part may use.
8
+ */
9
+ import type { FindRequest, Match, Wanted } from "../matching.ts";
10
+ import type { ContextReader } from "./context.inpage.ts";
11
+ import type { Names } from "./names.inpage.ts";
12
+ import type { Subjects } from "./subjects.inpage.ts";
13
+ import type { Walked } from "./walk.inpage.ts";
14
+
15
+ export interface PickRequest extends FindRequest {
16
+ readonly id: string;
17
+ readonly choose: "first" | "last" | "smallest" | "largest";
18
+ readonly words: Wanted | null;
19
+ }
20
+
21
+ export const layout = (
22
+ names: Names,
23
+ walked: Walked,
24
+ subjected: Subjects,
25
+ matching: Match,
26
+ placing: ContextReader,
27
+ ) => {
28
+ const { isDisabled, isOwn, nameOf, refFor, roleOf, textOf } = names;
29
+ const { boxOf, inView, visible } = walked;
30
+ // A pick's words are bounded, as a page's text is not.
31
+ const most = 200;
32
+
33
+ const area = (element: Element) => {
34
+ const { width, height } = element.getBoundingClientRect();
35
+
36
+ return width * height;
37
+ };
38
+
39
+ const chosen = (elements: ReadonlyArray<Element>, choose: PickRequest["choose"]) =>
40
+ choose === "first"
41
+ ? elements[0]
42
+ : choose === "last"
43
+ ? elements.at(-1)
44
+ : elements.reduce<Element | undefined>(
45
+ (best, element) =>
46
+ best === undefined ||
47
+ (choose === "smallest" ? area(element) < area(best) : area(element) > area(best))
48
+ ? element
49
+ : best,
50
+ undefined,
51
+ );
52
+
53
+ // Whether it keeps its place in the viewport as the page scrolls.
54
+ const fixed = (element: Element) => {
55
+ for (let at: Element | null = element; at !== null; at = at.parentElement)
56
+ if (getComputedStyle(at).position === "fixed") return true;
57
+
58
+ return false;
59
+ };
60
+
61
+ // Each match in the element's text, across the text nodes it is split into, with its box moved
62
+ // by `dx` and `dy` into the top document's viewport. A match that shows nothing is left out.
63
+ const words = (element: Element, wanted: Wanted, dx: number, dy: number) => {
64
+ // Each text node with where its text starts in the element's.
65
+ const parts: Array<{ readonly node: Node; readonly start: number }> = [];
66
+ let text = "";
67
+ const walker = element.ownerDocument.createTreeWalker(element, NodeFilter.SHOW_TEXT);
68
+
69
+ for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) {
70
+ parts.push({ node, start: text.length });
71
+ text += node.nodeValue ?? "";
72
+ }
73
+
74
+ const pattern =
75
+ typeof wanted === "string"
76
+ ? new RegExp(wanted.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "giu")
77
+ : new RegExp(wanted.source, wanted.flags.replace(/[gy]/g, "") + "g");
78
+
79
+ // The text node holding the character at `index`, or, for an end, the one ending at it.
80
+ const at = (index: number, end: boolean): [Node, number] => {
81
+ const part =
82
+ parts.findLast(({ start }) => (end ? start < index : start <= index)) ?? parts[0];
83
+
84
+ return part === undefined ? [element, 0] : [part.node, index - part.start];
85
+ };
86
+
87
+ const found: Array<{
88
+ text: string;
89
+ box: { x: number; y: number; width: number; height: number };
90
+ }> = [];
91
+
92
+ for (const match of text.matchAll(pattern)) {
93
+ if (found.length === most) break;
94
+ if (match[0] === "") continue;
95
+ const range = element.ownerDocument.createRange();
96
+
97
+ range.setStart(...at(match.index, false));
98
+ range.setEnd(...at(match.index + match[0].length, true));
99
+ const { x, y, width, height } = range.getBoundingClientRect();
100
+
101
+ if (width > 0 || height > 0)
102
+ found.push({ text: match[0], box: { x: x + dx, y: y + dy, width, height } });
103
+ }
104
+
105
+ return found;
106
+ };
107
+
108
+ // What a selector selects that shows and meets the pick's other rules, in tree order.
109
+ const selected = (pick: PickRequest & { readonly selector: string }) => {
110
+ let elements: Array<Element>;
111
+
112
+ try {
113
+ elements = Array.from(document.querySelectorAll(pick.selector));
114
+ } catch {
115
+ return { invalid: `${JSON.stringify(pick.selector)} is not a CSS selector` };
116
+ }
117
+ const rules = matching.compile(pick);
118
+
119
+ return elements.filter((element) => {
120
+ const role = roleOf(element, pick.role !== null);
121
+ const box = boxOf(element);
122
+
123
+ return (
124
+ !isOwn(element) &&
125
+ box.width * box.height > 0 &&
126
+ visible(element) &&
127
+ (pick.scope === "document" || inView(new DOMRect(box.x, box.y, box.width, box.height))) &&
128
+ (pick.state !== "enabled" || !isDisabled(element)) &&
129
+ rules({
130
+ role,
131
+ name: () => nameOf(element, role),
132
+ text: () => textOf(element),
133
+ context: () => placing.contextOf(element),
134
+ })
135
+ );
136
+ });
137
+ };
138
+
139
+ const read = (picks: ReadonlyArray<PickRequest>) => {
140
+ const places = [];
141
+ const missing: Array<string> = [];
142
+
143
+ for (const pick of picks) {
144
+ const elements =
145
+ pick.selector === null
146
+ ? subjected.elementsOf(pick)
147
+ : selected({ ...pick, selector: pick.selector });
148
+
149
+ if ("invalid" in elements) return { invalid: `${pick.id}: ${elements.invalid}` };
150
+ const element = chosen(elements, pick.choose);
151
+
152
+ if (element === undefined) {
153
+ missing.push(pick.id);
154
+ continue;
155
+ }
156
+ const role = roleOf(element, pick.role !== null);
157
+ const box = boxOf(element);
158
+ const own = element.getBoundingClientRect();
159
+
160
+ places.push({
161
+ id: pick.id,
162
+ ref: refFor(element),
163
+ subject: {
164
+ role,
165
+ name: nameOf(element, role),
166
+ tag: element.tagName.toLowerCase(),
167
+ context: placing.contextOf(element),
168
+ },
169
+ box,
170
+ fixed: fixed(element),
171
+ words:
172
+ pick.words === null
173
+ ? undefined
174
+ : words(element, pick.words, box.x - own.x, box.y - own.y),
175
+ });
176
+ }
177
+
178
+ return {
179
+ layout: {
180
+ url: location.href,
181
+ viewport: { width: innerWidth, height: innerHeight },
182
+ scroll: { x: scrollX, y: scrollY },
183
+ scale: devicePixelRatio,
184
+ places,
185
+ missing,
186
+ },
187
+ };
188
+ };
189
+
190
+ return { read };
191
+ };
192
+
193
+ export type Layouts = ReturnType<typeof layout>;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Reading where things are: `Layout.measure`, in one call to the page that takes its turn as other
3
+ * reads do and shares its work with identical ones. The page gives each place's viewport box; the
4
+ * document box is that box moved by the scroll read with it.
5
+ */
6
+ import { Effect, Schema } from "effect";
7
+
8
+ import { NotActionable } from "../../BrowserError.ts";
9
+ import { Box, Subject } from "../../BrowserEvent.ts";
10
+ import { Layout, type Picks, Place, Word } from "../../Layout.ts";
11
+ import { Point } from "../geometry.ts";
12
+ import { pickRequests } from "../matching.ts";
13
+ import { type Bridge, scriptCall } from "../page/bridge.ts";
14
+ import { contextGone, decodeWith, failWith, type PageContext, refuse } from "../page/context.ts";
15
+ import * as Url from "../url.ts";
16
+
17
+ // What `layout` reads back, before its document boxes are added.
18
+ const LayoutResult = Schema.Union([
19
+ Schema.Struct({
20
+ layout: Schema.Struct({
21
+ url: Schema.String,
22
+ viewport: Schema.Struct({ width: Schema.Finite, height: Schema.Finite }),
23
+ scroll: Point,
24
+ scale: Schema.Finite,
25
+ missing: Schema.Array(Schema.String),
26
+ places: Schema.Array(
27
+ Schema.Struct({
28
+ id: Schema.String,
29
+ ref: Schema.String,
30
+ subject: Subject,
31
+ box: Box,
32
+ fixed: Schema.Boolean,
33
+ words: Schema.optional(Schema.Array(Schema.Struct({ text: Schema.String, box: Box }))),
34
+ }),
35
+ ),
36
+ }),
37
+ }),
38
+ Schema.Struct({ invalid: Schema.String }),
39
+ ]);
40
+
41
+ export const make = (page: PageContext, bridge: Bridge) => {
42
+ const { now, span, owned, within, lane } = page;
43
+ const { evaluate } = bridge;
44
+ const layouts = lane.shared<Layout>("layout", true);
45
+
46
+ const layout = (picks: Picks) => {
47
+ const asked = pickRequests(picks);
48
+
49
+ // The boxes and the scroll describe the document the call ran in, which is the one current
50
+ // before and after it; a document that replaced it meanwhile is read again, once.
51
+ const once = Effect.gen(function* () {
52
+ const before = bridge.frameTag().document;
53
+
54
+ const result = yield* evaluate("layout", scriptCall("layout", asked)).pipe(
55
+ Effect.flatMap(decodeWith("layout", LayoutResult)),
56
+ );
57
+
58
+ if ("invalid" in result) return yield* refuse("layout", result.invalid);
59
+ if (bridge.frameTag().document !== before)
60
+ return yield* failWith(
61
+ "layout",
62
+ new NotActionable({ detail: "the page's document changed while it was read" }),
63
+ );
64
+ const { places, scroll, ...read } = result.layout;
65
+ const moved = (box: Box) => ({ ...box, x: box.x + scroll.x, y: box.y + scroll.y });
66
+
67
+ return new Layout({
68
+ ...read,
69
+ url: Url.redact(read.url),
70
+ page: page.id,
71
+ connection: page.connection,
72
+ document: before,
73
+ at: now(),
74
+ scroll,
75
+ places: places.map(
76
+ ({ words, ...place }) =>
77
+ new Place({
78
+ ...place,
79
+ page: moved(place.box),
80
+ words: words?.map((word) => new Word({ ...word, page: moved(word.box) })),
81
+ }),
82
+ ),
83
+ });
84
+ });
85
+
86
+ return layouts(
87
+ JSON.stringify(asked),
88
+ once.pipe(
89
+ Effect.retry({
90
+ times: 1,
91
+ while: (error) =>
92
+ contextGone(error) ||
93
+ (error.reason._tag === "NotActionable" && error.operation === "layout"),
94
+ }),
95
+ within("layout"),
96
+ ),
97
+ ).pipe(span("Layout.measure", { picks: asked.length }), owned);
98
+ };
99
+
100
+ return layout;
101
+ };
@@ -45,6 +45,19 @@ export const elements = () => {
45
45
  isTextArea(element) ||
46
46
  (isHtml(element) && element.isContentEditable);
47
47
 
48
+ // What the library itself puts in the page, such as its overlay's host. A reader that selects by
49
+ // CSS leaves it out; the walk finds nothing in it, since it never enters a closed shadow root.
50
+ const own = new WeakSet<Node>();
51
+
52
+ const adopt = (node: Node) => own.add(node);
53
+
54
+ /** Whether a node is the library's own, or inside a shadow root of one of its own. */
55
+ const isOwn = (node: Node): boolean => {
56
+ const root = node.getRootNode();
57
+
58
+ return own.has(node) || (root instanceof ShadowRoot && own.has(root.host));
59
+ };
60
+
48
61
  const clean = (value: string | null | undefined, max = 160): string => {
49
62
  const text = (value ?? "").replace(/\s+/g, " ").trim();
50
63
 
@@ -52,6 +65,7 @@ export const elements = () => {
52
65
  };
53
66
 
54
67
  return {
68
+ adopt,
55
69
  clean,
56
70
  isInput,
57
71
  isTextArea,
@@ -63,6 +77,7 @@ export const elements = () => {
63
77
  textOf,
64
78
  isElement,
65
79
  isDocument,
80
+ isOwn,
66
81
  textEntry,
67
82
  };
68
83
  };
@@ -2,15 +2,15 @@
2
2
  * In the page: the outline a model reads, with a ref for each control. See `names.inpage.ts` for
3
3
  * what a page-side part may use.
4
4
  */
5
- import { Schema } from "effect";
6
5
 
7
- import { type Control, Snapshot } from "../../Snapshot.ts";
8
- import type { addresses } from "../../Url.ts";
6
+ import type { Control } from "../../Snapshot.ts";
7
+ import type { addresses } from "../url.ts";
9
8
  import type { Controls } from "./controls.inpage.ts";
10
9
  import type { Names } from "./names.inpage.ts";
10
+ import type { SnapshotResult } from "./reading.ts";
11
11
  import type { Subjects } from "./subjects.inpage.ts";
12
12
  import type { Texts } from "./text.inpage.ts";
13
- import type { Walk } from "./walk.inpage.ts";
13
+ import type { Walked } from "./walk.inpage.ts";
14
14
 
15
15
  export interface SnapshotRequest {
16
16
  readonly full: boolean;
@@ -22,18 +22,12 @@ export interface SnapshotRequest {
22
22
  readonly boxes: boolean;
23
23
  }
24
24
 
25
- /**
26
- * The outline as a `Snapshot` reads it, and the next ref the page may give, or why `within` is not
27
- * a selector.
28
- */
29
- export type SnapshotResult = typeof SnapshotResultSchema.Encoded;
30
-
31
25
  /** The rule every address the library reports goes by, which a link's address goes by too. */
32
26
  type Url = ReturnType<typeof addresses>;
33
27
 
34
28
  export const outline = (
35
29
  names: Names,
36
- walked: Walk,
30
+ walked: Walked,
37
31
  subjects: Subjects,
38
32
  texts: Texts,
39
33
  controlling: Controls,
@@ -250,13 +244,3 @@ export const outline = (
250
244
  };
251
245
 
252
246
  export type Outline = ReturnType<typeof outline>;
253
-
254
- export const SnapshotResultSchema = Schema.Union([
255
- Schema.Struct({ snapshot: Snapshot }),
256
- Schema.Struct({ invalid: Schema.String }),
257
- ]);
258
-
259
- export const ViewportResultSchema = Schema.Struct({
260
- width: Schema.Finite,
261
- height: Schema.Finite,
262
- });
@@ -1,20 +1,40 @@
1
1
  /**
2
2
  * Reading a page: its outline with refs, the elements a query finds and the text it shows. Each
3
3
  * read takes its turn on the page and shares its work with identical reads, as `lane.ts`
4
- * describes. The viewport's text as it was last read is kept, for `Page.state`.
4
+ * describes.
5
5
  */
6
6
  import { Duration, Effect, Schedule, Schema } from "effect";
7
7
 
8
8
  import { StaleRef } from "../../BrowserError.ts";
9
- import { request as askedOf, type FindRequest } from "../../Matching.ts";
10
- import { type FindQuery, Found, Text, type TextOptions } from "../../Page.ts";
11
- import { Snapshot, type SnapshotOptions } from "../../Snapshot.ts";
12
- import * as Url from "../../Url.ts";
9
+ import { type FindQuery, Found, Snapshot, type SnapshotOptions } from "../../Snapshot.ts";
10
+ import { Text, type TextOptions } from "../../Text.ts";
11
+ import { request as askedOf, type FindRequest } from "../matching.ts";
13
12
  import { type Bridge, scriptCall } from "../page/bridge.ts";
14
13
  import { contextGone, decodeWith, failWith, type PageContext, refuse } from "../page/context.ts";
14
+ import * as Url from "../url.ts";
15
15
  import type { Want } from "./expect.inpage.ts";
16
- import { type SnapshotRequest, SnapshotResultSchema } from "./outline.inpage.ts";
17
- import { type TextRequest, TextResultSchema } from "./text.inpage.ts";
16
+ import type { SnapshotRequest } from "./outline.inpage.ts";
17
+ import type { TextRequest } from "./text.inpage.ts";
18
+
19
+ /** The outline as a `Snapshot` reads it, or why `within` is not a selector. */
20
+ const SnapshotResultSchema = Schema.Union([
21
+ Schema.Struct({ snapshot: Snapshot }),
22
+ Schema.Struct({ invalid: Schema.String }),
23
+ ]);
24
+
25
+ export type SnapshotResult = typeof SnapshotResultSchema.Encoded;
26
+
27
+ /** What `text` sends back, or null when its ref no longer names an element. */
28
+ const TextResultSchema = Schema.NullOr(
29
+ Schema.Struct({
30
+ text: Schema.String,
31
+ truncated: Schema.Boolean,
32
+ url: Schema.String,
33
+ title: Schema.String,
34
+ }),
35
+ );
36
+
37
+ export type TextResult = typeof TextResultSchema.Type;
18
38
 
19
39
  // What `find` reads back. The bridge envelope owns ref allocation across documents.
20
40
  const FindResults = Schema.Union([
@@ -34,7 +54,6 @@ export const make = (page: PageContext, bridge: Bridge) =>
34
54
  const snapshots = lane.shared<Snapshot>("snapshot", true);
35
55
  const finds = lane.shared<ReadonlyArray<Found>>("find", true);
36
56
  const texts = lane.shared<Text>("text", true);
37
- let viewed: Text | undefined;
38
57
 
39
58
  const snapshot = (snapshotOptions: SnapshotOptions = {}) => {
40
59
  const asked = {
@@ -61,7 +80,7 @@ export const make = (page: PageContext, bridge: Bridge) =>
61
80
 
62
81
  return new Snapshot({ ...result.snapshot, url: Url.redact(url) });
63
82
  }).pipe(within("snapshot")),
64
- ).pipe(span("Page.snapshot", { full: asked.full }), owned);
83
+ ).pipe(span("Snapshot.read", { full: asked.full }), owned);
65
84
  };
66
85
 
67
86
  const find = (query: FindQuery = {}) => {
@@ -84,7 +103,7 @@ export const make = (page: PageContext, bridge: Bridge) =>
84
103
  }).pipe(within("find")),
85
104
  ).pipe(
86
105
  // The query's words are the caller's, and may be anything; only its shape is traced.
87
- span("Page.find", { scope: asked.scope, role: asked.role ?? "" }),
106
+ span("Snapshot.find", { scope: asked.scope, role: asked.role ?? "" }),
88
107
  owned,
89
108
  );
90
109
  };
@@ -113,14 +132,11 @@ export const make = (page: PageContext, bridge: Bridge) =>
113
132
  chars: result.text.length,
114
133
  truncated: result.truncated,
115
134
  });
116
- const shown = new Text({ ...result, url: Url.redact(result.url), at: now() });
117
135
 
118
- if (request.ref === null) viewed = shown;
119
-
120
- return shown;
136
+ return new Text({ ...result, url: Url.redact(result.url), at: now() });
121
137
  }).pipe(within("text")),
122
138
  )
123
- ).pipe(span("Page.text", { scope: scope === "viewport" ? "viewport" : "ref" }), owned);
139
+ ).pipe(span("Text.read", { scope: scope === "viewport" ? "viewport" : "ref" }), owned);
124
140
  };
125
141
 
126
142
  // One call, which the page answers once `want` holds of what `query` matches, the whole document
@@ -161,16 +177,12 @@ export const make = (page: PageContext, bridge: Bridge) =>
161
177
  .pipe(
162
178
  Effect.andThen(look),
163
179
  within("expect", Duration.sum(Duration.millis(millis), page.settings.actionTimeout)),
164
- span("Page.expect", { want: typeof want === "string" ? want : "other" }),
180
+ span("Snapshot.until", { want: typeof want === "string" ? want : "other" }),
165
181
  owned,
166
182
  );
167
183
  };
168
184
 
169
- /** The viewport's text as it was last read, if after `since`, as a document began. */
170
- const viewedSince = (since: number) =>
171
- viewed !== undefined && viewed.at > since ? viewed : undefined;
172
-
173
- return { snapshot, find, text, until, viewedSince };
185
+ return { snapshot, find, text, until };
174
186
  });
175
187
 
176
188
  export type Reading = Effect.Success<ReturnType<typeof make>>;
@@ -6,31 +6,16 @@
6
6
  * frame. So a canvas mounted blank, or a spinner alone, is still loading. A screen that only says
7
7
  * "Loading…" in words reads as ready, and a WebGL canvas drawn once, without keeping its drawing,
8
8
  * reads as blank. Asked for a quiet spell, where the page's changes are recorded, nothing in view
9
- * may have changed for that long either. After input, it waits a task and a frame. See `names.inpage.ts` for what a page-side part may use.
9
+ * may have changed for that long either. On a page whose time is held (see `clock.inpage.ts`), an
10
+ * animation paused part way is still animating: held time has yet to finish it. After input, it
11
+ * waits a task and a frame. See `names.inpage.ts` for what a page-side part may use.
10
12
  */
11
- import { Schema } from "effect";
12
-
13
13
  import type { History } from "../timeline/history.inpage.ts";
14
+ import type { Readiness } from "./ready.ts";
14
15
  import type { Texts } from "./text.inpage.ts";
15
- import type { Walk } from "./walk.inpage.ts";
16
-
17
- /** What the page is still waiting for; none when it is ready. */
18
- export const ReadinessSchema = Schema.Array(
19
- Schema.Literals([
20
- "load",
21
- "paint",
22
- "animations",
23
- "images",
24
- "fonts",
25
- "busy",
26
- "content",
27
- "changing",
28
- ]),
29
- );
30
-
31
- export type Readiness = typeof ReadinessSchema.Type;
32
-
33
- export const ready = (walked: Walk, texts: Texts, kept: History) => {
16
+ import type { Walked } from "./walk.inpage.ts";
17
+
18
+ export const ready = (walked: Walked, texts: Texts, kept: History) => {
34
19
  const { inView, visible } = walked;
35
20
  // A canvas is read through a small copy: reading it directly would give it a context of ours.
36
21
  let copy: OffscreenCanvasRenderingContext2D | null | undefined;
@@ -85,10 +70,16 @@ export const ready = (walked: Walk, texts: Texts, kept: History) => {
85
70
  };
86
71
 
87
72
  // In a frame, before it is drawn: a canvas drawn every frame still holds its drawing then.
88
- const check = (quietMillis: number): Promise<Readiness> =>
73
+ const check = (quietMillis: number, clock: string | null): Promise<Readiness> =>
89
74
  painted().then((paints) => {
90
75
  const waiting: Array<Readiness[number]> = [];
91
76
 
77
+ const held =
78
+ clock !== null &&
79
+ !document.dispatchEvent(
80
+ new CustomEvent(clock, { detail: { op: "holds" }, cancelable: true }),
81
+ );
82
+
92
83
  if (document.readyState === "loading") waiting.push("load");
93
84
  if (!paints) waiting.push("paint");
94
85
  // An endless animation, such as a pulsing dot, never ends, so only those that end count.
@@ -97,7 +88,7 @@ export const ready = (walked: Walk, texts: Texts, kept: History) => {
97
88
  const effect = animation.effect;
98
89
 
99
90
  return (
100
- animation.playState === "running" &&
91
+ (animation.playState === "running" || (held && animation.playState === "paused")) &&
101
92
  effect !== null &&
102
93
  Number.isFinite(effect.getComputedTiming().endTime) &&
103
94
  "target" in effect &&
@@ -122,11 +113,15 @@ export const ready = (walked: Walk, texts: Texts, kept: History) => {
122
113
  * Check until the page is ready, or for `millis`, and say what it is still waiting for; with
123
114
  * `quietMillis`, until nothing the record saw in view has changed for that long, too.
124
115
  */
125
- const wait = async (millis: number, quietMillis = 0): Promise<Readiness> => {
116
+ const wait = async (
117
+ millis: number,
118
+ quietMillis = 0,
119
+ clock: string | null = null,
120
+ ): Promise<Readiness> => {
126
121
  const until = performance.now() + millis;
127
122
 
128
123
  for (;;) {
129
- const waiting = await check(quietMillis);
124
+ const waiting = await check(quietMillis, clock);
130
125
 
131
126
  if (waiting.length === 0 || performance.now() >= until) return waiting;
132
127
  const { promise, resolve } = Promise.withResolvers<void>();
@@ -1,19 +1,35 @@
1
1
  /** Document readiness and content quiet, independent of screen-capture features. */
2
- import { Duration, Effect, Schedule } from "effect";
2
+ import { Duration, Effect, Schedule, Schema } from "effect";
3
3
 
4
4
  import { Timeout, failWith, refuse } from "../../BrowserError.ts";
5
5
  import type { ReadyOptions } from "../../Page.ts";
6
+ import { millisOf } from "../clock.ts";
6
7
  import { type Bridge, scriptCall } from "../page/bridge.ts";
7
8
  import { contextGone, decodeWith, type PageContext } from "../page/context.ts";
8
- import { ReadinessSchema } from "./ready.inpage.ts";
9
+
10
+ /** What the page is still waiting for; none when it is ready. */
11
+ const ReadinessSchema = Schema.Array(
12
+ Schema.Literals([
13
+ "load",
14
+ "paint",
15
+ "animations",
16
+ "images",
17
+ "fonts",
18
+ "busy",
19
+ "content",
20
+ "changing",
21
+ ]),
22
+ );
23
+
24
+ export type Readiness = typeof ReadinessSchema.Type;
9
25
 
10
26
  export const make =
11
27
  (page: PageContext, bridge: Bridge) =>
12
28
  (options: ReadyOptions = {}) => {
13
- const quietMillis = options.quietMillis ?? 0;
29
+ const quietMillis = millisOf(options.quiet ?? 0);
14
30
 
15
31
  if (!Number.isFinite(quietMillis) || quietMillis < 0)
16
- return refuse("ready", "quietMillis must be finite and nonnegative");
32
+ return refuse("ready", "quiet must be a finite nonnegative duration");
17
33
  const timeout = options.timeout ?? Duration.seconds(15);
18
34
 
19
35
  // The page's own evidence, checked in the page until nothing is left or `until` has come.
@@ -21,7 +37,12 @@ export const make =
21
37
  Effect.suspend(() =>
22
38
  bridge.evaluate(
23
39
  "ready",
24
- scriptCall("ready", Math.max(0, Math.round(until - page.now())), quietMillis),
40
+ scriptCall(
41
+ "ready",
42
+ Math.max(0, Math.round(until - page.now())),
43
+ quietMillis,
44
+ page.settings.pageTime ?? null,
45
+ ),
25
46
  ),
26
47
  ).pipe(
27
48
  Effect.retry({ while: contextGone, schedule: Schedule.spaced(Duration.millis(10)) }),
@@ -4,10 +4,10 @@
4
4
  * beside it. See `names.inpage.ts` for what a page-side part may use.
5
5
  */
6
6
  import type { SubjectContext } from "../../BrowserEvent.ts";
7
- import type { FindRequest, Match } from "../../Matching.ts";
7
+ import type { FindRequest, Match } from "../matching.ts";
8
8
  import type { ContextReader } from "./context.inpage.ts";
9
9
  import type { Names } from "./names.inpage.ts";
10
- import type { Walk } from "./walk.inpage.ts";
10
+ import type { Walked } from "./walk.inpage.ts";
11
11
 
12
12
  export const states = (names: Names) => (element: Element, role: string | null) => {
13
13
  const { isDisabled, isInput } = names;
@@ -44,7 +44,7 @@ export const states = (names: Names) => (element: Element, role: string | null)
44
44
 
45
45
  export const subjects = (
46
46
  names: Names,
47
- walked: Walk,
47
+ walked: Walked,
48
48
  matching: Match,
49
49
  placing: ContextReader,
50
50
  stateOf: ReturnType<typeof states>,