import type { Result } from "@cprussin/option-result"; import type { Displays } from "./desktop/displays"; import type { GoogleCast } from "./desktop/google-cast"; import type { PortalAnswer, PortalRequest } from "./portal"; import type { VirtualMonitorMode } from "./system"; /** A TV a backend found. */ export type CastTarget = { /** Its id within its backend. */ id: string; /** What the TV calls itself. */ name: string; /** * Why it cannot be cast to now, such as "Needs Wi-Fi Direct", or * `undefined` when it can. */ unreachable: string | undefined; /** The mode it shows best, which an extended desk takes. */ mode: Omit; }; /** A picture going to a TV. */ export type Sending = { stop: () => void; /** Settles once it stopped, whoever stopped it. */ ended: Promise; }; /** Something that sends to TVs: the engine's Google Cast, or Miracast. */ export type CastBackend = { /** * The app id its ScreenCast portal requests carry, or `undefined` when it * is not known: then a cast claims the next request from any app. */ appId: string | undefined; /** Calls `listener` with every TV it finds now, and on each change. */ watchTargets: (listener: (targets: readonly CastTarget[]) => void) => () => void; /** * Starts sending to the TV `targetId`, asking the ScreenCast portal for the * picture. `Err` says why the TV refused, in words to show. */ send: (targetId: string) => Promise>; }; export declare enum CastMode { /** The TV becomes a monitor the desk extends onto. */ Extend = 0, /** The share picker asks what to show. */ Pick = 1 } /** A running cast. */ export type Cast = { backend: CastBackend; target: CastTarget; mode: CastMode; stop: () => void; }; export declare enum CastClaimKind { /** Answer it with `answer`, showing nothing. */ Answered = 0, /** Show the share picker, titled for the TV `to`. */ Pick = 1 } /** What the shell does with a ScreenCast request a cast asked for. */ export type CastClaim = { kind: CastClaimKind.Answered; answer: PortalAnswer; } | { kind: CastClaimKind.Pick; to: string; }; /** The casts on a desktop. */ export type Casting = { /** Casts to `target` from `backend`, once the TV takes it. */ start: (backend: CastBackend, target: CastTarget, mode: CastMode) => Promise>; /** Calls `listener` with every running cast now, and on each change. */ watch: (listener: (casts: readonly Cast[]) => void) => () => void; }; /** What {@link casting} needs of the desktop. */ export type CastDesktop = { readonly displays: Pick; }; /** * The casts on `domicile`. Every caller with the same desktop shares them, so * the bar and the portal dialogs see the same casts. `monitors`, for tests, * is the first caller's. */ export declare const casting: (domicile: CastDesktop, monitors?: Pick) => Casting; /** * What the shell does with `request` on `domicile`: `undefined` when no cast * asked for it, so it is an application's. Each cast claims one request. */ export declare const claimCastRequest: (domicile: object, request: PortalRequest) => CastClaim | undefined; /** The engine's Google Cast, as a backend: `domicile.googleCast`. */ export declare const engineCast: (cast: GoogleCast) => CastBackend;