@gtkx/testing 1.0.0-rc.2 → 1.0.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +4 -5
  2. package/dist/act.d.ts +2 -0
  3. package/dist/act.d.ts.map +1 -1
  4. package/dist/act.js.map +1 -1
  5. package/dist/bound-queries.d.ts +2 -3
  6. package/dist/bound-queries.d.ts.map +1 -1
  7. package/dist/bound-queries.js.map +1 -1
  8. package/dist/build-queries.d.ts.map +1 -1
  9. package/dist/build-queries.js +18 -7
  10. package/dist/build-queries.js.map +1 -1
  11. package/dist/config.d.ts +1 -0
  12. package/dist/config.d.ts.map +1 -1
  13. package/dist/config.js +3 -3
  14. package/dist/config.js.map +1 -1
  15. package/dist/errors.js +2 -2
  16. package/dist/errors.js.map +1 -1
  17. package/dist/index.d.ts +7 -4
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +4 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/matchers.d.ts +125 -21
  22. package/dist/matchers.d.ts.map +1 -1
  23. package/dist/matchers.js +258 -21
  24. package/dist/matchers.js.map +1 -1
  25. package/dist/normalize.d.ts +10 -0
  26. package/dist/normalize.d.ts.map +1 -0
  27. package/dist/normalize.js +20 -0
  28. package/dist/normalize.js.map +1 -0
  29. package/dist/pretty-widget.d.ts +2 -1
  30. package/dist/pretty-widget.d.ts.map +1 -1
  31. package/dist/pretty-widget.js +3 -3
  32. package/dist/pretty-widget.js.map +1 -1
  33. package/dist/queries.d.ts +4 -21
  34. package/dist/queries.d.ts.map +1 -1
  35. package/dist/queries.js +46 -59
  36. package/dist/queries.js.map +1 -1
  37. package/dist/render.js +3 -3
  38. package/dist/render.js.map +1 -1
  39. package/dist/suggestions.d.ts +3 -0
  40. package/dist/suggestions.d.ts.map +1 -1
  41. package/dist/suggestions.js.map +1 -1
  42. package/dist/traversal.d.ts +5 -0
  43. package/dist/traversal.d.ts.map +1 -1
  44. package/dist/traversal.js +1 -0
  45. package/dist/traversal.js.map +1 -1
  46. package/dist/types.d.ts +69 -5
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/types.js.map +1 -1
  49. package/dist/user-event/adjustment.d.ts +13 -0
  50. package/dist/user-event/adjustment.d.ts.map +1 -1
  51. package/dist/user-event/adjustment.js +11 -0
  52. package/dist/user-event/adjustment.js.map +1 -1
  53. package/dist/user-event/click.d.ts +7 -0
  54. package/dist/user-event/click.d.ts.map +1 -1
  55. package/dist/user-event/click.js +7 -0
  56. package/dist/user-event/click.js.map +1 -1
  57. package/dist/user-event/controller.d.ts +31 -1
  58. package/dist/user-event/controller.d.ts.map +1 -1
  59. package/dist/user-event/controller.js +36 -1
  60. package/dist/user-event/controller.js.map +1 -1
  61. package/dist/user-event/gesture.d.ts +51 -0
  62. package/dist/user-event/gesture.d.ts.map +1 -1
  63. package/dist/user-event/gesture.js +47 -4
  64. package/dist/user-event/gesture.js.map +1 -1
  65. package/dist/user-event/index.d.ts +27 -0
  66. package/dist/user-event/index.d.ts.map +1 -1
  67. package/dist/user-event/index.js.map +1 -1
  68. package/dist/user-event/keyboard.d.ts +4 -2
  69. package/dist/user-event/keyboard.d.ts.map +1 -1
  70. package/dist/user-event/keyboard.js +13 -12
  71. package/dist/user-event/keyboard.js.map +1 -1
  72. package/dist/user-event/pointer.js +5 -5
  73. package/dist/user-event/pointer.js.map +1 -1
  74. package/dist/user-event/selection.d.ts +15 -0
  75. package/dist/user-event/selection.d.ts.map +1 -1
  76. package/dist/user-event/selection.js +15 -0
  77. package/dist/user-event/selection.js.map +1 -1
  78. package/dist/user-event/state.d.ts +1 -1
  79. package/dist/user-event/state.d.ts.map +1 -1
  80. package/dist/user-event/state.js +1 -1
  81. package/dist/user-event/state.js.map +1 -1
  82. package/dist/user-event/text.d.ts +30 -3
  83. package/dist/user-event/text.d.ts.map +1 -1
  84. package/dist/user-event/text.js +28 -1
  85. package/dist/user-event/text.js.map +1 -1
  86. package/dist/wait-for.d.ts +2 -0
  87. package/dist/wait-for.d.ts.map +1 -1
  88. package/dist/wait-for.js.map +1 -1
  89. package/dist/widget-accessible-properties.d.ts +28 -2
  90. package/dist/widget-accessible-properties.d.ts.map +1 -1
  91. package/dist/widget-accessible-properties.js +129 -10
  92. package/dist/widget-accessible-properties.js.map +1 -1
  93. package/dist/within.js.map +1 -1
  94. package/package.json +7 -7
  95. package/src/act.ts +2 -0
  96. package/src/bound-queries.ts +2 -3
  97. package/src/build-queries.ts +20 -8
  98. package/src/config.ts +4 -3
  99. package/src/errors.ts +2 -2
  100. package/src/index.ts +11 -2
  101. package/src/matchers.ts +500 -53
  102. package/src/normalize.ts +28 -0
  103. package/src/pretty-widget.ts +5 -4
  104. package/src/queries.ts +79 -105
  105. package/src/render.tsx +3 -3
  106. package/src/suggestions.ts +3 -0
  107. package/src/traversal.ts +5 -0
  108. package/src/types.ts +88 -4
  109. package/src/user-event/adjustment.ts +13 -0
  110. package/src/user-event/click.ts +7 -0
  111. package/src/user-event/controller.ts +50 -1
  112. package/src/user-event/gesture.ts +57 -6
  113. package/src/user-event/index.ts +27 -0
  114. package/src/user-event/keyboard.ts +18 -16
  115. package/src/user-event/pointer.ts +5 -5
  116. package/src/user-event/selection.ts +15 -0
  117. package/src/user-event/state.ts +2 -2
  118. package/src/user-event/text.ts +31 -4
  119. package/src/wait-for.ts +2 -0
  120. package/src/widget-accessible-properties.ts +188 -10
  121. package/src/within.ts +1 -1
