UNPKG

45.9 kBTypeScriptView Raw
1export = Server;
2/**
3 * @typedef {Object} BasicApplication
4 * @property {typeof useFn} use
5 */
6/**
7 * @template {BasicApplication} [A=ExpressApplication]
8 * @template {BasicServer} [S=HTTPServer]
9 */
10declare class Server<
11 A extends BasicApplication = import("express").Application,
12 S extends BasicServer = import("http").Server<
13 typeof import("http").IncomingMessage,
14 typeof import("http").ServerResponse
15 >,
16> {
17 static get schema(): {
18 title: string;
19 type: string;
20 definitions: {
21 App: {
22 instanceof: string;
23 description: string;
24 link: string;
25 };
26 AllowedHosts: {
27 anyOf: (
28 | {
29 type: string;
30 minItems: number;
31 items: {
32 $ref: string;
33 };
34 enum?: undefined;
35 $ref?: undefined;
36 }
37 | {
38 enum: string[];
39 type?: undefined;
40 minItems?: undefined;
41 items?: undefined;
42 $ref?: undefined;
43 }
44 | {
45 $ref: string;
46 type?: undefined;
47 minItems?: undefined;
48 items?: undefined;
49 enum?: undefined;
50 }
51 )[];
52 description: string;
53 link: string;
54 };
55 AllowedHostsItem: {
56 type: string;
57 minLength: number;
58 };
59 Bonjour: {
60 anyOf: (
61 | {
62 type: string;
63 cli: {
64 negatedDescription: string;
65 };
66 description?: undefined;
67 link?: undefined;
68 }
69 | {
70 type: string;
71 description: string;
72 link: string;
73 cli?: undefined;
74 }
75 )[];
76 description: string;
77 link: string;
78 };
79 Client: {
80 description: string;
81 link: string;
82 anyOf: (
83 | {
84 enum: boolean[];
85 cli: {
86 negatedDescription: string;
87 };
88 type?: undefined;
89 additionalProperties?: undefined;
90 properties?: undefined;
91 }
92 | {
93 type: string;
94 additionalProperties: boolean;
95 properties: {
96 logging: {
97 $ref: string;
98 };
99 overlay: {
100 $ref: string;
101 };
102 progress: {
103 $ref: string;
104 };
105 reconnect: {
106 $ref: string;
107 };
108 webSocketTransport: {
109 $ref: string;
110 };
111 webSocketURL: {
112 $ref: string;
113 };
114 };
115 enum?: undefined;
116 cli?: undefined;
117 }
118 )[];
119 };
120 ClientLogging: {
121 enum: string[];
122 description: string;
123 link: string;
124 };
125 ClientOverlay: {
126 anyOf: (
127 | {
128 description: string;
129 link: string;
130 type: string;
131 cli: {
132 negatedDescription: string;
133 };
134 additionalProperties?: undefined;
135 properties?: undefined;
136 }
137 | {
138 type: string;
139 additionalProperties: boolean;
140 properties: {
141 errors: {
142 anyOf: (
143 | {
144 description: string;
145 type: string;
146 cli: {
147 negatedDescription: string;
148 };
149 instanceof?: undefined;
150 }
151 | {
152 instanceof: string;
153 description: string;
154 type?: undefined;
155 cli?: undefined;
156 }
157 )[];
158 };
159 warnings: {
160 anyOf: (
161 | {
162 description: string;
163 type: string;
164 cli: {
165 negatedDescription: string;
166 };
167 instanceof?: undefined;
168 }
169 | {
170 instanceof: string;
171 description: string;
172 type?: undefined;
173 cli?: undefined;
174 }
175 )[];
176 };
177 runtimeErrors: {
178 anyOf: (
179 | {
180 description: string;
181 type: string;
182 cli: {
183 negatedDescription: string;
184 };
185 instanceof?: undefined;
186 }
187 | {
188 instanceof: string;
189 description: string;
190 type?: undefined;
191 cli?: undefined;
192 }
193 )[];
194 };
195 trustedTypesPolicyName: {
196 description: string;
197 type: string;
198 };
199 };
200 description?: undefined;
201 link?: undefined;
202 cli?: undefined;
203 }
204 )[];
205 };
206 ClientProgress: {
207 description: string;
208 link: string;
209 type: string[];
210 enum: (string | boolean)[];
211 cli: {
212 negatedDescription: string;
213 };
214 };
215 ClientReconnect: {
216 description: string;
217 link: string;
218 anyOf: (
219 | {
220 type: string;
221 cli: {
222 negatedDescription: string;
223 };
224 minimum?: undefined;
225 }
226 | {
227 type: string;
228 minimum: number;
229 cli?: undefined;
230 }
231 )[];
232 };
233 ClientWebSocketTransport: {
234 anyOf: {
235 $ref: string;
236 }[];
237 description: string;
238 link: string;
239 };
240 ClientWebSocketTransportEnum: {
241 enum: string[];
242 };
243 ClientWebSocketTransportString: {
244 type: string;
245 minLength: number;
246 };
247 ClientWebSocketURL: {
248 description: string;
249 link: string;
250 anyOf: (
251 | {
252 type: string;
253 minLength: number;
254 additionalProperties?: undefined;
255 properties?: undefined;
256 }
257 | {
258 type: string;
259 additionalProperties: boolean;
260 properties: {
261 hostname: {
262 description: string;
263 type: string;
264 minLength: number;
265 };
266 pathname: {
267 description: string;
268 type: string;
269 };
270 password: {
271 description: string;
272 type: string;
273 };
274 port: {
275 description: string;
276 anyOf: (
277 | {
278 type: string;
279 minLength?: undefined;
280 }
281 | {
282 type: string;
283 minLength: number;
284 }
285 )[];
286 };
287 protocol: {
288 description: string;
289 anyOf: (
290 | {
291 enum: string[];
292 type?: undefined;
293 minLength?: undefined;
294 }
295 | {
296 type: string;
297 minLength: number;
298 enum?: undefined;
299 }
300 )[];
301 };
302 username: {
303 description: string;
304 type: string;
305 };
306 };
307 minLength?: undefined;
308 }
309 )[];
310 };
311 Compress: {
312 type: string;
313 description: string;
314 link: string;
315 cli: {
316 negatedDescription: string;
317 };
318 };
319 DevMiddleware: {
320 description: string;
321 link: string;
322 type: string;
323 additionalProperties: boolean;
324 };
325 HeaderObject: {
326 type: string;
327 additionalProperties: boolean;
328 properties: {
329 key: {
330 description: string;
331 type: string;
332 };
333 value: {
334 description: string;
335 type: string;
336 };
337 };
338 cli: {
339 exclude: boolean;
340 };
341 };
342 Headers: {
343 anyOf: (
344 | {
345 type: string;
346 items: {
347 $ref: string;
348 };
349 minItems: number;
350 instanceof?: undefined;
351 }
352 | {
353 type: string;
354 items?: undefined;
355 minItems?: undefined;
356 instanceof?: undefined;
357 }
358 | {
359 instanceof: string;
360 type?: undefined;
361 items?: undefined;
362 minItems?: undefined;
363 }
364 )[];
365 description: string;
366 link: string;
367 };
368 HistoryApiFallback: {
369 anyOf: (
370 | {
371 type: string;
372 cli: {
373 negatedDescription: string;
374 };
375 description?: undefined;
376 link?: undefined;
377 }
378 | {
379 type: string;
380 description: string;
381 link: string;
382 cli?: undefined;
383 }
384 )[];
385 description: string;
386 link: string;
387 };
388 Host: {
389 description: string;
390 link: string;
391 anyOf: (
392 | {
393 enum: string[];
394 type?: undefined;
395 minLength?: undefined;
396 }
397 | {
398 type: string;
399 minLength: number;
400 enum?: undefined;
401 }
402 )[];
403 };
404 Hot: {
405 anyOf: (
406 | {
407 type: string;
408 cli: {
409 negatedDescription: string;
410 };
411 enum?: undefined;
412 }
413 | {
414 enum: string[];
415 type?: undefined;
416 cli?: undefined;
417 }
418 )[];
419 description: string;
420 link: string;
421 };
422 IPC: {
423 anyOf: (
424 | {
425 type: string;
426 minLength: number;
427 enum?: undefined;
428 }
429 | {
430 type: string;
431 enum: boolean[];
432 minLength?: undefined;
433 }
434 )[];
435 description: string;
436 link: string;
437 };
438 LiveReload: {
439 type: string;
440 description: string;
441 cli: {
442 negatedDescription: string;
443 };
444 link: string;
445 };
446 OnListening: {
447 instanceof: string;
448 description: string;
449 link: string;
450 };
451 Open: {
452 anyOf: (
453 | {
454 type: string;
455 items: {
456 anyOf: {
457 $ref: string;
458 }[];
459 };
460 $ref?: undefined;
461 }
462 | {
463 $ref: string;
464 type?: undefined;
465 items?: undefined;
466 }
467 )[];
468 description: string;
469 link: string;
470 };
471 OpenBoolean: {
472 type: string;
473 cli: {
474 negatedDescription: string;
475 };
476 };
477 OpenObject: {
478 type: string;
479 additionalProperties: boolean;
480 properties: {
481 target: {
482 anyOf: (
483 | {
484 type: string;
485 items: {
486 type: string;
487 };
488 }
489 | {
490 type: string;
491 items?: undefined;
492 }
493 )[];
494 description: string;
495 };
496 app: {
497 anyOf: (
498 | {
499 type: string;
500 additionalProperties: boolean;
501 properties: {
502 name: {
503 anyOf: (
504 | {
505 type: string;
506 items: {
507 type: string;
508 minLength: number;
509 };
510 minItems: number;
511 minLength?: undefined;
512 }
513 | {
514 type: string;
515 minLength: number;
516 items?: undefined;
517 minItems?: undefined;
518 }
519 )[];
520 };
521 arguments: {
522 items: {
523 type: string;
524 minLength: number;
525 };
526 };
527 };
528 minLength?: undefined;
529 description?: undefined;
530 cli?: undefined;
531 }
532 | {
533 type: string;
534 minLength: number;
535 description: string;
536 cli: {
537 exclude: boolean;
538 };
539 additionalProperties?: undefined;
540 properties?: undefined;
541 }
542 )[];
543 description: string;
544 };
545 };
546 };
547 OpenString: {
548 type: string;
549 minLength: number;
550 };
551 Port: {
552 anyOf: (
553 | {
554 type: string;
555 minimum: number;
556 maximum: number;
557 minLength?: undefined;
558 enum?: undefined;
559 }
560 | {
561 type: string;
562 minLength: number;
563 minimum?: undefined;
564 maximum?: undefined;
565 enum?: undefined;
566 }
567 | {
568 enum: string[];
569 type?: undefined;
570 minimum?: undefined;
571 maximum?: undefined;
572 minLength?: undefined;
573 }
574 )[];
575 description: string;
576 link: string;
577 };
578 Proxy: {
579 type: string;
580 items: {
581 anyOf: (
582 | {
583 type: string;
584 instanceof?: undefined;
585 }
586 | {
587 instanceof: string;
588 type?: undefined;
589 }
590 )[];
591 };
592 description: string;
593 link: string;
594 };
595 Server: {
596 anyOf: {
597 $ref: string;
598 }[];
599 link: string;
600 description: string;
601 };
602 ServerType: {
603 enum: string[];
604 };
605 ServerFn: {
606 instanceof: string;
607 };
608 ServerEnum: {
609 enum: string[];
610 cli: {
611 exclude: boolean;
612 };
613 };
614 ServerString: {
615 type: string;
616 minLength: number;
617 cli: {
618 exclude: boolean;
619 };
620 };
621 ServerObject: {
622 type: string;
623 properties: {
624 type: {
625 anyOf: {
626 $ref: string;
627 }[];
628 };
629 options: {
630 $ref: string;
631 };
632 };
633 additionalProperties: boolean;
634 };
635 ServerOptions: {
636 type: string;
637 additionalProperties: boolean;
638 properties: {
639 passphrase: {
640 type: string;
641 description: string;
642 };
643 requestCert: {
644 type: string;
645 description: string;
646 cli: {
647 negatedDescription: string;
648 };
649 };
650 ca: {
651 anyOf: (
652 | {
653 type: string;
654 items: {
655 anyOf: (
656 | {
657 type: string;
658 instanceof?: undefined;
659 }
660 | {
661 instanceof: string;
662 type?: undefined;
663 }
664 )[];
665 };
666 instanceof?: undefined;
667 }
668 | {
669 type: string;
670 items?: undefined;
671 instanceof?: undefined;
672 }
673 | {
674 instanceof: string;
675 type?: undefined;
676 items?: undefined;
677 }
678 )[];
679 description: string;
680 };
681 cert: {
682 anyOf: (
683 | {
684 type: string;
685 items: {
686 anyOf: (
687 | {
688 type: string;
689 instanceof?: undefined;
690 }
691 | {
692 instanceof: string;
693 type?: undefined;
694 }
695 )[];
696 };
697 instanceof?: undefined;
698 }
699 | {
700 type: string;
701 items?: undefined;
702 instanceof?: undefined;
703 }
704 | {
705 instanceof: string;
706 type?: undefined;
707 items?: undefined;
708 }
709 )[];
710 description: string;
711 };
712 crl: {
713 anyOf: (
714 | {
715 type: string;
716 items: {
717 anyOf: (
718 | {
719 type: string;
720 instanceof?: undefined;
721 }
722 | {
723 instanceof: string;
724 type?: undefined;
725 }
726 )[];
727 };
728 instanceof?: undefined;
729 }
730 | {
731 type: string;
732 items?: undefined;
733 instanceof?: undefined;
734 }
735 | {
736 instanceof: string;
737 type?: undefined;
738 items?: undefined;
739 }
740 )[];
741 description: string;
742 };
743 key: {
744 anyOf: (
745 | {
746 type: string;
747 items: {
748 anyOf: (
749 | {
750 type: string;
751 instanceof?: undefined;
752 additionalProperties?: undefined;
753 }
754 | {
755 instanceof: string;
756 type?: undefined;
757 additionalProperties?: undefined;
758 }
759 | {
760 type: string;
761 additionalProperties: boolean;
762 instanceof?: undefined;
763 }
764 )[];
765 };
766 instanceof?: undefined;
767 }
768 | {
769 type: string;
770 items?: undefined;
771 instanceof?: undefined;
772 }
773 | {
774 instanceof: string;
775 type?: undefined;
776 items?: undefined;
777 }
778 )[];
779 description: string;
780 };
781 pfx: {
782 anyOf: (
783 | {
784 type: string;
785 items: {
786 anyOf: (
787 | {
788 type: string;
789 instanceof?: undefined;
790 additionalProperties?: undefined;
791 }
792 | {
793 instanceof: string;
794 type?: undefined;
795 additionalProperties?: undefined;
796 }
797 | {
798 type: string;
799 additionalProperties: boolean;
800 instanceof?: undefined;
801 }
802 )[];
803 };
804 instanceof?: undefined;
805 }
806 | {
807 type: string;
808 items?: undefined;
809 instanceof?: undefined;
810 }
811 | {
812 instanceof: string;
813 type?: undefined;
814 items?: undefined;
815 }
816 )[];
817 description: string;
818 };
819 };
820 };
821 SetupExitSignals: {
822 type: string;
823 description: string;
824 link: string;
825 cli: {
826 exclude: boolean;
827 };
828 };
829 SetupMiddlewares: {
830 instanceof: string;
831 description: string;
832 link: string;
833 };
834 Static: {
835 anyOf: (
836 | {
837 type: string;
838 items: {
839 anyOf: {
840 $ref: string;
841 }[];
842 };
843 cli?: undefined;
844 $ref?: undefined;
845 }
846 | {
847 type: string;
848 cli: {
849 negatedDescription: string;
850 };
851 items?: undefined;
852 $ref?: undefined;
853 }
854 | {
855 $ref: string;
856 type?: undefined;
857 items?: undefined;
858 cli?: undefined;
859 }
860 )[];
861 description: string;
862 link: string;
863 };
864 StaticObject: {
865 type: string;
866 additionalProperties: boolean;
867 properties: {
868 directory: {
869 type: string;
870 minLength: number;
871 description: string;
872 link: string;
873 };
874 staticOptions: {
875 type: string;
876 link: string;
877 additionalProperties: boolean;
878 };
879 publicPath: {
880 anyOf: (
881 | {
882 type: string;
883 items: {
884 type: string;
885 };
886 minItems: number;
887 }
888 | {
889 type: string;
890 items?: undefined;
891 minItems?: undefined;
892 }
893 )[];
894 description: string;
895 link: string;
896 };
897 serveIndex: {
898 anyOf: (
899 | {
900 type: string;
901 cli: {
902 negatedDescription: string;
903 };
904 additionalProperties?: undefined;
905 }
906 | {
907 type: string;
908 additionalProperties: boolean;
909 cli?: undefined;
910 }
911 )[];
912 description: string;
913 link: string;
914 };
915 watch: {
916 anyOf: (
917 | {
918 type: string;
919 cli: {
920 negatedDescription: string;
921 };
922 description?: undefined;
923 link?: undefined;
924 }
925 | {
926 type: string;
927 description: string;
928 link: string;
929 cli?: undefined;
930 }
931 )[];
932 description: string;
933 link: string;
934 };
935 };
936 };
937 StaticString: {
938 type: string;
939 minLength: number;
940 };
941 WatchFiles: {
942 anyOf: (
943 | {
944 type: string;
945 items: {
946 anyOf: {
947 $ref: string;
948 }[];
949 };
950 $ref?: undefined;
951 }
952 | {
953 $ref: string;
954 type?: undefined;
955 items?: undefined;
956 }
957 )[];
958 description: string;
959 link: string;
960 };
961 WatchFilesObject: {
962 cli: {
963 exclude: boolean;
964 };
965 type: string;
966 properties: {
967 paths: {
968 anyOf: (
969 | {
970 type: string;
971 items: {
972 type: string;
973 minLength: number;
974 };
975 minLength?: undefined;
976 }
977 | {
978 type: string;
979 minLength: number;
980 items?: undefined;
981 }
982 )[];
983 description: string;
984 };
985 options: {
986 type: string;
987 description: string;
988 link: string;
989 additionalProperties: boolean;
990 };
991 };
992 additionalProperties: boolean;
993 };
994 WatchFilesString: {
995 type: string;
996 minLength: number;
997 };
998 WebSocketServer: {
999 anyOf: {
1000 $ref: string;
1001 }[];
1002 description: string;
1003 link: string;
1004 };
1005 WebSocketServerType: {
1006 enum: string[];
1007 };
1008 WebSocketServerEnum: {
1009 anyOf: (
1010 | {
1011 enum: boolean[];
1012 cli: {
1013 negatedDescription: string;
1014 exclude?: undefined;
1015 };
1016 }
1017 | {
1018 enum: string[];
1019 cli: {
1020 exclude: boolean;
1021 negatedDescription?: undefined;
1022 };
1023 }
1024 )[];
1025 };
1026 WebSocketServerFunction: {
1027 instanceof: string;
1028 };
1029 WebSocketServerObject: {
1030 type: string;
1031 properties: {
1032 type: {
1033 anyOf: {
1034 $ref: string;
1035 }[];
1036 };
1037 options: {
1038 type: string;
1039 additionalProperties: boolean;
1040 cli: {
1041 exclude: boolean;
1042 };
1043 };
1044 };
1045 additionalProperties: boolean;
1046 };
1047 WebSocketServerString: {
1048 type: string;
1049 minLength: number;
1050 cli: {
1051 exclude: boolean;
1052 };
1053 };
1054 };
1055 additionalProperties: boolean;
1056 properties: {
1057 allowedHosts: {
1058 $ref: string;
1059 };
1060 bonjour: {
1061 $ref: string;
1062 };
1063 client: {
1064 $ref: string;
1065 };
1066 compress: {
1067 $ref: string;
1068 };
1069 devMiddleware: {
1070 $ref: string;
1071 };
1072 headers: {
1073 $ref: string;
1074 };
1075 historyApiFallback: {
1076 $ref: string;
1077 };
1078 host: {
1079 $ref: string;
1080 };
1081 hot: {
1082 $ref: string;
1083 };
1084 ipc: {
1085 $ref: string;
1086 };
1087 liveReload: {
1088 $ref: string;
1089 };
1090 onListening: {
1091 $ref: string;
1092 };
1093 open: {
1094 $ref: string;
1095 };
1096 port: {
1097 $ref: string;
1098 };
1099 proxy: {
1100 $ref: string;
1101 };
1102 server: {
1103 $ref: string;
1104 };
1105 app: {
1106 $ref: string;
1107 };
1108 setupExitSignals: {
1109 $ref: string;
1110 };
1111 setupMiddlewares: {
1112 $ref: string;
1113 };
1114 static: {
1115 $ref: string;
1116 };
1117 watchFiles: {
1118 $ref: string;
1119 };
1120 webSocketServer: {
1121 $ref: string;
1122 };
1123 };
1124 };
1125 /**
1126 * @param {string} URL
1127 * @returns {boolean}
1128 */
1129 static isAbsoluteURL(URL: string): boolean;
1130 /**
1131 * @param {string} gatewayOrFamily or family
1132 * @param {boolean} [isInternal] ip should be internal
1133 * @returns {string | undefined}
1134 */
1135 static findIp(
1136 gatewayOrFamily: string,
1137 isInternal?: boolean,
1138 ): string | undefined;
1139 /**
1140 * @param {"v4" | "v6"} family
1141 * @returns {Promise<string | undefined>}
1142 */
1143 static internalIP(family: "v4" | "v6"): Promise<string | undefined>;
1144 /**
1145 * @param {"v4" | "v6"} family
1146 * @returns {string | undefined}
1147 */
1148 static internalIPSync(family: "v4" | "v6"): string | undefined;
1149 /**
1150 * @param {Host} hostname
1151 * @returns {Promise<string>}
1152 */
1153 static getHostname(hostname: Host): Promise<string>;
1154 /**
1155 * @param {Port} port
1156 * @param {string} host
1157 * @returns {Promise<number | string>}
1158 */
1159 static getFreePort(port: Port, host: string): Promise<number | string>;
1160 /**
1161 * @returns {string}
1162 */
1163 static findCacheDir(): string;
1164 /**
1165 * @private
1166 * @param {Compiler} compiler
1167 * @returns bool
1168 */
1169 private static isWebTarget;
1170 /**
1171 * @param {Configuration<A, S>} options
1172 * @param {Compiler | MultiCompiler} compiler
1173 */
1174 constructor(
1175 options: Configuration<A, S> | undefined,
1176 compiler: Compiler | MultiCompiler,
1177 );
1178 compiler: import("webpack").Compiler | import("webpack").MultiCompiler;
1179 /**
1180 * @type {ReturnType<Compiler["getInfrastructureLogger"]>}
1181 * */
1182 logger: ReturnType<Compiler["getInfrastructureLogger"]>;
1183 options: Configuration<A, S>;
1184 /**
1185 * @type {FSWatcher[]}
1186 */
1187 staticWatchers: FSWatcher[];
1188 /**
1189 * @private
1190 * @type {{ name: string | symbol, listener: (...args: any[]) => void}[] }}
1191 */
1192 private listeners;
1193 /**
1194 * @private
1195 * @type {RequestHandler[]}
1196 */
1197 private webSocketProxies;
1198 /**
1199 * @type {Socket[]}
1200 */
1201 sockets: Socket[];
1202 /**
1203 * @private
1204 * @type {string | undefined}
1205 */
1206 private currentHash;
1207 /**
1208 * @private
1209 * @param {Compiler} compiler
1210 */
1211 private addAdditionalEntries;
1212 /**
1213 * @private
1214 * @returns {Compiler["options"]}
1215 */
1216 private getCompilerOptions;
1217 /**
1218 * @private
1219 * @returns {Promise<void>}
1220 */
1221 private normalizeOptions;
1222 /**
1223 * @private
1224 * @returns {string}
1225 */
1226 private getClientTransport;
1227 /**
1228 * @template T
1229 * @private
1230 * @returns {T}
1231 */
1232 private getServerTransport;
1233 /**
1234 * @returns {string}
1235 */
1236 getClientEntry(): string;
1237 /**
1238 * @returns {string | void}
1239 */
1240 getClientHotEntry(): string | void;
1241 /**
1242 * @private
1243 * @returns {void}
1244 */
1245 private setupProgressPlugin;
1246 /**
1247 * @private
1248 * @returns {Promise<void>}
1249 */
1250 private initialize;
1251 /**
1252 * @private
1253 * @returns {Promise<void>}
1254 */
1255 private setupApp;
1256 /** @type {A | undefined}*/
1257 app: A | undefined;
1258 /**
1259 * @private
1260 * @param {Stats | MultiStats} statsObj
1261 * @returns {StatsCompilation}
1262 */
1263 private getStats;
1264 /**
1265 * @private
1266 * @returns {void}
1267 */
1268 private setupHooks;
1269 /**
1270 * @private
1271 * @type {Stats | MultiStats}
1272 */
1273 private stats;
1274 /**
1275 * @private
1276 * @returns {void}
1277 */
1278 private setupWatchStaticFiles;
1279 /**
1280 * @private
1281 * @returns {void}
1282 */
1283 private setupWatchFiles;
1284 /**
1285 * @private
1286 * @returns {void}
1287 */
1288 private setupMiddlewares;
1289 /** @type {import("webpack-dev-middleware").API<Request, Response>} */
1290 middleware:
1291 | import("webpack-dev-middleware").API<
1292 import("express").Request<
1293 import("express-serve-static-core").ParamsDictionary,
1294 any,
1295 any,
1296 qs.ParsedQs,
1297 Record<string, any>
1298 >,
1299 import("express").Response<any, Record<string, any>>
1300 >
1301 | undefined;
1302 /**
1303 * @private
1304 * @returns {Promise<void>}
1305 */
1306 private createServer;
1307 /** @type {S | undefined}*/
1308 server: S | undefined;
1309 isTlsServer: boolean | undefined;
1310 /**
1311 * @private
1312 * @returns {void}
1313 */
1314 private createWebSocketServer;
1315 /** @type {WebSocketServerImplementation | undefined | null} */
1316 webSocketServer: WebSocketServerImplementation | undefined | null;
1317 /**
1318 * @private
1319 * @param {string} defaultOpenTarget
1320 * @returns {Promise<void>}
1321 */
1322 private openBrowser;
1323 /**
1324 * @private
1325 * @returns {void}
1326 */
1327 private runBonjour;
1328 /**
1329 * @private
1330 * @type {Bonjour | undefined}
1331 */
1332 private bonjour;
1333 /**
1334 * @private
1335 * @returns {void}
1336 */
1337 private stopBonjour;
1338 /**
1339 * @private
1340 * @returns {Promise<void>}
1341 */
1342 private logStatus;
1343 /**
1344 * @private
1345 * @param {Request} req
1346 * @param {Response} res
1347 * @param {NextFunction} next
1348 */
1349 private setHeaders;
1350 /**
1351 * @private
1352 * @param {{ [key: string]: string | undefined }} headers
1353 * @param {string} headerToCheck
1354 * @returns {boolean}
1355 */
1356 private checkHeader;
1357 /**
1358 * @param {ClientConnection[]} clients
1359 * @param {string} type
1360 * @param {any} [data]
1361 * @param {any} [params]
1362 */
1363 sendMessage(
1364 clients: ClientConnection[],
1365 type: string,
1366 data?: any,
1367 params?: any,
1368 ): void;
1369 /**
1370 * @private
1371 * @param {ClientConnection[]} clients
1372 * @param {StatsCompilation} stats
1373 * @param {boolean} [force]
1374 */
1375 private sendStats;
1376 /**
1377 * @param {string | string[]} watchPath
1378 * @param {WatchOptions} [watchOptions]
1379 */
1380 watchFiles(watchPath: string | string[], watchOptions?: WatchOptions): void;
1381 /**
1382 * @param {import("webpack-dev-middleware").Callback} [callback]
1383 */
1384 invalidate(callback?: import("webpack-dev-middleware").Callback): void;
1385 /**
1386 * @returns {Promise<void>}
1387 */
1388 start(): Promise<void>;
1389 /**
1390 * @param {(err?: Error) => void} [callback]
1391 */
1392 startCallback(callback?: (err?: Error) => void): void;
1393 /**
1394 * @returns {Promise<void>}
1395 */
1396 stop(): Promise<void>;
1397 /**
1398 * @param {(err?: Error) => void} [callback]
1399 */
1400 stopCallback(callback?: (err?: Error) => void): void;
1401}
1402declare namespace Server {
1403 export {
1404 DEFAULT_STATS,
1405 Schema,
1406 Compiler,
1407 MultiCompiler,
1408 WebpackConfiguration,
1409 StatsOptions,
1410 StatsCompilation,
1411 Stats,
1412 MultiStats,
1413 NetworkInterfaceInfo,
1414 WatchOptions,
1415 FSWatcher,
1416 ConnectHistoryApiFallbackOptions,
1417 Bonjour,
1418 BonjourOptions,
1419 RequestHandler,
1420 HttpProxyMiddlewareOptions,
1421 HttpProxyMiddlewareOptionsFilter,
1422 ServeIndexOptions,
1423 ServeStaticOptions,
1424 IPv4,
1425 IPv6,
1426 Socket,
1427 HTTPServer,
1428 IncomingMessage,
1429 ServerResponse,
1430 OpenOptions,
1431 ExpressApplication,
1432 ExpressRequestHandler,
1433 ExpressErrorRequestHandler,
1434 ExpressRequest,
1435 ExpressResponse,
1436 NextFunction,
1437 SimpleHandleFunction,
1438 NextHandleFunction,
1439 ErrorHandleFunction,
1440 HandleFunction,
1441 ServerOptions,
1442 Request,
1443 Response,
1444 DevMiddlewareOptions,
1445 DevMiddlewareContext,
1446 Host,
1447 Port,
1448 WatchFiles,
1449 Static,
1450 NormalizedStatic,
1451 ServerType,
1452 ServerConfiguration,
1453 WebSocketServerConfiguration,
1454 ClientConnection,
1455 WebSocketServer,
1456 WebSocketServerImplementation,
1457 ByPass,
1458 ProxyConfigArrayItem,
1459 ProxyConfigArray,
1460 OpenApp,
1461 Open,
1462 NormalizedOpen,
1463 WebSocketURL,
1464 OverlayMessageOptions,
1465 ClientConfiguration,
1466 Headers,
1467 MiddlewareHandler,
1468 MiddlewareObject,
1469 Middleware,
1470 BasicServer,
1471 Configuration,
1472 BasicApplication,
1473 };
1474}
1475declare class DEFAULT_STATS {
1476 private constructor();
1477}
1478type Schema = import("schema-utils/declarations/validate").Schema;
1479type Compiler = import("webpack").Compiler;
1480type MultiCompiler = import("webpack").MultiCompiler;
1481type WebpackConfiguration = import("webpack").Configuration;
1482type StatsOptions = import("webpack").StatsOptions;
1483type StatsCompilation = import("webpack").StatsCompilation;
1484type Stats = import("webpack").Stats;
1485type MultiStats = import("webpack").MultiStats;
1486type NetworkInterfaceInfo = import("os").NetworkInterfaceInfo;
1487type WatchOptions = import("chokidar").WatchOptions;
1488type FSWatcher = import("chokidar").FSWatcher;
1489type ConnectHistoryApiFallbackOptions =
1490 import("connect-history-api-fallback").Options;
1491type Bonjour = import("bonjour-service").Bonjour;
1492type BonjourOptions = import("bonjour-service").Service;
1493type RequestHandler = import("http-proxy-middleware").RequestHandler;
1494type HttpProxyMiddlewareOptions = import("http-proxy-middleware").Options;
1495type HttpProxyMiddlewareOptionsFilter = import("http-proxy-middleware").Filter;
1496type ServeIndexOptions = import("serve-index").Options;
1497type ServeStaticOptions = import("serve-static").ServeStaticOptions;
1498type IPv4 = import("ipaddr.js").IPv4;
1499type IPv6 = import("ipaddr.js").IPv6;
1500type Socket = import("net").Socket;
1501type HTTPServer = import("http").Server;
1502type IncomingMessage = import("http").IncomingMessage;
1503type ServerResponse = import("http").ServerResponse;
1504type OpenOptions = import("open").Options;
1505type ExpressApplication = import("express").Application;
1506type ExpressRequestHandler = import("express").RequestHandler;
1507type ExpressErrorRequestHandler = import("express").ErrorRequestHandler;
1508type ExpressRequest = import("express").Request;
1509type ExpressResponse = import("express").Response;
1510type NextFunction = (err?: any) => void;
1511type SimpleHandleFunction = (req: IncomingMessage, res: ServerResponse) => void;
1512type NextHandleFunction = (
1513 req: IncomingMessage,
1514 res: ServerResponse,
1515 next: NextFunction,
1516) => void;
1517type ErrorHandleFunction = (
1518 err: any,
1519 req: IncomingMessage,
1520 res: ServerResponse,
1521 next: NextFunction,
1522) => void;
1523type HandleFunction =
1524 | SimpleHandleFunction
1525 | NextHandleFunction
1526 | ErrorHandleFunction;
1527type ServerOptions = import("https").ServerOptions & {
1528 spdy?: {
1529 plain?: boolean | undefined;
1530 ssl?: boolean | undefined;
1531 "x-forwarded-for"?: string | undefined;
1532 protocol?: string | undefined;
1533 protocols?: string[] | undefined;
1534 };
1535};
1536type Request<T extends BasicApplication = import("express").Application> =
1537 T extends ExpressApplication ? ExpressRequest : IncomingMessage;
1538type Response<T extends BasicApplication = import("express").Application> =
1539 T extends ExpressApplication ? ExpressResponse : ServerResponse;
1540type DevMiddlewareOptions<
1541 T extends Request,
1542 U extends Response,
1543> = import("webpack-dev-middleware").Options<T, U>;
1544type DevMiddlewareContext<
1545 T extends Request,
1546 U extends Response,
1547> = import("webpack-dev-middleware").Context<T, U>;
1548type Host = "local-ip" | "local-ipv4" | "local-ipv6" | string;
1549type Port = number | string | "auto";
1550type WatchFiles = {
1551 paths: string | string[];
1552 options?:
1553 | (import("chokidar").WatchOptions & {
1554 aggregateTimeout?: number;
1555 ignored?: WatchOptions["ignored"];
1556 poll?: number | boolean;
1557 })
1558 | undefined;
1559};
1560type Static = {
1561 directory?: string | undefined;
1562 publicPath?: string | string[] | undefined;
1563 serveIndex?: boolean | import("serve-index").Options | undefined;
1564 staticOptions?:
1565 | import("serve-static").ServeStaticOptions<
1566 import("http").ServerResponse<import("http").IncomingMessage>
1567 >
1568 | undefined;
1569 watch?:
1570 | boolean
1571 | (import("chokidar").WatchOptions & {
1572 aggregateTimeout?: number;
1573 ignored?: WatchOptions["ignored"];
1574 poll?: number | boolean;
1575 })
1576 | undefined;
1577};
1578type NormalizedStatic = {
1579 directory: string;
1580 publicPath: string[];
1581 serveIndex: false | ServeIndexOptions;
1582 staticOptions: ServeStaticOptions;
1583 watch: false | WatchOptions;
1584};
1585type ServerType<
1586 A extends BasicApplication = import("express").Application,
1587 S extends BasicServer = import("http").Server<
1588 typeof import("http").IncomingMessage,
1589 typeof import("http").ServerResponse
1590 >,
1591> =
1592 | "http"
1593 | "https"
1594 | "spdy"
1595 | "http2"
1596 | string
1597 | ((arg0: ServerOptions, arg1: A) => S);
1598type ServerConfiguration<
1599 A extends BasicApplication = import("express").Application,
1600 S extends BasicServer = import("http").Server<
1601 typeof import("http").IncomingMessage,
1602 typeof import("http").ServerResponse
1603 >,
1604> = {
1605 type?: ServerType<A, S> | undefined;
1606 options?: ServerOptions | undefined;
1607};
1608type WebSocketServerConfiguration = {
1609 type?: string | Function | undefined;
1610 options?: Record<string, any> | undefined;
1611};
1612type ClientConnection = (
1613 | import("ws").WebSocket
1614 | (import("sockjs").Connection & {
1615 send: import("ws").WebSocket["send"];
1616 terminate: import("ws").WebSocket["terminate"];
1617 ping: import("ws").WebSocket["ping"];
1618 })
1619) & {
1620 isAlive?: boolean;
1621};
1622type WebSocketServer =
1623 | import("ws").WebSocketServer
1624 | (import("sockjs").Server & {
1625 close: import("ws").WebSocketServer["close"];
1626 });
1627type WebSocketServerImplementation = {
1628 implementation: WebSocketServer;
1629 clients: ClientConnection[];
1630};
1631type ByPass = (
1632 req: Request,
1633 res: Response,
1634 proxyConfig: ProxyConfigArrayItem,
1635) => any;
1636type ProxyConfigArrayItem = {
1637 path?: HttpProxyMiddlewareOptionsFilter | undefined;
1638 context?: HttpProxyMiddlewareOptionsFilter | undefined;
1639} & {
1640 bypass?: ByPass;
1641} & HttpProxyMiddlewareOptions;
1642type ProxyConfigArray = (
1643 | ProxyConfigArrayItem
1644 | ((
1645 req?: Request | undefined,
1646 res?: Response | undefined,
1647 next?: NextFunction | undefined,
1648 ) => ProxyConfigArrayItem)
1649)[];
1650type OpenApp = {
1651 name?: string | undefined;
1652 arguments?: string[] | undefined;
1653};
1654type Open = {
1655 app?: string | string[] | OpenApp | undefined;
1656 target?: string | string[] | undefined;
1657};
1658type NormalizedOpen = {
1659 target: string;
1660 options: import("open").Options;
1661};
1662type WebSocketURL = {
1663 hostname?: string | undefined;
1664 password?: string | undefined;
1665 pathname?: string | undefined;
1666 port?: string | number | undefined;
1667 protocol?: string | undefined;
1668 username?: string | undefined;
1669};
1670type OverlayMessageOptions = boolean | ((error: Error) => void);
1671type ClientConfiguration = {
1672 logging?: "none" | "error" | "warn" | "info" | "log" | "verbose" | undefined;
1673 overlay?:
1674 | boolean
1675 | {
1676 warnings?: OverlayMessageOptions;
1677 errors?: OverlayMessageOptions;
1678 runtimeErrors?: OverlayMessageOptions;
1679 }
1680 | undefined;
1681 progress?: boolean | undefined;
1682 reconnect?: number | boolean | undefined;
1683 webSocketTransport?: string | undefined;
1684 webSocketURL?: string | WebSocketURL | undefined;
1685};
1686type Headers =
1687 | Array<{
1688 key: string;
1689 value: string;
1690 }>
1691 | Record<string, string | string[]>;
1692type MiddlewareHandler<
1693 T extends BasicApplication = import("express").Application,
1694> = T extends ExpressApplication
1695 ? ExpressRequestHandler | ExpressErrorRequestHandler
1696 : HandleFunction;
1697type MiddlewareObject = {
1698 name?: string;
1699 path?: string;
1700 middleware: MiddlewareHandler;
1701};
1702type Middleware = MiddlewareObject | MiddlewareHandler;
1703type BasicServer = import("net").Server | import("tls").Server;
1704type Configuration<
1705 A extends BasicApplication = import("express").Application,
1706 S extends BasicServer = import("http").Server<
1707 typeof import("http").IncomingMessage,
1708 typeof import("http").ServerResponse
1709 >,
1710> = {
1711 ipc?: string | boolean | undefined;
1712 host?: string | undefined;
1713 port?: Port | undefined;
1714 hot?: boolean | "only" | undefined;
1715 liveReload?: boolean | undefined;
1716 devMiddleware?:
1717 | DevMiddlewareOptions<
1718 import("express").Request<
1719 import("express-serve-static-core").ParamsDictionary,
1720 any,
1721 any,
1722 qs.ParsedQs,
1723 Record<string, any>
1724 >,
1725 import("express").Response<any, Record<string, any>>
1726 >
1727 | undefined;
1728 compress?: boolean | undefined;
1729 allowedHosts?: string | string[] | undefined;
1730 historyApiFallback?:
1731 | boolean
1732 | import("connect-history-api-fallback").Options
1733 | undefined;
1734 bonjour?:
1735 | boolean
1736 | Record<string, never>
1737 | import("bonjour-service").Service
1738 | undefined;
1739 watchFiles?:
1740 | string
1741 | string[]
1742 | WatchFiles
1743 | (string | WatchFiles)[]
1744 | undefined;
1745 static?: string | boolean | Static | (string | Static)[] | undefined;
1746 server?: ServerType<A, S> | ServerConfiguration<A, S> | undefined;
1747 app?: (() => Promise<A>) | undefined;
1748 webSocketServer?: string | boolean | WebSocketServerConfiguration | undefined;
1749 proxy?: ProxyConfigArray | undefined;
1750 open?: string | boolean | Open | (string | Open)[] | undefined;
1751 setupExitSignals?: boolean | undefined;
1752 client?: boolean | ClientConfiguration | undefined;
1753 headers?:
1754 | Headers
1755 | ((
1756 req: Request,
1757 res: Response,
1758 context: DevMiddlewareContext<Request, Response> | undefined,
1759 ) => Headers)
1760 | undefined;
1761 onListening?: ((devServer: Server<A, S>) => void) | undefined;
1762 setupMiddlewares?:
1763 | ((middlewares: Middleware[], devServer: Server<A, S>) => Middleware[])
1764 | undefined;
1765};
1766type BasicApplication = {
1767 use: typeof useFn;
1768};
1769/**
1770 * @overload
1771 * @param {NextHandleFunction} fn
1772 * @returns {BasicApplication}
1773 */
1774declare function useFn(fn: NextHandleFunction): BasicApplication;
1775/**
1776 * @overload
1777 * @param {HandleFunction} fn
1778 * @returns {BasicApplication}
1779 */
1780declare function useFn(fn: HandleFunction): BasicApplication;
1781/**
1782 * @overload
1783 * @param {string} route
1784 * @param {NextHandleFunction} fn
1785 * @returns {BasicApplication}
1786 */
1787declare function useFn(route: string, fn: NextHandleFunction): BasicApplication;
1788
1789// DO NOT REMOVE THIS!
1790type DevServerConfiguration = Configuration;
1791declare module "webpack" {
1792 interface Configuration {
1793 /**
1794 * Can be used to configure the behaviour of webpack-dev-server when
1795 * the webpack config is passed to webpack-dev-server CLI.
1796 */
1797 devServer?: DevServerConfiguration | undefined;
1798 }
1799}
1800
\No newline at end of file