idmission-web-sdk 2.3.11 → 2.3.12

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.
@@ -211,7 +211,7 @@
211
211
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
212
212
  };
213
213
 
214
- var webSdkVersion = '2.3.11';
214
+ var webSdkVersion = '2.3.12';
215
215
 
216
216
  function getPlatform() {
217
217
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -23232,14 +23232,29 @@
23232
23232
  var AcceptBtn$1 = styled(LoaderButton)(templateObject_2$a || (templateObject_2$a = __makeTemplateObject(["\n margin-left: auto;\n"], ["\n margin-left: auto;\n"])));
23233
23233
  var templateObject_1$c, templateObject_2$a;
23234
23234
 
23235
+ var videoRecorder = null;
23236
+ var audioRecorder = null;
23237
+ var videoChunks = [];
23238
+ var audioChunks = [];
23239
+ function getVideoRecorder() {
23240
+ return videoRecorder;
23241
+ }
23242
+ function setVideoRecorder(recorder) {
23243
+ videoRecorder = recorder;
23244
+ }
23245
+ function setAudioRecorder(recorder) {
23246
+ audioRecorder = recorder;
23247
+ }
23248
+ function clearVideoChunks() {
23249
+ videoChunks = [];
23250
+ }
23251
+ function clearAudioChunks() {
23252
+ audioChunks = [];
23253
+ }
23235
23254
  var useVideoRecorder = function useVideoRecorder(camera, audioStream, mergeAVStreams) {
23236
23255
  if (mergeAVStreams === void 0) {
23237
23256
  mergeAVStreams = false;
23238
23257
  }
23239
- var videoRecorder = React.useRef(null);
23240
- var audioRecorder = React.useRef(null);
23241
- var videoChunks = React.useRef([]);
23242
- var audioChunks = React.useRef([]);
23243
23258
  var _a = React.useState(null),
23244
23259
  videoUrl = _a[0],
23245
23260
  setVideoUrl = _a[1];
@@ -23272,45 +23287,48 @@
23272
23287
  return new MediaStream(__spreadArray(__spreadArray([], videoTracks, true), audioTracks, true));
23273
23288
  }, [audioStream, camera === null || camera === void 0 ? void 0 : camera.stream, mergeAVStreams]);
