markshelf 0.1.4 → 0.1.5
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/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/app-path-routes-manifest.json +1 -0
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/routes-manifest.json +6 -0
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/api/diff/route.js +3 -2
- package/.next/standalone/.next/server/app/api/diff/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/file/route.js +3 -2
- package/.next/standalone/.next/server/app/api/file/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/graph/route.js +3 -2
- package/.next/standalone/.next/server/app/api/graph/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/history/route.js +3 -2
- package/.next/standalone/.next/server/app/api/history/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/search/route.js +3 -2
- package/.next/standalone/.next/server/app/api/search/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/timeline/route.js +3 -2
- package/.next/standalone/.next/server/app/api/timeline/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/tree/route.js +3 -2
- package/.next/standalone/.next/server/app/api/tree/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/watch/route/app-paths-manifest.json +3 -0
- package/.next/standalone/.next/server/app/api/watch/route/build-manifest.json +9 -0
- package/.next/standalone/.next/server/app/api/watch/route/server-reference-manifest.json +4 -0
- package/.next/standalone/.next/server/app/api/watch/route.js +6 -0
- package/.next/standalone/.next/server/app/api/watch/route.js.map +5 -0
- package/.next/standalone/.next/server/app/api/watch/route.js.nft.json +1 -0
- package/.next/standalone/.next/server/app/api/watch/route_client-reference-manifest.js +3 -0
- package/.next/standalone/.next/server/app/favicon.ico/route.js +2 -1
- package/.next/standalone/.next/server/app/favicon.ico/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app-paths-manifest.json +1 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0-_k816._.js +3 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__04otwp7._.js → [root-of-the-server]__01e7zo7._.js} +2 -2
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0zoyna0._.js → [root-of-the-server]__053gm34._.js} +2 -2
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0_gt~a4._.js → [root-of-the-server]__0d.-s5p._.js} +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0i.wyss._.js +6 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0qnrcw7._.js → [root-of-the-server]__0nr71d2._.js} +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0op9af~._.js +3 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__01cq2u6._.js → [root-of-the-server]__0rwylex._.js} +2 -2
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0yvq0sd._.js → [root-of-the-server]__13vatcq._.js} +2 -2
- package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_watch_route_actions_0go0kk3.js +3 -0
- package/.next/standalone/.next/server/chunks/node_modules_next_04~_e52._.js +13 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__05ar4zx._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__09qrkq5._.js +5 -5
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0serya4._.js → [root-of-the-server]__11e9~iq._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_10cz306._.js → node_modules_02chd8n._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_0eva9q1._.js → node_modules_08z1b9i._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_05e-8m3._.js → node_modules_0f-9xhq._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_06r3o30._.js → node_modules_0u-.0s2._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_09.cbx4._.js → node_modules_0vqo_80._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_11wp0ye._.js → node_modules_0xmn29o._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_0ic-wja._.js → node_modules_0~k33bz._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_0w2-q.z._.js → node_modules_10a06qi._.js} +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/static/chunks/0b42--.p9znhl.css +1 -0
- package/.next/standalone/.next/static/chunks/0wy.nfhujao0b.js +11 -0
- package/.next/standalone/docs//344/273/225/346/247/230/README.md +9 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC1-CLI/README.md +3 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC1-CLI/SPEC1.1-bin-cli.md +14 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC2-/343/202/260/343/203/251/343/203/225/346/217/217/347/224/273/README.md +3 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC2-/343/202/260/343/203/251/343/203/225/346/217/217/347/224/273/SPEC2.1-graph-api.md +16 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC2-/343/202/260/343/203/251/343/203/225/346/217/217/347/224/273/SPEC2.2-breadthfirst-layout.md +10 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC3-UI/343/202/263/343/203/263/343/203/235/343/203/274/343/203/215/343/203/263/343/203/210/README.md +3 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC3-UI/343/202/263/343/203/263/343/203/235/343/203/274/343/203/215/343/203/263/343/203/210/SPEC3.1-PreviewPopup.md +10 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC3-UI/343/202/263/343/203/263/343/203/235/343/203/274/343/203/215/343/203/263/343/203/210/SPEC3.2-TreeView.md +10 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206/Cytoscape.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206/Markdown.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206/Nextjs.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206/breadthfirst.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206/npx.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206/standalone.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206//343/203/204/343/203/252/343/203/274/343/203/223/343/203/245/343/203/274.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206//343/203/227/343/203/254/343/203/223/343/203/245/343/203/274/343/203/235/343/203/203/343/203/227/343/202/242/343/203/203/343/203/227.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206//343/203/252/343/203/263/343/202/257/343/202/260/343/203/251/343/203/225.md +5 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/README.md +9 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ1-/343/203/223/343/203/245/343/203/274/343/202/242/350/265/267/345/213/225/README.md +3 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ1-/343/203/223/343/203/245/343/203/274/343/202/242/350/265/267/345/213/225/REQ1.1-npx/350/265/267/345/213/225.md +13 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ2-/343/203/252/343/203/263/343/202/257/343/202/260/343/203/251/343/203/225/README.md +3 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ2-/343/203/252/343/203/263/343/202/257/343/202/260/343/203/251/343/203/225/REQ2.1-/343/202/260/343/203/251/343/203/225/346/217/217/347/224/273.md +11 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ2-/343/203/252/343/203/263/343/202/257/343/202/260/343/203/251/343/203/225/REQ2.2-/351/232/216/345/261/244/345/210/207/346/233/277.md +10 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ2-/343/203/252/343/203/263/343/202/257/343/202/260/343/203/251/343/203/225/REQ2.3-/343/203/225/343/202/251/343/203/253/343/203/200/351/231/244/345/244/226.md +10 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ3-/343/203/227/343/203/254/343/203/223/343/203/245/343/203/274/343/201/250/343/203/204/343/203/252/343/203/274/README.md +3 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ3-/343/203/227/343/203/254/343/203/223/343/203/245/343/203/274/343/201/250/343/203/204/343/203/252/343/203/274/REQ3.1-/343/203/227/343/203/254/343/203/223/343/203/245/343/203/274/343/203/235/343/203/203/343/203/227/343/202/242/343/203/203/343/203/227.md +15 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ3-/343/203/227/343/203/254/343/203/223/343/203/245/343/203/274/343/201/250/343/203/204/343/203/252/343/203/274/REQ3.2-/343/203/204/343/203/252/343/203/274/343/203/223/343/203/245/343/203/274.md +14 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ4-/343/203/212/343/203/223/343/202/262/343/203/274/343/202/267/343/203/247/343/203/263/README.md +3 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ4-/343/203/212/343/203/223/343/202/262/343/203/274/343/202/267/343/203/247/343/203/263/REQ4.1-/346/210/273/343/202/213/351/200/262/343/202/200.md +10 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R1-/343/203/211/343/202/255/343/203/245/343/203/241/343/203/263/343/203/210/351/226/262/350/246/247/346/200/247/R1.1-/347/213/254/347/253/213/343/203/223/343/203/245/343/203/274/343/202/242.md +11 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R1-/343/203/211/343/202/255/343/203/245/343/203/241/343/203/263/343/203/210/351/226/262/350/246/247/346/200/247/R1.2-/345/244/247/347/224/273/351/235/242/350/241/250/347/244/272.md +11 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R1-/343/203/211/343/202/255/343/203/245/343/203/241/343/203/263/343/203/210/351/226/262/350/246/247/346/200/247/R1.3-/343/203/212/343/203/223/343/202/262/343/203/274/343/202/267/343/203/247/343/203/263/345/261/245/346/255/264.md +9 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R1-/343/203/211/343/202/255/343/203/245/343/203/241/343/203/263/343/203/210/351/226/262/350/246/247/346/200/247/README.md +7 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R2-/343/203/211/343/202/255/343/203/245/343/203/241/343/203/263/343/203/210/351/226/242/344/277/202/343/201/256/345/217/257/350/246/226/345/214/226/R2.1-/344/276/235/345/255/230/351/226/242/344/277/202/343/201/256/346/212/212/346/217/241.md +9 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R2-/343/203/211/343/202/255/343/203/245/343/203/241/343/203/263/343/203/210/351/226/242/344/277/202/343/201/256/345/217/257/350/246/226/345/214/226/R2.2-/345/217/202/347/205/247/345/205/203/343/201/256/346/212/212/346/217/241.md +9 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R2-/343/203/211/343/202/255/343/203/245/343/203/241/343/203/263/343/203/210/351/226/242/344/277/202/343/201/256/345/217/257/350/246/226/345/214/226/README.md +8 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R3-/343/202/252/343/203/263/343/203/234/343/203/274/343/203/207/343/202/243/343/203/263/343/202/260/346/224/257/346/217/264/R3.1-/347/224/250/350/252/236/343/201/256/345/215/263/346/231/202/347/242/272/350/252/215.md +11 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R3-/343/202/252/343/203/263/343/203/234/343/203/274/343/203/207/343/202/243/343/203/263/343/202/260/346/224/257/346/217/264/README.md +7 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/README.md +9 -0
- package/.next/standalone/package.json +1 -1
- package/.next/standalone/src/app/api/watch/route.ts +89 -0
- package/.next/standalone/src/app/page.tsx +41 -8
- package/.next/standalone/src/components/DetailPanel.tsx +38 -6
- package/.next/standalone/src/components/HistoryPanel.tsx +3 -1
- package/.next/standalone/src/components/LinkGraph.tsx +179 -9
- package/.next/standalone/src/components/Markdown.tsx +60 -5
- package/.next/standalone/src/components/PreviewPopup.tsx +4 -2
- package/.next/standalone/src/components/TimelinePanel.tsx +3 -1
- package/.next/standalone/src/components/TreeView.tsx +36 -9
- package/.next/standalone/src/lib/links.ts +98 -25
- package/.next/standalone/src/lib/useRefreshTick.ts +43 -0
- package/.next/standalone/tsconfig.tsbuildinfo +1 -1
- package/.next/static/chunks/0b42--.p9znhl.css +1 -0
- package/.next/static/chunks/0wy.nfhujao0b.js +11 -0
- package/package.json +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0j8-xkl._.js +0 -13
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0owpp0l._.js +0 -3
- package/.next/standalone/.next/static/chunks/04x.fjh8sw0s1.css +0 -1
- package/.next/standalone/.next/static/chunks/0z_707.y37o2..js +0 -11
- package/.next/standalone/AGENTS.md +0 -5
- package/.next/standalone/CLAUDE.md +0 -1
- package/.next/standalone/markshelf-0.1.0.tgz +0 -0
- package/.next/standalone/markshelf-0.1.2.tgz +0 -0
- package/.next/static/chunks/04x.fjh8sw0s1.css +0 -1
- package/.next/static/chunks/0z_707.y37o2..js +0 -11
- /package/.next/standalone/.next/static/{JkyieJgBB2eU8MtnlBGvG → pOQs5i4GMjDH6W5XDSjRs}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{JkyieJgBB2eU8MtnlBGvG → pOQs5i4GMjDH6W5XDSjRs}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{JkyieJgBB2eU8MtnlBGvG → pOQs5i4GMjDH6W5XDSjRs}/_ssgManifest.js +0 -0
- /package/.next/static/{JkyieJgBB2eU8MtnlBGvG → pOQs5i4GMjDH6W5XDSjRs}/_buildManifest.js +0 -0
- /package/.next/static/{JkyieJgBB2eU8MtnlBGvG → pOQs5i4GMjDH6W5XDSjRs}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{JkyieJgBB2eU8MtnlBGvG → pOQs5i4GMjDH6W5XDSjRs}/_ssgManifest.js +0 -0
|
@@ -15,6 +15,64 @@ export interface LinkGraph {
|
|
|
15
15
|
edges: GraphEdge[];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
// Matches markdown link `[label](url)` excluding image syntax `![...]`.
|
|
19
|
+
// The leading capture group absorbs a non-"!" char (or string start) to avoid
|
|
20
|
+
// matching image links.
|
|
21
|
+
const LINK_RE = /(^|[^!])\[([^\]]*)\]\(([^)]+)\)/g;
|
|
22
|
+
// Fenced code blocks (``` or ~~~) — stripped before scanning
|
|
23
|
+
const FENCE_RE = /(^|\n)(```|~~~)[^\n]*\n[\s\S]*?\n\2/g;
|
|
24
|
+
// Inline code `...`
|
|
25
|
+
const INLINE_CODE_RE = /`[^`\n]*`/g;
|
|
26
|
+
|
|
27
|
+
function stripCode(content: string): string {
|
|
28
|
+
return content.replace(FENCE_RE, "").replace(INLINE_CODE_RE, "");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function resolveLink(
|
|
32
|
+
currentPath: string,
|
|
33
|
+
rawUrl: string,
|
|
34
|
+
fileSet: Set<string>,
|
|
35
|
+
): string | null {
|
|
36
|
+
const cleanUrl = rawUrl.split("#")[0].split("?")[0].trim();
|
|
37
|
+
if (!cleanUrl) return null;
|
|
38
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(cleanUrl)) return null;
|
|
39
|
+
if (cleanUrl.startsWith("//")) return null;
|
|
40
|
+
|
|
41
|
+
let decoded: string;
|
|
42
|
+
try {
|
|
43
|
+
decoded = decodeURI(cleanUrl);
|
|
44
|
+
} catch {
|
|
45
|
+
decoded = cleanUrl;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const currentDir = currentPath.includes("/")
|
|
49
|
+
? currentPath.slice(0, currentPath.lastIndexOf("/"))
|
|
50
|
+
: "";
|
|
51
|
+
const joined = decoded.startsWith("/")
|
|
52
|
+
? decoded.slice(1)
|
|
53
|
+
: currentDir
|
|
54
|
+
? currentDir + "/" + decoded
|
|
55
|
+
: decoded;
|
|
56
|
+
|
|
57
|
+
const parts = joined.split("/");
|
|
58
|
+
const normalized: string[] = [];
|
|
59
|
+
for (const p of parts) {
|
|
60
|
+
if (p === "" || p === ".") continue;
|
|
61
|
+
if (p === "..") {
|
|
62
|
+
normalized.pop();
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
normalized.push(p);
|
|
66
|
+
}
|
|
67
|
+
const resolved = normalized.join("/");
|
|
68
|
+
if (!resolved) return null;
|
|
69
|
+
|
|
70
|
+
if (fileSet.has(resolved)) return resolved;
|
|
71
|
+
if (fileSet.has(resolved + "/README.md")) return resolved + "/README.md";
|
|
72
|
+
if (!/\.md$/i.test(resolved) && fileSet.has(resolved + ".md")) return resolved + ".md";
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
18
76
|
export function buildLinkGraph(
|
|
19
77
|
files: FileRef[],
|
|
20
78
|
readFile: (path: string) => string | null,
|
|
@@ -23,43 +81,59 @@ export function buildLinkGraph(
|
|
|
23
81
|
.filter((f) => f.displayName.length > 2)
|
|
24
82
|
.sort((a, b) => b.displayName.length - a.displayName.length);
|
|
25
83
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// Build regex from all displayNames
|
|
29
|
-
const escaped = filtered.map((f) =>
|
|
30
|
-
f.displayName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
31
|
-
);
|
|
32
|
-
const regex = new RegExp(`(${escaped.join("|")})`, "g");
|
|
33
|
-
|
|
34
|
-
// Map displayName → path for lookup
|
|
84
|
+
const fileSet = new Set(files.map((f) => f.path));
|
|
35
85
|
const nameToPath = new Map<string, string>();
|
|
36
86
|
for (const f of filtered) {
|
|
37
87
|
nameToPath.set(f.displayName, f.path);
|
|
38
88
|
}
|
|
39
89
|
|
|
90
|
+
const displayNameRegex =
|
|
91
|
+
filtered.length === 0
|
|
92
|
+
? null
|
|
93
|
+
: new RegExp(
|
|
94
|
+
`(${filtered
|
|
95
|
+
.map((f) => f.displayName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
|
|
96
|
+
.join("|")})`,
|
|
97
|
+
"g",
|
|
98
|
+
);
|
|
99
|
+
|
|
40
100
|
const edgeSet = new Set<string>();
|
|
41
101
|
const referencedPaths = new Set<string>();
|
|
42
102
|
|
|
103
|
+
const addEdge = (source: string, target: string) => {
|
|
104
|
+
if (target === source) return;
|
|
105
|
+
const key = `${source}\0${target}`;
|
|
106
|
+
if (edgeSet.has(key)) return;
|
|
107
|
+
edgeSet.add(key);
|
|
108
|
+
referencedPaths.add(source);
|
|
109
|
+
referencedPaths.add(target);
|
|
110
|
+
};
|
|
111
|
+
|
|
43
112
|
for (const file of files) {
|
|
44
|
-
const
|
|
45
|
-
if (!
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
113
|
+
const raw = readFile(file.path);
|
|
114
|
+
if (!raw) continue;
|
|
115
|
+
let content = stripCode(raw);
|
|
116
|
+
|
|
117
|
+
// 1) Explicit markdown links: resolve URL → add edge, then strip (url) portion
|
|
118
|
+
// so URL path segments don't create spurious displayName matches.
|
|
119
|
+
content = content.replace(LINK_RE, (_m, lead, label, url) => {
|
|
120
|
+
const target = resolveLink(file.path, url, fileSet);
|
|
121
|
+
if (target) addEdge(file.path, target);
|
|
122
|
+
return `${lead}[${label}]`;
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// 2) DisplayName auto-matching on the stripped content
|
|
126
|
+
if (displayNameRegex) {
|
|
127
|
+
displayNameRegex.lastIndex = 0;
|
|
128
|
+
let match: RegExpExecArray | null;
|
|
129
|
+
while ((match = displayNameRegex.exec(content)) !== null) {
|
|
130
|
+
const targetPath = nameToPath.get(match[0]);
|
|
131
|
+
if (!targetPath) continue;
|
|
132
|
+
addEdge(file.path, targetPath);
|
|
58
133
|
}
|
|
59
134
|
}
|
|
60
135
|
}
|
|
61
136
|
|
|
62
|
-
// Only include nodes that have at least one edge
|
|
63
137
|
const nodes: GraphNode[] = files
|
|
64
138
|
.filter((f) => referencedPaths.has(f.path))
|
|
65
139
|
.map((f) => ({ id: f.path, label: f.displayName }));
|
|
@@ -81,7 +155,6 @@ function computeSignature(
|
|
|
81
155
|
files: FileRef[],
|
|
82
156
|
statFile: (path: string) => number | null,
|
|
83
157
|
): string {
|
|
84
|
-
// Sort paths for stability, then join "path\0mtime"
|
|
85
158
|
const sorted = [...files].sort((a, b) => a.path.localeCompare(b.path));
|
|
86
159
|
const parts: string[] = [];
|
|
87
160
|
for (const f of sorted) {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
|
|
5
|
+
type Listener = (tick: number) => void;
|
|
6
|
+
|
|
7
|
+
let currentTick = 0;
|
|
8
|
+
const listeners = new Set<Listener>();
|
|
9
|
+
let eventSource: EventSource | null = null;
|
|
10
|
+
let debounceTimer: ReturnType<typeof setTimeout> | null = null;
|
|
11
|
+
|
|
12
|
+
function bump() {
|
|
13
|
+
currentTick++;
|
|
14
|
+
for (const l of listeners) l(currentTick);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function ensureConnected() {
|
|
18
|
+
if (eventSource || typeof window === "undefined") return;
|
|
19
|
+
try {
|
|
20
|
+
eventSource = new EventSource("/api/watch");
|
|
21
|
+
} catch {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
eventSource.addEventListener("change", () => {
|
|
25
|
+
if (debounceTimer) clearTimeout(debounceTimer);
|
|
26
|
+
debounceTimer = setTimeout(bump, 150);
|
|
27
|
+
});
|
|
28
|
+
// If the connection errors out, EventSource will reconnect automatically.
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Returns a tick that increments when any file under the docs root changes. */
|
|
32
|
+
export function useRefreshTick(): number {
|
|
33
|
+
const [value, setValue] = useState(currentTick);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
ensureConnected();
|
|
36
|
+
const listener: Listener = (t) => setValue(t);
|
|
37
|
+
listeners.add(listener);
|
|
38
|
+
return () => {
|
|
39
|
+
listeners.delete(listener);
|
|
40
|
+
};
|
|
41
|
+
}, []);
|
|
42
|
+
return value;
|
|
43
|
+
}
|