@gtkx/testing 1.5.0 → 2.0.0-beta.1

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 (54) hide show
  1. package/README.md +5 -5
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +1 -3
  4. package/dist/config.js.map +1 -1
  5. package/dist/queries.d.ts +30 -126
  6. package/dist/queries.d.ts.map +1 -1
  7. package/dist/queries.js +30 -126
  8. package/dist/queries.js.map +1 -1
  9. package/dist/screenshot.d.ts.map +1 -1
  10. package/dist/screenshot.js +1 -3
  11. package/dist/screenshot.js.map +1 -1
  12. package/dist/user-event/adjustment.d.ts +2 -14
  13. package/dist/user-event/adjustment.d.ts.map +1 -1
  14. package/dist/user-event/adjustment.js +2 -14
  15. package/dist/user-event/adjustment.js.map +1 -1
  16. package/dist/user-event/click.d.ts +3 -41
  17. package/dist/user-event/click.d.ts.map +1 -1
  18. package/dist/user-event/click.js +3 -41
  19. package/dist/user-event/click.js.map +1 -1
  20. package/dist/user-event/gesture.d.ts +9 -43
  21. package/dist/user-event/gesture.d.ts.map +1 -1
  22. package/dist/user-event/gesture.js +9 -43
  23. package/dist/user-event/gesture.js.map +1 -1
  24. package/dist/user-event/index.d.ts +16 -85
  25. package/dist/user-event/index.d.ts.map +1 -1
  26. package/dist/user-event/index.js +1 -5
  27. package/dist/user-event/index.js.map +1 -1
  28. package/dist/user-event/keyboard.d.ts +1 -1
  29. package/dist/user-event/keyboard.d.ts.map +1 -1
  30. package/dist/user-event/keyboard.js +1 -1
  31. package/dist/user-event/keyboard.js.map +1 -1
  32. package/dist/user-event/selection.d.ts +2 -18
  33. package/dist/user-event/selection.d.ts.map +1 -1
  34. package/dist/user-event/selection.js +3 -21
  35. package/dist/user-event/selection.js.map +1 -1
  36. package/dist/user-event/text.d.ts +5 -34
  37. package/dist/user-event/text.d.ts.map +1 -1
  38. package/dist/user-event/text.js +5 -34
  39. package/dist/user-event/text.js.map +1 -1
  40. package/dist/widget-accessible-properties.d.ts.map +1 -1
  41. package/dist/widget-accessible-properties.js +14 -34
  42. package/dist/widget-accessible-properties.js.map +1 -1
  43. package/package.json +12 -8
  44. package/src/config.ts +1 -3
  45. package/src/queries.ts +30 -126
  46. package/src/screenshot.ts +1 -3
  47. package/src/user-event/adjustment.ts +2 -14
  48. package/src/user-event/click.ts +3 -41
  49. package/src/user-event/gesture.ts +9 -43
  50. package/src/user-event/index.ts +16 -85
  51. package/src/user-event/keyboard.ts +1 -1
  52. package/src/user-event/selection.ts +3 -21
  53. package/src/user-event/text.ts +5 -34
  54. package/src/widget-accessible-properties.ts +22 -44
