@stinkycomputing/sesame-api-client 1.4.1-alpha.7 → 1.4.1-alpha.9

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
@@ -1,5 +1,5 @@
1
1
  // src/proto/api.js
2
- import * as $protobuf from "protobufjs/minimal";
2
+ import $protobuf from "protobufjs/minimal.js";
3
3
  var $Reader = $protobuf.Reader;
4
4
  var $Writer = $protobuf.Writer;
5
5
  var $util = $protobuf.util;
@@ -8180,7 +8180,7 @@ var sesame = $root.sesame = (() => {
8180
8180
  RecorderClip.prototype.endTimeUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8181
8181
  RecorderClip.prototype.lockedStartUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8182
8182
  RecorderClip.prototype.lockedEndUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8183
- RecorderClip.prototype.userTimeUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8183
+ RecorderClip.prototype.userTimeMs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8184
8184
  RecorderClip.create = function create(properties) {
8185
8185
  return new RecorderClip(properties);
8186
8186
  };
@@ -8227,11 +8227,11 @@ var sesame = $root.sesame = (() => {
8227
8227
  /* id 8, wireType 0 =*/
8228
8228
  64
8229
8229
  ).int64(message.lockedEndUs);
8230
- if (message.userTimeUs != null && Object.hasOwnProperty.call(message, "userTimeUs"))
8230
+ if (message.userTimeMs != null && Object.hasOwnProperty.call(message, "userTimeMs"))
8231
8231
  writer.uint32(
8232
8232
  /* id 9, wireType 0 =*/
8233
8233
  72
8234
- ).int64(message.userTimeUs);
8234
+ ).int64(message.userTimeMs);
8235
8235
  return writer;
8236
8236
  };
8237
8237
  RecorderClip.encodeDelimited = function encodeDelimited(message, writer) {
@@ -8279,7 +8279,7 @@ var sesame = $root.sesame = (() => {
8279
8279
  break;
8280
8280
  }
8281
8281
  case 9: {
8282
- message.userTimeUs = reader.int64();
8282
+ message.userTimeMs = reader.int64();
8283
8283
  break;
8284
8284
  }
8285
8285
  default:
@@ -8329,9 +8329,9 @@ var sesame = $root.sesame = (() => {
8329
8329
  if (!$util.isInteger(message.lockedEndUs) && !(message.lockedEndUs && $util.isInteger(message.lockedEndUs.low) && $util.isInteger(message.lockedEndUs.high)))
8330
8330
  return "lockedEndUs: integer|Long expected";
8331
8331
  }
8332
- if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs")) {
8333
- if (!$util.isInteger(message.userTimeUs) && !(message.userTimeUs && $util.isInteger(message.userTimeUs.low) && $util.isInteger(message.userTimeUs.high)))
8334
- return "userTimeUs: integer|Long expected";
8332
+ if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs")) {
8333
+ if (!$util.isInteger(message.userTimeMs) && !(message.userTimeMs && $util.isInteger(message.userTimeMs.low) && $util.isInteger(message.userTimeMs.high)))
8334
+ return "userTimeMs: integer|Long expected";
8335
8335
  }
8336
8336
  return null;
8337
8337
  };
@@ -8403,15 +8403,15 @@ var sesame = $root.sesame = (() => {
8403
8403
  else if (typeof object.lockedEndUs === "object")
8404
8404
  message.lockedEndUs = new $util.LongBits(object.lockedEndUs.low >>> 0, object.lockedEndUs.high >>> 0).toNumber();
8405
8405
  }
8406
- if (object.userTimeUs != null) {
8406
+ if (object.userTimeMs != null) {
8407
8407
  if ($util.Long)
8408
- (message.userTimeUs = $util.Long.fromValue(object.userTimeUs)).unsigned = false;
8409
- else if (typeof object.userTimeUs === "string")
8410
- message.userTimeUs = parseInt(object.userTimeUs, 10);
8411
- else if (typeof object.userTimeUs === "number")
8412
- message.userTimeUs = object.userTimeUs;
8413
- else if (typeof object.userTimeUs === "object")
8414
- message.userTimeUs = new $util.LongBits(object.userTimeUs.low >>> 0, object.userTimeUs.high >>> 0).toNumber();
8408
+ (message.userTimeMs = $util.Long.fromValue(object.userTimeMs)).unsigned = false;
8409
+ else if (typeof object.userTimeMs === "string")
8410
+ message.userTimeMs = parseInt(object.userTimeMs, 10);
8411
+ else if (typeof object.userTimeMs === "number")
8412
+ message.userTimeMs = object.userTimeMs;
8413
+ else if (typeof object.userTimeMs === "object")
8414
+ message.userTimeMs = new $util.LongBits(object.userTimeMs.low >>> 0, object.userTimeMs.high >>> 0).toNumber();
8415
8415
  }
8416
8416
  return message;
8417
8417
  };
@@ -8454,9 +8454,9 @@ var sesame = $root.sesame = (() => {
8454
8454
  object.lockedEndUs = options.longs === String ? "0" : 0;
8455
8455
  if ($util.Long) {
8456
8456
  let long = new $util.Long(0, 0, false);
8457
- object.userTimeUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
8457
+ object.userTimeMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
8458
8458
  } else
8459
- object.userTimeUs = options.longs === String ? "0" : 0;
8459
+ object.userTimeMs = options.longs === String ? "0" : 0;
8460
8460
  }
8461
8461
  if (message.id != null && message.hasOwnProperty("id"))
8462
8462
  if (typeof message.id === "number")
@@ -8492,11 +8492,11 @@ var sesame = $root.sesame = (() => {
8492
8492
  object.lockedEndUs = options.longs === String ? String(message.lockedEndUs) : message.lockedEndUs;
8493
8493
  else
8494
8494
  object.lockedEndUs = options.longs === String ? $util.Long.prototype.toString.call(message.lockedEndUs) : options.longs === Number ? new $util.LongBits(message.lockedEndUs.low >>> 0, message.lockedEndUs.high >>> 0).toNumber() : message.lockedEndUs;
8495
- if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs"))
8496
- if (typeof message.userTimeUs === "number")
8497
- object.userTimeUs = options.longs === String ? String(message.userTimeUs) : message.userTimeUs;
8495
+ if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs"))
8496
+ if (typeof message.userTimeMs === "number")
8497
+ object.userTimeMs = options.longs === String ? String(message.userTimeMs) : message.userTimeMs;
8498
8498
  else
8499
- object.userTimeUs = options.longs === String ? $util.Long.prototype.toString.call(message.userTimeUs) : options.longs === Number ? new $util.LongBits(message.userTimeUs.low >>> 0, message.userTimeUs.high >>> 0).toNumber() : message.userTimeUs;
8499
+ object.userTimeMs = options.longs === String ? $util.Long.prototype.toString.call(message.userTimeMs) : options.longs === Number ? new $util.LongBits(message.userTimeMs.low >>> 0, message.userTimeMs.high >>> 0).toNumber() : message.userTimeMs;
8500
8500
  return object;
8501
8501
  };
8502
8502
  RecorderClip.prototype.toJSON = function toJSON() {
@@ -20377,8 +20377,8 @@ var sesame = $root.sesame = (() => {
20377
20377
  return jobs;
20378
20378
  }();
20379
20379
  v1.rpc = function() {
20380
- const rpc2 = {};
20381
- rpc2.Message = function() {
20380
+ const rpc = {};
20381
+ rpc.Message = function() {
20382
20382
  function Message2(properties) {
20383
20383
  if (properties) {
20384
20384
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
@@ -20540,7 +20540,7 @@ var sesame = $root.sesame = (() => {
20540
20540
  };
20541
20541
  return Message2;
20542
20542
  }();
20543
- rpc2.Request = function() {
20543
+ rpc.Request = function() {
20544
20544
  function Request2(properties) {
20545
20545
  if (properties) {
20546
20546
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
@@ -20677,7 +20677,7 @@ var sesame = $root.sesame = (() => {
20677
20677
  };
20678
20678
  return Request2;
20679
20679
  }();
20680
- rpc2.Response = function() {
20680
+ rpc.Response = function() {
20681
20681
  function Response2(properties) {
20682
20682
  if (properties) {
20683
20683
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
@@ -20833,7 +20833,7 @@ var sesame = $root.sesame = (() => {
20833
20833
  };
20834
20834
  return Response2;
20835
20835
  }();
20836
- rpc2.Event = function() {
20836
+ rpc.Event = function() {
20837
20837
  function Event2(properties) {
20838
20838
  if (properties) {
20839
20839
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
@@ -20994,7 +20994,7 @@ var sesame = $root.sesame = (() => {
20994
20994
  };
20995
20995
  return Event2;
20996
20996
  }();
20997
- rpc2.SesameAPIService = function() {
20997
+ rpc.SesameAPIService = function() {
20998
20998
  function SesameAPIService(rpcImpl, requestDelimited, responseDelimited) {
20999
20999
  $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited);
21000
21000
  }
@@ -21052,7 +21052,7 @@ var sesame = $root.sesame = (() => {
21052
21052
  }, "name", { value: "RequestIODeviceList" });
21053
21053
  return SesameAPIService;
21054
21054
  }();
21055
- return rpc2;
21055
+ return rpc;
21056
21056
  }();
21057
21057
  return v1;
21058
21058
  }();
@@ -21068,7 +21068,7 @@ var CommandList = class {
21068
21068
  add(item, timeOffsetMs, transaction) {
21069
21069
  item.timeOffsetUs = (timeOffsetMs || 0) * 1e3;
21070
21070
  if (transaction) {
21071
- item.transactionDeps = (transaction == null ? void 0 : transaction.dependencies) || [];
21071
+ item.transactionDeps = transaction?.dependencies || [];
21072
21072
  item.transactionId = transaction.transactionId;
21073
21073
  }
21074
21074
  this.cl.commandList.push(item);
@@ -21105,7 +21105,7 @@ var CommandList = class {
21105
21105
  this.cl.commandList.splice(this.cl.commandList.indexOf(item.del), 1);
21106
21106
  });
21107
21107
  }
21108
- get_command_list_msg() {
21108
+ getCommandListMsg() {
21109
21109
  return this.cl;
21110
21110
  }
21111
21111
  callback(event, data, timeOffsetMs) {
@@ -21113,32 +21113,32 @@ var CommandList = class {
21113
21113
  item.callback = { event, data };
21114
21114
  return this.add(item, timeOffsetMs);
21115
21115
  }
21116
- add_compositor(id, width, height, multisample, timeOffsetMs) {
21116
+ compositorAdd(id, width, height, multisample, timeOffsetMs) {
21117
21117
  let item = new sesame.v1.commands.CommandListItem();
21118
21118
  item.addCompositor = { id, multisample, width, height };
21119
21119
  return this.add(item, timeOffsetMs);
21120
21120
  }
21121
- remove_compositor(id, timeOffsetMs) {
21121
+ compositorRemove(id, timeOffsetMs) {
21122
21122
  let item = new sesame.v1.commands.CommandListItem();
21123
21123
  item.removeCompositor = { id };
21124
21124
  return this.add(item, timeOffsetMs);
21125
21125
  }
21126
- clear_compositor(id, timeOffsetMs) {
21126
+ compositorClear(id, timeOffsetMs) {
21127
21127
  let item = new sesame.v1.commands.CommandListItem();
21128
21128
  item.clearCompositor = { id };
21129
21129
  return this.add(item, timeOffsetMs);
21130
21130
  }
21131
- add_source(id, cfg, timeOffsetMs) {
21131
+ sourceAdd(id, cfg, timeOffsetMs) {
21132
21132
  let item = new sesame.v1.commands.CommandListItem();
21133
21133
  item.addSource = { id, config: cfg };
21134
21134
  return this.add(item, timeOffsetMs);
21135
21135
  }
21136
- remove_source(id, timeOffsetMs) {
21136
+ sourceRemove(id, timeOffsetMs) {
21137
21137
  let item = new sesame.v1.commands.CommandListItem();
21138
21138
  item.removeSource = { id };
21139
21139
  return this.add(item, timeOffsetMs);
21140
21140
  }
21141
- add_node(id, cfg, timeOffsetMs) {
21141
+ nodeAdd(id, cfg, timeOffsetMs) {
21142
21142
  let item = new sesame.v1.commands.CommandListItem();
21143
21143
  item.addNode = {
21144
21144
  compositorId: cfg.compositorId,
@@ -21148,12 +21148,12 @@ var CommandList = class {
21148
21148
  };
21149
21149
  return this.add(item, timeOffsetMs);
21150
21150
  }
21151
- remove_node(compositorId, address, timeOffsetMs) {
21151
+ nodeRemove(compositorId, address, timeOffsetMs) {
21152
21152
  let item = new sesame.v1.commands.CommandListItem();
21153
21153
  item.removeNode = { compositorId, address };
21154
21154
  return this.add(item, timeOffsetMs);
21155
21155
  }
21156
- set_property(propertyDomain, addr, prop, val, timeOffsetMs) {
21156
+ propertySet(propertyDomain, addr, prop, val, timeOffsetMs) {
21157
21157
  let item = new sesame.v1.commands.CommandListItem();
21158
21158
  item.setProperty = {
21159
21159
  address: addr,
@@ -21163,7 +21163,7 @@ var CommandList = class {
21163
21163
  };
21164
21164
  return this.add(item, timeOffsetMs);
21165
21165
  }
21166
- add_load_playlist_command(sourceId, playlist) {
21166
+ playlistLoad(sourceId, playlist) {
21167
21167
  const item = new sesame.v1.commands.CommandListItem();
21168
21168
  const loadPlaylistCmd = {
21169
21169
  items: playlist.clips.map((clip) => ({
@@ -21186,13 +21186,13 @@ var CommandList = class {
21186
21186
  item.loadPlaylist = loadPlaylistCmd;
21187
21187
  return this.add(item, 0);
21188
21188
  }
21189
- add_eject_playlist_command(sourceId) {
21189
+ playlistEject(sourceId) {
21190
21190
  const item = new sesame.v1.commands.CommandListItem();
21191
21191
  const ejectPlaylistCmd = { sourceId };
21192
21192
  item.ejectPlaylist = ejectPlaylistCmd;
21193
21193
  return this.add(item, 0);
21194
21194
  }
21195
- add_transport_command(id, msg, timeOffsetMs) {
21195
+ transportCommand(id, msg, timeOffsetMs) {
21196
21196
  let item = new sesame.v1.commands.CommandListItem();
21197
21197
  let transportCmd = { sourceId: id };
21198
21198
  let cmd;
@@ -21265,17 +21265,17 @@ var CommandList = class {
21265
21265
  item.updateSourceTransport = transportCmd;
21266
21266
  return this.add(item, timeOffsetMs, { transactionId: msg.transactionId, dependencies: [] });
21267
21267
  }
21268
- update_source(id, cfg, timeOffsetMs) {
21268
+ sourceUpdate(id, cfg, timeOffsetMs) {
21269
21269
  let item = new sesame.v1.commands.CommandListItem();
21270
21270
  item.updateSource = { id, config: cfg };
21271
21271
  return this.add(item, timeOffsetMs);
21272
21272
  }
21273
- update_source_metadata(id, metadata, timeOffsetMs) {
21273
+ sourceUpdateMetadata(id, metadata, timeOffsetMs) {
21274
21274
  let item = new sesame.v1.commands.CommandListItem();
21275
21275
  item.setSourceMetadata = { sourceId: id, metadata };
21276
21276
  return this.add(item, timeOffsetMs);
21277
21277
  }
21278
- update_source_transport(id, cfg, timeOffsetMs) {
21278
+ sourceUpdateTransport(id, cfg, timeOffsetMs) {
21279
21279
  let item = new sesame.v1.commands.CommandListItem();
21280
21280
  item.updateSourceTransport = {
21281
21281
  sourceId: id,
@@ -21284,47 +21284,47 @@ var CommandList = class {
21284
21284
  };
21285
21285
  return this.add(item, timeOffsetMs);
21286
21286
  }
21287
- add_output(id, cfg, timeOffsetMs) {
21287
+ outputAdd(id, cfg, timeOffsetMs) {
21288
21288
  let item = new sesame.v1.commands.CommandListItem();
21289
21289
  item.addOutput = { id, ...cfg };
21290
21290
  return this.add(item, timeOffsetMs);
21291
21291
  }
21292
- update_output(id, cfg, timeOffsetMs) {
21292
+ outputUpdate(id, cfg, timeOffsetMs) {
21293
21293
  let item = new sesame.v1.commands.CommandListItem();
21294
21294
  item.updateOutput = { id, ...cfg };
21295
21295
  return this.add(item, timeOffsetMs);
21296
21296
  }
21297
- remove_output(id, timeOffsetMs) {
21297
+ outputRemove(id, timeOffsetMs) {
21298
21298
  let item = new sesame.v1.commands.CommandListItem();
21299
21299
  item.removeOutput = { id };
21300
21300
  return this.add(item, timeOffsetMs);
21301
21301
  }
21302
- add_audio_mixer(id, cfg, timeOffsetMs) {
21302
+ audioMixerAdd(id, cfg, timeOffsetMs) {
21303
21303
  let item = new sesame.v1.commands.CommandListItem();
21304
21304
  item.addAudioMixer = { id, config: cfg };
21305
21305
  return this.add(item, timeOffsetMs);
21306
21306
  }
21307
- update_audio_mixer(id, cfg, timeOffsetMs) {
21307
+ audioMixerUpdate(id, cfg, timeOffsetMs) {
21308
21308
  let item = new sesame.v1.commands.CommandListItem();
21309
21309
  item.updateAudioMixer = { id, config: cfg };
21310
21310
  return this.add(item, timeOffsetMs);
21311
21311
  }
21312
- add_audio_mixer_channel(mixerId, cfg, timeOffsetMs) {
21312
+ audioMixerChannelAdd(mixerId, cfg, timeOffsetMs) {
21313
21313
  let item = new sesame.v1.commands.CommandListItem();
21314
21314
  item.addAudioChannel = { mixerId, channelConfig: cfg };
21315
21315
  return this.add(item, timeOffsetMs);
21316
21316
  }
21317
- remove_audio_mixer(mixerId, timeOffsetMs) {
21317
+ audioMixerRemove(mixerId, timeOffsetMs) {
21318
21318
  let item = new sesame.v1.commands.CommandListItem();
21319
21319
  item.removeAudioMixer = { id: mixerId };
21320
21320
  return this.add(item, timeOffsetMs);
21321
21321
  }
21322
- remove_audio_mixer_channel(mixerId, channelId, timeOffsetMs) {
21322
+ audioMixerChannelRemove(mixerId, channelId, timeOffsetMs) {
21323
21323
  let item = new sesame.v1.commands.CommandListItem();
21324
21324
  item.removeAudioChannel = { mixerId, channelId };
21325
21325
  return this.add(item, timeOffsetMs);
21326
21326
  }
21327
- animate_property(propertyDomain, addr, prop, before, after, keyframes, timeOffsetMs) {
21327
+ propertyAnimate(propertyDomain, addr, prop, before, after, keyframes, timeOffsetMs) {
21328
21328
  let item = new sesame.v1.commands.CommandListItem();
21329
21329
  item.animateProperty = {
21330
21330
  address: addr,
@@ -21340,7 +21340,6 @@ var CommandList = class {
21340
21340
 
21341
21341
  // src/rpc-client.ts
21342
21342
  import { EventEmitter } from "events";
21343
- import * as WebSocket from "ws";
21344
21343
 
21345
21344
  // src/logger.ts
21346
21345
  var ConsoleLogger = class {
@@ -21519,7 +21518,6 @@ var RPCClient = class extends EventEmitter {
21519
21518
 
21520
21519
  // src/sesame-connection.ts
21521
21520
  import { EventEmitter as EventEmitter2 } from "events";
21522
- import WebSocket2 from "ws";
21523
21521
 
21524
21522
  // src/sesame-binary-protocol.ts
21525
21523
  var PROTOCOL_MAGIC = 1297302867;
@@ -21782,20 +21780,24 @@ var SesameConnection = class extends EventEmitter2 {
21782
21780
  this.numRetries = 0;
21783
21781
  this.url = "";
21784
21782
  this.autoReconnect = true;
21783
+ /* Bound listeners so we can removeEventListener later */
21784
+ this.boundMessageHandler = (event) => this.messageHandler(event);
21785
+ this.boundOpenHandler = () => this.openHandler();
21786
+ this.boundCloseHandler = () => this.closeHandler();
21787
+ this.boundErrorHandler = (event) => this.errorHandler(event);
21785
21788
  this.openHandler = () => {
21786
21789
  this.numRetries = 0;
21787
21790
  this.emit("open");
21788
21791
  };
21789
21792
  this.messageHandler = (event) => {
21790
- var _a, _b, _c;
21791
21793
  if (event.data instanceof ArrayBuffer) {
21792
21794
  const parsed = SesameBinaryProtocol.parseData(new Uint8Array(event.data));
21793
21795
  if (!parsed.valid) this.emit("error", new Error("Invalid packet received"));
21794
- if (((_a = parsed.header) == null ? void 0 : _a.type) == 1 /* VIDEO_FRAME */) {
21796
+ if (parsed.header?.type == 1 /* VIDEO_FRAME */) {
21795
21797
  this.emit("video-packet", event.data);
21796
- } else if (((_b = parsed.header) == null ? void 0 : _b.type) == 2 /* AUDIO_FRAME */) {
21798
+ } else if (parsed.header?.type == 2 /* AUDIO_FRAME */) {
21797
21799
  this.emit("audio-packet", event.data);
21798
- } else if (((_c = parsed.header) == null ? void 0 : _c.type) == 3 /* RPC */) {
21800
+ } else if (parsed.header?.type == 3 /* RPC */) {
21799
21801
  this.emit("rpc", parsed.payload);
21800
21802
  }
21801
21803
  }
@@ -21805,7 +21807,7 @@ var SesameConnection = class extends EventEmitter2 {
21805
21807
  if (options.autoConnect) this.connect().catch(() => log.debug("failed connect"));
21806
21808
  }
21807
21809
  isConnected() {
21808
- return this.socket !== void 0 && this.socket.readyState === WebSocket2.OPEN;
21810
+ return this.socket !== void 0 && this.socket.readyState === WebSocket.OPEN;
21809
21811
  }
21810
21812
  async send(data) {
21811
21813
  if (!this.isConnected()) throw new Error("Not connected");
@@ -21817,11 +21819,11 @@ var SesameConnection = class extends EventEmitter2 {
21817
21819
  }
21818
21820
  async connect() {
21819
21821
  this.active = true;
21820
- this.socket = new WebSocket2(this.url);
21821
- this.socket.addEventListener("message", (event) => this.messageHandler(event));
21822
- this.socket.addEventListener("open", () => this.openHandler());
21823
- this.socket.addEventListener("close", () => this.closeHandler());
21824
- this.socket.addEventListener("error", (error) => this.errorHandler(error));
21822
+ this.socket = new WebSocket(this.url);
21823
+ this.socket.addEventListener("message", this.boundMessageHandler);
21824
+ this.socket.addEventListener("open", this.boundOpenHandler);
21825
+ this.socket.addEventListener("close", this.boundCloseHandler);
21826
+ this.socket.addEventListener("error", this.boundErrorHandler);
21825
21827
  this.socket.binaryType = "arraybuffer";
21826
21828
  await new Promise((resolve) => {
21827
21829
  const done = () => {
@@ -21842,11 +21844,17 @@ var SesameConnection = class extends EventEmitter2 {
21842
21844
  return;
21843
21845
  }
21844
21846
  const sock = this.socket;
21845
- if (sock.readyState !== WebSocket2.CLOSED) {
21847
+ if (sock.readyState !== WebSocket.CLOSED) {
21846
21848
  sock.close();
21847
21849
  await waitForEvent(this, "close");
21848
21850
  }
21849
- sock.removeAllListeners();
21851
+ this.removeSocketListeners(sock);
21852
+ }
21853
+ removeSocketListeners(sock) {
21854
+ sock.removeEventListener("message", this.boundMessageHandler);
21855
+ sock.removeEventListener("open", this.boundOpenHandler);
21856
+ sock.removeEventListener("close", this.boundCloseHandler);
21857
+ sock.removeEventListener("error", this.boundErrorHandler);
21850
21858
  }
21851
21859
  retryHandler() {
21852
21860
  if (this.active && this.autoReconnect) {
@@ -21856,7 +21864,7 @@ var SesameConnection = class extends EventEmitter2 {
21856
21864
  closeHandler() {
21857
21865
  this.emit("close");
21858
21866
  if (this.socket) {
21859
- this.socket.removeAllListeners();
21867
+ this.removeSocketListeners(this.socket);
21860
21868
  }
21861
21869
  this.socket = void 0;
21862
21870
  if (this.active) {
@@ -21879,6 +21887,131 @@ var defaultBackoff = (tries) => {
21879
21887
 
21880
21888
  // src/sesame-api-client.ts
21881
21889
  import { EventEmitter as EventEmitter3 } from "events";
21890
+
21891
+ // src/status-api.ts
21892
+ var StatusApi = class {
21893
+ /** @internal */
21894
+ constructor(rpc) {
21895
+ this.rpc = rpc;
21896
+ }
21897
+ async getStatus() {
21898
+ return this.rpc.service.requestStatus(new sesame.v1.common.Empty());
21899
+ }
21900
+ async getIODevices() {
21901
+ return this.rpc.service.requestIODeviceList(new sesame.v1.common.Empty());
21902
+ }
21903
+ async requestKeyframe(outputId) {
21904
+ await this.rpc.service.requestKeyframe({ id: outputId });
21905
+ }
21906
+ };
21907
+
21908
+ // src/recorder-api.ts
21909
+ var RecorderApi = class {
21910
+ /** @internal */
21911
+ constructor(rpc) {
21912
+ this.rpc = rpc;
21913
+ }
21914
+ async addClip(recorderId, clip) {
21915
+ const msg = sesame.v1.recorder.RecorderClipAddRequest.create({ clip });
21916
+ await this.rpc.service.requestRecorderOperation({ recorderId, addClip: msg });
21917
+ }
21918
+ async copyClip(recorderId, clipId, newClipId) {
21919
+ const msg = sesame.v1.recorder.RecorderClipCopyRequest.create({ clipId, newClipId });
21920
+ await this.rpc.service.requestRecorderOperation({ recorderId, copyClip: msg });
21921
+ }
21922
+ async removeClip(recorderId, id) {
21923
+ const msg = sesame.v1.recorder.RecorderClipRemoveRequest.create({ clipId: id });
21924
+ await this.rpc.service.requestRecorderOperation({ recorderId, removeClip: msg });
21925
+ }
21926
+ async removeAllClips(recorderId, protect) {
21927
+ const msg = sesame.v1.recorder.RecorderClipsClearRequest.create();
21928
+ if (protect) msg.protectedRanges = protect;
21929
+ await this.rpc.service.requestRecorderOperation({ recorderId, clearClips: msg });
21930
+ }
21931
+ async verifyClips(recorderId) {
21932
+ const msg = sesame.v1.recorder.RecorderClipsVerifyRequest.create();
21933
+ const reply = await this.rpc.service.requestRecorderOperation({ recorderId, verifyClips: msg });
21934
+ return reply.verifyClipsResponse?.errors || [];
21935
+ }
21936
+ async getClips(recorderId) {
21937
+ const msg = sesame.v1.recorder.RecorderClipsGetRequest.create();
21938
+ const reply = await this.rpc.service.requestRecorderOperation({ recorderId, getClips: msg });
21939
+ if (reply.getClipsResponse?.clips) {
21940
+ return reply.getClipsResponse.clips;
21941
+ } else {
21942
+ throw new Error(`No clips returned: ${JSON.stringify(reply)}`);
21943
+ }
21944
+ }
21945
+ async setLockedDuration(frames) {
21946
+ const msg = sesame.v1.recorder.RecorderLockedDurationSetRequest.create({ frames });
21947
+ await this.rpc.service.requestRecorderOperation({ recorderId: "", setLockedDuration: msg });
21948
+ }
21949
+ async setMetadata(recorderId, metadata) {
21950
+ const msg = sesame.v1.recorder.RecorderMetadataSetRequest.create({ metadata });
21951
+ await this.rpc.service.requestRecorderOperation({ recorderId, setMetadata: msg });
21952
+ }
21953
+ };
21954
+
21955
+ // src/jobs-api.ts
21956
+ var JobsApi = class {
21957
+ /** @internal */
21958
+ constructor(rpc) {
21959
+ this.rpc = rpc;
21960
+ }
21961
+ async importClip(config) {
21962
+ const msg = sesame.v1.jobs.ImportStartRequest.create();
21963
+ msg.config = config;
21964
+ const res = await this.rpc.service.requestClipImportStart(msg);
21965
+ if (res.error) {
21966
+ throw new Error(res.error);
21967
+ }
21968
+ return res;
21969
+ }
21970
+ async getImportStatus() {
21971
+ const msg = sesame.v1.jobs.ImportListRequest.create();
21972
+ return this.rpc.service.requestClipImportList(msg);
21973
+ }
21974
+ async abortImport(jobId) {
21975
+ const msg = { jobId };
21976
+ return this.rpc.service.requestClipImportAbort(msg);
21977
+ }
21978
+ async exportPlaylist(playlist, config) {
21979
+ const msg = sesame.v1.jobs.ExportStartRequest.create();
21980
+ if (!config.filename) throw new Error("Filename is required");
21981
+ msg.config = {
21982
+ ...config,
21983
+ filename: config.filename,
21984
+ videoCodec: config.videoCodec ?? sesame.v1.common.CodecId.CODEC_ID_H264,
21985
+ videoBitrateKbps: config.videoBitrateKbps ?? 1024,
21986
+ audioCodec: config.audioCodec ?? sesame.v1.jobs.AudioCodecId.AUDIO_CODEC_ID_AAC,
21987
+ audioBitrateKbps: config.audioBitrateKbps ?? 128,
21988
+ audioChannels: config.audioChannels ?? 4,
21989
+ audioRouting: config.audioRouting ?? [0, 1, 2, 3]
21990
+ };
21991
+ msg.items = playlist.clips.map((clip) => ({
21992
+ id: clip.id,
21993
+ recorderId: clip.recorderId,
21994
+ transitionTimeUs: clip.transitionTimeUs ?? 0,
21995
+ transitionType: clip.transitionType ?? sesame.v1.recorder.TransitionType.TRANSITION_TYPE_MIX,
21996
+ transitionFadeColor: clip.transitionFadeColor ?? { x: 0, y: 0, z: 0, w: 0 },
21997
+ speed: clip.speed ?? 1,
21998
+ audioRouting: clip.audioRouting,
21999
+ startTimeUs: clip.startTimeUs,
22000
+ endTimeUs: clip.endTimeUs
22001
+ }));
22002
+ await this.rpc.service.requestPlaylistExportStart(msg);
22003
+ }
22004
+ async getExportStatus() {
22005
+ const msg = sesame.v1.jobs.ExportListRequest.create();
22006
+ return this.rpc.service.requestPlaylistExportList(msg);
22007
+ }
22008
+ async abortExport(jobId) {
22009
+ const msg = { jobId };
22010
+ return this.rpc.service.requestPlaylistExportAbort(msg);
22011
+ }
22012
+ };
22013
+
22014
+ // src/sesame-api-client.ts
21882
22015
  var EaseKind = /* @__PURE__ */ ((EaseKind2) => {
21883
22016
  EaseKind2["STEPPED"] = "stepped";
21884
22017
  EaseKind2["LINEAR"] = "linear";
@@ -21949,6 +22082,9 @@ var SesameClient = class extends EventEmitter3 {
21949
22082
  eventTypes: events
21950
22083
  };
21951
22084
  this.rpc = new RPCClient(this.conn, sesame.v1.rpc.SesameAPIService, options);
22085
+ this.status = new StatusApi(this.rpc);
22086
+ this.recorder = new RecorderApi(this.rpc);
22087
+ this.jobs = new JobsApi(this.rpc);
21952
22088
  this.rpc.on("event", (topic, msg) => {
21953
22089
  for (const subscription of this.subscriptions) {
21954
22090
  if (subscription.topic === topic) {
@@ -21960,159 +22096,56 @@ var SesameClient = class extends EventEmitter3 {
21960
22096
  log.error(`RPC error: ${err.message}`);
21961
22097
  });
21962
22098
  this.conn.on("open", async () => {
21963
- this.send_subscriptions();
22099
+ this.sendSubscriptions();
21964
22100
  this.errorIsLogged = false;
21965
22101
  this.emit("connected");
21966
22102
  });
21967
22103
  this.conn.on("close", () => {
21968
22104
  this.emit("disconnected");
21969
22105
  });
21970
- this.conn.on("video-packet", (data) => this.onVideoPacket(this.video_subscription, data));
21971
- this.conn.on("audio-packet", (data) => this.onAudioPacket(this.video_subscription, data));
22106
+ this.conn.on("video-packet", (data) => this.onVideoPacket(this.videoSubscriptionId, data));
22107
+ this.conn.on("audio-packet", (data) => this.onAudioPacket(this.videoSubscriptionId, data));
21972
22108
  this.subscriptions = [];
21973
22109
  }
21974
22110
  isConnected() {
21975
22111
  return this.conn.isConnected();
21976
22112
  }
21977
- send_subscriptions() {
22113
+ sendSubscriptions() {
21978
22114
  if (!this.isConnected()) return;
21979
22115
  const eventTopics = this.subscriptions.map((subscription) => subscription.topic);
21980
22116
  const channels = [];
21981
- if (this.video_subscription) channels.push(`video/${this.video_subscription}`);
22117
+ if (this.videoSubscriptionId) channels.push(`video/${this.videoSubscriptionId}`);
21982
22118
  let subs = { eventTopics, channels };
21983
22119
  this.rpc.service.updateSubscriptions(subs).catch((err) => {
21984
22120
  log.error(`Failed to update subscriptions: ${err.message}`);
21985
22121
  });
21986
22122
  }
21987
- async get_status() {
21988
- const status = await this.rpc.service.requestStatus(new sesame.v1.common.Empty());
21989
- return status;
21990
- }
21991
- async get_io_devices() {
21992
- const reply = await this.rpc.service.requestIODeviceList(new sesame.v1.common.Empty());
21993
- return reply;
22123
+ addVideoSubscription(id) {
22124
+ this.videoSubscriptionId = id;
22125
+ this.sendSubscriptions();
21994
22126
  }
21995
- async request_keyframe(outputId) {
21996
- await this.rpc.service.requestKeyframe({ id: outputId });
21997
- }
21998
- add_video_subscription(id) {
21999
- this.video_subscription = id;
22000
- this.send_subscriptions();
22001
- }
22002
- add_subscription(topic, callback) {
22127
+ addSubscription(topic, callback) {
22003
22128
  for (let i = 0; i < this.subscriptions.length; i++) {
22004
22129
  if (this.subscriptions[i].callback === callback && this.subscriptions[i].topic === topic) {
22005
22130
  return;
22006
22131
  }
22007
22132
  }
22008
22133
  this.subscriptions.push({ topic, callback });
22009
- this.send_subscriptions();
22134
+ this.sendSubscriptions();
22010
22135
  }
22011
- remove_subscription(topic, callback) {
22136
+ removeSubscription(topic, callback) {
22012
22137
  this.subscriptions = this.subscriptions.filter((s) => !(s.topic === topic && s.callback === callback));
22013
- this.send_subscriptions();
22138
+ this.sendSubscriptions();
22014
22139
  }
22015
22140
  getService() {
22016
22141
  return this.rpc;
22017
22142
  }
22018
22143
  async execute(cl) {
22019
22144
  cl.filterCreatedAndDestroyedSources();
22020
- if (cl.get_command_list_msg().commandList.length > 0) {
22021
- await this.rpc.service.executeCommandList(cl.get_command_list_msg());
22022
- }
22023
- }
22024
- async addClip(recorderId, clip) {
22025
- const msg = sesame.v1.recorder.RecorderClipAddRequest.create({ clip });
22026
- await this.rpc.service.requestRecorderOperation({ recorderId, addClip: msg });
22027
- }
22028
- async copyClip(recorderId, clipId, newClipId) {
22029
- const msg = sesame.v1.recorder.RecorderClipCopyRequest.create({ clipId, newClipId });
22030
- await this.rpc.service.requestRecorderOperation({ recorderId, copyClip: msg });
22031
- }
22032
- async removeClip(recorderId, id) {
22033
- const msg = sesame.v1.recorder.RecorderClipRemoveRequest.create({ clipId: id });
22034
- await this.rpc.service.requestRecorderOperation({ recorderId, removeClip: msg });
22035
- }
22036
- async removeAllClips(recorderId, protect) {
22037
- const msg = sesame.v1.recorder.RecorderClipsClearRequest.create();
22038
- if (protect) msg.protectedRanges = protect;
22039
- await this.rpc.service.requestRecorderOperation({ recorderId, clearClips: msg });
22040
- }
22041
- async verifyClips(recorderId) {
22042
- var _a;
22043
- const msg = sesame.v1.recorder.RecorderClipsVerifyRequest.create();
22044
- const reply = await this.rpc.service.requestRecorderOperation({ recorderId, verifyClips: msg });
22045
- return ((_a = reply.verifyClipsResponse) == null ? void 0 : _a.errors) || [];
22046
- }
22047
- async setLockedDuration(frames) {
22048
- const msg = sesame.v1.recorder.RecorderLockedDurationSetRequest.create({ frames });
22049
- await this.rpc.service.requestRecorderOperation({ recorderId: "", setLockedDuration: msg });
22050
- }
22051
- async setMetadata(recorderId, metadata) {
22052
- const msg = sesame.v1.recorder.RecorderMetadataSetRequest.create({ metadata });
22053
- await this.rpc.service.requestRecorderOperation({ recorderId, setMetadata: msg });
22054
- }
22055
- async getClips(recorderId) {
22056
- const msg = sesame.v1.recorder.RecorderClipsGetRequest.create();
22057
- const reply = await this.rpc.service.requestRecorderOperation({ recorderId, getClips: msg });
22058
- if (reply.getClipsResponse && reply.getClipsResponse.clips) {
22059
- return reply.getClipsResponse.clips;
22060
- } else {
22061
- throw new Error(`No clips returned: ${JSON.stringify(reply)}`);
22145
+ if (cl.getCommandListMsg().commandList.length > 0) {
22146
+ await this.rpc.service.executeCommandList(cl.getCommandListMsg());
22062
22147
  }
22063
22148
  }
22064
- async getImportClipStatus() {
22065
- const msg = sesame.v1.jobs.ImportListRequest.create();
22066
- return await this.rpc.service.requestClipImportList(msg);
22067
- }
22068
- async getExportPlaylistStatus() {
22069
- const msg = sesame.v1.jobs.ExportListRequest.create();
22070
- return await this.rpc.service.requestPlaylistExportList(msg);
22071
- }
22072
- async exportPlaylist(playlist, config) {
22073
- const msg = sesame.v1.jobs.ExportStartRequest.create();
22074
- if (!config.filename) throw new Error("Filename is required");
22075
- msg.config = {
22076
- ...config,
22077
- filename: config.filename,
22078
- videoCodec: config.videoCodec ?? sesame.v1.common.CodecId.CODEC_ID_H264,
22079
- videoBitrateKbps: config.videoBitrateKbps ?? 1024,
22080
- audioCodec: config.audioCodec ?? sesame.v1.jobs.AudioCodecId.AUDIO_CODEC_ID_AAC,
22081
- audioBitrateKbps: config.audioBitrateKbps ?? 128,
22082
- audioChannels: config.audioChannels ?? 4,
22083
- audioRouting: config.audioRouting ?? [0, 1, 2, 3]
22084
- };
22085
- msg.items = playlist.clips.map((clip) => ({
22086
- id: clip.id,
22087
- recorderId: clip.recorderId,
22088
- transitionTimeUs: clip.transitionTimeUs ?? 0,
22089
- transitionType: clip.transitionType ?? sesame.v1.recorder.TransitionType.TRANSITION_TYPE_MIX,
22090
- transitionFadeColor: clip.transitionFadeColor ?? { x: 0, y: 0, z: 0, w: 0 },
22091
- speed: clip.speed ?? 1,
22092
- audioRouting: clip.audioRouting,
22093
- startTimeUs: clip.startTimeUs,
22094
- endTimeUs: clip.endTimeUs
22095
- }));
22096
- await this.rpc.service.requestPlaylistExportStart(msg);
22097
- }
22098
- async importClip(config) {
22099
- const msg = sesame.v1.jobs.ImportStartRequest.create();
22100
- msg.config = config;
22101
- const res = await this.rpc.service.requestClipImportStart(msg);
22102
- if (res.error) {
22103
- throw new Error(res.error);
22104
- } else {
22105
- return res;
22106
- }
22107
- }
22108
- async abortExportJob(jobId) {
22109
- const msg = { jobId };
22110
- return this.rpc.service.requestPlaylistExportAbort(msg);
22111
- }
22112
- async abortImportJob(jobId) {
22113
- const msg = { jobId };
22114
- return this.rpc.service.requestClipImportAbort(msg);
22115
- }
22116
22149
  disconnect() {
22117
22150
  this.conn.disconnect();
22118
22151
  }
@@ -22128,14 +22161,17 @@ export {
22128
22161
  CommandList,
22129
22162
  EaseKind,
22130
22163
  Event,
22164
+ JobsApi,
22131
22165
  Message,
22132
22166
  PacketType,
22133
22167
  RPCClient,
22168
+ RecorderApi,
22134
22169
  Request,
22135
22170
  Response,
22136
22171
  SesameBinaryProtocol,
22137
22172
  SesameClient,
22138
22173
  SesameConnection,
22174
+ StatusApi,
22139
22175
  getLogger,
22140
22176
  log,
22141
22177
  sesame,