effect-browser 0.3.0-beta.20 → 0.3.0-beta.22
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 +221 -158
- package/dist/Action-24sLOubi.d.mts +110 -0
- package/dist/Action.d.mts +2 -0
- package/dist/Action.mjs +141 -0
- package/dist/Action.mjs.map +1 -0
- package/dist/ActionPort.d.mts +15 -0
- package/dist/ActionPort.mjs +101 -0
- package/dist/ActionPort.mjs.map +1 -0
- package/dist/Browser-Cq2K1FEA.mjs +4075 -0
- package/dist/Browser-Cq2K1FEA.mjs.map +1 -0
- package/dist/Browser-wZhwZSlG.d.mts +167 -0
- package/dist/Browser.d.mts +2 -129
- package/dist/Browser.mjs +1 -1
- package/dist/{BrowserError-Coy7EW1N.d.mts → BrowserError-BlcmLVzn.d.mts} +22 -7
- package/dist/BrowserError.d.mts +2 -2
- package/dist/BrowserError.mjs +46 -9
- package/dist/BrowserError.mjs.map +1 -1
- package/dist/{BrowserEvent-dq6FRT8w.d.mts → BrowserEvent-lLqJ3GJS.d.mts} +93 -37
- package/dist/BrowserEvent.d.mts +2 -2
- package/dist/BrowserEvent.mjs +29 -24
- package/dist/BrowserEvent.mjs.map +1 -1
- package/dist/{Change-DqING3tr.d.mts → Change-Ba7INmay.d.mts} +4 -6
- package/dist/Change.d.mts +2 -2
- package/dist/Change.mjs +97 -2
- package/dist/Change.mjs.map +1 -0
- package/dist/Clock.d.mts +57 -0
- package/dist/Clock.mjs +80 -0
- package/dist/Clock.mjs.map +1 -0
- package/dist/{Frame-DkNdjjjr.d.mts → Frame-UEH2hO5T.d.mts} +10 -3
- package/dist/Frame.d.mts +2 -2
- package/dist/Frame.mjs +10 -2
- package/dist/Frame.mjs.map +1 -1
- package/dist/{Motion-DND6I-64.d.mts → Geometry-DJx9qrYy.d.mts} +7 -10
- package/dist/Geometry.d.mts +2 -0
- package/dist/Geometry.mjs +32 -0
- package/dist/Geometry.mjs.map +1 -0
- package/dist/LICENSE-jpeg-js +28 -0
- package/dist/Matching.d.mts +37 -0
- package/dist/{match.inpage-xOe9LNO0.mjs → Matching.mjs} +28 -4
- package/dist/Matching.mjs.map +1 -0
- package/dist/{Page-CfB6Zn1p.mjs → Page-BF5izr8R.mjs} +216 -31
- package/dist/Page-BF5izr8R.mjs.map +1 -0
- package/dist/{Page-ku6j5t-v.d.mts → Page-CvsOEorc.d.mts} +158 -185
- package/dist/Page.d.mts +2 -2
- package/dist/Page.mjs +1 -1
- package/dist/Released-tURbFmal.d.mts +15 -0
- package/dist/{Snapshot-B34hZ4Jl.d.mts → Snapshot-CtBVOtuu.d.mts} +6 -1
- package/dist/Snapshot.d.mts +1 -1
- package/dist/Snapshot.mjs.map +1 -1
- package/dist/Stillness-CNlvayIo.mjs +136 -0
- package/dist/Stillness-CNlvayIo.mjs.map +1 -0
- package/dist/Style-AO4V7Czt.mjs +357 -0
- package/dist/Style-AO4V7Czt.mjs.map +1 -0
- package/dist/Style.d.mts +72 -0
- package/dist/Style.mjs +2 -0
- package/dist/Url.d.mts +26 -0
- package/dist/Url.mjs +74 -0
- package/dist/Url.mjs.map +1 -0
- package/dist/Window-CMddGMt1.d.mts +34 -0
- package/dist/Window.d.mts +2 -0
- package/dist/Window.mjs +35 -0
- package/dist/Window.mjs.map +1 -0
- package/dist/connection-2KHI4_KN.d.mts +41 -0
- package/dist/connection-BTeO0Hiz.mjs +68 -0
- package/dist/connection-BTeO0Hiz.mjs.map +1 -0
- package/dist/index.d.mts +15 -17
- package/dist/index.mjs +11 -14
- package/dist/moment/Moment.d.mts +86 -0
- package/dist/{Moment.mjs → moment/Moment.mjs} +44 -38
- package/dist/moment/Moment.mjs.map +1 -0
- package/dist/{Plan-DJ4hEEna.d.mts → plan/index.d.mts} +169 -64
- package/dist/{Plan-C-d5QYS8.mjs → plan/index.mjs} +122 -155
- package/dist/plan/index.mjs.map +1 -0
- package/dist/{Policy.d.mts → policy/Policy.d.mts} +5 -9
- package/dist/{Policy.mjs → policy/Policy.mjs} +11 -21
- package/dist/policy/Policy.mjs.map +1 -0
- package/dist/presentation/Motion.d.mts +12 -0
- package/dist/{Motion.mjs → presentation/Motion.mjs} +4 -27
- package/dist/presentation/Motion.mjs.map +1 -0
- package/dist/presentation/Presentation.d.mts +30 -0
- package/dist/presentation/Presentation.mjs +105 -0
- package/dist/presentation/Presentation.mjs.map +1 -0
- package/dist/{Stage.d.mts → presentation/Stage.d.mts} +5 -8
- package/dist/{Stage.mjs → presentation/Stage.mjs} +68 -76
- package/dist/presentation/Stage.mjs.map +1 -0
- package/dist/presentation/feed.d.mts +20 -0
- package/dist/presentation/feed.mjs +18 -0
- package/dist/presentation/feed.mjs.map +1 -0
- package/dist/providers/Cdp.d.mts +9 -0
- package/dist/providers/Cdp.mjs +15 -0
- package/dist/providers/Cdp.mjs.map +1 -0
- package/dist/{Chromium.d.mts → providers/Chromium.d.mts} +6 -7
- package/dist/{Chromium.mjs → providers/Chromium.mjs} +7 -16
- package/dist/providers/Chromium.mjs.map +1 -0
- package/dist/providers/Released.d.mts +2 -0
- package/dist/providers/Released.mjs +12 -0
- package/dist/providers/Released.mjs.map +1 -0
- package/dist/stillness/Stillness.d.mts +12 -0
- package/dist/stillness/Stillness.mjs +2 -0
- package/dist/supervisor/Supervisor.d.mts +104 -0
- package/dist/supervisor/Supervisor.mjs +513 -0
- package/dist/supervisor/Supervisor.mjs.map +1 -0
- package/dist/testing/index.d.mts +337 -0
- package/dist/testing/index.mjs +515 -0
- package/dist/testing/index.mjs.map +1 -0
- package/dist/workerd/Cdp.d.mts +8 -0
- package/dist/workerd/Cdp.mjs +13 -0
- package/dist/workerd/Cdp.mjs.map +1 -0
- package/package.json +94 -33
- package/src/Action.ts +127 -0
- package/src/ActionPort.ts +128 -0
- package/src/Browser.ts +366 -225
- package/src/BrowserError.ts +63 -6
- package/src/BrowserEvent.ts +26 -25
- package/src/Change.ts +0 -2
- package/src/{internal/pictures/clock.ts → Clock.ts} +17 -6
- package/src/Frame.ts +14 -0
- package/src/Geometry.ts +48 -0
- package/src/{internal/reading/match.inpage.ts → Matching.ts} +34 -4
- package/src/Page.ts +111 -92
- package/src/Snapshot.ts +5 -0
- package/src/{internal/input/style.ts → Style.ts} +121 -14
- package/src/Window.ts +30 -0
- package/src/index.ts +8 -13
- package/src/internal/input/actions.ts +61 -119
- package/src/internal/input/dispatch.ts +3 -3
- package/src/internal/input/gate.ts +21 -18
- package/src/internal/input/guard.inpage.ts +25 -58
- package/src/internal/input/guard.ts +11 -20
- package/src/internal/input/keyboard.ts +12 -3
- package/src/internal/input/perform.ts +78 -60
- package/src/internal/input/pointer.ts +4 -2
- package/src/internal/input/settle.ts +7 -5
- package/src/internal/input/targets.inpage.ts +1 -1
- package/src/internal/input/targets.ts +4 -9
- package/src/internal/page/bridge.ts +210 -114
- package/src/internal/page/context.ts +23 -73
- package/src/internal/page/dialogs.ts +58 -0
- package/src/internal/page/identity.ts +6 -23
- package/src/internal/page/lane.ts +14 -15
- package/src/internal/page/navigation.ts +50 -42
- package/src/internal/page/openings.ts +11 -5
- package/src/internal/page/page.ts +44 -81
- package/src/internal/page/port.ts +125 -0
- package/src/internal/{input → page}/replies.ts +1 -1
- package/src/internal/page/request-owner.ts +269 -0
- package/src/internal/page/requests.ts +357 -0
- package/src/internal/page/scripts.ts +124 -0
- package/src/internal/pictures/capture.ts +255 -332
- package/src/internal/pictures/dimensions.ts +162 -0
- package/src/internal/pictures/frame.ts +68 -0
- package/src/internal/pictures/pictures.ts +57 -23
- package/src/internal/pictures/quiescence.ts +1 -1
- package/src/internal/pictures/state.ts +26 -0
- package/src/internal/pictures/transport.ts +21 -4
- package/src/internal/reading/controls.inpage.ts +5 -70
- package/src/internal/reading/expect.inpage.ts +13 -17
- package/src/internal/reading/names.inpage.ts +89 -45
- package/src/internal/reading/outline.inpage.ts +6 -7
- package/src/internal/reading/reading.ts +144 -176
- package/src/internal/reading/ready.inpage.ts +6 -17
- package/src/internal/reading/ready.ts +13 -135
- package/src/internal/reading/subjects.inpage.ts +83 -43
- package/src/internal/reading/walk.inpage.ts +33 -13
- package/src/internal/timeline/changes.ts +55 -6
- package/src/internal/timeline/events.ts +15 -5
- package/src/internal/timeline/history.inpage.ts +1 -1
- package/src/internal/timeline/record.inpage.ts +4 -1
- package/src/internal/timeline/window.ts +2 -1
- package/src/{Moment.ts → moment/Moment.ts} +13 -31
- package/src/{internal/timeline → moment}/words.ts +2 -2
- package/src/{internal/reading → plan}/choose.ts +3 -3
- package/src/plan/data.ts +117 -0
- package/src/plan/execute.ts +411 -0
- package/src/plan/index.ts +36 -0
- package/src/plan/record.ts +71 -0
- package/src/plan/targets.ts +71 -0
- package/src/{Policy.ts → policy/Policy.ts} +13 -10
- package/src/{Motion.ts → presentation/Motion.ts} +12 -46
- package/src/presentation/Presentation.ts +176 -0
- package/src/{Stage.ts → presentation/Stage.ts} +147 -112
- package/src/presentation/feed.ts +21 -0
- package/src/providers/Cdp.ts +16 -0
- package/src/{Chromium.ts → providers/Chromium.ts} +7 -10
- package/src/providers/Released.ts +13 -0
- package/src/providers/connection.ts +134 -0
- package/src/{internal/pictures/motion.ts → stillness/Pixels.ts} +4 -4
- package/src/stillness/Stillness.ts +166 -0
- package/src/supervisor/Supervisor.ts +170 -0
- package/src/supervisor/contract.ts +105 -0
- package/src/supervisor/lifecycle.ts +272 -0
- package/src/supervisor/runtime.ts +234 -0
- package/src/testing/TestBrowser.ts +115 -0
- package/src/testing/TestPage.ts +10 -0
- package/src/testing/evidence.ts +154 -0
- package/src/testing/index.ts +3 -0
- package/src/testing/model.ts +222 -0
- package/src/testing/page.ts +360 -0
- package/src/workerd/Cdp.ts +11 -0
- package/dist/Browser-BwCldIff.mjs +0 -629
- package/dist/Browser-BwCldIff.mjs.map +0 -1
- package/dist/Cdp.d.mts +0 -32
- package/dist/Cdp.mjs +0 -61
- package/dist/Cdp.mjs.map +0 -1
- package/dist/Change-DNvztNLu.mjs +0 -138
- package/dist/Change-DNvztNLu.mjs.map +0 -1
- package/dist/Chromium.mjs.map +0 -1
- package/dist/Expect.d.mts +0 -62
- package/dist/Expect.mjs +0 -114
- package/dist/Expect.mjs.map +0 -1
- package/dist/Moment.d.mts +0 -2
- package/dist/Moment.mjs.map +0 -1
- package/dist/Motion.d.mts +0 -2
- package/dist/Motion.mjs.map +0 -1
- package/dist/Page-CfB6Zn1p.mjs.map +0 -1
- package/dist/Plan-C-d5QYS8.mjs.map +0 -1
- package/dist/Plan.d.mts +0 -2
- package/dist/Plan.mjs +0 -2
- package/dist/Policy.mjs.map +0 -1
- package/dist/Presentation.d.mts +0 -48
- package/dist/Presentation.mjs +0 -118
- package/dist/Presentation.mjs.map +0 -1
- package/dist/Stage.mjs.map +0 -1
- package/dist/Supervisor-2mPjIYYs.mjs +0 -676
- package/dist/Supervisor-2mPjIYYs.mjs.map +0 -1
- package/dist/Supervisor-mVPeEUp8.d.mts +0 -317
- package/dist/Supervisor.d.mts +0 -2
- package/dist/Supervisor.mjs +0 -2
- package/dist/context-w3NJPRLo.mjs +0 -335
- package/dist/context-w3NJPRLo.mjs.map +0 -1
- package/dist/match.inpage-xOe9LNO0.mjs.map +0 -1
- package/dist/page-BKwfF6z-.mjs +0 -5099
- package/dist/page-BKwfF6z-.mjs.map +0 -1
- package/dist/url-Cd04Okid.mjs +0 -264
- package/dist/url-Cd04Okid.mjs.map +0 -1
- package/src/Cdp.ts +0 -101
- package/src/Expect.ts +0 -180
- package/src/Plan.ts +0 -674
- package/src/Presentation.ts +0 -196
- package/src/Supervisor.ts +0 -632
- package/src/internal/supervisor/lifecycle.ts +0 -484
- /package/src/{internal/page/url.ts → Url.ts} +0 -0
- /package/src/{internal/pictures → stillness}/utilsBundle.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effect-browser",
|
|
3
|
-
"version": "0.3.0-beta.
|
|
3
|
+
"version": "0.3.0-beta.22",
|
|
4
4
|
"description": "Effect browser sessions, page control, screencast and moments over Playwright and CDP.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
"sideEffects": [],
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
|
+
"workerd": {
|
|
20
|
+
"@effect-browser/source": "./src/index.ts",
|
|
21
|
+
"types": "./dist/index.d.mts",
|
|
22
|
+
"default": "./dist/index.mjs"
|
|
23
|
+
},
|
|
19
24
|
"@effect-browser/source": "./src/index.ts",
|
|
20
25
|
"types": "./dist/index.d.mts",
|
|
21
26
|
"default": "./dist/index.mjs"
|
|
@@ -41,19 +46,19 @@
|
|
|
41
46
|
"default": "./dist/Change.mjs"
|
|
42
47
|
},
|
|
43
48
|
"./Cdp": {
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
"workerd": {
|
|
50
|
+
"@effect-browser/source": "./src/workerd/Cdp.ts",
|
|
51
|
+
"types": "./dist/workerd/Cdp.d.mts",
|
|
52
|
+
"default": "./dist/workerd/Cdp.mjs"
|
|
53
|
+
},
|
|
54
|
+
"@effect-browser/source": "./src/providers/Cdp.ts",
|
|
55
|
+
"types": "./dist/providers/Cdp.d.mts",
|
|
56
|
+
"default": "./dist/providers/Cdp.mjs"
|
|
47
57
|
},
|
|
48
58
|
"./Chromium": {
|
|
49
|
-
"@effect-browser/source": "./src/Chromium.ts",
|
|
50
|
-
"types": "./dist/Chromium.d.mts",
|
|
51
|
-
"default": "./dist/Chromium.mjs"
|
|
52
|
-
},
|
|
53
|
-
"./Expect": {
|
|
54
|
-
"@effect-browser/source": "./src/Expect.ts",
|
|
55
|
-
"types": "./dist/Expect.d.mts",
|
|
56
|
-
"default": "./dist/Expect.mjs"
|
|
59
|
+
"@effect-browser/source": "./src/providers/Chromium.ts",
|
|
60
|
+
"types": "./dist/providers/Chromium.d.mts",
|
|
61
|
+
"default": "./dist/providers/Chromium.mjs"
|
|
57
62
|
},
|
|
58
63
|
"./Frame": {
|
|
59
64
|
"@effect-browser/source": "./src/Frame.ts",
|
|
@@ -61,14 +66,14 @@
|
|
|
61
66
|
"default": "./dist/Frame.mjs"
|
|
62
67
|
},
|
|
63
68
|
"./Moment": {
|
|
64
|
-
"@effect-browser/source": "./src/Moment.ts",
|
|
65
|
-
"types": "./dist/Moment.d.mts",
|
|
66
|
-
"default": "./dist/Moment.mjs"
|
|
69
|
+
"@effect-browser/source": "./src/moment/Moment.ts",
|
|
70
|
+
"types": "./dist/moment/Moment.d.mts",
|
|
71
|
+
"default": "./dist/moment/Moment.mjs"
|
|
67
72
|
},
|
|
68
73
|
"./Motion": {
|
|
69
|
-
"@effect-browser/source": "./src/Motion.ts",
|
|
70
|
-
"types": "./dist/Motion.d.mts",
|
|
71
|
-
"default": "./dist/Motion.mjs"
|
|
74
|
+
"@effect-browser/source": "./src/presentation/Motion.ts",
|
|
75
|
+
"types": "./dist/presentation/Motion.d.mts",
|
|
76
|
+
"default": "./dist/presentation/Motion.mjs"
|
|
72
77
|
},
|
|
73
78
|
"./Page": {
|
|
74
79
|
"@effect-browser/source": "./src/Page.ts",
|
|
@@ -76,19 +81,19 @@
|
|
|
76
81
|
"default": "./dist/Page.mjs"
|
|
77
82
|
},
|
|
78
83
|
"./Plan": {
|
|
79
|
-
"@effect-browser/source": "./src/
|
|
80
|
-
"types": "./dist/
|
|
81
|
-
"default": "./dist/
|
|
84
|
+
"@effect-browser/source": "./src/plan/index.ts",
|
|
85
|
+
"types": "./dist/plan/index.d.mts",
|
|
86
|
+
"default": "./dist/plan/index.mjs"
|
|
82
87
|
},
|
|
83
88
|
"./Policy": {
|
|
84
|
-
"@effect-browser/source": "./src/Policy.ts",
|
|
85
|
-
"types": "./dist/Policy.d.mts",
|
|
86
|
-
"default": "./dist/Policy.mjs"
|
|
89
|
+
"@effect-browser/source": "./src/policy/Policy.ts",
|
|
90
|
+
"types": "./dist/policy/Policy.d.mts",
|
|
91
|
+
"default": "./dist/policy/Policy.mjs"
|
|
87
92
|
},
|
|
88
93
|
"./Presentation": {
|
|
89
|
-
"@effect-browser/source": "./src/Presentation.ts",
|
|
90
|
-
"types": "./dist/Presentation.d.mts",
|
|
91
|
-
"default": "./dist/Presentation.mjs"
|
|
94
|
+
"@effect-browser/source": "./src/presentation/Presentation.ts",
|
|
95
|
+
"types": "./dist/presentation/Presentation.d.mts",
|
|
96
|
+
"default": "./dist/presentation/Presentation.mjs"
|
|
92
97
|
},
|
|
93
98
|
"./Snapshot": {
|
|
94
99
|
"@effect-browser/source": "./src/Snapshot.ts",
|
|
@@ -96,14 +101,69 @@
|
|
|
96
101
|
"default": "./dist/Snapshot.mjs"
|
|
97
102
|
},
|
|
98
103
|
"./Stage": {
|
|
99
|
-
"@effect-browser/source": "./src/Stage.ts",
|
|
100
|
-
"types": "./dist/Stage.d.mts",
|
|
101
|
-
"default": "./dist/Stage.mjs"
|
|
104
|
+
"@effect-browser/source": "./src/presentation/Stage.ts",
|
|
105
|
+
"types": "./dist/presentation/Stage.d.mts",
|
|
106
|
+
"default": "./dist/presentation/Stage.mjs"
|
|
102
107
|
},
|
|
103
108
|
"./Supervisor": {
|
|
104
|
-
"@effect-browser/source": "./src/Supervisor.ts",
|
|
105
|
-
"types": "./dist/Supervisor.d.mts",
|
|
106
|
-
"default": "./dist/Supervisor.mjs"
|
|
109
|
+
"@effect-browser/source": "./src/supervisor/Supervisor.ts",
|
|
110
|
+
"types": "./dist/supervisor/Supervisor.d.mts",
|
|
111
|
+
"default": "./dist/supervisor/Supervisor.mjs"
|
|
112
|
+
},
|
|
113
|
+
"./Released": {
|
|
114
|
+
"@effect-browser/source": "./src/providers/Released.ts",
|
|
115
|
+
"types": "./dist/providers/Released.d.mts",
|
|
116
|
+
"default": "./dist/providers/Released.mjs"
|
|
117
|
+
},
|
|
118
|
+
"./Action": {
|
|
119
|
+
"@effect-browser/source": "./src/Action.ts",
|
|
120
|
+
"types": "./dist/Action.d.mts",
|
|
121
|
+
"default": "./dist/Action.mjs"
|
|
122
|
+
},
|
|
123
|
+
"./Clock": {
|
|
124
|
+
"@effect-browser/source": "./src/Clock.ts",
|
|
125
|
+
"types": "./dist/Clock.d.mts",
|
|
126
|
+
"default": "./dist/Clock.mjs"
|
|
127
|
+
},
|
|
128
|
+
"./Geometry": {
|
|
129
|
+
"@effect-browser/source": "./src/Geometry.ts",
|
|
130
|
+
"types": "./dist/Geometry.d.mts",
|
|
131
|
+
"default": "./dist/Geometry.mjs"
|
|
132
|
+
},
|
|
133
|
+
"./Style": {
|
|
134
|
+
"@effect-browser/source": "./src/Style.ts",
|
|
135
|
+
"types": "./dist/Style.d.mts",
|
|
136
|
+
"default": "./dist/Style.mjs"
|
|
137
|
+
},
|
|
138
|
+
"./Window": {
|
|
139
|
+
"@effect-browser/source": "./src/Window.ts",
|
|
140
|
+
"types": "./dist/Window.d.mts",
|
|
141
|
+
"default": "./dist/Window.mjs"
|
|
142
|
+
},
|
|
143
|
+
"./Stillness": {
|
|
144
|
+
"@effect-browser/source": "./src/stillness/Stillness.ts",
|
|
145
|
+
"types": "./dist/stillness/Stillness.d.mts",
|
|
146
|
+
"default": "./dist/stillness/Stillness.mjs"
|
|
147
|
+
},
|
|
148
|
+
"./Matching": {
|
|
149
|
+
"@effect-browser/source": "./src/Matching.ts",
|
|
150
|
+
"types": "./dist/Matching.d.mts",
|
|
151
|
+
"default": "./dist/Matching.mjs"
|
|
152
|
+
},
|
|
153
|
+
"./testing": {
|
|
154
|
+
"@effect-browser/source": "./src/testing/index.ts",
|
|
155
|
+
"types": "./dist/testing/index.d.mts",
|
|
156
|
+
"default": "./dist/testing/index.mjs"
|
|
157
|
+
},
|
|
158
|
+
"./Url": {
|
|
159
|
+
"@effect-browser/source": "./src/Url.ts",
|
|
160
|
+
"types": "./dist/Url.d.mts",
|
|
161
|
+
"default": "./dist/Url.mjs"
|
|
162
|
+
},
|
|
163
|
+
"./ActionPort": {
|
|
164
|
+
"@effect-browser/source": "./src/ActionPort.ts",
|
|
165
|
+
"types": "./dist/ActionPort.d.mts",
|
|
166
|
+
"default": "./dist/ActionPort.mjs"
|
|
107
167
|
}
|
|
108
168
|
},
|
|
109
169
|
"publishConfig": {
|
|
@@ -118,6 +178,7 @@
|
|
|
118
178
|
"@effect/vitest": "4.0.3",
|
|
119
179
|
"@types/node": "26.1.2",
|
|
120
180
|
"effect": "4.0.3",
|
|
181
|
+
"esbuild": "0.28.2",
|
|
121
182
|
"playwright-core": "1.63.0",
|
|
122
183
|
"typescript": "7.0.2",
|
|
123
184
|
"vite": "npm:@voidzero-dev/vite-plus-core@1.1.0",
|
package/src/Action.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/** Typed browser actions, shared by execution, policy, recordings and replay. */
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
|
|
4
|
+
import { Point } from "./Geometry.ts";
|
|
5
|
+
import * as Url from "./Url.ts";
|
|
6
|
+
|
|
7
|
+
const Ref = Schema.String.check(Schema.isPattern(/^e\d+$/));
|
|
8
|
+
const Target = Schema.Union([Ref, Point]);
|
|
9
|
+
const optionalNumber = Schema.optional(Schema.Finite);
|
|
10
|
+
|
|
11
|
+
export const ClickOptions = Schema.Struct({
|
|
12
|
+
button: Schema.optional(Schema.Literals(["left", "right", "middle"])),
|
|
13
|
+
clickCount: optionalNumber,
|
|
14
|
+
holdMillis: optionalNumber,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const TypeOptions = Schema.Struct({
|
|
18
|
+
into: Schema.optional(Ref),
|
|
19
|
+
replace: Schema.optional(Schema.Boolean),
|
|
20
|
+
submit: Schema.optional(Schema.Boolean),
|
|
21
|
+
secret: Schema.optional(Schema.Boolean),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const PressOptions = Schema.Struct({
|
|
25
|
+
on: Schema.optional(Ref),
|
|
26
|
+
times: optionalNumber,
|
|
27
|
+
holdMillis: optionalNumber,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const ScrollOptions = Schema.Struct({
|
|
31
|
+
at: Schema.optional(Target),
|
|
32
|
+
dx: optionalNumber,
|
|
33
|
+
dy: optionalNumber,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const Action = Schema.TaggedUnion({
|
|
37
|
+
Click: { target: Target, options: Schema.optional(ClickOptions) },
|
|
38
|
+
Hover: { target: Target },
|
|
39
|
+
Drag: { from: Target, to: Target },
|
|
40
|
+
Type: { text: Schema.String, options: Schema.optional(TypeOptions) },
|
|
41
|
+
Press: { keys: Schema.String, options: Schema.optional(PressOptions) },
|
|
42
|
+
Scroll: { options: Schema.optional(ScrollOptions) },
|
|
43
|
+
Select: { ref: Ref, values: Schema.Array(Schema.String) },
|
|
44
|
+
Goto: { url: Schema.String },
|
|
45
|
+
Back: {},
|
|
46
|
+
Reload: {},
|
|
47
|
+
/** A script's code and arguments are never retained. */
|
|
48
|
+
Act: { document: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)) },
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export type Action = typeof Action.Type;
|
|
52
|
+
|
|
53
|
+
export const Name = Schema.Literals([
|
|
54
|
+
"click",
|
|
55
|
+
"hover",
|
|
56
|
+
"drag",
|
|
57
|
+
"type",
|
|
58
|
+
"press",
|
|
59
|
+
"scroll",
|
|
60
|
+
"select",
|
|
61
|
+
"navigate",
|
|
62
|
+
"back",
|
|
63
|
+
"reload",
|
|
64
|
+
"act",
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
export type Name = typeof Name.Type;
|
|
68
|
+
|
|
69
|
+
/** Effective semantics suitable for policy and records; credentials never survive. */
|
|
70
|
+
export const recorded = (value: Action, revealed: boolean): Action => {
|
|
71
|
+
if (value._tag === "Type") {
|
|
72
|
+
const secret = !revealed || value.options?.secret === true;
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
...value,
|
|
76
|
+
text: secret ? Url.withheld : value.text,
|
|
77
|
+
options: {
|
|
78
|
+
...value.options,
|
|
79
|
+
replace: value.options?.into === undefined ? false : (value.options.replace ?? true),
|
|
80
|
+
secret: secret || value.options?.secret,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return value._tag === "Goto" ? { ...value, url: Url.redact(value.url) } : value;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/** The stable event vocabulary for an action. */
|
|
89
|
+
const names: Record<Action["_tag"], Name> = {
|
|
90
|
+
Click: "click",
|
|
91
|
+
Hover: "hover",
|
|
92
|
+
Drag: "drag",
|
|
93
|
+
Type: "type",
|
|
94
|
+
Press: "press",
|
|
95
|
+
Scroll: "scroll",
|
|
96
|
+
Select: "select",
|
|
97
|
+
Goto: "navigate",
|
|
98
|
+
Back: "back",
|
|
99
|
+
Reload: "reload",
|
|
100
|
+
Act: "act",
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const nameOf = (action: Action): Name => names[action._tag];
|
|
104
|
+
|
|
105
|
+
/** The primary target, if this action addresses an element or point. */
|
|
106
|
+
export const targetOf = (action: Action) => {
|
|
107
|
+
switch (action._tag) {
|
|
108
|
+
case "Click":
|
|
109
|
+
case "Hover":
|
|
110
|
+
return action.target;
|
|
111
|
+
case "Drag":
|
|
112
|
+
return action.from;
|
|
113
|
+
case "Type":
|
|
114
|
+
return action.options?.into;
|
|
115
|
+
case "Press":
|
|
116
|
+
return action.options?.on;
|
|
117
|
+
case "Scroll":
|
|
118
|
+
return action.options?.at;
|
|
119
|
+
case "Select":
|
|
120
|
+
return action.ref;
|
|
121
|
+
case "Goto":
|
|
122
|
+
case "Back":
|
|
123
|
+
case "Reload":
|
|
124
|
+
case "Act":
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/** Assemble named Page methods and canonical action execution over one concrete input port. */
|
|
2
|
+
import { Effect, Schema, type SchemaIssue } from "effect";
|
|
3
|
+
|
|
4
|
+
import { Action, nameOf } from "./Action.ts";
|
|
5
|
+
import { InvalidRequest, undispatched } from "./BrowserError.ts";
|
|
6
|
+
import { type Page, ResolvedTarget } from "./Page.ts";
|
|
7
|
+
|
|
8
|
+
type Port = Pick<
|
|
9
|
+
Page,
|
|
10
|
+
"click" | "hover" | "drag" | "type" | "press" | "scroll" | "select" | "goto" | "back" | "reload"
|
|
11
|
+
>;
|
|
12
|
+
|
|
13
|
+
const invalid = (detail: string, operation = "perform") =>
|
|
14
|
+
undispatched(operation, new InvalidRequest({ detail }));
|
|
15
|
+
|
|
16
|
+
const expectedTypes: Readonly<Record<string, string>> = {
|
|
17
|
+
String: "a string",
|
|
18
|
+
Number: "a finite number",
|
|
19
|
+
Boolean: "a boolean",
|
|
20
|
+
Objects: "an object",
|
|
21
|
+
Arrays: "an array",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Action has fixed fields and array indices. Paths come from that schema; rejected values,
|
|
25
|
+
// formatter messages and annotations are never rendered. Prefer the most specific union branch.
|
|
26
|
+
const diagnostic = (
|
|
27
|
+
issue: SchemaIssue.Issue,
|
|
28
|
+
path: ReadonlyArray<PropertyKey> = [],
|
|
29
|
+
): { readonly path: ReadonlyArray<PropertyKey>; readonly expected: string } => {
|
|
30
|
+
if (issue._tag === "Pointer") return diagnostic(issue.issue, [...path, ...issue.path]);
|
|
31
|
+
if (issue._tag === "Encoding") return diagnostic(issue.issue, path);
|
|
32
|
+
if (issue._tag === "Composite" || issue._tag === "AnyOf")
|
|
33
|
+
return (
|
|
34
|
+
issue.issues
|
|
35
|
+
.map((child) => diagnostic(child, path))
|
|
36
|
+
.sort((a, b) => b.path.length - a.path.length)[0] ?? { path, expected: "a supported value" }
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const expected =
|
|
40
|
+
issue._tag === "Filter"
|
|
41
|
+
? issue.filter === Action.cases.Select.fields.ref.ast.checks?.[0]
|
|
42
|
+
? "an element ref such as e12"
|
|
43
|
+
: issue.filter === Schema.Finite.ast.checks?.[0]
|
|
44
|
+
? "a finite number"
|
|
45
|
+
: "a value satisfying the action's constraints"
|
|
46
|
+
: issue._tag === "InvalidType"
|
|
47
|
+
? (expectedTypes[issue.ast._tag] ?? "a supported value")
|
|
48
|
+
: issue._tag === "MissingKey"
|
|
49
|
+
? "a required value"
|
|
50
|
+
: "a valid value";
|
|
51
|
+
|
|
52
|
+
return { path, expected };
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** Dispatch a decoded request to a concrete input port. */
|
|
56
|
+
export const execute = (port: Port, action: Action): ReturnType<Page["perform"]> => {
|
|
57
|
+
switch (action._tag) {
|
|
58
|
+
case "Click":
|
|
59
|
+
return port.click(action.target, action.options);
|
|
60
|
+
case "Hover":
|
|
61
|
+
return port.hover(action.target);
|
|
62
|
+
case "Drag":
|
|
63
|
+
return port.drag(action.from, action.to);
|
|
64
|
+
case "Type":
|
|
65
|
+
return port.type(action.text, action.options);
|
|
66
|
+
case "Press":
|
|
67
|
+
return port.press(action.keys, action.options);
|
|
68
|
+
case "Scroll":
|
|
69
|
+
return port.scroll(action.options);
|
|
70
|
+
case "Select":
|
|
71
|
+
return port.select(action.ref, action.values);
|
|
72
|
+
case "Goto":
|
|
73
|
+
return port.goto(action.url);
|
|
74
|
+
case "Back":
|
|
75
|
+
return port.back;
|
|
76
|
+
case "Reload":
|
|
77
|
+
return port.reload;
|
|
78
|
+
case "Act":
|
|
79
|
+
return Effect.fail(invalid("call page.act with a script"));
|
|
80
|
+
default:
|
|
81
|
+
return Effect.fail(invalid("invalid action tag"));
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/** Decode once before dispatching the canonical request. */
|
|
86
|
+
export const checked =
|
|
87
|
+
(perform: Page["perform"]): Page["perform"] =>
|
|
88
|
+
(asked) =>
|
|
89
|
+
Schema.decodeEffect(Action)(asked).pipe(
|
|
90
|
+
Effect.mapError(({ issue }) => {
|
|
91
|
+
if (
|
|
92
|
+
typeof asked !== "object" ||
|
|
93
|
+
asked === null ||
|
|
94
|
+
typeof asked._tag !== "string" ||
|
|
95
|
+
!Object.hasOwn(Action.cases, asked._tag)
|
|
96
|
+
)
|
|
97
|
+
return invalid("_tag: expected a supported action tag");
|
|
98
|
+
const { path, expected } = diagnostic(issue);
|
|
99
|
+
|
|
100
|
+
return invalid((path.join(".") || "action") + ": expected " + expected, nameOf(asked));
|
|
101
|
+
}),
|
|
102
|
+
Effect.flatMap(perform),
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
/** Named entry points are the same typed action path used by replay and tools. */
|
|
106
|
+
export const methods = (perform: Page["perform"]): Port => ({
|
|
107
|
+
goto: (url) => Effect.asVoid(perform({ _tag: "Goto", url })),
|
|
108
|
+
back: Effect.asVoid(perform({ _tag: "Back" })),
|
|
109
|
+
reload: Effect.asVoid(perform({ _tag: "Reload" })),
|
|
110
|
+
click: (target, options) =>
|
|
111
|
+
perform({ _tag: "Click", target, options }).pipe(
|
|
112
|
+
Effect.filterOrFail(Schema.is(ResolvedTarget), () =>
|
|
113
|
+
invalid("the action produced no target"),
|
|
114
|
+
),
|
|
115
|
+
),
|
|
116
|
+
hover: (target) => Effect.asVoid(perform({ _tag: "Hover", target })),
|
|
117
|
+
drag: (from, to) => Effect.asVoid(perform({ _tag: "Drag", from, to })),
|
|
118
|
+
type: (text, options) => Effect.asVoid(perform({ _tag: "Type", text, options })),
|
|
119
|
+
press: (keys, options) => Effect.asVoid(perform({ _tag: "Press", keys, options })),
|
|
120
|
+
scroll: (options) => Effect.asVoid(perform({ _tag: "Scroll", options })),
|
|
121
|
+
select: (ref, values) =>
|
|
122
|
+
perform({ _tag: "Select", ref, values }).pipe(
|
|
123
|
+
Effect.filterOrFail(
|
|
124
|
+
(value) => typeof value === "string",
|
|
125
|
+
() => invalid("the action produced no labels"),
|
|
126
|
+
),
|
|
127
|
+
),
|
|
128
|
+
});
|