@@ -1 +1 @@
1
- {"version":3,"file":"click.js","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACxH,OAAO,EAAE,kBAAkB,EAAoB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAezF,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC9C,MAAM,eAAe,GAAgB,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;AAEtE,MAAM,cAAc,GAAG,CAAC,MAAkB,EAAc,EAAE;IACtD,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAChC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,EAAE;QACzB,WAAW,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACvB,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,KAAK,GAAG,KAAK,EAAE,MAAkB,EAAiB,EAAE;IACtD,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QAC5D,OAAO;IACX,CAAC;IAED,MAAM,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,QAAQ,GAAG,CAAC,MAAkB,EAAiB,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAChF;;;;GAIG;AACH,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAiB,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,wBAAwB,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import * as Gdk from \"@gtkx/gi/gdk\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { hasSignalListener } from \"@gtkx/runtime/internal\";\nimport { callBooleanGetter, getCallableMethod, hasWidgetMethod } from \"../widget-getters.js\";\nimport { queryAllControllers } from \"./controller.js\";\nimport { wrapEvent } from \"./event-wrapper.js\";\nimport { hasIndexedChildren, selectContainerChild, SELECTED_PROBE, unselectOtherChildren } from \"./indexed-children.js\";\nimport { isClickTransparent, type NativeClick, nativeClickFor } from \"./native-click.js\";\n\ntype PressPoint = { x: number; y: number };\ntype ClickPhase = \"pressed\" | \"released\";\ntype ClickSite = { gestures: Gtk.GestureClick[]; point: PressPoint };\ntype ClickScope = { isClicked: boolean; isInternalAllowed: boolean };\n\ntype ClickTarget = {\n widget: Gtk.Widget;\n container: Gtk.Widget | null;\n gestures: Gtk.GestureClick[];\n isClaiming: boolean;\n native: NativeClick | null;\n};\n\nconst CLICK_SIGNALS = [\"pressed\", \"released\"];\nconst PRIMARY_BUTTONS: Set<number> = new Set([0, Gdk.BUTTON_PRIMARY]);\n\nconst getCenterPoint = (widget: Gtk.Widget): PressPoint => {\n const width = widget.getWidth();\n const height = widget.getHeight();\n\n if (width > 0 && height > 0) {\n return { x: width / 2, y: height / 2 };\n }\n\n return { x: 0, y: 0 };\n};\n\nconst getClickPoint = (clicked: Gtk.Widget, carrier: Gtk.Widget): PressPoint => {\n if (clicked === carrier) {\n return getCenterPoint(clicked);\n }\n\n const [isComputed, bounds] = clicked.computeBounds(carrier);\n\n if (!isComputed) {\n return getCenterPoint(carrier);\n }\n\n return { x: bounds.getX() + bounds.getWidth() / 2, y: bounds.getY() + bounds.getHeight() / 2 };\n};\n\nconst emitGesture = (\n point: PressPoint,\n controllers: Gtk.GestureClick[],\n nPress: number,\n signal: ClickPhase,\n): void => {\n for (const controller of controllers) {\n controller.emit(signal, nPress, point.x, point.y);\n }\n};\n\nconst emitClickPhase = (\n widget: Gtk.Widget,\n controllers: Gtk.GestureClick[],\n nPress: number,\n phase: ClickPhase,\n): void => {\n emitGesture(getCenterPoint(widget), controllers, nPress, phase);\n};\n\nconst emitSitePhase = (sites: ClickSite[], nPress: number, phase: ClickPhase): void => {\n for (const site of sites) {\n emitGesture(site.point, site.gestures, nPress, phase);\n }\n};\n\nconst emitClickSequence = (sites: ClickSite[], nPress: number): void => {\n for (let i = 1; i <= nPress; i++) {\n emitSitePhase(sites, i, \"pressed\");\n emitSitePhase(sites, i, \"released\");\n }\n};\n\nconst containerFor = (widget: Gtk.Widget): Gtk.Widget | null => {\n const parent = widget.getParent();\n\n return parent !== null && hasWidgetMethod(widget, SELECTED_PROBE) && hasIndexedChildren(parent) ? parent : null;\n};\n\nconst hasClickHandlers = (gesture: Gtk.GestureClick): boolean => hasSignalListener(gesture, CLICK_SIGNALS);\nconst isInternalGesture = (gesture: Gtk.GestureClick): boolean => !hasSignalListener(gesture);\nconst isPrimaryGesture = (gesture: Gtk.GestureClick): boolean => PRIMARY_BUTTONS.has(gesture.getButton());\n\nconst clickGestures = (widget: Gtk.Widget): Gtk.GestureClick[] =>\n queryAllControllers(widget, Gtk.GestureClick).filter((gesture) => isPrimaryGesture(gesture));\n\nconst getAuthoredClickGestures = (widget: Gtk.Widget): Gtk.GestureClick[] =>\n clickGestures(widget).filter((gesture) => hasClickHandlers(gesture));\n\nconst isClaimingTarget = (widget: Gtk.Widget): boolean =>\n widget instanceof Gtk.Button || containerFor(widget) !== null;\n\nconst gestureTargetFor = (widget: Gtk.Widget, isInternalAllowed: boolean): ClickTarget | null => {\n const gestures = clickGestures(widget);\n\n if (isClaimingTarget(widget)) {\n return { widget, container: containerFor(widget), gestures, isClaiming: true, native: null };\n }\n\n const authored = gestures.filter((gesture) => hasClickHandlers(gesture));\n\n if (authored.length > 0) {\n return { widget, container: null, gestures: authored, isClaiming: false, native: null };\n }\n\n if (isInternalAllowed && gestures.some((gesture) => isInternalGesture(gesture))) {\n return { widget, container: null, gestures, isClaiming: true, native: null };\n }\n\n return null;\n};\n\nconst clickTargetFor = (widget: Gtk.Widget, scope: ClickScope): ClickTarget | null => {\n if (isClickTransparent(widget)) {\n return null;\n }\n\n const native = nativeClickFor(widget, scope.isClicked);\n\n if (native !== null) {\n return { widget, container: null, gestures: getAuthoredClickGestures(widget), isClaiming: true, native };\n }\n\n return gestureTargetFor(widget, scope.isInternalAllowed);\n};\n\nconst isSelfClickTarget = (widget: Gtk.Widget): boolean =>\n isClickTransparent(widget) || clickTargetFor(widget, { isClicked: true, isInternalAllowed: false }) !== null;\n\nconst nextClickWidget = (current: Gtk.Widget, target: ClickTarget | null): Gtk.Widget | null =>\n target?.isClaiming === true ? null : current.getParent();\n\nconst collectClickTargets = (widget: Gtk.Widget): ClickTarget[] => {\n const targets: ClickTarget[] = [];\n let current: Gtk.Widget | null = widget;\n\n while (current !== null) {\n const isClicked = current === widget;\n const scope = { isClicked, isInternalAllowed: !isClicked && targets.length === 0 };\n const target = clickTargetFor(current, scope);\n const next = nextClickWidget(current, target);\n\n if (target !== null) {\n targets.push(target);\n }\n\n current = next;\n }\n\n return targets;\n};\n\nconst targetSites = (clicked: Gtk.Widget, target: ClickTarget): ClickSite[] => {\n const { container } = target;\n const site = { gestures: target.gestures, point: getClickPoint(clicked, target.widget) };\n\n if (container === null) {\n return [site];\n }\n\n return [site, { gestures: getAuthoredClickGestures(container), point: getClickPoint(clicked, container) }];\n};\n\nconst isSingleClickActivating = (container: Gtk.Widget): boolean =>\n callBooleanGetter(container, \"getActivateOnSingleClick\") ?? true;\n\nconst isMultipleSelection = (container: Gtk.Widget): boolean =>\n getCallableMethod<[], Gtk.SelectionMode>(container, \"getSelectionMode\")?.() === Gtk.SelectionMode.MULTIPLE;\n\nconst isChildSelectable = (child: Gtk.Widget): boolean => callBooleanGetter(child, \"getSelectable\") ?? true;\n\nconst replaceContainerSelection = (container: Gtk.Widget, child: Gtk.Widget): void => {\n if (!isChildSelectable(child)) {\n return;\n }\n\n selectContainerChild(container, child);\n\n if (isMultipleSelection(container)) {\n unselectOtherChildren(container, child);\n }\n};\n\nconst isActivatedByClick = (container: Gtk.Widget, nPress: number): boolean =>\n isSingleClickActivating(container) || nPress > 1;\n\nconst isSelectionReplacedByClick = (container: Gtk.Widget, nPress: number): boolean =>\n nPress > 1 || !isSingleClickActivating(container);\n\nconst applyContainerOutcome = (target: ClickTarget, nPress: number): void => {\n const { container, widget } = target;\n\n if (container === null || widget.getParent() !== container) {\n return;\n }\n\n if (isActivatedByClick(container, nPress)) {\n widget.activate();\n }\n\n if (isSelectionReplacedByClick(container, nPress)) {\n replaceContainerSelection(container, widget);\n }\n};\n\nconst applyClickOutcome = (target: ClickTarget, nPress: number): void => {\n if (target.native === null) {\n applyContainerOutcome(target, nPress);\n\n return;\n }\n\n target.native(target.widget, nPress);\n};\n\nconst applyClickOutcomes = (targets: ClickTarget[], nPress: number): void => {\n for (const target of targets) {\n applyClickOutcome(target, nPress);\n }\n};\n\nconst deliverClick = (widget: Gtk.Widget, nPress: number): Promise<void> =>\n wrapEvent(widget, () => {\n const targets = collectClickTargets(widget);\n const sites = targets.flatMap((target) => targetSites(widget, target));\n emitClickSequence(sites, nPress);\n applyClickOutcomes(targets, nPress);\n });\n\n/* eslint-disable-next-line unicorn/consistent-boolean-name -- the boolean reports whether activation succeeded */\nconst tryActivate = async (widget: Gtk.Widget): Promise<boolean> => {\n if (widget.getAccessibleRole() === Gtk.AccessibleRole.LABEL) {\n return false;\n }\n\n let isActivated = false;\n\n await wrapEvent(widget, () => {\n isActivated = widget.activate();\n });\n\n return isActivated;\n};\n\n/**\n * Activates a widget that neither claims the click nor carries a click gesture of its own, and\n * otherwise delivers a press and release. The press travels outwards from the clicked widget\n * through every widget carrying a click gesture with a pressed or released handler, the way GTK\n * hands the same press to each of them, and stops at the first Gtk.Button or indexed child of a\n * list box or flow box, which claims it. A gesture GTK attached itself takes the press only when no\n * widget below it handles one, and stops it there, so an expander or a notebook tab nested in a row\n * opens instead of activating the row. Coordinates are the clicked widget's position in each\n * carrier, so a gesture the container of an indexed child carries reads the child's position rather\n * than the container's center. An indexed child that the press reaches is then activated, or\n * exclusively selected when its container does not activate on a single click. A widget with the\n * label role is never activated, but does consume the click when it carries a gesture of its own.\n *\n * The press also stops at a widget whose click GTK4 implements in C on a gesture it attached\n * itself, reading a GdkEvent that off-screen synthesis cannot produce. Gestures that widget carries\n * of its own still take the press and release, the way GTK hands them the press before its own\n * gesture claims it, and the same outcome is then applied through the public action GTK's own\n * handler invokes: a list, grid, or column-view row is focused and selected, and activated as well\n * on a second press or when its view activates on a single click; an expandable tree expander\n * toggles its expansion, once per press, and only when it is the widget clicked, so a click on its\n * child falls through to the enclosing row; a notebook tab, clicked directly or through its label,\n * focuses its notebook and switches to its page; a column header sorts by its column. Sorting goes\n * through Gtk.ColumnView.sortByColumn, so the primary sort column and order match what a pointer\n * produces while previously sorted columns are dropped rather than kept as secondary keys. A\n * column-view cell and the row that carries the column headers stand in the way of the click rather\n * than taking it, so a click on either reaches the row or the view behind it.\n */\nconst click = async (widget: Gtk.Widget): Promise<void> => {\n if (!isSelfClickTarget(widget) && (await tryActivate(widget))) {\n return;\n }\n\n await deliverClick(widget, 1);\n};\n\n/**\n * Delivers a two-press click gesture the way {@link click} delivers a single press, without trying\n * activation first. A list box row or flow box child the presses reach, clicked directly or through\n * a descendant, is activated and exclusively selected, as GTK's double-click path does whether or\n * not the container activates on a single click. A widget whose click GTK4 implements itself\n * receives that outcome once per press, so a list, grid, or column-view row is selected and then\n * activated by the second press, a tree expander ends back where it started, a notebook tab stays on\n * the page the first press opened, and a column header sorts and then inverts its order.\n */\nconst dblClick = (widget: Gtk.Widget): Promise<void> => deliverClick(widget, 2);\n/**\n * Delivers a three-press click gesture the same way a double click is delivered, applying the same\n * outcome to a list box row or flow box child the presses reach, and applying the outcome GTK4\n * implements itself once per press to a row, tree expander, notebook tab, or column header.\n */\nconst tripleClick = (widget: Gtk.Widget): Promise<void> => deliverClick(widget, 3);\n\nexport { clickGestures, emitClickPhase, getAuthoredClickGestures, click, dblClick, tripleClick };\n"]}
1
+ {"version":3,"file":"click.js","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,cAA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C,KAAK,EAAE,MAAM,CAAC,CAAC;IACjC,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC,CAAC,CAAC;AAEP,kHAAkH;AAClH,MAAM,WAAW,GAAG,KAAK,EAAE,MAAkB,EAAoB,EAAE;IAC/D,IAAI,MAAM,CAAC,iBAAiB,EAAE,KAAK,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC1D,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,MAAM,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE;QACzB,WAAW,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACvB,CAAC,CAAC;AAEF,kDAAkD;AAClD,MAAM,KAAK,GAAG,KAAK,EAAE,MAAkB,EAAiB,EAAE;IACtD,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QAC5D,OAAO;IACX,CAAC;IAED,MAAM,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF,uCAAuC;AACvC,MAAM,QAAQ,GAAG,CAAC,MAAkB,EAAiB,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAChF,uCAAuC;AACvC,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAiB,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,wBAAwB,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import * as Gdk from \"@gtkx/gi/gdk\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { hasSignalListener } from \"@gtkx/runtime/internal\";\nimport { callBooleanGetter, getCallableMethod, hasWidgetMethod } from \"../widget-getters.js\";\nimport { queryAllControllers } from \"./controller.js\";\nimport { wrapEvent } from \"./event-wrapper.js\";\nimport { hasIndexedChildren, selectContainerChild, SELECTED_PROBE, unselectOtherChildren } from \"./indexed-children.js\";\nimport { isClickTransparent, type NativeClick, nativeClickFor } from \"./native-click.js\";\n\ntype PressPoint = { x: number; y: number };\ntype ClickPhase = \"pressed\" | \"released\";\ntype ClickSite = { gestures: Gtk.GestureClick[]; point: PressPoint };\ntype ClickScope = { isClicked: boolean; isInternalAllowed: boolean };\n\ntype ClickTarget = {\n widget: Gtk.Widget;\n container: Gtk.Widget | null;\n gestures: Gtk.GestureClick[];\n isClaiming: boolean;\n native: NativeClick | null;\n};\n\nconst CLICK_SIGNALS = [\"pressed\", \"released\"];\nconst PRIMARY_BUTTONS: Set<number> = new Set([0, Gdk.BUTTON_PRIMARY]);\n\nconst getCenterPoint = (widget: Gtk.Widget): PressPoint => {\n const width = widget.getWidth();\n const height = widget.getHeight();\n\n if (width > 0 && height > 0) {\n return { x: width / 2, y: height / 2 };\n }\n\n return { x: 0, y: 0 };\n};\n\nconst getClickPoint = (clicked: Gtk.Widget, carrier: Gtk.Widget): PressPoint => {\n if (clicked === carrier) {\n return getCenterPoint(clicked);\n }\n\n const [isComputed, bounds] = clicked.computeBounds(carrier);\n\n if (!isComputed) {\n return getCenterPoint(carrier);\n }\n\n return { x: bounds.getX() + bounds.getWidth() / 2, y: bounds.getY() + bounds.getHeight() / 2 };\n};\n\nconst emitGesture = (\n point: PressPoint,\n controllers: Gtk.GestureClick[],\n nPress: number,\n signal: ClickPhase,\n): void => {\n for (const controller of controllers) {\n controller.emit(signal, nPress, point.x, point.y);\n }\n};\n\nconst emitClickPhase = (\n widget: Gtk.Widget,\n controllers: Gtk.GestureClick[],\n nPress: number,\n phase: ClickPhase,\n): void => {\n emitGesture(getCenterPoint(widget), controllers, nPress, phase);\n};\n\nconst emitSitePhase = (sites: ClickSite[], nPress: number, phase: ClickPhase): void => {\n for (const site of sites) {\n emitGesture(site.point, site.gestures, nPress, phase);\n }\n};\n\nconst emitClickSequence = (sites: ClickSite[], nPress: number): void => {\n for (let i = 1; i <= nPress; i++) {\n emitSitePhase(sites, i, \"pressed\");\n emitSitePhase(sites, i, \"released\");\n }\n};\n\nconst containerFor = (widget: Gtk.Widget): Gtk.Widget | null => {\n const parent = widget.getParent();\n\n return parent !== null && hasWidgetMethod(widget, SELECTED_PROBE) && hasIndexedChildren(parent) ? parent : null;\n};\n\nconst hasClickHandlers = (gesture: Gtk.GestureClick): boolean => hasSignalListener(gesture, CLICK_SIGNALS);\nconst isInternalGesture = (gesture: Gtk.GestureClick): boolean => !hasSignalListener(gesture);\nconst isPrimaryGesture = (gesture: Gtk.GestureClick): boolean => PRIMARY_BUTTONS.has(gesture.getButton());\n\nconst clickGestures = (widget: Gtk.Widget): Gtk.GestureClick[] =>\n queryAllControllers(widget, Gtk.GestureClick).filter((gesture) => isPrimaryGesture(gesture));\n\nconst getAuthoredClickGestures = (widget: Gtk.Widget): Gtk.GestureClick[] =>\n clickGestures(widget).filter((gesture) => hasClickHandlers(gesture));\n\nconst isClaimingTarget = (widget: Gtk.Widget): boolean =>\n widget instanceof Gtk.Button || containerFor(widget) !== null;\n\nconst gestureTargetFor = (widget: Gtk.Widget, isInternalAllowed: boolean): ClickTarget | null => {\n const gestures = clickGestures(widget);\n\n if (isClaimingTarget(widget)) {\n return { widget, container: containerFor(widget), gestures, isClaiming: true, native: null };\n }\n\n const authored = gestures.filter((gesture) => hasClickHandlers(gesture));\n\n if (authored.length > 0) {\n return { widget, container: null, gestures: authored, isClaiming: false, native: null };\n }\n\n if (isInternalAllowed && gestures.some((gesture) => isInternalGesture(gesture))) {\n return { widget, container: null, gestures, isClaiming: true, native: null };\n }\n\n return null;\n};\n\nconst clickTargetFor = (widget: Gtk.Widget, scope: ClickScope): ClickTarget | null => {\n if (isClickTransparent(widget)) {\n return null;\n }\n\n const native = nativeClickFor(widget, scope.isClicked);\n\n if (native !== null) {\n return { widget, container: null, gestures: getAuthoredClickGestures(widget), isClaiming: true, native };\n }\n\n return gestureTargetFor(widget, scope.isInternalAllowed);\n};\n\nconst isSelfClickTarget = (widget: Gtk.Widget): boolean =>\n isClickTransparent(widget) || clickTargetFor(widget, { isClicked: true, isInternalAllowed: false }) !== null;\n\nconst nextClickWidget = (current: Gtk.Widget, target: ClickTarget | null): Gtk.Widget | null =>\n target?.isClaiming === true ? null : current.getParent();\n\nconst collectClickTargets = (widget: Gtk.Widget): ClickTarget[] => {\n const targets: ClickTarget[] = [];\n let current: Gtk.Widget | null = widget;\n\n while (current !== null) {\n const isClicked = current === widget;\n const scope = { isClicked, isInternalAllowed: !isClicked && targets.length === 0 };\n const target = clickTargetFor(current, scope);\n const next = nextClickWidget(current, target);\n\n if (target !== null) {\n targets.push(target);\n }\n\n current = next;\n }\n\n return targets;\n};\n\nconst targetSites = (clicked: Gtk.Widget, target: ClickTarget): ClickSite[] => {\n const { container } = target;\n const site = { gestures: target.gestures, point: getClickPoint(clicked, target.widget) };\n\n if (container === null) {\n return [site];\n }\n\n return [site, { gestures: getAuthoredClickGestures(container), point: getClickPoint(clicked, container) }];\n};\n\nconst isSingleClickActivating = (container: Gtk.Widget): boolean =>\n callBooleanGetter(container, \"getActivateOnSingleClick\") ?? true;\n\nconst isMultipleSelection = (container: Gtk.Widget): boolean =>\n getCallableMethod<[], Gtk.SelectionMode>(container, \"getSelectionMode\")?.() === Gtk.SelectionMode.MULTIPLE;\n\nconst isChildSelectable = (child: Gtk.Widget): boolean => callBooleanGetter(child, \"getSelectable\") ?? true;\n\nconst replaceContainerSelection = (container: Gtk.Widget, child: Gtk.Widget): void => {\n if (!isChildSelectable(child)) {\n return;\n }\n\n selectContainerChild(container, child);\n\n if (isMultipleSelection(container)) {\n unselectOtherChildren(container, child);\n }\n};\n\nconst isActivatedByClick = (container: Gtk.Widget, nPress: number): boolean =>\n isSingleClickActivating(container) || nPress > 1;\n\nconst isSelectionReplacedByClick = (container: Gtk.Widget, nPress: number): boolean =>\n nPress > 1 || !isSingleClickActivating(container);\n\nconst applyContainerOutcome = (target: ClickTarget, nPress: number): void => {\n const { container, widget } = target;\n\n if (container === null || widget.getParent() !== container) {\n return;\n }\n\n if (isActivatedByClick(container, nPress)) {\n widget.activate();\n }\n\n if (isSelectionReplacedByClick(container, nPress)) {\n replaceContainerSelection(container, widget);\n }\n};\n\nconst applyClickOutcome = (target: ClickTarget, nPress: number): void => {\n if (target.native === null) {\n applyContainerOutcome(target, nPress);\n\n return;\n }\n\n target.native(target.widget, nPress);\n};\n\nconst applyClickOutcomes = (targets: ClickTarget[], nPress: number): void => {\n for (const target of targets) {\n applyClickOutcome(target, nPress);\n }\n};\n\nconst deliverClick = (widget: Gtk.Widget, nPress: number): Promise<void> =>\n wrapEvent(widget, () => {\n const targets = collectClickTargets(widget);\n const sites = targets.flatMap((target) => targetSites(widget, target));\n emitClickSequence(sites, nPress);\n applyClickOutcomes(targets, nPress);\n });\n\n/* eslint-disable-next-line unicorn/consistent-boolean-name -- the boolean reports whether activation succeeded */\nconst tryActivate = async (widget: Gtk.Widget): Promise<boolean> => {\n if (widget.getAccessibleRole() === Gtk.AccessibleRole.LABEL) {\n return false;\n }\n\n let isActivated = false;\n\n await wrapEvent(widget, () => {\n isActivated = widget.activate();\n });\n\n return isActivated;\n};\n\n/** Activates or presses and releases a widget. */\nconst click = async (widget: Gtk.Widget): Promise<void> => {\n if (!isSelfClickTarget(widget) && (await tryActivate(widget))) {\n return;\n }\n\n await deliverClick(widget, 1);\n};\n\n/** Delivers a double-click gesture. */\nconst dblClick = (widget: Gtk.Widget): Promise<void> => deliverClick(widget, 2);\n/** Delivers a triple-click gesture. */\nconst tripleClick = (widget: Gtk.Widget): Promise<void> => deliverClick(widget, 3);\n\nexport { clickGestures, emitClickPhase, getAuthoredClickGestures, click, dblClick, tripleClick };\n"]}
@@ -30,57 +30,23 @@ type DragOptions = {
30
30
  /** Explicit intermediate offsets emitted before the requested one, used instead of `steps`. */
31
31
  offsets?: DragOffset[];
32
32
  };
