webpack-dev-server 5.0.2 → 5.2.2

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,152 +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 {{ [url: string]: string | ProxyConfigArrayItem }} ProxyConfigMap
158
- */
159
- /**
160
- * @typedef {Object} OpenApp
161
- * @property {string} [name]
162
- * @property {string[]} [arguments]
163
- */
164
- /**
165
- * @typedef {Object} Open
166
- * @property {string | string[] | OpenApp} [app]
167
- * @property {string | string[]} [target]
168
- */
169
- /**
170
- * @typedef {Object} NormalizedOpen
171
- * @property {string} target
172
- * @property {import("open").Options} options
173
- */
174
- /**
175
- * @typedef {Object} WebSocketURL
176
- * @property {string} [hostname]
177
- * @property {string} [password]
178
- * @property {string} [pathname]
179
- * @property {number | string} [port]
180
- * @property {string} [protocol]
181
- * @property {string} [username]
182
- */
183
- /**
184
- * @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
185
- */
186
- /**
187
- * @typedef {Object} ClientConfiguration
188
- * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging]
189
- * @property {boolean | { warnings?: OverlayMessageOptions, errors?: OverlayMessageOptions, runtimeErrors?: OverlayMessageOptions }} [overlay]
190
- * @property {boolean} [progress]
191
- * @property {boolean | number} [reconnect]
192
- * @property {"ws" | "sockjs" | string} [webSocketTransport]
193
- * @property {string | WebSocketURL} [webSocketURL]
194
- */
195
- /**
196
- * @typedef {Array<{ key: string; value: string }> | Record<string, string | string[]>} Headers
197
- */
198
- /**
199
- * @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware
200
- */
201
- /**
202
- * @typedef {Object} Configuration
203
- * @property {boolean | string} [ipc]
204
- * @property {Host} [host]
205
- * @property {Port} [port]
206
- * @property {boolean | "only"} [hot]
207
- * @property {boolean} [liveReload]
208
- * @property {DevMiddlewareOptions<Request, Response>} [devMiddleware]
209
- * @property {boolean} [compress]
210
- * @property {"auto" | "all" | string | string[]} [allowedHosts]
211
- * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback]
212
- * @property {boolean | Record<string, never> | BonjourOptions} [bonjour]
213
- * @property {string | string[] | WatchFiles | Array<string | WatchFiles>} [watchFiles]
214
- * @property {boolean | string | Static | Array<string | Static>} [static]
215
- * @property {boolean | ServerOptions} [https]
216
- * @property {boolean} [http2]
217
- * @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
218
- * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
219
- * @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy]
220
- * @property {boolean | string | Open | Array<string | Open>} [open]
221
- * @property {boolean} [setupExitSignals]
222
- * @property {boolean | ClientConfiguration} [client]
223
- * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
224
- * @property {(devServer: Server) => void} [onListening]
225
- * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
226
- */
227
99
  overlay: {
228
100
  $ref: string;
229
101
  };
@@ -295,9 +167,7 @@ declare class Server {
295
167
  instanceof?: undefined;
296
168
  }
297
169
  | {
298
- instanceof: string /**
299
- * @typedef {import("ws").WebSocketServer | import("sockjs").Server & { close: import("ws").WebSocketServer["close"] }} WebSocketServer
300
- */;
170
+ instanceof: string;
301
171
  description: string;
302
172
  type?: undefined;
303
173
  cli?: undefined;
@@ -323,69 +193,6 @@ declare class Server {
323
193
  )[];
324
194
  };
