Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-05-14 17:59:46 +00:00
parent a8951935e6
commit 7532aa93a6
3 changed files with 242 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
/**
* Lightweight registry that lets the XR mirror expose its offscreen canvas
* as the preferred broadcast source. ShareButton checks here first.
*/
let activeCanvas: HTMLCanvasElement | null = null;
const listeners = new Set<(c: HTMLCanvasElement | null) => void>();
export function setBroadcastSource(c: HTMLCanvasElement | null) {
activeCanvas = c;
listeners.forEach((cb) => cb(c));
}
export function getBroadcastSource(): HTMLCanvasElement | null {
return activeCanvas;
}
export function onBroadcastSourceChange(cb: (c: HTMLCanvasElement | null) => void) {
listeners.add(cb);
return () => listeners.delete(cb);
}