@reactor-team/js-sdk 1.0.19 → 2.0.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 +8 -0
- package/dist/index.d.mts +31 -62
- package/dist/index.d.ts +31 -62
- package/dist/index.js +787 -658
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +786 -662
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -10
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,31 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import React, { ReactNode } from 'react';
|
|
4
|
-
import { RemoteVideoTrack } from 'livekit-client';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal types for the Reactor SDK.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
declare const WaitingInfoDataSchema: z.ZodObject<{
|
|
11
|
-
position: z.ZodOptional<z.ZodNumber>;
|
|
12
|
-
estimatedWaitTime: z.ZodOptional<z.ZodNumber>;
|
|
13
|
-
averageWaitTime: z.ZodOptional<z.ZodNumber>;
|
|
14
|
-
}, z.core.$strip>;
|
|
15
|
-
declare const SessionExpirationDataSchema: z.ZodObject<{
|
|
16
|
-
expire: z.ZodNumber;
|
|
17
|
-
}, z.core.$strip>;
|
|
18
|
-
declare const ReactorAuthSchema: z.ZodObject<{
|
|
19
|
-
insecureApiKey: z.ZodOptional<z.ZodString>;
|
|
20
|
-
jwtToken: z.ZodOptional<z.ZodString>;
|
|
21
|
-
}, z.core.$strip>;
|
|
22
|
-
type ReactorAuth = z.infer<typeof ReactorAuthSchema>;
|
|
23
4
|
|
|
24
5
|
type ReactorStatus = "disconnected" | "connecting" | "waiting" | "ready";
|
|
25
|
-
interface ReactorWaitingInfo extends z$1.infer<typeof WaitingInfoDataSchema> {
|
|
26
|
-
}
|
|
27
|
-
interface ReactorSessionExpiration extends z$1.infer<typeof SessionExpirationDataSchema> {
|
|
28
|
-
}
|
|
29
6
|
interface ReactorError {
|
|
30
7
|
code: string;
|
|
31
8
|
message: string;
|
|
@@ -36,15 +13,14 @@ interface ReactorError {
|
|
|
36
13
|
}
|
|
37
14
|
interface ReactorState$1 {
|
|
38
15
|
status: ReactorStatus;
|
|
39
|
-
waitingInfo?: ReactorWaitingInfo;
|
|
40
16
|
lastError?: ReactorError;
|
|
41
17
|
}
|
|
42
|
-
type ReactorEvent = "statusChanged" | "
|
|
18
|
+
type ReactorEvent = "statusChanged" | "sessionIdChanged" | "newMessage" | "streamChanged" | "error" | "sessionExpirationChanged";
|
|
43
19
|
|
|
20
|
+
declare const PROD_COORDINATOR_URL = "https://api.reactor.inc";
|
|
44
21
|
declare const OptionsSchema: z.ZodObject<{
|
|
45
22
|
coordinatorUrl: z.ZodDefault<z.ZodString>;
|
|
46
23
|
modelName: z.ZodString;
|
|
47
|
-
queueing: z.ZodDefault<z.ZodBoolean>;
|
|
48
24
|
local: z.ZodDefault<z.ZodBoolean>;
|
|
49
25
|
}, z.core.$strip>;
|
|
50
26
|
type Options = z.input<typeof OptionsSchema>;
|
|
@@ -55,12 +31,10 @@ declare class Reactor {
|
|
|
55
31
|
private status;
|
|
56
32
|
private coordinatorUrl;
|
|
57
33
|
private lastError?;
|
|
58
|
-
private
|
|
59
|
-
private modelName;
|
|
60
|
-
private modelVersion;
|
|
61
|
-
private queueing;
|
|
34
|
+
private model;
|
|
62
35
|
private sessionExpiration?;
|
|
63
36
|
private local;
|
|
37
|
+
private sessionId?;
|
|
64
38
|
constructor(options: Options);
|
|
65
39
|
private eventListeners;
|
|
66
40
|
on(event: ReactorEvent, handler: EventHandler): void;
|
|
@@ -72,51 +46,48 @@ declare class Reactor {
|
|
|
72
46
|
* @param message The message to send to the machine.
|
|
73
47
|
* @throws Error if not in ready state
|
|
74
48
|
*/
|
|
75
|
-
|
|
49
|
+
sendCommand(command: string, data: any): Promise<void>;
|
|
76
50
|
/**
|
|
77
|
-
* Public method to publish a
|
|
78
|
-
* @param
|
|
51
|
+
* Public method to publish a track to the machine.
|
|
52
|
+
* @param track The track to send to the machine.
|
|
79
53
|
*/
|
|
80
|
-
|
|
54
|
+
publishTrack(track: MediaStreamTrack): Promise<void>;
|
|
81
55
|
/**
|
|
82
|
-
* Public method to unpublish
|
|
83
|
-
* This unpublishes the video track that was previously sent.
|
|
56
|
+
* Public method to unpublish the currently published track.
|
|
84
57
|
*/
|
|
85
|
-
|
|
58
|
+
unpublishTrack(): Promise<void>;
|
|
86
59
|
/**
|
|
87
|
-
*
|
|
88
|
-
* Once the machine is ready, the Reactor will establish the LiveKit connection.
|
|
89
|
-
* @param livekitJwtToken The JWT token for LiveKit authentication
|
|
90
|
-
* @param livekitWsUrl The WebSocket URL for LiveKit connection
|
|
60
|
+
* Public method for reconnecting to an existing session, that may have been interrupted but can be recovered.
|
|
91
61
|
*/
|
|
92
|
-
|
|
62
|
+
reconnect(): Promise<void>;
|
|
93
63
|
/**
|
|
94
64
|
* Connects to the coordinator and waits for a GPU to be assigned.
|
|
95
|
-
* Once a GPU is assigned, the Reactor will connect to the gpu machine via
|
|
65
|
+
* Once a GPU is assigned, the Reactor will connect to the gpu machine via WebRTC.
|
|
96
66
|
* If no authentication is provided and not in local mode, an error is thrown.
|
|
97
67
|
*/
|
|
98
|
-
connect(
|
|
68
|
+
connect(jwtToken?: string): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Sets up event handlers for the machine client.
|
|
71
|
+
*/
|
|
72
|
+
private setupMachineClientHandlers;
|
|
99
73
|
/**
|
|
100
74
|
* Disconnects from the coordinator and the gpu machine.
|
|
101
75
|
* Ensures cleanup completes even if individual disconnections fail.
|
|
102
76
|
*/
|
|
103
|
-
disconnect(): Promise<void>;
|
|
77
|
+
disconnect(recoverable?: boolean): Promise<void>;
|
|
78
|
+
private setSessionId;
|
|
79
|
+
getSessionId(): string | undefined;
|
|
104
80
|
private setStatus;
|
|
105
|
-
|
|
81
|
+
getStatus(): ReactorStatus;
|
|
106
82
|
/**
|
|
107
83
|
* Set the session expiration time.
|
|
108
84
|
* @param newSessionExpiration The new session expiration time in seconds.
|
|
109
85
|
*/
|
|
110
86
|
private setSessionExpiration;
|
|
111
|
-
getStatus(): ReactorStatus;
|
|
112
87
|
/**
|
|
113
88
|
* Get the current state including status, error, and waiting info
|
|
114
89
|
*/
|
|
115
90
|
getState(): ReactorState$1;
|
|
116
|
-
/**
|
|
117
|
-
* Get waiting information when status is 'waiting'
|
|
118
|
-
*/
|
|
119
|
-
getWaitingInfo(): ReactorWaitingInfo | undefined;
|
|
120
91
|
/**
|
|
121
92
|
* Get the last error that occurred
|
|
122
93
|
*/
|
|
@@ -129,20 +100,20 @@ declare class Reactor {
|
|
|
129
100
|
|
|
130
101
|
interface ReactorState {
|
|
131
102
|
status: ReactorStatus;
|
|
132
|
-
videoTrack:
|
|
133
|
-
fps?: number;
|
|
134
|
-
waitingInfo?: ReactorWaitingInfo;
|
|
103
|
+
videoTrack: MediaStreamTrack | null;
|
|
135
104
|
lastError?: ReactorError;
|
|
105
|
+
sessionId?: string;
|
|
136
106
|
sessionExpiration?: number;
|
|
137
107
|
insecureApiKey?: string;
|
|
138
108
|
jwtToken?: string;
|
|
139
109
|
}
|
|
140
110
|
interface ReactorActions {
|
|
141
|
-
|
|
142
|
-
connect(
|
|
143
|
-
disconnect(): Promise<void>;
|
|
111
|
+
sendCommand(command: string, data: any): Promise<void>;
|
|
112
|
+
connect(jwtToken?: string): Promise<void>;
|
|
113
|
+
disconnect(recoverable?: boolean): Promise<void>;
|
|
144
114
|
publishVideoStream(stream: MediaStream): Promise<void>;
|
|
145
115
|
unpublishVideoStream(): Promise<void>;
|
|
116
|
+
reconnect(): Promise<void>;
|
|
146
117
|
}
|
|
147
118
|
interface ReactorInternalState {
|
|
148
119
|
reactor: Reactor;
|
|
@@ -151,17 +122,15 @@ type ReactorStore = ReactorState & ReactorActions & {
|
|
|
151
122
|
internal: ReactorInternalState;
|
|
152
123
|
};
|
|
153
124
|
interface ReactorInitializationProps extends Options {
|
|
154
|
-
insecureApiKey?: string;
|
|
155
125
|
jwtToken?: string;
|
|
156
126
|
}
|
|
157
127
|
|
|
158
128
|
interface ReactorProviderProps extends ReactorInitializationProps {
|
|
159
129
|
autoConnect?: boolean;
|
|
160
|
-
insecureApiKey?: string;
|
|
161
130
|
jwtToken?: string;
|
|
162
131
|
children: ReactNode;
|
|
163
132
|
}
|
|
164
|
-
declare function ReactorProvider({ children, autoConnect,
|
|
133
|
+
declare function ReactorProvider({ children, autoConnect, jwtToken, ...props }: ReactorProviderProps): react_jsx_runtime.JSX.Element;
|
|
165
134
|
declare function useReactorStore<T = ReactorStore>(selector: (state: ReactorStore) => T): T;
|
|
166
135
|
|
|
167
136
|
interface ReactorViewProps {
|
|
@@ -202,4 +171,4 @@ declare function useReactor<T>(selector: (state: ReactorStore) => T): T;
|
|
|
202
171
|
*/
|
|
203
172
|
declare function useReactorMessage(handler: (message: any) => void): void;
|
|
204
173
|
|
|
205
|
-
export { type Options, Reactor, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type
|
|
174
|
+
export { type Options, PROD_COORDINATOR_URL, Reactor, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, ReactorView, type ReactorViewProps, WebcamStream, useReactor, useReactorMessage, useReactorStore };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import React, { ReactNode } from 'react';
|
|
4
|
-
import { RemoteVideoTrack } from 'livekit-client';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal types for the Reactor SDK.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
declare const WaitingInfoDataSchema: z.ZodObject<{
|
|
11
|
-
position: z.ZodOptional<z.ZodNumber>;
|
|
12
|
-
estimatedWaitTime: z.ZodOptional<z.ZodNumber>;
|
|
13
|
-
averageWaitTime: z.ZodOptional<z.ZodNumber>;
|
|
14
|
-
}, z.core.$strip>;
|
|
15
|
-
declare const SessionExpirationDataSchema: z.ZodObject<{
|
|
16
|
-
expire: z.ZodNumber;
|
|
17
|
-
}, z.core.$strip>;
|
|
18
|
-
declare const ReactorAuthSchema: z.ZodObject<{
|
|
19
|
-
insecureApiKey: z.ZodOptional<z.ZodString>;
|
|
20
|
-
jwtToken: z.ZodOptional<z.ZodString>;
|
|
21
|
-
}, z.core.$strip>;
|
|
22
|
-
type ReactorAuth = z.infer<typeof ReactorAuthSchema>;
|
|
23
4
|
|
|
24
5
|
type ReactorStatus = "disconnected" | "connecting" | "waiting" | "ready";
|
|
25
|
-
interface ReactorWaitingInfo extends z$1.infer<typeof WaitingInfoDataSchema> {
|
|
26
|
-
}
|
|
27
|
-
interface ReactorSessionExpiration extends z$1.infer<typeof SessionExpirationDataSchema> {
|
|
28
|
-
}
|
|
29
6
|
interface ReactorError {
|
|
30
7
|
code: string;
|
|
31
8
|
message: string;
|
|
@@ -36,15 +13,14 @@ interface ReactorError {
|
|
|
36
13
|
}
|
|
37
14
|
interface ReactorState$1 {
|
|
38
15
|
status: ReactorStatus;
|
|
39
|
-
waitingInfo?: ReactorWaitingInfo;
|
|
40
16
|
lastError?: ReactorError;
|
|
41
17
|
}
|
|
42
|
-
type ReactorEvent = "statusChanged" | "
|
|
18
|
+
type ReactorEvent = "statusChanged" | "sessionIdChanged" | "newMessage" | "streamChanged" | "error" | "sessionExpirationChanged";
|
|
43
19
|
|
|
20
|
+
declare const PROD_COORDINATOR_URL = "https://api.reactor.inc";
|
|
44
21
|
declare const OptionsSchema: z.ZodObject<{
|
|
45
22
|
coordinatorUrl: z.ZodDefault<z.ZodString>;
|
|
46
23
|
modelName: z.ZodString;
|
|
47
|
-
queueing: z.ZodDefault<z.ZodBoolean>;
|
|
48
24
|
local: z.ZodDefault<z.ZodBoolean>;
|
|
49
25
|
}, z.core.$strip>;
|
|
50
26
|
type Options = z.input<typeof OptionsSchema>;
|
|
@@ -55,12 +31,10 @@ declare class Reactor {
|
|
|
55
31
|
private status;
|
|
56
32
|
private coordinatorUrl;
|
|
57
33
|
private lastError?;
|
|
58
|
-
private
|
|
59
|
-
private modelName;
|
|
60
|
-
private modelVersion;
|
|
61
|
-
private queueing;
|
|
34
|
+
private model;
|
|
62
35
|
private sessionExpiration?;
|
|
63
36
|
private local;
|
|
37
|
+
private sessionId?;
|
|
64
38
|
constructor(options: Options);
|
|
65
39
|
private eventListeners;
|
|
66
40
|
on(event: ReactorEvent, handler: EventHandler): void;
|
|
@@ -72,51 +46,48 @@ declare class Reactor {
|
|
|
72
46
|
* @param message The message to send to the machine.
|
|
73
47
|
* @throws Error if not in ready state
|
|
74
48
|
*/
|
|
75
|
-
|
|
49
|
+
sendCommand(command: string, data: any): Promise<void>;
|
|
76
50
|
/**
|
|
77
|
-
* Public method to publish a
|
|
78
|
-
* @param
|
|
51
|
+
* Public method to publish a track to the machine.
|
|
52
|
+
* @param track The track to send to the machine.
|
|
79
53
|
*/
|
|
80
|
-
|
|
54
|
+
publishTrack(track: MediaStreamTrack): Promise<void>;
|
|
81
55
|
/**
|
|
82
|
-
* Public method to unpublish
|
|
83
|
-
* This unpublishes the video track that was previously sent.
|
|
56
|
+
* Public method to unpublish the currently published track.
|
|
84
57
|
*/
|
|
85
|
-
|
|
58
|
+
unpublishTrack(): Promise<void>;
|
|
86
59
|
/**
|
|
87
|
-
*
|
|
88
|
-
* Once the machine is ready, the Reactor will establish the LiveKit connection.
|
|
89
|
-
* @param livekitJwtToken The JWT token for LiveKit authentication
|
|
90
|
-
* @param livekitWsUrl The WebSocket URL for LiveKit connection
|
|
60
|
+
* Public method for reconnecting to an existing session, that may have been interrupted but can be recovered.
|
|
91
61
|
*/
|
|
92
|
-
|
|
62
|
+
reconnect(): Promise<void>;
|
|
93
63
|
/**
|
|
94
64
|
* Connects to the coordinator and waits for a GPU to be assigned.
|
|
95
|
-
* Once a GPU is assigned, the Reactor will connect to the gpu machine via
|
|
65
|
+
* Once a GPU is assigned, the Reactor will connect to the gpu machine via WebRTC.
|
|
96
66
|
* If no authentication is provided and not in local mode, an error is thrown.
|
|
97
67
|
*/
|
|
98
|
-
connect(
|
|
68
|
+
connect(jwtToken?: string): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Sets up event handlers for the machine client.
|
|
71
|
+
*/
|
|
72
|
+
private setupMachineClientHandlers;
|
|
99
73
|
/**
|
|
100
74
|
* Disconnects from the coordinator and the gpu machine.
|
|
101
75
|
* Ensures cleanup completes even if individual disconnections fail.
|
|
102
76
|
*/
|
|
103
|
-
disconnect(): Promise<void>;
|
|
77
|
+
disconnect(recoverable?: boolean): Promise<void>;
|
|
78
|
+
private setSessionId;
|
|
79
|
+
getSessionId(): string | undefined;
|
|
104
80
|
private setStatus;
|
|
105
|
-
|
|
81
|
+
getStatus(): ReactorStatus;
|
|
106
82
|
/**
|
|
107
83
|
* Set the session expiration time.
|
|
108
84
|
* @param newSessionExpiration The new session expiration time in seconds.
|
|
109
85
|
*/
|
|
110
86
|
private setSessionExpiration;
|
|
111
|
-
getStatus(): ReactorStatus;
|
|
112
87
|
/**
|
|
113
88
|
* Get the current state including status, error, and waiting info
|
|
114
89
|
*/
|
|
115
90
|
getState(): ReactorState$1;
|
|
116
|
-
/**
|
|
117
|
-
* Get waiting information when status is 'waiting'
|
|
118
|
-
*/
|
|
119
|
-
getWaitingInfo(): ReactorWaitingInfo | undefined;
|
|
120
91
|
/**
|
|
121
92
|
* Get the last error that occurred
|
|
122
93
|
*/
|
|
@@ -129,20 +100,20 @@ declare class Reactor {
|
|
|
129
100
|
|
|
130
101
|
interface ReactorState {
|
|
131
102
|
status: ReactorStatus;
|
|
132
|
-
videoTrack:
|
|
133
|
-
fps?: number;
|
|
134
|
-
waitingInfo?: ReactorWaitingInfo;
|
|
103
|
+
videoTrack: MediaStreamTrack | null;
|
|
135
104
|
lastError?: ReactorError;
|
|
105
|
+
sessionId?: string;
|
|
136
106
|
sessionExpiration?: number;
|
|
137
107
|
insecureApiKey?: string;
|
|
138
108
|
jwtToken?: string;
|
|
139
109
|
}
|
|
140
110
|
interface ReactorActions {
|
|
141
|
-
|
|
142
|
-
connect(
|
|
143
|
-
disconnect(): Promise<void>;
|
|
111
|
+
sendCommand(command: string, data: any): Promise<void>;
|
|
112
|
+
connect(jwtToken?: string): Promise<void>;
|
|
113
|
+
disconnect(recoverable?: boolean): Promise<void>;
|
|
144
114
|
publishVideoStream(stream: MediaStream): Promise<void>;
|
|
145
115
|
unpublishVideoStream(): Promise<void>;
|
|
116
|
+
reconnect(): Promise<void>;
|
|
146
117
|
}
|
|
147
118
|
interface ReactorInternalState {
|
|
148
119
|
reactor: Reactor;
|
|
@@ -151,17 +122,15 @@ type ReactorStore = ReactorState & ReactorActions & {
|
|
|
151
122
|
internal: ReactorInternalState;
|
|
152
123
|
};
|
|
153
124
|
interface ReactorInitializationProps extends Options {
|
|
154
|
-
insecureApiKey?: string;
|
|
155
125
|
jwtToken?: string;
|
|
156
126
|
}
|
|
157
127
|
|
|
158
128
|
interface ReactorProviderProps extends ReactorInitializationProps {
|
|
159
129
|
autoConnect?: boolean;
|
|
160
|
-
insecureApiKey?: string;
|
|
161
130
|
jwtToken?: string;
|
|
162
131
|
children: ReactNode;
|
|
163
132
|
}
|
|
164
|
-
declare function ReactorProvider({ children, autoConnect,
|
|
133
|
+
declare function ReactorProvider({ children, autoConnect, jwtToken, ...props }: ReactorProviderProps): react_jsx_runtime.JSX.Element;
|
|
165
134
|
declare function useReactorStore<T = ReactorStore>(selector: (state: ReactorStore) => T): T;
|
|
166
135
|
|
|
167
136
|
interface ReactorViewProps {
|
|
@@ -202,4 +171,4 @@ declare function useReactor<T>(selector: (state: ReactorStore) => T): T;
|
|
|
202
171
|
*/
|
|
203
172
|
declare function useReactorMessage(handler: (message: any) => void): void;
|
|
204
173
|
|
|
205
|
-
export { type Options, Reactor, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type
|
|
174
|
+
export { type Options, PROD_COORDINATOR_URL, Reactor, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, ReactorView, type ReactorViewProps, WebcamStream, useReactor, useReactorMessage, useReactorStore };
|