MCPcopy Create free account
hub / github.com/adobe/react-spectrum / resolvePageRef

Function resolvePageRef

packages/dev/mcp/shared/src/page-manager.ts:63–103  ·  view source on GitHub ↗
(library: Library, pageName: string)

Source from the content-addressed store, hash-verified

61}
62
63export async function resolvePageRef(library: Library, pageName: string): Promise<PageInfo> {
64 await buildPageIndex(library);
65
66 if (pageCache.has(pageName)) {
67 return pageCache.get(pageName)!;
68 }
69
70 const baseUrl = getLibraryBaseUrl(library);
71
72 if (pageName.includes('/')) {
73 const normalized = pageName.replace(/\\/g, '/');
74 const prefix = normalized.split('/', 1)[0];
75 if (prefix !== library) {
76 throw new Error(`Page '${pageName}' is not in the '${library}' library.`);
77 }
78 const maybe = pageCache.get(normalized);
79 if (maybe) {
80 return maybe;
81 }
82 const filePath = `${baseUrl}/${normalized}.md`;
83 const stub: PageInfo = {
84 key: normalized,
85 name: path.basename(normalized),
86 description: undefined,
87 filePath,
88 sections: []
89 };
90 pageCache.set(stub.key, stub);
91 return stub;
92 }
93
94 const key = `${library}/${pageName}`;
95 const maybe = pageCache.get(key);
96 if (maybe) {
97 return maybe;
98 }
99 const filePath = `${baseUrl}/${key}.md`;
100 const stub: PageInfo = {key, name: pageName, description: undefined, filePath, sections: []};
101 pageCache.set(stub.key, stub);
102 return stub;
103}

Callers 1

registerLibraryDocsToolsFunction · 0.85

Calls 4

buildPageIndexFunction · 0.85
getLibraryBaseUrlFunction · 0.85
hasMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected