idmission-web-sdk 2.3.11 → 2.3.13
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.map +1 -1
- package/dist/lib/camera/useVideoRecorder.d.ts.map +1 -1
- package/dist/sdk2.cjs.development.js +119 -91
- 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 -91
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +119 -91
- 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
|
@@ -211,7 +211,7 @@
|
|
|
211
211
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
-
var webSdkVersion = '2.3.
|
|
214
|
+
var webSdkVersion = '2.3.13';
|
|
215
215
|
|
|
216
216
|
function getPlatform() {
|
|
217
217
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -23232,14 +23232,29 @@
|
|
|
23232
23232
|
var AcceptBtn$1 = styled(LoaderButton)(templateObject_2$a || (templateObject_2$a = __makeTemplateObject(["\n margin-left: auto;\n"], ["\n margin-left: auto;\n"])));
|
|
23233
23233
|
var templateObject_1$c, templateObject_2$a;
|
|
23234
23234
|
|
|
23235
|
+
var videoRecorder = null;
|
|
23236
|
+
var audioRecorder = null;
|
|
23237
|
+
var videoChunks = [];
|
|
23238
|
+
var audioChunks = [];
|
|
23239
|
+
function getVideoRecorder() {
|
|
23240
|
+
return videoRecorder;
|
|
23241
|
+
}
|
|
23242
|
+
function setVideoRecorder(recorder) {
|
|
23243
|
+
videoRecorder = recorder;
|
|
23244
|
+
}
|
|
23245
|
+
function setAudioRecorder(recorder) {
|
|
23246
|
+
audioRecorder = recorder;
|
|
23247
|
+
}
|
|
23248
|
+
function clearVideoChunks() {
|
|
23249
|
+
videoChunks = [];
|
|
23250
|
+
}
|
|
23251
|
+
function clearAudioChunks() {
|
|
23252
|
+
audioChunks = [];
|
|
23253
|
+
}
|
|
23235
23254
|
var useVideoRecorder = function useVideoRecorder(camera, audioStream, mergeAVStreams) {
|
|
23236
23255
|
if (mergeAVStreams === void 0) {
|
|
23237
23256
|
mergeAVStreams = false;
|
|
23238
23257
|
}
|
|
23239
|
-
var videoRecorder = React.useRef(null);
|
|
23240
|
-
var audioRecorder = React.useRef(null);
|
|
23241
|
-
var videoChunks = React.useRef([]);
|
|
23242
|
-
var audioChunks = React.useRef([]);
|
|
23243
23258
|
var _a = React.useState(null),
|
|
23244
23259
|
videoUrl = _a[0],
|
|
23245
23260
|
setVideoUrl = _a[1];
|
|
@@ -23272,45 +23287,48 @@
|
|
|
23272
23287
|
return new MediaStream(__spreadArray(__spreadArray([], videoTracks, true), audioTracks, true));
|
|
23273
23288
|
}, [audioStream, camera === null || camera === void 0 ? void 0 : camera.stream, mergeAVStreams]);
|
|
23274
23289
|
var processVideo = React.useCallback(function () {
|
|
23275
|
-
var videoBlob = new Blob(videoChunks
|
|
23290
|
+
var videoBlob = new Blob(videoChunks, {
|
|
23276
23291
|
type: 'video/mp4'
|
|
23277
23292
|
});
|
|
23278
|
-
videoChunks.current = [];
|
|
23279
23293
|
setVideoUrl(URL.createObjectURL(videoBlob));
|
|
23294
|
+
clearVideoChunks();
|
|
23280
23295
|
setIsRecordingVideo(false);
|
|
23296
|
+
setVideoRecorder(null);
|
|
23281
23297
|
camera === null || camera === void 0 ? void 0 : camera.release();
|
|
23282
23298
|
}, [camera]);
|
|
23283
23299
|
var processAudio = React.useCallback(function () {
|
|
23284
23300
|
var _a;
|
|
23285
|
-
var audioBlob = new Blob(audioChunks
|
|
23301
|
+
var audioBlob = new Blob(audioChunks, {
|
|
23286
23302
|
type: 'audio/mp4'
|
|
23287
23303
|
});
|
|
23288
|
-
audioChunks.current = [];
|
|
23289
23304
|
setAudioUrl(URL.createObjectURL(audioBlob));
|
|
23305
|
+
clearAudioChunks();
|
|
23290
23306
|
setIsRecordingAudio(false);
|
|
23307
|
+
setAudioRecorder(null);
|
|
23291
23308
|
(_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.stop) === null || _a === void 0 ? void 0 : _a.call(audioStream);
|
|
23292
23309
|
}, [audioStream]);
|
|
23293
23310
|
var startRecordingVideo = React.useCallback(function () {
|
|
23294
23311
|
var videoStream = getVideoStream();
|
|
23295
23312
|
if (!videoStream) return;
|
|
23296
|
-
|
|
23313
|
+
clearVideoChunks();
|
|
23297
23314
|
setIsRecordingVideo(true);
|
|
23298
23315
|
setVideoRecordingStopped(false);
|
|
23299
23316
|
setVideoRecordingIntentionallyStopped(false);
|
|
23300
|
-
videoRecorder
|
|
23317
|
+
var videoRecorder = new MediaRecorder(videoStream, {
|
|
23301
23318
|
videoBitsPerSecond: 270000,
|
|
23302
23319
|
audioBitsPerSecond: 32000
|
|
23303
23320
|
});
|
|
23304
|
-
videoRecorder
|
|
23305
|
-
|
|
23321
|
+
setVideoRecorder(videoRecorder);
|
|
23322
|
+
videoRecorder.ondataavailable = function (e) {
|
|
23323
|
+
videoChunks.push(e.data);
|
|
23306
23324
|
};
|
|
23307
|
-
videoRecorder.
|
|
23325
|
+
videoRecorder.onstop = function () {
|
|
23308
23326
|
setVideoRecordingStopped(true);
|
|
23309
23327
|
};
|
|
23310
|
-
videoRecorder.
|
|
23328
|
+
videoRecorder.start(1000);
|
|
23311
23329
|
setTimeout(function () {
|
|
23312
23330
|
var _a;
|
|
23313
|
-
if (((_a =
|
|
23331
|
+
if (((_a = getVideoRecorder()) === null || _a === void 0 ? void 0 : _a.state) === 'inactive') {
|
|
23314
23332
|
log('media recorder is inactive!');
|
|
23315
23333
|
// TODO: figure out what to do here
|
|
23316
23334
|
}
|
|
@@ -23319,33 +23337,32 @@
|
|
|
23319
23337
|
var startRecordingAudio = React.useCallback(function () {
|
|
23320
23338
|
if (mergeAVStreams) return;
|
|
23321
23339
|
if (!audioStream) return;
|
|
23322
|
-
|
|
23340
|
+
clearAudioChunks();
|
|
23323
23341
|
setIsRecordingAudio(true);
|
|
23324
23342
|
setAudioRecordingStopped(false);
|
|
23325
23343
|
setAudioRecordingIntentionallyStopped(false);
|
|
23326
|
-
audioRecorder
|
|
23344
|
+
var audioRecorder = new MediaRecorder(audioStream, {
|
|
23327
23345
|
audioBitsPerSecond: 32000
|
|
23328
23346
|
});
|
|
23329
|
-
audioRecorder
|
|
23330
|
-
|
|
23347
|
+
setAudioRecorder(audioRecorder);
|
|
23348
|
+
audioRecorder.ondataavailable = function (e) {
|
|
23349
|
+
audioChunks.push(e.data);
|
|
23331
23350
|
};
|
|
23332
|
-
audioRecorder.
|
|
23351
|
+
audioRecorder.onstop = function () {
|
|
23333
23352
|
setAudioRecordingStopped(true);
|
|
23334
23353
|
};
|
|
23335
|
-
audioRecorder.
|
|
23354
|
+
audioRecorder.start(1000);
|
|
23336
23355
|
}, [audioStream, mergeAVStreams]);
|
|
23337
23356
|
var stopRecordingVideo = React.useCallback(function () {
|
|
23338
|
-
var _a, _b;
|
|
23339
23357
|
setVideoRecordingIntentionallyStopped(true);
|
|
23340
|
-
if ((
|
|
23341
|
-
|
|
23358
|
+
if ((videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.state) !== 'inactive') {
|
|
23359
|
+
videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
|
|
23342
23360
|
}
|
|
23343
23361
|
}, []);
|
|
23344
23362
|
var stopRecordingAudio = React.useCallback(function () {
|
|
23345
|
-
var _a, _b;
|
|
23346
23363
|
setAudioRecordingIntentionallyStopped(true);
|
|
23347
|
-
if ((
|
|
23348
|
-
|
|
23364
|
+
if ((audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.state) !== 'inactive') {
|
|
23365
|
+
audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
|
|
23349
23366
|
}
|
|
23350
23367
|
}, []);
|
|
23351
23368
|
React.useEffect(function () {
|
|
@@ -23359,8 +23376,8 @@
|
|
|
23359
23376
|
}
|
|
23360
23377
|
}, [audioRecordingIntentionallyStopped, audioRecordingStopped, processAudio]);
|
|
23361
23378
|
var clearRecordedData = React.useCallback(function () {
|
|
23362
|
-
|
|
23363
|
-
|
|
23379
|
+
clearVideoChunks();
|
|
23380
|
+
clearAudioChunks();
|
|
23364
23381
|
}, []);
|
|
23365
23382
|
return React.useMemo(function () {
|
|
23366
23383
|
return {
|
|
@@ -23379,6 +23396,36 @@
|
|
|
23379
23396
|
}, [audioRecordingIntentionallyStopped, audioRecordingStopped, audioUrl, clearRecordedData, isRecordingAudio, isRecordingVideo, startRecordingAudio, startRecordingVideo, stopRecordingAudio, stopRecordingVideo, videoRecordingIntentionallyStopped, videoRecordingStopped, videoUrl]);
|
|
23380
23397
|
};
|
|
23381
23398
|
|
|
23399
|
+
var signatureRecorder = null;
|
|
23400
|
+
var getSignatureRecorder = function getSignatureRecorder() {
|
|
23401
|
+
return signatureRecorder;
|
|
23402
|
+
};
|
|
23403
|
+
var setSignatureRecorder = function setSignatureRecorder(recorder) {
|
|
23404
|
+
return signatureRecorder = recorder;
|
|
23405
|
+
};
|
|
23406
|
+
var signatureChunks = [];
|
|
23407
|
+
var clearSignatureChunks = function clearSignatureChunks() {
|
|
23408
|
+
return signatureChunks = [];
|
|
23409
|
+
};
|
|
23410
|
+
var recordingLock = false;
|
|
23411
|
+
var setRecordingLock = function setRecordingLock(lock) {
|
|
23412
|
+
return recordingLock = lock;
|
|
23413
|
+
};
|
|
23414
|
+
var recordingLockEngaged = function recordingLockEngaged() {
|
|
23415
|
+
return recordingLock;
|
|
23416
|
+
};
|
|
23417
|
+
function waitForCanvasAvailable(canvasRef) {
|
|
23418
|
+
if (canvasRef.current) return Promise.resolve(null);
|
|
23419
|
+
return new Promise(function (resolve) {
|
|
23420
|
+
var interval = setInterval(function () {
|
|
23421
|
+
debug('VideoSignatureContext: waiting for output canvas');
|
|
23422
|
+
if (canvasRef.current) {
|
|
23423
|
+
clearInterval(interval);
|
|
23424
|
+
resolve(null);
|
|
23425
|
+
}
|
|
23426
|
+
}, 100);
|
|
23427
|
+
});
|
|
23428
|
+
}
|
|
23382
23429
|
var videoSignatureInitialState = {
|
|
23383
23430
|
startRecording: function startRecording() {
|
|
23384
23431
|
return null;
|
|
@@ -23397,7 +23444,7 @@
|
|
|
23397
23444
|
onAcceptClicked: function onAcceptClicked() {
|
|
23398
23445
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
23399
23446
|
return __generator(this, function (_a) {
|
|
23400
|
-
return [2 /*return
|
|
23447
|
+
return [2 /*return*/];
|
|
23401
23448
|
});
|
|
23402
23449
|
});
|
|
23403
23450
|
}
|
|
@@ -23422,8 +23469,6 @@
|
|
|
23422
23469
|
var _h = React.useState(null),
|
|
23423
23470
|
signatureVideoUrl = _h[0],
|
|
23424
23471
|
setSignatureVideoUrl = _h[1];
|
|
23425
|
-
var signatureRecorder = React.useRef(null);
|
|
23426
|
-
var recordedChunks = React.useRef([]);
|
|
23427
23472
|
var _j = useCameraStore(),
|
|
23428
23473
|
camera = _j.camera,
|
|
23429
23474
|
videoRef = _j.videoRef,
|
|
@@ -23436,7 +23481,6 @@
|
|
|
23436
23481
|
stopRecordingAudio = _k.stopRecordingAudio,
|
|
23437
23482
|
clearRecordedVideoData = _k.clearRecordedData;
|
|
23438
23483
|
var outputCanvas = React.useRef(null);
|
|
23439
|
-
var recordingLock = React.useRef(false);
|
|
23440
23484
|
var onRecordingStopped = React.useRef(function () {});
|
|
23441
23485
|
var _l = React.useState(false),
|
|
23442
23486
|
isRecording = _l[0],
|
|
@@ -23455,67 +23499,45 @@
|
|
|
23455
23499
|
setIsRecording(true);
|
|
23456
23500
|
onRecordingStopped.current = function () {};
|
|
23457
23501
|
};
|
|
23458
|
-
|
|
23502
|
+
setRecordingLock(false);
|
|
23459
23503
|
setIsRecording(false);
|
|
23460
|
-
(_a =
|
|
23504
|
+
(_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
|
|
23505
|
+
setSignatureRecorder(null);
|
|
23461
23506
|
}, []);
|
|
23462
23507
|
React.useEffect(function () {
|
|
23463
23508
|
if (!isRecording) return;
|
|
23464
|
-
if (
|
|
23465
|
-
|
|
23466
|
-
(function () {
|
|
23467
|
-
|
|
23468
|
-
|
|
23469
|
-
|
|
23470
|
-
|
|
23471
|
-
|
|
23472
|
-
|
|
23473
|
-
|
|
23474
|
-
|
|
23475
|
-
|
|
23476
|
-
|
|
23477
|
-
|
|
23478
|
-
|
|
23479
|
-
}
|
|
23480
|
-
}, 10);
|
|
23481
|
-
})];
|
|
23482
|
-
case 1:
|
|
23483
|
-
_b.sent();
|
|
23484
|
-
_b.label = 2;
|
|
23485
|
-
case 2:
|
|
23486
|
-
recordedChunks.current = [];
|
|
23487
|
-
clearRecordedVideoData();
|
|
23488
|
-
startRecordingVideo();
|
|
23489
|
-
if (captureAudio) startRecordingAudio();
|
|
23490
|
-
stream = outputCanvas.current.captureStream(24 /* fps */);
|
|
23491
|
-
tracks = [stream.getVideoTracks()[0]];
|
|
23492
|
-
audioTrack = (_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks()) === null || _a === void 0 ? void 0 : _a[0];
|
|
23493
|
-
if (audioTrack) tracks.push(audioTrack);
|
|
23494
|
-
signatureRecorder.current = new MediaRecorder(new MediaStream(tracks), {
|
|
23495
|
-
videoBitsPerSecond: 270000,
|
|
23496
|
-
audioBitsPerSecond: 32000
|
|
23497
|
-
});
|
|
23498
|
-
signatureRecorder.current.start();
|
|
23499
|
-
signatureRecorder.current.ondataavailable = function (event) {
|
|
23500
|
-
var _a;
|
|
23501
|
-
recordedChunks.current.push(event.data);
|
|
23502
|
-
if (((_a = signatureRecorder.current) === null || _a === void 0 ? void 0 : _a.state) === 'recording') {
|
|
23503
|
-
signatureRecorder.current.stop();
|
|
23504
|
-
}
|
|
23505
|
-
};
|
|
23506
|
-
signatureRecorder.current.onstop = function () {
|
|
23507
|
-
var blob = new Blob(recordedChunks.current, {
|
|
23508
|
-
type: 'video/mp4'
|
|
23509
|
-
});
|
|
23510
|
-
setSignatureVideoData(blob);
|
|
23511
|
-
setSignatureVideoUrl(URL.createObjectURL(blob));
|
|
23512
|
-
onRecordingStopped.current();
|
|
23513
|
-
};
|
|
23514
|
-
return [2 /*return*/];
|
|
23515
|
-
}
|
|
23516
|
-
});
|
|
23509
|
+
if (recordingLockEngaged()) return;
|
|
23510
|
+
setRecordingLock(true);
|
|
23511
|
+
waitForCanvasAvailable(outputCanvas).then(function () {
|
|
23512
|
+
var _a;
|
|
23513
|
+
clearSignatureChunks();
|
|
23514
|
+
clearRecordedVideoData();
|
|
23515
|
+
startRecordingVideo();
|
|
23516
|
+
if (captureAudio) startRecordingAudio();
|
|
23517
|
+
var stream = outputCanvas.current.captureStream(24 /* fps */);
|
|
23518
|
+
var tracks = [stream.getVideoTracks()[0]];
|
|
23519
|
+
var audioTrack = (_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks()) === null || _a === void 0 ? void 0 : _a[0];
|
|
23520
|
+
if (audioTrack) tracks.push(audioTrack);
|
|
23521
|
+
var signatureRecorder = new MediaRecorder(new MediaStream(tracks), {
|
|
23522
|
+
videoBitsPerSecond: 270000,
|
|
23523
|
+
audioBitsPerSecond: 32000
|
|
23517
23524
|
});
|
|
23518
|
-
|
|
23525
|
+
setSignatureRecorder(signatureRecorder);
|
|
23526
|
+
signatureRecorder.ondataavailable = function (event) {
|
|
23527
|
+
signatureChunks.push(event.data);
|
|
23528
|
+
};
|
|
23529
|
+
signatureRecorder.onstop = function () {
|
|
23530
|
+
var blob = new Blob(signatureChunks, {
|
|
23531
|
+
type: 'video/mp4'
|
|
23532
|
+
});
|
|
23533
|
+
setSignatureVideoData(blob);
|
|
23534
|
+
setSignatureVideoUrl(URL.createObjectURL(blob));
|
|
23535
|
+
clearSignatureChunks();
|
|
23536
|
+
setSignatureRecorder(null);
|
|
23537
|
+
onRecordingStopped.current();
|
|
23538
|
+
};
|
|
23539
|
+
signatureRecorder.start(1000);
|
|
23540
|
+
});
|
|
23519
23541
|
}, [audioStream, captureAudio, clearRecordedVideoData, isRecording, startRecordingAudio, startRecordingVideo]);
|
|
23520
23542
|
var animationFrame = React.useRef(0);
|
|
23521
23543
|
React.useEffect(function () {
|
|
@@ -23557,17 +23579,23 @@
|
|
|
23557
23579
|
return __generator(this, function (_b) {
|
|
23558
23580
|
switch (_b.label) {
|
|
23559
23581
|
case 0:
|
|
23582
|
+
debug('VideoSignatureContext: onAcceptClicked');
|
|
23560
23583
|
if (!signaturePad.current) return [2 /*return*/];
|
|
23584
|
+
debug('VideoSignatureContext: building signature data...');
|
|
23561
23585
|
signatureData = buildSignatureData(signaturePad.current);
|
|
23586
|
+
debug('VideoSignatureContext: exporting signature image...');
|
|
23562
23587
|
return [4 /*yield*/, exportSignatureImage(signaturePad.current)];
|
|
23563
23588
|
case 1:
|
|
23564
23589
|
imageUrl = _b.sent();
|
|
23565
23590
|
if (imageUrl) signatureData.fileContent = dataUrlToBase64Sync(imageUrl);
|
|
23591
|
+
debug('VideoSignatureContext: setting signature data url...');
|
|
23566
23592
|
setSignatureDataUrl(imageUrl);
|
|
23567
23593
|
setSignatureData(signatureData);
|
|
23594
|
+
debug('VideoSignatureContext: stopping recording...');
|
|
23568
23595
|
stopRecordingVideo();
|
|
23569
23596
|
stopRecordingAudio();
|
|
23570
|
-
(
|
|
23597
|
+
debug('VideoSignatureContext: stopping signature recorder...');
|
|
23598
|
+
(_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
|
|
23571
23599
|
return [2 /*return*/];
|
|
23572
23600
|
}
|
|
23573
23601
|
});
|