effect-browser 0.3.0-beta.20 → 0.3.0-beta.22

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 (243) hide show
  1. package/README.md +221 -158
  2. package/dist/Action-24sLOubi.d.mts +110 -0
  3. package/dist/Action.d.mts +2 -0
  4. package/dist/Action.mjs +141 -0
  5. package/dist/Action.mjs.map +1 -0
  6. package/dist/ActionPort.d.mts +15 -0
  7. package/dist/ActionPort.mjs +101 -0
  8. package/dist/ActionPort.mjs.map +1 -0
  9. package/dist/Browser-Cq2K1FEA.mjs +4075 -0
  10. package/dist/Browser-Cq2K1FEA.mjs.map +1 -0
  11. package/dist/Browser-wZhwZSlG.d.mts +167 -0
  12. package/dist/Browser.d.mts +2 -129
  13. package/dist/Browser.mjs +1 -1
  14. package/dist/{BrowserError-Coy7EW1N.d.mts → BrowserError-BlcmLVzn.d.mts} +22 -7
  15. package/dist/BrowserError.d.mts +2 -2
  16. package/dist/BrowserError.mjs +46 -9
  17. package/dist/BrowserError.mjs.map +1 -1
  18. package/dist/{BrowserEvent-dq6FRT8w.d.mts → BrowserEvent-lLqJ3GJS.d.mts} +93 -37
  19. package/dist/BrowserEvent.d.mts +2 -2
  20. package/dist/BrowserEvent.mjs +29 -24
  21. package/dist/BrowserEvent.mjs.map +1 -1
  22. package/dist/{Change-DqING3tr.d.mts → Change-Ba7INmay.d.mts} +4 -6
  23. package/dist/Change.d.mts +2 -2
  24. package/dist/Change.mjs +97 -2
  25. package/dist/Change.mjs.map +1 -0
  26. package/dist/Clock.d.mts +57 -0
  27. package/dist/Clock.mjs +80 -0
  28. package/dist/Clock.mjs.map +1 -0
  29. package/dist/{Frame-DkNdjjjr.d.mts → Frame-UEH2hO5T.d.mts} +10 -3
  30. package/dist/Frame.d.mts +2 -2
  31. package/dist/Frame.mjs +10 -2
  32. package/dist/Frame.mjs.map +1 -1
  33. package/dist/{Motion-DND6I-64.d.mts → Geometry-DJx9qrYy.d.mts} +7 -10
  34. package/dist/Geometry.d.mts +2 -0
  35. package/dist/Geometry.mjs +32 -0
  36. package/dist/Geometry.mjs.map +1 -0
  37. package/dist/LICENSE-jpeg-js +28 -0
  38. package/dist/Matching.d.mts +37 -0
  39. package/dist/{match.inpage-xOe9LNO0.mjs → Matching.mjs} +28 -4
  40. package/dist/Matching.mjs.map +1 -0
  41. package/dist/{Page-CfB6Zn1p.mjs → Page-BF5izr8R.mjs} +216 -31
  42. package/dist/Page-BF5izr8R.mjs.map +1 -0
  43. package/dist/{Page-ku6j5t-v.d.mts → Page-CvsOEorc.d.mts} +158 -185
  44. package/dist/Page.d.mts +2 -2
  45. package/dist/Page.mjs +1 -1
  46. package/dist/Released-tURbFmal.d.mts +15 -0
  47. package/dist/{Snapshot-B34hZ4Jl.d.mts → Snapshot-CtBVOtuu.d.mts} +6 -1
  48. package/dist/Snapshot.d.mts +1 -1
  49. package/dist/Snapshot.mjs.map +1 -1
  50. package/dist/Stillness-CNlvayIo.mjs +136 -0
  51. package/dist/Stillness-CNlvayIo.mjs.map +1 -0
  52. package/dist/Style-AO4V7Czt.mjs +357 -0
  53. package/dist/Style-AO4V7Czt.mjs.map +1 -0
  54. package/dist/Style.d.mts +72 -0
  55. package/dist/Style.mjs +2 -0
  56. package/dist/Url.d.mts +26 -0
  57. package/dist/Url.mjs +74 -0
  58. package/dist/Url.mjs.map +1 -0
  59. package/dist/Window-CMddGMt1.d.mts +34 -0
  60. package/dist/Window.d.mts +2 -0
  61. package/dist/Window.mjs +35 -0
  62. package/dist/Window.mjs.map +1 -0
  63. package/dist/connection-2KHI4_KN.d.mts +41 -0
  64. package/dist/connection-BTeO0Hiz.mjs +68 -0
  65. package/dist/connection-BTeO0Hiz.mjs.map +1 -0
  66. package/dist/index.d.mts +15 -17
  67. package/dist/index.mjs +11 -14
  68. package/dist/moment/Moment.d.mts +86 -0
  69. package/dist/{Moment.mjs → moment/Moment.mjs} +44 -38
  70. package/dist/moment/Moment.mjs.map +1 -0
  71. package/dist/{Plan-DJ4hEEna.d.mts → plan/index.d.mts} +169 -64
  72. package/dist/{Plan-C-d5QYS8.mjs → plan/index.mjs} +122 -155
  73. package/dist/plan/index.mjs.map +1 -0
  74. package/dist/{Policy.d.mts → policy/Policy.d.mts} +5 -9
  75. package/dist/{Policy.mjs → policy/Policy.mjs} +11 -21
  76. package/dist/policy/Policy.mjs.map +1 -0
  77. package/dist/presentation/Motion.d.mts +12 -0
  78. package/dist/{Motion.mjs → presentation/Motion.mjs} +4 -27
  79. package/dist/presentation/Motion.mjs.map +1 -0
  80. package/dist/presentation/Presentation.d.mts +30 -0
  81. package/dist/presentation/Presentation.mjs +105 -0
  82. package/dist/presentation/Presentation.mjs.map +1 -0
  83. package/dist/{Stage.d.mts → presentation/Stage.d.mts} +5 -8
  84. package/dist/{Stage.mjs → presentation/Stage.mjs} +68 -76
  85. package/dist/presentation/Stage.mjs.map +1 -0
  86. package/dist/presentation/feed.d.mts +20 -0
  87. package/dist/presentation/feed.mjs +18 -0
  88. package/dist/presentation/feed.mjs.map +1 -0
  89. package/dist/providers/Cdp.d.mts +9 -0
  90. package/dist/providers/Cdp.mjs +15 -0
  91. package/dist/providers/Cdp.mjs.map +1 -0
  92. package/dist/{Chromium.d.mts → providers/Chromium.d.mts} +6 -7
  93. package/dist/{Chromium.mjs → providers/Chromium.mjs} +7 -16
  94. package/dist/providers/Chromium.mjs.map +1 -0
  95. package/dist/providers/Released.d.mts +2 -0
  96. package/dist/providers/Released.mjs +12 -0
  97. package/dist/providers/Released.mjs.map +1 -0
  98. package/dist/stillness/Stillness.d.mts +12 -0
  99. package/dist/stillness/Stillness.mjs +2 -0
  100. package/dist/supervisor/Supervisor.d.mts +104 -0
  101. package/dist/supervisor/Supervisor.mjs +513 -0
  102. package/dist/supervisor/Supervisor.mjs.map +1 -0
  103. package/dist/testing/index.d.mts +337 -0
  104. package/dist/testing/index.mjs +515 -0
  105. package/dist/testing/index.mjs.map +1 -0
  106. package/dist/workerd/Cdp.d.mts +8 -0
  107. package/dist/workerd/Cdp.mjs +13 -0
  108. package/dist/workerd/Cdp.mjs.map +1 -0
  109. package/package.json +94 -33
  110. package/src/Action.ts +127 -0
  111. package/src/ActionPort.ts +128 -0
  112. package/src/Browser.ts +366 -225
  113. package/src/BrowserError.ts +63 -6
  114. package/src/BrowserEvent.ts +26 -25
  115. package/src/Change.ts +0 -2
  116. package/src/{internal/pictures/clock.ts → Clock.ts} +17 -6
  117. package/src/Frame.ts +14 -0
  118. package/src/Geometry.ts +48 -0
  119. package/src/{internal/reading/match.inpage.ts → Matching.ts} +34 -4
  120. package/src/Page.ts +111 -92
  121. package/src/Snapshot.ts +5 -0
  122. package/src/{internal/input/style.ts → Style.ts} +121 -14
  123. package/src/Window.ts +30 -0
  124. package/src/index.ts +8 -13
  125. package/src/internal/input/actions.ts +61 -119
  126. package/src/internal/input/dispatch.ts +3 -3
  127. package/src/internal/input/gate.ts +21 -18
  128. package/src/internal/input/guard.inpage.ts +25 -58
  129. package/src/internal/input/guard.ts +11 -20
  130. package/src/internal/input/keyboard.ts +12 -3
  131. package/src/internal/input/perform.ts +78 -60
  132. package/src/internal/input/pointer.ts +4 -2
  133. package/src/internal/input/settle.ts +7 -5
  134. package/src/internal/input/targets.inpage.ts +1 -1
  135. package/src/internal/input/targets.ts +4 -9
  136. package/src/internal/page/bridge.ts +210 -114
  137. package/src/internal/page/context.ts +23 -73
  138. package/src/internal/page/dialogs.ts +58 -0
  139. package/src/internal/page/identity.ts +6 -23
  140. package/src/internal/page/lane.ts +14 -15
  141. package/src/internal/page/navigation.ts +50 -42
  142. package/src/internal/page/openings.ts +11 -5
  143. package/src/internal/page/page.ts +44 -81
  144. package/src/internal/page/port.ts +125 -0
  145. package/src/internal/{input → page}/replies.ts +1 -1
  146. package/src/internal/page/request-owner.ts +269 -0
  147. package/src/internal/page/requests.ts +357 -0
  148. package/src/internal/page/scripts.ts +124 -0
  149. package/src/internal/pictures/capture.ts +255 -332
  150. package/src/internal/pictures/dimensions.ts +162 -0
  151. package/src/internal/pictures/frame.ts +68 -0
  152. package/src/internal/pictures/pictures.ts +57 -23
  153. package/src/internal/pictures/quiescence.ts +1 -1
  154. package/src/internal/pictures/state.ts +26 -0
  155. package/src/internal/pictures/transport.ts +21 -4
  156. package/src/internal/reading/controls.inpage.ts +5 -70
  157. package/src/internal/reading/expect.inpage.ts +13 -17
  158. package/src/internal/reading/names.inpage.ts +89 -45
  159. package/src/internal/reading/outline.inpage.ts +6 -7
  160. package/src/internal/reading/reading.ts +144 -176
  161. package/src/internal/reading/ready.inpage.ts +6 -17
  162. package/src/internal/reading/ready.ts +13 -135
  163. package/src/internal/reading/subjects.inpage.ts +83 -43
  164. package/src/internal/reading/walk.inpage.ts +33 -13
  165. package/src/internal/timeline/changes.ts +55 -6
  166. package/src/internal/timeline/events.ts +15 -5
  167. package/src/internal/timeline/history.inpage.ts +1 -1
  168. package/src/internal/timeline/record.inpage.ts +4 -1
  169. package/src/internal/timeline/window.ts +2 -1
  170. package/src/{Moment.ts → moment/Moment.ts} +13 -31
  171. package/src/{internal/timeline → moment}/words.ts +2 -2
  172. package/src/{internal/reading → plan}/choose.ts +3 -3
  173. package/src/plan/data.ts +117 -0
  174. package/src/plan/execute.ts +411 -0
  175. package/src/plan/index.ts +36 -0
  176. package/src/plan/record.ts +71 -0
  177. package/src/plan/targets.ts +71 -0
  178. package/src/{Policy.ts → policy/Policy.ts} +13 -10
  179. package/src/{Motion.ts → presentation/Motion.ts} +12 -46
  180. package/src/presentation/Presentation.ts +176 -0
  181. package/src/{Stage.ts → presentation/Stage.ts} +147 -112
  182. package/src/presentation/feed.ts +21 -0
  183. package/src/providers/Cdp.ts +16 -0
  184. package/src/{Chromium.ts → providers/Chromium.ts} +7 -10
  185. package/src/providers/Released.ts +13 -0
  186. package/src/providers/connection.ts +134 -0
  187. package/src/{internal/pictures/motion.ts → stillness/Pixels.ts} +4 -4
  188. package/src/stillness/Stillness.ts +166 -0
  189. package/src/supervisor/Supervisor.ts +170 -0
  190. package/src/supervisor/contract.ts +105 -0
  191. package/src/supervisor/lifecycle.ts +272 -0
  192. package/src/supervisor/runtime.ts +234 -0
  193. package/src/testing/TestBrowser.ts +115 -0
  194. package/src/testing/TestPage.ts +10 -0
  195. package/src/testing/evidence.ts +154 -0
  196. package/src/testing/index.ts +3 -0
  197. package/src/testing/model.ts +222 -0
  198. package/src/testing/page.ts +360 -0
  199. package/src/workerd/Cdp.ts +11 -0
  200. package/dist/Browser-BwCldIff.mjs +0 -629
  201. package/dist/Browser-BwCldIff.mjs.map +0 -1
  202. package/dist/Cdp.d.mts +0 -32
  203. package/dist/Cdp.mjs +0 -61
  204. package/dist/Cdp.mjs.map +0 -1
  205. package/dist/Change-DNvztNLu.mjs +0 -138
  206. package/dist/Change-DNvztNLu.mjs.map +0 -1
  207. package/dist/Chromium.mjs.map +0 -1
  208. package/dist/Expect.d.mts +0 -62
  209. package/dist/Expect.mjs +0 -114
  210. package/dist/Expect.mjs.map +0 -1
  211. package/dist/Moment.d.mts +0 -2
  212. package/dist/Moment.mjs.map +0 -1
  213. package/dist/Motion.d.mts +0 -2
  214. package/dist/Motion.mjs.map +0 -1
  215. package/dist/Page-CfB6Zn1p.mjs.map +0 -1
  216. package/dist/Plan-C-d5QYS8.mjs.map +0 -1
  217. package/dist/Plan.d.mts +0 -2
  218. package/dist/Plan.mjs +0 -2
  219. package/dist/Policy.mjs.map +0 -1
  220. package/dist/Presentation.d.mts +0 -48
  221. package/dist/Presentation.mjs +0 -118
  222. package/dist/Presentation.mjs.map +0 -1
  223. package/dist/Stage.mjs.map +0 -1
  224. package/dist/Supervisor-2mPjIYYs.mjs +0 -676
  225. package/dist/Supervisor-2mPjIYYs.mjs.map +0 -1
  226. package/dist/Supervisor-mVPeEUp8.d.mts +0 -317
  227. package/dist/Supervisor.d.mts +0 -2
  228. package/dist/Supervisor.mjs +0 -2
  229. package/dist/context-w3NJPRLo.mjs +0 -335
  230. package/dist/context-w3NJPRLo.mjs.map +0 -1
  231. package/dist/match.inpage-xOe9LNO0.mjs.map +0 -1
  232. package/dist/page-BKwfF6z-.mjs +0 -5099
  233. package/dist/page-BKwfF6z-.mjs.map +0 -1
  234. package/dist/url-Cd04Okid.mjs +0 -264
  235. package/dist/url-Cd04Okid.mjs.map +0 -1
  236. package/src/Cdp.ts +0 -101
  237. package/src/Expect.ts +0 -180
  238. package/src/Plan.ts +0 -674
  239. package/src/Presentation.ts +0 -196
  240. package/src/Supervisor.ts +0 -632
  241. package/src/internal/supervisor/lifecycle.ts +0 -484
  242. /package/src/{internal/page/url.ts → Url.ts} +0 -0
  243. /package/src/{internal/pictures → stillness}/utilsBundle.d.ts +0 -0
