idmission-web-sdk 2.3.98 → 2.3.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/components/video_signature_capture/VideoSignatureContext.d.ts +4 -1
- package/dist/components/video_signature_capture/VideoSignatureContext.d.ts.map +1 -1
- package/dist/sdk2.cjs.development.js +119 -100
- 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 +119 -100
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +122 -104
- 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
package/dist/sdk2.esm.js
CHANGED
|
@@ -16,6 +16,7 @@ import { devtools } from 'zustand/middleware';
|
|
|
16
16
|
import { useShallow } from 'zustand/react/shallow';
|
|
17
17
|
import cn from 'clsx';
|
|
18
18
|
import SignatureCanvas from 'react-signature-canvas';
|
|
19
|
+
import { mediaInfoFactory } from 'mediainfo.js';
|
|
19
20
|
import { renderToString } from 'react-dom/server';
|
|
20
21
|
|
|
21
22
|
/******************************************************************************
|
|
@@ -205,7 +206,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
205
206
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
206
207
|
};
|
|
207
208
|
|
|
208
|
-
var webSdkVersion = '2.3.
|
|
209
|
+
var webSdkVersion = '2.3.99';
|
|
209
210
|
|
|
210
211
|
function getPlatform() {
|
|
211
212
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -14295,14 +14296,23 @@ function inferBlobType(blobPart) {
|
|
|
14295
14296
|
return t.length > 0 ? t : undefined;
|
|
14296
14297
|
}
|
|
14297
14298
|
|
|
14298
|
-
|
|
14299
|
-
|
|
14300
|
-
|
|
14301
|
-
|
|
14302
|
-
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14299
|
+
function makeReadChunk(file) {
|
|
14300
|
+
var _this = this;
|
|
14301
|
+
return function (chunkSize, offset) {
|
|
14302
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
14303
|
+
var _a;
|
|
14304
|
+
return __generator(this, function (_b) {
|
|
14305
|
+
switch (_b.label) {
|
|
14306
|
+
case 0:
|
|
14307
|
+
_a = Uint8Array.bind;
|
|
14308
|
+
return [4 /*yield*/, file.slice(offset, offset + chunkSize).arrayBuffer()];
|
|
14309
|
+
case 1:
|
|
14310
|
+
return [2 /*return*/, new (_a.apply(Uint8Array, [void 0, _b.sent()]))()];
|
|
14311
|
+
}
|
|
14312
|
+
});
|
|
14313
|
+
});
|
|
14314
|
+
};
|
|
14315
|
+
}
|
|
14306
14316
|
var signatureRecorder = null;
|
|
14307
14317
|
var signatureChunks = [];
|
|
14308
14318
|
var videoSignatureInitialState = {
|
|
@@ -14337,9 +14347,8 @@ var useVideoSignatureStore = create()(devtools(function (set, get) {
|
|
|
14337
14347
|
if (!camera) throw new Error('Camera not found');
|
|
14338
14348
|
// set our flag and clear whatever we have recorded so far.
|
|
14339
14349
|
signatureChunks = [];
|
|
14340
|
-
var outputCanvas = get().outputCanvas;
|
|
14341
14350
|
// start recording from the output canvas to capture the signature
|
|
14342
|
-
var outputStream = (_a = outputCanvas.current) === null || _a === void 0 ? void 0 : _a.captureStream(24);
|
|
14351
|
+
var outputStream = (_a = get().outputCanvas.current) === null || _a === void 0 ? void 0 : _a.captureStream(24);
|
|
14343
14352
|
if (!outputStream) throw new Error('outputStream not found');
|
|
14344
14353
|
var tracks = [outputStream.getVideoTracks()[0]];
|
|
14345
14354
|
if (captureAudio) {
|
|
@@ -14384,39 +14393,42 @@ var useVideoSignatureStore = create()(devtools(function (set, get) {
|
|
|
14384
14393
|
signatureRecorder.stop();
|
|
14385
14394
|
signatureRecorder.onstop = function () {
|
|
14386
14395
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
14387
|
-
var recordingStoppedAt, inferredType, blob, _a, onSignatureVideoCaptured, recordingStartRequestedAt, recordingStartedAt, firstChunkReceivedAt, signatureStartedAt, signatureEndedAt, recordingStopRequestedAt, lastChunkReceivedAt;
|
|
14388
|
-
|
|
14389
|
-
|
|
14390
|
-
|
|
14391
|
-
|
|
14392
|
-
|
|
14393
|
-
|
|
14394
|
-
|
|
14395
|
-
|
|
14396
|
-
|
|
14397
|
-
|
|
14398
|
-
|
|
14399
|
-
|
|
14400
|
-
|
|
14401
|
-
|
|
14402
|
-
|
|
14403
|
-
|
|
14404
|
-
|
|
14405
|
-
|
|
14406
|
-
|
|
14407
|
-
|
|
14408
|
-
|
|
14409
|
-
|
|
14410
|
-
|
|
14411
|
-
|
|
14412
|
-
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
|
|
14416
|
-
|
|
14417
|
-
|
|
14418
|
-
|
|
14419
|
-
|
|
14396
|
+
var recordingStoppedAt, inferredType, blob, _a, onSignatureVideoCaptured, recordingStartRequestedAt, recordingStartedAt, firstChunkReceivedAt, signatureStartedAt, signatureEndedAt, recordingStopRequestedAt, lastChunkReceivedAt, mediaInfo;
|
|
14397
|
+
var _b;
|
|
14398
|
+
return __generator(this, function (_c) {
|
|
14399
|
+
switch (_c.label) {
|
|
14400
|
+
case 0:
|
|
14401
|
+
recordingStoppedAt = performance.now();
|
|
14402
|
+
set({
|
|
14403
|
+
recordingStoppedAt: recordingStoppedAt
|
|
14404
|
+
});
|
|
14405
|
+
inferredType = inferBlobType(signatureChunks[0]) || (signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.mimeType) || 'video/mp4';
|
|
14406
|
+
blob = new Blob(signatureChunks, {
|
|
14407
|
+
type: inferredType
|
|
14408
|
+
});
|
|
14409
|
+
signatureChunks = [];
|
|
14410
|
+
signatureRecorder = null;
|
|
14411
|
+
if (!signatureData) return [2 /*return*/];
|
|
14412
|
+
_a = get(), onSignatureVideoCaptured = _a.onSignatureVideoCaptured, recordingStartRequestedAt = _a.recordingStartRequestedAt, recordingStartedAt = _a.recordingStartedAt, firstChunkReceivedAt = _a.firstChunkReceivedAt, signatureStartedAt = _a.signatureStartedAt, signatureEndedAt = _a.signatureEndedAt, recordingStopRequestedAt = _a.recordingStopRequestedAt, lastChunkReceivedAt = _a.lastChunkReceivedAt;
|
|
14413
|
+
return [4 /*yield*/, (_b = get().mediaInfo) === null || _b === void 0 ? void 0 : _b.analyzeData(blob.size, makeReadChunk(blob))];
|
|
14414
|
+
case 1:
|
|
14415
|
+
mediaInfo = _c.sent();
|
|
14416
|
+
onSignatureVideoCaptured(blob, signatureData, imageUrl !== null && imageUrl !== void 0 ? imageUrl : null, {
|
|
14417
|
+
mediaInfo: mediaInfo,
|
|
14418
|
+
mimeType: inferredType,
|
|
14419
|
+
timingData: {
|
|
14420
|
+
recordingStartRequestedAt: recordingStartRequestedAt,
|
|
14421
|
+
recordingStartedAt: recordingStartedAt,
|
|
14422
|
+
firstChunkReceivedAt: firstChunkReceivedAt,
|
|
14423
|
+
signatureStartedAt: signatureStartedAt,
|
|
14424
|
+
signatureEndedAt: signatureEndedAt,
|
|
14425
|
+
recordingStopRequestedAt: recordingStopRequestedAt,
|
|
14426
|
+
recordingStoppedAt: recordingStoppedAt,
|
|
14427
|
+
lastChunkReceivedAt: lastChunkReceivedAt
|
|
14428
|
+
}
|
|
14429
|
+
});
|
|
14430
|
+
return [2 /*return*/];
|
|
14431
|
+
}
|
|
14420
14432
|
});
|
|
14421
14433
|
});
|
|
14422
14434
|
};
|
|
@@ -14466,7 +14478,9 @@ function waitForOneMoreChunk(timeoutMs) {
|
|
|
14466
14478
|
function VideoSignatureContextProvider(_a) {
|
|
14467
14479
|
var _this = this;
|
|
14468
14480
|
var _b, _c, _d, _e;
|
|
14469
|
-
var children = _a.children
|
|
14481
|
+
var children = _a.children,
|
|
14482
|
+
_f = _a.captureMediaInfo,
|
|
14483
|
+
captureMediaInfo = _f === void 0 ? false : _f;
|
|
14470
14484
|
var videoRef = useCameraStore().videoRef;
|
|
14471
14485
|
var outputCanvas = useRef(null);
|
|
14472
14486
|
useEffect(function () {
|
|
@@ -14476,27 +14490,31 @@ function VideoSignatureContextProvider(_a) {
|
|
|
14476
14490
|
}, []);
|
|
14477
14491
|
var signatureVideoRef = useRef(null);
|
|
14478
14492
|
var frameCheckCanvas = useRef(null);
|
|
14479
|
-
|
|
14480
|
-
|
|
14481
|
-
|
|
14482
|
-
|
|
14483
|
-
|
|
14484
|
-
|
|
14485
|
-
|
|
14486
|
-
|
|
14487
|
-
|
|
14488
|
-
|
|
14489
|
-
|
|
14490
|
-
|
|
14491
|
-
|
|
14492
|
-
|
|
14493
|
-
|
|
14494
|
-
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
|
|
14498
|
-
|
|
14499
|
-
|
|
14493
|
+
useEffect(function () {
|
|
14494
|
+
if (!captureMediaInfo) return;
|
|
14495
|
+
mediaInfoFactory({
|
|
14496
|
+
format: 'object',
|
|
14497
|
+
full: true,
|
|
14498
|
+
locateFile: function locateFile(filename) {
|
|
14499
|
+
return "".concat(DEFAULT_CDN_URL, "/").concat(filename);
|
|
14500
|
+
}
|
|
14501
|
+
}).then(function (mediaInfo) {
|
|
14502
|
+
useVideoSignatureStore.setState({
|
|
14503
|
+
mediaInfo: mediaInfo
|
|
14504
|
+
});
|
|
14505
|
+
})["catch"](function (e) {
|
|
14506
|
+
warn('error loading mediaInfo', e);
|
|
14507
|
+
});
|
|
14508
|
+
return function () {
|
|
14509
|
+
var mediaInfo = useVideoSignatureStore.getState().mediaInfo;
|
|
14510
|
+
if (mediaInfo) {
|
|
14511
|
+
mediaInfo.close();
|
|
14512
|
+
useVideoSignatureStore.setState({
|
|
14513
|
+
mediaInfo: undefined
|
|
14514
|
+
});
|
|
14515
|
+
}
|
|
14516
|
+
};
|
|
14517
|
+
}, [captureMediaInfo]);
|
|
14500
14518
|
var signaturePadEmpty = useVideoSignatureStore().signaturePadEmpty;
|
|
14501
14519
|
var blankCheckPassed = useRef(false);
|
|
14502
14520
|
useEffect(function () {
|
|
@@ -14537,40 +14555,15 @@ function VideoSignatureContextProvider(_a) {
|
|
|
14537
14555
|
});
|
|
14538
14556
|
});
|
|
14539
14557
|
}, [videoRef, outputCanvas]);
|
|
14540
|
-
|
|
14541
|
-
|
|
14542
|
-
|
|
14543
|
-
|
|
14544
|
-
|
|
14545
|
-
|
|
14546
|
-
|
|
14547
|
-
|
|
14548
|
-
|
|
14549
|
-
video.requestVideoFrameCallback(onFrame);
|
|
14550
|
-
}
|
|
14551
|
-
video.addEventListener('play', onPlay);
|
|
14552
|
-
return function () {
|
|
14553
|
-
video.removeEventListener('play', onPlay);
|
|
14554
|
-
};
|
|
14555
|
-
}, [drawOutputFrame]);
|
|
14556
|
-
useEffect(function () {
|
|
14557
|
-
if (!videoRef.current) return;
|
|
14558
|
-
var video = videoRef.current;
|
|
14559
|
-
function onFrame() {
|
|
14560
|
-
drawOutputFrame();
|
|
14561
|
-
video.requestVideoFrameCallback(onFrame);
|
|
14562
|
-
}
|
|
14563
|
-
function onPlay() {
|
|
14564
|
-
video.requestVideoFrameCallback(onFrame);
|
|
14565
|
-
}
|
|
14566
|
-
video.addEventListener('play', onPlay);
|
|
14567
|
-
return function () {
|
|
14568
|
-
video.removeEventListener('play', onPlay);
|
|
14569
|
-
};
|
|
14570
|
-
}, [drawOutputFrame, videoRef]);
|
|
14571
|
-
var _f = useVideoSignatureStore(),
|
|
14572
|
-
signaturePad = _f.signaturePad,
|
|
14573
|
-
recordingStartedAt = _f.recordingStartedAt;
|
|
14558
|
+
var checkBlankAndDrawOutputFrame = useCallback(function () {
|
|
14559
|
+
blankCheckPassed.current || (blankCheckPassed.current = !isVideoBlank(signatureVideoRef.current, frameCheckCanvas.current));
|
|
14560
|
+
drawOutputFrame();
|
|
14561
|
+
}, [drawOutputFrame, signatureVideoRef]);
|
|
14562
|
+
useVideoFrameLoop(signatureVideoRef, checkBlankAndDrawOutputFrame);
|
|
14563
|
+
useVideoFrameLoop(videoRef, drawOutputFrame);
|
|
14564
|
+
var _g = useVideoSignatureStore(),
|
|
14565
|
+
signaturePad = _g.signaturePad,
|
|
14566
|
+
recordingStartedAt = _g.recordingStartedAt;
|
|
14574
14567
|
useEffect(function () {
|
|
14575
14568
|
var _a;
|
|
14576
14569
|
if (!signaturePad.current || !recordingStartedAt) return;
|
|
@@ -14610,6 +14603,32 @@ function isCanvasBlank(canvas) {
|
|
|
14610
14603
|
});
|
|
14611
14604
|
return result;
|
|
14612
14605
|
}
|
|
14606
|
+
function requestVideoFrameCallback(video, onFrame) {
|
|
14607
|
+
if (typeof (video === null || video === void 0 ? void 0 : video.requestVideoFrameCallback) === 'function') {
|
|
14608
|
+
video.requestVideoFrameCallback(onFrame);
|
|
14609
|
+
} else {
|
|
14610
|
+
requestAnimationFrame(onFrame);
|
|
14611
|
+
}
|
|
14612
|
+
}
|
|
14613
|
+
function videoFrameLoop(video, onFrame) {
|
|
14614
|
+
if (!video) return;
|
|
14615
|
+
function onFrameRecursive() {
|
|
14616
|
+
onFrame();
|
|
14617
|
+
requestVideoFrameCallback(video, onFrameRecursive);
|
|
14618
|
+
}
|
|
14619
|
+
function onPlay() {
|
|
14620
|
+
requestVideoFrameCallback(video, onFrameRecursive);
|
|
14621
|
+
}
|
|
14622
|
+
video.addEventListener('play', onPlay);
|
|
14623
|
+
return function () {
|
|
14624
|
+
video.removeEventListener('play', onPlay);
|
|
14625
|
+
};
|
|
14626
|
+
}
|
|
14627
|
+
function useVideoFrameLoop(ref, onFrame) {
|
|
14628
|
+
useEffect(function () {
|
|
14629
|
+
return videoFrameLoop(ref.current, onFrame);
|
|
14630
|
+
}, [onFrame, ref]);
|
|
14631
|
+
}
|
|
14613
14632
|
|
|
14614
14633
|
function VideoSignaturePad(_a) {
|
|
14615
14634
|
var onAcceptBtnClicked = _a.onAcceptBtnClicked,
|