effect-browser 0.3.0-beta.24 → 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 (345) hide show
  1. package/README.md +333 -157
  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 +1 -1
  11. package/dist/BrowserEvent.mjs +166 -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 +33 -6
  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/{Style.d.mts → InputStyle.d.mts} +93 -25
  23. package/dist/{Style.mjs → InputStyle.mjs} +1 -1
  24. package/dist/Layout.d.mts +2 -2
  25. package/dist/Layout.mjs +58 -16
  26. package/dist/Layout.mjs.map +1 -1
  27. package/dist/Overlay.d.mts +2 -2
  28. package/dist/Overlay.mjs +33 -5
  29. package/dist/Overlay.mjs.map +1 -1
  30. package/dist/Page.d.mts +2 -2
  31. package/dist/Page.mjs +2 -2
  32. package/dist/PageTime.d.mts +2 -2
  33. package/dist/PageTime.mjs +13 -3
  34. package/dist/PageTime.mjs.map +1 -1
  35. package/dist/Pose.d.mts +2 -2
  36. package/dist/Pose.mjs +30 -9
  37. package/dist/Pose.mjs.map +1 -1
  38. package/dist/Site.d.mts +288 -18
  39. package/dist/Site.mjs +11 -3
  40. package/dist/Site.mjs.map +1 -1
  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 -18
  66. package/dist/index.mjs +6 -9
  67. package/dist/{Action-24sLOubi.d.mts → internal/Action-CkanNTUw.d.mts} +64 -4
  68. package/dist/{Browser-DGR6ZEYo.d.mts → internal/Browser-DD9Vm1c-.d.mts} +75 -11
  69. package/dist/{Browser-CAQFhTkM.mjs → internal/Browser-vzD7i2oj.mjs} +174 -237
  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-C2p-NwuU.d.mts → internal/BrowserEvent-tGPYYf6R.d.mts} +168 -13
  73. package/dist/internal/BrowserTools-Yi3lOX4h.mjs +497 -0
  74. package/dist/internal/BrowserTools-Yi3lOX4h.mjs.map +1 -0
  75. package/dist/{Style-T3ezDYLI.mjs → internal/InputStyle-CPzxoN4g.mjs} +75 -20
  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} +53 -20
  80. package/dist/internal/Page-BfGxn7oN.d.mts +1553 -0
  81. package/dist/{Page-BaAOshxo.mjs → internal/Page-DqF-tuTx.mjs} +62 -74
  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-Db-YtlbE.d.mts → internal/connection-BaB0vp1o.d.mts} +6 -6
  106. package/dist/{connection-C_jWYIwe.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-uhrT-dOB.mjs +49 -0
  111. package/dist/internal/fold.inpage-uhrT-dOB.mjs.map +1 -0
  112. package/dist/internal/functions-jBOs6GKv.mjs +27 -0
  113. package/dist/internal/functions-jBOs6GKv.mjs.map +1 -0
  114. package/dist/{Geometry-DJx9qrYy.d.mts → internal/geometry-Dhj_ztJs.d.mts} +3 -3
  115. package/dist/{Geometry.mjs → internal/geometry-Lxyflb9J.mjs} +3 -12
  116. package/dist/internal/geometry-Lxyflb9J.mjs.map +1 -0
  117. package/dist/{Matching.mjs → internal/matching-Cs-UeOY0.mjs} +3 -3
  118. package/dist/internal/matching-Cs-UeOY0.mjs.map +1 -0
  119. package/dist/internal/page-DFQb-YOK.mjs +436 -0
  120. package/dist/internal/page-DFQb-YOK.mjs.map +1 -0
  121. package/dist/{pose.inpage-CLq7Mfdr.mjs → internal/pose.inpage-CBFeWcVa.mjs} +2 -48
  122. package/dist/internal/pose.inpage-CBFeWcVa.mjs.map +1 -0
  123. package/dist/{Url.mjs → internal/url-DB0pQYk6.mjs} +3 -12
  124. package/dist/internal/url-DB0pQYk6.mjs.map +1 -0
  125. package/dist/policy/Policy.d.mts +60 -6
  126. package/dist/policy/Policy.mjs +52 -9
  127. package/dist/policy/Policy.mjs.map +1 -1
  128. package/dist/policy/index.d.mts +2 -0
  129. package/dist/policy/index.mjs +2 -0
  130. package/dist/{film → presentation}/Film.d.mts +83 -16
  131. package/dist/{film → presentation}/Film.mjs +82 -30
  132. package/dist/presentation/Film.mjs.map +1 -0
  133. package/dist/presentation/Motion.d.mts +5 -1
  134. package/dist/presentation/Motion.mjs +16 -2
  135. package/dist/presentation/Motion.mjs.map +1 -1
  136. package/dist/presentation/Presentation.d.mts +42 -7
  137. package/dist/presentation/Presentation.mjs +26 -9
  138. package/dist/presentation/Presentation.mjs.map +1 -1
  139. package/dist/presentation/Stage.d.mts +40 -6
  140. package/dist/presentation/Stage.mjs +1 -262
  141. package/dist/presentation/index.d.mts +5 -0
  142. package/dist/presentation/index.mjs +5 -0
  143. package/dist/supervisor/Release.d.mts +2 -0
  144. package/dist/supervisor/Release.mjs +40 -0
  145. package/dist/supervisor/Release.mjs.map +1 -0
  146. package/dist/supervisor/Supervisor.d.mts +2 -104
  147. package/dist/supervisor/Supervisor.mjs +2 -515
  148. package/dist/supervisor/index.d.mts +3 -0
  149. package/dist/supervisor/index.mjs +3 -0
  150. package/dist/testing/HttpCassette.d.mts +98 -0
  151. package/dist/testing/HttpCassette.mjs +146 -0
  152. package/dist/testing/HttpCassette.mjs.map +1 -0
  153. package/dist/testing/Story.d.mts +31 -0
  154. package/dist/testing/Story.mjs +76 -0
  155. package/dist/testing/Story.mjs.map +1 -0
  156. package/dist/testing/TestBrowser.d.mts +191 -0
  157. package/dist/testing/TestBrowser.mjs +105 -0
  158. package/dist/testing/TestBrowser.mjs.map +1 -0
  159. package/dist/testing/TestModel.d.mts +133 -0
  160. package/dist/testing/TestModel.mjs +209 -0
  161. package/dist/testing/TestModel.mjs.map +1 -0
  162. package/dist/testing/TestPage.d.mts +2 -0
  163. package/dist/testing/TestPage.mjs +47 -0
  164. package/dist/testing/TestPage.mjs.map +1 -0
  165. package/dist/testing/index.d.mts +6 -311
  166. package/dist/testing/index.mjs +6 -521
  167. package/dist/timeline/Moment.d.mts +3 -0
  168. package/dist/timeline/Moment.mjs +3 -0
  169. package/dist/timeline/Stillness.d.mts +34 -0
  170. package/dist/timeline/Stillness.mjs +2 -0
  171. package/dist/timeline/index.d.mts +3 -0
  172. package/dist/timeline/index.mjs +3 -0
  173. package/dist/walk/Walk.d.mts +2 -0
  174. package/dist/walk/Walk.mjs +2 -0
  175. package/dist/walk/index.d.mts +2 -0
  176. package/dist/walk/index.mjs +2 -0
  177. package/package.json +54 -163
  178. package/src/Action.ts +73 -8
  179. package/src/Browser.ts +75 -9
  180. package/src/BrowserError.ts +258 -63
  181. package/src/BrowserEvent.ts +252 -55
  182. package/src/Cdp.ts +42 -0
  183. package/src/Change.ts +68 -3
  184. package/src/Frame.ts +247 -14
  185. package/src/{Style.ts → InputStyle.ts} +98 -22
  186. package/src/Layout.ts +95 -24
  187. package/src/Overlay.ts +42 -3
  188. package/src/Page.ts +144 -320
  189. package/src/PageTime.ts +29 -4
  190. package/src/Pose.ts +38 -7
  191. package/src/Site.ts +15 -3
  192. package/src/Snapshot.ts +179 -3
  193. package/src/Text.ts +60 -0
  194. package/src/Window.ts +53 -3
  195. package/src/ai/BrowserTools.ts +778 -0
  196. package/src/ai/PageControl.ts +702 -0
  197. package/src/ai/PromptCache.ts +87 -0
  198. package/src/ai/Tabs.ts +84 -0
  199. package/src/ai/ToolError.ts +50 -0
  200. package/src/ai/index.ts +36 -0
  201. package/src/ai/internal/crops.ts +38 -0
  202. package/src/ai/internal/points.ts +57 -0
  203. package/src/ai/internal/receipts.ts +107 -0
  204. package/src/index.ts +83 -6
  205. package/src/{ActionPort.ts → internal/action-port.ts} +3 -3
  206. package/src/{providers → internal/cdp}/connection.ts +19 -12
  207. package/src/internal/cdp/workerd.ts +36 -0
  208. package/src/{Clock.ts → internal/clock.ts} +20 -0
  209. package/src/internal/input/actions.ts +1 -1
  210. package/src/internal/input/dispatch.ts +2 -2
  211. package/src/internal/input/guard.inpage.ts +1 -1
  212. package/src/internal/input/guard.ts +1 -1
  213. package/src/internal/input/perform.ts +5 -5
  214. package/src/internal/input/pointer.ts +2 -2
  215. package/src/internal/input/targets.inpage.ts +3 -3
  216. package/src/{Matching.ts → internal/matching.ts} +6 -6
  217. package/src/internal/page/bridge.ts +2 -2
  218. package/src/internal/page/clock.inpage.ts +1 -1
  219. package/src/internal/page/compose.inpage.ts +2 -2
  220. package/src/internal/page/context.ts +2 -2
  221. package/src/internal/page/functions.ts +84 -0
  222. package/src/internal/page/navigation.ts +1 -1
  223. package/src/internal/page/openings.ts +2 -2
  224. package/src/internal/page/page.ts +33 -35
  225. package/src/internal/page/port.ts +14 -8
  226. package/src/internal/page/replies.ts +1 -1
  227. package/src/internal/page/requests.ts +1 -1
  228. package/src/internal/page/scripts.ts +1 -1
  229. package/src/internal/page/time.ts +1 -1
  230. package/src/internal/pictures/capture.ts +1 -4
  231. package/src/internal/pictures/dimensions.ts +1 -1
  232. package/src/internal/pictures/frame.ts +1 -1
  233. package/src/internal/pictures/pictures.ts +53 -61
  234. package/src/internal/reading/context.inpage.ts +2 -2
  235. package/src/internal/reading/expect.inpage.ts +1 -1
  236. package/src/internal/reading/layout.inpage.ts +3 -3
  237. package/src/internal/reading/layout.ts +5 -5
  238. package/src/internal/reading/outline.inpage.ts +3 -3
  239. package/src/internal/reading/reading.ts +11 -19
  240. package/src/internal/reading/ready.inpage.ts +2 -2
  241. package/src/internal/reading/ready.ts +3 -2
  242. package/src/internal/reading/subjects.inpage.ts +3 -3
  243. package/src/internal/reading/text.inpage.ts +2 -2
  244. package/src/internal/reading/walk.inpage.ts +1 -1
  245. package/src/internal/timeline/changes.inpage.ts +2 -2
  246. package/src/internal/timeline/changes.ts +3 -4
  247. package/src/internal/timeline/sight.inpage.ts +2 -2
  248. package/src/internal/timeline/window.ts +3 -4
  249. package/src/policy/Policy.ts +70 -16
  250. package/src/policy/index.ts +12 -0
  251. package/src/{film → presentation}/Film.ts +104 -37
  252. package/src/presentation/Motion.ts +45 -3
  253. package/src/presentation/Presentation.ts +47 -14
  254. package/src/presentation/Stage.ts +73 -35
  255. package/src/presentation/index.ts +30 -0
  256. package/src/presentation/{feed.ts → internal/feed.ts} +1 -1
  257. package/src/supervisor/Release.ts +45 -0
  258. package/src/supervisor/Supervisor.ts +80 -5
  259. package/src/supervisor/index.ts +18 -0
  260. package/src/supervisor/{contract.ts → internal/contract.ts} +14 -10
  261. package/src/supervisor/{lifecycle.ts → internal/lifecycle.ts} +7 -7
  262. package/src/supervisor/{runtime.ts → internal/runtime.ts} +7 -7
  263. package/src/testing/HttpCassette.ts +260 -0
  264. package/src/testing/Story.ts +103 -0
  265. package/src/testing/TestBrowser.ts +14 -4
  266. package/src/testing/TestModel.ts +297 -0
  267. package/src/testing/TestPage.ts +92 -4
  268. package/src/testing/index.ts +35 -1
  269. package/src/testing/{evidence.ts → internal/evidence.ts} +19 -11
  270. package/src/testing/{model.ts → internal/model.ts} +14 -8
  271. package/src/testing/{page.ts → internal/page.ts} +55 -56
  272. package/src/{moment → timeline}/Moment.ts +79 -29
  273. package/src/{stillness → timeline}/Stillness.ts +61 -43
  274. package/src/timeline/index.ts +18 -0
  275. package/src/{stillness/Pixels.ts → timeline/internal/pixels.ts} +2 -2
  276. package/src/{moment → timeline/internal}/words.ts +2 -2
  277. package/src/walk/Walk.ts +165 -0
  278. package/src/walk/index.ts +12 -0
  279. package/src/{plan → walk/internal}/choose.ts +23 -14
  280. package/src/{plan → walk/internal}/data.ts +37 -14
  281. package/src/{plan → walk/internal}/execute.ts +79 -36
  282. package/src/{plan → walk/internal}/record.ts +6 -6
  283. package/src/{plan → walk/internal}/targets.ts +35 -25
  284. package/dist/ActionPort.d.mts +0 -15
  285. package/dist/ActionPort.mjs.map +0 -1
  286. package/dist/Browser-CAQFhTkM.mjs.map +0 -1
  287. package/dist/Change-CxT1mp2e.d.mts +0 -80
  288. package/dist/Clock-Du5nP-nK.d.mts +0 -57
  289. package/dist/Clock.d.mts +0 -2
  290. package/dist/Clock.mjs.map +0 -1
  291. package/dist/Frame-UEH2hO5T.d.mts +0 -124
  292. package/dist/Geometry.d.mts +0 -2
  293. package/dist/Geometry.mjs.map +0 -1
  294. package/dist/Matching-MtcWZ_hA.d.mts +0 -266
  295. package/dist/Matching.d.mts +0 -2
  296. package/dist/Matching.mjs.map +0 -1
  297. package/dist/Overlay-CoGw5tL_.d.mts +0 -27
  298. package/dist/Page-BaAOshxo.mjs.map +0 -1
  299. package/dist/Page-CLzh5E9w.d.mts +0 -718
  300. package/dist/PageTime-68UPUZpZ.d.mts +0 -29
  301. package/dist/Pose-2qqGzPvb.d.mts +0 -32
  302. package/dist/Released-tURbFmal.d.mts +0 -15
  303. package/dist/Snapshot-CtBVOtuu.d.mts +0 -73
  304. package/dist/Stillness-BwP0RdI4.mjs +0 -157
  305. package/dist/Stillness-BwP0RdI4.mjs.map +0 -1
  306. package/dist/Style-T3ezDYLI.mjs.map +0 -1
  307. package/dist/Url-B7P-TWwL.d.mts +0 -26
  308. package/dist/Url.d.mts +0 -2
  309. package/dist/Url.mjs.map +0 -1
  310. package/dist/Window-BDa8MtNP.d.mts +0 -34
  311. package/dist/connection-C_jWYIwe.mjs.map +0 -1
  312. package/dist/film/Film.mjs.map +0 -1
  313. package/dist/moment/Moment.mjs.map +0 -1
  314. package/dist/plan/index.mjs.map +0 -1
  315. package/dist/pose.inpage-CLq7Mfdr.mjs.map +0 -1
  316. package/dist/presentation/Stage.mjs.map +0 -1
  317. package/dist/presentation/feed.d.mts +0 -20
  318. package/dist/presentation/feed.mjs +0 -18
  319. package/dist/presentation/feed.mjs.map +0 -1
  320. package/dist/providers/Cdp.d.mts +0 -9
  321. package/dist/providers/Cdp.mjs +0 -15
  322. package/dist/providers/Cdp.mjs.map +0 -1
  323. package/dist/providers/Chromium.d.mts +0 -32
  324. package/dist/providers/Chromium.mjs +0 -55
  325. package/dist/providers/Chromium.mjs.map +0 -1
  326. package/dist/providers/Released.d.mts +0 -2
  327. package/dist/providers/Released.mjs +0 -12
  328. package/dist/providers/Released.mjs.map +0 -1
  329. package/dist/stillness/Stillness.d.mts +0 -12
  330. package/dist/stillness/Stillness.mjs +0 -2
  331. package/dist/supervisor/Supervisor.mjs.map +0 -1
  332. package/dist/testing/index.mjs.map +0 -1
  333. package/dist/workerd/Cdp.d.mts +0 -8
  334. package/dist/workerd/Cdp.mjs +0 -13
  335. package/dist/workerd/Cdp.mjs.map +0 -1
  336. package/src/plan/index.ts +0 -36
  337. package/src/providers/Cdp.ts +0 -16
  338. package/src/providers/Chromium.ts +0 -99
  339. package/src/providers/Released.ts +0 -13
  340. package/src/workerd/Cdp.ts +0 -11
  341. /package/dist/{fold.inpage-CyVZQHZL.d.mts → internal/fold.inpage-CyVZQHZL.d.mts} +0 -0
  342. /package/dist/{rolldown-runtime-D7D4PA-g.mjs → internal/rolldown-runtime-D7D4PA-g.mjs} +0 -0
  343. /package/src/{Geometry.ts → internal/geometry.ts} +0 -0
  344. /package/src/{Url.ts → internal/url.ts} +0 -0
  345. /package/src/{stillness → timeline/internal}/utilsBundle.d.ts +0 -0
package/src/Page.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  /**
2
- * One browser tab: navigation, snapshots, pictures and input.
2
+ * One browser tab: navigation and input.
3
+ *
4
+ * `Page` gains a member only for identity, order, time or input. Everything else a page does is a
5
+ * function in the module of what it returns, taking the page first, such as `Snapshot.read(page)`,
6
+ * `Text.read(page)` or `Change.read(page)`.
3
7
  *
4
8
  * A page waits only for itself: its operations take turns in one lane of its own. An action, which
5
9
  * sends input or navigates, has the page to itself, in the order admitted after policy approval; reads share
@@ -13,9 +17,10 @@
13
17
  * screenshot's pixels. Mouse and keyboard input share a bounded pipeline, so pacing does not wait
14
18
  * for each protocol reply. Target lookup happens before the input is sent.
15
19
  *
20
+ * @stability stable
16
21
  * @since 0.3.0
17
22
  */
18
- import { type Clock, type Duration, Effect, Schema, type Scope, type Stream } from "effect";
23
+ import { type Clock, type Duration, Effect, Function, Schema } from "effect";
19
24
 
20
25
  import {
21
26
  Action,
@@ -26,42 +31,43 @@ import {
26
31
  } from "./Action.ts";
27
32
  import { type BrowserError, type PolicyDenied } from "./BrowserError.ts";
28
33
  import { Box, type BrowserEvent, PageLoaded, Subject } from "./BrowserEvent.ts";
29
- import type { Changes } from "./Change.ts";
30
- import { type CaptureStats, Frame, Image, type ScreencastOptions } from "./Frame.ts";
31
- import * as Motion from "./Geometry.ts";
34
+ import * as Motion from "./internal/geometry.ts";
32
35
  import { FormFieldSchema } from "./internal/input/evidence.inpage.ts";
33
36
  import * as Guard from "./internal/input/guard.inpage.ts";
37
+ import {
38
+ type Implementation,
39
+ isPage as isLibraryPage,
40
+ type key,
41
+ } from "./internal/page/functions.ts";
34
42
  import { Correlation, FailFast } from "./internal/page/lane.ts";
35
- import type { Layout, Picks } from "./Layout.ts";
36
- import type { Overlay } from "./Overlay.ts";
37
- import type { Held } from "./PageTime.ts";
38
- import type { Poses } from "./Pose.ts";
39
- import { type Snapshot, type SnapshotOptions } from "./Snapshot.ts";
40
- import * as Url from "./Url.ts";
41
- import type { Window } from "./Window.ts";
43
+ import * as Url from "./internal/url.ts";
42
44
 
45
+ /**
46
+ * @stability stable
47
+ * @category models
48
+ * @since 0.3.0
49
+ */
43
50
  export type Point = Motion.Point;
44
51
 
45
- /** A ref from a snapshot, such as `"e12"`, or a viewport point. */
52
+ /**
53
+ * A ref from a snapshot, such as `"e12"`, or a viewport point.
54
+ *
55
+ * @stability stable
56
+ * @category models
57
+ * @since 0.3.0
58
+ */
46
59
  export type Target = string | Point;
47
60
 
48
- /** An integer rectangle in viewport CSS pixels. */
49
- export class Region extends Schema.Class<Region>("effect-browser/Region")({
50
- x: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
51
- y: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
52
- width: Schema.Int.check(Schema.isGreaterThan(0)),
53
- height: Schema.Int.check(Schema.isGreaterThan(0)),
54
- }) {}
55
-
56
- /** A crop and its viewport origin: add that origin to a point read from the crop. */
57
- export class Zoom extends Schema.Class<Zoom>("effect-browser/Zoom")({
58
- page: Schema.String,
59
- region: Region,
60
- image: Image,
61
- }) {}
62
-
63
- /** The target as it read before input. Point coordinates are never snapped to another position. */
64
- export class ResolvedTarget extends Schema.Class<ResolvedTarget>("effect-browser/ResolvedTarget")({
61
+ /**
62
+ * The target as it read before input. Point coordinates are never snapped to another position.
63
+ *
64
+ * @stability stable
65
+ * @category schemas
66
+ * @since 0.3.0
67
+ */
68
+ export class ResolvedTarget extends Schema.Class<ResolvedTarget>(
69
+ "effect-browser/Page/ResolvedTarget",
70
+ )({
65
71
  point: Motion.Point,
66
72
  ...Subject.fields,
67
73
  element: Schema.String,
@@ -71,178 +77,56 @@ export class ResolvedTarget extends Schema.Class<ResolvedTarget>("effect-browser
71
77
  href: Schema.optional(Schema.String),
72
78
  }) {}
73
79
 
74
- /** Action options share the execution codec. */
80
+ /**
81
+ * Action options share the execution codec.
82
+ *
83
+ * @stability stable
84
+ * @category options
85
+ * @since 0.3.0
86
+ */
75
87
  export type ClickOptions = typeof ClickOptionsSchema.Type;
76
- export type TypeOptions = typeof TypeOptionsSchema.Type;
77
- export type PressOptions = typeof PressOptionsSchema.Type;
78
- export type ScrollOptions = typeof ScrollOptionsSchema.Type;
79
88
 
80
89
  /**
81
- * How current a picture must be. The newest screencast frame serves when it qualifies, at no cost;
82
- * otherwise a new screenshot is taken.
90
+ * @stability stable
91
+ * @category options
92
+ * @since 0.3.0
83
93
  */
84
- export interface FrameOptions {
85
- /**
86
- * The oldest a reused frame may be, from its paint, at the earliest its timing allows, to now.
87
- * Defaults to 250 milliseconds; 0 always takes a new screenshot.
88
- */
89
- readonly maxAge?: Duration.Input | undefined;
90
- /**
91
- * `"input"`: reuse only a frame painted after this page's latest input, including input of an
92
- * interrupted action, and never while an action is changing the page. For a caller that has
93
- * just acted on the page.
94
- */
95
- readonly after?: "input" | undefined;
96
- }
97
-
98
- /** A screenshot reuses only a frame painted after the page's latest input, as `after: "input"`. */
99
- export interface ScreenshotOptions {
100
- /** The oldest a reused frame may be, as for `frame`. Defaults to 250 milliseconds. */
101
- readonly maxAge?: Duration.Input | undefined;
102
- /** A region of the viewport, captured in CSS pixels at the viewport's own scale; always new. */
103
- readonly clip?: Box | undefined;
104
- /** JPEG quality, 0 to 100. Defaults to 80. */
105
- readonly quality?: number | undefined;
106
- /** `"jpeg"`, the default, or `"png"`, which is always a new picture. */
107
- readonly format?: "jpeg" | "png" | undefined;
108
- /**
109
- * `"css"`, the default, a picture pixel per CSS pixel; `"device"`, the screen's own pixels, as
110
- * many to a CSS pixel as its device scale factor, which is always a new picture.
111
- */
112
- readonly scale?: "css" | "device" | undefined;
113
- }
114
-
115
- /** How a page paints for a scope; see `Page.paint`. */
116
- export interface Paint {
117
- /** Device pixels to each CSS pixel, more than 0 and at most 4. The layout keeps its size. */
118
- readonly scale?: number | undefined;
119
- /** False hides the page's scrollbars from its next document on, and its layout takes their room. */
120
- readonly scrollbars?: boolean | undefined;
121
- }
94
+ export type TypeOptions = typeof TypeOptionsSchema.Type;
122
95
 
123
96
  /**
124
- * What `find` looks for. Every rule given must hold; with none, it finds every element in scope
125
- * that has a role or is a control.
97
+ * @stability stable
98
+ * @category options
99
+ * @since 0.3.0
126
100
  */
127
- export interface FindQuery {
128
- /** Narrow matching to this CSS selector. Invalid CSS fails InvalidRequest. */
129
- readonly selector?: string | undefined;
130
- /** Require a visible match, optionally enabled. */
131
- readonly state?: "visible" | "enabled" | undefined;
132
- /** An ARIA role, such as `"button"` or `"heading"`, ignoring case. */
133
- readonly role?: string | undefined;
134
- /**
135
- * The accessible name: a string that reads the same once spaces are collapsed and case folded,
136
- * or a pattern found in it.
137
- */
138
- readonly name?: string | RegExp | undefined;
139
- /**
140
- * Text it shows, ignoring case and spacing, or a pattern. Text inside a control or a heading is
141
- * that control's or heading's, and only the smallest element showing it matches, not every
142
- * element around it.
143
- */
144
- readonly text?: string | RegExp | undefined;
145
- /** Whole words in its context (row, column, label or heading), ignoring case and spacing. */
146
- readonly near?: string | undefined;
147
- /** Only what a point action at this viewport point would reach: the control there, or else what is painted there. */
148
- readonly at?: Point | undefined;
149
- /** The viewport (the default), or the whole document. */
150
- readonly scope?: "viewport" | "document" | undefined;
151
- }
101
+ export type PressOptions = typeof PressOptionsSchema.Type;
152
102
 
153
103
  /**
154
- * An element's state as its markup gives it: `checked` for what can be checked, `expanded`,
155
- * `selected` and `pressed` where the page says either way, and `level` for headings.
104
+ * @stability stable
105
+ * @category options
106
+ * @since 0.3.0
156
107
  */
157
- export const ElementState = Schema.Struct({
158
- disabled: Schema.Boolean,
159
- focused: Schema.Boolean,
160
- checked: Schema.optional(Schema.Boolean),
161
- expanded: Schema.optional(Schema.Boolean),
162
- selected: Schema.optional(Schema.Boolean),
163
- pressed: Schema.optional(Schema.Boolean),
164
- level: Schema.optional(Schema.Int),
165
- });
166
-
167
- export type ElementState = typeof ElementState.Type;
168
-
169
- /** An element `find` found: a ref for the actions, what it is, where it is and its state. */
170
- export class Found extends Schema.Class<Found>("effect-browser/Found")({
171
- ref: Schema.String,
172
- subject: Subject,
173
- /** Its box, rounded. Reading the document, it may be out of view. */
174
- box: Box,
175
- inViewport: Schema.Boolean,
176
- state: ElementState,
177
- }) {}
178
-
179
- export interface TextOptions {
180
- /** `"viewport"` (the default) reads what the viewport shows; a ref reads that element whole. */
181
- readonly scope?: string | undefined;
182
- /** Bound on the text's length, cut at a line. Defaults to 12,000 characters. */
183
- readonly maxChars?: number | undefined;
184
- /** Show what fields hold; a secret field still reads `••••`. Defaults to false. */
185
- readonly unmask?: boolean | undefined;
186
- }
187
-
188
- /** What a page showed as text: a line per block, with table cells apart by tabs. */
189
- export class Text extends Schema.Class<Text>("effect-browser/Text")({
190
- url: Schema.String,
191
- title: Schema.String,
192
- text: Schema.String,
193
- /** True when `text` was cut at `maxChars`. */
194
- truncated: Schema.Boolean,
195
- /** Host monotonic milliseconds from the browser's captured Effect Clock. */
196
- at: Schema.Finite,
197
- }) {}
108
+ export type ScrollOptions = typeof ScrollOptionsSchema.Type;
198
109
 
110
+ /**
111
+ * @stability stable
112
+ * @category options
113
+ * @since 0.3.0
114
+ */
199
115
  export interface ReadyOptions {
200
116
  /** How long recorded content must stay unchanged. Screen stillness is a separate feature. */
201
- readonly quietMillis?: number | undefined;
117
+ readonly quiet?: Duration.Input | undefined;
202
118
  readonly timeout?: Duration.Input | undefined;
203
119
  }
204
120
 
205
- /** The window `changes` reads, and whether to show what fields hold. */
206
- export interface ChangesOptions {
207
- /**
208
- * Where the window starts: the changes a previous read returned, to continue exactly where they
209
- * ended; a frame, at its paint; or host monotonic milliseconds, which mapped to the page's clock
210
- * may miss or repeat changes near the start if the browser's clock mapping changed since. Defaults
211
- * to the start of the record.
212
- */
213
- readonly since?: Changes | Frame | number | undefined;
214
- /**
215
- * Where it ends: a frame, at its paint, so a delayed frame's window holds nothing it does not
216
- * show; or host monotonic milliseconds. Defaults to now, and is never later.
217
- */
218
- readonly until?: Frame | number | undefined;
219
- /** Show what fields hold; a secret field still reads `••••`. Defaults to false. */
220
- readonly unmask?: boolean | undefined;
221
- }
222
-
223
- /** The window `window` reads, and whether to show what fields hold. */
224
- export interface WindowOptions {
225
- /**
226
- * Where the window starts: a previous window, to continue exactly where it ended; a frame, at its
227
- * paint; host monotonic milliseconds; or a `Duration` back from `until`. A start after `until`
228
- * leaves the window empty there.
229
- */
230
- readonly since: Window | Frame | Duration.Duration | number;
231
- /**
232
- * Where it ends: a frame, at its paint, such as one a delayed consumer airs now; or host
233
- * monotonic milliseconds. Defaults to now, and is never later.
234
- */
235
- readonly until?: Frame | number | undefined;
236
- /** Show what fields hold in its changes; a secret field still reads `••••`. Defaults to false. */
237
- readonly unmask?: boolean | undefined;
238
- }
239
-
240
121
  /**
241
122
  * What the library knows of a page now, without asking it, each part with when it learned it, in
242
- * host monotonic milliseconds: a part's age is `at` less its time. Text read before the current
243
- * document began is left out, since it tells of a document that has gone.
123
+ * host monotonic milliseconds: a part's age is `at` less its time.
124
+ *
125
+ * @stability stable
126
+ * @category schemas
127
+ * @since 0.3.0
244
128
  */
245
- export class State extends Schema.Class<State>("effect-browser/PageState")({
129
+ export class State extends Schema.Class<State>("effect-browser/Page/State")({
246
130
  page: Schema.String,
247
131
  /** The tracking connection that owns this document counter. */
248
132
  connection: Schema.String,
@@ -256,12 +140,6 @@ export class State extends Schema.Class<State>("effect-browser/PageState")({
256
140
  committedAt: Schema.optional(Schema.Finite),
257
141
  /** How far that document has loaded, as the page's own session heard; absent until parsed. */
258
142
  load: Schema.optional(PageLoaded),
259
- /** The newest screencast frame, of whichever document it names. */
260
- frame: Schema.optional(Frame),
261
- /** Where the overlay's drawing was last drawn, in viewport CSS pixels; absent with none shown. */
262
- overlay: Schema.optional(Schema.Array(Box)),
263
- /** The viewport's text as it was last read, with the page's title then. */
264
- text: Schema.optional(Text),
265
143
  }) {}
266
144
 
267
145
  /**
@@ -280,9 +158,18 @@ export class State extends Schema.Class<State>("effect-browser/PageState")({
280
158
  *
281
159
  * Facts never come from what an element's text says. What an input means, such as a payment
282
160
  * or a deletion, takes a judge that reads the evidence in the {@link InputRequest}.
161
+ *
162
+ * @stability stable
163
+ * @category schemas
164
+ * @since 0.3.0
283
165
  */
284
166
  export const Fact = Guard.Fact;
285
167
 
168
+ /**
169
+ * @stability stable
170
+ * @category schemas
171
+ * @since 0.3.0
172
+ */
286
173
  export type Fact = typeof Fact.Type;
287
174
 
288
175
  /**
@@ -294,8 +181,12 @@ export type Fact = typeof Fact.Type;
294
181
  * field is replaced with {@link redacted}, here and in the recorded `Action`, and its key events
295
182
  * record `Unidentified` keys; `press` records the keys it is given. Validation before dispatch
296
183
  * binds the facts and the target, not the text around it, which live pages change freely.
184
+ *
185
+ * @stability stable
186
+ * @category schemas
187
+ * @since 0.3.0
297
188
  */
298
- export class InputRequest extends Schema.Class<InputRequest>("effect-browser/InputRequest")({
189
+ export class InputRequest extends Schema.Class<InputRequest>("effect-browser/Page/InputRequest")({
299
190
  page: Schema.String,
300
191
  /**
301
192
  * The page's URL, without a fragment that only names a place on the page. This and the other
@@ -340,12 +231,30 @@ export class InputRequest extends Schema.Class<InputRequest>("effect-browser/Inp
340
231
  /**
341
232
  * What replaces text typed into a `secret` field, in requests and in the recorded `Action`, and a
342
233
  * credential's value in every address the library reports.
234
+ *
235
+ * @stability stable
236
+ * @category constants
237
+ * @since 0.3.0
343
238
  */
344
239
  export const redacted = Url.withheld;
345
240
 
241
+ /**
242
+ * Whether a value is a page the library made: what a function over a page, callable with the page
243
+ * first or last, tells it from its other arguments by.
244
+ *
245
+ * @stability stable
246
+ * @category guards
247
+ * @since 0.3.0
248
+ */
249
+ export const isPage: (u: unknown) => u is Page = isLibraryPage;
250
+
346
251
  /**
347
252
  * Run page operations without waiting their turn: on a page busy with other operations, each fails
348
253
  * `Busy` at once, and `Browser.newPage` on a browser with `maxPages` open fails `Limit` at once.
254
+ *
255
+ * @stability stable
256
+ * @category combinators
257
+ * @since 0.3.0
349
258
  */
350
259
  export const failFast = <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
351
260
  Effect.provideService(effect, FailFast, true);
@@ -353,48 +262,60 @@ export const failFast = <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect
353
262
  /**
354
263
  * Give every action `effect` performs a caller's id, such as a model's tool call id, which its
355
264
  * recorded `Action` carries as `correlation`.
265
+ *
266
+ * @stability stable
267
+ * @category combinators
268
+ * @since 0.3.0
356
269
  */
357
- export const correlate =
358
- (id: string) =>
359
- <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
360
- Effect.provideService(effect, Correlation, id);
270
+ export const correlate: {
271
+ (id: string): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
272
+ <A, E, R>(effect: Effect.Effect<A, E, R>, id: string): Effect.Effect<A, E, R>;
273
+ } = Function.dual(
274
+ 2,
275
+ <A, E, R>(effect: Effect.Effect<A, E, R>, id: string): Effect.Effect<A, E, R> =>
276
+ Effect.provideService(effect, Correlation, id),
277
+ );
361
278
 
362
- /** Succeed to allow, fail to deny, or await an external signal to hold the input. */
279
+ /**
280
+ * Succeed to allow, fail to deny, or await an external signal to hold the input.
281
+ *
282
+ * @stability stable
283
+ * @category models
284
+ * @since 0.3.0
285
+ */
363
286
  export type InputGuard = (request: InputRequest) => Effect.Effect<void, PolicyDenied>;
364
287
 
365
- /** What a wait requires of the query's matches. */
366
- export type UntilWant = "some" | "none" | { readonly other: string };
367
-
368
- export interface UntilResult {
369
- readonly met: boolean;
370
- readonly mark: string;
371
- }
372
-
373
- /** Scoped access to one page's shared capture and its current-document evidence. */
374
- export interface Capture {
375
- readonly stream: Stream.Stream<Frame, BrowserError>;
376
- readonly current: Frame | undefined;
377
- readonly isCurrent: (frame: Frame) => boolean;
378
- readonly confirm: (frame: Frame) => Effect.Effect<boolean, BrowserError>;
379
- readonly sync: Effect.Effect<void, BrowserError>;
380
- readonly stats: (options?: {
381
- readonly window?: Duration.Input | undefined;
382
- }) => Effect.Effect<CaptureStats, BrowserError>;
383
- }
384
-
385
- /** Script values cross the page boundary through the caller's Schema. A bundler may rewrite functions. */
288
+ /**
289
+ * Script values cross the page boundary through the caller's Schema. A bundler may rewrite functions.
290
+ *
291
+ * @stability stable
292
+ * @category options
293
+ * @since 0.3.0
294
+ */
386
295
  export interface ScriptOptions<A, Arg> {
387
296
  readonly arg: Arg;
388
297
  readonly result: Schema.Codec<A, unknown>;
389
298
  }
390
299
 
300
+ /**
301
+ * @stability stable
302
+ * @category options
303
+ * @since 0.3.0
304
+ */
391
305
  export interface ActOptions<A, Arg> extends ScriptOptions<A, Arg> {
392
306
  readonly document: number;
393
307
  /** Supplying the read's connection also refuses a document counter from another connection. */
394
308
  readonly connection?: string | undefined;
395
309
  }
396
310
 
311
+ /**
312
+ * @stability stable
313
+ * @category models
314
+ * @since 0.3.0
315
+ */
397
316
  export interface Page {
317
+ /** What the page does behind its types' modules' functions, such as `Snapshot.read`. */
318
+ readonly [key]: Implementation;
398
319
  /** Decode and perform a data action through the same policy and lane as the named methods. */
399
320
  readonly perform: (action: Action) => Effect.Effect<ResolvedTarget | string | void, BrowserError>;
400
321
  /** Read declared side-effect-free code in the main world, retrying one replaced document. */
@@ -414,22 +335,15 @@ export interface Page {
414
335
  script: (arg: Arg) => unknown,
415
336
  options: ActOptions<A, Arg>,
416
337
  ) => Effect.Effect<A, BrowserError>;
417
- /** Owning browser clock: deadlines and all frame/event timestamps use this clock. */
418
- readonly clock: Clock.Clock;
338
+ /**
339
+ * The owning browser's host clock, which stamps the page's events and frames and times its
340
+ * deadlines. It is not the page's own time, which `PageTime` holds.
341
+ */
342
+ readonly hostClock: Clock.Clock;
419
343
  /** Wait for admitted input and retain a bounded read turn through effect. */
420
344
  readonly afterInput: <A, E, R>(
421
345
  effect: Effect.Effect<A, E, R>,
422
346
  ) => Effect.Effect<A, E | BrowserError, R>;
423
- /** A scoped lease starts capture immediately, independently of its first frame. */
424
- readonly capture: (
425
- options?: ScreencastOptions,
426
- ) => Effect.Effect<Capture, BrowserError, Scope.Scope>;
427
- /** One page-side wait; replaced documents share one deadline. Unmet is met:false; an empty mark means no stable document could be sampled. */
428
- readonly until: (
429
- query: FindQuery,
430
- want: UntilWant,
431
- millis: number,
432
- ) => Effect.Effect<UntilResult, BrowserError>;
433
347
  /** The page's CDP target id: the same page has it again after a reconnect to its browser. */
434
348
  readonly id: string;
435
349
  /** The page's address, without its userinfo or known secret parameters. */
@@ -449,25 +363,6 @@ export interface Page {
449
363
  /** Close the tab, succeeding once it has closed, or at once when it already had. */
450
364
  readonly close: Effect.Effect<void, BrowserError>;
451
365
 
452
- readonly snapshot: (options?: SnapshotOptions) => Effect.Effect<Snapshot, BrowserError>;
453
- /**
454
- * A picture of the viewport, in CSS pixels: a screencast frame painted since the page's latest
455
- * input, if one qualifies, or a new one. A caller that has just acted sees what its action did.
456
- */
457
- readonly screenshot: (options?: ScreenshotOptions) => Effect.Effect<Image, BrowserError>;
458
- /**
459
- * The viewport with its timing: the newest screencast frame if it qualifies, else a new
460
- * screenshot timed by the host interval in which it was taken.
461
- */
462
- readonly frame: (options?: FrameOptions) => Effect.Effect<Frame, BrowserError>;
463
- /**
464
- * A crop in CSS pixels, unmagnified, with the origin that keeps later input in viewport pixels.
465
- * With `scale: "device"` its picture has the screen's own pixels, as a screenshot's would.
466
- */
467
- readonly zoom: (
468
- region: Region,
469
- options?: Pick<ScreenshotOptions, "scale">,
470
- ) => Effect.Effect<Zoom, BrowserError>;
471
366
  /**
472
367
  * The viewport's size in CSS pixels, the space of points, crops and page scrolls. Over CDP the
473
368
  * page reports it, within the action timeout.
@@ -476,67 +371,11 @@ export interface Page {
476
371
  { readonly width: number; readonly height: number },
477
372
  BrowserError
478
373
  >;
479
- /**
480
- * The elements that match a query, in tree order, with refs the actions take, in one call to the
481
- * page. All that match are returned, so a caller tells them apart by their context; none is an
482
- * empty result, not a failure.
483
- */
484
- readonly find: (query?: FindQuery) => Effect.Effect<ReadonlyArray<Found>, BrowserError>;
485
- /**
486
- * Where each pick is, in one call to the page: its box unrounded, in the viewport and in the
487
- * document, the boxes of words in it, and the viewport, scroll and scale they were read at. A
488
- * pick that finds nothing is listed as missing, not a failure. See `Layout`.
489
- */
490
- readonly layout: (picks: Picks) => Effect.Effect<Layout, BrowserError>;
491
- /**
492
- * A layer over the page to draw into, for the scope, that the library's readers never read.
493
- * One at a time: a second while one is open fails `InvalidRequest`. See `Overlay`.
494
- */
495
- readonly overlay: Effect.Effect<Overlay, BrowserError, Scope.Scope>;
496
- /**
497
- * Pose the page's own elements for the scope, moved, turned and scaled as a caller says, and put
498
- * back when the scope closes. One lease at a time: a second while one is open fails
499
- * `InvalidRequest`. See `Pose`.
500
- */
501
- readonly poses: Effect.Effect<Poses, BrowserError, Scope.Scope>;
502
- /**
503
- * Hold the page's own time for the scope, to step it on with `advance`; real time resumes when
504
- * the scope closes. Needs the browser's `pageTime` option; one hold at a time. See `PageTime`.
505
- */
506
- readonly hold: Effect.Effect<Held, BrowserError, Scope.Scope>;
507
- /**
508
- * The text the viewport shows, or one element whole, in one call to the page. Field values read
509
- * `••••` unless `unmask`, and a secret field's always do, as does one that was secret when the
510
- * library saw it.
511
- */
512
- readonly text: (options?: TextOptions) => Effect.Effect<Text, BrowserError>;
513
- /**
514
- * What visibly changed over a window, in one call to the page. The first read starts the page's
515
- * record, so it finds none; from then the page records, and from the start of each later
516
- * document, until nobody has read it for two minutes. See `Change`.
517
- */
518
- readonly changes: (options?: ChangesOptions) => Effect.Effect<Changes, BrowserError>;
519
- /**
520
- * The page's events, changes and frames over a window: the frames and events it keeps, at no
521
- * call, and its changes, in one call, the first starting its record as `changes` does. A part
522
- * that cannot be read is missing, with why; the window fails only for bounds that are not finite.
523
- */
524
- readonly window: (options: WindowOptions) => Effect.Effect<Window, BrowserError>;
525
374
  /**
526
375
  * What the library knows of the page now, at no call and with no wait for its turn: where it is,
527
- * its document and how far it has loaded, its newest frame, and its text and title as last read.
376
+ * its document and how far it has loaded.
528
377
  */
529
378
  readonly state: Effect.Effect<State>;
530
- /**
531
- * Paint the page at `scale` device pixels to each CSS pixel, or without its scrollbars, for a
532
- * scope: a screenshot with `scale: "device"` then has that many more pixels, while the layout,
533
- * its boxes and input keep their CSS pixels. Scrollbars go from the next document on, and come
534
- * back from the next after the scope, so paint, then load the page, then measure it. One at a
535
- * time. A browser this library launched paints at the scale of its launch (Chromium's
536
- * `deviceScaleFactor`), and refuses another.
537
- */
538
- readonly paint: (options: Paint) => Effect.Effect<void, BrowserError, Scope.Scope>;
539
-
540
379
  readonly click: (
541
380
  target: Target,
542
381
  options?: ClickOptions,
@@ -559,26 +398,11 @@ export interface Page {
559
398
 
560
399
  /**
561
400
  * Wait for document evidence, polling every 50 ms: parsed, painted, visible, fonts and visible
562
- * images loaded, and finite animations finished. Optional quietMillis requires recorded content
401
+ * images loaded, and finite animations finished. Optional `quiet` requires recorded content
563
402
  * to stay unchanged. Screen or foreground stillness belongs to the Stillness feature.
564
403
  * Fails Timeout after timeout, 15 seconds by default.
565
404
  */
566
405
  readonly ready: (options?: ReadyOptions) => Effect.Effect<void, BrowserError>;
567
-
568
- /**
569
- * Screencast frames for as long as the stream runs. Concurrent streams share one screencast and
570
- * its settings; explicit options that differ from a running screencast's fail with InvalidRequest.
571
- */
572
- readonly screencast: (options?: ScreencastOptions) => Stream.Stream<Frame, BrowserError>;
573
- /**
574
- * What this page's captures received, delivered and dropped, over its life or the latest
575
- * `window`, which reaches back at most a minute; a longer one is an `InvalidRequest`.
576
- */
577
- readonly captureStats: (options?: {
578
- readonly window?: Duration.Input | undefined;
579
- }) => Effect.Effect<CaptureStats, BrowserError>;
580
- /** Screencast frames painted within `frameHistory` of the newest, oldest first. */
581
- readonly recentFrames: Effect.Effect<ReadonlyArray<Frame>>;
582
406
  /** This page's events among the browser's latest `eventHistory`, oldest first. */
583
407
  readonly recentEvents: Effect.Effect<ReadonlyArray<BrowserEvent>>;
584
408
  }
package/src/PageTime.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * in one step, a recording's page moves one frame's worth per frame however long each takes.
5
5
  *
6
6
  * A browser opened with `pageTime` runs a page clock in each top document's main world, before
7
- * the page's own scripts. Until `Page.hold`, it keeps real time. Held, the page's timers and
7
+ * the page's own scripts. Until `hold`, it keeps real time. Held, the page's timers and
8
8
  * intervals, its animation frames, `performance.now`, `Date.now`, `new Date()` and `Date()`, and
9
9
  * its CSS transitions, CSS animations and Web Animations stand still, and each `advance` runs what
10
10
  * falls due in time order, each timer at its own time, and then one animation frame at its end.
@@ -17,16 +17,25 @@
17
17
  * never back, and what was left of each timer and frame runs in real time. `ready` and stillness
18
18
  * count an animation held part way as still running.
19
19
  *
20
+ * @stability stable
20
21
  * @since 0.3.0
21
22
  */
22
- import type { Duration, Effect } from "effect";
23
+ import type { Duration, Effect, Scope } from "effect";
23
24
 
24
25
  import type { BrowserError } from "./BrowserError.ts";
25
- import type { Point } from "./Geometry.ts";
26
+ import type { Point } from "./internal/geometry.ts";
27
+ import { functionsOf } from "./internal/page/functions.ts";
26
28
  import type { Content } from "./Overlay.ts";
29
+ import type { Page } from "./Page.ts";
27
30
  import type { Pose } from "./Pose.ts";
28
31
 
29
- /** What else changes with page time in the same call to the page. */
32
+ /**
33
+ * What else changes with page time in the same call to the page.
34
+ *
35
+ * @stability stable
36
+ * @category models
37
+ * @since 0.3.0
38
+ */
30
39
  export interface Step {
31
40
  /** Scroll the document to this many CSS pixels down it first, at once. */
32
41
  readonly scroll?: number | undefined;
@@ -36,6 +45,11 @@ export interface Step {
36
45
  readonly overlay?: Content | undefined;
37
46
  }
38
47
 
48
+ /**
49
+ * @stability stable
50
+ * @category models
51
+ * @since 0.3.0
52
+ */
39
53
  export interface Held {
40
54
  /**
41
55
  * Move page time on by `by`, in one call to the page, after the actions asked before it. Says
@@ -45,3 +59,14 @@ export interface Held {
45
59
  /** How far this hold has moved page time, across the documents it held. */
46
60
  readonly elapsed: Effect.Effect<Duration.Duration>;
47
61
  }
62
+
63
+ /**
64
+ * Hold the page's own time for the scope, to step it on with `advance`; real time resumes when
65
+ * the scope closes. Needs the browser's `pageTime` option; one hold at a time.
66
+ *
67
+ * @stability stable
68
+ * @category combinators
69
+ * @since 0.3.0
70
+ */
71
+ export const hold = (page: Page): Effect.Effect<Held, BrowserError, Scope.Scope> =>
72
+ functionsOf(page).hold;