@cloudflare/workers-types 5.20261119.1 → 5.20261120.1

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.
@@ -252,7 +252,6 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
252
252
  ): number;
253
253
  clearInterval(timeoutId: number | null): void;
254
254
  queueMicrotask(task: Function): void;
255
- structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
256
255
  reportError(error: any): void;
257
256
  fetch(
258
257
  input: RequestInfo | URL,
@@ -284,8 +283,6 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
284
283
  ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
285
284
  CountQueuingStrategy: typeof CountQueuingStrategy;
286
285
  ErrorEvent: typeof ErrorEvent;
287
- MessageChannel: typeof MessageChannel;
288
- MessagePort: typeof MessagePort;
289
286
  FileSystemHandle: typeof FileSystemHandle;
290
287
  FileSystemFileHandle: typeof FileSystemFileHandle;
291
288
  FileSystemDirectoryHandle: typeof FileSystemDirectoryHandle;
@@ -336,6 +333,8 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
336
333
  PerformanceResourceTiming: typeof PerformanceResourceTiming;
337
334
  PerformanceObserver: typeof PerformanceObserver;
338
335
  PerformanceObserverEntryList: typeof PerformanceObserverEntryList;
336
+ MessageChannel: typeof MessageChannel;
337
+ MessagePort: typeof MessagePort;
339
338
  }
