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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Presentation.mjs","names":["
|
|
1
|
+
{"version":3,"file":"Presentation.mjs","names":["InputStyle.keyGap","InputStyle.performed","Motion.lognormal","InputStyle.pause","InputStyle.provide"],"sources":["../../src/presentation/Presentation.ts"],"sourcesContent":["/**\n * Input performed for viewers. A presenter owns one pointer and pace. Its public page view applies\n * a style to input after approval, so policy holds leave the hand free. Hand acquisition is bounded\n * by the page's action wait and honours failFast; reactions and input use the page owner's clock.\n * @stability stable\n * @since 0.3.0\n */\nimport { type Clock, Deferred, Duration, Effect, MutableRef, Option, Semaphore } from \"effect\";\n\nimport { Busy, refuse, undispatched } from \"../BrowserError.ts\";\nimport type { ActionAnnounced } from \"../BrowserEvent.ts\";\nimport * as InputStyle from \"../InputStyle.ts\";\nimport { methods } from \"../internal/action-port.ts\";\nimport { monotonicMillis } from \"../internal/clock.ts\";\nimport type { Page, Point } from \"../Page.ts\";\nimport * as Motion from \"./Motion.ts\";\n\n/**\n * How long a person waits before acting, and how fast they type.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface Pacing {\n readonly expected: Duration.Input;\n readonly surprise: Duration.Input;\n readonly unrelated: Duration.Input;\n /** A word is five characters. */\n readonly wordsPerMinute: number;\n}\n\n/**\n * @stability stable\n * @category constants\n * @since 0.3.0\n */\nexport const human: Pacing = {\n expected: \"280 millis\",\n surprise: \"600 millis\",\n unrelated: \"1 second\",\n wordsPerMinute: 70,\n};\n\n/**\n * @stability stable\n * @category options\n * @since 0.3.0\n */\nexport interface Options {\n readonly pacing?: Pacing | undefined;\n readonly motion?: Motion.Planner | undefined;\n /**\n * After a view's action has announced its target, and before its pointer travels there, wait\n * for this: time for whatever is shown performing the input, such as a character, to arrive. It\n * comes after the reaction's wait, holds the page's turn and spends the action's deadline.\n */\n readonly lead?: ((announced: ActionAnnounced) => Effect.Effect<void>) | undefined;\n}\n\n/**\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport type View = Page;\n\n/**\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface Presenter {\n /** The same public page view for the same page. */\n readonly view: (page: Page) => View;\n}\n\nconst spread = { expected: 0.3, surprise: 0.4, unrelated: 0.4 };\n\n/**\n * One hand for the scope; input effects keep their page's authority and failure evidence.\n *\n * @stability stable\n * @category constructors\n * @since 0.3.0\n */\nexport const make = Effect.fn(\"Presentation.make\")(function* (options: Options = {}) {\n const pacing = options.pacing ?? human;\n const medians = { expected: 0, surprise: 0, unrelated: 0 };\n\n for (const key of [\"expected\", \"surprise\", \"unrelated\"] as const) {\n const duration = Duration.fromInput(pacing[key]);\n\n if (\n Option.isNone(duration) ||\n !Duration.isFinite(duration.value) ||\n Duration.isNegative(duration.value)\n )\n return yield* refuse(\"presentation\", \"reaction durations must be finite and nonnegative\");\n medians[key] = Duration.toMillis(duration.value);\n }\n if (\n !Number.isFinite(pacing.wordsPerMinute) ||\n pacing.wordsPerMinute <= 0 ||\n InputStyle.keyGap(pacing.wordsPerMinute) < 0\n )\n return yield* refuse(\"presentation\", \"wordsPerMinute must be positive and at most 1200\");\n\n const pointer = MutableRef.make(Option.none<Point>());\n const hand = yield* Semaphore.make(1);\n\n const planned = InputStyle.performed({\n pointer,\n motion: options.motion ?? Motion.lognormal,\n wordsPerMinute: pacing.wordsPerMinute,\n });\n\n const { lead } = options;\n\n const views = new WeakMap<Page, View>();\n\n let last:\n | {\n readonly page: string;\n readonly document: number;\n readonly clock: Clock.Clock;\n readonly at: number;\n }\n | undefined;\n\n const view = (page: Page): View => {\n const known = views.get(page);\n\n if (known !== undefined) return known;\n const now = () => monotonicMillis(page.hostClock);\n\n const style: InputStyle.InputStyle = {\n ...planned,\n lead:\n lead === undefined\n ? undefined\n : (announced) => lead(announced).pipe(Effect.withSpan(\"Presentation.lead\")),\n withInput:\n ({ operation, wait, failFast }) =>\n (effect) =>\n Effect.gen(function* () {\n const asked = now();\n const entered = yield* Deferred.make<void>();\n\n const busy = () =>\n undispatched(\n operation,\n new Busy({ waitedMillis: Math.round(now() - asked), ahead: 1 }),\n );\n\n const use = Effect.gen(function* () {\n yield* Deferred.succeed(entered, undefined);\n const document = (yield* page.state).document;\n\n const kind =\n last === undefined || last.page !== page.id || last.clock !== page.hostClock\n ? \"unrelated\"\n : last.document === document\n ? \"expected\"\n : \"surprise\";\n\n const left =\n (last?.clock === page.hostClock ? last.at : now()) +\n (yield* InputStyle.pause(medians[kind], spread[kind])) -\n now();\n\n if (left > 0)\n yield* Effect.sleep(Duration.millis(left)).pipe(\n Effect.withSpan(\"Presentation.react\"),\n );\n\n return yield* effect.pipe(\n Effect.ensuring(\n Effect.sync(() => {\n last = { page: page.id, document, clock: page.hostClock, at: now() };\n }),\n ),\n );\n });\n\n if (failFast)\n return yield* hand\n .withPermitsIfAvailable(1)(use)\n .pipe(\n Effect.flatMap((result) => Effect.fromOption(result).pipe(Effect.mapError(busy))),\n );\n\n // Only admission has a wait budget. Once admitted, the page owns input's deadline.\n return yield* Effect.raceFirst(\n hand.withPermits(1)(use),\n Deferred.await(entered).pipe(\n Effect.timeoutOrElse({ duration: wait, orElse: () => Effect.fail(busy()) }),\n Effect.andThen(Effect.never),\n ),\n );\n }).pipe(Effect.withSpan(\"Presentation.hand\")),\n };\n\n const styled = InputStyle.provide(style);\n const perform: Page[\"perform\"] = (action) => styled(page.perform(action));\n\n const performed: View = {\n ...page,\n ...methods(perform),\n perform,\n goto: page.goto,\n back: page.back,\n reload: page.reload,\n };\n\n views.set(page, performed);\n\n return performed;\n };\n\n return { view } satisfies Presenter;\n});\n"],"mappings":"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"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import { t as BrowserError } from "../BrowserError-
|
|
2
|
-
import {
|
|
3
|
-
import { f as Page } from "../Page-CvsOEorc.mjs";
|
|
1
|
+
import { t as BrowserError } from "../internal/BrowserError-CsuRYcDX.mjs";
|
|
2
|
+
import { Tt as ScreencastOptions, o as Page, vt as CaptureStats, xt as Frame_d_exports, yt as Frame } from "../internal/Page-BfGxn7oN.mjs";
|
|
4
3
|
import { Duration, Effect, Option, Schema, Scope, Stream } from "effect";
|
|
5
|
-
|
|
4
|
+
declare namespace Stage_d_exports {
|
|
5
|
+
export { Cue, Options, Presented, Shown, Stage, make };
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @stability stable
|
|
9
|
+
* @category options
|
|
10
|
+
* @since 0.3.0
|
|
11
|
+
*/
|
|
6
12
|
export interface Options extends ScreencastOptions {
|
|
7
13
|
/** Bound for each first-frame wait. Defaults to 5 seconds. */
|
|
8
14
|
readonly firstFrame?: Duration.Input | undefined;
|
|
@@ -12,8 +18,19 @@ declare const Presented_base: Schema.Class<Presented, Schema.Struct<{
|
|
|
12
18
|
readonly at: Schema.Finite;
|
|
13
19
|
readonly latency: Schema.Finite;
|
|
14
20
|
}>, {}>;
|
|
15
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* A switch that took effect, on the clock shared by browser events and frames.
|
|
23
|
+
*
|
|
24
|
+
* @stability stable
|
|
25
|
+
* @category schemas
|
|
26
|
+
* @since 0.3.0
|
|
27
|
+
*/
|
|
16
28
|
export declare class Presented extends Presented_base {}
|
|
29
|
+
/**
|
|
30
|
+
* @stability stable
|
|
31
|
+
* @category models
|
|
32
|
+
* @since 0.3.0
|
|
33
|
+
*/
|
|
17
34
|
export interface Cue {
|
|
18
35
|
readonly page: Page;
|
|
19
36
|
/** A frame of the current document, or the capture's failure or first-frame timeout. */
|
|
@@ -23,7 +40,13 @@ export interface Cue {
|
|
|
23
40
|
readonly at?: number | undefined;
|
|
24
41
|
}) => Effect.Effect<Presented, BrowserError>;
|
|
25
42
|
}
|
|
26
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* What the output establishes at nondecreasing host times; frames retain their capture times.
|
|
45
|
+
*
|
|
46
|
+
* @stability stable
|
|
47
|
+
* @category models
|
|
48
|
+
* @since 0.3.0
|
|
49
|
+
*/
|
|
27
50
|
export type Shown = {
|
|
28
51
|
readonly _tag: "Painted";
|
|
29
52
|
readonly frame: Frame;
|
|
@@ -41,6 +64,11 @@ export type Shown = {
|
|
|
41
64
|
readonly page: string;
|
|
42
65
|
readonly at: number;
|
|
43
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* @stability stable
|
|
69
|
+
* @category models
|
|
70
|
+
* @since 0.3.0
|
|
71
|
+
*/
|
|
44
72
|
export interface Stage {
|
|
45
73
|
readonly present: (page: Page, options?: {
|
|
46
74
|
readonly at?: number | undefined;
|
|
@@ -57,6 +85,12 @@ export interface Stage {
|
|
|
57
85
|
readonly window?: Duration.Input | undefined;
|
|
58
86
|
}) => Effect.Effect<Option.Option<CaptureStats>, BrowserError>;
|
|
59
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* @stability stable
|
|
90
|
+
* @category constructors
|
|
91
|
+
* @since 0.3.0
|
|
92
|
+
*/
|
|
60
93
|
export declare const make: (options?: Options | undefined) => Effect.Effect<Stage, BrowserError, Scope.Scope>;
|
|
61
94
|
//#endregion
|
|
95
|
+
export { Stage_d_exports as t };
|
|
62
96
|
//# sourceMappingURL=Stage.d.mts.map
|
|
@@ -1,263 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { monotonicMillis } from "../Clock.mjs";
|
|
3
|
-
import { initial, step } from "./feed.mjs";
|
|
4
|
-
import { Cause, Clock, Deferred, Duration, Effect, Exit, Fiber, Option, PubSub, Result, Schedule, Schema, Scope, Stream } from "effect";
|
|
5
|
-
//#region src/presentation/Stage.ts
|
|
6
|
-
/**
|
|
7
|
-
* An output's capture ownership. Cue a page while preparing an event; commit when that event
|
|
8
|
-
* happens. A prepared cue belongs to its caller's scope, and a committed one to the stage.
|
|
9
|
-
* Commits serialize, drain old-page input and refuse stale first frames. `shown` distinguishes
|
|
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
|
-
* @since 0.3.0
|
|
13
|
-
*/
|
|
14
|
-
/** A switch that took effect, on the clock shared by browser events and frames. */
|
|
15
|
-
var Presented = class extends Schema.Class("effect-browser/Presented")({
|
|
16
|
-
page: Schema.String,
|
|
17
|
-
at: Schema.Finite,
|
|
18
|
-
latency: Schema.Finite
|
|
19
|
-
}) {};
|
|
20
|
-
const unavailable = () => undispatched("cue", new InvalidRequest({ detail: "the cue's capture is no longer available" }));
|
|
21
|
-
/** The sole writer of a cue's capture lifecycle; presentation ownership belongs to the stage. */
|
|
22
|
-
const update = (feed, input) => {
|
|
23
|
-
feed.state = step(feed.state, input);
|
|
24
|
-
};
|
|
25
|
-
const restartable = (error) => {
|
|
26
|
-
const { lost, repeat } = consequence(error);
|
|
27
|
-
return lost === "nothing" && repeat !== "pointless";
|
|
28
|
-
};
|
|
29
|
-
const stop = (feed) => Effect.suspend(() => {
|
|
30
|
-
update(feed, { _tag: "Stop" });
|
|
31
|
-
return Scope.close(feed.scope, Exit.void);
|
|
32
|
-
});
|
|
33
|
-
const frameOf = (feed) => {
|
|
34
|
-
const frame = feed.state._tag === "Ready" ? feed.state.latest : void 0;
|
|
35
|
-
return frame !== void 0 && feed.capture?.isCurrent(frame) ? frame : void 0;
|
|
36
|
-
};
|
|
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())));
|
|
38
|
-
const firstOf = (feed, wait) => Effect.suspend(() => {
|
|
39
|
-
if (feed.state._tag === "Stopped") return Effect.fail(unavailable());
|
|
40
|
-
if (frameOf(feed) !== void 0) return Effect.void;
|
|
41
|
-
return Effect.raceFirst(Stream.fromPubSub(feed.changed).pipe(Stream.filter(() => frameOf(feed) !== void 0), Stream.runHead, Effect.asVoid), ended(feed)).pipe(Effect.timeoutOrElse({
|
|
42
|
-
duration: wait,
|
|
43
|
-
orElse: () => failWith("cue", new Timeout({ millis: Duration.toMillis(wait) }))
|
|
44
|
-
}));
|
|
45
|
-
});
|
|
46
|
-
const until = (at, now) => Effect.suspend(() => at > now() ? Effect.sleep(Duration.millis(Math.ceil(at - now()))).pipe(Effect.andThen(until(at, now))) : Effect.void);
|
|
47
|
-
/** Reserve the next turn before waking it; a fresh caller cannot overtake a queued commit. */
|
|
48
|
-
const ordered = () => {
|
|
49
|
-
const waiting = [];
|
|
50
|
-
return (effect) => Effect.acquireUseRelease(Effect.sync(() => {
|
|
51
|
-
const turn = Deferred.makeUnsafe();
|
|
52
|
-
waiting.push(turn);
|
|
53
|
-
if (waiting.length === 1) Deferred.doneUnsafe(turn, Exit.void);
|
|
54
|
-
return turn;
|
|
55
|
-
}), (turn) => Deferred.await(turn).pipe(Effect.andThen(effect)), (turn) => Effect.sync(() => {
|
|
56
|
-
const at = waiting.indexOf(turn);
|
|
57
|
-
waiting.splice(at, 1);
|
|
58
|
-
if (at === 0 && waiting[0] !== void 0) Deferred.doneUnsafe(waiting[0], Exit.void);
|
|
59
|
-
}));
|
|
60
|
-
};
|
|
61
|
-
/** A terminal capture can know the connection is gone before the page receives its close event. */
|
|
62
|
-
const confirm = (feed, frame) => {
|
|
63
|
-
const exit = feed.fiber?.pollUnsafe();
|
|
64
|
-
const failure = exit !== void 0 && Exit.isFailure(exit) ? Cause.findErrorOption(exit.cause) : Option.none();
|
|
65
|
-
if (Option.isSome(failure) && consequence(failure.value).lost !== "nothing") return Effect.fail(failure.value);
|
|
66
|
-
return feed.capture?.confirm(frame) ?? Effect.succeed(false);
|
|
67
|
-
};
|
|
68
|
-
/** Each subscriber confirms silence; a new frame or commit invalidates a probe. */
|
|
69
|
-
const evidence = (output, current, now, hold) => Stream.unwrap(Effect.sync(() => {
|
|
70
|
-
const millis = Duration.toMillis(hold);
|
|
71
|
-
let checkedAt = now();
|
|
72
|
-
let shownAt = Number.NEGATIVE_INFINITY;
|
|
73
|
-
let seen = current();
|
|
74
|
-
let gone;
|
|
75
|
-
const probe = Effect.gen(function* () {
|
|
76
|
-
yield* until(Math.max(checkedAt, current()?.changedAt ?? checkedAt) + millis, now);
|
|
77
|
-
const before = current();
|
|
78
|
-
const frame = before?.frame;
|
|
79
|
-
if (before !== void 0 && now() - before.changedAt < millis) return Option.none();
|
|
80
|
-
checkedAt = now();
|
|
81
|
-
if (before === void 0 || frame === void 0 || gone === before.feed) return Option.none();
|
|
82
|
-
const { feed } = before;
|
|
83
|
-
const confirmed = yield* Effect.result(confirm(feed, frame));
|
|
84
|
-
if (current()?.feed !== feed || current()?.frame !== frame) return Option.none();
|
|
85
|
-
const at = now();
|
|
86
|
-
checkedAt = at;
|
|
87
|
-
if (Result.isFailure(confirmed) && consequence(confirmed.failure).lost !== "nothing") return Option.some({
|
|
88
|
-
feed,
|
|
89
|
-
frame,
|
|
90
|
-
value: {
|
|
91
|
-
_tag: "Gone",
|
|
92
|
-
page: feed.page.id,
|
|
93
|
-
at
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
return Option.some({
|
|
97
|
-
feed,
|
|
98
|
-
frame,
|
|
99
|
-
value: {
|
|
100
|
-
_tag: Result.isSuccess(confirmed) && confirmed.success ? "Still" : "Stalled",
|
|
101
|
-
frame,
|
|
102
|
-
at
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
return Stream.merge(Stream.fromPubSub(output).pipe(Stream.map(({ feed, frame, at }) => ({
|
|
107
|
-
feed,
|
|
108
|
-
frame,
|
|
109
|
-
value: {
|
|
110
|
-
_tag: "Painted",
|
|
111
|
-
frame,
|
|
112
|
-
at
|
|
113
|
-
}
|
|
114
|
-
}))), Stream.fromEffectRepeat(probe).pipe(Stream.filter(Option.isSome), Stream.map(({ value }) => value))).pipe(Stream.filter(({ feed, frame, value }) => {
|
|
115
|
-
if (value._tag === "Painted" && gone !== feed) {
|
|
116
|
-
seen = {
|
|
117
|
-
feed,
|
|
118
|
-
frame
|
|
119
|
-
};
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
seen ??= {
|
|
123
|
-
feed,
|
|
124
|
-
frame
|
|
125
|
-
};
|
|
126
|
-
return value._tag !== "Painted" && seen?.feed === feed && seen.frame === frame;
|
|
127
|
-
}), Stream.map(({ feed, value }) => {
|
|
128
|
-
if (value._tag === "Gone") gone = feed;
|
|
129
|
-
shownAt = Math.max(shownAt, value.at);
|
|
130
|
-
return value.at === shownAt ? value : {
|
|
131
|
-
...value,
|
|
132
|
-
at: shownAt
|
|
133
|
-
};
|
|
134
|
-
}));
|
|
135
|
-
}));
|
|
136
|
-
const openFeed = (page, owner, settings, current, publish) => Effect.gen(function* () {
|
|
137
|
-
const scope = yield* Scope.fork(owner);
|
|
138
|
-
const started = yield* Deferred.make();
|
|
139
|
-
const feed = {
|
|
140
|
-
page,
|
|
141
|
-
capture: void 0,
|
|
142
|
-
scope,
|
|
143
|
-
changed: yield* PubSub.sliding({
|
|
144
|
-
capacity: 1,
|
|
145
|
-
replay: 1
|
|
146
|
-
}),
|
|
147
|
-
state: initial,
|
|
148
|
-
fiber: void 0
|
|
149
|
-
};
|
|
150
|
-
yield* Scope.addFinalizer(scope, Effect.sync(() => {
|
|
151
|
-
update(feed, { _tag: "Stop" });
|
|
152
|
-
}));
|
|
153
|
-
yield* Effect.addFinalizer(() => current() === feed ? Effect.void : stop(feed));
|
|
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;
|
|
157
|
-
update(feed, {
|
|
158
|
-
_tag: "Paint",
|
|
159
|
-
frame
|
|
160
|
-
});
|
|
161
|
-
if (current() === feed) yield* publish(feed, frame);
|
|
162
|
-
yield* PubSub.publish(feed.changed, frame);
|
|
163
|
-
});
|
|
164
|
-
feed.fiber = yield* Effect.scoped(Effect.gen(function* () {
|
|
165
|
-
update(feed, { _tag: "Reset" });
|
|
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);
|
|
170
|
-
yield* Deferred.succeed(started, void 0);
|
|
171
|
-
yield* Stream.runForEach(stream, accept);
|
|
172
|
-
})).pipe(Effect.ensuring(Effect.sync(() => update(feed, { _tag: "Reset" }))), Effect.retry({
|
|
173
|
-
while: (error) => feed.state._tag === "Ready" && restartable(error),
|
|
174
|
-
schedule: Schedule.spaced("500 millis")
|
|
175
|
-
})).pipe(Effect.provideService(Clock.Clock, feed.page.clock), Effect.forkIn(scope));
|
|
176
|
-
yield* Effect.raceFirst(Deferred.await(started), ended(feed)).pipe(Effect.onError(() => stop(feed)));
|
|
177
|
-
return feed;
|
|
178
|
-
});
|
|
179
|
-
const make = Effect.fn("Stage.make")(function* (options = {}) {
|
|
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
|
-
});
|
|
188
|
-
const owner = yield* Effect.scope;
|
|
189
|
-
const now = () => clock === void 0 ? 0 : monotonicMillis(clock);
|
|
190
|
-
const waited = Duration.fromInput(options.firstFrame ?? Duration.seconds(5));
|
|
191
|
-
if (Option.isNone(waited) || !Duration.isFinite(waited.value) || !Duration.isPositive(waited.value)) return yield* refuse("stage", "firstFrame must be a finite positive duration");
|
|
192
|
-
const firstFrame = waited.value;
|
|
193
|
-
const settings = {
|
|
194
|
-
quality: options.quality,
|
|
195
|
-
size: options.size
|
|
196
|
-
};
|
|
197
|
-
const output = yield* PubSub.sliding(16);
|
|
198
|
-
const switching = ordered();
|
|
199
|
-
let showing;
|
|
200
|
-
let painted = Number.NEGATIVE_INFINITY;
|
|
201
|
-
yield* Effect.addFinalizer(() => PubSub.shutdown(output));
|
|
202
|
-
const publish = (feed, frame, at = frame.hostTime) => Effect.suspend(() => {
|
|
203
|
-
painted = Math.max(painted, at);
|
|
204
|
-
if (showing !== void 0) {
|
|
205
|
-
showing.changedAt = now();
|
|
206
|
-
showing.frame = frame;
|
|
207
|
-
}
|
|
208
|
-
return PubSub.publish(output, {
|
|
209
|
-
feed,
|
|
210
|
-
frame,
|
|
211
|
-
at: painted
|
|
212
|
-
});
|
|
213
|
-
});
|
|
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)));
|
|
238
|
-
});
|
|
239
|
-
const cue = (page) => choose(page).pipe(Effect.andThen(Effect.map(openFeed(page, owner, settings, () => showing?.feed, publish), (feed) => ({
|
|
240
|
-
page,
|
|
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
|
-
}))));
|
|
244
|
-
return {
|
|
245
|
-
cue,
|
|
246
|
-
present: (page, options) => choose(page).pipe(Effect.andThen(Effect.suspend(() => {
|
|
247
|
-
const asked = options?.at ?? now();
|
|
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
|
-
},
|
|
255
|
-
frames: Stream.fromPubSub(output).pipe(Stream.map(({ frame }) => frame)),
|
|
256
|
-
current: Effect.sync(() => Option.fromNullishOr(showing?.feed.page)),
|
|
257
|
-
stats: (options = {}) => showing === void 0 ? Effect.succeedNone : Effect.asSome(showing.feed.page.captureStats({ window: options.window ?? "1 second" }))
|
|
258
|
-
};
|
|
259
|
-
});
|
|
260
|
-
//#endregion
|
|
1
|
+
import { r as make, t as Presented } from "../internal/Stage-D5ymSXDT.mjs";
|
|
261
2
|
export { Presented, make };
|
|
262
|
-
|
|
263
|
-
//# sourceMappingURL=Stage.mjs.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { t as Film_d_exports } from "./Film.mjs";
|
|
2
|
+
import { t as Motion_d_exports } from "./Motion.mjs";
|
|
3
|
+
import { t as Presentation_d_exports } from "./Presentation.mjs";
|
|
4
|
+
import { t as Stage_d_exports } from "./Stage.mjs";
|
|
5
|
+
export { Film_d_exports as Film, Motion_d_exports as Motion, Presentation_d_exports as Presentation, Stage_d_exports as Stage };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { t as Film_exports } from "./Film.mjs";
|
|
2
|
+
import { t as Motion_exports } from "./Motion.mjs";
|
|
3
|
+
import { t as Presentation_exports } from "./Presentation.mjs";
|
|
4
|
+
import { n as Stage_exports } from "../internal/Stage-D5ymSXDT.mjs";
|
|
5
|
+
export { Film_exports as Film, Motion_exports as Motion, Presentation_exports as Presentation, Stage_exports as Stage };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { t as __exportAll } from "../internal/rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
//#region src/supervisor/Release.ts
|
|
4
|
+
/**
|
|
5
|
+
* Provider release evidence, independent of supervision or browser implementation.
|
|
6
|
+
*
|
|
7
|
+
* @stability stable
|
|
8
|
+
* @since 0.3.0
|
|
9
|
+
*/
|
|
10
|
+
var Release_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
+
Confirmed: () => Confirmed,
|
|
12
|
+
Release: () => Release,
|
|
13
|
+
Unconfirmed: () => Unconfirmed
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* The provider confirmed the resource ended.
|
|
17
|
+
*
|
|
18
|
+
* @stability stable
|
|
19
|
+
* @category schemas
|
|
20
|
+
* @since 0.3.0
|
|
21
|
+
*/
|
|
22
|
+
var Confirmed = class extends Schema.TaggedClass("effect-browser/supervisor/Release/Confirmed")("Confirmed", {}) {};
|
|
23
|
+
/**
|
|
24
|
+
* The resource may still run, and bill, because its end could not be confirmed.
|
|
25
|
+
*
|
|
26
|
+
* @stability stable
|
|
27
|
+
* @category schemas
|
|
28
|
+
* @since 0.3.0
|
|
29
|
+
*/
|
|
30
|
+
var Unconfirmed = class extends Schema.TaggedClass("effect-browser/supervisor/Release/Unconfirmed")("Unconfirmed", { detail: Schema.String }) {};
|
|
31
|
+
/**
|
|
32
|
+
* @stability stable
|
|
33
|
+
* @category schemas
|
|
34
|
+
* @since 0.3.0
|
|
35
|
+
*/
|
|
36
|
+
const Release = Schema.Union([Confirmed, Unconfirmed]);
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Confirmed, Release, Unconfirmed, Release_exports as t };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=Release.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Release.mjs","names":[],"sources":["../../src/supervisor/Release.ts"],"sourcesContent":["/**\n * Provider release evidence, independent of supervision or browser implementation.\n *\n * @stability stable\n * @since 0.3.0\n */\nimport { Schema } from \"effect\";\n\n/**\n * The provider confirmed the resource ended.\n *\n * @stability stable\n * @category schemas\n * @since 0.3.0\n */\nexport class Confirmed extends Schema.TaggedClass<Confirmed>(\n \"effect-browser/supervisor/Release/Confirmed\",\n)(\"Confirmed\", {}) {}\n\n/**\n * The resource may still run, and bill, because its end could not be confirmed.\n *\n * @stability stable\n * @category schemas\n * @since 0.3.0\n */\nexport class Unconfirmed extends Schema.TaggedClass<Unconfirmed>(\n \"effect-browser/supervisor/Release/Unconfirmed\",\n)(\"Unconfirmed\", {\n detail: Schema.String,\n}) {}\n\n/**\n * @stability stable\n * @category schemas\n * @since 0.3.0\n */\nexport const Release = Schema.Union([Confirmed, Unconfirmed]);\n\n/**\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport type Release = typeof Release.Type;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeA,IAAa,YAAb,cAA+B,OAAO,YACpC,6CACF,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;;;AASpB,IAAa,cAAb,cAAiC,OAAO,YACtC,+CACF,CAAC,CAAC,eAAe,EACf,QAAQ,OAAO,OACjB,CAAC,CAAC,CAAC,CAAC;;;;;;AAOJ,MAAa,UAAU,OAAO,MAAM,CAAC,WAAW,WAAW,CAAC"}
|
|
@@ -1,104 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/supervisor/contract.d.ts
|
|
4
|
-
/** Why a generation stopped serving. */
|
|
5
|
-
export declare const Why: Schema.Literals<readonly ["lost", "rotated", "retired"]>;
|
|
6
|
-
export type Why = typeof Why.Type;
|
|
7
|
-
/** A resource acquired in the generation's scope. The core never inspects its value. */
|
|
8
|
-
interface Opened<A> {
|
|
9
|
-
readonly value: A;
|
|
10
|
-
/** Watched until the generation's scope closes, after its release. */
|
|
11
|
-
readonly lost?: Effect.Effect<string> | undefined;
|
|
12
|
-
/** Without a release hook, closing the generation's scope ends the resource. */
|
|
13
|
-
readonly release?: ((why: Why) => Effect.Effect<Released>) | undefined;
|
|
14
|
-
}
|
|
15
|
-
interface Options<A, E, R> {
|
|
16
|
-
/** Each try receives its generation number and owns resources in the supplied Scope. */
|
|
17
|
-
readonly open: (number: number) => Effect.Effect<Opened<A>, E, R>;
|
|
18
|
-
/** Defaults to exponential from one second, for five minutes. */
|
|
19
|
-
readonly reopen?: Schedule.Schedule<unknown, E> | undefined;
|
|
20
|
-
readonly definite?: ((error: E) => boolean) | undefined;
|
|
21
|
-
/** Each generation waits until every earlier release has completed. */
|
|
22
|
-
readonly exclusive?: boolean | undefined;
|
|
23
|
-
}
|
|
24
|
-
/** Every failed try retains its own typed error, including any provider cleanup evidence. */
|
|
25
|
-
type State<E> = {
|
|
26
|
-
readonly _tag: "Opening";
|
|
27
|
-
readonly attempt: number;
|
|
28
|
-
} | {
|
|
29
|
-
readonly _tag: "Failed";
|
|
30
|
-
readonly attempt: number;
|
|
31
|
-
readonly error: E;
|
|
32
|
-
} | {
|
|
33
|
-
readonly _tag: "Down";
|
|
34
|
-
readonly error: E | undefined;
|
|
35
|
-
readonly detail: string;
|
|
36
|
-
} | {
|
|
37
|
-
readonly _tag: "Open";
|
|
38
|
-
} | {
|
|
39
|
-
readonly _tag: "Ending";
|
|
40
|
-
readonly why: Why;
|
|
41
|
-
readonly detail?: string | undefined;
|
|
42
|
-
} | {
|
|
43
|
-
readonly _tag: "Closed";
|
|
44
|
-
readonly released?: Released | undefined;
|
|
45
|
-
};
|
|
46
|
-
interface Generation<E = unknown> {
|
|
47
|
-
readonly number: number;
|
|
48
|
-
/** Epoch milliseconds on the owning Effect clock. */
|
|
49
|
-
readonly at: number;
|
|
50
|
-
/** Monotonic milliseconds on the same clock. */
|
|
51
|
-
readonly hostTime: number;
|
|
52
|
-
readonly state: State<E>;
|
|
53
|
-
}
|
|
54
|
-
declare const Unavailable_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
55
|
-
readonly _tag: "Unavailable";
|
|
56
|
-
} & Readonly<A>;
|
|
57
|
-
/** No generation serves because opening failed permanently or the supervisor retired. */
|
|
58
|
-
export declare class Unavailable<E = unknown> extends Unavailable_base<{
|
|
59
|
-
readonly reason: "down" | "retired";
|
|
60
|
-
readonly error?: E | undefined;
|
|
61
|
-
readonly detail: string;
|
|
62
|
-
}> {
|
|
63
|
-
get message(): string;
|
|
64
|
-
}
|
|
65
|
-
declare const Superseded_base: Schema.Class<Superseded, Schema.TaggedStruct<"Superseded", {
|
|
66
|
-
readonly generation: Schema.Int;
|
|
67
|
-
readonly reason: Schema.Literals<readonly ["lost", "rotated", "retired"]>;
|
|
68
|
-
}>, Cause.YieldableError>;
|
|
69
|
-
/** Revoked work still uses its input receipt to determine whether input reached the site. */
|
|
70
|
-
export declare class Superseded extends Superseded_base {}
|
|
71
|
-
interface Lease<A> {
|
|
72
|
-
readonly generation: number;
|
|
73
|
-
readonly value: A;
|
|
74
|
-
readonly ending: Effect.Effect<Why>;
|
|
75
|
-
/** Stale declarations do nothing. */
|
|
76
|
-
readonly lose: (detail: string) => Effect.Effect<void>;
|
|
77
|
-
}
|
|
78
|
-
declare const InvalidWait_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
79
|
-
readonly _tag: "InvalidWait";
|
|
80
|
-
} & Readonly<A>;
|
|
81
|
-
/** A public admission budget must be finite and nonnegative. */
|
|
82
|
-
export declare class InvalidWait extends InvalidWait_base<{
|
|
83
|
-
readonly detail: string;
|
|
84
|
-
}> {}
|
|
85
|
-
interface UseOptions {
|
|
86
|
-
/** Finite nonnegative admission budget on the owner's clock. Zero peeks; absent waits. */
|
|
87
|
-
readonly wait?: Duration.Input | undefined;
|
|
88
|
-
}
|
|
89
|
-
interface Supervisor<A, E = unknown> {
|
|
90
|
-
/** Ending interrupts the work and awaits its scoped cleanup before releasing the resource. */
|
|
91
|
-
readonly use: <B, E2, R>(work: (lease: Lease<A>) => Effect.Effect<B, E2, R>, options?: UseOptions) => Effect.Effect<B, E2 | Unavailable<E> | Superseded | Cause.TimeoutError | InvalidWait, Exclude<R, Scope.Scope>>;
|
|
92
|
-
/** Replays the latest 64 changes; ends only after every try and release has finished. */
|
|
93
|
-
readonly states: Stream.Stream<Generation<E>>;
|
|
94
|
-
/** Replace the current generation. A stale `from` does nothing. */
|
|
95
|
-
readonly rotate: (from?: number) => Effect.Effect<void, Unavailable<E>>;
|
|
96
|
-
/** The stop runs on its own fiber; abandoning this wait never abandons retirement. */
|
|
97
|
-
readonly retire: Effect.Effect<void>;
|
|
98
|
-
}
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region src/supervisor/Supervisor.d.ts
|
|
101
|
-
export declare const make: <A, E, R>(options: Options<A, E, R>) => Effect.Effect<Supervisor<A, E>, never, Scope.Scope | Exclude<R, Scope.Scope>>;
|
|
102
|
-
//#endregion
|
|
103
|
-
export type { Generation, Lease, Opened, Options, State, Supervisor, UseOptions };
|
|
104
|
-
//# sourceMappingURL=Supervisor.d.mts.map
|
|
1
|
+
import { a as Lease, c as State, d as Supervisor, f as Unavailable, i as InvalidWait, l as StopReason, n as make, o as Opened, p as UseOptions, r as Generation, s as Options, u as Superseded } from "../internal/Supervisor-BcY_QNIY.mjs";
|
|
2
|
+
export { type Generation, InvalidWait, type Lease, type Opened, type Options, type State, StopReason, Superseded, type Supervisor, Unavailable, type UseOptions, make };
|