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

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

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,
      },
    });
  }
}