feat: add protocol explorer with catalogs and live playground

This commit is contained in:
2026-10-19 18:21:30 +09:00
parent b82c1d0a70
commit 75a36f2298
38 changed files with 1836 additions and 83 deletions
+6 -2
View File
@@ -23,7 +23,8 @@ export const draftPaths = [
'/draft/typescript-api-model.md',
'/draft/unresolved-issues.md',
];
export const treePaths = ['/', '/book', ...documentPaths];
export const catalogPaths = ['/sources', '/packages'];
export const treePaths = ['/', '/book', ...documentPaths, ...catalogPaths, '/playground'];
export const treeNodeCount = treePaths.length;
export const chapterSections: Record<string, string[]> = {
'/1-concept.md': ['/1.1-interaction-abstraction.md', '/1.2-existing-abstractions.md', '/1.3-design-principles.md', '/1.4-concepts-and-scope.md'],
@@ -31,9 +32,12 @@ export const chapterSections: Record<string, string[]> = {
'/4-client.md': ['/4.1-ai-tools.md', '/4.2-text-view.md'],
'/5-transports.md': ['/5.1-wip-over-http.md'],
};
export const treeParents: Record<string, string> = Object.fromEntries(treePaths.filter((path) => path !== '/').map((path) => [path, path === '/book' ? '/' : '/book']));
export const treeParents: Record<string, string> = Object.fromEntries(treePaths.filter((path) => path !== '/').map((path) => [path, path === '/book' || catalogPaths.includes(path) || path === '/playground' ? '/' : '/book']));
for (const [chapter, sections] of Object.entries(chapterSections)) {
for (const section of sections) treeParents[section] = chapter;
}
export const rootChildCount = treePaths.filter((path) => treeParents[path] === '/').length;
export const routeURL = (path: string, base: string) => path === '/' ? new URL('./', base).href
: path === '/book' || catalogPaths.includes(path) || path === '/playground' ? new URL(`${path.slice(1)}/`, base).href : bookURL(path, base);
export const bookURL = (path: string, base: string) => new URL(`book/${path.slice(1, -3).split('/').map(encodeURIComponent).join('/')}/`, base).href;