docstra 1.9.6 → 1.9.7
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.d.mts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.mjs +1 -1
- package/dist/server/index.d.mts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/{types-DYyitlml.d.mts → types-CLQX-iqJ.d.mts} +2 -0
- package/dist/{types-DYyitlml.d.ts → types-CLQX-iqJ.d.ts} +2 -0
- package/package.json +1 -1
package/dist/client/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1 from 'react';
|
|
3
|
-
import { D as DocstraConfig, p as pageDataContent, a as DocstraContextType } from '../types-
|
|
3
|
+
import { D as DocstraConfig, p as pageDataContent, a as DocstraContextType } from '../types-CLQX-iqJ.mjs';
|
|
4
4
|
|
|
5
5
|
declare function DocstraProvider({ children, docstraConfig, docs, pageData: initialPageData, slug }: {
|
|
6
6
|
children: React$1.ReactNode;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1 from 'react';
|
|
3
|
-
import { D as DocstraConfig, p as pageDataContent, a as DocstraContextType } from '../types-
|
|
3
|
+
import { D as DocstraConfig, p as pageDataContent, a as DocstraContextType } from '../types-CLQX-iqJ.js';
|
|
4
4
|
|
|
5
5
|
declare function DocstraProvider({ children, docstraConfig, docs, pageData: initialPageData, slug }: {
|
|
6
6
|
children: React$1.ReactNode;
|
package/dist/client/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var Ae=Object.create;var q=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var $e=Object.getPrototypeOf,Me=Object.prototype.hasOwnProperty;var qe=(e,r)=>{for(var t in r)q(e,t,{get:r[t],enumerable:!0})},se=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of He(r))!Me.call(e,a)&&a!==t&&q(e,a,{get:()=>r[a],enumerable:!(o=Ue(r,a))||o.enumerable});return e};var L=(e,r,t)=>(t=e!=null?Ae($e(e)):{},se(r||!e||!e.__esModule?q(t,"default",{value:e,enumerable:!0}):t,e)),Ke=e=>se(q({},"__esModule",{value:!0}),e);var Ze={};qe(Ze,{DocstraBody:()=>We,DocstraCodeBlock:()=>Xe,DocstraHeader:()=>Ye,DocstraPage:()=>_e,DocstraProvider:()=>Ve,useDocstra:()=>c});module.exports=Ke(Ze);var P=require("react"),fe=require("react-toast-msg");var ce=require("lucide-react");var ie=require("tailwind-merge"),le=L(require("clsx"));function f(...e){return(0,ie.twMerge)((0,le.default)(e))}var D=require("react"),me=L(require("fuse.js")),de=L(require("next/link")),pe=require("next/navigation"),h=require("react/jsx-runtime");function ue(){let{openSearchBox:e,setOpenSearchBox:r,docs:t}=c(),[o,a]=(0,D.useState)(""),[n,s]=(0,D.useState)([]),m=(0,pe.useRouter)();(0,D.useEffect)(()=>{let i=p=>{p.ctrlKey&&p.key==="k"&&(p.preventDefault(),r(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let g=(0,D.useMemo)(()=>!t||t.length===0?null:new me.default(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);(0,D.useEffect)(()=>{if(o&&g){let i=g.search(o);s(i.map(p=>p.item))}else o||s([])},[o,g]);let w=i=>{if(i.preventDefault(),o){let p=n[0];p&&(m.push(`/docs/${p.slug}`),a(""),r(!1))}};return(0,D.useEffect)(()=>{let i=p=>{p.key==="Escape"&&(r(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),(0,h.jsx)("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:(0,h.jsxs)("div",{onClick:i=>i.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: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&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(ce.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:i=>a(i.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: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(i=>(0,h.jsxs)(de.default,{href:`/docs/${i.slug==="index"?"":i.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:i.data?.metadata?.title||i.slug}),(0,h.jsx)("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&n.length===0&&(0,h.jsx)("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}var G=require("react/jsx-runtime"),ge=(0,P.createContext)(null);function Ve({children:e,docstraConfig:r,docs:t,pageData:o,slug:a}){let n=o||(()=>{let i=Array.isArray(a)?a.length===0?"index":a.join("/"):a||"index";return t.find(p=>p.slug===i)})(),[s,m]=(0,P.useState)(!1),[g,w]=(0,P.useState)(!1);return(0,G.jsxs)(ge.Provider,{value:{openSidebar:s,setOpenSidebar:m,docstraConfig:r,openSearchBox:g,setOpenSearchBox:w,pageData:n,docs:t},children:[(0,G.jsx)(fe.ToastContainer,{}),(0,G.jsx)(ue,{}),e]})}function c(){let e=(0,P.useContext)(ge);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}var V=require("lucide-react"),he=require("react");var K=L(require("next/link")),N=require("react/jsx-runtime");function Ye(){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,N.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,N.jsx)(K.default,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:(0,N.jsx)("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)})}),(0,N.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>(0,N.jsx)(K.default,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),(0,N.jsx)(K.default,{href:o||"https://github.com/sudhucodes/docstra",children:(0,N.jsx)("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,N.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,N.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,N.jsx)(V.XIcon,{className:"size-6.5"}):(0,N.jsx)(V.TextAlignEnd,{className:"size-6.5"})})]})}var xe=require("lucide-react"),ye=require("next/navigation");var Qe=L(require("lucide-react"));function be(e){if(e)return Qe[e]}var ve=L(require("next/link")),d=require("react/jsx-runtime");function we(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t,setOpenSearchBox:o}=c(),a=(0,ye.usePathname)();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("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)}),(0,d.jsxs)("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:[(0,d.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,d.jsx)(xe.SearchIcon,{className:"size-4.5"}),(0,d.jsx)("p",{children:"Search"}),(0,d.jsxs)("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[(0,d.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),(0,d.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),t.sidebar?.links?.map(n=>(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"inline-flex items-center gap-2 mb-2 mt-2 px-2",children:n.section}),(0,d.jsx)("ul",{className:"mb-4",children:n.items.map(s=>{let m=be(s.icon);return(0,d.jsx)("li",{children:(0,d.jsxs)(ve.default,{href:s.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===s.href&&"bg-gray-100 text-gray-800"),children:[m&&(0,d.jsx)(m,{className:"size-4"}),(0,d.jsx)("span",{children:s.name})]})},s.href)})})]},n.section))]})]})}var B=require("lucide-react"),ke=require("next/navigation"),y=require("react");var b=require("react/jsx-runtime");function Ce(){let[e,r]=(0,y.useState)(null),[t,o]=(0,y.useState)("down"),[a,n]=(0,y.useState)(!1),[s,m]=(0,y.useState)(!1),{docstraConfig:g,pageData:w}=c(),i=w?.path,p=w?.data?.tableOfContents||[],H=(0,y.useRef)(0),J=(0,y.useRef)(null),$=(0,ke.usePathname)(),ee=`${"https://github.com/"+g?.editOnGithub?.owner+"/"+g?.editOnGithub?.repo}/edit/main/${g?.editOnGithub?.path}/${i}`;(0,y.useEffect)(()=>{let u=()=>{let x=window.scrollY;o(x>H.current?"down":"up"),n(x>100),H.current=x};return window.addEventListener("scroll",u),()=>window.removeEventListener("scroll",u)},[]),(0,y.useEffect)(()=>{let u=document.querySelectorAll("h2[id], h3[id]"),x=new IntersectionObserver(E=>{if(s)return;let O=E.filter(z=>z.isIntersecting).sort((z,Fe)=>z.boundingClientRect.top-Fe.boundingClientRect.top);if(O.length>0){let z=t==="down"?O[0].target.id:O[O.length-1].target.id;r(z)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return u.forEach(E=>x.observe(E)),J.current=x,()=>x.disconnect()},[$,t,s]),(0,y.useEffect)(()=>{!(window.scrollY>100)&&r(p[0]?.id)},[p]),(0,y.useEffect)(()=>{if(!e)return;let u=document.querySelector(".toc-scroll-container");if(!u)return;let x=u.querySelector(`a[href="#${e}"]`);if(!x)return;let E=u.getBoundingClientRect(),O=x.getBoundingClientRect();(O.top<E.top||O.bottom>E.bottom)&&x.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),(0,y.useEffect)(()=>{if(!s)return;let u=setTimeout(()=>m(!1),800);return()=>clearTimeout(u)},[s]);let M=u=>{r(u),m(!0)};return(0,b.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,b.jsxs)("p",{className:"flex items-center gap-2 mb-5",children:[(0,b.jsx)(B.TextAlignStartIcon,{className:"size-4"}),"On this page"]}),(0,b.jsx)("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:p.map(u=>(0,b.jsxs)("li",{children:[(0,b.jsx)(Ne,{heading:u,activeId:e,handleClick:M}),u.children.map(x=>(0,b.jsx)(Ne,{heading:x,activeId:e,handleClick:M,className:"pl-8"},x.id))]},u.id))}),(0,b.jsx)("hr",{className:"my-6 border-gray-200"}),g.editOnGithub&&(0,b.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,b.jsx)(B.SquareArrowOutUpRightIcon,{className:"size-4"})]}),a&&(0,b.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,b.jsx)(B.ArrowUpCircleIcon,{className:"size-4"})]})]})}function Ne({heading:e,activeId:r,handleClick:t,className:o}){return(0,b.jsx)("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})}var F=require("react/jsx-runtime");function _e({children:e,toc:r=!0,sidebar:t=!0}){return(0,F.jsxs)("div",{className:"min-h-screen flex bg-white w-full",children:[t&&(0,F.jsx)(we,{}),e,r&&(0,F.jsx)(Ce,{})]})}var De=require("next/navigation"),Se=require("lucide-react"),te=L(require("next/link")),C=require("react/jsx-runtime");function Le(){let r=(0,De.usePathname)().split("/").filter(Boolean),t=r.map((o,a)=>{let n="/"+r.slice(0,a+1).join("/"),s=o.replace(/-/g," ").replace(/\b\w/g,m=>m.toUpperCase());return{href:n,title:s}});return(0,C.jsx)("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:(0,C.jsxs)("ol",{className:"flex items-center space-x-2",children:[(0,C.jsx)("li",{children:(0,C.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,C.jsxs)("li",{className:"flex items-center space-x-2",children:[(0,C.jsx)(Se.ChevronRight,{className:"w-4 h-4 text-gray-400"}),n?(0,C.jsx)("span",{className:"text-gray-600 font-medium",children:o.title}):(0,C.jsx)(te.default,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}var Y=require("lucide-react"),A=require("react");var R=require("react/jsx-runtime");function Ie(){let{pageData:e}=c(),[r,t]=(0,A.useState)(!1),[o,a]=(0,A.useState)(null);(0,A.useEffect)(()=>{a(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return(0,R.jsxs)("div",{className:"flex items-center gap-3 mt-6",children:[(0,R.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,R.jsx)(Y.CheckIcon,{className:"size-3.5"}):(0,R.jsx)(Y.CopyIcon,{className:"size-3.5"}),"Copy Markdown"]}),(0,R.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 S=require("react/jsx-runtime");function Oe(){let{pageData:e}=c(),r=e?.data?.metadata?.title,t=e?.data?.metadata?.description;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("h1",{className:"text-3xl font-bold",children:r}),(0,S.jsx)("p",{className:"my-4 text-gray-500",children:t}),(0,S.jsx)(Ie,{}),(0,S.jsx)("hr",{className:"my-10 border-gray-200"})]})}var U=require("react"),Q=require("lucide-react");var T=require("react/jsx-runtime");function re({label:e,type:r,placeholder:t="",id:o,required:a=!1,onChange:n,value:s,readOnly:m=!1,className:g="",optional:w=!1}){return(0,T.jsxs)("div",{className:f("flex flex-col mt-4 w-full",g),children:[e&&(0,T.jsxs)("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,w&&(0,T.jsx)("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),r==="textarea"?(0,T.jsx)("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",g),placeholder:t,required:a,onChange:n,rows:4,value:s,readOnly:m,maxLength:500}):(0,T.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:s,readOnly:m,maxLength:500})]})}var Pe=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: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?(0,oe.jsx)(Pe.Loader2Icon,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}var _=require("formsync"),l=require("react/jsx-runtime");function Re(){let[e,r]=(0,U.useState)(null),{docstraConfig:t}=c(),[o,a]=(0,U.useState)(""),[n,s]=(0,U.useState)(!1),[m,g]=(0,U.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:()=>{s(!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)(Q.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)(Q.ThumbsDown,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&(0,l.jsxs)(_.FormSyncForm,{className:"flex flex-col gap-2",formId:t?.feedback?.formSyncFormID||"",onSuccess:i=>{s(!0),r(null),a("")},onSubmitError:i=>{g(i.message)},children:[(0,l.jsx)(re,{value:o,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),m&&(0,l.jsx)("p",{className:"text-red-500",children:m}),(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)(_.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 Te(){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 ze=require("next/navigation"),ne=L(require("next/link")),W=require("lucide-react");var k=require("react/jsx-runtime");function Be(){let e=(0,ze.usePathname)(),{docstraConfig:r}=c(),t=r?.sidebar?.links?.flatMap(s=>s.items),o=t.findIndex(s=>s.href===e),a=o>0?t[o-1]:null,n=o<t.length-1?t[o+1]:null;return(0,k.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[a?(0,k.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,k.jsx)("span",{className:"text-gray-500",children:"Previous"}),(0,k.jsxs)("p",{className:"flex items-center font-medium",children:[(0,k.jsx)(W.ArrowLeftIcon,{className:"size-5 mr-2"}),a.name]})]}):(0,k.jsx)("div",{}),n?(0,k.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,k.jsx)("span",{className:"text-gray-500",children:"Next"}),(0,k.jsxs)("p",{className:"flex items-center font-medium",children:[n.name,(0,k.jsx)(W.ArrowRightIcon,{className:"size-5 ml-2"})]})]}):(0,k.jsx)("div",{})]})}var I=require("react/jsx-runtime");function We({children:e}){let{docstraConfig:r}=c();return(0,I.jsxs)("main",{className:"flex-1 px-4 md:px-8 py-10 text-base/7 prose max-w-none",children:[(0,I.jsx)(Le,{}),(0,I.jsx)(Oe,{}),e,r?.feedback?.enabled&&(0,I.jsx)(Re,{}),(0,I.jsx)(Te,{}),(0,I.jsx)(Be,{})]})}var X=require("lucide-react"),Z=require("prism-react-renderer"),Ge=require("react"),v=require("react/jsx-runtime");function Xe(e){let{filename:r,children:t,className:o}=e,a=!o?.includes("language-"),n=typeof t=="string"?t:t?.props?.children||"";if(a)return(0,v.jsx)("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 text-gray-800 text-sm",children:n});let[s,m]=(0,Ge.useState)(!1),w=o?.match(/language-([\w-]+)/)?.[1]??"txt";return(0,v.jsxs)("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200/80 mt-4",children:[(0,v.jsxs)("div",{className:"flex items-center bg-gray-50 justify-between border-b border-gray-200/80",children:[(0,v.jsx)("span",{className:"text-xs text-gray-400 p-4",children:r||w}),(0,v.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(n.trim()),m(!0),setTimeout(()=>m(!1),2e3)},className:"rounded cursor-pointer aspect-square p-2 m-2 text-xs hover:bg-gray-200 transition",children:s?(0,v.jsx)(X.CheckIcon,{className:"size-4"}):(0,v.jsx)(X.CopyIcon,{className:"size-4"})})]}),(0,v.jsx)(Z.Highlight,{theme:Z.themes.vsLight,code:n.trim(),language:w,children:({tokens:p,getLineProps:H,getTokenProps:J})=>(0,v.jsx)("pre",{className:"p-4 font-mono whitespace-pre overflow-x-auto",children:p.map(($,j)=>(0,v.jsxs)("div",{...H({line:$}),children:[(0,v.jsx)("span",{className:"text-slate-500 mr-4 select-none",children:j+1}),$.map((ee,M)=>(0,v.jsx)("span",{...J({token:ee})},M))]},j))})})]})}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 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});
|
package/dist/client/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{createContext as Re,useContext as Te,useState as J}from"react";import{ToastContainer as Ee}from"react-toast-msg";import{SearchIcon as De}from"lucide-react";import{twMerge as ke}from"tailwind-merge";import Ce from"clsx";function p(...e){return ke(Ce(e))}import{useEffect as q,useMemo as Se,useState as X}from"react";import Le from"fuse.js";import Ie from"next/link";import{useRouter as Oe}from"next/navigation";import{Fragment as Pe,jsx as v,jsxs as G}from"react/jsx-runtime";function Z(){let{openSearchBox:e,setOpenSearchBox:r,docs:t}=c(),[o,a]=X(""),[n,s]=X([]),l=Oe();q(()=>{let i=m=>{m.ctrlKey&&m.key==="k"&&(m.preventDefault(),r(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let u=Se(()=>!t||t.length===0?null:new Le(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);q(()=>{if(o&&u){let i=u.search(o);s(i.map(m=>m.item))}else o||s([])},[o,u]);let g=i=>{if(i.preventDefault(),o){let m=n[0];m&&(l.push(`/docs/${m.slug}`),a(""),r(!1))}};return q(()=>{let i=m=>{m.key==="Escape"&&(r(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),v("div",{onClick:()=>{r(!1),a("")},className:p("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:i=>i.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[v("form",{onSubmit:g,className:p("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(Pe,{children:[v(De,{className:"size-5.5 mx-3 shrink-0"}),v("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:i=>a(i.target.value),name:"searchQuery",required:!0}),v("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),G("div",{className:p("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(i=>G(Ie,{href:`/docs/${i.slug==="index"?"":i.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:[v("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),v("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&n.length===0&&v("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}import{jsx as j,jsxs as ze}from"react/jsx-runtime";var ee=Re(null);function Et({children:e,docstraConfig:r,docs:t,pageData:o,slug:a}){let n=o||(()=>{let i=Array.isArray(a)?a.length===0?"index":a.join("/"):a||"index";return t.find(m=>m.slug===i)})(),[s,l]=J(!1),[u,g]=J(!1);return ze(ee.Provider,{value:{openSidebar:s,setOpenSidebar:l,docstraConfig:r,openSearchBox:u,setOpenSearchBox:g,pageData:n,docs:t},children:[j(Ee,{}),j(Z,{}),e]})}function c(){let e=Te(ee);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}import{TextAlignEnd as Be,XIcon as Ge}from"lucide-react";import{useEffect as Fe}from"react";import K from"next/link";import{jsx as x,jsxs as te}from"react/jsx-runtime";function $t(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t}=c(),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]),te("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:[x(K,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:x("img",{src:t.navbar?.logo?.src||"/logo.png",alt:t.navbar?.logo?.alt||"Logo",className:p("h-9.5 w-auto",t.navbar?.logo?.className)})}),te("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>x(K,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),x(K,{href:o||"https://github.com/sudhucodes/docstra",children:x("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:x("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"})})})]}),x("button",{onClick:()=>r(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?x(Ge,{className:"size-6.5"}):x(Be,{className:"size-6.5"})})]})}import{SearchIcon as Ue}from"lucide-react";import{usePathname as He}from"next/navigation";import*as Ae from"lucide-react";function re(e){if(e)return Ae[e]}import $e from"next/link";import{Fragment as Me,jsx as b,jsxs as S}from"react/jsx-runtime";function oe(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t,setOpenSearchBox:o}=c(),a=He();return S(Me,{children:[b("div",{className:p("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)}),S("aside",{className:p("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:[S("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:[b(Ue,{className:"size-4.5"}),b("p",{children:"Search"}),S("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[b("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),b("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),t.sidebar?.links?.map(n=>S("div",{children:[b("p",{className:"inline-flex items-center gap-2 mb-2 mt-2 px-2",children:n.section}),b("ul",{className:"mb-4",children:n.items.map(s=>{let l=re(s.icon);return b("li",{children:S($e,{href:s.href,onNavigate:()=>e&&r(!1),className:p("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",a===s.href&&"bg-gray-100 text-gray-800"),children:[l&&b(l,{className:"size-4"}),b("span",{children:s.name})]})},s.href)})})]},n.section))]})]})}import{ArrowUpCircleIcon as qe,SquareArrowOutUpRightIcon as Ke,TextAlignStartIcon as Ve}from"lucide-react";import{usePathname as Ye}from"next/navigation";import{useEffect as O,useRef as ae,useState as F}from"react";import{jsx as w,jsxs as P}from"react/jsx-runtime";function se(){let[e,r]=F(null),[t,o]=F("down"),[a,n]=F(!1),[s,l]=F(!1),{docstraConfig:u,pageData:g}=c(),i=g?.path,m=g?.data?.tableOfContents||[],E=ae(0),H=ae(null),z=Ye(),M=`${"https://github.com/"+u?.editOnGithub?.owner+"/"+u?.editOnGithub?.repo}/edit/main/${u?.editOnGithub?.path}/${i}`;O(()=>{let d=()=>{let f=window.scrollY;o(f>E.current?"down":"up"),n(f>100),E.current=f};return window.addEventListener("scroll",d),()=>window.removeEventListener("scroll",d)},[]),O(()=>{let d=document.querySelectorAll("h2[id], h3[id]"),f=new IntersectionObserver(C=>{if(s)return;let N=C.filter(D=>D.isIntersecting).sort((D,Ne)=>D.boundingClientRect.top-Ne.boundingClientRect.top);if(N.length>0){let D=t==="down"?N[0].target.id:N[N.length-1].target.id;r(D)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return d.forEach(C=>f.observe(C)),H.current=f,()=>f.disconnect()},[z,t,s]),O(()=>{!(window.scrollY>100)&&r(m[0]?.id)},[m]),O(()=>{if(!e)return;let d=document.querySelector(".toc-scroll-container");if(!d)return;let f=d.querySelector(`a[href="#${e}"]`);if(!f)return;let C=d.getBoundingClientRect(),N=f.getBoundingClientRect();(N.top<C.top||N.bottom>C.bottom)&&f.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),O(()=>{if(!s)return;let d=setTimeout(()=>l(!1),800);return()=>clearTimeout(d)},[s]);let B=d=>{r(d),l(!0)};return P("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:[P("p",{className:"flex items-center gap-2 mb-5",children:[w(Ve,{className:"size-4"}),"On this page"]}),w("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:m.map(d=>P("li",{children:[w(ne,{heading:d,activeId:e,handleClick:B}),d.children.map(f=>w(ne,{heading:f,activeId:e,handleClick:B,className:"pl-8"},f.id))]},d.id))}),w("hr",{className:"my-6 border-gray-200"}),u.editOnGithub&&P("a",{href:M,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",w(Ke,{className:"size-4"})]}),a&&P("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",w(qe,{className:"size-4"})]})]})}function ne({heading:e,activeId:r,handleClick:t,className:o}){return w("a",{href:`#${e.id}`,className:p("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 ie,jsxs as Qe}from"react/jsx-runtime";function lr({children:e,toc:r=!0,sidebar:t=!0}){return Qe("div",{className:"min-h-screen flex bg-white w-full",children:[t&&ie(oe,{}),e,r&&ie(se,{})]})}import{usePathname as _e}from"next/navigation";import{ChevronRight as We}from"lucide-react";import le from"next/link";import{jsx as L,jsxs as ce}from"react/jsx-runtime";function me(){let r=_e().split("/").filter(Boolean),t=r.map((o,a)=>{let n="/"+r.slice(0,a+1).join("/"),s=o.replace(/-/g," ").replace(/\b\w/g,l=>l.toUpperCase());return{href:n,title:s}});return L("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:ce("ol",{className:"flex items-center space-x-2",children:[L("li",{children:L(le,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),t.map((o,a)=>{let n=a===t.length-1;return ce("li",{className:"flex items-center space-x-2",children:[L(We,{className:"w-4 h-4 text-gray-400"}),n?L("span",{className:"text-gray-600 font-medium",children:o.title}):L(le,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}import{CheckIcon as Xe,CopyIcon as Ze}from"lucide-react";import{useEffect as Je,useState as de}from"react";import{jsx as V,jsxs as pe}from"react/jsx-runtime";function ue(){let{pageData:e}=c(),[r,t]=de(!1),[o,a]=de(null);Je(()=>{a(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return pe("div",{className:"flex items-center gap-3 mt-6",children:[pe("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?V(Xe,{className:"size-3.5"}):V(Ze,{className:"size-3.5"}),"Copy Markdown"]}),V("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 je,jsx as A,jsxs as et}from"react/jsx-runtime";function fe(){let{pageData:e}=c(),r=e?.data?.metadata?.title,t=e?.data?.metadata?.description;return et(je,{children:[A("h1",{className:"text-3xl font-bold",children:r}),A("p",{className:"my-4 text-gray-500",children:t}),A(ue,{}),A("hr",{className:"my-10 border-gray-200"})]})}import{useState as U}from"react";import{ThumbsUp as rt,ThumbsDown as ot}from"lucide-react";import{jsx as Y,jsxs as ge}from"react/jsx-runtime";function Q({label:e,type:r,placeholder:t="",id:o,required:a=!1,onChange:n,value:s,readOnly:l=!1,className:u="",optional:g=!1}){return ge("div",{className:p("flex flex-col mt-4 w-full",u),children:[e&&ge("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,g&&Y("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),r==="textarea"?Y("textarea",{id:o,name:o,className:p("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",u),placeholder:t,required:a,onChange:n,rows:4,value:s,readOnly:l,maxLength:500}):Y("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:s,readOnly:l,maxLength:500})]})}import{Loader2Icon as tt}from"lucide-react";import{jsx as he}from"react/jsx-runtime";function _({label:e,loading:r,type:t="submit",className:o="",disabled:a=!1,onClick:n}){return he("button",{type:t,disabled:a,className:p("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(tt,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}import{FormSyncButton as at,FormSyncForm as nt}from"formsync";import{Fragment as be,jsx as h,jsxs as k}from"react/jsx-runtime";function xe(){let[e,r]=U(null),{docstraConfig:t}=c(),[o,a]=U(""),[n,s]=U(!1),[l,u]=U(null),g="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?k(be,{children:[h("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),h(_,{onClick:()=>{s(!1),r(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):k(be,{children:[h("p",{className:"font-medium",children:"How is this guide?"}),k("div",{className:"flex gap-2",children:[k("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(rt,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),k("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(ot,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&k(nt,{className:"flex flex-col gap-2",formId:t?.feedback?.formSyncFormID||"",onSuccess:i=>{s(!0),r(null),a("")},onSubmitError:i=>{u(i.message)},children:[h(Q,{value:o,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),l&&h("p",{className:"text-red-500",children:l}),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(at,{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&&k("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",h("a",{href:`https://www.formsync.app?utm_source=${g}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}import{jsxs as st}from"react/jsx-runtime";function ye(){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 st("p",{className:"text-sm text-gray-500",children:["Last updated on ",r]})}import{usePathname as it}from"next/navigation";import ve from"next/link";import{ArrowLeftIcon as lt,ArrowRightIcon as ct}from"lucide-react";import{jsx as I,jsxs as R}from"react/jsx-runtime";function we(){let e=it(),{docstraConfig:r}=c(),t=r?.sidebar?.links?.flatMap(s=>s.items),o=t.findIndex(s=>s.href===e),a=o>0?t[o-1]:null,n=o<t.length-1?t[o+1]:null;return R("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[a?R(ve,{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:[I("span",{className:"text-gray-500",children:"Previous"}),R("p",{className:"flex items-center font-medium",children:[I(lt,{className:"size-5 mr-2"}),a.name]})]}):I("div",{}),n?R(ve,{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:[I("span",{className:"text-gray-500",children:"Next"}),R("p",{className:"flex items-center font-medium",children:[n.name,I(ct,{className:"size-5 ml-2"})]})]}):I("div",{})]})}import{jsx as T,jsxs as mt}from"react/jsx-runtime";function to({children:e}){let{docstraConfig:r}=c();return mt("main",{className:"flex-1 px-4 md:px-8 py-10 text-base/7 prose max-w-none",children:[T(me,{}),T(fe,{}),e,r?.feedback?.enabled&&T(xe,{}),T(ye,{}),T(we,{})]})}import{CheckIcon as dt,CopyIcon as pt}from"lucide-react";import{Highlight as ut,themes as ft}from"prism-react-renderer";import{useState as gt}from"react";import{jsx as y,jsxs as W}from"react/jsx-runtime";function io(e){let{filename:r,children:t,className:o}=e,a=!o?.includes("language-"),n=typeof t=="string"?t:t?.props?.children||"";if(a)return y("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 text-gray-800 text-sm",children:n});let[s,l]=gt(!1),g=o?.match(/language-([\w-]+)/)?.[1]??"txt";return W("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200/80 mt-4",children:[W("div",{className:"flex items-center bg-gray-50 justify-between border-b border-gray-200/80",children:[y("span",{className:"text-xs text-gray-400 p-4",children:r||g}),y("button",{onClick:()=>{navigator.clipboard.writeText(n.trim()),l(!0),setTimeout(()=>l(!1),2e3)},className:"rounded cursor-pointer aspect-square p-2 m-2 text-xs hover:bg-gray-200 transition",children:s?y(dt,{className:"size-4"}):y(pt,{className:"size-4"})})]}),y(ut,{theme:ft.vsLight,code:n.trim(),language:g,children:({tokens:m,getLineProps:E,getTokenProps:H})=>y("pre",{className:"p-4 font-mono whitespace-pre overflow-x-auto",children:m.map((z,$)=>W("div",{...E({line:z}),children:[y("span",{className:"text-slate-500 mr-4 select-none",children:$+1}),z.map((M,B)=>y("span",{...H({token:M})},B))]},$))})})]})}export{to as DocstraBody,io as DocstraCodeBlock,$t as DocstraHeader,lr as DocstraPage,Et as DocstraProvider,c 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(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};
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DocstraConfig, p as pageDataContent, g as getSitemapProps } from '../types-
|
|
1
|
+
import { D as DocstraConfig, p as pageDataContent, g as getSitemapProps } from '../types-CLQX-iqJ.mjs';
|
|
2
2
|
import { NextConfig } from 'next';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DocstraConfig, p as pageDataContent, g as getSitemapProps } from '../types-
|
|
1
|
+
import { D as DocstraConfig, p as pageDataContent, g as getSitemapProps } from '../types-CLQX-iqJ.js';
|
|
2
2
|
import { NextConfig } from 'next';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
|
|
@@ -6,6 +6,8 @@ interface DocstraContextType {
|
|
|
6
6
|
setOpenSearchBox: (open: boolean) => void;
|
|
7
7
|
docs: pageDataContent[];
|
|
8
8
|
pageData: pageDataContent;
|
|
9
|
+
packageManager: 'npm' | 'yarn' | 'pnpm' | 'bun';
|
|
10
|
+
setPackageManager: (packageManager: 'npm' | 'yarn' | 'pnpm' | 'bun') => void;
|
|
9
11
|
}
|
|
10
12
|
interface pageDataContent {
|
|
11
13
|
slug: string;
|
|
@@ -6,6 +6,8 @@ interface DocstraContextType {
|
|
|
6
6
|
setOpenSearchBox: (open: boolean) => void;
|
|
7
7
|
docs: pageDataContent[];
|
|
8
8
|
pageData: pageDataContent;
|
|
9
|
+
packageManager: 'npm' | 'yarn' | 'pnpm' | 'bun';
|
|
10
|
+
setPackageManager: (packageManager: 'npm' | 'yarn' | 'pnpm' | 'bun') => void;
|
|
9
11
|
}
|
|
10
12
|
interface pageDataContent {
|
|
11
13
|
slug: string;
|