@gtkx/testing 2.0.0-beta.1 → 2.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -165
- package/dist/accessible-native.d.ts +1 -1
- package/dist/accessible-native.d.ts.map +1 -1
- package/dist/accessible-native.js +31 -10
- package/dist/accessible-native.js.map +1 -1
- package/dist/build-queries.d.ts +15 -16
- package/dist/build-queries.d.ts.map +1 -1
- package/dist/build-queries.js +25 -23
- package/dist/build-queries.js.map +1 -1
- package/dist/cleanup-registry.d.ts +2 -1
- package/dist/cleanup-registry.d.ts.map +1 -1
- package/dist/cleanup-registry.js +11 -4
- package/dist/cleanup-registry.js.map +1 -1
- package/dist/config.d.ts +3 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/fire-event.d.ts +3 -3
- package/dist/fire-event.d.ts.map +1 -1
- package/dist/fire-event.js +14 -4
- package/dist/fire-event.js.map +1 -1
- package/dist/matchers.d.ts +56 -62
- package/dist/matchers.d.ts.map +1 -1
- package/dist/matchers.js +6 -18
- package/dist/matchers.js.map +1 -1
- package/dist/pretty-widget.d.ts.map +1 -1
- package/dist/pretty-widget.js +13 -2
- package/dist/pretty-widget.js.map +1 -1
- package/dist/queries.d.ts +7 -7
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +21 -12
- 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-hook.js +3 -3
- package/dist/render-hook.js.map +1 -1
- package/dist/render.d.ts +17 -17
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +66 -62
- 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/role-naming.d.ts +2 -1
- package/dist/role-naming.d.ts.map +1 -1
- package/dist/role-naming.js +2 -1
- package/dist/role-naming.js.map +1 -1
- package/dist/screenshot.d.ts +11 -12
- package/dist/screenshot.d.ts.map +1 -1
- package/dist/screenshot.js +35 -16
- 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 +5 -3
- package/dist/suggestions.js.map +1 -1
- package/dist/traversal.d.ts +7 -6
- package/dist/traversal.d.ts.map +1 -1
- package/dist/traversal.js +32 -7
- package/dist/traversal.js.map +1 -1
- package/dist/types.d.ts +13 -15
- 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 +7 -4
- package/dist/user-event/controller.js.map +1 -1
- package/dist/user-event/gesture.d.ts +1 -1
- package/dist/user-event/gesture.d.ts.map +1 -1
- package/dist/user-event/gesture.js +103 -29
- package/dist/user-event/gesture.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 +26 -4
- 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 +3 -2
- 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 +3 -2
- package/dist/user-event/selection.js.map +1 -1
- package/dist/user-event/text.d.ts.map +1 -1
- package/dist/user-event/text.js +31 -27
- package/dist/user-event/text.js.map +1 -1
- package/dist/wait-for.d.ts +2 -2
- package/dist/wait-for.d.ts.map +1 -1
- package/dist/wait-for.js +34 -25
- package/dist/wait-for.js.map +1 -1
- package/dist/widget-accessible-properties.d.ts +5 -4
- package/dist/widget-accessible-properties.d.ts.map +1 -1
- package/dist/widget-accessible-properties.js +85 -41
- 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 +14 -11
- package/src/accessible-native.ts +47 -11
- package/src/build-queries.ts +84 -53
- package/src/cleanup-registry.ts +11 -5
- package/src/config.ts +3 -4
- package/src/fire-event.ts +32 -8
- package/src/matchers.ts +69 -93
- package/src/pretty-widget.ts +17 -2
- package/src/queries.ts +68 -31
- package/src/query-helpers.ts +17 -9
- package/src/render-hook.tsx +3 -3
- package/src/render.tsx +71 -79
- package/src/role-helpers.ts +3 -1
- package/src/role-naming.ts +2 -1
- package/src/screenshot.ts +58 -16
- package/src/suggestions.ts +5 -3
- package/src/traversal.ts +47 -13
- package/src/types.ts +17 -15
- package/src/user-event/click.ts +37 -17
- package/src/user-event/controller.ts +10 -7
- package/src/user-event/gesture.ts +142 -33
- package/src/user-event/index.ts +133 -47
- package/src/user-event/keyboard.ts +35 -5
- package/src/user-event/list-row-click.ts +3 -3
- package/src/user-event/pointer.ts +11 -15
- package/src/user-event/selection.ts +5 -4
- package/src/user-event/text.ts +36 -32
- package/src/wait-for.ts +46 -36
- package/src/widget-accessible-properties.ts +112 -52
- package/src/widget-getters.ts +11 -13
- package/src/widget-target.ts +11 -0
package/dist/queries.js
CHANGED
|
@@ -3,7 +3,7 @@ import { buildQueries } from "./build-queries.js";
|
|
|
3
3
|
import { multipleFoundError, notFoundError } from "./errors.js";
|
|
4
4
|
import { getDefaultNormalizer } from "./normalize.js";
|
|
5
5
|
import { findAll, traverse } from "./traversal.js";
|
|
6
|
-
import { getWidgetAccessibleName, getWidgetBusyState, getWidgetDescription, getWidgetDisplayValue, getWidgetExpandedState, getWidgetExternalLabelText, getWidgetLabelText, getWidgetLevel, getWidgetName, getWidgetOwnLabel, getWidgetPlaceholderText, getWidgetPressedState, getWidgetSelectedState, getWidgetValueText,
|
|
6
|
+
import { buildInaccessibilityCheck, getWidgetAccessibleName, getWidgetBusyState, getWidgetDescription, getWidgetDisplayValue, getWidgetExpandedState, getWidgetExternalLabelText, getWidgetLabelText, getWidgetLevel, getWidgetName, getWidgetOwnLabel, getWidgetPlaceholderText, getWidgetPressedState, getWidgetSelectedState, getWidgetValueText, isWidgetChecked, isWidgetValueMatch, namingLabelText, } from "./widget-accessible-properties.js";
|
|
7
7
|
const roleQueries = nameQueryFamily("Role", queryAllByRole, buildQueries(queryAllByRole, (container, matches, role, options) => multipleFoundError(container, { queryType: "role", role, options }, matches), (container, role, options) => notFoundError(container, { queryType: "role", role, options })));
|
|
8
8
|
const labelTextQueries = nameQueryFamily("LabelText", queryAllByLabelText, buildQueries(queryAllByLabelText, (container, matches, text) => multipleFoundError(container, { queryType: "labelText", text }, matches), (container, text) => notFoundError(container, { queryType: "labelText", text })));
|
|
9
9
|
const textQueries = nameQueryFamily("Text", queryAllByText, buildQueries(queryAllByText, (container, matches, text) => multipleFoundError(container, { queryType: "text", text }, matches), (container, text) => notFoundError(container, { queryType: "text", text })));
|
|
@@ -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)) {
|
|
@@ -230,10 +234,11 @@ const collectLabelMatches = (results, widget, text, options) => {
|
|
|
230
234
|
*/
|
|
231
235
|
function queryAllByLabelText(container, text, options) {
|
|
232
236
|
const results = new Set();
|
|
233
|
-
|
|
237
|
+
const widgets = new Set(traverse(container));
|
|
238
|
+
for (const widget of widgets) {
|
|
234
239
|
collectLabelMatches(results, widget, text, options);
|
|
235
240
|
}
|
|
236
|
-
return [...results].filter((widget) => isMatchingWidgetType(widget, options));
|
|
241
|
+
return [...results].filter((widget) => widgets.has(widget) && isMatchingWidgetType(widget, options));
|
|
237
242
|
}
|
|
238
243
|
/**
|
|
239
244
|
* Finds every widget whose rendered text content matches. Widgets that are not mapped are never matched.
|
|
@@ -243,7 +248,8 @@ function queryAllByLabelText(container, text, options) {
|
|
|
243
248
|
* @returns Every matching widget, or an empty array when none match.
|
|
244
249
|
*/
|
|
245
250
|
function queryAllByText(container, text, options) {
|
|
246
|
-
|
|
251
|
+
const matches = findAll(container, (widget) => isMatchingWidgetType(widget, options) && isTextMatch(getWidgetLabelText(widget), text, widget, options));
|
|
252
|
+
return matches.filter((widget) => isMatchingWidgetType(widget, options));
|
|
247
253
|
}
|
|
248
254
|
/**
|
|
249
255
|
* Finds every widget whose widget name matches. Widgets that are not mapped are never matched.
|
|
@@ -253,7 +259,8 @@ function queryAllByText(container, text, options) {
|
|
|
253
259
|
* @returns Every matching widget, or an empty array when none match.
|
|
254
260
|
*/
|
|
255
261
|
function queryAllByName(container, name, options) {
|
|
256
|
-
|
|
262
|
+
const matches = findAll(container, (widget) => isMatchingWidgetType(widget, options) && isTextMatch(getWidgetName(widget), name, widget, options));
|
|
263
|
+
return matches.filter((widget) => isMatchingWidgetType(widget, options));
|
|
257
264
|
}
|
|
258
265
|
/**
|
|
259
266
|
* Finds every widget whose placeholder text matches. Widgets that are not mapped are never matched.
|
|
@@ -263,8 +270,9 @@ function queryAllByName(container, name, options) {
|
|
|
263
270
|
* @returns Every matching widget, or an empty array when none match.
|
|
264
271
|
*/
|
|
265
272
|
function queryAllByPlaceholderText(container, text, options) {
|
|
266
|
-
|
|
273
|
+
const matches = findAll(container, (widget) => isMatchingWidgetType(widget, options) &&
|
|
267
274
|
isTextMatch(getWidgetPlaceholderText(widget), text, widget, options));
|
|
275
|
+
return matches.filter((widget) => isMatchingWidgetType(widget, options));
|
|
268
276
|
}
|
|
269
277
|
/**
|
|
270
278
|
* Finds every widget whose current display value matches. Widgets that are not mapped are never matched.
|
|
@@ -274,8 +282,9 @@ function queryAllByPlaceholderText(container, text, options) {
|
|
|
274
282
|
* @returns Every matching widget, or an empty array when none match.
|
|
275
283
|
*/
|
|
276
284
|
function queryAllByDisplayValue(container, value, options) {
|
|
277
|
-
|
|
285
|
+
const matches = findAll(container, (widget) => isMatchingWidgetType(widget, options) &&
|
|
278
286
|
isTextMatch(getWidgetDisplayValue(widget), value, widget, options));
|
|
287
|
+
return matches.filter((widget) => isMatchingWidgetType(widget, options));
|
|
279
288
|
}
|
|
280
289
|
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
290
|
//# 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,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ACjH,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,SAAS,yBAAyB,CAC9B,SAAoB,EACpB,IAAa,EACb,OAAwB;IAExB,OAAO,OAAO,CACV,SAAS,EACT,CAAC,MAAM,EAAE,EAAE,CACP,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC;QACrC,WAAW,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAC3E,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,SAAS,sBAAsB,CAAC,SAAoB,EAAE,KAAc,EAAE,OAAwB;IAC1F,OAAO,OAAO,CACV,SAAS,EACT,CAAC,MAAM,EAAE,EAAE,CACP,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC;QACrC,WAAW,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CACzE,CAAC;AACN,CAAC;AAED,OAAO,EACH,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,sBAAsB,GACzB,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport type {\n ByRoleOptions,\n ByRoleValue,\n Matcher,\n MatcherOptions,\n NormalizerFn,\n QueryFamilies,\n} from \"./types.js\";\nimport { buildQueries, type BuiltQueries, type QueryAllBy } from \"./build-queries.js\";\nimport { multipleFoundError, notFoundError } from \"./errors.js\";\nimport { getDefaultNormalizer } from \"./normalize.js\";\nimport { type Container, findAll, traverse } from \"./traversal.js\";\nimport {\n 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"]}
|
|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k 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 const widgets = new Set(traverse(container));\n\n for (const widget of widgets) {\n collectLabelMatches(results, widget, text, options);\n }\n\n return [...results].filter((widget): widget is Gtk.Widget & T =>\n widgets.has(widget) && isMatchingWidgetType(widget, options),\n );\n}\n\n/**\n * Finds every widget whose rendered text content matches. Widgets that are not mapped are never matched.\n * @param container Widget subtree to search.\n * @param text Matcher for the widget text.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByText<T extends Gtk.Accessible = Gtk.Widget>(\n container: Container,\n text: Matcher,\n options?: MatcherOptions<T>,\n): T[] {\n const matches = findAll(\n container,\n (widget) =>\n isMatchingWidgetType(widget, options) && isTextMatch(getWidgetLabelText(widget), text, widget, options),\n );\n\n return matches.filter((widget): widget is Gtk.Widget & T => isMatchingWidgetType(widget, options));\n}\n\n/**\n * Finds every widget whose widget name matches. Widgets that are not mapped are never matched.\n * @param container Widget subtree to search.\n * @param name Matcher for the widget name.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByName<T extends Gtk.Accessible = Gtk.Widget>(\n container: Container,\n name: Matcher,\n options?: MatcherOptions<T>,\n): T[] {\n const matches = findAll(\n container,\n (widget) => isMatchingWidgetType(widget, options) && isTextMatch(getWidgetName(widget), name, widget, options),\n );\n\n return matches.filter((widget): widget is Gtk.Widget & T => isMatchingWidgetType(widget, options));\n}\n\n/**\n * Finds every widget whose placeholder text matches. Widgets that are not mapped are never matched.\n * @param container Widget subtree to search.\n * @param text Matcher for the placeholder text.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByPlaceholderText<T extends Gtk.Accessible = Gtk.Widget>(\n container: Container,\n text: Matcher,\n options?: MatcherOptions<T>,\n): T[] {\n const matches = findAll(\n container,\n (widget) =>\n isMatchingWidgetType(widget, options) &&\n isTextMatch(getWidgetPlaceholderText(widget), text, widget, options),\n );\n\n return matches.filter((widget): widget is Gtk.Widget & T => isMatchingWidgetType(widget, options));\n}\n\n/**\n * Finds every widget whose current display value matches. Widgets that are not mapped are never matched.\n * @param container Widget subtree to search.\n * @param value Matcher for the display value.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByDisplayValue<T extends Gtk.Accessible = Gtk.Widget>(\n container: Container,\n value: Matcher,\n options?: MatcherOptions<T>,\n): T[] {\n const matches = findAll(\n container,\n (widget) =>\n isMatchingWidgetType(widget, options) &&\n isTextMatch(getWidgetDisplayValue(widget), value, widget, options),\n );\n\n return matches.filter((widget): widget is Gtk.Widget & T => isMatchingWidgetType(widget, options));\n}\n\nexport {\n builtinQueries,\n isMatchingWidgetType,\n isTextMatch,\n queryByRole,\n getAllByRole,\n getByRole,\n findAllByRole,\n findByRole,\n queryByLabelText,\n getAllByLabelText,\n getByLabelText,\n findAllByLabelText,\n findByLabelText,\n queryByText,\n getAllByText,\n getByText,\n findAllByText,\n findByText,\n queryByName,\n getAllByName,\n getByName,\n findAllByName,\n findByName,\n queryByPlaceholderText,\n getAllByPlaceholderText,\n getByPlaceholderText,\n findAllByPlaceholderText,\n findByPlaceholderText,\n queryByDisplayValue,\n getAllByDisplayValue,\n getByDisplayValue,\n findAllByDisplayValue,\n findByDisplayValue,\n queryAllByRole,\n queryAllByLabelText,\n queryAllByText,\n queryAllByName,\n queryAllByPlaceholderText,\n queryAllByDisplayValue,\n};\n"]}
|
package/dist/query-helpers.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ declare const queryHelpers: QueryHelpers;
|
|
|
27
27
|
* @param options Text matching options.
|
|
28
28
|
* @returns Every matching widget, or an empty array when none match.
|
|
29
29
|
*/
|
|
30
|
-
declare function queryAllByObjectProperty(property: string, container: Container, text: Matcher, options?: MatcherOptions):
|
|
30
|
+
declare function queryAllByObjectProperty<T extends Gtk.Accessible = Gtk.Widget>(property: string, container: Container, text: Matcher, options?: MatcherOptions<T>): T[];
|
|
31
31
|
/**
|
|
32
32
|
* Returns the single widget carrying a GObject property whose value matches, or null when none do,
|
|
33
33
|
* the counterpart of DOM Testing Library's `queryByAttribute`.
|
|
@@ -39,6 +39,6 @@ declare function queryAllByObjectProperty(property: string, container: Container
|
|
|
39
39
|
* @returns The matching widget, or null when none match.
|
|
40
40
|
* @throws When more than one widget matches.
|
|
41
41
|
*/
|
|
42
|
-
declare function queryByObjectProperty(property: string, container: Container, text: Matcher, options?: MatcherOptions):
|
|
42
|
+
declare function queryByObjectProperty<T extends Gtk.Accessible = Gtk.Widget>(property: string, container: Container, text: Matcher, options?: MatcherOptions<T>): T | null;
|
|
43
43
|
export { queryAllByObjectProperty, queryByObjectProperty, queryHelpers, type QueryHelpers };
|
|
44
44
|
//# sourceMappingURL=query-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-helpers.d.ts","sourceRoot":"","sources":["../src/query-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,gBAAgB,CAAC;AAEzD,kGAAkG;AAClG,KAAK,YAAY,GAAG;IAChB,wEAAwE;IACxE,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,+CAA+C;IAC/C,eAAe,EAAE,OAAO,eAAe,CAAC;IACxC,yDAAyD;IACzD,wBAAwB,EAAE,OAAO,wBAAwB,CAAC;IAC1D,8DAA8D;IAC9D,qBAAqB,EAAE,OAAO,qBAAqB,CAAC;CACvD,CAAC;AAEF,wFAAwF;AACxF,QAAA,MAAM,YAAY,EAAE,YAKnB,CAAC;
|
|
1
|
+
{"version":3,"file":"query-helpers.d.ts","sourceRoot":"","sources":["../src/query-helpers.ts"],"names":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+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,OAA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AC;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-hook.js
CHANGED
|
@@ -16,9 +16,9 @@ async function renderHook(callback, options) {
|
|
|
16
16
|
});
|
|
17
17
|
return {
|
|
18
18
|
result: resultRef,
|
|
19
|
-
rerender: async (
|
|
20
|
-
if (
|
|
21
|
-
currentProps =
|
|
19
|
+
rerender: async (...args) => {
|
|
20
|
+
if (args.length === 1) {
|
|
21
|
+
[currentProps] = args;
|
|
22
22
|
}
|
|
23
23
|
await renderResult.rerender(_jsx(TestComponent, { props: currentProps }));
|
|
24
24
|
},
|
package/dist/render-hook.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-hook.js","sourceRoot":"","sources":["../src/render-hook.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA4BrC,KAAK,UAAU,UAAU,CACrB,QAAkC,EAClC,OAAkC;IAElC,MAAM,YAAY,GAAI,OAAgD,EAAE,YAAqB,CAAC;IAC9F,MAAM,SAAS,GAAoC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAC1E,IAAI,YAAY,GAAU,YAAY,CAAC;IAEvC,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,EAAoB,EAAQ,EAAE;QACxD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC/B,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC;QAE3B,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,KAAC,aAAa,IAAC,KAAK,EAAE,YAAY,GAAI,EAAE;QACtE,SAAS,EAAE,IAAI,GAAG,CAAC,GAAG,EAAE;QACxB,OAAO,EAAE,OAAO,EAAE,OAAO;KAC5B,CAAC,CAAC;IAEH,OAAO;QACH,MAAM,EAAE,SAAgC;QACxC,QAAQ,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"render-hook.js","sourceRoot":"","sources":["../src/render-hook.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA4BrC,KAAK,UAAU,UAAU,CACrB,QAAkC,EAClC,OAAkC;IAElC,MAAM,YAAY,GAAI,OAAgD,EAAE,YAAqB,CAAC;IAC9F,MAAM,SAAS,GAAoC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAC1E,IAAI,YAAY,GAAU,YAAY,CAAC;IAEvC,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,EAAoB,EAAQ,EAAE;QACxD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC/B,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC;QAE3B,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,KAAC,aAAa,IAAC,KAAK,EAAE,YAAY,GAAI,EAAE;QACtE,SAAS,EAAE,IAAI,GAAG,CAAC,GAAG,EAAE;QACxB,OAAO,EAAE,OAAO,EAAE,OAAO;KAC5B,CAAC,CAAC;IAEH,OAAO;QACH,MAAM,EAAE,SAAgC;QACxC,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAkB,EAAE,EAAE;YACtC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACpB,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;YAC1B,CAAC;YAED,MAAM,YAAY,CAAC,QAAQ,CAAC,KAAC,aAAa,IAAC,KAAK,EAAE,YAAY,GAAI,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,EAAE,YAAY,CAAC,OAAO;KAChC,CAAC;AACN,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport type { RenderHookOptions, RenderHookResult } from \"./types.js\";\nimport { render } from \"./render.js\";\n\n/**\n * Renders a test component that calls the given hook, exposing its latest\n * return value along with rerender and unmount controls.\n *\n * @param callback The hook to run, invoked with the current props.\n * @param options Optional initial props and wrapper component.\n * @returns A result whose `result.current` holds the hook's latest value.\n */\nfunction renderHook<Result>(\n callback: () => Result,\n options?: RenderHookOptions<undefined>,\n): Promise<RenderHookResult<Result, undefined>>;\n\n/**\n * Renders a test component that calls the given hook with props, exposing its\n * latest return value along with rerender and unmount controls.\n *\n * @param callback The hook to run, invoked with the current props.\n * @param options Initial props and optional wrapper component.\n * @returns A result whose `result.current` holds the hook's latest value.\n */\nfunction renderHook<Result, Props>(\n callback: (props: Props) => Result,\n options: RenderHookOptions<Props>,\n): Promise<RenderHookResult<Result, Props>>;\n\nasync function renderHook<Result, Props>(\n callback: (props: Props) => Result,\n options?: RenderHookOptions<Props>,\n): Promise<RenderHookResult<Result, Props>> {\n const initialProps = (options as { initialProps?: Props } | undefined)?.initialProps as Props;\n const resultRef: { current: Result | undefined } = { current: undefined };\n let currentProps: Props = initialProps;\n\n const TestComponent = ({ props }: { props: Props }): null => {\n const result = callback(props);\n resultRef.current = result;\n\n return null;\n };\n\n const renderResult = await render(<TestComponent props={currentProps} />, {\n container: new Gtk.Box(),\n wrapper: options?.wrapper,\n });\n\n return {\n result: resultRef as { current: Result },\n rerender: async (...args: [] | [Props]) => {\n if (args.length === 1) {\n [currentProps] = args;\n }\n\n await renderResult.rerender(<TestComponent props={currentProps} />);\n },\n unmount: renderResult.unmount,\n };\n}\n\nexport { renderHook };\n"]}
|
package/dist/render.d.ts
CHANGED
|
@@ -2,24 +2,24 @@ import { type ReactNode } from "react";
|
|
|
2
2
|
import type { RenderResult } from "./bound-queries.js";
|
|
3
3
|
import type { QueryMap, RenderOptions } from "./types.js";
|
|
4
4
|
/**
|
|
5
|
-
* Renders
|
|
6
|
-
* scoped to it along with controls for rerendering and unmounting. When no
|
|
7
|
-
* container is supplied, a harness window is created and presented, and the editable it hands the
|
|
8
|
-
* focus to keeps its text unselected, with its caret at the end. The returned promise settles once
|
|
9
|
-
* the window the tree is shown in has been laid out and activation has arrived, so platform state
|
|
10
|
-
* such as focus is already readable when it resolves. A presented harness window is waited on until
|
|
11
|
-
* it is itself active; a window the caller or the tree owns is waited on until the application holds
|
|
12
|
-
* activation, since only a present can claim it. Rendering into a container that is not shown waits
|
|
13
|
-
* for nothing, and a window that never becomes readable within `windowActivationTimeout` throws an
|
|
14
|
-
* error naming the condition that failed rather than resolving with unreadable platform state. A
|
|
15
|
-
* tree mounted into a container that sits outside every toplevel, or inside a window that is not
|
|
16
|
-
* visible, is out of reach of a pointer and a keyboard, so every `userEvent` helper aimed at it
|
|
17
|
-
* rejects after `actionabilityTimeout` naming that condition, and `fireEvent` drives it instead.
|
|
5
|
+
* Renders React into native widgets and returns queries, debug helpers, and lifecycle controls.
|
|
18
6
|
*
|
|
19
|
-
* @
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Without a container, creates and presents a harness window. Its initially focused editable
|
|
9
|
+
* keeps its text unselected, with the caret at the end.
|
|
10
|
+
*
|
|
11
|
+
* Waits for layout and activation before resolving, so focus and other platform state can be
|
|
12
|
+
* read immediately. A new harness waits for its own activation; a caller-owned or rendered
|
|
13
|
+
* window waits for application activation, since only presentation can claim it. A container
|
|
14
|
+
* that is not shown requires no activation wait.
|
|
15
|
+
*
|
|
16
|
+
* Widgets outside all toplevels or inside a hidden window cannot receive pointer or keyboard
|
|
17
|
+
* input. `userEvent` rejects after `actionabilityTimeout`; use `fireEvent` to drive them directly.
|
|
18
|
+
*
|
|
19
|
+
* @param element React element to render.
|
|
20
|
+
* @param options Container, wrapper, custom queries, and render settings.
|
|
21
|
+
* @returns Bound queries, debug helpers, and rerender/unmount controls.
|
|
22
|
+
* @throws If a shown window is not laid out and activated within `windowActivationTimeout`.
|
|
23
23
|
*/
|
|
24
24
|
declare const render: <Q extends QueryMap = Record<never, never>>(element: ReactNode, options?: RenderOptions<Q>) => Promise<RenderResult<Q>>;
|
|
25
25
|
/**
|
package/dist/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.tsx"],"names":[],"mappings":"AAIA,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;AAgM7E;;;;;;;;;;;;;;;;;;;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,CAqDzB,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,OAAO,QAAa,OAAO,CAAC,IAAI,CAErC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC"}
|