screenci 0.0.21 → 0.0.22
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/cli.js +1 -1
- package/dist/e2e/instrument.e2e.js +98 -68
- package/dist/e2e/instrument.e2e.js.map +1 -1
- package/dist/src/autoZoom.d.ts +34 -15
- package/dist/src/autoZoom.d.ts.map +1 -1
- package/dist/src/autoZoom.js +100 -69
- package/dist/src/autoZoom.js.map +1 -1
- package/dist/src/changeFocus.d.ts +129 -0
- package/dist/src/changeFocus.d.ts.map +1 -0
- package/dist/src/changeFocus.js +885 -0
- package/dist/src/changeFocus.js.map +1 -0
- package/dist/src/defaults.d.ts +2 -17
- package/dist/src/defaults.d.ts.map +1 -1
- package/dist/src/defaults.js +8 -16
- package/dist/src/defaults.js.map +1 -1
- package/dist/src/easing.d.ts +6 -0
- package/dist/src/easing.d.ts.map +1 -0
- package/dist/src/easing.js +30 -0
- package/dist/src/easing.js.map +1 -0
- package/dist/src/errors.d.ts +10 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +26 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/events.d.ts +34 -12
- package/dist/src/events.d.ts.map +1 -1
- package/dist/src/events.js +111 -30
- package/dist/src/events.js.map +1 -1
- package/dist/src/instrument.d.ts +0 -6
- package/dist/src/instrument.d.ts.map +1 -1
- package/dist/src/instrument.js +382 -812
- package/dist/src/instrument.js.map +1 -1
- package/dist/src/mouse.d.ts +128 -0
- package/dist/src/mouse.d.ts.map +1 -0
- package/dist/src/mouse.js +268 -0
- package/dist/src/mouse.js.map +1 -0
- package/dist/src/recordingData.d.ts +29 -4
- package/dist/src/recordingData.d.ts.map +1 -1
- package/dist/src/types.d.ts +4 -7
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/zoom.d.ts +69 -0
- package/dist/src/zoom.d.ts.map +1 -0
- package/dist/src/zoom.js +90 -0
- package/dist/src/zoom.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/scroll.d.ts +0 -36
- package/dist/src/scroll.d.ts.map +0 -1
- package/dist/src/scroll.js +0 -274
- package/dist/src/scroll.js.map +0 -1
package/dist/src/autoZoom.d.ts
CHANGED
|
@@ -1,21 +1,40 @@
|
|
|
1
1
|
import type { ElementRect, IEventRecorder } from './events.js';
|
|
2
|
-
import type { AutoZoomOptions
|
|
3
|
-
export type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import type { AutoZoomOptions } from './types.js';
|
|
3
|
+
export type CurrentZoomViewport = {
|
|
4
|
+
focusPoint: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
elementRect?: ElementRect;
|
|
9
|
+
end: {
|
|
10
|
+
pointPx: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
14
|
+
size: {
|
|
15
|
+
widthPx: number;
|
|
16
|
+
heightPx: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
optimalOffset?: {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
};
|
|
23
|
+
viewportSize: {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
};
|
|
8
27
|
};
|
|
9
28
|
export declare function setActiveAutoZoomRecorder(recorder: IEventRecorder | null): void;
|
|
10
|
-
export declare function
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function
|
|
29
|
+
export declare function getCurrentZoomViewport(): CurrentZoomViewport | null;
|
|
30
|
+
export type AutoZoomState = {
|
|
31
|
+
insideAutoZoom: boolean;
|
|
32
|
+
options: AutoZoomOptions;
|
|
33
|
+
currentZoomViewport: CurrentZoomViewport | null;
|
|
34
|
+
};
|
|
35
|
+
export declare function getAutoZoomState(): AutoZoomState;
|
|
36
|
+
export declare function setAutoZoomState(state: AutoZoomState): void;
|
|
37
|
+
export declare function setCurrentZoomViewport(viewport: CurrentZoomViewport | null): void;
|
|
19
38
|
/**
|
|
20
39
|
* Zooms the camera in on interactions inside `fn`, panning to follow each
|
|
21
40
|
* click and fill. After `fn` resolves the camera zooms back out.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoZoom.d.ts","sourceRoot":"","sources":["../../src/autoZoom.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"autoZoom.d.ts","sourceRoot":"","sources":["../../src/autoZoom.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAU,MAAM,YAAY,CAAA;AAezD,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACpC,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,GAAG,EAAE;QACH,OAAO,EAAE;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;QACjC,IAAI,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAA;KAC5C,CAAA;IACD,aAAa,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACxC,YAAY,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAChD,CAAA;AASD,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,cAAc,GAAG,IAAI,GAC9B,IAAI,CAEN;AAED,wBAAgB,sBAAsB,IAAI,mBAAmB,GAAG,IAAI,CAEnE;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,cAAc,EAAE,OAAO,CAAA;IACvB,OAAO,EAAE,eAAe,CAAA;IACxB,mBAAmB,EAAE,mBAAmB,GAAG,IAAI,CAAA;CAChD,CAAA;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAEhD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAE3D;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,mBAAmB,GAAG,IAAI,GACnC,IAAI,CAKN;AAeD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,QAAQ,CAC5B,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAC9B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,IAAI,CAAC,CAgFf"}
|
package/dist/src/autoZoom.js
CHANGED
|
@@ -1,50 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEFAULT_ZOOM_OPTIONS } from './defaults.js';
|
|
2
|
+
import { invalidOptionError, ScreenciError } from './errors.js';
|
|
3
|
+
function assertAutoZoomUnitIntervalOption(value, name) {
|
|
4
|
+
if (!Number.isFinite(value) || value < 0 || value > 1) {
|
|
5
|
+
throw invalidOptionError({
|
|
6
|
+
api: 'autoZoom',
|
|
7
|
+
option: name,
|
|
8
|
+
expectation: 'must be between 0 and 1',
|
|
9
|
+
value,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
2
13
|
let activeRecorder = null;
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let currentAllowZoomingOut = null;
|
|
9
|
-
let currentPostZoomInOutDelay = null;
|
|
10
|
-
let lastZoomLocation = null;
|
|
14
|
+
let currentAutoZoomState = {
|
|
15
|
+
insideAutoZoom: false,
|
|
16
|
+
options: {},
|
|
17
|
+
currentZoomViewport: null,
|
|
18
|
+
};
|
|
11
19
|
export function setActiveAutoZoomRecorder(recorder) {
|
|
12
20
|
activeRecorder = recorder;
|
|
13
21
|
}
|
|
14
|
-
export function
|
|
15
|
-
return
|
|
16
|
-
}
|
|
17
|
-
export function getZoomDuration() {
|
|
18
|
-
return currentZoomDuration;
|
|
19
|
-
}
|
|
20
|
-
export function getZoomEasing() {
|
|
21
|
-
return currentZoomEasing;
|
|
22
|
-
}
|
|
23
|
-
export function getZoomAmount() {
|
|
24
|
-
return currentZoomAmount;
|
|
25
|
-
}
|
|
26
|
-
export function getZoomCentering() {
|
|
27
|
-
return currentZoomCentering;
|
|
22
|
+
export function getCurrentZoomViewport() {
|
|
23
|
+
return currentAutoZoomState.currentZoomViewport;
|
|
28
24
|
}
|
|
29
|
-
export function
|
|
30
|
-
return
|
|
25
|
+
export function getAutoZoomState() {
|
|
26
|
+
return currentAutoZoomState;
|
|
31
27
|
}
|
|
32
|
-
export function
|
|
33
|
-
|
|
28
|
+
export function setAutoZoomState(state) {
|
|
29
|
+
currentAutoZoomState = state;
|
|
34
30
|
}
|
|
35
|
-
export function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
export function setCurrentZoomViewport(viewport) {
|
|
32
|
+
setAutoZoomState({
|
|
33
|
+
...currentAutoZoomState,
|
|
34
|
+
currentZoomViewport: viewport,
|
|
35
|
+
});
|
|
40
36
|
}
|
|
41
37
|
function sleep(ms) {
|
|
42
38
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
43
39
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
function resetAutoZoomState() {
|
|
41
|
+
setAutoZoomState({
|
|
42
|
+
...currentAutoZoomState,
|
|
43
|
+
insideAutoZoom: false,
|
|
44
|
+
options: {},
|
|
45
|
+
currentZoomViewport: null,
|
|
46
|
+
});
|
|
48
47
|
}
|
|
49
48
|
/**
|
|
50
49
|
* Zooms the camera in on interactions inside `fn`, panning to follow each
|
|
@@ -71,47 +70,79 @@ function resolveCenteringValue(centering) {
|
|
|
71
70
|
* ```
|
|
72
71
|
*/
|
|
73
72
|
export async function autoZoom(fn, options) {
|
|
74
|
-
if (insideAutoZoom) {
|
|
75
|
-
throw new
|
|
73
|
+
if (currentAutoZoomState.insideAutoZoom) {
|
|
74
|
+
throw new ScreenciError('Cannot nest autoZoom() calls');
|
|
76
75
|
}
|
|
77
76
|
if (activeRecorder !== null) {
|
|
78
77
|
activeRecorder.addAutoZoomStart(options);
|
|
79
78
|
}
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
const resolvedOptions = {
|
|
80
|
+
...DEFAULT_ZOOM_OPTIONS,
|
|
81
|
+
...(options ?? {}),
|
|
82
|
+
};
|
|
83
|
+
assertAutoZoomUnitIntervalOption(resolvedOptions.amount, 'amount');
|
|
84
|
+
assertAutoZoomUnitIntervalOption(resolvedOptions.centering, 'centering');
|
|
85
|
+
setAutoZoomState({
|
|
86
|
+
...currentAutoZoomState,
|
|
87
|
+
insideAutoZoom: true,
|
|
88
|
+
options: {
|
|
89
|
+
duration: resolvedOptions.duration,
|
|
90
|
+
easing: resolvedOptions.easing,
|
|
91
|
+
amount: resolvedOptions.amount,
|
|
92
|
+
...(options?.centering !== undefined
|
|
93
|
+
? { centering: options.centering }
|
|
94
|
+
: {}),
|
|
95
|
+
preZoomDelay: resolvedOptions.preZoomDelay,
|
|
96
|
+
postZoomDelay: resolvedOptions.postZoomDelay,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
89
99
|
try {
|
|
90
100
|
await fn();
|
|
101
|
+
if (activeRecorder !== null) {
|
|
102
|
+
activeRecorder.addAutoZoomEnd(options);
|
|
103
|
+
if (currentAutoZoomState.currentZoomViewport !== null) {
|
|
104
|
+
const zoomOutStartMs = Date.now();
|
|
105
|
+
activeRecorder.addInput('focusChange', undefined, [
|
|
106
|
+
{
|
|
107
|
+
type: 'focusChange',
|
|
108
|
+
startMs: zoomOutStartMs,
|
|
109
|
+
endMs: zoomOutStartMs +
|
|
110
|
+
(currentAutoZoomState.options.duration ??
|
|
111
|
+
DEFAULT_ZOOM_OPTIONS.duration),
|
|
112
|
+
x: currentAutoZoomState.currentZoomViewport.focusPoint.x,
|
|
113
|
+
y: currentAutoZoomState.currentZoomViewport.focusPoint.y,
|
|
114
|
+
...(currentAutoZoomState.currentZoomViewport.elementRect !==
|
|
115
|
+
undefined
|
|
116
|
+
? {
|
|
117
|
+
elementRect: currentAutoZoomState.currentZoomViewport.elementRect,
|
|
118
|
+
}
|
|
119
|
+
: {}),
|
|
120
|
+
zoom: {
|
|
121
|
+
startMs: zoomOutStartMs,
|
|
122
|
+
endMs: zoomOutStartMs +
|
|
123
|
+
(currentAutoZoomState.options.duration ??
|
|
124
|
+
DEFAULT_ZOOM_OPTIONS.duration),
|
|
125
|
+
easing: currentAutoZoomState.options.easing ??
|
|
126
|
+
DEFAULT_ZOOM_OPTIONS.easing,
|
|
127
|
+
end: {
|
|
128
|
+
pointPx: { x: 0, y: 0 },
|
|
129
|
+
size: {
|
|
130
|
+
widthPx: currentAutoZoomState.currentZoomViewport.viewportSize.width,
|
|
131
|
+
heightPx: currentAutoZoomState.currentZoomViewport.viewportSize
|
|
132
|
+
.height,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
]);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if ((currentAutoZoomState.options.postZoomDelay ?? 0) > 0) {
|
|
141
|
+
await sleep(currentAutoZoomState.options.postZoomDelay ?? 0);
|
|
142
|
+
}
|
|
91
143
|
}
|
|
92
144
|
finally {
|
|
93
|
-
|
|
94
|
-
lastZoomLocation = null;
|
|
95
|
-
currentZoomDuration = null;
|
|
96
|
-
currentZoomEasing = null;
|
|
97
|
-
currentZoomAmount = null;
|
|
98
|
-
currentZoomCentering = null;
|
|
99
|
-
currentAllowZoomingOut = null;
|
|
100
|
-
currentPostZoomInOutDelay = null;
|
|
101
|
-
}
|
|
102
|
-
const duration = options?.duration ?? DEFAULT_ZOOM_DURATION;
|
|
103
|
-
const postZoomInOutDelay = options?.postZoomInOutDelay ?? DEFAULT_POST_ZOOM_IN_OUT_DELAY;
|
|
104
|
-
const elapsed = Date.now() - zoomStartTime;
|
|
105
|
-
const remaining = duration + postZoomInOutDelay - elapsed;
|
|
106
|
-
if (remaining > 0) {
|
|
107
|
-
await sleep(remaining);
|
|
108
|
-
}
|
|
109
|
-
if (activeRecorder !== null) {
|
|
110
|
-
activeRecorder.addAutoZoomEnd(options);
|
|
111
|
-
}
|
|
112
|
-
const postEndDelay = duration + postZoomInOutDelay;
|
|
113
|
-
if (postEndDelay > 0) {
|
|
114
|
-
await sleep(postEndDelay);
|
|
145
|
+
resetAutoZoomState();
|
|
115
146
|
}
|
|
116
147
|
}
|
|
117
148
|
//# sourceMappingURL=autoZoom.js.map
|
package/dist/src/autoZoom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoZoom.js","sourceRoot":"","sources":["../../src/autoZoom.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"autoZoom.js","sourceRoot":"","sources":["../../src/autoZoom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAG/D,SAAS,gCAAgC,CACvC,KAAa,EACb,IAA4B;IAE5B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACtD,MAAM,kBAAkB,CAAC;YACvB,GAAG,EAAE,UAAU;YACf,MAAM,EAAE,IAAI;YACZ,WAAW,EAAE,yBAAyB;YACtC,KAAK;SACN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D,CAAC,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;wBACxD,GAAG,CAAC,oBAAoB,CAAC,mBAAmB,CAAC,WAAW;4BACxD,SAAS;4BACP,CAAC,CAAC;gCACE,WAAW,EACT,oBAAoB,CAAC,mBAAmB,CAAC,WAAW;6BACvD;4BACH,CAAC,CAAC,EAAE,CAAC;wBACP,IAAI,EAAE;4BACJ,OAAO,EAAE,cAAc;4BACvB,KAAK,EACH,cAAc;gCACd,CAAC,oBAAoB,CAAC,OAAO,CAAC,QAAQ;oCACpC,oBAAoB,CAAC,QAAQ,CAAC;4BAClC,MAAM,EACJ,oBAAoB,CAAC,OAAO,CAAC,MAAM;gCACnC,oBAAoB,CAAC,MAAM;4BAC7B,GAAG,EAAE;gCACH,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;gCACvB,IAAI,EAAE;oCACJ,OAAO,EACL,oBAAoB,CAAC,mBAAmB,CAAC,YAAY,CAAC,KAAK;oCAC7D,QAAQ,EACN,oBAAoB,CAAC,mBAAmB,CAAC,YAAY;yCAClD,MAAM;iCACZ;6BACF;yBACF;qBACF;iBACF,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QACD,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1D,MAAM,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC,CAAA;QAC9D,CAAC;IACH,CAAC;YAAS,CAAC;QACT,kBAAkB,EAAE,CAAA;IACtB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { Locator } from '@playwright/test';
|
|
2
|
+
import type { ElementRect, FocusChangeEvent } from './events.js';
|
|
3
|
+
import type { AutoZoomOptions, Easing } from './types.js';
|
|
4
|
+
type ScrollRectLike = {
|
|
5
|
+
top: number;
|
|
6
|
+
left: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
export type MouseMoveRequest = {
|
|
11
|
+
targetPosInElement?: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
} | undefined;
|
|
15
|
+
duration?: number;
|
|
16
|
+
speed?: number;
|
|
17
|
+
easing: Easing;
|
|
18
|
+
};
|
|
19
|
+
type ViewportSize = {
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
};
|
|
23
|
+
type Point = {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
};
|
|
27
|
+
type FocusSnapshot = {
|
|
28
|
+
locatorRect: ElementRect;
|
|
29
|
+
viewportSize: ViewportSize;
|
|
30
|
+
page: {
|
|
31
|
+
scrollY: number;
|
|
32
|
+
scrollX: number;
|
|
33
|
+
scrollHeight: number;
|
|
34
|
+
scrollWidth: number;
|
|
35
|
+
};
|
|
36
|
+
ancestors: Array<{
|
|
37
|
+
clientHeight: number;
|
|
38
|
+
clientWidth: number;
|
|
39
|
+
scrollHeight: number;
|
|
40
|
+
scrollWidth: number;
|
|
41
|
+
scrollTop: number;
|
|
42
|
+
scrollLeft: number;
|
|
43
|
+
rect: ScrollRectLike;
|
|
44
|
+
}>;
|
|
45
|
+
};
|
|
46
|
+
type ScrollPlan = {
|
|
47
|
+
startTop: number;
|
|
48
|
+
startLeft: number;
|
|
49
|
+
targetTop: number;
|
|
50
|
+
targetLeft: number;
|
|
51
|
+
};
|
|
52
|
+
type PageScrollPlan = {
|
|
53
|
+
startY: number;
|
|
54
|
+
startX: number;
|
|
55
|
+
targetY: number;
|
|
56
|
+
targetX: number;
|
|
57
|
+
};
|
|
58
|
+
type AxisRange = {
|
|
59
|
+
min: number;
|
|
60
|
+
max: number;
|
|
61
|
+
};
|
|
62
|
+
type UnifiedFocusPlan = {
|
|
63
|
+
finalLocatorRect: ElementRect;
|
|
64
|
+
ancestorScrollPlans: ScrollPlan[];
|
|
65
|
+
pageScrollPlan: PageScrollPlan;
|
|
66
|
+
scrollNeeded: boolean;
|
|
67
|
+
zoomNeeded: boolean;
|
|
68
|
+
finalFocusPoint: Point;
|
|
69
|
+
optimalOffset: Point;
|
|
70
|
+
};
|
|
71
|
+
type ScrollAndZoomTimingPlan = {
|
|
72
|
+
startDelay: number;
|
|
73
|
+
duration: number;
|
|
74
|
+
};
|
|
75
|
+
export declare function resolveFixedFocusViewportSize(viewport: ViewportSize, amount: number): ViewportSize;
|
|
76
|
+
export declare function resolveIdealFocusOriginForAxis(params: {
|
|
77
|
+
rectStart: number;
|
|
78
|
+
rectSize: number;
|
|
79
|
+
focusSize: number;
|
|
80
|
+
centering: number;
|
|
81
|
+
}): number;
|
|
82
|
+
export declare function resolveIdealFocusOrigin(rect: ElementRect, focusViewport: ViewportSize, centering: number): Point;
|
|
83
|
+
export declare function resolveOptimalOffset(ideal: Point, actual: Point): Point;
|
|
84
|
+
export declare function resolveScrollAndZoomTimingPlan(params: {
|
|
85
|
+
viewportSize: ViewportSize;
|
|
86
|
+
target: Point;
|
|
87
|
+
startViewportPos: Point;
|
|
88
|
+
duration: number;
|
|
89
|
+
easing: Easing;
|
|
90
|
+
cursorTriggerEdgeThreshold: number;
|
|
91
|
+
cursorTriggerMaxProgress: number;
|
|
92
|
+
}): ScrollAndZoomTimingPlan;
|
|
93
|
+
export declare function resolveTargetRectPosition(params: {
|
|
94
|
+
containerSize: ViewportSize;
|
|
95
|
+
rect: ElementRect;
|
|
96
|
+
amount: number;
|
|
97
|
+
centering: number;
|
|
98
|
+
}): Point;
|
|
99
|
+
export declare function buildAncestorScrollPlans(params: {
|
|
100
|
+
snapshot: FocusSnapshot;
|
|
101
|
+
projectedRectRangeX: AxisRange;
|
|
102
|
+
projectedRectRangeY: AxisRange;
|
|
103
|
+
}): {
|
|
104
|
+
plans: ScrollPlan[];
|
|
105
|
+
accumulatedDelta: Point;
|
|
106
|
+
projectedRect: ElementRect;
|
|
107
|
+
};
|
|
108
|
+
export declare function buildPageScrollPlan(snapshot: FocusSnapshot, ancestorProjection: {
|
|
109
|
+
accumulatedDelta: Point;
|
|
110
|
+
projectedRect: ElementRect;
|
|
111
|
+
}, options: {
|
|
112
|
+
targetRectPositionInViewport: Point;
|
|
113
|
+
residualOnly?: {
|
|
114
|
+
x: number;
|
|
115
|
+
y: number;
|
|
116
|
+
};
|
|
117
|
+
}): {
|
|
118
|
+
plan: PageScrollPlan;
|
|
119
|
+
finalLocatorRect: ElementRect;
|
|
120
|
+
};
|
|
121
|
+
export declare function combineFocusPlan(params: {
|
|
122
|
+
snapshot: FocusSnapshot;
|
|
123
|
+
amount: number;
|
|
124
|
+
centering: number;
|
|
125
|
+
currentZoomEnd: NonNullable<FocusChangeEvent['zoom']>['end'];
|
|
126
|
+
}): UnifiedFocusPlan;
|
|
127
|
+
export declare function changeFocus(locator: Locator, options?: AutoZoomOptions, mouseMove?: MouseMoveRequest): Promise<FocusChangeEvent>;
|
|
128
|
+
export {};
|
|
129
|
+
//# sourceMappingURL=changeFocus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changeFocus.d.ts","sourceRoot":"","sources":["../../src/changeFocus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAGhE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AASzD,KAAK,cAAc,GAAG;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAoBD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,kBAAkB,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM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