33
- /** Emits `enter` at the widget's origin on its motion controllers, adding one when it has none. */
33
+ /** Enters a widget. */
34
34
  declare const hover: (widget: Gtk.Widget) => Promise<void>;
35
- /** Emits `leave` on the widget's motion controllers, adding one when it has none. */
35
+ /** Leaves a widget. */
36
36
  declare const unhover: (widget: Gtk.Widget) => Promise<void>;
37
- /**
38
- * Emits `angle-changed` on the widget's rotate gestures.
39
- *
40
- * @param angle Current angle, in radians.
41
- * @param deltaAngle Difference from the angle the gesture started at; defaults to `angle`.
42
- * @throws When the widget has no Gtk.GestureRotate.
43
- */
37
+ /** Rotates a widget's gestures. */
44
38
  declare const rotate: (widget: Gtk.Widget, angle: number, deltaAngle?: number) => Promise<void>;
45
- /**
46
- * Emits `scale-changed` with the given scale delta on the widget's zoom gestures.
47
- *
48
- * @throws When the widget has no Gtk.GestureZoom.
49
- */
39
+ /** Zooms a widget's gestures. */
50
40
  declare const zoom: (widget: Gtk.Widget, scale: number) => Promise<void>;
51
- /**
52
- * Emits `swipe` with the given per-axis velocity, in pixels per second, on the widget's swipe gestures.
53
- *
54
- * @throws When the widget has no Gtk.GestureSwipe.
55
- */
41
+ /** Swipes a widget's gestures. */
56
42
  declare const swipe: (widget: Gtk.Widget, velocityX: number, velocityY: number) => Promise<void>;
57
- /**
58
- * Emits `pressed` at the given point in widget coordinates on the widget's long-press gestures.
59
- *
60
- * @throws When the widget has no Gtk.GestureLongPress.
61
- */
43
+ /** Long-presses a widget. */
62
44
  declare const longPress: (widget: Gtk.Widget, x?: number, y?: number) => Promise<void>;
63
- /**
64
- * Runs a `drag-begin`, `drag-update`, `drag-end` sequence ending at the offset `dx`, `dy` on the
65
- * widget's drag gestures, overriding each gesture's start point and offset for the duration so
66
- * handlers read the simulated values back.
67
- *
68
- * @throws When the widget is a Gtk.Range, whose slider reads pointer coordinates from the display,
69
- * or when it has no Gtk.GestureDrag.
70
- */
45
+ /** Drags a widget by an offset. */
71
46
  declare const drag: (widget: Gtk.Widget, dx: number, dy: number, options?: DragOptions) => Promise<void>;
72
- /**
73
- * Emits `drop` with the given content on every drop target attached to the widget.
74
- *
75
- * @throws When the widget has no Gtk.DropTarget.
76
- */
47
+ /** Drops content on a widget. */
77
48
  declare const drop: (widget: Gtk.Widget, content: DropContent, options?: DropOptions) => Promise<void>;
78
- /**
79
- * Emits `drop` with the given content on the target's drop targets, after checking that the source
80
- * carries a drag source.
81
- *
82
- * @throws When the source has no Gtk.DragSource, or the target no Gtk.DropTarget.
83
- */
49
+ /** Drags content from one widget and drops it on another. */
84
50
  declare const dragAndDrop: (source: Gtk.Widget, target: Gtk.Widget, content: DropContent, options?: DropOptions) => Promise<void>;
85
51
  export { hover, unhover, rotate, zoom, swipe, longPress, drag, drop, dragAndDrop, type DropContent, type DropOptions, type DragOffset, type DragOptions, };
86
52
  //# sourceMappingURL=gesture.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gesture.d.ts","sourceRoot":"","sources":["../../src/user-event/gesture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAKpC,qHAAqH;AACrH,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC;AAE7D,kEAAkE;AAClE,KAAK,WAAW,GAAG;IACf,+DAA+D;IAC/D,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,6DAA6D;IAC7D,CAAC,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAIF,sDAAsD;AACtD,KAAK,UAAU,GAAG;IACd,gEAAgE;IAChE,CAAC,EAAE,MAAM,CAAC;IACV,8DAA8D;IAC9D,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;GAGG;AACH,KAAK,WAAW,GAAG;IACf,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D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EACN,IAAI,EACJ,KAAK,EACL,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,GACnB,CAAC"}
@@ -27,45 +27,27 @@ const buildDropValue = (content) => {
27
27
  v.setDouble(content);
28
28
  });
29
29
  };
30
- /** Emits `enter` at the widget's origin on its motion controllers, adding one when it has none. */
30
+ /** Enters a widget. */
31
31
  const hover = (widget) => dispatchOnOrCreateControllers(widget, Gtk.EventControllerMotion, (controller) => {
32
32
  controller.emit("enter", 0, 0);
33
33
  });
