effect-browser 0.3.0-beta.21 → 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.
- package/README.md +130 -159
- package/dist/Action-24sLOubi.d.mts +110 -0
- package/dist/Action.d.mts +2 -0
- package/dist/Action.mjs +141 -0
- package/dist/Action.mjs.map +1 -0
- package/dist/ActionPort.d.mts +15 -0
- package/dist/ActionPort.mjs +101 -0
- package/dist/ActionPort.mjs.map +1 -0
- package/dist/Browser-Cq2K1FEA.mjs +4075 -0
- package/dist/Browser-Cq2K1FEA.mjs.map +1 -0
- package/dist/{Browser-CiXHT1yO.d.mts → Browser-wZhwZSlG.d.mts} +51 -13
- package/dist/Browser.d.mts +2 -2
- package/dist/Browser.mjs +1 -1
- package/dist/{BrowserError-Coy7EW1N.d.mts → BrowserError-BlcmLVzn.d.mts} +22 -7
- package/dist/BrowserError.d.mts +2 -2
- package/dist/BrowserError.mjs +46 -9
- package/dist/BrowserError.mjs.map +1 -1
- package/dist/{BrowserEvent-dq6FRT8w.d.mts → BrowserEvent-lLqJ3GJS.d.mts} +93 -37
- package/dist/BrowserEvent.d.mts +2 -2
- package/dist/BrowserEvent.mjs +29 -24
- package/dist/BrowserEvent.mjs.map +1 -1
- package/dist/{Change-DqING3tr.d.mts → Change-Ba7INmay.d.mts} +4 -6
- package/dist/Change.d.mts +2 -2
- package/dist/Change.mjs +97 -2
- package/dist/Change.mjs.map +1 -0
- package/dist/Clock.d.mts +57 -0
- package/dist/Clock.mjs +80 -0
- package/dist/Clock.mjs.map +1 -0
- package/dist/{Frame-DkNdjjjr.d.mts → Frame-UEH2hO5T.d.mts} +10 -3
- package/dist/Frame.d.mts +2 -2
- package/dist/Frame.mjs +10 -2
- package/dist/Frame.mjs.map +1 -1
- package/dist/{Motion-DND6I-64.d.mts → Geometry-DJx9qrYy.d.mts} +7 -10
- package/dist/Geometry.d.mts +2 -0
- package/dist/Geometry.mjs +32 -0
- package/dist/Geometry.mjs.map +1 -0
- package/dist/Matching.d.mts +37 -0
- package/dist/Matching.mjs +72 -0
- package/dist/Matching.mjs.map +1 -0
- package/dist/Page-BF5izr8R.mjs +795 -0
- package/dist/Page-BF5izr8R.mjs.map +1 -0
- package/dist/{Page-ku6j5t-v.d.mts → Page-CvsOEorc.d.mts} +158 -185
- package/dist/Page.d.mts +2 -2
- package/dist/Page.mjs +1 -1
- package/dist/Released-tURbFmal.d.mts +15 -0
- package/dist/{Snapshot-B34hZ4Jl.d.mts → Snapshot-CtBVOtuu.d.mts} +6 -1
- package/dist/Snapshot.d.mts +1 -1
- package/dist/Snapshot.mjs.map +1 -1
- package/dist/Stillness-CNlvayIo.mjs +136 -0
- package/dist/Stillness-CNlvayIo.mjs.map +1 -0
- package/dist/Style-AO4V7Czt.mjs +357 -0
- package/dist/Style-AO4V7Czt.mjs.map +1 -0
- package/dist/Style.d.mts +72 -0
- package/dist/Style.mjs +2 -0
- package/dist/Url.d.mts +26 -0
- package/dist/Url.mjs +74 -0
- package/dist/Url.mjs.map +1 -0
- package/dist/Window-CMddGMt1.d.mts +34 -0
- package/dist/Window.d.mts +2 -0
- package/dist/Window.mjs +35 -0
- package/dist/Window.mjs.map +1 -0
- package/dist/{cdp-DL7XfEj5.d.mts → connection-2KHI4_KN.d.mts} +4 -4
- package/dist/{cdp-BMpYMWYe.mjs → connection-BTeO0Hiz.mjs} +5 -6
- package/dist/connection-BTeO0Hiz.mjs.map +1 -0
- package/dist/index.d.mts +15 -18
- package/dist/index.mjs +11 -15
- package/dist/moment/Moment.d.mts +86 -0
- package/dist/{Moment.mjs → moment/Moment.mjs} +44 -38
- package/dist/moment/Moment.mjs.map +1 -0
- package/dist/{Plan-DJ4hEEna.d.mts → plan/index.d.mts} +169 -64
- package/dist/{Plan-BG1WifW2.mjs → plan/index.mjs} +122 -199
- package/dist/plan/index.mjs.map +1 -0
- package/dist/{Policy-BGWjbqCl.d.mts → policy/Policy.d.mts} +16 -20
- package/dist/{Policy.mjs → policy/Policy.mjs} +11 -21
- package/dist/policy/Policy.mjs.map +1 -0
- package/dist/presentation/Motion.d.mts +12 -0
- package/dist/{Motion.mjs → presentation/Motion.mjs} +4 -27
- package/dist/presentation/Motion.mjs.map +1 -0
- package/dist/presentation/Presentation.d.mts +30 -0
- package/dist/presentation/Presentation.mjs +105 -0
- package/dist/presentation/Presentation.mjs.map +1 -0
- package/dist/{Stage-NHp8N81k.d.mts → presentation/Stage.d.mts} +12 -15
- package/dist/{Stage.mjs → presentation/Stage.mjs} +68 -76
- package/dist/presentation/Stage.mjs.map +1 -0
- package/dist/presentation/feed.d.mts +20 -0
- package/dist/presentation/feed.mjs +18 -0
- package/dist/presentation/feed.mjs.map +1 -0
- package/dist/providers/Cdp.d.mts +9 -0
- package/dist/{Cdp.mjs → providers/Cdp.mjs} +3 -8
- package/dist/providers/Cdp.mjs.map +1 -0
- package/dist/{Chromium.d.mts → providers/Chromium.d.mts} +6 -7
- package/dist/{Chromium.mjs → providers/Chromium.mjs} +6 -15
- package/dist/providers/Chromium.mjs.map +1 -0
- package/dist/providers/Released.d.mts +2 -0
- package/dist/providers/Released.mjs +12 -0
- package/dist/providers/Released.mjs.map +1 -0
- package/dist/stillness/Stillness.d.mts +12 -0
- package/dist/stillness/Stillness.mjs +2 -0
- package/dist/supervisor/Supervisor.d.mts +104 -0
- package/dist/supervisor/Supervisor.mjs +513 -0
- package/dist/supervisor/Supervisor.mjs.map +1 -0
- package/dist/testing/index.d.mts +337 -0
- package/dist/testing/index.mjs +515 -0
- package/dist/testing/index.mjs.map +1 -0
- package/dist/workerd/Cdp.d.mts +8 -3
- package/dist/workerd/Cdp.mjs +2 -7
- package/dist/workerd/Cdp.mjs.map +1 -1
- package/package.json +86 -36
- package/src/Action.ts +127 -0
- package/src/ActionPort.ts +128 -0
- package/src/Browser.ts +352 -201
- package/src/BrowserError.ts +63 -6
- package/src/BrowserEvent.ts +26 -25
- package/src/Change.ts +0 -2
- package/src/{internal/pictures/clock.ts → Clock.ts} +17 -6
- package/src/Frame.ts +14 -0
- package/src/Geometry.ts +48 -0
- package/src/{internal/reading/match.inpage.ts → Matching.ts} +34 -4
- package/src/Page.ts +111 -92
- package/src/Snapshot.ts +5 -0
- package/src/{internal/input/style.ts → Style.ts} +121 -14
- package/src/Window.ts +30 -0
- package/src/index.ts +15 -6
- package/src/internal/input/actions.ts +61 -119
- package/src/internal/input/dispatch.ts +3 -3
- package/src/internal/input/gate.ts +21 -18
- package/src/internal/input/guard.inpage.ts +25 -58
- package/src/internal/input/guard.ts +11 -20
- package/src/internal/input/keyboard.ts +12 -3
- package/src/internal/input/perform.ts +78 -60
- package/src/internal/input/pointer.ts +4 -2
- package/src/internal/input/settle.ts +7 -5
- package/src/internal/input/targets.inpage.ts +1 -1
- package/src/internal/input/targets.ts +4 -9
- package/src/internal/page/bridge.ts +209 -113
- package/src/internal/page/context.ts +12 -59
- package/src/internal/page/dialogs.ts +58 -0
- package/src/internal/page/lane.ts +14 -15
- package/src/internal/page/navigation.ts +50 -42
- package/src/internal/page/openings.ts +11 -5
- package/src/internal/page/page.ts +44 -81
- package/src/internal/page/port.ts +125 -0
- package/src/internal/{input → page}/replies.ts +1 -1
- package/src/internal/page/request-owner.ts +269 -0
- package/src/internal/page/requests.ts +357 -0
- package/src/internal/page/scripts.ts +124 -0
- package/src/internal/pictures/capture.ts +255 -332
- package/src/internal/pictures/dimensions.ts +162 -0
- package/src/internal/pictures/frame.ts +68 -0
- package/src/internal/pictures/pictures.ts +57 -23
- package/src/internal/pictures/quiescence.ts +1 -1
- package/src/internal/pictures/state.ts +26 -0
- package/src/internal/pictures/transport.ts +21 -4
- package/src/internal/reading/controls.inpage.ts +5 -70
- package/src/internal/reading/expect.inpage.ts +13 -17
- package/src/internal/reading/names.inpage.ts +89 -45
- package/src/internal/reading/outline.inpage.ts +6 -7
- package/src/internal/reading/reading.ts +144 -176
- package/src/internal/reading/ready.inpage.ts +6 -17
- package/src/internal/reading/ready.ts +13 -135
- package/src/internal/reading/subjects.inpage.ts +83 -43
- package/src/internal/reading/walk.inpage.ts +33 -13
- package/src/internal/timeline/changes.ts +55 -6
- package/src/internal/timeline/events.ts +15 -5
- package/src/internal/timeline/history.inpage.ts +1 -1
- package/src/internal/timeline/record.inpage.ts +4 -1
- package/src/internal/timeline/window.ts +2 -1
- package/src/{Moment.ts → moment/Moment.ts} +13 -31
- package/src/{internal/timeline → moment}/words.ts +2 -2
- package/src/{internal/reading → plan}/choose.ts +3 -3
- package/src/plan/data.ts +117 -0
- package/src/plan/execute.ts +411 -0
- package/src/plan/index.ts +36 -0
- package/src/plan/record.ts +71 -0
- package/src/plan/targets.ts +71 -0
- package/src/{Policy.ts → policy/Policy.ts} +13 -10
- package/src/{Motion.ts → presentation/Motion.ts} +12 -46
- package/src/presentation/Presentation.ts +176 -0
- package/src/{Stage.ts → presentation/Stage.ts} +147 -112
- package/src/presentation/feed.ts +21 -0
- package/src/{Cdp.ts → providers/Cdp.ts} +2 -2
- package/src/{Chromium.ts → providers/Chromium.ts} +7 -10
- package/src/providers/Released.ts +13 -0
- package/src/{internal/cdp.ts → providers/connection.ts} +2 -2
- package/src/{internal/pictures/motion.ts → stillness/Pixels.ts} +1 -1
- package/src/stillness/Stillness.ts +166 -0
- package/src/supervisor/Supervisor.ts +170 -0
- package/src/supervisor/contract.ts +105 -0
- package/src/supervisor/lifecycle.ts +272 -0
- package/src/supervisor/runtime.ts +234 -0
- package/src/testing/TestBrowser.ts +115 -0
- package/src/testing/TestPage.ts +10 -0
- package/src/testing/evidence.ts +154 -0
- package/src/testing/index.ts +3 -0
- package/src/testing/model.ts +222 -0
- package/src/testing/page.ts +360 -0
- package/src/workerd/Cdp.ts +2 -2
- package/dist/Browser-CxXUjxOp.mjs +0 -619
- package/dist/Browser-CxXUjxOp.mjs.map +0 -1
- package/dist/Cdp-CzCRnMlM.d.mts +0 -10
- package/dist/Cdp.d.mts +0 -11
- package/dist/Cdp.mjs.map +0 -1
- package/dist/Change-DNvztNLu.mjs +0 -138
- package/dist/Change-DNvztNLu.mjs.map +0 -1
- package/dist/Chromium.mjs.map +0 -1
- package/dist/Expect-u3P_ENLX.d.mts +0 -62
- package/dist/Expect.d.mts +0 -2
- package/dist/Expect.mjs +0 -114
- package/dist/Expect.mjs.map +0 -1
- package/dist/Moment.d.mts +0 -2
- package/dist/Moment.mjs.map +0 -1
- package/dist/Motion.d.mts +0 -2
- package/dist/Motion.mjs.map +0 -1
- package/dist/Page-BP02bmNv.mjs +0 -264
- package/dist/Page-BP02bmNv.mjs.map +0 -1
- package/dist/Plan-BG1WifW2.mjs.map +0 -1
- package/dist/Plan.d.mts +0 -2
- package/dist/Plan.mjs +0 -2
- package/dist/Policy.d.mts +0 -2
- package/dist/Policy.mjs.map +0 -1
- package/dist/Presentation-DxVikn9_.d.mts +0 -48
- package/dist/Presentation.d.mts +0 -2
- package/dist/Presentation.mjs +0 -118
- package/dist/Presentation.mjs.map +0 -1
- package/dist/Stage.d.mts +0 -2
- package/dist/Stage.mjs.map +0 -1
- package/dist/Supervisor-2mPjIYYs.mjs +0 -676
- package/dist/Supervisor-2mPjIYYs.mjs.map +0 -1
- package/dist/Supervisor-CfRxbaso.d.mts +0 -317
- package/dist/Supervisor.d.mts +0 -2
- package/dist/Supervisor.mjs +0 -2
- package/dist/cdp-BMpYMWYe.mjs.map +0 -1
- package/dist/context-EGhOqjNN.mjs +0 -335
- package/dist/context-EGhOqjNN.mjs.map +0 -1
- package/dist/page-PTM8m5wC.mjs +0 -4057
- package/dist/page-PTM8m5wC.mjs.map +0 -1
- package/dist/url-Bsp2y55M.mjs +0 -264
- package/dist/url-Bsp2y55M.mjs.map +0 -1
- package/dist/workerd/index.d.mts +0 -16
- package/dist/workerd/index.mjs +0 -17
- package/src/Expect.ts +0 -180
- package/src/Plan.ts +0 -674
- package/src/Presentation.ts +0 -196
- package/src/Supervisor.ts +0 -632
- package/src/internal/supervisor/lifecycle.ts +0 -484
- package/src/workerd/index.ts +0 -17
- /package/src/{internal/page/url.ts → Url.ts} +0 -0
- /package/src/{internal/pictures → stillness}/utilsBundle.d.ts +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as BrowserError } from "./BrowserError-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
4
|
import { Context, DateTime, Duration, Effect, Option, Schema, Scope, Stream } from "effect";
|
|
5
5
|
import { BrowserContext } from "playwright-core";
|
|
6
6
|
declare namespace Browser_d_exports {
|
|
7
|
-
export { Browser$1 as Browser, CaptureSource, EventOptions, InitScript, Options, Service, SuspendOptions, Suspension, make };
|
|
7
|
+
export { Browser$1 as Browser, CaptureSource, EventOptions, InitScript, Options, RequestDecision, RequestPolicy, Service, SuspendOptions, Suspension, make };
|
|
8
8
|
}
|
|
9
9
|
/** A script that documents run before their own, such as a consent-banner remover. */
|
|
10
10
|
interface InitScript {
|
|
@@ -16,7 +16,42 @@ interface InitScript {
|
|
|
16
16
|
readonly match?: RegExp | undefined;
|
|
17
17
|
readonly source: string;
|
|
18
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
|
+
}
|
|
19
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;
|
|
20
55
|
/**
|
|
21
56
|
* Bound on each action; finite and positive. Defaults to 10 seconds. What a presenter's view
|
|
22
57
|
* takes to show an action, such as its glides and typing at a person's pace, does not count
|
|
@@ -90,15 +125,18 @@ interface Service {
|
|
|
90
125
|
readonly now: Effect.Effect<number>;
|
|
91
126
|
/** Drain admitted input and withhold new input for this scope; reads and capture continue. */
|
|
92
127
|
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
128
|
/** Open pages in the order this browser began tracking them. */
|
|
96
|
-
readonly pages: Effect.Effect<ReadonlyArray<Page
|
|
129
|
+
readonly pages: Effect.Effect<ReadonlyArray<Page>>;
|
|
97
130
|
/** 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
|
|
131
|
+
readonly page: (id: string) => Effect.Effect<Option.Option<Page>>;
|
|
99
132
|
/** The first open page, opening one when there is none. */
|
|
100
|
-
readonly firstPage: Effect.Effect<Page
|
|
101
|
-
readonly newPage: (url?: string) => Effect.Effect<Page
|
|
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>;
|
|
102
140
|
/**
|
|
103
141
|
* Completes once the browser is lost to its owner, with why: its connection dropped, its
|
|
104
142
|
* provider ended its session, or its owner's scope released it.
|
|
@@ -118,12 +156,12 @@ declare class Browser$1 extends Browser_base {}
|
|
|
118
156
|
* tab retains nothing and the context keeps none of them afterwards.
|
|
119
157
|
*/
|
|
120
158
|
declare const make: (context: BrowserContext, info: {
|
|
121
|
-
readonly id
|
|
159
|
+
readonly id?: string | undefined;
|
|
122
160
|
readonly provider: string;
|
|
123
161
|
readonly expiresAt?: DateTime.Utc | undefined;
|
|
124
162
|
/** Where pages' screencasts run, if not on each page's own session. */
|
|
125
163
|
readonly capture?: CaptureSource | undefined;
|
|
126
164
|
}, options?: Options | undefined) => Effect.Effect<Service, BrowserError, Scope.Scope>;
|
|
127
165
|
//#endregion
|
|
128
|
-
export { InitScript as a,
|
|
129
|
-
//# sourceMappingURL=Browser-
|
|
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
|
package/dist/Browser.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as InitScript, c as
|
|
2
|
-
export { Browser, CaptureSource, EventOptions, InitScript, Options, Service, SuspendOptions, Suspension, make };
|
|
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-
|
|
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
|
|
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
|
|
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,
|
|
140
|
-
//# sourceMappingURL=BrowserError-
|
|
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
|
package/dist/BrowserError.d.mts
CHANGED
|
@@ -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
|
|
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 };
|
package/dist/BrowserError.mjs
CHANGED
|
@@ -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
|
-
|
|
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 "
|
|
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,C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S,OAAO,MAAM;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAID,IAAa,eAAb,cAAkC,OAAO,YAA0B,CAAC,CAAC,gBAAgB;CACnF,WAAW,OAAO;CAClB,QAAQ;CACR,YAAY,OAAO;AACrB,CAAC,CAAC,CAAC;CACD,IAAa,UAAU;EACrB,OAAO,GAAG,KAAK,UAAU,SAAS,KAAK,aAAa,uBAAuB,GAAG,IAAI,KAAK,OAAO;CAChG;AACF;;AAgBA,MAAa,eAAe,EAAE,QAAQ,iBAA4C;CAChF,MAAM,SAAS,aAAa,UAAU;CAEtC,QAAQ,OAAO,MAAf;EACE,KAAK,UACH,OAAO;GACL,MAAM,OAAO,UAAU,UAAU,OAAO,UAAU,YAAY,SAAS;GACvE;EACF;EACF,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,oBACH,OAAO;GAAE,MAAM;GAAW;EAAO;EACnC,KAAK,uBACH,OAAO;GAAE,MAAM;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;;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BAAiB,QAAQ,MAAM,UAAU,OAAO,UAAU,WAAW,QAAQ;CAE/E,IACE,yGAAyG,KACvG,OACF,GAEA,OAAO,IAAI,OAAO,EAAE,OAAO,OAAO,CAAC;CACrC,IAAI,iBAAiB,SAAS,MAAM,SAAS,kBAAkB,kBAAkB,KAAA,GAC/E,OAAO,IAAI,QAAQ,EAAE,QAAQ,cAAc,CAAC;CAG9C,OAAO,IAAI,OAAO,EAAE,SAFP,OAAO,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,gBAEnB,CAAK,QAAQ,aAAa,EAAE,EAAE,CAAC;AAC7D;;AAGA,MAAa,QACX,WACA,KACA,UACA,kBAEA,OAAO,WAAW;CAChB,KAAK;CACL,QAAQ,UAAU,aAAa,WAAW,SAAS,OAAO,eAAe,SAAS,CAAC,CAAC;AACtF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
declare namespace BrowserEvent_d_exports {
|
|
3
|
-
export { Action,
|
|
3
|
+
export { Action, Box, BrowserEvent, CursorChanged, DialogShown, DisconnectCause, Disconnected, KeyChanged, Navigated, PageClosed, PageLoaded, PageOpened, PageUntracked, PointerPressed, PointerReleased, RecordedEvent, RequestRefused, SessionEnding, Subject, SubjectContext, TextInserted, TrackEvent, TrackPerformed, TrackPlanned, WheelScrolled };
|
|
4
4
|
}
|
|
5
5
|
declare const PageOpened_base: Schema.Class<PageOpened, Schema.TaggedStruct<"PageOpened", {
|
|
6
6
|
readonly at: Schema.Finite;
|
|
@@ -112,43 +112,84 @@ declare const Box: Schema.Struct<{
|
|
|
112
112
|
readonly height: Schema.Finite;
|
|
113
113
|
}>;
|
|
114
114
|
type Box = typeof Box.Type;
|
|
115
|
-
/**
|
|
116
|
-
* What else an action was asked, where it changes what the action does: a click's button, count
|
|
117
|
-
* and hold, how `type` enters its text, how often and how long `press` holds its keys, how far
|
|
118
|
-
* `scroll` moves, and the options `select` chose. Only a completed action records them.
|
|
119
|
-
*/
|
|
120
|
-
declare const ActionOptions: Schema.Struct<{
|
|
121
|
-
readonly button: Schema.optional<Schema.Literals<readonly ["left", "right", "middle"]>>;
|
|
122
|
-
readonly clickCount: Schema.optional<Schema.Finite>;
|
|
123
|
-
readonly holdMillis: Schema.optional<Schema.Finite>;
|
|
124
|
-
readonly replace: Schema.optional<Schema.Boolean>;
|
|
125
|
-
readonly submit: Schema.optional<Schema.Boolean>;
|
|
126
|
-
readonly times: Schema.optional<Schema.Finite>;
|
|
127
|
-
readonly dx: Schema.optional<Schema.Finite>;
|
|
128
|
-
readonly dy: Schema.optional<Schema.Finite>;
|
|
129
|
-
readonly values: Schema.optional<Schema.$Array<Schema.String>>;
|
|
130
|
-
}>;
|
|
131
|
-
type ActionOptions = typeof ActionOptions.Type;
|
|
132
115
|
declare const Action_base: Schema.Class<Action, Schema.TaggedStruct<"Action", {
|
|
133
116
|
readonly at: Schema.Finite;
|
|
134
117
|
readonly startedAt: Schema.Finite;
|
|
135
118
|
readonly page: Schema.String;
|
|
136
|
-
readonly name: Schema.
|
|
119
|
+
readonly name: Schema.Literals<readonly ["click", "hover", "drag", "type", "press", "scroll", "select", "navigate", "back", "reload", "act"]>;
|
|
120
|
+
/** The decoded call, with secrets removed before publication. */
|
|
121
|
+
readonly value: Schema.TaggedUnion<{
|
|
122
|
+
readonly Act: Schema.TaggedStruct<"Act", {
|
|
123
|
+
readonly document: Schema.Int;
|
|
124
|
+
}>;
|
|
125
|
+
readonly Back: Schema.TaggedStruct<"Back", {}>;
|
|
126
|
+
readonly Click: Schema.TaggedStruct<"Click", {
|
|
127
|
+
readonly target: Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
128
|
+
readonly x: Schema.Finite;
|
|
129
|
+
readonly y: Schema.Finite;
|
|
130
|
+
}>]>;
|
|
131
|
+
readonly options: Schema.optional<Schema.Struct<{
|
|
132
|
+
readonly button: Schema.optional<Schema.Literals<readonly ["left", "right", "middle"]>>;
|
|
133
|
+
readonly clickCount: Schema.optional<Schema.Finite>;
|
|
134
|
+
readonly holdMillis: Schema.optional<Schema.Finite>;
|
|
135
|
+
}>>;
|
|
136
|
+
}>;
|
|
137
|
+
readonly Drag: Schema.TaggedStruct<"Drag", {
|
|
138
|
+
readonly from: Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
139
|
+
readonly x: Schema.Finite;
|
|
140
|
+
readonly y: Schema.Finite;
|
|
141
|
+
}>]>;
|
|
142
|
+
readonly to: Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
143
|
+
readonly x: Schema.Finite;
|
|
144
|
+
readonly y: Schema.Finite;
|
|
145
|
+
}>]>;
|
|
146
|
+
}>;
|
|
147
|
+
readonly Goto: Schema.TaggedStruct<"Goto", {
|
|
148
|
+
readonly url: Schema.String;
|
|
149
|
+
}>;
|
|
150
|
+
readonly Hover: Schema.TaggedStruct<"Hover", {
|
|
151
|
+
readonly target: Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
152
|
+
readonly x: Schema.Finite;
|
|
153
|
+
readonly y: Schema.Finite;
|
|
154
|
+
}>]>;
|
|
155
|
+
}>;
|
|
156
|
+
readonly Press: Schema.TaggedStruct<"Press", {
|
|
157
|
+
readonly keys: Schema.String;
|
|
158
|
+
readonly options: Schema.optional<Schema.Struct<{
|
|
159
|
+
readonly on: Schema.optional<Schema.String>;
|
|
160
|
+
readonly times: Schema.optional<Schema.Finite>;
|
|
161
|
+
readonly holdMillis: Schema.optional<Schema.Finite>;
|
|
162
|
+
}>>;
|
|
163
|
+
}>;
|
|
164
|
+
readonly Reload: Schema.TaggedStruct<"Reload", {}>;
|
|
165
|
+
readonly Scroll: Schema.TaggedStruct<"Scroll", {
|
|
166
|
+
readonly options: Schema.optional<Schema.Struct<{
|
|
167
|
+
readonly at: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
168
|
+
readonly x: Schema.Finite;
|
|
169
|
+
readonly y: Schema.Finite;
|
|
170
|
+
}>]>>;
|
|
171
|
+
readonly dx: Schema.optional<Schema.Finite>;
|
|
172
|
+
readonly dy: Schema.optional<Schema.Finite>;
|
|
173
|
+
}>>;
|
|
174
|
+
}>;
|
|
175
|
+
readonly Select: Schema.TaggedStruct<"Select", {
|
|
176
|
+
readonly ref: Schema.String;
|
|
177
|
+
readonly values: Schema.$Array<Schema.String>;
|
|
178
|
+
}>;
|
|
179
|
+
readonly Type: Schema.TaggedStruct<"Type", {
|
|
180
|
+
readonly text: Schema.String;
|
|
181
|
+
readonly options: Schema.optional<Schema.Struct<{
|
|
182
|
+
readonly into: Schema.optional<Schema.String>;
|
|
183
|
+
readonly replace: Schema.optional<Schema.Boolean>;
|
|
184
|
+
readonly submit: Schema.optional<Schema.Boolean>;
|
|
185
|
+
readonly secret: Schema.optional<Schema.Boolean>;
|
|
186
|
+
}>>;
|
|
187
|
+
}>;
|
|
188
|
+
}>;
|
|
137
189
|
/** The address when the action ended; absent in events recorded by older releases. */
|
|
138
190
|
readonly url: Schema.optional<Schema.String>;
|
|
139
191
|
readonly correlation: Schema.optional<Schema.String>;
|
|
140
192
|
readonly target: Schema.optional<Schema.String>;
|
|
141
|
-
readonly options: Schema.optional<Schema.Struct<{
|
|
142
|
-
readonly button: Schema.optional<Schema.Literals<readonly ["left", "right", "middle"]>>;
|
|
143
|
-
readonly clickCount: Schema.optional<Schema.Finite>;
|
|
144
|
-
readonly holdMillis: Schema.optional<Schema.Finite>;
|
|
145
|
-
readonly replace: Schema.optional<Schema.Boolean>;
|
|
146
|
-
readonly submit: Schema.optional<Schema.Boolean>;
|
|
147
|
-
readonly times: Schema.optional<Schema.Finite>;
|
|
148
|
-
readonly dx: Schema.optional<Schema.Finite>;
|
|
149
|
-
readonly dy: Schema.optional<Schema.Finite>;
|
|
150
|
-
readonly values: Schema.optional<Schema.$Array<Schema.String>>;
|
|
151
|
-
}>>;
|
|
152
193
|
readonly subject: Schema.optional<typeof Subject>;
|
|
153
194
|
readonly to: Schema.optional<typeof Subject>;
|
|
154
195
|
/** For an action at a point, the box of what it found there. */
|
|
@@ -167,7 +208,7 @@ declare const Action_base: Schema.Class<Action, Schema.TaggedStruct<"Action", {
|
|
|
167
208
|
}>, {}>;
|
|
168
209
|
/**
|
|
169
210
|
* One page operation ended, including one its caller interrupted (`error: "interrupted"`).
|
|
170
|
-
* `
|
|
211
|
+
* `value` is the decoded call. `target` is its short rendering for observers.
|
|
171
212
|
* `subject` is what an element or point action found there, and `to` where a drag ended; an
|
|
172
213
|
* action that failed before finding its target has neither. Point actions carry the viewport
|
|
173
214
|
* point they used. `correlation` is the id its caller gave it with `Page.correlate`, such as a
|
|
@@ -259,21 +300,36 @@ declare const DialogShown_base: Schema.Class<DialogShown, Schema.TaggedStruct<"D
|
|
|
259
300
|
readonly page: Schema.String;
|
|
260
301
|
readonly kind: Schema.String;
|
|
261
302
|
readonly message: Schema.String;
|
|
262
|
-
readonly answer: Schema.Literals<readonly ["accepted", "dismissed"]>;
|
|
303
|
+
readonly answer: Schema.Literals<readonly ["accepted", "dismissed", "failed"]>;
|
|
263
304
|
}>, {}>;
|
|
264
305
|
/**
|
|
265
|
-
* A JavaScript dialog appeared
|
|
306
|
+
* A JavaScript dialog appeared; its completed answer, or a failed response: an alert or a leave-page prompt accepted, a
|
|
266
307
|
* confirm or a prompt dismissed, as if its Cancel were pressed.
|
|
267
308
|
*/
|
|
268
309
|
declare class DialogShown extends DialogShown_base {}
|
|
269
|
-
declare const
|
|
310
|
+
declare const RequestRefused_base: Schema.Class<RequestRefused, Schema.TaggedStruct<"RequestRefused", {
|
|
311
|
+
readonly at: Schema.Finite;
|
|
312
|
+
readonly page: Schema.optional<Schema.String>;
|
|
313
|
+
readonly method: Schema.String;
|
|
314
|
+
readonly url: Schema.String;
|
|
315
|
+
readonly reason: Schema.String;
|
|
316
|
+
/** Safe structured diagnosis; arbitrary policy error details and causes stay private. */
|
|
317
|
+
readonly failure: Schema.optional<Schema.Struct<{
|
|
318
|
+
readonly reason: Schema.String;
|
|
319
|
+
readonly timeoutMillis: Schema.optional<Schema.Finite>;
|
|
320
|
+
}>>;
|
|
321
|
+
}>, {}>;
|
|
322
|
+
/** A context policy refused traffic; page is present only when its containing page was established.
|
|
323
|
+
* Worker and out-of-process iframe requests may omit it while retaining proven context ownership. */
|
|
324
|
+
declare class RequestRefused extends RequestRefused_base {}
|
|
325
|
+
declare const BrowserEvent: Schema.Union<readonly [typeof RequestRefused, 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]>;
|
|
270
326
|
type BrowserEvent = typeof BrowserEvent.Type;
|
|
271
327
|
declare const RecordedEvent_base: Schema.Class<RecordedEvent, Schema.Struct<{
|
|
272
328
|
readonly sequence: Schema.Int;
|
|
273
|
-
readonly event: 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]>;
|
|
329
|
+
readonly event: Schema.Union<readonly [typeof RequestRefused, 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]>;
|
|
274
330
|
}>, {}>;
|
|
275
331
|
/** A position in the browser's one replayable event history. Sequences begin at one. */
|
|
276
332
|
declare class RecordedEvent extends RecordedEvent_base {}
|
|
277
333
|
//#endregion
|
|
278
|
-
export { TrackEvent as C, WheelScrolled as E, TextInserted as S, TrackPlanned as T,
|
|
279
|
-
//# sourceMappingURL=BrowserEvent-
|
|
334
|
+
export { TrackEvent as C, WheelScrolled as E, TextInserted as S, TrackPlanned as T, RecordedEvent as _, CursorChanged as a, Subject as b, Disconnected as c, PageClosed as d, PageLoaded as f, PointerReleased as g, PointerPressed as h, BrowserEvent_d_exports as i, KeyChanged as l, PageUntracked as m, Box as n, DialogShown as o, PageOpened as p, BrowserEvent as r, DisconnectCause as s, Action as t, Navigated as u, RequestRefused as v, TrackPerformed as w, SubjectContext as x, SessionEnding as y };
|
|
335
|
+
//# sourceMappingURL=BrowserEvent-lLqJ3GJS.d.mts.map
|
package/dist/BrowserEvent.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as TrackEvent, E as WheelScrolled, S as TextInserted, T as TrackPlanned, _ as
|
|
2
|
-
export { Action,
|
|
1
|
+
import { C as TrackEvent, E as WheelScrolled, S as TextInserted, T as TrackPlanned, _ as RecordedEvent, a as CursorChanged, b as Subject, c as Disconnected, d as PageClosed, f as PageLoaded, g as PointerReleased, h as PointerPressed, l as KeyChanged, m as PageUntracked, n as Box, o as DialogShown, p as PageOpened, r as BrowserEvent, s as DisconnectCause, t as Action, u as Navigated, v as RequestRefused, w as TrackPerformed, x as SubjectContext, y as SessionEnding } from "./BrowserEvent-lLqJ3GJS.mjs";
|
|
2
|
+
export { Action, Box, BrowserEvent, CursorChanged, DialogShown, DisconnectCause, Disconnected, KeyChanged, Navigated, PageClosed, PageLoaded, PageOpened, PageUntracked, PointerPressed, PointerReleased, RecordedEvent, RequestRefused, SessionEnding, Subject, SubjectContext, TextInserted, TrackEvent, TrackPerformed, TrackPlanned, WheelScrolled };
|