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