@gtkx/testing 2.0.0-beta.2 → 2.0.0-beta.4
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/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 +6 -6
- package/dist/matchers.d.ts.map +1 -1
- package/dist/matchers.js +4 -3
- 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 +16 -9
- 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 +4 -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 +3 -1
- 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 +3 -3
- package/dist/traversal.d.ts.map +1 -1
- package/dist/traversal.js +1 -1
- package/dist/traversal.js.map +1 -1
- package/dist/types.d.ts +8 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.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/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 +2 -2
- package/dist/widget-accessible-properties.d.ts.map +1 -1
- package/dist/widget-accessible-properties.js +3 -1
- 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 +5 -5
- package/src/build-queries.ts +60 -30
- package/src/fire-event.ts +32 -8
- package/src/matchers.ts +14 -13
- package/src/queries.ts +61 -29
- package/src/query-helpers.ts +11 -9
- package/src/render.tsx +5 -0
- package/src/role-helpers.ts +3 -1
- package/src/screenshot.ts +3 -1
- package/src/suggestions.ts +3 -1
- package/src/traversal.ts +4 -4
- package/src/types.ts +12 -8
- package/src/user-event/controller.ts +8 -5
- package/src/user-event/index.ts +133 -47
- package/src/user-event/selection.ts +12 -4
- package/src/wait-for.ts +9 -6
- package/src/widget-accessible-properties.ts +7 -5
- package/src/widget-getters.ts +11 -13
- package/src/widget-target.ts +11 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestions.d.ts","sourceRoot":"","sources":["../src/suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"suggestions.d.ts","sourceRoot":"","sources":["../src/suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAapC,8CAA8C;AAC9C,KAAK,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAC5E,6CAA6C;AAC7C,KAAK,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,iBAAiB,GAAG,MAAM,GAAG,cAAc,GAAG,MAAM,CAAC;AAE1F;;;GAGG;AACH,KAAK,UAAU,GAAG;IACd,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,WAAW,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,OAAO,EAAE,OAAO,CAAC;IACjB,qGAAqG;IACrG,QAAQ,EAAE,MAAM,MAAM,CAAC;CAC1B,CAAC;AAsCF;;;;;;;GAOG;AACH,QAAA,MAAM,iBAAiB,GACnB,QAAQ,GAAG,CAAC,UAAU,EACtB,UAAS,OAAe,EACxB,SAAS,MAAM,KAChB,UAAU,GAAG,SA2Bf,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,UAAU,EAAE,CAAC"}
|
package/dist/suggestions.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
2
|
import { formatRole } from "./role-helpers.js";
|
|
3
3
|
import { getWidgetAccessibleName, getWidgetDisplayValue, getWidgetLabelledByText, getWidgetLabelText, getWidgetName, getWidgetOwnLabel, getWidgetPlaceholderText, } from "./widget-accessible-properties.js";
|
|
4
|
+
import { requireWidget } from "./widget-target.js";
|
|
4
5
|
const makeSuggestion = (queryName, variant, argsText) => {
|
|
5
6
|
const queryMethod = `${variant}By${queryName}`;
|
|
6
7
|
return {
|
|
@@ -36,7 +37,8 @@ const textSuggestion = (queryName, variant, value) => {
|
|
|
36
37
|
* @param method Restrict the suggestion to a specific query family instead of choosing by priority.
|
|
37
38
|
* @returns The best available suggestion, or undefined when no query applies.
|
|
38
39
|
*/
|
|
39
|
-
const getSuggestedQuery = (
|
|
40
|
+
const getSuggestedQuery = (target, variant = "get", method) => {
|
|
41
|
+
const widget = requireWidget(target);
|
|
40
42
|
const builders = {
|
|
41
43
|
Role: () => roleSuggestion(widget, variant),
|
|
42
44
|
LabelText: () => textSuggestion("LabelText", variant, getWidgetOwnLabel(widget) ?? getWidgetLabelledByText(widget)),
|
package/dist/suggestions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestions.js","sourceRoot":"","sources":["../src/suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACH,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,GAC3B,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"suggestions.js","sourceRoot":"","sources":["../src/suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACH,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAsBnD,MAAM,cAAc,GAAG,CAAC,SAAiB,EAAE,OAAgB,EAAE,QAAgB,EAAc,EAAE;IACzF,MAAM,WAAW,GAAG,GAAG,OAAO,KAAK,SAAS,EAAE,CAAC;IAE/C,OAAO;QACH,SAAS;QACT,WAAW;QACX,OAAO;QACP,QAAQ,EAAE,GAAG,EAAE,CAAC,G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AAG,EAAE,CACZ,cAAc,CAAC,WAAW,EAAE,OAAO,EAAE,iBAAiB,CAAC,MAAM,CAAC,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;QACtG,eAAe,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,iBAAiB,EAAE,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;QACnG,IAAI,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACvE,YAAY,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,cAAc,EAAE,OAAO,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAC1F,IAAI,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;KACrE,CAAC;IAEF,IAAI,MAAM,EAAE,CAAC;QACT,OAAO,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;IAC9B,CAAC;IAED,MAAM,QAAQ,GAAa,CAAC,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;IAEpG,KAAK,MAAM,SAAS,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAEzC,IAAI,UAAU,EAAE,CAAC;YACb,OAAO,UAAU,CAAC;QACtB,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAA8C,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { formatRole } from \"./role-helpers.js\";\nimport {\n getWidgetAccessibleName,\n getWidgetDisplayValue,\n getWidgetLabelledByText,\n getWidgetLabelText,\n getWidgetName,\n getWidgetOwnLabel,\n getWidgetPlaceholderText,\n} from \"./widget-accessible-properties.js\";\nimport { requireWidget } from \"./widget-target.js\";\n\n/** The query variant a suggestion targets. */\ntype Variant = \"get\" | \"getAll\" | \"query\" | \"queryAll\" | \"find\" | \"findAll\";\n/** The query family a suggestion targets. */\ntype Method = \"Role\" | \"LabelText\" | \"PlaceholderText\" | \"Text\" | \"DisplayValue\" | \"Name\";\n\n/**\n * A suggested query for reaching a widget, including its family, variant, method name, and a\n * `toString` that renders the full call.\n */\ntype Suggestion = {\n /** The query family, such as `Role`. */\n queryName: Method;\n /** The full query function name, such as `getByRole`. */\n queryMethod: string;\n /** The variant the suggestion was asked for, which prefixes `Suggestion.queryMethod`. */\n variant: Variant;\n /** Renders the suggested call with its arguments, such as `getByRole(Gtk.AccessibleRole.BUTTON)`. */\n toString: () => string;\n};\n\nconst makeSuggestion = (queryName: Method, variant: Variant, argsText: string): Suggestion => {\n const queryMethod = `${variant}By${queryName}`;\n\n return {\n queryName,\n queryMethod,\n variant,\n toString: () => `${queryMethod}(${argsText})`,\n };\n};\n\nconst roleSuggestion = (widget: Gtk.Widget, variant: Variant): Suggestion | undefined => {\n const role = widget.getAccessibleRole();\n\n if (role === Gtk.AccessibleRole.NONE || role === Gtk.AccessibleRole.GENERIC) {\n return undefined;\n }\n\n const roleText = `Gtk.AccessibleRole.${formatRole(role).toUpperCase()}`;\n const name = getWidgetAccessibleName(widget);\n\n if (name === null) {\n return makeSuggestion(\"Role\", variant, roleText);\n }\n\n return makeSuggestion(\"Role\", variant, `${roleText}, { name: '${name}' }`);\n};\n\nconst textSuggestion = (queryName: Method, variant: Variant, value: string | null): Suggestion | undefined => {\n if (value === null) {\n return undefined;\n }\n\n return makeSuggestion(queryName, variant, `'${value}'`);\n};\n\n/**\n * Computes the recommended query for reaching the given widget, preferring role, then label text,\n * placeholder text, text, display value, and name.\n * @param widget Widget to build a suggestion for.\n * @param variant Query variant the suggestion should use.\n * @param method Restrict the suggestion to a specific query family instead of choosing by priority.\n * @returns The best available suggestion, or undefined when no query applies.\n */\nconst getSuggestedQuery = (\n target: Gtk.Accessible,\n variant: Variant = \"get\",\n method?: Method,\n): Suggestion | undefined => {\n const widget = requireWidget(target);\n const builders: Record<Method, () => Suggestion | undefined> = {\n Role: () => roleSuggestion(widget, variant),\n LabelText: () =>\n textSuggestion(\"LabelText\", variant, getWidgetOwnLabel(widget) ?? getWidgetLabelledByText(widget)),\n PlaceholderText: () => textSuggestion(\"PlaceholderText\", variant, getWidgetPlaceholderText(widget)),\n Text: () => textSuggestion(\"Text\", variant, getWidgetLabelText(widget)),\n DisplayValue: () => textSuggestion(\"DisplayValue\", variant, getWidgetDisplayValue(widget)),\n Name: () => textSuggestion(\"Name\", variant, getWidgetName(widget)),\n };\n\n if (method) {\n return builders[method]();\n }\n\n const priority: Method[] = [\"Role\", \"LabelText\", \"PlaceholderText\", \"Text\", \"DisplayValue\", \"Name\"];\n\n for (const candidate of priority) {\n const suggestion = builders[candidate]();\n\n if (suggestion) {\n return suggestion;\n }\n }\n\n return undefined;\n};\n\nexport { getSuggestedQuery, type Variant, type Method, type Suggestion };\n"]}
|
package/dist/traversal.d.ts
CHANGED
|
@@ -3,21 +3,21 @@ import * as Gtk from "@gtkx/gi/gtk";
|
|
|
3
3
|
* A scope that resolves to a single root widget: the widget itself, the widget a controller or
|
|
4
4
|
* layout manager is attached to, or a list item's or header's child.
|
|
5
5
|
*/
|
|
6
|
-
type QueryContainer = Gtk.
|
|
6
|
+
type QueryContainer = Gtk.Accessible | Gtk.EventController | Gtk.LayoutManager | Gtk.ListItem | Gtk.ListHeader;
|
|
7
7
|
/**
|
|
8
8
|
* A scope that queries and traversal can run against: a widget, an event
|
|
9
9
|
* controller, a layout manager, a list item or header, an application, or the
|
|
10
10
|
* sentinel representing all current toplevel windows.
|
|
11
11
|
*/
|
|
12
12
|
type Container = QueryContainer | Gtk.Application | typeof TOPLEVELS;
|
|
13
|
-
type WidgetClass<T extends
|
|
13
|
+
type WidgetClass<T extends object> = abstract new (...args: never[]) => T;
|
|
14
14
|
/** Container sentinel that widens a query to every toplevel window currently open. */
|
|
15
15
|
declare const TOPLEVELS: unique symbol;
|
|
16
16
|
declare const isOnScreen: (widget: Gtk.Widget) => boolean;
|
|
17
17
|
declare const children: (widget: Gtk.Widget) => Generator<Gtk.Widget>;
|
|
18
18
|
declare const descendants: (widget: Gtk.Widget) => Generator<Gtk.Widget>;
|
|
19
19
|
declare const ancestors: (widget: Gtk.Widget) => Generator<Gtk.Widget>;
|
|
20
|
-
declare const ancestorFor: <T extends
|
|
20
|
+
declare const ancestorFor: <T extends object>(widget: Gtk.Widget, type: WidgetClass<T>) => T | null;
|
|
21
21
|
declare const relationCandidates: (widget: Gtk.Widget) => Gtk.Accessible[];
|
|
22
22
|
declare const roots: (container: Container) => Generator<Gtk.Widget>;
|
|
23
23
|
declare const traverse: (container: Container) => Generator<Gtk.Widget>;
|
package/dist/traversal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traversal.d.ts","sourceRoot":"","sources":["../src/traversal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC;;;GAGG;AACH,KAAK,cAAc,GAAG,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"traversal.d.ts","sourceRoot":"","sources":["../src/traversal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC;;;GAGG;AACH,KAAK,cAAc,GAAG,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,eAAe,GAAG,GAAG,CAAC,aAAa,GAAG,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAC;AAC/G;;;;GAIG;AACH,KAAK,SAAS,GAAG,cAAc,GAAG,GAAG,CAAC,WAAW,GAAG,OAAO,SAAS,CAAC;AACrE,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI,QAAQ,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAE1E,sFAAsF;AACtF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62
|
if (container instanceof Gtk.ListItem || container instanceof Gtk.ListHeader) {
|
|
63
63
|
return container.getChild();
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
throw new TypeError("Query container must resolve to a Gtk.Widget");
|
|
66
66
|
};
|
|
67
67
|
const roots = function* (container) {
|
|
68
68
|
if (container === TOPLEVELS || isApplication(container)) {
|
package/dist/traversal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traversal.js","sourceRoot":"","sources":["../src/traversal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAepC,sFAAsF;AACtF,MAAM,SAAS,GAAkB,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAE1D,MAAM,aAAa,GAAG,CAAC,SAAoB,EAAgC,EAAE,CAAC,SAAS,YAAY,GAAG,CAAC,WAAW,CAAC;AACnH,MAAM,WAAW,GAAG,GAAY,EAAE,CAAC,IAAI,CAAC;AACxC,MAAM,UAAU,GAAG,CAAC,MAAkB,EAAW,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;AAEvE,MAAM,kBAAkB,GAAG,QAAQ,CAAC,EAChC,IAAgB,EAChB,UAA2C;IAE3C,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,CAAC;IACf,CAAC;IAED,IAAI,KAAK,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IAEjC,OAAO,KAAK,EAAE,CAAC;QACX,KAAK,CAAC,CAAC,kBAAkB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAC7C,KAAK,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC;IACnC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,QAAQ,CAAC,EAAE,MAAkB;IAC1C,IAAI,KAAK,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;IAEnC,OAAO,KAAK,EAAE,CAAC;QACX,MAAM,KAAK,CAAC;QACZ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G,QAAQ,CAAC,EAAE,SAAoB;IAC5C,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QAClC,KAAK,CAAC,CAAC,kBAAkB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,SAAoB,EAAE,OAAsC,EAAgB,EAAE;IAC3F,MAAM,OAAO,GAAiB,EAAE,CAAC;IAEjC,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACrC,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF,OAAO,EACH,SAAS,EACT,WAAW,EACX,SAAS,EACT,QAAQ,EACR,WAAW,EACX,OAAO,EACP,UAAU,EACV,kBAAkB,EAClB,KAAK,EACL,QAAQ,GAEX,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\n\n/**\n * A scope that resolves to a single root widget: the widget itself, the widget a controller or\n * layout manager is attached to, or a list item's or header's child.\n */\ntype QueryContainer = Gtk.Accessible | Gtk.EventController | Gtk.LayoutManager | Gtk.ListItem | Gtk.ListHeader;\n/**\n * A scope that queries and traversal can run against: a widget, an event\n * controller, a layout manager, a list item or header, an application, or the\n * sentinel representing all current toplevel windows.\n */\ntype Container = QueryContainer | Gtk.Application | typeof TOPLEVELS;\ntype WidgetClass<T extends object> = abstract new (...args: never[]) => T;\n\n/** Container sentinel that widens a query to every toplevel window currently open. */\nconst TOPLEVELS: unique symbol = Symbol(\"gtkx.toplevels\");\n\nconst isApplication = (container: Container): container is Gtk.Application => container instanceof Gtk.Application;\nconst isAnyWidget = (): boolean => true;\nconst isOnScreen = (widget: Gtk.Widget): boolean => widget.getMapped();\n\nconst traverseWidgetTree = function* (\n root: Gtk.Widget,\n isIncluded: (widget: Gtk.Widget) => boolean,\n): Generator<Gtk.Widget> {\n if (isIncluded(root)) {\n yield root;\n }\n\n let child = root.getFirstChild();\n\n while (child) {\n yield* traverseWidgetTree(child, isIncluded);\n child = child.getNextSibling();\n }\n};\n\nconst children = function* (widget: Gtk.Widget): Generator<Gtk.Widget> {\n let child = widget.getFirstChild();\n\n while (child) {\n yield child;\n child = child.getNextSibling();\n }\n};\n\nconst descendants = function* (widget: Gtk.Widget): Generator<Gtk.Widget> {\n const tree = traverseWidgetTree(widget, isAnyWidget);\n tree.next();\n yield* tree;\n};\n\nconst ancestors = function* (widget: Gtk.Widget): Generator<Gtk.Widget> {\n let parent = widget.getParent();\n\n while (parent) {\n yield parent;\n parent = parent.getParent();\n }\n};\n\nconst ancestorFor = <T extends object>(widget: Gtk.Widget, type: WidgetClass<T>): T | null => {\n for (const ancestor of ancestors(widget)) {\n if (ancestor instanceof type) {\n return ancestor;\n }\n }\n\n return null;\n};\n\nconst relationCandidates = (widget: Gtk.Widget): Gtk.Accessible[] => {\n const pool: Gtk.Accessible[] = [...widget.listMnemonicLabels(), ...descendants(widget)];\n const root = widget.getRoot();\n\n if (root instanceof Gtk.Widget) {\n pool.push(...traverseWidgetTree(root, isAnyWidget));\n }\n\n return [...new Set(pool)];\n};\n\nconst resolveRoot = (container: QueryContainer): Gtk.Widget | null => {\n if (container instanceof Gtk.Widget) {\n return container;\n }\n\n if (container instanceof Gtk.EventController) {\n return container.getWidget();\n }\n\n if (container instanceof Gtk.LayoutManager) {\n return container.getWidget();\n }\n\n if (container instanceof Gtk.ListItem || container instanceof Gtk.ListHeader) {\n return container.getChild();\n }\n\n throw new TypeError(\"Query container must resolve to a Gtk.Widget\");\n};\n\nconst roots = function* (container: Container): Generator<Gtk.Widget> {\n if (container === TOPLEVELS || isApplication(container)) {\n yield* Gtk.Window.listToplevels();\n\n return;\n }\n\n const root = resolveRoot(container);\n\n if (root) {\n yield root;\n }\n};\n\nconst traverse = function* (container: Container): Generator<Gtk.Widget> {\n for (const root of roots(container)) {\n yield* traverseWidgetTree(root, isOnScreen);\n }\n};\n\nconst findAll = (container: Container, isMatch: (node: Gtk.Widget) => boolean): Gtk.Widget[] => {\n const results: Gtk.Widget[] = [];\n\n for (const node of traverse(container)) {\n if (isMatch(node)) {\n results.push(node);\n }\n }\n\n return results;\n};\n\nexport {\n TOPLEVELS,\n ancestorFor,\n ancestors,\n children,\n descendants,\n findAll,\n isOnScreen,\n relationCandidates,\n roots,\n traverse,\n type Container,\n};\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -14,9 +14,9 @@ type Matcher = string | number | RegExp | MatcherFunction;
|
|
|
14
14
|
type NormalizerFn = (text: string) => string;
|
|
15
15
|
/**
|
|
16
16
|
* A widget class usable as a query's `as` constraint, such as `Gtk.Button`. Abstract classes and
|
|
17
|
-
* generated GInterface pseudo-classes are accepted.
|
|
17
|
+
* generated GInterface pseudo-classes that extend `Gtk.Accessible` are accepted.
|
|
18
18
|
*/
|
|
19
|
-
type WidgetType<T extends Gtk.
|
|
19
|
+
type WidgetType<T extends Gtk.Accessible = Gtk.Accessible> = abstract new (...args: never[]) => T;
|
|
20
20
|
/** Options controlling the default text normalizer. */
|
|
21
21
|
type NormalizerOptions = {
|
|
22
22
|
/** Trim leading and trailing whitespace. */
|
|
@@ -36,7 +36,7 @@ type WaitForOptions = {
|
|
|
36
36
|
stackTraceError?: Error | undefined;
|
|
37
37
|
};
|
|
38
38
|
/** Options controlling text matching and, for asynchronous queries, polling behavior. */
|
|
39
|
-
type MatcherOptions<T extends Gtk.
|
|
39
|
+
type MatcherOptions<T extends Gtk.Accessible = Gtk.Accessible> = {
|
|
40
40
|
/** When true (the default), require an exact match; when false, match case-insensitively as a substring. */
|
|
41
41
|
exact?: boolean | undefined;
|
|
42
42
|
/** Custom normalizer replacing the default; cannot be combined with `trim` or `collapseWhitespace`. */
|
|
@@ -68,7 +68,7 @@ type ByRoleValue = {
|
|
|
68
68
|
text?: Matcher | undefined;
|
|
69
69
|
};
|
|
70
70
|
/** Options for role queries: an accessible name matcher plus accessible state and value constraints. */
|
|
71
|
-
type ByRoleOptions<T extends Gtk.
|
|
71
|
+
type ByRoleOptions<T extends Gtk.Accessible = Gtk.Accessible> = MatcherOptions<T> & {
|
|
72
72
|
/** Matcher for the widget's accessible name. */
|
|
73
73
|
name?: Matcher | undefined;
|
|
74
74
|
/** Required checked state; a mixed check button reads as neither, so it matches neither value. */
|
|
@@ -105,7 +105,7 @@ type BoundCustomQueries<Q extends QueryMap> = {
|
|
|
105
105
|
[K in keyof Q]: BoundQuery<Q[K]>;
|
|
106
106
|
};
|
|
107
107
|
/** What each variant of a query family yields for the widget type it matched. */
|
|
108
|
-
type QueryFamilyReturns<T extends Gtk.
|
|
108
|
+
type QueryFamilyReturns<T extends Gtk.Accessible> = {
|
|
109
109
|
/** The single match, or null when nothing matched; throws when more than one matched. */
|
|
110
110
|
queryBy: T | null;
|
|
111
111
|
/** Every match, empty when nothing matched. */
|
|
@@ -122,13 +122,13 @@ type QueryFamilyReturns<T extends Gtk.Widget> = {
|
|
|
122
122
|
/** What a query family matches against, which fixes the arguments it takes. */
|
|
123
123
|
type QueryKind = "role" | "text" | "name" | "value";
|
|
124
124
|
/** The arguments a query of the given kind takes after the family's leading ones. */
|
|
125
|
-
type QueryArgs<Kind extends QueryKind, T extends Gtk.
|
|
125
|
+
type QueryArgs<Kind extends QueryKind, T extends Gtk.Accessible> = Kind extends "role" ? [role: Gtk.AccessibleRole, options?: ByRoleOptions<T>] : Kind extends "name" ? [name: Matcher, options?: MatcherOptions<T>] : Kind extends "value" ? [value: Matcher, options?: MatcherOptions<T>] : [text: Matcher, options?: MatcherOptions<T>];
|
|
126
126
|
/**
|
|
127
127
|
* One family's query variants, each named for its variant followed by `Suffix` and taking `Head`
|
|
128
128
|
* ahead of the family's own arguments.
|
|
129
129
|
*/
|
|
130
130
|
type QueryFamily<Suffix extends string, Kind extends QueryKind, Head extends unknown[]> = {
|
|
131
|
-
[K in keyof QueryFamilyReturns<Gtk.Widget> as `${K & string}${Suffix}`]: <T extends Gtk.
|
|
131
|
+
[K in keyof QueryFamilyReturns<Gtk.Widget> as `${K & string}${Suffix}`]: <T extends Gtk.Accessible = Gtk.Widget>(...args: [...Head, ...QueryArgs<Kind, T>]) => QueryFamilyReturns<T>[K];
|
|
132
132
|
};
|
|
133
133
|
/**
|
|
134
134
|
* Every built-in query, spanning the Role, LabelText, Text, Name, PlaceholderText, and DisplayValue
|
|
@@ -146,7 +146,7 @@ type RenderOptions<Q extends QueryMap = Record<never, never>> = {
|
|
|
146
146
|
* out of reach of a pointer and a keyboard, so every `userEvent` helper aimed at it rejects
|
|
147
147
|
* after `actionabilityTimeout`; `fireEvent` drives such a tree instead.
|
|
148
148
|
*/
|
|
149
|
-
container?: Gtk.
|
|
149
|
+
container?: Gtk.Accessible | RootElement | undefined;
|
|
150
150
|
/** Root of the subtree that bound queries search. */
|
|
151
151
|
baseElement?: Container | undefined;
|
|
152
152
|
/** Component wrapped around the rendered element, such as a context provider. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;GAGG;AACH,KAAK,eAAe,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,KAAK,OAAO,CAAC;AACxE,wHAAwH;AACxH,KAAK,OAAO,GAA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OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC9B,GAAG,CAAC,SAAS,SAAS,KAAK,GACtB;IACM,yEAAyE;IACzE,YAAY,CAAC,EAAE,KAAK,CAAC;CACxB,GACH;IACM,YAAY,EAAE,KAAK,CAAC;CACvB,CAAC,CAAC;AAEX;;;GAGG;AACH,KAAK,gBAAgB,CAAC,MAAM,EAAE,KAAK,IAAI;IACnC,2EAA2E;IAC3E,MAAM,EAAE;QACJ,sCAAsC;QACtC,OAAO,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,2EAA2E;IAC3E,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,kDAAkD;IAClD,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC,CAAC;AAEF,OAAO,EACH,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACxB,CAAC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAsQA,OAAO,EAoBN,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { RootElement } from \"@gtkx/react\";\nimport type { ComponentType, ErrorInfo, ReactNode } from \"react\";\nimport type { PrettyWidgetOptions } from \"./pretty-widget.js\";\nimport type { Container } from \"./traversal.js\";\n\n/**\n * A custom matcher predicate: given a candidate widget's normalized text content and the widget\n * itself, returns whether it matches.\n */\ntype MatcherFunction = (content: string, widget: Gtk.Widget) => boolean;\n/** A value used to match widget text: a string or number, a regular expression, or a custom {@link MatcherFunction}. */\ntype Matcher = string | number | RegExp | MatcherFunction;\n/** Normalizes a widget's text before it is compared against a matcher. */\ntype NormalizerFn = (text: string) => string;\n/**\n * A widget class usable as a query's `as` constraint, such as `Gtk.Button`. Abstract classes and\n * generated GInterface pseudo-classes are accepted.\n */\ntype WidgetType<T extends Gtk.Widget = Gtk.Widget> = abstract new (...args: never[]) => T;\n\n/** Options controlling the default text normalizer. */\ntype NormalizerOptions = {\n /** Trim leading and trailing whitespace. */\n trim?: boolean | undefined;\n /** Collapse runs of whitespace into a single space. */\n collapseWhitespace?: boolean | undefined;\n};\n\n/** Options controlling how asynchronous queries and waits poll for a condition. */\ntype WaitForOptions = {\n /** Maximum time in milliseconds to keep retrying before failing. */\n timeout?: number | undefined;\n /** Delay in milliseconds between retries. */\n interval?: number | undefined;\n /** Transforms the error thrown when the timeout elapses. */\n onTimeout?: ((error: Error) => Error) | undefined;\n /** Error whose stack trace attributes the timeout failure to the calling code. */\n stackTraceError?: Error | undefined;\n};\n\n/** Options controlling text matching and, for asynchronous queries, polling behavior. */\ntype MatcherOptions<T extends Gtk.Widget = Gtk.Widget> = {\n /** When true (the default), require an exact match; when false, match case-insensitively as a substring. */\n exact?: boolean | undefined;\n /** Custom normalizer replacing the default; cannot be combined with `trim` or `collapseWhitespace`. */\n normalizer?: NormalizerFn | undefined;\n /** Forwarded to the default normalizer when no custom `normalizer` is given. */\n trim?: boolean | undefined;\n /** Forwarded to the default normalizer when no custom `normalizer` is given. */\n collapseWhitespace?: boolean | undefined;\n /** Whether to include a suggested better query in error messages. */\n suggest?: boolean | undefined;\n /** Restricts matches to instances of this widget class, and narrows the query's return type to it. */\n as?: WidgetType<T> | undefined;\n} & WaitForOptions;\n\n/**\n * Constraints on a widget's numeric range value used by role queries. The numbers come from the\n * accessibility tree and match within 0.001, the resolution GTK keeps them to.\n */\ntype ByRoleValue = {\n /** The current value. */\n now?: number | undefined;\n /** The lower bound of the value's range. */\n min?: number | undefined;\n /**\n * The highest value the widget can reach, which on a paged widget such as a scrollbar is its\n * adjustment's upper bound less one page.\n */\n max?: number | undefined;\n /** Matcher for the value's textual representation. */\n text?: Matcher | undefined;\n};\n\n/** Options for role queries: an accessible name matcher plus accessible state and value constraints. */\ntype ByRoleOptions<T extends Gtk.Widget = Gtk.Widget> = MatcherOptions<T> & {\n /** Matcher for the widget's accessible name. */\n name?: Matcher | undefined;\n /** Required checked state; a mixed check button reads as neither, so it matches neither value. */\n checked?: boolean | undefined;\n /** Required active state of a toggle button; any other widget matches neither value. */\n pressed?: boolean | undefined;\n /** Required selected state of a row, list item, grid cell, option or tree item. */\n selected?: boolean | undefined;\n /** Required expanded state of an expander or tree expander. */\n expanded?: boolean | undefined;\n /** Heading or hierarchy level. */\n level?: number | undefined;\n /** Required busy state, which an unset state satisfies as false. */\n busy?: boolean | undefined;\n /** Matcher for the widget's own accessible description, ignoring its `described-by` targets. */\n description?: Matcher | undefined;\n /** Constraints on the widget's range value, each checked only when given. */\n value?: ByRoleValue | undefined;\n /** When true, include widgets excluded from the accessibility tree. Widgets that are not mapped stay excluded. */\n hidden?: boolean | undefined;\n};\n\n/** A React component that wraps rendered content, receiving it as its children. */\ntype WrapperComponent = ComponentType<{\n children: ReactNode;\n}>;\n\n/** A custom query, taking the scope to search as its first argument and its matcher arguments after it. */\ntype Query = (container: Container, ...args: never[]) => unknown;\n/** Custom queries keyed by the name each is bound under. */\ntype QueryMap = Record<string, Query>;\n\n/** A query with its container argument already applied. */\ntype BoundQuery<Q extends Query> = Q extends (container: Container, ...args: infer A) => infer R\n ? (...args: A) => R\n : never;\n\n/** Custom queries with their container argument already applied, keyed as they were passed in. */\ntype BoundCustomQueries<Q extends QueryMap> = { [K in keyof Q]: BoundQuery<Q[K]> };\n\n/** What each variant of a query family yields for the widget type it matched. */\ntype QueryFamilyReturns<T extends Gtk.Widget> = {\n /** The single match, or null when nothing matched; throws when more than one matched. */\n queryBy: T | null;\n /** Every match, empty when nothing matched. */\n queryAllBy: T[];\n /** The single match; throws when nothing or more than one matched. */\n getBy: T;\n /** Every match; throws when nothing matched. */\n getAllBy: T[];\n /** The single match, retried until it appears or the timeout elapses. */\n findBy: Promise<T>;\n /** Every match, retried until at least one appears or the timeout elapses. */\n findAllBy: Promise<T[]>;\n};\n\n/** What a query family matches against, which fixes the arguments it takes. */\ntype QueryKind = \"role\" | \"text\" | \"name\" | \"value\";\n\n/** The arguments a query of the given kind takes after the family's leading ones. */\ntype QueryArgs<Kind extends QueryKind, T extends Gtk.Widget> = Kind extends \"role\"\n ? [role: Gtk.AccessibleRole, options?: ByRoleOptions<T>]\n : Kind extends \"name\"\n ? [name: Matcher, options?: MatcherOptions<T>]\n : Kind extends \"value\"\n ? [value: Matcher, options?: MatcherOptions<T>]\n : [text: Matcher, options?: MatcherOptions<T>];\n\n/**\n * One family's query variants, each named for its variant followed by `Suffix` and taking `Head`\n * ahead of the family's own arguments.\n */\ntype QueryFamily<Suffix extends string, Kind extends QueryKind, Head extends unknown[]> = {\n [K in keyof QueryFamilyReturns<Gtk.Widget> as `${K & string}${Suffix}`]: <T extends Gtk.Widget = Gtk.Widget>(\n ...args: [...Head, ...QueryArgs<Kind, T>]\n ) => QueryFamilyReturns<T>[K];\n};\n\n/**\n * Every built-in query, spanning the Role, LabelText, Text, Name, PlaceholderText, and DisplayValue\n * families, with `Head` prepended to each signature.\n */\ntype QueryFamilies<Head extends unknown[]> = QueryFamily<\"Role\", \"role\", Head> &\n QueryFamily<\"LabelText\", \"text\", Head> &\n QueryFamily<\"Text\", \"text\", Head> &\n QueryFamily<\"Name\", \"name\", Head> &\n QueryFamily<\"PlaceholderText\", \"text\", Head> &\n QueryFamily<\"DisplayValue\", \"value\", Head>;\n\n/**\n * Options for {@link render}: the container and base element to mount into, an optional wrapper,\n * React behavior toggles, error callbacks, and custom queries to bind.\n */\ntype RenderOptions<Q extends QueryMap = Record<never, never>> = {\n /**\n * Widget or root element to mount into; an undecorated harness window is created when omitted.\n * A widget container that sits outside every toplevel, such as a bare `Gtk.Box`, keeps the tree\n * out of reach of a pointer and a keyboard, so every `userEvent` helper aimed at it rejects\n * after `actionabilityTimeout`; `fireEvent` drives such a tree instead.\n */\n container?: Gtk.Widget | RootElement | undefined;\n /** Root of the subtree that bound queries search. */\n baseElement?: Container | undefined;\n /** Component wrapped around the rendered element, such as a context provider. */\n wrapper?: WrapperComponent | undefined;\n /** Render inside React StrictMode. */\n isReactStrictMode?: boolean | undefined;\n /** Enable widget animations during the test. */\n areAnimationsEnabled?: boolean | undefined;\n /** Called for errors caught by React error boundaries. */\n onCaughtError?: ((error: unknown, errorInfo: ErrorInfo) => void) | undefined;\n /** Called for errors React recovered from automatically. */\n onRecoverableError?: ((error: unknown, errorInfo: ErrorInfo) => void) | undefined;\n /** Custom queries to bind to the rendered result. */\n queries?: Q | undefined;\n};\n\n/** Console helpers bundled with the bound queries on {@link screen} and on a render result. */\ntype DebugUtilities = {\n /** Prints the widget tree of the given containers, or of the whole scope, to the console. */\n debug: (element?: Container | Container[], options?: PrettyWidgetOptions) => void;\n /** Prints the accessible roles found in the scope, with the widgets carrying each one. */\n logRoles: () => void;\n /**\n * Captures what is on screen, which is the active toplevel window: GTK4 exposes no position for\n * a toplevel, so windows cannot be composited into a single image.\n */\n screenshot: (options?: ScreenshotOptions) => Promise<ScreenshotResult>;\n};\n\n/** A captured screenshot: base64-encoded image data, its MIME type, and pixel dimensions. */\ntype ScreenshotResult = {\n /** Base64-encoded image bytes. */\n data: string;\n /** MIME type of the encoded image, always `image/png`. */\n mimeType: string;\n /** Image width in pixels, after the scale factor is applied. */\n width: number;\n /** Image height in pixels, after the scale factor is applied. */\n height: number;\n};\n\n/**\n * Options for capturing a screenshot: the poll timeout and interval, a rendering scale factor, and\n * a file to write the PNG to.\n */\ntype ScreenshotOptions = Pick<WaitForOptions, \"timeout\" | \"interval\"> & {\n /** Device scale factor applied when rendering. */\n scale?: number | undefined;\n /** File the PNG is written to, with its parent directories created as needed. */\n path?: string | undefined;\n};\n\n/**\n * Options for {@link renderHook}: an optional wrapper and the initial props (required unless the\n * props type permits undefined).\n */\ntype RenderHookOptions<Props> = {\n /** Component wrapped around the one calling the hook, such as a context provider. */\n wrapper?: WrapperComponent;\n} & (undefined extends Props\n ? {\n /** Props the hook is invoked with until `rerender` is given new ones. */\n initialProps?: Props;\n }\n : {\n initialProps: Props;\n });\n\n/**\n * The result of {@link renderHook}: the latest hook return value plus functions to rerender with new\n * props and to unmount.\n */\ntype RenderHookResult<Result, Props> = {\n /** Stable object the hook's return value is written to on every render. */\n result: {\n /** The hook's latest return value. */\n current: Result;\n };\n /** Re-invokes the hook, keeping the previous props when none are given. */\n rerender: (newProps?: Props) => Promise<void>;\n /** Unmounts the component that calls the hook. */\n unmount: () => Promise<void>;\n};\n\nexport {\n type MatcherFunction,\n type Matcher,\n type NormalizerFn,\n type NormalizerOptions,\n type WaitForOptions,\n type MatcherOptions,\n type ByRoleValue,\n type ByRoleOptions,\n type WidgetType,\n type WrapperComponent,\n type QueryMap,\n type BoundCustomQueries,\n type QueryFamilies,\n type RenderOptions,\n type DebugUtilities,\n type ScreenshotResult,\n type ScreenshotOptions,\n type RenderHookOptions,\n type RenderHookResult,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA0QA,OAAO,EAoBN,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { RootElement } from \"@gtkx/react\";\nimport type { ComponentType, ErrorInfo, ReactNode } from \"react\";\nimport type { PrettyWidgetOptions } from \"./pretty-widget.js\";\nimport type { Container } from \"./traversal.js\";\n\n/**\n * A custom matcher predicate: given a candidate widget's normalized text content and the widget\n * itself, returns whether it matches.\n */\ntype MatcherFunction = (content: string, widget: Gtk.Widget) => boolean;\n/** A value used to match widget text: a string or number, a regular expression, or a custom {@link MatcherFunction}. */\ntype Matcher = string | number | RegExp | MatcherFunction;\n/** Normalizes a widget's text before it is compared against a matcher. */\ntype NormalizerFn = (text: string) => string;\n/**\n * A widget class usable as a query's `as` constraint, such as `Gtk.Button`. Abstract classes and\n * generated GInterface pseudo-classes that extend `Gtk.Accessible` are accepted.\n */\ntype WidgetType<T extends Gtk.Accessible = Gtk.Accessible> = abstract new (\n ...args: never[]\n) => T;\n\n/** Options controlling the default text normalizer. */\ntype NormalizerOptions = {\n /** Trim leading and trailing whitespace. */\n trim?: boolean | undefined;\n /** Collapse runs of whitespace into a single space. */\n collapseWhitespace?: boolean | undefined;\n};\n\n/** Options controlling how asynchronous queries and waits poll for a condition. */\ntype WaitForOptions = {\n /** Maximum time in milliseconds to keep retrying before failing. */\n timeout?: number | undefined;\n /** Delay in milliseconds between retries. */\n interval?: number | undefined;\n /** Transforms the error thrown when the timeout elapses. */\n onTimeout?: ((error: Error) => Error) | undefined;\n /** Error whose stack trace attributes the timeout failure to the calling code. */\n stackTraceError?: Error | undefined;\n};\n\n/** Options controlling text matching and, for asynchronous queries, polling behavior. */\ntype MatcherOptions<T extends Gtk.Accessible = Gtk.Accessible> = {\n /** When true (the default), require an exact match; when false, match case-insensitively as a substring. */\n exact?: boolean | undefined;\n /** Custom normalizer replacing the default; cannot be combined with `trim` or `collapseWhitespace`. */\n normalizer?: NormalizerFn | undefined;\n /** Forwarded to the default normalizer when no custom `normalizer` is given. */\n trim?: boolean | undefined;\n /** Forwarded to the default normalizer when no custom `normalizer` is given. */\n collapseWhitespace?: boolean | undefined;\n /** Whether to include a suggested better query in error messages. */\n suggest?: boolean | undefined;\n /** Restricts matches to instances of this widget class, and narrows the query's return type to it. */\n as?: WidgetType<T> | undefined;\n} & WaitForOptions;\n\n/**\n * Constraints on a widget's numeric range value used by role queries. The numbers come from the\n * accessibility tree and match within 0.001, the resolution GTK keeps them to.\n */\ntype ByRoleValue = {\n /** The current value. */\n now?: number | undefined;\n /** The lower bound of the value's range. */\n min?: number | undefined;\n /**\n * The highest value the widget can reach, which on a paged widget such as a scrollbar is its\n * adjustment's upper bound less one page.\n */\n max?: number | undefined;\n /** Matcher for the value's textual representation. */\n text?: Matcher | undefined;\n};\n\n/** Options for role queries: an accessible name matcher plus accessible state and value constraints. */\ntype ByRoleOptions<T extends Gtk.Accessible = Gtk.Accessible> = MatcherOptions<T> & {\n /** Matcher for the widget's accessible name. */\n name?: Matcher | undefined;\n /** Required checked state; a mixed check button reads as neither, so it matches neither value. */\n checked?: boolean | undefined;\n /** Required active state of a toggle button; any other widget matches neither value. */\n pressed?: boolean | undefined;\n /** Required selected state of a row, list item, grid cell, option or tree item. */\n selected?: boolean | undefined;\n /** Required expanded state of an expander or tree expander. */\n expanded?: boolean | undefined;\n /** Heading or hierarchy level. */\n level?: number | undefined;\n /** Required busy state, which an unset state satisfies as false. */\n busy?: boolean | undefined;\n /** Matcher for the widget's own accessible description, ignoring its `described-by` targets. */\n description?: Matcher | undefined;\n /** Constraints on the widget's range value, each checked only when given. */\n value?: ByRoleValue | undefined;\n /** When true, include widgets excluded from the accessibility tree. Widgets that are not mapped stay excluded. */\n hidden?: boolean | undefined;\n};\n\n/** A React component that wraps rendered content, receiving it as its children. */\ntype WrapperComponent = ComponentType<{\n children: ReactNode;\n}>;\n\n/** A custom query, taking the scope to search as its first argument and its matcher arguments after it. */\ntype Query = (container: Container, ...args: never[]) => unknown;\n/** Custom queries keyed by the name each is bound under. */\ntype QueryMap = Record<string, Query>;\n\n/** A query with its container argument already applied. */\ntype BoundQuery<Q extends Query> = Q extends (container: Container, ...args: infer A) => infer R\n ? (...args: A) => R\n : never;\n\n/** Custom queries with their container argument already applied, keyed as they were passed in. */\ntype BoundCustomQueries<Q extends QueryMap> = { [K in keyof Q]: BoundQuery<Q[K]> };\n\n/** What each variant of a query family yields for the widget type it matched. */\ntype QueryFamilyReturns<T extends Gtk.Accessible> = {\n /** The single match, or null when nothing matched; throws when more than one matched. */\n queryBy: T | null;\n /** Every match, empty when nothing matched. */\n queryAllBy: T[];\n /** The single match; throws when nothing or more than one matched. */\n getBy: T;\n /** Every match; throws when nothing matched. */\n getAllBy: T[];\n /** The single match, retried until it appears or the timeout elapses. */\n findBy: Promise<T>;\n /** Every match, retried until at least one appears or the timeout elapses. */\n findAllBy: Promise<T[]>;\n};\n\n/** What a query family matches against, which fixes the arguments it takes. */\ntype QueryKind = \"role\" | \"text\" | \"name\" | \"value\";\n\n/** The arguments a query of the given kind takes after the family's leading ones. */\ntype QueryArgs<Kind extends QueryKind, T extends Gtk.Accessible> = Kind extends \"role\"\n ? [role: Gtk.AccessibleRole, options?: ByRoleOptions<T>]\n : Kind extends \"name\"\n ? [name: Matcher, options?: MatcherOptions<T>]\n : Kind extends \"value\"\n ? [value: Matcher, options?: MatcherOptions<T>]\n : [text: Matcher, options?: MatcherOptions<T>];\n\n/**\n * One family's query variants, each named for its variant followed by `Suffix` and taking `Head`\n * ahead of the family's own arguments.\n */\ntype QueryFamily<Suffix extends string, Kind extends QueryKind, Head extends unknown[]> = {\n [K in keyof QueryFamilyReturns<Gtk.Widget> as `${K & string}${Suffix}`]: <\n T extends Gtk.Accessible = Gtk.Widget,\n >(\n ...args: [...Head, ...QueryArgs<Kind, T>]\n ) => QueryFamilyReturns<T>[K];\n};\n\n/**\n * Every built-in query, spanning the Role, LabelText, Text, Name, PlaceholderText, and DisplayValue\n * families, with `Head` prepended to each signature.\n */\ntype QueryFamilies<Head extends unknown[]> = QueryFamily<\"Role\", \"role\", Head> &\n QueryFamily<\"LabelText\", \"text\", Head> &\n QueryFamily<\"Text\", \"text\", Head> &\n QueryFamily<\"Name\", \"name\", Head> &\n QueryFamily<\"PlaceholderText\", \"text\", Head> &\n QueryFamily<\"DisplayValue\", \"value\", Head>;\n\n/**\n * Options for {@link render}: the container and base element to mount into, an optional wrapper,\n * React behavior toggles, error callbacks, and custom queries to bind.\n */\ntype RenderOptions<Q extends QueryMap = Record<never, never>> = {\n /**\n * Widget or root element to mount into; an undecorated harness window is created when omitted.\n * A widget container that sits outside every toplevel, such as a bare `Gtk.Box`, keeps the tree\n * out of reach of a pointer and a keyboard, so every `userEvent` helper aimed at it rejects\n * after `actionabilityTimeout`; `fireEvent` drives such a tree instead.\n */\n container?: Gtk.Accessible | RootElement | undefined;\n /** Root of the subtree that bound queries search. */\n baseElement?: Container | undefined;\n /** Component wrapped around the rendered element, such as a context provider. */\n wrapper?: WrapperComponent | undefined;\n /** Render inside React StrictMode. */\n isReactStrictMode?: boolean | undefined;\n /** Enable widget animations during the test. */\n areAnimationsEnabled?: boolean | undefined;\n /** Called for errors caught by React error boundaries. */\n onCaughtError?: ((error: unknown, errorInfo: ErrorInfo) => void) | undefined;\n /** Called for errors React recovered from automatically. */\n onRecoverableError?: ((error: unknown, errorInfo: ErrorInfo) => void) | undefined;\n /** Custom queries to bind to the rendered result. */\n queries?: Q | undefined;\n};\n\n/** Console helpers bundled with the bound queries on {@link screen} and on a render result. */\ntype DebugUtilities = {\n /** Prints the widget tree of the given containers, or of the whole scope, to the console. */\n debug: (element?: Container | Container[], options?: PrettyWidgetOptions) => void;\n /** Prints the accessible roles found in the scope, with the widgets carrying each one. */\n logRoles: () => void;\n /**\n * Captures what is on screen, which is the active toplevel window: GTK4 exposes no position for\n * a toplevel, so windows cannot be composited into a single image.\n */\n screenshot: (options?: ScreenshotOptions) => Promise<ScreenshotResult>;\n};\n\n/** A captured screenshot: base64-encoded image data, its MIME type, and pixel dimensions. */\ntype ScreenshotResult = {\n /** Base64-encoded image bytes. */\n data: string;\n /** MIME type of the encoded image, always `image/png`. */\n mimeType: string;\n /** Image width in pixels, after the scale factor is applied. */\n width: number;\n /** Image height in pixels, after the scale factor is applied. */\n height: number;\n};\n\n/**\n * Options for capturing a screenshot: the poll timeout and interval, a rendering scale factor, and\n * a file to write the PNG to.\n */\ntype ScreenshotOptions = Pick<WaitForOptions, \"timeout\" | \"interval\"> & {\n /** Device scale factor applied when rendering. */\n scale?: number | undefined;\n /** File the PNG is written to, with its parent directories created as needed. */\n path?: string | undefined;\n};\n\n/**\n * Options for {@link renderHook}: an optional wrapper and the initial props (required unless the\n * props type permits undefined).\n */\ntype RenderHookOptions<Props> = {\n /** Component wrapped around the one calling the hook, such as a context provider. */\n wrapper?: WrapperComponent;\n} & (undefined extends Props\n ? {\n /** Props the hook is invoked with until `rerender` is given new ones. */\n initialProps?: Props;\n }\n : {\n initialProps: Props;\n });\n\n/**\n * The result of {@link renderHook}: the latest hook return value plus functions to rerender with new\n * props and to unmount.\n */\ntype RenderHookResult<Result, Props> = {\n /** Stable object the hook's return value is written to on every render. */\n result: {\n /** The hook's latest return value. */\n current: Result;\n };\n /** Re-invokes the hook, keeping the previous props when none are given. */\n rerender: (newProps?: Props) => Promise<void>;\n /** Unmounts the component that calls the hook. */\n unmount: () => Promise<void>;\n};\n\nexport {\n type MatcherFunction,\n type Matcher,\n type NormalizerFn,\n type NormalizerOptions,\n type WaitForOptions,\n type MatcherOptions,\n type ByRoleValue,\n type ByRoleOptions,\n type WidgetType,\n type WrapperComponent,\n type QueryMap,\n type BoundCustomQueries,\n type QueryFamilies,\n type RenderOptions,\n type DebugUtilities,\n type ScreenshotResult,\n type ScreenshotOptions,\n type RenderHookOptions,\n type RenderHookResult,\n};\n"]}
|
|
@@ -8,7 +8,7 @@ type ControllerConstructor<T extends Gtk.EventController> = new () => T;
|
|
|
8
8
|
* @param controllerType The controller class to match.
|
|
9
9
|
* @returns The matching controllers, or an empty array when the widget has none.
|
|
10
10
|
*/
|
|
11
|
-
declare const queryAllControllers: <T extends Gtk.EventController>(
|
|
11
|
+
declare const queryAllControllers: <T extends Gtk.EventController>(target: Gtk.Accessible, controllerType: ControllerConstructor<T>) => T[];
|
|
12
12
|
/**
|
|
13
13
|
* Returns the first controller of the given type attached to a widget.
|
|
14
14
|
*
|
|
@@ -16,7 +16,7 @@ declare const queryAllControllers: <T extends Gtk.EventController>(widget: Gtk.W
|
|
|
16
16
|
* @param controllerType The controller class to match.
|
|
17
17
|
* @returns The first matching controller, or null when the widget has none.
|
|
18
18
|
*/
|
|
19
|
-
declare const queryController: <T extends Gtk.EventController>(widget: Gtk.
|
|
19
|
+
declare const queryController: <T extends Gtk.EventController>(widget: Gtk.Accessible, controllerType: ControllerConstructor<T>) => T | null;
|
|
20
20
|
/**
|
|
21
21
|
* Returns every controller of the given type attached to a widget.
|
|
22
22
|
*
|
|
@@ -24,7 +24,7 @@ declare const queryController: <T extends Gtk.EventController>(widget: Gtk.Widge
|
|
|
24
24
|
* @param controllerType The controller class to match.
|
|
25
25
|
* @throws When the widget has no controller of that type.
|
|
26
26
|
*/
|
|
27
|
-
declare const getAllControllers: <T extends Gtk.EventController>(widget: Gtk.
|
|
27
|
+
declare const getAllControllers: <T extends Gtk.EventController>(widget: Gtk.Accessible, controllerType: ControllerConstructor<T>) => T[];
|
|
28
28
|
/**
|
|
29
29
|
* Returns the first controller of the given type attached to a widget.
|
|
30
30
|
*
|
|
@@ -32,7 +32,7 @@ declare const getAllControllers: <T extends Gtk.EventController>(widget: Gtk.Wid
|
|
|
32
32
|
* @param controllerType The controller class to match.
|
|
33
33
|
* @throws When the widget has no controller of that type.
|
|
34
34
|
*/
|
|
35
|
-
declare const getController: <T extends Gtk.EventController>(widget: Gtk.
|
|
36
|
-
declare const getOrCreateControllers: <T extends Gtk.EventController>(
|
|
35
|
+
declare const getController: <T extends Gtk.EventController>(widget: Gtk.Accessible, controllerType: ControllerConstructor<T>) => T;
|
|
36
|
+
declare const getOrCreateControllers: <T extends Gtk.EventController>(target: Gtk.Accessible, controllerType: ControllerConstructor<T>) => T[];
|
|
37
37
|
export { queryAllControllers, queryController, getAllControllers, getController, getOrCreateControllers, type ControllerConstructor, };
|
|
38
38
|
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/user-event/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,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,3 +1,4 @@
|
|
|
1
|
+
import { requireWidget } from "../widget-target.js";
|
|
1
2
|
/**
|
|
2
3
|
* Returns every controller of the given type attached to a widget, in the order GTK4 reports them.
|
|
3
4
|
*
|
|
@@ -5,7 +6,8 @@
|
|
|
5
6
|
* @param controllerType The controller class to match.
|
|
6
7
|
* @returns The matching controllers, or an empty array when the widget has none.
|
|
7
8
|
*/
|
|
8
|
-
const queryAllControllers = (
|
|
9
|
+
const queryAllControllers = (target, controllerType) => {
|
|
10
|
+
const widget = requireWidget(target);
|
|
9
11
|
const controllers = widget.observeControllers();
|
|
10
12
|
const nItems = controllers.getNItems();
|
|
11
13
|
const matches = [];
|
|
@@ -53,7 +55,8 @@ const getController = (widget, controllerType) => {
|
|
|
53
55
|
}
|
|
54
56
|
return controller;
|
|
55
57
|
};
|
|
56
|
-
const getOrCreateControllers = (
|
|
58
|
+
const getOrCreateControllers = (target, controllerType) => {
|
|
59
|
+
const widget = requireWidget(target);
|
|
57
60
|
const existing = queryAllControllers(widget, controllerType);
|
|
58
61
|
if (existing.length > 0) {
|
|
59
62
|
return existing;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../src/user-event/controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../src/user-event/controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKpD;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,CACxB,MAAsB,EACtB,cAAwC,EACrC,EAAE;IACL,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,WAAW,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC;IAChD,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,EAAE,CAAC;IACvC,MAAM,OAAO,GAAQ,EAAE,CAAC;IAExB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE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AQ,GAAG,mBAAmB,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAE7D,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,cAAc,EAAE,CAAC;IACxC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAEjC,OAAO,CAAC,UAAU,CAAC,CAAC;AACxB,CAAC,CAAC;AAEF,OAAO,EACH,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,sBAAsB,GAEzB,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { requireWidget } from \"../widget-target.js\";\n\n/** An event controller class that can be constructed without arguments, such as `Gtk.GestureClick`. */\ntype ControllerConstructor<T extends Gtk.EventController> = new () => T;\n\n/**\n * Returns every controller of the given type attached to a widget, in the order GTK4 reports them.\n *\n * @param widget The widget whose controllers are inspected.\n * @param controllerType The controller class to match.\n * @returns The matching controllers, or an empty array when the widget has none.\n */\nconst queryAllControllers = <T extends Gtk.EventController>(\n target: Gtk.Accessible,\n controllerType: ControllerConstructor<T>,\n): T[] => {\n const widget = requireWidget(target);\n const controllers = widget.observeControllers();\n const nItems = controllers.getNItems();\n const matches: T[] = [];\n\n for (let i = 0; i < nItems; i++) {\n const controller = controllers.getItem(i);\n\n if (controller instanceof controllerType) {\n matches.push(controller);\n }\n }\n\n return matches;\n};\n\n/**\n * Returns the first controller of the given type attached to a widget.\n *\n * @param widget The widget whose controllers are inspected.\n * @param controllerType The controller class to match.\n * @returns The first matching controller, or null when the widget has none.\n */\nconst queryController = <T extends Gtk.EventController>(\n widget: Gtk.Accessible,\n controllerType: ControllerConstructor<T>,\n): T | null => queryAllControllers(widget, controllerType)[0] ?? null;\n\n/**\n * Returns every controller of the given type attached to a widget.\n *\n * @param widget The widget whose controllers are inspected.\n * @param controllerType The controller class to match.\n * @throws When the widget has no controller of that type.\n */\nconst getAllControllers = <T extends Gtk.EventController>(\n widget: Gtk.Accessible,\n controllerType: ControllerConstructor<T>,\n): T[] => {\n const controllers = queryAllControllers(widget, controllerType);\n\n if (controllers.length === 0) {\n throw new Error(`No ${controllerType.name} controller is attached to the widget`);\n }\n\n return controllers;\n};\n\n/**\n * Returns the first controller of the given type attached to a widget.\n *\n * @param widget The widget whose controllers are inspected.\n * @param controllerType The controller class to match.\n * @throws When the widget has no controller of that type.\n */\nconst getController = <T extends Gtk.EventController>(\n widget: Gtk.Accessible,\n controllerType: ControllerConstructor<T>,\n): T => {\n const [controller] = getAllControllers(widget, controllerType);\n\n if (controller === undefined) {\n throw new Error(`No ${controllerType.name} controller is attached to the widget`);\n }\n\n return controller;\n};\n\nconst getOrCreateControllers = <T extends Gtk.EventController>(\n target: Gtk.Accessible,\n controllerType: ControllerConstructor<T>,\n): T[] => {\n const widget = requireWidget(target);\n const existing = queryAllControllers(widget, controllerType);\n\n if (existing.length > 0) {\n return existing;\n }\n\n const controller = new controllerType();\n widget.addController(controller);\n\n return [controller];\n};\n\nexport {\n queryAllControllers,\n queryController,\n getAllControllers,\n getController,\n getOrCreateControllers,\n type ControllerConstructor,\n};\n"]}
|
|
@@ -16,53 +16,53 @@ type UserEvent = {
|
|
|
16
16
|
/** Creates an instance with shared keyboard and pointer state. */
|
|
17
17
|
setup: (options?: UserEventOptions) => UserEvent;
|
|
18
18
|
/** Activates or presses and releases a widget. */
|
|
19
|
-
click: typeof click
|
|
19
|
+
click: (widget: Gtk.Accessible, ...args: Parameters<typeof click> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
20
20
|
/** Delivers a double-click gesture. */
|
|
21
|
-
dblClick: typeof dblClick
|
|
21
|
+
dblClick: (widget: Gtk.Accessible, ...args: Parameters<typeof dblClick> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
22
22
|
/** Delivers a triple-click gesture. */
|
|
23
|
-
tripleClick: typeof tripleClick
|
|
23
|
+
tripleClick: (widget: Gtk.Accessible, ...args: Parameters<typeof tripleClick> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
24
24
|
/** Moves focus forward or backward within the root. */
|
|
25
|
-
tab: typeof tab
|
|
25
|
+
tab: (widget: Gtk.Accessible, ...args: Parameters<typeof tab> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
26
26
|
/** Types into an editable widget. */
|
|
27
|
-
type: typeof type
|
|
27
|
+
type: (widget: Gtk.Accessible, ...args: Parameters<typeof type> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
28
28
|
/** Deletes all text from an editable widget. */
|
|
29
|
-
clear: typeof clear
|
|
29
|
+
clear: (widget: Gtk.Accessible, ...args: Parameters<typeof clear> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
30
30
|
/** Copies the current selection. */
|
|
31
|
-
copy: typeof copy
|
|
31
|
+
copy: (widget: Gtk.Accessible, ...args: Parameters<typeof copy> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
32
32
|
/** Cuts the current selection. */
|
|
33
|
-
cut: typeof cut
|
|
33
|
+
cut: (widget: Gtk.Accessible, ...args: Parameters<typeof cut> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
34
34
|
/** Pastes text or clipboard contents. */
|
|
35
|
-
paste: typeof paste
|
|
35
|
+
paste: (widget: Gtk.Accessible, ...args: Parameters<typeof paste> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
36
36
|
/** Selects positions without activating them. */
|
|
37
37
|
selectOptions: typeof selectOptions;
|
|
38
38
|
/** Unselects positions without activating them. */
|
|
39
39
|
deselectOptions: typeof deselectOptions;
|
|
40
40
|
/** Emits a motion `enter` on the widget, adding a motion controller when it has none. */
|
|
41
|
-
hover: typeof hover
|
|
41
|
+
hover: (widget: Gtk.Accessible, ...args: Parameters<typeof hover> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
42
42
|
/** Emits a motion `leave` on the widget, adding a motion controller when it has none. */
|
|
43
|
-
unhover: typeof unhover
|
|
43
|
+
unhover: (widget: Gtk.Accessible, ...args: Parameters<typeof unhover> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
44
44
|
/** Emits `angle-changed` on the widget's rotate gestures. */
|
|
45
|
-
rotate: typeof rotate
|
|
45
|
+
rotate: (widget: Gtk.Accessible, ...args: Parameters<typeof rotate> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
46
46
|
/** Emits `scale-changed` on the widget's zoom gestures. */
|
|
47
|
-
zoom: typeof zoom
|
|
47
|
+
zoom: (widget: Gtk.Accessible, ...args: Parameters<typeof zoom> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
48
48
|
/** Emits `swipe` with the given velocity on the widget's swipe gestures. */
|
|
49
|
-
swipe: typeof swipe
|
|
49
|
+
swipe: (widget: Gtk.Accessible, ...args: Parameters<typeof swipe> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
50
50
|
/** Emits `pressed` at the given point on the widget's long-press gestures. */
|
|
51
|
-
longPress: typeof longPress
|
|
51
|
+
longPress: (widget: Gtk.Accessible, ...args: Parameters<typeof longPress> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
52
52
|
/** Runs a begin, update, and end sequence on the widget's drag gestures, ending at the given offset. */
|
|
53
|
-
drag: typeof drag
|
|
53
|
+
drag: (widget: Gtk.Accessible, ...args: Parameters<typeof drag> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
54
54
|
/** Emits `drop` with the given content on the widget's drop targets. */
|
|
55
|
-
drop: typeof drop
|
|
55
|
+
drop: (widget: Gtk.Accessible, ...args: Parameters<typeof drop> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
56
56
|
/** Requires a drag source on the source widget, then emits `drop` with the content on the target's drop targets. */
|
|
57
|
-
dragAndDrop: typeof dragAndDrop
|
|
57
|
+
dragAndDrop: (source: Gtk.Accessible, target: Gtk.Accessible, ...args: Parameters<typeof dragAndDrop> extends [Gtk.Widget, Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
58
58
|
/** Emits a jump `change-value` on a Gtk.Range so it moves to the given value. */
|
|
59
|
-
slide: typeof slide
|
|
59
|
+
slide: (widget: Gtk.Accessible, ...args: Parameters<typeof slide> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
60
60
|
/** Adds the delta to the adjustments of the widget itself, or of its nearest scrollable ancestor. */
|
|
61
|
-
scroll: typeof scroll
|
|
61
|
+
scroll: (widget: Gtk.Accessible, ...args: Parameters<typeof scroll> extends [Gtk.Widget, ...infer Args] ? Args : never) => Promise<void>;
|
|
62
62
|
/** Sends a key sequence through GTK's propagation chain. */
|
|
63
|
-
keyboard: (widget: Gtk.
|
|
63
|
+
keyboard: (widget: Gtk.Accessible, input: string) => Promise<void>;
|
|
64
64
|
/** Applies a pointer token while preserving held-button state. */
|
|
65
|
-
pointer: (widget: Gtk.
|
|
65
|
+
pointer: (widget: Gtk.Accessible, input: PointerInput) => Promise<void>;
|
|
66
66
|
};
|
|
67
67
|
/** User interactions that dispatch GTK events and gestures. */
|
|
68
68
|
declare const userEvent: UserEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/user-event/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/user-event/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAA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AAU,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,CAAC"}
|
package/dist/user-event/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { delay } from "../timers.js";
|
|
2
|
+
import { requireWidget } from "../widget-target.js";
|
|
2
3
|
import { scroll, slide } from "./adjustment.js";
|
|
3
4
|
import { click, dblClick, tripleClick } from "./click.js";
|
|
4
|
-
import { drag, dragAndDrop, drop, hover, longPress, rotate, swipe, unhover, zoom } from "./gesture.js";
|
|
5
|
+
import { drag, dragAndDrop, drop, hover, longPress, rotate, swipe, unhover, zoom, } from "./gesture.js";
|
|
5
6
|
import { keyboard, tab } from "./keyboard.js";
|
|
6
7
|
import { pointer } from "./pointer.js";
|
|
7
8
|
import { deselectOptions, selectOptions } from "./selection.js";
|
|
8
9
|
import { createInitialState } from "./state.js";
|
|
9
10
|
import { clear, copy, cut, paste, type } from "./text.js";
|
|
11
|
+
const onWidget = (helper) => (target, ...args) => helper(requireWidget(target), ...args);
|
|
12
|
+
const onWidgetPair = (helper) => (source, target, ...args) => helper(requireWidget(source), requireWidget(target), ...args);
|
|
10
13
|
/** User interactions that dispatch GTK events and gestures. */
|
|
11
14
|
const userEvent = {
|
|
12
15
|
...createInstance(createInitialState(), {}),
|
|
@@ -25,30 +28,30 @@ function createInstance(state, options) {
|
|
|
25
28
|
};
|
|
26
29
|
return {
|
|
27
30
|
setup: (overrides) => createInstance(state, { ...options, ...overrides }),
|
|
28
|
-
click: after(click),
|
|
29
|
-
dblClick: after(dblClick),
|
|
30
|
-
tripleClick: after(tripleClick),
|
|
31
|
-
tab: after(tab),
|
|
32
|
-
type: after(type),
|
|
33
|
-
clear: after(clear),
|
|
34
|
-
copy: after(copy),
|
|
35
|
-
cut: after(cut),
|
|
36
|
-
paste: after(paste),
|
|
37
|
-
selectOptions: after(selectOptions),
|
|
38
|
-
deselectOptions: after(deselectOptions),
|
|
39
|
-
hover: after(hover),
|
|
40
|
-
unhover: after(unhover),
|
|
41
|
-
rotate: after(rotate),
|
|
42
|
-
zoom: after(zoom),
|
|
43
|
-
swipe: after(swipe),
|
|
44
|
-
longPress: after(longPress),
|
|
45
|
-
drag: after(drag),
|
|
46
|
-
drop: after(drop),
|
|
47
|
-
dragAndDrop: after(dragAndDrop),
|
|
48
|
-
slide: after(slide),
|
|
49
|
-
scroll: after(scroll),
|
|
50
|
-
keyboard: after((widget, input) => keyboard(state, widget, input)),
|
|
51
|
-
pointer: after((widget, input) => pointer(state, widget, input)),
|
|
31
|
+
click: after(onWidget(click)),
|
|
32
|
+
dblClick: after(onWidget(dblClick)),
|
|
33
|
+
tripleClick: after(onWidget(tripleClick)),
|
|
34
|
+
tab: after(onWidget(tab)),
|
|
35
|
+
type: after(onWidget(type)),
|
|
36
|
+
clear: after(onWidget(clear)),
|
|
37
|
+
copy: after(onWidget(copy)),
|
|
38
|
+
cut: after(onWidget(cut)),
|
|
39
|
+
paste: after(onWidget(paste)),
|
|
40
|
+
selectOptions: after(onWidget(selectOptions)),
|
|
41
|
+
deselectOptions: after(onWidget(deselectOptions)),
|
|
42
|
+
hover: after(onWidget(hover)),
|
|
43
|
+
unhover: after(onWidget(unhover)),
|
|
44
|
+
rotate: after(onWidget(rotate)),
|
|
45
|
+
zoom: after(onWidget(zoom)),
|
|
46
|
+
swipe: after(onWidget(swipe)),
|
|
47
|
+
longPress: after(onWidget(longPress)),
|
|
48
|
+
drag: after(onWidget(drag)),
|
|
49
|
+
drop: after(onWidget(drop)),
|
|
50
|
+
dragAndDrop: after(onWidgetPair(dragAndDrop)),
|
|
51
|
+
slide: after(onWidget(slide)),
|
|
52
|
+
scroll: after(onWidget(scroll)),
|
|
53
|
+
keyboard: after(onWidget((widget, input) => keyboard(state, widget, input))),
|
|
54
|
+
pointer: after(onWidget((widget, input) => pointer(state, widget, input))),
|
|
52
55
|
};
|
|
53
56
|
}
|
|
54
57
|
export { resetClipboard } from "./text.js";
|