@gtkx/testing 1.0.0-rc.1 → 1.0.0-rc.3

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 (187) hide show
  1. package/dist/act.d.ts +6 -6
  2. package/dist/act.d.ts.map +1 -1
  3. package/dist/act.js +34 -26
  4. package/dist/act.js.map +1 -1
  5. package/dist/bound-queries.d.ts +5 -5
  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 +5 -5
  9. package/dist/build-queries.d.ts.map +1 -1
  10. package/dist/build-queries.js +21 -9
  11. package/dist/build-queries.js.map +1 -1
  12. package/dist/cleanup-registry.d.ts +4 -3
  13. package/dist/cleanup-registry.d.ts.map +1 -1
  14. package/dist/cleanup-registry.js +13 -3
  15. package/dist/cleanup-registry.js.map +1 -1
  16. package/dist/config.d.ts +5 -4
  17. package/dist/config.d.ts.map +1 -1
  18. package/dist/config.js +11 -9
  19. package/dist/config.js.map +1 -1
  20. package/dist/editable.d.ts +6 -5
  21. package/dist/editable.d.ts.map +1 -1
  22. package/dist/editable.js +7 -5
  23. package/dist/editable.js.map +1 -1
  24. package/dist/errors.d.ts +7 -6
  25. package/dist/errors.d.ts.map +1 -1
  26. package/dist/errors.js +64 -48
  27. package/dist/errors.js.map +1 -1
  28. package/dist/fire-event.d.ts +2 -1
  29. package/dist/fire-event.d.ts.map +1 -1
  30. package/dist/fire-event.js +2 -1
  31. package/dist/fire-event.js.map +1 -1
  32. package/dist/frame-sync.d.ts +2 -1
  33. package/dist/frame-sync.d.ts.map +1 -1
  34. package/dist/frame-sync.js +28 -21
  35. package/dist/frame-sync.js.map +1 -1
  36. package/dist/index.d.ts +9 -6
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +5 -3
  39. package/dist/index.js.map +1 -1
  40. package/dist/matchers.d.ts +99 -35
  41. package/dist/matchers.d.ts.map +1 -1
  42. package/dist/matchers.js +314 -63
  43. package/dist/matchers.js.map +1 -1
  44. package/dist/normalize.d.ts +10 -0
  45. package/dist/normalize.d.ts.map +1 -0
  46. package/dist/normalize.js +20 -0
  47. package/dist/normalize.js.map +1 -0
  48. package/dist/pretty-widget.d.ts +6 -4
  49. package/dist/pretty-widget.d.ts.map +1 -1
  50. package/dist/pretty-widget.js +64 -24
  51. package/dist/pretty-widget.js.map +1 -1
  52. package/dist/queries.d.ts +129 -90
  53. package/dist/queries.d.ts.map +1 -1
  54. package/dist/queries.js +235 -164
  55. package/dist/queries.js.map +1 -1
  56. package/dist/register-test-hooks.js +2 -1
  57. package/dist/register-test-hooks.js.map +1 -1
  58. package/dist/render-hook.d.ts +3 -2
  59. package/dist/render-hook.d.ts.map +1 -1
  60. package/dist/render-hook.js +2 -1
  61. package/dist/render-hook.js.map +1 -1
  62. package/dist/render.d.ts +3 -2
  63. package/dist/render.d.ts.map +1 -1
  64. package/dist/render.js +25 -19
  65. package/dist/render.js.map +1 -1
  66. package/dist/role-helpers.d.ts +6 -5
  67. package/dist/role-helpers.d.ts.map +1 -1
  68. package/dist/role-helpers.js +16 -12
  69. package/dist/role-helpers.js.map +1 -1
  70. package/dist/screen.d.ts +4 -3
  71. package/dist/screen.d.ts.map +1 -1
  72. package/dist/screen.js +13 -11
  73. package/dist/screen.js.map +1 -1
  74. package/dist/screenshot.d.ts +4 -3
  75. package/dist/screenshot.d.ts.map +1 -1
  76. package/dist/screenshot.js +43 -36
  77. package/dist/screenshot.js.map +1 -1
  78. package/dist/suggestions.d.ts +11 -6
  79. package/dist/suggestions.d.ts.map +1 -1
  80. package/dist/suggestions.js +10 -5
  81. package/dist/suggestions.js.map +1 -1
  82. package/dist/traversal.d.ts +7 -7
  83. package/dist/traversal.d.ts.map +1 -1
  84. package/dist/traversal.js +17 -11
  85. package/dist/traversal.js.map +1 -1
  86. package/dist/types.d.ts +65 -24
  87. package/dist/types.d.ts.map +1 -1
  88. package/dist/types.js.map +1 -1
  89. package/dist/user-event/adjustment.d.ts +5 -3
  90. package/dist/user-event/adjustment.d.ts.map +1 -1
  91. package/dist/user-event/adjustment.js +6 -4
  92. package/dist/user-event/adjustment.js.map +1 -1
  93. package/dist/user-event/click.d.ts +6 -5
  94. package/dist/user-event/click.d.ts.map +1 -1
  95. package/dist/user-event/click.js +29 -21
  96. package/dist/user-event/click.js.map +1 -1
  97. package/dist/user-event/controller.d.ts +7 -5
  98. package/dist/user-event/controller.d.ts.map +1 -1
  99. package/dist/user-event/controller.js +16 -6
  100. package/dist/user-event/controller.js.map +1 -1
  101. package/dist/user-event/dispatch.d.ts +3 -3
  102. package/dist/user-event/dispatch.d.ts.map +1 -1
  103. package/dist/user-event/dispatch.js +3 -2
  104. package/dist/user-event/dispatch.js.map +1 -1
  105. package/dist/user-event/event-wrapper.d.ts +2 -1
  106. package/dist/user-event/event-wrapper.d.ts.map +1 -1
  107. package/dist/user-event/event-wrapper.js +27 -16
  108. package/dist/user-event/event-wrapper.js.map +1 -1
  109. package/dist/user-event/gesture.d.ts +18 -14
  110. package/dist/user-event/gesture.d.ts.map +1 -1
  111. package/dist/user-event/gesture.js +70 -37
  112. package/dist/user-event/gesture.js.map +1 -1
  113. package/dist/user-event/index.d.ts +17 -10
  114. package/dist/user-event/index.d.ts.map +1 -1
  115. package/dist/user-event/index.js +7 -3
  116. package/dist/user-event/index.js.map +1 -1
  117. package/dist/user-event/keyboard.d.ts +4 -3
  118. package/dist/user-event/keyboard.d.ts.map +1 -1
  119. package/dist/user-event/keyboard.js +89 -58
  120. package/dist/user-event/keyboard.js.map +1 -1
  121. package/dist/user-event/pointer.d.ts +7 -3
  122. package/dist/user-event/pointer.d.ts.map +1 -1
  123. package/dist/user-event/pointer.js +4 -1
  124. package/dist/user-event/pointer.js.map +1 -1
  125. package/dist/user-event/selection.d.ts +3 -2
  126. package/dist/user-event/selection.d.ts.map +1 -1
  127. package/dist/user-event/selection.js +26 -27
  128. package/dist/user-event/selection.js.map +1 -1
  129. package/dist/user-event/state.d.ts +3 -2
  130. package/dist/user-event/state.d.ts.map +1 -1
  131. package/dist/user-event/state.js +2 -1
  132. package/dist/user-event/state.js.map +1 -1
  133. package/dist/user-event/text.d.ts +8 -7
  134. package/dist/user-event/text.d.ts.map +1 -1
  135. package/dist/user-event/text.js +39 -33
  136. package/dist/user-event/text.js.map +1 -1
  137. package/dist/wait-for.d.ts +5 -5
  138. package/dist/wait-for.d.ts.map +1 -1
  139. package/dist/wait-for.js +45 -30
  140. package/dist/wait-for.js.map +1 -1
  141. package/dist/widget-accessible-properties.d.ts +36 -25
  142. package/dist/widget-accessible-properties.d.ts.map +1 -1
  143. package/dist/widget-accessible-properties.js +215 -68
  144. package/dist/widget-accessible-properties.js.map +1 -1
  145. package/dist/within.d.ts +2 -1
  146. package/dist/within.d.ts.map +1 -1
  147. package/dist/within.js +2 -1
  148. package/dist/within.js.map +1 -1
  149. package/package.json +11 -9
  150. package/src/act.ts +44 -35
  151. package/src/bound-queries.ts +6 -6
  152. package/src/build-queries.ts +84 -43
  153. package/src/cleanup-registry.ts +18 -5
  154. package/src/config.ts +16 -12
  155. package/src/editable.ts +13 -6
  156. package/src/errors.ts +106 -45
  157. package/src/fire-event.ts +3 -1
  158. package/src/frame-sync.ts +38 -21
  159. package/src/index.ts +13 -3
  160. package/src/matchers.ts +568 -114
  161. package/src/normalize.ts +28 -0
  162. package/src/pretty-widget.ts +114 -42
  163. package/src/queries.ts +418 -256
  164. package/src/register-test-hooks.ts +4 -1
  165. package/src/render-hook.tsx +10 -4
  166. package/src/render.tsx +59 -34
  167. package/src/role-helpers.ts +29 -16
  168. package/src/screen.ts +17 -12
  169. package/src/screenshot.ts +61 -38
  170. package/src/suggestions.ts +29 -10
  171. package/src/traversal.ts +35 -15
  172. package/src/types.ts +111 -32
  173. package/src/user-event/adjustment.ts +23 -10
  174. package/src/user-event/click.ts +49 -20
  175. package/src/user-event/controller.ts +41 -7
  176. package/src/user-event/dispatch.ts +4 -2
  177. package/src/user-event/event-wrapper.ts +42 -16
  178. package/src/user-event/gesture.ts +135 -50
  179. package/src/user-event/index.ts +19 -12
  180. package/src/user-event/keyboard.ts +147 -61
  181. package/src/user-event/pointer.ts +20 -8
  182. package/src/user-event/selection.ts +69 -32
  183. package/src/user-event/state.ts +4 -2
  184. package/src/user-event/text.ts +73 -38
  185. package/src/wait-for.ts +77 -36
  186. package/src/widget-accessible-properties.ts +385 -79
  187. package/src/within.ts +8 -5
