also exported from index.ts
AnalysisSession import type {AnalysisSession} from 'svelte-docinfo/session.js'; Persistent analysis handle.
Concurrency: not safe across overlapping calls. Serialize externally
(each caller awaits the previous setFile/setFiles before starting the
next). The LS underneath is sync, but the resolver phase awaits I/O for
async resolvers (Vite/Rollup), so the session does cross await boundaries.
Cache-hit semantics: per-entry, all-or-nothing. The implementation must not split the guarantee across separate caches (e.g. transform-cache hit + lex re-run). The match criterion is mode-discriminated:
- lex+resolve mode:
existing.content === incoming.contentANDexisting.resolverIdentity === incoming.resolverIdentity. - pre-resolved mode:
existing.content === incoming.contentANDarraysShallowEqual(existing.preResolvedDepsSnapshot, incoming.dependencies).
Mode flips (an entry previously ingested as lex+resolve now arrives with
dependencies, or vice versa) always cache-miss.
Promise resolution: setFile / setFiles resolve only after the
serial LS push (phase 3) completes for every file in the batch. Awaiting
the returned promise is sufficient — no separate flush step.
setFile
Ingest one file's content into the session. Idempotent on cache hit.
type (file: SourceFileInfo, opts?: SetFileOptions | undefined): Promise<SetFileResult>
file
opts?
SetFileOptions | undefinedPromise<SetFileResult>{changed, diagnostics} — changed: false indicates a
cache-hit no-op where the cached ingest diagnostics are returned.
setFiles
Ingest a batch of files. Additive — never removes; use deleteFile for
removal. Cache hits are folded into the result with changed: false.
type (files: readonly SourceFileInfo[], opts?: SetFileOptions | undefined): Promise<SetFilesResult>
files
readonly SourceFileInfo[]opts?
SetFileOptions | undefinedPromise<SetFilesResult>deleteFile
Drop a file from the session and evict from the LS.
type (id: string): Promise<void>
id
stringPromise<void>has
Whether the given file ID is currently owned by the session.
type (id: string): boolean
id
stringbooleanlist
Snapshot of currently-owned file IDs (sort order is insertion order).
type (): readonly string[]
readonly string[]query
Run a two-phase analysis pass against the current owned set.
type (opts?: QueryOptions | undefined): { modules: { path: string; declarations: ({ kind: "function"; parameters: { name: string; type: string; optional: boolean; rest: boolean; description?: string | undefined; defaultValue?: string | undefined; propertyDescriptions?: Record<...> | undefined; }[]; ... 17 more ...; sourceLine?: number | undefined; } | ... 7 more ... | { ...; })[]; ... 7 more ...; moduleComment?: string | undefined; }[]; diagnostics: ({ ...; } | ... 12 more ... | { ...; })[]; }
opts?
QueryOptions | undefined{ modules: { path: string; declarations: ({ kind: "function"; parameters: { name: string; type: string; optional: boolean; rest: boolean; description?: string | undefined; defaultValue?: string | undefined; propertyDescriptions?: Record<...> | undefined; }[]; ... 17 more ...; sourceLine?: number | undefined; } | ......analyzed modules and analysis-pass diagnostics. Ingest
diagnostics from prior setFile/setFiles calls are NOT included
here — concat with those returns for the full picture.
throws
Error- if `onDuplicates: 'throw'` and duplicates exist
allIngestDiagnostics
Concatenated ingest-time diagnostics across every owned entry — the
cumulative view of every setFile/setFiles return, kept current as
entries are added/replaced/deleted.
Lets long-lived consumers (Vite plugin, LSP) publish the full ingest picture without tracking per-batch returns themselves. Cheap: walks the owned map.
type (): ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 11 more ... | { ...; })[]
({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 11 more ... | { ...; })[]dispose
Release LS resources and clear the owned set. The session must not be used after disposal.
type (): void
void