@stinkycomputing/sesame-api-client 1.4.1-beta.6 → 1.4.1-beta.7

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.cjs CHANGED
@@ -8236,7 +8236,7 @@ var sesame = $root.sesame = (() => {
8236
8236
  RecorderClip.prototype.endTimeUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8237
8237
  RecorderClip.prototype.lockedStartUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8238
8238
  RecorderClip.prototype.lockedEndUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8239
- RecorderClip.prototype.userTimeMs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8239
+ RecorderClip.prototype.userTimeUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8240
8240
  RecorderClip.create = function create(properties) {
8241
8241
  return new RecorderClip(properties);
8242
8242
  };
@@ -8283,11 +8283,11 @@ var sesame = $root.sesame = (() => {
8283
8283
  /* id 8, wireType 0 =*/
8284
8284
  64
8285
8285
  ).int64(message.lockedEndUs);
8286
- if (message.userTimeMs != null && Object.hasOwnProperty.call(message, "userTimeMs"))
8286
+ if (message.userTimeUs != null && Object.hasOwnProperty.call(message, "userTimeUs"))
8287
8287
  writer.uint32(
8288
8288
  /* id 9, wireType 0 =*/
8289
8289
  72
8290
- ).int64(message.userTimeMs);
8290
+ ).int64(message.userTimeUs);
8291
8291
  return writer;
8292
8292
  };
8293
8293
  RecorderClip.encodeDelimited = function encodeDelimited(message, writer) {
@@ -8335,7 +8335,7 @@ var sesame = $root.sesame = (() => {
8335
8335
  break;
8336
8336
  }
8337
8337
  case 9: {
8338
- message.userTimeMs = reader.int64();
8338
+ message.userTimeUs = reader.int64();
8339
8339
  break;
8340
8340
  }
8341
8341
  default:
@@ -8385,9 +8385,9 @@ var sesame = $root.sesame = (() => {
8385
8385
  if (!$util.isInteger(message.lockedEndUs) && !(message.lockedEndUs && $util.isInteger(message.lockedEndUs.low) && $util.isInteger(message.lockedEndUs.high)))
8386
8386
  return "lockedEndUs: integer|Long expected";
8387
8387
  }
8388
- if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs")) {
8389
- if (!$util.isInteger(message.userTimeMs) && !(message.userTimeMs && $util.isInteger(message.userTimeMs.low) && $util.isInteger(message.userTimeMs.high)))
8390
- return "userTimeMs: integer|Long expected";
8388
+ if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs")) {
8389
+ if (!$util.isInteger(message.userTimeUs) && !(message.userTimeUs && $util.isInteger(message.userTimeUs.low) && $util.isInteger(message.userTimeUs.high)))
8390
+ return "userTimeUs: integer|Long expected";
8391
8391
  }
8392
8392
  return null;
8393
8393
  };
@@ -8459,15 +8459,15 @@ var sesame = $root.sesame = (() => {
8459
8459
  else if (typeof object.lockedEndUs === "object")
8460
8460
  message.lockedEndUs = new $util.LongBits(object.lockedEndUs.low >>> 0, object.lockedEndUs.high >>> 0).toNumber();
8461
8461
  }
8462
- if (object.userTimeMs != null) {
8462
+ if (object.userTimeUs != null) {
8463
8463
  if ($util.Long)
8464
- (message.userTimeMs = $util.Long.fromValue(object.userTimeMs)).unsigned = false;
8465
- else if (typeof object.userTimeMs === "string")
8466
- message.userTimeMs = parseInt(object.userTimeMs, 10);
8467
- else if (typeof object.userTimeMs === "number")
8468
- message.userTimeMs = object.userTimeMs;
8469
- else if (typeof object.userTimeMs === "object")
8470
- message.userTimeMs = new $util.LongBits(object.userTimeMs.low >>> 0, object.userTimeMs.high >>> 0).toNumber();
8464
+ (message.userTimeUs = $util.Long.fromValue(object.userTimeUs)).unsigned = false;
8465
+ else if (typeof object.userTimeUs === "string")
8466
+ message.userTimeUs = parseInt(object.userTimeUs, 10);
8467
+ else if (typeof object.userTimeUs === "number")
8468
+ message.userTimeUs = object.userTimeUs;
8469
+ else if (typeof object.userTimeUs === "object")
8470
+ message.userTimeUs = new $util.LongBits(object.userTimeUs.low >>> 0, object.userTimeUs.high >>> 0).toNumber();
8471
8471
  }
8472
8472
  return message;
8473
8473
  };
@@ -8510,9 +8510,9 @@ var sesame = $root.sesame = (() => {
8510
8510
  object.lockedEndUs = options.longs === String ? "0" : 0;
8511
8511
  if ($util.Long) {
8512
8512
  let long = new $util.Long(0, 0, false);
8513
- object.userTimeMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
8513
+ object.userTimeUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
8514
8514
  } else
8515
- object.userTimeMs = options.longs === String ? "0" : 0;
8515
+ object.userTimeUs = options.longs === String ? "0" : 0;
8516
8516
  }
8517
8517
  if (message.id != null && message.hasOwnProperty("id"))
8518
8518
  if (typeof message.id === "number")
@@ -8548,11 +8548,11 @@ var sesame = $root.sesame = (() => {
8548
8548
  object.lockedEndUs = options.longs === String ? String(message.lockedEndUs) : message.lockedEndUs;
8549
8549
  else
8550
8550
  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;
8551
- if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs"))
8552
- if (typeof message.userTimeMs === "number")
8553
- object.userTimeMs = options.longs === String ? String(message.userTimeMs) : message.userTimeMs;
8551
+ if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs"))
8552
+ if (typeof message.userTimeUs === "number")
8553
+ object.userTimeUs = options.longs === String ? String(message.userTimeUs) : message.userTimeUs;
8554
8554
  else
8555
- 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;
8555
+ 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;
8556
8556
  return object;
8557
8557
  };
8558
8558
  RecorderClip.prototype.toJSON = function toJSON() {
@@ -13365,7 +13365,7 @@ var sesame = $root.sesame = (() => {
13365
13365
  TransportEvent.prototype.durationUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13366
13366
  TransportEvent.prototype.positionUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13367
13367
  TransportEvent.prototype.materialPositionUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13368
- TransportEvent.prototype.userTimeMs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13368
+ TransportEvent.prototype.userTimeUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13369
13369
  TransportEvent.prototype.speed = 0;
13370
13370
  TransportEvent.prototype.userPlaylistId = "";
13371
13371
  TransportEvent.prototype.playlistIndex = 0;
@@ -13417,11 +13417,11 @@ var sesame = $root.sesame = (() => {
13417
13417
  /* id 7, wireType 0 =*/
13418
13418
  56
13419
13419
  ).int64(message.materialPositionUs);
13420
- if (message.userTimeMs != null && Object.hasOwnProperty.call(message, "userTimeMs"))
13420
+ if (message.userTimeUs != null && Object.hasOwnProperty.call(message, "userTimeUs"))
13421
13421
  writer.uint32(
13422
13422
  /* id 8, wireType 0 =*/
13423
13423
  64
13424
- ).int64(message.userTimeMs);
13424
+ ).int64(message.userTimeUs);
13425
13425
  if (message.speed != null && Object.hasOwnProperty.call(message, "speed"))
13426
13426
  writer.uint32(
13427
13427
  /* id 9, wireType 5 =*/
@@ -13515,7 +13515,7 @@ var sesame = $root.sesame = (() => {
13515
13515
  break;
13516
13516
  }
13517
13517
  case 8: {
13518
- message.userTimeMs = reader.int64();
13518
+ message.userTimeUs = reader.int64();
13519
13519
  break;
13520
13520
  }
13521
13521
  case 9: {
@@ -13608,9 +13608,9 @@ var sesame = $root.sesame = (() => {
13608
13608
  if (!$util.isInteger(message.materialPositionUs) && !(message.materialPositionUs && $util.isInteger(message.materialPositionUs.low) && $util.isInteger(message.materialPositionUs.high)))
13609
13609
  return "materialPositionUs: integer|Long expected";
13610
13610
  }
13611
- if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs")) {
13612
- if (!$util.isInteger(message.userTimeMs) && !(message.userTimeMs && $util.isInteger(message.userTimeMs.low) && $util.isInteger(message.userTimeMs.high)))
13613
- return "userTimeMs: integer|Long expected";
13611
+ if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs")) {
13612
+ if (!$util.isInteger(message.userTimeUs) && !(message.userTimeUs && $util.isInteger(message.userTimeUs.low) && $util.isInteger(message.userTimeUs.high)))
13613
+ return "userTimeUs: integer|Long expected";
13614
13614
  }
13615
13615
  if (message.speed != null && message.hasOwnProperty("speed")) {
13616
13616
  if (typeof message.speed !== "number")
@@ -13722,15 +13722,15 @@ var sesame = $root.sesame = (() => {
13722
13722
  else if (typeof object.materialPositionUs === "object")
13723
13723
  message.materialPositionUs = new $util.LongBits(object.materialPositionUs.low >>> 0, object.materialPositionUs.high >>> 0).toNumber();
13724
13724
  }
13725
- if (object.userTimeMs != null) {
13725
+ if (object.userTimeUs != null) {
13726
13726
  if ($util.Long)
13727
- (message.userTimeMs = $util.Long.fromValue(object.userTimeMs)).unsigned = false;
13728
- else if (typeof object.userTimeMs === "string")
13729
- message.userTimeMs = parseInt(object.userTimeMs, 10);
13730
- else if (typeof object.userTimeMs === "number")
13731
- message.userTimeMs = object.userTimeMs;
13732
- else if (typeof object.userTimeMs === "object")
13733
- message.userTimeMs = new $util.LongBits(object.userTimeMs.low >>> 0, object.userTimeMs.high >>> 0).toNumber();
13727
+ (message.userTimeUs = $util.Long.fromValue(object.userTimeUs)).unsigned = false;
13728
+ else if (typeof object.userTimeUs === "string")
13729
+ message.userTimeUs = parseInt(object.userTimeUs, 10);
13730
+ else if (typeof object.userTimeUs === "number")
13731
+ message.userTimeUs = object.userTimeUs;
13732
+ else if (typeof object.userTimeUs === "object")
13733
+ message.userTimeUs = new $util.LongBits(object.userTimeUs.low >>> 0, object.userTimeUs.high >>> 0).toNumber();
13734
13734
  }
13735
13735
  if (object.speed != null)
13736
13736
  message.speed = Number(object.speed);
@@ -13804,9 +13804,9 @@ var sesame = $root.sesame = (() => {
13804
13804
  object.materialPositionUs = options.longs === String ? "0" : 0;
13805
13805
  if ($util.Long) {
13806
13806
  let long = new $util.Long(0, 0, false);
13807
- object.userTimeMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13807
+ object.userTimeUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13808
13808
  } else
13809
- object.userTimeMs = options.longs === String ? "0" : 0;
13809
+ object.userTimeUs = options.longs === String ? "0" : 0;
13810
13810
  object.speed = 0;
13811
13811
  object.userPlaylistId = "";
13812
13812
  object.playlistIndex = 0;
@@ -13853,11 +13853,11 @@ var sesame = $root.sesame = (() => {
13853
13853
  object.materialPositionUs = options.longs === String ? String(message.materialPositionUs) : message.materialPositionUs;
13854
13854
  else
13855
13855
  object.materialPositionUs = options.longs === String ? $util.Long.prototype.toString.call(message.materialPositionUs) : options.longs === Number ? new $util.LongBits(message.materialPositionUs.low >>> 0, message.materialPositionUs.high >>> 0).toNumber() : message.materialPositionUs;
13856
- if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs"))
13857
- if (typeof message.userTimeMs === "number")
13858
- object.userTimeMs = options.longs === String ? String(message.userTimeMs) : message.userTimeMs;
13856
+ if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs"))
13857
+ if (typeof message.userTimeUs === "number")
13858
+ object.userTimeUs = options.longs === String ? String(message.userTimeUs) : message.userTimeUs;
13859
13859
  else
13860
- 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;
13860
+ 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;
13861
13861
  if (message.speed != null && message.hasOwnProperty("speed"))
13862
13862
  object.speed = options.json && !isFinite(message.speed) ? String(message.speed) : message.speed;
13863
13863
  if (message.userPlaylistId != null && message.hasOwnProperty("userPlaylistId"))
@@ -21979,8 +21979,8 @@ var RPCClient = class extends import_events.EventEmitter {
21979
21979
  } else {
21980
21980
  throw new Error("Unsupported RPC message payload");
21981
21981
  }
21982
- } catch (cause) {
21983
- const error = new Error("got invalid message");
21982
+ } catch (err) {
21983
+ const error = new Error(`Got invalid message: ${err instanceof Error ? err.message : String(err)}`);
21984
21984
  this.errorHandler(error);
21985
21985
  }
21986
21986
  };
@@ -22055,8 +22055,8 @@ var RPCClient = class extends import_events.EventEmitter {
22055
22055
  try {
22056
22056
  payload = type.decode(event.payload);
22057
22057
  object = type.toObject(payload, { longs: Number });
22058
- } catch (cause) {
22059
- const error = new Error("could not decode event payload");
22058
+ } catch (err) {
22059
+ const error = new Error(`Could not decode event payload: ${err instanceof Error ? err.message : String(err)}`);
22060
22060
  this.errorHandler(error);
22061
22061
  return;
22062
22062
  }
@@ -22211,14 +22211,29 @@ var SesameConnection = class extends import_events2.EventEmitter {
22211
22211
  this.socket.addEventListener("close", this.boundCloseHandler);
22212
22212
  this.socket.addEventListener("error", this.boundErrorHandler);
22213
22213
  this.socket.binaryType = "arraybuffer";
22214
- await new Promise((resolve) => {
22215
- const done = () => {
22216
- this.removeListener("open", done);
22217
- this.removeListener("close", done);
22218
- resolve(null);
22214
+ await new Promise((resolve, reject) => {
22215
+ const cleanup = () => {
22216
+ this.removeListener("open", onOpen);
22217
+ this.removeListener("close", onClose);
22218
+ this.removeListener("error", onError);
22219
22219
  };
22220
- this.on("open", done);
22221
- this.on("close", done);
22220
+ const onOpen = () => {
22221
+ cleanup();
22222
+ resolve();
22223
+ };
22224
+ const onError = (err) => {
22225
+ cleanup();
22226
+ reject(err instanceof Error ? err : new Error("WebSocket connection error"));
22227
+ };
22228
+ const onClose = () => {
22229
+ if (!this.isConnected()) {
22230
+ cleanup();
22231
+ reject(new Error("WebSocket connection closed before opening"));
22232
+ }
22233
+ };
22234
+ this.on("open", onOpen);
22235
+ this.on("close", onClose);
22236
+ this.on("error", onError);
22222
22237
  });
22223
22238
  }
22224
22239
  /**
@@ -22362,7 +22377,6 @@ var JobsApi = class {
22362
22377
  if (!config.filename) throw new Error("Filename is required");
22363
22378
  exportReq.config = {
22364
22379
  ...config,
22365
- filename: config.filename,
22366
22380
  videoCodec: config.videoCodec ?? sesame.v1.common.CodecId.CODEC_ID_H264,
22367
22381
  videoBitrateKbps: config.videoBitrateKbps ?? 1024,
22368
22382
  audioCodec: config.audioCodec ?? sesame.v1.jobs.AudioCodecId.AUDIO_CODEC_ID_AAC,
@@ -22371,18 +22385,18 @@ var JobsApi = class {
22371
22385
  audioRouting: config.audioRouting ?? [0, 1, 2, 3]
22372
22386
  };
22373
22387
  exportReq.items = playlist.clips.map((clip) => ({
22374
- id: clip.id,
22375
- recorderId: clip.recorderId,
22388
+ ...clip,
22376
22389
  transitionTimeUs: clip.transitionTimeUs ?? 0,
22377
22390
  transitionType: clip.transitionType ?? sesame.v1.recorder.TransitionType.TRANSITION_TYPE_MIX,
22378
22391
  transitionFadeColor: clip.transitionFadeColor ?? { x: 0, y: 0, z: 0, w: 0 },
22379
- speed: clip.speed ?? 1,
22380
- audioRouting: clip.audioRouting,
22381
- startTimeUs: clip.startTimeUs,
22382
- endTimeUs: clip.endTimeUs
22392
+ speed: clip.speed ?? 1
22383
22393
  }));
22384
22394
  const msg = sesame.v1.jobs.JobStartRequest.create({ exportRequest: exportReq });
22385
- await this.rpc.service.startJob(msg);
22395
+ const job = await this.rpc.service.startJob(msg);
22396
+ if (job.error) {
22397
+ throw new Error(job.error);
22398
+ }
22399
+ return job;
22386
22400
  }
22387
22401
  async abortJob(jobId) {
22388
22402
  const msg = { jobId };