@boy-offi9-inc/tidepull 0.7.6 → 0.7.8
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/README.md +1 -1
- package/dist/core/http.js +1 -1
- package/dist/main.js +3 -1
- package/dist/ui/banner.d.ts +3 -0
- package/dist/ui/banner.js +27 -81
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -164,7 +164,7 @@ TIDEPULL_THEME=high-contrast tidepull URL # --theme still wins if you also
|
|
|
164
164
|
|
|
165
165
|
A theme only decides *which* codes are emitted: `--no-color`, `NO_COLOR` and a non-TTY stderr still strip every escape sequence, so redirected output and CI logs stay plain text.
|
|
166
166
|
|
|
167
|
-
On an interactive terminal the CLI shows a launch banner and a spinner while resolving a URL; quiet, JSON, `-g`, simulate and non-TTY modes
|
|
167
|
+
On an interactive terminal the CLI shows a launch banner while a download is queued and a spinner while resolving a URL; a bare call, `--help`, `--version`, quiet, JSON, `-g`, simulate and non-TTY modes show neither, so piped and one-off output stays data-only. The banner is a dash-border box (`⬢ tidepull vX.Y.Z` in the top border) with labeled stat rows — version, stdout policy, detected plugins.
|
|
168
168
|
|
|
169
169
|
From a clone, `node src/cli.ts <args>` runs the TypeScript source directly (Node >= 22.18); `npm run build` emits JS + `.d.ts`.
|
|
170
170
|
|
package/dist/core/http.js
CHANGED
|
@@ -75,7 +75,7 @@ export class Http {
|
|
|
75
75
|
const start = new URL(url);
|
|
76
76
|
let cur = start;
|
|
77
77
|
for (let hop = 0;; hop++) {
|
|
78
|
-
const own = Object.fromEntries(Object.entries(init.headers ?? {}).filter(([k]) => cur.origin === start.origin || k.toLowerCase()
|
|
78
|
+
const own = Object.fromEntries(Object.entries(init.headers ?? {}).filter(([k]) => cur.origin === start.origin || ["range", "user-agent"].includes(k.toLowerCase())));
|
|
79
79
|
const headers = { ...this.headersFor(cur, start), ...own };
|
|
80
80
|
const cookie = this.cookies?.(cur);
|
|
81
81
|
if (cookie) {
|
package/dist/main.js
CHANGED
|
@@ -181,7 +181,8 @@ 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
|
-
const
|
|
184
|
+
const interactiveStdout = process.stdout.isTTY && !machineMode && !values["list-extractors"];
|
|
185
|
+
let showBanner = false;
|
|
185
186
|
const log = new Logger({
|
|
186
187
|
quiet: values.quiet,
|
|
187
188
|
verbose: values.verbose,
|
|
@@ -236,6 +237,7 @@ export async function main(argv) {
|
|
|
236
237
|
log.error(errMsg(e));
|
|
237
238
|
return e instanceof TidepullError ? e.exitCode : 1;
|
|
238
239
|
}
|
|
240
|
+
showBanner = interactiveStdout && urls.length > 0;
|
|
239
241
|
if (showBanner) {
|
|
240
242
|
const pluginNames = plugins.map((p) => p.name);
|
|
241
243
|
process.stderr.write(renderBanner(VERSION, theme, !values["no-color"] && shouldUseColor(), pluginNames) + "\n");
|
package/dist/ui/banner.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { Theme } from "./theme.js";
|
|
2
|
+
declare function termWidth(): number;
|
|
2
3
|
export declare function renderBanner(version: string, theme: Theme, color?: boolean, plugins?: string[], width?: number): string;
|
|
4
|
+
export declare const _visibleWidth: (s: string) => number;
|
|
5
|
+
export { termWidth };
|
package/dist/ui/banner.js
CHANGED
|
@@ -1,94 +1,40 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
e: ["█▀▀▀ ", "█▀▀ ", "▀▀▀▀ "],
|
|
6
|
-
p: ["█▀▀▄ ", "█▀▀ ", "▀ ▀ "],
|
|
7
|
-
u: ["█ █ ", "█ █ ", "▀▀▀▀ "],
|
|
8
|
-
l: ["█ ", "█ ", "▀▀▀▀ "],
|
|
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
|
-
}
|
|
22
|
-
function logo() {
|
|
23
|
-
const rows = ["", "", ""];
|
|
24
|
-
for (const ch of "tidepull") {
|
|
25
|
-
const g = GLYPHS[ch];
|
|
26
|
-
for (let r = 0; r < 3; r++)
|
|
27
|
-
rows[r] += g[r];
|
|
28
|
-
}
|
|
29
|
-
return rows.map((r) => r.trimEnd());
|
|
1
|
+
const GLYPH = "\u2b22";
|
|
2
|
+
const visible = (s) => s.replace(/\x1b\[[0-9;]*m/g, "").length;
|
|
3
|
+
function termWidth() {
|
|
4
|
+
return process.stdout.columns ?? 80;
|
|
30
5
|
}
|
|
31
|
-
function
|
|
6
|
+
function infoRows(version, theme, plain, plugins) {
|
|
32
7
|
const dim = (s) => (plain ? s : theme.dim + s + theme.reset);
|
|
33
8
|
const ok = (s) => (plain ? s : theme.success + s + theme.reset);
|
|
34
9
|
const tag = (s) => (plain ? s : theme.tag + s + theme.reset);
|
|
35
|
-
const rows = [
|
|
36
|
-
|
|
37
|
-
|
|
10
|
+
const rows = [
|
|
11
|
+
["media downloader", ok(`v${version}`)],
|
|
12
|
+
["stdout", ok("data only")],
|
|
13
|
+
];
|
|
14
|
+
rows.push(["plugins", plugins.length ? tag(plugins.join(", ")) : dim("none")]);
|
|
38
15
|
return rows;
|
|
39
16
|
}
|
|
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
17
|
export function renderBanner(version, theme, color = true, plugins = [], width) {
|
|
49
18
|
const plain = !color || !!process.env.NO_COLOR || theme.name === "mono";
|
|
50
19
|
const paint = (c, s) => (plain ? s : c + s + theme.reset);
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
let painted;
|
|
58
|
-
if (plain) {
|
|
59
|
-
painted = rows;
|
|
60
|
-
}
|
|
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]));
|
|
70
|
-
}
|
|
71
|
-
for (let r = 0; r < 3; r++)
|
|
72
|
-
painted[r] = painted[r].trimEnd() + theme.reset;
|
|
73
|
-
}
|
|
20
|
+
const accent = (s) => paint(theme.accent, s);
|
|
21
|
+
const dim = (s) => paint(theme.dim, s);
|
|
22
|
+
const w = Math.max(24, Math.min(width ?? termWidth(), 60));
|
|
23
|
+
const rows = infoRows(version, theme, plain, plugins);
|
|
24
|
+
const LABEL = Math.max(...rows.map(([k]) => k.length)) + 2;
|
|
25
|
+
const inner = w - 2;
|
|
74
26
|
const lines = [];
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
lines.push(...painted);
|
|
86
|
-
for (const row of info)
|
|
87
|
-
lines.push(" " + row);
|
|
27
|
+
const title = `${GLYPH} tidepull` + (plain ? ` v${version}` : ` ${paint(theme.dim, `v${version}`)}`);
|
|
28
|
+
const shownTitle = visible(title) > inner - 4 ? `${GLYPH} tidepull` : title;
|
|
29
|
+
const dash = "\u2500";
|
|
30
|
+
const fill = Math.max(1, inner - visible(shownTitle) - 4);
|
|
31
|
+
lines.push(accent("\u250c\u2500" + " ") + shownTitle + " " + accent(" " + dash.repeat(fill) + "\u2510"));
|
|
32
|
+
for (const [key, value] of rows) {
|
|
33
|
+
const pad = Math.max(0, inner - 2 - LABEL - visible(value));
|
|
34
|
+
lines.push(accent("\u2502") + " " + dim(key.padEnd(LABEL)) + value + " ".repeat(pad) + " " + accent("\u2502"));
|
|
88
35
|
}
|
|
89
|
-
|
|
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)));
|
|
36
|
+
lines.push(accent("\u2514" + dash.repeat(inner) + "\u2518"));
|
|
93
37
|
return lines.join("\n");
|
|
94
38
|
}
|
|
39
|
+
export const _visibleWidth = visible;
|
|
40
|
+
export { termWidth };
|
package/package.json
CHANGED