scandoc-ai-components 0.0.62 → 0.0.64

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 +22 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11191,6 +11191,7 @@ class ExtractorVideo {
11191
11191
  this.scanStartTime = null;
11192
11192
  this.unsupportedDocCount = 0;
11193
11193
  this.video = null;
11194
+ this.updateOverlayTimeout = null;
11194
11195
  }
11195
11196
  reset() {
11196
11197
  this.stopVideo();
@@ -11245,6 +11246,17 @@ class ExtractorVideo {
11245
11246
  bottomPct: bottom / canvas.height
11246
11247
  };
11247
11248
  }
11249
+ updateRectangleOverlay = async () => {
11250
+ const margins = await this.getCameraMargins();
11251
+ const rectangle = document.querySelector('.desktopRectangle');
11252
+ if (!rectangle) return;
11253
+ const clamp = (v, max = 0.25) => Math.min(v, max) * 100;
11254
+ const buffer = 0.03;
11255
+ rectangle.style.top = `${clamp(margins.topPct + buffer)}%`;
11256
+ rectangle.style.bottom = `${clamp(margins.bottomPct + buffer)}%`;
11257
+ rectangle.style.left = `${clamp(margins.leftPct + buffer)}%`;
11258
+ rectangle.style.right = `${clamp(margins.rightPct + buffer)}%`;
11259
+ };
11248
11260
  async analyzeVideoStream() {
11249
11261
  if (!this.isRunning) {
11250
11262
  return;
@@ -11405,17 +11417,16 @@ class ExtractorVideo {
11405
11417
  await this.video.play().catch(e => {
11406
11418
  console.warn(`Error on video play: ${e}`);
11407
11419
  });
11408
- setTimeout(async () => {
11409
- const margins = await this.getCameraMargins();
11410
- const rectangle = document.querySelector('.desktopRectangle');
11411
- if (rectangle) {
11412
- rectangle.style.top = `${margins.topPct * 100}%`;
11413
- rectangle.style.bottom = `${margins.bottomPct * 100}%`;
11414
- rectangle.style.left = `${margins.leftPct * 100}%`;
11415
- rectangle.style.right = `${margins.rightPct * 100}%`;
11416
- }
11417
- }, 500); // Give time for video frame to show
11418
-
11420
+ this.video.onloadedmetadata = () => {
11421
+ this.updateRectangleOverlay();
11422
+ };
11423
+ setTimeout(() => this.updateRectangleOverlay(), 500);
11424
+ const scheduleOverlayUpdate = (delay = 500) => {
11425
+ clearTimeout(this.updateOverlayTimeout);
11426
+ this.updateOverlayTimeout = setTimeout(() => this.updateRectangleOverlay(), delay);
11427
+ };
11428
+ window.addEventListener("resize", () => scheduleOverlayUpdate());
11429
+ window.addEventListener("orientationchange", () => scheduleOverlayUpdate(700));
11419
11430
  this.scanStartTime = Date.now(); // Reset timer
11420
11431
  setTimeout(() => this.analyzeVideoStream(), ExtractorVideo.FREQUENCY_MS);
11421
11432
  this.showMessage("Starting scanning");
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.62",
4
+ "version": "0.0.64",
5
5
  "private": false,
6
6
  "description": "Pure JavaScript package for integrating ScanDoc-AI services.",
7
7
  "keywords": [