@xh/hoist-docs-builder 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/hoist-docs-build.mjs +12 -0
- package/dist/cli/build-index.d.ts +15 -0
- package/dist/cli/build-index.js +199 -0
- package/dist/data/doc-registry.d.ts +148 -0
- package/dist/data/doc-registry.js +378 -0
- package/dist/data/import-paths.d.ts +28 -0
- package/dist/data/import-paths.js +107 -0
- package/dist/data/index-cache.d.ts +30 -0
- package/dist/data/index-cache.js +210 -0
- package/dist/data/ts-registry.d.ts +251 -0
- package/dist/data/ts-registry.js +1845 -0
- package/dist/util/logger.d.ts +6 -0
- package/dist/util/logger.js +31 -0
- package/dist/util/paths.d.ts +103 -0
- package/dist/util/paths.js +200 -0
- package/package.json +34 -4
- package/README.md +0 -3
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file belongs to Hoist, an application development toolkit
|
|
3
|
+
* developed by Extremely Heavy Industries (www.xh.io | info@xh.io)
|
|
4
|
+
*
|
|
5
|
+
* Copyright © 2026 Extremely Heavy Industries Inc.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Disk-persisted cache for the TypeScript symbol/member indexes.
|
|
9
|
+
*
|
|
10
|
+
* Turns cold CLI invocations from multi-second ts-morph builds into sub-second
|
|
11
|
+
* loads when source files haven't changed. The cache stores the prebuilt
|
|
12
|
+
* `symbolIndex`, `memberIndex`, and `promiseExtensionDetails`, keyed by a
|
|
13
|
+
* fingerprint over the indexable source-file set (path + mtime + size).
|
|
14
|
+
*
|
|
15
|
+
* Cache hit: deserialize and skip the ts-morph build. The live `Project` is
|
|
16
|
+
* only constructed if/when a detail-extraction call (`getSymbolDetail`,
|
|
17
|
+
* `getMembers`) needs AST access.
|
|
18
|
+
*
|
|
19
|
+
* Cache miss / stale: returns null. Caller falls back to the full build path,
|
|
20
|
+
* then writes a fresh cache via `writeCache`.
|
|
21
|
+
*
|
|
22
|
+
* Invalidation:
|
|
23
|
+
* - any source file's mtime or size changes
|
|
24
|
+
* - `package.json` mtime/size changes (catches snapshot/version bumps)
|
|
25
|
+
* - {@link CACHE_SCHEMA_VERSION} bump for breaking changes to entry shape
|
|
26
|
+
*/
|
|
27
|
+
import { createHash } from 'node:crypto';
|
|
28
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
29
|
+
import { dirname, resolve } from 'node:path';
|
|
30
|
+
import { fileURLToPath } from 'node:url';
|
|
31
|
+
import { log } from '../util/logger.js';
|
|
32
|
+
import { getLibraryOptions } from '../util/paths.js';
|
|
33
|
+
/**
|
|
34
|
+
* Bump when the shape of {@link SymbolEntry}, {@link MemberIndexEntry}, or
|
|
35
|
+
* {@link SymbolDetail} changes in a way that would make existing caches
|
|
36
|
+
* misleading. Old caches are silently discarded on schema mismatch.
|
|
37
|
+
*/
|
|
38
|
+
const CACHE_SCHEMA_VERSION = 2;
|
|
39
|
+
/** Directories pruned from the fingerprint walk - mirrors `buildSymbolIndex` filters. */
|
|
40
|
+
const EXCLUDED_DIRS = new Set([
|
|
41
|
+
'node_modules',
|
|
42
|
+
'build',
|
|
43
|
+
'docs-index',
|
|
44
|
+
'mcp',
|
|
45
|
+
'.git',
|
|
46
|
+
'.idea',
|
|
47
|
+
'.vscode',
|
|
48
|
+
'docs'
|
|
49
|
+
]);
|
|
50
|
+
/**
|
|
51
|
+
* Builder source files whose changes invalidate the cache. Without this, editing the indexer
|
|
52
|
+
* logic would keep loading caches built by the previous version of the code until an unrelated
|
|
53
|
+
* hoist-react source file changed. Paths are relative to this builder's root.
|
|
54
|
+
*/
|
|
55
|
+
const INDEXER_SOURCES = [
|
|
56
|
+
'data/ts-registry.ts',
|
|
57
|
+
'data/import-paths.ts',
|
|
58
|
+
'data/index-cache.ts',
|
|
59
|
+
'util/paths.ts'
|
|
60
|
+
];
|
|
61
|
+
const BUILDER_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
62
|
+
function cachePath(repoRoot) {
|
|
63
|
+
return resolve(repoRoot, 'node_modules', '.cache', 'hoist-docs-index', 'index-v1.json');
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Hash all candidate source files (path + mtime + size) plus `package.json`,
|
|
67
|
+
* yielding a fingerprint that changes whenever any indexable file or the
|
|
68
|
+
* package version changes. Mirrors the file-set filter applied in
|
|
69
|
+
* `buildSymbolIndex` so the fingerprint and the indexed file set stay in sync.
|
|
70
|
+
*
|
|
71
|
+
* Walks the repo tree once, one stat per `.ts`/`.tsx` file outside the excluded
|
|
72
|
+
* directories. Sub-100ms on a fast disk.
|
|
73
|
+
*/
|
|
74
|
+
export function computeFingerprint(repoRoot) {
|
|
75
|
+
const entries = [];
|
|
76
|
+
function walk(dir) {
|
|
77
|
+
let dirents;
|
|
78
|
+
try {
|
|
79
|
+
dirents = readdirSync(dir, { withFileTypes: true });
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
for (const entry of dirents) {
|
|
85
|
+
if (entry.name.startsWith('.'))
|
|
86
|
+
continue;
|
|
87
|
+
if (entry.isDirectory()) {
|
|
88
|
+
if (EXCLUDED_DIRS.has(entry.name))
|
|
89
|
+
continue;
|
|
90
|
+
walk(resolve(dir, entry.name));
|
|
91
|
+
}
|
|
92
|
+
else if (entry.isFile()) {
|
|
93
|
+
if (!entry.name.endsWith('.ts') && !entry.name.endsWith('.tsx'))
|
|
94
|
+
continue;
|
|
95
|
+
if (entry.name.endsWith('.spec.ts'))
|
|
96
|
+
continue;
|
|
97
|
+
const fullPath = resolve(dir, entry.name);
|
|
98
|
+
try {
|
|
99
|
+
const stats = statSync(fullPath);
|
|
100
|
+
const rel = fullPath.slice(repoRoot.length);
|
|
101
|
+
entries.push(`${rel}:${stats.mtimeMs}:${stats.size}`);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// skip unreadable files
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
walk(repoRoot);
|
|
110
|
+
// A cache built for other library options is not this build's.
|
|
111
|
+
entries.push(`options:${JSON.stringify(getLibraryOptions())}`);
|
|
112
|
+
entries.sort();
|
|
113
|
+
const hash = createHash('sha256');
|
|
114
|
+
for (const e of entries)
|
|
115
|
+
hash.update(e + '\n');
|
|
116
|
+
try {
|
|
117
|
+
const pkgStat = statSync(resolve(repoRoot, 'package.json'));
|
|
118
|
+
hash.update(`pkg:${pkgStat.mtimeMs}:${pkgStat.size}`);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
// package.json must exist (resolveRepoRoot enforces this); if stat
|
|
122
|
+
// fails for an unrelated reason we just skip the mix-in.
|
|
123
|
+
}
|
|
124
|
+
for (const rel of INDEXER_SOURCES) {
|
|
125
|
+
try {
|
|
126
|
+
const stat = statSync(resolve(BUILDER_ROOT, rel));
|
|
127
|
+
hash.update(`indexer:${rel}:${stat.mtimeMs}:${stat.size}`);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
// Indexer sources may be absent in unusual setups (e.g. a stripped
|
|
131
|
+
// package without the `docs-index/` tree). Skip the mix-in rather than
|
|
132
|
+
// fail; the index would just be unbuildable in that environment.
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return hash.digest('hex');
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Try to load cached indexes for the given repo. Returns `null` if the cache
|
|
139
|
+
* is missing, malformed, schema-mismatched, or fingerprint-stale - in any of
|
|
140
|
+
* those cases the caller should fall back to a fresh build.
|
|
141
|
+
*
|
|
142
|
+
* Set `HOIST_MCP_NO_CACHE=1` in the environment to bypass cache reads (useful
|
|
143
|
+
* for debugging).
|
|
144
|
+
*/
|
|
145
|
+
export function loadCache(repoRoot) {
|
|
146
|
+
if (process.env.HOIST_MCP_NO_CACHE)
|
|
147
|
+
return null;
|
|
148
|
+
const filePath = cachePath(repoRoot);
|
|
149
|
+
if (!existsSync(filePath))
|
|
150
|
+
return null;
|
|
151
|
+
let payload;
|
|
152
|
+
try {
|
|
153
|
+
payload = JSON.parse(readFileSync(filePath, 'utf8'));
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
log.debug(`Cache read failed, will rebuild: ${e}`);
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
if (payload.schemaVersion !== CACHE_SCHEMA_VERSION) {
|
|
160
|
+
log.debug(`Cache schema mismatch (cached=${payload.schemaVersion}, expected=${CACHE_SCHEMA_VERSION}); rebuilding`);
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
const fingerprint = computeFingerprint(repoRoot);
|
|
164
|
+
if (payload.fingerprint !== fingerprint) {
|
|
165
|
+
log.debug('Cache fingerprint stale; rebuilding');
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
symbols: new Map(payload.symbols),
|
|
170
|
+
members: new Map(payload.members),
|
|
171
|
+
promiseExtensions: new Map(payload.promiseExtensions)
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Write index data to disk atomically (write-to-tmp then rename). Failures
|
|
176
|
+
* are logged but non-fatal - the next invocation just rebuilds.
|
|
177
|
+
*/
|
|
178
|
+
export function writeCache(repoRoot, fingerprint, indexes) {
|
|
179
|
+
if (process.env.HOIST_MCP_NO_CACHE)
|
|
180
|
+
return;
|
|
181
|
+
const filePath = cachePath(repoRoot);
|
|
182
|
+
try {
|
|
183
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
184
|
+
}
|
|
185
|
+
catch (e) {
|
|
186
|
+
log.warn(`Failed to create cache dir, registry won't persist: ${e}`);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const payload = {
|
|
190
|
+
schemaVersion: CACHE_SCHEMA_VERSION,
|
|
191
|
+
fingerprint,
|
|
192
|
+
symbols: [...indexes.symbols.entries()],
|
|
193
|
+
members: [...indexes.members.entries()],
|
|
194
|
+
promiseExtensions: [...indexes.promiseExtensions.entries()]
|
|
195
|
+
};
|
|
196
|
+
const tmpPath = `${filePath}.${process.pid}.tmp`;
|
|
197
|
+
try {
|
|
198
|
+
writeFileSync(tmpPath, JSON.stringify(payload));
|
|
199
|
+
renameSync(tmpPath, filePath);
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
log.warn(`Failed to write registry cache: ${e}`);
|
|
203
|
+
try {
|
|
204
|
+
unlinkSync(tmpPath);
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
// best-effort cleanup
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/** Kind of TypeScript symbol in the index. */
|
|
2
|
+
export type SymbolKind = 'class' | 'interface' | 'type' | 'function' | 'const' | 'enum';
|
|
3
|
+
/** Lightweight index entry for fast search. */
|
|
4
|
+
export interface SymbolEntry {
|
|
5
|
+
name: string;
|
|
6
|
+
kind: SymbolKind;
|
|
7
|
+
filePath: string;
|
|
8
|
+
isExported: boolean;
|
|
9
|
+
sourcePackage: string;
|
|
10
|
+
/**
|
|
11
|
+
* Barrel import path (`@xh/hoist/cmp/grid`) - the shallowest package barrel that re-exports
|
|
12
|
+
* the symbol - or null when no barrel does. Output then shows the file path, derived from
|
|
13
|
+
* `filePath`, with `barrelExport: false`. See `import-paths.ts`.
|
|
14
|
+
*/
|
|
15
|
+
importPath: string | null;
|
|
16
|
+
/** JSDoc, if available. Populated at index time; displayed in search results. */
|
|
17
|
+
jsDoc: string;
|
|
18
|
+
/**
|
|
19
|
+
* Short hint for member-indexed owners, sourced from an `@mcpHint` JSDoc tag
|
|
20
|
+
* on the declaration. Shown alongside member search results to clarify how
|
|
21
|
+
* the owner fits into the framework (e.g. "model backing all grid
|
|
22
|
+
* components"). Omitted when the declaration has no `@mcpHint` tag.
|
|
23
|
+
*/
|
|
24
|
+
mcpHint?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Space-separated own member names for member-indexed owners (classes and `*Config`,
|
|
27
|
+
* `*Spec`, and `*Options` interfaces - not `*Props`, see `buildSymbolIndex`), used to expand
|
|
28
|
+
* the searchable text in symbol search. Only includes members directly declared on the
|
|
29
|
+
* owner - inherited HoistBase/HoistModel members are excluded to avoid noise from
|
|
30
|
+
* ubiquitous framework plumbing (destroy, addReaction, etc.). Empty for owners whose
|
|
31
|
+
* members are not indexed.
|
|
32
|
+
*/
|
|
33
|
+
memberNames?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Detailed symbol information extracted on-demand. */
|
|
36
|
+
export interface SymbolDetail {
|
|
37
|
+
name: string;
|
|
38
|
+
kind: SymbolKind;
|
|
39
|
+
filePath: string;
|
|
40
|
+
sourcePackage: string;
|
|
41
|
+
isExported: boolean;
|
|
42
|
+
/** Barrel import path, or null when no barrel does. See {@link SymbolEntry.importPath}. */
|
|
43
|
+
importPath: string | null;
|
|
44
|
+
signature: string;
|
|
45
|
+
jsDoc: string;
|
|
46
|
+
extends?: string;
|
|
47
|
+
implements?: string[];
|
|
48
|
+
decorators?: string[];
|
|
49
|
+
constructorType?: string;
|
|
50
|
+
/**
|
|
51
|
+
* For a const, the indexed class it is an instance of (`XHApi` for `XH`), from a
|
|
52
|
+
* `new Class()` initializer, a type annotation, or the checker's resolved type.
|
|
53
|
+
*/
|
|
54
|
+
instanceOf?: string;
|
|
55
|
+
}
|
|
56
|
+
/** A method parameter, with optional description sourced from a `@param` JSDoc tag. */
|
|
57
|
+
export interface MemberParameter {
|
|
58
|
+
name: string;
|
|
59
|
+
type: string;
|
|
60
|
+
/** Description from a matching `@param` JSDoc tag, when present. */
|
|
61
|
+
description?: string;
|
|
62
|
+
}
|
|
63
|
+
/** A member (property or method) of a class or interface. */
|
|
64
|
+
export interface MemberInfo {
|
|
65
|
+
name: string;
|
|
66
|
+
kind: 'property' | 'method' | 'accessor';
|
|
67
|
+
type: string;
|
|
68
|
+
isStatic: boolean;
|
|
69
|
+
isOptional?: boolean;
|
|
70
|
+
decorators: string[];
|
|
71
|
+
jsDoc: string;
|
|
72
|
+
/**
|
|
73
|
+
* Property initializer text (`true`, `'grid'`, `[]`) when the declaration has one that is
|
|
74
|
+
* short enough to read as a default. Defaults assigned in constructors or helpers are not
|
|
75
|
+
* chased.
|
|
76
|
+
*/
|
|
77
|
+
default?: string;
|
|
78
|
+
parameters?: MemberParameter[];
|
|
79
|
+
returnType?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Return-value info sourced from a `@returns` JSDoc tag. Distinct from
|
|
82
|
+
* `returnType` (which carries only the static type) - `returns.description`
|
|
83
|
+
* carries the author's prose explanation. Omitted when no `@returns` tag
|
|
84
|
+
* is present.
|
|
85
|
+
*/
|
|
86
|
+
returns?: {
|
|
87
|
+
type: string;
|
|
88
|
+
description: string;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Parent class name when this member is inherited via the `extends` chain
|
|
92
|
+
* - both the member and its behavior come from the named ancestor.
|
|
93
|
+
* Existing behavior from #4284. Orthogonal to {@link jsDocInheritedFrom}:
|
|
94
|
+
* a subclass member that is inherited from a parent class AND whose docs
|
|
95
|
+
* the parent itself inherits from an implemented interface will have both
|
|
96
|
+
* fields populated.
|
|
97
|
+
*/
|
|
98
|
+
inheritedFrom?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Interface name when this member's JSDoc was inherited from an
|
|
101
|
+
* implemented interface because no class in the surfaced extends chain
|
|
102
|
+
* declares own JSDoc on this member. The member itself is declared on a
|
|
103
|
+
* class (named via {@link inheritedFrom} when inherited, or the surfaced
|
|
104
|
+
* class when not) - the interface only contributes documentation.
|
|
105
|
+
*/
|
|
106
|
+
jsDocInheritedFrom?: string;
|
|
107
|
+
}
|
|
108
|
+
/** Lightweight index entry for a class member, enabling search by member name. */
|
|
109
|
+
export interface MemberIndexEntry {
|
|
110
|
+
name: string;
|
|
111
|
+
memberKind: 'property' | 'method' | 'accessor';
|
|
112
|
+
ownerName: string;
|
|
113
|
+
/** Short hint for the owner, from its `@mcpHint` JSDoc tag. Undefined if the owner has no tag. */
|
|
114
|
+
ownerHint?: string;
|
|
115
|
+
filePath: string;
|
|
116
|
+
sourcePackage: string;
|
|
117
|
+
isStatic: boolean;
|
|
118
|
+
type: string;
|
|
119
|
+
jsDoc: string;
|
|
120
|
+
/** Set when `jsDoc` was inherited from an implemented interface or a sibling `*Spec`/`*Config`. */
|
|
121
|
+
jsDocInheritedFrom?: string;
|
|
122
|
+
/** Property initializer text, when short. See {@link MemberInfo.default}. */
|
|
123
|
+
default?: string;
|
|
124
|
+
decorators: string[];
|
|
125
|
+
}
|
|
126
|
+
/** Member-name filters shared by `getMembers` and the tools that call it. */
|
|
127
|
+
export interface MemberFilter {
|
|
128
|
+
/** Case-insensitive substring match on the member name. */
|
|
129
|
+
filter?: string;
|
|
130
|
+
/** Own members, inherited members, or both (default). */
|
|
131
|
+
include?: 'own' | 'inherited' | 'all';
|
|
132
|
+
memberKind?: 'property' | 'method' | 'accessor';
|
|
133
|
+
}
|
|
134
|
+
/** A member inherited from a type outside the index (React, Blueprint, ...), found via the type checker. */
|
|
135
|
+
export interface ExternalMember {
|
|
136
|
+
name: string;
|
|
137
|
+
kind: 'property' | 'method';
|
|
138
|
+
/** Declared type text when the declaration has an annotation; omitted otherwise. */
|
|
139
|
+
type?: string;
|
|
140
|
+
}
|
|
141
|
+
/** External members grouped by the interface or class that declares them. */
|
|
142
|
+
export interface ExternalMemberGroup {
|
|
143
|
+
declaredIn: string;
|
|
144
|
+
/** npm package the declaring type comes from, or null for a type within hoist-react. */
|
|
145
|
+
module: string | null;
|
|
146
|
+
members: ExternalMember[];
|
|
147
|
+
}
|
|
148
|
+
/** Outcome of {@link getMembers}. A non-class/interface target is reported, not silently empty. */
|
|
149
|
+
export type MembersResult = {
|
|
150
|
+
ok: true;
|
|
151
|
+
symbol: SymbolDetail;
|
|
152
|
+
/** Members after `MemberFilter` is applied. */
|
|
153
|
+
members: MemberInfo[];
|
|
154
|
+
/** Members before filtering. */
|
|
155
|
+
totalMembers: number;
|
|
156
|
+
externalMembers: ExternalMemberGroup[];
|
|
157
|
+
/** External members before filtering. */
|
|
158
|
+
totalExternal: number;
|
|
159
|
+
} | {
|
|
160
|
+
ok: false;
|
|
161
|
+
reason: 'not-found';
|
|
162
|
+
} | {
|
|
163
|
+
ok: false;
|
|
164
|
+
reason: 'no-members';
|
|
165
|
+
entries: SymbolEntry[];
|
|
166
|
+
};
|
|
167
|
+
/** True for `*Props` owners, whose members are searched only when the query names the owner. */
|
|
168
|
+
export declare function isPropsOwner(ownerName: string): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* True for a Promise prototype extension entry (`catchDefault`, `linkTo`), which is public API
|
|
171
|
+
* that needs no import - the one kind of exported symbol the tools show no import path for.
|
|
172
|
+
*/
|
|
173
|
+
export declare function isPromiseExtension(entry: Pick<SymbolEntry, 'name' | 'filePath'>): boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Begin TypeScript registry initialization in the background.
|
|
176
|
+
*
|
|
177
|
+
* Call this after server startup to warm the index asynchronously, so the
|
|
178
|
+
* first tool invocation doesn't pay the full init cost. On a cache hit this
|
|
179
|
+
* completes in ~100ms; on a cache miss it runs the full ts-morph build.
|
|
180
|
+
* Safe to call multiple times - subsequent calls are no-ops.
|
|
181
|
+
*/
|
|
182
|
+
export declare function beginInitialization(): void;
|
|
183
|
+
/**
|
|
184
|
+
* Ensure the symbol and member indexes are populated (from cache or via a
|
|
185
|
+
* fresh build). Pure search paths (`searchSymbols` in `symbol-search.ts`) only need
|
|
186
|
+
* this; detail-extraction paths additionally call {@link ensureProject} to
|
|
187
|
+
* construct the live ts-morph `Project` on demand.
|
|
188
|
+
*
|
|
189
|
+
* If {@link beginInitialization} was called, awaits the in-flight init.
|
|
190
|
+
* Otherwise initializes synchronously. Safe to call multiple times.
|
|
191
|
+
*/
|
|
192
|
+
export declare function ensureInitialized(): Promise<void>;
|
|
193
|
+
/** The symbol and member indexes, keyed by lowercase name. Ranked search lives in `symbol-search.ts`. */
|
|
194
|
+
export declare function getIndexes(): Promise<{
|
|
195
|
+
symbols: Map<string, SymbolEntry[]>;
|
|
196
|
+
members: Map<string, MemberIndexEntry[]>;
|
|
197
|
+
}>;
|
|
198
|
+
/** Options for resolving a symbol by name. */
|
|
199
|
+
export interface SymbolLookupOptions {
|
|
200
|
+
/** Source file path to disambiguate duplicate names. */
|
|
201
|
+
filePath?: string;
|
|
202
|
+
/** Symbol kind to disambiguate a `type` and `const` (or class) sharing a name. */
|
|
203
|
+
kind?: SymbolKind;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get detailed information about a specific symbol.
|
|
207
|
+
*
|
|
208
|
+
* Finds the symbol in the index by exact name match (case-sensitive).
|
|
209
|
+
* If filePath is provided, filters to that specific file. If multiple matches
|
|
210
|
+
* and no filePath, returns the first exported match.
|
|
211
|
+
*/
|
|
212
|
+
export declare function getSymbolDetail(name: string, options?: SymbolLookupOptions): Promise<SymbolDetail | null>;
|
|
213
|
+
/**
|
|
214
|
+
* Get every declaration of a name within the file the name resolves to, primary first. A
|
|
215
|
+
* `type` and a `const` (or class) that share a name in one file - `FieldType` - describe one
|
|
216
|
+
* API, so callers show them together rather than silently picking one. Passing `kind` narrows
|
|
217
|
+
* the result to that declaration.
|
|
218
|
+
*/
|
|
219
|
+
export declare function getSymbolDeclarations(name: string, options?: SymbolLookupOptions): Promise<SymbolDetail[]>;
|
|
220
|
+
/**
|
|
221
|
+
* Find companion symbols for cross-referencing in detail output.
|
|
222
|
+
*
|
|
223
|
+
* For a Props interface (e.g. `PanelProps`), returns the companion component
|
|
224
|
+
* consts (`Panel`, `panel`) from the same file. For a component const, returns
|
|
225
|
+
* the companion Props interface. Returns an empty array if no companions found.
|
|
226
|
+
*/
|
|
227
|
+
export declare function getCompanionSymbols(entry: SymbolEntry): Promise<SymbolEntry[]>;
|
|
228
|
+
/**
|
|
229
|
+
* Get members (properties, methods, accessors) of a class or interface.
|
|
230
|
+
*
|
|
231
|
+
* For classes, walks the inheritance chain and includes inherited members tagged
|
|
232
|
+
* with their declaring class. Filters out `_`-prefixed and `private` members to
|
|
233
|
+
* match the member index behavior. Members inherited from types outside the index
|
|
234
|
+
* (React, Blueprint) are listed separately via the type checker - see
|
|
235
|
+
* {@link extractExternalMembers}.
|
|
236
|
+
*
|
|
237
|
+
* A name that resolves to something other than a class or interface is reported
|
|
238
|
+
* as `no-members` with the declarations found, so callers can explain it.
|
|
239
|
+
*/
|
|
240
|
+
export declare function getMembers(name: string, options?: SymbolLookupOptions & MemberFilter): Promise<MembersResult>;
|
|
241
|
+
/**
|
|
242
|
+
* Find other exported symbols with the same name as the given entry, excluding
|
|
243
|
+
* dynamics stubs. Used to surface disambiguation hints when multiple real symbols
|
|
244
|
+
* share a name (e.g. `View` in both `cmp/viewmanager` and `data/cube`).
|
|
245
|
+
*/
|
|
246
|
+
export declare function findAlternateEntries(name: string, selectedFilePath: string): SymbolEntry[];
|
|
247
|
+
/**
|
|
248
|
+
* Find a symbol in the index by exact name.
|
|
249
|
+
* Prefers exported symbols when multiple matches exist and no filePath filter.
|
|
250
|
+
*/
|
|
251
|
+
export declare function findIndexEntry(name: string, filePath?: string, kind?: SymbolKind): SymbolEntry | null;
|