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
@@ -0,0 +1,167 @@
1
+ import { t as BrowserError } from "./BrowserError-BlcmLVzn.mjs";
2
+ import { _ as RecordedEvent, i as BrowserEvent_d_exports, r as BrowserEvent, s as DisconnectCause } from "./BrowserEvent-lLqJ3GJS.mjs";
3
+ import { f as Page, p as Page_d_exports, u as InputGuard } from "./Page-CvsOEorc.mjs";
4
+ import { Context, DateTime, Duration, Effect, Option, Schema, Scope, Stream } from "effect";
5
+ import { BrowserContext } from "playwright-core";
6
+ declare namespace Browser_d_exports {
7
+ export { Browser$1 as Browser, CaptureSource, EventOptions, InitScript, Options, RequestDecision, RequestPolicy, Service, SuspendOptions, Suspension, make };
8
+ }
9
+ /** A script that documents run before their own, such as a consent-banner remover. */
10
+ interface InitScript {
11
+ /**
12
+ * The documents that run it, by a pattern their address (`location.href`) matches; every
13
+ * document and frame when left out. Under a `match`, the source runs as a block, so its own
14
+ * top-level `let`, `const` and classes stay its own.
15
+ */
16
+ readonly match?: RegExp | undefined;
17
+ readonly source: string;
18
+ }
19
+ /** Consumer-owned decision for one request caught by a narrow URL pattern. */
20
+ type RequestDecision = {
21
+ readonly _tag: "Allowed";
22
+ } | {
23
+ readonly _tag: "Refused";
24
+ readonly reason: string;
25
+ } | {
26
+ readonly _tag: "Fulfilled";
27
+ readonly status: number;
28
+ readonly contentType: string;
29
+ readonly headers?: Readonly<Record<string, string>> | undefined;
30
+ readonly body: string;
31
+ };
32
+ interface RequestPolicy {
33
+ readonly patterns: ReadonlyArray<string>;
34
+ /**
35
+ * Receives sensitive data for this context only; keep it out of model inputs and logs.
36
+ * Body is exact UTF-8 text, or null when absent. Incomplete/binary body evidence refuses
37
+ * that request. Preexisting shared workers make installation fail InvalidRequest.
38
+ * Enforcement belongs to this connection's scope; it is not a firewall after CDP disconnects.
39
+ */
40
+ readonly decide: (request: {
41
+ readonly url: string;
42
+ readonly method: string;
43
+ readonly body: string | null;
44
+ }) => Effect.Effect<RequestDecision, BrowserError>;
45
+ readonly timeout?: Duration.Input | undefined;
46
+ }
47
+ interface Options {
48
+ /** Fixed viewport applied before each existing or newly opened page registers. */
49
+ readonly viewport?: {
50
+ readonly width: number;
51
+ readonly height: number;
52
+ } | undefined;
53
+ /** This context's policy, installed before pages register; redirects retain ownership. */
54
+ readonly requests?: RequestPolicy | undefined;
55
+ /**
56
+ * Bound on each action; finite and positive. Defaults to 10 seconds. What a presenter's view
57
+ * takes to show an action, such as its glides and typing at a person's pace, does not count
58
+ * against it.
59
+ */
60
+ readonly actionTimeout?: Duration.Input | undefined;
61
+ /** Bound on each navigation; finite and positive. Defaults to 30 seconds. */
62
+ readonly navigationTimeout?: Duration.Input | undefined;
63
+ /**
64
+ * How long each page keeps screencast frames for `recentFrames`, measured back from the newest;
65
+ * finite and positive. Defaults to 5 seconds, a moment's default window.
66
+ */
67
+ readonly frameHistory?: Duration.Input | undefined;
68
+ /** Events retained for replay and `recentEvents`. A positive safe integer, defaulting to 4,096. */
69
+ readonly eventHistory?: number | undefined;
70
+ /** Allow, deny or hold each input or navigation before it reaches the page. Defaults to allow. */
71
+ readonly guard?: InputGuard | undefined;
72
+ /** A separate bound for policy holds, outside action timeouts. Defaults to 5 minutes. */
73
+ readonly policyTimeout?: Duration.Input | undefined;
74
+ /** Scripts that new documents run before their own, each where its `match` allows. */
75
+ readonly initScripts?: ReadonlyArray<InitScript> | undefined;
76
+ /**
77
+ * The most pages the browser keeps open, those a site opens included, which are never refused. At
78
+ * it, `newPage` waits for one to close, within the action timeout, then fails `Limit`; under
79
+ * `Page.failFast` it fails at once. A positive safe integer; no limit when left out.
80
+ */
81
+ readonly maxPages?: number | undefined;
82
+ }
83
+ interface EventOptions {
84
+ /** Resume after this sequence; 0 replays from the beginning if it is still retained. */
85
+ readonly after?: number | undefined;
86
+ }
87
+ interface SuspendOptions {
88
+ /** Finite, nonnegative drain bound; defaults to the browser's navigationTimeout. */
89
+ readonly drain?: Duration.Input | undefined;
90
+ }
91
+ declare const Suspension_base: Schema.Class<Suspension, Schema.Struct<{
92
+ readonly since: Schema.Int;
93
+ readonly at: Schema.Finite;
94
+ }>, {}>;
95
+ /** When admitted input finished; events after `since` describe the handoff interval. */
96
+ declare class Suspension extends Suspension_base {}
97
+ /**
98
+ * A connection to the browser apart from the one that drives its pages, for their screencasts,
99
+ * as a provider that reaches the browser over a network supplies it: a frame and its
100
+ * acknowledgement then never wait behind a large message, such as an upload or a read's answer,
101
+ * on the connection that drives the page. It is read-only. A page's session on it sends the
102
+ * capture's commands alone, and the page's own session keeps its focus emulation, which keeps a
103
+ * tab behind painting.
104
+ */
105
+ interface CaptureSource {
106
+ /**
107
+ * A session on the page's target, for the scope. `event` gets the session's events in the order
108
+ * the browser sent them, its target's detach among them, until the scope closes; `lost` gets
109
+ * the connection's failure, once, if it fails first. Its calls never throw: a failure rejects.
110
+ */
111
+ readonly attach: (target: string, listener: {
112
+ readonly event: (method: string, params: unknown) => void;
113
+ readonly lost: (error: BrowserError) => void;
114
+ }) => Effect.Effect<(method: "Page.enable" | "Page.getFrameTree" | "Page.startScreencast" | "Page.screencastFrameAck" | "Page.stopScreencast", params?: Record<string, unknown>) => Promise<unknown>, BrowserError, Scope.Scope>;
115
+ }
116
+ interface Service {
117
+ /** The provider's session id, or a local id. */
118
+ readonly id: string;
119
+ /** Fresh for this connection, even when reattaching the same provider session and page. */
120
+ readonly connection: string;
121
+ readonly provider: string;
122
+ /** When the provider ends the session on its own, as a hosted session's timeout does. */
123
+ readonly expiresAt: DateTime.Utc | undefined;
124
+ /** Host monotonic milliseconds on the clock shared by this browser’s events and frames. */
125
+ readonly now: Effect.Effect<number>;
126
+ /** Drain admitted input and withhold new input for this scope; reads and capture continue. */
127
+ readonly suspend: (options?: SuspendOptions) => Effect.Effect<Suspension, BrowserError, Scope.Scope>;
128
+ /** Open pages in the order this browser began tracking them. */
129
+ readonly pages: Effect.Effect<ReadonlyArray<Page>>;
130
+ /** The open page with this id, its CDP target id, as stored before a reconnect. */
131
+ readonly page: (id: string) => Effect.Effect<Option.Option<Page>>;
132
+ /** The first open page, opening one when there is none. */
133
+ readonly firstPage: Effect.Effect<Page, BrowserError>;
134
+ readonly newPage: (url?: string) => Effect.Effect<Page, BrowserError>;
135
+ /** Whether an applicable cookie exists; its value never leaves the browser owner. */
136
+ readonly hasCookie: (query: {
137
+ readonly name: string;
138
+ readonly url: string;
139
+ }) => Effect.Effect<boolean, BrowserError>;
140
+ /**
141
+ * Completes once the browser is lost to its owner, with why: its connection dropped, its
142
+ * provider ended its session, or its owner's scope released it.
143
+ */
144
+ readonly disconnected: Effect.Effect<DisconnectCause>;
145
+ /** Live events, or replay after a cursor. A reader that falls behind fails with EventHistoryExpired. */
146
+ readonly events: (options?: EventOptions) => Stream.Stream<RecordedEvent, BrowserError>;
147
+ /** The latest `eventHistory` events, oldest first. */
148
+ readonly recentEvents: Effect.Effect<ReadonlyArray<BrowserEvent>>;
149
+ }
150
+ declare const Browser_base: Context.ServiceClass<Browser$1, "effect-browser/Browser", Service>;
151
+ declare class Browser$1 extends Browser_base {}
152
+ /**
153
+ * Build the service over a context the provider owns. The provider closes the context; this only
154
+ * tracks its pages and events, for as long as the surrounding scope is open. Each page's protocol
155
+ * session, capture and listeners end when that page closes or when the scope does, so a closed
156
+ * tab retains nothing and the context keeps none of them afterwards.
157
+ */
158
+ declare const make: (context: BrowserContext, info: {
159
+ readonly id?: string | undefined;
160
+ readonly provider: string;
161
+ readonly expiresAt?: DateTime.Utc | undefined;
162
+ /** Where pages' screencasts run, if not on each page's own session. */
163
+ readonly capture?: CaptureSource | undefined;
164
+ }, options?: Options | undefined) => Effect.Effect<Service, BrowserError, Scope.Scope>;
165
+ //#endregion
166
+ export { InitScript as a, RequestPolicy as c, Suspension as d, make as f, EventOptions as i, Service as l, Browser_d_exports as n, Options as o, CaptureSource as r, RequestDecision as s, Browser$1 as t, SuspendOptions as u };
167
+ //# sourceMappingURL=Browser-wZhwZSlG.d.mts.map
@@ -1,129 +1,2 @@
1
- import { t as BrowserError } from "./BrowserError-Coy7EW1N.mjs";
2
- import { c as DisconnectCause, i as BrowserEvent, v as RecordedEvent } from "./BrowserEvent-dq6FRT8w.mjs";
3
- import { c as InputGuard, d as Page_d_exports, u as Page$1 } from "./Page-ku6j5t-v.mjs";
4
- import { Context, DateTime, Duration, Effect, Option, Schema, Scope, Stream } from "effect";
5
- import { BrowserContext } from "playwright-core";
6
- declare namespace Browser_d_exports {
7
- export { Browser, CaptureSource, EventOptions, InitScript, Options, Service, SuspendOptions, Suspension, make };
8
- }
9
- /** A script that documents run before their own, such as a consent-banner remover. */
10
- export interface InitScript {
11
- /**
12
- * The documents that run it, by a pattern their address (`location.href`) matches; every
13
- * document and frame when left out. Under a `match`, the source runs as a block, so its own
14
- * top-level `let`, `const` and classes stay its own.
15
- */
16
- readonly match?: RegExp | undefined;
17
- readonly source: string;
18
- }
19
- export interface Options {
20
- /**
21
- * Bound on each action; finite and positive. Defaults to 10 seconds. What a presenter's view
22
- * takes to show an action, such as its glides and typing at a person's pace, does not count
23
- * against it.
24
- */
25
- readonly actionTimeout?: Duration.Input | undefined;
26
- /** Bound on each navigation; finite and positive. Defaults to 30 seconds. */
27
- readonly navigationTimeout?: Duration.Input | undefined;
28
- /**
29
- * How long each page keeps screencast frames for `recentFrames`, measured back from the newest;
30
- * finite and positive. Defaults to 5 seconds, a moment's default window.
31
- */
32
- readonly frameHistory?: Duration.Input | undefined;
33
- /** Events retained for replay and `recentEvents`. A positive safe integer, defaulting to 4,096. */
34
- readonly eventHistory?: number | undefined;
35
- /** Allow, deny or hold each input or navigation before it reaches the page. Defaults to allow. */
36
- readonly guard?: InputGuard | undefined;
37
- /** A separate bound for policy holds, outside action timeouts. Defaults to 5 minutes. */
38
- readonly policyTimeout?: Duration.Input | undefined;
39
- /** Scripts that new documents run before their own, each where its `match` allows. */
40
- readonly initScripts?: ReadonlyArray<InitScript> | undefined;
41
- /**
42
- * The most pages the browser keeps open, those a site opens included, which are never refused. At
43
- * it, `newPage` waits for one to close, within the action timeout, then fails `Limit`; under
44
- * `Page.failFast` it fails at once. A positive safe integer; no limit when left out.
45
- */
46
- readonly maxPages?: number | undefined;
47
- }
48
- export interface EventOptions {
49
- /** Resume after this sequence; 0 replays from the beginning if it is still retained. */
50
- readonly after?: number | undefined;
51
- }
52
- export interface SuspendOptions {
53
- /** Finite, nonnegative drain bound; defaults to the browser's navigationTimeout. */
54
- readonly drain?: Duration.Input | undefined;
55
- }
56
- declare const Suspension_base: Schema.Class<Suspension, Schema.Struct<{
57
- readonly since: Schema.Int;
58
- readonly at: Schema.Finite;
59
- }>, {}>;
60
- /** When admitted input finished; events after `since` describe the handoff interval. */
61
- export declare class Suspension extends Suspension_base {}
62
- /**
63
- * A connection to the browser apart from the one that drives its pages, for their screencasts,
64
- * as a provider that reaches the browser over a network supplies it: a frame and its
65
- * acknowledgement then never wait behind a large message, such as an upload or a read's answer,
66
- * on the connection that drives the page. It is read-only. A page's session on it sends the
67
- * capture's commands alone, and the page's own session keeps its focus emulation, which keeps a
68
- * tab behind painting.
69
- */
70
- export interface CaptureSource {
71
- /**
72
- * A session on the page's target, for the scope. `event` gets the session's events in the order
73
- * the browser sent them, its target's detach among them, until the scope closes; `lost` gets
74
- * the connection's failure, once, if it fails first. Its calls never throw: a failure rejects.
75
- */
76
- readonly attach: (target: string, listener: {
77
- readonly event: (method: string, params: unknown) => void;
78
- readonly lost: (error: BrowserError) => void;
79
- }) => Effect.Effect<(method: "Page.enable" | "Page.getFrameTree" | "Page.startScreencast" | "Page.screencastFrameAck" | "Page.stopScreencast", params?: Record<string, unknown>) => Promise<unknown>, BrowserError, Scope.Scope>;
80
- }
81
- export interface Service {
82
- /** The provider's session id, or a local id. */
83
- readonly id: string;
84
- /** Fresh for this connection, even when reattaching the same provider session and page. */
85
- readonly connection: string;
86
- readonly provider: string;
87
- /** When the provider ends the session on its own, as a hosted session's timeout does. */
88
- readonly expiresAt: DateTime.Utc | undefined;
89
- /** Host monotonic milliseconds on the clock shared by this browser’s events and frames. */
90
- readonly now: Effect.Effect<number>;
91
- /** Drain admitted input and withhold new input for this scope; reads and capture continue. */
92
- readonly suspend: (options?: SuspendOptions) => Effect.Effect<Suspension, BrowserError, Scope.Scope>;
93
- /** The Playwright context, for anything this API does not cover. Never give it to a model. */
94
- readonly context: BrowserContext;
95
- /** Open pages in the order this browser began tracking them. */
96
- readonly pages: Effect.Effect<ReadonlyArray<Page$1>>;
97
- /** The open page with this id, its CDP target id, as stored before a reconnect. */
98
- readonly page: (id: string) => Effect.Effect<Option.Option<Page$1>>;
99
- /** The first open page, opening one when there is none. */
100
- readonly firstPage: Effect.Effect<Page$1, BrowserError>;
101
- readonly newPage: (url?: string) => Effect.Effect<Page$1, BrowserError>;
102
- /**
103
- * Completes once the browser is lost to its owner, with why: its connection dropped, its
104
- * provider ended its session, or its owner's scope released it.
105
- */
106
- readonly disconnected: Effect.Effect<DisconnectCause>;
107
- /** Live events, or replay after a cursor. A reader that falls behind fails with EventHistoryExpired. */
108
- readonly events: (options?: EventOptions) => Stream.Stream<RecordedEvent, BrowserError>;
109
- /** The latest `eventHistory` events, oldest first. */
110
- readonly recentEvents: Effect.Effect<ReadonlyArray<BrowserEvent>>;
111
- }
112
- declare const Browser_base: Context.ServiceClass<Browser, "effect-browser/Browser", Service>;
113
- export declare class Browser extends Browser_base {}
114
- /**
115
- * Build the service over a context the provider owns. The provider closes the context; this only
116
- * tracks its pages and events, for as long as the surrounding scope is open. Each page's protocol
117
- * session, capture and listeners end when that page closes or when the scope does, so a closed
118
- * tab retains nothing and the context keeps none of them afterwards.
119
- */
120
- export declare const make: (context: BrowserContext, info: {
121
- readonly id: string;
122
- readonly provider: string;
123
- readonly expiresAt?: DateTime.Utc | undefined;
124
- /** Where pages' screencasts run, if not on each page's own session. */
125
- readonly capture?: CaptureSource | undefined;
126
- }, options?: Options | undefined) => Effect.Effect<Service, BrowserError, Scope.Scope>;
127
- //#endregion
128
- export { Browser_d_exports as t };
129
- //# sourceMappingURL=Browser.d.mts.map
1
+ import { a as InitScript, c as RequestPolicy, d as Suspension, f as make, i as EventOptions, l as Service, o as Options, r as CaptureSource, s as RequestDecision, t as Browser, u as SuspendOptions } from "./Browser-wZhwZSlG.mjs";
2
+ export { Browser, CaptureSource, EventOptions, InitScript, Options, RequestDecision, RequestPolicy, Service, SuspendOptions, Suspension, make };
package/dist/Browser.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { i as make, r as Suspension, t as Browser } from "./Browser-BwCldIff.mjs";
1
+ import { i as make, r as Suspension, t as Browser } from "./Browser-Cq2K1FEA.mjs";
2
2
  export { Browser, Suspension, make };
