scandoc-ai-components 0.0.43 → 0.0.45
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 +13 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11222,8 +11222,14 @@ class ExtractorVideo {
|
|
|
11222
11222
|
//
|
|
11223
11223
|
const canvas = document.createElement("canvas");
|
|
11224
11224
|
let video = document.getElementById("ScanDocAIVideoElement");
|
|
11225
|
+
if (video && video.videoWidth < video.videoHeight) {
|
|
11226
|
+
this.showMessage("Please rotate your device to landscape mode.");
|
|
11227
|
+
this.candidateImages = [];
|
|
11228
|
+
setTimeout(() => this.analyzeVideoStream(), ExtractorVideo.FREQUENCY_MS);
|
|
11229
|
+
return;
|
|
11230
|
+
}
|
|
11225
11231
|
//
|
|
11226
|
-
const fullImage = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.videoImgToBase64)(video, canvas,
|
|
11232
|
+
const fullImage = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.videoImgToBase64)(video, canvas, 1280, 720, false);
|
|
11227
11233
|
const validationImage = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.videoImgToBase64)(video, canvas, ExtractorVideo.VALIDATION_IMG_WIDTH, ExtractorVideo.VALIDATION_IMG_HEIGHT, true);
|
|
11228
11234
|
DOCUMENT_DETECTOR.isDocumentPresent(video).then(async isPresent => {
|
|
11229
11235
|
if (isPresent) {
|
|
@@ -11328,7 +11334,8 @@ class ExtractorVideo {
|
|
|
11328
11334
|
async startVideo() {
|
|
11329
11335
|
try {
|
|
11330
11336
|
const serviceConfig = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getScanDocAIConfig)();
|
|
11331
|
-
await serviceConfig.getAccessToken(true);
|
|
11337
|
+
await serviceConfig.getAccessToken(true); // this will throw if 401
|
|
11338
|
+
|
|
11332
11339
|
const videoElem = document.getElementById("ScanDocAIVideoElement");
|
|
11333
11340
|
if (!videoElem) {
|
|
11334
11341
|
throw new Error("Video element not found.");
|
|
@@ -11361,12 +11368,13 @@ class ExtractorVideo {
|
|
|
11361
11368
|
this.showMessage("Starting scanning");
|
|
11362
11369
|
return true;
|
|
11363
11370
|
} catch (error) {
|
|
11371
|
+
console.error("startVideo failed:", error);
|
|
11364
11372
|
this.isRunning = false;
|
|
11365
11373
|
this.stopVideo();
|
|
11366
11374
|
this.onExtractedResults({
|
|
11367
11375
|
success: false,
|
|
11368
11376
|
code: error.status === 401 ? "004" : "005",
|
|
11369
|
-
info: error.status === 401 ? "Authentication failed." : error.message || "
|
|
11377
|
+
info: error.status === 401 ? "Authentication failed: Invalid API key." : "Startup failed: " + (error.message || "Unknown error")
|
|
11370
11378
|
});
|
|
11371
11379
|
return false;
|
|
11372
11380
|
}
|
|
@@ -11631,11 +11639,13 @@ class ServiceConfig {
|
|
|
11631
11639
|
this.refreshToken = data["refresh_token"];
|
|
11632
11640
|
return this.accessToken;
|
|
11633
11641
|
} else {
|
|
11642
|
+
console.error("Could not authenticate! Check your static key!");
|
|
11634
11643
|
const error = new Error("Authentication failed");
|
|
11635
11644
|
error.status = 401;
|
|
11636
11645
|
throw error;
|
|
11637
11646
|
}
|
|
11638
11647
|
}
|
|
11648
|
+
return this.accessToken;
|
|
11639
11649
|
}
|
|
11640
11650
|
async refreshTokens() {
|
|
11641
11651
|
if (this.refreshToken !== undefined) {
|