webpack-dev-server 5.0.3 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,28 @@
1
- /// <reference types="node" />
2
1
  export = Server;
3
- declare class Server {
2
+ /**
3
+ * @typedef {Object} BasicApplication
4
+ * @property {typeof useFn} use
5
+ */
6
+ /**
7
+ * @template {BasicApplication} [A=ExpressApplication]
8
+ * @template {BasicServer} [S=HTTPServer]
9
+ */
10
+ declare 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
+ > {
4
17
  static get schema(): {
5
18
  title: string;
6
19
  type: string;
7
20
  definitions: {
21
+ App: {
22
+ instanceof: string;
23
+ description: string;
24
+ link: string;
25
+ };
8
26
  AllowedHosts: {
9
27
  anyOf: (
10
28
  | {
@@ -49,7 +67,7 @@ declare class Server {
49
67
  link?: undefined;
50
68
  }
51
69
  | {
52
- type: string /** @typedef {import("express").ErrorRequestHandler} ExpressErrorRequestHandler */;
70
+ type: string;
53
71
  description: string;
54
72
  link: string;
55
73
  cli?: undefined;
@@ -78,149 +96,6 @@ declare class Server {
78
96
  logging: {
79
97
  $ref: string;
80
98
  };
81
- /** @typedef {import("net").Socket} Socket */
82
- /** @typedef {import("http").IncomingMessage} IncomingMessage */
83
- /** @typedef {import("http").ServerResponse} ServerResponse */
84
- /** @typedef {import("open").Options} OpenOptions */
85
- /** @typedef {import("https").ServerOptions & { spdy?: { plain?: boolean | undefined, ssl?: boolean | undefined, 'x-forwarded-for'?: string | undefined, protocol?: string | undefined, protocols?: string[] | undefined }}} ServerOptions */
86
- /** @typedef {import("express").Request} Request */
87
- /** @typedef {import("express").Response} Response */
88
- /**
89
- * @template {Request} T
90
- * @template {Response} U
91
- * @typedef {import("webpack-dev-middleware").Options<T, U>} DevMiddlewareOptions
92
- */
93
- /**
94
- * @template {Request} T
95
- * @template {Response} U
96
- * @typedef {import("webpack-dev-middleware").Context<T, U>} DevMiddlewareContext
97
- */
98
- /**
99
- * @typedef {"local-ip" | "local-ipv4" | "local-ipv6" | string} Host
100
- */
101
- /**
102
- * @typedef {number | string | "auto"} Port
103
- */
104
- /**
105
- * @typedef {Object} WatchFiles
106
- * @property {string | string[]} paths
107
- * @property {WatchOptions & { aggregateTimeout?: number, ignored?: WatchOptions["ignored"], poll?: number | boolean }} [options]
108
- */
109
- /**
110
- * @typedef {Object} Static
111
- * @property {string} [directory]
112
- * @property {string | string[]} [publicPath]
113
- * @property {boolean | ServeIndexOptions} [serveIndex]
114
- * @property {ServeStaticOptions} [staticOptions]
115
- * @property {boolean | WatchOptions & { aggregateTimeout?: number, ignored?: WatchOptions["ignored"], poll?: number | boolean }} [watch]
116
- */
117
- /**
118
- * @typedef {Object} NormalizedStatic
119
- * @property {string} directory
120
- * @property {string[]} publicPath
121
- * @property {false | ServeIndexOptions} serveIndex
122
- * @property {ServeStaticOptions} staticOptions
123
- * @property {false | WatchOptions} watch
124
- */
125
- /**
126
- * @typedef {Object} ServerConfiguration
127
- * @property {"http" | "https" | "spdy" | string} [type]
128
- * @property {ServerOptions} [options]
129
- */
130
- /**
131
- * @typedef {Object} WebSocketServerConfiguration
132
- * @property {"sockjs" | "ws" | string | Function} [type]
133
- * @property {Record<string, any>} [options]
134
- */
135
- /**
136
- * @typedef {(import("ws").WebSocket | import("sockjs").Connection & { send: import("ws").WebSocket["send"], terminate: import("ws").WebSocket["terminate"], ping: import("ws").WebSocket["ping"] }) & { isAlive?: boolean }} ClientConnection
137
- */
138
- /**
139
- * @typedef {import("ws").WebSocketServer | import("sockjs").Server & { close: import("ws").WebSocketServer["close"] }} WebSocketServer
140
- */
141
- /**
142
- * @typedef {{ implementation: WebSocketServer, clients: ClientConnection[] }} WebSocketServerImplementation
143
- */
144
- /**
145
- * @callback ByPass
146
- * @param {Request} req
147
- * @param {Response} res
148
- * @param {ProxyConfigArrayItem} proxyConfig
149
- */
150
- /**
151
- * @typedef {{ path?: HttpProxyMiddlewareOptionsFilter | undefined, context?: HttpProxyMiddlewareOptionsFilter | undefined } & { bypass?: ByPass } & HttpProxyMiddlewareOptions } ProxyConfigArrayItem
152
- */
153
- /**
154
- * @typedef {(ProxyConfigArrayItem | ((req?: Request | undefined, res?: Response | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem))[]} ProxyConfigArray
155
- */
156
- /**
157
- * @typedef {Object} OpenApp
158
- * @property {string} [name]
159
- * @property {string[]} [arguments]
160
- */
161
- /**
162
- * @typedef {Object} Open
163
- * @property {string | string[] | OpenApp} [app]
164
- * @property {string | string[]} [target]
165
- */
166
- /**
167
- * @typedef {Object} NormalizedOpen
168
- * @property {string} target
169
- * @property {import("open").Options} options
170
- */
171
- /**
172
- * @typedef {Object} WebSocketURL
173
- * @property {string} [hostname]
174
- * @property {string} [password]
175
- * @property {string} [pathname]
176
- * @property {number | string} [port]
177
- * @property {string} [protocol]
178
- * @property {string} [username]
179
- */
180
- /**
181
- * @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
182
- */
183
- /**
184
- * @typedef {Object} ClientConfiguration
185
- * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging]
186
- * @property {boolean | { warnings?: OverlayMessageOptions, errors?: OverlayMessageOptions, runtimeErrors?: OverlayMessageOptions }} [overlay]
187
- * @property {boolean} [progress]
188
- * @property {boolean | number} [reconnect]
189
- * @property {"ws" | "sockjs" | string} [webSocketTransport]
190
- * @property {string | WebSocketURL} [webSocketURL]
191
- */
192
- /**
193
- * @typedef {Array<{ key: string; value: string }> | Record<string, string | string[]>} Headers
194
- */
195
- /**
196
- * @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware
197
- */
198
- /**
199
- * @typedef {Object} Configuration
200
- * @property {boolean | string} [ipc]
201
- * @property {Host} [host]
202
- * @property {Port} [port]
203
- * @property {boolean | "only"} [hot]
204
- * @property {boolean} [liveReload]
205
- * @property {DevMiddlewareOptions<Request, Response>} [devMiddleware]
206
- * @property {boolean} [compress]
207
- * @property {"auto" | "all" | string | string[]} [allowedHosts]
208
- * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback]
209
- * @property {boolean | Record<string, never> | BonjourOptions} [bonjour]
210
- * @property {string | string[] | WatchFiles | Array<string | WatchFiles>} [watchFiles]
211
- * @property {boolean | string | Static | Array<string | Static>} [static]
212
- * @property {boolean | ServerOptions} [https]
213
- * @property {boolean} [http2]
214
- * @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
215
- * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
216
- * @property {ProxyConfigArray} [proxy]
217
- * @property {boolean | string | Open | Array<string | Open>} [open]
218
- * @property {boolean} [setupExitSignals]
219
- * @property {boolean | ClientConfiguration} [client]
220
- * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
221
- * @property {(devServer: Server) => void} [onListening]
222
- * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
223
- */
224
99
  overlay: {
225
100
  $ref: string;
226
101
  };
@@ -292,9 +167,7 @@ declare class Server {
292
167
  instanceof?: undefined;
293
168
  }
294
169
  | {
295
- instanceof: string /**
296
- * @typedef {import("ws").WebSocketServer | import("sockjs").Server & { close: import("ws").WebSocketServer["close"] }} WebSocketServer
297
- */;
170
+ instanceof: string;
298
171
  description: string;
299
172
  type?: undefined;
300
173
  cli?: undefined;
@@ -333,7 +206,8 @@ declare class Server {
333
206
  ClientProgress: {
334
207
  description: string;
335
208
  link: string;
336
- type: string;
209
+ type: string[];
210
+ enum: (string | boolean)[];
337
211
  cli: {
338
212
  negatedDescription: string;
339
213
  };
@@ -357,35 +231,6 @@ declare class Server {
357
231
  )[];
358
232
  };
359
233
  ClientWebSocketTransport: {
360
- /**
361
- * @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware
362
- */
363
- /**
364
- * @typedef {Object} Configuration
365
- * @property {boolean | string} [ipc]
366
- * @property {Host} [host]
367
- * @property {Port} [port]
368
- * @property {boolean | "only"} [hot]
369
- * @property {boolean} [liveReload]
370
- * @property {DevMiddlewareOptions<Request, Response>} [devMiddleware]
371
- * @property {boolean} [compress]
372
- * @property {"auto" | "all" | string | string[]} [allowedHosts]
373
- * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback]
374
- * @property {boolean | Record<string, never> | BonjourOptions} [bonjour]
375
- * @property {string | string[] | WatchFiles | Array<string | WatchFiles>} [watchFiles]
376
- * @property {boolean | string | Static | Array<string | Static>} [static]
377
- * @property {boolean | ServerOptions} [https]
378
- * @property {boolean} [http2]
379
- * @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
380
- * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
381
- * @property {ProxyConfigArray} [proxy]
382
- * @property {boolean | string | Open | Array<string | Open>} [open]
383
- * @property {boolean} [setupExitSignals]
384
- * @property {boolean | ClientConfiguration} [client]
385
- * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
386
- * @property {(devServer: Server) => void} [onListening]
387
- * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
388
- */
389
234
  anyOf: {
390
235
  $ref: string;
391
236
  }[];
@@ -479,9 +324,6 @@ declare class Server {
479
324
  };
480
325
  HeaderObject: {
481
326
  type: string;
482
- /**
483
- * @type {FSWatcher[]}
484
- */
485
327
  additionalProperties: boolean;
486
328
  properties: {
487
329
  key: {
@@ -731,7 +573,7 @@ declare class Server {
731
573
  }
732
574
  )[];
733
575
  description: string;
734
- link: string /** @type {WebSocketURL} */;
576
+ link: string;
735
577
  };
736
578
  Proxy: {
737
579
  type: string;
@@ -743,7 +585,6 @@ declare class Server {
743
585
  }
744
586
  | {
745
587
  instanceof: string;
746
- /** @type {{ type: WebSocketServerConfiguration["type"], options: NonNullable<WebSocketServerConfiguration["options"]> }} */
747
588
  type?: undefined;
748
589
  }
749
590
  )[];
@@ -761,6 +602,9 @@ declare class Server {
761
602
  ServerType: {
762
603
  enum: string[];
763
604
  };
605
+ ServerFn: {
606
+ instanceof: string;
607
+ };
764
608
  ServerEnum: {
765
609
  enum: string[];
766
610
  cli: {
@@ -770,7 +614,6 @@ declare class Server {
770
614
  ServerString: {
771
615
  type: string;
772
616
  minLength: number;
773
- /** @type {string} */
774
617
  cli: {
775
618
  exclude: boolean;
776
619
  };
@@ -1259,6 +1102,9 @@ declare class Server {
1259
1102
  server: {
1260
1103
  $ref: string;
1261
1104
  };
1105
+ app: {
1106
+ $ref: string;
1107
+ };
1262
1108
  setupExitSignals: {
1263
1109
  $ref: string;
1264
1110
  };
@@ -1282,10 +1128,14 @@ declare class Server {
1282
1128
  */
1283
1129
  static isAbsoluteURL(URL: string): boolean;
1284
1130
  /**
1285
- * @param {string} gateway
1131
+ * @param {string} gatewayOrFamily or family
1132
+ * @param {boolean} [isInternal] ip should be internal
1286
1133
  * @returns {string | undefined}
1287
1134
  */
1288
- static findIp(gateway: string): string | undefined;
1135
+ static findIp(
1136
+ gatewayOrFamily: string,
1137
+ isInternal?: boolean | undefined,
1138
+ ): string | undefined;
1289
1139
  /**
1290
1140
  * @param {"v4" | "v6"} family
1291
1141
  * @returns {Promise<string | undefined>}
@@ -1318,23 +1168,19 @@ declare class Server {
1318
1168
  */
1319
1169
  private static isWebTarget;
1320
1170
  /**
1321
- * @param {Configuration | Compiler | MultiCompiler} options
1322
- * @param {Compiler | MultiCompiler | Configuration} compiler
1171
+ * @param {Configuration<A, S>} options
1172
+ * @param {Compiler | MultiCompiler} compiler
1323
1173
  */
1324
1174
  constructor(
1325
- options:
1326
- | import("webpack").Compiler
1327
- | import("webpack").MultiCompiler
1328
- | Configuration
1329
- | undefined,
1330
- compiler: Compiler | MultiCompiler | Configuration,
1175
+ options: Configuration<A, S> | undefined,
1176
+ compiler: Compiler | MultiCompiler,
1331
1177
  );
1332
1178
  compiler: import("webpack").Compiler | import("webpack").MultiCompiler;
1333
1179
  /**
1334
1180
  * @type {ReturnType<Compiler["getInfrastructureLogger"]>}
1335
1181
  * */
1336
1182
  logger: ReturnType<Compiler["getInfrastructureLogger"]>;
1337
- options: Configuration;
1183
+ options: Configuration<A, S>;
1338
1184
  /**
1339
1185
  * @type {FSWatcher[]}
1340
1186
  */
@@ -1379,8 +1225,9 @@ declare class Server {
1379
1225
  */
1380
1226
  private getClientTransport;
1381
1227
  /**
1228
+ * @template T
1382
1229
  * @private
1383
- * @returns {string}
1230
+ * @returns {T}
1384
1231
  */
1385
1232
  private getServerTransport;
1386
1233
  /**
@@ -1395,11 +1242,11 @@ declare class Server {
1395
1242
  private initialize;
1396
1243
  /**
1397
1244
  * @private
1398
- * @returns {void}
1245
+ * @returns {Promise<void>}
1399
1246
  */
1400
1247
  private setupApp;
1401
- /** @type {import("express").Application | undefined}*/
1402
- app: import("express").Application | undefined;
1248
+ /** @type {A | undefined}*/
1249
+ app: A | undefined;
1403
1250
  /**
1404
1251
  * @private
1405
1252
  * @param {Stats | MultiStats} statsObj
@@ -1420,12 +1267,18 @@ declare class Server {
1420
1267
  * @private
1421
1268
  * @returns {void}
1422
1269
  */
1423
- private setupHostHeaderCheck;
1270
+ private setupWatchStaticFiles;
1271
+ /**
1272
+ * @private
1273
+ * @returns {void}
1274
+ */
1275
+ private setupWatchFiles;
1424
1276
  /**
1425
1277
  * @private
1426
1278
  * @returns {void}
1427
1279
  */
1428
- private setupDevMiddleware;
1280
+ private setupMiddlewares;
1281
+ /** @type {import("webpack-dev-middleware").API<Request, Response>} */
1429
1282
  middleware:
1430
1283
  | import("webpack-dev-middleware").API<
1431
1284
  import("express").Request<
@@ -1437,35 +1290,15 @@ declare class Server {
1437
1290
  >,
1438
1291
  import("express").Response<any, Record<string, any>>
1439
1292
  >
1440
- | null
1441
1293
  | undefined;
1442
1294
  /**
1443
1295
  * @private
1444
- * @returns {void}
1445
- */
1446
- private setupBuiltInRoutes;
1447
- /**
1448
- * @private
1449
- * @returns {void}
1450
- */
1451
- private setupWatchStaticFiles;
1452
- /**
1453
- * @private
1454
- * @returns {void}
1455
- */
1456
- private setupWatchFiles;
1457
- /**
1458
- * @private
1459
- * @returns {void}
1460
- */
1461
- private setupMiddlewares;
1462
- /**
1463
- * @private
1464
- * @returns {void}
1296
+ * @returns {Promise<void>}
1465
1297
  */
1466
1298
  private createServer;
1467
- /** @type {import("http").Server | undefined | null} */
1468
- server: import("http").Server | undefined | null;
1299
+ /** @type {S | undefined}*/
1300
+ server: S | undefined;
1301
+ isTlsServer: boolean | undefined;
1469
1302
  /**
1470
1303
  * @private
1471
1304
  * @returns {void}
@@ -1575,9 +1408,6 @@ declare namespace Server {
1575
1408
  Stats,
1576
1409
  MultiStats,
1577
1410
  NetworkInterfaceInfo,
1578
- NextFunction,
1579
- ExpressRequestHandler,
1580
- ExpressErrorRequestHandler,
1581
1411
  WatchOptions,
1582
1412
  FSWatcher,
1583
1413
  ConnectHistoryApiFallbackOptions,
@@ -1591,9 +1421,20 @@ declare namespace Server {
1591
1421
  IPv4,
1592
1422
  IPv6,
1593
1423
  Socket,
1424
+ HTTPServer,
1594
1425
  IncomingMessage,
1595
1426
  ServerResponse,
1596
1427
  OpenOptions,
1428
+ ExpressApplication,
1429
+ ExpressRequestHandler,
1430
+ ExpressErrorRequestHandler,
1431
+ ExpressRequest,
1432
+ ExpressResponse,
1433
+ NextFunction,
1434
+ SimpleHandleFunction,
1435
+ NextHandleFunction,
1436
+ ErrorHandleFunction,
1437
+ HandleFunction,
1597
1438
  ServerOptions,
1598
1439
  Request,
1599
1440
  Response,
@@ -1604,6 +1445,7 @@ declare namespace Server {
1604
1445
  WatchFiles,
1605
1446
  Static,
1606
1447
  NormalizedStatic,
1448
+ ServerType,
1607
1449
  ServerConfiguration,
1608
1450
  WebSocketServerConfiguration,
1609
1451
  ClientConnection,
@@ -1619,21 +1461,19 @@ declare namespace Server {
1619
1461
  OverlayMessageOptions,
1620
1462
  ClientConfiguration,
1621
1463
  Headers,
1464
+ MiddlewareHandler,
1465
+ MiddlewareObject,
1622
1466
  Middleware,
1467
+ BasicServer,
1623
1468
  Configuration,
1469
+ BasicApplication,
1624
1470
  };
1625
1471
  }
1626
- type Compiler = import("webpack").Compiler;
1627
- type FSWatcher = import("chokidar").FSWatcher;
1628
- type Socket = import("net").Socket;
1629
- type WebSocketServerImplementation = {
1630
- implementation: WebSocketServer;
1631
- clients: ClientConnection[];
1632
- };
1633
1472
  declare class DEFAULT_STATS {
1634
1473
  private constructor();
1635
1474
  }
1636
1475
  type Schema = import("schema-utils/declarations/validate").Schema;
1476
+ type Compiler = import("webpack").Compiler;
1637
1477
  type MultiCompiler = import("webpack").MultiCompiler;
1638
1478
  type WebpackConfiguration = import("webpack").Configuration;
1639
1479
  type StatsOptions = import("webpack").StatsOptions;
@@ -1641,10 +1481,8 @@ type StatsCompilation = import("webpack").StatsCompilation;
1641
1481
  type Stats = import("webpack").Stats;
1642
1482
  type MultiStats = import("webpack").MultiStats;
1643
1483
  type NetworkInterfaceInfo = import("os").NetworkInterfaceInfo;
1644
- type NextFunction = import("express").NextFunction;
1645
- type ExpressRequestHandler = import("express").RequestHandler;
1646
- type ExpressErrorRequestHandler = import("express").ErrorRequestHandler;
1647
1484
  type WatchOptions = import("chokidar").WatchOptions;
1485
+ type FSWatcher = import("chokidar").FSWatcher;
1648
1486
  type ConnectHistoryApiFallbackOptions =
1649
1487
  import("connect-history-api-fallback").Options;
1650
1488
  type Bonjour = import("bonjour-service").Bonjour;
@@ -1656,9 +1494,33 @@ type ServeIndexOptions = import("serve-index").Options;
1656
1494
  type ServeStaticOptions = import("serve-static").ServeStaticOptions;
1657
1495
  type IPv4 = import("ipaddr.js").IPv4;
1658
1496
  type IPv6 = import("ipaddr.js").IPv6;
1497
+ type Socket = import("net").Socket;
1498
+ type HTTPServer = import("http").Server;
1659
1499
  type IncomingMessage = import("http").IncomingMessage;
1660
1500
  type ServerResponse = import("http").ServerResponse;
1661
1501
  type OpenOptions = import("open").Options;
1502
+ type ExpressApplication = import("express").Application;
1503
+ type ExpressRequestHandler = import("express").RequestHandler;
1504
+ type ExpressErrorRequestHandler = import("express").ErrorRequestHandler;
1505
+ type ExpressRequest = import("express").Request;
1506
+ type ExpressResponse = import("express").Response;
1507
+ type NextFunction = (err?: any) => void;
1508
+ type SimpleHandleFunction = (req: IncomingMessage, res: ServerResponse) => void;
1509
+ type NextHandleFunction = (
1510
+ req: IncomingMessage,
1511
+ res: ServerResponse,
1512
+ next: NextFunction,
1513
+ ) => void;
1514
+ type ErrorHandleFunction = (
1515
+ err: any,
1516
+ req: IncomingMessage,
1517
+ res: ServerResponse,
1518
+ next: NextFunction,
1519
+ ) => void;
1520
+ type HandleFunction =
1521
+ | SimpleHandleFunction
1522
+ | NextHandleFunction
1523
+ | ErrorHandleFunction;
1662
1524
  type ServerOptions = import("https").ServerOptions & {
1663
1525
  spdy?: {
1664
1526
  plain?: boolean | undefined;
@@ -1668,27 +1530,17 @@ type ServerOptions = import("https").ServerOptions & {
1668
1530
  protocols?: string[] | undefined;
1669
1531
  };
1670
1532
  };
1671
- type Request = import("express").Request;
1672
- type Response = import("express").Response;
1533
+ type Request<T extends BasicApplication = import("express").Application> =
1534
+ T extends ExpressApplication ? ExpressRequest : IncomingMessage;
1535
+ type Response<T extends BasicApplication = import("express").Application> =
1536
+ T extends ExpressApplication ? ExpressResponse : ServerResponse;
1673
1537
  type DevMiddlewareOptions<
1674
- T extends import("express").Request<
1675
- import("express-serve-static-core").ParamsDictionary,
1676
- any,
1677
- any,
1678
- qs.ParsedQs,
1679
- Record<string, any>
1680
- >,
1681
- U extends import("express").Response<any, Record<string, any>>,
1538
+ T extends Request,
1539
+ U extends Response,
1682
1540
  > = import("webpack-dev-middleware").Options<T, U>;
1683
1541
  type DevMiddlewareContext<
1684
- T extends import("express").Request<
1685
- import("express-serve-static-core").ParamsDictionary,
1686
- any,
1687
- any,
1688
- qs.ParsedQs,
1689
- Record<string, any>
1690
- >,
1691
- U extends import("express").Response<any, Record<string, any>>,
1542
+ T extends Request,
1543
+ U extends Response,
1692
1544
  > = import("webpack-dev-middleware").Context<T, U>;
1693
1545
  type Host = "local-ip" | "local-ipv4" | "local-ipv6" | string;
1694
1546
  type Port = number | string | "auto";
@@ -1696,9 +1548,9 @@ type WatchFiles = {
1696
1548
  paths: string | string[];
1697
1549
  options?:
1698
1550
  | (import("chokidar").WatchOptions & {
1699
- aggregateTimeout?: number | undefined;
1551
+ aggregateTimeout?: number;
1700
1552
  ignored?: WatchOptions["ignored"];
1701
- poll?: number | boolean | undefined;
1553
+ poll?: number | boolean;
1702
1554
  })
1703
1555
  | undefined;
1704
1556
  };
@@ -1714,9 +1566,9 @@ type Static = {
1714
1566
  watch?:
1715
1567
  | boolean
1716
1568
  | (import("chokidar").WatchOptions & {
1717
- aggregateTimeout?: number | undefined;
1569
+ aggregateTimeout?: number;
1718
1570
  ignored?: WatchOptions["ignored"];
1719
- poll?: number | boolean | undefined;
1571
+ poll?: number | boolean;
1720
1572
  })
1721
1573
  | undefined;
1722
1574
  };
@@ -1727,8 +1579,27 @@ type NormalizedStatic = {
1727
1579
  staticOptions: ServeStaticOptions;
1728
1580
  watch: false | WatchOptions;
1729
1581
  };
1730
- type ServerConfiguration = {
1731
- type?: string | undefined;
1582
+ type ServerType<
1583
+ A extends BasicApplication = import("express").Application,
1584
+ S extends BasicServer = import("http").Server<
1585
+ typeof import("http").IncomingMessage,
1586
+ typeof import("http").ServerResponse
1587
+ >,
1588
+ > =
1589
+ | "http"
1590
+ | "https"
1591
+ | "spdy"
1592
+ | "http2"
1593
+ | string
1594
+ | ((arg0: ServerOptions, arg1: A) => S);
1595
+ type ServerConfiguration<
1596
+ A extends BasicApplication = import("express").Application,
1597
+ S extends BasicServer = import("http").Server<
1598
+ typeof import("http").IncomingMessage,
1599
+ typeof import("http").ServerResponse
1600
+ >,
1601
+ > = {
1602
+ type?: ServerType<A, S> | undefined;
1732
1603
  options?: ServerOptions | undefined;
1733
1604
  };
1734
1605
  type WebSocketServerConfiguration = {
@@ -1750,6 +1621,10 @@ type WebSocketServer =
1750
1621
  | (import("sockjs").Server & {
1751
1622
  close: import("ws").WebSocketServer["close"];
1752
1623
  });
1624
+ type WebSocketServerImplementation = {
1625
+ implementation: WebSocketServer;
1626
+ clients: ClientConnection[];
1627
+ };
1753
1628
  type ByPass = (
1754
1629
  req: Request,
1755
1630
  res: Response,
@@ -1795,9 +1670,9 @@ type ClientConfiguration = {
1795
1670
  overlay?:
1796
1671
  | boolean
1797
1672
  | {
1798
- warnings?: OverlayMessageOptions | undefined;
1799
- errors?: OverlayMessageOptions | undefined;
1800
- runtimeErrors?: OverlayMessageOptions | undefined;
1673
+ warnings?: OverlayMessageOptions;
1674
+ errors?: OverlayMessageOptions;
1675
+ runtimeErrors?: OverlayMessageOptions;
1801
1676
  }
1802
1677
  | undefined;
1803
1678
  progress?: boolean | undefined;
@@ -1811,15 +1686,25 @@ type Headers =
1811
1686
  value: string;
1812
1687
  }>
1813
1688
  | Record<string, string | string[]>;
1814
- type Middleware =
1815
- | {
1816
- name?: string;
1817
- path?: string;
1818
- middleware: ExpressRequestHandler | ExpressErrorRequestHandler;
1819
- }
1820
- | ExpressRequestHandler
1821
- | ExpressErrorRequestHandler;
1822
- type Configuration = {
1689
+ type MiddlewareHandler<
1690
+ T extends BasicApplication = import("express").Application,
1691
+ > = T extends ExpressApplication
1692
+ ? ExpressRequestHandler | ExpressErrorRequestHandler
1693
+ : HandleFunction;
1694
+ type MiddlewareObject = {
1695
+ name?: string;
1696
+ path?: string;
1697
+ middleware: MiddlewareHandler;
1698
+ };
1699
+ type Middleware = MiddlewareObject | MiddlewareHandler;
1700
+ type BasicServer = import("net").Server | import("tls").Server;
1701
+ type Configuration<
1702
+ A extends BasicApplication = import("express").Application,
1703
+ S extends BasicServer = import("http").Server<
1704
+ typeof import("http").IncomingMessage,
1705
+ typeof import("http").ServerResponse
1706
+ >,
1707
+ > = {
1823
1708
  ipc?: string | boolean | undefined;
1824
1709
  host?: string | undefined;
1825
1710
  port?: Port | undefined;
@@ -1855,9 +1740,8 @@ type Configuration = {
1855
1740
  | (string | WatchFiles)[]
1856
1741
  | undefined;
1857
1742
  static?: string | boolean | Static | (string | Static)[] | undefined;
1858
- https?: boolean | ServerOptions | undefined;
1859
- http2?: boolean | undefined;
1860
- server?: string | ServerConfiguration | undefined;
1743
+ server?: ServerType<A, S> | ServerConfiguration<A, S> | undefined;
1744
+ app?: (() => Promise<A>) | undefined;
1861
1745
  webSocketServer?: string | boolean | WebSocketServerConfiguration | undefined;
1862
1746
  proxy?: ProxyConfigArray | undefined;
1863
1747
  open?: string | boolean | Open | (string | Open)[] | undefined;
@@ -1868,15 +1752,36 @@ type Configuration = {
1868
1752
  | ((
1869
1753
  req: Request,
1870
1754
  res: Response,
1871
- context: DevMiddlewareContext<Request, Response>,
1755
+ context: DevMiddlewareContext<Request, Response> | undefined,
1872
1756
  ) => Headers)
1873
1757
  | undefined;
1874
- onListening?: ((devServer: Server) => void) | undefined;
1758
+ onListening?: ((devServer: Server<A, S>) => void) | undefined;
1875
1759
  setupMiddlewares?:
1876
- | ((middlewares: Middleware[], devServer: Server) => Middleware[])
1760
+ | ((middlewares: Middleware[], devServer: Server<A, S>) => Middleware[])
1877
1761
  | undefined;
1878
1762
  };
1879
- import path = require("path");
1763
+ type BasicApplication = {
1764
+ use: typeof useFn;
1765
+ };
1766
+ /**
1767
+ * @overload
1768
+ * @param {NextHandleFunction} fn
1769
+ * @returns {BasicApplication}
1770
+ */
1771
+ declare function useFn(fn: NextHandleFunction): BasicApplication;
1772
+ /**
1773
+ * @overload
1774
+ * @param {HandleFunction} fn
1775
+ * @returns {BasicApplication}
1776
+ */
1777
+ declare function useFn(fn: HandleFunction): BasicApplication;
1778
+ /**
1779
+ * @overload
1780
+ * @param {string} route
1781
+ * @param {NextHandleFunction} fn
1782
+ * @returns {BasicApplication}
1783
+ */
1784
+ declare function useFn(route: string, fn: NextHandleFunction): BasicApplication;
1880
1785
 
1881
1786
  // DO NOT REMOVE THIS!
1882
1787
  type DevServerConfiguration = Configuration;