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
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
declare namespace Action_d_exports {
|
|
3
|
+
export { Action, ClickOptions, Name, PressOptions, ScrollOptions, TypeOptions, nameOf, recorded, targetOf };
|
|
4
|
+
}
|
|
5
|
+
declare const ClickOptions: Schema.Struct<{
|
|
6
|
+
readonly button: Schema.optional<Schema.Literals<readonly ["left", "right", "middle"]>>;
|
|
7
|
+
readonly clickCount: Schema.optional<Schema.Finite>;
|
|
8
|
+
readonly holdMillis: Schema.optional<Schema.Finite>;
|
|
9
|
+
}>;
|
|
10
|
+
declare const TypeOptions: Schema.Struct<{
|
|
11
|
+
readonly into: Schema.optional<Schema.String>;
|
|
12
|
+
readonly replace: Schema.optional<Schema.Boolean>;
|
|
13
|
+
readonly submit: Schema.optional<Schema.Boolean>;
|
|
14
|
+
readonly secret: Schema.optional<Schema.Boolean>;
|
|
15
|
+
}>;
|
|
16
|
+
declare const PressOptions: Schema.Struct<{
|
|
17
|
+
readonly on: Schema.optional<Schema.String>;
|
|
18
|
+
readonly times: Schema.optional<Schema.Finite>;
|
|
19
|
+
readonly holdMillis: Schema.optional<Schema.Finite>;
|
|
20
|
+
}>;
|
|
21
|
+
declare const ScrollOptions: Schema.Struct<{
|
|
22
|
+
readonly at: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
23
|
+
readonly x: Schema.Finite;
|
|
24
|
+
readonly y: Schema.Finite;
|
|
25
|
+
}>]>>;
|
|
26
|
+
readonly dx: Schema.optional<Schema.Finite>;
|
|
27
|
+
readonly dy: Schema.optional<Schema.Finite>;
|
|
28
|
+
}>;
|
|
29
|
+
declare const Action: Schema.TaggedUnion<{
|
|
30
|
+
readonly Act: Schema.TaggedStruct<"Act", {
|
|
31
|
+
readonly document: Schema.Int;
|
|
32
|
+
}>;
|
|
33
|
+
readonly Back: Schema.TaggedStruct<"Back", {}>;
|
|
34
|
+
readonly Click: Schema.TaggedStruct<"Click", {
|
|
35
|
+
readonly target: Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
36
|
+
readonly x: Schema.Finite;
|
|
37
|
+
readonly y: Schema.Finite;
|
|
38
|
+
}>]>;
|
|
39
|
+
readonly options: Schema.optional<Schema.Struct<{
|
|
40
|
+
readonly button: Schema.optional<Schema.Literals<readonly ["left", "right", "middle"]>>;
|
|
41
|
+
readonly clickCount: Schema.optional<Schema.Finite>;
|
|
42
|
+
readonly holdMillis: Schema.optional<Schema.Finite>;
|
|
43
|
+
}>>;
|
|
44
|
+
}>;
|
|
45
|
+
readonly Drag: Schema.TaggedStruct<"Drag", {
|
|
46
|
+
readonly from: Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
47
|
+
readonly x: Schema.Finite;
|
|
48
|
+
readonly y: Schema.Finite;
|
|
49
|
+
}>]>;
|
|
50
|
+
readonly to: Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
51
|
+
readonly x: Schema.Finite;
|
|
52
|
+
readonly y: Schema.Finite;
|
|
53
|
+
}>]>;
|
|
54
|
+
}>;
|
|
55
|
+
readonly Goto: Schema.TaggedStruct<"Goto", {
|
|
56
|
+
readonly url: Schema.String;
|
|
57
|
+
}>;
|
|
58
|
+
readonly Hover: Schema.TaggedStruct<"Hover", {
|
|
59
|
+
readonly target: Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
60
|
+
readonly x: Schema.Finite;
|
|
61
|
+
readonly y: Schema.Finite;
|
|
62
|
+
}>]>;
|
|
63
|
+
}>;
|
|
64
|
+
readonly Press: Schema.TaggedStruct<"Press", {
|
|
65
|
+
readonly keys: Schema.String;
|
|
66
|
+
readonly options: Schema.optional<Schema.Struct<{
|
|
67
|
+
readonly on: Schema.optional<Schema.String>;
|
|
68
|
+
readonly times: Schema.optional<Schema.Finite>;
|
|
69
|
+
readonly holdMillis: Schema.optional<Schema.Finite>;
|
|
70
|
+
}>>;
|
|
71
|
+
}>;
|
|
72
|
+
readonly Reload: Schema.TaggedStruct<"Reload", {}>;
|
|
73
|
+
readonly Scroll: Schema.TaggedStruct<"Scroll", {
|
|
74
|
+
readonly options: Schema.optional<Schema.Struct<{
|
|
75
|
+
readonly at: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
76
|
+
readonly x: Schema.Finite;
|
|
77
|
+
readonly y: Schema.Finite;
|
|
78
|
+
}>]>>;
|
|
79
|
+
readonly dx: Schema.optional<Schema.Finite>;
|
|
80
|
+
readonly dy: Schema.optional<Schema.Finite>;
|
|
81
|
+
}>>;
|
|
82
|
+
}>;
|
|
83
|
+
readonly Select: Schema.TaggedStruct<"Select", {
|
|
84
|
+
readonly ref: Schema.String;
|
|
85
|
+
readonly values: Schema.$Array<Schema.String>;
|
|
86
|
+
}>;
|
|
87
|
+
readonly Type: Schema.TaggedStruct<"Type", {
|
|
88
|
+
readonly text: Schema.String;
|
|
89
|
+
readonly options: Schema.optional<Schema.Struct<{
|
|
90
|
+
readonly into: Schema.optional<Schema.String>;
|
|
91
|
+
readonly replace: Schema.optional<Schema.Boolean>;
|
|
92
|
+
readonly submit: Schema.optional<Schema.Boolean>;
|
|
93
|
+
readonly secret: Schema.optional<Schema.Boolean>;
|
|
94
|
+
}>>;
|
|
95
|
+
}>;
|
|
96
|
+
}>;
|
|
97
|
+
type Action = typeof Action.Type;
|
|
98
|
+
declare const Name: Schema.Literals<readonly ["click", "hover", "drag", "type", "press", "scroll", "select", "navigate", "back", "reload", "act"]>;
|
|
99
|
+
type Name = typeof Name.Type;
|
|
100
|
+
/** Effective semantics suitable for policy and records; credentials never survive. */
|
|
101
|
+
declare const recorded: (value: Action, revealed: boolean) => Action;
|
|
102
|
+
declare const nameOf: (action: Action) => Name;
|
|
103
|
+
/** The primary target, if this action addresses an element or point. */
|
|
104
|
+
declare const targetOf: (action: Action) => string | {
|
|
105
|
+
readonly x: number;
|
|
106
|
+
readonly y: number;
|
|
107
|
+
} | undefined;
|
|
108
|
+
//#endregion
|
|
109
|
+
export { PressOptions as a, nameOf as c, Name as i, recorded as l, Action_d_exports as n, ScrollOptions as o, ClickOptions as r, TypeOptions as s, Action as t, targetOf as u };
|
|
110
|
+
//# sourceMappingURL=Action-24sLOubi.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as PressOptions, c as nameOf, i as Name, l as recorded, o as ScrollOptions, r as ClickOptions, s as TypeOptions, t as Action, u as targetOf } from "./Action-24sLOubi.mjs";
|
|
2
|
+
export { Action, ClickOptions, Name, PressOptions, ScrollOptions, TypeOptions, nameOf, recorded, targetOf };
|
package/dist/Action.mjs
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { Point } from "./Geometry.mjs";
|
|
3
|
+
import { redact, withheld } from "./Url.mjs";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
|
+
//#region src/Action.ts
|
|
6
|
+
/** Typed browser actions, shared by execution, policy, recordings and replay. */
|
|
7
|
+
var Action_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
Action: () => Action,
|
|
9
|
+
ClickOptions: () => ClickOptions,
|
|
10
|
+
Name: () => Name,
|
|
11
|
+
PressOptions: () => PressOptions,
|
|
12
|
+
ScrollOptions: () => ScrollOptions,
|
|
13
|
+
TypeOptions: () => TypeOptions,
|
|
14
|
+
nameOf: () => nameOf,
|
|
15
|
+
recorded: () => recorded,
|
|
16
|
+
targetOf: () => targetOf
|
|
17
|
+
});
|
|
18
|
+
const Ref$1 = Schema.String.check(Schema.isPattern(/^e\d+$/));
|
|
19
|
+
const Target = Schema.Union([Ref$1, Point]);
|
|
20
|
+
const optionalNumber = Schema.optional(Schema.Finite);
|
|
21
|
+
const ClickOptions = Schema.Struct({
|
|
22
|
+
button: Schema.optional(Schema.Literals([
|
|
23
|
+
"left",
|
|
24
|
+
"right",
|
|
25
|
+
"middle"
|
|
26
|
+
])),
|
|
27
|
+
clickCount: optionalNumber,
|
|
28
|
+
holdMillis: optionalNumber
|
|
29
|
+
});
|
|
30
|
+
const TypeOptions = Schema.Struct({
|
|
31
|
+
into: Schema.optional(Ref$1),
|
|
32
|
+
replace: Schema.optional(Schema.Boolean),
|
|
33
|
+
submit: Schema.optional(Schema.Boolean),
|
|
34
|
+
secret: Schema.optional(Schema.Boolean)
|
|
35
|
+
});
|
|
36
|
+
const PressOptions = Schema.Struct({
|
|
37
|
+
on: Schema.optional(Ref$1),
|
|
38
|
+
times: optionalNumber,
|
|
39
|
+
holdMillis: optionalNumber
|
|
40
|
+
});
|
|
41
|
+
const ScrollOptions = Schema.Struct({
|
|
42
|
+
at: Schema.optional(Target),
|
|
43
|
+
dx: optionalNumber,
|
|
44
|
+
dy: optionalNumber
|
|
45
|
+
});
|
|
46
|
+
const Action = Schema.TaggedUnion({
|
|
47
|
+
Click: {
|
|
48
|
+
target: Target,
|
|
49
|
+
options: Schema.optional(ClickOptions)
|
|
50
|
+
},
|
|
51
|
+
Hover: { target: Target },
|
|
52
|
+
Drag: {
|
|
53
|
+
from: Target,
|
|
54
|
+
to: Target
|
|
55
|
+
},
|
|
56
|
+
Type: {
|
|
57
|
+
text: Schema.String,
|
|
58
|
+
options: Schema.optional(TypeOptions)
|
|
59
|
+
},
|
|
60
|
+
Press: {
|
|
61
|
+
keys: Schema.String,
|
|
62
|
+
options: Schema.optional(PressOptions)
|
|
63
|
+
},
|
|
64
|
+
Scroll: { options: Schema.optional(ScrollOptions) },
|
|
65
|
+
Select: {
|
|
66
|
+
ref: Ref$1,
|
|
67
|
+
values: Schema.Array(Schema.String)
|
|
68
|
+
},
|
|
69
|
+
Goto: { url: Schema.String },
|
|
70
|
+
Back: {},
|
|
71
|
+
Reload: {},
|
|
72
|
+
/** A script's code and arguments are never retained. */
|
|
73
|
+
Act: { document: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)) }
|
|
74
|
+
});
|
|
75
|
+
const Name = Schema.Literals([
|
|
76
|
+
"click",
|
|
77
|
+
"hover",
|
|
78
|
+
"drag",
|
|
79
|
+
"type",
|
|
80
|
+
"press",
|
|
81
|
+
"scroll",
|
|
82
|
+
"select",
|
|
83
|
+
"navigate",
|
|
84
|
+
"back",
|
|
85
|
+
"reload",
|
|
86
|
+
"act"
|
|
87
|
+
]);
|
|
88
|
+
/** Effective semantics suitable for policy and records; credentials never survive. */
|
|
89
|
+
const recorded = (value, revealed) => {
|
|
90
|
+
if (value._tag === "Type") {
|
|
91
|
+
const secret = !revealed || value.options?.secret === true;
|
|
92
|
+
return {
|
|
93
|
+
...value,
|
|
94
|
+
text: secret ? withheld : value.text,
|
|
95
|
+
options: {
|
|
96
|
+
...value.options,
|
|
97
|
+
replace: value.options?.into === void 0 ? false : value.options.replace ?? true,
|
|
98
|
+
secret: secret || value.options?.secret
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return value._tag === "Goto" ? {
|
|
103
|
+
...value,
|
|
104
|
+
url: redact(value.url)
|
|
105
|
+
} : value;
|
|
106
|
+
};
|
|
107
|
+
/** The stable event vocabulary for an action. */
|
|
108
|
+
const names = {
|
|
109
|
+
Click: "click",
|
|
110
|
+
Hover: "hover",
|
|
111
|
+
Drag: "drag",
|
|
112
|
+
Type: "type",
|
|
113
|
+
Press: "press",
|
|
114
|
+
Scroll: "scroll",
|
|
115
|
+
Select: "select",
|
|
116
|
+
Goto: "navigate",
|
|
117
|
+
Back: "back",
|
|
118
|
+
Reload: "reload",
|
|
119
|
+
Act: "act"
|
|
120
|
+
};
|
|
121
|
+
const nameOf = (action) => names[action._tag];
|
|
122
|
+
/** The primary target, if this action addresses an element or point. */
|
|
123
|
+
const targetOf = (action) => {
|
|
124
|
+
switch (action._tag) {
|
|
125
|
+
case "Click":
|
|
126
|
+
case "Hover": return action.target;
|
|
127
|
+
case "Drag": return action.from;
|
|
128
|
+
case "Type": return action.options?.into;
|
|
129
|
+
case "Press": return action.options?.on;
|
|
130
|
+
case "Scroll": return action.options?.at;
|
|
131
|
+
case "Select": return action.ref;
|
|
132
|
+
case "Goto":
|
|
133
|
+
case "Back":
|
|
134
|
+
case "Reload":
|
|
135
|
+
case "Act": return;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
//#endregion
|
|
139
|
+
export { Action, ClickOptions, Name, PressOptions, ScrollOptions, TypeOptions, nameOf, recorded, Action_exports as t, targetOf };
|
|
140
|
+
|
|
141
|
+
//# sourceMappingURL=Action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Action.mjs","names":["Ref","Url.withheld","Url.redact"],"sources":["../src/Action.ts"],"sourcesContent":["/** Typed browser actions, shared by execution, policy, recordings and replay. */\nimport { Schema } from \"effect\";\n\nimport { Point } from \"./Geometry.ts\";\nimport * as Url from \"./Url.ts\";\n\nconst Ref = Schema.String.check(Schema.isPattern(/^e\\d+$/));\nconst Target = Schema.Union([Ref, Point]);\nconst optionalNumber = Schema.optional(Schema.Finite);\n\nexport const ClickOptions = Schema.Struct({\n button: Schema.optional(Schema.Literals([\"left\", \"right\", \"middle\"])),\n clickCount: optionalNumber,\n holdMillis: optionalNumber,\n});\n\nexport const TypeOptions = Schema.Struct({\n into: Schema.optional(Ref),\n replace: Schema.optional(Schema.Boolean),\n submit: Schema.optional(Schema.Boolean),\n secret: Schema.optional(Schema.Boolean),\n});\n\nexport const PressOptions = Schema.Struct({\n on: Schema.optional(Ref),\n times: optionalNumber,\n holdMillis: optionalNumber,\n});\n\nexport const ScrollOptions = Schema.Struct({\n at: Schema.optional(Target),\n dx: optionalNumber,\n dy: optionalNumber,\n});\n\nexport const Action = Schema.TaggedUnion({\n Click: { target: Target, options: Schema.optional(ClickOptions) },\n Hover: { target: Target },\n Drag: { from: Target, to: Target },\n Type: { text: Schema.String, options: Schema.optional(TypeOptions) },\n Press: { keys: Schema.String, options: Schema.optional(PressOptions) },\n Scroll: { options: Schema.optional(ScrollOptions) },\n Select: { ref: Ref, values: Schema.Array(Schema.String) },\n Goto: { url: Schema.String },\n Back: {},\n Reload: {},\n /** A script's code and arguments are never retained. */\n Act: { document: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)) },\n});\n\nexport type Action = typeof Action.Type;\n\nexport const Name = Schema.Literals([\n \"click\",\n \"hover\",\n \"drag\",\n \"type\",\n \"press\",\n \"scroll\",\n \"select\",\n \"navigate\",\n \"back\",\n \"reload\",\n \"act\",\n]);\n\nexport type Name = typeof Name.Type;\n\n/** Effective semantics suitable for policy and records; credentials never survive. */\nexport const recorded = (value: Action, revealed: boolean): Action => {\n if (value._tag === \"Type\") {\n const secret = !revealed || value.options?.secret === true;\n\n return {\n ...value,\n text: secret ? Url.withheld : value.text,\n options: {\n ...value.options,\n replace: value.options?.into === undefined ? false : (value.options.replace ?? true),\n secret: secret || value.options?.secret,\n },\n };\n }\n\n return value._tag === \"Goto\" ? { ...value, url: Url.redact(value.url) } : value;\n};\n\n/** The stable event vocabulary for an action. */\nconst names: Record<Action[\"_tag\"], Name> = {\n Click: \"click\",\n Hover: \"hover\",\n Drag: \"drag\",\n Type: \"type\",\n Press: \"press\",\n Scroll: \"scroll\",\n Select: \"select\",\n Goto: \"navigate\",\n Back: \"back\",\n Reload: \"reload\",\n Act: \"act\",\n};\n\nexport const nameOf = (action: Action): Name => names[action._tag];\n\n/** The primary target, if this action addresses an element or point. */\nexport const targetOf = (action: Action) => {\n switch (action._tag) {\n case \"Click\":\n case \"Hover\":\n return action.target;\n case \"Drag\":\n return action.from;\n case \"Type\":\n return action.options?.into;\n case \"Press\":\n return action.options?.on;\n case \"Scroll\":\n return action.options?.at;\n case \"Select\":\n return action.ref;\n case \"Goto\":\n case \"Back\":\n case \"Reload\":\n case \"Act\":\n return undefined;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAMA,MAAMA,QAAM,OAAO,OAAO,MAAM,OAAO,UAAU,QAAQ,CAAC;AAC1D,MAAM,SAAS,OAAO,MAAM,CAACA,OAAK,KAAK,CAAC;AACxC,MAAM,iBAAiB,OAAO,SAAS,OAAO,MAAM;AAEpD,MAAa,eAAe,OAAO,OAAO;CACxC,QAAQ,OAAO,SAAS,OAAO,SAAS;EAAC;EAAQ;EAAS;CAAQ,CAAC,CAAC;CACpE,YAAY;CACZ,YAAY;AACd,CAAC;AAED,MAAa,cAAc,OAAO,OAAO;CACvC,MA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AAA,IAAY,QAAS,MAAM,QAAQ,WAAW;IAC/E,QAAQ,UAAU,MAAM,SAAS;GACnC;EACF;CACF;CAEA,OAAO,MAAM,SAAS,SAAS;EAAE,GAAG;EAAO,KAAKC,OAAW,MAAM,GAAG;CAAE,IAAI;AAC5E;;AAGA,MAAM,QAAsC;CAC1C,OAAO;CACP,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,MAAM;CACN,QAAQ;CACR,KAAK;AACP;AAEA,MAAa,UAAU,WAAyB,MAAM,OAAO;;AAG7D,MAAa,YAAY,WAAmB;CAC1C,QAAQ,OAAO,MAAf;EACE,KAAK;EACL,KAAK,SACH,OAAO,OAAO;EAChB,KAAK,QACH,OAAO,OAAO;EAChB,KAAK,QACH,OAAO,OAAO,SAAS;EACzB,KAAK,SACH,OAAO,OAAO,SAAS;EACzB,KAAK,UACH,OAAO,OAAO,SAAS;EACzB,KAAK,UACH,OAAO,OAAO;EAChB,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,OACH;CACJ;AACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { t as Action } from "./Action-24sLOubi.mjs";
|
|
2
|
+
import { f as Page } from "./Page-CvsOEorc.mjs";
|
|
3
|
+
declare namespace ActionPort_d_exports {
|
|
4
|
+
export { checked, execute, methods };
|
|
5
|
+
}
|
|
6
|
+
type Port = Pick<Page, "click" | "hover" | "drag" | "type" | "press" | "scroll" | "select" | "goto" | "back" | "reload">;
|
|
7
|
+
/** Dispatch a decoded request to a concrete input port. */
|
|
8
|
+
export declare const execute: (port: Port, action: Action) => ReturnType<Page["perform"]>;
|
|
9
|
+
/** Decode once before dispatching the canonical request. */
|
|
10
|
+
export declare const checked: (perform: Page["perform"]) => Page["perform"];
|
|
11
|
+
/** Named entry points are the same typed action path used by replay and tools. */
|
|
12
|
+
export declare const methods: (perform: Page["perform"]) => Port;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { ActionPort_d_exports as t };
|
|
15
|
+
//# sourceMappingURL=ActionPort.d.mts.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { Action, nameOf } from "./Action.mjs";
|
|
3
|
+
import { InvalidRequest, undispatched } from "./BrowserError.mjs";
|
|
4
|
+
import { s as ResolvedTarget } from "./Page-BF5izr8R.mjs";
|
|
5
|
+
import { Effect, Schema } from "effect";
|
|
6
|
+
//#region src/ActionPort.ts
|
|
7
|
+
/** Assemble named Page methods and canonical action execution over one concrete input port. */
|
|
8
|
+
var ActionPort_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
+
checked: () => checked,
|
|
10
|
+
execute: () => execute,
|
|
11
|
+
methods: () => methods
|
|
12
|
+
});
|
|
13
|
+
const invalid = (detail, operation = "perform") => undispatched(operation, new InvalidRequest({ detail }));
|
|
14
|
+
const expectedTypes = {
|
|
15
|
+
String: "a string",
|
|
16
|
+
Number: "a finite number",
|
|
17
|
+
Boolean: "a boolean",
|
|
18
|
+
Objects: "an object",
|
|
19
|
+
Arrays: "an array"
|
|
20
|
+
};
|
|
21
|
+
const diagnostic = (issue, path = []) => {
|
|
22
|
+
if (issue._tag === "Pointer") return diagnostic(issue.issue, [...path, ...issue.path]);
|
|
23
|
+
if (issue._tag === "Encoding") return diagnostic(issue.issue, path);
|
|
24
|
+
if (issue._tag === "Composite" || issue._tag === "AnyOf") return issue.issues.map((child) => diagnostic(child, path)).sort((a, b) => b.path.length - a.path.length)[0] ?? {
|
|
25
|
+
path,
|
|
26
|
+
expected: "a supported value"
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
path,
|
|
30
|
+
expected: issue._tag === "Filter" ? issue.filter === Action.cases.Select.fields.ref.ast.checks?.[0] ? "an element ref such as e12" : issue.filter === Schema.Finite.ast.checks?.[0] ? "a finite number" : "a value satisfying the action's constraints" : issue._tag === "InvalidType" ? expectedTypes[issue.ast._tag] ?? "a supported value" : issue._tag === "MissingKey" ? "a required value" : "a valid value"
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/** Dispatch a decoded request to a concrete input port. */
|
|
34
|
+
const execute = (port, action) => {
|
|
35
|
+
switch (action._tag) {
|
|
36
|
+
case "Click": return port.click(action.target, action.options);
|
|
37
|
+
case "Hover": return port.hover(action.target);
|
|
38
|
+
case "Drag": return port.drag(action.from, action.to);
|
|
39
|
+
case "Type": return port.type(action.text, action.options);
|
|
40
|
+
case "Press": return port.press(action.keys, action.options);
|
|
41
|
+
case "Scroll": return port.scroll(action.options);
|
|
42
|
+
case "Select": return port.select(action.ref, action.values);
|
|
43
|
+
case "Goto": return port.goto(action.url);
|
|
44
|
+
case "Back": return port.back;
|
|
45
|
+
case "Reload": return port.reload;
|
|
46
|
+
case "Act": return Effect.fail(invalid("call page.act with a script"));
|
|
47
|
+
default: return Effect.fail(invalid("invalid action tag"));
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/** Decode once before dispatching the canonical request. */
|
|
51
|
+
const checked = (perform) => (asked) => Schema.decodeEffect(Action)(asked).pipe(Effect.mapError(({ issue }) => {
|
|
52
|
+
if (typeof asked !== "object" || asked === null || typeof asked._tag !== "string" || !Object.hasOwn(Action.cases, asked._tag)) return invalid("_tag: expected a supported action tag");
|
|
53
|
+
const { path, expected } = diagnostic(issue);
|
|
54
|
+
return invalid((path.join(".") || "action") + ": expected " + expected, nameOf(asked));
|
|
55
|
+
}), Effect.flatMap(perform));
|
|
56
|
+
/** Named entry points are the same typed action path used by replay and tools. */
|
|
57
|
+
const methods = (perform) => ({
|
|
58
|
+
goto: (url) => Effect.asVoid(perform({
|
|
59
|
+
_tag: "Goto",
|
|
60
|
+
url
|
|
61
|
+
})),
|
|
62
|
+
back: Effect.asVoid(perform({ _tag: "Back" })),
|
|
63
|
+
reload: Effect.asVoid(perform({ _tag: "Reload" })),
|
|
64
|
+
click: (target, options) => perform({
|
|
65
|
+
_tag: "Click",
|
|
66
|
+
target,
|
|
67
|
+
options
|
|
68
|
+
}).pipe(Effect.filterOrFail(Schema.is(ResolvedTarget), () => invalid("the action produced no target"))),
|
|
69
|
+
hover: (target) => Effect.asVoid(perform({
|
|
70
|
+
_tag: "Hover",
|
|
71
|
+
target
|
|
72
|
+
})),
|
|
73
|
+
drag: (from, to) => Effect.asVoid(perform({
|
|
74
|
+
_tag: "Drag",
|
|
75
|
+
from,
|
|
76
|
+
to
|
|
77
|
+
})),
|
|
78
|
+
type: (text, options) => Effect.asVoid(perform({
|
|
79
|
+
_tag: "Type",
|
|
80
|
+
text,
|
|
81
|
+
options
|
|
82
|
+
})),
|
|
83
|
+
press: (keys, options) => Effect.asVoid(perform({
|
|
84
|
+
_tag: "Press",
|
|
85
|
+
keys,
|
|
86
|
+
options
|
|
87
|
+
})),
|
|
88
|
+
scroll: (options) => Effect.asVoid(perform({
|
|
89
|
+
_tag: "Scroll",
|
|
90
|
+
options
|
|
91
|
+
})),
|
|
92
|
+
select: (ref, values) => perform({
|
|
93
|
+
_tag: "Select",
|
|
94
|
+
ref,
|
|
95
|
+
values
|
|
96
|
+
}).pipe(Effect.filterOrFail((value) => typeof value === "string", () => invalid("the action produced no labels")))
|
|
97
|
+
});
|
|
98
|
+
//#endregion
|
|
99
|
+
export { checked, execute, methods, ActionPort_exports as t };
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=ActionPort.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionPort.mjs","names":[],"sources":["../src/ActionPort.ts"],"sourcesContent":["/** Assemble named Page methods and canonical action execution over one concrete input port. */\nimport { Effect, Schema, type SchemaIssue } from \"effect\";\n\nimport { Action, nameOf } from \"./Action.ts\";\nimport { InvalidRequest, undispatched } from \"./BrowserError.ts\";\nimport { type Page, ResolvedTarget } from \"./Page.ts\";\n\ntype Port = Pick<\n Page,\n \"click\" | \"hover\" | \"drag\" | \"type\" | \"press\" | \"scroll\" | \"select\" | \"goto\" | \"back\" | \"reload\"\n>;\n\nconst invalid = (detail: string, operation = \"perform\") =>\n undispatched(operation, new InvalidRequest({ detail }));\n\nconst expectedTypes: Readonly<Record<string, string>> = {\n String: \"a string\",\n Number: \"a finite number\",\n Boolean: \"a boolean\",\n Objects: \"an object\",\n Arrays: \"an array\",\n};\n\n// Action has fixed fields and array indices. Paths come from that schema; rejected values,\n// formatter messages and annotations are never rendered. Prefer the most specific union branch.\nconst diagnostic = (\n issue: SchemaIssue.Issue,\n path: ReadonlyArray<PropertyKey> = [],\n): { readonly path: ReadonlyArray<PropertyKey>; readonly expected: string } => {\n if (issue._tag === \"Pointer\") return diagnostic(issue.issue, [...path, ...issue.path]);\n if (issue._tag === \"Encoding\") return diagnostic(issue.issue, path);\n if (issue._tag === \"Composite\" || issue._tag === \"AnyOf\")\n return (\n issue.issues\n .map((child) => diagnostic(child, path))\n .sort((a, b) => b.path.length - a.path.length)[0] ?? { path, expected: \"a supported value\" }\n );\n\n const expected =\n issue._tag === \"Filter\"\n ? issue.filter === Action.cases.Select.fields.ref.ast.checks?.[0]\n ? \"an element ref such as e12\"\n : issue.filter === Schema.Finite.ast.checks?.[0]\n ? \"a finite number\"\n : \"a value satisfying the action's constraints\"\n : issue._tag === \"InvalidType\"\n ? (expectedTypes[issue.ast._tag] ?? \"a supported value\")\n : issue._tag === \"MissingKey\"\n ? \"a required value\"\n : \"a valid value\";\n\n return { path, expected };\n};\n\n/** Dispatch a decoded request to a concrete input port. */\nexport const execute = (port: Port, action: Action): ReturnType<Page[\"perform\"]> => {\n switch (action._tag) {\n case \"Click\":\n return port.click(action.target, action.options);\n case \"Hover\":\n return port.hover(action.target);\n case \"Drag\":\n return port.drag(action.from, action.to);\n case \"Type\":\n return port.type(action.text, action.options);\n case \"Press\":\n return port.press(action.keys, action.options);\n case \"Scroll\":\n return port.scroll(action.options);\n case \"Select\":\n return port.select(action.ref, action.values);\n case \"Goto\":\n return port.goto(action.url);\n case \"Back\":\n return port.back;\n case \"Reload\":\n return port.reload;\n case \"Act\":\n return Effect.fail(invalid(\"call page.act with a script\"));\n default:\n return Effect.fail(invalid(\"invalid action tag\"));\n }\n};\n\n/** Decode once before dispatching the canonical request. */\nexport const checked =\n (perform: Page[\"perform\"]): Page[\"perform\"] =>\n (asked) =>\n Schema.decodeEffect(Action)(asked).pipe(\n Effect.mapError(({ issue }) => {\n if (\n typeof asked !== \"object\" ||\n asked === null ||\n typeof asked._tag !== \"string\" ||\n !Object.hasOwn(Action.cases, asked._tag)\n )\n return invalid(\"_tag: expected a supported action tag\");\n const { path, expected } = diagnostic(issue);\n\n return invalid((path.join(\".\") || \"action\") + \": expected \" + expected, nameOf(asked));\n }),\n Effect.flatMap(perform),\n );\n\n/** Named entry points are the same typed action path used by replay and tools. */\nexport const methods = (perform: Page[\"perform\"]): Port => ({\n goto: (url) => Effect.asVoid(perform({ _tag: \"Goto\", url })),\n back: Effect.asVoid(perform({ _tag: \"Back\" })),\n reload: Effect.asVoid(perform({ _tag: \"Reload\" })),\n click: (target, options) =>\n perform({ _tag: \"Click\", target, options }).pipe(\n Effect.filterOrFail(Schema.is(ResolvedTarget), () =>\n invalid(\"the action produced no target\"),\n ),\n ),\n hover: (target) => Effect.asVoid(perform({ _tag: \"Hover\", target })),\n drag: (from, to) => Effect.asVoid(perform({ _tag: \"Drag\", from, to })),\n type: (text, options) => Effect.asVoid(perform({ _tag: \"Type\", text, options })),\n press: (keys, options) => Effect.asVoid(perform({ _tag: \"Press\", keys, options })),\n scroll: (options) => Effect.asVoid(perform({ _tag: \"Scroll\", options })),\n select: (ref, values) =>\n perform({ _tag: \"Select\", ref, values }).pipe(\n Effect.filterOrFail(\n (value) => typeof value === \"string\",\n () => invalid(\"the action produced no labels\"),\n ),\n ),\n});\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,WAAW,QAAgB,YAAY,cAC3C,aAAa,WAAW,IAAI,eAAe,EAAE,OAAO,CAAC,CAAC;AAExD,MAAM,gBAAkD;CACtD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