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/dist/Site.d.mts
CHANGED
|
@@ -1,17 +1,278 @@
|
|
|
1
|
-
import "./BrowserError-
|
|
2
|
-
import { x as Subject } from "./BrowserEvent-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { t as
|
|
7
|
-
import { n as Snapshot } from "./Snapshot-CtBVOtuu.mjs";
|
|
8
|
-
import "./Browser-DGR6ZEYo.mjs";
|
|
9
|
-
import "./Clock-Du5nP-nK.mjs";
|
|
10
|
-
import { c as Layouts, d as Walk, f as Names, l as Subjects, n as FindRequest, r as Match, u as ContextReader } from "./Matching-MtcWZ_hA.mjs";
|
|
11
|
-
import { n as addresses } from "./Url-B7P-TWwL.mjs";
|
|
12
|
-
import { a as Track, i as Shown, n as Folded, r as Sample, t as Fold } from "./fold.inpage-CyVZQHZL.mjs";
|
|
1
|
+
import "./internal/BrowserError-CsuRYcDX.mjs";
|
|
2
|
+
import { S as SubjectContext, x as Subject } from "./internal/BrowserEvent-tGPYYf6R.mjs";
|
|
3
|
+
import { r as Point } from "./internal/geometry-Dhj_ztJs.mjs";
|
|
4
|
+
import { G as Picks, N as Pose, et as FindQuery, nt as Snapshot, ut as Change } from "./internal/Page-BfGxn7oN.mjs";
|
|
5
|
+
import "./internal/Browser-DD9Vm1c-.mjs";
|
|
6
|
+
import { a as Track, i as Shown, n as Folded, r as Sample, t as Fold } from "./internal/fold.inpage-CyVZQHZL.mjs";
|
|
13
7
|
import { Clock, Context, Deferred, Duration, Effect, MutableRef, Option, Schema, Scope } from "effect";
|
|
14
8
|
import { BrowserContext } from "playwright-core";
|
|
9
|
+
//#region src/internal/url.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* The rule that reports an address without its credentials. The page script runs it too, so it
|
|
12
|
+
* stays self-contained, as `names.inpage.ts` says a page-side part must.
|
|
13
|
+
*/
|
|
14
|
+
declare const addresses: () => {
|
|
15
|
+
withheld: "••••••••";
|
|
16
|
+
redact: (url: string) => string;
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/internal/reading/names.inpage.d.ts
|
|
20
|
+
/**
|
|
21
|
+
* In the page: the foundation the other parts build on. It gives elements refs and reads the
|
|
22
|
+
* roles, names and states that the outline and the input checks report.
|
|
23
|
+
*
|
|
24
|
+
* Every `*.inpage.ts` part runs inside the page. The page receives it as source text, so it must
|
|
25
|
+
* stay self-contained: it uses only its parameters, the DOM and what it defines itself.
|
|
26
|
+
*/
|
|
27
|
+
declare const elements: () => {
|
|
28
|
+
adopt: (node: Node) => WeakSet<Node>;
|
|
29
|
+
clean: (value: string | null | undefined, max?: number) => string;
|
|
30
|
+
isInput: (element: Element) => element is HTMLInputElement;
|
|
31
|
+
isTextArea: (element: Element) => element is HTMLTextAreaElement;
|
|
32
|
+
isSelect: (element: Element) => element is HTMLSelectElement;
|
|
33
|
+
isFrame: (element: Element) => element is HTMLIFrameElement;
|
|
34
|
+
isHtml: (element: Element) => element is HTMLElement;
|
|
35
|
+
isButton: (element: Element) => element is HTMLButtonElement;
|
|
36
|
+
isLabel: (element: Element) => element is HTMLLabelElement;
|
|
37
|
+
textOf: (element: Element) => string;
|
|
38
|
+
isElement: (node: Node) => node is Element;
|
|
39
|
+
isDocument: (node: Node) => node is Document;
|
|
40
|
+
isOwn: (node: Node) => boolean;
|
|
41
|
+
textEntry: (element: Element) => boolean;
|
|
42
|
+
};
|
|
43
|
+
declare const names: (native: ReturnType<typeof elements>) => {
|
|
44
|
+
adopt: (node: Node) => WeakSet<Node>;
|
|
45
|
+
clean: (value: string | null | undefined, max?: number) => string;
|
|
46
|
+
isInput: (element: Element) => element is HTMLInputElement;
|
|
47
|
+
isTextArea: (element: Element) => element is HTMLTextAreaElement;
|
|
48
|
+
isSelect: (element: Element) => element is HTMLSelectElement;
|
|
49
|
+
isFrame: (element: Element) => element is HTMLIFrameElement;
|
|
50
|
+
isHtml: (element: Element) => element is HTMLElement;
|
|
51
|
+
isButton: (element: Element) => element is HTMLButtonElement;
|
|
52
|
+
isLabel: (element: Element) => element is HTMLLabelElement;
|
|
53
|
+
textOf: (element: Element) => string;
|
|
54
|
+
isElement: (node: Node) => node is Element;
|
|
55
|
+
isDocument: (node: Node) => node is Document;
|
|
56
|
+
isOwn: (node: Node) => boolean;
|
|
57
|
+
textEntry: (element: Element) => boolean;
|
|
58
|
+
activeElement: () => Element | null;
|
|
59
|
+
containers: Record<string, string>;
|
|
60
|
+
describe: (element: Element) => string;
|
|
61
|
+
inCurrentDocument: (element: Element) => boolean;
|
|
62
|
+
interactiveRoles: Set<string>;
|
|
63
|
+
isDisabled: (element: Element) => boolean;
|
|
64
|
+
isRoot: (node: Node) => node is Document | ShadowRoot;
|
|
65
|
+
isSecret: (element: Element) => boolean;
|
|
66
|
+
lookup: (ref: string) => Element | undefined;
|
|
67
|
+
nameOf: (element: Element, role: string | null) => string;
|
|
68
|
+
parentOf: (element: Element) => Element | null;
|
|
69
|
+
refFor: (element: Element) => string;
|
|
70
|
+
refs: {
|
|
71
|
+
next: number;
|
|
72
|
+
};
|
|
73
|
+
roleOf: (element: Element, structural?: boolean) => string | null;
|
|
74
|
+
};
|
|
75
|
+
type Names = ReturnType<typeof names>;
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/internal/reading/walk.inpage.d.ts
|
|
78
|
+
interface Visitor<S> {
|
|
79
|
+
/** The state for the element's children, or undefined to leave them out. */
|
|
80
|
+
readonly enter: (element: Element, style: CSSStyleDeclaration, rect: DOMRect, state: S) => S | undefined;
|
|
81
|
+
/** Whether to visit a child of an element entered with `state`; all by default. */
|
|
82
|
+
readonly admit?: ((child: Element, state: S) => boolean) | undefined;
|
|
83
|
+
/** Each text node of an entered element, in order among its children. */
|
|
84
|
+
readonly text?: ((node: Node, state: S) => void) | undefined;
|
|
85
|
+
/** After the children of an element `enter` went into, with the state it returned. */
|
|
86
|
+
readonly leave?: ((element: Element, state: S) => void) | undefined;
|
|
87
|
+
/** A subtree left out because its box lies outside the viewport, in top-document pixels. */
|
|
88
|
+
readonly outside?: ((rect: DOMRect) => void) | undefined;
|
|
89
|
+
}
|
|
90
|
+
declare const walk: (names: Names) => {
|
|
91
|
+
acts: (element: Element, role: string | null) => boolean;
|
|
92
|
+
boxOf: (element: Element) => {
|
|
93
|
+
x: number;
|
|
94
|
+
y: number;
|
|
95
|
+
width: number;
|
|
96
|
+
height: number;
|
|
97
|
+
};
|
|
98
|
+
controlOf: (hit: Element) => Element;
|
|
99
|
+
hitAt: (root: Document | ShadowRoot, x: number, y: number) => Element | null;
|
|
100
|
+
inView: (rect: DOMRect, width?: number, height?: number) => boolean;
|
|
101
|
+
visible: (element: Element) => boolean;
|
|
102
|
+
visit: <S>(root: Element | null, viewport: boolean, state: S, visitor: Visitor<S>) => void;
|
|
103
|
+
};
|
|
104
|
+
type Walked = ReturnType<typeof walk>;
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/internal/reading/context.inpage.d.ts
|
|
107
|
+
/** What one read has learnt of the page: each table's header row and each tree's headings. */
|
|
108
|
+
interface Known {
|
|
109
|
+
readonly headers: Map<Element, Element | null>;
|
|
110
|
+
readonly headings: Map<Node, ReadonlyArray<Element>>;
|
|
111
|
+
}
|
|
112
|
+
declare const context: (names: Names, walked: Walked) => {
|
|
113
|
+
contextOf: (element: Element, read?: Known) => SubjectContext;
|
|
114
|
+
groups: string;
|
|
115
|
+
headingBefore: (target: Element, scope: ParentNode, read?: Known) => string | undefined;
|
|
116
|
+
known: () => Known;
|
|
117
|
+
textBeside: (target: Element, scope: Node, backwards: boolean) => string;
|
|
118
|
+
treeOf: (element: Element) => ParentNode;
|
|
119
|
+
};
|
|
120
|
+
type ContextReader = ReturnType<typeof context>;
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/internal/reading/layout.inpage.d.ts
|
|
123
|
+
interface PickRequest extends FindRequest {
|
|
124
|
+
readonly id: string;
|
|
125
|
+
readonly choose: "first" | "last" | "smallest" | "largest";
|
|
126
|
+
readonly words: Wanted | null;
|
|
127
|
+
}
|
|
128
|
+
declare const layout: (names: Names, walked: Walked, subjected: Subjects, matching: Match, placing: ContextReader) => {
|
|
129
|
+
read: (picks: ReadonlyArray<PickRequest>) => {
|
|
130
|
+
invalid: string;
|
|
131
|
+
layout?: undefined;
|
|
132
|
+
} | {
|
|
133
|
+
invalid?: undefined;
|
|
134
|
+
layout: {
|
|
135
|
+
url: string;
|
|
136
|
+
viewport: {
|
|
137
|
+
width: number;
|
|
138
|
+
height: number;
|
|
139
|
+
};
|
|
140
|
+
scroll: {
|
|
141
|
+
x: number;
|
|
142
|
+
y: number;
|
|
143
|
+
};
|
|
144
|
+
scale: number;
|
|
145
|
+
places: {
|
|
146
|
+
id: string;
|
|
147
|
+
ref: string;
|
|
148
|
+
subject: {
|
|
149
|
+
role: string | null;
|
|
150
|
+
name: string;
|
|
151
|
+
tag: string;
|
|
152
|
+
context: {
|
|
153
|
+
readonly row?: string | undefined;
|
|
154
|
+
readonly column?: string | undefined;
|
|
155
|
+
readonly label?: string | undefined;
|
|
156
|
+
readonly heading?: string | undefined;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
box: {
|
|
160
|
+
x: number;
|
|
161
|
+
y: number;
|
|
162
|
+
width: number;
|
|
163
|
+
height: number;
|
|
164
|
+
};
|
|
165
|
+
fixed: boolean;
|
|
166
|
+
words: {
|
|
167
|
+
text: string;
|
|
168
|
+
box: {
|
|
169
|
+
x: number;
|
|
170
|
+
y: number;
|
|
171
|
+
width: number;
|
|
172
|
+
height: number;
|
|
173
|
+
};
|
|
174
|
+
}[] | undefined;
|
|
175
|
+
}[];
|
|
176
|
+
missing: string[];
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
type Layouts = ReturnType<typeof layout>;
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/internal/matching.d.ts
|
|
183
|
+
/** A string, or a pattern sent to the page as its source and flags. */
|
|
184
|
+
type Wanted = string | {
|
|
185
|
+
readonly source: string;
|
|
186
|
+
readonly flags: string;
|
|
187
|
+
};
|
|
188
|
+
interface FindRequest {
|
|
189
|
+
readonly selector: string | null;
|
|
190
|
+
readonly state: "visible" | "enabled";
|
|
191
|
+
readonly role: string | null;
|
|
192
|
+
readonly name: Wanted | null;
|
|
193
|
+
readonly text: Wanted | null;
|
|
194
|
+
readonly near: string | null;
|
|
195
|
+
readonly at: Point | null;
|
|
196
|
+
readonly scope: "viewport" | "document";
|
|
197
|
+
}
|
|
198
|
+
/** What a query is matched against, read only when a rule needs it. */
|
|
199
|
+
interface Candidate {
|
|
200
|
+
readonly role: string | null;
|
|
201
|
+
readonly name: () => string;
|
|
202
|
+
readonly text: () => string;
|
|
203
|
+
readonly context: () => SubjectContext;
|
|
204
|
+
}
|
|
205
|
+
declare const match: () => {
|
|
206
|
+
compile: (request: Pick<FindRequest, "role" | "name" | "text" | "near">) => (candidate: Candidate) => boolean;
|
|
207
|
+
holds: (text: string, value: string) => boolean;
|
|
208
|
+
normalize: (value: string) => string;
|
|
209
|
+
mark: (observations: ReadonlyArray<string>) => string;
|
|
210
|
+
};
|
|
211
|
+
type Match = ReturnType<typeof match>;
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/internal/reading/subjects.inpage.d.ts
|
|
214
|
+
declare const states: (names: Names) => (element: Element, role: string | null) => {
|
|
215
|
+
disabled: boolean;
|
|
216
|
+
checked: boolean | undefined;
|
|
217
|
+
expanded: boolean | undefined;
|
|
218
|
+
selected: boolean | undefined;
|
|
219
|
+
pressed: boolean | undefined;
|
|
220
|
+
focused: boolean;
|
|
221
|
+
level: number | undefined;
|
|
222
|
+
};
|
|
223
|
+
declare const subjects: (names: Names, walked: Walked, matching: Match, placing: ContextReader, stateOf: ReturnType<typeof states>) => {
|
|
224
|
+
find: (request: FindRequest) => {
|
|
225
|
+
invalid: string;
|
|
226
|
+
found?: undefined;
|
|
227
|
+
} | {
|
|
228
|
+
invalid?: undefined;
|
|
229
|
+
found: {
|
|
230
|
+
ref: string;
|
|
231
|
+
subject: {
|
|
232
|
+
role: string | null;
|
|
233
|
+
name: string;
|
|
234
|
+
tag: string;
|
|
235
|
+
context: {
|
|
236
|
+
readonly row?: string | undefined;
|
|
237
|
+
readonly column?: string | undefined;
|
|
238
|
+
readonly label?: string | undefined;
|
|
239
|
+
readonly heading?: string | undefined;
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
box: {
|
|
243
|
+
x: number;
|
|
244
|
+
y: number;
|
|
245
|
+
width: number;
|
|
246
|
+
height: number;
|
|
247
|
+
};
|
|
248
|
+
inViewport: boolean;
|
|
249
|
+
state: {
|
|
250
|
+
disabled: boolean;
|
|
251
|
+
checked: boolean | undefined;
|
|
252
|
+
expanded: boolean | undefined;
|
|
253
|
+
selected: boolean | undefined;
|
|
254
|
+
pressed: boolean | undefined;
|
|
255
|
+
focused: boolean;
|
|
256
|
+
level: number | undefined;
|
|
257
|
+
};
|
|
258
|
+
}[];
|
|
259
|
+
};
|
|
260
|
+
elementsOf: (request: FindRequest) => ReadonlyArray<Element> | {
|
|
261
|
+
readonly invalid: string;
|
|
262
|
+
};
|
|
263
|
+
isControl: (element: Element, role: string | null, style: CSSStyleDeclaration, rect: DOMRect, insidePointer: boolean) => boolean;
|
|
264
|
+
stateOf: (element: Element, role: string | null) => {
|
|
265
|
+
disabled: boolean;
|
|
266
|
+
checked: boolean | undefined;
|
|
267
|
+
expanded: boolean | undefined;
|
|
268
|
+
selected: boolean | undefined;
|
|
269
|
+
pressed: boolean | undefined;
|
|
270
|
+
focused: boolean;
|
|
271
|
+
level: number | undefined;
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
type Subjects = ReturnType<typeof subjects>;
|
|
275
|
+
//#endregion
|
|
15
276
|
//#region src/internal/input/evidence.inpage.d.ts
|
|
16
277
|
/** Page text about the first target. It never includes what a field holds. */
|
|
17
278
|
type Evidence = typeof EvidenceSchema.Encoded;
|
|
@@ -43,7 +304,7 @@ declare const EvidenceSchema: Schema.Struct<{
|
|
|
43
304
|
//#region src/internal/input/targets.inpage.d.ts
|
|
44
305
|
type ResolvedPoint = typeof ResolvedPointSchema.Type;
|
|
45
306
|
type PointResult = typeof PointResultSchema.Type;
|
|
46
|
-
declare const targets: (names: Names, walked:
|
|
307
|
+
declare const targets: (names: Names, walked: Walked, placing: ContextReader) => {
|
|
47
308
|
controlOf: (hit: Element) => Element;
|
|
48
309
|
details: (element: Element, hit: Element, x: number, y: number) => Omit<ResolvedPoint, "context">;
|
|
49
310
|
hitAt: (root: Document | ShadowRoot, x: number, y: number) => Element | null;
|
|
@@ -287,7 +548,7 @@ declare const ReadinessSchema: Schema.$Array<Schema.Literals<readonly ["load", "
|
|
|
287
548
|
type Readiness = typeof ReadinessSchema.Type;
|
|
288
549
|
//#endregion
|
|
289
550
|
//#region src/internal/reading/ready.inpage.d.ts
|
|
290
|
-
declare const ready: (walked:
|
|
551
|
+
declare const ready: (walked: Walked, texts: Texts, kept: History) => {
|
|
291
552
|
wait: (millis: number, quietMillis?: number, clock?: string | null) => Promise<Readiness>;
|
|
292
553
|
settle: () => Promise<boolean>;
|
|
293
554
|
};
|
|
@@ -306,7 +567,7 @@ declare const ChangesResultSchema: Schema.Struct<{
|
|
|
306
567
|
type ChangesResult = typeof ChangesResultSchema.Encoded;
|
|
307
568
|
//#endregion
|
|
308
569
|
//#region src/internal/timeline/sight.inpage.d.ts
|
|
309
|
-
declare const sight: (names: Names, walked:
|
|
570
|
+
declare const sight: (names: Names, walked: Walked, texts: Texts, kept: History) => {
|
|
310
571
|
/** Judge a sample at once if what it shows and whether it is in view are known, else on render. */
|
|
311
572
|
look: (element: Element, sample: Sample) => void;
|
|
312
573
|
/**
|
|
@@ -359,7 +620,7 @@ interface ChangesRequest {
|
|
|
359
620
|
readonly until: number | null;
|
|
360
621
|
readonly unmask: boolean;
|
|
361
622
|
}
|
|
362
|
-
declare const changes: (names: Names, walked:
|
|
623
|
+
declare const changes: (names: Names, walked: Walked, placing: ContextReader, kept: History, seeing: Sight, marking: Marks, recorder: Recorder) => {
|
|
363
624
|
read: (request: ChangesRequest) => ChangesResult;
|
|
364
625
|
};
|
|
365
626
|
type Changes = ReturnType<typeof changes>;
|
|
@@ -517,7 +778,7 @@ interface TextRequest {
|
|
|
517
778
|
readonly maxChars: number;
|
|
518
779
|
readonly unmask: boolean;
|
|
519
780
|
}
|
|
520
|
-
declare const text: (names: Names, walked:
|
|
781
|
+
declare const text: (names: Names, walked: Walked) => {
|
|
521
782
|
cut: (lines: string, max: number) => {
|
|
522
783
|
text: string;
|
|
523
784
|
truncated: boolean;
|
|
@@ -561,7 +822,7 @@ interface SnapshotRequest {
|
|
|
561
822
|
}
|
|
562
823
|
/** The rule every address the library reports goes by, which a link's address goes by too. */
|
|
563
824
|
type Url = ReturnType<typeof addresses>;
|
|
564
|
-
declare const outline: (names: Names, walked:
|
|
825
|
+
declare const outline: (names: Names, walked: Walked, subjects: Subjects, texts: Texts, controlling: Controls, url: Url) => {
|
|
565
826
|
snapshot: (request: SnapshotRequest) => SnapshotResult;
|
|
566
827
|
viewport: () => {
|
|
567
828
|
width: number;
|
|
@@ -574,6 +835,10 @@ type Outline = ReturnType<typeof outline>;
|
|
|
574
835
|
/**
|
|
575
836
|
* The readers, the change record, the overlay and poses for the current document. Make one for
|
|
576
837
|
* each document the site shows, and `stopRecord` the last one's.
|
|
838
|
+
*
|
|
839
|
+
* @stability stable
|
|
840
|
+
* @category constructors
|
|
841
|
+
* @since 0.3.0
|
|
577
842
|
*/
|
|
578
843
|
export declare const make: () => {
|
|
579
844
|
/** What a query finds in the viewport: each element's ref, subject, box and state. */
|
|
@@ -709,6 +974,11 @@ export declare const make: () => {
|
|
|
709
974
|
/** An address without its userinfo or the parameters known to carry secrets. */
|
|
710
975
|
redact: (url: string) => string;
|
|
711
976
|
};
|
|
977
|
+
/**
|
|
978
|
+
* @stability stable
|
|
979
|
+
* @category models
|
|
980
|
+
* @since 0.3.0
|
|
981
|
+
*/
|
|
712
982
|
export type Site = ReturnType<typeof make>;
|
|
713
983
|
//#endregion
|
|
714
984
|
//# sourceMappingURL=Site.d.mts.map
|
package/dist/Site.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { addresses } from "./
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { t as addresses } from "./internal/url-DB0pQYk6.mjs";
|
|
2
|
+
import { n as pickRequests, r as request, t as match } from "./internal/matching-Cs-UeOY0.mjs";
|
|
3
|
+
import { _ as names, a as sight, b as controls, c as history, d as text, f as states, g as elements, h as outline, i as compose, l as changes, m as ready, n as poseRequest, o as record, p as subjects, r as overlay, s as marks, t as pose, u as walk, v as layout, x as context, y as expectations } from "./internal/pose.inpage-CBFeWcVa.mjs";
|
|
4
|
+
import { t as fold } from "./internal/fold.inpage-uhrT-dOB.mjs";
|
|
4
5
|
//#region src/Site.ts
|
|
5
6
|
/**
|
|
6
7
|
* The library's readers for a site that owns its page, called in the site's own bundle on its own
|
|
@@ -24,10 +25,17 @@ import { S as context, _ as elements, a as sight, b as expectations, c as histor
|
|
|
24
25
|
* request the page cannot serve answers `{ invalid }`, and a ref it no longer has `{ stale }`,
|
|
25
26
|
* rather than throwing. `Layout`, `Change` and `Snapshot` hold their schemas. The script runs in
|
|
26
27
|
* the site's own world, so it shares the globals the site's code may patch.
|
|
28
|
+
*
|
|
29
|
+
* @stability stable
|
|
30
|
+
* @since 0.3.0
|
|
27
31
|
*/
|
|
28
32
|
/**
|
|
29
33
|
* The readers, the change record, the overlay and poses for the current document. Make one for
|
|
30
34
|
* each document the site shows, and `stopRecord` the last one's.
|
|
35
|
+
*
|
|
36
|
+
* @stability stable
|
|
37
|
+
* @category constructors
|
|
38
|
+
* @since 0.3.0
|
|
31
39
|
*/
|
|
32
40
|
const make = () => {
|
|
33
41
|
const { named, recorder, url, reads } = compose({
|
package/dist/Site.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Site.mjs","names":[],"sources":["../src/Site.ts"],"sourcesContent":["/**\n * The library's readers for a site that owns its page, called in the site's own bundle on its own\n * document, with no protocol in it. It is the composition the library installs in a page over the\n * protocol, so a site reads the same refs, subjects, outline, text, layout and changes as an agent\n * does, draws in the same overlay, and poses elements the same way.\n *\n * What needs the protocol stays out:\n *\n * - trusted input and the checks that make it safe;\n * - pictures;\n * - held page time;\n * - a record that starts before the page's own scripts.\n *\n * Instead, the site acts through its own app and `note`s each act, so the changes it brings name it\n * as their cause. Time is real, so a pose or a drawing is set again on each animation frame. The\n * record starts when the site calls `record`.\n *\n * Requests and results are the page script's own plain data. Boxes are in viewport CSS pixels, and\n * a change's times are epoch milliseconds, as `performance.timeOrigin + performance.now()`. A\n * request the page cannot serve answers `{ invalid }`, and a ref it no longer has `{ stale }`,\n * rather than throwing. `Layout`, `Change` and `Snapshot` hold their schemas. The script runs in\n * the site's own world, so it shares the globals the site's code may patch.\n */\nimport { compose } from \"./internal/page/compose.inpage.ts\";\nimport { overlay } from \"./internal/page/overlay.inpage.ts\";\nimport { pose, poseRequest } from \"./internal/page/pose.inpage.ts\";\nimport { context } from \"./internal/reading/context.inpage.ts\";\nimport { controls } from \"./internal/reading/controls.inpage.ts\";\nimport { expectations, type Want } from \"./internal/reading/expect.inpage.ts\";\nimport { layout } from \"./internal/reading/layout.inpage.ts\";\nimport { elements, names } from \"./internal/reading/names.inpage.ts\";\nimport { outline } from \"./internal/reading/outline.inpage.ts\";\nimport { ready } from \"./internal/reading/ready.inpage.ts\";\nimport { states, subjects } from \"./internal/reading/subjects.inpage.ts\";\nimport { text } from \"./internal/reading/text.inpage.ts\";\nimport { walk } from \"./internal/reading/walk.inpage.ts\";\nimport { changes } from \"./internal/timeline/changes.inpage.ts\";\nimport { fold } from \"./internal/timeline/fold.inpage.ts\";\nimport { history } from \"./internal/timeline/history.inpage.ts\";\nimport { marks } from \"./internal/timeline/marks.inpage.ts\";\nimport { record } from \"./internal/timeline/record.inpage.ts\";\nimport { sight } from \"./internal/timeline/sight.inpage.ts\";\nimport
|
|
1
|
+
{"version":3,"file":"Site.mjs","names":[],"sources":["../src/Site.ts"],"sourcesContent":["/**\n * The library's readers for a site that owns its page, called in the site's own bundle on its own\n * document, with no protocol in it. It is the composition the library installs in a page over the\n * protocol, so a site reads the same refs, subjects, outline, text, layout and changes as an agent\n * does, draws in the same overlay, and poses elements the same way.\n *\n * What needs the protocol stays out:\n *\n * - trusted input and the checks that make it safe;\n * - pictures;\n * - held page time;\n * - a record that starts before the page's own scripts.\n *\n * Instead, the site acts through its own app and `note`s each act, so the changes it brings name it\n * as their cause. Time is real, so a pose or a drawing is set again on each animation frame. The\n * record starts when the site calls `record`.\n *\n * Requests and results are the page script's own plain data. Boxes are in viewport CSS pixels, and\n * a change's times are epoch milliseconds, as `performance.timeOrigin + performance.now()`. A\n * request the page cannot serve answers `{ invalid }`, and a ref it no longer has `{ stale }`,\n * rather than throwing. `Layout`, `Change` and `Snapshot` hold their schemas. The script runs in\n * the site's own world, so it shares the globals the site's code may patch.\n *\n * @stability stable\n * @since 0.3.0\n */\nimport { match, pickRequests, request } from \"./internal/matching.ts\";\nimport { compose } from \"./internal/page/compose.inpage.ts\";\nimport { overlay } from \"./internal/page/overlay.inpage.ts\";\nimport { pose, poseRequest } from \"./internal/page/pose.inpage.ts\";\nimport { context } from \"./internal/reading/context.inpage.ts\";\nimport { controls } from \"./internal/reading/controls.inpage.ts\";\nimport { expectations, type Want } from \"./internal/reading/expect.inpage.ts\";\nimport { layout } from \"./internal/reading/layout.inpage.ts\";\nimport { elements, names } from \"./internal/reading/names.inpage.ts\";\nimport { outline } from \"./internal/reading/outline.inpage.ts\";\nimport { ready } from \"./internal/reading/ready.inpage.ts\";\nimport { states, subjects } from \"./internal/reading/subjects.inpage.ts\";\nimport { text } from \"./internal/reading/text.inpage.ts\";\nimport { walk } from \"./internal/reading/walk.inpage.ts\";\nimport { changes } from \"./internal/timeline/changes.inpage.ts\";\nimport { fold } from \"./internal/timeline/fold.inpage.ts\";\nimport { history } from \"./internal/timeline/history.inpage.ts\";\nimport { marks } from \"./internal/timeline/marks.inpage.ts\";\nimport { record } from \"./internal/timeline/record.inpage.ts\";\nimport { sight } from \"./internal/timeline/sight.inpage.ts\";\nimport { addresses } from \"./internal/url.ts\";\nimport type { Picks } from \"./Layout.ts\";\nimport type { Pose } from \"./Pose.ts\";\nimport type { FindQuery } from \"./Snapshot.ts\";\n\n/**\n * The readers, the change record, the overlay and poses for the current document. Make one for\n * each document the site shows, and `stopRecord` the last one's.\n *\n * @stability stable\n * @category constructors\n * @since 0.3.0\n */\nexport const make = () => {\n const { named, recorder, url, reads } = compose({\n elements,\n names,\n walk,\n match,\n context,\n subjects,\n states,\n expectations,\n text,\n layout,\n controls,\n fold,\n history,\n sight,\n marks,\n record,\n changes,\n ready,\n outline,\n overlay,\n pose,\n addresses,\n });\n\n const own = overlay(named);\n\n return {\n /** What a query finds in the viewport: each element's ref, subject, box and state. */\n find: (query: FindQuery) => reads.find(request(query, \"viewport\")),\n /** Where each pick is, unrounded, with a box for each of the words it asks for. */\n layout: (picks: Picks) => reads.layout(pickRequests(picks)),\n /** Wait up to `millis` until what a query finds in the document is as wanted. */\n until: (query: FindQuery, want: Want, millis: number) =>\n reads.until(request(query, \"document\"), want, millis),\n /** The page as an outline of its subjects, each control with a ref. */\n snapshot: reads.snapshot,\n /** The text the viewport shows, or one element's. */\n text: reads.text,\n /** Wait up to `millis` for what the page is still loading, quiet for `quietMillis`. */\n ready: (millis: number, quietMillis?: number) => reads.ready(millis, quietMillis),\n /** One task, then a frame; says whether the page painted. */\n settle: reads.settle,\n /** Record what changes from now, until `stopRecord`, or two minutes with no `changes`. */\n record: reads.record,\n stopRecord: reads.stopRecord,\n /** Keep an act the site did through its app at `target` now, for changes to name as cause. */\n note: recorder.note,\n /** What changed in a window of the record, each change with its box. */\n changes: reads.changes,\n /** Draw an SVG document over the viewport, or take it away with null; says where its parts are. */\n draw: reads.overlay,\n /**\n * A layer of the site's own over the viewport, which no reader reads and the record leaves\n * out: a closed shadow root to render into. It takes no pointer, except parts that set\n * `pointer-events: auto`.\n */\n layer: own.mount,\n /** Pose these elements and take the pose off every other. */\n pose: (poses: ReadonlyArray<Pose>) => reads.pose(poses.map(poseRequest)),\n unpose: reads.unpose,\n /** An element's ref, which `pose` and a read's `ref` take. */\n ref: named.refFor,\n /** The element a ref names, while it is in the document. */\n element: named.lookup,\n /** An address without its userinfo or the parameters known to carry secrets. */\n redact: url.redact,\n };\n};\n\n/**\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport type Site = ReturnType<typeof make>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAa,aAAa;CACxB,MAAM,EAAE,OAAO,UAAU,KAAK,UAAU,QAAQ;EAC9C;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,MAAM,QAAQ,KAAK;CAEzB,OAAO;;EAEL,OAAO,UAAqB,MAAM,KAAK,QAAQ,OAAO,UAAU,CAAC;;EAEjE,SAAS,UAAiB,MAAM,OAAO,aAAa,KAAK,CAAC;;EAE1D,QAAQ,OAAkB,MAAY,WACpC,MAAM,MAAM,QAAQ,OAAO,UAAU,GAAG,MAAM,MAAM;;EAEtD,UAAU,MAAM;;EAEhB,MAAM,MAAM;;EAEZ,QAAQ,QAAgB,gBAAyB,MAAM,MAAM,QAAQ,WAAW;;EAEhF,QAAQ,MAAM;;EAEd,QAAQ,MAAM;EACd,YAAY,MAAM;;EAElB,MAAM,SAAS;;EAEf,SAAS,MAAM;;EAEf,MAAM,MAAM;;;;;;EAMZ,OAAO,IAAI;;EAEX,OAAO,UAA+B,MAAM,KAAK,MAAM,IAAI,WAAW,CAAC;EACvE,QAAQ,MAAM;;EAEd,KAAK,MAAM;;EAEX,SAAS,MAAM;;EAEf,QAAQ,IAAI;CACd;AACF"}
|
package/dist/Snapshot.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { Control, Snapshot, SnapshotOptions };
|
|
1
|
+
import { $ as ElementState, Q as Control, at as UntilResult, ct as read, et as FindQuery, lt as until, nt as Snapshot, ot as UntilWant, rt as SnapshotOptions, st as find, tt as Found } from "./internal/Page-BfGxn7oN.mjs";
|
|
2
|
+
export { Control, ElementState, FindQuery, Found, Snapshot, SnapshotOptions, UntilResult, UntilWant, find, read, until };
|
package/dist/Snapshot.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import {
|
|
1
|
+
import { t as __exportAll } from "./internal/rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { Box, Subject } from "./BrowserEvent.mjs";
|
|
3
|
+
import { r as millisOf } from "./internal/clock-BKSAEf00.mjs";
|
|
4
|
+
import { n as functionsOf, r as isPage } from "./internal/functions-jBOs6GKv.mjs";
|
|
5
|
+
import { Function, Schema } from "effect";
|
|
3
6
|
//#region src/Snapshot.ts
|
|
4
7
|
/**
|
|
5
8
|
* A compact, model-readable outline of what a page shows.
|
|
@@ -8,14 +11,26 @@ import { Schema } from "effect";
|
|
|
8
11
|
* refs are never reused within a page, so a ref from an old snapshot fails as stale rather than
|
|
9
12
|
* naming a different element.
|
|
10
13
|
*
|
|
14
|
+
* @stability stable
|
|
11
15
|
* @since 0.3.0
|
|
12
16
|
*/
|
|
13
17
|
var Snapshot_exports = /* @__PURE__ */ __exportAll({
|
|
14
18
|
Control: () => Control,
|
|
15
|
-
|
|
19
|
+
ElementState: () => ElementState,
|
|
20
|
+
Found: () => Found,
|
|
21
|
+
Snapshot: () => Snapshot,
|
|
22
|
+
find: () => find,
|
|
23
|
+
read: () => read,
|
|
24
|
+
until: () => until
|
|
16
25
|
});
|
|
17
|
-
/**
|
|
18
|
-
|
|
26
|
+
/**
|
|
27
|
+
* A control the outline shows, as a value: its ref, what it is and what it holds.
|
|
28
|
+
*
|
|
29
|
+
* @stability stable
|
|
30
|
+
* @category schemas
|
|
31
|
+
* @since 0.3.0
|
|
32
|
+
*/
|
|
33
|
+
var Control = class extends Schema.Class("effect-browser/Snapshot/Control")({
|
|
19
34
|
ref: Schema.String,
|
|
20
35
|
/** Its role, such as `button` or `textbox`, or `clickable` for an element without one. */
|
|
21
36
|
kind: Schema.String,
|
|
@@ -33,6 +48,11 @@ var Control = class extends Schema.Class("effect-browser/Control")({
|
|
|
33
48
|
/** True for a field that takes typed text. */
|
|
34
49
|
editable: Schema.optional(Schema.Boolean)
|
|
35
50
|
}) {};
|
|
51
|
+
/**
|
|
52
|
+
* @stability stable
|
|
53
|
+
* @category schemas
|
|
54
|
+
* @since 0.3.0
|
|
55
|
+
*/
|
|
36
56
|
var Snapshot = class extends Schema.Class("effect-browser/Snapshot")({
|
|
37
57
|
url: Schema.String,
|
|
38
58
|
title: Schema.String,
|
|
@@ -73,7 +93,68 @@ var Snapshot = class extends Schema.Class("effect-browser/Snapshot")({
|
|
|
73
93
|
].join("\n");
|
|
74
94
|
}
|
|
75
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* An element's state as its markup gives it: `checked` for what can be checked, `expanded`,
|
|
98
|
+
* `selected` and `pressed` where the page says either way, and `level` for headings.
|
|
99
|
+
*
|
|
100
|
+
* @stability stable
|
|
101
|
+
* @category schemas
|
|
102
|
+
* @since 0.3.0
|
|
103
|
+
*/
|
|
104
|
+
const ElementState = Schema.Struct({
|
|
105
|
+
disabled: Schema.Boolean,
|
|
106
|
+
focused: Schema.Boolean,
|
|
107
|
+
checked: Schema.optional(Schema.Boolean),
|
|
108
|
+
expanded: Schema.optional(Schema.Boolean),
|
|
109
|
+
selected: Schema.optional(Schema.Boolean),
|
|
110
|
+
pressed: Schema.optional(Schema.Boolean),
|
|
111
|
+
level: Schema.optional(Schema.Int)
|
|
112
|
+
});
|
|
113
|
+
/**
|
|
114
|
+
* An element `find` found: a ref for the actions, what it is, where it is and its state.
|
|
115
|
+
*
|
|
116
|
+
* @stability stable
|
|
117
|
+
* @category schemas
|
|
118
|
+
* @since 0.3.0
|
|
119
|
+
*/
|
|
120
|
+
var Found = class extends Schema.Class("effect-browser/Snapshot/Found")({
|
|
121
|
+
ref: Schema.String,
|
|
122
|
+
subject: Subject,
|
|
123
|
+
/** Its box, rounded. Reading the document, it may be out of view. */
|
|
124
|
+
box: Box,
|
|
125
|
+
inViewport: Schema.Boolean,
|
|
126
|
+
state: ElementState
|
|
127
|
+
}) {};
|
|
128
|
+
/**
|
|
129
|
+
* The page's outline: one line per control, heading or text block, with a ref for each control,
|
|
130
|
+
* in one call to the page.
|
|
131
|
+
*
|
|
132
|
+
* @stability stable
|
|
133
|
+
* @category constructors
|
|
134
|
+
* @since 0.3.0
|
|
135
|
+
*/
|
|
136
|
+
const read = Function.dual((args) => isPage(args[0]), (page, options) => functionsOf(page).snapshot(options));
|
|
137
|
+
/**
|
|
138
|
+
* The elements that match a query, in tree order, with refs the actions take, in one call to the
|
|
139
|
+
* page. All that match are returned, so a caller tells them apart by their context; none is an
|
|
140
|
+
* empty result, not a failure.
|
|
141
|
+
*
|
|
142
|
+
* @stability stable
|
|
143
|
+
* @category combinators
|
|
144
|
+
* @since 0.3.0
|
|
145
|
+
*/
|
|
146
|
+
const find = Function.dual((args) => isPage(args[0]), (page, query) => functionsOf(page).find(query));
|
|
147
|
+
/**
|
|
148
|
+
* Wait, in one call to the page, until what `query` matches is as `want` says or `timeout` passes.
|
|
149
|
+
* Replaced documents share one deadline. Unmet is `met: false`; an empty mark means no stable
|
|
150
|
+
* document could be sampled.
|
|
151
|
+
*
|
|
152
|
+
* @stability stable
|
|
153
|
+
* @category combinators
|
|
154
|
+
* @since 0.3.0
|
|
155
|
+
*/
|
|
156
|
+
const until = Function.dual(4, (page, query, want, timeout) => functionsOf(page).until(query, want, millisOf(timeout)));
|
|
76
157
|
//#endregion
|
|
77
|
-
export { Control, Snapshot, Snapshot_exports as t };
|
|
158
|
+
export { Control, ElementState, Found, Snapshot, find, read, Snapshot_exports as t, until };
|
|
78
159
|
|
|
79
160
|
//# sourceMappingURL=Snapshot.mjs.map
|
package/dist/Snapshot.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Snapshot.mjs","names":[],"sources":["../src/Snapshot.ts"],"sourcesContent":["/**\n * A compact, model-readable outline of what a page shows.\n *\n * Each control gets a ref such as `e12`. A ref stays valid while its element is on the page, and\n * refs are never reused within a page, so a ref from an old snapshot fails as stale rather than\n * naming a different element.\n *\n * @since 0.3.0\n */\nimport { Schema } from \"effect\";\n\n/** A control the outline shows, as a value: its ref, what it is and what it holds. */\nexport class Control extends Schema.Class<Control>(\"effect-browser/Control\")({\n ref: Schema.String,\n /** Its role, such as `button` or `textbox`, or `clickable` for an element without one. */\n kind: Schema.String,\n /** Its accessible name. */\n name: Schema.String,\n /** What it holds: a field's text, `••••` for a secret one, or a select's chosen labels. */\n value: Schema.String,\n /** A select's option labels, at most 64. */\n options: Schema.optional(Schema.Array(Schema.String)),\n /** How many options a select has, when it has options. */\n optionCount: Schema.optional(Schema.Int),\n disabled: Schema.optional(Schema.Boolean),\n /** Whether it is checked, for what can be checked. */\n checked: Schema.optional(Schema.Boolean),\n /** True for a field that takes typed text. */\n editable: Schema.optional(Schema.Boolean),\n}) {}\n\nexport class Snapshot extends Schema.Class<Snapshot>(\"effect-browser/Snapshot\")({\n url: Schema.String,\n title: Schema.String,\n /** One line per control, heading or text block, indented by landmark. */\n text: Schema.String,\n /** True when `text` was cut at `maxChars`. */\n truncated: Schema.Boolean,\n /**\n * Parts of the page left out because they lie above or below the viewport, each an element out\n * of view with all it holds (viewport snapshots only).\n */\n above: Schema.Finite,\n below: Schema.Finite,\n viewport: Schema.Struct({ width: Schema.Finite, height: Schema.Finite }),\n scroll: Schema.Struct({ y: Schema.Finite, height: Schema.Finite }),\n /** The controls the outline shows, in its order. */\n controls: Schema.Array(Control),\n}) {\n /** The snapshot as one block of text for a model: header, outline and what was left out. */\n get rendered(): string {\n const position =\n this.scroll.height > this.viewport.height\n ? `, scrolled to ${this.scroll.y} of ${this.scroll.height - this.viewport.height}px`\n : \"\";\n\n const omitted: Array<string> = [];\n\n if (this.above > 0) omitted.push(`${this.above} parts above`);\n if (this.below > 0) omitted.push(`${this.below} parts below`);\n\n const footer = [\n ...(omitted.length > 0 ? [`(${omitted.join(\", \")} the viewport)`] : []),\n ...(this.truncated ? [\"(cut short: narrow it with query)\"] : []),\n ];\n\n return [\n `Page: ${this.title === \"\" ? \"(untitled)\" : this.title}`,\n `URL: ${this.url}`,\n `Viewport: ${this.viewport.width}x${this.viewport.height}${position}`,\n this.text === \"\" ? \"(nothing readable in view)\" : this.text,\n ...footer,\n ].join(\"\\n\");\n }\n}\n\nexport interface SnapshotOptions {\n /** Read the whole page instead of the viewport. Defaults to false. */\n readonly full?: boolean | undefined;\n /** Keep only lines containing this text (case-insensitive). */\n readonly query?: string | undefined;\n /**\n * Read only inside the elements this CSS selector matches, such as `form` or `#results`. A\n * selector that matches nothing reads nothing; one that is not CSS is an `InvalidRequest`.\n */\n readonly within?: string | undefined;\n /** Bound on the outline's length. Defaults to 12,000 characters. */\n readonly maxChars?: number | undefined;\n /**\n * Give every control's box, as `WxH at (x,y)` in viewport CSS pixels, as a canvas's or a frame's\n * always has. Defaults to false.\n */\n readonly boxes?: boolean | undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,IAAa,UAAb,cAA6B,OAAO,MAAe,wBAAwB,CAAC,CAAC;CAC3E,KAAK,OAAO;;CAEZ,MAAM,OAAO;;CAEb,MAAM,OAAO;;CAEb,OAAO,OAAO;;CAEd,SAAS,OAAO,SAAS,OAAO,MAAM,OAAO,MAAM,CAAC;;CAEpD,aAAa,OAAO,SAAS,OAAO,GAAG;CACvC,UAAU,OAAO,SAAS,OAAO,OAAO;;CAExC,SAAS,OAAO,SAAS,OAAO,OAAO;;CAEvC,UAAU,OAAO,SAAS,OAAO,OAAO;AAC1C,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,WAAb,cAA8B,OAAO,MAAgB,yBAAyB,CAAC,CAAC;CAC9E,KAAK,OAAO;CACZ,OAAO,OAAO;;CAEd,MAAM,OAAO;;CAEb,WAAW,OAAO;;;;;CAKlB,OAAO,OAAO;CACd,OAAO,OAAO;CACd,UAAU,OAAO,OAAO;EAAE,OAAO,OAAO;EAAQ,QAAQ,OAAO;CAAO,CAAC;CACvE,QAAQ,OAAO,OAAO;EAAE,GAAG,OAAO;EAAQ,QAAQ,OAAO;CAAO,CAAC;;CAEjE,UAAU,OAAO,MAAM,OAAO;AAChC,CAAC,CAAC,CAAC;;CAED,IAAI,WAAmB;EACrB,MAAM,WACJ,KAAK,OAAO,SAAS,KAAK,SAAS,SAC/B,iBAAiB,KAAK,OAAO,EAAE,MAAM,KAAK,OAAO,SAAS,KAAK,SAAS,OAAO,MAC/E;EAEN,MAAM,UAAyB,CAAC;EAEhC,IAAI,KAAK,QAAQ,GAAG,QAAQ,KAAK,GAAG,KAAK,MAAM,aAAa;EAC5D,IAAI,KAAK,QAAQ,GAAG,QAAQ,KAAK,GAAG,KAAK,MAAM,aAAa;EAE5D,MAAM,SAAS,CACb,GAAI,QAAQ,SAAS,IAAI,CAAC,IAAI,QAAQ,KAAK,IAAI,EAAE,eAAe,IAAI,CAAC,GACrE,GAAI,KAAK,YAAY,CAAC,mCAAmC,IAAI,CAAC,CAChE;EAEA,OAAO;GACL,SAAS,KAAK,UAAU,KAAK,eAAe,KAAK;GACjD,QAAQ,KAAK;GACb,aAAa,KAAK,SAAS,MAAM,GAAG,KAAK,SAAS,SAAS;GAC3D,KAAK,SAAS,KAAK,+BAA+B,KAAK;GACvD,GAAG;EACL,CAAC,CAAC,KAAK,IAAI;CACb;AACF"}
|
|
1
|
+
{"version":3,"file":"Snapshot.mjs","names":[],"sources":["../src/Snapshot.ts"],"sourcesContent":["/**\n * A compact, model-readable outline of what a page shows.\n *\n * Each control gets a ref such as `e12`. A ref stays valid while its element is on the page, and\n * refs are never reused within a page, so a ref from an old snapshot fails as stale rather than\n * naming a different element.\n *\n * @stability stable\n * @since 0.3.0\n */\nimport { type Duration, type Effect, Function, Schema } from \"effect\";\n\nimport type { BrowserError } from \"./BrowserError.ts\";\nimport { Box, Subject } from \"./BrowserEvent.ts\";\nimport { millisOf } from \"./internal/clock.ts\";\nimport type { Point } from \"./internal/geometry.ts\";\nimport { functionsOf, isPage } from \"./internal/page/functions.ts\";\nimport type { Page } from \"./Page.ts\";\n\n/**\n * A control the outline shows, as a value: its ref, what it is and what it holds.\n *\n * @stability stable\n * @category schemas\n * @since 0.3.0\n */\nexport class Control extends Schema.Class<Control>(\"effect-browser/Snapshot/Control\")({\n ref: Schema.String,\n /** Its role, such as `button` or `textbox`, or `clickable` for an element without one. */\n kind: Schema.String,\n /** Its accessible name. */\n name: Schema.String,\n /** What it holds: a field's text, `••••` for a secret one, or a select's chosen labels. */\n value: Schema.String,\n /** A select's option labels, at most 64. */\n options: Schema.optional(Schema.Array(Schema.String)),\n /** How many options a select has, when it has options. */\n optionCount: Schema.optional(Schema.Int),\n disabled: Schema.optional(Schema.Boolean),\n /** Whether it is checked, for what can be checked. */\n checked: Schema.optional(Schema.Boolean),\n /** True for a field that takes typed text. */\n editable: Schema.optional(Schema.Boolean),\n}) {}\n\n/**\n * @stability stable\n * @category schemas\n * @since 0.3.0\n */\nexport class Snapshot extends Schema.Class<Snapshot>(\"effect-browser/Snapshot\")({\n url: Schema.String,\n title: Schema.String,\n /** One line per control, heading or text block, indented by landmark. */\n text: Schema.String,\n /** True when `text` was cut at `maxChars`. */\n truncated: Schema.Boolean,\n /**\n * Parts of the page left out because they lie above or below the viewport, each an element out\n * of view with all it holds (viewport snapshots only).\n */\n above: Schema.Finite,\n below: Schema.Finite,\n viewport: Schema.Struct({ width: Schema.Finite, height: Schema.Finite }),\n scroll: Schema.Struct({ y: Schema.Finite, height: Schema.Finite }),\n /** The controls the outline shows, in its order. */\n controls: Schema.Array(Control),\n}) {\n /** The snapshot as one block of text for a model: header, outline and what was left out. */\n get rendered(): string {\n const position =\n this.scroll.height > this.viewport.height\n ? `, scrolled to ${this.scroll.y} of ${this.scroll.height - this.viewport.height}px`\n : \"\";\n\n const omitted: Array<string> = [];\n\n if (this.above > 0) omitted.push(`${this.above} parts above`);\n if (this.below > 0) omitted.push(`${this.below} parts below`);\n\n const footer = [\n ...(omitted.length > 0 ? [`(${omitted.join(\", \")} the viewport)`] : []),\n ...(this.truncated ? [\"(cut short: narrow it with query)\"] : []),\n ];\n\n return [\n `Page: ${this.title === \"\" ? \"(untitled)\" : this.title}`,\n `URL: ${this.url}`,\n `Viewport: ${this.viewport.width}x${this.viewport.height}${position}`,\n this.text === \"\" ? \"(nothing readable in view)\" : this.text,\n ...footer,\n ].join(\"\\n\");\n }\n}\n\n/**\n * @stability stable\n * @category options\n * @since 0.3.0\n */\nexport interface SnapshotOptions {\n /** Read the whole page instead of the viewport. Defaults to false. */\n readonly full?: boolean | undefined;\n /** Keep only lines containing this text (case-insensitive). */\n readonly query?: string | undefined;\n /**\n * Read only inside the elements this CSS selector matches, such as `form` or `#results`. A\n * selector that matches nothing reads nothing; one that is not CSS is an `InvalidRequest`.\n */\n readonly within?: string | undefined;\n /** Bound on the outline's length. Defaults to 12,000 characters. */\n readonly maxChars?: number | undefined;\n /**\n * Give every control's box, as `WxH at (x,y)` in viewport CSS pixels, as a canvas's or a frame's\n * always has. Defaults to false.\n */\n readonly boxes?: boolean | undefined;\n}\n\n/**\n * What `find` looks for. Every rule given must hold; with none, it finds every element in scope\n * that has a role or is a control.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface FindQuery {\n /** Narrow matching to this CSS selector. Invalid CSS fails InvalidRequest. */\n readonly selector?: string | undefined;\n /** Require a visible match, optionally enabled. */\n readonly state?: \"visible\" | \"enabled\" | undefined;\n /** An ARIA role, such as `\"button\"` or `\"heading\"`, ignoring case. */\n readonly role?: string | undefined;\n /**\n * The accessible name: a string that reads the same once spaces are collapsed and case folded,\n * or a pattern found in it.\n */\n readonly name?: string | RegExp | undefined;\n /**\n * Text it shows, ignoring case and spacing, or a pattern. Text inside a control or a heading is\n * that control's or heading's, and only the smallest element showing it matches, not every\n * element around it.\n */\n readonly text?: string | RegExp | undefined;\n /** Whole words in its context (row, column, label or heading), ignoring case and spacing. */\n readonly near?: string | undefined;\n /** Only what a point action at this viewport point would reach: the control there, or else what is painted there. */\n readonly at?: Point | undefined;\n /** The viewport (the default), or the whole document. */\n readonly scope?: \"viewport\" | \"document\" | undefined;\n}\n\n/**\n * An element's state as its markup gives it: `checked` for what can be checked, `expanded`,\n * `selected` and `pressed` where the page says either way, and `level` for headings.\n *\n * @stability stable\n * @category schemas\n * @since 0.3.0\n */\nexport const ElementState = Schema.Struct({\n disabled: Schema.Boolean,\n focused: Schema.Boolean,\n checked: Schema.optional(Schema.Boolean),\n expanded: Schema.optional(Schema.Boolean),\n selected: Schema.optional(Schema.Boolean),\n pressed: Schema.optional(Schema.Boolean),\n level: Schema.optional(Schema.Int),\n});\n\n/**\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport type ElementState = typeof ElementState.Type;\n\n/**\n * An element `find` found: a ref for the actions, what it is, where it is and its state.\n *\n * @stability stable\n * @category schemas\n * @since 0.3.0\n */\nexport class Found extends Schema.Class<Found>(\"effect-browser/Snapshot/Found\")({\n ref: Schema.String,\n subject: Subject,\n /** Its box, rounded. Reading the document, it may be out of view. */\n box: Box,\n inViewport: Schema.Boolean,\n state: ElementState,\n}) {}\n\n/**\n * The page's outline: one line per control, heading or text block, with a ref for each control,\n * in one call to the page.\n *\n * @stability stable\n * @category constructors\n * @since 0.3.0\n */\nexport const read: {\n (options?: SnapshotOptions): (page: Page) => Effect.Effect<Snapshot, BrowserError>;\n (page: Page, options?: SnapshotOptions): Effect.Effect<Snapshot, BrowserError>;\n} = Function.dual(\n (args) => isPage(args[0]),\n (page: Page, options?: SnapshotOptions) => functionsOf(page).snapshot(options),\n);\n\n/**\n * The elements that match a query, in tree order, with refs the actions take, in one call to the\n * page. All that match are returned, so a caller tells them apart by their context; none is an\n * empty result, not a failure.\n *\n * @stability stable\n * @category combinators\n * @since 0.3.0\n */\nexport const find: {\n (query?: FindQuery): (page: Page) => Effect.Effect<ReadonlyArray<Found>, BrowserError>;\n (page: Page, query?: FindQuery): Effect.Effect<ReadonlyArray<Found>, BrowserError>;\n} = Function.dual(\n (args) => isPage(args[0]),\n (page: Page, query?: FindQuery) => functionsOf(page).find(query),\n);\n\n/**\n * What a wait requires of the query's matches.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport type UntilWant = \"some\" | \"none\" | { readonly other: string };\n\n/**\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface UntilResult {\n readonly met: boolean;\n readonly mark: string;\n}\n\n/**\n * Wait, in one call to the page, until what `query` matches is as `want` says or `timeout` passes.\n * Replaced documents share one deadline. Unmet is `met: false`; an empty mark means no stable\n * document could be sampled.\n *\n * @stability stable\n * @category combinators\n * @since 0.3.0\n */\nexport const until: {\n (\n query: FindQuery,\n want: UntilWant,\n timeout: Duration.Input,\n ): (page: Page) => Effect.Effect<UntilResult, BrowserError>;\n (\n page: Page,\n query: FindQuery,\n want: UntilWant,\n timeout: Duration.Input,\n ): Effect.Effect<UntilResult, BrowserError>;\n} = Function.dual(4, (page: Page, query: FindQuery, want: UntilWant, timeout: Duration.Input) =>\n functionsOf(page).until(query, want, millisOf(timeout)),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAa,UAAb,cAA6B,OAAO,MAAe,iCAAiC,CAAC,CAAC;CACpF,KAAK,OAAO;;CAEZ,MAAM,OAAO;;CAEb,MAAM,OAAO;;CAEb,OAAO,OAAO;;CAEd,SAAS,OAAO,SAAS,OAAO,MAAM,OAAO,MAAM,CAAC;;CAEpD,aAAa,OAAO,SAAS,OAAO,GAAG;CACvC,UAAU,OAAO,SAAS,OAAO,OAAO;;CAExC,SAAS,OAAO,SAAS,OAAO,OAAO;;CAEvC,UAAU,OAAO,SAAS,OAAO,OAAO;AAC1C,CAAC,CAAC,CAAC,CAAC;;;;;;AAOJ,IAAa,WAAb,cAA8B,OAAO,MAAgB,yBAAyB,CAAC,CAAC;CAC9E,KAAK,OAAO;CACZ,OAAO,OAAO;;CAEd,MAAM,OAAO;;CAEb,WAAW,OAAO;;;;;CAKlB,OAAO,OAAO;CACd,OAAO,OAAO;CACd,UAAU,OAAO,OAAO;EAAE,OAAO,OAAO;EAAQ,QAAQ,OAAO;CAAO,CAAC;CACvE,QAAQ,OAAO,OAAO;EAAE,GAAG,OAAO;EAAQ,QAAQ,OAAO;CAAO,CAAC;;CAEjE,UAAU,OAAO,MAAM,OAAO;AAChC,CAAC,CAAC,CAAC;;CAED,IAAI,WAAmB;EACrB,MAAM,WACJ,KAAK,OAAO,SAAS,KAAK,SAAS,SAC/B,iBAAiB,KAAK,OAAO,EAAE,MAAM,KAAK,OAAO,SAAS,KAAK,SAAS,OAAO,MAC/E;EAEN,MAAM,UAAyB,CAAC;EAEhC,IAAI,KAAK,QAAQ,GAAG,QAAQ,KAAK,GAAG,KAAK,MAAM,aAAa;EAC5D,IAAI,KAAK,QAAQ,GAAG,QAAQ,KAAK,GAAG,KAAK,MAAM,aAAa;EAE5D,MAAM,SAAS,CACb,GAAI,QAAQ,SAAS,IAAI,CAAC,IAAI,QAAQ,KAAK,IAAI,EAAE,eAAe,IAAI,CAAC,GACrE,GAAI,KAAK,YAAY,CAAC,mCAAmC,IAAI,CAAC,CAChE;EAEA,OAAO;GACL,SAAS,KAAK,UAAU,KAAK,eAAe,KAAK;GACjD,QAAQ,KAAK;GACb,aAAa,KAAK,SAAS,MAAM,GAAG,KAAK,SAAS,SAAS;GAC3D,KAAK,SAAS,KAAK,+BAA+B,KAAK;GACvD,GAAG;EACL,CAAC,CAAC,KAAK,IAAI;CACb;AACF;;;;;;;;;AAoEA,MAAa,eAAe,OAAO,OAAO;CACxC,UAAU,OAAO;CACjB,SAAS,OAAO;CAChB,SAAS,OAAO,SAAS,OAAO,OAAO;CACvC,UAAU,OAAO,SAAS,OAAO,OAAO;CACxC,UAAU,OAAO,SAAS,OAAO,OAAO;CACxC,SAAS,OAAO,SAAS,OAAO,OAAO;CACvC,OAAO,OAAO,SAAS,OAAO,GAAG;AACnC,CAAC;;;;;;;;AAgBD,IAAa,QAAb,cAA2B,OAAO,MAAa,+BAA+B,CAAC,CAAC;CAC9E,KAAK,OAAO;CACZ,SAAS;;CAET,KAAK;CACL,YAAY,OAAO;CACnB,OAAO;AACT,CAAC,CAAC,CAAC,CAAC;;;;;;;;;AAUJ,MAAa,OAGT,SAAS,MACV,SAAS,OAAO,KAAK,EAAE,IACvB,MAAY,YAA8B,YAAY,IAAI,CAAC,CAAC,SAAS,OAAO,CAC/E;;;;;;;;;;AAWA,MAAa,OAGT,SAAS,MACV,SAAS,OAAO,KAAK,EAAE,IACvB,MAAY,UAAsB,YAAY,IAAI,CAAC,CAAC,KAAK,KAAK,CACjE;;;;;;;;;;AA8BA,MAAa,QAYT,SAAS,KAAK,IAAI,MAAY,OAAkB,MAAiB,YACnE,YAAY,IAAI,CAAC,CAAC,MAAM,OAAO,MAAM,SAAS,OAAO,CAAC,CACxD"}
|
package/dist/Text.d.mts
ADDED
package/dist/Text.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { t as __exportAll } from "./internal/rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { n as functionsOf, r as isPage } from "./internal/functions-jBOs6GKv.mjs";
|
|
3
|
+
import { Function, Schema } from "effect";
|
|
4
|
+
//#region src/Text.ts
|
|
5
|
+
/**
|
|
6
|
+
* What a page shows as text: a line per block, with table cells apart by tabs, read from the
|
|
7
|
+
* viewport or from one element whole.
|
|
8
|
+
*
|
|
9
|
+
* @stability stable
|
|
10
|
+
* @since 0.3.0
|
|
11
|
+
*/
|
|
12
|
+
var Text_exports = /* @__PURE__ */ __exportAll({
|
|
13
|
+
Text: () => Text,
|
|
14
|
+
read: () => read
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* What a page showed as text: a line per block, with table cells apart by tabs.
|
|
18
|
+
*
|
|
19
|
+
* @stability stable
|
|
20
|
+
* @category schemas
|
|
21
|
+
* @since 0.3.0
|
|
22
|
+
*/
|
|
23
|
+
var Text = class extends Schema.Class("effect-browser/Text")({
|
|
24
|
+
url: Schema.String,
|
|
25
|
+
title: Schema.String,
|
|
26
|
+
text: Schema.String,
|
|
27
|
+
/** True when `text` was cut at `maxChars`. */
|
|
28
|
+
truncated: Schema.Boolean,
|
|
29
|
+
/** Host monotonic milliseconds from the browser's captured Effect Clock. */
|
|
30
|
+
at: Schema.Finite
|
|
31
|
+
}) {};
|
|
32
|
+
/**
|
|
33
|
+
* The text the viewport shows, or one element whole, in one call to the page. Field values read
|
|
34
|
+
* `••••` unless `unmask`, and a secret field's always do, as does one that was secret when the
|
|
35
|
+
* library saw it.
|
|
36
|
+
*
|
|
37
|
+
* @stability stable
|
|
38
|
+
* @category constructors
|
|
39
|
+
* @since 0.3.0
|
|
40
|
+
*/
|
|
41
|
+
const read = Function.dual((args) => isPage(args[0]), (page, options) => functionsOf(page).text(options));
|
|
42
|
+
//#endregion
|
|
43
|
+
export { Text, read, Text_exports as t };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=Text.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.mjs","names":[],"sources":["../src/Text.ts"],"sourcesContent":["/**\n * What a page shows as text: a line per block, with table cells apart by tabs, read from the\n * viewport or from one element whole.\n *\n * @stability stable\n * @since 0.3.0\n */\nimport { type Effect, Function, Schema } from \"effect\";\n\nimport type { BrowserError } from \"./BrowserError.ts\";\nimport { functionsOf, isPage } from \"./internal/page/functions.ts\";\nimport type { Page } from \"./Page.ts\";\n\n/**\n * @stability stable\n * @category options\n * @since 0.3.0\n */\nexport interface TextOptions {\n /** `\"viewport\"` (the default) reads what the viewport shows; a ref reads that element whole. */\n readonly scope?: string | undefined;\n /** Bound on the text's length, cut at a line. Defaults to 12,000 characters. */\n readonly maxChars?: number | undefined;\n /** Show what fields hold; a secret field still reads `••••`. Defaults to false. */\n readonly unmask?: boolean | undefined;\n}\n\n/**\n * What a page showed as text: a line per block, with table cells apart by tabs.\n *\n * @stability stable\n * @category schemas\n * @since 0.3.0\n */\nexport class Text extends Schema.Class<Text>(\"effect-browser/Text\")({\n url: Schema.String,\n title: Schema.String,\n text: Schema.String,\n /** True when `text` was cut at `maxChars`. */\n truncated: Schema.Boolean,\n /** Host monotonic milliseconds from the browser's captured Effect Clock. */\n at: Schema.Finite,\n}) {}\n\n/**\n * The text the viewport shows, or one element whole, in one call to the page. Field values read\n * `••••` unless `unmask`, and a secret field's always do, as does one that was secret when the\n * library saw it.\n *\n * @stability stable\n * @category constructors\n * @since 0.3.0\n */\nexport const read: {\n (options?: TextOptions): (page: Page) => Effect.Effect<Text, BrowserError>;\n (page: Page, options?: TextOptions): Effect.Effect<Text, BrowserError>;\n} = Function.dual(\n (args) => isPage(args[0]),\n (page: Page, options?: TextOptions) => functionsOf(page).text(options),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,OAAb,cAA0B,OAAO,MAAY,qBAAqB,CAAC,CAAC;CAClE,KAAK,OAAO;CACZ,OAAO,OAAO;CACd,MAAM,OAAO;;CAEb,WAAW,OAAO;;CAElB,IAAI,OAAO;AACb,CAAC,CAAC,CAAC,CAAC;;;;;;;;;;AAWJ,MAAa,OAGT,SAAS,MACV,SAAS,OAAO,KAAK,EAAE,IACvB,MAAY,YAA0B,YAAY,IAAI,CAAC,CAAC,KAAK,OAAO,CACvE"}
|