@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.mjs CHANGED
@@ -8179,7 +8179,7 @@ var sesame = $root.sesame = (() => {
8179
8179
  RecorderClip.prototype.endTimeUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8180
8180
  RecorderClip.prototype.lockedStartUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8181
8181
  RecorderClip.prototype.lockedEndUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8182
- RecorderClip.prototype.userTimeMs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8182
+ RecorderClip.prototype.userTimeUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8183
8183
  RecorderClip.create = function create(properties) {
8184
8184
  return new RecorderClip(properties);
8185
8185
  };
@@ -8226,11 +8226,11 @@ var sesame = $root.sesame = (() => {
8226
8226
  /* id 8, wireType 0 =*/
8227
8227
  64
8228
8228
  ).int64(message.lockedEndUs);
8229
- if (message.userTimeMs != null && Object.hasOwnProperty.call(message, "userTimeMs"))
8229
+ if (message.userTimeUs != null && Object.hasOwnProperty.call(message, "userTimeUs"))
8230
8230
  writer.uint32(
8231
8231
  /* id 9, wireType 0 =*/
8232
8232
  72
8233
- ).int64(message.userTimeMs);
8233
+ ).int64(message.userTimeUs);
8234
8234
  return writer;
8235
8235
  };
8236
8236
  RecorderClip.encodeDelimited = function encodeDelimited(message, writer) {
@@ -8278,7 +8278,7 @@ var sesame = $root.sesame = (() => {
8278
8278
  break;
8279
8279
  }
8280
8280
  case 9: {
8281
- message.userTimeMs = reader.int64();
8281
+ message.userTimeUs = reader.int64();
8282
8282
  break;
8283
8283
  }
8284
8284
  default:
@@ -8328,9 +8328,9 @@ var sesame = $root.sesame = (() => {
8328
8328
  if (!$util.isInteger(message.lockedEndUs) && !(message.lockedEndUs && $util.isInteger(message.lockedEndUs.low) && $util.isInteger(message.lockedEndUs.high)))
8329
8329
  return "lockedEndUs: integer|Long expected";
8330
8330
  }
8331
- if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs")) {
8332
- if (!$util.isInteger(message.userTimeMs) && !(message.userTimeMs && $util.isInteger(message.userTimeMs.low) && $util.isInteger(message.userTimeMs.high)))
8333
- return "userTimeMs: integer|Long expected";
8331
+ if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs")) {
8332
+ if (!$util.isInteger(message.userTimeUs) && !(message.userTimeUs && $util.isInteger(message.userTimeUs.low) && $util.isInteger(message.userTimeUs.high)))
8333
+ return "userTimeUs: integer|Long expected";
8334
8334
  }
8335
8335
  return null;
8336
8336
  };
@@ -8402,15 +8402,15 @@ var sesame = $root.sesame = (() => {
8402
8402
  else if (typeof object.lockedEndUs === "object")
8403
8403
  message.lockedEndUs = new $util.LongBits(object.lockedEndUs.low >>> 0, object.lockedEndUs.high >>> 0).toNumber();
8404
8404
  }
8405
- if (object.userTimeMs != null) {
8405
+ if (object.userTimeUs != null) {
8406
8406
  if ($util.Long)
8407
- (message.userTimeMs = $util.Long.fromValue(object.userTimeMs)).unsigned = false;
8408
- else if (typeof object.userTimeMs === "string")
8409
- message.userTimeMs = parseInt(object.userTimeMs, 10);
8410
- else if (typeof object.userTimeMs === "number")
8411
- message.userTimeMs = object.userTimeMs;
8412
- else if (typeof object.userTimeMs === "object")
8413
- message.userTimeMs = new $util.LongBits(object.userTimeMs.low >>> 0, object.userTimeMs.high >>> 0).toNumber();
8407
+ (message.userTimeUs = $util.Long.fromValue(object.userTimeUs)).unsigned = false;
8408
+ else if (typeof object.userTimeUs === "string")
8409
+ message.userTimeUs = parseInt(object.userTimeUs, 10);
8410
+ else if (typeof object.userTimeUs === "number")
8411
+ message.userTimeUs = object.userTimeUs;
8412
+ else if (typeof object.userTimeUs === "object")
8413
+ message.userTimeUs = new $util.LongBits(object.userTimeUs.low >>> 0, object.userTimeUs.high >>> 0).toNumber();
8414
8414
  }
8415
8415
  return message;
8416
8416
  };
@@ -8453,9 +8453,9 @@ var sesame = $root.sesame = (() => {
8453
8453
  object.lockedEndUs = options.longs === String ? "0" : 0;
8454
8454
  if ($util.Long) {
8455
8455
  let long = new $util.Long(0, 0, false);
8456
- object.userTimeMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
8456
+ object.userTimeUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
8457
8457
  } else
8458
- object.userTimeMs = options.longs === String ? "0" : 0;
8458
+ object.userTimeUs = options.longs === String ? "0" : 0;
8459
8459
  }
8460
8460
  if (message.id != null && message.hasOwnProperty("id"))
8461
8461
  if (typeof message.id === "number")
@@ -8491,11 +8491,11 @@ var sesame = $root.sesame = (() => {
8491
8491
  object.lockedEndUs = options.longs === String ? String(message.lockedEndUs) : message.lockedEndUs;
8492
8492
  else
8493
8493
  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;
8494
- if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs"))
8495
- if (typeof message.userTimeMs === "number")
8496
- object.userTimeMs = options.longs === String ? String(message.userTimeMs) : message.userTimeMs;
8494
+ if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs"))
8495
+ if (typeof message.userTimeUs === "number")
8496
+ object.userTimeUs = options.longs === String ? String(message.userTimeUs) : message.userTimeUs;
8497
8497
  else
8498
- 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;
8498
+ 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
8499
  return object;
8500
8500
  };
8501
8501
  RecorderClip.prototype.toJSON = function toJSON() {
@@ -13308,7 +13308,7 @@ var sesame = $root.sesame = (() => {
13308
13308
  TransportEvent.prototype.durationUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13309
13309
  TransportEvent.prototype.positionUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13310
13310
  TransportEvent.prototype.materialPositionUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13311
- TransportEvent.prototype.userTimeMs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13311
+ TransportEvent.prototype.userTimeUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13312
13312
  TransportEvent.prototype.speed = 0;
13313
13313
  TransportEvent.prototype.userPlaylistId = "";
13314
13314
  TransportEvent.prototype.playlistIndex = 0;
@@ -13360,11 +13360,11 @@ var sesame = $root.sesame = (() => {
13360
13360
  /* id 7, wireType 0 =*/
13361
13361
  56
13362
13362
  ).int64(message.materialPositionUs);
13363
- if (message.userTimeMs != null && Object.hasOwnProperty.call(message, "userTimeMs"))
13363
+ if (message.userTimeUs != null && Object.hasOwnProperty.call(message, "userTimeUs"))
13364
13364
  writer.uint32(
13365
13365
  /* id 8, wireType 0 =*/
13366
13366
  64
13367
- ).int64(message.userTimeMs);
13367
+ ).int64(message.userTimeUs);
13368
13368
  if (message.speed != null && Object.hasOwnProperty.call(message, "speed"))
13369
13369
  writer.uint32(
13370
13370
  /* id 9, wireType 5 =*/
@@ -13458,7 +13458,7 @@ var sesame = $root.sesame = (() => {
13458
13458
  break;
13459
13459
  }
13460
13460
  case 8: {
13461
- message.userTimeMs = reader.int64();
13461
+ message.userTimeUs = reader.int64();
13462
13462
  break;
13463
13463
  }
13464
13464
  case 9: {
@@ -13551,9 +13551,9 @@ var sesame = $root.sesame = (() => {
13551
13551
  if (!$util.isInteger(message.materialPositionUs) && !(message.materialPositionUs && $util.isInteger(message.materialPositionUs.low) && $util.isInteger(message.materialPositionUs.high)))
13552
13552
  return "materialPositionUs: integer|Long expected";
13553
13553
  }
13554
- if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs")) {
13555
- if (!$util.isInteger(message.userTimeMs) && !(message.userTimeMs && $util.isInteger(message.userTimeMs.low) && $util.isInteger(message.userTimeMs.high)))
13556
- return "userTimeMs: integer|Long expected";
13554
+ if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs")) {
13555
+ if (!$util.isInteger(message.userTimeUs) && !(message.userTimeUs && $util.isInteger(message.userTimeUs.low) && $util.isInteger(message.userTimeUs.high)))
13556
+ return "userTimeUs: integer|Long expected";
13557
13557
  }
13558
13558
  if (message.speed != null && message.hasOwnProperty("speed")) {
13559
13559
  if (typeof message.speed !== "number")
@@ -13665,15 +13665,15 @@ var sesame = $root.sesame = (() => {
13665
13665
  else if (typeof object.materialPositionUs === "object")
13666
13666
  message.materialPositionUs = new $util.LongBits(object.materialPositionUs.low >>> 0, object.materialPositionUs.high >>> 0).toNumber();
13667
13667
  }
13668
- if (object.userTimeMs != null) {
13668
+ if (object.userTimeUs != null) {
13669
13669
  if ($util.Long)
13670
- (message.userTimeMs = $util.Long.fromValue(object.userTimeMs)).unsigned = false;
13671
- else if (typeof object.userTimeMs === "string")
13672
- message.userTimeMs = parseInt(object.userTimeMs, 10);
13673
- else if (typeof object.userTimeMs === "number")
13674
- message.userTimeMs = object.userTimeMs;
13675
- else if (typeof object.userTimeMs === "object")
13676
- message.userTimeMs = new $util.LongBits(object.userTimeMs.low >>> 0, object.userTimeMs.high >>> 0).toNumber();
13670
+ (message.userTimeUs = $util.Long.fromValue(object.userTimeUs)).unsigned = false;
13671
+ else if (typeof object.userTimeUs === "string")
13672
+ message.userTimeUs = parseInt(object.userTimeUs, 10);
13673
+ else if (typeof object.userTimeUs === "number")
13674
+ message.userTimeUs = object.userTimeUs;
13675
+ else if (typeof object.userTimeUs === "object")
13676
+ message.userTimeUs = new $util.LongBits(object.userTimeUs.low >>> 0, object.userTimeUs.high >>> 0).toNumber();
13677
13677
  }
13678
13678
  if (object.speed != null)
13679
13679
  message.speed = Number(object.speed);
@@ -13747,9 +13747,9 @@ var sesame = $root.sesame = (() => {
13747
13747
  object.materialPositionUs = options.longs === String ? "0" : 0;
13748
13748
  if ($util.Long) {
13749
13749
  let long = new $util.Long(0, 0, false);
13750
- object.userTimeMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13750
+ object.userTimeUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13751
13751
  } else
13752
- object.userTimeMs = options.longs === String ? "0" : 0;
13752
+ object.userTimeUs = options.longs === String ? "0" : 0;
13753
13753
  object.speed = 0;
13754
13754
  object.userPlaylistId = "";
13755
13755
  object.playlistIndex = 0;
@@ -13796,11 +13796,11 @@ var sesame = $root.sesame = (() => {
13796
13796
  object.materialPositionUs = options.longs === String ? String(message.materialPositionUs) : message.materialPositionUs;
13797
13797
  else
13798
13798
  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;
13799
- if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs"))
13800
- if (typeof message.userTimeMs === "number")
13801
- object.userTimeMs = options.longs === String ? String(message.userTimeMs) : message.userTimeMs;
13799
+ if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs"))
13800
+ if (typeof message.userTimeUs === "number")
13801
+ object.userTimeUs = options.longs === String ? String(message.userTimeUs) : message.userTimeUs;
13802
13802
  else
13803
- 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;
13803
+ 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;
13804
13804
  if (message.speed != null && message.hasOwnProperty("speed"))
13805
13805
  object.speed = options.json && !isFinite(message.speed) ? String(message.speed) : message.speed;
13806
13806
  if (message.userPlaylistId != null && message.hasOwnProperty("userPlaylistId"))
@@ -21922,8 +21922,8 @@ var RPCClient = class extends EventEmitter {
21922
21922
  } else {
21923
21923
  throw new Error("Unsupported RPC message payload");
21924
21924
  }
21925
- } catch (cause) {
21926
- const error = new Error("got invalid message");
21925
+ } catch (err) {
21926
+ const error = new Error(`Got invalid message: ${err instanceof Error ? err.message : String(err)}`);
21927
21927
  this.errorHandler(error);
21928
21928
  }
21929
21929
  };
@@ -21998,8 +21998,8 @@ var RPCClient = class extends EventEmitter {
21998
21998
  try {
21999
21999
  payload = type.decode(event.payload);
22000
22000
  object = type.toObject(payload, { longs: Number });
22001
- } catch (cause) {
22002
- const error = new Error("could not decode event payload");
22001
+ } catch (err) {
22002
+ const error = new Error(`Could not decode event payload: ${err instanceof Error ? err.message : String(err)}`);
22003
22003
  this.errorHandler(error);
22004
22004
  return;
22005
22005
  }
@@ -22154,14 +22154,29 @@ var SesameConnection = class extends EventEmitter2 {
22154
22154
  this.socket.addEventListener("close", this.boundCloseHandler);
22155
22155
  this.socket.addEventListener("error", this.boundErrorHandler);
22156
22156
  this.socket.binaryType = "arraybuffer";
22157
- await new Promise((resolve) => {
22158
- const done = () => {
22159
- this.removeListener("open", done);
22160
- this.removeListener("close", done);
22161
- resolve(null);
22157
+ await new Promise((resolve, reject) => {
22158
+ const cleanup = () => {
22159
+ this.removeListener("open", onOpen);
22160
+ this.removeListener("close", onClose);
22161
+ this.removeListener("error", onError);
22162
22162
  };
22163
- this.on("open", done);
22164
- this.on("close", done);
22163
+ const onOpen = () => {
22164
+ cleanup();
22165
+ resolve();
22166
+ };
22167
+ const onError = (err) => {
22168
+ cleanup();
22169
+ reject(err instanceof Error ? err : new Error("WebSocket connection error"));
22170
+ };
22171
+ const onClose = () => {
22172
+ if (!this.isConnected()) {
22173
+ cleanup();
22174
+ reject(new Error("WebSocket connection closed before opening"));
22175
+ }
22176
+ };
22177
+ this.on("open", onOpen);
22178
+ this.on("close", onClose);
22179
+ this.on("error", onError);
22165
22180
  });
22166
22181
  }
22167
22182
  /**
@@ -22305,7 +22320,6 @@ var JobsApi = class {
22305
22320
  if (!config.filename) throw new Error("Filename is required");
22306
22321
  exportReq.config = {
22307
22322
  ...config,
22308
- filename: config.filename,
22309
22323
  videoCodec: config.videoCodec ?? sesame.v1.common.CodecId.CODEC_ID_H264,
22310
22324
  videoBitrateKbps: config.videoBitrateKbps ?? 1024,
22311
22325
  audioCodec: config.audioCodec ?? sesame.v1.jobs.AudioCodecId.AUDIO_CODEC_ID_AAC,
@@ -22314,18 +22328,18 @@ var JobsApi = class {
22314
22328
  audioRouting: config.audioRouting ?? [0, 1, 2, 3]
22315
22329
  };
22316
22330
  exportReq.items = playlist.clips.map((clip) => ({
22317
- id: clip.id,
22318
- recorderId: clip.recorderId,
22331
+ ...clip,
22319
22332
  transitionTimeUs: clip.transitionTimeUs ?? 0,
22320
22333
  transitionType: clip.transitionType ?? sesame.v1.recorder.TransitionType.TRANSITION_TYPE_MIX,
22321
22334
  transitionFadeColor: clip.transitionFadeColor ?? { x: 0, y: 0, z: 0, w: 0 },
22322
- speed: clip.speed ?? 1,
22323
- audioRouting: clip.audioRouting,
22324
- startTimeUs: clip.startTimeUs,
22325
- endTimeUs: clip.endTimeUs
22335
+ speed: clip.speed ?? 1
22326
22336
  }));
22327
22337
  const msg = sesame.v1.jobs.JobStartRequest.create({ exportRequest: exportReq });
22328
- await this.rpc.service.startJob(msg);
22338
+ const job = await this.rpc.service.startJob(msg);
22339
+ if (job.error) {
22340
+ throw new Error(job.error);
22341
+ }
22342
+ return job;
22329
22343
  }
22330
22344
  async abortJob(jobId) {
22331
22345
  const msg = { jobId };