@gtkx/testing 1.0.0-rc.3 → 1.0.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 (215) hide show
  1. package/README.md +8 -9
  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 +2 -0
  7. package/dist/act.d.ts.map +1 -1
  8. package/dist/act.js.map +1 -1
  9. package/dist/build-queries.d.ts +27 -10
  10. package/dist/build-queries.d.ts.map +1 -1
  11. package/dist/build-queries.js +39 -30
  12. package/dist/build-queries.js.map +1 -1
  13. package/dist/cleanup-registry.d.ts +1 -1
  14. package/dist/cleanup-registry.d.ts.map +1 -1
  15. package/dist/cleanup-registry.js.map +1 -1
  16. package/dist/config.d.ts +1 -0
  17. package/dist/config.d.ts.map +1 -1
  18. package/dist/config.js +3 -3
  19. package/dist/config.js.map +1 -1
  20. package/dist/errors.d.ts +10 -1
  21. package/dist/errors.d.ts.map +1 -1
  22. package/dist/errors.js +12 -3
  23. package/dist/errors.js.map +1 -1
  24. package/dist/fire-event.d.ts +35 -6
  25. package/dist/fire-event.d.ts.map +1 -1
  26. package/dist/fire-event.js +23 -7
  27. package/dist/fire-event.js.map +1 -1
  28. package/dist/frame-sync.d.ts +2 -1
  29. package/dist/frame-sync.d.ts.map +1 -1
  30. package/dist/frame-sync.js +15 -5
  31. package/dist/frame-sync.js.map +1 -1
  32. package/dist/harness-window.d.ts +4 -0
  33. package/dist/harness-window.d.ts.map +1 -0
  34. package/dist/harness-window.js +6 -0
  35. package/dist/harness-window.js.map +1 -0
  36. package/dist/index.d.ts +14 -7
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +9 -5
  39. package/dist/index.js.map +1 -1
  40. package/dist/internal.d.ts +4 -0
  41. package/dist/internal.d.ts.map +1 -0
  42. package/dist/internal.js +4 -0
  43. package/dist/internal.js.map +1 -0
  44. package/dist/matchers.d.ts +125 -39
  45. package/dist/matchers.d.ts.map +1 -1
  46. package/dist/matchers.js +156 -18
  47. package/dist/matchers.js.map +1 -1
  48. package/dist/pretty-format.d.ts +2 -0
  49. package/dist/pretty-format.d.ts.map +1 -0
  50. package/dist/pretty-format.js +2 -0
  51. package/dist/pretty-format.js.map +1 -0
  52. package/dist/pretty-widget.d.ts +7 -3
  53. package/dist/pretty-widget.d.ts.map +1 -1
  54. package/dist/pretty-widget.js +74 -57
  55. package/dist/pretty-widget.js.map +1 -1
  56. package/dist/production.d.ts +8 -0
  57. package/dist/production.d.ts.map +1 -0
  58. package/dist/production.js +34 -0
  59. package/dist/production.js.map +1 -0
  60. package/dist/queries.d.ts +99 -56
  61. package/dist/queries.d.ts.map +1 -1
  62. package/dist/queries.js +123 -83
  63. package/dist/queries.js.map +1 -1
  64. package/dist/query-helpers.d.ts +44 -0
  65. package/dist/query-helpers.d.ts.map +1 -0
  66. package/dist/query-helpers.js +57 -0
  67. package/dist/query-helpers.js.map +1 -0
  68. package/dist/render-children.d.ts +9 -0
  69. package/dist/render-children.d.ts.map +1 -0
  70. package/dist/render-children.js +11 -0
  71. package/dist/render-children.js.map +1 -0
  72. package/dist/render.d.ts.map +1 -1
  73. package/dist/render.js +13 -11
  74. package/dist/render.js.map +1 -1
  75. package/dist/role-helpers.d.ts +12 -3
  76. package/dist/role-helpers.d.ts.map +1 -1
  77. package/dist/role-helpers.js +13 -4
  78. package/dist/role-helpers.js.map +1 -1
  79. package/dist/role-naming.d.ts +5 -0
  80. package/dist/role-naming.d.ts.map +1 -0
  81. package/dist/role-naming.js +96 -0
  82. package/dist/role-naming.js.map +1 -0
  83. package/dist/screenshot.d.ts +12 -20
  84. package/dist/screenshot.d.ts.map +1 -1
  85. package/dist/screenshot.js +183 -91
  86. package/dist/screenshot.js.map +1 -1
  87. package/dist/suggestions.d.ts +3 -0
  88. package/dist/suggestions.d.ts.map +1 -1
  89. package/dist/suggestions.js.map +1 -1
  90. package/dist/traversal.d.ts +9 -1
  91. package/dist/traversal.d.ts.map +1 -1
  92. package/dist/traversal.js +26 -6
  93. package/dist/traversal.js.map +1 -1
  94. package/dist/types.d.ts +67 -17
  95. package/dist/types.d.ts.map +1 -1
  96. package/dist/types.js.map +1 -1
  97. package/dist/user-event/adjustment.d.ts +16 -0
  98. package/dist/user-event/adjustment.d.ts.map +1 -1
  99. package/dist/user-event/adjustment.js +34 -2
  100. package/dist/user-event/adjustment.js.map +1 -1
  101. package/dist/user-event/click.d.ts +45 -3
  102. package/dist/user-event/click.d.ts.map +1 -1
  103. package/dist/user-event/click.js +177 -39
  104. package/dist/user-event/click.js.map +1 -1
  105. package/dist/user-event/column-header-click.d.ts +4 -0
  106. package/dist/user-event/column-header-click.d.ts.map +1 -0
  107. package/dist/user-event/column-header-click.js +65 -0
  108. package/dist/user-event/column-header-click.js.map +1 -0
  109. package/dist/user-event/controller.d.ts +29 -0
  110. package/dist/user-event/controller.d.ts.map +1 -1
  111. package/dist/user-event/controller.js +28 -0
  112. package/dist/user-event/controller.js.map +1 -1
  113. package/dist/user-event/event-wrapper.d.ts.map +1 -1
  114. package/dist/user-event/event-wrapper.js +2 -1
  115. package/dist/user-event/event-wrapper.js.map +1 -1
  116. package/dist/user-event/gesture.d.ts +51 -0
  117. package/dist/user-event/gesture.d.ts.map +1 -1
  118. package/dist/user-event/gesture.js +47 -4
  119. package/dist/user-event/gesture.js.map +1 -1
  120. package/dist/user-event/index.d.ts +70 -2
  121. package/dist/user-event/index.d.ts.map +1 -1
  122. package/dist/user-event/index.js +43 -26
  123. package/dist/user-event/index.js.map +1 -1
  124. package/dist/user-event/indexed-children.d.ts +10 -0
  125. package/dist/user-event/indexed-children.d.ts.map +1 -0
  126. package/dist/user-event/indexed-children.js +50 -0
  127. package/dist/user-event/indexed-children.js.map +1 -0
  128. package/dist/user-event/keyboard.d.ts +4 -2
  129. package/dist/user-event/keyboard.d.ts.map +1 -1
  130. package/dist/user-event/keyboard.js +46 -16
  131. package/dist/user-event/keyboard.js.map +1 -1
  132. package/dist/user-event/list-row-click.d.ts +4 -0
  133. package/dist/user-event/list-row-click.d.ts.map +1 -0
  134. package/dist/user-event/list-row-click.js +39 -0
  135. package/dist/user-event/list-row-click.js.map +1 -0
  136. package/dist/user-event/native-click.d.ts +6 -0
  137. package/dist/user-event/native-click.d.ts.map +1 -0
  138. package/dist/user-event/native-click.js +32 -0
  139. package/dist/user-event/native-click.js.map +1 -0
  140. package/dist/user-event/pointer.d.ts +1 -1
  141. package/dist/user-event/pointer.d.ts.map +1 -1
  142. package/dist/user-event/pointer.js +37 -13
  143. package/dist/user-event/pointer.js.map +1 -1
  144. package/dist/user-event/selection.d.ts +18 -0
  145. package/dist/user-event/selection.d.ts.map +1 -1
  146. package/dist/user-event/selection.js +56 -30
  147. package/dist/user-event/selection.js.map +1 -1
  148. package/dist/user-event/state.d.ts +1 -1
  149. package/dist/user-event/state.d.ts.map +1 -1
  150. package/dist/user-event/state.js +1 -1
  151. package/dist/user-event/state.js.map +1 -1
  152. package/dist/user-event/text.d.ts +34 -3
  153. package/dist/user-event/text.d.ts.map +1 -1
  154. package/dist/user-event/text.js +94 -17
  155. package/dist/user-event/text.js.map +1 -1
  156. package/dist/wait-for.d.ts +2 -0
  157. package/dist/wait-for.d.ts.map +1 -1
  158. package/dist/wait-for.js.map +1 -1
  159. package/dist/widget-accessible-properties.d.ts +14 -10
  160. package/dist/widget-accessible-properties.d.ts.map +1 -1
  161. package/dist/widget-accessible-properties.js +135 -173
  162. package/dist/widget-accessible-properties.js.map +1 -1
  163. package/dist/widget-getters.d.ts +8 -0
  164. package/dist/widget-getters.d.ts.map +1 -0
  165. package/dist/widget-getters.js +19 -0
  166. package/dist/widget-getters.js.map +1 -0
  167. package/dist/within.d.ts +3 -2
  168. package/dist/within.d.ts.map +1 -1
  169. package/dist/within.js +3 -2
  170. package/dist/within.js.map +1 -1
  171. package/package.json +13 -8
  172. package/src/accessible-native.ts +333 -0
  173. package/src/act.ts +2 -0
  174. package/src/build-queries.ts +66 -48
  175. package/src/cleanup-registry.ts +1 -1
  176. package/src/config.ts +4 -3
  177. package/src/errors.ts +14 -3
  178. package/src/fire-event.ts +61 -8
  179. package/src/frame-sync.ts +21 -5
  180. package/src/harness-window.ts +9 -0
  181. package/src/index.ts +18 -11
  182. package/src/internal.ts +11 -0
  183. package/src/matchers.ts +466 -64
  184. package/src/pretty-format.ts +1 -0
  185. package/src/pretty-widget.ts +100 -72
  186. package/src/production.ts +52 -0
  187. package/src/queries.ts +128 -89
  188. package/src/query-helpers.ts +97 -0
  189. package/src/render-children.ts +25 -0
  190. package/src/render.tsx +18 -13
  191. package/src/role-helpers.ts +14 -4
  192. package/src/role-naming.ts +99 -0
  193. package/src/screenshot.ts +272 -103
  194. package/src/suggestions.ts +3 -0
  195. package/src/traversal.ts +49 -6
  196. package/src/types.ts +69 -19
  197. package/src/user-event/adjustment.ts +42 -2
  198. package/src/user-event/click.ts +248 -46
  199. package/src/user-event/column-header-click.ts +90 -0
  200. package/src/user-event/controller.ts +29 -0
  201. package/src/user-event/event-wrapper.ts +3 -1
  202. package/src/user-event/gesture.ts +57 -6
  203. package/src/user-event/index.ts +119 -29
  204. package/src/user-event/indexed-children.ts +75 -0
  205. package/src/user-event/keyboard.ts +70 -20
  206. package/src/user-event/list-row-click.ts +57 -0
  207. package/src/user-event/native-click.ts +46 -0
  208. package/src/user-event/pointer.ts +52 -13
  209. package/src/user-event/selection.ts +74 -33
  210. package/src/user-event/state.ts +2 -2
  211. package/src/user-event/text.ts +121 -23
  212. package/src/wait-for.ts +2 -0
  213. package/src/widget-accessible-properties.ts +183 -214
  214. package/src/widget-getters.ts +32 -0
  215. package/src/within.ts +3 -2
