@cloudflare/workers-types 5.20261118.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.
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)
@@ -4193,6 +4131,11 @@ interface Tracing {
4193
4131
  ): T;
4194
4132
  Span: typeof Span;
4195
4133
  }
4134
+ interface TracingSpanLink {
4135
+ context: TracingSpanContext;
4136
+ attributes?: Record<string, boolean | number | string | undefined>;
4137
+ droppedAttributesCount?: number;
4138
+ }
4196
4139
  declare abstract class Span {
4197
4140
  get isTraced(): boolean;
4198
4141
  spanContext(): TracingSpanContext;
@@ -4225,6 +4168,8 @@ declare abstract class Span {
4225
4168
  updateName(name: string): this;
4226
4169
  setStatus(status: TracingSpanStatus): this;
4227
4170
  end(): void;
4171
+ addLink(link: TracingSpanLink): this;
4172
+ addLinks(links: readonly TracingSpanLink[]): this;
4228
4173
  }
4229
4174
  type TracingSpanStatusCode = "unset" | "ok" | "error";
4230
4175
  interface TracingSpanStatus {
@@ -13180,21 +13125,31 @@ type BrowserRunScriptOptions = {
13180
13125
  lab?: boolean;
13181
13126
  /** Record the browser session. @default false */
13182
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";
13183
13134
  };
13184
- /** Options for `scriptInSession()`. */
13135
+ /** Options for `script()` in an existing browser session. */
13185
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;
13186
13145
  /** Library whose objects are passed to the script. Omit it for raw CDP. */
13187
13146
  library?: BrowserRunScriptLibrary;
13188
13147
  /** Maximum run time of the script in milliseconds. Between 1 and 120000.
13189
13148
  * @default 60000
13190
13149
  */
13191
13150
  timeout?: number;
13192
- /** Page target the script attaches to, such as the `cf-browser-target-id`
13193
- * header returned by `script()`. Defaults to the session's first page.
13194
- */
13195
- targetId?: string;
13196
13151
  };
13197
- /** JSON success body of `script()` and `scriptInSession()`. */
13152
+ /** JSON success body of `script()`. */
13198
13153
  type BrowserRunScriptSuccessResponse = {
13199
13154
  success: true;
13200
13155
  /** The script's return value, or `null` when it returned nothing. */
@@ -13419,7 +13374,7 @@ declare abstract class BrowserRun {
13419
13374
  * @param code - Source of an async function. It receives the selected
13420
13375
  * library's objects (Playwright `{ page, context, browser }`, Puppeteer
13421
13376
  * `{ page, browser }`) or, without `library`, a CDP client.
13422
- * @param options - Library, timeout and session launch options.
13377
+ * @param options - Library, timeout, session launch and backend options.
13423
13378
  * @returns A `Response` containing one of:
13424
13379
  *
13425
13380
  * **Success (HTTP 200):**
@@ -13429,26 +13384,28 @@ declare abstract class BrowserRun {
13429
13384
  * non-JSON output
13430
13385
  *
13431
13386
  * **Error:**
13432
- * - 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)
13433
13388
  * - HTTP 408 when the script exceeds `timeout`
13434
13389
  * - HTTP 422 when the script fails to compile or throws
13390
+ * - HTTP 502 when the script fails on the `browser: 'kitesurf'` backend
13435
13391
  * - HTTP errors are returned as a `Response`, not thrown. Invalid `options`
13436
13392
  * throw before any request is made.
13437
13393
  *
13438
- * **Headers:**
13439
- * - `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`
13440
13397
  * - `cf-browser-target-id`: Page target the script ran on
13441
13398
  * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
13442
13399
  */
13443
13400
  script(code: string, options?: BrowserRunScriptOptions): Promise<Response>;
13444
13401
  /**
13445
13402
  * Run a script against an existing browser session, such as one kept open by
13446
- * `script()`.
13447
- * @param sessionId - Session to run in, such as the `cf-browser-session-id`
13448
- * header returned by `script()`.
13449
- * @param code - Source of an async function, as for `script()`.
13450
- * @param options - Library, timeout and page target options.
13451
- * @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.
13452
13409
  *
13453
13410
  * **Error:**
13454
13411
  * - JSON error body with an HTTP status code (400, 401, 404, 408, 410, 422, 500)
@@ -13460,10 +13417,9 @@ declare abstract class BrowserRun {
13460
13417
  * **Headers:**
13461
13418
  * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
13462
13419
  */
13463
- scriptInSession(
13464
- sessionId: string,
13420
+ script(
13465
13421
  code: string,
13466
- options?: BrowserRunScriptSessionOptions,
13422
+ options: BrowserRunScriptSessionOptions,
13467
13423
  ): Promise<Response>;
13468
13424
  /** DevTools JSON methods exposed through one nested binding target. */
13469
13425
  get devtools(): BrowserRunDevtools;
@@ -15793,6 +15749,62 @@ interface MediaError extends Error {
15793
15749
  readonly message: string;
15794
15750
  readonly stack?: string;
15795
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
+ }
15796
15808
  declare module "cloudflare:node" {
15797
15809
  interface NodeStyleServer {
15798
15810
  listen(...args: unknown[]): this;
@@ -17213,6 +17225,17 @@ interface AlreadyUploadedError extends StreamError {
17213
17225
  interface TooManyWatermarksError extends StreamError {
17214
17226
  name: "TooManyWatermarksError";
17215
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;
17216
17239
  type MarkdownDocument = {
17217
17240
  name: string;
17218
17241
  blob: Blob;
@@ -17440,6 +17463,22 @@ declare namespace TailStream {
17440
17463
  readonly type: "spanUpdate";
17441
17464
  readonly info: SpanUpdateInfo;
17442
17465
  }
17466
+ /** A causal relationship to a span, including spans in another trace. */
17467
+ interface SpanLink {
17468
+ readonly context: {
17469
+ readonly traceId: string;
17470
+ readonly spanId: string;
17471
+ readonly traceFlags: number;
17472
+ };
17473
+ readonly attributes: readonly Attribute[];
17474
+ /** Attributes dropped before this link was recorded. */
17475
+ readonly droppedAttributesCount: number;
17476
+ }
17477
+ /** Links added to the receiver identified by the event's spanContext. */
17478
+ interface SpanLinks {
17479
+ readonly type: "spanLinks";
17480
+ readonly links: readonly SpanLink[];
17481
+ }
17443
17482
  interface DiagnosticChannelEvent {
17444
17483
  readonly type: "diagnosticChannel";
17445
17484
  readonly channel: string;
@@ -17510,6 +17549,7 @@ declare namespace TailStream {
17510
17549
  | SpanOpen
17511
17550
  | SpanClose
17512
17551
  | SpanUpdate
17552
+ | SpanLinks
17513
17553
  | DiagnosticChannelEvent
17514
17554
  | Exception
17515
17555
  | Log
@@ -17553,6 +17593,7 @@ declare namespace TailStream {
17553
17593
  spanOpen?: TailEventHandler<SpanOpen>;
17554
17594
  spanClose?: TailEventHandler<SpanClose>;
17555
17595
  spanUpdate?: TailEventHandler<SpanUpdate>;
17596
+ spanLinks?: TailEventHandler<SpanLinks>;
17556
17597
  diagnosticChannel?: TailEventHandler<DiagnosticChannelEvent>;
17557
17598
  exception?: TailEventHandler<Exception>;
17558
17599
  log?: TailEventHandler<Log>;