@boy-offi9-inc/tidepull 0.7.1 → 0.7.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/dist/main.js CHANGED
@@ -181,9 +181,7 @@ export async function main(argv) {
181
181
  return 2;
182
182
  }
183
183
  const machineMode = values.quiet || values["dump-json"] || values["get-url"] || values.simulate || values["progress-json"];
184
- if (process.stdout.isTTY && !machineMode) {
185
- process.stderr.write(renderBanner(VERSION, theme, !values["no-color"] && shouldUseColor()) + "\n");
186
- }
184
+ const showBanner = process.stdout.isTTY && !machineMode;
187
185
  const log = new Logger({
188
186
  quiet: values.quiet,
189
187
  verbose: values.verbose,
@@ -238,6 +236,10 @@ export async function main(argv) {
238
236
  log.error(errMsg(e));
239
237
  return e instanceof TidepullError ? e.exitCode : 1;
240
238
  }
239
+ if (showBanner) {
240
+ const pluginNames = plugins.map((p) => p.name);
241
+ process.stderr.write(renderBanner(VERSION, theme, !values["no-color"] && shouldUseColor(), pluginNames) + "\n");
242
+ }
241
243
  const tp = createTidepull({
242
244
  http: { headers, headerHosts: values["header-host"] ?? [], userAgent: values["user-agent"], retries: num(values.retries, 3), cookies },
243
245
  plugins: [...plugins, dash, feeds],
@@ -1,2 +1,2 @@
1
1
  import type { Theme } from "./theme.js";
2
- export declare function renderBanner(version: string, theme: Theme, color?: boolean): string;
2
+ export declare function renderBanner(version: string, theme: Theme, color?: boolean, plugins?: string[]): string;
package/dist/ui/banner.js CHANGED
@@ -7,6 +7,18 @@ const GLYPHS = {
7
7
  u: ["█ █ ", "█ █ ", "▀▀▀▀ "],
8
8
  l: ["█ ", "█ ", "▀▀▀▀ "],
9
9
  };
10
+ function gradientStops(theme) {
11
+ switch (theme.name) {
12
+ case "amber":
13
+ return ["\x1b[93m", "\x1b[93m", "\x1b[33m", "\x1b[33m", "\x1b[33;1m", "\x1b[31m", "\x1b[31;1m", "\x1b[31;1m"];
14
+ case "high-contrast":
15
+ return ["\x1b[96;1m", "\x1b[96;1m", "\x1b[96;1m", "\x1b[97;1m", "\x1b[97;1m", "\x1b[97;1m", "\x1b[97;1m", "\x1b[97;1m"];
16
+ case "tide":
17
+ return ["\x1b[96m", "\x1b[96m", "\x1b[36m", "\x1b[36m", "\x1b[36m", "\x1b[92m", "\x1b[92m", "\x1b[92m"];
18
+ default:
19
+ return [];
20
+ }
21
+ }
10
22
  function logo() {
11
23
  const rows = ["", "", ""];
12
24
  for (const ch of "tidepull") {
@@ -16,11 +28,57 @@ function logo() {
16
28
  }
17
29
  return rows.map((r) => r.trimEnd());
18
30
  }
19
- export function renderBanner(version, theme, color = true) {
31
+ const LOGO_COLS = 42;
32
+ function infoLines(version, theme, plain, plugins) {
33
+ const dim = (s) => (plain ? s : theme.dim + s + theme.reset);
34
+ const ok = (s) => (plain ? s : theme.success + s + theme.reset);
35
+ const tag = (s) => (plain ? s : theme.tag + s + theme.reset);
36
+ const rows = [dim("media downloader"), `${dim("version")} ${ok(`v${version}`)}`, `${dim("stdout")} ${ok("data only")}`];
37
+ if (plugins.length)
38
+ rows.push(`${dim("plugins")} ${tag(plugins.join(", "))}`);
39
+ return rows;
40
+ }
41
+ export function renderBanner(version, theme, color = true, plugins = []) {
20
42
  const plain = !color || !!process.env.NO_COLOR || theme.name === "mono";
21
43
  const paint = (c, s) => (plain ? s : c + s + theme.reset);
22
- const dim = (s) => (plain ? s : theme.dim + s + theme.reset);
23
44
  const rows = logo();
24
- rows[2] = paint(theme.accent, rows[2]) + " " + dim(`v${version}`);
25
- return rows.map((r, i) => (i === 2 ? r : paint(theme.accent, r))).join("\n");
45
+ if (plain) {
46
+ const info = infoLines(version, theme, true, plugins);
47
+ const fold = info.length > 3 ? `${info[3]} v${version}` : undefined;
48
+ const shown = info.slice(0, 3);
49
+ if (fold)
50
+ shown[2] = shown[2];
51
+ const lines = [];
52
+ for (let r = 0; r < 3; r++) {
53
+ const pad = Math.max(2, LOGO_COLS - rows[r].length);
54
+ lines.push(rows[r] + " ".repeat(pad) + (shown[r] ?? ""));
55
+ }
56
+ if (fold)
57
+ lines.push(" ".repeat(LOGO_COLS + 2) + `${info[3]}`);
58
+ return lines.join("\n");
59
+ }
60
+ const stops = gradientStops(theme);
61
+ const starts = [0, 5, 9, 14, 19, 24, 29, 34];
62
+ const widths = [5, 4, 5, 5, 5, 5, 5, 5];
63
+ const painted = ["", "", ""];
64
+ for (let li = 0; li < 8; li++) {
65
+ const c = stops[li] ?? theme.accent;
66
+ for (let r = 0; r < 3; r++) {
67
+ painted[r] += paint(c, rows[r].slice(starts[li], starts[li] + widths[li]));
68
+ }
69
+ }
70
+ for (let r = 0; r < 3; r++)
71
+ painted[r] = painted[r].trimEnd() + theme.reset;
72
+ const info = infoLines(version, theme, plain, plugins);
73
+ const visible = (s) => s.replace(/\x1b\[[0-9;]*m/g, "").length;
74
+ const lines = [];
75
+ for (let r = 0; r < 3; r++) {
76
+ const pad = Math.max(2, LOGO_COLS - visible(painted[r]));
77
+ lines.push(painted[r] + " ".repeat(pad) + (info[r] ?? ""));
78
+ }
79
+ if (info.length > 3)
80
+ lines.push(" ".repeat(LOGO_COLS + 2) + info[3]);
81
+ const waveStr = " ≈≈≈≈≈≈≈≈≈≈≈";
82
+ lines.push(paint(plain ? "" : theme.tag, waveStr));
83
+ return lines.join("\n");
26
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boy-offi9-inc/tidepull",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "A minimal, from-scratch media downloader library: extractor plugins, yt-dlp-style format selection, resumable downloads.",
5
5
  "type": "module",
6
6
  "license": "MIT",