@gtkx/testing 2.0.0-beta.12 → 2.0.0-beta.13

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 (148) hide show
  1. package/dist/act.d.ts +7 -1
  2. package/dist/act.d.ts.map +1 -1
  3. package/dist/act.js +54 -4
  4. package/dist/act.js.map +1 -1
  5. package/dist/bound-queries.d.ts +1 -1
  6. package/dist/bound-queries.d.ts.map +1 -1
  7. package/dist/bound-queries.js.map +1 -1
  8. package/dist/cleanup-registry.d.ts.map +1 -1
  9. package/dist/cleanup-registry.js +4 -1
  10. package/dist/cleanup-registry.js.map +1 -1
  11. package/dist/fire-event.d.ts.map +1 -1
  12. package/dist/fire-event.js +11 -2
  13. package/dist/fire-event.js.map +1 -1
  14. package/dist/harness-window.d.ts +8 -2
  15. package/dist/harness-window.d.ts.map +1 -1
  16. package/dist/harness-window.js +28 -5
  17. package/dist/harness-window.js.map +1 -1
  18. package/dist/internal.d.ts +5 -0
  19. package/dist/internal.d.ts.map +1 -1
  20. package/dist/internal.js +5 -0
  21. package/dist/internal.js.map +1 -1
  22. package/dist/matchers.d.ts +4 -1
  23. package/dist/matchers.d.ts.map +1 -1
  24. package/dist/matchers.js +29 -9
  25. package/dist/matchers.js.map +1 -1
  26. package/dist/pretty-widget.d.ts +4 -2
  27. package/dist/pretty-widget.d.ts.map +1 -1
  28. package/dist/pretty-widget.js +7 -5
  29. package/dist/pretty-widget.js.map +1 -1
  30. package/dist/queries.d.ts +2 -1
  31. package/dist/queries.d.ts.map +1 -1
  32. package/dist/queries.js +19 -6
  33. package/dist/queries.js.map +1 -1
  34. package/dist/register-test-hooks.js +8 -0
  35. package/dist/register-test-hooks.js.map +1 -1
  36. package/dist/render.d.ts +14 -6
  37. package/dist/render.d.ts.map +1 -1
  38. package/dist/render.js +46 -31
  39. package/dist/render.js.map +1 -1
  40. package/dist/role-helpers.js.map +1 -1
  41. package/dist/types.d.ts +10 -2
  42. package/dist/types.d.ts.map +1 -1
  43. package/dist/types.js.map +1 -1
  44. package/dist/usage-error.d.ts +9 -0
  45. package/dist/usage-error.d.ts.map +1 -0
  46. package/dist/usage-error.js +13 -0
  47. package/dist/usage-error.js.map +1 -0
  48. package/dist/user-event/adjustment.d.ts.map +1 -1
  49. package/dist/user-event/adjustment.js +6 -5
  50. package/dist/user-event/adjustment.js.map +1 -1
  51. package/dist/user-event/click.d.ts +15 -7
  52. package/dist/user-event/click.d.ts.map +1 -1
  53. package/dist/user-event/click.js +165 -43
  54. package/dist/user-event/click.js.map +1 -1
  55. package/dist/user-event/controller.d.ts +10 -2
  56. package/dist/user-event/controller.d.ts.map +1 -1
  57. package/dist/user-event/controller.js +25 -3
  58. package/dist/user-event/controller.js.map +1 -1
  59. package/dist/user-event/dispatch.d.ts +1 -1
  60. package/dist/user-event/dispatch.d.ts.map +1 -1
  61. package/dist/user-event/dispatch.js +9 -6
  62. package/dist/user-event/dispatch.js.map +1 -1
  63. package/dist/user-event/editable-label-click.d.ts +5 -0
  64. package/dist/user-event/editable-label-click.d.ts.map +1 -0
  65. package/dist/user-event/editable-label-click.js +12 -0
  66. package/dist/user-event/editable-label-click.js.map +1 -0
  67. package/dist/user-event/event-wrapper.d.ts +11 -1
  68. package/dist/user-event/event-wrapper.d.ts.map +1 -1
  69. package/dist/user-event/event-wrapper.js +66 -12
  70. package/dist/user-event/event-wrapper.js.map +1 -1
  71. package/dist/user-event/gesture.d.ts.map +1 -1
  72. package/dist/user-event/gesture.js +67 -27
  73. package/dist/user-event/gesture.js.map +1 -1
  74. package/dist/user-event/index.d.ts +55 -18
  75. package/dist/user-event/index.d.ts.map +1 -1
  76. package/dist/user-event/index.js +42 -8
  77. package/dist/user-event/index.js.map +1 -1
  78. package/dist/user-event/keyboard.d.ts +27 -2
  79. package/dist/user-event/keyboard.d.ts.map +1 -1
  80. package/dist/user-event/keyboard.js +251 -30
  81. package/dist/user-event/keyboard.js.map +1 -1
  82. package/dist/user-event/list-row-click.d.ts +2 -1
  83. package/dist/user-event/list-row-click.d.ts.map +1 -1
  84. package/dist/user-event/list-row-click.js +10 -6
  85. package/dist/user-event/list-row-click.js.map +1 -1
  86. package/dist/user-event/native-click.d.ts +2 -1
  87. package/dist/user-event/native-click.d.ts.map +1 -1
  88. package/dist/user-event/native-click.js +16 -2
  89. package/dist/user-event/native-click.js.map +1 -1
  90. package/dist/user-event/pointer.d.ts +5 -3
  91. package/dist/user-event/pointer.d.ts.map +1 -1
  92. package/dist/user-event/pointer.js +72 -27
  93. package/dist/user-event/pointer.js.map +1 -1
  94. package/dist/user-event/selection.d.ts.map +1 -1
  95. package/dist/user-event/selection.js +46 -15
  96. package/dist/user-event/selection.js.map +1 -1
  97. package/dist/user-event/state.d.ts +2 -1
  98. package/dist/user-event/state.d.ts.map +1 -1
  99. package/dist/user-event/state.js +1 -1
  100. package/dist/user-event/state.js.map +1 -1
  101. package/dist/user-event/tab-view-click.d.ts +8 -0
  102. package/dist/user-event/tab-view-click.d.ts.map +1 -0
  103. package/dist/user-event/tab-view-click.js +37 -0
  104. package/dist/user-event/tab-view-click.js.map +1 -0
  105. package/dist/user-event/text.d.ts +3 -2
  106. package/dist/user-event/text.d.ts.map +1 -1
  107. package/dist/user-event/text.js +34 -14
  108. package/dist/user-event/text.js.map +1 -1
  109. package/dist/widget-accessible-properties.d.ts +13 -3
  110. package/dist/widget-accessible-properties.d.ts.map +1 -1
  111. package/dist/widget-accessible-properties.js +56 -17
  112. package/dist/widget-accessible-properties.js.map +1 -1
  113. package/dist/widget-target.d.ts.map +1 -1
  114. package/dist/widget-target.js +2 -1
  115. package/dist/widget-target.js.map +1 -1
  116. package/package.json +13 -8
  117. package/src/act.ts +70 -6
  118. package/src/bound-queries.ts +1 -1
  119. package/src/cleanup-registry.ts +5 -1
  120. package/src/fire-event.ts +17 -2
  121. package/src/harness-window.ts +37 -6
  122. package/src/internal.ts +5 -0
  123. package/src/matchers.ts +43 -9
  124. package/src/pretty-widget.ts +8 -5
  125. package/src/queries.ts +43 -10
  126. package/src/register-test-hooks.ts +11 -0
  127. package/src/render.tsx +56 -35
  128. package/src/role-helpers.ts +1 -1
  129. package/src/types.ts +11 -2
  130. package/src/usage-error.ts +16 -0
  131. package/src/user-event/adjustment.ts +11 -6
  132. package/src/user-event/click.ts +227 -47
  133. package/src/user-event/controller.ts +48 -3
  134. package/src/user-event/dispatch.ts +17 -7
  135. package/src/user-event/editable-label-click.ts +17 -0
  136. package/src/user-event/event-wrapper.ts +105 -14
  137. package/src/user-event/gesture.ts +101 -31
  138. package/src/user-event/index.ts +104 -36
  139. package/src/user-event/keyboard.ts +358 -35
  140. package/src/user-event/list-row-click.ts +12 -6
  141. package/src/user-event/native-click.ts +22 -3
  142. package/src/user-event/pointer.ts +101 -35
  143. package/src/user-event/selection.ts +71 -15
  144. package/src/user-event/state.ts +4 -2
  145. package/src/user-event/tab-view-click.ts +59 -0
  146. package/src/user-event/text.ts +39 -12
  147. package/src/widget-accessible-properties.ts +79 -18
  148. package/src/widget-target.ts +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;GAGG;AACH,KAAK,eAAe,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,KAAK,OAAO,CAAC;AACxE,wHAAwH;AACxH,KAAK,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,eAAe,CAAC;AAC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F;IACjF,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF;;;GAGG;AACH,KAAK,iBAAiB,CAAC,KAAK,IAAI;IAC5B,qFAAqF;IACrF,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC9B,GAAG,CAAC,SAAS,SAAS,KAAK,GACtB;IACI,yEAAyE;IACzE,YAAY,CAAC,EAAE,KAAK,CAAC;CACxB,GACD;IACI,YAAY,EAAE,KAAK,CAAC;CACvB,CAAC,CAAC;AAET;;;GAGG;AACH,KAAK,gBAAgB,CAAC,MAAM,EAAE,KAAK,IAAI;IACnC,2EAA2E;IAC3E,MAAM,EAAE;QACJ,sCAAsC;QACtC,OAAO,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,2EAA2E;IAC3E,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,kDAAkD;IAClD,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC,CAAC;AAEF,OAAO,EACH,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACxB,CAAC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAoQA,OAAO,EAoBN,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { CaughtErrorInfo, RootElement } from \"@gtkx/react\";\nimport type { ComponentType, ErrorInfo, PropsWithChildren } from \"react\";\nimport type { PrettyWidgetOptions } from \"./pretty-widget.js\";\nimport type { Container } from \"./traversal.js\";\n\n/**\n * A custom matcher predicate: given a candidate widget's normalized text content and the widget\n * itself, returns whether it matches.\n */\ntype MatcherFunction = (content: string, widget: Gtk.Widget) => boolean;\n/** A value used to match widget text: a string or number, a regular expression, or a custom {@link MatcherFunction}. */\ntype Matcher = string | number | RegExp | MatcherFunction;\n/** Normalizes a widget's text before it is compared against a matcher. */\ntype NormalizerFn = (text: string) => string;\n/**\n * A widget class usable as a query's `as` constraint, such as `Gtk.Button`. Abstract classes and\n * generated GInterface pseudo-classes that extend `Gtk.Accessible` are accepted.\n */\ntype WidgetType<T extends Gtk.Accessible = Gtk.Accessible> = abstract new (...args: never[]) => T;\n\n/** Options controlling the default text normalizer. */\ntype NormalizerOptions = {\n /** Trim leading and trailing whitespace. */\n trim?: boolean | undefined;\n /** Collapse runs of whitespace into a single space. */\n collapseWhitespace?: boolean | undefined;\n};\n\n/** Options controlling how asynchronous queries and waits poll for a condition. */\ntype WaitForOptions = {\n /** Maximum time in milliseconds to keep retrying before failing. */\n timeout?: number | undefined;\n /** Delay in milliseconds between retries. */\n interval?: number | undefined;\n /** Transforms the error thrown when the timeout elapses. */\n onTimeout?: ((error: Error) => Error) | undefined;\n /** Error whose stack trace attributes the timeout failure to the calling code. */\n stackTraceError?: Error | undefined;\n};\n\n/** Options controlling text matching and, for asynchronous queries, polling behavior. */\ntype MatcherOptions<T extends Gtk.Accessible = Gtk.Accessible> = {\n /** When true (the default), require an exact match; when false, match case-insensitively as a substring. */\n exact?: boolean | undefined;\n /** Custom normalizer replacing the default; cannot be combined with `trim` or `collapseWhitespace`. */\n normalizer?: NormalizerFn | undefined;\n /** Forwarded to the default normalizer when no custom `normalizer` is given. */\n trim?: boolean | undefined;\n /** Forwarded to the default normalizer when no custom `normalizer` is given. */\n collapseWhitespace?: boolean | undefined;\n /** Whether to include a suggested better query in error messages. */\n suggest?: boolean | undefined;\n /** Restricts matches to instances of this widget class, and narrows the query's return type to it. */\n as?: WidgetType<T> | undefined;\n} & WaitForOptions;\n\n/**\n * Constraints on a widget's numeric range value used by role queries. The numbers come from the\n * accessibility tree and match within 0.001, the resolution GTK keeps them to.\n */\ntype ByRoleValue = {\n /** The current value. */\n now?: number | undefined;\n /** The lower bound of the value's range. */\n min?: number | undefined;\n /**\n * The highest value the widget can reach, which on a paged widget such as a scrollbar is its\n * adjustment's upper bound less one page.\n */\n max?: number | undefined;\n /** Matcher for the value's textual representation. */\n text?: Matcher | undefined;\n};\n\n/** Options for role queries: an accessible name matcher plus accessible state and value constraints. */\ntype ByRoleOptions<T extends Gtk.Accessible = Gtk.Accessible> = MatcherOptions<T> & {\n /** Matcher for the widget's accessible name. */\n name?: Matcher | undefined;\n /** Required checked state; a mixed check button reads as neither, so it matches neither value. */\n checked?: boolean | undefined;\n /** Required active state of a toggle button; any other widget matches neither value. */\n pressed?: boolean | undefined;\n /** Required selected state of a row, list item, grid cell, option or tree item. */\n selected?: boolean | undefined;\n /** Required expanded state of an expander or tree expander. */\n expanded?: boolean | undefined;\n /** Heading or hierarchy level. */\n level?: number | undefined;\n /** Required busy state, which an unset state satisfies as false. */\n busy?: boolean | undefined;\n /** Matcher for the widget's own accessible description, ignoring its `described-by` targets. */\n description?: Matcher | undefined;\n /** Constraints on the widget's range value, each checked only when given. */\n value?: ByRoleValue | undefined;\n /** When true, include widgets excluded from the accessibility tree. Widgets that are not mapped stay excluded. */\n hidden?: boolean | undefined;\n};\n\n/** A React component that wraps rendered content, receiving it as its children. */\ntype WrapperComponent = ComponentType<Required<PropsWithChildren>>;\n\n/** A custom query, taking the scope to search as its first argument and its matcher arguments after it. */\ntype Query = (container: Container, ...args: never[]) => unknown;\n/** Custom queries keyed by the name each is bound under. */\ntype QueryMap = Record<string, Query>;\n\n/** A query with its container argument already applied. */\ntype BoundQuery<Q extends Query> = Q extends (container: Container, ...args: infer A) => infer R\n ? (...args: A) => R\n : never;\n\n/** Custom queries with their container argument already applied, keyed as they were passed in. */\ntype BoundCustomQueries<Q extends QueryMap> = { [K in keyof Q]: BoundQuery<Q[K]> };\n\n/** What each variant of a query family yields for the widget type it matched. */\ntype QueryFamilyReturns<T extends Gtk.Accessible> = {\n /** The single match, or null when nothing matched; throws when more than one matched. */\n queryBy: T | null;\n /** Every match, empty when nothing matched. */\n queryAllBy: T[];\n /** The single match; throws when nothing or more than one matched. */\n getBy: T;\n /** Every match; throws when nothing matched. */\n getAllBy: T[];\n /** The single match, retried until it appears or the timeout elapses. */\n findBy: Promise<T>;\n /** Every match, retried until at least one appears or the timeout elapses. */\n findAllBy: Promise<T[]>;\n};\n\n/** What a query family matches against, which fixes the arguments it takes. */\ntype QueryKind = \"role\" | \"text\" | \"name\" | \"value\";\n\n/** The arguments a query of the given kind takes after the family's leading ones. */\ntype QueryArgs<Kind extends QueryKind, T extends Gtk.Accessible> = Kind extends \"role\"\n ? [role: Gtk.AccessibleRole, options?: ByRoleOptions<T>]\n : Kind extends \"name\"\n ? [name: Matcher, options?: MatcherOptions<T>]\n : Kind extends \"value\"\n ? [value: Matcher, options?: MatcherOptions<T>]\n : [text: Matcher, options?: MatcherOptions<T>];\n\n/**\n * One family's query variants, each named for its variant followed by `Suffix` and taking `Head`\n * ahead of the family's own arguments.\n */\ntype QueryFamily<Suffix extends string, Kind extends QueryKind, Head extends unknown[]> = {\n [K in keyof QueryFamilyReturns<Gtk.Widget> as `${K & string}${Suffix}`]: <T extends Gtk.Accessible = Gtk.Widget>(\n ...args: [...Head, ...QueryArgs<Kind, T>]\n ) => QueryFamilyReturns<T>[K];\n};\n\n/**\n * Every built-in query, spanning the Role, LabelText, Text, Name, PlaceholderText, and DisplayValue\n * families, with `Head` prepended to each signature.\n */\ntype QueryFamilies<Head extends unknown[]> = QueryFamily<\"Role\", \"role\", Head> &\n QueryFamily<\"LabelText\", \"text\", Head> &\n QueryFamily<\"Text\", \"text\", Head> &\n QueryFamily<\"Name\", \"name\", Head> &\n QueryFamily<\"PlaceholderText\", \"text\", Head> &\n QueryFamily<\"DisplayValue\", \"value\", Head>;\n\n/**\n * Options for {@link render}: the container and base element to mount into, an optional wrapper,\n * React behavior toggles, error callbacks, and custom queries to bind.\n */\ntype RenderOptions<Q extends QueryMap = Record<never, never>> = {\n /**\n * Widget or root element to mount into; an undecorated harness window is created when omitted.\n * A widget container that sits outside every toplevel, such as a bare `Gtk.Box`, keeps the tree\n * out of reach of a pointer and a keyboard, so every `userEvent` helper aimed at it rejects\n * after `actionabilityTimeout`; `fireEvent` drives such a tree instead.\n */\n container?: Gtk.Accessible | RootElement | undefined;\n /** Root of the subtree that bound queries search. */\n baseElement?: Container | undefined;\n /** Component wrapped around the rendered element, such as a context provider. */\n wrapper?: WrapperComponent | undefined;\n /** Render inside React StrictMode. */\n isReactStrictMode?: boolean | undefined;\n /** Enable widget animations during the test. */\n areAnimationsEnabled?: boolean | undefined;\n /** Called for errors caught by React error boundaries. */\n onCaughtError?: ((error: unknown, errorInfo: CaughtErrorInfo) => void) | undefined;\n /** Called for errors React recovered from automatically. */\n onRecoverableError?: ((error: unknown, errorInfo: ErrorInfo) => void) | undefined;\n /** Custom queries to bind to the rendered result. */\n queries?: Q | undefined;\n};\n\n/** Console helpers bundled with the bound queries on {@link screen} and on a render result. */\ntype DebugUtilities = {\n /** Prints the widget tree of the given containers, or of the whole scope, to the console. */\n debug: (element?: Container | Container[], options?: PrettyWidgetOptions) => void;\n /** Prints the accessible roles found in the scope, with the widgets carrying each one. */\n logRoles: () => void;\n /**\n * Captures what is on screen, which is the active toplevel window: GTK4 exposes no position for\n * a toplevel, so windows cannot be composited into a single image.\n */\n screenshot: (options?: ScreenshotOptions) => Promise<ScreenshotResult>;\n};\n\n/** A captured screenshot: base64-encoded image data, its MIME type, and pixel dimensions. */\ntype ScreenshotResult = {\n /** Base64-encoded image bytes. */\n data: string;\n /** MIME type of the encoded image, always `image/png`. */\n mimeType: string;\n /** Image width in pixels, after the scale factor is applied. */\n width: number;\n /** Image height in pixels, after the scale factor is applied. */\n height: number;\n};\n\n/**\n * Options for capturing a screenshot: the poll timeout and interval, a rendering scale factor, and\n * a file to write the PNG to.\n */\ntype ScreenshotOptions = Pick<WaitForOptions, \"timeout\" | \"interval\"> & {\n /** Device scale factor applied when rendering. */\n scale?: number | undefined;\n /** File the PNG is written to, with its parent directories created as needed. */\n path?: string | undefined;\n};\n\n/**\n * Options for {@link renderHook}: an optional wrapper and the initial props (required unless the\n * props type permits undefined).\n */\ntype RenderHookOptions<Props> = {\n /** Component wrapped around the one calling the hook, such as a context provider. */\n wrapper?: WrapperComponent;\n} & (undefined extends Props\n ? {\n /** Props the hook is invoked with until `rerender` is given new ones. */\n initialProps?: Props;\n }\n : {\n initialProps: Props;\n });\n\n/**\n * The result of {@link renderHook}: the latest hook return value plus functions to rerender with new\n * props and to unmount.\n */\ntype RenderHookResult<Result, Props> = {\n /** Stable object the hook's return value is written to on every render. */\n result: {\n /** The hook's latest return value. */\n current: Result;\n };\n /** Re-invokes the hook, keeping the previous props when none are given. */\n rerender: (...args: [] | [newProps: Props]) => Promise<void>;\n /** Unmounts the component that calls the hook. */\n unmount: () => Promise<void>;\n};\n\nexport {\n type MatcherFunction,\n type Matcher,\n type NormalizerFn,\n type NormalizerOptions,\n type WaitForOptions,\n type MatcherOptions,\n type ByRoleValue,\n type ByRoleOptions,\n type WidgetType,\n type WrapperComponent,\n type QueryMap,\n type BoundCustomQueries,\n type QueryFamilies,\n type RenderOptions,\n type DebugUtilities,\n type ScreenshotResult,\n type ScreenshotOptions,\n type RenderHookOptions,\n type RenderHookResult,\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA6QA,OAAO,EAoBN,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { CaughtErrorInfo, RootElement } from \"@gtkx/react\";\nimport type { ComponentType, ErrorInfo, PropsWithChildren } from \"react\";\nimport type { PrettyWidgetOptions } from \"./pretty-widget.js\";\nimport type { Container } from \"./traversal.js\";\n\n/**\n * A custom matcher predicate: given a candidate widget's normalized text content and the widget\n * itself, returns whether it matches.\n */\ntype MatcherFunction = (content: string, widget: Gtk.Widget) => boolean;\n/** A value used to match widget text: a string or number, a regular expression, or a custom {@link MatcherFunction}. */\ntype Matcher = string | number | RegExp | MatcherFunction;\n/** Normalizes a widget's text before it is compared against a matcher. */\ntype NormalizerFn = (text: string) => string;\n/**\n * A widget class usable as a query's `as` constraint, such as `Gtk.Button`. Abstract classes and\n * generated GInterface pseudo-classes that extend `Gtk.Accessible` are accepted.\n */\ntype WidgetType<T extends Gtk.Accessible = Gtk.Accessible> = abstract new (...args: never[]) => T;\n\n/** Options controlling the default text normalizer. */\ntype NormalizerOptions = {\n /** Trim leading and trailing whitespace. */\n trim?: boolean | undefined;\n /** Collapse runs of whitespace into a single space. */\n collapseWhitespace?: boolean | undefined;\n};\n\n/** Options controlling how asynchronous queries and waits poll for a condition. */\ntype WaitForOptions = {\n /** Maximum time in milliseconds to keep retrying before failing. */\n timeout?: number | undefined;\n /** Delay in milliseconds between retries. */\n interval?: number | undefined;\n /** Transforms the error thrown when the timeout elapses. */\n onTimeout?: ((error: Error) => Error) | undefined;\n /** Error whose stack trace attributes the timeout failure to the calling code. */\n stackTraceError?: Error | undefined;\n};\n\n/** Options controlling text matching and, for asynchronous queries, polling behavior. */\ntype MatcherOptions<T extends Gtk.Accessible = Gtk.Accessible> = {\n /** When true (the default), require an exact match; when false, match case-insensitively as a substring. */\n exact?: boolean | undefined;\n /** Custom normalizer replacing the default; cannot be combined with `trim` or `collapseWhitespace`. */\n normalizer?: NormalizerFn | undefined;\n /** Forwarded to the default normalizer when no custom `normalizer` is given. */\n trim?: boolean | undefined;\n /** Forwarded to the default normalizer when no custom `normalizer` is given. */\n collapseWhitespace?: boolean | undefined;\n /** Whether to include a suggested better query in error messages. */\n suggest?: boolean | undefined;\n /** Restricts matches to instances of this widget class, and narrows the query's return type to it. */\n as?: WidgetType<T> | undefined;\n} & WaitForOptions;\n\n/**\n * Constraints on a widget's numeric range value used by role queries. The numbers come from the\n * accessibility tree and match within 0.001, the resolution GTK keeps them to.\n */\ntype ByRoleValue = {\n /** The current value. */\n now?: number | undefined;\n /** The lower bound of the value's range. */\n min?: number | undefined;\n /**\n * The highest value the widget can reach, which on a paged widget such as a scrollbar is its\n * adjustment's upper bound less one page.\n */\n max?: number | undefined;\n /** Matcher for the value's textual representation. */\n text?: Matcher | undefined;\n};\n\n/** Options for role queries: an accessible name matcher plus accessible state and value constraints. */\ntype ByRoleOptions<T extends Gtk.Accessible = Gtk.Accessible> = MatcherOptions<T> & {\n /** Matcher for the widget's accessible name. */\n name?: Matcher | undefined;\n /** Required checked state; a mixed check button reads as neither, so it matches neither value. */\n checked?: boolean | undefined;\n /** Required active state of a toggle button; any other widget matches neither value. */\n pressed?: boolean | undefined;\n /** Required selected state of a row, list item, grid cell, option or tree item. */\n selected?: boolean | undefined;\n /** Required expanded state of an expander or tree expander. */\n expanded?: boolean | undefined;\n /** Heading or hierarchy level. */\n level?: number | undefined;\n /** Required busy state, which an unset state satisfies as false. */\n busy?: boolean | undefined;\n /** Matcher for the widget's own accessible description, ignoring its `described-by` targets. */\n description?: Matcher | undefined;\n /** Constraints on the widget's range value, each checked only when given. */\n value?: ByRoleValue | undefined;\n /** When true, include widgets excluded from the accessibility tree. Widgets that are not mapped stay excluded. */\n hidden?: boolean | undefined;\n};\n\n/** A React component that wraps rendered content, receiving it as its children. */\ntype WrapperComponent = ComponentType<Required<PropsWithChildren>>;\n\n/** A custom query, taking the scope to search as its first argument and its matcher arguments after it. */\ntype Query = (container: Container, ...args: never[]) => unknown;\n/** Custom queries keyed by the name each is bound under. */\ntype QueryMap = Record<string, Query>;\n\n/** A query with its container argument already applied. */\ntype BoundQuery<Q extends Query> = Q extends (container: Container, ...args: infer A) => infer R\n ? (...args: A) => R\n : never;\n\n/** Custom queries with their container argument already applied, keyed as they were passed in. */\ntype BoundCustomQueries<Q extends QueryMap> = { [K in keyof Q]: BoundQuery<Q[K]> };\n\n/** What each variant of a query family yields for the widget type it matched. */\ntype QueryFamilyReturns<T extends Gtk.Accessible> = {\n /** The single match, or null when nothing matched; throws when more than one matched. */\n queryBy: T | null;\n /** Every match, empty when nothing matched. */\n queryAllBy: T[];\n /** The single match; throws when nothing or more than one matched. */\n getBy: T;\n /** Every match; throws when nothing matched. */\n getAllBy: T[];\n /** The single match, retried until it appears or the timeout elapses. */\n findBy: Promise<T>;\n /** Every match, retried until at least one appears or the timeout elapses. */\n findAllBy: Promise<T[]>;\n};\n\n/** What a query family matches against, which fixes the arguments it takes. */\ntype QueryKind = \"role\" | \"text\" | \"name\" | \"value\";\n\n/** The arguments a query of the given kind takes after the family's leading ones. */\ntype QueryArgs<Kind extends QueryKind, T extends Gtk.Accessible> = Kind extends \"role\"\n ? [role: Gtk.AccessibleRole, options?: ByRoleOptions<T>]\n : Kind extends \"name\"\n ? [name: Matcher, options?: MatcherOptions<T>]\n : Kind extends \"value\"\n ? [value: Matcher, options?: MatcherOptions<T>]\n : [text: Matcher, options?: MatcherOptions<T>];\n\n/**\n * The arguments a variant takes after the family's own. As in Testing Library, `findBy` and `findAllBy` take\n * their wait options third; options given with the matcher options also apply, and the third argument wins.\n */\ntype VariantArgs<Variant> = Variant extends \"findBy\" | \"findAllBy\" ? [waitForOptions?: WaitForOptions] : [];\n\n/**\n * One family's query variants, each named for its variant followed by `Suffix` and taking `Head`\n * ahead of the family's own arguments.\n */\ntype QueryFamily<Suffix extends string, Kind extends QueryKind, Head extends unknown[]> = {\n [K in keyof QueryFamilyReturns<Gtk.Widget> as `${K & string}${Suffix}`]: <T extends Gtk.Accessible = Gtk.Widget>(\n ...args: [...Head, ...QueryArgs<Kind, T>, ...VariantArgs<K>]\n ) => QueryFamilyReturns<T>[K];\n};\n\n/**\n * Every built-in query, spanning the Role, LabelText, Text, Name, PlaceholderText, and DisplayValue\n * families, with `Head` prepended to each signature.\n */\ntype QueryFamilies<Head extends unknown[]> = QueryFamily<\"Role\", \"role\", Head> &\n QueryFamily<\"LabelText\", \"text\", Head> &\n QueryFamily<\"Text\", \"text\", Head> &\n QueryFamily<\"Name\", \"name\", Head> &\n QueryFamily<\"PlaceholderText\", \"text\", Head> &\n QueryFamily<\"DisplayValue\", \"value\", Head>;\n\n/**\n * Options for {@link render}: the container and base element to mount into, an optional wrapper,\n * React behavior toggles, error callbacks, and custom queries to bind.\n */\ntype RenderOptions<Q extends QueryMap = Record<never, never>> = {\n /**\n * Widget or root element to mount into; an undecorated harness window is created when omitted.\n * A widget container that sits outside every toplevel, such as a bare `Gtk.Box`, keeps the tree\n * out of reach of a pointer and a keyboard, so every `userEvent` helper aimed at it rejects\n * after `actionabilityTimeout`; `fireEvent` drives such a tree instead.\n */\n container?: Gtk.Accessible | RootElement | undefined;\n /** Root of the subtree that bound queries search. */\n baseElement?: Container | undefined;\n /** Component wrapped around the rendered element, such as a context provider. */\n wrapper?: WrapperComponent | undefined;\n /** Render inside React StrictMode. */\n isReactStrictMode?: boolean | undefined;\n /** Enable widget animations during the test. */\n areAnimationsEnabled?: boolean | undefined;\n /**\n * Called for errors caught by React error boundaries, which never fail the test. They are logged when\n * this is omitted.\n */\n onCaughtError?: ((error: unknown, errorInfo: CaughtErrorInfo) => void) | undefined;\n /** Called for errors React recovered from automatically. */\n onRecoverableError?: ((error: unknown, errorInfo: ErrorInfo) => void) | undefined;\n /** Custom queries to bind to the rendered result. */\n queries?: Q | undefined;\n};\n\n/** Console helpers bundled with the bound queries on {@link screen} and on a render result. */\ntype DebugUtilities = {\n /** Prints the widget tree of the given containers, or of the whole scope, to the console. */\n debug: (element?: Container | Container[], options?: PrettyWidgetOptions) => void;\n /** Prints the accessible roles found in the scope, with the widgets carrying each one. */\n logRoles: () => void;\n /**\n * Captures what is on screen, which is the active toplevel window: GTK4 exposes no position for\n * a toplevel, so windows cannot be composited into a single image.\n */\n screenshot: (options?: ScreenshotOptions) => Promise<ScreenshotResult>;\n};\n\n/** A captured screenshot: base64-encoded image data, its MIME type, and pixel dimensions. */\ntype ScreenshotResult = {\n /** Base64-encoded image bytes. */\n data: string;\n /** MIME type of the encoded image, always `image/png`. */\n mimeType: string;\n /** Image width in pixels, after the scale factor is applied. */\n width: number;\n /** Image height in pixels, after the scale factor is applied. */\n height: number;\n};\n\n/**\n * Options for capturing a screenshot: the poll timeout and interval, a rendering scale factor, and\n * a file to write the PNG to.\n */\ntype ScreenshotOptions = Pick<WaitForOptions, \"timeout\" | \"interval\"> & {\n /** Device scale factor applied when rendering. */\n scale?: number | undefined;\n /** File the PNG is written to, with its parent directories created as needed. */\n path?: string | undefined;\n};\n\n/**\n * Options for {@link renderHook}: an optional wrapper and the initial props (required unless the\n * props type permits undefined).\n */\ntype RenderHookOptions<Props> = {\n /** Component wrapped around the one calling the hook, such as a context provider. */\n wrapper?: WrapperComponent;\n} & (undefined extends Props\n ? {\n /** Props the hook is invoked with until `rerender` is given new ones. */\n initialProps?: Props;\n }\n : {\n initialProps: Props;\n });\n\n/**\n * The result of {@link renderHook}: the latest hook return value plus functions to rerender with new\n * props and to unmount.\n */\ntype RenderHookResult<Result, Props> = {\n /** Stable object the hook's return value is written to on every render. */\n result: {\n /** The hook's latest return value. */\n current: Result;\n };\n /** Re-invokes the hook, keeping the previous props when none are given. */\n rerender: (...args: [] | [newProps: Props]) => Promise<void>;\n /** Unmounts the component that calls the hook. */\n unmount: () => Promise<void>;\n};\n\nexport {\n type MatcherFunction,\n type Matcher,\n type NormalizerFn,\n type NormalizerOptions,\n type WaitForOptions,\n type MatcherOptions,\n type ByRoleValue,\n type ByRoleOptions,\n type WidgetType,\n type WrapperComponent,\n type QueryMap,\n type BoundCustomQueries,\n type QueryFamilies,\n type RenderOptions,\n type DebugUtilities,\n type ScreenshotResult,\n type ScreenshotOptions,\n type RenderHookOptions,\n type RenderHookResult,\n};\n"]}
