UNPKG

1.14 kBTypeScriptView Raw
1import type {
2 ErrorPayload,
3 FullReloadPayload,
4 PrunePayload,
5 UpdatePayload,
6} from './hmrPayload'
7
8export interface CustomEventMap {
9 'vite:beforeUpdate': UpdatePayload
10 'vite:afterUpdate': UpdatePayload
11 'vite:beforePrune': PrunePayload
12 'vite:beforeFullReload': FullReloadPayload
13 'vite:error': ErrorPayload
14 'vite:invalidate': InvalidatePayload
15 'vite:ws:connect': WebSocketConnectionPayload
16 'vite:ws:disconnect': WebSocketConnectionPayload
17}
18
19export interface WebSocketConnectionPayload {
20 /**
21 * @experimental
22 * We expose this instance experimentally to see potential usage.
23 * This might be removed in the future if we didn't find reasonable use cases.
24 * If you find this useful, please open an issue with details so we can discuss and make it stable API.
25 */
26 // eslint-disable-next-line n/no-unsupported-features/node-builtins
27 webSocket: WebSocket
28}
29
30export interface InvalidatePayload {
31 path: string
32 message: string | undefined
33}
34
35/**
36 * provides types for built-in Vite events
37 */
38export type InferCustomEventPayload<T extends string> =
39 T extends keyof CustomEventMap ? CustomEventMap[T] : any