@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.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;
@@ -13375,7 +13375,7 @@ var sesame = $root.sesame = (() => {
13375
13375
  TransportEvent.prototype.clipDurationUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13376
13376
  TransportEvent.prototype.preroll = 0;
13377
13377
  TransportEvent.prototype.postroll = 0;
13378
- TransportEvent.prototype.metadata = "";
13378
+ TransportEvent.prototype.metadata = null;
13379
13379
  TransportEvent.create = function create(properties) {
13380
13380
  return new TransportEvent(properties);
13381
13381
  };
@@ -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 =*/
@@ -13468,10 +13468,10 @@ var sesame = $root.sesame = (() => {
13468
13468
  136
13469
13469
  ).uint32(message.postroll);
13470
13470
  if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata"))
13471
- writer.uint32(
13471
+ $root.sesame.v1.common.TransportMetadata.encode(message.metadata, writer.uint32(
13472
13472
  /* id 18, wireType 2 =*/
13473
13473
  146
13474
- ).string(message.metadata);
13474
+ ).fork()).ldelim();
13475
13475
  return writer;
13476
13476
  };
13477
13477
  TransportEvent.encodeDelimited = function encodeDelimited(message, writer) {
@@ -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: {
@@ -13555,7 +13555,7 @@ var sesame = $root.sesame = (() => {
13555
13555
  break;
13556
13556
  }
13557
13557
  case 18: {
13558
- message.metadata = reader.string();
13558
+ message.metadata = $root.sesame.v1.common.TransportMetadata.decode(reader, reader.uint32());
13559
13559
  break;
13560
13560
  }
13561
13561
  default:
@@ -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")
@@ -13649,8 +13649,9 @@ var sesame = $root.sesame = (() => {
13649
13649
  return "postroll: integer expected";
13650
13650
  }
13651
13651
  if (message.metadata != null && message.hasOwnProperty("metadata")) {
13652
- if (!$util.isString(message.metadata))
13653
- return "metadata: string expected";
13652
+ let error = $root.sesame.v1.common.TransportMetadata.verify(message.metadata);
13653
+ if (error)
13654
+ return "metadata." + error;
13654
13655
  }
13655
13656
  return null;
13656
13657
  };
@@ -13722,15 +13723,15 @@ var sesame = $root.sesame = (() => {
13722
13723
  else if (typeof object.materialPositionUs === "object")
13723
13724
  message.materialPositionUs = new $util.LongBits(object.materialPositionUs.low >>> 0, object.materialPositionUs.high >>> 0).toNumber();
13724
13725
  }
13725
- if (object.userTimeMs != null) {
13726
+ if (object.userTimeUs != null) {
13726
13727
  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();
13728
+ (message.userTimeUs = $util.Long.fromValue(object.userTimeUs)).unsigned = false;
13729
+ else if (typeof object.userTimeUs === "string")
13730
+ message.userTimeUs = parseInt(object.userTimeUs, 10);
13731
+ else if (typeof object.userTimeUs === "number")
13732
+ message.userTimeUs = object.userTimeUs;
13733
+ else if (typeof object.userTimeUs === "object")
13734
+ message.userTimeUs = new $util.LongBits(object.userTimeUs.low >>> 0, object.userTimeUs.high >>> 0).toNumber();
13734
13735
  }
13735
13736
  if (object.speed != null)
13736
13737
  message.speed = Number(object.speed);
@@ -13774,8 +13775,11 @@ var sesame = $root.sesame = (() => {
13774
13775
  message.preroll = object.preroll >>> 0;
13775
13776
  if (object.postroll != null)
13776
13777
  message.postroll = object.postroll >>> 0;
13777
- if (object.metadata != null)
13778
- message.metadata = String(object.metadata);
13778
+ if (object.metadata != null) {
13779
+ if (typeof object.metadata !== "object")
13780
+ throw TypeError(".sesame.v1.status.TransportEvent.metadata: object expected");
13781
+ message.metadata = $root.sesame.v1.common.TransportMetadata.fromObject(object.metadata);
13782
+ }
13779
13783
  return message;
13780
13784
  };
13781
13785
  TransportEvent.toObject = function toObject(message, options) {
@@ -13804,9 +13808,9 @@ var sesame = $root.sesame = (() => {
13804
13808
  object.materialPositionUs = options.longs === String ? "0" : 0;
13805
13809
  if ($util.Long) {
13806
13810
  let long = new $util.Long(0, 0, false);
13807
- object.userTimeMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13811
+ object.userTimeUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13808
13812
  } else
13809
- object.userTimeMs = options.longs === String ? "0" : 0;
13813
+ object.userTimeUs = options.longs === String ? "0" : 0;
13810
13814
  object.speed = 0;
13811
13815
  object.userPlaylistId = "";
13812
13816
  object.playlistIndex = 0;
@@ -13828,7 +13832,7 @@ var sesame = $root.sesame = (() => {
13828
13832
  object.clipDurationUs = options.longs === String ? "0" : 0;
13829
13833
  object.preroll = 0;
13830
13834
  object.postroll = 0;
13831
- object.metadata = "";
13835
+ object.metadata = null;
13832
13836
  }
13833
13837
  if (message.sourceId != null && message.hasOwnProperty("sourceId"))
13834
13838
  object.sourceId = message.sourceId;
@@ -13853,11 +13857,11 @@ var sesame = $root.sesame = (() => {
13853
13857
  object.materialPositionUs = options.longs === String ? String(message.materialPositionUs) : message.materialPositionUs;
13854
13858
  else
13855
13859
  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;
13860
+ if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs"))
13861
+ if (typeof message.userTimeUs === "number")
13862
+ object.userTimeUs = options.longs === String ? String(message.userTimeUs) : message.userTimeUs;
13859
13863
  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;
13864
+ 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
13865
  if (message.speed != null && message.hasOwnProperty("speed"))
13862
13866
  object.speed = options.json && !isFinite(message.speed) ? String(message.speed) : message.speed;
13863
13867
  if (message.userPlaylistId != null && message.hasOwnProperty("userPlaylistId"))
@@ -13886,7 +13890,7 @@ var sesame = $root.sesame = (() => {
13886
13890
  if (message.postroll != null && message.hasOwnProperty("postroll"))
13887
13891
  object.postroll = message.postroll;
13888
13892
  if (message.metadata != null && message.hasOwnProperty("metadata"))
13889
- object.metadata = message.metadata;
13893
+ object.metadata = $root.sesame.v1.common.TransportMetadata.toObject(message.metadata, options);
13890
13894
  return object;
13891
13895
  };
13892
13896
  TransportEvent.prototype.toJSON = function toJSON() {
@@ -21979,8 +21983,8 @@ var RPCClient = class extends import_events.EventEmitter {
21979
21983
  } else {
21980
21984
  throw new Error("Unsupported RPC message payload");
21981
21985
  }
21982
- } catch (cause) {
21983
- const error = new Error("got invalid message");
21986
+ } catch (err) {
21987
+ const error = new Error(`Got invalid message: ${err instanceof Error ? err.message : String(err)}`);
21984
21988
  this.errorHandler(error);
21985
21989
  }
21986
21990
  };
@@ -22055,8 +22059,8 @@ var RPCClient = class extends import_events.EventEmitter {
22055
22059
  try {
22056
22060
  payload = type.decode(event.payload);
22057
22061
  object = type.toObject(payload, { longs: Number });
22058
- } catch (cause) {
22059
- const error = new Error("could not decode event payload");
22062
+ } catch (err) {
22063
+ const error = new Error(`Could not decode event payload: ${err instanceof Error ? err.message : String(err)}`);
22060
22064
  this.errorHandler(error);
22061
22065
  return;
22062
22066
  }
@@ -22211,14 +22215,29 @@ var SesameConnection = class extends import_events2.EventEmitter {
22211
22215
  this.socket.addEventListener("close", this.boundCloseHandler);
22212
22216
  this.socket.addEventListener("error", this.boundErrorHandler);
22213
22217
  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);
22218
+ await new Promise((resolve, reject) => {
22219
+ const cleanup = () => {
22220
+ this.removeListener("open", onOpen);
22221
+ this.removeListener("close", onClose);
22222
+ this.removeListener("error", onError);
22223
+ };
22224
+ const onOpen = () => {
22225
+ cleanup();
22226
+ resolve();
22219
22227
  };
22220
- this.on("open", done);
22221
- this.on("close", done);
22228
+ const onError = (err) => {
22229
+ cleanup();
22230
+ reject(err instanceof Error ? err : new Error("WebSocket connection error"));
22231
+ };
22232
+ const onClose = () => {
22233
+ if (!this.isConnected()) {
22234
+ cleanup();
22235
+ reject(new Error("WebSocket connection closed before opening"));
22236
+ }
22237
+ };
22238
+ this.on("open", onOpen);
22239
+ this.on("close", onClose);
22240
+ this.on("error", onError);
22222
22241
  });
22223
22242
  }
22224
22243
  /**
@@ -22362,7 +22381,6 @@ var JobsApi = class {
22362
22381
  if (!config.filename) throw new Error("Filename is required");
22363
22382
  exportReq.config = {
22364
22383
  ...config,
22365
- filename: config.filename,
22366
22384
  videoCodec: config.videoCodec ?? sesame.v1.common.CodecId.CODEC_ID_H264,
22367
22385
  videoBitrateKbps: config.videoBitrateKbps ?? 1024,
22368
22386
  audioCodec: config.audioCodec ?? sesame.v1.jobs.AudioCodecId.AUDIO_CODEC_ID_AAC,
@@ -22371,18 +22389,18 @@ var JobsApi = class {
22371
22389
  audioRouting: config.audioRouting ?? [0, 1, 2, 3]
22372
22390
  };
22373
22391
  exportReq.items = playlist.clips.map((clip) => ({
22374
- id: clip.id,
22375
- recorderId: clip.recorderId,
22392
+ ...clip,
22376
22393
  transitionTimeUs: clip.transitionTimeUs ?? 0,
22377
22394
  transitionType: clip.transitionType ?? sesame.v1.recorder.TransitionType.TRANSITION_TYPE_MIX,
22378
22395
  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
22396
+ speed: clip.speed ?? 1
22383
22397
  }));
22384
22398
  const msg = sesame.v1.jobs.JobStartRequest.create({ exportRequest: exportReq });
22385
- await this.rpc.service.startJob(msg);
22399
+ const job = await this.rpc.service.startJob(msg);
22400
+ if (job.error) {
22401
+ throw new Error(job.error);
22402
+ }
22403
+ return job;
22386
22404
  }
22387
22405
  async abortJob(jobId) {
22388
22406
  const msg = { jobId };