vconsole.min.d.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * VConsole type definitions
  3. * @see https://github.com/Tencent/vConsole
  4. */
  5. declare module 'vconsole' {
  6. // VConsole configs
  7. export interface VConsoleConfig {
  8. defaultPlugins?: string[]
  9. onReady?: () => void
  10. onClearLog?: () => void
  11. maxLogNumber?: number
  12. disableLogScrolling?: boolean
  13. theme?: 'light' | 'dark'
  14. }
  15. /**
  16. * VConsole
  17. * @see https://github.com/Tencent/vConsole/blob/dev/doc/public_properties_methods.md
  18. */
  19. export class VConsoleInstance {
  20. constructor (config?: VConsoleConfig)
  21. // properties
  22. readonly version: string
  23. option: VConsoleConfig
  24. readonly activedTab: string
  25. readonly tabList: string[]
  26. readonly $dom: HTMLDivElement
  27. // methods
  28. setOption (config: VConsoleConfig): void;
  29. setOption <TKey extends keyof VConsoleConfig>(key: TKey, value: VConsoleConfig[TKey]): void
  30. destroy (): void
  31. addPlugin (plugin: VConsolePluginInstance): boolean
  32. removePlugin (pluginId: string): boolean
  33. showTab (pluginId: string): void
  34. show (): void
  35. hide (): void
  36. showSwitch (): void
  37. hideSwitch (): void
  38. }
  39. /**
  40. * VConsole Plugin Event List
  41. * @see https://github.com/Tencent/vConsole/blob/dev/doc/plugin_event_list.md
  42. */
  43. export interface VConsolePluginEventMap {
  44. init (): void
  45. renderTab (
  46. callback: <AnyElement extends { appendTo: () => void }>(html: string | HTMLElement | AnyElement) => void
  47. ): void
  48. addTopBar (
  49. callback: (
  50. btnList: {
  51. name: string
  52. data?: { [key: string]: string | number }
  53. className?: string
  54. onClick (e: MouseEvent | TouchEvent): void | boolean
  55. }[]
  56. ) => void
  57. ): void
  58. addTool (
  59. callback: (
  60. toolList: {
  61. name: string
  62. global?: boolean
  63. onClick (e: MouseEvent | TouchEvent): void | boolean
  64. }[]
  65. ) => void
  66. ): void
  67. ready (): void
  68. remove (): void
  69. show (): void
  70. hide (): void
  71. showConsole (): void
  72. hideConsole (): void
  73. updateOption (): void
  74. }
  75. /**
  76. * VConsole Plugin
  77. * @see https://github.com/Tencent/vConsole/blob/dev/doc/plugin_getting_started.md
  78. */
  79. export class VConsolePluginInstance {
  80. constructor (id: string, name?: string)
  81. // properties
  82. id: string
  83. name: string
  84. vConsole: VConsoleInstance
  85. // methods
  86. on<EventName extends keyof VConsolePluginEventMap> (
  87. eventName: EventName,
  88. callback: VConsolePluginEventMap[EventName]
  89. ): VConsolePluginInstance
  90. trigger<T = any> (eventName: keyof VConsolePluginEventMap, data: T): VConsolePluginInstance
  91. }
  92. export class VConsole extends VConsoleInstance {
  93. static VConsolePlugin: VConsolePluginInstance
  94. }
  95. export default VConsole
  96. }