idmission-web-sdk 2.2.97 → 2.2.99

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
@@ -203,7 +203,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
203
203
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
204
204
  };
205
205
 
206
- var webSdkVersion = '2.2.97';
206
+ var webSdkVersion = '2.2.99';
207
207
 
208
208
  function getPlatform() {
209
209
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -3836,6 +3836,9 @@ var DocumentDetectionModelContext = /*#__PURE__*/createContext({
3836
3836
  stopDocumentDetection: function stopDocumentDetection() {
3837
3837
  return null;
3838
3838
  },
3839
+ loadDocumentDetectionModel: function loadDocumentDetectionModel() {
3840
+ return null;
3841
+ },
3839
3842
  documentDetectionModelReady: false,
3840
3843
  documentDetectionModelDownloadProgress: 0,
3841
3844
  documentDetectionModelError: null,
@@ -3875,7 +3878,7 @@ function DocumentDetectionModelProvider(_a) {
3875
3878
  documentDetectionModelLoadTimeoutMs = _g === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _g,
3876
3879
  onDocumentDetectionModelError = _a.onDocumentDetectionModelError,
3877
3880
  _h = _a.shouldLoadModels,
3878
- shouldLoadModels = _h === void 0 ? true : _h;
3881
+ shouldLoadModelsProp = _h === void 0 ? true : _h;
3879
3882
  var _j = useCameraStore(),
3880
3883
  videoRef = _j.videoRef,
3881
3884
  videoLoaded = _j.videoLoaded,
@@ -3895,7 +3898,13 @@ function DocumentDetectionModelProvider(_a) {
3895
3898
  canvasKey = _o[0],
3896
3899
  setCanvasKey = _o[1];
3897
3900
  var stopDetection = useRef(0);
3898
- var _p = useLoadDocumentDetector({
3901
+ var _p = useState(shouldLoadModelsProp),
3902
+ shouldLoadModels = _p[0],
3903
+ setShouldLoadModels = _p[1];
3904
+ var load = useCallback(function () {
3905
+ return setShouldLoadModels(true);
3906
+ }, []);
3907
+ var _q = useLoadDocumentDetector({
3899
3908
  modelPath: documentDetectionModelPath,
3900
3909
  modelLoadTimeoutMs: documentDetectionModelLoadTimeoutMs,
3901
3910
  scoreThreshold: documentDetectionModelScoreThreshold,
@@ -3903,11 +3912,11 @@ function DocumentDetectionModelProvider(_a) {
3903
3912
  videoRef: videoRef,
3904
3913
  shouldLoadModels: shouldLoadModels
3905
3914
  }),
3906
- ready = _p.ready,
3907
- modelDownloadProgress = _p.modelDownloadProgress,
3908
- modelError = _p.modelError,
3909
- setModelError = _p.setModelError;
3910
- var _q = useFrameLoop(useCallback(function (frameId, timeRunning) {
3915
+ ready = _q.ready,
3916
+ modelDownloadProgress = _q.modelDownloadProgress,
3917
+ modelError = _q.modelError,
3918
+ setModelError = _q.setModelError;
3919
+ var _r = useFrameLoop(useCallback(function (frameId, timeRunning) {
3911
3920
  return __awaiter(_this, void 0, void 0, function () {
3912
3921
  var stopDetectionAtStart, vw, vh, ctx, prediction, processedPrediction;
3913
3922
  var _a;
@@ -3950,8 +3959,8 @@ function DocumentDetectionModelProvider(_a) {
3950
3959
  throttleMs: throttleMs,
3951
3960
  autoStart: autoStart
3952
3961
  }),
3953
- start = _q.start,
3954
- stop = _q.stop;
3962
+ start = _r.start,
3963
+ stop = _r.stop;
3955
3964
  useEffect(function setErrorIfAllZero() {
3956
3965
  if (timesAllZero >= 2) {
3957
3966
  setModelError(new Error('model is returning all zeroes'));
@@ -3970,6 +3979,7 @@ function DocumentDetectionModelProvider(_a) {
3970
3979
  return {
3971
3980
  startDocumentDetection: start,
3972
3981
  stopDocumentDetection: stop,
3982
+ loadDocumentDetectionModel: load,
3973
3983
  documentDetectionModelReady: ready,
3974
3984
  documentDetectionModelError: modelError,
3975
3985
  documentDetectionModelDownloadProgress: modelDownloadProgress,
@@ -3982,7 +3992,7 @@ function DocumentDetectionModelProvider(_a) {
3982
3992
  documentDetectionLastPredictionCanvas: lastPredictionCanvas,
3983
3993
  clearDocumentDetectionLastPredictionCanvas: clearDocumentDetectionLastPredictionCanvas
3984
3994
  };
3985
- }, [start, stop, ready, modelError, modelDownloadProgress, onDocumentDetected, documentDetectionThresholds, documentDetectionBoundaries, clearDocumentDetectionLastPredictionCanvas]);
3995
+ }, [start, stop, load, ready, modelError, modelDownloadProgress, onDocumentDetected, documentDetectionThresholds, documentDetectionBoundaries, clearDocumentDetectionLastPredictionCanvas]);
3986
3996
  return /*#__PURE__*/React.createElement(DocumentDetectionModelContext.Provider, {
3987
3997
  value: value
3988
3998
  }, /*#__PURE__*/React.createElement(InvisibleCanvas, {
@@ -3992,6 +4002,9 @@ function DocumentDetectionModelProvider(_a) {
3992
4002
  }
3993
4003
 
3994
4004
  var FocusModelContext = /*#__PURE__*/createContext({
4005
+ loadFocusModel: function loadFocusModel() {
4006
+ return null;
4007
+ },
3995
4008
  focusModelReady: false,
3996
4009
  focusModelDownloadProgress: 0,
3997
4010
  focusModelError: null,
@@ -4014,23 +4027,29 @@ function FocusModelProvider(_a) {
4014
4027
  _d = _a.showCanvases,
4015
4028
  showCanvases = _d === void 0 ? false : _d,
4016
4029
  _e = _a.shouldLoadModels,
4017
- shouldLoadModels = _e === void 0 ? true : _e;
4030
+ shouldLoadModelsProp = _e === void 0 ? true : _e;
4018
4031
  var cropCanvas = useRef(null);
4019
4032
  var rotateCanvas = useRef(null);
4020
4033
  var _f = useState({}),
4021
4034
  focusThresholds = _f[0],
4022
4035
  setFocusThresholds = _f[1];
4023
4036
  var videoRef = useCameraStore().videoRef;
4024
- var _g = useLoadFocusModel({
4037
+ var _g = useState(shouldLoadModelsProp),
4038
+ shouldLoadModels = _g[0],
4039
+ setShouldLoadModels = _g[1];
4040
+ var load = useCallback(function () {
4041
+ return setShouldLoadModels(true);
4042
+ }, []);
4043
+ var _h = useLoadFocusModel({
4025
4044
  modelPath: focusModelPath,
4026
4045
  modelLoadTimeoutMs: focusModelLoadTimeoutMs,
4027
4046
  onModelError: onFocusModelError,
4028
4047
  videoRef: videoRef,
4029
4048
  shouldLoadModels: shouldLoadModels
4030
4049
  }),
4031
- ready = _g.ready,
4032
- modelDownloadProgress = _g.modelDownloadProgress,
4033
- modelError = _g.modelError;
4050
+ ready = _h.ready,
4051
+ modelDownloadProgress = _h.modelDownloadProgress,
4052
+ modelError = _h.modelError;
4034
4053
  var makeFocusPrediction = useCallback(function (imageData, box) {
4035
4054
  if (!ready) return null;
4036
4055
  var prediction = makeFocusModelPrediction(imageData, cropCanvas.current, rotateCanvas.current, box);
@@ -4040,6 +4059,7 @@ function FocusModelProvider(_a) {
4040
4059
  }, [ready]);
4041
4060
  var value = useMemo(function () {
4042
4061
  return {
4062
+ loadFocusModel: load,
4043
4063
  focusModelReady: ready,
4044
4064
  focusModelDownloadProgress: modelDownloadProgress,
4045
4065
  focusModelError: modelError,
@@ -4048,7 +4068,7 @@ function FocusModelProvider(_a) {
4048
4068
  focusThresholds: focusThresholds,
4049
4069
  setFocusThresholds: setFocusThresholds
4050
4070
  };
4051
- }, [focusThresholds, makeFocusPrediction, modelDownloadProgress, modelError, ready]);
4071
+ }, [focusThresholds, load, makeFocusPrediction, modelDownloadProgress, modelError, ready]);
4052
4072
  return /*#__PURE__*/React__default.createElement(FocusModelContext.Provider, {
4053
4073
  value: value
4054
4074
  }, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
@@ -4109,6 +4129,9 @@ var IdCaptureModelsContext = /*#__PURE__*/createContext({
4109
4129
  stop: function stop() {
4110
4130
  return null;
4111
4131
  },
4132
+ load: function load() {
4133
+ return null;
4134
+ },
4112
4135
  modelDownloadProgress: 0,
4113
4136
  modelError: null,
4114
4137
  thresholds: defaultIdCaptureThresholds,
@@ -4148,6 +4171,7 @@ function IdCaptureModelsProviderInner(_a) {
4148
4171
  documentDetectionModelDownloadProgress = _c.documentDetectionModelDownloadProgress,
4149
4172
  startDocumentDetection = _c.startDocumentDetection,
4150
4173
  stopDocumentDetection = _c.stopDocumentDetection,
4174
+ loadDocumentDetectionModel = _c.loadDocumentDetectionModel,
4151
4175
  lastPredictionCanvas = _c.documentDetectionLastPredictionCanvas,
4152
4176
  clearDocumentDetectionLastPredictionCanvas = _c.clearDocumentDetectionLastPredictionCanvas,
4153
4177
  onDocumentDetected = _c.onDocumentDetected,
@@ -4158,6 +4182,7 @@ function IdCaptureModelsProviderInner(_a) {
4158
4182
  setDocumentDetectionBoundaries = _c.setDocumentDetectionBoundaries,
4159
4183
  documentDetectionModelError = _c.documentDetectionModelError;
4160
4184
  var _d = useContext(FocusModelContext),
4185
+ loadFocusModel = _d.loadFocusModel,
4161
4186
  focusModelReady = _d.focusModelReady,
4162
4187
  focusModelDownloadProgress = _d.focusModelDownloadProgress,
4163
4188
  makeFocusPrediction = _d.makeFocusPrediction,
@@ -4263,6 +4288,10 @@ function IdCaptureModelsProviderInner(_a) {
4263
4288
  useEffect(function () {
4264
4289
  if (requiredDocumentType) resetBestFrame();
4265
4290
  }, [requiredDocumentType, resetBestFrame]);
4291
+ var load = useCallback(function () {
4292
+ loadDocumentDetectionModel();
4293
+ loadFocusModel();
4294
+ }, [loadDocumentDetectionModel, loadFocusModel]);
4266
4295
  var value = useMemo(function () {
4267
4296
  return {
4268
4297
  ready: documentDetectionModelReady && focusModelReady,
@@ -4270,6 +4299,7 @@ function IdCaptureModelsProviderInner(_a) {
4270
4299
  modelError: modelError,
4271
4300
  start: startDocumentDetection,
4272
4301
  stop: stopDocumentDetection,
4302
+ load: load,
4273
4303
  thresholds: thresholds,
4274
4304
  setThresholds: setThresholds,
4275
4305
  documentDetectionBoundaries: documentDetectionBoundaries,
@@ -4283,7 +4313,7 @@ function IdCaptureModelsProviderInner(_a) {
4283
4313
  requiredDocumentType: requiredDocumentType,
4284
4314
  setRequiredDocumentType: setRequiredDocumentType
4285
4315
  };
4286
- }, [detectionTime, documentDetectionBoundaries, documentDetectionModelDownloadProgress, documentDetectionModelReady, focusModelDownloadProgress, focusModelReady, focusPredictionTime, getBestFrame, modelError, onPredictionMade, requiredDocumentType, resetBestFrame, setDocumentDetectionBoundaries, setThresholds, startDocumentDetection, stopDocumentDetection, thresholds]);
4316
+ }, [detectionTime, documentDetectionBoundaries, documentDetectionModelDownloadProgress, documentDetectionModelReady, focusModelDownloadProgress, focusModelReady, focusPredictionTime, getBestFrame, load, modelError, onPredictionMade, requiredDocumentType, resetBestFrame, setDocumentDetectionBoundaries, setThresholds, startDocumentDetection, stopDocumentDetection, thresholds]);
4287
4317
  return /*#__PURE__*/React__default.createElement(IdCaptureModelsContext.Provider, {
4288
4318
  value: value
4289
4319
  }, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
@@ -6828,6 +6858,13 @@ var IdCaptureLoadingOverlayDefault = function IdCaptureLoadingOverlayDefault(_a)
6828
6858
  var _q = useState(false),
6829
6859
  dismissed = _q[0],
6830
6860
  setDismissed = _q[1];
6861
+ var dispatch = useIdCaptureState()[1];
6862
+ useEffect(function () {
6863
+ dispatch({
6864
+ type: 'setUploadingDocumentsFromStorage',
6865
+ payload: false
6866
+ });
6867
+ }, [dispatch]);
6831
6868
  assets.instructionImageUrl || (assets.instructionImageUrl = legacyInstructionImageUrl$1);
6832
6869
  var verbiage = useTranslations(rawVerbiage, {
6833
6870
  headingText: 'Use your device camera to capture your ID',
@@ -9111,6 +9148,7 @@ function IdCaptureOrUploadScreen(_a) {
9111
9148
  state = _d[0],
9112
9149
  dispatch = _d[1];
9113
9150
  var requestCameraAccess = useCameraStore().requestCameraAccess;
9151
+ var loadModels = useContext(IdCaptureModelsContext).load;
9114
9152
  var _e = useState(false),
9115
9153
  selectIdTypeModalOpen = _e[0],
9116
9154
  setSelectIdTypeModalOpen = _e[1];
@@ -9143,6 +9181,7 @@ function IdCaptureOrUploadScreen(_a) {
9143
9181
  className: classNames.captureWithCameraButton,
9144
9182
  colors: buttonColors,
9145
9183
  onClick: function onClick() {
9184
+ loadModels();
9146
9185
  void requestCameraAccess();
9147
9186
  dispatch({
9148
9187
  type: 'setUploadingDocumentsFromStorage',