diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-11 19:43:56 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-18 17:28:11 +0900 |
commit | efc48dc7421e3bd48534bc94f84e2b0bd47ae47c (patch) | |
tree | dfe80ebc368911c385e6c36aa1096af619b1616b /src/content/client | |
parent | a88324acd9fe626b59637541975abe1ee6041aa7 (diff) |
Keymaps as a clean architecture [WIP]
Diffstat (limited to 'src/content/client')
-rw-r--r-- | src/content/client/BackgroundClient.ts | 11 | ||||
-rw-r--r-- | src/content/client/FindMasterClient.ts | 23 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/content/client/BackgroundClient.ts b/src/content/client/BackgroundClient.ts new file mode 100644 index 0000000..2fe8d01 --- /dev/null +++ b/src/content/client/BackgroundClient.ts @@ -0,0 +1,11 @@ +import * as operations from '../../shared/operations'; +import * as messages from '../../shared/messages'; + +export default class BackgroundClient { + execBackgroundOp(op: operations.Operation): Promise<void> { + return browser.runtime.sendMessage({ + type: messages.BACKGROUND_OPERATION, + operation: op, + }); + } +} diff --git a/src/content/client/FindMasterClient.ts b/src/content/client/FindMasterClient.ts new file mode 100644 index 0000000..0481ec1 --- /dev/null +++ b/src/content/client/FindMasterClient.ts @@ -0,0 +1,23 @@ +import * as messages from '../../shared/messages'; + +export default interface FindMasterClient { + findNext(): void; + + findPrev(): void; + + // eslint-disable-next-line semi +} + +export class FindMasterClientImpl implements FindMasterClient { + findNext(): void { + window.top.postMessage(JSON.stringify({ + type: messages.FIND_NEXT, + }), '*'); + } + + findPrev(): void { + window.top.postMessage(JSON.stringify({ + type: messages.FIND_PREV, + }), '*'); + } +} |