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
@@ -6,17 +6,27 @@
6
6
  * reached the browser first. `consequence` says what that leaves: what was lost, and whether the
7
7
  * call can be repeated. `message` is a sentence for operators.
8
8
  *
9
+ * @stability stable
9
10
  * @since 0.3.0
10
11
  */
11
12
  import { Effect, Schema } from "effect";
12
13
 
13
14
  import { DisconnectCause } from "./BrowserEvent.ts";
14
- import * as Url from "./Url.ts";
15
+ import * as Url from "./internal/url.ts";
15
16
 
16
- /** The operation did not finish in time. */
17
- export class Timeout extends Schema.TaggedError<Timeout>()("Timeout", {
18
- millis: Schema.Finite,
19
- }) {
17
+ /**
18
+ * The operation did not finish in time.
19
+ *
20
+ * @stability stable
21
+ * @category errors
22
+ * @since 0.3.0
23
+ */
24
+ export class Timeout extends Schema.TaggedError<Timeout>("effect-browser/BrowserError/Timeout")(
25
+ "Timeout",
26
+ {
27
+ millis: Schema.Finite,
28
+ },
29
+ ) {
20
30
  override get message() {
21
31
  return `timed out after ${this.millis} ms`;
22
32
  }
@@ -25,8 +35,12 @@ export class Timeout extends Schema.TaggedError<Timeout>()("Timeout", {
25
35
  /**
26
36
  * The operation waited its turn behind others on its page and was not given one in time, or was
27
37
  * asked to fail fast: the page may be well, only busy.
38
+ *
39
+ * @stability stable
40
+ * @category errors
41
+ * @since 0.3.0
28
42
  */
29
- export class Busy extends Schema.TaggedError<Busy>()("Busy", {
43
+ export class Busy extends Schema.TaggedError<Busy>("effect-browser/BrowserError/Busy")("Busy", {
30
44
  waitedMillis: Schema.Finite,
31
45
  /** The operations ahead of it: those holding the page and those asked before it. */
32
46
  ahead: Schema.Int,
@@ -38,15 +52,29 @@ export class Busy extends Schema.TaggedError<Busy>()("Busy", {
38
52
  }
39
53
  }
40
54
 
41
- /** Input is withheld by a scoped suspension; nothing was dispatched. */
42
- export class Suspended extends Schema.TaggedError<Suspended>()("Suspended", {}) {
55
+ /**
56
+ * Input is withheld by a scoped suspension; nothing was dispatched.
57
+ *
58
+ * @stability stable
59
+ * @category errors
60
+ * @since 0.3.0
61
+ */
62
+ export class Suspended extends Schema.TaggedError<Suspended>(
63
+ "effect-browser/BrowserError/Suspended",
64
+ )("Suspended", {}) {
43
65
  override get message() {
44
66
  return "browser input is suspended";
45
67
  }
46
68
  }
47
69
 
48
- /** The browser has as many pages open as `maxPages` allows, and none closed in time. */
49
- export class Limit extends Schema.TaggedError<Limit>()("Limit", {
70
+ /**
71
+ * The browser has as many pages open as `maxPages` allows, and none closed in time.
72
+ *
73
+ * @stability stable
74
+ * @category errors
75
+ * @since 0.3.0
76
+ */
77
+ export class Limit extends Schema.TaggedError<Limit>("effect-browser/BrowserError/Limit")("Limit", {
50
78
  maxPages: Schema.Int,
51
79
  }) {
52
80
  override get message() {
@@ -54,26 +82,52 @@ export class Limit extends Schema.TaggedError<Limit>()("Limit", {
54
82
  }
55
83
  }
56
84
 
57
- /** A ref from an earlier snapshot no longer names an element on the page. */
58
- export class StaleRef extends Schema.TaggedError<StaleRef>()("StaleRef", {
59
- ref: Schema.String,
60
- }) {
85
+ /**
86
+ * A ref from an earlier snapshot no longer names an element on the page.
87
+ *
88
+ * @stability stable
89
+ * @category errors
90
+ * @since 0.3.0
91
+ */
92
+ export class StaleRef extends Schema.TaggedError<StaleRef>("effect-browser/BrowserError/StaleRef")(
93
+ "StaleRef",
94
+ {
95
+ ref: Schema.String,
96
+ },
97
+ ) {
61
98
  override get message() {
62
99
  return `${this.ref} is not on the page any more`;
63
100
  }
64
101
  }
65
102
 
66
- /** What the operation looked for is not on the page. */
67
- export class NotFound extends Schema.TaggedError<NotFound>()("NotFound", {
68
- target: Schema.String,
69
- }) {
103
+ /**
104
+ * What the operation looked for is not on the page.
105
+ *
106
+ * @stability stable
107
+ * @category errors
108
+ * @since 0.3.0
109
+ */
110
+ export class NotFound extends Schema.TaggedError<NotFound>("effect-browser/BrowserError/NotFound")(
111
+ "NotFound",
112
+ {
113
+ target: Schema.String,
114
+ },
115
+ ) {
70
116
  override get message() {
71
117
  return `${this.target} was not found`;
72
118
  }
73
119
  }
74
120
 
75
- /** The element exists but cannot take this input: covered, disabled, hidden or the wrong kind. */
76
- export class NotActionable extends Schema.TaggedError<NotActionable>()("NotActionable", {
121
+ /**
122
+ * The element exists but cannot take this input: covered, disabled, hidden or the wrong kind.
123
+ *
124
+ * @stability stable
125
+ * @category errors
126
+ * @since 0.3.0
127
+ */
128
+ export class NotActionable extends Schema.TaggedError<NotActionable>(
129
+ "effect-browser/BrowserError/NotActionable",
130
+ )("NotActionable", {
77
131
  detail: Schema.String,
78
132
  }) {
79
133
  override get message() {
@@ -81,8 +135,16 @@ export class NotActionable extends Schema.TaggedError<NotActionable>()("NotActio
81
135
  }
82
136
  }
83
137
 
84
- /** A navigation failed, for example on a DNS error or a refused connection. */
85
- export class NavigationFailed extends Schema.TaggedError<NavigationFailed>()("NavigationFailed", {
138
+ /**
139
+ * A navigation failed, for example on a DNS error or a refused connection.
140
+ *
141
+ * @stability stable
142
+ * @category errors
143
+ * @since 0.3.0
144
+ */
145
+ export class NavigationFailed extends Schema.TaggedError<NavigationFailed>(
146
+ "effect-browser/BrowserError/NavigationFailed",
147
+ )("NavigationFailed", {
86
148
  url: Schema.String,
87
149
  detail: Schema.String,
88
150
  }) {
@@ -102,17 +164,32 @@ const closedBy = {
102
164
  /**
103
165
  * The page is gone: it was closed (`page`) or crashed, or its browser was lost for one of the
104
166
  * browser's `DisconnectCause`s.
167
+ *
168
+ * @stability stable
169
+ * @category errors
170
+ * @since 0.3.0
105
171
  */
106
- export class Closed extends Schema.TaggedError<Closed>()("Closed", {
107
- cause: Schema.Literals(["page", "crashed", ...DisconnectCause.literals]),
108
- }) {
172
+ export class Closed extends Schema.TaggedError<Closed>("effect-browser/BrowserError/Closed")(
173
+ "Closed",
174
+ {
175
+ cause: Schema.Literals(["page", "crashed", ...DisconnectCause.literals]),
176
+ },
177
+ ) {
109
178
  override get message() {
110
179
  return closedBy[this.cause];
111
180
  }
112
181
  }
113
182
 
114
- /** The request itself is invalid, such as a ref that is not a ref or a point off the screen. */
115
- export class InvalidRequest extends Schema.TaggedError<InvalidRequest>()("InvalidRequest", {
183
+ /**
184
+ * The request itself is invalid, such as a ref that is not a ref or a point off the screen.
185
+ *
186
+ * @stability stable
187
+ * @category errors
188
+ * @since 0.3.0
189
+ */
190
+ export class InvalidRequest extends Schema.TaggedError<InvalidRequest>(
191
+ "effect-browser/BrowserError/InvalidRequest",
192
+ )("InvalidRequest", {
116
193
  detail: Schema.String,
117
194
  }) {
118
195
  override get message() {
@@ -120,8 +197,16 @@ export class InvalidRequest extends Schema.TaggedError<InvalidRequest>()("Invali
120
197
  }
121
198
  }
122
199
 
123
- /** The input policy refused the action before any input was sent. */
124
- export class PolicyDenied extends Schema.TaggedError<PolicyDenied>()("PolicyDenied", {
200
+ /**
201
+ * The input policy refused the action before any input was sent.
202
+ *
203
+ * @stability stable
204
+ * @category errors
205
+ * @since 0.3.0
206
+ */
207
+ export class PolicyDenied extends Schema.TaggedError<PolicyDenied>(
208
+ "effect-browser/BrowserError/PolicyDenied",
209
+ )("PolicyDenied", {
125
210
  detail: Schema.String,
126
211
  /** What made the policy deny, such as the failure of the judge it asked. */
127
212
  cause: Schema.optional(Schema.Defect()),
@@ -131,8 +216,16 @@ export class PolicyDenied extends Schema.TaggedError<PolicyDenied>()("PolicyDeni
131
216
  }
132
217
  }
133
218
 
134
- /** The input policy did not release its hold within its own bound. */
135
- export class PolicyTimeout extends Schema.TaggedError<PolicyTimeout>()("PolicyTimeout", {
219
+ /**
220
+ * The input policy did not release its hold within its own bound.
221
+ *
222
+ * @stability stable
223
+ * @category errors
224
+ * @since 0.3.0
225
+ */
226
+ export class PolicyTimeout extends Schema.TaggedError<PolicyTimeout>(
227
+ "effect-browser/BrowserError/PolicyTimeout",
228
+ )("PolicyTimeout", {
136
229
  millis: Schema.Finite,
137
230
  }) {
138
231
  override get message() {
@@ -140,37 +233,67 @@ export class PolicyTimeout extends Schema.TaggedError<PolicyTimeout>()("PolicyTi
140
233
  }
141
234
  }
142
235
 
143
- /** The requested event cursor fell behind the browser's bounded replay history. */
144
- export class EventHistoryExpired extends Schema.TaggedError<EventHistoryExpired>()(
145
- "EventHistoryExpired",
146
- {
147
- after: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
148
- oldest: Schema.Int.check(Schema.isGreaterThan(0)),
149
- latest: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
150
- },
151
- ) {
236
+ /**
237
+ * The requested event cursor fell behind the browser's bounded replay history.
238
+ *
239
+ * @stability stable
240
+ * @category errors
241
+ * @since 0.3.0
242
+ */
243
+ export class EventHistoryExpired extends Schema.TaggedError<EventHistoryExpired>(
244
+ "effect-browser/BrowserError/EventHistoryExpired",
245
+ )("EventHistoryExpired", {
246
+ after: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
247
+ oldest: Schema.Int.check(Schema.isGreaterThan(0)),
248
+ latest: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
249
+ }) {
152
250
  override get message() {
153
251
  return `event history after ${this.after} expired; retained sequences are ${this.oldest}–${this.latest}`;
154
252
  }
155
253
  }
156
254
 
157
- /** The browser, the connection or the provider failed in a way the other reasons do not cover. */
158
- export class Failed extends Schema.TaggedError<Failed>()("Failed", {
159
- detail: Schema.String,
160
- }) {
255
+ /**
256
+ * The browser, the connection or the provider failed in a way the other reasons do not cover.
257
+ *
258
+ * @stability stable
259
+ * @category errors
260
+ * @since 0.3.0
261
+ */
262
+ export class Failed extends Schema.TaggedError<Failed>("effect-browser/BrowserError/Failed")(
263
+ "Failed",
264
+ {
265
+ detail: Schema.String,
266
+ },
267
+ ) {
161
268
  override get message() {
162
269
  return this.detail;
163
270
  }
164
271
  }
165
272
 
166
- /** Caller code threw in the page's main world. Its source and payload stay private. */
167
- export class Threw extends Schema.TaggedError<Threw>()("Threw", {}) {
273
+ /**
274
+ * Caller code threw in the page's main world. Its source and payload stay private.
275
+ *
276
+ * @stability stable
277
+ * @category errors
278
+ * @since 0.3.0
279
+ */
280
+ export class Threw extends Schema.TaggedError<Threw>("effect-browser/BrowserError/Threw")(
281
+ "Threw",
282
+ {},
283
+ ) {
168
284
  override get message() {
169
285
  return "the page script threw";
170
286
  }
171
287
  }
172
288
 
173
- export const Reason = Schema.Union([
289
+ /**
290
+ * What went wrong, as `BrowserError`'s `reason`.
291
+ *
292
+ * @stability stable
293
+ * @category errors
294
+ * @since 0.3.0
295
+ */
296
+ export const BrowserErrorReason = Schema.Union([
174
297
  Timeout,
175
298
  Busy,
176
299
  Suspended,
@@ -188,32 +311,74 @@ export const Reason = Schema.Union([
188
311
  Threw,
189
312
  ]);
190
313
 
191
- export type Reason = typeof Reason.Type;
314
+ /**
315
+ * @stability stable
316
+ * @category errors
317
+ * @since 0.3.0
318
+ */
319
+ export type BrowserErrorReason = typeof BrowserErrorReason.Type;
192
320
 
193
- export class BrowserError extends Schema.TaggedError<BrowserError>()("BrowserError", {
194
- operation: Schema.String,
195
- reason: Reason,
196
- dispatched: Schema.Boolean,
197
- }) {
321
+ /**
322
+ * @stability stable
323
+ * @category errors
324
+ * @since 0.3.0
325
+ */
326
+ export class BrowserError extends Schema.TaggedError<BrowserError>("effect-browser/BrowserError")(
327
+ "BrowserError",
328
+ {
329
+ operation: Schema.String,
330
+ reason: BrowserErrorReason,
331
+ dispatched: Schema.Boolean,
332
+ },
333
+ ) {
198
334
  override get message() {
199
335
  return `${this.operation} failed${this.dispatched ? " after it was sent" : ""}: ${this.reason.message}`;
200
336
  }
201
337
  }
202
338
 
339
+ /**
340
+ * Whether a value is a `BrowserError`.
341
+ *
342
+ * @stability stable
343
+ * @category guards
344
+ * @since 0.3.0
345
+ */
346
+ export const isBrowserError: (u: unknown) => u is BrowserError = Schema.is(BrowserError);
347
+
348
+ /**
349
+ * Whether a value is one of `BrowserError`'s reasons.
350
+ *
351
+ * @stability stable
352
+ * @category guards
353
+ * @since 0.3.0
354
+ */
355
+ export const isBrowserErrorReason: (u: unknown) => u is BrowserErrorReason =
356
+ Schema.is(BrowserErrorReason);
357
+
203
358
  /**
204
359
  * What a failure leaves. `lost` is `"page"` when the page is gone and its browser stands, and
205
360
  * `"session"` when the browser is gone with its pages. `repeat` says whether the call can be made
206
361
  * again, on what still stands: `"safe"`, as nothing reached the browser; `"check"`, as it may have
207
- * taken effect, so look first, as a Plan expectation does; `"pointless"`, as it fails again unless
362
+ * taken effect, so look first, as a walk's expectation does; `"pointless"`, as it fails again unless
208
363
  * something changes, such as
209
364
  * a new ref; or `"resume"`, reading events again from a newer cursor.
365
+ *
366
+ * @stability stable
367
+ * @category models
368
+ * @since 0.3.0
210
369
  */
211
370
  export interface Consequence {
212
371
  readonly lost: "nothing" | "page" | "session";
213
372
  readonly repeat: "safe" | "check" | "pointless" | "resume";
214
373
  }
215
374
 
216
- /** What `error` leaves, from its reason and whether it was dispatched alone. */
375
+ /**
376
+ * What `error` leaves, from its reason and whether it was dispatched alone.
377
+ *
378
+ * @stability stable
379
+ * @category combinators
380
+ * @since 0.3.0
381
+ */
217
382
  export const consequence = ({ reason, dispatched }: BrowserError): Consequence => {
218
383
  const repeat = dispatched ? "check" : "safe";
219
384
 
@@ -243,25 +408,49 @@ export const consequence = ({ reason, dispatched }: BrowserError): Consequence =
243
408
  }
244
409
  };
245
410
 
246
- /** A failure before any of the operation's input reached the page. */
247
- export const undispatched = (operation: string, reason: Reason) =>
411
+ /**
412
+ * A failure before any of the operation's input reached the page.
413
+ *
414
+ * @stability stable
415
+ * @category constructors
416
+ * @since 0.3.0
417
+ */
418
+ export const undispatched = (operation: string, reason: BrowserErrorReason) =>
248
419
  new BrowserError({ operation, reason, dispatched: false });
249
420
 
250
- /** Fail an operation before dispatch, preserving its typed reason. */
251
- export const failWith = (operation: string, reason: Reason) =>
421
+ /**
422
+ * Fail an operation before dispatch, preserving its typed reason.
423
+ *
424
+ * @stability stable
425
+ * @category constructors
426
+ * @since 0.3.0
427
+ */
428
+ export const failWith = (operation: string, reason: BrowserErrorReason) =>
252
429
  Effect.fail(undispatched(operation, reason));
253
430
 
254
- /** Refuse an invalid request before sending anything. */
431
+ /**
432
+ * Refuse an invalid request before sending anything.
433
+ *
434
+ * @stability stable
435
+ * @category constructors
436
+ * @since 0.3.0
437
+ */
255
438
  export const refuse = (operation: string, detail: string) =>
256
439
  failWith(operation, new InvalidRequest({ detail }));
257
440
 
258
- /** Translate a protocol/provider failure, redacting diagnostic addresses by default. */
441
+ /**
442
+ * Translate a protocol/provider failure, redacting diagnostic addresses by default.
443
+ *
444
+ * @stability stable
445
+ * @category constructors
446
+ * @since 0.3.0
447
+ */
259
448
  export const reasonOf = (
260
449
  cause: unknown,
261
450
  timeoutMillis?: number,
262
451
  closed: Closed["cause"] = "connection",
263
452
  redact: (message: string) => string = Url.redactWithin,
264
- ): Reason => {
453
+ ): BrowserErrorReason => {
265
454
  const message =
266
455
  cause instanceof Error ? cause.message : typeof cause === "string" ? cause : "unknown error";
267
456
 
@@ -278,7 +467,13 @@ export const reasonOf = (
278
467
  return new Failed({ detail: line.replace(/^[\w.]+: /, "") });
279
468
  };
280
469
 
281
- /** A native call whose action wrapper owns any later dispatch evidence. */
470
+ /**
471
+ * A native call whose action wrapper owns any later dispatch evidence.
472
+ *
473
+ * @stability stable
474
+ * @category constructors
475
+ * @since 0.3.0
476
+ */
282
477
  export const call = <A>(
283
478
  operation: string,
284
479
  run: () => Promise<A>,