@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.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)
@@ -4202,6 +4140,11 @@ export interface Tracing {
4202
4140
  ): T;
4203
4141
  Span: typeof Span;
4204
4142
  }
4143
+ export interface TracingSpanLink {
4144
+ context: TracingSpanContext;
4145
+ attributes?: Record<string, boolean | number | string | undefined>;
4146
+ droppedAttributesCount?: number;
4147
+ }
4205
4148
  export declare abstract class Span {
4206
4149
  get isTraced(): boolean;
4207
4150
  spanContext(): TracingSpanContext;
@@ -4234,6 +4177,8 @@ export declare abstract class Span {
4234
4177
  updateName(name: string): this;
4235
4178
  setStatus(status: TracingSpanStatus): this;
4236
4179
  end(): void;
4180
+ addLink(link: TracingSpanLink): this;
4181
+ addLinks(links: readonly TracingSpanLink[]): this;
4237
4182
  }
4238
4183
  export type TracingSpanStatusCode = "unset" | "ok" | "error";
4239
4184
  export interface TracingSpanStatus {
@@ -13198,21 +13143,31 @@ export type BrowserRunScriptOptions = {
13198
13143
  lab?: boolean;
13199
13144
  /** Record the browser session. @default false */
13200
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";
13201
13152
  };
13202
- /** Options for `scriptInSession()`. */
13153
+ /** Options for `script()` in an existing browser session. */
13203
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;
13204
13163
  /** Library whose objects are passed to the script. Omit it for raw CDP. */
13205
13164
  library?: BrowserRunScriptLibrary;
13206
13165
  /** Maximum run time of the script in milliseconds. Between 1 and 120000.
13207
13166
  * @default 60000
13208
13167
  */
13209
13168
  timeout?: number;
13210
- /** Page target the script attaches to, such as the `cf-browser-target-id`
13211
- * header returned by `script()`. Defaults to the session's first page.
13212
- */
13213
- targetId?: string;
13214
13169
  };
13215
- /** JSON success body of `script()` and `scriptInSession()`. */
13170
+ /** JSON success body of `script()`. */
13216
13171
  export type BrowserRunScriptSuccessResponse = {
13217
13172
  success: true;
13218
13173
  /** The script's return value, or `null` when it returned nothing. */
@@ -13437,7 +13392,7 @@ export declare abstract class BrowserRun {
13437
13392
  * @param code - Source of an async function. It receives the selected
13438
13393
  * library's objects (Playwright `{ page, context, browser }`, Puppeteer
13439
13394
  * `{ page, browser }`) or, without `library`, a CDP client.
13440
- * @param options - Library, timeout and session launch options.
13395
+ * @param options - Library, timeout, session launch and backend options.
13441
13396
  * @returns A `Response` containing one of:
13442
13397
  *
13443
13398
  * **Success (HTTP 200):**
@@ -13447,26 +13402,28 @@ export declare abstract class BrowserRun {
13447
13402
  * non-JSON output
13448
13403
  *
13449
13404
  * **Error:**
13450
- * - 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)
13451
13406
  * - HTTP 408 when the script exceeds `timeout`
13452
13407
  * - HTTP 422 when the script fails to compile or throws
13408
+ * - HTTP 502 when the script fails on the `browser: 'kitesurf'` backend
13453
13409
  * - HTTP errors are returned as a `Response`, not thrown. Invalid `options`
13454
13410
  * throw before any request is made.
13455
13411
  *
13456
- * **Headers:**
13457
- * - `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`
13458
13415
  * - `cf-browser-target-id`: Page target the script ran on
13459
13416
  * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
13460
13417
  */
13461
13418
  script(code: string, options?: BrowserRunScriptOptions): Promise<Response>;
13462
13419
  /**
13463
13420
  * Run a script against an existing browser session, such as one kept open by
13464
- * `script()`.
13465
- * @param sessionId - Session to run in, such as the `cf-browser-session-id`
13466
- * header returned by `script()`.
13467
- * @param code - Source of an async function, as for `script()`.
13468
- * @param options - Library, timeout and page target options.
13469
- * @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.
13470
13427
  *
13471
13428
  * **Error:**
13472
13429
  * - JSON error body with an HTTP status code (400, 401, 404, 408, 410, 422, 500)
@@ -13478,10 +13435,9 @@ export declare abstract class BrowserRun {
13478
13435
  * **Headers:**
13479
13436
  * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
13480
13437
  */
13481
- scriptInSession(
13482
- sessionId: string,
13438
+ script(
13483
13439
  code: string,
13484
- options?: BrowserRunScriptSessionOptions,
13440
+ options: BrowserRunScriptSessionOptions,
13485
13441
  ): Promise<Response>;
13486
13442
  /** DevTools JSON methods exposed through one nested binding target. */
13487
13443
  get devtools(): BrowserRunDevtools;
@@ -15785,6 +15741,62 @@ export interface MediaError extends Error {
15785
15741
  readonly message: string;
15786
15742
  readonly stack?: string;
15787
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
+ }
15788
15800
  export type Params<P extends string = any> = Record<P, string | string[]>;
15789
15801
  export type EventContext<Env, P extends string, Data> = {
15790
15802
  request: Request<unknown, IncomingRequestCfProperties<unknown>>;
@@ -17116,6 +17128,17 @@ export interface AlreadyUploadedError extends StreamError {
17116
17128
  export interface TooManyWatermarksError extends StreamError {
17117
17129
  name: "TooManyWatermarksError";
17118
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;
17119
17142
  export type MarkdownDocument = {
17120
17143
  name: string;
17121
17144
  blob: Blob;
@@ -17343,6 +17366,22 @@ export declare namespace TailStream {
17343
17366
  readonly type: "spanUpdate";
17344
17367
  readonly info: SpanUpdateInfo;
17345
17368
  }
17369
+ /** A causal relationship to a span, including spans in another trace. */
17370
+ interface SpanLink {
17371
+ readonly context: {
17372
+ readonly traceId: string;
17373
+ readonly spanId: string;
17374
+ readonly traceFlags: number;
17375
+ };
17376
+ readonly attributes: readonly Attribute[];
17377
+ /** Attributes dropped before this link was recorded. */
17378
+ readonly droppedAttributesCount: number;
17379
+ }
17380
+ /** Links added to the receiver identified by the event's spanContext. */
17381
+ interface SpanLinks {
17382
+ readonly type: "spanLinks";
17383
+ readonly links: readonly SpanLink[];
17384
+ }
17346
17385
  interface DiagnosticChannelEvent {
17347
17386
  readonly type: "diagnosticChannel";
17348
17387
  readonly channel: string;
@@ -17413,6 +17452,7 @@ export declare namespace TailStream {
17413
17452
  | SpanOpen
17414
17453
  | SpanClose
17415
17454
  | SpanUpdate
17455
+ | SpanLinks
17416
17456
  | DiagnosticChannelEvent
17417
17457
  | Exception
17418
17458
  | Log
@@ -17456,6 +17496,7 @@ export declare namespace TailStream {
17456
17496
  spanOpen?: TailEventHandler<SpanOpen>;
17457
17497
  spanClose?: TailEventHandler<SpanClose>;
17458
17498
  spanUpdate?: TailEventHandler<SpanUpdate>;
17499
+ spanLinks?: TailEventHandler<SpanLinks>;
17459
17500
  diagnosticChannel?: TailEventHandler<DiagnosticChannelEvent>;
17460
17501
  exception?: TailEventHandler<Exception>;
17461
17502
  log?: TailEventHandler<Log>;
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.20261118.1"
10
+ "version": "5.20261120.1"
11
11
  }