1 import chalk from
'chalk';
3 import type { AbstractUIServer
} from
'./AbstractUIServer';
4 import { UIHttpServer
} from
'./UIHttpServer';
5 import { UIServerUtils
} from
'./UIServerUtils';
6 import { UIWebSocketServer
} from
'./UIWebSocketServer';
7 import { ApplicationProtocol
, type UIServerConfiguration
} from
'../../types';
9 export class UIServerFactory
{
10 private constructor() {
11 // This is intentional
14 public static getUIServerImplementation(
15 uiServerConfiguration
: UIServerConfiguration
,
16 ): AbstractUIServer
| null {
17 if (UIServerUtils
.isLoopback(uiServerConfiguration
.options
!.host
!) === false) {
20 'Loopback address not detected in UI server configuration. This is not recommended.',
24 switch (uiServerConfiguration
.type) {
25 case ApplicationProtocol
.WS
:
26 return new UIWebSocketServer(uiServerConfiguration
);
27 case ApplicationProtocol
.HTTP
:
28 return new UIHttpServer(uiServerConfiguration
);