hot-middleware.d.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import type { webpack } from 'next/dist/compiled/webpack/webpack';
  2. import type ws from 'ws';
  3. declare class EventStream {
  4. clients: Set<ws>;
  5. constructor();
  6. everyClient(fn: (client: ws) => void): void;
  7. close(): void;
  8. handler(client: ws): void;
  9. publish(payload: any): void;
  10. }
  11. export declare class WebpackHotMiddleware {
  12. eventStream: EventStream;
  13. clientLatestStats: {
  14. ts: number;
  15. stats: webpack.Stats;
  16. } | null;
  17. middlewareLatestStats: {
  18. ts: number;
  19. stats: webpack.Stats;
  20. } | null;
  21. serverLatestStats: {
  22. ts: number;
  23. stats: webpack.Stats;
  24. } | null;
  25. closed: boolean;
  26. constructor(compilers: webpack.Compiler[]);
  27. onClientInvalid: () => void;
  28. onClientDone: (statsResult: webpack.Stats) => void;
  29. onServerInvalid: () => void;
  30. onServerDone: (statsResult: webpack.Stats) => void;
  31. onEdgeServerInvalid: () => void;
  32. onEdgeServerDone: (statsResult: webpack.Stats) => void;
  33. /**
  34. * To sync we use the most recent stats but also we append middleware
  35. * errors. This is because it is possible that middleware fails to compile
  36. * and we still want to show the client overlay with the error while
  37. * the error page should be rendered just fine.
  38. */
  39. onHMR: (client: ws) => void;
  40. publishStats: (action: string, statsResult: webpack.Stats) => void;
  41. publish: (payload: any) => void;
  42. close: () => void;
  43. }
  44. export {};