@gtkx/testing 1.0.0-rc.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/README.md +5 -5
  2. package/dist/accessible-native.d.ts +16 -0
  3. package/dist/accessible-native.d.ts.map +1 -0
  4. package/dist/accessible-native.js +206 -0
  5. package/dist/accessible-native.js.map +1 -0
  6. package/dist/act.d.ts +1 -3
  7. package/dist/act.d.ts.map +1 -1
  8. package/dist/act.js +1 -1
  9. package/dist/act.js.map +1 -1
  10. package/dist/build-queries.d.ts +27 -10
  11. package/dist/build-queries.d.ts.map +1 -1
  12. package/dist/build-queries.js +22 -24
  13. package/dist/build-queries.js.map +1 -1
  14. package/dist/cleanup-registry.d.ts +1 -1
  15. package/dist/cleanup-registry.d.ts.map +1 -1
  16. package/dist/cleanup-registry.js.map +1 -1
  17. package/dist/config.d.ts +8 -1
  18. package/dist/config.d.ts.map +1 -1
  19. package/dist/config.js +1 -0
  20. package/dist/config.js.map +1 -1
  21. package/dist/errors.d.ts +10 -1
  22. package/dist/errors.d.ts.map +1 -1
  23. package/dist/errors.js +10 -1
  24. package/dist/errors.js.map +1 -1
  25. package/dist/fire-event.d.ts +35 -6
  26. package/dist/fire-event.d.ts.map +1 -1
  27. package/dist/fire-event.js +23 -7
  28. package/dist/fire-event.js.map +1 -1
  29. package/dist/frame-sync.d.ts +3 -2
  30. package/dist/frame-sync.d.ts.map +1 -1
  31. package/dist/frame-sync.js +19 -9
  32. package/dist/frame-sync.js.map +1 -1
  33. package/dist/harness-window.d.ts +5 -0
  34. package/dist/harness-window.d.ts.map +1 -0
  35. package/dist/harness-window.js +17 -0
  36. package/dist/harness-window.js.map +1 -0
  37. package/dist/index.d.ts +14 -7
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +9 -5
  40. package/dist/index.js.map +1 -1
  41. package/dist/internal.d.ts +5 -0
  42. package/dist/internal.d.ts.map +1 -0
  43. package/dist/internal.js +5 -0
  44. package/dist/internal.js.map +1 -0
  45. package/dist/matchers.d.ts +88 -46
  46. package/dist/matchers.d.ts.map +1 -1
  47. package/dist/matchers.js +178 -20
  48. package/dist/matchers.js.map +1 -1
  49. package/dist/pretty-format.d.ts +2 -0
  50. package/dist/pretty-format.d.ts.map +1 -0
  51. package/dist/pretty-format.js +2 -0
  52. package/dist/pretty-format.js.map +1 -0
  53. package/dist/pretty-widget.d.ts +5 -2
  54. package/dist/pretty-widget.d.ts.map +1 -1
  55. package/dist/pretty-widget.js +75 -57
  56. package/dist/pretty-widget.js.map +1 -1
  57. package/dist/production.d.ts +8 -0
  58. package/dist/production.d.ts.map +1 -0
  59. package/dist/production.js +34 -0
  60. package/dist/production.js.map +1 -0
  61. package/dist/queries.d.ts +98 -56
  62. package/dist/queries.d.ts.map +1 -1
  63. package/dist/queries.js +123 -83
  64. package/dist/queries.js.map +1 -1
  65. package/dist/query-helpers.d.ts +44 -0
  66. package/dist/query-helpers.d.ts.map +1 -0
  67. package/dist/query-helpers.js +57 -0
  68. package/dist/query-helpers.js.map +1 -0
  69. package/dist/render-children.d.ts +9 -0
  70. package/dist/render-children.d.ts.map +1 -0
  71. package/dist/render-children.js +11 -0
  72. package/dist/render-children.js.map +1 -0
  73. package/dist/render.d.ts +12 -1
  74. package/dist/render.d.ts.map +1 -1
  75. package/dist/render.js +52 -16
  76. package/dist/render.js.map +1 -1
  77. package/dist/role-helpers.d.ts +12 -3
  78. package/dist/role-helpers.d.ts.map +1 -1
  79. package/dist/role-helpers.js +15 -5
  80. package/dist/role-helpers.js.map +1 -1
  81. package/dist/role-naming.d.ts +5 -0
  82. package/dist/role-naming.d.ts.map +1 -0
  83. package/dist/role-naming.js +96 -0
  84. package/dist/role-naming.js.map +1 -0
  85. package/dist/screenshot.d.ts +12 -20
  86. package/dist/screenshot.d.ts.map +1 -1
  87. package/dist/screenshot.js +179 -93
  88. package/dist/screenshot.js.map +1 -1
  89. package/dist/timers.d.ts +9 -0
  90. package/dist/timers.d.ts.map +1 -0
  91. package/dist/timers.js +21 -0
  92. package/dist/timers.js.map +1 -0
  93. package/dist/traversal.d.ts +7 -1
  94. package/dist/traversal.d.ts.map +1 -1
  95. package/dist/traversal.js +40 -6
  96. package/dist/traversal.js.map +1 -1
  97. package/dist/types.d.ts +32 -15
  98. package/dist/types.d.ts.map +1 -1
  99. package/dist/types.js.map +1 -1
  100. package/dist/user-event/adjustment.d.ts +3 -0
  101. package/dist/user-event/adjustment.d.ts.map +1 -1
  102. package/dist/user-event/adjustment.js +25 -3
  103. package/dist/user-event/adjustment.js.map +1 -1
  104. package/dist/user-event/click.d.ts +44 -8
  105. package/dist/user-event/click.d.ts.map +1 -1
  106. package/dist/user-event/click.js +176 -44
  107. package/dist/user-event/click.js.map +1 -1
  108. package/dist/user-event/column-header-click.d.ts +4 -0
  109. package/dist/user-event/column-header-click.d.ts.map +1 -0
  110. package/dist/user-event/column-header-click.js +55 -0
  111. package/dist/user-event/column-header-click.js.map +1 -0
  112. package/dist/user-event/event-wrapper.d.ts.map +1 -1
  113. package/dist/user-event/event-wrapper.js +34 -20
  114. package/dist/user-event/event-wrapper.js.map +1 -1
  115. package/dist/user-event/index.d.ts +80 -13
  116. package/dist/user-event/index.d.ts.map +1 -1
  117. package/dist/user-event/index.js +44 -26
  118. package/dist/user-event/index.js.map +1 -1
  119. package/dist/user-event/indexed-children.d.ts +10 -0
  120. package/dist/user-event/indexed-children.d.ts.map +1 -0
  121. package/dist/user-event/indexed-children.js +50 -0
  122. package/dist/user-event/indexed-children.js.map +1 -0
  123. package/dist/user-event/keyboard.d.ts.map +1 -1
  124. package/dist/user-event/keyboard.js +115 -31
  125. package/dist/user-event/keyboard.js.map +1 -1
  126. package/dist/user-event/list-row-click.d.ts +4 -0
  127. package/dist/user-event/list-row-click.d.ts.map +1 -0
  128. package/dist/user-event/list-row-click.js +38 -0
  129. package/dist/user-event/list-row-click.js.map +1 -0
  130. package/dist/user-event/native-click.d.ts +6 -0
  131. package/dist/user-event/native-click.d.ts.map +1 -0
  132. package/dist/user-event/native-click.js +36 -0
  133. package/dist/user-event/native-click.js.map +1 -0
  134. package/dist/user-event/notebook-tab-click.d.ts +5 -0
  135. package/dist/user-event/notebook-tab-click.d.ts.map +1 -0
  136. package/dist/user-event/notebook-tab-click.js +39 -0
  137. package/dist/user-event/notebook-tab-click.js.map +1 -0
  138. package/dist/user-event/pointer.d.ts +1 -1
  139. package/dist/user-event/pointer.d.ts.map +1 -1
  140. package/dist/user-event/pointer.js +33 -9
  141. package/dist/user-event/pointer.js.map +1 -1
  142. package/dist/user-event/selection.d.ts +11 -8
  143. package/dist/user-event/selection.d.ts.map +1 -1
  144. package/dist/user-event/selection.js +49 -38
  145. package/dist/user-event/selection.js.map +1 -1
  146. package/dist/user-event/text.d.ts +12 -5
  147. package/dist/user-event/text.d.ts.map +1 -1
  148. package/dist/user-event/text.js +151 -46
  149. package/dist/user-event/text.js.map +1 -1
  150. package/dist/wait-for.d.ts.map +1 -1
  151. package/dist/wait-for.js +4 -3
  152. package/dist/wait-for.js.map +1 -1
  153. package/dist/widget-accessible-properties.d.ts +14 -26
  154. package/dist/widget-accessible-properties.d.ts.map +1 -1
  155. package/dist/widget-accessible-properties.js +135 -190
  156. package/dist/widget-accessible-properties.js.map +1 -1
  157. package/dist/widget-getters.d.ts +11 -0
  158. package/dist/widget-getters.d.ts.map +1 -0
  159. package/dist/widget-getters.js +46 -0
  160. package/dist/widget-getters.js.map +1 -0
  161. package/dist/window-state.d.ts +10 -0
  162. package/dist/window-state.d.ts.map +1 -0
  163. package/dist/window-state.js +41 -0
  164. package/dist/window-state.js.map +1 -0
  165. package/dist/within.d.ts +3 -2
  166. package/dist/within.d.ts.map +1 -1
  167. package/dist/within.js +3 -2
  168. package/dist/within.js.map +1 -1
  169. package/package.json +21 -8
  170. package/src/accessible-native.ts +333 -0
  171. package/src/act.ts +1 -1
  172. package/src/build-queries.ts +47 -41
  173. package/src/cleanup-registry.ts +1 -1
  174. package/src/config.ts +10 -1
  175. package/src/errors.ts +12 -1
  176. package/src/fire-event.ts +61 -8
  177. package/src/frame-sync.ts +30 -9
  178. package/src/harness-window.ts +23 -0
  179. package/src/index.ts +18 -11
  180. package/src/internal.ts +12 -0
  181. package/src/matchers.ts +457 -72
  182. package/src/pretty-format.ts +1 -0
  183. package/src/pretty-widget.ts +98 -70
  184. package/src/production.ts +51 -0
  185. package/src/queries.ts +127 -89
  186. package/src/query-helpers.ts +97 -0
  187. package/src/render-children.ts +25 -0
  188. package/src/render.tsx +77 -17
  189. package/src/role-helpers.ts +16 -5
  190. package/src/role-naming.ts +99 -0
  191. package/src/screenshot.ts +266 -104
  192. package/src/timers.ts +31 -0
  193. package/src/traversal.ts +66 -6
  194. package/src/types.ts +34 -17
  195. package/src/user-event/adjustment.ts +31 -3
  196. package/src/user-event/click.ts +248 -52
  197. package/src/user-event/column-header-click.ts +76 -0
  198. package/src/user-event/event-wrapper.ts +41 -23
  199. package/src/user-event/index.ts +130 -40
  200. package/src/user-event/indexed-children.ts +75 -0
  201. package/src/user-event/keyboard.ts +161 -43
  202. package/src/user-event/list-row-click.ts +54 -0
  203. package/src/user-event/native-click.ts +51 -0
  204. package/src/user-event/notebook-tab-click.ts +57 -0
  205. package/src/user-event/pointer.ts +48 -9
  206. package/src/user-event/selection.ts +67 -41
  207. package/src/user-event/text.ts +192 -46
  208. package/src/wait-for.ts +4 -4
  209. package/src/widget-accessible-properties.ts +183 -230
  210. package/src/widget-getters.ts +85 -0
  211. package/src/window-state.ts +70 -0
  212. package/src/within.ts +3 -2
