@reactor-team/js-sdk 2.4.0 → 2.5.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/dist/index.d.mts +138 -20
- package/dist/index.d.ts +138 -20
- package/dist/index.js +332 -127
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +330 -127
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -9,6 +9,81 @@ type ReactorStatus = "disconnected" | "connecting" | "waiting" | "ready";
|
|
|
9
9
|
* - "runtime": platform-level control messages (e.g., capabilities exchange).
|
|
10
10
|
*/
|
|
11
11
|
type MessageScope = "application" | "runtime";
|
|
12
|
+
/**
|
|
13
|
+
* Describes a single named media track for SDP negotiation.
|
|
14
|
+
*
|
|
15
|
+
* Track names must exactly match the class attribute names defined on the
|
|
16
|
+
* model's Python code. The name is encoded as the SDP MID so both sides
|
|
17
|
+
* can route media by name rather than by positional index.
|
|
18
|
+
*
|
|
19
|
+
* Use the {@link video} and {@link audio} helper functions to create
|
|
20
|
+
* instances instead of constructing this interface directly.
|
|
21
|
+
*/
|
|
22
|
+
interface TrackConfig {
|
|
23
|
+
name: string;
|
|
24
|
+
kind: "audio" | "video";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Optional configuration for a video track (reserved for future use).
|
|
28
|
+
*/
|
|
29
|
+
interface VideoTrackOptions {
|
|
30
|
+
/** Maximum framerate constraint for the video track. */
|
|
31
|
+
maxFramerate?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Optional configuration for an audio track (reserved for future use).
|
|
35
|
+
*/
|
|
36
|
+
interface AudioTrackOptions {
|
|
37
|
+
/** Sample rate constraint for the audio track. */
|
|
38
|
+
sampleRate?: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates a **video** {@link TrackConfig}.
|
|
42
|
+
*
|
|
43
|
+
* A track declared in the **`receive`** array means the client will
|
|
44
|
+
* **RECEIVE** video frames **from the model** (model → client).
|
|
45
|
+
*
|
|
46
|
+
* A track declared in the **`send`** array means the client will
|
|
47
|
+
* **SEND** video frames **to the model** (client → model).
|
|
48
|
+
*
|
|
49
|
+
* Track names must be unique across both arrays — the same name cannot
|
|
50
|
+
* appear in `receive` and `send`.
|
|
51
|
+
*
|
|
52
|
+
* @param name - The track name. Must match the model's declared track attribute name.
|
|
53
|
+
* @param options - Reserved for future constraints (e.g. `maxFramerate`).
|
|
54
|
+
*
|
|
55
|
+
* When no `receive` array is provided to the Reactor constructor, a single
|
|
56
|
+
* `video("main_video")` track is used by default.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* receive: [video("main_video")] // receive video from the model
|
|
61
|
+
* send: [video("webcam")] // send webcam video to the model
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
declare function video(name: string, _options?: VideoTrackOptions): TrackConfig;
|
|
65
|
+
/**
|
|
66
|
+
* Creates an **audio** {@link TrackConfig}.
|
|
67
|
+
*
|
|
68
|
+
* A track declared in the **`receive`** array means the client will
|
|
69
|
+
* **RECEIVE** audio samples **from the model** (model → client).
|
|
70
|
+
*
|
|
71
|
+
* A track declared in the **`send`** array means the client will
|
|
72
|
+
* **SEND** audio samples **to the model** (client → model).
|
|
73
|
+
*
|
|
74
|
+
* Track names must be unique across both arrays — the same name cannot
|
|
75
|
+
* appear in `receive` and `send`.
|
|
76
|
+
*
|
|
77
|
+
* @param name - The track name. Must match the model's declared track attribute name.
|
|
78
|
+
* @param options - Reserved for future constraints (e.g. `sampleRate`).
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* receive: [audio("main_audio")] // receive audio from the model
|
|
83
|
+
* send: [audio("mic")] // send microphone audio to the model
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
declare function audio(name: string, _options?: AudioTrackOptions): TrackConfig;
|
|
12
87
|
interface ReactorError {
|
|
13
88
|
code: string;
|
|
14
89
|
message: string;
|
|
@@ -46,13 +121,27 @@ interface ConnectionStats {
|
|
|
46
121
|
jitter?: number;
|
|
47
122
|
timestamp: number;
|
|
48
123
|
}
|
|
49
|
-
type ReactorEvent = "statusChanged" | "sessionIdChanged" | "message" | "runtimeMessage" | "
|
|
124
|
+
type ReactorEvent = "statusChanged" | "sessionIdChanged" | "message" | "runtimeMessage" | "trackReceived" | "error" | "sessionExpirationChanged" | "statsUpdate";
|
|
50
125
|
|
|
51
126
|
declare const PROD_COORDINATOR_URL = "https://api.reactor.inc";
|
|
52
127
|
declare const OptionsSchema: z.ZodObject<{
|
|
53
128
|
coordinatorUrl: z.ZodDefault<z.ZodString>;
|
|
54
129
|
modelName: z.ZodString;
|
|
55
130
|
local: z.ZodDefault<z.ZodBoolean>;
|
|
131
|
+
receive: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
132
|
+
name: z.ZodString;
|
|
133
|
+
kind: z.ZodEnum<{
|
|
134
|
+
audio: "audio";
|
|
135
|
+
video: "video";
|
|
136
|
+
}>;
|
|
137
|
+
}, z.core.$strip>>>;
|
|
138
|
+
send: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
139
|
+
name: z.ZodString;
|
|
140
|
+
kind: z.ZodEnum<{
|
|
141
|
+
audio: "audio";
|
|
142
|
+
video: "video";
|
|
143
|
+
}>;
|
|
144
|
+
}, z.core.$strip>>>;
|
|
56
145
|
}, z.core.$strip>;
|
|
57
146
|
type Options = z.input<typeof OptionsSchema>;
|
|
58
147
|
type EventHandler = (...args: any[]) => void;
|
|
@@ -65,6 +154,10 @@ declare class Reactor {
|
|
|
65
154
|
private model;
|
|
66
155
|
private sessionExpiration?;
|
|
67
156
|
private local;
|
|
157
|
+
/** Tracks the client RECEIVES from the model (model → client). */
|
|
158
|
+
private receive;
|
|
159
|
+
/** Tracks the client SENDS to the model (client → model). */
|
|
160
|
+
private send;
|
|
68
161
|
private sessionId?;
|
|
69
162
|
constructor(options: Options);
|
|
70
163
|
private eventListeners;
|
|
@@ -72,24 +165,26 @@ declare class Reactor {
|
|
|
72
165
|
off(event: ReactorEvent, handler: EventHandler): void;
|
|
73
166
|
emit(event: ReactorEvent, ...args: any[]): void;
|
|
74
167
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @param command The command name
|
|
168
|
+
* Sends a command to the model via the data channel.
|
|
169
|
+
*
|
|
170
|
+
* @param command The command name.
|
|
78
171
|
* @param data The command payload.
|
|
79
|
-
* @param scope
|
|
80
|
-
* "runtime" for platform-level messages (e.g. requestCapabilities).
|
|
81
|
-
* @throws Error if not in ready state
|
|
172
|
+
* @param scope "application" (default) for model commands, "runtime" for platform messages.
|
|
82
173
|
*/
|
|
83
174
|
sendCommand(command: string, data: any, scope?: MessageScope): Promise<void>;
|
|
84
175
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
176
|
+
* Publishes a MediaStreamTrack to a named send track.
|
|
177
|
+
*
|
|
178
|
+
* @param name The declared send track name (e.g. "webcam").
|
|
179
|
+
* @param track The MediaStreamTrack to publish.
|
|
87
180
|
*/
|
|
88
|
-
publishTrack(track: MediaStreamTrack): Promise<void>;
|
|
181
|
+
publishTrack(name: string, track: MediaStreamTrack): Promise<void>;
|
|
89
182
|
/**
|
|
90
|
-
*
|
|
183
|
+
* Unpublishes the track with the given name.
|
|
184
|
+
*
|
|
185
|
+
* @param name The declared send track name to unpublish.
|
|
91
186
|
*/
|
|
92
|
-
unpublishTrack(): Promise<void>;
|
|
187
|
+
unpublishTrack(name: string): Promise<void>;
|
|
93
188
|
/**
|
|
94
189
|
* Public method for reconnecting to an existing session, that may have been interrupted but can be recovered.
|
|
95
190
|
* @param options Optional connect options (e.g. maxAttempts for SDP polling)
|
|
@@ -138,19 +233,24 @@ declare class Reactor {
|
|
|
138
233
|
|
|
139
234
|
interface ReactorState {
|
|
140
235
|
status: ReactorStatus;
|
|
141
|
-
|
|
236
|
+
/**
|
|
237
|
+
* Media tracks received from the model, keyed by track name.
|
|
238
|
+
*
|
|
239
|
+
* Each entry maps a declared **receive** track name (e.g. `"main_video"`,
|
|
240
|
+
* `"main_audio"`) to the live `MediaStreamTrack` delivered by the model.
|
|
241
|
+
*/
|
|
242
|
+
tracks: Record<string, MediaStreamTrack>;
|
|
142
243
|
lastError?: ReactorError;
|
|
143
244
|
sessionId?: string;
|
|
144
245
|
sessionExpiration?: number;
|
|
145
|
-
insecureApiKey?: string;
|
|
146
246
|
jwtToken?: string;
|
|
147
247
|
}
|
|
148
248
|
interface ReactorActions {
|
|
149
249
|
sendCommand(command: string, data: any, scope?: MessageScope): Promise<void>;
|
|
150
250
|
connect(jwtToken?: string, options?: ConnectOptions): Promise<void>;
|
|
151
251
|
disconnect(recoverable?: boolean): Promise<void>;
|
|
152
|
-
|
|
153
|
-
|
|
252
|
+
publish(name: string, track: MediaStreamTrack): Promise<void>;
|
|
253
|
+
unpublish(name: string): Promise<void>;
|
|
154
254
|
reconnect(options?: ConnectOptions): Promise<void>;
|
|
155
255
|
}
|
|
156
256
|
interface ReactorInternalState {
|
|
@@ -180,13 +280,26 @@ declare function ReactorProvider({ children, connectOptions, jwtToken, ...props
|
|
|
180
280
|
declare function useReactorStore<T = ReactorStore>(selector: (state: ReactorStore) => T): T;
|
|
181
281
|
|
|
182
282
|
interface ReactorViewProps {
|
|
283
|
+
/**
|
|
284
|
+
* The name of the **receive** track to render.
|
|
285
|
+
* Must match a track name declared in the `receive` array (model → client).
|
|
286
|
+
* Defaults to `"main_video"`.
|
|
287
|
+
*/
|
|
288
|
+
track?: string;
|
|
289
|
+
/**
|
|
290
|
+
* Optional name of a **receive** audio track to play alongside the video
|
|
291
|
+
* (e.g. `"main_audio"`). The audio is mixed into the same `<video>` element.
|
|
292
|
+
*/
|
|
293
|
+
audioTrack?: string;
|
|
183
294
|
width?: number;
|
|
184
295
|
height?: number;
|
|
185
296
|
className?: string;
|
|
186
297
|
style?: React.CSSProperties;
|
|
187
298
|
videoObjectFit?: NonNullable<React.VideoHTMLAttributes<HTMLVideoElement>["style"]>["objectFit"];
|
|
299
|
+
/** Controls whether inbound audio plays. Default true (muted) to satisfy browser autoplay policies. */
|
|
300
|
+
muted?: boolean;
|
|
188
301
|
}
|
|
189
|
-
declare function ReactorView({ width, height, className, style, videoObjectFit, }: ReactorViewProps): react_jsx_runtime.JSX.Element;
|
|
302
|
+
declare function ReactorView({ track, audioTrack, width, height, className, style, videoObjectFit, muted, }: ReactorViewProps): react_jsx_runtime.JSX.Element;
|
|
190
303
|
|
|
191
304
|
interface ReactorControllerProps {
|
|
192
305
|
className?: string;
|
|
@@ -194,14 +307,19 @@ interface ReactorControllerProps {
|
|
|
194
307
|
}
|
|
195
308
|
declare function ReactorController({ className, style, }: ReactorControllerProps): react_jsx_runtime.JSX.Element;
|
|
196
309
|
|
|
197
|
-
interface
|
|
310
|
+
interface WebcamStreamProps {
|
|
311
|
+
/**
|
|
312
|
+
* The name of the **send** track to publish the webcam to.
|
|
313
|
+
* Must match a track name declared in the `send` array (client → model).
|
|
314
|
+
*/
|
|
315
|
+
track: string;
|
|
198
316
|
className?: string;
|
|
199
317
|
style?: React.CSSProperties;
|
|
200
318
|
videoConstraints?: MediaTrackConstraints;
|
|
201
319
|
showWebcam?: boolean;
|
|
202
320
|
videoObjectFit?: NonNullable<React.VideoHTMLAttributes<HTMLVideoElement>["style"]>["objectFit"];
|
|
203
321
|
}
|
|
204
|
-
declare function WebcamStream({ className, style, videoConstraints, showWebcam, videoObjectFit, }:
|
|
322
|
+
declare function WebcamStream({ track, className, style, videoConstraints, showWebcam, videoObjectFit, }: WebcamStreamProps): react_jsx_runtime.JSX.Element;
|
|
205
323
|
|
|
206
324
|
/**
|
|
207
325
|
* Generic hook for accessing selected parts of the Reactor store.
|
|
@@ -249,4 +367,4 @@ declare function useStats(): ConnectionStats | undefined;
|
|
|
249
367
|
*/
|
|
250
368
|
declare function fetchInsecureJwtToken(apiKey: string, coordinatorUrl?: string): Promise<string>;
|
|
251
369
|
|
|
252
|
-
export { ConflictError, type ConnectOptions, type ConnectionStats, type MessageScope, type Options, PROD_COORDINATOR_URL, Reactor, type ReactorConnectOptions, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, ReactorView, type ReactorViewProps, WebcamStream, fetchInsecureJwtToken, useReactor, useReactorInternalMessage, useReactorMessage, useReactorStore, useStats };
|
|
370
|
+
export { type AudioTrackOptions, ConflictError, type ConnectOptions, type ConnectionStats, type MessageScope, type Options, PROD_COORDINATOR_URL, Reactor, type ReactorConnectOptions, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, ReactorView, type ReactorViewProps, type TrackConfig, type VideoTrackOptions, WebcamStream, type WebcamStreamProps, audio, fetchInsecureJwtToken, useReactor, useReactorInternalMessage, useReactorMessage, useReactorStore, useStats, video };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,81 @@ type ReactorStatus = "disconnected" | "connecting" | "waiting" | "ready";
|
|
|
9
9
|
* - "runtime": platform-level control messages (e.g., capabilities exchange).
|
|
10
10
|
*/
|
|
11
11
|
type MessageScope = "application" | "runtime";
|
|
12
|
+
/**
|
|
13
|
+
* Describes a single named media track for SDP negotiation.
|
|
14
|
+
*
|
|
15
|
+
* Track names must exactly match the class attribute names defined on the
|
|
16
|
+
* model's Python code. The name is encoded as the SDP MID so both sides
|
|
17
|
+
* can route media by name rather than by positional index.
|
|
18
|
+
*
|
|
19
|
+
* Use the {@link video} and {@link audio} helper functions to create
|
|
20
|
+
* instances instead of constructing this interface directly.
|
|
21
|
+
*/
|
|
22
|
+
interface TrackConfig {
|
|
23
|
+
name: string;
|
|
24
|
+
kind: "audio" | "video";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Optional configuration for a video track (reserved for future use).
|
|
28
|
+
*/
|
|
29
|
+
interface VideoTrackOptions {
|
|
30
|
+
/** Maximum framerate constraint for the video track. */
|
|
31
|
+
maxFramerate?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Optional configuration for an audio track (reserved for future use).
|
|
35
|
+
*/
|
|
36
|
+
interface AudioTrackOptions {
|
|
37
|
+
/** Sample rate constraint for the audio track. */
|
|
38
|
+
sampleRate?: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates a **video** {@link TrackConfig}.
|
|
42
|
+
*
|
|
43
|
+
* A track declared in the **`receive`** array means the client will
|
|
44
|
+
* **RECEIVE** video frames **from the model** (model → client).
|
|
45
|
+
*
|
|
46
|
+
* A track declared in the **`send`** array means the client will
|
|
47
|
+
* **SEND** video frames **to the model** (client → model).
|
|
48
|
+
*
|
|
49
|
+
* Track names must be unique across both arrays — the same name cannot
|
|
50
|
+
* appear in `receive` and `send`.
|
|
51
|
+
*
|
|
52
|
+
* @param name - The track name. Must match the model's declared track attribute name.
|
|
53
|
+
* @param options - Reserved for future constraints (e.g. `maxFramerate`).
|
|
54
|
+
*
|
|
55
|
+
* When no `receive` array is provided to the Reactor constructor, a single
|
|
56
|
+
* `video("main_video")` track is used by default.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* receive: [video("main_video")] // receive video from the model
|
|
61
|
+
* send: [video("webcam")] // send webcam video to the model
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
declare function video(name: string, _options?: VideoTrackOptions): TrackConfig;
|
|
65
|
+
/**
|
|
66
|
+
* Creates an **audio** {@link TrackConfig}.
|
|
67
|
+
*
|
|
68
|
+
* A track declared in the **`receive`** array means the client will
|
|
69
|
+
* **RECEIVE** audio samples **from the model** (model → client).
|
|
70
|
+
*
|
|
71
|
+
* A track declared in the **`send`** array means the client will
|
|
72
|
+
* **SEND** audio samples **to the model** (client → model).
|
|
73
|
+
*
|
|
74
|
+
* Track names must be unique across both arrays — the same name cannot
|
|
75
|
+
* appear in `receive` and `send`.
|
|
76
|
+
*
|
|
77
|
+
* @param name - The track name. Must match the model's declared track attribute name.
|
|
78
|
+
* @param options - Reserved for future constraints (e.g. `sampleRate`).
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* receive: [audio("main_audio")] // receive audio from the model
|
|
83
|
+
* send: [audio("mic")] // send microphone audio to the model
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
declare function audio(name: string, _options?: AudioTrackOptions): TrackConfig;
|
|
12
87
|
interface ReactorError {
|
|
13
88
|
code: string;
|
|
14
89
|
message: string;
|
|
@@ -46,13 +121,27 @@ interface ConnectionStats {
|
|
|
46
121
|
jitter?: number;
|
|
47
122
|
timestamp: number;
|
|
48
123
|
}
|
|
49
|
-
type ReactorEvent = "statusChanged" | "sessionIdChanged" | "message" | "runtimeMessage" | "
|
|
124
|
+
type ReactorEvent = "statusChanged" | "sessionIdChanged" | "message" | "runtimeMessage" | "trackReceived" | "error" | "sessionExpirationChanged" | "statsUpdate";
|
|
50
125
|
|
|
51
126
|
declare const PROD_COORDINATOR_URL = "https://api.reactor.inc";
|
|
52
127
|
declare const OptionsSchema: z.ZodObject<{
|
|
53
128
|
coordinatorUrl: z.ZodDefault<z.ZodString>;
|
|
54
129
|
modelName: z.ZodString;
|
|
55
130
|
local: z.ZodDefault<z.ZodBoolean>;
|
|
131
|
+
receive: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
132
|
+
name: z.ZodString;
|
|
133
|
+
kind: z.ZodEnum<{
|
|
134
|
+
audio: "audio";
|
|
135
|
+
video: "video";
|
|
136
|
+
}>;
|
|
137
|
+
}, z.core.$strip>>>;
|
|
138
|
+
send: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
139
|
+
name: z.ZodString;
|
|
140
|
+
kind: z.ZodEnum<{
|
|
141
|
+
audio: "audio";
|
|
142
|
+
video: "video";
|
|
143
|
+
}>;
|
|
144
|
+
}, z.core.$strip>>>;
|
|
56
145
|
}, z.core.$strip>;
|
|
57
146
|
type Options = z.input<typeof OptionsSchema>;
|
|
58
147
|
type EventHandler = (...args: any[]) => void;
|
|
@@ -65,6 +154,10 @@ declare class Reactor {
|
|
|
65
154
|
private model;
|
|
66
155
|
private sessionExpiration?;
|
|
67
156
|
private local;
|
|
157
|
+
/** Tracks the client RECEIVES from the model (model → client). */
|
|
158
|
+
private receive;
|
|
159
|
+
/** Tracks the client SENDS to the model (client → model). */
|
|
160
|
+
private send;
|
|
68
161
|
private sessionId?;
|
|
69
162
|
constructor(options: Options);
|
|
70
163
|
private eventListeners;
|
|
@@ -72,24 +165,26 @@ declare class Reactor {
|
|
|
72
165
|
off(event: ReactorEvent, handler: EventHandler): void;
|
|
73
166
|
emit(event: ReactorEvent, ...args: any[]): void;
|
|
74
167
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @param command The command name
|
|
168
|
+
* Sends a command to the model via the data channel.
|
|
169
|
+
*
|
|
170
|
+
* @param command The command name.
|
|
78
171
|
* @param data The command payload.
|
|
79
|
-
* @param scope
|
|
80
|
-
* "runtime" for platform-level messages (e.g. requestCapabilities).
|
|
81
|
-
* @throws Error if not in ready state
|
|
172
|
+
* @param scope "application" (default) for model commands, "runtime" for platform messages.
|
|
82
173
|
*/
|
|
83
174
|
sendCommand(command: string, data: any, scope?: MessageScope): Promise<void>;
|
|
84
175
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
176
|
+
* Publishes a MediaStreamTrack to a named send track.
|
|
177
|
+
*
|
|
178
|
+
* @param name The declared send track name (e.g. "webcam").
|
|
179
|
+
* @param track The MediaStreamTrack to publish.
|
|
87
180
|
*/
|
|
88
|
-
publishTrack(track: MediaStreamTrack): Promise<void>;
|
|
181
|
+
publishTrack(name: string, track: MediaStreamTrack): Promise<void>;
|
|
89
182
|
/**
|
|
90
|
-
*
|
|
183
|
+
* Unpublishes the track with the given name.
|
|
184
|
+
*
|
|
185
|
+
* @param name The declared send track name to unpublish.
|
|
91
186
|
*/
|
|
92
|
-
unpublishTrack(): Promise<void>;
|
|
187
|
+
unpublishTrack(name: string): Promise<void>;
|
|
93
188
|
/**
|
|
94
189
|
* Public method for reconnecting to an existing session, that may have been interrupted but can be recovered.
|
|
95
190
|
* @param options Optional connect options (e.g. maxAttempts for SDP polling)
|
|
@@ -138,19 +233,24 @@ declare class Reactor {
|
|
|
138
233
|
|
|
139
234
|
interface ReactorState {
|
|
140
235
|
status: ReactorStatus;
|
|
141
|
-
|
|
236
|
+
/**
|
|
237
|
+
* Media tracks received from the model, keyed by track name.
|
|
238
|
+
*
|
|
239
|
+
* Each entry maps a declared **receive** track name (e.g. `"main_video"`,
|
|
240
|
+
* `"main_audio"`) to the live `MediaStreamTrack` delivered by the model.
|
|
241
|
+
*/
|
|
242
|
+
tracks: Record<string, MediaStreamTrack>;
|
|
142
243
|
lastError?: ReactorError;
|
|
143
244
|
sessionId?: string;
|
|
144
245
|
sessionExpiration?: number;
|
|
145
|
-
insecureApiKey?: string;
|
|
146
246
|
jwtToken?: string;
|
|
147
247
|
}
|
|
148
248
|
interface ReactorActions {
|
|
149
249
|
sendCommand(command: string, data: any, scope?: MessageScope): Promise<void>;
|
|
150
250
|
connect(jwtToken?: string, options?: ConnectOptions): Promise<void>;
|
|
151
251
|
disconnect(recoverable?: boolean): Promise<void>;
|
|
152
|
-
|
|
153
|
-
|
|
252
|
+
publish(name: string, track: MediaStreamTrack): Promise<void>;
|
|
253
|
+
unpublish(name: string): Promise<void>;
|
|
154
254
|
reconnect(options?: ConnectOptions): Promise<void>;
|
|
155
255
|
}
|
|
156
256
|
interface ReactorInternalState {
|
|
@@ -180,13 +280,26 @@ declare function ReactorProvider({ children, connectOptions, jwtToken, ...props
|
|
|
180
280
|
declare function useReactorStore<T = ReactorStore>(selector: (state: ReactorStore) => T): T;
|
|
181
281
|
|
|
182
282
|
interface ReactorViewProps {
|
|
283
|
+
/**
|
|
284
|
+
* The name of the **receive** track to render.
|
|
285
|
+
* Must match a track name declared in the `receive` array (model → client).
|
|
286
|
+
* Defaults to `"main_video"`.
|
|
287
|
+
*/
|
|
288
|
+
track?: string;
|
|
289
|
+
/**
|
|
290
|
+
* Optional name of a **receive** audio track to play alongside the video
|
|
291
|
+
* (e.g. `"main_audio"`). The audio is mixed into the same `<video>` element.
|
|
292
|
+
*/
|
|
293
|
+
audioTrack?: string;
|
|
183
294
|
width?: number;
|
|
184
295
|
height?: number;
|
|
185
296
|
className?: string;
|
|
186
297
|
style?: React.CSSProperties;
|
|
187
298
|
videoObjectFit?: NonNullable<React.VideoHTMLAttributes<HTMLVideoElement>["style"]>["objectFit"];
|
|
299
|
+
/** Controls whether inbound audio plays. Default true (muted) to satisfy browser autoplay policies. */
|
|
300
|
+
muted?: boolean;
|
|
188
301
|
}
|
|
189
|
-
declare function ReactorView({ width, height, className, style, videoObjectFit, }: ReactorViewProps): react_jsx_runtime.JSX.Element;
|
|
302
|
+
declare function ReactorView({ track, audioTrack, width, height, className, style, videoObjectFit, muted, }: ReactorViewProps): react_jsx_runtime.JSX.Element;
|
|
190
303
|
|
|
191
304
|
interface ReactorControllerProps {
|
|
192
305
|
className?: string;
|
|
@@ -194,14 +307,19 @@ interface ReactorControllerProps {
|
|
|
194
307
|
}
|
|
195
308
|
declare function ReactorController({ className, style, }: ReactorControllerProps): react_jsx_runtime.JSX.Element;
|
|
196
309
|
|
|
197
|
-
interface
|
|
310
|
+
interface WebcamStreamProps {
|
|
311
|
+
/**
|
|
312
|
+
* The name of the **send** track to publish the webcam to.
|
|
313
|
+
* Must match a track name declared in the `send` array (client → model).
|
|
314
|
+
*/
|
|
315
|
+
track: string;
|
|
198
316
|
className?: string;
|
|
199
317
|
style?: React.CSSProperties;
|
|
200
318
|
videoConstraints?: MediaTrackConstraints;
|
|
201
319
|
showWebcam?: boolean;
|
|
202
320
|
videoObjectFit?: NonNullable<React.VideoHTMLAttributes<HTMLVideoElement>["style"]>["objectFit"];
|
|
203
321
|
}
|
|
204
|
-
declare function WebcamStream({ className, style, videoConstraints, showWebcam, videoObjectFit, }:
|
|
322
|
+
declare function WebcamStream({ track, className, style, videoConstraints, showWebcam, videoObjectFit, }: WebcamStreamProps): react_jsx_runtime.JSX.Element;
|
|
205
323
|
|
|
206
324
|
/**
|
|
207
325
|
* Generic hook for accessing selected parts of the Reactor store.
|
|
@@ -249,4 +367,4 @@ declare function useStats(): ConnectionStats | undefined;
|
|
|
249
367
|
*/
|
|
250
368
|
declare function fetchInsecureJwtToken(apiKey: string, coordinatorUrl?: string): Promise<string>;
|
|
251
369
|
|
|
252
|
-
export { ConflictError, type ConnectOptions, type ConnectionStats, type MessageScope, type Options, PROD_COORDINATOR_URL, Reactor, type ReactorConnectOptions, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, ReactorView, type ReactorViewProps, WebcamStream, fetchInsecureJwtToken, useReactor, useReactorInternalMessage, useReactorMessage, useReactorStore, useStats };
|
|
370
|
+
export { type AudioTrackOptions, ConflictError, type ConnectOptions, type ConnectionStats, type MessageScope, type Options, PROD_COORDINATOR_URL, Reactor, type ReactorConnectOptions, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, ReactorView, type ReactorViewProps, type TrackConfig, type VideoTrackOptions, WebcamStream, type WebcamStreamProps, audio, fetchInsecureJwtToken, useReactor, useReactorInternalMessage, useReactorMessage, useReactorStore, useStats, video };
|