Skip to content

Support window.iina in Web Views #8

@drakenstar

Description

@drakenstar

These definitions do not work with Web Views. According to the docs, a Web View does not get access to the full iina API, but have instead access to window.iina which has onMessage and postMessage defined.

I'm not sure the best approach for supporting multiple environments like this. I've worked around this in my project with this short definition:

declare namespace IINA {
  export type WebViewGlobal = {
    postMessage(name: string, data: any): void;
    onMessage(name: string, callback: (data: any) => void): void;
  };
}

declare global {
  interface Window {
    iina: IINA.WebViewGlobal;
  }
}

This works well as long as I prefix calls with window.iina.

I haven't dug too deeply into preferences yet, but I assume they have a different API surface area as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions