@ricsam/isolate-types 0.1.11 → 0.1.12

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.
@@ -362,6 +362,239 @@ declare global {
362
362
  * });
363
363
  */
364
364
  function serve<T = unknown>(options: ServeOptions<T>): void;
365
+
366
+ // ============================================
367
+ // Client WebSocket API (outbound connections)
368
+ // ============================================
369
+
370
+ /**
371
+ * The type for WebSocket binary data handling.
372
+ */
373
+ type BinaryType = "blob" | "arraybuffer";
374
+
375
+ /**
376
+ * Event fired when a WebSocket connection is closed.
377
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
378
+ */
379
+ interface CloseEvent extends Event {
380
+ /**
381
+ * The close code sent by the server.
382
+ */
383
+ readonly code: number;
384
+
385
+ /**
386
+ * The close reason sent by the server.
387
+ */
388
+ readonly reason: string;
389
+
390
+ /**
391
+ * Whether the connection was closed cleanly.
392
+ */
393
+ readonly wasClean: boolean;
394
+ }
395
+
396
+ /**
397
+ * Event fired when a WebSocket receives a message.
398
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent
399
+ */
400
+ interface MessageEvent<T = any> extends Event {
401
+ /**
402
+ * The data sent by the message emitter.
403
+ */
404
+ readonly data: T;
405
+
406
+ /**
407
+ * The origin of the message emitter.
408
+ */
409
+ readonly origin: string;
410
+
411
+ /**
412
+ * The last event ID (for Server-Sent Events).
413
+ */
414
+ readonly lastEventId: string;
415
+
416
+ /**
417
+ * The MessagePort array sent with the message (if any).
418
+ */
419
+ readonly ports: ReadonlyArray<MessagePort>;
420
+
421
+ /**
422
+ * The source of the message (if applicable).
423
+ */
424
+ readonly source: MessageEventSource | null;
425
+ }
426
+
427
+ /**
428
+ * WHATWG WebSocket client for making outbound WebSocket connections.
429
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
430
+ *
431
+ * @example
432
+ * const ws = new WebSocket("wss://echo.websocket.org");
433
+ *
434
+ * ws.onopen = () => {
435
+ * console.log("Connected!");
436
+ * ws.send("Hello, server!");
437
+ * };
438
+ *
439
+ * ws.onmessage = (event) => {
440
+ * console.log("Received:", event.data);
441
+ * };
442
+ *
443
+ * ws.onclose = (event) => {
444
+ * console.log("Closed:", event.code, event.reason);
445
+ * };
446
+ *
447
+ * ws.onerror = () => {
448
+ * console.log("Error occurred");
449
+ * };
450
+ */
451
+ interface WebSocket extends EventTarget {
452
+ /**
453
+ * The URL of the WebSocket connection.
454
+ */
455
+ readonly url: string;
456
+
457
+ /**
458
+ * The current state of the connection.
459
+ * - 0: CONNECTING
460
+ * - 1: OPEN
461
+ * - 2: CLOSING
462
+ * - 3: CLOSED
463
+ */
464
+ readonly readyState: number;
465
+
466
+ /**
467
+ * The number of bytes of data that have been queued but not yet transmitted.
468
+ */
469
+ readonly bufferedAmount: number;
470
+
471
+ /**
472
+ * The extensions selected by the server.
473
+ */
474
+ readonly extensions: string;
475
+
476
+ /**
477
+ * The subprotocol selected by the server.
478
+ */
479
+ readonly protocol: string;
480
+
481
+ /**
482
+ * The type of binary data being transmitted.
483
+ * Can be "blob" or "arraybuffer".
484
+ */
485
+ binaryType: BinaryType;
486
+
487
+ /**
488
+ * Send data through the WebSocket connection.
489
+ *
490
+ * @param data - The data to send
491
+ * @throws InvalidStateError if the connection is not open
492
+ *
493
+ * @example
494
+ * ws.send("Hello!");
495
+ * ws.send(new Uint8Array([1, 2, 3]));
496
+ */
497
+ send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
498
+
499
+ /**
500
+ * Close the WebSocket connection.
501
+ *
502
+ * @param code - The close code (default: 1000)
503
+ * @param reason - The close reason (max 123 bytes UTF-8)
504
+ *
505
+ * @example
506
+ * ws.close();
507
+ * ws.close(1000, "Normal closure");
508
+ */
509
+ close(code?: number, reason?: string): void;
510
+
511
+ /**
512
+ * Event handler for when the connection is established.
513
+ */
514
+ onopen: ((this: WebSocket, ev: Event) => any) | null;
515
+
516
+ /**
517
+ * Event handler for when a message is received.
518
+ */
519
+ onmessage: ((this: WebSocket, ev: MessageEvent) => any) | null;
520
+
521
+ /**
522
+ * Event handler for when an error occurs.
523
+ */
524
+ onerror: ((this: WebSocket, ev: Event) => any) | null;
525
+
526
+ /**
527
+ * Event handler for when the connection is closed.
528
+ */
529
+ onclose: ((this: WebSocket, ev: CloseEvent) => any) | null;
530
+
531
+ /**
532
+ * Connection is being established.
533
+ */
534
+ readonly CONNECTING: 0;
535
+
536
+ /**
537
+ * Connection is open and ready to communicate.
538
+ */
539
+ readonly OPEN: 1;
540
+
541
+ /**
542
+ * Connection is in the process of closing.
543
+ */
544
+ readonly CLOSING: 2;
545
+
546
+ /**
547
+ * Connection is closed or couldn't be opened.
548
+ */
549
+ readonly CLOSED: 3;
550
+ }
551
+
552
+ /**
553
+ * WebSocket constructor.
554
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket
555
+ */
556
+ interface WebSocketConstructor {
557
+ /**
558
+ * Create a new WebSocket connection.
559
+ *
560
+ * @param url - The URL to connect to (must be ws:// or wss://)
561
+ * @param protocols - Optional subprotocol(s) to request
562
+ * @throws SyntaxError if the URL is invalid
563
+ *
564
+ * @example
565
+ * const ws = new WebSocket("wss://example.com/socket");
566
+ * const ws = new WebSocket("wss://example.com/socket", "graphql-ws");
567
+ * const ws = new WebSocket("wss://example.com/socket", ["protocol1", "protocol2"]);
568
+ */
569
+ new (url: string | URL, protocols?: string | string[]): WebSocket;
570
+
571
+ readonly prototype: WebSocket;
572
+
573
+ /**
574
+ * Connection is being established.
575
+ */
576
+ readonly CONNECTING: 0;
577
+
578
+ /**
579
+ * Connection is open and ready to communicate.
580
+ */
581
+ readonly OPEN: 1;
582
+
583
+ /**
584
+ * Connection is in the process of closing.
585
+ */
586
+ readonly CLOSING: 2;
587
+
588
+ /**
589
+ * Connection is closed or couldn't be opened.
590
+ */
591
+ readonly CLOSED: 3;
592
+ }
593
+
594
+ /**
595
+ * WHATWG WebSocket client for making outbound WebSocket connections.
596
+ */
597
+ const WebSocket: WebSocketConstructor;
365
598
  }
