@gtkx/testing 1.0.0 → 1.2.0
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.
- package/README.md +1 -1
- package/dist/act.d.ts +1 -3
- package/dist/act.d.ts.map +1 -1
- package/dist/act.js +1 -1
- package/dist/act.js.map +1 -1
- package/dist/build-queries.d.ts +1 -1
- package/dist/build-queries.js +1 -1
- package/dist/build-queries.js.map +1 -1
- package/dist/config.d.ts +8 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/frame-sync.d.ts +2 -2
- package/dist/frame-sync.d.ts.map +1 -1
- package/dist/frame-sync.js +10 -10
- package/dist/frame-sync.js.map +1 -1
- package/dist/harness-window.d.ts +2 -1
- package/dist/harness-window.d.ts.map +1 -1
- package/dist/harness-window.js +12 -1
- package/dist/harness-window.js.map +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +1 -0
- package/dist/internal.js.map +1 -1
- package/dist/matchers.d.ts.map +1 -1
- package/dist/matchers.js +22 -2
- package/dist/matchers.js.map +1 -1
- package/dist/pretty-widget.d.ts.map +1 -1
- package/dist/pretty-widget.js +2 -1
- package/dist/pretty-widget.js.map +1 -1
- package/dist/production.d.ts.map +1 -1
- package/dist/production.js +2 -2
- package/dist/production.js.map +1 -1
- package/dist/render.d.ts +12 -1
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +45 -11
- package/dist/render.js.map +1 -1
- package/dist/role-helpers.d.ts.map +1 -1
- package/dist/role-helpers.js +2 -1
- package/dist/role-helpers.js.map +1 -1
- package/dist/screenshot.d.ts.map +1 -1
- package/dist/screenshot.js +8 -14
- package/dist/screenshot.js.map +1 -1
- package/dist/timers.d.ts +9 -0
- package/dist/timers.d.ts.map +1 -0
- package/dist/timers.js +21 -0
- package/dist/timers.js.map +1 -0
- package/dist/traversal.d.ts +4 -1
- package/dist/traversal.d.ts.map +1 -1
- package/dist/traversal.js +16 -1
- package/dist/traversal.js.map +1 -1
- package/dist/types.d.ts +6 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/user-event/adjustment.d.ts.map +1 -1
- package/dist/user-event/adjustment.js +2 -1
- package/dist/user-event/adjustment.js.map +1 -1
- package/dist/user-event/click.d.ts +5 -4
- package/dist/user-event/click.d.ts.map +1 -1
- package/dist/user-event/click.js +5 -4
- package/dist/user-event/click.js.map +1 -1
- package/dist/user-event/column-header-click.d.ts.map +1 -1
- package/dist/user-event/column-header-click.js +2 -12
- package/dist/user-event/column-header-click.js.map +1 -1
- package/dist/user-event/event-wrapper.d.ts.map +1 -1
- package/dist/user-event/event-wrapper.js +34 -21
- package/dist/user-event/event-wrapper.js.map +1 -1
- package/dist/user-event/index.d.ts +36 -10
- package/dist/user-event/index.d.ts.map +1 -1
- package/dist/user-event/index.js +4 -3
- package/dist/user-event/index.js.map +1 -1
- package/dist/user-event/keyboard.d.ts.map +1 -1
- package/dist/user-event/keyboard.js +93 -38
- package/dist/user-event/keyboard.js.map +1 -1
- package/dist/user-event/list-row-click.d.ts.map +1 -1
- package/dist/user-event/list-row-click.js +4 -5
- package/dist/user-event/list-row-click.js.map +1 -1
- package/dist/user-event/native-click.d.ts.map +1 -1
- package/dist/user-event/native-click.js +4 -0
- package/dist/user-event/native-click.js.map +1 -1
- package/dist/user-event/notebook-tab-click.d.ts +5 -0
- package/dist/user-event/notebook-tab-click.d.ts.map +1 -0
- package/dist/user-event/notebook-tab-click.js +39 -0
- package/dist/user-event/notebook-tab-click.js.map +1 -0
- package/dist/user-event/text.d.ts +6 -3
- package/dist/user-event/text.d.ts.map +1 -1
- package/dist/user-event/text.js +88 -33
- package/dist/user-event/text.js.map +1 -1
- package/dist/wait-for.d.ts.map +1 -1
- package/dist/wait-for.js +4 -3
- package/dist/wait-for.js.map +1 -1
- package/dist/widget-getters.d.ts +4 -1
- package/dist/widget-getters.d.ts.map +1 -1
- package/dist/widget-getters.js +29 -2
- package/dist/widget-getters.js.map +1 -1
- package/dist/window-state.d.ts +10 -0
- package/dist/window-state.d.ts.map +1 -0
- package/dist/window-state.js +41 -0
- package/dist/window-state.js.map +1 -0
- package/package.json +15 -7
- package/src/act.ts +1 -1
- package/src/build-queries.ts +1 -1
- package/src/config.ts +10 -1
- package/src/frame-sync.ts +15 -10
- package/src/harness-window.ts +15 -1
- package/src/internal.ts +1 -0
- package/src/matchers.ts +29 -2
- package/src/pretty-widget.ts +2 -1
- package/src/production.ts +2 -3
- package/src/render.tsx +67 -12
- package/src/role-helpers.ts +2 -1
- package/src/screenshot.ts +10 -17
- package/src/timers.ts +31 -0
- package/src/traversal.ts +22 -0
- package/src/types.ts +6 -1
- package/src/user-event/adjustment.ts +2 -1
- package/src/user-event/click.ts +5 -4
- package/src/user-event/column-header-click.ts +2 -16
- package/src/user-event/event-wrapper.ts +41 -25
- package/src/user-event/index.ts +40 -13
- package/src/user-event/keyboard.ts +124 -54
- package/src/user-event/list-row-click.ts +4 -7
- package/src/user-event/native-click.ts +5 -0
- package/src/user-event/notebook-tab-click.ts +57 -0
- package/src/user-event/text.ts +113 -38
- package/src/wait-for.ts +4 -4
- package/src/widget-getters.ts +55 -2
- package/src/window-state.ts +70 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
2
|
import { scheduleNextFrame } from "../frame-sync.js";
|
|
3
|
+
import { getTypeTag } from "../widget-getters.js";
|
|
3
4
|
import { wrapEvent } from "./event-wrapper.js";
|
|
4
5
|
/**
|
|
5
6
|
* Emits a jump `change-value` so a Gtk.Range moves to the given value.
|
|
@@ -8,7 +9,7 @@ import { wrapEvent } from "./event-wrapper.js";
|
|
|
8
9
|
*/
|
|
9
10
|
const slide = (widget, value) => wrapEvent(widget, () => {
|
|
10
11
|
if (!(widget instanceof Gtk.Range)) {
|
|
11
|
-
throw new TypeError(`userEvent.slide requires a Gtk.Range (e.g. Gtk.Scale), got ${widget
|
|
12
|
+
throw new TypeError(`userEvent.slide requires a Gtk.Range (e.g. Gtk.Scale), got ${getTypeTag(widget)}`);
|
|
12
13
|
}
|
|
13
14
|
widget.emit("change-value", Gtk.ScrollType.JUMP, value);
|
|
14
15
|
});
|
|
@@ -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,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAe/C;;;;GAIG;AACH,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,CACf,8DAA8D,
|
|
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;;;;GAIG;AACH,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,CACf,8DAA8D,UAAU,CAAC,MAAM,CAAC,EAAE,CACrF,CAAC;IACN,CAAC;IAED,MAAM,CAA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tk\";\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/**\n * Emits a jump `change-value` so a Gtk.Range moves to the given value.\n *\n * @throws When the widget is not a Gtk.Range.\n */\nconst slide = (widget: Gtk.Widget, value: number): Promise<void> =>\n wrapEvent(widget, () => {\n if (!(widget instanceof Gtk.Range)) {\n throw new TypeError(\n `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/**\n * Adds the delta to the adjustments of the widget itself, or of its nearest Gtk.ScrolledWindow or\n * Gtk.Scrollable ancestor.\n *\n * Each adjustment advances in viewport-sized steps rather than one jump, so virtualized views such\n * as Gtk.ListView, Gtk.GridView and Gtk.ColumnView re-anchor onto the rows the new offset shows.\n *\n * @throws When neither the widget nor any of its ancestors is scrollable.\n */\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"]}
|
|
@@ -23,7 +23,8 @@ declare const getAuthoredClickGestures: (widget: Gtk.Widget) => Gtk.GestureClick
|
|
|
23
23
|
* handler invokes: a list, grid, or column-view row is focused and selected, and activated as well
|
|
24
24
|
* on a second press or when its view activates on a single click; an expandable tree expander
|
|
25
25
|
* toggles its expansion, once per press, and only when it is the widget clicked, so a click on its
|
|
26
|
-
* child falls through to the enclosing row; a
|
|
26
|
+
* child falls through to the enclosing row; a notebook tab, clicked directly or through its label,
|
|
27
|
+
* focuses its notebook and switches to its page; a column header sorts by its column. Sorting goes
|
|
27
28
|
* through Gtk.ColumnView.sortByColumn, so the primary sort column and order match what a pointer
|
|
28
29
|
* produces while previously sorted columns are dropped rather than kept as secondary keys. A
|
|
29
30
|
* column-view cell and the row that carries the column headers stand in the way of the click rather
|
|
@@ -36,14 +37,14 @@ declare const click: (widget: Gtk.Widget) => Promise<void>;
|
|
|
36
37
|
* a descendant, is activated and exclusively selected, as GTK's double-click path does whether or
|
|
37
38
|
* not the container activates on a single click. A widget whose click GTK4 implements itself
|
|
38
39
|
* receives that outcome once per press, so a list, grid, or column-view row is selected and then
|
|
39
|
-
* activated by the second press, a tree expander ends back where it started,
|
|
40
|
-
* sorts and then inverts its order.
|
|
40
|
+
* activated by the second press, a tree expander ends back where it started, a notebook tab stays on
|
|
41
|
+
* the page the first press opened, and a column header sorts and then inverts its order.
|
|
41
42
|
*/
|
|
42
43
|
declare const dblClick: (widget: Gtk.Widget) => Promise<void>;
|
|
43
44
|
/**
|
|
44
45
|
* Delivers a three-press click gesture the same way a double click is delivered, applying the same
|
|
45
46
|
* outcome to a list box row or flow box child the presses reach, and applying the outcome GTK4
|
|
46
|
-
* implements itself once per press to a row, tree expander, or column header.
|
|
47
|
+
* implements itself once per press to a row, tree expander, notebook tab, or column header.
|
|
47
48
|
*/
|
|
48
49
|
declare const tripleClick: (widget: Gtk.Widget) => Promise<void>;
|
|
49
50
|
export { clickGestures, emitClickPhase, getAuthoredClickGestures, click, dblClick, tripleClick };
|
|
@@ -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;AASpC,KAAK,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;AA8CzC,QAAA,MAAM,cAAc,GAChB,QAAQ,GAAG,CAAC,MAAM,EAClB,aAAa,GAAG,CAAC,YAAY,EAAE,EAC/B,QAAQ,MAAM,EACd,OAAO,UAAU,KAClB,IAEF,CAAC;AAyBF,QAAA,MAAM,aAAa,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,GAAG,CAAC,YAAY,EACoC,CAAC;AAEjG,QAAA,MAAM,wBAAwB,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,GAAG,CAAC,YAAY,EACC,CAAC;AA6JzE
|
|
1
|
+
{"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AASpC,KAAK,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;AA8CzC,QAAA,MAAM,cAAc,GAChB,QAAQ,GAAG,CAAC,MAAM,EAClB,aAAa,GAAG,CAAC,YAAY,EAAE,EAC/B,QAAQ,MAAM,EACd,OAAO,UAAU,KAClB,IAEF,CAAC;AAyBF,QAAA,MAAM,aAAa,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,GAAG,CAAC,YAAY,EACoC,CAAC;AAEjG,QAAA,MAAM,wBAAwB,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,GAAG,CAAC,YAAY,EACC,CAAC;AA6JzE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,QAAA,MAAM,KAAK,GAAU,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAMrD,CAAC;AAEF;;;;;;;;GAQG;AACH,QAAA,MAAM,QAAQ,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAA4B,CAAC;AAChF;;;;GAIG;AACH,QAAA,MAAM,WAAW,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAA4B,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,wBAAwB,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/user-event/click.js
CHANGED
|
@@ -179,7 +179,8 @@ const tryActivate = async (widget) => {
|
|
|
179
179
|
* handler invokes: a list, grid, or column-view row is focused and selected, and activated as well
|
|
180
180
|
* on a second press or when its view activates on a single click; an expandable tree expander
|
|
181
181
|
* toggles its expansion, once per press, and only when it is the widget clicked, so a click on its
|
|
182
|
-
* child falls through to the enclosing row; a
|
|
182
|
+
* child falls through to the enclosing row; a notebook tab, clicked directly or through its label,
|
|
183
|
+
* focuses its notebook and switches to its page; a column header sorts by its column. Sorting goes
|
|
183
184
|
* through Gtk.ColumnView.sortByColumn, so the primary sort column and order match what a pointer
|
|
184
185
|
* produces while previously sorted columns are dropped rather than kept as secondary keys. A
|
|
185
186
|
* column-view cell and the row that carries the column headers stand in the way of the click rather
|
|
@@ -197,14 +198,14 @@ const click = async (widget) => {
|
|
|
197
198
|
* a descendant, is activated and exclusively selected, as GTK's double-click path does whether or
|
|
198
199
|
* not the container activates on a single click. A widget whose click GTK4 implements itself
|
|
199
200
|
* receives that outcome once per press, so a list, grid, or column-view row is selected and then
|
|
200
|
-
* activated by the second press, a tree expander ends back where it started,
|
|
201
|
-
* sorts and then inverts its order.
|
|
201
|
+
* activated by the second press, a tree expander ends back where it started, a notebook tab stays on
|
|
202
|
+
* the page the first press opened, and a column header sorts and then inverts its order.
|
|
202
203
|
*/
|
|
203
204
|
const dblClick = (widget) => deliverClick(widget, 2);
|
|
204
205
|
/**
|
|
205
206
|
* Delivers a three-press click gesture the same way a double click is delivered, applying the same
|
|
206
207
|
* outcome to a list box row or flow box child the presses reach, and applying the outcome GTK4
|
|
207
|
-
* implements itself once per press to a row, tree expander, or column header.
|
|
208
|
+
* implements itself once per press to a row, tree expander, notebook tab, or column header.
|
|
208
209
|
*/
|
|
209
210
|
const tripleClick = (widget) => deliverClick(widget, 3);
|
|
210
211
|
export { clickGestures, emitClickPhase, getAuthoredClickGestures, click, dblClick, tripleClick };
|
|
@@ -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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tkx/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 = (point: PressPoint, controllers: Gtk.GestureClick[], nPress: number, signal: string): 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 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, and a column header\n * 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, 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,cAA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,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 = (point: PressPoint, controllers: Gtk.GestureClick[], nPress: number, signal: string): 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-header-click.d.ts","sourceRoot":"","sources":["../../src/user-event/column-header-click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"column-header-click.d.ts","sourceRoot":"","sources":["../../src/user-event/column-header-click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AA8DpC,QAAA,MAAM,gBAAgB,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,QAAQ,MAAM,KAAG,IAW9D,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
-
import { children } from "../traversal.js";
|
|
2
|
+
import { ancestorFor, children } from "../traversal.js";
|
|
3
3
|
import { getWidgetTextContent } from "../widget-accessible-properties.js";
|
|
4
|
-
const columnViewFor = (header) => {
|
|
5
|
-
let current = header.getParent();
|
|
6
|
-
while (current !== null) {
|
|
7
|
-
if (current instanceof Gtk.ColumnView) {
|
|
8
|
-
return current;
|
|
9
|
-
}
|
|
10
|
-
current = current.getParent();
|
|
11
|
-
}
|
|
12
|
-
return null;
|
|
13
|
-
};
|
|
14
4
|
const columnsFor = (view) => {
|
|
15
5
|
const model = view.getColumns();
|
|
16
6
|
const columns = [];
|
|
@@ -52,7 +42,7 @@ const nextSortDirection = (view, column) => {
|
|
|
52
42
|
return invertedSortDirection(sorter.getPrimarySortOrder());
|
|
53
43
|
};
|
|
54
44
|
const applyHeaderClick = (header, nPress) => {
|
|
55
|
-
const view =
|
|
45
|
+
const view = ancestorFor(header, Gtk.ColumnView);
|
|
56
46
|
const column = view === null ? null : sortableColumnFor(header, view);
|
|
57
47
|
if (view === null || column === null) {
|
|
58
48
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-header-click.js","sourceRoot":"","sources":["../../src/user-event/column-header-click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"column-header-click.js","sourceRoot":"","sources":["../../src/user-event/column-header-click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,MAAM,UAAU,GAAG,CAAC,IAAoB,EAA0B,EAAE;IAChE,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IAChC,MAAM,OAAO,GAA2B,EAAE,CAAC;IAE3C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC;QACrD,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,MAAM,YAAY,GAAG,CAAC,gBAAgB,EAAE,CAAC;YACzC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,MAAkB,EAAU,EAAE;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC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","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { ancestorFor, children } from \"../traversal.js\";\nimport { getWidgetTextContent } from \"../widget-accessible-properties.js\";\n\nconst columnsFor = (view: Gtk.ColumnView): Gtk.ColumnViewColumn[] => {\n const model = view.getColumns();\n const columns: Gtk.ColumnViewColumn[] = [];\n\n for (let index = 0; index < model.getNItems(); index++) {\n const column = model.getItem(index);\n\n if (column instanceof Gtk.ColumnViewColumn) {\n columns.push(column);\n }\n }\n\n return columns;\n};\n\nconst headerIndexFor = (header: Gtk.Widget): number => {\n const parent = header.getParent();\n\n return parent === null ? -1 : [...children(parent)].indexOf(header);\n};\n\nconst titledColumnFor = (columns: Gtk.ColumnViewColumn[], title: string | null): Gtk.ColumnViewColumn | null => {\n const matches = columns.filter((column) => column.getTitle() === title);\n\n return matches.length === 1 ? matches[0] ?? null : null;\n};\n\nconst columnFor = (header: Gtk.Widget, view: Gtk.ColumnView): Gtk.ColumnViewColumn | null => {\n const columns = columnsFor(view);\n const picked = columns[headerIndexFor(header)] ?? null;\n const title = getWidgetTextContent(header);\n\n if (picked !== null && picked.getTitle() === title) {\n return picked;\n }\n\n return titledColumnFor(columns, title) ?? picked;\n};\n\nconst sortableColumnFor = (header: Gtk.Widget, view: Gtk.ColumnView): Gtk.ColumnViewColumn | null => {\n const column = columnFor(header, view);\n\n return column !== null && column.getSorter() !== null ? column : null;\n};\n\nconst invertedSortDirection = (order: Gtk.SortType): Gtk.SortType =>\n order === Gtk.SortType.ASCENDING ? Gtk.SortType.DESCENDING : Gtk.SortType.ASCENDING;\n\nconst nextSortDirection = (view: Gtk.ColumnView, column: Gtk.ColumnViewColumn): Gtk.SortType => {\n const sorter = view.getSorter();\n\n if (!(sorter instanceof Gtk.ColumnViewSorter) || sorter.getPrimarySortColumn() !== column) {\n return Gtk.SortType.ASCENDING;\n }\n\n return invertedSortDirection(sorter.getPrimarySortOrder());\n};\n\nconst applyHeaderClick = (header: Gtk.Widget, nPress: number): void => {\n const view = ancestorFor(header, Gtk.ColumnView);\n const column = view === null ? null : sortableColumnFor(header, view);\n\n if (view === null || column === null) {\n return;\n }\n\n for (let press = 1; press <= nPress; press++) {\n view.sortByColumn(column, nextSortDirection(view, column));\n }\n};\n\nexport { applyHeaderClick };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-wrapper.d.ts","sourceRoot":"","sources":["../../src/user-event/event-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"event-wrapper.d.ts","sourceRoot":"","sources":["../../src/user-event/event-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAyFpC,QAAA,MAAM,SAAS,GAAU,QAAQ,GAAG,CAAC,MAAM,EAAE,MAAM,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,KAAG,OAAO,CAAC,IAAI,CAM/F,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -2,47 +2,60 @@ import * as Gtk from "@gtkx/gi/gtk";
|
|
|
2
2
|
import { runInAct } from "../act.js";
|
|
3
3
|
import { getConfig } from "../config.js";
|
|
4
4
|
import { formatRole } from "../role-helpers.js";
|
|
5
|
+
import { delay, now } from "../timers.js";
|
|
6
|
+
import { getWidgetAccessibleName } from "../widget-accessible-properties.js";
|
|
7
|
+
import { getTypeTag, isDefaultWidgetName } from "../widget-getters.js";
|
|
8
|
+
import { isWindowAllocated, isWindowBlockedByModal } from "../window-state.js";
|
|
5
9
|
const NOT_SENSITIVE = "it is not sensitive (the widget or one of its ancestors is disabled)";
|
|
10
|
+
const NOT_ROOTED = "it is not inside a toplevel (it was removed from the widget tree, or was never added to one)";
|
|
11
|
+
const WINDOW_NOT_VISIBLE = "its window is not visible (it was hidden, or it was never shown)";
|
|
6
12
|
const WINDOW_NOT_ALLOCATED = "its window has not been allocated a size";
|
|
7
13
|
const NOT_MAPPED = "it is not mapped (it is not shown on screen, e.g. it is hidden or on a non-visible page)";
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (!isComputed || allocation.getWidth() === 0) {
|
|
14
|
-
return WINDOW_NOT_ALLOCATED;
|
|
14
|
+
const BLOCKED_BY_MODAL = "its window is blocked by a modal window holding the grab";
|
|
15
|
+
const ACTIONABLE_HOP_MS = 1;
|
|
16
|
+
const findWindowActionabilityFailure = (window) => {
|
|
17
|
+
if (!window.getVisible()) {
|
|
18
|
+
return WINDOW_NOT_VISIBLE;
|
|
15
19
|
}
|
|
16
|
-
if (!
|
|
17
|
-
return
|
|
20
|
+
if (!isWindowAllocated(window)) {
|
|
21
|
+
return WINDOW_NOT_ALLOCATED;
|
|
18
22
|
}
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
23
|
+
if (isWindowBlockedByModal(window)) {
|
|
24
|
+
return BLOCKED_BY_MODAL;
|
|
21
25
|
}
|
|
22
26
|
return null;
|
|
23
27
|
};
|
|
28
|
+
const findRootActionabilityFailure = (root) => root instanceof Gtk.Window ? findWindowActionabilityFailure(root) : null;
|
|
24
29
|
const findActionabilityFailure = (widget) => {
|
|
25
30
|
if (!widget.isSensitive()) {
|
|
26
31
|
return NOT_SENSITIVE;
|
|
27
32
|
}
|
|
28
33
|
const root = widget.getRoot();
|
|
29
|
-
if (
|
|
30
|
-
return
|
|
34
|
+
if (root === null) {
|
|
35
|
+
return NOT_ROOTED;
|
|
36
|
+
}
|
|
37
|
+
const rootFailure = findRootActionabilityFailure(root);
|
|
38
|
+
if (rootFailure !== null) {
|
|
39
|
+
return rootFailure;
|
|
31
40
|
}
|
|
32
|
-
return
|
|
41
|
+
return widget.getMapped() ? null : NOT_MAPPED;
|
|
33
42
|
};
|
|
34
|
-
const
|
|
35
|
-
|
|
43
|
+
const attribute = (key, value) => (value === null ? "" : ` ${key}="${value}"`);
|
|
44
|
+
const widgetNameAttribute = (widget) => {
|
|
36
45
|
const name = widget.getName();
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
return attribute("name", isDefaultWidgetName(widget, name) ? null : name);
|
|
47
|
+
};
|
|
48
|
+
const describeWidget = (widget) => {
|
|
49
|
+
const accessibleName = attribute("accessible-name", getWidgetAccessibleName(widget));
|
|
50
|
+
const role = attribute("role", formatRole(widget.getAccessibleRole()));
|
|
51
|
+
return `<${getTypeTag(widget)}${accessibleName}${widgetNameAttribute(widget)}${role}>`;
|
|
39
52
|
};
|
|
40
53
|
const waitForActionable = async (widget) => {
|
|
41
54
|
const timeout = getConfig().actionabilityTimeout;
|
|
42
|
-
const deadline =
|
|
55
|
+
const deadline = now() + timeout;
|
|
43
56
|
let failure = findActionabilityFailure(widget);
|
|
44
|
-
while (failure !== null &&
|
|
45
|
-
await
|
|
57
|
+
while (failure !== null && now() < deadline) {
|
|
58
|
+
await delay(ACTIONABLE_HOP_MS);
|
|
46
59
|
failure = findActionabilityFailure(widget);
|
|
47
60
|
}
|
|
48
61
|
if (failure !== null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-wrapper.js","sourceRoot":"","sources":["../../src/user-event/event-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"event-wrapper.js","sourceRoot":"","sources":["../../src/user-event/event-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;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M,OAAO,GAAG,SAAS,EAAE,CAAC,oBAAoB,CAAC;IACjD,MAAM,QAAQ,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC;IACjC,IAAI,OAAO,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAC;IAE/C,OAAO,OAAO,KAAK,IAAI,IAAI,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC1C,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CACX,+BAA+B,cAAc,CAAC,MAAM,CAAC,6BAA6B;YAClF,UAAU,MAAM,CAAC,OAAO,CAAC,cAAc,OAAO,EAAE,CACnD,CAAC;IACN,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,KAAK,EAAE,MAAkB,EAAE,IAAoC,EAAiB,EAAE;IAChG,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEhC,MAAM,QAAQ,CAAC,KAAK,IAAI,EAAE;QACtB,MAAM,IAAI,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { runInAct } from \"../act.js\";\nimport { getConfig } from \"../config.js\";\nimport { formatRole } from \"../role-helpers.js\";\nimport { delay, now } from \"../timers.js\";\nimport { getWidgetAccessibleName } from \"../widget-accessible-properties.js\";\nimport { getTypeTag, isDefaultWidgetName } from \"../widget-getters.js\";\nimport { isWindowAllocated, isWindowBlockedByModal } from \"../window-state.js\";\n\nconst NOT_SENSITIVE = \"it is not sensitive (the widget or one of its ancestors is disabled)\";\nconst NOT_ROOTED = \"it is not inside a toplevel (it was removed from the widget tree, or was never added to one)\";\nconst WINDOW_NOT_VISIBLE = \"its window is not visible (it was hidden, or it was never shown)\";\nconst WINDOW_NOT_ALLOCATED = \"its window has not been allocated a size\";\nconst NOT_MAPPED = \"it is not mapped (it is not shown on screen, e.g. it is hidden or on a non-visible page)\";\nconst BLOCKED_BY_MODAL = \"its window is blocked by a modal window holding the grab\";\nconst ACTIONABLE_HOP_MS = 1;\n\nconst findWindowActionabilityFailure = (window: Gtk.Window): string | null => {\n if (!window.getVisible()) {\n return WINDOW_NOT_VISIBLE;\n }\n\n if (!isWindowAllocated(window)) {\n return WINDOW_NOT_ALLOCATED;\n }\n\n if (isWindowBlockedByModal(window)) {\n return BLOCKED_BY_MODAL;\n }\n\n return null;\n};\n\nconst findRootActionabilityFailure = (root: Gtk.Root): string | null =>\n root instanceof Gtk.Window ? findWindowActionabilityFailure(root) : null;\n\nconst findActionabilityFailure = (widget: Gtk.Widget): string | null => {\n if (!widget.isSensitive()) {\n return NOT_SENSITIVE;\n }\n\n const root = widget.getRoot();\n\n if (root === null) {\n return NOT_ROOTED;\n }\n\n const rootFailure = findRootActionabilityFailure(root);\n\n if (rootFailure !== null) {\n return rootFailure;\n }\n\n return widget.getMapped() ? null : NOT_MAPPED;\n};\n\nconst attribute = (key: string, value: string | null): string => (value === null ? \"\" : ` ${key}=\"${value}\"`);\n\nconst widgetNameAttribute = (widget: Gtk.Widget): string => {\n const name = widget.getName();\n\n return attribute(\"name\", isDefaultWidgetName(widget, name) ? null : name);\n};\n\nconst describeWidget = (widget: Gtk.Widget): string => {\n const accessibleName = attribute(\"accessible-name\", getWidgetAccessibleName(widget));\n const role = attribute(\"role\", formatRole(widget.getAccessibleRole()));\n\n return `<${getTypeTag(widget)}${accessibleName}${widgetNameAttribute(widget)}${role}>`;\n};\n\nconst waitForActionable = async (widget: Gtk.Widget): Promise<void> => {\n const timeout = getConfig().actionabilityTimeout;\n const deadline = now() + timeout;\n let failure = findActionabilityFailure(widget);\n\n while (failure !== null && now() < deadline) {\n await delay(ACTIONABLE_HOP_MS);\n failure = findActionabilityFailure(widget);\n }\n\n if (failure !== null) {\n throw new Error(\n `Cannot dispatch user event: ${describeWidget(widget)} did not become actionable ` +\n `within ${String(timeout)}ms because ${failure}`,\n );\n }\n};\n\nconst wrapEvent = async (widget: Gtk.Widget, body: () => void | PromiseLike<void>): Promise<void> => {\n await waitForActionable(widget);\n\n await runInAct(async () => {\n await body();\n });\n};\n\nexport { wrapEvent };\n"]}
|
|
@@ -31,10 +31,11 @@ type UserEvent = {
|
|
|
31
31
|
* itself, where the gestures that widget carries of its own still take the press and the same
|
|
32
32
|
* outcome is then applied through GTK's own public action: a list, grid, or column-view row is
|
|
33
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
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
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.
|
|
38
39
|
*/
|
|
39
40
|
click: typeof click;
|
|
40
41
|
/**
|
|
@@ -42,19 +43,23 @@ type UserEvent = {
|
|
|
42
43
|
* activation first, activating a list box row or flow box child on that path and replacing its
|
|
43
44
|
* container's selection whether or not that container activates on a single click. A widget
|
|
44
45
|
* whose click GTK4 implements itself receives that outcome once per press, so a row is selected
|
|
45
|
-
* and activated by the second press, a tree expander ends back where it started,
|
|
46
|
-
* header inverts its order after sorting.
|
|
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.
|
|
47
48
|
*/
|
|
48
49
|
dblClick: typeof dblClick;
|
|
49
50
|
/**
|
|
50
51
|
* Delivers a three-press click gesture the same way a double click is delivered, applying the
|
|
51
52
|
* same outcome to a list box row or flow box child, and applying the outcome GTK4 implements
|
|
52
|
-
* itself once per press to a row, tree expander, or column header.
|
|
53
|
+
* itself once per press to a row, tree expander, notebook tab, or column header.
|
|
53
54
|
*/
|
|
54
55
|
tripleClick: typeof tripleClick;
|
|
55
56
|
/** Moves focus within the widget's root, forward by default and backward with `isShiftHeld`. */
|
|
56
57
|
tab: typeof tab;
|
|
57
|
-
/**
|
|
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
|
+
*/
|
|
58
63
|
type: typeof type;
|
|
59
64
|
/** Focuses an editable widget and deletes its whole text, leaving nothing selected. */
|
|
60
65
|
clear: typeof clear;
|
|
@@ -62,7 +67,10 @@ type UserEvent = {
|
|
|
62
67
|
copy: typeof copy;
|
|
63
68
|
/** Writes an editable widget's current selection to the clipboard and deletes it. */
|
|
64
69
|
cut: typeof cut;
|
|
65
|
-
/**
|
|
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
|
+
*/
|
|
66
74
|
paste: typeof paste;
|
|
67
75
|
/**
|
|
68
76
|
* Selects the items at those positions in a view or drop-down, or selects the indexed children of
|
|
@@ -93,7 +101,25 @@ type UserEvent = {
|
|
|
93
101
|
slide: typeof slide;
|
|
94
102
|
/** Adds the delta to the adjustments of the widget itself, or of its nearest scrollable ancestor. */
|
|
95
103
|
scroll: typeof scroll;
|
|
96
|
-
/**
|
|
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
|
+
*/
|
|
97
123
|
keyboard: (widget: Gtk.Widget, input: string) => Promise<void>;
|
|
98
124
|
/**
|
|
99
125
|
* Applies a pointer token to the click gestures the widget already carries, tracking whether the
|
|
@@ -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;
|
|
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,E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,EAAE,KAAK,gBAAgB,EAAE,CAAC"}
|
package/dist/user-event/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { delay } from "../timers.js";
|
|
1
2
|
import { scroll, slide } from "./adjustment.js";
|
|
2
3
|
import { click, dblClick, tripleClick } from "./click.js";
|
|
3
4
|
import { drag, dragAndDrop, drop, hover, longPress, rotate, swipe, unhover, zoom } from "./gesture.js";
|
|
@@ -15,11 +16,11 @@ const userEvent = {
|
|
|
15
16
|
...createInstance(createInitialState(), {}),
|
|
16
17
|
setup: (options) => createInstance(createInitialState(), options ?? {}),
|
|
17
18
|
};
|
|
18
|
-
const settle = (
|
|
19
|
-
if (
|
|
19
|
+
const settle = (ms) => {
|
|
20
|
+
if (ms === null || ms === undefined) {
|
|
20
21
|
return Promise.resolve();
|
|
21
22
|
}
|
|
22
|
-
return
|
|
23
|
+
return delay(ms);
|
|
23
24
|
};
|
|
24
25
|
function createInstance(state, options) {
|
|
25
26
|
const after = (helper) => async (...args) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/user-event/index.ts"],"names":[],"mappings":"AACA,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;A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AAK,CAAC,KAAK,CAAC;QACnB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;QACjB,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;QACf,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;QACnB,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC;QACnC,eAAe,EAAE,KAAK,CAAC,eAAe,CAAC;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 { 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 column\n * header sorts by its column. A column-view cell and the row carrying the column headers stand\n * in the way of the click rather than taking it, so a click on either reaches the row or the\n * 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, and a column\n * 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, 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 /** Focuses an editable widget, applies any initial selection, and inserts the text at the cursor. */\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 /** Inserts the given text, or the clipboard's text, at an editable widget's cursor. */\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 /** Sends a key sequence, dispatching matching shortcuts and tracking held modifiers across calls. */\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 = (delay: number | null | undefined): Promise<void> => {\n if (delay === null || delay === undefined) {\n return Promise.resolve();\n }\n\n return new Promise((resolve) => setTimeout(resolve, delay));\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;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,EAAE;IAC5D,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,KAAK,CAAC,EAAE,CAAC,CAAC;AACrB,CAAC,CAAC;AAEF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C/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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../../src/user-event/keyboard.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,cAAc,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,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"}
|