vconsole.min.d.ts 2.7 KB

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