effect-browser 0.3.0-beta.23 → 0.3.0-beta.24
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 +124 -5
- package/dist/ActionPort.d.mts +1 -1
- package/dist/ActionPort.mjs +1 -1
- package/dist/{Browser-BKPAbyys.mjs → Browser-CAQFhTkM.mjs} +559 -333
- package/dist/Browser-CAQFhTkM.mjs.map +1 -0
- package/dist/{Browser-wZhwZSlG.d.mts → Browser-DGR6ZEYo.d.mts} +9 -3
- package/dist/Browser.d.mts +1 -1
- package/dist/Browser.mjs +1 -1
- package/dist/{BrowserEvent-lLqJ3GJS.d.mts → BrowserEvent-C2p-NwuU.d.mts} +30 -6
- package/dist/BrowserEvent.d.mts +2 -2
- package/dist/BrowserEvent.mjs +20 -1
- package/dist/BrowserEvent.mjs.map +1 -1
- package/dist/{Change-Ba7INmay.d.mts → Change-CxT1mp2e.d.mts} +13 -2
- package/dist/Change.d.mts +1 -1
- package/dist/Change.mjs +7 -1
- package/dist/Change.mjs.map +1 -1
- package/dist/Clock-Du5nP-nK.d.mts +57 -0
- package/dist/Clock.d.mts +2 -57
- package/dist/Layout.d.mts +2 -0
- package/dist/Layout.mjs +81 -0
- package/dist/Layout.mjs.map +1 -0
- package/dist/Matching-MtcWZ_hA.d.mts +266 -0
- package/dist/Matching.d.mts +2 -37
- package/dist/Matching.mjs +22 -17
- package/dist/Matching.mjs.map +1 -1
- package/dist/Overlay-CoGw5tL_.d.mts +27 -0
- package/dist/Overlay.d.mts +2 -0
- package/dist/Overlay.mjs +30 -0
- package/dist/Overlay.mjs.map +1 -0
- package/dist/{Page-BF5izr8R.mjs → Page-BaAOshxo.mjs} +3 -1
- package/dist/Page-BaAOshxo.mjs.map +1 -0
- package/dist/{Page-CvsOEorc.d.mts → Page-CLzh5E9w.d.mts} +158 -6
- package/dist/Page.d.mts +2 -2
- package/dist/Page.mjs +1 -1
- package/dist/PageTime-68UPUZpZ.d.mts +29 -0
- package/dist/PageTime.d.mts +2 -0
- package/dist/PageTime.mjs +7 -0
- package/dist/PageTime.mjs.map +1 -0
- package/dist/Pose-2qqGzPvb.d.mts +32 -0
- package/dist/Pose.d.mts +2 -0
- package/dist/Pose.mjs +44 -0
- package/dist/Pose.mjs.map +1 -0
- package/dist/Site.d.mts +714 -0
- package/dist/Site.mjs +102 -0
- package/dist/Site.mjs.map +1 -0
- package/dist/{Stillness-CNlvayIo.mjs → Stillness-BwP0RdI4.mjs} +27 -6
- package/dist/Stillness-BwP0RdI4.mjs.map +1 -0
- package/dist/{Style-AO4V7Czt.mjs → Style-T3ezDYLI.mjs} +25 -2
- package/dist/{Style-AO4V7Czt.mjs.map → Style-T3ezDYLI.mjs.map} +1 -1
- package/dist/Style.d.mts +15 -2
- package/dist/Style.mjs +2 -2
- package/dist/Url-B7P-TWwL.d.mts +26 -0
- package/dist/Url.d.mts +2 -26
- package/dist/{Window-CMddGMt1.d.mts → Window-BDa8MtNP.d.mts} +4 -4
- package/dist/Window.d.mts +1 -1
- package/dist/{connection-CK83pvqP.mjs → connection-C_jWYIwe.mjs} +2 -2
- package/dist/{connection-CK83pvqP.mjs.map → connection-C_jWYIwe.mjs.map} +1 -1
- package/dist/{connection-2KHI4_KN.d.mts → connection-Db-YtlbE.d.mts} +2 -2
- package/dist/film/Film.d.mts +265 -0
- package/dist/film/Film.mjs +246 -0
- package/dist/film/Film.mjs.map +1 -0
- package/dist/fold.inpage-CyVZQHZL.d.mts +49 -0
- package/dist/index.d.mts +11 -8
- package/dist/index.mjs +8 -4
- package/dist/moment/Moment.d.mts +5 -5
- package/dist/plan/index.d.mts +2 -2
- package/dist/plan/index.mjs +2 -2
- package/dist/policy/Policy.d.mts +1 -1
- package/dist/policy/Policy.mjs +1 -1
- package/dist/pose.inpage-CLq7Mfdr.mjs +2042 -0
- package/dist/pose.inpage-CLq7Mfdr.mjs.map +1 -0
- package/dist/presentation/Presentation.d.mts +8 -1
- package/dist/presentation/Presentation.mjs +3 -1
- package/dist/presentation/Presentation.mjs.map +1 -1
- package/dist/presentation/Stage.d.mts +1 -1
- package/dist/providers/Cdp.d.mts +2 -2
- package/dist/providers/Cdp.mjs +1 -1
- package/dist/providers/Chromium.d.mts +1 -1
- package/dist/providers/Chromium.mjs +1 -1
- package/dist/stillness/Stillness.d.mts +1 -1
- package/dist/stillness/Stillness.mjs +1 -1
- package/dist/testing/index.d.mts +4 -30
- package/dist/testing/index.mjs +8 -2
- package/dist/testing/index.mjs.map +1 -1
- package/dist/workerd/Cdp.d.mts +2 -2
- package/dist/workerd/Cdp.mjs +1 -1
- package/package.json +32 -2
- package/src/Browser.ts +11 -6
- package/src/BrowserEvent.ts +19 -0
- package/src/Change.ts +7 -1
- package/src/Layout.ts +116 -0
- package/src/Matching.ts +24 -15
- package/src/Overlay.ts +37 -0
- package/src/Page.ts +45 -0
- package/src/PageTime.ts +47 -0
- package/src/Pose.ts +50 -0
- package/src/Site.ts +124 -0
- package/src/Style.ts +36 -0
- package/src/film/Film.ts +384 -0
- package/src/index.ts +4 -0
- package/src/internal/input/perform.ts +31 -3
- package/src/internal/input/pointer.ts +7 -4
- package/src/internal/input/targets.ts +1 -1
- package/src/internal/page/bridge.ts +65 -33
- package/src/internal/page/clock.inpage.ts +306 -0
- package/src/internal/page/compose.inpage.ts +101 -0
- package/src/internal/page/context.ts +2 -0
- package/src/internal/page/overlay.inpage.ts +96 -0
- package/src/internal/page/overlay.ts +89 -0
- package/src/internal/page/page.ts +12 -0
- package/src/internal/page/pose.inpage.ts +200 -0
- package/src/internal/page/pose.ts +80 -0
- package/src/internal/page/time.inpage.ts +49 -0
- package/src/internal/page/time.ts +122 -0
- package/src/internal/page/viewport.ts +3 -2
- package/src/internal/pictures/pictures.ts +93 -32
- package/src/internal/reading/layout.inpage.ts +193 -0
- package/src/internal/reading/layout.ts +101 -0
- package/src/internal/reading/names.inpage.ts +15 -0
- package/src/internal/reading/outline.inpage.ts +2 -18
- package/src/internal/reading/reading.ts +22 -2
- package/src/internal/reading/ready.inpage.ts +18 -23
- package/src/internal/reading/ready.ts +23 -3
- package/src/internal/reading/text.inpage.ts +1 -14
- package/src/internal/timeline/changes.inpage.ts +7 -15
- package/src/internal/timeline/changes.ts +14 -1
- package/src/internal/timeline/record.inpage.ts +15 -6
- package/src/presentation/Presentation.ts +13 -0
- package/src/stillness/Pixels.ts +26 -0
- package/src/stillness/Stillness.ts +30 -5
- package/src/testing/page.ts +5 -0
- package/dist/Browser-BKPAbyys.mjs.map +0 -1
- package/dist/Page-BF5izr8R.mjs.map +0 -1
- package/dist/Stillness-CNlvayIo.mjs.map +0 -1
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { S as SubjectContext } from "./BrowserEvent-C2p-NwuU.mjs";
|
|
2
|
+
import { i as Point } from "./Geometry-DJx9qrYy.mjs";
|
|
3
|
+
import { R as Picks, s as FindQuery } from "./Page-CLzh5E9w.mjs";
|
|
4
|
+
//#region src/internal/reading/names.inpage.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* In the page: the foundation the other parts build on. It gives elements refs and reads the
|
|
7
|
+
* roles, names and states that the outline and the input checks report.
|
|
8
|
+
*
|
|
9
|
+
* Every `*.inpage.ts` part runs inside the page. The page receives it as source text, so it must
|
|
10
|
+
* stay self-contained: it uses only its parameters, the DOM and what it defines itself.
|
|
11
|
+
*/
|
|
12
|
+
declare const elements: () => {
|
|
13
|
+
adopt: (node: Node) => WeakSet<Node>;
|
|
14
|
+
clean: (value: string | null | undefined, max?: number) => string;
|
|
15
|
+
isInput: (element: Element) => element is HTMLInputElement;
|
|
16
|
+
isTextArea: (element: Element) => element is HTMLTextAreaElement;
|
|
17
|
+
isSelect: (element: Element) => element is HTMLSelectElement;
|
|
18
|
+
isFrame: (element: Element) => element is HTMLIFrameElement;
|
|
19
|
+
isHtml: (element: Element) => element is HTMLElement;
|
|
20
|
+
isButton: (element: Element) => element is HTMLButtonElement;
|
|
21
|
+
isLabel: (element: Element) => element is HTMLLabelElement;
|
|
22
|
+
textOf: (element: Element) => string;
|
|
23
|
+
isElement: (node: Node) => node is Element;
|
|
24
|
+
isDocument: (node: Node) => node is Document;
|
|
25
|
+
isOwn: (node: Node) => boolean;
|
|
26
|
+
textEntry: (element: Element) => boolean;
|
|
27
|
+
};
|
|
28
|
+
declare const names: (native: ReturnType<typeof elements>) => {
|
|
29
|
+
adopt: (node: Node) => WeakSet<Node>;
|
|
30
|
+
clean: (value: string | null | undefined, max?: number) => string;
|
|
31
|
+
isInput: (element: Element) => element is HTMLInputElement;
|
|
32
|
+
isTextArea: (element: Element) => element is HTMLTextAreaElement;
|
|
33
|
+
isSelect: (element: Element) => element is HTMLSelectElement;
|
|
34
|
+
isFrame: (element: Element) => element is HTMLIFrameElement;
|
|
35
|
+
isHtml: (element: Element) => element is HTMLElement;
|
|
36
|
+
isButton: (element: Element) => element is HTMLButtonElement;
|
|
37
|
+
isLabel: (element: Element) => element is HTMLLabelElement;
|
|
38
|
+
textOf: (element: Element) => string;
|
|
39
|
+
isElement: (node: Node) => node is Element;
|
|
40
|
+
isDocument: (node: Node) => node is Document;
|
|
41
|
+
isOwn: (node: Node) => boolean;
|
|
42
|
+
textEntry: (element: Element) => boolean;
|
|
43
|
+
activeElement: () => Element | null;
|
|
44
|
+
containers: Record<string, string>;
|
|
45
|
+
describe: (element: Element) => string;
|
|
46
|
+
inCurrentDocument: (element: Element) => boolean;
|
|
47
|
+
interactiveRoles: Set<string>;
|
|
48
|
+
isDisabled: (element: Element) => boolean;
|
|
49
|
+
isRoot: (node: Node) => node is Document | ShadowRoot;
|
|
50
|
+
isSecret: (element: Element) => boolean;
|
|
51
|
+
lookup: (ref: string) => Element | undefined;
|
|
52
|
+
nameOf: (element: Element, role: string | null) => string;
|
|
53
|
+
parentOf: (element: Element) => Element | null;
|
|
54
|
+
refFor: (element: Element) => string;
|
|
55
|
+
refs: {
|
|
56
|
+
next: number;
|
|
57
|
+
};
|
|
58
|
+
roleOf: (element: Element, structural?: boolean) => string | null;
|
|
59
|
+
};
|
|
60
|
+
type Names = ReturnType<typeof names>;
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/internal/reading/walk.inpage.d.ts
|
|
63
|
+
interface Visitor<S> {
|
|
64
|
+
/** The state for the element's children, or undefined to leave them out. */
|
|
65
|
+
readonly enter: (element: Element, style: CSSStyleDeclaration, rect: DOMRect, state: S) => S | undefined;
|
|
66
|
+
/** Whether to visit a child of an element entered with `state`; all by default. */
|
|
67
|
+
readonly admit?: ((child: Element, state: S) => boolean) | undefined;
|
|
68
|
+
/** Each text node of an entered element, in order among its children. */
|
|
69
|
+
readonly text?: ((node: Node, state: S) => void) | undefined;
|
|
70
|
+
/** After the children of an element `enter` went into, with the state it returned. */
|
|
71
|
+
readonly leave?: ((element: Element, state: S) => void) | undefined;
|
|
72
|
+
/** A subtree left out because its box lies outside the viewport, in top-document pixels. */
|
|
73
|
+
readonly outside?: ((rect: DOMRect) => void) | undefined;
|
|
74
|
+
}
|
|
75
|
+
declare const walk: (names: Names) => {
|
|
76
|
+
acts: (element: Element, role: string | null) => boolean;
|
|
77
|
+
boxOf: (element: Element) => {
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
width: number;
|
|
81
|
+
height: number;
|
|
82
|
+
};
|
|
83
|
+
controlOf: (hit: Element) => Element;
|
|
84
|
+
hitAt: (root: Document | ShadowRoot, x: number, y: number) => Element | null;
|
|
85
|
+
inView: (rect: DOMRect, width?: number, height?: number) => boolean;
|
|
86
|
+
visible: (element: Element) => boolean;
|
|
87
|
+
visit: <S>(root: Element | null, viewport: boolean, state: S, visitor: Visitor<S>) => void;
|
|
88
|
+
};
|
|
89
|
+
type Walk = ReturnType<typeof walk>;
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/internal/reading/context.inpage.d.ts
|
|
92
|
+
/** What one read has learnt of the page: each table's header row and each tree's headings. */
|
|
93
|
+
interface Known {
|
|
94
|
+
readonly headers: Map<Element, Element | null>;
|
|
95
|
+
readonly headings: Map<Node, ReadonlyArray<Element>>;
|
|
96
|
+
}
|
|
97
|
+
declare const context: (names: Names, walked: Walk) => {
|
|
98
|
+
contextOf: (element: Element, read?: Known) => SubjectContext;
|
|
99
|
+
groups: string;
|
|
100
|
+
headingBefore: (target: Element, scope: ParentNode, read?: Known) => string | undefined;
|
|
101
|
+
known: () => Known;
|
|
102
|
+
textBeside: (target: Element, scope: Node, backwards: boolean) => string;
|
|
103
|
+
treeOf: (element: Element) => ParentNode;
|
|
104
|
+
};
|
|
105
|
+
type ContextReader = ReturnType<typeof context>;
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/internal/reading/subjects.inpage.d.ts
|
|
108
|
+
declare const states: (names: Names) => (element: Element, role: string | null) => {
|
|
109
|
+
disabled: boolean;
|
|
110
|
+
checked: boolean | undefined;
|
|
111
|
+
expanded: boolean | undefined;
|
|
112
|
+
selected: boolean | undefined;
|
|
113
|
+
pressed: boolean | undefined;
|
|
114
|
+
focused: boolean;
|
|
115
|
+
level: number | undefined;
|
|
116
|
+
};
|
|
117
|
+
declare const subjects: (names: Names, walked: Walk, matching: Match, placing: ContextReader, stateOf: ReturnType<typeof states>) => {
|
|
118
|
+
find: (request: FindRequest) => {
|
|
119
|
+
invalid: string;
|
|
120
|
+
found?: undefined;
|
|
121
|
+
} | {
|
|
122
|
+
invalid?: undefined;
|
|
123
|
+
found: {
|
|
124
|
+
ref: string;
|
|
125
|
+
subject: {
|
|
126
|
+
role: string | null;
|
|
127
|
+
name: string;
|
|
128
|
+
tag: string;
|
|
129
|
+
context: {
|
|
130
|
+
readonly row?: string | undefined;
|
|
131
|
+
readonly column?: string | undefined;
|
|
132
|
+
readonly label?: string | undefined;
|
|
133
|
+
readonly heading?: string | undefined;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
box: {
|
|
137
|
+
x: number;
|
|
138
|
+
y: number;
|
|
139
|
+
width: number;
|
|
140
|
+
height: number;
|
|
141
|
+
};
|
|
142
|
+
inViewport: boolean;
|
|
143
|
+
state: {
|
|
144
|
+
disabled: boolean;
|
|
145
|
+
checked: boolean | undefined;
|
|
146
|
+
expanded: boolean | undefined;
|
|
147
|
+
selected: boolean | undefined;
|
|
148
|
+
pressed: boolean | undefined;
|
|
149
|
+
focused: boolean;
|
|
150
|
+
level: number | undefined;
|
|
151
|
+
};
|
|
152
|
+
}[];
|
|
153
|
+
};
|
|
154
|
+
elementsOf: (request: FindRequest) => ReadonlyArray<Element> | {
|
|
155
|
+
readonly invalid: string;
|
|
156
|
+
};
|
|
157
|
+
isControl: (element: Element, role: string | null, style: CSSStyleDeclaration, rect: DOMRect, insidePointer: boolean) => boolean;
|
|
158
|
+
stateOf: (element: Element, role: string | null) => {
|
|
159
|
+
disabled: boolean;
|
|
160
|
+
checked: boolean | undefined;
|
|
161
|
+
expanded: boolean | undefined;
|
|
162
|
+
selected: boolean | undefined;
|
|
163
|
+
pressed: boolean | undefined;
|
|
164
|
+
focused: boolean;
|
|
165
|
+
level: number | undefined;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
type Subjects = ReturnType<typeof subjects>;
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/internal/reading/layout.inpage.d.ts
|
|
171
|
+
interface PickRequest extends FindRequest {
|
|
172
|
+
readonly id: string;
|
|
173
|
+
readonly choose: "first" | "last" | "smallest" | "largest";
|
|
174
|
+
readonly words: Wanted | null;
|
|
175
|
+
}
|
|
176
|
+
declare const layout: (names: Names, walked: Walk, subjected: Subjects, matching: Match, placing: ContextReader) => {
|
|
177
|
+
read: (picks: ReadonlyArray<PickRequest>) => {
|
|
178
|
+
invalid: string;
|
|
179
|
+
layout?: undefined;
|
|
180
|
+
} | {
|
|
181
|
+
invalid?: undefined;
|
|
182
|
+
layout: {
|
|
183
|
+
url: string;
|
|
184
|
+
viewport: {
|
|
185
|
+
width: number;
|
|
186
|
+
height: number;
|
|
187
|
+
};
|
|
188
|
+
scroll: {
|
|
189
|
+
x: number;
|
|
190
|
+
y: number;
|
|
191
|
+
};
|
|
192
|
+
scale: number;
|
|
193
|
+
places: {
|
|
194
|
+
id: string;
|
|
195
|
+
ref: string;
|
|
196
|
+
subject: {
|
|
197
|
+
role: string | null;
|
|
198
|
+
name: string;
|
|
199
|
+
tag: string;
|
|
200
|
+
context: {
|
|
201
|
+
readonly row?: string | undefined;
|
|
202
|
+
readonly column?: string | undefined;
|
|
203
|
+
readonly label?: string | undefined;
|
|
204
|
+
readonly heading?: string | undefined;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
box: {
|
|
208
|
+
x: number;
|
|
209
|
+
y: number;
|
|
210
|
+
width: number;
|
|
211
|
+
height: number;
|
|
212
|
+
};
|
|
213
|
+
fixed: boolean;
|
|
214
|
+
words: {
|
|
215
|
+
text: string;
|
|
216
|
+
box: {
|
|
217
|
+
x: number;
|
|
218
|
+
y: number;
|
|
219
|
+
width: number;
|
|
220
|
+
height: number;
|
|
221
|
+
};
|
|
222
|
+
}[] | undefined;
|
|
223
|
+
}[];
|
|
224
|
+
missing: string[];
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
type Layouts = ReturnType<typeof layout>;
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/Matching.d.ts
|
|
231
|
+
/** A string, or a pattern sent to the page as its source and flags. */
|
|
232
|
+
type Wanted = string | {
|
|
233
|
+
readonly source: string;
|
|
234
|
+
readonly flags: string;
|
|
235
|
+
};
|
|
236
|
+
interface FindRequest {
|
|
237
|
+
readonly selector: string | null;
|
|
238
|
+
readonly state: "visible" | "enabled";
|
|
239
|
+
readonly role: string | null;
|
|
240
|
+
readonly name: Wanted | null;
|
|
241
|
+
readonly text: Wanted | null;
|
|
242
|
+
readonly near: string | null;
|
|
243
|
+
readonly at: Point | null;
|
|
244
|
+
readonly scope: "viewport" | "document";
|
|
245
|
+
}
|
|
246
|
+
/** A public query in its serializable, fully specified form. */
|
|
247
|
+
declare const request: (query: FindQuery, scope: FindRequest["scope"]) => FindRequest;
|
|
248
|
+
/** Layout picks in their serializable form. */
|
|
249
|
+
declare const pickRequests: (picks: Picks) => ReadonlyArray<PickRequest>;
|
|
250
|
+
/** What a query is matched against, read only when a rule needs it. */
|
|
251
|
+
interface Candidate {
|
|
252
|
+
readonly role: string | null;
|
|
253
|
+
readonly name: () => string;
|
|
254
|
+
readonly text: () => string;
|
|
255
|
+
readonly context: () => SubjectContext;
|
|
256
|
+
}
|
|
257
|
+
declare const match: () => {
|
|
258
|
+
compile: (request: Pick<FindRequest, "role" | "name" | "text" | "near">) => (candidate: Candidate) => boolean;
|
|
259
|
+
holds: (text: string, value: string) => boolean;
|
|
260
|
+
normalize: (value: string) => string;
|
|
261
|
+
mark: (observations: ReadonlyArray<string>) => string;
|
|
262
|
+
};
|
|
263
|
+
type Match = ReturnType<typeof match>;
|
|
264
|
+
//#endregion
|
|
265
|
+
export { match as a, Layouts as c, Walk as d, Names as f, Wanted as i, Subjects as l, FindRequest as n, pickRequests as o, Match as r, request as s, Candidate as t, ContextReader as u };
|
|
266
|
+
//# sourceMappingURL=Matching-MtcWZ_hA.d.mts.map
|
package/dist/Matching.d.mts
CHANGED
|
@@ -1,37 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { s as FindQuery } from "./Page-CvsOEorc.mjs";
|
|
4
|
-
//#region src/Matching.d.ts
|
|
5
|
-
/** A string, or a pattern sent to the page as its source and flags. */
|
|
6
|
-
export type Wanted = string | {
|
|
7
|
-
readonly source: string;
|
|
8
|
-
readonly flags: string;
|
|
9
|
-
};
|
|
10
|
-
export interface FindRequest {
|
|
11
|
-
readonly selector: string | null;
|
|
12
|
-
readonly state: "visible" | "enabled";
|
|
13
|
-
readonly role: string | null;
|
|
14
|
-
readonly name: Wanted | null;
|
|
15
|
-
readonly text: Wanted | null;
|
|
16
|
-
readonly near: string | null;
|
|
17
|
-
readonly at: Point | null;
|
|
18
|
-
readonly scope: "viewport" | "document";
|
|
19
|
-
}
|
|
20
|
-
/** A public query in its serializable, fully specified form. */
|
|
21
|
-
export declare const request: (query: FindQuery, scope: FindRequest["scope"]) => FindRequest;
|
|
22
|
-
/** What a query is matched against, read only when a rule needs it. */
|
|
23
|
-
export interface Candidate {
|
|
24
|
-
readonly role: string | null;
|
|
25
|
-
readonly name: () => string;
|
|
26
|
-
readonly text: () => string;
|
|
27
|
-
readonly context: () => SubjectContext;
|
|
28
|
-
}
|
|
29
|
-
export declare const match: () => {
|
|
30
|
-
compile: (request: Pick<FindRequest, "role" | "name" | "text" | "near">) => (candidate: Candidate) => boolean;
|
|
31
|
-
holds: (text: string, value: string) => boolean;
|
|
32
|
-
normalize: (value: string) => string;
|
|
33
|
-
mark: (observations: ReadonlyArray<string>) => string;
|
|
34
|
-
};
|
|
35
|
-
export type Match = ReturnType<typeof match>;
|
|
36
|
-
//#endregion
|
|
37
|
-
//# sourceMappingURL=Matching.d.mts.map
|
|
1
|
+
import { a as match, i as Wanted, n as FindRequest, o as pickRequests, r as Match, s as request, t as Candidate } from "./Matching-MtcWZ_hA.mjs";
|
|
2
|
+
export { Candidate, FindRequest, Match, Wanted, match, pickRequests, request };
|
package/dist/Matching.mjs
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
//#region src/Matching.ts
|
|
2
|
+
const wanted = (value) => value instanceof RegExp ? {
|
|
3
|
+
source: value.source,
|
|
4
|
+
flags: value.flags
|
|
5
|
+
} : value ?? null;
|
|
2
6
|
/** A public query in its serializable, fully specified form. */
|
|
3
|
-
const request = (query, scope) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
const request = (query, scope) => ({
|
|
8
|
+
selector: query.selector ?? null,
|
|
9
|
+
state: query.state ?? "visible",
|
|
10
|
+
role: query.role ?? null,
|
|
11
|
+
name: wanted(query.name),
|
|
12
|
+
text: wanted(query.text),
|
|
13
|
+
near: query.near ?? null,
|
|
14
|
+
at: query.at ?? null,
|
|
15
|
+
scope: query.scope ?? scope
|
|
16
|
+
});
|
|
17
|
+
/** Layout picks in their serializable form. */
|
|
18
|
+
const pickRequests = (picks) => Object.entries(picks).map(([id, pick]) => ({
|
|
19
|
+
...request(pick, "document"),
|
|
20
|
+
id,
|
|
21
|
+
choose: pick.choose ?? "first",
|
|
22
|
+
words: wanted(pick.words)
|
|
23
|
+
}));
|
|
19
24
|
const match = () => {
|
|
20
25
|
/**
|
|
21
26
|
* How names, text and context compare: one Unicode form, without invisible format characters,
|
|
@@ -67,6 +72,6 @@ const match = () => {
|
|
|
67
72
|
};
|
|
68
73
|
};
|
|
69
74
|
//#endregion
|
|
70
|
-
export { match, request };
|
|
75
|
+
export { match, pickRequests, request };
|
|
71
76
|
|
|
72
77
|
//# sourceMappingURL=Matching.mjs.map
|
package/dist/Matching.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Matching.mjs","names":[],"sources":["../src/Matching.ts"],"sourcesContent":["/**\n * In the page: the rules `find` matches by. It touches no DOM, so it also runs outside a page.\n *\n * - A role matches when it is the same token, ignoring case and the space around it.\n * - A name given as a string matches when the two read the same once their spaces are collapsed,\n * their case folded and their characters given one Unicode form; a pattern matches when it\n * finds itself in the name.\n * - Text matches when it appears, read the same way, in the element's text.\n * - `near` matches when its words appear, whole and in order, in any of the element's context:\n * its row, column, label or heading. Replay chooses among candidates by the same rule.\n */\nimport type { SubjectContext } from \"./BrowserEvent.ts\";\nimport type { Point } from \"./Geometry.ts\";\nimport type { FindQuery } from \"./Page.ts\";\n\n/** A string, or a pattern sent to the page as its source and flags. */\nexport type Wanted = string | { readonly source: string; readonly flags: string };\n\nexport interface FindRequest {\n readonly selector: string | null;\n readonly state: \"visible\" | \"enabled\";\n readonly role: string | null;\n readonly name: Wanted | null;\n readonly text: Wanted | null;\n readonly near: string | null;\n readonly at: Point | null;\n readonly scope: \"viewport\" | \"document\";\n}\n\
|
|
1
|
+
{"version":3,"file":"Matching.mjs","names":[],"sources":["../src/Matching.ts"],"sourcesContent":["/**\n * In the page: the rules `find` matches by. It touches no DOM, so it also runs outside a page.\n *\n * - A role matches when it is the same token, ignoring case and the space around it.\n * - A name given as a string matches when the two read the same once their spaces are collapsed,\n * their case folded and their characters given one Unicode form; a pattern matches when it\n * finds itself in the name.\n * - Text matches when it appears, read the same way, in the element's text.\n * - `near` matches when its words appear, whole and in order, in any of the element's context:\n * its row, column, label or heading. Replay chooses among candidates by the same rule.\n */\nimport type { SubjectContext } from \"./BrowserEvent.ts\";\nimport type { Point } from \"./Geometry.ts\";\nimport type { PickRequest } from \"./internal/reading/layout.inpage.ts\";\nimport type { Picks } from \"./Layout.ts\";\nimport type { FindQuery } from \"./Page.ts\";\n\n/** A string, or a pattern sent to the page as its source and flags. */\nexport type Wanted = string | { readonly source: string; readonly flags: string };\n\nexport interface FindRequest {\n readonly selector: string | null;\n readonly state: \"visible\" | \"enabled\";\n readonly role: string | null;\n readonly name: Wanted | null;\n readonly text: Wanted | null;\n readonly near: string | null;\n readonly at: Point | null;\n readonly scope: \"viewport\" | \"document\";\n}\n\nconst wanted = (value: string | RegExp | undefined): Wanted | null =>\n value instanceof RegExp ? { source: value.source, flags: value.flags } : (value ?? null);\n\n/** A public query in its serializable, fully specified form. */\nexport const request = (query: FindQuery, scope: FindRequest[\"scope\"]): FindRequest => ({\n selector: query.selector ?? null,\n state: query.state ?? \"visible\",\n role: query.role ?? null,\n name: wanted(query.name),\n text: wanted(query.text),\n near: query.near ?? null,\n at: query.at ?? null,\n scope: query.scope ?? scope,\n});\n\n/** Layout picks in their serializable form. */\nexport const pickRequests = (picks: Picks): ReadonlyArray<PickRequest> =>\n Object.entries(picks).map(([id, pick]) => ({\n ...request(pick, \"document\"),\n id,\n choose: pick.choose ?? \"first\",\n words: wanted(pick.words),\n }));\n\n/** What a query is matched against, read only when a rule needs it. */\nexport interface Candidate {\n readonly role: string | null;\n readonly name: () => string;\n readonly text: () => string;\n readonly context: () => SubjectContext;\n}\n\nexport const match = () => {\n /**\n * How names, text and context compare: one Unicode form, without invisible format characters,\n * spaces collapsed, and case folded upper first, so that \"ß\" and \"SS\" read the same.\n */\n const normalize = (value: string): string =>\n value\n .normalize(\"NFKC\")\n .replace(/\\p{Cf}/gu, \"\")\n .replace(/\\s+/g, \" \")\n .trim()\n .toUpperCase()\n .toLowerCase();\n\n /** A string that reads the same, or, unless `whole`, appears within; or a pattern found within. */\n const rule = (wanted: Wanted, whole: boolean) => {\n if (typeof wanted !== \"string\") {\n // `g` and `y` keep a position from one test to the next, so one pattern would answer\n // differently for each element. A pattern is tried on the text as the page shows it.\n const found = new RegExp(wanted.source, wanted.flags.replace(/[gy]/g, \"\"));\n\n return (value: string) => found.test(value.replace(/\\s+/g, \" \").trim());\n }\n const target = normalize(wanted);\n\n return whole\n ? (value: string) => normalize(value) === target\n : (value: string) => normalize(value).includes(target);\n };\n\n /** Whether a value's words appear, whole and in order, among a text's: \"BTC\" not in \"WBTC\". */\n const holds = (text: string, value: string) =>\n ` ${normalize(text)} `.includes(` ${normalize(value)} `);\n\n /** Whether a candidate meets every rule a query gives; a rule left out always holds. */\n const compile = (request: Pick<FindRequest, \"role\" | \"name\" | \"text\" | \"near\">) => {\n const role = request.role === null ? null : normalize(request.role);\n const name = request.name === null ? null : rule(request.name, true);\n const text = request.text === null ? null : rule(request.text, false);\n const { near } = request;\n\n return (candidate: Candidate): boolean => {\n if (role !== null && normalize(candidate.role ?? \"\") !== role) return false;\n if (text !== null && !text(candidate.text())) return false;\n if (name !== null && !name(candidate.name())) return false;\n if (near === null) return true;\n const { row, column, label, heading } = candidate.context();\n\n return [row, column, label, heading].some(\n (value) => value !== undefined && holds(value, near),\n );\n };\n };\n\n /** A comparison token for ordered observations, without retaining their text. */\n const mark = (observations: ReadonlyArray<string>): string => {\n let hash = 0x811c9dc5;\n\n for (const shown of observations)\n for (let index = 0; index < shown.length; index++)\n hash = Math.imul(hash ^ shown.charCodeAt(index), 0x01000193);\n\n return `${observations.length}:${(hash >>> 0).toString(16)}`;\n };\n\n return { compile, holds, normalize, mark };\n};\n\nexport type Match = ReturnType<typeof match>;\n"],"mappings":";AA+BA,MAAM,UAAU,UACd,iBAAiB,SAAS;CAAE,QAAQ,MAAM;CAAQ,OAAO,MAAM;AAAM,IAAK,SAAS;;AAGrF,MAAa,WAAW,OAAkB,WAA8C;CACtF,UAAU,MAAM,YAAY;CAC5B,OAAO,MAAM,SAAS;CACtB,MAAM,MAAM,QAAQ;CACpB,MAAM,OAAO,MAAM,IAAI;CACvB,MAAM,OAAO,MAAM,IAAI;CACvB,MAAM,MAAM,QAAQ;CACpB,IAAI,MAAM,MAAM;CAChB,OAAO,MAAM,SAAS;AACxB;;AAGA,MAAa,gBAAgB,UAC3B,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,WAAW;CACzC,GAAG,QAAQ,MAAM,UAAU;CAC3B;CACA,QAAQ,KAAK,UAAU;CACvB,OAAO,OAAO,KAAK,KAAK;AAC1B,EAAE;AAUJ,MAAa,cAAc;;;;;CAKzB,MAAM,aAAa,UACjB,MACG,UAAU,MAAM,CAAC,CACjB,QAAQ,YAAY,EAAE,CAAC,CACvB,QAAQ,QAAQ,GAAG,CAAC,CACpB,KAAK,CAAC,CACN,YAAY,CAAC,CACb,YAAY;;CAGjB,MAAM,QAAQ,QAAgB,UAAmB;EAC/C,IAAI,OAAO,WAAW,UAAU;GAG9B,MAAM,QAAQ,IAAI,OAAO,OAAO,QAAQ,OAAO,MAAM,QAAQ,SAAS,EAAE,CAAC;GAEzE,QAAQ,UAAkB,MAAM,KAAK,MAAM,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC;EACxE;EACA,MAAM,SAAS,UAAU,MAAM;EAE/B,OAAO,SACF,UAAkB,UAAU,KAAK,MAAM,UACvC,UAAkB,UAAU,KAAK,CAAC,CAAC,SAAS,MAAM;CACzD;;CAGA,MAAM,SAAS,MAAc,UAC3B,IAAI,UAAU,IAAI,EAAE,GAAG,SAAS,IAAI,UAAU,KAAK,EAAE,EAAE;;CAGzD,MAAM,WAAW,YAAkE;EACjF,MAAM,OAAO,QAAQ,SAAS,OAAO,OAAO,UAAU,QAAQ,IAAI;EAClE,MAAM,OAAO,QAAQ,SAAS,OAAO,OAAO,KAAK,QAAQ,MAAM,IAAI;EACnE,MAAM,OAAO,QAAQ,SAAS,OAAO,OAAO,KAAK,QAAQ,MAAM,KAAK;EACpE,MAAM,EAAE,SAAS;EAEjB,QAAQ,cAAkC;GACxC,IAAI,SAAS,QAAQ,UAAU,UAAU,QAAQ,EAAE,MAAM,MAAM,OAAO;GACtE,IAAI,SAAS,QAAQ,CAAC,KAAK,UAAU,KAAK,CAAC,GAAG,OAAO;GACrD,IAAI,SAAS,QAAQ,CAAC,KAAK,UAAU,KAAK,CAAC,GAAG,OAAO;GACrD,IAAI,SAAS,MAAM,OAAO;GAC1B,MAAM,EAAE,KAAK,QAAQ,OAAO,YAAY,UAAU,QAAQ;GAE1D,OAAO;IAAC;IAAK;IAAQ;IAAO;GAAO,CAAC,CAAC,MAClC,UAAU,UAAU,KAAA,KAAa,MAAM,OAAO,IAAI,CACrD;EACF;CACF;;CAGA,MAAM,QAAQ,iBAAgD;EAC5D,IAAI,OAAO;EAEX,KAAK,MAAM,SAAS,cAClB,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SACxC,OAAO,KAAK,KAAK,OAAO,MAAM,WAAW,KAAK,GAAG,QAAU;EAE/D,OAAO,GAAG,aAAa,OAAO,IAAI,SAAS,EAAA,CAAG,SAAS,EAAE;CAC3D;CAEA,OAAO;EAAE;EAAS;EAAO;EAAW;CAAK;AAC3C"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { t as BrowserError } from "./BrowserError-BlcmLVzn.mjs";
|
|
2
|
+
import { r as Box } from "./BrowserEvent-C2p-NwuU.mjs";
|
|
3
|
+
import { Effect, Schema } from "effect";
|
|
4
|
+
declare namespace Overlay_d_exports {
|
|
5
|
+
export { Content, Overlay };
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* What the overlay shows. `Svg` is an SVG document sized to the viewport, whose own `viewBox` maps
|
|
9
|
+
* any design space onto it; its scripts and event handlers are dropped. `Empty` shows nothing.
|
|
10
|
+
*/
|
|
11
|
+
declare const Content: Schema.TaggedUnion<{
|
|
12
|
+
readonly Empty: Schema.TaggedStruct<"Empty", {}>;
|
|
13
|
+
readonly Svg: Schema.TaggedStruct<"Svg", {
|
|
14
|
+
readonly markup: Schema.String;
|
|
15
|
+
}>;
|
|
16
|
+
}>;
|
|
17
|
+
type Content = typeof Content.Type;
|
|
18
|
+
interface Overlay {
|
|
19
|
+
/**
|
|
20
|
+
* Show `content` in place of what was shown, in one call to the page, after the actions asked
|
|
21
|
+
* before it. Says where the drawing's top-level parts are, in viewport CSS pixels.
|
|
22
|
+
*/
|
|
23
|
+
readonly draw: (content: Content) => Effect.Effect<ReadonlyArray<Box>, BrowserError>;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { Overlay as n, Overlay_d_exports as r, Content as t };
|
|
27
|
+
//# sourceMappingURL=Overlay-CoGw5tL_.d.mts.map
|
package/dist/Overlay.mjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
//#region src/Overlay.ts
|
|
4
|
+
/**
|
|
5
|
+
* A layer over a page that the library draws a caller's content into, without knowing what it
|
|
6
|
+
* shows: a pointer, a ring round what an agent is about to press, a caption, a character. It shows
|
|
7
|
+
* in screenshots, screencasts and a live view alike. The library's own readers never read it:
|
|
8
|
+
* `find`, `snapshot`, `layout`, `text`, `changes`, `ready` and stillness see the page as if it
|
|
9
|
+
* were not there, and input passes through it to the page.
|
|
10
|
+
*
|
|
11
|
+
* A page has one overlay at a time, for a scope. It sits above the page's own layers but beneath
|
|
12
|
+
* its top layer (a modal dialog, a popover), in viewport CSS pixels, and undoes a zoom the page
|
|
13
|
+
* sets on its root. Each new document starts without it, and it is drawn again there, with what
|
|
14
|
+
* it last showed, once the document has loaded. It is gone when its scope closes.
|
|
15
|
+
*
|
|
16
|
+
* @since 0.3.0
|
|
17
|
+
*/
|
|
18
|
+
var Overlay_exports = /* @__PURE__ */ __exportAll({ Content: () => Content });
|
|
19
|
+
/**
|
|
20
|
+
* What the overlay shows. `Svg` is an SVG document sized to the viewport, whose own `viewBox` maps
|
|
21
|
+
* any design space onto it; its scripts and event handlers are dropped. `Empty` shows nothing.
|
|
22
|
+
*/
|
|
23
|
+
const Content = Schema.TaggedUnion({
|
|
24
|
+
Svg: { markup: Schema.String },
|
|
25
|
+
Empty: {}
|
|
26
|
+
});
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Content, Overlay_exports as t };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=Overlay.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Overlay.mjs","names":[],"sources":["../src/Overlay.ts"],"sourcesContent":["/**\n * A layer over a page that the library draws a caller's content into, without knowing what it\n * shows: a pointer, a ring round what an agent is about to press, a caption, a character. It shows\n * in screenshots, screencasts and a live view alike. The library's own readers never read it:\n * `find`, `snapshot`, `layout`, `text`, `changes`, `ready` and stillness see the page as if it\n * were not there, and input passes through it to the page.\n *\n * A page has one overlay at a time, for a scope. It sits above the page's own layers but beneath\n * its top layer (a modal dialog, a popover), in viewport CSS pixels, and undoes a zoom the page\n * sets on its root. Each new document starts without it, and it is drawn again there, with what\n * it last showed, once the document has loaded. It is gone when its scope closes.\n *\n * @since 0.3.0\n */\nimport { type Effect, Schema } from \"effect\";\n\nimport type { BrowserError } from \"./BrowserError.ts\";\nimport type { Box } from \"./BrowserEvent.ts\";\n\n/**\n * What the overlay shows. `Svg` is an SVG document sized to the viewport, whose own `viewBox` maps\n * any design space onto it; its scripts and event handlers are dropped. `Empty` shows nothing.\n */\nexport const Content = Schema.TaggedUnion({\n Svg: { markup: Schema.String },\n Empty: {},\n});\n\nexport type Content = typeof Content.Type;\n\nexport interface Overlay {\n /**\n * Show `content` in place of what was shown, in one call to the page, after the actions asked\n * before it. Says where the drawing's top-level parts are, in viewport CSS pixels.\n */\n readonly draw: (content: Content) => Effect.Effect<ReadonlyArray<Box>, BrowserError>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,UAAU,OAAO,YAAY;CACxC,KAAK,EAAE,QAAQ,OAAO,OAAO;CAC7B,OAAO,CAAC;AACV,CAAC"}
|
|
@@ -704,6 +704,8 @@ var State = class extends Schema.Class("effect-browser/PageState")({
|
|
|
704
704
|
load: Schema.optional(PageLoaded),
|
|
705
705
|
/** The newest screencast frame, of whichever document it names. */
|
|
706
706
|
frame: Schema.optional(Frame),
|
|
707
|
+
/** Where the overlay's drawing was last drawn, in viewport CSS pixels; absent with none shown. */
|
|
708
|
+
overlay: Schema.optional(Schema.Array(Box)),
|
|
707
709
|
/** The viewport's text as it was last read, with the page's title then. */
|
|
708
710
|
text: Schema.optional(Text)
|
|
709
711
|
}) {};
|
|
@@ -792,4 +794,4 @@ const correlate = (id) => (effect) => Effect.provideService(effect, Correlation,
|
|
|
792
794
|
//#endregion
|
|
793
795
|
export { PreparedInputResultSchema as _, Page_exports as a, evidence as b, State as c, correlate as d, failFast as f, make as g, FailFast as h, InputRequest as i, Text as l, Correlation as m, Fact as n, Region as o, redacted as p, Found as r, ResolvedTarget as s, ElementState as t, Zoom as u, ValidatedInputResultSchema as v, guard as y };
|
|
794
796
|
|
|
795
|
-
//# sourceMappingURL=Page-
|
|
797
|
+
//# sourceMappingURL=Page-BaAOshxo.mjs.map
|