@ricsam/isolate-types 0.1.11 → 0.1.13

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