package/dist/config.js CHANGED
@@ -3,6 +3,7 @@ const defaultConfig = {
3
3
  getElementError: defaultGetElementError,
4
4
  asyncUtilTimeout: 1000,
5
5
  actionabilityTimeout: 500,
6
+ windowActivationTimeout: 5000,
6
7
  };
7
8
  const currentConfig = { ...defaultConfig };
8
9
  function defaultGetElementError(message) {
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AA2BA,MAAM,aAAa,GAAW;IAC1B,gBAAgB,EAAE,KAAK;IACvB,eAAe,EAAE,sBAAsB;IACvC,gBAAgB,EAAE,IAAI;IACtB,oBAAoB,EAAE,GAAG;CAC5B,CAAC;AAEF,MAAM,aAAa,GAAW,EAAE,GAAG,aAAa,EAAE,CAAC;AAEnD,SAAS,sBAAsB,CAAC,OAAe;IAC3C,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,SAAS,GAAG,GAAW,EAAE;IAC3B,OAAO,aAAa,CAAC;AACzB,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,SAAS,GAAG,CAAC,SAAqC,EAAQ,EAAE;IAC9D,MAAM,OAAO,GAAG,OAAO,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACvF,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,YAAa,SAAQ,KAAK;IACnB,IAAI,GAAG,cAAc,CAAC;CAClC;AAED,OAAO,EAAE,SAAS,EAAE,SAAS,EAA8B,CAAC","sourcesContent":["import type { Container } from \"./traversal.js\";\n\n/**\n * Global configuration for the testing harness, controlling query behavior,\n * error formatting, and the timeouts used by async utilities and actionability\n * checks.\n */\ntype Config = {\n /** Whether a successful query throws instead, naming a better query, when one is available. */\n throwSuggestions: boolean;\n\n /** Builds the error thrown when a query fails, given a message and optional container. */\n getElementError: (message: string, container?: Container) => Error;\n\n /** Default timeout in milliseconds for async utilities such as waitFor. */\n asyncUtilTimeout: number;\n\n /** Timeout in milliseconds for waiting on a widget to become actionable. */\n actionabilityTimeout: number;\n};\n\n/**\n * Function form of a configuration update: receives the current config and\n * returns the fields to override.\n */\ntype ConfigFn = (existingConfig: Config) => Partial<Config>;\n\nconst defaultConfig: Config = {\n throwSuggestions: false,\n getElementError: defaultGetElementError,\n asyncUtilTimeout: 1000,\n actionabilityTimeout: 500,\n};\n\nconst currentConfig: Config = { ...defaultConfig };\n\nfunction defaultGetElementError(message: string): Error {\n return new ElementError(message);\n}\n\n/**\n * Returns the current global testing configuration.\n */\nconst getConfig = (): Config => {\n return currentConfig;\n};\n\n/**\n * Merges the given overrides into the global testing configuration.\n *\n * @param newConfig Either a partial config object or a function that receives\n * the current config and returns the fields to override.\n */\nconst configure = (newConfig: Partial<Config> | ConfigFn): void => {\n const updates = typeof newConfig === \"function\" ? newConfig(currentConfig) : newConfig;\n Object.assign(currentConfig, updates);\n};\n\nclass ElementError extends Error {\n override name = \"ElementError\";\n}\n\nexport { getConfig, configure, type Config, type ConfigFn };\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAmCA,MAAM,aAAa,GAAW;IAC1B,gBAAgB,EAAE,KAAK;IACvB,eAAe,EAAE,sBAAsB;IACvC,gBAAgB,EAAE,IAAI;IACtB,oBAAoB,EAAE,GAAG;IACzB,uBAAuB,EAAE,IAAI;CAChC,CAAC;AAEF,MAAM,aAAa,GAAW,EAAE,GAAG,aAAa,EAAE,CAAC;AAEnD,SAAS,sBAAsB,CAAC,OAAe;IAC3C,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,SAAS,GAAG,GAAW,EAAE;IAC3B,OAAO,aAAa,CAAC;AACzB,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,SAAS,GAAG,CAAC,SAAqC,EAAQ,EAAE;IAC9D,MAAM,OAAO,GAAG,OAAO,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACvF,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,YAAa,SAAQ,KAAK;IACnB,IAAI,GAAG,cAAc,CAAC;CAClC;AAED,OAAO,EAAE,SAAS,EAAE,SAAS,EAA8B,CAAC","sourcesContent":["import type { Container } from \"./traversal.js\";\n\n/**\n * Global configuration for the testing harness, controlling query behavior,\n * error formatting, and the timeouts used by async utilities and actionability\n * checks.\n */\ntype Config = {\n /** Whether a successful query throws instead, naming a better query, when one is available. */\n throwSuggestions: boolean;\n\n /** Builds the error thrown when a query fails, given a message and optional container. */\n getElementError: (message: string, container?: Container) => Error;\n\n /** Default timeout in milliseconds for async utilities such as waitFor. */\n asyncUtilTimeout: number;\n\n /** Timeout in milliseconds a user event waits for its widget to become actionable. */\n actionabilityTimeout: number;\n\n /**\n * Timeout in milliseconds `render` waits for the window it shows the tree in to be laid out and\n * activated. A window becoming active is a round trip through the compositor rather than an\n * in-process check, so this is far longer than {@link Config.actionabilityTimeout}: it bounds\n * how long a window that never activates takes to report, and costs nothing when one does.\n */\n windowActivationTimeout: number;\n};\n\n/**\n * Function form of a configuration update: receives the current config and\n * returns the fields to override.\n */\ntype ConfigFn = (existingConfig: Config) => Partial<Config>;\n\nconst defaultConfig: Config = {\n throwSuggestions: false,\n getElementError: defaultGetElementError,\n asyncUtilTimeout: 1000,\n actionabilityTimeout: 500,\n windowActivationTimeout: 5000,\n};\n\nconst currentConfig: Config = { ...defaultConfig };\n\nfunction defaultGetElementError(message: string): Error {\n return new ElementError(message);\n}\n\n/**\n * Returns the current global testing configuration.\n */\nconst getConfig = (): Config => {\n return currentConfig;\n};\n\n/**\n * Merges the given overrides into the global testing configuration.\n *\n * @param newConfig Either a partial config object or a function that receives\n * the current config and returns the fields to override.\n */\nconst configure = (newConfig: Partial<Config> | ConfigFn): void => {\n const updates = typeof newConfig === \"function\" ? newConfig(currentConfig) : newConfig;\n Object.assign(currentConfig, updates);\n};\n\nclass ElementError extends Error {\n override name = \"ElementError\";\n}\n\nexport { getConfig, configure, type Config, type ConfigFn };\n"]}
package/dist/errors.d.ts CHANGED
@@ -22,9 +22,18 @@ type QueryDescriptor = {
22
22
  value: Matcher;
23
23
  };
24
24
  declare const runWithExpensiveErrorDiagnosticsDisabled: <T>(callback: () => T) => T;
