@reactor-models/lingbot 0.2.18 → 0.2.20

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.js CHANGED
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- "use client";
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -21,7 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
20
  // src/index.ts
22
21
  var index_exports = {};
23
22
  __export(index_exports, {
24
- FileRef: () => import_js_sdk2.FileRef,
23
+ FileRef: () => import_js_sdk.FileRef,
25
24
  LingbotMainVideoView: () => LingbotMainVideoView,
26
25
  LingbotModel: () => LingbotModel,
27
26
  LingbotProvider: () => LingbotProvider,
@@ -44,257 +43,97 @@ __export(index_exports, {
44
43
  useLingbotTrack: () => useLingbotTrack
45
44
  });
46
45
  module.exports = __toCommonJS(index_exports);
47
- var import_js_sdk2 = require("@reactor-team/js-sdk");
48
46
 
49
- // src/react.ts
50
- var import_react = require("react");
47
+ // src/core.ts
51
48
  var import_js_sdk = require("@reactor-team/js-sdk");
52
- function _unwrapMessage(raw) {
53
- const env = raw;
54
- if (env && typeof env === "object" && env.data && typeof env.data === "object") {
55
- return { ...env.data, type: env.type };
56
- }
57
- return raw;
58
- }
59
- function LingbotProvider({
60
- apiUrl,
61
- local,
62
- jwtToken,
63
- connectOptions,
64
- children
65
- }) {
66
- return (0, import_react.createElement)(
67
- import_js_sdk.ReactorProvider,
68
- {
69
- apiUrl,
70
- local,
71
- modelName: MODEL_NAME,
72
- modelTracks: [...LingbotTracks],
73
- jwtToken,
74
- connectOptions
75
- },
76
- children
77
- );
78
- }
79
- function useLingbot() {
80
- const sendCommand = (0, import_js_sdk.useReactor)((s) => s.sendCommand);
81
- const uploadFile = (0, import_js_sdk.useReactor)((s) => s.uploadFile);
82
- const connect = (0, import_js_sdk.useReactor)((s) => s.connect);
83
- const disconnect = (0, import_js_sdk.useReactor)((s) => s.disconnect);
84
- const status = (0, import_js_sdk.useReactor)((s) => s.status);
85
- return {
86
- status,
87
- connect,
88
- disconnect,
89
- pause: () => sendCommand("pause", {}),
90
- reset: () => sendCommand("reset", {}),
91
- start: () => sendCommand("start", {}),
92
- resume: () => sendCommand("resume", {}),
93
- setSeed: (params) => sendCommand("set_seed", params),
94
- setImage: (params) => sendCommand("set_image", params),
95
- setPrompt: (params) => sendCommand("set_prompt", params),
96
- setMovement: (params) => sendCommand("set_movement", params),
97
- setLookVertical: (params) => sendCommand("set_look_vertical", params),
98
- setLookHorizontal: (params) => sendCommand("set_look_horizontal", params),
99
- setRotationSpeedDeg: (params) => sendCommand("set_rotation_speed_deg", params),
100
- uploadFile: (file, options) => uploadFile(file, options)
101
- };
102
- }
103
- function useLingbotMessage(handler) {
104
- (0, import_js_sdk.useReactorMessage)(
105
- (msg) => handler(_unwrapMessage(msg))
106
- );
107
- }
108
- function useLingbotState(handler) {
109
- (0, import_js_sdk.useReactorMessage)((msg) => {
110
- const m = _unwrapMessage(msg);
111
- if (m.type === "state") {
112
- handler(m);
113
- }
114
- });
115
- }
116
- function useLingbotCommandError(handler) {
117
- (0, import_js_sdk.useReactorMessage)((msg) => {
118
- const m = _unwrapMessage(msg);
119
- if (m.type === "command_error") {
120
- handler(m);
121
- }
122
- });
123
- }
124
- function useLingbotChunkComplete(handler) {
125
- (0, import_js_sdk.useReactorMessage)((msg) => {
126
- const m = _unwrapMessage(msg);
127
- if (m.type === "chunk_complete") {
128
- handler(m);
129
- }
130
- });
131
- }
132
- function useLingbotImageAccepted(handler) {
133
- (0, import_js_sdk.useReactorMessage)((msg) => {
134
- const m = _unwrapMessage(msg);
135
- if (m.type === "image_accepted") {
136
- handler(m);
137
- }
138
- });
139
- }
140
- function useLingbotPromptAccepted(handler) {
141
- (0, import_js_sdk.useReactorMessage)((msg) => {
142
- const m = _unwrapMessage(msg);
143
- if (m.type === "prompt_accepted") {
144
- handler(m);
145
- }
146
- });
147
- }
148
- function useLingbotConditionsReady(handler) {
149
- (0, import_js_sdk.useReactorMessage)((msg) => {
150
- const m = _unwrapMessage(msg);
151
- if (m.type === "conditions_ready") {
152
- handler(m);
153
- }
154
- });
155
- }
156
- function useLingbotGenerationReset(handler) {
157
- (0, import_js_sdk.useReactorMessage)((msg) => {
158
- const m = _unwrapMessage(msg);
159
- if (m.type === "generation_reset") {
160
- handler(m);
161
- }
162
- });
163
- }
164
- function useLingbotGenerationPaused(handler) {
165
- (0, import_js_sdk.useReactorMessage)((msg) => {
166
- const m = _unwrapMessage(msg);
167
- if (m.type === "generation_paused") {
168
- handler(m);
169
- }
170
- });
171
- }
172
- function useLingbotGenerationResumed(handler) {
173
- (0, import_js_sdk.useReactorMessage)((msg) => {
174
- const m = _unwrapMessage(msg);
175
- if (m.type === "generation_resumed") {
176
- handler(m);
177
- }
178
- });
179
- }
180
- function useLingbotGenerationStarted(handler) {
181
- (0, import_js_sdk.useReactorMessage)((msg) => {
182
- const m = _unwrapMessage(msg);
183
- if (m.type === "generation_started") {
184
- handler(m);
185
- }
186
- });
187
- }
188
- function useLingbotGenerationComplete(handler) {
189
- (0, import_js_sdk.useReactorMessage)((msg) => {
190
- const m = _unwrapMessage(msg);
191
- if (m.type === "generation_complete") {
192
- handler(m);
193
- }
194
- });
195
- }
196
- function useLingbotTrack(name) {
197
- return (0, import_js_sdk.useReactor)((s) => s.tracks[name]);
198
- }
199
- function LingbotMainVideoView(props) {
200
- return (0, import_react.createElement)(import_js_sdk.ReactorView, {
201
- ...props,
202
- track: "main_video"
203
- });
204
- }
205
-
206
- // src/index.ts
207
49
  var MODEL_NAME = "lingbot";
208
- var MODEL_VERSION = "v0.2.18";
50
+ var MODEL_VERSION = "v0.2.20";
209
51
  var LingbotTracks = [
210
52
  { name: "main_video", kind: "video", direction: "recvonly" }
211
53
  ];
212
- function _unwrapMessage2(raw) {
54
+ function _unwrapMessage(raw) {
213
55
  const env = raw;
214
56
  if (env && typeof env === "object" && env.data && typeof env.data === "object") {
215
57
  return { ...env.data, type: env.type };
216
58
  }
217
59
  return raw;
218
60
  }
219
- var LingbotModel = class {
220
- reactor;
61
+ var LingbotModel = class extends import_js_sdk.Reactor {
221
62
  constructor(options) {
222
- this.reactor = new import_js_sdk2.Reactor({
63
+ super({
223
64
  ...options,
224
65
  modelName: MODEL_NAME,
225
66
  modelTracks: [...LingbotTracks]
226
67
  });
227
68
  }
228
- async connect(jwtToken) {
229
- await this.reactor.connect(jwtToken);
230
- }
231
- async disconnect() {
232
- await this.reactor.disconnect();
69
+ /** @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. */
70
+ get reactor() {
71
+ return this;
233
72
  }
234
73
  /** Pause generation after the current chunk finishes. Frames stop streaming on `main_video` until `resume` is called. Requires generation to be active. Emits `generation_paused` and `state` on success, or `command_error` if not generating or already paused. */
235
74
  async pause() {
236
- await this.reactor.sendCommand("pause", {});
75
+ await this.sendCommand("pause", {});
237
76
  }
238
77
  /** Abort the current run, clear the active prompt and reference image, and return to the waiting state. Valid at any time. After `reset`, call `set_prompt` and `set_image` again before `start` to begin a new session. Emits `generation_reset` and `state`. */
239
78
  async reset() {
240
- await this.reactor.sendCommand("reset", {});
79
+ await this.sendCommand("reset", {});
241
80
  }
242
81
  /** Begin generating video on `main_video`. Requires both a prompt (via `set_prompt`) and a reference image (via `set_image`). Emits `generation_started` and `state` on success, or `command_error` if a precondition is missing. Has no effect while already generating. */
243
82
  async start() {
244
- await this.reactor.sendCommand("start", {});
83
+ await this.sendCommand("start", {});
245
84
  }
246
85
  /** Resume generation from a previous `pause`. Requires the session to be paused. Emits `generation_resumed` and `state` on success, or `command_error` if not paused. */
247
86
  async resume() {
248
- await this.reactor.sendCommand("resume", {});
87
+ await this.sendCommand("resume", {});
249
88
  }
250
89
  /**
251
90
  * Set seed
252
91
  * @param params - Set seed
253
92
  */
254
93
  async setSeed(params) {
255
- await this.reactor.sendCommand("set_seed", params);
94
+ await this.sendCommand("set_seed", params);
256
95
  }
257
96
  /**
258
97
  * Provide a reference image that anchors generation (image-to-video). Call before `start`; the image is required for generation to begin. Changes during generation have no effect until `reset` is issued and `start` is called again. Emits `image_accepted`, `conditions_ready`, and `state` on success, or `command_error` if the file is missing, not an image, or cannot be decoded.
259
98
  * @param params - Provide a reference image that anchors generation (image-to-video). Call before `start`; the image is required for generation to begin. Changes during generation have no effect until `reset` is issued and `start` is called again. Emits `image_accepted`, `conditions_ready`, and `state` on success, or `command_error` if the file is missing, not an image, or cannot be decoded.
260
99
  */
261
100
  async setImage(params) {
262
- await this.reactor.sendCommand("set_image", params);
101
+ await this.sendCommand("set_image", params);
263
102
  }
264
103
  /**
265
104
  * Set the scene prompt. Valid at any time — call before `start` to arm generation, or hot-swap during generation to steer the next chunk. Emits `prompt_accepted`, `conditions_ready`, and `state` on success.
266
105
  * @param params - Set the scene prompt. Valid at any time — call before `start` to arm generation, or hot-swap during generation to steer the next chunk. Emits `prompt_accepted`, `conditions_ready`, and `state` on success.
267
106
  */
268
107
  async setPrompt(params) {
269
- await this.reactor.sendCommand("set_prompt", params);
108
+ await this.sendCommand("set_prompt", params);
270
109
  }
271
110
  /**
272
111
  * Set movement
273
112
  * @param params - Set movement
274
113
  */
275
114
  async setMovement(params) {
276
- await this.reactor.sendCommand("set_movement", params);
115
+ await this.sendCommand("set_movement", params);
277
116
  }
278
117
  /**
279
118
  * Set look_vertical
280
119
  * @param params - Set look_vertical
281
120
  */
282
121
  async setLookVertical(params) {
283
- await this.reactor.sendCommand("set_look_vertical", params);
122
+ await this.sendCommand("set_look_vertical", params);
284
123
  }
285
124
  /**
286
125
  * Set look_horizontal
287
126
  * @param params - Set look_horizontal
288
127
  */
289
128
  async setLookHorizontal(params) {
290
- await this.reactor.sendCommand("set_look_horizontal", params);
129
+ await this.sendCommand("set_look_horizontal", params);
291
130
  }
292
131
  /**
293
132
  * Set rotation_speed_deg
294
133
  * @param params - Set rotation_speed_deg
295
134
  */
296
135
  async setRotationSpeedDeg(params) {
297
- await this.reactor.sendCommand("set_rotation_speed_deg", params);
136
+ await this.sendCommand("set_rotation_speed_deg", params);
298
137
  }
299
138
  /**
300
139
  * Subscribe to typed model messages.
@@ -303,10 +142,10 @@ var LingbotModel = class {
303
142
  */
304
143
  onMessage(handler) {
305
144
  const wrappedHandler = (raw) => {
306
- handler(_unwrapMessage2(raw));
145
+ handler(_unwrapMessage(raw));
307
146
  };
308
- this.reactor.on("message", wrappedHandler);
309
- return () => this.reactor.off("message", wrappedHandler);
147
+ this.on("message", wrappedHandler);
148
+ return () => this.off("message", wrappedHandler);
310
149
  }
311
150
  /**
312
151
  * Subscribe to "state" messages only.
@@ -407,14 +246,6 @@ var LingbotModel = class {
407
246
  if (msg.type === "generation_complete") handler(msg);
408
247
  });
409
248
  }
410
- /**
411
- * Upload a file and get a FileRef for use in events.
412
- * @param file - File or Blob to upload
413
- * @param options - Optional name override
414
- */
415
- async uploadFile(file, options) {
416
- return this.reactor.uploadFile(file, options);
417
- }
418
249
  /**
419
250
  * Subscribe to the "main_video" recvonly video track the model publishes.
420
251
  *
@@ -426,10 +257,175 @@ var LingbotModel = class {
426
257
  const wrapped = (name, t, s) => {
427
258
  if (name === "main_video") handler(t, s);
428
259
  };
429
- this.reactor.on("trackReceived", wrapped);
430
- return () => this.reactor.off("trackReceived", wrapped);
260
+ this.on("trackReceived", wrapped);
261
+ return () => this.off("trackReceived", wrapped);
431
262
  }
432
263
  };
264
+
265
+ // src/react.tsx
266
+ var import_js_sdk2 = require("@reactor-team/js-sdk");
267
+ var import_jsx_runtime = require("react/jsx-runtime");
268
+ function _unwrapMessage2(raw) {
269
+ const env = raw;
270
+ if (env && typeof env === "object" && env.data && typeof env.data === "object") {
271
+ return { ...env.data, type: env.type };
272
+ }
273
+ return raw;
274
+ }
275
+ function LingbotProvider({
276
+ children,
277
+ ...rest
278
+ }) {
279
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
280
+ import_js_sdk2.ReactorProvider,
281
+ {
282
+ ...rest,
283
+ modelName: MODEL_NAME,
284
+ modelTracks: [...LingbotTracks],
285
+ children
286
+ }
287
+ );
288
+ }
289
+ function useLingbot() {
290
+ const connect = (0, import_js_sdk2.useReactor)((s) => s.connect);
291
+ const disconnect = (0, import_js_sdk2.useReactor)((s) => s.disconnect);
292
+ const jwtToken = (0, import_js_sdk2.useReactor)((s) => s.jwtToken);
293
+ const lastError = (0, import_js_sdk2.useReactor)((s) => s.lastError);
294
+ const publish = (0, import_js_sdk2.useReactor)((s) => s.publish);
295
+ const reconnect = (0, import_js_sdk2.useReactor)((s) => s.reconnect);
296
+ const sendCommand = (0, import_js_sdk2.useReactor)((s) => s.sendCommand);
297
+ const sessionExpiration = (0, import_js_sdk2.useReactor)((s) => s.sessionExpiration);
298
+ const sessionId = (0, import_js_sdk2.useReactor)((s) => s.sessionId);
299
+ const status = (0, import_js_sdk2.useReactor)((s) => s.status);
300
+ const tracks = (0, import_js_sdk2.useReactor)((s) => s.tracks);
301
+ const unpublish = (0, import_js_sdk2.useReactor)((s) => s.unpublish);
302
+ const uploadFile = (0, import_js_sdk2.useReactor)((s) => s.uploadFile);
303
+ return {
304
+ connect,
305
+ disconnect,
306
+ jwtToken,
307
+ lastError,
308
+ publish,
309
+ reconnect,
310
+ sendCommand,
311
+ sessionExpiration,
312
+ sessionId,
313
+ status,
314
+ tracks,
315
+ unpublish,
316
+ uploadFile,
317
+ pause: () => sendCommand("pause", {}),
318
+ reset: () => sendCommand("reset", {}),
319
+ start: () => sendCommand("start", {}),
320
+ resume: () => sendCommand("resume", {}),
321
+ setSeed: (params) => sendCommand("set_seed", params),
322
+ setImage: (params) => sendCommand("set_image", params),
323
+ setPrompt: (params) => sendCommand("set_prompt", params),
324
+ setMovement: (params) => sendCommand("set_movement", params),
325
+ setLookVertical: (params) => sendCommand("set_look_vertical", params),
326
+ setLookHorizontal: (params) => sendCommand("set_look_horizontal", params),
327
+ setRotationSpeedDeg: (params) => sendCommand("set_rotation_speed_deg", params)
328
+ };
329
+ }
330
+ function useLingbotMessage(handler) {
331
+ (0, import_js_sdk2.useReactorMessage)(
332
+ (msg) => handler(_unwrapMessage2(msg))
333
+ );
334
+ }
335
+ function useLingbotState(handler) {
336
+ (0, import_js_sdk2.useReactorMessage)((msg) => {
337
+ const m = _unwrapMessage2(msg);
338
+ if (m.type === "state") {
339
+ handler(m);
340
+ }
341
+ });
342
+ }
343
+ function useLingbotCommandError(handler) {
344
+ (0, import_js_sdk2.useReactorMessage)((msg) => {
345
+ const m = _unwrapMessage2(msg);
346
+ if (m.type === "command_error") {
347
+ handler(m);
348
+ }
349
+ });
350
+ }
351
+ function useLingbotChunkComplete(handler) {
352
+ (0, import_js_sdk2.useReactorMessage)((msg) => {
353
+ const m = _unwrapMessage2(msg);
354
+ if (m.type === "chunk_complete") {
355
+ handler(m);
356
+ }
357
+ });
358
+ }
359
+ function useLingbotImageAccepted(handler) {
360
+ (0, import_js_sdk2.useReactorMessage)((msg) => {
361
+ const m = _unwrapMessage2(msg);
362
+ if (m.type === "image_accepted") {
363
+ handler(m);
364
+ }
365
+ });
366
+ }
367
+ function useLingbotPromptAccepted(handler) {
368
+ (0, import_js_sdk2.useReactorMessage)((msg) => {
369
+ const m = _unwrapMessage2(msg);
370
+ if (m.type === "prompt_accepted") {
371
+ handler(m);
372
+ }
373
+ });
374
+ }
375
+ function useLingbotConditionsReady(handler) {
376
+ (0, import_js_sdk2.useReactorMessage)((msg) => {
377
+ const m = _unwrapMessage2(msg);
378
+ if (m.type === "conditions_ready") {
379
+ handler(m);
380
+ }
381
+ });
382
+ }
383
+ function useLingbotGenerationReset(handler) {
384
+ (0, import_js_sdk2.useReactorMessage)((msg) => {
385
+ const m = _unwrapMessage2(msg);
386
+ if (m.type === "generation_reset") {
387
+ handler(m);
388
+ }
389
+ });
390
+ }
391
+ function useLingbotGenerationPaused(handler) {
392
+ (0, import_js_sdk2.useReactorMessage)((msg) => {
393
+ const m = _unwrapMessage2(msg);
394
+ if (m.type === "generation_paused") {
395
+ handler(m);
396
+ }
397
+ });
398
+ }
399
+ function useLingbotGenerationResumed(handler) {
400
+ (0, import_js_sdk2.useReactorMessage)((msg) => {
401
+ const m = _unwrapMessage2(msg);
402
+ if (m.type === "generation_resumed") {
403
+ handler(m);
404
+ }
405
+ });
406
+ }
407
+ function useLingbotGenerationStarted(handler) {
408
+ (0, import_js_sdk2.useReactorMessage)((msg) => {
409
+ const m = _unwrapMessage2(msg);
410
+ if (m.type === "generation_started") {
411
+ handler(m);
412
+ }
413
+ });
414
+ }
415
+ function useLingbotGenerationComplete(handler) {
416
+ (0, import_js_sdk2.useReactorMessage)((msg) => {
417
+ const m = _unwrapMessage2(msg);
418
+ if (m.type === "generation_complete") {
419
+ handler(m);
420
+ }
421
+ });
422
+ }
423
+ function useLingbotTrack(name) {
424
+ return (0, import_js_sdk2.useReactor)((s) => s.tracks[name]);
425
+ }
426
+ function LingbotMainVideoView(props) {
427
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_js_sdk2.ReactorView, { ...props, track: "main_video" });
428
+ }
433
429
  // Annotate the CommonJS export names for ESM import in node:
434
430
  0 && (module.exports = {
435
431
  FileRef,