inclusion-md 0.2.2 → 0.2.3
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/lib/ascii.js +52 -24
- package/package.json +1 -1
package/lib/ascii.js
CHANGED
|
@@ -3,31 +3,47 @@
|
|
|
3
3
|
const c = require("./colors");
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Animated INCLUSION.md wordmark. The letters wipe in from left to right,
|
|
7
|
+
* then settle from dim to bold.
|
|
8
8
|
*
|
|
9
9
|
* Accessibility:
|
|
10
10
|
* - Skipped automatically when stdout is not a TTY (CI, piped output).
|
|
11
|
-
* - Skipped when --no-color is passed (
|
|
11
|
+
* - Skipped when --no-color is passed (intensity is the cue).
|
|
12
12
|
* - Skipped when --yes is passed (non-interactive runs).
|
|
13
|
-
* -
|
|
14
|
-
* -
|
|
13
|
+
* - No flashing, no inverted colors, no decorative color. Motion is a
|
|
14
|
+
* single left-to-right reveal under 1 second total.
|
|
15
|
+
* - Uses Unicode block characters; terminals without block-drawing glyph
|
|
16
|
+
* support will see boxes instead of letters but the CLI still works.
|
|
15
17
|
*/
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
// "INCLUSION.md" wordmark, 3 rows tall, 73 columns wide.
|
|
20
|
+
const ART = [
|
|
21
|
+
"██ ███ ██ ▄█████ ██ ██ ██ ▄█████ ██ ▄████▄ ███ ██ ▄▄ ▄▄ ▄▄▄▄ ",
|
|
22
|
+
"██ ██ ▀▄██ ██ ██ ██ ██ ▀▀▀▄▄▄ ██ ██ ██ ██ ▀▄██ ██▀▄▀██ ██▀██",
|
|
23
|
+
"██ ██ ██ ▀█████ ██████ ▀████▀ █████▀ ██ ▀████▀ ██ ██ ▄ ██ ██ ████▀",
|
|
21
24
|
];
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
const ART_WIDTH = ART[0].length;
|
|
27
|
+
const ART_LINES = ART.length + 2; // includes 1 blank line top + bottom
|
|
28
|
+
|
|
29
|
+
function stylize(s, intensity) {
|
|
24
30
|
// intensity: 0 = dim, 1 = normal, 2 = bold
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
if (intensity === 0) return c.dim(s);
|
|
32
|
+
if (intensity === 2) return c.bold(s);
|
|
33
|
+
return s;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function renderRevealed(width, intensity) {
|
|
37
|
+
const lines = ART.map((line) => {
|
|
38
|
+
const visible = line.slice(0, width);
|
|
39
|
+
const padded = visible.padEnd(ART_WIDTH, " ");
|
|
40
|
+
return stylize(padded, intensity);
|
|
41
|
+
});
|
|
42
|
+
return ["", ...lines, ""].join("\n");
|
|
27
43
|
}
|
|
28
44
|
|
|
29
|
-
function
|
|
30
|
-
for (let i = 0; i <
|
|
45
|
+
function clearLines(n) {
|
|
46
|
+
for (let i = 0; i < n; i++) {
|
|
31
47
|
process.stdout.write("\x1b[1A\x1b[2K");
|
|
32
48
|
}
|
|
33
49
|
}
|
|
@@ -36,16 +52,27 @@ function sleep(ms) {
|
|
|
36
52
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
37
53
|
}
|
|
38
54
|
|
|
39
|
-
async function play({ enabled = true, frameMs =
|
|
40
|
-
if (!enabled)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (i < FRAMES.length - 1) {
|
|
45
|
-
await sleep(frameMs);
|
|
46
|
-
clearFrame(FRAMES[i].length + 1);
|
|
47
|
-
}
|
|
55
|
+
async function play({ enabled = true, frameMs = 70 } = {}) {
|
|
56
|
+
if (!enabled) {
|
|
57
|
+
// Static render so non-animated runs aren't blank.
|
|
58
|
+
process.stdout.write(renderRevealed(ART_WIDTH, 2) + "\n");
|
|
59
|
+
return;
|
|
48
60
|
}
|
|
61
|
+
|
|
62
|
+
// Phase 1: column-wipe reveal in 6 steps, dim.
|
|
63
|
+
const steps = 6;
|
|
64
|
+
for (let i = 1; i <= steps; i++) {
|
|
65
|
+
const w = Math.ceil((ART_WIDTH * i) / steps);
|
|
66
|
+
process.stdout.write(renderRevealed(w, 0) + "\n");
|
|
67
|
+
await sleep(frameMs);
|
|
68
|
+
clearLines(ART_LINES + 1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Phase 2: settle — full art, normal then bold.
|
|
72
|
+
process.stdout.write(renderRevealed(ART_WIDTH, 1) + "\n");
|
|
73
|
+
await sleep(120);
|
|
74
|
+
clearLines(ART_LINES + 1);
|
|
75
|
+
process.stdout.write(renderRevealed(ART_WIDTH, 2) + "\n");
|
|
49
76
|
}
|
|
50
77
|
|
|
51
78
|
function shouldAnimate({ noColor, yes }) {
|
|
@@ -56,4 +83,5 @@ function shouldAnimate({ noColor, yes }) {
|
|
|
56
83
|
return true;
|
|
57
84
|
}
|
|
58
85
|
|
|
59
|
-
|
|
86
|
+
// Back-compat: previous versions exported FRAMES.
|
|
87
|
+
module.exports = { play, shouldAnimate, ART, FRAMES: [ART, ART, ART] };
|
package/package.json
CHANGED