idmission-web-sdk 1.0.90 → 1.0.92
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/id_capture/IdCaptureModelsProvider.d.ts +8 -1
- package/dist/contexts/SubmissionContext.d.ts +2 -0
- package/dist/sdk2.cjs.development.js +38 -53
- 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 +38 -53
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +38 -53
- 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
|
@@ -35,6 +35,11 @@ export declare const PREDICTION_POSITIONS: {
|
|
|
35
35
|
scores: number;
|
|
36
36
|
labels: number;
|
|
37
37
|
};
|
|
38
|
+
export type BestFrame = {
|
|
39
|
+
canvas: HTMLCanvasElement;
|
|
40
|
+
detectionScore: number;
|
|
41
|
+
focusScore: number;
|
|
42
|
+
};
|
|
38
43
|
export type IdCaptureModelsState = {
|
|
39
44
|
ready: boolean;
|
|
40
45
|
working: MutableRefObject<boolean>;
|
|
@@ -45,8 +50,10 @@ export type IdCaptureModelsState = {
|
|
|
45
50
|
onPredictionMade: (handler: (prediction: IdCapturePrediction) => void) => void;
|
|
46
51
|
detectionTime: number;
|
|
47
52
|
focusPredictionTime: number;
|
|
48
|
-
getBestFrame: () => Promise<
|
|
53
|
+
getBestFrame: () => Promise<BestFrame | null>;
|
|
49
54
|
resetBestFrame: () => void;
|
|
55
|
+
bestFrameDetectionScore: number;
|
|
56
|
+
bestFrameFocusScore: number;
|
|
50
57
|
};
|
|
51
58
|
export declare const IdCaptureModelsContext: React.Context<IdCaptureModelsState>;
|
|
52
59
|
export type IdCaptureModelsProviderProps = {
|
|
@@ -46,7 +46,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
|
|
|
46
46
|
var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
|
|
47
47
|
var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
|
|
48
48
|
|
|
49
|
-
var webSdkVersion = '1.0.
|
|
49
|
+
var webSdkVersion = '1.0.92';
|
|
50
50
|
|
|
51
51
|
function getPlatform() {
|
|
52
52
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -1588,16 +1588,6 @@ function scanBarcode(blob, bbox) {
|
|
|
1588
1588
|
});
|
|
1589
1589
|
}
|
|
1590
1590
|
|
|
1591
|
-
function getBlobDimensions(blob) {
|
|
1592
|
-
return new Promise(function (resolve) {
|
|
1593
|
-
var image = new Image();
|
|
1594
|
-
image.onload = function () {
|
|
1595
|
-
resolve([image.naturalWidth, image.naturalHeight]);
|
|
1596
|
-
};
|
|
1597
|
-
image.src = URL.createObjectURL(blob);
|
|
1598
|
-
});
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
1591
|
function listAvailableCameras(facingMode, requestMicAccess) {
|
|
1602
1592
|
if (requestMicAccess === void 0) {
|
|
1603
1593
|
requestMicAccess = false;
|
|
@@ -8723,7 +8713,9 @@ var IdCaptureModelsContext = /*#__PURE__*/React.createContext({
|
|
|
8723
8713
|
},
|
|
8724
8714
|
resetBestFrame: function resetBestFrame() {
|
|
8725
8715
|
return null;
|
|
8726
|
-
}
|
|
8716
|
+
},
|
|
8717
|
+
bestFrameDetectionScore: 0,
|
|
8718
|
+
bestFrameFocusScore: 0
|
|
8727
8719
|
});
|
|
8728
8720
|
var defaultDocumentDetectionModelUrl = "".concat(DEFAULT_CDN_URL, "/models/documentdetection448/model.json");
|
|
8729
8721
|
var defaultFocusModelUrl = "".concat(DEFAULT_CDN_URL, "/models/focus/model.json");
|
|
@@ -8763,6 +8755,12 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
8763
8755
|
var _l = React.useState(null),
|
|
8764
8756
|
loadingError = _l[0],
|
|
8765
8757
|
setLoadingError = _l[1];
|
|
8758
|
+
var _m = React.useState(0),
|
|
8759
|
+
bestFrameDetectionScore = _m[0],
|
|
8760
|
+
setBestFrameDetectionScore = _m[1];
|
|
8761
|
+
var _o = React.useState(0),
|
|
8762
|
+
bestFrameFocusScore = _o[0],
|
|
8763
|
+
setBestFrameFocusScore = _o[1];
|
|
8766
8764
|
React.useEffect(function () {
|
|
8767
8765
|
setReady(false);
|
|
8768
8766
|
var ddmUrl = documentDetectionModelUrl || defaultDocumentDetectionModelUrl;
|
|
@@ -8840,9 +8838,9 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
8840
8838
|
if (thresholds.pdf417) setPdf417DetectionThreshold(thresholds.pdf417);
|
|
8841
8839
|
if (thresholds.focus) setFocusThreshold(thresholds.focus);
|
|
8842
8840
|
}, []);
|
|
8843
|
-
var
|
|
8844
|
-
timesAllZero =
|
|
8845
|
-
setTimesAllZero =
|
|
8841
|
+
var _p = React.useState(0),
|
|
8842
|
+
timesAllZero = _p[0],
|
|
8843
|
+
setTimesAllZero = _p[1];
|
|
8846
8844
|
var bestPredictionCanvas = React.useRef(null);
|
|
8847
8845
|
var bestFocusScore = React.useRef(0);
|
|
8848
8846
|
var makePrediction = React.useCallback(function (frame) {
|
|
@@ -8862,6 +8860,8 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
8862
8860
|
setFocusPredictionTime(prediction.focusPredictionTime);
|
|
8863
8861
|
if (bestFocusScore.current <= prediction.focusScore) {
|
|
8864
8862
|
bestFocusScore.current = prediction.focusScore;
|
|
8863
|
+
setBestFrameDetectionScore(prediction.detectionScore);
|
|
8864
|
+
setBestFrameFocusScore(prediction.focusScore);
|
|
8865
8865
|
drawToCanvas(bestPredictionCanvas.current, frame);
|
|
8866
8866
|
}
|
|
8867
8867
|
if (prediction.allZero) setTimesAllZero(function (n) {
|
|
@@ -8885,22 +8885,16 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
8885
8885
|
}, []);
|
|
8886
8886
|
var getBestFrame = React.useCallback(function () {
|
|
8887
8887
|
return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
8888
|
-
var photoURL, data;
|
|
8889
8888
|
return tslib.__generator(this, function (_a) {
|
|
8890
|
-
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
data = _a.sent();
|
|
8897
|
-
return [4 /*yield*/, data.blob()];
|
|
8898
|
-
case 2:
|
|
8899
|
-
return [2 /*return*/, _a.sent()];
|
|
8900
|
-
}
|
|
8889
|
+
if (!bestPredictionCanvas.current) return [2 /*return*/, null];
|
|
8890
|
+
return [2 /*return*/, {
|
|
8891
|
+
canvas: bestPredictionCanvas.current,
|
|
8892
|
+
detectionScore: bestFrameDetectionScore,
|
|
8893
|
+
focusScore: bestFrameFocusScore
|
|
8894
|
+
}];
|
|
8901
8895
|
});
|
|
8902
8896
|
});
|
|
8903
|
-
}, []);
|
|
8897
|
+
}, [bestFrameDetectionScore, bestFrameFocusScore]);
|
|
8904
8898
|
var resetBestFrame = React.useCallback(function () {
|
|
8905
8899
|
bestFocusScore.current = 0;
|
|
8906
8900
|
clearCanvas(bestPredictionCanvas.current);
|
|
@@ -8917,9 +8911,11 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
8917
8911
|
focusPredictionTime: focusPredictionTime,
|
|
8918
8912
|
getBestFrame: getBestFrame,
|
|
8919
8913
|
resetBestFrame: resetBestFrame,
|
|
8914
|
+
bestFrameDetectionScore: bestFrameDetectionScore,
|
|
8915
|
+
bestFrameFocusScore: bestFrameFocusScore,
|
|
8920
8916
|
error: loadingError
|
|
8921
8917
|
};
|
|
8922
|
-
}, [detectionTime, focusPredictionTime, getBestFrame, loadingError, makePrediction, onPredictionMade, ready, resetBestFrame, setThresholds, thresholds]);
|
|
8918
|
+
}, [bestFrameDetectionScore, bestFrameFocusScore, detectionTime, focusPredictionTime, getBestFrame, loadingError, makePrediction, onPredictionMade, ready, resetBestFrame, setThresholds, thresholds]);
|
|
8923
8919
|
return /*#__PURE__*/React__default['default'].createElement(IdCaptureModelsContext.Provider, {
|
|
8924
8920
|
value: value
|
|
8925
8921
|
}, children, /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
|
|
@@ -9975,9 +9971,9 @@ var IdCapture = function IdCapture(_a) {
|
|
|
9975
9971
|
React.useEffect(function () {
|
|
9976
9972
|
(function () {
|
|
9977
9973
|
return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
9978
|
-
var
|
|
9979
|
-
return tslib.__generator(this, function (
|
|
9980
|
-
switch (
|
|
9974
|
+
var bestFrame, originalCanvas, detectionScore, focusScore, width, height, canvas, isGreaterThan2k, ctx2d, imageURL;
|
|
9975
|
+
return tslib.__generator(this, function (_a) {
|
|
9976
|
+
switch (_a.label) {
|
|
9981
9977
|
case 0:
|
|
9982
9978
|
if (!shouldCapture) return [2 /*return*/];
|
|
9983
9979
|
dispatch({
|
|
@@ -9985,8 +9981,8 @@ var IdCapture = function IdCapture(_a) {
|
|
|
9985
9981
|
});
|
|
9986
9982
|
return [4 /*yield*/, getBestFrame()];
|
|
9987
9983
|
case 1:
|
|
9988
|
-
|
|
9989
|
-
if (!
|
|
9984
|
+
bestFrame = _a.sent();
|
|
9985
|
+
if (!bestFrame) {
|
|
9990
9986
|
console.log('uh oh, i did not get a photo');
|
|
9991
9987
|
dispatch({
|
|
9992
9988
|
type: 'captureFailed'
|
|
@@ -9994,21 +9990,12 @@ var IdCapture = function IdCapture(_a) {
|
|
|
9994
9990
|
return [2 /*return*/];
|
|
9995
9991
|
}
|
|
9996
9992
|
setProcessingFrame(true);
|
|
9997
|
-
|
|
9998
|
-
|
|
9999
|
-
|
|
10000
|
-
case 2:
|
|
10001
|
-
_a = _b.sent(), width = _a[0], height = _a[1];
|
|
10002
|
-
canvas = document.createElement('canvas');
|
|
10003
|
-
canvas.width = width;
|
|
10004
|
-
canvas.height = height;
|
|
10005
|
-
return [4 /*yield*/, createImageBitmap(photo)
|
|
10006
|
-
// resize image to 2k max if barcode is read
|
|
10007
|
-
];
|
|
10008
|
-
case 3:
|
|
10009
|
-
bitmap = _b.sent();
|
|
9993
|
+
originalCanvas = bestFrame.canvas, detectionScore = bestFrame.detectionScore, focusScore = bestFrame.focusScore;
|
|
9994
|
+
width = originalCanvas.width, height = originalCanvas.height;
|
|
9995
|
+
canvas = originalCanvas;
|
|
10010
9996
|
isGreaterThan2k = width > 1920 && height > 1080 || width > 1080 && height > 1920;
|
|
10011
9997
|
if (isGreaterThan2k && !!state.barcodeResult) {
|
|
9998
|
+
canvas = document.createElement('canvas');
|
|
10012
9999
|
if (width > height) {
|
|
10013
10000
|
canvas.width = 1920;
|
|
10014
10001
|
canvas.height = height * (1920 / width);
|
|
@@ -10018,11 +10005,7 @@ var IdCapture = function IdCapture(_a) {
|
|
|
10018
10005
|
}
|
|
10019
10006
|
ctx2d = canvas.getContext('2d');
|
|
10020
10007
|
if (!ctx2d) return [2 /*return*/];
|
|
10021
|
-
ctx2d.drawImage(
|
|
10022
|
-
} else {
|
|
10023
|
-
bmpCtx = canvas.getContext('bitmaprenderer');
|
|
10024
|
-
if (!bmpCtx) return [2 /*return*/];
|
|
10025
|
-
bmpCtx.transferFromImageBitmap(bitmap);
|
|
10008
|
+
ctx2d.drawImage(originalCanvas, 0, 0, canvas.width, canvas.height);
|
|
10026
10009
|
}
|
|
10027
10010
|
imageURL = canvas.toDataURL('image/jpeg', 0.92);
|
|
10028
10011
|
setImageURL(imageURL);
|
|
@@ -10031,7 +10014,9 @@ var IdCapture = function IdCapture(_a) {
|
|
|
10031
10014
|
var captureTime = new Date().getTime() - ((_a = captureStartedAt.current) !== null && _a !== void 0 ? _a : new Date()).getTime();
|
|
10032
10015
|
var metadata = {
|
|
10033
10016
|
autoCapture: 'Y',
|
|
10034
|
-
captureTime: captureTime
|
|
10017
|
+
captureTime: captureTime,
|
|
10018
|
+
bestDetectionScore: detectionScore,
|
|
10019
|
+
bestFocusScore: focusScore
|
|
10035
10020
|
};
|
|
10036
10021
|
onCapture === null || onCapture === void 0 ? void 0 : onCapture(imageURL, width, height, metadata);
|
|
10037
10022
|
dispatch({
|