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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "effect-browser",
3
- "version": "0.3.0-beta.23",
4
- "description": "Effect browser sessions, page control, screencast and moments over Playwright and CDP.",
3
+ "version": "0.3.0-beta.25",
4
+ "description": "Effect browser sessions, page control, screencast, moments, filming and an agent's browser tools over Playwright and CDP.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -15,6 +15,7 @@
15
15
  "type": "module",
16
16
  "sideEffects": [],
17
17
  "exports": {
18
+ "./package.json": "./package.json",
18
19
  ".": {
19
20
  "workerd": {
20
21
  "@effect-browser/source": "./src/index.ts",
@@ -25,146 +26,65 @@
25
26
  "types": "./dist/index.d.mts",
26
27
  "default": "./dist/index.mjs"
27
28
  },
28
- "./Browser": {
29
- "@effect-browser/source": "./src/Browser.ts",
30
- "types": "./dist/Browser.d.mts",
31
- "default": "./dist/Browser.mjs"
32
- },
33
- "./BrowserError": {
34
- "@effect-browser/source": "./src/BrowserError.ts",
35
- "types": "./dist/BrowserError.d.mts",
36
- "default": "./dist/BrowserError.mjs"
37
- },
38
- "./BrowserEvent": {
39
- "@effect-browser/source": "./src/BrowserEvent.ts",
40
- "types": "./dist/BrowserEvent.d.mts",
41
- "default": "./dist/BrowserEvent.mjs"
42
- },
43
- "./Change": {
44
- "@effect-browser/source": "./src/Change.ts",
45
- "types": "./dist/Change.d.mts",
46
- "default": "./dist/Change.mjs"
47
- },
48
29
  "./Cdp": {
49
30
  "workerd": {
50
- "@effect-browser/source": "./src/workerd/Cdp.ts",
51
- "types": "./dist/workerd/Cdp.d.mts",
52
- "default": "./dist/workerd/Cdp.mjs"
31
+ "@effect-browser/source": "./src/internal/cdp/workerd.ts",
32
+ "types": "./dist/internal/cdp/workerd.d.mts",
33
+ "default": "./dist/internal/cdp/workerd.mjs"
53
34
  },
54
- "@effect-browser/source": "./src/providers/Cdp.ts",
55
- "types": "./dist/providers/Cdp.d.mts",
56
- "default": "./dist/providers/Cdp.mjs"
57
- },
58
- "./Chromium": {
59
- "@effect-browser/source": "./src/providers/Chromium.ts",
60
- "types": "./dist/providers/Chromium.d.mts",
61
- "default": "./dist/providers/Chromium.mjs"
62
- },
63
- "./Frame": {
64
- "@effect-browser/source": "./src/Frame.ts",
65
- "types": "./dist/Frame.d.mts",
66
- "default": "./dist/Frame.mjs"
67
- },
68
- "./Moment": {
69
- "@effect-browser/source": "./src/moment/Moment.ts",
70
- "types": "./dist/moment/Moment.d.mts",
71
- "default": "./dist/moment/Moment.mjs"
72
- },
73
- "./Motion": {
74
- "@effect-browser/source": "./src/presentation/Motion.ts",
75
- "types": "./dist/presentation/Motion.d.mts",
76
- "default": "./dist/presentation/Motion.mjs"
77
- },
78
- "./Page": {
79
- "@effect-browser/source": "./src/Page.ts",
80
- "types": "./dist/Page.d.mts",
81
- "default": "./dist/Page.mjs"
82
- },
83
- "./Plan": {
84
- "@effect-browser/source": "./src/plan/index.ts",
85
- "types": "./dist/plan/index.d.mts",
86
- "default": "./dist/plan/index.mjs"
87
- },
88
- "./Policy": {
89
- "@effect-browser/source": "./src/policy/Policy.ts",
90
- "types": "./dist/policy/Policy.d.mts",
91
- "default": "./dist/policy/Policy.mjs"
92
- },
93
- "./Presentation": {
94
- "@effect-browser/source": "./src/presentation/Presentation.ts",
95
- "types": "./dist/presentation/Presentation.d.mts",
96
- "default": "./dist/presentation/Presentation.mjs"
97
- },
98
- "./Snapshot": {
99
- "@effect-browser/source": "./src/Snapshot.ts",
100
- "types": "./dist/Snapshot.d.mts",
101
- "default": "./dist/Snapshot.mjs"
102
- },
103
- "./Stage": {
104
- "@effect-browser/source": "./src/presentation/Stage.ts",
105
- "types": "./dist/presentation/Stage.d.mts",
106
- "default": "./dist/presentation/Stage.mjs"
107
- },
108
- "./Supervisor": {
109
- "@effect-browser/source": "./src/supervisor/Supervisor.ts",
110
- "types": "./dist/supervisor/Supervisor.d.mts",
111
- "default": "./dist/supervisor/Supervisor.mjs"
112
- },
113
- "./Released": {
114
- "@effect-browser/source": "./src/providers/Released.ts",
115
- "types": "./dist/providers/Released.d.mts",
116
- "default": "./dist/providers/Released.mjs"
117
- },
118
- "./Action": {
119
- "@effect-browser/source": "./src/Action.ts",
120
- "types": "./dist/Action.d.mts",
121
- "default": "./dist/Action.mjs"
122
- },
123
- "./Clock": {
124
- "@effect-browser/source": "./src/Clock.ts",
125
- "types": "./dist/Clock.d.mts",
126
- "default": "./dist/Clock.mjs"
127
- },
128
- "./Geometry": {
129
- "@effect-browser/source": "./src/Geometry.ts",
130
- "types": "./dist/Geometry.d.mts",
131
- "default": "./dist/Geometry.mjs"
132
- },
133
- "./Style": {
134
- "@effect-browser/source": "./src/Style.ts",
135
- "types": "./dist/Style.d.mts",
136
- "default": "./dist/Style.mjs"
137
- },
138
- "./Window": {
139
- "@effect-browser/source": "./src/Window.ts",
140
- "types": "./dist/Window.d.mts",
141
- "default": "./dist/Window.mjs"
142
- },
143
- "./Stillness": {
144
- "@effect-browser/source": "./src/stillness/Stillness.ts",
145
- "types": "./dist/stillness/Stillness.d.mts",
146
- "default": "./dist/stillness/Stillness.mjs"
147
- },
148
- "./Matching": {
149
- "@effect-browser/source": "./src/Matching.ts",
150
- "types": "./dist/Matching.d.mts",
151
- "default": "./dist/Matching.mjs"
35
+ "@effect-browser/source": "./src/Cdp.ts",
36
+ "types": "./dist/Cdp.d.mts",
37
+ "default": "./dist/Cdp.mjs"
38
+ },
39
+ "./timeline": {
40
+ "@effect-browser/source": "./src/timeline/index.ts",
41
+ "types": "./dist/timeline/index.d.mts",
42
+ "default": "./dist/timeline/index.mjs"
43
+ },
44
+ "./presentation": {
45
+ "@effect-browser/source": "./src/presentation/index.ts",
46
+ "types": "./dist/presentation/index.d.mts",
47
+ "default": "./dist/presentation/index.mjs"
48
+ },
49
+ "./walk": {
50
+ "@effect-browser/source": "./src/walk/index.ts",
51
+ "types": "./dist/walk/index.d.mts",
52
+ "default": "./dist/walk/index.mjs"
53
+ },
54
+ "./policy": {
55
+ "@effect-browser/source": "./src/policy/index.ts",
56
+ "types": "./dist/policy/index.d.mts",
57
+ "default": "./dist/policy/index.mjs"
58
+ },
59
+ "./supervisor": {
60
+ "@effect-browser/source": "./src/supervisor/index.ts",
61
+ "types": "./dist/supervisor/index.d.mts",
62
+ "default": "./dist/supervisor/index.mjs"
152
63
  },
153
64
  "./testing": {
154
65
  "@effect-browser/source": "./src/testing/index.ts",
155
66
  "types": "./dist/testing/index.d.mts",
156
67
  "default": "./dist/testing/index.mjs"
157
68
  },
158
- "./Url": {
159
- "@effect-browser/source": "./src/Url.ts",
160
- "types": "./dist/Url.d.mts",
161
- "default": "./dist/Url.mjs"
162
- },
163
- "./ActionPort": {
164
- "@effect-browser/source": "./src/ActionPort.ts",
165
- "types": "./dist/ActionPort.d.mts",
166
- "default": "./dist/ActionPort.mjs"
167
- }
69
+ "./ai": {
70
+ "@effect-browser/source": "./src/ai/index.ts",
71
+ "types": "./dist/ai/index.d.mts",
72
+ "default": "./dist/ai/index.mjs"
73
+ },
74
+ "./*": {
75
+ "@effect-browser/source": "./src/*.ts",
76
+ "types": "./dist/*.d.mts",
77
+ "default": "./dist/*.mjs"
78
+ },
79
+ "./internal/*": null,
80
+ "./timeline/internal/*": null,
81
+ "./presentation/internal/*": null,
82
+ "./walk/internal/*": null,
83
+ "./supervisor/internal/*": null,
84
+ "./testing/internal/*": null,
85
+ "./ai/internal/*": null,
86
+ "./index": null,
87
+ "./*/index": null
168
88
  },
169
89
  "publishConfig": {
170
90
  "access": "public"
@@ -175,6 +95,7 @@
175
95
  "test": "vp test --run"
176
96
  },
177
97
  "devDependencies": {
98
+ "@effect-browser/chromium": "0.3.0-beta.25",
178
99
  "@effect/vitest": "4.1.2",
179
100
  "@types/node": "26.1.2",
180
101
  "effect": "4.1.2",
package/src/Action.ts CHANGED
@@ -1,19 +1,34 @@
1
- /** Typed browser actions, shared by execution, policy, recordings and replay. */
2
- import { Schema } from "effect";
1
+ /**
2
+ * Typed browser actions, shared by execution, policy, recordings and replay.
3
+ *
4
+ * @stability stable
5
+ * @since 0.3.0
6
+ */
7
+ import { Function, Schema } from "effect";
3
8
 
4
- import { Point } from "./Geometry.ts";
5
- import * as Url from "./Url.ts";
9
+ import { Point } from "./internal/geometry.ts";
10
+ import * as Url from "./internal/url.ts";
6
11
 
7
12
  const Ref = Schema.String.check(Schema.isPattern(/^e\d+$/));
8
13
  const Target = Schema.Union([Ref, Point]);
9
14
  const optionalNumber = Schema.optional(Schema.Finite);
10
15
 
16
+ /**
17
+ * @stability stable
18
+ * @category options
19
+ * @since 0.3.0
20
+ */
11
21
  export const ClickOptions = Schema.Struct({
12
22
  button: Schema.optional(Schema.Literals(["left", "right", "middle"])),
13
23
  clickCount: optionalNumber,
14
24
  holdMillis: optionalNumber,
15
25
  });
16
26
 
27
+ /**
28
+ * @stability stable
29
+ * @category options
30
+ * @since 0.3.0
31
+ */
17
32
  export const TypeOptions = Schema.Struct({
18
33
  into: Schema.optional(Ref),
19
34
  replace: Schema.optional(Schema.Boolean),
@@ -21,18 +36,33 @@ export const TypeOptions = Schema.Struct({
21
36
  secret: Schema.optional(Schema.Boolean),
22
37
  });
23
38
 
39
+ /**
40
+ * @stability stable
41
+ * @category options
42
+ * @since 0.3.0
43
+ */
24
44
  export const PressOptions = Schema.Struct({
25
45
  on: Schema.optional(Ref),
26
46
  times: optionalNumber,
27
47
  holdMillis: optionalNumber,
28
48
  });
29
49
 
50
+ /**
51
+ * @stability stable
52
+ * @category options
53
+ * @since 0.3.0
54
+ */
30
55
  export const ScrollOptions = Schema.Struct({
31
56
  at: Schema.optional(Target),
32
57
  dx: optionalNumber,
33
58
  dy: optionalNumber,
34
59
  });
35
60
 
61
+ /**
62
+ * @stability stable
63
+ * @category schemas
64
+ * @since 0.3.0
65
+ */
36
66
  export const Action = Schema.TaggedUnion({
37
67
  Click: { target: Target, options: Schema.optional(ClickOptions) },
38
68
  Hover: { target: Target },
@@ -48,8 +78,18 @@ export const Action = Schema.TaggedUnion({
48
78
  Act: { document: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)) },
49
79
  });
50
80
 
81
+ /**
82
+ * @stability stable
83
+ * @category models
84
+ * @since 0.3.0
85
+ */
51
86
  export type Action = typeof Action.Type;
52
87
 
88
+ /**
89
+ * @stability stable
90
+ * @category schemas
91
+ * @since 0.3.0
92
+ */
53
93
  export const Name = Schema.Literals([
54
94
  "click",
55
95
  "hover",
@@ -64,10 +104,24 @@ export const Name = Schema.Literals([
64
104
  "act",
65
105
  ]);
66
106
 
107
+ /**
108
+ * @stability stable
109
+ * @category models
110
+ * @since 0.3.0
111
+ */
67
112
  export type Name = typeof Name.Type;
68
113
 
69
- /** Effective semantics suitable for policy and records; credentials never survive. */
70
- export const recorded = (value: Action, revealed: boolean): Action => {
114
+ /**
115
+ * Effective semantics suitable for policy and records; credentials never survive.
116
+ *
117
+ * @stability stable
118
+ * @category combinators
119
+ * @since 0.3.0
120
+ */
121
+ export const recorded: {
122
+ (revealed: boolean): (value: Action) => Action;
123
+ (value: Action, revealed: boolean): Action;
124
+ } = Function.dual(2, (value: Action, revealed: boolean): Action => {
71
125
  if (value._tag === "Type") {
72
126
  const secret = !revealed || value.options?.secret === true;
73
127
 
@@ -83,7 +137,7 @@ export const recorded = (value: Action, revealed: boolean): Action => {
83
137
  }
84
138
 
85
139
  return value._tag === "Goto" ? { ...value, url: Url.redact(value.url) } : value;
86
- };
140
+ });
87
141
 
88
142
  /** The stable event vocabulary for an action. */
89
143
  const names: Record<Action["_tag"], Name> = {
@@ -100,9 +154,20 @@ const names: Record<Action["_tag"], Name> = {
100
154
  Act: "act",
101
155
  };
102
156
 
157
+ /**
158
+ * @stability stable
159
+ * @category combinators
160
+ * @since 0.3.0
161
+ */
103
162
  export const nameOf = (action: Action): Name => names[action._tag];
104
163
 
105
- /** The primary target, if this action addresses an element or point. */
164
+ /**
165
+ * The primary target, if this action addresses an element or point.
166
+ *
167
+ * @stability stable
168
+ * @category combinators
169
+ * @since 0.3.0
170
+ */
106
171
  export const targetOf = (action: Action) => {
107
172
  switch (action._tag) {
108
173
  case "Click":
package/src/Browser.ts CHANGED
@@ -3,9 +3,10 @@
3
3
  *
4
4
  * `Browser` is a service with one implementation, built by a provider over a Playwright browser
5
5
  * context: `Chromium` launches one locally, `Cdp` connects to any DevTools endpoint and
6
- * `effect-browserbase` allocates a hosted one. Code written against `Browser` runs on all three.
6
+ * `@effect-browser/browserbase` allocates a hosted one. Code written against `Browser` runs on all three.
7
7
  * A page is named by its CDP target id, so a new connection to the same browser finds it again.
8
8
  *
9
+ * @stability stable
9
10
  * @since 0.3.0
10
11
  */
11
12
  import {
@@ -35,8 +36,9 @@ import {
35
36
  Timeout,
36
37
  } from "./BrowserError.ts";
37
38
  import * as Events from "./BrowserEvent.ts";
38
- import * as BrowserClock from "./Clock.ts";
39
+ import * as BrowserClock from "./internal/clock.ts";
39
40
  import * as Gate from "./internal/input/gate.ts";
41
+ import { documentScripts } from "./internal/page/bridge.ts";
40
42
  import { call, failWith, type Settings, undispatched } from "./internal/page/context.ts";
41
43
  import { listen } from "./internal/page/dialogs.ts";
42
44
  import * as Identity from "./internal/page/identity.ts";
@@ -46,10 +48,16 @@ import * as PageImpl from "./internal/page/page.ts";
46
48
  import * as Port from "./internal/page/port.ts";
47
49
  import * as Requests from "./internal/page/requests.ts";
48
50
  import * as Timeline from "./internal/timeline/events.ts";
51
+ import * as Url from "./internal/url.ts";
49
52
  import type * as Page from "./Page.ts";
50
- import * as Url from "./Url.ts";
51
53
 
52
- /** A script that documents run before their own, such as a consent-banner remover. */
54
+ /**
55
+ * A script that documents run before their own, such as a consent-banner remover.
56
+ *
57
+ * @stability stable
58
+ * @category models
59
+ * @since 0.3.0
60
+ */
53
61
  export interface InitScript {
54
62
  /**
55
63
  * The documents that run it, by a pattern their address (`location.href`) matches; every
@@ -60,7 +68,13 @@ export interface InitScript {
60
68
  readonly source: string;
61
69
  }
62
70
 
63
- /** Consumer-owned decision for one request caught by a narrow URL pattern. */
71
+ /**
72
+ * Consumer-owned decision for one request caught by a narrow URL pattern.
73
+ *
74
+ * @stability stable
75
+ * @category models
76
+ * @since 0.3.0
77
+ */
64
78
  export type RequestDecision =
65
79
  | { readonly _tag: "Allowed" }
66
80
  | { readonly _tag: "Refused"; readonly reason: string }
@@ -72,6 +86,11 @@ export type RequestDecision =
72
86
  readonly body: string;
73
87
  };
74
88
 
89
+ /**
90
+ * @stability stable
91
+ * @category models
92
+ * @since 0.3.0
93
+ */
75
94
  export interface RequestPolicy {
76
95
  readonly patterns: ReadonlyArray<string>;
77
96
  /**
@@ -88,6 +107,11 @@ export interface RequestPolicy {
88
107
  readonly timeout?: Duration.Input | undefined;
89
108
  }
90
109
 
110
+ /**
111
+ * @stability stable
112
+ * @category options
113
+ * @since 0.3.0
114
+ */
91
115
  export interface Options {
92
116
  /** Fixed viewport applied before each existing or newly opened page registers. */
93
117
  readonly viewport?: { readonly width: number; readonly height: number } | undefined;
@@ -102,7 +126,7 @@ export interface Options {
102
126
  /** Bound on each navigation; finite and positive. Defaults to 30 seconds. */
103
127
  readonly navigationTimeout?: Duration.Input | undefined;
104
128
  /**
105
- * How long each page keeps screencast frames for `recentFrames`, measured back from the newest;
129
+ * How long each page keeps screencast frames for `Frame.recent`, measured back from the newest;
106
130
  * finite and positive. Defaults to 5 seconds, a moment's default window.
107
131
  */
108
132
  readonly frameHistory?: Duration.Input | undefined;
@@ -114,6 +138,12 @@ export interface Options {
114
138
  readonly policyTimeout?: Duration.Input | undefined;
115
139
  /** Scripts that new documents run before their own, each where its `match` allows. */
116
140
  readonly initScripts?: ReadonlyArray<InitScript> | undefined;
141
+ /**
142
+ * Run a page clock in each top document before its own scripts, so `PageTime.hold` can hold and
143
+ * step its time. It keeps real time until held, but replaces the page's timers, animation
144
+ * frames, `Date` and `performance.now`, which a page script can notice. See `PageTime`.
145
+ */
146
+ readonly pageTime?: boolean | undefined;
117
147
  /**
118
148
  * The most pages the browser keeps open, those a site opens included, which are never refused. At
119
149
  * it, `newPage` waits for one to close, within the action timeout, then fails `Limit`; under
@@ -122,18 +152,34 @@ export interface Options {
122
152
  readonly maxPages?: number | undefined;
123
153
  }
124
154
 
155
+ /**
156
+ * @stability stable
157
+ * @category options
158
+ * @since 0.3.0
159
+ */
125
160
  export interface EventOptions {
126
161
  /** Resume after this sequence; 0 replays from the beginning if it is still retained. */
127
162
  readonly after?: number | undefined;
128
163
  }
129
164
 
165
+ /**
166
+ * @stability stable
167
+ * @category options
168
+ * @since 0.3.0
169
+ */
130
170
  export interface SuspendOptions {
131
171
  /** Finite, nonnegative drain bound; defaults to the browser's navigationTimeout. */
132
172
  readonly drain?: Duration.Input | undefined;
133
173
  }
134
174
 
135
- /** When admitted input finished; events after `since` describe the handoff interval. */
136
- export class Suspension extends Schema.Class<Suspension>("effect-browser/Suspension")({
175
+ /**
176
+ * When admitted input finished; events after `since` describe the handoff interval.
177
+ *
178
+ * @stability stable
179
+ * @category schemas
180
+ * @since 0.3.0
181
+ */
182
+ export class Suspension extends Schema.Class<Suspension>("effect-browser/Browser/Suspension")({
137
183
  since: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
138
184
  at: Schema.Finite,
139
185
  }) {}
@@ -145,6 +191,10 @@ export class Suspension extends Schema.Class<Suspension>("effect-browser/Suspens
145
191
  * on the connection that drives the page. It is read-only. A page's session on it sends the
146
192
  * capture's commands alone, and the page's own session keeps its focus emulation, which keeps a
147
193
  * tab behind painting.
194
+ *
195
+ * @stability stable
196
+ * @category models
197
+ * @since 0.3.0
148
198
  */
149
199
  export interface CaptureSource {
150
200
  /**
@@ -173,6 +223,11 @@ export interface CaptureSource {
173
223
  >;
174
224
  }
175
225
 
226
+ /**
227
+ * @stability stable
228
+ * @category models
229
+ * @since 0.3.0
230
+ */
176
231
  export interface Service {
177
232
  /** The provider's session id, or a local id. */
178
233
  readonly id: string;
@@ -210,8 +265,22 @@ export interface Service {
210
265
  readonly recentEvents: Effect.Effect<ReadonlyArray<Events.BrowserEvent>>;
211
266
  }
212
267
 
268
+ /**
269
+ * @stability stable
270
+ * @category services
271
+ * @since 0.3.0
272
+ */
213
273
  export class Browser extends Context.Service<Browser, Service>()("effect-browser/Browser") {}
214
274
 
275
+ /**
276
+ * Open a page in the context's `Browser`, at `url` when given.
277
+ *
278
+ * @stability stable
279
+ * @category constructors
280
+ * @since 0.3.0
281
+ */
282
+ export const newPage = (url?: string) => Effect.flatMap(Browser, (browser) => browser.newPage(url));
283
+
215
284
  /** The settings every page shares, and how many events the browser keeps, from its options. */
216
285
  const settingsOf = Effect.fnUntraced(function* (options: Options) {
217
286
  const invalid = (detail: string) => undispatched("make", new InvalidRequest({ detail }));
@@ -237,6 +306,8 @@ const settingsOf = Effect.fnUntraced(function* (options: Options) {
237
306
  frameHistory: yield* bound("frameHistory", options.frameHistory, Duration.seconds(5)),
238
307
  guard: options.guard,
239
308
  policyTimeout: yield* bound("policyTimeout", options.policyTimeout, Duration.minutes(5)),
309
+ // An event name the page's own scripts cannot guess, which only the clock listens for.
310
+ pageTime: options.pageTime === true ? `effect-browser-time-${yield* Identity.make}` : undefined,
240
311
  };
241
312
 
242
313
  if (
@@ -397,10 +468,6 @@ const eventsOf = (recent: Effect.Effect<ReadonlyArray<Events.RecordedEvent>>, pa
397
468
  ),
398
469
  );
399
470
 
400
- /** A script as its documents run it: everywhere, or as a block where its `match` allows. */
401
- const scoped = ({ match, source }: InitScript) =>
402
- match === undefined ? source : `if (${String(match)}.test(location.href)) {\n${source}\n}`;
403
-
404
471
  /**
405
472
  * At most `maxPages` open pages, those a site opened included, which are never refused: an open
406
473
  * past it waits for one to close, within `wait` on the owner's clock, then fails `Limit`, or fails
@@ -628,6 +695,10 @@ const runtime = Effect.fnUntraced(function* (
628
695
  * tracks its pages and events, for as long as the surrounding scope is open. Each page's protocol
629
696
  * session, capture and listeners end when that page closes or when the scope does, so a closed
630
697
  * tab retains nothing and the context keeps none of them afterwards.
698
+ *
699
+ * @stability stable
700
+ * @category constructors
701
+ * @since 0.3.0
631
702
  */
632
703
  export const make = Effect.fn("Browser.make")(function* (
633
704
  context: BrowserContext,
@@ -783,8 +854,8 @@ export const make = Effect.fn("Browser.make")(function* (
783
854
 
784
855
  // Playwright registers its init scripts as it sets up each page, before a popup's first document
785
856
  // runs, and they cost no call per document.
786
- for (const script of options.initScripts ?? [])
787
- yield* native("initScripts", () => context.addInitScript({ content: scoped(script) }));
857
+ for (const content of documentScripts(settings.pageTime, options.initScripts ?? []))
858
+ yield* native("initScripts", () => context.addInitScript({ content }));
788
859
  const register = yield* followOpened(context, registrations, registerPage, publish, now);
789
860
 
790
861
  for (const existing of context.pages()) yield* register(existing);