@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.mjs CHANGED
@@ -91,7 +91,7 @@ import { z } from "zod";
91
91
  // package.json
92
92
  var package_default = {
93
93
  name: "@reactor-team/js-sdk",
94
- version: "2.12.0",
94
+ version: "2.12.1",
95
95
  description: "Reactor JavaScript frontend SDK \u2014 connect React and TypeScript apps to real-time AI video models on Reactor.",
96
96
  license: "Apache-2.0",
97
97
  repository: {
@@ -163,14 +163,14 @@ var package_default = {
163
163
  }
164
164
  },
165
165
  devDependencies: {
166
- "@roamhq/wrtc": "^0.8.0",
166
+ "@roamhq/wrtc": "^0.10.0",
167
167
  "@types/node": "^25",
168
168
  "@types/react": "^19.2.15",
169
169
  "@types/sdp-transform": "^2.15.0",
170
170
  "hls.js": "^1.6.0",
171
- prettier: "^3.6.2",
171
+ prettier: "^3.8.4",
172
172
  tsup: "^8.5.0",
173
- typescript: "^5.8.3",
173
+ typescript: "^6.0.3",
174
174
  vitest: "^4.1.7"
175
175
  }
176
176
  };
@@ -3341,10 +3341,6 @@ var Reactor = class {
3341
3341
  ]);
3342
3342
  sessionPollingMs = performance.now() - tParallel;
3343
3343
  this.sessionResponse = sessionResponse;
3344
- this.capabilities = __spreadProps(__spreadValues({}, sessionResponse.capabilities), {
3345
- tracks: this.tracks
3346
- });
3347
- this.emit("capabilitiesReceived", this.capabilities);
3348
3344
  const tConnect = performance.now();
3349
3345
  yield this.transportClient.connect(false, options == null ? void 0 : options.connectionId);
3350
3346
  transportConnectingMs = performance.now() - tConnect;
@@ -3355,10 +3351,6 @@ var Reactor = class {
3355
3351
  sessionPollingMs = performance.now() - tPoll;
3356
3352
  this.sessionResponse = sessionResponse;
3357
3353
  this.tracks = sessionResponse.capabilities.tracks;
3358
- this.capabilities = __spreadProps(__spreadValues({}, sessionResponse.capabilities), {
3359
- tracks: this.tracks
3360
- });
3361
- this.emit("capabilitiesReceived", this.capabilities);
3362
3354
  const protocol = sessionResponse.selected_transport.protocol;
3363
3355
  if (protocol !== "webrtc") {
3364
3356
  throw new Error(`Unsupported transport protocol: ${protocol}`);
@@ -3407,6 +3399,10 @@ var Reactor = class {
3407
3399
  if (scope === "application") {
3408
3400
  this.emit("message", message);
3409
3401
  } else if (scope === "runtime") {
3402
+ if (message && typeof message === "object" && message.type === "modelSchema" && message.data) {
3403
+ this.schema = message.data;
3404
+ this.emit("schemaReceived", this.schema);
3405
+ }
3410
3406
  this.emit("runtimeMessage", message);
3411
3407
  }
3412
3408
  });
@@ -3423,6 +3419,7 @@ var Reactor = class {
3423
3419
  }
3424
3420
  }
3425
3421
  this.setStatus("ready");
3422
+ void this.sendCommand("requestSchema", {}, "runtime");
3426
3423
  break;
3427
3424
  case "disconnected":
3428
3425
  this.disconnect(true);