25
+ /**
26
+ * Builds the error a failing query throws, appending the container's widget tree to the message the
27
+ * way the built-in queries do.
28
+ *
29
+ * @param message The failure message.
30
+ * @param container The scope whose widget tree is appended; omitted, only the message is used.
31
+ * @returns The error produced by the configured `getElementError`.
32
+ */
33
+ declare const getElementError: (message: string, container?: Container) => Error;
25
34
  declare const notFoundError: (container: Container, descriptor: QueryDescriptor) => Error;
26
35
  declare const multipleFoundError: (container: Container, descriptor: QueryDescriptor, matches: Gtk.Widget[]) => Error;
27
36
  declare const suggestionError: (suggestion: string, container: Container) => Error;
28
37
  declare const timeoutError: (timeout: number, lastError: Error | null) => Error;
29
- export { runWithExpensiveErrorDiagnosticsDisabled, notFoundError, multipleFoundError, suggestionError, timeoutError, type QueryDescriptor, };
38
+ export { runWithExpensiveErrorDiagnosticsDisabled, getElementError, notFoundError, multipleFoundError, suggestionError, timeoutError, };
30
39
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAe,OAAO,EAAE,MAAM,YAAY,CAAC;AAKtE,KAAK,eAAe,GACd;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC,cAAc,CAAC;IAAC,OAAO,CAAC,EAAE,aAAa,GAAG,SAAS,CAAA;CAAE,GACtF;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GACpC;IAAE,SAAS,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE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CAAA;CAAE,GACpC;IAAE,SAAS,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GACzC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GACpC;IAAE,SAAS,EAAE,iBAAiB,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC/C;IAAE,SAAS,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAkGlD,QAAA,MAAM,wCAAwC,GAAI,CAAC,EAAE,UAAU,MAAM,CAAC,KAAG,CASxE,CAAC;AAYF;;;;;;;GAOG;AACH,QAAA,MAAM,eAAe,GAAI,SAAS,MAAM,EAAE,YAAY,SAAS,KAAG,KAC0C,CAAC;AAE7G,QAAA,MAAM,aAAa,GAAI,WAAW,SAAS,EAAE,YAAY,eAAe,KAAG,KAS1E,CAAC;AAWF,QAAA,MAAM,kBAAkB,GAAI,WAAW,SAAS,EAAE,YAAY,eAAe,EAAE,SAAS,GAAG,CAAC,MAAM,EAAE,KAAG,KAetG,CAAC;AAEF,QAAA,MAAM,eAAe,GAAI,YAAY,MAAM,EAAE,WAAW,SAAS,KAAG,KAKnE,CAAC;AAEF,QAAA,MAAM,YAAY,GAAI,SAAS,MAAM,EAAE,WAAW,KAAK,GAAG,IAAI,KAAG,KAKhE,CAAC;AAEF,OAAO,EACH,wCAAwC,EACxC,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,YAAY,GACf,CAAC"}
package/dist/errors.js CHANGED
@@ -95,6 +95,15 @@ const buildElementError = (container, headLines) => {
95
95
  : [...headLines, "", prettyWidget(container, { shouldHighlight: false })];
96
96
  return config.getElementError(lines.join("\n"), container);
97
97
  };
