idmission-web-sdk 2.3.121 → 2.3.123
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_signature_capture/VideoSignatureCapture.d.ts.map +1 -1
- package/dist/components/video_signature_capture/VideoSignatureContext.d.ts +0 -25
- 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/sdk2.cjs.development.js +108 -226
- 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 +108 -226
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +108 -226
- 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 +1 -1
package/dist/sdk2.esm.js
CHANGED
|
@@ -205,7 +205,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
205
205
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
-
var webSdkVersion = '2.3.
|
|
208
|
+
var webSdkVersion = '2.3.123';
|
|
209
209
|
|
|
210
210
|
function getPlatform() {
|
|
211
211
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -14368,9 +14368,6 @@ function inferBlobType(blobPart) {
|
|
|
14368
14368
|
|
|
14369
14369
|
var signatureRecorder = null;
|
|
14370
14370
|
var signatureChunks = [];
|
|
14371
|
-
var ondataavailableInvocations = [];
|
|
14372
|
-
var ondataavailableStartTime;
|
|
14373
|
-
var lastCalculatedVideoChunkRate;
|
|
14374
14371
|
var videoSignatureInitialState = {
|
|
14375
14372
|
startRecording: function startRecording() {
|
|
14376
14373
|
return null;
|
|
@@ -14395,9 +14392,6 @@ var videoSignatureInitialState = {
|
|
|
14395
14392
|
signatureValid: false,
|
|
14396
14393
|
supportsRequestVideoFrameCallback: undefined,
|
|
14397
14394
|
supportsRoundRect: undefined,
|
|
14398
|
-
nullChunksReceived: 0,
|
|
14399
|
-
timesSignatureCleared: 0,
|
|
14400
|
-
finalChunkReceived: false,
|
|
14401
14395
|
onSignatureVideoCaptured: function onSignatureVideoCaptured() {
|
|
14402
14396
|
return null;
|
|
14403
14397
|
}
|
|
@@ -14410,11 +14404,8 @@ var useVideoSignatureStore = create()(devtools(function (set, get) {
|
|
|
14410
14404
|
captureAudio = false;
|
|
14411
14405
|
}
|
|
14412
14406
|
if (!camera) throw new Error('Camera not found');
|
|
14413
|
-
// clear whatever we have recorded so far.
|
|
14407
|
+
// set our flag and clear whatever we have recorded so far.
|
|
14414
14408
|
signatureChunks = [];
|
|
14415
|
-
ondataavailableInvocations = [];
|
|
14416
|
-
ondataavailableStartTime = undefined;
|
|
14417
|
-
lastCalculatedVideoChunkRate = undefined;
|
|
14418
14409
|
// start recording from the output canvas to capture the signature
|
|
14419
14410
|
var outputStream = (_a = get().outputCanvas.current) === null || _a === void 0 ? void 0 : _a.captureStream(24);
|
|
14420
14411
|
if (!outputStream) throw new Error('outputStream not found');
|
|
@@ -14432,26 +14423,18 @@ var useVideoSignatureStore = create()(devtools(function (set, get) {
|
|
|
14432
14423
|
recordingStartedAt: e.timeStamp
|
|
14433
14424
|
});
|
|
14434
14425
|
};
|
|
14426
|
+
var hasFirstChunk = false;
|
|
14435
14427
|
signatureRecorder.ondataavailable = function (event) {
|
|
14436
|
-
var now = performance.now();
|
|
14437
14428
|
signatureChunks.push(event.data);
|
|
14438
|
-
|
|
14439
|
-
|
|
14440
|
-
set(
|
|
14441
|
-
|
|
14442
|
-
|
|
14443
|
-
firstChunkReceivedAt: (_a = state.firstChunkReceivedAt) !== null && _a !== void 0 ? _a : now,
|
|
14444
|
-
lastChunkReceivedAt: now
|
|
14445
|
-
};
|
|
14429
|
+
if (!hasFirstChunk) {
|
|
14430
|
+
hasFirstChunk = true;
|
|
14431
|
+
set({
|
|
14432
|
+
firstChunkReceivedAt: performance.now(),
|
|
14433
|
+
lastChunkReceivedAt: performance.now()
|
|
14446
14434
|
});
|
|
14447
14435
|
} else {
|
|
14448
|
-
set(
|
|
14449
|
-
|
|
14450
|
-
return {
|
|
14451
|
-
nullChunksReceived: state.nullChunksReceived + 1,
|
|
14452
|
-
firstNullChunkReceivedAt: (_a = state.firstNullChunkReceivedAt) !== null && _a !== void 0 ? _a : now,
|
|
14453
|
-
lastNullChunkReceivedAt: now
|
|
14454
|
-
};
|
|
14436
|
+
set({
|
|
14437
|
+
lastChunkReceivedAt: performance.now()
|
|
14455
14438
|
});
|
|
14456
14439
|
}
|
|
14457
14440
|
};
|
|
@@ -14462,88 +14445,55 @@ var useVideoSignatureStore = create()(devtools(function (set, get) {
|
|
|
14462
14445
|
},
|
|
14463
14446
|
stopRecording: function stopRecording(signatureData, imageUrl) {
|
|
14464
14447
|
return __awaiter(this, void 0, void 0, function () {
|
|
14465
|
-
|
|
14466
|
-
|
|
14467
|
-
|
|
14468
|
-
return __generator(this, function (_b) {
|
|
14469
|
-
if (get().recordingStoppedAt) return [2 /*return*/];
|
|
14470
|
-
recordingStoppedAt = performance.now();
|
|
14471
|
-
set({
|
|
14472
|
-
recordingStoppedAt: recordingStoppedAt
|
|
14473
|
-
});
|
|
14474
|
-
mimeType = inferBlobType(signatureChunks[0]) || (signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.mimeType) || 'video/mp4';
|
|
14475
|
-
blob = new Blob(signatureChunks, {
|
|
14476
|
-
type: mimeType
|
|
14477
|
-
});
|
|
14478
|
-
signatureChunks = [];
|
|
14479
|
-
signatureRecorder = null;
|
|
14480
|
-
_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;
|
|
14481
|
-
metadata = {
|
|
14482
|
-
mimeType: mimeType,
|
|
14483
|
-
browserFeatures: {
|
|
14484
|
-
supportsRoundRect: supportsRoundRect,
|
|
14485
|
-
supportsRequestVideoFrameCallback: supportsRequestVideoFrameCallback
|
|
14486
|
-
},
|
|
14487
|
-
diagnostics: {
|
|
14488
|
-
nullChunksReceived: nullChunksReceived,
|
|
14489
|
-
firstNullChunkReceivedAt: firstNullChunkReceivedAt,
|
|
14490
|
-
lastNullChunkReceivedAt: lastNullChunkReceivedAt,
|
|
14491
|
-
finalChunkReceived: finalChunkReceived,
|
|
14492
|
-
finalChunkTimedOut: timedOut,
|
|
14493
|
-
finalChunkWaitedMs: Math.ceil(waitedMs),
|
|
14494
|
-
videoChunkRate: lastCalculatedVideoChunkRate,
|
|
14495
|
-
timesSignatureCleared: timesSignatureCleared
|
|
14496
|
-
},
|
|
14497
|
-
timingData: {
|
|
14498
|
-
recordingStartRequestedAt: recordingStartRequestedAt ? Math.ceil(recordingStartRequestedAt) : 0,
|
|
14499
|
-
recordingStartedAt: recordingStartedAt ? Math.ceil(recordingStartedAt) : 0,
|
|
14500
|
-
firstChunkReceivedAt: firstChunkReceivedAt ? Math.ceil(firstChunkReceivedAt) : 0,
|
|
14501
|
-
signatureStartedAt: signatureStartedAt ? Math.ceil(signatureStartedAt) : 0,
|
|
14502
|
-
signatureEndedAt: signatureEndedAt ? Math.ceil(signatureEndedAt) : 0,
|
|
14503
|
-
acceptClickedAt: acceptClickedAt ? Math.ceil(acceptClickedAt) : 0,
|
|
14504
|
-
clearClickedAt: clearClickedAt ? Math.ceil(clearClickedAt) : 0,
|
|
14505
|
-
recordingStopRequestedAt: recordingStopRequestedAt ? Math.ceil(recordingStopRequestedAt) : 0,
|
|
14506
|
-
recordingStoppedAt: Math.ceil(recordingStoppedAt),
|
|
14507
|
-
lastChunkReceivedAt: lastChunkReceivedAt ? Math.ceil(lastChunkReceivedAt) : 0
|
|
14508
|
-
}
|
|
14509
|
-
};
|
|
14510
|
-
debug('signature video metadata', metadata);
|
|
14511
|
-
onSignatureVideoCaptured(blob, signatureData !== null && signatureData !== void 0 ? signatureData : null, imageUrl !== null && imageUrl !== void 0 ? imageUrl : null, metadata);
|
|
14512
|
-
return [2 /*return*/];
|
|
14513
|
-
});
|
|
14514
|
-
});
|
|
14515
|
-
}
|
|
14516
|
-
var _a, recordingStartedAt, recordingStopRequestedAt, isRecording, _b, finalChunkReceived, timedOut, waitedMs;
|
|
14517
|
-
return __generator(this, function (_c) {
|
|
14518
|
-
switch (_c.label) {
|
|
14448
|
+
var _this = this;
|
|
14449
|
+
return __generator(this, function (_a) {
|
|
14450
|
+
switch (_a.label) {
|
|
14519
14451
|
case 0:
|
|
14520
|
-
_a = get(), recordingStartedAt = _a.recordingStartedAt, recordingStopRequestedAt = _a.recordingStopRequestedAt;
|
|
14521
|
-
isRecording = !!recordingStartedAt && !recordingStopRequestedAt;
|
|
14522
|
-
if (!isRecording) return [2 /*return*/];
|
|
14523
14452
|
set({
|
|
14524
|
-
recordingStopRequestedAt: performance.now()
|
|
14525
|
-
recordingStoppedAt: undefined
|
|
14453
|
+
recordingStopRequestedAt: performance.now()
|
|
14526
14454
|
});
|
|
14527
|
-
return [
|
|
14528
|
-
|
|
14529
|
-
];
|
|
14455
|
+
if (!signatureRecorder) return [2 /*return*/];
|
|
14456
|
+
return [4 /*yield*/, waitForOneMoreChunk()];
|
|
14530
14457
|
case 1:
|
|
14531
|
-
|
|
14532
|
-
|
|
14533
|
-
|
|
14534
|
-
|
|
14535
|
-
|
|
14536
|
-
|
|
14537
|
-
|
|
14458
|
+
_a.sent();
|
|
14459
|
+
signatureRecorder.onstop = function () {
|
|
14460
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
14461
|
+
var recordingStoppedAt, mimeType, blob, _a, onSignatureVideoCaptured, recordingStartRequestedAt, recordingStartedAt, firstChunkReceivedAt, signatureStartedAt, signatureEndedAt, acceptClickedAt, recordingStopRequestedAt, lastChunkReceivedAt, supportsRequestVideoFrameCallback, supportsRoundRect;
|
|
14462
|
+
return __generator(this, function (_b) {
|
|
14463
|
+
recordingStoppedAt = performance.now();
|
|
14464
|
+
set({
|
|
14465
|
+
recordingStoppedAt: recordingStoppedAt
|
|
14466
|
+
});
|
|
14467
|
+
mimeType = inferBlobType(signatureChunks[0]) || (signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.mimeType) || 'video/mp4';
|
|
14468
|
+
blob = new Blob(signatureChunks, {
|
|
14469
|
+
type: mimeType
|
|
14470
|
+
});
|
|
14471
|
+
signatureChunks = [];
|
|
14472
|
+
signatureRecorder = null;
|
|
14473
|
+
_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;
|
|
14474
|
+
onSignatureVideoCaptured(blob, signatureData !== null && signatureData !== void 0 ? signatureData : null, imageUrl !== null && imageUrl !== void 0 ? imageUrl : null, {
|
|
14475
|
+
mimeType: mimeType,
|
|
14476
|
+
browserFeatures: {
|
|
14477
|
+
supportsRoundRect: supportsRoundRect,
|
|
14478
|
+
supportsRequestVideoFrameCallback: supportsRequestVideoFrameCallback
|
|
14479
|
+
},
|
|
14480
|
+
timingData: {
|
|
14481
|
+
recordingStartRequestedAt: recordingStartRequestedAt ? Math.ceil(recordingStartRequestedAt) : 0,
|
|
14482
|
+
recordingStartedAt: recordingStartedAt ? Math.ceil(recordingStartedAt) : 0,
|
|
14483
|
+
firstChunkReceivedAt: firstChunkReceivedAt ? Math.ceil(firstChunkReceivedAt) : 0,
|
|
14484
|
+
signatureStartedAt: signatureStartedAt ? Math.ceil(signatureStartedAt) : 0,
|
|
14485
|
+
signatureEndedAt: signatureEndedAt ? Math.ceil(signatureEndedAt) : 0,
|
|
14486
|
+
acceptClickedAt: acceptClickedAt ? Math.ceil(acceptClickedAt) : 0,
|
|
14487
|
+
recordingStopRequestedAt: recordingStopRequestedAt ? Math.ceil(recordingStopRequestedAt) : 0,
|
|
14488
|
+
recordingStoppedAt: Math.ceil(recordingStoppedAt),
|
|
14489
|
+
lastChunkReceivedAt: lastChunkReceivedAt ? Math.ceil(lastChunkReceivedAt) : 0
|
|
14490
|
+
}
|
|
14491
|
+
});
|
|
14492
|
+
return [2 /*return*/];
|
|
14493
|
+
});
|
|
14494
|
+
});
|
|
14495
|
+
};
|
|
14538
14496
|
signatureRecorder.stop();
|
|
14539
|
-
return [3 /*break*/, 4];
|
|
14540
|
-
case 2:
|
|
14541
|
-
warn('signature recorder not found, processing video immediately');
|
|
14542
|
-
return [4 /*yield*/, processVideo()];
|
|
14543
|
-
case 3:
|
|
14544
|
-
_c.sent();
|
|
14545
|
-
_c.label = 4;
|
|
14546
|
-
case 4:
|
|
14547
14497
|
return [2 /*return*/];
|
|
14548
14498
|
}
|
|
14549
14499
|
});
|
|
@@ -14551,9 +14501,6 @@ var useVideoSignatureStore = create()(devtools(function (set, get) {
|
|
|
14551
14501
|
},
|
|
14552
14502
|
clearRecordedData: function clearRecordedData() {
|
|
14553
14503
|
signatureChunks = [];
|
|
14554
|
-
ondataavailableInvocations = [];
|
|
14555
|
-
ondataavailableStartTime = undefined;
|
|
14556
|
-
lastCalculatedVideoChunkRate = undefined;
|
|
14557
14504
|
signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.stop();
|
|
14558
14505
|
signatureRecorder = null;
|
|
14559
14506
|
set({
|
|
@@ -14568,13 +14515,8 @@ var useVideoSignatureStore = create()(devtools(function (set, get) {
|
|
|
14568
14515
|
signatureStartedAt: undefined,
|
|
14569
14516
|
signatureEndedAt: undefined,
|
|
14570
14517
|
acceptClickedAt: undefined,
|
|
14571
|
-
clearClickedAt: undefined,
|
|
14572
14518
|
supportsRequestVideoFrameCallback: undefined,
|
|
14573
|
-
supportsRoundRect: undefined
|
|
14574
|
-
nullChunksReceived: 0,
|
|
14575
|
-
firstNullChunkReceivedAt: undefined,
|
|
14576
|
-
lastNullChunkReceivedAt: undefined,
|
|
14577
|
-
finalChunkReceived: false
|
|
14519
|
+
supportsRoundRect: undefined
|
|
14578
14520
|
});
|
|
14579
14521
|
}
|
|
14580
14522
|
});
|
|
@@ -14584,11 +14526,11 @@ var useVideoSignatureStore = create()(devtools(function (set, get) {
|
|
|
14584
14526
|
* @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.
|
|
14585
14527
|
* @param checkEveryMs - The interval in milliseconds between checks after the initial delay has passed.
|
|
14586
14528
|
* @param timeoutMs - The maximum time in milliseconds to wait for the chunk -- this is used to prevent infinite loops.
|
|
14587
|
-
* @returns A promise that resolves when the delay has passed and at least one chunk has been received received.
|
|
14529
|
+
* @returns A promise that resolves when the delay has passed and at least one chunk has been received received.
|
|
14588
14530
|
*/
|
|
14589
14531
|
function waitForOneMoreChunk(delayMs, checkEveryMs, timeoutMs) {
|
|
14590
14532
|
if (delayMs === void 0) {
|
|
14591
|
-
delayMs =
|
|
14533
|
+
delayMs = 1000;
|
|
14592
14534
|
}
|
|
14593
14535
|
if (checkEveryMs === void 0) {
|
|
14594
14536
|
checkEveryMs = 100;
|
|
@@ -14596,42 +14538,29 @@ function waitForOneMoreChunk(delayMs, checkEveryMs, timeoutMs) {
|
|
|
14596
14538
|
if (timeoutMs === void 0) {
|
|
14597
14539
|
timeoutMs = 3000;
|
|
14598
14540
|
}
|
|
14541
|
+
var start = performance.now();
|
|
14599
14542
|
return new Promise(function (resolve) {
|
|
14600
|
-
var start = performance.now();
|
|
14601
14543
|
var initialLastChunkReceivedAt = useVideoSignatureStore.getState().lastChunkReceivedAt;
|
|
14602
|
-
function
|
|
14544
|
+
function gotAChunk() {
|
|
14603
14545
|
var lastChunkReceivedAt = useVideoSignatureStore.getState().lastChunkReceivedAt;
|
|
14604
|
-
|
|
14605
|
-
var timedOut = waitedMs > timeoutMs;
|
|
14606
|
-
var finalChunkReceived = !!lastChunkReceivedAt && !!initialLastChunkReceivedAt && lastChunkReceivedAt > initialLastChunkReceivedAt;
|
|
14607
|
-
return {
|
|
14608
|
-
waitedMs: waitedMs,
|
|
14609
|
-
finalChunkReceived: finalChunkReceived,
|
|
14610
|
-
timedOut: timedOut
|
|
14611
|
-
};
|
|
14546
|
+
return performance.now() - start > timeoutMs || !lastChunkReceivedAt || !initialLastChunkReceivedAt || lastChunkReceivedAt > initialLastChunkReceivedAt;
|
|
14612
14547
|
}
|
|
14613
14548
|
setTimeout(function () {
|
|
14614
|
-
// check immediately
|
|
14615
|
-
var result = checkForChunk();
|
|
14616
|
-
if (result.finalChunkReceived || result.timedOut) return resolve(result);
|
|
14549
|
+
if (gotAChunk()) return resolve(); // check immediately
|
|
14617
14550
|
// otherwise, check on a configured interval
|
|
14618
14551
|
var interval = setInterval(function () {
|
|
14619
|
-
|
|
14620
|
-
if (result.finalChunkReceived || result.timedOut) {
|
|
14552
|
+
if (gotAChunk()) {
|
|
14621
14553
|
clearInterval(interval);
|
|
14622
|
-
resolve(
|
|
14554
|
+
resolve();
|
|
14623
14555
|
}
|
|
14624
14556
|
}, checkEveryMs);
|
|
14625
14557
|
}, delayMs);
|
|
14626
14558
|
});
|
|
14627
14559
|
}
|
|
14628
14560
|
function VideoSignatureContextProvider(_a) {
|
|
14561
|
+
var _b, _c;
|
|
14629
14562
|
var children = _a.children;
|
|
14630
|
-
var
|
|
14631
|
-
videoRef = _b.videoRef,
|
|
14632
|
-
videoWidth = _b.videoWidth,
|
|
14633
|
-
videoHeight = _b.videoHeight,
|
|
14634
|
-
releaseCameraAccess = _b.releaseCameraAccess;
|
|
14563
|
+
var videoRef = useCameraStore().videoRef;
|
|
14635
14564
|
var outputCanvas = useRef(null);
|
|
14636
14565
|
useEffect(function () {
|
|
14637
14566
|
return useVideoSignatureStore.setState({
|
|
@@ -14639,13 +14568,18 @@ function VideoSignatureContextProvider(_a) {
|
|
|
14639
14568
|
});
|
|
14640
14569
|
}, []);
|
|
14641
14570
|
var drawOutputFrame = useCallback(function () {
|
|
14642
|
-
if (!outputCanvas.current) return;
|
|
14571
|
+
if (!outputCanvas.current || !videoRef.current) return;
|
|
14643
14572
|
var ctx = outputCanvas.current.getContext('2d');
|
|
14644
14573
|
if (!ctx) return;
|
|
14645
|
-
var _a = [
|
|
14574
|
+
var _a = [videoRef.current.videoWidth, videoRef.current.videoHeight],
|
|
14646
14575
|
w = _a[0],
|
|
14647
14576
|
h = _a[1];
|
|
14648
14577
|
var isPortrait = w < h;
|
|
14578
|
+
// Only update canvas dimensions if they changed (setting dimensions clears the canvas!)
|
|
14579
|
+
if (outputCanvas.current.width !== w || outputCanvas.current.height !== h) {
|
|
14580
|
+
outputCanvas.current.width = w;
|
|
14581
|
+
outputCanvas.current.height = h;
|
|
14582
|
+
}
|
|
14649
14583
|
var rect = [w * (isPortrait ? 0.02 : 0.15),
|
|
14650
14584
|
// x
|
|
14651
14585
|
h * (isPortrait ? 0.15 : 0.25),
|
|
@@ -14654,9 +14588,7 @@ function VideoSignatureContextProvider(_a) {
|
|
|
14654
14588
|
// width
|
|
14655
14589
|
h * (isPortrait ? 0.7 : 0.5) // height
|
|
14656
14590
|
];
|
|
14657
|
-
|
|
14658
|
-
ctx.drawImage(videoRef.current, 0, 0, w, h);
|
|
14659
|
-
}
|
|
14591
|
+
ctx.drawImage(videoRef.current, 0, 0, w, h);
|
|
14660
14592
|
ctx.beginPath();
|
|
14661
14593
|
ctx.fillStyle = 'rgba(255,255,255,0.5)';
|
|
14662
14594
|
var supportsRoundRect = typeof ctx.roundRect === 'function';
|
|
@@ -14678,15 +14610,11 @@ function VideoSignatureContextProvider(_a) {
|
|
|
14678
14610
|
ctx.drawImage.apply(ctx, __spreadArray([signatureCanvas], rect, false));
|
|
14679
14611
|
}
|
|
14680
14612
|
}, [videoRef]);
|
|
14681
|
-
|
|
14682
|
-
useEffect(function () {
|
|
14683
|
-
if (finalChunkReceived) releaseCameraAccess();
|
|
14684
|
-
}, [finalChunkReceived, releaseCameraAccess]);
|
|
14685
|
-
useVideoFrameLoop(videoRef, drawOutputFrame, !finalChunkReceived);
|
|
14613
|
+
useVideoFrameLoop(videoRef, drawOutputFrame);
|
|
14686
14614
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
14687
14615
|
ref: outputCanvas,
|
|
14688
|
-
width: videoWidth,
|
|
14689
|
-
height: videoHeight
|
|
14616
|
+
width: (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth,
|
|
14617
|
+
height: (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.videoHeight
|
|
14690
14618
|
}));
|
|
14691
14619
|
}
|
|
14692
14620
|
function requestVideoFrameCallback(video, onFrame) {
|
|
@@ -14706,11 +14634,8 @@ function requestVideoFrameCallback(video, onFrame) {
|
|
|
14706
14634
|
};
|
|
14707
14635
|
}
|
|
14708
14636
|
}
|
|
14709
|
-
function videoFrameLoop(video, onFrame
|
|
14710
|
-
if (
|
|
14711
|
-
running = true;
|
|
14712
|
-
}
|
|
14713
|
-
if (!video || !running) return;
|
|
14637
|
+
function videoFrameLoop(video, onFrame) {
|
|
14638
|
+
if (!video) return;
|
|
14714
14639
|
var cancelFn;
|
|
14715
14640
|
var canceled = false;
|
|
14716
14641
|
function onFrameRecursive() {
|
|
@@ -14731,51 +14656,10 @@ function videoFrameLoop(video, onFrame, running) {
|
|
|
14731
14656
|
if (cancelFn !== undefined) cancelFn();
|
|
14732
14657
|
};
|
|
14733
14658
|
}
|
|
14734
|
-
function useVideoFrameLoop(ref, onFrame
|
|
14735
|
-
if (running === void 0) {
|
|
14736
|
-
running = true;
|
|
14737
|
-
}
|
|
14659
|
+
function useVideoFrameLoop(ref, onFrame) {
|
|
14738
14660
|
useEffect(function () {
|
|
14739
|
-
return videoFrameLoop(ref.current, onFrame
|
|
14740
|
-
}, [onFrame, ref
|
|
14741
|
-
}
|
|
14742
|
-
function calculateAndStoreOndataavailableRate() {
|
|
14743
|
-
if (ondataavailableInvocations.length < 2 || !ondataavailableStartTime) {
|
|
14744
|
-
lastCalculatedVideoChunkRate = {
|
|
14745
|
-
averageRate: 0,
|
|
14746
|
-
minRate: 0,
|
|
14747
|
-
maxRate: 0,
|
|
14748
|
-
totalChunksReceived: ondataavailableInvocations.length,
|
|
14749
|
-
recordingDurationMs: 0
|
|
14750
|
-
};
|
|
14751
|
-
return;
|
|
14752
|
-
}
|
|
14753
|
-
var totalDuration = ondataavailableInvocations[ondataavailableInvocations.length - 1] - ondataavailableStartTime;
|
|
14754
|
-
var averageRate = (ondataavailableInvocations.length - 1) / (totalDuration / 1000); // invocations per second
|
|
14755
|
-
// Calculate rates for each interval between invocations
|
|
14756
|
-
var rates = [];
|
|
14757
|
-
for (var i = 1; i < ondataavailableInvocations.length; i++) {
|
|
14758
|
-
var intervalMs = ondataavailableInvocations[i] - ondataavailableInvocations[i - 1];
|
|
14759
|
-
var rate = 1000 / intervalMs; // invocations per second for this interval
|
|
14760
|
-
rates.push(rate);
|
|
14761
|
-
}
|
|
14762
|
-
var minRate = Math.min.apply(Math, rates);
|
|
14763
|
-
var maxRate = Math.max.apply(Math, rates);
|
|
14764
|
-
lastCalculatedVideoChunkRate = {
|
|
14765
|
-
averageRate: Math.round(averageRate * 100) / 100,
|
|
14766
|
-
// Round to 2 decimal places
|
|
14767
|
-
minRate: Math.round(minRate * 100) / 100,
|
|
14768
|
-
maxRate: Math.round(maxRate * 100) / 100,
|
|
14769
|
-
totalChunksReceived: ondataavailableInvocations.length,
|
|
14770
|
-
recordingDurationMs: Math.round(totalDuration)
|
|
14771
|
-
};
|
|
14772
|
-
}
|
|
14773
|
-
function trackVideoChunkRate(now) {
|
|
14774
|
-
// Track ondataavailable invocations for rate calculation
|
|
14775
|
-
ondataavailableStartTime !== null && ondataavailableStartTime !== void 0 ? ondataavailableStartTime : ondataavailableStartTime = now;
|
|
14776
|
-
ondataavailableInvocations.push(now);
|
|
14777
|
-
// Calculate and store the current rate
|
|
14778
|
-
calculateAndStoreOndataavailableRate();
|
|
14661
|
+
return videoFrameLoop(ref.current, onFrame);
|
|
14662
|
+
}, [onFrame, ref]);
|
|
14779
14663
|
}
|
|
14780
14664
|
|
|
14781
14665
|
function VideoSignaturePad(_a) {
|
|
@@ -15027,11 +14911,14 @@ function VideoSignatureCaptureComponent(_a, ref) {
|
|
|
15027
14911
|
onHeadTrackingPredictionMade = _o.onPredictionMade,
|
|
15028
14912
|
startHeadTracking = _o.start,
|
|
15029
14913
|
stopHeadTracking = _o.stop;
|
|
15030
|
-
var
|
|
15031
|
-
|
|
15032
|
-
|
|
15033
|
-
|
|
15034
|
-
|
|
14914
|
+
var _p = useVideoSignatureStore(useShallow(function (state) {
|
|
14915
|
+
return {
|
|
14916
|
+
firstChunkReceivedAt: state.firstChunkReceivedAt,
|
|
14917
|
+
acceptClickedAt: state.acceptClickedAt
|
|
14918
|
+
};
|
|
14919
|
+
})),
|
|
14920
|
+
firstChunkReceivedAt = _p.firstChunkReceivedAt,
|
|
14921
|
+
acceptClickedAt = _p.acceptClickedAt;
|
|
15035
14922
|
useImperativeHandle(ref, function () {
|
|
15036
14923
|
return {
|
|
15037
14924
|
clearRecordedData: function clearRecordedData() {
|
|
@@ -15057,15 +14944,15 @@ function VideoSignatureCaptureComponent(_a, ref) {
|
|
|
15057
14944
|
var verbiage = useTranslations(rawVerbiage, {
|
|
15058
14945
|
guidanceMessageText: 'Please sign the box below'
|
|
15059
14946
|
});
|
|
15060
|
-
var
|
|
15061
|
-
headTrackingSatisfied =
|
|
15062
|
-
setHeadTrackingSatisfied =
|
|
15063
|
-
var
|
|
15064
|
-
lastFace =
|
|
15065
|
-
setLastFace =
|
|
15066
|
-
var
|
|
15067
|
-
numFramesWithoutFaces =
|
|
15068
|
-
setNumFramesWithoutFaces =
|
|
14947
|
+
var _q = useState(true),
|
|
14948
|
+
headTrackingSatisfied = _q[0],
|
|
14949
|
+
setHeadTrackingSatisfied = _q[1];
|
|
14950
|
+
var _r = useState(null),
|
|
14951
|
+
lastFace = _r[0],
|
|
14952
|
+
setLastFace = _r[1];
|
|
14953
|
+
var _s = useState(0),
|
|
14954
|
+
numFramesWithoutFaces = _s[0],
|
|
14955
|
+
setNumFramesWithoutFaces = _s[1];
|
|
15069
14956
|
onHeadTrackingPredictionMade(useThrottledCallback(useCallback(function (_a) {
|
|
15070
14957
|
var face = _a.face;
|
|
15071
14958
|
if (headTrackingDisabled) return;
|
|
@@ -15080,12 +14967,12 @@ function VideoSignatureCaptureComponent(_a, ref) {
|
|
|
15080
14967
|
return n + 1;
|
|
15081
14968
|
});
|
|
15082
14969
|
}, [headTrackingBoundaryPercentage, headTrackingBoundaryType, headTrackingDisabled, videoHeight, videoWidth]), 16));
|
|
15083
|
-
var
|
|
15084
|
-
containerRef =
|
|
15085
|
-
|
|
15086
|
-
width =
|
|
15087
|
-
|
|
15088
|
-
height =
|
|
14970
|
+
var _t = useResizeObserver(),
|
|
14971
|
+
containerRef = _t.ref,
|
|
14972
|
+
_u = _t.width,
|
|
14973
|
+
width = _u === void 0 ? 1 : _u,
|
|
14974
|
+
_v = _t.height,
|
|
14975
|
+
height = _v === void 0 ? 1 : _v;
|
|
15089
14976
|
var debugScalingDetails = useDebugScalingDetails({
|
|
15090
14977
|
enabled: debugMode,
|
|
15091
14978
|
pageWidth: width,
|
|
@@ -15128,10 +15015,10 @@ function VideoSignatureCaptureComponent(_a, ref) {
|
|
|
15128
15015
|
face: lastFace,
|
|
15129
15016
|
scaling: debugScalingDetails,
|
|
15130
15017
|
color: headTrackingSatisfied ? 'green' : 'red'
|
|
15131
|
-
}))), /*#__PURE__*/React__default.createElement(DebugStatsPane, null, "Video: ", videoWidth, "x", videoHeight, /*#__PURE__*/React__default.createElement("br", null), "Recording: ", firstChunkReceivedAt ? 'true' : 'false'))), /*#__PURE__*/React__default.createElement(ExitCaptureButton, {
|
|
15018
|
+
}))), /*#__PURE__*/React__default.createElement(DebugStatsPane, null, "Video: ", videoWidth, "x", videoHeight, /*#__PURE__*/React__default.createElement("br", null), "Recording: ", firstChunkReceivedAt ? 'true' : 'false'))), !acceptClickedAt && ( /*#__PURE__*/React__default.createElement(ExitCaptureButton, {
|
|
15132
15019
|
onClick: onExit,
|
|
15133
15020
|
className: classNames.exitCaptureBtn
|
|
15134
|
-
}));
|
|
15021
|
+
})));
|
|
15135
15022
|
}
|
|
15136
15023
|
var VideoSignatureCapture = /*#__PURE__*/forwardRef(VideoSignatureCaptureComponent);
|
|
15137
15024
|
var Container$2 = styled.div(templateObject_1$9 || (templateObject_1$9 = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n"], ["\n width: 100%;\n height: 100%;\n"
|
|
@@ -15710,18 +15597,13 @@ function VideoSignatureWizardGuides(_a) {
|
|
|
15710
15597
|
});
|
|
15711
15598
|
}, []);
|
|
15712
15599
|
var onClearBtnClicked = useCallback(function () {
|
|
15713
|
-
var _a;
|
|
15714
|
-
var _b = useVideoSignatureStore.getState(),
|
|
15715
|
-
timesSignatureCleared = _b.timesSignatureCleared,
|
|
15716
|
-
signaturePad = _b.signaturePad;
|
|
15600
|
+
var _a, _b;
|
|
15717
15601
|
useVideoSignatureStore.setState({
|
|
15718
|
-
clearClickedAt: performance.now(),
|
|
15719
|
-
timesSignatureCleared: timesSignatureCleared + 1,
|
|
15720
15602
|
signatureStartedAt: undefined,
|
|
15721
15603
|
signaturePadEmpty: true,
|
|
15722
15604
|
signatureValid: false
|
|
15723
15605
|
});
|
|
15724
|
-
(_a =
|
|
15606
|
+
(_b = (_a = useVideoSignatureStore.getState().signaturePad) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.clear();
|
|
15725
15607
|
if (restartVideoOnSignaturePadCleared) {
|
|
15726
15608
|
setTimeout(function () {
|
|
15727
15609
|
useVideoSignatureStore.getState().clearRecordedData();
|