idmission-web-sdk 0.0.79 → 0.0.81

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.
@@ -50,7 +50,7 @@ var tf__namespace = /*#__PURE__*/_interopNamespace(tf);
50
50
  var useResizeObserver__default = /*#__PURE__*/_interopDefaultLegacy(useResizeObserver);
51
51
  var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
52
52
 
53
- var webSdkVersion = '0.0.79';
53
+ var webSdkVersion = '0.0.81';
54
54
 
55
55
  function getPlatform() {
56
56
  return window.platform;
@@ -1422,14 +1422,15 @@ var useHighestResCaptureDevice = function useHighestResCaptureDevice(_a) {
1422
1422
  if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) return cleanup;
1423
1423
  (function () {
1424
1424
  return tslib.__awaiter(void 0, void 0, void 0, function () {
1425
- var stream, e_2;
1426
- return tslib.__generator(this, function (_a) {
1427
- switch (_a.label) {
1425
+ var stream, e_2, handleStreamEnded;
1426
+ var _a;
1427
+ return tslib.__generator(this, function (_b) {
1428
+ switch (_b.label) {
1428
1429
  case 0:
1429
1430
  stream = null;
1430
- _a.label = 1;
1431
+ _b.label = 1;
1431
1432
  case 1:
1432
- _a.trys.push([1, 3,, 4]);
1433
+ _b.trys.push([1, 3,, 4]);
1433
1434
  return [4, navigator.mediaDevices.getUserMedia({
1434
1435
  audio: requestMicrophoneAccess,
1435
1436
  video: {
@@ -1443,10 +1444,10 @@ var useHighestResCaptureDevice = function useHighestResCaptureDevice(_a) {
1443
1444
  }
1444
1445
  })];
1445
1446
  case 2:
1446
- stream = _a.sent();
1447
+ stream = _b.sent();
1447
1448
  return [3, 4];
1448
1449
  case 3:
1449
- e_2 = _a.sent();
1450
+ e_2 = _b.sent();
1450
1451
  if (e_2.name === 'NotAllowedError') {
1451
1452
  if (iphoneContinuityCameraAllowed) {
1452
1453
  setIphoneContinuityCameraAvailable(false);
@@ -1459,41 +1460,44 @@ var useHighestResCaptureDevice = function useHighestResCaptureDevice(_a) {
1459
1460
  return [3, 4];
1460
1461
  case 4:
1461
1462
  if (!!stream) return [3, 8];
1462
- _a.label = 5;
1463
+ _b.label = 5;
1463
1464
  case 5:
1464
- _a.trys.push([5, 7,, 8]);
1465
+ _b.trys.push([5, 7,, 8]);
1465
1466
  return [4, navigator.mediaDevices.getUserMedia({
1466
1467
  audio: false,
1467
1468
  video: true
1468
1469
  })];
1469
1470
  case 6:
1470
- stream = _a.sent();
1471
+ stream = _b.sent();
1471
1472
  console.log('opened stream with no width and height constraints');
1472
1473
  return [3, 8];
1473
1474
  case 7:
1474
- _a.sent();
1475
+ _b.sent();
1475
1476
  console.log('cannot open stream at all');
1476
1477
  return [3, 8];
1477
1478
  case 8:
1478
1479
  if (!stream) {
1479
1480
  throw new Error('failed to open camera');
1480
1481
  }
1482
+ handleStreamEnded = function handleStreamEnded() {
1483
+ if (iphoneContinuityCameraAvailable && iphoneContinuityCameraAllowed) {
1484
+ console.log('someone unplugged the continuity camera');
1485
+ releaseCameraAccess();
1486
+ cameraRef.current = null;
1487
+ setIphoneContinuityCameraAvailable(false);
1488
+ setIphoneContinuityCameraDenied(true);
1489
+ } else {
1490
+ console.log('someone unplugged the webcam');
1491
+ releaseCameraAccess();
1492
+ cameraRef.current = null;
1493
+ setVideoLoaded(false);
1494
+ setCameraAccessDenied(true);
1495
+ setCaptureDevice(null);
1496
+ }
1497
+ };
1498
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('ended', handleStreamEnded);
1481
1499
  stream.getVideoTracks().forEach(function (track) {
1482
- track.onended = function () {
1483
- var _a;
1484
- if (iphoneContinuityCameraAvailable && iphoneContinuityCameraAllowed) {
1485
- console.log('someone unplugged the continuity camera');
1486
- setIphoneContinuityCameraAvailable(false);
1487
- setIphoneContinuityCameraDenied(true);
1488
- } else {
1489
- console.log('someone unplugged the webcam');
1490
- (_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.release();
1491
- cameraRef.current = null;
1492
- setVideoLoaded(false);
1493
- setCameraAccessDenied(true);
1494
- setCaptureDevice(null);
1495
- }
1496
- };
1500
+ track.onended = handleStreamEnded;
1497
1501
  });
1498
1502
  cameraRef.current = obtainCameraAccess(stream, videoDevice.label, videoRef.current);
1499
1503
  return [2];