scandoc-ai-components 0.0.84 → 0.0.86
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 +25 -5
- 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.turnMessageTimer = null;
|
|
11195
11197
|
}
|
|
11196
11198
|
reset() {
|
|
11197
11199
|
this.stopVideo();
|
|
@@ -11206,6 +11208,9 @@ class ExtractorVideo {
|
|
|
11206
11208
|
this.video = null;
|
|
11207
11209
|
this.lastMessage = null;
|
|
11208
11210
|
this.waitingForSecondSide = false;
|
|
11211
|
+
this.hasShownTurnMessage = false;
|
|
11212
|
+
clearTimeout(this.turnMessageTimer);
|
|
11213
|
+
this.turnMessageTimer = null;
|
|
11209
11214
|
}
|
|
11210
11215
|
async analyzeVideoStream() {
|
|
11211
11216
|
if (!this.isRunning) return;
|
|
@@ -11248,7 +11253,6 @@ class ExtractorVideo {
|
|
|
11248
11253
|
const imageSide = response["Side"];
|
|
11249
11254
|
const message = response["Info"];
|
|
11250
11255
|
const isNewSide = this.extractionImages[imageSide] === undefined;
|
|
11251
|
-
const numScannedSides = Object.keys(this.extractionImages).length;
|
|
11252
11256
|
if (!this.waitingForSecondSide || isNewSide) {
|
|
11253
11257
|
this.showMessage(message);
|
|
11254
11258
|
}
|
|
@@ -11265,11 +11269,21 @@ class ExtractorVideo {
|
|
|
11265
11269
|
this.extractionImages[imageSide] = images[imageId].fullImg;
|
|
11266
11270
|
if (Object.keys(this.extractionImages).length === 1) {
|
|
11267
11271
|
this.waitingForSecondSide = true;
|
|
11272
|
+
this.hasShownTurnMessage = true;
|
|
11268
11273
|
this.scanStartTime = Date.now();
|
|
11269
|
-
this.showMessage("Turn to the other side");
|
|
11274
|
+
this.showMessage("Turn to the other side", true);
|
|
11275
|
+
|
|
11276
|
+
// Clear lock after 3 seconds
|
|
11277
|
+
clearTimeout(this.turnMessageTimer);
|
|
11278
|
+
this.turnMessageTimer = setTimeout(() => {
|
|
11279
|
+
this.hasShownTurnMessage = false;
|
|
11280
|
+
this.waitingForSecondSide = false;
|
|
11281
|
+
this.lastMessage = null; // allow same message again later
|
|
11282
|
+
}, 3000);
|
|
11270
11283
|
} else if (Object.keys(this.extractionImages).length === 2) {
|
|
11271
11284
|
this.waitingForSecondSide = false;
|
|
11272
|
-
this.
|
|
11285
|
+
this.hasShownTurnMessage = false;
|
|
11286
|
+
this.showMessage("Validation successful", true);
|
|
11273
11287
|
const [isExtractionOk, extractionData] = await (0,_requests_extraction__WEBPACK_IMPORTED_MODULE_2__["default"])(this.extractionImages["FRONT"], this.extractionImages["BACK"], {
|
|
11274
11288
|
IgnoreBackImage: false
|
|
11275
11289
|
});
|
|
@@ -11278,6 +11292,7 @@ class ExtractorVideo {
|
|
|
11278
11292
|
}
|
|
11279
11293
|
} else if (infoCode === "1000") {
|
|
11280
11294
|
this.waitingForSecondSide = false;
|
|
11295
|
+
this.hasShownTurnMessage = false;
|
|
11281
11296
|
this.showMessage("Validation successful");
|
|
11282
11297
|
this.showMessage("Extracting data");
|
|
11283
11298
|
const image = images[imageId].fullImg;
|
|
@@ -11292,8 +11307,9 @@ class ExtractorVideo {
|
|
|
11292
11307
|
setTimeout(() => this.analyzeVideoStream(), ExtractorVideo.FREQUENCY_MS);
|
|
11293
11308
|
});
|
|
11294
11309
|
}
|
|
11295
|
-
showMessage(message) {
|
|
11310
|
+
showMessage(message, force = false) {
|
|
11296
11311
|
if (!message || this.lastMessage === message) return;
|
|
11312
|
+
if (this.waitingForSecondSide && !force) return;
|
|
11297
11313
|
this.lastMessage = message;
|
|
11298
11314
|
const messageElement = document.getElementById("ScanDocAIMessage");
|
|
11299
11315
|
if (messageElement) {
|
|
@@ -11303,6 +11319,8 @@ class ExtractorVideo {
|
|
|
11303
11319
|
onExtraction(isExtractionOk, extractionData) {
|
|
11304
11320
|
this.candidateImages = [];
|
|
11305
11321
|
this.extractionImages = {};
|
|
11322
|
+
clearTimeout(this.turnMessageTimer);
|
|
11323
|
+
this.turnMessageTimer = null;
|
|
11306
11324
|
this.stopVideo();
|
|
11307
11325
|
if (isExtractionOk) {
|
|
11308
11326
|
this.showMessage("Success - data extracted", "success");
|
|
@@ -11385,6 +11403,8 @@ class ExtractorVideo {
|
|
|
11385
11403
|
}
|
|
11386
11404
|
this.video.srcObject = null;
|
|
11387
11405
|
}
|
|
11406
|
+
clearTimeout(this.turnMessageTimer);
|
|
11407
|
+
this.turnMessageTimer = null;
|
|
11388
11408
|
}
|
|
11389
11409
|
adjustOverlayPosition() {
|
|
11390
11410
|
const video = this.video;
|
|
@@ -11416,7 +11436,7 @@ class ExtractorVideo {
|
|
|
11416
11436
|
const isMobile = window.innerWidth < 768 || window.innerHeight > window.innerWidth;
|
|
11417
11437
|
window.innerWidth < 768 || window.innerHeight > window.innerWidth && window.innerWidth < 1024;
|
|
11418
11438
|
if (isMobile) {
|
|
11419
|
-
//
|
|
11439
|
+
// Mobile version with overlay feedback
|
|
11420
11440
|
return `
|
|
11421
11441
|
<div class="mobileVideoArea">
|
|
11422
11442
|
<video id="ScanDocAIVideoElement" class="mobileVideo" autoplay muted playsinline></video>
|