UNPKG

1.18 kBTypeScriptView Raw
1declare type CONTEXT = {
2 app_version: string;
3 immersive: boolean;
4 appearance: 'light' | 'dark';
5 currency: string;
6 locale: string;
7 platform: 'iOS' | 'Android' | 'Desktop';
8 conversation_id: string;
9 [props: string]: any;
10};
11interface MESSAGERS {
12 getContext: () => CONTEXT;
13 playlist: (audios: string[]) => any;
14 reloadTheme: (args?: string) => void;
15 showToast: (msg: string) => void;
16}
17declare global {
18 interface Window {
19 webkit?: {
20 messageHandlers?: {
21 MixinContext?: any;
22 playlist?: {
23 postMessage: MESSAGERS['playlist'];
24 };
25 reloadTheme?: {
26 postMessage: MESSAGERS['reloadTheme'];
27 };
28 };
29 };
30 MixinContext?: {
31 getContext?: MESSAGERS['getContext'];
32 playlist?: MESSAGERS['playlist'];
33 reloadTheme?: MESSAGERS['reloadTheme'];
34 showToast?: MESSAGERS['showToast'];
35 };
36 }
37}
38export declare function messager<T extends keyof MESSAGERS>(type: T): MESSAGERS[T];
39export default messager;