98
+ /**
99
+ * Builds the error a failing query throws, appending the container's widget tree to the message the
100
+ * way the built-in queries do.
101
+ *
102
+ * @param message The failure message.
103
+ * @param container The scope whose widget tree is appended; omitted, only the message is used.
104
+ * @returns The error produced by the configured `getElementError`.
105
+ */
106
+ const getElementError = (message, container) => container === undefined ? getConfig().getElementError(message) : buildElementError(container, [message]);
98
107
  const notFoundError = (container, descriptor) => {
99
108
  const description = formatQueryDescription(descriptor);
100
109
  const headLines = [`Unable to find an element with ${description}`];
@@ -131,5 +140,5 @@ const timeoutError = (timeout, lastError) => {
131
140
  const message = lastError ? `${baseMessage}.\n\n${lastError.message}` : baseMessage;
132
141
  return getConfig().getElementError(message);
133
142
  };
134
- export { runWithExpensiveErrorDiagnosticsDisabled, notFoundError, multipleFoundError, suggestionError, timeoutError, };
143
+ export { runWithExpensiveErrorDiagnosticsDisabled, getElementError, notFoundError, multipleFoundError, suggestionError, timeoutError, };
135
144
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAU5D,MAAM,oBAAoB,GAAkD;IACxE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5D,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACxE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;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C,OAAO,EAAE,SAAS,CAAC,CAAC;AACtD,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,OAAe,EAAE,SAAuB,EAAS,EAAE;IACrE,MAAM,WAAW,GAAG,mBAAmB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3D,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,WAAW,QAAQ,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;IAEpF,OAAO,SAAS,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF,OAAO,EACH,wCAAwC,EACxC,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,YAAY,GAEf,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { Container } from \"./traversal.js\";\nimport type { ByRoleOptions, ByRoleValue, Matcher } from \"./types.js\";\nimport { getConfig } from \"./config.js\";\nimport { prettyWidget } from \"./pretty-widget.js\";\nimport { formatRole, prettyRoles } from \"./role-helpers.js\";\n\ntype QueryDescriptor =\n | { queryType: \"role\"; role: Gtk.AccessibleRole; options?: ByRoleOptions | undefined } |\n { queryType: \"text\"; text: Matcher } |\n { queryType: \"labelText\"; text: Matcher } |\n { queryType: \"name\"; name: Matcher } |\n { queryType: \"placeholderText\"; text: Matcher } |\n { queryType: \"displayValue\"; value: Matcher };\n\nconst roleOptionFormatters: ((options: ByRoleOptions) => string | null)[] = [\n (o) => (o.name ? `name ${formatTextMatcher(o.name)}` : null),\n (o) => (o.checked === undefined ? null : `checked=${String(o.checked)}`),\n (o) => (o.pressed === undefined ? null : `pressed=${String(o.pressed)}`),\n (o) => (o.selected === undefined ? null : `selected=${String(o.selected)}`),\n (o) => (o.expanded === undefined ? null : `expanded=${String(o.expanded)}`),\n (o) => (o.level === undefined ? null : `level=${String(o.level)}`),\n (o) => (o.busy === undefined ? null : `busy=${String(o.busy)}`),\n (o) => (o.description ? `description ${formatTextMatcher(o.description)}` : null),\n (o) => (o.value ? `value ${formatByRoleValue(o.value)}` : null),\n (o) => (o.hidden === undefined ? null : `hidden=${String(o.hidden)}`),\n];\n\nconst expensiveErrorDiagnostics = { isDisabled: false };\n\nconst formatTextMatcher = (text: Matcher): string => {\n if (typeof text === \"function\") {\n return \"custom function\";\n }\n\n if (text instanceof RegExp) {\n return text.toString();\n }\n\n return `'${String(text)}'`;\n};\n\nconst formatByRoleValue = (value: ByRoleValue): string => {\n const parts: string[] = [];\n\n if (value.now !== undefined) {\n parts.push(`now=${String(value.now)}`);\n }\n\n if (value.min !== undefined) {\n parts.push(`min=${String(value.min)}`);\n }\n\n if (value.max !== undefined) {\n parts.push(`max=${String(value.max)}`);\n }\n\n if (value.text !== undefined) {\n parts.push(`text ${formatTextMatcher(value.text)}`);\n }\n\n return parts.join(\", \");\n};\n\nconst roleOptionParts = (options: ByRoleOptions): string[] => {\n const parts: string[] = [];\n\n for (const formatter of roleOptionFormatters) {\n const part = formatter(options);\n\n if (part !== null) {\n parts.push(part);\n }\n }\n\n return parts;\n};\n\nconst formatByRoleDescription = (role: Gtk.AccessibleRole, options?: ByRoleOptions): string => {\n const parts = [`role '${formatRole(role).toUpperCase()}'`];\n\n if (options) {\n parts.push(...roleOptionParts(options));\n }\n\n return parts.join(\" and \");\n};\n\nconst formatQueryDescription = (descriptor: QueryDescriptor): string => {\n switch (descriptor.queryType) {\n case \"role\": {\n return formatByRoleDescription(descriptor.role, descriptor.options);\n }\n case \"text\": {\n return `text ${formatTextMatcher(descriptor.text)}`;\n }\n case \"labelText\": {\n return `label text ${formatTextMatcher(descriptor.text)}`;\n }\n case \"name\": {\n return `name ${formatTextMatcher(descriptor.name)}`;\n }\n case \"placeholderText\": {\n return `placeholder text ${formatTextMatcher(descriptor.text)}`;\n }\n case \"displayValue\": {\n return `display value ${formatTextMatcher(descriptor.value)}`;\n }\n }\n};\n\nconst runWithExpensiveErrorDiagnosticsDisabled = <T>(callback: () => T): T => {\n const isPrevious = expensiveErrorDiagnostics.isDisabled;\n expensiveErrorDiagnostics.isDisabled = true;\n\n try {\n return callback();\n } finally {\n expensiveErrorDiagnostics.isDisabled = isPrevious;\n }\n};\n\nconst buildElementError = (container: Container, headLines: string[]): Error => {\n const config = getConfig();\n\n const lines = expensiveErrorDiagnostics.isDisabled\n ? headLines\n : [...headLines, \"\", prettyWidget(container, { shouldHighlight: false })];\n\n return config.getElementError(lines.join(\"\\n\"), container);\n};\n\nconst notFoundError = (container: Container, descriptor: QueryDescriptor): Error => {\n const description = formatQueryDescription(descriptor);\n const headLines = [`Unable to find an element with ${description}`];\n\n if (!expensiveErrorDiagnostics.isDisabled && descriptor.queryType === \"role\") {\n headLines.push(\"\", \"Here are the accessible roles:\", \"\", prettyRoles(container));\n }\n\n return buildElementError(container, headLines);\n};\n\nconst allByVariantHint = (descriptor: QueryDescriptor): string => {\n const variant = descriptor.queryType === \"role\" ? \"getAllByRole\" : \"getAllBy*\";\n\n return (\n \"(If this is intentional, use the *AllBy* variant of the query, \" +\n `e.g. queryAllBy*/getAllBy*/findAllBy*, such as ${variant}.)`\n );\n};\n\nconst multipleFoundError = (container: Container, descriptor: QueryDescriptor, matches: Gtk.Widget[]): Error => {\n const description = formatQueryDescription(descriptor);\n\n const headLines = [\n `Found ${String(matches.length)} elements with ${description}, but expected only one`,\n \"\",\n allByVariantHint(descriptor),\n ];\n\n if (!expensiveErrorDiagnostics.isDisabled) {\n const renderedMatches = matches.map((widget) => prettyWidget(widget, { shouldHighlight: false }));\n headLines.push(\"\", \"Here are the matching elements:\", \"\", ...renderedMatches);\n }\n\n return buildElementError(container, headLines);\n};\n\nconst suggestionError = (suggestion: string, container: Container): Error => {\n const config = getConfig();\n const message = `A better query is available, try this:\\n${suggestion}\\n`;\n\n return config.getElementError(message, container);\n};\n\nconst timeoutError = (timeout: number, lastError: Error | null): Error => {\n const baseMessage = `Timed out after ${String(timeout)}ms`;\n const message = lastError ? `${baseMessage}.\\n\\n${lastError.message}` : baseMessage;\n\n return getConfig().getElementError(message);\n};\n\nexport {\n runWithExpensiveErrorDiagnosticsDisabled,\n notFoundError,\n multipleFoundError,\n suggestionError,\n timeoutError,\n type QueryDescriptor,\n};\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAU5D,MAAM,oBAAoB,GAAkD;IACxE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5D,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACxE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACxE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC3E,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;I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,EAAE;IACrE,MAAM,WAAW,GAAG,mBAAmB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3D,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,WAAW,QAAQ,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;IAEpF,OAAO,SAAS,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF,OAAO,EACH,wCAAwC,EACxC,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,YAAY,GACf,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { Container } from \"./traversal.js\";\nimport type { ByRoleOptions, ByRoleValue, Matcher } from \"./types.js\";\nimport { getConfig } from \"./config.js\";\nimport { prettyWidget } from \"./pretty-widget.js\";\nimport { formatRole, prettyRoles } from \"./role-helpers.js\";\n\ntype QueryDescriptor =\n | { queryType: \"role\"; role: Gtk.AccessibleRole; options?: ByRoleOptions | undefined } |\n { queryType: \"text\"; text: Matcher } |\n { queryType: \"labelText\"; text: Matcher } |\n { queryType: \"name\"; name: Matcher } |\n { queryType: \"placeholderText\"; text: Matcher } |\n { queryType: \"displayValue\"; value: Matcher };\n\nconst roleOptionFormatters: ((options: ByRoleOptions) => string | null)[] = [\n (o) => (o.name ? `name ${formatTextMatcher(o.name)}` : null),\n (o) => (o.checked === undefined ? null : `checked=${String(o.checked)}`),\n (o) => (o.pressed === undefined ? null : `pressed=${String(o.pressed)}`),\n (o) => (o.selected === undefined ? null : `selected=${String(o.selected)}`),\n (o) => (o.expanded === undefined ? null : `expanded=${String(o.expanded)}`),\n (o) => (o.level === undefined ? null : `level=${String(o.level)}`),\n (o) => (o.busy === undefined ? null : `busy=${String(o.busy)}`),\n (o) => (o.description ? `description ${formatTextMatcher(o.description)}` : null),\n (o) => (o.value ? `value ${formatByRoleValue(o.value)}` : null),\n (o) => (o.hidden === undefined ? null : `hidden=${String(o.hidden)}`),\n];\n\nconst expensiveErrorDiagnostics = { isDisabled: false };\n\nconst formatTextMatcher = (text: Matcher): string => {\n if (typeof text === \"function\") {\n return \"custom function\";\n }\n\n if (text instanceof RegExp) {\n return text.toString();\n }\n\n return `'${String(text)}'`;\n};\n\nconst formatByRoleValue = (value: ByRoleValue): string => {\n const parts: string[] = [];\n\n if (value.now !== undefined) {\n parts.push(`now=${String(value.now)}`);\n }\n\n if (value.min !== undefined) {\n parts.push(`min=${String(value.min)}`);\n }\n\n if (value.max !== undefined) {\n parts.push(`max=${String(value.max)}`);\n }\n\n if (value.text !== undefined) {\n parts.push(`text ${formatTextMatcher(value.text)}`);\n }\n\n return parts.join(\", \");\n};\n\nconst roleOptionParts = (options: ByRoleOptions): string[] => {\n const parts: string[] = [];\n\n for (const formatter of roleOptionFormatters) {\n const part = formatter(options);\n\n if (part !== null) {\n parts.push(part);\n }\n }\n\n return parts;\n};\n\nconst formatByRoleDescription = (role: Gtk.AccessibleRole, options?: ByRoleOptions): string => {\n const parts = [`role '${formatRole(role).toUpperCase()}'`];\n\n if (options) {\n parts.push(...roleOptionParts(options));\n }\n\n return parts.join(\" and \");\n};\n\nconst formatQueryDescription = (descriptor: QueryDescriptor): string => {\n switch (descriptor.queryType) {\n case \"role\": {\n return formatByRoleDescription(descriptor.role, descriptor.options);\n }\n case \"text\": {\n return `text ${formatTextMatcher(descriptor.text)}`;\n }\n case \"labelText\": {\n return `label text ${formatTextMatcher(descriptor.text)}`;\n }\n case \"name\": {\n return `name ${formatTextMatcher(descriptor.name)}`;\n }\n case \"placeholderText\": {\n return `placeholder text ${formatTextMatcher(descriptor.text)}`;\n }\n case \"displayValue\": {\n return `display value ${formatTextMatcher(descriptor.value)}`;\n }\n }\n};\n\nconst runWithExpensiveErrorDiagnosticsDisabled = <T>(callback: () => T): T => {\n const isPrevious = expensiveErrorDiagnostics.isDisabled;\n expensiveErrorDiagnostics.isDisabled = true;\n\n try {\n return callback();\n } finally {\n expensiveErrorDiagnostics.isDisabled = isPrevious;\n }\n};\n\nconst buildElementError = (container: Container, headLines: string[]): Error => {\n const config = getConfig();\n\n const lines = expensiveErrorDiagnostics.isDisabled\n ? headLines\n : [...headLines, \"\", prettyWidget(container, { shouldHighlight: false })];\n\n return config.getElementError(lines.join(\"\\n\"), container);\n};\n\n/**\n * Builds the error a failing query throws, appending the container's widget tree to the message the\n * way the built-in queries do.\n *\n * @param message The failure message.\n * @param container The scope whose widget tree is appended; omitted, only the message is used.\n * @returns The error produced by the configured `getElementError`.\n */\nconst getElementError = (message: string, container?: Container): Error =>\n container === undefined ? getConfig().getElementError(message) : buildElementError(container, [message]);\n\nconst notFoundError = (container: Container, descriptor: QueryDescriptor): Error => {\n const description = formatQueryDescription(descriptor);\n const headLines = [`Unable to find an element with ${description}`];\n\n if (!expensiveErrorDiagnostics.isDisabled && descriptor.queryType === \"role\") {\n headLines.push(\"\", \"Here are the accessible roles:\", \"\", prettyRoles(container));\n }\n\n return buildElementError(container, headLines);\n};\n\nconst allByVariantHint = (descriptor: QueryDescriptor): string => {\n const variant = descriptor.queryType === \"role\" ? \"getAllByRole\" : \"getAllBy*\";\n\n return (\n \"(If this is intentional, use the *AllBy* variant of the query, \" +\n `e.g. queryAllBy*/getAllBy*/findAllBy*, such as ${variant}.)`\n );\n};\n\nconst multipleFoundError = (container: Container, descriptor: QueryDescriptor, matches: Gtk.Widget[]): Error => {\n const description = formatQueryDescription(descriptor);\n\n const headLines = [\n `Found ${String(matches.length)} elements with ${description}, but expected only one`,\n \"\",\n allByVariantHint(descriptor),\n ];\n\n if (!expensiveErrorDiagnostics.isDisabled) {\n const renderedMatches = matches.map((widget) => prettyWidget(widget, { shouldHighlight: false }));\n headLines.push(\"\", \"Here are the matching elements:\", \"\", ...renderedMatches);\n }\n\n return buildElementError(container, headLines);\n};\n\nconst suggestionError = (suggestion: string, container: Container): Error => {\n const config = getConfig();\n const message = `A better query is available, try this:\\n${suggestion}\\n`;\n\n return config.getElementError(message, container);\n};\n\nconst timeoutError = (timeout: number, lastError: Error | null): Error => {\n const baseMessage = `Timed out after ${String(timeout)}ms`;\n const message = lastError ? `${baseMessage}.\\n\\n${lastError.message}` : baseMessage;\n\n return getConfig().getElementError(message);\n};\n\nexport {\n runWithExpensiveErrorDiagnosticsDisabled,\n getElementError,\n notFoundError,\n multipleFoundError,\n suggestionError,\n timeoutError,\n};\n"]}
@@ -1,12 +1,41 @@
1
- import type * as GObject from "@gtkx/gi/gobject";
1
+ import * as GObject from "@gtkx/gi/gobject";
2
2
  /**
3
- * Emits a GObject signal on a widget or object inside React's act environment,
4
- * so any resulting state updates are flushed before the promise resolves.
3
+ * A signal emission built but not yet delivered. GObject has no event object to construct, so this
4
+ * records the target, signal, and arguments {@link fireEvent} will emit.
5
+ */
6
+ type WidgetEvent = {
7
+ /** The GObject instance the signal is emitted on. */
8
+ target: GObject.Object;
9
+ /** Name of the signal to emit. */
10
+ signalName: string;
11
+ /** Arguments passed to the signal handlers. */
12
+ args: unknown[];
13
+ };
14
+ /**
15
+ * Records a signal emission without delivering it, so it can be inspected or held and passed to
16
+ * {@link fireEvent} later.
17
+ *
18
+ * @param target The GObject instance the signal would be emitted on.
19
+ * @param signalName Name of the signal to emit.
20
+ * @param args Arguments to pass to the signal handlers.
21
+ * @returns The recorded emission.
22
+ */
23
+ declare const createEvent: (target: GObject.Object, signalName: string, ...args: unknown[]) => WidgetEvent;
24
+ /**
25
+ * Emits a recorded signal emission inside React's act environment, so any resulting state updates are
26
+ * flushed before the promise resolves.
27
+ *
28
+ * @param event An emission built by {@link createEvent}.
29
+ */
30
+ declare function fireEvent(event: WidgetEvent): Promise<void>;
31
+ /**
32
+ * Emits a GObject signal on a widget or object inside React's act environment, so any resulting state
33
+ * updates are flushed before the promise resolves.
5
34
  *
6
- * @param element The GObject instance to emit the signal on.
35
+ * @param target The GObject instance to emit the signal on.
7
36
  * @param signalName Name of the signal to emit.
8
37
  * @param args Arguments passed to the signal handlers.
9
38
  */
