-
Notifications
You must be signed in to change notification settings - Fork 0
/
iframe-message-proxy.d.ts
53 lines (48 loc) · 1.15 KB
/
iframe-message-proxy.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
type EventAction =
| 'sendCommand'
| 'startLoading'
| 'stopLoading'
| 'heightChange'
| 'stateChangeSuccess'
| 'showModal'
| 'hideNavbar'
| 'showNavbar'
| 'getCurrentLanguage'
| 'toast'
| 'getApplication'
| 'hasPermissions'
| 'getPermissionsObject'
| 'segment'
// eslint-disable-next-line @typescript-eslint/ban-types --- This allows for literal string union autocomplete
| (string & {});
interface Message {
action: EventAction;
content?: unknown;
caller?: string;
fireAndForget?: boolean;
}
interface TrackingProperties {
id: string;
}
interface Options {
prefix?: string;
caller?: string;
receiveWindow?: Window;
targetWindow?: Window;
shouldHandleMessage?: (message: {
message: Message;
trackingProperties: TrackingProperties;
}) => boolean;
}
interface IframeMessageProxyType {
config: (options?: Options) => IframeMessageProxyType;
listen: () => void;
stopListen: () => void;
sendMessage: (payload: Message) => Promise<{
response: unknown;
trackingProperties: TrackingProperties;
}>;
}
declare module 'iframe-message-proxy' {
export const IframeMessageProxy: IframeMessageProxyType;
}