@gtkx/testing 0.21.0 → 1.0.0-rc.2

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.
Files changed (216) hide show
  1. package/README.md +137 -34
  2. package/dist/act.d.ts +19 -0
  3. package/dist/act.d.ts.map +1 -0
  4. package/dist/act.js +56 -0
  5. package/dist/act.js.map +1 -0
  6. package/dist/bound-queries.d.ts +33 -0
  7. package/dist/bound-queries.d.ts.map +1 -0
  8. package/dist/bound-queries.js +2 -0
  9. package/dist/bound-queries.js.map +1 -0
  10. package/dist/build-queries.d.ts +16 -0
  11. package/dist/build-queries.d.ts.map +1 -0
  12. package/dist/build-queries.js +115 -0
  13. package/dist/build-queries.js.map +1 -0
  14. package/dist/cleanup-registry.d.ts +5 -0
  15. package/dist/cleanup-registry.d.ts.map +1 -0
  16. package/dist/cleanup-registry.js +21 -0
  17. package/dist/cleanup-registry.js.map +1 -0
  18. package/dist/config.d.ts +20 -52
  19. package/dist/config.d.ts.map +1 -1
  20. package/dist/config.js +17 -46
  21. package/dist/config.js.map +1 -1
  22. package/dist/editable.d.ts +8 -0
  23. package/dist/editable.d.ts.map +1 -0
  24. package/dist/editable.js +26 -0
  25. package/dist/editable.js.map +1 -0
  26. package/dist/errors.d.ts +30 -0
  27. package/dist/errors.d.ts.map +1 -0
  28. package/dist/errors.js +135 -0
  29. package/dist/errors.js.map +1 -0
  30. package/dist/fire-event.d.ts +8 -25
  31. package/dist/fire-event.d.ts.map +1 -1
  32. package/dist/fire-event.js +11 -30
  33. package/dist/fire-event.js.map +1 -1
  34. package/dist/frame-sync.d.ts +4 -0
  35. package/dist/frame-sync.d.ts.map +1 -0
  36. package/dist/frame-sync.js +37 -0
  37. package/dist/frame-sync.js.map +1 -0
  38. package/dist/index.d.ts +17 -12
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +11 -7
  41. package/dist/index.js.map +1 -1
  42. package/dist/matchers.d.ts +59 -0
  43. package/dist/matchers.d.ts.map +1 -0
  44. package/dist/matchers.js +117 -0
  45. package/dist/matchers.js.map +1 -0
  46. package/dist/pretty-widget.d.ts +24 -26
  47. package/dist/pretty-widget.d.ts.map +1 -1
  48. package/dist/pretty-widget.js +111 -117
  49. package/dist/pretty-widget.js.map +1 -1
  50. package/dist/queries.d.ts +190 -180
  51. package/dist/queries.d.ts.map +1 -1
  52. package/dist/queries.js +291 -320
  53. package/dist/queries.js.map +1 -1
  54. package/dist/register-test-hooks.d.ts +2 -0
  55. package/dist/register-test-hooks.d.ts.map +1 -0
  56. package/dist/register-test-hooks.js +16 -0
  57. package/dist/register-test-hooks.js.map +1 -0
  58. package/dist/render-hook.d.ts +15 -35
  59. package/dist/render-hook.d.ts.map +1 -1
  60. package/dist/render-hook.js +9 -45
  61. package/dist/render-hook.js.map +1 -1
  62. package/dist/render.d.ts +13 -42
  63. package/dist/render.d.ts.map +1 -1
  64. package/dist/render.js +138 -121
  65. package/dist/render.js.map +1 -1
  66. package/dist/role-helpers.d.ts +19 -53
  67. package/dist/role-helpers.d.ts.map +1 -1
  68. package/dist/role-helpers.js +48 -63
  69. package/dist/role-helpers.js.map +1 -1
  70. package/dist/screen.d.ts +7 -63
  71. package/dist/screen.d.ts.map +1 -1
  72. package/dist/screen.js +24 -110
  73. package/dist/screen.js.map +1 -1
  74. package/dist/screenshot.d.ts +21 -23
  75. package/dist/screenshot.d.ts.map +1 -1
  76. package/dist/screenshot.js +98 -50
  77. package/dist/screenshot.js.map +1 -1
  78. package/dist/suggestions.d.ts +27 -0
  79. package/dist/suggestions.d.ts.map +1 -0
  80. package/dist/suggestions.js +61 -0
  81. package/dist/suggestions.js.map +1 -0
  82. package/dist/traversal.d.ts +12 -10
  83. package/dist/traversal.d.ts.map +1 -1
  84. package/dist/traversal.js +36 -15
  85. package/dist/traversal.js.map +1 -1
  86. package/dist/types.d.ts +115 -169
  87. package/dist/types.d.ts.map +1 -1
  88. package/dist/types.js.map +1 -1
  89. package/dist/user-event/adjustment.d.ts +10 -0
  90. package/dist/user-event/adjustment.d.ts.map +1 -0
  91. package/dist/user-event/adjustment.js +35 -0
  92. package/dist/user-event/adjustment.js.map +1 -0
  93. package/dist/user-event/click.d.ts +8 -0
  94. package/dist/user-event/click.d.ts.map +1 -0
  95. package/dist/user-event/click.js +73 -0
  96. package/dist/user-event/click.js.map +1 -0
  97. package/dist/user-event/controller.d.ts +8 -0
  98. package/dist/user-event/controller.d.ts.map +1 -0
  99. package/dist/user-event/controller.js +31 -0
  100. package/dist/user-event/controller.js.map +1 -0
  101. package/dist/user-event/dispatch.d.ts +7 -0
  102. package/dist/user-event/dispatch.d.ts.map +1 -0
  103. package/dist/user-event/dispatch.js +11 -0
  104. package/dist/user-event/dispatch.js.map +1 -0
  105. package/dist/user-event/event-wrapper.d.ts +4 -0
  106. package/dist/user-event/event-wrapper.d.ts.map +1 -0
  107. package/dist/user-event/event-wrapper.js +59 -0
  108. package/dist/user-event/event-wrapper.js.map +1 -0
  109. package/dist/user-event/gesture.d.ts +35 -0
  110. package/dist/user-event/gesture.d.ts.map +1 -0
  111. package/dist/user-event/gesture.js +138 -0
  112. package/dist/user-event/gesture.js.map +1 -0
  113. package/dist/user-event/index.d.ts +51 -0
  114. package/dist/user-event/index.d.ts.map +1 -0
  115. package/dist/user-event/index.js +42 -0
  116. package/dist/user-event/index.js.map +1 -0
  117. package/dist/user-event/keyboard.d.ts +10 -0
  118. package/dist/user-event/keyboard.d.ts.map +1 -0
  119. package/dist/user-event/keyboard.js +204 -0
  120. package/dist/user-event/keyboard.js.map +1 -0
  121. package/dist/user-event/pointer.d.ts +10 -0
  122. package/dist/user-event/pointer.d.ts.map +1 -0
  123. package/dist/user-event/pointer.js +30 -0
  124. package/dist/user-event/pointer.js.map +1 -0
  125. package/dist/user-event/selection.d.ts +5 -0
  126. package/dist/user-event/selection.d.ts.map +1 -0
  127. package/dist/user-event/selection.js +105 -0
  128. package/dist/user-event/selection.js.map +1 -0
  129. package/dist/user-event/state.d.ts +7 -0
  130. package/dist/user-event/state.d.ts.map +1 -0
  131. package/dist/user-event/state.js +3 -0
  132. package/dist/user-event/state.js.map +1 -0
  133. package/dist/user-event/text.d.ts +18 -0
  134. package/dist/user-event/text.d.ts.map +1 -0
  135. package/dist/user-event/text.js +113 -0
  136. package/dist/user-event/text.js.map +1 -0
  137. package/dist/wait-for.d.ts +16 -36
  138. package/dist/wait-for.d.ts.map +1 -1
  139. package/dist/wait-for.js +74 -70
  140. package/dist/wait-for.js.map +1 -1
  141. package/dist/widget-accessible-properties.d.ts +34 -0
  142. package/dist/widget-accessible-properties.d.ts.map +1 -0
  143. package/dist/widget-accessible-properties.js +260 -0
  144. package/dist/widget-accessible-properties.js.map +1 -0
  145. package/dist/within.d.ts +10 -26
  146. package/dist/within.d.ts.map +1 -1
  147. package/dist/within.js +16 -25
  148. package/dist/within.js.map +1 -1
  149. package/package.json +23 -12
  150. package/src/act.ts +77 -0
  151. package/src/bound-queries.ts +37 -0
  152. package/src/build-queries.ts +226 -0
  153. package/src/cleanup-registry.ts +27 -0
  154. package/src/config.ts +35 -62
  155. package/src/editable.ts +37 -0
  156. package/src/errors.ts +191 -0
  157. package/src/fire-event.ts +13 -38
  158. package/src/frame-sync.ts +51 -0
  159. package/src/index.ts +58 -15
  160. package/src/matchers.ts +251 -0
  161. package/src/pretty-widget.ts +163 -130
  162. package/src/queries.ts +485 -396
  163. package/src/register-test-hooks.ts +19 -0
  164. package/src/render-hook.tsx +38 -45
  165. package/src/render.tsx +192 -155
  166. package/src/role-helpers.ts +65 -72
  167. package/src/screen.ts +26 -114
  168. package/src/screenshot.ts +128 -56
  169. package/src/suggestions.ts +106 -0
  170. package/src/traversal.ts +56 -22
  171. package/src/types.ts +144 -172
  172. package/src/user-event/adjustment.ts +62 -0
  173. package/src/user-event/click.ts +99 -0
  174. package/src/user-event/controller.ts +58 -0
  175. package/src/user-event/dispatch.ts +25 -0
  176. package/src/user-event/event-wrapper.ts +80 -0
  177. package/src/user-event/gesture.ts +239 -0
  178. package/src/user-event/index.ts +81 -0
  179. package/src/user-event/keyboard.ts +290 -0
  180. package/src/user-event/pointer.ts +46 -0
  181. package/src/user-event/selection.ts +159 -0
  182. package/src/user-event/state.ts +8 -0
  183. package/src/user-event/text.ts +172 -0
  184. package/src/wait-for.ts +117 -78
  185. package/src/widget-accessible-properties.ts +388 -0
  186. package/src/within.ts +29 -27
  187. package/dist/bind-queries.d.ts +0 -14
  188. package/dist/bind-queries.d.ts.map +0 -1
  189. package/dist/bind-queries.js +0 -29
  190. package/dist/bind-queries.js.map +0 -1
  191. package/dist/error-builder.d.ts +0 -28
  192. package/dist/error-builder.d.ts.map +0 -1
  193. package/dist/error-builder.js +0 -81
  194. package/dist/error-builder.js.map +0 -1
  195. package/dist/timing.d.ts +0 -18
  196. package/dist/timing.d.ts.map +0 -1
  197. package/dist/timing.js +0 -18
  198. package/dist/timing.js.map +0 -1
  199. package/dist/user-event.d.ts +0 -138
  200. package/dist/user-event.d.ts.map +0 -1
  201. package/dist/user-event.js +0 -411
  202. package/dist/user-event.js.map +0 -1
  203. package/dist/widget-text.d.ts +0 -69
  204. package/dist/widget-text.d.ts.map +0 -1
  205. package/dist/widget-text.js +0 -177
  206. package/dist/widget-text.js.map +0 -1
  207. package/dist/widget.d.ts +0 -3
  208. package/dist/widget.d.ts.map +0 -1
  209. package/dist/widget.js +0 -13
  210. package/dist/widget.js.map +0 -1
  211. package/src/bind-queries.ts +0 -52
  212. package/src/error-builder.ts +0 -102
  213. package/src/timing.ts +0 -17
  214. package/src/user-event.ts +0 -492
  215. package/src/widget-text.ts +0 -202
  216. package/src/widget.ts +0 -15
