@react-aria/mcp 1.0.0 → 1.1.0

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.
@@ -1,13 +1,10 @@
1
- import { DEFAULT_CDN_BASE, fetchText } from './utils.js';
2
1
  import { extractNameAndDescription, parseSectionsFromMarkdown } from './parser.js';
2
+ import { fetchText, getLibraryBaseUrl } from './utils.js';
3
3
  import path from 'path';
4
4
  // Cache of parsed pages
5
5
  const pageCache = new Map();
6
6
  // Whether we've loaded the page index for a library yet.
7
7
  const pageIndexLoaded = new Set();
8
- function libBaseUrl(library) {
9
- return `${DEFAULT_CDN_BASE}/${library}`;
10
- }
11
8
  // Build an index of pages for the given library from the CDN's llms.txt.
12
9
  export async function buildPageIndex(library) {
13
10
  if (pageIndexLoaded.has(library)) {
@@ -15,7 +12,8 @@ export async function buildPageIndex(library) {
15
12
  }
16
13
  const pages = [];
17
14
  // Read llms.txt to enumerate available pages without downloading them all.
18
- const llmsUrl = `${libBaseUrl(library)}/llms.txt`;
15
+ const baseUrl = getLibraryBaseUrl(library);
16
+ const llmsUrl = `${baseUrl}/llms.txt`;
19
17
  const txt = await fetchText(llmsUrl);
20
18
  const re = /^\s*-\s*\[([^\]]+)\]\(([^)]+)\)(?:\s*:\s*(.*))?\s*$/;
21
19
  for (const line of txt.split(/\r?\n/)) {
@@ -29,9 +27,10 @@ export async function buildPageIndex(library) {
29
27
  if (!href || !/\.md$/i.test(href)) {
30
28
  continue;
31
29
  }
32
- const key = href.replace(/\.md$/i, '').replace(/\\/g, '/');
33
- const name = display || path.basename(key);
34
- const filePath = `${DEFAULT_CDN_BASE}/${key}.md`;
30
+ const hrefWithoutExt = href.replace(/\.md$/i, '').replace(/\\/g, '/');
31
+ const key = `${library}/${hrefWithoutExt}`;
32
+ const name = display || path.basename(hrefWithoutExt);
33
+ const filePath = `${baseUrl}/${hrefWithoutExt}.md`;
35
34
  const info = { key, name, description, filePath, sections: [] };
36
35
  pages.push(info);
37
36
  pageCache.set(info.key, info);
@@ -56,6 +55,7 @@ export async function resolvePageRef(library, pageName) {
56
55
  if (pageCache.has(pageName)) {
57
56
  return pageCache.get(pageName);
58
57
  }
58
+ const baseUrl = getLibraryBaseUrl(library);
59
59
  if (pageName.includes('/')) {
60
60
  const normalized = pageName.replace(/\\/g, '/');
61
61
  const prefix = normalized.split('/', 1)[0];
@@ -66,7 +66,7 @@ export async function resolvePageRef(library, pageName) {
66
66
  if (maybe) {
67
67
  return maybe;
68
68
  }
69
- const filePath = `${DEFAULT_CDN_BASE}/${normalized}.md`;
69
+ const filePath = `${baseUrl}/${normalized}.md`;
70
70
  const stub = { key: normalized, name: path.basename(normalized), description: undefined, filePath, sections: [] };
71
71
  pageCache.set(stub.key, stub);
72
72
  return stub;
@@ -76,7 +76,7 @@ export async function resolvePageRef(library, pageName) {
76
76
  if (maybe) {
77
77
  return maybe;
78
78
  }
79
- const filePath = `${DEFAULT_CDN_BASE}/${key}.md`;
79
+ const filePath = `${baseUrl}/${key}.md`;
80
80
  const stub = { key, name: pageName, description: undefined, filePath, sections: [] };
81
81
  pageCache.set(stub.key, stub);
82
82
  return stub;
@@ -12,8 +12,15 @@ export function errorToString(err) {
12
12
  return String(err);
13
13
  }
14
14
  }
15
- // CDN base for docs. Can be overridden via env variable.
16
- export const DEFAULT_CDN_BASE = process.env.DOCS_CDN_BASE ?? 'https://react-spectrum.adobe.com/beta';
15
+ // Default base URLs for each library
16
+ const DEFAULT_S2_BASE = 'https://react-spectrum.adobe.com';
17
+ const DEFAULT_REACT_ARIA_BASE = 'https://react-aria.adobe.com';
18
+ export function getLibraryBaseUrl(library) {
19
+ if (process.env.DOCS_CDN_BASE) {
20
+ return process.env.DOCS_CDN_BASE;
21
+ }
22
+ return library === 's2' ? DEFAULT_S2_BASE : DEFAULT_REACT_ARIA_BASE;
23
+ }
17
24
  export async function fetchText(url, timeoutMs = 15000) {
18
25
  const ctrl = new AbortController();
19
26
  const id = setTimeout(() => ctrl.abort(), timeoutMs).unref?.();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/mcp",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "MCP server for React Aria documentation",
5
5
  "type": "module",
6
6
  "bin": "dist/react-aria/src/index.js",
@@ -38,5 +38,5 @@
38
38
  "module": "dist/module.js",
39
39
  "types": "dist/types.d.ts",
40
40
  "source": "src/index.ts",
41
- "gitHead": "4d838da5bfe36abb35aed166995a9ef63825370f"
41
+ "gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
42
42
  }