@roots/bud-dashboard
Version:
bud.js core module
30 lines (29 loc) • 2.47 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "@roots/bud-support/jsx-runtime";
import figures from '@roots/bud-support/figures';
import { Box, Text } from '@roots/bud-support/ink';
import { externalNetworkInterface } from '@roots/bud-support/os';
/**
* Server info ink component
*/
export const Server = ({ devUrl, displayServerInfo, mode, proxy = false, proxyUrl, publicDevUrl, publicProxyUrl, }) => {
if (!displayServerInfo ||
mode !== `development` ||
!devUrl ||
!(devUrl instanceof URL))
return null;
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: ` ` }), _jsxs(Text, { color: "blue", children: [` `, "Network"] }), _jsx(Text, { children: ` ` }), _jsx(Proxy, { proxy: proxy, proxyUrl: proxyUrl, publicProxyUrl: publicProxyUrl }), _jsx(Dev, { devUrl: devUrl, publicDevUrl: publicDevUrl })] }));
};
const Proxy = ({ proxy, proxyUrl, publicProxyUrl, }) => {
if (!proxy || !proxyUrl || !(proxyUrl instanceof URL))
return null;
return (_jsxs(Box, { flexDirection: "row", gap: 2, paddingLeft: 1, children: [_jsx(Box, { minWidth: 7, children: _jsxs(Text, { color: "white", children: [figures.pointerSmall, " Proxy"] }) }), _jsxs(Box, { flexDirection: "column", gap: 1, children: [_jsxs(Text, { dimColor: true, wrap: "truncate-end", children: [figures.lineDashed0, " ", proxyUrl.href] }), publicProxyUrl?.href &&
publicProxyUrl?.href !== proxyUrl.href && (_jsxs(Text, { dimColor: true, wrap: "truncate-end", children: [figures.lineDashed0, " ", publicProxyUrl.href] }))] })] }));
};
const Dev = ({ devUrl, publicDevUrl, }) => {
if (!devUrl?.href)
return null;
const ipv4 = externalNetworkInterface.ipv4Url(devUrl.protocol);
ipv4.port = devUrl.port;
return (_jsxs(Box, { flexDirection: "row", gap: 2, paddingLeft: 1, children: [_jsx(Box, { minWidth: 7, children: _jsxs(Text, { color: "white", children: [figures.pointerSmall, " Dev"] }) }), _jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { dimColor: true, wrap: "truncate-end", children: [figures.lineDashed0, " ", devUrl.href] }), ipv4.href !== devUrl.href && (_jsxs(Text, { dimColor: true, wrap: "truncate-end", children: [figures.lineDashed0, " ", ipv4.href] })), publicDevUrl && publicDevUrl?.href !== devUrl.href && (_jsxs(Text, { dimColor: true, wrap: "truncate-end", children: [figures.lineDashed0, " ", publicDevUrl.href] }))] })] }));
};
export { Server as default };