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/testing/index.mjs
CHANGED
|
@@ -1,521 +1,6 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { c as State, g as make$4, l as Text, r as Found, s as ResolvedTarget } from "../Page-BaAOshxo.mjs";
|
|
8
|
-
import { Control, Snapshot } from "../Snapshot.mjs";
|
|
9
|
-
import { checked, methods } from "../ActionPort.mjs";
|
|
10
|
-
import { monotonicMillis } from "../Clock.mjs";
|
|
11
|
-
import { a as make$5, o as make$6, r as Suspension } from "../Browser-CAQFhTkM.mjs";
|
|
12
|
-
import { match, request } from "../Matching.mjs";
|
|
13
|
-
import { l as fold } from "../pose.inpage-CLq7Mfdr.mjs";
|
|
14
|
-
import { Change, Changes } from "../Change.mjs";
|
|
15
|
-
import { Clock, Deferred, Duration, Effect, Exit, Option, PubSub, Scope, Semaphore, Stream } from "effect";
|
|
16
|
-
//#region src/testing/model.ts
|
|
17
|
-
/** Seeded structure, without a DOM, layout engine, page scripts or inferred browser effects. */
|
|
18
|
-
var model_exports = /* @__PURE__ */ __exportAll({
|
|
19
|
-
make: () => make$3,
|
|
20
|
-
unsupported: () => unsupported$1
|
|
21
|
-
});
|
|
22
|
-
/** Unsupported browser mechanics stay typed failures instead of inferred successes. */
|
|
23
|
-
const unsupported$1 = (operation) => Effect.fail(undispatched(operation, new InvalidRequest({ detail: "TestPage requires explicit data; browser mechanics are not simulated" })));
|
|
24
|
-
const make$3 = (seed, closedBy) => {
|
|
25
|
-
let current = {
|
|
26
|
-
...seed,
|
|
27
|
-
url: redact(seed.url ?? "about:blank")
|
|
28
|
-
};
|
|
29
|
-
let document = 0;
|
|
30
|
-
let next = 0;
|
|
31
|
-
let life = "Open";
|
|
32
|
-
const refs = /* @__PURE__ */ new Map();
|
|
33
|
-
const matching = match();
|
|
34
|
-
const ref = (element) => {
|
|
35
|
-
const existing = refs.get(element.key);
|
|
36
|
-
if (existing !== void 0) return existing;
|
|
37
|
-
const added = `e${++next}`;
|
|
38
|
-
refs.set(element.key, added);
|
|
39
|
-
return added;
|
|
40
|
-
};
|
|
41
|
-
const check = (operation) => Effect.suspend(() => life === "Open" && closedBy?.() === void 0 ? Effect.void : Effect.fail(undispatched(operation, new Closed({ cause: closedBy?.() ?? "page" }))));
|
|
42
|
-
const find = (query = {}) => {
|
|
43
|
-
const asked = request(query, "viewport");
|
|
44
|
-
const matches = matching.compile(asked);
|
|
45
|
-
return (current.elements ?? []).filter((element) => element.visible !== false && (asked.scope === "document" || element.inViewport !== false) && (asked.state !== "enabled" || !element.state?.disabled) && (query.at === void 0 || query.at.x >= element.box.x && query.at.x <= element.box.x + element.box.width && query.at.y >= element.box.y && query.at.y <= element.box.y + element.box.height) && matches({
|
|
46
|
-
role: element.subject.role,
|
|
47
|
-
name: () => element.subject.name,
|
|
48
|
-
text: () => element.text ?? element.subject.name,
|
|
49
|
-
context: () => element.subject.context
|
|
50
|
-
})).map((element) => new Found({
|
|
51
|
-
ref: ref(element),
|
|
52
|
-
subject: element.subject,
|
|
53
|
-
box: element.box,
|
|
54
|
-
inViewport: element.inViewport !== false,
|
|
55
|
-
state: {
|
|
56
|
-
disabled: false,
|
|
57
|
-
focused: false,
|
|
58
|
-
...element.state
|
|
59
|
-
}
|
|
60
|
-
}));
|
|
61
|
-
};
|
|
62
|
-
const resolve = (target) => Effect.suspend(() => {
|
|
63
|
-
const element = (current.elements ?? []).find((element) => typeof target === "string" ? refs.get(element.key) === target : target.x >= element.box.x && target.x <= element.box.x + element.box.width && target.y >= element.box.y && target.y <= element.box.y + element.box.height);
|
|
64
|
-
return element === void 0 ? Effect.fail(undispatched("input", typeof target === "string" ? new StaleRef({ ref: target }) : new InvalidRequest({ detail: "the seeded point has no element" }))) : Effect.succeed({
|
|
65
|
-
element,
|
|
66
|
-
ref: ref(element),
|
|
67
|
-
subject: element.subject
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
const snapshot = (options = {}) => {
|
|
71
|
-
const elements = (current.elements ?? []).filter((element) => element.visible !== false && (options.full || element.inViewport !== false));
|
|
72
|
-
const controls = elements.map((element) => new Control({
|
|
73
|
-
ref: ref(element),
|
|
74
|
-
kind: element.subject.role ?? "clickable",
|
|
75
|
-
name: element.subject.name,
|
|
76
|
-
value: element.secret ? "••••" : element.value ?? "",
|
|
77
|
-
disabled: element.state?.disabled,
|
|
78
|
-
checked: element.state?.checked,
|
|
79
|
-
editable: element.editable
|
|
80
|
-
}));
|
|
81
|
-
const text = elements.map((element) => element.text ?? element.subject.name).filter((text) => options.query === void 0 || matching.normalize(text).includes(matching.normalize(options.query))).join("\n");
|
|
82
|
-
const viewport = current.viewport ?? {
|
|
83
|
-
width: 800,
|
|
84
|
-
height: 600
|
|
85
|
-
};
|
|
86
|
-
return new Snapshot({
|
|
87
|
-
url: current.url ?? "about:blank",
|
|
88
|
-
title: current.title ?? "",
|
|
89
|
-
text: text.slice(0, options.maxChars ?? 12e3),
|
|
90
|
-
truncated: text.length > (options.maxChars ?? 12e3),
|
|
91
|
-
above: 0,
|
|
92
|
-
below: 0,
|
|
93
|
-
viewport,
|
|
94
|
-
scroll: {
|
|
95
|
-
y: 0,
|
|
96
|
-
height: viewport.height
|
|
97
|
-
},
|
|
98
|
-
controls
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
return {
|
|
102
|
-
find,
|
|
103
|
-
resolve,
|
|
104
|
-
snapshot,
|
|
105
|
-
mark: (found) => matching.mark(found.map((one) => {
|
|
106
|
-
const element = current.elements?.find((element) => refs.get(element.key) === one.ref);
|
|
107
|
-
const { focused: _focused, ...state } = one.state;
|
|
108
|
-
return `${element?.text ?? element?.subject.name ?? ""}\u0000${element?.value ?? ""}\u0000${JSON.stringify(state)}\u0001`;
|
|
109
|
-
})),
|
|
110
|
-
check,
|
|
111
|
-
get: () => current,
|
|
112
|
-
document: () => document,
|
|
113
|
-
update: (seed, replace = false) => {
|
|
114
|
-
current = {
|
|
115
|
-
...replace ? seed : {
|
|
116
|
-
...current,
|
|
117
|
-
...seed
|
|
118
|
-
},
|
|
119
|
-
url: redact(seed.url ?? (replace ? "about:blank" : current.url))
|
|
120
|
-
};
|
|
121
|
-
if (replace) {
|
|
122
|
-
document += 1;
|
|
123
|
-
refs.clear();
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
isClosed: () => life === "Closed" || closedBy?.() !== void 0,
|
|
127
|
-
close: () => {
|
|
128
|
-
const wasOpen = life === "Open";
|
|
129
|
-
life = "Closed";
|
|
130
|
-
return wasOpen;
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
};
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region src/testing/evidence.ts
|
|
136
|
-
/** Explicit picture and change evidence; bounded delivery and the production change fold. */
|
|
137
|
-
const make$2 = Effect.fnUntraced(function* (options) {
|
|
138
|
-
const { model, now } = options;
|
|
139
|
-
const { unsupported } = model_exports;
|
|
140
|
-
const feed = yield* PubSub.sliding(64);
|
|
141
|
-
let frames = [];
|
|
142
|
-
const folding = fold();
|
|
143
|
-
const owned = (frame) => frame.page === options.id && frame.connection === options.connection && frame.session === options.session;
|
|
144
|
-
const inDocument = (frame) => !model.isClosed() && owned(frame) && frame.document === model.document();
|
|
145
|
-
const isCurrent = (frame) => inDocument(frame) && sameCapture(frame, frames.findLast(inDocument));
|
|
146
|
-
const emitFrame = (frame) => Effect.gen(function* () {
|
|
147
|
-
yield* model.check("emitFrame");
|
|
148
|
-
if (!owned(frame) || frame.document > model.document()) return yield* undispatched("emitFrame", new InvalidRequest({ detail: "the frame belongs to another page, connection or future document" }));
|
|
149
|
-
frames = [...frames.slice(-255), frame];
|
|
150
|
-
yield* PubSub.publish(feed, [frame]);
|
|
151
|
-
});
|
|
152
|
-
const frame = (asked) => Effect.suspend(() => {
|
|
153
|
-
if (asked?.after !== void 0) return unsupported("frame:after");
|
|
154
|
-
const age = Duration.fromInput(asked?.maxAge ?? Duration.millis(250));
|
|
155
|
-
const found = frames.findLast((frame) => isCurrent(frame) && Option.isSome(age) && now() - (frame.hostTime - frame.timing.uncertaintyMillis) <= Duration.toMillis(age.value));
|
|
156
|
-
return found === void 0 ? Effect.fail(undispatched("frame", new NotFound({ target: "a current seeded frame" }))) : Effect.as(model.check("frame"), found);
|
|
157
|
-
});
|
|
158
|
-
const changes = (asked) => Effect.gen(function* () {
|
|
159
|
-
yield* model.check("changes");
|
|
160
|
-
const start = asked?.since;
|
|
161
|
-
const since = typeof start === "number" ? start : start === void 0 ? 0 : "cursor" in start ? start.cursor : start.hostTime;
|
|
162
|
-
const until = Math.min(now(), typeof asked?.until === "number" ? asked.until : asked?.until?.hostTime ?? now());
|
|
163
|
-
if (!Number.isFinite(since) || !Number.isFinite(until)) return yield* undispatched("changes", new InvalidRequest({ detail: "change bounds must be finite" }));
|
|
164
|
-
const changes = (model.get().changes ?? []).flatMap((record) => {
|
|
165
|
-
const over = folding.over({
|
|
166
|
-
...record,
|
|
167
|
-
key: record,
|
|
168
|
-
samples: [...record.samples]
|
|
169
|
-
}, since, until);
|
|
170
|
-
if (over === void 0) return [];
|
|
171
|
-
const hidden = record.secret || record.kind === "value" && !asked?.unmask;
|
|
172
|
-
return [new Change({
|
|
173
|
-
...over,
|
|
174
|
-
subject: record.subject,
|
|
175
|
-
before: hidden && over.before !== void 0 ? "••••" : over.before,
|
|
176
|
-
after: hidden && over.after !== void 0 ? "••••" : over.after
|
|
177
|
-
})];
|
|
178
|
-
});
|
|
179
|
-
return new Changes({
|
|
180
|
-
document: model.document(),
|
|
181
|
-
from: since,
|
|
182
|
-
until,
|
|
183
|
-
cursor: until,
|
|
184
|
-
dropped: 0,
|
|
185
|
-
changes
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
const capture = (asked) => asked?.quality === void 0 && asked?.size === void 0 ? Effect.gen(function* () {
|
|
189
|
-
yield* model.check("capture");
|
|
190
|
-
const subscription = yield* PubSub.subscribe(feed);
|
|
191
|
-
return {
|
|
192
|
-
stream: Stream.fromEffectRepeat(PubSub.take(subscription)).pipe(Stream.flattenTake),
|
|
193
|
-
get current() {
|
|
194
|
-
return frames.findLast(inDocument);
|
|
195
|
-
},
|
|
196
|
-
isCurrent,
|
|
197
|
-
confirm: (frame) => Effect.as(model.check("confirm"), isCurrent(frame)),
|
|
198
|
-
sync: model.check("sync"),
|
|
199
|
-
stats: () => unsupported("captureStats")
|
|
200
|
-
};
|
|
201
|
-
}) : unsupported("capture:options");
|
|
202
|
-
for (const frame of model.get().frames ?? []) yield* emitFrame(frame);
|
|
203
|
-
yield* Effect.addFinalizer(() => PubSub.shutdown(feed));
|
|
204
|
-
return {
|
|
205
|
-
frame,
|
|
206
|
-
changes,
|
|
207
|
-
capture,
|
|
208
|
-
emitFrame,
|
|
209
|
-
recentFrames: Effect.sync(() => frames),
|
|
210
|
-
close: Effect.flatMap(Effect.exit(model.check("capture")), (end) => PubSub.publish(feed, end)).pipe(Effect.asVoid)
|
|
211
|
-
};
|
|
212
|
-
});
|
|
213
|
-
//#endregion
|
|
214
|
-
//#region src/testing/page.ts
|
|
215
|
-
/** A scoped, seeded Page for deterministic stories. Effects are explicit data, never page code. */
|
|
216
|
-
const { unsupported } = model_exports;
|
|
217
|
-
const execution = (model, lane, now, id, timeline, gate) => {
|
|
218
|
-
const outcomes = [];
|
|
219
|
-
const actions = [];
|
|
220
|
-
const perform = (action) => {
|
|
221
|
-
const operation = nameOf(action);
|
|
222
|
-
return lane.write(operation, Duration.seconds(10))(Effect.suspend(() => {
|
|
223
|
-
const startedAt = now();
|
|
224
|
-
let dispatched = false;
|
|
225
|
-
let subject;
|
|
226
|
-
let safe = recorded(action, action._tag !== "Type");
|
|
227
|
-
return Effect.gen(function* () {
|
|
228
|
-
yield* model.check(operation);
|
|
229
|
-
if (action._tag === "Act" || (action._tag === "Back" || action._tag === "Select") && outcomes[0] === void 0) return yield* unsupported(operation);
|
|
230
|
-
const target = targetOf(action);
|
|
231
|
-
const resolved = target === void 0 ? void 0 : yield* model.resolve(target);
|
|
232
|
-
subject = resolved?.subject;
|
|
233
|
-
safe = recorded(action, !(action._tag === "Type" && (action.options?.secret || resolved?.element.secret)));
|
|
234
|
-
if (resolved?.element.state?.disabled || resolved?.element.visible === false || action._tag === "Type" && resolved !== void 0 && (!resolved.element.editable || action.options?.secret && !resolved.element.secret)) return yield* undispatched(operation, new NotActionable({ detail: "the seeded element cannot take this input" }));
|
|
235
|
-
if (action._tag === "Drag") yield* model.resolve(action.to);
|
|
236
|
-
return yield* Effect.acquireUseRelease(gate === void 0 ? Effect.succeed(() => {}) : gate.enter(operation), () => Effect.gen(function* () {
|
|
237
|
-
const outcome = outcomes.shift();
|
|
238
|
-
dispatched = true;
|
|
239
|
-
const value = outcome === void 0 ? void 0 : yield* outcome.pipe(Effect.tapError((error) => Effect.sync(() => {
|
|
240
|
-
dispatched = error.dispatched;
|
|
241
|
-
})));
|
|
242
|
-
if (action._tag === "Goto" || action._tag === "Reload") {
|
|
243
|
-
model.update({
|
|
244
|
-
...model.get(),
|
|
245
|
-
url: action._tag === "Goto" ? redact(action.url) : model.get().url
|
|
246
|
-
}, true);
|
|
247
|
-
timeline.publish(new Navigated({
|
|
248
|
-
at: now(),
|
|
249
|
-
page: id,
|
|
250
|
-
url: model.get().url ?? "about:blank",
|
|
251
|
-
document: model.document(),
|
|
252
|
-
sameDocument: false
|
|
253
|
-
}));
|
|
254
|
-
}
|
|
255
|
-
if (action._tag === "Click" && resolved !== void 0) return new ResolvedTarget({
|
|
256
|
-
...resolved.subject,
|
|
257
|
-
element: resolved.ref,
|
|
258
|
-
point: typeof target === "object" ? target : {
|
|
259
|
-
x: resolved.element.box.x + resolved.element.box.width / 2,
|
|
260
|
-
y: resolved.element.box.y + resolved.element.box.height / 2
|
|
261
|
-
},
|
|
262
|
-
cursor: "pointer",
|
|
263
|
-
box: resolved.element.box
|
|
264
|
-
});
|
|
265
|
-
return value;
|
|
266
|
-
}), (leave) => Effect.sync(leave));
|
|
267
|
-
}).pipe(Effect.onExit((exit) => Effect.sync(() => {
|
|
268
|
-
if (dispatched) actions.push(safe);
|
|
269
|
-
timeline.publish(new Action({
|
|
270
|
-
at: now(),
|
|
271
|
-
startedAt,
|
|
272
|
-
page: id,
|
|
273
|
-
name: operation,
|
|
274
|
-
value: safe,
|
|
275
|
-
url: redact(model.get().url ?? "about:blank"),
|
|
276
|
-
subject,
|
|
277
|
-
ok: Exit.isSuccess(exit),
|
|
278
|
-
dispatched,
|
|
279
|
-
error: Exit.isFailure(exit) ? "failed" : void 0
|
|
280
|
-
}));
|
|
281
|
-
})));
|
|
282
|
-
}));
|
|
283
|
-
};
|
|
284
|
-
return {
|
|
285
|
-
perform,
|
|
286
|
-
succeedNext: (value) => Effect.sync(() => {
|
|
287
|
-
outcomes.push(Effect.succeed(value));
|
|
288
|
-
}),
|
|
289
|
-
actions: Effect.sync(() => [...actions]),
|
|
290
|
-
failNext: (error) => Effect.sync(() => {
|
|
291
|
-
outcomes.push(Effect.fail(error));
|
|
292
|
-
}),
|
|
293
|
-
holdNext: () => Effect.sync(() => {
|
|
294
|
-
const entered = Deferred.makeUnsafe();
|
|
295
|
-
const release = Deferred.makeUnsafe();
|
|
296
|
-
outcomes.push(Effect.andThen(Deferred.succeed(entered, void 0), Deferred.await(release)));
|
|
297
|
-
return {
|
|
298
|
-
entered: Deferred.await(entered),
|
|
299
|
-
release: Deferred.succeed(release, void 0)
|
|
300
|
-
};
|
|
301
|
-
})
|
|
302
|
-
};
|
|
303
|
-
};
|
|
304
|
-
/** Wait admission follows preceding input, then releases the lane while observing new evidence. */
|
|
305
|
-
const untilFor = (model, lane, now) => (query, want, millis) => lane.read("until")(Effect.void).pipe(Effect.andThen(Effect.gen(function* () {
|
|
306
|
-
if (query.selector !== void 0) return yield* unsupported("until:selector");
|
|
307
|
-
if (!Number.isFinite(millis) || millis < 0) return yield* unsupported("until");
|
|
308
|
-
const deadline = now() + millis;
|
|
309
|
-
while (true) {
|
|
310
|
-
yield* model.check("until");
|
|
311
|
-
const found = model.find({
|
|
312
|
-
...query,
|
|
313
|
-
scope: query.scope ?? "document"
|
|
314
|
-
});
|
|
315
|
-
const mark = model.mark(found);
|
|
316
|
-
const met = want === "some" ? found.length > 0 : want === "none" ? found.length === 0 : mark !== want.other;
|
|
317
|
-
if (met || now() >= deadline) return {
|
|
318
|
-
met,
|
|
319
|
-
mark
|
|
320
|
-
};
|
|
321
|
-
yield* Effect.sleep(Duration.millis(Math.min(50, deadline - now())));
|
|
322
|
-
}
|
|
323
|
-
})));
|
|
324
|
-
const makeIn = Effect.fnUntraced(function* (seed = {}, options = {}) {
|
|
325
|
-
const clock = yield* Clock.Clock;
|
|
326
|
-
const scope = yield* Scope.Scope;
|
|
327
|
-
const now = () => monotonicMillis(clock);
|
|
328
|
-
const id = options.id ?? "test-page";
|
|
329
|
-
const connection = options.connection ?? "test-connection";
|
|
330
|
-
const model = make$3(seed, options.closedBy);
|
|
331
|
-
const timeline = options.timeline ?? make$5(4096);
|
|
332
|
-
const lane = make$4({
|
|
333
|
-
now,
|
|
334
|
-
actionTimeout: Duration.seconds(10),
|
|
335
|
-
documentAt: model.document,
|
|
336
|
-
scope,
|
|
337
|
-
gone: (operation) => undispatched(operation, new Closed({ cause: "page" })),
|
|
338
|
-
beforeWrite: options.gate?.check,
|
|
339
|
-
refusal: options.gate?.refused
|
|
340
|
-
});
|
|
341
|
-
const evidence = yield* make$2({
|
|
342
|
-
id,
|
|
343
|
-
connection,
|
|
344
|
-
session: options.session ?? "test-browser",
|
|
345
|
-
now,
|
|
346
|
-
model
|
|
347
|
-
});
|
|
348
|
-
if (options.disconnected !== void 0) yield* options.disconnected.pipe(Effect.andThen(evidence.close), Effect.forkIn(scope));
|
|
349
|
-
const run = execution(model, lane, now, id, timeline, options.gate);
|
|
350
|
-
const own = (effect) => Effect.provideService(effect, Clock.Clock, clock);
|
|
351
|
-
const read = (operation, work) => own(lane.read(operation)(Effect.andThen(model.check(operation), Effect.sync(work))));
|
|
352
|
-
const perform = checked((action) => own(run.perform(action)));
|
|
353
|
-
const page = {
|
|
354
|
-
...methods(perform),
|
|
355
|
-
id,
|
|
356
|
-
clock,
|
|
357
|
-
perform,
|
|
358
|
-
until: (query, want, millis) => own(untilFor(model, lane, now)(query, want, millis)),
|
|
359
|
-
afterInput: (effect) => own(lane.read("afterInput")(effect)),
|
|
360
|
-
read: () => unsupported("read"),
|
|
361
|
-
act: () => unsupported("act"),
|
|
362
|
-
url: Effect.sync(() => redact(model.get().url ?? "about:blank")),
|
|
363
|
-
title: read("title", () => model.get().title ?? ""),
|
|
364
|
-
bringToFront: model.check("bringToFront"),
|
|
365
|
-
close: Effect.andThen(Effect.sync(() => {
|
|
366
|
-
if (model.close()) timeline.publish(new PageClosed({
|
|
367
|
-
at: now(),
|
|
368
|
-
page: id,
|
|
369
|
-
cause: "page"
|
|
370
|
-
}));
|
|
371
|
-
}), evidence.close),
|
|
372
|
-
find: (query) => query?.selector !== void 0 ? unsupported("find:selector") : read("find", () => model.find(query)),
|
|
373
|
-
snapshot: (options) => options?.within !== void 0 ? unsupported("snapshot:within") : read("snapshot", () => model.snapshot(options)),
|
|
374
|
-
text: (options) => options?.scope !== void 0 && options.scope !== "viewport" ? unsupported("text:scope") : read("text", () => {
|
|
375
|
-
const snapshot = model.snapshot({ maxChars: options?.maxChars });
|
|
376
|
-
return new Text({
|
|
377
|
-
url: snapshot.url,
|
|
378
|
-
title: snapshot.title,
|
|
379
|
-
text: snapshot.text,
|
|
380
|
-
truncated: snapshot.truncated,
|
|
381
|
-
at: now()
|
|
382
|
-
});
|
|
383
|
-
}),
|
|
384
|
-
viewport: read("viewport", () => model.get().viewport ?? {
|
|
385
|
-
width: 800,
|
|
386
|
-
height: 600
|
|
387
|
-
}),
|
|
388
|
-
state: Effect.sync(() => new State({
|
|
389
|
-
page: id,
|
|
390
|
-
connection,
|
|
391
|
-
at: now(),
|
|
392
|
-
document: model.document(),
|
|
393
|
-
url: redact(model.get().url ?? "about:blank")
|
|
394
|
-
})),
|
|
395
|
-
screenshot: (options) => options === void 0 ? Effect.map(evidence.frame(), (frame) => frame.image) : unsupported("screenshot"),
|
|
396
|
-
frame: evidence.frame,
|
|
397
|
-
zoom: () => unsupported("zoom"),
|
|
398
|
-
layout: () => unsupported("layout"),
|
|
399
|
-
overlay: unsupported("overlay"),
|
|
400
|
-
poses: unsupported("poses"),
|
|
401
|
-
hold: unsupported("hold"),
|
|
402
|
-
paint: () => unsupported("paint"),
|
|
403
|
-
ready: () => model.get().ready === true ? read("ready", () => void 0) : unsupported("ready"),
|
|
404
|
-
capture: evidence.capture,
|
|
405
|
-
screencast: (options) => Stream.unwrap(Effect.map(evidence.capture(options), (capture) => capture.stream)),
|
|
406
|
-
captureStats: () => unsupported("captureStats"),
|
|
407
|
-
recentFrames: evidence.recentFrames,
|
|
408
|
-
changes: evidence.changes,
|
|
409
|
-
window: () => unsupported("window"),
|
|
410
|
-
recentEvents: Effect.map(timeline.recent, (records) => records.filter((record) => "page" in record.event && record.event.page === id).map((record) => record.event))
|
|
411
|
-
};
|
|
412
|
-
yield* Effect.addFinalizer(() => Effect.sync(() => {
|
|
413
|
-
model.close();
|
|
414
|
-
}));
|
|
415
|
-
return {
|
|
416
|
-
page,
|
|
417
|
-
emitFrame: evidence.emitFrame,
|
|
418
|
-
event: (event) => Effect.sync(() => {
|
|
419
|
-
timeline.publish(event);
|
|
420
|
-
}),
|
|
421
|
-
succeedNext: run.succeedNext,
|
|
422
|
-
isClosed: Effect.sync(model.isClosed),
|
|
423
|
-
actions: run.actions,
|
|
424
|
-
holdNext: run.holdNext,
|
|
425
|
-
failNext: run.failNext,
|
|
426
|
-
update: (seed) => Effect.sync(() => model.update(seed)),
|
|
427
|
-
document: (seed) => Effect.sync(() => model.update(seed, true))
|
|
428
|
-
};
|
|
429
|
-
});
|
|
430
|
-
//#endregion
|
|
431
|
-
//#region src/testing/TestBrowser.ts
|
|
432
|
-
/** A seeded browser whose pages use the production lane, suspension gate and event timeline. */
|
|
433
|
-
var TestBrowser_exports = /* @__PURE__ */ __exportAll({ make: () => make$1 });
|
|
434
|
-
const make$1 = Effect.fnUntraced(function* (seeds = [], options = {}) {
|
|
435
|
-
const clock = yield* Clock.Clock;
|
|
436
|
-
const scope = yield* Scope.Scope;
|
|
437
|
-
const id = options.id ?? "test-browser";
|
|
438
|
-
const connection = options.connection ?? "test-connection";
|
|
439
|
-
const capacity = options.eventHistory ?? 4096;
|
|
440
|
-
if (!Number.isSafeInteger(capacity) || capacity < 1) return yield* undispatched("make", new InvalidRequest({ detail: "eventHistory must be a positive safe integer" }));
|
|
441
|
-
const timeline = make$5(capacity);
|
|
442
|
-
const lost = Deferred.makeUnsafe();
|
|
443
|
-
const now = () => monotonicMillis(clock);
|
|
444
|
-
let closedBy;
|
|
445
|
-
let next = 0;
|
|
446
|
-
const tracked = [];
|
|
447
|
-
const gate = make$6({
|
|
448
|
-
now,
|
|
449
|
-
sequence: timeline.sequence,
|
|
450
|
-
closedBy: () => closedBy,
|
|
451
|
-
lost: Deferred.await(lost),
|
|
452
|
-
clock,
|
|
453
|
-
drain: Duration.seconds(10)
|
|
454
|
-
});
|
|
455
|
-
const add = Effect.fnUntraced(function* (seed = {}) {
|
|
456
|
-
if (closedBy !== void 0) return yield* undispatched("newPage", new Closed({ cause: closedBy }));
|
|
457
|
-
const test = yield* makeIn(seed, {
|
|
458
|
-
id: `${id}-page-${++next}`,
|
|
459
|
-
connection,
|
|
460
|
-
session: id,
|
|
461
|
-
gate,
|
|
462
|
-
timeline,
|
|
463
|
-
closedBy: () => closedBy,
|
|
464
|
-
disconnected: Deferred.await(lost)
|
|
465
|
-
}).pipe(Effect.provideService(Scope.Scope, scope));
|
|
466
|
-
tracked.push(test);
|
|
467
|
-
timeline.publish(new PageOpened({
|
|
468
|
-
at: now(),
|
|
469
|
-
page: test.page.id,
|
|
470
|
-
url: yield* test.page.url
|
|
471
|
-
}));
|
|
472
|
-
return test;
|
|
473
|
-
});
|
|
474
|
-
const pages = Effect.gen(function* () {
|
|
475
|
-
const pages = [];
|
|
476
|
-
for (const test of tracked) if (!(yield* test.isClosed)) pages.push(test.page);
|
|
477
|
-
return pages;
|
|
478
|
-
});
|
|
479
|
-
const firstPageLock = Semaphore.makeUnsafe(1);
|
|
480
|
-
const disconnect = (cause = "connection") => Effect.sync(() => {
|
|
481
|
-
if (closedBy !== void 0) return;
|
|
482
|
-
closedBy = cause;
|
|
483
|
-
timeline.publish(new Disconnected({
|
|
484
|
-
at: now(),
|
|
485
|
-
cause
|
|
486
|
-
}));
|
|
487
|
-
Deferred.doneUnsafe(lost, Effect.succeed(cause));
|
|
488
|
-
});
|
|
489
|
-
const browser = {
|
|
490
|
-
id,
|
|
491
|
-
connection,
|
|
492
|
-
provider: "test",
|
|
493
|
-
expiresAt: void 0,
|
|
494
|
-
now: Effect.sync(now),
|
|
495
|
-
suspend: (options) => Effect.map(gate.suspend(options?.drain), (stopped) => new Suspension(stopped)),
|
|
496
|
-
pages,
|
|
497
|
-
page: (id) => Effect.map(pages, (pages) => Option.fromUndefinedOr(pages.find((page) => page.id === id))),
|
|
498
|
-
firstPage: firstPageLock.withPermits(1)(Effect.flatMap(pages, (pages) => pages[0] === void 0 ? Effect.map(add(), (test) => test.page) : Effect.succeed(pages[0]))),
|
|
499
|
-
newPage: (url) => Effect.map(add({ url }), (test) => test.page),
|
|
500
|
-
hasCookie: () => unsupported$1("hasCookie"),
|
|
501
|
-
disconnected: Deferred.await(lost),
|
|
502
|
-
events: (options) => timeline.stream(options?.after),
|
|
503
|
-
recentEvents: Effect.map(timeline.recent, (records) => records.map((record) => record.event))
|
|
504
|
-
};
|
|
505
|
-
for (const seed of seeds) yield* add(seed);
|
|
506
|
-
yield* Effect.addFinalizer(() => Effect.andThen(disconnect("released"), timeline.close));
|
|
507
|
-
return {
|
|
508
|
-
browser,
|
|
509
|
-
add,
|
|
510
|
-
disconnect,
|
|
511
|
-
pages: Effect.sync(() => [...tracked])
|
|
512
|
-
};
|
|
513
|
-
});
|
|
514
|
-
//#endregion
|
|
515
|
-
//#region src/testing/TestPage.ts
|
|
516
|
-
var TestPage_exports = /* @__PURE__ */ __exportAll({ make: () => make });
|
|
517
|
-
const make = (seed = {}, options = {}) => makeIn(seed, options);
|
|
518
|
-
//#endregion
|
|
519
|
-
export { TestBrowser_exports as TestBrowser, TestPage_exports as TestPage };
|
|
520
|
-
|
|
521
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import { t as TestModel_exports } from "./TestModel.mjs";
|
|
2
|
+
import { t as HttpCassette_exports } from "./HttpCassette.mjs";
|
|
3
|
+
import { t as Story_exports } from "./Story.mjs";
|
|
4
|
+
import { t as TestBrowser_exports } from "./TestBrowser.mjs";
|
|
5
|
+
import { t as TestPage_exports } from "./TestPage.mjs";
|
|
6
|
+
export { HttpCassette_exports as HttpCassette, Story_exports as Story, TestBrowser_exports as TestBrowser, TestModel_exports as TestModel, TestPage_exports as TestPage };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { x as Window } from "../internal/Page-BfGxn7oN.mjs";
|
|
2
|
+
import { a as account, c as describe, n as Moment, o as read, r as MomentOptions, s as toPrompt, t as Account } from "../internal/Moment-DOcldBdf.mjs";
|
|
3
|
+
export { Account, Moment, MomentOptions, Window, account, describe as describeChange, read, toPrompt };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { t as BrowserError } from "../internal/BrowserError-CsuRYcDX.mjs";
|
|
2
|
+
import { o as Page } from "../internal/Page-BfGxn7oN.mjs";
|
|
3
|
+
import { Duration, Effect } from "effect";
|
|
4
|
+
declare namespace Stillness_d_exports {
|
|
5
|
+
export { Options, wait };
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @stability stable
|
|
9
|
+
* @category options
|
|
10
|
+
* @since 0.3.0
|
|
11
|
+
*/
|
|
12
|
+
export interface Options {
|
|
13
|
+
readonly still?: "screen" | "content" | "foreground" | undefined;
|
|
14
|
+
/** How long the screen, or the content, must stay still. */
|
|
15
|
+
readonly quiet: Duration.Input;
|
|
16
|
+
/** Defaults to 15 seconds. */
|
|
17
|
+
readonly timeout?: Duration.Input | undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Wait for a ready page to stay still for `quiet`: its screen, by default, with no screencast frame
|
|
21
|
+
* coming; its `"foreground"`, allowing motion it showed before its latest input; or its
|
|
22
|
+
* `"content"`, with no visible change recorded. Fails `Timeout` after `timeout`.
|
|
23
|
+
*
|
|
24
|
+
* @stability stable
|
|
25
|
+
* @category combinators
|
|
26
|
+
* @since 0.3.0
|
|
27
|
+
*/
|
|
28
|
+
export declare const wait: {
|
|
29
|
+
(options: Options): (page: Page) => Effect.Effect<void, BrowserError>;
|
|
30
|
+
(page: Page, options: Options): Effect.Effect<void, BrowserError>;
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { Stillness_d_exports as t };
|
|
34
|
+
//# sourceMappingURL=Stillness.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as Missing, S as Drifted, _ as Uncertain, a as repeatable, b as isReplayErrorReason, c as step, d as Expected, f as Receipt, g as Stopped, h as Step, i as StepOptions, l as locate, m as ReplayErrorReason, n as ReplayOptions, o as replay, p as ReplayError, r as RestoreOptions, s as restore, u as fromEvents, v as Walk, x as Ambiguous, y as isReplayError } from "../internal/Walk-BNXcfZ2z.mjs";
|
|
2
|
+
export { Ambiguous, Drifted, Expected, Missing, Receipt, ReplayError, ReplayErrorReason, type ReplayOptions, type RestoreOptions, Step, type StepOptions, Stopped, Uncertain, Walk, fromEvents, isReplayError, isReplayErrorReason, locate, repeatable, replay, restore, step };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as isReplayErrorReason, a as step, b as Missing, c as Expected, d as ReplayErrorReason, f as Step, g as isReplayError, h as Walk, i as restore, l as Receipt, m as Uncertain, n as repeatable, o as locate, p as Stopped, r as replay, s as fromEvents, u as ReplayError, v as Ambiguous, y as Drifted } from "../internal/Walk-C5ky7uSf.mjs";
|
|
2
|
+
export { Ambiguous, Drifted, Expected, Missing, Receipt, ReplayError, ReplayErrorReason, Step, Stopped, Uncertain, Walk, fromEvents, isReplayError, isReplayErrorReason, locate, repeatable, replay, restore, step };
|