All files / src/packlets/file-system index.ts

0% Statements 0/3
0% Branches 0/2
0% Functions 0/1
0% Lines 0/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                                                   
/**
 * @packageDocumentation
 *
 * Virtual file system abstraction. Provides a unified interface over the
 * browser's File System API (real directories) and an in-memory demo file
 * system for example projects.
 */
 
import type { ProjectSource } from "../project-store/types";
import type { ProjectFileSystem, FileEntry } from "./types";
import { createFileSystemFromHandle } from "./real-fs";
import { createFileSystemFromExample } from "./demo-fs";
import { showDirectoryPicker } from "./picker";
 
export function createProjectFileSystem(source: ProjectSource): ProjectFileSystem {
  switch (source.provider) {
    case "filesystem":
      return createFileSystemFromHandle(source.handle);
    case "examples":
      return createFileSystemFromExample(source.name);
  }
}
 
export { showDirectoryPicker };
export type { ProjectFileSystem, FileEntry };