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
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as internalsOf } from "./page-PTM8m5wC.mjs";
|
|
1
|
+
import { InvalidRequest, Timeout, consequence, failWith, refuse, undispatched } from "../BrowserError.mjs";
|
|
2
|
+
import { monotonicMillis } from "../Clock.mjs";
|
|
3
|
+
import { initial, step } from "./feed.mjs";
|
|
5
4
|
import { Cause, Clock, Deferred, Duration, Effect, Exit, Fiber, Option, PubSub, Result, Schedule, Schema, Scope, Stream } from "effect";
|
|
6
|
-
//#region src/Stage.ts
|
|
5
|
+
//#region src/presentation/Stage.ts
|
|
7
6
|
/**
|
|
8
7
|
* An output's capture ownership. Cue a page while preparing an event; commit when that event
|
|
9
8
|
* happens. A prepared cue belongs to its caller's scope, and a committed one to the stage.
|
|
10
9
|
* Commits serialize, drain old-page input and refuse stale first frames. `shown` distinguishes
|
|
11
10
|
* confirmed silence, uncertain silence and loss without treating capture silence as evidence.
|
|
11
|
+
* All pages of a stage must share one owning clock; timestamps from unrelated clocks cannot mix.
|
|
12
12
|
* @since 0.3.0
|
|
13
13
|
*/
|
|
14
|
-
var Stage_exports = /* @__PURE__ */ __exportAll({
|
|
15
|
-
Presented: () => Presented,
|
|
16
|
-
make: () => make
|
|
17
|
-
});
|
|
18
14
|
/** A switch that took effect, on the clock shared by browser events and frames. */
|
|
19
15
|
var Presented = class extends Schema.Class("effect-browser/Presented")({
|
|
20
16
|
page: Schema.String,
|
|
@@ -24,16 +20,7 @@ var Presented = class extends Schema.Class("effect-browser/Presented")({
|
|
|
24
20
|
const unavailable = () => undispatched("cue", new InvalidRequest({ detail: "the cue's capture is no longer available" }));
|
|
25
21
|
/** The sole writer of a cue's capture lifecycle; presentation ownership belongs to the stage. */
|
|
26
22
|
const update = (feed, input) => {
|
|
27
|
-
|
|
28
|
-
if (input._tag === "Stop") feed.state = { _tag: "Stopped" };
|
|
29
|
-
else if (input._tag === "Paint") feed.state = {
|
|
30
|
-
_tag: "Ready",
|
|
31
|
-
latest: input.frame
|
|
32
|
-
};
|
|
33
|
-
else if (feed.state._tag === "Ready") feed.state = {
|
|
34
|
-
_tag: "Ready",
|
|
35
|
-
latest: void 0
|
|
36
|
-
};
|
|
23
|
+
feed.state = step(feed.state, input);
|
|
37
24
|
};
|
|
38
25
|
const restartable = (error) => {
|
|
39
26
|
const { lost, repeat } = consequence(error);
|
|
@@ -45,13 +32,11 @@ const stop = (feed) => Effect.suspend(() => {
|
|
|
45
32
|
});
|
|
46
33
|
const frameOf = (feed) => {
|
|
47
34
|
const frame = feed.state._tag === "Ready" ? feed.state.latest : void 0;
|
|
48
|
-
|
|
49
|
-
return frame !== void 0 && (internals === void 0 || internals.current(frame)) ? frame : void 0;
|
|
35
|
+
return frame !== void 0 && feed.capture?.isCurrent(frame) ? frame : void 0;
|
|
50
36
|
};
|
|
51
37
|
const ended = (feed) => feed.fiber === void 0 ? Effect.never : Fiber.await(feed.fiber).pipe(Effect.flatMap((exit) => Exit.isFailure(exit) && !Cause.hasInterruptsOnly(exit.cause) ? Effect.failCause(exit.cause) : Effect.fail(unavailable())));
|
|
52
38
|
const firstOf = (feed, wait) => Effect.suspend(() => {
|
|
53
39
|
if (feed.state._tag === "Stopped") return Effect.fail(unavailable());
|
|
54
|
-
if (feed.page.playwright.isClosed()) return failWith("cue", new Closed({ cause: "page" }));
|
|
55
40
|
if (frameOf(feed) !== void 0) return Effect.void;
|
|
56
41
|
return Effect.raceFirst(Stream.fromPubSub(feed.changed).pipe(Stream.filter(() => frameOf(feed) !== void 0), Stream.runHead, Effect.asVoid), ended(feed)).pipe(Effect.timeoutOrElse({
|
|
57
42
|
duration: wait,
|
|
@@ -78,13 +63,11 @@ const confirm = (feed, frame) => {
|
|
|
78
63
|
const exit = feed.fiber?.pollUnsafe();
|
|
79
64
|
const failure = exit !== void 0 && Exit.isFailure(exit) ? Cause.findErrorOption(exit.cause) : Option.none();
|
|
80
65
|
if (Option.isSome(failure) && consequence(failure.value).lost !== "nothing") return Effect.fail(failure.value);
|
|
81
|
-
return feed.
|
|
66
|
+
return feed.capture?.confirm(frame) ?? Effect.succeed(false);
|
|
82
67
|
};
|
|
83
68
|
/** Each subscriber confirms silence; a new frame or commit invalidates a probe. */
|
|
84
69
|
const evidence = (output, current, now, hold) => Stream.unwrap(Effect.sync(() => {
|
|
85
|
-
const
|
|
86
|
-
if (Option.isNone(parsed) || !Duration.isFinite(parsed.value) || !Duration.isPositive(parsed.value)) throw new RangeError("shown hold must be a finite positive duration");
|
|
87
|
-
const millis = Duration.toMillis(parsed.value);
|
|
70
|
+
const millis = Duration.toMillis(hold);
|
|
88
71
|
let checkedAt = now();
|
|
89
72
|
let shownAt = Number.NEGATIVE_INFINITY;
|
|
90
73
|
let seen = current();
|
|
@@ -150,51 +133,60 @@ const evidence = (output, current, now, hold) => Stream.unwrap(Effect.sync(() =>
|
|
|
150
133
|
};
|
|
151
134
|
}));
|
|
152
135
|
}));
|
|
153
|
-
const openFeed = (page, owner,
|
|
136
|
+
const openFeed = (page, owner, settings, current, publish) => Effect.gen(function* () {
|
|
154
137
|
const scope = yield* Scope.fork(owner);
|
|
155
138
|
const started = yield* Deferred.make();
|
|
156
139
|
const feed = {
|
|
157
140
|
page,
|
|
141
|
+
capture: void 0,
|
|
158
142
|
scope,
|
|
159
143
|
changed: yield* PubSub.sliding({
|
|
160
144
|
capacity: 1,
|
|
161
145
|
replay: 1
|
|
162
146
|
}),
|
|
163
|
-
state:
|
|
147
|
+
state: initial,
|
|
164
148
|
fiber: void 0
|
|
165
149
|
};
|
|
166
150
|
yield* Scope.addFinalizer(scope, Effect.sync(() => {
|
|
167
151
|
update(feed, { _tag: "Stop" });
|
|
168
152
|
}));
|
|
169
153
|
yield* Effect.addFinalizer(() => current() === feed ? Effect.void : stop(feed));
|
|
170
|
-
const accept = (frame) => Effect.
|
|
154
|
+
const accept = (frame) => Effect.gen(function* () {
|
|
155
|
+
const state = yield* page.state;
|
|
156
|
+
if (feed.state._tag === "Stopped" || state.page !== frame.page || state.connection !== frame.connection || state.document !== frame.document) return;
|
|
171
157
|
update(feed, {
|
|
172
158
|
_tag: "Paint",
|
|
173
159
|
frame
|
|
174
160
|
});
|
|
175
|
-
|
|
161
|
+
if (current() === feed) yield* publish(feed, frame);
|
|
162
|
+
yield* PubSub.publish(feed.changed, frame);
|
|
176
163
|
});
|
|
177
164
|
feed.fiber = yield* Effect.scoped(Effect.gen(function* () {
|
|
178
165
|
update(feed, { _tag: "Reset" });
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
});
|
|
184
|
-
if (frame !== void 0 && internals?.current(frame)) yield* accept(frame);
|
|
166
|
+
const capture = yield* page.capture(settings);
|
|
167
|
+
feed.capture = capture;
|
|
168
|
+
const { stream, current: frame } = capture;
|
|
169
|
+
if (frame !== void 0 && capture.isCurrent(frame)) yield* accept(frame);
|
|
185
170
|
yield* Deferred.succeed(started, void 0);
|
|
186
171
|
yield* Stream.runForEach(stream, accept);
|
|
187
172
|
})).pipe(Effect.ensuring(Effect.sync(() => update(feed, { _tag: "Reset" }))), Effect.retry({
|
|
188
173
|
while: (error) => feed.state._tag === "Ready" && restartable(error),
|
|
189
174
|
schedule: Schedule.spaced("500 millis")
|
|
190
|
-
})).pipe(Effect.provideService(Clock.Clock, clock), Effect.forkIn(scope));
|
|
175
|
+
})).pipe(Effect.provideService(Clock.Clock, feed.page.clock), Effect.forkIn(scope));
|
|
191
176
|
yield* Effect.raceFirst(Deferred.await(started), ended(feed)).pipe(Effect.onError(() => stop(feed)));
|
|
192
177
|
return feed;
|
|
193
178
|
});
|
|
194
179
|
const make = Effect.fn("Stage.make")(function* (options = {}) {
|
|
195
|
-
const
|
|
180
|
+
const chosen = yield* Deferred.make();
|
|
181
|
+
let clock;
|
|
182
|
+
const choose = (page) => Effect.suspend(() => {
|
|
183
|
+
if (clock !== void 0 && clock !== page.clock) return refuse("stage", "pages presented by one stage must share an owning clock");
|
|
184
|
+
clock ??= page.clock;
|
|
185
|
+
Deferred.doneUnsafe(chosen, Exit.succeed(clock));
|
|
186
|
+
return Effect.void;
|
|
187
|
+
});
|
|
196
188
|
const owner = yield* Effect.scope;
|
|
197
|
-
const now = () => monotonicMillis(clock);
|
|
189
|
+
const now = () => clock === void 0 ? 0 : monotonicMillis(clock);
|
|
198
190
|
const waited = Duration.fromInput(options.firstFrame ?? Duration.seconds(5));
|
|
199
191
|
if (Option.isNone(waited) || !Duration.isFinite(waited.value) || !Duration.isPositive(waited.value)) return yield* refuse("stage", "firstFrame must be a finite positive duration");
|
|
200
192
|
const firstFrame = waited.value;
|
|
@@ -219,53 +211,53 @@ const make = Effect.fn("Stage.make")(function* (options = {}) {
|
|
|
219
211
|
at: painted
|
|
220
212
|
});
|
|
221
213
|
});
|
|
222
|
-
const commit = (feed,
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const readyToSwitch = firstOf(feed, firstFrame).pipe(Effect.andThen(switchTo), Effect.provideService(Clock.Clock, clock));
|
|
247
|
-
const before = old === void 0 ? void 0 : internalsOf(old.feed.page);
|
|
248
|
-
return yield* (before === void 0 ? readyToSwitch : before.afterInput(readyToSwitch)).pipe(Effect.ensuring(Effect.suspend(() => showing?.feed === feed && old !== void 0 ? stop(old.feed) : Effect.void)));
|
|
249
|
-
}).pipe(Effect.provideService(Clock.Clock, clock)));
|
|
214
|
+
const commit = (feed, asked) => Effect.gen(function* () {
|
|
215
|
+
if (!Number.isFinite(asked)) return yield* refuse("cue", "at must be finite host milliseconds");
|
|
216
|
+
yield* firstOf(feed, firstFrame);
|
|
217
|
+
const old = showing;
|
|
218
|
+
if (old?.feed === feed) return old.presented;
|
|
219
|
+
yield* Effect.raceFirst(until(asked, now), ended(feed));
|
|
220
|
+
const switchTo = Effect.suspend(() => {
|
|
221
|
+
const frame = frameOf(feed);
|
|
222
|
+
if (frame === void 0) return Effect.fail(unavailable());
|
|
223
|
+
const at = Math.max(now(), asked, frame.hostTime, painted);
|
|
224
|
+
showing = {
|
|
225
|
+
feed,
|
|
226
|
+
frame,
|
|
227
|
+
presented: new Presented({
|
|
228
|
+
page: feed.page.id,
|
|
229
|
+
at,
|
|
230
|
+
latency: at - asked
|
|
231
|
+
}),
|
|
232
|
+
changedAt: at
|
|
233
|
+
};
|
|
234
|
+
return publish(feed, frame, at).pipe(Effect.as(showing.presented));
|
|
235
|
+
}).pipe(Effect.uninterruptible);
|
|
236
|
+
const readyToSwitch = firstOf(feed, firstFrame).pipe(Effect.andThen(switchTo));
|
|
237
|
+
return yield* (old === void 0 ? readyToSwitch : old.feed.page.afterInput(readyToSwitch)).pipe(Effect.ensuring(Effect.suspend(() => showing?.feed === feed && old !== void 0 ? stop(old.feed) : Effect.void)));
|
|
250
238
|
});
|
|
251
|
-
const cue = (page) => Effect.map(openFeed(page, owner,
|
|
239
|
+
const cue = (page) => choose(page).pipe(Effect.andThen(Effect.map(openFeed(page, owner, settings, () => showing?.feed, publish), (feed) => ({
|
|
252
240
|
page,
|
|
253
|
-
ready: firstOf(feed, firstFrame).pipe(Effect.provideService(Clock.Clock, clock)),
|
|
254
|
-
commit: (options) => commit(feed, options)
|
|
255
|
-
}));
|
|
241
|
+
ready: firstOf(feed, firstFrame).pipe(Effect.provideService(Clock.Clock, feed.page.clock)),
|
|
242
|
+
commit: (options) => Effect.suspend(() => switching(commit(feed, options?.at ?? now()))).pipe(Effect.provideService(Clock.Clock, feed.page.clock))
|
|
243
|
+
}))));
|
|
256
244
|
return {
|
|
257
245
|
cue,
|
|
258
|
-
present: (page, options) => Effect.suspend(() => {
|
|
246
|
+
present: (page, options) => choose(page).pipe(Effect.andThen(Effect.suspend(() => {
|
|
259
247
|
const asked = options?.at ?? now();
|
|
260
|
-
return showing?.feed.page === page ?
|
|
261
|
-
}),
|
|
262
|
-
shown: ({ hold }) =>
|
|
248
|
+
return switching(Effect.suspend(() => showing?.feed.page === page ? commit(showing.feed, asked) : Effect.scoped(Effect.flatMap(openFeed(page, owner, settings, () => showing?.feed, publish), (feed) => commit(feed, asked)))));
|
|
249
|
+
})), Effect.provideService(Clock.Clock, page.clock)),
|
|
250
|
+
shown: ({ hold }) => {
|
|
251
|
+
const parsed = Duration.fromInput(hold);
|
|
252
|
+
if (Option.isNone(parsed) || !Duration.isFinite(parsed.value) || !Duration.isPositive(parsed.value)) return Stream.fromEffect(refuse("shown", "hold must be a finite positive duration"));
|
|
253
|
+
return Stream.unwrap(Deferred.await(chosen).pipe(Effect.map((ownerClock) => evidence(output, () => showing, now, parsed.value).pipe(Stream.provideService(Clock.Clock, ownerClock)))));
|
|
254
|
+
},
|
|
263
255
|
frames: Stream.fromPubSub(output).pipe(Stream.map(({ frame }) => frame)),
|
|
264
256
|
current: Effect.sync(() => Option.fromNullishOr(showing?.feed.page)),
|
|
265
257
|
stats: (options = {}) => showing === void 0 ? Effect.succeedNone : Effect.asSome(showing.feed.page.captureStats({ window: options.window ?? "1 second" }))
|
|
266
258
|
};
|
|
267
259
|
});
|
|
268
260
|
//#endregion
|
|
269
|
-
export { Presented, make
|
|
261
|
+
export { Presented, make };
|
|
270
262
|
|
|
271
263
|
//# sourceMappingURL=Stage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stage.mjs","names":["Lifecycle.step","Lifecycle.initial"],"sources":["../../src/presentation/Stage.ts"],"sourcesContent":["/**\n * An output's capture ownership. Cue a page while preparing an event; commit when that event\n * happens. A prepared cue belongs to its caller's scope, and a committed one to the stage.\n * Commits serialize, drain old-page input and refuse stale first frames. `shown` distinguishes\n * confirmed silence, uncertain silence and loss without treating capture silence as evidence.\n * All pages of a stage must share one owning clock; timestamps from unrelated clocks cannot mix.\n * @since 0.3.0\n */\nimport {\n Cause,\n Clock,\n Deferred,\n Duration,\n Effect,\n Exit,\n Fiber,\n Option,\n PubSub,\n Result,\n Schedule,\n Schema,\n Scope,\n Stream,\n} from \"effect\";\n\nimport {\n type BrowserError,\n consequence,\n failWith,\n InvalidRequest,\n refuse,\n Timeout,\n undispatched,\n} from \"../BrowserError.ts\";\nimport { monotonicMillis } from \"../Clock.ts\";\nimport type { CaptureStats, Frame, ScreencastOptions } from \"../Frame.ts\";\nimport type { Capture, Page } from \"../Page.ts\";\nimport * as Lifecycle from \"./feed.ts\";\n\nexport interface Options extends ScreencastOptions {\n /** Bound for each first-frame wait. Defaults to 5 seconds. */\n readonly firstFrame?: Duration.Input | undefined;\n}\n\n/** A switch that took effect, on the clock shared by browser events and frames. */\nexport class Presented extends Schema.Class<Presented>(\"effect-browser/Presented\")({\n page: Schema.String,\n at: Schema.Finite,\n latency: Schema.Finite,\n}) {}\n\nexport interface Cue {\n readonly page: Page;\n /** A frame of the current document, or the capture's failure or first-frame timeout. */\n readonly ready: Effect.Effect<void, BrowserError>;\n /** Commit on the event's host time, or now. Interruption before switching leaves the cue usable. */\n readonly commit: (options?: {\n readonly at?: number | undefined;\n }) => Effect.Effect<Presented, BrowserError>;\n}\n\n/** What the output establishes at nondecreasing host times; frames retain their capture times. */\nexport type Shown =\n | { readonly _tag: \"Painted\"; readonly frame: Frame; readonly at: number }\n | { readonly _tag: \"Still\"; readonly frame: Frame; readonly at: number }\n | { readonly _tag: \"Stalled\"; readonly frame: Frame; readonly at: number }\n | { readonly _tag: \"Gone\"; readonly page: string; readonly at: number };\n\nexport interface Stage {\n readonly present: (\n page: Page,\n options?: { readonly at?: number | undefined },\n ) => Effect.Effect<Presented, BrowserError>;\n readonly cue: (page: Page) => Effect.Effect<Cue, BrowserError, Scope.Scope>;\n /** Paint and, after every finite positive hold without paint, current evidence or loss. */\n readonly shown: (options: {\n readonly hold: Duration.Input;\n }) => Stream.Stream<Shown, BrowserError>;\n /** Capture-timed current-page paint; use `shown` for output time. Readers retain 16 frames. */\n readonly frames: Stream.Stream<Frame>;\n readonly current: Effect.Effect<Option.Option<Page>>;\n readonly stats: (options?: {\n readonly window?: Duration.Input | undefined;\n }) => Effect.Effect<Option.Option<CaptureStats>, BrowserError>;\n}\n\ninterface Feed {\n readonly page: Page;\n capture: Capture | undefined;\n readonly scope: Scope.Closeable;\n readonly changed: PubSub.PubSub<Frame>;\n state: Lifecycle.State;\n fiber: Fiber.Fiber<void, BrowserError> | undefined;\n}\ninterface Paint {\n readonly feed: Feed;\n readonly frame: Frame;\n readonly at: number;\n}\n\ninterface Evidence {\n readonly feed: Feed;\n readonly frame: Frame;\n readonly value: Shown;\n}\n\nconst unavailable = () =>\n undispatched(\"cue\", new InvalidRequest({ detail: \"the cue's capture is no longer available\" }));\n\n/** The sole writer of a cue's capture lifecycle; presentation ownership belongs to the stage. */\nconst update = (feed: Feed, input: Lifecycle.Input) => {\n feed.state = Lifecycle.step(feed.state, input);\n};\n\nconst restartable = (error: BrowserError) => {\n const { lost, repeat } = consequence(error);\n\n return lost === \"nothing\" && repeat !== \"pointless\";\n};\n\nconst stop = (feed: Feed) =>\n Effect.suspend(() => {\n update(feed, { _tag: \"Stop\" });\n\n return Scope.close(feed.scope, Exit.void);\n });\n\nconst frameOf = (feed: Feed) => {\n const frame = feed.state._tag === \"Ready\" ? feed.state.latest : undefined;\n\n return frame !== undefined && feed.capture?.isCurrent(frame) ? frame : undefined;\n};\n\nconst ended = (feed: Feed): Effect.Effect<never, BrowserError> =>\n feed.fiber === undefined\n ? Effect.never\n : Fiber.await(feed.fiber).pipe(\n Effect.flatMap((exit) =>\n Exit.isFailure(exit) && !Cause.hasInterruptsOnly(exit.cause)\n ? Effect.failCause(exit.cause)\n : Effect.fail(unavailable()),\n ),\n );\n\nconst firstOf = (feed: Feed, wait: Duration.Duration) =>\n Effect.suspend(() => {\n if (feed.state._tag === \"Stopped\") return Effect.fail(unavailable());\n if (frameOf(feed) !== undefined) return Effect.void;\n\n return Effect.raceFirst(\n Stream.fromPubSub(feed.changed).pipe(\n Stream.filter(() => frameOf(feed) !== undefined),\n Stream.runHead,\n Effect.asVoid,\n ),\n ended(feed),\n ).pipe(\n Effect.timeoutOrElse({\n duration: wait,\n orElse: () => failWith(\"cue\", new Timeout({ millis: Duration.toMillis(wait) })),\n }),\n );\n });\n\n// A timer can wake a fraction early; a commit never precedes its event.\nconst until = (at: number, now: () => number): Effect.Effect<void> =>\n Effect.suspend(() =>\n at > now()\n ? Effect.sleep(Duration.millis(Math.ceil(at - now()))).pipe(Effect.andThen(until(at, now)))\n : Effect.void,\n );\n\n/** Reserve the next turn before waking it; a fresh caller cannot overtake a queued commit. */\nconst ordered = () => {\n const waiting: Array<Deferred.Deferred<void>> = [];\n\n return <A, E, R>(effect: Effect.Effect<A, E, R>) =>\n Effect.acquireUseRelease(\n Effect.sync(() => {\n const turn = Deferred.makeUnsafe<void>();\n\n waiting.push(turn);\n if (waiting.length === 1) Deferred.doneUnsafe(turn, Exit.void);\n\n return turn;\n }),\n (turn) => Deferred.await(turn).pipe(Effect.andThen(effect)),\n (turn) =>\n Effect.sync(() => {\n const at = waiting.indexOf(turn);\n\n waiting.splice(at, 1);\n if (at === 0 && waiting[0] !== undefined) Deferred.doneUnsafe(waiting[0], Exit.void);\n }),\n );\n};\n\n/** A terminal capture can know the connection is gone before the page receives its close event. */\nconst confirm = (feed: Feed, frame: Frame) => {\n const exit = feed.fiber?.pollUnsafe();\n\n const failure =\n exit !== undefined && Exit.isFailure(exit) ? Cause.findErrorOption(exit.cause) : Option.none();\n\n if (Option.isSome(failure) && consequence(failure.value).lost !== \"nothing\")\n return Effect.fail(failure.value);\n\n return feed.capture?.confirm(frame) ?? Effect.succeed(false);\n};\n\n/** Each subscriber confirms silence; a new frame or commit invalidates a probe. */\nconst evidence = (\n output: PubSub.PubSub<Paint>,\n current: () =>\n | { readonly feed: Feed; readonly frame: Frame; readonly changedAt: number }\n | undefined,\n now: () => number,\n hold: Duration.Duration,\n): Stream.Stream<Shown, BrowserError> =>\n Stream.unwrap(\n Effect.sync(() => {\n const millis = Duration.toMillis(hold);\n let checkedAt = now();\n let shownAt = Number.NEGATIVE_INFINITY;\n let seen: Pick<Paint, \"feed\" | \"frame\"> | undefined = current();\n let gone: Feed | undefined;\n\n const probe = Effect.gen(function* () {\n yield* until(Math.max(checkedAt, current()?.changedAt ?? checkedAt) + millis, now);\n const before = current();\n const frame = before?.frame;\n\n // Paint during the wait moves the deadline; an early wake is not a silence check.\n if (before !== undefined && now() - before.changedAt < millis)\n return Option.none<Evidence>();\n checkedAt = now();\n if (before === undefined || frame === undefined || gone === before.feed)\n return Option.none<Evidence>();\n const { feed } = before;\n\n const confirmed = yield* Effect.result(confirm(feed, frame));\n\n if (current()?.feed !== feed || current()?.frame !== frame) return Option.none<Evidence>();\n const at = now();\n\n checkedAt = at;\n if (Result.isFailure(confirmed) && consequence(confirmed.failure).lost !== \"nothing\") {\n return Option.some<Evidence>({\n feed,\n frame,\n value: { _tag: \"Gone\", page: feed.page.id, at },\n });\n }\n\n return Option.some<Evidence>({\n feed,\n frame,\n value: {\n _tag: Result.isSuccess(confirmed) && confirmed.success ? \"Still\" : \"Stalled\",\n frame,\n at,\n },\n });\n });\n\n return Stream.merge(\n Stream.fromPubSub(output).pipe(\n Stream.map(({ feed, frame, at }): Evidence => ({\n feed,\n frame,\n value: { _tag: \"Painted\", frame, at },\n })),\n ),\n Stream.fromEffectRepeat(probe).pipe(\n Stream.filter(Option.isSome),\n Stream.map(({ value }) => value),\n ),\n ).pipe(\n // A probe can overtake queued paint while its reader is paused. It establishes nothing\n // about that reader's output until the matching frame has reached it.\n Stream.filter(({ feed, frame, value }) => {\n if (value._tag === \"Painted\" && gone !== feed) {\n seen = { feed, frame };\n\n return true;\n }\n // The subscription may have begun after its first publication.\n seen ??= { feed, frame };\n\n return value._tag !== \"Painted\" && seen?.feed === feed && seen.frame === frame;\n }),\n Stream.map(({ feed, value }) => {\n if (value._tag === \"Gone\") gone = feed;\n // A frame captured before a silence probe can arrive after the probe's evidence.\n shownAt = Math.max(shownAt, value.at);\n\n return value.at === shownAt ? value : { ...value, at: shownAt };\n }),\n );\n }),\n );\n\nconst openFeed = (\n page: Page,\n owner: Scope.Scope,\n settings: ScreencastOptions,\n current: () => Feed | undefined,\n publish: (feed: Feed, frame: Frame) => Effect.Effect<unknown>,\n) =>\n Effect.gen(function* () {\n const scope = yield* Scope.fork(owner);\n const started = yield* Deferred.make<void>();\n\n const feed: Feed = {\n page,\n capture: undefined,\n scope,\n changed: yield* PubSub.sliding<Frame>({ capacity: 1, replay: 1 }),\n state: Lifecycle.initial,\n fiber: undefined,\n };\n\n yield* Scope.addFinalizer(\n scope,\n Effect.sync(() => {\n update(feed, { _tag: \"Stop\" });\n }),\n );\n yield* Effect.addFinalizer(() => (current() === feed ? Effect.void : stop(feed)));\n\n const accept = (frame: Frame) =>\n Effect.gen(function* () {\n const state = yield* page.state;\n\n if (\n feed.state._tag === \"Stopped\" ||\n state.page !== frame.page ||\n state.connection !== frame.connection ||\n state.document !== frame.document\n )\n return;\n update(feed, { _tag: \"Paint\", frame });\n if (current() === feed) yield* publish(feed, frame);\n yield* PubSub.publish(feed.changed, frame);\n });\n\n const capture = Effect.scoped(\n Effect.gen(function* () {\n update(feed, { _tag: \"Reset\" });\n\n const capture = yield* page.capture(settings);\n\n feed.capture = capture;\n const { stream, current: frame } = capture;\n\n if (frame !== undefined && capture.isCurrent(frame)) yield* accept(frame);\n yield* Deferred.succeed(started, undefined);\n yield* Stream.runForEach(stream, accept);\n }),\n ).pipe(\n Effect.ensuring(Effect.sync(() => update(feed, { _tag: \"Reset\" }))),\n Effect.retry({\n while: (error) => feed.state._tag === \"Ready\" && restartable(error),\n schedule: Schedule.spaced(\"500 millis\"),\n }),\n );\n\n feed.fiber = yield* capture.pipe(\n Effect.provideService(Clock.Clock, feed.page.clock),\n Effect.forkIn(scope),\n );\n yield* Effect.raceFirst(Deferred.await(started), ended(feed)).pipe(\n Effect.onError(() => stop(feed)),\n );\n\n return feed;\n });\n\nexport const make = Effect.fn(\"Stage.make\")(function* (\n options: Options = {},\n): Effect.fn.Return<Stage, BrowserError, Scope.Scope> {\n const chosen = yield* Deferred.make<Clock.Clock>();\n let clock: Clock.Clock | undefined;\n\n const choose = (page: Page) =>\n Effect.suspend(() => {\n if (clock !== undefined && clock !== page.clock)\n return refuse(\"stage\", \"pages presented by one stage must share an owning clock\");\n clock ??= page.clock;\n Deferred.doneUnsafe(chosen, Exit.succeed(clock));\n\n return Effect.void;\n });\n\n const owner = yield* Effect.scope;\n const now = () => (clock === undefined ? 0 : monotonicMillis(clock));\n const waited = Duration.fromInput(options.firstFrame ?? Duration.seconds(5));\n\n if (\n Option.isNone(waited) ||\n !Duration.isFinite(waited.value) ||\n !Duration.isPositive(waited.value)\n )\n return yield* refuse(\"stage\", \"firstFrame must be a finite positive duration\");\n const firstFrame = waited.value;\n const settings = { quality: options.quality, size: options.size };\n const output = yield* PubSub.sliding<Paint>(16);\n const switching = ordered();\n\n let showing:\n | { readonly feed: Feed; readonly presented: Presented; frame: Frame; changedAt: number }\n | undefined;\n\n let painted = Number.NEGATIVE_INFINITY;\n\n yield* Effect.addFinalizer(() => PubSub.shutdown(output));\n\n const publish = (feed: Feed, frame: Frame, at = frame.hostTime) =>\n Effect.suspend(() => {\n painted = Math.max(painted, at);\n if (showing !== undefined) {\n showing.changedAt = now();\n showing.frame = frame;\n }\n\n return PubSub.publish(output, { feed, frame, at: painted });\n });\n\n // Both public entry points reserve a FIFO turn before reading the current feed.\n const commit = (feed: Feed, asked: number) =>\n Effect.gen(function* () {\n if (!Number.isFinite(asked))\n return yield* refuse(\"cue\", \"at must be finite host milliseconds\");\n yield* firstOf(feed, firstFrame);\n const old = showing;\n\n if (old?.feed === feed) return old.presented;\n\n yield* Effect.raceFirst(until(asked, now), ended(feed));\n\n const switchTo = Effect.suspend(() => {\n const frame = frameOf(feed);\n\n if (frame === undefined) return Effect.fail(unavailable());\n const at = Math.max(now(), asked, frame.hostTime, painted);\n\n showing = {\n feed,\n frame,\n presented: new Presented({ page: feed.page.id, at, latency: at - asked }),\n changedAt: at,\n };\n\n return publish(feed, frame, at).pipe(Effect.as(showing.presented));\n }).pipe(Effect.uninterruptible);\n\n const readyToSwitch = firstOf(feed, firstFrame).pipe(Effect.andThen(switchTo));\n\n return yield* (\n old === undefined ? readyToSwitch : old.feed.page.afterInput(readyToSwitch)\n ).pipe(\n // The cut owns old-page input through publication. Capture cleanup has its own bound\n // and must finish even if the caller leaves, without turning a completed cut into Timeout.\n Effect.ensuring(\n Effect.suspend(() =>\n showing?.feed === feed && old !== undefined ? stop(old.feed) : Effect.void,\n ),\n ),\n );\n });\n\n const cue: Stage[\"cue\"] = (page) =>\n choose(page).pipe(\n Effect.andThen(\n Effect.map(\n openFeed(page, owner, settings, () => showing?.feed, publish),\n (feed) => ({\n page,\n ready: firstOf(feed, firstFrame).pipe(\n Effect.provideService(Clock.Clock, feed.page.clock),\n ),\n commit: (options?: { readonly at?: number | undefined }) =>\n Effect.suspend(() => switching(commit(feed, options?.at ?? now()))).pipe(\n Effect.provideService(Clock.Clock, feed.page.clock),\n ),\n }),\n ),\n ),\n );\n\n return {\n cue,\n present: (page, options) =>\n choose(page).pipe(\n Effect.andThen(\n Effect.suspend(() => {\n const asked = options?.at ?? now();\n\n return switching(\n Effect.suspend(() =>\n showing?.feed.page === page\n ? commit(showing.feed, asked)\n : Effect.scoped(\n Effect.flatMap(\n openFeed(page, owner, settings, () => showing?.feed, publish),\n (feed) => commit(feed, asked),\n ),\n ),\n ),\n );\n }),\n ),\n Effect.provideService(Clock.Clock, page.clock),\n ),\n shown: ({ hold }) => {\n const parsed = Duration.fromInput(hold);\n\n if (\n Option.isNone(parsed) ||\n !Duration.isFinite(parsed.value) ||\n !Duration.isPositive(parsed.value)\n )\n return Stream.fromEffect(refuse(\"shown\", \"hold must be a finite positive duration\"));\n\n return Stream.unwrap(\n Deferred.await(chosen).pipe(\n Effect.map((ownerClock) =>\n evidence(output, () => showing, now, parsed.value).pipe(\n Stream.provideService(Clock.Clock, ownerClock),\n ),\n ),\n ),\n );\n },\n frames: Stream.fromPubSub(output).pipe(Stream.map(({ frame }) => frame)),\n current: Effect.sync(() => Option.fromNullishOr(showing?.feed.page)),\n stats: (options = {}) =>\n showing === undefined\n ? Effect.succeedNone\n : Effect.asSome(showing.feed.page.captureStats({ window: options.window ?? \"1 second\" })),\n } satisfies Stage;\n});\n"],"mappings":";;;;;;;;;;;;;;AA6CA,IAAa,YAAb,cAA+B,OAAO,MAAiB,0BAA0B,CAAC,CAAC;CACjF,MAAM,OAAO;CACb,IAAI,OAAO;CACX,SAAS,OAAO;AAClB,CAAC,CAAC,CAAC,CAAC;AAyDJ,MAAM,oBACJ,aAAa,OAAO,IAAI,eAAe,EAAE,QAAQ,2CAA2C,CAAC,CAAC;;AAGhG,MAAM,UAAU,MAAY,UAA2B;CACrD,KAAK,QAAQA,KAAe,KAAK,OAAO,KAAK;AAC/C;AAEA,MAAM,eAAe,UAAwB;CAC3C,MAAM,EAAE,MAAM,WAAW,YAAY,KAAK;CAE1C,OAAO,SAAS,aAAa,WAAW;AAC1C;AAEA,MAAM,QAAQ,SACZ,OAAO,cAAc;CACnB,OAAO,MAAM,EAAE,MAAM,OAAO,CAAC;CAE7B,OAAO,MAAM,MAAM,KAAK,OAAO,KAAK,IAAI;AAC1C,CAAC;AAEH,MAAM,WAAW,SAAe;CAC9B,MAAM,QAAQ,KAAK,MAAM,SAAS,UAAU,KAAK,MAAM,SAAS,KAAA;CAEhE,OAAO,UAAU,KAAA,KAAa,KAAK,SAAS,UAAU,KAAK,IAAI,QAAQ,KAAA;AACzE;AAEA,MAAM,SAAS,SACb,KAAK,UAAU,KAAA,I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C,CAAC,KAAK,OAAO,KAAK,EAAE,YAAY,KAAK,CAAC;EACvE,SAAS,OAAO,WAAW,OAAO,cAAc,SAAS,KAAK,IAAI,CAAC;EACnE,QAAQ,UAAU,CAAC,MACjB,YAAY,KAAA,IACR,OAAO,cACP,OAAO,OAAO,QAAQ,KAAK,KAAK,aAAa,EAAE,QAAQ,QAAQ,UAAU,WAAW,CAAC,CAAC;CAC9F;AACF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { r as Frame } from "../Frame-UEH2hO5T.mjs";
|
|
2
|
+
//#region src/presentation/feed.d.ts
|
|
3
|
+
export type State = {
|
|
4
|
+
readonly _tag: "Warming";
|
|
5
|
+
} | {
|
|
6
|
+
readonly _tag: "Ready";
|
|
7
|
+
readonly latest: Frame | undefined;
|
|
8
|
+
} | {
|
|
9
|
+
readonly _tag: "Stopped";
|
|
10
|
+
};
|
|
11
|
+
export type Input = {
|
|
12
|
+
readonly _tag: "Paint";
|
|
13
|
+
readonly frame: Frame;
|
|
14
|
+
} | {
|
|
15
|
+
readonly _tag: "Reset" | "Stop";
|
|
16
|
+
};
|
|
17
|
+
export declare const initial: State;
|
|
18
|
+
export declare const step: (state: State, input: Input) => State;
|
|
19
|
+
//#endregion
|
|
20
|
+
//# sourceMappingURL=feed.d.mts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/presentation/feed.ts
|
|
2
|
+
const initial = { _tag: "Warming" };
|
|
3
|
+
const step = (state, input) => {
|
|
4
|
+
if (state._tag === "Stopped") return state;
|
|
5
|
+
if (input._tag === "Stop") return { _tag: "Stopped" };
|
|
6
|
+
if (input._tag === "Paint") return {
|
|
7
|
+
_tag: "Ready",
|
|
8
|
+
latest: input.frame
|
|
9
|
+
};
|
|
10
|
+
return state._tag === "Ready" ? {
|
|
11
|
+
_tag: "Ready",
|
|
12
|
+
latest: void 0
|
|
13
|
+
} : state;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { initial, step };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=feed.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feed.mjs","names":[],"sources":["../../src/presentation/feed.ts"],"sourcesContent":["/** The capture feed's lifecycle: reset drops evidence without undoing readiness or retirement. */\nimport type { Frame } from \"../Frame.ts\";\n\nexport type State =\n | { readonly _tag: \"Warming\" }\n | { readonly _tag: \"Ready\"; readonly latest: Frame | undefined }\n | { readonly _tag: \"Stopped\" };\n\nexport type Input =\n | { readonly _tag: \"Paint\"; readonly frame: Frame }\n | { readonly _tag: \"Reset\" | \"Stop\" };\n\nexport const initial: State = { _tag: \"Warming\" };\n\nexport const step = (state: State, input: Input): State => {\n if (state._tag === \"Stopped\") return state;\n if (input._tag === \"Stop\") return { _tag: \"Stopped\" };\n if (input._tag === \"Paint\") return { _tag: \"Ready\", latest: input.frame };\n\n return state._tag === \"Ready\" ? { _tag: \"Ready\", latest: undefined } : state;\n};\n"],"mappings":";AAYA,MAAa,UAAiB,EAAE,MAAM,UAAU;AAEhD,MAAa,QAAQ,OAAc,UAAwB;CACzD,IAAI,MAAM,SAAS,WAAW,OAAO;CACrC,IAAI,MAAM,SAAS,QAAQ,OAAO,EAAE,MAAM,UAAU;CACpD,IAAI,MAAM,SAAS,SAAS,OAAO;EAAE,MAAM;EAAS,QAAQ,MAAM;CAAM;CAExE,OAAO,MAAM,SAAS,UAAU;EAAE,MAAM;EAAS,QAAQ,KAAA;CAAU,IAAI;AACzE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { t as BrowserError } from "../BrowserError-BlcmLVzn.mjs";
|
|
2
|
+
import { l as Service, t as Browser } from "../Browser-wZhwZSlG.mjs";
|
|
3
|
+
import { n as Connector, r as Options, t as ConnectOptions } from "../connection-2KHI4_KN.mjs";
|
|
4
|
+
//#region src/providers/Cdp.d.ts
|
|
5
|
+
/** Connect and open a `Browser` over the endpoint's first context. */
|
|
6
|
+
export declare const open: (options: Options) => import("effect/Effect").Effect<Service, BrowserError, import("effect/Scope").Scope>, layer: (options: Options) => import("effect/Layer").Layer<Browser, BrowserError>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export type { ConnectOptions, Connector, Options };
|
|
9
|
+
//# sourceMappingURL=Cdp.d.mts.map
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as make } from "./cdp-BMpYMWYe.mjs";
|
|
1
|
+
import { t as make } from "../connection-CK83pvqP.mjs";
|
|
3
2
|
import { chromium } from "playwright-core";
|
|
4
|
-
//#region src/Cdp.ts
|
|
3
|
+
//#region src/providers/Cdp.ts
|
|
5
4
|
/**
|
|
6
5
|
* A browser reached over Chrome DevTools Protocol. Node defaults to Playwright's transport;
|
|
7
6
|
* `connect` supplies another runtime's real Playwright browser. Closing the scope disconnects.
|
|
8
7
|
*
|
|
9
8
|
* @since 0.3.0
|
|
10
9
|
*/
|
|
11
|
-
var Cdp_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
-
layer: () => layer,
|
|
13
|
-
open: () => open
|
|
14
|
-
});
|
|
15
10
|
/** Connect and open a `Browser` over the endpoint's first context. */
|
|
16
11
|
const { open, layer } = make((endpoint, options) => chromium.connectOverCDP(endpoint, options));
|
|
17
12
|
//#endregion
|
|
18
|
-
export { layer, open
|
|
13
|
+
export { layer, open };
|
|
19
14
|
|
|
20
15
|
//# sourceMappingURL=Cdp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cdp.mjs","names":[],"sources":["../../src/providers/Cdp.ts"],"sourcesContent":["/**\n * A browser reached over Chrome DevTools Protocol. Node defaults to Playwright's transport;\n * `connect` supplies another runtime's real Playwright browser. Closing the scope disconnects.\n *\n * @since 0.3.0\n */\nimport { chromium } from \"playwright-core\";\n\nimport { make } from \"./connection.ts\";\n\nexport type { Connector, ConnectOptions, Options } from \"./connection.ts\";\n\n/** Connect and open a `Browser` over the endpoint's first context. */\nexport const { open, layer } = make((endpoint, options) =>\n chromium.connectOverCDP(endpoint, options),\n);\n"],"mappings":";;;;;;;;;;AAaA,MAAa,EAAE,MAAM,UAAU,MAAM,UAAU,YAC7C,SAAS,eAAe,UAAU,OAAO,CAC3C"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { t as BrowserError } from "
|
|
2
|
-
import { n as Browser_d_exports, o as Options$1,
|
|
1
|
+
import { t as BrowserError } from "../BrowserError-BlcmLVzn.mjs";
|
|
2
|
+
import { l as Service, n as Browser_d_exports, o as Options$1, t as Browser } from "../Browser-wZhwZSlG.mjs";
|
|
3
3
|
import { Effect, Layer } from "effect";
|
|
4
|
-
|
|
5
|
-
export { Options, layer, open };
|
|
6
|
-
}
|
|
4
|
+
//#region src/providers/Chromium.d.ts
|
|
7
5
|
export interface Options extends Options$1 {
|
|
8
6
|
/** Defaults to true. */
|
|
9
7
|
readonly headless?: boolean | undefined;
|
|
@@ -14,11 +12,13 @@ export interface Options extends Options$1 {
|
|
|
14
12
|
* fails and says so.
|
|
15
13
|
*/
|
|
16
14
|
readonly sandbox?: boolean | undefined;
|
|
17
|
-
/** Defaults to 1280x720 CSS pixels
|
|
15
|
+
/** Defaults to 1280x720 CSS pixels. */
|
|
18
16
|
readonly viewport?: {
|
|
19
17
|
readonly width: number;
|
|
20
18
|
readonly height: number;
|
|
21
19
|
} | undefined;
|
|
20
|
+
/** Device pixels per CSS pixel, as a high-density screen has two. Defaults to 1. */
|
|
21
|
+
readonly deviceScaleFactor?: number | undefined;
|
|
22
22
|
readonly executablePath?: string | undefined;
|
|
23
23
|
readonly args?: ReadonlyArray<string> | undefined;
|
|
24
24
|
readonly userAgent?: string | undefined;
|
|
@@ -29,5 +29,4 @@ export declare const open: (options?: Options | undefined) => Effect.Effect<Serv
|
|
|
29
29
|
/** A `Browser` Layer that launches Chromium when built and closes it when released. */
|
|
30
30
|
export declare const layer: (options?: Options) => Layer.Layer<Browser, BrowserError>;
|
|
31
31
|
//#endregion
|
|
32
|
-
export { Chromium_d_exports as t };
|
|
33
32
|
//# sourceMappingURL=Chromium.d.mts.map
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { i as make, t as Browser$1 } from "./Browser-CxXUjxOp.mjs";
|
|
4
|
-
import { c as undispatched, o as reasonOf } from "./context-EGhOqjNN.mjs";
|
|
1
|
+
import { Failed, reasonOf, undispatched } from "../BrowserError.mjs";
|
|
2
|
+
import { i as make, t as Browser$1 } from "../Browser-BKPAbyys.mjs";
|
|
5
3
|
import { Effect, Layer } from "effect";
|
|
6
4
|
import { chromium } from "playwright-core";
|
|
7
|
-
//#region src/Chromium.ts
|
|
5
|
+
//#region src/providers/Chromium.ts
|
|
8
6
|
/**
|
|
9
7
|
* A local Chromium, launched for the scope and closed with it.
|
|
10
8
|
*
|
|
@@ -16,10 +14,6 @@ import { chromium } from "playwright-core";
|
|
|
16
14
|
*
|
|
17
15
|
* @since 0.3.0
|
|
18
16
|
*/
|
|
19
|
-
var Chromium_exports = /* @__PURE__ */ __exportAll({
|
|
20
|
-
layer: () => layer,
|
|
21
|
-
open: () => open
|
|
22
|
-
});
|
|
23
17
|
const launchTimeoutMillis = 18e4;
|
|
24
18
|
const failed = (operation, timeoutMillis) => (cause) => undispatched(operation, reasonOf(cause, timeoutMillis));
|
|
25
19
|
const sandboxFailed = /Chromium sandboxing failed|No usable sandbox/;
|
|
@@ -45,20 +39,17 @@ const open = Effect.fn("Chromium.open")(function* (options = {}) {
|
|
|
45
39
|
width: 1280,
|
|
46
40
|
height: 720
|
|
47
41
|
},
|
|
48
|
-
deviceScaleFactor: 1,
|
|
42
|
+
deviceScaleFactor: options.deviceScaleFactor ?? 1,
|
|
49
43
|
...options.userAgent === void 0 ? {} : { userAgent: options.userAgent },
|
|
50
44
|
...options.locale === void 0 ? {} : { locale: options.locale }
|
|
51
45
|
}),
|
|
52
46
|
catch: failed("launch")
|
|
53
47
|
});
|
|
54
|
-
return yield* make(context, {
|
|
55
|
-
id: `chromium-${launched.version()}`,
|
|
56
|
-
provider: "chromium"
|
|
57
|
-
}, options);
|
|
48
|
+
return yield* make(context, { provider: "chromium" }, options);
|
|
58
49
|
});
|
|
59
50
|
/** A `Browser` Layer that launches Chromium when built and closes it when released. */
|
|
60
51
|
const layer = (options = {}) => Layer.effect(Browser$1, open(options));
|
|
61
52
|
//#endregion
|
|
62
|
-
export { layer, open
|
|
53
|
+
export { layer, open };
|
|
63
54
|
|
|
64
55
|
//# sourceMappingURL=Chromium.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chromium.mjs","names":["Browser.make","Browser.Browser"],"sources":["../../src/providers/Chromium.ts"],"sourcesContent":["/**\n * A local Chromium, launched for the scope and closed with it.\n *\n * It uses the Chromium build that `playwright-core` installs\n * (`npx playwright-core install chromium`), unless `executablePath` names another.\n *\n * Signals are the program's to handle: run it with `NodeRuntime.runMain`, which interrupts it on\n * SIGINT and SIGTERM, so the browser closes with its scope.\n *\n * @since 0.3.0\n */\nimport { Effect, Layer } from \"effect\";\nimport { chromium } from \"playwright-core\";\n\nimport * as Browser from \"../Browser.ts\";\nimport { type BrowserError, Failed, reasonOf, undispatched } from \"../BrowserError.ts\";\n\nexport interface Options extends Browser.Options {\n /** Defaults to true. */\n readonly headless?: boolean | undefined;\n /**\n * Run Chromium's sandbox. Defaults to false, as in Playwright, so an exploit in a page's renderer\n * runs with this process's privileges. Hosts that don't allow unprivileged user namespaces, such\n * as many containers and Ubuntu 23.10 or later by default, can't start the sandbox; opening then\n * fails and says so.\n */\n readonly sandbox?: boolean | undefined;\n /** Defaults to 1280x720 CSS pixels. */\n readonly viewport?: { readonly width: number; readonly height: number } | undefined;\n /** Device pixels per CSS pixel, as a high-density screen has two. Defaults to 1. */\n readonly deviceScaleFactor?: number | undefined;\n readonly executablePath?: string | undefined;\n readonly args?: ReadonlyArray<string> | undefined;\n readonly userAgent?: string | undefined;\n readonly locale?: string | undefined;\n}\n\n// Playwright's own default, stated so that a launch timeout reports the bound it exceeded.\nconst launchTimeoutMillis = 180_000;\n\nconst failed = (operation: string, timeoutMillis?: number) => (cause: unknown) =>\n undispatched(operation, reasonOf(cause, timeoutMillis));\n\n// Playwright puts this in place of Chromium's startup log when the sandbox could not start, in an\n// error that otherwise reads as a closed browser.\nconst sandboxFailed = /Chromium sandboxing failed|No usable sandbox/;\n\nconst launchFailed = (cause: unknown) =>\n sandboxFailed.test(String(cause))\n ? undispatched(\n \"launch\",\n new Failed({\n detail:\n \"Chromium's sandbox could not start on this host: it needs unprivileged user namespaces, and a user other than root\",\n }),\n )\n : failed(\"launch\", launchTimeoutMillis)(cause);\n\n/** Launch Chromium and open a `Browser` over a fresh context. */\nexport const open = Effect.fn(\"Chromium.open\")(function* (options: Options = {}) {\n const launched = yield* Effect.acquireRelease(\n Effect.tryPromise({\n try: () =>\n chromium.launch({\n headless: options.headless ?? true,\n chromiumSandbox: options.sandbox ?? false,\n timeout: launchTimeoutMillis,\n // The program owns its signals. Playwright's handlers close every browser on any of\n // these, and on SIGINT then exit the process, so no finalizer would run.\n handleSIGINT: false,\n handleSIGTERM: false,\n handleSIGHUP: false,\n ...(options.executablePath === undefined\n ? {}\n : { executablePath: options.executablePath }),\n ...(options.args === undefined ? {} : { args: [...options.args] }),\n }),\n catch: launchFailed,\n }).pipe(Effect.withSpan(\"Chromium.launch\", {}, { captureStackTrace: false })),\n (browser) => Effect.tryPromise(() => browser.close()).pipe(Effect.ignore),\n );\n\n const context = yield* Effect.tryPromise({\n try: () =>\n launched.newContext({\n viewport: options.viewport ?? { width: 1280, height: 720 },\n deviceScaleFactor: options.deviceScaleFactor ?? 1,\n ...(options.userAgent === undefined ? {} : { userAgent: options.userAgent }),\n ...(options.locale === undefined ? {} : { locale: options.locale }),\n }),\n catch: failed(\"launch\"),\n });\n\n return yield* Browser.make(context, { provider: \"chromium\" }, options);\n});\n\n/** A `Browser` Layer that launches Chromium when built and closes it when released. */\nexport const layer = (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,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,QAAQ,OAAO;EACnE,CAAC;EACH,OAAO,OAAO,QAAQ;CACxB,CAAC;CAED,OAAO,OAAOA,KAAa,SAAS,EAAE,UAAU,WAAW,GAAG,OAAO;AACvE,CAAC;;AAGD,MAAa,SAAS,UAAmB,CAAC,MACxC,MAAM,OAAOC,WAAiB,KAAK,OAAO,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
//#region src/providers/Released.ts
|
|
3
|
+
/** Provider release evidence, independent of supervision or browser implementation. */
|
|
4
|
+
/** The provider confirmed the resource ended. */
|
|
5
|
+
var Settled = class extends Schema.TaggedClass()("Settled", {}) {};
|
|
6
|
+
/** The resource may still run, and bill, because its end could not be confirmed. */
|
|
7
|
+
var Unconfirmed = class extends Schema.TaggedClass()("Unconfirmed", { detail: Schema.String }) {};
|
|
8
|
+
const Released = Schema.Union([Settled, Unconfirmed]);
|
|
9
|
+
//#endregion
|
|
10
|
+
export { Released, Settled, Unconfirmed };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=Released.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Released.mjs","names":[],"sources":["../../src/providers/Released.ts"],"sourcesContent":["/** Provider release evidence, independent of supervision or browser implementation. */\nimport { Schema } from \"effect\";\n\n/** The provider confirmed the resource ended. */\nexport class Settled extends Schema.TaggedClass<Settled>()(\"Settled\", {}) {}\n\n/** The resource may still run, and bill, because its end could not be confirmed. */\nexport class Unconfirmed extends Schema.TaggedClass<Unconfirmed>()(\"Unconfirmed\", {\n detail: Schema.String,\n}) {}\n\nexport const Released = Schema.Union([Settled, Unconfirmed]);\nexport type Released = typeof Released.Type;\n"],"mappings":";;;;AAIA,IAAa,UAAb,cAA6B,OAAO,YAAqB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;;AAG3E,IAAa,cAAb,cAAiC,OAAO,YAAyB,CAAC,CAAC,eAAe,EAChF,QAAQ,OAAO,OACjB,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAa,WAAW,OAAO,MAAM,CAAC,SAAS,WAAW,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { t as BrowserError } from "../BrowserError-BlcmLVzn.mjs";
|
|
2
|
+
import { f as Page } from "../Page-CvsOEorc.mjs";
|
|
3
|
+
import { Duration, Effect } from "effect";
|
|
4
|
+
//#region src/stillness/Stillness.d.ts
|
|
5
|
+
export interface Options {
|
|
6
|
+
readonly still?: "screen" | "content" | "foreground" | undefined;
|
|
7
|
+
readonly quietMillis: number;
|
|
8
|
+
readonly timeout?: Duration.Input | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare const wait: (page: Page, options: Options) => Effect.Effect<void, BrowserError, never>;
|
|
11
|
+
//#endregion
|
|
12
|
+
//# sourceMappingURL=Stillness.d.mts.map
|