llmd 0.2.1 → 0.3.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.
package/README.md CHANGED
@@ -1,22 +1,8 @@
1
1
  # llmd
2
2
 
3
- **Serve Markdown as beautiful HTML. Instantly.**
3
+ **Serve Markdown as HTML, instantly.**
4
4
 
5
- A minimal CLI tool for viewing Markdown files in your browser with syntax highlighting, live reload, and a clean interface. Built for developers reviewing LLM-generated documentation.
6
-
7
- ## Installation
8
-
9
- ```bash
10
- npm install -g llmd
11
- ```
12
-
13
- Or run directly without installing:
14
-
15
- ```bash
16
- npx llmd
17
- ```
18
-
19
- Requires Node.js 22 or later.
5
+ A minimal CLI tool for viewing Markdown files in your browser with syntax highlighting, live reload, and optional event analytics. Built for developers reviewing LLM-generated documentation.
20
6
 
21
7
  ## Quick Start
22
8
 
@@ -38,9 +24,6 @@ That's it! The docs will open in your browser. Click through the sidebar to expl
38
24
  - **Syntax highlighting** - Powered by Shiki
39
25
  - **Live reload** - Watch mode reloads on file changes
40
26
  - **Copy buttons** - One-click code copying
41
- - **Dark/light themes** - With 9 font combinations
42
- - **Fast** - Built with Bun, instant startup
43
- - **Sidebar navigation** - Browse files with directory structure
44
27
  - **Table of contents** - Auto-generated from headings
45
28
  - **Usage Analytics** - Track which docs you view most (local-only, opt-in)
46
29
 
@@ -69,6 +52,11 @@ llmd ./docs --theme dark --watch
69
52
 
70
53
  # Open directly to analytics
71
54
  llmd analytics
