@gtkx/testing 1.0.0-rc.3 → 1.0.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 +8 -9
- package/dist/accessible-native.d.ts +16 -0
- package/dist/accessible-native.d.ts.map +1 -0
- package/dist/accessible-native.js +206 -0
- package/dist/accessible-native.js.map +1 -0
- package/dist/act.d.ts +2 -0
- package/dist/act.d.ts.map +1 -1
- package/dist/act.js.map +1 -1
- package/dist/build-queries.d.ts +27 -10
- package/dist/build-queries.d.ts.map +1 -1
- package/dist/build-queries.js +39 -30
- package/dist/build-queries.js.map +1 -1
- package/dist/cleanup-registry.d.ts +1 -1
- package/dist/cleanup-registry.d.ts.map +1 -1
- package/dist/cleanup-registry.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -3
- package/dist/config.js.map +1 -1
- package/dist/errors.d.ts +10 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +12 -3
- package/dist/errors.js.map +1 -1
- package/dist/fire-event.d.ts +35 -6
- package/dist/fire-event.d.ts.map +1 -1
- package/dist/fire-event.js +23 -7
- package/dist/fire-event.js.map +1 -1
- package/dist/frame-sync.d.ts +2 -1
- package/dist/frame-sync.d.ts.map +1 -1
- package/dist/frame-sync.js +15 -5
- package/dist/frame-sync.js.map +1 -1
- package/dist/harness-window.d.ts +4 -0
- package/dist/harness-window.d.ts.map +1 -0
- package/dist/harness-window.js +6 -0
- package/dist/harness-window.js.map +1 -0
- package/dist/index.d.ts +14 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +4 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +4 -0
- package/dist/internal.js.map +1 -0
- package/dist/matchers.d.ts +125 -39
- package/dist/matchers.d.ts.map +1 -1
- package/dist/matchers.js +156 -18
- package/dist/matchers.js.map +1 -1
- package/dist/pretty-format.d.ts +2 -0
- package/dist/pretty-format.d.ts.map +1 -0
- package/dist/pretty-format.js +2 -0
- package/dist/pretty-format.js.map +1 -0
- package/dist/pretty-widget.d.ts +7 -3
- package/dist/pretty-widget.d.ts.map +1 -1
- package/dist/pretty-widget.js +74 -57
- package/dist/pretty-widget.js.map +1 -1
- package/dist/production.d.ts +8 -0
- package/dist/production.d.ts.map +1 -0
- package/dist/production.js +34 -0
- package/dist/production.js.map +1 -0
- package/dist/queries.d.ts +99 -56
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +123 -83
- package/dist/queries.js.map +1 -1
- package/dist/query-helpers.d.ts +44 -0
- package/dist/query-helpers.d.ts.map +1 -0
- package/dist/query-helpers.js +57 -0
- package/dist/query-helpers.js.map +1 -0
- package/dist/render-children.d.ts +9 -0
- package/dist/render-children.d.ts.map +1 -0
- package/dist/render-children.js +11 -0
- package/dist/render-children.js.map +1 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +13 -11
- package/dist/render.js.map +1 -1
- package/dist/role-helpers.d.ts +12 -3
- package/dist/role-helpers.d.ts.map +1 -1
- package/dist/role-helpers.js +13 -4
- package/dist/role-helpers.js.map +1 -1
- package/dist/role-naming.d.ts +5 -0
- package/dist/role-naming.d.ts.map +1 -0
- package/dist/role-naming.js +96 -0
- package/dist/role-naming.js.map +1 -0
- package/dist/screenshot.d.ts +12 -20
- package/dist/screenshot.d.ts.map +1 -1
- package/dist/screenshot.js +183 -91
- package/dist/screenshot.js.map +1 -1
- package/dist/suggestions.d.ts +3 -0
- package/dist/suggestions.d.ts.map +1 -1
- package/dist/suggestions.js.map +1 -1
- package/dist/traversal.d.ts +9 -1
- package/dist/traversal.d.ts.map +1 -1
- package/dist/traversal.js +26 -6
- package/dist/traversal.js.map +1 -1
- package/dist/types.d.ts +67 -17
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/user-event/adjustment.d.ts +16 -0
- package/dist/user-event/adjustment.d.ts.map +1 -1
- package/dist/user-event/adjustment.js +34 -2
- package/dist/user-event/adjustment.js.map +1 -1
- package/dist/user-event/click.d.ts +45 -3
- package/dist/user-event/click.d.ts.map +1 -1
- package/dist/user-event/click.js +177 -39
- package/dist/user-event/click.js.map +1 -1
- package/dist/user-event/column-header-click.d.ts +4 -0
- package/dist/user-event/column-header-click.d.ts.map +1 -0
- package/dist/user-event/column-header-click.js +65 -0
- package/dist/user-event/column-header-click.js.map +1 -0
- package/dist/user-event/controller.d.ts +29 -0
- package/dist/user-event/controller.d.ts.map +1 -1
- package/dist/user-event/controller.js +28 -0
- package/dist/user-event/controller.js.map +1 -1
- package/dist/user-event/event-wrapper.d.ts.map +1 -1
- package/dist/user-event/event-wrapper.js +2 -1
- package/dist/user-event/event-wrapper.js.map +1 -1
- package/dist/user-event/gesture.d.ts +51 -0
- package/dist/user-event/gesture.d.ts.map +1 -1
- package/dist/user-event/gesture.js +47 -4
- package/dist/user-event/gesture.js.map +1 -1
- package/dist/user-event/index.d.ts +70 -2
- package/dist/user-event/index.d.ts.map +1 -1
- package/dist/user-event/index.js +43 -26
- package/dist/user-event/index.js.map +1 -1
- package/dist/user-event/indexed-children.d.ts +10 -0
- package/dist/user-event/indexed-children.d.ts.map +1 -0
- package/dist/user-event/indexed-children.js +50 -0
- package/dist/user-event/indexed-children.js.map +1 -0
- package/dist/user-event/keyboard.d.ts +4 -2
- package/dist/user-event/keyboard.d.ts.map +1 -1
- package/dist/user-event/keyboard.js +46 -16
- package/dist/user-event/keyboard.js.map +1 -1
- package/dist/user-event/list-row-click.d.ts +4 -0
- package/dist/user-event/list-row-click.d.ts.map +1 -0
- package/dist/user-event/list-row-click.js +39 -0
- package/dist/user-event/list-row-click.js.map +1 -0
- package/dist/user-event/native-click.d.ts +6 -0
- package/dist/user-event/native-click.d.ts.map +1 -0
- package/dist/user-event/native-click.js +32 -0
- package/dist/user-event/native-click.js.map +1 -0
- package/dist/user-event/pointer.d.ts +1 -1
- package/dist/user-event/pointer.d.ts.map +1 -1
- package/dist/user-event/pointer.js +37 -13
- package/dist/user-event/pointer.js.map +1 -1
- package/dist/user-event/selection.d.ts +18 -0
- package/dist/user-event/selection.d.ts.map +1 -1
- package/dist/user-event/selection.js +56 -30
- package/dist/user-event/selection.js.map +1 -1
- package/dist/user-event/state.d.ts +1 -1
- package/dist/user-event/state.d.ts.map +1 -1
- package/dist/user-event/state.js +1 -1
- package/dist/user-event/state.js.map +1 -1
- package/dist/user-event/text.d.ts +34 -3
- package/dist/user-event/text.d.ts.map +1 -1
- package/dist/user-event/text.js +94 -17
- package/dist/user-event/text.js.map +1 -1
- package/dist/wait-for.d.ts +2 -0
- package/dist/wait-for.d.ts.map +1 -1
- package/dist/wait-for.js.map +1 -1
- package/dist/widget-accessible-properties.d.ts +14 -10
- package/dist/widget-accessible-properties.d.ts.map +1 -1
- package/dist/widget-accessible-properties.js +135 -173
- package/dist/widget-accessible-properties.js.map +1 -1
- package/dist/widget-getters.d.ts +8 -0
- package/dist/widget-getters.d.ts.map +1 -0
- package/dist/widget-getters.js +19 -0
- package/dist/widget-getters.js.map +1 -0
- package/dist/within.d.ts +3 -2
- package/dist/within.d.ts.map +1 -1
- package/dist/within.js +3 -2
- package/dist/within.js.map +1 -1
- package/package.json +13 -8
- package/src/accessible-native.ts +333 -0
- package/src/act.ts +2 -0
- package/src/build-queries.ts +66 -48
- package/src/cleanup-registry.ts +1 -1
- package/src/config.ts +4 -3
- package/src/errors.ts +14 -3
- package/src/fire-event.ts +61 -8
- package/src/frame-sync.ts +21 -5
- package/src/harness-window.ts +9 -0
- package/src/index.ts +18 -11
- package/src/internal.ts +11 -0
- package/src/matchers.ts +466 -64
- package/src/pretty-format.ts +1 -0
- package/src/pretty-widget.ts +100 -72
- package/src/production.ts +52 -0
- package/src/queries.ts +128 -89
- package/src/query-helpers.ts +97 -0
- package/src/render-children.ts +25 -0
- package/src/render.tsx +18 -13
- package/src/role-helpers.ts +14 -4
- package/src/role-naming.ts +99 -0
- package/src/screenshot.ts +272 -103
- package/src/suggestions.ts +3 -0
- package/src/traversal.ts +49 -6
- package/src/types.ts +69 -19
- package/src/user-event/adjustment.ts +42 -2
- package/src/user-event/click.ts +248 -46
- package/src/user-event/column-header-click.ts +90 -0
- package/src/user-event/controller.ts +29 -0
- package/src/user-event/event-wrapper.ts +3 -1
- package/src/user-event/gesture.ts +57 -6
- package/src/user-event/index.ts +119 -29
- package/src/user-event/indexed-children.ts +75 -0
- package/src/user-event/keyboard.ts +70 -20
- package/src/user-event/list-row-click.ts +57 -0
- package/src/user-event/native-click.ts +46 -0
- package/src/user-event/pointer.ts +52 -13
- package/src/user-event/selection.ts +74 -33
- package/src/user-event/state.ts +2 -2
- package/src/user-event/text.ts +121 -23
- package/src/wait-for.ts +2 -0
- package/src/widget-accessible-properties.ts +183 -214
- package/src/widget-getters.ts +32 -0
- package/src/within.ts +3 -2
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getInstanceType, typeName } from "@gtkx/runtime";
|
|
2
|
+
const getWidgetMethod = (widget, name) => Reflect.get(widget, name);
|
|
3
|
+
const getWidgetTypeName = (widget) => typeName(getInstanceType(widget));
|
|
4
|
+
const hasWidgetMethod = (widget, name) => typeof getWidgetMethod(widget, name) === "function";
|
|
5
|
+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- callers name the signature */
|
|
6
|
+
const getCallableMethod = (widget, name) => {
|
|
7
|
+
const fn = getWidgetMethod(widget, name);
|
|
8
|
+
return typeof fn === "function" ? fn.bind(widget) : null;
|
|
9
|
+
};
|
|
10
|
+
const callBooleanGetter = (widget, method) => {
|
|
11
|
+
const value = getCallableMethod(widget, method)?.();
|
|
12
|
+
return typeof value === "boolean" ? value : null;
|
|
13
|
+
};
|
|
14
|
+
const callStringGetter = (widget, method) => {
|
|
15
|
+
const value = getCallableMethod(widget, method)?.();
|
|
16
|
+
return typeof value === "string" ? value : null;
|
|
17
|
+
};
|
|
18
|
+
export { callBooleanGetter, callStringGetter, getCallableMethod, getWidgetTypeName, hasWidgetMethod };
|
|
19
|
+
//# sourceMappingURL=widget-getters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-getters.js","sourceRoot":"","sources":["../src/widget-getters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,eAAe,GAAG,CAAC,MAAkB,EAAE,IAAY,EAAW,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACjG,MAAM,iBAAiB,GAAG,CAAC,MAAkB,EAAiB,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;AAEnG,MAAM,eAAe,GAAG,CAAC,MAAkB,EAAE,IAAY,EAAW,EAAE,CAClE,OAAO,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,UAAU,CAAC;AAExD,8GAA8G;AAC9G,MAAM,iBAAiB,GAAG,CACtB,MAAkB,EAClB,IAAY,EACsB,EAAE;IACpC,MAAM,EAAE,GAAG,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAEzC,OAAO,OAAO,EAAE,KAAK,UAAU,CAAC,CAAC,CAAE,EAAgC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5F,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,MAAkB,EAAE,MAAc,EAAkB,EAAE;IAC7E,MAAM,KAAK,GAAG,iBAAiB,CAAc,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;IAEjE,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACrD,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,MAAkB,EAAE,MAAc,EAAiB,EAAE;IAC3E,MAAM,KAAK,GAAG,iBAAiB,CAAc,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;IAEjE,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACpD,CAAC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { getInstanceType, typeName } from \"@gtkx/runtime\";\n\nconst getWidgetMethod = (widget: Gtk.Widget, name: string): unknown => Reflect.get(widget, name);\nconst getWidgetTypeName = (widget: Gtk.Widget): string | null => typeName(getInstanceType(widget));\n\nconst hasWidgetMethod = (widget: Gtk.Widget, name: string): boolean =>\n typeof getWidgetMethod(widget, name) === \"function\";\n\n/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- callers name the signature */\nconst getCallableMethod = <Args extends unknown[], Result>(\n widget: Gtk.Widget,\n name: string,\n): ((...args: Args) => Result) | null => {\n const fn = getWidgetMethod(widget, name);\n\n return typeof fn === \"function\" ? (fn as (...args: Args) => Result).bind(widget) : null;\n};\n\nconst callBooleanGetter = (widget: Gtk.Widget, method: string): boolean | null => {\n const value = getCallableMethod<[], unknown>(widget, method)?.();\n\n return typeof value === \"boolean\" ? value : null;\n};\n\nconst callStringGetter = (widget: Gtk.Widget, method: string): string | null => {\n const value = getCallableMethod<[], unknown>(widget, method)?.();\n\n return typeof value === \"string\" ? value : null;\n};\n\nexport { callBooleanGetter, callStringGetter, getCallableMethod, getWidgetTypeName, hasWidgetMethod };\n"]}
|
package/dist/within.d.ts
CHANGED
|
@@ -3,12 +3,13 @@ import type { Container } from "./traversal.js";
|
|
|
3
3
|
import type { BoundCustomQueries, QueryMap } from "./types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Binds the built-in queries, and any custom queries, to a specific container
|
|
6
|
-
* so they search only within that scope.
|
|
6
|
+
* so they search only within that scope. Also exported as `getQueriesForElement`,
|
|
7
|
+
* which reads better in library code.
|
|
7
8
|
*
|
|
8
9
|
* @param container The scope the returned queries operate on.
|
|
9
10
|
* @param queries Optional custom queries to bind alongside the built-in ones.
|
|
10
11
|
* @returns The queries bound to the container.
|
|
11
12
|
*/
|
|
12
13
|
declare const within: <Q extends QueryMap = Record<never, never>>(container: Container, queries?: Q) => BoundQueries & BoundCustomQueries<Q>;
|
|
13
|
-
export { within };
|
|
14
|
+
export { within, within as getQueriesForElement };
|
|
14
15
|
//# sourceMappingURL=within.d.ts.map
|
package/dist/within.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"within.d.ts","sourceRoot":"","sources":["../src/within.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAc/D
|
|
1
|
+
{"version":3,"file":"within.d.ts","sourceRoot":"","sources":["../src/within.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAc/D;;;;;;;;GAQG;AACH,QAAA,MAAM,MAAM,GAAI,CAAC,SAAS,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EACrD,WAAW,SAAS,EACpB,UAAU,CAAC,KACZ,YAAY,GAAG,kBAAkB,CAAC,CAAC,CAGpC,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,oBAAoB,EAAE,CAAC"}
|
package/dist/within.js
CHANGED
|
@@ -6,7 +6,8 @@ const bindCustomQueries = (customQueries, container) => {
|
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* Binds the built-in queries, and any custom queries, to a specific container
|
|
9
|
-
* so they search only within that scope.
|
|
9
|
+
* so they search only within that scope. Also exported as `getQueriesForElement`,
|
|
10
|
+
* which reads better in library code.
|
|
10
11
|
*
|
|
11
12
|
* @param container The scope the returned queries operate on.
|
|
12
13
|
* @param queries Optional custom queries to bind alongside the built-in ones.
|
|
@@ -16,5 +17,5 @@ const within = (container, queries) => ({
|
|
|
16
17
|
...bindCustomQueries(builtinQueries, container),
|
|
17
18
|
...(queries ? bindCustomQueries(queries, container) : {}),
|
|
18
19
|
});
|
|
19
|
-
export { within };
|
|
20
|
+
export { within, within as getQueriesForElement };
|
|
20
21
|
//# sourceMappingURL=within.js.map
|
package/dist/within.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"within.js","sourceRoot":"","sources":["../src/within.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,SAAS,GACX,CAAiC,KAAsD,EAAE,SAAoB,EAAE,EAAE,CAC7G,CAAC,GAAG,IAAU,EAAU,EAAE,CACtB,KAAK,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;AAEtC,MAAM,iBAAiB,GAAG,CAAqB,aAAgB,EAAE,SAAoB,EAAyB,EAAE;IAC5G,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,CAAU,CAAC,CAAC;IAEjH,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAA0B,CAAC;AAChE,CAAC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"within.js","sourceRoot":"","sources":["../src/within.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,SAAS,GACX,CAAiC,KAAsD,EAAE,SAAoB,EAAE,EAAE,CAC7G,CAAC,GAAG,IAAU,EAAU,EAAE,CACtB,KAAK,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;AAEtC,MAAM,iBAAiB,GAAG,CAAqB,aAAgB,EAAE,SAAoB,EAAyB,EAAE;IAC5G,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,CAAU,CAAC,CAAC;IAEjH,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAA0B,CAAC;AAChE,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,GAAG,CACX,SAAoB,EACpB,OAAW,EACyB,EAAE,CAAC,CAAC;IACxC,GAAI,iBAAiB,CAAC,cAAc,EAAE,SAAS,CAAkB;IACjE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAE,EAA4B,CAAC;CACvF,CAAC,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,oBAAoB,EAAE,CAAC","sourcesContent":["import type { BoundQueries } from \"./bound-queries.js\";\nimport type { Container } from \"./traversal.js\";\nimport type { BoundCustomQueries, QueryMap } from \"./types.js\";\nimport { builtinQueries } from \"./queries.js\";\n\nconst bindQuery =\n <Args extends unknown[], Result>(query: (container: Container, ...args: Args) => Result, container: Container) =>\n (...args: Args): Result =>\n query(container, ...args);\n\nconst bindCustomQueries = <Q extends QueryMap>(customQueries: Q, container: Container): BoundCustomQueries<Q> => {\n const entries = Object.entries(customQueries).map(([key, query]) => [key, bindQuery(query, container)] as const);\n\n return Object.fromEntries(entries) as BoundCustomQueries<Q>;\n};\n\n/**\n * Binds the built-in queries, and any custom queries, to a specific container\n * so they search only within that scope. Also exported as `getQueriesForElement`,\n * which reads better in library code.\n *\n * @param container The scope the returned queries operate on.\n * @param queries Optional custom queries to bind alongside the built-in ones.\n * @returns The queries bound to the container.\n */\nconst within = <Q extends QueryMap = Record<never, never>>(\n container: Container,\n queries?: Q,\n): BoundQueries & BoundCustomQueries<Q> => ({\n ...(bindCustomQueries(builtinQueries, container) as BoundQueries),\n ...(queries ? bindCustomQueries(queries, container) : ({} as BoundCustomQueries<Q>)),\n});\n\nexport { within, within as getQueriesForElement };\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/testing",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Testing Library-style queries, user events, and screenshots for GTK4 widget trees rendered by GTKX",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
".": {
|
|
31
31
|
"types": "./dist/index.d.ts",
|
|
32
32
|
"default": "./dist/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./internal": {
|
|
35
|
+
"types": "./dist/internal.d.ts",
|
|
36
|
+
"default": "./dist/internal.js"
|
|
33
37
|
}
|
|
34
38
|
},
|
|
35
39
|
"sideEffects": [
|
|
@@ -44,20 +48,21 @@
|
|
|
44
48
|
"node": ">=24"
|
|
45
49
|
},
|
|
46
50
|
"dependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"@gtkx/
|
|
51
|
+
"@vitest/expect": "^4.1.10",
|
|
52
|
+
"@vitest/pretty-format": "^4.1.10",
|
|
53
|
+
"@gtkx/react": "1.0.0",
|
|
54
|
+
"@gtkx/utils": "1.0.0",
|
|
55
|
+
"@gtkx/runtime": "1.0.0"
|
|
50
56
|
},
|
|
51
57
|
"peerDependencies": {
|
|
52
58
|
"@types/react": "^19.2",
|
|
53
59
|
"react": "^19.2"
|
|
54
60
|
},
|
|
55
61
|
"devDependencies": {
|
|
56
|
-
"@types/react": "^19.2.
|
|
57
|
-
"@vitest/expect": "^4.1.10",
|
|
62
|
+
"@types/react": "^19.2.18",
|
|
58
63
|
"vitest": "^4.1.10",
|
|
59
|
-
"@gtkx/config": "1.0.0
|
|
60
|
-
"@gtkx/vitest": "1.0.0
|
|
64
|
+
"@gtkx/config": "1.0.0",
|
|
65
|
+
"@gtkx/vitest": "1.0.0"
|
|
61
66
|
},
|
|
62
67
|
"scripts": {
|
|
63
68
|
"release": "tsx ../../scripts/release-package.ts"
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
+
import { getHandle, t } from "@gtkx/runtime";
|
|
3
|
+
|
|
4
|
+
type CheckInt = (handle: unknown, attribute: number, expected: number) => string | null;
|
|
5
|
+
type CheckString = (handle: unknown, attribute: number, expected: string | null) => string | null;
|
|
6
|
+
type CheckDouble = (handle: unknown, attribute: number, expected: number) => string | null;
|
|
7
|
+
type CheckRelation = (...args: unknown[]) => string | null;
|
|
8
|
+
/** A value GTK holds for an accessible property: a string, a number, a token, or a boolean. */
|
|
9
|
+
type AccessibleAttributeValue = boolean | number | string;
|
|
10
|
+
type PropertyReader = (accessible: Gtk.Accessible, property: Gtk.AccessibleProperty) => AccessibleAttributeValue | null;
|
|
11
|
+
type NativeCall = (...inputs: unknown[]) => unknown;
|
|
12
|
+
type CheckArg = typeof DOUBLE_ARG | typeof INT_ARG | typeof OBJECT_ARG | typeof STRING_ARG;
|
|
13
|
+
|
|
14
|
+
const LIB = "libgtk-4.so.1";
|
|
15
|
+
const MAX_RELATION_TARGETS = 8;
|
|
16
|
+
const relationBindings: Map<number, CheckRelation> = new Map();
|
|
17
|
+
|
|
18
|
+
const REVERSE_RELATIONS: Partial<Record<Gtk.AccessibleRelation, Gtk.AccessibleRelation>> = {
|
|
19
|
+
[Gtk.AccessibleRelation.LABELLED_BY]: Gtk.AccessibleRelation.LABEL_FOR,
|
|
20
|
+
[Gtk.AccessibleRelation.DESCRIBED_BY]: Gtk.AccessibleRelation.DESCRIPTION_FOR,
|
|
21
|
+
[Gtk.AccessibleRelation.ERROR_MESSAGE]: Gtk.AccessibleRelation.ERROR_MESSAGE_FOR,
|
|
22
|
+
[Gtk.AccessibleRelation.CONTROLS]: Gtk.AccessibleRelation.CONTROLLED_BY,
|
|
23
|
+
[Gtk.AccessibleRelation.DETAILS]: Gtk.AccessibleRelation.DETAILS_FOR,
|
|
24
|
+
[Gtk.AccessibleRelation.FLOW_TO]: Gtk.AccessibleRelation.FLOW_FROM,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const UNDEFINED_VALUE = -1;
|
|
28
|
+
const INT_SENTINEL = -2_147_483_648;
|
|
29
|
+
const NUMBER_SENTINEL = -Number.MAX_VALUE;
|
|
30
|
+
const ACCESSIBLE_NUMBER_TOLERANCE = 0.001;
|
|
31
|
+
const BOOLEAN_DOMAIN = [0, 1];
|
|
32
|
+
const OPTIONAL_BOOLEAN_DOMAIN = [0, 1, UNDEFINED_VALUE];
|
|
33
|
+
const TRISTATE_DOMAIN = [Gtk.AccessibleTristate.FALSE, Gtk.AccessibleTristate.TRUE, Gtk.AccessibleTristate.MIXED];
|
|
34
|
+
|
|
35
|
+
const INVALID_DOMAIN = [
|
|
36
|
+
Gtk.AccessibleInvalidState.FALSE,
|
|
37
|
+
Gtk.AccessibleInvalidState.TRUE,
|
|
38
|
+
Gtk.AccessibleInvalidState.GRAMMAR,
|
|
39
|
+
Gtk.AccessibleInvalidState.SPELLING,
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const STATE_DOMAINS: Partial<Record<Gtk.AccessibleState, number[]>> = {
|
|
43
|
+
[Gtk.AccessibleState.BUSY]: BOOLEAN_DOMAIN,
|
|
44
|
+
[Gtk.AccessibleState.CHECKED]: TRISTATE_DOMAIN,
|
|
45
|
+
[Gtk.AccessibleState.DISABLED]: BOOLEAN_DOMAIN,
|
|
46
|
+
[Gtk.AccessibleState.EXPANDED]: OPTIONAL_BOOLEAN_DOMAIN,
|
|
47
|
+
[Gtk.AccessibleState.HIDDEN]: BOOLEAN_DOMAIN,
|
|
48
|
+
[Gtk.AccessibleState.INVALID]: INVALID_DOMAIN,
|
|
49
|
+
[Gtk.AccessibleState.PRESSED]: TRISTATE_DOMAIN,
|
|
50
|
+
[Gtk.AccessibleState.SELECTED]: OPTIONAL_BOOLEAN_DOMAIN,
|
|
51
|
+
[Gtk.AccessibleState.VISITED]: OPTIONAL_BOOLEAN_DOMAIN,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const AUTOCOMPLETE_DOMAIN = [
|
|
55
|
+
Gtk.AccessibleAutocomplete.NONE,
|
|
56
|
+
Gtk.AccessibleAutocomplete.INLINE,
|
|
57
|
+
Gtk.AccessibleAutocomplete.LIST,
|
|
58
|
+
Gtk.AccessibleAutocomplete.BOTH,
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
const ORIENTATION_DOMAIN = [Gtk.Orientation.HORIZONTAL, Gtk.Orientation.VERTICAL];
|
|
62
|
+
|
|
63
|
+
const SORT_DOMAIN = [
|
|
64
|
+
Gtk.AccessibleSort.NONE,
|
|
65
|
+
Gtk.AccessibleSort.ASCENDING,
|
|
66
|
+
Gtk.AccessibleSort.DESCENDING,
|
|
67
|
+
Gtk.AccessibleSort.OTHER,
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
const TOKEN_DOMAINS: Partial<Record<Gtk.AccessibleProperty, number[]>> = {
|
|
71
|
+
[Gtk.AccessibleProperty.AUTOCOMPLETE]: AUTOCOMPLETE_DOMAIN,
|
|
72
|
+
[Gtk.AccessibleProperty.ORIENTATION]: ORIENTATION_DOMAIN,
|
|
73
|
+
[Gtk.AccessibleProperty.SORT]: SORT_DOMAIN,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const STRING_PROPERTIES: Set<Gtk.AccessibleProperty> = new Set<Gtk.AccessibleProperty>([
|
|
77
|
+
Gtk.AccessibleProperty.DESCRIPTION,
|
|
78
|
+
Gtk.AccessibleProperty.HELP_TEXT,
|
|
79
|
+
Gtk.AccessibleProperty.KEY_SHORTCUTS,
|
|
80
|
+
Gtk.AccessibleProperty.LABEL,
|
|
81
|
+
Gtk.AccessibleProperty.PLACEHOLDER,
|
|
82
|
+
Gtk.AccessibleProperty.ROLE_DESCRIPTION,
|
|
83
|
+
Gtk.AccessibleProperty.VALUE_TEXT,
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
const BOOLEAN_PROPERTIES: Set<Gtk.AccessibleProperty> = new Set<Gtk.AccessibleProperty>([
|
|
87
|
+
Gtk.AccessibleProperty.HAS_POPUP,
|
|
88
|
+
Gtk.AccessibleProperty.MODAL,
|
|
89
|
+
Gtk.AccessibleProperty.MULTI_LINE,
|
|
90
|
+
Gtk.AccessibleProperty.MULTI_SELECTABLE,
|
|
91
|
+
Gtk.AccessibleProperty.READ_ONLY,
|
|
92
|
+
Gtk.AccessibleProperty.REQUIRED,
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
const NUMBER_PROPERTIES: Set<Gtk.AccessibleProperty> = new Set<Gtk.AccessibleProperty>([
|
|
96
|
+
Gtk.AccessibleProperty.VALUE_MAX,
|
|
97
|
+
Gtk.AccessibleProperty.VALUE_MIN,
|
|
98
|
+
Gtk.AccessibleProperty.VALUE_NOW,
|
|
99
|
+
]);
|
|
100
|
+
|
|
101
|
+
const OBJECT_ARG = { type: t.object("borrowed") };
|
|
102
|
+
const INT_ARG = { type: t.int32 };
|
|
103
|
+
const DOUBLE_ARG = { type: t.float64 };
|
|
104
|
+
const STRING_ARG = { type: t.string("borrowed") };
|
|
105
|
+
const CHECK_PROPERTY = "gtk_test_accessible_check_property";
|
|
106
|
+
const checkStateInt = buildAccessibleCheck("gtk_test_accessible_check_state", [INT_ARG]) as CheckInt;
|
|
107
|
+
const checkPropertyInt = buildAccessibleCheck(CHECK_PROPERTY, [INT_ARG]) as CheckInt;
|
|
108
|
+
const checkPropertyDouble = buildAccessibleCheck(CHECK_PROPERTY, [DOUBLE_ARG]) as CheckDouble;
|
|
109
|
+
const checkPropertyString = buildAccessibleCheck(CHECK_PROPERTY, [STRING_ARG]) as CheckString;
|
|
110
|
+
|
|
111
|
+
function buildAccessibleCheck(symbol: string, varargs: CheckArg[]): NativeCall {
|
|
112
|
+
return t.fn(LIB, symbol, {
|
|
113
|
+
args: [OBJECT_ARG, INT_ARG, ...varargs],
|
|
114
|
+
returns: t.string("full"),
|
|
115
|
+
fixedArgCount: 2,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const buildRelationBinding = (targetCount: number): CheckRelation => {
|
|
120
|
+
const targets = Array.from({ length: targetCount + 1 }, () => OBJECT_ARG);
|
|
121
|
+
|
|
122
|
+
return buildAccessibleCheck("gtk_test_accessible_check_relation", targets) as CheckRelation;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const relationBindingFor = (targetCount: number): CheckRelation => {
|
|
126
|
+
const cached = relationBindings.get(targetCount);
|
|
127
|
+
|
|
128
|
+
if (cached !== undefined) {
|
|
129
|
+
return cached;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const built = buildRelationBinding(targetCount);
|
|
133
|
+
relationBindings.set(targetCount, built);
|
|
134
|
+
|
|
135
|
+
return built;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const isRelationExactly = (
|
|
139
|
+
accessible: Gtk.Accessible,
|
|
140
|
+
relation: Gtk.AccessibleRelation,
|
|
141
|
+
candidate: Gtk.Accessible,
|
|
142
|
+
targetCount: number,
|
|
143
|
+
): boolean => {
|
|
144
|
+
const call = relationBindingFor(targetCount);
|
|
145
|
+
const repeated = Array.from({ length: targetCount }, () => getHandle(candidate));
|
|
146
|
+
|
|
147
|
+
return call(getHandle(accessible), relation, ...repeated, null) === null;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const hasRelationSize = (
|
|
151
|
+
accessible: Gtk.Accessible,
|
|
152
|
+
relation: Gtk.AccessibleRelation,
|
|
153
|
+
candidates: Gtk.Accessible[],
|
|
154
|
+
size: number,
|
|
155
|
+
): boolean => candidates.some((candidate) => isRelationExactly(accessible, relation, candidate, size));
|
|
156
|
+
|
|
157
|
+
const findRelationSize = (
|
|
158
|
+
accessible: Gtk.Accessible,
|
|
159
|
+
relation: Gtk.AccessibleRelation,
|
|
160
|
+
candidates: Gtk.Accessible[],
|
|
161
|
+
): number => {
|
|
162
|
+
for (let size = 1; size <= MAX_RELATION_TARGETS; size += 1) {
|
|
163
|
+
if (hasRelationSize(accessible, relation, candidates, size)) {
|
|
164
|
+
return size;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return 0;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const possibleTargets = (relation: Gtk.AccessibleRelation, candidates: Gtk.Accessible[]): Gtk.Accessible[] => {
|
|
172
|
+
const reverse = REVERSE_RELATIONS[relation];
|
|
173
|
+
|
|
174
|
+
if (reverse === undefined) {
|
|
175
|
+
return candidates;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return candidates.filter((candidate) => Gtk.testAccessibleHasRelation(candidate, reverse));
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const readAccessibleRelation = (
|
|
182
|
+
accessible: Gtk.Accessible,
|
|
183
|
+
relation: Gtk.AccessibleRelation,
|
|
184
|
+
pool: Gtk.Accessible[],
|
|
185
|
+
): Gtk.Accessible[] => {
|
|
186
|
+
if (!Gtk.testAccessibleHasRelation(accessible, relation)) {
|
|
187
|
+
return [];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const candidates = possibleTargets(relation, pool);
|
|
191
|
+
const size = findRelationSize(accessible, relation, candidates);
|
|
192
|
+
|
|
193
|
+
if (size === 0) {
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return candidates.filter((candidate) => isRelationExactly(accessible, relation, candidate, size));
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const memberOfDomain = (check: CheckInt, handle: unknown, attribute: number, domain: number[]): number | null => {
|
|
201
|
+
for (const candidate of domain) {
|
|
202
|
+
if (check(handle, attribute, candidate) === null) {
|
|
203
|
+
return candidate;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return null;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const readAccessibleState = (accessible: Gtk.Accessible, state: Gtk.AccessibleState): number | null => {
|
|
211
|
+
const domain = STATE_DOMAINS[state];
|
|
212
|
+
|
|
213
|
+
if (domain === undefined || !Gtk.testAccessibleHasState(accessible, state)) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const member = memberOfDomain(checkStateInt, getHandle(accessible), state, domain);
|
|
218
|
+
|
|
219
|
+
return member === UNDEFINED_VALUE ? null : member;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const readAccessibleFlag = (accessible: Gtk.Accessible, state: Gtk.AccessibleState): boolean | null => {
|
|
223
|
+
const value = readAccessibleState(accessible, state);
|
|
224
|
+
|
|
225
|
+
return value === null ? null : value === 1;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const readAccessibleString = (accessible: Gtk.Accessible, property: Gtk.AccessibleProperty): string | null => {
|
|
229
|
+
if (!Gtk.testAccessibleHasProperty(accessible, property)) {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return checkPropertyString(getHandle(accessible), property, null);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const readAccessibleToken = (
|
|
237
|
+
accessible: Gtk.Accessible,
|
|
238
|
+
property: Gtk.AccessibleProperty,
|
|
239
|
+
domain: number[],
|
|
240
|
+
): number | null => {
|
|
241
|
+
if (!Gtk.testAccessibleHasProperty(accessible, property)) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return memberOfDomain(checkPropertyInt, getHandle(accessible), property, domain);
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const readAccessibleBooleanProperty = (
|
|
249
|
+
accessible: Gtk.Accessible,
|
|
250
|
+
property: Gtk.AccessibleProperty,
|
|
251
|
+
): boolean | null => {
|
|
252
|
+
const member = readAccessibleToken(accessible, property, BOOLEAN_DOMAIN);
|
|
253
|
+
|
|
254
|
+
return member === null ? null : member === 1;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
const readAgainstSentinel = (
|
|
258
|
+
check: CheckDouble,
|
|
259
|
+
sentinel: number,
|
|
260
|
+
accessible: Gtk.Accessible,
|
|
261
|
+
property: Gtk.AccessibleProperty,
|
|
262
|
+
): number | null => {
|
|
263
|
+
if (!Gtk.testAccessibleHasProperty(accessible, property)) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const reported = check(getHandle(accessible), property, sentinel);
|
|
268
|
+
|
|
269
|
+
return reported === null ? sentinel : Number(reported);
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
const readAccessibleInt = (accessible: Gtk.Accessible, property: Gtk.AccessibleProperty): number | null =>
|
|
273
|
+
readAgainstSentinel(checkPropertyInt, INT_SENTINEL, accessible, property);
|
|
274
|
+
|
|
275
|
+
const readAccessibleNumber = (accessible: Gtk.Accessible, property: Gtk.AccessibleProperty): number | null =>
|
|
276
|
+
readAgainstSentinel(checkPropertyDouble, NUMBER_SENTINEL, accessible, property);
|
|
277
|
+
|
|
278
|
+
const isAccessibleNumberProperty = (property: Gtk.AccessibleProperty): boolean => NUMBER_PROPERTIES.has(property);
|
|
279
|
+
|
|
280
|
+
const isAccessibleNumberMatch = (
|
|
281
|
+
accessible: Gtk.Accessible,
|
|
282
|
+
property: Gtk.AccessibleProperty,
|
|
283
|
+
expected: number,
|
|
284
|
+
): boolean =>
|
|
285
|
+
Gtk.testAccessibleHasProperty(accessible, property) &&
|
|
286
|
+
checkPropertyDouble(getHandle(accessible), property, expected) === null;
|
|
287
|
+
|
|
288
|
+
const tokenReaderFor =
|
|
289
|
+
(domain: number[]): PropertyReader =>
|
|
290
|
+
(accessible, property) =>
|
|
291
|
+
readAccessibleToken(accessible, property, domain);
|
|
292
|
+
|
|
293
|
+
const propertyReaderFor = (property: Gtk.AccessibleProperty): PropertyReader => {
|
|
294
|
+
const domain = TOKEN_DOMAINS[property];
|
|
295
|
+
|
|
296
|
+
if (domain !== undefined) {
|
|
297
|
+
return tokenReaderFor(domain);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (STRING_PROPERTIES.has(property)) {
|
|
301
|
+
return readAccessibleString;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (BOOLEAN_PROPERTIES.has(property)) {
|
|
305
|
+
return readAccessibleBooleanProperty;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (NUMBER_PROPERTIES.has(property)) {
|
|
309
|
+
return readAccessibleNumber;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return readAccessibleInt;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
const readAccessibleProperty = (
|
|
316
|
+
accessible: Gtk.Accessible,
|
|
317
|
+
property: Gtk.AccessibleProperty,
|
|
318
|
+
): AccessibleAttributeValue | null => propertyReaderFor(property)(accessible, property);
|
|
319
|
+
|
|
320
|
+
export {
|
|
321
|
+
ACCESSIBLE_NUMBER_TOLERANCE,
|
|
322
|
+
isAccessibleNumberMatch,
|
|
323
|
+
isAccessibleNumberProperty,
|
|
324
|
+
readAccessibleBooleanProperty,
|
|
325
|
+
readAccessibleFlag,
|
|
326
|
+
readAccessibleInt,
|
|
327
|
+
readAccessibleNumber,
|
|
328
|
+
readAccessibleProperty,
|
|
329
|
+
readAccessibleRelation,
|
|
330
|
+
readAccessibleState,
|
|
331
|
+
readAccessibleString,
|
|
332
|
+
type AccessibleAttributeValue,
|
|
333
|
+
};
|
package/src/act.ts
CHANGED
|
@@ -4,7 +4,9 @@ declare global {
|
|
|
4
4
|
var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
/** Work run inside the act environment, either synchronous or asynchronous. */
|
|
7
8
|
type ActCallback<T> = () => T | PromiseLike<T>;
|
|
9
|
+
/** Runs a callback inside React's act environment and settles with its result once updates flush. */
|
|
8
10
|
type ActImplementation = <T>(callback: ActCallback<T>) => PromiseLike<T>;
|
|
9
11
|
|
|
10
12
|
const actImplementation: ActImplementation = reactAct;
|