aboutsummaryrefslogtreecommitdiff
path: root/src/content/client/ConsoleClient.ts
blob: e7046e5ce65f19d615cd9d4618bc755b99255ba7 (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
import * as messages from '../../shared/messages';

export default interface ConsoleClient {
  info(text: string): Promise<void>;
  error(text: string): Promise<void>;

  // eslint-disable-next-line semi
}

export class ConsoleClientImpl implements ConsoleClient {
  async info(text: string): Promise<void> {
    await browser.runtime.sendMessage({
      type: messages.CONSOLE_FRAME_MESSAGE,
      message: {
        type: messages.CONSOLE_SHOW_INFO,
        text,
      },
    });
  }

  async error(text: string): Promise<void> {
    await browser.runtime.sendMessage({
      type: messages.CONSOLE_FRAME_MESSAGE,
      message: {
        type: messages.CONSOLE_SHOW_ERROR,
        text,
      },
    });
  }
}