@pixui-dev/inflight-test 0.0.7

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.
@@ -0,0 +1,1679 @@
1
+ import { A as TestArtifact, C as joinPath, D as SuiteCollector, E as SuiteAPI, F as beforeEach, I as onTestFailed, L as onTestFinished, M as afterAll, N as afterEach, O as Test, P as beforeAll, S as createRunId, T as FileSpecification, _ as ProgressSurface, a as StartOptions, b as QuickjsReportIo, c as start, d as CaptureScreenRequest, f as CaptureScreenResult, g as ConsoleProgressSurface, h as CollectingProgressSurface, i as RunProgressEvent, j as VitestRunner, k as TestAPI, l as ActivityBridge, m as PROTOCOL_CAPTURE_SCREEN_CALLBACK, n as InflightRunResult, o as TestFileSpec, p as PROTOCOL_CAPTURE_SCREEN, r as InflightVitestRunner, s as run, t as InflightRunOptions, u as CaptureRect, v as MemoryReportIo, w as File, x as ReportIo, y as QuickjsOs } from "./run-tests-DoriyCYM.js";
2
+
3
+ //#region src/vendored/runtime/runner/suite.d.ts
4
+ /**
5
+ * Creates a suite of tests, allowing for grouping and hierarchical organization of tests.
6
+ * Suites can contain both tests and other suites, enabling complex test structures.
7
+ *
8
+ * @param {string} name - The name of the suite, used for identification and reporting.
9
+ * @param {Function} fn - A function that defines the tests and suites within this suite.
10
+ * @example
11
+ * ```ts
12
+ * // Define a suite with two tests
13
+ * suite('Math operations', () => {
14
+ * test('should add two numbers', () => {
15
+ * expect(add(1, 2)).toBe(3);
16
+ * });
17
+ *
18
+ * test('should subtract two numbers', () => {
19
+ * expect(subtract(5, 2)).toBe(3);
20
+ * });
21
+ * });
22
+ * ```
23
+ * @example
24
+ * ```ts
25
+ * // Define nested suites
26
+ * suite('String operations', () => {
27
+ * suite('Trimming', () => {
28
+ * test('should trim whitespace from start and end', () => {
29
+ * expect(' hello '.trim()).toBe('hello');
30
+ * });
31
+ * });
32
+ *
33
+ * suite('Concatenation', () => {
34
+ * test('should concatenate two strings', () => {
35
+ * expect('hello' + ' ' + 'world').toBe('hello world');
36
+ * });
37
+ * });
38
+ * });
39
+ * ```
40
+ */
41
+ declare const suite: SuiteAPI;
42
+ /**
43
+ * Defines a test case with a given name and test function. The test function can optionally be configured with test options.
44
+ *
45
+ * @param {string | Function} name - The name of the test or a function that will be used as a test name.
46
+ * @param {TestOptions | TestFunction} [optionsOrFn] - Optional. The test options or the test function if no explicit name is provided.
47
+ * @param {number | TestOptions | TestFunction} [optionsOrTest] - Optional. The test function or options, depending on the previous parameters.
48
+ * @throws {Error} If called inside another test function.
49
+ * @example
50
+ * ```ts
51
+ * // Define a simple test
52
+ * test('should add two numbers', () => {
53
+ * expect(add(1, 2)).toBe(3);
54
+ * });
55
+ * ```
56
+ * @example
57
+ * ```ts
58
+ * // Define a test with options
59
+ * test('should subtract two numbers', { retry: 3 }, () => {
60
+ * expect(subtract(5, 2)).toBe(3);
61
+ * });
62
+ * ```
63
+ */
64
+ declare const test: TestAPI;
65
+ /**
66
+ * Creates a suite of tests, allowing for grouping and hierarchical organization of tests.
67
+ * Suites can contain both tests and other suites, enabling complex test structures.
68
+ *
69
+ * @param {string} name - The name of the suite, used for identification and reporting.
70
+ * @param {Function} fn - A function that defines the tests and suites within this suite.
71
+ * @example
72
+ * ```ts
73
+ * // Define a suite with two tests
74
+ * describe('Math operations', () => {
75
+ * test('should add two numbers', () => {
76
+ * expect(add(1, 2)).toBe(3);
77
+ * });
78
+ *
79
+ * test('should subtract two numbers', () => {
80
+ * expect(subtract(5, 2)).toBe(3);
81
+ * });
82
+ * });
83
+ * ```
84
+ * @example
85
+ * ```ts
86
+ * // Define nested suites
87
+ * describe('String operations', () => {
88
+ * describe('Trimming', () => {
89
+ * test('should trim whitespace from start and end', () => {
90
+ * expect(' hello '.trim()).toBe('hello');
91
+ * });
92
+ * });
93
+ *
94
+ * describe('Concatenation', () => {
95
+ * test('should concatenate two strings', () => {
96
+ * expect('hello' + ' ' + 'world').toBe('hello world');
97
+ * });
98
+ * });
99
+ * });
100
+ * ```
101
+ */
102
+ declare const describe: SuiteAPI;
103
+ /**
104
+ * Defines a test case with a given name and test function. The test function can optionally be configured with test options.
105
+ *
106
+ * @param {string | Function} name - The name of the test or a function that will be used as a test name.
107
+ * @param {TestOptions | TestFunction} [optionsOrFn] - Optional. The test options or the test function if no explicit name is provided.
108
+ * @param {number | TestOptions | TestFunction} [optionsOrTest] - Optional. The test function or options, depending on the previous parameters.
109
+ * @throws {Error} If called inside another test function.
110
+ * @example
111
+ * ```ts
112
+ * // Define a simple test
113
+ * it('adds two numbers', () => {
114
+ * expect(add(1, 2)).toBe(3);
115
+ * });
116
+ * ```
117
+ * @example
118
+ * ```ts
119
+ * // Define a test with options
120
+ * it('subtracts two numbers', { retry: 3 }, () => {
121
+ * expect(subtract(5, 2)).toBe(3);
122
+ * });
123
+ * ```
124
+ */
125
+ declare const it: TestAPI;
126
+ declare function getRunner(): VitestRunner;
127
+ declare function getCurrentSuite<ExtraContext = object>(): SuiteCollector<ExtraContext>;
128
+ //#endregion
129
+ //#region src/vendored/runtime/runner/artifact.d.ts
130
+ /**
131
+ * @experimental
132
+ * @advanced
133
+ *
134
+ * Records a custom test artifact during test execution.
135
+ *
136
+ * This function allows you to attach structured data, files, or metadata to a test.
137
+ *
138
+ * Vitest automatically injects the source location where the artifact was created and manages any attachments you include.
139
+ *
140
+ * **Note:** artifacts must be recorded before the task is reported. Any artifacts recorded after that will not be included in the task.
141
+ *
142
+ * @param task - The test task context, typically accessed via `this.task` in custom matchers or `context.task` in tests
143
+ * @param artifact - The artifact to record. Must extend {@linkcode TestArtifactBase}
144
+ *
145
+ * @returns A promise that resolves to the recorded artifact with location injected
146
+ *
147
+ * @throws {Error} If the test runner doesn't support artifacts
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * // In a custom assertion
152
+ * async function toHaveValidSchema(this: MatcherState, actual: unknown) {
153
+ * const validation = validateSchema(actual)
154
+ *
155
+ * await recordArtifact(this.task, {
156
+ * type: 'my-plugin:schema-validation',
157
+ * passed: validation.valid,
158
+ * errors: validation.errors,
159
+ * })
160
+ *
161
+ * return { pass: validation.valid, message: () => '...' }
162
+ * }
163
+ * ```
164
+ */
165
+ declare function recordArtifact<Artifact extends TestArtifact>(task: Test, artifact: Artifact): Promise<Artifact>;
166
+ //#endregion
167
+ //#region src/vendored/runtime/runner/run.d.ts
168
+ declare function startTests(specs: string[] | FileSpecification[], runner: VitestRunner): Promise<File[]>;
169
+ //#endregion
170
+ //#region src/vendored/runtime/runner/collect.d.ts
171
+ declare function collectTests(specs: string[] | FileSpecification[], runner: VitestRunner): Promise<File[]>;
172
+ //#endregion
173
+ //#region src/expect.d.ts
174
+ /**
175
+ * `expect` assembled from the pure-JS `@vitest/expect` package.
176
+ *
177
+ * Per req 1.2 we reuse vitest's matcher implementations rather than rolling
178
+ * our own: chai is augmented with `JestExtend` (enables `expect.extend`) and
179
+ * `JestChaiExpect` (the `toBe` / `toEqual` / `toThrow` / … matcher set), then
180
+ * we expose chai's `expect` entry point.
181
+ *
182
+ * NOTE (v1 scope): asymmetric matchers (`expect.any`, …), `expect.soft`,
183
+ * `expect.poll` and snapshot matchers are not wired up yet — they can be
184
+ * layered on by porting vitest's `createExpect` once the core run loop is in
185
+ * place.
186
+ */
187
+ declare const expect: Chai.ExpectStatic;
188
+ //#endregion
189
+ //#region src/reporter/blob-report.d.ts
190
+ interface BlobReportInput {
191
+ /** The runner task tree (`File[]` returned by `startTests`). */
192
+ files: unknown[];
193
+ /** Unhandled errors collected during the run. */
194
+ errors?: unknown[];
195
+ /** Total wall-clock execution time, ms. */
196
+ executionTime: number;
197
+ }
198
+ /**
199
+ * Serialize a blob report payload, byte-for-byte compatible with what
200
+ * Vitest's own BlobReporter would write (modulo the empty coverage / module
201
+ * graph fields described above).
202
+ */
203
+ declare function serializeBlobReport(input: BlobReportInput): string;
204
+ interface WriteBlobReportOptions extends BlobReportInput {
205
+ /** Report root, e.g. `<external.writeablePath>/inflight-test-report`. */
206
+ reportRoot: string;
207
+ /** Pre-computed run id; defaults to a fresh local-time id. */
208
+ runId?: string;
209
+ }
210
+ interface WrittenReport {
211
+ /** Absolute path of this run's directory. */
212
+ runDir: string;
213
+ /** Absolute path of the written `report.blob`. */
214
+ blobPath: string;
215
+ runId: string;
216
+ }
217
+ /**
218
+ * Write `<reportRoot>/<run-id>/report.blob` via the injected {@link ReportIo}.
219
+ * Returns the resolved paths (the run dir is surfaced to the user on the
220
+ * end-of-run summary — req 4.3).
221
+ */
222
+ declare function writeBlobReport(io: ReportIo, options: WriteBlobReportOptions): WrittenReport;
223
+ //#endregion
224
+ //#region src/page/screenshot.d.ts
225
+ interface CaptureScreenshotOptions {
226
+ bridge: ActivityBridge;
227
+ io: ReportIo;
228
+ /** Absolute run directory; screenshots land in `<runDir>/screenshots/`. */
229
+ runDir: string;
230
+ /** File name within `screenshots/`, e.g. `<test-id>__<name>.png`. */
231
+ fileName: string;
232
+ /** Region to capture; defaults to the full `window.screen`. */
233
+ clip?: CaptureRect;
234
+ timeoutMs?: number;
235
+ }
236
+ interface CapturedScreenshot {
237
+ /** Path relative to the run directory — stored on the artifact (req 5.5). */
238
+ relativePath: string;
239
+ /** Absolute path written. */
240
+ absolutePath: string;
241
+ /** The PNG bytes. */
242
+ bytes: Uint8Array;
243
+ }
244
+ declare function captureScreenshot(options: CaptureScreenshotOptions): Promise<CapturedScreenshot>;
245
+ //#endregion
246
+ //#region src/page/simulated-bridge.d.ts
247
+ /** A minimal valid 1×1 transparent PNG, used as the default rendered frame. */
248
+ declare const TINY_PNG: Uint8Array;
249
+ interface SimulatedScreenshotHostOptions {
250
+ /** Produce PNG bytes for a capture request. Default: {@link TINY_PNG}. */
251
+ render?: (req: CaptureScreenRequest) => Uint8Array;
252
+ /**
253
+ * The host writes its PNG into this ReportIo and replies with its `savePath`
254
+ * (exercising the os.read copy path). Pass the SAME ReportIo the screenshot
255
+ * reader uses so the round-trip closes. Required for a successful capture.
256
+ */
257
+ io?: ReportIo;
258
+ /** Temp directory the host writes into (with `io`). Default `/pandora-capture-tmp`. */
259
+ tempDir?: string;
260
+ /** Simulate a failed capture — reply with an empty `savePath`. */
261
+ fail?: boolean;
262
+ /** Reply latency in ms (default 0 — replies on a microtask). */
263
+ latencyMs?: number;
264
+ }
265
+ type Handler = (payload: unknown) => void;
266
+ declare class SimulatedActivityBridge implements ActivityBridge {
267
+ private readonly _handlers;
268
+ private readonly _host;
269
+ private _seq;
270
+ /** Records every callGame for assertions. */
271
+ readonly calls: {
272
+ protocol: string;
273
+ payload: unknown;
274
+ }[];
275
+ constructor(host?: SimulatedScreenshotHostOptions);
276
+ callGame(protocol: string, payload: unknown): void;
277
+ onSDKMessage(protocol: string, handler: Handler): () => void;
278
+ /** Emit a host → activity message to all current subscribers. */
279
+ emit(protocol: string, payload: unknown): void;
280
+ private _handleCapture;
281
+ }
282
+ //#endregion
283
+ //#region ../shared-client/dist/create-page-api-BxBu-Q5N.d.ts
284
+ type TypedArrayKind = 'i8' | 'ui8' | 'ui8c' | 'i16' | 'ui16' | 'i32' | 'ui32' | 'f32' | 'f64' | 'bi64' | 'bui64';
285
+ //#endregion
286
+ //#region src/serialized-value.d.ts
287
+ /**
288
+ * Tagged union for serialized values.
289
+ *
290
+ * Primitives (boolean, number, string) pass through as-is since they're
291
+ * already JSON-safe. Special types get a discriminated wrapper object.
292
+ *
293
+ * @see Playwright SerializedValue in utilityScriptSerializers.ts
294
+ */
295
+ type SerializedValue = undefined | boolean | number | string | {
296
+ v: 'null' | 'undefined' | 'NaN' | 'Infinity' | '-Infinity' | '-0';
297
+ } | {
298
+ d: string;
299
+ } | {
300
+ u: string;
301
+ } | {
302
+ bi: string;
303
+ } | {
304
+ e: {
305
+ n: string;
306
+ m: string;
307
+ s: string;
308
+ };
309
+ } | {
310
+ r: {
311
+ p: string;
312
+ f: string;
313
+ };
314
+ } | {
315
+ a: SerializedValue[];
316
+ id: number;
317
+ } | {
318
+ o: {
319
+ k: string;
320
+ v: SerializedValue;
321
+ }[];
322
+ id: number;
323
+ } | {
324
+ ref: number;
325
+ } | {
326
+ h: number;
327
+ } | {
328
+ ta: {
329
+ b: string;
330
+ k: TypedArrayKind;
331
+ };
332
+ } | {
333
+ ab: {
334
+ b: string;
335
+ };
336
+ };
337
+ /**
338
+ * Optional transform applied to Error `.stack` strings during deserialization.
339
+ *
340
+ * On the Node.js side, this is used to normalize PixUI engine stack traces
341
+ * to V8-compatible format with source map resolution — the same transform
342
+ * applied to `ConsoleMessage.origin` and `SerializedError.stack`.
343
+ */
344
+ //#endregion
345
+ //#region src/evaluate-args.d.ts
346
+ /**
347
+ * Evaluate-arg payload travelling across the RPC boundary.
348
+ *
349
+ * Ship both fields as ordinary birpc arguments — the `SerializedValue` tree
350
+ * is already JSON-safe, so birpc's own serialiser passes it through
351
+ * symmetrically on both sides.
352
+ */
353
+ interface EvaluateArg {
354
+ /** Tagged-union tree with `{ h: N }` slots standing in for handles. */
355
+ readonly value: SerializedValue;
356
+ /** Ordered handle IDs: `value`'s `{ h: N }` slots index into this array. */
357
+ readonly handles: readonly string[];
358
+ }
359
+ /** An empty payload, for call-sites that pass no argument at all. */
360
+ /**
361
+ * Minimal element reference returned by selector queries.
362
+ *
363
+ * Playwright has `ElementHandle` — a behavior-carrying class with 30+
364
+ * DOM methods (click, fill, getAttribute, boundingBox, etc.). The
365
+ * Locator resolves a selector → ElementHandle, then delegates to the
366
+ * handle's methods. However, Playwright themselves now **discourage**
367
+ * ElementHandle in favor of the Locator-first API.
368
+ *
369
+ * We skip the ElementHandle layer entirely. Our Locator directly calls
370
+ * bridge RPC methods with element ID strings — there is no intermediate
371
+ * behavior-carrying object. This is a deliberate design choice aligned
372
+ * with Playwright's Locator-first direction, not a technical limitation.
373
+ *
374
+ * `ResolvedElement` is a plain DTO carrying the element's ID (from the
375
+ * client-side element map) plus `isVisible` — the one property needed
376
+ * for the Locator's pre-filtering (visibility) and strict mode checks,
377
+ * avoiding an extra RPC round-trip per element during selector resolution.
378
+ *
379
+ * @see Playwright dom.ts ElementHandle — deprecated in favor of Locator
380
+ * @see Playwright frames.ts _callOnElementOnceMatches
381
+ */
382
+ interface ResolvedElement {
383
+ id: string;
384
+ isVisible: boolean;
385
+ }
386
+ /** Actionability states, matching Playwright's ElementState. */
387
+ type ElementState = 'visible' | 'stable' | 'enabled' | 'editable' | 'receivesEvents';
388
+ /**
389
+ * Encoded string-or-regex expectation, mirroring Playwright's
390
+ * `channels.ExpectedTextValue`. Regex instances are never sent over the
391
+ * wire; they are decomposed into `regexSource` + `regexFlags` and
392
+ * reconstructed on the client side.
393
+ *
394
+ * @see Playwright packages/isomorphic/expectUtils.ts serializeExpectedTextValues
395
+ */
396
+ interface ExpectedTextValue {
397
+ string?: string | undefined;
398
+ regexSource?: string | undefined;
399
+ regexFlags?: string | undefined;
400
+ /** Match a substring of the received value instead of the whole value. */
401
+ matchSubstring?: boolean | undefined;
402
+ /** Collapse runs of whitespace before comparing (used by `toHaveText`). */
403
+ normalizeWhiteSpace?: boolean | undefined;
404
+ ignoreCase?: boolean | undefined;
405
+ }
406
+ /**
407
+ * All supported expect expressions. Exactly mirrors the subset of
408
+ * Playwright's `FrameExpectParams.expression` values that the PixUI
409
+ * DOM subset can implement.
410
+ *
411
+ * @see Playwright packages/injected/src/injectedScript.ts expectSingleElement
412
+ */
413
+ type ExpectExpression = 'to.be.attached' | 'to.be.detached' | 'to.be.visible' | 'to.be.hidden' | 'to.be.enabled' | 'to.be.disabled' | 'to.be.editable' | 'to.be.readonly' | 'to.be.empty' | 'to.be.checked' | 'to.be.focused' | 'to.have.attribute' | 'to.have.attribute.value' | 'to.have.class' | 'to.have.count' | 'to.have.css' | 'to.have.id' | 'to.have.property' | 'to.have.text' | 'to.have.value';
414
+ /**
415
+ * Parameters for a single `pageExpect` RPC call.
416
+ *
417
+ * The client runs one assertion tick per call and returns the result;
418
+ * the host-side polling loop (`src/expect-runner.ts`) decides whether
419
+ * to retry.
420
+ *
421
+ * @see Playwright packages/playwright-core/src/client/types.ts FrameExpectParams
422
+ */
423
+ interface ExpectParams {
424
+ expression: ExpectExpression;
425
+ /** Inverted match — mirrors Playwright's `options.isNot`. */
426
+ isNot: boolean;
427
+ /**
428
+ * Extra identifier for the attribute / CSS property / JS property
429
+ * being checked (e.g. `"href"` for `to.have.attribute.value`).
430
+ */
431
+ expressionArg?: string | undefined;
432
+ /** Encoded string/regex expectation(s) — array for text-like matchers. */
433
+ expectedText?: ExpectedTextValue[] | undefined;
434
+ /** Numeric expectation — used by `to.have.count`. */
435
+ expectedNumber?: number | undefined;
436
+ /** Arbitrary JSON-serializable expectation — used by `to.have.property`. */
437
+ expectedValue?: unknown;
438
+ /**
439
+ * Optional nth-index to slice the resolved element list after selector
440
+ * resolution — mirrors `Locator.first()/.last()/.nth(n)`. `null` means
441
+ * strict mode: exactly one element must match (matchers targeting
442
+ * element arrays like `to.have.count` always ignore this).
443
+ */
444
+ nthIndex?: number | null | undefined;
445
+ }
446
+ /**
447
+ * Result of a single `pageExpect` tick.
448
+ *
449
+ * - `matches`: whether the condition held on this tick.
450
+ * - `received`: the actual value observed (e.g. the element's text, a
451
+ * CSS property value, or a count) — used by the host-side matcher for
452
+ * the failure diff.
453
+ * - `log`: human-readable breadcrumbs from the client tick, echoed into
454
+ * the final matcher error.
455
+ * - `errorMessage`: a message for unrecoverable failures (e.g. strict
456
+ * mode violation). When set, the host matcher stops polling immediately.
457
+ * - `missingReceived`: true when the element was not found — so the
458
+ * matcher can distinguish "element gone" from "element present but
459
+ * value mismatched" in the failure message.
460
+ */
461
+ interface ExpectResult {
462
+ matches: boolean;
463
+ received?: unknown;
464
+ log?: string[] | undefined;
465
+ errorMessage?: string | undefined;
466
+ missingReceived?: boolean | undefined;
467
+ }
468
+ /** Functions exposed by __pxemu on the client side (callable via bridge RPC from the host) */
469
+ interface PageFunctions {
470
+ querySelectorCustom(selector: string, testIdAttribute: string): ResolvedElement[];
471
+ querySelectorAll(selector: string): ResolvedElement[];
472
+ querySelector(selector: string): ResolvedElement | null;
473
+ getBoundingRect(elementId: string): {
474
+ x: number;
475
+ y: number;
476
+ width: number;
477
+ height: number;
478
+ } | null;
479
+ isElementVisible(elementId: string): boolean;
480
+ isElementEnabled(elementId: string): boolean;
481
+ isElementEditable(elementId: string): boolean;
482
+ getElementAttribute(elementId: string, name: string): string | null;
483
+ getElementTextContent(elementId: string): string | null;
484
+ getElementInnerHTML(elementId: string): string;
485
+ getElementTag(elementId: string): string | null;
486
+ isElementChecked(elementId: string): boolean;
487
+ focusElement(elementId: string): 'done' | 'error:notconnected';
488
+ blurElement(elementId: string): 'done' | 'error:notconnected';
489
+ getDomTree(): ResolvedElement[];
490
+ configure(config: {
491
+ testIdAttribute?: string;
492
+ }): boolean;
493
+ /**
494
+ * Evaluate a function (or plain expression) in the page context and
495
+ * return its value by JSON-serialization.
496
+ *
497
+ * If the evaluation returns a Promise, it is awaited.
498
+ *
499
+ * @see shared/evaluate-args.ts
500
+ * @see Playwright Frame.evaluateExpression
501
+ */
502
+ evaluate(expression: string, arg: EvaluateArg): unknown;
503
+ /**
504
+ * Evaluate a function against all matching elements and return the
505
+ * result. The function's first argument is an array of the resolved
506
+ * Elements; the extra `arg` follows the same handle-aware serialization
507
+ * protocol as `evaluate`.
508
+ *
509
+ * @see Playwright Frame.$$eval
510
+ */
511
+ evaluateAll(expression: string, elementIds: string[], arg: EvaluateArg): unknown;
512
+ /**
513
+ * Evaluate a function in the page context and return a handle descriptor
514
+ * for the result, matching Playwright's `evaluateHandle`. The `arg`
515
+ * follows the same handle-aware serialization protocol as `evaluate`.
516
+ *
517
+ * Returns `null` when the value is null/undefined — the host wraps it
518
+ * in a local null-handle rather than wasting an entry in the handle map.
519
+ *
520
+ * @see Playwright Frame.evaluateExpressionHandle
521
+ */
522
+ evaluateHandle(expression: string, arg: EvaluateArg): {
523
+ id: string;
524
+ type: string;
525
+ } | null;
526
+ /**
527
+ * Evaluate a function against a single resolved element, matching
528
+ * Playwright's `Frame.evalOnSelector`. The resolved element is passed
529
+ * as the first positional argument to the function; the `arg` payload
530
+ * follows the same handle-aware protocol as `evaluate`.
531
+ *
532
+ * Returns `'error:notconnected'` when the element has detached so
533
+ * `Locator._retryWithSelectorResolution` can re-resolve.
534
+ *
535
+ * @see Playwright Frame.evalOnSelector
536
+ */
537
+ evalOnSelector(elementId: string, expression: string, arg: EvaluateArg): unknown;
538
+ /**
539
+ * Evaluate a function against a single resolved element and return a
540
+ * handle descriptor, matching Playwright's `Frame.evalOnSelectorHandle`.
541
+ *
542
+ * @see Playwright Frame.evalOnSelectorHandle
543
+ */
544
+ evalOnSelectorHandle(elementId: string, expression: string, arg: EvaluateArg): {
545
+ id: string;
546
+ type: string;
547
+ } | null | 'error:notconnected';
548
+ /**
549
+ * Evaluate a function with a handle's target value as its first argument.
550
+ * Returns the result by value. The `arg` payload follows the same
551
+ * handle-aware protocol as `evaluate`.
552
+ *
553
+ * @see Playwright JSHandleChannel.evaluateExpression
554
+ */
555
+ handleEvaluate(handleId: string, expression: string, arg: EvaluateArg): unknown;
556
+ /**
557
+ * Evaluate a function with a handle's target value as its first argument.
558
+ * Returns a new handle descriptor (or `null` for nullish results).
559
+ *
560
+ * @see Playwright JSHandleChannel.evaluateExpressionHandle
561
+ */
562
+ handleEvaluateHandle(handleId: string, expression: string, arg: EvaluateArg): {
563
+ id: string;
564
+ type: string;
565
+ } | null;
566
+ /**
567
+ * Get the JSON-serializable value of a handle.
568
+ *
569
+ * @see Playwright JSHandleChannel.jsonValue
570
+ * @see vitest-playwright-bridge BridgeHandleServerMethods.jsonValue
571
+ */
572
+ handleJsonValue(handleId: string): unknown;
573
+ /**
574
+ * Get a handle to a named property of a handle's value.
575
+ *
576
+ * @see Playwright JSHandleChannel.getProperty
577
+ * @see vitest-playwright-bridge BridgeHandleServerMethods.getProperty
578
+ */
579
+ handleGetProperty(handleId: string, propertyName: string): {
580
+ id: string;
581
+ type: string;
582
+ } | null;
583
+ /**
584
+ * Get handles to all enumerable own properties of a handle's value.
585
+ * Returns an array of {key, id, type} entries.
586
+ *
587
+ * @see Playwright JSHandleChannel.getPropertyList
588
+ * @see vitest-playwright-bridge BridgeHandleServerMethods.getProperties
589
+ */
590
+ handleGetProperties(handleId: string): Array<{
591
+ key: string;
592
+ id: string;
593
+ type: string;
594
+ }>;
595
+ /**
596
+ * Release a handle, removing it from the client-side handle map.
597
+ * The referenced JS value becomes eligible for garbage collection.
598
+ *
599
+ * @see Playwright JSHandleChannel.dispose
600
+ * @see vitest-playwright-bridge BridgeHandleServerMethods.dispose
601
+ */
602
+ handleDispose(handleId: string): void;
603
+ /**
604
+ * Run one tick of a Playwright-style auto-retrying assertion entirely
605
+ * in the page context. The host calls this method repeatedly on a
606
+ * backoff schedule until either the condition is met or the deadline
607
+ * passes — see `src/expect-runner.ts` for the polling loop.
608
+ *
609
+ * Rationale: executing the DOM assertion in the page avoids a round
610
+ * trip per observed value (faster convergence) and gives each matcher
611
+ * access to the full DOM API (`HTMLInputElement.value`,
612
+ * `document.activeElement`, `getComputedStyle`, …) with native
613
+ * TypeScript DOM types at author time — see `client/page-expect.ts`.
614
+ *
615
+ * @see Playwright packages/playwright-core/src/server/frames.ts Frame.expect
616
+ */
617
+ pageExpect(selector: string | null, testIdAttribute: string, params: ExpectParams): ExpectResult;
618
+ /**
619
+ * Check actionability states on an element entirely in the page context.
620
+ *
621
+ * This mirrors Playwright's injectedScript.checkElementStates().
622
+ * Stable uses real requestAnimationFrame. All checks operate on the
623
+ * same element instance, avoiding the race condition of re-resolving
624
+ * elements between RPC round-trips.
625
+ *
626
+ * @returns `{ passed: true }` if all states pass, or `{ missingState }` for
627
+ * the first state that failed.
628
+ */
629
+ checkElementStates(elementId: string, states: ElementState[]): Promise<{
630
+ passed: true;
631
+ } | {
632
+ missingState: ElementState;
633
+ }>;
634
+ /**
635
+ * Scroll the element into the visible area of the viewport if needed.
636
+ *
637
+ * This mirrors Playwright's scroll-into-view step performed between
638
+ * actionability checks and the actual input action.
639
+ *
640
+ * @see https://playwright.dev/docs/api/class-locator#locator-scroll-into-view-if-needed
641
+ */
642
+ scrollIntoViewIfNeeded(elementId: string): 'done' | 'error:notconnected';
643
+ /**
644
+ * Release element references by ID, allowing GC on the client side.
645
+ *
646
+ * This is for the element map (DOM elements resolved by selectors).
647
+ * For arbitrary JS value handles, use `handleDispose()` instead.
648
+ *
649
+ * @see Playwright Runtime.releaseObject (WebKit) / Runtime.disposeObject (Firefox)
650
+ */
651
+ releaseElements(elementIds: string[]): void;
652
+ /**
653
+ * Prune detached elements from the client-side element map and enforce
654
+ * a max-size cap. Returns the number of entries removed.
655
+ *
656
+ * Mirrors Playwright's dispatcher GC-bucket overflow protection
657
+ * (maybeDisposeStaleDispatchers) which caps ElementHandle dispatchers
658
+ * at 100k and evicts the oldest 10% on overflow.
659
+ *
660
+ * Called automatically before each querySelectorCustom on the client,
661
+ * but can also be called explicitly from the host for manual cleanup.
662
+ */
663
+ pruneDetachedElements(): number;
664
+ /**
665
+ * Prepare the page for a deterministic screenshot.
666
+ *
667
+ * Applies temporary visual changes (e.g. hiding carets) and stores
668
+ * a cleanup function so `restoreScreenshot()` can undo them.
669
+ *
670
+ * Ported from Playwright's `Screenshotter._preparePageForScreenshot()`.
671
+ */
672
+ prepareScreenshot(options: {
673
+ hideCaret: boolean;
674
+ }): void;
675
+ /**
676
+ * Undo visual changes applied by `prepareScreenshot()`.
677
+ *
678
+ * Ported from Playwright's `Screenshotter._restorePageAfterScreenshot()`.
679
+ */
680
+ restoreScreenshot(): void;
681
+ /** Append a log entry for navigation replay. */
682
+ clockLog(type: string, time: number, param?: number): void;
683
+ /** Inject fake clock infrastructure without setting time. */
684
+ clockInject(): void;
685
+ /** Install fake clock and set initial time. */
686
+ clockInstall(timeMs: number): void;
687
+ /** Advance clock, firing all due timers. */
688
+ clockRunFor(ticksMs: number): Promise<void>;
689
+ /** Jump forward in time, firing due timers at most once. */
690
+ clockFastForward(ticksMs: number): Promise<void>;
691
+ /** Jump to a specific time and pause. */
692
+ clockPauseAt(timeMs: number): Promise<number>;
693
+ /** Resume real-time progression. */
694
+ clockResume(): void;
695
+ /** Set a fixed time for Date.now() / new Date(). */
696
+ clockSetFixedTime(timeMs: number): void;
697
+ /** Set system time without triggering timers. */
698
+ clockSetSystemTime(timeMs: number): void;
699
+ /** Uninstall fake clock, restoring native globals. */
700
+ clockUninstall(): void;
701
+ }
702
+ /**
703
+ * Shared interface for bridge RPC callers.
704
+ *
705
+ * Both `DevtoolsBridge` (server-side, direct birpc) and `ControlClient`
706
+ * (worker-side, proxied via control channel) implement this interface.
707
+ * Consumers like `JSHandle` and `Locator` depend on this interface
708
+ * instead of a concrete class, so they work in both server and worker
709
+ * contexts.
710
+ *
711
+ * @see DevtoolsBridge.call — server-side implementation
712
+ * @see ControlClient.call — worker-side proxy implementation
713
+ */
714
+ interface BridgeClient {
715
+ /** Whether both devtools + bridge channels are connected. */
716
+ readonly connected: boolean;
717
+ /** Type-safe RPC call to a page function. */
718
+ call<M extends keyof PageFunctions>(method: M, ...args: Parameters<PageFunctions[M]>): Promise<ReturnType<PageFunctions[M]>>;
719
+ }
720
+ /** Functions exposed by the host to the client (callable via birpc from the page) */
721
+ //#endregion
722
+ //#region ../shared-client/dist/index.d.ts
723
+ //#endregion
724
+ //#region src/options.d.ts
725
+ /** Timeout option accepted by most Locator methods. Matches Playwright's TimeoutOptions. */
726
+ interface TimeoutOptions {
727
+ timeout?: number | undefined;
728
+ }
729
+ interface ClickOptions {
730
+ button?: string | undefined;
731
+ clickCount?: number | undefined;
732
+ delay?: number | undefined;
733
+ /** Skip actionability checks. */
734
+ force?: boolean | undefined;
735
+ /** Maximum time in milliseconds. Pass `0` to disable timeout. */
736
+ timeout?: number | undefined;
737
+ /** Click at a specific position relative to the element's top-left corner. */
738
+ position?: {
739
+ x: number;
740
+ y: number;
741
+ } | undefined;
742
+ /** Perform all actionability checks but skip the actual action. */
743
+ trial?: boolean | undefined;
744
+ }
745
+ interface HoverOptions {
746
+ /** Skip actionability checks. */
747
+ force?: boolean | undefined;
748
+ /** Maximum time in milliseconds. Pass `0` to disable timeout. */
749
+ timeout?: number | undefined;
750
+ /** Hover at a specific position relative to the element's top-left corner. */
751
+ position?: {
752
+ x: number;
753
+ y: number;
754
+ } | undefined;
755
+ /** Perform all actionability checks but skip the actual action. */
756
+ trial?: boolean | undefined;
757
+ }
758
+ interface MouseOptions {
759
+ button?: string | undefined;
760
+ isDown?: boolean | undefined;
761
+ }
762
+ interface DragOptions {
763
+ steps?: number | undefined;
764
+ stepDelay?: number | undefined;
765
+ /** Skip actionability checks. */
766
+ force?: boolean | undefined;
767
+ /** Maximum time in milliseconds. */
768
+ timeout?: number | undefined;
769
+ /** Perform all actionability checks but skip the actual action. */
770
+ trial?: boolean | undefined;
771
+ }
772
+ interface TapOptions {
773
+ delay?: number | undefined;
774
+ /** Skip actionability checks. */
775
+ force?: boolean | undefined;
776
+ /** Maximum time in milliseconds. */
777
+ timeout?: number | undefined;
778
+ /** Click at a specific position relative to the element's top-left corner. */
779
+ position?: {
780
+ x: number;
781
+ y: number;
782
+ } | undefined;
783
+ /** Perform all actionability checks but skip the actual action. */
784
+ trial?: boolean | undefined;
785
+ }
786
+ interface SwipeOptions {
787
+ steps?: number | undefined;
788
+ stepDelay?: number | undefined;
789
+ /** Skip actionability checks. */
790
+ force?: boolean | undefined;
791
+ /** Maximum time in milliseconds. */
792
+ timeout?: number | undefined;
793
+ }
794
+ interface LongPressOptions {
795
+ duration?: number | undefined;
796
+ /** Skip actionability checks. */
797
+ force?: boolean | undefined;
798
+ /** Maximum time in milliseconds. */
799
+ timeout?: number | undefined;
800
+ /** Press at a specific position relative to the element's top-left corner. */
801
+ position?: {
802
+ x: number;
803
+ y: number;
804
+ } | undefined;
805
+ }
806
+ interface PressOptions {
807
+ delay?: number | undefined;
808
+ }
809
+ interface TypeOptions {
810
+ delay?: number | undefined;
811
+ }
812
+ interface ScreenshotOptions {
813
+ path?: string | undefined;
814
+ timeout?: number | undefined;
815
+ /**
816
+ * Clip the screenshot to a specific region of the viewport.
817
+ *
818
+ * Coordinates are in CSS pixels relative to the top-left corner of the
819
+ * viewport. Typically obtained from an element's `boundingRect` (via
820
+ * `locator.boundingBox()`).
821
+ */
822
+ clip?: {
823
+ x: number;
824
+ y: number;
825
+ width: number;
826
+ height: number;
827
+ } | undefined;
828
+ /**
829
+ * Whether to hide the text input caret during the screenshot.
830
+ *
831
+ * - `'hide'` (default): set `caret-color: transparent !important` on all
832
+ * `input` and `textarea` elements before capture,
833
+ * then restore original values.
834
+ * - `'initial'`: leave carets as-is.
835
+ */
836
+ caret?: 'hide' | 'initial' | undefined;
837
+ }
838
+ interface FillOptions {
839
+ /** Skip actionability checks. */
840
+ force?: boolean | undefined;
841
+ /** Maximum time in milliseconds. */
842
+ timeout?: number | undefined;
843
+ } //#endregion
844
+ //#region src/progress.d.ts
845
+ /**
846
+ * Progress — Port of Playwright's Progress/ProgressController.
847
+ *
848
+ * Provides centralized timeout management, cooperative cancellation,
849
+ * and structured call logging for all retry loops (selector resolution,
850
+ * action retries, waitFor).
851
+ *
852
+ * Lives in shared-client because the Locator retry loops depend on it and
853
+ * must run unchanged in both the Node (emulator) and QuickJS (inflight)
854
+ * runtimes. It is pure async-control logic — `AbortController`, `setTimeout`,
855
+ * and Promises — with no Node builtins.
856
+ *
857
+ * @see Playwright packages/playwright-core/src/server/progress.ts
858
+ * @see Playwright packages/playwright-core/src/server/callLog.ts
859
+ */
860
+ /**
861
+ * A progress token passed to retry loops and action callbacks.
862
+ *
863
+ * Each method that takes a Progress must result in one of three outcomes:
864
+ * - It finishes successfully, returning a value, before the Progress is aborted.
865
+ * - It throws some error, before the Progress is aborted.
866
+ * - It throws the Progress's aborted error, because the Progress was aborted
867
+ * before the method could finish.
868
+ *
869
+ * @see Playwright Progress interface in packages/protocol/src/progress.d.ts
870
+ */
871
+ //#endregion
872
+ //#region src/evaluate-types.d.ts
873
+ /**
874
+ * Evaluate-family type system (runtime-agnostic, type-only).
875
+ *
876
+ * These types describe the `evaluate` / `evaluateHandle` argument and return
877
+ * shapes shared by the host driver (`Locator`) and the emulator's `JSHandle`.
878
+ * They carry ZERO runtime code, so the shared barrel that re-exports them has
879
+ * no module-load side effects — which is exactly what lets the in-page IIFE
880
+ * and the inflight bundle import from the package root without dragging in the
881
+ * emulator-only `JSHandle` (whose `FinalizationRegistry` the PixUI QuickJS
882
+ * runtime cannot construct).
883
+ *
884
+ * The concrete `JSHandle` class lives in `@pixui-dev/emulator-core` (it is an
885
+ * emulator-only host feature). `JSHandleLike` is the structural surface the
886
+ * shared `Locator.evaluateHandle` returns and that `Unboxed` uses to see
887
+ * through handles passed as `evaluate` arguments.
888
+ *
889
+ * @see Playwright packages/playwright-core/types/structs.d.ts (Unboxed, PageFunctionOn)
890
+ */
891
+ /**
892
+ * Structural surface of a host-side JS handle.
893
+ *
894
+ * The emulator's `JSHandle` satisfies this shape; the shared `Locator` returns
895
+ * it from `evaluateHandle` (constructed via the injected `PageHost.wrapHandle`
896
+ * seam) without importing the concrete class. Deliberately omits
897
+ * `getProperty`/`getProperties` (which return the concrete handle on the
898
+ * emulator) so the interface stays a clean structural supertype of `JSHandle`
899
+ * — avoiding `Map` invariance pitfalls — while still typing the members
900
+ * callers actually use on a locator-derived handle.
901
+ *
902
+ * @see Playwright JSHandle (client-side)
903
+ */
904
+ interface JSHandleLike<T = unknown> {
905
+ /** Brand used by {@link Unboxed} to recognise handles in argument positions. */
906
+ readonly __brand: '@pixui-dev/emulator JSHandle';
907
+ /** JS `typeof` the referenced value (for debugging/preview). */
908
+ readonly type: string;
909
+ /** Whether this handle has been disposed. */
910
+ readonly disposed: boolean;
911
+ /** Evaluate a function with this handle's value as the first argument. */
912
+ evaluate<R, Arg, O extends T = T>(pageFunction: PageFunctionOn<O, Arg, R>, arg: Arg): Promise<R>;
913
+ evaluate<R, O extends T = T>(pageFunction: PageFunctionOn<O, void, R>, arg?: unknown): Promise<R>;
914
+ /** Evaluate a function with this handle's value, returning a new handle. */
915
+ evaluateHandle<R, Arg, O extends T = T>(pageFunction: PageFunctionOn<O, Arg, R>, arg: Arg): Promise<JSHandleLike<R>>;
916
+ evaluateHandle<R, O extends T = T>(pageFunction: PageFunctionOn<O, void, R>, arg?: unknown): Promise<JSHandleLike<R>>;
917
+ /** Get the JSON-serializable value of this handle. */
918
+ jsonValue(): Promise<T>;
919
+ /** Explicitly release this handle. */
920
+ dispose(): Promise<void>;
921
+ }
922
+ /**
923
+ * Recursively unwrap `JSHandleLike<T>` → `T` in type positions.
924
+ *
925
+ * This is the core of the Box/Unbox type system, letting
926
+ * `handle.evaluate((el, arg) => ...)` infer the in-page types for `el`/`arg`:
927
+ * - `JSHandleLike<Element>` → `Element`
928
+ * - `{ foo: JSHandleLike<string> }` → `{ foo: string }`
929
+ * - `[JSHandleLike<number>, string]` → `[number, string]`
930
+ * - Plain types pass through unchanged
931
+ *
932
+ * Simplified from Playwright's `Unboxed` (no ElementHandle, no 4-tuple cases) —
933
+ * we only have one handle kind.
934
+ *
935
+ * @see Playwright structs.d.ts Unboxed
936
+ */
937
+ type Unboxed<Arg> = Arg extends JSHandleLike<infer T> ? T : Arg extends [infer A0, ...infer Rest] ? [Unboxed<A0>, ...{ [K in keyof Rest]: Unboxed<Rest[K]> }] : Arg extends Array<infer T> ? Array<Unboxed<T>> : Arg extends object ? { [Key in keyof Arg]: Unboxed<Arg[Key]> } : Arg;
938
+ /**
939
+ * Function type for `evaluate` / `evaluateHandle` on a handle or element.
940
+ *
941
+ * `On` is the type of the target value (first argument). `Arg` is the extra
942
+ * argument (second argument), unwrapped via {@link Unboxed}. `R` is the return
943
+ * type. Accepts either a string expression or a function.
944
+ *
945
+ * @see Playwright structs.d.ts PageFunctionOn
946
+ */
947
+ type PageFunctionOn<On, Arg, R> = string | ((on: On, arg: Unboxed<Arg>) => R | Promise<R>);
948
+ /**
949
+ * Function type for page-level `evaluate` (no "on" target).
950
+ *
951
+ * @see Playwright structs.d.ts PageFunction
952
+ */
953
+ //#endregion
954
+ //#region src/input-backend.d.ts
955
+ interface InputBackend {
956
+ click(x: number, y: number, options?: ClickOptions): Promise<void>;
957
+ move(x: number, y: number, options?: MouseOptions): Promise<void>;
958
+ down(x: number, y: number, options?: MouseOptions): Promise<void>;
959
+ up(x: number, y: number, options?: MouseOptions): Promise<void>;
960
+ wheel(x: number, y: number, deltaY: number, deltaX: number): Promise<void>;
961
+ tap(x: number, y: number, options?: TapOptions): Promise<void>;
962
+ swipe(fromX: number, fromY: number, toX: number, toY: number, options?: SwipeOptions): Promise<void>;
963
+ longPress(x: number, y: number, options?: LongPressOptions): Promise<void>;
964
+ press(key: string, options?: PressOptions): Promise<void>;
965
+ keyDown(key: string): Promise<void>;
966
+ keyUp(key: string): Promise<void>;
967
+ typeText(text: string, options?: TypeOptions): Promise<void>;
968
+ } //#endregion
969
+ //#region src/input.d.ts
970
+ /**
971
+ * Context object passed to input classes, providing the atomic input
972
+ * backend plus the two page-level hooks the devices need (closed-state
973
+ * assertion and post-action frame settling).
974
+ */
975
+ interface InputContext {
976
+ backend: InputBackend;
977
+ assertNotClosed(): void;
978
+ waitForFrame(): Promise<unknown>;
979
+ }
980
+ declare class Mouse {
981
+ /** @internal */
982
+ readonly _ctx: InputContext;
983
+ constructor(ctx: InputContext);
984
+ click(x: number, y: number, options?: ClickOptions): Promise<void>;
985
+ dblclick(x: number, y: number, options?: ClickOptions): Promise<void>;
986
+ move(x: number, y: number, options?: MouseOptions): Promise<void>;
987
+ down(x: number, y: number, options?: MouseOptions): Promise<void>;
988
+ up(x: number, y: number, options?: MouseOptions): Promise<void>;
989
+ wheel(x: number, y: number, deltaY: number, deltaX?: number): Promise<void>;
990
+ }
991
+ declare class Touchscreen {
992
+ /** @internal */
993
+ readonly _ctx: InputContext;
994
+ constructor(ctx: InputContext);
995
+ tap(x: number, y: number, options?: TapOptions): Promise<void>;
996
+ /** PixUI extension: swipe gesture. */
997
+ swipe(fromX: number, fromY: number, toX: number, toY: number, options?: SwipeOptions): Promise<void>;
998
+ /** PixUI extension: long press gesture. */
999
+ longPress(x: number, y: number, options?: LongPressOptions): Promise<void>;
1000
+ }
1001
+ declare class Keyboard {
1002
+ /** @internal */
1003
+ readonly _ctx: InputContext;
1004
+ constructor(ctx: InputContext);
1005
+ press(key: string, options?: PressOptions): Promise<void>;
1006
+ down(key: string): Promise<void>;
1007
+ up(key: string): Promise<void>;
1008
+ type(text: string, options?: TypeOptions): Promise<void>;
1009
+ insertText(text: string): Promise<void>;
1010
+ } //#endregion
1011
+ //#region src/page-host.d.ts
1012
+ interface PageHost {
1013
+ /** Bridge for DOM introspection RPCs, or `null` when not connected. */
1014
+ readonly devtoolsBridge: BridgeClient | null;
1015
+ /** The configured test ID attribute name (e.g. `data-testid`). */
1016
+ readonly testIdAttribute: string;
1017
+ /** Mouse input device. */
1018
+ readonly mouse: Mouse;
1019
+ /** Touchscreen input device. */
1020
+ readonly touchscreen: Touchscreen;
1021
+ /** Keyboard input device. */
1022
+ readonly keyboard: Keyboard;
1023
+ /** Whether the page has been closed via `window.close()`. */
1024
+ isClosed(): boolean;
1025
+ /** Whether the page has been disposed. */
1026
+ isDisposed(): boolean;
1027
+ /** Sleep helper used by the action retry loops. */
1028
+ waitForTimeout(ms: number): Promise<void>;
1029
+ /**
1030
+ * Capture a screenshot of the current frame. Returns the encoded PNG
1031
+ * bytes. (The emulator returns a Node `Buffer`, which is a `Uint8Array`;
1032
+ * the inflight backend returns the bytes it read back from the host.)
1033
+ */
1034
+ screenshot(options?: ScreenshotOptions): Promise<Uint8Array>;
1035
+ /**
1036
+ * Subscribe to the page `close` event (window.close()). Returns an
1037
+ * unsubscribe function. Used by Locator to fail fast on close instead of
1038
+ * waiting out the full timeout — without coupling Locator to a concrete
1039
+ * EventEmitter.
1040
+ */
1041
+ onClose(handler: () => void): () => void;
1042
+ /**
1043
+ * Subscribe to the page `disposed` event. Returns an unsubscribe function.
1044
+ */
1045
+ onDisposed(handler: () => void): () => void;
1046
+ /**
1047
+ * Wrap an `evalOnSelectorHandle` RPC result into a host-side JS handle.
1048
+ *
1049
+ * Optional seam: JS handles are an emulator-only feature (the concrete
1050
+ * `JSHandle` class with its `FinalizationRegistry` lives in
1051
+ * `@pixui-dev/emulator-core`, not in this runtime-agnostic layer). The
1052
+ * emulator's `SimulatorPage` implements this; backends without handle
1053
+ * support — notably inflight-test, which runs inside QuickJS and has no
1054
+ * `eval` — omit it, so `Locator.evaluateHandle` throws a clear error there.
1055
+ *
1056
+ * @param result The handle descriptor from the page, or `null` for a
1057
+ * null/undefined result (wrapped as a host-side null-handle).
1058
+ */
1059
+ wrapHandle?(result: {
1060
+ id: string;
1061
+ type: string;
1062
+ } | null): JSHandleLike<unknown>;
1063
+ } //#endregion
1064
+ //#region src/locator.d.ts
1065
+ /** Options for text-based locator queries. */
1066
+ /** Filter options for narrowing locator matches */
1067
+ interface LocatorFilterOptions {
1068
+ /** Filter by text content */
1069
+ hasText?: string | RegExp | undefined;
1070
+ /** Filter by NOT having text content */
1071
+ hasNotText?: string | RegExp | undefined;
1072
+ }
1073
+ interface SwipeTarget {
1074
+ x: number;
1075
+ y: number;
1076
+ }
1077
+ interface WaitForOptions {
1078
+ /** Timeout in milliseconds (default: 30000) */
1079
+ timeout?: number | undefined;
1080
+ /** Wait for element to reach this state (default: 'visible') */
1081
+ state?: 'attached' | 'detached' | 'visible' | 'hidden' | undefined;
1082
+ }
1083
+ /**
1084
+ * Defines how a locator resolves its target elements.
1085
+ * The selector is a custom selector string resolved by the bridge client.
1086
+ */
1087
+ type LocatorSource = {
1088
+ kind: 'selector';
1089
+ selector: string;
1090
+ };
1091
+ /**
1092
+ * A Locator represents a way to find one or more elements on the PixUI page.
1093
+ *
1094
+ * Locators are the core primitive for interacting with the page. They are:
1095
+ * - **Lazy**: Elements are resolved at interaction time.
1096
+ * - **Auto-waiting**: Actions automatically wait for elements to appear.
1097
+ * - **Auto-retrying**: Assertions retry until timeout.
1098
+ * - **Strict**: Actions throw if the locator matches more than one element
1099
+ * (configurable via .first(), .last(), .nth()).
1100
+ */
1101
+ declare class Locator {
1102
+ private _page;
1103
+ private _source;
1104
+ private _nthIndex;
1105
+ private _offsetX;
1106
+ private _offsetY;
1107
+ /** Timeout for auto-waiting (ms) */
1108
+ private _timeout;
1109
+ constructor(page: PageHost, source: LocatorSource);
1110
+ /**
1111
+ * The raw selector string.
1112
+ */
1113
+ get selector(): string | null;
1114
+ /**
1115
+ * Create a locator from a CSS selector string.
1116
+ */
1117
+ static fromSelector(page: PageHost, selector: string): Locator;
1118
+ /**
1119
+ * Create a locator by text content.
1120
+ */
1121
+ static fromText(page: PageHost, text: string | RegExp, options?: {
1122
+ exact?: boolean;
1123
+ }): Locator;
1124
+ /**
1125
+ * Create a locator by alt text.
1126
+ */
1127
+ static fromAltText(page: PageHost, text: string | RegExp, options?: {
1128
+ exact?: boolean;
1129
+ }): Locator;
1130
+ /**
1131
+ * Create a locator by label text.
1132
+ */
1133
+ static fromLabelText(page: PageHost, text: string | RegExp, options?: {
1134
+ exact?: boolean;
1135
+ }): Locator;
1136
+ /**
1137
+ * Create a locator by placeholder.
1138
+ */
1139
+ static fromPlaceholder(page: PageHost, text: string | RegExp, options?: {
1140
+ exact?: boolean;
1141
+ }): Locator;
1142
+ /**
1143
+ * Create a locator by title attribute.
1144
+ */
1145
+ static fromTitle(page: PageHost, text: string | RegExp, options?: {
1146
+ exact?: boolean;
1147
+ }): Locator;
1148
+ /**
1149
+ * Create a locator by data-testid attribute.
1150
+ */
1151
+ static fromTestId(page: PageHost, testId: string | RegExp): Locator;
1152
+ /**
1153
+ * Human-readable description of this locator (for error messages).
1154
+ */
1155
+ private get _description();
1156
+ /**
1157
+ * Raw selector query — no retry, no waiting.
1158
+ *
1159
+ * Returns all matching elements, or null if the bridge is not available.
1160
+ * This is the low-level building block used by _retryWithSelectorResolution.
1161
+ *
1162
+ * @see Playwright frames.ts: resolved.injected.evaluateHandle(injected.querySelectorAll)
1163
+ */
1164
+ private _resolveSelector;
1165
+ /**
1166
+ * Run a Playwright-style auto-retrying assertion against this locator.
1167
+ *
1168
+ * The host side is a thin polling loop: it fires `pageExpect` RPCs on
1169
+ * exponential intervals (`[100, 250, 500, 1000]`) until either the
1170
+ * condition holds (`matches !== isNot`) or the deadline passes.
1171
+ * Each tick performs the full selector resolution + DOM check inside
1172
+ * the page, so re-renders between ticks are observed naturally.
1173
+ *
1174
+ * This method is internal — matchers in the vitest plugin call it via
1175
+ * the public barrel export. Not for end-user consumption.
1176
+ *
1177
+ * @see Playwright server/frames.ts Frame.expect — the same two-phase
1178
+ * (one-shot + retry-with-backoff) loop.
1179
+ * @internal
1180
+ */
1181
+ _expect(params: Omit<ExpectParams, 'nthIndex'>, timeout: number): Promise<ExpectResult>;
1182
+ /**
1183
+ * Pick a single element from the resolved list, applying nth/strict mode.
1184
+ *
1185
+ * Returns the element, or null if no match (caller should retry),
1186
+ * or throws on strict mode violation (non-recoverable).
1187
+ *
1188
+ * @see Playwright frames.ts _retryWithProgressIfNotConnected: strict mode check
1189
+ */
1190
+ private _pickElement;
1191
+ /**
1192
+ * Run a ProgressController task with page close/dispose detection.
1193
+ *
1194
+ * Listens for the page's 'close' and 'disposed' events and aborts the
1195
+ * controller immediately, so pending locator operations fail fast with
1196
+ * a descriptive error instead of waiting for the full timeout.
1197
+ */
1198
+ private _runWithCloseDetection;
1199
+ /**
1200
+ * Outermost retry loop — resolves the selector and passes the element
1201
+ * to an action callback. Re-resolves on 'error:notconnected'.
1202
+ *
1203
+ * This is our equivalent of Playwright's Frame._retryWithProgressIfNotConnected.
1204
+ *
1205
+ * The retry loop uses progressive backoff: [0, 20, 100, 100, 500]ms,
1206
+ * matching Playwright's retryWithProgressAndTimeouts.
1207
+ *
1208
+ * @param action - Callback receiving the resolved element. Must return
1209
+ * 'error:notconnected' to trigger re-resolution, or any
1210
+ * other value as the final result.
1211
+ * @param options - timeout, force (skip visibility pre-filter)
1212
+ * @returns The action's return value (excluding 'error:notconnected')
1213
+ *
1214
+ * @see Playwright frames.ts _retryWithProgressIfNotConnected
1215
+ * @see Playwright frames.ts retryWithProgressAndTimeouts
1216
+ */
1217
+ private _retryWithSelectorResolution;
1218
+ /**
1219
+ * Generic retry wrapper for actions, matching Playwright's `_retryAction`.
1220
+ *
1221
+ * Retries the action callback when it returns a recoverable error code.
1222
+ * Uses progressive backoff: [0, 20, 100, 100, 500]ms between retries.
1223
+ *
1224
+ * Returns 'error:notconnected' to the caller so the outer loop
1225
+ * (_retryWithSelectorResolution) can re-resolve the selector.
1226
+ *
1227
+ * @see Playwright dom.ts ElementHandle._retryAction
1228
+ */
1229
+ private _retryAction;
1230
+ /**
1231
+ * Retry wrapper for pointer actions, matching Playwright's `_retryPointerAction`.
1232
+ *
1233
+ * Wraps `_retryAction` and adds pointer-specific retry logic:
1234
+ * - Cycles through different scroll alignments on each retry to handle
1235
+ * position:sticky elements that overlay the target.
1236
+ *
1237
+ * Returns 'error:notconnected' to bubble up to _retryWithSelectorResolution.
1238
+ *
1239
+ * @see Playwright dom.ts ElementHandle._retryPointerAction
1240
+ */
1241
+ private _retryPointerAction;
1242
+ /**
1243
+ * Perform a single pointer action attempt. Returns error codes instead
1244
+ * of throwing, letting the retry layers decide.
1245
+ *
1246
+ * Follows Playwright's exact sequence:
1247
+ * 1. Check element states (visible, stable, enabled) — unless force
1248
+ * 2. Scroll into view if needed
1249
+ * 3. Compute action point via _clickablePoint() or _offsetPoint()
1250
+ * 4. Hit target check — PixUI placeholder (always passes)
1251
+ * 5. Perform action — unless trial
1252
+ *
1253
+ * Note: Element resolution is NOT done here — it's done by
1254
+ * _retryWithSelectorResolution, which passes the element ID.
1255
+ *
1256
+ * @see Playwright dom.ts ElementHandle._performPointerAction
1257
+ */
1258
+ private _performPointerAction;
1259
+ /**
1260
+ * Compute the clickable point (center) of an element.
1261
+ * @see Playwright dom.ts ElementHandle._clickablePoint
1262
+ */
1263
+ private _clickablePoint;
1264
+ /**
1265
+ * Compute a point at a specific offset from the element's top-left corner.
1266
+ *
1267
+ * Note: Playwright computes offset relative to the padding box (adds
1268
+ * border width). PixUI uses border-box for all elements, so we compute
1269
+ * relative to the bounding box directly.
1270
+ *
1271
+ * @see Playwright dom.ts ElementHandle._offsetPoint
1272
+ */
1273
+ private _offsetPoint;
1274
+ /**
1275
+ * Fetch a fresh bounding rect for an element from the client side.
1276
+ * @see Playwright dom.ts ElementHandle.boundingBox / getContentQuads
1277
+ */
1278
+ private _getBoundingRect;
1279
+ /**
1280
+ * Scroll the element (or a sub-rect of it) into the visible viewport area.
1281
+ * @see Playwright dom.ts ElementHandle._scrollRectIntoViewIfNeeded
1282
+ */
1283
+ private _scrollRectIntoViewIfNeeded;
1284
+ /**
1285
+ * Resolve the click-target position for this locator.
1286
+ * Public API for getting the element's action point.
1287
+ *
1288
+ * @see Playwright dom.ts _clickablePoint / _offsetPoint
1289
+ */
1290
+ position(relativePosition?: {
1291
+ x: number;
1292
+ y: number;
1293
+ }, options?: TimeoutOptions): Promise<{
1294
+ x: number;
1295
+ y: number;
1296
+ }>;
1297
+ first(): Locator;
1298
+ last(): Locator;
1299
+ nth(index: number): Locator;
1300
+ and(locator: Locator): Locator;
1301
+ or(locator: Locator): Locator;
1302
+ filter(options: LocatorFilterOptions): Locator;
1303
+ locator(selector: string): Locator;
1304
+ getByText(text: string | RegExp, options?: {
1305
+ exact?: boolean;
1306
+ }): Locator;
1307
+ getByAltText(text: string | RegExp, options?: {
1308
+ exact?: boolean;
1309
+ }): Locator;
1310
+ getByLabel(text: string | RegExp, options?: {
1311
+ exact?: boolean;
1312
+ }): Locator;
1313
+ getByPlaceholder(text: string | RegExp, options?: {
1314
+ exact?: boolean;
1315
+ }): Locator;
1316
+ getByTitle(text: string | RegExp, options?: {
1317
+ exact?: boolean;
1318
+ }): Locator;
1319
+ getByTestId(testId: string | RegExp): Locator;
1320
+ offset(dx: number, dy: number): Locator;
1321
+ /**
1322
+ * Click on this locator's element.
1323
+ *
1324
+ * Call chain (matching Playwright):
1325
+ * Frame._retryWithProgressIfNotConnected(selector, handle => handle._click())
1326
+ * → ElementHandle._click → _retryPointerAction → _retryAction → _performPointerAction
1327
+ *
1328
+ * Our equivalent:
1329
+ * _retryWithSelectorResolution(element =>
1330
+ * _retryPointerAction(element.id, ...) → _retryAction → _performPointerAction)
1331
+ *
1332
+ * @see Playwright frames.ts Frame.click
1333
+ * @see Playwright dom.ts ElementHandle._click
1334
+ */
1335
+ click(options?: ClickOptions): Promise<void>;
1336
+ /**
1337
+ * Double-click on this locator's element.
1338
+ * @see Playwright frames.ts Frame.dblclick
1339
+ * @see Playwright dom.ts ElementHandle._dblclick
1340
+ */
1341
+ dblclick(options?: ClickOptions): Promise<void>;
1342
+ /**
1343
+ * Hover over this locator's element (move mouse to element center).
1344
+ *
1345
+ * @see Playwright dom.ts ElementHandle._hover
1346
+ */
1347
+ hover(options?: HoverOptions): Promise<void>;
1348
+ /**
1349
+ * Scroll the mouse wheel at this locator's element position.
1350
+ */
1351
+ wheel(deltaY: number, deltaX?: number): Promise<void>;
1352
+ /**
1353
+ * Drag from this locator to a target position or locator.
1354
+ * @see Playwright frames.ts Frame.dragAndDrop
1355
+ */
1356
+ dragTo(target: SwipeTarget | Locator, options?: DragOptions): Promise<void>;
1357
+ /**
1358
+ * Tap on this locator's element.
1359
+ * @see Playwright frames.ts Frame.tap
1360
+ * @see Playwright dom.ts ElementHandle._tap
1361
+ */
1362
+ tap(options?: TapOptions): Promise<void>;
1363
+ /**
1364
+ * Swipe from this locator to a target position or locator.
1365
+ * (PixUI extension — not in Playwright; follows dragTo's pattern.)
1366
+ */
1367
+ swipeTo(target: SwipeTarget | Locator, options?: SwipeOptions): Promise<void>;
1368
+ /**
1369
+ * Long press on this locator's element.
1370
+ * (PixUI extension — not in Playwright; follows click's pattern.)
1371
+ */
1372
+ longPress(options?: LongPressOptions): Promise<void>;
1373
+ /**
1374
+ * Click this locator's element, then type text.
1375
+ */
1376
+ type(text: string, options?: TypeOptions): Promise<void>;
1377
+ /**
1378
+ * Click, select all, then insert text (or delete if empty).
1379
+ *
1380
+ * Playwright's fill uses DOM selection APIs (input.select(), Range) to
1381
+ * select existing content, then keyboard.insertText() to replace it.
1382
+ * PixUI lacks DOM selection APIs, so we use Control+A as a fallback.
1383
+ *
1384
+ * @see Playwright dom.ts ElementHandle._fill
1385
+ */
1386
+ fill(text: string, options?: FillOptions): Promise<void>;
1387
+ /**
1388
+ * Click this locator's element, then press a key or key combo.
1389
+ */
1390
+ press(key: string, options?: PressOptions & TimeoutOptions): Promise<void>;
1391
+ /**
1392
+ * Type characters one by one into the element.
1393
+ * Alias for `type()`, matching Playwright's naming.
1394
+ *
1395
+ * @see Playwright Locator.pressSequentially
1396
+ */
1397
+ pressSequentially(text: string, options?: TypeOptions): Promise<void>;
1398
+ /**
1399
+ * Clear the input field.
1400
+ *
1401
+ * @see Playwright Locator.clear
1402
+ */
1403
+ clear(options?: FillOptions): Promise<void>;
1404
+ /**
1405
+ * Focus the element.
1406
+ *
1407
+ * @see Playwright Locator.focus → Frame.focus → ElementHandle._focus
1408
+ */
1409
+ focus(options?: TimeoutOptions): Promise<void>;
1410
+ /**
1411
+ * Remove focus from the element.
1412
+ *
1413
+ * @see Playwright Locator.blur → Frame.blur → ElementHandle._blur
1414
+ */
1415
+ blur(options?: TimeoutOptions): Promise<void>;
1416
+ /**
1417
+ * Returns the number of elements matching this locator.
1418
+ */
1419
+ count(): Promise<number>;
1420
+ /**
1421
+ * Returns all matching elements' serialized data.
1422
+ */
1423
+ all(): Promise<ResolvedElement[]>;
1424
+ /**
1425
+ * Returns an array of all matching elements' `innerText` values.
1426
+ *
1427
+ * @see Playwright Locator.allInnerTexts → $$eval(ee => ee.map(e => e.innerText))
1428
+ */
1429
+ allInnerTexts(): Promise<string[]>;
1430
+ /**
1431
+ * Returns an array of all matching elements' `textContent` values.
1432
+ *
1433
+ * @see Playwright Locator.allTextContents → $$eval(ee => ee.map(e => e.textContent || ''))
1434
+ */
1435
+ allTextContents(): Promise<string[]>;
1436
+ /**
1437
+ * Check if this locator matches any visible element.
1438
+ */
1439
+ isVisible(options?: TimeoutOptions): Promise<boolean>;
1440
+ /**
1441
+ * Check if this locator's element is hidden.
1442
+ */
1443
+ isHidden(options?: TimeoutOptions): Promise<boolean>;
1444
+ /**
1445
+ * Check if this locator's element is enabled.
1446
+ *
1447
+ * @see Playwright frames.ts Frame.isEnabled → _callOnElementOnceMatches
1448
+ */
1449
+ isEnabled(options?: TimeoutOptions): Promise<boolean>;
1450
+ /**
1451
+ * Check if this locator's element is disabled.
1452
+ */
1453
+ isDisabled(options?: TimeoutOptions): Promise<boolean>;
1454
+ /**
1455
+ * Check if this locator's element is editable.
1456
+ */
1457
+ isEditable(options?: TimeoutOptions): Promise<boolean>;
1458
+ /**
1459
+ * Check if this locator's element is checked (for checkboxes/radios).
1460
+ */
1461
+ isChecked(options?: TimeoutOptions): Promise<boolean>;
1462
+ /**
1463
+ * Get the text content of this locator's element.
1464
+ *
1465
+ * @see Playwright frames.ts Frame.textContent → _callOnElementOnceMatches
1466
+ */
1467
+ textContent(options?: TimeoutOptions): Promise<string | null>;
1468
+ /**
1469
+ * Get the inner text of this locator's element.
1470
+ */
1471
+ innerText(options?: TimeoutOptions): Promise<string>;
1472
+ /**
1473
+ * Get the inner HTML of this locator's element.
1474
+ *
1475
+ * @see Playwright frames.ts Frame.innerHTML → _callOnElementOnceMatches
1476
+ */
1477
+ innerHTML(options?: TimeoutOptions): Promise<string>;
1478
+ /**
1479
+ * Get an attribute value from this locator's element.
1480
+ *
1481
+ * @see Playwright frames.ts Frame.getAttribute → _callOnElementOnceMatches
1482
+ */
1483
+ getAttribute(name: string, options?: TimeoutOptions): Promise<string | null>;
1484
+ /**
1485
+ * Returns the bounding box of the element, or `null` if the element is not visible.
1486
+ */
1487
+ boundingBox(options?: TimeoutOptions): Promise<{
1488
+ x: number;
1489
+ y: number;
1490
+ width: number;
1491
+ height: number;
1492
+ } | null>;
1493
+ /**
1494
+ * Wait for this locator's element to reach a certain state.
1495
+ *
1496
+ * Matches Playwright's Frame.waitForSelector which uses
1497
+ * retryWithProgressAndTimeouts with the same backoff pattern.
1498
+ *
1499
+ * @see Playwright frames.ts Frame.waitForSelector
1500
+ */
1501
+ waitFor(options?: WaitForOptions): Promise<void>;
1502
+ /**
1503
+ * Scroll the element into the visible viewport area if needed.
1504
+ *
1505
+ * Uses _retryWithSelectorResolution → _retryAction, matching Playwright's
1506
+ * ElementHandle._waitAndScrollIntoViewIfNeeded → _retryAction.
1507
+ *
1508
+ * @see Playwright dom.ts ElementHandle.scrollIntoViewIfNeeded → _waitAndScrollIntoViewIfNeeded
1509
+ */
1510
+ scrollIntoViewIfNeeded(options?: TimeoutOptions): Promise<void>;
1511
+ /**
1512
+ * Take a screenshot clipped to this element's bounding box.
1513
+ *
1514
+ * Uses _retryWithSelectorResolution → _retryAction, matching Playwright's
1515
+ * Frame.rafrafTimeoutScreenshotElementWithProgress → _retryWithProgressIfNotConnected.
1516
+ *
1517
+ * @see Playwright frames.ts Frame.rafrafTimeoutScreenshotElementWithProgress
1518
+ * @see Playwright dom.ts ElementHandle.screenshot
1519
+ */
1520
+ screenshot(options?: Omit<ScreenshotOptions, 'clip'>): Promise<Uint8Array>;
1521
+ /**
1522
+ * Evaluate a function in the page context with this element as the
1523
+ * first argument.
1524
+ *
1525
+ * The expression is sent to the client-side bridge as a string and
1526
+ * parsed there (matching Playwright's `normalizeEvaluationExpression`
1527
+ * + vitest-playwright-bridge's `parseExpression` pattern). The resolved
1528
+ * element is passed as the function's argument.
1529
+ *
1530
+ * Usage:
1531
+ * // Arrow function — element is the first arg
1532
+ * const text = await locator.evaluate<string>('(el) => el.textContent');
1533
+ *
1534
+ * // With extra arg — [element, arg] is passed
1535
+ * const attr = await locator.evaluate<string>(
1536
+ * '([el, name]) => el.getAttribute(name)',
1537
+ * 'data-value',
1538
+ * );
1539
+ *
1540
+ * @see Playwright Locator.evaluate → Frame.evalOnSelector
1541
+ * @see vitest-playwright-bridge HostHandle.evaluate
1542
+ */
1543
+ evaluate<R, Arg, E extends HTMLElement = HTMLElement>(expression: PageFunctionOn<E, Arg, R>, arg: Arg): Promise<R>;
1544
+ evaluate<R, E extends HTMLElement = HTMLElement>(expression: PageFunctionOn<E, void, R>, arg?: unknown): Promise<R>;
1545
+ /**
1546
+ * Evaluate a function against all matching elements.
1547
+ *
1548
+ * The function receives an array of all matching HTMLElements as its
1549
+ * first argument, and the optional `arg` as its second argument.
1550
+ *
1551
+ * @see Playwright Locator.evaluateAll → Frame.$$eval
1552
+ */
1553
+ evaluateAll<R, Arg, E extends HTMLElement = HTMLElement>(expression: PageFunctionOn<E[], Arg, R>, arg: Arg): Promise<R>;
1554
+ evaluateAll<R, E extends HTMLElement = HTMLElement>(expression: PageFunctionOn<E[], void, R>, arg?: unknown): Promise<R>;
1555
+ /**
1556
+ * Evaluate a function in the page context and return a handle to the result
1557
+ * instead of the serialized value.
1558
+ *
1559
+ * The handle can be used in subsequent `handle.evaluate()` calls or released
1560
+ * via `handle.dispose()`. This is useful for non-serializable values (DOM
1561
+ * elements, functions, etc.).
1562
+ *
1563
+ * JS handles are an emulator-only host feature: the concrete `JSHandle`
1564
+ * class (with `FinalizationRegistry` auto-dispose) lives in
1565
+ * `@pixui-dev/emulator-core`, not in this runtime-agnostic layer. The page
1566
+ * backend supplies it through {@link PageHost.wrapHandle}; backends that do
1567
+ * not support handles (e.g. inflight-test, which runs inside QuickJS and has
1568
+ * no `eval`) simply omit `wrapHandle`, and this method throws.
1569
+ *
1570
+ * @see Playwright Locator.evaluateHandle → Frame.evalOnSelectorHandle
1571
+ */
1572
+ evaluateHandle<R, Arg, E extends HTMLElement = HTMLElement>(expression: PageFunctionOn<E, Arg, R>, arg: Arg): Promise<JSHandleLike<R>>;
1573
+ evaluateHandle<R, E extends HTMLElement = HTMLElement>(expression: PageFunctionOn<E, void, R>, arg?: unknown): Promise<JSHandleLike<R>>;
1574
+ private _clone;
1575
+ setTimeout(timeout: number): Locator;
1576
+ toString(): string;
1577
+ } //#endregion
1578
+ //#region src/local-bridge.d.ts
1579
+ //#endregion
1580
+ //#region src/page/inflight-page.d.ts
1581
+ interface InflightPageOptions {
1582
+ /** Test-id attribute for `getByTestId`. Default `data-testid`. */
1583
+ testIdAttribute?: string;
1584
+ /** Activity ⇄ host bridge — required for `page.screenshot`. */
1585
+ activityBridge?: ActivityBridge;
1586
+ /** Filesystem writer — required for `page.screenshot`. */
1587
+ io?: ReportIo;
1588
+ /** Run directory screenshots are written under (`<run-dir>/screenshots/`). */
1589
+ reportRunDir?: string;
1590
+ /** Override the page API (default: `createPageApi()` over the live DOM). */
1591
+ api?: PageFunctions;
1592
+ /** Override the input backend (default: {@link DomInputBackend}). */
1593
+ input?: InputBackend;
1594
+ }
1595
+ declare class InflightPage implements PageHost {
1596
+ readonly devtoolsBridge: BridgeClient;
1597
+ readonly mouse: Mouse;
1598
+ readonly keyboard: Keyboard;
1599
+ readonly touchscreen: Touchscreen;
1600
+ readonly testIdAttribute: string;
1601
+ private _closed;
1602
+ private _disposed;
1603
+ private readonly _closeHandlers;
1604
+ private readonly _disposedHandlers;
1605
+ private readonly _activityBridge;
1606
+ private readonly _io;
1607
+ private readonly _reportRunDir;
1608
+ constructor(options?: InflightPageOptions);
1609
+ isClosed(): boolean;
1610
+ isDisposed(): boolean;
1611
+ waitForTimeout(ms: number): Promise<void>;
1612
+ onClose(handler: () => void): () => void;
1613
+ onDisposed(handler: () => void): () => void;
1614
+ screenshot(options?: ScreenshotOptions): Promise<Uint8Array>;
1615
+ locator(selector: string, options?: LocatorFilterOptions): Locator;
1616
+ getByText(text: string | RegExp, options?: {
1617
+ exact?: boolean;
1618
+ }): Locator;
1619
+ getByAltText(text: string | RegExp, options?: {
1620
+ exact?: boolean;
1621
+ }): Locator;
1622
+ getByLabel(text: string | RegExp, options?: {
1623
+ exact?: boolean;
1624
+ }): Locator;
1625
+ getByPlaceholder(text: string | RegExp, options?: {
1626
+ exact?: boolean;
1627
+ }): Locator;
1628
+ getByTitle(text: string | RegExp, options?: {
1629
+ exact?: boolean;
1630
+ }): Locator;
1631
+ getByTestId(testId: string | RegExp): Locator;
1632
+ /** Mark the page closed (window.close()-style) and notify listeners. */
1633
+ close(): void;
1634
+ /** Dispose the page and notify listeners. */
1635
+ dispose(): void;
1636
+ private _assertNotClosed;
1637
+ private _screenshotFileName;
1638
+ }
1639
+ //#endregion
1640
+ //#region src/page/page-singleton.d.ts
1641
+ /**
1642
+ * Configure the lazily-created {@link page} singleton. Called by `run()` before
1643
+ * tests execute so `page.screenshot()` etc. have their host wiring. Resets any
1644
+ * existing instance so the next access rebuilds with the new config; safe
1645
+ * because configuration always happens before tests create locators.
1646
+ */
1647
+ declare function configureInflightPage(options: InflightPageOptions): void;
1648
+ /** The live {@link InflightPage} instance, created on first access. */
1649
+ declare function getInflightPage(): InflightPage;
1650
+ /** Drop the current instance + config (test isolation). */
1651
+ declare function resetInflightPage(): void;
1652
+ /**
1653
+ * The shared page. Every access forwards to the lazily-created
1654
+ * {@link InflightPage}; methods are bound so destructuring
1655
+ * (`const { getByTestId } = page`) keeps working.
1656
+ */
1657
+ declare const page: InflightPage;
1658
+ //#endregion
1659
+ //#region src/page/dom-input-backend.d.ts
1660
+ declare class DomInputBackend implements InputBackend {
1661
+ click(x: number, y: number, options?: ClickOptions): Promise<void>;
1662
+ move(x: number, y: number): Promise<void>;
1663
+ down(x: number, y: number, options?: MouseOptions): Promise<void>;
1664
+ up(x: number, y: number, options?: MouseOptions): Promise<void>;
1665
+ wheel(x: number, y: number, deltaY: number, deltaX?: number): Promise<void>;
1666
+ tap(x: number, y: number, options?: TapOptions): Promise<void>;
1667
+ swipe(fromX: number, fromY: number, toX: number, toY: number, options?: SwipeOptions): Promise<void>;
1668
+ longPress(x: number, y: number, options?: LongPressOptions): Promise<void>;
1669
+ press(key: string, options?: PressOptions): Promise<void>;
1670
+ keyDown(key: string): Promise<void>;
1671
+ keyUp(key: string): Promise<void>;
1672
+ typeText(text: string, options?: TypeOptions): Promise<void>;
1673
+ }
1674
+ //#endregion
1675
+ //#region src/vendored/version.d.ts
1676
+ declare const VENDORED_VITEST_VERSION = "5.0.0-beta.5";
1677
+ //#endregion
1678
+ export { type ActivityBridge, type BlobReportInput, type CaptureRect, type CaptureScreenRequest, type CaptureScreenResult, type CaptureScreenshotOptions, type CapturedScreenshot, CollectingProgressSurface, ConsoleProgressSurface, DomInputBackend, InflightPage, type InflightPageOptions, type InflightRunOptions, type InflightRunResult, InflightVitestRunner, MemoryReportIo, PROTOCOL_CAPTURE_SCREEN, PROTOCOL_CAPTURE_SCREEN_CALLBACK, type ProgressSurface, type QuickjsOs, QuickjsReportIo, type ReportIo, type RunProgressEvent, SimulatedActivityBridge, type SimulatedScreenshotHostOptions, type StartOptions, TINY_PNG, type TestFileSpec, VENDORED_VITEST_VERSION, type VitestRunner, type WriteBlobReportOptions, type WrittenReport, afterAll, afterEach, beforeAll, beforeEach, captureScreenshot, collectTests, configureInflightPage, createRunId, describe, expect, getCurrentSuite, getInflightPage, getRunner, it, joinPath, onTestFailed, onTestFinished, page, recordArtifact, resetInflightPage, run, serializeBlobReport, start, startTests, suite, test, writeBlobReport };
1679
+ //# sourceMappingURL=index.d.ts.map