366
599
  `;
367
600
  var FS_TYPES = `/**
@@ -1119,6 +1352,164 @@ declare global {
1119
1352
  * btoa("Hello"); // "SGVsbG8="
1120
1353
  */
1121
1354
  function btoa(stringToEncode: string): string;
1355
+
1356
+ // ============================================
1357
+ // Buffer
1358
+ // ============================================
1359
+
1360
+ /**
1361
+ * Buffer encoding types supported by the isolate Buffer implementation.
1362
+ */
1363
+ type BufferEncoding = "utf8" | "utf-8" | "base64" | "hex";
1364
+
1365
+ /**
1366
+ * Buffer class for working with binary data.
1367
+ * Extends Uint8Array for compatibility.
1368
+ * @see https://nodejs.org/api/buffer.html
1369
+ */
1370
+ interface Buffer extends Uint8Array {
1371
+ /**
1372
+ * Convert the buffer to a string.
1373
+ *
1374
+ * @param encoding - The encoding to use (default: "utf8")
1375
+ * @returns The string representation
1376
+ *
1377
+ * @example
1378
+ * const buf = Buffer.from("hello");
1379
+ * buf.toString(); // "hello"
1380
+ * buf.toString("hex"); // "68656c6c6f"
1381
+ * buf.toString("base64"); // "aGVsbG8="
1382
+ */
1383
+ toString(encoding?: BufferEncoding): string;
1384
+
1385
+ /**
1386
+ * Returns a new Buffer that references the same memory as the original,
1387
+ * but offset and cropped by the start and end indices.
1388
+ *
1389
+ * @param start - Start index (default: 0)
1390
+ * @param end - End index (default: buffer.length)
1391
+ * @returns A new Buffer instance
1392
+ *
1393
+ * @example
1394
+ * const buf = Buffer.from("hello");
1395
+ * buf.slice(1, 4).toString(); // "ell"
1396
+ */
1397
+ slice(start?: number, end?: number): Buffer;
1398
+
1399
+ /**
1400
+ * Returns a new Buffer that references the same memory as the original,
1401
+ * but offset and cropped by the start and end indices.
1402
+ *
1403
+ * @param start - Start index (default: 0)
1404
+ * @param end - End index (default: buffer.length)
1405
+ * @returns A new Buffer instance
1406
+ */
1407
+ subarray(start?: number, end?: number): Buffer;
1408
+ }
1409
+
1410
+ /**
1411
+ * Buffer constructor interface.
1412
+ */
1413
+ interface BufferConstructor {
1414
+ /**
1415
+ * Creates a new Buffer from a string, array, ArrayBuffer, or another Buffer.
1416
+ *
1417
+ * @param value - The value to create a buffer from
1418
+ * @param encodingOrOffset - Encoding for strings, or byte offset for ArrayBuffer
1419
+ * @param length - Length for ArrayBuffer (when offset is provided)
1420
+ * @returns A new Buffer instance
1421
+ *
1422
+ * @example
1423
+ * Buffer.from("hello"); // UTF-8 encoded
1424
+ * Buffer.from("aGVsbG8=", "base64"); // base64 decoded
1425
+ * Buffer.from("68656c6c6f", "hex"); // hex decoded
1426
+ * Buffer.from([104, 101, 108, 108, 111]); // from array
1427
+ */
1428
+ from(value: string, encoding?: BufferEncoding): Buffer;
1429
+ from(value: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
1430
+ from(value: Uint8Array | ReadonlyArray<number>): Buffer;
1431
+ from(value: Iterable<number>): Buffer;
1432
+
1433
+ /**
1434
+ * Allocates a new Buffer of the specified size, filled with zeros or the specified fill value.
1435
+ *
1436
+ * @param size - The size of the buffer in bytes
1437
+ * @param fill - Value to fill the buffer with (default: 0)
1438
+ * @param encoding - Encoding for string fill values
1439
+ * @returns A new Buffer instance
1440
+ *
1441
+ * @example
1442
+ * Buffer.alloc(5); // <Buffer 00 00 00 00 00>
1443
+ * Buffer.alloc(5, 1); // <Buffer 01 01 01 01 01>
1444
+ * Buffer.alloc(5, "ab"); // <Buffer 61 62 61 62 61>
1445
+ */
1446
+ alloc(size: number, fill?: number | string | Buffer, encoding?: BufferEncoding): Buffer;
1447
+
1448
+ /**
1449
+ * Allocates a new Buffer of the specified size without initializing the memory.
1450
+ * The contents are unknown and may contain sensitive data.
1451
+ *
1452
+ * @param size - The size of the buffer in bytes
1453
+ * @returns A new Buffer instance
1454
+ */
1455
+ allocUnsafe(size: number): Buffer;
1456
+
1457
+ /**
1458
+ * Concatenates a list of Buffers.
1459
+ *
1460
+ * @param list - Array of Buffer instances to concatenate
1461
+ * @param totalLength - Total length of the buffers (optional)
1462
+ * @returns A new Buffer instance
1463
+ *
1464
+ * @example
1465
+ * const buf1 = Buffer.from("hel");
1466
+ * const buf2 = Buffer.from("lo");
1467
+ * Buffer.concat([buf1, buf2]).toString(); // "hello"
1468
+ */
1469
+ concat(list: ReadonlyArray<Uint8Array>, totalLength?: number): Buffer;
1470
+
1471
+ /**
1472
+ * Returns true if the given object is a Buffer.
1473
+ *
1474
+ * @param obj - Object to test
1475
+ * @returns true if obj is a Buffer
1476
+ *
1477
+ * @example
1478
+ * Buffer.isBuffer(Buffer.from("test")); // true
1479
+ * Buffer.isBuffer(new Uint8Array(5)); // false
1480
+ */
1481
+ isBuffer(obj: unknown): obj is Buffer;
1482
+
1483
+ /**
1484
+ * Returns the byte length of a string when encoded.
1485
+ *
1486
+ * @param string - The string to measure
1487
+ * @param encoding - The encoding (default: "utf8")
1488
+ * @returns The byte length
1489
+ *
1490
+ * @example
1491
+ * Buffer.byteLength("hello"); // 5
1492
+ * Buffer.byteLength("aGVsbG8=", "base64"); // 5 (decoded length)
1493
+ */
1494
+ byteLength(string: string, encoding?: BufferEncoding): number;
1495
+ byteLength(buffer: ArrayBufferView | ArrayBuffer): number;
1496
+
1497
+ /**
1498
+ * Returns true if the encoding is a valid buffer encoding.
1499
+ *
1500
+ * @param encoding - The encoding to check
1501
+ * @returns true if the encoding is supported
1502
+ */
1503
+ isEncoding(encoding: string): encoding is BufferEncoding;
1504
+
1505
+ readonly prototype: Buffer;
1506
+ }
1507
+
1508
+ /**
1509
+ * Buffer class for working with binary data.
1510
+ * @see https://nodejs.org/api/buffer.html
1511
+ */
1512
+ const Buffer: BufferConstructor;
1122
1513
  }