package/README.md CHANGED
@@ -6,7 +6,8 @@
6
6
 
7
7
  <p align="center">
8
8
  The React framework for Linux.<br />
9
- Build GTK4 and Adwaita apps in TypeScript, with React components and hooks driving GNOME's own widgets. What you ship is a GNOME app.
9
+ Write native Linux applications with React and TypeScript.
10
+ Built on the GNOME stack and standard web tooling.
10
11
  </p>
11
12
 
12
13
  <p align="center">
@@ -20,15 +21,13 @@
20
21
 
21
22
  <p align="center">
22
23
  <a href="https://gtkx.dev">Homepage</a> &middot;
23
- <a href="https://gtkx.dev/guide/why-gtkx">Documentation</a> &middot;
24
+ <a href="https://gtkx.dev/guide/getting-started">Documentation</a> &middot;
24
25
  <a href="https://github.com/gtkx-org/gtkx/tree/main/examples">Examples</a> &middot;
25
26
  <a href="https://github.com/gtkx-org/gtkx/blob/main/CONTRIBUTING.md">Contributing</a>
26
27
  </p>
27
28
 
28
29
  ---
29
30
 
30
- GTKX generates fully typed bindings for the entire GTK4 and Adwaita surface directly from GObject-Introspection. On top of those bindings you get the React programming model: components and hooks driving GObject instances, with Fast Refresh while you develop.
31
-
32
31
  <p align="center">
33
32
  <img src="https://raw.githubusercontent.com/gtkx-org/gtkx/main/examples/tutorial/assets/screenshot.png" alt="The Tasks app: an Adwaita window with a sidebar of smart views and colored lists on the left, and a boxed task list on the right." />
34
33
  </p>
@@ -109,7 +108,7 @@ React Native and similar frameworks hide the native toolkit so one API can run e
109
108
 
110
109
  ### Why Node.js, and why generated bindings
111
110
 
112
- GTKX runs on Node.js, which puts native modules, the npm ecosystem, and the tooling built for Node.js APIs within reach. GJS is GNOME's own runtime, built on SpiderMonkey rather than V8; node-gtk runs on Node.js but is lightly maintained, on the older nan/V8 ABI rather than N-API, and still centered on GTK3. The [why-gtkx guide](https://gtkx.dev/guide/why-gtkx) covers the comparison in full.
111
+ GTKX runs on Node.js, which puts native modules, the npm ecosystem, and the tooling built for Node.js APIs within reach. GJS is GNOME's own runtime, built on SpiderMonkey rather than V8; node-gtk runs on Node.js but is lightly maintained, on the older nan/V8 ABI rather than N-API, and still centered on GTK3. The [Why GTKX guide](https://gtkx.dev/guide/why-gtkx) covers the comparison in full.
113
112
 
114
113
  GTKX generates the TypeScript types and the native FFI calls from the same GObject-Introspection data, so the types cannot drift from the calls they back. Codegen covers the whole GTK4 and Adwaita surface.
115
114
 
package/dist/act.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  declare global {
2
2
  var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;
3
3
  }
4
+ /** Work run inside the act environment, either synchronous or asynchronous. */
4
5
  type ActCallback<T> = () => T | PromiseLike<T>;
6
+ /** Runs a callback inside React's act environment and settles with its result once updates flush. */
5
7
  type ActImplementation = <T>(callback: ActCallback<T>) => PromiseLike<T>;
