import { createWebcamController, type WebcamSnapshot } from '@uppy/components' import type { ShallowRef } from 'vue' import { injectUppyContext } from './headless/context-provider.js' import { useExternalStore } from './useSyncExternalStore.js' type WebcamProps = { onSubmit?: () => void } export function useWebcam(props?: WebcamProps): ShallowRef { const ctx = injectUppyContext() const controller = createWebcamController(ctx.uppy, props?.onSubmit) const store = useExternalStore( controller.getSnapshot, controller.subscribe, ) return store }