30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
|
import { jsx as _jsx } from "react/jsx-runtime";
|
||
|
import { render } from 'ink';
|
||
|
import BigText from 'ink-big-text';
|
||
|
import Gradient from 'ink-gradient';
|
||
|
const Logo = ({ text, colors, font = 'block', letterSpacing, }) => {
|
||
|
// ink-gradient with custom colors
|
||
|
if (colors.length > 0) {
|
||
|
return (_jsx(Gradient, { colors: colors, children: _jsx(BigText, { text: text, font: font, letterSpacing: letterSpacing }) }));
|
||
|
}
|
||
|
// Default gradient
|
||
|
return (_jsx(Gradient, { name: "rainbow", children: _jsx(BigText, { text: text, font: font, letterSpacing: letterSpacing }) }));
|
||
|
};
|
||
|
export function renderInkLogo(text, palette, options) {
|
||
|
return new Promise((resolve) => {
|
||
|
const { unmount } = render(_jsx(Logo, { text: text, colors: palette, font: options?.font, letterSpacing: options?.letterSpacing }));
|
||
|
// Automatically unmount after rendering to allow process to exit
|
||
|
setTimeout(() => {
|
||
|
unmount();
|
||
|
// Reset terminal state to prevent corruption
|
||
|
// SGR reset (colors, styles)
|
||
|
process.stdout.write('\x1b[0m');
|
||
|
// Ensure cursor is visible
|
||
|
process.stdout.write('\x1b[?25h');
|
||
|
// Clear to end of line to remove any artifacts
|
||
|
process.stdout.write('\x1b[K');
|
||
|
resolve();
|
||
|
}, 100);
|
||
|
});
|
||
|
}
|
||
|
//# sourceMappingURL=InkRenderer.js.map
|