IFClite TypeScript API
    Preparing search index...

    Interface ViewerConnection

    interface ViewerConnection {
        capabilities: readonly (
            | "view.apply"
            | "view.capture"
            | "view.saved"
            | "clash.run"
            | "clash.decisions"
            | "connection.resume"
        )[];
        clashRuns: ClashRunDelivery;
        closed: boolean;
        protocol: ProtocolVersion;
        resumePoint: ResumePoint
        | null;
        close(): void;
        has(
            capability:
                | "view.apply"
                | "view.capture"
                | "view.saved"
                | "clash.run"
                | "clash.decisions"
                | "connection.resume",
        ): boolean;
        on<T extends keyof EventPayloads>(
            type: T,
            listener: (payload: EventPayloads[T]) => void,
        ): () => void;
        onClose(listener: (reason: "closed" | "viewer-closed") => void): () => void;
        request<T extends keyof RequestPayloads>(
            type: T,
            ...payload: RequestPayloads[T] extends undefined
                ? []
                : [RequestPayloads[T]],
        ): Promise<RequestResults[T]>;
    }
    Index
    capabilities: readonly (
        | "view.apply"
        | "view.capture"
        | "view.saved"
        | "clash.run"
        | "clash.decisions"
        | "connection.resume"
    )[]
    clashRuns: ClashRunDelivery
    closed: boolean
    protocol: ProtocolVersion

    The viewer's protocol version. Decide features by has, never by the minor.

    resumePoint: ResumePoint | null

    With connection.resume: the viewer's stream and the number of the last event this connection read, or the viewer's head when it connected (before the first event); null from a viewer without the capability. Keep it where a reloaded page finds it (say sessionStorage, on pagehide) and pass it as resumeFrom to get the events this page missed.

    • Says bye and closes the port; pending requests reject with closed.

      Returns void

    • Parameters

      • capability:
            | "view.apply"
            | "view.capture"
            | "view.saved"
            | "clash.run"
            | "clash.decisions"
            | "connection.resume"

      Returns boolean

    • Events reached before the first listener of their type are handed to it (at most 32 per type).

      Type Parameters

      Parameters

      Returns () => void

    • Parameters

      • listener: (reason: "closed" | "viewer-closed") => void

      Returns () => void