1import { fitStreamSurface } from './window-geometry.mjs';23export function createWindowRuntime({4 getFormat,5 getSurfaceBounds,6 setSurfaceSize,7} = {}) {8 const requiredCallbacks = {9 getFormat,10 getSurfaceBounds,11 setSurfaceSize,12 };13 for (const [name, callback] of Object.entries(requiredCallbacks)) {14 if (typeof callback !== 'function') throw new TypeError(`${name} must be a function`);15 }1617 function sizeSurfaceToIncomingStream() {18 const { width: frameWidth, height: frameHeight } = getFormat();19 if (frameWidth < 1 || frameHeight < 1) return false;20 const bounds = getSurfaceBounds();21 if (!bounds || bounds.width <= 0 || bounds.height <= 0) return false;22 const surface = fitStreamSurface({23 frameWidth,24 frameHeight,25 availableWidth: bounds.width,26 availableHeight: bounds.height,27 });28 setSurfaceSize(surface);29 return true;30 }3132 return Object.freeze({ sizeSurfaceToIncomingStream });33}