@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.
Files changed (64) hide show
  1. package/README.md +75 -5
  2. package/dist/camera-manager.js +1645 -1024
  3. package/package.json +6 -6
  4. package/types/core/Camera.d.ts +40 -2
  5. package/types/core/Camera.d.ts.map +1 -1
  6. package/types/core/CameraManager.d.ts +42 -39
  7. package/types/core/CameraManager.d.ts.map +1 -1
  8. package/types/core/VideoFrameProcessor.d.ts +61 -0
  9. package/types/core/VideoFrameProcessor.d.ts.map +1 -0
  10. package/types/core/cameraManagerStore.d.ts +2 -1
  11. package/types/core/cameraManagerStore.d.ts.map +1 -1
  12. package/types/core/cameraNames.d.ts.map +1 -1
  13. package/types/core/cameraUtils.d.ts +14 -7
  14. package/types/core/cameraUtils.d.ts.map +1 -1
  15. package/types/core/utils.d.ts.map +1 -1
  16. package/types/index.d.ts +1 -0
  17. package/types/index.d.ts.map +1 -1
  18. package/types/index.rollup.d.ts +182 -42
  19. package/types/media-mock/MediaMocker.d.ts +4 -779
  20. package/types/media-mock/MediaMocker.d.ts.map +1 -1
  21. package/types/media-mock/createInputDeviceInfo.d.ts.map +1 -1
  22. package/types/media-mock/fake-devices.d.ts +1 -788
  23. package/types/media-mock/fake-devices.d.ts.map +1 -1
  24. package/types/media-mock/fakeDevices/SamsungS21FE.d.ts +6 -0
  25. package/types/media-mock/fakeDevices/SamsungS21FE.d.ts.map +1 -0
  26. package/types/media-mock/fakeDevices/iPhone15.d.ts +6 -0
  27. package/types/media-mock/fakeDevices/iPhone15.d.ts.map +1 -0
  28. package/types/media-mock/fakeDevices/iPhoneSE.d.ts +9 -0
  29. package/types/media-mock/fakeDevices/iPhoneSE.d.ts.map +1 -0
  30. package/types/media-mock/utils.d.ts +4 -0
  31. package/types/media-mock/utils.d.ts.map +1 -1
  32. package/types/ui/CameraErrorModal.d.ts +7 -0
  33. package/types/ui/CameraErrorModal.d.ts.map +1 -0
  34. package/types/ui/CameraSelector.d.ts.map +1 -1
  35. package/types/ui/CameraUiStoreContext.d.ts +15 -2
  36. package/types/ui/CameraUiStoreContext.d.ts.map +1 -1
  37. package/types/ui/CaptureScreen.d.ts +2 -0
  38. package/types/ui/CaptureScreen.d.ts.map +1 -1
  39. package/types/ui/Header.d.ts.map +1 -1
  40. package/types/ui/RootComponent.d.ts.map +1 -1
  41. package/types/ui/SolidShadowRoot.d.ts +1 -12
  42. package/types/ui/SolidShadowRoot.d.ts.map +1 -1
  43. package/types/ui/createCameraManagerUi.d.ts +16 -8
  44. package/types/ui/createCameraManagerUi.d.ts.map +1 -1
  45. package/types/ui/determineFitMode.d.ts +35 -0
  46. package/types/ui/determineFitMode.d.ts.map +1 -0
  47. package/types/ui/determineFitMode.test.d.ts +5 -0
  48. package/types/ui/determineFitMode.test.d.ts.map +1 -0
  49. package/types/ui/getVisibleVideoArea.d.ts +10 -0
  50. package/types/ui/getVisibleVideoArea.d.ts.map +1 -0
  51. package/types/ui/getVisibleVideoArea.test.d.ts +5 -0
  52. package/types/ui/getVisibleVideoArea.test.d.ts.map +1 -0
  53. package/types/ui/locales/en.d.ts +7 -1
  54. package/types/ui/locales/en.d.ts.map +1 -1
  55. package/types/ui/zustandRefStore.d.ts +2 -0
  56. package/types/ui/zustandRefStore.d.ts.map +1 -1
  57. package/types/core/createCustomImageData.d.ts +0 -14
  58. package/types/core/createCustomImageData.d.ts.map +0 -1
  59. package/types/core/imageDataUtils.d.ts +0 -6
  60. package/types/core/imageDataUtils.d.ts.map +0 -1
  61. package/types/core/videoToImageData.d.ts +0 -5
  62. package/types/core/videoToImageData.d.ts.map +0 -1
  63. package/types/ui/ErrorAlert.d.ts +0 -8
  64. package/types/ui/ErrorAlert.d.ts.map +0 -1
