idmission-web-sdk 1.0.124 → 1.0.126

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.
@@ -47,7 +47,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
47
47
  var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
48
48
  var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
49
49
 
50
- var webSdkVersion = '1.0.124';
50
+ var webSdkVersion = '1.0.126';
51
51
 
52
52
  function getPlatform() {
53
53
  if (typeof window === 'undefined') return;
@@ -8709,6 +8709,10 @@ var DEFAULT_CDN_URL = 'https://websdk-cdn-dev.idmission.com/assets';
8709
8709
  function getFrameDimensions(frame) {
8710
8710
  var frameWidth = frame.width,
8711
8711
  frameHeight = frame.height;
8712
+ if (frame instanceof HTMLImageElement) {
8713
+ frameWidth = frame.naturalWidth;
8714
+ frameHeight = frame.naturalHeight;
8715
+ }
8712
8716
  if (frame instanceof HTMLVideoElement) {
8713
8717
  frameWidth = frame.videoWidth;
8714
8718
  frameHeight = frame.videoHeight;
@@ -10567,35 +10571,24 @@ var CapturedImage = function CapturedImage(_a) {
10567
10571
  var alt = _a.alt,
10568
10572
  className = _a.className,
10569
10573
  image = _a.image;
10570
- var canvasRef = React.useRef(null);
10571
10574
  var _b = React.useState(image.imageData),
10572
10575
  url = _b[0],
10573
10576
  setUrl = _b[1];
10574
- React.useEffect(function () {
10575
- if (!image.boundingBox) {
10576
- console.error('no bounding box received!');
10577
- return;
10578
- }
10579
- var im = new Image();
10580
- im.onload = function () {
10581
- console.log('image has been loaded');
10582
- cropToBoundingBox(im, image.boundingBox, canvasRef.current);
10583
- var croppedDataUrl = canvasRef.current.toDataURL();
10584
- console.log('croppedDataUrl', croppedDataUrl);
10585
- setUrl(croppedDataUrl);
10586
- };
10587
- im.onerror = function (e) {
10588
- console.error('failed to load image', e);
10589
- };
10590
- im.src = image.imageData;
10591
- }, [image.boundingBox, image.height, image.imageData, image.width]);
10592
- return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(CropCanvas, {
10593
- ref: canvasRef
10594
- }), /*#__PURE__*/React__default['default'].createElement(StyledImage, {
10577
+ var _c = React.useState(false),
10578
+ cropped = _c[0],
10579
+ setCropped = _c[1];
10580
+ var bbox = image.boundingBox;
10581
+ function onLoaded(e) {
10582
+ if (!bbox || cropped) return;
10583
+ setCropped(true);
10584
+ setUrl(cropToBoundingBox(e.currentTarget, bbox).toDataURL('image/jpeg', 0.95));
10585
+ }
10586
+ return /*#__PURE__*/React__default['default'].createElement(StyledImage, {
10595
10587
  alt: alt,
10596
10588
  className: className,
10597
- src: url
10598
- }));
10589
+ src: url,
10590
+ onLoad: onLoaded
10591
+ });
10599
10592
  };
10600
10593
  var Heading$9 = styled__default['default'].h1(templateObject_2$d || (templateObject_2$d = tslib.__makeTemplateObject(["\n margin-bottom: 12px;\n"], ["\n margin-bottom: 12px;\n"])));
10601
10594
  var ImagesContainer = styled__default['default'](OverlayImageContainer)(templateObject_3$a || (templateObject_3$a = tslib.__makeTemplateObject(["\n overflow-y: auto;\n"], ["\n overflow-y: auto;\n"])));
@@ -10606,9 +10599,8 @@ var CapturedImageWrapper = styled__default['default'].div(templateObject_7$1 ||
10606
10599
  var _a, _b, _c;
10607
10600
  return (_c = (_b = (_a = props.theme.idCapture) === null || _a === void 0 ? void 0 : _a.success) === null || _b === void 0 ? void 0 : _b.imageBorderColor) !== null && _c !== void 0 ? _c : 'var(--idm-color-primary-400)';
10608
10601
  });
10609
- var CropCanvas = styled__default['default'].canvas(templateObject_8 || (templateObject_8 = tslib.__makeTemplateObject(["\n display: none;\n"], ["\n display: none;\n"])));
10610
- var StyledImage = styled__default['default'].img(templateObject_9 || (templateObject_9 = tslib.__makeTemplateObject(["\n width: 100%;\n border-radius: 4px;\n"], ["\n width: 100%;\n border-radius: 4px;\n"])));
10611
- var templateObject_1$k, templateObject_2$d, templateObject_3$a, templateObject_4$6, templateObject_5$4, templateObject_6$3, templateObject_7$1, templateObject_8, templateObject_9;
10602
+ var StyledImage = styled__default['default'].img(templateObject_8 || (templateObject_8 = tslib.__makeTemplateObject(["\n width: 100%;\n border-radius: 4px;\n"], ["\n width: 100%;\n border-radius: 4px;\n"])));
10603
+ var templateObject_1$k, templateObject_2$d, templateObject_3$a, templateObject_4$6, templateObject_5$4, templateObject_6$3, templateObject_7$1, templateObject_8;
10612
10604
 
10613
10605
  var CameraVideoTag = function CameraVideoTag(_a) {
10614
10606
  var _b;