index.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.fsa = void 0;
  4. const tslib_1 = require("tslib");
  5. const CoreFileSystemDirectoryHandle_1 = require("./CoreFileSystemDirectoryHandle");
  6. const fs_core_1 = require("@jsonjoy.com/fs-core");
  7. const CoreFileSystemObserver_1 = require("./CoreFileSystemObserver");
  8. tslib_1.__exportStar(require("./types"), exports);
  9. tslib_1.__exportStar(require("./CoreFileSystemHandle"), exports);
  10. tslib_1.__exportStar(require("./CoreFileSystemDirectoryHandle"), exports);
  11. tslib_1.__exportStar(require("./CoreFileSystemFileHandle"), exports);
  12. tslib_1.__exportStar(require("./CoreFileSystemSyncAccessHandle"), exports);
  13. tslib_1.__exportStar(require("./CoreFileSystemWritableFileStream"), exports);
  14. tslib_1.__exportStar(require("./CoreFileSystemObserver"), exports);
  15. tslib_1.__exportStar(require("./CorePermissionStatus"), exports);
  16. tslib_1.__exportStar(require("./FileLockManager"), exports);
  17. /**
  18. * Create a new instance of an in-memory File System Access API
  19. * implementation rooted at the root directory of the filesystem.
  20. *
  21. * @param ctx Optional context for the File System Access API.
  22. * @param core Optional low-level file system implementation to
  23. * back the File System Access API. If not provided, a new empty
  24. * Superblock instance will be created.
  25. * @param dirPath Optional path within the filesystem to use as the root
  26. * directory of the File System Access API. Defaults to `/`.
  27. * @returns A File System Access API implementation `dir` rooted at
  28. * the root directory of the filesystem, as well as the `core`,
  29. * a low-level file system implementation itself. Also, returns
  30. * `FileSystemObserver`, a class that can be used to create
  31. * observers that watch for changes to files and directories.
  32. */
  33. const fsa = (ctx, core = new fs_core_1.Superblock(), dirPath = '/') => {
  34. const dir = new CoreFileSystemDirectoryHandle_1.CoreFileSystemDirectoryHandle(core, dirPath, ctx);
  35. const FileSystemObserver = class FileSystemObserver extends CoreFileSystemObserver_1.CoreFileSystemObserver {
  36. constructor(callback) {
  37. super(core, callback);
  38. }
  39. };
  40. return { core, dir, FileSystemObserver };
  41. };
  42. exports.fsa = fsa;
  43. //# sourceMappingURL=index.js.map