docstra 1.9.7 → 1.9.8
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/dist/client/index.js +1 -1
- package/dist/client/index.mjs +1 -1
- package/dist/server/docstra-loader.js +5 -5
- package/dist/server/docstra-loader.mjs +5 -5
- package/dist/server/index.d.mts +7 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +11 -11
- package/dist/server/index.mjs +5 -5
- package/package.json +3 -2
package/dist/client/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var Ae=Object.create;var Y=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty;var Ke=(e,r)=>{for(var t in r)Y(e,t,{get:r[t],enumerable:!0})},ie=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Ue(r))!qe.call(e,a)&&a!==t&&Y(e,a,{get:()=>r[a],enumerable:!(o=Fe(r,a))||o.enumerable});return e};var T=(e,r,t)=>(t=e!=null?Ae(He(e)):{},ie(r||!e||!e.__esModule?Y(t,"default",{value:e,enumerable:!0}):t,e)),Ve=e=>ie(Y({},"__esModule",{value:!0}),e);var Je={};Ke(Je,{DocstraBody:()=>Xe,DocstraCodeBlock:()=>Ze,DocstraHeader:()=>Qe,DocstraPage:()=>We,DocstraProvider:()=>Ye,useDocstra:()=>c});module.exports=Ve(Je);var z=require("react"),ge=require("react-toast-msg");var me=require("lucide-react");var le=require("tailwind-merge"),ce=T(require("clsx"));function x(...e){return(0,le.twMerge)((0,ce.default)(e))}var I=require("react"),de=T(require("fuse.js")),pe=T(require("next/link")),ue=require("next/navigation"),h=require("react/jsx-runtime");function fe(){let{openSearchBox:e,setOpenSearchBox:r,docs:t}=c(),[o,a]=(0,I.useState)(""),[n,i]=(0,I.useState)([]),f=(0,ue.useRouter)();(0,I.useEffect)(()=>{let s=g=>{g.ctrlKey&&g.key==="k"&&(g.preventDefault(),r(!0))};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[]);let m=(0,I.useMemo)(()=>!t||t.length===0?null:new de.default(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);(0,I.useEffect)(()=>{if(o&&m){let s=m.search(o);i(s.map(g=>g.item))}else o||i([])},[o,m]);let w=s=>{if(s.preventDefault(),o){let g=n[0];g&&(f.push(`/docs/${g.slug}`),a(""),r(!1))}};return(0,I.useEffect)(()=>{let s=g=>{g.key==="Escape"&&(r(!1),a(""))};return e&&window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[e]),(0,h.jsx)("div",{onClick:()=>{r(!1),a("")},className:x("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:(0,h.jsxs)("div",{onClick:s=>s.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[(0,h.jsx)("form",{onSubmit:w,className:x("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",o&&"rounded-b-none border-b-0"),children:e&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(me.SearchIcon,{className:"size-5.5 mx-3 shrink-0"}),(0,h.jsx)("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:o,onChange:s=>a(s.target.value),name:"searchQuery",required:!0}),(0,h.jsx)("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),(0,h.jsxs)("div",{className:x("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",o&&"rounded-b-md border border-slate-200"),children:[n.map(s=>(0,h.jsxs)(pe.default,{href:`/docs/${s.slug==="index"?"":s.slug}`,onClick:()=>{r(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[(0,h.jsx)("h4",{className:"font-medium",children:s.data?.metadata?.title||s.slug}),(0,h.jsx)("p",{className:"text-sm mt-1 text-gray-500",children:s.data?.metadata?.description})]},s.slug)),o&&n.length===0&&(0,h.jsx)("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}var F=require("react/jsx-runtime"),be=(0,z.createContext)(null);function Ye({children:e,docstraConfig:r,docs:t,pageData:o,slug:a}){let n=o||(()=>{let P=Array.isArray(a)?a.length===0?"index":a.join("/"):a||"index";return t.find(N=>N.slug===P)})();if(!n)throw new Error("Page not found");let[i,f]=(0,z.useState)(!1),[m,w]=(0,z.useState)(!1),[s,g]=(0,z.useState)("npm");return(0,F.jsxs)(be.Provider,{value:{openSidebar:i,setOpenSidebar:f,docstraConfig:r,openSearchBox:m,setOpenSearchBox:w,pageData:n,docs:t,packageManager:s,setPackageManager:g},children:[(0,F.jsx)(ge.ToastContainer,{}),(0,F.jsx)(fe,{}),e]})}function c(){let e=(0,z.useContext)(be);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}var _=require("lucide-react"),xe=require("react");var Q=T(require("next/link")),k=require("react/jsx-runtime");function Qe(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t}=c(),o="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return(0,xe.useEffect)(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),(0,k.jsxs)("header",{className:"sticky top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[(0,k.jsx)(Q.default,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:(0,k.jsx)("img",{src:t.navbar?.logo?.src||"/logo.png",alt:t.navbar?.logo?.alt||"Logo",className:x("h-9.5 w-auto",t.navbar?.logo?.className)})}),(0,k.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>(0,k.jsx)(Q.default,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),(0,k.jsx)(Q.default,{href:o||"https://github.com/sudhucodes/docstra",children:(0,k.jsx)("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,k.jsx)("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),(0,k.jsx)("button",{onClick:()=>r(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?(0,k.jsx)(_.XIcon,{className:"size-6.5"}):(0,k.jsx)(_.TextAlignEnd,{className:"size-6.5"})})]})}var ye=require("lucide-react"),ve=require("next/navigation");var _e=T(require("lucide-react"));function he(e){if(e)return _e[e]}var we=T(require("next/link")),p=require("react/jsx-runtime");function Ne(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t,setOpenSearchBox:o}=c(),a=(0,ve.usePathname)();return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{className:x("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>r(!1)}),(0,p.jsxs)("aside",{className:x("sticky md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",e?"top-32":"top-full"),children:[(0,p.jsxs)("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{r(e&&!1),o(!0)},children:[(0,p.jsx)(ye.SearchIcon,{className:"size-4.5"}),(0,p.jsx)("p",{children:"Search"}),(0,p.jsxs)("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[(0,p.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),(0,p.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),t.sidebar?.links?.map(n=>(0,p.jsxs)("div",{children:[(0,p.jsx)("p",{className:"inline-flex items-center gap-2 mb-2 mt-2 px-2",children:n.section}),(0,p.jsx)("ul",{className:"mb-4",children:n.items.map(i=>{let f=he(i.icon);return(0,p.jsx)("li",{children:(0,p.jsxs)(we.default,{href:i.href,onNavigate:()=>e&&r(!1),className:x("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",a===i.href&&"bg-gray-100 text-gray-800"),children:[f&&(0,p.jsx)(f,{className:"size-4"}),(0,p.jsx)("span",{children:i.name})]})},i.href)})})]},n.section))]})]})}var G=require("lucide-react"),Ce=require("next/navigation"),v=require("react");var y=require("react/jsx-runtime");function De(){let[e,r]=(0,v.useState)(null),[t,o]=(0,v.useState)("down"),[a,n]=(0,v.useState)(!1),[i,f]=(0,v.useState)(!1),{docstraConfig:m,pageData:w}=c(),s=w?.path,g=w?.data?.tableOfContents||[],P=(0,v.useRef)(0),N=(0,v.useRef)(null),K=(0,Ce.usePathname)(),ee=`${"https://github.com/"+m?.editOnGithub?.owner+"/"+m?.editOnGithub?.repo}/edit/main/${m?.editOnGithub?.path}/${s}`;(0,v.useEffect)(()=>{let d=()=>{let b=window.scrollY;o(b>P.current?"down":"up"),n(b>100),P.current=b};return window.addEventListener("scroll",d),()=>window.removeEventListener("scroll",d)},[]),(0,v.useEffect)(()=>{let d=document.querySelectorAll("h2[id], h3[id]"),b=new IntersectionObserver(R=>{if(i)return;let L=R.filter($=>$.isIntersecting).sort(($,Ge)=>$.boundingClientRect.top-Ge.boundingClientRect.top);if(L.length>0){let $=t==="down"?L[0].target.id:L[L.length-1].target.id;r($)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return d.forEach(R=>b.observe(R)),N.current=b,()=>b.disconnect()},[K,t,i]),(0,v.useEffect)(()=>{!(window.scrollY>100)&&r(g[0]?.id)},[g]),(0,v.useEffect)(()=>{if(!e)return;let d=document.querySelector(".toc-scroll-container");if(!d)return;let b=d.querySelector(`a[href="#${e}"]`);if(!b)return;let R=d.getBoundingClientRect(),L=b.getBoundingClientRect();(L.top<R.top||L.bottom>R.bottom)&&b.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),(0,v.useEffect)(()=>{if(!i)return;let d=setTimeout(()=>f(!1),800);return()=>clearTimeout(d)},[i]);let V=d=>{r(d),f(!0)};return(0,y.jsxs)("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[(0,y.jsxs)("p",{className:"flex items-center gap-2 mb-5",children:[(0,y.jsx)(G.TextAlignStartIcon,{className:"size-4"}),"On this page"]}),(0,y.jsx)("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:g.map(d=>(0,y.jsxs)("li",{children:[(0,y.jsx)(ke,{heading:d,activeId:e,handleClick:V}),d.children.map(b=>(0,y.jsx)(ke,{heading:b,activeId:e,handleClick:V,className:"pl-8"},b.id))]},d.id))}),(0,y.jsx)("hr",{className:"my-6 border-gray-200"}),m.editOnGithub&&(0,y.jsxs)("a",{href:ee,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",(0,y.jsx)(G.SquareArrowOutUpRightIcon,{className:"size-4"})]}),a&&(0,y.jsxs)("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",(0,y.jsx)(G.ArrowUpCircleIcon,{className:"size-4"})]})]})}function ke({heading:e,activeId:r,handleClick:t,className:o}){return(0,y.jsx)("a",{href:`#${e.id}`,className:x("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":r===e.id,"hover:text-gray-800 hover:border-gray-400":r!==e.id}),onClick:()=>t(e.id),children:e.text})}var U=require("react/jsx-runtime");function We({children:e,toc:r=!0,sidebar:t=!0}){return(0,U.jsxs)("div",{className:"min-h-screen flex bg-white w-full",children:[t&&(0,U.jsx)(Ne,{}),e,r&&(0,U.jsx)(De,{})]})}var Se=require("next/navigation"),Le=require("lucide-react"),te=T(require("next/link")),D=require("react/jsx-runtime");function Ie(){let r=(0,Se.usePathname)().split("/").filter(Boolean),t=r.map((o,a)=>{let n="/"+r.slice(0,a+1).join("/"),i=o.replace(/-/g," ").replace(/\b\w/g,f=>f.toUpperCase());return{href:n,title:i}});return(0,D.jsx)("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:(0,D.jsxs)("ol",{className:"flex items-center space-x-2",children:[(0,D.jsx)("li",{children:(0,D.jsx)(te.default,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),t.map((o,a)=>{let n=a===t.length-1;return(0,D.jsxs)("li",{className:"flex items-center space-x-2",children:[(0,D.jsx)(Le.ChevronRight,{className:"w-4 h-4 text-gray-400"}),n?(0,D.jsx)("span",{className:"text-gray-600 font-medium",children:o.title}):(0,D.jsx)(te.default,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}var W=require("lucide-react"),H=require("react");var B=require("react/jsx-runtime");function Oe(){let{pageData:e}=c(),[r,t]=(0,H.useState)(!1),[o,a]=(0,H.useState)(null);(0,H.useEffect)(()=>{a(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return(0,B.jsxs)("div",{className:"flex items-center gap-3 mt-6",children:[(0,B.jsxs)("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),t(!0),setTimeout(()=>t(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[r?(0,B.jsx)(W.CheckIcon,{className:"size-3.5"}):(0,B.jsx)(W.CopyIcon,{className:"size-3.5"}),"Copy Markdown"]}),(0,B.jsx)("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(n)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}var O=require("react/jsx-runtime");function Pe(){let{pageData:e}=c(),r=e?.data?.metadata?.title,t=e?.data?.metadata?.description;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("h1",{className:"text-3xl font-bold",children:r}),(0,O.jsx)("p",{className:"my-4 text-gray-500",children:t}),(0,O.jsx)(Oe,{}),(0,O.jsx)("hr",{className:"my-10 border-gray-200"})]})}var q=require("react"),X=require("lucide-react");var M=require("react/jsx-runtime");function re({label:e,type:r,placeholder:t="",id:o,required:a=!1,onChange:n,value:i,readOnly:f=!1,className:m="",optional:w=!1}){return(0,M.jsxs)("div",{className:x("flex flex-col mt-4 w-full",m),children:[e&&(0,M.jsxs)("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,w&&(0,M.jsx)("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),r==="textarea"?(0,M.jsx)("textarea",{id:o,name:o,className:x("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",m),placeholder:t,required:a,onChange:n,rows:4,value:i,readOnly:f,maxLength:500}):(0,M.jsx)("input",{type:r,id:o,name:o,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:t,required:a,onChange:n,value:i,readOnly:f,maxLength:500})]})}var Re=require("lucide-react");var oe=require("react/jsx-runtime");function ae({label:e,loading:r,type:t="submit",className:o="",disabled:a=!1,onClick:n}){return(0,oe.jsx)("button",{type:t,disabled:a,className:x("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",o),"aria-label":e,onClick:n,children:r?(0,oe.jsx)(Re.Loader2Icon,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}var Z=require("formsync"),l=require("react/jsx-runtime");function Te(){let[e,r]=(0,q.useState)(null),{docstraConfig:t}=c(),[o,a]=(0,q.useState)(""),[n,i]=(0,q.useState)(!1),[f,m]=(0,q.useState)(null),w="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return(0,l.jsx)("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:n?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),(0,l.jsx)(ae,{onClick:()=>{i(!1),r(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"font-medium",children:"How is this guide?"}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsxs)("button",{onClick:()=>r("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,l.jsx)(X.ThumbsUp,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),(0,l.jsxs)("button",{onClick:()=>r("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,l.jsx)(X.ThumbsDown,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&(0,l.jsxs)(Z.FormSyncForm,{className:"flex flex-col gap-2",formId:t?.feedback?.formSyncFormID||"",onSuccess:s=>{i(!0),r(null),a("")},onSubmitError:s=>{m(s.message)},children:[(0,l.jsx)(re,{value:o,id:"message",onChange:s=>a(s.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),f&&(0,l.jsx)("p",{className:"text-red-500",children:f}),(0,l.jsx)("input",{type:"hidden",name:"opinion",value:e}),(0,l.jsx)("input",{type:"hidden",name:"page",value:window.location.href}),(0,l.jsx)("input",{type:"hidden",name:"_redirect",value:window.location.href}),(0,l.jsx)(Z.FormSyncButton,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),t?.feedback?.watermark!==!1&&(0,l.jsxs)("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",(0,l.jsx)("a",{href:`https://www.formsync.app?utm_source=${w}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}var Ee=require("react/jsx-runtime");function ze(){let{pageData:e}=c();if(!e?.data?.lastUpdated)return null;let r=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return(0,Ee.jsxs)("p",{className:"text-sm text-gray-500",children:["Last updated on ",r]})}var Be=require("next/navigation"),ne=T(require("next/link")),J=require("lucide-react");var C=require("react/jsx-runtime");function Me(){let e=(0,Be.usePathname)(),{docstraConfig:r}=c(),t=r?.sidebar?.links?.flatMap(i=>i.items),o=t.findIndex(i=>i.href===e),a=o>0?t[o-1]:null,n=o<t.length-1?t[o+1]:null;return(0,C.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[a?(0,C.jsxs)(ne.default,{href:a.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[(0,C.jsx)("span",{className:"text-gray-500",children:"Previous"}),(0,C.jsxs)("p",{className:"flex items-center font-medium",children:[(0,C.jsx)(J.ArrowLeftIcon,{className:"size-5 mr-2"}),a.name]})]}):(0,C.jsx)("div",{}),n?(0,C.jsxs)(ne.default,{href:n.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[(0,C.jsx)("span",{className:"text-gray-500",children:"Next"}),(0,C.jsxs)("p",{className:"flex items-center font-medium",children:[n.name,(0,C.jsx)(J.ArrowRightIcon,{className:"size-5 ml-2"})]})]}):(0,C.jsx)("div",{})]})}var E=require("react/jsx-runtime");function Xe({children:e}){let{docstraConfig:r}=c();return(0,E.jsxs)("main",{className:"flex-1 px-4 md:px-8 py-10 text-base/7 prose max-w-none",children:[(0,E.jsx)(Ie,{}),(0,E.jsx)(Pe,{}),e,r?.feedback?.enabled&&(0,E.jsx)(Te,{}),(0,E.jsx)(ze,{}),(0,E.jsx)(Me,{})]})}var A=require("lucide-react"),j=require("prism-react-renderer"),$e=require("react");var u=require("react/jsx-runtime"),se={npm:"npm install",pnpm:"pnpm add",yarn:"yarn add",bun:"bun add"};function Ze(e){let{filename:r,copyable:t,children:o,className:a}=e,{packageManager:n,setPackageManager:i}=c(),f=!a?.includes("language-"),m=typeof o=="string"?o:o?.props?.children||"";if(f)return(0,u.jsx)("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:m});let[w,s]=(0,$e.useState)(!1),P=a?.match(/language-([\w-]+)/)?.[1]??"txt",N=P==="package-install",K=()=>{let S=N?`${se[n]} ${m.trim()}`:m.trim();navigator.clipboard.writeText(S),s(!0),setTimeout(()=>s(!1),2e3)};return(0,u.jsxs)("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[!N&&(0,u.jsx)("span",{className:"text-xs text-gray-400 px-4 py-3",children:r||P}),N&&(0,u.jsx)("div",{className:"flex items-center px-3",children:Object.keys(se).map(S=>(0,u.jsx)("button",{onClick:()=>i(S),className:`px-3 pb-2.5 pt-3 text-sm font-medium border-b-2 transition-all ${n===S?"border-gray-900 text-gray-900":"border-transparent text-gray-500 hover:text-gray-800"}`,children:S},S))}),t&&!N&&(0,u.jsx)("button",{onClick:K,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:w?(0,u.jsx)(A.CheckIcon,{className:"size-4 text-green-600"}):(0,u.jsx)(A.CopyIcon,{className:"size-4"})})]}),(0,u.jsx)(j.Highlight,{theme:j.themes.vsLight,code:m.trim(),language:N?"bash":P,children:({tokens:S,getLineProps:ee,getTokenProps:V})=>(0,u.jsxs)("pre",{className:`p-4 font-mono whitespace-pre overflow-x-auto text-sm leading-relaxed ${t&&N?"flex items-center justify-between":""}`,children:[S.map((d,b)=>(0,u.jsxs)("div",{...ee({line:d}),children:[!N&&(0,u.jsx)("span",{className:"text-gray-400 mr-4 select-none",children:b+1}),N&&(0,u.jsx)("span",{className:"mr-2",children:se[n]}),d.map((R,L)=>(0,u.jsx)("span",{...V({token:R})},L))]},b)),t&&N&&(0,u.jsx)("button",{onClick:K,className:"rounded-lg cursor-pointer p-2 text-gray-500 hover:bg-gray-100 transition",children:w?(0,u.jsx)(A.CheckIcon,{className:"size-4 text-green-600"}):(0,u.jsx)(A.CopyIcon,{className:"size-4"})})]})})]})}0&&(module.exports={DocstraBody,DocstraCodeBlock,DocstraHeader,DocstraPage,DocstraProvider,useDocstra});
|
|
1
|
+
"use strict";"use client";var Ae=Object.create;var Y=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty;var Ke=(e,r)=>{for(var t in r)Y(e,t,{get:r[t],enumerable:!0})},ie=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Ue(r))!qe.call(e,a)&&a!==t&&Y(e,a,{get:()=>r[a],enumerable:!(o=Fe(r,a))||o.enumerable});return e};var T=(e,r,t)=>(t=e!=null?Ae(He(e)):{},ie(r||!e||!e.__esModule?Y(t,"default",{value:e,enumerable:!0}):t,e)),Ve=e=>ie(Y({},"__esModule",{value:!0}),e);var Je={};Ke(Je,{DocstraBody:()=>Xe,DocstraCodeBlock:()=>Ze,DocstraHeader:()=>Qe,DocstraPage:()=>We,DocstraProvider:()=>Ye,useDocstra:()=>c});module.exports=Ve(Je);var z=require("react"),ge=require("react-toast-msg");var me=require("lucide-react");var le=require("tailwind-merge"),ce=T(require("clsx"));function h(...e){return(0,le.twMerge)((0,ce.default)(e))}var I=require("react"),de=T(require("fuse.js")),pe=T(require("next/link")),ue=require("next/navigation"),x=require("react/jsx-runtime");function fe(){let{openSearchBox:e,setOpenSearchBox:r,docs:t}=c(),[o,a]=(0,I.useState)(""),[n,i]=(0,I.useState)([]),f=(0,ue.useRouter)();(0,I.useEffect)(()=>{let s=g=>{g.ctrlKey&&g.key==="k"&&(g.preventDefault(),r(!0))};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[]);let m=(0,I.useMemo)(()=>!t||t.length===0?null:new de.default(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);(0,I.useEffect)(()=>{if(o&&m){let s=m.search(o);i(s.map(g=>g.item))}else o||i([])},[o,m]);let w=s=>{if(s.preventDefault(),o){let g=n[0];g&&(f.push(`/docs/${g.slug}`),a(""),r(!1))}};return(0,I.useEffect)(()=>{let s=g=>{g.key==="Escape"&&(r(!1),a(""))};return e&&window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[e]),(0,x.jsx)("div",{onClick:()=>{r(!1),a("")},className:h("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:(0,x.jsxs)("div",{onClick:s=>s.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[(0,x.jsx)("form",{onSubmit:w,className:h("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",o&&"rounded-b-none border-b-0"),children:e&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(me.SearchIcon,{className:"size-5.5 mx-3 shrink-0"}),(0,x.jsx)("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:o,onChange:s=>a(s.target.value),name:"searchQuery",required:!0}),(0,x.jsx)("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),(0,x.jsxs)("div",{className:h("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",o&&"rounded-b-md border border-slate-200"),children:[n.map(s=>(0,x.jsxs)(pe.default,{href:`/docs/${s.slug==="index"?"":s.slug}`,onClick:()=>{r(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[(0,x.jsx)("h4",{className:"font-medium",children:s.data?.metadata?.title||s.slug}),(0,x.jsx)("p",{className:"text-sm mt-1 text-gray-500",children:s.data?.metadata?.description})]},s.slug)),o&&n.length===0&&(0,x.jsx)("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}var F=require("react/jsx-runtime"),be=(0,z.createContext)(null);function Ye({children:e,docstraConfig:r,docs:t,pageData:o,slug:a}){let n=o||(()=>{let P=Array.isArray(a)?a.length===0?"index":a.join("/"):a||"index";return t.find(N=>N.slug===P)})();if(!n)throw new Error("Page not found");let[i,f]=(0,z.useState)(!1),[m,w]=(0,z.useState)(!1),[s,g]=(0,z.useState)("npm");return(0,F.jsxs)(be.Provider,{value:{openSidebar:i,setOpenSidebar:f,docstraConfig:r,openSearchBox:m,setOpenSearchBox:w,pageData:n,docs:t,packageManager:s,setPackageManager:g},children:[(0,F.jsx)(ge.ToastContainer,{}),(0,F.jsx)(fe,{}),e]})}function c(){let e=(0,z.useContext)(be);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}var _=require("lucide-react"),he=require("react");var Q=T(require("next/link")),k=require("react/jsx-runtime");function Qe(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t}=c(),o="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return(0,he.useEffect)(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),(0,k.jsxs)("header",{className:"sticky top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[(0,k.jsx)(Q.default,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:(0,k.jsx)("img",{src:t.navbar?.logo?.src||"/logo.png",alt:t.navbar?.logo?.alt||"Logo",className:h("h-9.5 w-auto",t.navbar?.logo?.className)})}),(0,k.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>(0,k.jsx)(Q.default,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),(0,k.jsx)(Q.default,{href:o||"https://github.com/sudhucodes/docstra",children:(0,k.jsx)("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,k.jsx)("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),(0,k.jsx)("button",{onClick:()=>r(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?(0,k.jsx)(_.XIcon,{className:"size-6.5"}):(0,k.jsx)(_.TextAlignEnd,{className:"size-6.5"})})]})}var ye=require("lucide-react"),ve=require("next/navigation");var _e=T(require("lucide-react"));function xe(e){if(e)return _e[e]}var we=T(require("next/link")),p=require("react/jsx-runtime");function Ne(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t,setOpenSearchBox:o}=c(),a=(0,ve.usePathname)();return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{className:h("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>r(!1)}),(0,p.jsxs)("aside",{className:h("sticky md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",e?"top-32":"top-full"),children:[(0,p.jsxs)("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{r(e&&!1),o(!0)},children:[(0,p.jsx)(ye.SearchIcon,{className:"size-4.5"}),(0,p.jsx)("p",{children:"Search"}),(0,p.jsxs)("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[(0,p.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),(0,p.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),t.sidebar?.links?.map(n=>(0,p.jsxs)("div",{children:[(0,p.jsx)("p",{className:"inline-flex items-center gap-2 mb-2 mt-2 px-2",children:n.section}),(0,p.jsx)("ul",{className:"mb-4",children:n.items.map(i=>{let f=xe(i.icon);return(0,p.jsx)("li",{children:(0,p.jsxs)(we.default,{href:i.href,onNavigate:()=>e&&r(!1),className:h("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",a===i.href&&"bg-gray-100 text-gray-800"),children:[f&&(0,p.jsx)(f,{className:"size-4"}),(0,p.jsx)("span",{children:i.name})]})},i.href)})})]},n.section))]})]})}var G=require("lucide-react"),Ce=require("next/navigation"),v=require("react");var y=require("react/jsx-runtime");function De(){let[e,r]=(0,v.useState)(null),[t,o]=(0,v.useState)("down"),[a,n]=(0,v.useState)(!1),[i,f]=(0,v.useState)(!1),{docstraConfig:m,pageData:w}=c(),s=w?.path,g=w?.data?.tableOfContents||[],P=(0,v.useRef)(0),N=(0,v.useRef)(null),K=(0,Ce.usePathname)(),ee=`${"https://github.com/"+m?.editOnGithub?.owner+"/"+m?.editOnGithub?.repo}/edit/main/${m?.editOnGithub?.path}/${s}`;(0,v.useEffect)(()=>{let d=()=>{let b=window.scrollY;o(b>P.current?"down":"up"),n(b>100),P.current=b};return window.addEventListener("scroll",d),()=>window.removeEventListener("scroll",d)},[]),(0,v.useEffect)(()=>{let d=document.querySelectorAll("h2[id], h3[id]"),b=new IntersectionObserver(R=>{if(i)return;let L=R.filter($=>$.isIntersecting).sort(($,Ge)=>$.boundingClientRect.top-Ge.boundingClientRect.top);if(L.length>0){let $=t==="down"?L[0].target.id:L[L.length-1].target.id;r($)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return d.forEach(R=>b.observe(R)),N.current=b,()=>b.disconnect()},[K,t,i]),(0,v.useEffect)(()=>{!(window.scrollY>100)&&r(g[0]?.id)},[g]),(0,v.useEffect)(()=>{if(!e)return;let d=document.querySelector(".toc-scroll-container");if(!d)return;let b=d.querySelector(`a[href="#${e}"]`);if(!b)return;let R=d.getBoundingClientRect(),L=b.getBoundingClientRect();(L.top<R.top||L.bottom>R.bottom)&&b.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),(0,v.useEffect)(()=>{if(!i)return;let d=setTimeout(()=>f(!1),800);return()=>clearTimeout(d)},[i]);let V=d=>{r(d),f(!0)};return(0,y.jsxs)("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[(0,y.jsxs)("p",{className:"flex items-center gap-2 mb-5",children:[(0,y.jsx)(G.TextAlignStartIcon,{className:"size-4"}),"On this page"]}),(0,y.jsx)("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:g.map(d=>(0,y.jsxs)("li",{children:[(0,y.jsx)(ke,{heading:d,activeId:e,handleClick:V}),d.children.map(b=>(0,y.jsx)(ke,{heading:b,activeId:e,handleClick:V,className:"pl-8"},b.id))]},d.id))}),(0,y.jsx)("hr",{className:"my-6 border-gray-200"}),m.editOnGithub&&(0,y.jsxs)("a",{href:ee,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",(0,y.jsx)(G.SquareArrowOutUpRightIcon,{className:"size-4"})]}),a&&(0,y.jsxs)("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",(0,y.jsx)(G.ArrowUpCircleIcon,{className:"size-4"})]})]})}function ke({heading:e,activeId:r,handleClick:t,className:o}){return(0,y.jsx)("a",{href:`#${e.id}`,className:h("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":r===e.id,"hover:text-gray-800 hover:border-gray-400":r!==e.id}),onClick:()=>t(e.id),children:e.text})}var U=require("react/jsx-runtime");function We({children:e,toc:r=!0,sidebar:t=!0}){return(0,U.jsxs)("div",{className:"min-h-screen flex bg-white w-full",children:[t&&(0,U.jsx)(Ne,{}),e,r&&(0,U.jsx)(De,{})]})}var Se=require("next/navigation"),Le=require("lucide-react"),te=T(require("next/link")),D=require("react/jsx-runtime");function Ie(){let r=(0,Se.usePathname)().split("/").filter(Boolean),t=r.map((o,a)=>{let n="/"+r.slice(0,a+1).join("/"),i=o.replace(/-/g," ").replace(/\b\w/g,f=>f.toUpperCase());return{href:n,title:i}});return(0,D.jsx)("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:(0,D.jsxs)("ol",{className:"flex items-center space-x-2",children:[(0,D.jsx)("li",{children:(0,D.jsx)(te.default,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),t.map((o,a)=>{let n=a===t.length-1;return(0,D.jsxs)("li",{className:"flex items-center space-x-2",children:[(0,D.jsx)(Le.ChevronRight,{className:"w-4 h-4 text-gray-400"}),n?(0,D.jsx)("span",{className:"text-gray-600 font-medium",children:o.title}):(0,D.jsx)(te.default,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}var W=require("lucide-react"),H=require("react");var B=require("react/jsx-runtime");function Oe(){let{pageData:e}=c(),[r,t]=(0,H.useState)(!1),[o,a]=(0,H.useState)(null);(0,H.useEffect)(()=>{a(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return(0,B.jsxs)("div",{className:"flex items-center gap-3 mt-6",children:[(0,B.jsxs)("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),t(!0),setTimeout(()=>t(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[r?(0,B.jsx)(W.CheckIcon,{className:"size-3.5"}):(0,B.jsx)(W.CopyIcon,{className:"size-3.5"}),"Copy Markdown"]}),(0,B.jsx)("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(n)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}var O=require("react/jsx-runtime");function Pe(){let{pageData:e}=c(),r=e?.data?.metadata?.title,t=e?.data?.metadata?.description;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("h1",{className:"text-3xl font-bold",children:r}),(0,O.jsx)("p",{className:"my-4 text-gray-500",children:t}),(0,O.jsx)(Oe,{}),(0,O.jsx)("hr",{className:"my-10 border-gray-200"})]})}var q=require("react"),X=require("lucide-react");var M=require("react/jsx-runtime");function re({label:e,type:r,placeholder:t="",id:o,required:a=!1,onChange:n,value:i,readOnly:f=!1,className:m="",optional:w=!1}){return(0,M.jsxs)("div",{className:h("flex flex-col mt-4 w-full",m),children:[e&&(0,M.jsxs)("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,w&&(0,M.jsx)("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),r==="textarea"?(0,M.jsx)("textarea",{id:o,name:o,className:h("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",m),placeholder:t,required:a,onChange:n,rows:4,value:i,readOnly:f,maxLength:500}):(0,M.jsx)("input",{type:r,id:o,name:o,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:t,required:a,onChange:n,value:i,readOnly:f,maxLength:500})]})}var Re=require("lucide-react");var oe=require("react/jsx-runtime");function ae({label:e,loading:r,type:t="submit",className:o="",disabled:a=!1,onClick:n}){return(0,oe.jsx)("button",{type:t,disabled:a,className:h("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",o),"aria-label":e,onClick:n,children:r?(0,oe.jsx)(Re.Loader2Icon,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}var Z=require("formsync"),l=require("react/jsx-runtime");function Te(){let[e,r]=(0,q.useState)(null),{docstraConfig:t}=c(),[o,a]=(0,q.useState)(""),[n,i]=(0,q.useState)(!1),[f,m]=(0,q.useState)(null),w="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return(0,l.jsx)("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:n?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),(0,l.jsx)(ae,{onClick:()=>{i(!1),r(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"font-medium",children:"How is this guide?"}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsxs)("button",{onClick:()=>r("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,l.jsx)(X.ThumbsUp,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),(0,l.jsxs)("button",{onClick:()=>r("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,l.jsx)(X.ThumbsDown,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&(0,l.jsxs)(Z.FormSyncForm,{className:"flex flex-col gap-2",formId:t?.feedback?.formSyncFormID||"",onSuccess:s=>{i(!0),r(null),a("")},onSubmitError:s=>{m(s.message)},children:[(0,l.jsx)(re,{value:o,id:"message",onChange:s=>a(s.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),f&&(0,l.jsx)("p",{className:"text-red-500",children:f}),(0,l.jsx)("input",{type:"hidden",name:"opinion",value:e}),(0,l.jsx)("input",{type:"hidden",name:"page",value:window.location.href}),(0,l.jsx)("input",{type:"hidden",name:"_redirect",value:window.location.href}),(0,l.jsx)(Z.FormSyncButton,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),t?.feedback?.watermark!==!1&&(0,l.jsxs)("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",(0,l.jsx)("a",{href:`https://www.formsync.app?utm_source=${w}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}var Ee=require("react/jsx-runtime");function ze(){let{pageData:e}=c();if(!e?.data?.lastUpdated)return null;let r=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return(0,Ee.jsxs)("p",{className:"text-sm text-gray-500",children:["Last updated on ",r]})}var Be=require("next/navigation"),ne=T(require("next/link")),J=require("lucide-react");var C=require("react/jsx-runtime");function Me(){let e=(0,Be.usePathname)(),{docstraConfig:r}=c(),t=r?.sidebar?.links?.flatMap(i=>i.items),o=t.findIndex(i=>i.href===e),a=o>0?t[o-1]:null,n=o<t.length-1?t[o+1]:null;return(0,C.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[a?(0,C.jsxs)(ne.default,{href:a.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[(0,C.jsx)("span",{className:"text-gray-500",children:"Previous"}),(0,C.jsxs)("p",{className:"flex items-center font-medium",children:[(0,C.jsx)(J.ArrowLeftIcon,{className:"size-5 mr-2"}),a.name]})]}):(0,C.jsx)("div",{}),n?(0,C.jsxs)(ne.default,{href:n.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[(0,C.jsx)("span",{className:"text-gray-500",children:"Next"}),(0,C.jsxs)("p",{className:"flex items-center font-medium",children:[n.name,(0,C.jsx)(J.ArrowRightIcon,{className:"size-5 ml-2"})]})]}):(0,C.jsx)("div",{})]})}var E=require("react/jsx-runtime");function Xe({children:e}){let{docstraConfig:r}=c();return(0,E.jsxs)("main",{className:"flex-1 px-4 md:px-8 py-10 prose max-w-none",children:[(0,E.jsx)(Ie,{}),(0,E.jsx)(Pe,{}),e,r?.feedback?.enabled&&(0,E.jsx)(Te,{}),(0,E.jsx)(ze,{}),(0,E.jsx)(Me,{})]})}var A=require("lucide-react"),j=require("prism-react-renderer"),$e=require("react");var u=require("react/jsx-runtime"),se={npm:"npm install",pnpm:"pnpm add",yarn:"yarn add",bun:"bun add"};function Ze(e){let{filename:r,copyable:t,children:o,className:a}=e,{packageManager:n,setPackageManager:i}=c(),f=!a?.includes("language-"),m=typeof o=="string"?o:o?.props?.children||"";if(f)return(0,u.jsx)("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:m});let[w,s]=(0,$e.useState)(!1),P=a?.match(/language-([\w-]+)/)?.[1]??"txt",N=P==="package-install",K=()=>{let S=N?`${se[n]} ${m.trim()}`:m.trim();navigator.clipboard.writeText(S),s(!0),setTimeout(()=>s(!1),2e3)};return(0,u.jsxs)("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[!N&&(0,u.jsx)("span",{className:"text-xs text-gray-400 px-4 py-3",children:r||P}),N&&(0,u.jsx)("div",{className:"flex items-center px-3",children:Object.keys(se).map(S=>(0,u.jsx)("button",{onClick:()=>i(S),className:`px-3 pb-2.5 pt-3 text-sm font-medium border-b-2 transition-all ${n===S?"border-gray-900 text-gray-900":"border-transparent text-gray-500 hover:text-gray-800"}`,children:S},S))}),t&&!N&&(0,u.jsx)("button",{onClick:K,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:w?(0,u.jsx)(A.CheckIcon,{className:"size-4 text-green-600"}):(0,u.jsx)(A.CopyIcon,{className:"size-4"})})]}),(0,u.jsx)(j.Highlight,{theme:j.themes.vsLight,code:m.trim(),language:N?"bash":P,children:({tokens:S,getLineProps:ee,getTokenProps:V})=>(0,u.jsxs)("pre",{className:`p-4 font-mono whitespace-pre overflow-x-auto text-sm leading-relaxed ${t&&N?"flex items-center justify-between":""}`,children:[S.map((d,b)=>(0,u.jsxs)("div",{...ee({line:d}),children:[!N&&(0,u.jsx)("span",{className:"text-gray-400 mr-4 select-none",children:b+1}),N&&(0,u.jsx)("span",{className:"mr-2",children:se[n]}),d.map((R,L)=>(0,u.jsx)("span",{...V({token:R})},L))]},b)),t&&N&&(0,u.jsx)("button",{onClick:K,className:"rounded-lg cursor-pointer p-2 text-gray-500 hover:bg-gray-100 transition",children:w?(0,u.jsx)(A.CheckIcon,{className:"size-4 text-green-600"}):(0,u.jsx)(A.CopyIcon,{className:"size-4"})})]})})]})}0&&(module.exports={DocstraBody,DocstraCodeBlock,DocstraHeader,DocstraPage,DocstraProvider,useDocstra});
|
package/dist/client/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{createContext as Ee,useContext as Be,useState as V}from"react";import{ToastContainer as Me}from"react-toast-msg";import{SearchIcon as Ie}from"lucide-react";import{twMerge as Se}from"tailwind-merge";import Le from"clsx";function f(...e){return Se(Le(e))}import{useEffect as K,useMemo as Oe,useState as J}from"react";import Pe from"fuse.js";import Re from"next/link";import{useRouter as Te}from"next/navigation";import{Fragment as ze,jsx as D,jsxs as G}from"react/jsx-runtime";function j(){let{openSearchBox:e,setOpenSearchBox:r,docs:t}=l(),[o,a]=J(""),[n,i]=J([]),d=Te();K(()=>{let s=p=>{p.ctrlKey&&p.key==="k"&&(p.preventDefault(),r(!0))};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[]);let c=Oe(()=>!t||t.length===0?null:new Pe(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);K(()=>{if(o&&c){let s=c.search(o);i(s.map(p=>p.item))}else o||i([])},[o,c]);let b=s=>{if(s.preventDefault(),o){let p=n[0];p&&(d.push(`/docs/${p.slug}`),a(""),r(!1))}};return K(()=>{let s=p=>{p.key==="Escape"&&(r(!1),a(""))};return e&&window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[e]),D("div",{onClick:()=>{r(!1),a("")},className:f("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:G("div",{onClick:s=>s.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[D("form",{onSubmit:b,className:f("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",o&&"rounded-b-none border-b-0"),children:e&&G(ze,{children:[D(Ie,{className:"size-5.5 mx-3 shrink-0"}),D("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:o,onChange:s=>a(s.target.value),name:"searchQuery",required:!0}),D("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),G("div",{className:f("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",o&&"rounded-b-md border border-slate-200"),children:[n.map(s=>G(Re,{href:`/docs/${s.slug==="index"?"":s.slug}`,onClick:()=>{r(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[D("h4",{className:"font-medium",children:s.data?.metadata?.title||s.slug}),D("p",{className:"text-sm mt-1 text-gray-500",children:s.data?.metadata?.description})]},s.slug)),o&&n.length===0&&D("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}import{jsx as ee,jsxs as $e}from"react/jsx-runtime";var te=Ee(null);function Et({children:e,docstraConfig:r,docs:t,pageData:o,slug:a}){let n=o||(()=>{let k=Array.isArray(a)?a.length===0?"index":a.join("/"):a||"index";return t.find(x=>x.slug===k)})();if(!n)throw new Error("Page not found");let[i,d]=V(!1),[c,b]=V(!1),[s,p]=V("npm");return $e(te.Provider,{value:{openSidebar:i,setOpenSidebar:d,docstraConfig:r,openSearchBox:c,setOpenSearchBox:b,pageData:n,docs:t,packageManager:s,setPackageManager:p},children:[ee(Me,{}),ee(j,{}),e]})}function l(){let e=Be(te);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}import{TextAlignEnd as Ge,XIcon as Ae}from"lucide-react";import{useEffect as Fe}from"react";import Y from"next/link";import{jsx as N,jsxs as re}from"react/jsx-runtime";function Ht(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t}=l(),o="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return Fe(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),re("header",{className:"sticky top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[N(Y,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:N("img",{src:t.navbar?.logo?.src||"/logo.png",alt:t.navbar?.logo?.alt||"Logo",className:f("h-9.5 w-auto",t.navbar?.logo?.className)})}),re("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>N(Y,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),N(Y,{href:o||"https://github.com/sudhucodes/docstra",children:N("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:N("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),N("button",{onClick:()=>r(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?N(Ae,{className:"size-6.5"}):N(Ge,{className:"size-6.5"})})]})}import{SearchIcon as He}from"lucide-react";import{usePathname as qe}from"next/navigation";import*as Ue from"lucide-react";function oe(e){if(e)return Ue[e]}import Ke from"next/link";import{Fragment as Ve,jsx as y,jsxs as O}from"react/jsx-runtime";function ae(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t,setOpenSearchBox:o}=l(),a=qe();return O(Ve,{children:[y("div",{className:f("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>r(!1)}),O("aside",{className:f("sticky md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",e?"top-32":"top-full"),children:[O("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{r(e&&!1),o(!0)},children:[y(He,{className:"size-4.5"}),y("p",{children:"Search"}),O("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[y("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),y("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),t.sidebar?.links?.map(n=>O("div",{children:[y("p",{className:"inline-flex items-center gap-2 mb-2 mt-2 px-2",children:n.section}),y("ul",{className:"mb-4",children:n.items.map(i=>{let d=oe(i.icon);return y("li",{children:O(Ke,{href:i.href,onNavigate:()=>e&&r(!1),className:f("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",a===i.href&&"bg-gray-100 text-gray-800"),children:[d&&y(d,{className:"size-4"}),y("span",{children:i.name})]})},i.href)})})]},n.section))]})]})}import{ArrowUpCircleIcon as Ye,SquareArrowOutUpRightIcon as Qe,TextAlignStartIcon as _e}from"lucide-react";import{usePathname as We}from"next/navigation";import{useEffect as T,useRef as ne,useState as A}from"react";import{jsx as S,jsxs as z}from"react/jsx-runtime";function ie(){let[e,r]=A(null),[t,o]=A("down"),[a,n]=A(!1),[i,d]=A(!1),{docstraConfig:c,pageData:b}=l(),s=b?.path,p=b?.data?.tableOfContents||[],k=ne(0),x=ne(null),M=We(),q=`${"https://github.com/"+c?.editOnGithub?.owner+"/"+c?.editOnGithub?.repo}/edit/main/${c?.editOnGithub?.path}/${s}`;T(()=>{let m=()=>{let u=window.scrollY;o(u>k.current?"down":"up"),n(u>100),k.current=u};return window.addEventListener("scroll",m),()=>window.removeEventListener("scroll",m)},[]),T(()=>{let m=document.querySelectorAll("h2[id], h3[id]"),u=new IntersectionObserver(C=>{if(i)return;let w=C.filter(I=>I.isIntersecting).sort((I,De)=>I.boundingClientRect.top-De.boundingClientRect.top);if(w.length>0){let I=t==="down"?w[0].target.id:w[w.length-1].target.id;r(I)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return m.forEach(C=>u.observe(C)),x.current=u,()=>u.disconnect()},[M,t,i]),T(()=>{!(window.scrollY>100)&&r(p[0]?.id)},[p]),T(()=>{if(!e)return;let m=document.querySelector(".toc-scroll-container");if(!m)return;let u=m.querySelector(`a[href="#${e}"]`);if(!u)return;let C=m.getBoundingClientRect(),w=u.getBoundingClientRect();(w.top<C.top||w.bottom>C.bottom)&&u.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),T(()=>{if(!i)return;let m=setTimeout(()=>d(!1),800);return()=>clearTimeout(m)},[i]);let $=m=>{r(m),d(!0)};return z("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[z("p",{className:"flex items-center gap-2 mb-5",children:[S(_e,{className:"size-4"}),"On this page"]}),S("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:p.map(m=>z("li",{children:[S(se,{heading:m,activeId:e,handleClick:$}),m.children.map(u=>S(se,{heading:u,activeId:e,handleClick:$,className:"pl-8"},u.id))]},m.id))}),S("hr",{className:"my-6 border-gray-200"}),c.editOnGithub&&z("a",{href:q,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",S(Qe,{className:"size-4"})]}),a&&z("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",S(Ye,{className:"size-4"})]})]})}function se({heading:e,activeId:r,handleClick:t,className:o}){return S("a",{href:`#${e.id}`,className:f("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":r===e.id,"hover:text-gray-800 hover:border-gray-400":r!==e.id}),onClick:()=>t(e.id),children:e.text})}import{jsx as le,jsxs as Xe}from"react/jsx-runtime";function cr({children:e,toc:r=!0,sidebar:t=!0}){return Xe("div",{className:"min-h-screen flex bg-white w-full",children:[t&&le(ae,{}),e,r&&le(ie,{})]})}import{usePathname as Ze}from"next/navigation";import{ChevronRight as Je}from"lucide-react";import ce from"next/link";import{jsx as P,jsxs as me}from"react/jsx-runtime";function de(){let r=Ze().split("/").filter(Boolean),t=r.map((o,a)=>{let n="/"+r.slice(0,a+1).join("/"),i=o.replace(/-/g," ").replace(/\b\w/g,d=>d.toUpperCase());return{href:n,title:i}});return P("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:me("ol",{className:"flex items-center space-x-2",children:[P("li",{children:P(ce,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),t.map((o,a)=>{let n=a===t.length-1;return me("li",{className:"flex items-center space-x-2",children:[P(Je,{className:"w-4 h-4 text-gray-400"}),n?P("span",{className:"text-gray-600 font-medium",children:o.title}):P(ce,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}import{CheckIcon as je,CopyIcon as et}from"lucide-react";import{useEffect as tt,useState as pe}from"react";import{jsx as Q,jsxs as ue}from"react/jsx-runtime";function fe(){let{pageData:e}=l(),[r,t]=pe(!1),[o,a]=pe(null);tt(()=>{a(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return ue("div",{className:"flex items-center gap-3 mt-6",children:[ue("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),t(!0),setTimeout(()=>t(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[r?Q(je,{className:"size-3.5"}):Q(et,{className:"size-3.5"}),"Copy Markdown"]}),Q("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(n)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}import{Fragment as rt,jsx as F,jsxs as ot}from"react/jsx-runtime";function ge(){let{pageData:e}=l(),r=e?.data?.metadata?.title,t=e?.data?.metadata?.description;return ot(rt,{children:[F("h1",{className:"text-3xl font-bold",children:r}),F("p",{className:"my-4 text-gray-500",children:t}),F(fe,{}),F("hr",{className:"my-10 border-gray-200"})]})}import{useState as U}from"react";import{ThumbsUp as nt,ThumbsDown as st}from"lucide-react";import{jsx as _,jsxs as be}from"react/jsx-runtime";function W({label:e,type:r,placeholder:t="",id:o,required:a=!1,onChange:n,value:i,readOnly:d=!1,className:c="",optional:b=!1}){return be("div",{className:f("flex flex-col mt-4 w-full",c),children:[e&&be("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,b&&_("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),r==="textarea"?_("textarea",{id:o,name:o,className:f("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",c),placeholder:t,required:a,onChange:n,rows:4,value:i,readOnly:d,maxLength:500}):_("input",{type:r,id:o,name:o,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:t,required:a,onChange:n,value:i,readOnly:d,maxLength:500})]})}import{Loader2Icon as at}from"lucide-react";import{jsx as xe}from"react/jsx-runtime";function X({label:e,loading:r,type:t="submit",className:o="",disabled:a=!1,onClick:n}){return xe("button",{type:t,disabled:a,className:f("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",o),"aria-label":e,onClick:n,children:r?xe(at,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}import{FormSyncButton as it,FormSyncForm as lt}from"formsync";import{Fragment as he,jsx as h,jsxs as L}from"react/jsx-runtime";function ye(){let[e,r]=U(null),{docstraConfig:t}=l(),[o,a]=U(""),[n,i]=U(!1),[d,c]=U(null),b="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return h("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:n?L(he,{children:[h("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),h(X,{onClick:()=>{i(!1),r(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):L(he,{children:[h("p",{className:"font-medium",children:"How is this guide?"}),L("div",{className:"flex gap-2",children:[L("button",{onClick:()=>r("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[h(nt,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),L("button",{onClick:()=>r("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[h(st,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&L(lt,{className:"flex flex-col gap-2",formId:t?.feedback?.formSyncFormID||"",onSuccess:s=>{i(!0),r(null),a("")},onSubmitError:s=>{c(s.message)},children:[h(W,{value:o,id:"message",onChange:s=>a(s.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),d&&h("p",{className:"text-red-500",children:d}),h("input",{type:"hidden",name:"opinion",value:e}),h("input",{type:"hidden",name:"page",value:window.location.href}),h("input",{type:"hidden",name:"_redirect",value:window.location.href}),h(it,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),t?.feedback?.watermark!==!1&&L("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",h("a",{href:`https://www.formsync.app?utm_source=${b}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}import{jsxs as ct}from"react/jsx-runtime";function ve(){let{pageData:e}=l();if(!e?.data?.lastUpdated)return null;let r=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return ct("p",{className:"text-sm text-gray-500",children:["Last updated on ",r]})}import{usePathname as mt}from"next/navigation";import we from"next/link";import{ArrowLeftIcon as dt,ArrowRightIcon as pt}from"lucide-react";import{jsx as R,jsxs as E}from"react/jsx-runtime";function Ne(){let e=mt(),{docstraConfig:r}=l(),t=r?.sidebar?.links?.flatMap(i=>i.items),o=t.findIndex(i=>i.href===e),a=o>0?t[o-1]:null,n=o<t.length-1?t[o+1]:null;return E("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[a?E(we,{href:a.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[R("span",{className:"text-gray-500",children:"Previous"}),E("p",{className:"flex items-center font-medium",children:[R(dt,{className:"size-5 mr-2"}),a.name]})]}):R("div",{}),n?E(we,{href:n.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[R("span",{className:"text-gray-500",children:"Next"}),E("p",{className:"flex items-center font-medium",children:[n.name,R(pt,{className:"size-5 ml-2"})]})]}):R("div",{})]})}import{jsx as B,jsxs as ut}from"react/jsx-runtime";function ro({children:e}){let{docstraConfig:r}=l();return ut("main",{className:"flex-1 px-4 md:px-8 py-10 text-base/7 prose max-w-none",children:[B(de,{}),B(ge,{}),e,r?.feedback?.enabled&&B(ye,{}),B(ve,{}),B(Ne,{})]})}import{CheckIcon as ke,CopyIcon as Ce}from"lucide-react";import{Highlight as ft,themes as gt}from"prism-react-renderer";import{useState as bt}from"react";import{jsx as g,jsxs as H}from"react/jsx-runtime";var Z={npm:"npm install",pnpm:"pnpm add",yarn:"yarn add",bun:"bun add"};function co(e){let{filename:r,copyable:t,children:o,className:a}=e,{packageManager:n,setPackageManager:i}=l(),d=!a?.includes("language-"),c=typeof o=="string"?o:o?.props?.children||"";if(d)return g("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:c});let[b,s]=bt(!1),k=a?.match(/language-([\w-]+)/)?.[1]??"txt",x=k==="package-install",M=()=>{let v=x?`${Z[n]} ${c.trim()}`:c.trim();navigator.clipboard.writeText(v),s(!0),setTimeout(()=>s(!1),2e3)};return H("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[H("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[!x&&g("span",{className:"text-xs text-gray-400 px-4 py-3",children:r||k}),x&&g("div",{className:"flex items-center px-3",children:Object.keys(Z).map(v=>g("button",{onClick:()=>i(v),className:`px-3 pb-2.5 pt-3 text-sm font-medium border-b-2 transition-all ${n===v?"border-gray-900 text-gray-900":"border-transparent text-gray-500 hover:text-gray-800"}`,children:v},v))}),t&&!x&&g("button",{onClick:M,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:b?g(ke,{className:"size-4 text-green-600"}):g(Ce,{className:"size-4"})})]}),g(ft,{theme:gt.vsLight,code:c.trim(),language:x?"bash":k,children:({tokens:v,getLineProps:q,getTokenProps:$})=>H("pre",{className:`p-4 font-mono whitespace-pre overflow-x-auto text-sm leading-relaxed ${t&&x?"flex items-center justify-between":""}`,children:[v.map((m,u)=>H("div",{...q({line:m}),children:[!x&&g("span",{className:"text-gray-400 mr-4 select-none",children:u+1}),x&&g("span",{className:"mr-2",children:Z[n]}),m.map((C,w)=>g("span",{...$({token:C})},w))]},u)),t&&x&&g("button",{onClick:M,className:"rounded-lg cursor-pointer p-2 text-gray-500 hover:bg-gray-100 transition",children:b?g(ke,{className:"size-4 text-green-600"}):g(Ce,{className:"size-4"})})]})})]})}export{ro as DocstraBody,co as DocstraCodeBlock,Ht as DocstraHeader,cr as DocstraPage,Et as DocstraProvider,l as useDocstra};
|
|
1
|
+
"use client";import{createContext as Ee,useContext as Be,useState as V}from"react";import{ToastContainer as Me}from"react-toast-msg";import{SearchIcon as Ie}from"lucide-react";import{twMerge as Se}from"tailwind-merge";import Le from"clsx";function f(...e){return Se(Le(e))}import{useEffect as K,useMemo as Oe,useState as J}from"react";import Pe from"fuse.js";import Re from"next/link";import{useRouter as Te}from"next/navigation";import{Fragment as ze,jsx as D,jsxs as G}from"react/jsx-runtime";function j(){let{openSearchBox:e,setOpenSearchBox:r,docs:t}=l(),[o,a]=J(""),[n,i]=J([]),d=Te();K(()=>{let s=p=>{p.ctrlKey&&p.key==="k"&&(p.preventDefault(),r(!0))};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[]);let c=Oe(()=>!t||t.length===0?null:new Pe(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);K(()=>{if(o&&c){let s=c.search(o);i(s.map(p=>p.item))}else o||i([])},[o,c]);let b=s=>{if(s.preventDefault(),o){let p=n[0];p&&(d.push(`/docs/${p.slug}`),a(""),r(!1))}};return K(()=>{let s=p=>{p.key==="Escape"&&(r(!1),a(""))};return e&&window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[e]),D("div",{onClick:()=>{r(!1),a("")},className:f("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:G("div",{onClick:s=>s.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[D("form",{onSubmit:b,className:f("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",o&&"rounded-b-none border-b-0"),children:e&&G(ze,{children:[D(Ie,{className:"size-5.5 mx-3 shrink-0"}),D("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:o,onChange:s=>a(s.target.value),name:"searchQuery",required:!0}),D("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),G("div",{className:f("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",o&&"rounded-b-md border border-slate-200"),children:[n.map(s=>G(Re,{href:`/docs/${s.slug==="index"?"":s.slug}`,onClick:()=>{r(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[D("h4",{className:"font-medium",children:s.data?.metadata?.title||s.slug}),D("p",{className:"text-sm mt-1 text-gray-500",children:s.data?.metadata?.description})]},s.slug)),o&&n.length===0&&D("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}import{jsx as ee,jsxs as $e}from"react/jsx-runtime";var te=Ee(null);function Et({children:e,docstraConfig:r,docs:t,pageData:o,slug:a}){let n=o||(()=>{let k=Array.isArray(a)?a.length===0?"index":a.join("/"):a||"index";return t.find(h=>h.slug===k)})();if(!n)throw new Error("Page not found");let[i,d]=V(!1),[c,b]=V(!1),[s,p]=V("npm");return $e(te.Provider,{value:{openSidebar:i,setOpenSidebar:d,docstraConfig:r,openSearchBox:c,setOpenSearchBox:b,pageData:n,docs:t,packageManager:s,setPackageManager:p},children:[ee(Me,{}),ee(j,{}),e]})}function l(){let e=Be(te);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}import{TextAlignEnd as Ge,XIcon as Ae}from"lucide-react";import{useEffect as Fe}from"react";import Y from"next/link";import{jsx as N,jsxs as re}from"react/jsx-runtime";function Ht(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t}=l(),o="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return Fe(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),re("header",{className:"sticky top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[N(Y,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:N("img",{src:t.navbar?.logo?.src||"/logo.png",alt:t.navbar?.logo?.alt||"Logo",className:f("h-9.5 w-auto",t.navbar?.logo?.className)})}),re("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>N(Y,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),N(Y,{href:o||"https://github.com/sudhucodes/docstra",children:N("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:N("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),N("button",{onClick:()=>r(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?N(Ae,{className:"size-6.5"}):N(Ge,{className:"size-6.5"})})]})}import{SearchIcon as He}from"lucide-react";import{usePathname as qe}from"next/navigation";import*as Ue from"lucide-react";function oe(e){if(e)return Ue[e]}import Ke from"next/link";import{Fragment as Ve,jsx as y,jsxs as O}from"react/jsx-runtime";function ae(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t,setOpenSearchBox:o}=l(),a=qe();return O(Ve,{children:[y("div",{className:f("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>r(!1)}),O("aside",{className:f("sticky md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",e?"top-32":"top-full"),children:[O("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{r(e&&!1),o(!0)},children:[y(He,{className:"size-4.5"}),y("p",{children:"Search"}),O("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[y("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),y("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),t.sidebar?.links?.map(n=>O("div",{children:[y("p",{className:"inline-flex items-center gap-2 mb-2 mt-2 px-2",children:n.section}),y("ul",{className:"mb-4",children:n.items.map(i=>{let d=oe(i.icon);return y("li",{children:O(Ke,{href:i.href,onNavigate:()=>e&&r(!1),className:f("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",a===i.href&&"bg-gray-100 text-gray-800"),children:[d&&y(d,{className:"size-4"}),y("span",{children:i.name})]})},i.href)})})]},n.section))]})]})}import{ArrowUpCircleIcon as Ye,SquareArrowOutUpRightIcon as Qe,TextAlignStartIcon as _e}from"lucide-react";import{usePathname as We}from"next/navigation";import{useEffect as T,useRef as ne,useState as A}from"react";import{jsx as S,jsxs as z}from"react/jsx-runtime";function ie(){let[e,r]=A(null),[t,o]=A("down"),[a,n]=A(!1),[i,d]=A(!1),{docstraConfig:c,pageData:b}=l(),s=b?.path,p=b?.data?.tableOfContents||[],k=ne(0),h=ne(null),M=We(),q=`${"https://github.com/"+c?.editOnGithub?.owner+"/"+c?.editOnGithub?.repo}/edit/main/${c?.editOnGithub?.path}/${s}`;T(()=>{let m=()=>{let u=window.scrollY;o(u>k.current?"down":"up"),n(u>100),k.current=u};return window.addEventListener("scroll",m),()=>window.removeEventListener("scroll",m)},[]),T(()=>{let m=document.querySelectorAll("h2[id], h3[id]"),u=new IntersectionObserver(C=>{if(i)return;let w=C.filter(I=>I.isIntersecting).sort((I,De)=>I.boundingClientRect.top-De.boundingClientRect.top);if(w.length>0){let I=t==="down"?w[0].target.id:w[w.length-1].target.id;r(I)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return m.forEach(C=>u.observe(C)),h.current=u,()=>u.disconnect()},[M,t,i]),T(()=>{!(window.scrollY>100)&&r(p[0]?.id)},[p]),T(()=>{if(!e)return;let m=document.querySelector(".toc-scroll-container");if(!m)return;let u=m.querySelector(`a[href="#${e}"]`);if(!u)return;let C=m.getBoundingClientRect(),w=u.getBoundingClientRect();(w.top<C.top||w.bottom>C.bottom)&&u.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),T(()=>{if(!i)return;let m=setTimeout(()=>d(!1),800);return()=>clearTimeout(m)},[i]);let $=m=>{r(m),d(!0)};return z("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[z("p",{className:"flex items-center gap-2 mb-5",children:[S(_e,{className:"size-4"}),"On this page"]}),S("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:p.map(m=>z("li",{children:[S(se,{heading:m,activeId:e,handleClick:$}),m.children.map(u=>S(se,{heading:u,activeId:e,handleClick:$,className:"pl-8"},u.id))]},m.id))}),S("hr",{className:"my-6 border-gray-200"}),c.editOnGithub&&z("a",{href:q,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",S(Qe,{className:"size-4"})]}),a&&z("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",S(Ye,{className:"size-4"})]})]})}function se({heading:e,activeId:r,handleClick:t,className:o}){return S("a",{href:`#${e.id}`,className:f("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":r===e.id,"hover:text-gray-800 hover:border-gray-400":r!==e.id}),onClick:()=>t(e.id),children:e.text})}import{jsx as le,jsxs as Xe}from"react/jsx-runtime";function cr({children:e,toc:r=!0,sidebar:t=!0}){return Xe("div",{className:"min-h-screen flex bg-white w-full",children:[t&&le(ae,{}),e,r&&le(ie,{})]})}import{usePathname as Ze}from"next/navigation";import{ChevronRight as Je}from"lucide-react";import ce from"next/link";import{jsx as P,jsxs as me}from"react/jsx-runtime";function de(){let r=Ze().split("/").filter(Boolean),t=r.map((o,a)=>{let n="/"+r.slice(0,a+1).join("/"),i=o.replace(/-/g," ").replace(/\b\w/g,d=>d.toUpperCase());return{href:n,title:i}});return P("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:me("ol",{className:"flex items-center space-x-2",children:[P("li",{children:P(ce,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),t.map((o,a)=>{let n=a===t.length-1;return me("li",{className:"flex items-center space-x-2",children:[P(Je,{className:"w-4 h-4 text-gray-400"}),n?P("span",{className:"text-gray-600 font-medium",children:o.title}):P(ce,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}import{CheckIcon as je,CopyIcon as et}from"lucide-react";import{useEffect as tt,useState as pe}from"react";import{jsx as Q,jsxs as ue}from"react/jsx-runtime";function fe(){let{pageData:e}=l(),[r,t]=pe(!1),[o,a]=pe(null);tt(()=>{a(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return ue("div",{className:"flex items-center gap-3 mt-6",children:[ue("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),t(!0),setTimeout(()=>t(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[r?Q(je,{className:"size-3.5"}):Q(et,{className:"size-3.5"}),"Copy Markdown"]}),Q("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(n)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}import{Fragment as rt,jsx as F,jsxs as ot}from"react/jsx-runtime";function ge(){let{pageData:e}=l(),r=e?.data?.metadata?.title,t=e?.data?.metadata?.description;return ot(rt,{children:[F("h1",{className:"text-3xl font-bold",children:r}),F("p",{className:"my-4 text-gray-500",children:t}),F(fe,{}),F("hr",{className:"my-10 border-gray-200"})]})}import{useState as U}from"react";import{ThumbsUp as nt,ThumbsDown as st}from"lucide-react";import{jsx as _,jsxs as be}from"react/jsx-runtime";function W({label:e,type:r,placeholder:t="",id:o,required:a=!1,onChange:n,value:i,readOnly:d=!1,className:c="",optional:b=!1}){return be("div",{className:f("flex flex-col mt-4 w-full",c),children:[e&&be("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,b&&_("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),r==="textarea"?_("textarea",{id:o,name:o,className:f("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",c),placeholder:t,required:a,onChange:n,rows:4,value:i,readOnly:d,maxLength:500}):_("input",{type:r,id:o,name:o,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:t,required:a,onChange:n,value:i,readOnly:d,maxLength:500})]})}import{Loader2Icon as at}from"lucide-react";import{jsx as he}from"react/jsx-runtime";function X({label:e,loading:r,type:t="submit",className:o="",disabled:a=!1,onClick:n}){return he("button",{type:t,disabled:a,className:f("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",o),"aria-label":e,onClick:n,children:r?he(at,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}import{FormSyncButton as it,FormSyncForm as lt}from"formsync";import{Fragment as xe,jsx as x,jsxs as L}from"react/jsx-runtime";function ye(){let[e,r]=U(null),{docstraConfig:t}=l(),[o,a]=U(""),[n,i]=U(!1),[d,c]=U(null),b="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return x("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:n?L(xe,{children:[x("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),x(X,{onClick:()=>{i(!1),r(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):L(xe,{children:[x("p",{className:"font-medium",children:"How is this guide?"}),L("div",{className:"flex gap-2",children:[L("button",{onClick:()=>r("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[x(nt,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),L("button",{onClick:()=>r("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[x(st,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&L(lt,{className:"flex flex-col gap-2",formId:t?.feedback?.formSyncFormID||"",onSuccess:s=>{i(!0),r(null),a("")},onSubmitError:s=>{c(s.message)},children:[x(W,{value:o,id:"message",onChange:s=>a(s.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),d&&x("p",{className:"text-red-500",children:d}),x("input",{type:"hidden",name:"opinion",value:e}),x("input",{type:"hidden",name:"page",value:window.location.href}),x("input",{type:"hidden",name:"_redirect",value:window.location.href}),x(it,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),t?.feedback?.watermark!==!1&&L("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",x("a",{href:`https://www.formsync.app?utm_source=${b}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}import{jsxs as ct}from"react/jsx-runtime";function ve(){let{pageData:e}=l();if(!e?.data?.lastUpdated)return null;let r=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return ct("p",{className:"text-sm text-gray-500",children:["Last updated on ",r]})}import{usePathname as mt}from"next/navigation";import we from"next/link";import{ArrowLeftIcon as dt,ArrowRightIcon as pt}from"lucide-react";import{jsx as R,jsxs as E}from"react/jsx-runtime";function Ne(){let e=mt(),{docstraConfig:r}=l(),t=r?.sidebar?.links?.flatMap(i=>i.items),o=t.findIndex(i=>i.href===e),a=o>0?t[o-1]:null,n=o<t.length-1?t[o+1]:null;return E("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[a?E(we,{href:a.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[R("span",{className:"text-gray-500",children:"Previous"}),E("p",{className:"flex items-center font-medium",children:[R(dt,{className:"size-5 mr-2"}),a.name]})]}):R("div",{}),n?E(we,{href:n.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[R("span",{className:"text-gray-500",children:"Next"}),E("p",{className:"flex items-center font-medium",children:[n.name,R(pt,{className:"size-5 ml-2"})]})]}):R("div",{})]})}import{jsx as B,jsxs as ut}from"react/jsx-runtime";function ro({children:e}){let{docstraConfig:r}=l();return ut("main",{className:"flex-1 px-4 md:px-8 py-10 prose max-w-none",children:[B(de,{}),B(ge,{}),e,r?.feedback?.enabled&&B(ye,{}),B(ve,{}),B(Ne,{})]})}import{CheckIcon as ke,CopyIcon as Ce}from"lucide-react";import{Highlight as ft,themes as gt}from"prism-react-renderer";import{useState as bt}from"react";import{jsx as g,jsxs as H}from"react/jsx-runtime";var Z={npm:"npm install",pnpm:"pnpm add",yarn:"yarn add",bun:"bun add"};function co(e){let{filename:r,copyable:t,children:o,className:a}=e,{packageManager:n,setPackageManager:i}=l(),d=!a?.includes("language-"),c=typeof o=="string"?o:o?.props?.children||"";if(d)return g("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:c});let[b,s]=bt(!1),k=a?.match(/language-([\w-]+)/)?.[1]??"txt",h=k==="package-install",M=()=>{let v=h?`${Z[n]} ${c.trim()}`:c.trim();navigator.clipboard.writeText(v),s(!0),setTimeout(()=>s(!1),2e3)};return H("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[H("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[!h&&g("span",{className:"text-xs text-gray-400 px-4 py-3",children:r||k}),h&&g("div",{className:"flex items-center px-3",children:Object.keys(Z).map(v=>g("button",{onClick:()=>i(v),className:`px-3 pb-2.5 pt-3 text-sm font-medium border-b-2 transition-all ${n===v?"border-gray-900 text-gray-900":"border-transparent text-gray-500 hover:text-gray-800"}`,children:v},v))}),t&&!h&&g("button",{onClick:M,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:b?g(ke,{className:"size-4 text-green-600"}):g(Ce,{className:"size-4"})})]}),g(ft,{theme:gt.vsLight,code:c.trim(),language:h?"bash":k,children:({tokens:v,getLineProps:q,getTokenProps:$})=>H("pre",{className:`p-4 font-mono whitespace-pre overflow-x-auto text-sm leading-relaxed ${t&&h?"flex items-center justify-between":""}`,children:[v.map((m,u)=>H("div",{...q({line:m}),children:[!h&&g("span",{className:"text-gray-400 mr-4 select-none",children:u+1}),h&&g("span",{className:"mr-2",children:Z[n]}),m.map((C,w)=>g("span",{...$({token:C})},w))]},u)),t&&h&&g("button",{onClick:M,className:"rounded-lg cursor-pointer p-2 text-gray-500 hover:bg-gray-100 transition",children:b?g(ke,{className:"size-4 text-green-600"}):g(Ce,{className:"size-4"})})]})})]})}export{ro as DocstraBody,co as DocstraCodeBlock,Ht as DocstraHeader,cr as DocstraPage,Et as DocstraProvider,l as useDocstra};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`),r=[],
|
|
1
|
+
"use strict";var S=Object.create;var p=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var P=(e,t)=>{for(var r in t)p(e,r,{get:t[r],enumerable:!0})},d=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of v(t))!O.call(e,o)&&o!==r&&p(e,o,{get:()=>t[o],enumerable:!(a=k(t,o))||a.enumerable});return e};var m=(e,t,r)=>(r=e!=null?S(F(e)):{},d(t||!e||!e.__esModule?p(r,"default",{value:e,enumerable:!0}):r,e)),E=e=>d(p({},"__esModule",{value:!0}),e);var J={};P(J,{default:()=>y});module.exports=E(J);var h=m(require("gray-matter"));function l(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function f(e){let t=e.split(`
|
|
2
|
+
`),r=[],a=null;for(let o of t){o=o.trim();let s=o.match(/^##\s+(.*)/),i=o.match(/^###\s+(.*)/);if(s){let n=s[1].trim();a={id:l(n),text:n,children:[]},r.push(a)}if(i&&a){let n=i[1].trim(),c=l(n);a.children.push({id:c,text:n})}}return r}var g=require("unist-util-visit");function u(){return e=>{(0,g.visit)(e,"element",t=>{if(t.tagName!=="code")return;t.properties||(t.properties={});let r=t.data?.meta||"";if(r){let a=/(\w+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"']+)))?/g,o;for(;(o=a.exec(r))!==null;){let s=o[1],i=o[2]||o[3]||o[4]||!0;t.properties[s]=i}}Array.isArray(t.properties.className)&&(t.properties.className=t.properties.className.join(" "))})}}var x=require("child_process");async function y(e){let t=this.async();try{let{compile:r}=await import("@mdx-js/mdx"),a=await import("remark-gfm"),{content:o,data:s}=(0,h.default)(e),i=await r(o,{outputFormat:"program",development:this.mode==="development",remarkPlugins:[a.default],rehypePlugins:[[u]]}),n=null;try{n=(0,x.execSync)(`git log -1 --format=%aI "${this.resourcePath}"`,{encoding:"utf-8"}).trim()}catch{n=null}let c=`export const metadata = ${JSON.stringify(s)};`,C=`export const raw = ${JSON.stringify(e)};`,$=f(e),H=`export const tableOfContents = ${JSON.stringify($)};`,w="export const mdxContent = MDXContent;",M=`export const lastUpdated = ${JSON.stringify(n)};`,N=`
|
|
3
3
|
${i.value}
|
|
4
|
-
${s}
|
|
5
4
|
${c}
|
|
6
|
-
${
|
|
5
|
+
${C}
|
|
7
6
|
${H}
|
|
8
7
|
${w}
|
|
9
|
-
|
|
8
|
+
${M}
|
|
9
|
+
`;t(null,N)}catch(r){t(r)}}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
`),o=[],n=null;for(let e of t){e=e.trim();let
|
|
1
|
+
import C from"gray-matter";function p(r){return r.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function m(r){let t=r.split(`
|
|
2
|
+
`),o=[],n=null;for(let e of t){e=e.trim();let s=e.match(/^##\s+(.*)/),i=e.match(/^###\s+(.*)/);if(s){let a=s[1].trim();n={id:p(a),text:a,children:[]},o.push(n)}if(i&&n){let a=i[1].trim(),c=p(a);n.children.push({id:c,text:a})}}return o}import{visit as y}from"unist-util-visit";function l(){return r=>{y(r,"element",t=>{if(t.tagName!=="code")return;t.properties||(t.properties={});let o=t.data?.meta||"";if(o){let n=/(\w+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"']+)))?/g,e;for(;(e=n.exec(o))!==null;){let s=e[1],i=e[2]||e[3]||e[4]||!0;t.properties[s]=i}}Array.isArray(t.properties.className)&&(t.properties.className=t.properties.className.join(" "))})}}import{execSync as $}from"child_process";async function H(r){let t=this.async();try{let{compile:o}=await import("@mdx-js/mdx"),n=await import("remark-gfm"),{content:e,data:s}=C(r),i=await o(e,{outputFormat:"program",development:this.mode==="development",remarkPlugins:[n.default],rehypePlugins:[[l]]}),a=null;try{a=$(`git log -1 --format=%aI "${this.resourcePath}"`,{encoding:"utf-8"}).trim()}catch{a=null}let c=`export const metadata = ${JSON.stringify(s)};`,d=`export const raw = ${JSON.stringify(r)};`,f=m(r),g=`export const tableOfContents = ${JSON.stringify(f)};`,u="export const mdxContent = MDXContent;",h=`export const lastUpdated = ${JSON.stringify(a)};`,x=`
|
|
3
3
|
${i.value}
|
|
4
|
-
${s}
|
|
5
4
|
${c}
|
|
5
|
+
${d}
|
|
6
6
|
${g}
|
|
7
|
-
${f}
|
|
8
7
|
${u}
|
|
9
|
-
|
|
8
|
+
${h}
|
|
9
|
+
`;t(null,x)}catch(o){t(o)}}export{H as default};
|
package/dist/server/index.d.mts
CHANGED
|
@@ -20,6 +20,13 @@ declare const defaultMdxComponents: {
|
|
|
20
20
|
ol: (props: any) => react_jsx_runtime.JSX.Element;
|
|
21
21
|
blockquote: (props: any) => react_jsx_runtime.JSX.Element;
|
|
22
22
|
pre: (props: any) => react_jsx_runtime.JSX.Element;
|
|
23
|
+
Callout: (props: any) => react_jsx_runtime.JSX.Element;
|
|
24
|
+
table: (props: any) => react_jsx_runtime.JSX.Element;
|
|
25
|
+
thead: (props: any) => react_jsx_runtime.JSX.Element;
|
|
26
|
+
tbody: (props: any) => react_jsx_runtime.JSX.Element;
|
|
27
|
+
tr: (props: any) => react_jsx_runtime.JSX.Element;
|
|
28
|
+
th: (props: any) => react_jsx_runtime.JSX.Element;
|
|
29
|
+
td: (props: any) => react_jsx_runtime.JSX.Element;
|
|
23
30
|
};
|
|
24
31
|
|
|
25
32
|
declare function getPageData(slug: string[], docs: any[]): any;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -20,6 +20,13 @@ declare const defaultMdxComponents: {
|
|
|
20
20
|
ol: (props: any) => react_jsx_runtime.JSX.Element;
|
|
21
21
|
blockquote: (props: any) => react_jsx_runtime.JSX.Element;
|
|
22
22
|
pre: (props: any) => react_jsx_runtime.JSX.Element;
|
|
23
|
+
Callout: (props: any) => react_jsx_runtime.JSX.Element;
|
|
24
|
+
table: (props: any) => react_jsx_runtime.JSX.Element;
|
|
25
|
+
thead: (props: any) => react_jsx_runtime.JSX.Element;
|
|
26
|
+
tbody: (props: any) => react_jsx_runtime.JSX.Element;
|
|
27
|
+
tr: (props: any) => react_jsx_runtime.JSX.Element;
|
|
28
|
+
th: (props: any) => react_jsx_runtime.JSX.Element;
|
|
29
|
+
td: (props: any) => react_jsx_runtime.JSX.Element;
|
|
23
30
|
};
|
|
24
31
|
|
|
25
32
|
declare function getPageData(slug: string[], docs: any[]): any;
|
package/dist/server/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
slug: "${
|
|
3
|
-
path: "${
|
|
1
|
+
"use strict";var R=Object.create;var b=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var U=(e,t)=>{for(var r in t)b(e,r,{get:t[r],enumerable:!0})},N=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of A(t))!H.call(e,n)&&n!==r&&b(e,n,{get:()=>t[n],enumerable:!(o=L(t,n))||o.enumerable});return e};var c=(e,t,r)=>(r=e!=null?R(B(e)):{},N(t||!e||!e.__esModule?b(r,"default",{value:e,enumerable:!0}):r,e)),z=e=>N(b({},"__esModule",{value:!0}),e);var Z={};U(Z,{createSource:()=>Y,defaultMdxComponents:()=>G,defineDocstraConfig:()=>V,getPageData:()=>K,withDocstra:()=>Q});module.exports=z(Z);function V(e){return e}var u=c(require("fs")),p=c(require("path"));var d={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m"},i={info:e=>{console.log(`${d.blue}[Docstra]${d.reset} ${e}`)},success:e=>{console.log(`${d.green}[Docstra]${d.reset} ${e}`)},warn:e=>{console.warn(`${d.yellow}[Docstra Warning]${d.reset} ${e}`)},error:(e,t)=>{console.error(`${d.red}[Docstra Error]${d.reset} ${e}`),t&&console.error(t)}};function y(e){let t=process.cwd(),r=p.default.join(t,".docstra"),o=p.default.join(r,"index.ts");u.default.existsSync(e)||(i.error(`Content directory not found: ${e}`),i.error(`Please create "${e}" or update "contentDir" in docstra.config.ts`),process.exit(1)),u.default.existsSync(r)||u.default.mkdirSync(r,{recursive:!0});let n=T(e);n.length===0&&i.warn(`No .md or .mdx files found in ${e}`);let s=[],l=[];n.forEach((w,W)=>{let _=p.default.relative(r,w).replace(/\\/g,"/"),f=`d${W}`;s.push(`import * as ${f} from "${_}?docstra";`);let v=p.default.relative(e,w).replace(/\\/g,"/"),M=X(v);l.push(`{
|
|
2
|
+
slug: "${M}",
|
|
3
|
+
path: "${v}",
|
|
4
4
|
data: {
|
|
5
|
-
metadata: ${
|
|
6
|
-
raw: ${
|
|
7
|
-
tableOfContents: ${
|
|
8
|
-
mdxContent: ${
|
|
9
|
-
lastUpdated: ${
|
|
5
|
+
metadata: ${f}.metadata,
|
|
6
|
+
raw: ${f}.raw,
|
|
7
|
+
tableOfContents: ${f}.tableOfContents,
|
|
8
|
+
mdxContent: ${f}.mdxContent,
|
|
9
|
+
lastUpdated: ${f}.lastUpdated,
|
|
10
10
|
}
|
|
11
|
-
}`)});let
|
|
11
|
+
}`)});let O=`// @ts-nocheck -- auto generated by docstra
|
|
12
12
|
${s.join(`
|
|
13
13
|
`)}
|
|
14
14
|
|
|
15
15
|
export const docs = [
|
|
16
|
-
${
|
|
16
|
+
${l.join(`,
|
|
17
17
|
`)}
|
|
18
18
|
];
|
|
19
|
-
`;
|
|
19
|
+
`;u.default.writeFileSync(o,O,"utf8")}function T(e){return u.default.readdirSync(e).flatMap(t=>{let r=p.default.join(e,t);return u.default.statSync(r).isDirectory()?T(r):t.endsWith(".md")||t.endsWith(".mdx")?[r]:[]})}function X(e){return e.replace(/\\/g,"/").replace(/\/index\.(md|mdx)$/,"").replace(/\.(md|mdx)$/,"")}var k=!1,D=null;async function S(e){if(k)return;k=!0,await y(e);let{FSWatcher:t}=await import("chokidar"),r="docstra.config.ts",o=new t({ignoreInitial:!0,persistent:!0,ignored:["node_modules",".next"]});o.add([e,r]),i.info("Dev server started..."),o.on("all",async(n,s)=>{!s.endsWith(".md")&&!s.endsWith(".mdx")&&!s.endsWith("docstra.config.ts")||(D&&clearTimeout(D),D=setTimeout(async()=>{await y(e)},200),i.info("MDX content rebuilt successfully"))}),process.on("exit",()=>{o.closed||o.close()})}var $=c(require("path")),F=c(require("fs"));var J="docs/content";function E(){let e=process.cwd(),t=$.default.join(e,"docstra.config.ts"),r={};if(F.default.existsSync(t))try{delete require.cache[require.resolve(t)];let n=require(t);r=n.default??n}catch(n){i.error("Failed to load docstra.config.ts",n),process.exit(1)}else i.warn("No docstra.config.ts found, using defaults");let o=r.contentDir?$.default.resolve(e,r.contentDir):$.default.join(e,J);return{root:e,contentDir:o,userConfig:r}}var P=!1;function Q(e={}){let t=process.env.NODE_ENV==="development",r=process.env.NODE_ENV==="production",o=E().contentDir;P||(P=!0,t&&S(o),r&&(y(o),i.info("MDX content generated successfully")));let n={...e.turbopack,rules:{...e.turbopack?.rules,"*.{md,mdx}":{loaders:[{loader:require.resolve("./docstra-loader")}],as:"*.js"}}};return{...e,turbopack:n,pageExtensions:e.pageExtensions??["ts","tsx","js","jsx","md","mdx"],webpack:(s,l)=>(s.module.rules.push({test:/\.(md|mdx)$/,resourceQuery:/docstra/,use:[{loader:require.resolve("./docstra-loader")}]}),typeof e.webpack=="function"?e.webpack(s,l):s)}}var m=require("lucide-react"),x=require("react/jsx-runtime");function C({type:e="info",children:t}){let r={info:"border-blue-500 bg-blue-50 text-blue-500",warning:"border-yellow-500 bg-yellow-50 text-yellow-500",error:"border-red-500 bg-red-50 text-red-500"},n={info:m.InfoIcon,warning:m.AlertTriangleIcon,error:m.AlertCircleIcon}[e];return(0,x.jsxs)("div",{className:`flex not-prose items-center gap-2 border-l-4 ${r[e]} px-4 py-2.5`,children:[(0,x.jsx)(n,{className:"w-5 h-5 shrink-0"}),(0,x.jsx)("div",{children:t})]})}var j=require("lucide-react");function I(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}var h=require("react/jsx-runtime");function g({children:e,level:t}){let r=`h${t}`,n=I(typeof e=="string"?e:"");return(0,h.jsxs)(r,{id:n,className:"group",children:[(0,h.jsx)("a",{className:"not-prose",href:`#${n}`,children:e}),(0,h.jsx)(j.LinkIcon,{className:"inline-block ml-2 size-5 text-gray-400 opacity-0 group-hover:opacity-100 transition"})]})}var q=c(require("next/link")),a=require("react/jsx-runtime"),G={h1:e=>(0,a.jsx)("h1",{className:"text-3xl font-bold text-gray-900",children:e.children}),h2:e=>(0,a.jsx)(g,{...e,level:2}),h3:e=>(0,a.jsx)(g,{...e,level:3}),h4:e=>(0,a.jsx)(g,{...e,level:4}),h5:e=>(0,a.jsx)(g,{...e,level:5}),p:e=>(0,a.jsx)("p",{children:e.children}),hr:e=>(0,a.jsx)("hr",{...e,className:"border-gray-200"}),a:e=>e.href.startsWith("http")?(0,a.jsx)("a",{href:e.href,className:"underline underline-offset-4",...e,target:"_blank",rel:"noopener noreferrer",children:e.children}):(0,a.jsx)(q.default,{href:e.href,className:"underline underline-offset-4",...e,children:e.children}),ul:e=>(0,a.jsx)("ul",{children:e.children}),li:e=>(0,a.jsx)("li",{children:e.children}),ol:e=>(0,a.jsx)("ol",{children:e.children}),blockquote:e=>(0,a.jsx)("blockquote",{className:"not-italic",children:e.children}),pre:e=>(0,a.jsx)("pre",{className:"not-prose",children:e.children}),Callout:e=>(0,a.jsx)(C,{...e}),table:e=>(0,a.jsx)("table",{children:e.children}),thead:e=>(0,a.jsx)("thead",{children:e.children}),tbody:e=>(0,a.jsx)("tbody",{children:e.children}),tr:e=>(0,a.jsx)("tr",{children:e.children}),th:e=>(0,a.jsx)("th",{children:e.children}),td:e=>(0,a.jsx)("td",{children:e.children})};function K(e,t){return t.find(o=>o.slug===(e?.join("/")||"index"))}function Y(e){return{getPage:t=>{let r=t?.join("/")||"index",o=e.find(l=>l.slug===r);if(!o)return null;let{mdxContent:n,...s}=o.data;return{info:{...o,data:s},body:o.data.mdxContent}},generateStaticParams:()=>e.map(t=>({slug:t.slug==="index"?[]:t.slug.split("/")})),files:e.map(t=>{let{mdxContent:r,...o}=t.data;return{...t,data:o}}),generateSitemap:({baseUrl:t,lastmod:r,changefreq:o,priority:n})=>e.map(s=>{let l=s.slug==="index"?"":s.slug.replace(/\/?index$/,"");return{url:`${t}/${l}`.replace(/\/$/,""),lastModified:r,changeFrequency:o,priority:n}})}}0&&(module.exports={createSource,defaultMdxComponents,defineDocstraConfig,getPageData,withDocstra});
|
package/dist/server/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var d=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});function
|
|
2
|
-
slug: "${
|
|
1
|
+
var d=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});function U(e){return e}import f from"fs";import m from"path";var c={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m"},i={info:e=>{console.log(`${c.blue}[Docstra]${c.reset} ${e}`)},success:e=>{console.log(`${c.green}[Docstra]${c.reset} ${e}`)},warn:e=>{console.warn(`${c.yellow}[Docstra Warning]${c.reset} ${e}`)},error:(e,t)=>{console.error(`${c.red}[Docstra Error]${c.reset} ${e}`),t&&console.error(t)}};function g(e){let t=process.cwd(),r=m.join(t,".docstra"),o=m.join(r,"index.ts");f.existsSync(e)||(i.error(`Content directory not found: ${e}`),i.error(`Please create "${e}" or update "contentDir" in docstra.config.ts`),process.exit(1)),f.existsSync(r)||f.mkdirSync(r,{recursive:!0});let a=D(e);a.length===0&&i.warn(`No .md or .mdx files found in ${e}`);let s=[],l=[];a.forEach((b,E)=>{let P=m.relative(r,b).replace(/\\/g,"/"),u=`d${E}`;s.push(`import * as ${u} from "${P}?docstra";`);let $=m.relative(e,b).replace(/\\/g,"/"),I=j($);l.push(`{
|
|
2
|
+
slug: "${I}",
|
|
3
3
|
path: "${$}",
|
|
4
4
|
data: {
|
|
5
5
|
metadata: ${u}.metadata,
|
|
@@ -8,12 +8,12 @@ var d=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(t
|
|
|
8
8
|
mdxContent: ${u}.mdxContent,
|
|
9
9
|
lastUpdated: ${u}.lastUpdated,
|
|
10
10
|
}
|
|
11
|
-
}`)});let
|
|
11
|
+
}`)});let F=`// @ts-nocheck -- auto generated by docstra
|
|
12
12
|
${s.join(`
|
|
13
13
|
`)}
|
|
14
14
|
|
|
15
15
|
export const docs = [
|
|
16
|
-
${
|
|
16
|
+
${l.join(`,
|
|
17
17
|
`)}
|
|
18
18
|
];
|
|
19
|
-
`;
|
|
19
|
+
`;f.writeFileSync(o,F,"utf8")}function D(e){return f.readdirSync(e).flatMap(t=>{let r=m.join(e,t);return f.statSync(r).isDirectory()?D(r):t.endsWith(".md")||t.endsWith(".mdx")?[r]:[]})}function j(e){return e.replace(/\\/g,"/").replace(/\/index\.(md|mdx)$/,"").replace(/\.(md|mdx)$/,"")}var C=!1,y=null;async function w(e){if(C)return;C=!0,await g(e);let{FSWatcher:t}=await import("chokidar"),r="docstra.config.ts",o=new t({ignoreInitial:!0,persistent:!0,ignored:["node_modules",".next"]});o.add([e,r]),i.info("Dev server started..."),o.on("all",async(a,s)=>{!s.endsWith(".md")&&!s.endsWith(".mdx")&&!s.endsWith("docstra.config.ts")||(y&&clearTimeout(y),y=setTimeout(async()=>{await g(e)},200),i.info("MDX content rebuilt successfully"))}),process.on("exit",()=>{o.closed||o.close()})}import x from"path";import q from"fs";var O="docs/content";function v(){let e=process.cwd(),t=x.join(e,"docstra.config.ts"),r={};if(q.existsSync(t))try{delete d.cache[d.resolve(t)];let a=d(t);r=a.default??a}catch(a){i.error("Failed to load docstra.config.ts",a),process.exit(1)}else i.warn("No docstra.config.ts found, using defaults");let o=r.contentDir?x.resolve(e,r.contentDir):x.join(e,O);return{root:e,contentDir:o,userConfig:r}}var N=!1;function ce(e={}){let t=process.env.NODE_ENV==="development",r=process.env.NODE_ENV==="production",o=v().contentDir;N||(N=!0,t&&w(o),r&&(g(o),i.info("MDX content generated successfully")));let a={...e.turbopack,rules:{...e.turbopack?.rules,"*.{md,mdx}":{loaders:[{loader:d.resolve("./docstra-loader")}],as:"*.js"}}};return{...e,turbopack:a,pageExtensions:e.pageExtensions??["ts","tsx","js","jsx","md","mdx"],webpack:(s,l)=>(s.module.rules.push({test:/\.(md|mdx)$/,resourceQuery:/docstra/,use:[{loader:d.resolve("./docstra-loader")}]}),typeof e.webpack=="function"?e.webpack(s,l):s)}}import{AlertTriangleIcon as W,InfoIcon as _,AlertCircleIcon as M}from"lucide-react";import{jsx as T,jsxs as R}from"react/jsx-runtime";function h({type:e="info",children:t}){let r={info:"border-blue-500 bg-blue-50 text-blue-500",warning:"border-yellow-500 bg-yellow-50 text-yellow-500",error:"border-red-500 bg-red-50 text-red-500"},a={info:_,warning:W,error:M}[e];return R("div",{className:`flex not-prose items-center gap-2 border-l-4 ${r[e]} px-4 py-2.5`,children:[T(a,{className:"w-5 h-5 shrink-0"}),T("div",{children:t})]})}import{LinkIcon as L}from"lucide-react";function k(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}import{jsx as S,jsxs as A}from"react/jsx-runtime";function p({children:e,level:t}){let r=`h${t}`,a=k(typeof e=="string"?e:"");return A(r,{id:a,className:"group",children:[S("a",{className:"not-prose",href:`#${a}`,children:e}),S(L,{className:"inline-block ml-2 size-5 text-gray-400 opacity-0 group-hover:opacity-100 transition"})]})}import B from"next/link";import{jsx as n}from"react/jsx-runtime";var we={h1:e=>n("h1",{className:"text-3xl font-bold text-gray-900",children:e.children}),h2:e=>n(p,{...e,level:2}),h3:e=>n(p,{...e,level:3}),h4:e=>n(p,{...e,level:4}),h5:e=>n(p,{...e,level:5}),p:e=>n("p",{children:e.children}),hr:e=>n("hr",{...e,className:"border-gray-200"}),a:e=>e.href.startsWith("http")?n("a",{href:e.href,className:"underline underline-offset-4",...e,target:"_blank",rel:"noopener noreferrer",children:e.children}):n(B,{href:e.href,className:"underline underline-offset-4",...e,children:e.children}),ul:e=>n("ul",{children:e.children}),li:e=>n("li",{children:e.children}),ol:e=>n("ol",{children:e.children}),blockquote:e=>n("blockquote",{className:"not-italic",children:e.children}),pre:e=>n("pre",{className:"not-prose",children:e.children}),Callout:e=>n(h,{...e}),table:e=>n("table",{children:e.children}),thead:e=>n("thead",{children:e.children}),tbody:e=>n("tbody",{children:e.children}),tr:e=>n("tr",{children:e.children}),th:e=>n("th",{children:e.children}),td:e=>n("td",{children:e.children})};function Te(e,t){return t.find(o=>o.slug===(e?.join("/")||"index"))}function Se(e){return{getPage:t=>{let r=t?.join("/")||"index",o=e.find(l=>l.slug===r);if(!o)return null;let{mdxContent:a,...s}=o.data;return{info:{...o,data:s},body:o.data.mdxContent}},generateStaticParams:()=>e.map(t=>({slug:t.slug==="index"?[]:t.slug.split("/")})),files:e.map(t=>{let{mdxContent:r,...o}=t.data;return{...t,data:o}}),generateSitemap:({baseUrl:t,lastmod:r,changefreq:o,priority:a})=>e.map(s=>{let l=s.slug==="index"?"":s.slug.replace(/\/?index$/,"");return{url:`${t}/${l}`.replace(/\/$/,""),lastModified:r,changeFrequency:o,priority:a}})}}export{Se as createSource,we as defaultMdxComponents,U as defineDocstraConfig,Te as getPageData,ce as withDocstra};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docstra",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.8",
|
|
4
4
|
"bin": {
|
|
5
5
|
"docstra": "cli/index.js"
|
|
6
6
|
},
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "pnpm run build:ts && pnpm run build:css",
|
|
32
|
-
"dev": "tsup --watch",
|
|
32
|
+
"dev": "tsup --watch ./src",
|
|
33
33
|
"build:ts": "tsup",
|
|
34
34
|
"build:css": "pnpx @tailwindcss/cli -i ./src/styles/input.css -o ./dist/styles.css",
|
|
35
35
|
"prettier": "prettier --write src"
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"react": "^18 || ^19",
|
|
61
61
|
"react-dom": "^18 || ^19",
|
|
62
62
|
"react-toast-msg": "^2.5.5",
|
|
63
|
+
"remark-gfm": "^4.0.1",
|
|
63
64
|
"tailwind-merge": "^3.4.0",
|
|
64
65
|
"unist-util-visit": "^5.0.0"
|
|
65
66
|
},
|