idmission-web-sdk 2.0.2 → 2.0.4

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.
@@ -140,7 +140,7 @@
140
140
  return cooked;
141
141
  }
142
142
 
143
- var webSdkVersion = '2.0.2';
143
+ var webSdkVersion = '2.0.4';
144
144
 
145
145
  function getPlatform() {
146
146
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -3034,6 +3034,34 @@
3034
3034
  });
3035
3035
  }
3036
3036
 
3037
+ function convertBoundingBox(box) {
3038
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3039
+ return {
3040
+ xMin: (_a = box === null || box === void 0 ? void 0 : box.originX) !== null && _a !== void 0 ? _a : 0,
3041
+ xMax: ((_b = box === null || box === void 0 ? void 0 : box.originX) !== null && _b !== void 0 ? _b : 0) + ((_c = box === null || box === void 0 ? void 0 : box.width) !== null && _c !== void 0 ? _c : 0),
3042
+ yMin: (_d = box === null || box === void 0 ? void 0 : box.originY) !== null && _d !== void 0 ? _d : 0,
3043
+ yMax: ((_e = box === null || box === void 0 ? void 0 : box.originY) !== null && _e !== void 0 ? _e : 0) + ((_f = box === null || box === void 0 ? void 0 : box.height) !== null && _f !== void 0 ? _f : 0),
3044
+ width: (_g = box === null || box === void 0 ? void 0 : box.width) !== null && _g !== void 0 ? _g : 0,
3045
+ height: (_h = box === null || box === void 0 ? void 0 : box.height) !== null && _h !== void 0 ? _h : 0
3046
+ };
3047
+ }
3048
+ function waitForVideoReady(videoRef, checkEveryMs) {
3049
+ if (checkEveryMs === void 0) {
3050
+ checkEveryMs = 100;
3051
+ }
3052
+ return new Promise(function (resolve) {
3053
+ var _a;
3054
+ if (((_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) === 4) return resolve();
3055
+ var interval = setInterval(function () {
3056
+ var _a;
3057
+ if (((_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) === 4) {
3058
+ clearInterval(interval);
3059
+ resolve();
3060
+ }
3061
+ }, checkEveryMs);
3062
+ });
3063
+ }
3064
+
3037
3065
  var defaultFocusModelPath = "https://websdk-cdn-dev.idmission.com/assets/models/focusmp20240523/model_float16.tflite";
3038
3066
  var defaultFocusModelLoadTimeoutMs = 45000;
3039
3067
  var defaultFocusThresholds = {
@@ -3072,16 +3100,9 @@
3072
3100
  delegate: modelCapabilities.delegate
3073
3101
  },
3074
3102
  runningMode: 'VIDEO'
3075
- }])
3076
- // const emptyFrame = document.createElement('canvas')
3077
- // models[id].classifyForVideo(emptyFrame, performance.now())
3078
- // emptyFrame.remove()
3079
- ];
3103
+ }])];
3080
3104
  case 3:
3081
3105
  _a[_b] = _e.sent();
3082
- // const emptyFrame = document.createElement('canvas')
3083
- // models[id].classifyForVideo(emptyFrame, performance.now())
3084
- // emptyFrame.remove()
3085
3106
  return [2 /*return*/, models[id]];
3086
3107
  }
3087
3108
  });
@@ -3103,7 +3124,9 @@
3103
3124
  var _f = React.useState(null),
3104
3125
  modelError = _f[0],
3105
3126
  setModelError = _f[1];
3127
+ var videoRef = React.useContext(CameraStateContext).videoRef;
3106
3128
  React.useEffect(function loadModel() {
3129
+ var _this = this;
3107
3130
  setReady(false);
3108
3131
  function handleDownloadProgress(event) {
3109
3132
  setModelDownloadProgress(progressToPercentage(event.detail));
@@ -3113,9 +3136,22 @@
3113
3136
  setModelError(new Error('Model loading time limit exceeded.'));
3114
3137
  }, modelLoadTimeoutMs);
3115
3138
  loadFocusModel(modelPath).then(function (loadedModel) {
3116
- model.current = loadedModel;
3117
- setModelDownloadProgress(100);
3118
- setReady(true);
3139
+ return __awaiter(_this, void 0, void 0, function () {
3140
+ return __generator(this, function (_a) {
3141
+ switch (_a.label) {
3142
+ case 0:
3143
+ model.current = loadedModel;
3144
+ setModelDownloadProgress(100);
3145
+ clearTimeout(modelLoadTimeout);
3146
+ return [4 /*yield*/, waitForVideoReady(videoRef)];
3147
+ case 1:
3148
+ _a.sent();
3149
+ loadedModel.classifyForVideo(videoRef.current, performance.now());
3150
+ setReady(true);
3151
+ return [2 /*return*/];
3152
+ }
3153
+ });
3154
+ });
3119
3155
  })["catch"](function (e) {
3120
3156
  setModelError(e);
3121
3157
  })["finally"](function () {
@@ -3125,7 +3161,7 @@
3125
3161
  clearTimeout(modelLoadTimeout);
3126
3162
  document.removeEventListener('idmission.preloadProgress.focus', handleDownloadProgress);
3127
3163
  };
3128
- }, [modelPath, modelLoadTimeoutMs]);
3164
+ }, [modelPath, modelLoadTimeoutMs, videoRef]);
3129
3165
  React.useEffect(function handleModelError() {
3130
3166
  modelError && (onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError));
3131
3167
  }, [modelError, onModelError]);
