@reactor-team/js-sdk 2.12.0 → 2.12.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.js CHANGED
@@ -88,7 +88,6 @@ __export(index_exports, {
88
88
  DEFAULT_PLAYLIST_POLL_SLACK_MS: () => DEFAULT_PLAYLIST_POLL_SLACK_MS,
89
89
  FileRef: () => FileRef,
90
90
  Reactor: () => Reactor,
91
- ReactorController: () => ReactorController,
92
91
  ReactorProvider: () => ReactorProvider,
93
92
  ReactorView: () => ReactorView,
94
93
  RecordingClient: () => RecordingClient,
@@ -153,7 +152,7 @@ var import_zod = require("zod");
153
152
  // package.json
154
153
  var package_default = {
155
154
  name: "@reactor-team/js-sdk",
156
- version: "2.12.0",
155
+ version: "2.12.1",
157
156
  description: "Reactor JavaScript frontend SDK \u2014 connect React and TypeScript apps to real-time AI video models on Reactor.",
158
157
  license: "Apache-2.0",
159
158
  repository: {
@@ -225,14 +224,14 @@ var package_default = {
225
224
  }
226
225
  },
227
226
  devDependencies: {
228
- "@roamhq/wrtc": "^0.8.0",
227
+ "@roamhq/wrtc": "^0.10.0",
229
228
  "@types/node": "^25",
230
229
  "@types/react": "^19.2.15",
231
230
  "@types/sdp-transform": "^2.15.0",
232
231
  "hls.js": "^1.6.0",
233
- prettier: "^3.6.2",
232
+ prettier: "^3.8.4",
234
233
  tsup: "^8.5.0",
235
- typescript: "^5.8.3",
234
+ typescript: "^6.0.3",
236
235
  vitest: "^4.1.7"
237
236
  }
238
237
  };
@@ -3403,10 +3402,6 @@ var Reactor = class {
3403
3402
  ]);
3404
3403
  sessionPollingMs = performance.now() - tParallel;
3405
3404
  this.sessionResponse = sessionResponse;
3406
- this.capabilities = __spreadProps(__spreadValues({}, sessionResponse.capabilities), {
3407
- tracks: this.tracks
3408
- });
3409
- this.emit("capabilitiesReceived", this.capabilities);
3410
3405
  const tConnect = performance.now();
3411
3406
  yield this.transportClient.connect(false, options == null ? void 0 : options.connectionId);
3412
3407
  transportConnectingMs = performance.now() - tConnect;
@@ -3417,10 +3412,6 @@ var Reactor = class {
3417
3412
  sessionPollingMs = performance.now() - tPoll;
3418
3413
  this.sessionResponse = sessionResponse;
3419
3414
  this.tracks = sessionResponse.capabilities.tracks;
3420
- this.capabilities = __spreadProps(__spreadValues({}, sessionResponse.capabilities), {
3421
- tracks: this.tracks
3422
- });
3423
- this.emit("capabilitiesReceived", this.capabilities);
3424
3415
  const protocol = sessionResponse.selected_transport.protocol;
3425
3416
  if (protocol !== "webrtc") {
3426
3417
  throw new Error(`Unsupported transport protocol: ${protocol}`);
@@ -3469,6 +3460,10 @@ var Reactor = class {
3469
3460
  if (scope === "application") {
3470
3461
  this.emit("message", message);
3471
3462
  } else if (scope === "runtime") {
3463
+ if (message && typeof message === "object" && message.type === "modelSchema" && message.data) {
3464
+ this.schema = message.data;
3465
+ this.emit("schemaReceived", this.schema);
3466
+ }
3472
3467
  this.emit("runtimeMessage", message);
3473
3468
  }
3474
3469
  });
@@ -3485,6 +3480,7 @@ var Reactor = class {
3485
3480
  }
3486
3481
  }
3487
3482
  this.setStatus("ready");
3483
+ void this.sendCommand("requestSchema", {}, "runtime");
3488
3484
  break;
3489
3485
  case "disconnected":
3490
3486
  this.disconnect(true);
@@ -3562,7 +3558,7 @@ var Reactor = class {
3562
3558
  if (!recoverable) {
3563
3559
  this.setSessionExpiration(void 0);
3564
3560
  this.setSessionId(void 0);
3565
- this.capabilities = void 0;
3561
+ this.schema = void 0;
3566
3562
  this.tracks = [];
3567
3563
  this.sessionResponse = void 0;
3568
3564
  this.createdSession = false;
@@ -3587,8 +3583,13 @@ var Reactor = class {
3587
3583
  getLastError() {
3588
3584
  return this.lastError;
3589
3585
  }
3590
- getCapabilities() {
3591
- return this.capabilities;
3586
+ /**
3587
+ * The model's OpenAPI schema (events, outbound messages, tracks),
3588
+ * received over the runtime channel shortly after the session becomes
3589
+ * ready. `undefined` until the `schemaReceived` event has fired.
3590
+ */
3591
+ getSchema() {
3592
+ return this.schema;
3592
3593
  }
3593
3594
  getSessionInfo() {
3594
3595
  return this.sessionResponse;
@@ -3599,6 +3600,10 @@ var Reactor = class {
3599
3600
  if (!stats) return void 0;
3600
3601
  return __spreadProps(__spreadValues({}, stats), { connectionTimings: this.connectionTimings });
3601
3602
  }
3603
+ /** Timing breakdown from the most recent connect() handshake. */
3604
+ getConnectionTimings() {
3605
+ return this.connectionTimings;
3606
+ }
3602
3607
  // ─────────────────────────────────────────────────────────────────────────
3603
3608
  // Private State Management
3604
3609
  // ─────────────────────────────────────────────────────────────────────────
@@ -3807,6 +3812,8 @@ var createReactorStore = (initProps, publicState = defaultInitState) => {
3807
3812
  throw error;
3808
3813
  }
3809
3814
  }),
3815
+ pauseTrack: (name) => get().internal.reactor.pauseTrack(name),
3816
+ resumeTrack: (name) => get().internal.reactor.resumeTrack(name),
3810
3817
  reconnect: (options) => __async(null, null, function* () {
3811
3818
  console.debug("[ReactorStore] Reconnecting");
3812
3819
  try {
@@ -4120,576 +4127,9 @@ function ReactorView({
4120
4127
  );
4121
4128
  }
4122
4129
 
4123
- // src/react/ReactorController.tsx
4124
- var import_react6 = __toESM(require("react"));
4125
- var import_jsx_runtime3 = require("react/jsx-runtime");
4126
- function isFileParam(ps) {
4127
- return ps.type === "file" || ps.type === "object" && ps.format === "file-reference";
4128
- }
4129
- function ReactorController({
4130
- className,
4131
- style
4132
- }) {
4133
- const { sendCommand, uploadFile, status } = useReactor((state) => ({
4134
- sendCommand: state.sendCommand,
4135
- uploadFile: state.uploadFile,
4136
- status: state.status
4137
- }));
4138
- const [commands, setCommands] = (0, import_react6.useState)({});
4139
- const [formValues, setFormValues] = (0, import_react6.useState)({});
4140
- const formRef = (0, import_react6.useRef)(formValues);
4141
- formRef.current = formValues;
4142
- const [expandedCommands, setExpandedCommands] = (0, import_react6.useState)({});
4143
- import_react6.default.useEffect(() => {
4144
- if (status === "disconnected") {
4145
- setCommands({});
4146
- setFormValues({});
4147
- setExpandedCommands({});
4148
- }
4149
- }, [status]);
4150
- const requestCapabilities = (0, import_react6.useCallback)(() => {
4151
- if (status === "ready") {
4152
- sendCommand("requestCapabilities", {}, "runtime");
4153
- }
4154
- }, [status, sendCommand]);
4155
- import_react6.default.useEffect(() => {
4156
- if (status === "ready") {
4157
- requestCapabilities();
4158
- }
4159
- }, [status, requestCapabilities]);
4160
- import_react6.default.useEffect(() => {
4161
- if (status !== "ready" || Object.keys(commands).length > 0) {
4162
- return;
4163
- }
4164
- const interval = setInterval(() => {
4165
- requestCapabilities();
4166
- }, 5e3);
4167
- return () => clearInterval(interval);
4168
- }, [status, commands, requestCapabilities]);
4169
- useReactorInternalMessage((message) => {
4170
- var _a;
4171
- if (message && typeof message === "object" && message.type === "modelCapabilities" && message.data && "commands" in message.data) {
4172
- const commandsMessage = message.data;
4173
- const commandsRecord = {};
4174
- for (const cmd of commandsMessage.commands) {
4175
- commandsRecord[cmd.name] = {
4176
- description: cmd.description,
4177
- schema: (_a = cmd.schema) != null ? _a : {}
4178
- };
4179
- }
4180
- setCommands(commandsRecord);
4181
- const initialValues = {};
4182
- const initialExpanded = {};
4183
- Object.entries(commandsRecord).forEach(([commandName, commandSchema]) => {
4184
- initialValues[commandName] = {};
4185
- initialExpanded[commandName] = false;
4186
- Object.entries(commandSchema.schema).forEach(
4187
- ([paramName, paramSchema]) => {
4188
- var _a2;
4189
- if (isFileParam(paramSchema)) {
4190
- initialValues[commandName][paramName] = null;
4191
- } else if (paramSchema.default !== void 0) {
4192
- initialValues[commandName][paramName] = paramSchema.default;
4193
- } else if (paramSchema.type === "number" || paramSchema.type === "integer") {
4194
- initialValues[commandName][paramName] = (_a2 = paramSchema.minimum) != null ? _a2 : 0;
4195
- } else if (paramSchema.type === "string") {
4196
- initialValues[commandName][paramName] = "";
4197
- } else if (paramSchema.type === "boolean") {
4198
- initialValues[commandName][paramName] = false;
4199
- }
4200
- }
4201
- );
4202
- });
4203
- setFormValues(initialValues);
4204
- setExpandedCommands(initialExpanded);
4205
- }
4206
- });
4207
- const handleInputChange = (0, import_react6.useCallback)(
4208
- (commandName, paramName, value) => {
4209
- setFormValues((prev) => __spreadProps(__spreadValues({}, prev), {
4210
- [commandName]: __spreadProps(__spreadValues({}, prev[commandName]), {
4211
- [paramName]: value
4212
- })
4213
- }));
4214
- },
4215
- []
4216
- );
4217
- const toggleCommandExpanded = (0, import_react6.useCallback)((commandName) => {
4218
- setExpandedCommands((prev) => __spreadProps(__spreadValues({}, prev), {
4219
- [commandName]: !prev[commandName]
4220
- }));
4221
- }, []);
4222
- const handleCommandSubmit = (0, import_react6.useCallback)(
4223
- (commandName) => __async(null, null, function* () {
4224
- const commandSchema = commands[commandName];
4225
- const formData = formRef.current[commandName] || {};
4226
- const data = {};
4227
- Object.keys(commandSchema.schema).forEach((paramName) => {
4228
- var _a;
4229
- const paramSchema = commandSchema.schema[paramName];
4230
- let value = formData[paramName];
4231
- if (value instanceof FileRef) {
4232
- data[paramName] = value;
4233
- return;
4234
- }
4235
- if (paramSchema.type === "number" && typeof value === "string") {
4236
- value = parseFloat(value) || 0;
4237
- } else if (paramSchema.type === "integer" && typeof value === "string") {
4238
- value = parseInt(value) || 0;
4239
- } else if (paramSchema.type === "boolean" && typeof value !== "boolean") {
4240
- value = Boolean(value);
4241
- }
4242
- if (value !== void 0 && value !== "" && value !== null) {
4243
- data[paramName] = value;
4244
- } else if (paramSchema.required) {
4245
- if (paramSchema.type === "number" || paramSchema.type === "integer") {
4246
- data[paramName] = (_a = paramSchema.minimum) != null ? _a : 0;
4247
- } else if (paramSchema.type === "string") {
4248
- data[paramName] = "";
4249
- } else if (paramSchema.type === "boolean") {
4250
- data[paramName] = false;
4251
- }
4252
- }
4253
- });
4254
- yield sendCommand(commandName, data);
4255
- }),
4256
- [sendCommand, commands]
4257
- );
4258
- const renderInput = (commandName, paramName, paramSchema) => {
4259
- var _a, _b;
4260
- const value = (_b = (_a = formValues[commandName]) == null ? void 0 : _a[paramName]) != null ? _b : "";
4261
- if (isFileParam(paramSchema)) {
4262
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4263
- FileParamInput,
4264
- {
4265
- commandName,
4266
- paramName,
4267
- description: paramSchema.description,
4268
- value,
4269
- onChange: handleInputChange,
4270
- disabled: status !== "ready",
4271
- uploadFile
4272
- },
4273
- `${commandName}-${paramName}`
4274
- );
4275
- }
4276
- if (paramSchema.type === "number" || paramSchema.type === "integer") {
4277
- const isInteger = paramSchema.type === "integer";
4278
- const step = isInteger ? 1 : 0.1;
4279
- const parseValue = isInteger ? parseInt : parseFloat;
4280
- if (typeof paramSchema.minimum === "number" && typeof paramSchema.maximum === "number") {
4281
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { marginBottom: "8px" }, children: [
4282
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4283
- "label",
4284
- {
4285
- style: { fontSize: "12px", color: "#666", display: "block" },
4286
- children: [
4287
- paramName,
4288
- " (",
4289
- paramSchema.minimum,
4290
- " - ",
4291
- paramSchema.maximum,
4292
- ")",
4293
- paramSchema.description && ` - ${paramSchema.description}`,
4294
- paramSchema.required && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { color: "red" }, children: " *" })
4295
- ]
4296
- }
4297
- ),
4298
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4299
- "input",
4300
- {
4301
- type: "range",
4302
- min: paramSchema.minimum,
4303
- max: paramSchema.maximum,
4304
- step,
4305
- value,
4306
- onChange: (e) => {
4307
- const newValue = parseValue(e.target.value) || 0;
4308
- handleInputChange(commandName, paramName, newValue);
4309
- handleCommandSubmit(commandName);
4310
- },
4311
- style: { width: "100%", marginBottom: "4px" }
4312
- }
4313
- ),
4314
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { fontSize: "11px", color: "#888" }, children: [
4315
- "Value: ",
4316
- value
4317
- ] })
4318
- ] });
4319
- } else {
4320
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { marginBottom: "8px" }, children: [
4321
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4322
- "label",
4323
- {
4324
- style: { fontSize: "12px", color: "#666", display: "block" },
4325
- children: [
4326
- paramName,
4327
- paramSchema.description && ` - ${paramSchema.description}`,
4328
- paramSchema.required && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { color: "red" }, children: " *" })
4329
- ]
4330
- }
4331
- ),
4332
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4333
- "input",
4334
- {
4335
- type: "number",
4336
- value,
4337
- min: paramSchema.minimum,
4338
- max: paramSchema.maximum,
4339
- step,
4340
- inputMode: "numeric",
4341
- onChange: (e) => {
4342
- const val = e.target.value;
4343
- if (val === "" || val === "-") {
4344
- handleInputChange(commandName, paramName, val);
4345
- } else {
4346
- const parsed = parseValue(val);
4347
- if (!isNaN(parsed)) {
4348
- handleInputChange(commandName, paramName, parsed);
4349
- }
4350
- }
4351
- },
4352
- onBlur: (e) => {
4353
- const val = e.target.value;
4354
- if (val === "" || val === "-") {
4355
- handleInputChange(commandName, paramName, 0);
4356
- }
4357
- },
4358
- style: {
4359
- width: "100%",
4360
- padding: "4px",
4361
- fontSize: "12px",
4362
- border: "1px solid #ccc",
4363
- borderRadius: "2px"
4364
- }
4365
- }
4366
- )
4367
- ] });
4368
- }
4369
- } else if (paramSchema.type === "string") {
4370
- if (paramSchema.enum) {
4371
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { marginBottom: "8px" }, children: [
4372
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4373
- "label",
4374
- {
4375
- style: { fontSize: "12px", color: "#666", display: "block" },
4376
- children: [
4377
- paramName,
4378
- paramSchema.description && ` - ${paramSchema.description}`,
4379
- paramSchema.required && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { color: "red" }, children: " *" })
4380
- ]
4381
- }
4382
- ),
4383
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4384
- "select",
4385
- {
4386
- value,
4387
- onChange: (e) => handleInputChange(commandName, paramName, e.target.value),
4388
- style: {
4389
- width: "100%",
4390
- padding: "4px",
4391
- fontSize: "12px",
4392
- border: "1px solid #ccc",
4393
- borderRadius: "2px"
4394
- },
4395
- children: [
4396
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "", children: "Select..." }),
4397
- paramSchema.enum.map((option) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: option, children: option }, option))
4398
- ]
4399
- }
4400
- )
4401
- ] });
4402
- } else {
4403
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { marginBottom: "8px" }, children: [
4404
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4405
- "label",
4406
- {
4407
- style: { fontSize: "12px", color: "#666", display: "block" },
4408
- children: [
4409
- paramName,
4410
- paramSchema.description && ` - ${paramSchema.description}`,
4411
- paramSchema.required && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { color: "red" }, children: " *" })
4412
- ]
4413
- }
4414
- ),
4415
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4416
- "input",
4417
- {
4418
- type: "text",
4419
- value,
4420
- onChange: (e) => handleInputChange(commandName, paramName, e.target.value),
4421
- style: {
4422
- width: "100%",
4423
- padding: "4px",
4424
- fontSize: "12px",
4425
- border: "1px solid #ccc",
4426
- borderRadius: "2px"
4427
- }
4428
- }
4429
- )
4430
- ] });
4431
- }
4432
- } else if (paramSchema.type === "boolean") {
4433
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { marginBottom: "8px" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4434
- "label",
4435
- {
4436
- style: {
4437
- fontSize: "12px",
4438
- color: "#666",
4439
- display: "flex",
4440
- alignItems: "center"
4441
- },
4442
- children: [
4443
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4444
- "input",
4445
- {
4446
- type: "checkbox",
4447
- checked: value,
4448
- onChange: (e) => handleInputChange(commandName, paramName, e.target.checked),
4449
- style: { marginRight: "6px" }
4450
- }
4451
- ),
4452
- paramName,
4453
- paramSchema.description && ` - ${paramSchema.description}`,
4454
- paramSchema.required && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { color: "red" }, children: " *" })
4455
- ]
4456
- }
4457
- ) });
4458
- }
4459
- return null;
4460
- };
4461
- const renderCommand = (commandName, commandSchema) => {
4462
- const hasParams = Object.keys(commandSchema.schema).length > 0;
4463
- const isExpanded = expandedCommands[commandName];
4464
- const params = Object.values(commandSchema.schema);
4465
- const allSliders = params.length > 0 && params.every(
4466
- (ps) => (ps.type === "number" || ps.type === "integer") && typeof ps.minimum === "number" && typeof ps.maximum === "number"
4467
- );
4468
- const showExecuteButton = !allSliders;
4469
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4470
- "div",
4471
- {
4472
- style: {
4473
- border: "1px solid #ddd",
4474
- borderRadius: "4px",
4475
- marginBottom: "8px",
4476
- backgroundColor: "#fafafa"
4477
- },
4478
- children: [
4479
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4480
- "div",
4481
- {
4482
- onClick: () => toggleCommandExpanded(commandName),
4483
- style: {
4484
- padding: "8px 12px",
4485
- cursor: "pointer",
4486
- borderBottom: isExpanded ? "1px solid #ddd" : "none",
4487
- display: "flex",
4488
- justifyContent: "space-between",
4489
- alignItems: "center"
4490
- },
4491
- children: [
4492
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
4493
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4494
- "h4",
4495
- {
4496
- style: {
4497
- margin: "0",
4498
- fontSize: "13px",
4499
- fontWeight: "bold"
4500
- },
4501
- children: commandName
4502
- }
4503
- ),
4504
- isExpanded && commandSchema.description && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4505
- "p",
4506
- {
4507
- style: { margin: "4px 0 0 0", fontSize: "11px", color: "#666" },
4508
- children: commandSchema.description
4509
- }
4510
- )
4511
- ] }),
4512
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4513
- "div",
4514
- {
4515
- style: {
4516
- fontSize: "10px",
4517
- color: "#999",
4518
- transform: isExpanded ? "rotate(180deg)" : "rotate(0deg)",
4519
- transition: "transform 0.2s"
4520
- },
4521
- children: "\u25BC"
4522
- }
4523
- )
4524
- ]
4525
- }
4526
- ),
4527
- isExpanded && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { padding: "12px", paddingTop: "0" }, children: [
4528
- hasParams && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { marginBottom: showExecuteButton ? "12px" : "0" }, children: [
4529
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4530
- "div",
4531
- {
4532
- style: {
4533
- marginBottom: "8px",
4534
- fontSize: "12px",
4535
- fontWeight: "bold",
4536
- color: "#555"
4537
- },
4538
- children: "Parameters:"
4539
- }
4540
- ),
4541
- Object.entries(commandSchema.schema).map(
4542
- ([paramName, paramSchema]) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4543
- "div",
4544
- {
4545
- style: { marginLeft: "8px" },
4546
- children: renderInput(commandName, paramName, paramSchema)
4547
- },
4548
- `${commandName}-${paramName}`
4549
- )
4550
- )
4551
- ] }),
4552
- !hasParams && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4553
- "div",
4554
- {
4555
- style: {
4556
- marginBottom: showExecuteButton ? "12px" : "0",
4557
- marginTop: "2px",
4558
- fontSize: "11px",
4559
- color: "#666",
4560
- fontStyle: "italic"
4561
- },
4562
- children: "No parameters required"
4563
- }
4564
- ),
4565
- showExecuteButton && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4566
- "button",
4567
- {
4568
- onClick: () => handleCommandSubmit(commandName),
4569
- style: {
4570
- padding: "8px 16px",
4571
- fontSize: "12px",
4572
- backgroundColor: "#007bff",
4573
- color: "white",
4574
- border: "none",
4575
- borderRadius: "4px",
4576
- cursor: "pointer",
4577
- fontWeight: "bold"
4578
- },
4579
- children: [
4580
- "Execute ",
4581
- commandName
4582
- ]
4583
- }
4584
- )
4585
- ] })
4586
- ]
4587
- },
4588
- commandName
4589
- );
4590
- };
4591
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className, style, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontFamily: "monospace", fontSize: "12px" }, children: Object.keys(commands).length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { padding: "12px", color: "#666", fontStyle: "italic" }, children: "Waiting for commands schema..." }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
4592
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4593
- "h3",
4594
- {
4595
- style: {
4596
- margin: "0 0 16px 0",
4597
- fontSize: "16px",
4598
- fontWeight: "bold"
4599
- },
4600
- children: "Reactor Commands"
4601
- }
4602
- ),
4603
- Object.entries(commands).map(([commandName, commandSchema]) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: renderCommand(commandName, commandSchema) }, commandName))
4604
- ] }) }) });
4605
- }
4606
- function FileParamInput({
4607
- commandName,
4608
- paramName,
4609
- description,
4610
- value,
4611
- onChange,
4612
- disabled,
4613
- uploadFile
4614
- }) {
4615
- const inputRef = (0, import_react6.useRef)(null);
4616
- const [uploading, setUploading] = (0, import_react6.useState)(false);
4617
- const fileRef = value instanceof FileRef ? value : null;
4618
- const handleFile = (e) => __async(null, null, function* () {
4619
- var _a;
4620
- const file = (_a = e.target.files) == null ? void 0 : _a[0];
4621
- if (!file) return;
4622
- e.target.value = "";
4623
- setUploading(true);
4624
- try {
4625
- const ref = yield uploadFile(file);
4626
- onChange(commandName, paramName, ref);
4627
- } catch (err) {
4628
- console.error("[FileParamInput] Upload failed:", err);
4629
- } finally {
4630
- setUploading(false);
4631
- }
4632
- });
4633
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { marginBottom: "8px" }, children: [
4634
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { style: { fontSize: "12px", color: "#666", display: "block" }, children: [
4635
- paramName,
4636
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { color: "#888", fontSize: "11px" }, children: " (file)" }),
4637
- description && ` - ${description}`
4638
- ] }),
4639
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4640
- "div",
4641
- {
4642
- style: {
4643
- display: "flex",
4644
- alignItems: "center",
4645
- gap: "8px",
4646
- marginTop: "4px"
4647
- },
4648
- children: [
4649
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4650
- "input",
4651
- {
4652
- ref: inputRef,
4653
- type: "file",
4654
- accept: "image/*",
4655
- onChange: handleFile,
4656
- style: { display: "none" }
4657
- }
4658
- ),
4659
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4660
- "button",
4661
- {
4662
- disabled: disabled || uploading,
4663
- onClick: () => {
4664
- var _a;
4665
- return (_a = inputRef.current) == null ? void 0 : _a.click();
4666
- },
4667
- style: {
4668
- padding: "4px 12px",
4669
- fontSize: "12px",
4670
- backgroundColor: "#007bff",
4671
- color: "white",
4672
- border: "none",
4673
- borderRadius: "4px",
4674
- cursor: disabled || uploading ? "default" : "pointer",
4675
- opacity: disabled || uploading ? 0.5 : 1
4676
- },
4677
- children: uploading ? "Uploading\u2026" : fileRef ? "Change" : "Choose File"
4678
- }
4679
- ),
4680
- fileRef && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { style: { fontSize: "11px", color: "#28a745" }, children: [
4681
- "\\u2713 ",
4682
- fileRef.name
4683
- ] })
4684
- ]
4685
- }
4686
- )
4687
- ] });
4688
- }
4689
-
4690
4130
  // src/react/WebcamStream.tsx