6
8
  /**
7
9
  * Runs a callback inside React's act environment, flushing pending state
package/dist/act.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"act.d.ts","sourceRoot":"","sources":["../src/act.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,CAAC;IACX,IAAI,wBAAwB,EAAE,OAAO,GAAG,SAAS,CAAC;CACrD;AAED,KAAK,WAAW,CAAC,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAC/C,KAAK,iBAAiB,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC;AAGzE;;;;;;GAMG;AACH,QAAA,MAAM,GAAG,EAAE,iBAA+D,CAAC;AAU3E,QAAA,MAAM,wBAAwB,QAAO,OAAO,GAAG,SAAqD,CAAC;AAErG,QAAA,MAAM,wBAAwB,GAAI,OAAO,OAAO,GAAG,SAAS,KAAG,IAE9D,CAAC;AAaF,QAAA,MAAM,qBAAqB,GAAI,CAAC,EAAE,UAAU,OAAO,EAAE,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAkB5F,CAAC;AAUF,QAAA,MAAM,QAAQ,GAAU,UAAU,MAAM,OAAO,KAAG,OAAO,CAAC,IAAI,CAE7D,CAAC;AAEF,OAAO,EAAE,GAAG,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"act.d.ts","sourceRoot":"","sources":["../src/act.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,CAAC;IACX,IAAI,wBAAwB,EAAE,OAAO,GAAG,SAAS,CAAC;C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C,IAAI,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAEvF,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,QAAQ,GAAG,KAAK,EAAE,QAAuB,EAAiB,EAAE;IAC9D,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF,OAAO,EAAE,GAAG,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import { act as reactAct } from \"react\";\n\ndeclare global {\n var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;\n}\n\ntype ActCallback<T> = () => T | PromiseLike<T>;\ntype ActImplementation = <T>(callback: ActCallback<T>) => PromiseLike<T>;\n\nconst actImplementation: ActImplementation = reactAct;\n/**\n * Runs a callback inside React's act environment, flushing pending state\n * updates and effects, and resolves once the work has settled.\n *\n * @param callback Work to run within the act environment.\n * @returns A promise that resolves with the callback's result after updates flush.\n */\nconst act: ActImplementation = withGlobalActEnvironment(actImplementation);\n\nconst getGlobalThis = (): typeof globalThis => {\n if (typeof globalThis !== \"undefined\") {\n return globalThis;\n }\n\n throw new Error(\"unable to locate global object\");\n};\n\nconst getIsReactActEnvironment = (): boolean | undefined => getGlobalThis().IS_REACT_ACT_ENVIRONMENT;\n\nconst setIsReactActEnvironment = (value: boolean | undefined): void => {\n getGlobalThis().IS_REACT_ACT_ENVIRONMENT = value;\n};\n\nconst isThenable = <T>(value: unknown): value is PromiseLike<T> =>\n value !== null && typeof value === \"object\" && typeof (value as PromiseLike<T>).then === \"function\";\n\nconst restoreAfter = async <T>(result: PromiseLike<T>, previous: boolean | undefined): Promise<T> => {\n try {\n return await result;\n } finally {\n setIsReactActEnvironment(previous);\n }\n};\n\nconst runWithActEnvironment = <T>(isForced: boolean, fn: () => T | PromiseLike<T>): Promise<T> => {\n const previousActEnvironment = getIsReactActEnvironment();\n setIsReactActEnvironment(isForced);\n\n try {\n const result: T | PromiseLike<T> = fn();\n\n if (isThenable<T>(result)) {\n return restoreAfter(result, previousActEnvironment);\n }\n\n setIsReactActEnvironment(previousActEnvironment);\n\n return Promise.resolve(result);\n } catch (error) {\n setIsReactActEnvironment(previousActEnvironment);\n throw error;\n }\n};\n\nfunction withGlobalActEnvironment(actImplementation: ActImplementation): ActImplementation {\n return <T>(callback: ActCallback<T>): PromiseLike<T> => {\n const settled = runWithActEnvironment(true, () => actImplementation(() => callback()));\n\n return Promise.resolve(settled);\n };\n}\n\nconst runInAct = async (callback: () => unknown): Promise<void> => {\n await act(() => callback());\n};\n\nexport { act, getIsReactActEnvironment, setIsReactActEnvironment, runWithActEnvironment, runInAct };\n"]}
1
+ {"version":3,"file":"act.js","sourceRoot":"","sources":["../src/act.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,QAAQ,EAAE,MAAM,OAAO,CAAC;AAWxC,MAAM,iBAAiB,GAAsB,QAAQ,CAAC;AACtD;;;;;;GAMG;AACH,MAAM,GAAG,GAAsB,wBAAwB,CAAC,iBAAiB,CAAC,CAAC;AAE3E,MAAM,aAAa,GAAG,GAAsB,EAAE;IAC1C,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE,CAAC;QACpC,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;AACtD,CAAC,CAAC;AAEF,MAAM,wBAAwB,GAAG,GAAwB,EAAE,CAAC,aAAa,EAAE,CAAC,wBAAwB,CAAC;AAErG,MAAM,wBAAwB,GAAG,CAAC,KAA0B,EAAQ,EAAE;IAClE,aAAa,EAAE,CAAC,wBAAwB,GAAG,KAAK,CAAC;AACrD,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAI,KAAc,EAA2B,EAAE,CAC9D,KAAK,KAA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AAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF,OAAO,EAAE,GAAG,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import { act as reactAct } from \"react\";\n\ndeclare global {\n var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;\n}\n\n/** Work run inside the act environment, either synchronous or asynchronous. */\ntype ActCallback<T> = () => T | PromiseLike<T>;\n/** Runs a callback inside React's act environment and settles with its result once updates flush. */\ntype ActImplementation = <T>(callback: ActCallback<T>) => PromiseLike<T>;\n\nconst actImplementation: ActImplementation = reactAct;\n/**\n * Runs a callback inside React's act environment, flushing pending state\n * updates and effects, and resolves once the work has settled.\n *\n * @param callback Work to run within the act environment.\n * @returns A promise that resolves with the callback's result after updates flush.\n */\nconst act: ActImplementation = withGlobalActEnvironment(actImplementation);\n\nconst getGlobalThis = (): typeof globalThis => {\n if (typeof globalThis !== \"undefined\") {\n return globalThis;\n }\n\n throw new Error(\"unable to locate global object\");\n};\n\nconst getIsReactActEnvironment = (): boolean | undefined => getGlobalThis().IS_REACT_ACT_ENVIRONMENT;\n\nconst setIsReactActEnvironment = (value: boolean | undefined): void => {\n getGlobalThis().IS_REACT_ACT_ENVIRONMENT = value;\n};\n\nconst isThenable = <T>(value: unknown): value is PromiseLike<T> =>\n value !== null && typeof value === \"object\" && typeof (value as PromiseLike<T>).then === \"function\";\n\nconst restoreAfter = async <T>(result: PromiseLike<T>, previous: boolean | undefined): Promise<T> => {\n try {\n return await result;\n } finally {\n setIsReactActEnvironment(previous);\n }\n};\n\nconst runWithActEnvironment = <T>(isForced: boolean, fn: () => T | PromiseLike<T>): Promise<T> => {\n const previousActEnvironment = getIsReactActEnvironment();\n setIsReactActEnvironment(isForced);\n\n try {\n const result: T | PromiseLike<T> = fn();\n\n if (isThenable<T>(result)) {\n return restoreAfter(result, previousActEnvironment);\n }\n\n setIsReactActEnvironment(previousActEnvironment);\n\n return Promise.resolve(result);\n } catch (error) {\n setIsReactActEnvironment(previousActEnvironment);\n throw error;\n }\n};\n\nfunction withGlobalActEnvironment(actImplementation: ActImplementation): ActImplementation {\n return <T>(callback: ActCallback<T>): PromiseLike<T> => {\n const settled = runWithActEnvironment(true, () => actImplementation(() => callback()));\n\n return Promise.resolve(settled);\n };\n}\n\nconst runInAct = async (callback: () => unknown): Promise<void> => {\n await act(() => callback());\n};\n\nexport { act, getIsReactActEnvironment, setIsReactActEnvironment, runWithActEnvironment, runInAct };\n"]}
@@ -1,13 +1,12 @@
1
1
  import type * as Gtk from "@gtkx/gi/gtk";
2
2
  import type { ReactNode } from "react";
3
- import type { builtinQueries } from "./queries.js";
4
3
  import type { Container } from "./traversal.js";
5
- import type { BoundCustomQueries, DebugUtilities, QueryMap } from "./types.js";
4
+ import type { BoundCustomQueries, DebugUtilities, QueryFamilies, QueryMap } from "./types.js";
6
5
  /**
7
6
  * The set of built-in queries (getBy, findBy, queryBy, and their All variants)
8
7
  * bound to a specific container.
9
8
  */
