@microblink/camera-manager 7.0.0-next.9 → 7.0.1
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 -5
- package/dist/camera-manager.js +1645 -1024
- package/package.json +6 -6
- package/types/core/Camera.d.ts +40 -2
- package/types/core/Camera.d.ts.map +1 -1
- package/types/core/CameraManager.d.ts +42 -39
- package/types/core/CameraManager.d.ts.map +1 -1
- package/types/core/VideoFrameProcessor.d.ts +61 -0
- package/types/core/VideoFrameProcessor.d.ts.map +1 -0
- package/types/core/cameraManagerStore.d.ts +2 -1
- package/types/core/cameraManagerStore.d.ts.map +1 -1
- package/types/core/cameraNames.d.ts.map +1 -1
- package/types/core/cameraUtils.d.ts +14 -7
- package/types/core/cameraUtils.d.ts.map +1 -1
- package/types/core/utils.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/index.rollup.d.ts +182 -42
- package/types/media-mock/MediaMocker.d.ts +4 -779
- package/types/media-mock/MediaMocker.d.ts.map +1 -1
- package/types/media-mock/createInputDeviceInfo.d.ts.map +1 -1
- package/types/media-mock/fake-devices.d.ts +1 -788
- package/types/media-mock/fake-devices.d.ts.map +1 -1
- package/types/media-mock/fakeDevices/SamsungS21FE.d.ts +6 -0
- package/types/media-mock/fakeDevices/SamsungS21FE.d.ts.map +1 -0
- package/types/media-mock/fakeDevices/iPhone15.d.ts +6 -0
- package/types/media-mock/fakeDevices/iPhone15.d.ts.map +1 -0
- package/types/media-mock/fakeDevices/iPhoneSE.d.ts +9 -0
- package/types/media-mock/fakeDevices/iPhoneSE.d.ts.map +1 -0
- package/types/media-mock/utils.d.ts +4 -0
- package/types/media-mock/utils.d.ts.map +1 -1
- package/types/ui/CameraErrorModal.d.ts +7 -0
- package/types/ui/CameraErrorModal.d.ts.map +1 -0
- package/types/ui/CameraSelector.d.ts.map +1 -1
- package/types/ui/CameraUiStoreContext.d.ts +15 -2
- package/types/ui/CameraUiStoreContext.d.ts.map +1 -1
- package/types/ui/CaptureScreen.d.ts +2 -0
- package/types/ui/CaptureScreen.d.ts.map +1 -1
- package/types/ui/Header.d.ts.map +1 -1
- package/types/ui/RootComponent.d.ts.map +1 -1
- package/types/ui/SolidShadowRoot.d.ts +1 -12
- package/types/ui/SolidShadowRoot.d.ts.map +1 -1
- package/types/ui/createCameraManagerUi.d.ts +16 -8
- package/types/ui/createCameraManagerUi.d.ts.map +1 -1
- package/types/ui/determineFitMode.d.ts +35 -0
- package/types/ui/determineFitMode.d.ts.map +1 -0
- package/types/ui/determineFitMode.test.d.ts +5 -0
- package/types/ui/determineFitMode.test.d.ts.map +1 -0
- package/types/ui/getVisibleVideoArea.d.ts +10 -0
- package/types/ui/getVisibleVideoArea.d.ts.map +1 -0
- package/types/ui/getVisibleVideoArea.test.d.ts +5 -0
- package/types/ui/getVisibleVideoArea.test.d.ts.map +1 -0
- package/types/ui/locales/en.d.ts +7 -1
- package/types/ui/locales/en.d.ts.map +1 -1
- package/types/ui/zustandRefStore.d.ts +2 -0
- package/types/ui/zustandRefStore.d.ts.map +1 -1
- package/types/core/createCustomImageData.d.ts +0 -14
- package/types/core/createCustomImageData.d.ts.map +0 -1
- package/types/core/imageDataUtils.d.ts +0 -6
- package/types/core/imageDataUtils.d.ts.map +0 -1
- package/types/core/videoToImageData.d.ts +0 -5
- package/types/core/videoToImageData.d.ts.map +0 -1
- package/types/ui/ErrorAlert.d.ts +0 -8
- package/types/ui/ErrorAlert.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microblink/camera-manager",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"author": "Microblink",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/camera-manager.js",
|
|
7
7
|
"module": "./dist/camera-manager.js",
|
|
8
|
-
"description": "",
|
|
8
|
+
"description": "Manages cameras and stream, provides both a headless component and a UI component",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
11
|
"types"
|
|
12
12
|
],
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@ark-ui/solid": "^
|
|
15
|
-
"solid-js": "^1.9.
|
|
14
|
+
"@ark-ui/solid": "^5.5.0",
|
|
15
|
+
"solid-js": "^1.9.5",
|
|
16
16
|
"solid-zustand": "^1.8.1",
|
|
17
17
|
"zustand": "^4.5.5"
|
|
18
18
|
},
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"access": "public",
|
|
23
23
|
"registry": "https://registry.npmjs.org/",
|
|
24
24
|
"types": "./types/index.rollup.d.ts",
|
|
25
|
-
"homepage": "https://github.com/BlinkID/blinkid-
|
|
25
|
+
"homepage": "https://github.com/BlinkID/blinkid-web",
|
|
26
26
|
"repository": {
|
|
27
27
|
"type": "git",
|
|
28
|
-
"url": "git+https://github.com/BlinkID/blinkid-
|
|
28
|
+
"url": "git+https://github.com/BlinkID/blinkid-web.git"
|
|
29
29
|
},
|
|
30
30
|
"exports": {
|
|
31
31
|
".": {
|
package/types/core/Camera.d.ts
CHANGED
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2025 Microblink Ltd. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import { VideoResolution } from "./CameraManager";
|
|
5
4
|
export type FacingMode = "front" | "back" | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Available video resolutions for the camera stream.
|
|
7
|
+
*/
|
|
8
|
+
export declare const videoResolutions: {
|
|
9
|
+
readonly "720p": {
|
|
10
|
+
readonly width: 1280;
|
|
11
|
+
readonly height: 720;
|
|
12
|
+
};
|
|
13
|
+
readonly "1080p": {
|
|
14
|
+
readonly width: 1920;
|
|
15
|
+
readonly height: 1080;
|
|
16
|
+
};
|
|
17
|
+
readonly "4k": {
|
|
18
|
+
readonly width: 3840;
|
|
19
|
+
readonly height: 2160;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export type Resolution = {
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
};
|
|
26
|
+
export type VideoResolutionName = keyof typeof videoResolutions;
|
|
27
|
+
export declare function returnLongerSide(resolution: Resolution): number;
|
|
28
|
+
export declare function getNormalizedResolution(resolution: Resolution): Resolution;
|
|
29
|
+
export declare function matchClosestResolution(resolution: Resolution): VideoResolutionName;
|
|
30
|
+
export declare function findResolutionKey(videoTrackResolution: Resolution): VideoResolutionName;
|
|
6
31
|
/**
|
|
7
32
|
* Represents a camera device and its active stream.
|
|
8
33
|
*/
|
|
@@ -24,11 +49,24 @@ export declare class Camera {
|
|
|
24
49
|
torchSupported: boolean;
|
|
25
50
|
torchEnabled: boolean;
|
|
26
51
|
singleShotSupported: boolean;
|
|
52
|
+
maxSupportedResolution?: VideoResolutionName;
|
|
53
|
+
/**
|
|
54
|
+
* Reference to the original instance before it was proxied.
|
|
55
|
+
*/
|
|
27
56
|
original: this;
|
|
28
57
|
notify: (reason?: unknown) => void;
|
|
29
58
|
notifyStateChange?: (camera: Camera, reason?: unknown) => void;
|
|
30
59
|
constructor(deviceInfo: InputDeviceInfo);
|
|
31
|
-
startStream(resolution:
|
|
60
|
+
startStream(resolution: VideoResolutionName): Promise<MediaStream>;
|
|
61
|
+
/**
|
|
62
|
+
* Acquires a camera stream with the specified resolution.
|
|
63
|
+
* If acquisition fails, it tries a lower resolution as fallback.
|
|
64
|
+
*/
|
|
65
|
+
private acquireStreamWithFallback;
|
|
66
|
+
/**
|
|
67
|
+
* Populates the camera instance with capabilities from the stream.
|
|
68
|
+
*/
|
|
69
|
+
private populateCapabilities;
|
|
32
70
|
toggleTorch(): Promise<boolean>;
|
|
33
71
|
stopStream(): void;
|
|
34
72
|
getVideoTrack(): MediaStreamTrack | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Camera.d.ts","sourceRoot":"","sources":["../../src/core/Camera.ts"],"names":[],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AAI,CAAC;gBAanD,UAAU,EAAE,eAAe;IAmDjC,WAAW,CAAC,UAAU,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC;IA6BxE;;;OAGG;YACW,yBAAyB;IAoCvC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA+DtB,WAAW;IA+BjB,UAAU;IAUV,aAAa;CAQd"}
|
|
@@ -1,44 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2025 Microblink Ltd. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import { Camera, FacingMode } from "./Camera";
|
|
4
|
+
import { Camera, FacingMode, VideoResolutionName } from "./Camera";
|
|
5
5
|
import { cameraManagerStore as store } from "./cameraManagerStore";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare const videoResolutions: {
|
|
11
|
-
HD: {
|
|
12
|
-
width: number;
|
|
13
|
-
height: number;
|
|
14
|
-
};
|
|
15
|
-
FHD: {
|
|
16
|
-
width: number;
|
|
17
|
-
height: number;
|
|
18
|
-
};
|
|
19
|
-
UHD: {
|
|
20
|
-
width: number;
|
|
21
|
-
height: number;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export type VideoResolution = keyof typeof videoResolutions;
|
|
6
|
+
import { Promisable } from "type-fest";
|
|
7
|
+
import { ExtractionArea, VideoFrameProcessorInitOptions } from "./VideoFrameProcessor";
|
|
8
|
+
export type FrameCaptureCallback = (frame: ImageData) => Promisable<ArrayBufferLike | void>;
|
|
9
|
+
type CameraGetter = (cameras: Camera[]) => Camera | undefined;
|
|
25
10
|
export type CameraPreference = {
|
|
26
|
-
preferredCamera: Camera;
|
|
27
|
-
preferredFacing?:
|
|
11
|
+
preferredCamera: Camera | undefined;
|
|
12
|
+
preferredFacing?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
preferredCamera: CameraGetter | undefined;
|
|
15
|
+
preferredFacing?: undefined;
|
|
28
16
|
} | {
|
|
29
17
|
preferredFacing: FacingMode;
|
|
30
|
-
preferredCamera?:
|
|
18
|
+
preferredCamera?: undefined;
|
|
31
19
|
} | {
|
|
32
|
-
preferredCamera?:
|
|
33
|
-
preferredFacing?:
|
|
20
|
+
preferredCamera?: undefined;
|
|
21
|
+
preferredFacing?: undefined;
|
|
34
22
|
};
|
|
23
|
+
export type StartCameraStreamOptions = {
|
|
24
|
+
autoplay?: boolean;
|
|
25
|
+
} & CameraPreference;
|
|
26
|
+
export type CameraManagerOptions = {
|
|
27
|
+
/** If true, the camera stream will be mirrored horizontally when started. */
|
|
28
|
+
mirrorFrontCameras: boolean;
|
|
29
|
+
};
|
|
30
|
+
export declare const defaultCameraManagerOptions: CameraManagerOptions;
|
|
35
31
|
export declare class CameraManager {
|
|
36
32
|
#private;
|
|
33
|
+
get userInitiatedAbort(): boolean;
|
|
34
|
+
set userInitiatedAbort(value: boolean);
|
|
35
|
+
/**
|
|
36
|
+
* Sets the area of the video frame that will be extracted.
|
|
37
|
+
* @param extractionArea The area of the video frame that will be extracted.
|
|
38
|
+
*/
|
|
39
|
+
setExtractionArea(extractionArea: ExtractionArea): void;
|
|
40
|
+
constructor(options?: Partial<CameraManagerOptions>, videoFrameProcessorOptions?: VideoFrameProcessorInitOptions);
|
|
37
41
|
/**
|
|
38
42
|
* Sets the resolution of the camera stream
|
|
39
43
|
*/
|
|
40
|
-
setResolution: (resolution:
|
|
41
|
-
get resolution(): "
|
|
44
|
+
setResolution: (resolution: VideoResolutionName) => Promise<void>;
|
|
45
|
+
get resolution(): "720p" | "1080p" | "4k";
|
|
42
46
|
/**
|
|
43
47
|
* True if there is a video playing or capturing
|
|
44
48
|
* TODO: see if we can simplify this, by observing the video playback state
|
|
@@ -49,9 +53,9 @@ export declare class CameraManager {
|
|
|
49
53
|
* Returns the cameras that are available to the user, filtered by the facing mode.
|
|
50
54
|
* If no facing mode is set, all cameras are returned.
|
|
51
55
|
*/
|
|
52
|
-
|
|
56
|
+
getCameraDevices(): Promise<Camera[]>;
|
|
53
57
|
/**
|
|
54
|
-
*
|
|
58
|
+
* Initializes the CameraManager with a video element.
|
|
55
59
|
*/
|
|
56
60
|
initVideoElement(videoElement: HTMLVideoElement): void;
|
|
57
61
|
/**
|
|
@@ -62,9 +66,11 @@ export declare class CameraManager {
|
|
|
62
66
|
* @returns a cleanup function to remove the callback
|
|
63
67
|
*/
|
|
64
68
|
addFrameCaptureCallback(frameCaptureCallback: FrameCaptureCallback): () => boolean;
|
|
65
|
-
|
|
69
|
+
releaseVideoElement(): void;
|
|
66
70
|
/**
|
|
67
71
|
* Select a camera device from available ones.
|
|
72
|
+
*
|
|
73
|
+
* TODO: might become a private method in the future as an implementation detail of `startStream`
|
|
68
74
|
*/
|
|
69
75
|
selectCamera(camera: Camera): Promise<void>;
|
|
70
76
|
/**
|
|
@@ -78,17 +84,14 @@ export declare class CameraManager {
|
|
|
78
84
|
*/
|
|
79
85
|
startPlayback(): Promise<void>;
|
|
80
86
|
/**
|
|
81
|
-
* Starts
|
|
87
|
+
* Starts capturing frames from the video element.
|
|
82
88
|
*/
|
|
83
|
-
startFrameCapture()
|
|
89
|
+
startFrameCapture: () => Promise<void>;
|
|
84
90
|
/**
|
|
85
91
|
* Starts a best-effort camera stream. Will pick a camera automatically if
|
|
86
92
|
* none is selected.
|
|
87
|
-
* TODO: Rename method
|
|
88
93
|
*/
|
|
89
|
-
startCameraStream(
|
|
90
|
-
autoplay?: boolean;
|
|
91
|
-
} & CameraPreference): Promise<void>;
|
|
94
|
+
startCameraStream(params?: StartCameraStreamOptions): Promise<void>;
|
|
92
95
|
/**
|
|
93
96
|
* Pauses capturing frames without pausing playback.
|
|
94
97
|
*/
|
|
@@ -103,9 +106,8 @@ export declare class CameraManager {
|
|
|
103
106
|
pausePlayback(): void;
|
|
104
107
|
/**
|
|
105
108
|
* If true, the video and captured frames will be mirrored horizontally.
|
|
106
|
-
* TODO: apply when needed
|
|
107
109
|
*/
|
|
108
|
-
|
|
110
|
+
setCameraMirrorX(mirrorX: boolean): void;
|
|
109
111
|
/**
|
|
110
112
|
* Allows the user to subscribe to state changes inside the Camera Manager.
|
|
111
113
|
* Implemented using Zustand. For usage information, see
|
|
@@ -119,6 +121,7 @@ export declare class CameraManager {
|
|
|
119
121
|
/**
|
|
120
122
|
* Resets the CameraManager and stop all streams
|
|
121
123
|
*/
|
|
122
|
-
|
|
124
|
+
reset(): void;
|
|
123
125
|
}
|
|
126
|
+
export {};
|
|
124
127
|
//# 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,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;AAQnE,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,MAAM,MAAM,oBAAoB,GAAG,CACjC,KAAK,EAAE,SAAS,KACb,UAAU,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;AAExC,KAAK,YAAY,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,GAAG,SAAS,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GACxB;IAEE,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B,GACD;IAEE,eAAe,EAAE,YAAY,GAAG,SAAS,CAAC;IAC1C,eAAe,CAAC,E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hB;;OAEG;IACH,UAAU;IAYV;;OAEG;IACH,aAAa;IAmIb;;OAEG;IACH,gBAAgB,CAAC,OAAO,EAAE,OAAO;IAyBjC;;;;OAIG;IACH,SAAS,EAAE,OAAO,KAAK,CAAC,SAAS,CAAmB;IAEpD;;OAEG;IACH,QAAQ,EAAE,OAAO,KAAK,CAAC,QAAQ,CAAkB;IAEjD;;OAEG;IACH,KAAK;CAMN"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Microblink Ltd. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
export type CanvasRenderingMode = "2d" | "webgl2";
|
|
5
|
+
export type ImageSource = HTMLVideoElement | HTMLCanvasElement | ImageBitmap;
|
|
6
|
+
export type VideoFrameProcessorInitOptions = {
|
|
7
|
+
canvasRenderingMode?: CanvasRenderingMode;
|
|
8
|
+
fallbackWebGlTo2d?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Check if an ArrayBuffer is detached
|
|
12
|
+
* @param buffer - ArrayBuffer to check
|
|
13
|
+
* @returns true if the buffer is detached, false otherwise
|
|
14
|
+
*/
|
|
15
|
+
export declare function isBufferDetached(buffer: ArrayBuffer): boolean;
|
|
16
|
+
export type ExtractionArea = {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* VideoFrameProcessor captures frames from video or image sources using either 2D or WebGL2 rendering
|
|
24
|
+
*/
|
|
25
|
+
export declare class VideoFrameProcessor {
|
|
26
|
+
#private;
|
|
27
|
+
constructor(options?: VideoFrameProcessorInitOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Returns ownership of an ArrayBuffer to the processor for reuse
|
|
30
|
+
* This should only be called with ArrayBuffers that were originally from this processor
|
|
31
|
+
* Typically used after transferring the buffer to/from a worker
|
|
32
|
+
*/
|
|
33
|
+
reattachArrayBuffer(arrayBuffer: ArrayBufferLike): void;
|
|
34
|
+
/**
|
|
35
|
+
* Used to check if the processor owns the buffer
|
|
36
|
+
*/
|
|
37
|
+
isBufferDetached(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Extracts image data from a source element
|
|
40
|
+
*/
|
|
41
|
+
getImageData(source: ImageSource, area?: ExtractionArea): ImageData;
|
|
42
|
+
/**
|
|
43
|
+
* Used to get the current ImageData object with the current buffer. Useful
|
|
44
|
+
* when you need to get the same `ImageData` object multiple times after the
|
|
45
|
+
* original `ImageData` buffer has been detached
|
|
46
|
+
* @returns ImageData object with the current buffer
|
|
47
|
+
*/
|
|
48
|
+
getCurrentImageData(): ImageData;
|
|
49
|
+
/**
|
|
50
|
+
* Clean up resources
|
|
51
|
+
*/
|
|
52
|
+
dispose(): void;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Converts a view to a buffer, since both match the type signature of
|
|
56
|
+
* `ArrayBufferLike`.
|
|
57
|
+
* @param buffer - The buffer or view to convert
|
|
58
|
+
* @returns The actual underlying buffer
|
|
59
|
+
*/
|
|
60
|
+
export declare const getBuffer: (buffer: ArrayBufferLike) => ArrayBufferLike;
|
|
61
|
+
//# sourceMappingURL=VideoFrameProcessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoFrameProcessor.d.ts","sourceRoot":"","sources":["../../src/core/VideoFrameProcessor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,mBAAmB,GAAG,IAAI,GAAG,QAAQ,CAAC;AAClD,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,WAAW,CAAC;AAE7E,MAAM,MAAM,8BAA8B,GAAG;IAC3C,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAe7D;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,qBAAa,mBAAmB;;gBAYlB,OAAO,GAAE,8BAAmC;IAyFxD;;;;OAIG;IACH,mBAAmB,CAAC,WAAW,EAAE,eAAe,GAAG,IAAI;IAoBvD;;OAEG;IACH,gBAAgB,IAAI,OAAO;IAO3B;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,SAAS;IAMnE;;;;;OAKG;IACH,mBAAmB,IAAI,SAAS;IA0HhC;;OAEG;IACH,OAAO,IAAI,IAAI;CAehB;AACD;;;;;GAKG;AAEH,eAAO,MAAM,SAAS,GAAI,QAAQ,eAAe,oBAOhD,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2025 Microblink Ltd. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
import { Camera, FacingMode } from "./Camera";
|
|
5
|
+
import { CameraError } from "./cameraUtils";
|
|
5
6
|
export type PlaybackState = "idle" | "playback" | "capturing";
|
|
6
7
|
export type CameraManagerStore = {
|
|
7
8
|
/**
|
|
@@ -40,7 +41,7 @@ export type CameraManagerStore = {
|
|
|
40
41
|
/**
|
|
41
42
|
* If the Camera manager has encountered an error, this will be set to the error.
|
|
42
43
|
*/
|
|
43
|
-
errorState?: Error;
|
|
44
|
+
errorState?: Error | CameraError;
|
|
44
45
|
};
|
|
45
46
|
/**
|
|
46
47
|
* ⚠️ DANGER AHEAD ⚠️
|
|
@@ -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,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,CAAC;AAE9D,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAEhC;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB;;;OAGG;IACH,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAE5B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,aAAa,EAAE,aAAa,CAAC;IAE7B;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC;CAClC,CAAC;AAeF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;CAG9B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,YAOnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cameraNames.d.ts","sourceRoot":"","sources":["../../src/core/cameraNames.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,gWAuEF,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,mBAAmB,sUAmEH,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,uBAAuB,8vBA8CP,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,+BAA+B,krCAsCf,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"cameraNames.d.ts","sourceRoot":"","sources":["../../src/core/cameraNames.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,gWAuEF,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,mBAAmB,sUAmEH,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,uBAAuB,8vBA8CP,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,+BAA+B,krCAsCf,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,UAAU,MAAM,EAAE,YAEjE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,YACF,CAAC;AAE9C,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,YACF,CAAC"}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2025 Microblink Ltd. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import { Camera, FacingMode } from "./Camera";
|
|
5
|
-
|
|
4
|
+
import { Camera, FacingMode, VideoResolutionName } from "./Camera";
|
|
5
|
+
type CameraErrorCode = "PERMISSION_DENIED" | (string & {});
|
|
6
|
+
export declare class CameraError extends Error {
|
|
7
|
+
code: CameraErrorCode;
|
|
8
|
+
constructor(message: string, code: CameraErrorCode, cause?: Error);
|
|
9
|
+
}
|
|
6
10
|
/**
|
|
7
11
|
* Trigger camera permission dialog.
|
|
8
12
|
*/
|
|
9
13
|
export declare const askForCameraPermission: () => Promise<void>;
|
|
10
14
|
/**
|
|
11
|
-
* Returns available camera
|
|
15
|
+
* Returns available camera devices on the user's device.
|
|
16
|
+
* @returns An array of {@linkcode InputDeviceInfo} objects representing the available camera devices.
|
|
12
17
|
*/
|
|
13
|
-
export declare const
|
|
18
|
+
export declare const obtainVideoInputDevices: () => Promise<InputDeviceInfo[]>;
|
|
14
19
|
export declare const closeStreamTracks: (stream: MediaStream) => void;
|
|
15
|
-
export declare const createConstraints: (resolution:
|
|
20
|
+
export declare const createConstraints: (resolution: VideoResolutionName, facing?: FacingMode, id?: Camera["deviceInfo"]["deviceId"]) => MediaStreamConstraints;
|
|
16
21
|
/**
|
|
17
|
-
*
|
|
22
|
+
* Finds the ideal camera based on the provided constraints.
|
|
23
|
+
*
|
|
18
24
|
* @param cameras Available {@linkcode Camera}s on the device
|
|
19
25
|
* @param resolution Ideal resolution for the camera stream, will fall back to the closest available resolution.
|
|
20
26
|
* @param requestedFacing Ideal facing mode for the camera stream. If not provided, will default to back camera.
|
|
@@ -22,10 +28,11 @@ export declare const createConstraints: (resolution: VideoResolution, facing?: F
|
|
|
22
28
|
*
|
|
23
29
|
* @returns A {@linkcode Camera} instance that matches the provided constraints, with an active stream.
|
|
24
30
|
*/
|
|
25
|
-
export declare const findIdealCamera: (cameras: Camera[], resolution?:
|
|
31
|
+
export declare const findIdealCamera: (cameras: Camera[], resolution?: VideoResolutionName, requestedFacing?: FacingMode) => Promise<Camera>;
|
|
26
32
|
/**
|
|
27
33
|
* Creates an array of {@linkcode Camera} instances with stream from native
|
|
28
34
|
* `deviceInfo` objects.
|
|
29
35
|
*/
|
|
30
36
|
export declare function createCameras(cameras: InputDeviceInfo[]): Camera[];
|
|
37
|
+
export {};
|
|
31
38
|
//# sourceMappingURL=cameraUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cameraUtils.d.ts","sourceRoot":"","sources":["../../src/core/cameraUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,
|
|
1
|
+
{"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,KAAK,eAAe,GAAG,mBAAmB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAE3D,qBAAa,WAAY,SAAQ,KAAK;IACpC,IAAI,EAAE,eAAe,CAAC;gBAEV,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,CAAC,EAAE,KAAK;CAKlE;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,qBAkBlC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,kCAkBnC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,WAAW,SAKpD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,YAAY,mBAAmB,EAC/B,SAAS,UAAU,EACnB,KAAK,MAAM,CAAC,YAAY,CAAC,CAAC,UAAU,CAAC,2BAuBtC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,EAAE,EACjB,aAAY,mBAA0B,EACtC,kBAAiB,UAAmB,KACnC,OAAO,CAAC,MAAM,CAsIhB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,YAWvD"}
|
|
@@ -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,
|
|
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"}
|
package/types/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import "rvfc-polyfill";
|
|
|
5
5
|
export * from "./core/cameraManagerStore";
|
|
6
6
|
export * from "./core/Camera";
|
|
7
7
|
export * from "./core/CameraManager";
|
|
8
|
+
export * from "./core/VideoFrameProcessor";
|
|
8
9
|
export * from "./ui/createCameraManagerUi";
|
|
9
10
|
export { cameraUiRefStore } from "./ui/zustandRefStore";
|
|
10
11
|
export type { CameraUiRefs } from "./ui/zustandRefStore";
|
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,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,eAAe,CAAC;AAEvB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,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,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,kBAAkB,EAAE,OAAO,UAAU,CAAC;CAC3C"}
|