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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/README.md +4 -5
  2. package/dist/act.d.ts +2 -0
  3. package/dist/act.d.ts.map +1 -1
  4. package/dist/act.js.map +1 -1
  5. package/dist/build-queries.d.ts.map +1 -1
  6. package/dist/build-queries.js +18 -7
  7. package/dist/build-queries.js.map +1 -1
  8. package/dist/config.d.ts +1 -0
  9. package/dist/config.d.ts.map +1 -1
  10. package/dist/config.js +3 -3
  11. package/dist/config.js.map +1 -1
  12. package/dist/errors.js +2 -2
  13. package/dist/errors.js.map +1 -1
  14. package/dist/matchers.d.ts +44 -0
  15. package/dist/matchers.d.ts.map +1 -1
  16. package/dist/matchers.js.map +1 -1
  17. package/dist/pretty-widget.d.ts +2 -1
  18. package/dist/pretty-widget.d.ts.map +1 -1
  19. package/dist/pretty-widget.js +3 -3
  20. package/dist/pretty-widget.js.map +1 -1
  21. package/dist/queries.d.ts +1 -0
  22. package/dist/queries.d.ts.map +1 -1
  23. package/dist/queries.js.map +1 -1
  24. package/dist/render.js +2 -2
  25. package/dist/render.js.map +1 -1
  26. package/dist/suggestions.d.ts +3 -0
  27. package/dist/suggestions.d.ts.map +1 -1
  28. package/dist/suggestions.js.map +1 -1
  29. package/dist/traversal.d.ts +5 -0
  30. package/dist/traversal.d.ts.map +1 -1
  31. package/dist/traversal.js +1 -0
  32. package/dist/traversal.js.map +1 -1
  33. package/dist/types.d.ts +43 -5
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/types.js.map +1 -1
  36. package/dist/user-event/adjustment.d.ts +13 -0
  37. package/dist/user-event/adjustment.d.ts.map +1 -1
  38. package/dist/user-event/adjustment.js +11 -0
  39. package/dist/user-event/adjustment.js.map +1 -1
  40. package/dist/user-event/click.d.ts +7 -0
  41. package/dist/user-event/click.d.ts.map +1 -1
  42. package/dist/user-event/click.js +7 -0
  43. package/dist/user-event/click.js.map +1 -1
  44. package/dist/user-event/controller.d.ts +29 -0
  45. package/dist/user-event/controller.d.ts.map +1 -1
  46. package/dist/user-event/controller.js +28 -0
  47. package/dist/user-event/controller.js.map +1 -1
  48. package/dist/user-event/gesture.d.ts +51 -0
  49. package/dist/user-event/gesture.d.ts.map +1 -1
  50. package/dist/user-event/gesture.js +47 -4
  51. package/dist/user-event/gesture.js.map +1 -1
  52. package/dist/user-event/index.d.ts +27 -0
  53. package/dist/user-event/index.d.ts.map +1 -1
  54. package/dist/user-event/index.js.map +1 -1
  55. package/dist/user-event/keyboard.d.ts +4 -2
  56. package/dist/user-event/keyboard.d.ts.map +1 -1
  57. package/dist/user-event/keyboard.js +13 -12
  58. package/dist/user-event/keyboard.js.map +1 -1
  59. package/dist/user-event/pointer.js +5 -5
  60. package/dist/user-event/pointer.js.map +1 -1
  61. package/dist/user-event/selection.d.ts +15 -0
  62. package/dist/user-event/selection.d.ts.map +1 -1
  63. package/dist/user-event/selection.js +15 -0
  64. package/dist/user-event/selection.js.map +1 -1
  65. package/dist/user-event/state.d.ts +1 -1
  66. package/dist/user-event/state.d.ts.map +1 -1
  67. package/dist/user-event/state.js +1 -1
  68. package/dist/user-event/state.js.map +1 -1
  69. package/dist/user-event/text.d.ts +30 -3
  70. package/dist/user-event/text.d.ts.map +1 -1
  71. package/dist/user-event/text.js +28 -1
  72. package/dist/user-event/text.js.map +1 -1
  73. package/dist/wait-for.d.ts +2 -0
  74. package/dist/wait-for.d.ts.map +1 -1
  75. package/dist/wait-for.js.map +1 -1
  76. package/dist/widget-accessible-properties.d.ts +17 -1
  77. package/dist/widget-accessible-properties.d.ts.map +1 -1
  78. package/dist/widget-accessible-properties.js +17 -0
  79. package/dist/widget-accessible-properties.js.map +1 -1
  80. package/package.json +7 -7
  81. package/src/act.ts +2 -0
  82. package/src/build-queries.ts +20 -8
  83. package/src/config.ts +4 -3
  84. package/src/errors.ts +2 -2
  85. package/src/matchers.ts +44 -0
  86. package/src/pretty-widget.ts +5 -4
  87. package/src/queries.ts +1 -0
  88. package/src/render.tsx +2 -2
  89. package/src/suggestions.ts +3 -0
  90. package/src/traversal.ts +5 -0
  91. package/src/types.ts +43 -5
  92. package/src/user-event/adjustment.ts +13 -0
  93. package/src/user-event/click.ts +7 -0
  94. package/src/user-event/controller.ts +29 -0
  95. package/src/user-event/gesture.ts +57 -6
  96. package/src/user-event/index.ts +27 -0
  97. package/src/user-event/keyboard.ts +18 -16
  98. package/src/user-event/pointer.ts +5 -5
  99. package/src/user-event/selection.ts +15 -0
  100. package/src/user-event/state.ts +2 -2
  101. package/src/user-event/text.ts +31 -4
  102. package/src/wait-for.ts +2 -0
  103. package/src/widget-accessible-properties.ts +17 -1
