scandoc-ai-components 0.0.81 → 0.0.83

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 +23 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11190,6 +11190,7 @@ class ExtractorVideo {
11190
11190
  this.scanStartTime = null;
11191
11191
  this.unsupportedDocCount = 0;
11192
11192
  this.video = null;
11193
+ this.lastMessage = null;
11193
11194
  }
11194
11195
  reset() {
11195
11196
  this.stopVideo();
@@ -11202,6 +11203,7 @@ class ExtractorVideo {
11202
11203
  this.unsupportedDocStartTime = null;
11203
11204
  this.unsupportedDocCount = 0;
11204
11205
  this.video = null;
11206
+ this.lastMessage = null;
11205
11207
  }
11206
11208
  async analyzeVideoStream() {
11207
11209
  if (!this.isRunning) {
@@ -11257,7 +11259,18 @@ class ExtractorVideo {
11257
11259
  } else {
11258
11260
  this.unsupportedDocCount = 0;
11259
11261
  }
11260
- this.showMessage(response["Info"]);
11262
+ const imageSide = response["Side"];
11263
+ const isAlreadyScanned = this.extractionImages[imageSide] !== undefined;
11264
+ const scannedSides = Object.keys(this.extractionImages).length;
11265
+
11266
+ // Show feedback only if both sides are not yet scanned
11267
+ // Avoid overwriting "Turn to the other side" until second side appears
11268
+ if (scannedSides < 1) {
11269
+ this.showMessage(response["Info"]); // normal feedback before first side
11270
+ } else if (!isAlreadyScanned && scannedSides === 1) {
11271
+ // We are seeing a new side after 1 side has already been scanned
11272
+ this.showMessage(response["Info"]); // allow resuming feedback (if desired)
11273
+ }
11261
11274
  //
11262
11275
  if ("DetectedBlurValue" in response) {
11263
11276
  this.pastBlurValues.push(response["DetectedBlurValue"]);
@@ -11269,9 +11282,11 @@ class ExtractorVideo {
11269
11282
  const imageId = response["Index"];
11270
11283
  const imageSide = response["Side"];
11271
11284
  //
11272
- if (this.extractionImages[imageSide] === undefined) {
11273
- this.extractionImages[imageSide] = images[imageId]["fullImg"];
11285
+ if (this.extractionImages[imageSide] !== undefined) {
11286
+ this.candidateImages = [];
11287
+ return;
11274
11288
  }
11289
+ this.extractionImages[imageSide] = images[imageId]["fullImg"];
11275
11290
  const extractionImages = {
11276
11291
  ...this.extractionImages
11277
11292
  };
@@ -11310,6 +11325,7 @@ class ExtractorVideo {
11310
11325
  onExtraction(isExtractionOk, extractionData) {
11311
11326
  this.candidateImages = [];
11312
11327
  this.extractionImages = {};
11328
+ this.lastMessage = null;
11313
11329
  this.stopVideo();
11314
11330
  if (isExtractionOk) {
11315
11331
  this.showMessage("Success - data extracted", "success");
@@ -11386,6 +11402,7 @@ class ExtractorVideo {
11386
11402
  }
11387
11403
  stopVideo() {
11388
11404
  this.isRunning = false;
11405
+ this.lastMessage = null;
11389
11406
  if (this.video) {
11390
11407
  this.video.pause();
11391
11408
  if (this.video.srcObject !== undefined && this.video.srcObject !== null) {
@@ -11395,6 +11412,9 @@ class ExtractorVideo {
11395
11412
  }
11396
11413
  }
11397
11414
  showMessage(message) {
11415
+ if (!message || message.trim() === "") return;
11416
+ if (this.lastMessage === message) return;
11417
+ this.lastMessage = message;
11398
11418
  const messageElement = document.getElementById("ScanDocAIMessage");
11399
11419
  if (messageElement) {
11400
11420
  messageElement.innerText = message;
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.81",
4
+ "version": "0.0.83",
5
5
  "private": false,
6
6
  "description": "Pure JavaScript package for integrating ScanDoc-AI services.",
7
7
  "keywords": [