@privateid/ultrapass-web-sdk 1.3.1 → 1.3.2-1300478
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/README.md +75 -75
- package/dist/apiUtils.d.ts +46 -46
- package/dist/apiUtils.js +922 -922
- package/dist/application/index.d.ts +7 -7
- package/dist/application/index.js +27 -27
- package/dist/application/modules/core/document/DocumentService.d.ts +22 -22
- package/dist/application/modules/core/document/DocumentService.js +254 -254
- package/dist/application/modules/core/document/document.constants.d.ts +15 -15
- package/dist/application/modules/core/document/document.constants.js +21 -21
- package/dist/application/modules/core/document/document.domain.d.ts +7 -7
- package/dist/application/modules/core/document/document.domain.js +1 -1
- package/dist/application/modules/core/document/document.types.d.ts +17 -17
- package/dist/application/modules/core/document/document.types.js +1 -1
- package/dist/application/modules/core/document/document.utils.d.ts +3 -3
- package/dist/application/modules/core/document/document.utils.js +58 -58
- package/dist/application/modules/core/document/index.d.ts +3 -3
- package/dist/application/modules/core/document/index.js +1 -1
- package/dist/application/modules/core/face/FaceService.d.ts +33 -33
- package/dist/application/modules/core/face/FaceService.js +228 -221
- package/dist/application/modules/core/face/FaceService.js.map +1 -1
- package/dist/application/modules/core/face/face.constants.d.ts +53 -53
- package/dist/application/modules/core/face/face.constants.js +53 -53
- package/dist/application/modules/core/face/face.domain.d.ts +10 -10
- package/dist/application/modules/core/face/face.domain.js +1 -1
- package/dist/application/modules/core/face/face.types.d.ts +41 -38
- package/dist/application/modules/core/face/face.types.js +1 -1
- package/dist/application/modules/core/face/face.utils.d.ts +15 -15
- package/dist/application/modules/core/face/face.utils.js +101 -101
- package/dist/application/modules/core/face/index.d.ts +3 -3
- package/dist/application/modules/core/face/index.js +1 -1
- package/dist/application/modules/global/shared.constants.d.ts +2 -2
- package/dist/application/modules/global/shared.constants.js +2 -2
- package/dist/application/modules/global/shared.utils.d.ts +25 -25
- package/dist/application/modules/global/shared.utils.js +100 -100
- package/dist/application/modules/global/shared.utils.js.map +1 -1
- package/dist/application/modules/internal/feature-flag/LDFeatureFlagService.d.ts +9 -0
- package/dist/application/modules/internal/feature-flag/LDFeatureFlagService.js +32 -0
- package/dist/application/modules/internal/feature-flag/LDFeatureFlagService.js.map +1 -0
- package/dist/application/modules/internal/feature-flag/feature-flag-init.d.ts +11 -0
- package/dist/application/modules/internal/feature-flag/feature-flag-init.js +24 -0
- package/dist/application/modules/internal/feature-flag/feature-flag-init.js.map +1 -0
- package/dist/application/modules/internal/feature-flag/feature-flag.domain.d.ts +10 -0
- package/dist/application/modules/internal/feature-flag/feature-flag.domain.js +7 -0
- package/dist/application/modules/internal/feature-flag/feature-flag.domain.js.map +1 -0
- package/dist/application/modules/internal/feature-flag/featureFlagInit.d.ts +11 -0
- package/dist/application/modules/internal/feature-flag/featureFlagInit.js +44 -0
- package/dist/application/modules/internal/feature-flag/featureFlagInit.js.map +1 -0
- package/dist/application/modules/internal/feature-flag/index.d.ts +2 -0
- package/dist/application/modules/internal/feature-flag/index.js +3 -0
- package/dist/application/modules/internal/feature-flag/index.js.map +1 -0
- package/dist/application/modules/internal/shared/index.d.ts +2 -0
- package/dist/application/modules/internal/shared/index.js +3 -0
- package/dist/application/modules/internal/shared/index.js.map +1 -0
- package/dist/application/modules/internal/shared/shared.constants.d.ts +2 -0
- package/dist/application/modules/internal/shared/shared.constants.js +3 -0
- package/dist/application/modules/internal/shared/shared.constants.js.map +1 -0
- package/dist/application/modules/internal/shared/shared.utils.d.ts +44 -0
- package/dist/application/modules/internal/shared/shared.utils.js +204 -0
- package/dist/application/modules/internal/shared/shared.utils.js.map +1 -0
- package/dist/application/modules/internal/wasm-orchestrator/WasmOrchestratorService.d.ts +28 -0
- package/dist/application/modules/internal/wasm-orchestrator/WasmOrchestratorService.js +380 -0
- package/dist/application/modules/internal/wasm-orchestrator/WasmOrchestratorService.js.map +1 -0
- package/dist/application/modules/internal/wasm-orchestrator/index.d.ts +6 -0
- package/dist/application/modules/internal/wasm-orchestrator/index.js +9 -0
- package/dist/application/modules/internal/wasm-orchestrator/index.js.map +1 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.constants.d.ts +28 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.constants.js +35 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.constants.js.map +1 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.domain.d.ts +51 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.domain.js +2 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.domain.js.map +1 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.types.d.ts +142 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.types.js +2 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.types.js.map +1 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.utils.d.ts +86 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.utils.js +201 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.utils.js.map +1 -0
- package/dist/application/modules/support/camera/CameraServiceFactory.d.ts +10 -10
- package/dist/application/modules/support/camera/CameraServiceFactory.js +33 -33
- package/dist/application/modules/support/camera/CameraServiceFactory.js.map +1 -1
- package/dist/application/modules/support/camera/camera.constants.d.ts +9 -9
- package/dist/application/modules/support/camera/camera.constants.js +48 -48
- package/dist/application/modules/support/camera/camera.domain.d.ts +15 -15
- package/dist/application/modules/support/camera/camera.domain.js +1 -1
- package/dist/application/modules/support/camera/camera.types.d.ts +42 -42
- package/dist/application/modules/support/camera/camera.types.js +10 -10
- package/dist/application/modules/support/camera/camera.utils.d.ts +157 -157
- package/dist/application/modules/support/camera/camera.utils.js +623 -623
- package/dist/application/modules/support/camera/index.d.ts +24 -24
- package/dist/application/modules/support/camera/index.js +27 -27
- package/dist/application/modules/support/camera/services/BaseCameraService.d.ts +41 -41
- package/dist/application/modules/support/camera/services/BaseCameraService.js +278 -278
- package/dist/application/modules/support/camera/services/DesktopCameraService.d.ts +5 -5
- package/dist/application/modules/support/camera/services/DesktopCameraService.js +46 -46
- package/dist/application/modules/support/camera/services/FirefoxCameraService.d.ts +5 -5
- package/dist/application/modules/support/camera/services/FirefoxCameraService.js +46 -46
- package/dist/application/modules/support/camera/services/MacSafariCameraService.d.ts +5 -5
- package/dist/application/modules/support/camera/services/MacSafariCameraService.js +47 -47
- package/dist/application/modules/support/camera/services/MobileCameraService.d.ts +5 -5
- package/dist/application/modules/support/camera/services/MobileCameraService.js +133 -133
- package/dist/application/modules/support/engine/EngineService.d.ts +15 -0
- package/dist/application/modules/support/engine/EngineService.js +106 -0
- package/dist/application/modules/support/engine/EngineService.js.map +1 -0
- package/dist/application/modules/support/engine/engine.constants.d.ts +33 -0
- package/dist/application/modules/support/engine/engine.constants.js +35 -0
- package/dist/application/modules/support/engine/engine.constants.js.map +1 -0
- package/dist/application/modules/support/engine/engine.domain.d.ts +23 -0
- package/dist/application/modules/support/engine/engine.domain.js +2 -0
- package/dist/application/modules/support/engine/engine.domain.js.map +1 -0
- package/dist/application/modules/support/engine/engine.types.d.ts +32 -0
- package/dist/application/modules/support/engine/engine.types.js +2 -0
- package/dist/application/modules/support/engine/engine.types.js.map +1 -0
- package/dist/application/modules/support/engine/engine.utils.d.ts +65 -0
- package/dist/application/modules/support/engine/engine.utils.js +135 -0
- package/dist/application/modules/support/engine/engine.utils.js.map +1 -0
- package/dist/application/modules/support/engine/index.d.ts +3 -0
- package/dist/application/modules/support/engine/index.js +2 -0
- package/dist/application/modules/support/engine/index.js.map +1 -0
- package/dist/application/modules/support/permissions/PermissionsService.d.ts +55 -55
- package/dist/application/modules/support/permissions/PermissionsService.js +183 -183
- package/dist/application/modules/support/permissions/index.d.ts +4 -4
- package/dist/application/modules/support/permissions/index.js +2 -2
- package/dist/application/modules/support/permissions/permission.utils.d.ts +6 -6
- package/dist/application/modules/support/permissions/permission.utils.js +33 -33
- package/dist/application/modules/support/permissions/permissions.domain.d.ts +6 -6
- package/dist/application/modules/support/permissions/permissions.domain.js +1 -1
- package/dist/application/modules/support/permissions/permissions.types.d.ts +9 -9
- package/dist/application/modules/support/permissions/permissions.types.js +1 -1
- package/dist/application/modules/support/wasm/WasmService.d.ts +25 -25
- package/dist/application/modules/support/wasm/WasmService.js +156 -155
- package/dist/application/modules/support/wasm/WasmService.js.map +1 -1
- package/dist/application/modules/support/wasm/index.d.ts +6 -6
- package/dist/application/modules/support/wasm/index.js +8 -8
- package/dist/application/modules/support/wasm/wasm.constants.d.ts +78 -78
- package/dist/application/modules/support/wasm/wasm.constants.js +86 -86
- package/dist/application/modules/support/wasm/wasm.domain.d.ts +52 -52
- package/dist/application/modules/support/wasm/wasm.domain.js +1 -1
- package/dist/application/modules/support/wasm/wasm.types.d.ts +119 -118
- package/dist/application/modules/support/wasm/wasm.types.js +1 -1
- package/dist/application/modules/support/wasm/wasm.utils.d.ts +88 -88
- package/dist/application/modules/support/wasm/wasm.utils.js +243 -243
- package/dist/application/modules/support/wasm-orchestrator/WasmOrchestratorService.d.ts +28 -0
- package/dist/application/modules/support/wasm-orchestrator/WasmOrchestratorService.js +324 -0
- package/dist/application/modules/support/wasm-orchestrator/WasmOrchestratorService.js.map +1 -0
- package/dist/application/modules/support/wasm-orchestrator/index.d.ts +6 -0
- package/dist/application/modules/support/wasm-orchestrator/index.js +9 -0
- package/dist/application/modules/support/wasm-orchestrator/index.js.map +1 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.constants.d.ts +36 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.constants.js +44 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.constants.js.map +1 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.domain.d.ts +47 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.domain.js +2 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.domain.js.map +1 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.types.d.ts +136 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.types.js +2 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.types.js.map +1 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.utils.d.ts +91 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.utils.js +250 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.utils.js.map +1 -0
- package/dist/application/workers/index.d.ts +42 -42
- package/dist/application/workers/index.js +8 -8
- package/dist/application/workers/wasm/WasmWorkerService.d.ts +66 -0
- package/dist/application/workers/wasm/WasmWorkerService.js +801 -0
- package/dist/application/workers/wasm/WasmWorkerService.js.map +1 -0
- package/dist/application/workers/wasm/index.d.ts +4 -0
- package/dist/application/workers/wasm/index.js +9 -0
- package/dist/application/workers/wasm/index.js.map +1 -0
- package/dist/application/workers/wasm/wasm-worker.constants.d.ts +5 -0
- package/dist/application/workers/wasm/wasm-worker.constants.js +6 -0
- package/dist/application/workers/wasm/wasm-worker.constants.js.map +1 -0
- package/dist/application/workers/wasm/wasm-worker.domain.d.ts +99 -0
- package/dist/application/workers/wasm/wasm-worker.domain.js +2 -0
- package/dist/application/workers/wasm/wasm-worker.domain.js.map +1 -0
- package/dist/application/workers/wasm/wasm-worker.types.d.ts +88 -0
- package/dist/application/workers/wasm/wasm-worker.types.js +2 -0
- package/dist/application/workers/wasm/wasm-worker.types.js.map +1 -0
- package/dist/application/workers/wasm/wasm-worker.utils.d.ts +10 -0
- package/dist/application/workers/wasm/wasm-worker.utils.js +130 -0
- package/dist/application/workers/wasm/wasm-worker.utils.js.map +1 -0
- package/dist/buildConfig.d.ts +3 -0
- package/dist/buildConfig.js +7 -0
- package/dist/buildConfig.js.map +1 -0
- package/dist/cameraUtils.d.ts +77 -77
- package/dist/cameraUtils.js +361 -361
- package/dist/constants.d.ts +9 -9
- package/dist/constants.js +13 -13
- package/dist/createCallback.d.ts +56 -56
- package/dist/createCallback.js +332 -331
- package/dist/createCallback.js.map +1 -1
- package/dist/dbUtils.d.ts +14 -14
- package/dist/dbUtils.js +148 -148
- package/dist/envUtils.d.ts +4 -4
- package/dist/envUtils.js +16 -16
- package/dist/faceModule.d.ts +196 -196
- package/dist/faceModule.js +978 -978
- package/dist/featureFlagInit.d.ts +11 -0
- package/dist/featureFlagInit.js +44 -0
- package/dist/featureFlagInit.js.map +1 -0
- package/dist/index.d.ts +38 -38
- package/dist/index.js +82 -82
- package/dist/main.d.ts +30 -30
- package/dist/main.js +84 -84
- package/dist/types.d.ts +139 -139
- package/dist/types.js +77 -77
- package/dist/utils.d.ts +84 -84
- package/dist/utils.js +580 -580
- package/package.json +102 -102
- package/wasm/ultra/nosimd/{25.11.13-1357710 → 26.01.08-1300478}/privid_fhe_uber.js +18 -18
- package/wasm/ultra/nosimd/{25.11.13-1357710 → 26.01.08-1300478}/privid_fhe_uber.wasm +0 -0
- package/wasm/ultra/nosimd/version.json +2 -2
- package/wasm/ultra/simd/{25.11.13-1357710 → 26.01.08-1300478}/privid_fhe_uber.js +18 -18
- package/wasm/ultra/simd/{25.11.13-1357710 → 26.01.08-1300478}/privid_fhe_uber.wasm +0 -0
- package/wasm/ultra/simd/version.json +2 -2
- package/workers/comlink.min.js +7 -7
- package/workers/comlink.min.js.map +1 -1
- package/workers/wasm.worker.js +936 -924
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
/* eslint-disable import/prefer-default-export */
|
|
11
|
-
import { BaseCameraService } from './BaseCameraService';
|
|
12
|
-
import { CameraFaceMode } from '../camera.types';
|
|
13
|
-
import { printLogs } from '../../../global/shared.utils';
|
|
14
|
-
import { getFilteredVideoDevices, isFaceTimeCamera, getMediaDeviceInfo, getDeviceMediaStream, handleDeviceId, } from '../camera.utils';
|
|
15
|
-
export class DesktopCameraService extends BaseCameraService {
|
|
16
|
-
openCamera(props) {
|
|
17
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
printLogs('[DesktopCameraService] openCamera props', props);
|
|
19
|
-
try {
|
|
20
|
-
this.setVideoElementId(props.videoElementId);
|
|
21
|
-
this.setFaceMode(props.requestFaceMode || CameraFaceMode.front);
|
|
22
|
-
const { isGranted } = yield this.permissionsService.requestCameraPermissions();
|
|
23
|
-
const devices = isGranted ? yield getFilteredVideoDevices() : [];
|
|
24
|
-
devices.forEach((device, index) => {
|
|
25
|
-
printLogs(`[DesktopCameraService] openCamera device ${index}: `, device);
|
|
26
|
-
});
|
|
27
|
-
if (devices.length === 0) {
|
|
28
|
-
throw new Error('NO_CAMERA');
|
|
29
|
-
}
|
|
30
|
-
const deviceId = handleDeviceId(devices, props.deviceId);
|
|
31
|
-
this.setCurrentDeviceId(deviceId);
|
|
32
|
-
printLogs(`[DesktopCameraService] openCamera deviceId: `, deviceId);
|
|
33
|
-
const mediaDeviceInfo = yield getMediaDeviceInfo(devices, deviceId);
|
|
34
|
-
printLogs(`[DesktopCameraService] openCamera mediaDeviceInfo: `, mediaDeviceInfo);
|
|
35
|
-
const isMacFaceTimeCamera = isFaceTimeCamera(mediaDeviceInfo.label, props.isDocumentScan);
|
|
36
|
-
const stream = yield getDeviceMediaStream(mediaDeviceInfo.deviceId, 'desktop', { isMacFaceTimeCamera });
|
|
37
|
-
printLogs(`[DesktopCameraService] openCamera stream: `, stream);
|
|
38
|
-
return this.prepareCameraResult(stream, devices, this.faceMode, props.videoElementId);
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
printLogs(`[DesktopCameraService] openCamera error: `, error, 'ERROR');
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
/* eslint-disable import/prefer-default-export */
|
|
11
|
+
import { BaseCameraService } from './BaseCameraService';
|
|
12
|
+
import { CameraFaceMode } from '../camera.types';
|
|
13
|
+
import { printLogs } from '../../../global/shared.utils';
|
|
14
|
+
import { getFilteredVideoDevices, isFaceTimeCamera, getMediaDeviceInfo, getDeviceMediaStream, handleDeviceId, } from '../camera.utils';
|
|
15
|
+
export class DesktopCameraService extends BaseCameraService {
|
|
16
|
+
openCamera(props) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
printLogs('[DesktopCameraService] openCamera props', props);
|
|
19
|
+
try {
|
|
20
|
+
this.setVideoElementId(props.videoElementId);
|
|
21
|
+
this.setFaceMode(props.requestFaceMode || CameraFaceMode.front);
|
|
22
|
+
const { isGranted } = yield this.permissionsService.requestCameraPermissions();
|
|
23
|
+
const devices = isGranted ? yield getFilteredVideoDevices() : [];
|
|
24
|
+
devices.forEach((device, index) => {
|
|
25
|
+
printLogs(`[DesktopCameraService] openCamera device ${index}: `, device);
|
|
26
|
+
});
|
|
27
|
+
if (devices.length === 0) {
|
|
28
|
+
throw new Error('NO_CAMERA');
|
|
29
|
+
}
|
|
30
|
+
const deviceId = handleDeviceId(devices, props.deviceId);
|
|
31
|
+
this.setCurrentDeviceId(deviceId);
|
|
32
|
+
printLogs(`[DesktopCameraService] openCamera deviceId: `, deviceId);
|
|
33
|
+
const mediaDeviceInfo = yield getMediaDeviceInfo(devices, deviceId);
|
|
34
|
+
printLogs(`[DesktopCameraService] openCamera mediaDeviceInfo: `, mediaDeviceInfo);
|
|
35
|
+
const isMacFaceTimeCamera = isFaceTimeCamera(mediaDeviceInfo.label, props.isDocumentScan);
|
|
36
|
+
const stream = yield getDeviceMediaStream(mediaDeviceInfo.deviceId, 'desktop', { isMacFaceTimeCamera });
|
|
37
|
+
printLogs(`[DesktopCameraService] openCamera stream: `, stream);
|
|
38
|
+
return this.prepareCameraResult(stream, devices, this.faceMode, props.videoElementId);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
printLogs(`[DesktopCameraService] openCamera error: `, error, 'ERROR');
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
47
|
//# sourceMappingURL=DesktopCameraService.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseCameraService } from './BaseCameraService';
|
|
2
|
-
import { CameraOpenResult, OpenCameraProps } from '../camera.types';
|
|
3
|
-
export declare class FirefoxCameraService extends BaseCameraService {
|
|
4
|
-
openCamera(props: OpenCameraProps): Promise<CameraOpenResult>;
|
|
5
|
-
}
|
|
1
|
+
import { BaseCameraService } from './BaseCameraService';
|
|
2
|
+
import { CameraOpenResult, OpenCameraProps } from '../camera.types';
|
|
3
|
+
export declare class FirefoxCameraService extends BaseCameraService {
|
|
4
|
+
openCamera(props: OpenCameraProps): Promise<CameraOpenResult>;
|
|
5
|
+
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
/* eslint-disable import/prefer-default-export */
|
|
11
|
-
import { BaseCameraService } from './BaseCameraService';
|
|
12
|
-
import { CameraFaceMode } from '../camera.types';
|
|
13
|
-
import { printLogs } from '../../../global/shared.utils';
|
|
14
|
-
import { getFilteredVideoDevices, handleDeviceId, getMediaDeviceInfo, getDeviceMediaStream } from '../camera.utils';
|
|
15
|
-
export class FirefoxCameraService extends BaseCameraService {
|
|
16
|
-
openCamera(props) {
|
|
17
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
printLogs('[FirefoxCameraService] openCamera props', props);
|
|
19
|
-
try {
|
|
20
|
-
this.setVideoElementId(props.videoElementId);
|
|
21
|
-
this.setFaceMode(props.requestFaceMode || CameraFaceMode.front);
|
|
22
|
-
const { isGranted } = yield this.permissionsService.requestCameraPermissions();
|
|
23
|
-
const devices = isGranted ? yield getFilteredVideoDevices() : [];
|
|
24
|
-
devices.forEach((device, index) => {
|
|
25
|
-
printLogs(`[FirefoxCameraService] openCamera device ${index}: `, device);
|
|
26
|
-
});
|
|
27
|
-
if (devices.length === 0) {
|
|
28
|
-
throw new Error('NO_CAMERA');
|
|
29
|
-
}
|
|
30
|
-
const deviceId = handleDeviceId(devices, props.deviceId);
|
|
31
|
-
this.setCurrentDeviceId(deviceId);
|
|
32
|
-
printLogs(`[FirefoxCameraService] openCamera deviceId: `, deviceId);
|
|
33
|
-
const mediaDeviceInfo = yield getMediaDeviceInfo(devices, deviceId);
|
|
34
|
-
const stream = yield getDeviceMediaStream(mediaDeviceInfo.deviceId, 'firefox', {
|
|
35
|
-
canvasResolution: props.canvasResolution,
|
|
36
|
-
});
|
|
37
|
-
printLogs(`[FirefoxCameraService] openCamera stream: `, stream);
|
|
38
|
-
return this.prepareCameraResult(stream, devices, this.getFaceMode(), props.videoElementId);
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
printLogs(`[FirefoxCameraService] openCamera error: `, error, 'ERROR');
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
/* eslint-disable import/prefer-default-export */
|
|
11
|
+
import { BaseCameraService } from './BaseCameraService';
|
|
12
|
+
import { CameraFaceMode } from '../camera.types';
|
|
13
|
+
import { printLogs } from '../../../global/shared.utils';
|
|
14
|
+
import { getFilteredVideoDevices, handleDeviceId, getMediaDeviceInfo, getDeviceMediaStream } from '../camera.utils';
|
|
15
|
+
export class FirefoxCameraService extends BaseCameraService {
|
|
16
|
+
openCamera(props) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
printLogs('[FirefoxCameraService] openCamera props', props);
|
|
19
|
+
try {
|
|
20
|
+
this.setVideoElementId(props.videoElementId);
|
|
21
|
+
this.setFaceMode(props.requestFaceMode || CameraFaceMode.front);
|
|
22
|
+
const { isGranted } = yield this.permissionsService.requestCameraPermissions();
|
|
23
|
+
const devices = isGranted ? yield getFilteredVideoDevices() : [];
|
|
24
|
+
devices.forEach((device, index) => {
|
|
25
|
+
printLogs(`[FirefoxCameraService] openCamera device ${index}: `, device);
|
|
26
|
+
});
|
|
27
|
+
if (devices.length === 0) {
|
|
28
|
+
throw new Error('NO_CAMERA');
|
|
29
|
+
}
|
|
30
|
+
const deviceId = handleDeviceId(devices, props.deviceId);
|
|
31
|
+
this.setCurrentDeviceId(deviceId);
|
|
32
|
+
printLogs(`[FirefoxCameraService] openCamera deviceId: `, deviceId);
|
|
33
|
+
const mediaDeviceInfo = yield getMediaDeviceInfo(devices, deviceId);
|
|
34
|
+
const stream = yield getDeviceMediaStream(mediaDeviceInfo.deviceId, 'firefox', {
|
|
35
|
+
canvasResolution: props.canvasResolution,
|
|
36
|
+
});
|
|
37
|
+
printLogs(`[FirefoxCameraService] openCamera stream: `, stream);
|
|
38
|
+
return this.prepareCameraResult(stream, devices, this.getFaceMode(), props.videoElementId);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
printLogs(`[FirefoxCameraService] openCamera error: `, error, 'ERROR');
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
47
|
//# sourceMappingURL=FirefoxCameraService.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseCameraService } from './BaseCameraService';
|
|
2
|
-
import { CameraOpenResult, OpenCameraProps } from '../camera.types';
|
|
3
|
-
export declare class MacSafariCameraService extends BaseCameraService {
|
|
4
|
-
openCamera(props: OpenCameraProps): Promise<CameraOpenResult>;
|
|
5
|
-
}
|
|
1
|
+
import { BaseCameraService } from './BaseCameraService';
|
|
2
|
+
import { CameraOpenResult, OpenCameraProps } from '../camera.types';
|
|
3
|
+
export declare class MacSafariCameraService extends BaseCameraService {
|
|
4
|
+
openCamera(props: OpenCameraProps): Promise<CameraOpenResult>;
|
|
5
|
+
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
/* eslint-disable import/prefer-default-export */
|
|
11
|
-
import { BaseCameraService } from './BaseCameraService';
|
|
12
|
-
import { CameraFaceMode } from '../camera.types';
|
|
13
|
-
import { printLogs } from '../../../global/shared.utils';
|
|
14
|
-
import { getFilteredVideoDevices, handleDeviceId, getMediaDeviceInfo, getDeviceMediaStream } from '../camera.utils';
|
|
15
|
-
export class MacSafariCameraService extends BaseCameraService {
|
|
16
|
-
openCamera(props) {
|
|
17
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
printLogs('[MacSafariCameraService] openCamera props', props);
|
|
19
|
-
try {
|
|
20
|
-
const faceMode = props.requestFaceMode || CameraFaceMode.front;
|
|
21
|
-
this.setVideoElementId(props.videoElementId);
|
|
22
|
-
this.setFaceMode(faceMode);
|
|
23
|
-
const { isGranted } = yield this.permissionsService.requestCameraPermissions();
|
|
24
|
-
const devices = isGranted ? yield getFilteredVideoDevices() : [];
|
|
25
|
-
devices.forEach((device, index) => {
|
|
26
|
-
printLogs(`[MacSafariCameraService] openCamera device ${index}: `, device);
|
|
27
|
-
});
|
|
28
|
-
if (devices.length === 0) {
|
|
29
|
-
throw new Error('NO_CAMERA');
|
|
30
|
-
}
|
|
31
|
-
const deviceId = handleDeviceId(devices, props.deviceId, true);
|
|
32
|
-
this.setCurrentDeviceId(deviceId);
|
|
33
|
-
printLogs(`[MacSafariCameraService] openCamera deviceId: `, deviceId);
|
|
34
|
-
const mediaDeviceInfo = yield getMediaDeviceInfo(devices, deviceId);
|
|
35
|
-
printLogs(`[MacSafariCameraService] openCamera mediaDeviceInfo: `, mediaDeviceInfo);
|
|
36
|
-
const stream = yield getDeviceMediaStream(mediaDeviceInfo.deviceId, 'mac-safari', {
|
|
37
|
-
canvasResolution: props.canvasResolution,
|
|
38
|
-
});
|
|
39
|
-
return this.prepareCameraResult(stream, devices, faceMode, props.videoElementId);
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
printLogs(`[MacSafariCameraService] openCamera error: `, error, 'ERROR');
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
/* eslint-disable import/prefer-default-export */
|
|
11
|
+
import { BaseCameraService } from './BaseCameraService';
|
|
12
|
+
import { CameraFaceMode } from '../camera.types';
|
|
13
|
+
import { printLogs } from '../../../global/shared.utils';
|
|
14
|
+
import { getFilteredVideoDevices, handleDeviceId, getMediaDeviceInfo, getDeviceMediaStream } from '../camera.utils';
|
|
15
|
+
export class MacSafariCameraService extends BaseCameraService {
|
|
16
|
+
openCamera(props) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
printLogs('[MacSafariCameraService] openCamera props', props);
|
|
19
|
+
try {
|
|
20
|
+
const faceMode = props.requestFaceMode || CameraFaceMode.front;
|
|
21
|
+
this.setVideoElementId(props.videoElementId);
|
|
22
|
+
this.setFaceMode(faceMode);
|
|
23
|
+
const { isGranted } = yield this.permissionsService.requestCameraPermissions();
|
|
24
|
+
const devices = isGranted ? yield getFilteredVideoDevices() : [];
|
|
25
|
+
devices.forEach((device, index) => {
|
|
26
|
+
printLogs(`[MacSafariCameraService] openCamera device ${index}: `, device);
|
|
27
|
+
});
|
|
28
|
+
if (devices.length === 0) {
|
|
29
|
+
throw new Error('NO_CAMERA');
|
|
30
|
+
}
|
|
31
|
+
const deviceId = handleDeviceId(devices, props.deviceId, true);
|
|
32
|
+
this.setCurrentDeviceId(deviceId);
|
|
33
|
+
printLogs(`[MacSafariCameraService] openCamera deviceId: `, deviceId);
|
|
34
|
+
const mediaDeviceInfo = yield getMediaDeviceInfo(devices, deviceId);
|
|
35
|
+
printLogs(`[MacSafariCameraService] openCamera mediaDeviceInfo: `, mediaDeviceInfo);
|
|
36
|
+
const stream = yield getDeviceMediaStream(mediaDeviceInfo.deviceId, 'mac-safari', {
|
|
37
|
+
canvasResolution: props.canvasResolution,
|
|
38
|
+
});
|
|
39
|
+
return this.prepareCameraResult(stream, devices, faceMode, props.videoElementId);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
printLogs(`[MacSafariCameraService] openCamera error: `, error, 'ERROR');
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
48
|
//# sourceMappingURL=MacSafariCameraService.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseCameraService } from './BaseCameraService';
|
|
2
|
-
import { CameraOpenResult, OpenCameraProps } from '../camera.types';
|
|
3
|
-
export declare class MobileCameraService extends BaseCameraService {
|
|
4
|
-
openCamera(props: OpenCameraProps): Promise<CameraOpenResult>;
|
|
5
|
-
}
|
|
1
|
+
import { BaseCameraService } from './BaseCameraService';
|
|
2
|
+
import { CameraOpenResult, OpenCameraProps } from '../camera.types';
|
|
3
|
+
export declare class MobileCameraService extends BaseCameraService {
|
|
4
|
+
openCamera(props: OpenCameraProps): Promise<CameraOpenResult>;
|
|
5
|
+
}
|
|
@@ -1,134 +1,134 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
/* eslint-disable import/prefer-default-export */
|
|
11
|
-
import { BaseCameraService } from './BaseCameraService';
|
|
12
|
-
import { CameraFaceMode } from '../camera.types';
|
|
13
|
-
import { printLogs } from '../../../global/shared.utils';
|
|
14
|
-
import { getDeviceMediaStream, getFilteredVideoDevices } from '../camera.utils';
|
|
15
|
-
import { isBackCameraLabel } from '../../../../../cameraUtils';
|
|
16
|
-
export class MobileCameraService extends BaseCameraService {
|
|
17
|
-
openCamera(props) {
|
|
18
|
-
var _a, _b;
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const maxAttempts = 3;
|
|
21
|
-
let lastError = null;
|
|
22
|
-
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
23
|
-
try {
|
|
24
|
-
printLogs(`[MobileCameraService] openCamera attempt ${attempt}/${maxAttempts}`, '');
|
|
25
|
-
localStorage.removeItem('defaultDeviceId');
|
|
26
|
-
if (this.isActive()) {
|
|
27
|
-
printLogs('[MobileCameraService] Camera is active, closing before reopening', '');
|
|
28
|
-
yield this.closeCamera(props.videoElementId);
|
|
29
|
-
}
|
|
30
|
-
this.setVideoElementId(props.videoElementId);
|
|
31
|
-
this.setFaceMode(props.requestFaceMode || CameraFaceMode.front);
|
|
32
|
-
printLogs('[MobileCameraService] Requesting camera permission...', '');
|
|
33
|
-
const { isGranted } = yield this.permissionsService.requestCameraPermissions();
|
|
34
|
-
printLogs('[MobileCameraService] Getting filtered video devices...', '');
|
|
35
|
-
let devices = isGranted ? yield getFilteredVideoDevices() : [];
|
|
36
|
-
printLogs(`[MobileCameraService] Found ${devices.length} devices`, '');
|
|
37
|
-
// sorting the cameras to bring face cameras first when is face scan and back cameras first when is document scan
|
|
38
|
-
if (props.requestFaceMode === CameraFaceMode.back) {
|
|
39
|
-
devices = devices.sort((a, b) => {
|
|
40
|
-
const aIsBack = isBackCameraLabel(a.label) ? 0 : 1;
|
|
41
|
-
const bIsBack = isBackCameraLabel(b.label) ? 0 : 1;
|
|
42
|
-
return aIsBack - bIsBack;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
else if (props.requestFaceMode === CameraFaceMode.front) {
|
|
46
|
-
devices = devices.sort((a, b) => {
|
|
47
|
-
const aIsFront = isBackCameraLabel(a.label) ? 1 : 0;
|
|
48
|
-
const bIsFront = isBackCameraLabel(b.label) ? 1 : 0;
|
|
49
|
-
return aIsFront - bIsFront;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
devices.forEach((device, index) => {
|
|
53
|
-
printLogs(`[MobileCameraService] Device ${index}: `, device);
|
|
54
|
-
});
|
|
55
|
-
if (devices.length === 0) {
|
|
56
|
-
throw new Error('NO_CAMERA');
|
|
57
|
-
}
|
|
58
|
-
const isFirstPermissionRequest = !props.deviceId && this.faceMode !== CameraFaceMode.back;
|
|
59
|
-
// If we don't have permission yet (first time), use only facingMode for more reliable camera selection
|
|
60
|
-
// If we already have permission, we can use deviceId for specific camera selection
|
|
61
|
-
const useDeviceId = isFirstPermissionRequest ? undefined : props.deviceId;
|
|
62
|
-
printLogs('[MobileCameraService] Waiting for camera availability...', '');
|
|
63
|
-
yield BaseCameraService.waitForCameraRelease(useDeviceId, this.faceMode);
|
|
64
|
-
printLogs(`[MobileCameraService] Using deviceId: `, useDeviceId || 'auto (facingMode)');
|
|
65
|
-
printLogs(`[MobileCameraService] Props deviceId: `, props.deviceId || 'none');
|
|
66
|
-
printLogs(`[MobileCameraService] Face mode: `, this.faceMode);
|
|
67
|
-
printLogs(`[MobileCameraService] Is first permission request: `, isFirstPermissionRequest);
|
|
68
|
-
printLogs('[MobileCameraService] Requesting media stream...', '');
|
|
69
|
-
const stream = yield getDeviceMediaStream(useDeviceId, 'mobile', {
|
|
70
|
-
isDocumentScan: props.isDocumentScan,
|
|
71
|
-
canvasResolution: props.canvasResolution,
|
|
72
|
-
faceMode: this.faceMode,
|
|
73
|
-
enabledDevices: devices,
|
|
74
|
-
isFirstPermissionRequest,
|
|
75
|
-
});
|
|
76
|
-
printLogs('[MobileCameraService] Media stream obtained successfully', '');
|
|
77
|
-
printLogs(`[MobileCameraService] Stream has ${stream.getVideoTracks().length} video tracks`, '');
|
|
78
|
-
// After stream is opened, get the actual deviceId that was selected
|
|
79
|
-
const actualDeviceId = (_b = (_a = stream.getVideoTracks()[0]) === null || _a === void 0 ? void 0 : _a.getSettings()) === null || _b === void 0 ? void 0 : _b.deviceId;
|
|
80
|
-
if (actualDeviceId) {
|
|
81
|
-
this.setCurrentDeviceId(actualDeviceId);
|
|
82
|
-
printLogs(`[MobileCameraService] Selected deviceId: `, actualDeviceId);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
printLogs('[MobileCameraService] Could not get actual deviceId from stream', '', 'WARN');
|
|
86
|
-
}
|
|
87
|
-
printLogs('[MobileCameraService] Preparing camera result...', '');
|
|
88
|
-
const result = yield this.prepareCameraResult(stream, devices, this.faceMode, props.videoElementId);
|
|
89
|
-
printLogs('[MobileCameraService] Camera opened successfully', '');
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
catch (e) {
|
|
93
|
-
lastError = e;
|
|
94
|
-
printLogs(`[MobileCameraService] Attempt ${attempt}/${maxAttempts} failed`, '', 'ERROR');
|
|
95
|
-
printLogs(`[MobileCameraService] Error name: `, (e === null || e === void 0 ? void 0 : e.name) || 'unknown');
|
|
96
|
-
printLogs(`[MobileCameraService] Error message: `, (e === null || e === void 0 ? void 0 : e.message) || 'unknown');
|
|
97
|
-
const permissionState = yield this.permissionsService.checkCameraPermissions();
|
|
98
|
-
printLogs(`[MobileCameraService] Camera permission state`, permissionState, 'ERROR');
|
|
99
|
-
// Enhanced error reporting for common issues
|
|
100
|
-
if ((e === null || e === void 0 ? void 0 : e.name) === 'NotAllowedError') {
|
|
101
|
-
printLogs(`[MobileCameraService] Camera permission denied by user`, '', 'ERROR');
|
|
102
|
-
}
|
|
103
|
-
else if ((e === null || e === void 0 ? void 0 : e.name) === 'NotFoundError') {
|
|
104
|
-
printLogs(`[MobileCameraService] No camera device found`, '', 'ERROR');
|
|
105
|
-
}
|
|
106
|
-
else if ((e === null || e === void 0 ? void 0 : e.name) === 'NotReadableError') {
|
|
107
|
-
printLogs(`[MobileCameraService] Camera is already in use by another app/tab`, '', 'ERROR');
|
|
108
|
-
}
|
|
109
|
-
else if ((e === null || e === void 0 ? void 0 : e.name) === 'OverconstrainedError') {
|
|
110
|
-
printLogs(`[MobileCameraService] Camera constraints cannot be satisfied`, '', 'ERROR');
|
|
111
|
-
}
|
|
112
|
-
else if ((e === null || e === void 0 ? void 0 : e.message) === 'NO_TRACK_SETTINGS') {
|
|
113
|
-
printLogs(`[MobileCameraService] Failed to get track settings from camera`, '', 'ERROR');
|
|
114
|
-
}
|
|
115
|
-
else if ((e === null || e === void 0 ? void 0 : e.message) === 'NO_VIDEO_TRACKS') {
|
|
116
|
-
printLogs(`[MobileCameraService] Stream has no video tracks`, '', 'ERROR');
|
|
117
|
-
}
|
|
118
|
-
printLogs(`[MobileCameraService] Error stack: `, (e === null || e === void 0 ? void 0 : e.stack) || 'no stack trace');
|
|
119
|
-
// If this is not the last attempt, wait before retrying
|
|
120
|
-
if (attempt < maxAttempts) {
|
|
121
|
-
const retryDelay = attempt * 500; // Progressive delay: 500ms, 1000ms
|
|
122
|
-
printLogs(`[MobileCameraService] Retrying in ${retryDelay}ms...`, '');
|
|
123
|
-
yield new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
// All attempts failed
|
|
128
|
-
printLogs(`[MobileCameraService] All ${maxAttempts} attempts failed`, '', 'ERROR');
|
|
129
|
-
printLogs(`[MobileCameraService] Final error: `, lastError, 'ERROR');
|
|
130
|
-
return null;
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
/* eslint-disable import/prefer-default-export */
|
|
11
|
+
import { BaseCameraService } from './BaseCameraService';
|
|
12
|
+
import { CameraFaceMode } from '../camera.types';
|
|
13
|
+
import { printLogs } from '../../../global/shared.utils';
|
|
14
|
+
import { getDeviceMediaStream, getFilteredVideoDevices } from '../camera.utils';
|
|
15
|
+
import { isBackCameraLabel } from '../../../../../cameraUtils';
|
|
16
|
+
export class MobileCameraService extends BaseCameraService {
|
|
17
|
+
openCamera(props) {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const maxAttempts = 3;
|
|
21
|
+
let lastError = null;
|
|
22
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
23
|
+
try {
|
|
24
|
+
printLogs(`[MobileCameraService] openCamera attempt ${attempt}/${maxAttempts}`, '');
|
|
25
|
+
localStorage.removeItem('defaultDeviceId');
|
|
26
|
+
if (this.isActive()) {
|
|
27
|
+
printLogs('[MobileCameraService] Camera is active, closing before reopening', '');
|
|
28
|
+
yield this.closeCamera(props.videoElementId);
|
|
29
|
+
}
|
|
30
|
+
this.setVideoElementId(props.videoElementId);
|
|
31
|
+
this.setFaceMode(props.requestFaceMode || CameraFaceMode.front);
|
|
32
|
+
printLogs('[MobileCameraService] Requesting camera permission...', '');
|
|
33
|
+
const { isGranted } = yield this.permissionsService.requestCameraPermissions();
|
|
34
|
+
printLogs('[MobileCameraService] Getting filtered video devices...', '');
|
|
35
|
+
let devices = isGranted ? yield getFilteredVideoDevices() : [];
|
|
36
|
+
printLogs(`[MobileCameraService] Found ${devices.length} devices`, '');
|
|
37
|
+
// sorting the cameras to bring face cameras first when is face scan and back cameras first when is document scan
|
|
38
|
+
if (props.requestFaceMode === CameraFaceMode.back) {
|
|
39
|
+
devices = devices.sort((a, b) => {
|
|
40
|
+
const aIsBack = isBackCameraLabel(a.label) ? 0 : 1;
|
|
41
|
+
const bIsBack = isBackCameraLabel(b.label) ? 0 : 1;
|
|
42
|
+
return aIsBack - bIsBack;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else if (props.requestFaceMode === CameraFaceMode.front) {
|
|
46
|
+
devices = devices.sort((a, b) => {
|
|
47
|
+
const aIsFront = isBackCameraLabel(a.label) ? 1 : 0;
|
|
48
|
+
const bIsFront = isBackCameraLabel(b.label) ? 1 : 0;
|
|
49
|
+
return aIsFront - bIsFront;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
devices.forEach((device, index) => {
|
|
53
|
+
printLogs(`[MobileCameraService] Device ${index}: `, device);
|
|
54
|
+
});
|
|
55
|
+
if (devices.length === 0) {
|
|
56
|
+
throw new Error('NO_CAMERA');
|
|
57
|
+
}
|
|
58
|
+
const isFirstPermissionRequest = !props.deviceId && this.faceMode !== CameraFaceMode.back;
|
|
59
|
+
// If we don't have permission yet (first time), use only facingMode for more reliable camera selection
|
|
60
|
+
// If we already have permission, we can use deviceId for specific camera selection
|
|
61
|
+
const useDeviceId = isFirstPermissionRequest ? undefined : props.deviceId;
|
|
62
|
+
printLogs('[MobileCameraService] Waiting for camera availability...', '');
|
|
63
|
+
yield BaseCameraService.waitForCameraRelease(useDeviceId, this.faceMode);
|
|
64
|
+
printLogs(`[MobileCameraService] Using deviceId: `, useDeviceId || 'auto (facingMode)');
|
|
65
|
+
printLogs(`[MobileCameraService] Props deviceId: `, props.deviceId || 'none');
|
|
66
|
+
printLogs(`[MobileCameraService] Face mode: `, this.faceMode);
|
|
67
|
+
printLogs(`[MobileCameraService] Is first permission request: `, isFirstPermissionRequest);
|
|
68
|
+
printLogs('[MobileCameraService] Requesting media stream...', '');
|
|
69
|
+
const stream = yield getDeviceMediaStream(useDeviceId, 'mobile', {
|
|
70
|
+
isDocumentScan: props.isDocumentScan,
|
|
71
|
+
canvasResolution: props.canvasResolution,
|
|
72
|
+
faceMode: this.faceMode,
|
|
73
|
+
enabledDevices: devices,
|
|
74
|
+
isFirstPermissionRequest,
|
|
75
|
+
});
|
|
76
|
+
printLogs('[MobileCameraService] Media stream obtained successfully', '');
|
|
77
|
+
printLogs(`[MobileCameraService] Stream has ${stream.getVideoTracks().length} video tracks`, '');
|
|
78
|
+
// After stream is opened, get the actual deviceId that was selected
|
|
79
|
+
const actualDeviceId = (_b = (_a = stream.getVideoTracks()[0]) === null || _a === void 0 ? void 0 : _a.getSettings()) === null || _b === void 0 ? void 0 : _b.deviceId;
|
|
80
|
+
if (actualDeviceId) {
|
|
81
|
+
this.setCurrentDeviceId(actualDeviceId);
|
|
82
|
+
printLogs(`[MobileCameraService] Selected deviceId: `, actualDeviceId);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
printLogs('[MobileCameraService] Could not get actual deviceId from stream', '', 'WARN');
|
|
86
|
+
}
|
|
87
|
+
printLogs('[MobileCameraService] Preparing camera result...', '');
|
|
88
|
+
const result = yield this.prepareCameraResult(stream, devices, this.faceMode, props.videoElementId);
|
|
89
|
+
printLogs('[MobileCameraService] Camera opened successfully', '');
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
lastError = e;
|
|
94
|
+
printLogs(`[MobileCameraService] Attempt ${attempt}/${maxAttempts} failed`, '', 'ERROR');
|
|
95
|
+
printLogs(`[MobileCameraService] Error name: `, (e === null || e === void 0 ? void 0 : e.name) || 'unknown');
|
|
96
|
+
printLogs(`[MobileCameraService] Error message: `, (e === null || e === void 0 ? void 0 : e.message) || 'unknown');
|
|
97
|
+
const permissionState = yield this.permissionsService.checkCameraPermissions();
|
|
98
|
+
printLogs(`[MobileCameraService] Camera permission state`, permissionState, 'ERROR');
|
|
99
|
+
// Enhanced error reporting for common issues
|
|
100
|
+
if ((e === null || e === void 0 ? void 0 : e.name) === 'NotAllowedError') {
|
|
101
|
+
printLogs(`[MobileCameraService] Camera permission denied by user`, '', 'ERROR');
|
|
102
|
+
}
|
|
103
|
+
else if ((e === null || e === void 0 ? void 0 : e.name) === 'NotFoundError') {
|
|
104
|
+
printLogs(`[MobileCameraService] No camera device found`, '', 'ERROR');
|
|
105
|
+
}
|
|
106
|
+
else if ((e === null || e === void 0 ? void 0 : e.name) === 'NotReadableError') {
|
|
107
|
+
printLogs(`[MobileCameraService] Camera is already in use by another app/tab`, '', 'ERROR');
|
|
108
|
+
}
|
|
109
|
+
else if ((e === null || e === void 0 ? void 0 : e.name) === 'OverconstrainedError') {
|
|
110
|
+
printLogs(`[MobileCameraService] Camera constraints cannot be satisfied`, '', 'ERROR');
|
|
111
|
+
}
|
|
112
|
+
else if ((e === null || e === void 0 ? void 0 : e.message) === 'NO_TRACK_SETTINGS') {
|
|
113
|
+
printLogs(`[MobileCameraService] Failed to get track settings from camera`, '', 'ERROR');
|
|
114
|
+
}
|
|
115
|
+
else if ((e === null || e === void 0 ? void 0 : e.message) === 'NO_VIDEO_TRACKS') {
|
|
116
|
+
printLogs(`[MobileCameraService] Stream has no video tracks`, '', 'ERROR');
|
|
117
|
+
}
|
|
118
|
+
printLogs(`[MobileCameraService] Error stack: `, (e === null || e === void 0 ? void 0 : e.stack) || 'no stack trace');
|
|
119
|
+
// If this is not the last attempt, wait before retrying
|
|
120
|
+
if (attempt < maxAttempts) {
|
|
121
|
+
const retryDelay = attempt * 500; // Progressive delay: 500ms, 1000ms
|
|
122
|
+
printLogs(`[MobileCameraService] Retrying in ${retryDelay}ms...`, '');
|
|
123
|
+
yield new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// All attempts failed
|
|
128
|
+
printLogs(`[MobileCameraService] All ${maxAttempts} attempts failed`, '', 'ERROR');
|
|
129
|
+
printLogs(`[MobileCameraService] Final error: `, lastError, 'ERROR');
|
|
130
|
+
return null;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
134
|
//# sourceMappingURL=MobileCameraService.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { WasmOrchestrator } from '../../internal/wasm-orchestrator';
|
|
2
|
+
import { Engine } from './engine.domain';
|
|
3
|
+
import { LoadModuleParams, LoadModuleResult, PackageSupportResult } from './engine.types';
|
|
4
|
+
export declare class EngineService implements Engine {
|
|
5
|
+
private wasmOrchestratorService;
|
|
6
|
+
private browserOS;
|
|
7
|
+
private browserName;
|
|
8
|
+
private browserVersion;
|
|
9
|
+
constructor(wasmOrchestratorService: WasmOrchestrator);
|
|
10
|
+
loadModule(params: LoadModuleParams): Promise<LoadModuleResult>;
|
|
11
|
+
checkModelsAreLoaded(): Promise<boolean>;
|
|
12
|
+
freeMemory(): Promise<boolean>;
|
|
13
|
+
encryptData(payload: unknown): Promise<(string | null)[]>;
|
|
14
|
+
checkPackageSupport(): PackageSupportResult;
|
|
15
|
+
}
|