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
package/src/Pose.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Element poses: one of the page's own elements moved, turned and scaled about a point, as a caller
|
|
3
|
+
* says, frame by frame on held time or live, so that the page answers what touches it. A tab
|
|
4
|
+
* squashes under a stomp, a box dips as something lands on it, a button tilts as it is pulled, a
|
|
5
|
+
* field wiggles to ask for input. The library chooses no motion: each pose is a caller's.
|
|
6
|
+
*
|
|
7
|
+
* A pose is plain data, in viewport CSS pixels: moved by `dx` and `dy`, scaled by `sx` and `sy`,
|
|
8
|
+
* and turned `rotate` degrees clockwise, each about `origin`, by default the middle of where the
|
|
9
|
+
* page draws the element. As CSS writes it: `transform-origin: origin; transform: translate(dx, dy)
|
|
10
|
+
* rotate(rotate) scale(sx, sy)`, applied around the element's own transform. Its own `translate`,
|
|
11
|
+
* `rotate` and `scale` properties, which pages seldom set, give way while it is posed.
|
|
12
|
+
*
|
|
13
|
+
* A page's poses are one lease, for a scope; each `set` poses the elements it names and takes the
|
|
14
|
+
* pose off every other, and the scope's end takes them all off. A pose sets no attribute and starts
|
|
15
|
+
* none of the page's transitions, and the library's change record does not report it. Readers
|
|
16
|
+
* report what is drawn: `Layout.measure`, `Snapshot.find` and the input's targets give a posed
|
|
17
|
+
* element's box as posed, and a click lands where it is drawn. Only HTML elements take a pose, and
|
|
18
|
+
* one inside another posed element is posed about its point as if the outer one were not. A new
|
|
19
|
+
* document starts with none.
|
|
20
|
+
*
|
|
21
|
+
* @stability stable
|
|
22
|
+
* @since 0.3.0
|
|
23
|
+
*/
|
|
24
|
+
import { type Effect, Schema, type Scope } from "effect";
|
|
25
|
+
|
|
26
|
+
import type { BrowserError } from "./BrowserError.ts";
|
|
27
|
+
import { Point } from "./internal/geometry.ts";
|
|
28
|
+
import { functionsOf } from "./internal/page/functions.ts";
|
|
29
|
+
import type { Page } from "./Page.ts";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* How an element is posed. A part left out changes nothing: no move, a scale of 1, no turn.
|
|
33
|
+
*
|
|
34
|
+
* @stability stable
|
|
35
|
+
* @category schemas
|
|
36
|
+
* @since 0.3.0
|
|
37
|
+
*/
|
|
38
|
+
export const Pose = Schema.Struct({
|
|
39
|
+
/** The element, by a ref from the page's current document, such as a `Layout` place's. */
|
|
40
|
+
ref: Schema.String,
|
|
41
|
+
dx: Schema.optional(Schema.Finite),
|
|
42
|
+
dy: Schema.optional(Schema.Finite),
|
|
43
|
+
sx: Schema.optional(Schema.Finite),
|
|
44
|
+
sy: Schema.optional(Schema.Finite),
|
|
45
|
+
/** Degrees, clockwise. */
|
|
46
|
+
rotate: Schema.optional(Schema.Finite),
|
|
47
|
+
/** The point it turns and scales about, in the viewport. */
|
|
48
|
+
origin: Schema.optional(Point),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @stability stable
|
|
53
|
+
* @category models
|
|
54
|
+
* @since 0.3.0
|
|
55
|
+
*/
|
|
56
|
+
export type Pose = typeof Pose.Type;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @stability stable
|
|
60
|
+
* @category models
|
|
61
|
+
* @since 0.3.0
|
|
62
|
+
*/
|
|
63
|
+
export interface Poses {
|
|
64
|
+
/**
|
|
65
|
+
* Pose these elements, in one call to the page, and take the pose off every other. A ref the
|
|
66
|
+
* document no longer has fails with `StaleRef`, and posing nothing.
|
|
67
|
+
*/
|
|
68
|
+
readonly set: (poses: ReadonlyArray<Pose>) => Effect.Effect<void, BrowserError>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Pose the page's own elements for the scope, moved, turned and scaled as a caller says, and put
|
|
73
|
+
* back when the scope closes. One lease at a time: a second while one is open fails
|
|
74
|
+
* `InvalidRequest`.
|
|
75
|
+
*
|
|
76
|
+
* @stability stable
|
|
77
|
+
* @category constructors
|
|
78
|
+
* @since 0.3.0
|
|
79
|
+
*/
|
|
80
|
+
export const make = (page: Page): Effect.Effect<Poses, BrowserError, Scope.Scope> =>
|
|
81
|
+
functionsOf(page).poses;
|
package/src/Site.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The library's readers for a site that owns its page, called in the site's own bundle on its own
|
|
3
|
+
* document, with no protocol in it. It is the composition the library installs in a page over the
|
|
4
|
+
* protocol, so a site reads the same refs, subjects, outline, text, layout and changes as an agent
|
|
5
|
+
* does, draws in the same overlay, and poses elements the same way.
|
|
6
|
+
*
|
|
7
|
+
* What needs the protocol stays out:
|
|
8
|
+
*
|
|
9
|
+
* - trusted input and the checks that make it safe;
|
|
10
|
+
* - pictures;
|
|
11
|
+
* - held page time;
|
|
12
|
+
* - a record that starts before the page's own scripts.
|
|
13
|
+
*
|
|
14
|
+
* Instead, the site acts through its own app and `note`s each act, so the changes it brings name it
|
|
15
|
+
* as their cause. Time is real, so a pose or a drawing is set again on each animation frame. The
|
|
16
|
+
* record starts when the site calls `record`.
|
|
17
|
+
*
|
|
18
|
+
* Requests and results are the page script's own plain data. Boxes are in viewport CSS pixels, and
|
|
19
|
+
* a change's times are epoch milliseconds, as `performance.timeOrigin + performance.now()`. A
|
|
20
|
+
* request the page cannot serve answers `{ invalid }`, and a ref it no longer has `{ stale }`,
|
|
21
|
+
* rather than throwing. `Layout`, `Change` and `Snapshot` hold their schemas. The script runs in
|
|
22
|
+
* the site's own world, so it shares the globals the site's code may patch.
|
|
23
|
+
*
|
|
24
|
+
* @stability stable
|
|
25
|
+
* @since 0.3.0
|
|
26
|
+
*/
|
|
27
|
+
import { match, pickRequests, request } from "./internal/matching.ts";
|
|
28
|
+
import { compose } from "./internal/page/compose.inpage.ts";
|
|
29
|
+
import { overlay } from "./internal/page/overlay.inpage.ts";
|
|
30
|
+
import { pose, poseRequest } from "./internal/page/pose.inpage.ts";
|
|
31
|
+
import { context } from "./internal/reading/context.inpage.ts";
|
|
32
|
+
import { controls } from "./internal/reading/controls.inpage.ts";
|
|
33
|
+
import { expectations, type Want } from "./internal/reading/expect.inpage.ts";
|
|
34
|
+
import { layout } from "./internal/reading/layout.inpage.ts";
|
|
35
|
+
import { elements, names } from "./internal/reading/names.inpage.ts";
|
|
36
|
+
import { outline } from "./internal/reading/outline.inpage.ts";
|
|
37
|
+
import { ready } from "./internal/reading/ready.inpage.ts";
|
|
38
|
+
import { states, subjects } from "./internal/reading/subjects.inpage.ts";
|
|
39
|
+
import { text } from "./internal/reading/text.inpage.ts";
|
|
40
|
+
import { walk } from "./internal/reading/walk.inpage.ts";
|
|
41
|
+
import { changes } from "./internal/timeline/changes.inpage.ts";
|
|
42
|
+
import { fold } from "./internal/timeline/fold.inpage.ts";
|
|
43
|
+
import { history } from "./internal/timeline/history.inpage.ts";
|
|
44
|
+
import { marks } from "./internal/timeline/marks.inpage.ts";
|
|
45
|
+
import { record } from "./internal/timeline/record.inpage.ts";
|
|
46
|
+
import { sight } from "./internal/timeline/sight.inpage.ts";
|
|
47
|
+
import { addresses } from "./internal/url.ts";
|
|
48
|
+
import type { Picks } from "./Layout.ts";
|
|
49
|
+
import type { Pose } from "./Pose.ts";
|
|
50
|
+
import type { FindQuery } from "./Snapshot.ts";
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The readers, the change record, the overlay and poses for the current document. Make one for
|
|
54
|
+
* each document the site shows, and `stopRecord` the last one's.
|
|
55
|
+
*
|
|
56
|
+
* @stability stable
|
|
57
|
+
* @category constructors
|
|
58
|
+
* @since 0.3.0
|
|
59
|
+
*/
|
|
60
|
+
export const make = () => {
|
|
61
|
+
const { named, recorder, url, reads } = compose({
|
|
62
|
+
elements,
|
|
63
|
+
names,
|
|
64
|
+
walk,
|
|
65
|
+
match,
|
|
66
|
+
context,
|
|
67
|
+
subjects,
|
|
68
|
+
states,
|
|
69
|
+
expectations,
|
|
70
|
+
text,
|
|
71
|
+
layout,
|
|
72
|
+
controls,
|
|
73
|
+
fold,
|
|
74
|
+
history,
|
|
75
|
+
sight,
|
|
76
|
+
marks,
|
|
77
|
+
record,
|
|
78
|
+
changes,
|
|
79
|
+
ready,
|
|
80
|
+
outline,
|
|
81
|
+
overlay,
|
|
82
|
+
pose,
|
|
83
|
+
addresses,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const own = overlay(named);
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
/** What a query finds in the viewport: each element's ref, subject, box and state. */
|
|
90
|
+
find: (query: FindQuery) => reads.find(request(query, "viewport")),
|
|
91
|
+
/** Where each pick is, unrounded, with a box for each of the words it asks for. */
|
|
92
|
+
layout: (picks: Picks) => reads.layout(pickRequests(picks)),
|
|
93
|
+
/** Wait up to `millis` until what a query finds in the document is as wanted. */
|
|
94
|
+
until: (query: FindQuery, want: Want, millis: number) =>
|
|
95
|
+
reads.until(request(query, "document"), want, millis),
|
|
96
|
+
/** The page as an outline of its subjects, each control with a ref. */
|
|
97
|
+
snapshot: reads.snapshot,
|
|
98
|
+
/** The text the viewport shows, or one element's. */
|
|
99
|
+
text: reads.text,
|
|
100
|
+
/** Wait up to `millis` for what the page is still loading, quiet for `quietMillis`. */
|
|
101
|
+
ready: (millis: number, quietMillis?: number) => reads.ready(millis, quietMillis),
|
|
102
|
+
/** One task, then a frame; says whether the page painted. */
|
|
103
|
+
settle: reads.settle,
|
|
104
|
+
/** Record what changes from now, until `stopRecord`, or two minutes with no `changes`. */
|
|
105
|
+
record: reads.record,
|
|
106
|
+
stopRecord: reads.stopRecord,
|
|
107
|
+
/** Keep an act the site did through its app at `target` now, for changes to name as cause. */
|
|
108
|
+
note: recorder.note,
|
|
109
|
+
/** What changed in a window of the record, each change with its box. */
|
|
110
|
+
changes: reads.changes,
|
|
111
|
+
/** Draw an SVG document over the viewport, or take it away with null; says where its parts are. */
|
|
112
|
+
draw: reads.overlay,
|
|
113
|
+
/**
|
|
114
|
+
* A layer of the site's own over the viewport, which no reader reads and the record leaves
|
|
115
|
+
* out: a closed shadow root to render into. It takes no pointer, except parts that set
|
|
116
|
+
* `pointer-events: auto`.
|
|
117
|
+
*/
|
|
118
|
+
layer: own.mount,
|
|
119
|
+
/** Pose these elements and take the pose off every other. */
|
|
120
|
+
pose: (poses: ReadonlyArray<Pose>) => reads.pose(poses.map(poseRequest)),
|
|
121
|
+
unpose: reads.unpose,
|
|
122
|
+
/** An element's ref, which `pose` and a read's `ref` take. */
|
|
123
|
+
ref: named.refFor,
|
|
124
|
+
/** The element a ref names, while it is in the document. */
|
|
125
|
+
element: named.lookup,
|
|
126
|
+
/** An address without its userinfo or the parameters known to carry secrets. */
|
|
127
|
+
redact: url.redact,
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @stability stable
|
|
133
|
+
* @category models
|
|
134
|
+
* @since 0.3.0
|
|
135
|
+
*/
|
|
136
|
+
export type Site = ReturnType<typeof make>;
|
package/src/Snapshot.ts
CHANGED
|
@@ -5,12 +5,26 @@
|
|
|
5
5
|
* refs are never reused within a page, so a ref from an old snapshot fails as stale rather than
|
|
6
6
|
* naming a different element.
|
|
7
7
|
*
|
|
8
|
+
* @stability stable
|
|
8
9
|
* @since 0.3.0
|
|
9
10
|
*/
|
|
10
|
-
import { Schema } from "effect";
|
|
11
|
+
import { type Duration, type Effect, Function, Schema } from "effect";
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
import type { BrowserError } from "./BrowserError.ts";
|
|
14
|
+
import { Box, Subject } from "./BrowserEvent.ts";
|
|
15
|
+
import { millisOf } from "./internal/clock.ts";
|
|
16
|
+
import type { Point } from "./internal/geometry.ts";
|
|
17
|
+
import { functionsOf, isPage } from "./internal/page/functions.ts";
|
|
18
|
+
import type { Page } from "./Page.ts";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A control the outline shows, as a value: its ref, what it is and what it holds.
|
|
22
|
+
*
|
|
23
|
+
* @stability stable
|
|
24
|
+
* @category schemas
|
|
25
|
+
* @since 0.3.0
|
|
26
|
+
*/
|
|
27
|
+
export class Control extends Schema.Class<Control>("effect-browser/Snapshot/Control")({
|
|
14
28
|
ref: Schema.String,
|
|
15
29
|
/** Its role, such as `button` or `textbox`, or `clickable` for an element without one. */
|
|
16
30
|
kind: Schema.String,
|
|
@@ -29,6 +43,11 @@ export class Control extends Schema.Class<Control>("effect-browser/Control")({
|
|
|
29
43
|
editable: Schema.optional(Schema.Boolean),
|
|
30
44
|
}) {}
|
|
31
45
|
|
|
46
|
+
/**
|
|
47
|
+
* @stability stable
|
|
48
|
+
* @category schemas
|
|
49
|
+
* @since 0.3.0
|
|
50
|
+
*/
|
|
32
51
|
export class Snapshot extends Schema.Class<Snapshot>("effect-browser/Snapshot")({
|
|
33
52
|
url: Schema.String,
|
|
34
53
|
title: Schema.String,
|
|
@@ -74,6 +93,11 @@ export class Snapshot extends Schema.Class<Snapshot>("effect-browser/Snapshot")(
|
|
|
74
93
|
}
|
|
75
94
|
}
|
|
76
95
|
|
|
96
|
+
/**
|
|
97
|
+
* @stability stable
|
|
98
|
+
* @category options
|
|
99
|
+
* @since 0.3.0
|
|
100
|
+
*/
|
|
77
101
|
export interface SnapshotOptions {
|
|
78
102
|
/** Read the whole page instead of the viewport. Defaults to false. */
|
|
79
103
|
readonly full?: boolean | undefined;
|
|
@@ -92,3 +116,155 @@ export interface SnapshotOptions {
|
|
|
92
116
|
*/
|
|
93
117
|
readonly boxes?: boolean | undefined;
|
|
94
118
|
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* What `find` looks for. Every rule given must hold; with none, it finds every element in scope
|
|
122
|
+
* that has a role or is a control.
|
|
123
|
+
*
|
|
124
|
+
* @stability stable
|
|
125
|
+
* @category models
|
|
126
|
+
* @since 0.3.0
|
|
127
|
+
*/
|
|
128
|
+
export interface FindQuery {
|
|
129
|
+
/** Narrow matching to this CSS selector. Invalid CSS fails InvalidRequest. */
|
|
130
|
+
readonly selector?: string | undefined;
|
|
131
|
+
/** Require a visible match, optionally enabled. */
|
|
132
|
+
readonly state?: "visible" | "enabled" | undefined;
|
|
133
|
+
/** An ARIA role, such as `"button"` or `"heading"`, ignoring case. */
|
|
134
|
+
readonly role?: string | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* The accessible name: a string that reads the same once spaces are collapsed and case folded,
|
|
137
|
+
* or a pattern found in it.
|
|
138
|
+
*/
|
|
139
|
+
readonly name?: string | RegExp | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* Text it shows, ignoring case and spacing, or a pattern. Text inside a control or a heading is
|
|
142
|
+
* that control's or heading's, and only the smallest element showing it matches, not every
|
|
143
|
+
* element around it.
|
|
144
|
+
*/
|
|
145
|
+
readonly text?: string | RegExp | undefined;
|
|
146
|
+
/** Whole words in its context (row, column, label or heading), ignoring case and spacing. */
|
|
147
|
+
readonly near?: string | undefined;
|
|
148
|
+
/** Only what a point action at this viewport point would reach: the control there, or else what is painted there. */
|
|
149
|
+
readonly at?: Point | undefined;
|
|
150
|
+
/** The viewport (the default), or the whole document. */
|
|
151
|
+
readonly scope?: "viewport" | "document" | undefined;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* An element's state as its markup gives it: `checked` for what can be checked, `expanded`,
|
|
156
|
+
* `selected` and `pressed` where the page says either way, and `level` for headings.
|
|
157
|
+
*
|
|
158
|
+
* @stability stable
|
|
159
|
+
* @category schemas
|
|
160
|
+
* @since 0.3.0
|
|
161
|
+
*/
|
|
162
|
+
export const ElementState = Schema.Struct({
|
|
163
|
+
disabled: Schema.Boolean,
|
|
164
|
+
focused: Schema.Boolean,
|
|
165
|
+
checked: Schema.optional(Schema.Boolean),
|
|
166
|
+
expanded: Schema.optional(Schema.Boolean),
|
|
167
|
+
selected: Schema.optional(Schema.Boolean),
|
|
168
|
+
pressed: Schema.optional(Schema.Boolean),
|
|
169
|
+
level: Schema.optional(Schema.Int),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @stability stable
|
|
174
|
+
* @category models
|
|
175
|
+
* @since 0.3.0
|
|
176
|
+
*/
|
|
177
|
+
export type ElementState = typeof ElementState.Type;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* An element `find` found: a ref for the actions, what it is, where it is and its state.
|
|
181
|
+
*
|
|
182
|
+
* @stability stable
|
|
183
|
+
* @category schemas
|
|
184
|
+
* @since 0.3.0
|
|
185
|
+
*/
|
|
186
|
+
export class Found extends Schema.Class<Found>("effect-browser/Snapshot/Found")({
|
|
187
|
+
ref: Schema.String,
|
|
188
|
+
subject: Subject,
|
|
189
|
+
/** Its box, rounded. Reading the document, it may be out of view. */
|
|
190
|
+
box: Box,
|
|
191
|
+
inViewport: Schema.Boolean,
|
|
192
|
+
state: ElementState,
|
|
193
|
+
}) {}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The page's outline: one line per control, heading or text block, with a ref for each control,
|
|
197
|
+
* in one call to the page.
|
|
198
|
+
*
|
|
199
|
+
* @stability stable
|
|
200
|
+
* @category constructors
|
|
201
|
+
* @since 0.3.0
|
|
202
|
+
*/
|
|
203
|
+
export const read: {
|
|
204
|
+
(options?: SnapshotOptions): (page: Page) => Effect.Effect<Snapshot, BrowserError>;
|
|
205
|
+
(page: Page, options?: SnapshotOptions): Effect.Effect<Snapshot, BrowserError>;
|
|
206
|
+
} = Function.dual(
|
|
207
|
+
(args) => isPage(args[0]),
|
|
208
|
+
(page: Page, options?: SnapshotOptions) => functionsOf(page).snapshot(options),
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* The elements that match a query, in tree order, with refs the actions take, in one call to the
|
|
213
|
+
* page. All that match are returned, so a caller tells them apart by their context; none is an
|
|
214
|
+
* empty result, not a failure.
|
|
215
|
+
*
|
|
216
|
+
* @stability stable
|
|
217
|
+
* @category combinators
|
|
218
|
+
* @since 0.3.0
|
|
219
|
+
*/
|
|
220
|
+
export const find: {
|
|
221
|
+
(query?: FindQuery): (page: Page) => Effect.Effect<ReadonlyArray<Found>, BrowserError>;
|
|
222
|
+
(page: Page, query?: FindQuery): Effect.Effect<ReadonlyArray<Found>, BrowserError>;
|
|
223
|
+
} = Function.dual(
|
|
224
|
+
(args) => isPage(args[0]),
|
|
225
|
+
(page: Page, query?: FindQuery) => functionsOf(page).find(query),
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* What a wait requires of the query's matches.
|
|
230
|
+
*
|
|
231
|
+
* @stability stable
|
|
232
|
+
* @category models
|
|
233
|
+
* @since 0.3.0
|
|
234
|
+
*/
|
|
235
|
+
export type UntilWant = "some" | "none" | { readonly other: string };
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @stability stable
|
|
239
|
+
* @category models
|
|
240
|
+
* @since 0.3.0
|
|
241
|
+
*/
|
|
242
|
+
export interface UntilResult {
|
|
243
|
+
readonly met: boolean;
|
|
244
|
+
readonly mark: string;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Wait, in one call to the page, until what `query` matches is as `want` says or `timeout` passes.
|
|
249
|
+
* Replaced documents share one deadline. Unmet is `met: false`; an empty mark means no stable
|
|
250
|
+
* document could be sampled.
|
|
251
|
+
*
|
|
252
|
+
* @stability stable
|
|
253
|
+
* @category combinators
|
|
254
|
+
* @since 0.3.0
|
|
255
|
+
*/
|
|
256
|
+
export const until: {
|
|
257
|
+
(
|
|
258
|
+
query: FindQuery,
|
|
259
|
+
want: UntilWant,
|
|
260
|
+
timeout: Duration.Input,
|
|
261
|
+
): (page: Page) => Effect.Effect<UntilResult, BrowserError>;
|
|
262
|
+
(
|
|
263
|
+
page: Page,
|
|
264
|
+
query: FindQuery,
|
|
265
|
+
want: UntilWant,
|
|
266
|
+
timeout: Duration.Input,
|
|
267
|
+
): Effect.Effect<UntilResult, BrowserError>;
|
|
268
|
+
} = Function.dual(4, (page: Page, query: FindQuery, want: UntilWant, timeout: Duration.Input) =>
|
|
269
|
+
functionsOf(page).until(query, want, millisOf(timeout)),
|
|
270
|
+
);
|
package/src/Text.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a page shows as text: a line per block, with table cells apart by tabs, read from the
|
|
3
|
+
* viewport or from one element whole.
|
|
4
|
+
*
|
|
5
|
+
* @stability stable
|
|
6
|
+
* @since 0.3.0
|
|
7
|
+
*/
|
|
8
|
+
import { type Effect, Function, Schema } from "effect";
|
|
9
|
+
|
|
10
|
+
import type { BrowserError } from "./BrowserError.ts";
|
|
11
|
+
import { functionsOf, isPage } from "./internal/page/functions.ts";
|
|
12
|
+
import type { Page } from "./Page.ts";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @stability stable
|
|
16
|
+
* @category options
|
|
17
|
+
* @since 0.3.0
|
|
18
|
+
*/
|
|
19
|
+
export interface TextOptions {
|
|
20
|
+
/** `"viewport"` (the default) reads what the viewport shows; a ref reads that element whole. */
|
|
21
|
+
readonly scope?: string | undefined;
|
|
22
|
+
/** Bound on the text's length, cut at a line. Defaults to 12,000 characters. */
|
|
23
|
+
readonly maxChars?: number | undefined;
|
|
24
|
+
/** Show what fields hold; a secret field still reads `••••`. Defaults to false. */
|
|
25
|
+
readonly unmask?: boolean | undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* What a page showed as text: a line per block, with table cells apart by tabs.
|
|
30
|
+
*
|
|
31
|
+
* @stability stable
|
|
32
|
+
* @category schemas
|
|
33
|
+
* @since 0.3.0
|
|
34
|
+
*/
|
|
35
|
+
export class Text extends Schema.Class<Text>("effect-browser/Text")({
|
|
36
|
+
url: Schema.String,
|
|
37
|
+
title: Schema.String,
|
|
38
|
+
text: Schema.String,
|
|
39
|
+
/** True when `text` was cut at `maxChars`. */
|
|
40
|
+
truncated: Schema.Boolean,
|
|
41
|
+
/** Host monotonic milliseconds from the browser's captured Effect Clock. */
|
|
42
|
+
at: Schema.Finite,
|
|
43
|
+
}) {}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The text the viewport shows, or one element whole, in one call to the page. Field values read
|
|
47
|
+
* `••••` unless `unmask`, and a secret field's always do, as does one that was secret when the
|
|
48
|
+
* library saw it.
|
|
49
|
+
*
|
|
50
|
+
* @stability stable
|
|
51
|
+
* @category constructors
|
|
52
|
+
* @since 0.3.0
|
|
53
|
+
*/
|
|
54
|
+
export const read: {
|
|
55
|
+
(options?: TextOptions): (page: Page) => Effect.Effect<Text, BrowserError>;
|
|
56
|
+
(page: Page, options?: TextOptions): Effect.Effect<Text, BrowserError>;
|
|
57
|
+
} = Function.dual(
|
|
58
|
+
(args) => isPage(args[0]),
|
|
59
|
+
(page: Page, options?: TextOptions) => functionsOf(page).text(options),
|
|
60
|
+
);
|
package/src/Window.ts
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* A bounded window of a page's events, visible changes and frames on the owning clock.
|
|
3
|
+
*
|
|
4
|
+
* @stability stable
|
|
5
|
+
* @since 0.3.0
|
|
6
|
+
*/
|
|
7
|
+
import { type Duration, type Effect, Function, Schema } from "effect";
|
|
3
8
|
|
|
4
9
|
import { BrowserError } from "./BrowserError.ts";
|
|
5
10
|
import { BrowserEvent } from "./BrowserEvent.ts";
|
|
6
11
|
import { Changes } from "./Change.ts";
|
|
7
12
|
import { Frame } from "./Frame.ts";
|
|
13
|
+
import { functionsOf } from "./internal/page/functions.ts";
|
|
14
|
+
import type { Page } from "./Page.ts";
|
|
8
15
|
|
|
9
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* A page's events, changes and frames over one window of its browser's host clock.
|
|
18
|
+
*
|
|
19
|
+
* @stability stable
|
|
20
|
+
* @category schemas
|
|
21
|
+
* @since 0.3.0
|
|
22
|
+
*/
|
|
10
23
|
export class Window extends Schema.Class<Window>("effect-browser/Window")({
|
|
11
24
|
page: Schema.String,
|
|
12
25
|
/** Where the window starts, in host monotonic milliseconds on the owning browser’s clock. */
|
|
@@ -28,3 +41,40 @@ export class Window extends Schema.Class<Window>("effect-browser/Window")({
|
|
|
28
41
|
*/
|
|
29
42
|
missing: Schema.Array(BrowserError),
|
|
30
43
|
}) {}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The window `read` reads, and whether to show what fields hold.
|
|
47
|
+
*
|
|
48
|
+
* @stability stable
|
|
49
|
+
* @category options
|
|
50
|
+
* @since 0.3.0
|
|
51
|
+
*/
|
|
52
|
+
export interface WindowOptions {
|
|
53
|
+
/**
|
|
54
|
+
* Where the window starts: a previous window, to continue exactly where it ended; a frame, at its
|
|
55
|
+
* paint; host monotonic milliseconds; or a `Duration` back from `until`. A start after `until`
|
|
56
|
+
* leaves the window empty there.
|
|
57
|
+
*/
|
|
58
|
+
readonly since: Window | Frame | Duration.Duration | number;
|
|
59
|
+
/**
|
|
60
|
+
* Where it ends: a frame, at its paint, such as one a delayed consumer airs now; or host
|
|
61
|
+
* monotonic milliseconds. Defaults to now, and is never later.
|
|
62
|
+
*/
|
|
63
|
+
readonly until?: Frame | number | undefined;
|
|
64
|
+
/** Show what fields hold in its changes; a secret field still reads `••••`. Defaults to false. */
|
|
65
|
+
readonly unmask?: boolean | undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The page's events, changes and frames over a window: the frames and events it keeps, at no
|
|
70
|
+
* call, and its changes, in one call, the first starting its record as `Change.read` does. A part
|
|
71
|
+
* that cannot be read is missing, with why; the window fails only for bounds that are not finite.
|
|
72
|
+
*
|
|
73
|
+
* @stability stable
|
|
74
|
+
* @category constructors
|
|
75
|
+
* @since 0.3.0
|
|
76
|
+
*/
|
|
77
|
+
export const read: {
|
|
78
|
+
(options: WindowOptions): (page: Page) => Effect.Effect<Window, BrowserError>;
|
|
79
|
+
(page: Page, options: WindowOptions): Effect.Effect<Window, BrowserError>;
|
|
80
|
+
} = Function.dual(2, (page: Page, options: WindowOptions) => functionsOf(page).window(options));
|