@@ -3500,7 +3497,7 @@ var Reactor = class {
3500
3497
  if (!recoverable) {
3501
3498
  this.setSessionExpiration(void 0);
3502
3499
  this.setSessionId(void 0);
3503
- this.capabilities = void 0;
3500
+ this.schema = void 0;
3504
3501
  this.tracks = [];
3505
3502
  this.sessionResponse = void 0;
3506
3503
  this.createdSession = false;
@@ -3525,8 +3522,13 @@ var Reactor = class {
3525
3522
  getLastError() {
3526
3523
  return this.lastError;
3527
3524
  }
3528
- getCapabilities() {
3529
- return this.capabilities;
3525
+ /**
3526
+ * The model's OpenAPI schema (events, outbound messages, tracks),
3527
+ * received over the runtime channel shortly after the session becomes
3528
+ * ready. `undefined` until the `schemaReceived` event has fired.
3529
+ */
3530
+ getSchema() {
3531
+ return this.schema;
3530
3532
  }
3531
3533
  getSessionInfo() {
3532
3534
  return this.sessionResponse;
@@ -3537,6 +3539,10 @@ var Reactor = class {
3537
3539
  if (!stats) return void 0;
3538
3540
  return __spreadProps(__spreadValues({}, stats), { connectionTimings: this.connectionTimings });
3539
3541
  }
3542
+ /** Timing breakdown from the most recent connect() handshake. */
3543
+ getConnectionTimings() {
3544
+ return this.connectionTimings;
3545
+ }
3540
3546
  // ─────────────────────────────────────────────────────────────────────────
3541
3547
  // Private State Management
3542
3548
  // ─────────────────────────────────────────────────────────────────────────
@@ -3751,6 +3757,8 @@ var createReactorStore = (initProps, publicState = defaultInitState) => {
3751
3757
  throw error;
3752
3758
  }
3753
3759
  }),
3760
+ pauseTrack: (name) => get().internal.reactor.pauseTrack(name),
3761
+ resumeTrack: (name) => get().internal.reactor.resumeTrack(name),
3754
3762
  reconnect: (options) => __async(null, null, function* () {
3755
3763
  console.debug("[ReactorStore] Reconnecting");
3756
3764
  try {
@@ -4064,576 +4072,9 @@ function ReactorView({
4064
4072
  );
4065
4073
  }
4066
4074
 
4067
- // src/react/ReactorController.tsx
4068
- import React, { useState as useState3, useCallback, useRef as useRef4 } from "react";
4069
- import { jsx as jsx3, jsxs } from "react/jsx-runtime";
4070
- function isFileParam(ps) {
4071
- return ps.type === "file" || ps.type === "object" && ps.format === "file-reference";
4072
- }
4073
- function ReactorController({
4074
- className,
4075
- style
4076
- }) {
4077
- const { sendCommand, uploadFile, status } = useReactor((state) => ({
4078
- sendCommand: state.sendCommand,
4079
- uploadFile: state.uploadFile,
4080
- status: state.status
4081
- }));
4082
- const [commands, setCommands] = useState3({});
4083
- const [formValues, setFormValues] = useState3({});
4084
- const formRef = useRef4(formValues);
4085
- formRef.current = formValues;
4086
- const [expandedCommands, setExpandedCommands] = useState3({});
4087
- React.useEffect(() => {
4088
- if (status === "disconnected") {
4089
- setCommands({});
4090
- setFormValues({});
4091
- setExpandedCommands({});
4092
- }
4093
- }, [status]);
4094
- const requestCapabilities = useCallback(() => {
4095
- if (status === "ready") {
4096
- sendCommand("requestCapabilities", {}, "runtime");
4097
- }
4098
- }, [status, sendCommand]);
4099
- React.useEffect(() => {
4100
- if (status === "ready") {
4101
- requestCapabilities();
4102
- }
4103
- }, [status, requestCapabilities]);
4104
- React.useEffect(() => {
4105
- if (status !== "ready" || Object.keys(commands).length > 0) {
4106
- return;
4107
- }
4108
- const interval = setInterval(() => {
4109
- requestCapabilities();
4110
- }, 5e3);
4111
- return () => clearInterval(interval);
4112
- }, [status, commands, requestCapabilities]);
4113
- useReactorInternalMessage((message) => {
4114
- var _a;
4115
- if (message && typeof message === "object" && message.type === "modelCapabilities" && message.data && "commands" in message.data) {
4116
- const commandsMessage = message.data;
4117
- const commandsRecord = {};
4118
- for (const cmd of commandsMessage.commands) {
4119
- commandsRecord[cmd.name] = {
4120
- description: cmd.description,
4121
- schema: (_a = cmd.schema) != null ? _a : {}
4122
- };
4123
- }
4124
- setCommands(commandsRecord);
4125
- const initialValues = {};
4126
- const initialExpanded = {};
4127
- Object.entries(commandsRecord).forEach(([commandName, commandSchema]) => {
4128
- initialValues[commandName] = {};
4129
- initialExpanded[commandName] = false;
4130
- Object.entries(commandSchema.schema).forEach(
4131
- ([paramName, paramSchema]) => {
4132
- var _a2;
4133
- if (isFileParam(paramSchema)) {
4134
- initialValues[commandName][paramName] = null;
4135
- } else if (paramSchema.default !== void 0) {
4136
- initialValues[commandName][paramName] = paramSchema.default;
4137
- } else if (paramSchema.type === "number" || paramSchema.type === "integer") {
4138
- initialValues[commandName][paramName] = (_a2 = paramSchema.minimum) != null ? _a2 : 0;
4139
- } else if (paramSchema.type === "string") {
4140
- initialValues[commandName][paramName] = "";
4141
- } else if (paramSchema.type === "boolean") {
4142
- initialValues[commandName][paramName] = false;
4143
- }
4144
- }
4145
- );
4146
- });
4147
- setFormValues(initialValues);
4148
- setExpandedCommands(initialExpanded);
4149
- }
4150
- });
4151
- const handleInputChange = useCallback(
4152
- (commandName, paramName, value) => {
4153
- setFormValues((prev) => __spreadProps(__spreadValues({}, prev), {
4154
- [commandName]: __spreadProps(__spreadValues({}, prev[commandName]), {
4155
- [paramName]: value
4156
- })
4157
- }));
4158
- },
4159
- []
4160
- );
4161
- const toggleCommandExpanded = useCallback((commandName) => {
4162
- setExpandedCommands((prev) => __spreadProps(__spreadValues({}, prev), {
4163
- [commandName]: !prev[commandName]
4164
- }));
4165
- }, []);
4166
- const handleCommandSubmit = useCallback(
4167
- (commandName) => __async(null, null, function* () {
4168
- const commandSchema = commands[commandName];
4169
- const formData = formRef.current[commandName] || {};
4170
- const data = {};
4171
- Object.keys(commandSchema.schema).forEach((paramName) => {
4172
- var _a;
4173
- const paramSchema = commandSchema.schema[paramName];
4174
- let value = formData[paramName];
4175
- if (value instanceof FileRef) {
4176
- data[paramName] = value;
4177
- return;
4178
- }
4179
- if (paramSchema.type === "number" && typeof value === "string") {
4180
- value = parseFloat(value) || 0;
4181
- } else if (paramSchema.type === "integer" && typeof value === "string") {
4182
- value = parseInt(value) || 0;
4183
- } else if (paramSchema.type === "boolean" && typeof value !== "boolean") {
4184
- value = Boolean(value);
4185
- }
4186
- if (value !== void 0 && value !== "" && value !== null) {
4187
- data[paramName] = value;
4188
- } else if (paramSchema.required) {
4189
- if (paramSchema.type === "number" || paramSchema.type === "integer") {
4190
- data[paramName] = (_a = paramSchema.minimum) != null ? _a : 0;
4191
- } else if (paramSchema.type === "string") {
4192
- data[paramName] = "";
4193
- } else if (paramSchema.type === "boolean") {
4194
- data[paramName] = false;
4195
- }
4196
- }
4197
- });
4198
- yield sendCommand(commandName, data);
4199
- }),
4200
- [sendCommand, commands]
4201
- );
4202
- const renderInput = (commandName, paramName, paramSchema) => {
4203
- var _a, _b;
4204
- const value = (_b = (_a = formValues[commandName]) == null ? void 0 : _a[paramName]) != null ? _b : "";
4205
- if (isFileParam(paramSchema)) {
4206
- return /* @__PURE__ */ jsx3(
4207
- FileParamInput,
4208
- {
4209
- commandName,
4210
- paramName,
4211
- description: paramSchema.description,
4212
- value,
4213
- onChange: handleInputChange,
4214
- disabled: status !== "ready",
4215
- uploadFile
4216
- },
4217
- `${commandName}-${paramName}`
4218
- );
4219
- }
4220
- if (paramSchema.type === "number" || paramSchema.type === "integer") {
4221
- const isInteger = paramSchema.type === "integer";
4222
- const step = isInteger ? 1 : 0.1;
4223
- const parseValue = isInteger ? parseInt : parseFloat;
4224
- if (typeof paramSchema.minimum === "number" && typeof paramSchema.maximum === "number") {
4225
- return /* @__PURE__ */ jsxs("div", { style: { marginBottom: "8px" }, children: [
4226
- /* @__PURE__ */ jsxs(
4227
- "label",
4228
- {
4229
- style: { fontSize: "12px", color: "#666", display: "block" },
4230
- children: [
4231
- paramName,
4232
- " (",
4233
- paramSchema.minimum,
4234
- " - ",
4235
- paramSchema.maximum,
4236
- ")",
4237
- paramSchema.description && ` - ${paramSchema.description}`,
4238
- paramSchema.required && /* @__PURE__ */ jsx3("span", { style: { color: "red" }, children: " *" })
4239
- ]
4240
- }
4241
- ),
4242
- /* @__PURE__ */ jsx3(
4243
- "input",
4244
- {
4245
- type: "range",
4246
- min: paramSchema.minimum,
4247
- max: paramSchema.maximum,
4248
- step,
4249
- value,
4250
- onChange: (e) => {
4251
- const newValue = parseValue(e.target.value) || 0;
4252
- handleInputChange(commandName, paramName, newValue);
4253
- handleCommandSubmit(commandName);
4254
- },
4255
- style: { width: "100%", marginBottom: "4px" }
4256
- }
4257
- ),
4258
- /* @__PURE__ */ jsxs("div", { style: { fontSize: "11px", color: "#888" }, children: [
4259
- "Value: ",
4260
- value
4261
- ] })
4262
- ] });
4263
- } else {
4264
- return /* @__PURE__ */ jsxs("div", { style: { marginBottom: "8px" }, children: [
4265
- /* @__PURE__ */ jsxs(
4266
- "label",
4267
- {
4268
- style: { fontSize: "12px", color: "#666", display: "block" },
4269
- children: [
4270
- paramName,
4271
- paramSchema.description && ` - ${paramSchema.description}`,
4272
- paramSchema.required && /* @__PURE__ */ jsx3("span", { style: { color: "red" }, children: " *" })
4273
- ]
4274
- }
4275
- ),
4276
- /* @__PURE__ */ jsx3(
4277
- "input",
4278
- {
4279
- type: "number",
4280
- value,
4281
- min: paramSchema.minimum,
4282
- max: paramSchema.maximum,
4283
- step,
4284
- inputMode: "numeric",
4285
- onChange: (e) => {
4286
- const val = e.target.value;
4287
- if (val === "" || val === "-") {
4288
- handleInputChange(commandName, paramName, val);
4289
- } else {
4290
- const parsed = parseValue(val);
4291
- if (!isNaN(parsed)) {
4292
- handleInputChange(commandName, paramName, parsed);
4293
- }
4294
- }
4295
- },
4296
- onBlur: (e) => {
4297
- const val = e.target.value;
4298
- if (val === "" || val === "-") {
4299
- handleInputChange(commandName, paramName, 0);
4300
- }
4301
- },
4302
- style: {
4303
- width: "100%",
4304
- padding: "4px",
4305
- fontSize: "12px",
4306
- border: "1px solid #ccc",
4307
- borderRadius: "2px"
4308
- }
4309
- }
4310
- )
4311
- ] });
4312
- }
4313
- } else if (paramSchema.type === "string") {
4314
- if (paramSchema.enum) {
4315
- return /* @__PURE__ */ jsxs("div", { style: { marginBottom: "8px" }, children: [
4316
- /* @__PURE__ */ jsxs(
4317
- "label",
4318
- {
4319
- style: { fontSize: "12px", color: "#666", display: "block" },
4320
- children: [
4321
- paramName,
4322
- paramSchema.description && ` - ${paramSchema.description}`,
4323
- paramSchema.required && /* @__PURE__ */ jsx3("span", { style: { color: "red" }, children: " *" })
4324
- ]
4325
- }
4326
- ),
4327
- /* @__PURE__ */ jsxs(
4328
- "select",
4329
- {
4330
- value,
4331
- onChange: (e) => handleInputChange(commandName, paramName, e.target.value),
4332
- style: {
4333
- width: "100%",
4334
- padding: "4px",
4335
- fontSize: "12px",
4336
- border: "1px solid #ccc",
4337
- borderRadius: "2px"
4338
- },
4339
- children: [
4340
- /* @__PURE__ */ jsx3("option", { value: "", children: "Select..." }),
4341
- paramSchema.enum.map((option) => /* @__PURE__ */ jsx3("option", { value: option, children: option }, option))
4342
- ]
4343
- }
4344
- )
4345
- ] });
4346
- } else {
4347
- return /* @__PURE__ */ jsxs("div", { style: { marginBottom: "8px" }, children: [
4348
- /* @__PURE__ */ jsxs(
4349
- "label",
4350
- {
4351
- style: { fontSize: "12px", color: "#666", display: "block" },
4352
- children: [
4353
- paramName,
4354
- paramSchema.description && ` - ${paramSchema.description}`,
4355
- paramSchema.required && /* @__PURE__ */ jsx3("span", { style: { color: "red" }, children: " *" })
4356
- ]
4357
- }
4358
- ),
4359
- /* @__PURE__ */ jsx3(
4360
- "input",
4361
- {
4362
- type: "text",
4363
- value,
4364
- onChange: (e) => handleInputChange(commandName, paramName, e.target.value),
4365
- style: {
4366
- width: "100%",
4367
- padding: "4px",
4368
- fontSize: "12px",
4369
- border: "1px solid #ccc",
4370
- borderRadius: "2px"
4371
- }
4372
- }
4373
- )
4374
- ] });
4375
- }
4376
- } else if (paramSchema.type === "boolean") {
4377
- return /* @__PURE__ */ jsx3("div", { style: { marginBottom: "8px" }, children: /* @__PURE__ */ jsxs(
4378
- "label",
4379
- {
4380
- style: {
4381
- fontSize: "12px",
4382
- color: "#666",
4383
- display: "flex",
4384
- alignItems: "center"
4385
- },
4386
- children: [
4387
- /* @__PURE__ */ jsx3(
4388
- "input",
4389
- {
4390
- type: "checkbox",
4391
- checked: value,
4392
- onChange: (e) => handleInputChange(commandName, paramName, e.target.checked),
4393
- style: { marginRight: "6px" }
4394
- }
4395
- ),
4396
- paramName,
4397
- paramSchema.description && ` - ${paramSchema.description}`,
4398
- paramSchema.required && /* @__PURE__ */ jsx3("span", { style: { color: "red" }, children: " *" })
4399
- ]
4400
- }
4401
- ) });
4402
- }
4403
- return null;
4404
- };
4405
- const renderCommand = (commandName, commandSchema) => {
4406
- const hasParams = Object.keys(commandSchema.schema).length > 0;
4407
- const isExpanded = expandedCommands[commandName];
4408
- const params = Object.values(commandSchema.schema);
4409
- const allSliders = params.length > 0 && params.every(
4410
- (ps) => (ps.type === "number" || ps.type === "integer") && typeof ps.minimum === "number" && typeof ps.maximum === "number"
4411
- );
4412
- const showExecuteButton = !allSliders;
4413
- return /* @__PURE__ */ jsxs(
4414
- "div",
4415
- {
4416
- style: {
4417
- border: "1px solid #ddd",
4418
- borderRadius: "4px",
4419
- marginBottom: "8px",
4420
- backgroundColor: "#fafafa"
4421
- },
4422
- children: [
4423
- /* @__PURE__ */ jsxs(
4424
- "div",
4425
- {
4426
- onClick: () => toggleCommandExpanded(commandName),
4427
- style: {
4428
- padding: "8px 12px",
4429
- cursor: "pointer",
4430
- borderBottom: isExpanded ? "1px solid #ddd" : "none",
4431
- display: "flex",
4432
- justifyContent: "space-between",
4433
- alignItems: "center"
4434
- },
4435
- children: [
4436
- /* @__PURE__ */ jsxs("div", { children: [
4437
- /* @__PURE__ */ jsx3(
4438
- "h4",
4439
- {
4440
- style: {
4441
- margin: "0",
4442
- fontSize: "13px",
4443
- fontWeight: "bold"
4444
- },
4445
- children: commandName
4446
- }
4447
- ),
4448
- isExpanded && commandSchema.description && /* @__PURE__ */ jsx3(
4449
- "p",
4450
- {
4451
- style: { margin: "4px 0 0 0", fontSize: "11px", color: "#666" },
4452
- children: commandSchema.description
4453
- }
4454
- )
4455
- ] }),
4456
- /* @__PURE__ */ jsx3(
4457
- "div",
4458
- {
4459
- style: {
4460
- fontSize: "10px",
4461
- color: "#999",
4462
- transform: isExpanded ? "rotate(180deg)" : "rotate(0deg)",
4463
- transition: "transform 0.2s"
4464
- },
4465
- children: "\u25BC"
4466
- }
4467
- )
4468
- ]
4469
- }
4470
- ),
4471
- isExpanded && /* @__PURE__ */ jsxs("div", { style: { padding: "12px", paddingTop: "0" }, children: [
4472
- hasParams && /* @__PURE__ */ jsxs("div", { style: { marginBottom: showExecuteButton ? "12px" : "0" }, children: [
4473
- /* @__PURE__ */ jsx3(
4474
- "div",
4475
- {
4476
- style: {
4477
- marginBottom: "8px",
4478
- fontSize: "12px",
4479
- fontWeight: "bold",
4480
- color: "#555"
4481
- },
4482
- children: "Parameters:"
4483
- }
4484
- ),
4485
- Object.entries(commandSchema.schema).map(
4486
- ([paramName, paramSchema]) => /* @__PURE__ */ jsx3(
4487
- "div",
4488
- {
4489
- style: { marginLeft: "8px" },
4490
- children: renderInput(commandName, paramName, paramSchema)
4491
- },
4492
- `${commandName}-${paramName}`
4493
- )
4494
- )
4495
- ] }),
4496
- !hasParams && /* @__PURE__ */ jsx3(
4497
- "div",
4498
- {
4499
- style: {
4500
- marginBottom: showExecuteButton ? "12px" : "0",
4501
- marginTop: "2px",
4502
- fontSize: "11px",
4503
- color: "#666",
4504
- fontStyle: "italic"
4505
- },
4506
- children: "No parameters required"
4507
- }
4508
- ),
4509
- showExecuteButton && /* @__PURE__ */ jsxs(
4510
- "button",
4511
- {
4512
- onClick: () => handleCommandSubmit(commandName),
4513
- style: {
4514
- padding: "8px 16px",
4515
- fontSize: "12px",
4516
- backgroundColor: "#007bff",
4517
- color: "white",
4518
- border: "none",
4519
- borderRadius: "4px",
4520
- cursor: "pointer",
4521
- fontWeight: "bold"
4522
- },
4523
- children: [
4524
- "Execute ",
4525
- commandName
4526
- ]
4527
- }
4528
- )
4529
- ] })
4530
- ]
4531
- },
4532
- commandName
4533
- );
4534
- };
4535
- return /* @__PURE__ */ jsx3("div", { className, style, children: /* @__PURE__ */ jsx3("div", { style: { fontFamily: "monospace", fontSize: "12px" }, children: Object.keys(commands).length === 0 ? /* @__PURE__ */ jsx3("div", { style: { padding: "12px", color: "#666", fontStyle: "italic" }, children: "Waiting for commands schema..." }) : /* @__PURE__ */ jsxs("div", { children: [
4536
- /* @__PURE__ */ jsx3(
4537
- "h3",
4538
- {
4539
- style: {
4540
- margin: "0 0 16px 0",
4541
- fontSize: "16px",
4542
- fontWeight: "bold"
4543
- },
4544
- children: "Reactor Commands"
4545
- }
4546
- ),
4547
- Object.entries(commands).map(([commandName, commandSchema]) => /* @__PURE__ */ jsx3("div", { children: renderCommand(commandName, commandSchema) }, commandName))
4548
- ] }) }) });
4549
- }
4550
- function FileParamInput({
4551
- commandName,
4552
- paramName,
4553
- description,
4554
- value,
4555
- onChange,
4556
- disabled,
4557
- uploadFile
4558
- }) {
4559
- const inputRef = useRef4(null);
4560
- const [uploading, setUploading] = useState3(false);
4561
- const fileRef = value instanceof FileRef ? value : null;
4562
- const handleFile = (e) => __async(null, null, function* () {
4563
- var _a;
4564
- const file = (_a = e.target.files) == null ? void 0 : _a[0];
4565
- if (!file) return;
4566
- e.target.value = "";
4567
- setUploading(true);
4568
- try {
4569
- const ref = yield uploadFile(file);
4570
- onChange(commandName, paramName, ref);
4571
- } catch (err) {
4572
- console.error("[FileParamInput] Upload failed:", err);
4573
- } finally {
4574
- setUploading(false);
4575
- }
4576
- });
4577
- return /* @__PURE__ */ jsxs("div", { style: { marginBottom: "8px" }, children: [
4578
- /* @__PURE__ */ jsxs("label", { style: { fontSize: "12px", color: "#666", display: "block" }, children: [
4579
- paramName,
4580
- /* @__PURE__ */ jsx3("span", { style: { color: "#888", fontSize: "11px" }, children: " (file)" }),
4581
- description && ` - ${description}`
4582
- ] }),
4583
- /* @__PURE__ */ jsxs(
4584
- "div",
4585
- {
4586
- style: {
4587
- display: "flex",
4588
- alignItems: "center",
4589
- gap: "8px",
4590
- marginTop: "4px"
4591
- },
4592
- children: [
4593
- /* @__PURE__ */ jsx3(
4594
- "input",
4595
- {
4596
- ref: inputRef,
4597
- type: "file",
4598
- accept: "image/*",
4599
- onChange: handleFile,
4600
- style: { display: "none" }
4601
- }
4602
- ),
4603
- /* @__PURE__ */ jsx3(
4604
- "button",
4605
- {
4606
- disabled: disabled || uploading,
4607
- onClick: () => {
4608
- var _a;
4609
- return (_a = inputRef.current) == null ? void 0 : _a.click();
4610
- },
4611
- style: {
4612
- padding: "4px 12px",
4613
- fontSize: "12px",
4614
- backgroundColor: "#007bff",
4615
- color: "white",
4616
- border: "none",
4617
- borderRadius: "4px",
4618
- cursor: disabled || uploading ? "default" : "pointer",
4619
- opacity: disabled || uploading ? 0.5 : 1
4620
- },
4621
- children: uploading ? "Uploading\u2026" : fileRef ? "Change" : "Choose File"
4622
- }
4623
- ),
4624
- fileRef && /* @__PURE__ */ jsxs("span", { style: { fontSize: "11px", color: "#28a745" }, children: [
4625
- "\\u2713 ",
4626
- fileRef.name
4627
- ] })
4628
- ]
4629
- }
4630
- )
4631
- ] });
4632
- }
4633
-
4634
4075
  // src/react/WebcamStream.tsx
4635
- import { useEffect as useEffect4, useRef as useRef5, useState as useState4 } from "react";
4636
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
4076
+ import { useEffect as useEffect4, useRef as useRef4, useState as useState3 } from "react";
4077
+ import { jsx as jsx3, jsxs } from "react/jsx-runtime";
4637
4078
  function WebcamStream({
4638
4079
  track,
4639
4080
  audio = false,
@@ -4650,19 +4091,19 @@ function WebcamStream({
4650
4091
  onPublished,
4651
4092
  onError
4652
4093
  }) {
4653
- const [stream, setStream] = useState4(null);
4654
- const [isPublishing, setIsPublishing] = useState4(false);
4655
- const [permissionDenied, setPermissionDenied] = useState4(false);
4094
+ const [stream, setStream] = useState3(null);
4095
+ const [isPublishing, setIsPublishing] = useState3(false);
4096
+ const [permissionDenied, setPermissionDenied] = useState3(false);
4656
4097
  const { status, publish, unpublish, reactor } = useReactor((state) => ({
4657
4098
  status: state.status,
4658
4099
  publish: state.publish,
4659
4100
  unpublish: state.unpublish,
4660
4101
  reactor: state.internal.reactor
4661
4102
  }));
4662
- const videoRef = useRef5(null);
4663
- const onPermissionDeniedRef = useRef5(onPermissionDenied);
4664
- const onPublishedRef = useRef5(onPublished);
4665
- const onErrorRef = useRef5(onError);
4103
+ const videoRef = useRef4(null);
4104
+ const onPermissionDeniedRef = useRef4(onPermissionDenied);
4105
+ const onPublishedRef = useRef4(onPublished);
4106
+ const onErrorRef = useRef4(onError);
4666
4107
  useEffect4(() => {
4667
4108
  onPermissionDeniedRef.current = onPermissionDenied;
4668
4109
  onPublishedRef.current = onPublished;
@@ -4835,7 +4276,7 @@ function WebcamStream({
4835
4276
  };
4836
4277
  }, []);
4837
4278
  const showPlaceholder = !stream;
4838
- return /* @__PURE__ */ jsxs2(
4279
+ return /* @__PURE__ */ jsxs(
4839
4280
  "div",
4840
4281
  {
4841
4282
  style: __spreadValues({
@@ -4845,7 +4286,7 @@ function WebcamStream({
4845
4286
  }, style),
4846
4287
  className,
4847
4288
  children: [
4848
- /* @__PURE__ */ jsx4(
4289
+ /* @__PURE__ */ jsx3(
4849
4290
  "video",
4850
4291
  {
4851
4292
  ref: videoRef,
@@ -4860,7 +4301,7 @@ function WebcamStream({
4860
4301
  autoPlay: true
4861
4302
  }
4862
4303
  ),
4863
- showPlaceholder && /* @__PURE__ */ jsx4(
4304
+ showPlaceholder && /* @__PURE__ */ jsx3(
4864
4305
  "div",
4865
4306
  {
4866
4307
  style: {
@@ -4881,11 +4322,11 @@ function WebcamStream({
4881
4322
  flexDirection: "column",
4882
4323
  gap: "12px"
4883
4324
  },
4884
- children: permissionDenied ? /* @__PURE__ */ jsxs2("div", { style: { fontSize: "12px", fontFamily: "monospace" }, children: [
4325
+ children: permissionDenied ? /* @__PURE__ */ jsxs("div", { style: { fontSize: "12px", fontFamily: "monospace" }, children: [
4885
4326
  "Camera access denied.",
4886
- /* @__PURE__ */ jsx4("br", {}),
4327
+ /* @__PURE__ */ jsx3("br", {}),
4887
4328
  "Please allow access in your browser settings."
4888
- ] }) : /* @__PURE__ */ jsx4("div", { style: { fontSize: "12px", fontFamily: "monospace" }, children: "Starting camera..." })
4329
+ ] }) : /* @__PURE__ */ jsx3("div", { style: { fontSize: "12px", fontFamily: "monospace" }, children: "Starting camera..." })
4889
4330
  }
4890
4331
  )
4891
4332
  ]
@@ -4894,8 +4335,8 @@ function WebcamStream({
4894
4335
  }
4895
4336
 
4896
4337
  // src/react/ClipPlayer.tsx
4897
- import { useContext as useContext2, useEffect as useEffect5, useRef as useRef6, useState as useState5 } from "react";
4898
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
4338
+ import { useContext as useContext2, useEffect as useEffect5, useRef as useRef5, useState as useState4 } from "react";
4339
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
4899
4340
  function ClipPlayer({
4900
4341
  clip,
4901
4342
  getJwt,
@@ -4906,14 +4347,14 @@ function ClipPlayer({
4906
4347
  style,
4907
4348
  onError
4908
4349
  }) {
4909
- const videoRef = useRef6(null);
4910
- const [phase, setPhase] = useState5({ kind: "waiting" });
4350
+ const videoRef = useRef5(null);
4351
+ const [phase, setPhase] = useState4({ kind: "waiting" });
4911
4352
  const store = useContext2(ReactorContext);
4912
- const getJwtRef = useRef6(getJwt);
4913
- const autoPlayRef = useRef6(autoPlay);
4914
- const slackMsRef = useRef6(slackMs);
4915
- const onErrorRef = useRef6(onError);
4916
- const storeRef = useRef6(store);
4353
+ const getJwtRef = useRef5(getJwt);
4354
+ const autoPlayRef = useRef5(autoPlay);
4355
+ const slackMsRef = useRef5(slackMs);
4356
+ const onErrorRef = useRef5(onError);
4357
+ const storeRef = useRef5(store);
4917
4358
  useEffect5(() => {
4918
4359
  getJwtRef.current = getJwt;
4919
4360
  autoPlayRef.current = autoPlay;
@@ -5030,7 +4471,7 @@ function ClipPlayer({
5030
4471
  };
5031
4472
  }, [clip]);
5032
4473
  const overlayText = phase.kind === "waiting" ? "Waiting for clip\u2026" : phase.kind === "loading" ? "Loading player\u2026" : null;
5033
- return /* @__PURE__ */ jsxs3(
4474
+ return /* @__PURE__ */ jsxs2(
5034
4475
  "div",
5035
4476
  {
5036
4477
  className,
@@ -5043,7 +4484,7 @@ function ClipPlayer({
5043
4484
  justifyContent: "center"
5044
4485
  }, style),
5045
4486
  children: [
5046
- /* @__PURE__ */ jsx5(
4487
+ /* @__PURE__ */ jsx4(
5047
4488
  "video",
5048
4489
  {
5049
4490
  ref: videoRef,
@@ -5058,7 +4499,7 @@ function ClipPlayer({
5058
4499
  }
5059
4500
  }
5060
4501
  ),
5061
- overlayText && /* @__PURE__ */ jsx5(
4502
+ overlayText && /* @__PURE__ */ jsx4(
5062
4503
  "div",
5063
4504
  {
5064
4505
  style: {
@@ -5076,7 +4517,7 @@ function ClipPlayer({
5076
4517
  children: overlayText
5077
4518
  }
5078
4519
  ),
5079
- phase.kind === "error" && /* @__PURE__ */ jsx5(
4520
+ phase.kind === "error" && /* @__PURE__ */ jsx4(
5080
4521
  "div",
5081
4522
  {
5082
4523
  style: {
@@ -5100,26 +4541,26 @@ function ClipPlayer({
5100
4541
  }
5101
4542
 
5102
4543
  // src/react/ClipDownloadButton.tsx
5103
- import { useEffect as useEffect7, useRef as useRef8 } from "react";
4544
+ import { useEffect as useEffect7, useRef as useRef7 } from "react";
5104
4545
 
5105
4546
  // src/react/useClipDownload.ts
5106
- import { useCallback as useCallback2, useContext as useContext3, useEffect as useEffect6, useRef as useRef7, useState as useState6 } from "react";
4547
+ import { useCallback, useContext as useContext3, useEffect as useEffect6, useRef as useRef6, useState as useState5 } from "react";
5107
4548
  function useClipDownload(clip, options = {}) {
5108
4549
  var _a;
5109
- const [state, setState] = useState6({ kind: "idle" });
4550
+ const [state, setState] = useState5({ kind: "idle" });
5110
4551
  const store = useContext3(ReactorContext);
5111
- const clipRef = useRef7(clip);
5112
- const filenameRef = useRef7(
4552
+ const clipRef = useRef6(clip);
4553
+ const filenameRef = useRef6(
5113
4554
  (_a = options.filename) != null ? _a : "reactor-clip.mp4"
5114
4555
  );
5115
- const getJwtRef = useRef7(options.getJwt);
4556
+ const getJwtRef = useRef6(options.getJwt);
5116
4557
  useEffect6(() => {
5117
4558
  clipRef.current = clip;
5118
4559
  filenameRef.current = options.filename === void 0 ? "reactor-clip.mp4" : options.filename;
5119
4560
  getJwtRef.current = options.getJwt;
5120
4561
  });
5121
- const inFlightRef = useRef7(false);
5122
- const download = useCallback2(() => __async(null, null, function* () {
4562
+ const inFlightRef = useRef6(false);
4563
+ const download = useCallback(() => __async(null, null, function* () {
5123
4564
  if (inFlightRef.current) return void 0;
5124
4565
  inFlightRef.current = true;
5125
4566
  setState({ kind: "downloading", fetched: 0, total: 0 });
@@ -5146,12 +4587,12 @@ function useClipDownload(clip, options = {}) {
5146
4587
  inFlightRef.current = false;
5147
4588
  }
5148
4589
  }), [store]);
5149
- const reset = useCallback2(() => setState({ kind: "idle" }), []);
4590
+ const reset = useCallback(() => setState({ kind: "idle" }), []);
5150
4591
  return { state, download, reset };
5151
4592
  }
5152
4593
 
5153
4594
  // src/react/ClipDownloadButton.tsx
5154
- import { jsx as jsx6 } from "react/jsx-runtime";
4595
+ import { jsx as jsx5 } from "react/jsx-runtime";
5155
4596
  function ClipDownloadButton({
5156
4597
  clip,
5157
4598
  getJwt,
@@ -5166,8 +4607,8 @@ function ClipDownloadButton({
5166
4607
  const { state, download } = useClipDownload(clip, { filename, getJwt });
5167
4608
  const downloading = state.kind === "downloading";
5168
4609
  const isDisabled = downloading || !!disabled;
5169
- const onSuccessRef = useRef8(onSuccess);
5170
- const onErrorRef = useRef8(onError);
4610
+ const onSuccessRef = useRef7(onSuccess);
4611
+ const onErrorRef = useRef7(onError);
5171
4612
  useEffect7(() => {
5172
4613
  onSuccessRef.current = onSuccess;
5173
4614
  onErrorRef.current = onError;
@@ -5179,7 +4620,7 @@ function ClipDownloadButton({
5179
4620
  }
5180
4621
  }, [state]);
5181
4622
  const content = typeof children === "function" ? children(state) : children !== void 0 ? children : defaultLabel(state);
5182
- return /* @__PURE__ */ jsx6(
4623
+ return /* @__PURE__ */ jsx5(
5183
4624
  "button",
5184
4625
  {
5185
4626
  type: "button",
@@ -5226,7 +4667,6 @@ export {
5226
4667
  DEFAULT_PLAYLIST_POLL_SLACK_MS,
5227
4668
  FileRef,
5228
4669
  Reactor,
5229
- ReactorController,
5230
4670
  ReactorProvider,
5231
4671
  ReactorView,
5232
4672
  RecordingClient,