effect-browser 0.2.0-beta.9 → 0.3.0-beta.11
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 +861 -1161
- package/dist/Browser-B4qncxe7.mjs +628 -0
- package/dist/Browser-B4qncxe7.mjs.map +1 -0
- package/dist/Browser.d.mts +129 -3
- package/dist/Browser.mjs +2 -22
- package/dist/BrowserError-Coy7EW1N.d.mts +140 -0
- package/dist/BrowserError.d.mts +2 -0
- package/dist/BrowserError.mjs +211 -0
- package/dist/BrowserError.mjs.map +1 -0
- package/dist/BrowserEvent-BRu2juEz.d.mts +279 -0
- package/dist/BrowserEvent.d.mts +2 -0
- package/dist/BrowserEvent.mjs +297 -0
- package/dist/BrowserEvent.mjs.map +1 -0
- package/dist/Cdp.d.mts +32 -0
- package/dist/Cdp.mjs +61 -0
- package/dist/Cdp.mjs.map +1 -0
- package/dist/Change-DNvztNLu.mjs +138 -0
- package/dist/Change-DNvztNLu.mjs.map +1 -0
- package/dist/Change-iMlcuzVD.d.mts +71 -0
- package/dist/Change.d.mts +2 -0
- package/dist/Change.mjs +2 -0
- package/dist/Chromium.d.mts +29 -81
- package/dist/Chromium.mjs +57 -392
- package/dist/Chromium.mjs.map +1 -1
- package/dist/Expect.d.mts +62 -0
- package/dist/Expect.mjs +114 -0
- package/dist/Expect.mjs.map +1 -0
- package/dist/Frame-Di2PxyF7.d.mts +119 -0
- package/dist/Frame.d.mts +2 -0
- package/dist/Frame.mjs +125 -0
- package/dist/Frame.mjs.map +1 -0
- package/dist/Moment.d.mts +2 -0
- package/dist/Moment.mjs +288 -0
- package/dist/Moment.mjs.map +1 -0
- package/dist/Motion.d.mts +40 -0
- package/dist/Motion.mjs +122 -0
- package/dist/Motion.mjs.map +1 -0
- package/dist/Page-B5cjaUp5.mjs +618 -0
- package/dist/Page-B5cjaUp5.mjs.map +1 -0
- package/dist/Page-B7X6DQUn.d.mts +595 -0
- package/dist/Page.d.mts +2 -0
- package/dist/Page.mjs +2 -0
- package/dist/Plan-Akcac63g.d.mts +209 -0
- package/dist/Plan-D1wrJVs8.mjs +508 -0
- package/dist/Plan-D1wrJVs8.mjs.map +1 -0
- package/dist/Plan.d.mts +2 -3
- package/dist/Plan.mjs +2 -2
- package/dist/Policy.d.mts +76 -0
- package/dist/Policy.mjs +237 -0
- package/dist/Policy.mjs.map +1 -0
- package/dist/Presentation.d.mts +48 -0
- package/dist/Presentation.mjs +117 -0
- package/dist/Presentation.mjs.map +1 -0
- package/dist/Snapshot-B34hZ4Jl.d.mts +68 -0
- package/dist/Snapshot.d.mts +2 -0
- package/dist/Snapshot.mjs +79 -0
- package/dist/Snapshot.mjs.map +1 -0
- package/dist/Stage.d.mts +64 -0
- package/dist/Stage.mjs +237 -0
- package/dist/Stage.mjs.map +1 -0
- package/dist/Supervisor-CYWFK3vM.d.mts +280 -0
- package/dist/Supervisor-TNKNOVzu.mjs +599 -0
- package/dist/Supervisor-TNKNOVzu.mjs.map +1 -0
- package/dist/Supervisor.d.mts +2 -0
- package/dist/Supervisor.mjs +2 -0
- package/dist/context-B6xr8nVi.mjs +261 -0
- package/dist/context-B6xr8nVi.mjs.map +1 -0
- package/dist/index.d.mts +17 -14
- package/dist/index.mjs +18 -13
- package/dist/match.inpage-xOe9LNO0.mjs +48 -0
- package/dist/match.inpage-xOe9LNO0.mjs.map +1 -0
- package/dist/page-BAf__WKX.mjs +5075 -0
- package/dist/page-BAf__WKX.mjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/url-Cd04Okid.mjs +264 -0
- package/dist/url-Cd04Okid.mjs.map +1 -0
- package/package.json +96 -61
- package/src/Browser.ts +672 -0
- package/src/BrowserError.ts +234 -0
- package/src/BrowserEvent.ts +296 -0
- package/src/Cdp.ts +101 -0
- package/src/Change.ts +88 -0
- package/src/Chromium.ts +102 -0
- package/src/Expect.ts +180 -0
- package/src/Frame.ts +132 -0
- package/src/Moment.ts +479 -0
- package/src/Motion.ts +166 -0
- package/src/Page.ts +522 -0
- package/src/Plan.ts +663 -0
- package/src/Policy.ts +325 -0
- package/src/Presentation.ts +195 -0
- package/src/Snapshot.ts +89 -0
- package/src/Stage.ts +467 -0
- package/src/Supervisor.ts +599 -0
- package/src/index.ts +20 -0
- package/src/internal/input/actions.ts +610 -0
- package/src/internal/input/dispatch.ts +161 -0
- package/src/internal/input/edit.inpage.ts +162 -0
- package/src/internal/input/evidence.inpage.ts +164 -0
- package/src/internal/input/gate.ts +224 -0
- package/src/internal/input/guard.inpage.ts +605 -0
- package/src/internal/input/guard.ts +184 -0
- package/src/internal/input/keyboard.ts +112 -0
- package/src/internal/input/keys.ts +127 -0
- package/src/internal/input/perform.ts +376 -0
- package/src/internal/input/pointer.ts +153 -0
- package/src/internal/input/replies.ts +195 -0
- package/src/internal/input/settle.ts +50 -0
- package/src/internal/input/style.ts +186 -0
- package/src/internal/input/targets.inpage.ts +293 -0
- package/src/internal/input/targets.ts +148 -0
- package/src/internal/page/bridge.ts +391 -0
- package/src/internal/page/context.ts +314 -0
- package/src/internal/page/identity.ts +35 -0
- package/src/internal/page/lane.ts +311 -0
- package/src/internal/page/navigation.ts +183 -0
- package/src/internal/page/openings.ts +87 -0
- package/src/internal/page/page.ts +165 -0
- package/src/internal/page/url.ts +100 -0
- package/src/internal/page/viewport.ts +43 -0
- package/src/internal/pictures/capture.ts +776 -0
- package/src/internal/pictures/clock.ts +141 -0
- package/src/internal/pictures/counts.ts +92 -0
- package/src/internal/pictures/pictures.ts +521 -0
- package/src/internal/pictures/transport.ts +243 -0
- package/src/internal/reading/choose.ts +100 -0
- package/src/internal/reading/context.inpage.ts +201 -0
- package/src/internal/reading/controls.inpage.ts +158 -0
- package/src/internal/reading/expect.inpage.ts +70 -0
- package/src/internal/reading/match.inpage.ts +92 -0
- package/src/internal/reading/names.inpage.ts +306 -0
- package/src/internal/reading/outline.inpage.ts +260 -0
- package/src/internal/reading/reading.ts +223 -0
- package/src/internal/reading/ready.inpage.ts +164 -0
- package/src/internal/reading/ready.ts +111 -0
- package/src/internal/reading/subjects.inpage.ts +188 -0
- package/src/internal/reading/text.inpage.ts +135 -0
- package/src/internal/reading/walk.inpage.ts +220 -0
- package/src/internal/supervisor/lifecycle.ts +416 -0
- package/src/internal/timeline/changes.inpage.ts +216 -0
- package/src/internal/timeline/changes.ts +100 -0
- package/src/internal/timeline/events.ts +94 -0
- package/src/internal/timeline/fold.inpage.ts +123 -0
- package/src/internal/timeline/history.inpage.ts +229 -0
- package/src/internal/timeline/marks.inpage.ts +207 -0
- package/src/internal/timeline/record.inpage.ts +133 -0
- package/src/internal/timeline/sight.inpage.ts +122 -0
- package/src/internal/timeline/window.ts +96 -0
- package/src/internal/timeline/words.ts +65 -0
- package/dist/Bootstrap-B9UUXsvF.d.mts +0 -183
- package/dist/Bootstrap-CeQOWBy6.mjs +0 -189
- package/dist/Bootstrap-CeQOWBy6.mjs.map +0 -1
- package/dist/Bootstrap.d.mts +0 -3
- package/dist/Bootstrap.mjs +0 -2
- package/dist/Browser-BF9_sORP.d.mts +0 -388
- package/dist/Browser.mjs.map +0 -1
- package/dist/BrowserData-CPIIIHol.d.mts +0 -585
- package/dist/BrowserData.d.mts +0 -3
- package/dist/BrowserData.mjs +0 -695
- package/dist/BrowserData.mjs.map +0 -1
- package/dist/BrowserRuntime-B6nT1G4X.d.mts +0 -148
- package/dist/BrowserRuntime-C1r2aSRK.mjs +0 -6820
- package/dist/BrowserRuntime-C1r2aSRK.mjs.map +0 -1
- package/dist/BrowserRuntime.d.mts +0 -3
- package/dist/BrowserRuntime.mjs +0 -3
- package/dist/Capture.d.mts +0 -56
- package/dist/Capture.mjs +0 -678
- package/dist/Capture.mjs.map +0 -1
- package/dist/CaptureData-CYriZHX1.mjs +0 -201
- package/dist/CaptureData-CYriZHX1.mjs.map +0 -1
- package/dist/CaptureData.d.mts +0 -219
- package/dist/CaptureData.mjs +0 -2
- package/dist/Errors.d.mts +0 -158
- package/dist/Errors.mjs +0 -207
- package/dist/Errors.mjs.map +0 -1
- package/dist/Images-yCG9BmRU.mjs +0 -76
- package/dist/Images-yCG9BmRU.mjs.map +0 -1
- package/dist/OperationOptions-DAeRS6O9.mjs +0 -55
- package/dist/OperationOptions-DAeRS6O9.mjs.map +0 -1
- package/dist/PageControl.d.mts +0 -15
- package/dist/PageControl.mjs +0 -34
- package/dist/PageControl.mjs.map +0 -1
- package/dist/PageRegistry-B3q9DS3g.mjs +0 -164
- package/dist/PageRegistry-B3q9DS3g.mjs.map +0 -1
- package/dist/Plan-Dyxu2q8C.mjs +0 -543
- package/dist/Plan-Dyxu2q8C.mjs.map +0 -1
- package/dist/PlanData-B668RxbQ.d.mts +0 -4831
- package/dist/PlanData.d.mts +0 -3
- package/dist/PlanData.mjs +0 -268
- package/dist/PlanData.mjs.map +0 -1
- package/dist/PlanInput-BJcPPncs.mjs +0 -75
- package/dist/PlanInput-BJcPPncs.mjs.map +0 -1
- package/dist/PublicSession-DCSMMqOj.mjs +0 -5602
- package/dist/PublicSession-DCSMMqOj.mjs.map +0 -1
- package/dist/Testing.d.mts +0 -479
- package/dist/Testing.mjs +0 -2147
- package/dist/Testing.mjs.map +0 -1
- package/dist/Timeline-fV22Xk-S.d.mts +0 -29
- package/dist/Timeline.d.mts +0 -4
- package/dist/Timeline.mjs +0 -20
- package/dist/Timeline.mjs.map +0 -1
- package/dist/TimelineData-BsOn-YGZ.d.mts +0 -3818
- package/dist/TimelineData.d.mts +0 -3
- package/dist/TimelineData.mjs +0 -482
- package/dist/TimelineData.mjs.map +0 -1
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { ActionOptions, Box, Subject } from "./BrowserEvent.mjs";
|
|
3
|
+
import { BrowserError, InvalidRequest } from "./BrowserError.mjs";
|
|
4
|
+
import { s as undispatched } from "./context-B6xr8nVi.mjs";
|
|
5
|
+
import { p as redacted } from "./Page-B5cjaUp5.mjs";
|
|
6
|
+
import { t as match } from "./match.inpage-xOe9LNO0.mjs";
|
|
7
|
+
import { Duration, Effect, Exit, Option, Schedule, Schema } from "effect";
|
|
8
|
+
//#region src/internal/reading/choose.ts
|
|
9
|
+
/**
|
|
10
|
+
* Choosing the one element a recorded subject names, among those `find` gives for its role and
|
|
11
|
+
* name. Context tells them apart, and an element that does not repeat every part of the recorded
|
|
12
|
+
* context is another subject, so a sole element left once its own has gone, such as Alice's
|
|
13
|
+
* "Remove" after Bob has left, drifts rather than stands in:
|
|
14
|
+
*
|
|
15
|
+
* - a row is read whole: a row named "Wrapped BTC" is not the row "BTC". Laid out again without
|
|
16
|
+
* rows, as cards, one of the element's fields must start with the row's words;
|
|
17
|
+
* - a column counts where the element is under one;
|
|
18
|
+
* - a label or heading must read the same, or its words appear, whole and in order, in one of the
|
|
19
|
+
* element's fields, as `near` reads them.
|
|
20
|
+
*
|
|
21
|
+
* The rest are ranked by how much of the recorded context they read the same. There is no
|
|
22
|
+
* ordinal, so a tie stays a tie.
|
|
23
|
+
*/
|
|
24
|
+
/** Nothing on the page has the step's role and name. */
|
|
25
|
+
var Missing = class extends Schema.TaggedError()("Missing", {}) {
|
|
26
|
+
get message() {
|
|
27
|
+
return "nothing on the page has the recorded role and name";
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
/** Several elements match the step's subject equally well, and nothing tells them apart. */
|
|
31
|
+
var Ambiguous = class extends Schema.TaggedError()("Ambiguous", { count: Schema.Int }) {
|
|
32
|
+
get message() {
|
|
33
|
+
return `${this.count} elements match the recorded subject equally well`;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
/** The page is not where the recording was: another site, or no element with its context. */
|
|
37
|
+
var Drifted = class extends Schema.TaggedError()("Drifted", { detail: Schema.String }) {
|
|
38
|
+
get message() {
|
|
39
|
+
return this.detail;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const { holds, normalize } = match();
|
|
43
|
+
const fields = [
|
|
44
|
+
"row",
|
|
45
|
+
"column",
|
|
46
|
+
"label",
|
|
47
|
+
"heading"
|
|
48
|
+
];
|
|
49
|
+
const said = (context) => Object.values(context).filter((value) => typeof value === "string");
|
|
50
|
+
/** How an element repeats one recorded field: 2 read the same, 1 found as words, 0 not at all. */
|
|
51
|
+
const repeats = (field, value, context) => {
|
|
52
|
+
const own = context[field];
|
|
53
|
+
if (own !== void 0 && normalize(own) === normalize(value)) return 2;
|
|
54
|
+
if (field === "column") return own === void 0 ? 1 : 0;
|
|
55
|
+
if (field === "row") return own === void 0 && said(context).some((other) => `${normalize(other)} `.startsWith(`${normalize(value)} `)) ? 1 : 0;
|
|
56
|
+
return said(context).some((other) => holds(other, value)) ? 1 : 0;
|
|
57
|
+
};
|
|
58
|
+
const choose = (subject, found) => {
|
|
59
|
+
const named = found.filter((one) => subject.role !== null || one.subject.role === null);
|
|
60
|
+
const kept = named.flatMap((one) => {
|
|
61
|
+
let score = 0;
|
|
62
|
+
for (const field of fields) {
|
|
63
|
+
const value = subject.context[field];
|
|
64
|
+
const repeated = value === void 0 ? 0 : repeats(field, value, one.subject.context);
|
|
65
|
+
if (value !== void 0 && repeated === 0) return [];
|
|
66
|
+
score += repeated;
|
|
67
|
+
}
|
|
68
|
+
return [{
|
|
69
|
+
one,
|
|
70
|
+
score
|
|
71
|
+
}];
|
|
72
|
+
});
|
|
73
|
+
const best = Math.max(...kept.map(({ score }) => score));
|
|
74
|
+
const top = kept.filter(({ score }) => score === best);
|
|
75
|
+
const [only] = top;
|
|
76
|
+
if (named.length === 0) return Effect.fail(new Missing());
|
|
77
|
+
if (kept.length === 0) return Effect.fail(new Drifted({ detail: "no element named so repeats the recorded context" }));
|
|
78
|
+
return top.length === 1 && only !== void 0 ? Effect.succeed(only.one) : Effect.fail(new Ambiguous({ count: top.length }));
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/Plan.ts
|
|
82
|
+
/**
|
|
83
|
+
* A walk recorded once from a page's events and replayed later, on a fresh page, with no model
|
|
84
|
+
* call.
|
|
85
|
+
*
|
|
86
|
+
* `fromEvents` keeps one page's completed actions with their subjects and the options they were
|
|
87
|
+
* given, its navigations with both the address asked for and the one reached, and what was typed
|
|
88
|
+
* as a named input slot, never the text itself. A navigation to an address whose credentials the
|
|
89
|
+
* events withheld is an input slot too, so replay goes where the caller says, or nowhere, and
|
|
90
|
+
* never to the address without them. `replay` takes the steps in turn. Before a step
|
|
91
|
+
* that acts on the page, it waits for `Page.ready`; then it finds the one element the step's
|
|
92
|
+
* subject names, by role and name among those that repeat all its recorded context, and acts on
|
|
93
|
+
* it. Text typed into focus was typed into the focused field, which replay finds the same way, and
|
|
94
|
+
* text typed into a secret field goes into nothing else. An element step never falls back to
|
|
95
|
+
* coordinates, and a step recorded at a point acts there only while the element found for it still
|
|
96
|
+
* covers that point. `take` and `replay` return receipts; failure preserves a stopping point and
|
|
97
|
+
* earlier receipts. Unknown consequential input is never resent. Only a positive durable read-back
|
|
98
|
+
* can reconcile it; restoration follows the same rule. The consumer journals begun steps before
|
|
99
|
+
* calling, treating interruption or a missing receipt as unknown. Plain recordings use version 1;
|
|
100
|
+
* authored expected effects use version 2. Old 0.2 plans and unknown versions do not decode.
|
|
101
|
+
*
|
|
102
|
+
* @since 0.3.0
|
|
103
|
+
*/
|
|
104
|
+
var Plan_exports = /* @__PURE__ */ __exportAll({
|
|
105
|
+
Ambiguous: () => Ambiguous,
|
|
106
|
+
Drifted: () => Drifted,
|
|
107
|
+
Expected: () => Expected,
|
|
108
|
+
Missing: () => Missing,
|
|
109
|
+
Plan: () => Plan,
|
|
110
|
+
Receipt: () => Receipt,
|
|
111
|
+
ReplayError: () => ReplayError,
|
|
112
|
+
Step: () => Step,
|
|
113
|
+
StepAction: () => StepAction,
|
|
114
|
+
Stopped: () => Stopped,
|
|
115
|
+
Uncertain: () => Uncertain,
|
|
116
|
+
fromEvents: () => fromEvents,
|
|
117
|
+
locate: () => locate,
|
|
118
|
+
repeatable: () => repeatable,
|
|
119
|
+
replay: () => replay,
|
|
120
|
+
restore: () => restore,
|
|
121
|
+
take: () => take
|
|
122
|
+
});
|
|
123
|
+
const ViewportPoint = Schema.Struct({
|
|
124
|
+
x: Schema.Finite,
|
|
125
|
+
y: Schema.Finite
|
|
126
|
+
});
|
|
127
|
+
const StepAction = Schema.Literals([
|
|
128
|
+
"navigate",
|
|
129
|
+
"back",
|
|
130
|
+
"reload",
|
|
131
|
+
"click",
|
|
132
|
+
"hover",
|
|
133
|
+
"drag",
|
|
134
|
+
"type",
|
|
135
|
+
"press",
|
|
136
|
+
"scroll",
|
|
137
|
+
"select"
|
|
138
|
+
]);
|
|
139
|
+
const Query = Schema.Struct({
|
|
140
|
+
role: Schema.optional(Schema.String),
|
|
141
|
+
name: Schema.optional(Schema.String),
|
|
142
|
+
text: Schema.optional(Schema.String)
|
|
143
|
+
});
|
|
144
|
+
/**
|
|
145
|
+
* What a step leaves. `durable` asserts an author-chosen, lasting read-back of this operation,
|
|
146
|
+
* such as its uniquely named saved receipt. A toast or an intermediate address is not durable.
|
|
147
|
+
* Even a durable check's absence never authorizes repeating unknown consequential input.
|
|
148
|
+
*/
|
|
149
|
+
const Expected = Schema.Union([
|
|
150
|
+
Schema.TaggedStruct("Checked", { checked: Schema.Boolean }),
|
|
151
|
+
Schema.TaggedStruct("Appeared", {
|
|
152
|
+
query: Query,
|
|
153
|
+
durable: Schema.optional(Schema.Literal(true))
|
|
154
|
+
}),
|
|
155
|
+
Schema.TaggedStruct("Gone", {
|
|
156
|
+
query: Query,
|
|
157
|
+
durable: Schema.optional(Schema.Literal(true))
|
|
158
|
+
}),
|
|
159
|
+
Schema.TaggedStruct("Navigated", {
|
|
160
|
+
url: Schema.optional(Schema.String),
|
|
161
|
+
durable: Schema.optional(Schema.Literal(true))
|
|
162
|
+
})
|
|
163
|
+
]);
|
|
164
|
+
/** One recorded step: the action, what it acted on, and what else it was asked. */
|
|
165
|
+
var Step = class extends Schema.Class("effect-browser/Plan/Step")({
|
|
166
|
+
action: StepAction,
|
|
167
|
+
/**
|
|
168
|
+
* The ending address, or a later recorded navigation before the next action began. Empty when
|
|
169
|
+
* unknown; a delayed navigation can be stronger arrival evidence than the action's ending URL.
|
|
170
|
+
*/
|
|
171
|
+
url: Schema.String,
|
|
172
|
+
/** A navigation's requested address, or the keys a press pressed. */
|
|
173
|
+
target: Schema.optional(Schema.String),
|
|
174
|
+
subject: Schema.optional(Subject),
|
|
175
|
+
/** Where a drag ended. */
|
|
176
|
+
to: Schema.optional(Subject),
|
|
177
|
+
/** The viewport point a step aimed at, when it aimed at a point, and a drag's end point. */
|
|
178
|
+
point: Schema.optional(ViewportPoint),
|
|
179
|
+
toPoint: Schema.optional(ViewportPoint),
|
|
180
|
+
/** The box of what a step aimed at by point found there, so replay aims at the same place in it. */
|
|
181
|
+
box: Schema.optional(Box),
|
|
182
|
+
/**
|
|
183
|
+
* The input slot whose text a `type` step types, or whose address a `navigate` step goes to, as
|
|
184
|
+
* its recorded address had a credential withheld.
|
|
185
|
+
*/
|
|
186
|
+
input: Schema.optional(Schema.String),
|
|
187
|
+
/** The slot's text went into a secret field, so replay types it into nothing else. */
|
|
188
|
+
secret: Schema.optional(Schema.Literal(true)),
|
|
189
|
+
options: Schema.optional(ActionOptions),
|
|
190
|
+
expect: Schema.optional(Expected)
|
|
191
|
+
}) {};
|
|
192
|
+
const PlanData = Schema.Struct({
|
|
193
|
+
version: Schema.Literals([1, 2]),
|
|
194
|
+
steps: Schema.Array(Step)
|
|
195
|
+
}).check(Schema.makeFilter((plan) => plan.version === (plan.steps.some((step) => step.expect !== void 0) ? 2 : 1) ? void 0 : "only plans with expected effects use version 2"));
|
|
196
|
+
var Plan = class Plan extends Schema.Class("effect-browser/Plan")(PlanData) {
|
|
197
|
+
/** Choose the encoding version from the steps; simple recordings remain version 1. */
|
|
198
|
+
static new(steps) {
|
|
199
|
+
return new Plan({
|
|
200
|
+
version: steps.some((step) => step.expect !== void 0) ? 2 : 1,
|
|
201
|
+
steps
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/** The input slots its steps type, in order; replay needs text for each. */
|
|
205
|
+
get inputs() {
|
|
206
|
+
return this.steps.flatMap((step) => step.input === void 0 ? [] : [step.input]);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
/** One completed step, on the page's host clock. `verified` means its expected effect was seen. */
|
|
210
|
+
var Receipt = class extends Schema.Class("effect-browser/Plan/Receipt")({
|
|
211
|
+
step: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
212
|
+
outcome: Schema.Literals([
|
|
213
|
+
"taken",
|
|
214
|
+
"verified",
|
|
215
|
+
"skipped"
|
|
216
|
+
]),
|
|
217
|
+
startedAt: Schema.Finite,
|
|
218
|
+
at: Schema.Finite
|
|
219
|
+
}) {};
|
|
220
|
+
/** Durable stopping data. A begun step without a receipt must be restored as `unknown`. */
|
|
221
|
+
var Stopped = class extends Schema.Class("effect-browser/Plan/Stopped")({
|
|
222
|
+
step: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
223
|
+
input: Schema.Literals(["unsent", "unknown"])
|
|
224
|
+
}) {};
|
|
225
|
+
/** Repeating this step could repeat an unresolved effect; the consumer must reconcile it. */
|
|
226
|
+
var Uncertain = class extends Schema.TaggedError()("Uncertain", { detail: Schema.String }) {
|
|
227
|
+
get message() {
|
|
228
|
+
return this.detail;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
/** Where replay stopped, counting steps from 0, why, and the steps that completed before it. */
|
|
232
|
+
var ReplayError = class extends Schema.TaggedError()("ReplayError", {
|
|
233
|
+
step: Schema.Int,
|
|
234
|
+
reason: Schema.Union([
|
|
235
|
+
Missing,
|
|
236
|
+
Ambiguous,
|
|
237
|
+
Drifted,
|
|
238
|
+
BrowserError,
|
|
239
|
+
Uncertain
|
|
240
|
+
]),
|
|
241
|
+
input: Schema.Literals(["unsent", "unknown"]),
|
|
242
|
+
receipts: Schema.Array(Receipt)
|
|
243
|
+
}) {
|
|
244
|
+
get stopped() {
|
|
245
|
+
return new Stopped({
|
|
246
|
+
step: this.step,
|
|
247
|
+
input: this.input
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
get message() {
|
|
251
|
+
return `step ${this.step} failed: ${this.reason.message}`;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
const isStep = (event) => event._tag === "Action" && event.ok && StepAction.literals.includes(event.name);
|
|
255
|
+
const pointIn = (target) => {
|
|
256
|
+
const parsed = /^\{?(?:"x":)?(-?[\d.]+),(?:"y":)?(-?[\d.]+)\}?$/.exec(target ?? "");
|
|
257
|
+
return parsed === null ? void 0 : {
|
|
258
|
+
x: Number(parsed[1]),
|
|
259
|
+
y: Number(parsed[2])
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
/** A slot named for the field it fills, such as `email`, unique within the plan. */
|
|
263
|
+
const slotFor = (taken, field) => {
|
|
264
|
+
const base = field?.toLowerCase().match(/[\p{L}\p{N}]+/gu)?.join("-") ?? "input";
|
|
265
|
+
let slot = base;
|
|
266
|
+
for (let count = 2; taken.has(slot); count++) slot = `${base}-${count}`;
|
|
267
|
+
taken.add(slot);
|
|
268
|
+
return slot;
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* The walk one page's events record: the completed actions of the page that acted first, in
|
|
272
|
+
* order. `page.recentEvents` gives them, or `browser.events()` read until the walk ends.
|
|
273
|
+
*/
|
|
274
|
+
const fromEvents = (events) => {
|
|
275
|
+
const all = Array.from(events);
|
|
276
|
+
const page = all.find((event) => event._tag === "Action")?.page;
|
|
277
|
+
const mine = all.filter((event) => "page" in event && event.page === page);
|
|
278
|
+
const steps = mine.filter(isStep);
|
|
279
|
+
const opened = mine.find((event) => event._tag === "PageOpened")?.url ?? "";
|
|
280
|
+
const moves = mine.filter((event) => event._tag === "Navigated");
|
|
281
|
+
const taken = /* @__PURE__ */ new Set();
|
|
282
|
+
const before = (time) => moves.findLast((move) => move.at <= time)?.url ?? opened;
|
|
283
|
+
return new Plan({
|
|
284
|
+
version: 1,
|
|
285
|
+
steps: steps.map((action, index) => {
|
|
286
|
+
const drag = action.name === "drag" ? (action.target ?? "").split(" -> ") : void 0;
|
|
287
|
+
const point = pointIn(drag === void 0 ? action.target : drag[0]);
|
|
288
|
+
const until = steps[index + 1]?.startedAt ?? Number.POSITIVE_INFINITY;
|
|
289
|
+
const arrival = moves.findLast((move) => move.at > action.at && move.at <= until);
|
|
290
|
+
return new Step({
|
|
291
|
+
action: action.name,
|
|
292
|
+
url: arrival?.url ?? action.url ?? before(until),
|
|
293
|
+
target: action.name === "navigate" || action.name === "press" ? action.target : void 0,
|
|
294
|
+
subject: action.subject,
|
|
295
|
+
to: action.to,
|
|
296
|
+
point,
|
|
297
|
+
toPoint: pointIn(drag?.[1]),
|
|
298
|
+
box: point === void 0 ? void 0 : action.box,
|
|
299
|
+
input: action.name === "type" ? slotFor(taken, action.subject?.name) : action.name === "navigate" && action.target?.includes(redacted) === true ? slotFor(taken, "address") : void 0,
|
|
300
|
+
secret: action.name === "type" && action.text === redacted ? true : void 0,
|
|
301
|
+
options: action.options
|
|
302
|
+
});
|
|
303
|
+
})
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* The one element on the page that a subject names, by role, name and context (see `Plan`),
|
|
308
|
+
* looking again for two seconds while the page may still be drawing it.
|
|
309
|
+
*/
|
|
310
|
+
const locate = (page, subject) => page.find({
|
|
311
|
+
name: subject.name,
|
|
312
|
+
scope: "document",
|
|
313
|
+
...subject.role === null ? {} : { role: subject.role }
|
|
314
|
+
}).pipe(Effect.flatMap((found) => choose(subject, found)), Effect.retry({
|
|
315
|
+
schedule: Schedule.spaced(Duration.millis(250)),
|
|
316
|
+
times: 8,
|
|
317
|
+
while: (error) => error._tag !== "BrowserError"
|
|
318
|
+
}), Effect.withSpan("Plan.locate", { attributes: { role: subject.role ?? "" } }));
|
|
319
|
+
const invalid = (detail) => undispatched("replay", new InvalidRequest({ detail }));
|
|
320
|
+
/**
|
|
321
|
+
* Where the step acts: the element its subject names, or, for a step recorded at a point, the same
|
|
322
|
+
* place within that element, as long as a press there reaches that element and not one over it.
|
|
323
|
+
* An element out of view is first brought into it, by hovering it, as a press by ref would be.
|
|
324
|
+
*/
|
|
325
|
+
const aim = (page, subject, point, recorded) => {
|
|
326
|
+
if (subject === void 0) return Effect.fail(invalid("the step names no element"));
|
|
327
|
+
if (point === void 0) return Effect.map(locate(page, subject), ({ ref }) => ref);
|
|
328
|
+
const reach = ({ ref, box }) => {
|
|
329
|
+
const at = recorded === void 0 || recorded.width <= 0 || recorded.height <= 0 ? point : {
|
|
330
|
+
x: box.x + (point.x - recorded.x) / recorded.width * box.width,
|
|
331
|
+
y: box.y + (point.y - recorded.y) / recorded.height * box.height
|
|
332
|
+
};
|
|
333
|
+
return Effect.map(page.find({ at }), ([reached]) => reached?.ref === ref ? at : void 0);
|
|
334
|
+
};
|
|
335
|
+
const missed = new Drifted({ detail: "a press at the subject's point reaches another element" });
|
|
336
|
+
return locate(page, subject).pipe(Effect.flatMap((found) => Effect.flatMap(reach(found), (at) => at !== void 0 ? Effect.succeed(at) : page.hover(found.ref).pipe(Effect.andThen(locate(page, subject)), Effect.flatMap(reach), Effect.flatMap((again) => again === void 0 ? Effect.fail(missed) : Effect.succeed(again))))));
|
|
337
|
+
};
|
|
338
|
+
const dispatch = (page, step, text) => {
|
|
339
|
+
const options = step.options ?? {};
|
|
340
|
+
switch (step.action) {
|
|
341
|
+
case "navigate": return page.goto(step.input === void 0 ? step.target ?? step.url : text);
|
|
342
|
+
case "back": return page.back;
|
|
343
|
+
case "reload": return page.reload;
|
|
344
|
+
case "press": return step.subject === void 0 ? page.press(step.target ?? "", options) : Effect.flatMap(locate(page, step.subject), ({ ref }) => page.press(step.target ?? "", {
|
|
345
|
+
...options,
|
|
346
|
+
on: ref
|
|
347
|
+
}));
|
|
348
|
+
case "click": return aim(page, step.subject, step.point, step.box).pipe(Effect.flatMap((at) => page.click(at, options)), Effect.asVoid);
|
|
349
|
+
case "hover": return Effect.flatMap(aim(page, step.subject, step.point, step.box), page.hover);
|
|
350
|
+
case "drag": return Effect.all([aim(page, step.subject, step.point), aim(page, step.to, step.toPoint)]).pipe(Effect.flatMap(([from, to]) => page.drag(from, to)));
|
|
351
|
+
case "select": return aim(page, step.subject).pipe(Effect.flatMap((at) => page.select(typeof at === "string" ? at : "", options.values ?? [])), Effect.asVoid);
|
|
352
|
+
case "scroll": return step.subject === void 0 ? page.scroll(options) : Effect.flatMap(aim(page, step.subject, step.point, step.box), (at) => page.scroll({
|
|
353
|
+
...options,
|
|
354
|
+
at
|
|
355
|
+
}));
|
|
356
|
+
case "type": return step.subject === void 0 ? page.type(text, {
|
|
357
|
+
...options,
|
|
358
|
+
secret: step.secret
|
|
359
|
+
}) : Effect.flatMap(aim(page, step.subject), (into) => page.type(text, {
|
|
360
|
+
...options,
|
|
361
|
+
into: typeof into === "string" ? into : void 0,
|
|
362
|
+
secret: step.secret
|
|
363
|
+
}));
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* Input that can be repeated without repeating a commitment. `take` also validates a Checked
|
|
368
|
+
* target's boolean state before input. Back/reload can resubmit a form.
|
|
369
|
+
*/
|
|
370
|
+
const repeatable = (step) => [
|
|
371
|
+
"navigate",
|
|
372
|
+
"hover",
|
|
373
|
+
"scroll",
|
|
374
|
+
"select"
|
|
375
|
+
].includes(step.action) || step.action === "type" && step.subject !== void 0 && step.options?.replace !== false && step.options?.submit !== true || step.action === "click" && step.expect?._tag === "Checked";
|
|
376
|
+
const within = (check, millis) => millis === 0 ? check : check.pipe(Effect.repeat({
|
|
377
|
+
until: (held) => held,
|
|
378
|
+
schedule: Schedule.spaced(Duration.millis(25))
|
|
379
|
+
}), Effect.timeoutOrElse({
|
|
380
|
+
duration: Duration.millis(millis),
|
|
381
|
+
orElse: () => Effect.succeed(false)
|
|
382
|
+
}));
|
|
383
|
+
const sameSite = (url, recorded) => {
|
|
384
|
+
const origin = URL.parse(recorded)?.origin;
|
|
385
|
+
return recorded === "" || (origin === void 0 || origin === "null" ? url === recorded : URL.parse(url)?.origin === origin);
|
|
386
|
+
};
|
|
387
|
+
const arrived = (page, urls, millis) => within(Effect.map(page.url, (url) => urls.some((recorded) => sameSite(url, recorded))), millis).pipe(Effect.filterOrFail((held) => held, () => new Drifted({ detail: "the page did not reach the recorded site within the arrival wait" })), Effect.asVoid);
|
|
388
|
+
const checkEffect = (page, step, first) => {
|
|
389
|
+
const expected = step.expect;
|
|
390
|
+
if (expected === void 0) return Effect.succeed(false);
|
|
391
|
+
switch (expected._tag) {
|
|
392
|
+
case "Checked": return step.subject === void 0 ? Effect.fail(invalid("a checked effect needs a subject")) : Effect.flatMap(locate(page, step.subject), (found) => found.state.checked === void 0 ? Effect.fail(invalid("a checked effect needs a checkable subject")) : Effect.succeed(found.state.checked === expected.checked));
|
|
393
|
+
case "Navigated": return Effect.map(page.state, (now) => expected.url === void 0 ? now.url !== first.url || now.document !== first.document : now.url === expected.url);
|
|
394
|
+
case "Appeared":
|
|
395
|
+
case "Gone": return Effect.map(page.find({
|
|
396
|
+
...expected.query,
|
|
397
|
+
scope: "document"
|
|
398
|
+
}), (found) => expected._tag === "Appeared" ? found.length > 0 : found.length === 0);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
/**
|
|
402
|
+
* Take one step. Unknown non-repeatable input is never resent: only positive durable read-back
|
|
403
|
+
* can skip it. An interrupted call remains interrupted; persist begun-before-call in the consumer
|
|
404
|
+
* and treat a missing receipt as Stopped{input: "unknown"}, including after process restart.
|
|
405
|
+
*/
|
|
406
|
+
const take = Effect.fn("Plan.take")(function* (page, plan, at, options = {}) {
|
|
407
|
+
const index = typeof at === "number" ? at : at.step;
|
|
408
|
+
let input = typeof at === "number" ? "unsent" : at.input;
|
|
409
|
+
return yield* Effect.gen(function* () {
|
|
410
|
+
const step = plan.steps[index];
|
|
411
|
+
if (!Number.isInteger(index) || index < 0 || step === void 0) return yield* invalid("the step index is outside the plan");
|
|
412
|
+
const duration = Duration.fromInput(options.arrival ?? Duration.seconds(5));
|
|
413
|
+
if (Option.isNone(duration) || Duration.isNegative(duration.value) || !Duration.isFinite(duration.value)) return yield* invalid("arrival must be a finite nonnegative duration");
|
|
414
|
+
const millis = Duration.toMillis(duration.value);
|
|
415
|
+
const first = yield* page.state;
|
|
416
|
+
const uncertain = new Uncertain({ detail: "the step may have been sent; reconcile its durable effect before continuing" });
|
|
417
|
+
const unresolved = input === "unknown" && !repeatable(step);
|
|
418
|
+
const expected = step.expect;
|
|
419
|
+
if (unresolved && (expected === void 0 || expected._tag === "Checked" || expected.durable !== true)) return yield* uncertain;
|
|
420
|
+
const settle = options.settle === false ? Effect.void : page.ready(options.settle);
|
|
421
|
+
if (![
|
|
422
|
+
"navigate",
|
|
423
|
+
"back",
|
|
424
|
+
"reload"
|
|
425
|
+
].includes(step.action)) yield* settle;
|
|
426
|
+
const before = plan.steps[index - 1]?.url;
|
|
427
|
+
if (before !== void 0) yield* arrived(page, unresolved ? [before, step.url] : [before], millis);
|
|
428
|
+
const check = checkEffect(page, step, first);
|
|
429
|
+
const held = yield* (millis === 0 ? check : check.pipe(Effect.timeoutOrElse({
|
|
430
|
+
duration: Duration.millis(millis),
|
|
431
|
+
orElse: () => Effect.fail(new Drifted({ detail: "the expected-effect read timed out" }))
|
|
432
|
+
}))).pipe(Effect.mapError((error) => unresolved ? uncertain : error));
|
|
433
|
+
const receipt = (outcome) => Effect.gen(function* () {
|
|
434
|
+
if (index === plan.steps.length - 1) yield* settle;
|
|
435
|
+
yield* arrived(page, [step.url], millis);
|
|
436
|
+
const now = yield* page.state;
|
|
437
|
+
return new Receipt({
|
|
438
|
+
step: index,
|
|
439
|
+
outcome,
|
|
440
|
+
startedAt: first.at,
|
|
441
|
+
at: now.at
|
|
442
|
+
});
|
|
443
|
+
});
|
|
444
|
+
if (held) return yield* receipt("skipped");
|
|
445
|
+
if (unresolved) return yield* uncertain;
|
|
446
|
+
const text = step.input === void 0 ? "" : options.inputs?.[step.input];
|
|
447
|
+
if (text === void 0) return yield* invalid(`no text for the input "${step.input ?? ""}"`);
|
|
448
|
+
const acted = yield* Effect.exit(dispatch(page, step, text));
|
|
449
|
+
if (Exit.isFailure(acted)) {
|
|
450
|
+
const error = Exit.findErrorOption(acted);
|
|
451
|
+
if (Option.isSome(error) && error.value._tag === "BrowserError" && error.value.dispatched) {
|
|
452
|
+
input = "unknown";
|
|
453
|
+
if (expected !== void 0 && (repeatable(step) || expected._tag !== "Checked" && expected.durable === true)) {
|
|
454
|
+
const observed = yield* Effect.exit(within(check, millis));
|
|
455
|
+
if (Exit.isSuccess(observed) && observed.value) return yield* receipt("verified");
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return yield* Effect.failCause(acted.cause);
|
|
459
|
+
}
|
|
460
|
+
input = "unknown";
|
|
461
|
+
if (expected !== void 0 && !(yield* within(check, millis))) return yield* new Drifted({ detail: "the step's expected effect did not arrive" });
|
|
462
|
+
return yield* receipt(expected === void 0 ? "taken" : "verified");
|
|
463
|
+
}).pipe(Effect.mapError((reason) => new ReplayError({
|
|
464
|
+
step: index,
|
|
465
|
+
reason,
|
|
466
|
+
input,
|
|
467
|
+
receipts: []
|
|
468
|
+
})));
|
|
469
|
+
});
|
|
470
|
+
const run = Effect.fnUntraced(function* (page, plan, options, from, until, restoring) {
|
|
471
|
+
const receipts = [];
|
|
472
|
+
const start = typeof from === "number" ? from : from.step;
|
|
473
|
+
if (!Number.isInteger(start) || start < 0 || start > plan.steps.length || !Number.isInteger(until) || until < start || until > plan.steps.length) return yield* new ReplayError({
|
|
474
|
+
step: start,
|
|
475
|
+
input: "unsent",
|
|
476
|
+
receipts,
|
|
477
|
+
reason: invalid("the run bounds are outside the plan")
|
|
478
|
+
});
|
|
479
|
+
if (!restoring && typeof from === "number") {
|
|
480
|
+
const unfilled = plan.steps.findIndex((step, index) => index >= start && step.input !== void 0 && options.inputs?.[step.input] === void 0);
|
|
481
|
+
if (unfilled !== -1) return yield* new ReplayError({
|
|
482
|
+
step: start,
|
|
483
|
+
input: "unsent",
|
|
484
|
+
receipts,
|
|
485
|
+
reason: invalid(`no text for the input "${plan.steps[unfilled]?.input ?? ""}"`)
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
for (let index = start; index < until; index++) {
|
|
489
|
+
const at = restoring ? new Stopped({
|
|
490
|
+
step: index,
|
|
491
|
+
input: "unknown"
|
|
492
|
+
}) : index === start ? from : index;
|
|
493
|
+
const receipt = yield* take(page, plan, at, options).pipe(Effect.mapError((error) => new ReplayError({
|
|
494
|
+
...error,
|
|
495
|
+
receipts: [...receipts]
|
|
496
|
+
})));
|
|
497
|
+
receipts.push(receipt);
|
|
498
|
+
}
|
|
499
|
+
return receipts;
|
|
500
|
+
});
|
|
501
|
+
/** Take a plan's steps from a fresh index or durable stopping point, returning completed receipts. */
|
|
502
|
+
const replay = (page, plan, options = {}) => run(page, plan, options, options.from ?? 0, plan.steps.length, false).pipe(Effect.withSpan("Plan.replay"));
|
|
503
|
+
/** Restore prior steps on a fresh page; unresolved commitments require positive durable evidence. */
|
|
504
|
+
const restore = (page, plan, options = {}) => run(page, plan, options, 0, options.upTo ?? plan.steps.length, true).pipe(Effect.withSpan("Plan.restore"));
|
|
505
|
+
//#endregion
|
|
506
|
+
export { Drifted as _, ReplayError as a, Stopped as c, locate as d, repeatable as f, Ambiguous as g, take as h, Receipt as i, Uncertain as l, restore as m, Plan as n, Step as o, replay as p, Plan_exports as r, StepAction as s, Expected as t, fromEvents as u, Missing as v };
|
|
507
|
+
|
|
508
|
+
//# sourceMappingURL=Plan-D1wrJVs8.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Plan-D1wrJVs8.mjs","names":[],"sources":["../src/internal/reading/choose.ts","../src/Plan.ts"],"sourcesContent":["/**\n * Choosing the one element a recorded subject names, among those `find` gives for its role and\n * name. Context tells them apart, and an element that does not repeat every part of the recorded\n * context is another subject, so a sole element left once its own has gone, such as Alice's\n * \"Remove\" after Bob has left, drifts rather than stands in:\n *\n * - a row is read whole: a row named \"Wrapped BTC\" is not the row \"BTC\". Laid out again without\n * rows, as cards, one of the element's fields must start with the row's words;\n * - a column counts where the element is under one;\n * - a label or heading must read the same, or its words appear, whole and in order, in one of the\n * element's fields, as `near` reads them.\n *\n * The rest are ranked by how much of the recorded context they read the same. There is no\n * ordinal, so a tie stays a tie.\n */\nimport { Effect, Schema } from \"effect\";\n\nimport type { Subject, SubjectContext } from \"../../BrowserEvent.ts\";\nimport type { Found } from \"../../Page.ts\";\nimport { match } from \"./match.inpage.ts\";\n\n/** Nothing on the page has the step's role and name. */\nexport class Missing extends Schema.TaggedError<Missing>()(\"Missing\", {}) {\n override get message() {\n return \"nothing on the page has the recorded role and name\";\n }\n}\n\n/** Several elements match the step's subject equally well, and nothing tells them apart. */\nexport class Ambiguous extends Schema.TaggedError<Ambiguous>()(\"Ambiguous\", {\n count: Schema.Int,\n}) {\n override get message() {\n return `${this.count} elements match the recorded subject equally well`;\n }\n}\n\n/** The page is not where the recording was: another site, or no element with its context. */\nexport class Drifted extends Schema.TaggedError<Drifted>()(\"Drifted\", {\n detail: Schema.String,\n}) {\n override get message() {\n return this.detail;\n }\n}\n\nconst { holds, normalize } = match();\nconst fields = [\"row\", \"column\", \"label\", \"heading\"] as const;\n\nconst said = (context: SubjectContext) =>\n Object.values(context).filter((value) => typeof value === \"string\");\n\n/** How an element repeats one recorded field: 2 read the same, 1 found as words, 0 not at all. */\nconst repeats = (field: (typeof fields)[number], value: string, context: SubjectContext) => {\n const own = context[field];\n\n if (own !== undefined && normalize(own) === normalize(value)) return 2;\n if (field === \"column\") return own === undefined ? 1 : 0;\n if (field === \"row\")\n return own === undefined &&\n said(context).some((other) => `${normalize(other)} `.startsWith(`${normalize(value)} `))\n ? 1\n : 0;\n\n return said(context).some((other) => holds(other, value)) ? 1 : 0;\n};\n\nexport const choose = (\n subject: Subject,\n found: ReadonlyArray<Found>,\n): Effect.Effect<Found, Missing | Ambiguous | Drifted> => {\n // `find` matched the role; a subject without one only matches elements without one.\n const named = found.filter((one) => subject.role !== null || one.subject.role === null);\n\n const kept = named.flatMap((one) => {\n let score = 0;\n\n for (const field of fields) {\n const value = subject.context[field];\n const repeated = value === undefined ? 0 : repeats(field, value, one.subject.context);\n\n if (value !== undefined && repeated === 0) return [];\n score += repeated;\n }\n\n return [{ one, score }];\n });\n\n const best = Math.max(...kept.map(({ score }) => score));\n const top = kept.filter(({ score }) => score === best);\n const [only] = top;\n\n if (named.length === 0) return Effect.fail(new Missing());\n if (kept.length === 0)\n return Effect.fail(new Drifted({ detail: \"no element named so repeats the recorded context\" }));\n\n return top.length === 1 && only !== undefined\n ? Effect.succeed(only.one)\n : Effect.fail(new Ambiguous({ count: top.length }));\n};\n","/**\n * A walk recorded once from a page's events and replayed later, on a fresh page, with no model\n * call.\n *\n * `fromEvents` keeps one page's completed actions with their subjects and the options they were\n * given, its navigations with both the address asked for and the one reached, and what was typed\n * as a named input slot, never the text itself. A navigation to an address whose credentials the\n * events withheld is an input slot too, so replay goes where the caller says, or nowhere, and\n * never to the address without them. `replay` takes the steps in turn. Before a step\n * that acts on the page, it waits for `Page.ready`; then it finds the one element the step's\n * subject names, by role and name among those that repeat all its recorded context, and acts on\n * it. Text typed into focus was typed into the focused field, which replay finds the same way, and\n * text typed into a secret field goes into nothing else. An element step never falls back to\n * coordinates, and a step recorded at a point acts there only while the element found for it still\n * covers that point. `take` and `replay` return receipts; failure preserves a stopping point and\n * earlier receipts. Unknown consequential input is never resent. Only a positive durable read-back\n * can reconcile it; restoration follows the same rule. The consumer journals begun steps before\n * calling, treating interruption or a missing receipt as unknown. Plain recordings use version 1;\n * authored expected effects use version 2. Old 0.2 plans and unknown versions do not decode.\n *\n * @since 0.3.0\n */\nimport { Duration, Effect, Exit, Option, Schedule, Schema } from \"effect\";\n\nimport { BrowserError, InvalidRequest } from \"./BrowserError.ts\";\nimport {\n type Action,\n ActionOptions,\n Box,\n type BrowserEvent,\n type Navigated,\n Subject,\n} from \"./BrowserEvent.ts\";\nimport { undispatched } from \"./internal/page/context.ts\";\nimport { Ambiguous, choose, Drifted, Missing } from \"./internal/reading/choose.ts\";\nimport {\n type Found,\n type Page,\n type Point,\n type ReadyOptions,\n redacted,\n type Target,\n} from \"./Page.ts\";\n\nexport { Ambiguous, Drifted, Missing } from \"./internal/reading/choose.ts\";\n\nconst ViewportPoint = Schema.Struct({ x: Schema.Finite, y: Schema.Finite });\n\nexport const StepAction = Schema.Literals([\n \"navigate\",\n \"back\",\n \"reload\",\n \"click\",\n \"hover\",\n \"drag\",\n \"type\",\n \"press\",\n \"scroll\",\n \"select\",\n]);\n\nexport type StepAction = typeof StepAction.Type;\n\nconst Query = Schema.Struct({\n role: Schema.optional(Schema.String),\n name: Schema.optional(Schema.String),\n text: Schema.optional(Schema.String),\n});\n\n/**\n * What a step leaves. `durable` asserts an author-chosen, lasting read-back of this operation,\n * such as its uniquely named saved receipt. A toast or an intermediate address is not durable.\n * Even a durable check's absence never authorizes repeating unknown consequential input.\n */\nexport const Expected = Schema.Union([\n Schema.TaggedStruct(\"Checked\", { checked: Schema.Boolean }),\n Schema.TaggedStruct(\"Appeared\", {\n query: Query,\n durable: Schema.optional(Schema.Literal(true)),\n }),\n Schema.TaggedStruct(\"Gone\", {\n query: Query,\n durable: Schema.optional(Schema.Literal(true)),\n }),\n Schema.TaggedStruct(\"Navigated\", {\n url: Schema.optional(Schema.String),\n durable: Schema.optional(Schema.Literal(true)),\n }),\n]);\n\nexport type Expected = typeof Expected.Type;\n\n/** One recorded step: the action, what it acted on, and what else it was asked. */\nexport class Step extends Schema.Class<Step>(\"effect-browser/Plan/Step\")({\n action: StepAction,\n /**\n * The ending address, or a later recorded navigation before the next action began. Empty when\n * unknown; a delayed navigation can be stronger arrival evidence than the action's ending URL.\n */\n url: Schema.String,\n /** A navigation's requested address, or the keys a press pressed. */\n target: Schema.optional(Schema.String),\n subject: Schema.optional(Subject),\n /** Where a drag ended. */\n to: Schema.optional(Subject),\n /** The viewport point a step aimed at, when it aimed at a point, and a drag's end point. */\n point: Schema.optional(ViewportPoint),\n toPoint: Schema.optional(ViewportPoint),\n /** The box of what a step aimed at by point found there, so replay aims at the same place in it. */\n box: Schema.optional(Box),\n /**\n * The input slot whose text a `type` step types, or whose address a `navigate` step goes to, as\n * its recorded address had a credential withheld.\n */\n input: Schema.optional(Schema.String),\n /** The slot's text went into a secret field, so replay types it into nothing else. */\n secret: Schema.optional(Schema.Literal(true)),\n options: Schema.optional(ActionOptions),\n expect: Schema.optional(Expected),\n}) {}\n\nconst PlanData = Schema.Struct({\n version: Schema.Literals([1, 2]),\n steps: Schema.Array(Step),\n}).check(\n Schema.makeFilter((plan) =>\n plan.version === (plan.steps.some((step) => step.expect !== undefined) ? 2 : 1)\n ? undefined\n : \"only plans with expected effects use version 2\",\n ),\n);\n\nexport class Plan extends Schema.Class<Plan>(\"effect-browser/Plan\")(PlanData) {\n /** Choose the encoding version from the steps; simple recordings remain version 1. */\n static new(steps: ReadonlyArray<Step>): Plan {\n return new Plan({ version: steps.some((step) => step.expect !== undefined) ? 2 : 1, steps });\n }\n\n /** The input slots its steps type, in order; replay needs text for each. */\n get inputs(): ReadonlyArray<string> {\n return this.steps.flatMap((step) => (step.input === undefined ? [] : [step.input]));\n }\n}\n\n/** One completed step, on the page's host clock. `verified` means its expected effect was seen. */\nexport class Receipt extends Schema.Class<Receipt>(\"effect-browser/Plan/Receipt\")({\n step: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n outcome: Schema.Literals([\"taken\", \"verified\", \"skipped\"]),\n startedAt: Schema.Finite,\n at: Schema.Finite,\n}) {}\n\n/** Durable stopping data. A begun step without a receipt must be restored as `unknown`. */\nexport class Stopped extends Schema.Class<Stopped>(\"effect-browser/Plan/Stopped\")({\n step: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n input: Schema.Literals([\"unsent\", \"unknown\"]),\n}) {}\n\n/** Repeating this step could repeat an unresolved effect; the consumer must reconcile it. */\nexport class Uncertain extends Schema.TaggedError<Uncertain>()(\"Uncertain\", {\n detail: Schema.String,\n}) {\n override get message() {\n return this.detail;\n }\n}\n\n/** Where replay stopped, counting steps from 0, why, and the steps that completed before it. */\nexport class ReplayError extends Schema.TaggedError<ReplayError>()(\"ReplayError\", {\n step: Schema.Int,\n reason: Schema.Union([Missing, Ambiguous, Drifted, BrowserError, Uncertain]),\n input: Schema.Literals([\"unsent\", \"unknown\"]),\n receipts: Schema.Array(Receipt),\n}) {\n get stopped(): Stopped {\n return new Stopped({ step: this.step, input: this.input });\n }\n\n override get message() {\n return `step ${this.step} failed: ${this.reason.message}`;\n }\n}\n\nconst isStep = (event: BrowserEvent): event is Action & { readonly name: StepAction } =>\n event._tag === \"Action\" &&\n event.ok &&\n (StepAction.literals as ReadonlyArray<string>).includes(event.name);\n\n// A point target reads `x,y`, as `{\"x\":…,\"y\":…}` inside a drag's; a ref reads like e12.\nconst pointIn = (target: string | undefined): Point | undefined => {\n const parsed = /^\\{?(?:\"x\":)?(-?[\\d.]+),(?:\"y\":)?(-?[\\d.]+)\\}?$/.exec(target ?? \"\");\n\n return parsed === null ? undefined : { x: Number(parsed[1]), y: Number(parsed[2]) };\n};\n\n/** A slot named for the field it fills, such as `email`, unique within the plan. */\nconst slotFor = (taken: Set<string>, field: string | undefined) => {\n const base =\n field\n ?.toLowerCase()\n .match(/[\\p{L}\\p{N}]+/gu)\n ?.join(\"-\") ?? \"input\";\n\n let slot = base;\n\n for (let count = 2; taken.has(slot); count++) slot = `${base}-${count}`;\n taken.add(slot);\n\n return slot;\n};\n\n/**\n * The walk one page's events record: the completed actions of the page that acted first, in\n * order. `page.recentEvents` gives them, or `browser.events()` read until the walk ends.\n */\nexport const fromEvents = (events: Iterable<BrowserEvent>): Plan => {\n const all = Array.from(events);\n const page = all.find((event) => event._tag === \"Action\")?.page;\n const mine = all.filter((event) => \"page\" in event && event.page === page);\n const steps = mine.filter(isStep);\n const opened = mine.find((event) => event._tag === \"PageOpened\")?.url ?? \"\";\n const moves = mine.filter((event): event is Navigated => event._tag === \"Navigated\");\n const taken = new Set<string>();\n\n // Where the page was just before a time: the last address it reached by then.\n const before = (time: number) => moves.findLast((move) => move.at <= time)?.url ?? opened;\n\n return new Plan({\n version: 1,\n steps: steps.map((action, index) => {\n const drag = action.name === \"drag\" ? (action.target ?? \"\").split(\" -> \") : undefined;\n const point = pointIn(drag === undefined ? action.target : drag[0]);\n const until = steps[index + 1]?.startedAt ?? Number.POSITIVE_INFINITY;\n const arrival = moves.findLast((move) => move.at > action.at && move.at <= until);\n\n // Only a navigation and a press keep their target: an address, or keys.\n return new Step({\n action: action.name,\n url: arrival?.url ?? action.url ?? before(until),\n target: action.name === \"navigate\" || action.name === \"press\" ? action.target : undefined,\n subject: action.subject,\n to: action.to,\n point,\n toPoint: pointIn(drag?.[1]),\n box: point === undefined ? undefined : action.box,\n input:\n action.name === \"type\"\n ? slotFor(taken, action.subject?.name)\n : action.name === \"navigate\" && action.target?.includes(redacted) === true\n ? slotFor(taken, \"address\")\n : undefined,\n secret: action.name === \"type\" && action.text === redacted ? true : undefined,\n options: action.options,\n });\n }),\n });\n};\n\n/**\n * The one element on the page that a subject names, by role, name and context (see `Plan`),\n * looking again for two seconds while the page may still be drawing it.\n */\nexport const locate = (page: Page, subject: Subject) =>\n page\n .find({\n name: subject.name,\n scope: \"document\",\n ...(subject.role === null ? {} : { role: subject.role }),\n })\n .pipe(\n Effect.flatMap((found) => choose(subject, found)),\n Effect.retry({\n schedule: Schedule.spaced(Duration.millis(250)),\n times: 8,\n while: (error) => error._tag !== \"BrowserError\",\n }),\n Effect.withSpan(\"Plan.locate\", { attributes: { role: subject.role ?? \"\" } }),\n );\n\nconst invalid = (detail: string) => undispatched(\"replay\", new InvalidRequest({ detail }));\n\n/**\n * Where the step acts: the element its subject names, or, for a step recorded at a point, the same\n * place within that element, as long as a press there reaches that element and not one over it.\n * An element out of view is first brought into it, by hovering it, as a press by ref would be.\n */\nconst aim = (page: Page, subject: Subject | undefined, point?: Point, recorded?: Box) => {\n if (subject === undefined) return Effect.fail(invalid(\"the step names no element\"));\n if (point === undefined) return Effect.map(locate(page, subject), ({ ref }): Target => ref);\n\n const reach = ({ ref, box }: Found) => {\n const at =\n recorded === undefined || recorded.width <= 0 || recorded.height <= 0\n ? point\n : {\n x: box.x + ((point.x - recorded.x) / recorded.width) * box.width,\n y: box.y + ((point.y - recorded.y) / recorded.height) * box.height,\n };\n\n return Effect.map(page.find({ at }), ([reached]) => (reached?.ref === ref ? at : undefined));\n };\n\n const missed = new Drifted({ detail: \"a press at the subject's point reaches another element\" });\n\n return locate(page, subject).pipe(\n Effect.flatMap((found) =>\n Effect.flatMap(reach(found), (at) =>\n at !== undefined\n ? Effect.succeed<Target>(at)\n : page.hover(found.ref).pipe(\n Effect.andThen(locate(page, subject)),\n Effect.flatMap(reach),\n Effect.flatMap((again) =>\n again === undefined ? Effect.fail(missed) : Effect.succeed<Target>(again),\n ),\n ),\n ),\n ),\n );\n};\n\nconst dispatch = (\n page: Page,\n step: Step,\n text: string,\n): Effect.Effect<void, Missing | Ambiguous | Drifted | BrowserError> => {\n const options = step.options ?? {};\n\n switch (step.action) {\n case \"navigate\":\n return page.goto(step.input === undefined ? (step.target ?? step.url) : text);\n case \"back\":\n return page.back;\n case \"reload\":\n return page.reload;\n case \"press\":\n return step.subject === undefined\n ? page.press(step.target ?? \"\", options)\n : Effect.flatMap(locate(page, step.subject), ({ ref }) =>\n page.press(step.target ?? \"\", { ...options, on: ref }),\n );\n case \"click\":\n return aim(page, step.subject, step.point, step.box).pipe(\n Effect.flatMap((at) => page.click(at, options)),\n Effect.asVoid,\n );\n case \"hover\":\n return Effect.flatMap(aim(page, step.subject, step.point, step.box), page.hover);\n case \"drag\":\n return Effect.all([\n aim(page, step.subject, step.point),\n aim(page, step.to, step.toPoint),\n ]).pipe(Effect.flatMap(([from, to]) => page.drag(from, to)));\n case \"select\":\n return aim(page, step.subject).pipe(\n Effect.flatMap((at) => page.select(typeof at === \"string\" ? at : \"\", options.values ?? [])),\n Effect.asVoid,\n );\n // A scroll or a typing step may name no element: the page, or whatever has focus.\n case \"scroll\":\n return step.subject === undefined\n ? page.scroll(options)\n : Effect.flatMap(aim(page, step.subject, step.point, step.box), (at) =>\n page.scroll({ ...options, at }),\n );\n case \"type\":\n return step.subject === undefined\n ? page.type(text, { ...options, secret: step.secret })\n : Effect.flatMap(aim(page, step.subject), (into) =>\n page.type(text, {\n ...options,\n into: typeof into === \"string\" ? into : undefined,\n secret: step.secret,\n }),\n );\n }\n};\n\nexport interface TakeOptions {\n /** How each step waits for the page first, or false not to wait. */\n readonly settle?: ReadyOptions | false | undefined;\n readonly inputs?: Readonly<Record<string, string>> | undefined;\n /**\n * Bound for recorded arrival and expected effect, each. Defaults to 5 seconds. Zero makes one\n * read without polling; that read retains the page operation's timeout.\n */\n readonly arrival?: Duration.Input | undefined;\n}\n\nexport interface ReplayOptions extends TakeOptions {\n readonly from?: number | Stopped | undefined;\n}\n\n/**\n * Input that can be repeated without repeating a commitment. `take` also validates a Checked\n * target's boolean state before input. Back/reload can resubmit a form.\n */\nexport const repeatable = (step: Step): boolean =>\n [\"navigate\", \"hover\", \"scroll\", \"select\"].includes(step.action) ||\n (step.action === \"type\" &&\n step.subject !== undefined &&\n step.options?.replace !== false &&\n step.options?.submit !== true) ||\n (step.action === \"click\" && step.expect?._tag === \"Checked\");\n\ntype StepError = Missing | Ambiguous | Drifted | BrowserError | Uncertain;\n\n// Zero waits make one read; positive waits bound all reads and never repeat input.\nconst within = (check: Effect.Effect<boolean, StepError>, millis: number) =>\n millis === 0\n ? check\n : check.pipe(\n Effect.repeat({ until: (held) => held, schedule: Schedule.spaced(Duration.millis(25)) }),\n Effect.timeoutOrElse({\n duration: Duration.millis(millis),\n orElse: () => Effect.succeed(false),\n }),\n );\n\nconst sameSite = (url: string, recorded: string) => {\n const origin = URL.parse(recorded)?.origin;\n\n return (\n recorded === \"\" ||\n (origin === undefined || origin === \"null\"\n ? url === recorded\n : URL.parse(url)?.origin === origin)\n );\n};\n\nconst arrived = (page: Page, urls: ReadonlyArray<string>, millis: number) =>\n within(\n Effect.map(page.url, (url) => urls.some((recorded) => sameSite(url, recorded))),\n millis,\n ).pipe(\n Effect.filterOrFail(\n (held) => held,\n () =>\n new Drifted({ detail: \"the page did not reach the recorded site within the arrival wait\" }),\n ),\n Effect.asVoid,\n );\n\nconst checkEffect = (\n page: Page,\n step: Step,\n first: { readonly url: string; readonly document: number },\n) => {\n const expected = step.expect;\n\n if (expected === undefined) return Effect.succeed(false);\n switch (expected._tag) {\n case \"Checked\":\n return step.subject === undefined\n ? Effect.fail(invalid(\"a checked effect needs a subject\"))\n : Effect.flatMap(locate(page, step.subject), (found) =>\n found.state.checked === undefined\n ? Effect.fail(invalid(\"a checked effect needs a checkable subject\"))\n : Effect.succeed(found.state.checked === expected.checked),\n );\n case \"Navigated\":\n return Effect.map(page.state, (now) =>\n expected.url === undefined\n ? now.url !== first.url || now.document !== first.document\n : now.url === expected.url,\n );\n case \"Appeared\":\n case \"Gone\":\n return Effect.map(page.find({ ...expected.query, scope: \"document\" }), (found) =>\n expected._tag === \"Appeared\" ? found.length > 0 : found.length === 0,\n );\n }\n};\n\n/**\n * Take one step. Unknown non-repeatable input is never resent: only positive durable read-back\n * can skip it. An interrupted call remains interrupted; persist begun-before-call in the consumer\n * and treat a missing receipt as Stopped{input: \"unknown\"}, including after process restart.\n */\nexport const take = Effect.fn(\"Plan.take\")(function* (\n page: Page,\n plan: Plan,\n at: number | Stopped,\n options: TakeOptions = {},\n): Effect.fn.Return<Receipt, ReplayError> {\n const index = typeof at === \"number\" ? at : at.step;\n let input: Stopped[\"input\"] = typeof at === \"number\" ? \"unsent\" : at.input;\n\n const work = Effect.gen(function* (): Effect.fn.Return<Receipt, StepError> {\n const step = plan.steps[index];\n\n if (!Number.isInteger(index) || index < 0 || step === undefined)\n return yield* invalid(\"the step index is outside the plan\");\n const duration = Duration.fromInput(options.arrival ?? Duration.seconds(5));\n\n if (\n Option.isNone(duration) ||\n Duration.isNegative(duration.value) ||\n !Duration.isFinite(duration.value)\n )\n return yield* invalid(\"arrival must be a finite nonnegative duration\");\n const millis = Duration.toMillis(duration.value);\n const first = yield* page.state;\n\n const uncertain = new Uncertain({\n detail: \"the step may have been sent; reconcile its durable effect before continuing\",\n });\n\n const unresolved = input === \"unknown\" && !repeatable(step);\n const expected = step.expect;\n\n if (\n unresolved &&\n (expected === undefined || expected._tag === \"Checked\" || expected.durable !== true)\n )\n return yield* uncertain;\n const settle = options.settle === false ? Effect.void : page.ready(options.settle);\n\n if (![\"navigate\", \"back\", \"reload\"].includes(step.action)) yield* settle;\n const before = plan.steps[index - 1]?.url;\n\n if (before !== undefined)\n yield* arrived(page, unresolved ? [before, step.url] : [before], millis);\n const check = checkEffect(page, step, first);\n\n const read =\n millis === 0\n ? check\n : check.pipe(\n Effect.timeoutOrElse({\n duration: Duration.millis(millis),\n orElse: () =>\n Effect.fail(new Drifted({ detail: \"the expected-effect read timed out\" })),\n }),\n );\n\n const held = yield* read.pipe(Effect.mapError((error) => (unresolved ? uncertain : error)));\n\n const receipt = (outcome: Receipt[\"outcome\"]) =>\n Effect.gen(function* () {\n if (index === plan.steps.length - 1) yield* settle;\n yield* arrived(page, [step.url], millis);\n const now = yield* page.state;\n\n return new Receipt({ step: index, outcome, startedAt: first.at, at: now.at });\n });\n\n if (held) return yield* receipt(\"skipped\");\n if (unresolved) return yield* uncertain;\n const text = step.input === undefined ? \"\" : options.inputs?.[step.input];\n\n if (text === undefined) return yield* invalid(`no text for the input \"${step.input ?? \"\"}\"`);\n const acted = yield* Effect.exit(dispatch(page, step, text));\n\n if (Exit.isFailure(acted)) {\n const error = Exit.findErrorOption(acted);\n\n if (Option.isSome(error) && error.value._tag === \"BrowserError\" && error.value.dispatched) {\n input = \"unknown\";\n if (\n expected !== undefined &&\n (repeatable(step) || (expected._tag !== \"Checked\" && expected.durable === true))\n ) {\n const observed = yield* Effect.exit(within(check, millis));\n\n if (Exit.isSuccess(observed) && observed.value) return yield* receipt(\"verified\");\n }\n }\n\n return yield* Effect.failCause(acted.cause);\n }\n input = \"unknown\";\n if (expected !== undefined && !(yield* within(check, millis)))\n return yield* new Drifted({ detail: \"the step's expected effect did not arrive\" });\n\n return yield* receipt(expected === undefined ? \"taken\" : \"verified\");\n });\n\n return yield* work.pipe(\n Effect.mapError(\n (reason) =>\n new ReplayError({\n step: index,\n reason,\n input,\n receipts: [],\n }),\n ),\n );\n});\n\nconst run = Effect.fnUntraced(function* (\n page: Page,\n plan: Plan,\n options: TakeOptions,\n from: number | Stopped,\n until: number,\n restoring: boolean,\n) {\n const receipts: Array<Receipt> = [];\n const start = typeof from === \"number\" ? from : from.step;\n\n if (\n !Number.isInteger(start) ||\n start < 0 ||\n start > plan.steps.length ||\n !Number.isInteger(until) ||\n until < start ||\n until > plan.steps.length\n )\n return yield* new ReplayError({\n step: start,\n input: \"unsent\",\n receipts,\n reason: invalid(\"the run bounds are outside the plan\"),\n });\n // Fresh runs still ask for all input slots before changing the page. Restoration checks first.\n if (!restoring && typeof from === \"number\") {\n const unfilled = plan.steps.findIndex(\n (step, index) =>\n index >= start && step.input !== undefined && options.inputs?.[step.input] === undefined,\n );\n\n if (unfilled !== -1)\n return yield* new ReplayError({\n step: start,\n input: \"unsent\",\n receipts,\n reason: invalid(`no text for the input \"${plan.steps[unfilled]?.input ?? \"\"}\"`),\n });\n }\n for (let index = start; index < until; index++) {\n const at = restoring\n ? new Stopped({ step: index, input: \"unknown\" })\n : index === start\n ? from\n : index;\n\n const receipt = yield* take(page, plan, at, options).pipe(\n Effect.mapError((error) => new ReplayError({ ...error, receipts: [...receipts] })),\n );\n\n receipts.push(receipt);\n }\n\n return receipts;\n});\n\n/** Take a plan's steps from a fresh index or durable stopping point, returning completed receipts. */\nexport const replay = (page: Page, plan: Plan, options: ReplayOptions = {}) =>\n run(page, plan, options, options.from ?? 0, plan.steps.length, false).pipe(\n Effect.withSpan(\"Plan.replay\"),\n );\n\n/** Restore prior steps on a fresh page; unresolved commitments require positive durable evidence. */\nexport const restore = (\n page: Page,\n plan: Plan,\n options: TakeOptions & { readonly upTo?: number | undefined } = {},\n) =>\n run(page, plan, options, 0, options.upTo ?? plan.steps.length, true).pipe(\n Effect.withSpan(\"Plan.restore\"),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,UAAb,cAA6B,OAAO,YAAqB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CACxE,IAAa,UAAU;EACrB,OAAO;CACT;AACF;;AAGA,IAAa,YAAb,cAA+B,OAAO,YAAuB,CAAC,CAAC,aAAa,EAC1E,OAAO,OAAO,IAChB,CAAC,CAAC,CAAC;CACD,IAAa,UAAU;EACrB,OAAO,GAAG,KAAK,MAAM;CACvB;AACF;;AAGA,IAAa,UAAb,cAA6B,OAAO,YAAqB,CAAC,CAAC,WAAW,EACpE,QAAQ,OAAO,OACjB,CAAC,CAAC,CAAC;CACD,IAAa,UAAU;EACrB,OAAO,KAAK;CACd;AACF;AAEA,MAAM,EAAE,OAAO,cAAc,MAAM;AACnC,MAAM,SAAS;CAAC;CAAO;CAAU;CAAS;AAAS;AAEnD,MAAM,QAAQ,YACZ,OAAO,OAAO,OAAO,CAAC,CAAC,QAAQ,UAAU,OAAO,UAAU,QAAQ;;AAGpE,MAAM,WAAW,OAAgC,OAAe,YAA4B;CAC1F,MAAM,MAAM,QAAQ;CAEpB,IAAI,QAAQ,KAAA,KAAa,UAAU,GAAG,MAAM,UAAU,KAAK,GAAG,OAAO;CACrE,IAAI,UAAU,UAAU,OAAO,QAAQ,KAAA,IAAY,IAAI;CACvD,IAAI,UAAU,OACZ,OAAO,QAAQ,KAAA,KACb,KAAK,OAAO,CAAC,CAAC,MAAM,UAAU,GAAG,UAAU,KAAK,EAAE,GAAG,WAAW,GAAG,UAAU,KAAK,EAAE,E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@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export {};
|
|
1
|
+
import { _ as take, a as ReplayError, b as Missing, c as StepAction, d as Uncertain, f as fromEvents, g as restore, h as replay, i as Receipt, l as Stopped, m as repeatable, n as Plan, o as ReplayOptions, p as locate, s as Step, t as Expected, u as TakeOptions, v as Ambiguous, y as Drifted } from "./Plan-Akcac63g.mjs";
|
|
2
|
+
export { Ambiguous, Drifted, Expected, Missing, Plan, Receipt, ReplayError, ReplayOptions, Step, StepAction, Stopped, TakeOptions, Uncertain, fromEvents, locate, repeatable, replay, restore, take };
|
package/dist/Plan.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export {
|
|
1
|
+
import { _ as Drifted, a as ReplayError, c as Stopped, d as locate, f as repeatable, g as Ambiguous, h as take, i as Receipt, l as Uncertain, m as restore, n as Plan, o as Step, p as replay, s as StepAction, t as Expected, u as fromEvents, v as Missing } from "./Plan-D1wrJVs8.mjs";
|
|
2
|
+
export { Ambiguous, Drifted, Expected, Missing, Plan, Receipt, ReplayError, Step, StepAction, Stopped, Uncertain, fromEvents, locate, repeatable, replay, restore, take };
|