effect-browser 0.3.0-beta.23 → 0.3.0-beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +437 -142
- package/dist/Action.d.mts +1 -1
- package/dist/Action.mjs +61 -9
- package/dist/Action.mjs.map +1 -1
- package/dist/Browser.d.mts +2 -2
- package/dist/Browser.mjs +2 -2
- package/dist/BrowserError.d.mts +2 -2
- package/dist/BrowserError.mjs +194 -41
- package/dist/BrowserError.mjs.map +1 -1
- package/dist/BrowserEvent.d.mts +2 -2
- package/dist/BrowserEvent.mjs +185 -35
- package/dist/BrowserEvent.mjs.map +1 -1
- package/dist/Cdp.d.mts +15 -0
- package/dist/Cdp.mjs +22 -0
- package/dist/Cdp.mjs.map +1 -0
- package/dist/Change.d.mts +2 -2
- package/dist/Change.mjs +40 -7
- package/dist/Change.mjs.map +1 -1
- package/dist/Frame.d.mts +2 -2
- package/dist/Frame.mjs +132 -14
- package/dist/Frame.mjs.map +1 -1
- package/dist/InputStyle.d.mts +153 -0
- package/dist/InputStyle.mjs +2 -0
- package/dist/Layout.d.mts +2 -0
- package/dist/Layout.mjs +123 -0
- package/dist/Layout.mjs.map +1 -0
- package/dist/Overlay.d.mts +2 -0
- package/dist/Overlay.mjs +58 -0
- package/dist/Overlay.mjs.map +1 -0
- package/dist/Page.d.mts +2 -2
- package/dist/Page.mjs +2 -2
- package/dist/PageTime.d.mts +2 -0
- package/dist/PageTime.mjs +17 -0
- package/dist/PageTime.mjs.map +1 -0
- package/dist/Pose.d.mts +2 -0
- package/dist/Pose.mjs +65 -0
- package/dist/Pose.mjs.map +1 -0
- package/dist/Site.d.mts +984 -0
- package/dist/Site.mjs +110 -0
- package/dist/Site.mjs.map +1 -0
- package/dist/Snapshot.d.mts +2 -2
- package/dist/Snapshot.mjs +87 -6
- package/dist/Snapshot.mjs.map +1 -1
- package/dist/Text.d.mts +2 -0
- package/dist/Text.mjs +45 -0
- package/dist/Text.mjs.map +1 -0
- package/dist/Window.d.mts +2 -2
- package/dist/Window.mjs +31 -6
- package/dist/Window.mjs.map +1 -1
- package/dist/ai/BrowserTools.d.mts +4987 -0
- package/dist/ai/BrowserTools.mjs +3 -0
- package/dist/ai/PageControl.d.mts +286 -0
- package/dist/ai/PageControl.mjs +426 -0
- package/dist/ai/PageControl.mjs.map +1 -0
- package/dist/ai/PromptCache.d.mts +16 -0
- package/dist/ai/PromptCache.mjs +72 -0
- package/dist/ai/PromptCache.mjs.map +1 -0
- package/dist/ai/Tabs.d.mts +2 -0
- package/dist/ai/Tabs.mjs +72 -0
- package/dist/ai/Tabs.mjs.map +1 -0
- package/dist/ai/ToolError.d.mts +34 -0
- package/dist/ai/ToolError.mjs +2 -0
- package/dist/ai/index.d.mts +6 -0
- package/dist/ai/index.mjs +6 -0
- package/dist/index.d.mts +7 -15
- package/dist/index.mjs +9 -8
- package/dist/{Action-24sLOubi.d.mts → internal/Action-CkanNTUw.d.mts} +64 -4
- package/dist/{Browser-wZhwZSlG.d.mts → internal/Browser-DD9Vm1c-.d.mts} +80 -10
- package/dist/{Browser-BKPAbyys.mjs → internal/Browser-vzD7i2oj.mjs} +658 -495
- package/dist/internal/Browser-vzD7i2oj.mjs.map +1 -0
- package/dist/{BrowserError-BlcmLVzn.d.mts → internal/BrowserError-CsuRYcDX.d.mts} +187 -28
- package/dist/{BrowserEvent-lLqJ3GJS.d.mts → internal/BrowserEvent-tGPYYf6R.d.mts} +197 -18
- package/dist/internal/BrowserTools-Yi3lOX4h.mjs +497 -0
- package/dist/internal/BrowserTools-Yi3lOX4h.mjs.map +1 -0
- package/dist/{Style-AO4V7Czt.mjs → internal/InputStyle-CPzxoN4g.mjs} +94 -16
- package/dist/internal/InputStyle-CPzxoN4g.mjs.map +1 -0
- package/dist/{moment/Moment.mjs → internal/Moment-CstaX1mR.mjs} +49 -16
- package/dist/internal/Moment-CstaX1mR.mjs.map +1 -0
- package/dist/{moment/Moment.d.mts → internal/Moment-DOcldBdf.d.mts} +54 -21
- package/dist/internal/Page-BfGxn7oN.d.mts +1553 -0
- package/dist/{Page-BF5izr8R.mjs → internal/Page-DqF-tuTx.mjs} +62 -72
- package/dist/internal/Page-DqF-tuTx.mjs.map +1 -0
- package/dist/internal/Release-CFONkPDP.d.mts +39 -0
- package/dist/internal/Stage-D5ymSXDT.mjs +298 -0
- package/dist/internal/Stage-D5ymSXDT.mjs.map +1 -0
- package/dist/internal/Stillness-DCPeAN1a.mjs +1124 -0
- package/dist/internal/Stillness-DCPeAN1a.mjs.map +1 -0
- package/dist/internal/Supervisor-BcY_QNIY.d.mts +108 -0
- package/dist/internal/Supervisor-BcglY23c.mjs +531 -0
- package/dist/internal/Supervisor-BcglY23c.mjs.map +1 -0
- package/dist/internal/Tabs-dXMscIUQ.d.mts +52 -0
- package/dist/internal/TestPage-CYiYbh63.d.mts +159 -0
- package/dist/internal/ToolError-DArsRS2m.mjs +117 -0
- package/dist/internal/ToolError-DArsRS2m.mjs.map +1 -0
- package/dist/{plan/index.d.mts → internal/Walk-BNXcfZ2z.d.mts} +59 -35
- package/dist/{plan/index.mjs → internal/Walk-C5ky7uSf.mjs} +83 -51
- package/dist/internal/Walk-C5ky7uSf.mjs.map +1 -0
- package/dist/{ActionPort.mjs → internal/action-port-B5EkeGOR.mjs} +6 -12
- package/dist/internal/action-port-B5EkeGOR.mjs.map +1 -0
- package/dist/internal/cdp/workerd.d.mts +13 -0
- package/dist/internal/cdp/workerd.mjs +19 -0
- package/dist/internal/cdp/workerd.mjs.map +1 -0
- package/dist/{Clock.mjs → internal/clock-BKSAEf00.mjs} +13 -13
- package/dist/internal/clock-BKSAEf00.mjs.map +1 -0
- package/dist/{connection-2KHI4_KN.d.mts → internal/connection-BaB0vp1o.d.mts} +6 -6
- package/dist/{connection-CK83pvqP.mjs → internal/connection-C2X4GmXM.mjs} +19 -15
- package/dist/internal/connection-C2X4GmXM.mjs.map +1 -0
- package/dist/internal/events-DzCrww-y.mjs +72 -0
- package/dist/internal/events-DzCrww-y.mjs.map +1 -0
- package/dist/internal/fold.inpage-CyVZQHZL.d.mts +49 -0
- package/dist/internal/fold.inpage-uhrT-dOB.mjs +49 -0
- package/dist/internal/fold.inpage-uhrT-dOB.mjs.map +1 -0
- package/dist/internal/functions-jBOs6GKv.mjs +27 -0
- package/dist/internal/functions-jBOs6GKv.mjs.map +1 -0
- package/dist/{Geometry-DJx9qrYy.d.mts → internal/geometry-Dhj_ztJs.d.mts} +3 -3
- package/dist/{Geometry.mjs → internal/geometry-Lxyflb9J.mjs} +3 -12
- package/dist/internal/geometry-Lxyflb9J.mjs.map +1 -0
- package/dist/{Matching.mjs → internal/matching-Cs-UeOY0.mjs} +24 -19
- package/dist/internal/matching-Cs-UeOY0.mjs.map +1 -0
- package/dist/internal/page-DFQb-YOK.mjs +436 -0
- package/dist/internal/page-DFQb-YOK.mjs.map +1 -0
- package/dist/internal/pose.inpage-CBFeWcVa.mjs +1996 -0
- package/dist/internal/pose.inpage-CBFeWcVa.mjs.map +1 -0
- package/dist/{Url.mjs → internal/url-DB0pQYk6.mjs} +3 -12
- package/dist/internal/url-DB0pQYk6.mjs.map +1 -0
- package/dist/policy/Policy.d.mts +60 -6
- package/dist/policy/Policy.mjs +52 -9
- package/dist/policy/Policy.mjs.map +1 -1
- package/dist/policy/index.d.mts +2 -0
- package/dist/policy/index.mjs +2 -0
- package/dist/presentation/Film.d.mts +332 -0
- package/dist/presentation/Film.mjs +298 -0
- package/dist/presentation/Film.mjs.map +1 -0
- package/dist/presentation/Motion.d.mts +5 -1
- package/dist/presentation/Motion.mjs +16 -2
- package/dist/presentation/Motion.mjs.map +1 -1
- package/dist/presentation/Presentation.d.mts +48 -6
- package/dist/presentation/Presentation.mjs +28 -9
- package/dist/presentation/Presentation.mjs.map +1 -1
- package/dist/presentation/Stage.d.mts +40 -6
- package/dist/presentation/Stage.mjs +1 -262
- package/dist/presentation/index.d.mts +5 -0
- package/dist/presentation/index.mjs +5 -0
- package/dist/supervisor/Release.d.mts +2 -0
- package/dist/supervisor/Release.mjs +40 -0
- package/dist/supervisor/Release.mjs.map +1 -0
- package/dist/supervisor/Supervisor.d.mts +2 -104
- package/dist/supervisor/Supervisor.mjs +2 -515
- package/dist/supervisor/index.d.mts +3 -0
- package/dist/supervisor/index.mjs +3 -0
- package/dist/testing/HttpCassette.d.mts +98 -0
- package/dist/testing/HttpCassette.mjs +146 -0
- package/dist/testing/HttpCassette.mjs.map +1 -0
- package/dist/testing/Story.d.mts +31 -0
- package/dist/testing/Story.mjs +76 -0
- package/dist/testing/Story.mjs.map +1 -0
- package/dist/testing/TestBrowser.d.mts +191 -0
- package/dist/testing/TestBrowser.mjs +105 -0
- package/dist/testing/TestBrowser.mjs.map +1 -0
- package/dist/testing/TestModel.d.mts +133 -0
- package/dist/testing/TestModel.mjs +209 -0
- package/dist/testing/TestModel.mjs.map +1 -0
- package/dist/testing/TestPage.d.mts +2 -0
- package/dist/testing/TestPage.mjs +47 -0
- package/dist/testing/TestPage.mjs.map +1 -0
- package/dist/testing/index.d.mts +6 -337
- package/dist/testing/index.mjs +6 -515
- package/dist/timeline/Moment.d.mts +3 -0
- package/dist/timeline/Moment.mjs +3 -0
- package/dist/timeline/Stillness.d.mts +34 -0
- package/dist/timeline/Stillness.mjs +2 -0
- package/dist/timeline/index.d.mts +3 -0
- package/dist/timeline/index.mjs +3 -0
- package/dist/walk/Walk.d.mts +2 -0
- package/dist/walk/Walk.mjs +2 -0
- package/dist/walk/index.d.mts +2 -0
- package/dist/walk/index.mjs +2 -0
- package/package.json +54 -133
- package/src/Action.ts +73 -8
- package/src/Browser.ts +85 -14
- package/src/BrowserError.ts +258 -63
- package/src/BrowserEvent.ts +264 -48
- package/src/Cdp.ts +42 -0
- package/src/Change.ts +75 -4
- package/src/Frame.ts +247 -14
- package/src/{Style.ts → InputStyle.ts} +130 -18
- package/src/Layout.ts +187 -0
- package/src/Overlay.ts +76 -0
- package/src/Page.ts +144 -275
- package/src/PageTime.ts +72 -0
- package/src/Pose.ts +81 -0
- package/src/Site.ts +136 -0
- package/src/Snapshot.ts +179 -3
- package/src/Text.ts +60 -0
- package/src/Window.ts +53 -3
- package/src/ai/BrowserTools.ts +778 -0
- package/src/ai/PageControl.ts +702 -0
- package/src/ai/PromptCache.ts +87 -0
- package/src/ai/Tabs.ts +84 -0
- package/src/ai/ToolError.ts +50 -0
- package/src/ai/index.ts +36 -0
- package/src/ai/internal/crops.ts +38 -0
- package/src/ai/internal/points.ts +57 -0
- package/src/ai/internal/receipts.ts +107 -0
- package/src/index.ts +87 -6
- package/src/{ActionPort.ts → internal/action-port.ts} +3 -3
- package/src/{providers → internal/cdp}/connection.ts +19 -12
- package/src/internal/cdp/workerd.ts +36 -0
- package/src/{Clock.ts → internal/clock.ts} +20 -0
- package/src/internal/input/actions.ts +1 -1
- package/src/internal/input/dispatch.ts +2 -2
- package/src/internal/input/guard.inpage.ts +1 -1
- package/src/internal/input/guard.ts +1 -1
- package/src/internal/input/perform.ts +35 -7
- package/src/internal/input/pointer.ts +9 -6
- package/src/internal/input/targets.inpage.ts +3 -3
- package/src/internal/input/targets.ts +1 -1
- package/src/{Matching.ts → internal/matching.ts} +28 -19
- package/src/internal/page/bridge.ts +67 -35
- package/src/internal/page/clock.inpage.ts +306 -0
- package/src/internal/page/compose.inpage.ts +101 -0
- package/src/internal/page/context.ts +4 -2
- package/src/internal/page/functions.ts +84 -0
- package/src/internal/page/navigation.ts +1 -1
- package/src/internal/page/openings.ts +2 -2
- package/src/internal/page/overlay.inpage.ts +96 -0
- package/src/internal/page/overlay.ts +89 -0
- package/src/internal/page/page.ts +39 -29
- package/src/internal/page/port.ts +14 -8
- package/src/internal/page/pose.inpage.ts +200 -0
- package/src/internal/page/pose.ts +80 -0
- package/src/internal/page/replies.ts +1 -1
- package/src/internal/page/requests.ts +1 -1
- package/src/internal/page/scripts.ts +1 -1
- package/src/internal/page/time.inpage.ts +49 -0
- package/src/internal/page/time.ts +122 -0
- package/src/internal/page/viewport.ts +3 -2
- package/src/internal/pictures/capture.ts +1 -4
- package/src/internal/pictures/dimensions.ts +1 -1
- package/src/internal/pictures/frame.ts +1 -1
- package/src/internal/pictures/pictures.ts +144 -91
- package/src/internal/reading/context.inpage.ts +2 -2
- package/src/internal/reading/expect.inpage.ts +1 -1
- package/src/internal/reading/layout.inpage.ts +193 -0
- package/src/internal/reading/layout.ts +101 -0
- package/src/internal/reading/names.inpage.ts +15 -0
- package/src/internal/reading/outline.inpage.ts +5 -21
- package/src/internal/reading/reading.ts +33 -21
- package/src/internal/reading/ready.inpage.ts +21 -26
- package/src/internal/reading/ready.ts +26 -5
- package/src/internal/reading/subjects.inpage.ts +3 -3
- package/src/internal/reading/text.inpage.ts +3 -16
- package/src/internal/reading/walk.inpage.ts +1 -1
- package/src/internal/timeline/changes.inpage.ts +7 -15
- package/src/internal/timeline/changes.ts +17 -5
- package/src/internal/timeline/record.inpage.ts +15 -6
- package/src/internal/timeline/sight.inpage.ts +2 -2
- package/src/internal/timeline/window.ts +3 -4
- package/src/policy/Policy.ts +70 -16
- package/src/policy/index.ts +12 -0
- package/src/presentation/Film.ts +451 -0
- package/src/presentation/Motion.ts +45 -3
- package/src/presentation/Presentation.ts +60 -14
- package/src/presentation/Stage.ts +73 -35
- package/src/presentation/index.ts +30 -0
- package/src/presentation/{feed.ts → internal/feed.ts} +1 -1
- package/src/supervisor/Release.ts +45 -0
- package/src/supervisor/Supervisor.ts +80 -5
- package/src/supervisor/index.ts +18 -0
- package/src/supervisor/{contract.ts → internal/contract.ts} +14 -10
- package/src/supervisor/{lifecycle.ts → internal/lifecycle.ts} +7 -7
- package/src/supervisor/{runtime.ts → internal/runtime.ts} +7 -7
- package/src/testing/HttpCassette.ts +260 -0
- package/src/testing/Story.ts +103 -0
- package/src/testing/TestBrowser.ts +14 -4
- package/src/testing/TestModel.ts +297 -0
- package/src/testing/TestPage.ts +92 -4
- package/src/testing/index.ts +35 -1
- package/src/testing/{evidence.ts → internal/evidence.ts} +19 -11
- package/src/testing/{model.ts → internal/model.ts} +14 -8
- package/src/testing/{page.ts → internal/page.ts} +55 -51
- package/src/{moment → timeline}/Moment.ts +79 -29
- package/src/{stillness → timeline}/Stillness.ts +89 -46
- package/src/timeline/index.ts +18 -0
- package/src/{stillness/Pixels.ts → timeline/internal/pixels.ts} +27 -1
- package/src/{moment → timeline/internal}/words.ts +2 -2
- package/src/walk/Walk.ts +165 -0
- package/src/walk/index.ts +12 -0
- package/src/{plan → walk/internal}/choose.ts +23 -14
- package/src/{plan → walk/internal}/data.ts +37 -14
- package/src/{plan → walk/internal}/execute.ts +79 -36
- package/src/{plan → walk/internal}/record.ts +6 -6
- package/src/{plan → walk/internal}/targets.ts +35 -25
- package/dist/ActionPort.d.mts +0 -15
- package/dist/ActionPort.mjs.map +0 -1
- package/dist/Browser-BKPAbyys.mjs.map +0 -1
- package/dist/Change-Ba7INmay.d.mts +0 -69
- package/dist/Clock.d.mts +0 -57
- package/dist/Clock.mjs.map +0 -1
- package/dist/Frame-UEH2hO5T.d.mts +0 -124
- package/dist/Geometry.d.mts +0 -2
- package/dist/Geometry.mjs.map +0 -1
- package/dist/Matching.d.mts +0 -37
- package/dist/Matching.mjs.map +0 -1
- package/dist/Page-BF5izr8R.mjs.map +0 -1
- package/dist/Page-CvsOEorc.d.mts +0 -566
- package/dist/Released-tURbFmal.d.mts +0 -15
- package/dist/Snapshot-CtBVOtuu.d.mts +0 -73
- package/dist/Stillness-CNlvayIo.mjs +0 -136
- package/dist/Stillness-CNlvayIo.mjs.map +0 -1
- package/dist/Style-AO4V7Czt.mjs.map +0 -1
- package/dist/Style.d.mts +0 -72
- package/dist/Style.mjs +0 -2
- package/dist/Url.d.mts +0 -26
- package/dist/Url.mjs.map +0 -1
- package/dist/Window-CMddGMt1.d.mts +0 -34
- package/dist/connection-CK83pvqP.mjs.map +0 -1
- package/dist/moment/Moment.mjs.map +0 -1
- package/dist/plan/index.mjs.map +0 -1
- package/dist/presentation/Stage.mjs.map +0 -1
- package/dist/presentation/feed.d.mts +0 -20
- package/dist/presentation/feed.mjs +0 -18
- package/dist/presentation/feed.mjs.map +0 -1
- package/dist/providers/Cdp.d.mts +0 -9
- package/dist/providers/Cdp.mjs +0 -15
- package/dist/providers/Cdp.mjs.map +0 -1
- package/dist/providers/Chromium.d.mts +0 -32
- package/dist/providers/Chromium.mjs +0 -55
- package/dist/providers/Chromium.mjs.map +0 -1
- package/dist/providers/Released.d.mts +0 -2
- package/dist/providers/Released.mjs +0 -12
- package/dist/providers/Released.mjs.map +0 -1
- package/dist/stillness/Stillness.d.mts +0 -12
- package/dist/stillness/Stillness.mjs +0 -2
- package/dist/supervisor/Supervisor.mjs.map +0 -1
- package/dist/testing/index.mjs.map +0 -1
- package/dist/workerd/Cdp.d.mts +0 -8
- package/dist/workerd/Cdp.mjs +0 -13
- package/dist/workerd/Cdp.mjs.map +0 -1
- package/src/plan/index.ts +0 -36
- package/src/providers/Cdp.ts +0 -16
- package/src/providers/Chromium.ts +0 -99
- package/src/providers/Released.ts +0 -13
- package/src/workerd/Cdp.ts +0 -11
- /package/dist/{rolldown-runtime-D7D4PA-g.mjs → internal/rolldown-runtime-D7D4PA-g.mjs} +0 -0
- /package/src/{Geometry.ts → internal/geometry.ts} +0 -0
- /package/src/{Url.ts → internal/url.ts} +0 -0
- /package/src/{stillness → timeline/internal}/utilsBundle.d.ts +0 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { t as __exportAll } from "../internal/rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { n as Point } from "../internal/geometry-Lxyflb9J.mjs";
|
|
3
|
+
import { Action } from "../Action.mjs";
|
|
4
|
+
import { refuse } from "../BrowserError.mjs";
|
|
5
|
+
import { i as monotonicMillis } from "../internal/clock-BKSAEf00.mjs";
|
|
6
|
+
import { i as ResolvedTarget } from "../internal/Page-DqF-tuTx.mjs";
|
|
7
|
+
import { Image, read } from "../Frame.mjs";
|
|
8
|
+
import { Layout, measure } from "../Layout.mjs";
|
|
9
|
+
import { Clock, Duration, Effect, Function, Schema, Stream } from "effect";
|
|
10
|
+
//#region src/presentation/Film.ts
|
|
11
|
+
/**
|
|
12
|
+
* Filming a page as a function of time: a new screenshot at each time a caller asks for, of the
|
|
13
|
+
* page as it is at that film time, with what the caller draws over it then. Film time comes from
|
|
14
|
+
* a held page (`PageTime.hold`), which steps to each frame however long the last one took, so a
|
|
15
|
+
* frame costs one call to step the page and one screenshot; from a page that seeks itself; or
|
|
16
|
+
* from real time. The frames are pictures; encoding them is the caller's.
|
|
17
|
+
*
|
|
18
|
+
* Loading takes real time, so a film holds its time while the page loads a new document: the
|
|
19
|
+
* first frame that finds one waits for it to be ready, measures its layout, and says so as a
|
|
20
|
+
* `Passage`, which `at` sees from then on. On real time the film's start moves on by the wait.
|
|
21
|
+
*
|
|
22
|
+
* @stability experimental
|
|
23
|
+
* @since 0.3.0
|
|
24
|
+
*/
|
|
25
|
+
var Film_exports = /* @__PURE__ */ __exportAll({
|
|
26
|
+
Contact: () => Contact,
|
|
27
|
+
Passage: () => Passage,
|
|
28
|
+
Sent: () => Sent,
|
|
29
|
+
Shot: () => Shot,
|
|
30
|
+
Summary: () => Summary,
|
|
31
|
+
frames: () => frames,
|
|
32
|
+
summary: () => summary
|
|
33
|
+
});
|
|
34
|
+
const Count = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
35
|
+
const Millis = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));
|
|
36
|
+
/**
|
|
37
|
+
* An input to send at film time `t`, in ms, with the caller's name for it.
|
|
38
|
+
*
|
|
39
|
+
* @stability experimental
|
|
40
|
+
* @category schemas
|
|
41
|
+
* @since 0.3.0
|
|
42
|
+
*/
|
|
43
|
+
const Contact = Schema.Struct({
|
|
44
|
+
t: Millis,
|
|
45
|
+
action: Action,
|
|
46
|
+
label: Schema.optional(Schema.String)
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* An input as it was sent, at its film time.
|
|
50
|
+
*
|
|
51
|
+
* @stability experimental
|
|
52
|
+
* @category schemas
|
|
53
|
+
* @since 0.3.0
|
|
54
|
+
*/
|
|
55
|
+
var Sent = class extends Schema.Class("effect-browser/presentation/Film/Sent")({
|
|
56
|
+
t: Millis,
|
|
57
|
+
label: Schema.optional(Schema.String),
|
|
58
|
+
action: Action,
|
|
59
|
+
/** What a click resolved its target to, before its input. */
|
|
60
|
+
target: Schema.optional(ResolvedTarget),
|
|
61
|
+
/** The page's document after it. */
|
|
62
|
+
document: Count
|
|
63
|
+
}) {};
|
|
64
|
+
/**
|
|
65
|
+
* The page's move to a new document, at the film time of the first frame that found it.
|
|
66
|
+
*
|
|
67
|
+
* @stability experimental
|
|
68
|
+
* @category schemas
|
|
69
|
+
* @since 0.3.0
|
|
70
|
+
*/
|
|
71
|
+
var Passage = class extends Schema.Class("effect-browser/presentation/Film/Passage")({
|
|
72
|
+
t: Millis,
|
|
73
|
+
/** The address of the document it left. */
|
|
74
|
+
left: Schema.String,
|
|
75
|
+
document: Count,
|
|
76
|
+
url: Schema.String,
|
|
77
|
+
/** Real milliseconds from the film's last step on the page before to the document's being ready. */
|
|
78
|
+
loadedAfter: Millis,
|
|
79
|
+
/** The new document's layout, ready, with the film's `picks`. */
|
|
80
|
+
layout: Layout
|
|
81
|
+
}) {};
|
|
82
|
+
/**
|
|
83
|
+
* One frame: its picture at film time `t`, in ms, and what taking it cost in real time.
|
|
84
|
+
*
|
|
85
|
+
* @stability experimental
|
|
86
|
+
* @category schemas
|
|
87
|
+
* @since 0.3.0
|
|
88
|
+
*/
|
|
89
|
+
var Shot = class extends Schema.Class("effect-browser/presentation/Film/Shot")({
|
|
90
|
+
index: Count,
|
|
91
|
+
t: Millis,
|
|
92
|
+
image: Image,
|
|
93
|
+
/** The page's document and address after the picture, as `Page.state` gives them. */
|
|
94
|
+
document: Count,
|
|
95
|
+
url: Schema.String,
|
|
96
|
+
/** Where the document was scrolled to, in CSS pixels, on held time. */
|
|
97
|
+
scroll: Schema.optional(Point),
|
|
98
|
+
/** The inputs sent since the frame before. */
|
|
99
|
+
sent: Schema.Array(Sent),
|
|
100
|
+
/** The new document this frame was the first to find. */
|
|
101
|
+
passage: Schema.optional(Passage),
|
|
102
|
+
/** Screenshots that timed out before this one. */
|
|
103
|
+
retries: Count,
|
|
104
|
+
/** Real milliseconds from the frame's start to its picture. */
|
|
105
|
+
took: Millis,
|
|
106
|
+
/**
|
|
107
|
+
* When its picture was taken, in host monotonic milliseconds on the browser's clock, as a
|
|
108
|
+
* `Change`'s times are. On held time, the first shot at or after a change's `at` is the first
|
|
109
|
+
* that shows it; on real time, the page may change while it is pictured.
|
|
110
|
+
*/
|
|
111
|
+
at: Schema.Finite
|
|
112
|
+
}) {};
|
|
113
|
+
/**
|
|
114
|
+
* What a film cost, from its shots.
|
|
115
|
+
*
|
|
116
|
+
* @stability experimental
|
|
117
|
+
* @category schemas
|
|
118
|
+
* @since 0.3.0
|
|
119
|
+
*/
|
|
120
|
+
var Summary = class extends Schema.Class("effect-browser/presentation/Film/Summary")({
|
|
121
|
+
frames: Count,
|
|
122
|
+
retries: Count,
|
|
123
|
+
/** Real milliseconds, all frames' and the slowest one's. */
|
|
124
|
+
took: Millis,
|
|
125
|
+
slowest: Millis,
|
|
126
|
+
/** Every input sent, and every passage, in order. */
|
|
127
|
+
sent: Schema.Array(Sent),
|
|
128
|
+
passages: Schema.Array(Passage)
|
|
129
|
+
}) {};
|
|
130
|
+
const operation = "Film.frames";
|
|
131
|
+
function* rated(fps, from, to) {
|
|
132
|
+
const count = Math.round((to - from) * fps / 1e3);
|
|
133
|
+
for (let index = 0; index < count; index++) yield from + index * 1e3 / fps;
|
|
134
|
+
}
|
|
135
|
+
const timesOf = (times) => {
|
|
136
|
+
if ("fps" in times) {
|
|
137
|
+
const { fps, from = 0, to } = times;
|
|
138
|
+
return [
|
|
139
|
+
fps,
|
|
140
|
+
from,
|
|
141
|
+
to
|
|
142
|
+
].every(Number.isFinite) && fps > 0 && from >= 0 && to >= from ? Effect.succeed(rated(fps, from, to)) : refuse(operation, "a film's rate is positive and runs from a nonnegative time to a later one");
|
|
143
|
+
}
|
|
144
|
+
return times.every((t, index) => Number.isFinite(t) && t >= 0 && (index === 0 || t >= (times[index - 1] ?? t))) ? Effect.succeed(times) : refuse(operation, "a film's times are finite, nonnegative and in order");
|
|
145
|
+
};
|
|
146
|
+
const mover = (page, time, overlay) => {
|
|
147
|
+
if (typeof time === "object" && "advance" in time) {
|
|
148
|
+
let now = 0;
|
|
149
|
+
const move = (t, { scroll, poses, overlay: content }, drawn) => time.advance(Duration.millis(t - now), {
|
|
150
|
+
scroll,
|
|
151
|
+
poses,
|
|
152
|
+
overlay: drawn ? content : void 0
|
|
153
|
+
}).pipe(Effect.tap(() => Effect.sync(() => {
|
|
154
|
+
now = t;
|
|
155
|
+
})));
|
|
156
|
+
return {
|
|
157
|
+
move,
|
|
158
|
+
skip: () => void 0
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
let start;
|
|
162
|
+
const arrive = time === "real" ? (t) => Effect.suspend(() => {
|
|
163
|
+
const now = monotonicMillis(page.hostClock);
|
|
164
|
+
start ??= now;
|
|
165
|
+
return Effect.sleep(Duration.millis(Math.max(0, start + t - now))).pipe(Effect.provideService(Clock.Clock, page.hostClock));
|
|
166
|
+
}) : time.seek;
|
|
167
|
+
const move = (t, at, drawn) => at.scroll === void 0 && at.poses === void 0 ? arrive(t).pipe(Effect.andThen(drawn && at.overlay !== void 0 && overlay !== void 0 ? overlay.draw(at.overlay) : Effect.void), Effect.as(void 0)) : refuse(operation, "a film scrolls and poses the page only on held time");
|
|
168
|
+
return {
|
|
169
|
+
move,
|
|
170
|
+
skip: (millis) => {
|
|
171
|
+
if (start !== void 0) start += millis;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
const picture = (page, image, retries) => Effect.gen(function* () {
|
|
176
|
+
let timedOut = 0;
|
|
177
|
+
return {
|
|
178
|
+
image: (yield* read(page, {
|
|
179
|
+
...image,
|
|
180
|
+
maxAge: 0
|
|
181
|
+
}).pipe(Effect.tapError((error) => Effect.sync(() => timedOut += error.reason._tag === "Timeout" ? 1 : 0)), Effect.retry({
|
|
182
|
+
times: retries,
|
|
183
|
+
while: (error) => error.reason._tag === "Timeout"
|
|
184
|
+
}))).image,
|
|
185
|
+
retries: timedOut
|
|
186
|
+
};
|
|
187
|
+
});
|
|
188
|
+
const keyOf = (content) => content === void 0 ? void 0 : content._tag === "Svg" ? `svg:${content.markup}` : "empty";
|
|
189
|
+
const film = (page, options) => Stream.unwrap(Effect.gen(function* () {
|
|
190
|
+
const times = yield* timesOf(options.times);
|
|
191
|
+
const retries = options.retries ?? 2;
|
|
192
|
+
if (!Number.isSafeInteger(retries) || retries < 0) return yield* refuse(operation, "retries must be a nonnegative safe integer");
|
|
193
|
+
const inputs = (options.inputs ?? []).toSorted((one, other) => one.t - other.t);
|
|
194
|
+
if (!inputs.every(({ t }) => Number.isFinite(t) && t >= 0)) return yield* refuse(operation, "an input's time is finite and nonnegative");
|
|
195
|
+
let next = 0;
|
|
196
|
+
const { move, skip } = mover(page, options.time, options.overlay);
|
|
197
|
+
const now = () => monotonicMillis(page.hostClock);
|
|
198
|
+
const passages = [];
|
|
199
|
+
const at = (t) => options.at === void 0 ? Effect.succeed({}) : options.at(t, { passages });
|
|
200
|
+
let shown;
|
|
201
|
+
let { document: seen, url: was } = yield* page.state;
|
|
202
|
+
let stepped = now();
|
|
203
|
+
const step = (t, showing, drawn) => Effect.tap(move(t, showing, drawn), () => Effect.sync(() => stepped = now()));
|
|
204
|
+
const arrival = (t) => Effect.gen(function* () {
|
|
205
|
+
const { document, url } = yield* page.state;
|
|
206
|
+
if (document === seen) return void 0;
|
|
207
|
+
yield* page.ready();
|
|
208
|
+
const layout = yield* measure(page, options.picks ?? {});
|
|
209
|
+
const loadedAfter = now() - stepped;
|
|
210
|
+
skip(loadedAfter);
|
|
211
|
+
const passage = new Passage({
|
|
212
|
+
t,
|
|
213
|
+
left: was,
|
|
214
|
+
document,
|
|
215
|
+
url,
|
|
216
|
+
loadedAfter,
|
|
217
|
+
layout
|
|
218
|
+
});
|
|
219
|
+
[seen, was] = [document, url];
|
|
220
|
+
passages.push(passage);
|
|
221
|
+
return passage;
|
|
222
|
+
});
|
|
223
|
+
const send = ({ t, action, label }) => Effect.gen(function* () {
|
|
224
|
+
yield* step(t, yield* at(t), false);
|
|
225
|
+
const done = yield* page.perform(action);
|
|
226
|
+
const { document } = yield* page.state;
|
|
227
|
+
return new Sent({
|
|
228
|
+
t,
|
|
229
|
+
label,
|
|
230
|
+
action,
|
|
231
|
+
target: Schema.is(ResolvedTarget)(done) ? done : void 0,
|
|
232
|
+
document
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
const shoot = (t, index) => Effect.gen(function* () {
|
|
236
|
+
const started = now();
|
|
237
|
+
const sent = [];
|
|
238
|
+
for (let input = inputs[next]; input !== void 0 && input.t <= t; input = inputs[++next]) sent.push(yield* send(input));
|
|
239
|
+
const passage = yield* arrival(t);
|
|
240
|
+
const showing = yield* at(t);
|
|
241
|
+
const key = keyOf(showing.overlay);
|
|
242
|
+
if (key !== void 0 && options.overlay === void 0) return yield* refuse(operation, "drawing needs the page's overlay, open, in `overlay`");
|
|
243
|
+
const scroll = yield* step(t, showing, key !== void 0 && key !== shown);
|
|
244
|
+
shown = key ?? shown;
|
|
245
|
+
const taken = yield* picture(page, options.image, retries);
|
|
246
|
+
const pictured = now();
|
|
247
|
+
const { document, url } = yield* page.state;
|
|
248
|
+
return new Shot({
|
|
249
|
+
index,
|
|
250
|
+
t,
|
|
251
|
+
image: taken.image,
|
|
252
|
+
document,
|
|
253
|
+
url,
|
|
254
|
+
scroll,
|
|
255
|
+
sent,
|
|
256
|
+
passage,
|
|
257
|
+
retries: taken.retries,
|
|
258
|
+
took: pictured - started,
|
|
259
|
+
at: pictured
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
return Stream.fromIterable(times).pipe(Stream.zipWithIndex, Stream.mapEffect(([t, index]) => shoot(t, index)));
|
|
263
|
+
}));
|
|
264
|
+
/**
|
|
265
|
+
* Frames of `page` at `times`, one at a time: each moves the page to its film time, draws what
|
|
266
|
+
* `at` gives there when it changed, and takes a new screenshot, again after one that times out.
|
|
267
|
+
*
|
|
268
|
+
* @stability experimental
|
|
269
|
+
* @category constructors
|
|
270
|
+
* @since 0.3.0
|
|
271
|
+
*/
|
|
272
|
+
const frames = Function.dual(2, film);
|
|
273
|
+
/**
|
|
274
|
+
* Run a film's shots, which a caller has usually written out on the way, to what they cost.
|
|
275
|
+
*
|
|
276
|
+
* @stability experimental
|
|
277
|
+
* @category combinators
|
|
278
|
+
* @since 0.3.0
|
|
279
|
+
*/
|
|
280
|
+
const summary = (shots) => Stream.runFold(shots, () => new Summary({
|
|
281
|
+
frames: 0,
|
|
282
|
+
retries: 0,
|
|
283
|
+
took: 0,
|
|
284
|
+
slowest: 0,
|
|
285
|
+
sent: [],
|
|
286
|
+
passages: []
|
|
287
|
+
}), (sum, shot) => new Summary({
|
|
288
|
+
frames: sum.frames + 1,
|
|
289
|
+
retries: sum.retries + shot.retries,
|
|
290
|
+
took: sum.took + shot.took,
|
|
291
|
+
slowest: Math.max(sum.slowest, shot.took),
|
|
292
|
+
sent: [...sum.sent, ...shot.sent],
|
|
293
|
+
passages: shot.passage === void 0 ? sum.passages : [...sum.passages, shot.passage]
|
|
294
|
+
}));
|
|
295
|
+
//#endregion
|
|
296
|
+
export { Contact, Passage, Sent, Shot, Summary, frames, summary, Film_exports as t };
|
|
297
|
+
|
|
298
|
+
//# sourceMappingURL=Film.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Film.mjs","names":["Layout.Layout","Frame.Image","Frame.read","Layout.measure"],"sources":["../../src/presentation/Film.ts"],"sourcesContent":["/**\n * Filming a page as a function of time: a new screenshot at each time a caller asks for, of the\n * page as it is at that film time, with what the caller draws over it then. Film time comes from\n * a held page (`PageTime.hold`), which steps to each frame however long the last one took, so a\n * frame costs one call to step the page and one screenshot; from a page that seeks itself; or\n * from real time. The frames are pictures; encoding them is the caller's.\n *\n * Loading takes real time, so a film holds its time while the page loads a new document: the\n * first frame that finds one waits for it to be ready, measures its layout, and says so as a\n * `Passage`, which `at` sees from then on. On real time the film's start moves on by the wait.\n *\n * @stability experimental\n * @since 0.3.0\n */\nimport { Clock, Duration, Effect, Function, Schema, Stream } from \"effect\";\n\nimport { Action } from \"../Action.ts\";\nimport { type BrowserError, refuse } from \"../BrowserError.ts\";\nimport * as Frame from \"../Frame.ts\";\nimport { monotonicMillis } from \"../internal/clock.ts\";\nimport { Point } from \"../internal/geometry.ts\";\nimport * as Layout from \"../Layout.ts\";\nimport type { Content, Overlay } from \"../Overlay.ts\";\nimport { type Page, ResolvedTarget } from \"../Page.ts\";\nimport type { Held, Step } from \"../PageTime.ts\";\n\n/**\n * What a frame shows over the page, and, on held time, where the page is scrolled to then and how\n * its elements are posed, with the page's poses open.\n *\n * @stability experimental\n * @category models\n * @since 0.3.0\n */\nexport type At = Step;\n\n/**\n * Frames at `fps` from `from` (0 by default) until before `to`, or at these times, in ms.\n *\n * @stability experimental\n * @category models\n * @since 0.3.0\n */\nexport type Times =\n | { readonly fps: number; readonly from?: number | undefined; readonly to: number }\n | ReadonlyArray<number>;\n\n/**\n * Where film time comes from: a held page, stepped to each frame; a page's own seek, given each\n * frame's time; or real time from the film's start, each frame taken when its time comes.\n *\n * @stability experimental\n * @category models\n * @since 0.3.0\n */\nexport type Time =\n | Held\n | { readonly seek: (t: number) => Effect.Effect<void, BrowserError> }\n | \"real\";\n\n/**\n * @stability experimental\n * @category options\n * @since 0.3.0\n */\nexport interface Options<E = never> {\n readonly times: Times;\n readonly time: Time;\n /** What the page shows at a film time, each frame's and each input's, from the passages so far. */\n readonly at?:\n | ((t: number, film: { readonly passages: ReadonlyArray<Passage> }) => Effect.Effect<At, E>)\n | undefined;\n /** What to measure in each new document the film arrives in. */\n readonly picks?: Layout.Picks | undefined;\n /**\n * Inputs sent at their film times, in time order, each before the first frame at or after it:\n * the page is moved to its time, and on held time it answers as its time is stepped on. One that\n * fails fails the film.\n */\n readonly inputs?: ReadonlyArray<Contact> | undefined;\n /** The page's overlay, open, that `at`'s drawings go to. */\n readonly overlay?: Overlay | undefined;\n /**\n * How each frame is taken. For frames with more pixels than the layout, paint the page first\n * (`Frame.paint`) and take them at `scale: \"device\"`.\n */\n readonly image?: Pick<Frame.FrameOptions, \"format\" | \"quality\" | \"scale\"> | undefined;\n /** How many times a frame's screenshot is taken again after it times out. Defaults to 2. */\n readonly retries?: number | undefined;\n}\n\nconst Count = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));\nconst Millis = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));\n\n/**\n * An input to send at film time `t`, in ms, with the caller's name for it.\n *\n * @stability experimental\n * @category schemas\n * @since 0.3.0\n */\nexport const Contact = Schema.Struct({\n t: Millis,\n action: Action,\n label: Schema.optional(Schema.String),\n});\n\n/**\n * @stability experimental\n * @category models\n * @since 0.3.0\n */\nexport type Contact = typeof Contact.Type;\n\n/**\n * An input as it was sent, at its film time.\n *\n * @stability experimental\n * @category schemas\n * @since 0.3.0\n */\nexport class Sent extends Schema.Class<Sent>(\"effect-browser/presentation/Film/Sent\")({\n t: Millis,\n label: Schema.optional(Schema.String),\n action: Action,\n /** What a click resolved its target to, before its input. */\n target: Schema.optional(ResolvedTarget),\n /** The page's document after it. */\n document: Count,\n}) {}\n\n/**\n * The page's move to a new document, at the film time of the first frame that found it.\n *\n * @stability experimental\n * @category schemas\n * @since 0.3.0\n */\nexport class Passage extends Schema.Class<Passage>(\"effect-browser/presentation/Film/Passage\")({\n t: Millis,\n /** The address of the document it left. */\n left: Schema.String,\n document: Count,\n url: Schema.String,\n /** Real milliseconds from the film's last step on the page before to the document's being ready. */\n loadedAfter: Millis,\n /** The new document's layout, ready, with the film's `picks`. */\n layout: Layout.Layout,\n}) {}\n\n/**\n * One frame: its picture at film time `t`, in ms, and what taking it cost in real time.\n *\n * @stability experimental\n * @category schemas\n * @since 0.3.0\n */\nexport class Shot extends Schema.Class<Shot>(\"effect-browser/presentation/Film/Shot\")({\n index: Count,\n t: Millis,\n image: Frame.Image,\n /** The page's document and address after the picture, as `Page.state` gives them. */\n document: Count,\n url: Schema.String,\n /** Where the document was scrolled to, in CSS pixels, on held time. */\n scroll: Schema.optional(Point),\n /** The inputs sent since the frame before. */\n sent: Schema.Array(Sent),\n /** The new document this frame was the first to find. */\n passage: Schema.optional(Passage),\n /** Screenshots that timed out before this one. */\n retries: Count,\n /** Real milliseconds from the frame's start to its picture. */\n took: Millis,\n /**\n * When its picture was taken, in host monotonic milliseconds on the browser's clock, as a\n * `Change`'s times are. On held time, the first shot at or after a change's `at` is the first\n * that shows it; on real time, the page may change while it is pictured.\n */\n at: Schema.Finite,\n}) {}\n\n/**\n * What a film cost, from its shots.\n *\n * @stability experimental\n * @category schemas\n * @since 0.3.0\n */\nexport class Summary extends Schema.Class<Summary>(\"effect-browser/presentation/Film/Summary\")({\n frames: Count,\n retries: Count,\n /** Real milliseconds, all frames' and the slowest one's. */\n took: Millis,\n slowest: Millis,\n /** Every input sent, and every passage, in order. */\n sent: Schema.Array(Sent),\n passages: Schema.Array(Passage),\n}) {}\n\nconst operation = \"Film.frames\";\n\nfunction* rated(fps: number, from: number, to: number) {\n const count = Math.round(((to - from) * fps) / 1000);\n\n for (let index = 0; index < count; index++) yield from + (index * 1000) / fps;\n}\n\nconst timesOf = (times: Times): Effect.Effect<Iterable<number>, BrowserError> => {\n if (\"fps\" in times) {\n const { fps, from = 0, to } = times;\n\n return [fps, from, to].every(Number.isFinite) && fps > 0 && from >= 0 && to >= from\n ? Effect.succeed(rated(fps, from, to))\n : refuse(\n operation,\n \"a film's rate is positive and runs from a nonnegative time to a later one\",\n );\n }\n\n return times.every(\n (t, index) => Number.isFinite(t) && t >= 0 && (index === 0 || t >= (times[index - 1] ?? t)),\n )\n ? Effect.succeed(times)\n : refuse(operation, \"a film's times are finite, nonnegative and in order\");\n};\n\n// `move` takes the page to film time `t`, showing `at` there; `drawn` says whether to draw its\n// overlay. On held time, it says where the document is scrolled to. `skip` leaves real time that\n// film time does not count.\ninterface Mover {\n readonly move: (\n t: number,\n at: At,\n drawn: boolean,\n ) => Effect.Effect<Point | undefined, BrowserError>;\n readonly skip: (millis: number) => void;\n}\n\nconst mover = (page: Page, time: Time, overlay: Overlay | undefined): Mover => {\n if (typeof time === \"object\" && \"advance\" in time) {\n let now = 0;\n\n const move: Mover[\"move\"] = (t, { scroll, poses, overlay: content }, drawn) =>\n time\n .advance(Duration.millis(t - now), {\n scroll,\n poses,\n overlay: drawn ? content : undefined,\n })\n .pipe(\n Effect.tap(() =>\n Effect.sync(() => {\n now = t;\n }),\n ),\n );\n\n return { move, skip: () => undefined };\n }\n let start: number | undefined;\n\n const arrive =\n time === \"real\"\n ? (t: number) =>\n Effect.suspend(() => {\n const now = monotonicMillis(page.hostClock);\n\n start ??= now;\n\n return Effect.sleep(Duration.millis(Math.max(0, start + t - now))).pipe(\n Effect.provideService(Clock.Clock, page.hostClock),\n );\n })\n : time.seek;\n\n const move: Mover[\"move\"] = (t, at, drawn) =>\n at.scroll === undefined && at.poses === undefined\n ? arrive(t).pipe(\n Effect.andThen(\n drawn && at.overlay !== undefined && overlay !== undefined\n ? overlay.draw(at.overlay)\n : Effect.void,\n ),\n Effect.as(undefined),\n )\n : refuse(operation, \"a film scrolls and poses the page only on held time\");\n\n return {\n move,\n skip: (millis) => {\n if (start !== undefined) start += millis;\n },\n };\n};\n\n// A new screenshot, taken again after one that times out, with how many did.\nconst picture = (page: Page, image: Options[\"image\"], retries: number) =>\n Effect.gen(function* () {\n let timedOut = 0;\n\n const taken = yield* Frame.read(page, { ...image, maxAge: 0 }).pipe(\n Effect.tapError((error) =>\n Effect.sync(() => (timedOut += error.reason._tag === \"Timeout\" ? 1 : 0)),\n ),\n Effect.retry({ times: retries, while: (error) => error.reason._tag === \"Timeout\" }),\n );\n\n return { image: taken.image, retries: timedOut };\n });\n\nconst keyOf = (content: Content | undefined) =>\n content === undefined ? undefined : content._tag === \"Svg\" ? `svg:${content.markup}` : \"empty\";\n\nconst film = <E = never>(page: Page, options: Options<E>): Stream.Stream<Shot, BrowserError | E> =>\n Stream.unwrap(\n Effect.gen(function* () {\n const times = yield* timesOf(options.times);\n const retries = options.retries ?? 2;\n\n if (!Number.isSafeInteger(retries) || retries < 0)\n return yield* refuse(operation, \"retries must be a nonnegative safe integer\");\n const inputs = (options.inputs ?? []).toSorted((one, other) => one.t - other.t);\n\n if (!inputs.every(({ t }) => Number.isFinite(t) && t >= 0))\n return yield* refuse(operation, \"an input's time is finite and nonnegative\");\n let next = 0;\n const { move, skip } = mover(page, options.time, options.overlay);\n const now = () => monotonicMillis(page.hostClock);\n const passages: Array<Passage> = [];\n\n const at = (t: number) =>\n options.at === undefined ? Effect.succeed<At>({}) : options.at(t, { passages });\n\n let shown: string | undefined;\n let { document: seen, url: was } = yield* page.state;\n let stepped = now();\n\n // Take the page to film time `t`, and note when, as a passage's wait counts from it.\n const step = (t: number, showing: At, drawn: boolean) =>\n Effect.tap(move(t, showing, drawn), () => Effect.sync(() => (stepped = now())));\n\n // A document the page moved to since the last frame, once it is ready.\n const arrival = (t: number) =>\n Effect.gen(function* () {\n const { document, url } = yield* page.state;\n\n if (document === seen) return undefined;\n yield* page.ready();\n const layout = yield* Layout.measure(page, options.picks ?? {});\n const loadedAfter = now() - stepped;\n\n skip(loadedAfter);\n const passage = new Passage({ t, left: was, document, url, loadedAfter, layout });\n\n [seen, was] = [document, url];\n passages.push(passage);\n\n return passage;\n });\n\n const send = ({ t, action, label }: Contact) =>\n Effect.gen(function* () {\n yield* step(t, yield* at(t), false);\n const done = yield* page.perform(action);\n const { document } = yield* page.state;\n const target = Schema.is(ResolvedTarget)(done) ? done : undefined;\n\n return new Sent({ t, label, action, target, document });\n });\n\n const shoot = (t: number, index: number) =>\n Effect.gen(function* () {\n const started = now();\n const sent: Array<Sent> = [];\n\n for (\n let input = inputs[next];\n input !== undefined && input.t <= t;\n input = inputs[++next]\n )\n sent.push(yield* send(input));\n const passage = yield* arrival(t);\n const showing = yield* at(t);\n const key = keyOf(showing.overlay);\n\n if (key !== undefined && options.overlay === undefined)\n return yield* refuse(operation, \"drawing needs the page's overlay, open, in `overlay`\");\n const scroll = yield* step(t, showing, key !== undefined && key !== shown);\n\n shown = key ?? shown;\n const taken = yield* picture(page, options.image, retries);\n const pictured = now();\n const { document, url } = yield* page.state;\n\n return new Shot({\n index,\n t,\n image: taken.image,\n document,\n url,\n scroll,\n sent,\n passage,\n retries: taken.retries,\n took: pictured - started,\n at: pictured,\n });\n });\n\n return Stream.fromIterable(times).pipe(\n Stream.zipWithIndex,\n Stream.mapEffect(([t, index]) => shoot(t, index)),\n );\n }),\n );\n\n/**\n * Frames of `page` at `times`, one at a time: each moves the page to its film time, draws what\n * `at` gives there when it changed, and takes a new screenshot, again after one that times out.\n *\n * @stability experimental\n * @category constructors\n * @since 0.3.0\n */\nexport const frames: {\n <E = never>(options: Options<E>): (page: Page) => Stream.Stream<Shot, BrowserError | E>;\n <E = never>(page: Page, options: Options<E>): Stream.Stream<Shot, BrowserError | E>;\n} = Function.dual(2, film);\n\n/**\n * Run a film's shots, which a caller has usually written out on the way, to what they cost.\n *\n * @stability experimental\n * @category combinators\n * @since 0.3.0\n */\nexport const summary = <E, R>(shots: Stream.Stream<Shot, E, R>): Effect.Effect<Summary, E, R> =>\n Stream.runFold(\n shots,\n () => new Summary({ frames: 0, retries: 0, took: 0, slowest: 0, sent: [], passages: [] }),\n (sum, shot) =>\n new Summary({\n frames: sum.frames + 1,\n retries: sum.retries + shot.retries,\n took: sum.took + shot.took,\n slowest: Math.max(sum.slowest, shot.took),\n sent: [...sum.sent, ...shot.sent],\n passages: shot.passage === undefined ? sum.passages : [...sum.passages, shot.passage],\n }),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,MAAM,Q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ACrB,SAAS,IAAI,UAAU,KAAK;CAC5B,MAAM,IAAI,OAAO,KAAK;CACtB,SAAS,KAAK,IAAI,IAAI,SAAS,KAAK,IAAI;CACxC,MAAM,CAAC,GAAG,IAAI,MAAM,GAAG,KAAK,IAAI;CAChC,UAAU,KAAK,YAAY,KAAA,IAAY,IAAI,WAAW,CAAC,GAAG,IAAI,UAAU,KAAK,OAAO;AACtF,CAAC,CACL"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as Sample, n as Planner, o as maximumDurationMillis, r as Point, s as maximumSamples, t as Plan } from "../internal/geometry-Dhj_ztJs.mjs";
|
|
2
2
|
declare namespace Motion_d_exports {
|
|
3
3
|
export { Plan, Planner, Point, Sample, lognormal, maximumDurationMillis, maximumSamples };
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
6
|
* The research's tuned two-stroke sigma-lognormal model: a fast stroke toward the target and a
|
|
7
7
|
* slower one that homes in on it, with a little bend, drawn from `Random`.
|
|
8
|
+
*
|
|
9
|
+
* @stability stable
|
|
10
|
+
* @category constants
|
|
11
|
+
* @since 0.3.0
|
|
8
12
|
*/
|
|
9
13
|
export declare const lognormal: Planner;
|
|
10
14
|
//#endregion
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as __exportAll } from "../internal/rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { a as maximumSamples, i as maximumDurationMillis, n as Point, o as normal, r as Sample, t as Plan } from "../internal/geometry-Lxyflb9J.mjs";
|
|
2
3
|
import { Effect, Random } from "effect";
|
|
3
4
|
//#region src/presentation/Motion.ts
|
|
4
5
|
/**
|
|
5
6
|
* Pointer motion as a complete, bounded schedule, independent of browser input and transport. A
|
|
6
7
|
* presenter takes a planner as a value: `lognormal` here, or another, such as recorded strokes.
|
|
7
8
|
*
|
|
9
|
+
* @stability stable
|
|
8
10
|
* @since 0.3.0
|
|
9
11
|
*/
|
|
12
|
+
var Motion_exports = /* @__PURE__ */ __exportAll({
|
|
13
|
+
Plan: () => Plan,
|
|
14
|
+
Point: () => Point,
|
|
15
|
+
Sample: () => Sample,
|
|
16
|
+
lognormal: () => lognormal,
|
|
17
|
+
maximumDurationMillis: () => maximumDurationMillis,
|
|
18
|
+
maximumSamples: () => maximumSamples
|
|
19
|
+
});
|
|
10
20
|
const tuning = {
|
|
11
21
|
intercept: 115.8,
|
|
12
22
|
slope: 291.8,
|
|
@@ -31,6 +41,10 @@ const cumulative = (time, onset, mu, sigma) => time <= onset ? 0 : (1 + erf((Mat
|
|
|
31
41
|
/**
|
|
32
42
|
* The research's tuned two-stroke sigma-lognormal model: a fast stroke toward the target and a
|
|
33
43
|
* slower one that homes in on it, with a little bend, drawn from `Random`.
|
|
44
|
+
*
|
|
45
|
+
* @stability stable
|
|
46
|
+
* @category constants
|
|
47
|
+
* @since 0.3.0
|
|
34
48
|
*/
|
|
35
49
|
const lognormal = { plan: Effect.fnUntraced(function* (from, to) {
|
|
36
50
|
const scale = Math.max(1, Math.abs(from.x), Math.abs(from.y), Math.abs(to.x), Math.abs(to.y));
|
|
@@ -93,6 +107,6 @@ const lognormal = { plan: Effect.fnUntraced(function* (from, to) {
|
|
|
93
107
|
return samples;
|
|
94
108
|
}) };
|
|
95
109
|
//#endregion
|
|
96
|
-
export { Plan, Point, Sample, lognormal, maximumDurationMillis, maximumSamples };
|
|
110
|
+
export { Plan, Point, Sample, lognormal, maximumDurationMillis, maximumSamples, Motion_exports as t };
|
|
97
111
|
|
|
98
112
|
//# sourceMappingURL=Motion.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Motion.mjs","names":[],"sources":["../../src/presentation/Motion.ts"],"sourcesContent":["/**\n * Pointer motion as a complete, bounded schedule, independent of browser input and transport. A\n * presenter takes a planner as a value: `lognormal` here, or another, such as recorded strokes.\n *\n * @since 0.3.0\n */\nimport { Effect, Random } from \"effect\";\n\nimport {\n normal,\n type Planner,\n type Point,\n type Sample,\n maximumDurationMillis,\n} from \"../
|
|
1
|
+
{"version":3,"file":"Motion.mjs","names":[],"sources":["../../src/presentation/Motion.ts"],"sourcesContent":["/**\n * Pointer motion as a complete, bounded schedule, independent of browser input and transport. A\n * presenter takes a planner as a value: `lognormal` here, or another, such as recorded strokes.\n *\n * @stability stable\n * @since 0.3.0\n */\nimport { Effect, Random } from \"effect\";\n\nimport {\n normal,\n type Planner,\n type Point,\n type Sample,\n maximumDurationMillis,\n} from \"../internal/geometry.ts\";\n\nexport {\n /**\n * @stability stable\n * @category schemas\n * @since 0.3.0\n */\n Point,\n /**\n * @stability stable\n * @category schemas\n * @since 0.3.0\n */\n Sample,\n /**\n * @stability stable\n * @category schemas\n * @since 0.3.0\n */\n Plan,\n /**\n * @stability stable\n * @category constants\n * @since 0.3.0\n */\n maximumSamples,\n /**\n * @stability stable\n * @category constants\n * @since 0.3.0\n */\n maximumDurationMillis,\n} from \"../internal/geometry.ts\";\n\n/**\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport type { Planner } from \"../internal/geometry.ts\";\n\n// These are the research's tuned two-stroke parameters. Width scaling was not evaluated, so the\n// model keeps its 40px reference width rather than implying measured target-size behavior.\nconst tuning = {\n intercept: 115.8,\n slope: 291.8,\n durationSigma: 0.407,\n amplitude: 0.989,\n amplitudeSigma: 0.138,\n lateral: 0.0934,\n primaryDuration: 0.512,\n correctionDuration: 0.586,\n overlap: 0.452,\n sigmaLow: 0.155,\n sigmaHigh: 0.53,\n} as const;\n\nconst sampleMillis = 16.7;\n\n// Abramowitz-Stegun 7.1.26 supplies erf without another runtime dependency (error < 1.5e-7).\nconst erf = (value: number) => {\n const x = Math.abs(value);\n const t = 1 / (1 + 0.3275911 * x);\n\n const polynomial =\n ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t;\n\n return Math.sign(value) * (1 - polynomial * Math.exp(-x * x));\n};\n\nconst cumulative = (time: number, onset: number, mu: number, sigma: number) =>\n time <= onset ? 0 : (1 + erf((Math.log(time - onset) - mu) / (sigma * Math.SQRT2))) / 2;\n\nconst plan: Planner[\"plan\"] = Effect.fnUntraced(function* (from, to) {\n // Work in normalized coordinates so finite extreme inputs cannot overflow the displacement.\n const scale = Math.max(1, Math.abs(from.x), Math.abs(from.y), Math.abs(to.x), Math.abs(to.y));\n const startX = from.x / scale;\n const startY = from.y / scale;\n const deltaX = to.x / scale - startX;\n const deltaY = to.y / scale - startY;\n const distance = Math.hypot(deltaX, deltaY);\n\n if (distance * scale < 2) return [{ ...to, afterMillis: 0 }];\n const unitX = deltaX / distance;\n const unitY = deltaY / distance;\n\n const drawnDuration =\n (tuning.intercept + tuning.slope * Math.log2(1 + distance * (scale / 40))) *\n Math.exp((yield* normal) * tuning.durationSigma);\n\n const endFactor = Math.max(\n tuning.primaryDuration,\n tuning.overlap * tuning.primaryDuration + tuning.correctionDuration,\n );\n\n // Bound the duration before evaluating either stroke: dropping a sampled tail would remove\n // its homing correction. The last regular 16.7ms sample remains inside the public time bound.\n const lastRegularSample = Math.floor(maximumDurationMillis / sampleMillis) * sampleMillis;\n const duration = Math.min(drawnDuration, lastRegularSample / endFactor);\n const amplitude = distance * (tuning.amplitude + (yield* normal) * tuning.amplitudeSigma);\n const angle = ((yield* normal) * Math.PI) / 60;\n const primaryX = amplitude * (unitX * Math.cos(angle) - unitY * Math.sin(angle));\n const primaryY = amplitude * (unitY * Math.cos(angle) + unitX * Math.sin(angle));\n const sigma1 = yield* Random.nextBetween(tuning.sigmaLow, tuning.sigmaHigh);\n const primaryDuration = tuning.primaryDuration * duration;\n const mu1 = Math.log(primaryDuration / (Math.exp(3 * sigma1) - Math.exp(-3 * sigma1)));\n const onset1 = -Math.exp(mu1 - 3 * sigma1);\n const sigma2 = yield* Random.nextBetween(tuning.sigmaLow, tuning.sigmaHigh);\n const correctionDuration = tuning.correctionDuration * duration;\n const mu2 = Math.log(correctionDuration / (Math.exp(3 * sigma2) - Math.exp(-3 * sigma2)));\n const onset2 = tuning.overlap * primaryDuration - Math.exp(mu2 - 3 * sigma2);\n const end = Math.max(primaryDuration, onset2 + Math.exp(mu2 + 3 * sigma2));\n const centered = Math.max(Number.EPSILON, yield* Random.next) - 0.5;\n\n const lateral =\n -tuning.lateral * Math.sign(centered) * Math.log(1 - 2 * Math.abs(centered)) * distance;\n\n const count = Math.min(\n Math.ceil(end / sampleMillis),\n Math.floor(lastRegularSample / sampleMillis),\n );\n\n const samples: Array<Sample> = [];\n let last: Point = from;\n\n const coordinate = (value: number) =>\n Math.round(Math.max(-Number.MAX_VALUE, Math.min(Number.MAX_VALUE, value * scale)));\n\n for (let index = 0; index < count; index++) {\n const afterMillis = index * sampleMillis;\n const first = cumulative(afterMillis, onset1, mu1, sigma1);\n const second = cumulative(afterMillis, onset2, mu2, sigma2);\n const bend = lateral * Math.sin(Math.PI * first);\n const x = coordinate(startX + primaryX * first + (deltaX - primaryX) * second - unitY * bend);\n const y = coordinate(startY + primaryY * first + (deltaY - primaryY) * second + unitX * bend);\n\n // A pointer that stays on its pixel reports nothing; the model's timing is unchanged.\n if (x === last.x && y === last.y) continue;\n last = { x, y };\n samples.push({ x, y, afterMillis });\n }\n\n // The exact destination always lands at the model's end, even if a dwell precedes it.\n samples.push({ ...to, afterMillis: count * sampleMillis });\n\n return samples;\n});\n\n/**\n * The research's tuned two-stroke sigma-lognormal model: a fast stroke toward the target and a\n * slower one that homes in on it, with a little bend, drawn from `Random`.\n *\n * @stability stable\n * @category constants\n * @since 0.3.0\n */\nexport const lognormal: Planner = { plan };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA2DA,MAAM,SAAS;CACb,WAAW;CACX,OAAO;CACP,eAAe;CACf,WAAW;CACX,gBAAgB;CAChB,SAAS;CACT,iBAAiB;CACjB,oBAAoB;CACpB,SAAS;CACT,UAAU;CACV,WAAW;AACb;AAEA,MAAM,eAAe;AAGrB,MAAM,OAAO,UAAkB;CAC7B,MAAM,IAAI,KAAK,IAAI,KAAK;CACxB,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,KAAK,CAAC,CAAC;CAEnF,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,SAAS;EAC1C,MAAM,cAAc,QAAQ;EAC5B,MAAM,QAAQ,WAAW,aAAa,QAAQ,KAAK,MAAM;EACzD,MAAM,SAAS,WAAW,aAAa,QAAQ,KAAK,MAAM;EAC1D,MAAM,OAAO,UAAU,KAAK,IAAI,KAAK,KAAK,KAAK;EAC/C,MAAM,IAAI,WAAW,SAAS,WAAW,SAAS,SAAS,YAAY,SAAS,QAAQ,IAAI;EAC5F,MAAM,IAAI,WAAW,SAAS,WAAW,SAAS,SAAS,YAAY,SAAS,QAAQ,IAAI;EAG5F,IAAI,MAAM,KAAK,KAAK,MAAM,KAAK,GAAG;EAClC,OAAO;GAAE;GAAG;EAAE;EACd,QAAQ,KAAK;GAAE;GAAG;GAAG;EAAY,CAAC;CACpC;CAGA,QAAQ,KAAK;EAAE,GAAG;EAAI,aAAa,QAAQ;CAAa,CAAC;CAEzD,OAAO;AACT,CAUoC,EAAK"}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import { t as BrowserError } from "../BrowserError-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { t as BrowserError } from "../internal/BrowserError-CsuRYcDX.mjs";
|
|
2
|
+
import { n as ActionAnnounced } from "../internal/BrowserEvent-tGPYYf6R.mjs";
|
|
3
|
+
import { n as Planner } from "../internal/geometry-Dhj_ztJs.mjs";
|
|
4
|
+
import { o as Page } from "../internal/Page-BfGxn7oN.mjs";
|
|
4
5
|
import { t as Motion_d_exports } from "./Motion.mjs";
|
|
5
6
|
import { Duration, Effect } from "effect";
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
declare namespace Presentation_d_exports {
|
|
8
|
+
export { Options, Pacing, Presenter, View, human, make };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* How long a person waits before acting, and how fast they type.
|
|
12
|
+
*
|
|
13
|
+
* @stability stable
|
|
14
|
+
* @category models
|
|
15
|
+
* @since 0.3.0
|
|
16
|
+
*/
|
|
8
17
|
export interface Pacing {
|
|
9
18
|
readonly expected: Duration.Input;
|
|
10
19
|
readonly surprise: Duration.Input;
|
|
@@ -12,19 +21,52 @@ export interface Pacing {
|
|
|
12
21
|
/** A word is five characters. */
|
|
13
22
|
readonly wordsPerMinute: number;
|
|
14
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* @stability stable
|
|
26
|
+
* @category constants
|
|
27
|
+
* @since 0.3.0
|
|
28
|
+
*/
|
|
15
29
|
export declare const human: Pacing;
|
|
30
|
+
/**
|
|
31
|
+
* @stability stable
|
|
32
|
+
* @category options
|
|
33
|
+
* @since 0.3.0
|
|
34
|
+
*/
|
|
16
35
|
export interface Options {
|
|
17
36
|
readonly pacing?: Pacing | undefined;
|
|
18
37
|
readonly motion?: Planner | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* After a view's action has announced its target, and before its pointer travels there, wait
|
|
40
|
+
* for this: time for whatever is shown performing the input, such as a character, to arrive. It
|
|
41
|
+
* comes after the reaction's wait, holds the page's turn and spends the action's deadline.
|
|
42
|
+
*/
|
|
43
|
+
readonly lead?: ((announced: ActionAnnounced) => Effect.Effect<void>) | undefined;
|
|
19
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* @stability stable
|
|
47
|
+
* @category models
|
|
48
|
+
* @since 0.3.0
|
|
49
|
+
*/
|
|
20
50
|
export type View = Page;
|
|
51
|
+
/**
|
|
52
|
+
* @stability stable
|
|
53
|
+
* @category models
|
|
54
|
+
* @since 0.3.0
|
|
55
|
+
*/
|
|
21
56
|
export interface Presenter {
|
|
22
57
|
/** The same public page view for the same page. */
|
|
23
58
|
readonly view: (page: Page) => View;
|
|
24
59
|
}
|
|
25
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* One hand for the scope; input effects keep their page's authority and failure evidence.
|
|
62
|
+
*
|
|
63
|
+
* @stability stable
|
|
64
|
+
* @category constructors
|
|
65
|
+
* @since 0.3.0
|
|
66
|
+
*/
|
|
26
67
|
export declare const make: (options?: Options | undefined) => Effect.Effect<{
|
|
27
68
|
view: (page: Page) => View;
|
|
28
69
|
}, BrowserError, never>;
|
|
29
70
|
//#endregion
|
|
71
|
+
export { Presentation_d_exports as t };
|
|
30
72
|
//# sourceMappingURL=Presentation.d.mts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { t as __exportAll } from "../internal/rolldown-runtime-D7D4PA-g.mjs";
|
|
1
2
|
import { Busy, refuse, undispatched } from "../BrowserError.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { i as monotonicMillis } from "../internal/clock-BKSAEf00.mjs";
|
|
4
|
+
import { r as methods } from "../internal/action-port-B5EkeGOR.mjs";
|
|
5
|
+
import { i as keyGap, l as provide, o as pause, s as performed } from "../internal/InputStyle-CPzxoN4g.mjs";
|
|
5
6
|
import { lognormal } from "./Motion.mjs";
|
|
6
7
|
import { Deferred, Duration, Effect, MutableRef, Option, Semaphore } from "effect";
|
|
7
8
|
//#region src/presentation/Presentation.ts
|
|
@@ -9,6 +10,16 @@ import { Deferred, Duration, Effect, MutableRef, Option, Semaphore } from "effec
|
|
|
9
10
|
* Input performed for viewers. A presenter owns one pointer and pace. Its public page view applies
|
|
10
11
|
* a style to input after approval, so policy holds leave the hand free. Hand acquisition is bounded
|
|
11
12
|
* by the page's action wait and honours failFast; reactions and input use the page owner's clock.
|
|
13
|
+
* @stability stable
|
|
14
|
+
* @since 0.3.0
|
|
15
|
+
*/
|
|
16
|
+
var Presentation_exports = /* @__PURE__ */ __exportAll({
|
|
17
|
+
human: () => human,
|
|
18
|
+
make: () => make
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* @stability stable
|
|
22
|
+
* @category constants
|
|
12
23
|
* @since 0.3.0
|
|
13
24
|
*/
|
|
14
25
|
const human = {
|
|
@@ -22,7 +33,13 @@ const spread = {
|
|
|
22
33
|
surprise: .4,
|
|
23
34
|
unrelated: .4
|
|
24
35
|
};
|
|
25
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* One hand for the scope; input effects keep their page's authority and failure evidence.
|
|
38
|
+
*
|
|
39
|
+
* @stability stable
|
|
40
|
+
* @category constructors
|
|
41
|
+
* @since 0.3.0
|
|
42
|
+
*/
|
|
26
43
|
const make = Effect.fn("Presentation.make")(function* (options = {}) {
|
|
27
44
|
const pacing = options.pacing ?? human;
|
|
28
45
|
const medians = {
|
|
@@ -47,14 +64,16 @@ const make = Effect.fn("Presentation.make")(function* (options = {}) {
|
|
|
47
64
|
motion: options.motion ?? lognormal,
|
|
48
65
|
wordsPerMinute: pacing.wordsPerMinute
|
|
49
66
|
});
|
|
67
|
+
const { lead } = options;
|
|
50
68
|
const views = /* @__PURE__ */ new WeakMap();
|
|
51
69
|
let last;
|
|
52
70
|
const view = (page) => {
|
|
53
71
|
const known = views.get(page);
|
|
54
72
|
if (known !== void 0) return known;
|
|
55
|
-
const now = () => monotonicMillis(page.
|
|
73
|
+
const now = () => monotonicMillis(page.hostClock);
|
|
56
74
|
const style = {
|
|
57
75
|
...planned,
|
|
76
|
+
lead: lead === void 0 ? void 0 : (announced) => lead(announced).pipe(Effect.withSpan("Presentation.lead")),
|
|
58
77
|
withInput: ({ operation, wait, failFast }) => (effect) => Effect.gen(function* () {
|
|
59
78
|
const asked = now();
|
|
60
79
|
const entered = yield* Deferred.make();
|
|
@@ -65,14 +84,14 @@ const make = Effect.fn("Presentation.make")(function* (options = {}) {
|
|
|
65
84
|
const use = Effect.gen(function* () {
|
|
66
85
|
yield* Deferred.succeed(entered, void 0);
|
|
67
86
|
const document = (yield* page.state).document;
|
|
68
|
-
const kind = last === void 0 || last.page !== page.id || last.clock !== page.
|
|
69
|
-
const left = (last?.clock === page.
|
|
87
|
+
const kind = last === void 0 || last.page !== page.id || last.clock !== page.hostClock ? "unrelated" : last.document === document ? "expected" : "surprise";
|
|
88
|
+
const left = (last?.clock === page.hostClock ? last.at : now()) + (yield* pause(medians[kind], spread[kind])) - now();
|
|
70
89
|
if (left > 0) yield* Effect.sleep(Duration.millis(left)).pipe(Effect.withSpan("Presentation.react"));
|
|
71
90
|
return yield* effect.pipe(Effect.ensuring(Effect.sync(() => {
|
|
72
91
|
last = {
|
|
73
92
|
page: page.id,
|
|
74
93
|
document,
|
|
75
|
-
clock: page.
|
|
94
|
+
clock: page.hostClock,
|
|
76
95
|
at: now()
|
|
77
96
|
};
|
|
78
97
|
})));
|
|
@@ -100,6 +119,6 @@ const make = Effect.fn("Presentation.make")(function* (options = {}) {
|
|
|
100
119
|
return { view };
|
|
101
120
|
});
|
|
102
121
|
//#endregion
|
|
103
|
-
export { human, make };
|
|
122
|
+
export { human, make, Presentation_exports as t };
|
|
104
123
|
|
|
105
124
|
//# sourceMappingURL=Presentation.mjs.map
|