@microblink/camera-manager 7.2.1 → 7.2.3
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/camera-manager.js +182 -48
- package/dist/camera-manager.js.map +1 -1
- package/package.json +1 -1
- package/types/core/Camera.d.ts +73 -0
- package/types/core/Camera.d.ts.map +1 -1
- package/types/core/CameraManager.d.ts +87 -7
- package/types/core/CameraManager.d.ts.map +1 -1
- package/types/core/VideoFrameProcessor.d.ts +28 -6
- package/types/core/VideoFrameProcessor.d.ts.map +1 -1
- package/types/core/cameraError.d.ts +22 -0
- package/types/core/cameraError.d.ts.map +1 -0
- package/types/core/cameraManagerStore.d.ts +10 -3
- package/types/core/cameraManagerStore.d.ts.map +1 -1
- package/types/core/cameraNames.d.ts +21 -5
- package/types/core/cameraNames.d.ts.map +1 -1
- package/types/core/cameraUtils.d.ts +34 -13
- package/types/core/cameraUtils.d.ts.map +1 -1
- package/types/core/iosCameraNames.d.ts +3 -0
- package/types/core/iosCameraNames.d.ts.map +1 -1
- package/types/core/utils.d.ts +18 -0
- package/types/core/utils.d.ts.map +1 -1
- package/types/index.d.ts +11 -1
- package/types/index.d.ts.map +1 -1
- package/types/index.rollup.d.ts +264 -21
- package/types/media-mock/MediaMocker.d.ts +67 -0
- package/types/media-mock/MediaMocker.d.ts.map +1 -1
- package/types/media-mock/createInputDeviceInfo.d.ts +9 -0
- package/types/media-mock/createInputDeviceInfo.d.ts.map +1 -1
- package/types/media-mock/defineProperty.d.ts +6 -3
- package/types/media-mock/defineProperty.d.ts.map +1 -1
- package/types/media-mock/fake-devices.d.ts +6 -0
- package/types/media-mock/fake-devices.d.ts.map +1 -1
- package/types/ui/CameraErrorModal.d.ts +3 -0
- package/types/ui/CameraErrorModal.d.ts.map +1 -1
- package/types/ui/CameraSelector.d.ts +3 -0
- package/types/ui/CameraSelector.d.ts.map +1 -1
- package/types/ui/CameraUiStoreContext.d.ts +14 -0
- package/types/ui/CameraUiStoreContext.d.ts.map +1 -1
- package/types/ui/CaptureScreen.d.ts +12 -0
- package/types/ui/CaptureScreen.d.ts.map +1 -1
- package/types/ui/Header.d.ts +3 -0
- package/types/ui/Header.d.ts.map +1 -1
- package/types/ui/LocalizationContext.d.ts +12 -0
- package/types/ui/LocalizationContext.d.ts.map +1 -1
- package/types/ui/RootComponent.d.ts +3 -0
- package/types/ui/RootComponent.d.ts.map +1 -1
- package/types/ui/SolidShadowRoot.d.ts +16 -3
- package/types/ui/SolidShadowRoot.d.ts.map +1 -1
- package/types/ui/createCameraManagerUi.d.ts +33 -3
- package/types/ui/createCameraManagerUi.d.ts.map +1 -1
- package/types/ui/determineFitMode.d.ts +7 -6
- package/types/ui/determineFitMode.d.ts.map +1 -1
- package/types/ui/getVisibleVideoArea.d.ts +7 -1
- package/types/ui/getVisibleVideoArea.d.ts.map +1 -1
- package/types/ui/locales/en.d.ts +3 -0
- package/types/ui/locales/en.d.ts.map +1 -1
- package/types/ui/zustandRefStore.d.ts +12 -0
- package/types/ui/zustandRefStore.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iosCameraNames.d.ts","sourceRoot":"","sources":["../../src/core/iosCameraNames.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,+BAA+B,UAsC3C,CAAC"}
|
|
1
|
+
{"version":3,"file":"iosCameraNames.d.ts","sourceRoot":"","sources":["../../src/core/iosCameraNames.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,+BAA+B,UAsC3C,CAAC"}
|
package/types/core/utils.d.ts
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2025 Microblink Ltd. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* Gets the average of an array of numbers.
|
|
6
|
+
*
|
|
7
|
+
* @param arr - The array of numbers to get the average of.
|
|
8
|
+
* @returns The average of the array.
|
|
9
|
+
*/
|
|
4
10
|
export declare function getAverage(arr: number[]): number;
|
|
11
|
+
/**
|
|
12
|
+
* Converts an unknown value to an error.
|
|
13
|
+
*
|
|
14
|
+
* @param thrown - The value to convert to an error.
|
|
15
|
+
* @returns The error.
|
|
16
|
+
*/
|
|
5
17
|
export declare const asError: (thrown: unknown) => Error;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the key with the highest value in a map.
|
|
20
|
+
*
|
|
21
|
+
* @param map - The map to get the key with the highest value from.
|
|
22
|
+
* @returns The key with the highest value.
|
|
23
|
+
*/
|
|
6
24
|
export declare function getKeyWithHighestValue(map: Map<string, number>): null;
|
|
7
25
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/core/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,UAEvC;AAED,eAAO,MAAM,OAAO,GAAI,QAAQ,OAAO,KAAG,KASzC,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,QAY9D"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/core/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,UAEvC;AAED;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,QAAQ,OAAO,KAAG,KASzC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,QAY9D"}
|
package/types/index.d.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2025 Microblink Ltd. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
* Camera management utilities for web applications - provides camera access, selection, and video stream handling.
|
|
7
|
+
* This package includes both core camera management functionality and UI components for camera selection
|
|
8
|
+
* and feedback, with support for multiple camera devices and orientations.
|
|
9
|
+
*/
|
|
4
10
|
import "rvfc-polyfill";
|
|
5
|
-
export * from "./core/cameraManagerStore";
|
|
6
11
|
export * from "./core/Camera";
|
|
12
|
+
export * from "./core/cameraError";
|
|
13
|
+
export * from "./core/cameraManagerStore";
|
|
7
14
|
export * from "./core/CameraManager";
|
|
8
15
|
export * from "./core/VideoFrameProcessor";
|
|
9
16
|
export * from "./ui/createCameraManagerUi";
|
|
@@ -11,6 +18,9 @@ export { cameraUiRefStore } from "./ui/zustandRefStore";
|
|
|
11
18
|
export type { CameraUiRefs } from "./ui/zustandRefStore";
|
|
12
19
|
export type { CameraUiLocalizationStrings, CameraUiLocaleRecord, } from "./ui/LocalizationContext";
|
|
13
20
|
declare const testSymbol: unique symbol;
|
|
21
|
+
/**
|
|
22
|
+
* The global interface.
|
|
23
|
+
*/
|
|
14
24
|
declare global {
|
|
15
25
|
var __CAMERA_MANAGER__: typeof testSymbol;
|
|
16
26
|
}
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,eAAe,CAAC;AAEvB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AAEH,OAAO,eAAe,CAAC;AAEvB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAE3C,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EACV,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAGlC,QAAA,MAAM,UAAU,eAAW,CAAC;AAE5B;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,kBAAkB,EAAE,OAAO,UAAU,CAAC;CAC3C"}
|
package/types/index.rollup.d.ts
CHANGED
|
@@ -5,9 +5,14 @@ import { StoreApi } from 'zustand/vanilla';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Represents a camera device and its active stream.
|
|
8
|
+
*
|
|
9
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getCapabilities for more details.
|
|
8
10
|
*/
|
|
9
11
|
export declare class Camera {
|
|
10
12
|
#private;
|
|
13
|
+
/**
|
|
14
|
+
* The device info.
|
|
15
|
+
*/
|
|
11
16
|
deviceInfo: InputDeviceInfo;
|
|
12
17
|
/**
|
|
13
18
|
* Stream capabilities as reported by the stream.
|
|
@@ -31,78 +36,165 @@ export declare class Camera {
|
|
|
31
36
|
original: this;
|
|
32
37
|
notify: (reason?: unknown) => void;
|
|
33
38
|
notifyStateChange?: (camera: Camera, reason?: unknown) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a new Camera instance.
|
|
41
|
+
*
|
|
42
|
+
* @param deviceInfo - The device info.
|
|
43
|
+
*/
|
|
34
44
|
constructor(deviceInfo: InputDeviceInfo);
|
|
45
|
+
/**
|
|
46
|
+
* Starts a stream with the specified resolution.
|
|
47
|
+
*
|
|
48
|
+
* @param resolution - The resolution to start the stream with.
|
|
49
|
+
* @returns The stream.
|
|
50
|
+
*/
|
|
35
51
|
startStream(resolution: VideoResolutionName): Promise<MediaStream>;
|
|
36
52
|
/**
|
|
37
53
|
* Acquires a camera stream with the specified resolution.
|
|
38
54
|
* If acquisition fails, it tries a lower resolution as fallback.
|
|
55
|
+
*
|
|
56
|
+
* @param resolution - The resolution to acquire the stream with.
|
|
57
|
+
* @returns The stream.
|
|
39
58
|
*/
|
|
40
59
|
private acquireStreamWithFallback;
|
|
41
60
|
/**
|
|
42
61
|
* Populates the camera instance with capabilities from the stream.
|
|
62
|
+
*
|
|
63
|
+
* @param stream - The stream to populate the capabilities from.
|
|
43
64
|
*/
|
|
44
65
|
private populateCapabilities;
|
|
66
|
+
/**
|
|
67
|
+
* Toggles the torch on the camera.
|
|
68
|
+
*
|
|
69
|
+
* @returns The torch status.
|
|
70
|
+
*/
|
|
45
71
|
toggleTorch(): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Stops the stream on the camera.
|
|
74
|
+
*/
|
|
46
75
|
stopStream(): void;
|
|
76
|
+
/**
|
|
77
|
+
* Gets the video track on the camera.
|
|
78
|
+
*
|
|
79
|
+
* @returns The video track.
|
|
80
|
+
*/
|
|
47
81
|
getVideoTrack(): MediaStreamTrack | undefined;
|
|
48
82
|
}
|
|
49
83
|
|
|
50
|
-
|
|
84
|
+
/**
|
|
85
|
+
* A camera error.
|
|
86
|
+
*/
|
|
87
|
+
export declare class CameraError extends Error {
|
|
51
88
|
code: CameraErrorCode;
|
|
89
|
+
/**
|
|
90
|
+
* Creates a new camera error.
|
|
91
|
+
*
|
|
92
|
+
* @param message - The error message.
|
|
93
|
+
* @param code - The error code.
|
|
94
|
+
* @param cause - The cause of the error.
|
|
95
|
+
*/
|
|
52
96
|
constructor(message: string, code: CameraErrorCode, cause?: Error);
|
|
53
97
|
}
|
|
54
98
|
|
|
55
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Copyright (c) 2025 Microblink Ltd. All rights reserved.
|
|
101
|
+
*/
|
|
102
|
+
/**
|
|
103
|
+
* A camera error code.
|
|
104
|
+
*/
|
|
105
|
+
export declare type CameraErrorCode = "PERMISSION_DENIED" | (string & {});
|
|
56
106
|
|
|
107
|
+
/**
|
|
108
|
+
* A camera getter.
|
|
109
|
+
*
|
|
110
|
+
* @param cameras - The cameras to get.
|
|
111
|
+
* @returns The camera.
|
|
112
|
+
*/
|
|
57
113
|
declare type CameraGetter = (cameras: Camera[]) => Camera | undefined;
|
|
58
114
|
|
|
115
|
+
/**
|
|
116
|
+
* The CameraManager class.
|
|
117
|
+
*
|
|
118
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getCapabilities for more details.
|
|
119
|
+
*/
|
|
59
120
|
export declare class CameraManager {
|
|
60
121
|
#private;
|
|
122
|
+
/**
|
|
123
|
+
* If true, the user has initiated an abort. This will prevent the
|
|
124
|
+
* CameraManager from throwing errors when the user interrupts the process.
|
|
125
|
+
*/
|
|
61
126
|
get userInitiatedAbort(): boolean;
|
|
62
127
|
set userInitiatedAbort(value: boolean);
|
|
63
128
|
/**
|
|
64
129
|
* Sets the area of the video frame that will be extracted.
|
|
130
|
+
*
|
|
65
131
|
* @param extractionArea The area of the video frame that will be extracted.
|
|
66
132
|
*/
|
|
67
133
|
setExtractionArea(extractionArea: ExtractionArea): void;
|
|
134
|
+
/**
|
|
135
|
+
* Creates a new CameraManager instance.
|
|
136
|
+
*
|
|
137
|
+
* @param options - The options for the CameraManager.
|
|
138
|
+
* @param videoFrameProcessorOptions - The options for the VideoFrameProcessor.
|
|
139
|
+
*/
|
|
68
140
|
constructor(options?: Partial<CameraManagerOptions>, videoFrameProcessorOptions?: VideoFrameProcessorInitOptions);
|
|
69
141
|
/**
|
|
70
|
-
* Sets the resolution of the camera stream
|
|
142
|
+
* Sets the resolution of the camera stream.
|
|
143
|
+
*
|
|
144
|
+
* @param resolution - The resolution to set.
|
|
71
145
|
*/
|
|
72
146
|
setResolution: (resolution: VideoResolutionName) => Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* The resolution of the camera stream.
|
|
149
|
+
*/
|
|
73
150
|
get resolution(): "720p" | "1080p" | "4k";
|
|
74
151
|
/**
|
|
75
152
|
* True if there is a video playing or capturing
|
|
76
|
-
*
|
|
153
|
+
*
|
|
154
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/playbackState for more details.
|
|
77
155
|
*/
|
|
78
156
|
get isActive(): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Sets the facing filter.
|
|
159
|
+
*
|
|
160
|
+
* @param facingFilter - The facing filter.
|
|
161
|
+
*/
|
|
79
162
|
setFacingFilter(facingFilter: FacingMode[]): void;
|
|
80
163
|
/**
|
|
81
164
|
* Returns the cameras that are available to the user, filtered by the facing mode.
|
|
82
165
|
* If no facing mode is set, all cameras are returned.
|
|
166
|
+
*
|
|
167
|
+
* @returns The cameras that are available to the user, filtered by the facing mode.
|
|
83
168
|
*/
|
|
84
169
|
getCameraDevices(): Promise<Camera[]>;
|
|
85
170
|
/**
|
|
86
171
|
* Initializes the CameraManager with a video element.
|
|
172
|
+
*
|
|
173
|
+
* @param videoElement - The video element to initialize.
|
|
87
174
|
*/
|
|
88
175
|
initVideoElement(videoElement: HTMLVideoElement): void;
|
|
89
176
|
/**
|
|
90
177
|
* Adds a callback that will be triggered on each frame when the playback state
|
|
91
178
|
* is "capturing".
|
|
92
179
|
*
|
|
93
|
-
* @param frameCaptureCallback
|
|
180
|
+
* @param frameCaptureCallback - The callback to add.
|
|
94
181
|
* @returns a cleanup function to remove the callback
|
|
95
182
|
*/
|
|
96
183
|
addFrameCaptureCallback(frameCaptureCallback: FrameCaptureCallback): () => boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Cleans up the video element, and stops the stream.
|
|
186
|
+
*/
|
|
97
187
|
releaseVideoElement(): void;
|
|
98
188
|
/**
|
|
99
189
|
* Select a camera device from available ones.
|
|
100
190
|
*
|
|
101
|
-
*
|
|
191
|
+
* @param camera - The camera to select.
|
|
102
192
|
*/
|
|
103
193
|
selectCamera(camera: Camera): Promise<void>;
|
|
104
194
|
/**
|
|
105
195
|
* Refreshes available devices on the system and updates the state.
|
|
196
|
+
*
|
|
197
|
+
* @returns resolves when the camera devices are refreshed
|
|
106
198
|
*/
|
|
107
199
|
refreshCameraDevices(): Promise<void>;
|
|
108
200
|
/**
|
|
@@ -113,15 +205,20 @@ export declare class CameraManager {
|
|
|
113
205
|
startPlayback(): Promise<void>;
|
|
114
206
|
/**
|
|
115
207
|
* Starts capturing frames from the video element.
|
|
208
|
+
*
|
|
209
|
+
* @returns resolves when frame capture starts
|
|
116
210
|
*/
|
|
117
211
|
startFrameCapture: () => Promise<void>;
|
|
118
212
|
/**
|
|
119
213
|
* Starts a best-effort camera stream. Will pick a camera automatically if
|
|
120
214
|
* none is selected.
|
|
215
|
+
*
|
|
216
|
+
* @param params - The parameters for the camera stream.
|
|
217
|
+
* @returns resolves when the camera stream starts
|
|
121
218
|
*/
|
|
122
219
|
startCameraStream(params?: StartCameraStreamOptions): Promise<void>;
|
|
123
220
|
/**
|
|
124
|
-
* Pauses capturing frames without
|
|
221
|
+
* Pauses capturing frames, without stopping playback.
|
|
125
222
|
*/
|
|
126
223
|
stopFrameCapture(): void;
|
|
127
224
|
/**
|
|
@@ -134,31 +231,42 @@ export declare class CameraManager {
|
|
|
134
231
|
pausePlayback(): void;
|
|
135
232
|
/**
|
|
136
233
|
* If true, the video and captured frames will be mirrored horizontally.
|
|
234
|
+
*
|
|
235
|
+
* @param mirrorX - If true, the video and captured frames will be mirrored horizontally.
|
|
137
236
|
*/
|
|
138
237
|
setCameraMirrorX(mirrorX: boolean): void;
|
|
139
238
|
/**
|
|
140
239
|
* Allows the user to subscribe to state changes inside the Camera Manager.
|
|
141
240
|
* Implemented using Zustand. For usage information, see
|
|
142
|
-
*
|
|
241
|
+
* @see https://github.com/pmndrs/zustand#using-subscribe-with-selector for more details.
|
|
242
|
+
*
|
|
243
|
+
* @returns a cleanup function to remove the subscription
|
|
143
244
|
*/
|
|
144
245
|
subscribe: typeof cameraManagerStore.subscribe;
|
|
145
246
|
/**
|
|
146
247
|
* Gets the current internal state of the CameraManager.
|
|
248
|
+
*
|
|
249
|
+
* @returns the current state of the CameraManager
|
|
147
250
|
*/
|
|
148
251
|
getState: typeof cameraManagerStore.getState;
|
|
149
252
|
/**
|
|
150
|
-
* Resets the CameraManager and
|
|
253
|
+
* Resets the CameraManager and stops all streams.
|
|
151
254
|
*/
|
|
152
255
|
reset(): void;
|
|
153
256
|
}
|
|
154
257
|
|
|
258
|
+
/**
|
|
259
|
+
* The camera manager component.
|
|
260
|
+
*/
|
|
155
261
|
export declare type CameraManagerComponent = {
|
|
262
|
+
/** The camera manager. */
|
|
156
263
|
cameraManager: CameraManager;
|
|
157
264
|
/** Updates the localization strings */
|
|
158
265
|
updateLocalization: SetStoreFunction<CameraUiLocalizationStrings>;
|
|
159
266
|
/** Dismounts the component from the DOM and unloads the SDK */
|
|
160
267
|
dismount: () => void;
|
|
161
|
-
/**
|
|
268
|
+
/**
|
|
269
|
+
* Sets a callback to be called when the component is unmounted.
|
|
162
270
|
* Returns a cleanup function that removes the callback when called.
|
|
163
271
|
*/
|
|
164
272
|
addOnDismountCallback: (fn: DismountCallback) => () => void;
|
|
@@ -171,16 +279,26 @@ export declare type CameraManagerComponent = {
|
|
|
171
279
|
*/
|
|
172
280
|
overlayLayerNode: HTMLDivElement;
|
|
173
281
|
/**
|
|
174
|
-
*
|
|
282
|
+
* The owner of the component.
|
|
283
|
+
*
|
|
284
|
+
* @see https://docs.solidjs.com/reference/reactive-utilities/get-owner
|
|
175
285
|
*/
|
|
176
286
|
owner: Owner;
|
|
177
287
|
};
|
|
178
288
|
|
|
289
|
+
/**
|
|
290
|
+
* Options for the CameraManager.
|
|
291
|
+
*
|
|
292
|
+
* @param mirrorFrontCameras - If true, front-facing cameras will be mirrored horizontally when started.
|
|
293
|
+
*/
|
|
179
294
|
export declare type CameraManagerOptions = {
|
|
180
295
|
/** If true, the camera stream will be mirrored horizontally when started. */
|
|
181
296
|
mirrorFrontCameras: boolean;
|
|
182
297
|
};
|
|
183
298
|
|
|
299
|
+
/**
|
|
300
|
+
* The camera manager store.
|
|
301
|
+
*/
|
|
184
302
|
export declare type CameraManagerStore = {
|
|
185
303
|
/**
|
|
186
304
|
* The video element that will display the camera stream.
|
|
@@ -200,7 +318,7 @@ export declare type CameraManagerStore = {
|
|
|
200
318
|
*/
|
|
201
319
|
selectedCamera?: Camera;
|
|
202
320
|
/**
|
|
203
|
-
* Capturing / playing / idle
|
|
321
|
+
* Capturing / playing / idle.
|
|
204
322
|
*/
|
|
205
323
|
playbackState: PlaybackState;
|
|
206
324
|
/**
|
|
@@ -231,7 +349,7 @@ export declare type CameraManagerStore = {
|
|
|
231
349
|
*
|
|
232
350
|
* Prefer using subscriptions if you require observable state.
|
|
233
351
|
*
|
|
234
|
-
*
|
|
352
|
+
* @see https://github.com/pmndrs/zustand for more details.
|
|
235
353
|
*/
|
|
236
354
|
export declare const cameraManagerStore: Omit<StoreApi<CameraManagerStore>, "subscribe"> & {
|
|
237
355
|
subscribe: {
|
|
@@ -243,7 +361,13 @@ export declare const cameraManagerStore: Omit<StoreApi<CameraManagerStore>, "sub
|
|
|
243
361
|
};
|
|
244
362
|
};
|
|
245
363
|
|
|
364
|
+
/**
|
|
365
|
+
* The camera manager UI options.
|
|
366
|
+
*/
|
|
246
367
|
export declare type CameraManagerUiOptions = {
|
|
368
|
+
/**
|
|
369
|
+
* The localization strings.
|
|
370
|
+
*/
|
|
247
371
|
localizationStrings?: Partial<CameraUiLocalizationStrings>;
|
|
248
372
|
/**
|
|
249
373
|
* If set to `true`, the mirror camera button will be shown.
|
|
@@ -263,8 +387,19 @@ export declare type CameraManagerUiOptions = {
|
|
|
263
387
|
* @defaultValue true
|
|
264
388
|
*/
|
|
265
389
|
showCloseButton?: boolean;
|
|
390
|
+
/**
|
|
391
|
+
* If set to `true`, the camera error modal will be shown.
|
|
392
|
+
*
|
|
393
|
+
* @defaultValue true
|
|
394
|
+
*/
|
|
395
|
+
showCameraErrorModal?: boolean;
|
|
266
396
|
};
|
|
267
397
|
|
|
398
|
+
/**
|
|
399
|
+
* A camera preference.
|
|
400
|
+
*
|
|
401
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/facingMode for facing mode details.
|
|
402
|
+
*/
|
|
268
403
|
export declare type CameraPreference = {
|
|
269
404
|
preferredCamera: Camera | undefined;
|
|
270
405
|
preferredFacing?: undefined;
|
|
@@ -279,18 +414,33 @@ export declare type CameraPreference = {
|
|
|
279
414
|
preferredFacing?: undefined;
|
|
280
415
|
};
|
|
281
416
|
|
|
417
|
+
/**
|
|
418
|
+
* The camera UI locale record.
|
|
419
|
+
*/
|
|
282
420
|
export declare type CameraUiLocaleRecord = typeof _default;
|
|
283
421
|
|
|
422
|
+
/**
|
|
423
|
+
* The camera UI localization strings.
|
|
424
|
+
*/
|
|
284
425
|
export declare type CameraUiLocalizationStrings = {
|
|
285
426
|
[K in keyof CameraUiLocaleRecord]: CameraUiLocaleRecord[K] | (string & {});
|
|
286
427
|
};
|
|
287
428
|
|
|
429
|
+
/**
|
|
430
|
+
* The camera UI refs.
|
|
431
|
+
*/
|
|
288
432
|
export declare type CameraUiRefs = {
|
|
433
|
+
/** The feedback layer. */
|
|
289
434
|
feedbackLayer: HTMLDivElement;
|
|
435
|
+
/** The overlay layer. */
|
|
290
436
|
overlayLayer: HTMLDivElement;
|
|
437
|
+
/** The owner of the component. */
|
|
291
438
|
owner: Owner;
|
|
292
439
|
};
|
|
293
440
|
|
|
441
|
+
/**
|
|
442
|
+
* The camera UI ref store.
|
|
443
|
+
*/
|
|
294
444
|
export declare const cameraUiRefStore: Omit<StoreApi<CameraUiRefs>, "subscribe"> & {
|
|
295
445
|
subscribe: {
|
|
296
446
|
(listener: (selectedState: CameraUiRefs, previousSelectedState: CameraUiRefs) => void): () => void;
|
|
@@ -308,11 +458,16 @@ export declare type CanvasRenderingMode = "2d" | "webgl2";
|
|
|
308
458
|
|
|
309
459
|
/**
|
|
310
460
|
* Creates a new Camera Manager UI component.
|
|
461
|
+
*
|
|
462
|
+
* @param cameraManager - The camera manager.
|
|
463
|
+
* @param target - The target element to mount the component to.
|
|
464
|
+
* @param options - The options for the camera manager UI.
|
|
465
|
+
* @returns The camera manager UI component.
|
|
311
466
|
*/
|
|
312
|
-
export declare function createCameraManagerUi(cameraManager: CameraManager, target?: HTMLElement, { localizationStrings, showMirrorCameraButton, showTorchButton, showCloseButton, }?: CameraManagerUiOptions): Promise<CameraManagerComponent>;
|
|
467
|
+
export declare function createCameraManagerUi(cameraManager: CameraManager, target?: HTMLElement, { localizationStrings, showMirrorCameraButton, showTorchButton, showCloseButton, showCameraErrorModal, }?: CameraManagerUiOptions): Promise<CameraManagerComponent>;
|
|
313
468
|
|
|
314
469
|
/**
|
|
315
|
-
*
|
|
470
|
+
* The default English localization strings.
|
|
316
471
|
*/
|
|
317
472
|
declare const _default: {
|
|
318
473
|
readonly selected_camera: "Selected camera";
|
|
@@ -329,10 +484,19 @@ declare const _default: {
|
|
|
329
484
|
readonly camera_error_primary_btn: "Retry";
|
|
330
485
|
};
|
|
331
486
|
|
|
487
|
+
/**
|
|
488
|
+
* Default options for the CameraManager.
|
|
489
|
+
*/
|
|
332
490
|
export declare const defaultCameraManagerOptions: CameraManagerOptions;
|
|
333
491
|
|
|
492
|
+
/**
|
|
493
|
+
* A dismount callback.
|
|
494
|
+
*/
|
|
334
495
|
export declare type DismountCallback = () => void;
|
|
335
496
|
|
|
497
|
+
/**
|
|
498
|
+
* The extraction area.
|
|
499
|
+
*/
|
|
336
500
|
export declare type ExtractionArea = {
|
|
337
501
|
x: number;
|
|
338
502
|
y: number;
|
|
@@ -345,18 +509,38 @@ export declare type ExtractionArea = {
|
|
|
345
509
|
*/
|
|
346
510
|
export declare type FacingMode = "front" | "back" | undefined;
|
|
347
511
|
|
|
512
|
+
/**
|
|
513
|
+
* Finds the closest resolution key to the given resolution.
|
|
514
|
+
*
|
|
515
|
+
* @param videoTrackResolution - The resolution to find the closest key for.
|
|
516
|
+
* @returns The closest resolution key.
|
|
517
|
+
*/
|
|
348
518
|
export declare function findResolutionKey(videoTrackResolution: Resolution): VideoResolutionName;
|
|
349
519
|
|
|
520
|
+
/**
|
|
521
|
+
* A callback that will be triggered on each frame when the playback state is
|
|
522
|
+
* "capturing".
|
|
523
|
+
*
|
|
524
|
+
* @param frame - The frame to capture.
|
|
525
|
+
* @returns The frame.
|
|
526
|
+
*/
|
|
350
527
|
export declare type FrameCaptureCallback = (frame: ImageData) => Promisable<ArrayBufferLike | void>;
|
|
351
528
|
|
|
352
529
|
/**
|
|
353
530
|
* Converts a view to a buffer, since both match the type signature of
|
|
354
531
|
* `ArrayBufferLike`.
|
|
532
|
+
*
|
|
355
533
|
* @param buffer - The buffer or view to convert
|
|
356
534
|
* @returns The actual underlying buffer
|
|
357
535
|
*/
|
|
358
536
|
export declare const getBuffer: (buffer: ArrayBufferLike) => ArrayBufferLike;
|
|
359
537
|
|
|
538
|
+
/**
|
|
539
|
+
* Normalizes a resolution to the longer side.
|
|
540
|
+
*
|
|
541
|
+
* @param resolution - The resolution to normalize.
|
|
542
|
+
* @returns The normalized resolution.
|
|
543
|
+
*/
|
|
360
544
|
export declare function getNormalizedResolution(resolution: Resolution): Resolution;
|
|
361
545
|
|
|
362
546
|
export declare type ImageSource = HTMLVideoElement | HTMLCanvasElement | ImageBitmap;
|
|
@@ -368,25 +552,57 @@ export declare type ImageSource = HTMLVideoElement | HTMLCanvasElement | ImageBi
|
|
|
368
552
|
*/
|
|
369
553
|
export declare function isBufferDetached(buffer: ArrayBuffer): boolean;
|
|
370
554
|
|
|
555
|
+
/**
|
|
556
|
+
* Matches the closest resolution to the given resolution.
|
|
557
|
+
*
|
|
558
|
+
* @param resolution - The resolution to match.
|
|
559
|
+
* @returns The closest resolution.
|
|
560
|
+
*/
|
|
371
561
|
export declare function matchClosestResolution(resolution: Resolution): VideoResolutionName;
|
|
372
562
|
|
|
563
|
+
/**
|
|
564
|
+
* The default mount point ID.
|
|
565
|
+
*/
|
|
373
566
|
export declare const MOUNT_POINT_ID = "camera-manager-mount-point";
|
|
374
567
|
|
|
568
|
+
/**
|
|
569
|
+
* The playback state of the camera manager.
|
|
570
|
+
*/
|
|
375
571
|
export declare type PlaybackState = "idle" | "playback" | "capturing";
|
|
376
572
|
|
|
377
573
|
/**
|
|
378
574
|
* Resets the store to its initial state.
|
|
575
|
+
*
|
|
379
576
|
* Stops all camera streams as a side effect.
|
|
380
577
|
*/
|
|
381
578
|
export declare const resetCameraManagerStore: () => void;
|
|
382
579
|
|
|
580
|
+
/**
|
|
581
|
+
* Represents a video resolution.
|
|
582
|
+
*
|
|
583
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/width for width details.
|
|
584
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/height for height details.
|
|
585
|
+
*/
|
|
383
586
|
export declare type Resolution = {
|
|
384
587
|
width: number;
|
|
385
588
|
height: number;
|
|
386
589
|
};
|
|
387
590
|
|
|
591
|
+
/**
|
|
592
|
+
* Returns the longer side of a resolution.
|
|
593
|
+
*
|
|
594
|
+
* @param resolution - The resolution to get the longer side of.
|
|
595
|
+
* @returns The longer side of the resolution.
|
|
596
|
+
*/
|
|
388
597
|
export declare function returnLongerSide(resolution: Resolution): number;
|
|
389
598
|
|
|
599
|
+
/**
|
|
600
|
+
* Options for starting a camera stream.
|
|
601
|
+
*
|
|
602
|
+
* @param autoplay - If true, the camera stream will be started automatically.
|
|
603
|
+
* @param preferredCamera - The camera to start the stream with.
|
|
604
|
+
* @param preferredFacing - The facing mode to start the stream with.
|
|
605
|
+
*/
|
|
390
606
|
export declare type StartCameraStreamOptions = {
|
|
391
607
|
autoplay?: boolean;
|
|
392
608
|
} & CameraPreference;
|
|
@@ -396,43 +612,70 @@ export declare type StartCameraStreamOptions = {
|
|
|
396
612
|
*/
|
|
397
613
|
export declare class VideoFrameProcessor {
|
|
398
614
|
#private;
|
|
615
|
+
/**
|
|
616
|
+
* Creates a new VideoFrameProcessor.
|
|
617
|
+
*
|
|
618
|
+
* @param options - The options for the VideoFrameProcessor.
|
|
619
|
+
*/
|
|
399
620
|
constructor(options?: VideoFrameProcessorInitOptions);
|
|
400
621
|
/**
|
|
401
|
-
* Returns ownership of an ArrayBuffer to the processor for reuse
|
|
402
|
-
*
|
|
403
|
-
*
|
|
622
|
+
* Returns ownership of an ArrayBuffer to the processor for reuse.
|
|
623
|
+
*
|
|
624
|
+
* This should only be called with ArrayBuffers that were originally from this processor.
|
|
625
|
+
* Typically used after transferring the buffer to/from a worker.
|
|
626
|
+
*
|
|
627
|
+
* @param arrayBuffer - The array buffer to reattach.
|
|
404
628
|
*/
|
|
405
629
|
reattachArrayBuffer(arrayBuffer: ArrayBufferLike): void;
|
|
406
630
|
/**
|
|
407
|
-
* Used to check if the processor owns the buffer
|
|
631
|
+
* Used to check if the processor owns the buffer.
|
|
632
|
+
*
|
|
633
|
+
* @returns true if the processor owns the buffer, false otherwise.
|
|
408
634
|
*/
|
|
409
635
|
isBufferDetached(): boolean;
|
|
410
636
|
/**
|
|
411
|
-
* Extracts image data from a source element
|
|
637
|
+
* Extracts image data from a source element.
|
|
638
|
+
*
|
|
639
|
+
* @param source - The source element to extract image data from.
|
|
640
|
+
* @param area - The extraction area.
|
|
641
|
+
* @returns The image data.
|
|
412
642
|
*/
|
|
413
643
|
getImageData(source: ImageSource, area?: ExtractionArea): ImageData;
|
|
414
644
|
/**
|
|
415
645
|
* Used to get the current ImageData object with the current buffer. Useful
|
|
416
646
|
* when you need to get the same `ImageData` object multiple times after the
|
|
417
647
|
* original `ImageData` buffer has been detached
|
|
648
|
+
*
|
|
418
649
|
* @returns ImageData object with the current buffer
|
|
419
650
|
*/
|
|
420
651
|
getCurrentImageData(): ImageData;
|
|
421
652
|
/**
|
|
422
|
-
* Clean up resources
|
|
653
|
+
* Clean up resources.
|
|
423
654
|
*/
|
|
424
655
|
dispose(): void;
|
|
425
656
|
}
|
|
426
657
|
|
|
658
|
+
/**
|
|
659
|
+
* Options for the VideoFrameProcessor.
|
|
660
|
+
*/
|
|
427
661
|
export declare type VideoFrameProcessorInitOptions = {
|
|
428
662
|
canvasRenderingMode?: CanvasRenderingMode;
|
|
429
663
|
fallbackWebGlTo2d?: boolean;
|
|
430
664
|
};
|
|
431
665
|
|
|
666
|
+
/**
|
|
667
|
+
* Represents a video resolution name.
|
|
668
|
+
*
|
|
669
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/width for width details.
|
|
670
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/height for height details.
|
|
671
|
+
*/
|
|
432
672
|
export declare type VideoResolutionName = keyof typeof videoResolutions;
|
|
433
673
|
|
|
434
674
|
/**
|
|
435
675
|
* Available video resolutions for the camera stream.
|
|
676
|
+
*
|
|
677
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/width for width details.
|
|
678
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/height for height details.
|
|
436
679
|
*/
|
|
437
680
|
export declare const videoResolutions: {
|
|
438
681
|
readonly "720p": {
|