idmission-web-sdk 2.2.27 → 2.2.29

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.2.27';
214
+ var webSdkVersion = '2.2.29';
215
215
 
216
216
  function getPlatform() {
217
217
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -8896,6 +8896,15 @@
8896
8896
  });
8897
8897
  });
8898
8898
  }
8899
+ function closeFocusModel(modelAssetPath) {
8900
+ if (modelAssetPath === void 0) {
8901
+ modelAssetPath = defaultFocusModelPath;
8902
+ }
8903
+ var id = "".concat(modelAssetPath);
8904
+ if (!models[id]) return;
8905
+ models[id].close();
8906
+ delete models[id];
8907
+ }
8899
8908
  function useLoadFocusModel(_a) {
8900
8909
  var _b = _a.modelPath,
8901
8910
  modelPath = _b === void 0 ? defaultFocusModelPath : _b,
@@ -8948,6 +8957,9 @@
8948
8957
  clearTimeout(modelLoadTimeout);
8949
8958
  });
8950
8959
  return function () {
8960
+ log('unloading focus model', model.current);
8961
+ model.current = null;
8962
+ closeFocusModel(modelPath);
8951
8963
  clearTimeout(modelLoadTimeout);
8952
8964
  document.removeEventListener('idmission.preloadProgress.focus', handleDownloadProgress);
8953
8965
  };
@@ -9001,38 +9013,53 @@
9001
9013
  }
9002
9014
 
9003
9015
  var defaultSelfieCaptureModelLoadTimeoutMs = 45000;
9004
- var detector;
9016
+ var detectors$1 = {};
9005
9017
  function loadFaceDetector() {
9006
- return __awaiter(this, void 0, void 0, function () {
9007
- var _a, _b;
9008
- return __generator(this, function (_c) {
9009
- switch (_c.label) {
9018
+ return __awaiter(this, arguments, void 0, function (modelAssetPath) {
9019
+ var id, _a, _b, _c, _d;
9020
+ if (modelAssetPath === void 0) {
9021
+ modelAssetPath = defaultFaceDetectorModelPath;
9022
+ }
9023
+ return __generator(this, function (_e) {
9024
+ switch (_e.label) {
9010
9025
  case 0:
9011
- if (detector) return [2 /*return*/, detector];
9026
+ id = "".concat(modelAssetPath);
9027
+ if (detectors$1[id]) return [2 /*return*/, detectors$1[id]];
9012
9028
  return [4 /*yield*/, preloadFaceDetectorDependencies()];
9013
9029
  case 1:
9014
- _c.sent();
9030
+ _e.sent();
9015
9031
  if (modelCapabilities.delegate === 'NONE') {
9016
9032
  throw new Error('No available delegate for face detector.');
9017
9033
  }
9018
- _b = (_a = ya).createFromOptions;
9034
+ _a = detectors$1;
9035
+ _b = id;
9036
+ _d = (_c = ya).createFromOptions;
9019
9037
  return [4 /*yield*/, ao.forVisionTasks(visionTasksBasePath)];
9020
9038
  case 2:
9021
- return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
9039
+ return [4 /*yield*/, _d.apply(_c, [_e.sent(), {
9022
9040
  // canvas: document.createElement('canvas'),
9023
9041
  baseOptions: {
9024
- modelAssetPath: defaultFaceDetectorModelPath,
9042
+ modelAssetPath: modelAssetPath,
9025
9043
  delegate: modelCapabilities.delegate
9026
9044
  },
9027
9045
  runningMode: 'VIDEO'
9028
9046
  }])];
9029
9047
  case 3:
9030
- detector = _c.sent();
9031
- return [2 /*return*/, detector];
9048
+ _a[_b] = _e.sent();
9049
+ return [2 /*return*/, detectors$1[id]];
9032
9050
  }
9033
9051
  });
9034
9052
  });
9035
9053
  }
9054
+ function closeFaceDetector(modelAssetPath) {
9055
+ if (modelAssetPath === void 0) {
9056
+ modelAssetPath = defaultFaceDetectorModelPath;
9057
+ }
9058
+ var id = "".concat(modelAssetPath);
9059
+ if (!detectors$1[id]) return;
9060
+ detectors$1[id].close();
9061
+ delete detectors$1[id];
9062
+ }
9036
9063
  function useLoadFaceDetector(_a) {
9037
9064
  var onModelError = _a.onModelError,
9038
9065
  _b = _a.modelLoadTimeoutMs,
@@ -9081,6 +9108,9 @@
9081
9108
  clearTimeout(modelLoadTimeout);
9082
9109
  });
9083
9110
  return function () {
9111
+ log('unloading face detection model', detector.current);
9112
+ detector.current = null;
9113
+ closeFaceDetector();
9084
9114
  clearTimeout(modelLoadTimeout);
9085
9115
  document.removeEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
9086
9116
  };
@@ -9503,6 +9533,18 @@
9503
9533
  });
9504
9534
  });
9505
9535
  }
9536
+ function closeDocumentDetector(modelAssetPath, scoreThreshold) {
9537
+ if (modelAssetPath === void 0) {
9538
+ modelAssetPath = defaultDocumentDetectorModelPath;
9539
+ }
9540
+ if (scoreThreshold === void 0) {
9541
+ scoreThreshold = defaultDocumentDetectionScoreThreshold;
9542
+ }
9543
+ var id = "".concat(modelAssetPath, ":").concat(scoreThreshold);
9544
+ if (!detectors[id]) return;
9545
+ detectors[id].close();
9546
+ delete detectors[id];
9547
+ }
9506
9548
  function useLoadDocumentDetector(_a) {
9507
9549
  var _b = _a.modelPath,
9508
9550
  modelPath = _b === void 0 ? defaultDocumentDetectorModelPath : _b,
@@ -9557,6 +9599,9 @@
9557
9599
  clearTimeout(modelLoadTimeout);
9558
9600
  });
9559
9601
  return function () {
9602
+ log('unloading document detection model');
9603
+ detector.current = null;
9604
+ closeDocumentDetector(modelPath, scoreThreshold);
9560
9605
  clearTimeout(modelLoadTimeout);
9561
9606
  document.removeEventListener('idmission.preloadProgress.documentDetection', handleDownloadProgress);
9562
9607
  };
@@ -10059,7 +10104,13 @@
10059
10104
  function _isNavigatorDefined() {
10060
10105
  return typeof navigator !== 'undefined' && navigator != null;
10061
10106
  }
10062
- function isMobile(nav) {
10107
+ var isMobileCache;
10108
+ function isMobile() {
10109
+ if (isMobileCache !== undefined) return isMobileCache;
10110
+ isMobileCache = evaluateIsMobile();
10111
+ return isMobileCache;
10112
+ }
10113
+ function evaluateIsMobile(nav) {
10063
10114
  if (nav || _isNavigatorDefined()) {
10064
10115
  if (!nav) {
10065
10116
  nav = navigator;