@@ -1,109 +1,14 @@
1
- import { p as PolicyDenied, t as BrowserError } from "./BrowserError-Coy7EW1N.mjs";
2
- import { E as WheelScrolled, S as TextInserted, T as TrackPlanned, _ as PointerReleased, b as Subject, d as Navigated, f as PageClosed, g as PointerPressed, h as PageUntracked, i as BrowserEvent, l as Disconnected, m as PageOpened, o as CursorChanged, p as PageLoaded, r as Box, s as DialogShown, t as Action, u as KeyChanged, w as TrackPerformed, y as SessionEnding } from "./BrowserEvent-dq6FRT8w.mjs";
3
- import { r as Changes, t as Change } from "./Change-DqING3tr.mjs";
4
- import { a as Image, n as CaptureStats, o as ScreencastOptions, r as Frame } from "./Frame-DkNdjjjr.mjs";
5
- import { n as Snapshot, r as SnapshotOptions } from "./Snapshot-B34hZ4Jl.mjs";
6
- import { r as Point$1, t as Motion_d_exports } from "./Motion-DND6I-64.mjs";
7
- import { Duration, Effect, Schema, Stream } from "effect";
8
- import { Prompt } from "effect/ai";
9
- import { Page } from "playwright-core";
10
- declare namespace Moment_d_exports {
11
- export { Account, CaptureOptions, Moment, Window, account, capture, toPrompt };
12
- }
13
- declare const Window_base: Schema.Class<Window, Schema.Struct<{
14
- readonly page: Schema.String;
15
- /** Where the window starts, in host monotonic milliseconds on the owning browser’s clock. */
16
- readonly since: Schema.Finite;
17
- /** Where it ends, never after it was taken. */
18
- readonly until: Schema.Finite;
19
- /** The page's events after `since`, up to `until`, oldest first, without the input presentation track. */
20
- readonly events: Schema.$Array<Schema.Union<readonly [typeof PageOpened, typeof PageClosed, typeof PageUntracked, typeof Navigated, typeof PageLoaded, typeof Action, typeof TrackPlanned, typeof TrackPerformed, typeof PointerPressed, typeof PointerReleased, typeof WheelScrolled, typeof KeyChanged, typeof TextInserted, typeof CursorChanged, typeof DialogShown, typeof Disconnected, typeof SessionEnding]>>;
21
- /**
22
- * What visibly changed after `since`, up to `until`; absent where `missing` says why. A page's
23
- * first window starts its record, so the record sees none of it.
24
- */
25
- readonly changes: Schema.optional<typeof Changes>;
26
- /** Screencast frames painted from `since` to `until`, oldest first, as far back as kept. */
27
- readonly frames: Schema.$Array<typeof Frame>;
28
- /**
29
- * Why each part that could not be read is missing: the read of its changes, by whatever
30
- * operation failed there, or a moment's picture (`frame`) or outline (`snapshot`).
31
- */
32
- readonly missing: Schema.$Array<typeof BrowserError>;
33
- }>, {}>;
34
- /** A page's events, changes and frames over one window of its browser's host clock. */
35
- declare class Window extends Window_base {}
36
- declare const Moment_base: Schema.Class<Moment, Schema.Struct<{
37
- readonly page: Schema.String;
38
- readonly since: Schema.Finite;
39
- readonly until: Schema.Finite;
40
- readonly events: Schema.$Array<Schema.Union<readonly [typeof PageOpened, typeof PageClosed, typeof PageUntracked, typeof Navigated, typeof PageLoaded, typeof Action, typeof TrackPlanned, typeof TrackPerformed, typeof PointerPressed, typeof PointerReleased, typeof WheelScrolled, typeof KeyChanged, typeof TextInserted, typeof CursorChanged, typeof DialogShown, typeof Disconnected, typeof SessionEnding]>>;
41
- readonly changes: Schema.optional<typeof Changes>;
42
- readonly frames: Schema.$Array<typeof Frame>;
43
- readonly missing: Schema.$Array<typeof BrowserError>;
44
- snapshot: Schema.optional<typeof Snapshot>;
45
- }>, Window> & Pick<{}, never>;
46
- /**
47
- * A window that ends at a picture of the page, its last frame, unless `missing` says why it has
48
- * none. Its frames are a few, spread over the window, so that it still begins where it starts.
49
- */
50
- declare class Moment extends Moment_base {}
51
- interface CaptureOptions {
52
- /**
53
- * Where the window starts, as for `Page.window`: a previous window or moment, so that consecutive
54
- * ones neither repeat nor miss an event or a change, or a `Duration` back from the picture.
55
- * Defaults to 5 seconds.
56
- */
57
- readonly since?: WindowOptions["since"] | undefined;
58
- /** Frames to keep, at least 1, spread over the window and ending with the picture. Defaults to 2. */
59
- readonly frames?: number | undefined;
60
- /**
61
- * Whether to take the page's outline at the end, or its options; `true` means 4,000 characters.
62
- * Defaults to `false`: the frames and the timeline carry most moments, while an outline costs a
63
- * round trip to the page and can double a moment's tokens.
64
- */
65
- readonly snapshot?: SnapshotOptions | boolean | undefined;
66
- /** Show what fields hold in the moment's changes; a secret field still reads `••••`. */
67
- readonly unmask?: boolean | undefined;
68
- }
69
- declare const capture: (page: Page$1, options?: CaptureOptions | undefined) => Effect.Effect<Moment, BrowserError, never>;
70
- /** What a window says of its page at its end: what was still in flux, and what had settled. */
71
- interface Account {
72
- /**
73
- * How long, in milliseconds, the page had been still at the end: since the last change in view
74
- * its record shows, or the last paint its screencast frames show, or else since the window, or
75
- * its record, began. Undefined where neither could tell, with no record of the window and no
76
- * painted frame: a screenshot shows the page, not when it last changed. Frames show paint only
77
- * while a capture runs, and the record does not see a canvas, so a canvas that keeps drawing
78
- * with no capture running reads as still.
79
- */
80
- readonly stillFor: number | undefined;
81
- /**
82
- * The changes still under way at the end: what kept changing, more than once in the window or
83
- * already before it, and changed again within twice its own pace before the end.
84
- */
85
- readonly changing: ReadonlyArray<Change>;
86
- /** Every other change, which shows what it settled at. */
87
- readonly settled: ReadonlyArray<Change>;
88
- }
89
- /**
90
- * An account of the window's page at its end: how long it had been still, and which of its
91
- * changes were still under way and which had settled. A window whose record saw none of it has
92
- * neither.
93
- */
94
- declare const account: (window: Window) => Account;
95
- /**
96
- * The moment as one user message: the page's outline when the moment has one, what changed, most
97
- * notable first, what kept changing told as still changing at the moment or settled since when, by
98
- * its account, with the actions that the changes followed, that changes followed though none
99
- * names them, or that drew what only the screenshots show, what could not be read and why, and its
100
- * frames captioned with their times, the last one "the moment" where it is the picture at its end.
101
- * Give a model its task with `Prompt.setSystem`, and add what the caller knows about the page as
102
- * more text.
103
- */
104
- declare const toPrompt: (moment: Moment) => Prompt.Prompt;
1
+ import { a as PressOptions$1, o as ScrollOptions$1, r as ClickOptions$1, s as TypeOptions$1, t as Action } from "./Action-24sLOubi.mjs";
2
+ import { p as PolicyDenied, t as BrowserError } from "./BrowserError-BlcmLVzn.mjs";
3
+ import { b as Subject, f as PageLoaded, n as Box, r as BrowserEvent } from "./BrowserEvent-lLqJ3GJS.mjs";
4
+ import { r as Changes } from "./Change-Ba7INmay.mjs";
5
+ import { a as Image, n as CaptureStats, o as ScreencastOptions, r as Frame } from "./Frame-UEH2hO5T.mjs";
6
+ import { i as Point$1, t as Geometry_d_exports } from "./Geometry-DJx9qrYy.mjs";
7
+ import { n as Snapshot, r as SnapshotOptions } from "./Snapshot-CtBVOtuu.mjs";
8
+ import { t as Window } from "./Window-CMddGMt1.mjs";
9
+ import { Clock, Duration, Effect, Schema, Scope, Stream } from "effect";
105
10
  declare namespace Page_d_exports {
106
- export { ChangesOptions, ClickOptions, ElementState, Fact, FindQuery, Found, FrameOptions, InputGuard, InputRequest, Page$1 as Page, Point, PressOptions, ReadyOptions, Region, ResolvedTarget, ScreenshotOptions, ScrollOptions, State, Target, Text, TextOptions, TypeOptions, WaitCondition, WindowOptions, Zoom, correlate, failFast, redacted };
11
+ export { ActOptions, Capture, ChangesOptions, ClickOptions, ElementState, Fact, FindQuery, Found, FrameOptions, InputGuard, InputRequest, Page, Point, PressOptions, ReadyOptions, Region, ResolvedTarget, ScreenshotOptions, ScriptOptions, ScrollOptions, State, Target, Text, TextOptions, TypeOptions, UntilResult, UntilWant, WindowOptions, Zoom, correlate, failFast, redacted };
107
12
  }
