blob: f0686838d8e2977bd5f1d35b2248612dda47f378 (
plain) (
blame)
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
|
import * as messages from "../../shared/messages";
import Key from "../../shared/settings/Key";
export default interface FollowMasterClient {
startFollow(newTab: boolean, background: boolean): void;
responseHintCount(count: number): void;
sendKey(key: Key): void;
}
export class FollowMasterClientImpl implements FollowMasterClient {
private window: Window;
constructor(window: Window) {
this.window = window;
}
startFollow(newTab: boolean, background: boolean): void {
this.postMessage({
type: messages.FOLLOW_START,
newTab,
background,
});
}
responseHintCount(count: number): void {
this.postMessage({
type: messages.FOLLOW_RESPONSE_COUNT_TARGETS,
count,
});
}
sendKey(key: Key): void {
this.postMessage({
type: messages.FOLLOW_KEY_PRESS,
key: key.key,
ctrlKey: key.ctrl || false,
});
}
private postMessage(msg: messages.Message): void {
this.window.postMessage(JSON.stringify(msg), "*");
}
}
|