import { EventEmitter } from 'node:events'; import { HMRPayload as HMRPayload$1, Plugin } from 'vite'; import { h as ViteNodeRunner, H as HotContext } from './types-516036fa.js'; import 'vite/types/hot'; import './types.d-7442d07f.js'; type EventType = string | symbol; type Handler = (event: T) => void; interface Emitter> { on(type: Key, handler: Handler): void; off(type: Key, handler?: Handler): void; emit(type: Key, event: Events[Key]): void; emit(type: undefined extends Events[Key] ? Key : never): void; } type HMREmitter = Emitter<{ 'message': HMRPayload$1; }> & EventEmitter; declare module 'vite' { interface ViteDevServer { emitter: HMREmitter; } } declare function createHmrEmitter(): HMREmitter; declare function viteNodeHmrPlugin(): Plugin; type HMRPayload = | ConnectedPayload | UpdatePayload | FullReloadPayload | CustomPayload | ErrorPayload | PrunePayload interface ConnectedPayload { type: 'connected' } interface UpdatePayload { type: 'update' updates: Update[] } interface Update { type: 'js-update' | 'css-update' path: string acceptedPath: string timestamp: number /** * @experimental internal */ explicitImportRequired?: boolean | undefined } interface PrunePayload { type: 'prune' paths: string[] } interface FullReloadPayload { type: 'full-reload' path?: string } interface CustomPayload { type: 'custom' event: string data?: any } interface ErrorPayload { type: 'error' err: { [name: string]: any message: string stack: string id?: string frame?: string plugin?: string pluginCode?: string loc?: { file?: string line: number column: number } } } interface CustomEventMap { 'vite:beforeUpdate': UpdatePayload 'vite:afterUpdate': UpdatePayload 'vite:beforePrune': PrunePayload 'vite:beforeFullReload': FullReloadPayload 'vite:error': ErrorPayload 'vite:invalidate': InvalidatePayload } interface InvalidatePayload { path: string message: string | undefined } type InferCustomEventPayload = T extends keyof CustomEventMap ? CustomEventMap[T] : any; interface HotModule { id: string; callbacks: HotCallback[]; } interface HotCallback { deps: string[]; fn: (modules: object[]) => void; } interface CacheData { hotModulesMap: Map; dataMap: Map; disposeMap: Map void | Promise>; pruneMap: Map void | Promise>; customListenersMap: Map void)[]>; ctxToListenersMap: Map void)[]>>; messageBuffer: string[]; isFirstUpdate: boolean; pending: boolean; queued: Promise<(() => void) | undefined>[]; } declare function getCache(runner: ViteNodeRunner): CacheData; declare function sendMessageBuffer(runner: ViteNodeRunner, emitter: HMREmitter): void; declare function reload(runner: ViteNodeRunner, files: string[]): Promise; declare function handleMessage(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], payload: HMRPayload): Promise; declare function createHotContext(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], ownerPath: string): HotContext; export { Emitter, EventType, HMREmitter, Handler, HotCallback, HotModule, InferCustomEventPayload, createHmrEmitter, createHotContext, getCache, handleMessage, reload, sendMessageBuffer, viteNodeHmrPlugin };