package/README.md CHANGED
@@ -1,8 +1,78 @@
1
- # Camera Manager
1
+ # @microblink/camera-manager
2
2
 
3
- The camera manager is a component that handles managing cameras, video streams and providing frames for usage in further processing.
4
- It doesn't do any processing on its own, and isn't dependent on any SDK.
3
+ This package provides camera management for web applications. It handles camera selection, permissions, video stream management, and provides access to video frames for further processing. It is framework-agnostic and can be used with or without a UI.
5
4
 
6
- It can be used with or without the UI component.
5
+ ## Overview
7
6
 
8
- Check out the [`camera-manager` example](../../apps/examples/camera-manager/src/App.tsx) for usage.
7
+ - Handles camera selection, permissions, and video stream lifecycle.
8
+ - Provides access to video frames for downstream processing.
9
+ - Can be used standalone or with the included UI components.
10
+ - Used by [`@microblink/blinkid-ux-manager`](https://www.npmjs.com/package/@microblink/blinkid-ux-manager) and [`@microblink/blinkid`](https://www.npmjs.com/package/@microblink/blinkid).
11
+
12
+ ## Installation
13
+
14
+ Install from npm using your preferred package manager:
15
+
16
+ ```sh
17
+ npm install @microblink/camera-manager
18
+ # or
19
+ yarn add @microblink/camera-manager
20
+ # or
21
+ pnpm add @microblink/camera-manager
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ### Basic Example
27
+
28
+ ```js
29
+ import { CameraManager } from "@microblink/camera-manager";
30
+
31
+ const cameraManager = new CameraManager();
32
+
33
+ // Start the camera stream (auto-selects the best camera)
34
+ await cameraManager.startCameraStream();
35
+
36
+ // Optionally, attach the video to a DOM element
37
+ const video = document.getElementById("video");
38
+ cameraManager.initVideoElement(video);
39
+
40
+ // Capture frames for processing
41
+ const removeCallback = cameraManager.addFrameCaptureCallback((imageData) => {
42
+ // Process imageData (instance of ImageData)
43
+ });
44
+
45
+ // Stop the camera when done
46
+ cameraManager.stopStream();
47
+ ```
48
+
49
+ See the [`camera-manager` example](../../apps/examples/camera-manager/src/App.tsx) for more usage details.
50
+
51
+ ## API
52
+
53
+ ### `CameraManager` class
54
+
55
+ - `startCameraStream(options?)`: Starts the camera stream. Options allow selecting a specific camera or facing mode.
56
+ - `initVideoElement(videoElement)`: Attaches a video element for preview.
57
+ - `addFrameCaptureCallback(callback)`: Registers a callback to receive frames as `ImageData` during capture. Returns a cleanup function.
58
+ - `startFrameCapture()`: Starts capturing frames for processing.
59
+ - `stopFrameCapture()`: Stops capturing frames but keeps the stream active.
60
+ - `stopStream()`: Stops the camera stream and video playback.
61
+ - `setResolution(resolution)`: Sets the desired video resolution (e.g., `"1080p"`).
62
+ - `setFacingFilter(facingModes)`: Filters available cameras by facing mode (`"front"` or `"back"`).
63
+ - `getCameraDevices()`: Returns available camera devices.
64
+ - `selectCamera(camera)`: Selects a specific camera device.
65
+ - `setCameraMirrorX(mirrorX)`: Mirrors the video horizontally if needed.
66
+ - `reset()`: Resets the camera manager and stops all streams.
67
+
68
+ ### UI Integration
69
+
70
+ To use the built-in UI, use:
71
+
72
+ ```js
73
+ import { createCameraManagerUi } from "@microblink/camera-manager";
74
+
75
+ const cameraUi = await createCameraManagerUi(cameraManager, document.body);
76
+ // Optionally, add cleanup:
77
+ cameraUi.dismount();
78
+ ```