@@ -1,5 +1,5 @@
1
1
  type CleanupFunction = () => void | Promise<void>;
2
2
  declare const addToCleanupQueue: (fn: CleanupFunction) => void;
3
3
  declare const runCleanup: () => Promise<void>;
4
- export { addToCleanupQueue, runCleanup, type CleanupFunction };
4
+ export { addToCleanupQueue, runCleanup };
5
5
  //# sourceMappingURL=cleanup-registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cleanup-registry.d.ts","sourceRoot":"","sources":["../src/cleanup-registry.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAIlD,QAAA,MAAM,iBAAiB,GAAI,IAAI,eAAe,KAAG,IAEhD,CAAC;AAEF,QAAA,MAAM,UAAU,QAAa,OAAO,CAAC,IAAI,CAgBxC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"cleanup-registry.d.ts","sourceRoot":"","sources":["../src/cleanup-registry.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAIlD,QAAA,MAAM,iBAAiB,GAAI,IAAI,eAAe,KAAG,IAEhD,CAAC;AAEF,QAAA,MAAM,UAAU,QAAa,OAAO,CAAC,IAAI,CAgBxC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"cleanup-registry.js","sourceRoot":"","sources":["../src/cleanup-registry.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAyB,IAAI,GAAG,EAAE,CAAC;AAErD,MAAM,iBAAiB,GAAG,CAAC,EAAmB,EAAQ,EAAE;IACpD,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,KAAK,IAAmB,EAAE;IACzC,MAAM,QAAQ,GAAc,EAAE,CAAC;IAE/B,KAAK,MAAM,EAAE,IAAI,YAAY,EAAE,CAAC;QAC5B,IAAI,CAAC;YACD,MAAM,EAAE,EAAE,CAAC;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;IACL,CAAC;IAED,YAAY,CAAC,KAAK,EAAE,CAAC;IAErB,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,cAAc,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IACzD,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAwB,CAAC","sourcesContent":["type CleanupFunction = () => void | Promise<void>;\n\nconst cleanupQueue: Set<CleanupFunction> = new Set();\n\nconst addToCleanupQueue = (fn: CleanupFunction): void => {\n cleanupQueue.add(fn);\n};\n\nconst runCleanup = async (): Promise<void> => {\n const failures: unknown[] = [];\n\n for (const fn of cleanupQueue) {\n try {\n await fn();\n } catch (error) {\n failures.push(error);\n }\n }\n\n cleanupQueue.clear();\n\n if (failures.length > 0) {\n throw new AggregateError(failures, \"Cleanup failed\");\n }\n};\n\nexport { addToCleanupQueue, runCleanup, type CleanupFunction };\n"]}