34
- /** Emits `leave` on the widget's motion controllers, adding one when it has none. */
34
+ /** Leaves a widget. */
35
35
  const unhover = (widget) => dispatchOnOrCreateControllers(widget, Gtk.EventControllerMotion, (controller) => {
36
36
  controller.emit("leave");
37
37
  });
38
- /**
39
- * Emits `angle-changed` on the widget's rotate gestures.
40
- *
41
- * @param angle Current angle, in radians.
42
- * @param deltaAngle Difference from the angle the gesture started at; defaults to `angle`.
43
- * @throws When the widget has no Gtk.GestureRotate.
44
- */
38
+ /** Rotates a widget's gestures. */
45
39
  const rotate = (widget, angle, deltaAngle = angle) => dispatchOnControllers(widget, Gtk.GestureRotate, (controller) => {
46
40
  controller.emit("angle-changed", angle, deltaAngle);
47
41
  });
48
- /**
49
- * Emits `scale-changed` with the given scale delta on the widget's zoom gestures.
50
- *
51
- * @throws When the widget has no Gtk.GestureZoom.
52
- */
42
+ /** Zooms a widget's gestures. */
53
43
  const zoom = (widget, scale) => dispatchOnControllers(widget, Gtk.GestureZoom, (controller) => {
54
44
  controller.emit("scale-changed", scale);
55
45
  });
56
- /**
57
- * Emits `swipe` with the given per-axis velocity, in pixels per second, on the widget's swipe gestures.
58
- *
59
- * @throws When the widget has no Gtk.GestureSwipe.
60
- */
46
+ /** Swipes a widget's gestures. */
61
47
  const swipe = (widget, velocityX, velocityY) => dispatchOnControllers(widget, Gtk.GestureSwipe, (controller) => {
62
48
  controller.emit("swipe", velocityX, velocityY);
63
49
  });
64
- /**
65
- * Emits `pressed` at the given point in widget coordinates on the widget's long-press gestures.
66
- *
67
- * @throws When the widget has no Gtk.GestureLongPress.
68
- */
50
+ /** Long-presses a widget. */
69
51
  const longPress = (widget, x = 0, y = 0) => dispatchOnControllers(widget, Gtk.GestureLongPress, (controller) => {
70
52
  controller.emit("pressed", x, y);
71
53
  });
@@ -135,14 +117,7 @@ const resolveDragUpdates = (dx, dy, options) => {
135
117
  }
136
118
  return updates;
137
119
  };
