@microblink/camera-manager 7.2.1 → 7.2.2

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