@cloudflare/workers-types 5.20261119.1 → 5.20261121.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/experimental/index.d.ts +280 -137
- package/experimental/index.ts +280 -137
- package/index.d.ts +279 -137
- package/index.ts +279 -137
- package/package.json +1 -1
package/experimental/index.d.ts
CHANGED
|
@@ -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,14 +283,11 @@ 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;
|
|
292
289
|
FileSystemWritableFileStream: typeof FileSystemWritableFileStream;
|
|
293
290
|
StorageManager: typeof StorageManager;
|
|
294
|
-
EventSource: typeof EventSource;
|
|
295
291
|
ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
|
|
296
292
|
ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
|
|
297
293
|
ReadableByteStreamController: typeof ReadableByteStreamController;
|
|
@@ -336,6 +332,9 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
|
|
|
336
332
|
PerformanceResourceTiming: typeof PerformanceResourceTiming;
|
|
337
333
|
PerformanceObserver: typeof PerformanceObserver;
|
|
338
334
|
PerformanceObserverEntryList: typeof PerformanceObserverEntryList;
|
|
335
|
+
MessageChannel: typeof MessageChannel;
|
|
336
|
+
MessagePort: typeof MessagePort;
|
|
337
|
+
EventSource: typeof EventSource;
|
|
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;
|
|
@@ -3684,58 +3676,6 @@ declare class Datagram {
|
|
|
3684
3676
|
constructor(data: Uint8Array);
|
|
3685
3677
|
get data(): Uint8Array;
|
|
3686
3678
|
}
|
|
3687
|
-
/**
|
|
3688
|
-
* The **`EventSource`** interface is web content's interface to server-sent events.
|
|
3689
|
-
*
|
|
3690
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
|
|
3691
|
-
*/
|
|
3692
|
-
declare class EventSource extends EventTarget {
|
|
3693
|
-
constructor(url: string, init?: EventSourceEventSourceInit);
|
|
3694
|
-
/**
|
|
3695
|
-
* The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the EventSource.readyState attribute to 2 (closed).
|
|
3696
|
-
*
|
|
3697
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
|
|
3698
|
-
*/
|
|
3699
|
-
close(): void;
|
|
3700
|
-
/**
|
|
3701
|
-
* The **`url`** read-only property of the EventSource interface returns a string representing the URL of the source.
|
|
3702
|
-
*
|
|
3703
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
|
|
3704
|
-
*/
|
|
3705
|
-
get url(): string;
|
|
3706
|
-
/**
|
|
3707
|
-
* The **`withCredentials`** read-only property of the EventSource interface returns a boolean value indicating whether the EventSource object was instantiated with CORS credentials set.
|
|
3708
|
-
*
|
|
3709
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
|
|
3710
|
-
*/
|
|
3711
|
-
get withCredentials(): boolean;
|
|
3712
|
-
/**
|
|
3713
|
-
* The **`readyState`** read-only property of the EventSource interface returns a number representing the state of the connection.
|
|
3714
|
-
*
|
|
3715
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
|
|
3716
|
-
*/
|
|
3717
|
-
get readyState(): number;
|
|
3718
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
|
3719
|
-
get onopen(): any | null;
|
|
3720
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
|
3721
|
-
set onopen(value: any | null);
|
|
3722
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
|
3723
|
-
get onmessage(): any | null;
|
|
3724
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
|
3725
|
-
set onmessage(value: any | null);
|
|
3726
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
|
3727
|
-
get onerror(): any | null;
|
|
3728
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
|
3729
|
-
set onerror(value: any | null);
|
|
3730
|
-
static readonly CONNECTING: number;
|
|
3731
|
-
static readonly OPEN: number;
|
|
3732
|
-
static readonly CLOSED: number;
|
|
3733
|
-
static from(stream: ReadableStream): EventSource;
|
|
3734
|
-
}
|
|
3735
|
-
interface EventSourceEventSourceInit {
|
|
3736
|
-
withCredentials?: boolean;
|
|
3737
|
-
fetcher?: Fetcher;
|
|
3738
|
-
}
|
|
3739
3679
|
interface ExecOutput {
|
|
3740
3680
|
readonly stdout: ArrayBuffer;
|
|
3741
3681
|
readonly stderr: ArrayBuffer;
|
|
@@ -4023,59 +3963,6 @@ interface FileSystemFileWriteParams {
|
|
|
4023
3963
|
interface FileSystemHandleRemoveOptions {
|
|
4024
3964
|
recursive?: boolean;
|
|
4025
3965
|
}
|
|
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
3966
|
type LoopbackForExport<
|
|
4080
3967
|
T extends
|
|
4081
3968
|
| (new (...args: any[]) => Rpc.EntrypointBranded)
|
|
@@ -13554,21 +13441,31 @@ type BrowserRunScriptOptions = {
|
|
|
13554
13441
|
lab?: boolean;
|
|
13555
13442
|
/** Record the browser session. @default false */
|
|
13556
13443
|
recording?: boolean;
|
|
13444
|
+
/** Run the script on an alternate browser backend. Only the raw CDP client is
|
|
13445
|
+
* supported, and no session is kept open afterwards. Setting `library`,
|
|
13446
|
+
* `keepAlive`, `lab` or `recording` with it returns an HTTP 400 error
|
|
13447
|
+
* response.
|
|
13448
|
+
*/
|
|
13449
|
+
browser?: "kitesurf";
|
|
13557
13450
|
};
|
|
13558
|
-
/** Options for `
|
|
13451
|
+
/** Options for `script()` in an existing browser session. */
|
|
13559
13452
|
type BrowserRunScriptSessionOptions = {
|
|
13453
|
+
/** Session to run in, such as the `cf-browser-session-id` header returned by
|
|
13454
|
+
* `script()`. The session keeps the launch options it was acquired with.
|
|
13455
|
+
*/
|
|
13456
|
+
sessionId: string;
|
|
13457
|
+
/** Page target the script attaches to, such as the `cf-browser-target-id`
|
|
13458
|
+
* header returned by `script()`. Defaults to the session's first page.
|
|
13459
|
+
*/
|
|
13460
|
+
targetId?: string;
|
|
13560
13461
|
/** Library whose objects are passed to the script. Omit it for raw CDP. */
|
|
13561
13462
|
library?: BrowserRunScriptLibrary;
|
|
13562
13463
|
/** Maximum run time of the script in milliseconds. Between 1 and 120000.
|
|
13563
13464
|
* @default 60000
|
|
13564
13465
|
*/
|
|
13565
13466
|
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
13467
|
};
|
|
13571
|
-
/** JSON success body of `script()
|
|
13468
|
+
/** JSON success body of `script()`. */
|
|
13572
13469
|
type BrowserRunScriptSuccessResponse = {
|
|
13573
13470
|
success: true;
|
|
13574
13471
|
/** The script's return value, or `null` when it returned nothing. */
|
|
@@ -13793,7 +13690,7 @@ declare abstract class BrowserRun {
|
|
|
13793
13690
|
* @param code - Source of an async function. It receives the selected
|
|
13794
13691
|
* library's objects (Playwright `{ page, context, browser }`, Puppeteer
|
|
13795
13692
|
* `{ page, browser }`) or, without `library`, a CDP client.
|
|
13796
|
-
* @param options - Library, timeout
|
|
13693
|
+
* @param options - Library, timeout, session launch and backend options.
|
|
13797
13694
|
* @returns A `Response` containing one of:
|
|
13798
13695
|
*
|
|
13799
13696
|
* **Success (HTTP 200):**
|
|
@@ -13803,26 +13700,28 @@ declare abstract class BrowserRun {
|
|
|
13803
13700
|
* non-JSON output
|
|
13804
13701
|
*
|
|
13805
13702
|
* **Error:**
|
|
13806
|
-
* - JSON error body with an HTTP status code (400, 404, 408, 422, 429, 500, 503)
|
|
13703
|
+
* - JSON error body with an HTTP status code (400, 404, 408, 422, 429, 500, 502, 503)
|
|
13807
13704
|
* - HTTP 408 when the script exceeds `timeout`
|
|
13808
13705
|
* - HTTP 422 when the script fails to compile or throws
|
|
13706
|
+
* - HTTP 502 when the script fails on the `browser: 'kitesurf'` backend
|
|
13809
13707
|
* - HTTP errors are returned as a `Response`, not thrown. Invalid `options`
|
|
13810
13708
|
* throw before any request is made.
|
|
13811
13709
|
*
|
|
13812
|
-
* **Headers
|
|
13813
|
-
* - `cf-browser-session-id`: Session kept open for `
|
|
13710
|
+
* **Headers** (not returned with `browser: 'kitesurf'`):
|
|
13711
|
+
* - `cf-browser-session-id`: Session kept open for a later `script()` call
|
|
13712
|
+
* with `sessionId`
|
|
13814
13713
|
* - `cf-browser-target-id`: Page target the script ran on
|
|
13815
13714
|
* - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
|
|
13816
13715
|
*/
|
|
13817
13716
|
script(code: string, options?: BrowserRunScriptOptions): Promise<Response>;
|
|
13818
13717
|
/**
|
|
13819
13718
|
* Run a script against an existing browser session, such as one kept open by
|
|
13820
|
-
* `script()
|
|
13821
|
-
* @param
|
|
13822
|
-
*
|
|
13823
|
-
*
|
|
13824
|
-
*
|
|
13825
|
-
* @returns A `Response` with the same success bodies as
|
|
13719
|
+
* an earlier `script()` call.
|
|
13720
|
+
* @param code - Source of an async function, as for a new session.
|
|
13721
|
+
* @param options - The session to run in, plus page target, library and
|
|
13722
|
+
* timeout options. Launch options such as `keepAlive` cannot be set, because
|
|
13723
|
+
* the session keeps the ones it was acquired with.
|
|
13724
|
+
* @returns A `Response` with the same success bodies as a new-session run.
|
|
13826
13725
|
*
|
|
13827
13726
|
* **Error:**
|
|
13828
13727
|
* - JSON error body with an HTTP status code (400, 401, 404, 408, 410, 422, 500)
|
|
@@ -13834,10 +13733,9 @@ declare abstract class BrowserRun {
|
|
|
13834
13733
|
* **Headers:**
|
|
13835
13734
|
* - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
|
|
13836
13735
|
*/
|
|
13837
|
-
|
|
13838
|
-
sessionId: string,
|
|
13736
|
+
script(
|
|
13839
13737
|
code: string,
|
|
13840
|
-
options
|
|
13738
|
+
options: BrowserRunScriptSessionOptions,
|
|
13841
13739
|
): Promise<Response>;
|
|
13842
13740
|
/** DevTools JSON methods exposed through one nested binding target. */
|
|
13843
13741
|
get devtools(): BrowserRunDevtools;
|
|
@@ -15388,6 +15286,59 @@ declare module "cloudflare:email" {
|
|
|
15388
15286
|
};
|
|
15389
15287
|
export { _EmailMessage as EmailMessage };
|
|
15390
15288
|
}
|
|
15289
|
+
// EventSource, a global at every compatibility date.
|
|
15290
|
+
/**
|
|
15291
|
+
* The **`EventSource`** interface is web content's interface to server-sent events.
|
|
15292
|
+
*
|
|
15293
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
|
|
15294
|
+
*/
|
|
15295
|
+
declare class EventSource extends EventTarget {
|
|
15296
|
+
constructor(url: string, init?: EventSourceEventSourceInit);
|
|
15297
|
+
/**
|
|
15298
|
+
* The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the EventSource.readyState attribute to 2 (closed).
|
|
15299
|
+
*
|
|
15300
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
|
|
15301
|
+
*/
|
|
15302
|
+
close(): void;
|
|
15303
|
+
/**
|
|
15304
|
+
* The **`url`** read-only property of the EventSource interface returns a string representing the URL of the source.
|
|
15305
|
+
*
|
|
15306
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
|
|
15307
|
+
*/
|
|
15308
|
+
get url(): string;
|
|
15309
|
+
/**
|
|
15310
|
+
* The **`withCredentials`** read-only property of the EventSource interface returns a boolean value indicating whether the EventSource object was instantiated with CORS credentials set.
|
|
15311
|
+
*
|
|
15312
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
|
|
15313
|
+
*/
|
|
15314
|
+
get withCredentials(): boolean;
|
|
15315
|
+
/**
|
|
15316
|
+
* The **`readyState`** read-only property of the EventSource interface returns a number representing the state of the connection.
|
|
15317
|
+
*
|
|
15318
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
|
|
15319
|
+
*/
|
|
15320
|
+
get readyState(): number;
|
|
15321
|
+
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
|
15322
|
+
get onopen(): any | null;
|
|
15323
|
+
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
|
15324
|
+
set onopen(value: any | null);
|
|
15325
|
+
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
|
15326
|
+
get onmessage(): any | null;
|
|
15327
|
+
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
|
15328
|
+
set onmessage(value: any | null);
|
|
15329
|
+
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
|
15330
|
+
get onerror(): any | null;
|
|
15331
|
+
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
|
15332
|
+
set onerror(value: any | null);
|
|
15333
|
+
static readonly CONNECTING: number;
|
|
15334
|
+
static readonly OPEN: number;
|
|
15335
|
+
static readonly CLOSED: number;
|
|
15336
|
+
static from(stream: ReadableStream): EventSource;
|
|
15337
|
+
}
|
|
15338
|
+
interface EventSourceEventSourceInit {
|
|
15339
|
+
withCredentials?: boolean;
|
|
15340
|
+
fetcher?: Fetcher;
|
|
15341
|
+
}
|
|
15391
15342
|
/**
|
|
15392
15343
|
* Evaluation context for targeting rules.
|
|
15393
15344
|
* Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
|
|
@@ -16167,6 +16118,62 @@ interface MediaError extends Error {
|
|
|
16167
16118
|
readonly message: string;
|
|
16168
16119
|
readonly stack?: string;
|
|
16169
16120
|
}
|
|
16121
|
+
// MessageChannel and MessagePort, declared at every compatibility date. They
|
|
16122
|
+
// are globals under the expose_global_message_channel compatibility flag (the
|
|
16123
|
+
// default from 2025-08-15); node:worker_threads exports them at any date.
|
|
16124
|
+
/**
|
|
16125
|
+
* 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.
|
|
16126
|
+
*
|
|
16127
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
|
|
16128
|
+
*/
|
|
16129
|
+
declare abstract class MessagePort extends EventTarget {
|
|
16130
|
+
/**
|
|
16131
|
+
* The **`postMessage()`** method of the MessagePort interface sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.
|
|
16132
|
+
*
|
|
16133
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
|
|
16134
|
+
*/
|
|
16135
|
+
postMessage(
|
|
16136
|
+
data?: any,
|
|
16137
|
+
options?: any[] | MessagePortPostMessageOptions,
|
|
16138
|
+
): void;
|
|
16139
|
+
/**
|
|
16140
|
+
* 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.
|
|
16141
|
+
*
|
|
16142
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
|
|
16143
|
+
*/
|
|
16144
|
+
close(): void;
|
|
16145
|
+
/**
|
|
16146
|
+
* 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.
|
|
16147
|
+
*
|
|
16148
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
|
|
16149
|
+
*/
|
|
16150
|
+
start(): void;
|
|
16151
|
+
get onmessage(): any | null;
|
|
16152
|
+
set onmessage(value: any | null);
|
|
16153
|
+
}
|
|
16154
|
+
/**
|
|
16155
|
+
* 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.
|
|
16156
|
+
*
|
|
16157
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
|
|
16158
|
+
*/
|
|
16159
|
+
declare class MessageChannel {
|
|
16160
|
+
constructor();
|
|
16161
|
+
/**
|
|
16162
|
+
* 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.
|
|
16163
|
+
*
|
|
16164
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
|
|
16165
|
+
*/
|
|
16166
|
+
readonly port1: MessagePort;
|
|
16167
|
+
/**
|
|
16168
|
+
* 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.
|
|
16169
|
+
*
|
|
16170
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
|
|
16171
|
+
*/
|
|
16172
|
+
readonly port2: MessagePort;
|
|
16173
|
+
}
|
|
16174
|
+
interface MessagePortPostMessageOptions {
|
|
16175
|
+
transfer?: any[];
|
|
16176
|
+
}
|
|
16170
16177
|
declare module "cloudflare:node" {
|
|
16171
16178
|
interface NodeStyleServer {
|
|
16172
16179
|
listen(...args: unknown[]): this;
|
|
@@ -16851,6 +16858,7 @@ declare module "cloudflare:sockets" {
|
|
|
16851
16858
|
* - Binding-level operations:
|
|
16852
16859
|
* `await env.STREAM.videos.upload`
|
|
16853
16860
|
* `await env.STREAM.videos.createDirectUpload`
|
|
16861
|
+
* `await env.STREAM.clip`
|
|
16854
16862
|
* `await env.STREAM.videos.*`
|
|
16855
16863
|
* `await env.STREAM.watermarks.*`
|
|
16856
16864
|
* - Per-video operations:
|
|
@@ -16897,6 +16905,19 @@ interface StreamBinding {
|
|
|
16897
16905
|
createDirectUpload(
|
|
16898
16906
|
params: StreamDirectUploadCreateParams,
|
|
16899
16907
|
): Promise<StreamDirectUpload>;
|
|
16908
|
+
/**
|
|
16909
|
+
* Creates a new video by clipping a time range from an existing video.
|
|
16910
|
+
* @param videoId The unique identifier of the source video to clip from.
|
|
16911
|
+
* @param params The time range to clip from the source video.
|
|
16912
|
+
* @returns The details of the newly created clip.
|
|
16913
|
+
* @throws {NotFoundError} if the source video is not found
|
|
16914
|
+
* @throws {BadRequestError} if the time range is invalid or extends past the end of the source video
|
|
16915
|
+
* @throws {BadRequestError} if the source video is a live stream recording
|
|
16916
|
+
* @throws {QuotaReachedError} if the account storage capacity is exceeded
|
|
16917
|
+
* @throws {RateLimitedError} if the account has too many videos processing at once
|
|
16918
|
+
* @throws {InternalError} if an unexpected error occurs
|
|
16919
|
+
*/
|
|
16920
|
+
clip(videoId: string, params: StreamClipParams): Promise<StreamVideo>;
|
|
16900
16921
|
videos: StreamVideos;
|
|
16901
16922
|
watermarks: StreamWatermarks;
|
|
16902
16923
|
}
|
|
@@ -16933,10 +16954,13 @@ interface StreamVideoHandle {
|
|
|
16933
16954
|
delete(): Promise<void>;
|
|
16934
16955
|
/**
|
|
16935
16956
|
* Creates a signed URL token for a video.
|
|
16957
|
+
* @param options Optional settings for the token.
|
|
16936
16958
|
* @returns The signed token that was created.
|
|
16959
|
+
* @throws {NotFoundError} if the video is not found
|
|
16960
|
+
* @throws {BadRequestError} if the options are invalid, e.g. `expiresAt` is in the past or more than 24 hours away, `notBefore` is not before `expiresAt`, or the signing key is not found or does not belong to the account
|
|
16937
16961
|
* @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed
|
|
16938
16962
|
*/
|
|
16939
|
-
generateToken(): Promise<string>;
|
|
16963
|
+
generateToken(options?: StreamSignedTokenOptions): Promise<string>;
|
|
16940
16964
|
downloads: StreamScopedDownloads;
|
|
16941
16965
|
captions: StreamScopedCaptions;
|
|
16942
16966
|
}
|
|
@@ -17046,6 +17070,13 @@ interface StreamVideo {
|
|
|
17046
17070
|
* Public details associated with the video.
|
|
17047
17071
|
*/
|
|
17048
17072
|
publicDetails: StreamPublicDetails | null;
|
|
17073
|
+
/**
|
|
17074
|
+
* The unique customer code associated with the video.
|
|
17075
|
+
*
|
|
17076
|
+
* Use this to construct URLs that require a customer code, such as player URLs using signed tokens.
|
|
17077
|
+
* `https://customer-{customerCode}.cloudflarestream.com/{token}/iframe`
|
|
17078
|
+
*/
|
|
17079
|
+
customerCode: string;
|
|
17049
17080
|
}
|
|
17050
17081
|
type StreamVideoStatus = {
|
|
17051
17082
|
/**
|
|
@@ -17204,6 +17235,98 @@ type StreamUrlUploadParams = {
|
|
|
17204
17235
|
*/
|
|
17205
17236
|
watermarkId?: string;
|
|
17206
17237
|
};
|
|
17238
|
+
type StreamClipParams = {
|
|
17239
|
+
/**
|
|
17240
|
+
* The point in the source video, in whole seconds, where the clip starts.
|
|
17241
|
+
*/
|
|
17242
|
+
startTimeSeconds: number;
|
|
17243
|
+
/**
|
|
17244
|
+
* The point in the source video, in whole seconds, where the clip ends.
|
|
17245
|
+
* Must be greater than `startTimeSeconds` and no later than the end of the
|
|
17246
|
+
* source video.
|
|
17247
|
+
*/
|
|
17248
|
+
endTimeSeconds: number;
|
|
17249
|
+
};
|
|
17250
|
+
type StreamSignedTokenOptions = {
|
|
17251
|
+
/**
|
|
17252
|
+
* The signing key to sign the token with. When omitted, the token is signed
|
|
17253
|
+
* with a key Stream manages for the account.
|
|
17254
|
+
*/
|
|
17255
|
+
signingKey?: StreamSigningKey;
|
|
17256
|
+
/**
|
|
17257
|
+
* When the token stops being accepted, as a `Date` or a Unix timestamp in
|
|
17258
|
+
* seconds. Must be in the future and no more than 24 hours from now.
|
|
17259
|
+
* Defaults to one hour from now.
|
|
17260
|
+
*/
|
|
17261
|
+
expiresAt?: Date | number;
|
|
17262
|
+
/**
|
|
17263
|
+
* When the token starts being accepted, as a `Date` or a Unix timestamp in
|
|
17264
|
+
* seconds. Must be earlier than `expiresAt`. Defaults to one hour ago.
|
|
17265
|
+
*/
|
|
17266
|
+
notBefore?: Date | number;
|
|
17267
|
+
/**
|
|
17268
|
+
* Whether the token can also be used to access the video's MP4 downloads.
|
|
17269
|
+
* @default false
|
|
17270
|
+
*/
|
|
17271
|
+
downloadable?: boolean;
|
|
17272
|
+
/**
|
|
17273
|
+
* Rules that allow or block viewers by IP address or country. Rules are
|
|
17274
|
+
* evaluated in order, and the first rule that matches is applied.
|
|
17275
|
+
*/
|
|
17276
|
+
accessRules?: StreamAccessRule[];
|
|
17277
|
+
/**
|
|
17278
|
+
* Additional flags for the token.
|
|
17279
|
+
*/
|
|
17280
|
+
flags?: StreamSignedTokenFlags;
|
|
17281
|
+
};
|
|
17282
|
+
type StreamSigningKey = {
|
|
17283
|
+
/**
|
|
17284
|
+
* The ID of a Stream signing key.
|
|
17285
|
+
*/
|
|
17286
|
+
id: string;
|
|
17287
|
+
/**
|
|
17288
|
+
* The base64-encoded private key, in PEM format, for the signing key.
|
|
17289
|
+
*/
|
|
17290
|
+
pem: string;
|
|
17291
|
+
};
|
|
17292
|
+
type StreamSignedTokenFlags = {
|
|
17293
|
+
/**
|
|
17294
|
+
* Whether the token serves the original video without transformations.
|
|
17295
|
+
* @default false
|
|
17296
|
+
*/
|
|
17297
|
+
original?: boolean;
|
|
17298
|
+
};
|
|
17299
|
+
type StreamAccessRuleAction = "allow" | "block";
|
|
17300
|
+
type StreamAccessRule =
|
|
17301
|
+
| {
|
|
17302
|
+
/**
|
|
17303
|
+
* Matches every request. Use as the last rule to set a default action.
|
|
17304
|
+
*/
|
|
17305
|
+
type: "any";
|
|
17306
|
+
action: StreamAccessRuleAction;
|
|
17307
|
+
}
|
|
17308
|
+
| {
|
|
17309
|
+
/**
|
|
17310
|
+
* Matches requests from the listed IP addresses or CIDR ranges.
|
|
17311
|
+
*/
|
|
17312
|
+
type: "ip.src";
|
|
17313
|
+
action: StreamAccessRuleAction;
|
|
17314
|
+
/**
|
|
17315
|
+
* IPv4 or IPv6 addresses or CIDR ranges.
|
|
17316
|
+
*/
|
|
17317
|
+
ip: string[];
|
|
17318
|
+
}
|
|
17319
|
+
| {
|
|
17320
|
+
/**
|
|
17321
|
+
* Matches requests from the listed countries.
|
|
17322
|
+
*/
|
|
17323
|
+
type: "ip.geoip.country";
|
|
17324
|
+
action: StreamAccessRuleAction;
|
|
17325
|
+
/**
|
|
17326
|
+
* Two-letter ISO 3166-1 alpha-2 country codes.
|
|
17327
|
+
*/
|
|
17328
|
+
country: string[];
|
|
17329
|
+
};
|
|
17207
17330
|
interface StreamScopedCaptions {
|
|
17208
17331
|
/**
|
|
17209
17332
|
* Uploads the caption or subtitle file to the endpoint for a specific BCP47 language.
|
|
@@ -17238,6 +17361,15 @@ interface StreamScopedCaptions {
|
|
|
17238
17361
|
* @throws {InternalError} if an unexpected error occurs
|
|
17239
17362
|
*/
|
|
17240
17363
|
list(language?: string): Promise<StreamCaption[]>;
|
|
17364
|
+
/**
|
|
17365
|
+
* Gets the WebVTT file for a caption or subtitle track.
|
|
17366
|
+
* @param language The BCP 47 language tag of the track.
|
|
17367
|
+
* @returns The track's WebVTT file as a stream.
|
|
17368
|
+
* @throws {NotFoundError} if the video is not found, it has no caption for this language, or a generated caption has not finished
|
|
17369
|
+
* @throws {BadRequestError} if the language is not a valid BCP 47 tag
|
|
17370
|
+
* @throws {InternalError} if an unexpected error occurs
|
|
17371
|
+
*/
|
|
17372
|
+
get(language: string): Promise<ReadableStream>;
|
|
17241
17373
|
/**
|
|
17242
17374
|
* Removes the captions or subtitles from a video.
|
|
17243
17375
|
* @param language The BCP 47 language tag to remove.
|
|
@@ -17587,6 +17719,17 @@ interface AlreadyUploadedError extends StreamError {
|
|
|
17587
17719
|
interface TooManyWatermarksError extends StreamError {
|
|
17588
17720
|
name: "TooManyWatermarksError";
|
|
17589
17721
|
}
|
|
17722
|
+
interface StructuredSerializeOptions {
|
|
17723
|
+
transfer?: any[];
|
|
17724
|
+
}
|
|
17725
|
+
interface ServiceWorkerGlobalScope {
|
|
17726
|
+
structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
|
|
17727
|
+
}
|
|
17728
|
+
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
|
|
17729
|
+
declare function structuredClone<T>(
|
|
17730
|
+
value: T,
|
|
17731
|
+
options?: StructuredSerializeOptions,
|
|
17732
|
+
): T;
|
|
17590
17733
|
type MarkdownDocument = {
|
|
17591
17734
|
name: string;
|
|
17592
17735
|
blob: Blob;
|