@microblink/camera-manager 7.2.5 → 7.2.6
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 +92 -0
- package/dist/camera-manager.js +1201 -1125
- package/package.json +3 -3
- package/types/core/Camera.d.ts +117 -77
- package/types/core/Camera.d.ts.map +1 -1
- package/types/core/CameraManager.d.ts +72 -65
- package/types/core/CameraManager.d.ts.map +1 -1
- package/types/core/cameraError.d.ts +1 -1
- package/types/core/cameraError.d.ts.map +1 -1
- package/types/core/cameraManagerStore.d.ts +15 -1
- package/types/core/cameraManagerStore.d.ts.map +1 -1
- package/types/core/cameraUtils.d.ts.map +1 -1
- package/types/index.rollup.d.ts +84 -27
- package/types/ui/CameraErrorModal.d.ts.map +1 -1
- package/types/ui/CameraSelector.d.ts.map +1 -1
- package/types/ui/CaptureScreen.d.ts +0 -4
- package/types/ui/CaptureScreen.d.ts.map +1 -1
- package/types/ui/Header.d.ts.map +1 -1
- package/types/ui/debounce.d.ts +14 -0
- package/types/ui/debounce.d.ts.map +1 -0
- package/types/ui/determineFitMode.d.ts +4 -1
- package/types/ui/determineFitMode.d.ts.map +1 -1
- package/types/ui/locales/ak.d.ts +19 -0
- package/types/ui/locales/ak.d.ts.map +1 -0
- package/types/ui/locales/am.d.ts +19 -0
- package/types/ui/locales/am.d.ts.map +1 -0
- package/types/ui/locales/ar.d.ts +19 -0
- package/types/ui/locales/ar.d.ts.map +1 -0
- package/types/ui/locales/bn.d.ts +19 -0
- package/types/ui/locales/bn.d.ts.map +1 -0
- package/types/ui/locales/cs.d.ts +19 -0
- package/types/ui/locales/cs.d.ts.map +1 -0
- package/types/ui/locales/da.d.ts +19 -0
- package/types/ui/locales/da.d.ts.map +1 -0
- package/types/ui/locales/de.d.ts +19 -0
- package/types/ui/locales/de.d.ts.map +1 -0
- package/types/ui/locales/el.d.ts +19 -0
- package/types/ui/locales/el.d.ts.map +1 -0
- package/types/ui/locales/en.d.ts +8 -8
- package/types/ui/locales/en_GB.d.ts +19 -0
- package/types/ui/locales/en_GB.d.ts.map +1 -0
- package/types/ui/locales/es.d.ts +19 -0
- package/types/ui/locales/es.d.ts.map +1 -0
- package/types/ui/locales/es_MX.d.ts +19 -0
- package/types/ui/locales/es_MX.d.ts.map +1 -0
- package/types/ui/locales/fa-latn.d.ts +19 -0
- package/types/ui/locales/fa-latn.d.ts.map +1 -0
- package/types/ui/locales/fi.d.ts +19 -0
- package/types/ui/locales/fi.d.ts.map +1 -0
- package/types/ui/locales/fil.d.ts +19 -0
- package/types/ui/locales/fil.d.ts.map +1 -0
- package/types/ui/locales/fr.d.ts +19 -0
- package/types/ui/locales/fr.d.ts.map +1 -0
- package/types/ui/locales/fr_CA.d.ts +19 -0
- package/types/ui/locales/fr_CA.d.ts.map +1 -0
- package/types/ui/locales/ha.d.ts +19 -0
- package/types/ui/locales/ha.d.ts.map +1 -0
- package/types/ui/locales/he.d.ts +19 -0
- package/types/ui/locales/he.d.ts.map +1 -0
- package/types/ui/locales/hi.d.ts +19 -0
- package/types/ui/locales/hi.d.ts.map +1 -0
- package/types/ui/locales/hr.d.ts +19 -0
- package/types/ui/locales/hr.d.ts.map +1 -0
- package/types/ui/locales/hu.d.ts +19 -0
- package/types/ui/locales/hu.d.ts.map +1 -0
- package/types/ui/locales/id.d.ts +19 -0
- package/types/ui/locales/id.d.ts.map +1 -0
- package/types/ui/locales/index.d.ts +60 -0
- package/types/ui/locales/index.d.ts.map +1 -0
- package/types/ui/locales/is.d.ts +19 -0
- package/types/ui/locales/is.d.ts.map +1 -0
- package/types/ui/locales/it.d.ts +19 -0
- package/types/ui/locales/it.d.ts.map +1 -0
- package/types/ui/locales/ja.d.ts +19 -0
- package/types/ui/locales/ja.d.ts.map +1 -0
- package/types/ui/locales/ka_GE.d.ts +19 -0
- package/types/ui/locales/ka_GE.d.ts.map +1 -0
- package/types/ui/locales/kk.d.ts +19 -0
- package/types/ui/locales/kk.d.ts.map +1 -0
- package/types/ui/locales/km_KH.d.ts +19 -0
- package/types/ui/locales/km_KH.d.ts.map +1 -0
- package/types/ui/locales/ko.d.ts +19 -0
- package/types/ui/locales/ko.d.ts.map +1 -0
- package/types/ui/locales/lv.d.ts +19 -0
- package/types/ui/locales/lv.d.ts.map +1 -0
- package/types/ui/locales/ms.d.ts +19 -0
- package/types/ui/locales/ms.d.ts.map +1 -0
- package/types/ui/locales/ne.d.ts +19 -0
- package/types/ui/locales/ne.d.ts.map +1 -0
- package/types/ui/locales/nl.d.ts +19 -0
- package/types/ui/locales/nl.d.ts.map +1 -0
- package/types/ui/locales/no.d.ts +19 -0
- package/types/ui/locales/no.d.ts.map +1 -0
- package/types/ui/locales/pl.d.ts +19 -0
- package/types/ui/locales/pl.d.ts.map +1 -0
- package/types/ui/locales/ps_AF.d.ts +19 -0
- package/types/ui/locales/ps_AF.d.ts.map +1 -0
- package/types/ui/locales/pt.d.ts +19 -0
- package/types/ui/locales/pt.d.ts.map +1 -0
- package/types/ui/locales/pt_BR.d.ts +19 -0
- package/types/ui/locales/pt_BR.d.ts.map +1 -0
- package/types/ui/locales/ro.d.ts +19 -0
- package/types/ui/locales/ro.d.ts.map +1 -0
- package/types/ui/locales/ru.d.ts +19 -0
- package/types/ui/locales/ru.d.ts.map +1 -0
- package/types/ui/locales/si.d.ts +19 -0
- package/types/ui/locales/si.d.ts.map +1 -0
- package/types/ui/locales/sk.d.ts +19 -0
- package/types/ui/locales/sk.d.ts.map +1 -0
- package/types/ui/locales/sl.d.ts +19 -0
- package/types/ui/locales/sl.d.ts.map +1 -0
- package/types/ui/locales/sr.d.ts +19 -0
- package/types/ui/locales/sr.d.ts.map +1 -0
- package/types/ui/locales/sv.d.ts +19 -0
- package/types/ui/locales/sv.d.ts.map +1 -0
- package/types/ui/locales/sw.d.ts +19 -0
- package/types/ui/locales/sw.d.ts.map +1 -0
- package/types/ui/locales/th.d.ts +19 -0
- package/types/ui/locales/th.d.ts.map +1 -0
- package/types/ui/locales/tr.d.ts +19 -0
- package/types/ui/locales/tr.d.ts.map +1 -0
- package/types/ui/locales/uk.d.ts +19 -0
- package/types/ui/locales/uk.d.ts.map +1 -0
- package/types/ui/locales/ur.d.ts +19 -0
- package/types/ui/locales/ur.d.ts.map +1 -0
- package/types/ui/locales/uz.d.ts +19 -0
- package/types/ui/locales/uz.d.ts.map +1 -0
- package/types/ui/locales/vi.d.ts +19 -0
- package/types/ui/locales/vi.d.ts.map +1 -0
- package/types/ui/locales/yo.d.ts +19 -0
- package/types/ui/locales/yo.d.ts.map +1 -0
- package/types/ui/locales/zh_CN.d.ts +19 -0
- package/types/ui/locales/zh_CN.d.ts.map +1 -0
- package/types/ui/locales/zh_TW.d.ts +19 -0
- package/types/ui/locales/zh_TW.d.ts.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microblink/camera-manager",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.6",
|
|
4
4
|
"author": "Microblink",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/camera-manager.js",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"types"
|
|
12
12
|
],
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@ark-ui/solid": "^5.
|
|
15
|
-
"solid-js": "^1.9.
|
|
14
|
+
"@ark-ui/solid": "^5.26.2",
|
|
15
|
+
"solid-js": "^1.9.9",
|
|
16
16
|
"solid-zustand": "^1.8.1",
|
|
17
17
|
"zustand": "^4.5.5"
|
|
18
18
|
},
|
package/types/core/Camera.d.ts
CHANGED
|
@@ -1,6 +1,122 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2025 Microblink Ltd. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
+
import { CameraError } from "./cameraError";
|
|
5
|
+
interface CameraState {
|
|
6
|
+
deviceInfo: InputDeviceInfo;
|
|
7
|
+
activeStream: MediaStream | undefined;
|
|
8
|
+
name: string;
|
|
9
|
+
facingMode: FacingMode;
|
|
10
|
+
torchSupported: boolean;
|
|
11
|
+
torchEnabled: boolean;
|
|
12
|
+
singleShotSupported: boolean;
|
|
13
|
+
maxSupportedResolution?: VideoResolutionName;
|
|
14
|
+
streamCapabilities?: ReturnType<MediaStreamTrack["getCapabilities"]>;
|
|
15
|
+
error?: CameraError;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Represents a camera device and its active stream.
|
|
19
|
+
*
|
|
20
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getCapabilities for more details.
|
|
21
|
+
*/
|
|
22
|
+
export declare class Camera {
|
|
23
|
+
#private;
|
|
24
|
+
/**
|
|
25
|
+
* The internal state of the camera, implemented as a Zustand store.
|
|
26
|
+
*/
|
|
27
|
+
store: Omit<import("zustand/vanilla").StoreApi<CameraState>, "subscribe"> & {
|
|
28
|
+
subscribe: {
|
|
29
|
+
(listener: (selectedState: CameraState, previousSelectedState: CameraState) => void): () => void;
|
|
30
|
+
<U>(selector: (state: CameraState) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
31
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
32
|
+
fireImmediately?: boolean;
|
|
33
|
+
} | undefined): () => void;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The device info.
|
|
38
|
+
*/
|
|
39
|
+
get deviceInfo(): InputDeviceInfo;
|
|
40
|
+
/**
|
|
41
|
+
* Stream capabilities as reported by the stream.
|
|
42
|
+
*
|
|
43
|
+
* On iOS it's the same as `deviceCapabilities`. Firefox is only reporting
|
|
44
|
+
* rudimentary capabilities, so we can't rely on this for picking the right
|
|
45
|
+
* camera.
|
|
46
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getCapabilities
|
|
47
|
+
*/
|
|
48
|
+
get streamCapabilities(): MediaTrackCapabilities | undefined;
|
|
49
|
+
get activeStream(): MediaStream | undefined;
|
|
50
|
+
get name(): string;
|
|
51
|
+
get facingMode(): FacingMode;
|
|
52
|
+
get torchSupported(): boolean;
|
|
53
|
+
get torchEnabled(): boolean;
|
|
54
|
+
get singleShotSupported(): boolean;
|
|
55
|
+
get maxSupportedResolution(): VideoResolutionName | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new Camera instance.
|
|
58
|
+
*
|
|
59
|
+
* @param deviceInfo - The device info.
|
|
60
|
+
*/
|
|
61
|
+
constructor(deviceInfo: InputDeviceInfo);
|
|
62
|
+
/**
|
|
63
|
+
* Subscribe to camera state changes.
|
|
64
|
+
*
|
|
65
|
+
* @param listener - Listener function that gets called when state changes
|
|
66
|
+
* @returns Unsubscribe function
|
|
67
|
+
*/
|
|
68
|
+
subscribe(listener: (selectedState: CameraState, previousSelectedState: CameraState) => void): () => void;
|
|
69
|
+
/**
|
|
70
|
+
* Subscribe to camera state changes with selector.
|
|
71
|
+
*
|
|
72
|
+
* @param selector - Function to select specific state slice
|
|
73
|
+
* @param listener - Listener function that gets called when selected state changes
|
|
74
|
+
* @param options - Optional subscription options
|
|
75
|
+
* @returns Unsubscribe function
|
|
76
|
+
*/
|
|
77
|
+
subscribe<U>(selector: (state: CameraState) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
78
|
+
equalityFn?: (a: U, b: U) => boolean;
|
|
79
|
+
fireImmediately?: boolean;
|
|
80
|
+
}): () => void;
|
|
81
|
+
unsubscribeAll(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Starts a stream with the specified resolution.
|
|
84
|
+
*
|
|
85
|
+
* @param resolution - The resolution to start the stream with.
|
|
86
|
+
* @returns The stream.
|
|
87
|
+
*/
|
|
88
|
+
startStream(resolution: VideoResolutionName): Promise<MediaStream>;
|
|
89
|
+
/**
|
|
90
|
+
* Acquires a camera stream with the specified resolution.
|
|
91
|
+
* If acquisition fails, it tries a lower resolution as fallback.
|
|
92
|
+
*
|
|
93
|
+
* @param resolution - The resolution to acquire the stream with.
|
|
94
|
+
* @returns The stream.
|
|
95
|
+
*/
|
|
96
|
+
private acquireStreamWithFallback;
|
|
97
|
+
/**
|
|
98
|
+
* Populates the camera instance with capabilities from the stream.
|
|
99
|
+
*
|
|
100
|
+
* @param stream - The stream to populate the capabilities from.
|
|
101
|
+
*/
|
|
102
|
+
private populateCapabilities;
|
|
103
|
+
/**
|
|
104
|
+
* Toggles the torch on the camera.
|
|
105
|
+
*
|
|
106
|
+
* @returns The torch status.
|
|
107
|
+
*/
|
|
108
|
+
toggleTorch(): Promise<boolean>;
|
|
109
|
+
/**
|
|
110
|
+
* Stops the stream on the camera.
|
|
111
|
+
*/
|
|
112
|
+
stopStream(): void;
|
|
113
|
+
/**
|
|
114
|
+
* Gets the video track on the camera.
|
|
115
|
+
*
|
|
116
|
+
* @returns The video track.
|
|
117
|
+
*/
|
|
118
|
+
getVideoTrack(): MediaStreamTrack | undefined;
|
|
119
|
+
}
|
|
4
120
|
export type FacingMode = "front" | "back" | undefined;
|
|
5
121
|
/**
|
|
6
122
|
* Available video resolutions for the camera stream.
|
|
@@ -67,81 +183,5 @@ export declare function matchClosestResolution(resolution: Resolution): VideoRes
|
|
|
67
183
|
* @returns The closest resolution key.
|
|
68
184
|
*/
|
|
69
185
|
export declare function findResolutionKey(videoTrackResolution: Resolution): VideoResolutionName;
|
|
70
|
-
|
|
71
|
-
* Represents a camera device and its active stream.
|
|
72
|
-
*
|
|
73
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getCapabilities for more details.
|
|
74
|
-
*/
|
|
75
|
-
export declare class Camera {
|
|
76
|
-
#private;
|
|
77
|
-
/**
|
|
78
|
-
* The device info.
|
|
79
|
-
*/
|
|
80
|
-
deviceInfo: InputDeviceInfo;
|
|
81
|
-
/**
|
|
82
|
-
* Stream capabilities as reported by the stream.
|
|
83
|
-
*
|
|
84
|
-
* On iOS it's the same as `deviceCapabilities`. Firefox is only reporting
|
|
85
|
-
* rudimentary capabilities, so we can't rely on this for picking the right
|
|
86
|
-
* camera.
|
|
87
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getCapabilities
|
|
88
|
-
*/
|
|
89
|
-
streamCapabilities?: ReturnType<MediaStreamTrack["getCapabilities"]>;
|
|
90
|
-
activeStream: MediaStream | undefined;
|
|
91
|
-
name: string;
|
|
92
|
-
facingMode: FacingMode;
|
|
93
|
-
torchSupported: boolean;
|
|
94
|
-
torchEnabled: boolean;
|
|
95
|
-
singleShotSupported: boolean;
|
|
96
|
-
maxSupportedResolution?: VideoResolutionName;
|
|
97
|
-
/**
|
|
98
|
-
* Reference to the original instance before it was proxied.
|
|
99
|
-
*/
|
|
100
|
-
original: this;
|
|
101
|
-
notify: (reason?: unknown) => void;
|
|
102
|
-
notifyStateChange?: (camera: Camera, reason?: unknown) => void;
|
|
103
|
-
/**
|
|
104
|
-
* Creates a new Camera instance.
|
|
105
|
-
*
|
|
106
|
-
* @param deviceInfo - The device info.
|
|
107
|
-
*/
|
|
108
|
-
constructor(deviceInfo: InputDeviceInfo);
|
|
109
|
-
/**
|
|
110
|
-
* Starts a stream with the specified resolution.
|
|
111
|
-
*
|
|
112
|
-
* @param resolution - The resolution to start the stream with.
|
|
113
|
-
* @returns The stream.
|
|
114
|
-
*/
|
|
115
|
-
startStream(resolution: VideoResolutionName): Promise<MediaStream>;
|
|
116
|
-
/**
|
|
117
|
-
* Acquires a camera stream with the specified resolution.
|
|
118
|
-
* If acquisition fails, it tries a lower resolution as fallback.
|
|
119
|
-
*
|
|
120
|
-
* @param resolution - The resolution to acquire the stream with.
|
|
121
|
-
* @returns The stream.
|
|
122
|
-
*/
|
|
123
|
-
private acquireStreamWithFallback;
|
|
124
|
-
/**
|
|
125
|
-
* Populates the camera instance with capabilities from the stream.
|
|
126
|
-
*
|
|
127
|
-
* @param stream - The stream to populate the capabilities from.
|
|
128
|
-
*/
|
|
129
|
-
private populateCapabilities;
|
|
130
|
-
/**
|
|
131
|
-
* Toggles the torch on the camera.
|
|
132
|
-
*
|
|
133
|
-
* @returns The torch status.
|
|
134
|
-
*/
|
|
135
|
-
toggleTorch(): Promise<boolean>;
|
|
136
|
-
/**
|
|
137
|
-
* Stops the stream on the camera.
|
|
138
|
-
*/
|
|
139
|
-
stopStream(): void;
|
|
140
|
-
/**
|
|
141
|
-
* Gets the video track on the camera.
|
|
142
|
-
*
|
|
143
|
-
* @returns The video track.
|
|
144
|
-
*/
|
|
145
|
-
getVideoTrack(): MediaStreamTrack | undefined;
|
|
146
|
-
}
|
|
186
|
+
export {};
|
|
147
187
|
//# sourceMappingURL=Camera.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Camera.d.ts","sourceRoot":"","sources":["../../src/core/Camera.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"Camera.d.ts","sourceRoot":"","sources":["../../src/core/Camera.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C,UAAU,WAAW;IACnB,UAAU,EAAE,eAAe,CAAC;IAC5B,YAAY,EAAE,WAAW,GAAG,SAAS,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,OAAO,CAAC;IACtB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,sBAAsB,CAAC,EAAE,mBAAmB,CAAC;IAC7C,kBAAkB,CAAC,EAAE,UAAU,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACrE,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAsBD;;;;GAIG;AACH,qBAAa,MAAM;;IACjB;;OAEG;IACH,KAAK;;;;;;;;MAEH;IAIF;;OAEG;IACH,IAAI,UAAU,IAAI,eAAe,CAEhC;IAED;;;;;;;OAOG;IACH,IAAI,kBAAkB,uCAErB;IAED,IAAI,YAAY,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AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,gBAAgB,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAE/D;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAiB1E;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,UAAU,GACrB,mBAAmB,CASrB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,oBAAoB,EAAE,UAAU,GAC/B,mBAAmB,CA0BrB"}
|
|
@@ -5,71 +5,6 @@ import { Camera, FacingMode, VideoResolutionName } from "./Camera";
|
|
|
5
5
|
import { cameraManagerStore as store } from "./cameraManagerStore";
|
|
6
6
|
import { Promisable } from "type-fest";
|
|
7
7
|
import { ExtractionArea, VideoFrameProcessorInitOptions } from "./VideoFrameProcessor";
|
|
8
|
-
/**
|
|
9
|
-
* A callback that will be triggered on each frame when the playback state is
|
|
10
|
-
* "capturing".
|
|
11
|
-
*
|
|
12
|
-
* @param frame - The frame to capture.
|
|
13
|
-
* @returns The frame.
|
|
14
|
-
*/
|
|
15
|
-
export type FrameCaptureCallback = (frame: ImageData) => Promisable<ArrayBufferLike | void>;
|
|
16
|
-
/**
|
|
17
|
-
* A camera getter.
|
|
18
|
-
*
|
|
19
|
-
* @param cameras - The cameras to get.
|
|
20
|
-
* @returns The camera.
|
|
21
|
-
*/
|
|
22
|
-
type CameraGetter = (cameras: Camera[]) => Camera | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* A camera preference.
|
|
25
|
-
*
|
|
26
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/facingMode for facing mode details.
|
|
27
|
-
*/
|
|
28
|
-
export type CameraPreference = {
|
|
29
|
-
preferredCamera: Camera | undefined;
|
|
30
|
-
preferredFacing?: undefined;
|
|
31
|
-
} | {
|
|
32
|
-
preferredCamera: CameraGetter | undefined;
|
|
33
|
-
preferredFacing?: undefined;
|
|
34
|
-
} | {
|
|
35
|
-
preferredFacing: FacingMode;
|
|
36
|
-
preferredCamera?: undefined;
|
|
37
|
-
} | {
|
|
38
|
-
preferredCamera?: undefined;
|
|
39
|
-
preferredFacing?: undefined;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Options for starting a camera stream.
|
|
43
|
-
*
|
|
44
|
-
* @param autoplay - If true, the camera stream will be started automatically.
|
|
45
|
-
* @param preferredCamera - The camera to start the stream with.
|
|
46
|
-
* @param preferredFacing - The facing mode to start the stream with.
|
|
47
|
-
*/
|
|
48
|
-
export type StartCameraStreamOptions = {
|
|
49
|
-
autoplay?: boolean;
|
|
50
|
-
} & CameraPreference;
|
|
51
|
-
/**
|
|
52
|
-
* Options for the CameraManager.
|
|
53
|
-
*
|
|
54
|
-
* @param mirrorFrontCameras - If true, front-facing cameras will be mirrored horizontally when started.
|
|
55
|
-
* @param preferredResolution - The desired video resolution for camera streams. This is used as the ideal resolution when starting camera streams. If a camera doesn't support the specified resolution, the camera will automatically fall back to the next lower supported resolution in this order: 4k → 1080p → 720p.
|
|
56
|
-
*/
|
|
57
|
-
export type CameraManagerOptions = {
|
|
58
|
-
/** If true, the camera stream will be mirrored horizontally when started. */
|
|
59
|
-
mirrorFrontCameras: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* The desired video resolution for camera streams. This is used as the ideal resolution
|
|
62
|
-
* when starting camera streams. If a camera doesn't support the specified resolution,
|
|
63
|
-
* the camera will automatically fall back to the next lower supported resolution in this order:
|
|
64
|
-
* 4k → 1080p → 720p. The actual resolution used may differ from this setting based on
|
|
65
|
-
* camera capabilities and system constraints.
|
|
66
|
-
*/
|
|
67
|
-
preferredResolution: VideoResolutionName;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Default options for the CameraManager.
|
|
71
|
-
*/
|
|
72
|
-
export declare const defaultCameraManagerOptions: CameraManagerOptions;
|
|
73
8
|
/**
|
|
74
9
|
* The CameraManager class.
|
|
75
10
|
*
|
|
@@ -89,6 +24,12 @@ export declare class CameraManager {
|
|
|
89
24
|
* @param extractionArea The area of the video frame that will be extracted.
|
|
90
25
|
*/
|
|
91
26
|
setExtractionArea(extractionArea: ExtractionArea): void;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the area of the video frame that will be extracted.
|
|
29
|
+
*
|
|
30
|
+
* @returns The area of the video frame that will be extracted.
|
|
31
|
+
*/
|
|
32
|
+
get extractionArea(): ExtractionArea | undefined;
|
|
92
33
|
/**
|
|
93
34
|
* Creates a new CameraManager instance.
|
|
94
35
|
*
|
|
@@ -132,6 +73,7 @@ export declare class CameraManager {
|
|
|
132
73
|
* @returns The cameras that are available to the user, filtered by the facing mode.
|
|
133
74
|
*/
|
|
134
75
|
getCameraDevices(): Promise<Camera[]>;
|
|
76
|
+
get selectedCamera(): Camera | undefined;
|
|
135
77
|
/**
|
|
136
78
|
* Initializes the CameraManager with a video element.
|
|
137
79
|
*
|
|
@@ -219,5 +161,70 @@ export declare class CameraManager {
|
|
|
219
161
|
*/
|
|
220
162
|
reset(): void;
|
|
221
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* A callback that will be triggered on each frame when the playback state is
|
|
166
|
+
* "capturing".
|
|
167
|
+
*
|
|
168
|
+
* @param frame - The frame to capture.
|
|
169
|
+
* @returns The frame.
|
|
170
|
+
*/
|
|
171
|
+
export type FrameCaptureCallback = (frame: ImageData) => Promisable<ArrayBufferLike | void>;
|
|
172
|
+
/**
|
|
173
|
+
* A camera getter.
|
|
174
|
+
*
|
|
175
|
+
* @param cameras - The cameras to get.
|
|
176
|
+
* @returns The camera.
|
|
177
|
+
*/
|
|
178
|
+
type CameraGetter = (cameras: Camera[]) => Camera | undefined;
|
|
179
|
+
/**
|
|
180
|
+
* A camera preference.
|
|
181
|
+
*
|
|
182
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/facingMode for facing mode details.
|
|
183
|
+
*/
|
|
184
|
+
export type CameraPreference = {
|
|
185
|
+
preferredCamera: Camera | undefined;
|
|
186
|
+
preferredFacing?: undefined;
|
|
187
|
+
} | {
|
|
188
|
+
preferredCamera: CameraGetter | undefined;
|
|
189
|
+
preferredFacing?: undefined;
|
|
190
|
+
} | {
|
|
191
|
+
preferredFacing: FacingMode;
|
|
192
|
+
preferredCamera?: undefined;
|
|
193
|
+
} | {
|
|
194
|
+
preferredCamera?: undefined;
|
|
195
|
+
preferredFacing?: undefined;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Options for starting a camera stream.
|
|
199
|
+
*
|
|
200
|
+
* @param autoplay - If true, the camera stream will be started automatically.
|
|
201
|
+
* @param preferredCamera - The camera to start the stream with.
|
|
202
|
+
* @param preferredFacing - The facing mode to start the stream with.
|
|
203
|
+
*/
|
|
204
|
+
export type StartCameraStreamOptions = {
|
|
205
|
+
autoplay?: boolean;
|
|
206
|
+
} & CameraPreference;
|
|
207
|
+
/**
|
|
208
|
+
* Options for the CameraManager.
|
|
209
|
+
*
|
|
210
|
+
* @param mirrorFrontCameras - If true, front-facing cameras will be mirrored horizontally when started.
|
|
211
|
+
* @param preferredResolution - The desired video resolution for camera streams. This is used as the ideal resolution when starting camera streams. If a camera doesn't support the specified resolution, the camera will automatically fall back to the next lower supported resolution in this order: 4k → 1080p → 720p.
|
|
212
|
+
*/
|
|
213
|
+
export type CameraManagerOptions = {
|
|
214
|
+
/** If true, the camera stream will be mirrored horizontally when started. */
|
|
215
|
+
mirrorFrontCameras: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* The desired video resolution for camera streams. This is used as the ideal resolution
|
|
218
|
+
* when starting camera streams. If a camera doesn't support the specified resolution,
|
|
219
|
+
* the camera will automatically fall back to the next lower supported resolution in this order:
|
|
220
|
+
* 4k → 1080p → 720p. The actual resolution used may differ from this setting based on
|
|
221
|
+
* camera capabilities and system constraints.
|
|
222
|
+
*/
|
|
223
|
+
preferredResolution: VideoResolutionName;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Default options for the CameraManager.
|
|
227
|
+
*/
|
|
228
|
+
export declare const defaultCameraManagerOptions: CameraManagerOptions;
|
|
222
229
|
export {};
|
|
223
230
|
//# sourceMappingURL=CameraManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CameraManager.d.ts","sourceRoot":"","sources":["../../src/core/CameraManager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"CameraManager.d.ts","sourceRoot":"","sources":["../../src/core/CameraManager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AASnE,OAAO,EAGL,kBAAkB,IAAI,KAAK,EAC5B,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EACL,cAAc,EAGd,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAE/B;;;;GAIG;AACH,qBAAa,aAAa;;IA0BxB;;;OAGG;IACH,IAAI,kBAAkB,IAIQ,OAAO,CAFpC;IAED,IAAI,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAEpC;IAED;;;;OAIG;IACH,iBAAiB,CAAC,cAAc,EAAE,cAAc;IAkBhD;;;;OAIG;IACH,IAAI,cAAc,+BAEjB;IAQD;;;;;OAKG;gBAED,OAAO,GAAE,OAAO,CAAC,oBAAoB,CAAM,EAC3C,0BAA0B,CAAC,EAAE,8BAA8B;IAc7D;;;;;;;OAOG;IACH,aAAa,GAAU,YAAY,mBAAmB,mBAUpD;IAEF;;;;;;OAMG;IACH,IAAI,UAAU,4BAEb;IAED;;;;OAIG;IACH,IAAI,QAAQ,YAGX;IAED;;;;OAIG;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;IAC5B,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B,GACD;IAEE,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B,CAAC;AAEN;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,gBAAgB,CAAC;AAErB;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,6EAA6E;IAC7E,kBAAkB,EAAE,OAAO,CAAC;IAC5B;;;;;;OAMG;IACH,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,oBAGhC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cameraError.d.ts","sourceRoot":"","sources":["../../src/core/cameraError.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;
|
|
1
|
+
{"version":3,"file":"cameraError.d.ts","sourceRoot":"","sources":["../../src/core/cameraError.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB,mBAAmB,GACnB,2BAA2B,GAE3B,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,IAAI,EAAE,eAAe,CAAC;IAEtB;;;;;;OAMG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,CAAC,EAAE,KAAK;CAKlE"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2025 Microblink Ltd. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import { Camera, FacingMode } from "./Camera";
|
|
4
|
+
import { Camera, FacingMode, Resolution } from "./Camera";
|
|
5
5
|
import { CameraError } from "./cameraError";
|
|
6
|
+
import { ExtractionArea } from "./VideoFrameProcessor";
|
|
6
7
|
/**
|
|
7
8
|
* The playback state of the camera manager.
|
|
8
9
|
*/
|
|
9
10
|
export type PlaybackState = "idle" | "playback" | "capturing";
|
|
11
|
+
export type CameraPermission = "prompt" | "granted" | "denied" | "blocked" | undefined;
|
|
10
12
|
/**
|
|
11
13
|
* The camera manager store.
|
|
12
14
|
*/
|
|
@@ -15,10 +17,22 @@ export type CameraManagerStore = {
|
|
|
15
17
|
* The video element that will display the camera stream.
|
|
16
18
|
*/
|
|
17
19
|
videoElement?: HTMLVideoElement;
|
|
20
|
+
/**
|
|
21
|
+
* The resolution of the video on the `videoElement`
|
|
22
|
+
*/
|
|
23
|
+
videoResolution?: Resolution;
|
|
24
|
+
/**
|
|
25
|
+
* Defines the area of the video which will be sent for processing.
|
|
26
|
+
*/
|
|
27
|
+
extractionArea?: ExtractionArea;
|
|
18
28
|
/**
|
|
19
29
|
* The list of cameras that are available to the user.
|
|
20
30
|
*/
|
|
21
31
|
cameras: Camera[];
|
|
32
|
+
/**
|
|
33
|
+
* Browser camera permission.
|
|
34
|
+
*/
|
|
35
|
+
cameraPermission: CameraPermission;
|
|
22
36
|
/**
|
|
23
37
|
* The facing mode filter that will be used to filter the available cameras.
|
|
24
38
|
* Can be a single facing mode or an array of facing modes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cameraManagerStore.d.ts","sourceRoot":"","sources":["../../src/core/cameraManagerStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"cameraManagerStore.d.ts","sourceRoot":"","sources":["../../src/core/cameraManagerStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,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version":3,"file":"cameraUtils.d.ts","sourceRoot":"","sources":["../../src/core/cameraUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EACL,MAAM,EACN,UAAU,EACV,mBAAmB,EAEpB,MAAM,UAAU,CAAC;AAMlB;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,qBAgBlC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,kCAkBnC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,WAAW,SAKpD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,YAAY,mBAAmB,EAC/B,SAAS,UAAU,EACnB,KAAK,MAAM,CAAC,YAAY,CAAC,CAAC,UAAU,CAAC,2BAuBtC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAK9D;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EAAE,EACjB,eAAe,EAAE,UAAU,GAC1B,MAAM,EAAE,CAQV;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,EAAE,EACjB,aAAY,mBAA0B,EACtC,kBAAiB,UAAmB,KACnC,OAAO,CAAC,MAAM,CAoGhB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,YAWvD"}
|