1
+ {"version":3,"file":"cleanup-registry.js","sourceRoot":"","sources":["../src/cleanup-registry.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAyB,IAAI,GAAG,EAAE,CAAC;AAErD,MAAM,iBAAiB,GAAG,CAAC,EAAmB,EAAQ,EAAE;IACpD,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,KAAK,IAAmB,EAAE;IACzC,MAAM,QAAQ,GAAc,EAAE,CAAC;IAE/B,KAAK,MAAM,EAAE,IAAI,YAAY,EAAE,CAAC;QAC5B,IAAI,CAAC;YACD,MAAM,EAAE,EAAE,CAAC;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;IACL,CAAC;IAED,YAAY,CAAC,KAAK,EAAE,CAAC;IAErB,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,cAAc,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IACzD,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,CAAC","sourcesContent":["type CleanupFunction = () => void | Promise<void>;\n\nconst cleanupQueue: Set<CleanupFunction> = new Set();\n\nconst addToCleanupQueue = (fn: CleanupFunction): void => {\n cleanupQueue.add(fn);\n};\n\nconst runCleanup = async (): Promise<void> => {\n const failures: unknown[] = [];\n\n for (const fn of cleanupQueue) {\n try {\n await fn();\n } catch (error) {\n failures.push(error);\n }\n }\n\n cleanupQueue.clear();\n\n if (failures.length > 0) {\n throw new AggregateError(failures, \"Cleanup failed\");\n }\n};\n\nexport { addToCleanupQueue, runCleanup };\n"]}
package/dist/config.d.ts CHANGED
@@ -5,6 +5,7 @@ import type { Container } from "./traversal.js";
5
5
  * checks.
6
6
  */
7
7
  type Config = {
8
+ /** Whether a successful query throws instead, naming a better query, when one is available. */
8
9
  throwSuggestions: boolean;
9
10
  /** Builds the error thrown when a query fails, given a message and optional container. */
10
11
  getElementError: (message: string, container?: Container) => Error;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;GAIG;AACH,KAAK,MAAM,GAAG;IACV,gBAAgB,EAAE,OAAO,CAAC;IAE1B,0FAA0F;IAC1F,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,KAAK,KAAK,CAAC;IAEnE,2EAA2E;IAC3E,gBAAgB,EAAE,MAAM,CAAC;IAEzB,4EAA4E;IAC5E,oBAAoB,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF;;;GAGG;AACH,KAAK,QAAQ,GAAG,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAe5D;;GAEG;AACH,QAAA,MAAM,SAAS,QAAO,MAErB,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,SAAS,GAAI,WAAW,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,KAAG,IAG1D,CAAC;AAMF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;GAIG;AACH,KAAK,MAAM,GAAG;IACV,+FAA+F;IAC/F,gBAAgB,EAAE,OAAO,CAAC;IAE1B,0FAA0F;IAC1F,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,KAAK,KAAK,CAAC;IAEnE,2EAA2E;IAC3E,gBAAgB,EAAE,MAAM,CAAC;IAEzB,4EAA4E;IAC5E,oBAAoB,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF;;;GAGG;AACH,KAAK,QAAQ,GAAG,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAe5D;;GAEG;AACH,QAAA,MAAM,SAAS,QAAO,MAErB,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,SAAS,GAAI,WAAW,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,KAAG,IAG1D,CAAC;AAMF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,CAAC"}
package/dist/config.js CHANGED
@@ -6,7 +6,7 @@ const defaultConfig = {
6
6
  };
7
7
  const currentConfig = { ...defaultConfig };
8
8
  function defaultGetElementError(message) {
9
- return new GtkxElementError(message);
9
+ return new ElementError(message);
10
10
  }
11
11
  /**
12
12
  * Returns the current global testing configuration.
@@ -24,8 +24,8 @@ const configure = (newConfig) => {
24
24
  const updates = typeof newConfig === "function" ? newConfig(currentConfig) : newConfig;
25
25
  Object.assign(currentConfig, updates);
26
26
  };
27
- class GtkxElementError extends Error {
28
- name = "GtkxElementError";
27
+ class ElementError extends Error {
28
+ name = "ElementError";
29
29
  }
30
30
  export { getConfig, configure };
31
31
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AA0BA,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,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACzC,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,gBAAiB,SAAQ,KAAK;IACvB,IAAI,GAAG,kBAAkB,CAAC;CACtC;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 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 GtkxElementError(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 GtkxElementError extends Error {\n override name = \"GtkxElementError\";\n}\n\nexport { getConfig, configure, type Config, type ConfigFn };\n"]}
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"]}
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;I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AO,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,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
@@ -92,9 +92,18 @@ const buildElementError = (container, headLines) => {
92
92
  const config = getConfig();
93
93
  const lines = expensiveErrorDiagnostics.isDisabled
94
94
  ? headLines
95
- : [...headLines, "", prettyWidget(container, { highlight: false })];
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}`];
@@ -116,7 +125,7 @@ const multipleFoundError = (container, descriptor, matches) => {
116
125
  allByVariantHint(descriptor),
117
126
  ];
118
127
  if (!expensiveErrorDiagnostics.isDisabled) {
119
- const renderedMatches = matches.map((widget) => prettyWidget(widget, { highlight: false }));
128
+ const renderedMatches = matches.map((widget) => prettyWidget(widget, { shouldHighlight: false }));
120
129
  headLines.push("", "Here are the matching elements:", "", ...renderedMatches);
121
130
  }
122
131
  return buildElementError(container, headLines);
@@ -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;IACx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AO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QAC5F,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,iCAAiC,EAAE,EAAE,EAAE,GAAG,eAAe,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,iBAAiB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,UAAkB,EAAE,SAAoB,EAAS,EAAE;IACxE,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,2CAA2C,UAAU,IAAI,CAAC;IAE1E,OAAO,MAAM,CAAC,eAAe,CAAC,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, { highlight: 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, { highlight: 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,EAA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AAC,CAAC;QAClG,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,iCAAiC,EAAE,EAAE,EAAE,GAAG,eAAe,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,iBAAiB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,UAAkB,EAAE,SAAoB,EAAS,EAAE;IACxE,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,2CAA2C,UAAU,IAAI,CAAC;IAE1E,OAAO,MAAM,CAAC,eAAe,CAAC,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,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 scheduleNextFrame: (widget: Gtk.Widget) => Promise<void>;
2
3
  declare const scheduleAfterLayout: (widget: Gtk.Widget | null, callback: () => void) => void;
3
- export { scheduleAfterLayout };
4
+ export { scheduleAfterLayout, scheduleNextFrame };
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,mBAAmB,GAAI,QAAQ,GAAG,CAAC,MAAM,GAAG,IAAI,EAAE,UAAU,MAAM,IAAI,KAAG,IAU9E,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,CAAC"}
@@ -10,14 +10,16 @@ const once = (callback) => {
10
10
  callback();
11
11
  };
12
12
  };
13
- const runWhenSized = (widget, finish) => {
13
+ const hasFrameClock = (widget) => widget?.getFrameClock() != null;
14
+ const isSized = (widget) => widget.getWidth() > 0;
15
+ const runUntilReady = (widget, isReady, finish) => {
14
16
  let tickId = 0;
15
17
  const fallback = setTimeout(() => {
16
18
  widget.removeTickCallback(tickId);
17
19
  finish();
18
20
  }, CLOCK_STALL_FALLBACK_MS);
19
21
  tickId = widget.addTickCallback(() => {
20
- if (widget.getWidth() === 0) {
22
+ if (!isReady()) {
21
23
  return GLib.SOURCE_CONTINUE;
22
24
  }
23
25
  clearTimeout(fallback);
@@ -25,13 +27,21 @@ const runWhenSized = (widget, finish) => {
25
27
  return GLib.SOURCE_REMOVE;
26
28
  });
27
29
  };
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, finish);
37
+ });
28
38
  const scheduleAfterLayout = (widget, callback) => {
29
39
  const finish = once(callback);
30
- if (widget?.getFrameClock() == null || widget.getWidth() > 0) {
40
+ if (!hasFrameClock(widget) || isSized(widget)) {
31
41
  queueMicrotask(finish);
32
42
  return;
33
43
  }
34
- runWhenSized(widget, finish);
44
+ runUntilReady(widget, () => isSized(widget), finish);
35
45
  };
36
- export { scheduleAfterLayout };
46
+ export { scheduleAfterLayout, scheduleNextFrame };
37
47
  //# sourceMappingURL=frame-sync.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"frame-sync.js","sourceRoot":"","sources":["../src/frame-sync.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAEtC,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,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,MAAkB,EAAE,MAAkB,EAAQ,EAAE;IAClE,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE;QAC7B,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAClC,MAAM,EAAE,CAAC;IACb,CAAC,EAAE,uBAAuB,CAAC,CAAC;IAE5B,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE;QACjC,IAAI,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,eAAe,CAAC;QAChC,CAAC;QAED,YAAY,CAAC,QAAQ,CAAC,CAAC;QACvB,MAAM,EAAE,CAAC;QAET,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,MAAyB,EAAE,QAAoB,EAAQ,EAAE;IAClF,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAE9B,IAAI,MAAM,EAAE,aAAa,EAAE,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;QAC3D,cAAc,CAAC,MAAM,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;AAEtC,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,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AyB,EAAE,QAAoB,EAAQ,EAAE;IAClF,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAE9B,IAAI,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,MAAM,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,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 hasFrameClock = (widget: Gtk.Widget | null): widget is Gtk.Widget => widget?.getFrameClock() != null;\nconst isSized = (widget: Gtk.Widget): boolean => widget.getWidth() > 0;\n\nconst runUntilReady = (widget: Gtk.Widget, isReady: () => boolean, 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 (!isReady()) {\n return GLib.SOURCE_CONTINUE;\n }\n\n clearTimeout(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, finish);\n });\n\nconst scheduleAfterLayout = (widget: Gtk.Widget | null, callback: () => void): void => {\n const finish = once(callback);\n\n if (!hasFrameClock(widget) || isSized(widget)) {\n queueMicrotask(finish);\n\n return;\n }\n\n runUntilReady(widget, () => isSized(widget), finish);\n};\n\nexport { scheduleAfterLayout, scheduleNextFrame };\n"]}
@@ -0,0 +1,4 @@
1
+ import * as Gtk from "@gtkx/gi/gtk";
2
+ declare const createHarnessWindow: () => Gtk.Window;
3
+ export { createHarnessWindow };
4
+ //# 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;AAKpC,QAAA,MAAM,mBAAmB,QAAO,GAAG,CAAC,MAC4D,CAAC;AAEjG,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ import * as Gtk from "@gtkx/gi/gtk";
2
+ const HARNESS_WINDOW_WIDTH = 800;
3
+ const HARNESS_WINDOW_HEIGHT = 600;
4
+ const createHarnessWindow = () => new Gtk.Window({ defaultWidth: HARNESS_WINDOW_WIDTH, defaultHeight: HARNESS_WINDOW_HEIGHT });
5
+ export { createHarnessWindow };
6
+ //# 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;AAElC,MAAM,mBAAmB,GAAG,GAAe,EAAE,CACzC,IAAI,GAAG,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,oBAAoB,EAAE,aAAa,EAAE,qBAAqB,EAAE,CAAC,CAAC;AAEjG,OAAO,EAAE,mBAAmB,EAAE,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\n\nconst HARNESS_WINDOW_WIDTH = 800;\nconst HARNESS_WINDOW_HEIGHT = 600;\n\nconst createHarnessWindow = (): Gtk.Window =>\n new Gtk.Window({ defaultWidth: HARNESS_WINDOW_WIDTH, defaultHeight: HARNESS_WINDOW_HEIGHT });\n\nexport { createHarnessWindow };\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":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A4B,CAAC;AACpC,YAAY,EACR,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EACX,UAAU,EACV,WAAW,EACX,SAAS,EACT,gBAAgB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,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"}
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,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAQ/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,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;AAEtB,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,QAAQ,EAAE,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,4 @@
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
+ //# 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"}
@@ -0,0 +1,4 @@
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
+ //# 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","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\";\n"]}