@gtkx/testing 1.0.0-rc.3 → 1.0.0
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 +8 -9
- package/dist/accessible-native.d.ts +16 -0
- package/dist/accessible-native.d.ts.map +1 -0
- package/dist/accessible-native.js +206 -0
- package/dist/accessible-native.js.map +1 -0
- package/dist/act.d.ts +2 -0
- package/dist/act.d.ts.map +1 -1
- package/dist/act.js.map +1 -1
- package/dist/build-queries.d.ts +27 -10
- package/dist/build-queries.d.ts.map +1 -1
- package/dist/build-queries.js +39 -30
- package/dist/build-queries.js.map +1 -1
- package/dist/cleanup-registry.d.ts +1 -1
- package/dist/cleanup-registry.d.ts.map +1 -1
- package/dist/cleanup-registry.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -3
- package/dist/config.js.map +1 -1
- package/dist/errors.d.ts +10 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +12 -3
- package/dist/errors.js.map +1 -1
- package/dist/fire-event.d.ts +35 -6
- package/dist/fire-event.d.ts.map +1 -1
- package/dist/fire-event.js +23 -7
- package/dist/fire-event.js.map +1 -1
- package/dist/frame-sync.d.ts +2 -1
- package/dist/frame-sync.d.ts.map +1 -1
- package/dist/frame-sync.js +15 -5
- package/dist/frame-sync.js.map +1 -1
- package/dist/harness-window.d.ts +4 -0
- package/dist/harness-window.d.ts.map +1 -0
- package/dist/harness-window.js +6 -0
- package/dist/harness-window.js.map +1 -0
- package/dist/index.d.ts +14 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +4 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +4 -0
- package/dist/internal.js.map +1 -0
- package/dist/matchers.d.ts +125 -39
- package/dist/matchers.d.ts.map +1 -1
- package/dist/matchers.js +156 -18
- package/dist/matchers.js.map +1 -1
- package/dist/pretty-format.d.ts +2 -0
- package/dist/pretty-format.d.ts.map +1 -0
- package/dist/pretty-format.js +2 -0
- package/dist/pretty-format.js.map +1 -0
- package/dist/pretty-widget.d.ts +7 -3
- package/dist/pretty-widget.d.ts.map +1 -1
- package/dist/pretty-widget.js +74 -57
- package/dist/pretty-widget.js.map +1 -1
- package/dist/production.d.ts +8 -0
- package/dist/production.d.ts.map +1 -0
- package/dist/production.js +34 -0
- package/dist/production.js.map +1 -0
- package/dist/queries.d.ts +99 -56
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +123 -83
- package/dist/queries.js.map +1 -1
- package/dist/query-helpers.d.ts +44 -0
- package/dist/query-helpers.d.ts.map +1 -0
- package/dist/query-helpers.js +57 -0
- package/dist/query-helpers.js.map +1 -0
- package/dist/render-children.d.ts +9 -0
- package/dist/render-children.d.ts.map +1 -0
- package/dist/render-children.js +11 -0
- package/dist/render-children.js.map +1 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +13 -11
- package/dist/render.js.map +1 -1
- package/dist/role-helpers.d.ts +12 -3
- package/dist/role-helpers.d.ts.map +1 -1
- package/dist/role-helpers.js +13 -4
- package/dist/role-helpers.js.map +1 -1
- package/dist/role-naming.d.ts +5 -0
- package/dist/role-naming.d.ts.map +1 -0
- package/dist/role-naming.js +96 -0
- package/dist/role-naming.js.map +1 -0
- package/dist/screenshot.d.ts +12 -20
- package/dist/screenshot.d.ts.map +1 -1
- package/dist/screenshot.js +183 -91
- package/dist/screenshot.js.map +1 -1
- package/dist/suggestions.d.ts +3 -0
- package/dist/suggestions.d.ts.map +1 -1
- package/dist/suggestions.js.map +1 -1
- package/dist/traversal.d.ts +9 -1
- package/dist/traversal.d.ts.map +1 -1
- package/dist/traversal.js +26 -6
- package/dist/traversal.js.map +1 -1
- package/dist/types.d.ts +67 -17
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/user-event/adjustment.d.ts +16 -0
- package/dist/user-event/adjustment.d.ts.map +1 -1
- package/dist/user-event/adjustment.js +34 -2
- package/dist/user-event/adjustment.js.map +1 -1
- package/dist/user-event/click.d.ts +45 -3
- package/dist/user-event/click.d.ts.map +1 -1
- package/dist/user-event/click.js +177 -39
- package/dist/user-event/click.js.map +1 -1
- package/dist/user-event/column-header-click.d.ts +4 -0
- package/dist/user-event/column-header-click.d.ts.map +1 -0
- package/dist/user-event/column-header-click.js +65 -0
- package/dist/user-event/column-header-click.js.map +1 -0
- package/dist/user-event/controller.d.ts +29 -0
- package/dist/user-event/controller.d.ts.map +1 -1
- package/dist/user-event/controller.js +28 -0
- package/dist/user-event/controller.js.map +1 -1
- package/dist/user-event/event-wrapper.d.ts.map +1 -1
- package/dist/user-event/event-wrapper.js +2 -1
- package/dist/user-event/event-wrapper.js.map +1 -1
- package/dist/user-event/gesture.d.ts +51 -0
- package/dist/user-event/gesture.d.ts.map +1 -1
- package/dist/user-event/gesture.js +47 -4
- package/dist/user-event/gesture.js.map +1 -1
- package/dist/user-event/index.d.ts +70 -2
- package/dist/user-event/index.d.ts.map +1 -1
- package/dist/user-event/index.js +43 -26
- package/dist/user-event/index.js.map +1 -1
- package/dist/user-event/indexed-children.d.ts +10 -0
- package/dist/user-event/indexed-children.d.ts.map +1 -0
- package/dist/user-event/indexed-children.js +50 -0
- package/dist/user-event/indexed-children.js.map +1 -0
- package/dist/user-event/keyboard.d.ts +4 -2
- package/dist/user-event/keyboard.d.ts.map +1 -1
- package/dist/user-event/keyboard.js +46 -16
- package/dist/user-event/keyboard.js.map +1 -1
- package/dist/user-event/list-row-click.d.ts +4 -0
- package/dist/user-event/list-row-click.d.ts.map +1 -0
- package/dist/user-event/list-row-click.js +39 -0
- package/dist/user-event/list-row-click.js.map +1 -0
- package/dist/user-event/native-click.d.ts +6 -0
- package/dist/user-event/native-click.d.ts.map +1 -0
- package/dist/user-event/native-click.js +32 -0
- package/dist/user-event/native-click.js.map +1 -0
- package/dist/user-event/pointer.d.ts +1 -1
- package/dist/user-event/pointer.d.ts.map +1 -1
- package/dist/user-event/pointer.js +37 -13
- package/dist/user-event/pointer.js.map +1 -1
- package/dist/user-event/selection.d.ts +18 -0
- package/dist/user-event/selection.d.ts.map +1 -1
- package/dist/user-event/selection.js +56 -30
- package/dist/user-event/selection.js.map +1 -1
- package/dist/user-event/state.d.ts +1 -1
- package/dist/user-event/state.d.ts.map +1 -1
- package/dist/user-event/state.js +1 -1
- package/dist/user-event/state.js.map +1 -1
- package/dist/user-event/text.d.ts +34 -3
- package/dist/user-event/text.d.ts.map +1 -1
- package/dist/user-event/text.js +94 -17
- package/dist/user-event/text.js.map +1 -1
- package/dist/wait-for.d.ts +2 -0
- package/dist/wait-for.d.ts.map +1 -1
- package/dist/wait-for.js.map +1 -1
- package/dist/widget-accessible-properties.d.ts +14 -10
- package/dist/widget-accessible-properties.d.ts.map +1 -1
- package/dist/widget-accessible-properties.js +135 -173
- package/dist/widget-accessible-properties.js.map +1 -1
- package/dist/widget-getters.d.ts +8 -0
- package/dist/widget-getters.d.ts.map +1 -0
- package/dist/widget-getters.js +19 -0
- package/dist/widget-getters.js.map +1 -0
- package/dist/within.d.ts +3 -2
- package/dist/within.d.ts.map +1 -1
- package/dist/within.js +3 -2
- package/dist/within.js.map +1 -1
- package/package.json +13 -8
- package/src/accessible-native.ts +333 -0
- package/src/act.ts +2 -0
- package/src/build-queries.ts +66 -48
- package/src/cleanup-registry.ts +1 -1
- package/src/config.ts +4 -3
- package/src/errors.ts +14 -3
- package/src/fire-event.ts +61 -8
- package/src/frame-sync.ts +21 -5
- package/src/harness-window.ts +9 -0
- package/src/index.ts +18 -11
- package/src/internal.ts +11 -0
- package/src/matchers.ts +466 -64
- package/src/pretty-format.ts +1 -0
- package/src/pretty-widget.ts +100 -72
- package/src/production.ts +52 -0
- package/src/queries.ts +128 -89
- package/src/query-helpers.ts +97 -0
- package/src/render-children.ts +25 -0
- package/src/render.tsx +18 -13
- package/src/role-helpers.ts +14 -4
- package/src/role-naming.ts +99 -0
- package/src/screenshot.ts +272 -103
- package/src/suggestions.ts +3 -0
- package/src/traversal.ts +49 -6
- package/src/types.ts +69 -19
- package/src/user-event/adjustment.ts +42 -2
- package/src/user-event/click.ts +248 -46
- package/src/user-event/column-header-click.ts +90 -0
- package/src/user-event/controller.ts +29 -0
- package/src/user-event/event-wrapper.ts +3 -1
- package/src/user-event/gesture.ts +57 -6
- package/src/user-event/index.ts +119 -29
- package/src/user-event/indexed-children.ts +75 -0
- package/src/user-event/keyboard.ts +70 -20
- package/src/user-event/list-row-click.ts +57 -0
- package/src/user-event/native-click.ts +46 -0
- package/src/user-event/pointer.ts +52 -13
- package/src/user-event/selection.ts +74 -33
- package/src/user-event/state.ts +2 -2
- package/src/user-event/text.ts +121 -23
- package/src/wait-for.ts +2 -0
- package/src/widget-accessible-properties.ts +183 -214
- package/src/widget-getters.ts +32 -0
- package/src/within.ts +3 -2
package/dist/queries.js
CHANGED
|
@@ -3,13 +3,13 @@ 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,
|
|
7
|
-
const roleQueries = nameQueryFamily("Role", queryAllByRole, buildQueries(
|
|
8
|
-
const labelTextQueries = nameQueryFamily("LabelText", queryAllByLabelText, buildQueries(
|
|
9
|
-
const textQueries = nameQueryFamily("Text", queryAllByText, buildQueries(
|
|
10
|
-
const nameQueries = nameQueryFamily("Name", queryAllByName, buildQueries(
|
|
11
|
-
const placeholderTextQueries = nameQueryFamily("PlaceholderText", queryAllByPlaceholderText, buildQueries(
|
|
12
|
-
const displayValueQueries = nameQueryFamily("DisplayValue", queryAllByDisplayValue, buildQueries(
|
|
6
|
+
import { getWidgetAccessibleName, getWidgetBusyState, getWidgetDescription, getWidgetDisplayValue, getWidgetExpandedState, getWidgetExternalLabelText, getWidgetLabelText, getWidgetLevel, getWidgetName, getWidgetOwnLabel, getWidgetPlaceholderText, getWidgetPressedState, getWidgetSelectedState, getWidgetValueText, isInaccessible, isWidgetChecked, isWidgetValueMatch, namingLabelText, } from "./widget-accessible-properties.js";
|
|
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
|
+
const labelTextQueries = nameQueryFamily("LabelText", queryAllByLabelText, buildQueries(queryAllByLabelText, (container, matches, text) => multipleFoundError(container, { queryType: "labelText", text }, matches), (container, text) => notFoundError(container, { queryType: "labelText", text })));
|
|
9
|
+
const textQueries = nameQueryFamily("Text", queryAllByText, buildQueries(queryAllByText, (container, matches, text) => multipleFoundError(container, { queryType: "text", text }, matches), (container, text) => notFoundError(container, { queryType: "text", text })));
|
|
10
|
+
const nameQueries = nameQueryFamily("Name", queryAllByName, buildQueries(queryAllByName, (container, matches, name) => multipleFoundError(container, { queryType: "name", name }, matches), (container, name) => notFoundError(container, { queryType: "name", name })));
|
|
11
|
+
const placeholderTextQueries = nameQueryFamily("PlaceholderText", queryAllByPlaceholderText, buildQueries(queryAllByPlaceholderText, (container, matches, text) => multipleFoundError(container, { queryType: "placeholderText", text }, matches), (container, text) => notFoundError(container, { queryType: "placeholderText", text })));
|
|
12
|
+
const displayValueQueries = nameQueryFamily("DisplayValue", queryAllByDisplayValue, buildQueries(queryAllByDisplayValue, (container, matches, value) => multipleFoundError(container, { queryType: "displayValue", value }, matches), (container, value) => notFoundError(container, { queryType: "displayValue", value })));
|
|
13
13
|
const builtinQueries = {
|
|
14
14
|
...roleQueries,
|
|
15
15
|
...labelTextQueries,
|
|
@@ -19,120 +19,159 @@ const builtinQueries = {
|
|
|
19
19
|
...displayValueQueries,
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
|
-
* Returns the single widget with a matching accessible role and options, or null when none
|
|
23
|
-
* Throws when more than one matches.
|
|
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
24
|
*/
|
|
25
25
|
const queryByRole = builtinQueries.queryByRole;
|
|
26
|
-
/**
|
|
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
|
+
*/
|
|
27
30
|
const getAllByRole = builtinQueries.getAllByRole;
|
|
28
31
|
/**
|
|
29
|
-
* Returns the single widget with a matching accessible role and options.
|
|
30
|
-
* Throws when none or more than one matches.
|
|
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.
|
|
31
34
|
*/
|
|
32
35
|
const getByRole = builtinQueries.getByRole;
|
|
33
36
|
/**
|
|
34
|
-
* Waits for and returns every widget with a matching accessible role and options, retrying
|
|
35
|
-
* least one appears or the timeout elapses.
|
|
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.
|
|
36
39
|
*/
|
|
37
40
|
const findAllByRole = builtinQueries.findAllByRole;
|
|
38
41
|
/**
|
|
39
|
-
* Waits for and returns the single widget with a matching accessible role and options,
|
|
40
|
-
* until it appears or the timeout elapses.
|
|
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.
|
|
41
45
|
*/
|
|
42
46
|
const findByRole = builtinQueries.findByRole;
|
|
43
47
|
/**
|
|
44
|
-
* Returns the single widget with matching associated label text, or null when none match.
|
|
45
|
-
* Throws when more than one matches.
|
|
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.
|
|
46
50
|
*/
|
|
47
51
|
const queryByLabelText = builtinQueries.queryByLabelText;
|
|
48
|
-
/**
|
|
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
|
+
*/
|
|
49
56
|
const getAllByLabelText = builtinQueries.getAllByLabelText;
|
|
50
|
-
/**
|
|
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
|
+
*/
|
|
51
61
|
const getByLabelText = builtinQueries.getByLabelText;
|
|
52
62
|
/**
|
|
53
|
-
* Waits for and returns every widget with matching associated label text, retrying until at
|
|
54
|
-
* one appears or the timeout elapses.
|
|
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.
|
|
55
65
|
*/
|
|
56
66
|
const findAllByLabelText = builtinQueries.findAllByLabelText;
|
|
57
67
|
/**
|
|
58
|
-
* Waits for and returns the single widget with matching associated label text, retrying until
|
|
59
|
-
* appears or the timeout elapses.
|
|
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.
|
|
60
71
|
*/
|
|
61
72
|
const findByLabelText = builtinQueries.findByLabelText;
|
|
62
73
|
/**
|
|
63
|
-
* Returns the single widget with matching rendered text content, or null when none match.
|
|
64
|
-
* Throws when more than one matches.
|
|
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.
|
|
65
76
|
*/
|
|
66
77
|
const queryByText = builtinQueries.queryByText;
|
|
67
|
-
/**
|
|
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
|
+
*/
|
|
68
82
|
const getAllByText = builtinQueries.getAllByText;
|
|
69
|
-
/**
|
|
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
|
+
*/
|
|
70
87
|
const getByText = builtinQueries.getByText;
|
|
71
88
|
/**
|
|
72
|
-
* Waits for and returns every widget with matching rendered text content, retrying until at
|
|
73
|
-
* one appears or the timeout elapses.
|
|
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.
|
|
74
91
|
*/
|
|
75
92
|
const findAllByText = builtinQueries.findAllByText;
|
|
76
93
|
/**
|
|
77
|
-
* Waits for and returns the single widget with matching rendered text content, retrying until
|
|
78
|
-
* appears or the timeout elapses.
|
|
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.
|
|
79
97
|
*/
|
|
80
98
|
const findByText = builtinQueries.findByText;
|
|
81
99
|
/**
|
|
82
|
-
* Returns the single widget with a matching widget name, or null when none match.
|
|
83
|
-
* Throws when more than one matches.
|
|
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.
|
|
84
102
|
*/
|
|
85
103
|
const queryByName = builtinQueries.queryByName;
|
|
86
|
-
/**
|
|
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
|
+
*/
|
|
87
108
|
const getAllByName = builtinQueries.getAllByName;
|
|
88
|
-
/**
|
|
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
|
+
*/
|
|
89
113
|
const getByName = builtinQueries.getByName;
|
|
90
114
|
/**
|
|
91
|
-
* Waits for and returns every widget with a matching widget name, retrying until at least one
|
|
92
|
-
* appears or the timeout elapses.
|
|
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.
|
|
93
117
|
*/
|
|
94
118
|
const findAllByName = builtinQueries.findAllByName;
|
|
95
119
|
/**
|
|
96
|
-
* Waits for and returns the single widget with a matching widget name, retrying until it
|
|
97
|
-
* the timeout elapses.
|
|
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.
|
|
98
123
|
*/
|
|
99
124
|
const findByName = builtinQueries.findByName;
|
|
100
125
|
/**
|
|
101
|
-
* Returns the single widget with matching placeholder text, or null when none match.
|
|
102
|
-
* Throws when more than one matches.
|
|
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.
|
|
103
128
|
*/
|
|
104
129
|
const queryByPlaceholderText = builtinQueries.queryByPlaceholderText;
|
|
105
|
-
/**
|
|
130
|
+
/**
|
|
131
|
+
* Returns every mapped widget with matching placeholder text. Widgets that are not mapped are never
|
|
132
|
+
* matched. Throws when none match.
|
|
133
|
+
*/
|
|
106
134
|
const getAllByPlaceholderText = builtinQueries.getAllByPlaceholderText;
|
|
107
|
-
/**
|
|
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
|
+
*/
|
|
108
139
|
const getByPlaceholderText = builtinQueries.getByPlaceholderText;
|
|
109
140
|
/**
|
|
110
|
-
* Waits for and returns every widget with matching placeholder text, retrying until at least
|
|
111
|
-
* appears or the timeout elapses.
|
|
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.
|
|
112
143
|
*/
|
|
113
144
|
const findAllByPlaceholderText = builtinQueries.findAllByPlaceholderText;
|
|
114
145
|
/**
|
|
115
|
-
* Waits for and returns the single widget with matching placeholder text, retrying until it
|
|
116
|
-
* or the timeout elapses.
|
|
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.
|
|
117
149
|
*/
|
|
118
150
|
const findByPlaceholderText = builtinQueries.findByPlaceholderText;
|
|
119
151
|
/**
|
|
120
|
-
* Returns the single widget with a matching display value, or null when none match.
|
|
121
|
-
* Throws when more than one matches.
|
|
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.
|
|
122
154
|
*/
|
|
123
155
|
const queryByDisplayValue = builtinQueries.queryByDisplayValue;
|
|
124
|
-
/**
|
|
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
|
+
*/
|
|
125
160
|
const getAllByDisplayValue = builtinQueries.getAllByDisplayValue;
|
|
126
|
-
/**
|
|
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
|
+
*/
|
|
127
165
|
const getByDisplayValue = builtinQueries.getByDisplayValue;
|
|
128
166
|
/**
|
|
129
|
-
* Waits for and returns every widget with a matching display value, retrying until at least
|
|
130
|
-
* appears or the timeout elapses.
|
|
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.
|
|
131
169
|
*/
|
|
132
170
|
const findAllByDisplayValue = builtinQueries.findAllByDisplayValue;
|
|
133
171
|
/**
|
|
134
|
-
* Waits for and returns the single widget with a matching display value, retrying until it
|
|
135
|
-
* or the timeout elapses.
|
|
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.
|
|
136
175
|
*/
|
|
137
176
|
const findByDisplayValue = builtinQueries.findByDisplayValue;
|
|
138
177
|
const buildNormalizer = (options) => {
|
|
@@ -176,20 +215,19 @@ const hasMatchingAccessibleName = (widget, options) => {
|
|
|
176
215
|
const text = getWidgetAccessibleName(widget);
|
|
177
216
|
return isTextMatch(text, options.name, widget, options);
|
|
178
217
|
};
|
|
179
|
-
const isNumericValueMatch = (
|
|
218
|
+
const isNumericValueMatch = (widget, field, expected) => expected === undefined || isWidgetValueMatch(widget, field, expected);
|
|
180
219
|
const hasMatchingAccessibleValue = (widget, value, options) => {
|
|
181
|
-
const actual = getWidgetValue(widget);
|
|
182
220
|
const numericChecks = [
|
|
183
|
-
[
|
|
184
|
-
[
|
|
185
|
-
[
|
|
221
|
+
["now", value.now],
|
|
222
|
+
["min", value.min],
|
|
223
|
+
["max", value.max],
|
|
186
224
|
];
|
|
187
|
-
for (const [
|
|
188
|
-
if (!isNumericValueMatch(
|
|
225
|
+
for (const [field, expected] of numericChecks) {
|
|
226
|
+
if (!isNumericValueMatch(widget, field, expected)) {
|
|
189
227
|
return false;
|
|
190
228
|
}
|
|
191
229
|
}
|
|
192
|
-
return value.text === undefined || isTextMatch(
|
|
230
|
+
return value.text === undefined || isTextMatch(getWidgetValueText(widget), value.text, widget, options);
|
|
193
231
|
};
|
|
194
232
|
const hasMatchingBooleanStates = (widget, options) => {
|
|
195
233
|
const stateChecks = [
|
|
@@ -224,18 +262,20 @@ const hasMatchingByRoleOptions = (widget, options) => {
|
|
|
224
262
|
hasMatchingAccessibleStates(widget, options));
|
|
225
263
|
};
|
|
226
264
|
function nameQueryFamily(suffix, queryAllBy, built) {
|
|
265
|
+
const [queryBy, getAllBy, getBy, findAllBy, findBy] = built;
|
|
227
266
|
return {
|
|
228
|
-
[`queryBy${suffix}`]:
|
|
267
|
+
[`queryBy${suffix}`]: queryBy,
|
|
229
268
|
[`queryAllBy${suffix}`]: queryAllBy,
|
|
230
|
-
[`getBy${suffix}`]:
|
|
231
|
-
[`getAllBy${suffix}`]:
|
|
232
|
-
[`findBy${suffix}`]:
|
|
233
|
-
[`findAllBy${suffix}`]:
|
|
269
|
+
[`getBy${suffix}`]: getBy,
|
|
270
|
+
[`getAllBy${suffix}`]: getAllBy,
|
|
271
|
+
[`findBy${suffix}`]: findBy,
|
|
272
|
+
[`findAllBy${suffix}`]: findAllBy,
|
|
234
273
|
};
|
|
235
274
|
}
|
|
236
275
|
/**
|
|
237
276
|
* Finds every widget under the container whose accessible role matches `role` and that satisfies the given options.
|
|
238
|
-
* Widgets excluded from the accessibility tree are
|
|
277
|
+
* Widgets that are not mapped are never matched, and widgets excluded from the accessibility tree are
|
|
278
|
+
* skipped unless `options.hidden` is set.
|
|
239
279
|
* @param container Widget subtree to search.
|
|
240
280
|
* @param role Accessible role to match.
|
|
241
281
|
* @param options Additional accessible name, state, and value constraints.
|
|
@@ -256,29 +296,29 @@ const collectMnemonicMatch = (widget, text, options) => {
|
|
|
256
296
|
if (!(widget instanceof Gtk.Label)) {
|
|
257
297
|
return null;
|
|
258
298
|
}
|
|
259
|
-
const labelText = widget
|
|
299
|
+
const labelText = namingLabelText(widget);
|
|
260
300
|
if (!labelText || !isTextMatch(labelText, text, widget, options)) {
|
|
261
301
|
return null;
|
|
262
302
|
}
|
|
263
303
|
return widget.getMnemonicWidget();
|
|
264
304
|
};
|
|
305
|
+
const labellingText = (widget) => {
|
|
306
|
+
const ownLabel = widget.getAccessibleRole() === Gtk.AccessibleRole.LABEL ? null : getWidgetOwnLabel(widget);
|
|
307
|
+
return ownLabel ?? getWidgetExternalLabelText(widget);
|
|
308
|
+
};
|
|
265
309
|
const collectLabelMatches = (results, widget, text, options) => {
|
|
266
310
|
const mnemonicTarget = collectMnemonicMatch(widget, text, options);
|
|
267
311
|
if (mnemonicTarget) {
|
|
268
312
|
results.add(mnemonicTarget);
|
|
269
313
|
}
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
272
|
-
results.add(widget);
|
|
273
|
-
}
|
|
274
|
-
const labelledByText = getWidgetLabelledByText(widget);
|
|
275
|
-
if (labelledByText !== null && isTextMatch(labelledByText, text, widget, options)) {
|
|
314
|
+
const labelText = labellingText(widget);
|
|
315
|
+
if (labelText !== null && isTextMatch(labelText, text, widget, options)) {
|
|
276
316
|
results.add(widget);
|
|
277
317
|
}
|
|
278
318
|
};
|
|
279
319
|
/**
|
|
280
320
|
* Finds every widget associated with a label whose text matches: a Gtk.Label mnemonic target, the
|
|
281
|
-
* widget's own accessible label, or its labelled-by relation.
|
|
321
|
+
* widget's own accessible label, or its labelled-by relation. Widgets that are not mapped are never matched.
|
|
282
322
|
* @param container Widget subtree to search.
|
|
283
323
|
* @param text Matcher for the label text.
|
|
284
324
|
* @param options Text matching options.
|
|
@@ -292,7 +332,7 @@ function queryAllByLabelText(container, text, options) {
|
|
|
292
332
|
return [...results].filter((widget) => isMatchingWidgetType(widget, options));
|
|
293
333
|
}
|
|
294
334
|
/**
|
|
295
|
-
* Finds every widget whose rendered text content matches.
|
|
335
|
+
* Finds every widget whose rendered text content matches. Widgets that are not mapped are never matched.
|
|
296
336
|
* @param container Widget subtree to search.
|
|
297
337
|
* @param text Matcher for the widget text.
|
|
298
338
|
* @param options Text matching options.
|
|
@@ -302,7 +342,7 @@ function queryAllByText(container, text, options) {
|
|
|
302
342
|
return findAll(container, (widget) => isMatchingWidgetType(widget, options) && isTextMatch(getWidgetLabelText(widget), text, widget, options));
|
|
303
343
|
}
|
|
304
344
|
/**
|
|
305
|
-
* Finds every widget whose widget name matches.
|
|
345
|
+
* Finds every widget whose widget name matches. Widgets that are not mapped are never matched.
|
|
306
346
|
* @param container Widget subtree to search.
|
|
307
347
|
* @param name Matcher for the widget name.
|
|
308
348
|
* @param options Text matching options.
|
|
@@ -312,7 +352,7 @@ function queryAllByName(container, name, options) {
|
|
|
312
352
|
return findAll(container, (widget) => isMatchingWidgetType(widget, options) && isTextMatch(getWidgetName(widget), name, widget, options));
|
|
313
353
|
}
|
|
314
354
|
/**
|
|
315
|
-
* Finds every widget whose placeholder text matches.
|
|
355
|
+
* Finds every widget whose placeholder text matches. Widgets that are not mapped are never matched.
|
|
316
356
|
* @param container Widget subtree to search.
|
|
317
357
|
* @param text Matcher for the placeholder text.
|
|
318
358
|
* @param options Text matching options.
|
|
@@ -323,7 +363,7 @@ function queryAllByPlaceholderText(container, text, options) {
|
|
|
323
363
|
isTextMatch(getWidgetPlaceholderText(widget), text, widget, options));
|
|
324
364
|
}
|
|
325
365
|
/**
|
|
326
|
-
* Finds every widget whose current display value matches.
|
|
366
|
+
* Finds every widget whose current display value matches. Widgets that are not mapped are never matched.
|
|
327
367
|
* @param container Widget subtree to search.
|
|
328
368
|
* @param value Matcher for the display value.
|
|
329
369
|
* @param options Text matching options.
|
|
@@ -333,5 +373,5 @@ function queryAllByDisplayValue(container, value, options) {
|
|
|
333
373
|
return findAll(container, (widget) => isMatchingWidgetType(widget, options) &&
|
|
334
374
|
isTextMatch(getWidgetDisplayValue(widget), value, widget, options));
|
|
335
375
|
}
|
|
336
|
-
export { builtinQueries, 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, };
|
|
376
|
+
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, };
|
|
337
377
|
//# 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,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,eAAe,GAClB,MAAM,mCAAmC,CAAC;AAI3C,MAAM,WAAW,GAAG,eAAe,CAC/B,MAAM,EACN,cAAc,EACd,YAAY,CACR,MAAM,EACN,cAAc,EACd,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAClC,kBAAkB,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM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ACV,SAAS,EACT,CAAC,MAAM,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;AACN,CAAC;AAED,OAAO,EACH,cAAc,EACd,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,GAEzB,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 getWidgetLabelledByText,\n getWidgetLabelText,\n getWidgetLevel,\n getWidgetName,\n getWidgetOwnLabel,\n getWidgetPlaceholderText,\n getWidgetPressedState,\n getWidgetSelectedState,\n getWidgetValue,\n isInaccessible,\n isWidgetChecked,\n} from \"./widget-accessible-properties.js\";\n\ntype BuiltinQueries = QueryFamilies<[container: Container]>;\n\nconst roleQueries = nameQueryFamily(\n \"Role\",\n queryAllByRole,\n buildQueries<[role: Gtk.AccessibleRole, options?: ByRoleOptions]>(\n \"Role\",\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 \"LabelText\",\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 \"Text\",\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 \"Name\",\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 \"PlaceholderText\",\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 \"DisplayValue\",\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 widget with a matching accessible role and options, or null when none match.\n * Throws when more than one matches.\n */\nconst queryByRole: BuiltinQueries[\"queryByRole\"] = builtinQueries.queryByRole;\n/** Returns every widget with a matching accessible role and options. Throws when none match. */\nconst getAllByRole: BuiltinQueries[\"getAllByRole\"] = builtinQueries.getAllByRole;\n/**\n * Returns the single widget with a matching accessible role and options.\n * Throws when none or more than one matches.\n */\nconst getByRole: BuiltinQueries[\"getByRole\"] = builtinQueries.getByRole;\n/**\n * Waits for and returns every widget with a matching accessible role and options, retrying until at\n * least one appears or the timeout elapses.\n */\nconst findAllByRole: BuiltinQueries[\"findAllByRole\"] = builtinQueries.findAllByRole;\n/**\n * Waits for and returns the single widget with a matching accessible role and options, retrying\n * until it appears or the timeout elapses. Rejects when none or more than one matches.\n */\nconst findByRole: BuiltinQueries[\"findByRole\"] = builtinQueries.findByRole;\n/**\n * Returns the single widget with matching associated label text, or null when none match.\n * Throws when more than one matches.\n */\nconst queryByLabelText: BuiltinQueries[\"queryByLabelText\"] = builtinQueries.queryByLabelText;\n/** Returns every widget with matching associated label text. Throws when none match. */\nconst getAllByLabelText: BuiltinQueries[\"getAllByLabelText\"] = builtinQueries.getAllByLabelText;\n/** Returns the single widget with matching associated label text. Throws when none or more than one matches. */\nconst getByLabelText: BuiltinQueries[\"getByLabelText\"] = builtinQueries.getByLabelText;\n/**\n * Waits for and returns every widget with matching associated label text, retrying until at least\n * one appears or the timeout elapses.\n */\nconst findAllByLabelText: BuiltinQueries[\"findAllByLabelText\"] = builtinQueries.findAllByLabelText;\n/**\n * Waits for and returns the single widget with matching associated label text, retrying until it\n * appears or the timeout elapses. Rejects when none or more than one matches.\n */\nconst findByLabelText: BuiltinQueries[\"findByLabelText\"] = builtinQueries.findByLabelText;\n/**\n * Returns the single widget with matching rendered text content, or null when none match.\n * Throws when more than one matches.\n */\nconst queryByText: BuiltinQueries[\"queryByText\"] = builtinQueries.queryByText;\n/** Returns every widget with matching rendered text content. Throws when none match. */\nconst getAllByText: BuiltinQueries[\"getAllByText\"] = builtinQueries.getAllByText;\n/** Returns the single widget with matching rendered text content. Throws when none or more than one matches. */\nconst getByText: BuiltinQueries[\"getByText\"] = builtinQueries.getByText;\n/**\n * Waits for and returns every widget with matching rendered text content, retrying until at least\n * one appears or the timeout elapses.\n */\nconst findAllByText: BuiltinQueries[\"findAllByText\"] = builtinQueries.findAllByText;\n/**\n * Waits for and returns the single widget with matching rendered text content, retrying until it\n * appears or the timeout elapses. Rejects when none or more than one matches.\n */\nconst findByText: BuiltinQueries[\"findByText\"] = builtinQueries.findByText;\n/**\n * Returns the single widget with a matching widget name, or null when none match.\n * Throws when more than one matches.\n */\nconst queryByName: BuiltinQueries[\"queryByName\"] = builtinQueries.queryByName;\n/** Returns every widget with a matching widget name. Throws when none match. */\nconst getAllByName: BuiltinQueries[\"getAllByName\"] = builtinQueries.getAllByName;\n/** Returns the single widget with a matching widget name. Throws when none or more than one matches. */\nconst getByName: BuiltinQueries[\"getByName\"] = builtinQueries.getByName;\n/**\n * Waits for and returns every widget with a matching widget name, retrying until at least one\n * appears or the timeout elapses.\n */\nconst findAllByName: BuiltinQueries[\"findAllByName\"] = builtinQueries.findAllByName;\n/**\n * Waits for and returns the single widget with a matching widget name, retrying until it appears or\n * the timeout elapses. Rejects when none or more than one matches.\n */\nconst findByName: BuiltinQueries[\"findByName\"] = builtinQueries.findByName;\n/**\n * Returns the single widget with matching placeholder text, or null when none match.\n * Throws when more than one matches.\n */\nconst queryByPlaceholderText: BuiltinQueries[\"queryByPlaceholderText\"] = builtinQueries.queryByPlaceholderText;\n/** Returns every widget with matching placeholder text. Throws when none match. */\nconst getAllByPlaceholderText: BuiltinQueries[\"getAllByPlaceholderText\"] = builtinQueries.getAllByPlaceholderText;\n/** Returns the single widget with matching placeholder text. Throws when none or more than one matches. */\nconst getByPlaceholderText: BuiltinQueries[\"getByPlaceholderText\"] = builtinQueries.getByPlaceholderText;\n/**\n * Waits for and returns every widget with matching placeholder text, retrying until at least one\n * appears or the timeout elapses.\n */\nconst findAllByPlaceholderText: BuiltinQueries[\"findAllByPlaceholderText\"] = builtinQueries.findAllByPlaceholderText;\n/**\n * Waits for and returns the single widget with matching placeholder text, retrying until it appears\n * or the timeout elapses. Rejects when none or more than one matches.\n */\nconst findByPlaceholderText: BuiltinQueries[\"findByPlaceholderText\"] = builtinQueries.findByPlaceholderText;\n/**\n * Returns the single widget with a matching display value, or null when none match.\n * Throws when more than one matches.\n */\nconst queryByDisplayValue: BuiltinQueries[\"queryByDisplayValue\"] = builtinQueries.queryByDisplayValue;\n/** Returns every widget with a matching display value. Throws when none match. */\nconst getAllByDisplayValue: BuiltinQueries[\"getAllByDisplayValue\"] = builtinQueries.getAllByDisplayValue;\n/** Returns the single widget with a matching display value. Throws when none or more than one matches. */\nconst getByDisplayValue: BuiltinQueries[\"getByDisplayValue\"] = builtinQueries.getByDisplayValue;\n/**\n * Waits for and returns every widget with a matching display value, retrying until at least one\n * appears or the timeout elapses.\n */\nconst findAllByDisplayValue: BuiltinQueries[\"findAllByDisplayValue\"] = builtinQueries.findAllByDisplayValue;\n/**\n * Waits for and returns the single widget with a matching display value, retrying until it appears\n * or the timeout elapses. Rejects when none 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 = (expected: number | undefined, actual: number | null): boolean =>\n expected === undefined || actual === expected;\n\nconst hasMatchingAccessibleValue = (widget: Gtk.Widget, value: ByRoleValue, options: ByRoleOptions): boolean => {\n const actual = getWidgetValue(widget);\n\n const numericChecks: [number | undefined, number | null][] = [\n [value.now, actual.now],\n [value.min, actual.min],\n [value.max, actual.max],\n ];\n\n for (const [expected, current] of numericChecks) {\n if (!isNumericValueMatch(expected, current)) {\n return false;\n }\n }\n\n return value.text === undefined || isTextMatch(actual.text, 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 return {\n [`queryBy${suffix}`]: built.queryBy,\n [`queryAllBy${suffix}`]: queryAllBy,\n [`getBy${suffix}`]: built.getBy,\n [`getAllBy${suffix}`]: built.getAllBy,\n [`findBy${suffix}`]: built.findBy,\n [`findAllBy${suffix}`]: built.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 excluded from the accessibility tree are 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 = widget.getLabel();\n\n if (!labelText || !isTextMatch(labelText, text, widget, options)) {\n return null;\n }\n\n return widget.getMnemonicWidget();\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 ownLabel = getWidgetOwnLabel(widget);\n\n if (ownLabel !== null && isTextMatch(ownLabel, text, widget, options)) {\n results.add(widget);\n }\n\n const labelledByText = getWidgetLabelledByText(widget);\n\n if (labelledByText !== null && isTextMatch(labelledByText, 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.\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.\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.\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.\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.\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 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 type BuiltinQueries,\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,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,gBA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AAoB,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 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"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
+
import type { Matcher, MatcherOptions } from "./types.js";
|
|
3
|
+
import { buildQueries } from "./build-queries.js";
|
|
4
|
+
import { getElementError } from "./errors.js";
|
|
5
|
+
import { type Container } from "./traversal.js";
|
|
6
|
+
/** The helpers used to build custom queries, bundled the way DOM Testing Library exposes them. */
|
|
7
|
+
type QueryHelpers = {
|
|
8
|
+
/** Derives a query family's variants from its `queryAllBy` function. */
|
|
9
|
+
buildQueries: typeof buildQueries;
|
|
10
|
+
/** Builds the error a failing query throws. */
|
|
11
|
+
getElementError: typeof getElementError;
|
|
12
|
+
/** Finds every widget whose GObject property matches. */
|
|
13
|
+
queryAllByObjectProperty: typeof queryAllByObjectProperty;
|
|
14
|
+
/** Finds the single widget whose GObject property matches. */
|
|
15
|
+
queryByObjectProperty: typeof queryByObjectProperty;
|
|
16
|
+
};
|
|
17
|
+
/** The query-building helpers, bundled so they can be reached under a single import. */
|
|
18
|
+
declare const queryHelpers: QueryHelpers;
|
|
19
|
+
/**
|
|
20
|
+
* Finds every widget carrying a GObject property whose value matches, the counterpart of DOM Testing
|
|
21
|
+
* Library's `queryAllByAttribute`. The property name may be given in kebab-case or camelCase, and
|
|
22
|
+
* widgets that are not mapped are never matched.
|
|
23
|
+
*
|
|
24
|
+
* @param property Name of the GObject property to read.
|
|
25
|
+
* @param container Widget subtree to search.
|
|
26
|
+
* @param text Matcher for the property's value.
|
|
27
|
+
* @param options Text matching options.
|
|
28
|
+
* @returns Every matching widget, or an empty array when none match.
|
|
29
|
+
*/
|
|
30
|
+
declare function queryAllByObjectProperty(property: string, container: Container, text: Matcher, options?: MatcherOptions): Gtk.Widget[];
|
|
31
|
+
/**
|
|
32
|
+
* Returns the single widget carrying a GObject property whose value matches, or null when none do,
|
|
33
|
+
* the counterpart of DOM Testing Library's `queryByAttribute`.
|
|
34
|
+
*
|
|
35
|
+
* @param property Name of the GObject property to read.
|
|
36
|
+
* @param container Widget subtree to search.
|
|
37
|
+
* @param text Matcher for the property's value.
|
|
38
|
+
* @param options Text matching options.
|
|
39
|
+
* @returns The matching widget, or null when none match.
|
|
40
|
+
* @throws When more than one widget matches.
|
|
41
|
+
*/
|
|
42
|
+
declare function queryByObjectProperty(property: string, container: Container, text: Matcher, options?: MatcherOptions): Gtk.Widget | null;
|
|
43
|
+
export { queryAllByObjectProperty, queryByObjectProperty, queryHelpers, type QueryHelpers };
|
|
44
|
+
//# sourceMappingURL=query-helpers.d.ts.map
|
|
@@ -0,0 +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;AAgBF;;;;;;;;;;GAUG;AACH,iBAAS,wBAAwB,CAC7B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE,cAAc,GACzB,GAAG,CAAC,MAAM,EAAE,CAOd;AAED;;;;;;;;;;GAUG;AACH,iBAAS,qBAAqB,CAC1B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE,cAAc,GACzB,GAAG,CAAC,MAAM,GAAG,IAAI,CAWnB;AAED,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,CAAC"}
|