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

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;
@@ -13318,7 +13318,7 @@ var sesame = $root.sesame = (() => {
13318
13318
  TransportEvent.prototype.clipDurationUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13319
13319
  TransportEvent.prototype.preroll = 0;
13320
13320
  TransportEvent.prototype.postroll = 0;
13321
- TransportEvent.prototype.metadata = "";
13321
+ TransportEvent.prototype.metadata = null;
13322
13322
  TransportEvent.create = function create(properties) {
13323
13323
  return new TransportEvent(properties);
13324
13324
  };
@@ -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 =*/
@@ -13411,10 +13411,10 @@ var sesame = $root.sesame = (() => {
13411
13411
  136
13412
13412
  ).uint32(message.postroll);
13413
13413
  if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata"))
13414
- writer.uint32(
13414
+ $root.sesame.v1.common.TransportMetadata.encode(message.metadata, writer.uint32(
13415
13415
  /* id 18, wireType 2 =*/
13416
13416
  146
13417
- ).string(message.metadata);
13417
+ ).fork()).ldelim();
13418
13418
  return writer;
13419
13419
  };
13420
13420
  TransportEvent.encodeDelimited = function encodeDelimited(message, writer) {
@@ -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: {
@@ -13498,7 +13498,7 @@ var sesame = $root.sesame = (() => {
13498
13498
  break;
13499
13499
  }
13500
13500
  case 18: {
13501
- message.metadata = reader.string();
13501
+ message.metadata = $root.sesame.v1.common.TransportMetadata.decode(reader, reader.uint32());
13502
13502
  break;
13503
13503
  }
13504
13504
  default:
@@ -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")
@@ -13592,8 +13592,9 @@ var sesame = $root.sesame = (() => {
13592
13592
  return "postroll: integer expected";
13593
13593
  }
13594
13594
  if (message.metadata != null && message.hasOwnProperty("metadata")) {
13595
- if (!$util.isString(message.metadata))
13596
- return "metadata: string expected";
13595
+ let error = $root.sesame.v1.common.TransportMetadata.verify(message.metadata);
13596
+ if (error)
13597
+ return "metadata." + error;
13597
13598
  }
13598
13599
  return null;
13599
13600
  };
@@ -13665,15 +13666,15 @@ var sesame = $root.sesame = (() => {
13665
13666
  else if (typeof object.materialPositionUs === "object")
13666
13667
  message.materialPositionUs = new $util.LongBits(object.materialPositionUs.low >>> 0, object.materialPositionUs.high >>> 0).toNumber();
13667
13668
  }
13668
- if (object.userTimeMs != null) {
13669
+ if (object.userTimeUs != null) {
13669
13670
  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();
13671
+ (message.userTimeUs = $util.Long.fromValue(object.userTimeUs)).unsigned = false;
13672
+ else if (typeof object.userTimeUs === "string")
13673
+ message.userTimeUs = parseInt(object.userTimeUs, 10);
13674
+ else if (typeof object.userTimeUs === "number")
13675
+ message.userTimeUs = object.userTimeUs;
13676
+ else if (typeof object.userTimeUs === "object")
13677
+ message.userTimeUs = new $util.LongBits(object.userTimeUs.low >>> 0, object.userTimeUs.high >>> 0).toNumber();
13677
13678
  }
13678
13679
  if (object.speed != null)
13679
13680
  message.speed = Number(object.speed);
@@ -13717,8 +13718,11 @@ var sesame = $root.sesame = (() => {
13717
13718
  message.preroll = object.preroll >>> 0;
13718
13719
  if (object.postroll != null)
13719
13720
  message.postroll = object.postroll >>> 0;
13720
- if (object.metadata != null)
13721
- message.metadata = String(object.metadata);
13721
+ if (object.metadata != null) {
13722
+ if (typeof object.metadata !== "object")
13723
+ throw TypeError(".sesame.v1.status.TransportEvent.metadata: object expected");
13724
+ message.metadata = $root.sesame.v1.common.TransportMetadata.fromObject(object.metadata);
13725
+ }
13722
13726
  return message;
13723
13727
  };
13724
13728
  TransportEvent.toObject = function toObject(message, options) {
@@ -13747,9 +13751,9 @@ var sesame = $root.sesame = (() => {
13747
13751
  object.materialPositionUs = options.longs === String ? "0" : 0;
13748
13752
  if ($util.Long) {
13749
13753
  let long = new $util.Long(0, 0, false);
13750
- object.userTimeMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13754
+ object.userTimeUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13751
13755
  } else
13752
- object.userTimeMs = options.longs === String ? "0" : 0;
13756
+ object.userTimeUs = options.longs === String ? "0" : 0;
13753
13757
  object.speed = 0;
13754
13758
  object.userPlaylistId = "";
13755
13759
  object.playlistIndex = 0;
@@ -13771,7 +13775,7 @@ var sesame = $root.sesame = (() => {
13771
13775
  object.clipDurationUs = options.longs === String ? "0" : 0;
13772
13776
  object.preroll = 0;
13773
13777
  object.postroll = 0;
13774
- object.metadata = "";
13778
+ object.metadata = null;
13775
13779
  }
13776
13780
  if (message.sourceId != null && message.hasOwnProperty("sourceId"))
13777
13781
  object.sourceId = message.sourceId;
@@ -13796,11 +13800,11 @@ var sesame = $root.sesame = (() => {
13796
13800
  object.materialPositionUs = options.longs === String ? String(message.materialPositionUs) : message.materialPositionUs;
13797
13801
  else
13798
13802
  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;
13803
+ if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs"))
13804
+ if (typeof message.userTimeUs === "number")
13805
+ object.userTimeUs = options.longs === String ? String(message.userTimeUs) : message.userTimeUs;
13802
13806
  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;
13807
+ 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
13808
  if (message.speed != null && message.hasOwnProperty("speed"))
13805
13809
  object.speed = options.json && !isFinite(message.speed) ? String(message.speed) : message.speed;
13806
13810
  if (message.userPlaylistId != null && message.hasOwnProperty("userPlaylistId"))
@@ -13829,7 +13833,7 @@ var sesame = $root.sesame = (() => {
13829
13833
  if (message.postroll != null && message.hasOwnProperty("postroll"))
13830
13834
  object.postroll = message.postroll;
13831
13835
  if (message.metadata != null && message.hasOwnProperty("metadata"))
13832
- object.metadata = message.metadata;
13836
+ object.metadata = $root.sesame.v1.common.TransportMetadata.toObject(message.metadata, options);
13833
13837
  return object;
13834
13838
  };
13835
13839
  TransportEvent.prototype.toJSON = function toJSON() {
@@ -21922,8 +21926,8 @@ var RPCClient = class extends EventEmitter {
21922
21926
  } else {
21923
21927
  throw new Error("Unsupported RPC message payload");
21924
21928
  }
21925
- } catch (cause) {
21926
- const error = new Error("got invalid message");
21929
+ } catch (err) {
21930
+ const error = new Error(`Got invalid message: ${err instanceof Error ? err.message : String(err)}`);
21927
21931
  this.errorHandler(error);
21928
21932
  }
21929
21933
  };
@@ -21998,8 +22002,8 @@ var RPCClient = class extends EventEmitter {
21998
22002
  try {
21999
22003
  payload = type.decode(event.payload);
22000
22004
  object = type.toObject(payload, { longs: Number });
22001
- } catch (cause) {
22002
- const error = new Error("could not decode event payload");
22005
+ } catch (err) {
22006
+ const error = new Error(`Could not decode event payload: ${err instanceof Error ? err.message : String(err)}`);
22003
22007
  this.errorHandler(error);
22004
22008
  return;
22005
22009
  }
@@ -22154,14 +22158,29 @@ var SesameConnection = class extends EventEmitter2 {
22154
22158
  this.socket.addEventListener("close", this.boundCloseHandler);
22155
22159
  this.socket.addEventListener("error", this.boundErrorHandler);
22156
22160
  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);
22161
+ await new Promise((resolve, reject) => {
22162
+ const cleanup = () => {
22163
+ this.removeListener("open", onOpen);
22164
+ this.removeListener("close", onClose);
22165
+ this.removeListener("error", onError);
22166
+ };
22167
+ const onOpen = () => {
22168
+ cleanup();
22169
+ resolve();
22162
22170
  };
22163
- this.on("open", done);
22164
- this.on("close", done);
22171
+ const onError = (err) => {
22172
+ cleanup();
22173
+ reject(err instanceof Error ? err : new Error("WebSocket connection error"));
22174
+ };
22175
+ const onClose = () => {
22176
+ if (!this.isConnected()) {
22177
+ cleanup();
22178
+ reject(new Error("WebSocket connection closed before opening"));
22179
+ }
22180
+ };
22181
+ this.on("open", onOpen);
22182
+ this.on("close", onClose);
22183
+ this.on("error", onError);
22165
22184
  });
22166
22185
  }
22167
22186
  /**
@@ -22305,7 +22324,6 @@ var JobsApi = class {
22305
22324
  if (!config.filename) throw new Error("Filename is required");
22306
22325
  exportReq.config = {
22307
22326
  ...config,
22308
- filename: config.filename,
22309
22327
  videoCodec: config.videoCodec ?? sesame.v1.common.CodecId.CODEC_ID_H264,
22310
22328
  videoBitrateKbps: config.videoBitrateKbps ?? 1024,
22311
22329
  audioCodec: config.audioCodec ?? sesame.v1.jobs.AudioCodecId.AUDIO_CODEC_ID_AAC,
@@ -22314,18 +22332,18 @@ var JobsApi = class {
22314
22332
  audioRouting: config.audioRouting ?? [0, 1, 2, 3]
22315
22333
  };
22316
22334
  exportReq.items = playlist.clips.map((clip) => ({
22317
- id: clip.id,
22318
- recorderId: clip.recorderId,
22335
+ ...clip,
22319
22336
  transitionTimeUs: clip.transitionTimeUs ?? 0,
22320
22337
  transitionType: clip.transitionType ?? sesame.v1.recorder.TransitionType.TRANSITION_TYPE_MIX,
22321
22338
  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
22339
+ speed: clip.speed ?? 1
22326
22340
  }));
22327
22341
  const msg = sesame.v1.jobs.JobStartRequest.create({ exportRequest: exportReq });
22328
- await this.rpc.service.startJob(msg);
22342
+ const job = await this.rpc.service.startJob(msg);
22343
+ if (job.error) {
22344
+ throw new Error(job.error);
22345
+ }
22346
+ return job;
22329
22347
  }
22330
22348
  async abortJob(jobId) {
22331
22349
  const msg = { jobId };