4691
- var import_react7 = require("react");
4692
- var import_jsx_runtime4 = require("react/jsx-runtime");
4131
+ var import_react6 = require("react");
4132
+ var import_jsx_runtime3 = require("react/jsx-runtime");
4693
4133
  function WebcamStream({
4694
4134
  track,
4695
4135
  audio = false,
@@ -4706,20 +4146,20 @@ function WebcamStream({
4706
4146
  onPublished,
4707
4147
  onError
4708
4148
  }) {
4709
- const [stream, setStream] = (0, import_react7.useState)(null);
4710
- const [isPublishing, setIsPublishing] = (0, import_react7.useState)(false);
4711
- const [permissionDenied, setPermissionDenied] = (0, import_react7.useState)(false);
4149
+ const [stream, setStream] = (0, import_react6.useState)(null);
4150
+ const [isPublishing, setIsPublishing] = (0, import_react6.useState)(false);
4151
+ const [permissionDenied, setPermissionDenied] = (0, import_react6.useState)(false);
4712
4152
  const { status, publish, unpublish, reactor } = useReactor((state) => ({
4713
4153
  status: state.status,
4714
4154
  publish: state.publish,
4715
4155
  unpublish: state.unpublish,
4716
4156
  reactor: state.internal.reactor
4717
4157
  }));
4718
- const videoRef = (0, import_react7.useRef)(null);
4719
- const onPermissionDeniedRef = (0, import_react7.useRef)(onPermissionDenied);
4720
- const onPublishedRef = (0, import_react7.useRef)(onPublished);
4721
- const onErrorRef = (0, import_react7.useRef)(onError);
4722
- (0, import_react7.useEffect)(() => {
4158
+ const videoRef = (0, import_react6.useRef)(null);
4159
+ const onPermissionDeniedRef = (0, import_react6.useRef)(onPermissionDenied);
4160
+ const onPublishedRef = (0, import_react6.useRef)(onPublished);
4161
+ const onErrorRef = (0, import_react6.useRef)(onError);
4162
+ (0, import_react6.useEffect)(() => {
4723
4163
  onPermissionDeniedRef.current = onPermissionDenied;
4724
4164
  onPublishedRef.current = onPublished;
4725
4165
  onErrorRef.current = onError;
@@ -4784,7 +4224,7 @@ function WebcamStream({
4784
4224
  setStream(null);
4785
4225
  console.debug("[WebcamPublisher] Webcam stopped");
4786
4226
  });
4787
- (0, import_react7.useEffect)(() => {
4227
+ (0, import_react6.useEffect)(() => {
4788
4228
  console.debug("[WebcamPublisher] Stream effect triggered", {
4789
4229
  hasVideoElement: !!videoRef.current,
4790
4230
  hasStream: !!stream
@@ -4801,7 +4241,7 @@ function WebcamStream({
4801
4241
  videoRef.current.srcObject = null;
4802
4242
  }
4803
4243
  }, [stream]);
4804
- (0, import_react7.useEffect)(() => {
4244
+ (0, import_react6.useEffect)(() => {
4805
4245
  if (!stream) {
4806
4246
  return;
4807
4247
  }
@@ -4857,7 +4297,7 @@ function WebcamStream({
4857
4297
  audioEnabled,
4858
4298
  audioTrack
4859
4299
  ]);
4860
- (0, import_react7.useEffect)(() => {
4300
+ (0, import_react6.useEffect)(() => {
4861
4301
  const handleError = (error) => {
4862
4302
  console.debug("[WebcamPublisher] Received error event:", error);
4863
4303
  if (error.code === "TRACK_PUBLISH_FAILED") {
@@ -4872,7 +4312,7 @@ function WebcamStream({
4872
4312
  reactor.off("error", handleError);
4873
4313
  };
4874
4314
  }, [reactor]);
4875
- (0, import_react7.useEffect)(() => {
4315
+ (0, import_react6.useEffect)(() => {
4876
4316
  if (status !== "ready") {
4877
4317
  console.debug(
4878
4318
  "[WebcamPublisher] Status changed to",
@@ -4882,7 +4322,7 @@ function WebcamStream({
4882
4322
  setIsPublishing(false);
4883
4323
  }
4884
4324
  }, [status, isPublishing]);
4885
- (0, import_react7.useEffect)(() => {
4325
+ (0, import_react6.useEffect)(() => {
4886
4326
  console.debug("[WebcamPublisher] Auto-starting webcam");
4887
4327
  startWebcam();
4888
4328
  return () => {
@@ -4891,7 +4331,7 @@ function WebcamStream({
4891
4331
  };
4892
4332
  }, []);
4893
4333
  const showPlaceholder = !stream;
4894
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
4334
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4895
4335
  "div",
4896
4336
  {
4897
4337
  style: __spreadValues({
@@ -4901,7 +4341,7 @@ function WebcamStream({
4901
4341
  }, style),
4902
4342
  className,
4903
4343
  children: [
4904
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
4344
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4905
4345
  "video",
4906
4346
  {
4907
4347
  ref: videoRef,
@@ -4916,7 +4356,7 @@ function WebcamStream({
4916
4356
  autoPlay: true
4917
4357
  }
4918
4358
  ),
4919
- showPlaceholder && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
4359
+ showPlaceholder && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4920
4360
  "div",
4921
4361
  {
4922
4362
  style: {
@@ -4937,11 +4377,11 @@ function WebcamStream({
4937
4377
  flexDirection: "column",
4938
4378
  gap: "12px"
4939
4379
  },
4940
- children: permissionDenied ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { fontSize: "12px", fontFamily: "monospace" }, children: [
4380
+ children: permissionDenied ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { fontSize: "12px", fontFamily: "monospace" }, children: [
4941
4381
  "Camera access denied.",
4942
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("br", {}),
4382
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("br", {}),
4943
4383
  "Please allow access in your browser settings."
4944
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { fontSize: "12px", fontFamily: "monospace" }, children: "Starting camera..." })
4384
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "12px", fontFamily: "monospace" }, children: "Starting camera..." })
4945
4385
  }
4946
4386
  )
4947
4387
  ]
@@ -4950,8 +4390,8 @@ function WebcamStream({
4950
4390
  }
4951
4391
 
4952
4392
  // src/react/ClipPlayer.tsx
4953
- var import_react8 = require("react");
4954
- var import_jsx_runtime5 = require("react/jsx-runtime");
4393
+ var import_react7 = require("react");
4394
+ var import_jsx_runtime4 = require("react/jsx-runtime");
4955
4395
  function ClipPlayer({
4956
4396
  clip,
4957
4397
  getJwt,
@@ -4962,28 +4402,28 @@ function ClipPlayer({
4962
4402
  style,
4963
4403
  onError
4964
4404
  }) {
4965
- const videoRef = (0, import_react8.useRef)(null);
4966
- const [phase, setPhase] = (0, import_react8.useState)({ kind: "waiting" });
4967
- const store = (0, import_react8.useContext)(ReactorContext);
4968
- const getJwtRef = (0, import_react8.useRef)(getJwt);
4969
- const autoPlayRef = (0, import_react8.useRef)(autoPlay);
4970
- const slackMsRef = (0, import_react8.useRef)(slackMs);
4971
- const onErrorRef = (0, import_react8.useRef)(onError);
4972
- const storeRef = (0, import_react8.useRef)(store);
4973
- (0, import_react8.useEffect)(() => {
4405
+ const videoRef = (0, import_react7.useRef)(null);
4406
+ const [phase, setPhase] = (0, import_react7.useState)({ kind: "waiting" });
4407
+ const store = (0, import_react7.useContext)(ReactorContext);
4408
+ const getJwtRef = (0, import_react7.useRef)(getJwt);
4409
+ const autoPlayRef = (0, import_react7.useRef)(autoPlay);
4410
+ const slackMsRef = (0, import_react7.useRef)(slackMs);
4411
+ const onErrorRef = (0, import_react7.useRef)(onError);
4412
+ const storeRef = (0, import_react7.useRef)(store);
4413
+ (0, import_react7.useEffect)(() => {
4974
4414
  getJwtRef.current = getJwt;
4975
4415
  autoPlayRef.current = autoPlay;
4976
4416
  slackMsRef.current = slackMs;
4977
4417
  onErrorRef.current = onError;
4978
4418
  storeRef.current = store;
4979
4419
  });
4980
- (0, import_react8.useEffect)(() => {
4420
+ (0, import_react7.useEffect)(() => {
4981
4421
  var _a;
4982
4422
  if (phase.kind === "error") {
4983
4423
  (_a = onErrorRef.current) == null ? void 0 : _a.call(onErrorRef, phase.error);
4984
4424
  }
4985
4425
  }, [phase]);
4986
- (0, import_react8.useEffect)(() => {
4426
+ (0, import_react7.useEffect)(() => {
4987
4427
  const video = videoRef.current;
4988
4428
  if (!video) return;
4989
4429
  const abort = new AbortController();
@@ -5086,7 +4526,7 @@ function ClipPlayer({
5086
4526
  };
5087
4527
  }, [clip]);
5088
4528
  const overlayText = phase.kind === "waiting" ? "Waiting for clip\u2026" : phase.kind === "loading" ? "Loading player\u2026" : null;
5089
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
4529
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5090
4530
  "div",
5091
4531
  {
5092
4532
  className,
@@ -5099,7 +4539,7 @@ function ClipPlayer({
5099
4539
  justifyContent: "center"
5100
4540
  }, style),
5101
4541
  children: [
5102
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4542
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5103
4543
  "video",
5104
4544
  {
5105
4545
  ref: videoRef,
@@ -5114,7 +4554,7 @@ function ClipPlayer({
5114
4554
  }
5115
4555
  }
5116
4556
  ),
5117
- overlayText && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4557
+ overlayText && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5118
4558
  "div",
5119
4559
  {
5120
4560
  style: {
@@ -5132,7 +4572,7 @@ function ClipPlayer({
5132
4572
  children: overlayText
5133
4573
  }
5134
4574
  ),
5135
- phase.kind === "error" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4575
+ phase.kind === "error" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5136
4576
  "div",
5137
4577
  {
5138
4578
  style: {
@@ -5156,26 +4596,26 @@ function ClipPlayer({
5156
4596
  }
5157
4597
 
5158
4598
  // src/react/ClipDownloadButton.tsx
5159
- var import_react10 = require("react");
4599
+ var import_react9 = require("react");
5160
4600
 
5161
4601
  // src/react/useClipDownload.ts
5162
- var import_react9 = require("react");
4602
+ var import_react8 = require("react");
5163
4603
  function useClipDownload(clip, options = {}) {
5164
4604
  var _a;
5165
- const [state, setState] = (0, import_react9.useState)({ kind: "idle" });
5166
- const store = (0, import_react9.useContext)(ReactorContext);
5167
- const clipRef = (0, import_react9.useRef)(clip);
5168
- const filenameRef = (0, import_react9.useRef)(
4605
+ const [state, setState] = (0, import_react8.useState)({ kind: "idle" });
4606
+ const store = (0, import_react8.useContext)(ReactorContext);
4607
+ const clipRef = (0, import_react8.useRef)(clip);
4608
+ const filenameRef = (0, import_react8.useRef)(
5169
4609
  (_a = options.filename) != null ? _a : "reactor-clip.mp4"
5170
4610
  );
5171
- const getJwtRef = (0, import_react9.useRef)(options.getJwt);
5172
- (0, import_react9.useEffect)(() => {
4611
+ const getJwtRef = (0, import_react8.useRef)(options.getJwt);
4612
+ (0, import_react8.useEffect)(() => {
5173
4613
  clipRef.current = clip;
5174
4614
  filenameRef.current = options.filename === void 0 ? "reactor-clip.mp4" : options.filename;
5175
4615
  getJwtRef.current = options.getJwt;
5176
4616
  });
5177
- const inFlightRef = (0, import_react9.useRef)(false);
5178
- const download = (0, import_react9.useCallback)(() => __async(null, null, function* () {
4617
+ const inFlightRef = (0, import_react8.useRef)(false);
4618
+ const download = (0, import_react8.useCallback)(() => __async(null, null, function* () {
5179
4619
  if (inFlightRef.current) return void 0;
5180
4620
  inFlightRef.current = true;
5181
4621
  setState({ kind: "downloading", fetched: 0, total: 0 });
@@ -5202,12 +4642,12 @@ function useClipDownload(clip, options = {}) {
5202
4642
  inFlightRef.current = false;
5203
4643
  }
5204
4644
  }), [store]);
5205
- const reset = (0, import_react9.useCallback)(() => setState({ kind: "idle" }), []);
4645
+ const reset = (0, import_react8.useCallback)(() => setState({ kind: "idle" }), []);
5206
4646
  return { state, download, reset };
5207
4647
  }
5208
4648
 
5209
4649
  // src/react/ClipDownloadButton.tsx
5210
- var import_jsx_runtime6 = require("react/jsx-runtime");
4650
+ var import_jsx_runtime5 = require("react/jsx-runtime");
5211
4651
  function ClipDownloadButton({
5212
4652
  clip,
5213
4653
  getJwt,
@@ -5222,20 +4662,20 @@ function ClipDownloadButton({
5222
4662
  const { state, download } = useClipDownload(clip, { filename, getJwt });
5223
4663
  const downloading = state.kind === "downloading";
5224
4664
  const isDisabled = downloading || !!disabled;
5225
- const onSuccessRef = (0, import_react10.useRef)(onSuccess);
5226
- const onErrorRef = (0, import_react10.useRef)(onError);
5227
- (0, import_react10.useEffect)(() => {
4665
+ const onSuccessRef = (0, import_react9.useRef)(onSuccess);
4666
+ const onErrorRef = (0, import_react9.useRef)(onError);
4667
+ (0, import_react9.useEffect)(() => {
5228
4668
  onSuccessRef.current = onSuccess;
5229
4669
  onErrorRef.current = onError;
5230
4670
  });
5231
- (0, import_react10.useEffect)(() => {
4671
+ (0, import_react9.useEffect)(() => {
5232
4672
  var _a;
5233
4673
  if (state.kind === "error") {
5234
4674
  (_a = onErrorRef.current) == null ? void 0 : _a.call(onErrorRef, new Error(state.message));
5235
4675
  }
5236
4676
  }, [state]);
5237
4677
  const content = typeof children === "function" ? children(state) : children !== void 0 ? children : defaultLabel(state);
5238
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
4678
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5239
4679
  "button",
5240
4680
  {
5241
4681
  type: "button",
@@ -5283,7 +4723,6 @@ function defaultLabel(state) {
5283
4723
  DEFAULT_PLAYLIST_POLL_SLACK_MS,
5284
4724
  FileRef,
5285
4725
  Reactor,
5286
- ReactorController,
5287
4726
  ReactorProvider,
5288
4727
  ReactorView,
5289
4728
  RecordingClient,