@lavitre/apps 1.51.0 → 1.52.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalPreview.js","sourceRoot":"","sources":["../../Frame/LocalPreview.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EAGpB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AAgDrE,MAAM,kBAAkB,GAAG,KAAM,CAAA;AACjC,MAAM,oBAAoB,GAAG,IAAK,CAAA;AAClC,MAAM,yBAAyB,GAAG,KAAM,CAAA;AACxC,MAAM,kBAAkB,GAAG,IAAK,CAAA;AAChC,MAAM,uBAAuB,GAAG,IAAK,CAAA;AACrC,gHAAgH;AAChH,MAAM,mBAAmB,GAAG,CAAC,CAAA;AAE7B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,YAAY;IAsBvB,YACmB,KAAY,EAC7B,UAA+B,EAAE;QADjC;;;;mBAAiB,KAAK;WAAO;QAtBd;;;;;WAG8B;QACvC;;;;mBAAoC,IAAI;WAAA;QACxC;;;;mBAAgC,IAAI;WAAA;QACpC;;;;;WAA6B;QAC7B;;;;;WAA4B;QAC5B;;;;mBAAyC,IAAI;WAAA;QAC7C;;;;mBAAW,CAAC;WAAA;QACZ;;;;mBAAgB,CAAC;WAAA;QACjB;;;;;WAAwB;QACxB;;;;mBAAY,KAAK;WAAA;QACjB;;;;mBAAiB,KAAK;WAAA;QACtB;;;;mBAAgB,KAAK;WAAA;QACrB;;;;mBAAW,KAAK;WAAA;QACP;;;;mBAAY,IAAI,GAAG,EAAsC;WAAA;QACzD;;;;mBAAW,IAAI,GAAG,EAAc;WAAA;QACzC;;;;mBAAmC,IAAI;WAAA;QACvC;;;;mBAAwC,IAAI;WAAA;QAMlD,I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ice, DeviceScaling } from '../Common/index.js'\nimport {\n computePreviewLayout,\n type PreviewLayout,\n type PreviewMatrix,\n previewAspectRatio,\n previewMatrix,\n previewOutputSize,\n resolvePreviewScaling,\n} from '../Common/PreviewScaling.js'\nimport type { Frame } from './Frame.js'\nimport { SCALED_STREAM_WORKER_SOURCE } from './ScaledStreamWorker.js'\n\nexport type LocalPreviewOptions = {\n /** Longest side requested from the camera and of `getScaledStream`. Default 1920. */\n maxSize?: number\n /**\n * First delay before reopening the camera after a failure; it doubles on\n * each consecutive failure, up to 30 s. Also the period of the check for\n * an ended camera. Default 1000 ms.\n */\n retryDelayMs?: number\n /**\n * Resize the frame to the preview's orientation (portrait or landscape)\n * each time the camera opens, keeping its long and short sides. Default\n * false.\n */\n fitFrame?: boolean\n /**\n * Lists the cameras, with ids `getUserMedia` accepts in this frame.\n * Defaults to the main connector's `requestEnumerateDevices`, which maps\n * the Vitre's device ids to this frame's.\n */\n enumerateDevices?: () => Promise<ConnectedMediaDevice[]>\n}\n\n/** Why the camera is not open: a `DOMException` name from `getUserMedia` (`NotAllowedError`, `NotFoundError`…) or `TimeoutError`. */\nexport type LocalPreviewError = { name: string; message: string }\n\nexport type LocalPreviewState = {\n /** The raw camera stream, null until the camera is open. */\n stream: MediaStream | null\n /** Resolved scaling: zoom/offsets seen by the fullscreen participant. */\n scaling: DeviceScaling\n layout: PreviewLayout\n /** Last failure to open the camera, null once it is open. Retries go on meanwhile. */\n error: LocalPreviewError | null\n}\n\nexport type AttachOptions = {\n /** `contain` letterboxes the preview, `cover` fills the container. Default `contain`. */\n fit?: 'contain' | 'cover'\n}\n\nexport type ScaledStreamOptions = {\n /** Frame rate of the canvas fallback (browsers without insertable streams). Default 30. */\n frameRate?: number\n}\n\nconst MAX_RETRY_DELAY_MS = 30_000\nconst ENUMERATE_TIMEOUT_MS = 5_000\nconst GET_USER_MEDIA_TIMEOUT_MS = 15_000\nconst CAPTURE_TIMEOUT_MS = 5_000\nconst WORKER_FRAME_TIMEOUT_MS = 1_000\n/** Consecutive unanswered frames before giving up on the worker: one late answer can be a main-thread pause. */\nconst WORKER_MAX_TIMEOUTS = 3\n\n/**\n * Local camera preview cropped, zoomed and oriented the way the participants\n * of the space see it — the behavior of the core app's \"local preview\".\n *\n * ```ts\n * const preview = new LocalPreview(frame)\n * preview.attach(document.getElementById('view')!) // CSS rendering, no per-frame cost\n * // or: video.srcObject = preview.getScaledStream() // already-cropped MediaStream\n * ```\n *\n * It opens the camera the Vitre uses as its main stream (retrying with a\n * growing delay, reopening it when it ends or when the main camera changes)\n * and follows the host's scaling updates through\n * `Frame.addDeviceStateListener`, so the app's own `on…` callbacks stay\n * untouched.\n */\nexport class LocalPreview {\n private readonly options: Required<\n Omit<LocalPreviewOptions, 'enumerateDevices'>\n > &\n Pick<LocalPreviewOptions, 'enumerateDevices'>\n private currentStream: MediaStream | null = null\n private cameraDeviceId: string | null = null\n private currentScaling: DeviceScaling\n private currentLayout: PreviewLayout\n private currentError: LocalPreviewError | null = null\n private failures = 0\n private nextAttemptAt = 0\n private seenMediaDevices: string\n private acquiring = false\n private checkingCamera = false\n private recheckCamera = false\n private disposed = false\n private readonly listeners = new Set<(state: LocalPreviewState) => void>()\n private readonly cleanups = new Set<() => void>()\n private scaledStream: MediaStream | null = null\n private stopScaledStream: (() => void) | null = null\n\n constructor(\n private readonly frame: Frame,\n options: LocalPreviewOptions = {},\n ) {\n this.options = {\n maxSize: options.maxSize ?? 1920,\n retryDelayMs: options.retryDelayMs ?? 1000,\n fitFrame: options.fitFrame ?? false,\n enumerateDevices: options.enumerateDevices,\n }\n this.currentScaling = resolvePreviewScaling(frame.hostInformation)\n this.currentLayout = computePreviewLayout(this.currentScaling)\n this.seenMediaDevices = this.hostMediaDevices()\n\n this.cleanups.add(\n frame.addDeviceStateListener(() => this.onDeviceStateChanged()),\n )\n const watchdog = setInterval(() => this.tick(), this.options.retryDelayMs)\n this.cleanups.add(() => clearInterval(watchdog))\n void this.tick()\n }\n\n get stream() {\n return this.currentStream\n }\n\n get scaling() {\n return this.currentScaling\n }\n\n get layout() {\n return this.currentLayout\n }\n\n get error() {\n return this.currentError\n }\n\n get state(): LocalPreviewState {\n return {\n stream: this.currentStream,\n scaling: this.currentScaling,\n layout: this.currentLayout,\n error: this.currentError,\n }\n }\n\n /** Called with the new state whenever the stream, the scaling or the error changes. Returns the unsubscribe function. */\n addListener(listener: (state: LocalPreviewState) => void): () => void {\n this.listeners.add(listener)\n return () => this.listeners.delete(listener)\n }\n\n /**\n * Renders the preview inside `container` with CSS transforms on a\n * `<video>`: no per-frame work. Returns the detach function.\n */\n attach(container: HTMLElement, options: AttachOptions = {}): () => void {\n const fit = options.fit ?? 'contain'\n const root = document.createElement('div')\n root.className = 'lavitre-local-preview'\n root.style.cssText =\n 'position:relative;width:100%;height:100%;overflow:hidden;background:black'\n const box = document.createElement('div')\n box.style.cssText = 'position:absolute;overflow:hidden'\n const video = createVideoElement()\n video.style.cssText = 'position:absolute;left:0;top:0;transform-origin:0 0'\n box.appendChild(video)\n root.appendChild(box)\n container.appendChild(root)\n\n const update = () => {\n if (video.srcObject !== this.currentStream) {\n video.srcObject = this.currentStream\n }\n const w = video.videoWidth\n const h = video.videoHeight\n box.style.visibility = this.currentStream && w && h ? 'visible' : 'hidden'\n if (!w || !h) return\n const ratio = previewAspectRatio(this.currentLayout, w, h)\n const cw = root.clientWidth\n const ch = root.clientHeight\n const boxWidth =\n fit === 'contain' ? Math.min(cw, ch * ratio) : Math.max(cw, ch * ratio)\n const boxHeight = boxWidth / ratio\n box.style.left = `${(cw - boxWidth) / 2}px`\n box.style.top = `${(ch - boxHeight) / 2}px`\n box.style.width = `${boxWidth}px`\n box.style.height = `${boxHeight}px`\n video.style.width = `${w}px`\n video.style.height = `${h}px`\n video.style.transform = `matrix(${previewMatrix(this.currentLayout, w, h, boxWidth, boxHeight).join(',')})`\n }\n\n const resizeObserver = new ResizeObserver(update)\n resizeObserver.observe(root)\n video.addEventListener('loadedmetadata', update)\n video.addEventListener('resize', update)\n const unsubscribe = this.addListener(update)\n update()\n\n const detach = () => {\n this.cleanups.delete(detach)\n unsubscribe()\n resizeObserver.disconnect()\n video.srcObject = null\n root.remove()\n }\n this.cleanups.add(detach)\n return detach\n }\n\n /**\n * A `MediaStream` whose frames are already cropped, zoomed, rotated and\n * mirrored: plug it into a `<video>`, WebGL, a recorder… On Chromium each\n * frame goes through insertable streams and is redrawn in a worker — on\n * the main thread while the worker starts, or for good if it cannot run\n * (CSP without `blob:` in `worker-src`). Elsewhere a canvas redraws a\n * hidden `<video>` (`options.frameRate`). It survives camera changes. The\n * same stream is returned until its track ends (stopped by the app, or\n * `dispose()`); the next call then builds a new one.\n */\n getScaledStream(options: ScaledStreamOptions = {}): MediaStream {\n const live = this.scaledStream\n ?.getVideoTracks()\n .some((t) => t.readyState === 'live')\n if (this.scaledStream && live) return this.scaledStream\n this.stopScaledStream?.()\n const pipeline =\n this.startFramePipeline() ??\n this.startCanvasPipeline(options.frameRate ?? 30)\n const stop = () => {\n this.cleanups.delete(stop)\n pipeline.stop()\n if (this.scaledStream === pipeline.stream) {\n this.scaledStream = null\n this.stopScaledStream = null\n }\n }\n this.scaledStream = pipeline.stream\n this.stopScaledStream = stop\n this.cleanups.add(stop)\n return pipeline.stream\n }\n\n /**\n * Still image of the preview, as the participants see it. Rejects when the\n * camera is not open or yields no image within 5 s.\n */\n async capture(type = 'image/jpeg', quality?: number): Promise<Blob> {\n const stream = this.currentStream\n if (!stream) throw new Error('camera not open')\n const video = createVideoElement()\n video.srcObject = stream\n try {\n await waitForVideoData(video, CAPTURE_TIMEOUT_MS)\n const sw = video.videoWidth\n const sh = video.videoHeight\n const { width, height } = previewOutputSize(\n this.currentLayout,\n sw,\n sh,\n this.options.maxSize,\n )\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n paintPreview(\n canvas.getContext('2d') as CanvasRenderingContext2D,\n width,\n height,\n previewMatrix(this.currentLayout, sw, sh, width, height),\n video,\n sw,\n sh,\n )\n return await new Promise<Blob>((resolve, reject) =>\n canvas.toBlob(\n (blob) => (blob ? resolve(blob) : reject(new Error('toBlob failed'))),\n type,\n quality,\n ),\n )\n } finally {\n video.srcObject = null\n }\n }\n\n /** Stops the camera, the scaled stream and every attached rendering. */\n dispose() {\n if (this.disposed) return\n this.disposed = true\n for (const cleanup of [...this.cleanups].reverse()) cleanup()\n this.cleanups.clear()\n this.setStream(null)\n this.listeners.clear()\n }\n\n private notify() {\n const state = this.state\n for (const listener of this.listeners) {\n try {\n listener(state)\n } catch (error) {\n console.error('[LocalPreview] listener failed', error)\n }\n }\n }\n\n private setStream(stream: MediaStream | null) {\n if (stream === this.currentStream) return\n for (const t of this.currentStream?.getTracks() ?? []) t.stop()\n this.currentStream = stream\n if (!stream) this.cameraDeviceId = null\n this.notify()\n }\n\n private setError(error: LocalPreviewError | null) {\n const previous = this.currentError\n if (\n previous?.name === error?.name &&\n previous?.message === error?.message\n ) {\n return\n }\n if (error && error.name !== previous?.name) {\n console.warn(\n `[LocalPreview] camera not open: ${error.name}: ${error.message}`,\n )\n }\n this.currentError = error\n this.notify()\n }\n\n /**\n * The host's cameras as a comparable key: `vitreSettingsUpdated` replaces\n * the whole list on any settings change, so its reference says nothing.\n */\n private hostMediaDevices(): string {\n const devices =\n this.frame.hostInformation.vitreSettings?.availableMediaDevices ?? []\n return JSON.stringify(\n devices\n .filter((d) => d.kind === 'videoinput')\n .map((d) => [d.deviceId, d.inUseBy]),\n )\n }\n\n private onDeviceStateChanged() {\n const scaling = resolvePreviewScaling(this.frame.hostInformation)\n if (JSON.stringify(scaling) !== JSON.stringify(this.currentScaling)) {\n this.currentScaling = scaling\n this.currentLayout = computePreviewLayout(scaling)\n this.notify()\n }\n\n // The list of cameras changed: the main one may have been switched, or\n // the missing one plugged in — retry now rather than after the backoff.\n const mediaDevices = this.hostMediaDevices()\n if (mediaDevices !== this.seenMediaDevices) {\n this.seenMediaDevices = mediaDevices\n this.failures = 0\n this.nextAttemptAt = 0\n if (this.currentStream) void this.checkMainCamera()\n else void this.tick()\n }\n }\n\n private enumerate(): Promise<ConnectedMediaDevice[]> {\n const enumerate =\n this.options.enumerateDevices ??\n (() => {\n const connector = this.frame.getMainConnector()\n if (!connector) {\n throw namedError('NotReadyError', 'main connector not available')\n }\n return connector.requestEnumerateDevices()\n })\n return withTimeout(\n Promise.resolve().then(enumerate),\n ENUMERATE_TIMEOUT_MS,\n 'listing the cameras',\n )\n }\n\n /** Reopens the camera when the main one is no longer the one open. */\n private async checkMainCamera() {\n if (this.checkingCamera) {\n this.recheckCamera = true\n return\n }\n this.checkingCamera = true\n try {\n const camera = findMainCamera(await this.enumerate())\n if (\n this.currentStream &&\n camera &&\n camera.deviceId !== this.cameraDeviceId\n ) {\n this.setStream(null)\n void this.tick()\n }\n } catch (_error) {\n // Transient; the next device change checks again.\n } finally {\n this.checkingCamera = false\n if (this.recheckCamera) {\n this.recheckCamera = false\n void this.checkMainCamera()\n }\n }\n }\n\n private async tick() {\n if (this.disposed) return\n const track = this.currentStream?.getVideoTracks()[0]\n if (this.currentStream && (!track || track.readyState === 'ended')) {\n this.setStream(null)\n }\n if (this.currentStream || this.acquiring) return\n if (Date.now() < this.nextAttemptAt) return\n this.acquiring = true\n try {\n await this.openCamera()\n this.failures = 0\n this.nextAttemptAt = 0\n this.setError(null)\n } catch (error) {\n this.failures += 1\n this.nextAttemptAt =\n Date.now() +\n Math.min(\n this.options.retryDelayMs * 2 ** (this.failures - 1),\n MAX_RETRY_DELAY_MS,\n )\n if (!this.disposed) this.setError(toPreviewError(error))\n } finally {\n this.acquiring = false\n }\n }\n\n private async openCamera() {\n const devicesBefore = this.hostMediaDevices()\n const camera = findMainCamera(await this.enumerate())\n if (!camera) {\n throw namedError('NotFoundError', 'no camera used as main stream')\n }\n\n const sideways =\n camera.orientation === 'left' || camera.orientation === 'right'\n const video: MediaTrackConstraints = {\n deviceId: { exact: camera.deviceId },\n }\n if (camera.orientationBySystem === true && sideways) {\n video.height = { max: this.options.maxSize }\n } else {\n video.width = { max: this.options.maxSize }\n }\n const stream = await withTimeout(\n navigator.mediaDevices.getUserMedia({ video }),\n GET_USER_MEDIA_TIMEOUT_MS,\n 'opening the camera',\n (late) => {\n for (const t of late.getTracks()) t.stop()\n },\n )\n if (this.disposed) {\n for (const t of stream.getTracks()) t.stop()\n return\n }\n const track = stream.getVideoTracks()[0]\n track?.addEventListener('ended', () => {\n if (this.currentStream === stream) this.setStream(null)\n })\n this.cameraDeviceId = camera.deviceId\n this.setStream(stream)\n if (this.options.fitFrame && track) this.fitFrame(track)\n // The main camera may have changed while it was opening.\n if (this.hostMediaDevices() !== devicesBefore) void this.checkMainCamera()\n }\n\n private fitFrame(track: MediaStreamTrack) {\n const { width, height } = track.getSettings()\n if (!width || !height) return\n const portrait = previewAspectRatio(this.currentLayout, width, height) < 1\n const { width: fw, height: fh } = this.frame.position\n const short = Math.min(fw, fh)\n const long = Math.max(fw, fh)\n this.frame.setPosition(\n portrait\n ? { width: `${short}px`, height: `${long}px` }\n : { width: `${long}px`, height: `${short}px` },\n )\n }\n\n /** Chromium: camera frames → transform (worker, else main thread) → generator track. */\n private startFramePipeline(): ScaledPipeline | null {\n if (\n typeof MediaStreamTrackProcessor === 'undefined' ||\n typeof MediaStreamTrackGenerator === 'undefined' ||\n typeof VideoFrame === 'undefined' ||\n typeof OffscreenCanvas === 'undefined'\n ) {\n return null\n }\n const generator = new MediaStreamTrackGenerator({ kind: 'video' })\n const writer = generator.writable.getWriter()\n const transformer = new FrameTransformer()\n let source: MediaStreamTrack | null = null\n let reader: ReadableStreamDefaultReader<VideoFrame> | null = null\n let stopped = false\n\n const pump = async (current: ReadableStreamDefaultReader<VideoFrame>) => {\n for (;;) {\n let result: ReadableStreamReadResult<VideoFrame>\n try {\n result = await current.read()\n } catch (_error) {\n return\n }\n if (result.done) return\n const frame = result.value\n if (current !== reader) {\n frame.close()\n return\n }\n const sw = frame.displayWidth\n const sh = frame.displayHeight\n const { width, height } = previewOutputSize(\n this.currentLayout,\n sw,\n sh,\n this.options.maxSize,\n )\n const matrix = previewMatrix(this.currentLayout, sw, sh, width, height)\n let out: VideoFrame | null\n try {\n out = await transformer.transform(frame, width, height, matrix)\n } catch (error) {\n // Drop this frame, keep the stream going.\n frame.close()\n console.warn('[LocalPreview] frame dropped', error)\n continue\n }\n if (!out) continue\n if (current !== reader) {\n out.close()\n return\n }\n try {\n await writer.write(out)\n } catch (_error) {\n // The app stopped the track.\n out.close()\n stop()\n return\n }\n }\n }\n\n const sync = () => {\n const track = this.currentStream?.getVideoTracks()[0] ?? null\n if (track === source) return\n source = track\n reader?.cancel().catch(() => {})\n reader = track\n ? (new MediaStreamTrackProcessor({\n track,\n }).readable.getReader() as ReadableStreamDefaultReader<VideoFrame>)\n : null\n if (reader) void pump(reader)\n }\n const unsubscribe = this.addListener(sync)\n const stop = () => {\n if (stopped) return\n stopped = true\n unsubscribe()\n reader?.cancel().catch(() => {})\n reader = null\n transformer.dispose()\n generator.stop()\n }\n sync()\n return { stream: new MediaStream([generator]), stop }\n }\n\n /** Fallback: hidden `<video>` drawn into a canvas on every new camera frame. */\n private startCanvasPipeline(frameRate: number): ScaledPipeline {\n const video = createVideoElement()\n const canvas = document.createElement('canvas')\n const ctx = canvas.getContext('2d') as CanvasRenderingContext2D\n const stream = canvas.captureStream(frameRate)\n // One frame-callback chain per camera stream; a stale chain stops at its\n // next callback, and none runs while there is no camera.\n let chain = 0\n const draw = (id: number) => {\n if (id !== chain || !video.srcObject) return\n const sw = video.videoWidth\n const sh = video.videoHeight\n if (sw && sh) {\n const { width, height } = previewOutputSize(\n this.currentLayout,\n sw,\n sh,\n this.options.maxSize,\n )\n if (canvas.width !== width) canvas.width = width\n if (canvas.height !== height) canvas.height = height\n paintPreview(\n ctx,\n width,\n height,\n previewMatrix(this.currentLayout, sw, sh, width, height),\n video,\n sw,\n sh,\n )\n }\n if ('requestVideoFrameCallback' in video) {\n ;(video as any).requestVideoFrameCallback(() => draw(id))\n } else {\n setTimeout(() => draw(id), 1000 / frameRate)\n }\n }\n const sync = () => {\n if (video.srcObject === this.currentStream) return\n video.srcObject = this.currentStream\n draw(++chain)\n }\n const unsubscribe = this.addListener(sync)\n sync()\n return {\n stream,\n stop: () => {\n chain = -1\n unsubscribe()\n video.srcObject = null\n for (const t of stream.getTracks()) t.stop()\n },\n }\n }\n}\n\ntype ScaledPipeline = { stream: MediaStream; stop: () => void }\n\n/**\n * Redraws camera frames, in a worker when one can run. Until the worker says\n * it is ready, and for good once it fails (load error, CSP, three frames in a\n * row without an answer within a second), frames are drawn on the main\n * thread instead.\n */\nclass FrameTransformer {\n private worker: Worker | null = null\n private ready = false\n private nextId = 0\n private timeouts = 0\n private readonly pending = new Map<\n number,\n (frame: VideoFrame | null) => void\n >()\n private canvas: OffscreenCanvas | null = null\n private ctx: OffscreenCanvasRenderingContext2D | null = null\n\n constructor() {\n if (typeof Worker === 'undefined') return\n const url = URL.createObjectURL(\n new Blob([SCALED_STREAM_WORKER_SOURCE], { type: 'text/javascript' }),\n )\n try {\n const worker = new Worker(url)\n worker.onmessage = (event: MessageEvent) => {\n const msg = event.data\n if (msg?.type === 'ready') {\n this.ready = true\n return\n }\n const resolve = this.pending.get(msg?.id)\n if (!resolve) {\n msg?.frame?.close()\n return\n }\n this.pending.delete(msg.id)\n this.timeouts = 0\n resolve(msg.frame ?? null)\n if (msg.error) this.fail(msg.error)\n }\n worker.onerror = (event) => {\n event.preventDefault()\n this.fail(event.message || 'worker error')\n }\n worker.onmessageerror = () => this.fail('worker message error')\n this.worker = worker\n } catch (error) {\n console.warn(\n `[LocalPreview] scaled-stream worker unavailable, drawing on the main thread: ${error}`,\n )\n } finally {\n // The worker has fetched its script by the time it posts 'ready'; a\n // worker revoked too early fails with an error event and is replaced\n // by the main thread like any other failure.\n setTimeout(() => URL.revokeObjectURL(url), 10_000)\n }\n }\n\n /** Takes ownership of `frame`. Null when the frame was lost to a failing worker. */\n async transform(\n frame: VideoFrame,\n width: number,\n height: number,\n matrix: PreviewMatrix,\n ): Promise<VideoFrame | null> {\n const worker = this.worker\n if (worker && this.ready) {\n const id = this.nextId++\n return await new Promise<VideoFrame | null>((resolve) => {\n const timer = setTimeout(() => {\n if (this.pending.delete(id)) {\n resolve(null)\n this.timeouts += 1\n if (this.timeouts >= WORKER_MAX_TIMEOUTS) {\n this.fail('no answer from the worker')\n }\n }\n }, WORKER_FRAME_TIMEOUT_MS)\n this.pending.set(id, (out) => {\n clearTimeout(timer)\n resolve(out)\n })\n worker.postMessage({ id, frame, width, height, matrix }, [frame as any])\n })\n }\n try {\n if (\n !this.canvas ||\n this.canvas.width !== width ||\n this.canvas.height !== height\n ) {\n this.canvas = new OffscreenCanvas(width, height)\n this.ctx = this.canvas.getContext('2d')\n }\n paintPreview(\n this.ctx as OffscreenCanvasRenderingContext2D,\n width,\n height,\n matrix,\n frame,\n frame.displayWidth,\n frame.displayHeight,\n )\n return new VideoFrame(this.canvas, { timestamp: frame.timestamp })\n } finally {\n frame.close()\n }\n }\n\n dispose() {\n this.worker?.terminate()\n this.worker = null\n this.ready = false\n for (const resolve of this.pending.values()) resolve(null)\n this.pending.clear()\n }\n\n private fail(reason: string) {\n if (!this.worker) return\n console.warn(\n `[LocalPreview] scaled-stream worker disabled, drawing on the main thread: ${reason}`,\n )\n this.dispose()\n }\n}\n\nconst findMainCamera = (devices: ConnectedMediaDevice[]) =>\n devices.find(\n (d) => d.kind === 'videoinput' && d.inUseBy?.includes('mainStream'),\n )\n\nconst createVideoElement = () => {\n const video = document.createElement('video')\n video.muted = true\n video.autoplay = true\n video.playsInline = true\n return video\n}\n\n/** Black background, then the source through the preview matrix. Same drawing as the worker. */\nconst paintPreview = (\n ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D,\n width: number,\n height: number,\n matrix: PreviewMatrix,\n source: CanvasImageSource,\n sourceWidth: number,\n sourceHeight: number,\n) => {\n ctx.setTransform(1, 0, 0, 1, 0, 0)\n ctx.fillStyle = 'black'\n ctx.fillRect(0, 0, width, height)\n ctx.setTransform(...matrix)\n ctx.drawImage(source, 0, 0, sourceWidth, sourceHeight)\n}\n\nconst namedError = (name: string, message: string) => {\n const error = new Error(message)\n error.name = name\n return error\n}\n\nconst toPreviewError = (error: unknown): LocalPreviewError =>\n error instanceof Error || error instanceof DOMException\n ? { name: error.name, message: error.message }\n : { name: 'Error', message: String(error) }\n\n/** Rejects with a `TimeoutError` after `ms`; a value arriving later goes to `onLate` (to release it). */\nconst withTimeout = <T>(\n promise: Promise<T>,\n ms: number,\n what: string,\n onLate?: (value: T) => void,\n): Promise<T> =>\n new Promise<T>((resolve, reject) => {\n let timedOut = false\n const timer = setTimeout(() => {\n timedOut = true\n reject(namedError('TimeoutError', `${what} took more than ${ms} ms`))\n }, ms)\n promise.then(\n (value) => {\n clearTimeout(timer)\n if (timedOut) onLate?.(value)\n else resolve(value)\n },\n (error) => {\n clearTimeout(timer)\n if (!timedOut) reject(error)\n },\n )\n })\n\nconst waitForVideoData = (video: HTMLVideoElement, ms: number) =>\n new Promise<void>((resolve, reject) => {\n if (video.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA) {\n resolve()\n return\n }\n const done = (error?: Error) => {\n clearTimeout(timer)\n video.removeEventListener('loadeddata', onData)\n video.removeEventListener('error', onError)\n video.removeEventListener('emptied', onError)\n if (error) reject(error)\n else resolve()\n }\n const onData = () => done()\n const onError = () => done(new Error('camera stream ended'))\n const timer = setTimeout(\n () => done(namedError('TimeoutError', `no image within ${ms} ms`)),\n ms,\n )\n video.addEventListener('loadeddata', onData)\n video.addEventListener('error', onError)\n video.addEventListener('emptied', onError)\n })\n"]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Source of the scaled-stream worker, as plain JavaScript text. It ships as
3
+ * a string so that the app's build tools (transpilers, coverage, minifiers)
4
+ * cannot rewrite it into code referencing helpers the worker does not have.
5
+ * It does no geometry: the main thread sends each frame with its output size
6
+ * and matrix (`previewOutputSize`, `previewMatrix`), and gets the redrawn
7
+ * frame back under the same id. Keep the drawing in step with `paintPreview`.
8
+ */
9
+ export declare const SCALED_STREAM_WORKER_SOURCE = "\nlet canvas = null\nlet ctx = null\nself.onmessage = (event) => {\n const { id, frame, width, height, matrix } = event.data\n try {\n if (!canvas || canvas.width !== width || canvas.height !== height) {\n canvas = new OffscreenCanvas(width, height)\n ctx = canvas.getContext('2d')\n }\n ctx.setTransform(1, 0, 0, 1, 0, 0)\n ctx.fillStyle = 'black'\n ctx.fillRect(0, 0, width, height)\n ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5])\n ctx.drawImage(frame, 0, 0, frame.displayWidth, frame.displayHeight)\n const out = new VideoFrame(canvas, { timestamp: frame.timestamp })\n self.postMessage({ id, frame: out }, [out])\n } catch (error) {\n self.postMessage({ id, error: String(error) })\n } finally {\n frame.close()\n }\n}\nself.postMessage({ type: 'ready' })\n";
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Source of the scaled-stream worker, as plain JavaScript text. It ships as
3
+ * a string so that the app's build tools (transpilers, coverage, minifiers)
4
+ * cannot rewrite it into code referencing helpers the worker does not have.
5
+ * It does no geometry: the main thread sends each frame with its output size
6
+ * and matrix (`previewOutputSize`, `previewMatrix`), and gets the redrawn
7
+ * frame back under the same id. Keep the drawing in step with `paintPreview`.
8
+ */
9
+ export const SCALED_STREAM_WORKER_SOURCE = `
10
+ let canvas = null
11
+ let ctx = null
12
+ self.onmessage = (event) => {
13
+ const { id, frame, width, height, matrix } = event.data
14
+ try {
15
+ if (!canvas || canvas.width !== width || canvas.height !== height) {
16
+ canvas = new OffscreenCanvas(width, height)
17
+ ctx = canvas.getContext('2d')
18
+ }
19
+ ctx.setTransform(1, 0, 0, 1, 0, 0)
20
+ ctx.fillStyle = 'black'
21
+ ctx.fillRect(0, 0, width, height)
22
+ ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5])
23
+ ctx.drawImage(frame, 0, 0, frame.displayWidth, frame.displayHeight)
24
+ const out = new VideoFrame(canvas, { timestamp: frame.timestamp })
25
+ self.postMessage({ id, frame: out }, [out])
26
+ } catch (error) {
27
+ self.postMessage({ id, error: String(error) })
28
+ } finally {
29
+ frame.close()
30
+ }
31
+ }
32
+ self.postMessage({ type: 'ready' })
33
+ `;
34
+ //# sourceMappingURL=ScaledStreamWorker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScaledStreamWorker.js","sourceRoot":"","sources":["../../Frame/ScaledStreamWorker.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwB1C,CAAA","sourcesContent":["/**\n * Source of the scaled-stream worker, as plain JavaScript text. It ships as\n * a string so that the app's build tools (transpilers, coverage, minifiers)\n * cannot rewrite it into code referencing helpers the worker does not have.\n * It does no geometry: the main thread sends each frame with its output size\n * and matrix (`previewOutputSize`, `previewMatrix`), and gets the redrawn\n * frame back under the same id. Keep the drawing in step with `paintPreview`.\n */\nexport const SCALED_STREAM_WORKER_SOURCE = `\nlet canvas = null\nlet ctx = null\nself.onmessage = (event) => {\n const { id, frame, width, height, matrix } = event.data\n try {\n if (!canvas || canvas.width !== width || canvas.height !== height) {\n canvas = new OffscreenCanvas(width, height)\n ctx = canvas.getContext('2d')\n }\n ctx.setTransform(1, 0, 0, 1, 0, 0)\n ctx.fillStyle = 'black'\n ctx.fillRect(0, 0, width, height)\n ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5])\n ctx.drawImage(frame, 0, 0, frame.displayWidth, frame.displayHeight)\n const out = new VideoFrame(canvas, { timestamp: frame.timestamp })\n self.postMessage({ id, frame: out }, [out])\n } catch (error) {\n self.postMessage({ id, error: String(error) })\n } finally {\n frame.close()\n }\n}\nself.postMessage({ type: 'ready' })\n`\n"]}
@@ -1,3 +1,4 @@
1
1
  export * from './Frame.js';
2
2
  export * from './Frame.Model.js';
3
3
  export * from './SyncAdapter.js';
4
+ export * from './LocalPreview.js';
@@ -1,4 +1,5 @@
1
1
  export * from './Frame.js';
2
2
  export * from './Frame.Model.js';
3
3
  export * from './SyncAdapter.js';
4
+ export * from './LocalPreview.js';
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../Frame/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA","sourcesContent":["export * from './Frame.js'\nexport * from './Frame.Model.js'\nexport * from './SyncAdapter.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../Frame/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA","sourcesContent":["export * from './Frame.js'\nexport * from './Frame.Model.js'\nexport * from './SyncAdapter.js'\nexport * from './LocalPreview.js'\n"]}
package/dist/Version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const apiVersion = "1.51.0";
1
+ export declare const apiVersion = "1.52.0";
package/dist/Version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const apiVersion = '1.51.0';
1
+ export const apiVersion = '1.52.0';
2
2
  //# sourceMappingURL=Version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Version.js","sourceRoot":"","sources":["../Version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAA","sourcesContent":["export const apiVersion = '1.51.0'"]}
1
+ {"version":3,"file":"Version.js","sourceRoot":"","sources":["../Version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAA","sourcesContent":["export const apiVersion = '1.52.0'"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lavitre/apps",
3
- "version": "1.51.0",
3
+ "version": "1.52.0",
4
4
  "description": "TypeScript SDK for building la Vitre apps (connector, frames, companion, CRDT sync)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -59,6 +59,7 @@
59
59
  "prebuild": "node ./replaceVersion.js",
60
60
  "build": "tsc -p tsconfig.build.json",
61
61
  "typecheck": "tsc -p tsconfig.json",
62
+ "test": "node --test 'test/**/*.test.ts'",
62
63
  "prepublishOnly": "pnpm run clean && pnpm run build",
63
64
  "lint": "eslint --fix ."
64
65
  },