@@ -0,0 +1,9 @@
1
+ /** Marks an error @gtkx/testing raises because it was called on a target or with input it cannot use. */
2
+ declare const usageError: <T extends Error>(error: T) => T;
3
+ /**
4
+ * Whether @gtkx/testing raised this error because it was misused, such as typing into a widget that is not editable,
5
+ * rather than because the code under test threw it while handling the interaction.
6
+ */
7
+ declare const isUsageError: (reason: unknown) => boolean;
8
+ export { isUsageError, usageError };
9
+ //# sourceMappingURL=usage-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage-error.d.ts","sourceRoot":"","sources":["../src/usage-error.ts"],"names":[],"mappings":"AAEA,yGAAyG;AACzG,QAAA,MAAM,UAAU,GAAI,CAAC,SAAS,KAAK,SAAS,CAAC,KAAG,CAI/C,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,YAAY,WAAY,OAAO,KAAG,OAA6D,CAAC;AAEtG,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,13 @@
1
+ const usageErrors = new WeakSet();
2
+ /** Marks an error @gtkx/testing raises because it was called on a target or with input it cannot use. */
3
+ const usageError = (error) => {
4
+ usageErrors.add(error);
5
+ return error;
6
+ };
7
+ /**
8
+ * Whether @gtkx/testing raised this error because it was misused, such as typing into a widget that is not editable,
9
+ * rather than because the code under test threw it while handling the interaction.
10
+ */
11
+ const isUsageError = (reason) => reason instanceof Error && usageErrors.has(reason);
12
+ export { isUsageError, usageError };
13
+ //# sourceMappingURL=usage-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage-error.js","sourceRoot":"","sources":["../src/usage-error.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAmB,IAAI,OAAO,EAAE,CAAC;AAElD,yGAAyG;AACzG,MAAM,UAAU,GAAG,CAAkB,KAAQ,EAAK,EAAE;IAChD,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAEvB,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,YAAY,GAAG,CAAC,MAAe,EAAW,EAAE,CAAC,MAAM,YAAY,KAAK,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAEtG,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC","sourcesContent":["const usageErrors: WeakSet<Error> = new WeakSet();\n\n/** Marks an error @gtkx/testing raises because it was called on a target or with input it cannot use. */\nconst usageError = <T extends Error>(error: T): T => {\n usageErrors.add(error);\n\n return error;\n};\n\n/**\n * Whether @gtkx/testing raised this error because it was misused, such as typing into a widget that is not editable,\n * rather than because the code under test threw it while handling the interaction.\n */\nconst isUsageError = (reason: unknown): boolean => reason instanceof Error && usageErrors.has(reason);\n\nexport { isUsageError, usageError };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"adjustment.d.ts","sourceRoot":"","sources":["../../src/user-event/adjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAKpC,mDAAmD;AACnD,KAAK,WAAW,GAAG;IACf,mDAAmD;IACnD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,CAAC,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAOF,gCAAgC;AAChC,QAAA,MAAM,KAAK,WAAY,GAAG,CAAC,MAAM,SAAS,MAAM,KAAG,OAAO,CAAC,IAAI,CAOzD,CAAC;AA8CP,6DAA6D;AAC7D,QAAA,MAAM,MAAM,WAAY,GAAG,CAAC,MAAM,SAAS,WAAW,KAAG,OAAO,CAAC,IAAI,CAa/D,CAAC;AAEP,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"adjustment.d.ts","sourceRoot":"","sources":["../../src/user-event/adjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAMpC,mDAAmD;AACnD,KAAK,WAAW,GAAG;IACf,mDAAmD;IACnD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,CAAC,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAOF,gCAAgC;AAChC,QAAA,MAAM,KAAK,WAAY,GAAG,CAAC,MAAM,SAAS,MAAM,KAAG,OAAO,CAAC,IAAI,CASzD,CAAC;AA8CP,6DAA6D;AAC7D,QAAA,MAAM,MAAM,WAAY,GAAG,CAAC,MAAM,SAAS,WAAW,KAAG,OAAO,CAAC,IAAI,CAe/D,CAAC;AAEP,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,CAAC"}
@@ -1,11 +1,12 @@
1
1
  import * as Gtk from "@gtkx/gi/gtk";
