forked from Tencent/vConsole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
115 lines (95 loc) · 2.68 KB
/
index.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/**
* VConsole type definitions
* @see https://github.com/Tencent/vConsole
*/
declare module 'vconsole' {
// VConsole configs
export interface VConsoleConfig {
defaultPlugins?: string[]
onReady?: () => void
onClearLog?: () => void
maxLogNumber?: number
disableLogScrolling?: boolean
}
/**
* VConsole
* @see https://github.com/Tencent/vConsole/blob/dev/doc/public_properties_methods.md
*/
export class VConsoleInstance {
constructor (config?: VConsoleConfig)
// properties
readonly version: string
option: VConsoleConfig
readonly activedTab: string
readonly tabList: string[]
readonly $dom: HTMLDivElement
// methods
setOption (config: VConsoleConfig): void;
setOption <TKey extends keyof VConsoleConfig>(key: TKey, value: VConsoleConfig[TKey]): void
destroy (): void
addPlugin (plugin: VConsolePluginInstance): boolean
removePlugin (pluginId: string): boolean
showTab (pluginId: string): void
show (): void
hide (): void
showSwitch (): void
hideSwitch (): void
}
/**
* VConsole Plugin Event List
* @see https://github.com/Tencent/vConsole/blob/dev/doc/plugin_event_list.md
*/
export interface VConsolePluginEventMap {
init (): void
renderTab (
callback: <AnyElement extends { appendTo: () => void }>(html: string | HTMLElement | AnyElement) => void
): void
addTopBar (
callback: (
btnList: {
name: string
data?: { [key: string]: string | number }
className?: string
onClick (e: MouseEvent | TouchEvent): void | boolean
}[]
) => void
): void
addTool (
callback: (
toolList: {
name: string
global?: boolean
onClick (e: MouseEvent | TouchEvent): void | boolean
}[]
) => void
): void
ready (): void
remove (): void
show (): void
hide (): void
showConsole (): void
hideConsole (): void
updateOption (): void
}
/**
* VConsole Plugin
* @see https://github.com/Tencent/vConsole/blob/dev/doc/plugin_getting_started.md
*/
export class VConsolePluginInstance {
constructor (id: string, name?: string)
// properties
id: string
name: string
vConsole: VConsoleInstance
// methods
on<EventName extends keyof VConsolePluginEventMap> (
eventName: EventName,
callback: VConsolePluginEventMap[EventName]
): VConsolePluginInstance
trigger<T = any> (eventName: keyof VConsolePluginEventMap, data: T): VConsolePluginInstance
}
export class VConsole extends VConsoleInstance {
static VConsolePlugin: VConsolePluginInstance
}
export default VConsole
}