@threadbase-sh/streamer 1.51.0 → 1.52.0

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/index.js CHANGED
@@ -6329,6 +6329,10 @@ async function listDirectories(absolutePath) {
6329
6329
  const entries = await readdir(absolutePath, { withFileTypes: true });
6330
6330
  return entries.filter((e) => e.isDirectory()).map((e) => ({ name: e.name })).sort((a, b) => a.name.localeCompare(b.name));
6331
6331
  }
6332
+ async function listFiles(absolutePath) {
6333
+ const entries = await readdir(absolutePath, { withFileTypes: true });
6334
+ return entries.filter((e) => e.isFile()).map((e) => ({ name: e.name })).sort((a, b) => a.name.localeCompare(b.name));
6335
+ }
6332
6336
  async function createDirectory(parentAbsolutePath, name) {
6333
6337
  if (name.includes("/") || name.includes("\\") || name === ".." || name === ".") {
6334
6338
  throw new Error("Invalid directory name");
@@ -15320,8 +15324,11 @@ var StreamerServer = class {
15320
15324
  const relativePath = url.searchParams.get("path") ?? "";
15321
15325
  try {
15322
15326
  const resolved = await resolveBrowsePath(this.browseRoot, relativePath);
15323
- const directories = await listDirectories(resolved);
15324
- json(res, 200, { path: relativePath, directories });
15327
+ const [directories, files] = await Promise.all([
15328
+ listDirectories(resolved),
15329
+ listFiles(resolved)
15330
+ ]);
15331
+ json(res, 200, { path: relativePath, directories, files });
15325
15332
  } catch (err) {
15326
15333
  const message = err instanceof Error ? err.message : "Browse failed";
15327
15334
  if (err instanceof BrowsePathNotFoundError) {