diff options
Diffstat (limited to 'src/content/client')
-rw-r--r-- | src/content/client/BackgroundClient.ts | 13 | ||||
-rw-r--r-- | src/content/client/OperationClient.ts | 33 |
2 files changed, 33 insertions, 13 deletions
diff --git a/src/content/client/BackgroundClient.ts b/src/content/client/BackgroundClient.ts deleted file mode 100644 index 4a41184..0000000 --- a/src/content/client/BackgroundClient.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { injectable } from 'tsyringe'; -import * as operations from '../../shared/operations'; -import * as messages from '../../shared/messages'; - -@injectable() -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/OperationClient.ts b/src/content/client/OperationClient.ts new file mode 100644 index 0000000..5dbe555 --- /dev/null +++ b/src/content/client/OperationClient.ts @@ -0,0 +1,33 @@ +import * as operations from '../../shared/operations'; +import * as messages from '../../shared/messages'; + +export default interface OperationClient { + execBackgroundOp(op: operations.Operation): Promise<void>; + + internalOpenUrl( + url: string, newTab?: boolean, background?: boolean, + ): Promise<void>; +} + +export class OperationClientImpl implements OperationClient { + execBackgroundOp(op: operations.Operation): Promise<void> { + return browser.runtime.sendMessage({ + type: messages.BACKGROUND_OPERATION, + operation: op, + }); + } + + internalOpenUrl( + url: string, newTab?: boolean, background?: boolean, + ): Promise<void> { + return browser.runtime.sendMessage({ + type: messages.BACKGROUND_OPERATION, + operation: { + type: operations.INTERNAL_OPEN_URL, + url, + newTab, + background, + }, + }); + } +} |