scandoc-ai-components 0.0.84 → 0.0.85
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/index.js +18 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11192,6 +11192,8 @@ class ExtractorVideo {
|
|
|
11192
11192
|
this.video = null;
|
|
11193
11193
|
this.lastMessage = null;
|
|
11194
11194
|
this.waitingForSecondSide = false;
|
|
11195
|
+
this.hasShownTurnMessage = false;
|
|
11196
|
+
this.awaitingNewPresence = false;
|
|
11195
11197
|
}
|
|
11196
11198
|
reset() {
|
|
11197
11199
|
this.stopVideo();
|
|
@@ -11206,6 +11208,8 @@ class ExtractorVideo {
|
|
|
11206
11208
|
this.video = null;
|
|
11207
11209
|
this.lastMessage = null;
|
|
11208
11210
|
this.waitingForSecondSide = false;
|
|
11211
|
+
this.hasShownTurnMessage = false;
|
|
11212
|
+
this.awaitingNewPresence = false;
|
|
11209
11213
|
}
|
|
11210
11214
|
async analyzeVideoStream() {
|
|
11211
11215
|
if (!this.isRunning) return;
|
|
@@ -11231,6 +11235,9 @@ class ExtractorVideo {
|
|
|
11231
11235
|
const fullImage = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.videoImgToBase64)(video, canvas, 1280, 720, false);
|
|
11232
11236
|
const validationImage = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.videoImgToBase64)(video, canvas, ExtractorVideo.VALIDATION_IMG_WIDTH, ExtractorVideo.VALIDATION_IMG_HEIGHT, true);
|
|
11233
11237
|
DOCUMENT_DETECTOR.isDocumentPresent(video).then(async isPresent => {
|
|
11238
|
+
if (this.awaitingNewPresence && isPresent) {
|
|
11239
|
+
this.awaitingNewPresence = false;
|
|
11240
|
+
}
|
|
11234
11241
|
if (!isPresent) return;
|
|
11235
11242
|
this.candidateImages.push({
|
|
11236
11243
|
fullImg: fullImage,
|
|
@@ -11265,11 +11272,15 @@ class ExtractorVideo {
|
|
|
11265
11272
|
this.extractionImages[imageSide] = images[imageId].fullImg;
|
|
11266
11273
|
if (Object.keys(this.extractionImages).length === 1) {
|
|
11267
11274
|
this.waitingForSecondSide = true;
|
|
11275
|
+
this.hasShownTurnMessage = true;
|
|
11276
|
+
this.awaitingNewPresence = true;
|
|
11268
11277
|
this.scanStartTime = Date.now();
|
|
11269
|
-
this.showMessage("Turn to the other side");
|
|
11278
|
+
this.showMessage("Turn to the other side", true);
|
|
11270
11279
|
} else if (Object.keys(this.extractionImages).length === 2) {
|
|
11271
11280
|
this.waitingForSecondSide = false;
|
|
11272
|
-
this.
|
|
11281
|
+
this.hasShownTurnMessage = false;
|
|
11282
|
+
this.awaitingNewPresence = false;
|
|
11283
|
+
this.showMessage("Validation successful", true);
|
|
11273
11284
|
const [isExtractionOk, extractionData] = await (0,_requests_extraction__WEBPACK_IMPORTED_MODULE_2__["default"])(this.extractionImages["FRONT"], this.extractionImages["BACK"], {
|
|
11274
11285
|
IgnoreBackImage: false
|
|
11275
11286
|
});
|
|
@@ -11278,6 +11289,8 @@ class ExtractorVideo {
|
|
|
11278
11289
|
}
|
|
11279
11290
|
} else if (infoCode === "1000") {
|
|
11280
11291
|
this.waitingForSecondSide = false;
|
|
11292
|
+
this.hasShownTurnMessage = false;
|
|
11293
|
+
this.awaitingNewPresence = false;
|
|
11281
11294
|
this.showMessage("Validation successful");
|
|
11282
11295
|
this.showMessage("Extracting data");
|
|
11283
11296
|
const image = images[imageId].fullImg;
|
|
@@ -11292,8 +11305,9 @@ class ExtractorVideo {
|
|
|
11292
11305
|
setTimeout(() => this.analyzeVideoStream(), ExtractorVideo.FREQUENCY_MS);
|
|
11293
11306
|
});
|
|
11294
11307
|
}
|
|
11295
|
-
showMessage(message) {
|
|
11308
|
+
showMessage(message, force = false) {
|
|
11296
11309
|
if (!message || this.lastMessage === message) return;
|
|
11310
|
+
if (this.hasShownTurnMessage && this.awaitingNewPresence && !force) return;
|
|
11297
11311
|
this.lastMessage = message;
|
|
11298
11312
|
const messageElement = document.getElementById("ScanDocAIMessage");
|
|
11299
11313
|
if (messageElement) {
|
|
@@ -11416,7 +11430,7 @@ class ExtractorVideo {
|
|
|
11416
11430
|
const isMobile = window.innerWidth < 768 || window.innerHeight > window.innerWidth;
|
|
11417
11431
|
window.innerWidth < 768 || window.innerHeight > window.innerWidth && window.innerWidth < 1024;
|
|
11418
11432
|
if (isMobile) {
|
|
11419
|
-
//
|
|
11433
|
+
// Mobile version with overlay feedback
|
|
11420
11434
|
return `
|
|
11421
11435
|
<div class="mobileVideoArea">
|
|
11422
11436
|
<video id="ScanDocAIVideoElement" class="mobileVideo" autoplay muted playsinline></video>
|