@reactor-team/js-sdk 2.8.1 → 2.9.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/dist/index.d.mts +54 -1
- package/dist/index.d.ts +54 -1
- package/dist/index.js +382 -82
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +384 -85
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -86,6 +86,22 @@ type CommandCapability = z.infer<typeof CommandCapabilitySchema>;
|
|
|
86
86
|
type SessionResponse = z.infer<typeof SessionResponseSchema>;
|
|
87
87
|
type Capabilities = z.infer<typeof CapabilitiesSchema>;
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Reference to an uploaded file, returned by {@link Reactor.uploadFile}.
|
|
91
|
+
*
|
|
92
|
+
* Pass a `FileRef` as a value in {@link Reactor.sendCommand} and it will
|
|
93
|
+
* be serialized into the `uploads` section of the wire envelope, separate
|
|
94
|
+
* from scalar arguments. The runtime resolves each reference to bytes
|
|
95
|
+
* before dispatching the event to the model handler.
|
|
96
|
+
*/
|
|
97
|
+
declare class FileRef {
|
|
98
|
+
readonly uploadId: string;
|
|
99
|
+
readonly name: string;
|
|
100
|
+
readonly mimeType: string;
|
|
101
|
+
readonly size: number;
|
|
102
|
+
constructor(uploadId: string, name: string, mimeType: string, size: number);
|
|
103
|
+
}
|
|
104
|
+
|
|
89
105
|
type ReactorStatus = "disconnected" | "connecting" | "waiting" | "ready";
|
|
90
106
|
/**
|
|
91
107
|
* The message scope identifies the envelope layer a data channel message belongs to.
|
|
@@ -161,8 +177,20 @@ declare const OptionsSchema: z.ZodObject<{
|
|
|
161
177
|
apiUrl: z.ZodDefault<z.ZodString>;
|
|
162
178
|
modelName: z.ZodString;
|
|
163
179
|
local: z.ZodDefault<z.ZodBoolean>;
|
|
180
|
+
modelTracks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
181
|
+
name: z.ZodString;
|
|
182
|
+
kind: z.ZodEnum<{
|
|
183
|
+
video: "video";
|
|
184
|
+
audio: "audio";
|
|
185
|
+
}>;
|
|
186
|
+
direction: z.ZodEnum<{
|
|
187
|
+
recvonly: "recvonly";
|
|
188
|
+
sendonly: "sendonly";
|
|
189
|
+
}>;
|
|
190
|
+
}, z.core.$strip>>>;
|
|
164
191
|
}, z.core.$strip>;
|
|
165
192
|
type Options = z.input<typeof OptionsSchema>;
|
|
193
|
+
|
|
166
194
|
type EventHandler = (...args: any[]) => void;
|
|
167
195
|
declare class Reactor {
|
|
168
196
|
private coordinatorClient;
|
|
@@ -178,6 +206,7 @@ declare class Reactor {
|
|
|
178
206
|
private connectionTimings?;
|
|
179
207
|
private capabilities?;
|
|
180
208
|
private tracks;
|
|
209
|
+
private presetTracks?;
|
|
181
210
|
private sessionResponse?;
|
|
182
211
|
constructor(options: Options);
|
|
183
212
|
private eventListeners;
|
|
@@ -186,8 +215,29 @@ declare class Reactor {
|
|
|
186
215
|
emit(event: ReactorEvent, ...args: any[]): void;
|
|
187
216
|
/**
|
|
188
217
|
* Sends a command to the model via the data channel.
|
|
218
|
+
*
|
|
219
|
+
* When any value in `data` is a {@link FileRef}, it is automatically
|
|
220
|
+
* extracted and serialized into a separate `uploads` section on the
|
|
221
|
+
* wire, keyed by the parameter name. Scalar values remain in `data`.
|
|
189
222
|
*/
|
|
190
223
|
sendCommand(command: string, data: any, scope?: MessageScope): Promise<void>;
|
|
224
|
+
/**
|
|
225
|
+
* Uploads a file to the session's object store and returns a {@link FileRef}.
|
|
226
|
+
*
|
|
227
|
+
* Flow:
|
|
228
|
+
* 1. POST /sessions/{id}/uploads → allocate presigned PUT URL
|
|
229
|
+
* 2. PUT file bytes to the presigned URL
|
|
230
|
+
* 3. Send `fileUploaded` notification on the runtime data channel
|
|
231
|
+
* (fires `@file_uploaded` on the model if registered)
|
|
232
|
+
* 4. Return a `FileRef` to pass into {@link sendCommand}
|
|
233
|
+
*
|
|
234
|
+
* In local mode, the presigned URL returned by the runtime is rewritten
|
|
235
|
+
* to use the SDK-configured base URL (scheme + host), so port-forwarded
|
|
236
|
+
* setups work correctly (REA-1573).
|
|
237
|
+
*/
|
|
238
|
+
uploadFile(file: File | Blob, options?: {
|
|
239
|
+
name?: string;
|
|
240
|
+
}): Promise<FileRef>;
|
|
191
241
|
/**
|
|
192
242
|
* Publishes a MediaStreamTrack to a named sendonly track.
|
|
193
243
|
* The transceiver is already set up from capabilities — this just
|
|
@@ -249,6 +299,9 @@ interface ReactorActions {
|
|
|
249
299
|
publish(name: string, track: MediaStreamTrack): Promise<void>;
|
|
250
300
|
unpublish(name: string): Promise<void>;
|
|
251
301
|
reconnect(options?: ConnectOptions): Promise<void>;
|
|
302
|
+
uploadFile(file: File | Blob, options?: {
|
|
303
|
+
name?: string;
|
|
304
|
+
}): Promise<FileRef>;
|
|
252
305
|
}
|
|
253
306
|
interface ReactorInternalState {
|
|
254
307
|
reactor: Reactor;
|
|
@@ -354,4 +407,4 @@ declare function useReactorInternalMessage(handler: (message: any) => void): voi
|
|
|
354
407
|
*/
|
|
355
408
|
declare function useStats(): ConnectionStats | undefined;
|
|
356
409
|
|
|
357
|
-
export { AbortError, type Capabilities, type CommandCapability, ConflictError, type ConnectOptions, type ConnectionStats, type ConnectionTimings, DEFAULT_BASE_URL, type MessageScope, type Options, Reactor, type ReactorConnectOptions, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, type ReactorStore, ReactorView, type ReactorViewProps, type SessionResponse, type TrackCapability, WebcamStream, type WebcamStreamProps, isAbortError, useReactor, useReactorInternalMessage, useReactorMessage, useReactorStore, useStats };
|
|
410
|
+
export { AbortError, type Capabilities, type CommandCapability, ConflictError, type ConnectOptions, type ConnectionStats, type ConnectionTimings, DEFAULT_BASE_URL, FileRef, type MessageScope, type Options, Reactor, type ReactorConnectOptions, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, type ReactorStore, ReactorView, type ReactorViewProps, type SessionResponse, type TrackCapability, WebcamStream, type WebcamStreamProps, isAbortError, useReactor, useReactorInternalMessage, useReactorMessage, useReactorStore, useStats };
|
package/dist/index.d.ts
CHANGED
|
@@ -86,6 +86,22 @@ type CommandCapability = z.infer<typeof CommandCapabilitySchema>;
|
|
|
86
86
|
type SessionResponse = z.infer<typeof SessionResponseSchema>;
|
|
87
87
|
type Capabilities = z.infer<typeof CapabilitiesSchema>;
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Reference to an uploaded file, returned by {@link Reactor.uploadFile}.
|
|
91
|
+
*
|
|
92
|
+
* Pass a `FileRef` as a value in {@link Reactor.sendCommand} and it will
|
|
93
|
+
* be serialized into the `uploads` section of the wire envelope, separate
|
|
94
|
+
* from scalar arguments. The runtime resolves each reference to bytes
|
|
95
|
+
* before dispatching the event to the model handler.
|
|
96
|
+
*/
|
|
97
|
+
declare class FileRef {
|
|
98
|
+
readonly uploadId: string;
|
|
99
|
+
readonly name: string;
|
|
100
|
+
readonly mimeType: string;
|
|
101
|
+
readonly size: number;
|
|
102
|
+
constructor(uploadId: string, name: string, mimeType: string, size: number);
|
|
103
|
+
}
|
|
104
|
+
|
|
89
105
|
type ReactorStatus = "disconnected" | "connecting" | "waiting" | "ready";
|
|
90
106
|
/**
|
|
91
107
|
* The message scope identifies the envelope layer a data channel message belongs to.
|
|
@@ -161,8 +177,20 @@ declare const OptionsSchema: z.ZodObject<{
|
|
|
161
177
|
apiUrl: z.ZodDefault<z.ZodString>;
|
|
162
178
|
modelName: z.ZodString;
|
|
163
179
|
local: z.ZodDefault<z.ZodBoolean>;
|
|
180
|
+
modelTracks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
181
|
+
name: z.ZodString;
|
|
182
|
+
kind: z.ZodEnum<{
|
|
183
|
+
video: "video";
|
|
184
|
+
audio: "audio";
|
|
185
|
+
}>;
|
|
186
|
+
direction: z.ZodEnum<{
|
|
187
|
+
recvonly: "recvonly";
|
|
188
|
+
sendonly: "sendonly";
|
|
189
|
+
}>;
|
|
190
|
+
}, z.core.$strip>>>;
|
|
164
191
|
}, z.core.$strip>;
|
|
165
192
|
type Options = z.input<typeof OptionsSchema>;
|
|
193
|
+
|
|
166
194
|
type EventHandler = (...args: any[]) => void;
|
|
167
195
|
declare class Reactor {
|
|
168
196
|
private coordinatorClient;
|
|
@@ -178,6 +206,7 @@ declare class Reactor {
|
|
|
178
206
|
private connectionTimings?;
|
|
179
207
|
private capabilities?;
|
|
180
208
|
private tracks;
|
|
209
|
+
private presetTracks?;
|
|
181
210
|
private sessionResponse?;
|
|
182
211
|
constructor(options: Options);
|
|
183
212
|
private eventListeners;
|
|
@@ -186,8 +215,29 @@ declare class Reactor {
|
|
|
186
215
|
emit(event: ReactorEvent, ...args: any[]): void;
|
|
187
216
|
/**
|
|
188
217
|
* Sends a command to the model via the data channel.
|
|
218
|
+
*
|
|
219
|
+
* When any value in `data` is a {@link FileRef}, it is automatically
|
|
220
|
+
* extracted and serialized into a separate `uploads` section on the
|
|
221
|
+
* wire, keyed by the parameter name. Scalar values remain in `data`.
|
|
189
222
|
*/
|
|
190
223
|
sendCommand(command: string, data: any, scope?: MessageScope): Promise<void>;
|
|
224
|
+
/**
|
|
225
|
+
* Uploads a file to the session's object store and returns a {@link FileRef}.
|
|
226
|
+
*
|
|
227
|
+
* Flow:
|
|
228
|
+
* 1. POST /sessions/{id}/uploads → allocate presigned PUT URL
|
|
229
|
+
* 2. PUT file bytes to the presigned URL
|
|
230
|
+
* 3. Send `fileUploaded` notification on the runtime data channel
|
|
231
|
+
* (fires `@file_uploaded` on the model if registered)
|
|
232
|
+
* 4. Return a `FileRef` to pass into {@link sendCommand}
|
|
233
|
+
*
|
|
234
|
+
* In local mode, the presigned URL returned by the runtime is rewritten
|
|
235
|
+
* to use the SDK-configured base URL (scheme + host), so port-forwarded
|
|
236
|
+
* setups work correctly (REA-1573).
|
|
237
|
+
*/
|
|
238
|
+
uploadFile(file: File | Blob, options?: {
|
|
239
|
+
name?: string;
|
|
240
|
+
}): Promise<FileRef>;
|
|
191
241
|
/**
|
|
192
242
|
* Publishes a MediaStreamTrack to a named sendonly track.
|
|
193
243
|
* The transceiver is already set up from capabilities — this just
|
|
@@ -249,6 +299,9 @@ interface ReactorActions {
|
|
|
249
299
|
publish(name: string, track: MediaStreamTrack): Promise<void>;
|
|
250
300
|
unpublish(name: string): Promise<void>;
|
|
251
301
|
reconnect(options?: ConnectOptions): Promise<void>;
|
|
302
|
+
uploadFile(file: File | Blob, options?: {
|
|
303
|
+
name?: string;
|
|
304
|
+
}): Promise<FileRef>;
|
|
252
305
|
}
|
|
253
306
|
interface ReactorInternalState {
|
|
254
307
|
reactor: Reactor;
|
|
@@ -354,4 +407,4 @@ declare function useReactorInternalMessage(handler: (message: any) => void): voi
|
|
|
354
407
|
*/
|
|
355
408
|
declare function useStats(): ConnectionStats | undefined;
|
|
356
409
|
|
|
357
|
-
export { AbortError, type Capabilities, type CommandCapability, ConflictError, type ConnectOptions, type ConnectionStats, type ConnectionTimings, DEFAULT_BASE_URL, type MessageScope, type Options, Reactor, type ReactorConnectOptions, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, type ReactorStore, ReactorView, type ReactorViewProps, type SessionResponse, type TrackCapability, WebcamStream, type WebcamStreamProps, isAbortError, useReactor, useReactorInternalMessage, useReactorMessage, useReactorStore, useStats };
|
|
410
|
+
export { AbortError, type Capabilities, type CommandCapability, ConflictError, type ConnectOptions, type ConnectionStats, type ConnectionTimings, DEFAULT_BASE_URL, FileRef, type MessageScope, type Options, Reactor, type ReactorConnectOptions, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, type ReactorStore, ReactorView, type ReactorViewProps, type SessionResponse, type TrackCapability, WebcamStream, type WebcamStreamProps, isAbortError, useReactor, useReactorInternalMessage, useReactorMessage, useReactorStore, useStats };
|