@reactor-models/h3-reference-to-video-turbo-realtime 0.3.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 +1401 -0
- package/dist/chunk-G3JJXOQR.mjs +343 -0
- package/dist/chunk-G3JJXOQR.mjs.map +1 -0
- package/dist/chunk-NXDKLVKO.mjs +301 -0
- package/dist/chunk-NXDKLVKO.mjs.map +1 -0
- package/dist/core.d.mts +621 -0
- package/dist/core.d.ts +621 -0
- package/dist/core.js +371 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +15 -0
- package/dist/core.mjs.map +1 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +683 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +61 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react.d.mts +185 -0
- package/dist/react.d.ts +185 -0
- package/dist/react.js +347 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +51 -0
- package/dist/react.mjs.map +1 -0
- package/package.json +54 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,683 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
FileRef: () => import_js_sdk.FileRef,
|
|
24
|
+
H3ReferenceToVideoTurboRealtimeMainVideoView: () => H3ReferenceToVideoTurboRealtimeMainVideoView,
|
|
25
|
+
H3ReferenceToVideoTurboRealtimeModel: () => H3ReferenceToVideoTurboRealtimeModel,
|
|
26
|
+
H3ReferenceToVideoTurboRealtimeProvider: () => H3ReferenceToVideoTurboRealtimeProvider,
|
|
27
|
+
H3ReferenceToVideoTurboRealtimeTracks: () => H3ReferenceToVideoTurboRealtimeTracks,
|
|
28
|
+
MODEL_NAME: () => MODEL_NAME,
|
|
29
|
+
MODEL_VERSION: () => MODEL_VERSION,
|
|
30
|
+
useH3ReferenceToVideoTurboRealtime: () => useH3ReferenceToVideoTurboRealtime,
|
|
31
|
+
useH3ReferenceToVideoTurboRealtimeAutoplayAccepted: () => useH3ReferenceToVideoTurboRealtimeAutoplayAccepted,
|
|
32
|
+
useH3ReferenceToVideoTurboRealtimeCanvasAccepted: () => useH3ReferenceToVideoTurboRealtimeCanvasAccepted,
|
|
33
|
+
useH3ReferenceToVideoTurboRealtimeClipFailed: () => useH3ReferenceToVideoTurboRealtimeClipFailed,
|
|
34
|
+
useH3ReferenceToVideoTurboRealtimeClipFinished: () => useH3ReferenceToVideoTurboRealtimeClipFinished,
|
|
35
|
+
useH3ReferenceToVideoTurboRealtimeClipGenerated: () => useH3ReferenceToVideoTurboRealtimeClipGenerated,
|
|
36
|
+
useH3ReferenceToVideoTurboRealtimeClipLengthAccepted: () => useH3ReferenceToVideoTurboRealtimeClipLengthAccepted,
|
|
37
|
+
useH3ReferenceToVideoTurboRealtimeClipMoved: () => useH3ReferenceToVideoTurboRealtimeClipMoved,
|
|
38
|
+
useH3ReferenceToVideoTurboRealtimeClipPopped: () => useH3ReferenceToVideoTurboRealtimeClipPopped,
|
|
39
|
+
useH3ReferenceToVideoTurboRealtimeClipQueued: () => useH3ReferenceToVideoTurboRealtimeClipQueued,
|
|
40
|
+
useH3ReferenceToVideoTurboRealtimeClipStarted: () => useH3ReferenceToVideoTurboRealtimeClipStarted,
|
|
41
|
+
useH3ReferenceToVideoTurboRealtimeClipStopped: () => useH3ReferenceToVideoTurboRealtimeClipStopped,
|
|
42
|
+
useH3ReferenceToVideoTurboRealtimeCommandError: () => useH3ReferenceToVideoTurboRealtimeCommandError,
|
|
43
|
+
useH3ReferenceToVideoTurboRealtimeFlushAccepted: () => useH3ReferenceToVideoTurboRealtimeFlushAccepted,
|
|
44
|
+
useH3ReferenceToVideoTurboRealtimeMessage: () => useH3ReferenceToVideoTurboRealtimeMessage,
|
|
45
|
+
useH3ReferenceToVideoTurboRealtimeQueueUpdate: () => useH3ReferenceToVideoTurboRealtimeQueueUpdate,
|
|
46
|
+
useH3ReferenceToVideoTurboRealtimeSeedAccepted: () => useH3ReferenceToVideoTurboRealtimeSeedAccepted,
|
|
47
|
+
useH3ReferenceToVideoTurboRealtimeSessionReset: () => useH3ReferenceToVideoTurboRealtimeSessionReset,
|
|
48
|
+
useH3ReferenceToVideoTurboRealtimeStateUpdate: () => useH3ReferenceToVideoTurboRealtimeStateUpdate,
|
|
49
|
+
useH3ReferenceToVideoTurboRealtimeTrack: () => useH3ReferenceToVideoTurboRealtimeTrack
|
|
50
|
+
});
|
|
51
|
+
module.exports = __toCommonJS(index_exports);
|
|
52
|
+
|
|
53
|
+
// src/core.ts
|
|
54
|
+
var import_js_sdk = require("@reactor-team/js-sdk");
|
|
55
|
+
var MODEL_NAME = "reactor/h3-reference-to-video-turbo-realtime";
|
|
56
|
+
var MODEL_VERSION = "v0.3.0";
|
|
57
|
+
var H3ReferenceToVideoTurboRealtimeTracks = [
|
|
58
|
+
{ name: "main_video", kind: "video", direction: "recvonly" },
|
|
59
|
+
{ name: "main_audio", kind: "audio", direction: "recvonly" }
|
|
60
|
+
];
|
|
61
|
+
function _unwrapMessage(raw) {
|
|
62
|
+
const env = raw;
|
|
63
|
+
if (env && typeof env === "object" && env.data && typeof env.data === "object") {
|
|
64
|
+
return { ...env.data, type: env.type };
|
|
65
|
+
}
|
|
66
|
+
return raw;
|
|
67
|
+
}
|
|
68
|
+
var H3ReferenceToVideoTurboRealtimeModel = class extends import_js_sdk.Reactor {
|
|
69
|
+
constructor(options) {
|
|
70
|
+
super({
|
|
71
|
+
...options,
|
|
72
|
+
modelName: MODEL_NAME,
|
|
73
|
+
modelTracks: [...H3ReferenceToVideoTurboRealtimeTracks]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/** @deprecated The model client now extends `Reactor` directly — call methods on `this` instead. This accessor returns `this` for backwards compatibility and will be removed in a future major release. */
|
|
77
|
+
get reactor() {
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Remove a clip from its queue; reply clip_popped and emit queue_update and state_update. A running build finishes but is discarded. Refuses with command_error for a missing/unknown id. Use stop for the playing clip.
|
|
82
|
+
* @param params - Remove a clip from its queue; reply clip_popped and emit queue_update and state_update. A running build finishes but is discarded. Refuses with command_error for a missing/unknown id. Use stop for the playing clip.
|
|
83
|
+
* @returns The correlated {@link H3ReferenceToVideoTurboRealtimeClipPoppedMessage} reply, or `undefined` when the send fails (the SDK never rejects — see `getLastError()`).
|
|
84
|
+
*/
|
|
85
|
+
async pop(params) {
|
|
86
|
+
const reply = await this.sendCommand("pop", params);
|
|
87
|
+
return reply === void 0 ? void 0 : _unwrapMessage(reply);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Reposition within the current queue, 0 = front. A running build is unaffected. Replies clip_moved and emits queue_update; refuses with command_error for a missing/unknown id or invalid position.
|
|
91
|
+
* @param params - Reposition within the current queue, 0 = front. A running build is unaffected. Replies clip_moved and emits queue_update; refuses with command_error for a missing/unknown id or invalid position.
|
|
92
|
+
* @returns The correlated {@link H3ReferenceToVideoTurboRealtimeClipMovedMessage} reply, or `undefined` when the send fails (the SDK never rejects — see `getLastError()`).
|
|
93
|
+
*/
|
|
94
|
+
async move(params) {
|
|
95
|
+
const reply = await this.sendCommand("move", params);
|
|
96
|
+
return reply === void 0 ? void 0 : _unwrapMessage(reply);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Play the front ready clip, or a named ready clip. Consumes it and emits clip_started, queue_update and state_update. Refuses with command_error if already playing or no matching ready clip exists.
|
|
100
|
+
* @param params - Play the front ready clip, or a named ready clip. Consumes it and emits clip_started, queue_update and state_update. Refuses with command_error if already playing or no matching ready clip exists.
|
|
101
|
+
* @returns Resolves once the model's handler has completed; this command declares no reply payload.
|
|
102
|
+
*/
|
|
103
|
+
async play(params) {
|
|
104
|
+
await this.sendCommand("play", params);
|
|
105
|
+
return void 0;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Cut playback and emit clip_stopped and state_update; queues are untouched. Under autoplay this skips to the next clip. Refuses with command_error when nothing is playing.
|
|
109
|
+
* @returns Resolves once the model's handler has completed; this command declares no reply payload.
|
|
110
|
+
*/
|
|
111
|
+
async stop() {
|
|
112
|
+
await this.sendCommand("stop", {});
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Drop both queues, cut playback, restore defaults and clear tracks. Replies session_reset; emits queue_update, state_update and clip_stopped if playing. In-flight results are discarded.
|
|
117
|
+
* @returns The correlated {@link H3ReferenceToVideoTurboRealtimeSessionResetMessage} reply, or `undefined` when the send fails (the SDK never rejects — see `getLastError()`).
|
|
118
|
+
*/
|
|
119
|
+
async reset() {
|
|
120
|
+
const reply = await this.sendCommand("reset", {});
|
|
121
|
+
return reply === void 0 ? void 0 : _unwrapMessage(reply);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Queue a clip with 1–9 reference images at position, or at the back. Each clip keeps its own prompt and ordered references: new images do not alter earlier requests. The images guide appearance, not a fixed first or last frame. Replies clip_queued and broadcasts queue_update and state_update; completion emits clip_generated. Refuses with command_error for empty text, missing/invalid reference, invalid parameters or a full generation queue.
|
|
125
|
+
* @param params - Queue a clip with 1–9 reference images at position, or at the back. Each clip keeps its own prompt and ordered references: new images do not alter earlier requests. The images guide appearance, not a fixed first or last frame. Replies clip_queued and broadcasts queue_update and state_update; completion emits clip_generated. Refuses with command_error for empty text, missing/invalid reference, invalid parameters or a full generation queue.
|
|
126
|
+
* @returns The correlated {@link H3ReferenceToVideoTurboRealtimeClipQueuedMessage} reply, or `undefined` when the send fails (the SDK never rejects — see `getLastError()`).
|
|
127
|
+
*/
|
|
128
|
+
async enqueue(params) {
|
|
129
|
+
const reply = await this.sendCommand("enqueue", params);
|
|
130
|
+
return reply === void 0 ? void 0 : _unwrapMessage(reply);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Set the advancing default seed for future enqueues. Replies seed_accepted and emits state_update; an invalid seed emits command_error. Explicit per-clip seeds do not advance it.
|
|
134
|
+
* @param params - Set the advancing default seed for future enqueues. Replies seed_accepted and emits state_update; an invalid seed emits command_error. Explicit per-clip seeds do not advance it.
|
|
135
|
+
* @returns The correlated {@link H3ReferenceToVideoTurboRealtimeSeedAcceptedMessage} reply, or `undefined` when the send fails (the SDK never rejects — see `getLastError()`).
|
|
136
|
+
*/
|
|
137
|
+
async setSeed(params) {
|
|
138
|
+
const reply = await this.sendCommand("set_seed", params);
|
|
139
|
+
return reply === void 0 ? void 0 : _unwrapMessage(reply);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Reply queue_update with both queues in full. The history field is always empty: a played clip is not listed and cannot be replayed, though a generated clip can still seed a new one through `enqueue.continue_from_clip_id`. Valid at any time.
|
|
143
|
+
* @returns The correlated {@link H3ReferenceToVideoTurboRealtimeQueueUpdateMessage} reply, or `undefined` when the send fails (the SDK never rejects — see `getLastError()`).
|
|
144
|
+
*/
|
|
145
|
+
async getQueue() {
|
|
146
|
+
const reply = await this.sendCommand("get_queue", {});
|
|
147
|
+
return reply === void 0 ? void 0 : _unwrapMessage(reply);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Reply state_update with defaults, capacities, playback progress and valid_commands. Valid at any time.
|
|
151
|
+
* @returns The correlated {@link H3ReferenceToVideoTurboRealtimeStateUpdateMessage} reply, or `undefined` when the send fails (the SDK never rejects — see `getLastError()`).
|
|
152
|
+
*/
|
|
153
|
+
async getState() {
|
|
154
|
+
const reply = await this.sendCommand("get_state", {});
|
|
155
|
+
return reply === void 0 ? void 0 : _unwrapMessage(reply);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Set the canvas while both queues and playback are empty. Replies canvas_accepted and emits state_update; refuses with command_error for an unsupported aspect or nonempty session.
|
|
159
|
+
* @param params - Set the canvas while both queues and playback are empty. Replies canvas_accepted and emits state_update; refuses with command_error for an unsupported aspect or nonempty session.
|
|
160
|
+
* @returns The correlated {@link H3ReferenceToVideoTurboRealtimeCanvasAcceptedMessage} reply, or `undefined` when the send fails (the SDK never rejects — see `getLastError()`).
|
|
161
|
+
*/
|
|
162
|
+
async setCanvas(params) {
|
|
163
|
+
const reply = await this.sendCommand("set_canvas", params);
|
|
164
|
+
return reply === void 0 ? void 0 : _unwrapMessage(reply);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Automatically play ready clips whenever idle. Empty queues wait; no prompts are generated automatically. Replies autoplay_accepted and emits state_update.
|
|
168
|
+
* @param params - Automatically play ready clips whenever idle. Empty queues wait; no prompts are generated automatically. Replies autoplay_accepted and emits state_update.
|
|
169
|
+
* @returns The correlated {@link H3ReferenceToVideoTurboRealtimeAutoplayAcceptedMessage} reply, or `undefined` when the send fails (the SDK never rejects — see `getLastError()`).
|
|
170
|
+
*/
|
|
171
|
+
async setAutoplay(params) {
|
|
172
|
+
const reply = await this.sendCommand("set_autoplay", params);
|
|
173
|
+
return reply === void 0 ? void 0 : _unwrapMessage(reply);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Set the duration for future enqueues, aligned to a supported frame count. Replies clip_length_accepted and emits state_update; invalid lengths emit command_error. Queued clips keep their lengths.
|
|
177
|
+
* @param params - Set the duration for future enqueues, aligned to a supported frame count. Replies clip_length_accepted and emits state_update; invalid lengths emit command_error. Queued clips keep their lengths.
|
|
178
|
+
* @returns The correlated {@link H3ReferenceToVideoTurboRealtimeClipLengthAcceptedMessage} reply, or `undefined` when the send fails (the SDK never rejects — see `getLastError()`).
|
|
179
|
+
*/
|
|
180
|
+
async setClipSeconds(params) {
|
|
181
|
+
const reply = await this.sendCommand("set_clip_seconds", params);
|
|
182
|
+
return reply === void 0 ? void 0 : _unwrapMessage(reply);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Choose black or a held last frame at boundaries. Off carries the playback clock across ready autoplay clips without flushing. Does not guarantee visual continuity; reset always clears tracks. Replies flush_accepted and emits state_update.
|
|
186
|
+
* @param params - Choose black or a held last frame at boundaries. Off carries the playback clock across ready autoplay clips without flushing. Does not guarantee visual continuity; reset always clears tracks. Replies flush_accepted and emits state_update.
|
|
187
|
+
* @returns The correlated {@link H3ReferenceToVideoTurboRealtimeFlushAcceptedMessage} reply, or `undefined` when the send fails (the SDK never rejects — see `getLastError()`).
|
|
188
|
+
*/
|
|
189
|
+
async setFlushOnClipEnd(params) {
|
|
190
|
+
const reply = await this.sendCommand("set_flush_on_clip_end", params);
|
|
191
|
+
return reply === void 0 ? void 0 : _unwrapMessage(reply);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Subscribe to typed model messages.
|
|
195
|
+
* @param handler - Called with a discriminated H3ReferenceToVideoTurboRealtimeMessage
|
|
196
|
+
* @returns Unsubscribe function
|
|
197
|
+
*/
|
|
198
|
+
onMessage(handler) {
|
|
199
|
+
const wrappedHandler = (raw) => {
|
|
200
|
+
handler(_unwrapMessage(raw));
|
|
201
|
+
};
|
|
202
|
+
this.on("message", wrappedHandler);
|
|
203
|
+
return () => this.off("message", wrappedHandler);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Subscribe to "clip_moved" messages only.
|
|
207
|
+
* @returns Unsubscribe function
|
|
208
|
+
*/
|
|
209
|
+
onClipMoved(handler) {
|
|
210
|
+
return this.onMessage((msg) => {
|
|
211
|
+
if (msg.type === "clip_moved") handler(msg);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Subscribe to "clip_failed" messages only.
|
|
216
|
+
* @returns Unsubscribe function
|
|
217
|
+
*/
|
|
218
|
+
onClipFailed(handler) {
|
|
219
|
+
return this.onMessage((msg) => {
|
|
220
|
+
if (msg.type === "clip_failed") handler(msg);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Subscribe to "clip_popped" messages only.
|
|
225
|
+
* @returns Unsubscribe function
|
|
226
|
+
*/
|
|
227
|
+
onClipPopped(handler) {
|
|
228
|
+
return this.onMessage((msg) => {
|
|
229
|
+
if (msg.type === "clip_popped") handler(msg);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Subscribe to "clip_queued" messages only.
|
|
234
|
+
* @returns Unsubscribe function
|
|
235
|
+
*/
|
|
236
|
+
onClipQueued(handler) {
|
|
237
|
+
return this.onMessage((msg) => {
|
|
238
|
+
if (msg.type === "clip_queued") handler(msg);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Subscribe to "clip_started" messages only.
|
|
243
|
+
* @returns Unsubscribe function
|
|
244
|
+
*/
|
|
245
|
+
onClipStarted(handler) {
|
|
246
|
+
return this.onMessage((msg) => {
|
|
247
|
+
if (msg.type === "clip_started") handler(msg);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Subscribe to "clip_stopped" messages only.
|
|
252
|
+
* @returns Unsubscribe function
|
|
253
|
+
*/
|
|
254
|
+
onClipStopped(handler) {
|
|
255
|
+
return this.onMessage((msg) => {
|
|
256
|
+
if (msg.type === "clip_stopped") handler(msg);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Subscribe to "queue_update" messages only.
|
|
261
|
+
* @returns Unsubscribe function
|
|
262
|
+
*/
|
|
263
|
+
onQueueUpdate(handler) {
|
|
264
|
+
return this.onMessage((msg) => {
|
|
265
|
+
if (msg.type === "queue_update") handler(msg);
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Subscribe to "state_update" messages only.
|
|
270
|
+
* @returns Unsubscribe function
|
|
271
|
+
*/
|
|
272
|
+
onStateUpdate(handler) {
|
|
273
|
+
return this.onMessage((msg) => {
|
|
274
|
+
if (msg.type === "state_update") handler(msg);
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Subscribe to "clip_finished" messages only.
|
|
279
|
+
* @returns Unsubscribe function
|
|
280
|
+
*/
|
|
281
|
+
onClipFinished(handler) {
|
|
282
|
+
return this.onMessage((msg) => {
|
|
283
|
+
if (msg.type === "clip_finished") handler(msg);
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Subscribe to "command_error" messages only.
|
|
288
|
+
* @returns Unsubscribe function
|
|
289
|
+
*/
|
|
290
|
+
onCommandError(handler) {
|
|
291
|
+
return this.onMessage((msg) => {
|
|
292
|
+
if (msg.type === "command_error") handler(msg);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Subscribe to "seed_accepted" messages only.
|
|
297
|
+
* @returns Unsubscribe function
|
|
298
|
+
*/
|
|
299
|
+
onSeedAccepted(handler) {
|
|
300
|
+
return this.onMessage((msg) => {
|
|
301
|
+
if (msg.type === "seed_accepted") handler(msg);
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Subscribe to "session_reset" messages only.
|
|
306
|
+
* @returns Unsubscribe function
|
|
307
|
+
*/
|
|
308
|
+
onSessionReset(handler) {
|
|
309
|
+
return this.onMessage((msg) => {
|
|
310
|
+
if (msg.type === "session_reset") handler(msg);
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Subscribe to "clip_generated" messages only.
|
|
315
|
+
* @returns Unsubscribe function
|
|
316
|
+
*/
|
|
317
|
+
onClipGenerated(handler) {
|
|
318
|
+
return this.onMessage((msg) => {
|
|
319
|
+
if (msg.type === "clip_generated") handler(msg);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Subscribe to "flush_accepted" messages only.
|
|
324
|
+
* @returns Unsubscribe function
|
|
325
|
+
*/
|
|
326
|
+
onFlushAccepted(handler) {
|
|
327
|
+
return this.onMessage((msg) => {
|
|
328
|
+
if (msg.type === "flush_accepted") handler(msg);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Subscribe to "canvas_accepted" messages only.
|
|
333
|
+
* @returns Unsubscribe function
|
|
334
|
+
*/
|
|
335
|
+
onCanvasAccepted(handler) {
|
|
336
|
+
return this.onMessage((msg) => {
|
|
337
|
+
if (msg.type === "canvas_accepted") handler(msg);
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Subscribe to "autoplay_accepted" messages only.
|
|
342
|
+
* @returns Unsubscribe function
|
|
343
|
+
*/
|
|
344
|
+
onAutoplayAccepted(handler) {
|
|
345
|
+
return this.onMessage((msg) => {
|
|
346
|
+
if (msg.type === "autoplay_accepted") handler(msg);
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Subscribe to "clip_length_accepted" messages only.
|
|
351
|
+
* @returns Unsubscribe function
|
|
352
|
+
*/
|
|
353
|
+
onClipLengthAccepted(handler) {
|
|
354
|
+
return this.onMessage((msg) => {
|
|
355
|
+
if (msg.type === "clip_length_accepted") handler(msg);
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Subscribe to the "main_video" recvonly video track the model publishes.
|
|
360
|
+
*
|
|
361
|
+
* The handler fires once the model starts publishing this track; it receives the live MediaStreamTrack and the parent MediaStream (useful for attaching to a `<video>` / `<audio>` element via `srcObject`).
|
|
362
|
+
* @param handler - Called with the received track and its stream
|
|
363
|
+
* @returns Unsubscribe function
|
|
364
|
+
*/
|
|
365
|
+
onMainVideo(handler) {
|
|
366
|
+
const wrapped = (name, t, s) => {
|
|
367
|
+
if (name === "main_video") handler(t, s);
|
|
368
|
+
};
|
|
369
|
+
this.on("trackReceived", wrapped);
|
|
370
|
+
return () => this.off("trackReceived", wrapped);
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Subscribe to the "main_audio" recvonly audio track the model publishes.
|
|
374
|
+
*
|
|
375
|
+
* The handler fires once the model starts publishing this track; it receives the live MediaStreamTrack and the parent MediaStream (useful for attaching to a `<video>` / `<audio>` element via `srcObject`).
|
|
376
|
+
* @param handler - Called with the received track and its stream
|
|
377
|
+
* @returns Unsubscribe function
|
|
378
|
+
*/
|
|
379
|
+
onMainAudio(handler) {
|
|
380
|
+
const wrapped = (name, t, s) => {
|
|
381
|
+
if (name === "main_audio") handler(t, s);
|
|
382
|
+
};
|
|
383
|
+
this.on("trackReceived", wrapped);
|
|
384
|
+
return () => this.off("trackReceived", wrapped);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
// src/react.tsx
|
|
389
|
+
var import_js_sdk2 = require("@reactor-team/js-sdk");
|
|
390
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
391
|
+
function _unwrapMessage2(raw) {
|
|
392
|
+
const env = raw;
|
|
393
|
+
if (env && typeof env === "object" && env.data && typeof env.data === "object") {
|
|
394
|
+
return { ...env.data, type: env.type };
|
|
395
|
+
}
|
|
396
|
+
return raw;
|
|
397
|
+
}
|
|
398
|
+
function H3ReferenceToVideoTurboRealtimeProvider({
|
|
399
|
+
children,
|
|
400
|
+
...rest
|
|
401
|
+
}) {
|
|
402
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
403
|
+
import_js_sdk2.ReactorProvider,
|
|
404
|
+
{
|
|
405
|
+
...rest,
|
|
406
|
+
modelName: MODEL_NAME,
|
|
407
|
+
modelTracks: [...H3ReferenceToVideoTurboRealtimeTracks],
|
|
408
|
+
children
|
|
409
|
+
}
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
function useH3ReferenceToVideoTurboRealtime() {
|
|
413
|
+
const connect = (0, import_js_sdk2.useReactor)((s) => s.connect);
|
|
414
|
+
const connectOptions = (0, import_js_sdk2.useReactor)((s) => s.connectOptions);
|
|
415
|
+
const disconnect = (0, import_js_sdk2.useReactor)((s) => s.disconnect);
|
|
416
|
+
const downloadClipAsFile = (0, import_js_sdk2.useReactor)((s) => s.downloadClipAsFile);
|
|
417
|
+
const jwtToken = (0, import_js_sdk2.useReactor)((s) => s.jwtToken);
|
|
418
|
+
const lastError = (0, import_js_sdk2.useReactor)((s) => s.lastError);
|
|
419
|
+
const lastMessage = (0, import_js_sdk2.useReactor)((s) => s.lastMessage);
|
|
420
|
+
const pauseTrack = (0, import_js_sdk2.useReactor)((s) => s.pauseTrack);
|
|
421
|
+
const publish = (0, import_js_sdk2.useReactor)((s) => s.publish);
|
|
422
|
+
const reconnect = (0, import_js_sdk2.useReactor)((s) => s.reconnect);
|
|
423
|
+
const requestClip = (0, import_js_sdk2.useReactor)((s) => s.requestClip);
|
|
424
|
+
const requestRecording = (0, import_js_sdk2.useReactor)((s) => s.requestRecording);
|
|
425
|
+
const resumeTrack = (0, import_js_sdk2.useReactor)((s) => s.resumeTrack);
|
|
426
|
+
const sendCommand = (0, import_js_sdk2.useReactor)((s) => s.sendCommand);
|
|
427
|
+
const sessionId = (0, import_js_sdk2.useReactor)((s) => s.sessionId);
|
|
428
|
+
const status = (0, import_js_sdk2.useReactor)((s) => s.status);
|
|
429
|
+
const tracks = (0, import_js_sdk2.useReactor)((s) => s.tracks);
|
|
430
|
+
const unpublish = (0, import_js_sdk2.useReactor)((s) => s.unpublish);
|
|
431
|
+
const uploadFile = (0, import_js_sdk2.useReactor)((s) => s.uploadFile);
|
|
432
|
+
return {
|
|
433
|
+
connect,
|
|
434
|
+
connectOptions,
|
|
435
|
+
disconnect,
|
|
436
|
+
downloadClipAsFile,
|
|
437
|
+
jwtToken,
|
|
438
|
+
lastError,
|
|
439
|
+
lastMessage,
|
|
440
|
+
pauseTrack,
|
|
441
|
+
publish,
|
|
442
|
+
reconnect,
|
|
443
|
+
requestClip,
|
|
444
|
+
requestRecording,
|
|
445
|
+
resumeTrack,
|
|
446
|
+
sendCommand,
|
|
447
|
+
sessionId,
|
|
448
|
+
status,
|
|
449
|
+
tracks,
|
|
450
|
+
unpublish,
|
|
451
|
+
uploadFile,
|
|
452
|
+
pop: async (params) => {
|
|
453
|
+
const reply = await sendCommand("pop", params);
|
|
454
|
+
return reply === void 0 ? void 0 : _unwrapMessage2(reply);
|
|
455
|
+
},
|
|
456
|
+
move: async (params) => {
|
|
457
|
+
const reply = await sendCommand("move", params);
|
|
458
|
+
return reply === void 0 ? void 0 : _unwrapMessage2(reply);
|
|
459
|
+
},
|
|
460
|
+
play: async (params) => {
|
|
461
|
+
await sendCommand("play", params);
|
|
462
|
+
return void 0;
|
|
463
|
+
},
|
|
464
|
+
stop: async () => {
|
|
465
|
+
await sendCommand("stop", {});
|
|
466
|
+
return void 0;
|
|
467
|
+
},
|
|
468
|
+
reset: async () => {
|
|
469
|
+
const reply = await sendCommand("reset", {});
|
|
470
|
+
return reply === void 0 ? void 0 : _unwrapMessage2(reply);
|
|
471
|
+
},
|
|
472
|
+
enqueue: async (params) => {
|
|
473
|
+
const reply = await sendCommand("enqueue", params);
|
|
474
|
+
return reply === void 0 ? void 0 : _unwrapMessage2(reply);
|
|
475
|
+
},
|
|
476
|
+
setSeed: async (params) => {
|
|
477
|
+
const reply = await sendCommand("set_seed", params);
|
|
478
|
+
return reply === void 0 ? void 0 : _unwrapMessage2(reply);
|
|
479
|
+
},
|
|
480
|
+
getQueue: async () => {
|
|
481
|
+
const reply = await sendCommand("get_queue", {});
|
|
482
|
+
return reply === void 0 ? void 0 : _unwrapMessage2(reply);
|
|
483
|
+
},
|
|
484
|
+
getState: async () => {
|
|
485
|
+
const reply = await sendCommand("get_state", {});
|
|
486
|
+
return reply === void 0 ? void 0 : _unwrapMessage2(reply);
|
|
487
|
+
},
|
|
488
|
+
setCanvas: async (params) => {
|
|
489
|
+
const reply = await sendCommand("set_canvas", params);
|
|
490
|
+
return reply === void 0 ? void 0 : _unwrapMessage2(reply);
|
|
491
|
+
},
|
|
492
|
+
setAutoplay: async (params) => {
|
|
493
|
+
const reply = await sendCommand("set_autoplay", params);
|
|
494
|
+
return reply === void 0 ? void 0 : _unwrapMessage2(reply);
|
|
495
|
+
},
|
|
496
|
+
setClipSeconds: async (params) => {
|
|
497
|
+
const reply = await sendCommand("set_clip_seconds", params);
|
|
498
|
+
return reply === void 0 ? void 0 : _unwrapMessage2(reply);
|
|
499
|
+
},
|
|
500
|
+
setFlushOnClipEnd: async (params) => {
|
|
501
|
+
const reply = await sendCommand("set_flush_on_clip_end", params);
|
|
502
|
+
return reply === void 0 ? void 0 : _unwrapMessage2(reply);
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
function useH3ReferenceToVideoTurboRealtimeMessage(handler) {
|
|
507
|
+
(0, import_js_sdk2.useReactorMessage)(
|
|
508
|
+
(msg) => handler(_unwrapMessage2(msg))
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
function useH3ReferenceToVideoTurboRealtimeClipMoved(handler) {
|
|
512
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
513
|
+
const m = _unwrapMessage2(msg);
|
|
514
|
+
if (m.type === "clip_moved") {
|
|
515
|
+
handler(m);
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
function useH3ReferenceToVideoTurboRealtimeClipFailed(handler) {
|
|
520
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
521
|
+
const m = _unwrapMessage2(msg);
|
|
522
|
+
if (m.type === "clip_failed") {
|
|
523
|
+
handler(m);
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
function useH3ReferenceToVideoTurboRealtimeClipPopped(handler) {
|
|
528
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
529
|
+
const m = _unwrapMessage2(msg);
|
|
530
|
+
if (m.type === "clip_popped") {
|
|
531
|
+
handler(m);
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
function useH3ReferenceToVideoTurboRealtimeClipQueued(handler) {
|
|
536
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
537
|
+
const m = _unwrapMessage2(msg);
|
|
538
|
+
if (m.type === "clip_queued") {
|
|
539
|
+
handler(m);
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
function useH3ReferenceToVideoTurboRealtimeClipStarted(handler) {
|
|
544
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
545
|
+
const m = _unwrapMessage2(msg);
|
|
546
|
+
if (m.type === "clip_started") {
|
|
547
|
+
handler(m);
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
function useH3ReferenceToVideoTurboRealtimeClipStopped(handler) {
|
|
552
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
553
|
+
const m = _unwrapMessage2(msg);
|
|
554
|
+
if (m.type === "clip_stopped") {
|
|
555
|
+
handler(m);
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
function useH3ReferenceToVideoTurboRealtimeQueueUpdate(handler) {
|
|
560
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
561
|
+
const m = _unwrapMessage2(msg);
|
|
562
|
+
if (m.type === "queue_update") {
|
|
563
|
+
handler(m);
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
function useH3ReferenceToVideoTurboRealtimeStateUpdate(handler) {
|
|
568
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
569
|
+
const m = _unwrapMessage2(msg);
|
|
570
|
+
if (m.type === "state_update") {
|
|
571
|
+
handler(m);
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
function useH3ReferenceToVideoTurboRealtimeClipFinished(handler) {
|
|
576
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
577
|
+
const m = _unwrapMessage2(msg);
|
|
578
|
+
if (m.type === "clip_finished") {
|
|
579
|
+
handler(m);
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
function useH3ReferenceToVideoTurboRealtimeCommandError(handler) {
|
|
584
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
585
|
+
const m = _unwrapMessage2(msg);
|
|
586
|
+
if (m.type === "command_error") {
|
|
587
|
+
handler(m);
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
function useH3ReferenceToVideoTurboRealtimeSeedAccepted(handler) {
|
|
592
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
593
|
+
const m = _unwrapMessage2(msg);
|
|
594
|
+
if (m.type === "seed_accepted") {
|
|
595
|
+
handler(m);
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
function useH3ReferenceToVideoTurboRealtimeSessionReset(handler) {
|
|
600
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
601
|
+
const m = _unwrapMessage2(msg);
|
|
602
|
+
if (m.type === "session_reset") {
|
|
603
|
+
handler(m);
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
function useH3ReferenceToVideoTurboRealtimeClipGenerated(handler) {
|
|
608
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
609
|
+
const m = _unwrapMessage2(msg);
|
|
610
|
+
if (m.type === "clip_generated") {
|
|
611
|
+
handler(m);
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
function useH3ReferenceToVideoTurboRealtimeFlushAccepted(handler) {
|
|
616
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
617
|
+
const m = _unwrapMessage2(msg);
|
|
618
|
+
if (m.type === "flush_accepted") {
|
|
619
|
+
handler(m);
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
function useH3ReferenceToVideoTurboRealtimeCanvasAccepted(handler) {
|
|
624
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
625
|
+
const m = _unwrapMessage2(msg);
|
|
626
|
+
if (m.type === "canvas_accepted") {
|
|
627
|
+
handler(m);
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
function useH3ReferenceToVideoTurboRealtimeAutoplayAccepted(handler) {
|
|
632
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
633
|
+
const m = _unwrapMessage2(msg);
|
|
634
|
+
if (m.type === "autoplay_accepted") {
|
|
635
|
+
handler(m);
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
function useH3ReferenceToVideoTurboRealtimeClipLengthAccepted(handler) {
|
|
640
|
+
(0, import_js_sdk2.useReactorMessage)((msg) => {
|
|
641
|
+
const m = _unwrapMessage2(msg);
|
|
642
|
+
if (m.type === "clip_length_accepted") {
|
|
643
|
+
handler(m);
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
function useH3ReferenceToVideoTurboRealtimeTrack(name) {
|
|
648
|
+
return (0, import_js_sdk2.useReactor)((s) => s.tracks[name]);
|
|
649
|
+
}
|
|
650
|
+
function H3ReferenceToVideoTurboRealtimeMainVideoView(props) {
|
|
651
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_js_sdk2.ReactorView, { ...props, track: "main_video" });
|
|
652
|
+
}
|
|
653
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
654
|
+
0 && (module.exports = {
|
|
655
|
+
FileRef,
|
|
656
|
+
H3ReferenceToVideoTurboRealtimeMainVideoView,
|
|
657
|
+
H3ReferenceToVideoTurboRealtimeModel,
|
|
658
|
+
H3ReferenceToVideoTurboRealtimeProvider,
|
|
659
|
+
H3ReferenceToVideoTurboRealtimeTracks,
|
|
660
|
+
MODEL_NAME,
|
|
661
|
+
MODEL_VERSION,
|
|
662
|
+
useH3ReferenceToVideoTurboRealtime,
|
|
663
|
+
useH3ReferenceToVideoTurboRealtimeAutoplayAccepted,
|
|
664
|
+
useH3ReferenceToVideoTurboRealtimeCanvasAccepted,
|
|
665
|
+
useH3ReferenceToVideoTurboRealtimeClipFailed,
|
|
666
|
+
useH3ReferenceToVideoTurboRealtimeClipFinished,
|
|
667
|
+
useH3ReferenceToVideoTurboRealtimeClipGenerated,
|
|
668
|
+
useH3ReferenceToVideoTurboRealtimeClipLengthAccepted,
|
|
669
|
+
useH3ReferenceToVideoTurboRealtimeClipMoved,
|
|
670
|
+
useH3ReferenceToVideoTurboRealtimeClipPopped,
|
|
671
|
+
useH3ReferenceToVideoTurboRealtimeClipQueued,
|
|
672
|
+
useH3ReferenceToVideoTurboRealtimeClipStarted,
|
|
673
|
+
useH3ReferenceToVideoTurboRealtimeClipStopped,
|
|
674
|
+
useH3ReferenceToVideoTurboRealtimeCommandError,
|
|
675
|
+
useH3ReferenceToVideoTurboRealtimeFlushAccepted,
|
|
676
|
+
useH3ReferenceToVideoTurboRealtimeMessage,
|
|
677
|
+
useH3ReferenceToVideoTurboRealtimeQueueUpdate,
|
|
678
|
+
useH3ReferenceToVideoTurboRealtimeSeedAccepted,
|
|
679
|
+
useH3ReferenceToVideoTurboRealtimeSessionReset,
|
|
680
|
+
useH3ReferenceToVideoTurboRealtimeStateUpdate,
|
|
681
|
+
useH3ReferenceToVideoTurboRealtimeTrack
|
|
682
|
+
});
|
|
683
|
+
//# sourceMappingURL=index.js.map
|