effect-browser 0.3.0-beta.21 → 0.3.0-beta.23
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-BKPAbyys.mjs +4076 -0
- package/dist/Browser-BKPAbyys.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-CK83pvqP.mjs} +5 -6
- package/dist/connection-CK83pvqP.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 +515 -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 +89 -39
- 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/identity.ts +6 -5
- 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 +238 -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
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Effect } from "effect";
|
|
7
7
|
|
|
8
|
+
import { recorded, nameOf, type Action } from "../../Action.ts";
|
|
8
9
|
import { type BrowserError, InvalidRequest, NotActionable, StaleRef } from "../../BrowserError.ts";
|
|
9
|
-
import { InputRequest
|
|
10
|
+
import { InputRequest } from "../../Page.ts";
|
|
11
|
+
import * as Url from "../../Url.ts";
|
|
10
12
|
import { type Bridge, scriptCall } from "../page/bridge.ts";
|
|
11
|
-
import { contextGone, decodeWith, failWith, type PageContext
|
|
12
|
-
import * as Url from "../page/url.ts";
|
|
13
|
+
import { contextGone, decodeWith, failWith, type PageContext } from "../page/context.ts";
|
|
13
14
|
import * as Script from "./guard.inpage.ts";
|
|
14
15
|
|
|
15
16
|
export interface Approval {
|
|
@@ -62,7 +63,7 @@ export const make = (page: PageContext, bridge: Bridge) => {
|
|
|
62
63
|
const { current, evaluateIn, evaluateWithContext } = bridge;
|
|
63
64
|
|
|
64
65
|
const preparePolicy = (
|
|
65
|
-
|
|
66
|
+
asked: Action,
|
|
66
67
|
info: { readonly target?: string | undefined; readonly text?: string | undefined },
|
|
67
68
|
targets: Script.InputPlan["targets"],
|
|
68
69
|
flags: {
|
|
@@ -72,16 +73,7 @@ export const make = (page: PageContext, bridge: Bridge) => {
|
|
|
72
73
|
} = {},
|
|
73
74
|
): Effect.Effect<PolicyPlan, BrowserError> =>
|
|
74
75
|
Effect.gen(function* () {
|
|
75
|
-
|
|
76
|
-
if (typeof target === "string" && !/^e\d+$/.test(target))
|
|
77
|
-
return yield* refuse(action, `"${target}" is not a ref; refs look like e12`);
|
|
78
|
-
if (
|
|
79
|
-
target !== null &&
|
|
80
|
-
typeof target !== "string" &&
|
|
81
|
-
(!Number.isFinite(target.x) || !Number.isFinite(target.y))
|
|
82
|
-
)
|
|
83
|
-
return yield* refuse(action, "point coordinates must be finite");
|
|
84
|
-
}
|
|
76
|
+
const action = nameOf(asked);
|
|
85
77
|
|
|
86
78
|
const input: Script.InputPlan = {
|
|
87
79
|
action,
|
|
@@ -103,17 +95,16 @@ export const make = (page: PageContext, bridge: Bridge) => {
|
|
|
103
95
|
const target = targets[0];
|
|
104
96
|
const { title, description, dialog, heading, nearby, form } = prepared.evidence;
|
|
105
97
|
|
|
98
|
+
const safe = recorded(asked, first?.secret !== true);
|
|
99
|
+
|
|
106
100
|
// A guard may hand the request to a judge's model, so its addresses keep no secrets.
|
|
107
101
|
const request = new InputRequest({
|
|
108
102
|
page: id,
|
|
109
103
|
url: Url.redact(prepared.url),
|
|
110
104
|
title,
|
|
111
|
-
action,
|
|
105
|
+
action: safe,
|
|
112
106
|
target: info.target,
|
|
113
|
-
text:
|
|
114
|
-
info.text !== undefined && action === "type" && first?.secret === true
|
|
115
|
-
? redacted
|
|
116
|
-
: info.text,
|
|
107
|
+
text: safe._tag === "Type" ? safe.text : info.text,
|
|
117
108
|
element: first?.element,
|
|
118
109
|
role: first?.role,
|
|
119
110
|
name: first?.name,
|
|
@@ -124,7 +115,7 @@ export const make = (page: PageContext, bridge: Bridge) => {
|
|
|
124
115
|
prepared.destination === undefined ? undefined : Url.redact(prepared.destination),
|
|
125
116
|
facts: prepared.facts,
|
|
126
117
|
context: { dialog, heading, nearby },
|
|
127
|
-
form,
|
|
118
|
+
form: form === undefined ? undefined : { ...form, action: Url.redact(form.action) },
|
|
128
119
|
});
|
|
129
120
|
|
|
130
121
|
const check = (options: Script.ValidationOptions = {}) =>
|
|
@@ -7,12 +7,21 @@ import { Duration, Effect } from "effect";
|
|
|
7
7
|
import { NotActionable } from "../../BrowserError.ts";
|
|
8
8
|
import type { Bridge } from "../page/bridge.ts";
|
|
9
9
|
import { failWith, type PageContext } from "../page/context.ts";
|
|
10
|
+
import type * as Replies from "../page/replies.ts";
|
|
10
11
|
import type { Dispatch } from "./dispatch.ts";
|
|
11
12
|
import * as Keys from "./keys.ts";
|
|
12
|
-
import type * as Replies from "./replies.ts";
|
|
13
13
|
|
|
14
14
|
export const make = (page: PageContext, bridge: Bridge, dispatch: Dispatch) => {
|
|
15
15
|
const { playwright } = page;
|
|
16
|
+
|
|
17
|
+
const key = (direction: "down" | "up", part: string) => {
|
|
18
|
+
const run = () => playwright.keyboard[direction](part);
|
|
19
|
+
|
|
20
|
+
return page.nativePort === undefined
|
|
21
|
+
? run()
|
|
22
|
+
: page.nativePort(page.id, `keyboard.${direction}`, { key: part }, run);
|
|
23
|
+
};
|
|
24
|
+
|
|
16
25
|
const { send } = page.protocol;
|
|
17
26
|
const { currentDocument } = bridge;
|
|
18
27
|
const { stamp, inputCall, dispatchKey, dispatchText } = dispatch;
|
|
@@ -47,8 +56,8 @@ export const make = (page: PageContext, bridge: Bridge, dispatch: Dispatch) => {
|
|
|
47
56
|
operation,
|
|
48
57
|
run.down(
|
|
49
58
|
`playwright:${part}`,
|
|
50
|
-
() => dispatchKey(part, "down", () =>
|
|
51
|
-
() => dispatchKey(part, "up", () =>
|
|
59
|
+
() => dispatchKey(part, "down", () => key("down", part), run),
|
|
60
|
+
() => dispatchKey(part, "up", () => key("up", part), run),
|
|
52
61
|
),
|
|
53
62
|
);
|
|
54
63
|
if (holdMillis > 0) yield* Effect.sleep(Duration.millis(holdMillis));
|
|
@@ -4,17 +4,18 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Deferred, Duration, Effect, Exit, Option, Ref } from "effect";
|
|
6
6
|
|
|
7
|
+
import { recorded, nameOf, type Action as ActionValue } from "../../Action.ts";
|
|
7
8
|
import { BrowserError, PolicyTimeout, Timeout } from "../../BrowserError.ts";
|
|
8
|
-
import { Action,
|
|
9
|
+
import { Action, Subject } from "../../BrowserEvent.ts";
|
|
10
|
+
import type * as BrowserClock from "../../Clock.ts";
|
|
9
11
|
import { type Point, redacted, type ResolvedTarget } from "../../Page.ts";
|
|
12
|
+
import { Current, type Style, validated } from "../../Style.ts";
|
|
13
|
+
import { redact } from "../../Url.ts";
|
|
10
14
|
import { failWith, type PageContext, undispatched } from "../page/context.ts";
|
|
11
|
-
import { Correlation } from "../page/lane.ts";
|
|
12
|
-
import
|
|
13
|
-
import type * as BrowserClock from "../pictures/clock.ts";
|
|
15
|
+
import { Correlation, FailFast } from "../page/lane.ts";
|
|
16
|
+
import * as Replies from "../page/replies.ts";
|
|
14
17
|
import type { Dispatch } from "./dispatch.ts";
|
|
15
18
|
import type { Approval, PolicyPlan } from "./guard.ts";
|
|
16
|
-
import * as Replies from "./replies.ts";
|
|
17
|
-
import { plain, type Style } from "./style.ts";
|
|
18
19
|
|
|
19
20
|
export interface InputMarks {
|
|
20
21
|
/** How the action's input is sent: plainly, or performed for viewers. */
|
|
@@ -62,20 +63,34 @@ const subjectAttributes = (prefix: string, subject: Subject | undefined) =>
|
|
|
62
63
|
/** What an action's record keeps of its call. */
|
|
63
64
|
export interface Call {
|
|
64
65
|
readonly target?: string | undefined;
|
|
65
|
-
/** The rest of what the caller asked, recorded so a plan can ask it again. */
|
|
66
|
-
readonly options?: ActionOptions | undefined;
|
|
67
66
|
readonly text?: string | undefined;
|
|
68
|
-
/** The text may be a secret: it is recorded only once the action reveals that it is not. */
|
|
69
|
-
readonly secret?: boolean | undefined;
|
|
70
|
-
/** False for navigation, which sends no input. */
|
|
71
|
-
readonly input?: boolean | undefined;
|
|
72
|
-
/** False for the pointer's travel ahead of an action, which is no action of its own. */
|
|
73
|
-
readonly recorded?: boolean | undefined;
|
|
74
67
|
}
|
|
75
68
|
|
|
76
69
|
const timedOut = (operation: string, timeout: Duration.Duration) =>
|
|
77
70
|
failWith(operation, new Timeout({ millis: Duration.toMillis(timeout) }));
|
|
78
71
|
|
|
72
|
+
/** Trace summaries carry lengths and subjects, never typed text. */
|
|
73
|
+
const annotate = (
|
|
74
|
+
dispatched: boolean,
|
|
75
|
+
queuedMillis: number | undefined,
|
|
76
|
+
info: Call,
|
|
77
|
+
revealed: boolean,
|
|
78
|
+
subject: Subject | undefined,
|
|
79
|
+
to: Subject | undefined,
|
|
80
|
+
failure: Option.Option<BrowserError>,
|
|
81
|
+
) =>
|
|
82
|
+
Effect.annotateCurrentSpan({
|
|
83
|
+
dispatched,
|
|
84
|
+
...(queuedMillis === undefined ? {} : { queuedMillis }),
|
|
85
|
+
...(info.text !== undefined && revealed ? { chars: info.text.length } : {}),
|
|
86
|
+
...subjectAttributes("subject", subject),
|
|
87
|
+
...subjectAttributes("to", to),
|
|
88
|
+
...Option.match(failure, {
|
|
89
|
+
onNone: () => ({}),
|
|
90
|
+
onSome: (error) => ({ "error.type": error.reason._tag }),
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
|
|
79
94
|
/**
|
|
80
95
|
* Fail `effect` with `Timeout` once `timeout` has passed, and as much later again as `presented`
|
|
81
96
|
* says presentation has planned meanwhile.
|
|
@@ -140,7 +155,11 @@ const useRun = <A>(
|
|
|
140
155
|
canStop: Effect.Effect<boolean>,
|
|
141
156
|
) =>
|
|
142
157
|
action.pipe(
|
|
143
|
-
Effect.tapError(() =>
|
|
158
|
+
Effect.tapError((error) =>
|
|
159
|
+
error.reason._tag === "Closed"
|
|
160
|
+
? run.close
|
|
161
|
+
: run.close.pipe(Effect.andThen(sender.flush(name, run)), Effect.ignore),
|
|
162
|
+
),
|
|
144
163
|
Effect.tap(() => run.close.pipe(Effect.andThen(sender.flush(name, run)))),
|
|
145
164
|
// Cleanup submits missing releases; the page retains replies after caller interruption.
|
|
146
165
|
Effect.ensuring(run.close.pipe(Effect.andThen(page.openings.clear))),
|
|
@@ -157,14 +176,23 @@ export const make = (page: PageContext, sender: Dispatch) => {
|
|
|
157
176
|
// Record the whole operation, but never hold the page's turn or spend its action timeout while
|
|
158
177
|
// a policy is waiting. Validation binds approval to the document and targets it saw.
|
|
159
178
|
const perform = <A>(
|
|
160
|
-
|
|
179
|
+
value: ActionValue,
|
|
161
180
|
info: Call,
|
|
162
181
|
timeout: Duration.Duration,
|
|
163
|
-
prepare: Effect.Effect<PolicyPlan, BrowserError>,
|
|
182
|
+
prepare: (action: ActionValue) => Effect.Effect<PolicyPlan, BrowserError>,
|
|
164
183
|
body: (marks: InputMarks, approval: Approval | undefined) => Effect.Effect<A, BrowserError>,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
184
|
+
): Effect.Effect<A, BrowserError> => {
|
|
185
|
+
const name = nameOf(value);
|
|
186
|
+
const sendsInput = value._tag !== "Goto" && value._tag !== "Back" && value._tag !== "Reload";
|
|
187
|
+
|
|
188
|
+
return Effect.gen(function* () {
|
|
189
|
+
const style = validated(yield* Current);
|
|
190
|
+
const failFast = yield* FailFast;
|
|
191
|
+
|
|
192
|
+
const styled =
|
|
193
|
+
style.withInput?.({ operation: name, wait: timeout, failFast }) ??
|
|
194
|
+
(<Value, Error, Requirements>(effect: Effect.Effect<Value, Error, Requirements>) => effect);
|
|
195
|
+
|
|
168
196
|
const startedAt = now();
|
|
169
197
|
const sent = yield* Ref.make(false);
|
|
170
198
|
const at = yield* Ref.make(Option.none<Point>());
|
|
@@ -176,7 +204,7 @@ export const make = (page: PageContext, sender: Dispatch) => {
|
|
|
176
204
|
const touch = Effect.sync(noteInput);
|
|
177
205
|
|
|
178
206
|
// A failure before the action checks its field, a denial included, records no text.
|
|
179
|
-
let revealed =
|
|
207
|
+
let revealed = value._tag !== "Type";
|
|
180
208
|
// The time the style has planned to show the input, which the deadline leaves out.
|
|
181
209
|
let presented = 0;
|
|
182
210
|
const ticket = admission(page, admitted, name);
|
|
@@ -204,7 +232,7 @@ export const make = (page: PageContext, sender: Dispatch) => {
|
|
|
204
232
|
const admit = input.idle.pipe(
|
|
205
233
|
Effect.tap(() =>
|
|
206
234
|
Effect.sync(() => {
|
|
207
|
-
estimate =
|
|
235
|
+
estimate = sendsInput ? mapping.latest() : undefined;
|
|
208
236
|
}),
|
|
209
237
|
),
|
|
210
238
|
);
|
|
@@ -226,7 +254,7 @@ export const make = (page: PageContext, sender: Dispatch) => {
|
|
|
226
254
|
name,
|
|
227
255
|
run,
|
|
228
256
|
action(run),
|
|
229
|
-
|
|
257
|
+
sendsInput ? Ref.get(sent) : Effect.succeed(false),
|
|
230
258
|
),
|
|
231
259
|
),
|
|
232
260
|
);
|
|
@@ -242,29 +270,31 @@ export const make = (page: PageContext, sender: Dispatch) => {
|
|
|
242
270
|
Effect.suspend(() => {
|
|
243
271
|
const asked = now();
|
|
244
272
|
|
|
245
|
-
return
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
Effect.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
273
|
+
return styled(
|
|
274
|
+
lane.write(
|
|
275
|
+
name,
|
|
276
|
+
timeout,
|
|
277
|
+
)(
|
|
278
|
+
ticket.enter.pipe(
|
|
279
|
+
Effect.andThen(
|
|
280
|
+
Effect.suspend(() =>
|
|
281
|
+
admit.pipe(
|
|
282
|
+
Effect.timeoutOrElse({
|
|
283
|
+
duration: Duration.millis(
|
|
284
|
+
Math.max(0, Duration.toMillis(timeout) - (now() - asked)),
|
|
285
|
+
),
|
|
286
|
+
orElse: () => timedOut(name, timeout),
|
|
287
|
+
}),
|
|
288
|
+
),
|
|
259
289
|
),
|
|
260
290
|
),
|
|
291
|
+
Effect.tap(() =>
|
|
292
|
+
Effect.sync(() => {
|
|
293
|
+
queuedMillis = Math.round(now() - asked);
|
|
294
|
+
}),
|
|
295
|
+
),
|
|
296
|
+
Effect.andThen(deadline(name, timeout, now, () => presented)(action)),
|
|
261
297
|
),
|
|
262
|
-
Effect.tap(() =>
|
|
263
|
-
Effect.sync(() => {
|
|
264
|
-
queuedMillis = Math.round(now() - asked);
|
|
265
|
-
}),
|
|
266
|
-
),
|
|
267
|
-
Effect.andThen(deadline(name, timeout, now, () => presented)(action)),
|
|
268
298
|
),
|
|
269
299
|
);
|
|
270
300
|
});
|
|
@@ -277,7 +307,7 @@ export const make = (page: PageContext, sender: Dispatch) => {
|
|
|
277
307
|
? dispatch(useInput((run) => body({ ...marks, input: run }, undefined)))
|
|
278
308
|
: Effect.gen(function* () {
|
|
279
309
|
const plan = yield* lane
|
|
280
|
-
.read(name)(deadline(name, settings.actionTimeout, now, () => 0)(prepare))
|
|
310
|
+
.read(name)(deadline(name, settings.actionTimeout, now, () => 0)(prepare(value)))
|
|
281
311
|
.pipe(span("Page.prepare", {}, "Debug"));
|
|
282
312
|
|
|
283
313
|
// A hold lasts as long as this span; a judge's model call is its child.
|
|
@@ -303,8 +333,6 @@ export const make = (page: PageContext, sender: Dispatch) => {
|
|
|
303
333
|
);
|
|
304
334
|
});
|
|
305
335
|
|
|
306
|
-
const record = info.recorded === false ? () => 0 : publish;
|
|
307
|
-
|
|
308
336
|
// Record the outcome even when the caller interrupts: its input may already be in the page.
|
|
309
337
|
return yield* Effect.uninterruptibleMask((restore) =>
|
|
310
338
|
Effect.gen(function* () {
|
|
@@ -317,29 +345,18 @@ export const make = (page: PageContext, sender: Dispatch) => {
|
|
|
317
345
|
const { subject, to, box } = yield* Ref.get(acted);
|
|
318
346
|
const failure = Exit.isFailure(exit) ? Exit.findErrorOption(exit) : Option.none();
|
|
319
347
|
|
|
320
|
-
|
|
321
|
-
yield* Effect.annotateCurrentSpan({
|
|
322
|
-
dispatched,
|
|
323
|
-
...(queuedMillis === undefined ? {} : { queuedMillis }),
|
|
324
|
-
...(info.text !== undefined && revealed ? { chars: info.text.length } : {}),
|
|
325
|
-
...subjectAttributes("subject", subject),
|
|
326
|
-
...subjectAttributes("to", to),
|
|
327
|
-
...Option.match(failure, {
|
|
328
|
-
onNone: () => ({}),
|
|
329
|
-
onSome: (error) => ({ "error.type": error.reason._tag }),
|
|
330
|
-
}),
|
|
331
|
-
});
|
|
348
|
+
yield* annotate(dispatched, queuedMillis, info, revealed, subject, to, failure);
|
|
332
349
|
|
|
333
|
-
|
|
350
|
+
publish(
|
|
334
351
|
new Action({
|
|
335
352
|
at: now(),
|
|
336
353
|
startedAt,
|
|
337
354
|
page: id,
|
|
338
355
|
name,
|
|
356
|
+
value: recorded(value, revealed),
|
|
339
357
|
url: redact(page.playwright.url()),
|
|
340
358
|
correlation: yield* Correlation,
|
|
341
359
|
target: info.target,
|
|
342
|
-
options: Exit.isSuccess(exit) ? info.options : undefined,
|
|
343
360
|
subject,
|
|
344
361
|
to,
|
|
345
362
|
box,
|
|
@@ -371,6 +388,7 @@ export const make = (page: PageContext, sender: Dispatch) => {
|
|
|
371
388
|
}),
|
|
372
389
|
).pipe(Effect.ensuring(ticket.end));
|
|
373
390
|
}).pipe(span(`Page.${name}`, info.target === undefined ? {} : { target: info.target }), owned);
|
|
391
|
+
};
|
|
374
392
|
|
|
375
393
|
return Object.assign(perform, {
|
|
376
394
|
idle: Effect.suspend(() => Effect.forEach(admitted, Deferred.await, { discard: true })),
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
import { Duration, Effect, MutableRef, Option, Schema } from "effect";
|
|
7
7
|
|
|
8
8
|
import { CursorChanged, TrackPerformed, TrackPlanned } from "../../BrowserEvent.ts";
|
|
9
|
-
import * as Motion from "../../
|
|
9
|
+
import * as Motion from "../../Geometry.ts";
|
|
10
10
|
import type { Point } from "../../Page.ts";
|
|
11
|
+
import type { WheelStep } from "../../Style.ts";
|
|
11
12
|
import { type PageContext, refuse } from "../page/context.ts";
|
|
12
13
|
import type { Viewport } from "../page/viewport.ts";
|
|
13
14
|
import type { Dispatch } from "./dispatch.ts";
|
|
@@ -126,8 +127,9 @@ export const make = (page: PageContext, dispatch: Dispatch, viewport: Viewport)
|
|
|
126
127
|
point: Point,
|
|
127
128
|
dx: number,
|
|
128
129
|
dy: number,
|
|
130
|
+
planned?: ReadonlyArray<WheelStep>,
|
|
129
131
|
) {
|
|
130
|
-
const steps = yield* marks.style.wheel(dx, dy);
|
|
132
|
+
const steps = planned ?? (yield* marks.style.wheel(dx, dy));
|
|
131
133
|
const at = now();
|
|
132
134
|
|
|
133
135
|
yield* marks.present(steps.at(-1)?.afterMillis ?? 0);
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* `pushState` asks for no document, and a navigation a handler starts after a fetch answers is the
|
|
7
7
|
* next look's to see. A tab the input opened waits for the browser's registration too.
|
|
8
8
|
*/
|
|
9
|
-
import { Deferred, Duration, Effect, Exit } from "effect";
|
|
9
|
+
import { Deferred, Duration, Effect, Exit, Option } from "effect";
|
|
10
10
|
|
|
11
11
|
import { type Bridge, scriptCall } from "../page/bridge.ts";
|
|
12
12
|
import { contextGone, type PageContext } from "../page/context.ts";
|
|
13
|
-
import { Current } from "
|
|
13
|
+
import { Current } from "../page/replies.ts";
|
|
14
14
|
|
|
15
15
|
// A document still loading after this, or a closed page, is the next look's to show.
|
|
16
16
|
const settling = Duration.seconds(5);
|
|
@@ -42,9 +42,11 @@ export const make = (page: PageContext, bridge: Bridge) => {
|
|
|
42
42
|
);
|
|
43
43
|
while (document() > before.document && parsed < document()) yield* Deferred.await(changed);
|
|
44
44
|
}).pipe(
|
|
45
|
-
Effect.
|
|
46
|
-
Effect.
|
|
47
|
-
|
|
45
|
+
Effect.timeoutOption(settling),
|
|
46
|
+
Effect.flatMap((result) =>
|
|
47
|
+
Option.isSome(result)
|
|
48
|
+
? Effect.void
|
|
49
|
+
: page.stopLoading.pipe(Effect.andThen(Effect.annotateCurrentSpan("settled", false))),
|
|
48
50
|
),
|
|
49
51
|
Effect.andThen(page.openings.settle(before.openings)),
|
|
50
52
|
page.span("Page.settle", {}, "Debug"),
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { Schema } from "effect";
|
|
7
7
|
|
|
8
8
|
import { Box, Subject } from "../../BrowserEvent.ts";
|
|
9
|
-
import { Point } from "../../
|
|
9
|
+
import { Point } from "../../Geometry.ts";
|
|
10
10
|
import type { ContextReader } from "../reading/context.inpage.ts";
|
|
11
11
|
import type { Names } from "../reading/names.inpage.ts";
|
|
12
12
|
import type { Walk } from "../reading/walk.inpage.ts";
|
|
@@ -8,7 +8,7 @@ import { Effect } from "effect";
|
|
|
8
8
|
import { InvalidRequest, NotActionable, StaleRef } from "../../BrowserError.ts";
|
|
9
9
|
import { ResolvedTarget, type Target } from "../../Page.ts";
|
|
10
10
|
import { scriptCall } from "../page/bridge.ts";
|
|
11
|
-
import { decodeWith, failWith
|
|
11
|
+
import { decodeWith, failWith } from "../page/context.ts";
|
|
12
12
|
import type { Viewport } from "../page/viewport.ts";
|
|
13
13
|
import type { Dispatch } from "./dispatch.ts";
|
|
14
14
|
import { type Approval, check, type Guard } from "./guard.ts";
|
|
@@ -55,20 +55,15 @@ export const make = (
|
|
|
55
55
|
Effect.flatMap(decodeWith(operation, Script.PointResultSchema)),
|
|
56
56
|
);
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (typeof target !== "string" && (!Number.isFinite(target.x) || !Number.isFinite(target.y)))
|
|
62
|
-
return refuse(operation, "point coordinates must be finite");
|
|
63
|
-
|
|
64
|
-
return readPoint(operation, target, approval, scroll).pipe(
|
|
58
|
+
// Every input reaches this phase through ActionPort's decoded Target schema.
|
|
59
|
+
const resolve = (operation: string, target: Target, approval?: Approval, scroll = true) =>
|
|
60
|
+
readPoint(operation, target, approval, scroll).pipe(
|
|
65
61
|
Effect.flatMap((result) =>
|
|
66
62
|
"error" in result
|
|
67
63
|
? pointFailure(operation, target, result)
|
|
68
64
|
: Effect.succeed(resolvedTarget(result)),
|
|
69
65
|
),
|
|
70
66
|
);
|
|
71
|
-
};
|
|
72
67
|
|
|
73
68
|
const targetFor = Effect.fnUntraced(function* (
|
|
74
69
|
operation: string,
|