@@ -1,13 +1,15 @@
1
- import * as Gtk from "@gtkx/ffi/gtk";
1
+ import * as Gtk from "@gtkx/gi/gtk";
2
+ type QueryContainer = Gtk.Widget | Gtk.EventController | Gtk.LayoutManager | Gtk.ListItem | Gtk.ListHeader;
2
3
  /**
3
- * Root element for scoping queries.
4
- *
5
- * When a `Gtk.Application` is provided, queries search across all toplevel
6
- * windows. When a `Gtk.Widget` is provided, queries are scoped to that
7
- * widget's subtree.
4
+ * A scope that queries and traversal can run against: a widget, an event
5
+ * controller, a layout manager, a list item or header, an application, or the
6
+ * sentinel representing all current toplevel windows.
8
7
  */
9
- export type Container = Gtk.Application | Gtk.Widget;
10
- export declare const isApplication: (container: Container) => container is Gtk.Application;
11
- export declare const traverse: (container: Container) => Generator<Gtk.Widget>;
12
- export declare const findAll: (container: Container, predicate: (node: Gtk.Widget) => boolean) => Gtk.Widget[];
8
+ type Container = QueryContainer | Gtk.Application | typeof TOPLEVELS;
9
+ declare const TOPLEVELS: unique symbol;
10
+ declare const descendants: (widget: Gtk.Widget) => Generator<Gtk.Widget>;
11
+ declare const roots: (container: Container) => Generator<Gtk.Widget>;
12
+ declare const traverse: (container: Container) => Generator<Gtk.Widget>;
13
+ declare const findAll: (container: Container, isMatch: (node: Gtk.Widget) => boolean) => Gtk.Widget[];
14
+ export { TOPLEVELS, descendants, roots, traverse, findAll, type Container };
13
15
  //# sourceMappingURL=traversal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"traversal.d.ts","sourceRoot":"","sources":["../src/traversal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AAErC;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC;AAErD,eAAO,MAAM,aAAa,GAAI,WAAW,SAAS,KAAG,SAAS,IAAI,GAAG,CAAC,WACK,CAAC;AAmB5E,eAAO,MAAM,QAAQ,GAAc,WAAW,SAAS,KAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAM7E,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,WAAW,SAAS,EAAE,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,KAAK,OAAO,KAAG,GAAG,CAAC,MAAM,EASlG,CAAC"}
