effect-browser 0.3.0-beta.24 → 0.3.0-beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +333 -157
- package/dist/Action.d.mts +1 -1
- package/dist/Action.mjs +61 -9
- package/dist/Action.mjs.map +1 -1
- package/dist/Browser.d.mts +2 -2
- package/dist/Browser.mjs +2 -2
- package/dist/BrowserError.d.mts +2 -2
- package/dist/BrowserError.mjs +194 -41
- package/dist/BrowserError.mjs.map +1 -1
- package/dist/BrowserEvent.d.mts +1 -1
- package/dist/BrowserEvent.mjs +166 -35
- package/dist/BrowserEvent.mjs.map +1 -1
- package/dist/Cdp.d.mts +15 -0
- package/dist/Cdp.mjs +22 -0
- package/dist/Cdp.mjs.map +1 -0
- package/dist/Change.d.mts +2 -2
- package/dist/Change.mjs +33 -6
- package/dist/Change.mjs.map +1 -1
- package/dist/Frame.d.mts +2 -2
- package/dist/Frame.mjs +132 -14
- package/dist/Frame.mjs.map +1 -1
- package/dist/{Style.d.mts → InputStyle.d.mts} +93 -25
- package/dist/{Style.mjs → InputStyle.mjs} +1 -1
- package/dist/Layout.d.mts +2 -2
- package/dist/Layout.mjs +58 -16
- package/dist/Layout.mjs.map +1 -1
- package/dist/Overlay.d.mts +2 -2
- package/dist/Overlay.mjs +33 -5
- package/dist/Overlay.mjs.map +1 -1
- package/dist/Page.d.mts +2 -2
- package/dist/Page.mjs +2 -2
- package/dist/PageTime.d.mts +2 -2
- package/dist/PageTime.mjs +13 -3
- package/dist/PageTime.mjs.map +1 -1
- package/dist/Pose.d.mts +2 -2
- package/dist/Pose.mjs +30 -9
- package/dist/Pose.mjs.map +1 -1
- package/dist/Site.d.mts +288 -18
- package/dist/Site.mjs +11 -3
- package/dist/Site.mjs.map +1 -1
- package/dist/Snapshot.d.mts +2 -2
- package/dist/Snapshot.mjs +87 -6
- package/dist/Snapshot.mjs.map +1 -1
- package/dist/Text.d.mts +2 -0
- package/dist/Text.mjs +45 -0
- package/dist/Text.mjs.map +1 -0
- package/dist/Window.d.mts +2 -2
- package/dist/Window.mjs +31 -6
- package/dist/Window.mjs.map +1 -1
- package/dist/ai/BrowserTools.d.mts +4987 -0
- package/dist/ai/BrowserTools.mjs +3 -0
- package/dist/ai/PageControl.d.mts +286 -0
- package/dist/ai/PageControl.mjs +426 -0
- package/dist/ai/PageControl.mjs.map +1 -0
- package/dist/ai/PromptCache.d.mts +16 -0
- package/dist/ai/PromptCache.mjs +72 -0
- package/dist/ai/PromptCache.mjs.map +1 -0
- package/dist/ai/Tabs.d.mts +2 -0
- package/dist/ai/Tabs.mjs +72 -0
- package/dist/ai/Tabs.mjs.map +1 -0
- package/dist/ai/ToolError.d.mts +34 -0
- package/dist/ai/ToolError.mjs +2 -0
- package/dist/ai/index.d.mts +6 -0
- package/dist/ai/index.mjs +6 -0
- package/dist/index.d.mts +7 -18
- package/dist/index.mjs +6 -9
- package/dist/{Action-24sLOubi.d.mts → internal/Action-CkanNTUw.d.mts} +64 -4
- package/dist/{Browser-DGR6ZEYo.d.mts → internal/Browser-DD9Vm1c-.d.mts} +75 -11
- package/dist/{Browser-CAQFhTkM.mjs → internal/Browser-vzD7i2oj.mjs} +174 -237
- package/dist/internal/Browser-vzD7i2oj.mjs.map +1 -0
- package/dist/{BrowserError-BlcmLVzn.d.mts → internal/BrowserError-CsuRYcDX.d.mts} +187 -28
- package/dist/{BrowserEvent-C2p-NwuU.d.mts → internal/BrowserEvent-tGPYYf6R.d.mts} +168 -13
- package/dist/internal/BrowserTools-Yi3lOX4h.mjs +497 -0
- package/dist/internal/BrowserTools-Yi3lOX4h.mjs.map +1 -0
- package/dist/{Style-T3ezDYLI.mjs → internal/InputStyle-CPzxoN4g.mjs} +75 -20
- package/dist/internal/InputStyle-CPzxoN4g.mjs.map +1 -0
- package/dist/{moment/Moment.mjs → internal/Moment-CstaX1mR.mjs} +49 -16
- package/dist/internal/Moment-CstaX1mR.mjs.map +1 -0
- package/dist/{moment/Moment.d.mts → internal/Moment-DOcldBdf.d.mts} +53 -20
- package/dist/internal/Page-BfGxn7oN.d.mts +1553 -0
- package/dist/{Page-BaAOshxo.mjs → internal/Page-DqF-tuTx.mjs} +62 -74
- package/dist/internal/Page-DqF-tuTx.mjs.map +1 -0
- package/dist/internal/Release-CFONkPDP.d.mts +39 -0
- package/dist/internal/Stage-D5ymSXDT.mjs +298 -0
- package/dist/internal/Stage-D5ymSXDT.mjs.map +1 -0
- package/dist/internal/Stillness-DCPeAN1a.mjs +1124 -0
- package/dist/internal/Stillness-DCPeAN1a.mjs.map +1 -0
- package/dist/internal/Supervisor-BcY_QNIY.d.mts +108 -0
- package/dist/internal/Supervisor-BcglY23c.mjs +531 -0
- package/dist/internal/Supervisor-BcglY23c.mjs.map +1 -0
- package/dist/internal/Tabs-dXMscIUQ.d.mts +52 -0
- package/dist/internal/TestPage-CYiYbh63.d.mts +159 -0
- package/dist/internal/ToolError-DArsRS2m.mjs +117 -0
- package/dist/internal/ToolError-DArsRS2m.mjs.map +1 -0
- package/dist/{plan/index.d.mts → internal/Walk-BNXcfZ2z.d.mts} +59 -35
- package/dist/{plan/index.mjs → internal/Walk-C5ky7uSf.mjs} +83 -51
- package/dist/internal/Walk-C5ky7uSf.mjs.map +1 -0
- package/dist/{ActionPort.mjs → internal/action-port-B5EkeGOR.mjs} +6 -12
- package/dist/internal/action-port-B5EkeGOR.mjs.map +1 -0
- package/dist/internal/cdp/workerd.d.mts +13 -0
- package/dist/internal/cdp/workerd.mjs +19 -0
- package/dist/internal/cdp/workerd.mjs.map +1 -0
- package/dist/{Clock.mjs → internal/clock-BKSAEf00.mjs} +13 -13
- package/dist/internal/clock-BKSAEf00.mjs.map +1 -0
- package/dist/{connection-Db-YtlbE.d.mts → internal/connection-BaB0vp1o.d.mts} +6 -6
- package/dist/{connection-C_jWYIwe.mjs → internal/connection-C2X4GmXM.mjs} +19 -15
- package/dist/internal/connection-C2X4GmXM.mjs.map +1 -0
- package/dist/internal/events-DzCrww-y.mjs +72 -0
- package/dist/internal/events-DzCrww-y.mjs.map +1 -0
- package/dist/internal/fold.inpage-uhrT-dOB.mjs +49 -0
- package/dist/internal/fold.inpage-uhrT-dOB.mjs.map +1 -0
- package/dist/internal/functions-jBOs6GKv.mjs +27 -0
- package/dist/internal/functions-jBOs6GKv.mjs.map +1 -0
- package/dist/{Geometry-DJx9qrYy.d.mts → internal/geometry-Dhj_ztJs.d.mts} +3 -3
- package/dist/{Geometry.mjs → internal/geometry-Lxyflb9J.mjs} +3 -12
- package/dist/internal/geometry-Lxyflb9J.mjs.map +1 -0
- package/dist/{Matching.mjs → internal/matching-Cs-UeOY0.mjs} +3 -3
- package/dist/internal/matching-Cs-UeOY0.mjs.map +1 -0
- package/dist/internal/page-DFQb-YOK.mjs +436 -0
- package/dist/internal/page-DFQb-YOK.mjs.map +1 -0
- package/dist/{pose.inpage-CLq7Mfdr.mjs → internal/pose.inpage-CBFeWcVa.mjs} +2 -48
- package/dist/internal/pose.inpage-CBFeWcVa.mjs.map +1 -0
- package/dist/{Url.mjs → internal/url-DB0pQYk6.mjs} +3 -12
- package/dist/internal/url-DB0pQYk6.mjs.map +1 -0
- package/dist/policy/Policy.d.mts +60 -6
- package/dist/policy/Policy.mjs +52 -9
- package/dist/policy/Policy.mjs.map +1 -1
- package/dist/policy/index.d.mts +2 -0
- package/dist/policy/index.mjs +2 -0
- package/dist/{film → presentation}/Film.d.mts +83 -16
- package/dist/{film → presentation}/Film.mjs +82 -30
- package/dist/presentation/Film.mjs.map +1 -0
- package/dist/presentation/Motion.d.mts +5 -1
- package/dist/presentation/Motion.mjs +16 -2
- package/dist/presentation/Motion.mjs.map +1 -1
- package/dist/presentation/Presentation.d.mts +42 -7
- package/dist/presentation/Presentation.mjs +26 -9
- package/dist/presentation/Presentation.mjs.map +1 -1
- package/dist/presentation/Stage.d.mts +40 -6
- package/dist/presentation/Stage.mjs +1 -262
- package/dist/presentation/index.d.mts +5 -0
- package/dist/presentation/index.mjs +5 -0
- package/dist/supervisor/Release.d.mts +2 -0
- package/dist/supervisor/Release.mjs +40 -0
- package/dist/supervisor/Release.mjs.map +1 -0
- package/dist/supervisor/Supervisor.d.mts +2 -104
- package/dist/supervisor/Supervisor.mjs +2 -515
- package/dist/supervisor/index.d.mts +3 -0
- package/dist/supervisor/index.mjs +3 -0
- package/dist/testing/HttpCassette.d.mts +98 -0
- package/dist/testing/HttpCassette.mjs +146 -0
- package/dist/testing/HttpCassette.mjs.map +1 -0
- package/dist/testing/Story.d.mts +31 -0
- package/dist/testing/Story.mjs +76 -0
- package/dist/testing/Story.mjs.map +1 -0
- package/dist/testing/TestBrowser.d.mts +191 -0
- package/dist/testing/TestBrowser.mjs +105 -0
- package/dist/testing/TestBrowser.mjs.map +1 -0
- package/dist/testing/TestModel.d.mts +133 -0
- package/dist/testing/TestModel.mjs +209 -0
- package/dist/testing/TestModel.mjs.map +1 -0
- package/dist/testing/TestPage.d.mts +2 -0
- package/dist/testing/TestPage.mjs +47 -0
- package/dist/testing/TestPage.mjs.map +1 -0
- package/dist/testing/index.d.mts +6 -311
- package/dist/testing/index.mjs +6 -521
- package/dist/timeline/Moment.d.mts +3 -0
- package/dist/timeline/Moment.mjs +3 -0
- package/dist/timeline/Stillness.d.mts +34 -0
- package/dist/timeline/Stillness.mjs +2 -0
- package/dist/timeline/index.d.mts +3 -0
- package/dist/timeline/index.mjs +3 -0
- package/dist/walk/Walk.d.mts +2 -0
- package/dist/walk/Walk.mjs +2 -0
- package/dist/walk/index.d.mts +2 -0
- package/dist/walk/index.mjs +2 -0
- package/package.json +54 -163
- package/src/Action.ts +73 -8
- package/src/Browser.ts +75 -9
- package/src/BrowserError.ts +258 -63
- package/src/BrowserEvent.ts +252 -55
- package/src/Cdp.ts +42 -0
- package/src/Change.ts +68 -3
- package/src/Frame.ts +247 -14
- package/src/{Style.ts → InputStyle.ts} +98 -22
- package/src/Layout.ts +95 -24
- package/src/Overlay.ts +42 -3
- package/src/Page.ts +144 -320
- package/src/PageTime.ts +29 -4
- package/src/Pose.ts +38 -7
- package/src/Site.ts +15 -3
- package/src/Snapshot.ts +179 -3
- package/src/Text.ts +60 -0
- package/src/Window.ts +53 -3
- package/src/ai/BrowserTools.ts +778 -0
- package/src/ai/PageControl.ts +702 -0
- package/src/ai/PromptCache.ts +87 -0
- package/src/ai/Tabs.ts +84 -0
- package/src/ai/ToolError.ts +50 -0
- package/src/ai/index.ts +36 -0
- package/src/ai/internal/crops.ts +38 -0
- package/src/ai/internal/points.ts +57 -0
- package/src/ai/internal/receipts.ts +107 -0
- package/src/index.ts +83 -6
- package/src/{ActionPort.ts → internal/action-port.ts} +3 -3
- package/src/{providers → internal/cdp}/connection.ts +19 -12
- package/src/internal/cdp/workerd.ts +36 -0
- package/src/{Clock.ts → internal/clock.ts} +20 -0
- package/src/internal/input/actions.ts +1 -1
- package/src/internal/input/dispatch.ts +2 -2
- package/src/internal/input/guard.inpage.ts +1 -1
- package/src/internal/input/guard.ts +1 -1
- package/src/internal/input/perform.ts +5 -5
- package/src/internal/input/pointer.ts +2 -2
- package/src/internal/input/targets.inpage.ts +3 -3
- package/src/{Matching.ts → internal/matching.ts} +6 -6
- package/src/internal/page/bridge.ts +2 -2
- package/src/internal/page/clock.inpage.ts +1 -1
- package/src/internal/page/compose.inpage.ts +2 -2
- package/src/internal/page/context.ts +2 -2
- package/src/internal/page/functions.ts +84 -0
- package/src/internal/page/navigation.ts +1 -1
- package/src/internal/page/openings.ts +2 -2
- package/src/internal/page/page.ts +33 -35
- package/src/internal/page/port.ts +14 -8
- package/src/internal/page/replies.ts +1 -1
- package/src/internal/page/requests.ts +1 -1
- package/src/internal/page/scripts.ts +1 -1
- package/src/internal/page/time.ts +1 -1
- package/src/internal/pictures/capture.ts +1 -4
- package/src/internal/pictures/dimensions.ts +1 -1
- package/src/internal/pictures/frame.ts +1 -1
- package/src/internal/pictures/pictures.ts +53 -61
- package/src/internal/reading/context.inpage.ts +2 -2
- package/src/internal/reading/expect.inpage.ts +1 -1
- package/src/internal/reading/layout.inpage.ts +3 -3
- package/src/internal/reading/layout.ts +5 -5
- package/src/internal/reading/outline.inpage.ts +3 -3
- package/src/internal/reading/reading.ts +11 -19
- package/src/internal/reading/ready.inpage.ts +2 -2
- package/src/internal/reading/ready.ts +3 -2
- package/src/internal/reading/subjects.inpage.ts +3 -3
- package/src/internal/reading/text.inpage.ts +2 -2
- package/src/internal/reading/walk.inpage.ts +1 -1
- package/src/internal/timeline/changes.inpage.ts +2 -2
- package/src/internal/timeline/changes.ts +3 -4
- package/src/internal/timeline/sight.inpage.ts +2 -2
- package/src/internal/timeline/window.ts +3 -4
- package/src/policy/Policy.ts +70 -16
- package/src/policy/index.ts +12 -0
- package/src/{film → presentation}/Film.ts +104 -37
- package/src/presentation/Motion.ts +45 -3
- package/src/presentation/Presentation.ts +47 -14
- package/src/presentation/Stage.ts +73 -35
- package/src/presentation/index.ts +30 -0
- package/src/presentation/{feed.ts → internal/feed.ts} +1 -1
- package/src/supervisor/Release.ts +45 -0
- package/src/supervisor/Supervisor.ts +80 -5
- package/src/supervisor/index.ts +18 -0
- package/src/supervisor/{contract.ts → internal/contract.ts} +14 -10
- package/src/supervisor/{lifecycle.ts → internal/lifecycle.ts} +7 -7
- package/src/supervisor/{runtime.ts → internal/runtime.ts} +7 -7
- package/src/testing/HttpCassette.ts +260 -0
- package/src/testing/Story.ts +103 -0
- package/src/testing/TestBrowser.ts +14 -4
- package/src/testing/TestModel.ts +297 -0
- package/src/testing/TestPage.ts +92 -4
- package/src/testing/index.ts +35 -1
- package/src/testing/{evidence.ts → internal/evidence.ts} +19 -11
- package/src/testing/{model.ts → internal/model.ts} +14 -8
- package/src/testing/{page.ts → internal/page.ts} +55 -56
- package/src/{moment → timeline}/Moment.ts +79 -29
- package/src/{stillness → timeline}/Stillness.ts +61 -43
- package/src/timeline/index.ts +18 -0
- package/src/{stillness/Pixels.ts → timeline/internal/pixels.ts} +2 -2
- package/src/{moment → timeline/internal}/words.ts +2 -2
- package/src/walk/Walk.ts +165 -0
- package/src/walk/index.ts +12 -0
- package/src/{plan → walk/internal}/choose.ts +23 -14
- package/src/{plan → walk/internal}/data.ts +37 -14
- package/src/{plan → walk/internal}/execute.ts +79 -36
- package/src/{plan → walk/internal}/record.ts +6 -6
- package/src/{plan → walk/internal}/targets.ts +35 -25
- package/dist/ActionPort.d.mts +0 -15
- package/dist/ActionPort.mjs.map +0 -1
- package/dist/Browser-CAQFhTkM.mjs.map +0 -1
- package/dist/Change-CxT1mp2e.d.mts +0 -80
- package/dist/Clock-Du5nP-nK.d.mts +0 -57
- package/dist/Clock.d.mts +0 -2
- package/dist/Clock.mjs.map +0 -1
- package/dist/Frame-UEH2hO5T.d.mts +0 -124
- package/dist/Geometry.d.mts +0 -2
- package/dist/Geometry.mjs.map +0 -1
- package/dist/Matching-MtcWZ_hA.d.mts +0 -266
- package/dist/Matching.d.mts +0 -2
- package/dist/Matching.mjs.map +0 -1
- package/dist/Overlay-CoGw5tL_.d.mts +0 -27
- package/dist/Page-BaAOshxo.mjs.map +0 -1
- package/dist/Page-CLzh5E9w.d.mts +0 -718
- package/dist/PageTime-68UPUZpZ.d.mts +0 -29
- package/dist/Pose-2qqGzPvb.d.mts +0 -32
- package/dist/Released-tURbFmal.d.mts +0 -15
- package/dist/Snapshot-CtBVOtuu.d.mts +0 -73
- package/dist/Stillness-BwP0RdI4.mjs +0 -157
- package/dist/Stillness-BwP0RdI4.mjs.map +0 -1
- package/dist/Style-T3ezDYLI.mjs.map +0 -1
- package/dist/Url-B7P-TWwL.d.mts +0 -26
- package/dist/Url.d.mts +0 -2
- package/dist/Url.mjs.map +0 -1
- package/dist/Window-BDa8MtNP.d.mts +0 -34
- package/dist/connection-C_jWYIwe.mjs.map +0 -1
- package/dist/film/Film.mjs.map +0 -1
- package/dist/moment/Moment.mjs.map +0 -1
- package/dist/plan/index.mjs.map +0 -1
- package/dist/pose.inpage-CLq7Mfdr.mjs.map +0 -1
- package/dist/presentation/Stage.mjs.map +0 -1
- package/dist/presentation/feed.d.mts +0 -20
- package/dist/presentation/feed.mjs +0 -18
- package/dist/presentation/feed.mjs.map +0 -1
- package/dist/providers/Cdp.d.mts +0 -9
- package/dist/providers/Cdp.mjs +0 -15
- package/dist/providers/Cdp.mjs.map +0 -1
- package/dist/providers/Chromium.d.mts +0 -32
- package/dist/providers/Chromium.mjs +0 -55
- package/dist/providers/Chromium.mjs.map +0 -1
- package/dist/providers/Released.d.mts +0 -2
- package/dist/providers/Released.mjs +0 -12
- package/dist/providers/Released.mjs.map +0 -1
- package/dist/stillness/Stillness.d.mts +0 -12
- package/dist/stillness/Stillness.mjs +0 -2
- package/dist/supervisor/Supervisor.mjs.map +0 -1
- package/dist/testing/index.mjs.map +0 -1
- package/dist/workerd/Cdp.d.mts +0 -8
- package/dist/workerd/Cdp.mjs +0 -13
- package/dist/workerd/Cdp.mjs.map +0 -1
- package/src/plan/index.ts +0 -36
- package/src/providers/Cdp.ts +0 -16
- package/src/providers/Chromium.ts +0 -99
- package/src/providers/Released.ts +0 -13
- package/src/workerd/Cdp.ts +0 -11
- /package/dist/{fold.inpage-CyVZQHZL.d.mts → internal/fold.inpage-CyVZQHZL.d.mts} +0 -0
- /package/dist/{rolldown-runtime-D7D4PA-g.mjs → internal/rolldown-runtime-D7D4PA-g.mjs} +0 -0
- /package/src/{Geometry.ts → internal/geometry.ts} +0 -0
- /package/src/{Url.ts → internal/url.ts} +0 -0
- /package/src/{stillness → timeline/internal}/utilsBundle.d.ts +0 -0
|
@@ -1,27 +1,41 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Screen and foreground stillness over the public page capture and owning clock.
|
|
3
|
+
*
|
|
4
|
+
* @stability stable
|
|
5
|
+
* @since 0.3.0
|
|
6
|
+
*/
|
|
7
|
+
import { Clock, Duration, Effect, Function, Option, Schedule, Stream } from "effect";
|
|
8
|
+
|
|
9
|
+
import { type BrowserError, Failed, refuse, Timeout, undispatched } from "../BrowserError.ts";
|
|
5
10
|
import type { Box } from "../BrowserEvent.ts";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
11
|
+
import * as Change from "../Change.ts";
|
|
12
|
+
import * as Frame from "../Frame.ts";
|
|
13
|
+
import { millisOf, monotonicMillis } from "../internal/clock.ts";
|
|
14
|
+
import * as Overlay from "../Overlay.ts";
|
|
8
15
|
import type { Page } from "../Page.ts";
|
|
9
|
-
import * as Motion from "./
|
|
16
|
+
import * as Motion from "./internal/pixels.ts";
|
|
10
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @stability stable
|
|
20
|
+
* @category options
|
|
21
|
+
* @since 0.3.0
|
|
22
|
+
*/
|
|
11
23
|
export interface Options {
|
|
12
24
|
readonly still?: "screen" | "content" | "foreground" | undefined;
|
|
13
|
-
|
|
25
|
+
/** How long the screen, or the content, must stay still. */
|
|
26
|
+
readonly quiet: Duration.Input;
|
|
27
|
+
/** Defaults to 15 seconds. */
|
|
14
28
|
readonly timeout?: Duration.Input | undefined;
|
|
15
29
|
}
|
|
16
30
|
|
|
17
|
-
const observe = (page: Page, options: Options, timeout: Duration.Duration) =>
|
|
31
|
+
const observe = (page: Page, options: Options, quietMillis: number, timeout: Duration.Duration) =>
|
|
18
32
|
Effect.gen(function* () {
|
|
19
|
-
const now = () => monotonicMillis(page.
|
|
33
|
+
const now = () => monotonicMillis(page.hostClock);
|
|
20
34
|
const deadline = now() + Duration.toMillis(timeout);
|
|
21
35
|
|
|
22
36
|
const settled = () =>
|
|
23
37
|
page.ready({
|
|
24
|
-
|
|
38
|
+
quiet: quietMillis,
|
|
25
39
|
timeout: Duration.millis(Math.max(0, deadline - now())),
|
|
26
40
|
});
|
|
27
41
|
|
|
@@ -30,14 +44,14 @@ const observe = (page: Page, options: Options, timeout: Duration.Duration) =>
|
|
|
30
44
|
// even of a still page.
|
|
31
45
|
const quiet = (millis: number) =>
|
|
32
46
|
Effect.gen(function* () {
|
|
33
|
-
const capture = yield*
|
|
47
|
+
const capture = yield* Frame.capture(page);
|
|
34
48
|
|
|
35
49
|
const foreground = options.still === "foreground";
|
|
36
50
|
let counts = yield* capture.stats();
|
|
37
51
|
let stirred = now();
|
|
38
52
|
let reference: Motion.Picture | undefined;
|
|
39
53
|
|
|
40
|
-
const decoded = (frame: Frame) =>
|
|
54
|
+
const decoded = (frame: Frame.Frame) =>
|
|
41
55
|
Effect.try({
|
|
42
56
|
try: () => Motion.picture(frame),
|
|
43
57
|
catch: (error) =>
|
|
@@ -52,7 +66,7 @@ const observe = (page: Page, options: Options, timeout: Duration.Duration) =>
|
|
|
52
66
|
|
|
53
67
|
const document = (yield* page.state).document;
|
|
54
68
|
|
|
55
|
-
const before = (foreground ? yield* page
|
|
69
|
+
const before = (foreground ? yield* Frame.recent(page) : []).filter(
|
|
56
70
|
(frame) =>
|
|
57
71
|
frame.hostTime < inputAt &&
|
|
58
72
|
frame.hostTime >= inputAt - 1500 &&
|
|
@@ -81,7 +95,9 @@ const observe = (page: Page, options: Options, timeout: Duration.Duration) =>
|
|
|
81
95
|
// unanswered with no frame coming.
|
|
82
96
|
const look = Effect.gen(function* () {
|
|
83
97
|
const stats = yield* capture.stats();
|
|
84
|
-
const
|
|
98
|
+
const overlay = Option.getOrUndefined(yield* Overlay.drawn(page));
|
|
99
|
+
const recent = yield* Frame.recent(page);
|
|
100
|
+
const latest = recent.at(-1);
|
|
85
101
|
const comparing = foreground || overlay !== undefined;
|
|
86
102
|
const arrived = stats.received !== counts.received;
|
|
87
103
|
const unseen = stats.accepted - counts.accepted;
|
|
@@ -93,7 +109,7 @@ const observe = (page: Page, options: Options, timeout: Duration.Duration) =>
|
|
|
93
109
|
else if (comparing && (unseen > 0 || reference === undefined)) {
|
|
94
110
|
// A move and its return between looks both count. Bound decoding; any frames lost
|
|
95
111
|
// from history, or beyond this batch, deny a quiet spell rather than hiding motion.
|
|
96
|
-
const frames =
|
|
112
|
+
const frames = recent.slice(-Math.max(1, Math.min(8, unseen)));
|
|
97
113
|
|
|
98
114
|
if (unseen > frames.length) stirred = now();
|
|
99
115
|
for (const frame of frames) {
|
|
@@ -127,7 +143,7 @@ const observe = (page: Page, options: Options, timeout: Duration.Duration) =>
|
|
|
127
143
|
if (
|
|
128
144
|
(yield* look) >= millis &&
|
|
129
145
|
(foreground ||
|
|
130
|
-
(yield* page
|
|
146
|
+
Option.isSome(yield* Overlay.drawn(page)) ||
|
|
131
147
|
counts.received === before)
|
|
132
148
|
)
|
|
133
149
|
return;
|
|
@@ -142,40 +158,28 @@ const observe = (page: Page, options: Options, timeout: Duration.Duration) =>
|
|
|
142
158
|
|
|
143
159
|
yield* page.afterInput(Effect.void);
|
|
144
160
|
if (options.still === "content") {
|
|
145
|
-
yield*
|
|
146
|
-
yield* Effect.sleep(Duration.millis(
|
|
161
|
+
yield* Change.read(page);
|
|
162
|
+
yield* Effect.sleep(Duration.millis(quietMillis));
|
|
147
163
|
|
|
148
164
|
return yield* settled();
|
|
149
165
|
}
|
|
150
166
|
yield* settled();
|
|
151
|
-
yield* quiet(
|
|
167
|
+
yield* quiet(quietMillis);
|
|
152
168
|
});
|
|
153
169
|
|
|
154
|
-
|
|
170
|
+
const waitStill = (page: Page, options: Options) =>
|
|
155
171
|
Effect.gen(function* () {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
: typeof input === "object" && !Duration.isDuration(input)
|
|
164
|
-
? Object.values(input)
|
|
165
|
-
: [];
|
|
166
|
-
|
|
167
|
-
const timeout = Duration.fromInput(input);
|
|
168
|
-
|
|
169
|
-
if (
|
|
170
|
-
components.some((value) => typeof value === "number" && !Number.isFinite(value)) ||
|
|
171
|
-
Option.isNone(timeout) ||
|
|
172
|
-
!Duration.isFinite(timeout.value) ||
|
|
173
|
-
Duration.isNegative(timeout.value)
|
|
174
|
-
)
|
|
172
|
+
const quietMillis = millisOf(options.quiet);
|
|
173
|
+
|
|
174
|
+
if (!Number.isFinite(quietMillis) || quietMillis < 0)
|
|
175
|
+
return yield* refuse("stillness", "quiet must be a finite nonnegative duration");
|
|
176
|
+
const timeoutMillis = millisOf(options.timeout ?? Duration.seconds(15));
|
|
177
|
+
|
|
178
|
+
if (!Number.isFinite(timeoutMillis) || timeoutMillis < 0)
|
|
175
179
|
return yield* refuse("stillness", "timeout must be a finite nonnegative duration");
|
|
176
|
-
const duration =
|
|
180
|
+
const duration = Duration.millis(timeoutMillis);
|
|
177
181
|
|
|
178
|
-
return yield* observe(page, options, duration).pipe(
|
|
182
|
+
return yield* observe(page, options, quietMillis, duration).pipe(
|
|
179
183
|
Effect.timeoutOrElse({
|
|
180
184
|
duration,
|
|
181
185
|
orElse: () =>
|
|
@@ -186,6 +190,20 @@ export const wait = (page: Page, options: Options) =>
|
|
|
186
190
|
);
|
|
187
191
|
}).pipe(
|
|
188
192
|
Effect.scoped,
|
|
189
|
-
Effect.provideService(Clock.Clock, page.
|
|
193
|
+
Effect.provideService(Clock.Clock, page.hostClock),
|
|
190
194
|
Effect.withSpan("Stillness.wait"),
|
|
191
195
|
);
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Wait for a ready page to stay still for `quiet`: its screen, by default, with no screencast frame
|
|
199
|
+
* coming; its `"foreground"`, allowing motion it showed before its latest input; or its
|
|
200
|
+
* `"content"`, with no visible change recorded. Fails `Timeout` after `timeout`.
|
|
201
|
+
*
|
|
202
|
+
* @stability stable
|
|
203
|
+
* @category combinators
|
|
204
|
+
* @since 0.3.0
|
|
205
|
+
*/
|
|
206
|
+
export const wait: {
|
|
207
|
+
(options: Options): (page: Page) => Effect.Effect<void, BrowserError>;
|
|
208
|
+
(page: Page, options: Options): Effect.Effect<void, BrowserError>;
|
|
209
|
+
} = Function.dual(2, waitStill);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A page's timeline: what it showed and what changed on it (`Moment`), and when it is still (`Stillness`).
|
|
3
|
+
*
|
|
4
|
+
* @stability stable
|
|
5
|
+
* @since 0.3.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @stability stable
|
|
10
|
+
* @since 0.3.0
|
|
11
|
+
*/
|
|
12
|
+
export * as Moment from "./Moment.ts";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @stability stable
|
|
16
|
+
* @since 0.3.0
|
|
17
|
+
*/
|
|
18
|
+
export * as Stillness from "./Stillness.ts";
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
/// <reference path="./utilsBundle.d.ts" />
|
|
14
14
|
import { jpegjs } from "playwright-core/lib/utilsBundle";
|
|
15
15
|
|
|
16
|
-
import type { Box } from "
|
|
17
|
-
import type { Frame } from "
|
|
16
|
+
import type { Box } from "../../BrowserEvent.ts";
|
|
17
|
+
import type { Frame } from "../../Frame.ts";
|
|
18
18
|
|
|
19
19
|
/** A decoded frame: RGBA, `width` pixels a row. */
|
|
20
20
|
export type Picture = ReturnType<typeof jpegjs.decode>;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* What changed on a page, in words for a model: a change with where it is, and what it is. A moment
|
|
3
3
|
* tells its changes this way, and a tool's receipt the changes its action caused.
|
|
4
4
|
*/
|
|
5
|
-
import type { Subject, SubjectContext } from "
|
|
6
|
-
import type { Change } from "
|
|
5
|
+
import type { Subject, SubjectContext } from "../../BrowserEvent.ts";
|
|
6
|
+
import type { Change } from "../../Change.ts";
|
|
7
7
|
|
|
8
8
|
export const quoted = (value: string | undefined) => JSON.stringify(value ?? "");
|
|
9
9
|
|
package/src/walk/Walk.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A walk recorded once from a page's events and replayed later, on a fresh page, with no model
|
|
3
|
+
* call.
|
|
4
|
+
*
|
|
5
|
+
* `fromEvents` keeps one page's completed actions with their subjects and the options they were
|
|
6
|
+
* given, its navigations with both the address asked for and the one reached, and what was typed
|
|
7
|
+
* as a named input slot, never the text itself. A navigation to an address whose credentials the
|
|
8
|
+
* events withheld is an input slot too, so replay goes where the caller says, or nowhere, and
|
|
9
|
+
* never to the address without them. `replay` takes the steps in turn. Before a step
|
|
10
|
+
* except an opening navigate, back or reload, it waits for `Page.ready`; then it finds the element its
|
|
11
|
+
* subject names, by role and name among those that repeat all its recorded context, and acts on
|
|
12
|
+
* it. Text typed into focus was typed into the focused field, which replay finds the same way, and
|
|
13
|
+
* text typed into a secret field goes into nothing else. An element step never falls back to
|
|
14
|
+
* coordinates, and a step recorded at a point acts there only while the element found for it still
|
|
15
|
+
* covers that point. `step` and `replay` return receipts; failure preserves a stopping point and
|
|
16
|
+
* earlier receipts. Unknown consequential input is never resent. Only a positive durable read-back
|
|
17
|
+
* can reconcile it; restoration follows the same rule. The consumer journals begun steps before
|
|
18
|
+
* calling, treating interruption or a missing receipt as unknown. Version 3 carries canonical typed
|
|
19
|
+
* Actions. Prior string-action plans and unknown versions do not decode.
|
|
20
|
+
*
|
|
21
|
+
* @stability stable
|
|
22
|
+
* @since 0.3.0
|
|
23
|
+
*/
|
|
24
|
+
export {
|
|
25
|
+
/**
|
|
26
|
+
* @stability stable
|
|
27
|
+
* @category schemas
|
|
28
|
+
* @since 0.3.0
|
|
29
|
+
*/
|
|
30
|
+
Expected,
|
|
31
|
+
/**
|
|
32
|
+
* @stability stable
|
|
33
|
+
* @category schemas
|
|
34
|
+
* @since 0.3.0
|
|
35
|
+
*/
|
|
36
|
+
Step,
|
|
37
|
+
/**
|
|
38
|
+
* @stability stable
|
|
39
|
+
* @category schemas
|
|
40
|
+
* @since 0.3.0
|
|
41
|
+
*/
|
|
42
|
+
Walk,
|
|
43
|
+
/**
|
|
44
|
+
* @stability stable
|
|
45
|
+
* @category schemas
|
|
46
|
+
* @since 0.3.0
|
|
47
|
+
*/
|
|
48
|
+
Receipt,
|
|
49
|
+
/**
|
|
50
|
+
* @stability stable
|
|
51
|
+
* @category schemas
|
|
52
|
+
* @since 0.3.0
|
|
53
|
+
*/
|
|
54
|
+
Stopped,
|
|
55
|
+
/**
|
|
56
|
+
* @stability stable
|
|
57
|
+
* @category errors
|
|
58
|
+
* @since 0.3.0
|
|
59
|
+
*/
|
|
60
|
+
Uncertain,
|
|
61
|
+
/**
|
|
62
|
+
* @stability stable
|
|
63
|
+
* @category errors
|
|
64
|
+
* @since 0.3.0
|
|
65
|
+
*/
|
|
66
|
+
ReplayError,
|
|
67
|
+
/**
|
|
68
|
+
* @stability stable
|
|
69
|
+
* @category errors
|
|
70
|
+
* @since 0.3.0
|
|
71
|
+
*/
|
|
72
|
+
ReplayErrorReason,
|
|
73
|
+
/**
|
|
74
|
+
* @stability stable
|
|
75
|
+
* @category guards
|
|
76
|
+
* @since 0.3.0
|
|
77
|
+
*/
|
|
78
|
+
isReplayError,
|
|
79
|
+
/**
|
|
80
|
+
* @stability stable
|
|
81
|
+
* @category guards
|
|
82
|
+
* @since 0.3.0
|
|
83
|
+
*/
|
|
84
|
+
isReplayErrorReason,
|
|
85
|
+
} from "./internal/data.ts";
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @stability stable
|
|
89
|
+
* @category constructors
|
|
90
|
+
* @since 0.3.0
|
|
91
|
+
*/
|
|
92
|
+
export { fromEvents } from "./internal/record.ts";
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @stability stable
|
|
96
|
+
* @category combinators
|
|
97
|
+
* @since 0.3.0
|
|
98
|
+
*/
|
|
99
|
+
export { locate } from "./internal/targets.ts";
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
/**
|
|
103
|
+
* @stability stable
|
|
104
|
+
* @category combinators
|
|
105
|
+
* @since 0.3.0
|
|
106
|
+
*/
|
|
107
|
+
replay,
|
|
108
|
+
/**
|
|
109
|
+
* @stability stable
|
|
110
|
+
* @category combinators
|
|
111
|
+
* @since 0.3.0
|
|
112
|
+
*/
|
|
113
|
+
restore,
|
|
114
|
+
/**
|
|
115
|
+
* @stability stable
|
|
116
|
+
* @category combinators
|
|
117
|
+
* @since 0.3.0
|
|
118
|
+
*/
|
|
119
|
+
step,
|
|
120
|
+
/**
|
|
121
|
+
* @stability stable
|
|
122
|
+
* @category predicates
|
|
123
|
+
* @since 0.3.0
|
|
124
|
+
*/
|
|
125
|
+
repeatable,
|
|
126
|
+
/**
|
|
127
|
+
* @stability stable
|
|
128
|
+
* @category options
|
|
129
|
+
* @since 0.3.0
|
|
130
|
+
*/
|
|
131
|
+
type StepOptions,
|
|
132
|
+
/**
|
|
133
|
+
* @stability stable
|
|
134
|
+
* @category options
|
|
135
|
+
* @since 0.3.0
|
|
136
|
+
*/
|
|
137
|
+
type ReplayOptions,
|
|
138
|
+
/**
|
|
139
|
+
* @stability stable
|
|
140
|
+
* @category options
|
|
141
|
+
* @since 0.3.0
|
|
142
|
+
*/
|
|
143
|
+
type RestoreOptions,
|
|
144
|
+
} from "./internal/execute.ts";
|
|
145
|
+
|
|
146
|
+
export {
|
|
147
|
+
/**
|
|
148
|
+
* @stability stable
|
|
149
|
+
* @category errors
|
|
150
|
+
* @since 0.3.0
|
|
151
|
+
*/
|
|
152
|
+
Ambiguous,
|
|
153
|
+
/**
|
|
154
|
+
* @stability stable
|
|
155
|
+
* @category errors
|
|
156
|
+
* @since 0.3.0
|
|
157
|
+
*/
|
|
158
|
+
Drifted,
|
|
159
|
+
/**
|
|
160
|
+
* @stability stable
|
|
161
|
+
* @category errors
|
|
162
|
+
* @since 0.3.0
|
|
163
|
+
*/
|
|
164
|
+
Missing,
|
|
165
|
+
} from "./internal/choose.ts";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Choosing the one element a recorded subject names, among those `find` gives for its
|
|
3
|
-
* name. Context tells them apart, and an element that does not repeat every part of the
|
|
4
|
-
* context is another subject, so a sole element left once its own has gone, such as
|
|
5
|
-
* "Remove" after Bob has left, drifts rather than stands in:
|
|
2
|
+
* Choosing the one element a recorded subject names, among those `Snapshot.find` gives for its
|
|
3
|
+
* role and name. Context tells them apart, and an element that does not repeat every part of the
|
|
4
|
+
* recorded context is another subject, so a sole element left once its own has gone, such as
|
|
5
|
+
* Alice's "Remove" after Bob has left, drifts rather than stands in:
|
|
6
6
|
*
|
|
7
7
|
* - a row is read whole: a row named "Wrapped BTC" is not the row "BTC". Laid out again without
|
|
8
8
|
* rows, as cards, one of the element's fields must start with the row's words;
|
|
@@ -15,30 +15,39 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { Effect, Schema } from "effect";
|
|
17
17
|
|
|
18
|
-
import type { Subject, SubjectContext } from "
|
|
19
|
-
import { match } from "
|
|
20
|
-
import type { Found } from "
|
|
18
|
+
import type { Subject, SubjectContext } from "../../BrowserEvent.ts";
|
|
19
|
+
import { match } from "../../internal/matching.ts";
|
|
20
|
+
import type { Found } from "../../Snapshot.ts";
|
|
21
21
|
|
|
22
22
|
/** Nothing on the page has the step's role and name. */
|
|
23
|
-
export class Missing extends Schema.TaggedError<Missing>(
|
|
23
|
+
export class Missing extends Schema.TaggedError<Missing>("effect-browser/walk/Walk/Missing")(
|
|
24
|
+
"Missing",
|
|
25
|
+
{},
|
|
26
|
+
) {
|
|
24
27
|
override get message() {
|
|
25
28
|
return "nothing on the page has the recorded role and name";
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
/** Several elements match the step's subject equally well, and nothing tells them apart. */
|
|
30
|
-
export class Ambiguous extends Schema.TaggedError<Ambiguous>(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
export class Ambiguous extends Schema.TaggedError<Ambiguous>("effect-browser/walk/Walk/Ambiguous")(
|
|
34
|
+
"Ambiguous",
|
|
35
|
+
{
|
|
36
|
+
count: Schema.Int,
|
|
37
|
+
},
|
|
38
|
+
) {
|
|
33
39
|
override get message() {
|
|
34
40
|
return `${this.count} elements match the recorded subject equally well`;
|
|
35
41
|
}
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
/** The page is not where the recording was: another site, or no element with its context. */
|
|
39
|
-
export class Drifted extends Schema.TaggedError<Drifted>(
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
export class Drifted extends Schema.TaggedError<Drifted>("effect-browser/walk/Walk/Drifted")(
|
|
46
|
+
"Drifted",
|
|
47
|
+
{
|
|
48
|
+
detail: Schema.String,
|
|
49
|
+
},
|
|
50
|
+
) {
|
|
42
51
|
override get message() {
|
|
43
52
|
return this.detail;
|
|
44
53
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** Serializable plan steps, expected effects, receipts and durable stopping evidence. */
|
|
2
2
|
import { Schema } from "effect";
|
|
3
3
|
|
|
4
|
-
import { Action } from "
|
|
5
|
-
import { BrowserError } from "
|
|
6
|
-
import { Box, Subject } from "
|
|
4
|
+
import { Action } from "../../Action.ts";
|
|
5
|
+
import { BrowserError } from "../../BrowserError.ts";
|
|
6
|
+
import { Box, Subject } from "../../BrowserEvent.ts";
|
|
7
7
|
import { Ambiguous, Drifted, Missing } from "./choose.ts";
|
|
8
8
|
|
|
9
9
|
/** Reuse the execution variants; recorded code has no serializable replay capability. */
|
|
@@ -48,7 +48,7 @@ export const Expected = Schema.Union([
|
|
|
48
48
|
export type Expected = typeof Expected.Type;
|
|
49
49
|
|
|
50
50
|
/** One recorded step: the action, what it acted on, and what else it was asked. */
|
|
51
|
-
export class Step extends Schema.Class<Step>("effect-browser/
|
|
51
|
+
export class Step extends Schema.Class<Step>("effect-browser/walk/Walk/Step")({
|
|
52
52
|
action: ReplayAction,
|
|
53
53
|
/** The address reached, including a delayed navigation before the next action began. */
|
|
54
54
|
url: Schema.String,
|
|
@@ -62,13 +62,13 @@ export class Step extends Schema.Class<Step>("effect-browser/Plan/Step")({
|
|
|
62
62
|
expect: Schema.optional(Expected),
|
|
63
63
|
}) {}
|
|
64
64
|
|
|
65
|
-
export class
|
|
65
|
+
export class Walk extends Schema.Class<Walk>("effect-browser/walk/Walk")({
|
|
66
66
|
version: Schema.Literal(3),
|
|
67
67
|
steps: Schema.Array(Step),
|
|
68
68
|
}) {
|
|
69
69
|
/** Version 3 carries canonical typed Actions; prior string-action encodings are rejected. */
|
|
70
|
-
static new(steps: ReadonlyArray<Step>):
|
|
71
|
-
return new
|
|
70
|
+
static new(steps: ReadonlyArray<Step>): Walk {
|
|
71
|
+
return new Walk({ version: 3, steps });
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/** The input slots its steps type, in order; replay needs text for each. */
|
|
@@ -78,7 +78,7 @@ export class Plan extends Schema.Class<Plan>("effect-browser/Plan")({
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/** One completed step, on the page's host clock. `verified` means its expected effect was seen. */
|
|
81
|
-
export class Receipt extends Schema.Class<Receipt>("effect-browser/
|
|
81
|
+
export class Receipt extends Schema.Class<Receipt>("effect-browser/walk/Walk/Receipt")({
|
|
82
82
|
step: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
83
83
|
outcome: Schema.Literals(["taken", "verified", "skipped"]),
|
|
84
84
|
startedAt: Schema.Finite,
|
|
@@ -86,24 +86,40 @@ export class Receipt extends Schema.Class<Receipt>("effect-browser/Plan/Receipt"
|
|
|
86
86
|
}) {}
|
|
87
87
|
|
|
88
88
|
/** Durable stopping data. A begun step without a receipt must be restored as `unknown`. */
|
|
89
|
-
export class Stopped extends Schema.Class<Stopped>("effect-browser/
|
|
89
|
+
export class Stopped extends Schema.Class<Stopped>("effect-browser/walk/Walk/Stopped")({
|
|
90
90
|
step: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
91
91
|
input: Schema.Literals(["unsent", "unknown"]),
|
|
92
92
|
}) {}
|
|
93
93
|
|
|
94
94
|
/** Repeating this step could repeat an unresolved effect; the consumer must reconcile it. */
|
|
95
|
-
export class Uncertain extends Schema.TaggedError<Uncertain>(
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
export class Uncertain extends Schema.TaggedError<Uncertain>("effect-browser/walk/Walk/Uncertain")(
|
|
96
|
+
"Uncertain",
|
|
97
|
+
{
|
|
98
|
+
detail: Schema.String,
|
|
99
|
+
},
|
|
100
|
+
) {
|
|
98
101
|
override get message() {
|
|
99
102
|
return this.detail;
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
105
|
|
|
106
|
+
/** Why replay stopped, as `ReplayError`'s `reason`. */
|
|
107
|
+
export const ReplayErrorReason = Schema.Union([
|
|
108
|
+
Missing,
|
|
109
|
+
Ambiguous,
|
|
110
|
+
Drifted,
|
|
111
|
+
BrowserError,
|
|
112
|
+
Uncertain,
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
export type ReplayErrorReason = typeof ReplayErrorReason.Type;
|
|
116
|
+
|
|
103
117
|
/** Where replay stopped, counting steps from 0, why, and the steps that completed before it. */
|
|
104
|
-
export class ReplayError extends Schema.TaggedError<ReplayError>(
|
|
118
|
+
export class ReplayError extends Schema.TaggedError<ReplayError>(
|
|
119
|
+
"effect-browser/walk/Walk/ReplayError",
|
|
120
|
+
)("ReplayError", {
|
|
105
121
|
step: Schema.Int,
|
|
106
|
-
reason:
|
|
122
|
+
reason: ReplayErrorReason,
|
|
107
123
|
input: Schema.Literals(["unsent", "unknown"]),
|
|
108
124
|
receipts: Schema.Array(Receipt),
|
|
109
125
|
}) {
|
|
@@ -115,3 +131,10 @@ export class ReplayError extends Schema.TaggedError<ReplayError>()("ReplayError"
|
|
|
115
131
|
return `step ${this.step} failed: ${this.reason.message}`;
|
|
116
132
|
}
|
|
117
133
|
}
|
|
134
|
+
|
|
135
|
+
/** Whether a value is a `ReplayError`. */
|
|
136
|
+
export const isReplayError: (u: unknown) => u is ReplayError = Schema.is(ReplayError);
|
|
137
|
+
|
|
138
|
+
/** Whether a value is one of `ReplayError`'s reasons. */
|
|
139
|
+
export const isReplayErrorReason: (u: unknown) => u is ReplayErrorReason =
|
|
140
|
+
Schema.is(ReplayErrorReason);
|