108
13
  type Point = Point$1;
109
14
  /** A ref from a snapshot, such as `"e12"`, or a viewport point. */
@@ -150,43 +55,11 @@ declare const ResolvedTarget_base: Schema.Class<ResolvedTarget, Schema.Struct<{
150
55
  }>, {}>;
151
56
  /** The target as it read before input. Point coordinates are never snapped to another position. */
152
57
  declare class ResolvedTarget extends ResolvedTarget_base {}
153
- interface ClickOptions {
154
- readonly button?: "left" | "right" | "middle" | undefined;
155
- /** 2 for a double click. */
156
- readonly clickCount?: number | undefined;
157
- /** Hold the button down this long before releasing it. */
158
- readonly holdMillis?: number | undefined;
159
- }
160
- interface TypeOptions {
161
- /** Type into this text field: it is focused first, and its content replaced unless `replace` is false. */
162
- readonly into?: string | undefined;
163
- readonly replace?: boolean | undefined;
164
- /** Press Enter afterwards. */
165
- readonly submit?: boolean | undefined;
166
- /**
167
- * The text is a secret: type it only into a field the page marks secret, such as a password,
168
- * and otherwise refuse with `NotActionable` before any input. A replayed password asks this.
169
- */
170
- readonly secret?: boolean | undefined;
171
- }
172
- interface PressOptions {
173
- /**
174
- * Focus this element, by ref, before the first press: a link, a button or a field. The keys go to
175
- * whatever has focus otherwise.
176
- */
177
- readonly on?: string | undefined;
178
- /** Press the keys this many times. */
179
- readonly times?: number | undefined;
180
- /** Hold the keys down this long before releasing them, as a game control might need. */
181
- readonly holdMillis?: number | undefined;
182
- }
183
- interface ScrollOptions {
184
- readonly dx?: number | undefined;
185
- /** Pixels to scroll down; negative scrolls up. Defaults to most of a viewport. */
186
- readonly dy?: number | undefined;
187
- /** Scroll whatever is under this point or element. Defaults to the middle of the viewport. */
188
- readonly at?: Target | undefined;
189
- }
58
+ /** Action options share the execution codec. */
59
+ type ClickOptions = typeof ClickOptions$1.Type;
60
+ type TypeOptions = typeof TypeOptions$1.Type;
61
+ type PressOptions = typeof PressOptions$1.Type;
62
+ type ScrollOptions = typeof ScrollOptions$1.Type;
190
63
  /**
191
64
  * How current a picture must be. The newest screencast frame serves when it qualifies, at no cost;
192
65
  * otherwise a new screenshot is taken.
@@ -214,12 +87,21 @@ interface ScreenshotOptions {
214
87
  readonly quality?: number | undefined;
215
88
  /** `"jpeg"`, the default, or `"png"`, which is always a new picture. */