@@ -3303,18 +3339,6 @@
3303
3339
  [256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,
3304
3340
  343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]]);K("VERSION","0.4.1646425229");}).call(commonjsGlobal);
3305
3341
 
3306
- function convertBoundingBox(box) {
3307
- var _a, _b, _c, _d, _e, _f, _g, _h;
3308
- return {
3309
- xMin: (_a = box === null || box === void 0 ? void 0 : box.originX) !== null && _a !== void 0 ? _a : 0,
3310
- xMax: ((_b = box === null || box === void 0 ? void 0 : box.originX) !== null && _b !== void 0 ? _b : 0) + ((_c = box === null || box === void 0 ? void 0 : box.width) !== null && _c !== void 0 ? _c : 0),
3311
- yMin: (_d = box === null || box === void 0 ? void 0 : box.originY) !== null && _d !== void 0 ? _d : 0,
3312
- yMax: ((_e = box === null || box === void 0 ? void 0 : box.originY) !== null && _e !== void 0 ? _e : 0) + ((_f = box === null || box === void 0 ? void 0 : box.height) !== null && _f !== void 0 ? _f : 0),
3313
- width: (_g = box === null || box === void 0 ? void 0 : box.width) !== null && _g !== void 0 ? _g : 0,
3314
- height: (_h = box === null || box === void 0 ? void 0 : box.height) !== null && _h !== void 0 ? _h : 0
3315
- };
3316
- }
3317
-
3318
3342
  var defaultFaceDetectorModelPath = 'https://websdk-cdn-dev.idmission.com/assets/models/blazeface20240207/blaze_face_short_range.tflite';
3319
3343
  var defaultSelfieCaptureModelLoadTimeoutMs = 45000;
3320
3344
  var detector;
@@ -3340,16 +3364,9 @@
3340
3364
  delegate: modelCapabilities.delegate
3341
3365
  },
3342
3366
  runningMode: 'VIDEO'
3343
- }])
3344
- // const emptyFrame = document.createElement('canvas')
3345
- // detector.detectForVideo(emptyFrame, performance.now())
3346
- // emptyFrame.remove()
3347
- ];
3367
+ }])];
3348
3368
  case 3:
3349
3369
  detector = _c.sent();
3350
- // const emptyFrame = document.createElement('canvas')
3351
- // detector.detectForVideo(emptyFrame, performance.now())
3352
- // emptyFrame.remove()
3353
3370
  return [2 /*return*/, detector];
3354
3371
  }
3355
3372
  });
@@ -3369,7 +3386,9 @@
3369
3386
  var _e = React.useState(null),
3370
3387
  modelError = _e[0],
3371
3388
  setModelError = _e[1];
3389
+ var videoRef = React.useContext(CameraStateContext).videoRef;
3372
3390
  React.useEffect(function loadModel() {
3391
+ var _this = this;
3373
3392
  setReady(false);
3374
3393
  var modelLoadTimeout = setTimeout(function () {
3375
3394
  setModelError(new Error('Model loading time limit exceeded.'));
@@ -3379,9 +3398,22 @@
3379
3398
  }
3380
3399
  document.addEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
3381
3400
  loadFaceDetector().then(function (model) {
3382
- detector.current = model;
3383
- setModelDownloadProgress(100);
3384
- setReady(true);
3401
+ return __awaiter(_this, void 0, void 0, function () {
3402
+ return __generator(this, function (_a) {
3403
+ switch (_a.label) {
3404
+ case 0:
3405
+ detector.current = model;
3406
+ setModelDownloadProgress(100);
3407
+ clearTimeout(modelLoadTimeout);
3408
+ return [4 /*yield*/, waitForVideoReady(videoRef)];
3409
+ case 1:
3410
+ _a.sent();
3411
+ model.detectForVideo(videoRef.current, performance.now());
3412
+ setReady(true);
3413
+ return [2 /*return*/];
3414
+ }
3415
+ });
3416
+ });
3385
3417
  })["catch"](function (e) {
3386
3418
  setModelError(e);
3387
3419
  })["finally"](function () {
@@ -3391,7 +3423,7 @@
3391
3423
  clearTimeout(modelLoadTimeout);
3392
3424
  document.removeEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
3393
3425
  };
3394
- }, [modelLoadTimeoutMs]);
3426
+ }, [modelLoadTimeoutMs, videoRef]);
3395
3427
  React.useEffect(function handleModelError() {
3396
3428
  modelError && (onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError));
3397
3429
  }, [modelError, onModelError]);
