@gtkx/testing 2.0.0-beta.1 → 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 +43 -40
- 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/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 +7 -7
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +18 -10
- 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 +25 -5
- 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/click.d.ts +17 -4
- package/dist/user-event/click.d.ts.map +1 -1
- package/dist/user-event/click.js +28 -9
- 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/index.d.ts +22 -22
- package/dist/user-event/index.d.ts.map +1 -1
- package/dist/user-event/index.js +28 -25
- package/dist/user-event/index.js.map +1 -1
- package/dist/user-event/keyboard.d.ts.map +1 -1
- package/dist/user-event/keyboard.js +23 -2
- 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 +2 -2
- package/dist/user-event/selection.d.ts.map +1 -1
- package/dist/user-event/selection.js +8 -2
- package/dist/user-event/selection.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 +24 -17
- 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 +13 -10
- package/src/accessible-native.ts +45 -9
- package/src/build-queries.ts +60 -30
- package/src/fire-event.ts +32 -8
- package/src/matchers.ts +63 -85
- package/src/queries.ts +64 -30
- package/src/query-helpers.ts +17 -9
- package/src/render.tsx +7 -2
- package/src/role-helpers.ts +3 -1
- package/src/screenshot.ts +48 -5
- package/src/suggestions.ts +3 -1
- package/src/traversal.ts +35 -11
- package/src/types.ts +14 -10
- package/src/user-event/click.ts +37 -17
- package/src/user-event/controller.ts +8 -5
- package/src/user-event/index.ts +133 -47
- package/src/user-event/keyboard.ts +32 -3
- package/src/user-event/list-row-click.ts +2 -2
- package/src/user-event/pointer.ts +11 -15
- package/src/user-event/selection.ts +12 -4
- package/src/wait-for.ts +9 -6
- package/src/widget-accessible-properties.ts +39 -25
- package/src/widget-getters.ts +11 -13
- package/src/widget-target.ts +11 -0
package/dist/queries.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,EACR,aAAa,EAEb,OAAO,EACP,cAAc,EAEd,aAAa,EAChB,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,gBAAgB,CAAC;AAuBnE,6GAA6G;AAC7G,KAAK,cAAc,GAAG,aAAa,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;AA+D5D,QAAA,MAAM,cAAc,EAOf,cAAc,CAAC;AAEpB,oDAAoD;AACpD,QAAA,MAAM,WAAW,EAAE,cAAc,CAAC,aAAa,CAA8B,CAAC;AAC9E,uDAAuD;AACvD,QAAA,MAAM,YAAY,EAAE,cAAc,CAAC,cAAc,CAA+B,CAAC;AACjF,iDAAiD;AACjD,QAAA,MAAM,SAAS,EAAE,cAAc,CAAC,WAAW,CAA4B,CAAC;AACxE,wDAAwD;AACxD,QAAA,MAAM,aAAa,EAAE,cAAc,CAAC,eAAe,CAAgC,CAAC;AACpF,kDAAkD;AAClD,QAAA,MAAM,UAAU,EA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EAAE,cAAc,CAAC,CAAC,CAAC,GAC5B,CAAC,EAAE,CAOL;AAED;;;;;;GAMG;AACH,iBAAS,yBAAyB,CAAC,CAAC,SAAS,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,EACpE,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAC5B,CAAC,EAAE,CASL;AAED;;;;;;GAMG;AACH,iBAAS,sBAAsB,CAAC,CAAC,SAAS,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,EACjE,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAC5B,CAAC,EAAE,CASL;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"}
|
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 })));
|
|
@@ -157,12 +157,11 @@ const hasMatchingAccessibleStates = (widget, options) => hasMatchingBooleanState
|
|
|
157
157
|
hasMatchingDescriptionState(widget, options) &&
|
|
158
158
|
hasMatchingValueState(widget, options);
|
|
159
159
|
const isMatchingWidgetType = (widget, options) => options?.as === undefined || widget instanceof options.as;
|
|
160
|
-
const
|
|
160
|
+
const hasMatchingAccessibleOptions = (widget, options) => {
|
|
161
161
|
if (!options) {
|
|
162
162
|
return true;
|
|
163
163
|
}
|
|
164
|
-
return (
|
|
165
|
-
hasMatchingAccessibleName(widget, options) &&
|
|
164
|
+
return (hasMatchingAccessibleName(widget, options) &&
|
|
166
165
|
hasMatchingAccessibleStates(widget, options));
|
|
167
166
|
};
|
|
168
167
|
function nameQueryFamily(suffix, queryAllBy, built) {
|
|
@@ -186,15 +185,20 @@ function nameQueryFamily(suffix, queryAllBy, built) {
|
|
|
186
185
|
* @returns Every matching widget, or an empty array when none match.
|
|
187
186
|
*/
|
|
188
187
|
function queryAllByRole(container, role, options) {
|
|
189
|
-
|
|
188
|
+
const isInaccessible = buildInaccessibilityCheck();
|
|
189
|
+
const matches = findAll(container, (widget) => {
|
|
190
190
|
if (widget.getAccessibleRole() !== role) {
|
|
191
191
|
return false;
|
|
192
192
|
}
|
|
193
|
+
if (!isMatchingWidgetType(widget, options)) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
193
196
|
if (!options?.hidden && isInaccessible(widget)) {
|
|
194
197
|
return false;
|
|
195
198
|
}
|
|
196
|
-
return
|
|
199
|
+
return hasMatchingAccessibleOptions(widget, options);
|
|
197
200
|
});
|
|
201
|
+
return matches.filter((widget) => isMatchingWidgetType(widget, options));
|
|
198
202
|
}
|
|
199
203
|
const collectMnemonicMatch = (widget, text, options) => {
|
|
200
204
|
if (!(widget instanceof Gtk.Label)) {
|
|
@@ -243,7 +247,8 @@ function queryAllByLabelText(container, text, options) {
|
|
|
243
247
|
* @returns Every matching widget, or an empty array when none match.
|
|
244
248
|
*/
|
|
245
249
|
function queryAllByText(container, text, options) {
|
|
246
|
-
|
|
250
|
+
const matches = findAll(container, (widget) => isMatchingWidgetType(widget, options) && isTextMatch(getWidgetLabelText(widget), text, widget, options));
|
|
251
|
+
return matches.filter((widget) => isMatchingWidgetType(widget, options));
|
|
247
252
|
}
|
|
248
253
|
/**
|
|
249
254
|
* Finds every widget whose widget name matches. Widgets that are not mapped are never matched.
|
|
@@ -253,7 +258,8 @@ function queryAllByText(container, text, options) {
|
|
|
253
258
|
* @returns Every matching widget, or an empty array when none match.
|
|
254
259
|
*/
|
|
255
260
|
function queryAllByName(container, name, options) {
|
|
256
|
-
|
|
261
|
+
const matches = findAll(container, (widget) => isMatchingWidgetType(widget, options) && isTextMatch(getWidgetName(widget), name, widget, options));
|
|
262
|
+
return matches.filter((widget) => isMatchingWidgetType(widget, options));
|
|
257
263
|
}
|
|
258
264
|
/**
|
|
259
265
|
* Finds every widget whose placeholder text matches. Widgets that are not mapped are never matched.
|
|
@@ -263,8 +269,9 @@ function queryAllByName(container, name, options) {
|
|
|
263
269
|
* @returns Every matching widget, or an empty array when none match.
|
|
264
270
|
*/
|
|
265
271
|
function queryAllByPlaceholderText(container, text, options) {
|
|
266
|
-
|
|
272
|
+
const matches = findAll(container, (widget) => isMatchingWidgetType(widget, options) &&
|
|
267
273
|
isTextMatch(getWidgetPlaceholderText(widget), text, widget, options));
|
|
274
|
+
return matches.filter((widget) => isMatchingWidgetType(widget, options));
|
|
268
275
|
}
|
|
269
276
|
/**
|
|
270
277
|
* Finds every widget whose current display value matches. Widgets that are not mapped are never matched.
|
|
@@ -274,8 +281,9 @@ function queryAllByPlaceholderText(container, text, options) {
|
|
|
274
281
|
* @returns Every matching widget, or an empty array when none match.
|
|
275
282
|
*/
|
|
276
283
|
function queryAllByDisplayValue(container, value, options) {
|
|
277
|
-
|
|
284
|
+
const matches = findAll(container, (widget) => isMatchingWidgetType(widget, options) &&
|
|
278
285
|
isTextMatch(getWidgetDisplayValue(widget), value, widget, options));
|
|
286
|
+
return matches.filter((widget) => isMatchingWidgetType(widget, options));
|
|
279
287
|
}
|
|
280
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, };
|
|
281
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,mB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X,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/** 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 = (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,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACH,yBAAyB,EACzB,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,eAAe,EACf,kBAAkB,EAClB,eAAe,GAElB,MAAM,mCAAmC,CAAC;AAK3C,MAAM,WAA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AAW,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,O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,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,CAAC;QACL,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvF,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,SAAS,wBAAwB,CAC7B,QAAgB,EAChB,SAAoB,EACpB,IAAa,EACb,OAA2B;IAE3B,MAAM,OAAO,GAAG,OAAO,CACnB,SAAS,EACT,CAAC,MAAM,EAAE,EAAE,CACP,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC;QACrC,WAAW,CAAC,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAC/E,CAAC;IAEF,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAA4B,EAAE,CAAC,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACvG,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,qBAAqB,CAC1B,QAAgB,EAChB,SAAoB,EACpB,IAAa,EACb,OAA2B;IAE3B,MAAM,OAAO,GAAG,wBAAwB,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAE7E,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,eAAe,CACjB,SAAS,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,uBAAuB,QAAQ,mCAAmC,EACjG,SAAS,CACZ,CAAC;IACN,CAAC;IAED,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAC9B,CAAC;AAED,OAAO,EAAE,wBAAwB,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 };
|
package/dist/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EACH,oBAAoB,EACpB,aAAa,EAEb,yBAAyB,EACzB,gBAAgB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAkC,UAAU,EAAE,MAAM,OAAO,CAAC;AAGnE,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,SAAS,EAA4B,MAAM,oBAAoB,CAAC;AACzE,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AE,EAAE,CAAC,aAAa,CAAC,iBAAiB,CAAC;KAC1F,CAAC;IAEF,SAAS,CAAC,MAAM,CAAC,CAAC;IAElB,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,OAAO,GAAG,KAAK,IAAmB,EAAE;IACtC,MAAM,UAAU,EAAE,CAAC;AACvB,CAAC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import type { RootElement } from \"@gtkx/react\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport {\n createReconcilerRoot,\n isRootElement,\n type ReconcilerRoot,\n setReconcilerErrorHandler,\n settleAccessible,\n} from \"@gtkx/react/internal\";\nimport { type ErrorInfo, type ReactNode, StrictMode } from \"react\";\nimport type { RenderResult } from \"./bound-queries.js\";\nimport type { QueryMap, RenderOptions, ScreenshotOptions } from \"./types.js\";\nimport { runInAct, runWithActEnvironment } from \"./act.js\";\nimport { addToCleanupQueue, runCleanup } from \"./cleanup-registry.js\";\nimport { getConfig } from \"./config.js\";\nimport { scheduleWhenWindowReady } from \"./frame-sync.js\";\nimport { createHarnessWindow, presentHarnessWindow } from \"./harness-window.js\";\nimport { logWidget, type PrettyWidgetOptions } from \"./pretty-widget.js\";\nimport { logRoles } from \"./role-helpers.js\";\nimport { clearScreen, setScreen } from \"./screen.js\";\nimport { captureScreen } from \"./screenshot.js\";\nimport { type Container, roots, TOPLEVELS } from \"./traversal.js\";\nimport { resetClipboard } from \"./user-event/index.js\";\nimport { findPresentedWindowFailure, findRenderedWindowFailure, mappedToplevels } from \"./window-state.js\";\nimport { within } from \"./within.js\";\n\n/** A mounted render tracked so cleanup can unmount it. */\ntype ActiveRender = {\n /** Root that rerenders drive and that cleanup tears the tree down through. */\n root: ReconcilerRoot;\n /** Harness window created for the render, null when it renders into a container the caller supplied. */\n window: Gtk.Window | null;\n};\n\ntype ResolvedContainer = {\n containerInfo: Gtk.Widget | RootElement;\n window: Gtk.Window | null;\n};\n\ntype ReconcilerErrorState = {\n lastError: Error | null;\n isHandlerInstalled: boolean;\n};\n\ntype WindowFailureReporter = (window: Gtk.Window) => string | null;\ntype SettleAction = \"render\" | \"rerender\";\n\nconst reconcilerErrors: ReconcilerErrorState = { lastError: null, isHandlerInstalled: false };\nconst activeRenders: Set<ActiveRender> = new Set();\n\nconst settleWindow = async (\n window: Gtk.Window | null,\n findFailure: WindowFailureReporter,\n action: SettleAction,\n): Promise<void> => {\n const timeout = getConfig().windowActivationTimeout;\n\n await runWithActEnvironment(\n false,\n () =>\n new Promise<void>((resolve) => {\n scheduleWhenWindowReady(window, (target) => findFailure(target) === null, timeout, resolve);\n }),\n );\n\n settleAccessible();\n const failure = window === null ? null : findFailure(window);\n\n if (failure !== null) {\n throw new Error(\n `${action} timed out after ${String(timeout)}ms waiting for the window it rendered into: ${failure}. ` +\n \"Platform state such as focus is only readable once that window is allocated and active.\",\n );\n }\n};\n\nconst update = async (element: ReactNode, root: ReconcilerRoot): Promise<void> => {\n await runInAct(() => {\n root.update(element);\n });\n\n if (reconcilerErrors.lastError) {\n const captured = reconcilerErrors.lastError;\n reconcilerErrors.lastError = null;\n throw captured;\n }\n};\n\nconst disposeActiveRender = async (active: ActiveRender): Promise<void> => {\n if (!activeRenders.delete(active)) {\n return;\n }\n\n await active.root.unmount(async (root) => {\n await update(null, root);\n active.window?.destroy();\n });\n};\n\nconst disposeAllActiveRenders = async (): Promise<void> => {\n for (const active of activeRenders) {\n await disposeActiveRender(active);\n }\n};\n\nconst handleError = (error: unknown): void => {\n reconcilerErrors.lastError = error instanceof Error ? error : new Error(String(error));\n};\n\nconst installErrorHandler = (): void => {\n if (reconcilerErrors.isHandlerInstalled) {\n return;\n }\n\n setReconcilerErrorHandler(handleError);\n reconcilerErrors.isHandlerInstalled = true;\n};\n\nconst resolveContainer = (container: RenderOptions[\"container\"]): ResolvedContainer => {\n if (isRootElement(container)) {\n return { containerInfo: container, window: null };\n }\n\n if (container instanceof Gtk.Widget) {\n return { containerInfo: container, window: null };\n }\n\n const window = createHarnessWindow();\n window.setDecorated(false);\n\n return { containerInfo: window, window };\n};\n\nconst firstToplevelWidget = (baseElement: Container): Gtk.Widget => {\n if (baseElement instanceof Gtk.Widget) {\n return baseElement;\n }\n\n const [first] = roots(baseElement);\n\n if (first) {\n return first;\n }\n\n throw new Error(\"render() produced no widgets: ensure the element renders visible content\");\n};\n\nconst resolveResultContainer = (\n resolved: ResolvedContainer,\n container: RenderOptions[\"container\"],\n baseElement: Container,\n): Gtk.Widget => {\n if (resolved.window) {\n return resolved.window;\n }\n\n if (container instanceof Gtk.Widget) {\n return container;\n }\n\n return firstToplevelWidget(baseElement);\n};\n\nconst realizedWindow = (root: Gtk.Root | null): Gtk.Window | null =>\n root instanceof Gtk.Window && root.getFrameClock() !== null ? root : null;\n\nconst settleTarget = (resolved: ResolvedContainer, container: RenderOptions[\"container\"]): Gtk.Window | null => {\n if (resolved.window) {\n return realizedWindow(resolved.window);\n }\n\n if (container instanceof Gtk.Widget) {\n return realizedWindow(container.getRoot());\n }\n\n return realizedWindow(mappedToplevels()[0] ?? null);\n};\n\nconst settleRender = async (\n resolved: ResolvedContainer,\n container: RenderOptions[\"container\"],\n action: SettleAction,\n): Promise<void> => {\n const isPresentedNow = action === \"render\" && resolved.window !== null;\n const findFailure = isPresentedNow ? findPresentedWindowFailure : findRenderedWindowFailure;\n await settleWindow(settleTarget(resolved, container), findFailure, action);\n};\n\nconst renderErrorHandlers = <Q extends QueryMap>(options: RenderOptions<Q> | undefined) => ({\n onUncaughtError: handleError,\n onCaughtError: (error: unknown, errorInfo: ErrorInfo): void => {\n handleError(error);\n options?.onCaughtError?.(error, errorInfo);\n },\n onRecoverableError: (error: unknown, errorInfo: ErrorInfo): void => {\n options?.onRecoverableError?.(error, errorInfo);\n },\n});\n\nconst applyEnableAnimations = (areAnimationsEnabled: boolean): void => {\n const settings = Gtk.Settings.getDefault();\n\n if (settings) {\n settings.gtkEnableAnimations = areAnimationsEnabled;\n }\n};\n\n/**\n * Renders a React element into a GTK4 widget tree and returns queries\n * scoped to it along with controls for rerendering and unmounting. When no\n * container is supplied, a harness window is created and presented, and the editable it hands the\n * focus to keeps its text unselected, with its caret at the end. The returned promise settles once\n * the window the tree is shown in has been laid out and activation has arrived, so platform state\n * such as focus is already readable when it resolves. A presented harness window is waited on until\n * it is itself active; a window the caller or the tree owns is waited on until the application holds\n * activation, since only a present can claim it. Rendering into a container that is not shown waits\n * for nothing, and a window that never becomes readable within `windowActivationTimeout` throws an\n * error naming the condition that failed rather than resolving with unreadable platform state. A\n * tree mounted into a container that sits outside every toplevel, or inside a window that is not\n * visible, is out of reach of a pointer and a keyboard, so every `userEvent` helper aimed at it\n * rejects after `actionabilityTimeout` naming that condition, and `fireEvent` drives it instead.\n *\n * @param element The React element to render.\n * @param options Optional container, wrapper, custom queries, and other render settings.\n * @returns A render result with bound queries, debug helpers, and lifecycle controls.\n * @throws When the window the tree is shown in is not laid out and activated in time.\n */\nconst render = async <Q extends QueryMap = Record<never, never>>(\n element: ReactNode,\n options?: RenderOptions<Q>,\n): Promise<RenderResult<Q>> => {\n installErrorHandler();\n applyEnableAnimations(options?.areAnimationsEnabled === true);\n const baseElement: Container = options?.baseElement ?? TOPLEVELS;\n const Wrapper = options?.wrapper;\n const resolved = resolveContainer(options?.container);\n\n const root = createReconcilerRoot({\n containerInfo: resolved.containerInfo,\n ...renderErrorHandlers(options),\n });\n\n const active: ActiveRender = { root, window: resolved.window };\n activeRenders.add(active);\n addToCleanupQueue(disposeAllActiveRenders);\n addToCleanupQueue(clearScreen);\n addToCleanupQueue(resetClipboard);\n\n const wrap = (node: ReactNode): ReactNode => {\n const wrapped = Wrapper ? <Wrapper>{node}</Wrapper> : node;\n\n return options?.isReactStrictMode ? <StrictMode>{wrapped}</StrictMode> : wrapped;\n };\n\n await update(wrap(element), root);\n presentHarnessWindow(resolved.window);\n await settleRender(resolved, options?.container, \"render\");\n const container = resolveResultContainer(resolved, options?.container, baseElement);\n\n const result: RenderResult<Q> = {\n ...within(baseElement, options?.queries),\n container,\n baseElement,\n unmount: async () => {\n await disposeActiveRender(active);\n },\n rerender: async (newElement: ReactNode) => {\n await update(wrap(newElement), root);\n await settleRender(resolved, options?.container, \"rerender\");\n },\n debug: (element: Container | Container[] = baseElement, debugOptions?: PrettyWidgetOptions) => {\n logWidget(element, debugOptions);\n },\n logRoles: () => {\n logRoles(baseElement);\n },\n screenshot: (screenshotOptions?: ScreenshotOptions) => captureScreen(screenshotOptions),\n };\n\n setScreen(result);\n\n return result;\n};\n\n/**\n * Unmounts every active render and runs all registered cleanup callbacks,\n * resetting the screen and clipboard. Called automatically after each test.\n */\nconst cleanup = async (): Promise<void> => {\n await runCleanup();\n};\n\nexport { render, cleanup };\n"]}
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EACH,oBAAoB,EACpB,aAAa,EAEb,yBAAyB,EACzB,gBAAgB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAkC,UAAU,EAAE,MAAM,OAAO,CAAC;AAGnE,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,SAAS,EAA4B,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,M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EAAE,EAAE,CAAC,aAAa,CAAC,iBAAiB,CAAC;KAC1F,CAAC;IAEF,SAAS,CAAC,MAAM,CAAC,CAAC;IAElB,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,OAAO,GAAG,KAAK,IAAmB,EAAE;IACtC,MAAM,UAAU,EAAE,CAAC;AACvB,CAAC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import type { CaughtErrorInfo, RootElement } from \"@gtkx/react\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport {\n createReconcilerRoot,\n isRootElement,\n type ReconcilerRoot,\n setReconcilerErrorHandler,\n settleAccessible,\n} from \"@gtkx/react/internal\";\nimport { type ErrorInfo, type ReactNode, StrictMode } from \"react\";\nimport type { RenderResult } from \"./bound-queries.js\";\nimport type { QueryMap, RenderOptions, ScreenshotOptions } from \"./types.js\";\nimport { runInAct, runWithActEnvironment } from \"./act.js\";\nimport { addToCleanupQueue, runCleanup } from \"./cleanup-registry.js\";\nimport { getConfig } from \"./config.js\";\nimport { scheduleWhenWindowReady } from \"./frame-sync.js\";\nimport { createHarnessWindow, presentHarnessWindow } from \"./harness-window.js\";\nimport { logWidget, type PrettyWidgetOptions } from \"./pretty-widget.js\";\nimport { logRoles } from \"./role-helpers.js\";\nimport { clearScreen, setScreen } from \"./screen.js\";\nimport { captureScreen } from \"./screenshot.js\";\nimport { type Container, roots, TOPLEVELS } from \"./traversal.js\";\nimport { resetClipboard } from \"./user-event/index.js\";\nimport { requireWidget } from \"./widget-target.js\";\nimport { findPresentedWindowFailure, findRenderedWindowFailure, mappedToplevels } from \"./window-state.js\";\nimport { within } from \"./within.js\";\n\n/** A mounted render tracked so cleanup can unmount it. */\ntype ActiveRender = {\n /** Root that rerenders drive and that cleanup tears the tree down through. */\n root: ReconcilerRoot;\n /** Harness window created for the render, null when it renders into a container the caller supplied. */\n window: Gtk.Window | null;\n};\n\ntype ResolvedContainer = {\n containerInfo: Gtk.Widget | RootElement;\n window: Gtk.Window | null;\n};\n\ntype ReconcilerErrorState = {\n lastError: Error | null;\n isHandlerInstalled: boolean;\n};\n\ntype WindowFailureReporter = (window: Gtk.Window) => string | null;\ntype SettleAction = \"render\" | \"rerender\";\n\nconst reconcilerErrors: ReconcilerErrorState = { lastError: null, isHandlerInstalled: false };\nconst activeRenders: Set<ActiveRender> = new Set();\n\nconst settleWindow = async (\n window: Gtk.Window | null,\n findFailure: WindowFailureReporter,\n action: SettleAction,\n): Promise<void> => {\n const timeout = getConfig().windowActivationTimeout;\n\n await runWithActEnvironment(\n false,\n () =>\n new Promise<void>((resolve) => {\n scheduleWhenWindowReady(window, (target) => findFailure(target) === null, timeout, resolve);\n }),\n );\n\n settleAccessible();\n const failure = window === null ? null : findFailure(window);\n\n if (failure !== null) {\n throw new Error(\n `${action} timed out after ${String(timeout)}ms waiting for the window it rendered into: ${failure}. ` +\n \"Platform state such as focus is only readable once that window is allocated and active.\",\n );\n }\n};\n\nconst update = async (element: ReactNode, root: ReconcilerRoot): Promise<void> => {\n await runInAct(() => {\n root.update(element);\n });\n\n if (reconcilerErrors.lastError) {\n const captured = reconcilerErrors.lastError;\n reconcilerErrors.lastError = null;\n throw captured;\n }\n};\n\nconst disposeActiveRender = async (active: ActiveRender): Promise<void> => {\n if (!activeRenders.delete(active)) {\n return;\n }\n\n await active.root.unmount(async (root) => {\n await update(null, root);\n active.window?.destroy();\n });\n};\n\nconst disposeAllActiveRenders = async (): Promise<void> => {\n for (const active of activeRenders) {\n await disposeActiveRender(active);\n }\n};\n\nconst handleError = (error: unknown): void => {\n reconcilerErrors.lastError = error instanceof Error ? error : new Error(String(error));\n};\n\nconst installErrorHandler = (): void => {\n if (reconcilerErrors.isHandlerInstalled) {\n return;\n }\n\n setReconcilerErrorHandler(handleError);\n reconcilerErrors.isHandlerInstalled = true;\n};\n\nconst resolveContainer = (container: RenderOptions[\"container\"]): ResolvedContainer => {\n if (isRootElement(container)) {\n return { containerInfo: container, window: null };\n }\n\n if (container instanceof Gtk.Widget) {\n return { containerInfo: container, window: null };\n }\n\n if (container !== undefined) {\n requireWidget(container);\n }\n\n const window = createHarnessWindow();\n window.setDecorated(false);\n\n return { containerInfo: window, window };\n};\n\nconst firstToplevelWidget = (baseElement: Container): Gtk.Widget => {\n if (baseElement instanceof Gtk.Widget) {\n return baseElement;\n }\n\n const [first] = roots(baseElement);\n\n if (first) {\n return first;\n }\n\n throw new Error(\"render() produced no widgets: ensure the element renders visible content\");\n};\n\nconst resolveResultContainer = (\n resolved: ResolvedContainer,\n container: RenderOptions[\"container\"],\n baseElement: Container,\n): Gtk.Widget => {\n if (resolved.window) {\n return resolved.window;\n }\n\n if (container instanceof Gtk.Widget) {\n return container;\n }\n\n return firstToplevelWidget(baseElement);\n};\n\nconst realizedWindow = (root: Gtk.Root | null): Gtk.Window | null =>\n root instanceof Gtk.Window && root.getFrameClock() !== null ? root : null;\n\nconst settleTarget = (resolved: ResolvedContainer, container: RenderOptions[\"container\"]): Gtk.Window | null => {\n if (resolved.window) {\n return realizedWindow(resolved.window);\n }\n\n if (container instanceof Gtk.Widget) {\n return realizedWindow(container.getRoot());\n }\n\n return realizedWindow(mappedToplevels()[0] ?? null);\n};\n\nconst settleRender = async (\n resolved: ResolvedContainer,\n container: RenderOptions[\"container\"],\n action: SettleAction,\n): Promise<void> => {\n const isPresentedNow = action === \"render\" && resolved.window !== null;\n const findFailure = isPresentedNow ? findPresentedWindowFailure : findRenderedWindowFailure;\n await settleWindow(settleTarget(resolved, container), findFailure, action);\n};\n\nconst renderErrorHandlers = <Q extends QueryMap>(options: RenderOptions<Q> | undefined) => ({\n onUncaughtError: handleError,\n onCaughtError: (error: unknown, errorInfo: CaughtErrorInfo): void => {\n handleError(error);\n options?.onCaughtError?.(error, errorInfo);\n },\n onRecoverableError: (error: unknown, errorInfo: ErrorInfo): void => {\n options?.onRecoverableError?.(error, errorInfo);\n },\n});\n\nconst applyEnableAnimations = (areAnimationsEnabled: boolean): void => {\n const settings = Gtk.Settings.getDefault();\n\n if (settings) {\n settings.gtkEnableAnimations = areAnimationsEnabled;\n }\n};\n\n/**\n * Renders a React element into a GTK4 widget tree and returns queries\n * scoped to it along with controls for rerendering and unmounting. When no\n * container is supplied, a harness window is created and presented, and the editable it hands the\n * focus to keeps its text unselected, with its caret at the end. The returned promise settles once\n * the window the tree is shown in has been laid out and activation has arrived, so platform state\n * such as focus is already readable when it resolves. A presented harness window is waited on until\n * it is itself active; a window the caller or the tree owns is waited on until the application holds\n * activation, since only a present can claim it. Rendering into a container that is not shown waits\n * for nothing, and a window that never becomes readable within `windowActivationTimeout` throws an\n * error naming the condition that failed rather than resolving with unreadable platform state. A\n * tree mounted into a container that sits outside every toplevel, or inside a window that is not\n * visible, is out of reach of a pointer and a keyboard, so every `userEvent` helper aimed at it\n * rejects after `actionabilityTimeout` naming that condition, and `fireEvent` drives it instead.\n *\n * @param element The React element to render.\n * @param options Optional container, wrapper, custom queries, and other render settings.\n * @returns A render result with bound queries, debug helpers, and lifecycle controls.\n * @throws When the window the tree is shown in is not laid out and activated in time.\n */\nconst render = async <Q extends QueryMap = Record<never, never>>(\n element: ReactNode,\n options?: RenderOptions<Q>,\n): Promise<RenderResult<Q>> => {\n installErrorHandler();\n applyEnableAnimations(options?.areAnimationsEnabled === true);\n const baseElement: Container = options?.baseElement ?? TOPLEVELS;\n const Wrapper = options?.wrapper;\n const resolved = resolveContainer(options?.container);\n\n const root = createReconcilerRoot({\n containerInfo: resolved.containerInfo,\n ...renderErrorHandlers(options),\n });\n\n const active: ActiveRender = { root, window: resolved.window };\n activeRenders.add(active);\n addToCleanupQueue(disposeAllActiveRenders);\n addToCleanupQueue(clearScreen);\n addToCleanupQueue(resetClipboard);\n\n const wrap = (node: ReactNode): ReactNode => {\n const wrapped = Wrapper ? <Wrapper>{node}</Wrapper> : node;\n\n return options?.isReactStrictMode ? <StrictMode>{wrapped}</StrictMode> : wrapped;\n };\n\n await update(wrap(element), root);\n presentHarnessWindow(resolved.window);\n await settleRender(resolved, options?.container, \"render\");\n const container = resolveResultContainer(resolved, options?.container, baseElement);\n\n const result: RenderResult<Q> = {\n ...within(baseElement, options?.queries),\n container,\n baseElement,\n unmount: async () => {\n await disposeActiveRender(active);\n },\n rerender: async (newElement: ReactNode) => {\n await update(wrap(newElement), root);\n await settleRender(resolved, options?.container, \"rerender\");\n },\n debug: (element: Container | Container[] = baseElement, debugOptions?: PrettyWidgetOptions) => {\n logWidget(element, debugOptions);\n },\n logRoles: () => {\n logRoles(baseElement);\n },\n screenshot: (screenshotOptions?: ScreenshotOptions) => captureScreen(screenshotOptions),\n };\n\n setScreen(result);\n\n return result;\n};\n\n/**\n * Unmounts every active render and runs all registered cleanup callbacks,\n * resetting the screen and clipboard. Called automatically after each test.\n */\nconst cleanup = async (): Promise<void> => {\n await runCleanup();\n};\n\nexport { render, cleanup };\n"]}
|
package/dist/role-helpers.d.ts
CHANGED
|
@@ -37,6 +37,6 @@ declare const logRoles: (container: Container) => void;
|
|
|
37
37
|
*
|
|
38
38
|
* @param widget The widget to read the level from.
|
|
39
39
|
*/
|
|
40
|
-
declare const computeHeadingLevel: (widget: Gtk.
|
|
40
|
+
declare const computeHeadingLevel: (widget: Gtk.Accessible) => number | undefined;
|
|
41
41
|
export { computeHeadingLevel, formatRole, formatRoleList, getRoles, prettyRoles, logRoles };
|
|
42
42
|
//# sourceMappingURL=role-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role-helpers.d.ts","sourceRoot":"","sources":["../src/role-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"role-helpers.d.ts","sourceRoot":"","sources":["../src/role-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,gBAAgB,CAAC;AAe1D;;;;;GAKG;AACH,QAAA,MAAM,UAAU,GAAI,MAAM,GAAG,CAAC,cAAc,KAAG,MAQ9C,CAAC;AAEF,QAAA,MAAM,cAAc,GAAI,OAAO,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,KAAG,MAe7D,CAAC;AAEF;;;;;;GAMG;AACH,QAAA,MAAM,QAAQ,GAAI,WAAW,SAAS,KAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAehE,CAAC;AAUF;;;;;;GAMG;AACH,QAAA,MAAM,WAAW,GAAI,WAAW,SAAS,KAAG,MAqB3C,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,QAAQ,GAAI,WAAW,SAAS,KAAG,IAExC,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,mBAAmB,GAAI,QAAQ,GAAG,CAAC,UAAU,KAAG,MAAM,GAAG,SACT,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/role-helpers.js
CHANGED
|
@@ -3,6 +3,7 @@ import { sortStringsBy } from "@gtkx/utils";
|
|
|
3
3
|
import { traverse } from "./traversal.js";
|
|
4
4
|
import { getWidgetAccessibleName, getWidgetLevel } from "./widget-accessible-properties.js";
|
|
5
5
|
import { getTypeTag } from "./widget-getters.js";
|
|
6
|
+
import { requireWidget } from "./widget-target.js";
|
|
6
7
|
const ROLE_NAMES_BY_VALUE = enumNamesByValue(Gtk.AccessibleRole);
|
|
7
8
|
function enumNamesByValue(enumObject) {
|
|
8
9
|
return new Map(Object.entries(enumObject)
|
|
@@ -99,6 +100,6 @@ const logRoles = (container) => {
|
|
|
99
100
|
*
|
|
100
101
|
* @param widget The widget to read the level from.
|
|
101
102
|
*/
|
|
102
|
-
const computeHeadingLevel = (widget) => getWidgetLevel(widget) ?? undefined;
|
|
103
|
+
const computeHeadingLevel = (widget) => getWidgetLevel(requireWidget(widget)) ?? undefined;
|
|
103
104
|
export { computeHeadingLevel, formatRole, formatRoleList, getRoles, prettyRoles, logRoles };
|
|
104
105
|
//# sourceMappingURL=role-helpers.js.map
|
package/dist/role-helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role-helpers.js","sourceRoot":"","sources":["../src/role-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAkB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"role-helpers.js","sourceRoot":"","sources":["../src/role-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAkB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AAEjE,SAAS,gBAAgB,CAAC,UAA2C;IACjE,OAAO,IAAI,GAAG,CACV,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;SACrB,MAAM,CAAC,CAAC,KAAK,EAA6B,EAAE,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;SAC1E,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Q,CAAC,CAAC;IAExE,KAAK,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,WAAW,EAAE,CAAC;QAC5C,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC;QAE3B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,KAAK,mBAAmB,CAAC,MAAM,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;QACpF,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AACtC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,CAAC,SAAoB,EAAQ,EAAE;IAC5C,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,mBAAmB,GAAG,CAAC,MAAsB,EAAsB,EAAE,CACvE,cAAc,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,SAAS,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { sortStringsBy } from \"@gtkx/utils\";\nimport { type Container, traverse } from \"./traversal.js\";\nimport { getWidgetAccessibleName, getWidgetLevel } from \"./widget-accessible-properties.js\";\nimport { getTypeTag } from \"./widget-getters.js\";\nimport { requireWidget } from \"./widget-target.js\";\n\nconst ROLE_NAMES_BY_VALUE = enumNamesByValue(Gtk.AccessibleRole);\n\nfunction enumNamesByValue(enumObject: Record<string, string | number>): Map<number, string> {\n return new Map<number, string>(\n Object.entries(enumObject)\n .filter((entry): entry is [string, number] => typeof entry[1] === \"number\")\n .map(([name, value]) => [value, name]),\n );\n}\n\n/**\n * Converts an accessible role enum value into its lowercase name, falling back\n * to the numeric value when the role is unknown.\n *\n * @param role The accessible role to format.\n */\nconst formatRole = (role: Gtk.AccessibleRole): string => {\n const name = ROLE_NAMES_BY_VALUE.get(role);\n\n if (!name) {\n return String(role);\n }\n\n return name.toLowerCase();\n};\n\nconst formatRoleList = (roles: Iterable<Gtk.AccessibleRole>): string => {\n const names = [...roles].map((role) => formatRole(role).toUpperCase());\n\n if (names.length <= 1) {\n return names.join(\"\");\n }\n\n if (names.length === 2) {\n return names.join(\" or \");\n }\n\n const head = names.slice(0, -1);\n const last = names.at(-1) ?? \"\";\n\n return `${head.join(\", \")}, or ${last}`;\n};\n\n/**\n * Groups every mapped widget in a container's tree by its accessible role name. Widgets that are not\n * mapped are left out.\n *\n * @param container The scope to traverse.\n * @returns A map from role name to the mapped widgets that have that role.\n */\nconst getRoles = (container: Container): Map<string, Gtk.Widget[]> => {\n const roles: Map<string, Gtk.Widget[]> = new Map();\n\n for (const widget of traverse(container)) {\n const roleName = formatRole(widget.getAccessibleRole());\n const existing = roles.get(roleName);\n\n if (existing) {\n existing.push(widget);\n } else {\n roles.set(roleName, [widget]);\n }\n }\n\n return roles;\n};\n\nconst formatWidgetPreview = (widget: Gtk.Widget, name: string | null): string => {\n const tagName = getTypeTag(widget);\n const roleAttr = formatRole(widget.getAccessibleRole());\n const nameDisplay = name ? `Name \"${name}\"` : 'Name \"\"';\n\n return `${nameDisplay}: <${tagName} role=\"${roleAttr}\">${name ?? \"\"}</${tagName}>`;\n};\n\n/**\n * Formats the accessible roles in a container's tree as a readable string,\n * listing each role together with its widgets and their accessible names.\n * Widgets that are not mapped are left out.\n *\n * @param container The scope to inspect.\n */\nconst prettyRoles = (container: Container): string => {\n const roles = getRoles(container);\n\n if (roles.size === 0) {\n return \"No accessible roles found in the widget tree.\";\n }\n\n const lines: string[] = [];\n const sortedRoles = sortStringsBy([...roles], ([roleName]) => roleName);\n\n for (const [roleName, widgets] of sortedRoles) {\n lines.push(`${roleName}:`);\n\n for (const widget of widgets) {\n lines.push(` ${formatWidgetPreview(widget, getWidgetAccessibleName(widget))}`);\n }\n\n lines.push(\"\");\n }\n\n return lines.join(\"\\n\").trimEnd();\n};\n\n/**\n * Prints the accessible roles in a container's tree to the console using\n * {@link prettyRoles}.\n *\n * @param container The scope to inspect.\n */\nconst logRoles = (container: Container): void => {\n console.log(prettyRoles(container));\n};\n\n/**\n * Returns the heading or hierarchy level GTK reports for a widget, or undefined when it declares\n * none.\n *\n * @param widget The widget to read the level from.\n */\nconst computeHeadingLevel = (widget: Gtk.Accessible): number | undefined =>\n getWidgetLevel(requireWidget(widget)) ?? undefined;\n\nexport { computeHeadingLevel, formatRole, formatRoleList, getRoles, prettyRoles, logRoles };\n"]}
|
package/dist/screenshot.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import type { ScreenshotOptions, ScreenshotResult } from "./types.js";
|
|
|
14
14
|
* @param options Optional scale, timeout, retry interval, and output path.
|
|
15
15
|
* @returns The base64-encoded PNG data along with its mime type and dimensions.
|
|
16
16
|
*/
|
|
17
|
-
declare const screenshot: (
|
|
17
|
+
declare const screenshot: (target: Gtk.Accessible, options?: ScreenshotOptions) => Promise<ScreenshotResult>;
|
|
18
18
|
declare const captureScreen: (options?: ScreenshotOptions) => Promise<ScreenshotResult>;
|
|
19
19
|
export { captureScreen, screenshot };
|
|
20
20
|
//# sourceMappingURL=screenshot.d.ts.map
|
package/dist/screenshot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../src/screenshot.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAGpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../src/screenshot.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAGpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAqUtE;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,UAAU,GAAU,QAAQ,GAAG,CAAC,UAAU,EAAE,UAAU,iBAAiB,KAAG,OAAO,CAAC,gBAAgB,CAmBvG,CAAC;AAYF,QAAA,MAAM,aAAa,GAAU,UAAU,iBAAiB,KAAG,OAAO,CAAC,gBAAgB,CAC5C,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC"}
|