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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom/client'), require('platform'), require('styled-components'), require('react-dom'), require('tus-js-client'), require('prop-types'), require('react-dom/server')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom/client', 'platform', 'styled-components', 'react-dom', 'tus-js-client', 'prop-types', 'react-dom/server'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Sdk2 = {}, global.React, global.ReactDOM, global.platform, global.styled, global.ReactDOM, global.tusJsClient, global.PropTypes, global.server));
5
- })(this, (function (exports, React, ReactDOM, platform, styled, reactDom, tusJsClient, require$$0, server) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom/client'), require('platform'), require('styled-components'), require('react-dom'), require('tus-js-client'), require('prop-types'), require('mediainfo.js'), require('react-dom/server')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom/client', 'platform', 'styled-components', 'react-dom', 'tus-js-client', 'prop-types', 'mediainfo.js', 'react-dom/server'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Sdk2 = {}, global.React, global.ReactDOM, global.platform, global.styled, global.ReactDOM, global.tusJsClient, global.PropTypes, global.mediainfo_js, global.server));
5
+ })(this, (function (exports, React, ReactDOM, platform, styled, reactDom, tusJsClient, require$$0, mediainfo_js, server) { 'use strict';
6
6
 
7
7
  function _interopNamespaceDefault(e) {
8
8
  var n = Object.create(null);
@@ -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.98';
214
+ var webSdkVersion = '2.3.99';
215
215
 
216
216
  function getPlatform() {
217
217
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -24200,14 +24200,23 @@
24200
24200
  return t.length > 0 ? t : undefined;
24201
24201
  }
24202
24202
 
24203
- // import { mediaInfoFactory } from 'mediainfo.js'
24204
- // import type { ReadChunkFunc, MediaInfo, MediaInfoResult } from 'mediainfo.js'
24205
- // import { DEFAULT_CDN_URL } from '../common/cdn'
24206
- // import { warn } from '../../lib/utils/logger'
24207
- // function makeReadChunk(file: File | Blob): ReadChunkFunc {
24208
- // return async (chunkSize: number, offset: number) =>
24209
- // new Uint8Array(await file.slice(offset, offset + chunkSize).arrayBuffer())
24210
- // }
24203
+ function makeReadChunk(file) {
24204
+ var _this = this;
24205
+ return function (chunkSize, offset) {
24206
+ return __awaiter(_this, void 0, void 0, function () {
24207
+ var _a;
24208
+ return __generator(this, function (_b) {
24209
+ switch (_b.label) {
24210
+ case 0:
24211
+ _a = Uint8Array.bind;
24212
+ return [4 /*yield*/, file.slice(offset, offset + chunkSize).arrayBuffer()];
24213
+ case 1:
24214
+ return [2 /*return*/, new (_a.apply(Uint8Array, [void 0, _b.sent()]))()];
24215
+ }
24216
+ });
24217
+ });
24218
+ };
24219
+ }
24211
24220
  var signatureRecorder = null;
24212
24221
  var signatureChunks = [];
24213
24222
  var videoSignatureInitialState = {
@@ -24242,9 +24251,8 @@
24242
24251
  if (!camera) throw new Error('Camera not found');
24243
24252
  // set our flag and clear whatever we have recorded so far.
24244
24253
  signatureChunks = [];
24245
- var outputCanvas = get().outputCanvas;
24246
24254
  // start recording from the output canvas to capture the signature
24247
- var outputStream = (_a = outputCanvas.current) === null || _a === void 0 ? void 0 : _a.captureStream(24);
24255
+ var outputStream = (_a = get().outputCanvas.current) === null || _a === void 0 ? void 0 : _a.captureStream(24);
24248
24256
  if (!outputStream) throw new Error('outputStream not found');
24249
24257
  var tracks = [outputStream.getVideoTracks()[0]];
24250
24258
  if (captureAudio) {
@@ -24289,39 +24297,42 @@
24289
24297
  signatureRecorder.stop();
24290
24298
  signatureRecorder.onstop = function () {
24291
24299
  return __awaiter(void 0, void 0, void 0, function () {
24292
- var recordingStoppedAt, inferredType, blob, _a, onSignatureVideoCaptured, recordingStartRequestedAt, recordingStartedAt, firstChunkReceivedAt, signatureStartedAt, signatureEndedAt, recordingStopRequestedAt, lastChunkReceivedAt;
24293
- return __generator(this, function (_b) {
24294
- recordingStoppedAt = performance.now();
24295
- set({
24296
- recordingStoppedAt: recordingStoppedAt
24297
- });
24298
- inferredType = inferBlobType(signatureChunks[0]) || (signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.mimeType) || 'video/mp4';
24299
- blob = new Blob(signatureChunks, {
24300
- type: inferredType
24301
- });
24302
- signatureChunks = [];
24303
- signatureRecorder = null;
24304
- if (!signatureData) return [2 /*return*/];
24305
- _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;
24306
- // const mediaInfo = await get().mediaInfo?.analyzeData(
24307
- // blob.size,
24308
- // makeReadChunk(blob),
24309
- // )
24310
- onSignatureVideoCaptured(blob, signatureData, imageUrl !== null && imageUrl !== void 0 ? imageUrl : null, {
24311
- // mediaInfo,
24312
- mimeType: inferredType,
24313
- timingData: {
24314
- recordingStartRequestedAt: recordingStartRequestedAt,
24315
- recordingStartedAt: recordingStartedAt,
24316
- firstChunkReceivedAt: firstChunkReceivedAt,
24317
- signatureStartedAt: signatureStartedAt,
24318
- signatureEndedAt: signatureEndedAt,
24319
- recordingStopRequestedAt: recordingStopRequestedAt,
24320
- recordingStoppedAt: recordingStoppedAt,
24321
- lastChunkReceivedAt: lastChunkReceivedAt
24322
- }
24323
- });
24324
- return [2 /*return*/];
24300
+ var recordingStoppedAt, inferredType, blob, _a, onSignatureVideoCaptured, recordingStartRequestedAt, recordingStartedAt, firstChunkReceivedAt, signatureStartedAt, signatureEndedAt, recordingStopRequestedAt, lastChunkReceivedAt, mediaInfo;
24301
+ var _b;
24302
+ return __generator(this, function (_c) {
24303
+ switch (_c.label) {
24304
+ case 0:
24305
+ recordingStoppedAt = performance.now();
24306
+ set({
24307
+ recordingStoppedAt: recordingStoppedAt
24308
+ });
24309
+ inferredType = inferBlobType(signatureChunks[0]) || (signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.mimeType) || 'video/mp4';
24310
+ blob = new Blob(signatureChunks, {
24311
+ type: inferredType
24312
+ });
24313
+ signatureChunks = [];
24314
+ signatureRecorder = null;
24315
+ if (!signatureData) return [2 /*return*/];
24316
+ _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;
24317
+ return [4 /*yield*/, (_b = get().mediaInfo) === null || _b === void 0 ? void 0 : _b.analyzeData(blob.size, makeReadChunk(blob))];
24318
+ case 1:
24319
+ mediaInfo = _c.sent();
24320
+ onSignatureVideoCaptured(blob, signatureData, imageUrl !== null && imageUrl !== void 0 ? imageUrl : null, {
24321
+ mediaInfo: mediaInfo,
24322
+ mimeType: inferredType,
24323
+ timingData: {
24324
+ recordingStartRequestedAt: recordingStartRequestedAt,
24325
+ recordingStartedAt: recordingStartedAt,
24326
+ firstChunkReceivedAt: firstChunkReceivedAt,
24327
+ signatureStartedAt: signatureStartedAt,
24328
+ signatureEndedAt: signatureEndedAt,
24329
+ recordingStopRequestedAt: recordingStopRequestedAt,
24330
+ recordingStoppedAt: recordingStoppedAt,
24331
+ lastChunkReceivedAt: lastChunkReceivedAt
24332
+ }
24333
+ });
24334
+ return [2 /*return*/];
24335
+ }
24325
24336
  });
24326
24337
  });
24327
24338
  };
@@ -24371,7 +24382,9 @@
24371
24382
  function VideoSignatureContextProvider(_a) {
24372
24383
  var _this = this;
24373
24384
  var _b, _c, _d, _e;
24374
- var children = _a.children;
24385
+ var children = _a.children,
24386
+ _f = _a.captureMediaInfo,
24387
+ captureMediaInfo = _f === void 0 ? false : _f;
24375
24388
  var videoRef = useCameraStore().videoRef;
24376
24389
  var outputCanvas = React.useRef(null);
24377
24390
  React.useEffect(function () {
@@ -24381,27 +24394,31 @@
24381
24394
  }, []);
24382
24395
  var signatureVideoRef = React.useRef(null);
24383
24396
  var frameCheckCanvas = React.useRef(null);
24384
- // useEffect(() => {
24385
- // if (!captureMediaInfo) return
24386
- // mediaInfoFactory({
24387
- // format: 'object',
24388
- // full: true,
24389
- // locateFile: (filename) => `${DEFAULT_CDN_URL}/${filename}`,
24390
- // })
24391
- // .then((mediaInfo) => {
24392
- // useVideoSignatureStore.setState({ mediaInfo })
24393
- // })
24394
- // .catch((e) => {
24395
- // warn('error loading mediaInfo', e)
24396
- // })
24397
- // return () => {
24398
- // const mediaInfo = useVideoSignatureStore.getState().mediaInfo
24399
- // if (mediaInfo) {
24400
- // mediaInfo.close()
24401
- // useVideoSignatureStore.setState({ mediaInfo: undefined })
24402
- // }
24403
- // }
24404
- // }, [captureMediaInfo])
24397
+ React.useEffect(function () {
24398
+ if (!captureMediaInfo) return;
24399
+ mediainfo_js.mediaInfoFactory({
24400
+ format: 'object',
24401
+ full: true,
24402
+ locateFile: function locateFile(filename) {
24403
+ return "".concat(DEFAULT_CDN_URL, "/").concat(filename);
24404
+ }
24405
+ }).then(function (mediaInfo) {
24406
+ useVideoSignatureStore.setState({
24407
+ mediaInfo: mediaInfo
24408
+ });
24409
+ })["catch"](function (e) {
24410
+ warn('error loading mediaInfo', e);
24411
+ });
24412
+ return function () {
24413
+ var mediaInfo = useVideoSignatureStore.getState().mediaInfo;
24414
+ if (mediaInfo) {
24415
+ mediaInfo.close();
24416
+ useVideoSignatureStore.setState({
24417
+ mediaInfo: undefined
24418
+ });
24419
+ }
24420
+ };
24421
+ }, [captureMediaInfo]);
24405
24422
  var signaturePadEmpty = useVideoSignatureStore().signaturePadEmpty;
24406
24423
  var blankCheckPassed = React.useRef(false);
24407
24424
  React.useEffect(function () {
@@ -24442,40 +24459,15 @@
24442
24459
  });
24443
24460
  });
24444
24461
  }, [videoRef, outputCanvas]);
24445
- React.useEffect(function () {
24446
- if (!signatureVideoRef.current) return;
24447
- var video = signatureVideoRef.current;
24448
- function onFrame() {
24449
- blankCheckPassed.current || (blankCheckPassed.current = !isVideoBlank(signatureVideoRef.current, frameCheckCanvas.current));
24450
- drawOutputFrame();
24451
- video.requestVideoFrameCallback(onFrame);
24452
- }
24453
- function onPlay() {
24454
- video.requestVideoFrameCallback(onFrame);
24455
- }
24456
- video.addEventListener('play', onPlay);
24457
- return function () {
24458
- video.removeEventListener('play', onPlay);
24459
- };
24460
- }, [drawOutputFrame]);
24461
- React.useEffect(function () {
24462
- if (!videoRef.current) return;
24463
- var video = videoRef.current;
24464
- function onFrame() {
24465
- drawOutputFrame();
24466
- video.requestVideoFrameCallback(onFrame);
24467
- }
24468
- function onPlay() {
24469
- video.requestVideoFrameCallback(onFrame);
24470
- }
24471
- video.addEventListener('play', onPlay);
24472
- return function () {
24473
- video.removeEventListener('play', onPlay);
24474
- };
24475
- }, [drawOutputFrame, videoRef]);
24476
- var _f = useVideoSignatureStore(),
24477
- signaturePad = _f.signaturePad,
24478
- recordingStartedAt = _f.recordingStartedAt;
24462
+ var checkBlankAndDrawOutputFrame = React.useCallback(function () {
24463
+ blankCheckPassed.current || (blankCheckPassed.current = !isVideoBlank(signatureVideoRef.current, frameCheckCanvas.current));
24464
+ drawOutputFrame();
24465
+ }, [drawOutputFrame, signatureVideoRef]);
24466
+ useVideoFrameLoop(signatureVideoRef, checkBlankAndDrawOutputFrame);
24467
+ useVideoFrameLoop(videoRef, drawOutputFrame);
24468
+ var _g = useVideoSignatureStore(),
24469
+ signaturePad = _g.signaturePad,
24470
+ recordingStartedAt = _g.recordingStartedAt;
24479
24471
  React.useEffect(function () {
24480
24472
  var _a;
24481
24473
  if (!signaturePad.current || !recordingStartedAt) return;
@@ -24515,6 +24507,32 @@
24515
24507
  });
24516
24508
  return result;
24517
24509
  }
24510
+ function requestVideoFrameCallback(video, onFrame) {
24511
+ if (typeof (video === null || video === void 0 ? void 0 : video.requestVideoFrameCallback) === 'function') {
24512
+ video.requestVideoFrameCallback(onFrame);
24513
+ } else {
24514
+ requestAnimationFrame(onFrame);
24515
+ }
24516
+ }
24517
+ function videoFrameLoop(video, onFrame) {
24518
+ if (!video) return;
24519
+ function onFrameRecursive() {
24520
+ onFrame();
24521
+ requestVideoFrameCallback(video, onFrameRecursive);
24522
+ }
24523
+ function onPlay() {
24524
+ requestVideoFrameCallback(video, onFrameRecursive);
24525
+ }
24526
+ video.addEventListener('play', onPlay);
24527
+ return function () {
24528
+ video.removeEventListener('play', onPlay);
24529
+ };
24530
+ }
24531
+ function useVideoFrameLoop(ref, onFrame) {
24532
+ React.useEffect(function () {
24533
+ return videoFrameLoop(ref.current, onFrame);
24534
+ }, [onFrame, ref]);
24535
+ }
24518
24536
 
24519
24537
  function VideoSignaturePad(_a) {
24520
24538
  var onAcceptBtnClicked = _a.onAcceptBtnClicked,