import { Resource, ResourceLink } from './note'; import { URI } from './uri'; import { ResourceProvider } from './provider'; import { IDisposable } from '../common/lifecycle'; import { IDataStore } from '../services/datastore'; export declare class FoamWorkspace implements IDisposable { defaultExtension: string; private onDidAddEmitter; private onDidUpdateEmitter; private onDidDeleteEmitter; onDidAdd: import("../common/event").Event; onDidUpdate: import("../common/event").Event<{ old: Resource; new: Resource; }>; onDidDelete: import("../common/event").Event; private providers; /** * Resources by path */ private _resources; /** * Maps a normalized directory path to the URI of its directory index file owner. * Only index and README files (with any configured note extension) are registered here. * Priority: index > README. Maintained independently of the main trie. */ private _directoryIndex; /** Basenames (without extension, lowercase) that qualify as directory index files, in priority order */ private static readonly DIRECTORY_INDEX_NAMES; /** * The root URIs of this workspace, in priority order. * Used for resolving workspace-relative paths. * First root is always used when a path must be resolved to exactly one root. */ readonly roots: URI[]; /** * @param roots The root URIs of the workspace (e.g. VS Code workspace folders) * @param defaultExtension The default extension for notes in this workspace (e.g. `.md`) */ constructor(roots?: URI[], defaultExtension?: string); registerProvider(provider: ResourceProvider): void; /** * Resolves a path string to an absolute URI within this workspace. * * Filesystem inputs (Windows drive paths, UNC paths, backslash separators) * are normalized to POSIX via {@link fromFsPath}, then classified. * * Resolution rules (in order): * 1. Filesystem-absolute path already under a workspace root → returned as-is * 2. Workspace-relative absolute path (starts with '/' but not under any root) → * resolved as roots[0].joinPath(path) * 3. Relative path → resolved relative to `relativeTo` if provided, otherwise roots[0] * * Throws when `roots` is empty and no `relativeTo` is provided — there's * no base URI to derive scheme/authority from. Callers must construct a * workspace with at least one root or supply a `relativeTo` URI. */ resolveUri(filepath: string, relativeTo?: URI): URI; set(resource: Resource): this; delete(uri: URI): Resource; clear(): void; /** * Returns the priority index of a URI as a directory index file (lower = higher priority). * Returns -1 if the URI is not a directory index file. */ private _directoryIndexPriority; private _registerDirectoryIndex; private _unregisterDirectoryIndex; /** * Returns the directory index file for the given directory path, or null if none exists. * The directory path should be an absolute path string (e.g. resource.uri.getDirectory().path). */ findByDirectory(dirPath: string): Resource | null; /** * Returns all directory index resources whose directory path ends with the given identifier. * Used to resolve wikilinks like [[bar]] or [[zoo/bar]] to directory index files. * Results are sorted by path for deterministic ordering. */ listByDirectoryIdentifier(identifier: string): Resource[]; exists(uri: URI): boolean; list(): Resource[]; resources(): IterableIterator; get(uri: URI): Resource; listByIdentifier(identifier: string): Resource[]; /** * Returns the minimal identifier for the given resource * * @param forResource the resource to compute the identifier for */ getIdentifier(forResource: URI, exclude?: URI[]): string; /** * Returns the shortest unambiguous directory-style identifier for a directory index file * (e.g. `bar` or `zoo/bar`), or null if the resource is not the current directory index owner. * * Use this when `foam.links.directory.completionStyle` is `"directory"`. */ getDirectoryIdentifier(forResource: URI): string | null; /** * Returns a note identifier in reversed order. Used to optimise the storage of notes in * the workspace to optimise retrieval of notes. * * @param reference the URI path to reverse */ private getTrieIdentifier; find(reference: URI | string, baseUri?: URI): Resource | null; resolveLink(resource: Resource, link: ResourceLink): URI; fetch(uri: URI): Promise; /** * Takes a resource URI, and adds it to the workspace as a resource. * If the URI is not supported by any provider or is not found, it will not * add anything to the workspace, and return null. * * @param uri the URI where the resource is located * @returns A promise to the Resource, or null if none was found */ fetchAndSet(uri: URI): Promise; readAsMarkdown(uri: URI): Promise; dispose(): void; static isIdentifier(path: string): boolean; /** * Returns the minimal identifier for the given string amongst others * * @param forPath the value to compute the identifier for * @param amongst the set of strings within which to find the identifier */ static getShortestIdentifier(forPath: string, amongst: string[]): string; static fromProviders(roots: URI[], providers: ResourceProvider[], dataStore: IDataStore, defaultExtension?: string, fetchConcurrency?: number): Promise; } //# sourceMappingURL=workspace.d.ts.map