10
- type BoundQueries = BoundCustomQueries<typeof builtinQueries>;
9
+ type BoundQueries = QueryFamilies<[]>;
11
10
  /**
12
11
  * The global screen object's shape: built-in queries scoped to the current
13
12
  * toplevels, plus debug utilities.
@@ -1 +1 @@
1
- {"version":3,"file":"bound-queries.d.ts","sourceRoot":"","sources":["../src/bound-queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE/E;;;GAGG;AACH,KAAK,YAAY,GAAG,kBAAkB,CAAC,OAAO,cAAc,C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IAC1D,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC;IACtB,sEAAsE;IACtE,WAAW,EAAE,SAAS,CAAC;IACvB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,qEAAqE;IACrE,QAAQ,EAAE,CAAC,OAAO,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD,CAAC;AAEN,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"bound-queries.js","sourceRoot":"","sources":["../src/bound-queries.ts"],"names":[],"mappings":"AAoCA,OAAO,EAAqD,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { ReactNode } from \"react\";\nimport type { builtinQueries } from \"./queries.js\";\nimport type { Container } from \"./traversal.js\";\nimport type { BoundCustomQueries, DebugUtilities, QueryMap } from \"./types.js\";\n\n/**\n * The set of built-in queries (getBy, findBy, queryBy, and their All variants)\n * bound to a specific container.\n */\ntype BoundQueries = BoundCustomQueries<typeof builtinQueries>;\n/**\n * The global screen object's shape: built-in queries scoped to the current\n * toplevels, plus debug utilities.\n */\ntype Screen = BoundQueries & DebugUtilities;\n\n/**\n * The result of a render call: queries scoped to the rendered tree, debug\n * utilities, and controls for updating or tearing down the render.\n *\n * @typeParam Q Custom queries provided at render time, merged with the built-in ones.\n */\ntype RenderResult<Q extends QueryMap = Record<never, never>> = BoundQueries &\n BoundCustomQueries<Q> &\n DebugUtilities & {\n /** The top-level widget the element was rendered into. */\n container: Gtk.Widget;\n /** The root the queries are scoped to (defaults to all toplevels). */\n baseElement: Container;\n /** Unmounts the rendered tree and disposes its resources. */\n unmount: () => Promise<void>;\n /** Re-renders the tree with a new element, reusing the same root. */\n rerender: (element: ReactNode) => Promise<void>;\n };\n\nexport { type BoundQueries, type Screen, type RenderResult };\n"]}
1
+ {"version":3,"file":"bound-queries.js","sourceRoot":"","sources":["../src/bound-queries.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAqD,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { ReactNode } from \"react\";\nimport type { Container } from \"./traversal.js\";\nimport type { BoundCustomQueries, DebugUtilities, QueryFamilies, QueryMap } from \"./types.js\";\n\n/**\n * The set of built-in queries (getBy, findBy, queryBy, and their All variants)\n * bound to a specific container.\n */\ntype BoundQueries = QueryFamilies<[]>;\n/**\n * The global screen object's shape: built-in queries scoped to the current\n * toplevels, plus debug utilities.\n */\ntype Screen = BoundQueries & DebugUtilities;\n\n/**\n * The result of a render call: queries scoped to the rendered tree, debug\n * utilities, and controls for updating or tearing down the render.\n *\n * @typeParam Q Custom queries provided at render time, merged with the built-in ones.\n */\ntype RenderResult<Q extends QueryMap = Record<never, never>> = BoundQueries &\n BoundCustomQueries<Q> &\n DebugUtilities & {\n /** The top-level widget the element was rendered into. */\n container: Gtk.Widget;\n /** The root the queries are scoped to (defaults to all toplevels). */\n baseElement: Container;\n /** Unmounts the rendered tree and disposes its resources. */\n unmount: () => Promise<void>;\n /** Re-renders the tree with a new element, reusing the same root. */\n rerender: (element: ReactNode) => Promise<void>;\n };\n\nexport { type BoundQueries, type Screen, type RenderResult };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"build-queries.d.ts","sourceRoot":"","sources":["../src/build-queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,OAAO,EAAqB,KAAK,MAAM,EAAgB,MAAM,kBAAkB,CAAC;AAGhF,KAAK,UAAU,CAAC,IAAI,SAAS,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC;AAEhG,KAAK,oBAAoB,CAAC,IAAI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AS,OAAO,EAAE,EACxC,WAAW,MAAM,EACjB,YAAY,UAAU,CAAC,IAAI,CAAC,EAC5B,kBAAkB,oBAAoB,CAAC,IAAI,CAAC,EAC5C,iBAAiB,mBAAmB,CAAC,IAAI,CAAC,KAC3C,YAAY,CAAC,IAAI,CA6CnB,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,CAAC"}
@@ -10,7 +10,7 @@ const extractWaitForOptions = (args) => {
10
10
  }
11
11
  return {};
12
12
  };
13
- const extractSuggestOption = (args) => {
13
+ const extractShouldSuggest = (args) => {
14
14
  const last = args.at(-1);
15
15
  if (last && typeof last === "object" && !(last instanceof RegExp)) {
16
16
  return last.suggest;
@@ -18,9 +18,8 @@ const extractSuggestOption = (args) => {
18
18
  return undefined;
19
19
  };
20
20
  const maybeThrowSuggestion = (options) => {
21
- const { container, match, queryName, variant, suggest } = options;
22
- const shouldSuggest = suggest ?? getConfig().throwSuggestions;
23
- if (!shouldSuggest) {
21
+ const { container, match, queryName, variant, shouldSuggest } = options;
22
+ if (!(shouldSuggest ?? getConfig().throwSuggestions)) {
24
23
  return;
25
24
  }
26
25
  const suggestion = getSuggestedQuery(match, variant);
@@ -66,7 +65,13 @@ const allOrThrow = (allQuery, getMissingError) => (container, ...args) => {
66
65
  const wrapSingleWithSuggestion = (query, queryName, variant) => (container, ...args) => {
67
66
  const match = query(container, ...args);
68
67
  if (match) {
69
- maybeThrowSuggestion({ container, match, queryName, variant, suggest: extractSuggestOption(args) });
68
+ maybeThrowSuggestion({
69
+ container,
70
+ match,
71
+ queryName,
72
+ variant,
73
+ shouldSuggest: extractShouldSuggest(args),
74
+ });
70
75
  }
71
76
  return match;
72
77
  };
@@ -79,7 +84,7 @@ const wrapAllWithSuggestion = (query, queryName, variant) => (container, ...args
79
84
  match: first,
80
85
  queryName,
81
86
  variant,
82
- suggest: extractSuggestOption(args),
87
+ shouldSuggest: extractShouldSuggest(args),
83
88
  });
84
89
  }
85
90
  return matches;
@@ -98,7 +103,13 @@ const buildQueries = (queryName, queryAllBy, getMultipleError, getMissingError)
98
103
  const getAllByWithSuggestion = wrapAllWithSuggestion(getAllBy, queryName, "getAll");
99
104
  const getByWithSuggestion = (container, ...args) => {
100
105
  const match = getBy(container, ...args);
101
- maybeThrowSuggestion({ container, match, queryName, variant: "get", suggest: extractSuggestOption(args) });
106
+ maybeThrowSuggestion({
107
+ container,
108
+ match,
109
+ queryName,
110
+ variant: "get",
111
+ shouldSuggest: extractShouldSuggest(args),
112
+ });
102
113
  return match;
103
114
  };
104
115
  const findAllBy = (container, ...args) => waitFor(() => runWithExpensiveErrorDiagnosticsDisabled(() => getAllByWithSuggestion(container, ...args)), findOptions(getAllByWithSuggestion, container, args));
@@ -1 +1 @@
1
- {"version":3,"file":"build-queries.js","sourceRoot":"","sources":["../src/build-queries.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,wCAAwC,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAA6B,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAuBxC,MAAM,qBAAqB,GAAG,CAAC,IAAe,EAAkB,EAAE;IAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzB,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,YAAY,MAAM,CAAC,EAAE,CAAC;QAChE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAsB,CAAC;QAEhE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAC5C,CAAC;IAED,OAAO,EAAE,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,IAAe,EA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C9B,QAAQ,EAAE,sBAAsB;QAChC,KAAK,EAAE,mBAAmB;QAC1B,SAAS;QACT,MAAM;KACT,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAsC,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { Container } from \"./traversal.js\";\nimport type { MatcherOptions, WaitForOptions } from \"./types.js\";\nimport { getConfig } from \"./config.js\";\nimport { runWithExpensiveErrorDiagnosticsDisabled, suggestionError } from \"./errors.js\";\nimport { getSuggestedQuery, type Method, type Variant } from \"./suggestions.js\";\nimport { waitFor } from \"./wait-for.js\";\n\ntype QueryAllBy<Args extends unknown[]> = (container: Container, ...args: Args) => Gtk.Widget[];\n\ntype MultipleErrorBuilder<Args extends unknown[]> = (\n container: Container,\n matches: Gtk.Widget[],\n ...args: Args\n) => Error;\n\ntype MissingErrorBuilder<Args extends unknown[]> = (container: Container, ...args: Args) => Error;\n\ntype BuiltQueries<Args extends unknown[]> = {\n queryBy: (container: Container, ...args: Args) => Gtk.Widget | null;\n getAllBy: QueryAllBy<Args>;\n getBy: (container: Container, ...args: Args) => Gtk.Widget;\n findAllBy: (container: Container, ...args: Args) => Promise<Gtk.Widget[]>;\n findBy: (container: Container, ...args: Args) => Promise<Gtk.Widget>;\n};\n\ntype FindQuery<Args extends unknown[]> = (container: Container, ...args: Args) => unknown;\ntype SingleQuery<Args extends unknown[]> = (container: Container, ...args: Args) => Gtk.Widget | null;\n\nconst extractWaitForOptions = (args: unknown[]): WaitForOptions => {\n const last = args.at(-1);\n\n if (last && typeof last === \"object\" && !(last instanceof RegExp)) {\n const { timeout, interval, onTimeout } = last as WaitForOptions;\n\n return { timeout, interval, onTimeout };\n }\n\n return {};\n};\n\nconst extractSuggestOption = (args: unknown[]): boolean | undefined => {\n const last = args.at(-1);\n\n if (last && typeof last === \"object\" && !(last instanceof RegExp)) {\n return (last as MatcherOptions).suggest;\n }\n\n return undefined;\n};\n\nconst maybeThrowSuggestion = (options: {\n container: Container;\n match: Gtk.Widget;\n queryName: Method;\n variant: Variant;\n suggest: boolean | undefined;\n}): void => {\n const { container, match, queryName, variant, suggest } = options;\n const shouldSuggest = suggest ?? getConfig().throwSuggestions;\n\n if (!shouldSuggest) {\n return;\n }\n\n const suggestion = getSuggestedQuery(match, variant);\n\n if (suggestion && suggestion.queryName !== queryName) {\n throw suggestionError(suggestion.toString(), container);\n }\n};\n\nconst reRunForDiagnostics = <Args extends unknown[]>(\n query: FindQuery<Args>,\n container: Container,\n args: Args,\n fallback: Error,\n): Error => {\n try {\n query(container, ...args);\n } catch (error) {\n if (error instanceof Error) {\n return error;\n }\n }\n\n return fallback;\n};\n\nconst findOptions = <Args extends unknown[]>(\n query: FindQuery<Args>,\n container: Container,\n args: Args,\n): WaitForOptions => {\n const userOptions = extractWaitForOptions(args);\n\n const onTimeout =\n userOptions.onTimeout ?? ((fallback: Error) => reRunForDiagnostics(query, container, args, fallback));\n\n return {\n stackTraceError: new Error(\"STACK_TRACE_MESSAGE\"),\n onTimeout,\n timeout: userOptions.timeout,\n interval: userOptions.interval,\n };\n};\n\nconst singleFrom =\n <Args extends unknown[]>(\n allQuery: QueryAllBy<Args>,\n getMultipleError: MultipleErrorBuilder<Args>,\n ): SingleQuery<Args> =>\n (container, ...args) => {\n const matches = allQuery(container, ...args);\n\n if (matches.length > 1) {\n throw getMultipleError(container, matches, ...args);\n }\n\n return matches[0] ?? null;\n };\n\nconst allOrThrow =\n <Args extends unknown[]>(\n allQuery: QueryAllBy<Args>,\n getMissingError: MissingErrorBuilder<Args>,\n ): QueryAllBy<Args> =>\n (container, ...args) => {\n const matches = allQuery(container, ...args);\n\n if (matches.length === 0) {\n throw getMissingError(container, ...args);\n }\n\n return matches;\n };\n\nconst wrapSingleWithSuggestion =\n <Args extends unknown[]>(query: SingleQuery<Args>, queryName: Method, variant: Variant): SingleQuery<Args> =>\n (container, ...args) => {\n const match = query(container, ...args);\n\n if (match) {\n maybeThrowSuggestion({ container, match, queryName, variant, suggest: extractSuggestOption(args) });\n }\n\n return match;\n };\n\nconst wrapAllWithSuggestion =\n <Args extends unknown[]>(query: QueryAllBy<Args>, queryName: Method, variant: Variant): QueryAllBy<Args> =>\n (container, ...args) => {\n const matches = query(container, ...args);\n const [first] = matches;\n\n if (first !== undefined) {\n maybeThrowSuggestion({\n container,\n match: first,\n queryName,\n variant,\n suggest: extractSuggestOption(args),\n });\n }\n\n return matches;\n };\n\nconst requireSingle =\n <Args extends unknown[]>(query: SingleQuery<Args>, getMissingError: MissingErrorBuilder<Args>) =>\n (container: Container, ...args: Args): Gtk.Widget => {\n const match = query(container, ...args);\n\n if (match === null) {\n throw getMissingError(container, ...args);\n }\n\n return match;\n };\n\nconst buildQueries = <Args extends unknown[]>(\n queryName: Method,\n queryAllBy: QueryAllBy<Args>,\n getMultipleError: MultipleErrorBuilder<Args>,\n getMissingError: MissingErrorBuilder<Args>,\n): BuiltQueries<Args> => {\n const getAllBy = allOrThrow(queryAllBy, getMissingError);\n const getBy = requireSingle(singleFrom(getAllBy, getMultipleError), getMissingError);\n\n const queryByWithSuggestion = wrapSingleWithSuggestion(\n singleFrom(queryAllBy, getMultipleError),\n queryName,\n \"query\",\n );\n\n const getAllByWithSuggestion = wrapAllWithSuggestion(getAllBy, queryName, \"getAll\");\n\n const getByWithSuggestion: (container: Container, ...args: Args) => Gtk.Widget = (container, ...args) => {\n const match = getBy(container, ...args);\n maybeThrowSuggestion({ container, match, queryName, variant: \"get\", suggest: extractSuggestOption(args) });\n\n return match;\n };\n\n const findAllBy = (container: Container, ...args: Args): Promise<Gtk.Widget[]> =>\n waitFor(\n () => runWithExpensiveErrorDiagnosticsDisabled(() => getAllByWithSuggestion(container, ...args)),\n findOptions(getAllByWithSuggestion, container, args),\n );\n\n const findBy = (container: Container, ...args: Args): Promise<Gtk.Widget> =>\n waitFor(\n () => runWithExpensiveErrorDiagnosticsDisabled(() => getByWithSuggestion(container, ...args)),\n findOptions(getByWithSuggestion, container, args),\n );\n\n return {\n queryBy: queryByWithSuggestion,\n getAllBy: getAllByWithSuggestion,\n getBy: getByWithSuggestion,\n findAllBy,\n findBy,\n };\n};\n\nexport { buildQueries, type QueryAllBy, type BuiltQueries };\n"]}
1
+ {"version":3,"file":"build-queries.js","sourceRoot":"","sources":["../src/build-queries.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,wCAAwC,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAA6B,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAuBxC,MAAM,qBAAqB,GAAG,CAAC,IAAe,EAAkB,EAAE;IAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzB,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,YAAY,MAAM,CAAC,EAAE,CAAC;QAChE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAsB,CAAC;QAEhE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAC5C,CAAC;IAED,OAAO,EAAE,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,IAAe,EAAuB,EAAE;IAClE,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzB,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,YAAY,MAAM,CAAC,EAAE,CAAC;QAChE,OAAQ,IAAuB,CAAC,OAAO,CAAC;IAC5C,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,OAM7B,EAAQ,EAAE;IACP,MAAM,EAAE,S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AAC,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE;QACpG,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;QAExC,oBAAoB,CAAC;YACjB,SAAS;YACT,KAAK;YACL,SAAS;YACT,OAAO,EAAE,KAAK;YACd,aAAa,EAAE,oBAAoB,CAAC,IAAI,CAAC;SAC5C,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC;IAEF,MAAM,SAAS,GAAG,CAAC,SAAoB,EAAE,GAAG,IAAU,EAAyB,EAAE,CAC7E,OAAO,CACH,GAAG,EAAE,CAAC,wCAAwC,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC,EAChG,WAAW,CAAC,sBAAsB,EAAE,SAAS,EAAE,IAAI,CAAC,CACvD,CAAC;IAEN,MAAM,MAAM,GAAG,CAAC,SAAoB,EAAE,GAAG,IAAU,EAAuB,EAAE,CACxE,OAAO,CACH,GAAG,EAAE,CAAC,wCAAwC,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC,EAC7F,WAAW,CAAC,mBAAmB,EAAE,SAAS,EAAE,IAAI,CAAC,CACpD,CAAC;IAEN,OAAO;QACH,OAAO,EAAE,qBAAqB;QAC9B,QAAQ,EAAE,sBAAsB;QAChC,KAAK,EAAE,mBAAmB;QAC1B,SAAS;QACT,MAAM;KACT,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAsC,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { Container } from \"./traversal.js\";\nimport type { MatcherOptions, WaitForOptions } from \"./types.js\";\nimport { getConfig } from \"./config.js\";\nimport { runWithExpensiveErrorDiagnosticsDisabled, suggestionError } from \"./errors.js\";\nimport { getSuggestedQuery, type Method, type Variant } from \"./suggestions.js\";\nimport { waitFor } from \"./wait-for.js\";\n\ntype QueryAllBy<Args extends unknown[]> = (container: Container, ...args: Args) => Gtk.Widget[];\n\ntype MultipleErrorBuilder<Args extends unknown[]> = (\n container: Container,\n matches: Gtk.Widget[],\n ...args: Args\n) => Error;\n\ntype MissingErrorBuilder<Args extends unknown[]> = (container: Container, ...args: Args) => Error;\n\ntype BuiltQueries<Args extends unknown[]> = {\n queryBy: (container: Container, ...args: Args) => Gtk.Widget | null;\n getAllBy: QueryAllBy<Args>;\n getBy: (container: Container, ...args: Args) => Gtk.Widget;\n findAllBy: (container: Container, ...args: Args) => Promise<Gtk.Widget[]>;\n findBy: (container: Container, ...args: Args) => Promise<Gtk.Widget>;\n};\n\ntype FindQuery<Args extends unknown[]> = (container: Container, ...args: Args) => unknown;\ntype SingleQuery<Args extends unknown[]> = (container: Container, ...args: Args) => Gtk.Widget | null;\n\nconst extractWaitForOptions = (args: unknown[]): WaitForOptions => {\n const last = args.at(-1);\n\n if (last && typeof last === \"object\" && !(last instanceof RegExp)) {\n const { timeout, interval, onTimeout } = last as WaitForOptions;\n\n return { timeout, interval, onTimeout };\n }\n\n return {};\n};\n\nconst extractShouldSuggest = (args: unknown[]): boolean | undefined => {\n const last = args.at(-1);\n\n if (last && typeof last === \"object\" && !(last instanceof RegExp)) {\n return (last as MatcherOptions).suggest;\n }\n\n return undefined;\n};\n\nconst maybeThrowSuggestion = (options: {\n container: Container;\n match: Gtk.Widget;\n queryName: Method;\n variant: Variant;\n shouldSuggest: boolean | undefined;\n}): void => {\n const { container, match, queryName, variant, shouldSuggest } = options;\n\n if (!(shouldSuggest ?? getConfig().throwSuggestions)) {\n return;\n }\n\n const suggestion = getSuggestedQuery(match, variant);\n\n if (suggestion && suggestion.queryName !== queryName) {\n throw suggestionError(suggestion.toString(), container);\n }\n};\n\nconst reRunForDiagnostics = <Args extends unknown[]>(\n query: FindQuery<Args>,\n container: Container,\n args: Args,\n fallback: Error,\n): Error => {\n try {\n query(container, ...args);\n } catch (error) {\n if (error instanceof Error) {\n return error;\n }\n }\n\n return fallback;\n};\n\nconst findOptions = <Args extends unknown[]>(\n query: FindQuery<Args>,\n container: Container,\n args: Args,\n): WaitForOptions => {\n const userOptions = extractWaitForOptions(args);\n\n const onTimeout =\n userOptions.onTimeout ?? ((fallback: Error) => reRunForDiagnostics(query, container, args, fallback));\n\n return {\n stackTraceError: new Error(\"STACK_TRACE_MESSAGE\"),\n onTimeout,\n timeout: userOptions.timeout,\n interval: userOptions.interval,\n };\n};\n\nconst singleFrom =\n <Args extends unknown[]>(\n allQuery: QueryAllBy<Args>,\n getMultipleError: MultipleErrorBuilder<Args>,\n ): SingleQuery<Args> =>\n (container, ...args) => {\n const matches = allQuery(container, ...args);\n\n if (matches.length > 1) {\n throw getMultipleError(container, matches, ...args);\n }\n\n return matches[0] ?? null;\n };\n\nconst allOrThrow =\n <Args extends unknown[]>(\n allQuery: QueryAllBy<Args>,\n getMissingError: MissingErrorBuilder<Args>,\n ): QueryAllBy<Args> =>\n (container, ...args) => {\n const matches = allQuery(container, ...args);\n\n if (matches.length === 0) {\n throw getMissingError(container, ...args);\n }\n\n return matches;\n };\n\nconst wrapSingleWithSuggestion =\n <Args extends unknown[]>(query: SingleQuery<Args>, queryName: Method, variant: Variant): SingleQuery<Args> =>\n (container, ...args) => {\n const match = query(container, ...args);\n\n if (match) {\n maybeThrowSuggestion({\n container,\n match,\n queryName,\n variant,\n shouldSuggest: extractShouldSuggest(args),\n });\n }\n\n return match;\n };\n\nconst wrapAllWithSuggestion =\n <Args extends unknown[]>(query: QueryAllBy<Args>, queryName: Method, variant: Variant): QueryAllBy<Args> =>\n (container, ...args) => {\n const matches = query(container, ...args);\n const [first] = matches;\n\n if (first !== undefined) {\n maybeThrowSuggestion({\n container,\n match: first,\n queryName,\n variant,\n shouldSuggest: extractShouldSuggest(args),\n });\n }\n\n return matches;\n };\n\nconst requireSingle =\n <Args extends unknown[]>(query: SingleQuery<Args>, getMissingError: MissingErrorBuilder<Args>) =>\n (container: Container, ...args: Args): Gtk.Widget => {\n const match = query(container, ...args);\n\n if (match === null) {\n throw getMissingError(container, ...args);\n }\n\n return match;\n };\n\nconst buildQueries = <Args extends unknown[]>(\n queryName: Method,\n queryAllBy: QueryAllBy<Args>,\n getMultipleError: MultipleErrorBuilder<Args>,\n getMissingError: MissingErrorBuilder<Args>,\n): BuiltQueries<Args> => {\n const getAllBy = allOrThrow(queryAllBy, getMissingError);\n const getBy = requireSingle(singleFrom(getAllBy, getMultipleError), getMissingError);\n\n const queryByWithSuggestion = wrapSingleWithSuggestion(\n singleFrom(queryAllBy, getMultipleError),\n queryName,\n \"query\",\n );\n\n const getAllByWithSuggestion = wrapAllWithSuggestion(getAllBy, queryName, \"getAll\");\n\n const getByWithSuggestion: (container: Container, ...args: Args) => Gtk.Widget = (container, ...args) => {\n const match = getBy(container, ...args);\n\n maybeThrowSuggestion({\n container,\n match,\n queryName,\n variant: \"get\",\n shouldSuggest: extractShouldSuggest(args),\n });\n\n return match;\n };\n\n const findAllBy = (container: Container, ...args: Args): Promise<Gtk.Widget[]> =>\n waitFor(\n () => runWithExpensiveErrorDiagnosticsDisabled(() => getAllByWithSuggestion(container, ...args)),\n findOptions(getAllByWithSuggestion, container, args),\n );\n\n const findBy = (container: Container, ...args: Args): Promise<Gtk.Widget> =>\n waitFor(\n () => runWithExpensiveErrorDiagnosticsDisabled(() => getByWithSuggestion(container, ...args)),\n findOptions(getByWithSuggestion, container, args),\n );\n\n return {\n queryBy: queryByWithSuggestion,\n getAllBy: getAllByWithSuggestion,\n getBy: getByWithSuggestion,\n findAllBy,\n findBy,\n };\n};\n\nexport { buildQueries, type QueryAllBy, type BuiltQueries };\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.js CHANGED
@@ -92,7 +92,7 @@ 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
98
  const notFoundError = (container, descriptor) => {
@@ -116,7 +116,7 @@ const multipleFoundError = (container, descriptor, matches) => {
116
116
  allByVariantHint(descriptor),
117
117
  ];
118
118
  if (!expensiveErrorDiagnostics.isDisabled) {
119
- const renderedMatches = matches.map((widget) => prettyWidget(widget, { highlight: false }));
119
+ const renderedMatches = matches.map((widget) => prettyWidget(widget, { shouldHighlight: false }));
120
120
  headLines.push("", "Here are the matching elements:", "", ...renderedMatches);
121
121
  }
122
122
  return buildElementError(container, headLines);
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa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AkB,WAAW,yBAAyB;QACrF,EAAE;QACF,gBAAgB,CAAC,UAAU,CAAC;KAC/B,CAAC;IAEF,IAAI,CAAC,yBAAyB,CAAC,UAAU,EAAE,CAAC;QACxC,MAAM,eAAe,GAAG,OAAO,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,C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AAe,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, { 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"]}
package/dist/index.d.ts CHANGED
@@ -4,11 +4,12 @@ export type { BoundQueries, RenderResult, Screen } from "./bound-queries.js";
4
4
  export type { Config, ConfigFn } from "./config.js";
5
5
  export { configure, getConfig } from "./config.js";
6
6
  export { fireEvent } from "./fire-event.js";
7
- export type { TextExpectation } from "./matchers.js";
7
+ export type { ClassExpectation, TextContentOptions, TextExpectation } from "./matchers.js";
8
8
  export { matchers, registerMatchers } from "./matchers.js";
9
+ export { getDefaultNormalizer } from "./normalize.js";
9
10
  export type { PrettyWidgetOptions } from "./pretty-widget.js";
10
11
  export { logWidget, prettyWidget } from "./pretty-widget.js";
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, getDefaultNormalizer, queryAllByDisplayValue, queryAllByLabelText, queryAllByName, queryAllByPlaceholderText, queryAllByRole, queryAllByText, queryByDisplayValue, queryByLabelText, queryByName, queryByPlaceholderText, queryByRole, queryByText, } from "./queries.js";
12
+ 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
13
  export { renderHook } from "./render-hook.js";
13
14
  export { cleanup, render } from "./render.js";
14
15
  export { formatRole, getRoles, logRoles, prettyRoles } from "./role-helpers.js";
@@ -17,10 +18,12 @@ export { captureAndSaveScreenshot, logScreenshotPath, screenshot } from "./scree
17
18
  export type { Method, Suggestion, Variant } from "./suggestions.js";
18
19
  export { getSuggestedQuery } from "./suggestions.js";
19
20
  export type { Container } from "./traversal.js";
20
- export type { ByRoleOptions, ByRoleValue, Matcher, MatcherFunction, MatcherOptions, NormalizerFn, NormalizerOptions, RenderHookOptions, RenderHookResult, RenderOptions, ScreenshotOptions, ScreenshotResult, WaitForOptions, WindowSelector, WrapperComponent, } from "./types.js";
21
+ export type { ByRoleOptions, ByRoleValue, WidgetType, Matcher, MatcherFunction, MatcherOptions, NormalizerFn, NormalizerOptions, RenderHookOptions, RenderHookResult, RenderOptions, ScreenshotOptions, ScreenshotResult, WaitForOptions, WindowSelector, WrapperComponent, } from "./types.js";
22
+ export type { ControllerConstructor } from "./user-event/controller.js";
23
+ export { getAllControllers, getController, queryAllControllers, queryController, } from "./user-event/controller.js";
21
24
  export type { DragOffset, DragOptions, DropContent, DropOptions, PointerInput, ScrollDelta, TabOptions, TypeOptions, UserEvent, } from "./user-event/index.js";
22
25
  export { userEvent } from "./user-event/index.js";
23
26
  export { waitFor, waitForElementToBeRemoved } from "./wait-for.js";
24
- export { getWidgetErrorMessage, getWidgetInvalidState, getWidgetNodeText, } from "./widget-accessible-properties.js";
27
+ export { getWidgetErrorMessage, getWidgetInvalidState, getWidgetNodeText, getWidgetTextContent, } from "./widget-accessible-properties.js";
25
28
  export { within } from "./within.js";
26
29
  //# 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,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC3D,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,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,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,cAAc,EACd,yBAAyB,EACzB,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,sBAAsB,EACtB,WAAW,EACX,W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AU,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;AAC1F,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EACR,aAAa,EACb,WAAW,EACX,UAAU,EACV,OAAO,EACP,eAAe,EACf,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,gBAAgB,GACnB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EACH,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,eAAe,GAClB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACR,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EACX,UAAU,EACV,WAAW,EACX,SAAS,GACZ,MAAM,uBAAuB,CAAC;AAC/B,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"}
package/dist/index.js CHANGED
@@ -3,16 +3,18 @@ export { act } from "./act.js";
3
3
  export { configure, getConfig } from "./config.js";
4
4
  export { fireEvent } from "./fire-event.js";
5
5
  export { matchers, registerMatchers } from "./matchers.js";
6
+ export { getDefaultNormalizer } from "./normalize.js";
6
7
  export { logWidget, prettyWidget } from "./pretty-widget.js";
7
- 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, getDefaultNormalizer, queryAllByDisplayValue, queryAllByLabelText, queryAllByName, queryAllByPlaceholderText, queryAllByRole, queryAllByText, queryByDisplayValue, queryByLabelText, queryByName, queryByPlaceholderText, queryByRole, queryByText, } from "./queries.js";
8
+ 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";
8
9
  export { renderHook } from "./render-hook.js";
9
10
  export { cleanup, render } from "./render.js";
10
11
  export { formatRole, getRoles, logRoles, prettyRoles } from "./role-helpers.js";
11
12
  export { screen } from "./screen.js";
12
13
  export { captureAndSaveScreenshot, logScreenshotPath, screenshot } from "./screenshot.js";
13
14
  export { getSuggestedQuery } from "./suggestions.js";
15
+ export { getAllControllers, getController, queryAllControllers, queryController, } from "./user-event/controller.js";
14
16
  export { userEvent } from "./user-event/index.js";
15
17
  export { waitFor, waitForElementToBeRemoved } from "./wait-for.js";
16
- export { getWidgetErrorMessage, getWidgetInvalidState, getWidgetNodeText, } from "./widget-accessible-properties.js";
18
+ export { getWidgetErrorMessage, getWidgetInvalidState, getWidgetNodeText, getWidgetTextContent, } from "./widget-accessible-properties.js";
17
19
  export { within } from "./within.js";
18
20
  //# 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;AAE3D,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,oBAAoB,EACpB,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;AA8BrD,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,GACpB,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 { TextExpectation } from \"./matchers.js\";\nexport { matchers, registerMatchers } from \"./matchers.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 getDefaultNormalizer,\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 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 {\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} 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;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,kB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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"]}