10
- declare const fireEvent: (element: GObject.Object, signalName: string, ...args: unknown[]) => Promise<void>;
11
- export { fireEvent };
39
+ declare function fireEvent(target: GObject.Object, signalName: string, ...args: unknown[]): Promise<void>;
40
+ export { createEvent, fireEvent, type WidgetEvent };
12
41
  //# sourceMappingURL=fire-event.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fire-event.d.ts","sourceRoot":"","sources":["../src/fire-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAGjD;;;;;;;GAOG;AACH,QAAA,MAAM,SAAS,GAAU,SAAS,OAAO,CAAC,MAAM,EAAE,YAAY,MAAM,EAAE,GAAG,MAAM,OAAO,EAAE,KAAG,OAAO,CAAC,IAAI,CAItG,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"fire-event.d.ts","sourceRoot":"","sources":["../src/fire-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAG5C;;;GAGG;AACH,KAAK,WAAW,GAAG;IACf,qDAAqD;IACrD,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC;IACvB,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,IAAI,EAAE,OAAO,EAAE,CAAC;CACnB,CAAC;AAEF;;;;;;;;GAQG;AACH,QAAA,MAAM,WAAW,GAAI,QAAQ,OAAO,CAAC,MAAM,EAAE,YAAY,MAAM,EAAE,GAAG,MAAM,OAAO,EAAE,KAAG,WAIpF,CAAC;AAQH;;;;;GAKG;AACH,iBAAS,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACtD;;;;;;;GAOG;AACH,iBAAS,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAkBlG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,CAAC"}
@@ -1,16 +1,32 @@
1
+ import * as GObject from "@gtkx/gi/gobject";
1
2
  import { runInAct } from "./act.js";
2
3
  /**
3
- * Emits a GObject signal on a widget or object inside React's act environment,
4
- * so any resulting state updates are flushed before the promise resolves.
4
+ * Records a signal emission without delivering it, so it can be inspected or held and passed to
5
+ * {@link fireEvent} later.
5
6
  *
6
- * @param element The GObject instance to emit the signal on.
7
+ * @param target The GObject instance the signal would be emitted on.
7
8
  * @param signalName Name of the signal to emit.
8
- * @param args Arguments passed to the signal handlers.
9
+ * @param args Arguments to pass to the signal handlers.
10
+ * @returns The recorded emission.
9
11
  */
