@reactor-team/js-sdk 2.11.0 → 2.11.2

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 CHANGED
@@ -112,7 +112,7 @@ For video-to-video models, drop `<WebcamStream>` inside the provider and name th
112
112
 
113
113
  ### Receive messages
114
114
 
115
- Models emit structured messages back to your app, such as progress updates, state snapshots, or custom model events. Subscribe with `useReactorMessage`:
115
+ Models emit structured messages back to your app, such as progress updates, state snapshots, or custom model events. Subscribe with `useReactorMessage`. Select store fields one at a time so a component only re-renders when something it actually uses changes — passing `(s) => s` will rerender on every track frame, status flip, and error:
116
116
 
117
117
  ```tsx
118
118
  import { useReactorMessage } from "@reactor-team/js-sdk";
@@ -135,7 +135,10 @@ function FrameCounter() {
135
135
  Bind an `<input type="file">` to the model with `uploadFile` and then pass the returned [`FileRef`](https://docs.reactor.inc/api-reference/types#fileref) into any command:
136
136
 
137
137
  ```tsx
138
- const { uploadFile, sendCommand } = useReactor((s) => s);
138
+ const { uploadFile, sendCommand } = useReactor((s) => ({
139
+ uploadFile: s.uploadFile,
140
+ sendCommand: s.sendCommand,
141
+ }));
139
142
 
140
143
  const ref = await uploadFile(file);
141
144
  await sendCommand("set_image", { image: ref });
@@ -153,18 +156,17 @@ import { Reactor } from "@reactor-team/js-sdk";
153
156
  const reactor = new Reactor({
154
157
  apiUrl: "https://api.reactor.inc",
155
158
  modelName: "your-model-name",
156
- jwtToken: await fetchJwt(),
157
159
  });
158
160
 
159
- reactor.on("statusChange", (status) => console.log("status:", status));
161
+ reactor.on("statusChanged", (status) => console.log("status:", status));
160
162
  reactor.on("message", (msg) => console.log("model:", msg));
163
+ reactor.on("trackReceived", (name, _track, stream) => {
164
+ if (name === "main_video") videoEl.srcObject = stream;
165
+ });
161
166
 
162
- await reactor.connect();
167
+ await reactor.connect(await fetchJwt());
163
168
 
164
169
  await reactor.sendCommand("set_prompt", { prompt: "a forest at dawn" });