1
+ {"version":3,"file":"traversal.d.ts","sourceRoot":"","sources":["../src/traversal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,KAAK,cAAc,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,eAAe,GAAG,GAAG,CAAC,aAAa,GAAG,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAC;AAC3G;;;;GAIG;AACH,KAAK,SAAS,GAAG,cAAc,GAAG,GAAG,CAAC,WAAW,GAAG,OAAO,SAAS,CAAC;AAErE,QAAA,MAAM,SAAS,EAAE,OAAO,MAAiC,CAAC;AAc1D,QAAA,MAAM,WAAW,GAAc,QAAQ,GAAG,CAAC,MAAM,KAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAIvE,CAAC;AAsBF,QAAA,MAAM,KAAK,GAAc,WAAW,SAAS,KAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAYnE,CAAC;AAEF,QAAA,MAAM,QAAQ,GAAc,WAAW,SAAS,KAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAItE,CAAC;AAEF,QAAA,MAAM,OAAO,GAAI,WAAW,SAAS,EAAE,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,KAAK,OAAO,KAAG,GAAG,CAAC,MAAM,EAUzF,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,SAAS,EAAE,CAAC"}
package/dist/traversal.js CHANGED
@@ -1,5 +1,6 @@
1
- import * as Gtk from "@gtkx/ffi/gtk";
2
- export const isApplication = (container) => "getWindows" in container && typeof container.getWindows === "function";
1
+ import * as Gtk from "@gtkx/gi/gtk";
2
+ const TOPLEVELS = Symbol("gtkx.toplevels");
3
+ const isApplication = (container) => container instanceof Gtk.Application;
3
4
  const traverseWidgetTree = function* (root) {
4
5
  yield root;
5
6
  let child = root.getFirstChild();
@@ -8,29 +9,49 @@ const traverseWidgetTree = function* (root) {
8
9
  child = child.getNextSibling();
9
10
  }
10
11
  };
11
- const traverseWindows = function* () {
12
- const windows = Gtk.Window.listToplevels();
13
- for (const window of windows) {
14
- yield* traverseWidgetTree(window);
12
+ const descendants = function* (widget) {
13
+ const tree = traverseWidgetTree(widget);
14
+ tree.next();
15
+ yield* tree;
16
+ };
17
+ const resolveRoot = (container) => {
18
+ if (container instanceof Gtk.Widget) {
19
+ return container;
20
+ }
21
+ if (container instanceof Gtk.EventController) {
22
+ return container.getWidget();
23
+ }
24
+ if (container instanceof Gtk.LayoutManager) {
25
+ return container.getWidget();
15
26
  }
27
+ if (container instanceof Gtk.ListItem || container instanceof Gtk.ListHeader) {
28
+ return container.getChild();
29
+ }
30
+ return null;
16
31
  };
17
- export const traverse = function* (container) {
18
- if (isApplication(container)) {
19
- yield* traverseWindows();
32
+ const roots = function* (container) {
33
+ if (container === TOPLEVELS || isApplication(container)) {
34
+ yield* Gtk.Window.listToplevels();
35
+ return;
36
+ }
37
+ const root = resolveRoot(container);
38
+ if (root) {
39
+ yield root;
20
40
  }
21
- else {
22
- yield* traverseWidgetTree(container);
41
+ };
42
+ const traverse = function* (container) {
43
+ for (const root of roots(container)) {
44
+ yield* traverseWidgetTree(root);
23
45
  }
24
46
  };
25
- export const findAll = (container, predicate) => {
47
+ const findAll = (container, isMatch) => {
26
48
  const results = [];
27
49
  for (const node of traverse(container)) {
28
- if (node.getAccessibleRole?.() === Gtk.AccessibleRole.LABEL)
29
- continue;
30
- if (predicate(node)) {
50
+ if (isMatch(node)) {
31
51
  results.push(node);
32
52
  }
33
53
  }
34
54
  return results;
35
55
  };
56
+ export { TOPLEVELS, descendants, roots, traverse, findAll };
36
57
  //# sourceMappingURL=traversal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"traversal.js","sourceRoot":"","sources":["../src/traversal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AAWrC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAoB,EAAgC,EAAE,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\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;\n\nconst TOPLEVELS: unique symbol = Symbol(\"gtkx.toplevels\");\n\nconst isApplication = (container: Container): container is Gtk.Application => container instanceof Gtk.Application;\n\nconst traverseWidgetTree = function* (root: Gtk.Widget): Generator<Gtk.Widget> {\n yield root;\n let child = root.getFirstChild();\n\n while (child) {\n yield* traverseWidgetTree(child);\n child = child.getNextSibling();\n }\n};\n\nconst descendants = function* (widget: Gtk.Widget): Generator<Gtk.Widget> {\n const tree = traverseWidgetTree(widget);\n tree.next();\n yield* tree;\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 return null;\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);\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 { TOPLEVELS, descendants, roots, traverse, findAll, type Container };\n"]}
package/dist/types.d.ts CHANGED
@@ -1,200 +1,146 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import type { ComponentType, ReactNode, Ref } from "react";
1
+ import type * as Gtk from "@gtkx/gi/gtk";
2
+ import type { RootElement } from "@gtkx/react";
3
+ import type { ComponentType, ErrorInfo, ReactNode } from "react";
4
+ import type { PrettyWidgetOptions } from "./pretty-widget.js";
3
5
  import type { Container } from "./traversal.js";
4
6
  /**
5
- * Custom function for matching text content.
6
- *
7
- * @param content - The normalized text content to match against
8
- * @param widget - The widget being tested
9
- * @returns `true` if the content matches
7
+ * A custom matcher predicate: given a candidate widget's normalized text content and the widget
8
+ * itself, returns whether it matches.
10
9
  */
11
- export type TextMatchFunction = (content: string, widget: Gtk.Widget) => boolean;
12
- /**
13
- * Text matching pattern.
14
- *
15
- * Can be a string for exact/substring matching, a RegExp for pattern matching,
16
- * or a custom function for advanced matching logic.
17
- */
18
- export type TextMatch = string | RegExp | TextMatchFunction;
19
- /**
20
- * Options for text normalization before matching.
21
- */
22
- export type NormalizerOptions = {
23
- /** Remove leading/trailing whitespace (default: true) */
24
- trim?: boolean;
25
- /** Replace multiple whitespace characters with single space (default: true) */
26
- collapseWhitespace?: boolean;
10
+ type MatcherFunction = (content: string, widget: Gtk.Widget) => boolean;
11
+ /** A value used to match widget text: a string or number, a regular expression, or a custom {@link MatcherFunction}. */
12
+ type Matcher = string | number | RegExp | MatcherFunction;
13
+ /** Normalizes a widget's text before it is compared against a matcher. */
14
+ type NormalizerFn = (text: string) => string;
15
+ /** Options controlling the default text normalizer. */
16
+ type NormalizerOptions = {
17
+ /** Trim leading and trailing whitespace. */
18
+ trim?: boolean | undefined;
19
+ /** Collapse runs of whitespace into a single space. */
20
+ collapseWhitespace?: boolean | undefined;
27
21
  };
28
- /**
29
- * Options for text-based queries.
30
- */
31
- export type TextMatchOptions = {
32
- /** Require exact match vs substring match (default: true) */
33
- exact?: boolean;
34
- /** Custom text normalizer function */
35
- normalizer?: (text: string) => string;
36
- /** Remove leading/trailing whitespace (default: true) */
37
- trim?: boolean;
38
- /** Replace multiple whitespace with single space (default: true) */
39
- collapseWhitespace?: boolean;
40
- /** Timeout in milliseconds for async queries (default: 1000) */
41
- timeout?: number;
22
+ /** Options controlling how asynchronous queries and waits poll for a condition. */
23
+ type WaitForOptions = {
24
+ /** Maximum time in milliseconds to keep retrying before failing. */
25
+ timeout?: number | undefined;
26
+ /** Delay in milliseconds between retries. */
27
+ interval?: number | undefined;
28
+ /** Transforms the error thrown when the timeout elapses. */
29
+ onTimeout?: ((error: Error) => Error) | undefined;
30
+ /** Error whose stack trace attributes the timeout failure to the calling code. */
31
+ stackTraceError?: Error | undefined;
42
32
  };
43
- /**
44
- * Options for role-based queries.
45
- *
46
- * Extends text matching options with accessible state filters.
47
- */
48
- export type ByRoleOptions = TextMatchOptions & {
49
- /** Filter by accessible name/label */
50
- name?: TextMatch;
51
- /** Filter by checked state (checkboxes, radios, toggles) */
52
- checked?: boolean;
53
- /** Filter by pressed state */
54
- pressed?: boolean;
55
- /** Filter by selected state */
56
- selected?: boolean;
57
- /** Filter by expanded state (expanders) */
58
- expanded?: boolean;
59
- /** Filter by heading level */
60
- level?: number;
33
+ /** Options controlling text matching and, for asynchronous queries, polling behavior. */
34
+ type MatcherOptions = {
35
+ /** When true (the default), require an exact match; when false, match case-insensitively as a substring. */
36
+ exact?: boolean | undefined;
37
+ /** Custom normalizer replacing the default; cannot be combined with `trim` or `collapseWhitespace`. */
38
+ normalizer?: NormalizerFn | undefined;
39
+ /** Forwarded to the default normalizer when no custom `normalizer` is given. */
40
+ trim?: boolean | undefined;
41
+ /** Forwarded to the default normalizer when no custom `normalizer` is given. */
42
+ collapseWhitespace?: boolean | undefined;
43
+ /** Whether to include a suggested better query in error messages. */
44
+ suggest?: boolean | undefined;
45
+ } & WaitForOptions;
46
+ /** Constraints on a widget's numeric range value used by role queries. */
47
+ type ByRoleValue = {
48
+ /** The current value. */
49
+ now?: number | undefined;
50
+ min?: number | undefined;
51
+ max?: number | undefined;
52
+ /** Matcher for the value's textual representation. */
53
+ text?: Matcher | undefined;
61
54
  };
62
- /**
63
- * Options for {@link waitFor} and {@link waitForElementToBeRemoved}.
64
- */
65
- export type WaitForOptions = {
66
- /** Maximum time to wait in milliseconds (default: 1000) */
67
- timeout?: number;
68
- /** Polling interval in milliseconds (default: 50) */
69
- interval?: number;
70
- /** Custom error handler called on timeout */
71
- onTimeout?: (error: Error) => Error;
55
+ /** Options for role queries: an accessible name matcher plus accessible state and value constraints. */
56
+ type ByRoleOptions = MatcherOptions & {
57
+ name?: Matcher | undefined;
58
+ checked?: boolean | undefined;
59
+ pressed?: boolean | undefined;
60
+ selected?: boolean | undefined;
61
+ expanded?: boolean | undefined;
62
+ /** Heading or hierarchy level. */
63
+ level?: number | undefined;
64
+ busy?: boolean | undefined;
65
+ description?: Matcher | undefined;
66
+ value?: ByRoleValue | undefined;
67
+ /** When true, include widgets excluded from the accessibility tree. */
68
+ hidden?: boolean | undefined;
72
69
  };
73
- /**
74
- * A wrapper component that exposes its root GTK widget via `ref`.
75
- * Accept `ref` as a prop and pass it through to the root intrinsic element.
76
- */
77
- export type WrapperComponent = ComponentType<{
70
+ /** A React component that wraps rendered content, receiving it as its children. */
71
+ type WrapperComponent = ComponentType<{
78
72
  children: ReactNode;
79
- ref?: Ref<Gtk.Widget>;
80
73
  }>;
81
- /**
82
- * Options for {@link render}.
83
- */
84
- export type RenderOptions = {
85
- /**
86
- * Wrapper component or boolean.
87
- * - `true` (default): Wrap in GtkApplicationWindow
88
- * - `false`: No wrapper
89
- * - Component: Custom wrapper that passes `ref` to its root element
90
- */
91
- wrapper?: boolean | WrapperComponent;
92
- /**
93
- * The element queries are bound to.
94
- * Defaults to the GTK Application (searches all toplevel windows).
95
- * Provide a specific widget or application to scope queries.
96
- */
97
- baseElement?: Container;
74
+ type Query = (container: Container, ...args: never[]) => unknown;
75
+ type QueryMap = Record<string, Query>;
76
+ type BoundQuery<Q extends Query> = Q extends (container: Container, ...args: infer A) => infer R ? (...args: A) => R : never;
77
+ type BoundCustomQueries<Q extends QueryMap> = {
78
+ [K in keyof Q]: BoundQuery<Q[K]>;
98
79
  };
99
80
  /**
100
- * Query methods bound to a container.
101
- *
102
- * @see {@link screen} for global queries
103
- * @see {@link within} for scoped queries
81
+ * Options for {@link render}: the container and base element to mount into, an optional wrapper,
82
+ * React behavior toggles, error callbacks, and custom queries to bind.
104
83
  */
105
- export type BoundQueries = {
106
- /** Query single element by accessible role (returns null if not found) */
107
- queryByRole: (role: Gtk.AccessibleRole, options?: ByRoleOptions) => Gtk.Widget | null;
108
- /** Query single element by label/text content (returns null if not found) */
109
- queryByLabelText: (text: TextMatch, options?: TextMatchOptions) => Gtk.Widget | null;
110
- /** Query single element by visible text (returns null if not found) */
111
- queryByText: (text: TextMatch, options?: TextMatchOptions) => Gtk.Widget | null;
112
- /** Query single element by widget name (returns null if not found) */
113
- queryByName: (name: TextMatch, options?: TextMatchOptions) => Gtk.Widget | null;
114
- /** Query all elements by accessible role (returns empty array if none found) */
115
- queryAllByRole: (role: Gtk.AccessibleRole, options?: ByRoleOptions) => Gtk.Widget[];
116
- /** Query all elements by label/text content (returns empty array if none found) */
117
- queryAllByLabelText: (text: TextMatch, options?: TextMatchOptions) => Gtk.Widget[];
118
- /** Query all elements by visible text (returns empty array if none found) */
119
- queryAllByText: (text: TextMatch, options?: TextMatchOptions) => Gtk.Widget[];
120
- /** Query all elements by widget name (returns empty array if none found) */
121
- queryAllByName: (name: TextMatch, options?: TextMatchOptions) => Gtk.Widget[];
122
- /** Find single element by accessible role (waits and throws if not found) */
123
- findByRole: (role: Gtk.AccessibleRole, options?: ByRoleOptions) => Promise<Gtk.Widget>;
124
- /** Find single element by label/text content (waits and throws if not found) */
125
- findByLabelText: (text: TextMatch, options?: TextMatchOptions) => Promise<Gtk.Widget>;
126
- /** Find single element by visible text (waits and throws if not found) */
127
- findByText: (text: TextMatch, options?: TextMatchOptions) => Promise<Gtk.Widget>;
128
- /** Find single element by widget name (waits and throws if not found) */
129
- findByName: (name: TextMatch, options?: TextMatchOptions) => Promise<Gtk.Widget>;
130
- /** Find all elements by accessible role (waits and throws if none found) */
131
- findAllByRole: (role: Gtk.AccessibleRole, options?: ByRoleOptions) => Promise<Gtk.Widget[]>;
132
- /** Find all elements by label/text content (waits and throws if none found) */
133
- findAllByLabelText: (text: TextMatch, options?: TextMatchOptions) => Promise<Gtk.Widget[]>;
134
- /** Find all elements by visible text (waits and throws if none found) */
135
- findAllByText: (text: TextMatch, options?: TextMatchOptions) => Promise<Gtk.Widget[]>;
136
- /** Find all elements by widget name (waits and throws if none found) */
137
- findAllByName: (name: TextMatch, options?: TextMatchOptions) => Promise<Gtk.Widget[]>;
84
+ type RenderOptions<Q extends QueryMap = Record<never, never>> = {
85
+ container?: Gtk.Widget | RootElement | undefined;
86
+ /** Root of the subtree that bound queries search. */
87
+ baseElement?: Container | undefined;
88
+ wrapper?: WrapperComponent | undefined;
89
+ /** Render inside React StrictMode. */
90
+ reactStrictMode?: boolean | undefined;
91
+ /** Enable widget animations during the test. */
92
+ animations?: boolean | undefined;
93
+ /** Called for errors caught by React error boundaries. */
94
+ onCaughtError?: ((error: unknown, errorInfo: ErrorInfo) => void) | undefined;
95
+ /** Called for errors React recovered from automatically. */
96
+ onRecoverableError?: ((error: unknown, errorInfo: ErrorInfo) => void) | undefined;
97
+ /** Custom queries to bind to the rendered result. */
98
+ queries?: Q | undefined;
138
99
  };
139
- /**
140
- * Result returned by {@link render}.
141
- *
142
- * Provides query methods and utilities for testing rendered components.
143
- */
144
- export type RenderResult = BoundQueries & {
145
- /** The direct container widget wrapping the rendered content */
146
- container: Gtk.Widget;
147
- /** The element queries are bound to (defaults to the GTK Application) */
148
- baseElement: Container;
149
- /** Unmount the rendered component */
150
- unmount: () => Promise<void>;
151
- /** Re-render with a new element */
152
- rerender: (element: ReactNode) => Promise<void>;
153
- /** Print the widget tree to console for debugging */
154
- debug: () => void;
100
+ type DebugUtilities = {
101
+ debug: (element?: Container | Container[], options?: PrettyWidgetOptions) => void;
102
+ logRoles: () => void;
103
+ screenshot: (selector?: WindowSelector, options?: ScreenshotOptions) => Promise<ScreenshotResult>;
155
104
  };
156
- /**
157
- * Result returned by {@link screenshot} and screen.screenshot.
158
- */
159
- export type ScreenshotResult = {
160
- /** Base64-encoded PNG image data */
105
+ /** A captured screenshot: base64-encoded image data, its MIME type, and pixel dimensions. */
106
+ type ScreenshotResult = {
161
107
  data: string;
162
- /** MIME type of the image (always "image/png") */
163
108
  mimeType: string;
164
- /** Width of the captured image in pixels */
165
109
  width: number;
166
- /** Height of the captured image in pixels */
167
110
  height: number;
168
111
  };
112
+ /** Options for capturing a screenshot: the poll timeout and interval, plus a rendering scale factor. */
113
+ type ScreenshotOptions = Pick<WaitForOptions, "timeout" | "interval"> & {
114
+ /** Device scale factor applied when rendering. */
115
+ scale?: number;
116
+ };
169
117
  /**
170
- * Options for {@link renderHook}.
118
+ * Selects the window to screenshot by index, or by title (exact string or regular expression);
119
+ * undefined targets the default window.
171
120
  */
172
- export type RenderHookOptions<Props> = {
173
- /**
174
- * Initial props passed to the hook callback.
175
- */
121
+ type WindowSelector = number | string | RegExp | undefined;
122
+ /**
123
+ * Options for {@link renderHook}: an optional wrapper and the initial props (required unless the
124
+ * props type permits undefined).
125
+ */
126
+ type RenderHookOptions<Props> = {
127
+ wrapper?: WrapperComponent;
128
+ } & (undefined extends Props ? {
176
129
  initialProps?: Props;
177
- /**
178
- * Wrapper component or boolean.
179
- * - `true` (default): Wrap in GtkApplicationWindow
180
- * - `false`: No wrapper
181
- * - Component: Custom wrapper that passes `ref` to its root element
182
- */
183
- wrapper?: boolean | WrapperComponent;
184
- };
130
+ } : {
131
+ initialProps: Props;
132
+ });
185
133
  /**
186
- * Result returned by {@link renderHook}.
187
- *
188
- * Provides access to the hook result and utilities for re-rendering and cleanup.
134
+ * The result of {@link renderHook}: the latest hook return value plus functions to rerender with new
135
+ * props and to unmount.
189
136
  */
190
- export type RenderHookResult<Result, Props> = {
191
- /** Object containing the current hook return value */
137
+ type RenderHookResult<Result, Props> = {
138
+ /** Holds the most recent value returned by the hook under `current`. */
192
139
  result: {
193
140
  current: Result;
194
141
  };
195
- /** Re-render the hook with optional new props */
196
142
  rerender: (newProps?: Props) => Promise<void>;
197
- /** Unmount the component containing the hook */
198
143
  unmount: () => Promise<void>;
199
144
  };
145
+ export { type MatcherFunction, type Matcher, type NormalizerFn, type NormalizerOptions, type WaitForOptions, type MatcherOptions, type ByRoleValue, type ByRoleOptions, type WrapperComponent, type QueryMap, type BoundCustomQueries, type RenderOptions, type DebugUtilities, type ScreenshotResult, type ScreenshotOptions, type WindowSelector, type RenderHookOptions, type RenderHookResult, };
200
146
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,KAAK,OAAO,CAAC;AAEjF;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,iBAAiB,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC5B,yDAAyD;IACzD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,+EAA+E;IAC/E,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC3B,6DAA6D;IAC7D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sCAAsC;IACtC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACtC,yDAAyD;IACzD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,oEAAoE;IACpE,kBAAkB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AAgB,GACxB,CAAC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAkKA,OAAO,EAmBN,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/** 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 = {\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} & WaitForOptions;\n\n/** Constraints on a widget's numeric range value used by role queries. */\ntype ByRoleValue = {\n /** The current value. */\n now?: number | undefined;\n min?: number | undefined;\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 = MatcherOptions & {\n name?: Matcher | undefined;\n checked?: boolean | undefined;\n pressed?: boolean | undefined;\n selected?: boolean | undefined;\n expanded?: boolean | undefined;\n /** Heading or hierarchy level. */\n level?: number | undefined;\n busy?: boolean | undefined;\n description?: Matcher | undefined;\n value?: ByRoleValue | undefined;\n /** When true, include widgets excluded from the accessibility tree. */\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\ntype Query = (container: Container, ...args: never[]) => unknown;\ntype QueryMap = Record<string, Query>;\n\ntype BoundQuery<Q extends Query> = Q extends (container: Container, ...args: infer A) => infer R\n ? (...args: A) => R\n : never;\n\ntype BoundCustomQueries<Q extends QueryMap> = { [K in keyof Q]: BoundQuery<Q[K]> };\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 container?: Gtk.Widget | RootElement | undefined;\n /** Root of the subtree that bound queries search. */\n baseElement?: Container | undefined;\n wrapper?: WrapperComponent | undefined;\n /** Render inside React StrictMode. */\n reactStrictMode?: boolean | undefined;\n /** Enable widget animations during the test. */\n animations?: 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\ntype DebugUtilities = {\n debug: (element?: Container | Container[], options?: PrettyWidgetOptions) => void;\n logRoles: () => void;\n screenshot: (selector?: WindowSelector, options?: ScreenshotOptions) => Promise<ScreenshotResult>;\n};\n\n/** A captured screenshot: base64-encoded image data, its MIME type, and pixel dimensions. */\ntype ScreenshotResult = {\n data: string;\n mimeType: string;\n width: number;\n height: number;\n};\n\n/** Options for capturing a screenshot: the poll timeout and interval, plus a rendering scale factor. */\ntype ScreenshotOptions = Pick<WaitForOptions, \"timeout\" | \"interval\"> & {\n /** Device scale factor applied when rendering. */\n scale?: number;\n};\n\n/**\n * Selects the window to screenshot by index, or by title (exact string or regular expression);\n * undefined targets the default window.\n */\ntype WindowSelector = number | string | RegExp | undefined;\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 wrapper?: WrapperComponent;\n} & (undefined extends Props\n ? {\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 /** Holds the most recent value returned by the hook under `current`. */\n result: { current: Result };\n rerender: (newProps?: Props) => Promise<void>;\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 WrapperComponent,\n type QueryMap,\n type BoundCustomQueries,\n type RenderOptions,\n type DebugUtilities,\n type ScreenshotResult,\n type ScreenshotOptions,\n type WindowSelector,\n type RenderHookOptions,\n type RenderHookResult,\n};\n"]}
@@ -0,0 +1,10 @@
1
+ import * as Gtk from "@gtkx/gi/gtk";
2
+ /** A scroll distance in pixels along each axis. */
3
+ type ScrollDelta = {
4
+ x?: number;
5
+ y?: number;
6
+ };
7
+ declare const slide: (widget: Gtk.Widget, value: number) => Promise<void>;
8
+ declare const scroll: (widget: Gtk.Widget, delta: ScrollDelta) => Promise<void>;
9
+ export { slide, scroll, type ScrollDelta };
10
+ //# sourceMappingURL=adjustment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adjustment.d.ts","sourceRoot":"","sources":["../../src/user-event/adjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAGpC,mDAAmD;AACnD,KAAK,WAAW,GAAG;IACf,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAOF,QAAA,MAAM,KAAK,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,OAAO,MAAM,KAAG,OAAO,CAAC,IAAI,CASzD,CAAC;AAwBP,QAAA,MAAM,MAAM,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,OAAO,WAAW,KAAG,OAAO,CAAC,IAAI,CAY/D,CAAC;AAEP,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,CAAC"}
@@ -0,0 +1,35 @@
1
+ import * as Gtk from "@gtkx/gi/gtk";
2
+ import { wrapEvent } from "./event-wrapper.js";
3
+ const slide = (widget, value) => wrapEvent(widget, () => {
4
+ if (!(widget instanceof Gtk.Range)) {
5
+ throw new TypeError(`userEvent.slide requires a Gtk.Range (e.g. Gtk.Scale), got ${widget.constructor.name}`);
6
+ }
7
+ widget.emit("change-value", Gtk.ScrollType.JUMP, value);
8
+ });
9
+ const resolveScrollAdjustments = (widget) => {
10
+ for (let current = widget; current; current = current.getParent()) {
11
+ if (current instanceof Gtk.ScrolledWindow) {
12
+ return { horizontal: current.getHadjustment(), vertical: current.getVadjustment() };
13
+ }
14
+ if (current instanceof Gtk.Scrollable) {
15
+ return { horizontal: current.getHadjustment(), vertical: current.getVadjustment() };
16
+ }
17
+ }
18
+ return null;
19
+ };
20
+ const applyScrollDelta = (adjustment, delta) => {
21
+ if (!adjustment || delta === 0) {
22
+ return;
23
+ }
24
+ adjustment.setValue(adjustment.getValue() + delta);
25
+ };
26
+ const scroll = (widget, delta) => wrapEvent(widget, () => {
27
+ const adjustments = resolveScrollAdjustments(widget);
28
+ if (!adjustments) {
29
+ throw new Error("userEvent.scroll: no Gtk.ScrolledWindow or Gtk.Scrollable found on the widget or its ancestors");
30
+ }
31
+ applyScrollDelta(adjustments.horizontal, delta.x ?? 0);
32
+ applyScrollDelta(adjustments.vertical, delta.y ?? 0);
33
+ });
34
+ export { slide, scroll };
35
+ //# sourceMappingURL=adjustment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adjustment.js","sourceRoot":"","sources":["../../src/user-event/adjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAa/C,MAAM,KAAK,GAAG,CAAC,MAAkB,EAAE,KAAa,EAAiB,EAAE,CAC/D,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE;IACnB,IAAI,CAAC,CAAC,MAAM,YAAY,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,SAAS,CACf,8DAA8D,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAC1F,CAAC;IACN,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC5D,CAAC,CAAC,CAAC;AAEP,MAAM,wBAAwB,GAAG,CAAC,MAAkB,EAA4B,EAAE;IAC9E,KAAK,IAAI,OAAO,GAAsB,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;QACnF,IAAI,OAAO,YAAY,GAAG,CAAC,cAAc,EAAE,CAAC;YACxC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;QACxF,CAAC;QAED,IAAI,OAAO,YAAY,GAAG,CAAC,UAAU,EAAE,CAAC;YACpC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;QACxF,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,UAAiC,EAAE,KAAa,EAAQ,EAAE;IAChF,IAAI,CAAC,UAAU,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO;IACX,CAAC;IAED,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,MAAkB,EAAE,KAAkB,EAAiB,EAAE,CACrE,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE;IACnB,MAAM,WAAW,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAC;IAErD,IAAI,CAAC,WAAW,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACX,gGAAgG,CACnG,CAAC;IACN,CAAC;IAED,gBAAgB,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,gBAAgB,CAAC,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACzD,CAAC,CAAC,CAAC;AAEP,OAAO,EAAE,KAAK,EAAE,MAAM,EAAoB,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { wrapEvent } from \"./event-wrapper.js\";\n\n/** A scroll distance in pixels along each axis. */\ntype ScrollDelta = {\n x?: number;\n y?: number;\n};\n\ntype ScrollAdjustments = {\n horizontal: Gtk.Adjustment | null;\n vertical: Gtk.Adjustment | null;\n};\n\nconst slide = (widget: Gtk.Widget, value: number): Promise<void> =>\n wrapEvent(widget, () => {\n if (!(widget instanceof Gtk.Range)) {\n throw new TypeError(\n `userEvent.slide requires a Gtk.Range (e.g. Gtk.Scale), got ${widget.constructor.name}`,\n );\n }\n\n widget.emit(\"change-value\", Gtk.ScrollType.JUMP, value);\n });\n\nconst resolveScrollAdjustments = (widget: Gtk.Widget): ScrollAdjustments | null => {\n for (let current: Gtk.Widget | null = widget; current; current = current.getParent()) {\n if (current instanceof Gtk.ScrolledWindow) {\n return { horizontal: current.getHadjustment(), vertical: current.getVadjustment() };\n }\n\n if (current instanceof Gtk.Scrollable) {\n return { horizontal: current.getHadjustment(), vertical: current.getVadjustment() };\n }\n }\n\n return null;\n};\n\nconst applyScrollDelta = (adjustment: Gtk.Adjustment | null, delta: number): void => {\n if (!adjustment || delta === 0) {\n return;\n }\n\n adjustment.setValue(adjustment.getValue() + delta);\n};\n\nconst scroll = (widget: Gtk.Widget, delta: ScrollDelta): Promise<void> =>\n wrapEvent(widget, () => {\n const adjustments = resolveScrollAdjustments(widget);\n\n if (!adjustments) {\n throw new Error(\n \"userEvent.scroll: no Gtk.ScrolledWindow or Gtk.Scrollable found on the widget or its ancestors\",\n );\n }\n\n applyScrollDelta(adjustments.horizontal, delta.x ?? 0);\n applyScrollDelta(adjustments.vertical, delta.y ?? 0);\n });\n\nexport { slide, scroll, type ScrollDelta };\n"]}
@@ -0,0 +1,8 @@
1
+ import * as Gtk from "@gtkx/gi/gtk";
2
+ declare const emitPress: (widget: Gtk.Widget, controllers: Gtk.GestureClick[], nPress: number) => void;
3
+ declare const emitRelease: (widget: Gtk.Widget, controllers: Gtk.GestureClick[], nPress: number) => void;
4
+ declare const click: (widget: Gtk.Widget) => Promise<void>;
5
+ declare const dblClick: (widget: Gtk.Widget) => Promise<void>;
6
+ declare const tripleClick: (widget: Gtk.Widget) => Promise<void>;
7
+ export { emitPress, emitRelease, click, dblClick, tripleClick };
8
+ //# sourceMappingURL=click.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAuBpC,QAAA,MAAM,SAAS,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,aAAa,GAAG,CAAC,YAAY,EAAE,EAAE,QAAQ,MAAM,KAAG,IAExF,CAAC;AAEF,QAAA,MAAM,WAAW,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,aAAa,GAAG,CAAC,YAAY,EAAE,EAAE,QAAQ,MAAM,KAAG,IAE1F,CAAC;AAwCF,QAAA,MAAM,KAAK,GAAU,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAwBrD,CAAC;AAEF,QAAA,MAAM,QAAQ,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAAyC,CAAC;AAC7F,QAAA,MAAM,WAAW,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAAyC,CAAC;AAEhG,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC"}