@ericrisco/rsc 0.1.12 → 0.1.13
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.
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/scripts/lib/ui.js +32 -8
package/manifest.json
CHANGED
package/package.json
CHANGED
package/scripts/lib/ui.js
CHANGED
|
@@ -57,13 +57,33 @@ function hsl(h, s = 1, l = 0.6) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// One frame: rainbow per character, diagonal phase, revealed up to `cols`.
|
|
60
|
-
|
|
60
|
+
const SPARK = ['✦', '✧', '⋆', '✺', '·', '*'];
|
|
61
|
+
const SPARK_C = ['\x1b[1;97m', '\x1b[1;93m', '\x1b[1;96m']; // bright white / yellow / cyan
|
|
62
|
+
|
|
63
|
+
// `n` random twinkles as a Map "r,c" -> pre-coloured glyph string.
|
|
64
|
+
function sparkles(n, rows, W) {
|
|
65
|
+
const m = new Map();
|
|
66
|
+
for (let i = 0; i < n; i++) {
|
|
67
|
+
const r = Math.floor(Math.random() * rows);
|
|
68
|
+
const c = Math.floor(Math.random() * W);
|
|
69
|
+
const g = SPARK[Math.floor(Math.random() * SPARK.length)];
|
|
70
|
+
m.set(`${r},${c}`, SPARK_C[Math.floor(Math.random() * SPARK_C.length)] + g);
|
|
71
|
+
}
|
|
72
|
+
return m;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// One frame: rainbow per character (or white), revealed up to `cols`, with
|
|
76
|
+
// sparkles overlaid on top wherever the map has a position.
|
|
77
|
+
function frame(phase, cols, sparks, white) {
|
|
61
78
|
return ART.map((line, r) => {
|
|
62
79
|
const chars = [...line];
|
|
63
80
|
let out = '';
|
|
64
81
|
for (let c = 0; c < chars.length && c < cols; c++) {
|
|
82
|
+
const sp = sparks && sparks.get(`${r},${c}`);
|
|
83
|
+
if (sp) { out += sp; continue; }
|
|
65
84
|
const ch = chars[c];
|
|
66
85
|
if (ch === ' ') { out += ' '; continue; }
|
|
86
|
+
if (white) { out += `\x1b[1;97m${ch}`; continue; }
|
|
67
87
|
const [rr, gg, bb] = hsl((c * 5 + r * 14 + phase * 20) % 360);
|
|
68
88
|
out += `\x1b[1;38;2;${rr};${gg};${bb}m${ch}`;
|
|
69
89
|
}
|
|
@@ -83,27 +103,31 @@ export async function banner() {
|
|
|
83
103
|
const W = Math.max(...ART.map((l) => [...l].length));
|
|
84
104
|
stdout.write('\x1b[?25l'); // hide cursor
|
|
85
105
|
say('');
|
|
86
|
-
// 1) letters slide in left → right
|
|
106
|
+
// 1) letters slide in left → right, a sparkle riding the drawing edge
|
|
87
107
|
let first = true;
|
|
88
108
|
for (let cols = 2; cols <= W; cols += 2) {
|
|
89
109
|
if (!first) stdout.write(`\x1b[${rows}A`);
|
|
90
110
|
first = false;
|
|
91
|
-
|
|
111
|
+
const edge = new Map();
|
|
112
|
+
const er = Math.floor(Math.random() * rows);
|
|
113
|
+
edge.set(`${er},${Math.min(cols - 1, W - 1)}`, '\x1b[1;97m✦');
|
|
114
|
+
if (Math.random() < 0.5) edge.set(`${Math.floor(Math.random() * rows)},${Math.min(cols, W - 1)}`, '\x1b[1;93m·');
|
|
115
|
+
stdout.write(frame(0, cols, edge));
|
|
92
116
|
await sleep(12);
|
|
93
117
|
}
|
|
94
|
-
// 2) flowing rainbow diagonal sweeps
|
|
118
|
+
// 2) flowing rainbow diagonal sweeps with twinkling sparkles
|
|
95
119
|
for (let phase = 1; phase <= 30; phase++) {
|
|
96
120
|
stdout.write(`\x1b[${rows}A`);
|
|
97
|
-
stdout.write(frame(phase, W));
|
|
121
|
+
stdout.write(frame(phase, W, sparkles(4, rows, W)));
|
|
98
122
|
await sleep(26);
|
|
99
123
|
}
|
|
100
|
-
// 3) double white flash — the pop
|
|
124
|
+
// 3) double white flash with a sparkle burst — the pop
|
|
101
125
|
for (let f = 0; f < 2; f++) {
|
|
102
126
|
stdout.write(`\x1b[${rows}A`);
|
|
103
|
-
stdout.write(
|
|
127
|
+
stdout.write(frame(0, W, sparkles(12, rows, W), true));
|
|
104
128
|
await sleep(60);
|
|
105
129
|
stdout.write(`\x1b[${rows}A`);
|
|
106
|
-
stdout.write(frame(15, W));
|
|
130
|
+
stdout.write(frame(15, W, sparkles(3, rows, W)));
|
|
107
131
|
await sleep(60);
|
|
108
132
|
}
|
|
109
133
|
// settle on a final rainbow snapshot
|