@e2edev/web 0.11.0-canary-20260921180210

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +112 -0
  4. package/dist/.build.json +1 -0
  5. package/dist/actions.d.ts +23 -0
  6. package/dist/actions.d.ts.map +1 -0
  7. package/dist/actions.js +174 -0
  8. package/dist/actions.js.map +1 -0
  9. package/dist/attempt-session.d.ts +76 -0
  10. package/dist/attempt-session.d.ts.map +1 -0
  11. package/dist/attempt-session.js +290 -0
  12. package/dist/attempt-session.js.map +1 -0
  13. package/dist/browser-connection.d.ts +34 -0
  14. package/dist/browser-connection.d.ts.map +1 -0
  15. package/dist/browser-connection.js +87 -0
  16. package/dist/browser-connection.js.map +1 -0
  17. package/dist/capture-scope.d.ts +21 -0
  18. package/dist/capture-scope.d.ts.map +1 -0
  19. package/dist/capture-scope.js +61 -0
  20. package/dist/capture-scope.js.map +1 -0
  21. package/dist/cdp-recovery.d.ts +29 -0
  22. package/dist/cdp-recovery.d.ts.map +1 -0
  23. package/dist/cdp-recovery.js +84 -0
  24. package/dist/cdp-recovery.js.map +1 -0
  25. package/dist/cdp-selectors.d.ts +14 -0
  26. package/dist/cdp-selectors.d.ts.map +1 -0
  27. package/dist/cdp-selectors.js +48 -0
  28. package/dist/cdp-selectors.js.map +1 -0
  29. package/dist/dialogs.d.ts +37 -0
  30. package/dist/dialogs.d.ts.map +1 -0
  31. package/dist/dialogs.js +78 -0
  32. package/dist/dialogs.js.map +1 -0
  33. package/dist/engine.d.ts +26 -0
  34. package/dist/engine.d.ts.map +1 -0
  35. package/dist/engine.js +166 -0
  36. package/dist/engine.js.map +1 -0
  37. package/dist/evaluation.d.ts +11 -0
  38. package/dist/evaluation.d.ts.map +1 -0
  39. package/dist/evaluation.js +27 -0
  40. package/dist/evaluation.js.map +1 -0
  41. package/dist/index.d.ts +21 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +14 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/install.d.ts +40 -0
  46. package/dist/install.d.ts.map +1 -0
  47. package/dist/install.js +117 -0
  48. package/dist/install.js.map +1 -0
  49. package/dist/locators.d.ts +74 -0
  50. package/dist/locators.d.ts.map +1 -0
  51. package/dist/locators.js +260 -0
  52. package/dist/locators.js.map +1 -0
  53. package/dist/observation-capture.d.ts +12 -0
  54. package/dist/observation-capture.d.ts.map +1 -0
  55. package/dist/observation-capture.js +93 -0
  56. package/dist/observation-capture.js.map +1 -0
  57. package/dist/observation.d.ts +63 -0
  58. package/dist/observation.d.ts.map +1 -0
  59. package/dist/observation.js +262 -0
  60. package/dist/observation.js.map +1 -0
  61. package/dist/observe.d.ts +51 -0
  62. package/dist/observe.d.ts.map +1 -0
  63. package/dist/observe.js +104 -0
  64. package/dist/observe.js.map +1 -0
  65. package/dist/operation-budget.d.ts +11 -0
  66. package/dist/operation-budget.d.ts.map +1 -0
  67. package/dist/operation-budget.js +40 -0
  68. package/dist/operation-budget.js.map +1 -0
  69. package/dist/protected-app.d.ts +32 -0
  70. package/dist/protected-app.d.ts.map +1 -0
  71. package/dist/protected-app.js +39 -0
  72. package/dist/protected-app.js.map +1 -0
  73. package/dist/read-node.d.ts +170 -0
  74. package/dist/read-node.d.ts.map +1 -0
  75. package/dist/read-node.js +823 -0
  76. package/dist/read-node.js.map +1 -0
  77. package/dist/refs.d.ts +43 -0
  78. package/dist/refs.d.ts.map +1 -0
  79. package/dist/refs.js +85 -0
  80. package/dist/refs.js.map +1 -0
  81. package/dist/route-pattern.d.ts +15 -0
  82. package/dist/route-pattern.d.ts.map +1 -0
  83. package/dist/route-pattern.js +68 -0
  84. package/dist/route-pattern.js.map +1 -0
  85. package/dist/support.d.ts +119 -0
  86. package/dist/support.d.ts.map +1 -0
  87. package/dist/support.js +299 -0
  88. package/dist/support.js.map +1 -0
  89. package/dist/surface.d.ts +257 -0
  90. package/dist/surface.d.ts.map +1 -0
  91. package/dist/surface.js +587 -0
  92. package/dist/surface.js.map +1 -0
  93. package/dist/video.d.ts +59 -0
  94. package/dist/video.d.ts.map +1 -0
  95. package/dist/video.js +115 -0
  96. package/dist/video.js.map +1 -0
  97. package/dist/web.d.ts +191 -0
  98. package/dist/web.d.ts.map +1 -0
  99. package/dist/web.js +354 -0
  100. package/dist/web.js.map +1 -0
  101. package/package.json +67 -0
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The attempt's recording on the Playwright surface.
3
+ *
4
+ * A screencast belongs to one page, so a recording is a series of segments:
5
+ * one per page the attempt shows. `arm` starts the first segment on the
6
+ * attempt's page; a page about to close (a restart, a context replaced by a
7
+ * state reset) ends its segment first, since Playwright writes nothing for a
8
+ * screencast whose page closed under it, and the next page the attempt opens
9
+ * starts the next segment. Each segment is captured at the attempt's viewport
10
+ * size and carries the instant it began, so a consumer can place step
11
+ * timestamps on it. The first segment is `video/video.webm`; later ones are
12
+ * `video/video-part<n>.webm`. Without a recording, every hook here is a no-op.
13
+ */
14
+ import type { Page } from 'playwright';
15
+ import { type VideoSegment, type ViewportSize } from 'e2e/engine';
16
+ export declare class VideoRecorder {
17
+ private readonly artifactsDir;
18
+ private readonly viewport;
19
+ /** Set by `arm`, cleared by `stop`; pages the attempt opens in between start segments. */
20
+ private armed;
21
+ private current;
22
+ /** Segments finished this attempt, in order; `stop` hands them over. */
23
+ private finished;
24
+ /** Segments started this attempt, for their file names. */
25
+ private count;
26
+ /** The first segment whose stop failed and left no file; `stop` reports it. */
27
+ private lost;
28
+ constructor(viewport: ViewportSize, artifactsDir: string);
29
+ /** True between `arm` and `stop`: a page the attempt opens then starts a segment. */
30
+ get isArmed(): boolean;
31
+ /** True while a segment records, so a context closing early can end it within a budget. */
32
+ get isRecording(): boolean;
33
+ /** Starts the recording on `page`, unless a segment already records, and arms it. */
34
+ arm(page: Page): Promise<void>;
35
+ /** A page the attempt opened: the next segment, when armed. */
36
+ pageOpened(page: Page): Promise<void>;
37
+ /** The recorded page is about to close: its segment ends here, while the page can still flush it. */
38
+ pageClosing(): Promise<void>;
39
+ /**
40
+ * Ends the recording and returns every segment written this attempt, in
41
+ * order. A segment that was lost (its stop failed and left no file) is
42
+ * reported instead: the harness records that as a cleanup failure, and the
43
+ * segments that did finalize stay on disk.
44
+ */
45
+ stop(): Promise<readonly VideoSegment[]>;
46
+ /**
47
+ * Starts one segment on a page, a screencast at the attempt's viewport size.
48
+ * A segment still recording (a page the app closed on its own) ends first.
49
+ */
50
+ private begin;
51
+ /**
52
+ * Ends the segment in progress. A stop that failed but left a file keeps
53
+ * the file; one that left nothing (a page closed before the stop, which
54
+ * Playwright never flushes) lost the segment, which `stop` reports. A
55
+ * segment that wrote nothing is not a segment.
56
+ */
57
+ private end;
58
+ }
59
+ //# sourceMappingURL=video.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../src/video.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAe,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAW/E,qBAAa,aAAa;IActB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAb/B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,0FAA0F;IAC1F,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,OAAO,CAAwB;IACvC,wEAAwE;IACxE,OAAO,CAAC,QAAQ,CAAsB;IACtC,2DAA2D;IAC3D,OAAO,CAAC,KAAK,CAAK;IAClB,+EAA+E;IAC/E,OAAO,CAAC,IAAI,CAAqE;IAEjF,YACE,QAAQ,EAAE,YAAY,EACL,YAAY,EAAE,MAAM,EAGtC;IAED,qFAAqF;IACrF,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,2FAA2F;IAC3F,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,qFAAqF;IAC/E,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAGnC;IAED,+DAA+D;IACzD,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1C;IAED,qGAAqG;IACrG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED;;;;;OAKG;IACG,IAAI,IAAI,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC,CAa7C;IAED;;;OAGG;YACW,KAAK;IAcnB;;;;;OAKG;YACW,GAAG;CAgBlB"}
package/dist/video.js ADDED
@@ -0,0 +1,115 @@
1
+ /**
2
+ * The attempt's recording on the Playwright surface.
3
+ *
4
+ * A screencast belongs to one page, so a recording is a series of segments:
5
+ * one per page the attempt shows. `arm` starts the first segment on the
6
+ * attempt's page; a page about to close (a restart, a context replaced by a
7
+ * state reset) ends its segment first, since Playwright writes nothing for a
8
+ * screencast whose page closed under it, and the next page the attempt opens
9
+ * starts the next segment. Each segment is captured at the attempt's viewport
10
+ * size and carries the instant it began, so a consumer can place step
11
+ * timestamps on it. The first segment is `video/video.webm`; later ones are
12
+ * `video/video-part<n>.webm`. Without a recording, every hook here is a no-op.
13
+ */
14
+ import { existsSync, mkdirSync } from 'node:fs';
15
+ import path from 'node:path';
16
+ import { EngineError } from 'e2e/engine';
17
+ import { message } from './support.js';
18
+ export class VideoRecorder {
19
+ artifactsDir;
20
+ viewport;
21
+ /** Set by `arm`, cleared by `stop`; pages the attempt opens in between start segments. */
22
+ armed = false;
23
+ current = null;
24
+ /** Segments finished this attempt, in order; `stop` hands them over. */
25
+ finished = [];
26
+ /** Segments started this attempt, for their file names. */
27
+ count = 0;
28
+ /** The first segment whose stop failed and left no file; `stop` reports it. */
29
+ lost;
30
+ constructor(viewport, artifactsDir) {
31
+ this.artifactsDir = artifactsDir;
32
+ this.viewport = viewport;
33
+ }
34
+ /** True between `arm` and `stop`: a page the attempt opens then starts a segment. */
35
+ get isArmed() {
36
+ return this.armed;
37
+ }
38
+ /** True while a segment records, so a context closing early can end it within a budget. */
39
+ get isRecording() {
40
+ return this.current !== null;
41
+ }
42
+ /** Starts the recording on `page`, unless a segment already records, and arms it. */
43
+ async arm(page) {
44
+ if (this.current === null)
45
+ await this.begin(page);
46
+ this.armed = true;
47
+ }
48
+ /** A page the attempt opened: the next segment, when armed. */
49
+ async pageOpened(page) {
50
+ if (this.armed)
51
+ await this.begin(page);
52
+ }
53
+ /** The recorded page is about to close: its segment ends here, while the page can still flush it. */
54
+ pageClosing() {
55
+ return this.end();
56
+ }
57
+ /**
58
+ * Ends the recording and returns every segment written this attempt, in
59
+ * order. A segment that was lost (its stop failed and left no file) is
60
+ * reported instead: the harness records that as a cleanup failure, and the
61
+ * segments that did finalize stay on disk.
62
+ */
63
+ async stop() {
64
+ await this.end();
65
+ this.armed = false;
66
+ const lost = this.lost;
67
+ this.lost = undefined;
68
+ if (lost !== undefined) {
69
+ throw new EngineError('ENGINE_FAILURE', `video segment ${lost.relative} could not be finalized: ${message(lost.cause)}`, { retryable: false, cause: lost.cause });
70
+ }
71
+ return this.finished.splice(0);
72
+ }
73
+ /**
74
+ * Starts one segment on a page, a screencast at the attempt's viewport size.
75
+ * A segment still recording (a page the app closed on its own) ends first.
76
+ */
77
+ async begin(page) {
78
+ await this.end();
79
+ this.count += 1;
80
+ const name = this.count === 1 ? 'video' : `video-part${String(this.count)}`;
81
+ const relative = path.posix.join('video', `${name}.webm`);
82
+ const absolute = path.join(this.artifactsDir, relative);
83
+ mkdirSync(path.dirname(absolute), { recursive: true });
84
+ await page.screencast.start({
85
+ path: absolute,
86
+ size: { width: this.viewport.width, height: this.viewport.height },
87
+ });
88
+ this.current = { page, relative, absolute, startedAt: new Date().toISOString() };
89
+ }
90
+ /**
91
+ * Ends the segment in progress. A stop that failed but left a file keeps
92
+ * the file; one that left nothing (a page closed before the stop, which
93
+ * Playwright never flushes) lost the segment, which `stop` reports. A
94
+ * segment that wrote nothing is not a segment.
95
+ */
96
+ async end() {
97
+ const segment = this.current;
98
+ if (segment === null)
99
+ return;
100
+ this.current = null;
101
+ try {
102
+ await segment.page.screencast.stop();
103
+ }
104
+ catch (cause) {
105
+ if (!existsSync(segment.absolute)) {
106
+ this.lost ??= { relative: segment.relative, cause };
107
+ return;
108
+ }
109
+ }
110
+ if (existsSync(segment.absolute)) {
111
+ this.finished.push({ path: segment.relative, startedAt: segment.startedAt });
112
+ }
113
+ }
114
+ }
115
+ //# sourceMappingURL=video.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"video.js","sourceRoot":"","sources":["../src/video.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAwC,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAUvC,MAAM,OAAO,aAAa;IAcL,YAAY;IAbd,QAAQ,CAAe;IACxC,0FAA0F;IAClF,KAAK,GAAG,KAAK,CAAC;IACd,OAAO,GAAmB,IAAI,CAAC;IACvC,wEAAwE;IAChE,QAAQ,GAAmB,EAAE,CAAC;IACtC,2DAA2D;IACnD,KAAK,GAAG,CAAC,CAAC;IAClB,+EAA+E;IACvE,IAAI,CAAqE;IAEjF,YACE,QAAsB,EACL,YAAoB;4BAApB,YAAY;QAE7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,qFAAqF;IACrF,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,2FAA2F;IAC3F,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC;IAC/B,CAAC;IAED,qFAAqF;IACrF,KAAK,CAAC,GAAG,CAAC,IAAU;QAClB,IAAI,IAAI,CAAC,O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AO,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;CACF"}
package/dist/web.d.ts ADDED
@@ -0,0 +1,191 @@
1
+ /**
2
+ * The `web` fixture: the browser-shaped deterministic surface this engine
3
+ * contributes. It lives here, not in core, because the harness knows the
4
+ * engine contract and never a platform's fixture shape. Every async method
5
+ * runs as a harness-recorded `web.<method>` step; `expect(web)` reaches the
6
+ * matchers attached through `context.expectable`.
7
+ *
8
+ * Layering rule: validation (`resolveUrl`, JSON checks, cookie URLs, the
9
+ * download trigger) runs outside `surface.guard`, so a runner error keeps its
10
+ * classification and only Playwright faults are translated. The URL rule is
11
+ * never re-implemented here: `context.app.resolveUrl` is the one place that
12
+ * says which URLs a test may open.
13
+ */
14
+ import type { ActionOptions, Expectable, JsonValue, Locator, Screen, TextMatch } from 'e2e';
15
+ import { type EngineFixtureContext } from 'e2e/engine';
16
+ import type { DialogHandler } from './dialogs.ts';
17
+ import type { PlaywrightSurface } from './surface.ts';
18
+ /** `json` or `body`, never both; neither fulfills with an empty body. */
19
+ export type RouteFulfillResponse = {
20
+ status?: number;
21
+ headers?: Record<string, string>;
22
+ } & ({
23
+ json: JsonValue;
24
+ body?: never;
25
+ } | {
26
+ body: string;
27
+ json?: never;
28
+ } | {
29
+ body?: never;
30
+ json?: never;
31
+ });
32
+ export interface WebRoute {
33
+ /** The intercepted request. */
34
+ readonly request: {
35
+ readonly url: string;
36
+ readonly method: string;
37
+ readonly headers: Readonly<Record<string, string>>;
38
+ readonly postData?: string;
39
+ };
40
+ /** Fulfills the intercepted request once. */
41
+ fulfill(response: RouteFulfillResponse): Promise<void>;
42
+ /** Continues the intercepted request once. */
43
+ continue(): Promise<void>;
44
+ /** Aborts the intercepted request once. */
45
+ abort(): Promise<void>;
46
+ }
47
+ export interface WebResponse {
48
+ /** Response URL. */
49
+ readonly url: string;
50
+ /** HTTP status. */
51
+ readonly status: number;
52
+ /** Response headers, lower-cased names. */
53
+ readonly headers: Readonly<Record<string, string>>;
54
+ /** Parses the response body as JSON. */
55
+ json<T = unknown>(): Promise<T>;
56
+ /** Reads the response body as text. */
57
+ text(): Promise<string>;
58
+ }
59
+ export interface CookieFields {
60
+ /** Cookie name. */
61
+ name: string;
62
+ /** Cookie value. */
63
+ value: string;
64
+ /** Unix timestamp in whole seconds. */
65
+ expires?: number;
66
+ /** HttpOnly flag. */
67
+ httpOnly?: boolean;
68
+ /** Secure flag. */
69
+ secure?: boolean;
70
+ /** SameSite attribute. */
71
+ sameSite?: 'Strict' | 'Lax' | 'None';
72
+ }
73
+ /** `url`, or `domain` with an optional `path`, never both. */
74
+ export type Cookie = CookieFields & ({
75
+ url: string;
76
+ domain?: never;
77
+ path?: never;
78
+ } | {
79
+ url?: never;
80
+ domain: string;
81
+ path?: string;
82
+ });
83
+ export interface WebExpectation {
84
+ /** Inverts the matcher. */
85
+ readonly not: WebExpectation;
86
+ /** Waits for the current URL to match. */
87
+ toHaveURL(expected: string | RegExp, options?: {
88
+ timeout?: number;
89
+ }): Promise<void>;
90
+ /** Waits for the current title to match. */
91
+ toHaveTitle(expected: TextMatch, options?: {
92
+ timeout?: number;
93
+ }): Promise<void>;
94
+ /** Waits for the target's `class` attribute to match: a string is the whole normalized class list, a RegExp is tested against it. */
95
+ toHaveClass(target: Locator, expected: TextMatch, options?: {
96
+ timeout?: number;
97
+ }): Promise<void>;
98
+ }
99
+ /**
100
+ * The screen scope `web.frameLocator` returns. Every `Screen` query answers
101
+ * from inside the frame, and because the frame's document is Playwright's,
102
+ * the web-only escape hatches follow it in: `locator` for a CSS or XPath
103
+ * selector on a control with no accessible name, `frameLocator` for a frame
104
+ * nested inside this one.
105
+ */
106
+ export interface FrameScreen extends Screen {
107
+ /** Creates a web-only CSS or XPath locator inside this frame. */
108
+ locator(selector: string): Locator;
109
+ /** Creates a screen query scope inside an iframe nested in this frame. */
110
+ frameLocator(selector: string): FrameScreen;
111
+ }
112
+ export interface Web extends Expectable<WebExpectation> {
113
+ /** Navigates to an allowed URL. */
114
+ goto(url: string, options?: {
115
+ waitUntil?: 'load' | 'domcontentloaded' | 'networkidle';
116
+ timeout?: number;
117
+ }): Promise<void>;
118
+ /** Reloads the current document. */
119
+ reload(options?: ActionOptions): Promise<void>;
120
+ /** Navigates browser history back once. */
121
+ back(options?: ActionOptions): Promise<void>;
122
+ /** Navigates browser history forward once. */
123
+ forward(options?: ActionOptions): Promise<void>;
124
+ /** Returns the current URL. */
125
+ url(): Promise<string>;
126
+ /** Returns the current title. */
127
+ title(): Promise<string>;
128
+ /** Waits for the current URL to match. */
129
+ waitForURL(url: string | RegExp, options?: {
130
+ timeout?: number;
131
+ }): Promise<void>;
132
+ /** Creates a web-only CSS or XPath locator. */
133
+ locator(selector: string): Locator;
134
+ /** Creates a screen query scope inside one iframe. */
135
+ frameLocator(selector: string): FrameScreen;
136
+ /** Evaluates trusted test code in the page. */
137
+ evaluate<T extends JsonValue>(fn: string | (() => T | Promise<T>)): Promise<T>;
138
+ /** Evaluates trusted test code with one required JSON-safe argument. */
139
+ evaluate<T extends JsonValue, Arg extends JsonValue>(fn: string | ((arg: Arg) => T | Promise<T>), arg: Arg): Promise<T>;
140
+ /** Adds an attempt-scoped network route. */
141
+ route(pattern: string | RegExp, handler: (route: WebRoute) => void | Promise<void>): Promise<void>;
142
+ /** Removes matching attempt-scoped routes. */
143
+ unroute(pattern: string | RegExp): Promise<void>;
144
+ /** Waits for a matching response. */
145
+ waitForResponse(pattern: string | RegExp, options?: {
146
+ timeout?: number;
147
+ }): Promise<WebResponse>;
148
+ /** Returns cookies visible to the current context. */
149
+ cookies(): Promise<Cookie[]>;
150
+ /** Sets cookies after URL validation. */
151
+ setCookies(cookies: readonly Cookie[]): Promise<void>;
152
+ /** Sets the viewport size. */
153
+ setViewport(size: {
154
+ width: number;
155
+ height: number;
156
+ }): Promise<void>;
157
+ /** Registers an attempt-scoped dialog handler and returns an unsubscribe function. */
158
+ onDialog(handler: DialogHandler): Promise<() => Promise<void>>;
159
+ /** Runs a trigger and waits for its download. */
160
+ waitForDownload(trigger: () => Promise<void>, options?: {
161
+ timeout?: number;
162
+ }): Promise<{
163
+ path: string;
164
+ suggestedFilename: string;
165
+ }>;
166
+ /** Viewport-level keyboard, for whatever has focus. */
167
+ readonly keyboard: {
168
+ /** Sends one key. */
169
+ press(key: string): Promise<void>;
170
+ /** Types plain text. */
171
+ type(text: string): Promise<void>;
172
+ };
173
+ /**
174
+ * Direct pointer input from test code, independent of agent observations.
175
+ * After CDP recovery, test code can read current geometry with `evaluate`
176
+ * before starting a pointer sequence.
177
+ */
178
+ readonly mouse: {
179
+ /** Moves the pointer. */
180
+ move(x: number, y: number): Promise<void>;
181
+ /** Scrolls the pointer wheel. */
182
+ wheel(deltaX: number, deltaY: number): Promise<void>;
183
+ /** Presses the primary pointer button. */
184
+ down(): Promise<void>;
185
+ /** Releases the primary pointer button. */
186
+ up(): Promise<void>;
187
+ };
188
+ }
189
+ /** Builds the `web` fixture for one attempt over the shared surface. */
190
+ export declare function createWebFixture(surface: PlaywrightSurface, context: EngineFixtureContext): Web;
191
+ //# sourceMappingURL=web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAC5F,OAAO,EASL,KAAK,oBAAoB,EAM1B,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAIlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,yEAAyE;AACzE,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CA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