import type { Help, UseKind } from '@variance-authority/package/help'; import { type StoreRows } from './store-rows.js'; import { type StoreHead } from './store-layout.js'; /** * The questions' store: the Help value and the search over it, in one file a * question opens in place. * * The value holds every export of the repository, every import site of every * published name, and every signature and doc comment. A question needs a few * rows of it: a name's entry, its uses, a substring over names and docs. * Parsing the whole value to ask for one name made every question cost the * repository: on Kibana, 162 MB of JSON in front of every name question. * * So every field is a column here, every string lives once in a pool, and the * text a substring runs over is one lowercased byte run per column. Opening the * file costs one read and no decoding; a question decodes the rows it reads, * and the value decodes a field the first time something reads it. * * The loose pass reads a term dictionary written with the same tokenizer and * term rule MiniSearch was given, so the set it answers is the set MiniSearch * would have answered without building an index per question * ([`loose.ts`](./tools/loose.ts)). The dictionary holds each token whole and, * when the token is written in several words, each word, so `select test * files` reaches `selectTestFiles`. */ /** * The tokenizer MiniSearch applies by default, which the loose pass was built * with, the backtick, a symbol that delimits a code span and is never a word's, * and a math symbol (`Sm`), which a type writes between names: `Promise`, * `A | B`, `=>`. */ export declare const SPACE_OR_PUNCTUATION: RegExp; /** A query's terms: the tokens it was typed in, short ones dropped, the rest lowercased. */ export declare function tokensOf(text: string): readonly string[]; /** One published name, as a search line prints it. */ export interface PublishedRow { readonly row: number; readonly name: string; readonly specifier: string; readonly kind: string; readonly doc?: string; readonly at: string; /** Counted and not named: a list line never names who imports. */ readonly usedBy: { readonly length: number; }; readonly uses: number; } /** One exported name, as a search line prints it. */ export interface ExportedRow { readonly row: number; readonly name: string; readonly at: string; readonly by: string; readonly line: number; readonly kind: UseKind; readonly doc?: string; } /** An opened store's search: columns over one buffer, decoded a row at a time. */ export interface SearchIndex { /** The generation the store was published as; absent when it was encoded in memory. */ readonly generation?: StoreHead; /** Names whose lowercase text contains `query`, ascending. */ namesContaining(query: string): readonly number[]; /** Published rows whose lowercase doc contains `query`, ascending. */ docsContaining(query: string): readonly number[]; /** Exported rows whose lowercase doc contains `query`, ascending. */ exportedDocsContaining(query: string): readonly number[]; /** Of {@link docsContaining}, the rows whose doc says `query` in its opening paragraph, before any blank line. */ docOpeningsContaining(query: string): readonly number[]; /** Of {@link exportedDocsContaining}, the rows whose doc says `query` in its opening paragraph. */ exportedDocOpeningsContaining(query: string): readonly number[]; /** The name `id` names; ids are in code-unit order of the names. */ name(id: number): string; publishedOf(name: number): Uint32Array; exportedOf(name: number): Uint32Array; published(row: number): PublishedRow; /** The name id of one published row, without decoding the rest of it. */ publishedName(row: number): number; /** The bytes of one published row's doc, without decoding it; absent when it has none. */ publishedDocLength(row: number): number | undefined; /** The package and import counts of one published row, read off their columns. */ usedBy(row: number): number; uses(row: number): number; /** The files that import one published row, one per import site. */ sites(row: number): readonly string[]; /** The same, as file ids. */ siteFiles(row: number): Uint32Array; /** The ids of those of `paths` any row names; a path no row names has none. */ fileIds(paths: Iterable): ReadonlySet; file(id: number): string; exportedFile(row: number): number; exported(row: number): ExportedRow; /** The name id of one exported row, without decoding the rest of it. */ exportedName(row: number): number; /** The bytes of one exported row's doc, without decoding it; absent when it has none. */ exportedDocLength(row: number): number | undefined; /** Where one exported row sits among source, test and story: 0, 1 or 2. */ exportedKind(row: number): number; /** The file of one exported row, without decoding the rest of it. */ exportedAt(row: number): string; /** The line of one exported row, without decoding its documentation. */ exportedLine(row: number): number; /** The file of one published row. */ publishedAt(row: number): string; /** The rows a question names, by name, by file and by specifier, without the lists they are rows of. */ readonly rows: StoreRows; /** How many names the index holds. */ readonly nameCount: number; /** How many dictionary terms there are; they are ordered by their UTF-8 bytes. */ readonly termCount: number; term(id: number): string; termBytes(id: number): Buffer; termNames(term: number): Uint32Array; termPublished(term: number): Uint32Array; /** The exported rows whose doc holds the term. */ termExported(term: number): Uint32Array; /** The published rows whose signature holds the term: what the declaration writes before its body. */ termPublishedSignature(term: number): Uint32Array; /** The exported rows whose signature holds the term. */ termExportedSignature(term: number): Uint32Array; } /** One opened store: the Help value, decoded a field at a time, and the search over it. */ export interface OpenedStore { readonly help: Help; readonly search: SearchIndex; /** Absent for a store encoded in memory. */ readonly generation?: StoreHead; /** The digest of the export list, which every store carries. */ readonly exportedDigest: string; } /** Open one encoded store's search. Throws on anything that is not this format and version. */ export declare function openSearchIndex(bytes: Uint8Array): SearchIndex; /** * Open one encoded store. Throws on anything that is not this format and * version; nothing past the head is decoded until something reads it. */ export declare function openHelpStore(bytes: Uint8Array): OpenedStore; //# sourceMappingURL=search-index.d.ts.map