effect-browser 0.3.0-beta.24 → 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 +333 -157
- 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 +1 -1
- package/dist/BrowserEvent.mjs +166 -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 +33 -6
- 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/{Style.d.mts → InputStyle.d.mts} +93 -25
- package/dist/{Style.mjs → InputStyle.mjs} +1 -1
- package/dist/Layout.d.mts +2 -2
- package/dist/Layout.mjs +58 -16
- package/dist/Layout.mjs.map +1 -1
- package/dist/Overlay.d.mts +2 -2
- package/dist/Overlay.mjs +33 -5
- package/dist/Overlay.mjs.map +1 -1
- package/dist/Page.d.mts +2 -2
- package/dist/Page.mjs +2 -2
- package/dist/PageTime.d.mts +2 -2
- package/dist/PageTime.mjs +13 -3
- package/dist/PageTime.mjs.map +1 -1
- package/dist/Pose.d.mts +2 -2
- package/dist/Pose.mjs +30 -9
- package/dist/Pose.mjs.map +1 -1
- package/dist/Site.d.mts +288 -18
- package/dist/Site.mjs +11 -3
- package/dist/Site.mjs.map +1 -1
- 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 -18
- package/dist/index.mjs +6 -9
- package/dist/{Action-24sLOubi.d.mts → internal/Action-CkanNTUw.d.mts} +64 -4
- package/dist/{Browser-DGR6ZEYo.d.mts → internal/Browser-DD9Vm1c-.d.mts} +75 -11
- package/dist/{Browser-CAQFhTkM.mjs → internal/Browser-vzD7i2oj.mjs} +174 -237
- 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-C2p-NwuU.d.mts → internal/BrowserEvent-tGPYYf6R.d.mts} +168 -13
- package/dist/internal/BrowserTools-Yi3lOX4h.mjs +497 -0
- package/dist/internal/BrowserTools-Yi3lOX4h.mjs.map +1 -0
- package/dist/{Style-T3ezDYLI.mjs → internal/InputStyle-CPzxoN4g.mjs} +75 -20
- 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} +53 -20
- package/dist/internal/Page-BfGxn7oN.d.mts +1553 -0
- package/dist/{Page-BaAOshxo.mjs → internal/Page-DqF-tuTx.mjs} +62 -74
- 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-Db-YtlbE.d.mts → internal/connection-BaB0vp1o.d.mts} +6 -6
- package/dist/{connection-C_jWYIwe.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-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} +3 -3
- 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/{pose.inpage-CLq7Mfdr.mjs → internal/pose.inpage-CBFeWcVa.mjs} +2 -48
- 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/{film → presentation}/Film.d.mts +83 -16
- package/dist/{film → presentation}/Film.mjs +82 -30
- 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 +42 -7
- package/dist/presentation/Presentation.mjs +26 -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 -311
- package/dist/testing/index.mjs +6 -521
- 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 -163
- package/src/Action.ts +73 -8
- package/src/Browser.ts +75 -9
- package/src/BrowserError.ts +258 -63
- package/src/BrowserEvent.ts +252 -55
- package/src/Cdp.ts +42 -0
- package/src/Change.ts +68 -3
- package/src/Frame.ts +247 -14
- package/src/{Style.ts → InputStyle.ts} +98 -22
- package/src/Layout.ts +95 -24
- package/src/Overlay.ts +42 -3
- package/src/Page.ts +144 -320
- package/src/PageTime.ts +29 -4
- package/src/Pose.ts +38 -7
- package/src/Site.ts +15 -3
- 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 +83 -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 +5 -5
- package/src/internal/input/pointer.ts +2 -2
- package/src/internal/input/targets.inpage.ts +3 -3
- package/src/{Matching.ts → internal/matching.ts} +6 -6
- package/src/internal/page/bridge.ts +2 -2
- package/src/internal/page/clock.inpage.ts +1 -1
- package/src/internal/page/compose.inpage.ts +2 -2
- package/src/internal/page/context.ts +2 -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/page.ts +33 -35
- package/src/internal/page/port.ts +14 -8
- 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.ts +1 -1
- 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 +53 -61
- 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 +3 -3
- package/src/internal/reading/layout.ts +5 -5
- package/src/internal/reading/outline.inpage.ts +3 -3
- package/src/internal/reading/reading.ts +11 -19
- package/src/internal/reading/ready.inpage.ts +2 -2
- package/src/internal/reading/ready.ts +3 -2
- package/src/internal/reading/subjects.inpage.ts +3 -3
- package/src/internal/reading/text.inpage.ts +2 -2
- package/src/internal/reading/walk.inpage.ts +1 -1
- package/src/internal/timeline/changes.inpage.ts +2 -2
- package/src/internal/timeline/changes.ts +3 -4
- 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/{film → presentation}/Film.ts +104 -37
- package/src/presentation/Motion.ts +45 -3
- package/src/presentation/Presentation.ts +47 -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 -56
- package/src/{moment → timeline}/Moment.ts +79 -29
- package/src/{stillness → timeline}/Stillness.ts +61 -43
- package/src/timeline/index.ts +18 -0
- package/src/{stillness/Pixels.ts → timeline/internal/pixels.ts} +2 -2
- 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-CAQFhTkM.mjs.map +0 -1
- package/dist/Change-CxT1mp2e.d.mts +0 -80
- package/dist/Clock-Du5nP-nK.d.mts +0 -57
- package/dist/Clock.d.mts +0 -2
- 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-MtcWZ_hA.d.mts +0 -266
- package/dist/Matching.d.mts +0 -2
- package/dist/Matching.mjs.map +0 -1
- package/dist/Overlay-CoGw5tL_.d.mts +0 -27
- package/dist/Page-BaAOshxo.mjs.map +0 -1
- package/dist/Page-CLzh5E9w.d.mts +0 -718
- package/dist/PageTime-68UPUZpZ.d.mts +0 -29
- package/dist/Pose-2qqGzPvb.d.mts +0 -32
- package/dist/Released-tURbFmal.d.mts +0 -15
- package/dist/Snapshot-CtBVOtuu.d.mts +0 -73
- package/dist/Stillness-BwP0RdI4.mjs +0 -157
- package/dist/Stillness-BwP0RdI4.mjs.map +0 -1
- package/dist/Style-T3ezDYLI.mjs.map +0 -1
- package/dist/Url-B7P-TWwL.d.mts +0 -26
- package/dist/Url.d.mts +0 -2
- package/dist/Url.mjs.map +0 -1
- package/dist/Window-BDa8MtNP.d.mts +0 -34
- package/dist/connection-C_jWYIwe.mjs.map +0 -1
- package/dist/film/Film.mjs.map +0 -1
- package/dist/moment/Moment.mjs.map +0 -1
- package/dist/plan/index.mjs.map +0 -1
- package/dist/pose.inpage-CLq7Mfdr.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/{fold.inpage-CyVZQHZL.d.mts → internal/fold.inpage-CyVZQHZL.d.mts} +0 -0
- /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/Layout.ts
CHANGED
|
@@ -4,25 +4,40 @@
|
|
|
4
4
|
* read with them in one call. A rehearsal measures things that exist only after an interaction,
|
|
5
5
|
* and puts the page back.
|
|
6
6
|
*
|
|
7
|
+
* @stability stable
|
|
7
8
|
* @since 0.3.0
|
|
8
9
|
*/
|
|
9
|
-
import { Effect, Exit, Schema } from "effect";
|
|
10
|
+
import { Effect, Exit, Function, Schema } from "effect";
|
|
10
11
|
|
|
11
12
|
import type { Action } from "./Action.ts";
|
|
12
13
|
import type { BrowserError } from "./BrowserError.ts";
|
|
13
14
|
import { Box, Subject } from "./BrowserEvent.ts";
|
|
14
|
-
import { Point } from "./
|
|
15
|
-
import
|
|
15
|
+
import { Point } from "./internal/geometry.ts";
|
|
16
|
+
import { functionsOf } from "./internal/page/functions.ts";
|
|
17
|
+
import type { Page } from "./Page.ts";
|
|
18
|
+
import type { FindQuery } from "./Snapshot.ts";
|
|
16
19
|
|
|
17
|
-
/**
|
|
18
|
-
|
|
20
|
+
/**
|
|
21
|
+
* A match of a pick's `words`, by its box in the viewport and in the document.
|
|
22
|
+
*
|
|
23
|
+
* @stability stable
|
|
24
|
+
* @category schemas
|
|
25
|
+
* @since 0.3.0
|
|
26
|
+
*/
|
|
27
|
+
export class Word extends Schema.Class<Word>("effect-browser/Layout/Word")({
|
|
19
28
|
text: Schema.String,
|
|
20
29
|
box: Box,
|
|
21
30
|
page: Box,
|
|
22
31
|
}) {}
|
|
23
32
|
|
|
24
|
-
/**
|
|
25
|
-
|
|
33
|
+
/**
|
|
34
|
+
* What one pick found.
|
|
35
|
+
*
|
|
36
|
+
* @stability stable
|
|
37
|
+
* @category schemas
|
|
38
|
+
* @since 0.3.0
|
|
39
|
+
*/
|
|
40
|
+
export class Place extends Schema.Class<Place>("effect-browser/Layout/Place")({
|
|
26
41
|
/** The pick's own name. */
|
|
27
42
|
id: Schema.String,
|
|
28
43
|
ref: Schema.String,
|
|
@@ -37,7 +52,13 @@ export class Place extends Schema.Class<Place>("effect-browser/Place")({
|
|
|
37
52
|
words: Schema.optional(Schema.Array(Word)),
|
|
38
53
|
}) {}
|
|
39
54
|
|
|
40
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* A page's picked places, and the viewport, scroll and scale they were read at.
|
|
57
|
+
*
|
|
58
|
+
* @stability stable
|
|
59
|
+
* @category schemas
|
|
60
|
+
* @since 0.3.0
|
|
61
|
+
*/
|
|
41
62
|
export class Layout extends Schema.Class<Layout>("effect-browser/Layout")({
|
|
42
63
|
page: Schema.String,
|
|
43
64
|
/** The tracking connection that owns the document counter. */
|
|
@@ -60,10 +81,15 @@ export class Layout extends Schema.Class<Layout>("effect-browser/Layout")({
|
|
|
60
81
|
}) {}
|
|
61
82
|
|
|
62
83
|
/**
|
|
63
|
-
* A `find` query that names one thing. Its scope defaults to the whole document. Every
|
|
64
|
-
* finds is a candidate, and `choose` takes one: the first in tree order (the default),
|
|
65
|
-
* or the smallest or largest by area. With a selector, the candidates are what it
|
|
66
|
-
* shows and meets the other rules, a drawing's elements among them, which
|
|
84
|
+
* A `Snapshot.find` query that names one thing. Its scope defaults to the whole document. Every
|
|
85
|
+
* element it finds is a candidate, and `choose` takes one: the first in tree order (the default),
|
|
86
|
+
* the last, or the smallest or largest by area. With a selector, the candidates are what it
|
|
87
|
+
* selects that shows and meets the other rules, a drawing's elements among them, which
|
|
88
|
+
* `Snapshot.find` leaves out.
|
|
89
|
+
*
|
|
90
|
+
* @stability stable
|
|
91
|
+
* @category models
|
|
92
|
+
* @since 0.3.0
|
|
67
93
|
*/
|
|
68
94
|
export interface Pick extends FindQuery {
|
|
69
95
|
readonly choose?: "first" | "last" | "smallest" | "largest" | undefined;
|
|
@@ -74,33 +100,64 @@ export interface Pick extends FindQuery {
|
|
|
74
100
|
readonly words?: string | RegExp | undefined;
|
|
75
101
|
}
|
|
76
102
|
|
|
77
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* Picks by the names their places will carry.
|
|
105
|
+
*
|
|
106
|
+
* @stability stable
|
|
107
|
+
* @category models
|
|
108
|
+
* @since 0.3.0
|
|
109
|
+
*/
|
|
78
110
|
export type Picks = Readonly<Record<string, Pick>>;
|
|
79
111
|
|
|
80
|
-
/**
|
|
81
|
-
|
|
82
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Where each pick is, in one call to the page: its box unrounded, in the viewport and in the
|
|
114
|
+
* document, the boxes of words in it, and the viewport, scroll and scale they were read at. A
|
|
115
|
+
* pick that finds nothing is listed as missing, not a failure.
|
|
116
|
+
*
|
|
117
|
+
* @stability stable
|
|
118
|
+
* @category constructors
|
|
119
|
+
* @since 0.3.0
|
|
120
|
+
*/
|
|
121
|
+
export const measure: {
|
|
122
|
+
(picks: Picks): (page: Page) => Effect.Effect<Layout, BrowserError>;
|
|
123
|
+
(page: Page, picks: Picks): Effect.Effect<Layout, BrowserError>;
|
|
124
|
+
} = Function.dual(2, (page: Page, picks: Picks) => functionsOf(page).layout(picks));
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The place a pick named, if it found one.
|
|
128
|
+
*
|
|
129
|
+
* @stability stable
|
|
130
|
+
* @category combinators
|
|
131
|
+
* @since 0.3.0
|
|
132
|
+
*/
|
|
133
|
+
export const place: {
|
|
134
|
+
(id: string): (layout: Layout) => Place | undefined;
|
|
135
|
+
(layout: Layout, id: string): Place | undefined;
|
|
136
|
+
} = Function.dual(2, (layout: Layout, id: string): Place | undefined =>
|
|
137
|
+
layout.places.find((each) => each.id === id),
|
|
138
|
+
);
|
|
83
139
|
|
|
84
|
-
/**
|
|
140
|
+
/**
|
|
141
|
+
* What a rehearsal does, measures, and does to put the page back.
|
|
142
|
+
*
|
|
143
|
+
* @stability stable
|
|
144
|
+
* @category models
|
|
145
|
+
* @since 0.3.0
|
|
146
|
+
*/
|
|
85
147
|
export interface Rehearsal {
|
|
86
148
|
readonly act: ReadonlyArray<Action>;
|
|
87
149
|
readonly picks: Picks;
|
|
88
150
|
readonly undo: ReadonlyArray<Action>;
|
|
89
151
|
}
|
|
90
152
|
|
|
91
|
-
|
|
92
|
-
* Measure what exists only after an interaction: perform `act`, wait for the page to be ready,
|
|
93
|
-
* read the layout, then perform `undo`, which runs whether or not acting and reading succeeded,
|
|
94
|
-
* and is not interrupted. A failure to act or read is the rehearsal's; otherwise one to undo is.
|
|
95
|
-
*/
|
|
96
|
-
export const rehearse = (page: Page, rehearsal: Rehearsal): Effect.Effect<Layout, BrowserError> =>
|
|
153
|
+
const rehearseOn = (page: Page, rehearsal: Rehearsal): Effect.Effect<Layout, BrowserError> =>
|
|
97
154
|
Effect.uninterruptibleMask((restore) =>
|
|
98
155
|
Effect.gen(function* () {
|
|
99
156
|
const measured = yield* Effect.exit(
|
|
100
157
|
restore(
|
|
101
158
|
Effect.forEach(rehearsal.act, page.perform, { discard: true }).pipe(
|
|
102
159
|
Effect.andThen(page.ready()),
|
|
103
|
-
Effect.andThen(page
|
|
160
|
+
Effect.andThen(measure(page, rehearsal.picks)),
|
|
104
161
|
),
|
|
105
162
|
),
|
|
106
163
|
);
|
|
@@ -114,3 +171,17 @@ export const rehearse = (page: Page, rehearsal: Rehearsal): Effect.Effect<Layout
|
|
|
114
171
|
: Exit.failCause(undone.cause);
|
|
115
172
|
}),
|
|
116
173
|
);
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Measure what exists only after an interaction: perform `act`, wait for the page to be ready,
|
|
177
|
+
* read the layout, then perform `undo`, which runs whether or not acting and reading succeeded,
|
|
178
|
+
* and is not interrupted. A failure to act or read is the rehearsal's; otherwise one to undo is.
|
|
179
|
+
*
|
|
180
|
+
* @stability stable
|
|
181
|
+
* @category constructors
|
|
182
|
+
* @since 0.3.0
|
|
183
|
+
*/
|
|
184
|
+
export const rehearse: {
|
|
185
|
+
(rehearsal: Rehearsal): (page: Page) => Effect.Effect<Layout, BrowserError>;
|
|
186
|
+
(page: Page, rehearsal: Rehearsal): Effect.Effect<Layout, BrowserError>;
|
|
187
|
+
} = Function.dual(2, rehearseOn);
|
package/src/Overlay.ts
CHANGED
|
@@ -2,32 +2,49 @@
|
|
|
2
2
|
* A layer over a page that the library draws a caller's content into, without knowing what it
|
|
3
3
|
* shows: a pointer, a ring round what an agent is about to press, a caption, a character. It shows
|
|
4
4
|
* in screenshots, screencasts and a live view alike. The library's own readers never read it:
|
|
5
|
-
* `
|
|
6
|
-
*
|
|
5
|
+
* `Snapshot`, `Layout`, `Text`, `Change`, `ready` and stillness see the page as if it were not
|
|
6
|
+
* there, and input passes through it to the page.
|
|
7
7
|
*
|
|
8
8
|
* A page has one overlay at a time, for a scope. It sits above the page's own layers but beneath
|
|
9
9
|
* its top layer (a modal dialog, a popover), in viewport CSS pixels, and undoes a zoom the page
|
|
10
10
|
* sets on its root. Each new document starts without it, and it is drawn again there, with what
|
|
11
11
|
* it last showed, once the document has loaded. It is gone when its scope closes.
|
|
12
12
|
*
|
|
13
|
+
* @stability stable
|
|
13
14
|
* @since 0.3.0
|
|
14
15
|
*/
|
|
15
|
-
import { type Effect, Schema } from "effect";
|
|
16
|
+
import { type Effect, type Option, Schema, type Scope } from "effect";
|
|
16
17
|
|
|
17
18
|
import type { BrowserError } from "./BrowserError.ts";
|
|
18
19
|
import type { Box } from "./BrowserEvent.ts";
|
|
20
|
+
import { functionsOf } from "./internal/page/functions.ts";
|
|
21
|
+
import type { Page } from "./Page.ts";
|
|
19
22
|
|
|
20
23
|
/**
|
|
21
24
|
* What the overlay shows. `Svg` is an SVG document sized to the viewport, whose own `viewBox` maps
|
|
22
25
|
* any design space onto it; its scripts and event handlers are dropped. `Empty` shows nothing.
|
|
26
|
+
*
|
|
27
|
+
* @stability stable
|
|
28
|
+
* @category schemas
|
|
29
|
+
* @since 0.3.0
|
|
23
30
|
*/
|
|
24
31
|
export const Content = Schema.TaggedUnion({
|
|
25
32
|
Svg: { markup: Schema.String },
|
|
26
33
|
Empty: {},
|
|
27
34
|
});
|
|
28
35
|
|
|
36
|
+
/**
|
|
37
|
+
* @stability stable
|
|
38
|
+
* @category models
|
|
39
|
+
* @since 0.3.0
|
|
40
|
+
*/
|
|
29
41
|
export type Content = typeof Content.Type;
|
|
30
42
|
|
|
43
|
+
/**
|
|
44
|
+
* @stability stable
|
|
45
|
+
* @category models
|
|
46
|
+
* @since 0.3.0
|
|
47
|
+
*/
|
|
31
48
|
export interface Overlay {
|
|
32
49
|
/**
|
|
33
50
|
* Show `content` in place of what was shown, in one call to the page, after the actions asked
|
|
@@ -35,3 +52,25 @@ export interface Overlay {
|
|
|
35
52
|
*/
|
|
36
53
|
readonly draw: (content: Content) => Effect.Effect<ReadonlyArray<Box>, BrowserError>;
|
|
37
54
|
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A layer over the page to draw into, for the scope, that the library's readers never read.
|
|
58
|
+
* One at a time: a second while one is open fails `InvalidRequest`.
|
|
59
|
+
*
|
|
60
|
+
* @stability stable
|
|
61
|
+
* @category constructors
|
|
62
|
+
* @since 0.3.0
|
|
63
|
+
*/
|
|
64
|
+
export const make = (page: Page): Effect.Effect<Overlay, BrowserError, Scope.Scope> =>
|
|
65
|
+
functionsOf(page).overlay;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Where the overlay's drawing was last drawn, in viewport CSS pixels, at no call to the page;
|
|
69
|
+
* none with nothing shown.
|
|
70
|
+
*
|
|
71
|
+
* @stability stable
|
|
72
|
+
* @category combinators
|
|
73
|
+
* @since 0.3.0
|
|
74
|
+
*/
|
|
75
|
+
export const drawn = (page: Page): Effect.Effect<Option.Option<ReadonlyArray<Box>>> =>
|
|
76
|
+
functionsOf(page).drawn;
|