@@ -1 +1 @@
1
- {"version":3,"file":"queries.js","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAqB,YAAY,EAAmB,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAkB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,EACH,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,cAAc,GACjB,MAAM,mCAAmC,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EACjC,IAAI,GAAG,IAAI,EACX,kBAAkB,GAAG,IAAI,GAC5B,GAAsB,EAAE,EAAgB,EAAE;IACvC,OAAO,CAAC,IAAY,EAAU,EAAE;QAC5B,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,IAAI,IAAI,EAAE,CAAC;YACP,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;QAC3B,CAAC;QAED,IAAI,kBAAkB,EAAE,CAAC;YACrB,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC5C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AW,CAAC,YAAY,CAAC;AACrF,wGAAwG;AACxG,MAAM,CAAC,MAAM,SAAS,GAAgC,WAAW,CAAC,SAAS,CAAC;AAC5E,kIAAkI;AAClI,MAAM,CAAC,MAAM,aAAa,GAAoC,WAAW,CAAC,aAAa,CAAC;AACxF,yKAAyK;AACzK,MAAM,CAAC,MAAM,UAAU,GAAiC,WAAW,CAAC,UAAU,CAAC;AAE/E,4HAA4H;AAC5H,MAAM,CAAC,MAAM,sBAAsB,GAC/B,sBAAsB,CAAC,sBAAsB,CAAC;AAClD,mFAAmF;AACnF,MAAM,CAAC,MAAM,uBAAuB,GAChC,sBAAsB,CAAC,uBAAuB,CAAC;AACnD,2GAA2G;AAC3G,MAAM,CAAC,MAAM,oBAAoB,GAA2C,sBAAsB,CAAC,oBAAoB,CAAC;AACxH,qIAAqI;AACrI,MAAM,CAAC,MAAM,wBAAwB,GACjC,sBAAsB,CAAC,wBAAwB,CAAC;AACpD,4KAA4K;AAC5K,MAAM,CAAC,MAAM,qBAAqB,GAC9B,sBAAsB,CAAC,qBAAqB,CAAC;AAEjD,2HAA2H;AAC3H,MAAM,CAAC,MAAM,mBAAmB,GAA0C,mBAAmB,CAAC,mBAAmB,CAAC;AAClH,kFAAkF;AAClF,MAAM,CAAC,MAAM,oBAAoB,GAA2C,mBAAmB,CAAC,oBAAoB,CAAC;AACrH,0GAA0G;AAC1G,MAAM,CAAC,MAAM,iBAAiB,GAAwC,mBAAmB,CAAC,iBAAiB,CAAC;AAC5G,oIAAoI;AACpI,MAAM,CAAC,MAAM,qBAAqB,GAA4C,mBAAmB,CAAC,qBAAqB,CAAC;AACxH,2KAA2K;AAC3K,MAAM,CAAC,MAAM,kBAAkB,GAAyC,mBAAmB,CAAC,kBAAkB,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { type BuiltQueries, buildQueries, type QueryAllBy } from \"./build-queries.js\";\nimport { multipleFoundError, notFoundError } from \"./errors.js\";\nimport { type Container, findAll, traverse } from \"./traversal.js\";\nimport type { ByRoleOptions, ByRoleValue, Matcher, MatcherOptions, NormalizerFn, NormalizerOptions } from \"./types.js\";\nimport {\n getWidgetAccessibleName,\n getWidgetBusyState,\n getWidgetCheckedState,\n getWidgetDescription,\n getWidgetDisplayValue,\n getWidgetExpandedState,\n getWidgetLabelledByText,\n getWidgetLabelText,\n getWidgetLevel,\n getWidgetName,\n getWidgetOwnLabel,\n getWidgetPlaceholderText,\n getWidgetPressedState,\n getWidgetSelectedState,\n getWidgetValue,\n isInaccessible,\n} from \"./widget-accessible-properties.js\";\n\n/**\n * Builds the default text normalizer, which optionally trims surrounding whitespace and collapses runs of whitespace into single spaces.\n * @param options Toggles for trimming and whitespace collapsing.\n * @returns A function that normalizes a string for comparison against a matcher.\n */\nexport const getDefaultNormalizer = ({\n trim = true,\n collapseWhitespace = true,\n}: NormalizerOptions = {}): NormalizerFn => {\n return (text: string): string => {\n let result = text;\n if (trim) {\n result = result.trim();\n }\n\n if (collapseWhitespace) {\n result = result.replaceAll(/\\s+/g, \" \");\n }\n\n return result;\n };\n};\n\nconst buildNormalizer = (options?: MatcherOptions): NormalizerFn => {\n const { normalizer, trim, collapseWhitespace } = options ?? {};\n\n if (!normalizer) {\n return getDefaultNormalizer({ trim, collapseWhitespace });\n }\n\n if (trim !== undefined || collapseWhitespace !== undefined) {\n throw new Error(\n \"trim and collapseWhitespace are not supported with a normalizer. \" +\n \"If you want to use the default trim and collapseWhitespace logic in your normalizer, \" +\n 'use \"getDefaultNormalizer({ trim, collapseWhitespace })\" and compose that into your normalizer',\n );\n }\n\n return normalizer;\n};\n\nconst normalizeText = (text: string, options?: MatcherOptions): string => {\n const normalizer = buildNormalizer(options);\n return normalizer(text);\n};\n\nconst matchText = (actual: string | null, expected: Matcher, widget: Gtk.Widget, options?: MatcherOptions): boolean => {\n if (actual === null) return false;\n\n const normalizedActual = normalizeText(actual, options);\n\n if (typeof expected === \"function\") {\n return expected(normalizedActual, widget);\n }\n\n if (expected instanceof RegExp) {\n expected.lastIndex = 0;\n return expected.test(normalizedActual);\n }\n\n const normalizedExpected = normalizeText(String(expected), options);\n const exact = options?.exact ?? true;\n return exact\n ? normalizedActual === normalizedExpected\n : normalizedActual.toLowerCase().includes(normalizedExpected.toLowerCase());\n};\n\nconst matchAccessibleName = (widget: Gtk.Widget, options: ByRoleOptions): boolean => {\n if (options.name === undefined) return true;\n const text = getWidgetAccessibleName(widget);\n return matchText(text, options.name, widget, options);\n};\n\nconst matchAccessibleValue = (widget: Gtk.Widget, value: ByRoleValue, options: ByRoleOptions): boolean => {\n const actual = getWidgetValue(widget);\n if (value.now !== undefined && actual.now !== value.now) return false;\n if (value.min !== undefined && actual.min !== value.min) return false;\n if (value.max !== undefined && actual.max !== value.max) return false;\n if (value.text !== undefined && !matchText(actual.text, value.text, widget, options)) return false;\n return true;\n};\n\nconst matchBooleanStates = (widget: Gtk.Widget, options: ByRoleOptions): boolean => {\n if (options.checked !== undefined && getWidgetCheckedState(widget) !== options.checked) return false;\n if (options.pressed !== undefined && getWidgetPressedState(widget) !== options.pressed) return false;\n if (options.expanded !== undefined && getWidgetExpandedState(widget) !== options.expanded) return false;\n if (options.selected !== undefined && getWidgetSelectedState(widget) !== options.selected) return false;\n if (options.busy !== undefined && (getWidgetBusyState(widget) ?? false) !== options.busy) return false;\n return true;\n};\n\nconst matchAccessibleStates = (widget: Gtk.Widget, options: ByRoleOptions): boolean => {\n if (!matchBooleanStates(widget, options)) return false;\n if (options.level !== undefined && getWidgetLevel(widget) !== options.level) return false;\n if (\n options.description !== undefined &&\n !matchText(getWidgetDescription(widget), options.description, widget, options)\n )\n return false;\n if (options.value !== undefined && !matchAccessibleValue(widget, options.value, options)) return false;\n return true;\n};\n\nconst matchByRoleOptions = (widget: Gtk.Widget, options?: ByRoleOptions): boolean => {\n if (!options) return true;\n return matchAccessibleName(widget, options) && matchAccessibleStates(widget, options);\n};\n\ntype NamedFamily<Suffix extends string, Args extends unknown[]> = {\n [P in `queryBy${Suffix}`]: (container: Container, ...args: Args) => Gtk.Widget | null;\n} & {\n [P in `queryAllBy${Suffix}`]: (container: Container, ...args: Args) => Gtk.Widget[];\n} & {\n [P in `getBy${Suffix}`]: (container: Container, ...args: Args) => Gtk.Widget;\n} & {\n [P in `getAllBy${Suffix}`]: (container: Container, ...args: Args) => Gtk.Widget[];\n} & {\n [P in `findBy${Suffix}`]: (container: Container, ...args: Args) => Promise<Gtk.Widget>;\n} & {\n [P in `findAllBy${Suffix}`]: (container: Container, ...args: Args) => Promise<Gtk.Widget[]>;\n};\n\nconst nameQueryFamily = <Suffix extends string, Args extends unknown[]>(\n suffix: Suffix,\n queryAllBy: QueryAllBy<Args>,\n built: BuiltQueries<Args>,\n): NamedFamily<Suffix, Args> => {\n const family = {\n [`queryBy${suffix}`]: built.queryBy,\n [`queryAllBy${suffix}`]: queryAllBy,\n [`getBy${suffix}`]: built.getBy,\n [`getAllBy${suffix}`]: built.getAllBy,\n [`findBy${suffix}`]: built.findBy,\n [`findAllBy${suffix}`]: built.findAllBy,\n };\n return family as NamedFamily<Suffix, Args>;\n};\n\n/**\n * Finds every widget under the container whose accessible role matches `role` and that satisfies the given options.\n * Widgets excluded from the accessibility tree are skipped unless `options.hidden` is set.\n * @param container Widget subtree to search.\n * @param role Accessible role to match.\n * @param options Additional accessible name, state, and value constraints.\n * @returns Every matching widget, or an empty array when none match.\n */\nexport const queryAllByRole = (container: Container, role: Gtk.AccessibleRole, options?: ByRoleOptions): Gtk.Widget[] =>\n findAll(container, (widget) => {\n if (widget.getAccessibleRole() !== role) return false;\n if (!options?.hidden && isInaccessible(widget)) return false;\n return matchByRoleOptions(widget, options);\n });\n\nconst roleQueries = nameQueryFamily(\n \"Role\",\n queryAllByRole,\n buildQueries<[role: Gtk.AccessibleRole, options?: ByRoleOptions]>(\n \"Role\",\n queryAllByRole,\n (container, matches, role, options) =>\n multipleFoundError(container, { queryType: \"role\", role, options }, matches),\n (container, role, options) => notFoundError(container, { queryType: \"role\", role, options }),\n ),\n);\n\nconst collectMnemonicMatch = (\n widget: Gtk.Widget,\n text: Matcher,\n options: MatcherOptions | undefined,\n): Gtk.Widget | null => {\n if (!(widget instanceof Gtk.Label)) return null;\n const labelText = widget.getLabel();\n if (!labelText || !matchText(labelText, text, widget, options)) return null;\n return widget.getMnemonicWidget();\n};\n\n/**\n * Finds every widget associated with a label whose text matches: a Gtk.Label mnemonic target, the widget's own accessible label, or its labelled-by relation.\n * @param container Widget subtree to search.\n * @param text Matcher for the label text.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nexport const queryAllByLabelText = (container: Container, text: Matcher, options?: MatcherOptions): Gtk.Widget[] => {\n const results = new Set<Gtk.Widget>();\n\n for (const widget of traverse(container)) {\n const mnemonicTarget = collectMnemonicMatch(widget, text, options);\n if (mnemonicTarget) results.add(mnemonicTarget);\n\n const ownLabel = getWidgetOwnLabel(widget);\n if (ownLabel !== null && matchText(ownLabel, text, widget, options)) results.add(widget);\n\n const labelledByText = getWidgetLabelledByText(widget);\n if (labelledByText !== null && matchText(labelledByText, text, widget, options)) results.add(widget);\n }\n\n return [...results];\n};\n\nconst labelTextQueries = nameQueryFamily(\n \"LabelText\",\n queryAllByLabelText,\n buildQueries<[text: Matcher, options?: MatcherOptions]>(\n \"LabelText\",\n queryAllByLabelText,\n (container, matches, text) => multipleFoundError(container, { queryType: \"labelText\", text }, matches),\n (container, text) => notFoundError(container, { queryType: \"labelText\", text }),\n ),\n);\n\n/**\n * Finds every widget whose rendered text content matches.\n * @param container Widget subtree to search.\n * @param text Matcher for the widget text.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nexport const queryAllByText = (container: Container, text: Matcher, options?: MatcherOptions): Gtk.Widget[] =>\n findAll(container, (widget) => matchText(getWidgetLabelText(widget), text, widget, options));\n\nconst textQueries = nameQueryFamily(\n \"Text\",\n queryAllByText,\n buildQueries<[text: Matcher, options?: MatcherOptions]>(\n \"Text\",\n queryAllByText,\n (container, matches, text) => multipleFoundError(container, { queryType: \"text\", text }, matches),\n (container, text) => notFoundError(container, { queryType: \"text\", text }),\n ),\n);\n\n/**\n * Finds every widget whose widget name matches.\n * @param container Widget subtree to search.\n * @param name Matcher for the widget name.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nexport const queryAllByName = (container: Container, name: Matcher, options?: MatcherOptions): Gtk.Widget[] =>\n findAll(container, (widget) => matchText(getWidgetName(widget), name, widget, options));\n\nconst nameQueries = nameQueryFamily(\n \"Name\",\n queryAllByName,\n buildQueries<[name: Matcher, options?: MatcherOptions]>(\n \"Name\",\n queryAllByName,\n (container, matches, name) => multipleFoundError(container, { queryType: \"name\", name }, matches),\n (container, name) => notFoundError(container, { queryType: \"name\", name }),\n ),\n);\n\n/**\n * Finds every widget whose placeholder text matches.\n * @param container Widget subtree to search.\n * @param text Matcher for the placeholder text.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nexport const queryAllByPlaceholderText = (\n container: Container,\n text: Matcher,\n options?: MatcherOptions,\n): Gtk.Widget[] => findAll(container, (widget) => matchText(getWidgetPlaceholderText(widget), text, widget, options));\n\nconst placeholderTextQueries = nameQueryFamily(\n \"PlaceholderText\",\n queryAllByPlaceholderText,\n buildQueries<[text: Matcher, options?: MatcherOptions]>(\n \"PlaceholderText\",\n queryAllByPlaceholderText,\n (container, matches, text) => multipleFoundError(container, { queryType: \"placeholderText\", text }, matches),\n (container, text) => notFoundError(container, { queryType: \"placeholderText\", text }),\n ),\n);\n\n/**\n * Finds every widget whose current display value matches.\n * @param container Widget subtree to search.\n * @param value Matcher for the display value.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nexport const queryAllByDisplayValue = (container: Container, value: Matcher, options?: MatcherOptions): Gtk.Widget[] =>\n findAll(container, (widget) => matchText(getWidgetDisplayValue(widget), value, widget, options));\n\nconst displayValueQueries = nameQueryFamily(\n \"DisplayValue\",\n queryAllByDisplayValue,\n buildQueries<[value: Matcher, options?: MatcherOptions]>(\n \"DisplayValue\",\n queryAllByDisplayValue,\n (container, matches, value) => multipleFoundError(container, { queryType: \"displayValue\", value }, matches),\n (container, value) => notFoundError(container, { queryType: \"displayValue\", value }),\n ),\n);\n\nexport type BuiltinQueries = NamedFamily<\"Role\", [role: Gtk.AccessibleRole, options?: ByRoleOptions]> &\n NamedFamily<\"LabelText\", [text: Matcher, options?: MatcherOptions]> &\n NamedFamily<\"Text\", [text: Matcher, options?: MatcherOptions]> &\n NamedFamily<\"Name\", [name: Matcher, options?: MatcherOptions]> &\n NamedFamily<\"PlaceholderText\", [text: Matcher, options?: MatcherOptions]> &\n NamedFamily<\"DisplayValue\", [value: Matcher, options?: MatcherOptions]>;\n\nexport const builtinQueries: BuiltinQueries = {\n ...roleQueries,\n ...labelTextQueries,\n ...textQueries,\n ...nameQueries,\n ...placeholderTextQueries,\n ...displayValueQueries,\n};\n\n/** Returns the single widget with a matching accessible role and options, or null when none match. Throws when more than one matches. */\nexport const queryByRole: BuiltinQueries[\"queryByRole\"] = roleQueries.queryByRole;\n/** Returns every widget with a matching accessible role and options. Throws when none match. */\nexport const getAllByRole: BuiltinQueries[\"getAllByRole\"] = roleQueries.getAllByRole;\n/** Returns the single widget with a matching accessible role and options. Throws when none or more than one matches. */\nexport const getByRole: BuiltinQueries[\"getByRole\"] = roleQueries.getByRole;\n/** Waits for and returns every widget with a matching accessible role and options, retrying until at least one appears or the timeout elapses. */\nexport const findAllByRole: BuiltinQueries[\"findAllByRole\"] = roleQueries.findAllByRole;\n/** Waits for and returns the single widget with a matching accessible role and options, retrying until it appears or the timeout elapses. Rejects when none or more than one matches. */\nexport const findByRole: BuiltinQueries[\"findByRole\"] = roleQueries.findByRole;\n\n/** Returns the single widget with matching associated label text, or null when none match. Throws when more than one matches. */\nexport const queryByLabelText: BuiltinQueries[\"queryByLabelText\"] = labelTextQueries.queryByLabelText;\n/** Returns every widget with matching associated label text. Throws when none match. */\nexport const getAllByLabelText: BuiltinQueries[\"getAllByLabelText\"] = labelTextQueries.getAllByLabelText;\n/** Returns the single widget with matching associated label text. Throws when none or more than one matches. */\nexport const getByLabelText: BuiltinQueries[\"getByLabelText\"] = labelTextQueries.getByLabelText;\n/** Waits for and returns every widget with matching associated label text, retrying until at least one appears or the timeout elapses. */\nexport const findAllByLabelText: BuiltinQueries[\"findAllByLabelText\"] = labelTextQueries.findAllByLabelText;\n/** Waits for and returns the single widget with matching associated label text, retrying until it appears or the timeout elapses. Rejects when none or more than one matches. */\nexport const findByLabelText: BuiltinQueries[\"findByLabelText\"] = labelTextQueries.findByLabelText;\n\n/** Returns the single widget with matching rendered text content, or null when none match. Throws when more than one matches. */\nexport const queryByText: BuiltinQueries[\"queryByText\"] = textQueries.queryByText;\n/** Returns every widget with matching rendered text content. Throws when none match. */\nexport const getAllByText: BuiltinQueries[\"getAllByText\"] = textQueries.getAllByText;\n/** Returns the single widget with matching rendered text content. Throws when none or more than one matches. */\nexport const getByText: BuiltinQueries[\"getByText\"] = textQueries.getByText;\n/** Waits for and returns every widget with matching rendered text content, retrying until at least one appears or the timeout elapses. */\nexport const findAllByText: BuiltinQueries[\"findAllByText\"] = textQueries.findAllByText;\n/** Waits for and returns the single widget with matching rendered text content, retrying until it appears or the timeout elapses. Rejects when none or more than one matches. */\nexport const findByText: BuiltinQueries[\"findByText\"] = textQueries.findByText;\n\n/** Returns the single widget with a matching widget name, or null when none match. Throws when more than one matches. */\nexport const queryByName: BuiltinQueries[\"queryByName\"] = nameQueries.queryByName;\n/** Returns every widget with a matching widget name. Throws when none match. */\nexport const getAllByName: BuiltinQueries[\"getAllByName\"] = nameQueries.getAllByName;\n/** Returns the single widget with a matching widget name. Throws when none or more than one matches. */\nexport const getByName: BuiltinQueries[\"getByName\"] = nameQueries.getByName;\n/** Waits for and returns every widget with a matching widget name, retrying until at least one appears or the timeout elapses. */\nexport const findAllByName: BuiltinQueries[\"findAllByName\"] = nameQueries.findAllByName;\n/** Waits for and returns the single widget with a matching widget name, retrying until it appears or the timeout elapses. Rejects when none or more than one matches. */\nexport const findByName: BuiltinQueries[\"findByName\"] = nameQueries.findByName;\n\n/** Returns the single widget with matching placeholder text, or null when none match. Throws when more than one matches. */\nexport const queryByPlaceholderText: BuiltinQueries[\"queryByPlaceholderText\"] =\n placeholderTextQueries.queryByPlaceholderText;\n/** Returns every widget with matching placeholder text. Throws when none match. */\nexport const getAllByPlaceholderText: BuiltinQueries[\"getAllByPlaceholderText\"] =\n placeholderTextQueries.getAllByPlaceholderText;\n/** Returns the single widget with matching placeholder text. Throws when none or more than one matches. */\nexport const getByPlaceholderText: BuiltinQueries[\"getByPlaceholderText\"] = placeholderTextQueries.getByPlaceholderText;\n/** Waits for and returns every widget with matching placeholder text, retrying until at least one appears or the timeout elapses. */\nexport const findAllByPlaceholderText: BuiltinQueries[\"findAllByPlaceholderText\"] =\n placeholderTextQueries.findAllByPlaceholderText;\n/** Waits for and returns the single widget with matching placeholder text, retrying until it appears or the timeout elapses. Rejects when none or more than one matches. */\nexport const findByPlaceholderText: BuiltinQueries[\"findByPlaceholderText\"] =\n placeholderTextQueries.findByPlaceholderText;\n\n/** Returns the single widget with a matching display value, or null when none match. Throws when more than one matches. */\nexport const queryByDisplayValue: BuiltinQueries[\"queryByDisplayValue\"] = displayValueQueries.queryByDisplayValue;\n/** Returns every widget with a matching display value. Throws when none match. */\nexport const getAllByDisplayValue: BuiltinQueries[\"getAllByDisplayValue\"] = displayValueQueries.getAllByDisplayValue;\n/** Returns the single widget with a matching display value. Throws when none or more than one matches. */\nexport const getByDisplayValue: BuiltinQueries[\"getByDisplayValue\"] = displayValueQueries.getByDisplayValue;\n/** Waits for and returns every widget with a matching display value, retrying until at least one appears or the timeout elapses. */\nexport const findAllByDisplayValue: BuiltinQueries[\"findAllByDisplayValue\"] = displayValueQueries.findAllByDisplayValue;\n/** Waits for and returns the single widget with a matching display value, retrying until it appears or the timeout elapses. Rejects when none or more than one matches. */\nexport const findByDisplayValue: BuiltinQueries[\"findByDisplayValue\"] = displayValueQueries.findByDisplayValue;\n"]}
1
+ {"version":3,"file":"queries.js","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AASpC,OAAO,EAAE,YAAY,EAAsC,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAkB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACH,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,eAAe,GAClB,MAAM,mCAAmC,CAAC;AAI3C,MAAM,WAAW,GAAG,eAAe,CAC/B,MAAM,EACN,cAAc,EACd,YAAY,CACR,MAAM,EACN,cAAc,EACd,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAClC,kBAAkB,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAChF,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAC/F,CACJ,CAAC;AAEF,MAAM,gBAAgB,GAAG,eAAe,CACpC,WAAW,EACX,mBAAmB,EACnB,YAAY,CACR,WAAW,EACX,mBAAmB,EACnB,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,SAAS,EAAE,EAAE,SAAS,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AAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,sBAAsB,GAEzB,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport type {\n ByRoleOptions,\n ByRoleValue,\n Matcher,\n MatcherOptions,\n NormalizerFn,\n QueryFamilies,\n} from \"./types.js\";\nimport { buildQueries, type BuiltQueries, type QueryAllBy } from \"./build-queries.js\";\nimport { multipleFoundError, notFoundError } from \"./errors.js\";\nimport { getDefaultNormalizer } from \"./normalize.js\";\nimport { type Container, findAll, traverse } from \"./traversal.js\";\nimport {\n getWidgetAccessibleName,\n getWidgetBusyState,\n getWidgetDescription,\n getWidgetDisplayValue,\n getWidgetExpandedState,\n getWidgetLabelledByText,\n getWidgetLabelText,\n getWidgetLevel,\n getWidgetName,\n getWidgetOwnLabel,\n getWidgetPlaceholderText,\n getWidgetPressedState,\n getWidgetSelectedState,\n getWidgetValue,\n isInaccessible,\n isWidgetChecked,\n} from \"./widget-accessible-properties.js\";\n\ntype BuiltinQueries = QueryFamilies<[container: Container]>;\n\nconst roleQueries = nameQueryFamily(\n \"Role\",\n queryAllByRole,\n buildQueries<[role: Gtk.AccessibleRole, options?: ByRoleOptions]>(\n \"Role\",\n queryAllByRole,\n (container, matches, role, options) =>\n multipleFoundError(container, { queryType: \"role\", role, options }, matches),\n (container, role, options) => notFoundError(container, { queryType: \"role\", role, options }),\n ),\n);\n\nconst labelTextQueries = nameQueryFamily(\n \"LabelText\",\n queryAllByLabelText,\n buildQueries<[text: Matcher, options?: MatcherOptions]>(\n \"LabelText\",\n queryAllByLabelText,\n (container, matches, text) => multipleFoundError(container, { queryType: \"labelText\", text }, matches),\n (container, text) => notFoundError(container, { queryType: \"labelText\", text }),\n ),\n);\n\nconst textQueries = nameQueryFamily(\n \"Text\",\n queryAllByText,\n buildQueries<[text: Matcher, options?: MatcherOptions]>(\n \"Text\",\n queryAllByText,\n (container, matches, text) => multipleFoundError(container, { queryType: \"text\", text }, matches),\n (container, text) => notFoundError(container, { queryType: \"text\", text }),\n ),\n);\n\nconst nameQueries = nameQueryFamily(\n \"Name\",\n queryAllByName,\n buildQueries<[name: Matcher, options?: MatcherOptions]>(\n \"Name\",\n queryAllByName,\n (container, matches, name) => multipleFoundError(container, { queryType: \"name\", name }, matches),\n (container, name) => notFoundError(container, { queryType: \"name\", name }),\n ),\n);\n\nconst placeholderTextQueries = nameQueryFamily(\n \"PlaceholderText\",\n queryAllByPlaceholderText,\n buildQueries<[text: Matcher, options?: MatcherOptions]>(\n \"PlaceholderText\",\n queryAllByPlaceholderText,\n (container, matches, text) => multipleFoundError(container, { queryType: \"placeholderText\", text }, matches),\n (container, text) => notFoundError(container, { queryType: \"placeholderText\", text }),\n ),\n);\n\nconst displayValueQueries = nameQueryFamily(\n \"DisplayValue\",\n queryAllByDisplayValue,\n buildQueries<[value: Matcher, options?: MatcherOptions]>(\n \"DisplayValue\",\n queryAllByDisplayValue,\n (container, matches, value) => multipleFoundError(container, { queryType: \"displayValue\", value }, matches),\n (container, value) => notFoundError(container, { queryType: \"displayValue\", value }),\n ),\n);\n\nconst builtinQueries = {\n ...roleQueries,\n ...labelTextQueries,\n ...textQueries,\n ...nameQueries,\n ...placeholderTextQueries,\n ...displayValueQueries,\n} as BuiltinQueries;\n\n/**\n * Returns the single widget with a matching accessible role and options, or null when none match.\n * Throws when more than one matches.\n */\nconst queryByRole: BuiltinQueries[\"queryByRole\"] = builtinQueries.queryByRole;\n/** Returns every widget with a matching accessible role and options. Throws when none match. */\nconst getAllByRole: BuiltinQueries[\"getAllByRole\"] = builtinQueries.getAllByRole;\n/**\n * Returns the single widget with a matching accessible role and options.\n * Throws when none or more than one matches.\n */\nconst getByRole: BuiltinQueries[\"getByRole\"] = builtinQueries.getByRole;\n/**\n * Waits for and returns every widget with a matching accessible role and options, retrying until at\n * least one appears or the timeout elapses.\n */\nconst findAllByRole: BuiltinQueries[\"findAllByRole\"] = builtinQueries.findAllByRole;\n/**\n * Waits for and returns the single widget with a matching accessible role and options, retrying\n * until it appears or the timeout elapses. Rejects when none or more than one matches.\n */\nconst findByRole: BuiltinQueries[\"findByRole\"] = builtinQueries.findByRole;\n/**\n * Returns the single widget with matching associated label text, or null when none match.\n * Throws when more than one matches.\n */\nconst queryByLabelText: BuiltinQueries[\"queryByLabelText\"] = builtinQueries.queryByLabelText;\n/** Returns every widget with matching associated label text. Throws when none match. */\nconst getAllByLabelText: BuiltinQueries[\"getAllByLabelText\"] = builtinQueries.getAllByLabelText;\n/** Returns the single widget with matching associated label text. Throws when none or more than one matches. */\nconst getByLabelText: BuiltinQueries[\"getByLabelText\"] = builtinQueries.getByLabelText;\n/**\n * Waits for and returns every widget with matching associated label text, retrying until at least\n * one appears or the timeout elapses.\n */\nconst findAllByLabelText: BuiltinQueries[\"findAllByLabelText\"] = builtinQueries.findAllByLabelText;\n/**\n * Waits for and returns the single widget with matching associated label text, retrying until it\n * appears or the timeout elapses. Rejects when none or more than one matches.\n */\nconst findByLabelText: BuiltinQueries[\"findByLabelText\"] = builtinQueries.findByLabelText;\n/**\n * Returns the single widget with matching rendered text content, or null when none match.\n * Throws when more than one matches.\n */\nconst queryByText: BuiltinQueries[\"queryByText\"] = builtinQueries.queryByText;\n/** Returns every widget with matching rendered text content. Throws when none match. */\nconst getAllByText: BuiltinQueries[\"getAllByText\"] = builtinQueries.getAllByText;\n/** Returns the single widget with matching rendered text content. Throws when none or more than one matches. */\nconst getByText: BuiltinQueries[\"getByText\"] = builtinQueries.getByText;\n/**\n * Waits for and returns every widget with matching rendered text content, retrying until at least\n * one appears or the timeout elapses.\n */\nconst findAllByText: BuiltinQueries[\"findAllByText\"] = builtinQueries.findAllByText;\n/**\n * Waits for and returns the single widget with matching rendered text content, retrying until it\n * appears or the timeout elapses. Rejects when none or more than one matches.\n */\nconst findByText: BuiltinQueries[\"findByText\"] = builtinQueries.findByText;\n/**\n * Returns the single widget with a matching widget name, or null when none match.\n * Throws when more than one matches.\n */\nconst queryByName: BuiltinQueries[\"queryByName\"] = builtinQueries.queryByName;\n/** Returns every widget with a matching widget name. Throws when none match. */\nconst getAllByName: BuiltinQueries[\"getAllByName\"] = builtinQueries.getAllByName;\n/** Returns the single widget with a matching widget name. Throws when none or more than one matches. */\nconst getByName: BuiltinQueries[\"getByName\"] = builtinQueries.getByName;\n/**\n * Waits for and returns every widget with a matching widget name, retrying until at least one\n * appears or the timeout elapses.\n */\nconst findAllByName: BuiltinQueries[\"findAllByName\"] = builtinQueries.findAllByName;\n/**\n * Waits for and returns the single widget with a matching widget name, retrying until it appears or\n * the timeout elapses. Rejects when none or more than one matches.\n */\nconst findByName: BuiltinQueries[\"findByName\"] = builtinQueries.findByName;\n/**\n * Returns the single widget with matching placeholder text, or null when none match.\n * Throws when more than one matches.\n */\nconst queryByPlaceholderText: BuiltinQueries[\"queryByPlaceholderText\"] = builtinQueries.queryByPlaceholderText;\n/** Returns every widget with matching placeholder text. Throws when none match. */\nconst getAllByPlaceholderText: BuiltinQueries[\"getAllByPlaceholderText\"] = builtinQueries.getAllByPlaceholderText;\n/** Returns the single widget with matching placeholder text. Throws when none or more than one matches. */\nconst getByPlaceholderText: BuiltinQueries[\"getByPlaceholderText\"] = builtinQueries.getByPlaceholderText;\n/**\n * Waits for and returns every widget with matching placeholder text, retrying until at least one\n * appears or the timeout elapses.\n */\nconst findAllByPlaceholderText: BuiltinQueries[\"findAllByPlaceholderText\"] = builtinQueries.findAllByPlaceholderText;\n/**\n * Waits for and returns the single widget with matching placeholder text, retrying until it appears\n * or the timeout elapses. Rejects when none or more than one matches.\n */\nconst findByPlaceholderText: BuiltinQueries[\"findByPlaceholderText\"] = builtinQueries.findByPlaceholderText;\n/**\n * Returns the single widget with a matching display value, or null when none match.\n * Throws when more than one matches.\n */\nconst queryByDisplayValue: BuiltinQueries[\"queryByDisplayValue\"] = builtinQueries.queryByDisplayValue;\n/** Returns every widget with a matching display value. Throws when none match. */\nconst getAllByDisplayValue: BuiltinQueries[\"getAllByDisplayValue\"] = builtinQueries.getAllByDisplayValue;\n/** Returns the single widget with a matching display value. Throws when none or more than one matches. */\nconst getByDisplayValue: BuiltinQueries[\"getByDisplayValue\"] = builtinQueries.getByDisplayValue;\n/**\n * Waits for and returns every widget with a matching display value, retrying until at least one\n * appears or the timeout elapses.\n */\nconst findAllByDisplayValue: BuiltinQueries[\"findAllByDisplayValue\"] = builtinQueries.findAllByDisplayValue;\n/**\n * Waits for and returns the single widget with a matching display value, retrying until it appears\n * or the timeout elapses. Rejects when none or more than one matches.\n */\nconst findByDisplayValue: BuiltinQueries[\"findByDisplayValue\"] = builtinQueries.findByDisplayValue;\n\nconst buildNormalizer = (options?: MatcherOptions): NormalizerFn => {\n const { normalizer, trim, collapseWhitespace } = options ?? {};\n\n if (!normalizer) {\n return getDefaultNormalizer({ trim, collapseWhitespace });\n }\n\n if (trim !== undefined || collapseWhitespace !== undefined) {\n throw new Error(\n \"trim and collapseWhitespace are not supported with a normalizer. \" +\n \"If you want to use the default trim and collapseWhitespace logic in your normalizer, \" +\n \"use \\\"getDefaultNormalizer({ trim, collapseWhitespace })\\\" and compose that into your normalizer\",\n );\n }\n\n return normalizer;\n};\n\nconst normalizeText = (text: string, options?: MatcherOptions): string => {\n const normalizer = buildNormalizer(options);\n\n return normalizer(text);\n};\n\nconst isTextMatch = (\n actual: string | null,\n expected: Matcher,\n widget: Gtk.Widget,\n options?: MatcherOptions,\n): boolean => {\n if (actual === null) {\n return false;\n }\n\n const normalizedActual = normalizeText(actual, options);\n\n if (typeof expected === \"function\") {\n return expected(normalizedActual, widget);\n }\n\n if (expected instanceof RegExp) {\n expected.lastIndex = 0;\n\n return expected.test(normalizedActual);\n }\n\n const normalizedExpected = normalizeText(String(expected), options);\n const isExact = options?.exact ?? true;\n\n return isExact\n ? normalizedActual === normalizedExpected\n : normalizedActual.toLowerCase().includes(normalizedExpected.toLowerCase());\n};\n\nconst hasMatchingAccessibleName = (widget: Gtk.Widget, options: ByRoleOptions): boolean => {\n if (options.name === undefined) {\n return true;\n }\n\n const text = getWidgetAccessibleName(widget);\n\n return isTextMatch(text, options.name, widget, options);\n};\n\nconst isNumericValueMatch = (expected: number | undefined, actual: number | null): boolean =>\n expected === undefined || actual === expected;\n\nconst hasMatchingAccessibleValue = (widget: Gtk.Widget, value: ByRoleValue, options: ByRoleOptions): boolean => {\n const actual = getWidgetValue(widget);\n\n const numericChecks: [number | undefined, number | null][] = [\n [value.now, actual.now],\n [value.min, actual.min],\n [value.max, actual.max],\n ];\n\n for (const [expected, current] of numericChecks) {\n if (!isNumericValueMatch(expected, current)) {\n return false;\n }\n }\n\n return value.text === undefined || isTextMatch(actual.text, value.text, widget, options);\n};\n\nconst hasMatchingBooleanStates = (widget: Gtk.Widget, options: ByRoleOptions): boolean => {\n const stateChecks: [boolean | undefined, () => boolean | null][] = [\n [options.checked, () => isWidgetChecked(widget)],\n [options.pressed, () => getWidgetPressedState(widget)],\n [options.expanded, () => getWidgetExpandedState(widget)],\n [options.selected, () => getWidgetSelectedState(widget)],\n [options.busy, () => getWidgetBusyState(widget) ?? false],\n ];\n\n for (const [expected, getActual] of stateChecks) {\n if (expected !== undefined && getActual() !== expected) {\n return false;\n }\n }\n\n return true;\n};\n\nconst hasMatchingLevelState = (widget: Gtk.Widget, options: ByRoleOptions): boolean =>\n options.level === undefined || getWidgetLevel(widget) === options.level;\n\nconst hasMatchingDescriptionState = (widget: Gtk.Widget, options: ByRoleOptions): boolean =>\n options.description === undefined ||\n isTextMatch(getWidgetDescription(widget), options.description, widget, options);\n\nconst hasMatchingValueState = (widget: Gtk.Widget, options: ByRoleOptions): boolean =>\n options.value === undefined || hasMatchingAccessibleValue(widget, options.value, options);\n\nconst hasMatchingAccessibleStates = (widget: Gtk.Widget, options: ByRoleOptions): boolean =>\n hasMatchingBooleanStates(widget, options) &&\n hasMatchingLevelState(widget, options) &&\n hasMatchingDescriptionState(widget, options) &&\n hasMatchingValueState(widget, options);\n\nconst isMatchingWidgetType = (widget: Gtk.Widget, options?: MatcherOptions): boolean =>\n options?.as === undefined || widget instanceof options.as;\n\nconst hasMatchingByRoleOptions = (widget: Gtk.Widget, options?: ByRoleOptions): boolean => {\n if (!options) {\n return true;\n }\n\n return (\n isMatchingWidgetType(widget, options) &&\n hasMatchingAccessibleName(widget, options) &&\n hasMatchingAccessibleStates(widget, options)\n );\n};\n\nfunction nameQueryFamily<Args extends unknown[]>(\n suffix: string,\n queryAllBy: QueryAllBy<Args>,\n built: BuiltQueries<Args>,\n): Record<string, unknown> {\n return {\n [`queryBy${suffix}`]: built.queryBy,\n [`queryAllBy${suffix}`]: queryAllBy,\n [`getBy${suffix}`]: built.getBy,\n [`getAllBy${suffix}`]: built.getAllBy,\n [`findBy${suffix}`]: built.findBy,\n [`findAllBy${suffix}`]: built.findAllBy,\n };\n}\n\n/**\n * Finds every widget under the container whose accessible role matches `role` and that satisfies the given options.\n * Widgets excluded from the accessibility tree are skipped unless `options.hidden` is set.\n * @param container Widget subtree to search.\n * @param role Accessible role to match.\n * @param options Additional accessible name, state, and value constraints.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByRole(\n container: Container,\n role: Gtk.AccessibleRole,\n options?: ByRoleOptions,\n): Gtk.Widget[] {\n return findAll(container, (widget) => {\n if (widget.getAccessibleRole() !== role) {\n return false;\n }\n\n if (!options?.hidden && isInaccessible(widget)) {\n return false;\n }\n\n return hasMatchingByRoleOptions(widget, options);\n });\n}\n\nconst collectMnemonicMatch = (\n widget: Gtk.Widget,\n text: Matcher,\n options: MatcherOptions | undefined,\n): Gtk.Widget | null => {\n if (!(widget instanceof Gtk.Label)) {\n return null;\n }\n\n const labelText = widget.getLabel();\n\n if (!labelText || !isTextMatch(labelText, text, widget, options)) {\n return null;\n }\n\n return widget.getMnemonicWidget();\n};\n\nconst collectLabelMatches = (\n results: Set<Gtk.Widget>,\n widget: Gtk.Widget,\n text: Matcher,\n options: MatcherOptions | undefined,\n): void => {\n const mnemonicTarget = collectMnemonicMatch(widget, text, options);\n\n if (mnemonicTarget) {\n results.add(mnemonicTarget);\n }\n\n const ownLabel = getWidgetOwnLabel(widget);\n\n if (ownLabel !== null && isTextMatch(ownLabel, text, widget, options)) {\n results.add(widget);\n }\n\n const labelledByText = getWidgetLabelledByText(widget);\n\n if (labelledByText !== null && isTextMatch(labelledByText, text, widget, options)) {\n results.add(widget);\n }\n};\n\n/**\n * Finds every widget associated with a label whose text matches: a Gtk.Label mnemonic target, the\n * widget's own accessible label, or its labelled-by relation.\n * @param container Widget subtree to search.\n * @param text Matcher for the label text.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByLabelText(container: Container, text: Matcher, options?: MatcherOptions): Gtk.Widget[] {\n const results: Set<Gtk.Widget> = new Set();\n\n for (const widget of traverse(container)) {\n collectLabelMatches(results, widget, text, options);\n }\n\n return [...results].filter((widget) => isMatchingWidgetType(widget, options));\n}\n\n/**\n * Finds every widget whose rendered text content matches.\n * @param container Widget subtree to search.\n * @param text Matcher for the widget text.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByText(container: Container, text: Matcher, options?: MatcherOptions): Gtk.Widget[] {\n return findAll(\n container,\n (widget) =>\n isMatchingWidgetType(widget, options) && isTextMatch(getWidgetLabelText(widget), text, widget, options),\n );\n}\n\n/**\n * Finds every widget whose widget name matches.\n * @param container Widget subtree to search.\n * @param name Matcher for the widget name.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByName(container: Container, name: Matcher, options?: MatcherOptions): Gtk.Widget[] {\n return findAll(\n container,\n (widget) => isMatchingWidgetType(widget, options) && isTextMatch(getWidgetName(widget), name, widget, options),\n );\n}\n\n/**\n * Finds every widget whose placeholder text matches.\n * @param container Widget subtree to search.\n * @param text Matcher for the placeholder text.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByPlaceholderText(\n container: Container,\n text: Matcher,\n options?: MatcherOptions,\n): Gtk.Widget[] {\n return findAll(\n container,\n (widget) =>\n isMatchingWidgetType(widget, options) &&\n isTextMatch(getWidgetPlaceholderText(widget), text, widget, options),\n );\n}\n\n/**\n * Finds every widget whose current display value matches.\n * @param container Widget subtree to search.\n * @param value Matcher for the display value.\n * @param options Text matching options.\n * @returns Every matching widget, or an empty array when none match.\n */\nfunction queryAllByDisplayValue(container: Container, value: Matcher, options?: MatcherOptions): Gtk.Widget[] {\n return findAll(\n container,\n (widget) =>\n isMatchingWidgetType(widget, options) &&\n isTextMatch(getWidgetDisplayValue(widget), value, widget, options),\n );\n}\n\nexport {\n builtinQueries,\n queryByRole,\n getAllByRole,\n getByRole,\n findAllByRole,\n findByRole,\n queryByLabelText,\n getAllByLabelText,\n getByLabelText,\n findAllByLabelText,\n findByLabelText,\n queryByText,\n getAllByText,\n getByText,\n findAllByText,\n findByText,\n queryByName,\n getAllByName,\n getByName,\n findAllByName,\n findByName,\n queryByPlaceholderText,\n getAllByPlaceholderText,\n getByPlaceholderText,\n findAllByPlaceholderText,\n findByPlaceholderText,\n queryByDisplayValue,\n getAllByDisplayValue,\n getByDisplayValue,\n findAllByDisplayValue,\n findByDisplayValue,\n queryAllByRole,\n queryAllByLabelText,\n queryAllByText,\n queryAllByName,\n queryAllByPlaceholderText,\n queryAllByDisplayValue,\n type BuiltinQueries,\n};\n"]}
@@ -3,8 +3,9 @@ import { registerMatchers } from "./matchers.js";
3
3
  import { cleanup } from "./render.js";