325
195
  trustedTypesPolicyName: {
326
- /**
327
- * @typedef {Object} Open
328
- * @property {string | string[] | OpenApp} [app]
329
- * @property {string | string[]} [target]
330
- */
331
- /**
332
- * @typedef {Object} NormalizedOpen
333
- * @property {string} target
334
- * @property {import("open").Options} options
335
- */
336
- /**
337
- * @typedef {Object} WebSocketURL
338
- * @property {string} [hostname]
339
- * @property {string} [password]
340
- * @property {string} [pathname]
341
- * @property {number | string} [port]
342
- * @property {string} [protocol]
343
- * @property {string} [username]
344
- */
345
- /**
346
- * @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
347
- */
348
- /**
349
- * @typedef {Object} ClientConfiguration
350
- * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging]
351
- * @property {boolean | { warnings?: OverlayMessageOptions, errors?: OverlayMessageOptions, runtimeErrors?: OverlayMessageOptions }} [overlay]
352
- * @property {boolean} [progress]
353
- * @property {boolean | number} [reconnect]
354
- * @property {"ws" | "sockjs" | string} [webSocketTransport]
355
- * @property {string | WebSocketURL} [webSocketURL]
356
- */
357
- /**
358
- * @typedef {Array<{ key: string; value: string }> | Record<string, string | string[]>} Headers
359
- */
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 {ProxyConfigMap | ProxyConfigArrayItem | 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
196
  description: string;
390
197
  type: string;
391
198
  };
@@ -399,7 +206,8 @@ declare class Server {
399
206
  ClientProgress: {
400
207
  description: string;
401
208
  link: string;
402
- type: string;
209
+ type: string[];
210
+ enum: (string | boolean)[];
403
211
  cli: {
404
212
  negatedDescription: string;
405
213
  };
@@ -539,9 +347,6 @@ declare class Server {
539
347
  $ref: string;
540
348
  };
541
349
  minItems: number;
542
- /**
543
- * @type {Socket[]}
544
- */
545
350
  instanceof?: undefined;
546
351
  }
547
352
  | {
@@ -641,11 +446,6 @@ declare class Server {
641
446
  OnListening: {
642
447
  instanceof: string;
643
448
  description: string;
644
- /**
645
- * @param {Port} port
646
- * @param {string} host
647
- * @returns {Promise<number | string>}
648
- */
649
449
  link: string;
650
450
  };
651
451
  Open: {
@@ -781,11 +581,11 @@ declare class Server {
781
581
  anyOf: (
782
582
  | {
783
583
  type: string;
784
- /** @type {WebSocketURL} */ instanceof?: undefined;
584
+ instanceof?: undefined;
785
585
  }
786
586
  | {
787
587
  instanceof: string;
788
- /** @type {ClientConfiguration} */ type?: undefined;
588
+ type?: undefined;
789
589
  }
790
590
  )[];
791
591
  };
@@ -802,6 +602,9 @@ declare class Server {
802
602
  ServerType: {
803
603
  enum: string[];
804
604
  };
605
+ ServerFn: {
606
+ instanceof: string;
607
+ };
805
608
  ServerEnum: {
806
609
  enum: string[];
807
610
  cli: {
@@ -1190,7 +993,7 @@ declare class Server {
1190
993
  };
1191
994
  WatchFilesString: {
1192
995
  type: string;
1193
- /** @type {NormalizedStatic} */ minLength: number;
996
+ minLength: number;
1194
997
  };
1195
998
  WebSocketServer: {
1196
999
  anyOf: {
@@ -1299,6 +1102,9 @@ declare class Server {
1299
1102
  server: {
1300
1103
  $ref: string;
1301
1104
  };
1105
+ app: {
1106
+ $ref: string;
1107
+ };
1302
1108
  setupExitSignals: {
1303
1109
  $ref: string;
1304
1110
  };
@@ -1322,10 +1128,14 @@ declare class Server {
1322
1128
  */
1323
1129
  static isAbsoluteURL(URL: string): boolean;
1324
1130
  /**
1325
- * @param {string} gateway
1131
+ * @param {string} gatewayOrFamily or family
1132
+ * @param {boolean} [isInternal] ip should be internal
1326
1133
  * @returns {string | undefined}
1327
1134
  */
1328
- static findIp(gateway: string): string | undefined;
1135
+ static findIp(
1136
+ gatewayOrFamily: string,
1137
+ isInternal?: boolean,
1138
+ ): string | undefined;
1329
1139
  /**
1330
1140
  * @param {"v4" | "v6"} family
1331
1141
  * @returns {Promise<string | undefined>}
@@ -1358,23 +1168,19 @@ declare class Server {
1358
1168
  */
1359
1169
  private static isWebTarget;
1360
1170
  /**
1361
- * @param {Configuration | Compiler | MultiCompiler} options
1362
- * @param {Compiler | MultiCompiler | Configuration} compiler
1171
+ * @param {Configuration<A, S>} options
1172
+ * @param {Compiler | MultiCompiler} compiler
1363
1173
  */
1364
1174
  constructor(
1365
- options:
1366
- | import("webpack").Compiler
1367
- | import("webpack").MultiCompiler
1368
- | Configuration
1369
- | undefined,
1370
- compiler: Compiler | MultiCompiler | Configuration,
1175
+ options: Configuration<A, S> | undefined,
1176
+ compiler: Compiler | MultiCompiler,
1371
1177
  );
1372
1178
  compiler: import("webpack").Compiler | import("webpack").MultiCompiler;
1373
1179
  /**
1374
1180
  * @type {ReturnType<Compiler["getInfrastructureLogger"]>}
1375
1181
  * */
1376
1182
  logger: ReturnType<Compiler["getInfrastructureLogger"]>;
1377
- options: Configuration;
1183
+ options: Configuration<A, S>;
1378
1184
  /**
1379
1185
  * @type {FSWatcher[]}
1380
1186
  */
@@ -1419,10 +1225,19 @@ declare class Server {
1419
1225
  */
1420
1226
  private getClientTransport;
1421
1227
  /**
1228
+ * @template T
1422
1229
  * @private
1423
- * @returns {string}
1230
+ * @returns {T}
1424
1231
  */
1425
1232
  private getServerTransport;
1233
+ /**
1234
+ * @returns {string}
1235
+ */
1236
+ getClientEntry(): string;
1237
+ /**
1238
+ * @returns {string | void}
1239
+ */
1240
+ getClientHotEntry(): string | void;
1426
1241
  /**
1427
1242
  * @private
1428
1243
  * @returns {void}
@@ -1435,11 +1250,11 @@ declare class Server {
1435
1250
  private initialize;
1436
1251
  /**
1437
1252
  * @private
1438
- * @returns {void}
1253
+ * @returns {Promise<void>}
1439
1254
  */
1440
1255
  private setupApp;
1441
- /** @type {import("express").Application | undefined}*/
1442
- app: import("express").Application | undefined;
1256
+ /** @type {A | undefined}*/
1257
+ app: A | undefined;
1443
1258
  /**
1444
1259
  * @private
1445
1260
  * @param {Stats | MultiStats} statsObj
@@ -1460,12 +1275,18 @@ declare class Server {
1460
1275
  * @private
1461
1276
  * @returns {void}
1462
1277
  */
1463
- private setupHostHeaderCheck;
1278
+ private setupWatchStaticFiles;
1279
+ /**
1280
+ * @private
1281
+ * @returns {void}
1282
+ */
1283
+ private setupWatchFiles;
1464
1284
  /**
1465
1285
  * @private
1466
1286
  * @returns {void}
1467
1287
  */
1468
- private setupDevMiddleware;
1288
+ private setupMiddlewares;
1289
+ /** @type {import("webpack-dev-middleware").API<Request, Response>} */
1469
1290
  middleware:
1470
1291
  | import("webpack-dev-middleware").API<
1471
1292
  import("express").Request<
@@ -1477,35 +1298,15 @@ declare class Server {
1477
1298
  >,
1478
1299
  import("express").Response<any, Record<string, any>>
1479
1300
  >
1480
- | null
1481
1301
  | undefined;
1482
1302
  /**
1483
1303
  * @private
1484
- * @returns {void}
1485
- */
1486
- private setupBuiltInRoutes;
1487
- /**
1488
- * @private
1489
- * @returns {void}
1490
- */
1491
- private setupWatchStaticFiles;
1492
- /**
1493
- * @private
1494
- * @returns {void}
1495
- */
1496
- private setupWatchFiles;
1497
- /**
1498
- * @private
1499
- * @returns {void}
1500
- */
1501
- private setupMiddlewares;
1502
- /**
1503
- * @private
1504
- * @returns {void}
1304
+ * @returns {Promise<void>}
1505
1305
  */
1506
1306
  private createServer;
1507
- /** @type {import("http").Server | undefined | null} */
1508
- server: import("http").Server | undefined | null;
1307
+ /** @type {S | undefined}*/
1308
+ server: S | undefined;
1309
+ isTlsServer: boolean | undefined;
1509
1310
  /**
1510
1311
  * @private
1511
1312
  * @returns {void}
@@ -1546,13 +1347,26 @@ declare class Server {
1546
1347
  * @param {NextFunction} next
1547
1348
  */
1548
1349
  private setHeaders;
1350
+ /**
1351
+ * @private
1352
+ * @param {string} value
1353
+ * @returns {boolean}
1354
+ */
1355
+ private isHostAllowed;
1549
1356
  /**
1550
1357
  * @private
1551
1358
  * @param {{ [key: string]: string | undefined }} headers
1552
1359
  * @param {string} headerToCheck
1360
+ * @param {boolean} validateHost
1361
+ * @returns {boolean}
1362
+ */
1363
+ private isValidHost;
1364
+ /**
1365
+ * @private
1366
+ * @param {{ [key: string]: string | undefined }} headers
1553
1367
  * @returns {boolean}
1554
1368
  */
1555
- private checkHeader;
1369
+ private isSameOrigin;
1556
1370
  /**
1557
1371
  * @param {ClientConnection[]} clients
1558
1372
  * @param {string} type
@@ -1576,16 +1390,11 @@ declare class Server {
1576
1390
  * @param {string | string[]} watchPath
1577
1391
  * @param {WatchOptions} [watchOptions]
1578
1392
  */
1579
- watchFiles(
1580
- watchPath: string | string[],
1581
- watchOptions?: import("chokidar").WatchOptions | undefined,
1582
- ): void;
1393
+ watchFiles(watchPath: string | string[], watchOptions?: WatchOptions): void;
1583
1394
  /**
1584
1395
  * @param {import("webpack-dev-middleware").Callback} [callback]
1585
1396
  */
1586
- invalidate(
1587
- callback?: import("webpack-dev-middleware").Callback | undefined,
1588
- ): void;
1397
+ invalidate(callback?: import("webpack-dev-middleware").Callback): void;
1589
1398
  /**
1590
1399
  * @returns {Promise<void>}
1591
1400
  */
@@ -1593,7 +1402,7 @@ declare class Server {
1593
1402
  /**
1594
1403
  * @param {(err?: Error) => void} [callback]
1595
1404
  */
1596
- startCallback(callback?: ((err?: Error) => void) | undefined): void;
1405
+ startCallback(callback?: (err?: Error) => void): void;
1597
1406
  /**
1598
1407
  * @returns {Promise<void>}
1599
1408
  */
@@ -1601,7 +1410,7 @@ declare class Server {
1601
1410
  /**
1602
1411
  * @param {(err?: Error) => void} [callback]
1603
1412
  */
1604
- stopCallback(callback?: ((err?: Error) => void) | undefined): void;
1413
+ stopCallback(callback?: (err?: Error) => void): void;
1605
1414
  }
1606
1415
  declare namespace Server {
1607
1416
  export {
@@ -1615,9 +1424,6 @@ declare namespace Server {
1615
1424
  Stats,
1616
1425
  MultiStats,
1617
1426
  NetworkInterfaceInfo,
1618
- NextFunction,
1619
- ExpressRequestHandler,
1620
- ExpressErrorRequestHandler,
1621
1427
  WatchOptions,
1622
1428
  FSWatcher,
1623
1429
  ConnectHistoryApiFallbackOptions,
@@ -1631,9 +1437,20 @@ declare namespace Server {
1631
1437
  IPv4,
1632
1438
  IPv6,
1633
1439
  Socket,
1440
+ HTTPServer,
1634
1441
  IncomingMessage,
1635
1442
  ServerResponse,
1636
1443
  OpenOptions,
1444
+ ExpressApplication,
1445
+ ExpressRequestHandler,
1446
+ ExpressErrorRequestHandler,
1447
+ ExpressRequest,
1448
+ ExpressResponse,
1449
+ NextFunction,
1450
+ SimpleHandleFunction,
1451
+ NextHandleFunction,
1452
+ ErrorHandleFunction,
1453
+ HandleFunction,
1637
1454
  ServerOptions,
1638
1455
  Request,
1639
1456
  Response,
@@ -1644,6 +1461,7 @@ declare namespace Server {
1644
1461
  WatchFiles,
1645
1462
  Static,
1646
1463
  NormalizedStatic,
1464
+ ServerType,
1647
1465
  ServerConfiguration,
1648
1466
  WebSocketServerConfiguration,
1649
1467
  ClientConnection,
@@ -1652,7 +1470,6 @@ declare namespace Server {
1652
1470
  ByPass,
1653
1471
  ProxyConfigArrayItem,
1654
1472
  ProxyConfigArray,
1655
- ProxyConfigMap,
1656
1473
  OpenApp,
1657
1474
  Open,
1658
1475
  NormalizedOpen,
@@ -1660,21 +1477,19 @@ declare namespace Server {
1660
1477
  OverlayMessageOptions,
1661
1478
  ClientConfiguration,
1662
1479
  Headers,
1480
+ MiddlewareHandler,
1481
+ MiddlewareObject,
1663
1482
  Middleware,
1483
+ BasicServer,
1664
1484
  Configuration,
1485
+ BasicApplication,
1665
1486
  };
1666
1487
  }
1667
- type Compiler = import("webpack").Compiler;
1668
- type FSWatcher = import("chokidar").FSWatcher;
1669
- type Socket = import("net").Socket;
1670
- type WebSocketServerImplementation = {
1671
- implementation: WebSocketServer;
1672
- clients: ClientConnection[];
1673
- };
1674
1488
  declare class DEFAULT_STATS {
1675
1489
  private constructor();
1676
1490
  }
1677
1491
  type Schema = import("schema-utils/declarations/validate").Schema;
1492
+ type Compiler = import("webpack").Compiler;
1678
1493
  type MultiCompiler = import("webpack").MultiCompiler;
1679
1494
  type WebpackConfiguration = import("webpack").Configuration;
1680
1495
  type StatsOptions = import("webpack").StatsOptions;
@@ -1682,10 +1497,8 @@ type StatsCompilation = import("webpack").StatsCompilation;
1682
1497
  type Stats = import("webpack").Stats;
1683
1498
  type MultiStats = import("webpack").MultiStats;
1684
1499
  type NetworkInterfaceInfo = import("os").NetworkInterfaceInfo;
1685
- type NextFunction = import("express").NextFunction;
1686
- type ExpressRequestHandler = import("express").RequestHandler;
1687
- type ExpressErrorRequestHandler = import("express").ErrorRequestHandler;
1688
1500
  type WatchOptions = import("chokidar").WatchOptions;
1501
+ type FSWatcher = import("chokidar").FSWatcher;
1689
1502
  type ConnectHistoryApiFallbackOptions =
1690
1503
  import("connect-history-api-fallback").Options;
1691
1504
  type Bonjour = import("bonjour-service").Bonjour;
@@ -1697,9 +1510,33 @@ type ServeIndexOptions = import("serve-index").Options;
1697
1510
  type ServeStaticOptions = import("serve-static").ServeStaticOptions;
1698
1511
  type IPv4 = import("ipaddr.js").IPv4;
1699
1512
  type IPv6 = import("ipaddr.js").IPv6;
1513
+ type Socket = import("net").Socket;
1514
+ type HTTPServer = import("http").Server;
1700
1515
  type IncomingMessage = import("http").IncomingMessage;
1701
1516
  type ServerResponse = import("http").ServerResponse;
1702
1517
  type OpenOptions = import("open").Options;
1518
+ type ExpressApplication = import("express").Application;
1519
+ type ExpressRequestHandler = import("express").RequestHandler;
1520
+ type ExpressErrorRequestHandler = import("express").ErrorRequestHandler;
1521
+ type ExpressRequest = import("express").Request;
1522
+ type ExpressResponse = import("express").Response;
1523
+ type NextFunction = (err?: any) => void;
1524
+ type SimpleHandleFunction = (req: IncomingMessage, res: ServerResponse) => void;
1525
+ type NextHandleFunction = (
1526
+ req: IncomingMessage,
1527
+ res: ServerResponse,
1528
+ next: NextFunction,
1529
+ ) => void;
1530
+ type ErrorHandleFunction = (
1531
+ err: any,
1532
+ req: IncomingMessage,
1533
+ res: ServerResponse,
1534
+ next: NextFunction,
1535
+ ) => void;
1536
+ type HandleFunction =
1537
+ | SimpleHandleFunction
1538
+ | NextHandleFunction
1539
+ | ErrorHandleFunction;
1703
1540
  type ServerOptions = import("https").ServerOptions & {
1704
1541
  spdy?: {
1705
1542
  plain?: boolean | undefined;
@@ -1709,27 +1546,17 @@ type ServerOptions = import("https").ServerOptions & {
1709
1546
  protocols?: string[] | undefined;
1710
1547
  };
1711
1548
  };
1712
- type Request = import("express").Request;
1713
- type Response = import("express").Response;
1549
+ type Request<T extends BasicApplication = import("express").Application> =
1550
+ T extends ExpressApplication ? ExpressRequest : IncomingMessage;
1551
+ type Response<T extends BasicApplication = import("express").Application> =
1552
+ T extends ExpressApplication ? ExpressResponse : ServerResponse;
1714
1553
  type DevMiddlewareOptions<
1715
- T extends import("express").Request<
1716
- import("express-serve-static-core").ParamsDictionary,
1717
- any,
1718
- any,
1719
- qs.ParsedQs,
1720
- Record<string, any>
1721
- >,
1722
- U extends import("express").Response<any, Record<string, any>>,
1554
+ T extends Request,
1555
+ U extends Response,
1723
1556
  > = import("webpack-dev-middleware").Options<T, U>;
1724
1557
  type DevMiddlewareContext<
1725
- T extends import("express").Request<
1726
- import("express-serve-static-core").ParamsDictionary,
1727
- any,
1728
- any,
1729
- qs.ParsedQs,
1730
- Record<string, any>
1731
- >,
1732
- U extends import("express").Response<any, Record<string, any>>,
1558
+ T extends Request,
1559
+ U extends Response,
1733
1560
  > = import("webpack-dev-middleware").Context<T, U>;
1734
1561
  type Host = "local-ip" | "local-ipv4" | "local-ipv6" | string;
1735
1562
  type Port = number | string | "auto";
@@ -1737,9 +1564,9 @@ type WatchFiles = {
1737
1564
  paths: string | string[];
1738
1565
  options?:
1739
1566
  | (import("chokidar").WatchOptions & {
1740
- aggregateTimeout?: number | undefined;
1567
+ aggregateTimeout?: number;
1741
1568
  ignored?: WatchOptions["ignored"];
1742
- poll?: number | boolean | undefined;
1569
+ poll?: number | boolean;
1743
1570
  })
1744
1571
  | undefined;
1745
1572
  };
@@ -1755,9 +1582,9 @@ type Static = {
1755
1582
  watch?:
1756
1583
  | boolean
1757
1584
  | (import("chokidar").WatchOptions & {
1758
- aggregateTimeout?: number | undefined;
1585
+ aggregateTimeout?: number;
1759
1586
  ignored?: WatchOptions["ignored"];
1760
- poll?: number | boolean | undefined;
1587
+ poll?: number | boolean;
1761
1588
  })
1762
1589
  | undefined;
1763
1590
  };
@@ -1768,8 +1595,27 @@ type NormalizedStatic = {
1768
1595
  staticOptions: ServeStaticOptions;
1769
1596
  watch: false | WatchOptions;
1770
1597
  };
1771
- type ServerConfiguration = {
1772
- type?: string | undefined;
1598
+ type ServerType<
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
+ | "http"
1606
+ | "https"
1607
+ | "spdy"
1608
+ | "http2"
1609
+ | string
1610
+ | ((arg0: ServerOptions, arg1: A) => S);
1611
+ type ServerConfiguration<
1612
+ A extends BasicApplication = import("express").Application,
1613
+ S extends BasicServer = import("http").Server<
1614
+ typeof import("http").IncomingMessage,
1615
+ typeof import("http").ServerResponse
1616
+ >,
1617
+ > = {
1618
+ type?: ServerType<A, S> | undefined;
1773
1619
  options?: ServerOptions | undefined;
1774
1620
  };
1775
1621
  type WebSocketServerConfiguration = {
@@ -1791,6 +1637,10 @@ type WebSocketServer =
1791
1637
  | (import("sockjs").Server & {
1792
1638
  close: import("ws").WebSocketServer["close"];
1793
1639
  });
1640
+ type WebSocketServerImplementation = {
1641
+ implementation: WebSocketServer;
1642
+ clients: ClientConnection[];
1643
+ };
1794
1644
  type ByPass = (
1795
1645
  req: Request,
1796
1646
  res: Response,
@@ -1810,9 +1660,6 @@ type ProxyConfigArray = (
1810
1660
  next?: NextFunction | undefined,
1811
1661
  ) => ProxyConfigArrayItem)
1812
1662
  )[];
1813
- type ProxyConfigMap = {
1814
- [url: string]: string | ProxyConfigArrayItem;
1815
- };
1816
1663
  type OpenApp = {
1817
1664
  name?: string | undefined;
1818
1665
  arguments?: string[] | undefined;
@@ -1839,9 +1686,9 @@ type ClientConfiguration = {
1839
1686
  overlay?:
1840
1687
  | boolean
1841
1688
  | {
1842
- warnings?: OverlayMessageOptions | undefined;
1843
- errors?: OverlayMessageOptions | undefined;
1844
- runtimeErrors?: OverlayMessageOptions | undefined;
1689
+ warnings?: OverlayMessageOptions;
1690
+ errors?: OverlayMessageOptions;
1691
+ runtimeErrors?: OverlayMessageOptions;
1845
1692
  }
1846
1693
  | undefined;
1847
1694
  progress?: boolean | undefined;
@@ -1855,15 +1702,25 @@ type Headers =
1855
1702
  value: string;
1856
1703
  }>
1857
1704
  | Record<string, string | string[]>;
1858
- type Middleware =
1859
- | {
1860
- name?: string;
1861
- path?: string;
1862
- middleware: ExpressRequestHandler | ExpressErrorRequestHandler;
1863
- }
1864
- | ExpressRequestHandler
1865
- | ExpressErrorRequestHandler;
1866
- type Configuration = {
1705
+ type MiddlewareHandler<
1706
+ T extends BasicApplication = import("express").Application,
1707
+ > = T extends ExpressApplication
1708
+ ? ExpressRequestHandler | ExpressErrorRequestHandler
1709
+ : HandleFunction;
1710
+ type MiddlewareObject = {
1711
+ name?: string;
1712
+ path?: string;
1713
+ middleware: MiddlewareHandler;
1714
+ };
1715
+ type Middleware = MiddlewareObject | MiddlewareHandler;
1716
+ type BasicServer = import("net").Server | import("tls").Server;
1717
+ type Configuration<
1718
+ A extends BasicApplication = import("express").Application,
1719
+ S extends BasicServer = import("http").Server<
1720
+ typeof import("http").IncomingMessage,
1721
+ typeof import("http").ServerResponse
1722
+ >,
1723
+ > = {
1867
1724
  ipc?: string | boolean | undefined;
1868
1725
  host?: string | undefined;
1869
1726
  port?: Port | undefined;
@@ -1899,11 +1756,10 @@ type Configuration = {
1899
1756
  | (string | WatchFiles)[]
1900
1757
  | undefined;
1901
1758
  static?: string | boolean | Static | (string | Static)[] | undefined;
1902
- https?: boolean | ServerOptions | undefined;
1903
- http2?: boolean | undefined;
1904
- server?: string | ServerConfiguration | undefined;
1759
+ server?: ServerType<A, S> | ServerConfiguration<A, S> | undefined;
1760
+ app?: (() => Promise<A>) | undefined;
1905
1761
  webSocketServer?: string | boolean | WebSocketServerConfiguration | undefined;
1906
- proxy?: ProxyConfigArrayItem | ProxyConfigMap | ProxyConfigArray | undefined;
1762
+ proxy?: ProxyConfigArray | undefined;
1907
1763
  open?: string | boolean | Open | (string | Open)[] | undefined;
1908
1764
  setupExitSignals?: boolean | undefined;
1909
1765
  client?: boolean | ClientConfiguration | undefined;
@@ -1912,15 +1768,36 @@ type Configuration = {
1912
1768
  | ((
1913
1769
  req: Request,
1914
1770
  res: Response,
1915
- context: DevMiddlewareContext<Request, Response>,
1771
+ context: DevMiddlewareContext<Request, Response> | undefined,
1916
1772
  ) => Headers)
1917
1773
  | undefined;
1918
- onListening?: ((devServer: Server) => void) | undefined;
1774
+ onListening?: ((devServer: Server<A, S>) => void) | undefined;
1919
1775
  setupMiddlewares?:
1920
- | ((middlewares: Middleware[], devServer: Server) => Middleware[])
1776
+ | ((middlewares: Middleware[], devServer: Server<A, S>) => Middleware[])
1921
1777
  | undefined;
1922
1778
  };
1923
- import path = require("path");
1779
+ type BasicApplication = {
1780
+ use: typeof useFn;
1781
+ };
1782
+ /**
1783
+ * @overload
1784
+ * @param {NextHandleFunction} fn
1785
+ * @returns {BasicApplication}
1786
+ */
1787
+ declare function useFn(fn: NextHandleFunction): BasicApplication;
1788
+ /**
1789
+ * @overload
1790
+ * @param {HandleFunction} fn
1791
+ * @returns {BasicApplication}
1792
+ */
1793
+ declare function useFn(fn: HandleFunction): BasicApplication;
1794
+ /**
1795
+ * @overload
1796
+ * @param {string} route
1797
+ * @param {NextHandleFunction} fn
1798
+ * @returns {BasicApplication}
1799
+ */
1800
+ declare function useFn(route: string, fn: NextHandleFunction): BasicApplication;
1924
1801
 
1925
1802
  // DO NOT REMOVE THIS!
1926
1803
  type DevServerConfiguration = Configuration;