1123
1514
  `;
1124
1515
  var CRYPTO_TYPES = `/**
@@ -1689,6 +2080,406 @@ declare global {
1689
2080
  function clearInterval(id: number | undefined): void;
1690
2081
  }
1691
2082
  `;
2083
+ var PLAYWRIGHT_TYPES = `
2084
+ /**
2085
+ * Locator represents an element or group of elements in the page.
2086
+ */
2087
+ declare class Locator {
2088
+ /** Click the element */
2089
+ click(): Promise<void>;
2090
+ /** Double-click the element */
2091
+ dblclick(): Promise<void>;
2092
+ /** Fill an input element with text */
2093
+ fill(text: string): Promise<void>;
2094
+ /** Type text into an element (key by key) */
2095
+ type(text: string): Promise<void>;
2096
+ /** Check a checkbox or radio */
2097
+ check(): Promise<void>;
2098
+ /** Uncheck a checkbox */
2099
+ uncheck(): Promise<void>;
2100
+ /** Select an option in a dropdown */
2101
+ selectOption(value: string | string[]): Promise<void>;
2102
+ /** Clear an input element */
2103
+ clear(): Promise<void>;
2104
+ /** Press a key */
2105
+ press(key: string): Promise<void>;
2106
+ /** Hover over the element */
2107
+ hover(): Promise<void>;
2108
+ /** Focus the element */
2109
+ focus(): Promise<void>;
2110
+ /** Get text content of the element */
2111
+ textContent(): Promise<string | null>;
2112
+ /** Get the value of an input element */
2113
+ inputValue(): Promise<string>;
2114
+ /** Check if the element is visible */
2115
+ isVisible(): Promise<boolean>;
2116
+ /** Check if the element is enabled */
2117
+ isEnabled(): Promise<boolean>;
2118
+ /** Check if the element is checked */
2119
+ isChecked(): Promise<boolean>;
2120
+ /** Check if the element is disabled */
2121
+ isDisabled(): Promise<boolean>;
2122
+ /** Check if the element is hidden */
2123
+ isHidden(): Promise<boolean>;
2124
+ /** Get the count of matching elements */
2125
+ count(): Promise<number>;
2126
+ /** Get an attribute value */
2127
+ getAttribute(name: string): Promise<string | null>;
2128
+ /** Get innerHTML */
2129
+ innerHTML(): Promise<string>;
2130
+ /** Get innerText */
2131
+ innerText(): Promise<string>;
2132
+ /** Get all text contents */
2133
+ allTextContents(): Promise<string[]>;
2134
+ /** Get all inner texts */
2135
+ allInnerTexts(): Promise<string[]>;
2136
+ /** Wait for the element to match a state */
2137
+ waitFor(options?: { state?: "attached" | "detached" | "visible" | "hidden"; timeout?: number }): Promise<void>;
2138
+ /** Get bounding box */
2139
+ boundingBox(): Promise<{ x: number; y: number; width: number; height: number } | null>;
2140
+ /** Set input files for a file input */
2141
+ setInputFiles(files: string | string[] | { name: string; mimeType: string; buffer: ArrayBuffer | Uint8Array | string }[]): Promise<void>;
2142
+ /** Take a screenshot of the element */
2143
+ screenshot(options?: { path?: string; type?: "png" | "jpeg"; quality?: number }): Promise<string>;
2144
+ /** Drag to another element */
2145
+ dragTo(target: Locator): Promise<void>;
2146
+ /** Scroll element into view */
2147
+ scrollIntoViewIfNeeded(): Promise<void>;
2148
+ /** Highlight the element for debugging */
2149
+ highlight(): Promise<void>;
2150
+ /** Evaluate a function in the context of the element */
2151
+ evaluate<R>(fn: (el: Element, arg?: unknown) => R, arg?: unknown): Promise<R>;
2152
+ /** Evaluate a function for all matching elements */
2153
+ evaluateAll<R>(fn: (els: Element[], arg?: unknown) => R, arg?: unknown): Promise<R>;
2154
+
2155
+ // Chaining methods
2156
+ /** Chain with another CSS selector */
2157
+ locator(selector: string): Locator;
2158
+ /** Chain with getByRole */
2159
+ getByRole(role: string, options?: { name?: string | RegExp; exact?: boolean }): Locator;
2160
+ /** Chain with getByText */
2161
+ getByText(text: string | RegExp): Locator;
2162
+ /** Chain with getByLabel */
2163
+ getByLabel(label: string | RegExp): Locator;
2164
+ /** Chain with getByPlaceholder */
2165
+ getByPlaceholder(placeholder: string | RegExp): Locator;
2166
+ /** Chain with getByTestId */
2167
+ getByTestId(testId: string): Locator;
2168
+ /** Chain with getByAltText */
2169
+ getByAltText(alt: string | RegExp): Locator;
2170
+ /** Chain with getByTitle */
2171
+ getByTitle(title: string | RegExp): Locator;
2172
+
2173
+ // Subset selection
2174
+ /** Get all matching locators as an array */
2175
+ all(): Promise<Locator[]>;
2176
+ /** Get the nth matching element */
2177
+ nth(index: number): Locator;
2178
+ /** Get the first matching element */
2179
+ first(): Locator;
2180
+ /** Get the last matching element */
2181
+ last(): Locator;
2182
+
2183
+ // Filtering
2184
+ /** Filter locators by additional criteria */
2185
+ filter(options: { hasText?: string | RegExp; hasNotText?: string | RegExp; has?: Locator; hasNot?: Locator }): Locator;
2186
+ /** Create a locator matching either this or the other locator */
2187
+ or(other: Locator): Locator;
2188
+ /** Create a locator matching both this and the other locator */
2189
+ and(other: Locator): Locator;
2190
+ }
2191
+
2192
+ /**
2193
+ * FrameLocator for interacting with elements inside iframes.
2194
+ */
2195
+ interface FrameLocator {
2196
+ locator(selector: string): Locator;
2197
+ getByRole(role: string, options?: { name?: string | RegExp; exact?: boolean }): Locator;
2198
+ getByText(text: string | RegExp): Locator;
2199
+ getByLabel(label: string | RegExp): Locator;
2200
+ getByPlaceholder(placeholder: string | RegExp): Locator;
2201
+ getByTestId(testId: string): Locator;
2202
+ getByAltText(alt: string | RegExp): Locator;
2203
+ getByTitle(title: string | RegExp): Locator;
2204
+ }
2205
+
2206
+ /**
2207
+ * Keyboard API for simulating keyboard input.
2208
+ */
2209
+ interface Keyboard {
2210
+ type(text: string, options?: { delay?: number }): Promise<void>;
2211
+ press(key: string, options?: { delay?: number }): Promise<void>;
2212
+ down(key: string): Promise<void>;
2213
+ up(key: string): Promise<void>;
2214
+ insertText(text: string): Promise<void>;
2215
+ }
2216
+
2217
+ /**
2218
+ * Mouse API for simulating mouse input.
2219
+ */
2220
+ interface Mouse {
2221
+ move(x: number, y: number, options?: { steps?: number }): Promise<void>;
2222
+ click(x: number, y: number, options?: { button?: "left" | "right" | "middle"; clickCount?: number; delay?: number }): Promise<void>;
2223
+ down(options?: { button?: "left" | "right" | "middle"; clickCount?: number }): Promise<void>;
2224
+ up(options?: { button?: "left" | "right" | "middle"; clickCount?: number }): Promise<void>;
2225
+ wheel(deltaX: number, deltaY: number): Promise<void>;
2226
+ }
2227
+
2228
+ /**
2229
+ * API Response from page.request methods.
2230
+ */
2231
+ interface APIResponse {
2232
+ status(): number;
2233
+ ok(): boolean;
2234
+ headers(): Record<string, string>;
2235
+ json(): Promise<unknown>;
2236
+ text(): Promise<string>;
2237
+ body(): Promise<ArrayBuffer>;
2238
+ }
2239
+
2240
+ /**
2241
+ * Request API for making HTTP requests with page cookies.
2242
+ */
2243
+ interface APIRequestContext {
2244
+ fetch(url: string, options?: { method?: string; data?: unknown; headers?: Record<string, string> }): Promise<APIResponse>;
2245
+ get(url: string, options?: { headers?: Record<string, string> }): Promise<APIResponse>;
2246
+ post(url: string, options?: { data?: unknown; headers?: Record<string, string> }): Promise<APIResponse>;
2247
+ put(url: string, options?: { data?: unknown; headers?: Record<string, string> }): Promise<APIResponse>;
2248
+ delete(url: string, options?: { headers?: Record<string, string> }): Promise<APIResponse>;
2249
+ }
2250
+
2251
+ /**
2252
+ * Frame information.
2253
+ */
2254
+ interface FrameInfo {
2255
+ name: string;
2256
+ url: string;
2257
+ }
2258
+
2259
+ /**
2260
+ * Cookie data.
2261
+ */
2262
+ interface Cookie {
2263
+ name: string;
2264
+ value: string;
2265
+ domain?: string;
2266
+ path?: string;
2267
+ expires?: number;
2268
+ httpOnly?: boolean;
2269
+ secure?: boolean;
2270
+ sameSite?: "Strict" | "Lax" | "None";
2271
+ }
2272
+
2273
+ /**
2274
+ * IsolatePage - represents a browser page in the isolate.
2275
+ */
2276
+ declare class IsolatePage {
2277
+ /** Navigate to a URL */
2278
+ goto(url: string, options?: { waitUntil?: "load" | "domcontentloaded" | "networkidle" }): Promise<void>;
2279
+ /** Reload the page */
2280
+ reload(): Promise<void>;
2281
+ /** Get the current URL (synchronous) */
2282
+ url(): string;
2283
+ /** Get the page title */
2284
+ title(): Promise<string>;
2285
+ /** Get the page HTML content */
2286
+ content(): Promise<string>;
2287
+ /** Wait for a selector to appear */
2288
+ waitForSelector(selector: string, options?: { state?: "attached" | "detached" | "visible" | "hidden"; timeout?: number }): Promise<void>;
2289
+ /** Wait for a specified time */
2290
+ waitForTimeout(ms: number): Promise<void>;
2291
+ /** Wait for a load state */
2292
+ waitForLoadState(state?: "load" | "domcontentloaded" | "networkidle"): Promise<void>;
2293
+ /** Wait for the URL to match */
2294
+ waitForURL(url: string | RegExp, options?: { timeout?: number; waitUntil?: "load" | "domcontentloaded" | "networkidle" }): Promise<void>;
2295
+ /** Evaluate JavaScript in the browser context */
2296
+ evaluate<R>(script: string | (() => R) | ((arg: unknown) => R), arg?: unknown): Promise<R>;
2297
+ /** Create a locator by CSS selector */
2298
+ locator(selector: string): Locator;
2299
+ /** Create a locator by ARIA role */
2300
+ getByRole(role: string, options?: { name?: string | RegExp; exact?: boolean }): Locator;
2301
+ /** Create a locator by text content */
2302
+ getByText(text: string | RegExp): Locator;
2303
+ /** Create a locator by label */
2304
+ getByLabel(label: string | RegExp): Locator;
2305
+ /** Create a locator by placeholder */
2306
+ getByPlaceholder(placeholder: string | RegExp): Locator;
2307
+ /** Create a locator by test ID */
2308
+ getByTestId(testId: string): Locator;
2309
+ /** Create a locator by alt text */
2310
+ getByAltText(alt: string | RegExp): Locator;
2311
+ /** Create a locator by title */
2312
+ getByTitle(title: string | RegExp): Locator;
2313
+ /** Create a frame locator */
2314
+ frameLocator(selector: string): FrameLocator;
2315
+ /** Navigate back */
2316
+ goBack(options?: { waitUntil?: "load" | "domcontentloaded" | "networkidle" }): Promise<void>;
2317
+ /** Navigate forward */
2318
+ goForward(options?: { waitUntil?: "load" | "domcontentloaded" | "networkidle" }): Promise<void>;
2319
+ /** Click an element (shorthand) */
2320
+ click(selector: string): Promise<void>;
2321
+ /** Fill an input (shorthand) */
2322
+ fill(selector: string, value: string): Promise<void>;
2323
+ /** Take a screenshot */
2324
+ screenshot(options?: { path?: string; fullPage?: boolean; type?: "png" | "jpeg"; quality?: number }): Promise<string>;
2325
+ /** Generate a PDF (Chromium only) */
2326
+ pdf(options?: { path?: string; format?: string; landscape?: boolean; margin?: { top?: string; bottom?: string; left?: string; right?: string } }): Promise<string>;
2327
+ /** Set the viewport size */
2328
+ setViewportSize(size: { width: number; height: number }): Promise<void>;
2329
+ /** Get the viewport size */
2330
+ viewportSize(): Promise<{ width: number; height: number } | null>;
2331
+ /** Emulate media type or color scheme */
2332
+ emulateMedia(options: { media?: "screen" | "print" | null; colorScheme?: "light" | "dark" | "no-preference" | null }): Promise<void>;
2333
+ /** Set extra HTTP headers */
2334
+ setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
2335
+ /** Bring the page to front */
2336
+ bringToFront(): Promise<void>;
2337
+ /** Close the page */
2338
+ close(): Promise<void>;
2339
+ /** Check if the page is closed */
2340
+ isClosed(): Promise<boolean>;
2341
+ /** Pause execution (for debugging) */
2342
+ pause(): Promise<void>;
2343
+ /** Get all frames */
2344
+ frames(): Promise<FrameInfo[]>;
2345
+ /** Get the main frame */
2346
+ mainFrame(): Promise<FrameInfo>;
2347
+ /** Get the browser context for this page */
2348
+ context(): IsolateContext;
2349
+ /** Keyboard API */
2350
+ readonly keyboard: Keyboard;
2351
+ /** Mouse API */
2352
+ readonly mouse: Mouse;
2353
+ /** Request API for making HTTP requests */
2354
+ readonly request: APIRequestContext;
2355
+ }
2356
+
2357
+ /**
2358
+ * IsolateContext - represents a browser context in the isolate.
2359
+ */
2360
+ declare class IsolateContext {
2361
+ /** Create a new page in this context (requires createPage callback) */
2362
+ newPage(): Promise<IsolatePage>;
2363
+ /** Close this context and all its pages */
2364
+ close(): Promise<void>;
2365
+ /** Clear all cookies */
2366
+ clearCookies(): Promise<void>;
2367
+ /** Add cookies */
2368
+ addCookies(cookies: Cookie[]): Promise<void>;
2369
+ /** Get cookies */
2370
+ cookies(urls?: string | string[]): Promise<Cookie[]>;
2371
+ }
2372
+
2373
+ /**
2374
+ * Browser object for creating new contexts.
2375
+ */
2376
+ interface IsolateBrowser {
2377
+ /** Create a new browser context (requires createContext callback) */
2378
+ newContext(options?: {
2379
+ viewport?: { width: number; height: number } | null;
2380
+ userAgent?: string;
2381
+ locale?: string;
2382
+ timezoneId?: string;
2383
+ geolocation?: { latitude: number; longitude: number; accuracy?: number };
2384
+ permissions?: string[];
2385
+ colorScheme?: "light" | "dark" | "no-preference";
2386
+ }): Promise<IsolateContext>;
2387
+ }
2388
+
2389
+ /**
2390
+ * The default page object.
2391
+ */
2392
+ declare const page: IsolatePage;
2393
+
2394
+ /**
2395
+ * The default browser context.
2396
+ */
2397
+ declare const context: IsolateContext;
2398
+
2399
+ /**
2400
+ * Browser object for creating new contexts.
2401
+ */
2402
+ declare const browser: IsolateBrowser;
2403
+
2404
+ // ============================================================================
2405
+ // Playwright Expect Matchers (extends test-environment expect)
2406
+ // ============================================================================
2407
+
2408
+ /**
2409
+ * Options for locator assertion timeouts.
2410
+ */
2411
+ interface LocatorAssertionOptions {
2412
+ timeout?: number;
2413
+ }
2414
+
2415
+ /**
2416
+ * Locator-specific assertion matchers (added to expect when using Playwright).
2417
+ * These are available when calling expect(locator).
2418
+ */
2419
+ interface PlaywrightLocatorMatchers {
2420
+ /** Assert element is visible */
2421
+ toBeVisible(options?: LocatorAssertionOptions): Promise<void>;
2422
+ /** Assert element is hidden */
2423
+ toBeHidden(options?: LocatorAssertionOptions): Promise<void>;
2424
+ /** Assert element is enabled */
2425
+ toBeEnabled(options?: LocatorAssertionOptions): Promise<void>;
2426
+ /** Assert element is disabled */
2427
+ toBeDisabled(options?: LocatorAssertionOptions): Promise<void>;
2428
+ /** Assert element is checked */
2429
+ toBeChecked(options?: LocatorAssertionOptions): Promise<void>;
2430
+ /** Assert element is focused */
2431
+ toBeFocused(options?: LocatorAssertionOptions): Promise<void>;
2432
+ /** Assert element is empty */
2433
+ toBeEmpty(options?: LocatorAssertionOptions): Promise<void>;
2434
+ /** Assert element is attached to DOM */
2435
+ toBeAttached(options?: LocatorAssertionOptions): Promise<void>;
2436
+ /** Assert element is editable */
2437
+ toBeEditable(options?: LocatorAssertionOptions): Promise<void>;
2438
+ /** Assert element is in viewport */
2439
+ toBeInViewport(options?: LocatorAssertionOptions): Promise<void>;
2440
+ /** Assert element contains text */
2441
+ toContainText(expected: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2442
+ /** Assert element has exact text */
2443
+ toHaveText(expected: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2444
+ /** Assert element has value (for inputs) */
2445
+ toHaveValue(expected: string, options?: LocatorAssertionOptions): Promise<void>;
2446
+ /** Assert element has attribute */
2447
+ toHaveAttribute(name: string, value?: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2448
+ /** Assert element count */
2449
+ toHaveCount(count: number, options?: LocatorAssertionOptions): Promise<void>;
2450
+ /** Assert element has class */
2451
+ toHaveClass(expected: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2452
+ /** Assert element contains class */
2453
+ toContainClass(expected: string, options?: LocatorAssertionOptions): Promise<void>;
2454
+ /** Assert element has id */
2455
+ toHaveId(expected: string, options?: LocatorAssertionOptions): Promise<void>;
2456
+ /** Assert element has CSS property */
2457
+ toHaveCSS(name: string, value: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2458
+ /** Assert element has JavaScript property */
2459
+ toHaveJSProperty(name: string, value: unknown, options?: LocatorAssertionOptions): Promise<void>;
2460
+ /** Assert element has accessible name */
2461
+ toHaveAccessibleName(expected: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2462
+ /** Assert element has accessible description */
2463
+ toHaveAccessibleDescription(expected: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2464
+ /** Assert element has ARIA role */
2465
+ toHaveRole(expected: string, options?: LocatorAssertionOptions): Promise<void>;
2466
+ /** Negated matchers */
2467
+ not: PlaywrightLocatorMatchers;
2468
+ }
2469
+
2470
+ /**
2471
+ * Page-specific assertion matchers (added to expect when using Playwright).
2472
+ * These are available when calling expect(page).
2473
+ */
2474
+ interface PlaywrightPageMatchers {
2475
+ /** Assert page has URL */
2476
+ toHaveURL(expected: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2477
+ /** Assert page has title */
2478
+ toHaveTitle(expected: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2479
+ /** Negated matchers */
2480
+ not: PlaywrightPageMatchers;
2481
+ }
2482
+ `;
1692
2483
  var TYPE_DEFINITIONS = {
1693
2484
  core: CORE_TYPES,
1694
2485
  console: CONSOLE_TYPES,
@@ -1698,12 +2489,14 @@ var TYPE_DEFINITIONS = {
1698
2489
  fs: FS_TYPES,
1699
2490
  path: PATH_TYPES,
1700
2491
  testEnvironment: TEST_ENV_TYPES,
1701
- timers: TIMERS_TYPES
2492
+ timers: TIMERS_TYPES,
2493
+ playwright: PLAYWRIGHT_TYPES
1702
2494
  };
1703
2495
  export {
1704
2496
  TYPE_DEFINITIONS,
1705
2497
  TIMERS_TYPES,
1706
2498
  TEST_ENV_TYPES,
2499
+ PLAYWRIGHT_TYPES,
1707
2500
  PATH_TYPES,
1708
2501
  FS_TYPES,
1709
2502
  FETCH_TYPES,
@@ -1713,4 +2506,4 @@ export {
1713
2506
  CONSOLE_TYPES
1714
2507
  };
1715
2508
 
1716
- //# debugId=C1F61403DE2A5D3A64756E2164756E21
2509
+ //# debugId=C56FF6D7DC9C53B764756E2164756E21