@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/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,9 +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
|
-
EventSource: typeof EventSource;
|
|
289
285
|
ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
|
|
290
286
|
ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
|
|
291
287
|
ReadableByteStreamController: typeof ReadableByteStreamController;
|
|
@@ -337,6 +333,9 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
|
|
|
337
333
|
PerformanceResourceTiming: typeof PerformanceResourceTiming;
|
|
338
334
|
PerformanceObserver: typeof PerformanceObserver;
|
|
339
335
|
PerformanceObserverEntryList: typeof PerformanceObserverEntryList;
|
|
336
|
+
MessageChannel: typeof MessageChannel;
|
|
337
|
+
MessagePort: typeof MessagePort;
|
|
338
|
+
EventSource: typeof EventSource;
|
|
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;
|
|
@@ -3507,58 +3498,6 @@ interface SocketInfo {
|
|
|
3507
3498
|
remoteAddress?: string;
|
|
3508
3499
|
localAddress?: string;
|
|
3509
3500
|
}
|
|
3510
|
-
/**
|
|
3511
|
-
* The **`EventSource`** interface is web content's interface to server-sent events.
|
|
3512
|
-
*
|
|
3513
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
|
|
3514
|
-
*/
|
|
3515
|
-
declare class EventSource extends EventTarget {
|
|
3516
|
-
constructor(url: string, init?: EventSourceEventSourceInit);
|
|
3517
|
-
/**
|
|
3518
|
-
* The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the EventSource.readyState attribute to 2 (closed).
|
|
3519
|
-
*
|
|
3520
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
|
|
3521
|
-
*/
|
|
3522
|
-
close(): void;
|
|
3523
|
-
/**
|
|
3524
|
-
* The **`url`** read-only property of the EventSource interface returns a string representing the URL of the source.
|
|
3525
|
-
*
|
|
3526
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
|
|
3527
|
-
*/
|
|
3528
|
-
get url(): string;
|
|
3529
|
-
/**
|
|
3530
|
-
* The **`withCredentials`** read-only property of the EventSource interface returns a boolean value indicating whether the EventSource object was instantiated with CORS credentials set.
|
|
3531
|
-
*
|
|
3532
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
|
|
3533
|
-
*/
|
|
3534
|
-
get withCredentials(): boolean;
|
|
3535
|
-
/**
|
|
3536
|
-
* The **`readyState`** read-only property of the EventSource interface returns a number representing the state of the connection.
|
|
3537
|
-
*
|
|
3538
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
|
|
3539
|
-
*/
|
|
3540
|
-
get readyState(): number;
|
|
3541
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
|
3542
|
-
get onopen(): any | null;
|
|
3543
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
|
3544
|
-
set onopen(value: any | null);
|
|
3545
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
|
3546
|
-
get onmessage(): any | null;
|
|
3547
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
|
3548
|
-
set onmessage(value: any | null);
|
|
3549
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
|
3550
|
-
get onerror(): any | null;
|
|
3551
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
|
3552
|
-
set onerror(value: any | null);
|
|
3553
|
-
static readonly CONNECTING: number;
|
|
3554
|
-
static readonly OPEN: number;
|
|
3555
|
-
static readonly CLOSED: number;
|
|
3556
|
-
static from(stream: ReadableStream): EventSource;
|
|
3557
|
-
}
|
|
3558
|
-
interface EventSourceEventSourceInit {
|
|
3559
|
-
withCredentials?: boolean;
|
|
3560
|
-
fetcher?: Fetcher;
|
|
3561
|
-
}
|
|
3562
3501
|
interface ExecOutput {
|
|
3563
3502
|
readonly stdout: ArrayBuffer;
|
|
3564
3503
|
readonly stderr: ArrayBuffer;
|
|
@@ -3666,59 +3605,6 @@ interface ContainerStartResources {
|
|
|
3666
3605
|
memoryMib: number;
|
|
3667
3606
|
diskMb: number;
|
|
3668
3607
|
}
|
|
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
3608
|
type LoopbackForExport<
|
|
3723
3609
|
T extends
|
|
3724
3610
|
| (new (...args: any[]) => Rpc.EntrypointBranded)
|
|
@@ -13187,21 +13073,31 @@ type BrowserRunScriptOptions = {
|
|
|
13187
13073
|
lab?: boolean;
|
|
13188
13074
|
/** Record the browser session. @default false */
|
|
13189
13075
|
recording?: boolean;
|
|
13076
|
+
/** Run the script on an alternate browser backend. Only the raw CDP client is
|
|
13077
|
+
* supported, and no session is kept open afterwards. Setting `library`,
|
|
13078
|
+
* `keepAlive`, `lab` or `recording` with it returns an HTTP 400 error
|
|
13079
|
+
* response.
|
|
13080
|
+
*/
|
|
13081
|
+
browser?: "kitesurf";
|
|
13190
13082
|
};
|
|
13191
|
-
/** Options for `
|
|
13083
|
+
/** Options for `script()` in an existing browser session. */
|
|
13192
13084
|
type BrowserRunScriptSessionOptions = {
|
|
13085
|
+
/** Session to run in, such as the `cf-browser-session-id` header returned by
|
|
13086
|
+
* `script()`. The session keeps the launch options it was acquired with.
|
|
13087
|
+
*/
|
|
13088
|
+
sessionId: string;
|
|
13089
|
+
/** Page target the script attaches to, such as the `cf-browser-target-id`
|
|
13090
|
+
* header returned by `script()`. Defaults to the session's first page.
|
|
13091
|
+
*/
|
|
13092
|
+
targetId?: string;
|
|
13193
13093
|
/** Library whose objects are passed to the script. Omit it for raw CDP. */
|
|
13194
13094
|
library?: BrowserRunScriptLibrary;
|
|
13195
13095
|
/** Maximum run time of the script in milliseconds. Between 1 and 120000.
|
|
13196
13096
|
* @default 60000
|
|
13197
13097
|
*/
|
|
13198
13098
|
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
13099
|
};
|
|
13204
|
-
/** JSON success body of `script()
|
|
13100
|
+
/** JSON success body of `script()`. */
|
|
13205
13101
|
type BrowserRunScriptSuccessResponse = {
|
|
13206
13102
|
success: true;
|
|
13207
13103
|
/** The script's return value, or `null` when it returned nothing. */
|
|
@@ -13426,7 +13322,7 @@ declare abstract class BrowserRun {
|
|
|
13426
13322
|
* @param code - Source of an async function. It receives the selected
|
|
13427
13323
|
* library's objects (Playwright `{ page, context, browser }`, Puppeteer
|
|
13428
13324
|
* `{ page, browser }`) or, without `library`, a CDP client.
|
|
13429
|
-
* @param options - Library, timeout
|
|
13325
|
+
* @param options - Library, timeout, session launch and backend options.
|
|
13430
13326
|
* @returns A `Response` containing one of:
|
|
13431
13327
|
*
|
|
13432
13328
|
* **Success (HTTP 200):**
|
|
@@ -13436,26 +13332,28 @@ declare abstract class BrowserRun {
|
|
|
13436
13332
|
* non-JSON output
|
|
13437
13333
|
*
|
|
13438
13334
|
* **Error:**
|
|
13439
|
-
* - JSON error body with an HTTP status code (400, 404, 408, 422, 429, 500, 503)
|
|
13335
|
+
* - JSON error body with an HTTP status code (400, 404, 408, 422, 429, 500, 502, 503)
|
|
13440
13336
|
* - HTTP 408 when the script exceeds `timeout`
|
|
13441
13337
|
* - HTTP 422 when the script fails to compile or throws
|
|
13338
|
+
* - HTTP 502 when the script fails on the `browser: 'kitesurf'` backend
|
|
13442
13339
|
* - HTTP errors are returned as a `Response`, not thrown. Invalid `options`
|
|
13443
13340
|
* throw before any request is made.
|
|
13444
13341
|
*
|
|
13445
|
-
* **Headers
|
|
13446
|
-
* - `cf-browser-session-id`: Session kept open for `
|
|
13342
|
+
* **Headers** (not returned with `browser: 'kitesurf'`):
|
|
13343
|
+
* - `cf-browser-session-id`: Session kept open for a later `script()` call
|
|
13344
|
+
* with `sessionId`
|
|
13447
13345
|
* - `cf-browser-target-id`: Page target the script ran on
|
|
13448
13346
|
* - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
|
|
13449
13347
|
*/
|
|
13450
13348
|
script(code: string, options?: BrowserRunScriptOptions): Promise<Response>;
|
|
13451
13349
|
/**
|
|
13452
13350
|
* Run a script against an existing browser session, such as one kept open by
|
|
13453
|
-
* `script()
|
|
13454
|
-
* @param
|
|
13455
|
-
*
|
|
13456
|
-
*
|
|
13457
|
-
*
|
|
13458
|
-
* @returns A `Response` with the same success bodies as
|
|
13351
|
+
* an earlier `script()` call.
|
|
13352
|
+
* @param code - Source of an async function, as for a new session.
|
|
13353
|
+
* @param options - The session to run in, plus page target, library and
|
|
13354
|
+
* timeout options. Launch options such as `keepAlive` cannot be set, because
|
|
13355
|
+
* the session keeps the ones it was acquired with.
|
|
13356
|
+
* @returns A `Response` with the same success bodies as a new-session run.
|
|
13459
13357
|
*
|
|
13460
13358
|
* **Error:**
|
|
13461
13359
|
* - JSON error body with an HTTP status code (400, 401, 404, 408, 410, 422, 500)
|
|
@@ -13467,10 +13365,9 @@ declare abstract class BrowserRun {
|
|
|
13467
13365
|
* **Headers:**
|
|
13468
13366
|
* - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
|
|
13469
13367
|
*/
|
|
13470
|
-
|
|
13471
|
-
sessionId: string,
|
|
13368
|
+
script(
|
|
13472
13369
|
code: string,
|
|
13473
|
-
options
|
|
13370
|
+
options: BrowserRunScriptSessionOptions,
|
|
13474
13371
|
): Promise<Response>;
|
|
13475
13372
|
/** DevTools JSON methods exposed through one nested binding target. */
|
|
13476
13373
|
get devtools(): BrowserRunDevtools;
|
|
@@ -15021,6 +14918,59 @@ declare module "cloudflare:email" {
|
|
|
15021
14918
|
};
|
|
15022
14919
|
export { _EmailMessage as EmailMessage };
|
|
15023
14920
|
}
|
|
14921
|
+
// EventSource, a global at every compatibility date.
|
|
14922
|
+
/**
|
|
14923
|
+
* The **`EventSource`** interface is web content's interface to server-sent events.
|
|
14924
|
+
*
|
|
14925
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
|
|
14926
|
+
*/
|
|
14927
|
+
declare class EventSource extends EventTarget {
|
|
14928
|
+
constructor(url: string, init?: EventSourceEventSourceInit);
|
|
14929
|
+
/**
|
|
14930
|
+
* The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the EventSource.readyState attribute to 2 (closed).
|
|
14931
|
+
*
|
|
14932
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
|
|
14933
|
+
*/
|
|
14934
|
+
close(): void;
|
|
14935
|
+
/**
|
|
14936
|
+
* The **`url`** read-only property of the EventSource interface returns a string representing the URL of the source.
|
|
14937
|
+
*
|
|
14938
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
|
|
14939
|
+
*/
|
|
14940
|
+
get url(): string;
|
|
14941
|
+
/**
|
|
14942
|
+
* The **`withCredentials`** read-only property of the EventSource interface returns a boolean value indicating whether the EventSource object was instantiated with CORS credentials set.
|
|
14943
|
+
*
|
|
14944
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
|
|
14945
|
+
*/
|
|
14946
|
+
get withCredentials(): boolean;
|
|
14947
|
+
/**
|
|
14948
|
+
* The **`readyState`** read-only property of the EventSource interface returns a number representing the state of the connection.
|
|
14949
|
+
*
|
|
14950
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
|
|
14951
|
+
*/
|
|
14952
|
+
get readyState(): number;
|
|
14953
|
+
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
|
14954
|
+
get onopen(): any | null;
|
|
14955
|
+
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
|
14956
|
+
set onopen(value: any | null);
|
|
14957
|
+
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
|
14958
|
+
get onmessage(): any | null;
|
|
14959
|
+
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
|
14960
|
+
set onmessage(value: any | null);
|
|
14961
|
+
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
|
14962
|
+
get onerror(): any | null;
|
|
14963
|
+
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
|
14964
|
+
set onerror(value: any | null);
|
|
14965
|
+
static readonly CONNECTING: number;
|
|
14966
|
+
static readonly OPEN: number;
|
|
14967
|
+
static readonly CLOSED: number;
|
|
14968
|
+
static from(stream: ReadableStream): EventSource;
|
|
14969
|
+
}
|
|
14970
|
+
interface EventSourceEventSourceInit {
|
|
14971
|
+
withCredentials?: boolean;
|
|
14972
|
+
fetcher?: Fetcher;
|
|
14973
|
+
}
|
|
15024
14974
|
/**
|
|
15025
14975
|
* Evaluation context for targeting rules.
|
|
15026
14976
|
* Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
|
|
@@ -15800,6 +15750,62 @@ interface MediaError extends Error {
|
|
|
15800
15750
|
readonly message: string;
|
|
15801
15751
|
readonly stack?: string;
|
|
15802
15752
|
}
|
|
15753
|
+
// MessageChannel and MessagePort, declared at every compatibility date. They
|
|
15754
|
+
// are globals under the expose_global_message_channel compatibility flag (the
|
|
15755
|
+
// default from 2025-08-15); node:worker_threads exports them at any date.
|
|
15756
|
+
/**
|
|
15757
|
+
* 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.
|
|
15758
|
+
*
|
|
15759
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
|
|
15760
|
+
*/
|
|
15761
|
+
declare abstract class MessagePort extends EventTarget {
|
|
15762
|
+
/**
|
|
15763
|
+
* The **`postMessage()`** method of the MessagePort interface sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.
|
|
15764
|
+
*
|
|
15765
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
|
|
15766
|
+
*/
|
|
15767
|
+
postMessage(
|
|
15768
|
+
data?: any,
|
|
15769
|
+
options?: any[] | MessagePortPostMessageOptions,
|
|
15770
|
+
): void;
|
|
15771
|
+
/**
|
|
15772
|
+
* 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.
|
|
15773
|
+
*
|
|
15774
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
|
|
15775
|
+
*/
|
|
15776
|
+
close(): void;
|
|
15777
|
+
/**
|
|
15778
|
+
* 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.
|
|
15779
|
+
*
|
|
15780
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
|
|
15781
|
+
*/
|
|
15782
|
+
start(): void;
|
|
15783
|
+
get onmessage(): any | null;
|
|
15784
|
+
set onmessage(value: any | null);
|
|
15785
|
+
}
|
|
15786
|
+
/**
|
|
15787
|
+
* 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.
|
|
15788
|
+
*
|
|
15789
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
|
|
15790
|
+
*/
|
|
15791
|
+
declare class MessageChannel {
|
|
15792
|
+
constructor();
|
|
15793
|
+
/**
|
|
15794
|
+
* 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.
|
|
15795
|
+
*
|
|
15796
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
|
|
15797
|
+
*/
|
|
15798
|
+
readonly port1: MessagePort;
|
|
15799
|
+
/**
|
|
15800
|
+
* 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.
|
|
15801
|
+
*
|
|
15802
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
|
|
15803
|
+
*/
|
|
15804
|
+
readonly port2: MessagePort;
|
|
15805
|
+
}
|
|
15806
|
+
interface MessagePortPostMessageOptions {
|
|
15807
|
+
transfer?: any[];
|
|
15808
|
+
}
|
|
15803
15809
|
declare module "cloudflare:node" {
|
|
15804
15810
|
interface NodeStyleServer {
|
|
15805
15811
|
listen(...args: unknown[]): this;
|
|
@@ -16484,6 +16490,7 @@ declare module "cloudflare:sockets" {
|
|
|
16484
16490
|
* - Binding-level operations:
|
|
16485
16491
|
* `await env.STREAM.videos.upload`
|
|
16486
16492
|
* `await env.STREAM.videos.createDirectUpload`
|
|
16493
|
+
* `await env.STREAM.clip`
|
|
16487
16494
|
* `await env.STREAM.videos.*`
|
|
16488
16495
|
* `await env.STREAM.watermarks.*`
|
|
16489
16496
|
* - Per-video operations:
|
|
@@ -16530,6 +16537,19 @@ interface StreamBinding {
|
|
|
16530
16537
|
createDirectUpload(
|
|
16531
16538
|
params: StreamDirectUploadCreateParams,
|
|
16532
16539
|
): Promise<StreamDirectUpload>;
|
|
16540
|
+
/**
|
|
16541
|
+
* Creates a new video by clipping a time range from an existing video.
|
|
16542
|
+
* @param videoId The unique identifier of the source video to clip from.
|
|
16543
|
+
* @param params The time range to clip from the source video.
|
|
16544
|
+
* @returns The details of the newly created clip.
|
|
16545
|
+
* @throws {NotFoundError} if the source video is not found
|
|
16546
|
+
* @throws {BadRequestError} if the time range is invalid or extends past the end of the source video
|
|
16547
|
+
* @throws {BadRequestError} if the source video is a live stream recording
|
|
16548
|
+
* @throws {QuotaReachedError} if the account storage capacity is exceeded
|
|
16549
|
+
* @throws {RateLimitedError} if the account has too many videos processing at once
|
|
16550
|
+
* @throws {InternalError} if an unexpected error occurs
|
|
16551
|
+
*/
|
|
16552
|
+
clip(videoId: string, params: StreamClipParams): Promise<StreamVideo>;
|
|
16533
16553
|
videos: StreamVideos;
|
|
16534
16554
|
watermarks: StreamWatermarks;
|
|
16535
16555
|
}
|
|
@@ -16566,10 +16586,13 @@ interface StreamVideoHandle {
|
|
|
16566
16586
|
delete(): Promise<void>;
|
|
16567
16587
|
/**
|
|
16568
16588
|
* Creates a signed URL token for a video.
|
|
16589
|
+
* @param options Optional settings for the token.
|
|
16569
16590
|
* @returns The signed token that was created.
|
|
16591
|
+
* @throws {NotFoundError} if the video is not found
|
|
16592
|
+
* @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
|
|
16570
16593
|
* @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed
|
|
16571
16594
|
*/
|
|
16572
|
-
generateToken(): Promise<string>;
|
|
16595
|
+
generateToken(options?: StreamSignedTokenOptions): Promise<string>;
|
|
16573
16596
|
downloads: StreamScopedDownloads;
|
|
16574
16597
|
captions: StreamScopedCaptions;
|
|
16575
16598
|
}
|
|
@@ -16679,6 +16702,13 @@ interface StreamVideo {
|
|
|
16679
16702
|
* Public details associated with the video.
|
|
16680
16703
|
*/
|
|
16681
16704
|
publicDetails: StreamPublicDetails | null;
|
|
16705
|
+
/**
|
|
16706
|
+
* The unique customer code associated with the video.
|
|
16707
|
+
*
|
|
16708
|
+
* Use this to construct URLs that require a customer code, such as player URLs using signed tokens.
|
|
16709
|
+
* `https://customer-{customerCode}.cloudflarestream.com/{token}/iframe`
|
|
16710
|
+
*/
|
|
16711
|
+
customerCode: string;
|
|
16682
16712
|
}
|
|
16683
16713
|
type StreamVideoStatus = {
|
|
16684
16714
|
/**
|
|
@@ -16837,6 +16867,98 @@ type StreamUrlUploadParams = {
|
|
|
16837
16867
|
*/
|
|
16838
16868
|
watermarkId?: string;
|
|
16839
16869
|
};
|
|
16870
|
+
type StreamClipParams = {
|
|
16871
|
+
/**
|
|
16872
|
+
* The point in the source video, in whole seconds, where the clip starts.
|
|
16873
|
+
*/
|
|
16874
|
+
startTimeSeconds: number;
|
|
16875
|
+
/**
|
|
16876
|
+
* The point in the source video, in whole seconds, where the clip ends.
|
|
16877
|
+
* Must be greater than `startTimeSeconds` and no later than the end of the
|
|
16878
|
+
* source video.
|
|
16879
|
+
*/
|
|
16880
|
+
endTimeSeconds: number;
|
|
16881
|
+
};
|
|
16882
|
+
type StreamSignedTokenOptions = {
|
|
16883
|
+
/**
|
|
16884
|
+
* The signing key to sign the token with. When omitted, the token is signed
|
|
16885
|
+
* with a key Stream manages for the account.
|
|
16886
|
+
*/
|
|
16887
|
+
signingKey?: StreamSigningKey;
|
|
16888
|
+
/**
|
|
16889
|
+
* When the token stops being accepted, as a `Date` or a Unix timestamp in
|
|
16890
|
+
* seconds. Must be in the future and no more than 24 hours from now.
|
|
16891
|
+
* Defaults to one hour from now.
|
|
16892
|
+
*/
|
|
16893
|
+
expiresAt?: Date | number;
|
|
16894
|
+
/**
|
|
16895
|
+
* When the token starts being accepted, as a `Date` or a Unix timestamp in
|
|
16896
|
+
* seconds. Must be earlier than `expiresAt`. Defaults to one hour ago.
|
|
16897
|
+
*/
|
|
16898
|
+
notBefore?: Date | number;
|
|
16899
|
+
/**
|
|
16900
|
+
* Whether the token can also be used to access the video's MP4 downloads.
|
|
16901
|
+
* @default false
|
|
16902
|
+
*/
|
|
16903
|
+
downloadable?: boolean;
|
|
16904
|
+
/**
|
|
16905
|
+
* Rules that allow or block viewers by IP address or country. Rules are
|
|
16906
|
+
* evaluated in order, and the first rule that matches is applied.
|
|
16907
|
+
*/
|
|
16908
|
+
accessRules?: StreamAccessRule[];
|
|
16909
|
+
/**
|
|
16910
|
+
* Additional flags for the token.
|
|
16911
|
+
*/
|
|
16912
|
+
flags?: StreamSignedTokenFlags;
|
|
16913
|
+
};
|
|
16914
|
+
type StreamSigningKey = {
|
|
16915
|
+
/**
|
|
16916
|
+
* The ID of a Stream signing key.
|
|
16917
|
+
*/
|
|
16918
|
+
id: string;
|
|
16919
|
+
/**
|
|
16920
|
+
* The base64-encoded private key, in PEM format, for the signing key.
|
|
16921
|
+
*/
|
|
16922
|
+
pem: string;
|
|
16923
|
+
};
|
|
16924
|
+
type StreamSignedTokenFlags = {
|
|
16925
|
+
/**
|
|
16926
|
+
* Whether the token serves the original video without transformations.
|
|
16927
|
+
* @default false
|
|
16928
|
+
*/
|
|
16929
|
+
original?: boolean;
|
|
16930
|
+
};
|
|
16931
|
+
type StreamAccessRuleAction = "allow" | "block";
|
|
16932
|
+
type StreamAccessRule =
|
|
16933
|
+
| {
|
|
16934
|
+
/**
|
|
16935
|
+
* Matches every request. Use as the last rule to set a default action.
|
|
16936
|
+
*/
|
|
16937
|
+
type: "any";
|
|
16938
|
+
action: StreamAccessRuleAction;
|
|
16939
|
+
}
|
|
16940
|
+
| {
|
|
16941
|
+
/**
|
|
16942
|
+
* Matches requests from the listed IP addresses or CIDR ranges.
|
|
16943
|
+
*/
|
|
16944
|
+
type: "ip.src";
|
|
16945
|
+
action: StreamAccessRuleAction;
|
|
16946
|
+
/**
|
|
16947
|
+
* IPv4 or IPv6 addresses or CIDR ranges.
|
|
16948
|
+
*/
|
|
16949
|
+
ip: string[];
|
|
16950
|
+
}
|
|
16951
|
+
| {
|
|
16952
|
+
/**
|
|
16953
|
+
* Matches requests from the listed countries.
|
|
16954
|
+
*/
|
|
16955
|
+
type: "ip.geoip.country";
|
|
16956
|
+
action: StreamAccessRuleAction;
|
|
16957
|
+
/**
|
|
16958
|
+
* Two-letter ISO 3166-1 alpha-2 country codes.
|
|
16959
|
+
*/
|
|
16960
|
+
country: string[];
|
|
16961
|
+
};
|
|
16840
16962
|
interface StreamScopedCaptions {
|
|
16841
16963
|
/**
|
|
16842
16964
|
* Uploads the caption or subtitle file to the endpoint for a specific BCP47 language.
|
|
@@ -16871,6 +16993,15 @@ interface StreamScopedCaptions {
|
|
|
16871
16993
|
* @throws {InternalError} if an unexpected error occurs
|
|
16872
16994
|
*/
|
|
16873
16995
|
list(language?: string): Promise<StreamCaption[]>;
|
|
16996
|
+
/**
|
|
16997
|
+
* Gets the WebVTT file for a caption or subtitle track.
|
|
16998
|
+
* @param language The BCP 47 language tag of the track.
|
|
16999
|
+
* @returns The track's WebVTT file as a stream.
|
|
17000
|
+
* @throws {NotFoundError} if the video is not found, it has no caption for this language, or a generated caption has not finished
|
|
17001
|
+
* @throws {BadRequestError} if the language is not a valid BCP 47 tag
|
|
17002
|
+
* @throws {InternalError} if an unexpected error occurs
|
|
17003
|
+
*/
|
|
17004
|
+
get(language: string): Promise<ReadableStream>;
|
|
16874
17005
|
/**
|
|
16875
17006
|
* Removes the captions or subtitles from a video.
|
|
16876
17007
|
* @param language The BCP 47 language tag to remove.
|
|
@@ -17220,6 +17351,17 @@ interface AlreadyUploadedError extends StreamError {
|
|
|
17220
17351
|
interface TooManyWatermarksError extends StreamError {
|
|
17221
17352
|
name: "TooManyWatermarksError";
|
|
17222
17353
|
}
|
|
17354
|
+
interface StructuredSerializeOptions {
|
|
17355
|
+
transfer?: any[];
|
|
17356
|
+
}
|
|
17357
|
+
interface ServiceWorkerGlobalScope {
|
|
17358
|
+
structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
|
|
17359
|
+
}
|
|
17360
|
+
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
|
|
17361
|
+
declare function structuredClone<T>(
|
|
17362
|
+
value: T,
|
|
17363
|
+
options?: StructuredSerializeOptions,
|
|
17364
|
+
): T;
|
|
17223
17365
|
type MarkdownDocument = {
|
|
17224
17366
|
name: string;
|
|
17225
17367
|
blob: Blob;
|