@boy-offi9-inc/tidepull 0.7.4 → 0.7.5

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.
Files changed (2) hide show
  1. package/dist/loader.js +15 -1
  2. package/package.json +1 -1
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/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.5",
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",