@boy-offi9-inc/tidepull 0.7.2 → 0.7.4

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[], width?: number): string;
package/dist/ui/banner.js CHANGED
@@ -28,41 +28,67 @@ function logo() {
28
28
  }
29
29
  return rows.map((r) => r.trimEnd());
30
30
  }
31
- function infoLines(version, theme, plain) {
31
+ function infoLines(version, theme, plain, plugins) {
32
32
  const dim = (s) => (plain ? s : theme.dim + s + theme.reset);
33
33
  const ok = (s) => (plain ? s : theme.success + s + theme.reset);
34
- return [
35
- dim("media downloader"),
36
- `${dim("version")} ${ok(`v${version}`)}`,
37
- `${dim("stdout")} ${ok("data only")}`,
38
- ];
34
+ const tag = (s) => (plain ? s : theme.tag + s + theme.reset);
35
+ const rows = [dim("media downloader"), `${dim("version")} ${ok(`v${version}`)}`, `${dim("stdout")} ${ok("data only")}`];
36
+ if (plugins.length)
37
+ rows.push(`${dim("plugins")} ${tag(plugins.join(", "))}`);
38
+ return rows;
39
39
  }
40
- export function renderBanner(version, theme, color = true) {
40
+ function termWidth() {
41
+ return process.stdout.columns ?? 80;
42
+ }
43
+ const visible = (s) => s.replace(/\x1b\[[0-9;]*m/g, "").length;
44
+ function chooseLayout(logoWidth, infoWidths, width) {
45
+ const maxInfo = Math.max(...infoWidths);
46
+ return logoWidth + 3 + maxInfo <= width - 1 ? "side" : "stack";
47
+ }
48
+ export function renderBanner(version, theme, color = true, plugins = [], width) {
41
49
  const plain = !color || !!process.env.NO_COLOR || theme.name === "mono";
42
50
  const paint = (c, s) => (plain ? s : c + s + theme.reset);
43
51
  const rows = logo();
52
+ const logoWidth = Math.max(...rows.map((r) => r.length));
53
+ const info = infoLines(version, theme, plain, plugins);
54
+ const infoWidths = info.map(visible);
55
+ const w = width ?? termWidth();
56
+ const layout = chooseLayout(logoWidth, infoWidths, w);
57
+ let painted;
44
58
  if (plain) {
45
- rows[2] += " v" + version;
46
- return rows.join("\n");
59
+ painted = rows;
47
60
  }
48
- const stops = gradientStops(theme);
49
- const starts = [0, 5, 9, 14, 19, 24, 29, 34];
50
- const widths = [5, 4, 5, 5, 5, 5, 5, 5];
51
- const painted = ["", "", ""];
52
- for (let li = 0; li < 8; li++) {
53
- const c = stops[li] ?? theme.accent;
54
- for (let r = 0; r < 3; r++) {
55
- painted[r] += paint(c, rows[r].slice(starts[li], starts[li] + widths[li]));
61
+ else {
62
+ const stops = gradientStops(theme);
63
+ const starts = [0, 5, 9, 14, 19, 24, 29, 34];
64
+ const widths = [5, 4, 5, 5, 5, 5, 5, 5];
65
+ painted = ["", "", ""];
66
+ for (let li = 0; li < 8; li++) {
67
+ const c = stops[li] ?? theme.accent;
68
+ for (let r = 0; r < 3; r++)
69
+ painted[r] += paint(c, rows[r].slice(starts[li], starts[li] + widths[li]));
56
70
  }
71
+ for (let r = 0; r < 3; r++)
72
+ painted[r] = painted[r].trimEnd() + theme.reset;
57
73
  }
58
- for (let r = 0; r < 3; r++)
59
- painted[r] = painted[r].trimEnd() + theme.reset;
60
- const info = infoLines(version, theme, plain);
61
- const visible = (s) => s.replace(/\x1b\[[0-9;]*m/g, "").length;
62
74
  const lines = [];
63
- for (let r = 0; r < 3; r++) {
64
- const pad = Math.max(2, 42 - visible(painted[r]));
65
- lines.push(painted[r] + " ".repeat(pad) + (info[r] ?? ""));
75
+ if (layout === "side") {
76
+ const col = logoWidth + 4;
77
+ for (let r = 0; r < 3; r++) {
78
+ const pad = Math.max(2, col - visible(painted[r]));
79
+ lines.push(painted[r] + " ".repeat(pad) + (info[r] ?? ""));
80
+ }
81
+ for (let r = 3; r < info.length; r++)
82
+ lines.push(" ".repeat(col + 1) + info[r]);
83
+ }
84
+ else {
85
+ lines.push(...painted);
86
+ for (const row of info)
87
+ lines.push(" " + row);
66
88
  }
89
+ const tag = plain ? "" : theme.tag;
90
+ const span = layout === "side" ? logoWidth + 4 + infoWidths[0] : logoWidth;
91
+ const waves = Math.max(6, Math.min(30, span - 1));
92
+ lines.push(paint(tag, " " + "≈".repeat(waves)));
67
93
  return lines.join("\n");
68
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boy-offi9-inc/tidepull",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
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",