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.
package/dist/sdk2.esm.js CHANGED
@@ -204,7 +204,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
204
204
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
205
205
  };
206
206
 
207
- var webSdkVersion = '2.3.11';
207
+ var webSdkVersion = '2.3.12';
208
208
 
209
209
  function getPlatform() {
210
210
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -13326,14 +13326,29 @@ var Container$4 = styled.div(templateObject_1$c || (templateObject_1$c = __makeT
13326
13326
  var AcceptBtn$1 = styled(LoaderButton)(templateObject_2$a || (templateObject_2$a = __makeTemplateObject(["\n margin-left: auto;\n"], ["\n margin-left: auto;\n"])));
13327
13327
  var templateObject_1$c, templateObject_2$a;
13328
13328
 
13329
+ var videoRecorder = null;
13330
+ var audioRecorder = null;
13331
+ var videoChunks = [];
13332
+ var audioChunks = [];
13333
+ function getVideoRecorder() {
13334
+ return videoRecorder;
13335
+ }
13336
+ function setVideoRecorder(recorder) {
13337
+ videoRecorder = recorder;
13338
+ }
13339
+ function setAudioRecorder(recorder) {
13340
+ audioRecorder = recorder;
13341
+ }
13342
+ function clearVideoChunks() {
13343
+ videoChunks = [];
13344
+ }
13345
+ function clearAudioChunks() {
13346
+ audioChunks = [];
13347
+ }
13329
13348
  var useVideoRecorder = function useVideoRecorder(camera, audioStream, mergeAVStreams) {
13330
13349
  if (mergeAVStreams === void 0) {
13331
13350
  mergeAVStreams = false;
13332
13351
  }
13333
- var videoRecorder = useRef(null);
13334
- var audioRecorder = useRef(null);
13335
- var videoChunks = useRef([]);
13336
- var audioChunks = useRef([]);
13337
13352
  var _a = useState(null),
13338
13353
  videoUrl = _a[0],
13339
13354
  setVideoUrl = _a[1];
@@ -13366,45 +13381,48 @@ var useVideoRecorder = function useVideoRecorder(camera, audioStream, mergeAVStr
13366
13381
  return new MediaStream(__spreadArray(__spreadArray([], videoTracks, true), audioTracks, true));
13367
13382
  }, [audioStream, camera === null || camera === void 0 ? void 0 : camera.stream, mergeAVStreams]);
13368
13383
  var processVideo = useCallback(function () {
13369
- var videoBlob = new Blob(videoChunks.current, {
13384
+ var videoBlob = new Blob(videoChunks, {
13370
13385
  type: 'video/mp4'
13371
13386
  });
13372
- videoChunks.current = [];
13373
13387
  setVideoUrl(URL.createObjectURL(videoBlob));
13388
+ clearVideoChunks();
13374
13389
  setIsRecordingVideo(false);
13390
+ setVideoRecorder(null);
13375
13391
  camera === null || camera === void 0 ? void 0 : camera.release();
13376
13392
  }, [camera]);
13377
13393
  var processAudio = useCallback(function () {
13378
13394
  var _a;
13379
- var audioBlob = new Blob(audioChunks.current, {
13395
+ var audioBlob = new Blob(audioChunks, {
13380
13396
  type: 'audio/mp4'
13381
13397
  });
13382
- audioChunks.current = [];
13383
13398
  setAudioUrl(URL.createObjectURL(audioBlob));
13399
+ clearAudioChunks();
13384
13400
  setIsRecordingAudio(false);
13401
+ setAudioRecorder(null);
13385
13402
  (_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.stop) === null || _a === void 0 ? void 0 : _a.call(audioStream);
13386
13403
  }, [audioStream]);
13387
13404
  var startRecordingVideo = useCallback(function () {
13388
13405
  var videoStream = getVideoStream();
13389
13406
  if (!videoStream) return;
13390
- videoChunks.current = [];
13407
+ clearVideoChunks();
13391
13408
  setIsRecordingVideo(true);
13392
13409
  setVideoRecordingStopped(false);
13393
13410
  setVideoRecordingIntentionallyStopped(false);
13394
- videoRecorder.current = new MediaRecorder(videoStream, {
13411
+ var videoRecorder = new MediaRecorder(videoStream, {
13395
13412
  videoBitsPerSecond: 270000,
13396
13413
  audioBitsPerSecond: 32000
13397
13414
  });
13398
- videoRecorder.current.ondataavailable = function (e) {
13399
- videoChunks.current.push(e.data);
13415
+ setVideoRecorder(videoRecorder);
13416
+ videoRecorder.ondataavailable = function (e) {
13417
+ videoChunks.push(e.data);
13400
13418
  };
13401
- videoRecorder.current.onstop = function () {
13419
+ videoRecorder.onstop = function () {
13402
13420
  setVideoRecordingStopped(true);
13403
13421
  };
13404
- videoRecorder.current.start(1000);
13422
+ videoRecorder.start(1000);
13405
13423
  setTimeout(function () {
13406
13424
  var _a;
13407
- if (((_a = videoRecorder.current) === null || _a === void 0 ? void 0 : _a.state) === 'inactive') {
13425
+ if (((_a = getVideoRecorder()) === null || _a === void 0 ? void 0 : _a.state) === 'inactive') {
13408
13426
  log('media recorder is inactive!');
13409
13427
  // TODO: figure out what to do here
13410
13428
  }
@@ -13413,33 +13431,32 @@ var useVideoRecorder = function useVideoRecorder(camera, audioStream, mergeAVStr
13413
13431
  var startRecordingAudio = useCallback(function () {
13414
13432
  if (mergeAVStreams) return;
13415
13433
  if (!audioStream) return;
13416
- audioChunks.current = [];
13434
+ clearAudioChunks();
13417
13435
  setIsRecordingAudio(true);
13418
13436
  setAudioRecordingStopped(false);
13419
13437
  setAudioRecordingIntentionallyStopped(false);
13420
- audioRecorder.current = new MediaRecorder(audioStream, {
13438
+ var audioRecorder = new MediaRecorder(audioStream, {
13421
13439
  audioBitsPerSecond: 32000
13422
13440
  });
13423
- audioRecorder.current.ondataavailable = function (e) {
13424
- audioChunks.current.push(e.data);
13441
+ setAudioRecorder(audioRecorder);
13442
+ audioRecorder.ondataavailable = function (e) {
13443
+ audioChunks.push(e.data);
13425
13444
  };
13426
- audioRecorder.current.onstop = function () {
13445
+ audioRecorder.onstop = function () {
13427
13446
  setAudioRecordingStopped(true);
13428
13447
  };
13429
- audioRecorder.current.start(1000);
13448
+ audioRecorder.start(1000);
13430
13449
  }, [audioStream, mergeAVStreams]);
13431
13450
  var stopRecordingVideo = useCallback(function () {
13432
- var _a, _b;
13433
13451
  setVideoRecordingIntentionallyStopped(true);
13434
- if (((_a = videoRecorder.current) === null || _a === void 0 ? void 0 : _a.state) !== 'inactive') {
13435
- (_b = videoRecorder.current) === null || _b === void 0 ? void 0 : _b.stop(); // if you call this while state === 'inactive', an exception is thrown.
13452
+ if ((videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.state) !== 'inactive') {
13453
+ videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
13436
13454
  }
13437
13455
  }, []);
13438
13456
  var stopRecordingAudio = useCallback(function () {
13439
- var _a, _b;
13440
13457
  setAudioRecordingIntentionallyStopped(true);
13441
- if (((_a = audioRecorder.current) === null || _a === void 0 ? void 0 : _a.state) !== 'inactive') {
13442
- (_b = audioRecorder.current) === null || _b === void 0 ? void 0 : _b.stop(); // if you call this while state === 'inactive', an exception is thrown.
13458
+ if ((audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.state) !== 'inactive') {
13459
+ audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
13443
13460
  }
13444
13461
  }, []);
13445
13462
  useEffect(function () {
@@ -13453,8 +13470,8 @@ var useVideoRecorder = function useVideoRecorder(camera, audioStream, mergeAVStr
13453
13470
  }
13454
13471
  }, [audioRecordingIntentionallyStopped, audioRecordingStopped, processAudio]);
13455
13472
  var clearRecordedData = useCallback(function () {
13456
- videoChunks.current = [];
13457
- audioChunks.current = [];
13473
+ clearVideoChunks();
13474
+ clearAudioChunks();
13458
13475
  }, []);
13459
13476
  return useMemo(function () {
13460
13477
  return {
@@ -13473,6 +13490,17 @@ var useVideoRecorder = function useVideoRecorder(camera, audioStream, mergeAVStr
13473
13490
  }, [audioRecordingIntentionallyStopped, audioRecordingStopped, audioUrl, clearRecordedData, isRecordingAudio, isRecordingVideo, startRecordingAudio, startRecordingVideo, stopRecordingAudio, stopRecordingVideo, videoRecordingIntentionallyStopped, videoRecordingStopped, videoUrl]);
13474
13491
  };
13475
13492
 
13493
+ var signatureRecorder = null;
13494
+ function getSignatureRecorder() {
13495
+ return signatureRecorder;
13496
+ }
13497
+ function setSignatureRecorder(recorder) {
13498
+ signatureRecorder = recorder;
13499
+ }
13500
+ var signatureChunks = [];
13501
+ function clearSignatureChunks() {
13502
+ signatureChunks = [];
13503
+ }
13476
13504
  var videoSignatureInitialState = {
13477
13505
  startRecording: function startRecording() {
13478
13506
  return null;
@@ -13491,7 +13519,7 @@ var videoSignatureInitialState = {
13491
13519
  onAcceptClicked: function onAcceptClicked() {
13492
13520
  return __awaiter(void 0, void 0, void 0, function () {
13493
13521
  return __generator(this, function (_a) {
13494
- return [2 /*return*/, void 0];
13522
+ return [2 /*return*/];
13495
13523
  });
13496
13524
  });
13497
13525
  }
@@ -13516,8 +13544,6 @@ function VideoSignatureContextProvider(_a) {
13516
13544
  var _h = useState(null),
13517
13545
  signatureVideoUrl = _h[0],
13518
13546
  setSignatureVideoUrl = _h[1];
13519
- var signatureRecorder = useRef(null);
13520
- var recordedChunks = useRef([]);
13521
13547
  var _j = useCameraStore(),
13522
13548
  camera = _j.camera,
13523
13549
  videoRef = _j.videoRef,
@@ -13551,7 +13577,8 @@ function VideoSignatureContextProvider(_a) {
13551
13577
  };
13552
13578
  recordingLock.current = false;
13553
13579
  setIsRecording(false);
13554
- (_a = signatureRecorder.current) === null || _a === void 0 ? void 0 : _a.stop();
13580
+ (_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
13581
+ setSignatureRecorder(null);
13555
13582
  }, []);
13556
13583
  useEffect(function () {
13557
13584
  if (!isRecording) return;
@@ -13559,7 +13586,7 @@ function VideoSignatureContextProvider(_a) {
13559
13586
  recordingLock.current = true;
13560
13587
  (function () {
13561
13588
  return __awaiter(_this, void 0, void 0, function () {
13562
- var stream, tracks, audioTrack;
13589
+ var stream, tracks, audioTrack, signatureRecorder;
13563
13590
  var _a;
13564
13591
  return __generator(this, function (_b) {
13565
13592
  switch (_b.label) {
@@ -13577,7 +13604,7 @@ function VideoSignatureContextProvider(_a) {
13577
13604
  _b.sent();
13578
13605
  _b.label = 2;
13579
13606
  case 2:
13580
- recordedChunks.current = [];
13607
+ clearSignatureChunks();
13581
13608
  clearRecordedVideoData();
13582
13609
  startRecordingVideo();
13583
13610
  if (captureAudio) startRecordingAudio();
@@ -13585,24 +13612,23 @@ function VideoSignatureContextProvider(_a) {
13585
13612
  tracks = [stream.getVideoTracks()[0]];
13586
13613
  audioTrack = (_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks()) === null || _a === void 0 ? void 0 : _a[0];
13587
13614
  if (audioTrack) tracks.push(audioTrack);
13588
- signatureRecorder.current = new MediaRecorder(new MediaStream(tracks), {
13615
+ signatureRecorder = new MediaRecorder(new MediaStream(tracks), {
13589
13616
  videoBitsPerSecond: 270000,
13590
13617
  audioBitsPerSecond: 32000
13591
13618
  });
13592
- signatureRecorder.current.start();
13593
- signatureRecorder.current.ondataavailable = function (event) {
13594
- var _a;
13595
- recordedChunks.current.push(event.data);
13596
- if (((_a = signatureRecorder.current) === null || _a === void 0 ? void 0 : _a.state) === 'recording') {
13597
- signatureRecorder.current.stop();
13598
- }
13619
+ setSignatureRecorder(signatureRecorder);
13620
+ signatureRecorder.start();
13621
+ signatureRecorder.ondataavailable = function (event) {
13622
+ signatureChunks.push(event.data);
13599
13623
  };
13600
- signatureRecorder.current.onstop = function () {
13601
- var blob = new Blob(recordedChunks.current, {
13624
+ signatureRecorder.onstop = function () {
13625
+ var blob = new Blob(signatureChunks, {
13602
13626
  type: 'video/mp4'
13603
13627
  });
13604
13628
  setSignatureVideoData(blob);
13605
13629
  setSignatureVideoUrl(URL.createObjectURL(blob));
13630
+ clearSignatureChunks();
13631
+ setSignatureRecorder(null);
13606
13632
  onRecordingStopped.current();
13607
13633
  };
13608
13634
  return [2 /*return*/];
@@ -13661,7 +13687,7 @@ function VideoSignatureContextProvider(_a) {
13661
13687
  setSignatureData(signatureData);
13662
13688
  stopRecordingVideo();
13663
13689
  stopRecordingAudio();
13664
- (_a = signatureRecorder.current) === null || _a === void 0 ? void 0 : _a.stop();
13690
+ (_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
13665
13691
  return [2 /*return*/];
13666
13692
  }
13667
13693
  });