@boy-offi9-inc/tidepull 0.7.4 → 0.7.6

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/loader.js CHANGED
@@ -7,6 +7,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
7
7
  return path;
8
8
  };
9
9
  import { readdir, stat } from "node:fs/promises";
10
+ import { existsSync, writeFileSync } from "node:fs";
10
11
  import os from "node:os";
11
12
  import path from "node:path";
12
13
  import { pathToFileURL } from "node:url";
@@ -40,6 +41,18 @@ export async function loadPlugin(file) {
40
41
  }
41
42
  const FILE_RE = /\.(?:m?js|cjs|mts|ts)$/;
42
43
  const INDEX_RE = /^index\.(?:m?js|mts|ts)$/;
44
+ function ensureModuleType(dir) {
45
+ if (process.env.TIDEPULL_NO_MODULE_FIX)
46
+ return;
47
+ const pkg = path.join(dir, "package.json");
48
+ if (existsSync(pkg))
49
+ return;
50
+ try {
51
+ writeFileSync(pkg, JSON.stringify({ type: "module" }) + "\n");
52
+ }
53
+ catch {
54
+ }
55
+ }
43
56
  export async function loadPlugins(paths) {
44
57
  const out = [];
45
58
  for (const p of paths) {
@@ -50,8 +63,9 @@ export async function loadPlugins(paths) {
50
63
  out.push(await loadPlugin(p));
51
64
  continue;
52
65
  }
66
+ ensureModuleType(p);
53
67
  for (const name of (await readdir(p)).sort()) {
54
- if (name.startsWith("_") || name.startsWith(".") || name.endsWith(".d.ts"))
68
+ if (name.startsWith("_") || name.startsWith(".") || name.endsWith(".d.ts") || name === "package.json")
55
69
  continue;
56
70
  const full = path.join(p, name);
57
71
  const fs = await stat(full);
package/dist/main.js CHANGED
@@ -11,7 +11,7 @@ import { createTidepull } from "./tidepull.js";
11
11
  import dash from "./dash/index.js";
12
12
  import { defaultPluginDir, loadPlugins } from "./loader.js";
13
13
  import { table, fmtBytes } from "./ui/format.js";
14
- import { Logger, shouldUseColor } from "./ui/log.js";
14
+ import { Logger, shouldUseColor, sanitizeLog } from "./ui/log.js";
15
15
  import { humanRenderer, jsonRenderer } from "./ui/render.js";
16
16
  import { renderBanner } from "./ui/banner.js";
17
17
  import { pickTheme, THEME_NAMES } from "./ui/theme.js";
@@ -158,14 +158,14 @@ export async function main(argv) {
158
158
  args = [...configArgs(argv), ...argv];
159
159
  }
160
160
  catch (e) {
161
- process.stderr.write(`ERROR: ${errMsg(e)}\n`);
161
+ process.stderr.write(`ERROR: ${sanitizeLog(errMsg(e))}\n`);
162
162
  return e instanceof TidepullError ? e.exitCode : 2;
163
163
  }
164
164
  try {
165
165
  ({ values, positionals } = parse());
166
166
  }
167
167
  catch (e) {
168
- process.stderr.write(`ERROR: ${errMsg(e)}\nTry 'tidepull --help'.\n`);
168
+ process.stderr.write(`ERROR: ${sanitizeLog(errMsg(e))}\nTry 'tidepull --help'.\n`);
169
169
  return 2;
170
170
  }
171
171
  if (values.help)
@@ -177,7 +177,7 @@ export async function main(argv) {
177
177
  theme = pickTheme(values.theme);
178
178
  }
179
179
  catch (e) {
180
- process.stderr.write(`ERROR: ${errMsg(e)}\n`);
180
+ process.stderr.write(`ERROR: ${sanitizeLog(errMsg(e))}\n`);
181
181
  return 2;
182
182
  }
183
183
  const machineMode = values.quiet || values["dump-json"] || values["get-url"] || values.simulate || values["progress-json"];
package/dist/ui/log.d.ts CHANGED
@@ -6,6 +6,7 @@ export interface LoggerOptions {
6
6
  theme?: Theme | string;
7
7
  }
8
8
  export declare function shouldUseColor(env?: NodeJS.ProcessEnv, isTTY?: boolean): boolean;
9
+ export declare function sanitizeLog(s: string): string;
9
10
  export declare class Logger {
10
11
  quiet: boolean;
11
12
  verbose: boolean;
package/dist/ui/log.js CHANGED
@@ -6,6 +6,9 @@ export function shouldUseColor(env = process.env, isTTY = !!process.stderr.isTTY
6
6
  return true;
7
7
  return isTTY && env.TERM !== "dumb";
8
8
  }
9
+ export function sanitizeLog(s) {
10
+ return s.replace(/\x1b(?:\[[0-9;?]*[A-Za-z]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[@-Z\\-_])/g, "").replace(/[\x00-\x08\x0a-\x1f\x7f]/g, " ");
11
+ }
9
12
  export class Logger {
10
13
  quiet;
11
14
  verbose;
@@ -22,16 +25,16 @@ export class Logger {
22
25
  }
23
26
  tag(tag, msg) {
24
27
  if (!this.quiet)
25
- process.stderr.write(`${this.paint(this.theme.tag, `[${tag}]`)} ${msg}\n`);
28
+ process.stderr.write(`${this.paint(this.theme.tag, `[${tag}]`)} ${sanitizeLog(msg)}\n`);
26
29
  }
27
30
  debug(msg) {
28
31
  if (this.verbose)
29
- process.stderr.write(`${this.paint(this.theme.dim, "[debug]")} ${msg}\n`);
32
+ process.stderr.write(`${this.paint(this.theme.dim, "[debug]")} ${sanitizeLog(msg)}\n`);
30
33
  }
31
34
  warn(msg) {
32
- process.stderr.write(`${this.paint(this.theme.warn, "WARNING:")} ${msg}\n`);
35
+ process.stderr.write(`${this.paint(this.theme.warn, "WARNING:")} ${sanitizeLog(msg)}\n`);
33
36
  }
34
37
  error(msg) {
35
- process.stderr.write(`${this.paint(this.theme.error, "ERROR:")} ${msg}\n`);
38
+ process.stderr.write(`${this.paint(this.theme.error, "ERROR:")} ${sanitizeLog(msg)}\n`);
36
39
  }
37
40
  }
package/dist/ui/render.js CHANGED
@@ -65,9 +65,12 @@ export function humanRenderer(log, o) {
65
65
  case "item":
66
66
  log.tag("item", `${e.position}/${e.total}${e.title ? ` ${e.title}` : ""}`);
67
67
  break;
68
- case "done":
69
- log.tag("done", colorize(theme.success, e.file));
68
+ case "done": {
69
+ clear();
70
+ const file = colorize(theme.success, e.file);
71
+ log.tag("done", file);
70
72
  break;
73
+ }
71
74
  case "error":
72
75
  clear();
73
76
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boy-offi9-inc/tidepull",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
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",
@@ -78,4 +78,4 @@
78
78
  "library",
79
79
  "typescript"
80
80
  ]
81
- }
81
+ }