@@ -1,6 +1,6 @@
1
- import { Schema } from "effect";
1
+ import { Effect, Schema } from "effect";
2
2
  declare namespace BrowserError_d_exports {
3
- export { BrowserError, Busy, Closed, Consequence, EventHistoryExpired, Failed, InvalidRequest, Limit, NavigationFailed, NotActionable, NotFound, PolicyDenied, PolicyTimeout, Reason, StaleRef, Suspended, Timeout, consequence };
3
+ export { BrowserError, Busy, Closed, Consequence, EventHistoryExpired, Failed, InvalidRequest, Limit, NavigationFailed, NotActionable, NotFound, PolicyDenied, PolicyTimeout, Reason, StaleRef, Suspended, Threw, Timeout, call, consequence, failWith, reasonOf, refuse, undispatched };
4
4
  }
5
5
  declare const Timeout_base: Schema.Class<Timeout, Schema.TaggedStruct<"Timeout", {
6
6
  readonly millis: Schema.Finite;
@@ -111,11 +111,16 @@ declare const Failed_base: Schema.Class<Failed, Schema.TaggedStruct<"Failed", {
111
111
  declare class Failed extends Failed_base {
112
112
  get message(): string;
113
113
  }
114
- declare const Reason: Schema.Union<readonly [typeof Timeout, typeof Busy, typeof Suspended, typeof Limit, typeof StaleRef, typeof NotFound, typeof NotActionable, typeof NavigationFailed, typeof Closed, typeof InvalidRequest, typeof PolicyDenied, typeof PolicyTimeout, typeof EventHistoryExpired, typeof Failed]>;
114
+ declare const Threw_base: Schema.Class<Threw, Schema.TaggedStruct<"Threw", {}>, import("effect/Cause").YieldableError>;
115
+ /** Caller code threw in the page's main world. Its source and payload stay private. */
116
+ declare class Threw extends Threw_base {
117
+ get message(): string;
118
+ }
119
+ declare const Reason: Schema.Union<readonly [typeof Timeout, typeof Busy, typeof Suspended, typeof Limit, typeof StaleRef, typeof NotFound, typeof NotActionable, typeof NavigationFailed, typeof Closed, typeof InvalidRequest, typeof PolicyDenied, typeof PolicyTimeout, typeof EventHistoryExpired, typeof Failed, typeof Threw]>;
115
120
  type Reason = typeof Reason.Type;
116
121
  declare const BrowserError_base: Schema.Class<BrowserError, Schema.TaggedStruct<"BrowserError", {
117
122
  readonly operation: Schema.String;
118
- readonly reason: Schema.Union<readonly [typeof Timeout, typeof Busy, typeof Suspended, typeof Limit, typeof StaleRef, typeof NotFound, typeof NotActionable, typeof NavigationFailed, typeof Closed, typeof InvalidRequest, typeof PolicyDenied, typeof PolicyTimeout, typeof EventHistoryExpired, typeof Failed]>;
123
+ readonly reason: Schema.Union<readonly [typeof Timeout, typeof Busy, typeof Suspended, typeof Limit, typeof StaleRef, typeof NotFound, typeof NotActionable, typeof NavigationFailed, typeof Closed, typeof InvalidRequest, typeof PolicyDenied, typeof PolicyTimeout, typeof EventHistoryExpired, typeof Failed, typeof Threw]>;
119
124
  readonly dispatched: Schema.Boolean;
120
125
  }>, import("effect/Cause").YieldableError>;
121
126
  declare class BrowserError extends BrowserError_base {
@@ -125,7 +130,7 @@ declare class BrowserError extends BrowserError_base {
125
130
  * What a failure leaves. `lost` is `"page"` when the page is gone and its browser stands, and
126
131
  * `"session"` when the browser is gone with its pages. `repeat` says whether the call can be made
127
132
  * again, on what still stands: `"safe"`, as nothing reached the browser; `"check"`, as it may have
128
- * taken effect, so look first, as an `Expect` attempt does; `"pointless"`, as it fails again unless
133
+ * taken effect, so look first, as a Plan expectation does; `"pointless"`, as it fails again unless
129
134
  * something changes, such as
130
135
  * a new ref; or `"resume"`, reading events again from a newer cursor.
131
136
  */
@@ -135,6 +140,16 @@ interface Consequence {
135
140
  }
136
141
  /** What `error` leaves, from its reason and whether it was dispatched alone. */
137
142
  declare const consequence: ({ reason, dispatched }: BrowserError) => Consequence;
143
+ /** A failure before any of the operation's input reached the page. */
144
+ declare const undispatched: (operation: string, reason: Reason) => BrowserError;
145
+ /** Fail an operation before dispatch, preserving its typed reason. */
146
+ declare const failWith: (operation: string, reason: Reason) => Effect.Effect<never, BrowserError, never>;
147
+ /** Refuse an invalid request before sending anything. */
148
+ declare const refuse: (operation: string, detail: string) => Effect.Effect<never, BrowserError, never>;
149
+ /** Translate a protocol/provider failure, redacting diagnostic addresses by default. */
150
+ declare const reasonOf: (cause: unknown, timeoutMillis?: number, closed?: Closed["cause"], redact?: (message: string) => string) => Reason;
151
+ /** A native call whose action wrapper owns any later dispatch evidence. */
152
+ declare const call: <A>(operation: string, run: () => Promise<A>, closedBy: () => Closed["cause"], timeoutMillis?: number) => Effect.Effect<A, BrowserError, never>;
138
153
  //#endregion
139
- export { Suspended as _, Consequence as a, InvalidRequest as c, NotActionable as d, NotFound as f, StaleRef as g, Reason as h, Closed as i, Limit as l, PolicyTimeout as m, BrowserError_d_exports as n, EventHistoryExpired as o, PolicyDenied as p, Busy as r, Failed as s, BrowserError as t, NavigationFailed as u, Timeout as v, consequence as y };
140
- //# sourceMappingURL=BrowserError-Coy7EW1N.d.mts.map
154
+ export { reasonOf as C, failWith as S, undispatched as T, Suspended as _, Consequence as a, call as b, InvalidRequest as c, NotActionable as d, NotFound as f, StaleRef as g, Reason as h, Closed as i, Limit as l, PolicyTimeout as m, BrowserError_d_exports as n, EventHistoryExpired as o, PolicyDenied as p, Busy as r, Failed as s, BrowserError as t, NavigationFailed as u, Threw as v, refuse as w, consequence as x, Timeout as y };
155
+ //# sourceMappingURL=BrowserError-BlcmLVzn.d.mts.map
@@ -1,2 +1,2 @@
1
- import { _ as Suspended, a as Consequence, c as InvalidRequest, d as NotActionable, f as NotFound, g as StaleRef, h as Reason, i as Closed, l as Limit, m as PolicyTimeout, o as EventHistoryExpired, p as PolicyDenied, r as Busy, s as Failed, t as BrowserError, u as NavigationFailed, v as Timeout, y as consequence } from "./BrowserError-Coy7EW1N.mjs";
2
- export { BrowserError, Busy, Closed, Consequence, EventHistoryExpired, Failed, InvalidRequest, Limit, NavigationFailed, NotActionable, NotFound, PolicyDenied, PolicyTimeout, Reason, StaleRef, Suspended, Timeout, consequence };
1
+ import { C as reasonOf, S as failWith, T as undispatched, _ as Suspended, a as Consequence, b as call, c as InvalidRequest, d as NotActionable, f as NotFound, g as StaleRef, h as Reason, i as Closed, l as Limit, m as PolicyTimeout, o as EventHistoryExpired, p as PolicyDenied, r as Busy, s as Failed, t as BrowserError, u as NavigationFailed, v as Threw, w as refuse, x as consequence, y as Timeout } from "./BrowserError-BlcmLVzn.mjs";
2
+ export { BrowserError, Busy, Closed, Consequence, EventHistoryExpired, Failed, InvalidRequest, Limit, NavigationFailed, NotActionable, NotFound, PolicyDenied, PolicyTimeout, Reason, StaleRef, Suspended, Threw, Timeout, call, consequence, failWith, reasonOf, refuse, undispatched };
@@ -1,6 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { redactWithin } from "./Url.mjs";
2
3
  import { DisconnectCause } from "./BrowserEvent.mjs";
3
- import { Schema } from "effect";
4
+ import { Effect, Schema } from "effect";
4
5
  //#region src/BrowserError.ts
5
6
  /**
6
7
  * The one error every browser operation fails with.
@@ -28,8 +29,14 @@ var BrowserError_exports = /* @__PURE__ */ __exportAll({
28
29
  Reason: () => Reason,
29
30
  StaleRef: () => StaleRef,
30
31
  Suspended: () => Suspended,
32
+ Threw: () => Threw,
31
33
  Timeout: () => Timeout,
32
- consequence: () => consequence
34
+ call: () => call,
35
+ consequence: () => consequence,
36
+ failWith: () => failWith,
37
+ reasonOf: () => reasonOf,
38
+ refuse: () => refuse,
39
+ undispatched: () => undispatched
33
40
  });
34
41
  /** The operation did not finish in time. */
35
42
  var Timeout = class extends Schema.TaggedError()("Timeout", { millis: Schema.Finite }) {
@@ -148,6 +155,12 @@ var Failed = class extends Schema.TaggedError()("Failed", { detail: Schema.Strin
148
155
  return this.detail;
149
156
  }
150
157
  };
158
+ /** Caller code threw in the page's main world. Its source and payload stay private. */
159
+ var Threw = class extends Schema.TaggedError()("Threw", {}) {
160
+ get message() {
161
+ return "the page script threw";
162
+ }
163
+ };
151
164
  const Reason = Schema.Union([
152
165
  Timeout,
153
166
  Busy,
@@ -162,7 +175,8 @@ const Reason = Schema.Union([
162
175
  PolicyDenied,
163
176
  PolicyTimeout,
164
177
  EventHistoryExpired,
165
- Failed
178
+ Failed,
179
+ Threw
166
180
  ]);
167
181
  var BrowserError = class extends Schema.TaggedError()("BrowserError", {
168
182
  operation: Schema.String,
@@ -181,6 +195,8 @@ const consequence = ({ reason, dispatched }) => {
181
195
  lost: reason.cause === "page" || reason.cause === "crashed" ? "page" : "session",
182
196
  repeat
183
197
  };
198
+ case "Limit":
199
+ case "PolicyTimeout":
184
200
  case "Busy":
185
201
  case "Suspended":
186
202
  case "Timeout":
@@ -191,21 +207,42 @@ const consequence = ({ reason, dispatched }) => {
191
207
  };
192
208
  case "EventHistoryExpired": return {
193
209
  lost: "nothing",
194
- repeat: "resume"
210
+ repeat: dispatched ? "check" : "resume"
195
211
  };
212
+ case "Threw":
196
213
  case "StaleRef":
197
214
  case "NotFound":
198
215
  case "NotActionable":
199
216
  case "InvalidRequest":
200
- case "Limit":
201
- case "PolicyDenied":
202
- case "PolicyTimeout": return {
217
+ case "PolicyDenied": return {
203
218
  lost: "nothing",
204
- repeat: "pointless"
219
+ repeat: dispatched ? "check" : "pointless"
205
220
  };
206
221
  }
207
222
  };
223
+ /** A failure before any of the operation's input reached the page. */
224
+ const undispatched = (operation, reason) => new BrowserError({
225
+ operation,
226
+ reason,
227
+ dispatched: false
228
+ });
229
+ /** Fail an operation before dispatch, preserving its typed reason. */
230
+ const failWith = (operation, reason) => Effect.fail(undispatched(operation, reason));
231
+ /** Refuse an invalid request before sending anything. */
232
+ const refuse = (operation, detail) => failWith(operation, new InvalidRequest({ detail }));
233
+ /** Translate a protocol/provider failure, redacting diagnostic addresses by default. */
234
+ const reasonOf = (cause, timeoutMillis, closed = "connection", redact = redactWithin) => {
235
+ const message = cause instanceof Error ? cause.message : typeof cause === "string" ? cause : "unknown error";
236
+ if (/has been closed|Target closed|Session closed|browser has disconnected|Target page, context or browser/i.test(message)) return new Closed({ cause: closed });
237
+ if (cause instanceof Error && cause.name === "TimeoutError" && timeoutMillis !== void 0) return new Timeout({ millis: timeoutMillis });
238
+ return new Failed({ detail: (redact(message).split("\n")[0] ?? "unknown error").replace(/^[\w.]+: /, "") });
239
+ };
240
+ /** A native call whose action wrapper owns any later dispatch evidence. */
241
+ const call = (operation, run, closedBy, timeoutMillis) => Effect.tryPromise({
242
+ try: run,
243
+ catch: (cause) => undispatched(operation, reasonOf(cause, timeoutMillis, closedBy()))
244
+ });
208
245
  //#endregion
209
- export { BrowserError, Busy, Closed, EventHistoryExpired, Failed, InvalidRequest, Limit, NavigationFailed, NotActionable, NotFound, PolicyDenied, PolicyTimeout, Reason, StaleRef, Suspended, Timeout, consequence, BrowserError_exports as t };
246
+ export { BrowserError, Busy, Closed, EventHistoryExpired, Failed, InvalidRequest, Limit, NavigationFailed, NotActionable, NotFound, PolicyDenied, PolicyTimeout, Reason, StaleRef, Suspended, Threw, Timeout, call, consequence, failWith, reasonOf, refuse, BrowserError_exports as t, undispatched };
210
247
 
211
248
  //# sourceMappingURL=BrowserError.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"BrowserError.mjs","names":[],"sources":["../src/BrowserError.ts"],"sourcesContent":["/**\n * The one error every browser operation fails with.\n *\n * `reason` says what went wrong and `dispatched` says whether the action's own input (a press,\n * key, wheel, selection or hover, not the pointer travelling toward a press) or a navigation\n * reached the browser first. `consequence` says what that leaves: what was lost, and whether the\n * call can be repeated. `message` is a sentence for operators.\n *\n * @since 0.3.0\n */\nimport { Schema } from \"effect\";\n\nimport { DisconnectCause } from \"./BrowserEvent.ts\";\n\n/** The operation did not finish in time. */\nexport class Timeout extends Schema.TaggedError<Timeout>()(\"Timeout\", {\n millis: Schema.Finite,\n}) {\n override get message() {\n return `timed out after ${this.millis} ms`;\n }\n}\n\n/**\n * The operation waited its turn behind others on its page and was not given one in time, or was\n * asked to fail fast: the page may be well, only busy.\n */\nexport class Busy extends Schema.TaggedError<Busy>()(\"Busy\", {\n waitedMillis: Schema.Finite,\n /** The operations ahead of it: those holding the page and those asked before it. */\n ahead: Schema.Int,\n}) {\n override get message() {\n const others = this.ahead === 1 ? \"operation\" : \"operations\";\n\n return `the page was busy: it waited ${this.waitedMillis} ms behind ${this.ahead} other ${others}`;\n }\n}\n\n/** Input is withheld by a scoped suspension; nothing was dispatched. */\nexport class Suspended extends Schema.TaggedError<Suspended>()(\"Suspended\", {}) {\n override get message() {\n return \"browser input is suspended\";\n }\n}\n\n/** The browser has as many pages open as `maxPages` allows, and none closed in time. */\nexport class Limit extends Schema.TaggedError<Limit>()(\"Limit\", {\n maxPages: Schema.Int,\n}) {\n override get message() {\n return `the browser already has ${this.maxPages} pages open, as many as it allows`;\n }\n}\n\n/** A ref from an earlier snapshot no longer names an element on the page. */\nexport class StaleRef extends Schema.TaggedError<StaleRef>()(\"StaleRef\", {\n ref: Schema.String,\n}) {\n override get message() {\n return `${this.ref} is not on the page any more`;\n }\n}\n\n/** What the operation looked for is not on the page. */\nexport class NotFound extends Schema.TaggedError<NotFound>()(\"NotFound\", {\n target: Schema.String,\n}) {\n override get message() {\n return `${this.target} was not found`;\n }\n}\n\n/** The element exists but cannot take this input: covered, disabled, hidden or the wrong kind. */\nexport class NotActionable extends Schema.TaggedError<NotActionable>()(\"NotActionable\", {\n detail: Schema.String,\n}) {\n override get message() {\n return this.detail;\n }\n}\n\n/** A navigation failed, for example on a DNS error or a refused connection. */\nexport class NavigationFailed extends Schema.TaggedError<NavigationFailed>()(\"NavigationFailed\", {\n url: Schema.String,\n detail: Schema.String,\n}) {\n override get message() {\n return `could not load ${this.url}: ${this.detail}`;\n }\n}\n\nconst closedBy = {\n page: \"the page was closed\",\n crashed: \"the page crashed\",\n connection: \"the connection to the browser was lost\",\n session: \"the browser's session ended\",\n released: \"the browser was released\",\n};\n\n/**\n * The page is gone: it was closed (`page`) or crashed, or its browser was lost for one of the\n * browser's `DisconnectCause`s.\n */\nexport class Closed extends Schema.TaggedError<Closed>()(\"Closed\", {\n cause: Schema.Literals([\"page\", \"crashed\", ...DisconnectCause.literals]),\n}) {\n override get message() {\n return closedBy[this.cause];\n }\n}\n\n/** The request itself is invalid, such as a ref that is not a ref or a point off the screen. */\nexport class InvalidRequest extends Schema.TaggedError<InvalidRequest>()(\"InvalidRequest\", {\n detail: Schema.String,\n}) {\n override get message() {\n return this.detail;\n }\n}\n\n/** The input policy refused the action before any input was sent. */\nexport class PolicyDenied extends Schema.TaggedError<PolicyDenied>()(\"PolicyDenied\", {\n detail: Schema.String,\n /** What made the policy deny, such as the failure of the judge it asked. */\n cause: Schema.optional(Schema.Defect()),\n}) {\n override get message() {\n return `the input policy denied this action: ${this.detail}`;\n }\n}\n\n/** The input policy did not release its hold within its own bound. */\nexport class PolicyTimeout extends Schema.TaggedError<PolicyTimeout>()(\"PolicyTimeout\", {\n millis: Schema.Finite,\n}) {\n override get message() {\n return `the input policy did not allow this action within ${this.millis} ms`;\n }\n}\n\n/** The requested event cursor fell behind the browser's bounded replay history. */\nexport class EventHistoryExpired extends Schema.TaggedError<EventHistoryExpired>()(\n \"EventHistoryExpired\",\n {\n after: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n oldest: Schema.Int.check(Schema.isGreaterThan(0)),\n latest: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n },\n) {\n override get message() {\n return `event history after ${this.after} expired; retained sequences are ${this.oldest}–${this.latest}`;\n }\n}\n\n/** The browser, the connection or the provider failed in a way the other reasons do not cover. */\nexport class Failed extends Schema.TaggedError<Failed>()(\"Failed\", {\n detail: Schema.String,\n}) {\n override get message() {\n return this.detail;\n }\n}\n\nexport const Reason = Schema.Union([\n Timeout,\n Busy,\n Suspended,\n Limit,\n StaleRef,\n NotFound,\n NotActionable,\n NavigationFailed,\n Closed,\n InvalidRequest,\n PolicyDenied,\n PolicyTimeout,\n EventHistoryExpired,\n Failed,\n]);\n\nexport type Reason = typeof Reason.Type;\n\nexport class BrowserError extends Schema.TaggedError<BrowserError>()(\"BrowserError\", {\n operation: Schema.String,\n reason: Reason,\n dispatched: Schema.Boolean,\n}) {\n override get message() {\n return `${this.operation} failed${this.dispatched ? \" after it was sent\" : \"\"}: ${this.reason.message}`;\n }\n}\n\n/**\n * What a failure leaves. `lost` is `\"page\"` when the page is gone and its browser stands, and\n * `\"session\"` when the browser is gone with its pages. `repeat` says whether the call can be made\n * again, on what still stands: `\"safe\"`, as nothing reached the browser; `\"check\"`, as it may have\n * taken effect, so look first, as an `Expect` attempt does; `\"pointless\"`, as it fails again unless\n * something changes, such as\n * a new ref; or `\"resume\"`, reading events again from a newer cursor.\n */\nexport interface Consequence {\n readonly lost: \"nothing\" | \"page\" | \"session\";\n readonly repeat: \"safe\" | \"check\" | \"pointless\" | \"resume\";\n}\n\n/** What `error` leaves, from its reason and whether it was dispatched alone. */\nexport const consequence = ({ reason, dispatched }: BrowserError): Consequence => {\n const repeat = dispatched ? \"check\" : \"safe\";\n\n switch (reason._tag) {\n case \"Closed\":\n return {\n lost: reason.cause === \"page\" || reason.cause === \"crashed\" ? \"page\" : \"session\",\n repeat,\n };\n case \"Busy\":\n case \"Suspended\":\n case \"Timeout\":\n case \"Failed\":\n case \"NavigationFailed\":\n return { lost: \"nothing\", repeat };\n case \"EventHistoryExpired\":\n return { lost: \"nothing\", repeat: \"resume\" };\n case \"StaleRef\":\n case \"NotFound\":\n case \"NotActionable\":\n case \"InvalidRequest\":\n case \"Limit\":\n case \"PolicyDenied\":\n case \"PolicyTimeout\":\n return { lost: \"nothing\", repeat: \"pointless\" };\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,IAAa,UAAb,cAA6B,OAAO,YAAqB,CAAC,CAAC,WAAW,EACpE,QAAQ,OAAO,OACjB,CAAC,CAAC,CAAC;CACD,IAAa,UAAU;EACrB,OAAO,mBAAmB,KAAK,OAAO;CACxC;AACF;;;;;AAMA,IAAa,OAAb,cAA0B,OAAO,YAAkB,CAAC,CAAC,QAAQ;CAC3D,cAAc,OAAO;;CAErB,OAAO,OAAO;AAChB,CAAC,CAAC,CAAC;CACD,IAAa,UAAU;EACrB,MAAM,SAAS,KAAK,UAAU,IAAI,cAAc;EAEhD,OAAO,gCAAgC,KAAK,aAAa,aAAa,KAAK,MAAM,SAAS;CAC5F;AACF;;AAGA,IAAa,YAAb,cAA+B,OAAO,YAAuB,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAC9E,IAAa,UAAU;EACrB,OAAO;CACT;AACF;;AAGA,IAAa,QAAb,cAA2B,OAAO,YAAmB,CAAC,CAAC,SAAS,EAC9D,UAAU,OAAO,IACnB,CAAC,CAAC,CAAC;CACD,IAAa,UAAU;EACrB,OAAO,2BAA2B,KAAK,SAAS;CAClD;AACF;;AAGA,IAAa,WAAb,cAA8B,OAAO,YAAsB,CAAC,CAAC,YAAY,EACvE,KAAK,OAAO,OACd,CAAC,CAAC,CAAC;CACD,IAAa,UAAU;EACrB,OAAO,GAAG,KAAK,IAAI;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AM;GAAW,QAAQ;EAAS;EAC7C,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,iBACH,OAAO;GAAE,MAAM;GAAW,QAAQ;EAAY;CAClD;AACF"}
1
+ {"version":3,"file":"BrowserError.mjs","names":["Url.redactWithin"],"sources":["../src/BrowserError.ts"],"sourcesContent":["/**\n * The one error every browser operation fails with.\n *\n * `reason` says what went wrong and `dispatched` says whether the action's own input (a press,\n * key, wheel, selection or hover, not the pointer travelling toward a press) or a navigation\n * reached the browser first. `consequence` says what that leaves: what was lost, and whether the\n * call can be repeated. `message` is a sentence for operators.\n *\n * @since 0.3.0\n */\nimport { Effect, Schema } from \"effect\";\n\nimport { DisconnectCause } from \"./BrowserEvent.ts\";\nimport * as Url from \"./Url.ts\";\n\n/** The operation did not finish in time. */\nexport class Timeout extends Schema.TaggedError<Timeout>()(\"Timeout\", {\n millis: Schema.Finite,\n}) {\n override get message() {\n return `timed out after ${this.millis} ms`;\n }\n}\n\n/**\n * The operation waited its turn behind others on its page and was not given one in time, or was\n * asked to fail fast: the page may be well, only busy.\n */\nexport class Busy extends Schema.TaggedError<Busy>()(\"Busy\", {\n waitedMillis: Schema.Finite,\n /** The operations ahead of it: those holding the page and those asked before it. */\n ahead: Schema.Int,\n}) {\n override get message() {\n const others = this.ahead === 1 ? \"operation\" : \"operations\";\n\n return `the page was busy: it waited ${this.waitedMillis} ms behind ${this.ahead} other ${others}`;\n }\n}\n\n/** Input is withheld by a scoped suspension; nothing was dispatched. */\nexport class Suspended extends Schema.TaggedError<Suspended>()(\"Suspended\", {}) {\n override get message() {\n return \"browser input is suspended\";\n }\n}\n\n/** The browser has as many pages open as `maxPages` allows, and none closed in time. */\nexport class Limit extends Schema.TaggedError<Limit>()(\"Limit\", {\n maxPages: Schema.Int,\n}) {\n override get message() {\n return `the browser already has ${this.maxPages} pages open, as many as it allows`;\n }\n}\n\n/** A ref from an earlier snapshot no longer names an element on the page. */\nexport class StaleRef extends Schema.TaggedError<StaleRef>()(\"StaleRef\", {\n ref: Schema.String,\n}) {\n override get message() {\n return `${this.ref} is not on the page any more`;\n }\n}\n\n/** What the operation looked for is not on the page. */\nexport class NotFound extends Schema.TaggedError<NotFound>()(\"NotFound\", {\n target: Schema.String,\n}) {\n override get message() {\n return `${this.target} was not found`;\n }\n}\n\n/** The element exists but cannot take this input: covered, disabled, hidden or the wrong kind. */\nexport class NotActionable extends Schema.TaggedError<NotActionable>()(\"NotActionable\", {\n detail: Schema.String,\n}) {\n override get message() {\n return this.detail;\n }\n}\n\n/** A navigation failed, for example on a DNS error or a refused connection. */\nexport class NavigationFailed extends Schema.TaggedError<NavigationFailed>()(\"NavigationFailed\", {\n url: Schema.String,\n detail: Schema.String,\n}) {\n override get message() {\n return `could not load ${this.url}: ${this.detail}`;\n }\n}\n\nconst closedBy = {\n page: \"the page was closed\",\n crashed: \"the page crashed\",\n connection: \"the connection to the browser was lost\",\n session: \"the browser's session ended\",\n released: \"the browser was released\",\n};\n\n/**\n * The page is gone: it was closed (`page`) or crashed, or its browser was lost for one of the\n * browser's `DisconnectCause`s.\n */\nexport class Closed extends Schema.TaggedError<Closed>()(\"Closed\", {\n cause: Schema.Literals([\"page\", \"crashed\", ...DisconnectCause.literals]),\n}) {\n override get message() {\n return closedBy[this.cause];\n }\n}\n\n/** The request itself is invalid, such as a ref that is not a ref or a point off the screen. */\nexport class InvalidRequest extends Schema.TaggedError<InvalidRequest>()(\"InvalidRequest\", {\n detail: Schema.String,\n}) {\n override get message() {\n return this.detail;\n }\n}\n\n/** The input policy refused the action before any input was sent. */\nexport class PolicyDenied extends Schema.TaggedError<PolicyDenied>()(\"PolicyDenied\", {\n detail: Schema.String,\n /** What made the policy deny, such as the failure of the judge it asked. */\n cause: Schema.optional(Schema.Defect()),\n}) {\n override get message() {\n return `the input policy denied this action: ${this.detail}`;\n }\n}\n\n/** The input policy did not release its hold within its own bound. */\nexport class PolicyTimeout extends Schema.TaggedError<PolicyTimeout>()(\"PolicyTimeout\", {\n millis: Schema.Finite,\n}) {\n override get message() {\n return `the input policy did not allow this action within ${this.millis} ms`;\n }\n}\n\n/** The requested event cursor fell behind the browser's bounded replay history. */\nexport class EventHistoryExpired extends Schema.TaggedError<EventHistoryExpired>()(\n \"EventHistoryExpired\",\n {\n after: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n oldest: Schema.Int.check(Schema.isGreaterThan(0)),\n latest: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n },\n) {\n override get message() {\n return `event history after ${this.after} expired; retained sequences are ${this.oldest}–${this.latest}`;\n }\n}\n\n/** The browser, the connection or the provider failed in a way the other reasons do not cover. */\nexport class Failed extends Schema.TaggedError<Failed>()(\"Failed\", {\n detail: Schema.String,\n}) {\n override get message() {\n return this.detail;\n }\n}\n\n/** Caller code threw in the page's main world. Its source and payload stay private. */\nexport class Threw extends Schema.TaggedError<Threw>()(\"Threw\", {}) {\n override get message() {\n return \"the page script threw\";\n }\n}\n\nexport const Reason = Schema.Union([\n Timeout,\n Busy,\n Suspended,\n Limit,\n StaleRef,\n NotFound,\n NotActionable,\n NavigationFailed,\n Closed,\n InvalidRequest,\n PolicyDenied,\n PolicyTimeout,\n EventHistoryExpired,\n Failed,\n Threw,\n]);\n\nexport type Reason = typeof Reason.Type;\n\nexport class BrowserError extends Schema.TaggedError<BrowserError>()(\"BrowserError\", {\n operation: Schema.String,\n reason: Reason,\n dispatched: Schema.Boolean,\n}) {\n override get message() {\n return `${this.operation} failed${this.dispatched ? \" after it was sent\" : \"\"}: ${this.reason.message}`;\n }\n}\n\n/**\n * What a failure leaves. `lost` is `\"page\"` when the page is gone and its browser stands, and\n * `\"session\"` when the browser is gone with its pages. `repeat` says whether the call can be made\n * again, on what still stands: `\"safe\"`, as nothing reached the browser; `\"check\"`, as it may have\n * taken effect, so look first, as a Plan expectation does; `\"pointless\"`, as it fails again unless\n * something changes, such as\n * a new ref; or `\"resume\"`, reading events again from a newer cursor.\n */\nexport interface Consequence {\n readonly lost: \"nothing\" | \"page\" | \"session\";\n readonly repeat: \"safe\" | \"check\" | \"pointless\" | \"resume\";\n}\n\n/** What `error` leaves, from its reason and whether it was dispatched alone. */\nexport const consequence = ({ reason, dispatched }: BrowserError): Consequence => {\n const repeat = dispatched ? \"check\" : \"safe\";\n\n switch (reason._tag) {\n case \"Closed\":\n return {\n lost: reason.cause === \"page\" || reason.cause === \"crashed\" ? \"page\" : \"session\",\n repeat,\n };\n case \"Limit\":\n case \"PolicyTimeout\":\n case \"Busy\":\n case \"Suspended\":\n case \"Timeout\":\n case \"Failed\":\n case \"NavigationFailed\":\n return { lost: \"nothing\", repeat };\n case \"EventHistoryExpired\":\n return { lost: \"nothing\", repeat: dispatched ? \"check\" : \"resume\" };\n case \"Threw\":\n case \"StaleRef\":\n case \"NotFound\":\n case \"NotActionable\":\n case \"InvalidRequest\":\n case \"PolicyDenied\":\n return { lost: \"nothing\", repeat: dispatched ? \"check\" : \"pointless\" };\n }\n};\n\n/** A failure before any of the operation's input reached the page. */\nexport const undispatched = (operation: string, reason: Reason) =>\n new BrowserError({ operation, reason, dispatched: false });\n\n/** Fail an operation before dispatch, preserving its typed reason. */\nexport const failWith = (operation: string, reason: Reason) =>\n Effect.fail(undispatched(operation, reason));\n\n/** Refuse an invalid request before sending anything. */\nexport const refuse = (operation: string, detail: string) =>\n failWith(operation, new InvalidRequest({ detail }));\n\n/** Translate a protocol/provider failure, redacting diagnostic addresses by default. */\nexport const reasonOf = (\n cause: unknown,\n timeoutMillis?: number,\n closed: Closed[\"cause\"] = \"connection\",\n redact: (message: string) => string = Url.redactWithin,\n): Reason => {\n const message =\n cause instanceof Error ? cause.message : typeof cause === \"string\" ? cause : \"unknown error\";\n\n if (\n /has been closed|Target closed|Session closed|browser has disconnected|Target page, context or browser/i.test(\n message,\n )\n )\n return new Closed({ cause: closed });\n if (cause instanceof Error && cause.name === \"TimeoutError\" && timeoutMillis !== undefined)\n return new Timeout({ millis: timeoutMillis });\n const line = redact(message).split(\"\\n\")[0] ?? \"unknown error\";\n\n return new Failed({ detail: line.replace(/^[\\w.]+: /, \"\") });\n};\n\n/** A native call whose action wrapper owns any later dispatch evidence. */\nexport const call = <A>(\n operation: string,\n run: () => Promise<A>,\n closedBy: () => Closed[\"cause\"],\n timeoutMillis?: number,\n) =>\n Effect.tryPromise({\n try: run,\n catch: (cause) => undispatched(operation, reasonOf(cause, timeoutMillis, closedBy())),\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAa,UAAb,cAA6B,OAAO,YAAqB,CAAC,CAAC,WAAW,EACpE,QAAQ,OAAO,OACjB,CAAC,CAAC,CAAC;CACD,IAAa,UAAU;EACrB,OAAO,mBAAmB,KAAK,OAAO;CACxC;AACF;;;;;AAMA,IAAa,OAAb,cAA0B,OAAO,YAAkB,CAAC,CAAC,QAAQ;CAC3D,cAAc,OAAO;;CAErB,OAAO,OAAO;AAChB,CAAC,CAAC,CAAC;CACD,IAAa,UAAU;EACrB,MAAM,SAAS,KAAK,UAAU,IAAI,cAAc;EAEhD,OAAO,gCAAgC,KAAK,aAAa,aAAa,KAAK,MAAM,SAAS;CAC5F;AACF;;AAGA,IAAa,YAAb,cAA+B,OAAO,YAAuB,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAC9E,IAAa,UAAU;EACrB,OAAO;CACT;AACF;;AAGA,IAAa,QAAb,cAA2B,OAAO,YAAmB,CAAC,CAAC,SAAS,EAC9D,UAAU,OAAO,IACnB,CAAC,CAAC,CAAC;CACD,IAAa,UAAU;EACrB,OAAO,2BAA2B,KAAK,SAAS;CAClD;AACF;;AAGA,IAAa,WAAb,cAA8B,OAAO,YAAsB,CAAC,CAAC,YAAY,EACvE,KAAK,OAAO,OACd,CAAC,CAAC,CAAC;CACD,IAAa,UAAU;EACrB,OAAO,GAAG,KAAK,IAAI;CACrB;AACF;;AAGA,IAAa,WAAb,cAA8B,OAAO,YA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