10
- const fireEvent = async (element, signalName, ...args) => {
12
+ const createEvent = (target, signalName, ...args) => ({
13
+ target,
14
+ signalName,
15
+ args,
16
+ });
17
+ const dispatchEvent = async (event) => {
11
18
  await runInAct(() => {
12
- element.emit(signalName, ...args);
19
+ event.target.emit(event.signalName, ...event.args);
13
20
  });
14
21
  };
15
- export { fireEvent };
22
+ function fireEvent(eventOrTarget, signalName, ...args) {
23
+ if (!(eventOrTarget instanceof GObject.Object)) {
24
+ return dispatchEvent(eventOrTarget);
25
+ }
26
+ if (signalName === undefined) {
27
+ throw new Error("Unable to fire an event: pass a signal name, or an event built by createEvent.");
28
+ }
29
+ return dispatchEvent(createEvent(eventOrTarget, signalName, ...args));
30
+ }
31
+ export { createEvent, fireEvent };
16
32
  //# sourceMappingURL=fire-event.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fire-event.js","sourceRoot":"","sources":["../src/fire-event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,SAAS,GAAG,KAAK,EAAE,OAAuB,EAAE,UAAkB,EAAE,GAAG,IAAe,EAAiB,EAAE;IACvG,MAAM,QAAQ,CAAC,GAAG,EAAE;QAChB,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport { runInAct } from \"./act.js\";\n\n/**\n * Emits a GObject signal on a widget or object inside React's act environment,\n * so any resulting state updates are flushed before the promise resolves.\n *\n * @param element The GObject instance to emit the signal on.\n * @param signalName Name of the signal to emit.\n * @param args Arguments passed to the signal handlers.\n */\nconst fireEvent = async (element: GObject.Object, signalName: string, ...args: unknown[]): Promise<void> => {\n await runInAct(() => {\n element.emit(signalName, ...args);\n });\n};\n\nexport { fireEvent };\n"]}
1
+ {"version":3,"file":"fire-event.js","sourceRoot":"","sources":["../src/fire-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAepC;;;;;;;;GAQG;AACH,MAAM,WAAW,GAAG,CAAC,MAAsB,EAAE,UAAkB,EAAE,GAAG,IAAe,EAAe,EAAE,CAAC,CAAC;IAClG,MAAM;IACN,UAAU;IACV,IAAI;CACP,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,KAAK,EAAE,KAAkB,EAAiB,EAAE;IAC9D,MAAM,QAAQ,CAAC,GAAG,EAAE;QAChB,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAmBF,SAAS,SAAS,CACd,aAA2C,EAC3C,UAAmB,EACnB,GAAG,IAAe;IAElB,IAAI,CAAC,CAAC,aAAa,YAAY,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7C,OAAO,aAAa,CAAC,aAAa,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;IACtG,CAAC;IAED,OAAO,aAAa,CAAC,WAAW,CAAC,aAAa,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,SAAS,EAAoB,CAAC","sourcesContent":["import * as GObject from \"@gtkx/gi/gobject\";\nimport { runInAct } from \"./act.js\";\n\n/**\n * A signal emission built but not yet delivered. GObject has no event object to construct, so this\n * records the target, signal, and arguments {@link fireEvent} will emit.\n */\ntype WidgetEvent = {\n /** The GObject instance the signal is emitted on. */\n target: GObject.Object;\n /** Name of the signal to emit. */\n signalName: string;\n /** Arguments passed to the signal handlers. */\n args: unknown[];\n};\n\n/**\n * Records a signal emission without delivering it, so it can be inspected or held and passed to\n * {@link fireEvent} later.\n *\n * @param target The GObject instance the signal would be emitted on.\n * @param signalName Name of the signal to emit.\n * @param args Arguments to pass to the signal handlers.\n * @returns The recorded emission.\n */\nconst createEvent = (target: GObject.Object, signalName: string, ...args: unknown[]): WidgetEvent => ({\n target,\n signalName,\n args,\n});\n\nconst dispatchEvent = async (event: WidgetEvent): Promise<void> => {\n await runInAct(() => {\n event.target.emit(event.signalName, ...event.args);\n });\n};\n\n/**\n * Emits a recorded signal emission inside React's act environment, so any resulting state updates are\n * flushed before the promise resolves.\n *\n * @param event An emission built by {@link createEvent}.\n */\nfunction fireEvent(event: WidgetEvent): Promise<void>;\n/**\n * Emits a GObject signal on a widget or object inside React's act environment, so any resulting state\n * updates are flushed before the promise resolves.\n *\n * @param target The GObject instance to emit the signal on.\n * @param signalName Name of the signal to emit.\n * @param args Arguments passed to the signal handlers.\n */\nfunction fireEvent(target: GObject.Object, signalName: string, ...args: unknown[]): Promise<void>;\n\nfunction fireEvent(\n eventOrTarget: WidgetEvent | GObject.Object,\n signalName?: string,\n ...args: unknown[]\n): Promise<void> {\n if (!(eventOrTarget instanceof GObject.Object)) {\n return dispatchEvent(eventOrTarget);\n }\n\n if (signalName === undefined) {\n throw new Error(\"Unable to fire an event: pass a signal name, or an event built by createEvent.\");\n }\n\n return dispatchEvent(createEvent(eventOrTarget, signalName, ...args));\n}\n\nexport { createEvent, fireEvent, type WidgetEvent };\n"]}
@@ -1,4 +1,5 @@
1
1
  import type * as Gtk from "@gtkx/gi/gtk";
2
- declare const scheduleAfterLayout: (widget: Gtk.Widget | null, callback: () => void) => void;
3
- export { scheduleAfterLayout };
2
+ declare const scheduleNextFrame: (widget: Gtk.Widget) => Promise<void>;
3
+ declare const scheduleWhenWindowReady: (window: Gtk.Window | null, isReady: (window: Gtk.Window) => boolean, timeout: number, callback: () => void) => void;
4
+ export { scheduleNextFrame, scheduleWhenWindowReady };
4
5
  //# sourceMappingURL=frame-sync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"frame-sync.d.ts","sourceRoot":"","sources":["../src/frame-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAsCzC,QAAA,MAAM,mBAAmB,GAAI,QAAQ,GAAG,CAAC,MAAM,GAAG,IAAI,EAAE,UAAU,MAAM,IAAI,KAAG,IAU9E,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
1
+ {"version":3,"file":"frame-sync.d.ts","sourceRoot":"","sources":["../src/frame-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAyCzC,QAAA,MAAM,iBAAiB,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAWtD,CAAC;AAEP,QAAA,MAAM,uBAAuB,GACzB,QAAQ,GAAG,CAAC,MAAM,GAAG,IAAI,EACzB,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,KAAK,OAAO,EACxC,SAAS,MAAM,EACf,UAAU,MAAM,IAAI,KACrB,IAUF,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import * as GLib from "@gtkx/gi/glib";
2
+ import { cancelTimeout, scheduleTimeout } from "./timers.js";
2
3
  const CLOCK_STALL_FALLBACK_MS = 500;
3
4
  const once = (callback) => {
4
5
  let isCalled = false;
@@ -10,28 +11,37 @@ const once = (callback) => {
10
11
  callback();
11
12
  };
12
13
  };
13
- const runWhenSized = (widget, finish) => {
14
+ const hasFrameClock = (widget) => widget?.getFrameClock() != null;
15
+ const runUntilReady = (widget, isReady, timeout, finish) => {
14
16
  let tickId = 0;
15
- const fallback = setTimeout(() => {
17
+ const fallback = scheduleTimeout(() => {
16
18
  widget.removeTickCallback(tickId);
17
19
  finish();
18
- }, CLOCK_STALL_FALLBACK_MS);
20
+ }, timeout);
19
21
  tickId = widget.addTickCallback(() => {
20
- if (widget.getWidth() === 0) {
22
+ if (!isReady()) {
21
23
  return GLib.SOURCE_CONTINUE;
22
24
  }
23
- clearTimeout(fallback);
25
+ cancelTimeout(fallback);
24
26
  finish();
25
27
  return GLib.SOURCE_REMOVE;
26
28
  });
27
29
  };
28
- const scheduleAfterLayout = (widget, callback) => {
30
+ const scheduleNextFrame = (widget) => new Promise((resolve) => {
31
+ const finish = once(resolve);
32
+ if (!hasFrameClock(widget)) {
33
+ queueMicrotask(finish);
34
+ return;
35
+ }
36
+ runUntilReady(widget, () => true, CLOCK_STALL_FALLBACK_MS, finish);
37
+ });
38
+ const scheduleWhenWindowReady = (window, isReady, timeout, callback) => {
29
39
  const finish = once(callback);
30
- if (widget?.getFrameClock() == null || widget.getWidth() > 0) {
40
+ if (!hasFrameClock(window) || isReady(window)) {
31
41
  queueMicrotask(finish);
32
42
  return;
33
43
  }
34
- runWhenSized(widget, finish);
44
+ runUntilReady(window, () => isReady(window), timeout, finish);
35
45
  };
36
- export { scheduleAfterLayout };
46
+ export { scheduleNextFrame, scheduleWhenWindowReady };
37
47
  //# sourceMappingURL=frame-sync.js.map
@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M,CAAC,CAAC;QAEvB,OAAO;IACX,CAAC;IAED,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport * as GLib from \"@gtkx/gi/glib\";\n\nconst CLOCK_STALL_FALLBACK_MS = 500;\n\nconst once = (callback: () => void): (() => void) => {\n let isCalled = false;\n\n return () => {\n if (isCalled) {\n return;\n }\n\n isCalled = true;\n callback();\n };\n};\n\nconst runWhenSized = (widget: Gtk.Widget, finish: () => void): void => {\n let tickId = 0;\n\n const fallback = setTimeout(() => {\n widget.removeTickCallback(tickId);\n finish();\n }, CLOCK_STALL_FALLBACK_MS);\n\n tickId = widget.addTickCallback(() => {\n if (widget.getWidth() === 0) {\n return GLib.SOURCE_CONTINUE;\n }\n\n clearTimeout(fallback);\n finish();\n\n return GLib.SOURCE_REMOVE;\n });\n};\n\nconst scheduleAfterLayout = (widget: Gtk.Widget | null, callback: () => void): void => {\n const finish = once(callback);\n\n if (widget?.getFrameClock() == null || widget.getWidth() > 0) {\n queueMicrotask(finish);\n\n return;\n }\n\n runWhenSized(widget, finish);\n};\n\nexport { scheduleAfterLayout };\n"]}
1
+ {"version":3,"file":"frame-sync.js","sourceRoot":"","sources":["../src/frame-sync.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC,MAAM,IAAI,GAAG,CAAC,QAAoB,EAAgB,EAAE;IAChD,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,OAAO,GAAG,EAAE;QACR,IAAI,QAAQ,EAAE,CAAC;YACX,OAAO;QACX,CAAC;QAED,QAAQ,GAAG,IAAI,CAAC;QAChB,QAAQ,EAAE,CAAC;IACf,CAAC,C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,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5C,cAAc,CAAC,MAAM,CAAC,CAAC;QAEvB,OAAO;IACX,CAAC;IAED,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAClE,CAAC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport * as GLib from \"@gtkx/gi/glib\";\nimport { cancelTimeout, scheduleTimeout } from \"./timers.js\";\n\nconst CLOCK_STALL_FALLBACK_MS = 500;\n\nconst once = (callback: () => void): (() => void) => {\n let isCalled = false;\n\n return () => {\n if (isCalled) {\n return;\n }\n\n isCalled = true;\n callback();\n };\n};\n\nconst hasFrameClock = (widget: Gtk.Widget | null): widget is Gtk.Widget => widget?.getFrameClock() != null;\n\nconst runUntilReady = (widget: Gtk.Widget, isReady: () => boolean, timeout: number, finish: () => void): void => {\n let tickId = 0;\n\n const fallback = scheduleTimeout(() => {\n widget.removeTickCallback(tickId);\n finish();\n }, timeout);\n\n tickId = widget.addTickCallback(() => {\n if (!isReady()) {\n return GLib.SOURCE_CONTINUE;\n }\n\n cancelTimeout(fallback);\n finish();\n\n return GLib.SOURCE_REMOVE;\n });\n};\n\nconst scheduleNextFrame = (widget: Gtk.Widget): Promise<void> =>\n new Promise((resolve) => {\n const finish = once(resolve);\n\n if (!hasFrameClock(widget)) {\n queueMicrotask(finish);\n\n return;\n }\n\n runUntilReady(widget, () => true, CLOCK_STALL_FALLBACK_MS, finish);\n });\n\nconst scheduleWhenWindowReady = (\n window: Gtk.Window | null,\n isReady: (window: Gtk.Window) => boolean,\n timeout: number,\n callback: () => void,\n): void => {\n const finish = once(callback);\n\n if (!hasFrameClock(window) || isReady(window)) {\n queueMicrotask(finish);\n\n return;\n }\n\n runUntilReady(window, () => isReady(window), timeout, finish);\n};\n\nexport { scheduleNextFrame, scheduleWhenWindowReady };\n"]}
@@ -0,0 +1,5 @@
1
+ import * as Gtk from "@gtkx/gi/gtk";
2
+ declare const createHarnessWindow: () => Gtk.Window;
3
+ declare const presentHarnessWindow: (window: Gtk.Window | null) => void;
4
+ export { createHarnessWindow, presentHarnessWindow };
5
+ //# sourceMappingURL=harness-window.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness-window.d.ts","sourceRoot":"","sources":["../src/harness-window.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAMpC,QAAA,MAAM,mBAAmB,QAAO,GAAG,CAAC,MAC4D,CAAC;AAEjG,QAAA,MAAM,oBAAoB,GAAI,QAAQ,GAAG,CAAC,MAAM,GAAG,IAAI,KAAG,IAWzD,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ import * as Gtk from "@gtkx/gi/gtk";
2
+ const HARNESS_WINDOW_WIDTH = 800;
3
+ const HARNESS_WINDOW_HEIGHT = 600;
4
+ const TEXT_END_POSITION = -1;
5
+ const createHarnessWindow = () => new Gtk.Window({ defaultWidth: HARNESS_WINDOW_WIDTH, defaultHeight: HARNESS_WINDOW_HEIGHT });
6
+ const presentHarnessWindow = (window) => {
7
+ if (!window) {
8
+ return;
9
+ }
10
+ window.present();
11
+ const focus = window.getFocus();
12
+ if (focus instanceof Gtk.Text) {
13
+ focus.setPosition(TEXT_END_POSITION);
14
+ }
15
+ };
16
+ export { createHarnessWindow, presentHarnessWindow };
17
+ //# sourceMappingURL=harness-window.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness-window.js","sourceRoot":"","sources":["../src/harness-window.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,iBAAiB,GAAG,CAAC,CAAC,CAAC;AAE7B,MAAM,mBAAmB,GAAG,GAAe,EAAE,CACzC,IAAI,GAAG,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,oBAAoB,EAAE,aAAa,EAAE,qBAAqB,EAAE,CAAC,CAAC;AAEjG,MAAM,oBAAoB,GAAG,CAAC,MAAyB,EAAQ,EAAE;IAC7D,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,OAAO;IACX,CAAC;IAED,MAAM,CAAC,OAAO,EAAE,CAAC;IACjB,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAEhC,IAAI,KAAK,YAAY,GAAG,CAAC,IAAI,EAAE,CAAC;QAC5B,KAAK,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;IACzC,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\n\nconst HARNESS_WINDOW_WIDTH = 800;\nconst HARNESS_WINDOW_HEIGHT = 600;\nconst TEXT_END_POSITION = -1;\n\nconst createHarnessWindow = (): Gtk.Window =>\n new Gtk.Window({ defaultWidth: HARNESS_WINDOW_WIDTH, defaultHeight: HARNESS_WINDOW_HEIGHT });\n\nconst presentHarnessWindow = (window: Gtk.Window | null): void => {\n if (!window) {\n return;\n }\n\n window.present();\n const focus = window.getFocus();\n\n if (focus instanceof Gtk.Text) {\n focus.setPosition(TEXT_END_POSITION);\n }\n};\n\nexport { createHarnessWindow, presentHarnessWindow };\n"]}
package/dist/index.d.ts CHANGED
@@ -1,29 +1,36 @@
1
1
  import "./register-test-hooks.js";
2
2
  export { act } from "./act.js";
3
3
  export type { BoundQueries, RenderResult, Screen } from "./bound-queries.js";
4
+ export type { BuiltQueries, MissingErrorBuilder, MultipleErrorBuilder, QueryAllBy, } from "./build-queries.js";
5
+ export { buildQueries } from "./build-queries.js";
4
6
  export type { Config, ConfigFn } from "./config.js";
5
7
  export { configure, getConfig } from "./config.js";
6
- export { fireEvent } from "./fire-event.js";
8
+ export { getElementError } from "./errors.js";
9
+ export type { WidgetEvent } from "./fire-event.js";
10
+ export { createEvent, fireEvent } from "./fire-event.js";
7
11
  export type { ClassExpectation, TextContentOptions, TextExpectation } from "./matchers.js";
8
12
  export { matchers, registerMatchers } from "./matchers.js";
9
13
  export { getDefaultNormalizer } from "./normalize.js";
14
+ export { prettyFormat } from "./pretty-format.js";
10
15
  export type { PrettyWidgetOptions } from "./pretty-widget.js";
11
16
  export { logWidget, prettyWidget } from "./pretty-widget.js";
12
17
  export { findAllByDisplayValue, findAllByLabelText, findAllByName, findAllByPlaceholderText, findAllByRole, findAllByText, findByDisplayValue, findByLabelText, findByName, findByPlaceholderText, findByRole, findByText, getAllByDisplayValue, getAllByLabelText, getAllByName, getAllByPlaceholderText, getAllByRole, getAllByText, getByDisplayValue, getByLabelText, getByName, getByPlaceholderText, getByRole, getByText, queryAllByDisplayValue, queryAllByLabelText, queryAllByName, queryAllByPlaceholderText, queryAllByRole, queryAllByText, queryByDisplayValue, queryByLabelText, queryByName, queryByPlaceholderText, queryByRole, queryByText, } from "./queries.js";
18
+ export type { QueryHelpers } from "./query-helpers.js";
19
+ export { queryAllByObjectProperty, queryByObjectProperty, queryHelpers } from "./query-helpers.js";
13
20
  export { renderHook } from "./render-hook.js";
14
21
  export { cleanup, render } from "./render.js";
15
- export { formatRole, getRoles, logRoles, prettyRoles } from "./role-helpers.js";
22
+ export { computeHeadingLevel, formatRole, getRoles, logRoles, prettyRoles } from "./role-helpers.js";
16
23
  export { screen } from "./screen.js";
17
- export { captureAndSaveScreenshot, logScreenshotPath, screenshot } from "./screenshot.js";
24
+ export { screenshot } from "./screenshot.js";
18
25
  export type { Method, Suggestion, Variant } from "./suggestions.js";
19
26
  export { getSuggestedQuery } from "./suggestions.js";
20
27
  export type { Container } from "./traversal.js";
21
- export type { ByRoleOptions, ByRoleValue, WidgetType, Matcher, MatcherFunction, MatcherOptions, NormalizerFn, NormalizerOptions, RenderHookOptions, RenderHookResult, RenderOptions, ScreenshotOptions, ScreenshotResult, WaitForOptions, WindowSelector, WrapperComponent, } from "./types.js";
28
+ export type { ByRoleOptions, ByRoleValue, WidgetType, Matcher, MatcherFunction, MatcherOptions, NormalizerFn, NormalizerOptions, RenderHookOptions, RenderHookResult, RenderOptions, ScreenshotOptions, ScreenshotResult, WaitForOptions, WrapperComponent, } from "./types.js";
22
29
  export type { ControllerConstructor } from "./user-event/controller.js";
23
30
  export { getAllControllers, getController, queryAllControllers, queryController, } from "./user-event/controller.js";
24
- export type { DragOffset, DragOptions, DropContent, DropOptions, PointerInput, ScrollDelta, TabOptions, TypeOptions, UserEvent, } from "./user-event/index.js";
31
+ export type { DragOffset, DragOptions, DropContent, DropOptions, PointerInput, ScrollDelta, TabOptions, TypeOptions, UserEvent, UserEventOptions, } from "./user-event/index.js";
25
32
  export { userEvent } from "./user-event/index.js";
26
33
  export { waitFor, waitForElementToBeRemoved } from "./wait-for.js";
27
- export { getWidgetErrorMessage, getWidgetInvalidState, getWidgetNodeText, getWidgetTextContent, } from "./widget-accessible-properties.js";
28
- export { within } from "./within.js";
34
+ export { getWidgetText, isInaccessible } from "./widget-accessible-properties.js";
35
+ export { getQueriesForElement, within } from "./within.js";
29
36
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC7E,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAA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AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,20 +1,24 @@
1
1
  import "./register-test-hooks.js";
2
2
  export { act } from "./act.js";
3
+ export { buildQueries } from "./build-queries.js";
3
4
  export { configure, getConfig } from "./config.js";
4
- export { fireEvent } from "./fire-event.js";
5
+ export { getElementError } from "./errors.js";
6
+ export { createEvent, fireEvent } from "./fire-event.js";
5
7
  export { matchers, registerMatchers } from "./matchers.js";
6
8
  export { getDefaultNormalizer } from "./normalize.js";
9
+ export { prettyFormat } from "./pretty-format.js";
7
10
  export { logWidget, prettyWidget } from "./pretty-widget.js";
8
11
  export { findAllByDisplayValue, findAllByLabelText, findAllByName, findAllByPlaceholderText, findAllByRole, findAllByText, findByDisplayValue, findByLabelText, findByName, findByPlaceholderText, findByRole, findByText, getAllByDisplayValue, getAllByLabelText, getAllByName, getAllByPlaceholderText, getAllByRole, getAllByText, getByDisplayValue, getByLabelText, getByName, getByPlaceholderText, getByRole, getByText, queryAllByDisplayValue, queryAllByLabelText, queryAllByName, queryAllByPlaceholderText, queryAllByRole, queryAllByText, queryByDisplayValue, queryByLabelText, queryByName, queryByPlaceholderText, queryByRole, queryByText, } from "./queries.js";
12
+ export { queryAllByObjectProperty, queryByObjectProperty, queryHelpers } from "./query-helpers.js";
9
13
  export { renderHook } from "./render-hook.js";
10
14
  export { cleanup, render } from "./render.js";
11
- export { formatRole, getRoles, logRoles, prettyRoles } from "./role-helpers.js";
15
+ export { computeHeadingLevel, formatRole, getRoles, logRoles, prettyRoles } from "./role-helpers.js";
12
16
  export { screen } from "./screen.js";
13
- export { captureAndSaveScreenshot, logScreenshotPath, screenshot } from "./screenshot.js";
17
+ export { screenshot } from "./screenshot.js";
14
18
  export { getSuggestedQuery } from "./suggestions.js";
15
19
  export { getAllControllers, getController, queryAllControllers, queryController, } from "./user-event/controller.js";
16
20
  export { userEvent } from "./user-event/index.js";
17
21
  export { waitFor, waitForElementToBeRemoved } from "./wait-for.js";
18
- export { getWidgetErrorMessage, getWidgetInvalidState, getWidgetNodeText, getWidgetTextContent, } from "./widget-accessible-properties.js";
19
- export { within } from "./within.js";
22
+ export { getWidgetText, isInaccessible } from "./widget-accessible-properties.js";
23
+ export { getQueriesForElement, within } from "./within.js";
20
24
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAG/B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACH,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EACb,wBAAwB,EACxB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,qBAAqB,EACrB,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,oBAAoB,EACpB,SAAS,EACT,SAAS,EACT,sBAAsB,EACtB,mBAAmB,EACnB,cAAc,EACd,yBAAyB,EACzB,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,sBAAsB,EACtB,WAAW,EACX,WAAW,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAqBrD,OAAO,EACH,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,eAAe,GAClB,MAAM,4BAA4B,CAAC;AAYpC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EACH,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,GACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC","sourcesContent":["import \"./register-test-hooks.js\";\n\nexport { act } from \"./act.js\";\nexport type { BoundQueries, RenderResult, Screen } from \"./bound-queries.js\";\nexport type { Config, ConfigFn } from \"./config.js\";\nexport { configure, getConfig } from \"./config.js\";\nexport { fireEvent } from \"./fire-event.js\";\nexport type { ClassExpectation, TextContentOptions, TextExpectation } from \"./matchers.js\";\nexport { matchers, registerMatchers } from \"./matchers.js\";\nexport { getDefaultNormalizer } from \"./normalize.js\";\nexport type { PrettyWidgetOptions } from \"./pretty-widget.js\";\nexport { logWidget, prettyWidget } from \"./pretty-widget.js\";\nexport {\n findAllByDisplayValue,\n findAllByLabelText,\n findAllByName,\n findAllByPlaceholderText,\n findAllByRole,\n findAllByText,\n findByDisplayValue,\n findByLabelText,\n findByName,\n findByPlaceholderText,\n findByRole,\n findByText,\n getAllByDisplayValue,\n getAllByLabelText,\n getAllByName,\n getAllByPlaceholderText,\n getAllByRole,\n getAllByText,\n getByDisplayValue,\n getByLabelText,\n getByName,\n getByPlaceholderText,\n getByRole,\n getByText,\n queryAllByDisplayValue,\n queryAllByLabelText,\n queryAllByName,\n queryAllByPlaceholderText,\n queryAllByRole,\n queryAllByText,\n queryByDisplayValue,\n queryByLabelText,\n queryByName,\n queryByPlaceholderText,\n queryByRole,\n queryByText,\n} from \"./queries.js\";\nexport { renderHook } from \"./render-hook.js\";\nexport { cleanup, render } from \"./render.js\";\nexport { formatRole, getRoles, logRoles, prettyRoles } from \"./role-helpers.js\";\nexport { screen } from \"./screen.js\";\nexport { captureAndSaveScreenshot, logScreenshotPath, screenshot } from \"./screenshot.js\";\nexport type { Method, Suggestion, Variant } from \"./suggestions.js\";\nexport { getSuggestedQuery } from \"./suggestions.js\";\nexport type { Container } from \"./traversal.js\";\nexport type {\n ByRoleOptions,\n ByRoleValue,\n WidgetType,\n Matcher,\n MatcherFunction,\n MatcherOptions,\n NormalizerFn,\n NormalizerOptions,\n RenderHookOptions,\n RenderHookResult,\n RenderOptions,\n ScreenshotOptions,\n ScreenshotResult,\n WaitForOptions,\n WindowSelector,\n WrapperComponent,\n} from \"./types.js\";\nexport type { ControllerConstructor } from \"./user-event/controller.js\";\nexport {\n getAllControllers,\n getController,\n queryAllControllers,\n queryController,\n} from \"./user-event/controller.js\";\nexport type {\n DragOffset,\n DragOptions,\n DropContent,\n DropOptions,\n PointerInput,\n ScrollDelta,\n TabOptions,\n TypeOptions,\n UserEvent,\n} from \"./user-event/index.js\";\nexport { userEvent } from \"./user-event/index.js\";\nexport { waitFor, waitForElementToBeRemoved } from \"./wait-for.js\";\nexport {\n getWidgetErrorMessage,\n getWidgetInvalidState,\n getWidgetNodeText,\n getWidgetTextContent,\n} from \"./widget-accessible-properties.js\";\nexport { within } from \"./within.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,CAAC;AAElC,OA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AE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrG,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAoBrD,OAAO,EACH,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,eAAe,GAClB,MAAM,4BAA4B,CAAC;AAapC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC","sourcesContent":["import \"./register-test-hooks.js\";\n\nexport { act } from \"./act.js\";\nexport type { BoundQueries, RenderResult, Screen } from \"./bound-queries.js\";\nexport type {\n BuiltQueries,\n MissingErrorBuilder,\n MultipleErrorBuilder,\n QueryAllBy,\n} from \"./build-queries.js\";\nexport { buildQueries } from \"./build-queries.js\";\nexport type { Config, ConfigFn } from \"./config.js\";\nexport { configure, getConfig } from \"./config.js\";\nexport { getElementError } from \"./errors.js\";\nexport type { WidgetEvent } from \"./fire-event.js\";\nexport { createEvent, fireEvent } from \"./fire-event.js\";\nexport type { ClassExpectation, TextContentOptions, TextExpectation } from \"./matchers.js\";\nexport { matchers, registerMatchers } from \"./matchers.js\";\nexport { getDefaultNormalizer } from \"./normalize.js\";\nexport { prettyFormat } from \"./pretty-format.js\";\nexport type { PrettyWidgetOptions } from \"./pretty-widget.js\";\nexport { logWidget, prettyWidget } from \"./pretty-widget.js\";\nexport {\n findAllByDisplayValue,\n findAllByLabelText,\n findAllByName,\n findAllByPlaceholderText,\n findAllByRole,\n findAllByText,\n findByDisplayValue,\n findByLabelText,\n findByName,\n findByPlaceholderText,\n findByRole,\n findByText,\n getAllByDisplayValue,\n getAllByLabelText,\n getAllByName,\n getAllByPlaceholderText,\n getAllByRole,\n getAllByText,\n getByDisplayValue,\n getByLabelText,\n getByName,\n getByPlaceholderText,\n getByRole,\n getByText,\n queryAllByDisplayValue,\n queryAllByLabelText,\n queryAllByName,\n queryAllByPlaceholderText,\n queryAllByRole,\n queryAllByText,\n queryByDisplayValue,\n queryByLabelText,\n queryByName,\n queryByPlaceholderText,\n queryByRole,\n queryByText,\n} from \"./queries.js\";\nexport type { QueryHelpers } from \"./query-helpers.js\";\nexport { queryAllByObjectProperty, queryByObjectProperty, queryHelpers } from \"./query-helpers.js\";\nexport { renderHook } from \"./render-hook.js\";\nexport { cleanup, render } from \"./render.js\";\nexport { computeHeadingLevel, formatRole, getRoles, logRoles, prettyRoles } from \"./role-helpers.js\";\nexport { screen } from \"./screen.js\";\nexport { screenshot } from \"./screenshot.js\";\nexport type { Method, Suggestion, Variant } from \"./suggestions.js\";\nexport { getSuggestedQuery } from \"./suggestions.js\";\nexport type { Container } from \"./traversal.js\";\nexport type {\n ByRoleOptions,\n ByRoleValue,\n WidgetType,\n Matcher,\n MatcherFunction,\n MatcherOptions,\n NormalizerFn,\n NormalizerOptions,\n RenderHookOptions,\n RenderHookResult,\n RenderOptions,\n ScreenshotOptions,\n ScreenshotResult,\n WaitForOptions,\n WrapperComponent,\n} from \"./types.js\";\nexport type { ControllerConstructor } from \"./user-event/controller.js\";\nexport {\n getAllControllers,\n getController,\n queryAllControllers,\n queryController,\n} from \"./user-event/controller.js\";\nexport type {\n DragOffset,\n DragOptions,\n DropContent,\n DropOptions,\n PointerInput,\n ScrollDelta,\n TabOptions,\n TypeOptions,\n UserEvent,\n UserEventOptions,\n} from \"./user-event/index.js\";\nexport { userEvent } from \"./user-event/index.js\";\nexport { waitFor, waitForElementToBeRemoved } from \"./wait-for.js\";\nexport { getWidgetText, isInaccessible } from \"./widget-accessible-properties.js\";\nexport { getQueriesForElement, within } from \"./within.js\";\n"]}
@@ -0,0 +1,5 @@
1
+ export { readAccessibleBooleanProperty, readAccessibleFlag, readAccessibleInt, readAccessibleNumber, readAccessibleRelation, readAccessibleState, readAccessibleString, } from "./accessible-native.js";
2
+ export { cleanup, render } from "./production.js";
3
+ export { renderChildren, type ChildrenBuilder } from "./render-children.js";
4
+ export { getTypeTag } from "./widget-getters.js";
5
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,6BAA6B,EAC7B,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { readAccessibleBooleanProperty, readAccessibleFlag, readAccessibleInt, readAccessibleNumber, readAccessibleRelation, readAccessibleState, readAccessibleString, } from "./accessible-native.js";
2
+ export { cleanup, render } from "./production.js";
3
+ export { renderChildren } from "./render-children.js";
4
+ export { getTypeTag } from "./widget-getters.js";
5
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,6BAA6B,EAC7B,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAwB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["export {\n readAccessibleBooleanProperty,\n readAccessibleFlag,\n readAccessibleInt,\n readAccessibleNumber,\n readAccessibleRelation,\n readAccessibleState,\n readAccessibleString,\n} from \"./accessible-native.js\";\nexport { cleanup, render } from \"./production.js\";\nexport { renderChildren, type ChildrenBuilder } from \"./render-children.js\";\nexport { getTypeTag } from \"./widget-getters.js\";\n"]}