216
89
  readonly format?: "jpeg" | "png" | undefined;
90
+ /**
91
+ * `"css"`, the default, a picture pixel per CSS pixel; `"device"`, the screen's own pixels, as
92
+ * many to a CSS pixel as its device scale factor, which is always a new picture.
93
+ */
94
+ readonly scale?: "css" | "device" | undefined;
217
95
  }
218
96
  /**
219
97
  * What `find` looks for. Every rule given must hold; with none, it finds every element in scope
220
98
  * that has a role or is a control.
221
99
  */
222
100
  interface FindQuery {
101
+ /** Narrow matching to this CSS selector. Invalid CSS fails InvalidRequest. */
102
+ readonly selector?: string | undefined;
103
+ /** Require a visible match, optionally enabled. */
104
+ readonly state?: "visible" | "enabled" | undefined;
223
105
  /** An ARIA role, such as `"button"` or `"heading"`, ignoring case. */
224
106
  readonly role?: string | undefined;
225
107
  /**
@@ -296,25 +178,8 @@ declare const Text_base: Schema.Class<Text, Schema.Struct<{
296
178
  }>, {}>;
297
179
  /** What a page showed as text: a line per block, with table cells apart by tabs. */
298
180
  declare class Text extends Text_base {}
299
- /** What `waitFor` waits for. */
300
- interface WaitCondition {
301
- /** A CSS selector for what to watch; the document's body without one. */
302
- readonly selector?: string | undefined;
303
- /**
304
- * `"visible"` (the default): something it matches shows; `"hidden"`: nothing it matches shows;
305
- * `"enabled"`: something it matches shows and is not disabled.
306
- */
307
- readonly state?: "visible" | "hidden" | "enabled" | undefined;
308
- /** Only what shows this text counts, case and all, with runs of spaces read as one. */
309
- readonly text?: string | undefined;
310
- }
311
181
  interface ReadyOptions {
312
- /**
313
- * What must stay still during quietMillis: screen paint (default); recorded content; or the
314
- * `"foreground"`, the screen but for what was already moving before the page's latest input.
315
- */
316
- readonly still?: "screen" | "content" | "foreground" | undefined;
317
- /** How long the selected evidence must stay still; screen paint by default. */
182
+ /** How long recorded content must stay unchanged. Screen stillness is a separate feature. */
318
183
  readonly quietMillis?: number | undefined;
319
184
  readonly timeout?: Duration.Input | undefined;
320
185
  }
@@ -353,6 +218,8 @@ interface WindowOptions {
353
218
  }
354
219
  declare const State_base: Schema.Class<State, Schema.Struct<{
355
220
  readonly page: Schema.String;
221
+ /** The tracking connection that owns this document counter. */
222
+ readonly connection: Schema.String;
356
223
  /** When this was taken. */
357
224
  readonly at: Schema.Finite;
358
225
  /** Where the main frame last committed or moved, without userinfo or known secret parameters. */
@@ -402,7 +269,74 @@ declare const InputRequest_base: Schema.Class<InputRequest, Schema.Struct<{
402
269
  readonly url: Schema.String;
403
270
  /** The page's title, at most 120 characters. */
404
271
  readonly title: Schema.String;
405
- readonly action: Schema.String;
272
+ readonly action: Schema.TaggedUnion<{
273
+ readonly Act: Schema.TaggedStruct<"Act", {
274
+ readonly document: Schema.Int;
275
+ }>;
276
+ readonly Back: Schema.TaggedStruct<"Back", {}>;
277
+ readonly Click: Schema.TaggedStruct<"Click", {
278
+ readonly target: Schema.Union<readonly [Schema.String, Schema.Struct<{
279
+ readonly x: Schema.Finite;
280
+ readonly y: Schema.Finite;
281
+ }>]>;
282
+ readonly options: Schema.optional<Schema.Struct<{
283
+ readonly button: Schema.optional<Schema.Literals<readonly ["left", "right", "middle"]>>;
284
+ readonly clickCount: Schema.optional<Schema.Finite>;
285
+ readonly holdMillis: Schema.optional<Schema.Finite>;
286
+ }>>;
287
+ }>;
288
+ readonly Drag: Schema.TaggedStruct<"Drag", {
289
+ readonly from: Schema.Union<readonly [Schema.String, Schema.Struct<{
290
+ readonly x: Schema.Finite;
291
+ readonly y: Schema.Finite;
292
+ }>]>;
293
+ readonly to: Schema.Union<readonly [Schema.String, Schema.Struct<{
294
+ readonly x: Schema.Finite;
295
+ readonly y: Schema.Finite;
296
+ }>]>;
297
+ }>;
298
+ readonly Goto: Schema.TaggedStruct<"Goto", {
299
+ readonly url: Schema.String;
300
+ }>;
301
+ readonly Hover: Schema.TaggedStruct<"Hover", {
302
+ readonly target: Schema.Union<readonly [Schema.String, Schema.Struct<{
303
+ readonly x: Schema.Finite;
304
+ readonly y: Schema.Finite;
305
+ }>]>;
306
+ }>;
307
+ readonly Press: Schema.TaggedStruct<"Press", {
308
+ readonly keys: Schema.String;
309
+ readonly options: Schema.optional<Schema.Struct<{
310
+ readonly on: Schema.optional<Schema.String>;
311
+ readonly times: Schema.optional<Schema.Finite>;
312
+ readonly holdMillis: Schema.optional<Schema.Finite>;
313
+ }>>;
314
+ }>;
315
+ readonly Reload: Schema.TaggedStruct<"Reload", {}>;
316
+ readonly Scroll: Schema.TaggedStruct<"Scroll", {
317
+ readonly options: Schema.optional<Schema.Struct<{
318
+ readonly at: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Struct<{
319
+ readonly x: Schema.Finite;
320
+ readonly y: Schema.Finite;
321
+ }>]>>;
322
+ readonly dx: Schema.optional<Schema.Finite>;
323
+ readonly dy: Schema.optional<Schema.Finite>;
324
+ }>>;
325
+ }>;
326
+ readonly Select: Schema.TaggedStruct<"Select", {
327
+ readonly ref: Schema.String;
328
+ readonly values: Schema.$Array<Schema.String>;
329
+ }>;
330
+ readonly Type: Schema.TaggedStruct<"Type", {
331
+ readonly text: Schema.String;
332
+ readonly options: Schema.optional<Schema.Struct<{
333
+ readonly into: Schema.optional<Schema.String>;
334
+ readonly replace: Schema.optional<Schema.Boolean>;
335
+ readonly submit: Schema.optional<Schema.Boolean>;
336
+ readonly secret: Schema.optional<Schema.Boolean>;
337
+ }>>;
338
+ }>;
339
+ }>;
406
340
  readonly target: Schema.optional<Schema.String>;
407
341
  readonly element: Schema.optional<Schema.String>;
408
342
  /** Literal pixel targets only; ref coordinates are resolved after the policy allows them. */
@@ -468,11 +402,60 @@ declare const failFast: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effe
468
402
  declare const correlate: (id: string) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
469
403
  /** Succeed to allow, fail to deny, or await an external signal to hold the input. */
470
404
  type InputGuard = (request: InputRequest) => Effect.Effect<void, PolicyDenied>;
471
- interface Page$1 {
405
+ /** What a wait requires of the query's matches. */
406
+ type UntilWant = "some" | "none" | {
407
+ readonly other: string;
408
+ };
409
+ interface UntilResult {
410
+ readonly met: boolean;
411
+ readonly mark: string;
412
+ }
413
+ /** Scoped access to one page's shared capture and its current-document evidence. */
414
+ interface Capture {
415
+ readonly stream: Stream.Stream<Frame, BrowserError>;
416
+ readonly current: Frame | undefined;
417
+ readonly isCurrent: (frame: Frame) => boolean;
418
+ readonly confirm: (frame: Frame) => Effect.Effect<boolean, BrowserError>;
419
+ readonly sync: Effect.Effect<void, BrowserError>;
420
+ readonly stats: (options?: {
421
+ readonly window?: Duration.Input | undefined;
422
+ }) => Effect.Effect<CaptureStats, BrowserError>;
423
+ }
424
+ /** Script values cross the page boundary through the caller's Schema. A bundler may rewrite functions. */
425
+ interface ScriptOptions<A, Arg> {
426
+ readonly arg: Arg;
427
+ readonly result: Schema.Codec<A, unknown>;
428
+ }
429
+ interface ActOptions<A, Arg> extends ScriptOptions<A, Arg> {
430
+ readonly document: number;
431
+ /** Supplying the read's connection also refuses a document counter from another connection. */
432
+ readonly connection?: string | undefined;
433
+ }
434
+ interface Page {
435
+ /** Decode and perform a data action through the same policy and lane as the named methods. */
436
+ readonly perform: (action: Action) => Effect.Effect<ResolvedTarget | string | void, BrowserError>;
437
+ /** Read declared side-effect-free code in the main world, retrying one replaced document. */
438
+ readonly read: <A, Arg>(script: (arg: Arg) => unknown, options: ScriptOptions<A, Arg>) => Effect.Effect<{
439
+ readonly value: A;
440
+ readonly document: number;
441
+ readonly connection: string;
442
+ }, BrowserError>;
443
+ /**
444
+ * Run code as a guarded, recorded action bound to the caller's document.
445
+ * A timeout or cancellation cannot stop JavaScript already running: later input waits for its
446
+ * actual reply. Close the page and open a replacement if the script never settles.
447
+ */
448
+ readonly act: <A, Arg>(script: (arg: Arg) => unknown, options: ActOptions<A, Arg>) => Effect.Effect<A, BrowserError>;
449
+ /** Owning browser clock: deadlines and all frame/event timestamps use this clock. */
450
+ readonly clock: Clock.Clock;
451
+ /** Wait for admitted input and retain a bounded read turn through effect. */
452
+ readonly afterInput: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | BrowserError, R>;
453
+ /** A scoped lease starts capture immediately, independently of its first frame. */
454
+ readonly capture: (options?: ScreencastOptions) => Effect.Effect<Capture, BrowserError, Scope.Scope>;
455
+ /** One page-side wait; replaced documents share one deadline. Unmet is met:false; an empty mark means no stable document could be sampled. */
456
+ readonly until: (query: FindQuery, want: UntilWant, millis: number) => Effect.Effect<UntilResult, BrowserError>;
472
457
  /** The page's CDP target id: the same page has it again after a reconnect to its browser. */
473
458
  readonly id: string;
474
- /** The Playwright page, for anything this API does not cover. Never give it to a model. */
475
- readonly playwright: Page;
476
459
  /** The page's address, without its userinfo or known secret parameters. */
477
460
  readonly url: Effect.Effect<string>;
478
461
  /**
@@ -499,8 +482,11 @@ interface Page$1 {
499
482
  * screenshot timed by the host interval in which it was taken.
500
483
  */
501
484
  readonly frame: (options?: FrameOptions) => Effect.Effect<Frame, BrowserError>;
502
- /** A crop in CSS pixels, unmagnified, with the origin that keeps later input in viewport pixels. */
503
- readonly zoom: (region: Region) => Effect.Effect<Zoom, BrowserError>;
485
+ /**
486
+ * A crop in CSS pixels, unmagnified, with the origin that keeps later input in viewport pixels.
487
+ * With `scale: "device"` its picture has the screen's own pixels, as a screenshot's would.
488
+ */
489
+ readonly zoom: (region: Region, options?: Pick<ScreenshotOptions, "scale">) => Effect.Effect<Zoom, BrowserError>;
504
490
  /**
505
491
  * The viewport's size in CSS pixels, the space of points, crops and page scrolls. Over CDP the
506
492
  * page reports it, within the action timeout.
@@ -552,23 +538,10 @@ interface Page$1 {
552
538
  */
553
539
  readonly select: (ref: string, values: ReadonlyArray<string>) => Effect.Effect<string, BrowserError>;
554
540
  /**
555
- * Wait until a condition holds, in one call that the page answers as it comes, looking every
556
- * 100 ms, or `Timeout` after `timeout`, 10 seconds by default. A selector that is not CSS is an
557
- * `InvalidRequest`.
558
- */
559
- readonly waitFor: (condition: WaitCondition, timeout?: Duration.Input) => Effect.Effect<void, BrowserError>;
560
- /**
561
- * Wait until the page is ready to be shown, asking the page every 100 ms: its document is parsed
562
- * and has painted since, nothing that ends is animating in view, its fonts and the images in
563
- * view have loaded, and the viewport shows something. With `quietMillis`, the screen must then
564
- * also stay still that long: nothing in view changed, where the page's changes are recorded, and
565
- * no frame comes, counted from the first frame of a capture the wait starts itself. A canvas
566
- * that keeps drawing, such as a live chart, is never still. With `still: "foreground"`, frames
567
- * may keep coming, but nothing may move in them outside what moved in the frames of the 1.5 s
568
- * before the page's latest input, such as an idle animation; reels set spinning, or a counter
569
- * set rolling, by the input keep the wait going. Without those frames, as where they are older
570
- * than the browser's `frameHistory`, nothing may move at all. A page is never ready without a
571
- * painted frame, as a hidden tab may be. `Timeout` after `timeout`, 15 seconds by default.
541
+ * Wait for document evidence, polling every 50 ms: parsed, painted, visible, fonts and visible
542
+ * images loaded, and finite animations finished. Optional quietMillis requires recorded content
543
+ * to stay unchanged. Screen or foreground stillness belongs to the Stillness feature.
544
+ * Fails Timeout after timeout, 15 seconds by default.
572
545
  */
573
546
  readonly ready: (options?: ReadyOptions) => Effect.Effect<void, BrowserError>;
574
547
  /**
@@ -589,5 +562,5 @@ interface Page$1 {
589
562
  readonly recentEvents: Effect.Effect<ReadonlyArray<BrowserEvent>>;
590
563
  }
591
564
  //#endregion
592
- export { Account as A, TypeOptions as C, correlate as D, Zoom as E, account as F, capture as I, toPrompt as L, Moment as M, Moment_d_exports as N, failFast as O, Window as P, TextOptions as S, WindowOptions as T, ScreenshotOptions as _, FindQuery as a, Target as b, InputGuard as c, Page_d_exports as d, Point as f, ResolvedTarget as g, Region as h, Fact as i, CaptureOptions as j, redacted as k, InputRequest as l, ReadyOptions as m, ClickOptions as n, Found as o, PressOptions as p, ElementState as r, FrameOptions as s, ChangesOptions as t, Page$1 as u, ScrollOptions as v, WaitCondition as w, Text as x, State as y };
593
- //# sourceMappingURL=Page-ku6j5t-v.d.mts.map
565
+ export { Zoom as A, Target as C, UntilResult as D, TypeOptions as E, failFast as M, redacted as N, UntilWant as O, State as S, TextOptions as T, Region as _, ElementState as a, ScriptOptions as b, Found as c, InputRequest as d, Page as f, ReadyOptions as g, PressOptions as h, ClickOptions as i, correlate as j, WindowOptions as k, FrameOptions as l, Point as m, Capture as n, Fact as o, Page_d_exports as p, ChangesOptions as r, FindQuery as s, ActOptions as t, InputGuard as u, ResolvedTarget as v, Text as w, ScrollOptions as x, ScreenshotOptions as y };
566
+ //# sourceMappingURL=Page-CvsOEorc.d.mts.map
package/dist/Page.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { C as TypeOptions, D as correlate, E as Zoom, O as failFast, S as TextOptions, T as WindowOptions, _ as ScreenshotOptions, a as FindQuery, b as Target, c as InputGuard, f as Point, g as ResolvedTarget, h as Region, i as Fact, k as redacted, l as InputRequest, m as ReadyOptions, n as ClickOptions, o as Found, p as PressOptions, r as ElementState, s as FrameOptions, t as ChangesOptions, u as Page, v as ScrollOptions, w as WaitCondition, x as Text, y as State } from "./Page-ku6j5t-v.mjs";
2
- export { ChangesOptions, ClickOptions, ElementState, Fact, FindQuery, Found, FrameOptions, InputGuard, InputRequest, Page, Point, PressOptions, ReadyOptions, Region, ResolvedTarget, ScreenshotOptions, ScrollOptions, State, Target, Text, TextOptions, TypeOptions, WaitCondition, WindowOptions, Zoom, correlate, failFast, redacted };
1
+ import { A as Zoom, C as Target, D as UntilResult, E as TypeOptions, M as failFast, N as redacted, O as UntilWant, S as State, T as TextOptions, _ as Region, a as ElementState, b as ScriptOptions, c as Found, d as InputRequest, f as Page, g as ReadyOptions, h as PressOptions, i as ClickOptions, j as correlate, k as WindowOptions, l as FrameOptions, m as Point, n as Capture, o as Fact, r as ChangesOptions, s as FindQuery, t as ActOptions, u as InputGuard, v as ResolvedTarget, w as Text, x as ScrollOptions, y as ScreenshotOptions } from "./Page-CvsOEorc.mjs";
2
+ export { ActOptions, Capture, ChangesOptions, ClickOptions, ElementState, Fact, FindQuery, Found, FrameOptions, InputGuard, InputRequest, Page, Point, PressOptions, ReadyOptions, Region, ResolvedTarget, ScreenshotOptions, ScriptOptions, ScrollOptions, State, Target, Text, TextOptions, TypeOptions, UntilResult, UntilWant, WindowOptions, Zoom, correlate, failFast, redacted };
package/dist/Page.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { c as State, d as correlate, f as failFast, i as InputRequest, l as Text, n as Fact, o as Region, p as redacted, r as Found, s as ResolvedTarget, t as ElementState, u as Zoom } from "./Page-CfB6Zn1p.mjs";
1
+ import { c as State, d as correlate, f as failFast, i as InputRequest, l as Text, n as Fact, o as Region, p as redacted, r as Found, s as ResolvedTarget, t as ElementState, u as Zoom } from "./Page-BF5izr8R.mjs";
2
2
  export { ElementState, Fact, Found, InputRequest, Region, ResolvedTarget, State, Text, Zoom, correlate, failFast, redacted };
@@ -0,0 +1,15 @@
1
+ import { Schema } from "effect";
2
+ //#region src/providers/Released.d.ts
3
+ declare const Settled_base: Schema.Class<Settled, Schema.TaggedStruct<"Settled", {}>, {}>;
4
+ /** The provider confirmed the resource ended. */
5
+ declare class Settled extends Settled_base {}
6
+ declare const Unconfirmed_base: Schema.Class<Unconfirmed, Schema.TaggedStruct<"Unconfirmed", {
7
+ readonly detail: Schema.String;
8
+ }>, {}>;
9
+ /** The resource may still run, and bill, because its end could not be confirmed. */
10
+ declare class Unconfirmed extends Unconfirmed_base {}
11
+ declare const Released: Schema.Union<readonly [typeof Settled, typeof Unconfirmed]>;
12
+ type Released = typeof Released.Type;
13
+ //#endregion
14
+ export { Settled as n, Unconfirmed as r, Released as t };
15
+ //# sourceMappingURL=Released-tURbFmal.d.mts.map
@@ -62,7 +62,12 @@ interface SnapshotOptions {
62
62
  readonly within?: string | undefined;
63
63
  /** Bound on the outline's length. Defaults to 12,000 characters. */
64
64
  readonly maxChars?: number | undefined;
65
+ /**
66
+ * Give every control's box, as `WxH at (x,y)` in viewport CSS pixels, as a canvas's or a frame's
67
+ * always has. Defaults to false.
68
+ */
69
+ readonly boxes?: boolean | undefined;
65
70
  }
66
71
  //#endregion
67
72
  export { Snapshot_d_exports as i, Snapshot as n, SnapshotOptions as r, Control as t };
68
- //# sourceMappingURL=Snapshot-B34hZ4Jl.d.mts.map
73
+ //# sourceMappingURL=Snapshot-CtBVOtuu.d.mts.map
@@ -1,2 +1,2 @@
1
- import { n as Snapshot, r as SnapshotOptions, t as Control } from "./Snapshot-B34hZ4Jl.mjs";
1
+ import { n as Snapshot, r as SnapshotOptions, t as Control } from "./Snapshot-CtBVOtuu.mjs";
2
2
  export { Control, Snapshot, SnapshotOptions };
@@ -1 +1 @@
1
- {"version":3,"file":"Snapshot.mjs","names":[],"sources":["../src/Snapshot.ts"],"sourcesContent":["/**\n * A compact, model-readable outline of what a page shows.\n *\n * Each control gets a ref such as `e12`. A ref stays valid while its element is on the page, and\n * refs are never reused within a page, so a ref from an old snapshot fails as stale rather than\n * naming a different element.\n *\n * @since 0.3.0\n */\nimport { Schema } from \"effect\";\n\n/** A control the outline shows, as a value: its ref, what it is and what it holds. */\nexport class Control extends Schema.Class<Control>(\"effect-browser/Control\")({\n ref: Schema.String,\n /** Its role, such as `button` or `textbox`, or `clickable` for an element without one. */\n kind: Schema.String,\n /** Its accessible name. */\n name: Schema.String,\n /** What it holds: a field's text, `••••` for a secret one, or a select's chosen labels. */\n value: Schema.String,\n /** A select's option labels, at most 64. */\n options: Schema.optional(Schema.Array(Schema.String)),\n /** How many options a select has, when it has options. */\n optionCount: Schema.optional(Schema.Int),\n disabled: Schema.optional(Schema.Boolean),\n /** Whether it is checked, for what can be checked. */\n checked: Schema.optional(Schema.Boolean),\n /** True for a field that takes typed text. */\n editable: Schema.optional(Schema.Boolean),\n}) {}\n\nexport class Snapshot extends Schema.Class<Snapshot>(\"effect-browser/Snapshot\")({\n url: Schema.String,\n title: Schema.String,\n /** One line per control, heading or text block, indented by landmark. */\n text: Schema.String,\n /** True when `text` was cut at `maxChars`. */\n truncated: Schema.Boolean,\n /**\n * Parts of the page left out because they lie above or below the viewport, each an element out\n * of view with all it holds (viewport snapshots only).\n */\n above: Schema.Finite,\n below: Schema.Finite,\n viewport: Schema.Struct({ width: Schema.Finite, height: Schema.Finite }),\n scroll: Schema.Struct({ y: Schema.Finite, height: Schema.Finite }),\n /** The controls the outline shows, in its order. */\n controls: Schema.Array(Control),\n}) {\n /** The snapshot as one block of text for a model: header, outline and what was left out. */\n get rendered(): string {\n const position =\n this.scroll.height > this.viewport.height\n ? `, scrolled to ${this.scroll.y} of ${this.scroll.height - this.viewport.height}px`\n : \"\";\n\n const omitted: Array<string> = [];\n\n if (this.above > 0) omitted.push(`${this.above} parts above`);\n if (this.below > 0) omitted.push(`${this.below} parts below`);\n\n const footer = [\n ...(omitted.length > 0 ? [`(${omitted.join(\", \")} the viewport)`] : []),\n ...(this.truncated ? [\"(cut short: narrow it with query)\"] : []),\n ];\n\n return [\n `Page: ${this.title === \"\" ? \"(untitled)\" : this.title}`,\n `URL: ${this.url}`,\n `Viewport: ${this.viewport.width}x${this.viewport.height}${position}`,\n this.text === \"\" ? \"(nothing readable in view)\" : this.text,\n ...footer,\n ].join(\"\\n\");\n }\n}\n\nexport interface SnapshotOptions {\n /** Read the whole page instead of the viewport. Defaults to false. */\n readonly full?: boolean | undefined;\n /** Keep only lines containing this text (case-insensitive). */\n readonly query?: string | undefined;\n /**\n * Read only inside the elements this CSS selector matches, such as `form` or `#results`. A\n * selector that matches nothing reads nothing; one that is not CSS is an `InvalidRequest`.\n */\n readonly within?: string | undefined;\n /** Bound on the outline's length. Defaults to 12,000 characters. */\n readonly maxChars?: number | undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,IAAa,UAAb,cAA6B,OAAO,MAAe,wBAAwB,CAAC,CAAC;CAC3E,KAAK,OAAO;;CAEZ,MAAM,OAAO;;CAEb,MAAM,OAAO;;CAEb,OAAO,OAAO;;CAEd,SAAS,OAAO,SAAS,OAAO,MAAM,OAAO,MAAM,CAAC;;CAEpD,aAAa,OAAO,SAAS,OAAO,GAAG;CACvC,UAAU,OAAO,SAAS,OAAO,OAAO;;CAExC,SAAS,OAAO,SAAS,OAAO,OAAO;;CAEvC,UAAU,OAAO,SAAS,OAAO,OAAO;AAC1C,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,WAAb,cAA8B,OAAO,MAAgB,yBAAyB,CAAC,CAAC;CAC9E,KAAK,OAAO;CACZ,OAAO,OAAO;;CAEd,MAAM,OAAO;;CAEb,WAAW,OAAO;;;;;CAKlB,OAAO,OAAO;CACd,OAAO,OAAO;CACd,UAAU,OAAO,OAAO;EAAE,OAAO,OAAO;EAAQ,QAAQ,OAAO;CAAO,CAAC;CACvE,QAAQ,OAAO,OAAO;EAAE,GAAG,OAAO;EAAQ,QAAQ,OAAO;CAAO,CAAC;;CAEjE,UAAU,OAAO,MAAM,OAAO;AAChC,CAAC,CAAC,CAAC;;CAED,IAAI,WAAmB;EACrB,MAAM,WACJ,KAAK,OAAO,SAAS,KAAK,SAAS,SAC/B,iBAAiB,KAAK,OAAO,EAAE,MAAM,KAAK,OAAO,SAAS,KAAK,SAAS,OAAO,MAC/E;EAEN,MAAM,UAAyB,CAAC;EAEhC,IAAI,KAAK,QAAQ,GAAG,QAAQ,KAAK,GAAG,KAAK,MAAM,aAAa;EAC5D,IAAI,KAAK,QAAQ,GAAG,QAAQ,KAAK,GAAG,KAAK,MAAM,aAAa;EAE5D,MAAM,SAAS,CACb,GAAI,QAAQ,SAAS,IAAI,CAAC,IAAI,QAAQ,KAAK,IAAI,EAAE,eAAe,IAAI,CAAC,GACrE,GAAI,KAAK,YAAY,CAAC,mCAAmC,IAAI,CAAC,CAChE;EAEA,OAAO;GACL,SAAS,KAAK,UAAU,KAAK,eAAe,KAAK;GACjD,QAAQ,KAAK;GACb,aAAa,KAAK,SAAS,MAAM,GAAG,KAAK,SAAS,SAAS;GAC3D,KAAK,SAAS,KAAK,+BAA+B,KAAK;GACvD,GAAG;EACL,CAAC,CAAC,KAAK,IAAI;CACb;AACF"}
1
+ {"version":3,"file":"Snapshot.mjs","names":[],"sources":["../src/Snapshot.ts"],"sourcesContent":["/**\n * A compact, model-readable outline of what a page shows.\n *\n * Each control gets a ref such as `e12`. A ref stays valid while its element is on the page, and\n * refs are never reused within a page, so a ref from an old snapshot fails as stale rather than\n * naming a different element.\n *\n * @since 0.3.0\n */\nimport { Schema } from \"effect\";\n\n/** A control the outline shows, as a value: its ref, what it is and what it holds. */\nexport class Control extends Schema.Class<Control>(\"effect-browser/Control\")({\n ref: Schema.String,\n /** Its role, such as `button` or `textbox`, or `clickable` for an element without one. */\n kind: Schema.String,\n /** Its accessible name. */\n name: Schema.String,\n /** What it holds: a field's text, `••••` for a secret one, or a select's chosen labels. */\n value: Schema.String,\n /** A select's option labels, at most 64. */\n options: Schema.optional(Schema.Array(Schema.String)),\n /** How many options a select has, when it has options. */\n optionCount: Schema.optional(Schema.Int),\n disabled: Schema.optional(Schema.Boolean),\n /** Whether it is checked, for what can be checked. */\n checked: Schema.optional(Schema.Boolean),\n /** True for a field that takes typed text. */\n editable: Schema.optional(Schema.Boolean),\n}) {}\n\nexport class Snapshot extends Schema.Class<Snapshot>(\"effect-browser/Snapshot\")({\n url: Schema.String,\n title: Schema.String,\n /** One line per control, heading or text block, indented by landmark. */\n text: Schema.String,\n /** True when `text` was cut at `maxChars`. */\n truncated: Schema.Boolean,\n /**\n * Parts of the page left out because they lie above or below the viewport, each an element out\n * of view with all it holds (viewport snapshots only).\n */\n above: Schema.Finite,\n below: Schema.Finite,\n viewport: Schema.Struct({ width: Schema.Finite, height: Schema.Finite }),\n scroll: Schema.Struct({ y: Schema.Finite, height: Schema.Finite }),\n /** The controls the outline shows, in its order. */\n controls: Schema.Array(Control),\n}) {\n /** The snapshot as one block of text for a model: header, outline and what was left out. */\n get rendered(): string {\n const position =\n this.scroll.height > this.viewport.height\n ? `, scrolled to ${this.scroll.y} of ${this.scroll.height - this.viewport.height}px`\n : \"\";\n\n const omitted: Array<string> = [];\n\n if (this.above > 0) omitted.push(`${this.above} parts above`);\n if (this.below > 0) omitted.push(`${this.below} parts below`);\n\n const footer = [\n ...(omitted.length > 0 ? [`(${omitted.join(\", \")} the viewport)`] : []),\n ...(this.truncated ? [\"(cut short: narrow it with query)\"] : []),\n ];\n\n return [\n `Page: ${this.title === \"\" ? \"(untitled)\" : this.title}`,\n `URL: ${this.url}`,\n `Viewport: ${this.viewport.width}x${this.viewport.height}${position}`,\n this.text === \"\" ? \"(nothing readable in view)\" : this.text,\n ...footer,\n ].join(\"\\n\");\n }\n}\n\nexport interface SnapshotOptions {\n /** Read the whole page instead of the viewport. Defaults to false. */\n readonly full?: boolean | undefined;\n /** Keep only lines containing this text (case-insensitive). */\n readonly query?: string | undefined;\n /**\n * Read only inside the elements this CSS selector matches, such as `form` or `#results`. A\n * selector that matches nothing reads nothing; one that is not CSS is an `InvalidRequest`.\n */\n readonly within?: string | undefined;\n /** Bound on the outline's length. Defaults to 12,000 characters. */\n readonly maxChars?: number | undefined;\n /**\n * Give every control's box, as `WxH at (x,y)` in viewport CSS pixels, as a canvas's or a frame's\n * always has. Defaults to false.\n */\n readonly boxes?: boolean | undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,IAAa,UAAb,cAA6B,OAAO,MAAe,wBAAwB,CAAC,CAAC;CAC3E,KAAK,OAAO;;CAEZ,MAAM,OAAO;;CAEb,MAAM,OAAO;;CAEb,OAAO,OAAO;;CAEd,SAAS,OAAO,SAAS,OAAO,MAAM,OAAO,MAAM,CAAC;;CAEpD,aAAa,OAAO,SAAS,OAAO,GAAG;CACvC,UAAU,OAAO,SAAS,OAAO,OAAO;;CAExC,SAAS,OAAO,SAAS,OAAO,OAAO;;CAEvC,UAAU,OAAO,SAAS,OAAO,OAAO;AAC1C,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,WAAb,cAA8B,OAAO,MAAgB,yBAAyB,CAAC,CAAC;CAC9E,KAAK,OAAO;CACZ,OAAO,OAAO;;CAEd,MAAM,OAAO;;CAEb,WAAW,OAAO;;;;;CAKlB,OAAO,OAAO;CACd,OAAO,OAAO;CACd,UAAU,OAAO,OAAO;EAAE,OAAO,OAAO;EAAQ,QAAQ,OAAO;CAAO,CAAC;CACvE,QAAQ,OAAO,OAAO;EAAE,GAAG,OAAO;EAAQ,QAAQ,OAAO;CAAO,CAAC;;CAEjE,UAAU,OAAO,MAAM,OAAO;AAChC,CAAC,CAAC,CAAC;;CAED,IAAI,WAAmB;EACrB,MAAM,WACJ,KAAK,OAAO,SAAS,KAAK,SAAS,SAC/B,iBAAiB,KAAK,OAAO,EAAE,MAAM,KAAK,OAAO,SAAS,KAAK,SAAS,OAAO,MAC/E;EAEN,MAAM,UAAyB,CAAC;EAEhC,IAAI,KAAK,QAAQ,GAAG,QAAQ,KAAK,GAAG,KAAK,MAAM,aAAa;EAC5D,IAAI,KAAK,QAAQ,GAAG,QAAQ,KAAK,GAAG,KAAK,MAAM,aAAa;EAE5D,MAAM,SAAS,CACb,GAAI,QAAQ,SAAS,IAAI,CAAC,IAAI,QAAQ,KAAK,IAAI,EAAE,eAAe,IAAI,CAAC,GACrE,GAAI,KAAK,YAAY,CAAC,mCAAmC,IAAI,CAAC,CAChE;EAEA,OAAO;GACL,SAAS,KAAK,UAAU,KAAK,eAAe,KAAK;GACjD,QAAQ,KAAK;GACb,aAAa,KAAK,SAAS,MAAM,GAAG,KAAK,SAAS,SAAS;GAC3D,KAAK,SAAS,KAAK,+BAA+B,KAAK;GACvD,GAAG;EACL,CAAC,CAAC,KAAK,IAAI;CACb;AACF"}
@@ -0,0 +1,136 @@
1
+ import { Failed, Timeout, refuse, undispatched } from "./BrowserError.mjs";
2
+ import { monotonicMillis } from "./Clock.mjs";
3
+ import { Clock, Duration, Effect, Option, Schedule, Stream } from "effect";
4
+ import { jpegjs } from "playwright-core/lib/utilsBundle";
5
+ //#region src/stillness/Pixels.ts
6
+ /**
7
+ * Where a page's screen moves, from its screencast frames: each frame decoded and cut into
8
+ * 16-pixel blocks, a block moving where a few of its pixels, sampled every other one, changed by
9
+ * more than JPEG's noise in any color channel.
10
+ * What moved among the frames before an input is the page's background, such as an idle
11
+ * animation; foreground stillness ignores it.
12
+ *
13
+ * Frames use Playwright's bundled JPEG decoder. The package build ships that exact decoder
14
+ * alone, keeping its Node utility bundle out of Workers. Source runs use its native export,
15
+ * whose untyped entry point is declared by `utilsBundle.d.ts`.
16
+ */
17
+ const picture = (frame) => jpegjs.decode(frame.data, { useTArray: true });
18
+ /** A sample changed where any color channel moved more than this, beyond JPEG's noise. */
19
+ const noise = 32;
20
+ /** The blocks where two pictures differ, by `row * columns + column`; -1 for different sizes. */
21
+ const moved = (from, to) => {
22
+ if (from.width !== to.width || from.height !== to.height) return [-1];
23
+ const columns = Math.ceil(from.width / 16);
24
+ const counts = /* @__PURE__ */ new Map();
25
+ const differs = (at) => Math.abs((from.data[at] ?? 0) - (to.data[at] ?? 0)) > noise;
26
+ for (let y = 0; y < from.height; y += 2) for (let x = 0; x < from.width; x += 2) {
27
+ const at = (y * from.width + x) * 4;
28
+ const block = Math.floor(y / 16) * columns + Math.floor(x / 16);
29
+ if (differs(at) || differs(at + 1) || differs(at + 2)) counts.set(block, (counts.get(block) ?? 0) + 1);
30
+ }
31
+ return [...counts].flatMap(([block, count]) => count >= 3 ? [block] : []);
32
+ };
33
+ /** The blocks that moved from one picture to the next and their neighbours; none past a resize. */
34
+ const background = (pictures) => {
35
+ const columns = Math.ceil((pictures[0]?.width ?? 0) / 16);
36
+ const around = (block) => [
37
+ -1,
38
+ 0,
39
+ 1
40
+ ].flatMap((row) => [
41
+ -1,
42
+ 0,
43
+ 1
44
+ ].filter((step) => block >= 0 && block % columns + step >= 0).filter((step) => block % columns + step < columns).map((step) => block + row * columns + step));
45
+ return new Set(pictures.flatMap((to, index) => moved(pictures[index - 1] ?? to, to).flatMap(around)));
46
+ };
47
+ /** Whether anything moved from one picture to another outside the background. */
48
+ const stirs = (from, to, mask) => moved(from, to).some((block) => !mask.has(block));
49
+ //#endregion
50
+ //#region src/stillness/Stillness.ts
51
+ /** Screen and foreground stillness over the public page capture and owning clock. */
52
+ const observe = (page, options, timeout) => Effect.gen(function* () {
53
+ const now = () => monotonicMillis(page.clock);
54
+ const deadline = now() + Duration.toMillis(timeout);
55
+ const settled = () => page.ready({
56
+ quietMillis: options.quietMillis,
57
+ timeout: Duration.millis(Math.max(0, deadline - now()))
58
+ });
59
+ const quiet = (millis) => Effect.gen(function* () {
60
+ const capture = yield* page.capture();
61
+ const foreground = options.still === "foreground";
62
+ let counts = yield* capture.stats();
63
+ let stirred = now();
64
+ let reference;
65
+ const decoded = (frame) => Effect.try({
66
+ try: () => picture(frame),
67
+ catch: (error) => undispatched("ready", new Failed({ detail: `no picture: ${String(error)}` }))
68
+ });
69
+ const inputAt = (yield* page.recentEvents).findLast((event) => event._tag === "Action")?.startedAt ?? Number.NEGATIVE_INFINITY;
70
+ const document = (yield* page.state).document;
71
+ const before = (foreground ? yield* page.recentFrames : []).filter((frame) => frame.hostTime < inputAt && frame.hostTime >= inputAt - 1500 && frame.document === document);
72
+ const sampled = before.filter((_, index) => index % Math.ceil(before.length / 8) === 0);
73
+ const mask = background(yield* Effect.forEach(sampled, decoded));
74
+ const look = Effect.gen(function* () {
75
+ const stats = yield* capture.stats();
76
+ const latest = (yield* page.state).frame;
77
+ const arrived = stats.received !== counts.received;
78
+ const unseen = stats.accepted - counts.accepted;
79
+ counts = stats;
80
+ if (latest === void 0 || !capture.isCurrent(latest)) stirred = now();
81
+ else if (!foreground ? arrived || stats.ackBacklog > 0 : !arrived && stats.ackBacklog > 0) stirred = now();
82
+ else if (foreground && (unseen > 0 || reference === void 0)) {
83
+ const frames = (yield* page.recentFrames).slice(-Math.max(1, Math.min(8, unseen)));
84
+ if (unseen > frames.length) stirred = now();
85
+ for (const frame of frames) {
86
+ const seen = yield* decoded(frame);
87
+ if (reference === void 0 || stirs(reference, seen, mask)) {
88
+ reference = seen;
89
+ stirred = now();
90
+ }
91
+ }
92
+ }
93
+ return now() - stirred;
94
+ });
95
+ const spell = Effect.repeat(look, {
96
+ schedule: Schedule.fixed(Duration.millis(foreground ? 100 : 25)),
97
+ until: (still) => still >= millis
98
+ });
99
+ const still = Effect.gen(function* () {
100
+ for (;;) {
101
+ yield* spell;
102
+ const before = counts.received;
103
+ yield* Effect.all([settled(), capture.sync], {
104
+ concurrency: 2,
105
+ discard: true
106
+ });
107
+ if ((yield* look) >= millis && (foreground || counts.received === before)) return;
108
+ }
109
+ });
110
+ return yield* Effect.raceFirst(capture.stream.pipe(Stream.runDrain, Effect.andThen(Effect.never)), still);
111
+ });
112
+ yield* page.afterInput(Effect.void);
113
+ if (options.still === "content") {
114
+ yield* page.changes();
115
+ yield* Effect.sleep(Duration.millis(options.quietMillis));
116
+ return yield* settled();
117
+ }
118
+ yield* settled();
119
+ yield* quiet(options.quietMillis);
120
+ });
121
+ const wait = (page, options) => Effect.gen(function* () {
122
+ if (!Number.isFinite(options.quietMillis) || options.quietMillis < 0) return yield* refuse("stillness", "quietMillis must be finite and nonnegative");
123
+ const input = options.timeout ?? Duration.seconds(15);
124
+ const components = typeof input === "number" ? [input] : typeof input === "object" && !Duration.isDuration(input) ? Object.values(input) : [];
125
+ const timeout = Duration.fromInput(input);
126
+ if (components.some((value) => typeof value === "number" && !Number.isFinite(value)) || Option.isNone(timeout) || !Duration.isFinite(timeout.value) || Duration.isNegative(timeout.value)) return yield* refuse("stillness", "timeout must be a finite nonnegative duration");
127
+ const duration = timeout.value;
128
+ return yield* observe(page, options, duration).pipe(Effect.timeoutOrElse({
129
+ duration,
130
+ orElse: () => Effect.fail(undispatched("stillness", new Timeout({ millis: Duration.toMillis(duration) })))
131
+ }));
132
+ }).pipe(Effect.scoped, Effect.provideService(Clock.Clock, page.clock), Effect.withSpan("Stillness.wait"));
133
+ //#endregion
134
+ export { wait as t };
135
+
136
+ //# sourceMappingURL=Stillness-CNlvayIo.mjs.map