blyuecode 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,119 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useEffect, useRef } from 'react';
3
+ import { Box, Text, useStdout } from 'ink';
4
+ import { pastelAt } from './pastel.js';
5
+ const BLYUE_BIG = [
6
+ '██████╗ ██╗ ██╗ ██╗ ██╗ ██╗ ███████╗',
7
+ '██╔══██╗██║ ╚██╗ ██╔╝ ██║ ██║ ██╔════╝',
8
+ '██████╔╝██║ ╚████╔╝ ██║ ██║ █████╗ ',
9
+ '██╔══██╗██║ ╚██╔╝ ██║ ██║ ██╔══╝ ',
10
+ '██████╔╝███████╗ ██║ ╚██████╔╝ ███████╗',
11
+ '╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚══════╝',
12
+ ];
13
+ const BLYUE_SMALL = [
14
+ ' ___ _ _ _ _ _ ___ ',
15
+ '| _ )| | | | | | | | | __|',
16
+ '| _ \\| |__| |_| | |_| | _| ',
17
+ '|___/|____|\\___/ \\___/|___|',
18
+ ];
19
+ const CODE_BIG = [
20
+ ' ██████╗ ██████╗ ██████╗ ███████╗',
21
+ ' ██╔════╝██╔═══██╗██╔══██╗██╔════╝',
22
+ ' ██║ ██║ ██║██║ ██║█████╗ ',
23
+ ' ██║ ██║ ██║██║ ██║██╔══╝ ',
24
+ ' ╚██████╗╚██████╔╝██████╔╝███████╗',
25
+ ' ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝',
26
+ ];
27
+ const CODE_SMALL = [
28
+ ' █▀▀ █▀█ █▀▄ █▀▀',
29
+ ' █▄▄ █▄█ █▄▀ ██▄',
30
+ ];
31
+ const BLYUE_WIDTH = 44;
32
+ const BLYUE_SMALL_WIDTH = 27;
33
+ const LUMEN_COL_BIG = 35;
34
+ const LUMEN_COL_SMALL = 9;
35
+ const LUMEN_LETTERS = ['L', 'U', 'M', 'E', 'N'];
36
+ const UNLIT = '#1c1c1c';
37
+ const FRAME_MS = 55;
38
+ const T_LUMEN_IN_START = 3;
39
+ const T_LUMEN_IN_END = 7;
40
+ const T_LUMEN_HOLD_END = 13;
41
+ const T_LUMEN_OUT_START = 14;
42
+ const T_LUMEN_OUT_END = 18;
43
+ const T_GAP_END = 21;
44
+ const T_BANNER_IN_START = 22;
45
+ const T_BANNER_IN_END = 33;
46
+ const T_HOLD_END = 39;
47
+ export const SplashBanner = ({ onDone, version }) => {
48
+ const { stdout } = useStdout();
49
+ const width = stdout?.columns ?? 80;
50
+ const wide = width >= 60;
51
+ const blyue = wide ? BLYUE_BIG : BLYUE_SMALL;
52
+ const code = wide ? CODE_BIG : CODE_SMALL;
53
+ const blockWidth = wide ? BLYUE_WIDTH : BLYUE_SMALL_WIDTH;
54
+ const lumenCol = wide ? LUMEN_COL_BIG : LUMEN_COL_SMALL;
55
+ const leftPad = Math.max(0, Math.floor((width - blockWidth) / 2));
56
+ const pad = ' '.repeat(leftPad);
57
+ const lumenStart = leftPad + lumenCol;
58
+ const LUMEN_TEXT_LEN = 9;
59
+ const totalLetterRows = blyue.length + code.length;
60
+ const [frame, setFrame] = useState(0);
61
+ const onDoneRef = useRef(onDone);
62
+ useEffect(() => {
63
+ onDoneRef.current = onDone;
64
+ }, [onDone]);
65
+ useEffect(() => {
66
+ const int = setInterval(() => {
67
+ setFrame((f) => {
68
+ const nf = f + 1;
69
+ if (nf > T_HOLD_END) {
70
+ clearInterval(int);
71
+ setTimeout(() => onDoneRef.current(), 80);
72
+ return T_HOLD_END;
73
+ }
74
+ return nf;
75
+ });
76
+ }, FRAME_MS);
77
+ return () => clearInterval(int);
78
+ }, []);
79
+ const lumenLetterLit = (i) => {
80
+ if (frame < T_LUMEN_IN_START)
81
+ return false;
82
+ if (frame <= T_LUMEN_IN_END)
83
+ return frame >= T_LUMEN_IN_START + i;
84
+ if (frame <= T_LUMEN_HOLD_END)
85
+ return true;
86
+ if (frame <= T_LUMEN_OUT_END)
87
+ return frame < T_LUMEN_OUT_START + i;
88
+ return false;
89
+ };
90
+ const bannerRowLit = (rowIdx) => {
91
+ if (frame < T_BANNER_IN_START)
92
+ return false;
93
+ if (frame <= T_BANNER_IN_END)
94
+ return frame >= T_BANNER_IN_START + rowIdx;
95
+ return true;
96
+ };
97
+ const versionVisible = frame > T_BANNER_IN_END;
98
+ const renderLumenLetters = () => {
99
+ const out = [];
100
+ for (let i = 0; i < 5; i++) {
101
+ const lit = lumenLetterLit(i);
102
+ const hue = 0.3 + (((frame * 0.02) + i * 0.06) % 0.45);
103
+ out.push(_jsx(Text, { color: lit ? pastelAt(hue) : 'gray', bold: lit, dimColor: !lit, children: lit ? LUMEN_LETTERS[i] : ' ' }, 'L' + i));
104
+ if (i < 4)
105
+ out.push(_jsx(Text, { children: " " }, 'sp' + i));
106
+ }
107
+ return out;
108
+ };
109
+ const renderBannerRow = (line, rowIdx) => {
110
+ const lit = bannerRowLit(rowIdx);
111
+ const hue = (rowIdx * 0.045) % 1;
112
+ return (_jsx(Text, { color: lit ? pastelAt(hue) : UNLIT, bold: lit, children: pad + line }, 'r' + rowIdx));
113
+ };
114
+ const versionText = 'v' + version;
115
+ const lumenEnd = lumenStart + LUMEN_TEXT_LEN;
116
+ const versionStart = Math.max(lumenEnd + 2, width - versionText.length - 1);
117
+ const gap = Math.max(1, versionStart - lumenEnd);
118
+ return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Box, { flexDirection: "row", children: [_jsx(Text, { children: ' '.repeat(lumenStart) }), renderLumenLetters(), _jsx(Text, { children: ' '.repeat(gap) }), versionVisible ? (_jsx(Text, { color: "gray", children: versionText })) : (_jsx(Text, { children: " " }))] }), _jsx(Text, { children: " " }), blyue.map((line, i) => renderBannerRow(line, i)), code.map((line, i) => renderBannerRow(line, blyue.length + i))] }));
119
+ };
@@ -0,0 +1,121 @@
1
+ import { pastelAt } from './pastel.js';
2
+ const BLYUE_BIG = [
3
+ '██████╗ ██╗ ██╗ ██╗ ██╗ ██╗ ███████╗',
4
+ '██╔══██╗██║ ╚██╗ ██╔╝ ██║ ██║ ██╔════╝',
5
+ '██████╔╝██║ ╚████╔╝ ██║ ██║ █████╗ ',
6
+ '██╔══██╗██║ ╚██╔╝ ██║ ██║ ██╔══╝ ',
7
+ '██████╔╝███████╗ ██║ ╚██████╔╝ ███████╗',
8
+ '╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚══════╝',
9
+ ];
10
+ const BLYUE_SMALL = [
11
+ ' ___ _ _ _ _ _ ___ ',
12
+ '| _ )| | | | | | | | | __|',
13
+ '| _ \\| |__| |_| | |_| | _| ',
14
+ '|___/|____|\\___/ \\___/|___|',
15
+ ];
16
+ const CODE_BIG = [
17
+ ' ██████╗ ██████╗ ██████╗ ███████╗',
18
+ ' ██╔════╝██╔═══██╗██╔══██╗██╔════╝',
19
+ ' ██║ ██║ ██║██║ ██║█████╗ ',
20
+ ' ██║ ██║ ██║██║ ██║██╔══╝ ',
21
+ ' ╚██████╗╚██████╔╝██████╔╝███████╗',
22
+ ' ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝',
23
+ ];
24
+ const CODE_SMALL = [
25
+ ' █▀▀ █▀█ █▀▄ █▀▀',
26
+ ' █▄▄ █▄█ █▄▀ ██▄',
27
+ ];
28
+ const LETTERS = ['L', 'U', 'M', 'E', 'N'];
29
+ const RESET = '\x1b[0m';
30
+ const BOLD = '\x1b[1m';
31
+ const DIM = '\x1b[2m';
32
+ const HOME_CLEAR = '\x1b[2J\x1b[H';
33
+ const HIDE_CURSOR = '\x1b[?25l';
34
+ const SHOW_CURSOR = '\x1b[?25h';
35
+ function hexToAnsi(hex) {
36
+ const r = parseInt(hex.slice(1, 3), 16);
37
+ const g = parseInt(hex.slice(3, 5), 16);
38
+ const b = parseInt(hex.slice(5, 7), 16);
39
+ return `\x1b[38;2;${r};${g};${b}m`;
40
+ }
41
+ const FRAME_MS = 55;
42
+ const T_LUMEN_IN_START = 3;
43
+ const T_LUMEN_IN_END = 7;
44
+ const T_BANNER_IN_START = 12;
45
+ const T_BANNER_IN_END = 23;
46
+ const T_HOLD_END = 31;
47
+ function lumenLetterLit(frame, i) {
48
+ if (frame < T_LUMEN_IN_START)
49
+ return false;
50
+ if (frame <= T_LUMEN_IN_END)
51
+ return frame >= T_LUMEN_IN_START + i;
52
+ return true;
53
+ }
54
+ function bannerRowLit(frame, i) {
55
+ if (frame < T_BANNER_IN_START)
56
+ return false;
57
+ if (frame <= T_BANNER_IN_END)
58
+ return frame >= T_BANNER_IN_START + i;
59
+ return true;
60
+ }
61
+ function stripAnsi(s) {
62
+ return s.replace(/\x1b\[[0-9;]*m/g, '');
63
+ }
64
+ function buildFrame(frame, cols, version) {
65
+ const wide = cols >= 60;
66
+ const blyue = wide ? BLYUE_BIG : BLYUE_SMALL;
67
+ const code = wide ? CODE_BIG : CODE_SMALL;
68
+ const blockWidth = wide ? 44 : 27;
69
+ const lumenCol = wide ? 35 : 9;
70
+ const leftPad = Math.max(0, Math.floor((cols - blockWidth) / 2));
71
+ const pad = ' '.repeat(leftPad);
72
+ const out = [];
73
+ const lumenStart = leftPad + lumenCol;
74
+ let lumenRow = ' '.repeat(lumenStart);
75
+ for (let i = 0; i < LETTERS.length; i++) {
76
+ const lit = lumenLetterLit(frame, i);
77
+ if (lit) {
78
+ const hue = 0.3 + ((frame * 0.02 + i * 0.06) % 0.45);
79
+ lumenRow += BOLD + hexToAnsi(pastelAt(hue)) + LETTERS[i] + RESET;
80
+ }
81
+ else {
82
+ lumenRow += ' ';
83
+ }
84
+ if (i < LETTERS.length - 1)
85
+ lumenRow += ' ';
86
+ }
87
+ const versionText = 'v' + version;
88
+ const versionStart = Math.max(lumenStart + 9 + 2, cols - versionText.length - 1);
89
+ const visibleLen = stripAnsi(lumenRow).length;
90
+ lumenRow += ' '.repeat(Math.max(1, versionStart - visibleLen));
91
+ if (frame > T_BANNER_IN_END)
92
+ lumenRow += DIM + versionText + RESET;
93
+ out.push(lumenRow);
94
+ out.push('');
95
+ const rows = [...blyue, ...code];
96
+ for (let i = 0; i < rows.length; i++) {
97
+ const lit = bannerRowLit(frame, i);
98
+ const hue = (i * 0.045) % 1;
99
+ const color = lit ? BOLD + hexToAnsi(pastelAt(hue)) : hexToAnsi('#1c1c1c');
100
+ out.push(color + pad + rows[i] + RESET);
101
+ }
102
+ return out.join('\n');
103
+ }
104
+ function sleep(ms) {
105
+ return new Promise((r) => setTimeout(r, ms));
106
+ }
107
+ export async function playSplash(version) {
108
+ const cols = process.stdout.columns || 80;
109
+ process.stdout.write(HIDE_CURSOR);
110
+ try {
111
+ for (let frame = 0; frame <= T_HOLD_END; frame++) {
112
+ process.stdout.write(HOME_CLEAR + buildFrame(frame, cols, version));
113
+ await sleep(FRAME_MS);
114
+ }
115
+ await sleep(150);
116
+ process.stdout.write(HOME_CLEAR);
117
+ }
118
+ finally {
119
+ process.stdout.write(SHOW_CURSOR);
120
+ }
121
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blyuecode",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "BLYUE Code — a coding agent by Lumen",
5
5
  "type": "module",
6
6
  "license": "MIT",