138
- /**
139
- * Runs a `drag-begin`, `drag-update`, `drag-end` sequence ending at the offset `dx`, `dy` on the
140
- * widget's drag gestures, overriding each gesture's start point and offset for the duration so
141
- * handlers read the simulated values back.
142
- *
143
- * @throws When the widget is a Gtk.Range, whose slider reads pointer coordinates from the display,
144
- * or when it has no Gtk.GestureDrag.
145
- */
120
+ /** Drags a widget by an offset. */
146
121
  const drag = async (widget, dx, dy, options = {}) => {
147
122
  if (widget instanceof Gtk.Range) {
148
123
  throw new TypeError("userEvent.drag cannot drive a Gtk.Range's built-in slider " +
@@ -161,20 +136,11 @@ const emitDrop = (target, content, options) => {
161
136
  dropTarget.emit("drop", buildDropValue(content), options.x ?? 0, options.y ?? 0);
162
137
  }
163
138
  };
164
- /**
165
- * Emits `drop` with the given content on every drop target attached to the widget.
166
- *
167
- * @throws When the widget has no Gtk.DropTarget.
168
- */
139
+ /** Drops content on a widget. */
169
140
  const drop = (widget, content, options = {}) => wrapEvent(widget, () => {
170
141
  emitDrop(widget, content, options);
171
142
  });
172
- /**
173
- * Emits `drop` with the given content on the target's drop targets, after checking that the source
174
- * carries a drag source.
175
- *
176
- * @throws When the source has no Gtk.DragSource, or the target no Gtk.DropTarget.
177
- */
143
+ /** Drags content from one widget and drops it on another. */
178
144
  const dragAndDrop = async (source, target, content, options = {}) => {
179
145
  await wrapEvent(source, () => {
180
146
  getAllControllers(source, Gtk.DragSource);
@@ -1 +1 @@
1
- {"version":3,"file":"gesture.js","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E,GAAG,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,MAAM,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE;QACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EACH,KAAK,EACL,OAAO,EACP,MAAM,EACN,IAAI,EACJ,KAAK,EACL,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,WAAW,GAKd,CAAC","sourcesContent":["import * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { getAllControllers } from \"./controller.js\";\nimport { dispatchOnControllers, dispatchOnOrCreateControllers } from \"./dispatch.js\";\nimport { wrapEvent } from \"./event-wrapper.js\";\n\n/** The value delivered to a drop target: a primitive (converted to a GObject.Value) or an explicit GObject.Value. */\ntype DropContent = string | number | boolean | GObject.Value;\n\n/** Options for a drop: the drop coordinates within the target. */\ntype DropOptions = {\n /** Horizontal drop coordinate within the target, in pixels. */\n x?: number;\n /** Vertical drop coordinate within the target, in pixels. */\n y?: number;\n};\n\ntype DragPhase = \"drag-begin\" | \"drag-update\" | \"drag-end\";\n\n/** A drag offset relative to the drag start point. */\ntype DragOffset = {\n /** Horizontal distance from the drag start point, in pixels. */\n x: number;\n /** Vertical distance from the drag start point, in pixels. */\n y: number;\n};\n\n/**\n * Options for a drag gesture: the starting point, the number of interpolated drag updates, or\n * explicit intermediate offsets emitted before the final one.\n */\ntype DragOptions = {\n /** Horizontal coordinate the drag begins at; defaults to 0. */\n startX?: number;\n /** Vertical coordinate the drag begins at; defaults to 0. */\n startY?: number;\n /** Number of evenly interpolated drag updates, the last of which is the requested offset; defaults to 2. */\n steps?: number;\n /** Explicit intermediate offsets emitted before the requested one, used instead of `steps`. */\n offsets?: DragOffset[];\n};\n\ntype DragInstancePatch = {\n getStartPoint?: Gtk.GestureDrag[\"getStartPoint\"] | undefined;\n getOffset?: Gtk.GestureDrag[\"getOffset\"] | undefined;\n};\n\ntype SavedDragState = {\n instance: DragInstancePatch;\n hasOwnStartPoint: boolean;\n hasOwnOffset: boolean;\n previousStartPoint: DragInstancePatch[\"getStartPoint\"];\n previousOffset: DragInstancePatch[\"getOffset\"];\n};\n\nconst initValue = (gtype: GObject.Type, populate: (value: GObject.Value) => void): GObject.Value => {\n const value = new GObject.Value();\n value.init(gtype);\n populate(value);\n\n return value;\n};\n\nconst buildDropValue = (content: DropContent): GObject.Value => {\n if (content instanceof GObject.Value) {\n return content;\n }\n\n if (typeof content === \"string\") {\n return initValue(GObject.TYPE_STRING, (v) => {\n v.setString(content);\n });\n }\n\n if (typeof content === \"boolean\") {\n return initValue(GObject.TYPE_BOOLEAN, (v) => {\n v.setBoolean(content);\n });\n }\n\n return initValue(GObject.TYPE_DOUBLE, (v) => {\n v.setDouble(content);\n });\n};\n\n/** Emits `enter` at the widget's origin on its motion controllers, adding one when it has none. */\nconst hover = (widget: Gtk.Widget): Promise<void> =>\n dispatchOnOrCreateControllers(widget, Gtk.EventControllerMotion, (controller) => {\n controller.emit(\"enter\", 0, 0);\n });\n\n/** Emits `leave` on the widget's motion controllers, adding one when it has none. */\nconst unhover = (widget: Gtk.Widget): Promise<void> =>\n dispatchOnOrCreateControllers(widget, Gtk.EventControllerMotion, (controller) => {\n controller.emit(\"leave\");\n });\n\n/**\n * Emits `angle-changed` on the widget's rotate gestures.\n *\n * @param angle Current angle, in radians.\n * @param deltaAngle Difference from the angle the gesture started at; defaults to `angle`.\n * @throws When the widget has no Gtk.GestureRotate.\n */\nconst rotate = (widget: Gtk.Widget, angle: number, deltaAngle: number = angle): Promise<void> =>\n dispatchOnControllers(widget, Gtk.GestureRotate, (controller) => {\n controller.emit(\"angle-changed\", angle, deltaAngle);\n },\n );\n\n/**\n * Emits `scale-changed` with the given scale delta on the widget's zoom gestures.\n *\n * @throws When the widget has no Gtk.GestureZoom.\n */\nconst zoom = (widget: Gtk.Widget, scale: number): Promise<void> =>\n dispatchOnControllers(widget, Gtk.GestureZoom, (controller) => {\n controller.emit(\"scale-changed\", scale);\n });\n\n/**\n * Emits `swipe` with the given per-axis velocity, in pixels per second, on the widget's swipe gestures.\n *\n * @throws When the widget has no Gtk.GestureSwipe.\n */\nconst swipe = (widget: Gtk.Widget, velocityX: number, velocityY: number): Promise<void> =>\n dispatchOnControllers(widget, Gtk.GestureSwipe, (controller) => {\n controller.emit(\"swipe\", velocityX, velocityY);\n });\n\n/**\n * Emits `pressed` at the given point in widget coordinates on the widget's long-press gestures.\n *\n * @throws When the widget has no Gtk.GestureLongPress.\n */\nconst longPress = (widget: Gtk.Widget, x = 0, y = 0): Promise<void> =>\n dispatchOnControllers(widget, Gtk.GestureLongPress, (controller) => {\n controller.emit(\"pressed\", x, y);\n });\n\nconst restoreDragState = (saved: SavedDragState): void => {\n const { instance } = saved;\n\n if (saved.hasOwnStartPoint) {\n instance.getStartPoint = saved.previousStartPoint;\n } else {\n delete instance.getStartPoint;\n }\n\n if (saved.hasOwnOffset) {\n instance.getOffset = saved.previousOffset;\n } else {\n delete instance.getOffset;\n }\n};\n\nconst patchDragState = (controller: Gtk.GestureDrag, start: DragOffset, offset: () => DragOffset): (() => void) => {\n const instance: DragInstancePatch = controller;\n\n const saved: SavedDragState = {\n instance,\n hasOwnStartPoint: Object.hasOwn(instance, \"getStartPoint\"),\n hasOwnOffset: Object.hasOwn(instance, \"getOffset\"),\n previousStartPoint: instance.getStartPoint,\n previousOffset: instance.getOffset,\n };\n\n instance.getStartPoint = () => [true, start.x, start.y];\n\n instance.getOffset = () => {\n const current = offset();\n\n return [true, current.x, current.y];\n };\n\n return () => {\n restoreDragState(saved);\n };\n};\n\nconst emitToControllers = (controllers: Gtk.GestureDrag[], signal: DragPhase, x: number, y: number): void => {\n for (const controller of controllers) {\n controller.emit(signal, x, y);\n }\n};\n\nconst runDragSequence = (controllers: Gtk.GestureDrag[], start: DragOffset, updates: DragOffset[]): void => {\n let current: DragOffset = { x: 0, y: 0 };\n const restores = controllers.map((controller) => patchDragState(controller, start, () => current));\n\n try {\n emitToControllers(controllers, \"drag-begin\", start.x, start.y);\n\n for (const update of updates) {\n current = update;\n emitToControllers(controllers, \"drag-update\", update.x, update.y);\n }\n\n emitToControllers(controllers, \"drag-end\", current.x, current.y);\n } finally {\n for (const restore of restores) {\n restore();\n }\n }\n};\n\nconst resolveDragUpdates = (dx: number, dy: number, options: DragOptions): DragOffset[] => {\n if (options.offsets) {\n return [...options.offsets, { x: dx, y: dy }];\n }\n\n const steps = Math.max(1, Math.floor(options.steps ?? 2));\n const updates: DragOffset[] = [];\n\n for (let i = 1; i <= steps; i++) {\n updates.push({ x: (dx * i) / steps, y: (dy * i) / steps });\n }\n\n return updates;\n};\n\n/**\n * Runs a `drag-begin`, `drag-update`, `drag-end` sequence ending at the offset `dx`, `dy` on the\n * widget's drag gestures, overriding each gesture's start point and offset for the duration so\n * handlers read the simulated values back.\n *\n * @throws When the widget is a Gtk.Range, whose slider reads pointer coordinates from the display,\n * or when it has no Gtk.GestureDrag.\n */\nconst drag = async (widget: Gtk.Widget, dx: number, dy: number, options: DragOptions = {}): Promise<void> => {\n if (widget instanceof Gtk.Range) {\n throw new TypeError(\n \"userEvent.drag cannot drive a Gtk.Range's built-in slider \" +\n \"(its drag reads pointer coordinates from the display); \" +\n \"use userEvent.slide(range, value) or userEvent.keyboard for sliders\",\n );\n }\n\n const start = { x: options.startX ?? 0, y: options.startY ?? 0 };\n const updates = resolveDragUpdates(dx, dy, options);\n\n await wrapEvent(widget, () => {\n runDragSequence(getAllControllers(widget, Gtk.GestureDrag), start, updates);\n });\n};\n\nconst emitDrop = (target: Gtk.Widget, content: DropContent, options: DropOptions): void => {\n const dropTargets = getAllControllers(target, Gtk.DropTarget);\n\n for (const dropTarget of dropTargets) {\n dropTarget.emit(\"drop\", buildDropValue(content), options.x ?? 0, options.y ?? 0);\n }\n};\n\n/**\n * Emits `drop` with the given content on every drop target attached to the widget.\n *\n * @throws When the widget has no Gtk.DropTarget.\n */\nconst drop = (widget: Gtk.Widget, content: DropContent, options: DropOptions = {}): Promise<void> =>\n wrapEvent(widget, () => {\n emitDrop(widget, content, options);\n });\n\n/**\n * Emits `drop` with the given content on the target's drop targets, after checking that the source\n * carries a drag source.\n *\n * @throws When the source has no Gtk.DragSource, or the target no Gtk.DropTarget.\n */\nconst dragAndDrop = async (\n source: Gtk.Widget,\n target: Gtk.Widget,\n content: DropContent,\n options: DropOptions = {},\n): Promise<void> => {\n await wrapEvent(source, () => {\n getAllControllers(source, Gtk.DragSource);\n });\n\n await wrapEvent(target, () => {\n emitDrop(target, content, options);\n });\n};\n\nexport {\n hover,\n unhover,\n rotate,\n zoom,\n swipe,\n longPress,\n drag,\n drop,\n dragAndDrop,\n type DropContent,\n type DropOptions,\n type DragOffset,\n type DragOptions,\n};\n"]}
1
+ {"version":3,"file":"gesture.js","sourceRoot":"","sources":["../../src/user-event/gesture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAmD/C,MAAM,SAAS,GAAG,CAAC,KAAmB,EAAE,QAAwC,EAAiB,EAAE;IAC/F,MAAM,KAAK,GAAG,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAClC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhB,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,OAAoB,EAAiB,EAAE;IAC3D,IAAI,OAAO,YAAY,OAAO,CAAC,KAAK,EAAE,CAAC;QACnC,O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Ac,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACrF,CAAC;AACL,CAAC,CAAC;AAEF,iCAAiC;AACjC,MAAM,IAAI,GAAG,CAAC,MAAkB,EAAE,OAAoB,EAAE,UAAuB,EAAE,EAAiB,EAAE,CAChG,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE;IACnB,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC;AAEP,6DAA6D;AAC7D,MAAM,WAAW,GAAG,KAAK,EACrB,MAAkB,EAClB,MAAkB,EAClB,OAAoB,EACpB,UAAuB,EAAE,EACZ,EAAE;IACf,MAAM,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE;QACzB,iBAAiB,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,MAAM,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE;QACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EACH,KAAK,EACL,OAAO,EACP,MAAM,EACN,IAAI,EACJ,KAAK,EACL,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,WAAW,GAKd,CAAC","sourcesContent":["import * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { getAllControllers } from \"./controller.js\";\nimport { dispatchOnControllers, dispatchOnOrCreateControllers } from \"./dispatch.js\";\nimport { wrapEvent } from \"./event-wrapper.js\";\n\n/** The value delivered to a drop target: a primitive (converted to a GObject.Value) or an explicit GObject.Value. */\ntype DropContent = string | number | boolean | GObject.Value;\n\n/** Options for a drop: the drop coordinates within the target. */\ntype DropOptions = {\n /** Horizontal drop coordinate within the target, in pixels. */\n x?: number;\n /** Vertical drop coordinate within the target, in pixels. */\n y?: number;\n};\n\ntype DragPhase = \"drag-begin\" | \"drag-update\" | \"drag-end\";\n\n/** A drag offset relative to the drag start point. */\ntype DragOffset = {\n /** Horizontal distance from the drag start point, in pixels. */\n x: number;\n /** Vertical distance from the drag start point, in pixels. */\n y: number;\n};\n\n/**\n * Options for a drag gesture: the starting point, the number of interpolated drag updates, or\n * explicit intermediate offsets emitted before the final one.\n */\ntype DragOptions = {\n /** Horizontal coordinate the drag begins at; defaults to 0. */\n startX?: number;\n /** Vertical coordinate the drag begins at; defaults to 0. */\n startY?: number;\n /** Number of evenly interpolated drag updates, the last of which is the requested offset; defaults to 2. */\n steps?: number;\n /** Explicit intermediate offsets emitted before the requested one, used instead of `steps`. */\n offsets?: DragOffset[];\n};\n\ntype DragInstancePatch = {\n getStartPoint?: Gtk.GestureDrag[\"getStartPoint\"] | undefined;\n getOffset?: Gtk.GestureDrag[\"getOffset\"] | undefined;\n};\n\ntype SavedDragState = {\n instance: DragInstancePatch;\n hasOwnStartPoint: boolean;\n hasOwnOffset: boolean;\n previousStartPoint: DragInstancePatch[\"getStartPoint\"];\n previousOffset: DragInstancePatch[\"getOffset\"];\n};\n\nconst initValue = (gtype: GObject.Type, populate: (value: GObject.Value) => void): GObject.Value => {\n const value = new GObject.Value();\n value.init(gtype);\n populate(value);\n\n return value;\n};\n\nconst buildDropValue = (content: DropContent): GObject.Value => {\n if (content instanceof GObject.Value) {\n return content;\n }\n\n if (typeof content === \"string\") {\n return initValue(GObject.TYPE_STRING, (v) => {\n v.setString(content);\n });\n }\n\n if (typeof content === \"boolean\") {\n return initValue(GObject.TYPE_BOOLEAN, (v) => {\n v.setBoolean(content);\n });\n }\n\n return initValue(GObject.TYPE_DOUBLE, (v) => {\n v.setDouble(content);\n });\n};\n\n/** Enters a widget. */\nconst hover = (widget: Gtk.Widget): Promise<void> =>\n dispatchOnOrCreateControllers(widget, Gtk.EventControllerMotion, (controller) => {\n controller.emit(\"enter\", 0, 0);\n });\n\n/** Leaves a widget. */\nconst unhover = (widget: Gtk.Widget): Promise<void> =>\n dispatchOnOrCreateControllers(widget, Gtk.EventControllerMotion, (controller) => {\n controller.emit(\"leave\");\n });\n\n/** Rotates a widget's gestures. */\nconst rotate = (widget: Gtk.Widget, angle: number, deltaAngle: number = angle): Promise<void> =>\n dispatchOnControllers(widget, Gtk.GestureRotate, (controller) => {\n controller.emit(\"angle-changed\", angle, deltaAngle);\n },\n );\n\n/** Zooms a widget's gestures. */\nconst zoom = (widget: Gtk.Widget, scale: number): Promise<void> =>\n dispatchOnControllers(widget, Gtk.GestureZoom, (controller) => {\n controller.emit(\"scale-changed\", scale);\n });\n\n/** Swipes a widget's gestures. */\nconst swipe = (widget: Gtk.Widget, velocityX: number, velocityY: number): Promise<void> =>\n dispatchOnControllers(widget, Gtk.GestureSwipe, (controller) => {\n controller.emit(\"swipe\", velocityX, velocityY);\n });\n\n/** Long-presses a widget. */\nconst longPress = (widget: Gtk.Widget, x = 0, y = 0): Promise<void> =>\n dispatchOnControllers(widget, Gtk.GestureLongPress, (controller) => {\n controller.emit(\"pressed\", x, y);\n });\n\nconst restoreDragState = (saved: SavedDragState): void => {\n const { instance } = saved;\n\n if (saved.hasOwnStartPoint) {\n instance.getStartPoint = saved.previousStartPoint;\n } else {\n delete instance.getStartPoint;\n }\n\n if (saved.hasOwnOffset) {\n instance.getOffset = saved.previousOffset;\n } else {\n delete instance.getOffset;\n }\n};\n\nconst patchDragState = (controller: Gtk.GestureDrag, start: DragOffset, offset: () => DragOffset): (() => void) => {\n const instance: DragInstancePatch = controller;\n\n const saved: SavedDragState = {\n instance,\n hasOwnStartPoint: Object.hasOwn(instance, \"getStartPoint\"),\n hasOwnOffset: Object.hasOwn(instance, \"getOffset\"),\n previousStartPoint: instance.getStartPoint,\n previousOffset: instance.getOffset,\n };\n\n instance.getStartPoint = () => [true, start.x, start.y];\n\n instance.getOffset = () => {\n const current = offset();\n\n return [true, current.x, current.y];\n };\n\n return () => {\n restoreDragState(saved);\n };\n};\n\nconst emitToControllers = (controllers: Gtk.GestureDrag[], signal: DragPhase, x: number, y: number): void => {\n for (const controller of controllers) {\n controller.emit(signal, x, y);\n }\n};\n\nconst runDragSequence = (controllers: Gtk.GestureDrag[], start: DragOffset, updates: DragOffset[]): void => {\n let current: DragOffset = { x: 0, y: 0 };\n const restores = controllers.map((controller) => patchDragState(controller, start, () => current));\n\n try {\n emitToControllers(controllers, \"drag-begin\", start.x, start.y);\n\n for (const update of updates) {\n current = update;\n emitToControllers(controllers, \"drag-update\", update.x, update.y);\n }\n\n emitToControllers(controllers, \"drag-end\", current.x, current.y);\n } finally {\n for (const restore of restores) {\n restore();\n }\n }\n};\n\nconst resolveDragUpdates = (dx: number, dy: number, options: DragOptions): DragOffset[] => {\n if (options.offsets) {\n return [...options.offsets, { x: dx, y: dy }];\n }\n\n const steps = Math.max(1, Math.floor(options.steps ?? 2));\n const updates: DragOffset[] = [];\n\n for (let i = 1; i <= steps; i++) {\n updates.push({ x: (dx * i) / steps, y: (dy * i) / steps });\n }\n\n return updates;\n};\n\n/** Drags a widget by an offset. */\nconst drag = async (widget: Gtk.Widget, dx: number, dy: number, options: DragOptions = {}): Promise<void> => {\n if (widget instanceof Gtk.Range) {\n throw new TypeError(\n \"userEvent.drag cannot drive a Gtk.Range's built-in slider \" +\n \"(its drag reads pointer coordinates from the display); \" +\n \"use userEvent.slide(range, value) or userEvent.keyboard for sliders\",\n );\n }\n\n const start = { x: options.startX ?? 0, y: options.startY ?? 0 };\n const updates = resolveDragUpdates(dx, dy, options);\n\n await wrapEvent(widget, () => {\n runDragSequence(getAllControllers(widget, Gtk.GestureDrag), start, updates);\n });\n};\n\nconst emitDrop = (target: Gtk.Widget, content: DropContent, options: DropOptions): void => {\n const dropTargets = getAllControllers(target, Gtk.DropTarget);\n\n for (const dropTarget of dropTargets) {\n dropTarget.emit(\"drop\", buildDropValue(content), options.x ?? 0, options.y ?? 0);\n }\n};\n\n/** Drops content on a widget. */\nconst drop = (widget: Gtk.Widget, content: DropContent, options: DropOptions = {}): Promise<void> =>\n wrapEvent(widget, () => {\n emitDrop(widget, content, options);\n });\n\n/** Drags content from one widget and drops it on another. */\nconst dragAndDrop = async (\n source: Gtk.Widget,\n target: Gtk.Widget,\n content: DropContent,\n options: DropOptions = {},\n): Promise<void> => {\n await wrapEvent(source, () => {\n getAllControllers(source, Gtk.DragSource);\n });\n\n await wrapEvent(target, () => {\n emitDrop(target, content, options);\n });\n};\n\nexport {\n hover,\n unhover,\n rotate,\n zoom,\n swipe,\n longPress,\n drag,\n drop,\n dragAndDrop,\n type DropContent,\n type DropOptions,\n type DragOffset,\n type DragOptions,\n};\n"]}
@@ -11,73 +11,31 @@ type UserEventOptions = {
11
11
  /** Milliseconds to wait after each helper resolves; null, the default, waits not at all. */
12
12
  delay?: number | null | undefined;
13
13
  };
14
- /**
15
- * The set of user interaction helpers exposed by {@link userEvent}, covering clicks, typing,
16
- * keyboard, pointer, gestures, selection, and scrolling.
17
- */
14
+ /** User interactions exposed by {@link userEvent}. */
18
15
  type UserEvent = {
19
- /**
20
- * Returns a fresh instance whose helpers share one keyboard and pointer state, so held modifiers
21
- * and buttons carry across its calls but not across instances.
22
- */
16
+ /** Creates an instance with shared keyboard and pointer state. */
23
17
  setup: (options?: UserEventOptions) => UserEvent;
24
- /**
25
- * Activates a widget that neither claims the click nor carries a click gesture of its own, and
26
- * otherwise presses and releases outwards from the clicked widget through every widget carrying
27
- * a click gesture, stopping at the first button or indexed child. A list box row or flow box
28
- * child receives its click gesture at the clicked position, passes one on to the gestures its
29
- * container carries, and is then activated, or exclusively selected when its container does not
30
- * activate on a single click. The press also stops at a widget whose click GTK4 implements
31
- * itself, where the gestures that widget carries of its own still take the press and the same
32
- * outcome is then applied through GTK's own public action: a list, grid, or column-view row is
33
- * focused and selected, and activated as well when its view activates on a single click; an
34
- * expandable tree expander that is itself the clicked widget toggles its expansion; a notebook
35
- * tab, clicked directly or through its label, focuses its notebook and switches to its page; a
36
- * column header sorts by its column. A column-view cell and the row carrying the column headers
37
- * stand in the way of the click rather than taking it, so a click on either reaches the row or
38
- * the view behind it.
39
- */
18
+ /** Activates or presses and releases a widget. */
40
19
  click: typeof click;
41
- /**
42
- * Delivers a two-press click gesture along the same path a single click takes, without trying
43
- * activation first, activating a list box row or flow box child on that path and replacing its
44
- * container's selection whether or not that container activates on a single click. A widget
45
- * whose click GTK4 implements itself receives that outcome once per press, so a row is selected
46
- * and activated by the second press, a tree expander ends back where it started, a notebook tab
47
- * stays on the page the first press opened, and a column header inverts its order after sorting.
48
- */
20
+ /** Delivers a double-click gesture. */
49
21
  dblClick: typeof dblClick;
50
- /**
51
- * Delivers a three-press click gesture the same way a double click is delivered, applying the
52
- * same outcome to a list box row or flow box child, and applying the outcome GTK4 implements
53
- * itself once per press to a row, tree expander, notebook tab, or column header.
54
- */
22
+ /** Delivers a triple-click gesture. */
55
23
  tripleClick: typeof tripleClick;
56
- /** Moves focus within the widget's root, forward by default and backward with `isShiftHeld`. */
24
+ /** Moves focus forward or backward within the root. */
57
25
  tab: typeof tab;
58
- /**
59
- * Focuses an editable widget the way clicking into it does, leaving its text unselected, applies
60
- * any initial selection, and inserts the text at the cursor, deleting the text the widget has
61
- * selected first, the way GTK4 does.
62
- */
26
+ /** Types into an editable widget. */
63
27
  type: typeof type;
64
- /** Focuses an editable widget and deletes its whole text, leaving nothing selected. */
28
+ /** Deletes all text from an editable widget. */
65
29
  clear: typeof clear;
66
- /** Writes an editable widget's current selection to the clipboard. */
30
+ /** Copies the current selection. */
67
31
  copy: typeof copy;
68
- /** Writes an editable widget's current selection to the clipboard and deletes it. */
32
+ /** Cuts the current selection. */
69
33
  cut: typeof cut;
70
- /**
71
- * Inserts the given text, or the clipboard's text, at an editable widget's cursor, deleting the
72
- * text the widget has selected first, the way GTK4 does.
73
- */
34
+ /** Pastes text or clipboard contents. */
74
35
  paste: typeof paste;
75
- /**
76
- * Selects the items at those positions in a view or drop-down, or selects the indexed children of
77
- * a list box or flow box through their container, without activating them.
78
- */
36
+ /** Selects positions without activating them. */
79
37
  selectOptions: typeof selectOptions;
80
- /** Unselects the items at those positions, leaving list box and flow box children unactivated. */
38
+ /** Unselects positions without activating them. */
81
39
  deselectOptions: typeof deselectOptions;
82
40
  /** Emits a motion `enter` on the widget, adding a motion controller when it has none. */
83
41
  hover: typeof hover;
@@ -101,39 +59,12 @@ type UserEvent = {
101
59
  slide: typeof slide;
102
60
  /** Adds the delta to the adjustments of the widget itself, or of its nearest scrollable ancestor. */
103
61
  scroll: typeof scroll;
104
- /**
105
- * Sends a key sequence along the chain GTK4 propagates a key event through: the application's
106
- * accelerators first, then the capture-phase controllers from the root down to the event widget,
107
- * the event widget's target-phase controllers, and the bubble-phase controllers from it back up
108
- * to the root, so a key controller or shortcut controller a container or window above the widget
109
- * carries receives the key too, each in the phase it declares. The event widget is the editable
110
- * delegate GTK4 focuses when the widget has one, the `Gtk.Text` inside a `Gtk.Entry` for
111
- * instance, so the delegate stands ahead of the widget in the chain. A shortcut controller whose
112
- * scope is not local runs where it registered instead, the root for a global one and the nearest
113
- * `Gtk.ShortcutManager` for a managed one, so it fires wherever focus sits inside that subtree
114
- * and never at its own widget, while a shortcut whose widget is insensitive or unmapped stays
115
- * inert wherever it sits. The first controller that handles a press ends the chain, and a
116
- * `Gdk.KEY_Return` press none of them handled reaches an editable widget's activate handler.
117
- * Built-in key bindings take part, since GTK4 carries them on a shortcut controller: a
118
- * `Gtk.Text`'s arrow keys or a `Gtk.TextView`'s undo can consume a press before an ancestor
119
- * sees it. Key controllers GTK4 attaches itself are the exception, since they read a GDK event
120
- * that off-screen synthesis cannot produce, so only the key controllers the tree connected a
121
- * `key-pressed` or `key-released` handler to take part. Held modifiers carry across calls.
122
- */
62
+ /** Sends a key sequence through GTK's propagation chain. */
123
63
  keyboard: (widget: Gtk.Widget, input: string) => Promise<void>;
124
- /**
125
- * Applies a pointer token to the click gestures the widget already carries, tracking whether the
126
- * left button is held across calls. On a widget whose click GTK4 implements itself, the release
127
- * also applies GTK's own outcome, the way {@link UserEvent.click} does, and a column-view cell
128
- * or the row carrying the column headers passes the token to the row or view behind it.
129
- */
64
+ /** Applies a pointer token while preserving held-button state. */
130
65
  pointer: (widget: Gtk.Widget, input: PointerInput) => Promise<void>;
131
66
  };
132
- /**
133
- * High-level helpers that drive widgets by dispatching the same events and gestures GTK4 delivers
134
- * when someone clicks, types, or drags. Call `setup` for an instance with its own keyboard and
135
- * pointer state.
136
- */
67
+ /** User interactions that dispatch GTK events and gestures. */
137
68
  declare const userEvent: UserEvent;
138
69
  export type { ScrollDelta } from "./adjustment.js";
139
70
  export type { DragOffset, DragOptions, DropContent, DropOptions } from "./gesture.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/user-event/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACvG,OAAO,EAAY,GAAG,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1D,sEAAsE;AACtE,KAAK,gBAAgB,GAAG;IACpB,4FAA4F;IAC5F,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAA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AI,CAAC;IAClB,4EAA4E;IAC5E,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,8EAA8E;IAC9E,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,wGAAwG;IACxG,IAAI,EAAE,OAAO,IAAI,CAAC;IAClB,wEAAwE;IACxE,IAAI,EAAE,OAAO,IAAI,CAAC;IAClB,oHAAoH;IACpH,WAAW,EAAE,OAAO,WAAW,CAAC;IAChC,iFAAiF;IACjF,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,qGAAqG;IACrG,MAAM,EAAE,OAAO,MAAM,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,kEAAkE;IAClE,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE,CAAC;AAEF,+DAA+D;AAC/D,QAAA,MAAM,SAAS,EAAE,SAGhB,CAAC;AA+CF,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACtF,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,CAAC"}
@@ -7,11 +7,7 @@ import { pointer } from "./pointer.js";
7
7
  import { deselectOptions, selectOptions } from "./selection.js";
8
8
  import { createInitialState } from "./state.js";
9
9
  import { clear, copy, cut, paste, type } from "./text.js";
10
- /**
11
- * High-level helpers that drive widgets by dispatching the same events and gestures GTK4 delivers
12
- * when someone clicks, types, or drags. Call `setup` for an instance with its own keyboard and
13
- * pointer state.
14
- */
10
+ /** User interactions that dispatch GTK events and gestures. */
15
11
  const userEvent = {
16
12
  ...createInstance(createInitialState(), {}),
17
13
  setup: (options) => createInstance(createInitialState(), options ?? {}),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/user-event/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACvG,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAuB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA+H1D;;;;GAIG;AACH,MAAM,SAAS,GAAc;IACzB,GAAG,cAAc,CAAC,kBAAkB,EAAE,EAAE,EAAE,CAAC;IAC3C,KAAK,EAAE,CAAC,OAA0B,EAAa,EAAE,CAAC,cAAc,CAAC,kBAAkB,EAAE,EAAE,OAAO,IAAI,EAAE,CAAC;CACxG,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,EAA6B,EAAiB,EAA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AAC,KAAK,CAAC;QACnB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;QAC3B,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;QACjB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;QACjB,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC;QAC/B,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;QACnB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;QACrB,QAAQ,EAAE,KAAK,CAAC,CAAC,MAAkB,EAAE,KAAa,EAAiB,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACrG,OAAO,EAAE,KAAK,CAAC,CAAC,MAAkB,EAAE,KAAmB,EAAiB,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;KAC5G,CAAC;AACN,CAAC;AAOD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAyC,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { delay } from \"../timers.js\";\nimport { scroll, slide } from \"./adjustment.js\";\nimport { click, dblClick, tripleClick } from \"./click.js\";\nimport { drag, dragAndDrop, drop, hover, longPress, rotate, swipe, unhover, zoom } from \"./gesture.js\";\nimport { keyboard, tab } from \"./keyboard.js\";\nimport { pointer, type PointerInput } from \"./pointer.js\";\nimport { deselectOptions, selectOptions } from \"./selection.js\";\nimport { createInitialState, type UserEventState } from \"./state.js\";\nimport { clear, copy, cut, paste, type } from \"./text.js\";\n\n/** Options shared by every helper on a {@link UserEvent} instance. */\ntype UserEventOptions = {\n /** Milliseconds to wait after each helper resolves; null, the default, waits not at all. */\n delay?: number | null | undefined;\n};\n\n/**\n * The set of user interaction helpers exposed by {@link userEvent}, covering clicks, typing,\n * keyboard, pointer, gestures, selection, and scrolling.\n */\ntype UserEvent = {\n /**\n * Returns a fresh instance whose helpers share one keyboard and pointer state, so held modifiers\n * and buttons carry across its calls but not across instances.\n */\n setup: (options?: UserEventOptions) => UserEvent;\n /**\n * Activates a widget that neither claims the click nor carries a click gesture of its own, and\n * otherwise presses and releases outwards from the clicked widget through every widget carrying\n * a click gesture, stopping at the first button or indexed child. A list box row or flow box\n * child receives its click gesture at the clicked position, passes one on to the gestures its\n * container carries, and is then activated, or exclusively selected when its container does not\n * activate on a single click. The press also stops at a widget whose click GTK4 implements\n * itself, where the gestures that widget carries of its own still take the press and the same\n * outcome is then applied through GTK's own public action: a list, grid, or column-view row is\n * focused and selected, and activated as well when its view activates on a single click; an\n * expandable tree expander that is itself the clicked widget toggles its expansion; a notebook\n * tab, clicked directly or through its label, focuses its notebook and switches to its page; a\n * column header sorts by its column. A column-view cell and the row carrying the column headers\n * stand in the way of the click rather than taking it, so a click on either reaches the row or\n * the view behind it.\n */\n click: typeof click;\n /**\n * Delivers a two-press click gesture along the same path a single click takes, without trying\n * activation first, activating a list box row or flow box child on that path and replacing its\n * container's selection whether or not that container activates on a single click. A widget\n * whose click GTK4 implements itself receives that outcome once per press, so a row is selected\n * and activated by the second press, a tree expander ends back where it started, a notebook tab\n * stays on the page the first press opened, and a column header inverts its order after sorting.\n */\n dblClick: typeof dblClick;\n /**\n * Delivers a three-press click gesture the same way a double click is delivered, applying the\n * same outcome to a list box row or flow box child, and applying the outcome GTK4 implements\n * itself once per press to a row, tree expander, notebook tab, or column header.\n */\n tripleClick: typeof tripleClick;\n /** Moves focus within the widget's root, forward by default and backward with `isShiftHeld`. */\n tab: typeof tab;\n /**\n * Focuses an editable widget the way clicking into it does, leaving its text unselected, applies\n * any initial selection, and inserts the text at the cursor, deleting the text the widget has\n * selected first, the way GTK4 does.\n */\n type: typeof type;\n /** Focuses an editable widget and deletes its whole text, leaving nothing selected. */\n clear: typeof clear;\n /** Writes an editable widget's current selection to the clipboard. */\n copy: typeof copy;\n /** Writes an editable widget's current selection to the clipboard and deletes it. */\n cut: typeof cut;\n /**\n * Inserts the given text, or the clipboard's text, at an editable widget's cursor, deleting the\n * text the widget has selected first, the way GTK4 does.\n */\n paste: typeof paste;\n /**\n * Selects the items at those positions in a view or drop-down, or selects the indexed children of\n * a list box or flow box through their container, without activating them.\n */\n selectOptions: typeof selectOptions;\n /** Unselects the items at those positions, leaving list box and flow box children unactivated. */\n deselectOptions: typeof deselectOptions;\n /** Emits a motion `enter` on the widget, adding a motion controller when it has none. */\n hover: typeof hover;\n /** Emits a motion `leave` on the widget, adding a motion controller when it has none. */\n unhover: typeof unhover;\n /** Emits `angle-changed` on the widget's rotate gestures. */\n rotate: typeof rotate;\n /** Emits `scale-changed` on the widget's zoom gestures. */\n zoom: typeof zoom;\n /** Emits `swipe` with the given velocity on the widget's swipe gestures. */\n swipe: typeof swipe;\n /** Emits `pressed` at the given point on the widget's long-press gestures. */\n longPress: typeof longPress;\n /** Runs a begin, update, and end sequence on the widget's drag gestures, ending at the given offset. */\n drag: typeof drag;\n /** Emits `drop` with the given content on the widget's drop targets. */\n drop: typeof drop;\n /** Requires a drag source on the source widget, then emits `drop` with the content on the target's drop targets. */\n dragAndDrop: typeof dragAndDrop;\n /** Emits a jump `change-value` on a Gtk.Range so it moves to the given value. */\n slide: typeof slide;\n /** Adds the delta to the adjustments of the widget itself, or of its nearest scrollable ancestor. */\n scroll: typeof scroll;\n /**\n * Sends a key sequence along the chain GTK4 propagates a key event through: the application's\n * accelerators first, then the capture-phase controllers from the root down to the event widget,\n * the event widget's target-phase controllers, and the bubble-phase controllers from it back up\n * to the root, so a key controller or shortcut controller a container or window above the widget\n * carries receives the key too, each in the phase it declares. The event widget is the editable\n * delegate GTK4 focuses when the widget has one, the `Gtk.Text` inside a `Gtk.Entry` for\n * instance, so the delegate stands ahead of the widget in the chain. A shortcut controller whose\n * scope is not local runs where it registered instead, the root for a global one and the nearest\n * `Gtk.ShortcutManager` for a managed one, so it fires wherever focus sits inside that subtree\n * and never at its own widget, while a shortcut whose widget is insensitive or unmapped stays\n * inert wherever it sits. The first controller that handles a press ends the chain, and a\n * `Gdk.KEY_Return` press none of them handled reaches an editable widget's activate handler.\n * Built-in key bindings take part, since GTK4 carries them on a shortcut controller: a\n * `Gtk.Text`'s arrow keys or a `Gtk.TextView`'s undo can consume a press before an ancestor\n * sees it. Key controllers GTK4 attaches itself are the exception, since they read a GDK event\n * that off-screen synthesis cannot produce, so only the key controllers the tree connected a\n * `key-pressed` or `key-released` handler to take part. Held modifiers carry across calls.\n */\n keyboard: (widget: Gtk.Widget, input: string) => Promise<void>;\n /**\n * Applies a pointer token to the click gestures the widget already carries, tracking whether the\n * left button is held across calls. On a widget whose click GTK4 implements itself, the release\n * also applies GTK's own outcome, the way {@link UserEvent.click} does, and a column-view cell\n * or the row carrying the column headers passes the token to the row or view behind it.\n */\n pointer: (widget: Gtk.Widget, input: PointerInput) => Promise<void>;\n};\n\n/**\n * High-level helpers that drive widgets by dispatching the same events and gestures GTK4 delivers\n * when someone clicks, types, or drags. Call `setup` for an instance with its own keyboard and\n * pointer state.\n */\nconst userEvent: UserEvent = {\n ...createInstance(createInitialState(), {}),\n setup: (options?: UserEventOptions): UserEvent => createInstance(createInitialState(), options ?? {}),\n};\n\nconst settle = (ms: number | null | undefined): Promise<void> => {\n if (ms === null || ms === undefined) {\n return Promise.resolve();\n }\n\n return delay(ms);\n};\n\nfunction createInstance(state: UserEventState, options: UserEventOptions): UserEvent {\n const after =\n <Args extends unknown[]>(helper: (...args: Args) => Promise<void>) =>\n async (...args: Args): Promise<void> => {\n await helper(...args);\n await settle(options.delay);\n };\n\n return {\n setup: (overrides?: UserEventOptions): UserEvent => createInstance(state, { ...options, ...overrides }),\n click: after(click),\n dblClick: after(dblClick),\n tripleClick: after(tripleClick),\n tab: after(tab),\n type: after(type),\n clear: after(clear),\n copy: after(copy),\n cut: after(cut),\n paste: after(paste),\n selectOptions: after(selectOptions),\n deselectOptions: after(deselectOptions),\n hover: after(hover),\n unhover: after(unhover),\n rotate: after(rotate),\n zoom: after(zoom),\n swipe: after(swipe),\n longPress: after(longPress),\n drag: after(drag),\n drop: after(drop),\n dragAndDrop: after(dragAndDrop),\n slide: after(slide),\n scroll: after(scroll),\n keyboard: after((widget: Gtk.Widget, input: string): Promise<void> => keyboard(state, widget, input)),\n pointer: after((widget: Gtk.Widget, input: PointerInput): Promise<void> => pointer(state, widget, input)),\n };\n}\n\nexport type { ScrollDelta } from \"./adjustment.js\";\nexport type { DragOffset, DragOptions, DropContent, DropOptions } from \"./gesture.js\";\nexport type { TabOptions } from \"./keyboard.js\";\nexport type { PointerInput } from \"./pointer.js\";\nexport type { TypeOptions } from \"./text.js\";\nexport { resetClipboard } from \"./text.js\";\nexport { userEvent, type UserEvent, type UserEventOptions };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/user-event/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACvG,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAuB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA8D1D,+DAA+D;AAC/D,MAAM,SAAS,GAAc;IACzB,GAAG,cAAc,CAAC,kBAAk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QACvC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;QACnB,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;QACvB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;QACrB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;QACjB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;QACnB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;QAC3B,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;QACjB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;QACjB,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC;QAC/B,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;QACnB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;QACrB,QAAQ,EAAE,KAAK,CAAC,CAAC,MAAkB,EAAE,KAAa,EAAiB,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACrG,OAAO,EAAE,KAAK,CAAC,CAAC,MAAkB,EAAE,KAAmB,EAAiB,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;KAC5G,CAAC;AACN,CAAC;AAOD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAyC,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { delay } from \"../timers.js\";\nimport { scroll, slide } from \"./adjustment.js\";\nimport { click, dblClick, tripleClick } from \"./click.js\";\nimport { drag, dragAndDrop, drop, hover, longPress, rotate, swipe, unhover, zoom } from \"./gesture.js\";\nimport { keyboard, tab } from \"./keyboard.js\";\nimport { pointer, type PointerInput } from \"./pointer.js\";\nimport { deselectOptions, selectOptions } from \"./selection.js\";\nimport { createInitialState, type UserEventState } from \"./state.js\";\nimport { clear, copy, cut, paste, type } from \"./text.js\";\n\n/** Options shared by every helper on a {@link UserEvent} instance. */\ntype UserEventOptions = {\n /** Milliseconds to wait after each helper resolves; null, the default, waits not at all. */\n delay?: number | null | undefined;\n};\n\n/** User interactions exposed by {@link userEvent}. */\ntype UserEvent = {\n /** Creates an instance with shared keyboard and pointer state. */\n setup: (options?: UserEventOptions) => UserEvent;\n /** Activates or presses and releases a widget. */\n click: typeof click;\n /** Delivers a double-click gesture. */\n dblClick: typeof dblClick;\n /** Delivers a triple-click gesture. */\n tripleClick: typeof tripleClick;\n /** Moves focus forward or backward within the root. */\n tab: typeof tab;\n /** Types into an editable widget. */\n type: typeof type;\n /** Deletes all text from an editable widget. */\n clear: typeof clear;\n /** Copies the current selection. */\n copy: typeof copy;\n /** Cuts the current selection. */\n cut: typeof cut;\n /** Pastes text or clipboard contents. */\n paste: typeof paste;\n /** Selects positions without activating them. */\n selectOptions: typeof selectOptions;\n /** Unselects positions without activating them. */\n deselectOptions: typeof deselectOptions;\n /** Emits a motion `enter` on the widget, adding a motion controller when it has none. */\n hover: typeof hover;\n /** Emits a motion `leave` on the widget, adding a motion controller when it has none. */\n unhover: typeof unhover;\n /** Emits `angle-changed` on the widget's rotate gestures. */\n rotate: typeof rotate;\n /** Emits `scale-changed` on the widget's zoom gestures. */\n zoom: typeof zoom;\n /** Emits `swipe` with the given velocity on the widget's swipe gestures. */\n swipe: typeof swipe;\n /** Emits `pressed` at the given point on the widget's long-press gestures. */\n longPress: typeof longPress;\n /** Runs a begin, update, and end sequence on the widget's drag gestures, ending at the given offset. */\n drag: typeof drag;\n /** Emits `drop` with the given content on the widget's drop targets. */\n drop: typeof drop;\n /** Requires a drag source on the source widget, then emits `drop` with the content on the target's drop targets. */\n dragAndDrop: typeof dragAndDrop;\n /** Emits a jump `change-value` on a Gtk.Range so it moves to the given value. */\n slide: typeof slide;\n /** Adds the delta to the adjustments of the widget itself, or of its nearest scrollable ancestor. */\n scroll: typeof scroll;\n /** Sends a key sequence through GTK's propagation chain. */\n keyboard: (widget: Gtk.Widget, input: string) => Promise<void>;\n /** Applies a pointer token while preserving held-button state. */\n pointer: (widget: Gtk.Widget, input: PointerInput) => Promise<void>;\n};\n\n/** User interactions that dispatch GTK events and gestures. */\nconst userEvent: UserEvent = {\n ...createInstance(createInitialState(), {}),\n setup: (options?: UserEventOptions): UserEvent => createInstance(createInitialState(), options ?? {}),\n};\n\nconst settle = (ms: number | null | undefined): Promise<void> => {\n if (ms === null || ms === undefined) {\n return Promise.resolve();\n }\n\n return delay(ms);\n};\n\nfunction createInstance(state: UserEventState, options: UserEventOptions): UserEvent {\n const after =\n <Args extends unknown[]>(helper: (...args: Args) => Promise<void>) =>\n async (...args: Args): Promise<void> => {\n await helper(...args);\n await settle(options.delay);\n };\n\n return {\n setup: (overrides?: UserEventOptions): UserEvent => createInstance(state, { ...options, ...overrides }),\n click: after(click),\n dblClick: after(dblClick),\n tripleClick: after(tripleClick),\n tab: after(tab),\n type: after(type),\n clear: after(clear),\n copy: after(copy),\n cut: after(cut),\n paste: after(paste),\n selectOptions: after(selectOptions),\n deselectOptions: after(deselectOptions),\n hover: after(hover),\n unhover: after(unhover),\n rotate: after(rotate),\n zoom: after(zoom),\n swipe: after(swipe),\n longPress: after(longPress),\n drag: after(drag),\n drop: after(drop),\n dragAndDrop: after(dragAndDrop),\n slide: after(slide),\n scroll: after(scroll),\n keyboard: after((widget: Gtk.Widget, input: string): Promise<void> => keyboard(state, widget, input)),\n pointer: after((widget: Gtk.Widget, input: PointerInput): Promise<void> => pointer(state, widget, input)),\n };\n}\n\nexport type { ScrollDelta } from \"./adjustment.js\";\nexport type { DragOffset, DragOptions, DropContent, DropOptions } from \"./gesture.js\";\nexport type { TabOptions } from \"./keyboard.js\";\nexport type { PointerInput } from \"./pointer.js\";\nexport type { TypeOptions } from \"./text.js\";\nexport { resetClipboard } from \"./text.js\";\nexport { userEvent, type UserEvent, type UserEventOptions };\n"]}
@@ -5,7 +5,7 @@ type TabOptions = {
5
5
  /** Move focus backward instead of forward. */
6
6
  isShiftHeld?: boolean;
7
7
  };
8
- /** Moves focus within the widget's root, forward by default and backward when `isShiftHeld` is set. */
8
+ /** Moves focus within the widget's root. */
9
9
  declare const tab: (widget: Gtk.Widget, options?: TabOptions) => Promise<void>;
10
10
  declare const keyboard: (state: UserEventState, widget: Gtk.Widget, input: string) => Promise<void>;
11
11
  export { tab, keyboard, type TabOptions };
@@ -1 +1 @@
1
- {"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../../src/user-event/keyboard.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAMjD,mCAAmC;AACnC,KAAK,UAAU,GAAG;IACd,8CAA8C;IAC9C,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAqDF,uGAAuG;AACvG,QAAA,MAAM,GAAG,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,UAAU,UAAU,KAAG,OAAO,CAAC,IAAI,CAQ9D,CAAC;AAsUP,QAAA,MAAM,QAAQ,GAAI,OAAO,cAAc,EAAE,QAAQ,GAAG,CAAC,MAAM,EAAE,OAAO,MAAM,KAAG,OAAO,CAAC,IAAI,CAKnF,CAAC;AAEP,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../../src/user-event/keyboard.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAMjD,mCAAmC;AACnC,KAAK,UAAU,GAAG;IACd,8CAA8C;IAC9C,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAqDF,4CAA4C;AAC5C,QAAA,MAAM,GAAG,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,UAAU,UAAU,KAAG,OAAO,CAAC,IAAI,CAQ9D,CAAC;AAsUP,QAAA,MAAM,QAAQ,GAAI,OAAO,cAAc,EAAE,QAAQ,GAAG,CAAC,MAAM,EAAE,OAAO,MAAM,KAAG,OAAO,CAAC,IAAI,CAKnF,CAAC;AAEP,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,CAAC"}
@@ -49,7 +49,7 @@ const MODIFIER_KEYVAL_TO_MASK = {
49
49
  [Gdk.KEY_Meta_L]: Gdk.ModifierType.META_MASK,
50
50
  [Gdk.KEY_Meta_R]: Gdk.ModifierType.META_MASK,
51
51
  };
52
- /** Moves focus within the widget's root, forward by default and backward when `isShiftHeld` is set. */
52
+ /** Moves focus within the widget's root. */
53
53
  const tab = (widget, options) => wrapEvent(widget, () => {
54
54
  const direction = options?.isShiftHeld ? Gtk.DirectionType.TAB_BACKWARD : Gtk.DirectionType.TAB_FORWARD;
55
55
  const root = widget.getRoot();