import { ResourceLink } from './note'; import { URI } from './uri'; import { FoamWorkspace } from './workspace'; import { IDisposable } from '../common/lifecycle'; export type Connection = { source: URI; target: URI; link: ResourceLink; }; export declare class FoamGraph implements IDisposable { private readonly workspace; /** * Placehoders by key / slug / value */ readonly placeholders: Map; /** * Maps the connections starting from a URI */ readonly links: Map; /** * Maps the connections arriving to a URI */ readonly backlinks: Map; private onDidUpdateEmitter; onDidUpdate: import("../common/event").Event; /** * List of disposables to destroy with the workspace */ private disposables; constructor(workspace: FoamWorkspace); contains(uri: URI): boolean; getAllNodes(): URI[]; getAllConnections(): Connection[]; getConnections(uri: URI): Connection[]; getLinks(uri: URI): Connection[]; getBacklinks(uri: URI): Connection[]; /** * Computes all the links in the workspace, connecting notes and * creating placeholders. * * @param workspace the target workspace * @param keepMonitoring whether to recompute the links when the workspace changes * @param debounceFor how long to wait between change detection and graph update * @returns the FoamGraph */ static fromWorkspace(workspace: FoamWorkspace, keepMonitoring?: boolean): FoamGraph; /** * Full rebuild of the graph from the workspace. Used for the initial build and * available as a fallback; steady-state changes go through the incremental * onResource* handlers. */ update(): void; /** * A note's content changed. Its OUTGOING links may have changed, but incoming * backlinks are unaffected (the note existed before and after, so how other * notes resolve to it does not change). Reconnect just this note's links. */ private onResourceUpdated; /** * A new note appeared. Connect its outgoing links, then handle the fan-out: * notes that were linking to a PLACEHOLDER which this note now fills must be * recomputed (their link resolves to the real note instead). We can't cheaply * invert resolution, so we re-resolve the sources of each existing placeholder * and reconnect those whose target changed. */ private onResourceAdded; /** * A note was removed. Drop its outgoing links, then handle the fan-out: notes * that linked TO this note now resolve to a placeholder, so recompute them. * Those sources are exactly the (now stale) backlinks to the deleted note. */ private onResourceDeleted; /** Distinct source URIs whose links currently point at `target.path`. */ private sourcesLinkingTo; /** * Reconnects the outgoing links of every source that currently links to a * placeholder. Used on note-add: filling a placeholder changes how its * referrers resolve. Bounded by the number of placeholder backlinks, not the * workspace size. Reconnecting is idempotent, so re-resolving unaffected * sources is harmless. */ private reconnectAffectedPlaceholderSources; /** Disconnects and re-resolves the outgoing links of each given source. */ private reconnectSources; /** Resolves and connects all of a resource's (non-external) links. */ private connectResource; /** * Removes all connections originating from `source`: deletes its `links` * entry, filters it out of each affected target's `backlinks`, and drops any * placeholder left with no remaining backlinks. */ private disconnectResource; private connect; dispose(): void; } //# sourceMappingURL=graph.d.ts.map