@reactor-team/js-sdk 3.0.2 → 3.2.0
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/README.md +63 -11
- package/dist/index.cjs +313 -96
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +63 -25
- package/dist/index.d.ts +63 -25
- package/dist/index.js +313 -96
- package/dist/index.js.map +1 -1
- package/dist/wasm/reactor_wasm.d.ts +57 -6
- package/dist/wasm/reactor_wasm.js +50 -9
- package/dist/wasm/reactor_wasm_bg.wasm.d.ts +1 -0
- package/package.json +1 -1
- package/dist/wasm/reactor_wasm_bg.wasm +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -29,6 +29,8 @@ interface ReactorErrorOptions {
|
|
|
29
29
|
operation?: string | undefined;
|
|
30
30
|
retry_after_ms?: number | undefined;
|
|
31
31
|
timestamp_ms?: number | undefined;
|
|
32
|
+
/** The underlying error, kept as the standard `Error.cause`. */
|
|
33
|
+
cause?: unknown;
|
|
32
34
|
}
|
|
33
35
|
declare class ReactorError extends Error {
|
|
34
36
|
/** The code this class stands for. `ReactorError` itself is the fallback,
|
|
@@ -223,9 +225,16 @@ interface ConnectOptions {
|
|
|
223
225
|
autoResumeTracks?: boolean;
|
|
224
226
|
maxAttempts?: number;
|
|
225
227
|
}
|
|
226
|
-
/**
|
|
227
|
-
*
|
|
228
|
-
|
|
228
|
+
/** What a token is being resolved for. `sessionId` is set for every request
|
|
229
|
+
* that targets an existing session and unset for session creation. A
|
|
230
|
+
* resolver that mints a replacement token must bind it to that session
|
|
231
|
+
* (`resources.sessions.bind`), or the token cannot reach the session. */
|
|
232
|
+
interface JwtRequestContext {
|
|
233
|
+
sessionId?: string;
|
|
234
|
+
}
|
|
235
|
+
/** A token, or a resolver called before every authenticated request with a
|
|
236
|
+
* `JwtRequestContext`. Returning "" sends no Authorization header. */
|
|
237
|
+
type JwtSource = string | ((context?: JwtRequestContext) => string | Promise<string>);
|
|
229
238
|
interface TrackCapability {
|
|
230
239
|
name: string;
|
|
231
240
|
kind: TrackKind;
|
|
@@ -476,7 +485,7 @@ interface ReactorEventMap {
|
|
|
476
485
|
* that want the binding's own identifier (e.g. for
|
|
477
486
|
* `getTrackByMid`/`getStreamByMid`). */
|
|
478
487
|
trackReceived: (name: string, track: MediaStreamTrack, stream: MediaStream, mid: string | undefined) => void;
|
|
479
|
-
/** Fired every `
|
|
488
|
+
/** Fired every `LOCAL_STATS_INTERVAL_MS` while the session is "ready" — see
|
|
480
489
|
* `getStats()`. */
|
|
481
490
|
statsUpdate: (stats: ConnectionStats) => void;
|
|
482
491
|
}
|
|
@@ -549,10 +558,14 @@ interface FetchPlaylistOptions {
|
|
|
549
558
|
*/
|
|
550
559
|
signal?: AbortSignal;
|
|
551
560
|
/**
|
|
552
|
-
* Coordinator JWT
|
|
553
|
-
*
|
|
561
|
+
* Coordinator JWT for the manifest GET: a string, or a resolver called
|
|
562
|
+
* before every poll with `{ sessionId }`, so a long 202 wait can cross a
|
|
563
|
+
* token refresh. Omit in local mode (HttpRuntime).
|
|
554
564
|
*/
|
|
555
|
-
jwt?:
|
|
565
|
+
jwt?: JwtSource;
|
|
566
|
+
/** The clip's session, handed to a resolver `jwt`. `downloadClipAsFile()`
|
|
567
|
+
* fills it from `clip.sessionId`. */
|
|
568
|
+
sessionId?: string;
|
|
556
569
|
}
|
|
557
570
|
/**
|
|
558
571
|
* Fetch `playlistUrl`, polling on `202 Accepted` — returned while the
|
|
@@ -584,9 +597,10 @@ declare function parsePlaylist(manifestBody: string, playlistUrl: string): Parse
|
|
|
584
597
|
*/
|
|
585
598
|
declare function createPlayableManifestUrl(manifestBody: string, playlistUrl: string): string;
|
|
586
599
|
interface DownloadClipOptions {
|
|
587
|
-
/** Coordinator JWT for the manifest GET
|
|
588
|
-
*
|
|
589
|
-
|
|
600
|
+
/** Coordinator JWT for the manifest GET: a string, or a resolver called
|
|
601
|
+
* per poll with `{ sessionId: clip.sessionId }`. The chunks the manifest
|
|
602
|
+
* references are S3 presigned URLs, fetched unauthenticated. */
|
|
603
|
+
jwt?: JwtSource;
|
|
590
604
|
/** Cancels both the playlist poll and any in-flight chunk fetches. */
|
|
591
605
|
signal?: AbortSignal;
|
|
592
606
|
/** Called after each chunk completes — useful for progress UI. */
|
|
@@ -623,11 +637,14 @@ declare class Reactor implements Disposable {
|
|
|
623
637
|
private capabilities;
|
|
624
638
|
private stats;
|
|
625
639
|
private connectionTimings;
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
*
|
|
630
|
-
|
|
640
|
+
/** The stop functions of the running stats pollers — see `pollPeerStats()`. */
|
|
641
|
+
private stopStatsPollers;
|
|
642
|
+
/** Whether this connection has already reported its time to connect —
|
|
643
|
+
* a one-time fact, sent on the first client-stats report that carries it
|
|
644
|
+
* and omitted on every one after. Set only once a batch actually went out
|
|
645
|
+
* with it, so a batch sent before the timings exist doesn't use it up.
|
|
646
|
+
* Reset per `startStatsPolling()` call, i.e. per connect()/reconnect(). */
|
|
647
|
+
private hasSentConnectTime;
|
|
631
648
|
/** Set on the "connecting" status transition, cleared once `connectionTimings`
|
|
632
649
|
* is finalized on "ready" — see `handleStatusChanged()`. */
|
|
633
650
|
private connectStartTime;
|
|
@@ -897,7 +914,7 @@ declare class Reactor implements Disposable {
|
|
|
897
914
|
* rejected call — whichever landed last. `undefined` until the first
|
|
898
915
|
* failure. */
|
|
899
916
|
getLastError(): ReactorError | undefined;
|
|
900
|
-
/** The most recent WebRTC connection stats, polled every `
|
|
917
|
+
/** The most recent WebRTC connection stats, polled every `LOCAL_STATS_INTERVAL_MS`
|
|
901
918
|
* while "ready" — see `statsUpdate`. `undefined` before the first sample. */
|
|
902
919
|
getStats(): ConnectionStats | undefined;
|
|
903
920
|
/** Timing breakdown from the most recent `connect()`/`reconnect()`
|
|
@@ -940,7 +957,24 @@ declare class Reactor implements Disposable {
|
|
|
940
957
|
* → "ready" status sequence (see `ReactorStatus`), and starts/stops stats
|
|
941
958
|
* polling around the "ready" window. */
|
|
942
959
|
private handleStatusChanged;
|
|
960
|
+
/** Starts both stats pollers: the local one updates `getStats()` and emits
|
|
961
|
+
* `statsUpdate`, the runtime one sends a client-stats batch. Each owns the
|
|
962
|
+
* extractor it computes bitrates with, so a bitrate covers its own
|
|
963
|
+
* poller's interval. */
|
|
943
964
|
private startStatsPolling;
|
|
965
|
+
/** Report one quality batch to the runtime: a reading per negotiated
|
|
966
|
+
* track — audio and video, sent and received — see
|
|
967
|
+
* `createTrackStatsExtractor`, and the connection-wide reading — see
|
|
968
|
+
* `toClientConnectionStat`. The connection reading goes even while no
|
|
969
|
+
* track has one yet (none negotiated onto a named track, or no codec
|
|
970
|
+
* reported yet), so the runtime gets the bandwidth estimate, the
|
|
971
|
+
* round-trip time and the time to connect without waiting on the tracks.
|
|
972
|
+
* Skipped only when there is nothing at all to say; one is due again in
|
|
973
|
+
* `RUNTIME_REPORT_INTERVAL_MS`. The time to connect goes on the first batch
|
|
974
|
+
* actually sent for this connection — see `hasSentConnectTime`.
|
|
975
|
+
* `sendClientStats` throws synchronously on a closing connection; caught
|
|
976
|
+
* here for the same reason `getStats()`'s rejection is above. */
|
|
977
|
+
private reportClientStats;
|
|
944
978
|
private stopStatsPolling;
|
|
945
979
|
/** Called on every `disconnect()` and on `[Symbol.dispose]`. Leaves
|
|
946
980
|
* `client`/`schema` alone — that's `freeClient()`'s job, run separately
|
|
@@ -962,8 +996,10 @@ declare class Reactor implements Disposable {
|
|
|
962
996
|
}
|
|
963
997
|
|
|
964
998
|
/** Lazy resolver for a Coordinator/runtime bearer token, called immediately
|
|
965
|
-
* before each authenticated request
|
|
966
|
-
|
|
999
|
+
* before each authenticated request with the session that request is for —
|
|
1000
|
+
* see `JwtSource` and `JwtRequestContext`. A resolver that ignores the
|
|
1001
|
+
* context keeps working. */
|
|
1002
|
+
type JwtResolver = (context?: JwtRequestContext) => string | Promise<string>;
|
|
967
1003
|
/**
|
|
968
1004
|
* Wraps a `JwtSource` into a `JwtResolver`: a static string becomes a
|
|
969
1005
|
* resolver that always returns it, a resolver passes through unchanged.
|
|
@@ -1164,13 +1200,14 @@ interface ClipPlayerProps {
|
|
|
1164
1200
|
clip: Clip;
|
|
1165
1201
|
/**
|
|
1166
1202
|
* Lazy resolver for the Coordinator JWT used on the manifest GET, called
|
|
1167
|
-
*
|
|
1203
|
+
* before every poll with `{ sessionId: clip.sessionId }` so token refreshes
|
|
1204
|
+
* are picked up automatically.
|
|
1168
1205
|
*
|
|
1169
1206
|
* Required outside a `ReactorProvider` in production; optional inside one
|
|
1170
1207
|
* (inherits the provider's resolver). Omit in local-dev mode (HttpRuntime)
|
|
1171
1208
|
* — the manifest endpoint there is auth-free.
|
|
1172
1209
|
*/
|
|
1173
|
-
getJwt?:
|
|
1210
|
+
getJwt?: JwtResolver;
|
|
1174
1211
|
/**
|
|
1175
1212
|
* Opt into a bounded wait: give up polling the manifest with
|
|
1176
1213
|
* `CLIP_NOT_READY` once `max(clip.predictedReadyAtMs, pollStart) + slackMs`
|
|
@@ -1223,13 +1260,14 @@ interface UseClipDownloadOptions {
|
|
|
1223
1260
|
filename?: string | null;
|
|
1224
1261
|
/**
|
|
1225
1262
|
* Lazy resolver for the Coordinator JWT used on the manifest GET. Called
|
|
1226
|
-
*
|
|
1227
|
-
* refreshes are picked up
|
|
1263
|
+
* before every poll of a {@link UseClipDownloadResult.download} with
|
|
1264
|
+
* `{ sessionId: clip.sessionId }`, so token refreshes are picked up
|
|
1265
|
+
* automatically.
|
|
1228
1266
|
*
|
|
1229
1267
|
* Optional inside a `ReactorProvider` (inherits the provider's resolver)
|
|
1230
1268
|
* and in local-dev mode.
|
|
1231
1269
|
*/
|
|
1232
|
-
getJwt?:
|
|
1270
|
+
getJwt?: JwtResolver;
|
|
1233
1271
|
}
|
|
1234
1272
|
interface UseClipDownloadResult {
|
|
1235
1273
|
/** Current state of the most recent download attempt. */
|
|
@@ -1274,7 +1312,7 @@ interface ClipDownloadButtonProps {
|
|
|
1274
1312
|
clip: Clip;
|
|
1275
1313
|
/** Lazy JWT resolver. Optional inside a `ReactorProvider` (inherits the
|
|
1276
1314
|
* provider's resolver) and in local-dev mode. See `ClipPlayerProps.getJwt`. */
|
|
1277
|
-
getJwt?:
|
|
1315
|
+
getJwt?: JwtResolver;
|
|
1278
1316
|
/** Filename for the saved MP4. Default `"reactor-clip.mp4"`. */
|
|
1279
1317
|
filename?: string;
|
|
1280
1318
|
/**
|
|
@@ -1304,4 +1342,4 @@ interface ClipDownloadButtonProps {
|
|
|
1304
1342
|
}
|
|
1305
1343
|
declare function ClipDownloadButton({ clip, getJwt, filename, children, className, style, disabled, onSuccess, onError, }: ClipDownloadButtonProps): react.JSX.Element;
|
|
1306
1344
|
|
|
1307
|
-
export { AbortedError, BadRequestError, type Capabilities, type Clip, ClipDownloadButton, type ClipDownloadButtonProps, type ClipDownloadState, type ClipKind, ClipPlayer, type ClipPlayerProps, type CommandCapability, ConflictError, type ConnectOptions, type ConnectionStats, type ConnectionTimings, DEFAULT_PLAYLIST_POLL_SLACK_MS, DecodeError, DisconnectedError, type DownloadClipOptions, type FetchPlaylistOptions, FileRef, InvalidStateError, type JwtResolver, type JwtSource, type MessageScope, MessageTooLargeError, type ModelSchema, type ModelSchemaOperation, type ModelSchemaPathItem, type ModerationAction, type ModerationEvent, NetworkError, NotFoundError, RateLimitedError, Reactor, type ReactorActions, type ReactorConnectOptions, ReactorError, type ReactorEventMap, type ReactorEventName, type ReactorMessage, type ReactorOptions, ReactorProvider, type ReactorProviderProps, type ReactorState, type ReactorStatus, type ReactorStore, ReactorView, type ReactorViewProps, RecorderDisabledError, RecordingError, RequestTimeoutError, ServerError, type SessionResponse, SessionTerminalError, type TrackCapability, type TrackDirection, type TrackKind, type TrackMappingEntry, TransportError, UnauthorizedError, type UseClipDownloadOptions, type UseClipDownloadResult, VersionMismatchError, WebcamStream, type WebcamStreamProps, createPlayableManifestUrl, downloadClipAsFile, fetchPlaylist, isFileRef, normalizeJwtSource, parsePlaylist, useClipDownload, useReactor, useReactorInternalMessage, useReactorMessage, useStats };
|
|
1345
|
+
export { AbortedError, BadRequestError, type Capabilities, type Clip, ClipDownloadButton, type ClipDownloadButtonProps, type ClipDownloadState, type ClipKind, ClipPlayer, type ClipPlayerProps, type CommandCapability, ConflictError, type ConnectOptions, type ConnectionStats, type ConnectionTimings, DEFAULT_PLAYLIST_POLL_SLACK_MS, DecodeError, DisconnectedError, type DownloadClipOptions, type FetchPlaylistOptions, FileRef, InvalidStateError, type JwtRequestContext, type JwtResolver, type JwtSource, type MessageScope, MessageTooLargeError, type ModelSchema, type ModelSchemaOperation, type ModelSchemaPathItem, type ModerationAction, type ModerationEvent, NetworkError, NotFoundError, RateLimitedError, Reactor, type ReactorActions, type ReactorConnectOptions, ReactorError, type ReactorEventMap, type ReactorEventName, type ReactorMessage, type ReactorOptions, ReactorProvider, type ReactorProviderProps, type ReactorState, type ReactorStatus, type ReactorStore, ReactorView, type ReactorViewProps, RecorderDisabledError, RecordingError, RequestTimeoutError, ServerError, type SessionResponse, SessionTerminalError, type TrackCapability, type TrackDirection, type TrackKind, type TrackMappingEntry, TransportError, UnauthorizedError, type UseClipDownloadOptions, type UseClipDownloadResult, VersionMismatchError, WebcamStream, type WebcamStreamProps, createPlayableManifestUrl, downloadClipAsFile, fetchPlaylist, isFileRef, normalizeJwtSource, parsePlaylist, useClipDownload, useReactor, useReactorInternalMessage, useReactorMessage, useStats };
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ interface ReactorErrorOptions {
|
|
|
29
29
|
operation?: string | undefined;
|
|
30
30
|
retry_after_ms?: number | undefined;
|
|
31
31
|
timestamp_ms?: number | undefined;
|
|
32
|
+
/** The underlying error, kept as the standard `Error.cause`. */
|
|
33
|
+
cause?: unknown;
|
|
32
34
|
}
|
|
33
35
|
declare class ReactorError extends Error {
|
|
34
36
|
/** The code this class stands for. `ReactorError` itself is the fallback,
|
|
@@ -223,9 +225,16 @@ interface ConnectOptions {
|
|
|
223
225
|
autoResumeTracks?: boolean;
|
|
224
226
|
maxAttempts?: number;
|
|
225
227
|
}
|
|
226
|
-
/**
|
|
227
|
-
*
|
|
228
|
-
|
|
228
|
+
/** What a token is being resolved for. `sessionId` is set for every request
|
|
229
|
+
* that targets an existing session and unset for session creation. A
|
|
230
|
+
* resolver that mints a replacement token must bind it to that session
|
|
231
|
+
* (`resources.sessions.bind`), or the token cannot reach the session. */
|
|
232
|
+
interface JwtRequestContext {
|
|
233
|
+
sessionId?: string;
|
|
234
|
+
}
|
|
235
|
+
/** A token, or a resolver called before every authenticated request with a
|
|
236
|
+
* `JwtRequestContext`. Returning "" sends no Authorization header. */
|
|
237
|
+
type JwtSource = string | ((context?: JwtRequestContext) => string | Promise<string>);
|
|
229
238
|
interface TrackCapability {
|
|
230
239
|
name: string;
|
|
231
240
|
kind: TrackKind;
|
|
@@ -476,7 +485,7 @@ interface ReactorEventMap {
|
|
|
476
485
|
* that want the binding's own identifier (e.g. for
|
|
477
486
|
* `getTrackByMid`/`getStreamByMid`). */
|
|
478
487
|
trackReceived: (name: string, track: MediaStreamTrack, stream: MediaStream, mid: string | undefined) => void;
|
|
479
|
-
/** Fired every `
|
|
488
|
+
/** Fired every `LOCAL_STATS_INTERVAL_MS` while the session is "ready" — see
|
|
480
489
|
* `getStats()`. */
|
|
481
490
|
statsUpdate: (stats: ConnectionStats) => void;
|
|
482
491
|
}
|
|
@@ -549,10 +558,14 @@ interface FetchPlaylistOptions {
|
|
|
549
558
|
*/
|
|
550
559
|
signal?: AbortSignal;
|
|
551
560
|
/**
|
|
552
|
-
* Coordinator JWT
|
|
553
|
-
*
|
|
561
|
+
* Coordinator JWT for the manifest GET: a string, or a resolver called
|
|
562
|
+
* before every poll with `{ sessionId }`, so a long 202 wait can cross a
|
|
563
|
+
* token refresh. Omit in local mode (HttpRuntime).
|
|
554
564
|
*/
|
|
555
|
-
jwt?:
|
|
565
|
+
jwt?: JwtSource;
|
|
566
|
+
/** The clip's session, handed to a resolver `jwt`. `downloadClipAsFile()`
|
|
567
|
+
* fills it from `clip.sessionId`. */
|
|
568
|
+
sessionId?: string;
|
|
556
569
|
}
|
|
557
570
|
/**
|
|
558
571
|
* Fetch `playlistUrl`, polling on `202 Accepted` — returned while the
|
|
@@ -584,9 +597,10 @@ declare function parsePlaylist(manifestBody: string, playlistUrl: string): Parse
|
|
|
584
597
|
*/
|
|
585
598
|
declare function createPlayableManifestUrl(manifestBody: string, playlistUrl: string): string;
|
|
586
599
|
interface DownloadClipOptions {
|
|
587
|
-
/** Coordinator JWT for the manifest GET
|
|
588
|
-
*
|
|
589
|
-
|
|
600
|
+
/** Coordinator JWT for the manifest GET: a string, or a resolver called
|
|
601
|
+
* per poll with `{ sessionId: clip.sessionId }`. The chunks the manifest
|
|
602
|
+
* references are S3 presigned URLs, fetched unauthenticated. */
|
|
603
|
+
jwt?: JwtSource;
|
|
590
604
|
/** Cancels both the playlist poll and any in-flight chunk fetches. */
|
|
591
605
|
signal?: AbortSignal;
|
|
592
606
|
/** Called after each chunk completes — useful for progress UI. */
|
|
@@ -623,11 +637,14 @@ declare class Reactor implements Disposable {
|
|
|
623
637
|
private capabilities;
|
|
624
638
|
private stats;
|
|
625
639
|
private connectionTimings;
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
*
|
|
630
|
-
|
|
640
|
+
/** The stop functions of the running stats pollers — see `pollPeerStats()`. */
|
|
641
|
+
private stopStatsPollers;
|
|
642
|
+
/** Whether this connection has already reported its time to connect —
|
|
643
|
+
* a one-time fact, sent on the first client-stats report that carries it
|
|
644
|
+
* and omitted on every one after. Set only once a batch actually went out
|
|
645
|
+
* with it, so a batch sent before the timings exist doesn't use it up.
|
|
646
|
+
* Reset per `startStatsPolling()` call, i.e. per connect()/reconnect(). */
|
|
647
|
+
private hasSentConnectTime;
|
|
631
648
|
/** Set on the "connecting" status transition, cleared once `connectionTimings`
|
|
632
649
|
* is finalized on "ready" — see `handleStatusChanged()`. */
|
|
633
650
|
private connectStartTime;
|
|
@@ -897,7 +914,7 @@ declare class Reactor implements Disposable {
|
|
|
897
914
|
* rejected call — whichever landed last. `undefined` until the first
|
|
898
915
|
* failure. */
|
|
899
916
|
getLastError(): ReactorError | undefined;
|
|
900
|
-
/** The most recent WebRTC connection stats, polled every `
|
|
917
|
+
/** The most recent WebRTC connection stats, polled every `LOCAL_STATS_INTERVAL_MS`
|
|
901
918
|
* while "ready" — see `statsUpdate`. `undefined` before the first sample. */
|
|
902
919
|
getStats(): ConnectionStats | undefined;
|
|
903
920
|
/** Timing breakdown from the most recent `connect()`/`reconnect()`
|
|
@@ -940,7 +957,24 @@ declare class Reactor implements Disposable {
|
|
|
940
957
|
* → "ready" status sequence (see `ReactorStatus`), and starts/stops stats
|
|
941
958
|
* polling around the "ready" window. */
|
|
942
959
|
private handleStatusChanged;
|
|
960
|
+
/** Starts both stats pollers: the local one updates `getStats()` and emits
|
|
961
|
+
* `statsUpdate`, the runtime one sends a client-stats batch. Each owns the
|
|
962
|
+
* extractor it computes bitrates with, so a bitrate covers its own
|
|
963
|
+
* poller's interval. */
|
|
943
964
|
private startStatsPolling;
|
|
965
|
+
/** Report one quality batch to the runtime: a reading per negotiated
|
|
966
|
+
* track — audio and video, sent and received — see
|
|
967
|
+
* `createTrackStatsExtractor`, and the connection-wide reading — see
|
|
968
|
+
* `toClientConnectionStat`. The connection reading goes even while no
|
|
969
|
+
* track has one yet (none negotiated onto a named track, or no codec
|
|
970
|
+
* reported yet), so the runtime gets the bandwidth estimate, the
|
|
971
|
+
* round-trip time and the time to connect without waiting on the tracks.
|
|
972
|
+
* Skipped only when there is nothing at all to say; one is due again in
|
|
973
|
+
* `RUNTIME_REPORT_INTERVAL_MS`. The time to connect goes on the first batch
|
|
974
|
+
* actually sent for this connection — see `hasSentConnectTime`.
|
|
975
|
+
* `sendClientStats` throws synchronously on a closing connection; caught
|
|
976
|
+
* here for the same reason `getStats()`'s rejection is above. */
|
|
977
|
+
private reportClientStats;
|
|
944
978
|
private stopStatsPolling;
|
|
945
979
|
/** Called on every `disconnect()` and on `[Symbol.dispose]`. Leaves
|
|
946
980
|
* `client`/`schema` alone — that's `freeClient()`'s job, run separately
|
|
@@ -962,8 +996,10 @@ declare class Reactor implements Disposable {
|
|
|
962
996
|
}
|
|
963
997
|
|
|
964
998
|
/** Lazy resolver for a Coordinator/runtime bearer token, called immediately
|
|
965
|
-
* before each authenticated request
|
|
966
|
-
|
|
999
|
+
* before each authenticated request with the session that request is for —
|
|
1000
|
+
* see `JwtSource` and `JwtRequestContext`. A resolver that ignores the
|
|
1001
|
+
* context keeps working. */
|
|
1002
|
+
type JwtResolver = (context?: JwtRequestContext) => string | Promise<string>;
|
|
967
1003
|
/**
|
|
968
1004
|
* Wraps a `JwtSource` into a `JwtResolver`: a static string becomes a
|
|
969
1005
|
* resolver that always returns it, a resolver passes through unchanged.
|
|
@@ -1164,13 +1200,14 @@ interface ClipPlayerProps {
|
|
|
1164
1200
|
clip: Clip;
|
|
1165
1201
|
/**
|
|
1166
1202
|
* Lazy resolver for the Coordinator JWT used on the manifest GET, called
|
|
1167
|
-
*
|
|
1203
|
+
* before every poll with `{ sessionId: clip.sessionId }` so token refreshes
|
|
1204
|
+
* are picked up automatically.
|
|
1168
1205
|
*
|
|
1169
1206
|
* Required outside a `ReactorProvider` in production; optional inside one
|
|
1170
1207
|
* (inherits the provider's resolver). Omit in local-dev mode (HttpRuntime)
|
|
1171
1208
|
* — the manifest endpoint there is auth-free.
|
|
1172
1209
|
*/
|
|
1173
|
-
getJwt?:
|
|
1210
|
+
getJwt?: JwtResolver;
|
|
1174
1211
|
/**
|
|
1175
1212
|
* Opt into a bounded wait: give up polling the manifest with
|
|
1176
1213
|
* `CLIP_NOT_READY` once `max(clip.predictedReadyAtMs, pollStart) + slackMs`
|
|
@@ -1223,13 +1260,14 @@ interface UseClipDownloadOptions {
|
|
|
1223
1260
|
filename?: string | null;
|
|
1224
1261
|
/**
|
|
1225
1262
|
* Lazy resolver for the Coordinator JWT used on the manifest GET. Called
|
|
1226
|
-
*
|
|
1227
|
-
* refreshes are picked up
|
|
1263
|
+
* before every poll of a {@link UseClipDownloadResult.download} with
|
|
1264
|
+
* `{ sessionId: clip.sessionId }`, so token refreshes are picked up
|
|
1265
|
+
* automatically.
|
|
1228
1266
|
*
|
|
1229
1267
|
* Optional inside a `ReactorProvider` (inherits the provider's resolver)
|
|
1230
1268
|
* and in local-dev mode.
|
|
1231
1269
|
*/
|
|
1232
|
-
getJwt?:
|
|
1270
|
+
getJwt?: JwtResolver;
|
|
1233
1271
|
}
|
|
1234
1272
|
interface UseClipDownloadResult {
|
|
1235
1273
|
/** Current state of the most recent download attempt. */
|
|
@@ -1274,7 +1312,7 @@ interface ClipDownloadButtonProps {
|
|
|
1274
1312
|
clip: Clip;
|
|
1275
1313
|
/** Lazy JWT resolver. Optional inside a `ReactorProvider` (inherits the
|
|
1276
1314
|
* provider's resolver) and in local-dev mode. See `ClipPlayerProps.getJwt`. */
|
|
1277
|
-
getJwt?:
|
|
1315
|
+
getJwt?: JwtResolver;
|
|
1278
1316
|
/** Filename for the saved MP4. Default `"reactor-clip.mp4"`. */
|
|
1279
1317
|
filename?: string;
|
|
1280
1318
|
/**
|
|
@@ -1304,4 +1342,4 @@ interface ClipDownloadButtonProps {
|
|
|
1304
1342
|
}
|
|
1305
1343
|
declare function ClipDownloadButton({ clip, getJwt, filename, children, className, style, disabled, onSuccess, onError, }: ClipDownloadButtonProps): react.JSX.Element;
|
|
1306
1344
|
|
|
1307
|
-
export { AbortedError, BadRequestError, type Capabilities, type Clip, ClipDownloadButton, type ClipDownloadButtonProps, type ClipDownloadState, type ClipKind, ClipPlayer, type ClipPlayerProps, type CommandCapability, ConflictError, type ConnectOptions, type ConnectionStats, type ConnectionTimings, DEFAULT_PLAYLIST_POLL_SLACK_MS, DecodeError, DisconnectedError, type DownloadClipOptions, type FetchPlaylistOptions, FileRef, InvalidStateError, type JwtResolver, type JwtSource, type MessageScope, MessageTooLargeError, type ModelSchema, type ModelSchemaOperation, type ModelSchemaPathItem, type ModerationAction, type ModerationEvent, NetworkError, NotFoundError, RateLimitedError, Reactor, type ReactorActions, type ReactorConnectOptions, ReactorError, type ReactorEventMap, type ReactorEventName, type ReactorMessage, type ReactorOptions, ReactorProvider, type ReactorProviderProps, type ReactorState, type ReactorStatus, type ReactorStore, ReactorView, type ReactorViewProps, RecorderDisabledError, RecordingError, RequestTimeoutError, ServerError, type SessionResponse, SessionTerminalError, type TrackCapability, type TrackDirection, type TrackKind, type TrackMappingEntry, TransportError, UnauthorizedError, type UseClipDownloadOptions, type UseClipDownloadResult, VersionMismatchError, WebcamStream, type WebcamStreamProps, createPlayableManifestUrl, downloadClipAsFile, fetchPlaylist, isFileRef, normalizeJwtSource, parsePlaylist, useClipDownload, useReactor, useReactorInternalMessage, useReactorMessage, useStats };
|
|
1345
|
+
export { AbortedError, BadRequestError, type Capabilities, type Clip, ClipDownloadButton, type ClipDownloadButtonProps, type ClipDownloadState, type ClipKind, ClipPlayer, type ClipPlayerProps, type CommandCapability, ConflictError, type ConnectOptions, type ConnectionStats, type ConnectionTimings, DEFAULT_PLAYLIST_POLL_SLACK_MS, DecodeError, DisconnectedError, type DownloadClipOptions, type FetchPlaylistOptions, FileRef, InvalidStateError, type JwtRequestContext, type JwtResolver, type JwtSource, type MessageScope, MessageTooLargeError, type ModelSchema, type ModelSchemaOperation, type ModelSchemaPathItem, type ModerationAction, type ModerationEvent, NetworkError, NotFoundError, RateLimitedError, Reactor, type ReactorActions, type ReactorConnectOptions, ReactorError, type ReactorEventMap, type ReactorEventName, type ReactorMessage, type ReactorOptions, ReactorProvider, type ReactorProviderProps, type ReactorState, type ReactorStatus, type ReactorStore, ReactorView, type ReactorViewProps, RecorderDisabledError, RecordingError, RequestTimeoutError, ServerError, type SessionResponse, SessionTerminalError, type TrackCapability, type TrackDirection, type TrackKind, type TrackMappingEntry, TransportError, UnauthorizedError, type UseClipDownloadOptions, type UseClipDownloadResult, VersionMismatchError, WebcamStream, type WebcamStreamProps, createPlayableManifestUrl, downloadClipAsFile, fetchPlaylist, isFileRef, normalizeJwtSource, parsePlaylist, useClipDownload, useReactor, useReactorInternalMessage, useReactorMessage, useStats };
|