web-listener 1.2.1 → 1.3.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.
package/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { Duplex, Readable, Writable } from 'node:stream';
3
3
  import { AddressInfo } from 'node:net';
4
4
  import { FileHandle, CreateReadStreamOptions } from 'node:fs/promises';
5
5
  import { Mode, Stats, StatOptions, BigIntStats } from 'node:fs';
6
- import { ReadableStream, TransformStream } from 'node:stream/web';
6
+ import { ReadableStream as ReadableStream$1, TransformStream } from 'node:stream/web';
7
7
  import { AgentOptions, Agent as Agent$1 } from 'node:https';
8
8
 
9
9
  type ClientErrorListener = (error: Error, socket: Duplex) => void;
@@ -16,7 +16,7 @@ interface Address {
16
16
  port: number | undefined;
17
17
  }
18
18
  declare function parseAddress(address: string | undefined): Address | undefined;
19
- declare function makeAddressTester(cidrRanges: string[]): (address: Address | undefined) => boolean;
19
+ declare function makeAddressTester(cidrRanges: ReadonlyArray<string>): (address: Address | undefined) => boolean;
20
20
 
21
21
  declare class BlockingQueue<T> {
22
22
  constructor();
@@ -40,7 +40,8 @@ declare function findCause<T>(error: unknown, errorType: {
40
40
 
41
41
  declare function getAddressURL(addressInfo: string | Address | AddressInfo | null | undefined, protocol?: string): string;
42
42
 
43
- type AnyHeaders = Headers | [string, string][] | OutgoingHttpHeaders | Map<string, string | number | Readonly<string[]>> | undefined;
43
+ type LooseHeaderValue = string | number | ReadonlyArray<string>;
44
+ type AnyHeaders = Headers | ReadonlyArray<[string, string]> | OutgoingHttpHeaders | Map<string, LooseHeaderValue> | undefined;
44
45
 
45
46
  declare class Queue<T> {
46
47
  constructor(initialItem?: T);
@@ -52,15 +53,12 @@ declare class Queue<T> {
52
53
  [Symbol.iterator](): Iterator<T, unknown, undefined>;
53
54
  }
54
55
 
55
- interface CloseableReadable extends Readable {
56
- close(): void;
57
- }
58
56
  interface ReadOnlyFileHandle extends Pick<FileHandle, 'stat' | 'close' | typeof Symbol.asyncDispose>, Partial<Pick<FileHandle, 'read' | 'readFile' | 'readLines' | 'readableWebStream' | 'readv'>> {
59
- createReadStream(options?: CreateReadStreamOptions): CloseableReadable;
57
+ createReadStream(options?: CreateReadStreamOptions | undefined): Readable;
60
58
  noRandomAccess?: boolean | undefined;
61
59
  }
62
60
 
63
- declare const stringPredicate: (conditions: (string | RegExp)[] | string | RegExp | undefined, caseInsensitive: boolean) => ((value: string) => boolean);
61
+ declare const stringPredicate: (conditions: ReadonlyArray<string | RegExp> | string | RegExp | undefined, caseInsensitive: boolean) => ((value: string) => boolean);
64
62
 
65
63
  declare class SharedFileHandle {
66
64
  constructor(path: string, flags?: number, mode?: Mode, closeDelay?: number);
@@ -77,7 +75,7 @@ type UpgradeErrorHandler = (error: unknown) => void;
77
75
  type SoftCloseHandler = (reason: string) => MaybePromise<void>;
78
76
  declare function setSoftCloseHandler(req: IncomingMessage, fn: SoftCloseHandler): void;
79
77
  declare const isSoftClosed: (req: IncomingMessage) => boolean;
80
- declare function scheduleClose(req: IncomingMessage, reason: string, hardCloseTimestamp: number, softCloseBufferTime?: number, onSoftCloseError?: ServerErrorCallback): void;
78
+ declare function scheduleClose(req: IncomingMessage, reason: string, hardCloseTimestamp: number, softCloseBufferTime?: number, onSoftCloseError?: ServerErrorCallback | undefined): void;
81
79
  declare const defer: (req: IncomingMessage, fn: () => MaybePromise<void>) => void;
82
80
  declare const addTeardown: (req: IncomingMessage, fn: () => MaybePromise<void>) => void;
83
81
  declare const getAbortSignal: (req: IncomingMessage) => AbortSignal;
@@ -85,8 +83,8 @@ declare const getAbortSignal: (req: IncomingMessage) => AbortSignal;
85
83
  type AcceptUpgradeHandler<T, Req = {}> = (req: IncomingMessage & Req, socket: Duplex, head: Buffer) => Promise<AcceptUpgradeResult<T>>;
86
84
  interface AcceptUpgradeResult<T> {
87
85
  return: T;
88
- onError?: UpgradeErrorHandler;
89
- softCloseHandler?: SoftCloseHandler;
86
+ onError?: UpgradeErrorHandler | undefined;
87
+ softCloseHandler?: SoftCloseHandler | undefined;
90
88
  }
91
89
  declare function acceptUpgrade<T, Req = {}>(req: IncomingMessage & Req, upgrade: AcceptUpgradeHandler<T, Req>): Promise<T>;
92
90
  declare function delegateUpgrade(req: IncomingMessage): void;
@@ -104,15 +102,15 @@ type RequestHandlerFn<Req = {}> = (req: IncomingMessage & Req, res: ServerRespon
104
102
  interface RequestHandler<Req = {}> {
105
103
  handleRequest: RequestHandlerFn<Req>;
106
104
  }
107
- declare const requestHandler: <Req>(handler: RequestHandler<Req> | RequestHandlerFn<Req>) => RequestHandler<Req>;
105
+ declare const requestHandler: <Req = {}>(handler: RequestHandler<Req> | RequestHandlerFn<Req>) => RequestHandler<Req>;
108
106
  type UpgradeHandlerFn<Req = {}> = (req: IncomingMessage & Req, socket: Duplex, head: Buffer) => MaybePromise<HandlerResult>;
109
107
  type ShouldUpgradeFn<Req = {}> = (req: IncomingMessage & Req) => boolean;
110
108
  interface UpgradeHandler<Req = {}> {
111
109
  handleUpgrade: UpgradeHandlerFn<Req>;
112
110
  shouldUpgrade?: ShouldUpgradeFn<Req> | undefined;
113
111
  }
114
- declare const upgradeHandler: <Req>(handler: UpgradeHandler<Req> | UpgradeHandlerFn<Req>, shouldUpgrade?: ShouldUpgradeFn<Req>) => UpgradeHandler<Req>;
115
- declare const anyHandler: <Req>(handler: UpgradeHandlerFn<Req> & RequestHandlerFn<Req>, shouldUpgrade?: ShouldUpgradeFn<Req>) => RequestHandler<Req> & UpgradeHandler<Req>;
112
+ declare const upgradeHandler: <Req = {}>(handler: UpgradeHandler<Req> | UpgradeHandlerFn<Req>, shouldUpgrade?: ShouldUpgradeFn<Req> | undefined) => UpgradeHandler<Req>;
113
+ declare const anyHandler: <Req = {}>(handler: UpgradeHandlerFn<Req> & RequestHandlerFn<Req>, shouldUpgrade?: ShouldUpgradeFn<Req>) => RequestHandler<Req> & UpgradeHandler<Req>;
116
114
  type ErrorOutput = {
117
115
  response: ServerResponse;
118
116
  socket?: never;
@@ -127,9 +125,9 @@ type ErrorOutput = {
127
125
  type ErrorHandlerFn<Req = {}> = (error: unknown, req: IncomingMessage & Req, output: ErrorOutput) => MaybePromise<HandlerResult>;
128
126
  interface ErrorHandler<Req = {}> {
129
127
  handleError: ErrorHandlerFn<Req>;
130
- shouldHandleError?: (error: unknown, req: IncomingMessage & Req, output: ErrorOutput) => boolean;
128
+ shouldHandleError?: ((error: unknown, req: IncomingMessage & Req, output: ErrorOutput) => boolean) | undefined;
131
129
  }
132
- declare const errorHandler: <Req>(handler: ErrorHandler<Req> | ErrorHandlerFn<Req>) => ErrorHandler<Req>;
130
+ declare const errorHandler: <Req = {}>(handler: ErrorHandler<Req> | ErrorHandlerFn<Req>) => ErrorHandler<Req>;
133
131
  type TypedErrorHandlerFn<Error, Req = {}> = (error: Error, req: IncomingMessage & Req, response: ServerResponse) => MaybePromise<HandlerResult>;
134
132
  declare const typedErrorHandler: <Error, Req>(ErrorClass: abstract new (...args: any[]) => Error, handler: TypedErrorHandlerFn<Error, Req>) => ErrorHandler<Req>;
135
133
  type ConditionalErrorHandler = (<Error, Req>(condition: (x: unknown) => x is Error, handler: TypedErrorHandlerFn<Error, Req>) => ErrorHandler<Req>) & (<Req>(condition: (x: unknown) => boolean, handler: TypedErrorHandlerFn<unknown, Req>) => ErrorHandler<Req>);
@@ -147,12 +145,12 @@ interface NativeListenersOptions {
147
145
  *
148
146
  * The default implementation logs the error via `console.error` unless it is a `HTTPError` with `statusCode` < 500
149
147
  */
150
- onError?: ServerGeneralErrorCallback;
148
+ onError?: ServerGeneralErrorCallback | undefined;
151
149
  /**
152
150
  * Number of milliseconds to wait before forcibly closing sockets which are left half-open by the client.
153
151
  * @default 500
154
152
  */
155
- socketCloseTimeout?: number;
153
+ socketCloseTimeout?: number | undefined;
156
154
  }
157
155
  type ServerGeneralErrorCallback = (error: unknown, context: string, req: IncomingMessage | undefined) => void;
158
156
  interface NativeListeners {
@@ -222,7 +220,7 @@ declare const WebListener_base: TypedEventTarget<WebListener, {
222
220
  }>;
223
221
  declare class WebListener extends WebListener_base {
224
222
  constructor(handler: Handler);
225
- attach(server: Server, options?: ListenerOptions): (reason?: string, existingConnectionTimeout?: number, forShutdown?: boolean, callback?: () => void) => NativeListeners;
223
+ attach(server: Server, options?: ListenerOptions): (reason?: string, existingConnectionTimeout?: number, forShutdown?: boolean, callback?: (() => void) | undefined) => NativeListeners;
226
224
  createServer(options?: ServerOptions & ListenerOptions): AugmentedServer;
227
225
  listen(port: number, host: string, options?: CombinedServerOptions): Promise<AugmentedServer>;
228
226
  }
@@ -239,7 +237,7 @@ interface AugmentedServer extends Server {
239
237
  interface HTTPErrorOptions {
240
238
  message?: string | undefined;
241
239
  statusMessage?: string | undefined;
242
- headers?: AnyHeaders;
240
+ headers?: AnyHeaders | undefined;
243
241
  body?: string | undefined;
244
242
  cause?: unknown;
245
243
  }
@@ -295,9 +293,9 @@ declare const getQuery: (req: IncomingMessage, name: string) => string | null;
295
293
 
296
294
  type CommonMethod = 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'TRACE';
297
295
  type CommonUpgrade = 'http/2' | 'http/3' | 'https' | 'h2c' | 'websocket';
298
- type RelaxedRequestHandler<Req = {}> = RequestHandlerFn<Req> | RequestHandler<Req> | ErrorHandler<Req>;
296
+ type RelaxedRequestHandler<Req = {}> = RequestHandlerFn<Req> | RequestHandler<Req> | ErrorHandler<Req> | null | undefined;
299
297
  type RelaxedRequestHandlerOrExplicitUpgrade<Req = {}> = RelaxedRequestHandler<Req> | UpgradeHandler<Req>;
300
- type RelaxedUpgradeHandler<Req = {}> = UpgradeHandlerFn<Req> | UpgradeHandler<Req> | ErrorHandler<Req>;
298
+ type RelaxedUpgradeHandler<Req = {}> = UpgradeHandlerFn<Req> | UpgradeHandler<Req> | ErrorHandler<Req> | null | undefined;
301
299
  type MethodWrapper<Req, This> = <Path extends string>(path: ValidPath<Path>, ...handlers: RelaxedRequestHandler<Req & WithPathParameters<ParametersFromPath<Path>>>[]) => This;
302
300
  type UpgradeWrapper<Req, This> = <Path extends string>(path: ValidPath<Path>, ...handlers: RelaxedUpgradeHandler<Req & WithPathParameters<ParametersFromPath<Path>>>[]) => This;
303
301
  declare class Router<Req = {}> implements Handler<Req> {
@@ -440,9 +438,12 @@ declare const hasAuthScope: (req: IncomingMessage, scope: string) => boolean;
440
438
  declare const getAuthScopes: (req: IncomingMessage) => Set<string>;
441
439
  declare const requireAuthScope: (scope: string) => RequestHandler & UpgradeHandler;
442
440
 
443
- declare function generateWeakETag(contentEncoding: string | number | string[] | undefined, fileStats: Pick<Stats, 'mtimeMs' | 'size'>): string;
441
+ declare function generateWeakETag(contentEncoding: LooseHeaderValue | undefined, fileStats: Pick<Stats, 'mtimeMs' | 'size'>): string;
444
442
  declare function generateStrongETag(file: string | Pick<ReadOnlyFileHandle, 'createReadStream'>): Promise<string>;
445
443
 
444
+ type ContentEncoding = 'zstd' | 'br' | 'gzip' | 'deflate' | 'identity';
445
+ type EncodingQuality = 'fast' | 'mid' | 'max';
446
+
446
447
  declare const FEATURES: {
447
448
  type: {
448
449
  _requestHeader: string;
@@ -462,9 +463,9 @@ interface FileNegotiation {
462
463
  /** Feature to negotiate ('type', 'language', or 'encoding') */
463
464
  feature: NegotiationFeature;
464
465
  /** Filename filter (only apply this negotiation for requests with filenames matching the pattern) */
465
- match?: string | RegExp;
466
+ match?: string | RegExp | undefined;
466
467
  /** List of negotiation options available, ordered by server preference */
467
- options: FileNegotiationOption[];
468
+ options: ReadonlyArray<FileNegotiationOption>;
468
469
  }
469
470
  interface FileNegotiationOption {
470
471
  /**
@@ -481,7 +482,7 @@ interface FileNegotiationOption {
481
482
  *
482
483
  * @example { value: 'text/plain', for: /^text\//, file: '{base}.txt' }
483
484
  */
484
- for?: RegExp;
485
+ for?: RegExp | undefined;
485
486
  /**
486
487
  * Filename modifier to apply. Several tokens are available:
487
488
  *
@@ -497,8 +498,7 @@ interface FileNegotiationOption {
497
498
  */
498
499
  file: string;
499
500
  }
500
- type FileEncodingFormat = 'zstd' | 'br' | 'gzip' | 'deflate' | 'identity';
501
- declare const negotiateEncoding: (options: FileEncodingFormat[] | Record<FileEncodingFormat, string>) => FileNegotiation;
501
+ declare const negotiateEncoding: (options: ReadonlyArray<ContentEncoding> | Record<ContentEncoding, string>) => FileNegotiation;
502
502
  type NegotiationOutputHeaders = {
503
503
  /** The negotiated mime type for the resolved file */
504
504
  'content-type'?: string;
@@ -535,79 +535,12 @@ declare class Negotiator {
535
535
  *
536
536
  * See the helper `negotiateEncoding` for a simple way to support pre-compressed files.
537
537
  */
538
- constructor(rules: FileNegotiation[], { maxFailedAttempts }?: {
538
+ constructor(rules: ReadonlyArray<FileNegotiation>, { maxFailedAttempts }?: {
539
539
  maxFailedAttempts?: number | undefined;
540
540
  });
541
541
  options(base: string, reqHeaders: IncomingHttpHeaders): Generator<NegotiationOutput, undefined, undefined>;
542
542
  }
543
543
 
544
- interface CompressionInfo {
545
- /** the path to the file */
546
- file: string;
547
- /** the mime type of the file */
548
- mime: string;
549
- /** the size of the original file in bytes */
550
- rawSize: number;
551
- /** the size of the smallest compressed version of the file in bytes */
552
- bestSize: number;
553
- /** the number of compressed files which were saved */
554
- created: number;
555
- }
556
- interface CompressionOptions {
557
- /**
558
- * the minimum compression (in bytes) which must be achieved to save the file
559
- * @default 0
560
- */
561
- minCompression?: number;
562
- /**
563
- * if `true`, existing compressed files which are no-longer relevant will be removed
564
- * @default false
565
- */
566
- deleteObsolete?: boolean;
567
- /**
568
- * if `true`, the modified time of the compressed files will be set to match the modified time of
569
- * the input file
570
- * @default true
571
- */
572
- matchModifiedTime?: boolean;
573
- /**
574
- * Filter to apply to files (does not attempt to compress files if the function returns `false`)
575
- * @param path the full path to the file
576
- * @param mime the mime type of the file (if known, else 'application/binary')
577
- * @returns `true` if the file should be compressed
578
- * @default (_, mime) => !['image', 'video', 'audio', 'font'].includes(mime.split('/')[0])
579
- */
580
- filter?: (path: string, mime: string) => boolean;
581
- }
582
- declare function compressFileOffline(file: string, encodings: FileNegotiationOption[], { minCompression, deleteObsolete, matchModifiedTime, filter, }?: CompressionOptions): Promise<CompressionInfo>;
583
- declare function compressFilesInDir(dir: string, encodings: FileNegotiationOption[], options?: CompressionOptions): Promise<CompressionInfo[]>;
584
-
585
- declare const emitError: (req: IncomingMessage, error: unknown, context?: string) => void;
586
-
587
- interface JSONErrorHandlerOptions {
588
- /**
589
- * Only send a JSON response if the client sent `Accept: application/json`.
590
- * @default true
591
- */
592
- onlyIfRequested?: boolean | undefined;
593
- /**
594
- * Emit the error to the current error listener.
595
- * @default true
596
- */
597
- emitError?: boolean | undefined;
598
- /**
599
- * If set, forces a consistent HTTP status code (ignoring the status code from the error).
600
- * @default undefined
601
- */
602
- forceStatus?: number | undefined;
603
- /**
604
- * The content-type to set on the response.
605
- * @default 'application/json'
606
- */
607
- contentType?: string;
608
- }
609
- declare const jsonErrorHandler: (conversion: (error: HTTPError) => unknown, { onlyIfRequested, emitError: doEmitError, forceStatus, contentType, }?: JSONErrorHandlerOptions) => ErrorHandler;
610
-
611
544
  interface FileFinderOptions {
612
545
  /**
613
546
  * Also serve files from sub-directories.
@@ -672,14 +605,14 @@ interface FileFinderOptions {
672
605
  *
673
606
  * @default []
674
607
  */
675
- hide?: (string | RegExp)[] | undefined;
608
+ hide?: ReadonlyArray<string | RegExp> | undefined;
676
609
  /**
677
610
  * Allow access to specific files which would otherwise be blocked as a dotfile, tilde file, or
678
611
  * hidden by `hide`.
679
612
  *
680
613
  * @default ['.well-known']
681
614
  */
682
- allow?: string[] | undefined;
615
+ allow?: ReadonlyArray<string> | undefined;
683
616
  /**
684
617
  * Files to look for if a directory is requested.
685
618
  * Note that direct access to these files will be blocked unless `allowDirectIndexAccess` is `true`.
@@ -688,7 +621,7 @@ interface FileFinderOptions {
688
621
  *
689
622
  * @default ['index.htm', 'index.html']
690
623
  */
691
- indexFiles?: string[] | undefined;
624
+ indexFiles?: ReadonlyArray<string> | undefined;
692
625
  /**
693
626
  * Suffixes to try appending if the requested file does not exist.
694
627
  *
@@ -696,7 +629,7 @@ interface FileFinderOptions {
696
629
  *
697
630
  * @default []
698
631
  */
699
- implicitSuffixes?: string[] | undefined;
632
+ implicitSuffixes?: ReadonlyArray<string> | undefined;
700
633
  /**
701
634
  * Content negotiation to apply to files.
702
635
  *
@@ -711,8 +644,8 @@ interface FileFinderOptions {
711
644
  negotiator?: Negotiator | undefined;
712
645
  }
713
646
  interface FileFinder {
714
- find(pathParts: string[], reqHeaders?: IncomingHttpHeaders, warnings?: string[] | undefined): Promise<ResolvedFileInfo | null>;
715
- toNormalisedPath(pathParts: string[]): string[];
647
+ find(pathParts: ReadonlyArray<string>, reqHeaders?: IncomingHttpHeaders | undefined, warnings?: string[] | undefined): Promise<ResolvedFileInfo | null>;
648
+ toNormalisedPath(pathParts: ReadonlyArray<string>): ReadonlyArray<string>;
716
649
  isStaticListing: boolean;
717
650
  staticPaths?: () => Set<string>;
718
651
  }
@@ -729,6 +662,73 @@ interface ResolvedFileInfo {
729
662
  headers: NegotiationOutputHeaders;
730
663
  }
731
664
 
665
+ interface CompressionInfo {
666
+ /** the path to the file */
667
+ file: string;
668
+ /** the mime type of the file */
669
+ mime: string;
670
+ /** the size of the original file in bytes */
671
+ rawSize: number;
672
+ /** the size of the smallest compressed version of the file in bytes */
673
+ bestSize: number;
674
+ /** the number of compressed files which were saved */
675
+ created: number;
676
+ }
677
+ interface CompressionOptions {
678
+ /**
679
+ * the minimum compression (in bytes) which must be achieved to save the file
680
+ * @default 0
681
+ */
682
+ minCompression?: number | undefined;
683
+ /**
684
+ * if `true`, existing compressed files which are no-longer relevant will be removed
685
+ * @default false
686
+ */
687
+ deleteObsolete?: boolean | undefined;
688
+ /**
689
+ * if `true`, the modified time of the compressed files will be set to match the modified time of
690
+ * the input file
691
+ * @default true
692
+ */
693
+ matchModifiedTime?: boolean | undefined;
694
+ /**
695
+ * Filter to apply to files (does not attempt to compress files if the function returns `false`)
696
+ * @param path the full path to the file
697
+ * @param mime the mime type of the file (if known, else 'application/binary')
698
+ * @returns `true` if the file should be compressed
699
+ * @default (_, mime) => !['image', 'video', 'audio', 'font'].includes(mime.split('/')[0])
700
+ */
701
+ filter?: ((path: string, mime: string) => boolean) | undefined;
702
+ }
703
+ declare function compressFileOffline(file: string, encodings: ReadonlyArray<FileNegotiationOption>, { minCompression, deleteObsolete, matchModifiedTime, filter, }?: CompressionOptions): Promise<CompressionInfo>;
704
+ declare function compressFilesInDir(dir: string, encodings: ReadonlyArray<FileNegotiationOption>, options?: CompressionOptions & Pick<FileFinderOptions, 'subDirectories' | 'allowAllDotfiles' | 'allowAllTildefiles' | 'hide' | 'allow'>): Promise<CompressionInfo[]>;
705
+
706
+ declare const emitError: (req: IncomingMessage, error: unknown, context?: string | undefined) => void;
707
+
708
+ interface JSONErrorHandlerOptions {
709
+ /**
710
+ * Only send a JSON response if the client sent `Accept: application/json`.
711
+ * @default true
712
+ */
713
+ onlyIfRequested?: boolean | undefined;
714
+ /**
715
+ * Emit the error to the current error listener.
716
+ * @default true
717
+ */
718
+ emitError?: boolean | undefined;
719
+ /**
720
+ * If set, forces a consistent HTTP status code (ignoring the status code from the error).
721
+ * @default undefined
722
+ */
723
+ forceStatus?: number | undefined;
724
+ /**
725
+ * The content-type to set on the response.
726
+ * @default 'application/json'
727
+ */
728
+ contentType?: string | undefined;
729
+ }
730
+ declare const jsonErrorHandler: (conversion: (error: HTTPError) => unknown, { onlyIfRequested, emitError: doEmitError, forceStatus, contentType, }?: JSONErrorHandlerOptions) => ErrorHandler;
731
+
732
732
  declare const dynamicFileFinder: (baseDir: string, options?: FileFinderOptions) => Promise<FileFinder>;
733
733
 
734
734
  declare function staticFileFinder(baseDir: string, options?: FileFinderOptions): Promise<FileFinder & {
@@ -747,7 +747,7 @@ declare class ZipDirectory {
747
747
  path: string[];
748
748
  node: ZipFile;
749
749
  }, undefined, undefined>;
750
- find(path: string[]): ZipNode | undefined;
750
+ find(path: ReadonlyArray<string>): ZipNode | undefined;
751
751
  }
752
752
  declare class ZipFile {
753
753
  readonly virtual: boolean;
@@ -755,13 +755,13 @@ declare class ZipFile {
755
755
  get zipFilePath(): string;
756
756
  get filesystemPath(): string;
757
757
  get crc32(): number;
758
- stat(opts?: StatOptions & {
758
+ stat(opts?: (StatOptions & {
759
759
  bigint?: false | undefined;
760
- }): Stats;
760
+ }) | undefined): Stats;
761
761
  stat(opts: StatOptions & {
762
762
  bigint: true;
763
763
  }): BigIntStats;
764
- stat(opts?: StatOptions): Stats | BigIntStats;
764
+ stat(opts?: StatOptions | undefined): Stats | BigIntStats;
765
765
  open(): Promise<ReadOnlyFileHandle>;
766
766
  }
767
767
 
@@ -778,9 +778,9 @@ interface SavedFile {
778
778
  interface TempFileStorage {
779
779
  dir: string;
780
780
  nextFile: () => string;
781
- save: (stream: Readable | ReadableStream, options?: {
781
+ save: (stream: Readable | ReadableStream$1, options?: {
782
782
  mode?: number | undefined;
783
- }) => Promise<SavedFile>;
783
+ } | undefined) => Promise<SavedFile>;
784
784
  }
785
785
  declare const makeTempFileStorage: (req: IncomingMessage) => Promise<TempFileStorage>;
786
786
 
@@ -803,7 +803,7 @@ interface GetClientOptions {
803
803
  * @default 0 if trustedProxyAddresses is not set
804
804
  * @default infinity if trustedProxyAddresses is set
805
805
  */
806
- trustedProxyCount?: number;
806
+ trustedProxyCount?: number | undefined;
807
807
  /**
808
808
  * The proxies to trust.
809
809
  *
@@ -813,7 +813,7 @@ interface GetClientOptions {
813
813
  *
814
814
  * @default none (trust all proxies within trustedProxyCount hops)
815
815
  */
816
- trustedProxyAddresses?: string[];
816
+ trustedProxyAddresses?: ReadonlyArray<string> | undefined;
817
817
  /**
818
818
  * The headers which are set (or cleared) by your proxy, and can therefore be trusted.
819
819
  *
@@ -823,7 +823,7 @@ interface GetClientOptions {
823
823
  *
824
824
  * @default [] (no headers are trusted)
825
825
  */
826
- trustedHeaders: ProxyHeader[];
826
+ trustedHeaders: ReadonlyArray<ProxyHeader>;
827
827
  }
828
828
  type GetClient = (req: IncomingMessage) => ProxyChain;
829
829
  declare function makeGetClient({ trustedProxyCount, trustedProxyAddresses, trustedHeaders, }: GetClientOptions): GetClient;
@@ -845,8 +845,8 @@ type ProxyResponseHeaderAdapter = (request: IncomingMessage, proxyResponse: Inco
845
845
  declare function removeForwarded(_: IncomingMessage, headers: IncomingHttpHeaders): OutgoingHttpHeaders;
846
846
  declare function replaceForwarded(req: IncomingMessage, headers: IncomingHttpHeaders): OutgoingHttpHeaders;
847
847
  declare const sanitiseAndAppendForwarded: (getClient: (req: IncomingMessage) => {
848
- outwardChain: ProxyNode[];
849
- trusted: ProxyNode[];
848
+ outwardChain: ReadonlyArray<ProxyNode>;
849
+ trusted: ReadonlyArray<ProxyNode>;
850
850
  }, { onlyTrusted }?: {
851
851
  onlyTrusted?: boolean | undefined;
852
852
  }) => (req: IncomingMessage, headers: IncomingHttpHeaders) => OutgoingHttpHeaders;
@@ -861,7 +861,7 @@ interface ProxyOptions extends AgentOptions {
861
861
  *
862
862
  * @default []
863
863
  */
864
- blockRequestHeaders?: string[] | undefined;
864
+ blockRequestHeaders?: ReadonlyArray<string> | undefined;
865
865
  /**
866
866
  * A list of headers to remove from proxied responses (runs before `responseHeaders`).
867
867
  * Hop-by-hop headers (including standard hop-by-hop headers and
@@ -869,17 +869,17 @@ interface ProxyOptions extends AgentOptions {
869
869
  *
870
870
  * @default []
871
871
  */
872
- blockResponseHeaders?: string[] | undefined;
872
+ blockResponseHeaders?: ReadonlyArray<string> | undefined;
873
873
  /**
874
874
  * Mutators for the proxied request headers. e.g. `replaceForwarded`.
875
875
  */
876
- requestHeaders?: ProxyRequestHeaderAdapter[] | undefined;
876
+ requestHeaders?: ReadonlyArray<ProxyRequestHeaderAdapter> | undefined;
877
877
  /**
878
878
  * Mutators for the proxied response headers.
879
879
  */
880
- responseHeaders?: ProxyResponseHeaderAdapter[] | undefined;
880
+ responseHeaders?: ReadonlyArray<ProxyResponseHeaderAdapter> | undefined;
881
881
  }
882
- declare function proxy(forwardHost: string | URL, { blockRequestHeaders, requestHeaders, blockResponseHeaders, responseHeaders, agent, ...options }?: ProxyOptions): RequestHandler<unknown>;
882
+ declare function proxy(forwardHost: string | URL, { blockRequestHeaders, requestHeaders, blockResponseHeaders, responseHeaders, agent, ...options }?: ProxyOptions): RequestHandler<{}>;
883
883
 
884
884
  interface TextDecoderOptions {
885
885
  fatal?: boolean;
@@ -894,7 +894,7 @@ type DecoderStream = TransformStream<Uint8Array, string>;
894
894
 
895
895
  interface Charset {
896
896
  decoder: (options: TextDecoderOptions) => Decoder;
897
- decoderStream?: (options: TextDecoderOptions) => DecoderStream;
897
+ decoderStream?: ((options: TextDecoderOptions) => DecoderStream) | undefined;
898
898
  }
899
899
  declare function registerCharset(charsetName: string, definition: Charset): void;
900
900
  declare function registerUTF32(): void;
@@ -913,36 +913,36 @@ declare function getMime(ext: string, charset?: string): string;
913
913
 
914
914
  declare function checkIfModified(req: IncomingMessage, res: ServerResponse, fileStats: Pick<Stats, 'mtimeMs' | 'size'> | null): boolean;
915
915
  declare function checkIfRange(req: IncomingMessage, res: ServerResponse, fileStats: Pick<Stats, 'mtimeMs' | 'size'>): boolean;
916
- declare function compareETag(res: ServerResponse, fileStats: Pick<Stats, 'mtimeMs' | 'size'> | null, etags: string[]): boolean;
916
+ declare function compareETag(res: ServerResponse, fileStats: Pick<Stats, 'mtimeMs' | 'size'> | null, etags: ReadonlyArray<string>): boolean;
917
917
 
918
918
  interface GetBodyOptions {
919
919
  /**
920
920
  * The maximum content length after applying all decoding steps
921
921
  * @default Infinity
922
922
  */
923
- maxContentBytes?: number;
923
+ maxContentBytes?: number | undefined;
924
924
  /**
925
925
  * The maximum content length as sent (before applying any decoding steps)
926
926
  * @default maxContentBytes
927
927
  */
928
- maxNetworkBytes?: number;
928
+ maxNetworkBytes?: number | undefined;
929
929
  /**
930
930
  * The maximum number of content-encoding steps the client can specify.
931
931
  * Browsers typically do not use any content-encoding in requests, and it is unlikely that this would need to be set greater than 1 for any standard client.
932
932
  * @default 1
933
933
  */
934
- maxEncodingSteps?: number;
934
+ maxEncodingSteps?: number | undefined;
935
935
  }
936
936
  interface GetBodyTextOptions extends GetBodyOptions, TextDecoderOptions {
937
- defaultCharset?: string;
937
+ defaultCharset?: string | undefined;
938
938
  }
939
939
  interface GetBodyJSONOptions extends GetBodyOptions, TextDecoderOptions {
940
940
  reviver?: ((this: Record<string, unknown> | unknown[], key: string, value: unknown, context?: {
941
- source?: string;
942
- }) => unknown) | undefined;
941
+ source?: string | undefined;
942
+ } | undefined) => unknown) | undefined;
943
943
  }
944
- declare function getBodyStream(req: IncomingMessage, { maxContentBytes, maxNetworkBytes, maxEncodingSteps, }?: GetBodyOptions): ReadableStream<Uint8Array>;
945
- declare function getBodyTextStream(req: IncomingMessage, options?: GetBodyTextOptions): ReadableStream<string>;
944
+ declare function getBodyStream(req: IncomingMessage, { maxContentBytes, maxNetworkBytes, maxEncodingSteps, }?: GetBodyOptions): ReadableStream$1<Uint8Array>;
945
+ declare function getBodyTextStream(req: IncomingMessage, options?: GetBodyTextOptions): ReadableStream$1<string>;
946
946
  declare function getBodyText(req: IncomingMessage, options?: GetBodyTextOptions): Promise<string>;
947
947
  declare function getBodyJSON(req: IncomingMessage, options?: GetBodyJSONOptions): Promise<unknown>;
948
948
 
@@ -954,38 +954,38 @@ interface BusboyOptions {
954
954
  * `true` to block `multipart/form-data` (including file uploads). If set, only `application/x-www-form-urlencoded` is supported.
955
955
  * @default false
956
956
  */
957
- blockMultipart?: boolean;
957
+ blockMultipart?: boolean | undefined;
958
958
  /**
959
959
  * `true` to preserve path information in filenames. `false` to only include the basename (omitting everything before the last `/` or `\`)
960
960
  * @default false
961
961
  */
962
- preservePath?: boolean;
962
+ preservePath?: boolean | undefined;
963
963
  /**
964
964
  * High water mark to set on file streams.
965
965
  * @default 65536
966
966
  */
967
- fileHwm?: number;
967
+ fileHwm?: number | undefined;
968
968
  /**
969
969
  * Default character set to use for reading name and filename from the content-disposition header in multipart content.
970
970
  * According to the standard this should be `latin1`, but most browsers use `utf-8`.
971
971
  * @default 'utf-8'
972
972
  */
973
- defParamCharset?: string;
973
+ defParamCharset?: string | undefined;
974
974
  /**
975
975
  * Default character set to use for reading field content (and field names in urlencoded content).
976
976
  * @default 'utf-8'
977
977
  */
978
- defCharset?: string;
978
+ defCharset?: string | undefined;
979
979
  /**
980
980
  * The maximum content length as sent (including e.g. multipart boundaries and headers)
981
981
  * @default Infinity
982
982
  */
983
- maxNetworkBytes?: number;
983
+ maxNetworkBytes?: number | undefined;
984
984
  /**
985
985
  * The maximum content length, combining all field names, values, and files
986
986
  * @default maxNetworkBytes
987
987
  */
988
- maxContentBytes?: number;
988
+ maxContentBytes?: number | undefined;
989
989
  /**
990
990
  * The maximum field name size (in bytes).
991
991
  * @default 100
@@ -1052,13 +1052,13 @@ interface GetFormFieldsOptions extends BusboyOptions {
1052
1052
  * This can be used to prevent clients uploading large files when the request has already been rejected.
1053
1053
  * @default 500
1054
1054
  */
1055
- closeAfterErrorDelay?: number;
1055
+ closeAfterErrorDelay?: number | undefined;
1056
1056
  }
1057
1057
  interface GetFormDataOptions extends GetFormFieldsOptions {
1058
1058
  /** true to apply .trim() to all field values */
1059
- trimAllValues?: boolean;
1059
+ trimAllValues?: boolean | undefined;
1060
1060
  /** function to apply to all uploaded files (e.g. to check available disk space) */
1061
- preCheckFile?: PreCheckFile;
1061
+ preCheckFile?: PreCheckFile | undefined;
1062
1062
  }
1063
1063
  type PreCheckFile = (info: PreCheckFileInfo) => MaybePromise<PostCheckFile | void>;
1064
1064
  interface PreCheckFileInfo {
@@ -1091,8 +1091,8 @@ interface RangePart {
1091
1091
  end: number;
1092
1092
  }
1093
1093
  interface SimplifyRangeOptions {
1094
- forceSequential?: boolean;
1095
- mergeOverlapDistance?: number;
1094
+ forceSequential?: boolean | undefined;
1095
+ mergeOverlapDistance?: number | undefined;
1096
1096
  }
1097
1097
  declare function simplifyRange(original: HTTPRange, { forceSequential, mergeOverlapDistance }?: SimplifyRangeOptions): HTTPRange;
1098
1098
 
@@ -1112,7 +1112,7 @@ interface GetRangeOptions {
1112
1112
  *
1113
1113
  * @default 10
1114
1114
  */
1115
- maxRanges?: number;
1115
+ maxRanges?: number | undefined;
1116
1116
  /**
1117
1117
  * Maximum number of ranges a client can request in a single message if any ranges are
1118
1118
  * non-sequential (i.e. a later range begins at lower offset than an earlier range).
@@ -1122,7 +1122,7 @@ interface GetRangeOptions {
1122
1122
  *
1123
1123
  * @default 2
1124
1124
  */
1125
- maxNonSequential?: number;
1125
+ maxNonSequential?: number | undefined;
1126
1126
  /**
1127
1127
  * Maximum number of ranges a client can request in a single message if any ranges are
1128
1128
  * overlapping.
@@ -1132,7 +1132,7 @@ interface GetRangeOptions {
1132
1132
  *
1133
1133
  * @default 2
1134
1134
  */
1135
- maxWithOverlap?: number;
1135
+ maxWithOverlap?: number | undefined;
1136
1136
  }
1137
1137
  declare function getRange(req: IncomingMessage, totalSize: number, { maxRanges, maxNonSequential, maxWithOverlap }?: GetRangeOptions): HTTPRange | undefined;
1138
1138
  interface QualityValue {
@@ -1146,7 +1146,6 @@ declare function readHTTPInteger(raw: string | undefined): number | undefined;
1146
1146
  declare const readHTTPQualityValues: (raw: LooseHeaderValue | undefined) => QualityValue[] | undefined;
1147
1147
  declare function readHTTPKeyValues(raw: string): Map<string, string>;
1148
1148
  declare function readHTTPDateSeconds(raw: LooseHeaderValue | undefined): number | undefined;
1149
- type LooseHeaderValue = string | number | string[];
1150
1149
 
1151
1150
  declare function getRemainingPathComponents(req: IncomingMessage, { rejectPotentiallyUnsafe }?: {
1152
1151
  rejectPotentiallyUnsafe?: boolean | undefined;
@@ -1166,22 +1165,22 @@ interface CSVOptions {
1166
1165
  * The delimiter to use between cells
1167
1166
  * @default ','
1168
1167
  */
1169
- delimiter?: string | Uint8Array;
1168
+ delimiter?: string | Uint8Array | undefined;
1170
1169
  /**
1171
1170
  * The delimiter to use between rows
1172
1171
  * @default '\n'
1173
1172
  */
1174
- newline?: string | Uint8Array;
1173
+ newline?: string | Uint8Array | undefined;
1175
1174
  /**
1176
1175
  * The quote character to use. Typically should be `"` or (if the target application supports it) `'`
1177
1176
  * @default '"'
1178
1177
  */
1179
- quote?: string;
1178
+ quote?: string | undefined;
1180
1179
  /**
1181
1180
  * The text encoding to use.
1182
1181
  * @default 'utf-8'
1183
1182
  */
1184
- encoding?: BufferEncoding;
1183
+ encoding?: BufferEncoding | undefined;
1185
1184
  /**
1186
1185
  * For use with `ServerResponse` targets.
1187
1186
  * If `true`, adds header=present to the mime type; if `false`, adds header=absent to the mime type.
@@ -1192,11 +1191,11 @@ interface CSVOptions {
1192
1191
  * If `true`, will call `end()` on target stream after writing.
1193
1192
  * @default true
1194
1193
  */
1195
- end?: boolean;
1194
+ end?: boolean | undefined;
1196
1195
  }
1197
1196
  type MaybeAsyncIterable<T> = Iterable<T> | AsyncIterable<T>;
1198
1197
  type MaybeLoadOnDemand<T> = LoadOnDemand<T> | T;
1199
- type CellContent = string | ReadableStream<string> | Readable | null | undefined;
1198
+ type CellContent = string | ReadableStream$1<string> | Readable | null | undefined;
1200
1199
  /**
1201
1200
  * Output a CSV formatted table, using the format from RFC4180.
1202
1201
  * Specifically:
@@ -1209,36 +1208,48 @@ type CellContent = string | ReadableStream<string> | Readable | null | undefined
1209
1208
  */
1210
1209
  declare function sendCSVStream(target: Writable, table: MaybeLoadOnDemand<MaybeAsyncIterable<MaybeLoadOnDemand<MaybeAsyncIterable<MaybeLoadOnDemand<CellContent>>>>>, { delimiter, newline, quote, encoding, headerRow, end, }?: CSVOptions): Promise<void>;
1211
1210
 
1211
+ interface EncoderOptions {
1212
+ encodings?: ReadonlyArray<ContentEncoding> | undefined;
1213
+ encodingQuality?: EncodingQuality | undefined;
1214
+ estimatedLength?: number | undefined;
1215
+ compressionSizeThreshold?: number | undefined;
1216
+ }
1217
+ declare function makeResponseEncoder(req: IncomingMessage, res: ServerResponse, { encodings, encodingQuality, estimatedLength, compressionSizeThreshold, }?: EncoderOptions): Writable;
1218
+ declare function sendEncoded(req: IncomingMessage, res: ServerResponse, content: string, options?: (EncoderOptions & {
1219
+ encoding?: BufferEncoding | undefined;
1220
+ }) | undefined): Promise<void>;
1221
+ declare function sendEncoded(req: IncomingMessage, res: ServerResponse, content: ArrayBufferView | Readable | ReadableStream<Uint8Array>, options?: EncoderOptions | undefined): Promise<void>;
1222
+
1212
1223
  declare function sendFile(req: IncomingMessage, res: ServerResponse, source: string | (Pick<ReadOnlyFileHandle, 'createReadStream'> & {
1213
1224
  stat?: () => Promise<Pick<Stats, 'mtimeMs' | 'size'>>;
1214
- }) | Readable | ReadableStream<Uint8Array>, fileStats?: Pick<Stats, 'mtimeMs' | 'size'> | null, options?: GetRangeOptions & SimplifyRangeOptions): Promise<void>;
1225
+ }) | Readable | ReadableStream$1<Uint8Array>, fileStats?: Pick<Stats, 'mtimeMs' | 'size'> | null, options?: (GetRangeOptions & SimplifyRangeOptions) | undefined): Promise<void>;
1215
1226
 
1216
1227
  interface JSONOptions {
1217
1228
  /**
1218
1229
  * Either a function to invoke on every object (recursive) to be printed, or a list of properties to filter for when printing objects (applies to nested objects too).
1219
1230
  * @default null
1220
1231
  */
1221
- replacer?: ((this: unknown, key: string, value: unknown) => unknown) | (number | string)[] | null;
1232
+ replacer?: ((this: unknown, key: string, value: unknown) => unknown) | ReadonlyArray<number | string> | null | undefined;
1222
1233
  /**
1223
1234
  * The amount of spacing to use for indentation. If this is 0, no spacing is used anywhere.
1224
1235
  * @default 0
1225
1236
  */
1226
- space?: string | number | null;
1237
+ space?: string | number | null | undefined;
1227
1238
  /**
1228
1239
  * If the top-level value being encoded is `undefined`, setting this to `true` will output `null`. `false` will output nothing.
1229
1240
  * @default false
1230
1241
  */
1231
- undefinedAsNull?: boolean;
1242
+ undefinedAsNull?: boolean | undefined;
1232
1243
  /**
1233
1244
  * The text encoding to use. Note that only Unicode variants are permitted by the standard.
1234
1245
  * @default 'utf-8'
1235
1246
  */
1236
- encoding?: BufferEncoding;
1247
+ encoding?: BufferEncoding | undefined;
1237
1248
  /**
1238
1249
  * Whether to close the writable automatically after writing the JSON content.
1239
1250
  * @default true
1240
1251
  */
1241
- end?: boolean;
1252
+ end?: boolean | undefined;
1242
1253
  }
1243
1254
  declare function sendJSON(target: Writable, entity: unknown, { replacer, space, undefinedAsNull, encoding, end }?: JSONOptions): void;
1244
1255
  declare function sendJSONStream(target: Writable, entity: unknown, { replacer, space, undefinedAsNull, encoding, end, }?: JSONOptions): Promise<void>;
@@ -1250,12 +1261,12 @@ declare global {
1250
1261
  }
1251
1262
  }
1252
1263
 
1253
- declare function sendRanges(req: IncomingMessage, res: ServerResponse, source: string | Pick<ReadOnlyFileHandle, 'createReadStream' | 'noRandomAccess'> | Readable | ReadableStream<Uint8Array>, httpRange: HTTPRange): Promise<void>;
1264
+ declare function sendRanges(req: IncomingMessage, res: ServerResponse, source: string | Pick<ReadOnlyFileHandle, 'createReadStream' | 'noRandomAccess'> | Readable | ReadableStream$1<Uint8Array>, httpRange: HTTPRange): Promise<void>;
1254
1265
 
1255
1266
  interface ServerSentEventsOptions {
1256
- keepaliveInterval?: number;
1257
- softCloseReconnectDelay?: number;
1258
- softCloseReconnectStagger?: number;
1267
+ keepaliveInterval?: number | undefined;
1268
+ softCloseReconnectDelay?: number | undefined;
1269
+ softCloseReconnectStagger?: number | undefined;
1259
1270
  }
1260
1271
  interface ServerSentEvent {
1261
1272
  event?: string;
@@ -1269,7 +1280,7 @@ declare class ServerSentEvents {
1269
1280
  get open(): boolean;
1270
1281
  ping(): void;
1271
1282
  send({ event, id, data, reconnectDelay }: ServerSentEvent): Promise<void>;
1272
- sendFields(parts: [string, string | undefined][]): Promise<void>;
1283
+ sendFields(parts: ReadonlyArray<[string, string | undefined]>): Promise<void>;
1273
1284
  close(reconnectDelay?: number, reconnectStagger?: number): Promise<void>;
1274
1285
  }
1275
1286
 
@@ -1307,7 +1318,7 @@ interface AssetServerOptions {
1307
1318
  *
1308
1319
  * @default ['etag', 'last-modified']
1309
1320
  */
1310
- dynamicHeaders?: ('etag' | 'last-modified')[] | false | undefined;
1321
+ dynamicHeaders?: ReadonlyArray<'etag' | 'last-modified'> | false | undefined;
1311
1322
  /**
1312
1323
  * A function to call when a file is being served. Can modify headers in the response.
1313
1324
  *
@@ -1374,15 +1385,13 @@ interface FileServerOptions extends AssetServerOptions, FileFinderOptions {
1374
1385
  */
1375
1386
  declare const fileServer: (baseDir: string, options?: FileServerOptions) => Promise<RequestHandler<{}>>;
1376
1387
 
1377
- type ContentEncoding = 'zstd' | 'br' | 'gzip' | 'deflate';
1378
-
1379
1388
  interface StaticContentOptions {
1380
1389
  headers?: AnyHeaders | undefined;
1381
- encodings?: ContentEncoding[] | undefined;
1382
- minCompression?: number;
1390
+ encodings?: ReadonlyArray<ContentEncoding> | undefined;
1391
+ minCompression?: number | undefined;
1383
1392
  }
1384
1393
  declare const staticContent: (content: Buffer, contentType: string, { headers, encodings, minCompression }?: StaticContentOptions) => RequestHandler;
1385
- declare const staticJSON: (content: unknown, options?: StaticContentOptions) => RequestHandler<{}>;
1394
+ declare const staticJSON: (content: unknown, options?: StaticContentOptions | undefined) => RequestHandler<{}>;
1386
1395
 
1387
1396
  interface InternalWebSocketServerOptions {
1388
1397
  noServer?: true;
@@ -1412,7 +1421,7 @@ interface ListenableWebSocket {
1412
1421
  on(event: 'close', handler: CloseHandler): void;
1413
1422
  off(event: 'message', handler: MessageHandler): void;
1414
1423
  off(event: 'close', handler: CloseHandler): void;
1415
- readyState?: number;
1424
+ readyState?: number | undefined;
1416
1425
  }
1417
1426
  declare class WebSocketMessage {
1418
1427
  readonly data: Buffer;
@@ -1422,18 +1431,18 @@ declare class WebSocketMessage {
1422
1431
  get binary(): Buffer<ArrayBufferLike>;
1423
1432
  }
1424
1433
  interface WebSocketMessagesOptions {
1425
- limit?: number;
1434
+ limit?: number | undefined;
1426
1435
  signal?: AbortSignal | undefined;
1427
1436
  }
1428
1437
  declare class WebSocketMessages implements AsyncIterable<WebSocketMessage, unknown, undefined> {
1429
1438
  readonly detach: () => void;
1430
1439
  constructor(ws: ListenableWebSocket, { limit, signal }?: WebSocketMessagesOptions);
1431
- next(timeout?: number): Promise<WebSocketMessage>;
1440
+ next(timeout?: number | undefined): Promise<WebSocketMessage>;
1432
1441
  [Symbol.asyncIterator](): AsyncIterator<WebSocketMessage, unknown, undefined>;
1433
1442
  }
1434
1443
  declare function nextWebSocketMessage(ws: ListenableWebSocket, { timeout, signal }?: {
1435
- timeout?: number;
1436
- signal?: AbortSignal;
1444
+ timeout?: number | undefined;
1445
+ signal?: AbortSignal | undefined;
1437
1446
  }): Promise<WebSocketMessage>;
1438
1447
 
1439
1448
  declare function isWebSocketRequest(req: IncomingMessage): boolean;
@@ -1449,9 +1458,9 @@ declare const getWebSocketOrigin: (req: IncomingMessage) => string | undefined;
1449
1458
  declare const makeWebSocketFallbackTokenFetcher: <Req>(acceptWebSocket: (req: IncomingMessage & Req) => Promise<ListenableWebSocket>, timeout?: number) => (req: IncomingMessage & Req) => Promise<string | undefined>;
1450
1459
 
1451
1460
  interface WebSocketErrorOptions {
1452
- message?: string;
1453
- closeReason?: string;
1454
- cause?: unknown;
1461
+ message?: string | undefined;
1462
+ closeReason?: string | undefined;
1463
+ cause?: unknown | undefined;
1455
1464
  }
1456
1465
  declare class WebSocketError extends Error {
1457
1466
  readonly closeCode: number;
@@ -1473,9 +1482,9 @@ declare class Property<T> {
1473
1482
  set(req: IncomingMessage, value: T): void;
1474
1483
  get(req: IncomingMessage): T;
1475
1484
  clear(req: IncomingMessage): void;
1476
- withValue(value: T): RequestHandler<unknown> & UpgradeHandler<unknown>;
1485
+ withValue(value: T): RequestHandler<{}> & UpgradeHandler<{}>;
1477
1486
  }
1478
1487
  declare const makeMemo: <T, Args extends any[] = []>(fn: (req: IncomingMessage, ...args: Args) => T, ...args: Args) => ((req: IncomingMessage) => T);
1479
1488
 
1480
- export { BlockingQueue, CONTINUE, HTTPError, LoadOnDemand, NEXT_ROUTE, NEXT_ROUTER, Negotiator, PP_BASE_DENY_2026, Property, Queue, Router, STOP, ServerSentEvents, SharedFileHandle, WebListener, WebSocketError, WebSocketMessage, WebSocketMessages, ZipDirectory, ZipFile, acceptBody, acceptUpgrade, addTeardown, anyHandler, assetServer, checkIfModified, checkIfRange, compareETag, compressFileOffline, compressFilesInDir, conditionalErrorHandler, createSafeReadStream, decompressMime, defer, delegateUpgrade, dynamicFileFinder, emitError, errorHandler, fileServer, findCause, generateStrongETag, generateWeakETag, getAbortSignal, getAbsolutePath, getAddressURL, getAuthScopes, getAuthorization, getBodyJSON, getBodyStream, getBodyText, getBodyTextStream, getCharset, getFormData, getFormFields, getIfRange, getMime, getPathParameter, getPathParameters, getQuery, getRange, getRemainingPathComponents, getSearch, getSearchParams, getTextDecoder, getTextDecoderStream, getWebSocketOrigin, hasAuthScope, isSoftClosed, isWebSocketRequest, jsonErrorHandler, loadOnDemand, makeAcceptWebSocket, makeAddressTester, makeGetClient, makeMemo, makeTempFileStorage, makeWebSocketFallbackTokenFetcher, mergePermissionsPolicy, negotiateEncoding, nextWebSocketMessage, parseAddress, proxy, readHTTPDateSeconds, readHTTPInteger, readHTTPKeyValues, readHTTPQualityValues, readHTTPUnquotedCommaSeparated, readMimeTypes, readZip, registerCharset, registerMime, registerUTF32, removeForwarded, replaceForwarded, requestHandler, requireAuthScope, requireBearerAuth, resetMime, restoreAbsolutePath, sanitiseAndAppendForwarded, scheduleClose, sendCSVStream, sendFile, sendJSON, sendJSONStream, sendRanges, setSoftCloseHandler, simpleAppendForwarded, simplifyRange, staticContent, staticFileFinder, staticJSON, stringPredicate, toListeners, typedErrorHandler, upgradeHandler, willSendBody, zipFileFinder };
1481
- export type { AcceptUpgradeHandler, AcceptUpgradeResult, Address, AnyHeaders, AssetServerOptions, AugmentedFormData, AugmentedServer, CSVOptions, CloseableReadable, CombinedServerOptions, CommonMethod, CommonUpgrade, CompressionInfo, CompressionOptions, ErrorHandler, FallbackOptions, FileFinder, FileFinderOptions, FileNegotiation, FileNegotiationOption, FileServerOptions, FormField, GetClient, GetClientOptions, GetFormDataOptions, GetFormFieldsOptions, GetRangeOptions, HTTPErrorOptions, HTTPRange, HandlerResult, JSONErrorHandlerOptions, JSONOptions, ListenOptions, ListenerOptions, NativeListeners, NegotiationOutput, NegotiationOutputHeaders, ParametersFromPath, PostCheckFile, PostCheckFileInfo, PreCheckFile, PreCheckFileInfo, ProxyChain, ProxyNode, ProxyOptions, ProxyRequestHeaderAdapter, ProxyResponseHeaderAdapter, QualityValue, RangePart, ReadOnlyFileHandle, RequestHandler, ResolvedFileInfo, ServerErrorCallback, ServerGeneralErrorCallback, ServerSentEvent, SimplifyRangeOptions, StaticContentOptions, TokenAuthHandler, UpgradeErrorHandler, UpgradeHandler, UpgradeListener, ValidPath, WithPathParameters, ZipNode };
1489
+ export { BlockingQueue, CONTINUE, HTTPError, LoadOnDemand, NEXT_ROUTE, NEXT_ROUTER, Negotiator, PP_BASE_DENY_2026, Property, Queue, Router, STOP, ServerSentEvents, SharedFileHandle, WebListener, WebSocketError, WebSocketMessage, WebSocketMessages, ZipDirectory, ZipFile, acceptBody, acceptUpgrade, addTeardown, anyHandler, assetServer, checkIfModified, checkIfRange, compareETag, compressFileOffline, compressFilesInDir, conditionalErrorHandler, createSafeReadStream, decompressMime, defer, delegateUpgrade, dynamicFileFinder, emitError, errorHandler, fileServer, findCause, generateStrongETag, generateWeakETag, getAbortSignal, getAbsolutePath, getAddressURL, getAuthScopes, getAuthorization, getBodyJSON, getBodyStream, getBodyText, getBodyTextStream, getCharset, getFormData, getFormFields, getIfRange, getMime, getPathParameter, getPathParameters, getQuery, getRange, getRemainingPathComponents, getSearch, getSearchParams, getTextDecoder, getTextDecoderStream, getWebSocketOrigin, hasAuthScope, isSoftClosed, isWebSocketRequest, jsonErrorHandler, loadOnDemand, makeAcceptWebSocket, makeAddressTester, makeGetClient, makeMemo, makeResponseEncoder, makeTempFileStorage, makeWebSocketFallbackTokenFetcher, mergePermissionsPolicy, negotiateEncoding, nextWebSocketMessage, parseAddress, proxy, readHTTPDateSeconds, readHTTPInteger, readHTTPKeyValues, readHTTPQualityValues, readHTTPUnquotedCommaSeparated, readMimeTypes, readZip, registerCharset, registerMime, registerUTF32, removeForwarded, replaceForwarded, requestHandler, requireAuthScope, requireBearerAuth, resetMime, restoreAbsolutePath, sanitiseAndAppendForwarded, scheduleClose, sendCSVStream, sendEncoded, sendFile, sendJSON, sendJSONStream, sendRanges, setSoftCloseHandler, simpleAppendForwarded, simplifyRange, staticContent, staticFileFinder, staticJSON, stringPredicate, toListeners, typedErrorHandler, upgradeHandler, willSendBody, zipFileFinder };
1490
+ export type { AcceptUpgradeHandler, AcceptUpgradeResult, Address, AnyHeaders, AssetServerOptions, AugmentedFormData, AugmentedServer, CSVOptions, CombinedServerOptions, CommonMethod, CommonUpgrade, CompressionInfo, CompressionOptions, ContentEncoding, EncoderOptions, EncodingQuality, ErrorHandler, FallbackOptions, FileFinder, FileFinderOptions, FileNegotiation, FileNegotiationOption, FileServerOptions, FormField, GetClient, GetClientOptions, GetFormDataOptions, GetFormFieldsOptions, GetRangeOptions, HTTPErrorOptions, HTTPRange, HandlerResult, JSONErrorHandlerOptions, JSONOptions, ListenOptions, ListenerOptions, NativeListeners, NegotiationOutput, NegotiationOutputHeaders, ParametersFromPath, PostCheckFile, PostCheckFileInfo, PreCheckFile, PreCheckFileInfo, ProxyChain, ProxyNode, ProxyOptions, ProxyRequestHeaderAdapter, ProxyResponseHeaderAdapter, QualityValue, RangePart, ReadOnlyFileHandle, RequestHandler, ResolvedFileInfo, ServerErrorCallback, ServerGeneralErrorCallback, ServerSentEvent, SimplifyRangeOptions, StaticContentOptions, TokenAuthHandler, UpgradeErrorHandler, UpgradeHandler, UpgradeListener, ValidPath, WithPathParameters, ZipNode };