scandoc-ai-components 0.0.85 → 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.
Files changed (2) hide show
  1. package/dist/index.js +16 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11193,7 +11193,7 @@ class ExtractorVideo {
11193
11193
  this.lastMessage = null;
11194
11194
  this.waitingForSecondSide = false;
11195
11195
  this.hasShownTurnMessage = false;
11196
- this.awaitingNewPresence = false;
11196
+ this.turnMessageTimer = null;
11197
11197
  }
11198
11198
  reset() {
11199
11199
  this.stopVideo();
@@ -11209,7 +11209,8 @@ class ExtractorVideo {
11209
11209
  this.lastMessage = null;
11210
11210
  this.waitingForSecondSide = false;
11211
11211
  this.hasShownTurnMessage = false;
11212
- this.awaitingNewPresence = false;
11212
+ clearTimeout(this.turnMessageTimer);
11213
+ this.turnMessageTimer = null;
11213
11214
  }
11214
11215
  async analyzeVideoStream() {
11215
11216
  if (!this.isRunning) return;
@@ -11235,9 +11236,6 @@ class ExtractorVideo {
11235
11236
  const fullImage = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.videoImgToBase64)(video, canvas, 1280, 720, false);
11236
11237
  const validationImage = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.videoImgToBase64)(video, canvas, ExtractorVideo.VALIDATION_IMG_WIDTH, ExtractorVideo.VALIDATION_IMG_HEIGHT, true);
11237
11238
  DOCUMENT_DETECTOR.isDocumentPresent(video).then(async isPresent => {
11238
- if (this.awaitingNewPresence && isPresent) {
11239
- this.awaitingNewPresence = false;
11240
- }
11241
11239
  if (!isPresent) return;
11242
11240
  this.candidateImages.push({
11243
11241
  fullImg: fullImage,
@@ -11255,7 +11253,6 @@ class ExtractorVideo {
11255
11253
  const imageSide = response["Side"];
11256
11254
  const message = response["Info"];
11257
11255
  const isNewSide = this.extractionImages[imageSide] === undefined;
11258
- const numScannedSides = Object.keys(this.extractionImages).length;
11259
11256
  if (!this.waitingForSecondSide || isNewSide) {
11260
11257
  this.showMessage(message);
11261
11258
  }
@@ -11273,13 +11270,19 @@ class ExtractorVideo {
11273
11270
  if (Object.keys(this.extractionImages).length === 1) {
11274
11271
  this.waitingForSecondSide = true;
11275
11272
  this.hasShownTurnMessage = true;
11276
- this.awaitingNewPresence = true;
11277
11273
  this.scanStartTime = Date.now();
11278
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);
11279
11283
  } else if (Object.keys(this.extractionImages).length === 2) {
11280
11284
  this.waitingForSecondSide = false;
11281
11285
  this.hasShownTurnMessage = false;
11282
- this.awaitingNewPresence = false;
11283
11286
  this.showMessage("Validation successful", true);
11284
11287
  const [isExtractionOk, extractionData] = await (0,_requests_extraction__WEBPACK_IMPORTED_MODULE_2__["default"])(this.extractionImages["FRONT"], this.extractionImages["BACK"], {
11285
11288
  IgnoreBackImage: false
@@ -11290,7 +11293,6 @@ class ExtractorVideo {
11290
11293
  } else if (infoCode === "1000") {
11291
11294
  this.waitingForSecondSide = false;
11292
11295
  this.hasShownTurnMessage = false;
11293
- this.awaitingNewPresence = false;
11294
11296
  this.showMessage("Validation successful");
11295
11297
  this.showMessage("Extracting data");
11296
11298
  const image = images[imageId].fullImg;
@@ -11307,7 +11309,7 @@ class ExtractorVideo {
11307
11309
  }
11308
11310
  showMessage(message, force = false) {
11309
11311
  if (!message || this.lastMessage === message) return;
11310
- if (this.hasShownTurnMessage && this.awaitingNewPresence && !force) return;
11312
+ if (this.waitingForSecondSide && !force) return;
11311
11313
  this.lastMessage = message;
11312
11314
  const messageElement = document.getElementById("ScanDocAIMessage");
11313
11315
  if (messageElement) {
@@ -11317,6 +11319,8 @@ class ExtractorVideo {
11317
11319
  onExtraction(isExtractionOk, extractionData) {
11318
11320
  this.candidateImages = [];
11319
11321
  this.extractionImages = {};
11322
+ clearTimeout(this.turnMessageTimer);
11323
+ this.turnMessageTimer = null;
11320
11324
  this.stopVideo();
11321
11325
  if (isExtractionOk) {
11322
11326
  this.showMessage("Success - data extracted", "success");
@@ -11399,6 +11403,8 @@ class ExtractorVideo {
11399
11403
  }
11400
11404
  this.video.srcObject = null;
11401
11405
  }
11406
+ clearTimeout(this.turnMessageTimer);
11407
+ this.turnMessageTimer = null;
11402
11408
  }
11403
11409
  adjustOverlayPosition() {
11404
11410
  const video = this.video;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "scandoc-ai-components",
3
3
  "author": "ScanDoc-AI",
4
- "version": "0.0.85",
4
+ "version": "0.0.86",
5
5
  "private": false,
6
6
  "description": "Pure JavaScript package for integrating ScanDoc-AI services.",
7
7
  "keywords": [