905ce66d5325fc7bca9424d6f313de5cec089588
1 import chalk from
'chalk';
3 import { ApplicationProtocol
, type UIServerConfiguration
} from
'../../types';
4 import { Configuration
} from
'../../utils';
5 import { type AbstractUIServer
, UIHttpServer
, UIServerUtils
, UIWebSocketServer
} from
'../internal';
7 export class UIServerFactory
{
8 private constructor() {
12 public static getUIServerImplementation(
13 uiServerConfiguration
?: UIServerConfiguration
14 ): AbstractUIServer
| null {
15 if (UIServerUtils
.isLoopback(uiServerConfiguration
.options
?.host
) === false) {
18 'Loopback address not detected in UI server configuration. This is not recommended.'
22 switch (uiServerConfiguration
?.type ?? Configuration
.getUIServer().type) {
23 case ApplicationProtocol
.WS
:
24 return new UIWebSocketServer(uiServerConfiguration
?? Configuration
.getUIServer());
25 case ApplicationProtocol
.HTTP
:
26 return new UIHttpServer(uiServerConfiguration
?? Configuration
.getUIServer());