4
4
  const callRunnerHook = (name, callback) => {
5
5
  const hook = Reflect.get(globalThis, name);
6
- if (typeof hook === "function")
6
+ if (typeof hook === "function") {
7
7
  hook(callback);
8
+ }
8
9
  };
9
10
  const registerTestRuntimeHooks = () => {
10
11
  callRunnerHook("afterEach", cleanup);
@@ -1 +1 @@
1
- {"version":3,"file":"register-test-hooks.js","sourceRoot":"","sources":["../src/register-test-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,cAAc,GAAG,CAAC,IAA8B,EAAE,QAAuB,EAAQ,EAAE;IACrF,MAAM,IAAI,GAAY,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACpD,IAAI,OAAO,IAAI,KAAK,UAAU;QAAG,IAA0C,CAAC,QAAQ,CAAC,CAAC;AAC1F,CAAC,CAAC;AAEF,MAAM,wBAAwB,GAAG,GAAS,EAAE;IACxC,cAAc,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACrC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACjC,gBAAgB,EAAE,CAAC;AACvB,CAAC,CAAC;AAEF,wBAAwB,EAAE,CAAC","sourcesContent":["import { quit } from \"@gtkx/runtime\";\nimport { registerMatchers } from \"./matchers.js\";\nimport { cleanup } from \"./render.js\";\n\nconst callRunnerHook = (name: \"afterEach\" | \"afterAll\", callback: () => unknown): void => {\n const hook: unknown = Reflect.get(globalThis, name);\n if (typeof hook === \"function\") (hook as (callback: () => unknown) => void)(callback);\n};\n\nconst registerTestRuntimeHooks = (): void => {\n callRunnerHook(\"afterEach\", cleanup);\n callRunnerHook(\"afterAll\", quit);\n registerMatchers();\n};\n\nregisterTestRuntimeHooks();\n"]}
1
+ {"version":3,"file":"register-test-hooks.js","sourceRoot":"","sources":["../src/register-test-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,cAAc,GAAG,CAAC,IAA8B,EAAE,QAAuB,EAAQ,EAAE;IACrF,MAAM,IAAI,GAAY,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAEpD,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC5B,IAA0C,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,wBAAwB,GAAG,GAAS,EAAE;IACxC,cAAc,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACrC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACjC,gBAAgB,EAAE,CAAC;AACvB,CAAC,CAAC;AAEF,wBAAwB,EAAE,CAAC","sourcesContent":["import { quit } from \"@gtkx/runtime\";\nimport { registerMatchers } from \"./matchers.js\";\nimport { cleanup } from \"./render.js\";\n\nconst callRunnerHook = (name: \"afterEach\" | \"afterAll\", callback: () => unknown): void => {\n const hook: unknown = Reflect.get(globalThis, name);\n\n if (typeof hook === \"function\") {\n (hook as (callback: () => unknown) => void)(callback);\n }\n};\n\nconst registerTestRuntimeHooks = (): void => {\n callRunnerHook(\"afterEach\", cleanup);\n callRunnerHook(\"afterAll\", quit);\n registerMatchers();\n};\n\nregisterTestRuntimeHooks();\n"]}
@@ -7,7 +7,7 @@ import type { RenderHookOptions, RenderHookResult } from "./types.js";
7
7
  * @param options Optional initial props and wrapper component.
8
8
  * @returns A result whose `result.current` holds the hook's latest value.
9
9
  */
10
- export declare function renderHook<Result>(callback: () => Result, options?: RenderHookOptions<undefined>): Promise<RenderHookResult<Result, undefined>>;
10
+ declare function renderHook<Result>(callback: () => Result, options?: RenderHookOptions<undefined>): Promise<RenderHookResult<Result, undefined>>;
11
11
  /**
12
12
  * Renders a test component that calls the given hook with props, exposing its
13
13
  * latest return value along with rerender and unmount controls.
@@ -16,5 +16,6 @@ export declare function renderHook<Result>(callback: () => Result, options?: Ren
16
16
  * @param options Initial props and optional wrapper component.
17
17
  * @returns A result whose `result.current` holds the hook's latest value.
18
18
  */
19
- export declare function renderHook<Result, Props>(callback: (props: Props) => Result, options: RenderHookOptions<Props>): Promise<RenderHookResult<Result, Props>>;
19
+ declare function renderHook<Result, Props>(callback: (props: Props) => Result, options: RenderHookOptions<Props>): Promise<RenderHookResult<Result, Props>>;
20
+ export { renderHook };
20
21
  //# sourceMappingURL=render-hook.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-hook.d.ts","sourceRoot":"","sources":["../src/render-hook.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEtE;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAC7B,QAAQ,EAAE,MAAM,MAAM,EACtB,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,GACvC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAChD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,KAAK,EACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,EAClC,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAClC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"render-hook.d.ts","sourceRoot":"","sources":["../src/render-hook.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGtE;;;;;;;GAOG;AACH,iBAAS,UAAU,CAAC,MAAM,EACtB,QAAQ,EAAE,MAAM,MAAM,EACtB,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,GACvC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAEhD;;;;;;;GAOG;AACH,iBAAS,UAAU,CAAC,MAAM,EAAE,KAAK,EAC7B,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,EAClC,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAClC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAmC5C,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as Gtk from "@gtkx/gi/gtk";
3
3
  import { render } from "./render.js";
4
- export async function renderHook(callback, options) {
4
+ async function renderHook(callback, options) {
5
5
  const initialProps = options?.initialProps;
6
6
  const resultRef = { current: undefined };
7
7
  let currentProps = initialProps;
@@ -25,4 +25,5 @@ export async function renderHook(callback, options) {
25
25
  unmount: renderResult.unmount,
26
26
  };
27
27
  }
28
+ export { renderHook };
28
29
  //# sourceMappingURL=render-hook.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-hook.js","sourceRoot":"","sources":["../src/render-hook.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA2BrC,MAAM,CAAC,KAAK,UAAU,UAAU,CAC5B,QAAkC,EAClC,OAAkC;IAElC,MAAM,YAAY,GAAI,OAAgD,EAAE,YAAqB,CAAC;IAC9F,MAAM,SAAS,GAAoC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAC1E,IAAI,YAAY,GAAU,YAAY,CAAC;IAEvC,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,EAAoB,EAAQ,EAAE;QACxD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC/B,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC;QAC3B,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,KAAC,aAAa,IAAC,KAAK,EAAE,YAAY,GAAI,EAAE;QACtE,SAAS,EAAE,IAAI,GAAG,CAAC,GAAG,EAAE;QACxB,OAAO,EAAE,OAAO,EAAE,OAAO;KAC5B,CAAC,CAAC;IAEH,OAAO;QACH,MAAM,EAAE,SAAgC;QACxC,QAAQ,EAAE,KAAK,EAAE,QAAgB,EAAE,EAAE;YACjC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBACzB,YAAY,GAAG,QAAQ,CAAC;YAC5B,CAAC;YACD,MAAM,YAAY,CAAC,QAAQ,CAAC,KAAC,aAAa,IAAC,KAAK,EAAE,YAAY,GAAI,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,EAAE,YAAY,CAAC,OAAO;KAChC,CAAC;AACN,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { render } from \"./render.js\";\nimport type { RenderHookOptions, RenderHookResult } from \"./types.js\";\n\n/**\n * Renders a test component that calls the given hook, exposing its latest\n * return value along with rerender and unmount controls.\n *\n * @param callback The hook to run, invoked with the current props.\n * @param options Optional initial props and wrapper component.\n * @returns A result whose `result.current` holds the hook's latest value.\n */\nexport function renderHook<Result>(\n callback: () => Result,\n options?: RenderHookOptions<undefined>,\n): Promise<RenderHookResult<Result, undefined>>;\n/**\n * Renders a test component that calls the given hook with props, exposing its\n * latest return value along with rerender and unmount controls.\n *\n * @param callback The hook to run, invoked with the current props.\n * @param options Initial props and optional wrapper component.\n * @returns A result whose `result.current` holds the hook's latest value.\n */\nexport function renderHook<Result, Props>(\n callback: (props: Props) => Result,\n options: RenderHookOptions<Props>,\n): Promise<RenderHookResult<Result, Props>>;\nexport async function renderHook<Result, Props>(\n callback: (props: Props) => Result,\n options?: RenderHookOptions<Props>,\n): Promise<RenderHookResult<Result, Props>> {\n const initialProps = (options as { initialProps?: Props } | undefined)?.initialProps as Props;\n const resultRef: { current: Result | undefined } = { current: undefined };\n let currentProps: Props = initialProps;\n\n const TestComponent = ({ props }: { props: Props }): null => {\n const result = callback(props);\n resultRef.current = result;\n return null;\n };\n\n const renderResult = await render(<TestComponent props={currentProps} />, {\n container: new Gtk.Box(),\n wrapper: options?.wrapper,\n });\n\n return {\n result: resultRef as { current: Result },\n rerender: async (newProps?: Props) => {\n if (newProps !== undefined) {\n currentProps = newProps;\n }\n await renderResult.rerender(<TestComponent props={currentProps} />);\n },\n unmount: renderResult.unmount,\n };\n}\n"]}
1
+ {"version":3,"file":"render-hook.js","sourceRoot":"","sources":["../src/render-hook.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA4BrC,KAAK,UAAU,UAAU,CACrB,QAAkC,EAClC,OAAkC;IAElC,MAAM,YAAY,GAAI,OAAgD,EAAE,YAAqB,CAAC;IAC9F,MAAM,SAAS,GAAoC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAC1E,IAAI,YAAY,GAAU,YAAY,CAAC;IAEvC,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,EAAoB,EAAQ,EAAE;QACxD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC/B,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC;QAE3B,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,KAAC,aAAa,IAAC,KAAK,EAAE,YAAY,GAAI,EAAE;QACtE,SAAS,EAAE,IAAI,GAAG,CAAC,GAAG,EAAE;QACxB,OAAO,EAAE,OAAO,EAAE,OAAO;KAC5B,CAAC,CAAC;IAEH,OAAO;QACH,MAAM,EAAE,SAAgC;QACxC,QAAQ,EAAE,KAAK,EAAE,QAAgB,EAAE,EAAE;YACjC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBACzB,YAAY,GAAG,QAAQ,CAAC;YAC5B,CAAC;YAED,MAAM,YAAY,CAAC,QAAQ,CAAC,KAAC,aAAa,IAAC,KAAK,EAAE,YAAY,GAAI,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,EAAE,YAAY,CAAC,OAAO;KAChC,CAAC;AACN,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport type { RenderHookOptions, RenderHookResult } from \"./types.js\";\nimport { render } from \"./render.js\";\n\n/**\n * Renders a test component that calls the given hook, exposing its latest\n * return value along with rerender and unmount controls.\n *\n * @param callback The hook to run, invoked with the current props.\n * @param options Optional initial props and wrapper component.\n * @returns A result whose `result.current` holds the hook's latest value.\n */\nfunction renderHook<Result>(\n callback: () => Result,\n options?: RenderHookOptions<undefined>,\n): Promise<RenderHookResult<Result, undefined>>;\n\n/**\n * Renders a test component that calls the given hook with props, exposing its\n * latest return value along with rerender and unmount controls.\n *\n * @param callback The hook to run, invoked with the current props.\n * @param options Initial props and optional wrapper component.\n * @returns A result whose `result.current` holds the hook's latest value.\n */\nfunction renderHook<Result, Props>(\n callback: (props: Props) => Result,\n options: RenderHookOptions<Props>,\n): Promise<RenderHookResult<Result, Props>>;\n\nasync function renderHook<Result, Props>(\n callback: (props: Props) => Result,\n options?: RenderHookOptions<Props>,\n): Promise<RenderHookResult<Result, Props>> {\n const initialProps = (options as { initialProps?: Props } | undefined)?.initialProps as Props;\n const resultRef: { current: Result | undefined } = { current: undefined };\n let currentProps: Props = initialProps;\n\n const TestComponent = ({ props }: { props: Props }): null => {\n const result = callback(props);\n resultRef.current = result;\n\n return null;\n };\n\n const renderResult = await render(<TestComponent props={currentProps} />, {\n container: new Gtk.Box(),\n wrapper: options?.wrapper,\n });\n\n return {\n result: resultRef as { current: Result },\n rerender: async (newProps?: Props) => {\n if (newProps !== undefined) {\n currentProps = newProps;\n }\n\n await renderResult.rerender(<TestComponent props={currentProps} />);\n },\n unmount: renderResult.unmount,\n };\n}\n\nexport { renderHook };\n"]}
package/dist/render.d.ts CHANGED
@@ -10,10 +10,11 @@ import type { QueryMap, RenderOptions } from "./types.js";
10
10
  * @param options Optional container, wrapper, custom queries, and other render settings.
11
11
  * @returns A render result with bound queries, debug helpers, and lifecycle controls.
12
12
  */
13
- export declare const render: <Q extends QueryMap = Record<never, never>>(element: ReactNode, options?: RenderOptions<Q>) => Promise<RenderResult<Q>>;
13
+ declare const render: <Q extends QueryMap = Record<never, never>>(element: ReactNode, options?: RenderOptions<Q>) => Promise<RenderResult<Q>>;
14
14
  /**
15
15
  * Unmounts every active render and runs all registered cleanup callbacks,
16
16
  * resetting the screen and clipboard. Called automatically after each test.
17
17
  */
18
- export declare const cleanup: () => Promise<void>;
18
+ declare const cleanup: () => Promise<void>;
19
+ export { render, cleanup };
19
20
  //# sourceMappingURL=render.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAkB,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AAEnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQvD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAqC,MAAM,YAAY,CAAC;AA8G7F;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,GAAU,CAAC,SAAS,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,WACzD,SAAS,YACR,aAAa,CAAC,CAAC,CAAC,KAC3B,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAuDzB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,OAAO,QAAa,OAAO,CAAC,IAAI,CAE5C,CAAC"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAkB,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAqC,MAAM,YAAY,CAAC;AA+I7F;;;;;;;;GAQG;AACH,QAAA,MAAM,MAAM,GAAU,CAAC,SAAS,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAC3D,SAAS,SAAS,EAClB,UAAU,aAAa,CAAC,CAAC,CAAC,KAC3B,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAqDzB,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,OAAO,QAAa,OAAO,CAAC,IAAI,CAErC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC"}
package/dist/render.js CHANGED
@@ -12,8 +12,7 @@ import { captureAndSaveScreenshot } from "./screenshot.js";
12
12
  import { TOPLEVELS, traverse } from "./traversal.js";
13
13
  import { resetClipboard } from "./user-event/index.js";
14
14
  import { within } from "./within.js";
15
- let lastRenderError = null;
16
- let errorHandlerInstalled = false;
15
+ const reconcilerErrors = { lastError: null, isHandlerInstalled: false };
17
16
  const activeRenders = new Set();
18
17
  const HARNESS_WINDOW_WIDTH = 800;
19
18
  const HARNESS_WINDOW_HEIGHT = 600;
@@ -24,33 +23,35 @@ const update = async (element, root) => {
24
23
  await runInAct(() => {
25
24
  root.update(element);
26
25
  });
27
- if (lastRenderError) {
28
- const captured = lastRenderError;
29
- lastRenderError = null;
26
+ if (reconcilerErrors.lastError) {
27
+ const captured = reconcilerErrors.lastError;
28
+ reconcilerErrors.lastError = null;
30
29
  throw captured;
31
30
  }
32
31
  };
33
32
  const disposeActiveRender = async (active) => {
34
- if (!activeRenders.delete(active))
33
+ if (!activeRenders.delete(active)) {
35
34
  return;
35
+ }
36
36
  await active.root.unmount(async (root) => {
37
37
  await update(null, root);
38
38
  active.window?.destroy();
39
39
  });
40
40
  };
41
41
  const disposeAllActiveRenders = async () => {
42
- for (const active of [...activeRenders]) {
42
+ for (const active of activeRenders) {
43
43
  await disposeActiveRender(active);
44
44
  }
45
45
  };
46
46
  const handleError = (error) => {
47
- lastRenderError = error instanceof Error ? error : new Error(String(error));
47
+ reconcilerErrors.lastError = error instanceof Error ? error : new Error(String(error));
48
48
  };
49
49
  const installErrorHandler = () => {
50
- if (errorHandlerInstalled)
50
+ if (reconcilerErrors.isHandlerInstalled) {
51
51
  return;
52
+ }
52
53
  setReconcilerErrorHandler(handleError);
53
- errorHandlerInstalled = true;
54
+ reconcilerErrors.isHandlerInstalled = true;
54
55
  };
55
56
  const resolveContainer = (container) => {
56
57
  if (isRootElement(container)) {
@@ -60,22 +61,26 @@ const resolveContainer = (container) => {
60
61
  return { containerInfo: container, window: null };
61
62
  }
62
63
  const window = new Gtk.Window({ defaultWidth: HARNESS_WINDOW_WIDTH, defaultHeight: HARNESS_WINDOW_HEIGHT });
63
- window.setTitlebar(new Gtk.HeaderBar({ showTitleButtons: false }));
64
+ window.setDecorated(false);
64
65
  return { containerInfo: window, window };
65
66
  };
66
67
  const firstToplevelWidget = (baseElement) => {
67
- if (baseElement instanceof Gtk.Widget)
68
+ if (baseElement instanceof Gtk.Widget) {
68
69
  return baseElement;
70
+ }
69
71
  const [first] = traverse(baseElement);
70
- if (first)
72
+ if (first) {
71
73
  return first;
74
+ }
72
75
  throw new Error("render() produced no widgets: ensure the element renders visible content");
73
76
  };
74
77
  const resolveResultContainer = (resolved, container, baseElement) => {
75
- if (resolved.window)
78
+ if (resolved.window) {
76
79
  return resolved.window;
77
- if (container instanceof Gtk.Widget)
80
+ }
81
+ if (container instanceof Gtk.Widget) {
78
82
  return container;
83
+ }
79
84
  return firstToplevelWidget(baseElement);
80
85
  };
81
86
  const renderErrorHandlers = (options) => ({
@@ -88,10 +93,10 @@ const renderErrorHandlers = (options) => ({
88
93
  options?.onRecoverableError?.(error, errorInfo);
89
94
  },
90
95
  });
91
- const applyEnableAnimations = (enabled) => {
96
+ const applyEnableAnimations = (areAnimationsEnabled) => {
92
97
  const settings = Gtk.Settings.getDefault();
93
98
  if (settings) {
94
- settings.gtkEnableAnimations = enabled;
99
+ settings.gtkEnableAnimations = areAnimationsEnabled;
95
100
  }
96
101
  };
97
102
  /**
@@ -103,7 +108,7 @@ const applyEnableAnimations = (enabled) => {
103
108
  * @param options Optional container, wrapper, custom queries, and other render settings.
104
109
  * @returns A render result with bound queries, debug helpers, and lifecycle controls.
105
110
  */
106
- export const render = async (element, options) => {
111
+ const render = async (element, options) => {
107
112
  installErrorHandler();
108
113
  applyEnableAnimations(options?.animations === true);
109
114
  const baseElement = options?.baseElement ?? TOPLEVELS;
@@ -152,7 +157,8 @@ export const render = async (element, options) => {
152
157
  * Unmounts every active render and runs all registered cleanup callbacks,
153
158
  * resetting the screen and clipboard. Called automatically after each test.
154
159
  */
155
- export const cleanup = async () => {
160
+ const cleanup = async () => {
156
161
  await runCleanup();
157
162
  };
163
+ export { render, cleanup };
158
164
  //# sourceMappingURL=render.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,EACH,oBAAoB,EACpB,aAAa,EAEb,yBAAyB,GAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAkC,UAAU,EAAE,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,SAAS,EAA4B,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAkB,SAAS,EAA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pF,MAAM,MAAM,GAAoB;QAC5B,GAAG,MAAM,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC;QACxC,SAAS;QACT,WAAW;QACX,OAAO,EAAE,KAAK,IAAI,EAAE;YAChB,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACtC,CAAC;QACD,QAAQ,EAAE,KAAK,EAAE,UAAqB,EAAE,EAAE;YACtC,MAAM,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC;YACrC,MAAM,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC;QACD,KAAK,EAAE,CAAC,OAAO,GAA4B,WAAW,EAAE,YAAkC,EAAE,EAAE;YAC1F,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACrC,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE;YACX,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC1B,CAAC;QACD,UAAU,EAAE,CAAC,QAAyB,EAAE,iBAAqC,EAAE,EAAE,CAC7E,wBAAwB,CAAC,QAAQ,EAAE,iBAAiB,CAAC;KAC5D,CAAC;IAEF,SAAS,CAAC,MAAM,CAAC,CAAC;IAElB,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,IAAmB,EAAE;IAC7C,MAAM,UAAU,EAAE,CAAC;AACvB,CAAC,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport type { RootElement } from \"@gtkx/react\";\nimport {\n createReconcilerRoot,\n isRootElement,\n type ReconcilerRoot,\n setReconcilerErrorHandler,\n} from \"@gtkx/react/internal\";\nimport { type ErrorInfo, type ReactNode, StrictMode } from \"react\";\nimport { runInAct } from \"./act.js\";\nimport type { RenderResult } from \"./bound-queries.js\";\nimport { addToCleanupQueue, runCleanup } from \"./cleanup-registry.js\";\nimport { scheduleAfterLayout } from \"./frame-sync.js\";\nimport { logWidget, type PrettyWidgetOptions } from \"./pretty-widget.js\";\nimport { logRoles } from \"./role-helpers.js\";\nimport { clearScreen, setScreen } from \"./screen.js\";\nimport { captureAndSaveScreenshot } from \"./screenshot.js\";\nimport { type Container, TOPLEVELS, traverse } from \"./traversal.js\";\nimport type { QueryMap, RenderOptions, ScreenshotOptions, WindowSelector } from \"./types.js\";\nimport { resetClipboard } from \"./user-event/index.js\";\nimport { within } from \"./within.js\";\n\nlet lastRenderError: Error | null = null;\nlet errorHandlerInstalled = false;\n\ntype ActiveRender = {\n root: ReconcilerRoot;\n window: Gtk.Window | null;\n};\n\nconst activeRenders = new Set<ActiveRender>();\n\nconst HARNESS_WINDOW_WIDTH = 800;\nconst HARNESS_WINDOW_HEIGHT = 600;\n\nconst flushLayout = (window: Gtk.Window | null): Promise<void> =>\n new Promise((resolve) => {\n scheduleAfterLayout(window, resolve);\n });\n\nconst update = async (element: ReactNode, root: ReconcilerRoot): Promise<void> => {\n await runInAct(() => {\n root.update(element);\n });\n\n if (lastRenderError) {\n const captured = lastRenderError;\n lastRenderError = null;\n throw captured;\n }\n};\n\nconst disposeActiveRender = async (active: ActiveRender): Promise<void> => {\n if (!activeRenders.delete(active)) return;\n await active.root.unmount(async (root) => {\n await update(null, root);\n active.window?.destroy();\n });\n};\n\nconst disposeAllActiveRenders = async (): Promise<void> => {\n for (const active of [...activeRenders]) {\n await disposeActiveRender(active);\n }\n};\n\nconst handleError = (error: unknown): void => {\n lastRenderError = error instanceof Error ? error : new Error(String(error));\n};\n\nconst installErrorHandler = (): void => {\n if (errorHandlerInstalled) return;\n setReconcilerErrorHandler(handleError);\n errorHandlerInstalled = true;\n};\n\ntype ResolvedContainer = {\n containerInfo: Gtk.Widget | RootElement;\n window: Gtk.Window | null;\n};\n\nconst resolveContainer = (container: RenderOptions[\"container\"]): ResolvedContainer => {\n if (isRootElement(container)) {\n return { containerInfo: container, window: null };\n }\n if (container instanceof Gtk.Widget) {\n return { containerInfo: container, window: null };\n }\n const window = new Gtk.Window({ defaultWidth: HARNESS_WINDOW_WIDTH, defaultHeight: HARNESS_WINDOW_HEIGHT });\n window.setTitlebar(new Gtk.HeaderBar({ showTitleButtons: false }));\n return { containerInfo: window, window };\n};\n\nconst firstToplevelWidget = (baseElement: Container): Gtk.Widget => {\n if (baseElement instanceof Gtk.Widget) return baseElement;\n const [first] = traverse(baseElement);\n if (first) return first;\n throw new Error(\"render() produced no widgets: ensure the element renders visible content\");\n};\n\nconst resolveResultContainer = (\n resolved: ResolvedContainer,\n container: RenderOptions[\"container\"],\n baseElement: Container,\n): Gtk.Widget => {\n if (resolved.window) return resolved.window;\n if (container instanceof Gtk.Widget) return container;\n return firstToplevelWidget(baseElement);\n};\n\nconst renderErrorHandlers = <Q extends QueryMap>(options: RenderOptions<Q> | undefined) => ({\n onUncaughtError: handleError,\n onCaughtError: (error: unknown, errorInfo: ErrorInfo): void => {\n handleError(error);\n options?.onCaughtError?.(error, errorInfo);\n },\n onRecoverableError: (error: unknown, errorInfo: ErrorInfo): void => {\n options?.onRecoverableError?.(error, errorInfo);\n },\n});\n\nconst applyEnableAnimations = (enabled: boolean): void => {\n const settings = Gtk.Settings.getDefault();\n if (settings) {\n settings.gtkEnableAnimations = enabled;\n }\n};\n\n/**\n * Renders a React element into a GTK4 widget tree and returns queries\n * scoped to it along with controls for rerendering and unmounting. When no\n * container is supplied, a harness window is created and presented.\n *\n * @param element The React element to render.\n * @param options Optional container, wrapper, custom queries, and other render settings.\n * @returns A render result with bound queries, debug helpers, and lifecycle controls.\n */\nexport const render = async <Q extends QueryMap = Record<never, never>>(\n element: ReactNode,\n options?: RenderOptions<Q>,\n): Promise<RenderResult<Q>> => {\n installErrorHandler();\n\n applyEnableAnimations(options?.animations === true);\n\n const baseElement: Container = options?.baseElement ?? TOPLEVELS;\n const Wrapper = options?.wrapper;\n\n const resolved = resolveContainer(options?.container);\n const root = createReconcilerRoot({\n containerInfo: resolved.containerInfo,\n ...renderErrorHandlers(options),\n });\n const active: ActiveRender = { root, window: resolved.window };\n activeRenders.add(active);\n\n addToCleanupQueue(disposeAllActiveRenders);\n addToCleanupQueue(clearScreen);\n addToCleanupQueue(resetClipboard);\n\n const wrap = (node: ReactNode): ReactNode => {\n const wrapped = Wrapper ? <Wrapper>{node}</Wrapper> : node;\n return options?.reactStrictMode ? <StrictMode>{wrapped}</StrictMode> : wrapped;\n };\n\n await update(wrap(element), root);\n resolved.window?.present();\n await flushLayout(resolved.window);\n\n const container = resolveResultContainer(resolved, options?.container, baseElement);\n\n const result: RenderResult<Q> = {\n ...within(baseElement, options?.queries),\n container,\n baseElement,\n unmount: async () => {\n await disposeActiveRender(active);\n },\n rerender: async (newElement: ReactNode) => {\n await update(wrap(newElement), root);\n await flushLayout(resolved.window);\n },\n debug: (element: Container | Container[] = baseElement, debugOptions?: PrettyWidgetOptions) => {\n logWidget(element, debugOptions);\n },\n logRoles: () => {\n logRoles(baseElement);\n },\n screenshot: (selector?: WindowSelector, screenshotOptions?: ScreenshotOptions) =>\n captureAndSaveScreenshot(selector, screenshotOptions),\n };\n\n setScreen(result);\n\n return result;\n};\n\n/**\n * Unmounts every active render and runs all registered cleanup callbacks,\n * resetting the screen and clipboard. Called automatically after each test.\n */\nexport const cleanup = async (): Promise<void> => {\n await runCleanup();\n};\n"]}
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EACH,oBAAoB,EACpB,aAAa,EAEb,yBAAyB,GAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAkC,UAAU,EAAE,MAAM,OAAO,CAAC;AAGnE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,SAAS,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,EAAE,CAAC;AACvB,CAAC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import type { RootElement } from \"@gtkx/react\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport {\n createReconcilerRoot,\n isRootElement,\n type ReconcilerRoot,\n setReconcilerErrorHandler,\n} from \"@gtkx/react/internal\";\nimport { type ErrorInfo, type ReactNode, StrictMode } from \"react\";\nimport type { RenderResult } from \"./bound-queries.js\";\nimport type { QueryMap, RenderOptions, ScreenshotOptions, WindowSelector } from \"./types.js\";\nimport { runInAct } from \"./act.js\";\nimport { addToCleanupQueue, runCleanup } from \"./cleanup-registry.js\";\nimport { scheduleAfterLayout } from \"./frame-sync.js\";\nimport { logWidget, type PrettyWidgetOptions } from \"./pretty-widget.js\";\nimport { logRoles } from \"./role-helpers.js\";\nimport { clearScreen, setScreen } from \"./screen.js\";\nimport { captureAndSaveScreenshot } from \"./screenshot.js\";\nimport { type Container, TOPLEVELS, traverse } from \"./traversal.js\";\nimport { resetClipboard } from \"./user-event/index.js\";\nimport { within } from \"./within.js\";\n\ntype ActiveRender = {\n root: ReconcilerRoot;\n window: Gtk.Window | null;\n};\n\ntype ResolvedContainer = {\n containerInfo: Gtk.Widget | RootElement;\n window: Gtk.Window | null;\n};\n\ntype ReconcilerErrorState = {\n lastError: Error | null;\n isHandlerInstalled: boolean;\n};\n\nconst reconcilerErrors: ReconcilerErrorState = { lastError: null, isHandlerInstalled: false };\nconst activeRenders: Set<ActiveRender> = new Set();\nconst HARNESS_WINDOW_WIDTH = 800;\nconst HARNESS_WINDOW_HEIGHT = 600;\n\nconst flushLayout = (window: Gtk.Window | null): Promise<void> =>\n new Promise((resolve) => {\n scheduleAfterLayout(window, resolve);\n });\n\nconst update = async (element: ReactNode, root: ReconcilerRoot): Promise<void> => {\n await runInAct(() => {\n root.update(element);\n });\n\n if (reconcilerErrors.lastError) {\n const captured = reconcilerErrors.lastError;\n reconcilerErrors.lastError = null;\n throw captured;\n }\n};\n\nconst disposeActiveRender = async (active: ActiveRender): Promise<void> => {\n if (!activeRenders.delete(active)) {\n return;\n }\n\n await active.root.unmount(async (root) => {\n await update(null, root);\n active.window?.destroy();\n });\n};\n\nconst disposeAllActiveRenders = async (): Promise<void> => {\n for (const active of activeRenders) {\n await disposeActiveRender(active);\n }\n};\n\nconst handleError = (error: unknown): void => {\n reconcilerErrors.lastError = error instanceof Error ? error : new Error(String(error));\n};\n\nconst installErrorHandler = (): void => {\n if (reconcilerErrors.isHandlerInstalled) {\n return;\n }\n\n setReconcilerErrorHandler(handleError);\n reconcilerErrors.isHandlerInstalled = true;\n};\n\nconst resolveContainer = (container: RenderOptions[\"container\"]): ResolvedContainer => {\n if (isRootElement(container)) {\n return { containerInfo: container, window: null };\n }\n\n if (container instanceof Gtk.Widget) {\n return { containerInfo: container, window: null };\n }\n\n const window = new Gtk.Window({ defaultWidth: HARNESS_WINDOW_WIDTH, defaultHeight: HARNESS_WINDOW_HEIGHT });\n window.setDecorated(false);\n\n return { containerInfo: window, window };\n};\n\nconst firstToplevelWidget = (baseElement: Container): Gtk.Widget => {\n if (baseElement instanceof Gtk.Widget) {\n return baseElement;\n }\n\n const [first] = traverse(baseElement);\n\n if (first) {\n return first;\n }\n\n throw new Error(\"render() produced no widgets: ensure the element renders visible content\");\n};\n\nconst resolveResultContainer = (\n resolved: ResolvedContainer,\n container: RenderOptions[\"container\"],\n baseElement: Container,\n): Gtk.Widget => {\n if (resolved.window) {\n return resolved.window;\n }\n\n if (container instanceof Gtk.Widget) {\n return container;\n }\n\n return firstToplevelWidget(baseElement);\n};\n\nconst renderErrorHandlers = <Q extends QueryMap>(options: RenderOptions<Q> | undefined) => ({\n onUncaughtError: handleError,\n onCaughtError: (error: unknown, errorInfo: ErrorInfo): void => {\n handleError(error);\n options?.onCaughtError?.(error, errorInfo);\n },\n onRecoverableError: (error: unknown, errorInfo: ErrorInfo): void => {\n options?.onRecoverableError?.(error, errorInfo);\n },\n});\n\nconst applyEnableAnimations = (areAnimationsEnabled: boolean): void => {\n const settings = Gtk.Settings.getDefault();\n\n if (settings) {\n settings.gtkEnableAnimations = areAnimationsEnabled;\n }\n};\n\n/**\n * Renders a React element into a GTK4 widget tree and returns queries\n * scoped to it along with controls for rerendering and unmounting. When no\n * container is supplied, a harness window is created and presented.\n *\n * @param element The React element to render.\n * @param options Optional container, wrapper, custom queries, and other render settings.\n * @returns A render result with bound queries, debug helpers, and lifecycle controls.\n */\nconst render = async <Q extends QueryMap = Record<never, never>>(\n element: ReactNode,\n options?: RenderOptions<Q>,\n): Promise<RenderResult<Q>> => {\n installErrorHandler();\n applyEnableAnimations(options?.animations === true);\n const baseElement: Container = options?.baseElement ?? TOPLEVELS;\n const Wrapper = options?.wrapper;\n const resolved = resolveContainer(options?.container);\n\n const root = createReconcilerRoot({\n containerInfo: resolved.containerInfo,\n ...renderErrorHandlers(options),\n });\n\n const active: ActiveRender = { root, window: resolved.window };\n activeRenders.add(active);\n addToCleanupQueue(disposeAllActiveRenders);\n addToCleanupQueue(clearScreen);\n addToCleanupQueue(resetClipboard);\n\n const wrap = (node: ReactNode): ReactNode => {\n const wrapped = Wrapper ? <Wrapper>{node}</Wrapper> : node;\n\n return options?.reactStrictMode ? <StrictMode>{wrapped}</StrictMode> : wrapped;\n };\n\n await update(wrap(element), root);\n resolved.window?.present();\n await flushLayout(resolved.window);\n const container = resolveResultContainer(resolved, options?.container, baseElement);\n\n const result: RenderResult<Q> = {\n ...within(baseElement, options?.queries),\n container,\n baseElement,\n unmount: async () => {\n await disposeActiveRender(active);\n },\n rerender: async (newElement: ReactNode) => {\n await update(wrap(newElement), root);\n await flushLayout(resolved.window);\n },\n debug: (element: Container | Container[] = baseElement, debugOptions?: PrettyWidgetOptions) => {\n logWidget(element, debugOptions);\n },\n logRoles: () => {\n logRoles(baseElement);\n },\n screenshot: (selector?: WindowSelector, screenshotOptions?: ScreenshotOptions) =>\n captureAndSaveScreenshot(selector, screenshotOptions),\n };\n\n setScreen(result);\n\n return result;\n};\n\n/**\n * Unmounts every active render and runs all registered cleanup callbacks,\n * resetting the screen and clipboard. Called automatically after each test.\n */\nconst cleanup = async (): Promise<void> => {\n await runCleanup();\n};\n\nexport { render, cleanup };\n"]}
@@ -6,27 +6,28 @@ import { type Container } from "./traversal.js";
6
6
  *
7
7
  * @param role The accessible role to format.
8
8
  */
9
- export declare const formatRole: (role: Gtk.AccessibleRole) => string;
10
- export declare const formatRoleList: (roles: Iterable<Gtk.AccessibleRole>) => string;
9
+ declare const formatRole: (role: Gtk.AccessibleRole) => string;
10
+ declare const formatRoleList: (roles: Iterable<Gtk.AccessibleRole>) => string;
11
11
  /**
12
12
  * Groups every widget in a container's tree by its accessible role name.
13
13
  *
14
14
  * @param container The scope to traverse.
15
15
  * @returns A map from role name to the widgets that have that role.
16
16
  */
17
- export declare const getRoles: (container: Container) => Map<string, Gtk.Widget[]>;
17
+ declare const getRoles: (container: Container) => Map<string, Gtk.Widget[]>;
18
18
  /**
19
19
  * Formats the accessible roles in a container's tree as a readable string,
20
20
  * listing each role together with its widgets and their accessible names.
21
21
  *
22
22
  * @param container The scope to inspect.
23
23
  */
24
- export declare const prettyRoles: (container: Container) => string;
24
+ declare const prettyRoles: (container: Container) => string;
25
25
  /**
26
26
  * Prints the accessible roles in a container's tree to the console using
27
27
  * {@link prettyRoles}.
28
28
  *
29
29
  * @param container The scope to inspect.
30
30
  */
31
- export declare const logRoles: (container: Container) => void;
31
+ declare const logRoles: (container: Container) => void;
32
+ export { formatRole, formatRoleList, getRoles, prettyRoles, logRoles };
32
33
  //# sourceMappingURL=role-helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"role-helpers.d.ts","sourceRoot":"","sources":["../src/role-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,gBAAgB,CAAC;AAY1D;;;;;GAKG;AACH,eAAO,MAAM,UAAU,SAAU,GAAG,CAAC,cAAc,KAAG,MAIrD,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,KAAG,MAWpE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,cAAe,SAAS,KAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAevE,CAAC;AASF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,cAAe,SAAS,KAAG,MAoBlD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,cAAe,SAAS,KAAG,IAE/C,CAAC"}
1
+ {"version":3,"file":"role-helpers.d.ts","sourceRoot":"","sources":["../src/role-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,gBAAgB,CAAC;AAa1D;;;;;GAKG;AACH,QAAA,MAAM,UAAU,GAAI,MAAM,GAAG,CAAC,cAAc,KAAG,MAQ9C,CAAC;AAEF,QAAA,MAAM,cAAc,GAAI,OAAO,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,KAAG,MAe7D,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,QAAQ,GAAI,WAAW,SAAS,KAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAehE,CAAC;AAUF;;;;;GAKG;AACH,QAAA,MAAM,WAAW,GAAI,WAAW,SAAS,KAAG,MAqB3C,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,QAAQ,GAAI,WAAW,SAAS,KAAG,IAExC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC"}
@@ -2,32 +2,35 @@ import * as Gtk from "@gtkx/gi/gtk";
2
2
  import { sortStringsBy } from "@gtkx/utils";
3
3
  import { traverse } from "./traversal.js";
4
4
  import { getWidgetAccessibleName } from "./widget-accessible-properties.js";
5
- const enumNamesByValue = (enumObject) => new Map(Object.entries(enumObject)
6
- .filter((entry) => typeof entry[1] === "number")
7
- .map(([name, value]) => [value, name]));
8
5
  const ROLE_NAMES_BY_VALUE = enumNamesByValue(Gtk.AccessibleRole);
6
+ function enumNamesByValue(enumObject) {
7
+ return new Map(Object.entries(enumObject)
8
+ .filter((entry) => typeof entry[1] === "number")
9
+ .map(([name, value]) => [value, name]));
10
+ }
9
11
  /**
10
12
  * Converts an accessible role enum value into its lowercase name, falling back
11
13
  * to the numeric value when the role is unknown.
12
14
  *
13
15
  * @param role The accessible role to format.
14
16
  */
15
- export const formatRole = (role) => {
17
+ const formatRole = (role) => {
16
18
  const name = ROLE_NAMES_BY_VALUE.get(role);
17
- if (!name)
19
+ if (!name) {
18
20
  return String(role);
21
+ }
19
22
  return name.toLowerCase();
20
23
  };
21
- export const formatRoleList = (roles) => {
24
+ const formatRoleList = (roles) => {
22
25
  const names = [...roles].map((role) => formatRole(role).toUpperCase());
23
26
  if (names.length <= 1) {
24
27
  return names.join("");
25
28
  }
26
29
  if (names.length === 2) {
27
- return `${names[0]} or ${names[1]}`;
30
+ return names.join(" or ");
28
31
  }
29
32
  const head = names.slice(0, -1);
30
- const last = names[names.length - 1];
33
+ const last = names.at(-1) ?? "";
31
34
  return `${head.join(", ")}, or ${last}`;
32
35
  };
33
36
  /**
@@ -36,7 +39,7 @@ export const formatRoleList = (roles) => {
36
39
  * @param container The scope to traverse.
37
40
  * @returns A map from role name to the widgets that have that role.
38
41
  */
39
- export const getRoles = (container) => {
42
+ const getRoles = (container) => {
40
43
  const roles = new Map();
41
44
  for (const widget of traverse(container)) {
42
45
  const roleName = formatRole(widget.getAccessibleRole());
@@ -62,13 +65,13 @@ const formatWidgetPreview = (widget, name) => {
62
65
  *
63
66
  * @param container The scope to inspect.
64
67
  */
65
- export const prettyRoles = (container) => {
68
+ const prettyRoles = (container) => {
66
69
  const roles = getRoles(container);
67
70
  if (roles.size === 0) {
68
71
  return "No accessible roles found in the widget tree.";
69
72
  }
70
73
  const lines = [];
71
- const sortedRoles = sortStringsBy([...roles.entries()], ([roleName]) => roleName);
74
+ const sortedRoles = sortStringsBy([...roles], ([roleName]) => roleName);
72
75
  for (const [roleName, widgets] of sortedRoles) {
73
76
  lines.push(`${roleName}:`);
74
77
  for (const widget of widgets) {
@@ -84,7 +87,8 @@ export const prettyRoles = (container) => {
84
87
  *
85
88
  * @param container The scope to inspect.
86
89
  */
87
- export const logRoles = (container) => {
90
+ const logRoles = (container) => {
88
91
  console.log(prettyRoles(container));
89
92
  };
93
+ export { formatRole, formatRoleList, getRoles, prettyRoles, logRoles };
90
94
  //# sourceMappingURL=role-helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"role-helpers.js","sourceRoot":"","sources":["../src/role-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAkB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAE5E,MAAM,gBAAgB,GAAG,CAAC,UAA2C,EAAuB,EAAE,CAC1F,IAAI,GAAG,CACH,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;KACrB,MAAM,CAAC,CAAC,KAAK,EAA6B,EAAE,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;KAC1E,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAC7C,CAAC;AAEN,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAwB,EAAU,EAAE;IA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,GAAG,CAAC,CAAC;QAC3B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,KAAK,mBAAmB,CAAC,MAAM,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;QACpF,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AACtC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,SAAoB,EAAQ,EAAE;IACnD,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { sortStringsBy } from \"@gtkx/utils\";\nimport { type Container, traverse } from \"./traversal.js\";\nimport { getWidgetAccessibleName } from \"./widget-accessible-properties.js\";\n\nconst enumNamesByValue = (enumObject: Record<string, string | number>): Map<number, string> =>\n new Map<number, string>(\n Object.entries(enumObject)\n .filter((entry): entry is [string, number] => typeof entry[1] === \"number\")\n .map(([name, value]) => [value, name]),\n );\n\nconst ROLE_NAMES_BY_VALUE = enumNamesByValue(Gtk.AccessibleRole);\n\n/**\n * Converts an accessible role enum value into its lowercase name, falling back\n * to the numeric value when the role is unknown.\n *\n * @param role The accessible role to format.\n */\nexport const formatRole = (role: Gtk.AccessibleRole): string => {\n const name = ROLE_NAMES_BY_VALUE.get(role);\n if (!name) return String(role);\n return name.toLowerCase();\n};\n\nexport const formatRoleList = (roles: Iterable<Gtk.AccessibleRole>): string => {\n const names = [...roles].map((role) => formatRole(role).toUpperCase());\n if (names.length <= 1) {\n return names.join(\"\");\n }\n if (names.length === 2) {\n return `${names[0]} or ${names[1]}`;\n }\n const head = names.slice(0, -1);\n const last = names[names.length - 1];\n return `${head.join(\", \")}, or ${last}`;\n};\n\n/**\n * Groups every widget in a container's tree by its accessible role name.\n *\n * @param container The scope to traverse.\n * @returns A map from role name to the widgets that have that role.\n */\nexport const getRoles = (container: Container): Map<string, Gtk.Widget[]> => {\n const roles = new Map<string, Gtk.Widget[]>();\n\n for (const widget of traverse(container)) {\n const roleName = formatRole(widget.getAccessibleRole());\n\n const existing = roles.get(roleName);\n if (existing) {\n existing.push(widget);\n } else {\n roles.set(roleName, [widget]);\n }\n }\n\n return roles;\n};\n\nconst formatWidgetPreview = (widget: Gtk.Widget, name: string | null): string => {\n const tagName = widget.constructor.name;\n const roleAttr = formatRole(widget.getAccessibleRole());\n const nameDisplay = name ? `Name \"${name}\"` : 'Name \"\"';\n return `${nameDisplay}: <${tagName} role=\"${roleAttr}\">${name ?? \"\"}</${tagName}>`;\n};\n\n/**\n * Formats the accessible roles in a container's tree as a readable string,\n * listing each role together with its widgets and their accessible names.\n *\n * @param container The scope to inspect.\n */\nexport const prettyRoles = (container: Container): string => {\n const roles = getRoles(container);\n\n if (roles.size === 0) {\n return \"No accessible roles found in the widget tree.\";\n }\n\n const lines: string[] = [];\n\n const sortedRoles = sortStringsBy([...roles.entries()], ([roleName]) => roleName);\n\n for (const [roleName, widgets] of sortedRoles) {\n lines.push(`${roleName}:`);\n for (const widget of widgets) {\n lines.push(` ${formatWidgetPreview(widget, getWidgetAccessibleName(widget))}`);\n }\n lines.push(\"\");\n }\n\n return lines.join(\"\\n\").trimEnd();\n};\n\n/**\n * Prints the accessible roles in a container's tree to the console using\n * {@link prettyRoles}.\n *\n * @param container The scope to inspect.\n */\nexport const logRoles = (container: Container): void => {\n console.log(prettyRoles(container));\n};\n"]}
1
+ {"version":3,"file":"role-helpers.js","sourceRoot":"","sources":["../src/role-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAkB,QAAQ,EAAE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;;;;GAKG;AACH,MAAM,WAAW,GAAG,CAAC,SAAoB,EAAU,EAAE;IACjD,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAElC,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,+CAA+C,CAAC;IAC3D,CAAC;IAED,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,WAAW,GAAG,aAAa,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC;IAExE,KAAK,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,WAAW,EAAE,CAAC;QAC5C,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC;QAE3B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,KAAK,mBAAmB,CAAC,MAAM,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;QACpF,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AACtC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,CAAC,SAAoB,EAAQ,EAAE;IAC5C,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { sortStringsBy } from \"@gtkx/utils\";\nimport { type Container, traverse } from \"./traversal.js\";\nimport { getWidgetAccessibleName } from \"./widget-accessible-properties.js\";\n\nconst ROLE_NAMES_BY_VALUE = enumNamesByValue(Gtk.AccessibleRole);\n\nfunction enumNamesByValue(enumObject: Record<string, string | number>): Map<number, string> {\n return new Map<number, string>(\n Object.entries(enumObject)\n .filter((entry): entry is [string, number] => typeof entry[1] === \"number\")\n .map(([name, value]) => [value, name]),\n );\n}\n\n/**\n * Converts an accessible role enum value into its lowercase name, falling back\n * to the numeric value when the role is unknown.\n *\n * @param role The accessible role to format.\n */\nconst formatRole = (role: Gtk.AccessibleRole): string => {\n const name = ROLE_NAMES_BY_VALUE.get(role);\n\n if (!name) {\n return String(role);\n }\n\n return name.toLowerCase();\n};\n\nconst formatRoleList = (roles: Iterable<Gtk.AccessibleRole>): string => {\n const names = [...roles].map((role) => formatRole(role).toUpperCase());\n\n if (names.length <= 1) {\n return names.join(\"\");\n }\n\n if (names.length === 2) {\n return names.join(\" or \");\n }\n\n const head = names.slice(0, -1);\n const last = names.at(-1) ?? \"\";\n\n return `${head.join(\", \")}, or ${last}`;\n};\n\n/**\n * Groups every widget in a container's tree by its accessible role name.\n *\n * @param container The scope to traverse.\n * @returns A map from role name to the widgets that have that role.\n */\nconst getRoles = (container: Container): Map<string, Gtk.Widget[]> => {\n const roles: Map<string, Gtk.Widget[]> = new Map();\n\n for (const widget of traverse(container)) {\n const roleName = formatRole(widget.getAccessibleRole());\n const existing = roles.get(roleName);\n\n if (existing) {\n existing.push(widget);\n } else {\n roles.set(roleName, [widget]);\n }\n }\n\n return roles;\n};\n\nconst formatWidgetPreview = (widget: Gtk.Widget, name: string | null): string => {\n const tagName = widget.constructor.name;\n const roleAttr = formatRole(widget.getAccessibleRole());\n const nameDisplay = name ? `Name \"${name}\"` : 'Name \"\"';\n\n return `${nameDisplay}: <${tagName} role=\"${roleAttr}\">${name ?? \"\"}</${tagName}>`;\n};\n\n/**\n * Formats the accessible roles in a container's tree as a readable string,\n * listing each role together with its widgets and their accessible names.\n *\n * @param container The scope to inspect.\n */\nconst prettyRoles = (container: Container): string => {\n const roles = getRoles(container);\n\n if (roles.size === 0) {\n return \"No accessible roles found in the widget tree.\";\n }\n\n const lines: string[] = [];\n const sortedRoles = sortStringsBy([...roles], ([roleName]) => roleName);\n\n for (const [roleName, widgets] of sortedRoles) {\n lines.push(`${roleName}:`);\n\n for (const widget of widgets) {\n lines.push(` ${formatWidgetPreview(widget, getWidgetAccessibleName(widget))}`);\n }\n\n lines.push(\"\");\n }\n\n return lines.join(\"\\n\").trimEnd();\n};\n\n/**\n * Prints the accessible roles in a container's tree to the console using\n * {@link prettyRoles}.\n *\n * @param container The scope to inspect.\n */\nconst logRoles = (container: Container): void => {\n console.log(prettyRoles(container));\n};\n\nexport { formatRole, formatRoleList, getRoles, prettyRoles, logRoles };\n"]}