@gtkx/testing 1.6.0 → 2.0.0-beta.10
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 +47 -44
- package/dist/accessible-native.d.ts +1 -1
- package/dist/accessible-native.d.ts.map +1 -1
- package/dist/accessible-native.js +29 -8
- package/dist/accessible-native.js.map +1 -1
- package/dist/build-queries.d.ts +9 -9
- package/dist/build-queries.d.ts.map +1 -1
- package/dist/build-queries.js +2 -1
- package/dist/build-queries.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -3
- package/dist/config.js.map +1 -1
- package/dist/fire-event.d.ts +3 -3
- package/dist/fire-event.d.ts.map +1 -1
- package/dist/fire-event.js +14 -4
- package/dist/fire-event.js.map +1 -1
- package/dist/matchers.d.ts +52 -56
- package/dist/matchers.d.ts.map +1 -1
- package/dist/matchers.js +4 -16
- package/dist/matchers.js.map +1 -1
- package/dist/queries.d.ts +37 -133
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +48 -136
- package/dist/queries.js.map +1 -1
- package/dist/query-helpers.d.ts +2 -2
- package/dist/query-helpers.d.ts.map +1 -1
- package/dist/query-helpers.js +10 -3
- package/dist/query-helpers.js.map +1 -1
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +4 -0
- package/dist/render.js.map +1 -1
- package/dist/role-helpers.d.ts +1 -1
- package/dist/role-helpers.d.ts.map +1 -1
- package/dist/role-helpers.js +2 -1
- package/dist/role-helpers.js.map +1 -1
- package/dist/screenshot.d.ts +1 -1
- package/dist/screenshot.d.ts.map +1 -1
- package/dist/screenshot.js +26 -8
- package/dist/screenshot.js.map +1 -1
- package/dist/suggestions.d.ts +1 -1
- package/dist/suggestions.d.ts.map +1 -1
- package/dist/suggestions.js +3 -1
- package/dist/suggestions.js.map +1 -1
- package/dist/traversal.d.ts +4 -4
- package/dist/traversal.d.ts.map +1 -1
- package/dist/traversal.js +25 -7
- package/dist/traversal.js.map +1 -1
- package/dist/types.d.ts +10 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/user-event/adjustment.d.ts +2 -14
- package/dist/user-event/adjustment.d.ts.map +1 -1
- package/dist/user-event/adjustment.js +2 -14
- package/dist/user-event/adjustment.js.map +1 -1
- package/dist/user-event/click.d.ts +20 -45
- package/dist/user-event/click.d.ts.map +1 -1
- package/dist/user-event/click.js +31 -50
- package/dist/user-event/click.js.map +1 -1
- package/dist/user-event/controller.d.ts +5 -5
- package/dist/user-event/controller.d.ts.map +1 -1
- package/dist/user-event/controller.js +5 -2
- package/dist/user-event/controller.js.map +1 -1
- package/dist/user-event/gesture.d.ts +9 -43
- package/dist/user-event/gesture.d.ts.map +1 -1
- package/dist/user-event/gesture.js +9 -43
- package/dist/user-event/gesture.js.map +1 -1
- package/dist/user-event/index.d.ts +38 -107
- package/dist/user-event/index.d.ts.map +1 -1
- package/dist/user-event/index.js +29 -30
- package/dist/user-event/index.js.map +1 -1
- package/dist/user-event/keyboard.d.ts +1 -1
- package/dist/user-event/keyboard.d.ts.map +1 -1
- package/dist/user-event/keyboard.js +24 -3
- package/dist/user-event/keyboard.js.map +1 -1
- package/dist/user-event/list-row-click.d.ts +1 -1
- package/dist/user-event/list-row-click.d.ts.map +1 -1
- package/dist/user-event/list-row-click.js +2 -1
- package/dist/user-event/list-row-click.js.map +1 -1
- package/dist/user-event/pointer.d.ts.map +1 -1
- package/dist/user-event/pointer.js +9 -11
- package/dist/user-event/pointer.js.map +1 -1
- package/dist/user-event/selection.d.ts +4 -20
- package/dist/user-event/selection.d.ts.map +1 -1
- package/dist/user-event/selection.js +11 -23
- package/dist/user-event/selection.js.map +1 -1
- package/dist/user-event/text.d.ts +5 -34
- package/dist/user-event/text.d.ts.map +1 -1
- package/dist/user-event/text.js +5 -34
- package/dist/user-event/text.js.map +1 -1
- package/dist/wait-for.d.ts +2 -2
- package/dist/wait-for.d.ts.map +1 -1
- package/dist/wait-for.js +6 -4
- package/dist/wait-for.js.map +1 -1
- package/dist/widget-accessible-properties.d.ts +4 -3
- package/dist/widget-accessible-properties.d.ts.map +1 -1
- package/dist/widget-accessible-properties.js +38 -51
- package/dist/widget-accessible-properties.js.map +1 -1
- package/dist/widget-getters.d.ts +7 -9
- package/dist/widget-getters.d.ts.map +1 -1
- package/dist/widget-getters.js.map +1 -1
- package/dist/widget-target.d.ts +4 -0
- package/dist/widget-target.d.ts.map +1 -0
- package/dist/widget-target.js +9 -0
- package/dist/widget-target.js.map +1 -0
- package/package.json +17 -10
- package/src/accessible-native.ts +45 -9
- package/src/build-queries.ts +60 -30
- package/src/config.ts +1 -3
- package/src/fire-event.ts +32 -8
- package/src/matchers.ts +63 -85
- package/src/queries.ts +94 -156
- package/src/query-helpers.ts +17 -9
- package/src/render.tsx +7 -2
- package/src/role-helpers.ts +3 -1
- package/src/screenshot.ts +49 -8
- package/src/suggestions.ts +3 -1
- package/src/traversal.ts +35 -11
- package/src/types.ts +14 -10
- package/src/user-event/adjustment.ts +2 -14
- package/src/user-event/click.ts +40 -58
- package/src/user-event/controller.ts +8 -5
- package/src/user-event/gesture.ts +9 -43
- package/src/user-event/index.ts +149 -132
- package/src/user-event/keyboard.ts +33 -4
- package/src/user-event/list-row-click.ts +2 -2
- package/src/user-event/pointer.ts +11 -15
- package/src/user-event/selection.ts +15 -25
- package/src/user-event/text.ts +5 -34
- package/src/wait-for.ts +9 -6
- package/src/widget-accessible-properties.ts +61 -69
- package/src/widget-getters.ts +11 -13
- package/src/widget-target.ts +11 -0
package/dist/queries.js
CHANGED
|
@@ -3,7 +3,7 @@ import { buildQueries } from "./build-queries.js";
|
|
|
3
3
|
import { multipleFoundError, notFoundError } from "./errors.js";
|
|
4
4
|
import { getDefaultNormalizer } from "./normalize.js";
|
|
5
5
|
import { findAll, traverse } from "./traversal.js";
|
|
6
|
-
import { getWidgetAccessibleName, getWidgetBusyState, getWidgetDescription, getWidgetDisplayValue, getWidgetExpandedState, getWidgetExternalLabelText, getWidgetLabelText, getWidgetLevel, getWidgetName, getWidgetOwnLabel, getWidgetPlaceholderText, getWidgetPressedState, getWidgetSelectedState, getWidgetValueText,
|
|
6
|
+
import { buildInaccessibilityCheck, getWidgetAccessibleName, getWidgetBusyState, getWidgetDescription, getWidgetDisplayValue, getWidgetExpandedState, getWidgetExternalLabelText, getWidgetLabelText, getWidgetLevel, getWidgetName, getWidgetOwnLabel, getWidgetPlaceholderText, getWidgetPressedState, getWidgetSelectedState, getWidgetValueText, isWidgetChecked, isWidgetValueMatch, namingLabelText, } from "./widget-accessible-properties.js";
|
|
7
7
|
const roleQueries = nameQueryFamily("Role", queryAllByRole, buildQueries(queryAllByRole, (container, matches, role, options) => multipleFoundError(container, { queryType: "role", role, options }, matches), (container, role, options) => notFoundError(container, { queryType: "role", role, options })));
|
|
8
8
|
const labelTextQueries = nameQueryFamily("LabelText", queryAllByLabelText, buildQueries(queryAllByLabelText, (container, matches, text) => multipleFoundError(container, { queryType: "labelText", text }, matches), (container, text) => notFoundError(container, { queryType: "labelText", text })));
|
|
9
9
|
const textQueries = nameQueryFamily("Text", queryAllByText, buildQueries(queryAllByText, (container, matches, text) => multipleFoundError(container, { queryType: "text", text }, matches), (container, text) => notFoundError(container, { queryType: "text", text })));
|
|
@@ -18,161 +18,65 @@ const builtinQueries = {
|
|
|
18
18
|
...placeholderTextQueries,
|
|
19
19
|
...displayValueQueries,
|
|
20
20
|
};
|
|
21
|
-
/**
|
|
22
|
-
* Returns the single mapped widget with a matching accessible role and options, or null when none
|
|
23
|
-
* match. Widgets that are not mapped are never matched. Throws when more than one matches.
|
|
24
|
-
*/
|
|
21
|
+
/** Queries one mapped widget by accessible role. */
|
|
25
22
|
const queryByRole = builtinQueries.queryByRole;
|
|
26
|
-
/**
|
|
27
|
-
* Returns every mapped widget with a matching accessible role and options. Widgets that are not
|
|
28
|
-
* mapped are never matched. Throws when none match.
|
|
29
|
-
*/
|
|
23
|
+
/** Gets all mapped widgets with an accessible role. */
|
|
30
24
|
const getAllByRole = builtinQueries.getAllByRole;
|
|
31
|
-
/**
|
|
32
|
-
* Returns the single mapped widget with a matching accessible role and options. Widgets that are not
|
|
33
|
-
* mapped are never matched. Throws when none or more than one matches.
|
|
34
|
-
*/
|
|
25
|
+
/** Gets one mapped widget by accessible role. */
|
|
35
26
|
const getByRole = builtinQueries.getByRole;
|
|
36
|
-
/**
|
|
37
|
-
* Waits for and returns every mapped widget with a matching accessible role and options, retrying
|
|
38
|
-
* until at least one appears or the timeout elapses. Widgets that are not mapped are never matched.
|
|
39
|
-
*/
|
|
27
|
+
/** Finds all mapped widgets with an accessible role. */
|
|
40
28
|
const findAllByRole = builtinQueries.findAllByRole;
|
|
41
|
-
/**
|
|
42
|
-
* Waits for and returns the single mapped widget with a matching accessible role and options,
|
|
43
|
-
* retrying until it appears or the timeout elapses. Widgets that are not mapped are never matched.
|
|
44
|
-
* Rejects when none or more than one matches.
|
|
45
|
-
*/
|
|
29
|
+
/** Finds one mapped widget by accessible role. */
|
|
46
30
|
const findByRole = builtinQueries.findByRole;
|
|
47
|
-
/**
|
|
48
|
-
* Returns the single mapped widget with matching associated label text, or null when none match.
|
|
49
|
-
* Widgets that are not mapped are never matched. Throws when more than one matches.
|
|
50
|
-
*/
|
|
31
|
+
/** Queries one mapped widget by label text. */
|
|
51
32
|
const queryByLabelText = builtinQueries.queryByLabelText;
|
|
52
|
-
/**
|
|
53
|
-
* Returns every mapped widget with matching associated label text. Widgets that are not mapped are
|
|
54
|
-
* never matched. Throws when none match.
|
|
55
|
-
*/
|
|
33
|
+
/** Gets all mapped widgets with label text. */
|
|
56
34
|
const getAllByLabelText = builtinQueries.getAllByLabelText;
|
|
57
|
-
/**
|
|
58
|
-
* Returns the single mapped widget with matching associated label text. Widgets that are not mapped
|
|
59
|
-
* are never matched. Throws when none or more than one matches.
|
|
60
|
-
*/
|
|
35
|
+
/** Gets one mapped widget by label text. */
|
|
61
36
|
const getByLabelText = builtinQueries.getByLabelText;
|
|
62
|
-
/**
|
|
63
|
-
* Waits for and returns every mapped widget with matching associated label text, retrying until at
|
|
64
|
-
* least one appears or the timeout elapses. Widgets that are not mapped are never matched.
|
|
65
|
-
*/
|
|
37
|
+
/** Finds all mapped widgets with label text. */
|
|
66
38
|
const findAllByLabelText = builtinQueries.findAllByLabelText;
|
|
67
|
-
/**
|
|
68
|
-
* Waits for and returns the single mapped widget with matching associated label text, retrying until
|
|
69
|
-
* it appears or the timeout elapses. Widgets that are not mapped are never matched. Rejects when
|
|
70
|
-
* none or more than one matches.
|
|
71
|
-
*/
|
|
39
|
+
/** Finds one mapped widget by label text. */
|
|
72
40
|
const findByLabelText = builtinQueries.findByLabelText;
|
|
73
|
-
/**
|
|
74
|
-
* Returns the single mapped widget with matching rendered text content, or null when none match.
|
|
75
|
-
* Widgets that are not mapped are never matched. Throws when more than one matches.
|
|
76
|
-
*/
|
|
41
|
+
/** Queries one mapped widget by rendered text. */
|
|
77
42
|
const queryByText = builtinQueries.queryByText;
|
|
78
|
-
/**
|
|
79
|
-
* Returns every mapped widget with matching rendered text content. Widgets that are not mapped are
|
|
80
|
-
* never matched. Throws when none match.
|
|
81
|
-
*/
|
|
43
|
+
/** Gets all mapped widgets with rendered text. */
|
|
82
44
|
const getAllByText = builtinQueries.getAllByText;
|
|
83
|
-
/**
|
|
84
|
-
* Returns the single mapped widget with matching rendered text content. Widgets that are not mapped
|
|
85
|
-
* are never matched. Throws when none or more than one matches.
|
|
86
|
-
*/
|
|
45
|
+
/** Gets one mapped widget by rendered text. */
|
|
87
46
|
const getByText = builtinQueries.getByText;
|
|
88
|
-
/**
|
|
89
|
-
* Waits for and returns every mapped widget with matching rendered text content, retrying until at
|
|
90
|
-
* least one appears or the timeout elapses. Widgets that are not mapped are never matched.
|
|
91
|
-
*/
|
|
47
|
+
/** Finds all mapped widgets with rendered text. */
|
|
92
48
|
const findAllByText = builtinQueries.findAllByText;
|
|
93
|
-
/**
|
|
94
|
-
* Waits for and returns the single mapped widget with matching rendered text content, retrying until
|
|
95
|
-
* it appears or the timeout elapses. Widgets that are not mapped are never matched. Rejects when
|
|
96
|
-
* none or more than one matches.
|
|
97
|
-
*/
|
|
49
|
+
/** Finds one mapped widget by rendered text. */
|
|
98
50
|
const findByText = builtinQueries.findByText;
|
|
99
|
-
/**
|
|
100
|
-
* Returns the single mapped widget with a matching widget name, or null when none match. Widgets
|
|
101
|
-
* that are not mapped are never matched. Throws when more than one matches.
|
|
102
|
-
*/
|
|
51
|
+
/** Queries one mapped widget by GTK name. */
|
|
103
52
|
const queryByName = builtinQueries.queryByName;
|
|
104
|
-
/**
|
|
105
|
-
* Returns every mapped widget with a matching widget name. Widgets that are not mapped are never
|
|
106
|
-
* matched. Throws when none match.
|
|
107
|
-
*/
|
|
53
|
+
/** Gets all mapped widgets with a GTK name. */
|
|
108
54
|
const getAllByName = builtinQueries.getAllByName;
|
|
109
|
-
/**
|
|
110
|
-
* Returns the single mapped widget with a matching widget name. Widgets that are not mapped are
|
|
111
|
-
* never matched. Throws when none or more than one matches.
|
|
112
|
-
*/
|
|
55
|
+
/** Gets one mapped widget by GTK name. */
|
|
113
56
|
const getByName = builtinQueries.getByName;
|
|
114
|
-
/**
|
|
115
|
-
* Waits for and returns every mapped widget with a matching widget name, retrying until at least one
|
|
116
|
-
* appears or the timeout elapses. Widgets that are not mapped are never matched.
|
|
117
|
-
*/
|
|
57
|
+
/** Finds all mapped widgets with a GTK name. */
|
|
118
58
|
const findAllByName = builtinQueries.findAllByName;
|
|
119
|
-
/**
|
|
120
|
-
* Waits for and returns the single mapped widget with a matching widget name, retrying until it
|
|
121
|
-
* appears or the timeout elapses. Widgets that are not mapped are never matched. Rejects when none
|
|
122
|
-
* or more than one matches.
|
|
123
|
-
*/
|
|
59
|
+
/** Finds one mapped widget by GTK name. */
|
|
124
60
|
const findByName = builtinQueries.findByName;
|
|
125
|
-
/**
|
|
126
|
-
* Returns the single mapped widget with matching placeholder text, or null when none match. Widgets
|
|
127
|
-
* that are not mapped are never matched. Throws when more than one matches.
|
|
128
|
-
*/
|
|
61
|
+
/** Queries one mapped widget by placeholder text. */
|
|
129
62
|
const queryByPlaceholderText = builtinQueries.queryByPlaceholderText;
|
|
130
|
-
/**
|
|
131
|
-
* Returns every mapped widget with matching placeholder text. Widgets that are not mapped are never
|
|
132
|
-
* matched. Throws when none match.
|
|
133
|
-
*/
|
|
63
|
+
/** Gets all mapped widgets with placeholder text. */
|
|
134
64
|
const getAllByPlaceholderText = builtinQueries.getAllByPlaceholderText;
|
|
135
|
-
/**
|
|
136
|
-
* Returns the single mapped widget with matching placeholder text. Widgets that are not mapped are
|
|
137
|
-
* never matched. Throws when none or more than one matches.
|
|
138
|
-
*/
|
|
65
|
+
/** Gets one mapped widget by placeholder text. */
|
|
139
66
|
const getByPlaceholderText = builtinQueries.getByPlaceholderText;
|
|
140
|
-
/**
|
|
141
|
-
* Waits for and returns every mapped widget with matching placeholder text, retrying until at least
|
|
142
|
-
* one appears or the timeout elapses. Widgets that are not mapped are never matched.
|
|
143
|
-
*/
|
|
67
|
+
/** Finds all mapped widgets with placeholder text. */
|
|
144
68
|
const findAllByPlaceholderText = builtinQueries.findAllByPlaceholderText;
|
|
145
|
-
/**
|
|
146
|
-
* Waits for and returns the single mapped widget with matching placeholder text, retrying until it
|
|
147
|
-
* appears or the timeout elapses. Widgets that are not mapped are never matched. Rejects when none
|
|
148
|
-
* or more than one matches.
|
|
149
|
-
*/
|
|
69
|
+
/** Finds one mapped widget by placeholder text. */
|
|
150
70
|
const findByPlaceholderText = builtinQueries.findByPlaceholderText;
|
|
151
|
-
/**
|
|
152
|
-
* Returns the single mapped widget with a matching display value, or null when none match. Widgets
|
|
153
|
-
* that are not mapped are never matched. Throws when more than one matches.
|
|
154
|
-
*/
|
|
71
|
+
/** Queries one mapped widget by display value. */
|
|
155
72
|
const queryByDisplayValue = builtinQueries.queryByDisplayValue;
|
|
156
|
-
/**
|
|
157
|
-
* Returns every mapped widget with a matching display value. Widgets that are not mapped are never
|
|
158
|
-
* matched. Throws when none match.
|
|
159
|
-
*/
|
|
73
|
+
/** Gets all mapped widgets with a display value. */
|
|
160
74
|
const getAllByDisplayValue = builtinQueries.getAllByDisplayValue;
|
|
161
|
-
/**
|
|
162
|
-
* Returns the single mapped widget with a matching display value. Widgets that are not mapped are
|
|
163
|
-
* never matched. Throws when none or more than one matches.
|
|
164
|
-
*/
|
|
75
|
+
/** Gets one mapped widget by display value. */
|
|
165
76
|
const getByDisplayValue = builtinQueries.getByDisplayValue;
|
|
166
|
-
/**
|
|
167
|
-
* Waits for and returns every mapped widget with a matching display value, retrying until at least
|
|
168
|
-
* one appears or the timeout elapses. Widgets that are not mapped are never matched.
|
|
169
|
-
*/
|
|
77
|
+
/** Finds all mapped widgets with a display value. */
|
|
170
78
|
const findAllByDisplayValue = builtinQueries.findAllByDisplayValue;
|
|
171
|
-
/**
|
|
172
|
-
* Waits for and returns the single mapped widget with a matching display value, retrying until it
|
|
173
|
-
* appears or the timeout elapses. Widgets that are not mapped are never matched. Rejects when none
|
|
174
|
-
* or more than one matches.
|
|
175
|
-
*/
|
|
79
|
+
/** Finds one mapped widget by display value. */
|
|
176
80
|
const findByDisplayValue = builtinQueries.findByDisplayValue;
|
|
177
81
|
const buildNormalizer = (options) => {
|
|
178
82
|
const { normalizer, trim, collapseWhitespace } = options ?? {};
|
|
@@ -253,12 +157,11 @@ const hasMatchingAccessibleStates = (widget, options) => hasMatchingBooleanState
|
|
|
253
157
|
hasMatchingDescriptionState(widget, options) &&
|
|
254
158
|
hasMatchingValueState(widget, options);
|
|
255
159
|
const isMatchingWidgetType = (widget, options) => options?.as === undefined || widget instanceof options.as;
|
|
256
|
-
const
|
|
160
|
+
const hasMatchingAccessibleOptions = (widget, options) => {
|
|
257
161
|
if (!options) {
|
|
258
162
|
return true;
|
|
259
163
|
}
|
|
260
|
-
return (
|
|
261
|
-
hasMatchingAccessibleName(widget, options) &&
|
|
164
|
+
return (hasMatchingAccessibleName(widget, options) &&
|
|
262
165
|
hasMatchingAccessibleStates(widget, options));
|
|
263
166
|
};
|
|
264
167
|
function nameQueryFamily(suffix, queryAllBy, built) {
|
|
@@ -282,15 +185,20 @@ function nameQueryFamily(suffix, queryAllBy, built) {
|
|
|
282
185
|
* @returns Every matching widget, or an empty array when none match.
|
|
283
186
|
*/
|
|
284
187
|
function queryAllByRole(container, role, options) {
|
|
285
|
-
|
|
188
|
+
const isInaccessible = buildInaccessibilityCheck();
|
|
189
|
+
const matches = findAll(container, (widget) => {
|
|
286
190
|
if (widget.getAccessibleRole() !== role) {
|
|
287
191
|
return false;
|
|
288
192
|
}
|
|
193
|
+
if (!isMatchingWidgetType(widget, options)) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
289
196
|
if (!options?.hidden && isInaccessible(widget)) {
|
|
290
197
|
return false;
|
|
291
198
|
}
|
|
292
|
-
return
|
|
199
|
+
return hasMatchingAccessibleOptions(widget, options);
|
|
293
200
|
});
|
|
201
|
+
return matches.filter((widget) => isMatchingWidgetType(widget, options));
|
|
294
202
|
}
|
|
295
203
|
const collectMnemonicMatch = (widget, text, options) => {
|
|
296
204
|
if (!(widget instanceof Gtk.Label)) {
|
|
@@ -339,7 +247,8 @@ function queryAllByLabelText(container, text, options) {
|
|
|
339
247
|
* @returns Every matching widget, or an empty array when none match.
|
|
340
248
|
*/
|
|
341
249
|
function queryAllByText(container, text, options) {
|
|
342
|
-
|
|
250
|
+
const matches = findAll(container, (widget) => isMatchingWidgetType(widget, options) && isTextMatch(getWidgetLabelText(widget), text, widget, options));
|
|
251
|
+
return matches.filter((widget) => isMatchingWidgetType(widget, options));
|
|
343
252
|
}
|
|
344
253
|
/**
|
|
345
254
|
* Finds every widget whose widget name matches. Widgets that are not mapped are never matched.
|
|
@@ -349,7 +258,8 @@ function queryAllByText(container, text, options) {
|
|
|
349
258
|
* @returns Every matching widget, or an empty array when none match.
|
|
350
259
|
*/
|
|
351
260
|
function queryAllByName(container, name, options) {
|
|
352
|
-
|
|
261
|
+
const matches = findAll(container, (widget) => isMatchingWidgetType(widget, options) && isTextMatch(getWidgetName(widget), name, widget, options));
|
|
262
|
+
return matches.filter((widget) => isMatchingWidgetType(widget, options));
|
|
353
263
|
}
|
|
354
264
|
/**
|
|
355
265
|
* Finds every widget whose placeholder text matches. Widgets that are not mapped are never matched.
|
|
@@ -359,8 +269,9 @@ function queryAllByName(container, name, options) {
|
|
|
359
269
|
* @returns Every matching widget, or an empty array when none match.
|
|
360
270
|
*/
|
|
361
271
|
function queryAllByPlaceholderText(container, text, options) {
|
|
362
|
-
|
|
272
|
+
const matches = findAll(container, (widget) => isMatchingWidgetType(widget, options) &&
|
|
363
273
|
isTextMatch(getWidgetPlaceholderText(widget), text, widget, options));
|
|
274
|
+
return matches.filter((widget) => isMatchingWidgetType(widget, options));
|
|
364
275
|
}
|
|
365
276
|
/**
|
|
366
277
|
* Finds every widget whose current display value matches. Widgets that are not mapped are never matched.
|
|
@@ -370,8 +281,9 @@ function queryAllByPlaceholderText(container, text, options) {
|
|
|
370
281
|
* @returns Every matching widget, or an empty array when none match.
|
|
371
282
|
*/
|
|
372
283
|
function queryAllByDisplayValue(container, value, options) {
|
|
373
|
-
|
|
284
|
+
const matches = findAll(container, (widget) => isMatchingWidgetType(widget, options) &&
|
|
374
285
|
isTextMatch(getWidgetDisplayValue(widget), value, widget, options));
|
|
286
|
+
return matches.filter((widget) => isMatchingWidgetType(widget, options));
|
|
375
287
|
}
|
|
376
288
|
export { builtinQueries, isMatchingWidgetType, isTextMatch, queryByRole, getAllByRole, getByRole, findAllByRole, findByRole, queryByLabelText, getAllByLabelText, getByLabelText, findAllByLabelText, findByLabelText, queryByText, getAllByText, getByText, findAllByText, findByText, queryByName, getAllByName, getByName, findAllByName, findByName, queryByPlaceholderText, getAllByPlaceholderText, getByPlaceholderText, findAllByPlaceholderText, findByPlaceholderText, queryByDisplayValue, getAllByDisplayValue, getByDisplayValue, findAllByDisplayValue, findByDisplayValue, queryAllByRole, queryAllByLabelText, queryAllByText, queryAllByName, queryAllByPlaceholderText, queryAllByDisplayValue, };
|
|
377
289
|
//# sourceMappingURL=queries.js.map
|
package/dist/queries.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AASpC,OAAO,EAAE,YAAY,EAAsC,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAkB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACH,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,eAAe,GAElB,MAAM,mCAAmC,CAAC;AAK3C,MAAM,WAAW,GAAG,eAAe,CAC/B,MAAM,EACN,cAAc,EACd,YAAY,CACR,cAAc,EACd,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAClC,kBAAkB,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAChF,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAC/F,CACJ,CAAC;AAEF,MAAM,gBAAgB,GAAG,eAAe,CACpC,WAAW,EACX,mBAAmB,EACnB,YAAY,CACR,mBAAmB,EACnB,CA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V,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,sBAAsB,GACzB,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport type {\n ByRoleOptions,\n ByRoleValue,\n Matcher,\n MatcherOptions,\n NormalizerFn,\n QueryFamilies,\n} from \"./types.js\";\nimport { buildQueries, type BuiltQueries, type QueryAllBy } from \"./build-queries.js\";\nimport { multipleFoundError, notFoundError } from \"./errors.js\";\nimport { getDefaultNormalizer } from \"./normalize.js\";\nimport { type Container, findAll, traverse } from \"./traversal.js\";\nimport {\n getWidgetAccessibleName,\n getWidgetBusyState,\n getWidgetDescription,\n getWidgetDisplayValue,\n getWidgetExpandedState,\n getWidgetExternalLabelText,\n getWidgetLabelText,\n getWidgetLevel,\n getWidgetName,\n getWidgetOwnLabel,\n getWidgetPlaceholderText,\n getWidgetPressedState,\n getWidgetSelectedState,\n getWidgetValueText,\n isInaccessible,\n isWidgetChecked,\n isWidgetValueMatch,\n namingLabelText,\n type WidgetValueField,\n} from \"./widget-accessible-properties.js\";\n\n/** The built-in queries in their unbound form, each taking the container to search as its first argument. */\ntype BuiltinQueries = QueryFamilies<[container: Container]>;\n\nconst roleQueries = nameQueryFamily(\n \"Role\",\n queryAllByRole,\n buildQueries<[role: Gtk.AccessibleRole, options?: ByRoleOptions]>(\n queryAllByRole,\n (container, matches, role, options) =>\n multipleFoundError(container, { queryType: \"role\", role, options }, matches),\n (container, role, options) => notFoundError(container, { queryType: \"role\", role, options }),\n ),\n);\n\nconst labelTextQueries = nameQueryFamily(\n \"LabelText\",\n queryAllByLabelText,\n buildQueries<[text: Matcher, options?: MatcherOptions]>(\n queryAllByLabelText,\n (container, matches, text) => multipleFoundError(container, { queryType: \"labelText\", text }, matches),\n (container, text) => notFoundError(container, { queryType: \"labelText\", text }),\n ),\n);\n\nconst textQueries = nameQueryFamily(\n \"Text\",\n queryAllByText,\n buildQueries<[text: Matcher, options?: MatcherOptions]>(\n queryAllByText,\n (container, matches, text) => multipleFoundError(container, { queryType: \"text\", text }, matches),\n (container, text) => notFoundError(container, { queryType: \"text\", text }),\n ),\n);\n\nconst nameQueries = nameQueryFamily(\n \"Name\",\n queryAllByName,\n buildQueries<[name: Matcher, options?: MatcherOptions]>(\n queryAllByName,\n (container, matches, name) => multipleFoundError(container, { queryType: \"name\", name }, matches),\n (container, name) => notFoundError(container, { queryType: \"name\", name }),\n ),\n);\n\nconst placeholderTextQueries = nameQueryFamily(\n \"PlaceholderText\",\n queryAllByPlaceholderText,\n buildQueries<[text: Matcher, options?: MatcherOptions]>(\n queryAllByPlaceholderText,\n (container, matches, text) => multipleFoundError(container, { queryType: \"placeholderText\", text }, matches),\n (container, text) => notFoundError(container, { queryType: \"placeholderText\", text }),\n ),\n);\n\nconst displayValueQueries = nameQueryFamily(\n \"DisplayValue\",\n queryAllByDisplayValue,\n buildQueries<[value: Matcher, options?: MatcherOptions]>(\n queryAllByDisplayValue,\n (container, matches, value) => multipleFoundError(container, { queryType: \"displayValue\", value }, matches),\n (container, value) => notFoundError(container, { queryType: \"displayValue\", value }),\n ),\n);\n\nconst builtinQueries = {\n ...roleQueries,\n ...labelTextQueries,\n ...textQueries,\n ...nameQueries,\n ...placeholderTextQueries,\n ...displayValueQueries,\n} as BuiltinQueries;\n\n/**\n * Returns the single mapped widget with a matching accessible role and options, or null when none\n * match. Widgets that are not mapped are never matched. Throws when more than one matches.\n */\nconst queryByRole: BuiltinQueries[\"queryByRole\"] = builtinQueries.queryByRole;\n/**\n * Returns every mapped widget with a matching accessible role and options. Widgets that are not\n * mapped are never matched. Throws when none match.\n */\nconst getAllByRole: BuiltinQueries[\"getAllByRole\"] = builtinQueries.getAllByRole;\n/**\n * Returns the single mapped widget with a matching accessible role and options. Widgets that are not\n * mapped are never matched. Throws when none or more than one matches.\n */\nconst getByRole: BuiltinQueries[\"getByRole\"] = builtinQueries.getByRole;\n/**\n * Waits for and returns every mapped widget with a matching accessible role and options, retrying\n * until at least one appears or the timeout elapses. Widgets that are not mapped are never matched.\n */\nconst findAllByRole: BuiltinQueries[\"findAllByRole\"] = builtinQueries.findAllByRole;\n/**\n * Waits for and returns the single mapped widget with a matching accessible role and options,\n * retrying until it appears or the timeout elapses. Widgets that are not mapped are never matched.\n * Rejects when none or more than one matches.\n */\nconst findByRole: BuiltinQueries[\"findByRole\"] = builtinQueries.findByRole;\n/**\n * Returns the single mapped widget with matching associated label text, or null when none match.\n * Widgets that are not mapped are never matched. Throws when more than one matches.\n */\nconst queryByLabelText: BuiltinQueries[\"queryByLabelText\"] = builtinQueries.queryByLabelText;\n/**\n * Returns every mapped widget with matching associated label text. Widgets that are not mapped are\n * never matched. Throws when none match.\n */\nconst getAllByLabelText: BuiltinQueries[\"getAllByLabelText\"] = builtinQueries.getAllByLabelText;\n/**\n * Returns the single mapped widget with matching associated label text. Widgets that are not mapped\n * are never matched. Throws when none or more than one matches.\n */\nconst getByLabelText: BuiltinQueries[\"getByLabelText\"] = builtinQueries.getByLabelText;\n/**\n * Waits for and returns every mapped widget with matching associated label text, retrying until at\n * least one appears or the timeout elapses. Widgets that are not mapped are never matched.\n */\nconst findAllByLabelText: BuiltinQueries[\"findAllByLabelText\"] = builtinQueries.findAllByLabelText;\n/**\n * Waits for and returns the single mapped widget with matching associated label text, retrying until\n * it appears or the timeout elapses. Widgets that are not mapped are never matched. Rejects when\n * none or more than one matches.\n */\nconst findByLabelText: BuiltinQueries[\"findByLabelText\"] = builtinQueries.findByLabelText;\n/**\n * Returns the single mapped widget with matching rendered text content, or null when none match.\n * Widgets that are not mapped are never matched. Throws when more than one matches.\n */\nconst queryByText: BuiltinQueries[\"queryByText\"] = builtinQueries.queryByText;\n/**\n * Returns every mapped widget with matching rendered text content. Widgets that are not mapped are\n * never matched. Throws when none match.\n */\nconst getAllByText: BuiltinQueries[\"getAllByText\"] = builtinQueries.getAllByText;\n/**\n * Returns the single mapped widget with matching rendered text content. Widgets that are not mapped\n * are never matched. Throws when none or more than one matches.\n */\nconst getByText: BuiltinQueries[\"getByText\"] = builtinQueries.getByText;\n/**\n * Waits for and returns every mapped widget with matching rendered text content, retrying until at\n * least one appears or the timeout elapses. Widgets that are not mapped are never matched.\n */\nconst findAllByText: BuiltinQueries[\"findAllByText\"] = builtinQueries.findAllByText;\n/**\n * Waits for and returns the single mapped widget with matching rendered text content, retrying until\n * it appears or the timeout elapses. Widgets that are not mapped are never matched. Rejects when\n * none or more than one matches.\n */\nconst findByText: BuiltinQueries[\"findByText\"] = builtinQueries.findByText;\n/**\n * Returns the single mapped widget with a matching widget name, or null when none match. Widgets\n * that are not mapped are never matched. Throws when more than one matches.\n */\nconst queryByName: BuiltinQueries[\"queryByName\"] = builtinQueries.queryByName;\n/**\n * Returns every mapped widget with a matching widget name. Widgets that are not mapped are never\n * matched. Throws when none match.\n */\nconst getAllByName: BuiltinQueries[\"getAllByName\"] = builtinQueries.getAllByName;\n/**\n * Returns the single mapped widget with a matching widget name. Widgets that are not mapped are\n * never matched. Throws when none or more than one matches.\n */\nconst getByName: BuiltinQueries[\"getByName\"] = builtinQueries.getByName;\n/**\n * Waits for and returns every mapped widget with a matching widget name, retrying until at least one\n * appears or the timeout elapses. Widgets that are not mapped are never matched.\n */\nconst findAllByName: BuiltinQueries[\"findAllByName\"] = builtinQueries.findAllByName;\n/**\n * Waits for and returns the single mapped widget with a matching widget name, retrying until it\n * appears or the timeout elapses. Widgets that are not mapped are never matched. Rejects when none\n * or more than one matches.\n */\nconst findByName: BuiltinQueries[\"findByName\"] = builtinQueries.findByName;\n/**\n * Returns the single mapped widget with matching placeholder text, or null when none match. Widgets\n * that are not mapped are never matched. Throws when more than one matches.\n */\nconst queryByPlaceholderText: BuiltinQueries[\"queryByPlaceholderText\"] = builtinQueries.queryByPlaceholderText;\n/**\n * Returns every mapped widget with matching placeholder text. Widgets that are not mapped are never\n * matched. Throws when none match.\n */\nconst getAllByPlaceholderText: BuiltinQueries[\"getAllByPlaceholderText\"] = builtinQueries.getAllByPlaceholderText;\n/**\n * Returns the single mapped widget with matching placeholder text. Widgets that are not mapped are\n * never matched. Throws when none or more than one matches.\n */\nconst getByPlaceholderText: BuiltinQueries[\"getByPlaceholderText\"] = builtinQueries.getByPlaceholderText;\n/**\n * Waits for and returns every mapped widget with matching placeholder text, retrying until at least\n * one appears or the timeout elapses. Widgets that are not mapped are never matched.\n */\nconst findAllByPlaceholderText: BuiltinQueries[\"findAllByPlaceholderText\"] = builtinQueries.findAllByPlaceholderText;\n/**\n * Waits for and returns the single mapped widget with matching placeholder text, retrying until it\n * appears or the timeout elapses. Widgets that are not mapped are never matched. Rejects when none\n * or more than one matches.\n */\nconst findByPlaceholderText: BuiltinQueries[\"findByPlaceholderText\"] = builtinQueries.findByPlaceholderText;\n/**\n * Returns the single mapped widget with a matching display value, or null when none match. Widgets\n * that are not mapped are never matched. Throws when more than one matches.\n */\nconst queryByDisplayValue: BuiltinQueries[\"queryByDisplayValue\"] = builtinQueries.queryByDisplayValue;\n/**\n * Returns every mapped widget with a matching display value. Widgets that are not mapped are never\n * matched. Throws when none match.\n */\nconst getAllByDisplayValue: BuiltinQueries[\"getAllByDisplayValue\"] = builtinQueries.getAllByDisplayValue;\n/**\n * Returns the single mapped widget with a matching display value. Widgets that are not mapped are\n * never matched. Throws when none or more than one matches.\n */\nconst getByDisplayValue: BuiltinQueries[\"getByDisplayValue\"] = builtinQueries.getByDisplayValue;\n/**\n * Waits for and returns every mapped widget with a matching display value, retrying until at least\n * one appears or the timeout elapses. Widgets that are not mapped are never matched.\n */\nconst findAllByDisplayValue: BuiltinQueries[\"findAllByDisplayValue\"] = builtinQueries.findAllByDisplayValue;\n/**\n * Waits for and returns the single mapped widget with a matching display value, retrying until it\n * appears or the timeout elapses. Widgets that are not mapped are never matched. Rejects when none\n * or more than one matches.\n */\nconst findByDisplayValue: BuiltinQueries[\"findByDisplayValue\"] = builtinQueries.findByDisplayValue;\n\nconst buildNormalizer = (options?: MatcherOptions): NormalizerFn => {\n const { normalizer, trim, collapseWhitespace } = options ?? {};\n\n if (!normalizer) {\n return getDefaultNormalizer({ trim, collapseWhitespace });\n }\n\n if (trim !== undefined || collapseWhitespace !== undefined) {\n throw new Error(\n \"trim and collapseWhitespace are not supported with a normalizer. \" +\n \"If you want to use the default trim and collapseWhitespace logic in your normalizer, \" +\n \"use \\\"getDefaultNormalizer({ trim, collapseWhitespace })\\\" and compose that into your normalizer\",\n );\n }\n\n return normalizer;\n};\n\nconst normalizeText = (text: string, options?: MatcherOptions): string => {\n const normalizer = buildNormalizer(options);\n\n return normalizer(text);\n};\n\nconst isTextMatch = (\n actual: string | null,\n expected: Matcher,\n widget: Gtk.Widget,\n options?: MatcherOptions,\n): boolean => {\n if (actual === null) {\n return false;\n }\n\n const normalizedActual = normalizeText(actual, options);\n\n if (typeof expected === \"function\") {\n return expected(normalizedActual, widget);\n }\n\n if (expected instanceof RegExp) {\n expected.lastIndex = 0;\n\n return expected.test(normalizedActual);\n }\n\n const normalizedExpected = normalizeText(String(expected), options);\n const isExact = options?.exact ?? true;\n\n return isExact\n ? normalizedActual === normalizedExpected\n : normalizedActual.toLowerCase().includes(normalizedExpected.toLowerCase());\n};\n\nconst hasMatchingAccessibleName = (widget: Gtk.Widget, options: ByRoleOptions): boolean => {\n if (options.name === undefined) {\n return true;\n }\n\n const text = getWidgetAccessibleName(widget);\n\n return isTextMatch(text, options.name, widget, options);\n};\n\nconst isNumericValueMatch = (widget: Gtk.Widget, field: WidgetValueField, expected: number | undefined): boolean =>\n expected === undefined || isWidgetValueMatch(widget, field, expected);\n\nconst hasMatchingAccessibleValue = (widget: Gtk.Widget, value: ByRoleValue, options: ByRoleOptions): boolean => {\n const numericChecks: [WidgetValueField, number | undefined][] = [\n [\"now\", value.now],\n [\"min\", value.min],\n [\"max\", value.max],\n ];\n\n for (const [field, expected] of numericChecks) {\n if (!isNumericValueMatch(widget, field, expected)) {\n return false;\n }\n }\n\n return value.text === undefined || isTextMatch(getWidgetValueText(widget), value.text, widget, options);\n};\n\nconst hasMatchingBooleanStates = (widget: Gtk.Widget, options: ByRoleOptions): boolean => {\n const stateChecks: [boolean | undefined, () => boolean | null][] = [\n [options.checked, () => isWidgetChecked(widget)],\n [options.pressed, () => getWidgetPressedState(widget)],\n [options.expanded, () => getWidgetExpandedState(widget)],\n [options.selected, () => getWidgetSelectedState(widget)],\n [options.busy, () => getWidgetBusyState(widget) ?? false],\n ];\n\n for (const [expected, getActual] of stateChecks) {\n if (expected !== undefined && getActual() !== expected) {\n return false;\n }\n }\n\n return true;\n};\n\nconst hasMatchingLevelState = (widget: Gtk.Widget, options: ByRoleOptions): boolean =>\n options.level === undefined || getWidgetLevel(widget) === options.level;\n\nconst hasMatchingDescriptionState = (widget: Gtk.Widget, options: ByRoleOptions): boolean =>\n options.description === undefined ||\n isTextMatch(getWidgetDescription(widget), options.description, widget, options);\n\nconst hasMatchingValueState = (widget: Gtk.Widget, options: ByRoleOptions): boolean =>\n options.value === undefined || hasMatchingAccessibleValue(widget, options.value, options);\n\nconst hasMatchingAccessibleStates = (widget: Gtk.Widget, options: ByRoleOptions): boolean =>\n hasMatchingBooleanStates(widget, options) &&\n hasMatchingLevelState(widget, options) &&\n hasMatchingDescriptionState(widget, options) &&\n hasMatchingValueState(widget, options);\n\nconst isMatchingWidgetType = (widget: Gtk.Widget, options?: MatcherOptions): boolean =>\n options?.as === undefined || widget instanceof options.as;\n\nconst hasMatchingByRoleOptions = (widget: Gtk.Widget, options?: ByRoleOptions): boolean => {\n if (!options) {\n return true;\n }\n\n return (\n isMatchingWidgetType(widget, options) &&\n hasMatchingAccessibleName(widget, options) &&\n hasMatchingAccessibleStates(widget, options)\n );\n};\n\nfunction nameQueryFamily<Args extends unknown[]>(\n suffix: string,\n queryAllBy: QueryAllBy<Args>,\n built: BuiltQueries<Args>,\n): Record<string, unknown> {\n const [queryBy, getAllBy, getBy, findAllBy, findBy] = built;\n\n return {\n [`queryBy${suffix}`]: queryBy,\n [`queryAllBy${suffix}`]: queryAllBy,\n [`getBy${suffix}`]: getBy,\n [`getAllBy${suffix}`]: getAllBy,\n [`findBy${suffix}`]: findBy,\n [`findAllBy${suffix}`]: findAllBy,\n };\n}\n\n/**\n * Finds every widget under the container whose accessible role matches `role` and that satisfies the given options.\n * Widgets that are not mapped are never matched, and widgets excluded from the accessibility tree are\n * skipped unless `options.hidden` is set.\n * @param container Widget subtree to search.\n * @param role Accessible role to match.\n * @param options Additional accessible name, state, and value constraints.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByRole(\n container: Container,\n role: Gtk.AccessibleRole,\n options?: ByRoleOptions,\n): Gtk.Widget[] {\n return findAll(container, (widget) => {\n if (widget.getAccessibleRole() !== role) {\n return false;\n }\n\n if (!options?.hidden && isInaccessible(widget)) {\n return false;\n }\n\n return hasMatchingByRoleOptions(widget, options);\n });\n}\n\nconst collectMnemonicMatch = (\n widget: Gtk.Widget,\n text: Matcher,\n options: MatcherOptions | undefined,\n): Gtk.Widget | null => {\n if (!(widget instanceof Gtk.Label)) {\n return null;\n }\n\n const labelText = namingLabelText(widget);\n\n if (!labelText || !isTextMatch(labelText, text, widget, options)) {\n return null;\n }\n\n return widget.getMnemonicWidget();\n};\n\nconst labellingText = (widget: Gtk.Widget): string | null => {\n const ownLabel = widget.getAccessibleRole() === Gtk.AccessibleRole.LABEL ? null : getWidgetOwnLabel(widget);\n\n return ownLabel ?? getWidgetExternalLabelText(widget);\n};\n\nconst collectLabelMatches = (\n results: Set<Gtk.Widget>,\n widget: Gtk.Widget,\n text: Matcher,\n options: MatcherOptions | undefined,\n): void => {\n const mnemonicTarget = collectMnemonicMatch(widget, text, options);\n\n if (mnemonicTarget) {\n results.add(mnemonicTarget);\n }\n\n const labelText = labellingText(widget);\n\n if (labelText !== null && isTextMatch(labelText, text, widget, options)) {\n results.add(widget);\n }\n};\n\n/**\n * Finds every widget associated with a label whose text matches: a Gtk.Label mnemonic target, the\n * widget's own accessible label, or its labelled-by relation. Widgets that are not mapped are never matched.\n * @param container Widget subtree to search.\n * @param text Matcher for the label text.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByLabelText(container: Container, text: Matcher, options?: MatcherOptions): Gtk.Widget[] {\n const results: Set<Gtk.Widget> = new Set();\n\n for (const widget of traverse(container)) {\n collectLabelMatches(results, widget, text, options);\n }\n\n return [...results].filter((widget) => isMatchingWidgetType(widget, options));\n}\n\n/**\n * Finds every widget whose rendered text content matches. Widgets that are not mapped are never matched.\n * @param container Widget subtree to search.\n * @param text Matcher for the widget text.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByText(container: Container, text: Matcher, options?: MatcherOptions): Gtk.Widget[] {\n return findAll(\n container,\n (widget) =>\n isMatchingWidgetType(widget, options) && isTextMatch(getWidgetLabelText(widget), text, widget, options),\n );\n}\n\n/**\n * Finds every widget whose widget name matches. Widgets that are not mapped are never matched.\n * @param container Widget subtree to search.\n * @param name Matcher for the widget name.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByName(container: Container, name: Matcher, options?: MatcherOptions): Gtk.Widget[] {\n return findAll(\n container,\n (widget) => isMatchingWidgetType(widget, options) && isTextMatch(getWidgetName(widget), name, widget, options),\n );\n}\n\n/**\n * Finds every widget whose placeholder text matches. Widgets that are not mapped are never matched.\n * @param container Widget subtree to search.\n * @param text Matcher for the placeholder text.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByPlaceholderText(\n container: Container,\n text: Matcher,\n options?: MatcherOptions,\n): Gtk.Widget[] {\n return findAll(\n container,\n (widget) =>\n isMatchingWidgetType(widget, options) &&\n isTextMatch(getWidgetPlaceholderText(widget), text, widget, options),\n );\n}\n\n/**\n * Finds every widget whose current display value matches. Widgets that are not mapped are never matched.\n * @param container Widget subtree to search.\n * @param value Matcher for the display value.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByDisplayValue(container: Container, value: Matcher, options?: MatcherOptions): Gtk.Widget[] {\n return findAll(\n container,\n (widget) =>\n isMatchingWidgetType(widget, options) &&\n isTextMatch(getWidgetDisplayValue(widget), value, widget, options),\n );\n}\n\nexport {\n builtinQueries,\n isMatchingWidgetType,\n isTextMatch,\n queryByRole,\n getAllByRole,\n getByRole,\n findAllByRole,\n findByRole,\n queryByLabelText,\n getAllByLabelText,\n getByLabelText,\n findAllByLabelText,\n findByLabelText,\n queryByText,\n getAllByText,\n getByText,\n findAllByText,\n findByText,\n queryByName,\n getAllByName,\n getByName,\n findAllByName,\n findByName,\n queryByPlaceholderText,\n getAllByPlaceholderText,\n getByPlaceholderText,\n findAllByPlaceholderText,\n findByPlaceholderText,\n queryByDisplayValue,\n getAllByDisplayValue,\n getByDisplayValue,\n findAllByDisplayValue,\n findByDisplayValue,\n queryAllByRole,\n queryAllByLabelText,\n queryAllByText,\n queryAllByName,\n queryAllByPlaceholderText,\n queryAllByDisplayValue,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AASpC,OAAO,EAAE,YAAY,EAAsC,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAkB,OAAO,EAAE,QAAQ,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M,EAAE,EAAE,CACP,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC;QACrC,WAAW,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CACzE,CAAC;IAEF,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAA4B,EAAE,CAAC,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACvG,CAAC;AAED,OAAO,EACH,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,sBAAsB,GACzB,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport type {\n ByRoleOptions,\n ByRoleValue,\n Matcher,\n MatcherOptions,\n NormalizerFn,\n QueryFamilies,\n} from \"./types.js\";\nimport { buildQueries, type BuiltQueries, type QueryAllBy } from \"./build-queries.js\";\nimport { multipleFoundError, notFoundError } from \"./errors.js\";\nimport { getDefaultNormalizer } from \"./normalize.js\";\nimport { type Container, findAll, traverse } from \"./traversal.js\";\nimport {\n buildInaccessibilityCheck,\n getWidgetAccessibleName,\n getWidgetBusyState,\n getWidgetDescription,\n getWidgetDisplayValue,\n getWidgetExpandedState,\n getWidgetExternalLabelText,\n getWidgetLabelText,\n getWidgetLevel,\n getWidgetName,\n getWidgetOwnLabel,\n getWidgetPlaceholderText,\n getWidgetPressedState,\n getWidgetSelectedState,\n getWidgetValueText,\n isWidgetChecked,\n isWidgetValueMatch,\n namingLabelText,\n type WidgetValueField,\n} from \"./widget-accessible-properties.js\";\n\n/** The built-in queries in their unbound form, each taking the container to search as its first argument. */\ntype BuiltinQueries = QueryFamilies<[container: Container]>;\n\nconst roleQueries = nameQueryFamily(\n \"Role\",\n queryAllByRole,\n buildQueries<[role: Gtk.AccessibleRole, options?: ByRoleOptions<Gtk.Widget>], Gtk.Widget>(\n queryAllByRole,\n (container, matches, role, options) =>\n multipleFoundError(container, { queryType: \"role\", role, options }, matches),\n (container, role, options) => notFoundError(container, { queryType: \"role\", role, options }),\n ),\n);\n\nconst labelTextQueries = nameQueryFamily(\n \"LabelText\",\n queryAllByLabelText,\n buildQueries<[text: Matcher, options?: MatcherOptions<Gtk.Widget>], Gtk.Widget>(\n queryAllByLabelText,\n (container, matches, text) => multipleFoundError(container, { queryType: \"labelText\", text }, matches),\n (container, text) => notFoundError(container, { queryType: \"labelText\", text }),\n ),\n);\n\nconst textQueries = nameQueryFamily(\n \"Text\",\n queryAllByText,\n buildQueries<[text: Matcher, options?: MatcherOptions<Gtk.Widget>], Gtk.Widget>(\n queryAllByText,\n (container, matches, text) => multipleFoundError(container, { queryType: \"text\", text }, matches),\n (container, text) => notFoundError(container, { queryType: \"text\", text }),\n ),\n);\n\nconst nameQueries = nameQueryFamily(\n \"Name\",\n queryAllByName,\n buildQueries<[name: Matcher, options?: MatcherOptions<Gtk.Widget>], Gtk.Widget>(\n queryAllByName,\n (container, matches, name) => multipleFoundError(container, { queryType: \"name\", name }, matches),\n (container, name) => notFoundError(container, { queryType: \"name\", name }),\n ),\n);\n\nconst placeholderTextQueries = nameQueryFamily(\n \"PlaceholderText\",\n queryAllByPlaceholderText,\n buildQueries<[text: Matcher, options?: MatcherOptions<Gtk.Widget>], Gtk.Widget>(\n queryAllByPlaceholderText,\n (container, matches, text) => multipleFoundError(container, { queryType: \"placeholderText\", text }, matches),\n (container, text) => notFoundError(container, { queryType: \"placeholderText\", text }),\n ),\n);\n\nconst displayValueQueries = nameQueryFamily(\n \"DisplayValue\",\n queryAllByDisplayValue,\n buildQueries<[value: Matcher, options?: MatcherOptions<Gtk.Widget>], Gtk.Widget>(\n queryAllByDisplayValue,\n (container, matches, value) => multipleFoundError(container, { queryType: \"displayValue\", value }, matches),\n (container, value) => notFoundError(container, { queryType: \"displayValue\", value }),\n ),\n);\n\nconst builtinQueries = {\n ...roleQueries,\n ...labelTextQueries,\n ...textQueries,\n ...nameQueries,\n ...placeholderTextQueries,\n ...displayValueQueries,\n} as BuiltinQueries;\n\n/** Queries one mapped widget by accessible role. */\nconst queryByRole: BuiltinQueries[\"queryByRole\"] = builtinQueries.queryByRole;\n/** Gets all mapped widgets with an accessible role. */\nconst getAllByRole: BuiltinQueries[\"getAllByRole\"] = builtinQueries.getAllByRole;\n/** Gets one mapped widget by accessible role. */\nconst getByRole: BuiltinQueries[\"getByRole\"] = builtinQueries.getByRole;\n/** Finds all mapped widgets with an accessible role. */\nconst findAllByRole: BuiltinQueries[\"findAllByRole\"] = builtinQueries.findAllByRole;\n/** Finds one mapped widget by accessible role. */\nconst findByRole: BuiltinQueries[\"findByRole\"] = builtinQueries.findByRole;\n/** Queries one mapped widget by label text. */\nconst queryByLabelText: BuiltinQueries[\"queryByLabelText\"] = builtinQueries.queryByLabelText;\n/** Gets all mapped widgets with label text. */\nconst getAllByLabelText: BuiltinQueries[\"getAllByLabelText\"] = builtinQueries.getAllByLabelText;\n/** Gets one mapped widget by label text. */\nconst getByLabelText: BuiltinQueries[\"getByLabelText\"] = builtinQueries.getByLabelText;\n/** Finds all mapped widgets with label text. */\nconst findAllByLabelText: BuiltinQueries[\"findAllByLabelText\"] = builtinQueries.findAllByLabelText;\n/** Finds one mapped widget by label text. */\nconst findByLabelText: BuiltinQueries[\"findByLabelText\"] = builtinQueries.findByLabelText;\n/** Queries one mapped widget by rendered text. */\nconst queryByText: BuiltinQueries[\"queryByText\"] = builtinQueries.queryByText;\n/** Gets all mapped widgets with rendered text. */\nconst getAllByText: BuiltinQueries[\"getAllByText\"] = builtinQueries.getAllByText;\n/** Gets one mapped widget by rendered text. */\nconst getByText: BuiltinQueries[\"getByText\"] = builtinQueries.getByText;\n/** Finds all mapped widgets with rendered text. */\nconst findAllByText: BuiltinQueries[\"findAllByText\"] = builtinQueries.findAllByText;\n/** Finds one mapped widget by rendered text. */\nconst findByText: BuiltinQueries[\"findByText\"] = builtinQueries.findByText;\n/** Queries one mapped widget by GTK name. */\nconst queryByName: BuiltinQueries[\"queryByName\"] = builtinQueries.queryByName;\n/** Gets all mapped widgets with a GTK name. */\nconst getAllByName: BuiltinQueries[\"getAllByName\"] = builtinQueries.getAllByName;\n/** Gets one mapped widget by GTK name. */\nconst getByName: BuiltinQueries[\"getByName\"] = builtinQueries.getByName;\n/** Finds all mapped widgets with a GTK name. */\nconst findAllByName: BuiltinQueries[\"findAllByName\"] = builtinQueries.findAllByName;\n/** Finds one mapped widget by GTK name. */\nconst findByName: BuiltinQueries[\"findByName\"] = builtinQueries.findByName;\n/** Queries one mapped widget by placeholder text. */\nconst queryByPlaceholderText: BuiltinQueries[\"queryByPlaceholderText\"] = builtinQueries.queryByPlaceholderText;\n/** Gets all mapped widgets with placeholder text. */\nconst getAllByPlaceholderText: BuiltinQueries[\"getAllByPlaceholderText\"] = builtinQueries.getAllByPlaceholderText;\n/** Gets one mapped widget by placeholder text. */\nconst getByPlaceholderText: BuiltinQueries[\"getByPlaceholderText\"] = builtinQueries.getByPlaceholderText;\n/** Finds all mapped widgets with placeholder text. */\nconst findAllByPlaceholderText: BuiltinQueries[\"findAllByPlaceholderText\"] = builtinQueries.findAllByPlaceholderText;\n/** Finds one mapped widget by placeholder text. */\nconst findByPlaceholderText: BuiltinQueries[\"findByPlaceholderText\"] = builtinQueries.findByPlaceholderText;\n/** Queries one mapped widget by display value. */\nconst queryByDisplayValue: BuiltinQueries[\"queryByDisplayValue\"] = builtinQueries.queryByDisplayValue;\n/** Gets all mapped widgets with a display value. */\nconst getAllByDisplayValue: BuiltinQueries[\"getAllByDisplayValue\"] = builtinQueries.getAllByDisplayValue;\n/** Gets one mapped widget by display value. */\nconst getByDisplayValue: BuiltinQueries[\"getByDisplayValue\"] = builtinQueries.getByDisplayValue;\n/** Finds all mapped widgets with a display value. */\nconst findAllByDisplayValue: BuiltinQueries[\"findAllByDisplayValue\"] = builtinQueries.findAllByDisplayValue;\n/** Finds one mapped widget by display value. */\nconst findByDisplayValue: BuiltinQueries[\"findByDisplayValue\"] = builtinQueries.findByDisplayValue;\n\nconst buildNormalizer = (options?: MatcherOptions): NormalizerFn => {\n const { normalizer, trim, collapseWhitespace } = options ?? {};\n\n if (!normalizer) {\n return getDefaultNormalizer({ trim, collapseWhitespace });\n }\n\n if (trim !== undefined || collapseWhitespace !== undefined) {\n throw new Error(\n \"trim and collapseWhitespace are not supported with a normalizer. \" +\n \"If you want to use the default trim and collapseWhitespace logic in your normalizer, \" +\n \"use \\\"getDefaultNormalizer({ trim, collapseWhitespace })\\\" and compose that into your normalizer\",\n );\n }\n\n return normalizer;\n};\n\nconst normalizeText = (text: string, options?: MatcherOptions): string => {\n const normalizer = buildNormalizer(options);\n\n return normalizer(text);\n};\n\nconst isTextMatch = (\n actual: string | null,\n expected: Matcher,\n widget: Gtk.Widget,\n options?: MatcherOptions,\n): boolean => {\n if (actual === null) {\n return false;\n }\n\n const normalizedActual = normalizeText(actual, options);\n\n if (typeof expected === \"function\") {\n return expected(normalizedActual, widget);\n }\n\n if (expected instanceof RegExp) {\n expected.lastIndex = 0;\n\n return expected.test(normalizedActual);\n }\n\n const normalizedExpected = normalizeText(String(expected), options);\n const isExact = options?.exact ?? true;\n\n return isExact\n ? normalizedActual === normalizedExpected\n : normalizedActual.toLowerCase().includes(normalizedExpected.toLowerCase());\n};\n\nconst hasMatchingAccessibleName = (widget: Gtk.Widget, options: ByRoleOptions): boolean => {\n if (options.name === undefined) {\n return true;\n }\n\n const text = getWidgetAccessibleName(widget);\n\n return isTextMatch(text, options.name, widget, options);\n};\n\nconst isNumericValueMatch = (widget: Gtk.Widget, field: WidgetValueField, expected: number | undefined): boolean =>\n expected === undefined || isWidgetValueMatch(widget, field, expected);\n\nconst hasMatchingAccessibleValue = (widget: Gtk.Widget, value: ByRoleValue, options: ByRoleOptions): boolean => {\n const numericChecks: [WidgetValueField, number | undefined][] = [\n [\"now\", value.now],\n [\"min\", value.min],\n [\"max\", value.max],\n ];\n\n for (const [field, expected] of numericChecks) {\n if (!isNumericValueMatch(widget, field, expected)) {\n return false;\n }\n }\n\n return value.text === undefined || isTextMatch(getWidgetValueText(widget), value.text, widget, options);\n};\n\nconst hasMatchingBooleanStates = (widget: Gtk.Widget, options: ByRoleOptions): boolean => {\n const stateChecks: [boolean | undefined, () => boolean | null][] = [\n [options.checked, () => isWidgetChecked(widget)],\n [options.pressed, () => getWidgetPressedState(widget)],\n [options.expanded, () => getWidgetExpandedState(widget)],\n [options.selected, () => getWidgetSelectedState(widget)],\n [options.busy, () => getWidgetBusyState(widget) ?? false],\n ];\n\n for (const [expected, getActual] of stateChecks) {\n if (expected !== undefined && getActual() !== expected) {\n return false;\n }\n }\n\n return true;\n};\n\nconst hasMatchingLevelState = (widget: Gtk.Widget, options: ByRoleOptions): boolean =>\n options.level === undefined || getWidgetLevel(widget) === options.level;\n\nconst hasMatchingDescriptionState = (widget: Gtk.Widget, options: ByRoleOptions): boolean =>\n options.description === undefined ||\n isTextMatch(getWidgetDescription(widget), options.description, widget, options);\n\nconst hasMatchingValueState = (widget: Gtk.Widget, options: ByRoleOptions): boolean =>\n options.value === undefined || hasMatchingAccessibleValue(widget, options.value, options);\n\nconst hasMatchingAccessibleStates = (widget: Gtk.Widget, options: ByRoleOptions): boolean =>\n hasMatchingBooleanStates(widget, options) &&\n hasMatchingLevelState(widget, options) &&\n hasMatchingDescriptionState(widget, options) &&\n hasMatchingValueState(widget, options);\n\nconst isMatchingWidgetType = <T extends Gtk.Accessible>(\n widget: Gtk.Widget,\n options?: MatcherOptions<T>,\n): widget is Gtk.Widget & T =>\n options?.as === undefined || widget instanceof options.as;\n\nconst hasMatchingAccessibleOptions = (widget: Gtk.Widget, options?: ByRoleOptions): boolean => {\n if (!options) {\n return true;\n }\n\n return (\n hasMatchingAccessibleName(widget, options) &&\n hasMatchingAccessibleStates(widget, options)\n );\n};\n\nfunction nameQueryFamily<Args extends unknown[], Element extends Gtk.Accessible>(\n suffix: string,\n queryAllBy: QueryAllBy<Args, Element>,\n built: BuiltQueries<Args, Element>,\n): Record<string, unknown> {\n const [queryBy, getAllBy, getBy, findAllBy, findBy] = built;\n\n return {\n [`queryBy${suffix}`]: queryBy,\n [`queryAllBy${suffix}`]: queryAllBy,\n [`getBy${suffix}`]: getBy,\n [`getAllBy${suffix}`]: getAllBy,\n [`findBy${suffix}`]: findBy,\n [`findAllBy${suffix}`]: findAllBy,\n };\n}\n\n/**\n * Finds every widget under the container whose accessible role matches `role` and that satisfies the given options.\n * Widgets that are not mapped are never matched, and widgets excluded from the accessibility tree are\n * skipped unless `options.hidden` is set.\n * @param container Widget subtree to search.\n * @param role Accessible role to match.\n * @param options Additional accessible name, state, and value constraints.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByRole<T extends Gtk.Accessible = Gtk.Widget>(\n container: Container,\n role: Gtk.AccessibleRole,\n options?: ByRoleOptions<T>,\n): T[] {\n const isInaccessible = buildInaccessibilityCheck();\n\n const matches = findAll(container, (widget) => {\n if (widget.getAccessibleRole() !== role) {\n return false;\n }\n\n if (!isMatchingWidgetType(widget, options)) {\n return false;\n }\n\n if (!options?.hidden && isInaccessible(widget)) {\n return false;\n }\n\n return hasMatchingAccessibleOptions(widget, options);\n });\n\n return matches.filter((widget): widget is Gtk.Widget & T => isMatchingWidgetType(widget, options));\n}\n\nconst collectMnemonicMatch = (\n widget: Gtk.Widget,\n text: Matcher,\n options: MatcherOptions | undefined,\n): Gtk.Widget | null => {\n if (!(widget instanceof Gtk.Label)) {\n return null;\n }\n\n const labelText = namingLabelText(widget);\n\n if (!labelText || !isTextMatch(labelText, text, widget, options)) {\n return null;\n }\n\n return widget.getMnemonicWidget();\n};\n\nconst labellingText = (widget: Gtk.Widget): string | null => {\n const ownLabel = widget.getAccessibleRole() === Gtk.AccessibleRole.LABEL ? null : getWidgetOwnLabel(widget);\n\n return ownLabel ?? getWidgetExternalLabelText(widget);\n};\n\nconst collectLabelMatches = (\n results: Set<Gtk.Widget>,\n widget: Gtk.Widget,\n text: Matcher,\n options: MatcherOptions | undefined,\n): void => {\n const mnemonicTarget = collectMnemonicMatch(widget, text, options);\n\n if (mnemonicTarget) {\n results.add(mnemonicTarget);\n }\n\n const labelText = labellingText(widget);\n\n if (labelText !== null && isTextMatch(labelText, text, widget, options)) {\n results.add(widget);\n }\n};\n\n/**\n * Finds every widget associated with a label whose text matches: a Gtk.Label mnemonic target, the\n * widget's own accessible label, or its labelled-by relation. Widgets that are not mapped are never matched.\n * @param container Widget subtree to search.\n * @param text Matcher for the label text.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByLabelText<T extends Gtk.Accessible = Gtk.Widget>(\n container: Container,\n text: Matcher,\n options?: MatcherOptions<T>,\n): T[] {\n const results: Set<Gtk.Widget> = new Set();\n\n for (const widget of traverse(container)) {\n collectLabelMatches(results, widget, text, options);\n }\n\n return [...results].filter((widget): widget is Gtk.Widget & T => isMatchingWidgetType(widget, options));\n}\n\n/**\n * Finds every widget whose rendered text content matches. Widgets that are not mapped are never matched.\n * @param container Widget subtree to search.\n * @param text Matcher for the widget text.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByText<T extends Gtk.Accessible = Gtk.Widget>(\n container: Container,\n text: Matcher,\n options?: MatcherOptions<T>,\n): T[] {\n const matches = findAll(\n container,\n (widget) =>\n isMatchingWidgetType(widget, options) && isTextMatch(getWidgetLabelText(widget), text, widget, options),\n );\n\n return matches.filter((widget): widget is Gtk.Widget & T => isMatchingWidgetType(widget, options));\n}\n\n/**\n * Finds every widget whose widget name matches. Widgets that are not mapped are never matched.\n * @param container Widget subtree to search.\n * @param name Matcher for the widget name.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByName<T extends Gtk.Accessible = Gtk.Widget>(\n container: Container,\n name: Matcher,\n options?: MatcherOptions<T>,\n): T[] {\n const matches = findAll(\n container,\n (widget) => isMatchingWidgetType(widget, options) && isTextMatch(getWidgetName(widget), name, widget, options),\n );\n\n return matches.filter((widget): widget is Gtk.Widget & T => isMatchingWidgetType(widget, options));\n}\n\n/**\n * Finds every widget whose placeholder text matches. Widgets that are not mapped are never matched.\n * @param container Widget subtree to search.\n * @param text Matcher for the placeholder text.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByPlaceholderText<T extends Gtk.Accessible = Gtk.Widget>(\n container: Container,\n text: Matcher,\n options?: MatcherOptions<T>,\n): T[] {\n const matches = findAll(\n container,\n (widget) =>\n isMatchingWidgetType(widget, options) &&\n isTextMatch(getWidgetPlaceholderText(widget), text, widget, options),\n );\n\n return matches.filter((widget): widget is Gtk.Widget & T => isMatchingWidgetType(widget, options));\n}\n\n/**\n * Finds every widget whose current display value matches. Widgets that are not mapped are never matched.\n * @param container Widget subtree to search.\n * @param value Matcher for the display value.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByDisplayValue<T extends Gtk.Accessible = Gtk.Widget>(\n container: Container,\n value: Matcher,\n options?: MatcherOptions<T>,\n): T[] {\n const matches = findAll(\n container,\n (widget) =>\n isMatchingWidgetType(widget, options) &&\n isTextMatch(getWidgetDisplayValue(widget), value, widget, options),\n );\n\n return matches.filter((widget): widget is Gtk.Widget & T => isMatchingWidgetType(widget, options));\n}\n\nexport {\n builtinQueries,\n isMatchingWidgetType,\n isTextMatch,\n queryByRole,\n getAllByRole,\n getByRole,\n findAllByRole,\n findByRole,\n queryByLabelText,\n getAllByLabelText,\n getByLabelText,\n findAllByLabelText,\n findByLabelText,\n queryByText,\n getAllByText,\n getByText,\n findAllByText,\n findByText,\n queryByName,\n getAllByName,\n getByName,\n findAllByName,\n findByName,\n queryByPlaceholderText,\n getAllByPlaceholderText,\n getByPlaceholderText,\n findAllByPlaceholderText,\n findByPlaceholderText,\n queryByDisplayValue,\n getAllByDisplayValue,\n getByDisplayValue,\n findAllByDisplayValue,\n findByDisplayValue,\n queryAllByRole,\n queryAllByLabelText,\n queryAllByText,\n queryAllByName,\n queryAllByPlaceholderText,\n queryAllByDisplayValue,\n};\n"]}
|
package/dist/query-helpers.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ declare const queryHelpers: QueryHelpers;
|
|
|
27
27
|
* @param options Text matching options.
|
|
28
28
|
* @returns Every matching widget, or an empty array when none match.
|
|
29
29
|
*/
|
|
30
|
-
declare function queryAllByObjectProperty(property: string, container: Container, text: Matcher, options?: MatcherOptions):
|
|
30
|
+
declare function queryAllByObjectProperty<T extends Gtk.Accessible = Gtk.Widget>(property: string, container: Container, text: Matcher, options?: MatcherOptions<T>): T[];
|
|
31
31
|
/**
|
|
32
32
|
* Returns the single widget carrying a GObject property whose value matches, or null when none do,
|
|
33
33
|
* the counterpart of DOM Testing Library's `queryByAttribute`.
|
|
@@ -39,6 +39,6 @@ declare function queryAllByObjectProperty(property: string, container: Container
|
|
|
39
39
|
* @returns The matching widget, or null when none match.
|
|
40
40
|
* @throws When more than one widget matches.
|
|
41
41
|
*/
|
|
42
|
-
declare function queryByObjectProperty(property: string, container: Container, text: Matcher, options?: MatcherOptions):
|
|
42
|
+
declare function queryByObjectProperty<T extends Gtk.Accessible = Gtk.Widget>(property: string, container: Container, text: Matcher, options?: MatcherOptions<T>): T | null;
|
|
43
43
|
export { queryAllByObjectProperty, queryByObjectProperty, queryHelpers, type QueryHelpers };
|
|
44
44
|
//# sourceMappingURL=query-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-helpers.d.ts","sourceRoot":"","sources":["../src/query-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,gBAAgB,CAAC;AAEzD,kGAAkG;AAClG,KAAK,YAAY,GAAG;IAChB,wEAAwE;IACxE,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,+CAA+C;IAC/C,eAAe,EAAE,OAAO,eAAe,CAAC;IACxC,yDAAyD;IACzD,wBAAwB,EAAE,OAAO,wBAAwB,CAAC;IAC1D,8DAA8D;IAC9D,qBAAqB,EAAE,OAAO,qBAAqB,CAAC;CACvD,CAAC;AAEF,wFAAwF;AACxF,QAAA,MAAM,YAAY,EAAE,YAKnB,CAAC;
|
|
1
|
+
{"version":3,"file":"query-helpers.d.ts","sourceRoot":"","sources":["../src/query-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,gBAAgB,CAAC;AAEzD,kGAAkG;AAClG,KAAK,YAAY,GAAG;IAChB,wEAAwE;IACxE,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,+CAA+C;IAC/C,eAAe,EAAE,OAAO,eAAe,CAAC;IACxC,yDAAyD;IACzD,wBAAwB,EAAE,OAAO,wBAAwB,CAAC;IAC1D,8DAA8D;IAC9D,qBAAqB,EAAE,OAAO,qBAAqB,CAAC;CACvD,CAAC;AAEF,wFAAwF;AACxF,QAAA,MAAM,YAAY,EAAE,YAKnB,CAAC;AAsBF;;;;;;;;;;GAUG;AACH,iBAAS,wBAAwB,CAAC,CAAC,SAAS,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,EACnE,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAC5B,CAAC,EAAE,CASL;AAED;;;;;;;;;;GAUG;AACH,iBAAS,qBAAqB,CAAC,CAAC,SAAS,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,EAChE,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAC5B,CAAC,GAAG,IAAI,CAWV;AAED,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,CAAC"}
|
package/dist/query-helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getProperty } from "@gtkx/gi/gobject";
|
|
2
2
|
import { buildQueries } from "./build-queries.js";
|
|
3
3
|
import { getElementError } from "./errors.js";
|
|
4
4
|
import { isMatchingWidgetType, isTextMatch } from "./queries.js";
|
|
@@ -11,7 +11,13 @@ const queryHelpers = {
|
|
|
11
11
|
queryByObjectProperty,
|
|
12
12
|
};
|
|
13
13
|
const readObjectProperty = (widget, property) => {
|
|
14
|
-
|
|
14
|
+
let value;
|
|
15
|
+
try {
|
|
16
|
+
value = Reflect.apply(getProperty, undefined, [widget, property]);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
15
21
|
if (typeof value === "string") {
|
|
16
22
|
return value;
|
|
17
23
|
}
|
|
@@ -32,8 +38,9 @@ const readObjectProperty = (widget, property) => {
|
|
|
32
38
|
* @returns Every matching widget, or an empty array when none match.
|
|
33
39
|
*/
|
|
34
40
|
function queryAllByObjectProperty(property, container, text, options) {
|
|
35
|
-
|
|
41
|
+
const matches = findAll(container, (widget) => isMatchingWidgetType(widget, options) &&
|
|
36
42
|
isTextMatch(readObjectProperty(widget, property), text, widget, options));
|
|
43
|
+
return matches.filter((widget) => isMatchingWidgetType(widget, options));
|
|
37
44
|
}
|
|
38
45
|
/**
|
|
39
46
|
* Returns the single widget carrying a GObject property whose value matches, or null when none do,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-helpers.js","sourceRoot":"","sources":["../src/query-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"query-helpers.js","sourceRoot":"","sources":["../src/query-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAkB,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAczD,wFAAwF;AACxF,MAAM,YAAY,GAAiB;IAC/B,YAAY;IACZ,eAAe;IACf,wBAAwB;IACxB,qBAAqB;CACxB,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,MAAkB,EAAE,QAAgB,EAAiB,EAAE;IAC/E,IAAI,KAAc,CAAC;IAEnB,IAAI,CAAC;QACD,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACtE,CAAC;IAAC,MAAM,CAA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BAAwB,EAAE,qBAAqB,EAAE,YAAY,EAAqB,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { getProperty } from \"@gtkx/gi/gobject\";\nimport type { Matcher, MatcherOptions } from \"./types.js\";\nimport { buildQueries } from \"./build-queries.js\";\nimport { getElementError } from \"./errors.js\";\nimport { isMatchingWidgetType, isTextMatch } from \"./queries.js\";\nimport { type Container, findAll } from \"./traversal.js\";\n\n/** The helpers used to build custom queries, bundled the way DOM Testing Library exposes them. */\ntype QueryHelpers = {\n /** Derives a query family's variants from its `queryAllBy` function. */\n buildQueries: typeof buildQueries;\n /** Builds the error a failing query throws. */\n getElementError: typeof getElementError;\n /** Finds every widget whose GObject property matches. */\n queryAllByObjectProperty: typeof queryAllByObjectProperty;\n /** Finds the single widget whose GObject property matches. */\n queryByObjectProperty: typeof queryByObjectProperty;\n};\n\n/** The query-building helpers, bundled so they can be reached under a single import. */\nconst queryHelpers: QueryHelpers = {\n buildQueries,\n getElementError,\n queryAllByObjectProperty,\n queryByObjectProperty,\n};\n\nconst readObjectProperty = (widget: Gtk.Widget, property: string): string | null => {\n let value: unknown;\n\n try {\n value = Reflect.apply(getProperty, undefined, [widget, property]);\n } catch {\n return null;\n }\n\n if (typeof value === \"string\") {\n return value;\n }\n\n if (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") {\n return String(value);\n }\n\n return null;\n};\n\n/**\n * Finds every widget carrying a GObject property whose value matches, the counterpart of DOM Testing\n * Library's `queryAllByAttribute`. The property name may be given in kebab-case or camelCase, and\n * widgets that are not mapped are never matched.\n *\n * @param property Name of the GObject property to read.\n * @param container Widget subtree to search.\n * @param text Matcher for the property's value.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByObjectProperty<T extends Gtk.Accessible = Gtk.Widget>(\n property: string,\n container: Container,\n text: Matcher,\n options?: MatcherOptions<T>,\n): T[] {\n const matches = findAll(\n container,\n (widget) =>\n isMatchingWidgetType(widget, options) &&\n isTextMatch(readObjectProperty(widget, property), text, widget, options),\n );\n\n return matches.filter((widget): widget is Gtk.Widget & T => isMatchingWidgetType(widget, options));\n}\n\n/**\n * Returns the single widget carrying a GObject property whose value matches, or null when none do,\n * the counterpart of DOM Testing Library's `queryByAttribute`.\n *\n * @param property Name of the GObject property to read.\n * @param container Widget subtree to search.\n * @param text Matcher for the property's value.\n * @param options Text matching options.\n * @returns The matching widget, or null when none match.\n * @throws When more than one widget matches.\n */\nfunction queryByObjectProperty<T extends Gtk.Accessible = Gtk.Widget>(\n property: string,\n container: Container,\n text: Matcher,\n options?: MatcherOptions<T>,\n): T | null {\n const matches = queryAllByObjectProperty(property, container, text, options);\n\n if (matches.length > 1) {\n throw getElementError(\n `Found ${String(matches.length)} elements with the '${property}' property, but expected only one`,\n container,\n );\n }\n\n return matches[0] ?? null;\n}\n\nexport { queryAllByObjectProperty, queryByObjectProperty, queryHelpers, type QueryHelpers };\n"]}
|
package/dist/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.tsx"],"names":[],"mappings":"AASA,OAAO,EAAkB,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAqB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.tsx"],"names":[],"mappings":"AASA,OAAO,EAAkB,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAqB,MAAM,YAAY,CAAC;AAyM7E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,MAAM,GAAU,CAAC,SAAS,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAC3D,SAAS,SAAS,EAClB,UAAU,aAAa,CAAC,CAAC,CAAC,KAC3B,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAoDzB,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,OAAO,QAAa,OAAO,CAAC,IAAI,CAErC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/render.js
CHANGED
|
@@ -13,6 +13,7 @@ import { clearScreen, setScreen } from "./screen.js";
|
|
|
13
13
|
import { captureScreen } from "./screenshot.js";
|
|
14
14
|
import { roots, TOPLEVELS } from "./traversal.js";
|
|
15
15
|
import { resetClipboard } from "./user-event/index.js";
|
|
16
|
+
import { requireWidget } from "./widget-target.js";
|
|
16
17
|
import { findPresentedWindowFailure, findRenderedWindowFailure, mappedToplevels } from "./window-state.js";
|
|
17
18
|
import { within } from "./within.js";
|
|
18
19
|
const reconcilerErrors = { lastError: null, isHandlerInstalled: false };
|
|
@@ -70,6 +71,9 @@ const resolveContainer = (container) => {
|
|
|
70
71
|
if (container instanceof Gtk.Widget) {
|
|
71
72
|
return { containerInfo: container, window: null };
|
|
72
73
|
}
|
|
74
|
+
if (container !== undefined) {
|
|
75
|
+
requireWidget(container);
|
|
76
|
+
}
|
|
73
77
|
const window = createHarnessWindow();
|
|
74
78
|
window.setDecorated(false);
|
|
75
79
|
return { containerInfo: window, window };
|