@gtkx/testing 1.0.0-rc.1 → 1.0.0-rc.3
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/dist/act.d.ts +6 -6
- package/dist/act.d.ts.map +1 -1
- package/dist/act.js +34 -26
- package/dist/act.js.map +1 -1
- package/dist/bound-queries.d.ts +5 -5
- package/dist/bound-queries.d.ts.map +1 -1
- package/dist/bound-queries.js.map +1 -1
- package/dist/build-queries.d.ts +5 -5
- package/dist/build-queries.d.ts.map +1 -1
- package/dist/build-queries.js +21 -9
- package/dist/build-queries.js.map +1 -1
- package/dist/cleanup-registry.d.ts +4 -3
- package/dist/cleanup-registry.d.ts.map +1 -1
- package/dist/cleanup-registry.js +13 -3
- package/dist/cleanup-registry.js.map +1 -1
- package/dist/config.d.ts +5 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +11 -9
- package/dist/config.js.map +1 -1
- package/dist/editable.d.ts +6 -5
- package/dist/editable.d.ts.map +1 -1
- package/dist/editable.js +7 -5
- package/dist/editable.js.map +1 -1
- package/dist/errors.d.ts +7 -6
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +64 -48
- package/dist/errors.js.map +1 -1
- package/dist/fire-event.d.ts +2 -1
- package/dist/fire-event.d.ts.map +1 -1
- package/dist/fire-event.js +2 -1
- 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 +28 -21
- package/dist/frame-sync.js.map +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/matchers.d.ts +99 -35
- package/dist/matchers.d.ts.map +1 -1
- package/dist/matchers.js +314 -63
- package/dist/matchers.js.map +1 -1
- package/dist/normalize.d.ts +10 -0
- package/dist/normalize.d.ts.map +1 -0
- package/dist/normalize.js +20 -0
- package/dist/normalize.js.map +1 -0
- package/dist/pretty-widget.d.ts +6 -4
- package/dist/pretty-widget.d.ts.map +1 -1
- package/dist/pretty-widget.js +64 -24
- package/dist/pretty-widget.js.map +1 -1
- package/dist/queries.d.ts +129 -90
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +235 -164
- package/dist/queries.js.map +1 -1
- package/dist/register-test-hooks.js +2 -1
- package/dist/register-test-hooks.js.map +1 -1
- package/dist/render-hook.d.ts +3 -2
- package/dist/render-hook.d.ts.map +1 -1
- package/dist/render-hook.js +2 -1
- package/dist/render-hook.js.map +1 -1
- package/dist/render.d.ts +3 -2
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +25 -19
- package/dist/render.js.map +1 -1
- package/dist/role-helpers.d.ts +6 -5
- package/dist/role-helpers.d.ts.map +1 -1
- package/dist/role-helpers.js +16 -12
- package/dist/role-helpers.js.map +1 -1
- package/dist/screen.d.ts +4 -3
- package/dist/screen.d.ts.map +1 -1
- package/dist/screen.js +13 -11
- package/dist/screen.js.map +1 -1
- package/dist/screenshot.d.ts +4 -3
- package/dist/screenshot.d.ts.map +1 -1
- package/dist/screenshot.js +43 -36
- package/dist/screenshot.js.map +1 -1
- package/dist/suggestions.d.ts +11 -6
- package/dist/suggestions.d.ts.map +1 -1
- package/dist/suggestions.js +10 -5
- package/dist/suggestions.js.map +1 -1
- package/dist/traversal.d.ts +7 -7
- package/dist/traversal.d.ts.map +1 -1
- package/dist/traversal.js +17 -11
- package/dist/traversal.js.map +1 -1
- package/dist/types.d.ts +65 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/user-event/adjustment.d.ts +5 -3
- package/dist/user-event/adjustment.d.ts.map +1 -1
- package/dist/user-event/adjustment.js +6 -4
- package/dist/user-event/adjustment.js.map +1 -1
- package/dist/user-event/click.d.ts +6 -5
- package/dist/user-event/click.d.ts.map +1 -1
- package/dist/user-event/click.js +29 -21
- package/dist/user-event/click.js.map +1 -1
- package/dist/user-event/controller.d.ts +7 -5
- package/dist/user-event/controller.d.ts.map +1 -1
- package/dist/user-event/controller.js +16 -6
- package/dist/user-event/controller.js.map +1 -1
- package/dist/user-event/dispatch.d.ts +3 -3
- package/dist/user-event/dispatch.d.ts.map +1 -1
- package/dist/user-event/dispatch.js +3 -2
- package/dist/user-event/dispatch.js.map +1 -1
- package/dist/user-event/event-wrapper.d.ts +2 -1
- package/dist/user-event/event-wrapper.d.ts.map +1 -1
- package/dist/user-event/event-wrapper.js +27 -16
- package/dist/user-event/event-wrapper.js.map +1 -1
- package/dist/user-event/gesture.d.ts +18 -14
- package/dist/user-event/gesture.d.ts.map +1 -1
- package/dist/user-event/gesture.js +70 -37
- package/dist/user-event/gesture.js.map +1 -1
- package/dist/user-event/index.d.ts +17 -10
- package/dist/user-event/index.d.ts.map +1 -1
- package/dist/user-event/index.js +7 -3
- package/dist/user-event/index.js.map +1 -1
- package/dist/user-event/keyboard.d.ts +4 -3
- package/dist/user-event/keyboard.d.ts.map +1 -1
- package/dist/user-event/keyboard.js +89 -58
- package/dist/user-event/keyboard.js.map +1 -1
- package/dist/user-event/pointer.d.ts +7 -3
- package/dist/user-event/pointer.d.ts.map +1 -1
- package/dist/user-event/pointer.js +4 -1
- package/dist/user-event/pointer.js.map +1 -1
- package/dist/user-event/selection.d.ts +3 -2
- package/dist/user-event/selection.d.ts.map +1 -1
- package/dist/user-event/selection.js +26 -27
- package/dist/user-event/selection.js.map +1 -1
- package/dist/user-event/state.d.ts +3 -2
- package/dist/user-event/state.d.ts.map +1 -1
- package/dist/user-event/state.js +2 -1
- package/dist/user-event/state.js.map +1 -1
- package/dist/user-event/text.d.ts +8 -7
- package/dist/user-event/text.d.ts.map +1 -1
- package/dist/user-event/text.js +39 -33
- package/dist/user-event/text.js.map +1 -1
- package/dist/wait-for.d.ts +5 -5
- package/dist/wait-for.d.ts.map +1 -1
- package/dist/wait-for.js +45 -30
- package/dist/wait-for.js.map +1 -1
- package/dist/widget-accessible-properties.d.ts +36 -25
- package/dist/widget-accessible-properties.d.ts.map +1 -1
- package/dist/widget-accessible-properties.js +215 -68
- package/dist/widget-accessible-properties.js.map +1 -1
- package/dist/within.d.ts +2 -1
- package/dist/within.d.ts.map +1 -1
- package/dist/within.js +2 -1
- package/dist/within.js.map +1 -1
- package/package.json +11 -9
- package/src/act.ts +44 -35
- package/src/bound-queries.ts +6 -6
- package/src/build-queries.ts +84 -43
- package/src/cleanup-registry.ts +18 -5
- package/src/config.ts +16 -12
- package/src/editable.ts +13 -6
- package/src/errors.ts +106 -45
- package/src/fire-event.ts +3 -1
- package/src/frame-sync.ts +38 -21
- package/src/index.ts +13 -3
- package/src/matchers.ts +568 -114
- package/src/normalize.ts +28 -0
- package/src/pretty-widget.ts +114 -42
- package/src/queries.ts +418 -256
- package/src/register-test-hooks.ts +4 -1
- package/src/render-hook.tsx +10 -4
- package/src/render.tsx +59 -34
- package/src/role-helpers.ts +29 -16
- package/src/screen.ts +17 -12
- package/src/screenshot.ts +61 -38
- package/src/suggestions.ts +29 -10
- package/src/traversal.ts +35 -15
- package/src/types.ts +111 -32
- package/src/user-event/adjustment.ts +23 -10
- package/src/user-event/click.ts +49 -20
- package/src/user-event/controller.ts +41 -7
- package/src/user-event/dispatch.ts +4 -2
- package/src/user-event/event-wrapper.ts +42 -16
- package/src/user-event/gesture.ts +135 -50
- package/src/user-event/index.ts +19 -12
- package/src/user-event/keyboard.ts +147 -61
- package/src/user-event/pointer.ts +20 -8
- package/src/user-event/selection.ts +69 -32
- package/src/user-event/state.ts +4 -2
- package/src/user-event/text.ts +73 -38
- package/src/wait-for.ts +77 -36
- package/src/widget-accessible-properties.ts +385 -79
- package/src/within.ts +8 -5
package/dist/types.d.ts
CHANGED
|
@@ -3,21 +3,29 @@ import type { RootElement } from "@gtkx/react";
|
|
|
3
3
|
import type { ComponentType, ErrorInfo, ReactNode } from "react";
|
|
4
4
|
import type { PrettyWidgetOptions } from "./pretty-widget.js";
|
|
5
5
|
import type { Container } from "./traversal.js";
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* A custom matcher predicate: given a candidate widget's normalized text content and the widget
|
|
8
|
+
* itself, returns whether it matches.
|
|
9
|
+
*/
|
|
10
|
+
type MatcherFunction = (content: string, widget: Gtk.Widget) => boolean;
|
|
8
11
|
/** A value used to match widget text: a string or number, a regular expression, or a custom {@link MatcherFunction}. */
|
|
9
|
-
|
|
12
|
+
type Matcher = string | number | RegExp | MatcherFunction;
|
|
10
13
|
/** Normalizes a widget's text before it is compared against a matcher. */
|
|
11
|
-
|
|
14
|
+
type NormalizerFn = (text: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* A widget class usable as a query's `as` constraint, such as `Gtk.Button`. Abstract classes and
|
|
17
|
+
* generated GInterface pseudo-classes are accepted.
|
|
18
|
+
*/
|
|
19
|
+
type WidgetType<T extends Gtk.Widget = Gtk.Widget> = abstract new (...args: never[]) => T;
|
|
12
20
|
/** Options controlling the default text normalizer. */
|
|
13
|
-
|
|
21
|
+
type NormalizerOptions = {
|
|
14
22
|
/** Trim leading and trailing whitespace. */
|
|
15
23
|
trim?: boolean | undefined;
|
|
16
24
|
/** Collapse runs of whitespace into a single space. */
|
|
17
25
|
collapseWhitespace?: boolean | undefined;
|
|
18
26
|
};
|
|
19
27
|
/** Options controlling how asynchronous queries and waits poll for a condition. */
|
|
20
|
-
|
|
28
|
+
type WaitForOptions = {
|
|
21
29
|
/** Maximum time in milliseconds to keep retrying before failing. */
|
|
22
30
|
timeout?: number | undefined;
|
|
23
31
|
/** Delay in milliseconds between retries. */
|
|
@@ -28,7 +36,7 @@ export type WaitForOptions = {
|
|
|
28
36
|
stackTraceError?: Error | undefined;
|
|
29
37
|
};
|
|
30
38
|
/** Options controlling text matching and, for asynchronous queries, polling behavior. */
|
|
31
|
-
|
|
39
|
+
type MatcherOptions<T extends Gtk.Widget = Gtk.Widget> = {
|
|
32
40
|
/** When true (the default), require an exact match; when false, match case-insensitively as a substring. */
|
|
33
41
|
exact?: boolean | undefined;
|
|
34
42
|
/** Custom normalizer replacing the default; cannot be combined with `trim` or `collapseWhitespace`. */
|
|
@@ -39,9 +47,11 @@ export type MatcherOptions = {
|
|
|
39
47
|
collapseWhitespace?: boolean | undefined;
|
|
40
48
|
/** Whether to include a suggested better query in error messages. */
|
|
41
49
|
suggest?: boolean | undefined;
|
|
50
|
+
/** Restricts matches to instances of this widget class, and narrows the query's return type to it. */
|
|
51
|
+
as?: WidgetType<T> | undefined;
|
|
42
52
|
} & WaitForOptions;
|
|
43
53
|
/** Constraints on a widget's numeric range value used by role queries. */
|
|
44
|
-
|
|
54
|
+
type ByRoleValue = {
|
|
45
55
|
/** The current value. */
|
|
46
56
|
now?: number | undefined;
|
|
47
57
|
min?: number | undefined;
|
|
@@ -50,7 +60,7 @@ export type ByRoleValue = {
|
|
|
50
60
|
text?: Matcher | undefined;
|
|
51
61
|
};
|
|
52
62
|
/** Options for role queries: an accessible name matcher plus accessible state and value constraints. */
|
|
53
|
-
|
|
63
|
+
type ByRoleOptions<T extends Gtk.Widget = Gtk.Widget> = MatcherOptions<T> & {
|
|
54
64
|
name?: Matcher | undefined;
|
|
55
65
|
checked?: boolean | undefined;
|
|
56
66
|
pressed?: boolean | undefined;
|
|
@@ -65,17 +75,39 @@ export type ByRoleOptions = MatcherOptions & {
|
|
|
65
75
|
hidden?: boolean | undefined;
|
|
66
76
|
};
|
|
67
77
|
/** A React component that wraps rendered content, receiving it as its children. */
|
|
68
|
-
|
|
78
|
+
type WrapperComponent = ComponentType<{
|
|
69
79
|
children: ReactNode;
|
|
70
80
|
}>;
|
|
71
81
|
type Query = (container: Container, ...args: never[]) => unknown;
|
|
72
|
-
|
|
82
|
+
type QueryMap = Record<string, Query>;
|
|
73
83
|
type BoundQuery<Q extends Query> = Q extends (container: Container, ...args: infer A) => infer R ? (...args: A) => R : never;
|
|
74
|
-
|
|
84
|
+
type BoundCustomQueries<Q extends QueryMap> = {
|
|
75
85
|
[K in keyof Q]: BoundQuery<Q[K]>;
|
|
76
86
|
};
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
type QueryFamilyReturns<T extends Gtk.Widget> = {
|
|
88
|
+
queryBy: T | null;
|
|
89
|
+
queryAllBy: T[];
|
|
90
|
+
getBy: T;
|
|
91
|
+
getAllBy: T[];
|
|
92
|
+
findBy: Promise<T>;
|
|
93
|
+
findAllBy: Promise<T[]>;
|
|
94
|
+
};
|
|
95
|
+
type QueryKind = "role" | "text" | "name" | "value";
|
|
96
|
+
type QueryArgs<Kind extends QueryKind, T extends Gtk.Widget> = Kind extends "role" ? [role: Gtk.AccessibleRole, options?: ByRoleOptions<T>] : Kind extends "name" ? [name: Matcher, options?: MatcherOptions<T>] : Kind extends "value" ? [value: Matcher, options?: MatcherOptions<T>] : [text: Matcher, options?: MatcherOptions<T>];
|
|
97
|
+
/**
|
|
98
|
+
* One query family (`queryBy`, `getBy`, `findBy` and their `All` variants) for a single suffix.
|
|
99
|
+
* Each member takes an explicit widget type, as Testing Library's queries do, and also infers it
|
|
100
|
+
* from an `as` option.
|
|
101
|
+
*/
|
|
102
|
+
type QueryFamily<Suffix extends string, Kind extends QueryKind, Head extends unknown[]> = {
|
|
103
|
+
[K in keyof QueryFamilyReturns<Gtk.Widget> as `${K & string}${Suffix}`]: <T extends Gtk.Widget = Gtk.Widget>(...args: [...Head, ...QueryArgs<Kind, T>]) => QueryFamilyReturns<T>[K];
|
|
104
|
+
};
|
|
105
|
+
type QueryFamilies<Head extends unknown[]> = QueryFamily<"Role", "role", Head> & QueryFamily<"LabelText", "text", Head> & QueryFamily<"Text", "text", Head> & QueryFamily<"Name", "name", Head> & QueryFamily<"PlaceholderText", "text", Head> & QueryFamily<"DisplayValue", "value", Head>;
|
|
106
|
+
/**
|
|
107
|
+
* Options for {@link render}: the container and base element to mount into, an optional wrapper,
|
|
108
|
+
* React behavior toggles, error callbacks, and custom queries to bind.
|
|
109
|
+
*/
|
|
110
|
+
type RenderOptions<Q extends QueryMap = Record<never, never>> = {
|
|
79
111
|
container?: Gtk.Widget | RootElement | undefined;
|
|
80
112
|
/** Root of the subtree that bound queries search. */
|
|
81
113
|
baseElement?: Container | undefined;
|
|
@@ -91,35 +123,44 @@ export type RenderOptions<Q extends QueryMap = Record<never, never>> = {
|
|
|
91
123
|
/** Custom queries to bind to the rendered result. */
|
|
92
124
|
queries?: Q | undefined;
|
|
93
125
|
};
|
|
94
|
-
|
|
126
|
+
type DebugUtilities = {
|
|
95
127
|
debug: (element?: Container | Container[], options?: PrettyWidgetOptions) => void;
|
|
96
128
|
logRoles: () => void;
|
|
97
129
|
screenshot: (selector?: WindowSelector, options?: ScreenshotOptions) => Promise<ScreenshotResult>;
|
|
98
130
|
};
|
|
99
131
|
/** A captured screenshot: base64-encoded image data, its MIME type, and pixel dimensions. */
|
|
100
|
-
|
|
132
|
+
type ScreenshotResult = {
|
|
101
133
|
data: string;
|
|
102
134
|
mimeType: string;
|
|
103
135
|
width: number;
|
|
104
136
|
height: number;
|
|
105
137
|
};
|
|
106
138
|
/** Options for capturing a screenshot: the poll timeout and interval, plus a rendering scale factor. */
|
|
107
|
-
|
|
139
|
+
type ScreenshotOptions = Pick<WaitForOptions, "timeout" | "interval"> & {
|
|
108
140
|
/** Device scale factor applied when rendering. */
|
|
109
141
|
scale?: number;
|
|
110
142
|
};
|
|
111
|
-
/**
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Selects the window to screenshot by index, or by title (exact string or regular expression);
|
|
145
|
+
* undefined targets the default window.
|
|
146
|
+
*/
|
|
147
|
+
type WindowSelector = number | string | RegExp | undefined;
|
|
148
|
+
/**
|
|
149
|
+
* Options for {@link renderHook}: an optional wrapper and the initial props (required unless the
|
|
150
|
+
* props type permits undefined).
|
|
151
|
+
*/
|
|
152
|
+
type RenderHookOptions<Props> = {
|
|
115
153
|
wrapper?: WrapperComponent;
|
|
116
154
|
} & (undefined extends Props ? {
|
|
117
155
|
initialProps?: Props;
|
|
118
156
|
} : {
|
|
119
157
|
initialProps: Props;
|
|
120
158
|
});
|
|
121
|
-
/**
|
|
122
|
-
|
|
159
|
+
/**
|
|
160
|
+
* The result of {@link renderHook}: the latest hook return value plus functions to rerender with new
|
|
161
|
+
* props and to unmount.
|
|
162
|
+
*/
|
|
163
|
+
type RenderHookResult<Result, Props> = {
|
|
123
164
|
/** Holds the most recent value returned by the hook under `current`. */
|
|
124
165
|
result: {
|
|
125
166
|
current: Result;
|
|
@@ -127,5 +168,5 @@ export type RenderHookResult<Result, Props> = {
|
|
|
127
168
|
rerender: (newProps?: Props) => Promise<void>;
|
|
128
169
|
unmount: () => Promise<void>;
|
|
129
170
|
};
|
|
130
|
-
export {};
|
|
171
|
+
export { type MatcherFunction, type Matcher, type NormalizerFn, type NormalizerOptions, type WaitForOptions, type MatcherOptions, type ByRoleValue, type ByRoleOptions, type WidgetType, type WrapperComponent, type QueryMap, type BoundCustomQueries, type QueryFamilies, type RenderOptions, type DebugUtilities, type ScreenshotResult, type ScreenshotOptions, type WindowSelector, type RenderHookOptions, type RenderHookResult, };
|
|
131
172
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,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B,EACtB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACxB,CAAC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { RootElement } from \"@gtkx/react\";\nimport type { ComponentType, ErrorInfo, ReactNode } from \"react\";\nimport type { PrettyWidgetOptions } from \"./pretty-widget.js\";\nimport type { Container } from \"./traversal.js\";\n\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA8MA,OAAO,EAqBN,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { RootElement } from \"@gtkx/react\";\nimport type { ComponentType, ErrorInfo, ReactNode } from \"react\";\nimport type { PrettyWidgetOptions } from \"./pretty-widget.js\";\nimport type { Container } from \"./traversal.js\";\n\n/**\n * A custom matcher predicate: given a candidate widget's normalized text content and the widget\n * itself, returns whether it matches.\n */\ntype MatcherFunction = (content: string, widget: Gtk.Widget) => boolean;\n/** A value used to match widget text: a string or number, a regular expression, or a custom {@link MatcherFunction}. */\ntype Matcher = string | number | RegExp | MatcherFunction;\n/** Normalizes a widget's text before it is compared against a matcher. */\ntype NormalizerFn = (text: string) => string;\n/**\n * A widget class usable as a query's `as` constraint, such as `Gtk.Button`. Abstract classes and\n * generated GInterface pseudo-classes are accepted.\n */\ntype WidgetType<T extends Gtk.Widget = Gtk.Widget> = abstract new (...args: never[]) => T;\n\n/** Options controlling the default text normalizer. */\ntype NormalizerOptions = {\n /** Trim leading and trailing whitespace. */\n trim?: boolean | undefined;\n /** Collapse runs of whitespace into a single space. */\n collapseWhitespace?: boolean | undefined;\n};\n\n/** Options controlling how asynchronous queries and waits poll for a condition. */\ntype WaitForOptions = {\n /** Maximum time in milliseconds to keep retrying before failing. */\n timeout?: number | undefined;\n /** Delay in milliseconds between retries. */\n interval?: number | undefined;\n /** Transforms the error thrown when the timeout elapses. */\n onTimeout?: ((error: Error) => Error) | undefined;\n /** Error whose stack trace attributes the timeout failure to the calling code. */\n stackTraceError?: Error | undefined;\n};\n\n/** Options controlling text matching and, for asynchronous queries, polling behavior. */\ntype MatcherOptions<T extends Gtk.Widget = Gtk.Widget> = {\n /** When true (the default), require an exact match; when false, match case-insensitively as a substring. */\n exact?: boolean | undefined;\n /** Custom normalizer replacing the default; cannot be combined with `trim` or `collapseWhitespace`. */\n normalizer?: NormalizerFn | undefined;\n /** Forwarded to the default normalizer when no custom `normalizer` is given. */\n trim?: boolean | undefined;\n /** Forwarded to the default normalizer when no custom `normalizer` is given. */\n collapseWhitespace?: boolean | undefined;\n /** Whether to include a suggested better query in error messages. */\n suggest?: boolean | undefined;\n /** Restricts matches to instances of this widget class, and narrows the query's return type to it. */\n as?: WidgetType<T> | undefined;\n} & WaitForOptions;\n\n/** Constraints on a widget's numeric range value used by role queries. */\ntype ByRoleValue = {\n /** The current value. */\n now?: number | undefined;\n min?: number | undefined;\n max?: number | undefined;\n /** Matcher for the value's textual representation. */\n text?: Matcher | undefined;\n};\n\n/** Options for role queries: an accessible name matcher plus accessible state and value constraints. */\ntype ByRoleOptions<T extends Gtk.Widget = Gtk.Widget> = MatcherOptions<T> & {\n name?: Matcher | undefined;\n checked?: boolean | undefined;\n pressed?: boolean | undefined;\n selected?: boolean | undefined;\n expanded?: boolean | undefined;\n /** Heading or hierarchy level. */\n level?: number | undefined;\n busy?: boolean | undefined;\n description?: Matcher | undefined;\n value?: ByRoleValue | undefined;\n /** When true, include widgets excluded from the accessibility tree. */\n hidden?: boolean | undefined;\n};\n\n/** A React component that wraps rendered content, receiving it as its children. */\ntype WrapperComponent = ComponentType<{\n children: ReactNode;\n}>;\n\ntype Query = (container: Container, ...args: never[]) => unknown;\ntype QueryMap = Record<string, Query>;\n\ntype BoundQuery<Q extends Query> = Q extends (container: Container, ...args: infer A) => infer R\n ? (...args: A) => R\n : never;\n\ntype BoundCustomQueries<Q extends QueryMap> = { [K in keyof Q]: BoundQuery<Q[K]> };\n\ntype QueryFamilyReturns<T extends Gtk.Widget> = {\n queryBy: T | null;\n queryAllBy: T[];\n getBy: T;\n getAllBy: T[];\n findBy: Promise<T>;\n findAllBy: Promise<T[]>;\n};\n\ntype QueryKind = \"role\" | \"text\" | \"name\" | \"value\";\n\ntype QueryArgs<Kind extends QueryKind, T extends Gtk.Widget> = Kind extends \"role\"\n ? [role: Gtk.AccessibleRole, options?: ByRoleOptions<T>]\n : Kind extends \"name\"\n ? [name: Matcher, options?: MatcherOptions<T>]\n : Kind extends \"value\"\n ? [value: Matcher, options?: MatcherOptions<T>]\n : [text: Matcher, options?: MatcherOptions<T>];\n\n/**\n * One query family (`queryBy`, `getBy`, `findBy` and their `All` variants) for a single suffix.\n * Each member takes an explicit widget type, as Testing Library's queries do, and also infers it\n * from an `as` option.\n */\ntype QueryFamily<Suffix extends string, Kind extends QueryKind, Head extends unknown[]> = {\n [K in keyof QueryFamilyReturns<Gtk.Widget> as `${K & string}${Suffix}`]: <T extends Gtk.Widget = Gtk.Widget>(\n ...args: [...Head, ...QueryArgs<Kind, T>]\n ) => QueryFamilyReturns<T>[K];\n};\n\ntype QueryFamilies<Head extends unknown[]> = QueryFamily<\"Role\", \"role\", Head> &\n QueryFamily<\"LabelText\", \"text\", Head> &\n QueryFamily<\"Text\", \"text\", Head> &\n QueryFamily<\"Name\", \"name\", Head> &\n QueryFamily<\"PlaceholderText\", \"text\", Head> &\n QueryFamily<\"DisplayValue\", \"value\", Head>;\n\n/**\n * Options for {@link render}: the container and base element to mount into, an optional wrapper,\n * React behavior toggles, error callbacks, and custom queries to bind.\n */\ntype RenderOptions<Q extends QueryMap = Record<never, never>> = {\n container?: Gtk.Widget | RootElement | undefined;\n /** Root of the subtree that bound queries search. */\n baseElement?: Container | undefined;\n wrapper?: WrapperComponent | undefined;\n /** Render inside React StrictMode. */\n reactStrictMode?: boolean | undefined;\n /** Enable widget animations during the test. */\n animations?: boolean | undefined;\n /** Called for errors caught by React error boundaries. */\n onCaughtError?: ((error: unknown, errorInfo: ErrorInfo) => void) | undefined;\n /** Called for errors React recovered from automatically. */\n onRecoverableError?: ((error: unknown, errorInfo: ErrorInfo) => void) | undefined;\n /** Custom queries to bind to the rendered result. */\n queries?: Q | undefined;\n};\n\ntype DebugUtilities = {\n debug: (element?: Container | Container[], options?: PrettyWidgetOptions) => void;\n logRoles: () => void;\n screenshot: (selector?: WindowSelector, options?: ScreenshotOptions) => Promise<ScreenshotResult>;\n};\n\n/** A captured screenshot: base64-encoded image data, its MIME type, and pixel dimensions. */\ntype ScreenshotResult = {\n data: string;\n mimeType: string;\n width: number;\n height: number;\n};\n\n/** Options for capturing a screenshot: the poll timeout and interval, plus a rendering scale factor. */\ntype ScreenshotOptions = Pick<WaitForOptions, \"timeout\" | \"interval\"> & {\n /** Device scale factor applied when rendering. */\n scale?: number;\n};\n\n/**\n * Selects the window to screenshot by index, or by title (exact string or regular expression);\n * undefined targets the default window.\n */\ntype WindowSelector = number | string | RegExp | undefined;\n\n/**\n * Options for {@link renderHook}: an optional wrapper and the initial props (required unless the\n * props type permits undefined).\n */\ntype RenderHookOptions<Props> = {\n wrapper?: WrapperComponent;\n} & (undefined extends Props\n ? {\n initialProps?: Props;\n }\n : {\n initialProps: Props;\n });\n\n/**\n * The result of {@link renderHook}: the latest hook return value plus functions to rerender with new\n * props and to unmount.\n */\ntype RenderHookResult<Result, Props> = {\n /** Holds the most recent value returned by the hook under `current`. */\n result: { current: Result };\n rerender: (newProps?: Props) => Promise<void>;\n unmount: () => Promise<void>;\n};\n\nexport {\n type MatcherFunction,\n type Matcher,\n type NormalizerFn,\n type NormalizerOptions,\n type WaitForOptions,\n type MatcherOptions,\n type ByRoleValue,\n type ByRoleOptions,\n type WidgetType,\n type WrapperComponent,\n type QueryMap,\n type BoundCustomQueries,\n type QueryFamilies,\n type RenderOptions,\n type DebugUtilities,\n type ScreenshotResult,\n type ScreenshotOptions,\n type WindowSelector,\n type RenderHookOptions,\n type RenderHookResult,\n};\n"]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
-
|
|
2
|
+
/** A scroll distance in pixels along each axis. */
|
|
3
|
+
type ScrollDelta = {
|
|
3
4
|
x?: number;
|
|
4
5
|
y?: number;
|
|
5
6
|
};
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
declare const slide: (widget: Gtk.Widget, value: number) => Promise<void>;
|
|
8
|
+
declare const scroll: (widget: Gtk.Widget, delta: ScrollDelta) => Promise<void>;
|
|
9
|
+
export { slide, scroll, type ScrollDelta };
|
|
8
10
|
//# sourceMappingURL=adjustment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adjustment.d.ts","sourceRoot":"","sources":["../../src/user-event/adjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAGpC,
|
|
1
|
+
{"version":3,"file":"adjustment.d.ts","sourceRoot":"","sources":["../../src/user-event/adjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAGpC,mDAAmD;AACnD,KAAK,WAAW,GAAG;IACf,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAOF,QAAA,MAAM,KAAK,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,OAAO,MAAM,KAAG,OAAO,CAAC,IAAI,CASzD,CAAC;AAwBP,QAAA,MAAM,MAAM,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,OAAO,WAAW,KAAG,OAAO,CAAC,IAAI,CAY/D,CAAC;AAEP,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
2
|
import { wrapEvent } from "./event-wrapper.js";
|
|
3
|
-
|
|
3
|
+
const slide = (widget, value) => wrapEvent(widget, () => {
|
|
4
4
|
if (!(widget instanceof Gtk.Range)) {
|
|
5
|
-
throw new
|
|
5
|
+
throw new TypeError(`userEvent.slide requires a Gtk.Range (e.g. Gtk.Scale), got ${widget.constructor.name}`);
|
|
6
6
|
}
|
|
7
7
|
widget.emit("change-value", Gtk.ScrollType.JUMP, value);
|
|
8
8
|
});
|
|
@@ -18,11 +18,12 @@ const resolveScrollAdjustments = (widget) => {
|
|
|
18
18
|
return null;
|
|
19
19
|
};
|
|
20
20
|
const applyScrollDelta = (adjustment, delta) => {
|
|
21
|
-
if (!adjustment || delta === 0)
|
|
21
|
+
if (!adjustment || delta === 0) {
|
|
22
22
|
return;
|
|
23
|
+
}
|
|
23
24
|
adjustment.setValue(adjustment.getValue() + delta);
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
+
const scroll = (widget, delta) => wrapEvent(widget, () => {
|
|
26
27
|
const adjustments = resolveScrollAdjustments(widget);
|
|
27
28
|
if (!adjustments) {
|
|
28
29
|
throw new Error("userEvent.scroll: no Gtk.ScrolledWindow or Gtk.Scrollable found on the widget or its ancestors");
|
|
@@ -30,4 +31,5 @@ export const scroll = (widget, delta) => wrapEvent(widget, () => {
|
|
|
30
31
|
applyScrollDelta(adjustments.horizontal, delta.x ?? 0);
|
|
31
32
|
applyScrollDelta(adjustments.vertical, delta.y ?? 0);
|
|
32
33
|
});
|
|
34
|
+
export { slide, scroll };
|
|
33
35
|
//# sourceMappingURL=adjustment.js.map
|
|
@@ -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,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"adjustment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B,OAAO;IACX,CAAC;IAED,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,MAAkB,EAAE,KAAkB,EAAiB,EAAE,CACrE,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE;IACnB,MAAM,WAAW,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAC;IAErD,IAAI,CAAC,WAAW,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACX,gGAAgG,CACnG,CAAC;IACN,CAAC;IAED,gBAAgB,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,gBAAgB,CAAC,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACzD,CAAC,CAAC,CAAC;AAEP,OAAO,EAAE,KAAK,EAAE,MAAM,EAAoB,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { wrapEvent } from \"./event-wrapper.js\";\n\n/** A scroll distance in pixels along each axis. */\ntype ScrollDelta = {\n x?: number;\n y?: number;\n};\n\ntype ScrollAdjustments = {\n horizontal: Gtk.Adjustment | null;\n vertical: Gtk.Adjustment | null;\n};\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 ${widget.constructor.name}`,\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 applyScrollDelta = (adjustment: Gtk.Adjustment | null, delta: number): void => {\n if (!adjustment || delta === 0) {\n return;\n }\n\n adjustment.setValue(adjustment.getValue() + delta);\n};\n\nconst scroll = (widget: Gtk.Widget, delta: ScrollDelta): Promise<void> =>\n wrapEvent(widget, () => {\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 });\n\nexport { slide, scroll, type ScrollDelta };\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
declare const emitPress: (widget: Gtk.Widget, controllers: Gtk.GestureClick[], nPress: number) => void;
|
|
3
|
+
declare const emitRelease: (widget: Gtk.Widget, controllers: Gtk.GestureClick[], nPress: number) => void;
|
|
4
|
+
declare const click: (widget: Gtk.Widget) => Promise<void>;
|
|
5
|
+
declare const dblClick: (widget: Gtk.Widget) => Promise<void>;
|
|
6
|
+
declare const tripleClick: (widget: Gtk.Widget) => Promise<void>;
|
|
7
|
+
export { emitPress, emitRelease, click, dblClick, tripleClick };
|
|
7
8
|
//# sourceMappingURL=click.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAuBpC,QAAA,MAAM,SAAS,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,aAAa,GAAG,CAAC,YAAY,EAAE,EAAE,QAAQ,MAAM,KAAG,IAExF,CAAC;AAEF,QAAA,MAAM,WAAW,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,aAAa,GAAG,CAAC,YAAY,EAAE,EAAE,QAAQ,MAAM,KAAG,IAE1F,CAAC;AAwCF,QAAA,MAAM,KAAK,GAAU,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAwBrD,CAAC;AAEF,QAAA,MAAM,QAAQ,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAAyC,CAAC;AAC7F,QAAA,MAAM,WAAW,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAAyC,CAAC;AAEhG,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/user-event/click.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
2
|
import { getOrCreateControllers, queryController } from "./controller.js";
|
|
3
3
|
import { wrapEvent } from "./event-wrapper.js";
|
|
4
|
-
const
|
|
4
|
+
const getPressPoint = (widget) => {
|
|
5
5
|
const width = widget.getWidth();
|
|
6
6
|
const height = widget.getHeight();
|
|
7
|
-
if (width > 0 && height > 0)
|
|
7
|
+
if (width > 0 && height > 0) {
|
|
8
8
|
return { x: width / 2, y: height / 2 };
|
|
9
|
+
}
|
|
9
10
|
return { x: 0, y: 0 };
|
|
10
11
|
};
|
|
11
|
-
|
|
12
|
-
const { x, y } =
|
|
12
|
+
const emitGesture = (widget, controllers, nPress, signal) => {
|
|
13
|
+
const { x, y } = getPressPoint(widget);
|
|
13
14
|
for (const controller of controllers) {
|
|
14
|
-
controller.emit(
|
|
15
|
+
controller.emit(signal, nPress, x, y);
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const emitPress = (widget, controllers, nPress) => {
|
|
19
|
+
emitGesture(widget, controllers, nPress, "pressed");
|
|
20
|
+
};
|
|
21
|
+
const emitRelease = (widget, controllers, nPress) => {
|
|
22
|
+
emitGesture(widget, controllers, nPress, "released");
|
|
22
23
|
};
|
|
23
24
|
const emitClickSequence = (widget, target, nPress) => wrapEvent(widget, () => {
|
|
24
25
|
const controllers = getOrCreateControllers(target, Gtk.GestureClick);
|
|
@@ -37,7 +38,17 @@ const findClickableAncestor = (widget) => {
|
|
|
37
38
|
}
|
|
38
39
|
return null;
|
|
39
40
|
};
|
|
40
|
-
|
|
41
|
+
const tryActivate = async (widget) => {
|
|
42
|
+
if (widget.getAccessibleRole() === Gtk.AccessibleRole.LABEL) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
let isActivated = false;
|
|
46
|
+
await wrapEvent(widget, () => {
|
|
47
|
+
isActivated = widget.activate();
|
|
48
|
+
});
|
|
49
|
+
return isActivated;
|
|
50
|
+
};
|
|
51
|
+
const click = async (widget) => {
|
|
41
52
|
if (widget instanceof Gtk.Button) {
|
|
42
53
|
await emitClickSequence(widget, widget, 1);
|
|
43
54
|
return;
|
|
@@ -48,18 +59,15 @@ export const click = async (widget) => {
|
|
|
48
59
|
});
|
|
49
60
|
return;
|
|
50
61
|
}
|
|
51
|
-
if (widget
|
|
52
|
-
|
|
53
|
-
await wrapEvent(widget, () => {
|
|
54
|
-
activated = widget.activate();
|
|
55
|
-
});
|
|
56
|
-
if (activated)
|
|
57
|
-
return;
|
|
62
|
+
if (await tryActivate(widget)) {
|
|
63
|
+
return;
|
|
58
64
|
}
|
|
59
65
|
const target = findClickableAncestor(widget);
|
|
60
|
-
if (target)
|
|
66
|
+
if (target) {
|
|
61
67
|
await emitClickSequence(widget, target, 1);
|
|
68
|
+
}
|
|
62
69
|
};
|
|
63
|
-
|
|
64
|
-
|
|
70
|
+
const dblClick = (widget) => emitClickSequence(widget, widget, 2);
|
|
71
|
+
const tripleClick = (widget) => emitClickSequence(widget, widget, 3);
|
|
72
|
+
export { emitPress, emitRelease, click, dblClick, tripleClick };
|
|
65
73
|
//# sourceMappingURL=click.js.map
|
|
@@ -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,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,MAAM,
|
|
1
|
+
{"version":3,"file":"click.js","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,MAAM,aAAa,GAAG,CAAC,MAAkB,EAA4B,EAAE;IACnE,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IAElC,IAAI,KAAK,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;IAC3C,CAAC;IAED,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAE,WAA+B,EAAE,MAAc,EAAE,MAAc,EAAQ,EAAE;IAC9G,MAAM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AAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,MAAkB,EAAiB,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC7F,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAiB,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAEhG,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { getOrCreateControllers, queryController } from \"./controller.js\";\nimport { wrapEvent } from \"./event-wrapper.js\";\n\nconst getPressPoint = (widget: Gtk.Widget): { x: number; y: number } => {\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 emitGesture = (widget: Gtk.Widget, controllers: Gtk.GestureClick[], nPress: number, signal: string): void => {\n const { x, y } = getPressPoint(widget);\n\n for (const controller of controllers) {\n controller.emit(signal, nPress, x, y);\n }\n};\n\nconst emitPress = (widget: Gtk.Widget, controllers: Gtk.GestureClick[], nPress: number): void => {\n emitGesture(widget, controllers, nPress, \"pressed\");\n};\n\nconst emitRelease = (widget: Gtk.Widget, controllers: Gtk.GestureClick[], nPress: number): void => {\n emitGesture(widget, controllers, nPress, \"released\");\n};\n\nconst emitClickSequence = (widget: Gtk.Widget, target: Gtk.Widget, nPress: number): Promise<void> =>\n wrapEvent(widget, () => {\n const controllers = getOrCreateControllers(target, Gtk.GestureClick);\n\n for (let i = 1; i <= nPress; i++) {\n emitPress(target, controllers, i);\n emitRelease(target, controllers, i);\n }\n });\n\nconst findClickableAncestor = (widget: Gtk.Widget): Gtk.Widget | null => {\n let current = widget.getParent();\n\n while (current) {\n if (current instanceof Gtk.Button || queryController(current, Gtk.GestureClick) !== null) {\n return current;\n }\n\n current = current.getParent();\n }\n\n return null;\n};\n\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\nconst click = async (widget: Gtk.Widget): Promise<void> => {\n if (widget instanceof Gtk.Button) {\n await emitClickSequence(widget, widget, 1);\n\n return;\n }\n\n if (widget instanceof Gtk.Switch) {\n await wrapEvent(widget, () => {\n widget.setActive(!widget.getActive());\n });\n\n return;\n }\n\n if (await tryActivate(widget)) {\n return;\n }\n\n const target = findClickableAncestor(widget);\n\n if (target) {\n await emitClickSequence(widget, target, 1);\n }\n};\n\nconst dblClick = (widget: Gtk.Widget): Promise<void> => emitClickSequence(widget, widget, 2);\nconst tripleClick = (widget: Gtk.Widget): Promise<void> => emitClickSequence(widget, widget, 3);\n\nexport { emitPress, emitRelease, click, dblClick, tripleClick };\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
type ControllerConstructor<T extends Gtk.EventController> = new () => T;
|
|
3
|
+
declare const queryAllControllers: <T extends Gtk.EventController>(widget: Gtk.Widget, controllerType: ControllerConstructor<T>) => T[];
|
|
4
|
+
declare const queryController: <T extends Gtk.EventController>(widget: Gtk.Widget, controllerType: ControllerConstructor<T>) => T | null;
|
|
5
|
+
declare const getAllControllers: <T extends Gtk.EventController>(widget: Gtk.Widget, controllerType: ControllerConstructor<T>) => T[];
|
|
6
|
+
declare const getController: <T extends Gtk.EventController>(widget: Gtk.Widget, controllerType: ControllerConstructor<T>) => T;
|
|
7
|
+
declare const getOrCreateControllers: <T extends Gtk.EventController>(widget: Gtk.Widget, controllerType: ControllerConstructor<T>) => T[];
|
|
8
|
+
export { queryAllControllers, queryController, getAllControllers, getController, getOrCreateControllers, type ControllerConstructor, };
|
|
7
9
|
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/user-event/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAEzC,
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/user-event/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAEzC,KAAK,qBAAqB,CAAC,CAAC,SAAS,GAAG,CAAC,eAAe,IAAI,UAAU,CAAC,CAAC;AAExE,QAAA,MAAM,mBAAmB,GAAI,CAAC,SAAS,GAAG,CAAC,eAAe,EACtD,QAAQ,GAAG,CAAC,MAAM,EAClB,gBAAgB,qBAAqB,CAAC,CAAC,CAAC,KACzC,CAAC,EAcH,CAAC;AAEF,QAAA,MAAM,eAAe,GAAI,CAAC,SAAS,GAAG,CAAC,eAAe,EAClD,QAAQ,GAAG,CAAC,MAAM,EAClB,gBAAgB,qBAAqB,CAAC,CAAC,CAAC,KACzC,CAAC,GAAG,IAA8D,CAAC;AAEtE,QAAA,MAAM,iBAAiB,GAAI,CAAC,SAAS,GAAG,CAAC,eAAe,EACpD,QAAQ,GAAG,CAAC,MAAM,EAClB,gBAAgB,qBAAqB,CAAC,CAAC,CAAC,KACzC,CAAC,EAQH,CAAC;AAEF,QAAA,MAAM,aAAa,GAAI,CAAC,SAAS,GAAG,CAAC,eAAe,EAChD,QAAQ,GAAG,CAAC,MAAM,EAClB,gBAAgB,qBAAqB,CAAC,CAAC,CAAC,KACzC,CAQF,CAAC;AAEF,QAAA,MAAM,sBAAsB,GAAI,CAAC,SAAS,GAAG,CAAC,eAAe,EACzD,QAAQ,GAAG,CAAC,MAAM,EAClB,gBAAgB,qBAAqB,CAAC,CAAC,CAAC,KACzC,CAAC,EAWH,CAAC;AAEF,OAAO,EACH,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,sBAAsB,EACtB,KAAK,qBAAqB,GAC7B,CAAC"}
|
|
@@ -1,28 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
const queryAllControllers = (widget, controllerType) => {
|
|
2
2
|
const controllers = widget.observeControllers();
|
|
3
3
|
const nItems = controllers.getNItems();
|
|
4
4
|
const matches = [];
|
|
5
5
|
for (let i = 0; i < nItems; i++) {
|
|
6
6
|
const controller = controllers.getItem(i);
|
|
7
|
-
if (controller instanceof controllerType)
|
|
7
|
+
if (controller instanceof controllerType) {
|
|
8
8
|
matches.push(controller);
|
|
9
|
+
}
|
|
9
10
|
}
|
|
10
11
|
return matches;
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
const queryController = (widget, controllerType) => queryAllControllers(widget, controllerType)[0] ?? null;
|
|
14
|
+
const getAllControllers = (widget, controllerType) => {
|
|
14
15
|
const controllers = queryAllControllers(widget, controllerType);
|
|
15
16
|
if (controllers.length === 0) {
|
|
16
17
|
throw new Error(`No ${controllerType.name} controller is attached to the widget`);
|
|
17
18
|
}
|
|
18
19
|
return controllers;
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
+
const getController = (widget, controllerType) => {
|
|
22
|
+
const [controller] = getAllControllers(widget, controllerType);
|
|
23
|
+
if (controller === undefined) {
|
|
24
|
+
throw new Error(`No ${controllerType.name} controller is attached to the widget`);
|
|
25
|
+
}
|
|
26
|
+
return controller;
|
|
27
|
+
};
|
|
28
|
+
const getOrCreateControllers = (widget, controllerType) => {
|
|
21
29
|
const existing = queryAllControllers(widget, controllerType);
|
|
22
|
-
if (existing.length > 0)
|
|
30
|
+
if (existing.length > 0) {
|
|
23
31
|
return existing;
|
|
32
|
+
}
|
|
24
33
|
const controller = new controllerType();
|
|
25
34
|
widget.addController(controller);
|
|
26
35
|
return [controller];
|
|
27
36
|
};
|
|
37
|
+
export { queryAllControllers, queryController, getAllControllers, getController, getOrCreateControllers, };
|
|
28
38
|
//# sourceMappingURL=controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../src/user-event/controller.ts"],"names":[],"mappings":"AAIA,MAAM,
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../src/user-event/controller.ts"],"names":[],"mappings":"AAIA,MAAM,mBAAmB,GAAG,CACxB,MAAkB,EAClB,cAAwC,EACrC,EAAE;IACL,MAAM,WAAW,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC;IAChD,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,EAAE,CAAC;IACvC,MAAM,OAAO,GAAQ,EAAE,CAAC;IAExB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAE1C,IAAI,UAAU,YAAY,cAAc,EAAE,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7B,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CACpB,MAAkB,EAClB,cAAwC,EAChC,EAAE,CAAC,mBAAmB,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAEtE,MAAM,iBAAiB,GAAG,CACtB,MAAkB,EAClB,cAAwC,EACrC,EAAE;IACL,MAAM,WAAW,GAAG,mBAAmB,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEhE,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,MAAM,cAAc,CAAC,IAAI,uCAAuC,CAAC,CAAC;IACtF,CAAC;IAED,OAAO,WAAW,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAClB,MAAkB,EAClB,cAAwC,EACvC,EAAE;IACH,MAAM,CAAC,UAAU,CAAC,GAAG,iBAAiB,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAE/D,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,MAAM,cAAc,CAAC,IAAI,uCAAuC,CAAC,CAAC;IACtF,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAC3B,MAAkB,EAClB,cAAwC,EACrC,EAAE;IACL,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAE7D,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,cAAc,EAAE,CAAC;IACxC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAEjC,OAAO,CAAC,UAAU,CAAC,CAAC;AACxB,CAAC,CAAC;AAEF,OAAO,EACH,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,sBAAsB,GAEzB,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\n\ntype ControllerConstructor<T extends Gtk.EventController> = new () => T;\n\nconst queryAllControllers = <T extends Gtk.EventController>(\n widget: Gtk.Widget,\n controllerType: ControllerConstructor<T>,\n): T[] => {\n const controllers = widget.observeControllers();\n const nItems = controllers.getNItems();\n const matches: T[] = [];\n\n for (let i = 0; i < nItems; i++) {\n const controller = controllers.getItem(i);\n\n if (controller instanceof controllerType) {\n matches.push(controller);\n }\n }\n\n return matches;\n};\n\nconst queryController = <T extends Gtk.EventController>(\n widget: Gtk.Widget,\n controllerType: ControllerConstructor<T>,\n): T | null => queryAllControllers(widget, controllerType)[0] ?? null;\n\nconst getAllControllers = <T extends Gtk.EventController>(\n widget: Gtk.Widget,\n controllerType: ControllerConstructor<T>,\n): T[] => {\n const controllers = queryAllControllers(widget, controllerType);\n\n if (controllers.length === 0) {\n throw new Error(`No ${controllerType.name} controller is attached to the widget`);\n }\n\n return controllers;\n};\n\nconst getController = <T extends Gtk.EventController>(\n widget: Gtk.Widget,\n controllerType: ControllerConstructor<T>,\n): T => {\n const [controller] = getAllControllers(widget, controllerType);\n\n if (controller === undefined) {\n throw new Error(`No ${controllerType.name} controller is attached to the widget`);\n }\n\n return controller;\n};\n\nconst getOrCreateControllers = <T extends Gtk.EventController>(\n widget: Gtk.Widget,\n controllerType: ControllerConstructor<T>,\n): T[] => {\n const existing = queryAllControllers(widget, controllerType);\n\n if (existing.length > 0) {\n return existing;\n }\n\n const controller = new controllerType();\n widget.addController(controller);\n\n return [controller];\n};\n\nexport {\n queryAllControllers,\n queryController,\n getAllControllers,\n getController,\n getOrCreateControllers,\n type ControllerConstructor,\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/gi/gtk";
|
|
2
2
|
import { type ControllerConstructor } from "./controller.js";
|
|
3
3
|
type ControllerEmit<T extends Gtk.EventController> = (controller: T) => void | PromiseLike<void>;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export {};
|
|
4
|
+
declare const dispatchOnOrCreateControllers: <T extends Gtk.EventController>(widget: Gtk.Widget, controllerType: ControllerConstructor<T>, emit: ControllerEmit<T>) => Promise<void>;
|
|
5
|
+
declare const dispatchOnControllers: <T extends Gtk.EventController>(widget: Gtk.Widget, controllerType: ControllerConstructor<T>, emit: ControllerEmit<T>) => Promise<void>;
|
|
6
|
+
export { dispatchOnOrCreateControllers, dispatchOnControllers };
|
|
7
7
|
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/user-event/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,qBAAqB,EAA6C,MAAM,iBAAiB,CAAC;AAGxG,KAAK,cAAc,CAAC,CAAC,SAAS,GAAG,CAAC,eAAe,IAAI,CAAC,UAAU,EAAE,CAAC,KAAK,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;AAQjG,
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/user-event/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,qBAAqB,EAA6C,MAAM,iBAAiB,CAAC;AAGxG,KAAK,cAAc,CAAC,CAAC,SAAS,GAAG,CAAC,eAAe,IAAI,CAAC,UAAU,EAAE,CAAC,KAAK,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;AAQjG,QAAA,MAAM,6BAA6B,GAAI,CAAC,SAAS,GAAG,CAAC,eAAe,EAChE,QAAQ,GAAG,CAAC,MAAM,EAClB,gBAAgB,qBAAqB,CAAC,CAAC,CAAC,EACxC,MAAM,cAAc,CAAC,CAAC,CAAC,KACxB,OAAO,CAAC,IAAI,CAA6F,CAAC;AAE7G,QAAA,MAAM,qBAAqB,GAAI,CAAC,SAAS,GAAG,CAAC,eAAe,EACxD,QAAQ,GAAG,CAAC,MAAM,EAClB,gBAAgB,qBAAqB,CAAC,CAAC,CAAC,EACxC,MAAM,cAAc,CAAC,CAAC,CAAC,KACxB,OAAO,CAAC,IAAI,CAAwF,CAAC;AAExG,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -5,6 +5,7 @@ const emitOnAll = async (controllers, emit) => {
|
|
|
5
5
|
await emit(controller);
|
|
6
6
|
}
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const dispatchOnOrCreateControllers = (widget, controllerType, emit) => wrapEvent(widget, () => emitOnAll(getOrCreateControllers(widget, controllerType), emit));
|
|
9
|
+
const dispatchOnControllers = (widget, controllerType, emit) => wrapEvent(widget, () => emitOnAll(getAllControllers(widget, controllerType), emit));
|
|
10
|
+
export { dispatchOnOrCreateControllers, dispatchOnControllers };
|
|
10
11
|
//# sourceMappingURL=dispatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../src/user-event/dispatch.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,SAAS,GAAG,KAAK,EAAiC,WAAgB,EAAE,IAAuB,EAAiB,EAAE;IAChH,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACnC,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3B,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,
|
|
1
|
+
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../src/user-event/dispatch.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,SAAS,GAAG,KAAK,EAAiC,WAAgB,EAAE,IAAuB,EAAiB,EAAE;IAChH,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACnC,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3B,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,6BAA6B,GAAG,CAClC,MAAkB,EAClB,cAAwC,EACxC,IAAuB,EACV,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,sBAAsB,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AAE7G,MAAM,qBAAqB,GAAG,CAC1B,MAAkB,EAClB,cAAwC,EACxC,IAAuB,EACV,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AAExG,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { type ControllerConstructor, getAllControllers, getOrCreateControllers } from \"./controller.js\";\nimport { wrapEvent } from \"./event-wrapper.js\";\n\ntype ControllerEmit<T extends Gtk.EventController> = (controller: T) => void | PromiseLike<void>;\n\nconst emitOnAll = async <T extends Gtk.EventController>(controllers: T[], emit: ControllerEmit<T>): Promise<void> => {\n for (const controller of controllers) {\n await emit(controller);\n }\n};\n\nconst dispatchOnOrCreateControllers = <T extends Gtk.EventController>(\n widget: Gtk.Widget,\n controllerType: ControllerConstructor<T>,\n emit: ControllerEmit<T>,\n): Promise<void> => wrapEvent(widget, () => emitOnAll(getOrCreateControllers(widget, controllerType), emit));\n\nconst dispatchOnControllers = <T extends Gtk.EventController>(\n widget: Gtk.Widget,\n controllerType: ControllerConstructor<T>,\n emit: ControllerEmit<T>,\n): Promise<void> => wrapEvent(widget, () => emitOnAll(getAllControllers(widget, controllerType), emit));\n\nexport { dispatchOnOrCreateControllers, dispatchOnControllers };\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
-
|
|
2
|
+
declare const wrapEvent: (widget: Gtk.Widget, body: () => void | PromiseLike<void>) => Promise<void>;
|
|
3
|
+
export { wrapEvent };
|
|
3
4
|
//# sourceMappingURL=event-wrapper.d.ts.map
|