340
339
  declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(
341
340
  type: Type,
@@ -389,11 +388,6 @@ declare function setInterval<Args extends any[]>(
389
388
  declare function clearInterval(timeoutId: number | null): void;
390
389
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
391
390
  declare function queueMicrotask(task: Function): void;
392
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
393
- declare function structuredClone<T>(
394
- value: T,
395
- options?: StructuredSerializeOptions,
396
- ): T;
397
391
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
398
392
  declare function reportError(error: any): void;
399
393
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
@@ -517,9 +511,6 @@ interface ExportedHandler<
517
511
  email?: EmailExportedHandler<Env, Props>;
518
512
  queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage, Props>;
519
513
  }
520
- interface StructuredSerializeOptions {
521
- transfer?: any[];
522
- }
523
514
  declare abstract class Navigator {
524
515
  sendBeacon(url: string, body?: BodyInit): boolean;
525
516
  readonly userAgent: string;
@@ -3663,6 +3654,7 @@ interface Socket {
3663
3654
  close(): Promise<void>;
3664
3655
  startTls(options?: TlsOptions): Socket;
3665
3656
  proxyTo(sock: Socket, options?: StreamPipeOptions): Promise<void>;
3657
+ accept(): void;
3666
3658
  }
3667
3659
  interface SocketOptions {
3668
3660
  secureTransport?: string;
@@ -4023,59 +4015,6 @@ interface FileSystemFileWriteParams {
4023
4015
  interface FileSystemHandleRemoveOptions {
4024
4016
  recursive?: boolean;
4025
4017
  }
4026
- /**
4027
- * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
4028
- *
4029
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
4030
- */
4031
- declare abstract class MessagePort extends EventTarget {
4032
- /**
4033
- * The **`postMessage()`** method of the MessagePort interface sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.
4034
- *
4035
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
4036
- */
4037
- postMessage(
4038
- data?: any,
4039
- options?: any[] | MessagePortPostMessageOptions,
4040
- ): void;
4041
- /**
4042
- * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active. This stops the flow of messages to that port.
4043
- *
4044
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
4045
- */
4046
- close(): void;
4047
- /**
4048
- * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port. This method is only needed when using EventTarget.addEventListener; it is implied when using onmessage.
4049
- *
4050
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
4051
- */
4052
- start(): void;
4053
- get onmessage(): any | null;
4054
- set onmessage(value: any | null);
4055
- }
4056
- /**
4057
- * The **`MessageChannel`** interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.
4058
- *
4059
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
4060
- */
4061
- declare class MessageChannel {
4062
- constructor();
4063
- /**
4064
- * The **`port1`** read-only property of the MessageChannel interface returns the first port of the message channel — the port attached to the context that originated the channel.
4065
- *
4066
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
4067
- */
4068
- readonly port1: MessagePort;
4069
- /**
4070
- * The **`port2`** read-only property of the MessageChannel interface returns the second port of the message channel — the port attached to the context at the other end of the channel, which the message is initially sent to.
4071
- *
4072
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
4073
- */
4074
- readonly port2: MessagePort;
4075
- }
4076
- interface MessagePortPostMessageOptions {
4077
- transfer?: any[];
4078
- }
4079
4018
  type LoopbackForExport<
4080
4019
  T extends
4081
4020
  | (new (...args: any[]) => Rpc.EntrypointBranded)
@@ -13554,21 +13493,31 @@ type BrowserRunScriptOptions = {
13554
13493
  lab?: boolean;
13555
13494
  /** Record the browser session. @default false */
13556
13495
  recording?: boolean;
13496
+ /** Run the script on an alternate browser backend. Only the raw CDP client is
13497
+ * supported, and no session is kept open afterwards. Setting `library`,
13498
+ * `keepAlive`, `lab` or `recording` with it returns an HTTP 400 error
13499
+ * response.
13500
+ */
13501
+ browser?: "kitesurf";
13557
13502
  };
13558
- /** Options for `scriptInSession()`. */
13503
+ /** Options for `script()` in an existing browser session. */
13559
13504
  type BrowserRunScriptSessionOptions = {
13505
+ /** Session to run in, such as the `cf-browser-session-id` header returned by
13506
+ * `script()`. The session keeps the launch options it was acquired with.
13507
+ */
13508
+ sessionId: string;
13509
+ /** Page target the script attaches to, such as the `cf-browser-target-id`
13510
+ * header returned by `script()`. Defaults to the session's first page.
13511
+ */
13512
+ targetId?: string;
13560
13513
  /** Library whose objects are passed to the script. Omit it for raw CDP. */
13561
13514
  library?: BrowserRunScriptLibrary;
13562
13515
  /** Maximum run time of the script in milliseconds. Between 1 and 120000.
13563
13516
  * @default 60000
13564
13517
  */
13565
13518
  timeout?: number;
13566
- /** Page target the script attaches to, such as the `cf-browser-target-id`
13567
- * header returned by `script()`. Defaults to the session's first page.
13568
- */
13569
- targetId?: string;
13570
13519
  };
13571
- /** JSON success body of `script()` and `scriptInSession()`. */
13520
+ /** JSON success body of `script()`. */
13572
13521
  type BrowserRunScriptSuccessResponse = {
13573
13522
  success: true;
13574
13523
  /** The script's return value, or `null` when it returned nothing. */
@@ -13793,7 +13742,7 @@ declare abstract class BrowserRun {
13793
13742
  * @param code - Source of an async function. It receives the selected
13794
13743
  * library's objects (Playwright `{ page, context, browser }`, Puppeteer
13795
13744
  * `{ page, browser }`) or, without `library`, a CDP client.
13796
- * @param options - Library, timeout and session launch options.
13745
+ * @param options - Library, timeout, session launch and backend options.
13797
13746
  * @returns A `Response` containing one of:
13798
13747
  *
13799
13748
  * **Success (HTTP 200):**
@@ -13803,26 +13752,28 @@ declare abstract class BrowserRun {
13803
13752
  * non-JSON output
13804
13753
  *
13805
13754
  * **Error:**
13806
- * - JSON error body with an HTTP status code (400, 404, 408, 422, 429, 500, 503)
13755
+ * - JSON error body with an HTTP status code (400, 404, 408, 422, 429, 500, 502, 503)
13807
13756
  * - HTTP 408 when the script exceeds `timeout`
13808
13757
  * - HTTP 422 when the script fails to compile or throws
13758
+ * - HTTP 502 when the script fails on the `browser: 'kitesurf'` backend
13809
13759
  * - HTTP errors are returned as a `Response`, not thrown. Invalid `options`
13810
13760
  * throw before any request is made.
13811
13761
  *
13812
- * **Headers:**
13813
- * - `cf-browser-session-id`: Session kept open for `scriptInSession()`
13762
+ * **Headers** (not returned with `browser: 'kitesurf'`):
13763
+ * - `cf-browser-session-id`: Session kept open for a later `script()` call
13764
+ * with `sessionId`
13814
13765
  * - `cf-browser-target-id`: Page target the script ran on
13815
13766
  * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
13816
13767
  */
13817
13768
  script(code: string, options?: BrowserRunScriptOptions): Promise<Response>;
13818
13769
  /**
13819
13770
  * Run a script against an existing browser session, such as one kept open by
13820
- * `script()`.
13821
- * @param sessionId - Session to run in, such as the `cf-browser-session-id`
13822
- * header returned by `script()`.
13823
- * @param code - Source of an async function, as for `script()`.
13824
- * @param options - Library, timeout and page target options.
13825
- * @returns A `Response` with the same success bodies as `script()`.
13771
+ * an earlier `script()` call.
13772
+ * @param code - Source of an async function, as for a new session.
13773
+ * @param options - The session to run in, plus page target, library and
13774
+ * timeout options. Launch options such as `keepAlive` cannot be set, because
13775
+ * the session keeps the ones it was acquired with.
13776
+ * @returns A `Response` with the same success bodies as a new-session run.
13826
13777
  *
13827
13778
  * **Error:**
13828
13779
  * - JSON error body with an HTTP status code (400, 401, 404, 408, 410, 422, 500)
@@ -13834,10 +13785,9 @@ declare abstract class BrowserRun {
13834
13785
  * **Headers:**
13835
13786
  * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
13836
13787
  */
13837
- scriptInSession(
13838
- sessionId: string,
13788
+ script(
13839
13789
  code: string,
13840
- options?: BrowserRunScriptSessionOptions,
13790
+ options: BrowserRunScriptSessionOptions,
13841
13791
  ): Promise<Response>;
13842
13792
  /** DevTools JSON methods exposed through one nested binding target. */
13843
13793
  get devtools(): BrowserRunDevtools;
@@ -16167,6 +16117,62 @@ interface MediaError extends Error {
16167
16117
  readonly message: string;
16168
16118
  readonly stack?: string;
16169
16119
  }
16120
+ // MessageChannel and MessagePort, declared at every compatibility date. They
16121
+ // are globals under the expose_global_message_channel compatibility flag (the
16122
+ // default from 2025-08-15); node:worker_threads exports them at any date.
16123
+ /**
16124
+ * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
16125
+ *
16126
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
16127
+ */
16128
+ declare abstract class MessagePort extends EventTarget {
16129
+ /**
16130
+ * The **`postMessage()`** method of the MessagePort interface sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.
16131
+ *
16132
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
16133
+ */
16134
+ postMessage(
16135
+ data?: any,
16136
+ options?: any[] | MessagePortPostMessageOptions,
16137
+ ): void;
16138
+ /**
16139
+ * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active. This stops the flow of messages to that port.
16140
+ *
16141
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
16142
+ */
16143
+ close(): void;
16144
+ /**
16145
+ * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port. This method is only needed when using EventTarget.addEventListener; it is implied when using onmessage.
16146
+ *
16147
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
16148
+ */
16149
+ start(): void;
16150
+ get onmessage(): any | null;
16151
+ set onmessage(value: any | null);
16152
+ }
16153
+ /**
16154
+ * The **`MessageChannel`** interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.
16155
+ *
16156
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
16157
+ */
16158
+ declare class MessageChannel {
16159
+ constructor();
16160
+ /**
16161
+ * The **`port1`** read-only property of the MessageChannel interface returns the first port of the message channel — the port attached to the context that originated the channel.
16162
+ *
16163
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
16164
+ */
16165
+ readonly port1: MessagePort;
16166
+ /**
16167
+ * The **`port2`** read-only property of the MessageChannel interface returns the second port of the message channel — the port attached to the context at the other end of the channel, which the message is initially sent to.
16168
+ *
16169
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
16170
+ */
16171
+ readonly port2: MessagePort;
16172
+ }
16173
+ interface MessagePortPostMessageOptions {
16174
+ transfer?: any[];
16175
+ }
16170
16176
  declare module "cloudflare:node" {
16171
16177
  interface NodeStyleServer {
16172
16178
  listen(...args: unknown[]): this;
@@ -17587,6 +17593,17 @@ interface AlreadyUploadedError extends StreamError {
17587
17593
  interface TooManyWatermarksError extends StreamError {
17588
17594
  name: "TooManyWatermarksError";
17589
17595
  }
17596
+ interface StructuredSerializeOptions {
17597
+ transfer?: any[];
17598
+ }
17599
+ interface ServiceWorkerGlobalScope {
17600
+ structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
17601
+ }
17602
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
17603
+ declare function structuredClone<T>(
17604
+ value: T,
17605
+ options?: StructuredSerializeOptions,
17606
+ ): T;
17590
17607
  type MarkdownDocument = {
17591
17608
  name: string;
17592
17609
  blob: Blob;
@@ -252,7 +252,6 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
252
252
  ): number;
253
253
  clearInterval(timeoutId: number | null): void;
254
254
  queueMicrotask(task: Function): void;
255
- structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
256
255
  reportError(error: any): void;
257
256
  fetch(
258
257
  input: RequestInfo | URL,
@@ -284,8 +283,6 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
284
283
  ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
285
284
  CountQueuingStrategy: typeof CountQueuingStrategy;
286
285
  ErrorEvent: typeof ErrorEvent;
287
- MessageChannel: typeof MessageChannel;
288
- MessagePort: typeof MessagePort;
289
286
  FileSystemHandle: typeof FileSystemHandle;
290
287
  FileSystemFileHandle: typeof FileSystemFileHandle;
291
288
  FileSystemDirectoryHandle: typeof FileSystemDirectoryHandle;
@@ -336,6 +333,8 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
336
333
  PerformanceResourceTiming: typeof PerformanceResourceTiming;
337
334
  PerformanceObserver: typeof PerformanceObserver;
338
335
  PerformanceObserverEntryList: typeof PerformanceObserverEntryList;
336
+ MessageChannel: typeof MessageChannel;
337
+ MessagePort: typeof MessagePort;
339
338
  }
340
339
  export declare function addEventListener<
341
340
  Type extends keyof WorkerGlobalScopeEventMap,
@@ -391,11 +390,6 @@ export declare function setInterval<Args extends any[]>(
391
390
  export declare function clearInterval(timeoutId: number | null): void;
392
391
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
393
392
  export declare function queueMicrotask(task: Function): void;
394
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
395
- export declare function structuredClone<T>(
396
- value: T,
397
- options?: StructuredSerializeOptions,
398
- ): T;
399
393
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
400
394
  export declare function reportError(error: any): void;
401
395
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
@@ -519,9 +513,6 @@ export interface ExportedHandler<
519
513
  email?: EmailExportedHandler<Env, Props>;
520
514
  queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage, Props>;
521
515
  }
522
- export interface StructuredSerializeOptions {
523
- transfer?: any[];
524
- }
525
516
  export declare abstract class Navigator {
526
517
  sendBeacon(url: string, body?: BodyInit): boolean;
527
518
  readonly userAgent: string;
@@ -3669,6 +3660,7 @@ export interface Socket {
3669
3660
  close(): Promise<void>;
3670
3661
  startTls(options?: TlsOptions): Socket;
3671
3662
  proxyTo(sock: Socket, options?: StreamPipeOptions): Promise<void>;
3663
+ accept(): void;
3672
3664
  }
3673
3665
  export interface SocketOptions {
3674
3666
  secureTransport?: string;
@@ -4029,59 +4021,6 @@ export interface FileSystemFileWriteParams {
4029
4021
  export interface FileSystemHandleRemoveOptions {
4030
4022
  recursive?: boolean;
4031
4023
  }
4032
- /**
4033
- * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
4034
- *
4035
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
4036
- */
4037
- export declare abstract class MessagePort extends EventTarget {
4038
- /**
4039
- * The **`postMessage()`** method of the MessagePort interface sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.
4040
- *
4041
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
4042
- */
4043
- postMessage(
4044
- data?: any,
4045
- options?: any[] | MessagePortPostMessageOptions,
4046
- ): void;
4047
- /**
4048
- * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active. This stops the flow of messages to that port.
4049
- *
4050
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
4051
- */
4052
- close(): void;
4053
- /**
4054
- * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port. This method is only needed when using EventTarget.addEventListener; it is implied when using onmessage.
4055
- *
4056
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
4057
- */
4058
- start(): void;
4059
- get onmessage(): any | null;
4060
- set onmessage(value: any | null);
4061
- }
4062
- /**
4063
- * The **`MessageChannel`** interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.
4064
- *
4065
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
4066
- */
4067
- export declare class MessageChannel {
4068
- constructor();
4069
- /**
4070
- * The **`port1`** read-only property of the MessageChannel interface returns the first port of the message channel — the port attached to the context that originated the channel.
4071
- *
4072
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
4073
- */
4074
- readonly port1: MessagePort;
4075
- /**
4076
- * The **`port2`** read-only property of the MessageChannel interface returns the second port of the message channel — the port attached to the context at the other end of the channel, which the message is initially sent to.
4077
- *
4078
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
4079
- */
4080
- readonly port2: MessagePort;
4081
- }
4082
- export interface MessagePortPostMessageOptions {
4083
- transfer?: any[];
4084
- }
4085
4024
  export type LoopbackForExport<
4086
4025
  T extends
4087
4026
  | (new (...args: any[]) => Rpc.EntrypointBranded)
@@ -13569,21 +13508,31 @@ export type BrowserRunScriptOptions = {
13569
13508
  lab?: boolean;
13570
13509
  /** Record the browser session. @default false */
13571
13510
  recording?: boolean;
13511
+ /** Run the script on an alternate browser backend. Only the raw CDP client is
13512
+ * supported, and no session is kept open afterwards. Setting `library`,
13513
+ * `keepAlive`, `lab` or `recording` with it returns an HTTP 400 error
13514
+ * response.
13515
+ */
13516
+ browser?: "kitesurf";
13572
13517
  };
13573
- /** Options for `scriptInSession()`. */
13518
+ /** Options for `script()` in an existing browser session. */
13574
13519
  export type BrowserRunScriptSessionOptions = {
13520
+ /** Session to run in, such as the `cf-browser-session-id` header returned by
13521
+ * `script()`. The session keeps the launch options it was acquired with.
13522
+ */
13523
+ sessionId: string;
13524
+ /** Page target the script attaches to, such as the `cf-browser-target-id`
13525
+ * header returned by `script()`. Defaults to the session's first page.
13526
+ */
13527
+ targetId?: string;
13575
13528
  /** Library whose objects are passed to the script. Omit it for raw CDP. */
13576
13529
  library?: BrowserRunScriptLibrary;
13577
13530
  /** Maximum run time of the script in milliseconds. Between 1 and 120000.
13578
13531
  * @default 60000
13579
13532
  */
13580
13533
  timeout?: number;
13581
- /** Page target the script attaches to, such as the `cf-browser-target-id`
13582
- * header returned by `script()`. Defaults to the session's first page.
13583
- */
13584
- targetId?: string;
13585
13534
  };
13586
- /** JSON success body of `script()` and `scriptInSession()`. */
13535
+ /** JSON success body of `script()`. */
13587
13536
  export type BrowserRunScriptSuccessResponse = {
13588
13537
  success: true;
13589
13538
  /** The script's return value, or `null` when it returned nothing. */
@@ -13808,7 +13757,7 @@ export declare abstract class BrowserRun {
13808
13757
  * @param code - Source of an async function. It receives the selected
13809
13758
  * library's objects (Playwright `{ page, context, browser }`, Puppeteer
13810
13759
  * `{ page, browser }`) or, without `library`, a CDP client.
13811
- * @param options - Library, timeout and session launch options.
13760
+ * @param options - Library, timeout, session launch and backend options.
13812
13761
  * @returns A `Response` containing one of:
13813
13762
  *
13814
13763
  * **Success (HTTP 200):**
@@ -13818,26 +13767,28 @@ export declare abstract class BrowserRun {
13818
13767
  * non-JSON output
13819
13768
  *
13820
13769
  * **Error:**
13821
- * - JSON error body with an HTTP status code (400, 404, 408, 422, 429, 500, 503)
13770
+ * - JSON error body with an HTTP status code (400, 404, 408, 422, 429, 500, 502, 503)
13822
13771
  * - HTTP 408 when the script exceeds `timeout`
13823
13772
  * - HTTP 422 when the script fails to compile or throws
13773
+ * - HTTP 502 when the script fails on the `browser: 'kitesurf'` backend
13824
13774
  * - HTTP errors are returned as a `Response`, not thrown. Invalid `options`
13825
13775
  * throw before any request is made.
13826
13776
  *
13827
- * **Headers:**
13828
- * - `cf-browser-session-id`: Session kept open for `scriptInSession()`
13777
+ * **Headers** (not returned with `browser: 'kitesurf'`):
13778
+ * - `cf-browser-session-id`: Session kept open for a later `script()` call
13779
+ * with `sessionId`
13829
13780
  * - `cf-browser-target-id`: Page target the script ran on
13830
13781
  * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
13831
13782
  */
13832
13783
  script(code: string, options?: BrowserRunScriptOptions): Promise<Response>;
13833
13784
  /**
13834
13785
  * Run a script against an existing browser session, such as one kept open by
13835
- * `script()`.
13836
- * @param sessionId - Session to run in, such as the `cf-browser-session-id`
13837
- * header returned by `script()`.
13838
- * @param code - Source of an async function, as for `script()`.
13839
- * @param options - Library, timeout and page target options.
13840
- * @returns A `Response` with the same success bodies as `script()`.
13786
+ * an earlier `script()` call.
13787
+ * @param code - Source of an async function, as for a new session.
13788
+ * @param options - The session to run in, plus page target, library and
13789
+ * timeout options. Launch options such as `keepAlive` cannot be set, because
13790
+ * the session keeps the ones it was acquired with.
13791
+ * @returns A `Response` with the same success bodies as a new-session run.
13841
13792
  *
13842
13793
  * **Error:**
13843
13794
  * - JSON error body with an HTTP status code (400, 401, 404, 408, 410, 422, 500)
@@ -13849,10 +13800,9 @@ export declare abstract class BrowserRun {
13849
13800
  * **Headers:**
13850
13801
  * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
13851
13802
  */
13852
- scriptInSession(
13853
- sessionId: string,
13803
+ script(
13854
13804
  code: string,
13855
- options?: BrowserRunScriptSessionOptions,
13805
+ options: BrowserRunScriptSessionOptions,
13856
13806
  ): Promise<Response>;
13857
13807
  /** DevTools JSON methods exposed through one nested binding target. */
13858
13808
  get devtools(): BrowserRunDevtools;
@@ -16156,6 +16106,62 @@ export interface MediaError extends Error {
16156
16106
  readonly message: string;
16157
16107
  readonly stack?: string;
16158
16108
  }
16109
+ // MessageChannel and MessagePort, declared at every compatibility date. They
16110
+ // are globals under the expose_global_message_channel compatibility flag (the
16111
+ // default from 2025-08-15); node:worker_threads exports them at any date.
16112
+ /**
16113
+ * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
16114
+ *
16115
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
16116
+ */
16117
+ export declare abstract class MessagePort extends EventTarget {
16118
+ /**
16119
+ * The **`postMessage()`** method of the MessagePort interface sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.
16120
+ *
16121
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
16122
+ */
16123
+ postMessage(
16124
+ data?: any,
16125
+ options?: any[] | MessagePortPostMessageOptions,
16126
+ ): void;
16127
+ /**
16128
+ * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active. This stops the flow of messages to that port.
16129
+ *
16130
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
16131
+ */
16132
+ close(): void;
16133
+ /**
16134
+ * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port. This method is only needed when using EventTarget.addEventListener; it is implied when using onmessage.
16135
+ *
16136
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
16137
+ */
16138
+ start(): void;
16139
+ get onmessage(): any | null;
16140
+ set onmessage(value: any | null);
16141
+ }
16142
+ /**
16143
+ * The **`MessageChannel`** interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.
16144
+ *
16145
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
16146
+ */
16147
+ export declare class MessageChannel {
16148
+ constructor();
16149
+ /**
16150
+ * The **`port1`** read-only property of the MessageChannel interface returns the first port of the message channel — the port attached to the context that originated the channel.
16151
+ *
16152
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
16153
+ */
16154
+ readonly port1: MessagePort;
16155
+ /**
16156
+ * The **`port2`** read-only property of the MessageChannel interface returns the second port of the message channel — the port attached to the context at the other end of the channel, which the message is initially sent to.
16157
+ *
16158
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
16159
+ */
16160
+ readonly port2: MessagePort;
16161
+ }
16162
+ export interface MessagePortPostMessageOptions {
16163
+ transfer?: any[];
16164
+ }
16159
16165
  export type Params<P extends string = any> = Record<P, string | string[]>;
16160
16166
  export type EventContext<Env, P extends string, Data> = {
16161
16167
  request: Request<unknown, IncomingRequestCfProperties<unknown>>;
@@ -17487,6 +17493,17 @@ export interface AlreadyUploadedError extends StreamError {
17487
17493
  export interface TooManyWatermarksError extends StreamError {
17488
17494
  name: "TooManyWatermarksError";
17489
17495
  }
17496
+ export interface StructuredSerializeOptions {
17497
+ transfer?: any[];
17498
+ }
17499
+ export interface ServiceWorkerGlobalScope {
17500
+ structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
17501
+ }
17502
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
17503
+ export declare function structuredClone<T>(
17504
+ value: T,
17505
+ options?: StructuredSerializeOptions,
17506
+ ): T;
17490
17507
  export type MarkdownDocument = {
17491
17508
  name: string;
17492
17509
  blob: Blob;
package/index.d.ts CHANGED
@@ -251,7 +251,6 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
251
251
  ): number;
252
252
  clearInterval(timeoutId: number | null): void;
253
253
  queueMicrotask(task: Function): void;
254
- structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
255
254
  reportError(error: any): void;
256
255
  fetch(
257
256
  input: RequestInfo | URL,
@@ -283,8 +282,6 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
283
282
  ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
284
283
  CountQueuingStrategy: typeof CountQueuingStrategy;
285
284
  ErrorEvent: typeof ErrorEvent;
286
- MessageChannel: typeof MessageChannel;
287
- MessagePort: typeof MessagePort;
288
285
  EventSource: typeof EventSource;
289
286
  ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
290
287
  ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
@@ -337,6 +334,8 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
337
334
  PerformanceResourceTiming: typeof PerformanceResourceTiming;
338
335
  PerformanceObserver: typeof PerformanceObserver;
339
336
  PerformanceObserverEntryList: typeof PerformanceObserverEntryList;
337
+ MessageChannel: typeof MessageChannel;
338
+ MessagePort: typeof MessagePort;
340
339
  }
341
340
  declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(
342
341
  type: Type,
@@ -390,11 +389,6 @@ declare function setInterval<Args extends any[]>(
390
389
  declare function clearInterval(timeoutId: number | null): void;
391
390
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
392
391
  declare function queueMicrotask(task: Function): void;
393
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
394
- declare function structuredClone<T>(
395
- value: T,
396
- options?: StructuredSerializeOptions,
397
- ): T;
398
392
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
399
393
  declare function reportError(error: any): void;
400
394
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
@@ -517,9 +511,6 @@ interface ExportedHandler<
517
511
  email?: EmailExportedHandler<Env, Props>;
518
512
  queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage, Props>;
519
513
  }
520
- interface StructuredSerializeOptions {
521
- transfer?: any[];
522
- }
523
514
  declare abstract class Navigator {
524
515
  sendBeacon(url: string, body?: BodyInit): boolean;
525
516
  readonly userAgent: string;
@@ -3666,59 +3657,6 @@ interface ContainerStartResources {
3666
3657
  memoryMib: number;
3667
3658
  diskMb: number;
3668
3659
  }
3669
- /**
3670
- * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
3671
- *
3672
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
3673
- */
3674
- declare abstract class MessagePort extends EventTarget {
3675
- /**
3676
- * The **`postMessage()`** method of the MessagePort interface sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.
3677
- *
3678
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
3679
- */
3680
- postMessage(
3681
- data?: any,
3682
- options?: any[] | MessagePortPostMessageOptions,
3683
- ): void;
3684
- /**
3685
- * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active. This stops the flow of messages to that port.
3686
- *
3687
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
3688
- */
3689
- close(): void;
3690
- /**
3691
- * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port. This method is only needed when using EventTarget.addEventListener; it is implied when using onmessage.
3692
- *
3693
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
3694
- */
3695
- start(): void;
3696
- get onmessage(): any | null;
3697
- set onmessage(value: any | null);
3698
- }
3699
- /**
3700
- * The **`MessageChannel`** interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.
3701
- *
3702
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
3703
- */
3704
- declare class MessageChannel {
3705
- constructor();
3706
- /**
3707
- * The **`port1`** read-only property of the MessageChannel interface returns the first port of the message channel — the port attached to the context that originated the channel.
3708
- *
3709
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
3710
- */
3711
- readonly port1: MessagePort;
3712
- /**
3713
- * The **`port2`** read-only property of the MessageChannel interface returns the second port of the message channel — the port attached to the context at the other end of the channel, which the message is initially sent to.
3714
- *
3715
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
3716
- */
3717
- readonly port2: MessagePort;
3718
- }
3719
- interface MessagePortPostMessageOptions {
3720
- transfer?: any[];
3721
- }
3722
3660
  type LoopbackForExport<
3723
3661
  T extends
3724
3662
  | (new (...args: any[]) => Rpc.EntrypointBranded)
@@ -13187,21 +13125,31 @@ type BrowserRunScriptOptions = {
13187
13125
  lab?: boolean;
13188
13126
  /** Record the browser session. @default false */
13189
13127
  recording?: boolean;
13128
+ /** Run the script on an alternate browser backend. Only the raw CDP client is
13129
+ * supported, and no session is kept open afterwards. Setting `library`,
13130
+ * `keepAlive`, `lab` or `recording` with it returns an HTTP 400 error
13131
+ * response.
13132
+ */
13133
+ browser?: "kitesurf";
13190
13134
  };
13191
- /** Options for `scriptInSession()`. */
13135
+ /** Options for `script()` in an existing browser session. */
13192
13136
  type BrowserRunScriptSessionOptions = {
13137
+ /** Session to run in, such as the `cf-browser-session-id` header returned by
13138
+ * `script()`. The session keeps the launch options it was acquired with.
13139
+ */
13140
+ sessionId: string;
13141
+ /** Page target the script attaches to, such as the `cf-browser-target-id`
13142
+ * header returned by `script()`. Defaults to the session's first page.
13143
+ */
13144
+ targetId?: string;
13193
13145
  /** Library whose objects are passed to the script. Omit it for raw CDP. */
13194
13146
  library?: BrowserRunScriptLibrary;
13195
13147
  /** Maximum run time of the script in milliseconds. Between 1 and 120000.
13196
13148
  * @default 60000
13197
13149
  */
13198
13150
  timeout?: number;
13199
- /** Page target the script attaches to, such as the `cf-browser-target-id`
13200
- * header returned by `script()`. Defaults to the session's first page.
13201
- */
13202
- targetId?: string;
13203
13151
  };
13204
- /** JSON success body of `script()` and `scriptInSession()`. */
13152
+ /** JSON success body of `script()`. */
13205
13153
  type BrowserRunScriptSuccessResponse = {
13206
13154
  success: true;
13207
13155
  /** The script's return value, or `null` when it returned nothing. */
@@ -13426,7 +13374,7 @@ declare abstract class BrowserRun {
13426
13374
  * @param code - Source of an async function. It receives the selected
13427
13375
  * library's objects (Playwright `{ page, context, browser }`, Puppeteer
13428
13376
  * `{ page, browser }`) or, without `library`, a CDP client.
13429
- * @param options - Library, timeout and session launch options.
13377
+ * @param options - Library, timeout, session launch and backend options.
13430
13378
  * @returns A `Response` containing one of:
13431
13379
  *
13432
13380
  * **Success (HTTP 200):**
@@ -13436,26 +13384,28 @@ declare abstract class BrowserRun {
13436
13384
  * non-JSON output
13437
13385
  *
13438
13386
  * **Error:**
13439
- * - JSON error body with an HTTP status code (400, 404, 408, 422, 429, 500, 503)
13387
+ * - JSON error body with an HTTP status code (400, 404, 408, 422, 429, 500, 502, 503)
13440
13388
  * - HTTP 408 when the script exceeds `timeout`
13441
13389
  * - HTTP 422 when the script fails to compile or throws
13390
+ * - HTTP 502 when the script fails on the `browser: 'kitesurf'` backend
13442
13391
  * - HTTP errors are returned as a `Response`, not thrown. Invalid `options`
13443
13392
  * throw before any request is made.
13444
13393
  *
13445
- * **Headers:**
13446
- * - `cf-browser-session-id`: Session kept open for `scriptInSession()`
13394
+ * **Headers** (not returned with `browser: 'kitesurf'`):
13395
+ * - `cf-browser-session-id`: Session kept open for a later `script()` call
13396
+ * with `sessionId`
13447
13397
  * - `cf-browser-target-id`: Page target the script ran on
13448
13398
  * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
13449
13399
  */
13450
13400
  script(code: string, options?: BrowserRunScriptOptions): Promise<Response>;
13451
13401
  /**
13452
13402
  * Run a script against an existing browser session, such as one kept open by
13453
- * `script()`.
13454
- * @param sessionId - Session to run in, such as the `cf-browser-session-id`
13455
- * header returned by `script()`.
13456
- * @param code - Source of an async function, as for `script()`.
13457
- * @param options - Library, timeout and page target options.
13458
- * @returns A `Response` with the same success bodies as `script()`.
13403
+ * an earlier `script()` call.
13404
+ * @param code - Source of an async function, as for a new session.
13405
+ * @param options - The session to run in, plus page target, library and
13406
+ * timeout options. Launch options such as `keepAlive` cannot be set, because
13407
+ * the session keeps the ones it was acquired with.
13408
+ * @returns A `Response` with the same success bodies as a new-session run.
13459
13409
  *
13460
13410
  * **Error:**
13461
13411
  * - JSON error body with an HTTP status code (400, 401, 404, 408, 410, 422, 500)
@@ -13467,10 +13417,9 @@ declare abstract class BrowserRun {
13467
13417
  * **Headers:**
13468
13418
  * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
13469
13419
  */
13470
- scriptInSession(
13471
- sessionId: string,
13420
+ script(
13472
13421
  code: string,
13473
- options?: BrowserRunScriptSessionOptions,
13422
+ options: BrowserRunScriptSessionOptions,
13474
13423
  ): Promise<Response>;
13475
13424
  /** DevTools JSON methods exposed through one nested binding target. */
13476
13425
  get devtools(): BrowserRunDevtools;
@@ -15800,6 +15749,62 @@ interface MediaError extends Error {
15800
15749
  readonly message: string;
15801
15750
  readonly stack?: string;
15802
15751
  }
15752
+ // MessageChannel and MessagePort, declared at every compatibility date. They
15753
+ // are globals under the expose_global_message_channel compatibility flag (the
15754
+ // default from 2025-08-15); node:worker_threads exports them at any date.
15755
+ /**
15756
+ * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
15757
+ *
15758
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
15759
+ */
15760
+ declare abstract class MessagePort extends EventTarget {
15761
+ /**
15762
+ * The **`postMessage()`** method of the MessagePort interface sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.
15763
+ *
15764
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
15765
+ */
15766
+ postMessage(
15767
+ data?: any,
15768
+ options?: any[] | MessagePortPostMessageOptions,
15769
+ ): void;
15770
+ /**
15771
+ * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active. This stops the flow of messages to that port.
15772
+ *
15773
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
15774
+ */
15775
+ close(): void;
15776
+ /**
15777
+ * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port. This method is only needed when using EventTarget.addEventListener; it is implied when using onmessage.
15778
+ *
15779
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
15780
+ */
15781
+ start(): void;
15782
+ get onmessage(): any | null;
15783
+ set onmessage(value: any | null);
15784
+ }
15785
+ /**
15786
+ * The **`MessageChannel`** interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.
15787
+ *
15788
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
15789
+ */
15790
+ declare class MessageChannel {
15791
+ constructor();
15792
+ /**
15793
+ * The **`port1`** read-only property of the MessageChannel interface returns the first port of the message channel — the port attached to the context that originated the channel.
15794
+ *
15795
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
15796
+ */
15797
+ readonly port1: MessagePort;
15798
+ /**
15799
+ * The **`port2`** read-only property of the MessageChannel interface returns the second port of the message channel — the port attached to the context at the other end of the channel, which the message is initially sent to.
15800
+ *
15801
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
15802
+ */
15803
+ readonly port2: MessagePort;
15804
+ }
15805
+ interface MessagePortPostMessageOptions {
15806
+ transfer?: any[];
15807
+ }
15803
15808
  declare module "cloudflare:node" {
15804
15809
  interface NodeStyleServer {
15805
15810
  listen(...args: unknown[]): this;
@@ -17220,6 +17225,17 @@ interface AlreadyUploadedError extends StreamError {
17220
17225
  interface TooManyWatermarksError extends StreamError {
17221
17226
  name: "TooManyWatermarksError";
17222
17227
  }
17228
+ interface StructuredSerializeOptions {
17229
+ transfer?: any[];
17230
+ }
17231
+ interface ServiceWorkerGlobalScope {
17232
+ structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
17233
+ }
17234
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
17235
+ declare function structuredClone<T>(
17236
+ value: T,
17237
+ options?: StructuredSerializeOptions,
17238
+ ): T;
17223
17239
  type MarkdownDocument = {
17224
17240
  name: string;
17225
17241
  blob: Blob;
package/index.ts CHANGED
@@ -251,7 +251,6 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
251
251
  ): number;
252
252
  clearInterval(timeoutId: number | null): void;
253
253
  queueMicrotask(task: Function): void;
254
- structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
255
254
  reportError(error: any): void;
256
255
  fetch(
257
256
  input: RequestInfo | URL,
@@ -283,8 +282,6 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
283
282
  ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
284
283
  CountQueuingStrategy: typeof CountQueuingStrategy;
285
284
  ErrorEvent: typeof ErrorEvent;
286
- MessageChannel: typeof MessageChannel;
287
- MessagePort: typeof MessagePort;
288
285
  EventSource: typeof EventSource;
289
286
  ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
290
287
  ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
@@ -337,6 +334,8 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
337
334
  PerformanceResourceTiming: typeof PerformanceResourceTiming;
338
335
  PerformanceObserver: typeof PerformanceObserver;
339
336
  PerformanceObserverEntryList: typeof PerformanceObserverEntryList;
337
+ MessageChannel: typeof MessageChannel;
338
+ MessagePort: typeof MessagePort;
340
339
  }
341
340
  export declare function addEventListener<
342
341
  Type extends keyof WorkerGlobalScopeEventMap,
@@ -392,11 +391,6 @@ export declare function setInterval<Args extends any[]>(
392
391
  export declare function clearInterval(timeoutId: number | null): void;
393
392
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
394
393
  export declare function queueMicrotask(task: Function): void;
395
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
396
- export declare function structuredClone<T>(
397
- value: T,
398
- options?: StructuredSerializeOptions,
399
- ): T;
400
394
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
401
395
  export declare function reportError(error: any): void;
402
396
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
@@ -519,9 +513,6 @@ export interface ExportedHandler<
519
513
  email?: EmailExportedHandler<Env, Props>;
520
514
  queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage, Props>;
521
515
  }
522
- export interface StructuredSerializeOptions {
523
- transfer?: any[];
524
- }
525
516
  export declare abstract class Navigator {
526
517
  sendBeacon(url: string, body?: BodyInit): boolean;
527
518
  readonly userAgent: string;
@@ -3675,59 +3666,6 @@ export interface ContainerStartResources {
3675
3666
  memoryMib: number;
3676
3667
  diskMb: number;
3677
3668
  }
3678
- /**
3679
- * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
3680
- *
3681
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
3682
- */
3683
- export declare abstract class MessagePort extends EventTarget {
3684
- /**
3685
- * The **`postMessage()`** method of the MessagePort interface sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.
3686
- *
3687
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
3688
- */
3689
- postMessage(
3690
- data?: any,
3691
- options?: any[] | MessagePortPostMessageOptions,
3692
- ): void;
3693
- /**
3694
- * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active. This stops the flow of messages to that port.
3695
- *
3696
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
3697
- */
3698
- close(): void;
3699
- /**
3700
- * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port. This method is only needed when using EventTarget.addEventListener; it is implied when using onmessage.
3701
- *
3702
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
3703
- */
3704
- start(): void;
3705
- get onmessage(): any | null;
3706
- set onmessage(value: any | null);
3707
- }
3708
- /**
3709
- * The **`MessageChannel`** interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.
3710
- *
3711
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
3712
- */
3713
- export declare class MessageChannel {
3714
- constructor();
3715
- /**
3716
- * The **`port1`** read-only property of the MessageChannel interface returns the first port of the message channel — the port attached to the context that originated the channel.
3717
- *
3718
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
3719
- */
3720
- readonly port1: MessagePort;
3721
- /**
3722
- * The **`port2`** read-only property of the MessageChannel interface returns the second port of the message channel — the port attached to the context at the other end of the channel, which the message is initially sent to.
3723
- *
3724
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
3725
- */
3726
- readonly port2: MessagePort;
3727
- }
3728
- export interface MessagePortPostMessageOptions {
3729
- transfer?: any[];
3730
- }
3731
3669
  export type LoopbackForExport<
3732
3670
  T extends
3733
3671
  | (new (...args: any[]) => Rpc.EntrypointBranded)
@@ -13205,21 +13143,31 @@ export type BrowserRunScriptOptions = {
13205
13143
  lab?: boolean;
13206
13144
  /** Record the browser session. @default false */
13207
13145
  recording?: boolean;
13146
+ /** Run the script on an alternate browser backend. Only the raw CDP client is
13147
+ * supported, and no session is kept open afterwards. Setting `library`,
13148
+ * `keepAlive`, `lab` or `recording` with it returns an HTTP 400 error
13149
+ * response.
13150
+ */
13151
+ browser?: "kitesurf";
13208
13152
  };
13209
- /** Options for `scriptInSession()`. */
13153
+ /** Options for `script()` in an existing browser session. */
13210
13154
  export type BrowserRunScriptSessionOptions = {
13155
+ /** Session to run in, such as the `cf-browser-session-id` header returned by
13156
+ * `script()`. The session keeps the launch options it was acquired with.
13157
+ */
13158
+ sessionId: string;
13159
+ /** Page target the script attaches to, such as the `cf-browser-target-id`
13160
+ * header returned by `script()`. Defaults to the session's first page.
13161
+ */
13162
+ targetId?: string;
13211
13163
  /** Library whose objects are passed to the script. Omit it for raw CDP. */
13212
13164
  library?: BrowserRunScriptLibrary;
13213
13165
  /** Maximum run time of the script in milliseconds. Between 1 and 120000.
13214
13166
  * @default 60000
13215
13167
  */
13216
13168
  timeout?: number;
13217
- /** Page target the script attaches to, such as the `cf-browser-target-id`
13218
- * header returned by `script()`. Defaults to the session's first page.
13219
- */
13220
- targetId?: string;
13221
13169
  };
13222
- /** JSON success body of `script()` and `scriptInSession()`. */
13170
+ /** JSON success body of `script()`. */
13223
13171
  export type BrowserRunScriptSuccessResponse = {
13224
13172
  success: true;
13225
13173
  /** The script's return value, or `null` when it returned nothing. */
@@ -13444,7 +13392,7 @@ export declare abstract class BrowserRun {
13444
13392
  * @param code - Source of an async function. It receives the selected
13445
13393
  * library's objects (Playwright `{ page, context, browser }`, Puppeteer
13446
13394
  * `{ page, browser }`) or, without `library`, a CDP client.
13447
- * @param options - Library, timeout and session launch options.
13395
+ * @param options - Library, timeout, session launch and backend options.
13448
13396
  * @returns A `Response` containing one of:
13449
13397
  *
13450
13398
  * **Success (HTTP 200):**
@@ -13454,26 +13402,28 @@ export declare abstract class BrowserRun {
13454
13402
  * non-JSON output
13455
13403
  *
13456
13404
  * **Error:**
13457
- * - JSON error body with an HTTP status code (400, 404, 408, 422, 429, 500, 503)
13405
+ * - JSON error body with an HTTP status code (400, 404, 408, 422, 429, 500, 502, 503)
13458
13406
  * - HTTP 408 when the script exceeds `timeout`
13459
13407
  * - HTTP 422 when the script fails to compile or throws
13408
+ * - HTTP 502 when the script fails on the `browser: 'kitesurf'` backend
13460
13409
  * - HTTP errors are returned as a `Response`, not thrown. Invalid `options`
13461
13410
  * throw before any request is made.
13462
13411
  *
13463
- * **Headers:**
13464
- * - `cf-browser-session-id`: Session kept open for `scriptInSession()`
13412
+ * **Headers** (not returned with `browser: 'kitesurf'`):
13413
+ * - `cf-browser-session-id`: Session kept open for a later `script()` call
13414
+ * with `sessionId`
13465
13415
  * - `cf-browser-target-id`: Page target the script ran on
13466
13416
  * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
13467
13417
  */
13468
13418
  script(code: string, options?: BrowserRunScriptOptions): Promise<Response>;
13469
13419
  /**
13470
13420
  * Run a script against an existing browser session, such as one kept open by
13471
- * `script()`.
13472
- * @param sessionId - Session to run in, such as the `cf-browser-session-id`
13473
- * header returned by `script()`.
13474
- * @param code - Source of an async function, as for `script()`.
13475
- * @param options - Library, timeout and page target options.
13476
- * @returns A `Response` with the same success bodies as `script()`.
13421
+ * an earlier `script()` call.
13422
+ * @param code - Source of an async function, as for a new session.
13423
+ * @param options - The session to run in, plus page target, library and
13424
+ * timeout options. Launch options such as `keepAlive` cannot be set, because
13425
+ * the session keeps the ones it was acquired with.
13426
+ * @returns A `Response` with the same success bodies as a new-session run.
13477
13427
  *
13478
13428
  * **Error:**
13479
13429
  * - JSON error body with an HTTP status code (400, 401, 404, 408, 410, 422, 500)
@@ -13485,10 +13435,9 @@ export declare abstract class BrowserRun {
13485
13435
  * **Headers:**
13486
13436
  * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
13487
13437
  */
13488
- scriptInSession(
13489
- sessionId: string,
13438
+ script(
13490
13439
  code: string,
13491
- options?: BrowserRunScriptSessionOptions,
13440
+ options: BrowserRunScriptSessionOptions,
13492
13441
  ): Promise<Response>;
13493
13442
  /** DevTools JSON methods exposed through one nested binding target. */
13494
13443
  get devtools(): BrowserRunDevtools;
@@ -15792,6 +15741,62 @@ export interface MediaError extends Error {
15792
15741
  readonly message: string;
15793
15742
  readonly stack?: string;
15794
15743
  }
15744
+ // MessageChannel and MessagePort, declared at every compatibility date. They
15745
+ // are globals under the expose_global_message_channel compatibility flag (the
15746
+ // default from 2025-08-15); node:worker_threads exports them at any date.
15747
+ /**
15748
+ * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
15749
+ *
15750
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
15751
+ */
15752
+ export declare abstract class MessagePort extends EventTarget {
15753
+ /**
15754
+ * The **`postMessage()`** method of the MessagePort interface sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.
15755
+ *
15756
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
15757
+ */
15758
+ postMessage(
15759
+ data?: any,
15760
+ options?: any[] | MessagePortPostMessageOptions,
15761
+ ): void;
15762
+ /**
15763
+ * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active. This stops the flow of messages to that port.
15764
+ *
15765
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
15766
+ */
15767
+ close(): void;
15768
+ /**
15769
+ * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port. This method is only needed when using EventTarget.addEventListener; it is implied when using onmessage.
15770
+ *
15771
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
15772
+ */
15773
+ start(): void;
15774
+ get onmessage(): any | null;
15775
+ set onmessage(value: any | null);
15776
+ }
15777
+ /**
15778
+ * The **`MessageChannel`** interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.
15779
+ *
15780
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
15781
+ */
15782
+ export declare class MessageChannel {
15783
+ constructor();
15784
+ /**
15785
+ * The **`port1`** read-only property of the MessageChannel interface returns the first port of the message channel — the port attached to the context that originated the channel.
15786
+ *
15787
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
15788
+ */
15789
+ readonly port1: MessagePort;
15790
+ /**
15791
+ * The **`port2`** read-only property of the MessageChannel interface returns the second port of the message channel — the port attached to the context at the other end of the channel, which the message is initially sent to.
15792
+ *
15793
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
15794
+ */
15795
+ readonly port2: MessagePort;
15796
+ }
15797
+ export interface MessagePortPostMessageOptions {
15798
+ transfer?: any[];
15799
+ }
15795
15800
  export type Params<P extends string = any> = Record<P, string | string[]>;
15796
15801
  export type EventContext<Env, P extends string, Data> = {
15797
15802
  request: Request<unknown, IncomingRequestCfProperties<unknown>>;
@@ -17123,6 +17128,17 @@ export interface AlreadyUploadedError extends StreamError {
17123
17128
  export interface TooManyWatermarksError extends StreamError {
17124
17129
  name: "TooManyWatermarksError";
17125
17130
  }
17131
+ export interface StructuredSerializeOptions {
17132
+ transfer?: any[];
17133
+ }
17134
+ export interface ServiceWorkerGlobalScope {
17135
+ structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
17136
+ }
17137
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
17138
+ export declare function structuredClone<T>(
17139
+ value: T,
17140
+ options?: StructuredSerializeOptions,
17141
+ ): T;
17126
17142
  export type MarkdownDocument = {
17127
17143
  name: string;
17128
17144
  blob: Blob;
package/package.json CHANGED
@@ -7,5 +7,5 @@
7
7
  },
8
8
  "author": "Cloudflare Workers DevProd Team <workers-devprod@cloudflare.com> (https://workers.cloudflare.com)",
9
9
  "license": "MIT OR Apache-2.0",
10
- "version": "5.20261119.1"
10
+ "version": "5.20261120.1"
11
11
  }