idmission-web-sdk 2.3.122 → 2.3.124
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/components/video_id/IdVideoCaptureSuccess.d.ts.map +1 -1
- package/dist/components/video_signature_capture/VideoSignatureCapture.d.ts.map +1 -1
- package/dist/components/video_signature_capture/VideoSignatureContext.d.ts +0 -26
- package/dist/components/video_signature_capture/VideoSignatureContext.d.ts.map +1 -1
- package/dist/components/video_signature_capture/VideoSignatureWizard.d.ts.map +1 -1
- package/dist/lib/camera/Camera.d.ts.map +1 -1
- package/dist/lib/camera/cameraStore.d.ts.map +1 -1
- package/dist/lib/utils/logger.d.ts +6 -6
- package/dist/lib/utils/logger.d.ts.map +1 -1
- package/dist/sdk2.cjs.development.js +174 -292
- package/dist/sdk2.cjs.development.js.map +1 -1
- package/dist/sdk2.cjs.production.js +1 -1
- package/dist/sdk2.cjs.production.js.map +1 -1
- package/dist/sdk2.esm.js +174 -292
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +174 -292
- package/dist/sdk2.umd.development.js.map +1 -1
- package/dist/sdk2.umd.production.js +1 -1
- package/dist/sdk2.umd.production.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +3 -3
|
@@ -236,7 +236,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
236
236
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
237
237
|
};
|
|
238
238
|
|
|
239
|
-
var webSdkVersion = '2.3.
|
|
239
|
+
var webSdkVersion = '2.3.124';
|
|
240
240
|
|
|
241
241
|
function getPlatform() {
|
|
242
242
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -834,38 +834,35 @@ function useLogLevel(newLogLevel) {
|
|
|
834
834
|
function useDebugLogging(enabled) {
|
|
835
835
|
useLogLevel(enabled ? LogLevel.Debug : logLevel);
|
|
836
836
|
}
|
|
837
|
-
function
|
|
838
|
-
|
|
837
|
+
var noop = function noop() {};
|
|
838
|
+
var debug = function debug() {
|
|
839
|
+
var args = [];
|
|
839
840
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
840
|
-
|
|
841
|
+
args[_i] = arguments[_i];
|
|
841
842
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
var parts = [];
|
|
843
|
+
return (logLevel >= LogLevel.Debug ? console.debug : noop).apply(void 0, args);
|
|
844
|
+
}; // eslint-disable-line no-console
|
|
845
|
+
var log = function log() {
|
|
846
|
+
var args = [];
|
|
847
847
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
848
|
-
|
|
848
|
+
args[_i] = arguments[_i];
|
|
849
849
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
var parts = [];
|
|
850
|
+
return (logLevel >= LogLevel.Info ? console.log : noop).apply(void 0, args);
|
|
851
|
+
}; // eslint-disable-line no-console
|
|
852
|
+
var warn = function warn() {
|
|
853
|
+
var args = [];
|
|
855
854
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
856
|
-
|
|
855
|
+
args[_i] = arguments[_i];
|
|
857
856
|
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
var parts = [];
|
|
857
|
+
return (logLevel >= LogLevel.Warn ? console.warn : noop).apply(void 0, args);
|
|
858
|
+
}; // eslint-disable-line no-console
|
|
859
|
+
var error = function error() {
|
|
860
|
+
var args = [];
|
|
863
861
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
864
|
-
|
|
862
|
+
args[_i] = arguments[_i];
|
|
865
863
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
}
|
|
864
|
+
return (logLevel >= LogLevel.Error ? console.error : noop).apply(void 0, args);
|
|
865
|
+
}; // eslint-disable-line no-console
|
|
869
866
|
|
|
870
867
|
exports.defaultAuthUrl = 'https://portal-api.idmission.com';
|
|
871
868
|
var allowedAuthUrls = ['https://portal-api.idmission.com', 'https://portal-api-uat.idmission.com', 'https://portal-api-demo.idmission.com', 'https://portal-api-dev.idmission.com', 'http://localhost:10000'];
|
|
@@ -3170,6 +3167,7 @@ function useFrameLoop(fn, options) {
|
|
|
3170
3167
|
};
|
|
3171
3168
|
}
|
|
3172
3169
|
|
|
3170
|
+
var LOG_TAG$1 = 'camera:Camera';
|
|
3173
3171
|
function listAvailableCameras(facingMode_1) {
|
|
3174
3172
|
return __awaiter(this, arguments, void 0, function (facingMode, requestMicAccess) {
|
|
3175
3173
|
var cameraEnumerationStream, allDevices, allowedVideoDevices;
|
|
@@ -3232,21 +3230,24 @@ var getDeviceLabel = function getDeviceLabel(deviceInfo) {
|
|
|
3232
3230
|
var currentCamera;
|
|
3233
3231
|
function obtainCameraAccess(stream, deviceLabel, video) {
|
|
3234
3232
|
releaseCameraAccess();
|
|
3235
|
-
log(
|
|
3233
|
+
log("".concat(LOG_TAG$1, " obtaining camera access..."));
|
|
3236
3234
|
var _a = stream.getVideoTracks()[0].getSettings(),
|
|
3237
3235
|
width = _a.width,
|
|
3238
3236
|
height = _a.height;
|
|
3239
|
-
log(
|
|
3237
|
+
log("".concat(LOG_TAG$1, " camera dimensions"), width, height);
|
|
3240
3238
|
var label = deviceLabel.toLocaleLowerCase().split(' ').join('');
|
|
3241
|
-
log(
|
|
3239
|
+
log("".concat(LOG_TAG$1, " camera label"), label);
|
|
3242
3240
|
var isRearFacing = cameraLabelMatches(label, __spreadArray(__spreadArray(__spreadArray([], rearCameraLabels, true), backUltraWideCameraLabels, true), ['iphone'], false));
|
|
3243
|
-
log(
|
|
3241
|
+
log("".concat(LOG_TAG$1, " is rear facing?"), isRearFacing);
|
|
3244
3242
|
var release = function release() {
|
|
3243
|
+
debug("".concat(LOG_TAG$1, " camera releasing stream"), stream);
|
|
3245
3244
|
stream.getTracks().forEach(function (track) {
|
|
3246
3245
|
track.enabled = false;
|
|
3246
|
+
debug("".concat(LOG_TAG$1, " camera stopping stream track"), track);
|
|
3247
3247
|
track.stop();
|
|
3248
3248
|
});
|
|
3249
3249
|
if (video) {
|
|
3250
|
+
debug("".concat(LOG_TAG$1, " camera releasing video element"), video);
|
|
3250
3251
|
video.pause();
|
|
3251
3252
|
video.srcObject = null;
|
|
3252
3253
|
video.src = '';
|
|
@@ -3262,14 +3263,14 @@ function obtainCameraAccess(stream, deviceLabel, video) {
|
|
|
3262
3263
|
isRearFacing: isRearFacing,
|
|
3263
3264
|
release: release
|
|
3264
3265
|
};
|
|
3265
|
-
log(
|
|
3266
|
+
log("".concat(LOG_TAG$1, " camera access granted"), currentCamera);
|
|
3266
3267
|
// if (video) video.srcObject = stream
|
|
3267
3268
|
// log('video source initialized')
|
|
3268
3269
|
return currentCamera;
|
|
3269
3270
|
}
|
|
3270
3271
|
function releaseCameraAccess() {
|
|
3271
3272
|
if (!currentCamera) return;
|
|
3272
|
-
log(
|
|
3273
|
+
log("".concat(LOG_TAG$1, " releasing camera access..."));
|
|
3273
3274
|
currentCamera.release();
|
|
3274
3275
|
currentCamera = undefined;
|
|
3275
3276
|
}
|
|
@@ -4421,6 +4422,7 @@ function useTranslations(verbiage, fallbacks) {
|
|
|
4421
4422
|
}, [fallbacks, i18n.language, t, verbiage]);
|
|
4422
4423
|
}
|
|
4423
4424
|
|
|
4425
|
+
var LOG_TAG = 'camera:store';
|
|
4424
4426
|
var camera = null;
|
|
4425
4427
|
var videoStream = null;
|
|
4426
4428
|
var audioStream = null;
|
|
@@ -4446,7 +4448,8 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
4446
4448
|
var store = zustand.createStore(function (set, get) {
|
|
4447
4449
|
return _assign(_assign(_assign({}, initialState$6), config), {
|
|
4448
4450
|
reset: function reset() {
|
|
4449
|
-
|
|
4451
|
+
debug("".concat(LOG_TAG, " reset"));
|
|
4452
|
+
set(_assign(_assign({}, initialState$6), config));
|
|
4450
4453
|
},
|
|
4451
4454
|
setConfig: function setConfig(config) {
|
|
4452
4455
|
return set(config);
|
|
@@ -4477,6 +4480,7 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
4477
4480
|
return __generator(this, function (_f) {
|
|
4478
4481
|
switch (_f.label) {
|
|
4479
4482
|
case 0:
|
|
4483
|
+
debug("".concat(LOG_TAG, " requestCameraAccess"), new Error().stack);
|
|
4480
4484
|
_a = get(), videoRef = _a.videoRef, releaseCameraAccess = _a.releaseCameraAccess, preferFrontFacingCamera = _a.preferFrontFacingCamera, preferIphoneContinuityCamera = _a.preferIphoneContinuityCamera, iphoneContinuityCameraDenied = _a.iphoneContinuityCameraDenied;
|
|
4481
4485
|
releaseCameraAccess();
|
|
4482
4486
|
_f.label = 1;
|
|
@@ -4486,9 +4490,9 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
4486
4490
|
case 2:
|
|
4487
4491
|
availableCameras = _f.sent();
|
|
4488
4492
|
selectedCamera = void 0;
|
|
4489
|
-
debug(
|
|
4493
|
+
debug("".concat(LOG_TAG, " availableCameras"), availableCameras);
|
|
4490
4494
|
platform_1 = getPlatform();
|
|
4491
|
-
debug(
|
|
4495
|
+
debug("".concat(LOG_TAG, " platformDetails"), platform_1);
|
|
4492
4496
|
if (!iphoneContinuityCameraDenied && (!(platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) || platform_1.os.family === 'OS X')) {
|
|
4493
4497
|
iphoneContinuityCamera = availableCameras.find(function (deviceInfo) {
|
|
4494
4498
|
return cameraLabelMatches(deviceInfo, 'iphone');
|
|
@@ -4505,7 +4509,7 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
4505
4509
|
availableCameras = availableCameras.sort(function (a, b) {
|
|
4506
4510
|
return a.label.toLowerCase().localeCompare(b.label.toLowerCase());
|
|
4507
4511
|
});
|
|
4508
|
-
debug(
|
|
4512
|
+
debug("".concat(LOG_TAG, " cameras have been sorted"), availableCameras);
|
|
4509
4513
|
}
|
|
4510
4514
|
if (preferFrontFacingCamera) {
|
|
4511
4515
|
selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
@@ -4529,7 +4533,7 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
4529
4533
|
selectedCamera || (selectedCamera = availableCameras[1]);
|
|
4530
4534
|
}
|
|
4531
4535
|
selectedCamera || (selectedCamera = availableCameras[0]);
|
|
4532
|
-
debug(
|
|
4536
|
+
debug("".concat(LOG_TAG, " selectedCamera"), selectedCamera);
|
|
4533
4537
|
set({
|
|
4534
4538
|
videoDevice: selectedCamera
|
|
4535
4539
|
});
|
|
@@ -4557,7 +4561,7 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
4557
4561
|
_f.label = 3;
|
|
4558
4562
|
case 3:
|
|
4559
4563
|
_f.trys.push([3, 5,, 6]);
|
|
4560
|
-
debug(
|
|
4564
|
+
debug("".concat(LOG_TAG, " obtaining camera access with constraints"), constraints);
|
|
4561
4565
|
return [4 /*yield*/, navigator.mediaDevices.getUserMedia(constraints)];
|
|
4562
4566
|
case 4:
|
|
4563
4567
|
stream_1 = _f.sent();
|
|
@@ -4589,21 +4593,21 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
4589
4593
|
})];
|
|
4590
4594
|
case 8:
|
|
4591
4595
|
stream_1 = _f.sent();
|
|
4592
|
-
debug(
|
|
4596
|
+
debug("".concat(LOG_TAG, " opened stream with no width and height constraints"));
|
|
4593
4597
|
return [3 /*break*/, 10];
|
|
4594
4598
|
case 9:
|
|
4595
4599
|
e_2 = _f.sent();
|
|
4596
|
-
debug(
|
|
4600
|
+
debug("".concat(LOG_TAG, " cannot open stream at all"), e_2);
|
|
4597
4601
|
return [3 /*break*/, 10];
|
|
4598
4602
|
case 10:
|
|
4599
4603
|
if (!stream_1) {
|
|
4600
|
-
error(
|
|
4604
|
+
error("".concat(LOG_TAG, " failed to open camera"));
|
|
4601
4605
|
throw new Error('failed to open camera: ');
|
|
4602
4606
|
}
|
|
4603
|
-
debug(
|
|
4607
|
+
debug("".concat(LOG_TAG, " camera access requested with constraints"), constraints);
|
|
4604
4608
|
handleStreamEnded_1 = function handleStreamEnded_1() {
|
|
4605
4609
|
if (preferIphoneContinuityCamera && get().iphoneContinuityCameraAvailable) {
|
|
4606
|
-
debug(
|
|
4610
|
+
debug("".concat(LOG_TAG, " someone unplugged the continuity camera"), camera);
|
|
4607
4611
|
videoStream = null;
|
|
4608
4612
|
set({
|
|
4609
4613
|
videoDevice: null,
|
|
@@ -4611,10 +4615,8 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
4611
4615
|
iphoneContinuityCameraAvailable: false,
|
|
4612
4616
|
iphoneContinuityCameraDenied: true
|
|
4613
4617
|
});
|
|
4614
|
-
get().requestCameraAccess();
|
|
4615
4618
|
} else {
|
|
4616
|
-
debug(
|
|
4617
|
-
get().releaseCameraAccess();
|
|
4619
|
+
debug("".concat(LOG_TAG, " someone unplugged the webcam"), camera);
|
|
4618
4620
|
videoStream = null;
|
|
4619
4621
|
set({
|
|
4620
4622
|
videoDevice: null,
|
|
@@ -4624,16 +4626,25 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
4624
4626
|
});
|
|
4625
4627
|
}
|
|
4626
4628
|
};
|
|
4627
|
-
(_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('ended',
|
|
4629
|
+
(_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('ended', function () {
|
|
4630
|
+
debug("".concat(LOG_TAG, ":handleStreamEnded HTMLVideoElement ended event"));
|
|
4631
|
+
handleStreamEnded_1();
|
|
4632
|
+
});
|
|
4628
4633
|
videoTrack_1 = stream_1.getVideoTracks()[0];
|
|
4629
|
-
videoTrack_1.onended =
|
|
4634
|
+
videoTrack_1.onended = function () {
|
|
4635
|
+
debug("".concat(LOG_TAG, ":handleStreamEnded MediaStreamTrack onended"), 'videoStream', videoStream, 'videoTrack', videoTrack_1, 'camera', camera);
|
|
4636
|
+
handleStreamEnded_1();
|
|
4637
|
+
};
|
|
4630
4638
|
camera = obtainCameraAccess(stream_1, selectedCamera.label, videoRef.current);
|
|
4631
4639
|
setTimeout(function () {
|
|
4632
4640
|
var _a;
|
|
4633
4641
|
// iOS 17 has a strange behavior where the video track flickers between muted and unmuted
|
|
4634
4642
|
// when the camera access is being requested. This delay is a workaround for that.
|
|
4635
4643
|
videoTrack_1.onmute = function () {
|
|
4636
|
-
if (videoTrack_1.readyState !== 'live')
|
|
4644
|
+
if (videoTrack_1.readyState !== 'live') {
|
|
4645
|
+
debug("".concat(LOG_TAG, ":handleStreamEnded MediaStreamTrack onmute"), 'videoStream', videoStream, 'videoTrack', videoTrack_1);
|
|
4646
|
+
handleStreamEnded_1();
|
|
4647
|
+
}
|
|
4637
4648
|
};
|
|
4638
4649
|
videoStream = stream_1;
|
|
4639
4650
|
var isRearFacing = (_a = camera === null || camera === void 0 ? void 0 : camera.isRearFacing) !== null && _a !== void 0 ? _a : false;
|
|
@@ -4647,12 +4658,12 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
4647
4658
|
case 11:
|
|
4648
4659
|
e_3 = _f.sent();
|
|
4649
4660
|
if (e_3.name === 'NotAllowedError' || ((_e = e_3.message) === null || _e === void 0 ? void 0 : _e.includes('Could not start video source'))) {
|
|
4650
|
-
error(
|
|
4661
|
+
error("".concat(LOG_TAG, " camera access has been blocked by the user"), e_3);
|
|
4651
4662
|
set({
|
|
4652
4663
|
cameraAccessDenied: true
|
|
4653
4664
|
});
|
|
4654
4665
|
} else {
|
|
4655
|
-
error(
|
|
4666
|
+
error("".concat(LOG_TAG, " camera access encountered some other error"), e_3);
|
|
4656
4667
|
throw e_3;
|
|
4657
4668
|
}
|
|
4658
4669
|
return [3 /*break*/, 12];
|
|
@@ -4665,12 +4676,10 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
4665
4676
|
releaseCameraAccess: function releaseCameraAccess() {
|
|
4666
4677
|
return __awaiter(this, void 0, void 0, function () {
|
|
4667
4678
|
return __generator(this, function (_a) {
|
|
4679
|
+
debug("".concat(LOG_TAG, " release camera access"), 'camera', camera, 'videoStream', videoStream);
|
|
4668
4680
|
if (!camera) return [2 /*return*/];
|
|
4669
|
-
camera.release();
|
|
4681
|
+
camera.release(); // NOTE calls stop Camera tracks internally as noted above
|
|
4670
4682
|
camera = null;
|
|
4671
|
-
videoStream === null || videoStream === void 0 ? void 0 : videoStream.getTracks().forEach(function (track) {
|
|
4672
|
-
track.stop();
|
|
4673
|
-
});
|
|
4674
4683
|
videoStream = null;
|
|
4675
4684
|
set({
|
|
4676
4685
|
cameraReady: false,
|
|
@@ -4725,7 +4734,7 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
4725
4734
|
return [3 /*break*/, 4];
|
|
4726
4735
|
case 3:
|
|
4727
4736
|
e_4 = _a.sent();
|
|
4728
|
-
debug(
|
|
4737
|
+
debug("".concat(LOG_TAG, " failed to open microphone"), e_4);
|
|
4729
4738
|
set({
|
|
4730
4739
|
microphoneAccessDenied: true
|
|
4731
4740
|
});
|
|
@@ -4752,6 +4761,7 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
4752
4761
|
});
|
|
4753
4762
|
});
|
|
4754
4763
|
if (config.requestAccessAutomatically) {
|
|
4764
|
+
debug("".concat(LOG_TAG, " requesting camera access automatically"));
|
|
4755
4765
|
void store.getState().requestCameraAccess();
|
|
4756
4766
|
}
|
|
4757
4767
|
return _assign(_assign({}, store), {
|
|
@@ -14399,9 +14409,6 @@ function inferBlobType(blobPart) {
|
|
|
14399
14409
|
|
|
14400
14410
|
var signatureRecorder = null;
|
|
14401
14411
|
var signatureChunks = [];
|
|
14402
|
-
var ondataavailableInvocations = [];
|
|
14403
|
-
var ondataavailableStartTime;
|
|
14404
|
-
var lastCalculatedVideoChunkRate;
|
|
14405
14412
|
var videoSignatureInitialState = {
|
|
14406
14413
|
startRecording: function startRecording() {
|
|
14407
14414
|
return null;
|
|
@@ -14426,10 +14433,6 @@ var videoSignatureInitialState = {
|
|
|
14426
14433
|
signatureValid: false,
|
|
14427
14434
|
supportsRequestVideoFrameCallback: undefined,
|
|
14428
14435
|
supportsRoundRect: undefined,
|
|
14429
|
-
nullChunksReceived: 0,
|
|
14430
|
-
timesSignatureCleared: 0,
|
|
14431
|
-
finalChunkReceived: false,
|
|
14432
|
-
requestDataInterval: undefined,
|
|
14433
14436
|
onSignatureVideoCaptured: function onSignatureVideoCaptured() {
|
|
14434
14437
|
return null;
|
|
14435
14438
|
}
|
|
@@ -14442,11 +14445,8 @@ var useVideoSignatureStore = zustand.create()(middleware.devtools(function (set,
|
|
|
14442
14445
|
captureAudio = false;
|
|
14443
14446
|
}
|
|
14444
14447
|
if (!camera) throw new Error('Camera not found');
|
|
14445
|
-
// clear whatever we have recorded so far.
|
|
14448
|
+
// set our flag and clear whatever we have recorded so far.
|
|
14446
14449
|
signatureChunks = [];
|
|
14447
|
-
ondataavailableInvocations = [];
|
|
14448
|
-
ondataavailableStartTime = undefined;
|
|
14449
|
-
lastCalculatedVideoChunkRate = undefined;
|
|
14450
14450
|
// start recording from the output canvas to capture the signature
|
|
14451
14451
|
var outputStream = (_a = get().outputCanvas.current) === null || _a === void 0 ? void 0 : _a.captureStream(24);
|
|
14452
14452
|
if (!outputStream) throw new Error('outputStream not found');
|
|
@@ -14464,123 +14464,77 @@ var useVideoSignatureStore = zustand.create()(middleware.devtools(function (set,
|
|
|
14464
14464
|
recordingStartedAt: e.timeStamp
|
|
14465
14465
|
});
|
|
14466
14466
|
};
|
|
14467
|
+
var hasFirstChunk = false;
|
|
14467
14468
|
signatureRecorder.ondataavailable = function (event) {
|
|
14468
|
-
var now = performance.now();
|
|
14469
14469
|
signatureChunks.push(event.data);
|
|
14470
|
-
|
|
14471
|
-
|
|
14472
|
-
set(
|
|
14473
|
-
|
|
14474
|
-
|
|
14475
|
-
firstChunkReceivedAt: (_a = state.firstChunkReceivedAt) !== null && _a !== void 0 ? _a : now,
|
|
14476
|
-
lastChunkReceivedAt: now
|
|
14477
|
-
};
|
|
14470
|
+
if (!hasFirstChunk) {
|
|
14471
|
+
hasFirstChunk = true;
|
|
14472
|
+
set({
|
|
14473
|
+
firstChunkReceivedAt: performance.now(),
|
|
14474
|
+
lastChunkReceivedAt: performance.now()
|
|
14478
14475
|
});
|
|
14479
14476
|
} else {
|
|
14480
|
-
set(
|
|
14481
|
-
|
|
14482
|
-
return {
|
|
14483
|
-
nullChunksReceived: state.nullChunksReceived + 1,
|
|
14484
|
-
firstNullChunkReceivedAt: (_a = state.firstNullChunkReceivedAt) !== null && _a !== void 0 ? _a : now,
|
|
14485
|
-
lastNullChunkReceivedAt: now
|
|
14486
|
-
};
|
|
14477
|
+
set({
|
|
14478
|
+
lastChunkReceivedAt: performance.now()
|
|
14487
14479
|
});
|
|
14488
14480
|
}
|
|
14489
14481
|
};
|
|
14490
|
-
signatureRecorder.start();
|
|
14491
|
-
var interval = setInterval(function () {
|
|
14492
|
-
return signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.requestData();
|
|
14493
|
-
}, 250);
|
|
14482
|
+
signatureRecorder.start(250);
|
|
14494
14483
|
set({
|
|
14495
|
-
requestDataInterval: interval,
|
|
14496
14484
|
recordingStartRequestedAt: performance.now()
|
|
14497
14485
|
});
|
|
14498
14486
|
},
|
|
14499
14487
|
stopRecording: function stopRecording(signatureData, imageUrl) {
|
|
14500
14488
|
return __awaiter(this, void 0, void 0, function () {
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
return __generator(this, function (_b) {
|
|
14505
|
-
if (get().recordingStoppedAt) return [2 /*return*/];
|
|
14506
|
-
recordingStoppedAt = performance.now();
|
|
14507
|
-
set({
|
|
14508
|
-
recordingStoppedAt: recordingStoppedAt
|
|
14509
|
-
});
|
|
14510
|
-
mimeType = inferBlobType(signatureChunks[0]) || (signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.mimeType) || 'video/mp4';
|
|
14511
|
-
blob = new Blob(signatureChunks, {
|
|
14512
|
-
type: mimeType
|
|
14513
|
-
});
|
|
14514
|
-
signatureChunks = [];
|
|
14515
|
-
signatureRecorder = null;
|
|
14516
|
-
_a = get(), onSignatureVideoCaptured = _a.onSignatureVideoCaptured, recordingStartRequestedAt = _a.recordingStartRequestedAt, recordingStartedAt = _a.recordingStartedAt, firstChunkReceivedAt = _a.firstChunkReceivedAt, signatureStartedAt = _a.signatureStartedAt, signatureEndedAt = _a.signatureEndedAt, acceptClickedAt = _a.acceptClickedAt, clearClickedAt = _a.clearClickedAt, recordingStopRequestedAt = _a.recordingStopRequestedAt, lastChunkReceivedAt = _a.lastChunkReceivedAt, supportsRequestVideoFrameCallback = _a.supportsRequestVideoFrameCallback, supportsRoundRect = _a.supportsRoundRect, nullChunksReceived = _a.nullChunksReceived, firstNullChunkReceivedAt = _a.firstNullChunkReceivedAt, lastNullChunkReceivedAt = _a.lastNullChunkReceivedAt, timesSignatureCleared = _a.timesSignatureCleared;
|
|
14517
|
-
metadata = {
|
|
14518
|
-
mimeType: mimeType,
|
|
14519
|
-
browserFeatures: {
|
|
14520
|
-
supportsRoundRect: supportsRoundRect,
|
|
14521
|
-
supportsRequestVideoFrameCallback: supportsRequestVideoFrameCallback
|
|
14522
|
-
},
|
|
14523
|
-
diagnostics: {
|
|
14524
|
-
nullChunksReceived: nullChunksReceived,
|
|
14525
|
-
firstNullChunkReceivedAt: firstNullChunkReceivedAt ? Math.ceil(firstNullChunkReceivedAt) : 0,
|
|
14526
|
-
lastNullChunkReceivedAt: lastNullChunkReceivedAt ? Math.ceil(lastNullChunkReceivedAt) : 0,
|
|
14527
|
-
finalChunkReceived: finalChunkReceived,
|
|
14528
|
-
finalChunkTimedOut: timedOut,
|
|
14529
|
-
finalChunkWaitedMs: Math.ceil(waitedMs),
|
|
14530
|
-
videoChunkRate: lastCalculatedVideoChunkRate,
|
|
14531
|
-
timesSignatureCleared: timesSignatureCleared
|
|
14532
|
-
},
|
|
14533
|
-
timingData: {
|
|
14534
|
-
recordingStartRequestedAt: recordingStartRequestedAt ? Math.ceil(recordingStartRequestedAt) : 0,
|
|
14535
|
-
recordingStartedAt: recordingStartedAt ? Math.ceil(recordingStartedAt) : 0,
|
|
14536
|
-
firstChunkReceivedAt: firstChunkReceivedAt ? Math.ceil(firstChunkReceivedAt) : 0,
|
|
14537
|
-
signatureStartedAt: signatureStartedAt ? Math.ceil(signatureStartedAt) : 0,
|
|
14538
|
-
signatureEndedAt: signatureEndedAt ? Math.ceil(signatureEndedAt) : 0,
|
|
14539
|
-
acceptClickedAt: acceptClickedAt ? Math.ceil(acceptClickedAt) : 0,
|
|
14540
|
-
clearClickedAt: clearClickedAt ? Math.ceil(clearClickedAt) : 0,
|
|
14541
|
-
recordingStopRequestedAt: recordingStopRequestedAt ? Math.ceil(recordingStopRequestedAt) : 0,
|
|
14542
|
-
recordingStoppedAt: Math.ceil(recordingStoppedAt),
|
|
14543
|
-
lastChunkReceivedAt: lastChunkReceivedAt ? Math.ceil(lastChunkReceivedAt) : 0
|
|
14544
|
-
}
|
|
14545
|
-
};
|
|
14546
|
-
debug('signature video metadata', metadata);
|
|
14547
|
-
onSignatureVideoCaptured(blob, signatureData !== null && signatureData !== void 0 ? signatureData : null, imageUrl !== null && imageUrl !== void 0 ? imageUrl : null, metadata);
|
|
14548
|
-
return [2 /*return*/];
|
|
14549
|
-
});
|
|
14550
|
-
});
|
|
14551
|
-
}
|
|
14552
|
-
var _a, recordingStartedAt, recordingStopRequestedAt, isRecording, _b, finalChunkReceived, timedOut, waitedMs;
|
|
14553
|
-
return __generator(this, function (_c) {
|
|
14554
|
-
switch (_c.label) {
|
|
14489
|
+
var _this = this;
|
|
14490
|
+
return __generator(this, function (_a) {
|
|
14491
|
+
switch (_a.label) {
|
|
14555
14492
|
case 0:
|
|
14556
|
-
_a = get(), recordingStartedAt = _a.recordingStartedAt, recordingStopRequestedAt = _a.recordingStopRequestedAt;
|
|
14557
|
-
isRecording = !!recordingStartedAt && !recordingStopRequestedAt;
|
|
14558
|
-
if (!isRecording) return [2 /*return*/];
|
|
14559
14493
|
set({
|
|
14560
|
-
recordingStopRequestedAt: performance.now()
|
|
14561
|
-
recordingStoppedAt: undefined
|
|
14494
|
+
recordingStopRequestedAt: performance.now()
|
|
14562
14495
|
});
|
|
14563
|
-
|
|
14564
|
-
return [4 /*yield*/, waitForOneMoreChunk()
|
|
14565
|
-
// this represents the time that it is safe to release the camera access
|
|
14566
|
-
];
|
|
14496
|
+
if (!signatureRecorder) return [2 /*return*/];
|
|
14497
|
+
return [4 /*yield*/, waitForOneMoreChunk()];
|
|
14567
14498
|
case 1:
|
|
14568
|
-
|
|
14569
|
-
|
|
14570
|
-
|
|
14571
|
-
|
|
14572
|
-
|
|
14573
|
-
|
|
14574
|
-
|
|
14499
|
+
_a.sent();
|
|
14500
|
+
signatureRecorder.onstop = function () {
|
|
14501
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
14502
|
+
var recordingStoppedAt, mimeType, blob, _a, onSignatureVideoCaptured, recordingStartRequestedAt, recordingStartedAt, firstChunkReceivedAt, signatureStartedAt, signatureEndedAt, acceptClickedAt, recordingStopRequestedAt, lastChunkReceivedAt, supportsRequestVideoFrameCallback, supportsRoundRect;
|
|
14503
|
+
return __generator(this, function (_b) {
|
|
14504
|
+
recordingStoppedAt = performance.now();
|
|
14505
|
+
set({
|
|
14506
|
+
recordingStoppedAt: recordingStoppedAt
|
|
14507
|
+
});
|
|
14508
|
+
mimeType = inferBlobType(signatureChunks[0]) || (signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.mimeType) || 'video/mp4';
|
|
14509
|
+
blob = new Blob(signatureChunks, {
|
|
14510
|
+
type: mimeType
|
|
14511
|
+
});
|
|
14512
|
+
signatureChunks = [];
|
|
14513
|
+
signatureRecorder = null;
|
|
14514
|
+
_a = get(), onSignatureVideoCaptured = _a.onSignatureVideoCaptured, recordingStartRequestedAt = _a.recordingStartRequestedAt, recordingStartedAt = _a.recordingStartedAt, firstChunkReceivedAt = _a.firstChunkReceivedAt, signatureStartedAt = _a.signatureStartedAt, signatureEndedAt = _a.signatureEndedAt, acceptClickedAt = _a.acceptClickedAt, recordingStopRequestedAt = _a.recordingStopRequestedAt, lastChunkReceivedAt = _a.lastChunkReceivedAt, supportsRequestVideoFrameCallback = _a.supportsRequestVideoFrameCallback, supportsRoundRect = _a.supportsRoundRect;
|
|
14515
|
+
onSignatureVideoCaptured(blob, signatureData !== null && signatureData !== void 0 ? signatureData : null, imageUrl !== null && imageUrl !== void 0 ? imageUrl : null, {
|
|
14516
|
+
mimeType: mimeType,
|
|
14517
|
+
browserFeatures: {
|
|
14518
|
+
supportsRoundRect: supportsRoundRect,
|
|
14519
|
+
supportsRequestVideoFrameCallback: supportsRequestVideoFrameCallback
|
|
14520
|
+
},
|
|
14521
|
+
timingData: {
|
|
14522
|
+
recordingStartRequestedAt: recordingStartRequestedAt ? Math.ceil(recordingStartRequestedAt) : 0,
|
|
14523
|
+
recordingStartedAt: recordingStartedAt ? Math.ceil(recordingStartedAt) : 0,
|
|
14524
|
+
firstChunkReceivedAt: firstChunkReceivedAt ? Math.ceil(firstChunkReceivedAt) : 0,
|
|
14525
|
+
signatureStartedAt: signatureStartedAt ? Math.ceil(signatureStartedAt) : 0,
|
|
14526
|
+
signatureEndedAt: signatureEndedAt ? Math.ceil(signatureEndedAt) : 0,
|
|
14527
|
+
acceptClickedAt: acceptClickedAt ? Math.ceil(acceptClickedAt) : 0,
|
|
14528
|
+
recordingStopRequestedAt: recordingStopRequestedAt ? Math.ceil(recordingStopRequestedAt) : 0,
|
|
14529
|
+
recordingStoppedAt: Math.ceil(recordingStoppedAt),
|
|
14530
|
+
lastChunkReceivedAt: lastChunkReceivedAt ? Math.ceil(lastChunkReceivedAt) : 0
|
|
14531
|
+
}
|
|
14532
|
+
});
|
|
14533
|
+
return [2 /*return*/];
|
|
14534
|
+
});
|
|
14535
|
+
});
|
|
14536
|
+
};
|
|
14575
14537
|
signatureRecorder.stop();
|
|
14576
|
-
return [3 /*break*/, 4];
|
|
14577
|
-
case 2:
|
|
14578
|
-
warn('signature recorder not found, processing video immediately');
|
|
14579
|
-
return [4 /*yield*/, processVideo()];
|
|
14580
|
-
case 3:
|
|
14581
|
-
_c.sent();
|
|
14582
|
-
_c.label = 4;
|
|
14583
|
-
case 4:
|
|
14584
14538
|
return [2 /*return*/];
|
|
14585
14539
|
}
|
|
14586
14540
|
});
|
|
@@ -14588,9 +14542,6 @@ var useVideoSignatureStore = zustand.create()(middleware.devtools(function (set,
|
|
|
14588
14542
|
},
|
|
14589
14543
|
clearRecordedData: function clearRecordedData() {
|
|
14590
14544
|
signatureChunks = [];
|
|
14591
|
-
ondataavailableInvocations = [];
|
|
14592
|
-
ondataavailableStartTime = undefined;
|
|
14593
|
-
lastCalculatedVideoChunkRate = undefined;
|
|
14594
14545
|
signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.stop();
|
|
14595
14546
|
signatureRecorder = null;
|
|
14596
14547
|
set({
|
|
@@ -14605,13 +14556,8 @@ var useVideoSignatureStore = zustand.create()(middleware.devtools(function (set,
|
|
|
14605
14556
|
signatureStartedAt: undefined,
|
|
14606
14557
|
signatureEndedAt: undefined,
|
|
14607
14558
|
acceptClickedAt: undefined,
|
|
14608
|
-
// Note: clearClickedAt is intentionally preserved for telemetry metadata
|
|
14609
14559
|
supportsRequestVideoFrameCallback: undefined,
|
|
14610
|
-
supportsRoundRect: undefined
|
|
14611
|
-
nullChunksReceived: 0,
|
|
14612
|
-
firstNullChunkReceivedAt: undefined,
|
|
14613
|
-
lastNullChunkReceivedAt: undefined,
|
|
14614
|
-
finalChunkReceived: false
|
|
14560
|
+
supportsRoundRect: undefined
|
|
14615
14561
|
});
|
|
14616
14562
|
}
|
|
14617
14563
|
});
|
|
@@ -14621,11 +14567,11 @@ var useVideoSignatureStore = zustand.create()(middleware.devtools(function (set,
|
|
|
14621
14567
|
* @param delayMs - The delay in milliseconds before the first check -- this is used to make sure we get at least one extra second of video.
|
|
14622
14568
|
* @param checkEveryMs - The interval in milliseconds between checks after the initial delay has passed.
|
|
14623
14569
|
* @param timeoutMs - The maximum time in milliseconds to wait for the chunk -- this is used to prevent infinite loops.
|
|
14624
|
-
* @returns A promise that resolves when the delay has passed and at least one chunk has been received received.
|
|
14570
|
+
* @returns A promise that resolves when the delay has passed and at least one chunk has been received received.
|
|
14625
14571
|
*/
|
|
14626
14572
|
function waitForOneMoreChunk(delayMs, checkEveryMs, timeoutMs) {
|
|
14627
14573
|
if (delayMs === void 0) {
|
|
14628
|
-
delayMs =
|
|
14574
|
+
delayMs = 1000;
|
|
14629
14575
|
}
|
|
14630
14576
|
if (checkEveryMs === void 0) {
|
|
14631
14577
|
checkEveryMs = 100;
|
|
@@ -14633,44 +14579,29 @@ function waitForOneMoreChunk(delayMs, checkEveryMs, timeoutMs) {
|
|
|
14633
14579
|
if (timeoutMs === void 0) {
|
|
14634
14580
|
timeoutMs = 3000;
|
|
14635
14581
|
}
|
|
14582
|
+
var start = performance.now();
|
|
14636
14583
|
return new Promise(function (resolve) {
|
|
14637
|
-
var
|
|
14638
|
-
|
|
14639
|
-
var initialLastChunkReceivedAt = (_a = useVideoSignatureStore.getState().lastChunkReceivedAt) !== null && _a !== void 0 ? _a : start;
|
|
14640
|
-
signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.requestData();
|
|
14641
|
-
function checkForChunk() {
|
|
14584
|
+
var initialLastChunkReceivedAt = useVideoSignatureStore.getState().lastChunkReceivedAt;
|
|
14585
|
+
function gotAChunk() {
|
|
14642
14586
|
var lastChunkReceivedAt = useVideoSignatureStore.getState().lastChunkReceivedAt;
|
|
14643
|
-
|
|
14644
|
-
var timedOut = waitedMs > timeoutMs;
|
|
14645
|
-
var finalChunkReceived = !!lastChunkReceivedAt && !!initialLastChunkReceivedAt && lastChunkReceivedAt > initialLastChunkReceivedAt;
|
|
14646
|
-
return {
|
|
14647
|
-
waitedMs: waitedMs,
|
|
14648
|
-
finalChunkReceived: finalChunkReceived,
|
|
14649
|
-
timedOut: timedOut
|
|
14650
|
-
};
|
|
14587
|
+
return performance.now() - start > timeoutMs || !lastChunkReceivedAt || !initialLastChunkReceivedAt || lastChunkReceivedAt > initialLastChunkReceivedAt;
|
|
14651
14588
|
}
|
|
14652
14589
|
setTimeout(function () {
|
|
14653
|
-
// check immediately
|
|
14654
|
-
var result = checkForChunk();
|
|
14655
|
-
if (result.finalChunkReceived || result.timedOut) return resolve(result);
|
|
14590
|
+
if (gotAChunk()) return resolve(); // check immediately
|
|
14656
14591
|
// otherwise, check on a configured interval
|
|
14657
14592
|
var interval = setInterval(function () {
|
|
14658
|
-
|
|
14659
|
-
if (result.finalChunkReceived || result.timedOut) {
|
|
14593
|
+
if (gotAChunk()) {
|
|
14660
14594
|
clearInterval(interval);
|
|
14661
|
-
resolve(
|
|
14595
|
+
resolve();
|
|
14662
14596
|
}
|
|
14663
14597
|
}, checkEveryMs);
|
|
14664
14598
|
}, delayMs);
|
|
14665
14599
|
});
|
|
14666
14600
|
}
|
|
14667
14601
|
function VideoSignatureContextProvider(_a) {
|
|
14602
|
+
var _b, _c;
|
|
14668
14603
|
var children = _a.children;
|
|
14669
|
-
var
|
|
14670
|
-
videoRef = _b.videoRef,
|
|
14671
|
-
videoWidth = _b.videoWidth,
|
|
14672
|
-
videoHeight = _b.videoHeight,
|
|
14673
|
-
releaseCameraAccess = _b.releaseCameraAccess;
|
|
14604
|
+
var videoRef = useCameraStore().videoRef;
|
|
14674
14605
|
var outputCanvas = React.useRef(null);
|
|
14675
14606
|
React.useEffect(function () {
|
|
14676
14607
|
return useVideoSignatureStore.setState({
|
|
@@ -14678,13 +14609,18 @@ function VideoSignatureContextProvider(_a) {
|
|
|
14678
14609
|
});
|
|
14679
14610
|
}, []);
|
|
14680
14611
|
var drawOutputFrame = React.useCallback(function () {
|
|
14681
|
-
if (!outputCanvas.current) return;
|
|
14612
|
+
if (!outputCanvas.current || !videoRef.current) return;
|
|
14682
14613
|
var ctx = outputCanvas.current.getContext('2d');
|
|
14683
14614
|
if (!ctx) return;
|
|
14684
|
-
var _a = [
|
|
14615
|
+
var _a = [videoRef.current.videoWidth, videoRef.current.videoHeight],
|
|
14685
14616
|
w = _a[0],
|
|
14686
14617
|
h = _a[1];
|
|
14687
14618
|
var isPortrait = w < h;
|
|
14619
|
+
// Only update canvas dimensions if they changed (setting dimensions clears the canvas!)
|
|
14620
|
+
if (outputCanvas.current.width !== w || outputCanvas.current.height !== h) {
|
|
14621
|
+
outputCanvas.current.width = w;
|
|
14622
|
+
outputCanvas.current.height = h;
|
|
14623
|
+
}
|
|
14688
14624
|
var rect = [w * (isPortrait ? 0.02 : 0.15),
|
|
14689
14625
|
// x
|
|
14690
14626
|
h * (isPortrait ? 0.15 : 0.25),
|
|
@@ -14693,9 +14629,7 @@ function VideoSignatureContextProvider(_a) {
|
|
|
14693
14629
|
// width
|
|
14694
14630
|
h * (isPortrait ? 0.7 : 0.5) // height
|
|
14695
14631
|
];
|
|
14696
|
-
|
|
14697
|
-
ctx.drawImage(videoRef.current, 0, 0, w, h);
|
|
14698
|
-
}
|
|
14632
|
+
ctx.drawImage(videoRef.current, 0, 0, w, h);
|
|
14699
14633
|
ctx.beginPath();
|
|
14700
14634
|
ctx.fillStyle = 'rgba(255,255,255,0.5)';
|
|
14701
14635
|
var supportsRoundRect = typeof ctx.roundRect === 'function';
|
|
@@ -14717,15 +14651,11 @@ function VideoSignatureContextProvider(_a) {
|
|
|
14717
14651
|
ctx.drawImage.apply(ctx, __spreadArray([signatureCanvas], rect, false));
|
|
14718
14652
|
}
|
|
14719
14653
|
}, [videoRef]);
|
|
14720
|
-
|
|
14721
|
-
React.useEffect(function () {
|
|
14722
|
-
if (finalChunkReceived) releaseCameraAccess();
|
|
14723
|
-
}, [finalChunkReceived, releaseCameraAccess]);
|
|
14724
|
-
useVideoFrameLoop(videoRef, drawOutputFrame, !finalChunkReceived);
|
|
14654
|
+
useVideoFrameLoop(videoRef, drawOutputFrame);
|
|
14725
14655
|
return /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, children, /*#__PURE__*/React__namespace.default.createElement(InvisibleCanvas, {
|
|
14726
14656
|
ref: outputCanvas,
|
|
14727
|
-
width: videoWidth,
|
|
14728
|
-
height: videoHeight
|
|
14657
|
+
width: (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth,
|
|
14658
|
+
height: (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.videoHeight
|
|
14729
14659
|
}));
|
|
14730
14660
|
}
|
|
14731
14661
|
function requestVideoFrameCallback(video, onFrame) {
|
|
@@ -14745,11 +14675,8 @@ function requestVideoFrameCallback(video, onFrame) {
|
|
|
14745
14675
|
};
|
|
14746
14676
|
}
|
|
14747
14677
|
}
|
|
14748
|
-
function videoFrameLoop(video, onFrame
|
|
14749
|
-
if (
|
|
14750
|
-
running = true;
|
|
14751
|
-
}
|
|
14752
|
-
if (!video || !running) return;
|
|
14678
|
+
function videoFrameLoop(video, onFrame) {
|
|
14679
|
+
if (!video) return;
|
|
14753
14680
|
var cancelFn;
|
|
14754
14681
|
var canceled = false;
|
|
14755
14682
|
function onFrameRecursive() {
|
|
@@ -14770,51 +14697,10 @@ function videoFrameLoop(video, onFrame, running) {
|
|
|
14770
14697
|
if (cancelFn !== undefined) cancelFn();
|
|
14771
14698
|
};
|
|
14772
14699
|
}
|
|
14773
|
-
function useVideoFrameLoop(ref, onFrame
|
|
14774
|
-
if (running === void 0) {
|
|
14775
|
-
running = true;
|
|
14776
|
-
}
|
|
14700
|
+
function useVideoFrameLoop(ref, onFrame) {
|
|
14777
14701
|
React.useEffect(function () {
|
|
14778
|
-
return videoFrameLoop(ref.current, onFrame
|
|
14779
|
-
}, [onFrame, ref
|
|
14780
|
-
}
|
|
14781
|
-
function calculateAndStoreOndataavailableRate() {
|
|
14782
|
-
if (ondataavailableInvocations.length < 2 || !ondataavailableStartTime) {
|
|
14783
|
-
lastCalculatedVideoChunkRate = {
|
|
14784
|
-
averageRate: 0,
|
|
14785
|
-
minRate: 0,
|
|
14786
|
-
maxRate: 0,
|
|
14787
|
-
totalChunksReceived: ondataavailableInvocations.length,
|
|
14788
|
-
recordingDurationMs: 0
|
|
14789
|
-
};
|
|
14790
|
-
return;
|
|
14791
|
-
}
|
|
14792
|
-
var totalDuration = ondataavailableInvocations[ondataavailableInvocations.length - 1] - ondataavailableStartTime;
|
|
14793
|
-
var averageRate = (ondataavailableInvocations.length - 1) / (totalDuration / 1000); // invocations per second
|
|
14794
|
-
// Calculate rates for each interval between invocations
|
|
14795
|
-
var rates = [];
|
|
14796
|
-
for (var i = 1; i < ondataavailableInvocations.length; i++) {
|
|
14797
|
-
var intervalMs = ondataavailableInvocations[i] - ondataavailableInvocations[i - 1];
|
|
14798
|
-
var rate = 1000 / intervalMs; // invocations per second for this interval
|
|
14799
|
-
rates.push(rate);
|
|
14800
|
-
}
|
|
14801
|
-
var minRate = Math.min.apply(Math, rates);
|
|
14802
|
-
var maxRate = Math.max.apply(Math, rates);
|
|
14803
|
-
lastCalculatedVideoChunkRate = {
|
|
14804
|
-
averageRate: Math.round(averageRate * 100) / 100,
|
|
14805
|
-
// Round to 2 decimal places
|
|
14806
|
-
minRate: Math.round(minRate * 100) / 100,
|
|
14807
|
-
maxRate: Math.round(maxRate * 100) / 100,
|
|
14808
|
-
totalChunksReceived: ondataavailableInvocations.length,
|
|
14809
|
-
recordingDurationMs: Math.round(totalDuration)
|
|
14810
|
-
};
|
|
14811
|
-
}
|
|
14812
|
-
function trackVideoChunkRate(now) {
|
|
14813
|
-
// Track ondataavailable invocations for rate calculation
|
|
14814
|
-
ondataavailableStartTime !== null && ondataavailableStartTime !== void 0 ? ondataavailableStartTime : ondataavailableStartTime = now;
|
|
14815
|
-
ondataavailableInvocations.push(now);
|
|
14816
|
-
// Calculate and store the current rate
|
|
14817
|
-
calculateAndStoreOndataavailableRate();
|
|
14702
|
+
return videoFrameLoop(ref.current, onFrame);
|
|
14703
|
+
}, [onFrame, ref]);
|
|
14818
14704
|
}
|
|
14819
14705
|
|
|
14820
14706
|
function VideoSignaturePad(_a) {
|
|
@@ -15066,11 +14952,14 @@ function VideoSignatureCaptureComponent(_a, ref) {
|
|
|
15066
14952
|
onHeadTrackingPredictionMade = _o.onPredictionMade,
|
|
15067
14953
|
startHeadTracking = _o.start,
|
|
15068
14954
|
stopHeadTracking = _o.stop;
|
|
15069
|
-
var
|
|
15070
|
-
|
|
15071
|
-
|
|
15072
|
-
|
|
15073
|
-
|
|
14955
|
+
var _p = useVideoSignatureStore(shallow.useShallow(function (state) {
|
|
14956
|
+
return {
|
|
14957
|
+
firstChunkReceivedAt: state.firstChunkReceivedAt,
|
|
14958
|
+
acceptClickedAt: state.acceptClickedAt
|
|
14959
|
+
};
|
|
14960
|
+
})),
|
|
14961
|
+
firstChunkReceivedAt = _p.firstChunkReceivedAt,
|
|
14962
|
+
acceptClickedAt = _p.acceptClickedAt;
|
|
15074
14963
|
React.useImperativeHandle(ref, function () {
|
|
15075
14964
|
return {
|
|
15076
14965
|
clearRecordedData: function clearRecordedData() {
|
|
@@ -15096,15 +14985,15 @@ function VideoSignatureCaptureComponent(_a, ref) {
|
|
|
15096
14985
|
var verbiage = useTranslations(rawVerbiage, {
|
|
15097
14986
|
guidanceMessageText: 'Please sign the box below'
|
|
15098
14987
|
});
|
|
15099
|
-
var
|
|
15100
|
-
headTrackingSatisfied =
|
|
15101
|
-
setHeadTrackingSatisfied =
|
|
15102
|
-
var
|
|
15103
|
-
lastFace =
|
|
15104
|
-
setLastFace =
|
|
15105
|
-
var
|
|
15106
|
-
numFramesWithoutFaces =
|
|
15107
|
-
setNumFramesWithoutFaces =
|
|
14988
|
+
var _q = React.useState(true),
|
|
14989
|
+
headTrackingSatisfied = _q[0],
|
|
14990
|
+
setHeadTrackingSatisfied = _q[1];
|
|
14991
|
+
var _r = React.useState(null),
|
|
14992
|
+
lastFace = _r[0],
|
|
14993
|
+
setLastFace = _r[1];
|
|
14994
|
+
var _s = React.useState(0),
|
|
14995
|
+
numFramesWithoutFaces = _s[0],
|
|
14996
|
+
setNumFramesWithoutFaces = _s[1];
|
|
15108
14997
|
onHeadTrackingPredictionMade(useDebounce.useThrottledCallback(React.useCallback(function (_a) {
|
|
15109
14998
|
var face = _a.face;
|
|
15110
14999
|
if (headTrackingDisabled) return;
|
|
@@ -15119,12 +15008,12 @@ function VideoSignatureCaptureComponent(_a, ref) {
|
|
|
15119
15008
|
return n + 1;
|
|
15120
15009
|
});
|
|
15121
15010
|
}, [headTrackingBoundaryPercentage, headTrackingBoundaryType, headTrackingDisabled, videoHeight, videoWidth]), 16));
|
|
15122
|
-
var
|
|
15123
|
-
containerRef =
|
|
15124
|
-
|
|
15125
|
-
width =
|
|
15126
|
-
|
|
15127
|
-
height =
|
|
15011
|
+
var _t = useResizeObserver(),
|
|
15012
|
+
containerRef = _t.ref,
|
|
15013
|
+
_u = _t.width,
|
|
15014
|
+
width = _u === void 0 ? 1 : _u,
|
|
15015
|
+
_v = _t.height,
|
|
15016
|
+
height = _v === void 0 ? 1 : _v;
|
|
15128
15017
|
var debugScalingDetails = useDebugScalingDetails({
|
|
15129
15018
|
enabled: debugMode,
|
|
15130
15019
|
pageWidth: width,
|
|
@@ -15167,10 +15056,10 @@ function VideoSignatureCaptureComponent(_a, ref) {
|
|
|
15167
15056
|
face: lastFace,
|
|
15168
15057
|
scaling: debugScalingDetails,
|
|
15169
15058
|
color: headTrackingSatisfied ? 'green' : 'red'
|
|
15170
|
-
}))), /*#__PURE__*/React__namespace.default.createElement(DebugStatsPane, null, "Video: ", videoWidth, "x", videoHeight, /*#__PURE__*/React__namespace.default.createElement("br", null), "Recording: ", firstChunkReceivedAt ? 'true' : 'false'))), /*#__PURE__*/React__namespace.default.createElement(ExitCaptureButton, {
|
|
15059
|
+
}))), /*#__PURE__*/React__namespace.default.createElement(DebugStatsPane, null, "Video: ", videoWidth, "x", videoHeight, /*#__PURE__*/React__namespace.default.createElement("br", null), "Recording: ", firstChunkReceivedAt ? 'true' : 'false'))), !acceptClickedAt && ( /*#__PURE__*/React__namespace.default.createElement(ExitCaptureButton, {
|
|
15171
15060
|
onClick: onExit,
|
|
15172
15061
|
className: classNames.exitCaptureBtn
|
|
15173
|
-
}));
|
|
15062
|
+
})));
|
|
15174
15063
|
}
|
|
15175
15064
|
var VideoSignatureCapture = /*#__PURE__*/React.forwardRef(VideoSignatureCaptureComponent);
|
|
15176
15065
|
var Container$2 = styled__default.default.div(templateObject_1$9 || (templateObject_1$9 = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n"], ["\n width: 100%;\n height: 100%;\n"
|
|
@@ -15749,18 +15638,13 @@ function VideoSignatureWizardGuides(_a) {
|
|
|
15749
15638
|
});
|
|
15750
15639
|
}, []);
|
|
15751
15640
|
var onClearBtnClicked = React.useCallback(function () {
|
|
15752
|
-
var _a;
|
|
15753
|
-
var _b = useVideoSignatureStore.getState(),
|
|
15754
|
-
timesSignatureCleared = _b.timesSignatureCleared,
|
|
15755
|
-
signaturePad = _b.signaturePad;
|
|
15641
|
+
var _a, _b;
|
|
15756
15642
|
useVideoSignatureStore.setState({
|
|
15757
|
-
clearClickedAt: performance.now(),
|
|
15758
|
-
timesSignatureCleared: timesSignatureCleared + 1,
|
|
15759
15643
|
signatureStartedAt: undefined,
|
|
15760
15644
|
signaturePadEmpty: true,
|
|
15761
15645
|
signatureValid: false
|
|
15762
15646
|
});
|
|
15763
|
-
(_a =
|
|
15647
|
+
(_b = (_a = useVideoSignatureStore.getState().signaturePad) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.clear();
|
|
15764
15648
|
if (restartVideoOnSignaturePadCleared) {
|
|
15765
15649
|
setTimeout(function () {
|
|
15766
15650
|
useVideoSignatureStore.getState().clearRecordedData();
|
|
@@ -16758,7 +16642,6 @@ var IdVideoCaptureSuccess = function IdVideoCaptureSuccess(props) {
|
|
|
16758
16642
|
idFrontText: 'ID Front Image',
|
|
16759
16643
|
idBackText: 'ID Back Image'
|
|
16760
16644
|
});
|
|
16761
|
-
var requestCameraAccess = useCameraStore().requestCameraAccess;
|
|
16762
16645
|
return /*#__PURE__*/React__namespace.default.createElement(OverlayContainer, {
|
|
16763
16646
|
className: classNames.container
|
|
16764
16647
|
}, /*#__PURE__*/React__namespace.default.createElement(OverlayInner$2, {
|
|
@@ -16817,7 +16700,6 @@ var IdVideoCaptureSuccess = function IdVideoCaptureSuccess(props) {
|
|
|
16817
16700
|
variant: "warning",
|
|
16818
16701
|
className: classNames.retryBtn,
|
|
16819
16702
|
onClick: function onClick() {
|
|
16820
|
-
void requestCameraAccess();
|
|
16821
16703
|
return onRetryClick === null || onRetryClick === void 0 ? void 0 : onRetryClick();
|
|
16822
16704
|
},
|
|
16823
16705
|
colors: colors.retryBtn,
|