55
+
56
+ # Manage analytics database
57
+ llmd db check # View database stats
58
+ llmd db cleanup --days 30 # Delete old events
59
+ llmd db clear # Clear all analytics data
72
60
  ```
73
61
 
74
62
  See [Usage](./docs/usage.md) for all options.
package/dist/client.js CHANGED
@@ -1 +1 @@
1
- var Q=()=>{let y=document.querySelectorAll(".dir-label");for(let m of Array.from(y)){let C=m,L=document.createElement("span");L.className="dir-chevron",L.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>',C.insertBefore(L,C.firstChild),C.style.cursor="pointer",C.addEventListener("click",(q)=>{q.preventDefault();let B=C.closest(".dir-item");if(B)B.classList.toggle("collapsed")})}},Y=()=>{let y=document.querySelector(".toc");if(!y)return;let m=y.querySelector("h3");if(!m)return;let C=document.createElement("span");C.className="toc-chevron",C.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>',m.style.cursor="pointer",m.insertBefore(C,m.firstChild),y.classList.add("collapsed"),m.addEventListener("click",()=>{y.classList.toggle("collapsed")})};if(typeof window<"u")window.addEventListener("DOMContentLoaded",()=>{Q(),Y()});var u=()=>{for(let y of Array.from(document.querySelectorAll("pre code"))){let m=y.parentElement;if(!m)continue;if(m.querySelector(".copy-button"))continue;let C=document.createElement("button");C.className="copy-button",C.textContent="Copy",C.setAttribute("aria-label","Copy code to clipboard"),C.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(y.textContent||""),C.textContent="Copied!",C.classList.add("copied"),setTimeout(()=>{C.textContent="Copy",C.classList.remove("copied")},2000)}catch(L){console.error("Failed to copy:",L),C.textContent="Failed",setTimeout(()=>{C.textContent="Copy"},2000)}}),m.appendChild(C)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",u);else u();var Z=(y)=>{let C=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/_ws`,L=null,q=null,B=()=>{L=new WebSocket(C),L.addEventListener("open",()=>{console.log("[llmd] Connected to file watcher"),L?.send(JSON.stringify({type:"watch",file:y}))}),L.addEventListener("message",(M)=>{try{let x=JSON.parse(M.data);if(x.type==="reload"&&x.file===y)console.log(`[llmd] File changed: ${y}, reloading...`),window.location.reload()}catch(x){console.error("[llmd] Failed to parse message:",x)}}),L.addEventListener("close",()=>{console.log("[llmd] Disconnected from file watcher"),q=window.setTimeout(()=>{console.log("[llmd] Reconnecting..."),B()},2000)}),L.addEventListener("error",(M)=>{console.error("[llmd] WebSocket error:",M),L?.close()})};B(),window.addEventListener("beforeunload",()=>{if(q)clearTimeout(q);L?.close()})};window.connectFileWatcher=Z;var _=()=>{let y=document.querySelector(".sidebar");if(!y)return;let m=document.createElement("div");m.className="sidebar-resize-handle",y.appendChild(m);let C=!1,L=0,q=0,B=(A)=>{C=!0,L=A.clientX,q=y.offsetWidth,document.body.style.cursor="ew-resize",document.body.style.userSelect="none",A.preventDefault()},M=(A)=>{if(!C)return;let K=A.clientX-L,O=q+K,k=Math.max(200,Math.min(600,O));y.style.width=`${k}px`,localStorage.setItem("llmd-sidebar-width",k.toString())},x=()=>{if(!C)return;C=!1,document.body.style.cursor="",document.body.style.userSelect=""};m.addEventListener("mousedown",B),document.addEventListener("mousemove",M),document.addEventListener("mouseup",x);let j=localStorage.getItem("llmd-sidebar-width");if(j){let A=Number.parseInt(j,10);if(A>=200&&A<=600)y.style.width=`${A}px`}};if(typeof window<"u")window.addEventListener("DOMContentLoaded",()=>{_()});var E=(y,m,C)=>{fetch("/api/events",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:y,path:m,resourceType:C})}).catch(()=>{})},G=(y)=>{E("open",y,"dir")},J=(y)=>{E("view",y,"file")};window.trackDirectoryOpen=G;window.trackFileView=J;console.log("[llmd] Client initialized");
1
+ var G=/\/$/,U=(y)=>{let q=y.querySelector(":scope > .dir-label");if(!q)return null;let C=Array.from(q.querySelectorAll("span"));if(C.length===0)return null;let B=C[C.length-1];if(!B.textContent)return null;return B.textContent.replace(G,"")},O=(y)=>{let q=[],C=y;while(C){let B=U(C);if(B)q.unshift(B);let M=C.parentElement;C=M?M.closest(".dir-item"):null}return q.length>0?q.join("/"):null},V=()=>{let y=[],q=document.querySelectorAll(".dir-item.collapsed");for(let C of Array.from(q)){let B=O(C);if(B)y.push(B)}localStorage.setItem("llmd-nav-collapsed",JSON.stringify(y))},_=()=>{try{let y=localStorage.getItem("llmd-nav-collapsed");if(!y)return;let q=JSON.parse(y),C=document.querySelectorAll(".dir-item");for(let B of Array.from(C)){let M=O(B);if(M&&q.includes(M))B.classList.add("collapsed")}}catch(y){console.error("[collapsible] Failed to restore state:",y)}},E=()=>{let y=document.querySelectorAll(".dir-label");for(let q of Array.from(y)){let C=q,B=document.createElement("span");B.className="dir-chevron",B.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>',C.insertBefore(B,C.firstChild),C.style.cursor="pointer",C.addEventListener("click",(M)=>{M.preventDefault();let k=C.closest(".dir-item");if(k)k.classList.toggle("collapsed"),V()})}_()},X=()=>{let y=document.querySelector(".toc");if(!y)return;let q=y.querySelector("h3");if(!q)return;let C=document.createElement("span");C.className="toc-chevron",C.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>',q.style.cursor="pointer",q.insertBefore(C,q.firstChild),y.classList.add("collapsed"),q.addEventListener("click",()=>{y.classList.toggle("collapsed")})};if(typeof window<"u")window.addEventListener("DOMContentLoaded",()=>{E(),X()});var Q=()=>{for(let y of Array.from(document.querySelectorAll("pre code"))){let q=y.parentElement;if(!q)continue;if(q.querySelector(".copy-button"))continue;let C=document.createElement("button");C.className="copy-button",C.textContent="Copy",C.setAttribute("aria-label","Copy code to clipboard"),C.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(y.textContent||""),C.textContent="Copied!",C.classList.add("copied"),setTimeout(()=>{C.textContent="Copy",C.classList.remove("copied")},2000)}catch(B){console.error("Failed to copy:",B),C.textContent="Failed",setTimeout(()=>{C.textContent="Copy"},2000)}}),q.appendChild(C)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",Q);else Q();var u=(y)=>{let C=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/_ws`,B=null,M=null,k=()=>{B=new WebSocket(C),B.addEventListener("open",()=>{console.log("[llmd] Connected to file watcher"),B?.send(JSON.stringify({type:"watch",file:y}))}),B.addEventListener("message",(J)=>{try{let A=JSON.parse(J.data);if(A.type==="reload"&&A.file===y)console.log(`[llmd] File changed: ${y}, reloading...`),window.location.reload()}catch(A){console.error("[llmd] Failed to parse message:",A)}}),B.addEventListener("close",()=>{console.log("[llmd] Disconnected from file watcher"),M=window.setTimeout(()=>{console.log("[llmd] Reconnecting..."),k()},2000)}),B.addEventListener("error",(J)=>{console.error("[llmd] WebSocket error:",J),B?.close()})};k(),window.addEventListener("beforeunload",()=>{if(M)clearTimeout(M);B?.close()})};window.connectFileWatcher=u;var P=()=>{let y=document.querySelector(".sidebar");if(!y)return;let q=document.createElement("div");q.className="sidebar-resize-handle",y.appendChild(q);let C=!1,B=0,M=0,k=(j)=>{C=!0,B=j.clientX,M=y.offsetWidth,document.body.style.cursor="ew-resize",document.body.style.userSelect="none",j.preventDefault()},J=(j)=>{if(!C)return;let f=j.clientX-B,x=M+f,L=Math.max(200,Math.min(600,x));y.style.width=`${L}px`,localStorage.setItem("llmd-sidebar-width",L.toString())},A=()=>{if(!C)return;C=!1,document.body.style.cursor="",document.body.style.userSelect=""};q.addEventListener("mousedown",k),document.addEventListener("mousemove",J),document.addEventListener("mouseup",A);let K=localStorage.getItem("llmd-sidebar-width");if(K){let j=Number.parseInt(K,10);if(j>=200&&j<=600)y.style.width=`${j}px`}};if(typeof window<"u")window.addEventListener("DOMContentLoaded",()=>{P()});var Y=(y,q,C)=>{fetch("/api/events",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:y,path:q,resourceType:C})}).catch(()=>{})},Z=(y)=>{Y("open",y,"dir")},$=(y)=>{Y("view",y,"file")};window.trackDirectoryOpen=Z;window.trackFileView=$;console.log("[llmd] Client initialized");