@@ -3696,16 +3728,9 @@
3696
3728
  },
3697
3729
  scoreThreshold: scoreThreshold,
3698
3730
  runningMode: 'VIDEO'
3699
- }])
3700
- // const emptyFrame = document.createElement('canvas')
3701
- // detectors[id].detectForVideo(emptyFrame, performance.now())
3702
- // emptyFrame.remove()
3703
- ];
3731
+ }])];
3704
3732
  case 3:
3705
3733
  _a[_b] = _e.sent();
3706
- // const emptyFrame = document.createElement('canvas')
3707
- // detectors[id].detectForVideo(emptyFrame, performance.now())
3708
- // emptyFrame.remove()
3709
3734
  return [2 /*return*/, detectors[id]];
3710
3735
  }
3711
3736
  });
@@ -3729,7 +3754,9 @@
3729
3754
  var _g = React.useState(null),
3730
3755
  modelError = _g[0],
3731
3756
  setModelError = _g[1];
3757
+ var videoRef = React.useContext(CameraStateContext).videoRef;
3732
3758
  React.useEffect(function loadModel() {
3759
+ var _this = this;
3733
3760
  setReady(false);
3734
3761
  function handleDownloadProgress(event) {
3735
3762
  setModelDownloadProgress(progressToPercentage(event.detail));
@@ -3739,9 +3766,22 @@
3739
3766
  setModelError(new Error('Model loading time limit exceeded.'));
3740
3767
  }, modelLoadTimeoutMs);
3741
3768
  loadDocumentDetector(modelPath, scoreThreshold).then(function (model) {
3742
- detector.current = model;
3743
- setModelDownloadProgress(100);
3744
- setReady(true);
3769
+ return __awaiter(_this, void 0, void 0, function () {
3770
+ return __generator(this, function (_a) {
3771
+ switch (_a.label) {
3772
+ case 0:
3773
+ detector.current = model;
3774
+ setModelDownloadProgress(100);
3775
+ clearTimeout(modelLoadTimeout);
3776
+ return [4 /*yield*/, waitForVideoReady(videoRef)];
3777
+ case 1:
3778
+ _a.sent();
3779
+ model.detectForVideo(videoRef.current, performance.now());
3780
+ setReady(true);
3781
+ return [2 /*return*/];
3782
+ }
3783
+ });
3784
+ });
3745
3785
  })["catch"](function (e) {
3746
3786
  setModelError(e);
3747
3787
  })["finally"](function () {
@@ -3751,7 +3791,7 @@
3751
3791
  clearTimeout(modelLoadTimeout);
3752
3792
  document.removeEventListener('idmission.preloadProgress.documentDetection', handleDownloadProgress);
3753
3793
  };
3754
- }, [modelLoadTimeoutMs, modelPath, scoreThreshold]);
3794
+ }, [modelLoadTimeoutMs, modelPath, scoreThreshold, videoRef]);
3755
3795
  React.useEffect(function handleModelError() {
3756
3796
  modelError && (onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError));
3757
3797
  }, [modelError, onModelError]);
@@ -12690,6 +12730,7 @@
12690
12730
  var fileContent = fileReader.result.toString();
12691
12731
  onComplete === null || onComplete === void 0 ? void 0 : onComplete({
12692
12732
  documentName: document.name,
12733
+ processAsPOA: document.processAsPOA ? 'Y' : 'N',
12693
12734
  additionalDocument: {
12694
12735
  name: file.name,
12695
12736
  fileContent: dataUrlToBase64Sync(fileContent),
@@ -13576,7 +13617,7 @@
13576
13617
  var processAudio = React.useCallback(function () {
13577
13618
  var _a;
13578
13619
  var audioBlob = new Blob(audioChunks.current, {
13579
- type: 'audio/ogg; codecs=opus'
13620
+ type: 'audio/mp4'
13580
13621
  });
13581
13622
  audioChunks.current = [];
13582
13623
  setAudioUrl(URL.createObjectURL(audioBlob));