Skip to content
Source
Sign inSign up

desktopSnapShot.ts

18 lines701 Bytes

1import type { DesktopBridge } from "@t3tools/contracts";
2​
3const SNAP_SHOT_FOCUS_EVENT = "t3code:focus-composer";
4​
5export function dispatchSnapShotComposerFocus(): void {
6 if (typeof window === "undefined") return;
7 window.dispatchEvent(new Event(SNAP_SHOT_FOCUS_EVENT));
8}
9​
10export function subscribeSnapShotComposerFocus(listener: () => void): () => void {
11 if (typeof window === "undefined") return () => {};
12 window.addEventListener(SNAP_SHOT_FOCUS_EVENT, listener);
13 return () => window.removeEventListener(SNAP_SHOT_FOCUS_EVENT, listener);
15​
16export function getDesktopSnapShotBridge(): DesktopBridge | undefined {
17 return typeof window === "undefined" ? undefined : window.desktopBridge;