import { t as Serializable } from "./Serializable-BNGC32bH.js"; import { t as Rect } from "./Rect-tESibxOU.js"; import { t as INTERNAL_ACCESS } from "./privateAccess-DLrOMEAu.js"; //#region src/main/private/CameraAccess.d.ts declare enum CameraPosition$1 { WorldFacing = "worldFacing", UserFacing = "userFacing" } declare enum CameraResolutionConstraint { ULTRA_HD = 0, FULL_HD = 1, HD = 2, SD = 3, NONE = 4 } declare enum AspectRatio { AUTO = "auto", FOUR_TO_THREE = "fourToThree", SIXTEEN_TO_NINE = "sixteenToNine" } interface DeviceCamera { position: CameraPosition$1; label: string; deviceId: string; currentResolution?: VideoFrameResolution; } /** * A helper object to interact with cameras. */ declare namespace CameraAccess { /** * Overrides for main camera for a given camera position on a desktop/laptop device, set when accessing an initial camera. */ const mainCameraForPositionOverridesOnDesktop: Map; /** * * To be accessed directly only for tests. * * The mapping from deviceIds to camera objects. */ const deviceIdToCameraObjects: Map; /** * * To be accessed directly only for tests. * * The list of inaccessible deviceIds. */ const inaccessibleDeviceIds: Set; type DeviceCameraChangeListener = (videoDevices: DeviceCamera[]) => void; function addVideoDevicesListener(listener: DeviceCameraChangeListener): void; function setMainCameraForPositionOverridesOnDesktop(cameraPosition: CameraPosition$1, deviceCamera: DeviceCamera): void; /** * used mainly for testing */ function clearMainCameraForPositionOverridesOnDesktop(): void; /** * * @param label The camera label. * @returns Whether the label identifies the camera being the iOS front (main) camera one. */ function isIOSFrontCameraLabel(label: string): boolean; /** * * @param label The camera label. * @returns Whether the label identifies the camera being the iOS back (main) camera one. */ function isIOSBackCameraLabel(label: string): boolean; /** * * @param label The camera label. * @returns Whether the label identifies the camera being the iOS Back Dual camera one. */ function isIOSBackDualWideCameraLabel(label: string): boolean; /** * * @param label The camera label. * @returns Whether the label identifies the camera being the iOS UltraWide back camera one. */ function isIOSUltraWideBackCameraLabel(label: string): boolean; /** * * Get the main camera for the given camera position. * * @param cameras The array of available [[DeviceCamera]] objects. * @param cameraPosition The wanted camera position. * @returns The main camera matching the wanted camera position. */ function getMainCameraForPosition(cameras: DeviceCamera[], cameraPosition: CameraPosition$1): DeviceCamera | undefined; /** * * Sort the given cameras in order of priority of access based on the given camera position. * * @param cameras The array of available [[DeviceCamera]] objects. * @param cameraPosition The preferred camera position. * @returns The sorted cameras. */ function sortCamerasForCameraPosition(cameras: DeviceCameraLike[], cameraPosition: CameraPosition$1): DeviceCameraLike[]; /** * * Adjusts the camera's information based on the given currently active video stream. * * @param mediaStream The currently active `MediaStream` object. * @param camera The currently active [[Camera]] object associated with the video stream. */ function adjustCameraFromMediaStream(mediaStream: MediaStream, camera: DeviceCamera): void; /** * Get a list of cameras (if any) available on the device, a camera access permission is requested to the user * the first time this method is called if needed. * * If the user denies the necessary camera access permission, a list of cameras with the correct amount of devices is * returned in any case, but the cameras will have no available (empty) label and deviceId and can thus not be * accessed. * * If the browser is incompatible the returned promise is rejected with a `UnsupportedBrowserError` error. * * When refreshing available devices, if updated deviceId information is detected, cameras' deviceId are updated * accordingly. This could happen after a camera access and stop in some situations. * * @param refreshDevices Force a call to refresh available video devices even when information is already available. * @param cameraAlreadyAccessed Hint that a camera has already been accessed before, avoiding a possible initial * camera access permission request on the first call, in cases this cannot be already reliably detected. * @returns A promise resolving to the array of available [[Camera]] objects (could be empty). */ function getCameras(refreshDevices?: boolean, cameraAlreadyAccessed?: boolean): Promise; /** * * Get the current camera access permission state. * * When available, the browser Permissions API is used, which never triggers a permission prompt. On browsers that * do not support querying the "camera" permission (e.g. Safari 14, Firefox) the state is derived, in order, from: * the enumerated cameras (a non-empty deviceId is only exposed once access has been granted); then the outcome of * the device-access probe performed by [[getCameras]] (which reports a denial). When neither is conclusive (e.g. no * cameras present and no access attempted) `PermissionState.Prompt` is returned. * * @param accessibleCameras The cameras returned by [[getCameras]], used for the fallback inference. When not * provided, [[getCameras]] is called to retrieve them (which also updates the probed permission state). * @returns A promise resolving to the current camera [[PermissionState]]. */ function getCameraPermissionState(accessibleCameras?: DeviceCamera[]): Promise; /** * * Get the *getUserMedia* *video* parameters to be used given a resolution fallback level and the browser used. * * @param cameraResolutionConstraint The resolution constraint. * @param preferredAspectRatio The preferred aspect ratio, if any. * @param maxFrameRate The frame rate cap to request, sent as a hard `max` constraint. When omitted or not a * positive number, {@link DEFAULT_MAX_FRAME_RATE} is requested as an `ideal` (best-effort) value instead of a * hard cap: browsers that model a camera mode's frame rate as the single top value of its fps range (Firefox, * https://bugzilla.mozilla.org/show_bug.cgi?id=1573356) reject every mode above a hard `max` even though the * mode could deliver fewer fps, silently collapsing the negotiated resolution (SDC-33445). An `ideal` value * can never overconstrain. Not applied when `cameraResolutionConstraint` is `NONE`, so that an * `OverconstrainedError` caused by the frame rate cap itself can still be recovered from via the * resolution-downgrade retry ladder. * @param demoteFrameRateCapToIdeal When true, an explicit `maxFrameRate` is requested as `ideal` only instead of * a hard `max`. Used by `CameraManager` to retry the same resolution tier after the browser reported the frame * rate cap itself as overconstraining. * @returns The resulting *getUserMedia* *video* parameters. */ function getUserMediaVideoParameters(cameraResolutionConstraint: CameraResolutionConstraint, preferredAspectRatio?: AspectRatio, maxFrameRate?: number, demoteFrameRateCapToIdeal?: boolean): MediaTrackConstraints; /** * * Mark a camera to be inaccessible and thus excluded from the camera list returned by [[getCameras]]. * * @param camera The camera to mark to be inaccessible. */ function markCameraAsInaccessible(camera: DeviceCamera): void; /** * * Try to access a given camera for video input at the given resolution level. * * If a camera is inaccessible because of errors, then it's added to the inaccessible device list. If the specific * error is of type `OverconstrainedError` or `NotReadableError` however, this procedure is done later on via a * separate external logic; also, in case of an error of type `NotAllowedError` (permission denied) this procedure is * not executed, in order to possibly recover if and when the user allows the camera to be accessed again. * This is done to allow checking if the camera can still be accessed via an updated deviceId when deviceId * information changes, or if it should then be confirmed to be considered inaccessible. * * Depending on parameters, device features and user permissions for camera access, any of the following errors * could be the rejected result of the returned promise: * - `AbortError` * - `NotAllowedError` * - `NotFoundError` * - `NotReadableError` * - `SecurityError` * - `OverconstrainedError` * * @param camera The camera to try to access for video input. * @param cameraResolutionConstraint The resolution constraint. * @param preferredAspectRatio The preferred aspect ratio, if any. * @param maxFrameRate The frame rate cap to request; see {@link getUserMediaVideoParameters}. * @param demoteFrameRateCapToIdeal Request an explicit `maxFrameRate` as `ideal` only; see * {@link getUserMediaVideoParameters}. * @returns A promise resolving to the `MediaStream` object coming from the accessed camera. */ function accessCameraStream(camera: DeviceCamera, cameraResolutionConstraint: CameraResolutionConstraint, preferredAspectRatio?: AspectRatio, maxFrameRate?: number, demoteFrameRateCapToIdeal?: boolean): Promise; } //#endregion //#region src/main/CameraRelated.d.ts /** * Private camera settings properties that are not part of the public API. * These properties are accessed via getProperty/setProperty methods. */ interface PrivateCameraExtraProperties { grayScaleFrameReader?: boolean; exposureTargetBias?: number; exposureDuration?: number; minFrameRate?: number; /** Unset (or non-positive) defaults to 30 fps for the initial camera request; has no default for the live-stream `applyConstraints` path. */ maxFrameRate?: number; manualLensPosition?: number; preferredAspectRatio?: AspectRatio; repeatedTriggerInterval?: number; } declare enum FrameSourceState { On = "on", Off = "off", Standby = "standby", Starting = "starting", Stopping = "stopping", BootingUp = "bootingUp", WakingUp = "wakingUp", GoingToSleep = "goingToSleep", ShuttingDown = "shuttingDown" } declare enum TorchState { On = "on", Off = "off" } declare enum CameraPosition { WorldFacing = "worldFacing", UserFacing = "userFacing" } /** * The camera access permission state. Mirrors the browser's * {@link https://developer.mozilla.org/docs/Web/API/PermissionStatus/state | PermissionStatus.state}. * @since 8.6 */ declare enum PermissionState { /** Camera access has been granted by the user. */ Granted = "granted", /** Camera access has been denied by the user. */ Denied = "denied", /** Camera access has not been decided yet; requesting it will prompt the user. */ Prompt = "prompt" } declare enum VideoResolution { /** * @deprecated 8.0.0 Auto is deprecated. Please use the capture mode's recommendedCameraSettings for the best results. */ Auto = "auto", HD = "hd", FullHD = "fullHd", UHD4K = "uhd4k" } declare enum FocusGestureStrategy { None = "none", Manual = "manual", ManualUntilCapture = "manualUntilCapture", AutoOnLocation = "autoOnLocation" } interface FrameSourceListener { didChangeState?: (frameSource: FrameSource, newState: FrameSourceState) => void; } interface FrameSourceJSON { type: string; } interface FrameSource extends Serializable { readonly desiredState: FrameSourceState; getCurrentState: () => FrameSourceState; switchToDesiredState: (desiredState: FrameSourceState) => Promise; addListener: (listener: FrameSourceListener) => void; removeListener: (listener: FrameSourceListener) => void; } interface CameraSettingsJSONBase extends Partial { preferredResolution: string; zoomFactor: number; zoomGestureZoomFactor: number; zoomLevels: number[]; api?: number; } interface CameraSettingsFromJSON extends CameraSettingsJSONBase { focusGestureStrategy: string; } interface CameraSettingsJSON extends CameraSettingsJSONBase { focus: { focusGestureStrategy: string; [key: string]: any; }; [key: string]: any; } declare function isCameraFrameSource(frameSource?: FrameSource | null): frameSource is Camera; declare class CameraSettings implements Serializable { preferredResolution: VideoResolution; zoomFactor: number; /** * @deprecated 8.4.0 Use {@link CameraSettings.zoomLevels} instead. */ zoomGestureZoomFactor: number; zoomLevels: number[]; private focus; get focusGestureStrategy(): FocusGestureStrategy; set focusGestureStrategy(newStrategy: FocusGestureStrategy); /** * Copies private enumerable properties from a source object to this instance. * @param source - The source object to copy properties from */ private copyPrivatePropertiesFrom; private static fromJSON; constructor(); constructor(settings: CameraSettings); setProperty(name: string, value: any): void; getProperty(name: string): any; /** * The resulting JSON must also contain properties set on the object itself ("hidden" properties) */ toJSONObject(): CameraSettingsJSON & Record; } //#endregion //#region src/main/ZoomListener.d.ts interface ZoomListener { onZoomLevelChanged(camera: Camera, oldLevel: number, newLevel: number): void; } //#endregion //#region src/main/Camera.d.ts interface CameraJSON extends FrameSourceJSON { type: "camera"; position: CameraPosition; settings: CameraSettingsJSON | Record; desiredState: FrameSourceState; desiredTorchState: TorchState; } interface VideoFrameResolution { readonly width: number; readonly height: number; } /** * The result of {@link Camera.getAllWithPermissionState}: the available cameras together with the current camera * {@link PermissionState}. * @since 8.6 */ interface CamerasWithPermissionState { readonly cameras: Camera[]; readonly permissionState: PermissionState; } declare class Camera implements FrameSource, Serializable { private _label; private _deviceId; position: CameraPosition; private _currentResolution?; /** This flag is set to true when the present camera could not be mapped to a real device camera. This happens when * device cameras were discovered but the reconciliation with existing cameras lead to unmapped instances. * See CameraPool.ts for more details about reconciliation. */ private _notFoundOnDevice; /** * Internal flag to mark this instance as being the one for the best guess. * This allows us to have Camera.pickBestGuess() === Camera.pickBestGuess() */ private _isBestGuess; private readonly cameraManager; private readonly type; private readonly webGLContextLostListener; private _currentState; private _settings; private _desiredTorchState; private _desiredState; private readonly listeners; private readonly zoomListeners; private _context; private _desiredMirrorImageEnabled?; private _lastCaptureRequestAnimationFrame?; private _lastCanvasVideoPreviewAnimationFrame?; private _isAndroidWebView?; [INTERNAL_ACCESS]: { markAsUnmappedToDeviceCameras: () => void; resetUnmappedState: () => void; setDeviceId: (deviceId: string) => void; setLabel: (label: string) => void; markAsBestGuess: () => void; }; private _captureAndSendBound; private readonly stateTransitionStrategyMap; private currentTransitionStrategyPromise?; private constructor(); /** * Return a new camera with no constraints. We autoselect the world facing position by default. The CameraManager * will figure out which of the device cameras will be the best match. */ static pickBestGuess(): Camera; /** * Return a new camera with no constraints except for the position. The CameraManager will figure out * which of the device cameras will be the best match. */ static pickBestGuessForPosition(position: CameraPosition): Camera; /** * Return a camera instance with the deviceId set on it. If the camera was already created in the past, it will be * returned instead of being created. */ static forDeviceId(deviceId: string): Camera; /** * Get all available cameras from the device. This may trigger a permission prompt to the user to access cameras. */ static getAll(refreshDevices?: boolean, cameraAlreadyAccessed?: boolean): Promise; /** * Get all available cameras from the device together with the current camera {@link PermissionState}. * * This behaves like {@link Camera.getAll} but additionally reports the camera permission state. It lets you tell * apart an empty camera list caused by the absence of cameras on the device ({@link PermissionState.Granted} with * no cameras) from one caused by the user denying camera access ({@link PermissionState.Denied}). * * The permission state is retrieved through the browser Permissions API when available, without triggering a * permission prompt. On browsers that do not support querying the camera permission (e.g. Safari 14, Firefox) the * state is derived from the enumerated cameras and from the camera-access attempt this method already performs (the * same attempt as {@link Camera.getAll}), so a denial is still reported. It may be reported as * {@link PermissionState.Prompt} only when the state cannot be determined, e.g. no cameras are present and access * has not been attempted. * * @param refreshDevices Force a call to refresh available video devices even when information is already available, * defaults to false. * @param cameraAlreadyAccessed Hint that a camera has already been accessed before, avoiding a possible initial * camera access permission request on the first call, in cases this cannot be already reliably detected, defaults * to false. * @returns The available cameras and the current camera permission state. * @since 8.6 */ static getAllWithPermissionState(refreshDevices?: boolean, cameraAlreadyAccessed?: boolean): Promise; private static getOrCreate; /** * Create a Camera instance from a low-level DeviceCamera instance. */ private static fromDeviceCamera; get deviceId(): string; get label(): string; get desiredState(): FrameSourceState; get settings(): CameraSettings; get currentResolution(): VideoFrameResolution | null; private setDeviceId; private setLabel; private get context(); private set context(value); private get currentState(); switchToDesiredState(state: FrameSourceState): Promise; getDesiredTorchState(): TorchState; setDesiredTorchState(desiredTorchState: TorchState): Promise; isTorchAvailable(): Promise; addListener(listener: FrameSourceListener | null): void; removeListener(listener: FrameSourceListener | null): void; addZoomListener(listener: ZoomListener): void; removeZoomListener(listener: ZoomListener): void; isZoomAvailable(): boolean; applySettings(settings: CameraSettings): Promise; toJSONObject(): CameraJSON; getMirrorImageEnabled(): boolean; setMirrorImageEnabled(enabled: boolean): Promise; getCurrentState(): FrameSourceState; setClipArea(area?: Rect): Promise; private setCurrentState; /** * Starts camera according to the given position. If a deviceId is set, pre-select the corresponding camera. * The function returns as soon as the camera has started successfully and is active. The label and * position properties reflect then the values found in the accessed stream. */ private setupCamera; private markAsUnmappedToDeviceCameras; private resetUnmappedState; private markAsBestGuess; private notifyContext; private notifyListeners; private updateCanvasVideoImage; private captureAndSend; /** * Capture images from the video stream and send them to the context. If no context is set, the function will * stop itself until called again. While no enabled mode is present in the context, the function will schedule itself * again indefinitely without doing anything else. */ private startSendingCapturesToWorker; private stopSendingCapturesToWorker; private transitionFromStateOffToOn; private transitionFromStateOffToStandby; private transitionFromStateOnToOff; private transitionFromStateOnToStandby; private transitionFromStateStandbyToOff; private transitionFromStateStandbyToOn; private isAndroidWebView; private notifyZoomListeners; private notifyListenersOfZoomLevelChange; } //#endregion export { CameraPosition$1 as C, CameraAccess as S, DeviceCamera as T, PrivateCameraExtraProperties as _, ZoomListener as a, isCameraFrameSource as b, CameraSettingsFromJSON as c, FocusGestureStrategy as d, FrameSource as f, PermissionState as g, FrameSourceState as h, VideoFrameResolution as i, CameraSettingsJSON as l, FrameSourceListener as m, CameraJSON as n, CameraPosition as o, FrameSourceJSON as p, CamerasWithPermissionState as r, CameraSettings as s, Camera as t, CameraSettingsJSONBase as u, TorchState as v, CameraResolutionConstraint as w, AspectRatio as x, VideoResolution as y };