/**
 * File module — public surface.
 *
 * The file module uses a **facade + private internals** pattern:
 *
 * - `FileManager` is the single public entry point for all file operations,
 *   registered as a lifecycle service (`@Injectable('FileManager')`,
 *   `@ServicePhase(Phase.WhenReady)`). Main runtime code resolves the
 *   singleton via `application.get('FileManager')`. This barrel exports the
 *   public contract types / errors only — the class itself is reached
 *   through the container, not by direct import.
 * - Implementation lives under `./internal/*` (entry / content / system ops)
 *   as pure-function modules. These are **NOT** re-exported from this barrel
 *   and MUST NOT be imported from outside the file module.
 * - Pure FS / path / metadata primitives live under
 *   `@main/utils/file/{fs,metadata,path,search,shell}` (sole FS owner, open
 *   to the entire Main process). Modules that need raw `atomicWriteFile` /
 *   `stat` etc. import those submodules directly. See `architecture.md §1.2`.
 * - `./watcher/*` exposes `createDirectoryWatcher()` as a consumable primitive
 *   for business modules (e.g. future NoteService).
 * - `./danglingCache.ts` is a file-module singleton; only queried via the
 *   DataApi handler or via FileManager side effects — not imported directly.
 *
 * If you find yourself reaching into `internal/`, the answer is almost
 * certainly "add a method to FileManager" instead.
 */

export type {
  AtomicWriteStream,
  CreateInternalEntryParams,
  EnsureExternalEntryParams,
  FileVersion,
  IFileManager,
  ReadResult
} from './FileManager'
export { StaleVersionError } from './FileManager'

// DanglingCache: interface and singleton are both exported for in-process
// callers (orphanSweep, business services querying live state). External
// imports of the singleton should stay narrow — treat the barrel-exported
// value as read-only from outside the file module.
export type {
  DanglingCache,
  DanglingCacheOptions,
  DanglingListener,
  DanglingStateChangedEvent,
  ObservedPresence
} from './danglingCache'
export { createDanglingCacheImpl, danglingCache } from './danglingCache'

// VersionCache: interface only. The runtime instance is a private class
// field on each `FileManager` (not a module singleton) and is not exposed
// via the barrel — see file-manager-architecture.md §1.6.1 / §12.
export type { VersionCache } from './versionCache'

// Watcher primitive — business modules (future NoteService, KB watcher, etc.)
// call `createDirectoryWatcher` directly. Not a lifecycle service.
export type {
  CreateDirectoryWatcherOptions,
  DirectoryWatcher,
  WatcherEvent,
  WatcherListener
} from './watcher'
export { createDirectoryWatcher } from './watcher'

// Projection helper: managed FileEntry → live on-disk FileInfo descriptor.
export { toFileInfo } from './toFileInfo'
