1- import type { Server as HttpServer , IncomingMessage } from 'node:http' ;
1+ import type { Server as HttpServer } from 'node:http' ;
22import type { Server as HttpsServer } from 'node:https' ;
3- import type { Duplex } from 'node:stream ' ;
3+ import type { RunServerOptions } from 'metro ' ;
44import type { Reporter } from './reporter.js' ;
55import type { Config as HarnessConfig } from '@react-native-harness/config' ;
66
7- export type MetroWebSocketEndpoint = {
8- handleUpgrade : (
9- request : IncomingMessage ,
10- socket : Duplex ,
11- upgradeHead : Buffer ,
12- callback : ( client : unknown , request : IncomingMessage ) => void
13- ) => void ;
14- emit : ( event : 'connection' , client : unknown , request : IncomingMessage ) => void ;
15- } ;
7+ export type MetroWebSocketEndpoints = NonNullable <
8+ RunServerOptions [ 'websocketEndpoints' ]
9+ > ;
10+ export type MetroWebSocketEndpoint = MetroWebSocketEndpoints [ string ] ;
1611
1712export type MetroOptions = {
1813 projectRoot : string ;
1914 harnessConfig : HarnessConfig ;
20- websocketEndpoints ?: Record < string , MetroWebSocketEndpoint > ;
15+ websocketEndpoints ?: MetroWebSocketEndpoints ;
2116} ;
2217
2318export type WaitForMetroHealthOptions = {
@@ -33,7 +28,7 @@ export type PrewarmMetroBundleOptions = {
3328export type MetroInstance = {
3429 events : Reporter ;
3530 httpServer : HttpServer | HttpsServer ;
36- websocketEndpoints : Record < string , MetroWebSocketEndpoint > ;
31+ websocketEndpoints : MetroWebSocketEndpoints ;
3732 waitUntilHealthy : ( options : WaitForMetroHealthOptions ) => Promise < string > ;
3833 prewarm : ( options : PrewarmMetroBundleOptions ) => Promise < boolean > ;
3934 dispose : ( ) => Promise < void > ;
0 commit comments