2
2
  import { scheduleNextFrame } from "../frame-sync.js";
3
3
  import { getTypeTag } from "../widget-getters.js";
4
- import { wrapEvent } from "./event-wrapper.js";
4
+ import { wrapPointerEvent } from "./event-wrapper.js";
5
+ import { usageError } from "../usage-error.js";
5
6
  /** Moves a range to a value. */
6
- const slide = (widget, value) => wrapEvent(widget, () => {
7
+ const slide = (widget, value) => wrapPointerEvent(widget, () => {
7
8
  if (!(widget instanceof Gtk.Range)) {
8
- throw new TypeError(`userEvent.slide requires a Gtk.Range (e.g. Gtk.Scale), got ${getTypeTag(widget)}`);
9
+ throw usageError(new TypeError(`userEvent.slide requires a Gtk.Range (e.g. Gtk.Scale), got ${getTypeTag(widget)}`));
9
10
  }
10
11
  widget.emit("change-value", Gtk.ScrollType.JUMP, value);
11
12
  });
@@ -43,10 +44,10 @@ const applyScrollDelta = (adjustment, delta) => {
43
44
  rampTo(adjustment, adjustment.getValue() + delta, pageSize > 0 ? pageSize : Math.abs(delta));
44
45
  };
45
46
  /** Scrolls the widget or its nearest scrollable ancestor. */
46
- const scroll = (widget, delta) => wrapEvent(widget, async () => {
47
+ const scroll = (widget, delta) => wrapPointerEvent(widget, async () => {
47
48
  const adjustments = resolveScrollAdjustments(widget);
48
49
  if (!adjustments) {
49
- throw new Error("userEvent.scroll: no Gtk.ScrolledWindow or Gtk.Scrollable found on the widget or its ancestors");
50
+ throw usageError(new Error("userEvent.scroll: no Gtk.ScrolledWindow or Gtk.Scrollable found on the widget or its ancestors"));
50
51
  }
51
52
  applyScrollDelta(adjustments.horizontal, delta.x ?? 0);
52
53
  applyScrollDelta(adjustments.vertical, delta.y ?? 0);
@@ -1 +1 @@
1
- {"version":3,"file":"adjustment.js","sourceRoot":"","sources":["../../src/user-event/adjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAe/C,gCAAgC;AAChC,MAAM,KAAK,GAAG,CAAC,MAAkB,EAAE,KAAa,EAAiB,EAAE,CAC/D,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE;IACnB,IAAI,CAAC,CAAC,MAAM,YAAY,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,SAAS,CAAC,8DAA8D,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC5G,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC5D,CAAC,CAAC,CAAC;AAEP,MAAM,wBAAwB,GAAG,CAAC,MAAkB,EAA4B,EAAE;IAC9E,KAAK,IAAI,OAAO,GAAsB,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;QACnF,IAAI,OAAO,YAAY,GAAG,CAAC,cAAc,EAAE,CAAC;YACxC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;QACxF,CAAC;QAED,IAAI,OAAO,Y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,CAAC,QAAQ,EAAE,GAAG,KAAK,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AACjG,CAAC,CAAC;AAEF,6DAA6D;AAC7D,MAAM,MAAM,GAAG,CAAC,MAAkB,EAAE,KAAkB,EAAiB,EAAE,CACrE,SAAS,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;IACzB,MAAM,WAAW,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAC;IAErD,IAAI,CAAC,WAAW,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACX,gGAAgG,CACnG,CAAC;IACN,CAAC;IAED,gBAAgB,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,gBAAgB,CAAC,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC,CAAC,CAAC;AAEP,OAAO,EAAE,KAAK,EAAE,MAAM,EAAoB,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { scheduleNextFrame } from \"../frame-sync.js\";\nimport { getTypeTag } from \"../widget-getters.js\";\nimport { wrapEvent } from \"./event-wrapper.js\";\n\n/** A scroll distance in pixels along each axis. */\ntype ScrollDelta = {\n /** Distance added to the horizontal adjustment. */\n x?: number;\n /** Distance added to the vertical adjustment. */\n y?: number;\n};\n\ntype ScrollAdjustments = {\n horizontal: Gtk.Adjustment | null;\n vertical: Gtk.Adjustment | null;\n};\n\n/** Moves a range to a value. */\nconst slide = (widget: Gtk.Widget, value: number): Promise<void> =>\n wrapEvent(widget, () => {\n if (!(widget instanceof Gtk.Range)) {\n throw new TypeError(`userEvent.slide requires a Gtk.Range (e.g. Gtk.Scale), got ${getTypeTag(widget)}`);\n }\n\n widget.emit(\"change-value\", Gtk.ScrollType.JUMP, value);\n });\n\nconst resolveScrollAdjustments = (widget: Gtk.Widget): ScrollAdjustments | null => {\n for (let current: Gtk.Widget | null = widget; current; current = current.getParent()) {\n if (current instanceof Gtk.ScrolledWindow) {\n return { horizontal: current.getHadjustment(), vertical: current.getVadjustment() };\n }\n\n if (current instanceof Gtk.Scrollable) {\n return { horizontal: current.getHadjustment(), vertical: current.getVadjustment() };\n }\n }\n\n return null;\n};\n\nconst stepToward = (adjustment: Gtk.Adjustment, target: number, step: number): number => {\n const value = adjustment.getValue();\n adjustment.setValue(value < target ? Math.min(value + step, target) : Math.max(value - step, target));\n\n return adjustment.getValue();\n};\n\nconst rampTo = (adjustment: Gtk.Adjustment, target: number, step: number): void => {\n let value = adjustment.getValue();\n\n while (value !== target) {\n const moved = stepToward(adjustment, target, step);\n\n if (moved === value) {\n return;\n }\n\n value = moved;\n }\n};\n\nconst applyScrollDelta = (adjustment: Gtk.Adjustment | null, delta: number): void => {\n if (!adjustment || delta === 0) {\n return;\n }\n\n const pageSize = adjustment.getPageSize();\n rampTo(adjustment, adjustment.getValue() + delta, pageSize > 0 ? pageSize : Math.abs(delta));\n};\n\n/** Scrolls the widget or its nearest scrollable ancestor. */\nconst scroll = (widget: Gtk.Widget, delta: ScrollDelta): Promise<void> =>\n wrapEvent(widget, async () => {\n const adjustments = resolveScrollAdjustments(widget);\n\n if (!adjustments) {\n throw new Error(\n \"userEvent.scroll: no Gtk.ScrolledWindow or Gtk.Scrollable found on the widget or its ancestors\",\n );\n }\n\n applyScrollDelta(adjustments.horizontal, delta.x ?? 0);\n applyScrollDelta(adjustments.vertical, delta.y ?? 0);\n await scheduleNextFrame(widget);\n });\n\nexport { slide, scroll, type ScrollDelta };\n"]}
1
+ {"version":3,"file":"adjustment.js","sourceRoot":"","sources":["../../src/user-event/adjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,iBAAi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M,EAAE,KAAK,IAAI,EAAE;IAChC,MAAM,WAAW,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAC;IAErD,IAAI,CAAC,WAAW,EAAE,CAAC;QACf,MAAM,UAAU,CACZ,IAAI,KAAK,CACL,gGAAgG,CACnG,CACJ,CAAC;IACN,CAAC;IAED,gBAAgB,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,gBAAgB,CAAC,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC,CAAC,CAAC;AAEP,OAAO,EAAE,KAAK,EAAE,MAAM,EAAoB,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { scheduleNextFrame } from \"../frame-sync.js\";\nimport { getTypeTag } from \"../widget-getters.js\";\nimport { wrapPointerEvent } from \"./event-wrapper.js\";\nimport { usageError } from \"../usage-error.js\";\n\n/** A scroll distance in pixels along each axis. */\ntype ScrollDelta = {\n /** Distance added to the horizontal adjustment. */\n x?: number;\n /** Distance added to the vertical adjustment. */\n y?: number;\n};\n\ntype ScrollAdjustments = {\n horizontal: Gtk.Adjustment | null;\n vertical: Gtk.Adjustment | null;\n};\n\n/** Moves a range to a value. */\nconst slide = (widget: Gtk.Widget, value: number): Promise<void> =>\n wrapPointerEvent(widget, () => {\n if (!(widget instanceof Gtk.Range)) {\n throw usageError(\n new TypeError(`userEvent.slide requires a Gtk.Range (e.g. Gtk.Scale), got ${getTypeTag(widget)}`),\n );\n }\n\n widget.emit(\"change-value\", Gtk.ScrollType.JUMP, value);\n });\n\nconst resolveScrollAdjustments = (widget: Gtk.Widget): ScrollAdjustments | null => {\n for (let current: Gtk.Widget | null = widget; current; current = current.getParent()) {\n if (current instanceof Gtk.ScrolledWindow) {\n return { horizontal: current.getHadjustment(), vertical: current.getVadjustment() };\n }\n\n if (current instanceof Gtk.Scrollable) {\n return { horizontal: current.getHadjustment(), vertical: current.getVadjustment() };\n }\n }\n\n return null;\n};\n\nconst stepToward = (adjustment: Gtk.Adjustment, target: number, step: number): number => {\n const value = adjustment.getValue();\n adjustment.setValue(value < target ? Math.min(value + step, target) : Math.max(value - step, target));\n\n return adjustment.getValue();\n};\n\nconst rampTo = (adjustment: Gtk.Adjustment, target: number, step: number): void => {\n let value = adjustment.getValue();\n\n while (value !== target) {\n const moved = stepToward(adjustment, target, step);\n\n if (moved === value) {\n return;\n }\n\n value = moved;\n }\n};\n\nconst applyScrollDelta = (adjustment: Gtk.Adjustment | null, delta: number): void => {\n if (!adjustment || delta === 0) {\n return;\n }\n\n const pageSize = adjustment.getPageSize();\n rampTo(adjustment, adjustment.getValue() + delta, pageSize > 0 ? pageSize : Math.abs(delta));\n};\n\n/** Scrolls the widget or its nearest scrollable ancestor. */\nconst scroll = (widget: Gtk.Widget, delta: ScrollDelta): Promise<void> =>\n wrapPointerEvent(widget, async () => {\n const adjustments = resolveScrollAdjustments(widget);\n\n if (!adjustments) {\n throw usageError(\n new Error(\n \"userEvent.scroll: no Gtk.ScrolledWindow or Gtk.Scrollable found on the widget or its ancestors\",\n ),\n );\n }\n\n applyScrollDelta(adjustments.horizontal, delta.x ?? 0);\n applyScrollDelta(adjustments.vertical, delta.y ?? 0);\n await scheduleNextFrame(widget);\n });\n\nexport { slide, scroll, type ScrollDelta };\n"]}
@@ -1,5 +1,7 @@
1
+ import * as Gdk from "@gtkx/gi/gdk";
1
2
  import * as Gtk from "@gtkx/gi/gtk";
2
3
  import { type NativeClick } from "./native-click.js";
4
+ import type { UserEventState } from "./state.js";
3
5
  type PressPoint = {
4
6
  x: number;
5
7
  y: number;
@@ -13,14 +15,20 @@ type DirectClick = {
13
15
  sites: ClickSite[];
14
16
  outcome: NativeClick | null;
15
17
  };
16
- declare const emitSitePhase: (sites: ClickSite[], nPress: number, phase: ClickPhase) => void;
18
+ declare const emitSitePhase: (sites: ClickSite[], nPress: number, phase: ClickPhase, modifiers: Gdk.ModifierType, button?: number) => ClickSite[];
17
19
  declare const directClickFor: (widget: Gtk.Widget) => DirectClick;
18
- /** Activates or presses and releases a widget. */
19
- declare const click: (widget: Gtk.Widget) => Promise<void>;
20
+ /**
21
+ * The press sites a non-primary button reaches: the authored click gestures listening for that button on the widget
22
+ * and its ancestors that GTK runs for the press, as it propagates up the tree. Widgets react to these buttons only
23
+ * through gestures.
24
+ */
25
+ declare const buttonSitesFor: (widget: Gtk.Widget, button: number) => ClickSite[];
26
+ /** Activates or presses and releases a widget, and returns whether anything is known to have handled the click. */
27
+ declare const click: (state: UserEventState, widget: Gtk.Widget) => Promise<boolean>;
20
28
  /** Delivers a double-click gesture. */
21
- declare const dblClick: (widget: Gtk.Widget) => Promise<void>;
29
+ declare const dblClick: (state: UserEventState, widget: Gtk.Widget) => Promise<boolean>;
22
30
  /** Delivers a triple-click gesture. */
23
- declare const tripleClick: (widget: Gtk.Widget) => Promise<void>;
24
- export { directClickFor, emitSitePhase, click, dblClick, tripleClick };
25
- export type { DirectClick };
31
+ declare const tripleClick: (state: UserEventState, widget: Gtk.Widget) => Promise<boolean>;
32
+ export { buttonSitesFor, directClickFor, emitSitePhase, click, dblClick, tripleClick };
33
+ export type { ClickSite, DirectClick };
26
34
  //# sourceMappingURL=click.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAMpC,OAAO,EAAsB,KAAK,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAEzF,KAAK,UAAU,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAC3C,KAAK,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;AACzC,KAAK,SAAS,GAAG;IAAE,QAAQ,EAAE,GAAG,CAAC,YAAY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EAAE,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAAC;AAErE,KAAK,WAAW,GAAG;IAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;CAAE,CAAC;AA8GvE,QAAA,MAAM,aAAa,UACR,SAAS,EAAE,UACV,MAAM,SACP,UAAU,aACN,GAAG,CAAC,YAAY,WACnB,MAAM,KACf,SAAS,EAYX,CAAC;AA8MF,QAAA,MAAM,cAAc,WAAY,GAAG,CAAC,MAAM,KAAG,WAU5C,CAAC;AAQF;;;;GAIG;AACH,QAAA,MAAM,cAAc,WAAY,GAAG,CAAC,MAAM,UAAU,MAAM,KAAG,SAAS,EAgBrE,CAAC;AA2DF,mHAAmH;AACnH,QAAA,MAAM,KAAK,UAAiB,cAAc,UAAU,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,OAAO,CAM/E,CAAC;AAEF,uCAAuC;AACvC,QAAA,MAAM,QAAQ,UAAW,cAAc,UAAU,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,OAAO,CAAmC,CAAC;AACjH,uCAAuC;AACvC,QAAA,MAAM,WAAW,UAAW,cAAc,UAAU,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,OAAO,CAAmC,CAAC;AAEpH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AACvF,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC"}
@@ -1,13 +1,14 @@
1
1
  import * as Gdk from "@gtkx/gi/gdk";
2
2
  import * as Gtk from "@gtkx/gi/gtk";
3
3
  import { hasSignalListener } from "@gtkx/runtime/internal";
4
- import { callBooleanGetter, getCallableMethod, hasWidgetMethod } from "../widget-getters.js";
5
- import { queryAllControllers } from "./controller.js";
6
- import { wrapEvent } from "./event-wrapper.js";
4
+ import { callBooleanGetter, getCallableMethod, getWidgetTypeName, hasWidgetMethod } from "../widget-getters.js";
5
+ import { queryAllControllers, receivesEventsFor, runsFor } from "./controller.js";
6
+ import { wrapPointerEvent } from "./event-wrapper.js";
7
7
  import { hasIndexedChildren, selectContainerChild, SELECTED_PROBE, unselectOtherChildren } from "./indexed-children.js";
8
8
  import { isClickTransparent, nativeClickFor } from "./native-click.js";
9
9
  const CLICK_SIGNALS = ["pressed", "released"];
10
10
  const PRIMARY_BUTTONS = new Set([0, Gdk.BUTTON_PRIMARY]);
11
+ const MENU_ITEM_TYPE_NAME = "GtkModelButton";
11
12
  const getCenterPoint = (widget) => {
12
13
  const width = widget.getWidth();
13
14
  const height = widget.getHeight();
@@ -26,21 +27,73 @@ const getClickPoint = (clicked, carrier) => {
26
27
  }
27
28
  return { x: bounds.getX() + bounds.getWidth() / 2, y: bounds.getY() + bounds.getHeight() / 2 };
28
29
  };
29
- const emitGesture = (point, controllers, nPress, signal) => {
30
+ const emitWithCurrentEvent = (controller, button, modifiers, emit) => {
31
+ const instance = controller;
32
+ const hasOwnButton = Object.hasOwn(instance, "getCurrentButton");
33
+ const hasOwnState = Object.hasOwn(instance, "getCurrentEventState");
34
+ const hasOwnSetState = Object.hasOwn(instance, "setState");
35
+ const previousButton = instance.getCurrentButton;
36
+ const previousState = instance.getCurrentEventState;
37
+ const previousSetState = instance.setState;
38
+ let isClaimed = false;
39
+ instance.getCurrentButton = () => button;
40
+ instance.getCurrentEventState = () => modifiers;
41
+ instance.setState = (state) => {
42
+ isClaimed = state === Gtk.EventSequenceState.CLAIMED;
43
+ return true;
44
+ };
45
+ try {
46
+ emit();
47
+ }
48
+ finally {
49
+ if (hasOwnButton) {
50
+ instance.getCurrentButton = previousButton;
51
+ }
52
+ else {
53
+ delete instance.getCurrentButton;
54
+ }
55
+ if (hasOwnState) {
56
+ instance.getCurrentEventState = previousState;
57
+ }
58
+ else {
59
+ delete instance.getCurrentEventState;
60
+ }
61
+ if (hasOwnSetState) {
62
+ instance.setState = previousSetState;
63
+ }
64
+ else {
65
+ delete instance.setState;
66
+ }
67
+ }
68
+ return isClaimed;
69
+ };
70
+ const emitGesture = (point, controllers, nPress, signal, button, modifiers) => {
71
+ let isClaimed = false;
30
72
  for (const controller of controllers) {
31
- controller.emit(signal, nPress, point.x, point.y);
73
+ const hasClaimed = emitWithCurrentEvent(controller, button, modifiers, () => {
74
+ controller.emit(signal, nPress, point.x, point.y);
75
+ });
76
+ isClaimed ||= hasClaimed;
32
77
  }
78
+ return isClaimed;
33
79
  };
34
- const emitSitePhase = (sites, nPress, phase) => {
80
+ const emitSitePhase = (sites, nPress, phase, modifiers, button = Gdk.BUTTON_PRIMARY) => {
81
+ const reached = [];
35
82
  for (const site of sites) {
36
- emitGesture(site.point, site.gestures, nPress, phase);
83
+ reached.push(site);
84
+ if (emitGesture(site.point, site.gestures, nPress, phase, button, modifiers)) {
85
+ break;
86
+ }
37
87
  }
88
+ return reached;
38
89
  };
39
- const emitClickSequence = (sites, nPress) => {
90
+ const emitClickSequence = (sites, nPress, modifiers) => {
91
+ let reached = [];
40
92
  for (let i = 1; i <= nPress; i++) {
41
- emitSitePhase(sites, i, "pressed");
42
- emitSitePhase(sites, i, "released");
93
+ reached = emitSitePhase(sites, i, "pressed", modifiers);
94
+ emitSitePhase(reached, i, "released", modifiers);
43
95
  }
96
+ return new Set(reached);
44
97
  };
45
98
  const containerFor = (widget) => {
46
99
  const parent = widget.getParent();
@@ -49,13 +102,26 @@ const containerFor = (widget) => {
49
102
  const hasClickHandlers = (gesture) => hasSignalListener(gesture, CLICK_SIGNALS);
50
103
  const isInternalGesture = (gesture) => !hasSignalListener(gesture);
51
104
  const isPrimaryGesture = (gesture) => PRIMARY_BUTTONS.has(gesture.getButton());
52
- const clickGestures = (widget) => queryAllControllers(widget, Gtk.GestureClick).filter((gesture) => isPrimaryGesture(gesture));
53
- const getAuthoredClickGestures = (widget) => clickGestures(widget).filter((gesture) => hasClickHandlers(gesture));
54
- const gestureTargetFor = (widget, isInternalAllowed) => {
55
- const gestures = clickGestures(widget);
105
+ const clickGestures = (widget, clicked) => queryAllControllers(widget, Gtk.GestureClick).filter((gesture) => isPrimaryGesture(gesture) && runsFor(gesture, widget, clicked));
106
+ const getAuthoredClickGestures = (widget, clicked) => clickGestures(widget, clicked).filter((gesture) => hasClickHandlers(gesture));
107
+ const authoredTargetFor = (widget, clicked) => {
108
+ const gestures = getAuthoredClickGestures(widget, clicked);
109
+ return gestures.length > 0 ? { widget, container: null, gestures, isClaiming: false, native: null } : null;
110
+ };
111
+ const gestureTargetFor = (widget, clicked, isInternalAllowed) => {
112
+ const gestures = clickGestures(widget, clicked);
56
113
  if (widget instanceof Gtk.Button) {
57
114
  return { widget, container: null, gestures, isClaiming: true, native: null };
58
115
  }
116
+ if (widget instanceof Gtk.WindowHandle) {
117
+ return {
118
+ widget,
119
+ container: null,
120
+ gestures: getAuthoredClickGestures(widget, clicked),
121
+ isClaiming: true,
122
+ native: null,
123
+ };
124
+ }
59
125
  const container = containerFor(widget);
60
126
  if (container !== null) {
61
127
  return {
@@ -66,33 +132,47 @@ const gestureTargetFor = (widget, isInternalAllowed) => {
66
132
  native: null,
67
133
  };
68
134
  }
69
- const authored = gestures.filter((gesture) => hasClickHandlers(gesture));
70
- if (authored.length > 0) {
71
- return { widget, container: null, gestures: authored, isClaiming: false, native: null };
135
+ const authored = authoredTargetFor(widget, clicked);
136
+ if (authored !== null) {
137
+ return authored;
72
138
  }
73
139
  if (isInternalAllowed && gestures.some((gesture) => isInternalGesture(gesture))) {
74
140
  return { widget, container: null, gestures, isClaiming: true, native: null };
75
141
  }
76
142
  return null;
77
143
  };
144
+ /**
145
+ * The click target a widget forms for a press on `scope.clicked`. Past the clicked widget's event limit, such as the
146
+ * popover it sits in, only authored gestures without a propagation limit receive the press: GTK's own click gestures
147
+ * keep the default same-native limit.
148
+ */
78
149
  const clickTargetFor = (widget, scope) => {
150
+ const { clicked } = scope;
79
151
  if (isClickTransparent(widget)) {
80
152
  return null;
81
153
  }
82
- const native = nativeClickFor(widget, scope.isClicked);
154
+ if (!receivesEventsFor(widget, Gtk.PropagationLimit.SAME_NATIVE, clicked)) {
155
+ return authoredTargetFor(widget, clicked);
156
+ }
157
+ const native = nativeClickFor(widget, widget === clicked);
83
158
  if (native !== null) {
84
- return { widget, container: null, gestures: getAuthoredClickGestures(widget), isClaiming: true, native };
159
+ return {
160
+ widget,
161
+ container: null,
162
+ gestures: getAuthoredClickGestures(widget, clicked),
163
+ isClaiming: true,
164
+ native,
165
+ };
85
166
  }
86
- return gestureTargetFor(widget, scope.isInternalAllowed);
167
+ return gestureTargetFor(widget, clicked, scope.isInternalAllowed);
87
168
  };
88
- const isSelfClickTarget = (widget) => isClickTransparent(widget) || clickTargetFor(widget, { isClicked: true, isInternalAllowed: false }) !== null;
169
+ const isSelfClickTarget = (widget) => isClickTransparent(widget) || clickTargetFor(widget, { clicked: widget, isInternalAllowed: false }) !== null;
89
170
  const nextClickWidget = (current, target) => target?.isClaiming === true ? null : current.getParent();
90
171
  const collectClickTargets = (widget) => {
91
172
  const targets = [];
92
173
  let current = widget;
93
174
  while (current !== null) {
94
- const isClicked = current === widget;
95
- const scope = { isClicked, isInternalAllowed: !isClicked && targets.length === 0 };
175
+ const scope = { clicked: widget, isInternalAllowed: current !== widget && targets.length === 0 };
96
176
  const target = clickTargetFor(current, scope);
97
177
  const next = nextClickWidget(current, target);
98
178
  if (target !== null) {
@@ -108,7 +188,7 @@ const targetSites = (clicked, target) => {
108
188
  if (container === null) {
109
189
  return [site];
110
190
  }
111
- return [site, { gestures: getAuthoredClickGestures(container), point: getClickPoint(clicked, container) }];
191
+ return [site, { gestures: getAuthoredClickGestures(container, clicked), point: getClickPoint(clicked, container) }];
112
192
  };
113
193
  const isSingleClickActivating = (container) => callBooleanGetter(container, "getActivateOnSingleClick") ?? true;
114
194
  const isMultipleSelection = (container) => getCallableMethod(container, "getSelectionMode")?.() === Gtk.SelectionMode.MULTIPLE;
@@ -136,12 +216,12 @@ const applyContainerOutcome = (target, nPress) => {
136
216
  replaceContainerSelection(container, widget);
137
217
  }
138
218
  };
139
- const applyClickOutcome = (target, nPress) => {
219
+ const applyClickOutcome = (target, nPress, modifiers) => {
140
220
  if (target.native === null) {
141
221
  applyContainerOutcome(target, nPress);
142
222
  return;
143
223
  }
144
- target.native(target.widget, nPress);
224
+ target.native(target.widget, nPress, modifiers);
145
225
  };
146
226
  const applyContainerClick = (widget, nPress) => {
147
227
  const container = containerFor(widget);
@@ -152,41 +232,83 @@ const applyContainerClick = (widget, nPress) => {
152
232
  const directClickFor = (widget) => {
153
233
  const native = nativeClickFor(widget, true);
154
234
  const container = native === null ? containerFor(widget) : null;
155
- const gestures = native !== null || container !== null ? getAuthoredClickGestures(widget) : clickGestures(widget);
235
+ const gestures = native !== null || container !== null
236
+ ? getAuthoredClickGestures(widget, widget)
237
+ : clickGestures(widget, widget);
156
238
  const target = { widget, container, gestures, isClaiming: true, native };
157
239
  return { sites: targetSites(widget, target), outcome: native ?? (container === null ? null : applyContainerClick) };
158
240
  };
159
- const applyClickOutcomes = (targets, nPress) => {
241
+ const listensForButton = (gesture, button) => {
242
+ const listened = gesture.getButton();
243
+ return listened === 0 || listened === button;
244
+ };
245
+ /**
246
+ * The press sites a non-primary button reaches: the authored click gestures listening for that button on the widget
247
+ * and its ancestors that GTK runs for the press, as it propagates up the tree. Widgets react to these buttons only
248
+ * through gestures.
249
+ */
250
+ const buttonSitesFor = (widget, button) => {
251
+ const sites = [];
252
+ for (let current = widget; current !== null; current = current.getParent()) {
253
+ const owner = current;
254
+ const gestures = queryAllControllers(owner, Gtk.GestureClick).filter((gesture) => listensForButton(gesture, button) && hasClickHandlers(gesture) && runsFor(gesture, owner, widget));
255
+ if (gestures.length > 0) {
256
+ sites.push({ gestures, point: getClickPoint(widget, current) });
257
+ }
258
+ }
259
+ return sites;
260
+ };
261
+ const applyClickOutcomes = (targets, nPress, modifiers) => {
160
262
  for (const target of targets) {
161
- applyClickOutcome(target, nPress);
263
+ applyClickOutcome(target, nPress, modifiers);
162
264
  }
163
265
  };
164
- const deliverClick = (widget, nPress) => wrapEvent(widget, () => {
165
- const targets = collectClickTargets(widget);
166
- const sites = targets.flatMap((target) => targetSites(widget, target));
167
- emitClickSequence(sites, nPress);
168
- applyClickOutcomes(targets, nPress);
169
- });
266
+ /** Whether GTK's own click gesture on the widget acts without the real pointer event, as on buttons and menu items. */
267
+ const isButtonLike = (widget) => widget instanceof Gtk.Button ||
268
+ widget instanceof Gtk.CheckButton ||
269
+ getWidgetTypeName(widget) === MENU_ITEM_TYPE_NAME;
270
+ /**
271
+ * Whether a click target is known to handle the click: app code listens to its gestures, GTKX applies the outcome a
272
+ * real click has, or it is a button, check button or menu item. GTK's other gestures read the real pointer event, so
273
+ * a click that reaches only them may do nothing.
274
+ */
275
+ const isHandlingTarget = (target) => target.native !== null ||
276
+ target.container !== null ||
277
+ isButtonLike(target.widget) ||
278
+ target.gestures.some((gesture) => hasClickHandlers(gesture));
279
+ const deliverClick = async (state, widget, nPress) => {
280
+ let isHandled = false;
281
+ await wrapPointerEvent(widget, () => {
282
+ const placed = collectClickTargets(widget).map((target) => ({ target, sites: targetSites(widget, target) }));
283
+ const reached = emitClickSequence(placed.flatMap(({ sites }) => sites), nPress, state.modifierState);
284
+ const targets = placed
285
+ .filter(({ sites }) => sites.every((site) => reached.has(site)))
286
+ .map(({ target }) => target);
287
+ applyClickOutcomes(targets, nPress, state.modifierState);
288
+ isHandled = targets.some((target) => isHandlingTarget(target));
289
+ });
290
+ return isHandled;
291
+ };
170
292
  const tryActivate = async (widget) => {
171
293
  if (widget.getAccessibleRole() === Gtk.AccessibleRole.LABEL) {
172
294
  return false;
173
295
  }
174
296
  let isActivated = false;
175
- await wrapEvent(widget, () => {
297
+ await wrapPointerEvent(widget, () => {
176
298
  isActivated = Gtk.Widget.prototype.activate.call(widget);
177
299
  });
178
300
  return isActivated;
179
301
  };
180
- /** Activates or presses and releases a widget. */
181
- const click = async (widget) => {
302
+ /** Activates or presses and releases a widget, and returns whether anything is known to have handled the click. */
303
+ const click = async (state, widget) => {
182
304
  if (!isSelfClickTarget(widget) && (await tryActivate(widget))) {
183
- return;
305
+ return true;
184
306
  }
185
- await deliverClick(widget, 1);
307
+ return deliverClick(state, widget, 1);
186
308
  };
187
309
  /** Delivers a double-click gesture. */
188
- const dblClick = (widget) => deliverClick(widget, 2);
310
+ const dblClick = (state, widget) => deliverClick(state, widget, 2);
189
311
  /** Delivers a triple-click gesture. */
190
- const tripleClick = (widget) => deliverClick(widget, 3);
191
- export { directClickFor, emitSitePhase, click, dblClick, tripleClick };
312
+ const tripleClick = (state, widget) => deliverClick(state, widget, 3);
313
+ export { buttonSitesFor, directClickFor, emitSitePhase, click, dblClick, tripleClick };
192
314
  //# sourceMappingURL=click.js.map