unicode-animations 1.0.0 → 1.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unicode-animations",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Unicode spinner animations as raw frame data",
5
5
  "type": "module",
6
6
  "exports": {
@@ -61,5 +61,8 @@
61
61
  "tsup": "^8.4.0",
62
62
  "typescript": "^5.7.0",
63
63
  "vitest": "^3.0.0"
64
+ },
65
+ "dependencies": {
66
+ "unicode-animations": "^1.0.1"
64
67
  }
65
68
  }
@@ -36,6 +36,7 @@ try {
36
36
  const R = '\x1B[0m';
37
37
  const HIDE = '\x1B[?25l';
38
38
  const SHOW = '\x1B[?25h';
39
+ const CL = '\x1B[2K';
39
40
 
40
41
  out.write(HIDE);
41
42
  const cleanup = () => { try { out.write(SHOW); } catch {} };
@@ -50,6 +51,7 @@ try {
50
51
  }
51
52
 
52
53
  function pad(str, n) { return str + ' '.repeat(Math.max(0, n - str.length)); }
54
+ function padBraille(str, n) { return str + '\u2800'.repeat(Math.max(0, n - str.length)); }
53
55
 
54
56
  // ─── Title (box-drawing art) ───
55
57
  const titleLines = [
@@ -111,24 +113,24 @@ try {
111
113
  const name = row[c];
112
114
  const sp = S[name];
113
115
  const frame = sp.frames[tick % sp.frames.length];
114
- line += B + pad(frame, colFPad[c]) + R + ' ' + D + pad(name, NPAD) + R;
116
+ line += B + padBraille(frame, colFPad[c]) + R + ' ' + D + pad(name, NPAD) + R;
115
117
  if (c < 2) line += ' ';
116
118
  }
117
- buf += line + '\n';
119
+ buf += CL + line + '\n';
118
120
  }
119
121
  return buf;
120
122
  }
121
123
 
122
124
  // ─── Print static top ───
123
125
  let top = '\n';
124
- top += topCrop + '\n';
125
- top += '\n';
126
+ top += CL + topCrop + '\n';
127
+ top += CL + '\n';
126
128
  for (let i = 0; i < titleLines.length; i++) {
127
129
  const style = i === titleLines.length - 1 ? D : B;
128
- top += contentPad + style + titleLines[i] + R + '\n';
130
+ top += CL + contentPad + style + titleLines[i] + R + '\n';
129
131
  }
130
- top += contentPad + D + 'BRAILLE ANIMATIONS' + R + '\n';
131
- top += '\n';
132
+ top += CL + contentPad + D + 'BRAILLE ANIMATIONS' + R + '\n';
133
+ top += CL + '\n';
132
134
  out.write(top);
133
135
 
134
136
  // ─── Print first frame of spinners ───
@@ -142,7 +144,7 @@ try {
142
144
  if (Date.now() - start >= DURATION) {
143
145
  clearInterval(timer);
144
146
  // Print static bottom
145
- let bot = '\n';
147
+ let bot = CL + '\n';
146
148
  const cmds = [
147
149
  ['npx unicode-animations', 'demo all spinners'],
148
150
  ['npx unicode-animations --list', 'list all spinners'],
@@ -150,10 +152,10 @@ try {
150
152
  ];
151
153
  for (const [left, right] of cmds) {
152
154
  const gap = ' '.repeat(Math.max(2, contentW - left.length - right.length));
153
- bot += contentPad + D + left + R + gap + D + right + R + '\n';
155
+ bot += CL + contentPad + D + left + R + gap + D + right + R + '\n';
154
156
  }
155
- bot += '\n';
156
- bot += botCrop + '\n\n';
157
+ bot += CL + '\n';
158
+ bot += CL + botCrop + '\n\n';
157
159
  out.write(bot);
158
160
  cleanup();
159
161
  return;