@@ -1 +1 @@
1
- {"version":3,"file":"matchers.js","sourceRoot":"","sources":["../src/matchers.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAEH,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,eAAe,GAClB,MAAM,mCAAmC,CAAC;AA4D3C,MAAM,YAAY,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AAC7C,MAAM,mBAAmB,GAAgB,WAAW,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,OAAO,CAAC,CAAC;AAC3G,MAAM,oBAAoB,GAAgB,WAAW,CAAC,sBA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MAAM,CAAC,qBAAqB,MAAM,CAAC,IAAI,CAAC,IAAI;YACjG,YAAY,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;KACrF,CAAC;AACN,CAAC;AAED,gHAAgH;AAChH,MAAM,gBAAgB,GAAG,GAAS,EAAE;IAChC,IAAI,YAAY,CAAC,YAAY,EAAE,CAAC;QAC5B,OAAO;IACX,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAE9B,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,OAAO;IACX,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxB,YAAY,CAAC,YAAY,GAAG,IAAI,CAAC;AACrC,CAAC,CAAC;AAsCF,OAAO,EACH,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,2BAA2B,EAC3B,4BAA4B,EAC5B,qBAAqB,EACrB,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,QAAQ,EACR,gBAAgB,GAInB,CAAC","sourcesContent":["/// <reference types=\"@vitest/expect\" />\nimport * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { getDefaultNormalizer } from \"./normalize.js\";\nimport { formatRole } from \"./role-helpers.js\";\nimport {\n type CheckedState,\n getWidgetAccessibleName,\n getWidgetCheckedState,\n getWidgetDescribedByText,\n getWidgetDisplayValue,\n getWidgetErrorMessage,\n getWidgetExpandedState,\n getWidgetInvalidState,\n getWidgetLabelText,\n getWidgetPlaceholderText,\n getWidgetPressedState,\n getWidgetRequiredState,\n getWidgetSelectedState,\n getWidgetSelection,\n getWidgetTextContent,\n getWidgetValue,\n hasDisplayValue,\n isWidgetDisabled,\n isWidgetVisible,\n} from \"./widget-accessible-properties.js\";\n\n/** The expected value for a text matcher: an exact string or a regular expression. */\ntype TextExpectation = string | RegExp;\n\n/** Options controlling how `toHaveTextContent` normalizes the text it reads. */\ntype TextContentOptions = {\n /**\n * When true (the default), trim the text and collapse runs of whitespace into single spaces\n * before comparing. When false, only replace non-breaking spaces with regular ones.\n */\n normalizeWhitespace?: boolean | undefined;\n};\n\n/** The expected value for a style class: an exact class name or a regular expression. */\ntype ClassExpectation = string | RegExp;\ntype MatcherResult = { pass: boolean; message: () => string };\ntype MatcherContext = { equals: (actual: unknown, expected: unknown) => boolean };\ntype TextMatcher = (received: unknown, expected?: TextExpectation) => MatcherResult;\ntype StateMatcher = (received: unknown) => MatcherResult;\ntype TextMatcherContext = { matcherName: string; widget: Gtk.Widget; actual: string | null };\ntype ClassArguments = { expected: ClassExpectation[]; isExact: boolean };\n\ntype TextContentMatcher = (\n received: unknown,\n expected?: TextExpectation,\n options?: TextContentOptions,\n) => MatcherResult;\n\ntype MatcherImplementations = {\n toHaveDisplayValue: TextMatcher;\n toHaveTextContent: TextContentMatcher;\n toHaveAccessibleName: TextMatcher;\n toHaveAccessibleDescription: TextMatcher;\n toHaveAccessibleErrorMessage: TextMatcher;\n toHavePlaceholderText: TextMatcher;\n toHaveSelection: TextMatcher;\n toBeChecked: StateMatcher;\n toBePartiallyChecked: StateMatcher;\n toBePressed: StateMatcher;\n toBeExpanded: StateMatcher;\n toBeSelected: StateMatcher;\n toBeDisabled: StateMatcher;\n toBeEnabled: StateMatcher;\n toBeVisible: StateMatcher;\n toBeRooted: StateMatcher;\n toBeEmpty: StateMatcher;\n toBeInvalid: StateMatcher;\n toBeValid: StateMatcher;\n toBeRequired: StateMatcher;\n toHaveFocus: StateMatcher;\n toHaveValue: (received: unknown, expected?: number | string) => MatcherResult;\n toHaveRole: (received: unknown, expected: Gtk.AccessibleRole) => MatcherResult;\n toContainElement: (received: unknown, descendant: Gtk.Widget | null) => MatcherResult;\n toHaveClass: (received: unknown, ...args: unknown[]) => MatcherResult;\n toHaveObjectProperty: (this: MatcherContext, received: unknown, ...args: unknown[]) => MatcherResult;\n};\n\ntype ExpectExtend = { extend: (m: MatcherImplementations) => void };\n\nconst registration = { isRegistered: false };\nconst displayValueMatcher: TextMatcher = textMatcher(\"toHaveDisplayValue\", getWidgetDisplayValue, \"exact\");\nconst toHaveAccessibleName: TextMatcher = textMatcher(\"toHaveAccessibleName\", getWidgetAccessibleName, \"exact\");\n\nconst toHaveAccessibleDescription: TextMatcher = textMatcher(\n \"toHaveAccessibleDescription\",\n getWidgetDescribedByText,\n \"exact\",\n);\n\nconst toHaveAccessibleErrorMessage: TextMatcher = textMatcher(\n \"toHaveAccessibleErrorMessage\",\n readErrorMessageText,\n \"exact\",\n);\n\nconst toHavePlaceholderText: TextMatcher = textMatcher(\"toHavePlaceholderText\", getWidgetPlaceholderText, \"exact\");\nconst toHaveSelection: TextMatcher = textMatcher(\"toHaveSelection\", getWidgetSelection, \"exact\");\nconst toBePressed: StateMatcher = booleanStateMatcher(\"toBePressed\", \"pressed\", getWidgetPressedState);\nconst toBeExpanded: StateMatcher = booleanStateMatcher(\"toBeExpanded\", \"expanded\", getWidgetExpandedState);\nconst toBeSelected: StateMatcher = booleanStateMatcher(\"toBeSelected\", \"selected\", getWidgetSelectedState);\nconst toBeRequired: StateMatcher = booleanStateMatcher(\"toBeRequired\", \"required\", getWidgetRequiredState);\n\n/** The widget assertion matchers keyed by name, suitable for passing to `expect.extend`. */\nconst matchers: MatcherImplementations = {\n toHaveDisplayValue,\n toHaveTextContent,\n toHaveAccessibleName,\n toHaveAccessibleDescription,\n toHaveAccessibleErrorMessage,\n toHavePlaceholderText,\n toHaveSelection,\n toBeChecked,\n toBePartiallyChecked,\n toBePressed,\n toBeExpanded,\n toBeSelected,\n toBeDisabled,\n toBeEnabled,\n toBeVisible,\n toBeRooted,\n toBeEmpty,\n toBeInvalid,\n toBeValid,\n toBeRequired,\n toHaveFocus,\n toHaveValue,\n toHaveRole,\n toContainElement,\n toHaveClass,\n toHaveObjectProperty,\n};\n\nconst asWidget = (received: unknown, matcherName: string): Gtk.Widget => {\n if (!(received instanceof Gtk.Widget)) {\n throw new TypeError(`${matcherName}: received value must be a Gtk.Widget, got ${typeof received}`);\n }\n\n return received;\n};\n\nconst asObject = (received: unknown, matcherName: string): GObject.Object => {\n if (!(received instanceof GObject.Object)) {\n throw new TypeError(`${matcherName}: received value must be a GObject, got ${typeof received}`);\n }\n\n return received;\n};\n\nconst describeWidget = (widget: Gtk.Widget): string => {\n const role = Gtk.AccessibleRole[widget.getAccessibleRole()];\n const name = getWidgetAccessibleName(widget);\n\n return name === null ? `<${role}>` : `<${role} name=${JSON.stringify(name)}>`;\n};\n\nconst describeObject = (object: GObject.Object): string =>\n object instanceof Gtk.Widget ? describeWidget(object) : `<${object.constructor.name}>`;\n\nconst isTextMatch = (actual: string, expected: TextExpectation, mode: \"exact\" | \"substring\"): boolean => {\n if (expected instanceof RegExp) {\n expected.lastIndex = 0;\n\n return expected.test(actual);\n }\n\n return mode === \"exact\" ? actual === expected : actual.includes(expected);\n};\n\nconst describeExpected = (expected: TextExpectation): string =>\n expected instanceof RegExp ? String(expected) : JSON.stringify(expected);\n\nconst negationPrefix = (isPass: boolean): string => (isPass ? \"not \" : \"\");\n\nconst nonEmptyResult = ({ matcherName, widget, actual }: TextMatcherContext): MatcherResult => {\n const isPass = actual !== null && actual !== \"\";\n\n return {\n pass: isPass,\n message: () =>\n `expected widget ${negationPrefix(isPass)}to have a non-empty value for ${matcherName}, ` +\n `but got ${JSON.stringify(actual)}\\n${describeWidget(widget)}`,\n };\n};\n\nconst matchedResult = (context: TextMatcherContext, expected: TextExpectation, isPass: boolean): MatcherResult => ({\n pass: isPass,\n message: () =>\n `expected widget ${negationPrefix(isPass)}${context.matcherName} ${describeExpected(expected)}, ` +\n `but received ${JSON.stringify(context.actual)}\\n${describeWidget(context.widget)}`,\n});\n\nconst stateResult = (widget: Gtk.Widget, stateName: string, isPass: boolean): MatcherResult => ({\n pass: isPass,\n message: () => `expected widget ${negationPrefix(isPass)}to be ${stateName}\\n${describeWidget(widget)}`,\n});\n\nconst camelCase = (name: string): string =>\n name.replaceAll(/-([a-z])/g, (_match, letter: string) => letter.toUpperCase());\n\nconst isAsymmetricMatcher = (value: unknown): boolean =>\n typeof value === \"object\" && value !== null && typeof Reflect.get(value, \"asymmetricMatch\") === \"function\";\n\nconst isEqualValue = (context: MatcherContext, actual: unknown, expected: unknown): boolean => {\n if (isAsymmetricMatcher(expected)) {\n return context.equals(actual, expected);\n }\n\n if (actual instanceof GObject.Object || expected instanceof GObject.Object) {\n return Object.is(actual, expected);\n }\n\n return context.equals(actual, expected);\n};\n\nconst isClassMatch = (actual: string[], expected: ClassExpectation): boolean =>\n expected instanceof RegExp ? actual.some((name) => expected.test(name)) : actual.includes(expected);\n\nconst isWidgetRooted = (widget: Gtk.Widget): boolean => {\n const root = widget.getRoot();\n\n if (root === null) {\n return false;\n }\n\n if (root instanceof Gtk.Window) {\n return Gtk.Window.listToplevels().includes(root);\n }\n\n return true;\n};\n\nconst globalExpect = (): ExpectExtend | null => {\n const candidate: unknown = Reflect.get(globalThis, \"expect\");\n\n if (candidate && typeof (candidate as ExpectExtend).extend === \"function\") {\n return candidate as ExpectExtend;\n }\n\n return null;\n};\n\nfunction readErrorMessageText(widget: Gtk.Widget): string | null {\n const state = getWidgetInvalidState(widget);\n\n if (state === null || state === Gtk.AccessibleInvalidState.FALSE) {\n return null;\n }\n\n const targets = getWidgetErrorMessage(widget);\n\n if (targets === null) {\n return null;\n }\n\n const texts = targets.map((target) => getWidgetAccessibleName(target)).filter((text) => text !== null);\n\n return texts.length > 0 ? texts.join(\" \") : null;\n}\n\nfunction assertReadableProperty(object: GObject.Object, name: string, property: string, value: unknown): void {\n if (typeof value === \"function\") {\n throw new TypeError(\n `toHaveObjectProperty: \"${name}\" is shadowed by a method of the same name; ` +\n `call ${property}() and assert on its result instead`,\n );\n }\n\n if (value === undefined && !Reflect.has(object, property)) {\n throw new TypeError(\n `toHaveObjectProperty: no readable property \"${name}\" on ${describeObject(object)}; ` +\n \"construct-only and write-only properties cannot be read back\",\n );\n }\n}\n\nfunction readObjectProperty(object: GObject.Object, name: string): unknown {\n const property = camelCase(name);\n const value: unknown = Reflect.get(object, property);\n assertReadableProperty(object, name, property, value);\n\n return value;\n}\n\nfunction classEntries(entry: unknown): ClassExpectation[] {\n return entry instanceof RegExp ? [entry] : String(entry).split(/\\s+/).filter(Boolean);\n}\n\nfunction parseClassArguments(args: unknown[]): ClassArguments {\n const last = args.at(-1);\n const isOptions = typeof last === \"object\" && last !== null && !(last instanceof RegExp);\n const isExact = isOptions && Reflect.get(last, \"exact\") === true;\n const entries = isOptions ? args.slice(0, -1) : args;\n\n return { expected: entries.flatMap((entry) => classEntries(entry)), isExact };\n}\n\nfunction exactClassResult(widget: Gtk.Widget, actual: string[], expected: ClassExpectation[]): MatcherResult {\n if (expected.some((entry) => entry instanceof RegExp)) {\n throw new TypeError(\"toHaveClass: the exact option cannot be combined with a regular expression\");\n }\n\n const names = expected.map(String);\n const isPass = names.length === actual.length && names.every((name) => actual.includes(name));\n\n return {\n pass: isPass,\n message: () =>\n `expected widget ${negationPrefix(isPass)}to have exactly the classes ${JSON.stringify(names)}, ` +\n `but received ${JSON.stringify(actual)}\\n${describeWidget(widget)}`,\n };\n}\n\nfunction textMatcher(\n matcherName: string,\n read: (widget: Gtk.Widget) => string | null,\n mode: \"exact\" | \"substring\",\n): TextMatcher {\n return (received: unknown, expected?: TextExpectation): MatcherResult => {\n const widget = asWidget(received, matcherName);\n const actual = read(widget);\n const context: TextMatcherContext = { matcherName, widget, actual };\n\n if (expected === undefined) {\n return nonEmptyResult(context);\n }\n\n return matchedResult(context, expected, actual !== null && isTextMatch(actual, expected, mode));\n };\n}\n\nfunction normalizeTextContent(text: string, options?: TextContentOptions): string {\n if (options?.normalizeWhitespace === false) {\n return text.replaceAll(\"\\u{A0}\", \" \");\n }\n\n return getDefaultNormalizer()(text);\n}\n\nfunction readTextContent(widget: Gtk.Widget, options?: TextContentOptions): string | null {\n const text = getWidgetTextContent(widget);\n\n return text === null ? null : normalizeTextContent(text, options);\n}\n\nfunction toHaveTextContent(\n received: unknown,\n expected?: TextExpectation,\n options?: TextContentOptions,\n): MatcherResult {\n const read = (widget: Gtk.Widget): string | null => readTextContent(widget, options);\n\n return textMatcher(\"toHaveTextContent\", read, \"substring\")(received, expected);\n}\n\nfunction notApplicable(matcherName: string, stateName: string, widget: Gtk.Widget): Error {\n return new Error(\n `${matcherName}: widget does not expose a ${stateName} ` +\n `(role ${Gtk.AccessibleRole[widget.getAccessibleRole()]})\\n${describeWidget(widget)}`,\n );\n}\n\nfunction booleanStateMatcher(\n matcherName: string,\n stateName: string,\n read: (widget: Gtk.Widget) => boolean | null,\n): StateMatcher {\n return (received: unknown): MatcherResult => {\n const widget = asWidget(received, matcherName);\n const state = read(widget);\n\n if (state === null) {\n throw notApplicable(matcherName, `${stateName} state`, widget);\n }\n\n return stateResult(widget, stateName, state);\n };\n}\n\nfunction readCheckedState(widget: Gtk.Widget, matcherName: string): CheckedState {\n const state = getWidgetCheckedState(widget);\n\n if (state === null) {\n throw notApplicable(matcherName, \"checked state\", widget);\n }\n\n return state;\n}\n\nfunction toBeChecked(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBeChecked\");\n\n return stateResult(widget, \"checked\", readCheckedState(widget, \"toBeChecked\") === \"checked\");\n}\n\nfunction toBePartiallyChecked(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBePartiallyChecked\");\n\n return stateResult(widget, \"partially checked\", readCheckedState(widget, \"toBePartiallyChecked\") === \"mixed\");\n}\n\nfunction toHaveDisplayValue(received: unknown, expected?: TextExpectation): MatcherResult {\n const widget = asWidget(received, \"toHaveDisplayValue\");\n\n if (!hasDisplayValue(widget)) {\n throw notApplicable(\"toHaveDisplayValue\", \"display value\", widget);\n }\n\n return displayValueMatcher(received, expected);\n}\n\nfunction toHaveValue(received: unknown, expected?: number | string): MatcherResult {\n const widget = asWidget(received, \"toHaveValue\");\n\n if (typeof expected === \"string\") {\n return displayValueMatcher(received, expected);\n }\n\n const actual = getWidgetValue(widget).now;\n\n if (actual === null) {\n throw notApplicable(\"toHaveValue\", \"numeric value\", widget);\n }\n\n const isPass = expected === undefined || actual === expected;\n\n return {\n pass: isPass,\n message: () =>\n `expected widget ${negationPrefix(isPass)}to have value ${String(expected)}, ` +\n `but received ${String(actual)}\\n${describeWidget(widget)}`,\n };\n}\n\nfunction toBeDisabled(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBeDisabled\");\n\n return stateResult(widget, \"disabled\", isWidgetDisabled(widget));\n}\n\nfunction toBeEnabled(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBeEnabled\");\n\n return stateResult(widget, \"enabled\", !isWidgetDisabled(widget));\n}\n\nfunction toBeVisible(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBeVisible\");\n\n return stateResult(widget, \"visible\", isWidgetVisible(widget));\n}\n\nfunction toBeRooted(received: unknown): MatcherResult {\n if (received === null) {\n return { pass: false, message: () => \"expected a widget to be rooted in a window, but received null\" };\n }\n\n const widget = asWidget(received, \"toBeRooted\");\n\n return stateResult(widget, \"rooted in a window\", isWidgetRooted(widget));\n}\n\nfunction toBeEmpty(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBeEmpty\");\n\n return stateResult(widget, \"empty\", widget.getFirstChild() === null && getWidgetLabelText(widget) === null);\n}\n\nfunction toBeInvalid(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBeInvalid\");\n const state = getWidgetInvalidState(widget);\n\n return stateResult(widget, \"invalid\", state !== null && state !== Gtk.AccessibleInvalidState.FALSE);\n}\n\nfunction toBeValid(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBeValid\");\n const state = getWidgetInvalidState(widget);\n\n return stateResult(widget, \"valid\", state === null || state === Gtk.AccessibleInvalidState.FALSE);\n}\n\nfunction toHaveFocus(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toHaveFocus\");\n\n return stateResult(widget, \"focused\", widget.getPlatformState(Gtk.AccessiblePlatformState.FOCUSED));\n}\n\nfunction toHaveRole(received: unknown, expected: Gtk.AccessibleRole): MatcherResult {\n const widget = asWidget(received, \"toHaveRole\");\n const actual = widget.getAccessibleRole();\n const isPass = actual === expected;\n\n return {\n pass: isPass,\n message: () =>\n `expected widget ${negationPrefix(isPass)}to have role '${formatRole(expected)}', ` +\n `but received '${formatRole(actual)}'\\n${describeWidget(widget)}`,\n };\n}\n\nfunction toContainElement(received: unknown, descendant: Gtk.Widget | null): MatcherResult {\n const widget = asWidget(received, \"toContainElement\");\n const isPass = descendant !== null && (descendant === widget || descendant.isAncestor(widget));\n\n return {\n pass: isPass,\n message: () =>\n `expected widget ${negationPrefix(isPass)}to contain ` +\n `${descendant === null ? \"null\" : describeWidget(descendant)}\\n${describeWidget(widget)}`,\n };\n}\n\nfunction toHaveClass(received: unknown, ...args: unknown[]): MatcherResult {\n const widget = asWidget(received, \"toHaveClass\");\n const actual = widget.getCssClasses();\n const { expected, isExact } = parseClassArguments(args);\n\n if (isExact) {\n return exactClassResult(widget, actual, expected);\n }\n\n if (expected.length === 0) {\n return stateResult(widget, \"given any style class\", actual.length > 0);\n }\n\n const isPass = expected.every((entry) => isClassMatch(actual, entry));\n\n return {\n pass: isPass,\n message: () =>\n `expected widget ${negationPrefix(isPass)}to have class ${expected.map(String).join(\", \")}, ` +\n `but received ${JSON.stringify(actual)}\\n${describeWidget(widget)}`,\n };\n}\n\nfunction toHaveObjectProperty(this: MatcherContext, received: unknown, ...args: unknown[]): MatcherResult {\n const object = asObject(received, \"toHaveObjectProperty\");\n const [name, expected] = args;\n const actual = readObjectProperty(object, String(name));\n\n if (args.length < 2) {\n const isSet = actual !== null && actual !== undefined;\n\n return {\n pass: isSet,\n message: () =>\n `expected ${describeObject(object)} ${negationPrefix(isSet)}to have a value for property ` +\n `\"${String(name)}\", but received ${JSON.stringify(actual)}`,\n };\n }\n\n /* eslint-disable-next-line unicorn/no-this-outside-of-class --\n expect.extend invokes matchers with the matcher state as `this` */\n const isPass = isEqualValue(this, actual, expected);\n\n return {\n pass: isPass,\n message: () =>\n `expected ${describeObject(object)} ${negationPrefix(isPass)}to have property \"${String(name)}\" ` +\n `equal to ${JSON.stringify(expected)}, but received ${JSON.stringify(actual)}`,\n };\n}\n\n/** Registers the widget matchers on the global `expect`, when one is available. Safe to call more than once. */\nconst registerMatchers = (): void => {\n if (registration.isRegistered) {\n return;\n }\n\n const expect = globalExpect();\n\n if (!expect) {\n return;\n }\n\n expect.extend(matchers);\n registration.isRegistered = true;\n};\n\ndeclare module \"@vitest/expect\" {\n /* eslint-disable @typescript-eslint/consistent-type-definitions -- declaration merging requires interfaces */\n interface WidgetMatchers {\n toHaveDisplayValue(expected?: TextExpectation): void;\n toHaveTextContent(expected?: TextExpectation, options?: TextContentOptions): void;\n toHaveAccessibleName(expected?: TextExpectation): void;\n toHaveAccessibleDescription(expected?: TextExpectation): void;\n toHaveAccessibleErrorMessage(expected?: TextExpectation): void;\n toHavePlaceholderText(expected?: TextExpectation): void;\n toHaveSelection(expected?: TextExpectation): void;\n toBeChecked(): void;\n toBePartiallyChecked(): void;\n toBePressed(): void;\n toBeExpanded(): void;\n toBeSelected(): void;\n toBeDisabled(): void;\n toBeEnabled(): void;\n toBeVisible(): void;\n toBeRooted(): void;\n toBeEmpty(): void;\n toBeInvalid(): void;\n toBeValid(): void;\n toBeRequired(): void;\n toHaveFocus(): void;\n toHaveValue(expected?: number | string): void;\n toHaveRole(expected: Gtk.AccessibleRole): void;\n toContainElement(descendant: Gtk.Widget | null): void;\n toHaveClass(...args: (ClassExpectation | { exact: boolean })[]): void;\n toHaveObjectProperty(name: string, expected?: unknown): void;\n }\n\n interface Assertion extends WidgetMatchers {}\n interface AsymmetricMatchersContaining extends WidgetMatchers {}\n /* eslint-enable @typescript-eslint/consistent-type-definitions */\n}\n\nexport {\n toHaveDisplayValue,\n toHaveTextContent,\n toHaveAccessibleName,\n toHaveAccessibleDescription,\n toHaveAccessibleErrorMessage,\n toHavePlaceholderText,\n toHaveSelection,\n toBeChecked,\n toBePartiallyChecked,\n toBePressed,\n toBeExpanded,\n toBeSelected,\n toBeDisabled,\n toBeEnabled,\n toBeVisible,\n toBeRooted,\n toBeEmpty,\n toBeInvalid,\n toBeValid,\n toBeRequired,\n toHaveFocus,\n toHaveValue,\n toHaveRole,\n toContainElement,\n toHaveClass,\n toHaveObjectProperty,\n matchers,\n registerMatchers,\n type ClassExpectation,\n type TextContentOptions,\n type TextExpectation,\n};\n"]}
1
+ {"version":3,"file":"matchers.js","sourceRoot":"","sources":["../src/matchers.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAEH,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,eAAe,GAClB,MAAM,mCAAmC,CAAC;AAwG3C,MAAM,YAAY,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AAC7C,MAAM,mBAAmB,GAAgB,WAAW,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,OAAO,CAAC,CAAC;AAC3G,MAAM,oBAAoB,GAAgB,WAAW,CAAC,sBAAsB,EAAE,uBAA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AqB,MAAM,CAAC,IAAI,CAAC,IAAI;YACjG,YAAY,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;KACrF,CAAC;AACN,CAAC;AAED,gHAAgH;AAChH,MAAM,gBAAgB,GAAG,GAAS,EAAE;IAChC,IAAI,YAAY,CAAC,YAAY,EAAE,CAAC;QAC5B,OAAO;IACX,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAE9B,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,OAAO;IACX,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxB,YAAY,CAAC,YAAY,GAAG,IAAI,CAAC;AACrC,CAAC,CAAC;AAsCF,OAAO,EACH,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,2BAA2B,EAC3B,4BAA4B,EAC5B,qBAAqB,EACrB,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,QAAQ,EACR,gBAAgB,GAInB,CAAC","sourcesContent":["/// <reference types=\"@vitest/expect\" />\nimport * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { getDefaultNormalizer } from \"./normalize.js\";\nimport { formatRole } from \"./role-helpers.js\";\nimport {\n type CheckedState,\n getWidgetAccessibleName,\n getWidgetCheckedState,\n getWidgetDescribedByText,\n getWidgetDisplayValue,\n getWidgetErrorMessage,\n getWidgetExpandedState,\n getWidgetInvalidState,\n getWidgetLabelText,\n getWidgetPlaceholderText,\n getWidgetPressedState,\n getWidgetRequiredState,\n getWidgetSelectedState,\n getWidgetSelection,\n getWidgetTextContent,\n getWidgetValue,\n hasDisplayValue,\n isWidgetDisabled,\n isWidgetVisible,\n} from \"./widget-accessible-properties.js\";\n\n/** The expected value for a text matcher: an exact string or a regular expression. */\ntype TextExpectation = string | RegExp;\n\n/** Options controlling how `toHaveTextContent` normalizes the text it reads. */\ntype TextContentOptions = {\n /**\n * When true (the default), trim the text and collapse runs of whitespace into single spaces\n * before comparing. When false, only replace non-breaking spaces with regular ones.\n */\n normalizeWhitespace?: boolean | undefined;\n};\n\n/** The expected value for a style class: an exact class name or a regular expression. */\ntype ClassExpectation = string | RegExp;\n/** The outcome of a matcher: whether it passed, and the failure text built on demand. */\ntype MatcherResult = { pass: boolean; message: () => string };\n/** The matcher state bound as `this`, supplying the test runner's deep equality check. */\ntype MatcherContext = { equals: (actual: unknown, expected: unknown) => boolean };\n/** Compares text read from the received widget; with no expected value, asserts the text is non-empty. */\ntype TextMatcher = (received: unknown, expected?: TextExpectation) => MatcherResult;\n/** Asserts a single state of the received widget, taking no expected value. */\ntype StateMatcher = (received: unknown) => MatcherResult;\ntype TextMatcherContext = { matcherName: string; widget: Gtk.Widget; actual: string | null };\ntype ClassArguments = { expected: ClassExpectation[]; isExact: boolean };\n\n/** A text matcher that also takes normalization options for the text it reads. */\ntype TextContentMatcher = (\n received: unknown,\n expected?: TextExpectation,\n options?: TextContentOptions,\n) => MatcherResult;\n\n/** Signatures of the widget assertion matchers, keyed by the name each is registered under. */\ntype MatcherImplementations = {\n /** Asserts the text an editable widget or combo box shows; with no argument, that it is not empty. */\n toHaveDisplayValue: TextMatcher;\n /** Asserts the widget's own text, or its descendants' when it has none, contains or matches the expectation. */\n toHaveTextContent: TextContentMatcher;\n /** Asserts the widget's accessible name; with no argument, that it has one. */\n toHaveAccessibleName: TextMatcher;\n /**\n * Asserts the joined accessible names of the widget's `described-by` targets, falling back to its\n * `description` and then to its tooltip.\n */\n toHaveAccessibleDescription: TextMatcher;\n /** Asserts the joined accessible names of the widget's `error-message` targets, read only while it is invalid. */\n toHaveAccessibleErrorMessage: TextMatcher;\n /** Asserts the widget's placeholder text; with no argument, that it has some. */\n toHavePlaceholderText: TextMatcher;\n /** Asserts the text currently selected in an editable widget. */\n toHaveSelection: TextMatcher;\n /** Asserts the widget's checked state is checked rather than unchecked or mixed. */\n toBeChecked: StateMatcher;\n /** Asserts the widget's checked state is mixed. */\n toBePartiallyChecked: StateMatcher;\n /** Asserts a `Gtk.ToggleButton` is active, and throws for any other widget. */\n toBePressed: StateMatcher;\n /** Asserts a `Gtk.Expander` or the row behind a `Gtk.TreeExpander` is expanded, and throws for anything else. */\n toBeExpanded: StateMatcher;\n /**\n * Asserts a `Gtk.ListBoxRow` or `Gtk.FlowBoxChild` is selected, or that a widget in a selectable role\n * carries the selected state flag, and throws for anything else.\n */\n toBeSelected: StateMatcher;\n /** Asserts the widget is insensitive, or sits inside an insensitive ancestor. */\n toBeDisabled: StateMatcher;\n /** Asserts the widget and all of its ancestors are sensitive. */\n toBeEnabled: StateMatcher;\n /** Asserts the widget and its ancestors are all visible, and that none of them is fully transparent. */\n toBeVisible: StateMatcher;\n /** Asserts the widget's root is a window that is still in the toplevel list. */\n toBeRooted: StateMatcher;\n /** Asserts the widget has neither a child nor label text. */\n toBeEmpty: StateMatcher;\n /** Asserts the widget's accessible invalid state is set to anything other than false. */\n toBeInvalid: StateMatcher;\n /** Asserts the widget's accessible invalid state is unset or false. */\n toBeValid: StateMatcher;\n /** Asserts the widget's accessible required state. */\n toBeRequired: StateMatcher;\n /** Asserts the widget holds the platform focus state. */\n toHaveFocus: StateMatcher;\n /** Asserts a widget's numeric value, or its display value when a string is given. */\n toHaveValue: (received: unknown, expected?: number | string) => MatcherResult;\n /** Asserts the widget's accessible role. */\n toHaveRole: (received: unknown, expected: Gtk.AccessibleRole) => MatcherResult;\n /** Asserts the widget is, or is an ancestor of, the given widget. */\n toContainElement: (received: unknown, descendant: Gtk.Widget | null) => MatcherResult;\n /**\n * Asserts the widget carries every given style class, each a name, a space-separated list, or a pattern.\n * Pass `{ exact: true }` last to require exactly that set, which rules out patterns.\n */\n toHaveClass: (received: unknown, ...args: unknown[]) => MatcherResult;\n /**\n * Asserts a GObject property, named as in GObject and looked up by its camel-cased accessor, equals the\n * expected value. With no expected value, asserts the property is set. GObject values compare by identity.\n */\n toHaveObjectProperty: (this: MatcherContext, received: unknown, ...args: unknown[]) => MatcherResult;\n};\n\ntype ExpectExtend = { extend: (m: MatcherImplementations) => void };\n\nconst registration = { isRegistered: false };\nconst displayValueMatcher: TextMatcher = textMatcher(\"toHaveDisplayValue\", getWidgetDisplayValue, \"exact\");\nconst toHaveAccessibleName: TextMatcher = textMatcher(\"toHaveAccessibleName\", getWidgetAccessibleName, \"exact\");\n\nconst toHaveAccessibleDescription: TextMatcher = textMatcher(\n \"toHaveAccessibleDescription\",\n getWidgetDescribedByText,\n \"exact\",\n);\n\nconst toHaveAccessibleErrorMessage: TextMatcher = textMatcher(\n \"toHaveAccessibleErrorMessage\",\n readErrorMessageText,\n \"exact\",\n);\n\nconst toHavePlaceholderText: TextMatcher = textMatcher(\"toHavePlaceholderText\", getWidgetPlaceholderText, \"exact\");\nconst toHaveSelection: TextMatcher = textMatcher(\"toHaveSelection\", getWidgetSelection, \"exact\");\nconst toBePressed: StateMatcher = booleanStateMatcher(\"toBePressed\", \"pressed\", getWidgetPressedState);\nconst toBeExpanded: StateMatcher = booleanStateMatcher(\"toBeExpanded\", \"expanded\", getWidgetExpandedState);\nconst toBeSelected: StateMatcher = booleanStateMatcher(\"toBeSelected\", \"selected\", getWidgetSelectedState);\nconst toBeRequired: StateMatcher = booleanStateMatcher(\"toBeRequired\", \"required\", getWidgetRequiredState);\n\n/** The widget assertion matchers keyed by name, suitable for passing to `expect.extend`. */\nconst matchers: MatcherImplementations = {\n toHaveDisplayValue,\n toHaveTextContent,\n toHaveAccessibleName,\n toHaveAccessibleDescription,\n toHaveAccessibleErrorMessage,\n toHavePlaceholderText,\n toHaveSelection,\n toBeChecked,\n toBePartiallyChecked,\n toBePressed,\n toBeExpanded,\n toBeSelected,\n toBeDisabled,\n toBeEnabled,\n toBeVisible,\n toBeRooted,\n toBeEmpty,\n toBeInvalid,\n toBeValid,\n toBeRequired,\n toHaveFocus,\n toHaveValue,\n toHaveRole,\n toContainElement,\n toHaveClass,\n toHaveObjectProperty,\n};\n\nconst asWidget = (received: unknown, matcherName: string): Gtk.Widget => {\n if (!(received instanceof Gtk.Widget)) {\n throw new TypeError(`${matcherName}: received value must be a Gtk.Widget, got ${typeof received}`);\n }\n\n return received;\n};\n\nconst asObject = (received: unknown, matcherName: string): GObject.Object => {\n if (!(received instanceof GObject.Object)) {\n throw new TypeError(`${matcherName}: received value must be a GObject, got ${typeof received}`);\n }\n\n return received;\n};\n\nconst describeWidget = (widget: Gtk.Widget): string => {\n const role = Gtk.AccessibleRole[widget.getAccessibleRole()];\n const name = getWidgetAccessibleName(widget);\n\n return name === null ? `<${role}>` : `<${role} name=${JSON.stringify(name)}>`;\n};\n\nconst describeObject = (object: GObject.Object): string =>\n object instanceof Gtk.Widget ? describeWidget(object) : `<${object.constructor.name}>`;\n\nconst isTextMatch = (actual: string, expected: TextExpectation, mode: \"exact\" | \"substring\"): boolean => {\n if (expected instanceof RegExp) {\n expected.lastIndex = 0;\n\n return expected.test(actual);\n }\n\n return mode === \"exact\" ? actual === expected : actual.includes(expected);\n};\n\nconst describeExpected = (expected: TextExpectation): string =>\n expected instanceof RegExp ? String(expected) : JSON.stringify(expected);\n\nconst negationPrefix = (isPass: boolean): string => (isPass ? \"not \" : \"\");\n\nconst nonEmptyResult = ({ matcherName, widget, actual }: TextMatcherContext): MatcherResult => {\n const isPass = actual !== null && actual !== \"\";\n\n return {\n pass: isPass,\n message: () =>\n `expected widget ${negationPrefix(isPass)}to have a non-empty value for ${matcherName}, ` +\n `but got ${JSON.stringify(actual)}\\n${describeWidget(widget)}`,\n };\n};\n\nconst matchedResult = (context: TextMatcherContext, expected: TextExpectation, isPass: boolean): MatcherResult => ({\n pass: isPass,\n message: () =>\n `expected widget ${negationPrefix(isPass)}${context.matcherName} ${describeExpected(expected)}, ` +\n `but received ${JSON.stringify(context.actual)}\\n${describeWidget(context.widget)}`,\n});\n\nconst stateResult = (widget: Gtk.Widget, stateName: string, isPass: boolean): MatcherResult => ({\n pass: isPass,\n message: () => `expected widget ${negationPrefix(isPass)}to be ${stateName}\\n${describeWidget(widget)}`,\n});\n\nconst camelCase = (name: string): string =>\n name.replaceAll(/-([a-z])/g, (_match, letter: string) => letter.toUpperCase());\n\nconst isAsymmetricMatcher = (value: unknown): boolean =>\n typeof value === \"object\" && value !== null && typeof Reflect.get(value, \"asymmetricMatch\") === \"function\";\n\nconst isEqualValue = (context: MatcherContext, actual: unknown, expected: unknown): boolean => {\n if (isAsymmetricMatcher(expected)) {\n return context.equals(actual, expected);\n }\n\n if (actual instanceof GObject.Object || expected instanceof GObject.Object) {\n return Object.is(actual, expected);\n }\n\n return context.equals(actual, expected);\n};\n\nconst isClassMatch = (actual: string[], expected: ClassExpectation): boolean =>\n expected instanceof RegExp ? actual.some((name) => expected.test(name)) : actual.includes(expected);\n\nconst isWidgetRooted = (widget: Gtk.Widget): boolean => {\n const root = widget.getRoot();\n\n if (root === null) {\n return false;\n }\n\n if (root instanceof Gtk.Window) {\n return Gtk.Window.listToplevels().includes(root);\n }\n\n return true;\n};\n\nconst globalExpect = (): ExpectExtend | null => {\n const candidate: unknown = Reflect.get(globalThis, \"expect\");\n\n if (candidate && typeof (candidate as ExpectExtend).extend === \"function\") {\n return candidate as ExpectExtend;\n }\n\n return null;\n};\n\nfunction readErrorMessageText(widget: Gtk.Widget): string | null {\n const state = getWidgetInvalidState(widget);\n\n if (state === null || state === Gtk.AccessibleInvalidState.FALSE) {\n return null;\n }\n\n const targets = getWidgetErrorMessage(widget);\n\n if (targets === null) {\n return null;\n }\n\n const texts = targets.map((target) => getWidgetAccessibleName(target)).filter((text) => text !== null);\n\n return texts.length > 0 ? texts.join(\" \") : null;\n}\n\nfunction assertReadableProperty(object: GObject.Object, name: string, property: string, value: unknown): void {\n if (typeof value === \"function\") {\n throw new TypeError(\n `toHaveObjectProperty: \"${name}\" is shadowed by a method of the same name; ` +\n `call ${property}() and assert on its result instead`,\n );\n }\n\n if (value === undefined && !Reflect.has(object, property)) {\n throw new TypeError(\n `toHaveObjectProperty: no readable property \"${name}\" on ${describeObject(object)}; ` +\n \"construct-only and write-only properties cannot be read back\",\n );\n }\n}\n\nfunction readObjectProperty(object: GObject.Object, name: string): unknown {\n const property = camelCase(name);\n const value: unknown = Reflect.get(object, property);\n assertReadableProperty(object, name, property, value);\n\n return value;\n}\n\nfunction classEntries(entry: unknown): ClassExpectation[] {\n return entry instanceof RegExp ? [entry] : String(entry).split(/\\s+/).filter(Boolean);\n}\n\nfunction parseClassArguments(args: unknown[]): ClassArguments {\n const last = args.at(-1);\n const isOptions = typeof last === \"object\" && last !== null && !(last instanceof RegExp);\n const isExact = isOptions && Reflect.get(last, \"exact\") === true;\n const entries = isOptions ? args.slice(0, -1) : args;\n\n return { expected: entries.flatMap((entry) => classEntries(entry)), isExact };\n}\n\nfunction exactClassResult(widget: Gtk.Widget, actual: string[], expected: ClassExpectation[]): MatcherResult {\n if (expected.some((entry) => entry instanceof RegExp)) {\n throw new TypeError(\"toHaveClass: the exact option cannot be combined with a regular expression\");\n }\n\n const names = expected.map(String);\n const isPass = names.length === actual.length && names.every((name) => actual.includes(name));\n\n return {\n pass: isPass,\n message: () =>\n `expected widget ${negationPrefix(isPass)}to have exactly the classes ${JSON.stringify(names)}, ` +\n `but received ${JSON.stringify(actual)}\\n${describeWidget(widget)}`,\n };\n}\n\nfunction textMatcher(\n matcherName: string,\n read: (widget: Gtk.Widget) => string | null,\n mode: \"exact\" | \"substring\",\n): TextMatcher {\n return (received: unknown, expected?: TextExpectation): MatcherResult => {\n const widget = asWidget(received, matcherName);\n const actual = read(widget);\n const context: TextMatcherContext = { matcherName, widget, actual };\n\n if (expected === undefined) {\n return nonEmptyResult(context);\n }\n\n return matchedResult(context, expected, actual !== null && isTextMatch(actual, expected, mode));\n };\n}\n\nfunction normalizeTextContent(text: string, options?: TextContentOptions): string {\n if (options?.normalizeWhitespace === false) {\n return text.replaceAll(\"\\u{A0}\", \" \");\n }\n\n return getDefaultNormalizer()(text);\n}\n\nfunction readTextContent(widget: Gtk.Widget, options?: TextContentOptions): string | null {\n const text = getWidgetTextContent(widget);\n\n return text === null ? null : normalizeTextContent(text, options);\n}\n\nfunction toHaveTextContent(\n received: unknown,\n expected?: TextExpectation,\n options?: TextContentOptions,\n): MatcherResult {\n const read = (widget: Gtk.Widget): string | null => readTextContent(widget, options);\n\n return textMatcher(\"toHaveTextContent\", read, \"substring\")(received, expected);\n}\n\nfunction notApplicable(matcherName: string, stateName: string, widget: Gtk.Widget): Error {\n return new Error(\n `${matcherName}: widget does not expose a ${stateName} ` +\n `(role ${Gtk.AccessibleRole[widget.getAccessibleRole()]})\\n${describeWidget(widget)}`,\n );\n}\n\nfunction booleanStateMatcher(\n matcherName: string,\n stateName: string,\n read: (widget: Gtk.Widget) => boolean | null,\n): StateMatcher {\n return (received: unknown): MatcherResult => {\n const widget = asWidget(received, matcherName);\n const state = read(widget);\n\n if (state === null) {\n throw notApplicable(matcherName, `${stateName} state`, widget);\n }\n\n return stateResult(widget, stateName, state);\n };\n}\n\nfunction readCheckedState(widget: Gtk.Widget, matcherName: string): CheckedState {\n const state = getWidgetCheckedState(widget);\n\n if (state === null) {\n throw notApplicable(matcherName, \"checked state\", widget);\n }\n\n return state;\n}\n\nfunction toBeChecked(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBeChecked\");\n\n return stateResult(widget, \"checked\", readCheckedState(widget, \"toBeChecked\") === \"checked\");\n}\n\nfunction toBePartiallyChecked(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBePartiallyChecked\");\n\n return stateResult(widget, \"partially checked\", readCheckedState(widget, \"toBePartiallyChecked\") === \"mixed\");\n}\n\nfunction toHaveDisplayValue(received: unknown, expected?: TextExpectation): MatcherResult {\n const widget = asWidget(received, \"toHaveDisplayValue\");\n\n if (!hasDisplayValue(widget)) {\n throw notApplicable(\"toHaveDisplayValue\", \"display value\", widget);\n }\n\n return displayValueMatcher(received, expected);\n}\n\nfunction toHaveValue(received: unknown, expected?: number | string): MatcherResult {\n const widget = asWidget(received, \"toHaveValue\");\n\n if (typeof expected === \"string\") {\n return displayValueMatcher(received, expected);\n }\n\n const actual = getWidgetValue(widget).now;\n\n if (actual === null) {\n throw notApplicable(\"toHaveValue\", \"numeric value\", widget);\n }\n\n const isPass = expected === undefined || actual === expected;\n\n return {\n pass: isPass,\n message: () =>\n `expected widget ${negationPrefix(isPass)}to have value ${String(expected)}, ` +\n `but received ${String(actual)}\\n${describeWidget(widget)}`,\n };\n}\n\nfunction toBeDisabled(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBeDisabled\");\n\n return stateResult(widget, \"disabled\", isWidgetDisabled(widget));\n}\n\nfunction toBeEnabled(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBeEnabled\");\n\n return stateResult(widget, \"enabled\", !isWidgetDisabled(widget));\n}\n\nfunction toBeVisible(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBeVisible\");\n\n return stateResult(widget, \"visible\", isWidgetVisible(widget));\n}\n\nfunction toBeRooted(received: unknown): MatcherResult {\n if (received === null) {\n return { pass: false, message: () => \"expected a widget to be rooted in a window, but received null\" };\n }\n\n const widget = asWidget(received, \"toBeRooted\");\n\n return stateResult(widget, \"rooted in a window\", isWidgetRooted(widget));\n}\n\nfunction toBeEmpty(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBeEmpty\");\n\n return stateResult(widget, \"empty\", widget.getFirstChild() === null && getWidgetLabelText(widget) === null);\n}\n\nfunction toBeInvalid(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBeInvalid\");\n const state = getWidgetInvalidState(widget);\n\n return stateResult(widget, \"invalid\", state !== null && state !== Gtk.AccessibleInvalidState.FALSE);\n}\n\nfunction toBeValid(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toBeValid\");\n const state = getWidgetInvalidState(widget);\n\n return stateResult(widget, \"valid\", state === null || state === Gtk.AccessibleInvalidState.FALSE);\n}\n\nfunction toHaveFocus(received: unknown): MatcherResult {\n const widget = asWidget(received, \"toHaveFocus\");\n\n return stateResult(widget, \"focused\", widget.getPlatformState(Gtk.AccessiblePlatformState.FOCUSED));\n}\n\nfunction toHaveRole(received: unknown, expected: Gtk.AccessibleRole): MatcherResult {\n const widget = asWidget(received, \"toHaveRole\");\n const actual = widget.getAccessibleRole();\n const isPass = actual === expected;\n\n return {\n pass: isPass,\n message: () =>\n `expected widget ${negationPrefix(isPass)}to have role '${formatRole(expected)}', ` +\n `but received '${formatRole(actual)}'\\n${describeWidget(widget)}`,\n };\n}\n\nfunction toContainElement(received: unknown, descendant: Gtk.Widget | null): MatcherResult {\n const widget = asWidget(received, \"toContainElement\");\n const isPass = descendant !== null && (descendant === widget || descendant.isAncestor(widget));\n\n return {\n pass: isPass,\n message: () =>\n `expected widget ${negationPrefix(isPass)}to contain ` +\n `${descendant === null ? \"null\" : describeWidget(descendant)}\\n${describeWidget(widget)}`,\n };\n}\n\nfunction toHaveClass(received: unknown, ...args: unknown[]): MatcherResult {\n const widget = asWidget(received, \"toHaveClass\");\n const actual = widget.getCssClasses();\n const { expected, isExact } = parseClassArguments(args);\n\n if (isExact) {\n return exactClassResult(widget, actual, expected);\n }\n\n if (expected.length === 0) {\n return stateResult(widget, \"given any style class\", actual.length > 0);\n }\n\n const isPass = expected.every((entry) => isClassMatch(actual, entry));\n\n return {\n pass: isPass,\n message: () =>\n `expected widget ${negationPrefix(isPass)}to have class ${expected.map(String).join(\", \")}, ` +\n `but received ${JSON.stringify(actual)}\\n${describeWidget(widget)}`,\n };\n}\n\nfunction toHaveObjectProperty(this: MatcherContext, received: unknown, ...args: unknown[]): MatcherResult {\n const object = asObject(received, \"toHaveObjectProperty\");\n const [name, expected] = args;\n const actual = readObjectProperty(object, String(name));\n\n if (args.length < 2) {\n const isSet = actual !== null && actual !== undefined;\n\n return {\n pass: isSet,\n message: () =>\n `expected ${describeObject(object)} ${negationPrefix(isSet)}to have a value for property ` +\n `\"${String(name)}\", but received ${JSON.stringify(actual)}`,\n };\n }\n\n /* eslint-disable-next-line unicorn/no-this-outside-of-class --\n expect.extend invokes matchers with the matcher state as `this` */\n const isPass = isEqualValue(this, actual, expected);\n\n return {\n pass: isPass,\n message: () =>\n `expected ${describeObject(object)} ${negationPrefix(isPass)}to have property \"${String(name)}\" ` +\n `equal to ${JSON.stringify(expected)}, but received ${JSON.stringify(actual)}`,\n };\n}\n\n/** Registers the widget matchers on the global `expect`, when one is available. Safe to call more than once. */\nconst registerMatchers = (): void => {\n if (registration.isRegistered) {\n return;\n }\n\n const expect = globalExpect();\n\n if (!expect) {\n return;\n }\n\n expect.extend(matchers);\n registration.isRegistered = true;\n};\n\ndeclare module \"@vitest/expect\" {\n /* eslint-disable @typescript-eslint/consistent-type-definitions -- declaration merging requires interfaces */\n interface WidgetMatchers {\n toHaveDisplayValue(expected?: TextExpectation): void;\n toHaveTextContent(expected?: TextExpectation, options?: TextContentOptions): void;\n toHaveAccessibleName(expected?: TextExpectation): void;\n toHaveAccessibleDescription(expected?: TextExpectation): void;\n toHaveAccessibleErrorMessage(expected?: TextExpectation): void;\n toHavePlaceholderText(expected?: TextExpectation): void;\n toHaveSelection(expected?: TextExpectation): void;\n toBeChecked(): void;\n toBePartiallyChecked(): void;\n toBePressed(): void;\n toBeExpanded(): void;\n toBeSelected(): void;\n toBeDisabled(): void;\n toBeEnabled(): void;\n toBeVisible(): void;\n toBeRooted(): void;\n toBeEmpty(): void;\n toBeInvalid(): void;\n toBeValid(): void;\n toBeRequired(): void;\n toHaveFocus(): void;\n toHaveValue(expected?: number | string): void;\n toHaveRole(expected: Gtk.AccessibleRole): void;\n toContainElement(descendant: Gtk.Widget | null): void;\n toHaveClass(...args: (ClassExpectation | { exact: boolean })[]): void;\n toHaveObjectProperty(name: string, expected?: unknown): void;\n }\n\n interface Assertion extends WidgetMatchers {}\n interface AsymmetricMatchersContaining extends WidgetMatchers {}\n /* eslint-enable @typescript-eslint/consistent-type-definitions */\n}\n\nexport {\n toHaveDisplayValue,\n toHaveTextContent,\n toHaveAccessibleName,\n toHaveAccessibleDescription,\n toHaveAccessibleErrorMessage,\n toHavePlaceholderText,\n toHaveSelection,\n toBeChecked,\n toBePartiallyChecked,\n toBePressed,\n toBeExpanded,\n toBeSelected,\n toBeDisabled,\n toBeEnabled,\n toBeVisible,\n toBeRooted,\n toBeEmpty,\n toBeInvalid,\n toBeValid,\n toBeRequired,\n toHaveFocus,\n toHaveValue,\n toHaveRole,\n toContainElement,\n toHaveClass,\n toHaveObjectProperty,\n matchers,\n registerMatchers,\n type ClassExpectation,\n type TextContentOptions,\n type TextExpectation,\n};\n"]}
@@ -1,5 +1,6 @@
1
1
  import type * as Gtk from "@gtkx/gi/gtk";
2
2
  import { type Container } from "./traversal.js";
3
+ /** Produces the value of the `id` attribute printed first on a widget's opening tag. */
3
4
  type WidgetIdResolver = (widget: Gtk.Widget) => string;
4
5
  /**
5
6
  * Options controlling how a widget tree is rendered to a string by
@@ -9,7 +10,7 @@ type PrettyWidgetOptions = {
9
10
  /** Truncates the output once it exceeds this many characters. */
10
11
  maxLength?: number;
11
12
  /** Whether to apply ANSI color highlighting; defaults to the terminal capabilities. */
12
- highlight?: boolean;
13
+ shouldHighlight?: boolean;
13
14
  /** Resolves an `id` attribute to show for each widget. */
14
15
  getId?: WidgetIdResolver;
15
16
  /** Stops descending past this depth, replacing deeper children with a summary line. */
@@ -1 +1 @@
1
- {"version":3,"file":"pretty-widget.d.ts","sourceRoot":"","sources":["../src/pretty-widget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,KAAK,SAAS,EAAS,MAAM,gBAAgB,CAAC;AAGvD,KAAK,gBAAgB,GAAG,CAAC,MA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AAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,SAAS,GAAI,WAAW,SAAS,GAAG,SAAS,EAAE,EAAE,UAAU,mBAAmB,KAAG,IAMtF,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,mBAAmB,EAAE,CAAC"}
@@ -30,7 +30,7 @@ const buildAttrs = (widget, getId) => {
30
30
  const otherAttrs = sortStringsBy(attrs.filter(([key]) => key !== "id"), ([key]) => key);
31
31
  return [...idAttrs, ...otherAttrs];
32
32
  };
33
- const shouldHighlight = () => {
33
+ const isHighlightSupported = () => {
34
34
  if (typeof process === "undefined") {
35
35
  return false;
36
36
  }
@@ -128,8 +128,8 @@ const prettyWidget = (container, options = {}) => {
128
128
  if (maxLength === 0) {
129
129
  return "";
130
130
  }
131
- const isHighlight = options.highlight ?? shouldHighlight();
132
- const colors = createColors(isHighlight);
131
+ const shouldHighlight = options.shouldHighlight ?? isHighlightSupported();
132
+ const colors = createColors(shouldHighlight);
133
133
  let output = "";
134
134
  for (const root of roots(container)) {
135
135
  output += formatWidget(root, 0, { getId: options.getId, colors, maxDepth: options.maxDepth });
@@ -1 +1 @@
1
- {"version":3,"file":"pretty-widget.js","sourceRoot":"","sources":["../src/pretty-widget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAkB,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AA+BtE,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,MAAM,GAAG,IAAI,CAAC;AAEpB,MAAM,IAAI,GAAG;IACT,IAAI,EAAE,YAAY;IAClB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE,YAAY;IACnB,KAAK,EAAE,WAAW;CACrB,CAAC;AAEF,MAAM,UAAU,GAAG,CAA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container, roots } from \"./traversal.js\";\nimport { getWidgetNodeText } from \"./widget-accessible-properties.js\";\n\ntype WidgetIdResolver = (widget: Gtk.Widget) => string;\n\n/**\n * Options controlling how a widget tree is rendered to a string by\n * {@link prettyWidget} and {@link logWidget}.\n */\ntype PrettyWidgetOptions = {\n /** Truncates the output once it exceeds this many characters. */\n maxLength?: number;\n /** Whether to apply ANSI color highlighting; defaults to the terminal capabilities. */\n highlight?: boolean;\n /** Resolves an `id` attribute to show for each widget. */\n getId?: WidgetIdResolver;\n /** Stops descending past this depth, replacing deeper children with a summary line. */\n maxDepth?: number;\n};\n\ntype Colors = {\n tag: (s: string) => string;\n attr: (s: string) => string;\n value: (s: string) => string;\n};\n\ntype FormatContext = {\n getId: WidgetIdResolver | undefined;\n colors: Colors;\n maxDepth: number | undefined;\n};\n\nconst DEFAULT_MAX_LENGTH = 7000;\nconst INDENT = \" \";\n\nconst ansi = {\n cyan: \"\\u{1B}[36m\",\n yellow: \"\\u{1B}[33m\",\n green: \"\\u{1B}[32m\",\n reset: \"\\u{1B}[0m\",\n};\n\nconst buildAttrs = (widget: Gtk.Widget, getId: WidgetIdResolver | undefined): [string, string][] => {\n const attrs: [string, string][] = [];\n\n if (getId) {\n attrs.push([\"id\", getId(widget)]);\n }\n\n const name = widget.getName();\n\n if (name) {\n attrs.push([\"name\", name]);\n }\n\n attrs.push([\"role\", formatRole(widget.getAccessibleRole())]);\n\n if (!widget.getSensitive()) {\n attrs.push([\"accessible-disabled\", \"true\"]);\n }\n\n if (!widget.getVisible()) {\n attrs.push([\"accessible-hidden\", \"true\"]);\n }\n\n const idAttrs = attrs.filter(([key]) => key === \"id\");\n\n const otherAttrs = sortStringsBy(\n attrs.filter(([key]) => key !== \"id\"),\n ([key]) => key,\n );\n\n return [...idAttrs, ...otherAttrs];\n};\n\nconst shouldHighlight = (): boolean => {\n if (typeof process === \"undefined\") {\n return false;\n }\n\n if (process.env.COLORS === \"false\" || process.env.NO_COLOR) {\n return false;\n }\n\n if (process.env.COLORS === \"true\" || process.env.FORCE_COLOR) {\n return true;\n }\n\n return process.stdout.isTTY;\n};\n\nconst createColors = (isEnabled: boolean): Colors => {\n if (!isEnabled) {\n const identity = (s: string): string => s;\n\n return { tag: identity, attr: identity, value: identity };\n }\n\n return {\n tag: (s) => `${ansi.cyan}${s}${ansi.reset}`,\n attr: (s) => `${ansi.yellow}${s}${ansi.reset}`,\n value: (s) => `${ansi.green}${s}${ansi.reset}`,\n };\n};\n\nconst escapeAttrValue = (value: string): string => value.replaceAll('\"', \"&quot;\");\n\nconst formatAttr = (key: string, value: string, colors: Colors): string => {\n const quoted = `\"${escapeAttrValue(value)}\"`;\n\n return ` ${colors.attr(key)}=${colors.value(quoted)}`;\n};\n\nconst formatAttrs = (attrs: [string, string][], colors: Colors): string =>\n attrs.map(([key, value]) => formatAttr(key, value, colors)).join(\"\");\n\nconst countChildren = (widget: Gtk.Widget): number => {\n let count = 0;\n let child = widget.getFirstChild();\n\n while (child) {\n count += 1;\n child = child.getNextSibling();\n }\n\n return count;\n};\n\nconst formatHiddenChildrenLine = (widget: Gtk.Widget, depth: number, ctx: FormatContext): string => {\n const { getId, colors } = ctx;\n const indent = INDENT.repeat(depth);\n const count = countChildren(widget);\n const hint = getId ? ` (pass rootId=\"${getId(widget)}\" or raise maxDepth to expand)` : \"\";\n const plural = count === 1 ? \"\" : \"s\";\n const summary = `… ${String(count)} child widget${plural} hidden${hint}`;\n\n return `${indent}${INDENT}${colors.tag(summary)}\\n`;\n};\n\nconst formatChildren = (widget: Gtk.Widget, depth: number, ctx: FormatContext): string => {\n let output = \"\";\n let child = widget.getFirstChild();\n\n while (child) {\n output += formatWidget(child, depth + 1, ctx);\n child = child.getNextSibling();\n }\n\n return output;\n};\n\nconst formatWidget = (widget: Gtk.Widget, depth: number, ctx: FormatContext): string => {\n const { getId, colors, maxDepth } = ctx;\n const indent = INDENT.repeat(depth);\n const tag = widget.constructor.name;\n const attrs = formatAttrs(buildAttrs(widget, getId), colors);\n const openTag = `${colors.tag(\"<\")}${colors.tag(tag)}${attrs}${colors.tag(\">\")}`;\n const closeTag = `${colors.tag(\"</\")}${colors.tag(tag)}${colors.tag(\">\")}`;\n const text = getWidgetNodeText(widget);\n const firstChild = widget.getFirstChild();\n\n if (!text && !firstChild) {\n return `${indent}${openTag}\\n`;\n }\n\n let output = `${indent}${openTag}\\n`;\n\n if (text) {\n output += `${indent}${INDENT}${text}\\n`;\n }\n\n if (firstChild && maxDepth !== undefined && depth >= maxDepth) {\n output += formatHiddenChildrenLine(widget, depth, ctx);\n output += `${indent}${closeTag}\\n`;\n\n return output;\n }\n\n output += formatChildren(widget, depth, ctx);\n output += `${indent}${closeTag}\\n`;\n\n return output;\n};\n\nconst resolveMaxLength = (options: PrettyWidgetOptions): number => {\n const envLimit = process.env.DEBUG_PRINT_LIMIT ? Number(process.env.DEBUG_PRINT_LIMIT) : DEFAULT_MAX_LENGTH;\n\n return options.maxLength ?? envLimit;\n};\n\n/**\n * Renders a widget tree as an indented, HTML-like string showing each widget's\n * tag, accessible attributes, and text content.\n *\n * @param container The scope whose widget tree is formatted.\n * @param options Formatting options such as truncation length and highlighting.\n * @returns The formatted representation of the tree.\n */\nconst prettyWidget = (container: Container, options: PrettyWidgetOptions = {}): string => {\n const maxLength = resolveMaxLength(options);\n\n if (maxLength === 0) {\n return \"\";\n }\n\n const isHighlight = options.highlight ?? shouldHighlight();\n const colors = createColors(isHighlight);\n let output = \"\";\n\n for (const root of roots(container)) {\n output += formatWidget(root, 0, { getId: options.getId, colors, maxDepth: options.maxDepth });\n }\n\n if (output.length > maxLength) {\n return `${output.slice(0, maxLength)}...`;\n }\n\n return output.trimEnd();\n};\n\n/**\n * Prints one or more widget trees to the console using {@link prettyWidget}.\n *\n * @param container A single scope or an array of scopes to format and print.\n * @param options Formatting options passed through to {@link prettyWidget}.\n */\nconst logWidget = (container: Container | Container[], options?: PrettyWidgetOptions): void => {\n const containers: Container[] = Array.isArray(container) ? container : [container];\n\n for (const target of containers) {\n console.log(prettyWidget(target, options));\n }\n};\n\nexport { prettyWidget, logWidget, type PrettyWidgetOptions };\n"]}
1
+ {"version":3,"file":"pretty-widget.js","sourceRoot":"","sources":["../src/pretty-widget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAkB,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAgCtE,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,MAAM,GAAG,IAAI,CAAC;AAEpB,MAAM,IAAI,GAAG;IACT,IAAI,EAAE,YAAY;IAClB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE,YAAY;IACnB,KAAK,EAAE,WAAW;CACrB,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,MAAkB,EAAE,KAAmC,EAAsB,EAAE;IAC/F,MAAM,KAAK,GAAuB,EAAE,CAAC;IAErC,IAAI,KAAK,EAAE,CAAC;QACR,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAE9B,IAAI,IAAI,EAAE,CAAC;QACP,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,CAAC;IAE7D,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,CAAC,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AC9C,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC;AAC5B,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,SAAS,GAAG,CAAC,SAAkC,EAAE,OAA6B,EAAQ,EAAE;IAC1F,MAAM,UAAU,GAAgB,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAEnF,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/C,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,SAAS,EAA4B,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { sortStringsBy } from \"@gtkx/utils\";\nimport { formatRole } from \"./role-helpers.js\";\nimport { type Container, roots } from \"./traversal.js\";\nimport { getWidgetNodeText } from \"./widget-accessible-properties.js\";\n\n/** Produces the value of the `id` attribute printed first on a widget's opening tag. */\ntype WidgetIdResolver = (widget: Gtk.Widget) => string;\n\n/**\n * Options controlling how a widget tree is rendered to a string by\n * {@link prettyWidget} and {@link logWidget}.\n */\ntype PrettyWidgetOptions = {\n /** Truncates the output once it exceeds this many characters. */\n maxLength?: number;\n /** Whether to apply ANSI color highlighting; defaults to the terminal capabilities. */\n shouldHighlight?: boolean;\n /** Resolves an `id` attribute to show for each widget. */\n getId?: WidgetIdResolver;\n /** Stops descending past this depth, replacing deeper children with a summary line. */\n maxDepth?: number;\n};\n\ntype Colors = {\n tag: (s: string) => string;\n attr: (s: string) => string;\n value: (s: string) => string;\n};\n\ntype FormatContext = {\n getId: WidgetIdResolver | undefined;\n colors: Colors;\n maxDepth: number | undefined;\n};\n\nconst DEFAULT_MAX_LENGTH = 7000;\nconst INDENT = \" \";\n\nconst ansi = {\n cyan: \"\\u{1B}[36m\",\n yellow: \"\\u{1B}[33m\",\n green: \"\\u{1B}[32m\",\n reset: \"\\u{1B}[0m\",\n};\n\nconst buildAttrs = (widget: Gtk.Widget, getId: WidgetIdResolver | undefined): [string, string][] => {\n const attrs: [string, string][] = [];\n\n if (getId) {\n attrs.push([\"id\", getId(widget)]);\n }\n\n const name = widget.getName();\n\n if (name) {\n attrs.push([\"name\", name]);\n }\n\n attrs.push([\"role\", formatRole(widget.getAccessibleRole())]);\n\n if (!widget.getSensitive()) {\n attrs.push([\"accessible-disabled\", \"true\"]);\n }\n\n if (!widget.getVisible()) {\n attrs.push([\"accessible-hidden\", \"true\"]);\n }\n\n const idAttrs = attrs.filter(([key]) => key === \"id\");\n\n const otherAttrs = sortStringsBy(\n attrs.filter(([key]) => key !== \"id\"),\n ([key]) => key,\n );\n\n return [...idAttrs, ...otherAttrs];\n};\n\nconst isHighlightSupported = (): boolean => {\n if (typeof process === \"undefined\") {\n return false;\n }\n\n if (process.env.COLORS === \"false\" || process.env.NO_COLOR) {\n return false;\n }\n\n if (process.env.COLORS === \"true\" || process.env.FORCE_COLOR) {\n return true;\n }\n\n return process.stdout.isTTY;\n};\n\nconst createColors = (isEnabled: boolean): Colors => {\n if (!isEnabled) {\n const identity = (s: string): string => s;\n\n return { tag: identity, attr: identity, value: identity };\n }\n\n return {\n tag: (s) => `${ansi.cyan}${s}${ansi.reset}`,\n attr: (s) => `${ansi.yellow}${s}${ansi.reset}`,\n value: (s) => `${ansi.green}${s}${ansi.reset}`,\n };\n};\n\nconst escapeAttrValue = (value: string): string => value.replaceAll('\"', \"&quot;\");\n\nconst formatAttr = (key: string, value: string, colors: Colors): string => {\n const quoted = `\"${escapeAttrValue(value)}\"`;\n\n return ` ${colors.attr(key)}=${colors.value(quoted)}`;\n};\n\nconst formatAttrs = (attrs: [string, string][], colors: Colors): string =>\n attrs.map(([key, value]) => formatAttr(key, value, colors)).join(\"\");\n\nconst countChildren = (widget: Gtk.Widget): number => {\n let count = 0;\n let child = widget.getFirstChild();\n\n while (child) {\n count += 1;\n child = child.getNextSibling();\n }\n\n return count;\n};\n\nconst formatHiddenChildrenLine = (widget: Gtk.Widget, depth: number, ctx: FormatContext): string => {\n const { getId, colors } = ctx;\n const indent = INDENT.repeat(depth);\n const count = countChildren(widget);\n const hint = getId ? ` (pass rootId=\"${getId(widget)}\" or raise maxDepth to expand)` : \"\";\n const plural = count === 1 ? \"\" : \"s\";\n const summary = `… ${String(count)} child widget${plural} hidden${hint}`;\n\n return `${indent}${INDENT}${colors.tag(summary)}\\n`;\n};\n\nconst formatChildren = (widget: Gtk.Widget, depth: number, ctx: FormatContext): string => {\n let output = \"\";\n let child = widget.getFirstChild();\n\n while (child) {\n output += formatWidget(child, depth + 1, ctx);\n child = child.getNextSibling();\n }\n\n return output;\n};\n\nconst formatWidget = (widget: Gtk.Widget, depth: number, ctx: FormatContext): string => {\n const { getId, colors, maxDepth } = ctx;\n const indent = INDENT.repeat(depth);\n const tag = widget.constructor.name;\n const attrs = formatAttrs(buildAttrs(widget, getId), colors);\n const openTag = `${colors.tag(\"<\")}${colors.tag(tag)}${attrs}${colors.tag(\">\")}`;\n const closeTag = `${colors.tag(\"</\")}${colors.tag(tag)}${colors.tag(\">\")}`;\n const text = getWidgetNodeText(widget);\n const firstChild = widget.getFirstChild();\n\n if (!text && !firstChild) {\n return `${indent}${openTag}\\n`;\n }\n\n let output = `${indent}${openTag}\\n`;\n\n if (text) {\n output += `${indent}${INDENT}${text}\\n`;\n }\n\n if (firstChild && maxDepth !== undefined && depth >= maxDepth) {\n output += formatHiddenChildrenLine(widget, depth, ctx);\n output += `${indent}${closeTag}\\n`;\n\n return output;\n }\n\n output += formatChildren(widget, depth, ctx);\n output += `${indent}${closeTag}\\n`;\n\n return output;\n};\n\nconst resolveMaxLength = (options: PrettyWidgetOptions): number => {\n const envLimit = process.env.DEBUG_PRINT_LIMIT ? Number(process.env.DEBUG_PRINT_LIMIT) : DEFAULT_MAX_LENGTH;\n\n return options.maxLength ?? envLimit;\n};\n\n/**\n * Renders a widget tree as an indented, HTML-like string showing each widget's\n * tag, accessible attributes, and text content.\n *\n * @param container The scope whose widget tree is formatted.\n * @param options Formatting options such as truncation length and highlighting.\n * @returns The formatted representation of the tree.\n */\nconst prettyWidget = (container: Container, options: PrettyWidgetOptions = {}): string => {\n const maxLength = resolveMaxLength(options);\n\n if (maxLength === 0) {\n return \"\";\n }\n\n const shouldHighlight = options.shouldHighlight ?? isHighlightSupported();\n const colors = createColors(shouldHighlight);\n let output = \"\";\n\n for (const root of roots(container)) {\n output += formatWidget(root, 0, { getId: options.getId, colors, maxDepth: options.maxDepth });\n }\n\n if (output.length > maxLength) {\n return `${output.slice(0, maxLength)}...`;\n }\n\n return output.trimEnd();\n};\n\n/**\n * Prints one or more widget trees to the console using {@link prettyWidget}.\n *\n * @param container A single scope or an array of scopes to format and print.\n * @param options Formatting options passed through to {@link prettyWidget}.\n */\nconst logWidget = (container: Container | Container[], options?: PrettyWidgetOptions): void => {\n const containers: Container[] = Array.isArray(container) ? container : [container];\n\n for (const target of containers) {\n console.log(prettyWidget(target, options));\n }\n};\n\nexport { prettyWidget, logWidget, type PrettyWidgetOptions };\n"]}
package/dist/queries.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as Gtk from "@gtkx/gi/gtk";
2
2
  import type { ByRoleOptions, Matcher, MatcherOptions, QueryFamilies } from "./types.js";
3
3
  import { type Container } from "./traversal.js";
4
+ /** The built-in queries in their unbound form, each taking the container to search as its first argument. */
4
5
  type BuiltinQueries = QueryFamilies<[container: Container]>;
5
6
  declare const builtinQueries: BuiltinQueries;
6
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,EACR,aAAa,EAEb,OAAO,EACP,cAAc,EAEd,aAAa,EAChB,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,KAA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,cAAc,GACzB,GAAG,CAAC,MAAM,EAAE,CAOd;AAED;;;;;;GAMG;AACH,iBAAS,sBAAsB,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,CAO5G;AAED,OAAO,EACH,cAAc,EACd,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,WAAW,EACX,YAAY,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,EACtB,KAAK,cAAc,GACtB,CAAC"}
@@ -1 +1 @@
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,EACr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,EACT,CAAC,MAAM,EAAE,EAAE,CACP,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC;QACrC,WAAW,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAC3E,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,SAAS,sBAAsB,CAAC,SAAoB,EAAE,KAAc,EAAE,OAAwB;IAC1F,OAAO,OAAO,CACV,SAAS,EACT,CAAC,MAAM,EAAE,EAAE,CACP,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC;QACrC,WAAW,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CACzE,CAAC;AACN,CAAC;AAED,OAAO,EACH,cAAc,EACd,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,WAAW,EACX,YAAY,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"]}
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;AAK3C,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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wB;IAC1F,OAAO,OAAO,CACV,SAAS,EACT,CAAC,MAAM,EAAE,EAAE,CACP,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC;QACrC,WAAW,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CACzE,CAAC;AACN,CAAC;AAED,OAAO,EACH,cAAc,EACd,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,WAAW,EACX,YAAY,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\n/** The built-in queries in their unbound form, each taking the container to search as its first argument. */\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"]}
package/dist/render.js CHANGED
@@ -110,7 +110,7 @@ const applyEnableAnimations = (areAnimationsEnabled) => {
110
110
  */
111
111
  const render = async (element, options) => {
112
112
  installErrorHandler();
113
- applyEnableAnimations(options?.animations === true);
113
+ applyEnableAnimations(options?.areAnimationsEnabled === true);
114
114
  const baseElement = options?.baseElement ?? TOPLEVELS;
115
115
  const Wrapper = options?.wrapper;
116
116
  const resolved = resolveContainer(options?.container);
@@ -125,7 +125,7 @@ const render = async (element, options) => {
125
125
  addToCleanupQueue(resetClipboard);
126
126
  const wrap = (node) => {
127
127
  const wrapped = Wrapper ? _jsx(Wrapper, { children: node }) : node;
128
- return options?.reactStrictMode ? _jsx(StrictMode, { children: wrapped }) : wrapped;
128
+ return options?.isReactStrictMode ? _jsx(StrictMode, { children: wrapped }) : wrapped;
129
129
  };
130
130
  await update(wrap(element), root);
131
131
  resolved.window?.present();
@@ -1 +1 @@
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,EAA4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E,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"]}
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,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,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAiBrC,MAAM,gBAAgB,GAAyB,EAAE,SAAS,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;AAC9F,MAAM,aAAa,GAAsB,IAAI,GAAG,EAAE,CAAC;AACnD,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAElC,MAAM,WAAW,GAAG,CAAC,MAAyB,EAAiB,EAAE,CAC7D,IAAI,OAAO,CAAC,CAA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AC,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC;YACrC,MAAM,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC;QACD,KAAK,EAAE,CAAC,UAAmC,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,OAAO,GAAG,KAAK,IAAmB,EAAE;IACtC,MAAM,UAAU,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?.areAnimationsEnabled === 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?.isReactStrictMode ? <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"]}