165
-
166
- const stream = reactor.getMediaStream("main_video");
167
- videoEl.srcObject = stream;
168
170
  ```
169
171
 
170
172
  ---
package/dist/index.d.mts CHANGED
@@ -136,6 +136,13 @@ interface ReactorState$1 {
136
136
  interface ConnectOptions {
137
137
  /** Maximum number of SDP polling attempts before giving up. Default: 6. */
138
138
  maxAttempts?: number;
139
+ /**
140
+ * Attach to a session that already exists (e.g. one created by a backend)
141
+ * instead of creating a new one. When set, `connect()` skips `POST /sessions`
142
+ * and brings up the transport directly against this id. The JWT passed to
143
+ * `connect()` must be valid for the account that owns the session.
144
+ */
145
+ sessionId?: string;
139
146
  }
140
147
  /**
141
148
  * Transport-agnostic timing breakdown of the connect() handshake, recorded
@@ -177,6 +184,50 @@ interface ConnectionStats {
177
184
  timestamp: number;
178
185
  }
179
186
  type ReactorEvent = "statusChanged" | "sessionIdChanged" | "message" | "runtimeMessage" | "trackReceived" | "error" | "sessionExpirationChanged" | "capabilitiesReceived" | "statsUpdate";
187
+ /**
188
+ * Severity tier of a content moderation event delivered as the inner
189
+ * payload of a `runtimeMessage` with `type === "moderation"`.
190
+ *
191
+ * - `"warn"`: the input scored above the warn threshold but below the
192
+ * terminate threshold. The session continues; this is informational
193
+ * only.
194
+ * - `"terminate"`: the input crossed the terminate threshold. The
195
+ * session will be ended shortly after this message is dispatched.
196
+ */
197
+ type ModerationAction = "warn" | "terminate";
198
+ /**
199
+ * Inner payload of a `runtimeMessage` with `type === "moderation"`.
200
+ *
201
+ * Surfaces a content-moderation outcome to the client app. Fires on
202
+ * any moderatable input (free-text fields, file uploads) that the
203
+ * configured moderation policy flags. Apps receive it by subscribing
204
+ * to the existing `runtimeMessage` event and filtering on `type`:
205
+ *
206
+ * reactor.on("runtimeMessage", (m) => {
207
+ * if (m?.type === "moderation") {
208
+ * const payload = m.data as ModerationEvent;
209
+ * // ...render banner, log, etc.
210
+ * }
211
+ * });
212
+ */
213
+ interface ModerationEvent {
214
+ /** Severity tier — `"warn"` continues the session, `"terminate"` ends it. */
215
+ action: ModerationAction;
216
+ /**
217
+ * Modality of the flagged input. `"text"` for string fields,
218
+ * `"image"` for `UploadedFile` payloads with an image MIME type.
219
+ */
220
+ input_kind: "text" | "image";
221
+ /**
222
+ * Name of the inbound command/event whose payload was flagged
223
+ * (e.g. `"set_prompt"`, `"set_image"`, `"fileUploaded"`).
224
+ */
225
+ command: string;
226
+ /** Category labels that flagged (e.g. `["sexual"]`, `["violence/graphic"]`). */
227
+ categories: string[];
228
+ /** Short human-readable summary suitable for UI rendering. */
229
+ message: string;
230
+ }
180
231
 
181
232
  /**
182
233
  * Lazy resolver for the Coordinator bearer token. The SDK calls this
@@ -676,6 +727,12 @@ declare class Reactor {
676
727
  * be a static string or a {@link JwtSource} resolver; pass a
677
728
  * resolver when the token is short-lived so each Coordinator HTTP
678
729
  * hop sees a fresh value.
730
+ *
731
+ * Pass `options.sessionId` to attach to a session that already exists
732
+ * (e.g. one created by a backend) instead of creating a new one — session
733
+ * creation is skipped and the transport is brought up against that id. The
734
+ * `jwtToken` must be valid for the account that owns the session. Works in
735
+ * local mode too (it looks the session up by id rather than starting one).
679
736
  */
680
737
  connect(jwtToken?: JwtSource, options?: ConnectOptions): Promise<void>;
681
738
  /**
@@ -719,6 +776,11 @@ interface ReactorState {
719
776
  }
720
777
  interface ReactorActions {
721
778
  sendCommand(command: string, data: any, scope?: MessageScope): Promise<void>;
779
+ /**
780
+ * Connect the underlying {@link Reactor}. `options` is forwarded verbatim —
781
+ * pass `options.sessionId` to attach to an existing session instead of
782
+ * creating one (see {@link ConnectOptions}).
783
+ */
722
784
  connect(jwtToken?: JwtSource, options?: ConnectOptions): Promise<void>;
723
785
  disconnect(recoverable?: boolean): Promise<void>;
724
786
  publish(name: string, track: MediaStreamTrack): Promise<void>;
@@ -727,6 +789,27 @@ interface ReactorActions {
727
789
  uploadFile(file: File | Blob, options?: {
728
790
  name?: string;
729
791
  }): Promise<FileRef>;
792
+ /**
793
+ * Capture the trailing `durationSeconds` of the live session as a
794
+ * clip. Top-level alias for `internal.reactor.requestClip(…)` —
795
+ * lifted onto the store so consumers don't have to reach through
796
+ * `internal.reactor` for the common case. See
797
+ * {@link Reactor.requestClip}.
798
+ */
799
+ requestClip(durationSeconds: number): Promise<Clip>;
800
+ /**
801
+ * Capture the entire session up to "now" as a clip. Top-level
802
+ * alias for `internal.reactor.requestRecording()`. See
803
+ * {@link Reactor.requestRecording}.
804
+ */
805
+ requestRecording(): Promise<Clip>;
806
+ /**
807
+ * Stream the chunks referenced by `clip.playlistUrl` and trigger a
808
+ * native browser download of the assembled MP4. Top-level alias
809
+ * for `internal.reactor.downloadClipAsFile(…)`. See
810
+ * {@link Reactor.downloadClipAsFile}.
811
+ */
812
+ downloadClipAsFile(clip: Clip, filename?: string | null, options?: DownloadClipOptions): Promise<Blob>;
730
813
  }
731
814
  interface ReactorInternalState {
732
815
  reactor: Reactor;
@@ -784,7 +867,13 @@ interface ReactorViewProps {
784
867
  className?: string;
785
868
  style?: React.CSSProperties;
786
869
  videoObjectFit?: NonNullable<React.VideoHTMLAttributes<HTMLVideoElement>["style"]>["objectFit"];
787
- /** Controls whether inbound audio plays. Default true (muted) to satisfy browser autoplay policies. */
870
+ /**
871
+ * Controls whether inbound audio plays. Default is `true`
872
+ * (muted) when no `audioTrack` is set — keeps the underlying
873
+ * `<video>` element within browser autoplay policies; `false`
874
+ * when an `audioTrack` is set. Pass an explicit value to
875
+ * override either default.
876
+ */
788
877
  muted?: boolean;
789
878
  }
790
879
  declare function ReactorView({ track, audioTrack, width, height, className, style, videoObjectFit, muted, }: ReactorViewProps): react_jsx_runtime.JSX.Element;
@@ -797,18 +886,49 @@ declare function ReactorController({ className, style, }: ReactorControllerProps
797
886
 
798
887
  interface WebcamStreamProps {
799
888
  /**
800
- * The name of the sendonly track to publish the webcam to.
889
+ * The name of the sendonly **video** track to publish the webcam to.
801
890
  * Must match a track name declared in the server capabilities.
802
891
  * Check the model's documentation for available track names.
803
892
  */
804
893
  track: string;
894
+ /**
895
+ * Capture and publish the microphone alongside the webcam. Pass
896
+ * `true` for default constraints, or an explicit
897
+ * `MediaTrackConstraints` to control sample rate / device / echo
898
+ * cancellation. Requires {@link audioTrack} so the SDK knows
899
+ * which sendonly track to publish the mic to. Default `false`.
900
+ */
901
+ audio?: boolean | MediaTrackConstraints;
902
+ /**
903
+ * The name of the sendonly **audio** track to publish the mic to.
904
+ * Ignored when {@link audio} is `false` (the default); required
905
+ * otherwise.
906
+ */
907
+ audioTrack?: string;
805
908
  className?: string;
806
909
  style?: React.CSSProperties;
807
910
  videoConstraints?: MediaTrackConstraints;
808
911
  showWebcam?: boolean;
809
912
  videoObjectFit?: NonNullable<React.VideoHTMLAttributes<HTMLVideoElement>["style"]>["objectFit"];
913
+ /**
914
+ * Fires once `getUserMedia` is rejected with `NotAllowedError`
915
+ * or `PermissionDeniedError`.
916
+ */
917
+ onPermissionDenied?: () => void;
918
+ /**
919
+ * Fires after the local media stream has been published (both
920
+ * video and audio when {@link audio} is enabled). Re-fires
921
+ * after a reconnect.
922
+ */
923
+ onPublished?: () => void;
924
+ /**
925
+ * Fires on non-permission `getUserMedia` failures and on
926
+ * publish / unpublish rejections. Permission denials route to
927
+ * {@link onPermissionDenied} instead.
928
+ */
929
+ onError?: (error: Error) => void;
810
930
  }
811
- declare function WebcamStream({ track, className, style, videoConstraints, showWebcam, videoObjectFit, }: WebcamStreamProps): react_jsx_runtime.JSX.Element;
931
+ declare function WebcamStream({ track, audio, audioTrack, className, style, videoConstraints, showWebcam, videoObjectFit, onPermissionDenied, onPublished, onError, }: WebcamStreamProps): react_jsx_runtime.JSX.Element;
812
932
 
813
933
  /**
814
934
  * Video preview for a captured {@link Clip}.
@@ -893,8 +1013,15 @@ interface ClipPlayerProps {
893
1013
  muted?: boolean;
894
1014
  className?: string;
895
1015
  style?: React.CSSProperties;
1016
+ /**
1017
+ * Fires when the player enters its inline error state. Receives
1018
+ * the originating error: a ``RecordingError`` for manifest-fetch
1019
+ * failures, a plain ``Error`` for hls.js / native playback or
1020
+ * missing-peer-dep cases.
1021
+ */
1022
+ onError?: (error: Error) => void;
896
1023
  }
897
- declare function ClipPlayer({ clip, getJwt, slackMs, autoPlay, muted, className, style, }: ClipPlayerProps): react_jsx_runtime.JSX.Element;
1024
+ declare function ClipPlayer({ clip, getJwt, slackMs, autoPlay, muted, className, style, onError, }: ClipPlayerProps): react_jsx_runtime.JSX.Element;
898
1025
 
899
1026
  /**
900
1027
  * State machine for an in-progress clip download.
@@ -1050,8 +1177,18 @@ interface ClipDownloadButtonProps {
1050
1177
  style?: React.CSSProperties;
1051
1178
  /** Forwarded to the underlying ``<button>``. ORed with the internal "downloading" state. */
1052
1179
  disabled?: boolean;
1180
+ /**
1181
+ * Fires when the download completes with the assembled MP4 ``Blob``.
1182
+ */
1183
+ onSuccess?: (blob: Blob) => void;
1184
+ /**
1185
+ * Fires when the download fails. Message mirrors the in-button
1186
+ * state — ``"<CODE>: <reason>"`` for ``RecordingError``s, the
1187
+ * plain error message otherwise.
1188
+ */
1189
+ onError?: (error: Error) => void;
1053
1190
  }
1054
- declare function ClipDownloadButton({ clip, getJwt, filename, children, className, style, disabled, }: ClipDownloadButtonProps): react_jsx_runtime.JSX.Element;
1191
+ declare function ClipDownloadButton({ clip, getJwt, filename, children, className, style, disabled, onSuccess, onError, }: ClipDownloadButtonProps): react_jsx_runtime.JSX.Element;
1055
1192
 
1056
1193
  /**
1057
1194
  * Generic hook for accessing selected parts of the Reactor store.
@@ -1086,4 +1223,4 @@ declare function useReactorInternalMessage(handler: (message: any) => void): voi
1086
1223
  */
1087
1224
  declare function useStats(): ConnectionStats | undefined;
1088
1225
 
1089
- export { AbortError, type Capabilities, type Clip, ClipDownloadButton, type ClipDownloadButtonProps, type ClipDownloadState, type ClipFailedPayload, type ClipKind, ClipPlayer, type ClipPlayerProps, type ClipReadyPayload, type CommandCapability, ConflictError, type ConnectOptions, type ConnectionStats, type ConnectionTimings, DEFAULT_BASE_URL, DEFAULT_CLIP_REQUEST_TIMEOUT_MS, DEFAULT_PLAYLIST_POLL_SLACK_MS, type DownloadClipOptions, type FetchPlaylistOptions, FileRef, type JwtResolver, type JwtSource, type MessageScope, type Options, type ParseClipOptions, Reactor, type ReactorConnectOptions, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, type ReactorStore, ReactorView, type ReactorViewProps, RecordingClient, type RecordingClientHost, RecordingError, RuntimeRecordingMessageType, type SessionResponse, type TrackCapability, type UseClipDownloadOptions, type UseClipDownloadResult, WebcamStream, type WebcamStreamProps, clipFromPayload, createPlayableManifestUrl, downloadClipAsFile, fetchPlaylist, isAbortError, normalizeJwtSource, parsePlaylist, rewriteUrlHost, useClipDownload, useReactor, useReactorInternalMessage, useReactorMessage, useReactorStore, useStats };
1226
+ export { AbortError, type Capabilities, type Clip, ClipDownloadButton, type ClipDownloadButtonProps, type ClipDownloadState, type ClipFailedPayload, type ClipKind, ClipPlayer, type ClipPlayerProps, type ClipReadyPayload, type CommandCapability, ConflictError, type ConnectOptions, type ConnectionStats, type ConnectionTimings, DEFAULT_BASE_URL, DEFAULT_CLIP_REQUEST_TIMEOUT_MS, DEFAULT_PLAYLIST_POLL_SLACK_MS, type DownloadClipOptions, type FetchPlaylistOptions, FileRef, type JwtResolver, type JwtSource, type MessageScope, type ModerationAction, type ModerationEvent, type Options, type ParseClipOptions, Reactor, type ReactorConnectOptions, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, type ReactorStore, ReactorView, type ReactorViewProps, RecordingClient, type RecordingClientHost, RecordingError, RuntimeRecordingMessageType, type SessionResponse, type TrackCapability, type UseClipDownloadOptions, type UseClipDownloadResult, WebcamStream, type WebcamStreamProps, clipFromPayload, createPlayableManifestUrl, downloadClipAsFile, fetchPlaylist, isAbortError, normalizeJwtSource, parsePlaylist, rewriteUrlHost, useClipDownload, useReactor, useReactorInternalMessage, useReactorMessage, useReactorStore, useStats };
package/dist/index.d.ts CHANGED
@@ -136,6 +136,13 @@ interface ReactorState$1 {
136
136
  interface ConnectOptions {
137
137
  /** Maximum number of SDP polling attempts before giving up. Default: 6. */
138
138
  maxAttempts?: number;
139
+ /**
140
+ * Attach to a session that already exists (e.g. one created by a backend)
141
+ * instead of creating a new one. When set, `connect()` skips `POST /sessions`
142
+ * and brings up the transport directly against this id. The JWT passed to
143
+ * `connect()` must be valid for the account that owns the session.
144
+ */
145
+ sessionId?: string;
139
146
  }
140
147
  /**
141
148
  * Transport-agnostic timing breakdown of the connect() handshake, recorded
@@ -177,6 +184,50 @@ interface ConnectionStats {
177
184
  timestamp: number;
178
185
  }
179
186
  type ReactorEvent = "statusChanged" | "sessionIdChanged" | "message" | "runtimeMessage" | "trackReceived" | "error" | "sessionExpirationChanged" | "capabilitiesReceived" | "statsUpdate";
187
+ /**
188
+ * Severity tier of a content moderation event delivered as the inner
189
+ * payload of a `runtimeMessage` with `type === "moderation"`.
190
+ *
191
+ * - `"warn"`: the input scored above the warn threshold but below the
192
+ * terminate threshold. The session continues; this is informational
193
+ * only.
194
+ * - `"terminate"`: the input crossed the terminate threshold. The
195
+ * session will be ended shortly after this message is dispatched.
196
+ */
197
+ type ModerationAction = "warn" | "terminate";
198
+ /**
199
+ * Inner payload of a `runtimeMessage` with `type === "moderation"`.
200
+ *
201
+ * Surfaces a content-moderation outcome to the client app. Fires on
202
+ * any moderatable input (free-text fields, file uploads) that the
203
+ * configured moderation policy flags. Apps receive it by subscribing
204
+ * to the existing `runtimeMessage` event and filtering on `type`:
205
+ *
206
+ * reactor.on("runtimeMessage", (m) => {
207
+ * if (m?.type === "moderation") {
208
+ * const payload = m.data as ModerationEvent;
209
+ * // ...render banner, log, etc.
210
+ * }
211
+ * });
212
+ */
213
+ interface ModerationEvent {
214
+ /** Severity tier — `"warn"` continues the session, `"terminate"` ends it. */
215
+ action: ModerationAction;
216
+ /**
217
+ * Modality of the flagged input. `"text"` for string fields,
218
+ * `"image"` for `UploadedFile` payloads with an image MIME type.
219
+ */
220
+ input_kind: "text" | "image";
221
+ /**
222
+ * Name of the inbound command/event whose payload was flagged
223
+ * (e.g. `"set_prompt"`, `"set_image"`, `"fileUploaded"`).
224
+ */
225
+ command: string;
226
+ /** Category labels that flagged (e.g. `["sexual"]`, `["violence/graphic"]`). */
227
+ categories: string[];
228
+ /** Short human-readable summary suitable for UI rendering. */
229
+ message: string;
230
+ }
180
231
 
181
232
  /**
182
233
  * Lazy resolver for the Coordinator bearer token. The SDK calls this
@@ -676,6 +727,12 @@ declare class Reactor {
676
727
  * be a static string or a {@link JwtSource} resolver; pass a
677
728
  * resolver when the token is short-lived so each Coordinator HTTP
678
729
  * hop sees a fresh value.
730
+ *
731
+ * Pass `options.sessionId` to attach to a session that already exists
732
+ * (e.g. one created by a backend) instead of creating a new one — session
733
+ * creation is skipped and the transport is brought up against that id. The
734
+ * `jwtToken` must be valid for the account that owns the session. Works in
735
+ * local mode too (it looks the session up by id rather than starting one).
679
736
  */
680
737
  connect(jwtToken?: JwtSource, options?: ConnectOptions): Promise<void>;
681
738
  /**
@@ -719,6 +776,11 @@ interface ReactorState {
719
776
  }
720
777
  interface ReactorActions {
721
778
  sendCommand(command: string, data: any, scope?: MessageScope): Promise<void>;
779
+ /**
780
+ * Connect the underlying {@link Reactor}. `options` is forwarded verbatim —
781
+ * pass `options.sessionId` to attach to an existing session instead of
782
+ * creating one (see {@link ConnectOptions}).
783
+ */
722
784
  connect(jwtToken?: JwtSource, options?: ConnectOptions): Promise<void>;
723
785
  disconnect(recoverable?: boolean): Promise<void>;
724
786
  publish(name: string, track: MediaStreamTrack): Promise<void>;
@@ -727,6 +789,27 @@ interface ReactorActions {
727
789
  uploadFile(file: File | Blob, options?: {
728
790
  name?: string;
729
791
  }): Promise<FileRef>;
792
+ /**
793
+ * Capture the trailing `durationSeconds` of the live session as a
794
+ * clip. Top-level alias for `internal.reactor.requestClip(…)` —
795
+ * lifted onto the store so consumers don't have to reach through
796
+ * `internal.reactor` for the common case. See
797
+ * {@link Reactor.requestClip}.
798
+ */
799
+ requestClip(durationSeconds: number): Promise<Clip>;
800
+ /**
801
+ * Capture the entire session up to "now" as a clip. Top-level
802
+ * alias for `internal.reactor.requestRecording()`. See
803
+ * {@link Reactor.requestRecording}.
804
+ */
805
+ requestRecording(): Promise<Clip>;
806
+ /**
807
+ * Stream the chunks referenced by `clip.playlistUrl` and trigger a
808
+ * native browser download of the assembled MP4. Top-level alias
809
+ * for `internal.reactor.downloadClipAsFile(…)`. See
810
+ * {@link Reactor.downloadClipAsFile}.
811
+ */
812
+ downloadClipAsFile(clip: Clip, filename?: string | null, options?: DownloadClipOptions): Promise<Blob>;
730
813
  }
731
814
  interface ReactorInternalState {
732
815
  reactor: Reactor;
@@ -784,7 +867,13 @@ interface ReactorViewProps {
784
867
  className?: string;
785
868
  style?: React.CSSProperties;
786
869
  videoObjectFit?: NonNullable<React.VideoHTMLAttributes<HTMLVideoElement>["style"]>["objectFit"];
787
- /** Controls whether inbound audio plays. Default true (muted) to satisfy browser autoplay policies. */
870
+ /**
871
+ * Controls whether inbound audio plays. Default is `true`
872
+ * (muted) when no `audioTrack` is set — keeps the underlying
873
+ * `<video>` element within browser autoplay policies; `false`
874
+ * when an `audioTrack` is set. Pass an explicit value to
875
+ * override either default.
876
+ */
788
877
  muted?: boolean;
789
878
  }
790
879
  declare function ReactorView({ track, audioTrack, width, height, className, style, videoObjectFit, muted, }: ReactorViewProps): react_jsx_runtime.JSX.Element;
@@ -797,18 +886,49 @@ declare function ReactorController({ className, style, }: ReactorControllerProps
797
886
 
798
887
  interface WebcamStreamProps {
799
888
  /**
800
- * The name of the sendonly track to publish the webcam to.
889
+ * The name of the sendonly **video** track to publish the webcam to.
801
890
  * Must match a track name declared in the server capabilities.
802
891
  * Check the model's documentation for available track names.
803
892
  */
804
893
  track: string;
894
+ /**
895
+ * Capture and publish the microphone alongside the webcam. Pass
896
+ * `true` for default constraints, or an explicit
897
+ * `MediaTrackConstraints` to control sample rate / device / echo
898
+ * cancellation. Requires {@link audioTrack} so the SDK knows
899
+ * which sendonly track to publish the mic to. Default `false`.
900
+ */
901
+ audio?: boolean | MediaTrackConstraints;
902
+ /**
903
+ * The name of the sendonly **audio** track to publish the mic to.
904
+ * Ignored when {@link audio} is `false` (the default); required
905
+ * otherwise.
906
+ */
907
+ audioTrack?: string;
805
908
  className?: string;
806
909
  style?: React.CSSProperties;
807
910
  videoConstraints?: MediaTrackConstraints;
808
911
  showWebcam?: boolean;
809
912
  videoObjectFit?: NonNullable<React.VideoHTMLAttributes<HTMLVideoElement>["style"]>["objectFit"];
913
+ /**
914
+ * Fires once `getUserMedia` is rejected with `NotAllowedError`
915
+ * or `PermissionDeniedError`.
916
+ */
917
+ onPermissionDenied?: () => void;
918
+ /**
919
+ * Fires after the local media stream has been published (both
920
+ * video and audio when {@link audio} is enabled). Re-fires
921
+ * after a reconnect.
922
+ */
923
+ onPublished?: () => void;
924
+ /**
925
+ * Fires on non-permission `getUserMedia` failures and on
926
+ * publish / unpublish rejections. Permission denials route to
927
+ * {@link onPermissionDenied} instead.
928
+ */
929
+ onError?: (error: Error) => void;
810
930
  }
811
- declare function WebcamStream({ track, className, style, videoConstraints, showWebcam, videoObjectFit, }: WebcamStreamProps): react_jsx_runtime.JSX.Element;
931
+ declare function WebcamStream({ track, audio, audioTrack, className, style, videoConstraints, showWebcam, videoObjectFit, onPermissionDenied, onPublished, onError, }: WebcamStreamProps): react_jsx_runtime.JSX.Element;
812
932
 
813
933
  /**
814
934
  * Video preview for a captured {@link Clip}.
@@ -893,8 +1013,15 @@ interface ClipPlayerProps {
893
1013
  muted?: boolean;
894
1014
  className?: string;
895
1015
  style?: React.CSSProperties;
1016
+ /**
1017
+ * Fires when the player enters its inline error state. Receives
1018
+ * the originating error: a ``RecordingError`` for manifest-fetch
1019
+ * failures, a plain ``Error`` for hls.js / native playback or
1020
+ * missing-peer-dep cases.
1021
+ */
1022
+ onError?: (error: Error) => void;
896
1023
  }
897
- declare function ClipPlayer({ clip, getJwt, slackMs, autoPlay, muted, className, style, }: ClipPlayerProps): react_jsx_runtime.JSX.Element;
1024
+ declare function ClipPlayer({ clip, getJwt, slackMs, autoPlay, muted, className, style, onError, }: ClipPlayerProps): react_jsx_runtime.JSX.Element;
898
1025
 
899
1026
  /**
900
1027
  * State machine for an in-progress clip download.
@@ -1050,8 +1177,18 @@ interface ClipDownloadButtonProps {
1050
1177
  style?: React.CSSProperties;
1051
1178
  /** Forwarded to the underlying ``<button>``. ORed with the internal "downloading" state. */
1052
1179
  disabled?: boolean;
1180
+ /**
1181
+ * Fires when the download completes with the assembled MP4 ``Blob``.
1182
+ */
1183
+ onSuccess?: (blob: Blob) => void;
1184
+ /**
1185
+ * Fires when the download fails. Message mirrors the in-button
1186
+ * state — ``"<CODE>: <reason>"`` for ``RecordingError``s, the
1187
+ * plain error message otherwise.
1188
+ */
1189
+ onError?: (error: Error) => void;
1053
1190
  }
1054
- declare function ClipDownloadButton({ clip, getJwt, filename, children, className, style, disabled, }: ClipDownloadButtonProps): react_jsx_runtime.JSX.Element;
1191
+ declare function ClipDownloadButton({ clip, getJwt, filename, children, className, style, disabled, onSuccess, onError, }: ClipDownloadButtonProps): react_jsx_runtime.JSX.Element;
1055
1192
 
1056
1193
  /**
1057
1194
  * Generic hook for accessing selected parts of the Reactor store.
@@ -1086,4 +1223,4 @@ declare function useReactorInternalMessage(handler: (message: any) => void): voi
1086
1223
  */
1087
1224
  declare function useStats(): ConnectionStats | undefined;
1088
1225
 
1089
- export { AbortError, type Capabilities, type Clip, ClipDownloadButton, type ClipDownloadButtonProps, type ClipDownloadState, type ClipFailedPayload, type ClipKind, ClipPlayer, type ClipPlayerProps, type ClipReadyPayload, type CommandCapability, ConflictError, type ConnectOptions, type ConnectionStats, type ConnectionTimings, DEFAULT_BASE_URL, DEFAULT_CLIP_REQUEST_TIMEOUT_MS, DEFAULT_PLAYLIST_POLL_SLACK_MS, type DownloadClipOptions, type FetchPlaylistOptions, FileRef, type JwtResolver, type JwtSource, type MessageScope, type Options, type ParseClipOptions, Reactor, type ReactorConnectOptions, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, type ReactorStore, ReactorView, type ReactorViewProps, RecordingClient, type RecordingClientHost, RecordingError, RuntimeRecordingMessageType, type SessionResponse, type TrackCapability, type UseClipDownloadOptions, type UseClipDownloadResult, WebcamStream, type WebcamStreamProps, clipFromPayload, createPlayableManifestUrl, downloadClipAsFile, fetchPlaylist, isAbortError, normalizeJwtSource, parsePlaylist, rewriteUrlHost, useClipDownload, useReactor, useReactorInternalMessage, useReactorMessage, useReactorStore, useStats };
1226
+ export { AbortError, type Capabilities, type Clip, ClipDownloadButton, type ClipDownloadButtonProps, type ClipDownloadState, type ClipFailedPayload, type ClipKind, ClipPlayer, type ClipPlayerProps, type ClipReadyPayload, type CommandCapability, ConflictError, type ConnectOptions, type ConnectionStats, type ConnectionTimings, DEFAULT_BASE_URL, DEFAULT_CLIP_REQUEST_TIMEOUT_MS, DEFAULT_PLAYLIST_POLL_SLACK_MS, type DownloadClipOptions, type FetchPlaylistOptions, FileRef, type JwtResolver, type JwtSource, type MessageScope, type ModerationAction, type ModerationEvent, type Options, type ParseClipOptions, Reactor, type ReactorConnectOptions, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, type ReactorStore, ReactorView, type ReactorViewProps, RecordingClient, type RecordingClientHost, RecordingError, RuntimeRecordingMessageType, type SessionResponse, type TrackCapability, type UseClipDownloadOptions, type UseClipDownloadResult, WebcamStream, type WebcamStreamProps, clipFromPayload, createPlayableManifestUrl, downloadClipAsFile, fetchPlaylist, isAbortError, normalizeJwtSource, parsePlaylist, rewriteUrlHost, useClipDownload, useReactor, useReactorInternalMessage, useReactorMessage, useReactorStore, useStats };