23274
23289
  var processVideo = React.useCallback(function () {
23275
- var videoBlob = new Blob(videoChunks.current, {
23290
+ var videoBlob = new Blob(videoChunks, {
23276
23291
  type: 'video/mp4'
23277
23292
  });
23278
- videoChunks.current = [];
23279
23293
  setVideoUrl(URL.createObjectURL(videoBlob));
23294
+ clearVideoChunks();
23280
23295
  setIsRecordingVideo(false);
23296
+ setVideoRecorder(null);
23281
23297
  camera === null || camera === void 0 ? void 0 : camera.release();
23282
23298
  }, [camera]);
23283
23299
  var processAudio = React.useCallback(function () {
23284
23300
  var _a;
23285
- var audioBlob = new Blob(audioChunks.current, {
23301
+ var audioBlob = new Blob(audioChunks, {
23286
23302
  type: 'audio/mp4'
23287
23303
  });
23288
- audioChunks.current = [];
23289
23304
  setAudioUrl(URL.createObjectURL(audioBlob));
23305
+ clearAudioChunks();
23290
23306
  setIsRecordingAudio(false);
23307
+ setAudioRecorder(null);
23291
23308
  (_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.stop) === null || _a === void 0 ? void 0 : _a.call(audioStream);
23292
23309
  }, [audioStream]);
23293
23310
  var startRecordingVideo = React.useCallback(function () {
23294
23311
  var videoStream = getVideoStream();
23295
23312
  if (!videoStream) return;
23296
- videoChunks.current = [];
23313
+ clearVideoChunks();
23297
23314
  setIsRecordingVideo(true);
23298
23315
  setVideoRecordingStopped(false);
23299
23316
  setVideoRecordingIntentionallyStopped(false);
23300
- videoRecorder.current = new MediaRecorder(videoStream, {
23317
+ var videoRecorder = new MediaRecorder(videoStream, {
23301
23318
  videoBitsPerSecond: 270000,
23302
23319
  audioBitsPerSecond: 32000
23303
23320
  });
23304
- videoRecorder.current.ondataavailable = function (e) {
23305
- videoChunks.current.push(e.data);
23321
+ setVideoRecorder(videoRecorder);
23322
+ videoRecorder.ondataavailable = function (e) {
23323
+ videoChunks.push(e.data);
23306
23324
  };
23307
- videoRecorder.current.onstop = function () {
23325
+ videoRecorder.onstop = function () {
23308
23326
  setVideoRecordingStopped(true);
23309
23327
  };
23310
- videoRecorder.current.start(1000);
23328
+ videoRecorder.start(1000);
23311
23329
  setTimeout(function () {
23312
23330
  var _a;
23313
- if (((_a = videoRecorder.current) === null || _a === void 0 ? void 0 : _a.state) === 'inactive') {
23331
+ if (((_a = getVideoRecorder()) === null || _a === void 0 ? void 0 : _a.state) === 'inactive') {
23314
23332
  log('media recorder is inactive!');
23315
23333
  // TODO: figure out what to do here
23316
23334
  }
@@ -23319,33 +23337,32 @@
23319
23337
  var startRecordingAudio = React.useCallback(function () {
23320
23338
  if (mergeAVStreams) return;
23321
23339
  if (!audioStream) return;
23322
- audioChunks.current = [];
23340
+ clearAudioChunks();
23323
23341
  setIsRecordingAudio(true);
23324
23342
  setAudioRecordingStopped(false);
23325
23343
  setAudioRecordingIntentionallyStopped(false);
23326
- audioRecorder.current = new MediaRecorder(audioStream, {
23344
+ var audioRecorder = new MediaRecorder(audioStream, {
23327
23345
  audioBitsPerSecond: 32000
23328
23346
  });
23329
- audioRecorder.current.ondataavailable = function (e) {
23330
- audioChunks.current.push(e.data);
23347
+ setAudioRecorder(audioRecorder);
23348
+ audioRecorder.ondataavailable = function (e) {
23349
+ audioChunks.push(e.data);
23331
23350
  };
23332
- audioRecorder.current.onstop = function () {
23351
+ audioRecorder.onstop = function () {
23333
23352
  setAudioRecordingStopped(true);
23334
23353
  };
23335
- audioRecorder.current.start(1000);
23354
+ audioRecorder.start(1000);
23336
23355
  }, [audioStream, mergeAVStreams]);
23337
23356
  var stopRecordingVideo = React.useCallback(function () {
23338
- var _a, _b;
23339
23357
  setVideoRecordingIntentionallyStopped(true);
23340
- if (((_a = videoRecorder.current) === null || _a === void 0 ? void 0 : _a.state) !== 'inactive') {
23341
- (_b = videoRecorder.current) === null || _b === void 0 ? void 0 : _b.stop(); // if you call this while state === 'inactive', an exception is thrown.
23358
+ if ((videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.state) !== 'inactive') {
23359
+ videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
23342
23360
  }
23343
23361
  }, []);
23344
23362
  var stopRecordingAudio = React.useCallback(function () {
23345
- var _a, _b;
23346
23363
  setAudioRecordingIntentionallyStopped(true);
23347
- if (((_a = audioRecorder.current) === null || _a === void 0 ? void 0 : _a.state) !== 'inactive') {
23348
- (_b = audioRecorder.current) === null || _b === void 0 ? void 0 : _b.stop(); // if you call this while state === 'inactive', an exception is thrown.
23364
+ if ((audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.state) !== 'inactive') {
23365
+ audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
23349
23366
  }
23350
23367
  }, []);
23351
23368
  React.useEffect(function () {
@@ -23359,8 +23376,8 @@
23359
23376
  }
23360
23377
  }, [audioRecordingIntentionallyStopped, audioRecordingStopped, processAudio]);
23361
23378
  var clearRecordedData = React.useCallback(function () {
23362
- videoChunks.current = [];
23363
- audioChunks.current = [];
23379
+ clearVideoChunks();
23380
+ clearAudioChunks();
23364
23381
  }, []);
23365
23382
  return React.useMemo(function () {
23366
23383
  return {
@@ -23379,6 +23396,17 @@
23379
23396
  }, [audioRecordingIntentionallyStopped, audioRecordingStopped, audioUrl, clearRecordedData, isRecordingAudio, isRecordingVideo, startRecordingAudio, startRecordingVideo, stopRecordingAudio, stopRecordingVideo, videoRecordingIntentionallyStopped, videoRecordingStopped, videoUrl]);
23380
23397
  };
23381
23398
 
23399
+ var signatureRecorder = null;
23400
+ function getSignatureRecorder() {
23401
+ return signatureRecorder;
23402
+ }
23403
+ function setSignatureRecorder(recorder) {
23404
+ signatureRecorder = recorder;
23405
+ }
23406
+ var signatureChunks = [];
23407
+ function clearSignatureChunks() {
23408
+ signatureChunks = [];
23409
+ }
23382
23410
  var videoSignatureInitialState = {
23383
23411
  startRecording: function startRecording() {
23384
23412
  return null;
@@ -23397,7 +23425,7 @@
23397
23425
  onAcceptClicked: function onAcceptClicked() {
23398
23426
  return __awaiter(void 0, void 0, void 0, function () {
23399
23427
  return __generator(this, function (_a) {
23400
- return [2 /*return*/, void 0];
23428
+ return [2 /*return*/];
23401
23429
  });
23402
23430
  });
23403
23431
  }
@@ -23422,8 +23450,6 @@
23422
23450
  var _h = React.useState(null),
23423
23451
  signatureVideoUrl = _h[0],
23424
23452
  setSignatureVideoUrl = _h[1];
23425
- var signatureRecorder = React.useRef(null);
23426
- var recordedChunks = React.useRef([]);
23427
23453
  var _j = useCameraStore(),
23428
23454
  camera = _j.camera,
23429
23455
  videoRef = _j.videoRef,
@@ -23457,7 +23483,8 @@
23457
23483
  };
23458
23484
  recordingLock.current = false;
23459
23485
  setIsRecording(false);
23460
- (_a = signatureRecorder.current) === null || _a === void 0 ? void 0 : _a.stop();
23486
+ (_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
23487
+ setSignatureRecorder(null);
23461
23488
  }, []);
23462
23489
  React.useEffect(function () {
23463
23490
  if (!isRecording) return;
@@ -23465,7 +23492,7 @@
23465
23492
  recordingLock.current = true;
23466
23493
  (function () {
23467
23494
  return __awaiter(_this, void 0, void 0, function () {
23468
- var stream, tracks, audioTrack;
23495
+ var stream, tracks, audioTrack, signatureRecorder;
23469
23496
  var _a;
23470
23497
  return __generator(this, function (_b) {
23471
23498
  switch (_b.label) {
@@ -23483,7 +23510,7 @@
23483
23510
  _b.sent();
23484
23511
  _b.label = 2;
23485
23512
  case 2:
23486
- recordedChunks.current = [];
23513
+ clearSignatureChunks();
23487
23514
  clearRecordedVideoData();
23488
23515
  startRecordingVideo();
23489
23516
  if (captureAudio) startRecordingAudio();
@@ -23491,24 +23518,23 @@
23491
23518
  tracks = [stream.getVideoTracks()[0]];
23492
23519
  audioTrack = (_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks()) === null || _a === void 0 ? void 0 : _a[0];
23493
23520
  if (audioTrack) tracks.push(audioTrack);
23494
- signatureRecorder.current = new MediaRecorder(new MediaStream(tracks), {
23521
+ signatureRecorder = new MediaRecorder(new MediaStream(tracks), {
23495
23522
  videoBitsPerSecond: 270000,
23496
23523
  audioBitsPerSecond: 32000
23497
23524
  });
23498
- signatureRecorder.current.start();
23499
- signatureRecorder.current.ondataavailable = function (event) {
23500
- var _a;
23501
- recordedChunks.current.push(event.data);
23502
- if (((_a = signatureRecorder.current) === null || _a === void 0 ? void 0 : _a.state) === 'recording') {
23503
- signatureRecorder.current.stop();
23504
- }
23525
+ setSignatureRecorder(signatureRecorder);
23526
+ signatureRecorder.start();
23527
+ signatureRecorder.ondataavailable = function (event) {
23528
+ signatureChunks.push(event.data);
23505
23529
  };
23506
- signatureRecorder.current.onstop = function () {
23507
- var blob = new Blob(recordedChunks.current, {
23530
+ signatureRecorder.onstop = function () {
23531
+ var blob = new Blob(signatureChunks, {
23508
23532
  type: 'video/mp4'
23509
23533
  });
23510
23534
  setSignatureVideoData(blob);
23511
23535
  setSignatureVideoUrl(URL.createObjectURL(blob));
23536
+ clearSignatureChunks();
23537
+ setSignatureRecorder(null);
23512
23538
  onRecordingStopped.current();
23513
23539
  };
23514
23540
  return [2 /*return*/];
@@ -23567,7 +23593,7 @@
23567
23593
  setSignatureData(signatureData);
23568
23594
  stopRecordingVideo();
23569
23595
  stopRecordingAudio();
23570
- (_a = signatureRecorder.current) === null || _a === void 0 ? void 0 : _a.stop();
23596
+ (_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
23571
23597
  return [2 /*return*/];
23572
23598
  }
23573
23599
  });