-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtypes.d.ts
60 lines (52 loc) · 1.14 KB
/
types.d.ts
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* Private interface.
*
* Use to send a message to another script through a port.
* Must contain only JSON compatible data.
*/
export interface CoreMessage {
async: boolean
tabId: number | null
payload: any
scope: string
}
export interface TypedMessage<T> {
greeting: string
data: T
}
/**
* Pass back to a script through a port.
* Must contain only JSON compatible data.
*
* Must have the same message id as initial Message.
*/
export interface CoreResponse {
success: boolean
payload: any
}
export interface MessageListener {
(message: any, sender: chrome.runtime.MessageSender): void
}
export interface AsyncMessageListener {
(
message: any,
sender: chrome.runtime.MessageSender,
sendResponse: (response?: any) => void,
): void
}
export interface CoreListener {
(
coreMessage: CoreMessage,
sender: chrome.runtime.MessageSender,
sendResponse: (response?: any) => void,
): void
}
/** The tab that sent the message */
export type Sender = chrome.runtime.MessageSender
export type SendOptions = {
tabId?: number
frameId?: number
}
export type AsyncSendOptions = SendOptions & {
async: true
}