@veluai/velu 0.2.46 → 0.2.47
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/cli.js +60 -49
- package/package.json +1 -1
- package/schema/velu.schema.json +1 -0
- package/src/navigation.js +1 -0
- package/src/runtime/App.jsx +8 -2
- package/src/runtime/client-entry.jsx +9 -3
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`,"utf-8");let o=await sn(e);console.log(`[velu] created ${t}/`);for(let i of o)console.log(` ${i}`);console.log(""),console.log("Next steps:"),console.log(` cd ${t}`),console.log(" velu dev")}async function sn(e,t=e,r=[]){let n=await de.readdir(e,{withFileTypes:!0});for(let o of n){let i=ge.join(e,o.name);o.isDirectory()?await sn(i,t,r):r.push(ge.relative(t,i).split(ge.sep).join("/"))}return r.sort()}var to,no,ln=_(()=>{to=ge.dirname(eo(import.meta.url)),no=ge.resolve(to,"..","templates","starter")});import ke from"node:fs";import X from"node:path";import{fileURLToPath as oo}from"node:url";import{parse as io,printParseErrorCode as so}from"jsonc-parser";import ao from"js-yaml";function le(e,t){let r=X.relative(e,t);return r===""||!r.startsWith(`..${X.sep}`)&&r!==".."&&!X.isAbsolute(r)}function ht(e,t){let r=[],n=io(e.replace(/^\uFEFF/,""),r,{allowTrailingComma:!0});if(r.length)throw new Error(`${t}: ${so(r[0].error)} at offset ${r[0].offset}`);return n}function cn(e,t){let r=ke.realpathSync(e);function n(i,a=[]){if(!le(r,ke.realpathSync(i)))throw new Error("Config reference escapes the source directory.");if(a.includes(i))throw new Error(`Circular config reference: ${gt(X.relative(e,i))}`);if(a.length>50)throw new Error("Config reference nesting exceeds 50 levels.");let s=ke.readFileSync(i,"utf8"),l=/\.ya?ml$/i.test(i)?ao.load(s):ht(s,X.basename(i));function c(u){if(Array.isArray(u))return u.map(c);if(!W(u))return u;if(typeof u.$ref=="string"){if(!/^\.\.?\//.test(u.$ref)||/[#?]/.test(u.$ref))throw new Error(`Config $ref must be a local JSON/YAML file without a fragment: ${u.$ref}`);let p=X.resolve(X.dirname(i),u.$ref);if(!le(e,p))throw new Error("Config reference escapes the source directory.");let y=n(p,[...a,i]),m=Object.fromEntries(Object.entries(u).filter(([g])=>g!=="$ref").map(([g,v])=>[g,c(v)]));if(Object.keys(m).length&&!W(y))throw new Error("Config $ref siblings require an object reference.");return W(y)?{...y,...m}:y}return Object.fromEntries(Object.entries(u).map(([p,y])=>[p,c(y)]))}return c(l)}let o=n(X.join(e,t));if(!W(o))throw new Error(`${t} must contain an object.`);return o}function lo(e,t){let r=e.navigation||[],n=e.tabs||[];if(!Array.isArray(r)||!Array.isArray(n))throw new Error("Legacy navigation and tabs must be arrays.");function o(a,s,l){return a.flatMap(c=>{if(typeof c=="string"){let p=c.replace(/^\//,"");return(s?p===s||p.startsWith(s+"/"):!l.some(m=>p===m||p.startsWith(m+"/")))?[c]:[]}if(!W(c))return[];let u=o(c.pages||[],s,l);return u.length?[{...c,pages:u}]:[]})}let i={groups:r};if(n.length){let a=n.filter(c=>c.url&&!/^https?:/.test(c.url)).map(c=>c.url.replace(/^\/+|\/+$/g,"")),s=n.map(c=>{if(/^https?:/.test(c.url||""))return{tab:c.name,href:c.url,...c.icon?{icon:c.icon}:{}};let u=(c.url||"").replace(/^\/+|\/+$/g,"");return{tab:c.name,...c.icon?{icon:c.icon}:{},groups:o(r,u,a)}}),l=o(r,"",a);l.length&&!n.some(c=>!c.url||c.url==="/")&&s.unshift({tab:"Documentation",groups:l}),i={tabs:s}}return Array.isArray(e.anchors)&&(i.anchors=e.anchors.map(({name:a,url:s,...l})=>({...l,anchor:a,href:s}))),e.versions&&t("legacy-versions","warning","versions","Legacy version filtering needs review; all groups are retained. Convert version-specific groups to navigation.versions."),i}function un(e,t,r){let n=structuredClone(e);if(n.theme==="sequoia"&&(n.theme="vepa",n.contextual==null&&(n.contextual={options:[]})),n.theme==="mint"&&(n.theme="thulir",n.contextual==null&&(n.contextual={options:[]})),n.theme==="maple"&&(n.theme="aalam",n.contextual==null&&(n.contextual={options:[]})),n.theme==="aspen"&&(n.theme="nila",n.contextual==null&&(n.contextual={options:[]})),n.theme==="luma"&&(n.theme="kadhir"),n.theme&&!["velu","vepa","thulir","aalam","nila","kadhir"].includes(n.theme)&&(r("unsupported-config","warning","theme","This theme has no Velu preset; original setting preserved in source config."),delete n.theme),t==="mint.json"||Array.isArray(n.navigation)){if(n.navigation=lo(n,r),n.topbarLinks&&(n.navbar={...n.navbar,links:n.topbarLinks.map(({name:p,...y})=>({...y,label:p}))}),n.topbarCta){let{name:p,...y}=n.topbarCta;p&&!y.label&&(y.label=p),n.navbar={...n.navbar,primary:y}}n.footerSocials&&(n.footer={...n.footer,socials:n.footerSocials}),n.modeToggle&&r("appearance","warning","modeToggle","Set the initial theme and theme-switcher behavior manually in Velu."),typeof n.api?.baseUrl=="string"&&(n.api.server=n.api.baseUrl),n.api?.request?.example?.languages&&(n.api.examples={languages:n.api.request.example.languages});for(let p of["tabs","anchors","topbarLinks","topbarCta","footerSocials","modeToggle"])delete n[p];n.api&&(delete n.api.baseUrl,delete n.api.request)}if(n.fonts&&!n.font){let p=n.fonts.family||n.fonts.body?.family;p&&(n.font={family:p}),r("fonts","warning","fonts","Body font family migrated where available; custom font sources, weights, and heading fonts need review."),delete n.fonts}W(n.favicon)&&(n.favicon=n.favicon.light||n.favicon.dark,r("favicon-theme","warning","favicon","Velu uses one favicon; selected the light variant when available.")),W(n.logo)&&(n.logo.light??=n.logo.dark,n.logo.dark??=n.logo.light);function o(p,y="navigation"){if(Array.isArray(p))return p.map((g,v)=>o(g,`${y}[${v}]`));if(!W(p))return p;let m={...p};if(Array.isArray(m.dropdowns)&&!m.products&&!m.tabs&&(m.tabs=m.dropdowns.map(({dropdown:g,...v})=>({tab:g,...v})),delete m.dropdowns,r("navigation-dropdowns","warning",y,"Dropdowns converted to tabs. Check navigation layout and URLs.")),m.global){for(let g of["anchors","tabs"])Array.isArray(m.global[g])&&(m[g]=[...m[g]||[],...m.global[g]]);r("navigation-global","warning",`${y}.global`,"Global anchors/tabs merged into this container. Review switcher visibility; other global entries remain in the original config."),delete m.global}W(m.icon)&&typeof m.icon.name=="string"&&(m.icon=m.icon.name,r("icon-library","warning",`${y}.icon`,"Icon name retained; check its equivalent in Velu\u2019s Lucide icon library.")),W(m.openapi)&&typeof m.openapi.source=="string"&&(r("openapi-options","warning",`${y}.openapi`,"OpenAPI source retained; generation options need review."),m.openapi=m.openapi.source);for(let[g,v]of Object.entries(m))g==="pages"&&Array.isArray(v)?m[g]=v.map((d,h)=>typeof d=="string"?d.replace(/\.(mdx|md)$/i,""):o(d,`${y}.pages[${h}]`)):(W(v)||Array.isArray(v))&&(m[g]=o(v,`${y}.${g}`));return m}n.navigation=o(n.navigation||{}),(n.navigation.products||n.navigation.versions||n.navigation.languages)&&(n.navigation.preservePagePaths=!0),typeof n.description=="string"&&(n.seo={...n.seo,metatags:{description:n.description,...n.seo?.metatags}},delete n.description),n.$schema="https://veludocs.com/velu.schema.json";let i=X.dirname(oo(import.meta.url)),a=[X.resolve(i,"../../schema/velu.schema.json"),X.resolve(i,"../schema/velu.schema.json")].find(p=>ke.existsSync(p));if(!a)throw new Error("Velu config schema is missing from this installation.");let s=JSON.parse(ke.readFileSync(a,"utf8")),l=p=>p.$ref?p.$ref.split("/").slice(1).reduce((y,m)=>y[m],s):p,c=p=>Array.isArray(p)?"array":p===null?"null":typeof p;function u(p,y,m){let g=l(y);if(g.oneOf&&(g=g.oneOf.map(l).find(v=>v.type&&c(p)!==v.type||v.properties?.type?.const&&p?.type!==v.properties.type.const?!1:Array.isArray(v.required)&&v.required.length&&W(p)?v.required.every(d=>Object.prototype.hasOwnProperty.call(p,d)):!0),!g)){r("config-shape","error",m,"Value does not match any supported Velu shape; original retained in source config.");return}if(g.type&&c(p)!==g.type||g.enum&&!g.enum.includes(p)||"const"in g&&p!==g.const){r("config-value","error",m,"Unsupported value or type; original retained in source config.");return}if(typeof p=="string"&&g.minLength&&p.length<g.minLength&&r("config-value","error",m,"Value must not be empty."),W(p)){let v={};for(let[d,h]of Object.entries(p)){let S=m?`${m}.${d}`:d,T=g.properties?.[d]||(W(g.additionalProperties)?g.additionalProperties:null);if(!T&&g.additionalProperties===!1){let x=/(^|\.)(auth|authentication|groups|hidden|public|permissions|personalization)(\.|$)/.test(S);r("unsupported-config",x?"error":"warning",S,x?"Access or visibility rules require manual migration before publishing.":"No equivalent in the Velu schema; original setting preserved in source config.");continue}let O=T?u(h,T,S):h;O!==void 0&&Object.defineProperty(v,d,{value:O,enumerable:!0,writable:!0,configurable:!0})}for(let d of g.required||[])d in v||r("required-config","error",m?`${m}.${d}`:d,"Required Velu setting is missing.");return v}return Array.isArray(p)&&g.items?(g.maxItems&&p.length>g.maxItems&&r("config-limit","warning",m,`Velu supports up to ${g.maxItems} entries here; review rendering.`),p.map((v,d)=>u(v,g.items,`${m}[${d}]`)).filter(v=>v!==void 0)):p}return u(n,s,"")}var W,gt,Ge=_(()=>{W=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),gt=e=>e.split(X.sep).join("/")});var te,We=_(()=>{te=["Callout","Card","CardGroup","Accordion","AccordionGroup","Columns","Field","Prompt","Steps","Step","Tree","Folder","File","Update","Icon","Image","CodeBlock","CodeGroup","MethodBadge","ApiPath","TryItBar","ApiField","ApiClient","ApiSidebar"]});import q from"node:path";import{createProcessor as co,compile as uo}from"@mdx-js/mdx";import pn from"remark-frontmatter";import po from"remark-mdx-frontmatter";import fn from"remark-gfm";import{visit as mn}from"unist-util-visit";import fo from"js-yaml";import{parse as mo}from"@babel/parser";import go from"postcss";async function dn(e,t,r,n,{endpointConverted:o=!1}={}){let i=co({remarkPlugins:[pn,fn]}),a;try{a=i.parse(e)}catch(d){return n("mdx-syntax","error",t,d.reason||d.message,d.line),{text:e,adapters:[]}}let s=new Set,l=[],c=[],u=new Set,p=new Set,y=new Set,m=(d,h,S)=>c.push({start:d,end:h,value:S});mn(a,"mdxjsEsm",d=>{for(let h of d.data?.estree?.body||[]){if(h.type==="ImportDeclaration"){for(let T of h.specifiers)s.add(T.local.name);l.push({node:d,stmt:h})}let S=h.declaration;S?.id?.name&&s.add(S.id.name);for(let T of S?.declarations||[])T.id?.name&&s.add(T.id.name)}});let g=(d,h=!1)=>{if(typeof d!="string"||/^(?:[a-z][a-z0-9+.-]*:|\/\/|#)/i.test(d)||h&&!d.startsWith(".")&&!d.startsWith("/"))return d;let[,S,T]=/^([^?#]*)(.*)$/.exec(d),O=q.posix.normalize(S.startsWith("/")?S.slice(1):q.posix.join(q.posix.dirname(t),S)),x=r.get(O);if(!x)return h&&n("missing-import","error",t,`Local import cannot be resolved in migrated files: ${d}`),d;if(h){let w=q.posix.relative(q.posix.dirname(r.get(t)||t),x);return(w.startsWith(".")?w:"./"+w)+T}return/\.(md|mdx)$/i.test(x)||p.add(x),/\.mdx$/i.test(x)&&/\.(md|mdx)$/i.test(S)?S.replace(/\.(md|mdx)$/i,"")+T:d};for(let{stmt:d}of l){let h=d.source.value;/^(?:@mintlify\/|next(?:\/|$))/.test(h)&&n("runtime-import","error",t,`Replace the runtime dependency ${h} with a Velu/React equivalent.`);let S=g(h,!0);S!==h&&m(d.source.start,d.source.end,JSON.stringify(S))}mn(a,d=>{if(d.type==="yaml")try{let w=fo.load(d.value)||{};for(let P of Object.keys(w))if(["auth","groups","public","hidden"].includes(P))n("page-access","error",t,`Frontmatter ${P} requires manual visibility/access migration.`,d.position.start.line);else{if(P==="openapi"&&o)continue;["api","openapi","asyncapi"].includes(P)?n("endpoint-frontmatter","error",t,`Frontmatter ${P} is preserved but does not generate an endpoint in Velu. Wire the spec into navigation.openapi and review endpoint routes.`,d.position.start.line):["title","description","icon","sidebarTitle","mode","keywords","og:title","og:description","og:image"].includes(P)||n("frontmatter-review","warning",t,`Frontmatter ${P} is preserved; verify its behavior in Velu.`,d.position.start.line)}}catch(w){n("frontmatter-syntax","error",t,w.message,d.position.start.line)}if(["link","image","definition"].includes(d.type)&&d.url){let w=g(d.url);if(w!==d.url){let P=d.position.start.offset,V=e.slice(P,d.position.end.offset).lastIndexOf(d.url);V>=0&&m(P+V,P+V+d.url.length,w)}}if(!["mdxJsxFlowElement","mdxJsxTextElement"].includes(d.type)||!d.name)return;let h=d.name,S=d.position.start.line;if(s.has(h.split(".")[0]))return;y.add(h);let T=yt[h]?"Callout":["ParamField","ResponseField"].includes(h)?"Field":h==="Expandable"?"Accordion":h;if(T!==h&&s.has(T)){n("component-name-conflict","error",t,`Cannot convert <${h}> to <${T}> because that name is already locally defined. Rename the local binding before migration.`,S);return}let O=d.attributes.filter(w=>w.type==="mdxJsxAttribute"),x=(w,P)=>{let L=O.find(V=>V.name===w);L&&!O.some(V=>V.name===P)&&m(L.position.start.offset,L.position.start.offset+w.length,P)};if(h==="ParamField")for(let w of["body","query","path","header","cookie"])x(w,"name");if(h==="CardGroup"&&x("cols","limit"),h==="Accordion"&&x("default-open","defaultOpen"),h==="Expandable"&&(x("title","title"),O.some(w=>w.name==="title")||m(d.position.start.offset+1+h.length,d.position.start.offset+1+h.length,' title="Details"')),T!==h){let w=d.position.start.offset;m(w+1,w+1+h.length,T+(yt[h]?` type="${yt[h]}"`:""));let P=d.position.end.offset,L=new RegExp(`</${h}\\s*>$`).exec(e.slice(w,P));L&&m(P-L[0].length+2,P-L[0].length+2+h.length,T)}ho.has(h)?(u.add(h),n("component-adapter","warning",t,`<${h}> uses an editable React adapter. Review visual styling and optional props.`,S)):/^[A-Z]/.test(T)&&!yo.has(T)&&n("unsupported-component","error",t,`<${h}> needs a local component implementation or import.`,S);for(let w of O)if(["href","src"].includes(w.name)&&typeof w.value=="string"){let P=g(w.value);if(P!==w.value){let L=w.position.start.offset,K=e.slice(L,w.position.end.offset).indexOf(w.value);K>=0&&m(L+K,L+K+w.value.length,P)}}}),c.sort((d,h)=>h.start-d.start||h.end-d.end);let v=e;for(let d of c)v=v.slice(0,d.start)+d.value+v.slice(d.end);if(u.size){let d=q.posix.relative(q.posix.dirname(r.get(t)||t),he);v+=`
|
|
2
|
+
var ro=Object.defineProperty;var _=(e,t)=>()=>(e&&(t=e(e=0)),t);var Se=(e,t)=>{for(var r in t)ro(e,r,{get:t[r],enumerable:!0})};var ln={};Se(ln,{initProject:()=>ao});import de from"node:fs/promises";import ge from"node:path";import{fileURLToPath as oo}from"node:url";async function ao(e,t){try{if((await de.readdir(e)).length>0)throw new Error(`Directory "${t}" already exists and is not empty. Choose a different name or remove the folder first.`)}catch(i){if(i.code!=="ENOENT")throw i}await de.mkdir(e,{recursive:!0}),await de.cp(so,e,{recursive:!0});let r=ge.join(e,"velu.json"),n=JSON.parse(await de.readFile(r,"utf-8"));n.name=t,await de.writeFile(r,JSON.stringify(n,null,2)+`
|
|
3
|
+
`,"utf-8");let o=await an(e);console.log(`[velu] created ${t}/`);for(let i of o)console.log(` ${i}`);console.log(""),console.log("Next steps:"),console.log(` cd ${t}`),console.log(" velu dev")}async function an(e,t=e,r=[]){let n=await de.readdir(e,{withFileTypes:!0});for(let o of n){let i=ge.join(e,o.name);o.isDirectory()?await an(i,t,r):r.push(ge.relative(t,i).split(ge.sep).join("/"))}return r.sort()}var io,so,cn=_(()=>{io=ge.dirname(oo(import.meta.url)),so=ge.resolve(io,"..","templates","starter")});import ke from"node:fs";import X from"node:path";import{fileURLToPath as lo}from"node:url";import{parse as co,printParseErrorCode as uo}from"jsonc-parser";import po from"js-yaml";function le(e,t){let r=X.relative(e,t);return r===""||!r.startsWith(`..${X.sep}`)&&r!==".."&&!X.isAbsolute(r)}function ht(e,t){let r=[],n=co(e.replace(/^\uFEFF/,""),r,{allowTrailingComma:!0});if(r.length)throw new Error(`${t}: ${uo(r[0].error)} at offset ${r[0].offset}`);return n}function un(e,t){let r=ke.realpathSync(e);function n(i,a=[]){if(!le(r,ke.realpathSync(i)))throw new Error("Config reference escapes the source directory.");if(a.includes(i))throw new Error(`Circular config reference: ${gt(X.relative(e,i))}`);if(a.length>50)throw new Error("Config reference nesting exceeds 50 levels.");let s=ke.readFileSync(i,"utf8"),l=/\.ya?ml$/i.test(i)?po.load(s):ht(s,X.basename(i));function c(u){if(Array.isArray(u))return u.map(c);if(!H(u))return u;if(typeof u.$ref=="string"){if(!/^\.\.?\//.test(u.$ref)||/[#?]/.test(u.$ref))throw new Error(`Config $ref must be a local JSON/YAML file without a fragment: ${u.$ref}`);let p=X.resolve(X.dirname(i),u.$ref);if(!le(e,p))throw new Error("Config reference escapes the source directory.");let y=n(p,[...a,i]),f=Object.fromEntries(Object.entries(u).filter(([g])=>g!=="$ref").map(([g,b])=>[g,c(b)]));if(Object.keys(f).length&&!H(y))throw new Error("Config $ref siblings require an object reference.");return H(y)?{...y,...f}:y}return Object.fromEntries(Object.entries(u).map(([p,y])=>[p,c(y)]))}return c(l)}let o=n(X.join(e,t));if(!H(o))throw new Error(`${t} must contain an object.`);return o}function fo(e,t){let r=e.navigation||[],n=e.tabs||[];if(!Array.isArray(r)||!Array.isArray(n))throw new Error("Legacy navigation and tabs must be arrays.");function o(a,s,l){return a.flatMap(c=>{if(typeof c=="string"){let p=c.replace(/^\//,"");return(s?p===s||p.startsWith(s+"/"):!l.some(f=>p===f||p.startsWith(f+"/")))?[c]:[]}if(!H(c))return[];let u=o(c.pages||[],s,l);return u.length?[{...c,pages:u}]:[]})}let i={groups:r};if(n.length){let a=n.filter(c=>c.url&&!/^https?:/.test(c.url)).map(c=>c.url.replace(/^\/+|\/+$/g,"")),s=n.map(c=>{if(/^https?:/.test(c.url||""))return{tab:c.name,href:c.url,...c.icon?{icon:c.icon}:{}};let u=(c.url||"").replace(/^\/+|\/+$/g,"");return{tab:c.name,...c.icon?{icon:c.icon}:{},groups:o(r,u,a)}}),l=o(r,"",a);l.length&&!n.some(c=>!c.url||c.url==="/")&&s.unshift({tab:"Documentation",groups:l}),i={tabs:s}}return Array.isArray(e.anchors)&&(i.anchors=e.anchors.map(({name:a,url:s,...l})=>({...l,anchor:a,href:s}))),e.versions&&t("legacy-versions","warning","versions","Legacy version filtering needs review; all groups are retained. Convert version-specific groups to navigation.versions."),i}function pn(e,t,r){let n=structuredClone(e);if(n.theme==="sequoia"&&(n.theme="vepa",n.contextual==null&&(n.contextual={options:[]})),n.theme==="mint"&&(n.theme="thulir",n.contextual==null&&(n.contextual={options:[]})),n.theme==="maple"&&(n.theme="aalam",n.contextual==null&&(n.contextual={options:[]})),n.theme==="aspen"&&(n.theme="nila",n.contextual==null&&(n.contextual={options:[]})),n.theme==="luma"&&(n.theme="kadhir"),n.theme&&!["velu","vepa","thulir","aalam","nila","kadhir"].includes(n.theme)&&(r("unsupported-config","warning","theme","This theme has no Velu preset; original setting preserved in source config."),delete n.theme),t==="mint.json"||Array.isArray(n.navigation)){if(n.navigation=fo(n,r),n.topbarLinks&&(n.navbar={...n.navbar,links:n.topbarLinks.map(({name:p,...y})=>({...y,label:p}))}),n.topbarCta){let{name:p,...y}=n.topbarCta;p&&!y.label&&(y.label=p),n.navbar={...n.navbar,primary:y}}n.footerSocials&&(n.footer={...n.footer,socials:n.footerSocials}),n.modeToggle&&r("appearance","warning","modeToggle","Set the initial theme and theme-switcher behavior manually in Velu."),typeof n.api?.baseUrl=="string"&&(n.api.server=n.api.baseUrl),n.api?.request?.example?.languages&&(n.api.examples={languages:n.api.request.example.languages});for(let p of["tabs","anchors","topbarLinks","topbarCta","footerSocials","modeToggle"])delete n[p];n.api&&(delete n.api.baseUrl,delete n.api.request)}if(n.fonts&&!n.font){let p=n.fonts.family||n.fonts.body?.family;p&&(n.font={family:p}),r("fonts","warning","fonts","Body font family migrated where available; custom font sources, weights, and heading fonts need review."),delete n.fonts}H(n.favicon)&&(n.favicon=n.favicon.light||n.favicon.dark,r("favicon-theme","warning","favicon","Velu uses one favicon; selected the light variant when available.")),H(n.logo)&&(n.logo.light??=n.logo.dark,n.logo.dark??=n.logo.light);function o(p,y="navigation"){if(Array.isArray(p))return p.map((g,b)=>o(g,`${y}[${b}]`));if(!H(p))return p;let f={...p};if(Array.isArray(f.dropdowns)&&!f.products&&!f.tabs&&(f.tabs=f.dropdowns.map(({dropdown:g,...b})=>({tab:g,...b})),delete f.dropdowns,r("navigation-dropdowns","warning",y,"Dropdowns converted to tabs. Check navigation layout and URLs.")),f.global){for(let g of["anchors","tabs"])Array.isArray(f.global[g])&&(f[g]=[...f[g]||[],...f.global[g]]);r("navigation-global","warning",`${y}.global`,"Global anchors/tabs merged into this container. Review switcher visibility; other global entries remain in the original config."),delete f.global}H(f.icon)&&typeof f.icon.name=="string"&&(f.icon=f.icon.name,r("icon-library","warning",`${y}.icon`,"Icon name retained; check its equivalent in Velu\u2019s Lucide icon library.")),H(f.openapi)&&typeof f.openapi.source=="string"&&(r("openapi-options","warning",`${y}.openapi`,"OpenAPI source retained; generation options need review."),f.openapi=f.openapi.source);for(let[g,b]of Object.entries(f))g==="pages"&&Array.isArray(b)?f[g]=b.map((m,h)=>typeof m=="string"?m.replace(/\.(mdx|md)$/i,""):o(m,`${y}.pages[${h}]`)):(H(b)||Array.isArray(b))&&(f[g]=o(b,`${y}.${g}`));return f}n.navigation=o(n.navigation||{}),(n.navigation.products||n.navigation.versions||n.navigation.languages)&&(n.navigation.preservePagePaths=!0),typeof n.description=="string"&&(n.seo={...n.seo,metatags:{description:n.description,...n.seo?.metatags}},delete n.description),n.$schema="https://veludocs.com/velu.schema.json";let i=X.dirname(lo(import.meta.url)),a=[X.resolve(i,"../../schema/velu.schema.json"),X.resolve(i,"../schema/velu.schema.json")].find(p=>ke.existsSync(p));if(!a)throw new Error("Velu config schema is missing from this installation.");let s=JSON.parse(ke.readFileSync(a,"utf8")),l=p=>p.$ref?p.$ref.split("/").slice(1).reduce((y,f)=>y[f],s):p,c=p=>Array.isArray(p)?"array":p===null?"null":typeof p;function u(p,y,f){let g=l(y);if(g.oneOf&&(g=g.oneOf.map(l).find(b=>b.type&&c(p)!==b.type||b.properties?.type?.const&&p?.type!==b.properties.type.const?!1:Array.isArray(b.required)&&b.required.length&&H(p)?b.required.every(m=>Object.prototype.hasOwnProperty.call(p,m)):!0),!g)){r("config-shape","error",f,"Value does not match any supported Velu shape; original retained in source config.");return}if(g.type&&c(p)!==g.type||g.enum&&!g.enum.includes(p)||"const"in g&&p!==g.const){r("config-value","error",f,"Unsupported value or type; original retained in source config.");return}if(typeof p=="string"&&g.minLength&&p.length<g.minLength&&r("config-value","error",f,"Value must not be empty."),H(p)){let b={};for(let[m,h]of Object.entries(p)){let $=f?`${f}.${m}`:m,P=g.properties?.[m]||(H(g.additionalProperties)?g.additionalProperties:null);if(!P&&g.additionalProperties===!1){let T=/(^|\.)(auth|authentication|groups|hidden|public|permissions|personalization)(\.|$)/.test($);r("unsupported-config",T?"error":"warning",$,T?"Access or visibility rules require manual migration before publishing.":"No equivalent in the Velu schema; original setting preserved in source config.");continue}let E=P?u(h,P,$):h;E!==void 0&&Object.defineProperty(b,m,{value:E,enumerable:!0,writable:!0,configurable:!0})}for(let m of g.required||[])m in b||r("required-config","error",f?`${f}.${m}`:m,"Required Velu setting is missing.");return b}return Array.isArray(p)&&g.items?(g.maxItems&&p.length>g.maxItems&&r("config-limit","warning",f,`Velu supports up to ${g.maxItems} entries here; review rendering.`),p.map((b,m)=>u(b,g.items,`${f}[${m}]`)).filter(b=>b!==void 0)):p}return u(n,s,"")}var H,gt,Ge=_(()=>{H=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),gt=e=>e.split(X.sep).join("/")});var ne,We=_(()=>{ne=["Callout","Card","CardGroup","Accordion","AccordionGroup","Columns","Field","Prompt","Steps","Step","Tree","Folder","File","Update","Icon","Image","CodeBlock","CodeGroup","MethodBadge","ApiPath","TryItBar","ApiField","ApiClient","ApiSidebar"]});import G from"node:path";import{createProcessor as mo,compile as go}from"@mdx-js/mdx";import fn from"remark-frontmatter";import ho from"remark-mdx-frontmatter";import mn from"remark-gfm";import{visit as dn}from"unist-util-visit";import yo from"js-yaml";import{parse as vo}from"@babel/parser";import bo from"postcss";async function gn(e,t,r,n,{endpointConverted:o=!1}={}){let i=mo({remarkPlugins:[fn,mn]}),a;try{a=i.parse(e)}catch(m){return n("mdx-syntax","error",t,m.reason||m.message,m.line),{text:e,adapters:[]}}let s=new Set,l=[],c=[],u=new Set,p=new Set,y=new Set,f=(m,h,$)=>c.push({start:m,end:h,value:$});dn(a,"mdxjsEsm",m=>{for(let h of m.data?.estree?.body||[]){if(h.type==="ImportDeclaration"){for(let P of h.specifiers)s.add(P.local.name);l.push({node:m,stmt:h})}let $=h.declaration;$?.id?.name&&s.add($.id.name);for(let P of $?.declarations||[])P.id?.name&&s.add(P.id.name)}});let g=(m,h=!1)=>{if(typeof m!="string"||/^(?:[a-z][a-z0-9+.-]*:|\/\/|#)/i.test(m)||h&&!m.startsWith(".")&&!m.startsWith("/"))return m;let[,$,P]=/^([^?#]*)(.*)$/.exec(m),E=G.posix.normalize($.startsWith("/")?$.slice(1):G.posix.join(G.posix.dirname(t),$)),T=r.get(E);if(!T)return h&&n("missing-import","error",t,`Local import cannot be resolved in migrated files: ${m}`),m;if(h){let S=G.posix.relative(G.posix.dirname(r.get(t)||t),T);return(S.startsWith(".")?S:"./"+S)+P}return/\.(md|mdx)$/i.test(T)||p.add(T),/\.mdx$/i.test(T)&&/\.(md|mdx)$/i.test($)?$.replace(/\.(md|mdx)$/i,"")+P:m};for(let{stmt:m}of l){let h=m.source.value;/^(?:@mintlify\/|next(?:\/|$))/.test(h)&&n("runtime-import","error",t,`Replace the runtime dependency ${h} with a Velu/React equivalent.`);let $=g(h,!0);$!==h&&f(m.source.start,m.source.end,JSON.stringify($))}dn(a,m=>{if(m.type==="yaml")try{let S=yo.load(m.value)||{};for(let w of Object.keys(S))if(["auth","groups","public","hidden"].includes(w))n("page-access","error",t,`Frontmatter ${w} requires manual visibility/access migration.`,m.position.start.line);else{if(w==="openapi"&&o)continue;["api","openapi","asyncapi"].includes(w)?n("endpoint-frontmatter","error",t,`Frontmatter ${w} is preserved but does not generate an endpoint in Velu. Wire the spec into navigation.openapi and review endpoint routes.`,m.position.start.line):["title","description","icon","sidebarTitle","mode","keywords","og:title","og:description","og:image"].includes(w)||n("frontmatter-review","warning",t,`Frontmatter ${w} is preserved; verify its behavior in Velu.`,m.position.start.line)}}catch(S){n("frontmatter-syntax","error",t,S.message,m.position.start.line)}if(["link","image","definition"].includes(m.type)&&m.url){let S=g(m.url);if(S!==m.url){let w=m.position.start.offset,I=e.slice(w,m.position.end.offset).lastIndexOf(m.url);I>=0&&f(w+I,w+I+m.url.length,S)}}if(!["mdxJsxFlowElement","mdxJsxTextElement"].includes(m.type)||!m.name)return;let h=m.name,$=m.position.start.line;if(s.has(h.split(".")[0]))return;y.add(h);let P=yt[h]?"Callout":["ParamField","ResponseField"].includes(h)?"Field":h==="Expandable"?"Accordion":h;if(P!==h&&s.has(P)){n("component-name-conflict","error",t,`Cannot convert <${h}> to <${P}> because that name is already locally defined. Rename the local binding before migration.`,$);return}let E=m.attributes.filter(S=>S.type==="mdxJsxAttribute"),T=(S,w)=>{let L=E.find(I=>I.name===S);L&&!E.some(I=>I.name===w)&&f(L.position.start.offset,L.position.start.offset+S.length,w)};if(h==="ParamField")for(let S of["body","query","path","header","cookie"])T(S,"name");if(h==="CardGroup"&&T("cols","limit"),h==="Accordion"&&T("default-open","defaultOpen"),h==="Expandable"&&(T("title","title"),E.some(S=>S.name==="title")||f(m.position.start.offset+1+h.length,m.position.start.offset+1+h.length,' title="Details"')),P!==h){let S=m.position.start.offset;f(S+1,S+1+h.length,P+(yt[h]?` type="${yt[h]}"`:""));let w=m.position.end.offset,L=new RegExp(`</${h}\\s*>$`).exec(e.slice(S,w));L&&f(w-L[0].length+2,w-L[0].length+2+h.length,P)}xo.has(h)?(u.add(h),n("component-adapter","warning",t,`<${h}> uses an editable React adapter. Review visual styling and optional props.`,$)):/^[A-Z]/.test(P)&&!wo.has(P)&&n("unsupported-component","error",t,`<${h}> needs a local component implementation or import.`,$);for(let S of E)if(["href","src"].includes(S.name)&&typeof S.value=="string"){let w=g(S.value);if(w!==S.value){let L=S.position.start.offset,F=e.slice(L,S.position.end.offset).indexOf(S.value);F>=0&&f(L+F,L+F+S.value.length,w)}}}),c.sort((m,h)=>h.start-m.start||h.end-m.end);let b=e;for(let m of c)b=b.slice(0,m.start)+m.value+b.slice(m.end);if(u.size){let m=G.posix.relative(G.posix.dirname(r.get(t)||t),he);b+=`
|
|
4
4
|
|
|
5
|
-
import { ${[...u].sort().join(", ")} } from ${JSON.stringify(
|
|
6
|
-
`}try{await
|
|
7
|
-
`).length)}}function
|
|
8
|
-
`:e,scripts:a}}function
|
|
5
|
+
import { ${[...u].sort().join(", ")} } from ${JSON.stringify(m.startsWith(".")?m:"./"+m)};
|
|
6
|
+
`}try{await go(b,{remarkPlugins:[fn,ho,mn]})}catch(m){n("mdx-compile","error",t,m.reason||m.message,m.line)}return{text:b,adapters:[...u],components:[...y].sort(),assets:[...p]}}function hn(e,t,r){let n=[[/\b(?:window|globalThis)\s*(?:\?\.)?\s*\.?(?:mintlify|\[\s*['"]mintlify['"]\s*\])|mintlify:user/,"mintlify-browser-api","error","Mintlify browser APIs/events need a Velu implementation; script preserved without inventing an API mapping."],[/__NEXT_DATA__|next\/router|next\/navigation|routeChangeComplete|next-route-announcer/,"next-runtime","error","Script depends on Next.js internals; adapt it to Velu\u2019s React Router runtime."],[/DOMContentLoaded|\bwindow\.onload\b|addEventListener\(\s*['"]load['"]/,"script-lifecycle","warning","Script loads after hydration; use document.readyState or an immediate initializer when DOMContentLoaded/load has already fired."],[/\brequire\s*\(|\bmodule\.exports|\bprocess\.env|from\s*['"]node:/,"node-script","error","This .js file is auto-loaded in the browser but contains Node.js constructs. Move tooling outside the docs content root or use .cjs/.mjs."],[/(?:^|\n)\s*(?:import\s|export\s)/,"module-script","error","Auto-loaded JavaScript uses classic scripts. Bundle ES modules for the browser or move them to explicitly imported .jsx/.mjs modules."],[/document\.querySelector|document\.getElementById|MutationObserver/,"script-dom","warning","Verify DOM hooks and behavior after client-side navigation; scripts execute once per full page load."]];for(let[o,i,a,s]of n){let l=o.exec(e);l&&r(i,a,t,s,e.slice(0,l.index).split(`
|
|
7
|
+
`).length)}}function yn(e,t,r){let n=JSON.parse(e),o=!1,i=!1,a=[];for(let[s,l]of Object.entries(n.scripts||{})){if(typeof l!="string"||!/\b(?:mint|mintlify)\b/.test(l))continue;i=!0;let c=/^(?:(?:npx(?: --no-install)?|yarn|pnpm(?: exec)?|bunx)\s+)?(?:mint|mintlify)\s+(dev|validate|version|v|update)\s*$/.exec(l.trim());if(c){let u=`velu ${c[1]==="v"?"version":c[1]}`;n.scripts[s]=u,o=!0,a.push({name:s,action:"converted",from:l,to:u})}else a.push({name:s,action:"preserved",from:l}),r("npm-script","warning",`package.json:scripts.${s}`,"Mintlify command/flags or compound shell script has no verified equivalent. Original retained; update manually.")}for(let s of["dependencies","devDependencies","optionalDependencies"])Object.keys(n[s]||{}).some(l=>["mint","mintlify","@mintlify/cli"].includes(l))&&(i=!0);return i&&!n.dependencies?.["@veluai/velu"]&&!n.devDependencies?.["@veluai/velu"]&&(n.devDependencies={...n.devDependencies,"@veluai/velu":`^${t}`},o=!0),i&&r("package-install","warning","package.json","Run your package manager in the migrated directory to refresh its lockfile. Mintlify dependencies remain for scripts that still need them; remove them after review."),{text:o?JSON.stringify(n,null,2)+`
|
|
8
|
+
`:e,scripts:a}}function vn(e,t,r,n){let o;try{o=vo(e,{sourceType:"unambiguous",plugins:["jsx",.../\.[cm]?tsx?$/.test(t)?["typescript"]:[]]})}catch(l){return n("module-syntax","error",t,l.message,l.loc?.line),e}let i=[],a=new Set,s=l=>{if(!l||typeof l!="object")return;let c=["ImportDeclaration","ExportNamedDeclaration","ExportAllDeclaration"].includes(l.type)?l.source:l.type==="CallExpression"&&(l.callee?.type==="Import"||l.callee?.name==="require")?l.arguments?.[0]:null;if(c?.type==="StringLiteral"&&!a.has(c.start)){a.add(c.start);let u=c.value;if(u.startsWith(".")||u.startsWith("/")){let p=G.posix.normalize(u.startsWith("/")?u.slice(1):G.posix.join(G.posix.dirname(t),u)),y=r.get(p);if(y){let f=G.posix.relative(G.posix.dirname(r.get(t)||t),y),g=f.startsWith(".")?f:"./"+f;u!==g&&i.push({start:c.start,end:c.end,value:JSON.stringify(g)})}else n("missing-import","error",t,`Local module import missing or ignored: ${u}`,c.loc?.start.line)}}for(let[u,p]of Object.entries(l))["loc","comments","tokens","extra"].includes(u)||(Array.isArray(p)?p.forEach(s):p&&typeof p=="object"&&s(p))};s(o.program);for(let l of i.sort((c,u)=>u.start-c.start))e=e.slice(0,l.start)+l.value+e.slice(l.end);return e}function bn(e,t,r,n){let o;try{o=bo.parse(e,{from:t})}catch(s){return n("css-syntax","error",t,s.reason||s.message,s.line),e}let i=new Set,a;return o.walkRules(s=>{for(let l of s.selector.matchAll(/#(?:content|navbar|sidebar(?:-content)?|navigation-items|page-title|header|footer|table-of-contents)(?![\w-])/g))i.add(l[0]),a??=s.source?.start?.line}),i.size&&n("css-dom","warning",t,`Styles target renderer structure (${[...i].join(", ")}). Selectors are preserved, but matching elements and their nesting can differ in Velu; compare page headers, sidebars, API pages, and mobile layouts in the browser.`,a),o.walkDecls(s=>{s.value=s.value.replace(/url\(\s*(?:"([^"\\]*)"|'([^'\\]*)'|([^)'"\\\s]*))\s*\)/gi,(l,c,u,p)=>{let y=c??u??p;if(!y||/^(?:[a-z][a-z0-9+.-]*:|\/|#)/i.test(y))return l;let f=/^([^?#]*)(.*)$/.exec(y),g=G.posix.normalize(G.posix.join(G.posix.dirname(t),f[1]));return r.has(g)?`url("${"/"+r.get(g).split("/").map(encodeURIComponent).join("/")+f[2]}")`:(n("css-missing-asset","error",t,`CSS asset missing or ignored: ${y}`,s.source?.start?.line),l)})}),o.walkAtRules("import",s=>n("css-import","warning",t,"Custom CSS files are included globally. Check @import for duplicate styles and loading order.",s.source?.start?.line)),o.toString()}var he,yt,xo,wo,vt,xn=_(()=>{We();Ge();he="snippets/velu-mintlify-compat.jsx",yt={Note:"note",Tip:"tip",Warning:"warning",Info:"info",Check:"check",Danger:"danger"},xo=new Set(["Tabs","Tab","Frame","Tooltip","Badge","Button","Panel"]),wo=new Set(ne),vt=`import React from 'react';
|
|
9
9
|
export function Tabs({ children, defaultIndex = 0 }) {
|
|
10
10
|
const tabs = React.Children.toArray(children).filter(React.isValidElement);
|
|
11
11
|
const [active, setActive] = React.useState(defaultIndex);
|
|
@@ -30,27 +30,27 @@ export function Tooltip({children,tip}) { return <span title={typeof tip === 'st
|
|
|
30
30
|
export function Badge({children,color,className=''}) { return <span data-component="badge" className={className} style={{border:'1px solid currentColor',borderRadius:'1rem',padding:'.1rem .5rem',color}}>{children}</span>; }
|
|
31
31
|
export function Button({children,href,variant,size,icon,iconType,...props}) { return href ? <a href={href} {...props}>{children}</a> : <button type="button" {...props}>{children}</button>; }
|
|
32
32
|
export function Panel({children}) { return <aside data-component="panel">{children}</aside>; }
|
|
33
|
-
`});import vo from"github-slugger";import bo from"iso-639-1";function wo(e){let t=String(e).toLowerCase();return bo.getNativeName(t)||e}function He(e){return new vo().slug(String(e??""))}function xn(e){let t=String(e).replace(/^\/+|\/+$/g,"").split("/").filter(Boolean);return t[t.length-1]==="index"&&t.pop(),"/"+t.join("/")}function bt(e){let t=String(e).split("#")[0].split("?")[0];try{t=decodeURI(t)}catch{}return t.startsWith("/")||(t="/"+t),t.length>1&&(t=t.replace(/\/+$/,"")),t||"/"}function Y(e){let t={kind:"root",children:je(e??{})};return e?.preservePagePaths===!0&&(t.preservePagePaths=!0),Sn(t.children),t}function je(e){let t=Array.isArray(e.anchors)?e.anchors.map(Ao):[];if(Array.isArray(e.products))return[...t,...e.products.map($o)];if(Array.isArray(e.versions))return[...t,...e.versions.map(So)];if(Array.isArray(e.languages))return[...t,...e.languages.map(ko)];if(Array.isArray(e.tabs))return[...t,...e.tabs.map(jo)];let r=[...t];return Array.isArray(e.groups)&&r.push(...e.groups.map(wn)),Array.isArray(e.pages)&&r.push(...e.pages.map($n)),r}function $o(e){return{kind:"product",label:e.name??e.product,slug:He(e.product),icon:e.icon,color:e.color,default:!!e.default,children:je(e)}}function So(e){return{kind:"version",label:e.version,slug:He(e.version),default:!!e.default,children:je(e)}}function ko(e){let t=String(e.language);return{kind:"language",code:t,label:wo(t),slug:He(t),default:!!e.default,children:je(e)}}function jo(e){return{kind:"tab",label:e.tab,slug:He(e.tab),icon:e.icon,href:e.href,children:je(e)}}function Ao(e){return{kind:"anchor",label:e.anchor,icon:e.icon,href:e.href,color:e.color}}function wn(e){let t=(e.pages??[]).map($n);return e.root&&t.unshift({kind:"page",pagePath:e.root}),{kind:"group",label:e.group,icon:e.icon,expanded:!!e.expanded,root:e.root,children:t}}function $n(e){if(typeof e=="string")return{kind:"page",pagePath:e};if(e&&e.apiPage)return{kind:"page",pagePath:e.apiPage,label:e.label,method:e.method,api:!0};if(e&&typeof e.page=="string"){let t={kind:"page",pagePath:e.page};return e.icon&&(t.icon=e.icon),(e.title||e.label)&&(t.label=e.title??e.label),t}return wn(e)}function Sn(e){for(let t of xo){let r=e.filter(n=>n.kind===t);r.length&&!r.some(n=>n.default)&&(r[0].default=!0)}for(let t of e)t.children&&Sn(t.children)}function ne(e){let t=[],r=(n,o,i)=>{if(n.kind==="page"){t.push({pagePath:n.pagePath,url:Oo(n.pagePath,o),ctx:{...o},ancestors:i,node:n});return}let a=o;n.kind==="product"?a={...o,product:n.default?null:n.slug}:n.kind==="version"?a={...o,version:n.default?null:n.slug}:n.kind==="language"&&(a={...o,language:n.default?null:n.slug});let s=n.kind==="root"?i:[...i,n];for(let l of n.children??[])r(l,a,s)};return r(e,{product:null,version:null,language:null,...e.preservePagePaths?{preservePagePaths:!0}:{}},[]),t}function Oo(e,t){if(t.preservePagePaths)return xn(e);let r=[t.product,t.version,t.language].filter(Boolean),n=xn(e).split("/").filter(Boolean);return"/"+[...r,...n].join("/")}var xo,re=_(()=>{xo=["product","version","language"]});function To(e,t){let r=t.slice(2).split("/").filter(o=>o!=="").map(o=>decodeURIComponent(o).replace(/~1/g,"/").replace(/~0/g,"~")),n=e;for(let o of r){if(n==null||typeof n!="object")return;n=n[o]}return n}function kn(e){let t=new Map;function r(n){if(n==null||typeof n!="object")return n;if(t.has(n))return t.get(n);if(typeof n.$ref=="string"){let i=n.$ref;if(!i.startsWith("#/"))throw new Error(`external $ref "${i}" is not supported in the instant preview \u2014 inline it or use a single-file spec`);let a=To(e,i);if(a===void 0)throw new Error(`$ref "${i}" does not resolve`);let s=r(a);return t.set(n,s),s}let o=Array.isArray(n)?[]:{};t.set(n,o);for(let[i,a]of Object.entries(n))o[i]=r(a);return o}return r(e)}var jn=_(()=>{});function ce(e){return!e||typeof e!="object"?e||{}:Array.isArray(e.allOf)?e.allOf.reduce((t,r)=>{let n=ce(r);return{...t,...n,properties:{...t.properties||{},...n.properties||{}},required:[...t.required||[],...n.required||[]]}},{...e,allOf:void 0}):Array.isArray(e.oneOf)&&e.oneOf.length?ce(e.oneOf[0]):Array.isArray(e.anyOf)&&e.anyOf.length?ce(e.anyOf[0]):e}function Ae(e){let t=ce(e);if(!t||typeof t!="object")return"any";if(Array.isArray(t.enum)&&t.enum.length)return`enum<${typeof t.enum[0]}>`;if(t.type==="array")return`${Ae(t.items||{})}[]`;let r=t.type||(t.properties?"object":"any");return t.format?`${r}<${t.format}>`:r}function ye(e,t=0){let r=ce(e);if(!r||typeof r!="object")return null;if(r.example!==void 0)return r.example;if(r.default!==void 0)return r.default;if(Array.isArray(r.enum)&&r.enum.length)return r.enum[0];if(t>=6)return r.type==="object"?{}:null;switch(r.type){case"object":{let n={};for(let[o,i]of Object.entries(r.properties||{}))n[o]=ye(i,t+1);return n}case"array":return[ye(r.items||{},t+1)];case"integer":case"number":return 0;case"boolean":return!0;default:return Co(r)}}function Co(e){switch(e.format){case"date-time":return"2024-01-01T00:00:00Z";case"date":return"2024-01-01";case"email":return"user@example.com";case"uuid":return"3fa85f64-5717-4562-b3fc-2c963f66afa6";case"uri":case"url":return"https://example.com";default:return"<string>"}}function xt(e){let t=ce(e);if(!t||t.type!=="object"||!t.properties)return t&&(t.type||t.items)?[{name:"body",type:Ae(t),required:!1,description:t.description||""}]:[];let r=new Set(t.required||[]);return Object.entries(t.properties).map(([n,o])=>{let i=ce(o);return{name:n,type:Ae(i),required:r.has(n),description:i.description||"",enum:Array.isArray(i.enum)?i.enum:void 0,deprecated:i.deprecated||void 0}})}function Po(e){let t=e.schema||{};return{name:e.name,in:e.in,required:e.in==="path"?!0:!!e.required,type:Ae(t),description:e.description||"",enum:Array.isArray(t.enum)?t.enum:void 0,example:ye(t),deprecated:e.deprecated||void 0}}function On(e){if(!e||typeof e!="object")return null;let t=Object.keys(e),r=t.find(n=>/json/i.test(n))||t[0];return r?{contentType:r,media:e[r]}:null}function Lo(e){if(!e)return null;let t=On(e.content);if(!t)return null;let r=t.media.schema||{};return{required:!!e.required,description:e.description||"",contentType:t.contentType,fields:xt(r),example:t.media.example??ye(r)}}function _o(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,r])=>{let n=On(r?.content),o=n?.media?.schema||{};return{status:t,description:r?.description||"",contentType:n?.contentType||null,fields:n?xt(o):[],example:n?n.media.example??ye(o):null}})}function Ro(e,t){if(!Array.isArray(e)||!t)return[];let r=[],n=new Set;for(let o of e)for(let i of Object.keys(o||{})){let a=t[i];!a||n.has(i)||(n.add(i),r.push(Uo(i,a)))}return r.filter(Boolean)}function Uo(e,t){return t.type==="http"&&/bearer/i.test(t.scheme||"")?{name:"Authorization",in:"header",required:!0,type:"string",prefix:"Bearer",description:t.description||"Bearer authentication token."}:t.type==="http"&&/basic/i.test(t.scheme||"")?{name:"Authorization",in:"header",required:!0,type:"string",prefix:"Basic",description:t.description||"Basic authentication credentials."}:t.type==="apiKey"?{name:t.name||e,in:t.in||"header",required:!0,type:"string",description:t.description||"API key."}:t.type==="oauth2"||t.type==="openIdConnect"?{name:"Authorization",in:"header",required:!0,type:"string",prefix:"Bearer",description:t.description||"OAuth 2.0 access token."}:{name:e,in:"header",required:!0,type:"string",description:t.description||""}}function An(e){return String(e).replace(/\{[^}]+\}/g,t=>t.slice(1,-1)).replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function No(e){let{method:t,path:r,op:n,sharedParams:o,servers:i,schemes:a}=e,s=[...o||[],...n.parameters||[]],l={path:[],query:[],header:[],cookie:[]};for(let u of s)u&&l[u.in]&&l[u.in].push(Po(u));let c=n.security??e.globalSecurity;return{id:n.operationId?An(n.operationId):`${t}-${An(r)}`,method:t.toUpperCase(),path:r,title:n.summary||n.operationId||`${t.toUpperCase()} ${r}`,description:n.description||n.summary||"",tags:Array.isArray(n.tags)&&n.tags.length?n.tags:["API"],deprecated:n.deprecated||!1,auth:Ro(c,a),parameters:l,body:Lo(n.requestBody),responses:_o(n.responses),servers:(i||[]).map(u=>u.url).filter(Boolean)}}function Fo(e,t,r,n,o,i,a){let s={};e.openapi?s.openapi=e.openapi:e.swagger?s.swagger=e.swagger:s.openapi="3.0.0",s.info=e.info||{title:"API Reference",version:"1.0.0"};let l=(n.servers||i||[]).filter(Boolean);l.length&&(s.servers=l);let c={};Array.isArray(o)&&o.length&&(c.parameters=o),c[r]=n,s.paths={[t]:c};let u=n.security??e.security;if(a&&Array.isArray(u)&&u.length){let p={};for(let y of u)for(let m of Object.keys(y||{}))a[m]&&(p[m]=a[m]);Object.keys(p).length&&(e.swagger?s.securityDefinitions=p:s.components={securitySchemes:p})}return s}function Tn(e){let t=[],r=[],n=e.components?.securitySchemes||e.securityDefinitions||{},o=e.security||[],i=e.servers||(e.host?[{url:`https://${e.host}${e.basePath||""}`}]:[]);for(let[a,s]of Object.entries(e.paths||{})){if(!s||typeof s!="object")continue;let l=s.parameters||[],c=s.servers||i;for(let u of Eo){let p=s[u];!p||typeof p!="object"||(t.push(No({method:u,path:a,op:p,sharedParams:l,servers:p.servers||c,globalSecurity:o,schemes:n})),r.push(Fo(e,a,u,p,l,p.servers||c,n)))}}return{operations:t,segments:r}}function Oe(e){let t=e.servers||(e.host?[{url:`https://${e.host}${e.basePath||""}`}]:[]),{operations:r,segments:n}=Tn(e);return{title:e.info?.title||"API Reference",version:e.info?.version||"",servers:t.map(o=>o.url).filter(Boolean),operations:r,segments:n}}var Eo,Ke=_(()=>{Eo=["get","post","put","patch","delete","options","head","trace"]});function Io(e,{server:t}={}){let n=`${(t||e.servers?.[0]||"").replace(/\/+$/,"")}${e.path}`,o={};for(let a of e.auth||[])a.in==="header"&&(o[a.name]=a.prefix?`${a.prefix} <token>`:"<token>");for(let a of e.parameters?.header||[])o[a.name]||(o[a.name]=String(a.example??`<${a.type}>`));let i=!!e.body;return i&&(o["Content-Type"]=e.body.contentType||"application/json"),{method:e.method,url:n,headers:o,body:i?e.body.example??{}:null}}function Mo(e){let t=`curl --request ${e.method} \\
|
|
33
|
+
`});import $o from"github-slugger";import So from"iso-639-1";function jo(e){let t=String(e).toLowerCase();return So.getNativeName(t)||e}function He(e){return new $o().slug(String(e??""))}function wn(e){let t=String(e).replace(/^\/+|\/+$/g,"").split("/").filter(Boolean);return t[t.length-1]==="index"&&t.pop(),"/"+t.join("/")}function bt(e){let t=String(e).split("#")[0].split("?")[0];try{t=decodeURI(t)}catch{}return t.startsWith("/")||(t="/"+t),t.length>1&&(t=t.replace(/\/+$/,"")),t||"/"}function Y(e){let t={kind:"root",children:je(e??{})};return e?.preservePagePaths===!0&&(t.preservePagePaths=!0),kn(t.children),t}function je(e){let t=Array.isArray(e.anchors)?e.anchors.map(Co):[];if(Array.isArray(e.products))return[...t,...e.products.map(Ao)];if(Array.isArray(e.versions))return[...t,...e.versions.map(Oo)];if(Array.isArray(e.languages))return[...t,...e.languages.map(Eo)];if(Array.isArray(e.tabs))return[...t,...e.tabs.map(To)];let r=[...t];return Array.isArray(e.groups)&&r.push(...e.groups.map($n)),Array.isArray(e.pages)&&r.push(...e.pages.map(Sn)),r}function Ao(e){return{kind:"product",label:e.name??e.product,slug:He(e.product),icon:e.icon,color:e.color,default:!!e.default,children:je(e)}}function Oo(e){return{kind:"version",label:e.version,slug:He(e.version),default:!!e.default,children:je(e)}}function Eo(e){let t=String(e.language);return{kind:"language",code:t,label:jo(t),slug:He(t),default:!!e.default,children:je(e)}}function To(e){return{kind:"tab",label:e.tab,slug:He(e.tab),icon:e.icon,href:e.href,children:je(e)}}function Co(e){return{kind:"anchor",label:e.anchor,icon:e.icon,href:e.href,color:e.color}}function $n(e){let t=(e.pages??[]).map(Sn);return e.root&&t.unshift({kind:"page",pagePath:e.root}),{kind:"group",...e.public!==void 0?{public:e.public}:{},label:e.group,icon:e.icon,expanded:!!e.expanded,root:e.root,children:t}}function Sn(e){if(typeof e=="string")return{kind:"page",pagePath:e};if(e&&e.apiPage)return{kind:"page",pagePath:e.apiPage,label:e.label,method:e.method,api:!0};if(e&&typeof e.page=="string"){let t={kind:"page",pagePath:e.page};return e.icon&&(t.icon=e.icon),(e.title||e.label)&&(t.label=e.title??e.label),t}return $n(e)}function kn(e){for(let t of ko){let r=e.filter(n=>n.kind===t);r.length&&!r.some(n=>n.default)&&(r[0].default=!0)}for(let t of e)t.children&&kn(t.children)}function ee(e){let t=[],r=(n,o,i)=>{if(n.kind==="page"){t.push({pagePath:n.pagePath,url:Po(n.pagePath,o),ctx:{...o},ancestors:i,node:n});return}let a=o;n.kind==="product"?a={...o,product:n.default?null:n.slug}:n.kind==="version"?a={...o,version:n.default?null:n.slug}:n.kind==="language"&&(a={...o,language:n.default?null:n.slug});let s=n.kind==="root"?i:[...i,n];for(let l of n.children??[])r(l,a,s)};return r(e,{product:null,version:null,language:null,...e.preservePagePaths?{preservePagePaths:!0}:{}},[]),t}function Po(e,t){if(t.preservePagePaths)return wn(e);let r=[t.product,t.version,t.language].filter(Boolean),n=wn(e).split("/").filter(Boolean);return"/"+[...r,...n].join("/")}var ko,re=_(()=>{ko=["product","version","language"]});function Lo(e,t){let r=t.slice(2).split("/").filter(o=>o!=="").map(o=>decodeURIComponent(o).replace(/~1/g,"/").replace(/~0/g,"~")),n=e;for(let o of r){if(n==null||typeof n!="object")return;n=n[o]}return n}function jn(e){let t=new Map;function r(n){if(n==null||typeof n!="object")return n;if(t.has(n))return t.get(n);if(typeof n.$ref=="string"){let i=n.$ref;if(!i.startsWith("#/"))throw new Error(`external $ref "${i}" is not supported in the instant preview \u2014 inline it or use a single-file spec`);let a=Lo(e,i);if(a===void 0)throw new Error(`$ref "${i}" does not resolve`);let s=r(a);return t.set(n,s),s}let o=Array.isArray(n)?[]:{};t.set(n,o);for(let[i,a]of Object.entries(n))o[i]=r(a);return o}return r(e)}var An=_(()=>{});function ce(e){return!e||typeof e!="object"?e||{}:Array.isArray(e.allOf)?e.allOf.reduce((t,r)=>{let n=ce(r);return{...t,...n,properties:{...t.properties||{},...n.properties||{}},required:[...t.required||[],...n.required||[]]}},{...e,allOf:void 0}):Array.isArray(e.oneOf)&&e.oneOf.length?ce(e.oneOf[0]):Array.isArray(e.anyOf)&&e.anyOf.length?ce(e.anyOf[0]):e}function Ae(e){let t=ce(e);if(!t||typeof t!="object")return"any";if(Array.isArray(t.enum)&&t.enum.length)return`enum<${typeof t.enum[0]}>`;if(t.type==="array")return`${Ae(t.items||{})}[]`;let r=t.type||(t.properties?"object":"any");return t.format?`${r}<${t.format}>`:r}function ye(e,t=0){let r=ce(e);if(!r||typeof r!="object")return null;if(r.example!==void 0)return r.example;if(r.default!==void 0)return r.default;if(Array.isArray(r.enum)&&r.enum.length)return r.enum[0];if(t>=6)return r.type==="object"?{}:null;switch(r.type){case"object":{let n={};for(let[o,i]of Object.entries(r.properties||{}))n[o]=ye(i,t+1);return n}case"array":return[ye(r.items||{},t+1)];case"integer":case"number":return 0;case"boolean":return!0;default:return Ro(r)}}function Ro(e){switch(e.format){case"date-time":return"2024-01-01T00:00:00Z";case"date":return"2024-01-01";case"email":return"user@example.com";case"uuid":return"3fa85f64-5717-4562-b3fc-2c963f66afa6";case"uri":case"url":return"https://example.com";default:return"<string>"}}function xt(e){let t=ce(e);if(!t||t.type!=="object"||!t.properties)return t&&(t.type||t.items)?[{name:"body",type:Ae(t),required:!1,description:t.description||""}]:[];let r=new Set(t.required||[]);return Object.entries(t.properties).map(([n,o])=>{let i=ce(o);return{name:n,type:Ae(i),required:r.has(n),description:i.description||"",enum:Array.isArray(i.enum)?i.enum:void 0,deprecated:i.deprecated||void 0}})}function No(e){let t=e.schema||{};return{name:e.name,in:e.in,required:e.in==="path"?!0:!!e.required,type:Ae(t),description:e.description||"",enum:Array.isArray(t.enum)?t.enum:void 0,example:ye(t),deprecated:e.deprecated||void 0}}function En(e){if(!e||typeof e!="object")return null;let t=Object.keys(e),r=t.find(n=>/json/i.test(n))||t[0];return r?{contentType:r,media:e[r]}:null}function Uo(e){if(!e)return null;let t=En(e.content);if(!t)return null;let r=t.media.schema||{};return{required:!!e.required,description:e.description||"",contentType:t.contentType,fields:xt(r),example:t.media.example??ye(r)}}function Fo(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,r])=>{let n=En(r?.content),o=n?.media?.schema||{};return{status:t,description:r?.description||"",contentType:n?.contentType||null,fields:n?xt(o):[],example:n?n.media.example??ye(o):null}})}function Io(e,t){if(!Array.isArray(e)||!t)return[];let r=[],n=new Set;for(let o of e)for(let i of Object.keys(o||{})){let a=t[i];!a||n.has(i)||(n.add(i),r.push(Mo(i,a)))}return r.filter(Boolean)}function Mo(e,t){return t.type==="http"&&/bearer/i.test(t.scheme||"")?{name:"Authorization",in:"header",required:!0,type:"string",prefix:"Bearer",description:t.description||"Bearer authentication token."}:t.type==="http"&&/basic/i.test(t.scheme||"")?{name:"Authorization",in:"header",required:!0,type:"string",prefix:"Basic",description:t.description||"Basic authentication credentials."}:t.type==="apiKey"?{name:t.name||e,in:t.in||"header",required:!0,type:"string",description:t.description||"API key."}:t.type==="oauth2"||t.type==="openIdConnect"?{name:"Authorization",in:"header",required:!0,type:"string",prefix:"Bearer",description:t.description||"OAuth 2.0 access token."}:{name:e,in:"header",required:!0,type:"string",description:t.description||""}}function On(e){return String(e).replace(/\{[^}]+\}/g,t=>t.slice(1,-1)).replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function zo(e){let{method:t,path:r,op:n,sharedParams:o,servers:i,schemes:a}=e,s=[...o||[],...n.parameters||[]],l={path:[],query:[],header:[],cookie:[]};for(let u of s)u&&l[u.in]&&l[u.in].push(No(u));let c=n.security??e.globalSecurity;return{id:n.operationId?On(n.operationId):`${t}-${On(r)}`,method:t.toUpperCase(),path:r,title:n.summary||n.operationId||`${t.toUpperCase()} ${r}`,description:n.description||n.summary||"",tags:Array.isArray(n.tags)&&n.tags.length?n.tags:["API"],deprecated:n.deprecated||!1,auth:Io(c,a),parameters:l,body:Uo(n.requestBody),responses:Fo(n.responses),servers:(i||[]).map(u=>u.url).filter(Boolean)}}function Vo(e,t,r,n,o,i,a){let s={};e.openapi?s.openapi=e.openapi:e.swagger?s.swagger=e.swagger:s.openapi="3.0.0",s.info=e.info||{title:"API Reference",version:"1.0.0"};let l=(n.servers||i||[]).filter(Boolean);l.length&&(s.servers=l);let c={};Array.isArray(o)&&o.length&&(c.parameters=o),c[r]=n,s.paths={[t]:c};let u=n.security??e.security;if(a&&Array.isArray(u)&&u.length){let p={};for(let y of u)for(let f of Object.keys(y||{}))a[f]&&(p[f]=a[f]);Object.keys(p).length&&(e.swagger?s.securityDefinitions=p:s.components={securitySchemes:p})}return s}function Tn(e){let t=[],r=[],n=e.components?.securitySchemes||e.securityDefinitions||{},o=e.security||[],i=e.servers||(e.host?[{url:`https://${e.host}${e.basePath||""}`}]:[]);for(let[a,s]of Object.entries(e.paths||{})){if(!s||typeof s!="object")continue;let l=s.parameters||[],c=s.servers||i;for(let u of _o){let p=s[u];!p||typeof p!="object"||(t.push(zo({method:u,path:a,op:p,sharedParams:l,servers:p.servers||c,globalSecurity:o,schemes:n})),r.push(Vo(e,a,u,p,l,p.servers||c,n)))}}return{operations:t,segments:r}}function Oe(e){let t=e.servers||(e.host?[{url:`https://${e.host}${e.basePath||""}`}]:[]),{operations:r,segments:n}=Tn(e);return{title:e.info?.title||"API Reference",version:e.info?.version||"",servers:t.map(o=>o.url).filter(Boolean),operations:r,segments:n}}var _o,Ke=_(()=>{_o=["get","post","put","patch","delete","options","head","trace"]});function Jo(e,{server:t}={}){let n=`${(t||e.servers?.[0]||"").replace(/\/+$/,"")}${e.path}`,o={};for(let a of e.auth||[])a.in==="header"&&(o[a.name]=a.prefix?`${a.prefix} <token>`:"<token>");for(let a of e.parameters?.header||[])o[a.name]||(o[a.name]=String(a.example??`<${a.type}>`));let i=!!e.body;return i&&(o["Content-Type"]=e.body.contentType||"application/json"),{method:e.method,url:n,headers:o,body:i?e.body.example??{}:null}}function Bo(e){let t=`curl --request ${e.method} \\
|
|
34
34
|
--url ${e.url}`;for(let[r,n]of Object.entries(e.headers))t+=` \\
|
|
35
35
|
--header '${r}: ${n}'`;return e.body!=null&&(t+=` \\
|
|
36
|
-
--data '${JSON.stringify(e.body)}'`),t}function
|
|
36
|
+
--data '${JSON.stringify(e.body)}'`),t}function Do(e){let t=[` method: '${e.method}'`];if(Object.keys(e.headers).length){let r=Object.entries(e.headers).map(([n,o])=>` '${n}': '${o}'`).join(`,
|
|
37
37
|
`);t.push(` headers: {
|
|
38
38
|
${r}
|
|
39
39
|
}`)}return e.body!=null&&t.push(` body: JSON.stringify(${wt(e.body," ")})`),[`const res = await fetch('${e.url}', {`,t.join(`,
|
|
40
40
|
`),"});","const data = await res.json();"].join(`
|
|
41
|
-
`)}function
|
|
41
|
+
`)}function qo(e){let t=["import requests","",`url = "${e.url}"`];if(Object.keys(e.headers).length){let n=Object.entries(e.headers).map(([o,i])=>` "${o}": "${i}"`).join(`,
|
|
42
42
|
`);t.push(`headers = {
|
|
43
43
|
${n}
|
|
44
44
|
}`)}let r=["url"];return e.body!=null&&(t.push(`payload = ${wt(e.body,"")}`),r.push("json=payload")),Object.keys(e.headers).length&&r.push("headers=headers"),t.push("",`response = requests.${e.method.toLowerCase()}(${r.join(", ")})`,"print(response.json())"),t.join(`
|
|
45
|
-
`)}function
|
|
46
|
-
`)}function Xe(e,{server:t,languages:r=$t}={}){let n=
|
|
45
|
+
`)}function Go(e){let t=e.method.charAt(0)+e.method.slice(1).toLowerCase(),r=["require 'net/http'","require 'json'","",`uri = URI("${e.url}")`,"http = Net::HTTP.new(uri.host, uri.port)","http.use_ssl = true",`request = Net::HTTP::${t}.new(uri)`];for(let[n,o]of Object.entries(e.headers))r.push(`request['${n}'] = '${o}'`);return e.body!=null&&r.push(`request.body = ${wt(e.body,"")}.to_json`),r.push("","response = http.request(request)","puts response.body"),r.join(`
|
|
46
|
+
`)}function Xe(e,{server:t,languages:r=$t}={}){let n=Jo(e,{server:t});return r.filter(o=>Cn[o]).map(o=>({key:o,label:Wo[o],language:Ho[o],code:Cn[o](n)}))}var wt,Cn,Wo,Ho,$t,St=_(()=>{wt=(e,t)=>JSON.stringify(e,null,2).split(`
|
|
47
47
|
`).map((r,n)=>n===0?r:t+r).join(`
|
|
48
|
-
`);
|
|
49
|
-
`)}function
|
|
50
|
-
`)}function
|
|
51
|
-
export const veluApi = ${JSON.stringify({operation:u,samples:
|
|
48
|
+
`);Cn={curl:Bo,javascript:Do,python:qo,ruby:Go},Wo={curl:"cURL",javascript:"JavaScript",python:"Python",ruby:"Ruby"},Ho={curl:"bash",javascript:"javascript",python:"python",ruby:"ruby"},$t=["curl","javascript","python","ruby"]});function Ln(e){let t=e?.font?.family;return typeof t=="string"&&t.trim()?t.trim():e?.theme==="vepa"||["thulir","aalam","nila","kadhir"].includes(e?.theme)?"Inter":Xo}function Ee(e){return e==="vepa"||["thulir","aalam","nila","kadhir"].includes(e)?e:"velu"}function jt({light:e,dark:t,family:r,theme:n,primary:o=e,cta:i=o}){let a=n==="vepa"||["thulir","aalam","nila","kadhir"].includes(n)?Yo(o,t):"";return[":root:root {",` --accent-color: ${e};`,...["thulir","aalam","nila","kadhir"].includes(n)?[` --thulir-cta-color: ${i};`]:[],` --font-sans: "${r}", sans-serif;`,a,"}",':root:root[data-theme="dark"] {',` --accent-color: ${t};`,"}"].join(`
|
|
49
|
+
`)}function Yo(e,t){let r=(s,l)=>{let c=/^#([\da-f]{3}|[\da-f]{6})$/i.exec(s||"")?.[1];return c||(c=l),c.length===3&&(c=[...c].map(u=>u+u).join("")),[0,2,4].map(u=>parseInt(c.slice(u,u+2),16))},n=r(e,"16a34a"),o=r(t,"4ade80"),i={50:250,100:245,200:229,300:212,400:163,500:115,600:82,700:64,800:38,900:23,950:10},a=.95/(.95+.6-.95*.6);return[...Object.entries(i).map(([s,l])=>` --vepa-gray-${s}: rgb(${n.map(c=>Math.round(c*(1-a)+l*a)).join(" ")});`),` --vepa-background-dark: rgb(${o.map((s,l)=>Math.round([9,9,11][l]*.98+s*.02)).join(" ")});`].join(`
|
|
50
|
+
`)}function Te(e){if(!e||typeof e!="object")return null;let t=[];if(e.socials&&typeof e.socials=="object")for(let[n,o]of Object.entries(e.socials))typeof o!="string"||!o.trim()||t.push({kind:Ko[n]??n,href:o.trim()});let r=Array.isArray(e.links)?e.links.filter(n=>n&&typeof n=="object").map(n=>({title:(n.header??n.title??"").trim(),items:(Array.isArray(n.items)?n.items:[]).filter(o=>o&&o.label).map(o=>({label:o.label,href:o.href??"#"}))})).filter(n=>n.title||n.items.length):[];return!t.length&&!r.length?null:{socials:t,links:r}}function kt(e){return/^(https?:)?\/\//.test(e)||/^(mailto|tel):/.test(e)}function Ce(e){if(!e||typeof e!="object")return null;let t=(Array.isArray(e.links)?e.links:[]).filter(o=>o&&typeof o.href=="string"&&o.href.trim()).map(o=>({label:o.label??"",href:o.href.trim(),icon:o.icon??null,external:kt(o.href.trim())})),r=null,n=e.primary;if(n&&typeof n=="object"&&typeof n.href=="string"&&n.href.trim()){let o=n.href.trim();r=n.type==="github"?{kind:"github",label:n.label??"GitHub",href:o,external:kt(o)}:{kind:"button",label:n.label??"",href:o,external:kt(o)}}return!t.length&&!r?null:{links:t,primary:r}}function At(e){if(e==null)return{options:[...Pn],display:"header"};if(typeof e!="object")return{options:[],display:"header"};let t=e.display==="toc"?"toc":"header",r=Array.isArray(e.options)?e.options:Pn,n=[];for(let o of r)typeof o=="string"?Zo.has(o)&&n.push(o):o&&typeof o=="object"&&o.title&&o.href&&n.push({title:String(o.title),description:o.description?String(o.description):"",href:String(o.href),icon:typeof o.icon=="string"?o.icon:void 0});return{options:n,display:t}}function Z(e){if(!e||typeof e!="object")return{server:null,proxy:!0,languages:void 0};let t=e.playground||{};return{server:typeof e.server=="string"?e.server.trim():null,proxy:t.proxy!==!1&&t.display!=="none",languages:Array.isArray(e.examples?.languages)?e.examples.languages:void 0}}function Pe(e){if(!e||typeof e!="object")return null;let t=typeof e.apiBase=="string"&&e.apiBase.trim()?e.apiBase.trim().replace(/\/+$/,""):null,r=typeof e.host=="string"&&e.host.trim()?e.host.trim():null,n=Array.isArray(e.suggestions)?e.suggestions.filter(o=>typeof o=="string"&&o.trim()).map(o=>o.trim()).slice(0,6):[];return!t&&!n.length?null:{apiBase:t,host:r,suggestions:n}}var Ko,Xo,Zo,Pn,Le=_(()=>{Ko={twitter:"x","x-twitter":"x"},Xo="Google Sans Flex";Zo=new Set(["copy","assistant","view","download-pdf","download-spec","chatgpt","claude","perplexity","grok","aistudio","devin","windsurf","mcp","add-mcp","cursor","vscode","devin-mcp"]),Pn=["copy","view","chatgpt","claude"]});import Qo from"node:path";import _n from"js-yaml";function Rn(e,t,r,n,o){let i=/^(?:\uFEFF)?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(e);if(!i)return{text:e,converted:!1};let a;try{a=_n.load(i[1])}catch{return{text:e,converted:!1}}if(typeof a?.openapi!="string")return{text:e,converted:!1};let s=/^(?:(.+?)\s+)?(GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD|TRACE)\s+(\/\S+)$/i.exec(a.openapi.trim());if(!s)return{text:e,converted:!1};let l=s[1]?[s[1]]:[].concat(n.openapi||n.api?.openapi||[]);if(l=l.map(u=>typeof u=="string"?u:u?.source).filter(Boolean),!l.length)return{text:e,converted:!1};let c=[];try{for(let m of l){if(/^[a-z][a-z0-9+.-]*:/i.test(m))throw new Error("Remote specs must be downloaded locally first.");let h=Qo.posix.normalize(m.replace(/^\//,"")),$=r.get(h);if(!$)throw new Error(`Spec is missing or ignored: ${h}`);let P=/\.ya?ml$/i.test(h)?_n.load($.toString("utf8")):ht($.toString("utf8"),h),E=Oe(jn(P));for(let T of E.operations)T.method===s[2].toUpperCase()&&T.path===s[3]&&c.push({operation:T,rel:h})}if(c.length!==1)throw new Error(`Expected exactly one matching operation; found ${c.length}.`);let{operation:u,rel:p}=c[0],y=Z(n.api),f=Xe(u,{server:y.server||u.servers?.[0],...y.languages?{languages:y.languages}:{}});if(/\bveluApi\b/.test(e))throw new Error("Reserved generated export name already used: veluApi");let b=`
|
|
51
|
+
export const veluApi = ${JSON.stringify({operation:u,samples:f,api:{proxy:y.proxy,server:y.server}})};
|
|
52
52
|
|
|
53
|
-
${e.slice(i[0].length)}`;return o("endpoint-snapshot","warning",t,`Generated the ${s[2].toUpperCase()} ${s[3]} playground from ${p}, preserving the page URL and body. This is an editable snapshot: regenerate after spec changes; review x-mint extensions and page-specific overrides.`),{text:e.slice(0,i[0].length)+
|
|
53
|
+
${e.slice(i[0].length)}`;return o("endpoint-snapshot","warning",t,`Generated the ${s[2].toUpperCase()} ${s[3]} playground from ${p}, preserving the page URL and body. This is an editable snapshot: regenerate after spec changes; review x-mint extensions and page-specific overrides.`),{text:e.slice(0,i[0].length)+b,converted:!0}}catch(u){return o("endpoint-conversion","error",t,`Could not migrate OpenAPI endpoint: ${u.message}`),{text:e,converted:!1}}}var Nn=_(()=>{An();Ke();St();Le();Ge()});var Vn={};Se(Vn,{MIGRATE_HELP:()=>Fn,migrateMintlify:()=>zn,parseMigrateArgs:()=>In,planMigration:()=>Mn,runMigrate:()=>ai});import M from"node:fs";import J from"node:path";import{randomUUID as ei,createHash as ti}from"node:crypto";import ni from"ignore";function In(e){if(e.includes("--help")||e.includes("-h"))return{help:!0};if(e.shift()!=="mintlify")throw new Error("Specify the source platform: velu migrate mintlify [source]");let t={},r=!1;for(let n=0;n<e.length;n++){let o=e[n];if(["--dry-run","--json","--strict"].includes(o))t[{"--dry-run":"dryRun","--json":"json","--strict":"strict"}[o]]=!0;else if(["--out","--config"].includes(o)){if(!e[n+1]||e[n+1].startsWith("--"))throw new Error(`${o} requires a value.`);if(t[o.slice(2)]!==void 0)throw new Error(`${o} was specified twice.`);t[o.slice(2)]=e[++n]}else{if(o.startsWith("-"))throw new Error(`Unknown migration option: ${o}`);if(r)throw new Error("Only one source directory may be specified. Use --out for the destination.");t.source=o,r=!0}}if(t.config&&!["docs.json","mint.json"].includes(t.config))throw new Error("--config must be docs.json or mint.json.");return t}function ii(e,t){let r=J.resolve(t||`${e}-velu`),n=r,o=[];for(;!M.existsSync(n);){o.unshift(J.basename(n));let a=J.dirname(n);if(a===n)throw new Error("Cannot resolve destination parent.");n=a}let i=J.join(M.realpathSync(n),...o);if(le(e,i)||le(i,e))throw new Error("Destination must be outside the source directory and cannot be its ancestor.");if(M.existsSync(r))throw new Error("Destination already exists. Choose a new directory; migration never overwrites existing files.");return i}function si(e){let t=r=>String(r).replace(/\|/g,"\\|").replace(/[\r\n]+/g," ");return`# Mintlify \u2192 Velu migration
|
|
54
54
|
|
|
55
55
|
Status: **${e.status}**. ${e.summary.files} files; ${e.summary.pages} pages/snippets; ${e.summary.scripts} browser scripts; ${e.summary.styles} stylesheets.
|
|
56
56
|
|
|
@@ -69,8 +69,8 @@ The original Mintlify configuration is preserved. Unsupported settings have not
|
|
|
69
69
|
| --- | --- | --- | --- |
|
|
70
70
|
`+e.issues.map(r=>`| ${r.severity} | ${t(r.code)} | ${t(r.file)}${r.line?":"+r.line:""} | ${t(r.message)} |`).join(`
|
|
71
71
|
`)+`
|
|
72
|
-
`}async function In({source:e=".",out:t,config:r,version:n="0.2.40"}={}){let o=F.realpathSync(z.resolve(e));if(!F.statSync(o).isDirectory())throw new Error("Source must be a directory.");let i=ti(o,t);if(r&&!["docs.json","mint.json"].includes(r))throw new Error("Config must be docs.json or mint.json.");let a=r||["docs.json","mint.json"].find(f=>F.existsSync(z.join(o,f)));if(!a)throw new Error("No docs.json or mint.json found in the source directory.");let s=[],l=new Set,c=(f,b,j,E,M)=>{let ie=JSON.stringify([f,b,j,E,M]);l.has(ie)||(s.push({code:f,severity:b,file:j,message:E,...M?{line:M}:{}}),l.add(ie))},u=cn(o,a),p=un(u,a,c);!r&&F.existsSync(z.join(o,"docs.json"))&&F.existsSync(z.join(o,"mint.json"))&&c("multiple-configs","warning",a,"Both config files exist; docs.json selected. Use --config mint.json to select the legacy config.");let y=Zo(),m=z.join(o,".mintignore");if(F.existsSync(m)){if(!le(o,F.realpathSync(m)))throw new Error(".mintignore resolves outside the source.");y.add(F.readFileSync(m,"utf8"))}let g=new Map,v=[];function d(f){for(let b of F.readdirSync(f,{withFileTypes:!0}).sort((j,E)=>j.name<E.name?-1:j.name>E.name?1:0)){let j=z.join(f,b.name),E=gt(z.relative(o,j));b.isSymbolicLink()?(v.push({path:E,reason:"symbolic-link"}),c("symlink","warning",E,"Symbolic link/junction skipped. Copy its required content into the source explicitly.")):b.isDirectory()&&Qo.has(b.name)||/^\.env(?:\.|$)/i.test(b.name)||[".npmrc",".yarnrc.yml",".pnp.cjs",".pnp.loader.mjs"].includes(b.name)?v.push({path:E,reason:"dependency-cache-tooling-or-environment"}):y.ignores(E+(b.isDirectory()?"/":""))&&E!==a&&E!==".mintignore"?v.push({path:E,reason:"mintignore"}):b.isFile()&&E.startsWith(".mintlify/")&&!/\.(json|ya?ml)$/i.test(E)&&!E.startsWith(".mintlify/skills/")?v.push({path:E,reason:"mintlify-runtime-file"}):b.isDirectory()?d(j):b.isFile()?g.set(E,F.readFileSync(j)):v.push({path:E,reason:"not-regular-file"})}}if(d(o),!g.has(a))throw new Error("Source config must be a regular file, not a symbolic link.");if(g.has("velu.json"))throw new Error("Source already contains velu.json. Use the original Mintlify project to avoid replacing an existing Velu config.");let h=new Map,S=new Set,T=new Set;try{for(let f of ne(Y(p.navigation)))T.add(f.pagePath.replace(/^\//,""))}catch{}for(let f of g.keys()){let b=f;/\.md$/i.test(f)&&(T.has(f.slice(0,-3))||!/^(readme|license|changelog|contributing|contribute|skill|agents|claude)\.md$/i.test(z.posix.basename(f)))&&(b=f.replace(/\.md$/i,".mdx")),/\.mdx$/i.test(f)&&(b=f.replace(/\.mdx$/i,".mdx")),/^(?:_snippets|snippets)\/.*\.js$/i.test(f)&&(b=f.replace(/\.js$/i,".jsx"));let j=b.toLowerCase();if(S.has(j)||[Ot.toLowerCase(),Tt.toLowerCase()].includes(j))throw new Error(`Migration output collision: ${b}`);S.add(j),h.set(f,b)}let O=new Map(h);for(let[f,b]of h)if(/\.(mdx?|jsx?|tsx?)$/.test(f)){let j=f.replace(/\.[^.]+$/,"");O.has(j)||O.set(j,b),/\/index$/.test(j)&&!O.has(j.slice(0,-6))&&O.set(j.slice(0,-6),b)}let x=new Map,w=[],P=new Set,L=!1,V=[];for(let[f,b]of g){let j=h.get(f),E=b,M="asset",ie;if(/\.mdx$/i.test(j)){M="content";let J=_n(b.toString("utf8"),f,g,u,c),se=await dn(J.text,f,O,c,{endpointConverted:J.converted});E=Buffer.from(se.text),ie=se.components,L||=se.adapters.length>0;for(let dt of se.assets||[])P.add(dt)}else if(f==="package.json"){M="package";let J=hn(b.toString("utf8"),n,c);E=Buffer.from(J.text),V=J.scripts}else if(/\.js$/i.test(j))M="script",gn(b.toString("utf8"),f,c),(f.startsWith("public/")||f.split("/").some(J=>J.startsWith(".")))&&c("asset-not-autoloaded","warning",f,"Velu does not auto-load JavaScript from public or dot directories; explicitly load it from a custom script if required.");else if(/\.css$/i.test(j)){M="style";let J=b.toString("utf8");f.startsWith("public/")||(E=Buffer.from(vn(J,f,h,c))),/@import|data-component-(?:name|part)|\.dark\b|__next|#banner|#header\b/.test(J)&&c("css-hooks","warning",f,"Review CSS imports, theme classes, and Mintlify-specific selectors against Velu\u2019s DOM hooks."),(f.startsWith("public/")||f.split("/").some(se=>se.startsWith(".")))&&c("asset-not-autoloaded","warning",f,"Velu does not auto-load CSS from public or dot directories.")}else/\.[cm]?[jt]sx?$/.test(j)&&(M="module",E=Buffer.from(yn(b.toString("utf8"),f,O,c)),/(?:@mintlify\/|next\/|window\.mintlify)/.test(b.toString("utf8"))&&c("module-runtime","error",f,"Custom module depends on a Mintlify/Next.js runtime. Adapt its imports and APIs."));f.startsWith(".github/workflows/")&&/mintlify|\bmint\s/.test(b.toString("utf8"))&&c("ci-workflow","warning",f,"Workflow preserved. Replace Mintlify install/validation/deployment commands manually."),x.set(j,E),w.push({source:f,destination:j,kind:M,action:f!==j?"renamed":E.equals(b)?"copied":"transformed",sha256:_e(E),...ie?{components:ie}:{}})}for(let[f,b]of[...x]){if(!ei.test(f)&&!P.has(f)&&!/\.(css|js)$/i.test(f)||f.startsWith("public/")||f.split("/").some(M=>M.startsWith("."))||["docs.json","mint.json","package.json","velu.json",...Un].includes(f))continue;let j=`public/${f}`,E=[...x.keys()].find(M=>M.toLowerCase()===j.toLowerCase());if(E){x.get(E).equals(b)||c("public-asset-conflict","error",f,`Different asset already exists at ${E}; public file retained. Review which URL should be served.`);continue}x.set(j,b),w.push({source:f,destination:j,kind:"public-asset",action:"mirrored",sha256:_e(b)})}if(L){if(S.has(he.toLowerCase()))throw new Error(`Generated adapter conflicts with source file: ${he}`);x.set(he,Buffer.from(vt)),w.push({destination:he,kind:"module",action:"generated",sha256:_e(vt)})}let K=Buffer.from(Ye(p));x.set("velu.json",K),w.push({destination:"velu.json",kind:"config",action:"generated",sha256:_e(K)});let k=Buffer.from(Ye(u));x.set(".velu-migration/source-config.json",k),w.push({destination:".velu-migration/source-config.json",kind:"config",action:"archived",sha256:_e(k)});let $=new Set,C=new Set;try{for(let f of ne(Y(p.navigation))){C.has(f.url)&&c("duplicate-route","error","velu.json",`Duplicate route: ${f.url}`),C.add(f.url);let b=f.pagePath.replace(/^\/+|\/+$/g,"")+".mdx";/\.\.(?:\/|$)|\\/.test(b)&&c("unsafe-page-path","error","velu.json",`Page path is outside the supported project-relative format: ${f.pagePath}`),$.add(b),x.has(b)||c("missing-page","error","velu.json",`Navigation page is missing or ignored: ${b}`)}}catch(f){c("navigation-invalid","error","velu.json",f.message)}for(let f of w.filter(b=>b.kind==="content"))!$.has(f.destination)&&!/^(?:_snippets|snippets)\//.test(f.destination)&&c("unlisted-page","warning",f.destination,"Page preserved but absent from navigation. Velu\u2019s current preview only renders navigation pages; add it to navigation if it must be accessible.");let A=(f,b)=>{if(typeof f!="string")return;if(/^https?:\/\//.test(f)){c("remote-asset","error",b,"Download this branding asset into the project and use a local path; migration does not fetch external assets.");return}let j=f.replace(/^\//,"").split(/[?#]/)[0];x.has(j)||c("missing-asset","error",b,`Asset is missing or ignored: ${j}`)};if(A(p.favicon,"favicon"),typeof p.logo=="string")A(p.logo,"logo");else for(let f of["light","dark"])A(p.logo?.[f],`logo.${f}`);function N(f){if(!(!f||typeof f!="object")){if(f.openapi)for(let b of[].concat(f.openapi))/^https?:\/\//.test(b)?c("remote-openapi","warning","velu.json","Remote OpenAPI URL preserved; availability and generation need validation with network access."):x.has(b.replace(/^\//,""))?c("openapi-routes","warning","velu.json",`OpenAPI source ${b} preserved; compare generated endpoint URLs and x-mint extensions in preview.`):c("missing-openapi","error","velu.json",`OpenAPI source missing or ignored: ${b}`);for(let b of Object.values(f))typeof b=="object"&&N(b)}}N(p.navigation),V.some(f=>f.action==="converted")&&[...Un].some(f=>x.has(f))&&c("lockfile-stale","warning","package.json","Lockfiles are preserved and require regeneration after the dependency changes."),s.sort((f,b)=>f.file.localeCompare(b.file)||(f.line||0)-(b.line||0)||f.code.localeCompare(b.code));let R=s.filter(f=>f.severity==="error").length,U=s.filter(f=>f.severity==="warning").length,D={reportVersion:1,source:o,destination:i,sourceConfig:a,status:R||U?"needs-review":"ready",parityReference:{cli:"@mintlify/cli@4.0.1479",common:"@mintlify/common@1.0.1132",prebuild:"@mintlify/prebuild@1.0.1286",inspected:"2026-09-08"},summary:{files:w.length,pages:w.filter(f=>f.kind==="content").length,scripts:w.filter(f=>f.kind==="script").length,styles:w.filter(f=>f.kind==="style").length,errors:R,warnings:U,skipped:v.length},issues:s,files:w,skipped:v,npmScripts:V};return x.set(Ot,Buffer.from(Ye(D))),x.set(Tt,Buffer.from(ni(D))),{report:D,files:x}}async function Mn(e={}){let t=await In(e),r=e.strict&&(t.report.summary.errors||t.report.summary.warnings),n=!1;if(!e.dryRun&&!r){let o=t.report.destination,i=z.dirname(o);F.mkdirSync(i,{recursive:!0});let a=z.join(i,`.velu-migration-${Xo()}`);F.mkdirSync(a);try{for(let[s,l]of t.files){let c=z.resolve(a,s);if(!le(a,c))throw new Error("Output path escapes the staging directory.");F.mkdirSync(z.dirname(c),{recursive:!0}),F.writeFileSync(c,l,{flag:"wx"})}if(F.existsSync(o))throw new Error("Destination appeared during migration; no existing files were changed.");F.renameSync(a,o),n=!0}finally{z.dirname(a)===i&&z.basename(a).startsWith(".velu-migration-")&&F.rmSync(a,{recursive:!0,force:!0})}}return{report:t.report,written:n,exitCode:r?3:t.report.summary.errors?2:0}}async function ri(e,t){let r=Fn([...e]);if(r.help)return console.log(Nn),0;let n=await Mn({...r,version:t});if(r.json)console.log(Ye({...n.report,written:n.written}).trimEnd());else{let{summary:o}=n.report;console.log(`${n.written?"Migrated to":"Migration plan for"} ${n.report.destination}`),console.log(`${o.files} files \xB7 ${o.pages} pages/snippets \xB7 ${o.scripts} scripts \xB7 ${o.styles} stylesheets`),console.log(`${o.errors} errors \xB7 ${o.warnings} warnings \xB7 ${o.skipped} skipped paths`);for(let i of n.report.issues)console.log(` ${i.severity.toUpperCase()} [${i.code}] ${i.file}${i.line?":"+i.line:""}: ${i.message}`);n.written?console.log(`Review ${Tt}, then run: velu validate ${JSON.stringify(n.report.destination)}`):console.log(r.strict&&n.exitCode===3?"Strict mode: review required; no files written.":"Dry run: no files written.")}return n.exitCode}var Qo,Un,Ot,Tt,ei,_e,Ye,Nn,Vn=_(()=>{Ge();bn();re();re();Rn();Qo=new Set(["node_modules",".git",".velu",".velu-migration",".next",".turbo",".cache",".idea",".vscode",".claude",".agents","dist","dist-preview","coverage"]),Un=new Set(["package-lock.json","yarn.lock","pnpm-lock.yaml","bun.lock","bun.lockb"]),Ot="velu-migration-report.json",Tt="VELU-MIGRATION.md",ei=/\.(?:avif|apng|bmp|gif|ico|jpe?g|png|svg|svgz|tiff?|webp|mp4|webm|mov|avi|m4v|mp3|wav|ogg|flac|aac|m4a|woff2?|ttf|otf|eot|pdf|txt|csv|tsv|xml|zip|gz|tar|docx?|xlsx?|pptx?)$/i,_e=e=>Yo("sha256").update(e).digest("hex"),Ye=e=>JSON.stringify(e,null,2)+`
|
|
73
|
-
`,
|
|
72
|
+
`}async function Mn({source:e=".",out:t,config:r,version:n="0.2.40"}={}){let o=M.realpathSync(J.resolve(e));if(!M.statSync(o).isDirectory())throw new Error("Source must be a directory.");let i=ii(o,t);if(r&&!["docs.json","mint.json"].includes(r))throw new Error("Config must be docs.json or mint.json.");let a=r||["docs.json","mint.json"].find(d=>M.existsSync(J.join(o,d)));if(!a)throw new Error("No docs.json or mint.json found in the source directory.");let s=[],l=new Set,c=(d,v,j,C,V)=>{let ie=JSON.stringify([d,v,j,C,V]);l.has(ie)||(s.push({code:d,severity:v,file:j,message:C,...V?{line:V}:{}}),l.add(ie))},u=un(o,a),p=pn(u,a,c);!r&&M.existsSync(J.join(o,"docs.json"))&&M.existsSync(J.join(o,"mint.json"))&&c("multiple-configs","warning",a,"Both config files exist; docs.json selected. Use --config mint.json to select the legacy config.");let y=ni(),f=J.join(o,".mintignore");if(M.existsSync(f)){if(!le(o,M.realpathSync(f)))throw new Error(".mintignore resolves outside the source.");y.add(M.readFileSync(f,"utf8"))}let g=new Map,b=[];function m(d){for(let v of M.readdirSync(d,{withFileTypes:!0}).sort((j,C)=>j.name<C.name?-1:j.name>C.name?1:0)){let j=J.join(d,v.name),C=gt(J.relative(o,j));v.isSymbolicLink()?(b.push({path:C,reason:"symbolic-link"}),c("symlink","warning",C,"Symbolic link/junction skipped. Copy its required content into the source explicitly.")):v.isDirectory()&&ri.has(v.name)||/^\.env(?:\.|$)/i.test(v.name)||[".npmrc",".yarnrc.yml",".pnp.cjs",".pnp.loader.mjs"].includes(v.name)?b.push({path:C,reason:"dependency-cache-tooling-or-environment"}):y.ignores(C+(v.isDirectory()?"/":""))&&C!==a&&C!==".mintignore"?b.push({path:C,reason:"mintignore"}):v.isFile()&&C.startsWith(".mintlify/")&&!/\.(json|ya?ml)$/i.test(C)&&!C.startsWith(".mintlify/skills/")?b.push({path:C,reason:"mintlify-runtime-file"}):v.isDirectory()?m(j):v.isFile()?g.set(C,M.readFileSync(j)):b.push({path:C,reason:"not-regular-file"})}}if(m(o),!g.has(a))throw new Error("Source config must be a regular file, not a symbolic link.");if(g.has("velu.json"))throw new Error("Source already contains velu.json. Use the original Mintlify project to avoid replacing an existing Velu config.");let h=new Map,$=new Set,P=new Set;try{for(let d of ee(Y(p.navigation)))P.add(d.pagePath.replace(/^\//,""))}catch{}for(let d of g.keys()){let v=d;/\.md$/i.test(d)&&(P.has(d.slice(0,-3))||!/^(readme|license|changelog|contributing|contribute|skill|agents|claude)\.md$/i.test(J.posix.basename(d)))&&(v=d.replace(/\.md$/i,".mdx")),/\.mdx$/i.test(d)&&(v=d.replace(/\.mdx$/i,".mdx")),/^(?:_snippets|snippets)\/.*\.js$/i.test(d)&&(v=d.replace(/\.js$/i,".jsx"));let j=v.toLowerCase();if($.has(j)||[Ot.toLowerCase(),Et.toLowerCase()].includes(j))throw new Error(`Migration output collision: ${v}`);$.add(j),h.set(d,v)}let E=new Map(h);for(let[d,v]of h)if(/\.(mdx?|jsx?|tsx?)$/.test(d)){let j=d.replace(/\.[^.]+$/,"");E.has(j)||E.set(j,v),/\/index$/.test(j)&&!E.has(j.slice(0,-6))&&E.set(j.slice(0,-6),v)}let T=new Map,S=[],w=new Set,L=!1,I=[];for(let[d,v]of g){let j=h.get(d),C=v,V="asset",ie;if(/\.mdx$/i.test(j)){V="content";let q=Rn(v.toString("utf8"),d,g,u,c),se=await gn(q.text,d,E,c,{endpointConverted:q.converted});C=Buffer.from(se.text),ie=se.components,L||=se.adapters.length>0;for(let dt of se.assets||[])w.add(dt)}else if(d==="package.json"){V="package";let q=yn(v.toString("utf8"),n,c);C=Buffer.from(q.text),I=q.scripts}else if(/\.js$/i.test(j))V="script",hn(v.toString("utf8"),d,c),(d.startsWith("public/")||d.split("/").some(q=>q.startsWith(".")))&&c("asset-not-autoloaded","warning",d,"Velu does not auto-load JavaScript from public or dot directories; explicitly load it from a custom script if required.");else if(/\.css$/i.test(j)){V="style";let q=v.toString("utf8");d.startsWith("public/")||(C=Buffer.from(bn(q,d,h,c))),/@import|data-component-(?:name|part)|\.dark\b|__next|#banner|#header\b/.test(q)&&c("css-hooks","warning",d,"Review CSS imports, theme classes, and Mintlify-specific selectors against Velu\u2019s DOM hooks."),(d.startsWith("public/")||d.split("/").some(se=>se.startsWith(".")))&&c("asset-not-autoloaded","warning",d,"Velu does not auto-load CSS from public or dot directories.")}else/\.[cm]?[jt]sx?$/.test(j)&&(V="module",C=Buffer.from(vn(v.toString("utf8"),d,E,c)),/(?:@mintlify\/|next\/|window\.mintlify)/.test(v.toString("utf8"))&&c("module-runtime","error",d,"Custom module depends on a Mintlify/Next.js runtime. Adapt its imports and APIs."));d.startsWith(".github/workflows/")&&/mintlify|\bmint\s/.test(v.toString("utf8"))&&c("ci-workflow","warning",d,"Workflow preserved. Replace Mintlify install/validation/deployment commands manually."),T.set(j,C),S.push({source:d,destination:j,kind:V,action:d!==j?"renamed":C.equals(v)?"copied":"transformed",sha256:_e(C),...ie?{components:ie}:{}})}for(let[d,v]of[...T]){if(!oi.test(d)&&!w.has(d)&&!/\.(css|js)$/i.test(d)||d.startsWith("public/")||d.split("/").some(V=>V.startsWith("."))||["docs.json","mint.json","package.json","velu.json",...Un].includes(d))continue;let j=`public/${d}`,C=[...T.keys()].find(V=>V.toLowerCase()===j.toLowerCase());if(C){T.get(C).equals(v)||c("public-asset-conflict","error",d,`Different asset already exists at ${C}; public file retained. Review which URL should be served.`);continue}T.set(j,v),S.push({source:d,destination:j,kind:"public-asset",action:"mirrored",sha256:_e(v)})}if(L){if($.has(he.toLowerCase()))throw new Error(`Generated adapter conflicts with source file: ${he}`);T.set(he,Buffer.from(vt)),S.push({destination:he,kind:"module",action:"generated",sha256:_e(vt)})}let F=Buffer.from(Ye(p));T.set("velu.json",F),S.push({destination:"velu.json",kind:"config",action:"generated",sha256:_e(F)});let O=Buffer.from(Ye(u));T.set(".velu-migration/source-config.json",O),S.push({destination:".velu-migration/source-config.json",kind:"config",action:"archived",sha256:_e(O)});let x=new Set,A=new Set;try{for(let d of ee(Y(p.navigation))){A.has(d.url)&&c("duplicate-route","error","velu.json",`Duplicate route: ${d.url}`),A.add(d.url);let v=d.pagePath.replace(/^\/+|\/+$/g,"")+".mdx";/\.\.(?:\/|$)|\\/.test(v)&&c("unsafe-page-path","error","velu.json",`Page path is outside the supported project-relative format: ${d.pagePath}`),x.add(v),T.has(v)||c("missing-page","error","velu.json",`Navigation page is missing or ignored: ${v}`)}}catch(d){c("navigation-invalid","error","velu.json",d.message)}for(let d of S.filter(v=>v.kind==="content"))!x.has(d.destination)&&!/^(?:_snippets|snippets)\//.test(d.destination)&&c("unlisted-page","warning",d.destination,"Page preserved but absent from navigation. Velu\u2019s current preview only renders navigation pages; add it to navigation if it must be accessible.");let k=(d,v)=>{if(typeof d!="string")return;if(/^https?:\/\//.test(d)){c("remote-asset","error",v,"Download this branding asset into the project and use a local path; migration does not fetch external assets.");return}let j=d.replace(/^\//,"").split(/[?#]/)[0];T.has(j)||c("missing-asset","error",v,`Asset is missing or ignored: ${j}`)};if(k(p.favicon,"favicon"),typeof p.logo=="string")k(p.logo,"logo");else for(let d of["light","dark"])k(p.logo?.[d],`logo.${d}`);function U(d){if(!(!d||typeof d!="object")){if(d.openapi)for(let v of[].concat(d.openapi))/^https?:\/\//.test(v)?c("remote-openapi","warning","velu.json","Remote OpenAPI URL preserved; availability and generation need validation with network access."):T.has(v.replace(/^\//,""))?c("openapi-routes","warning","velu.json",`OpenAPI source ${v} preserved; compare generated endpoint URLs and x-mint extensions in preview.`):c("missing-openapi","error","velu.json",`OpenAPI source missing or ignored: ${v}`);for(let v of Object.values(d))typeof v=="object"&&U(v)}}U(p.navigation),I.some(d=>d.action==="converted")&&[...Un].some(d=>T.has(d))&&c("lockfile-stale","warning","package.json","Lockfiles are preserved and require regeneration after the dependency changes."),s.sort((d,v)=>d.file.localeCompare(v.file)||(d.line||0)-(v.line||0)||d.code.localeCompare(v.code));let R=s.filter(d=>d.severity==="error").length,N=s.filter(d=>d.severity==="warning").length,D={reportVersion:1,source:o,destination:i,sourceConfig:a,status:R||N?"needs-review":"ready",parityReference:{cli:"@mintlify/cli@4.0.1479",common:"@mintlify/common@1.0.1132",prebuild:"@mintlify/prebuild@1.0.1286",inspected:"2026-09-08"},summary:{files:S.length,pages:S.filter(d=>d.kind==="content").length,scripts:S.filter(d=>d.kind==="script").length,styles:S.filter(d=>d.kind==="style").length,errors:R,warnings:N,skipped:b.length},issues:s,files:S,skipped:b,npmScripts:I};return T.set(Ot,Buffer.from(Ye(D))),T.set(Et,Buffer.from(si(D))),{report:D,files:T}}async function zn(e={}){let t=await Mn(e),r=e.strict&&(t.report.summary.errors||t.report.summary.warnings),n=!1;if(!e.dryRun&&!r){let o=t.report.destination,i=J.dirname(o);M.mkdirSync(i,{recursive:!0});let a=J.join(i,`.velu-migration-${ei()}`);M.mkdirSync(a);try{for(let[s,l]of t.files){let c=J.resolve(a,s);if(!le(a,c))throw new Error("Output path escapes the staging directory.");M.mkdirSync(J.dirname(c),{recursive:!0}),M.writeFileSync(c,l,{flag:"wx"})}if(M.existsSync(o))throw new Error("Destination appeared during migration; no existing files were changed.");M.renameSync(a,o),n=!0}finally{J.dirname(a)===i&&J.basename(a).startsWith(".velu-migration-")&&M.rmSync(a,{recursive:!0,force:!0})}}return{report:t.report,written:n,exitCode:r?3:t.report.summary.errors?2:0}}async function ai(e,t){let r=In([...e]);if(r.help)return console.log(Fn),0;let n=await zn({...r,version:t});if(r.json)console.log(Ye({...n.report,written:n.written}).trimEnd());else{let{summary:o}=n.report;console.log(`${n.written?"Migrated to":"Migration plan for"} ${n.report.destination}`),console.log(`${o.files} files \xB7 ${o.pages} pages/snippets \xB7 ${o.scripts} scripts \xB7 ${o.styles} stylesheets`),console.log(`${o.errors} errors \xB7 ${o.warnings} warnings \xB7 ${o.skipped} skipped paths`);for(let i of n.report.issues)console.log(` ${i.severity.toUpperCase()} [${i.code}] ${i.file}${i.line?":"+i.line:""}: ${i.message}`);n.written?console.log(`Review ${Et}, then run: velu validate ${JSON.stringify(n.report.destination)}`):console.log(r.strict&&n.exitCode===3?"Strict mode: review required; no files written.":"Dry run: no files written.")}return n.exitCode}var ri,Un,Ot,Et,oi,_e,Ye,Fn,Jn=_(()=>{Ge();xn();re();re();Nn();ri=new Set(["node_modules",".git",".velu",".velu-migration",".next",".turbo",".cache",".idea",".vscode",".claude",".agents","dist","dist-preview","coverage"]),Un=new Set(["package-lock.json","yarn.lock","pnpm-lock.yaml","bun.lock","bun.lockb"]),Ot="velu-migration-report.json",Et="VELU-MIGRATION.md",oi=/\.(?:avif|apng|bmp|gif|ico|jpe?g|png|svg|svgz|tiff?|webp|mp4|webm|mov|avi|m4v|mp3|wav|ogg|flac|aac|m4a|woff2?|ttf|otf|eot|pdf|txt|csv|tsv|xml|zip|gz|tar|docx?|xlsx?|pptx?)$/i,_e=e=>ti("sha256").update(e).digest("hex"),Ye=e=>JSON.stringify(e,null,2)+`
|
|
73
|
+
`,Fn=`Usage: velu migrate mintlify [source] [--out <directory>] [--config docs.json|mint.json] [--dry-run] [--json] [--strict]
|
|
74
74
|
|
|
75
75
|
Migrate a local Mintlify project into a NEW Velu directory.
|
|
76
76
|
Defaults: source=current directory, output=<source>-velu, docs.json before mint.json.
|
|
@@ -83,29 +83,40 @@ Defaults: source=current directory, output=<source>-velu, docs.json before mint.
|
|
|
83
83
|
Source files are never modified; no project scripts or package installs are executed.
|
|
84
84
|
Exit codes: 0=completed/clean plan, 1=invalid invocation or I/O failure,
|
|
85
85
|
2=compatibility errors (output is still written unless --strict), 3=strict review required.
|
|
86
|
-
`});var _t={};Se(_t,{currentVersion:()=>Ct,getLatestVersion:()=>Lt,isNewer:()=>Pt,maybeAutoUpdate:()=>
|
|
87
|
-
New velu version available: ${e} \u2192 ${t}. Updating\u2026`),!
|
|
88
|
-
`);let n=Dn(
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
`});var _t={};Se(_t,{currentVersion:()=>Ct,getLatestVersion:()=>Lt,isNewer:()=>Pt,maybeAutoUpdate:()=>wi,updateCommand:()=>xi});import{spawnSync as Dn}from"node:child_process";import{readFileSync as qn,writeFileSync as li,mkdirSync as ci}from"node:fs";import{fileURLToPath as ui}from"node:url";import{homedir as pi,tmpdir as fi}from"node:os";import Tt from"node:path";import te from"node:process";function Ct(){try{return JSON.parse(qn(new URL("../package.json",import.meta.url),"utf8")).version}catch{return"unknown"}}function hi(e,t){let r=i=>String(i).split("-")[0].split(".").map(a=>Number(a)||0),n=r(e),o=r(t);for(let i=0;i<3;i++){let a=(n[i]||0)-(o[i]||0);if(a!==0)return a<0?-1:1}return 0}function Pt(e,t){return!e||!t||t==="unknown"?!1:hi(e,t)>0}function Gn(){let e=Tt.join(pi()||fi(),".velu");return Tt.join(e,"update-check.json")}function Bn(){try{return JSON.parse(qn(Gn(),"utf8"))}catch{return null}}function yi(e){try{let t=Gn();ci(Tt.dirname(t),{recursive:!0}),li(t,JSON.stringify(e))}catch{}}async function vi(){let e=`${mi}/-/package/${Ze}/dist-tags`,t=new AbortController,r=setTimeout(()=>t.abort(),gi);try{let n=await fetch(e,{signal:t.signal,headers:{accept:"application/json"}});if(!n.ok)return null;let o=await n.json();return o&&typeof o.latest=="string"?o.latest:null}catch{return null}finally{clearTimeout(r)}}async function Lt({force:e=!1}={}){if(!e){let r=Bn();if(r?.latest&&Date.now()-(r.checkedAt||0)<di)return r.latest}let t=await vi();return t?(yi({latest:t,checkedAt:Date.now()}),t):Bn()?.latest??null}function Wn(){let e=te.env.npm_config_user_agent||"";if(e.startsWith("pnpm"))return"pnpm";if(e.startsWith("yarn"))return"yarn";if(e.startsWith("bun"))return"bun";let t="";try{t=ui(import.meta.url).replace(/\\/g,"/")}catch{}return t.includes("/pnpm/")?"pnpm":t.includes("/yarn/")||t.includes("/.yarn/")?"yarn":t.includes("/.bun/")?"bun":"npm"}function bi(e){let t=`${Ze}@latest`;switch(e){case"pnpm":return["pnpm",["add","-g",t]];case"yarn":return["yarn",["global","add",t]];case"bun":return["bun",["add","-g",t]];default:return["npm",["install","-g",t]]}}function Hn(e){let[t,r]=bi(e);return Dn(t,r,{stdio:"inherit",shell:te.platform==="win32"}).status===0}async function xi(){let e=Ct(),t=await Lt({force:!0});if(t&&!Pt(t,e)){console.log(`velu is already up to date (v${e}).`);return}let r=Wn();console.log(t?`Updating velu ${e} \u2192 ${t} (via ${r})\u2026`:`Could not reach the npm registry; installing ${Ze}@latest (via ${r}) anyway\u2026`),Hn(r)?console.log('\u2713 Updated. Run "velu version" to confirm.'):(console.error("Update failed. You can update manually with:"),console.error(` npm install -g ${Ze}@latest`),te.exitCode=1)}async function wi(){if(te.env.VELU_NO_UPDATE==="1"||te.env.VELU_UPDATED==="1"||!te.stdout.isTTY)return;let e=Ct();if(e==="unknown")return;let t=null;try{t=await Lt()}catch{return}if(!Pt(t,e))return;let r=Wn();if(console.log(`
|
|
87
|
+
New velu version available: ${e} \u2192 ${t}. Updating\u2026`),!Hn(r)){console.log("Auto-update failed; continuing on the current version. Run `velu update` to retry.\n");return}console.log(`Restarting on the new version\u2026
|
|
88
|
+
`);let n=Dn(te.execPath,te.argv.slice(1),{stdio:"inherit",env:{...te.env,VELU_UPDATED:"1"}});te.exit(n.status??0)}var Ze,mi,di,gi,Rt=_(()=>{Ze="@veluai/velu",mi="https://registry.npmjs.org",di=720*60*1e3,gi=3e3});import $i from"node:fs/promises";import Qe from"node:path";function Xn(e){if(!e.favicon)return null;let t=Qe.extname(e.favicon).toLowerCase();return{url:Nt+t,type:Kn[t]||""}}function Ut(e,t){let r=e.logo?.[t];if(!r)return null;let n=Qe.extname(r).toLowerCase();return{url:(t==="dark"?Ne:Re)+n,type:Kn[n]||""}}function Ue(e){if(typeof e=="string"){let t=e.trim();return t?{light:t,dark:t,href:"/"}:null}if(e&&typeof e=="object"){let t=(e.light??e.dark)?.trim?.(),r=(e.dark??e.light)?.trim?.();return!t||!r?null:{light:t,dark:r,href:e.href?.trim?.()||"/"}}return null}function ki(e){return!e||typeof e!="object"?{metatags:{},indexing:"navigable"}:{metatags:e.metatags&&typeof e.metatags=="object"?e.metatags:{},indexing:e.indexing==="all"?"all":"navigable"}}function Ft(e={},t){let r=e.colors?.primary??Si;return{name:e.name??t??"docs",theme:Ee(e.theme),url:typeof process.env.VELU_SITE_URL=="string"&&process.env.VELU_SITE_URL.trim()?process.env.VELU_SITE_URL.trim().replace(/\/+$/,""):null,seo:ki(e.seo),assistant:Pe(e.assistant),thumbnails:e.thumbnails&&typeof e.thumbnails=="object"&&typeof e.thumbnails.background=="string"?{background:e.thumbnails.background}:null,colors:{primary:r,...["thulir","aalam","nila","kadhir"].includes(e.theme)?{cta:e.colors?.dark??r}:{},light:e.theme==="vepa"||["thulir","aalam","nila","kadhir"].includes(e.theme)?r:e.colors?.light??r,dark:e.theme==="vepa"||["thulir","aalam","nila","kadhir"].includes(e.theme)?e.colors?.light??r:e.colors?.dark??r},favicon:e.favicon??null,api:Z(e.api),logo:Ue(e.logo),footer:Te(e.footer),navbar:Ce(e.navbar),font:{family:Ln(e)},navigation:e.navigation??null}}async function Yn(e){let t=Qe.join(e,"velu.json"),r;try{r=await $i.readFile(t,"utf-8")}catch(o){throw o.code==="ENOENT"?new Error(`No velu.json found in ${e}. Run \`velu init <name>\` to scaffold one.`):o}let n;try{n=JSON.parse(r)}catch(o){throw new Error(`velu.json is not valid JSON: ${o.message}`)}return Ft(n,Qe.basename(e))}function Zn(e){let{colors:t,font:r}=e;return jt({light:t.light,dark:t.dark,family:r.family,theme:e.theme,primary:t.primary,cta:t.cta})}var Si,Re,Ne,Nt,Kn,Fe=_(()=>{Le();Le();Si="#dc143c",Re="/@velu-logo-light",Ne="/@velu-logo-dark",Nt="/@velu-favicon",Kn={".svg":"image/svg+xml",".ico":"image/x-icon",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif"}});import{visit as Qn}from"unist-util-visit";import{toString as ji}from"mdast-util-to-string";import Ai from"github-slugger";import{valueToEstree as Oi}from"estree-util-value-to-estree";function Ei(e,t){let r=a=>String(a||"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),n=r(e),o=t==null||t===""?"":r(t);return`update-${o?n?`${n}-${o}`:o:n||"item"}`}function It(e,t){let r=(e.attributes||[]).find(n=>n&&n.type==="mdxJsxAttribute"&&n.name===t);if(r)return typeof r.value=="string"?r.value:void 0}function Ti(e){let t=(e.attributes||[]).find(a=>a&&a.type==="mdxJsxAttribute"&&a.name==="tags");if(!t)return[];if(typeof t.value=="string")return[t.value];let r=t.value&&t.value.value?String(t.value.value):"",n=[],o=/["'`]([^"'`]+)["'`]/g,i;for(;i=o.exec(r);)n.push(i[1]);return n}function Ie(){return e=>{let t=new Ai,r=[];Qn(e,"heading",l=>{let c=ji(l);r.push({depth:l.depth,id:t.slug(c),label:c})});let n=[],o=[],i=new Set;if(Qn(e,"mdxJsxFlowElement",l=>{if(l.name!=="Update")return;let c=It(l,"label")??It(l,"date"),u=It(l,"description");c&&n.push({id:Ei(c,u),label:u||c});for(let p of Ti(l)){let y=p.trim().toLowerCase();p.trim()&&!i.has(y)&&(i.add(y),o.push(p.trim()))}}),n.length){er(e,n),Mt(e,"changelog",{tags:o});return}let a={children:[]},s=[{node:a,depth:0}];for(let l of r){for(;s.length>1&&s[s.length-1].depth>=l.depth;)s.pop();let c={id:l.id,label:l.label},u=s[s.length-1].node;u.children||(u.children=[]),u.children.push(c),s.push({node:c,depth:l.depth})}er(e,a.children),Mt(e,"changelog",null)}}function er(e,t){Mt(e,"toc",t)}function Mt(e,t,r){e.children.unshift({type:"mdxjsEsm",value:"",data:{estree:{type:"Program",sourceType:"module",body:[{type:"ExportNamedDeclaration",specifiers:[],declaration:{type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:t},init:Oi(r)}]}}]}}})}var zt=_(()=>{});import{visit as Ci}from"unist-util-visit";function Vt(){return e=>{Ci(e,"code",t=>{let r=(t.meta||"").trim();if(!r)return;let n={},o=r.match(/\btitle="([^"]*)"/);o&&(n["data-title"]=o[1],r=(r.slice(0,o.index)+r.slice(o.index+o[0].length)).trim());let i=r.match(/\{([\d,\s-]+)\}/);i&&(n["data-highlight"]=i[1].replace(/\s+/g,""),r=(r.slice(0,i.index)+r.slice(i.index+i[0].length)).trim()),r=r.replace(/\blineNumbers\b/,()=>(n["data-line-numbers"]="","")).trim(),r&&(n["data-filename"]=r),Object.keys(n).length&&(t.data=t.data||{},t.data.hProperties={...t.data.hProperties||{},...n})})}}var tr=_(()=>{});import Pi from"node:crypto";import Li from"node:fs";import _i from"node:path";function nr({pageEntries:e,tree:t,site:r,ops:n,walkPages:o,apiModules:i,targetDir:a}){let s=[],l=c=>Pi.createHash("sha256").update(c).digest("hex");for(let c of e)c.exists&&s.push(`${JSON.stringify(l(c.url))}:()=>import(${JSON.stringify(c.fileAbsPath.replaceAll("\\","/"))})`);for(let c of o(t)){if(!c.node?.api||!n[c.pagePath])continue;let u=n[c.pagePath],p="virtual:velu-auth-api:"+c.url,y=a?_i.join(a,`${c.pagePath}.mdx`):"",f=y&&Li.existsSync(y)?y.replaceAll("\\","/"):null,g=f?`import * as Overlay from ${JSON.stringify(f)};`:"",b=f?"Overlay.toc||[]":"[]",m=f?",React.createElement(Overlay.default)":"";i.set("\0"+p,`${g}import React from 'react';import {ApiReferencePage} from 'velu-ui';export const frontmatter=${JSON.stringify({title:u.title,description:u.description})};export const toc=${b};export const operation=${JSON.stringify(u.operation)};export const samples=${JSON.stringify(u.samples)};export const api=true;export default function Page(){return React.createElement(ApiReferencePage,{preset:${JSON.stringify(r.theme)},operation,samples,apiOperations:[{...operation,operation,samples,url:${JSON.stringify(c.url)}}],api:${JSON.stringify(u.api||{proxy:!0,server:null})}}${m})}`),s.push(`${JSON.stringify(l(c.url))}:()=>import(${JSON.stringify(p)})`)}return`const loaders={${s.join(",")}};
|
|
89
|
+
export const site=${JSON.stringify({...r,assistant:r.assistant?{apiBase:r.assistant.apiBase,host:r.assistant.host}:null,guarded:!0})};
|
|
90
|
+
export let navigation={kind:'root',children:[]};
|
|
91
|
+
export const pages={};
|
|
92
|
+
export async function initializeReader(){
|
|
93
|
+
const base=(import.meta.env.BASE_URL || '/').replace(/\\/$/,'');
|
|
94
|
+
const response=await fetch(base+'/@velu-reader/catalog',{credentials:'same-origin',cache:'no-store'});
|
|
95
|
+
if(!response.ok)throw Error('Unable to load documentation access.');
|
|
96
|
+
const catalog=await response.json();navigation=catalog.navigation;site.readerPrivate=catalog.private;site.readerRestricted=catalog.restricted;
|
|
97
|
+
await Promise.all(Object.keys(catalog.pages).map(async url=>{const id=catalog.pages[url].moduleId;if(!loaders[id])return;const mod=await loaders[id]();pages[url]={...mod,Component:mod.default,...(mod.veluApi?{mdxApi:mod.veluApi,api:true,operation:mod.veluApi.operation,samples:mod.veluApi.samples}:{})};}));
|
|
98
|
+
if(site.logo)site.logo={...site.logo,light:base+site.logo.light,dark:base+site.logo.dark};
|
|
99
|
+
}`}var rr=_(()=>{});import Ri from"node:fs";import or from"node:path";function ae(e,t){let r=[],n=[],o=new Set;for(let i of ee(e)){if(i.node?.api){o.add(i.url);continue}if(o.has(i.url)){r.push(`duplicate URL "${i.url}" (page "${i.pagePath}") \u2014 keeping the first occurrence`);continue}o.add(i.url);let a=i.pagePath.replace(/^\/+|\/+$/g,""),s=or.join(t,...a.split("/"))+".mdx",l=Ri.existsSync(s);l||r.push(`page "${i.pagePath}" \u2192 ${or.relative(t,s)} not found`),n.push({pagePath:i.pagePath,url:i.url,fileAbsPath:s,exists:l})}return{pageEntries:n,warnings:r}}var Me=_(()=>{re()});import Ni from"@apidevtools/swagger-parser";async function Ui(e){return Ni.dereference(e)}async function ir(e){return Oe(await Ui(e))}var sr=_(()=>{Ke();Ke()});function ar(e,t){if(!t||typeof t!="object")return e;let r=Z(t);return{server:t.server!=null?r.server:e?.server??null,proxy:t.playground!=null?r.proxy:e?.proxy!==!1,languages:t.examples?.languages!=null?r.languages:e?.languages}}function Fi(e,{base:t,api:r,ops:n}){let o=r?.server,i=r?.languages||$t,a={proxy:r?.proxy!==!1,server:o??null},s=new Map;for(let c of e){let u=c.op.tags?.[0]||"API";s.has(u)||s.set(u,[]),s.get(u).push(c)}let l=[];for(let[c,u]of s){let p=u.map(({op:y,segment:f})=>{let g=`${t}/${Jt(c)}/${y.id}`;return n[g]={operation:y,samples:Xe(y,{server:o||y.servers?.[0],languages:i}),segment:f,title:y.title,description:y.description,method:y.method,api:a},{apiPage:g,label:y.title,method:y.method}});l.push({group:c,pages:p})}return l}async function lr(e,{loadOps:t,base:r,api:n,ops:o}){let i=Array.isArray(e)?e:[e],a=[];for(let s of i){let{operations:l,segments:c,servers:u}=await t(s);l.forEach((p,y)=>{!p.servers?.length&&u?.length&&(p.servers=u),a.push({op:p,segment:c[y]})})}return Fi(a,{base:r,api:n,ops:o})}async function cr(e,t){if(!e||typeof e!="object")return e;if(typeof e.tab=="string"&&e.openapi){let n=Jt(e.tab),o=ar(t.api,e.api),i=await lr(e.openapi,{...t,base:n,api:o}),{openapi:a,api:s,...l}=e;return{...l,groups:[...l.groups||[],...i]}}if(typeof e.group=="string"&&e.openapi){let n=Jt(e.group),o=ar(t.api,e.api),i=await lr(e.openapi,{...t,base:n,api:o}),{openapi:a,api:s,...l}=e,c=i.flatMap(u=>u.pages);return{...l,pages:[...l.pages||[],...c]}}let r={...e};for(let n of["products","versions","languages","tabs","groups"])Array.isArray(e[n])&&(r[n]=await Promise.all(e[n].map(o=>cr(o,t))));return r}async function ur(e,{api:t,loadOps:r}){let n={};return!e||typeof e!="object"?{nav:e,ops:n}:{nav:await cr(e,{api:t,loadOps:r,ops:n}),ops:n}}var Jt,pr=_(()=>{Le();St();Jt=e=>String(e??"").replace(/\{[^}]+\}/g,t=>t.slice(1,-1)).replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()||"x"});import Ii from"node:path";function Mi(e,t){return/^https?:\/\//.test(e)?e:Ii.resolve(t,e.replace(/^\/+/,""))}async function et(e,{targetDir:t,api:r}={}){return ur(e,{api:r,loadOps:n=>ir(Mi(n,t))})}var Bt=_(()=>{sr();pr()});import mr from"node:fs";import ve from"node:path";import{createHash as zi}from"node:crypto";function ze(e,{outDir:t}={}){let r=ve.resolve(e),n=t?ve.resolve(t):null,o=[],i=[],a=l=>{let c;try{c=mr.readdirSync(l,{withFileTypes:!0})}catch{return}for(let u of c){let p=ve.join(l,u.name);if(u.isDirectory()){if(u.name.startsWith(".")||Ji.has(u.name)||n&&p===n)continue;a(p);continue}if(!u.isFile())continue;let y=ve.extname(u.name).toLowerCase();if(y!==fr&&y!==Vi)continue;let f=ve.relative(r,p).split(ve.sep).join("/"),g={rel:f,abs:p,url:`${tt}/${f.split("/").map(encodeURIComponent).join("/")}?v=${Bi(p)}`,kind:y===fr?"css":"js"};(g.kind==="css"?o:i).push(g)}};a(r);let s=(l,c)=>l.rel<c.rel?-1:l.rel>c.rel?1:0;return o.sort(s),i.sort(s),{styles:o,scripts:i}}function Bi(e){try{return zi("sha1").update(mr.readFileSync(e)).digest("hex").slice(0,8)}catch{return"0"}}function dr(e,t){let r=`${tt}/`;if(!t.startsWith(r))return null;let n;try{n=decodeURIComponent(t.slice(r.length))}catch{return null}return[...e.styles,...e.scripts].find(o=>o.rel===n)??null}function gr(e,t=""){return(e?.styles??[]).map(r=>`<link rel="stylesheet" href="${Di(t+r.url)}" data-velu-custom />`).join(`
|
|
100
|
+
`)}var tt,fr,Vi,Ji,Di,Dt=_(()=>{tt="/@velu-custom",fr=".css",Vi=".js",Ji=new Set(["node_modules","public","dist"]);Di=e=>String(e).replace(/&/g,"&").replace(/"/g,""")});import hr from"node:fs";import ue from"node:path";function br(e,{buildOutDir:t}={}){let r=!1,n=new Map;return{configResolved(o){r=o.command==="build"&&!o.build.ssr&&process.env.VELU_DOCS_ACCESS_CONTROL==="1"},name:"velu-site",resolveId(o){return o.startsWith("virtual:velu-auth-api:")?"\0"+o:o===vr?yr:null},async load(o){return n.has(o)?n.get(o):o!==yr?null:qi(e,{buildOutDir:t,guarded:r,apiModules:n})}}}async function qi(e,{buildOutDir:t,guarded:r,apiModules:n}={}){let o={};try{o=JSON.parse(hr.readFileSync(ue.join(e,"velu.json"),"utf-8"))}catch{}let i=Z(o.api),a=o.navigation??{},s={};try{let w=await et(o.navigation??{},{targetDir:e,api:i});a=w.nav,s=w.ops}catch(w){console.warn(`[velu] openapi: ${w.message}`)}let l=Y(a),{pageEntries:c,warnings:u}=ae(l,e);for(let w of u)console.warn(`[velu] nav: ${w}`);let p=Ue(o.logo),y={name:o.name??ue.basename(e),theme:Ee(o.theme),logo:p?{light:Ut({logo:p},"light")?.url??Re,dark:Ut({logo:p},"dark")?.url??Ne,href:p.href,mono:p.light===p.dark}:null,footer:Te(o.footer),navbar:Ce(o.navbar),contextual:At(o.contextual??(["thulir","aalam","nila","kadhir"].includes(o.theme)?{options:[]}:void 0)),assistant:Pe(o.assistant),customScripts:ze(e,{outDir:t}).scripts.map(w=>w.url)};if(r)return nr({pageEntries:c,tree:l,site:y,ops:s,walkPages:ee,apiModules:n,targetDir:e});let f=[],g=[],b=0;for(let w of c){if(!w.exists)continue;let L=JSON.stringify(w.fileAbsPath.split(ue.sep).join("/")),I=JSON.stringify(ue.relative(e,w.fileAbsPath).split(ue.sep).join("/")),F=`__p${b++}`;f.push(`import * as ${F} from ${L};`),g.push(` ${JSON.stringify(w.url)}: { Component: ${F}.default, frontmatter: ${F}.frontmatter, toc: ${F}.toc, changelog: ${F}.changelog, relPath: ${I}, ...__mdxApi(${F}) },`)}let m=new Set(c.filter(w=>w.exists).map(w=>w.url));for(let w of c)!w.exists&&!m.has(w.url)&&g.push(` ${JSON.stringify(w.url)}: { missing: true },`);let h=[],$=[],P=[],E=!1,T=0;for(let w of ee(l)){if(!w.node?.api)continue;let L=s[w.pagePath];if(!L)continue;E=!0;let I=`__op${T}`,F=`__samples${T}`,O=`__api${T}`,x=ue.join(e,`${w.pagePath}.mdx`),A=hr.existsSync(x)?`__overlay${T}`:null;T+=1,A&&f.push(`import * as ${A} from ${JSON.stringify(x.split(ue.sep).join("/"))};`),h.push(`const ${I} = ${JSON.stringify(L.operation)};`),h.push(`const ${F} = ${JSON.stringify(L.samples)};`),P.push(`{ id: ${JSON.stringify(L.operation.id)}, method: ${JSON.stringify(L.operation.method)}, title: ${JSON.stringify(L.operation.title)}, url: ${JSON.stringify(w.url)}, operation: ${I}, samples: ${F}, api: ${JSON.stringify(L.api||{proxy:!0,server:null})} }`);let k=`{ preset: ${JSON.stringify(y.theme)}, operation: ${I}, samples: ${F}, apiOperations: __apiOperations, api: ${JSON.stringify(L.api||{proxy:!0,server:null})} }`;$.push(A?`function ${O}(){ return React.createElement(ApiReferencePage, ${k}, React.createElement(${A}.default)); }`:`function ${O}(){ return React.createElement(ApiReferencePage, ${k}); }`),g.push(` ${JSON.stringify(w.url)}: { Component: ${O}, frontmatter: { title: ${JSON.stringify(L.title)}, description: ${JSON.stringify(L.description)} }, toc: ${A?`${A}.toc || []`:"[]"}, operation: ${I}, samples: ${F}, api: true },`)}E&&(h.push(`const __apiOperations = [
|
|
101
|
+
${P.join(`,
|
|
91
102
|
`)}
|
|
92
|
-
];`),
|
|
93
|
-
`)));let
|
|
94
|
-
`),
|
|
95
|
-
`),"function __mdxApi(mod) { const data = Reflect.get(mod, 'veluApi'); return data?.operation ? { mdxApi: data, api: true, operation: data.operation, samples: data.samples } : {}; }",
|
|
96
|
-
`),"","export const pages = {",
|
|
97
|
-
`),"};",`export const navigation = ${JSON.stringify(
|
|
98
|
-
`)}var
|
|
103
|
+
];`),h.push($.join(`
|
|
104
|
+
`)));let S=[];return E&&(S.push("import React from 'react';"),S.push("import { ApiReferencePage } from 'velu-ui';")),["// AUTO-GENERATED by vite-plugin-velu-site. Do not edit.",S.join(`
|
|
105
|
+
`),f.join(`
|
|
106
|
+
`),"function __mdxApi(mod) { const data = Reflect.get(mod, 'veluApi'); return data?.operation ? { mdxApi: data, api: true, operation: data.operation, samples: data.samples } : {}; }",h.join(`
|
|
107
|
+
`),"","export async function initializeReader() {}","export const pages = {",g.join(`
|
|
108
|
+
`),"};",`export const navigation = ${JSON.stringify(l)};`,`export const site = ${JSON.stringify(y)};`,"if (site.logo) {"," const __veluBase = (import.meta.env.BASE_URL || '/').replace(/\\/$/, '');"," site.logo = { ...site.logo, light: __veluBase + site.logo.light, dark: __veluBase + site.logo.dark };","}",""].join(`
|
|
109
|
+
`)}var vr,yr,xr=_(()=>{rr();re();Me();Fe();Bt();Dt();vr="virtual:velu-site",yr="\0"+vr});import nt from"node:path";function wr(e){let t=nt.resolve(e);return{name:"velu-tailwind-project-source",enforce:"pre",transform(r,n){let o=n.split("?",1)[0].replace(/\\/g,"/");if(!o.endsWith("/styles.css")||!o.includes("/velu-ui/")||r.includes("data-velu-project-source"))return null;let i=nt.dirname(n.split("?",1)[0]),a=nt.relative(i,t).split(nt.sep).join("/");!a||a===""?a=".":a.startsWith(".")||(a=`./${a}`);let s=`
|
|
99
110
|
/* data-velu-project-source */
|
|
100
111
|
@source "${a}/**/*.{mdx,md,jsx,tsx,js,ts,html}";
|
|
101
112
|
@source not "${a}/node_modules";
|
|
102
113
|
@source not "${a}/.velu";
|
|
103
114
|
@source not "${a}/dist";
|
|
104
115
|
@source not "${a}/.git";
|
|
105
|
-
`;return{code:r+s,map:null}}}}var
|
|
106
|
-
`))i.push(` ${a}`);return e.suggestion&&i.push(` ${Q(t,
|
|
107
|
-
`)}function it(e,{color:t=!1}={}){if(!e.length)return Q(t,
|
|
108
|
-
`)}var qt,
|
|
116
|
+
`;return{code:r+s,map:null}}}}var $r=_(()=>{});import{visit as Gi}from"unist-util-visit";function Wi(e,t){let r=Sr(e).replace(/[?#].*$/,""),n=Sr(t).replace(/\/+$/,"");return n&&r.toLowerCase().startsWith(n.toLowerCase())?r.slice(n.length).replace(/^\/+/,""):null}function kr(e,t){return()=>(r,n)=>{typeof e=="function"&&Gi(r,o=>{if(o.type!=="mdxJsxFlowElement"&&o.type!=="mdxJsxTextElement"||typeof o.name!="string"||!/^[A-Z]/.test(o.name)||o.name.includes("."))return;let i={};for(let s of o.attributes||[])s.type==="mdxJsxAttribute"&&(s.value==null?i[s.name]=!0:typeof s.value=="string"&&(i[s.name]=s.value));let a=e(o.name,i,{checkRequired:!1});if(a){let s=new Error(a.title);throw s.veluIssue={...a,file:Wi(n?.path,t),line:o.position?.start?.line??null,column:o.position?.start?.column??null},s.loc={line:s.veluIssue.line,column:s.veluIssue.column},s}})}}var Sr,jr=_(()=>{Sr=e=>String(e||"").replace(/\\/g,"/")});import rt from"node:path";import Hi from"node:fs";import{createRequire as Ki}from"node:module";import Xi from"@tailwindcss/vite";import Yi from"@vitejs/plugin-react";import Zi from"@mdx-js/rollup";import Qi from"remark-frontmatter";import es from"remark-mdx-frontmatter";import ts from"remark-gfm";import ns from"rehype-slug";function rs(e){let r=Ki(import.meta.url).resolve("@mdx-js/react"),n=rt.resolve(e,"runtime","velu-ui"),o=Hi.existsSync(n)?n:rt.resolve(e,"..","velu-ui","src");return[{find:"@mdx-js/react",replacement:r},{find:/^velu-ui$/,replacement:rt.join(o,"index.js")},{find:/^velu-ui\//,replacement:o+"/"}]}function Ar({targetDir:e,VITE_ROOT:t,validateProps:r,basePath:n,buildOutDir:o}){return{root:t,base:n?`${n}/`:"/",plugins:[br(e,{buildOutDir:o}),Zi({remarkPlugins:[Qi,es,ts,Vt,Ie,kr(r,e)],rehypePlugins:[ns],providerImportSource:"@mdx-js/react"}),Yi(),wr(e),Xi({optimize:!1})],cacheDir:rt.resolve(e,".velu","vite-cache"),optimizeDeps:{include:["react","react-dom","react-dom/client","react-router-dom","@mdx-js/react","lucide-react","prism-react-renderer","iso-639-1","github-slugger"],exclude:["tailwindcss","@tailwindcss/oxide","playwright","playwright-core","@apidevtools/swagger-parser","satori","@resvg/resvg-js","pagefind"],esbuildOptions:{loader:{".mdx":"jsx"}}},resolve:{alias:rs(t),dedupe:["react","react-dom","@mdx-js/react"]}}}var Or=_(()=>{zt();tr();xr();$r();jr()});function z(e){return{category:"render-crash",severity:"error",file:null,line:null,column:null,frame:null,title:"Something went wrong",detail:"",hint:"",suggestion:null,...e}}function os(e,t){if(e=String(e),t=String(t),e===t)return 0;if(!e.length)return t.length;if(!t.length)return e.length;let r=Array.from({length:t.length+1},(o,i)=>i),n=new Array(t.length+1);for(let o=1;o<=e.length;o++){n[0]=o;for(let i=1;i<=t.length;i++){let a=e[o-1]===t[i-1]?0:1;n[i]=Math.min(n[i-1]+1,r[i]+1,r[i-1]+a)}[r,n]=[n,r]}return r[t.length]}function ot(e,t=[]){if(!e)return null;let r=String(e).toLowerCase(),n=null,o=1/0;for(let a of t){let s=os(r,String(a).toLowerCase());s<o&&(o=s,n=a)}let i=Math.min(3,Math.max(2,Math.floor(r.length/4)));return o<=i?n:null}function is(e,t){return e==="warning"?Q(t,K.yellow,"\u26A0"):e==="info"?Q(t,K.cyan,"\u2139"):Q(t,K.red,"\u2716")}function Gt(e,{color:t=!1}={}){let r=qt[e.category]||e.category,n=e.line?`${e.line}${e.column?`:${e.column}`:""}`:"",o=e.file?`${e.file}${n?`:${n}`:""}`:n,i=[];if(i.push(`${is(e.severity,t)} ${Q(t,K.bold,r)}`+(o?` ${Q(t,K.dim,o)}`:"")),e.title&&i.push(` ${e.title}`),e.detail&&e.detail!==e.title&&i.push(` ${Q(t,K.dim,e.detail)}`),e.frame)for(let a of String(e.frame).split(`
|
|
117
|
+
`))i.push(` ${a}`);return e.suggestion&&i.push(` ${Q(t,K.cyan,`Did you mean <${e.suggestion}>?`)}`),e.hint&&i.push(` ${Q(t,K.dim,`\u2192 ${e.hint}`)}`),i.join(`
|
|
118
|
+
`)}function it(e,{color:t=!1}={}){if(!e.length)return Q(t,K.cyan,"\u2713 No issues found.");let r=new Map;for(let s of e){let l=s.file||"velu.json";r.has(l)||r.set(l,[]),r.get(l).push(s)}let n=[];for(let[s,l]of r){n.push(Q(t,K.bold,s));for(let c of l)n.push(Gt({...c,file:null},{color:t}).replace(/^/gm," "));n.push("")}let o=e.filter(s=>s.severity!=="warning"&&s.severity!=="info").length,i=e.length-o,a=`${o} error${o===1?"":"s"}`+(i?`, ${i} warning${i===1?"":"s"}`:"");return n.push(Q(t,o?K.red:K.yellow,a)),n.join(`
|
|
119
|
+
`)}var qt,K,Q,pe=_(()=>{qt={"mdx-syntax":"MDX syntax",frontmatter:"Frontmatter","unknown-component":"Unknown component","invalid-props":"Invalid options","render-crash":"Render error","config-json":"velu.json","config-schema":"velu.json","config-nav":"Navigation","config-asset":"Asset"};K={reset:"\x1B[0m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",dim:"\x1B[2m",bold:"\x1B[1m"},Q=(e,t,r)=>e?`${t}${r}${K.reset}`:r});function ss(e){let t=e,r=0;for(;t&&t.cause&&r<3&&!(t.loc||t.line||/`[^`]+` to be defined/.test(t.message||""));)t=t.cause,r+=1;return t||e}function Wt(e,t){if(!e)return null;let r=Er(e).replace(/[?#].*$/,""),n=t?Er(t).replace(/\/+$/,""):"";return n&&r.toLowerCase().startsWith(n.toLowerCase())?r.slice(n.length).replace(/^\/+/,""):!/^([a-zA-Z]:\/|\/)/.test(r)&&!/node_modules/.test(r)?r:null}function as(e){return e?String(e).replace(/([a-zA-Z]:\\|\/)[^\s'"()]+/g,t=>/node_modules|[\\/]vite[\\/]|@veluai|velu-cli|velu-ui/.test(t)?"\u2026":t).trim():""}function ls(e){let t=/\((\d+):(\d+)(?:-\d+:\d+)?\)\s*$/.exec(String(e||""));return t?{line:Number(t[1]),column:Number(t[2])}:null}function cs(e){return String(e||"").replace(/\s*\(\d+:\d+(?:-\d+:\d+)?\)\s*$/,"").trim()}function ps(e,t){if(!e||!t)return null;let r=String(e);return/node_modules|[\\/]vite[\\/]|@veluai[\\/]/.test(r)?null:r}function Ve(e,t={}){let{projectDir:r="",knownComponents:n=[],file:o=null}=t,i=null;for(let h=e,$=0;h&&$<6;h=h.cause,$+=1)if(h.veluIssue){i=h.veluIssue;break}if(i)return z({...i,file:i.file||o});let a=ss(e)||{},s=a.message||String(e||""),l=/Expected component `([^`]+)` to be defined/.exec(s);if(l){let h=l[1],$=/referenced in your code at `(\d+):(\d+)/.exec(s),P=/\bin `([^`]+)`/.exec(s),E=P?Wt(P[1],r):null;return z({category:"unknown-component",file:E||o,line:$?Number($[1]):null,column:$?Number($[2]):null,title:`<${h}> is not a built-in component`,detail:"",hint:"Components are built in \u2014 check the spelling and capitalization (you don\u2019t import them).",suggestion:ot(h,n)})}let c=a.loc||(a.line!=null?{line:a.line,column:a.column,file:a.file}:null)||ls(a.reason||s),u=a.id||c&&c.file||a.file||null,p=Wt(u,r)||o,y=!!p&&Wt(u,r)!=null,f=ps(a.frame,y||!!o),g=as(cs(a.reason||s)),b=us.test(s),m=a.source==="remark-frontmatter"||/\byaml\b|frontmatter/i.test(s)||c&&c.line===1&&/unexpected|expected/i.test(s)&&/---/.test(s);return c||b||f&&y?z({category:m?"frontmatter":"mdx-syntax",file:p,line:c?c.line:null,column:c?c.column:null,frame:f,title:g||(m?"Invalid frontmatter":"MDX syntax error"),detail:"",hint:m?"Check the YAML between the --- markers \u2014 indentation, quotes, and colons.":"Make sure every <Component> has a matching closing tag and that { } braces are balanced."}):/\.map is not a function|is not iterable|reading '|undefined \(reading/i.test(s)?z({category:"invalid-props",file:p,title:"A component received an invalid value",detail:g,hint:"Check the props/options you passed to a component on this page."}):z({category:"render-crash",file:p,title:"This page failed to render",detail:g,hint:"Set VELU_DEBUG=1 for the full stack trace."})}var Er,us,Ht=_(()=>{pe();Er=e=>String(e).replace(/\\/g,"/");us=/closing tag|unexpected closing|could not parse (?:expression|import|export)|unexpected character|unexpected end of|expected a closing|expected the closing|unexpected `|in expression|misnested|before name/i});function fs(e){let t=qt[e.category]||e.category,r=e.file?`${e.file}${e.line?`:${e.line}${e.column?`:${e.column}`:""}`:""}`:"",n=[];return n.push('<div class="velu-err-card">'),n.push('<div class="velu-err-head">'),n.push(`<span class="velu-err-pill">${oe(t)}</span>`),n.push("</div>"),e.title&&n.push(`<div class="velu-err-title">${oe(e.title)}</div>`),r&&n.push(`<a class="velu-err-loc" title="${oe(r)}">${oe(r)}</a>`),e.detail&&n.push(`<div class="velu-err-detail">${oe(e.detail)}</div>`),e.frame&&n.push(`<pre class="velu-err-frame">${oe(e.frame)}</pre>`),e.suggestion&&n.push(`<div class="velu-err-suggest">Did you mean <code><${oe(e.suggestion)}></code>?</div>`),e.hint&&n.push(`<div class="velu-err-hint">${oe(e.hint)}</div>`),n.push("</div>"),n.join("")}function Kt(e,t={}){let r=Array.isArray(e)?e:[e],n=t.title||(r.length>1?`${r.length} problems to fix`:"There\u2019s a problem to fix"),o=r.map(fs).join(`
|
|
109
120
|
`);return`<!doctype html>
|
|
110
121
|
<html lang="en">
|
|
111
122
|
<head>
|
|
@@ -177,16 +188,16 @@ ${h.join(`,
|
|
|
177
188
|
<div class="velu-err-foot">Fix the file and save \u2014 this page reloads automatically.</div>
|
|
178
189
|
</div>
|
|
179
190
|
</body>
|
|
180
|
-
</html>`}var oe,
|
|
181
|
-
`).length}function
|
|
191
|
+
</html>`}var oe,Tr=_(()=>{pe();oe=e=>String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")});import st from"node:fs";import Be from"node:path";import{fileURLToPath as ms}from"node:url";import ds from"iso-639-1";function Je(e,t){if(!t)return null;let r=e.indexOf(`"${t}"`);return r===-1?null:e.slice(0,r).split(`
|
|
192
|
+
`).length}function ys(e,t){return t==null||t<0?null:e.slice(0,t).split(`
|
|
182
193
|
`).length}function Xt(e,t){if(!t)return null;let r=e.indexOf(`"${t}"`);return r===-1?null:e.slice(0,r).split(`
|
|
183
|
-
`).length}function
|
|
184
|
-
${e}`;let r=e.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n/),n=`> ${
|
|
194
|
+
`).length}function vs(e,t,r){let n=[];return s(e,t,"",null),n;function o(l){if(l&&l.$ref){let c=l.$ref.replace(/^#\//,"").split("/"),u=r;for(let p of c)u=u?.[p];return u||{}}return l}function i(l){return Array.isArray(l)?"array":l===null?"null":typeof l}function a(l,c){let u=n.length;s(l,c,"",null,!0);let p=n.length===u;return p||(n.length=u),p}function s(l,c,u,p,y){let f=o(c);if(f){if(f.oneOf){f.oneOf.some(b=>a(l,b))||n.push({path:u,key:p,message:"value does not match any allowed shape"});return}if(f.type&&i(l)!==f.type){n.push({path:u,key:p,message:`expected ${f.type}, got ${i(l)}`});return}if(f.type==="string"&&f.minLength!=null&&l.length<f.minLength&&n.push({path:u,key:p,message:"must not be empty"}),f.type==="object"&&i(l)==="object"){for(let b of f.required||[])b in l||n.push({path:u?`${u}.${b}`:b,key:b,message:`missing required "${b}"`});let g=f.properties||{};if(f.additionalProperties===!1)for(let b of Object.keys(l))b in g||n.push({path:u?`${u}.${b}`:b,key:b,message:`unknown field "${b}"`});for(let[b,m]of Object.entries(g))b in l&&s(l[b],m,u?`${u}.${b}`:b,b,y)}f.type==="array"&&Array.isArray(l)&&f.items&&l.forEach((g,b)=>s(g,f.items,`${u}[${b}]`,p,y))}}}function bs(e){if(typeof e!="string")return!1;let t=e.trim();return/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^(rgb|rgba|hsl|hsla|color|oklch|lab|lch)\(/i.test(t)||/^[a-z][a-z0-9-]*$/i.test(t)}function at(e){let t=[],r=Be.join(e,"velu.json"),n;try{n=st.readFileSync(r,"utf-8")}catch(s){return s.code==="ENOENT"?t.push(z({category:"config-json",file:"velu.json",title:"No velu.json found",hint:"Run `velu init <name>` to scaffold a project."})):t.push(z({category:"config-json",file:"velu.json",title:"Could not read velu.json"})),t}let o;try{o=JSON.parse(n)}catch(s){let l=/position (\d+)/.exec(s.message||""),c=l?ys(n,Number(l[1])):null;return t.push(z({category:"config-json",file:"velu.json",line:c,title:"velu.json is not valid JSON",detail:String(s.message||"").replace(/\s+in JSON.*$/,""),hint:"Check for a trailing comma, a missing quote, or an unclosed brace."})),t}let i=null;try{i=JSON.parse(st.readFileSync(hs,"utf-8"))}catch{}if(i)for(let s of vs(o,i,i)){let l=/^unknown field/.test(s.message);t.push(z({category:"config-schema",severity:l?"warning":"error",file:"velu.json",line:Je(n,s.key),title:s.path?`${s.path}: ${s.message}`:s.message,hint:l?"Remove it, or check the spelling against the velu.json schema.":""}))}for(let s of["primary","light","dark"]){let l=o.colors?.[s];l!=null&&!bs(l)&&t.push(z({category:"config-schema",severity:"warning",file:"velu.json",line:Je(n,s),title:`colors.${s}: "${l}" doesn\u2019t look like a CSS color`,hint:"Use a hex value like #dc143c, an rgb()/hsl() function, or a CSS color name."}))}if(typeof o.favicon=="string"&&o.favicon.trim()){let s=Be.resolve(e,o.favicon.replace(/^\/+/,""));st.existsSync(s)||t.push(z({category:"config-asset",file:"velu.json",line:Je(n,"favicon"),title:`favicon not found: ${o.favicon}`,hint:"The path is relative to the project root."}))}let a=Ue(o.logo);if(a){let s=new Map;for(let l of["light","dark"]){let c=a[l];c&&s.set(c,[...s.get(c)||[],l])}for(let[l,c]of s)if(!st.existsSync(Be.resolve(e,l.replace(/^\/+/,"")))){let u=c.length===2?"logo":`logo (${c[0]})`;t.push(z({category:"config-asset",file:"velu.json",line:Xt(n,l),title:`${u} not found: ${l}`,hint:"The path is relative to the project root."}))}}if(o.navigation&&typeof o.navigation=="object"){let s;try{s=Y(o.navigation)}catch(l){t.push(z({category:"config-nav",file:"velu.json",line:Je(n,"navigation"),title:"navigation could not be processed",detail:String(l.message||"")})),s=null}if(s){let{pageEntries:l,warnings:c}=ae(s,e);for(let u of c){let p=/not found$/.test(u),y=/page "([^"]+)"/.exec(u),f=y?Xt(n,y[1]):null;t.push(z({category:"config-nav",severity:p?"error":"warning",file:"velu.json",line:f,title:u,hint:p?"Create the .mdx file, or remove the page from navigation.":""}))}xs(s,n,t)}}return t}function xs(e,t,r){let n=new Set,o=i=>{if(!(!i||typeof i!="object")){if(i.language&&!n.has(i.language)){n.add(i.language);let a=String(i.language).toLowerCase();ds.validate(a)||r.push(z({category:"config-nav",severity:"warning",file:"velu.json",line:Xt(t,i.language)||Je(t,"language"),title:`"${i.language}" is not a valid ISO 639-1 language code`,hint:'Use a two-letter code like "en", "fr", or "ja".'}))}for(let a of Object.values(i))Array.isArray(a)?a.forEach(o):a&&typeof a=="object"&&o(a)}};o(e)}var gs,hs,Yt=_(()=>{pe();re();Me();Fe();gs=Be.dirname(ms(import.meta.url)),hs=Be.resolve(gs,"..","..","schema","velu.schema.json")});import ws from"node:fs/promises";import $s from"node:fs";import fe from"node:path";import{fileURLToPath as Ss,pathToFileURL as ks}from"node:url";import{compile as js}from"@mdx-js/mdx";import As from"remark-frontmatter";import Os from"remark-mdx-frontmatter";import Es from"remark-gfm";import Ts from"rehype-slug";import{visit as Cs}from"unist-util-visit";function Zt(){if(lt)return lt;let e=fe.dirname(Ss(import.meta.url)),t=[fe.resolve(e,"..","runtime","velu-ui"),fe.resolve(e,"..","..","runtime","velu-ui"),fe.resolve(e,"..","..","..","velu-ui","src")],r=null;for(let n of t){let o=fe.join(n,"lib","component-schemas.js");if($s.existsSync(o)){r=o;break}}return lt=r?import(ks(r).href).then(n=>n.validateProps).catch(()=>null):Promise.resolve(null),lt}function Ps(e){let t={};for(let r of e.attributes||[])r.type==="mdxJsxAttribute"&&(r.value==null?t[r.name]=!0:typeof r.value=="string"&&(t[r.name]=r.value));return t}function Ls(e,t){return()=>r=>{Cs(r,n=>{if((n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")&&typeof n.name=="string"&&/^[A-Z]/.test(n.name)&&!n.name.includes(".")&&e.push({name:n.name,props:Ps(n),line:n.position?.start?.line??null,column:n.position?.start?.column??null}),n.type==="mdxjsEsm"&&typeof n.value=="string")for(let o of n.value.matchAll(/\b([A-Z][A-Za-z0-9_]*)\b/g))t.add(o[1])})}}async function _s(e,t){let r=[],n;try{n=await ws.readFile(t.fileAbsPath,"utf-8")}catch{return r}let o=fe.relative(e,t.fileAbsPath).split(fe.sep).join("/"),i=[],a=new Set;try{await js({value:n,path:t.fileAbsPath},{remarkPlugins:[As,Os,Es,Ie,Ls(i,a)],rehypePlugins:[Ts],providerImportSource:"@mdx-js/react"})}catch(u){return r.push(Ve(u,{projectDir:e,knownComponents:ne,file:o})),r}let s=new Set(ne),l=await Zt(),c=new Set;for(let u of i)if(!a.has(u.name)){if(!s.has(u.name)){if(c.has(u.name))continue;c.add(u.name),r.push(z({category:"unknown-component",file:o,line:u.line,column:u.column,title:`<${u.name}> is not a built-in component`,hint:"Components are built in \u2014 check the spelling and capitalization (you don\u2019t import them).",suggestion:ot(u.name,ne)}));continue}if(l){let p=l(u.name,u.props,{checkRequired:!1});p&&r.push(z({...p,file:o,line:u.line,column:u.column}))}}return r}async function Cr(e,t){let r=t.filter(s=>s.exists),n=[],o=8,i=0;async function a(){for(;i<r.length;){let s=r[i++],l=await _s(e,s);for(let c of l)n.push(c)}}return await Promise.all(Array.from({length:Math.min(o,r.length)},a)),n}var lt,Qt=_(()=>{zt();pe();Ht();We()});function en(e={},t=[]){if("public"in e&&typeof e.public!="boolean")throw new Error("Frontmatter public must be a boolean.");if(t.some(n=>n.public!==void 0&&typeof n.public!="boolean"))throw new Error("Navigation public must be a boolean.");let r=e.groups;if(r!==void 0&&(!Array.isArray(r)||r.length===0||r.some(n=>typeof n!="string"||!n.trim())))throw new Error("Frontmatter groups must be a non-empty array of group names.");return r?{public:!1,groups:[...new Set(r.map(n=>n.trim()))]}:{public:e.public??t.some(n=>n.public===!0),groups:[]}}var Pr=_(()=>{});import qe from"node:fs";import tn from"node:path";import Rr from"js-yaml";function nn(e,t,r){if(r>24||e===null||typeof e!="object")return r>24&&e&&typeof e=="object"?null:e;if(t.has(e))return null;t.add(e);let n;if(Array.isArray(e))n=e.map(o=>nn(o,t,r+1));else{n={};for(let[o,i]of Object.entries(e))n[o]=nn(i,t,r+1)}return t.delete(e),n}function Nr(e){return Rr.dump(nn(e,new Set,0),{noRefs:!0,lineWidth:100,skipInvalid:!0})}function Ur(e){let t=String(e).replace(/\.md$/i,"");return t===""||t==="/"||t==="/index"?"/":t.replace(/\/+$/,"")||"/"}function Rs(e){return e==="/"?"/index.md":`${e}.md`}function rn(e,t){if(t==="api")return`# ${Lr}
|
|
195
|
+
${e}`;let r=e.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n/),n=`> ${Lr}
|
|
185
196
|
|
|
186
|
-
`;return r?e.slice(0,r[0].length)+n+e.slice(r[0].length):n+e}function
|
|
187
|
-
`)}async function
|
|
197
|
+
`;return r?e.slice(0,r[0].length)+n+e.slice(r[0].length):n+e}function Us(e){return e.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,"")}function Fs(e){try{let t=qe.readFileSync(e,"utf-8").match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!t)return{};let r=Rr.load(t[1]);return r&&typeof r=="object"?r:{}}catch{return{}}}async function we(e){let t={};try{t=JSON.parse(qe.readFileSync(tn.join(e,"velu.json"),"utf-8"))}catch{return{name:tn.basename(e),baseUrl:"",pages:[]}}let r=t.name??tn.basename(e),n=typeof process.env.VELU_SITE_URL=="string"?process.env.VELU_SITE_URL.replace(/\/+$/,""):"",o=Z(t.api),i=t.navigation??{},a={};try{let p=await et(t.navigation??{},{targetDir:e,api:o});i=p.nav,a=p.ops}catch(p){console.warn(`[velu] openapi: ${p.message}`)}let s=Y(i),{pageEntries:l}=ae(s,e),c=new Map(l.map(p=>[p.url,p])),u=[];for(let p of ee(s)){if(!p.url)continue;let y=p.ancestors.filter(h=>h.kind==="group").pop(),f=p.ancestors.filter(h=>h.kind==="tab").pop(),g=y?.label||f?.label||"Pages",b=p.ancestors.filter(h=>h.kind==="tab"||h.kind==="group").map(h=>h.label),m=p.ancestors.filter(h=>h.kind==="language").pop()?.code||null;if(p.node?.api){let h=a[p.pagePath];if(!h)continue;let $=h.title||_r(p.url);u.push({url:p.url,title:$,description:h.description||"",group:g,breadcrumb:[...b,$],lang:m,access:en({},p.ancestors),frontmatter:{title:h.title,description:h.description},source:{kind:"api",segment:h.segment}})}else{let h=c.get(p.url);if(!h||!h.exists)continue;let $=Fs(h.fileAbsPath),P=$.title||_r(p.url);u.push({url:p.url,title:P,description:$.description||"",group:g,breadcrumb:[...b,P],lang:m,access:en($,p.ancestors),frontmatter:$,source:{kind:"mdx",fileAbsPath:h.fileAbsPath}})}}return{name:r,baseUrl:n,pages:u,navigation:s}}function ut(e){return new Map(e.pages.map(t=>[t.url,{...t.source,title:t.title}]))}async function Is(e){return ut(await we(e))}async function on(e,t,r){let o=(r||await Is(e)).get(t);if(!o)return null;if(o.kind==="mdx")try{return{body:qe.readFileSync(o.fileAbsPath,"utf-8"),contentType:"text/markdown; charset=utf-8",kind:"mdx"}}catch{return null}return o.segment?{body:Nr(o.segment),contentType:"text/yaml; charset=utf-8",kind:"api"}:null}async function Fr(e,t){let r=t||await we(e),n=s=>r.baseUrl?r.baseUrl+s:s,o=[`# ${r.name}`,"",`> Documentation index for ${r.name}. Append \`.md\` to any page URL (or send \`Accept: text/markdown\`) for its Markdown; fetch ${ct} for the whole site in one document.`,""],i=[],a=new Map;for(let s of r.pages)a.has(s.group)||(a.set(s.group,[]),i.push(s.group)),a.get(s.group).push(s);for(let s of i){o.push(`## ${s}`,"");for(let l of a.get(s))o.push(`- [${l.title}](${n(Rs(l.url))})${l.description?`: ${l.description}`:""}`);o.push("")}return o.join(`
|
|
198
|
+
`)}async function Ir(e,t){let r=t||await we(e),n=[`# ${r.name}`,"",`> Full documentation \u2014 every page concatenated. Index: ${be}`];for(let o of r.pages)if(n.push("","---","",`# ${o.title}`,`Source: ${o.url}`,""),o.source.kind==="mdx")try{n.push(Us(qe.readFileSync(o.source.fileAbsPath,"utf-8")).trim())}catch{}else o.source.segment&&n.push("```yaml",Nr(o.source.segment).trim(),"```");return n.join(`
|
|
188
199
|
`)+`
|
|
189
|
-
`}async function
|
|
200
|
+
`}async function Mr(e,t){let r=t||await we(e),n=r.baseUrl||"",o=[];for(let s of r.pages){if(s.source.kind!=="mdx")continue;let l="";try{l=qe.readFileSync(s.source.fileAbsPath,"utf-8")}catch{continue}let c=/<Update\b([^>]*)>([\s\S]*?)<\/Update>/gi,u;for(;u=c.exec(l);){let p=u[1]||"",y=u[2]||"",f=De(p,"label")||De(p,"date")||"Update",g=De(p,"description")||zs(y)||f,b=De(p,"description"),m=`${n}${s.url}#${Ms(f,b)}`,h=De(p,"date")||f,$=new Date(h),P=Number.isNaN($.getTime())?null:$.toUTCString();o.push({title:f,link:m,description:g,pubDate:P})}}if(!o.length)return null;let i=n||"/",a=o.map(s=>` <item>
|
|
190
201
|
<title>${me(s.title)}</title>
|
|
191
202
|
<link>${me(s.link)}</link>
|
|
192
203
|
<guid isPermaLink="true">${me(s.link)}</guid>
|
|
@@ -203,12 +214,12 @@ ${e}`;let r=e.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n/),n=`> ${Tr}
|
|
|
203
214
|
`+a+`
|
|
204
215
|
</channel>
|
|
205
216
|
</rss>
|
|
206
|
-
`}var be,ct,
|
|
217
|
+
`}var be,ct,Ns,xe,Lr,_r,me,Ms,De,zs,zr=_(()=>{Pr();re();Me();Fe();Bt();be="/llms.txt",ct="/llms-full.txt",Ns=`<${be}>; rel="llms-txt", <${ct}>; rel="llms-full-txt"`,xe={Link:Ns,"X-Llms-Txt":be},Lr=`Full documentation index: ${be}`;_r=e=>(e.split("/").filter(Boolean).pop()||"Home").replace(/[-_]+/g," ").replace(/\b\w/g,r=>r.toUpperCase());me=e=>String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),Ms=(e,t)=>{let r=a=>String(a||"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),n=r(e),o=t==null||t===""?"":r(t);return`update-${o?n?`${n}-${o}`:o:n||"item"}`},De=(e,t)=>{let r=e.match(new RegExp(`${t}\\s*=\\s*["']([^"']*)["']`,"i"));return r?r[1]:void 0},zs=e=>String(e||"").replace(/```[\s\S]*?```/g,"").replace(/<[^>]+>/g," ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/[#*`_>]/g,"").replace(/\s+/g," ").trim().slice(0,500)});var Hr={};Se(Hr,{startDevServer:()=>na});import Vr from"node:fs/promises";import $e from"node:fs";import Vs from"node:http";import{spawn as Js}from"node:child_process";import W from"node:path";import{fileURLToPath as Bs}from"node:url";import Ds from"chokidar";import sn from"express";import{createServer as qs,createLogger as Gs,searchForWorkspaceRoot as Ws}from"vite";function Ys(e){return`<link rel="stylesheet" href="${`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e).replace(/%20/g,"+")}:wght@300;400;500;600;700&display=swap`}" />`}function Br(e,t){let r=Gt(e,{color:!!process.stderr.isTTY});console.error(`
|
|
207
218
|
`+r+`
|
|
208
|
-
`),process.env.VELU_DEBUG&&t&&console.error(t)}function
|
|
209
|
-
`)}function
|
|
210
|
-
`+it(
|
|
211
|
-
`)
|
|
212
|
-
${
|
|
213
|
-
</style>`,ie=
|
|
214
|
-
`),
|
|
219
|
+
`),process.env.VELU_DEBUG&&t&&console.error(t)}function Dr(){try{return JSON.parse($e.readFileSync(W.join(pt,"package.json"),"utf8")).version||"unknown"}catch{return"unknown"}}function Zs(e,t){let r=W.resolve(e,".velu"),n=W.resolve(r,".velu-version"),o=null;try{o=$e.readFileSync(n,"utf8").trim()}catch{}if(o!==t){if(o!==null)try{$e.rmSync(W.join(r,"vite-cache"),{recursive:!0,force:!0}),console.log("[velu] new version detected \u2014 refreshing the preview cache\u2026")}catch{}try{$e.mkdirSync(r,{recursive:!0}),$e.writeFileSync(n,t)}catch{}}}async function qr(e){try{return await Yn(e)}catch{return Ft({},W.basename(e))}}async function Gr(e,t){let r=await e.moduleGraph.getModuleByUrl(t,!0),n=new Map,o=new Set;async function i(a){if(!(!a||o.has(a.url))){if(o.add(a.url),a.id&&Ks.test(a.id)){let s=a.url.includes("?")?"&":"?",l=await e.transformRequest(`${a.url}${s}direct`);l?.code&&n.set(a.url,l.code)}for(let s of a.importedModules)await i(s)}}return await i(r),[...n.values()].join(`
|
|
220
|
+
`)}function ta(e,t,r){let n=()=>{process.stdout.isTTY&&!process.env.VELU_NO_BELL&&process.stdout.write("\x07")},o=process.stdout.isTTY,i=g=>o&&process.stdout.write(`\x1B]${g}\x1B\\`),a=()=>{i(`0;\u23F3 ${t}`),i("9;4;3;0")},s=()=>{i(`0;${t}`),i("9;4;0;0")};o&&process.once("exit",()=>i("9;4;0;0")),a();let l=r&&r!=="unknown"?`v${r}`:"";if(!e)return console.log(`Starting Velu${l?" "+l:""}\u2026`),{ready:g=>{console.log(`Velu${l?" "+l:""} ready \u2192 ${g}`),s(),n()}};let c="\x1B[38;2;220;20;60m",u="\x1B[0m",p="\x1B[2m";console.log("");for(let g of Qs)console.log(`${c}${g}${u}`);l&&console.log(` ${p}${l}${u}`),console.log("");let y=null;try{y=Js(process.execPath,["-e",ea],{stdio:["ignore","inherit","ignore"]}),y.on("error",()=>{})}catch{}let f=()=>{if(y){try{y.kill()}catch{}y=null}};return process.once("exit",f),{ready:g=>{f(),process.stdout.write("\x1B[2K\r"),console.log(` \x1B[32m\u2713${u} Velu${l?" "+l:""} ready \u2192 \x1B[36m${g}${u}`),s(),n()}}}async function na(e){let t=!!process.env.VELU_PROFILE,r=performance.now(),n=(O,x)=>t&&console.log(`[velu-profile] ${O}: ${(performance.now()-x).toFixed(0)}ms`),o=ta(!!process.stdout.isTTY&&!t,W.basename(e),Dr()),i=await qr(e),a=l(),s=ze(e);function l(){let x=at(e).filter(A=>A.severity==="error"&&(A.category==="config-json"||A.category==="config-schema"));return x.length&&console.error(`
|
|
221
|
+
`+it(x,{color:!!process.stderr.isTTY})+`
|
|
222
|
+
`),x}let c=e;try{c=$e.realpathSync(e)}catch{}let u=0,p=O=>{let x=performance.now();if(x-u<500)return;u=x;let A=Ve(O,{projectDir:c,knownComponents:ne});Br(A,O)};process.on("unhandledRejection",p),process.on("uncaughtException",p);let y=Number(process.env.PORT)||8358,f=await Zt();Zs(e,Dr());let g=sn(),b=Vs.createServer(g),m=Gs(t?"info":"warn"),h=O=>typeof O=="string"&&O.includes("Failed to load source map"),$=m.warn.bind(m),P=m.warnOnce.bind(m);m.warn=(O,x)=>{h(O)||$(O,x)},m.warnOnce=(O,x)=>{h(O)||P(O,x)};let E=await qs({...Ar({targetDir:e,VITE_ROOT:pt,validateProps:f}),appType:"custom",logLevel:t?"info":"warn",customLogger:m,server:{middlewareMode:!0,fs:{allow:[Ws(pt),e,c]},hmr:{server:b}}});n("vite server created",r),g.get(new RegExp(`^${tt}/`),(O,x,A)=>{let k=dr(s,O.path);if(!k)return A();x.sendFile(k.abs,U=>{U&&x.status(404).end()})}),g.use(E.middlewares);let T=W.join(e,"public");g.use(sn.static(T)),g.get(new RegExp(`^${Nt}(\\.[a-z0-9]+)?$`,"i"),async(O,x)=>{if(!i.favicon)return x.status(404).end();let A=W.resolve(e,i.favicon.replace(/^\//,""));x.sendFile(A,k=>{k&&x.status(404).end()})});let S=O=>(x,A)=>{let k=i.logo?.[O];if(!k)return A.status(404).end();A.sendFile(W.resolve(e,k.replace(/^\//,"")),U=>{U&&A.status(404).end()})};g.get(new RegExp(`^${Re}(\\.[a-z0-9]+)?$`,"i"),S("light")),g.get(new RegExp(`^${Ne}(\\.[a-z0-9]+)?$`,"i"),S("dark")),g.post("/@velu-api-proxy",sn.json({limit:"8mb"}),async(O,x)=>{let{method:A="GET",url:k,headers:U={},body:R}=O.body||{};if(typeof k!="string"||!/^https?:\/\//i.test(k))return x.status(400).json({error:"A valid http(s) target URL is required."});try{let N=await fetch(k,{method:A,headers:U,body:R!=null&&R!==""?R:void 0}),D=await N.text(),d=N.headers.get("content-type")||"",v={};N.headers.forEach((C,V)=>{v[V]=C});let j=D;if(/json/i.test(d))try{j=JSON.parse(D)}catch{}x.json({status:N.status,statusText:N.statusText,headers:v,body:j})}catch(N){x.json({error:`Request failed: ${N.message}`})}});let w=null,L=async()=>w||=await we(e);g.get(/\.md$/i,async(O,x,A)=>{try{let k=await L(),U=await on(e,Ur(decodeURIComponent(O.path)),ut(k));if(!U)return A();x.status(200).set({"Content-Type":U.contentType,...xe}).end(rn(U.body,U.kind))}catch{A()}}),g.get(be,async(O,x,A)=>{try{let k=await Fr(e,await L());x.status(200).set({"Content-Type":"text/plain; charset=utf-8",...xe}).end(k)}catch{A()}}),g.get(ct,async(O,x,A)=>{try{let k=await Ir(e,await L());x.status(200).set({"Content-Type":"text/plain; charset=utf-8",...xe}).end(k)}catch{A()}}),g.get("/rss.xml",async(O,x,A)=>{try{let k=await Mr(e,await L());if(!k)return A();x.status(200).set({"Content-Type":"application/rss+xml; charset=utf-8"}).end(k)}catch{A()}}),g.use("*",async(O,x,A)=>{let k=O.originalUrl,U=performance.now();if(/text\/markdown/i.test(O.headers.accept||""))try{let R=await L(),N=await on(e,bt(k),ut(R));if(N)return x.status(200).set({"Content-Type":N.contentType,...xe}).end(rn(N.body,N.kind))}catch{}if(a.length)return x.status(200).set({"Content-Type":"text/html"}).end(Kt(a,{title:"Fix velu.json to continue"}));try{let R=performance.now(),N=await Vr.readFile(Wr,"utf-8");N=await E.transformIndexHtml(k,N),n(`transformIndexHtml ${k}`,R);let D="/src/runtime/server-entry.jsx";R=performance.now();let{render:d}=await E.ssrLoadModule(D);n(`ssrLoadModule ${k} (1st req includes dep pre-bundle)`,R),R=performance.now();let v=await d(k);n(`render ${k}`,R),R=performance.now();let j=await Gr(E,D);n(`collectSsrCss ${k}`,R);let C=j?`<style data-velu-ssr>${j}</style>`:"",V=`<style data-velu-config>
|
|
223
|
+
${Zn(i)}
|
|
224
|
+
</style>`,ie=Xs.has(i.font.family)?"":Ys(i.font.family),q=Xn(i),se=q?`<link rel="icon"${q.type?` type="${q.type}"`:""} href="${q.url}" />`:"",dt=gr(s),to=[C,V,ie,se,dt].filter(Boolean).join(`
|
|
225
|
+
`),no=N.replace('<html lang="en">',`<html lang="en" data-current-path="${Jr(bt(k))}">`).replace("<!--app-title-->",Jr(i.name)).replace("<!--app-head-->",to).replace("<!--app-html-->",v);x.status(200).set({"Content-Type":"text/html",...xe}).end(no),n(`TOTAL ${k}`,U)}catch(R){E.ssrFixStacktrace(R);let N=Ve(R,{projectDir:c,knownComponents:ne});if(/failed to load url|does the file exist|cannot find module|ERR_MODULE_NOT_FOUND/i.test(String(R&&R.message))){try{E.moduleGraph.invalidateAll()}catch{}N.hint="The dev server cache is out of sync \u2014 this usually happens after files are added, removed, or moved. Reload the page; if it persists, stop velu dev, delete the .velu folder in your project, and restart."}Br(N,R),x.status(200).set({"Content-Type":"text/html"}).end(Kt([N]))}}),Ds.watch(e,{ignoreInitial:!0,ignored:/(^|[\\/])(node_modules|\.git|\.velu)([\\/]|$)/,awaitWriteFinish:{stabilityThreshold:100,pollInterval:20}}).on("all",async(O,x)=>{console.log(`[velu-cli] content ${O}: ${W.relative(e,x)}`);let A=W.basename(x)==="velu.json",k=x.endsWith(".mdx"),U=/\.(css|js)$/i.test(x),R=!1;if(U){let d=j=>j.scripts.some(C=>C.abs===x),v=d(s);s=ze(e),R=v||d(s)}let N=/\.(ya?ml|json)$/i.test(x),D=A||N||k&&(O==="add"||O==="unlink")||R;if((D||k||/\.(ya?ml|json)$/i.test(x))&&(w=null),A&&(i=await qr(e),a=l()),D)E.moduleGraph.invalidateAll();else if(k){let d=x.split(W.sep).join("/"),v=E.moduleGraph.getModulesByFile(d);if(v)for(let j of v)E.moduleGraph.invalidateModule(j)}E.ws.send({type:"full-reload"})});async function F(O){let x=new Set,A=12,k=0,U=[],R=()=>k<A?(k+=1,Promise.resolve()):new Promise(v=>U.push(v)).then(()=>{k+=1}),N=()=>{k-=1,U.shift()?.()},D=v=>/[\\/]\.velu[\\/]vite-cache[\\/]|[\\/]deps[\\/]/.test(v)||/[\\/]node_modules[\\/]/.test(v)&&!/velu-ui/.test(v);async function d(v){if(!(!v||x.has(v)||D(v))){x.add(v);try{await R();try{await E.transformRequest(v,{ssr:!1})}finally{N()}let j=await E.moduleGraph.getModuleByUrl(v,!1);j?.importedModules?.size&&await Promise.all([...j.importedModules].map(C=>d(C.url)))}catch{}}}return await d(O),x.size}b.listen(y,async()=>{let O=performance.now(),x=0;try{let{render:A}=await E.ssrLoadModule("/src/runtime/server-entry.jsx");await F("/src/runtime/client-entry.jsx"),typeof E.waitForRequestsIdle=="function"&&await E.waitForRequestsIdle();let[k]=await Promise.allSettled([F("/src/runtime/client-entry.jsx"),A("/"),E.transformIndexHtml("/",await Vr.readFile(Wr,"utf-8")),Gr(E,"/src/runtime/server-entry.jsx")]).then(U=>U.map(R=>R.status==="fulfilled"?R.value:0));x=k}catch(A){t&&console.log("[velu-profile] warmup error:",A?.message)}n(`cold-start warm-up (${x} client modules)`,O),o.ready(`http://localhost:${y}`)})}var Hs,Ks,Xs,Jr,pt,Wr,Qs,ea,Kr=_(()=>{Fe();Or();Ht();Tr();pe();We();Yt();Qt();zr();re();Dt();Hs=W.dirname(Bs(import.meta.url)),Ks=/\.(css|less|sass|scss|styl|stylus|pcss|postcss)(\?|$)/,Xs=new Set(["Google Sans Flex","Google Sans Code","Outfit"]),Jr=e=>String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");pt=W.resolve(Hs,".."),Wr=W.resolve(pt,"src","template.html"),Qs=[" _ __ __","| | / /__ / /_ __","| | / / _ \\/ / / / /","| |/ / __/ / /_/ /","|___/\\___/_/\\__,_/"],ea="const F=['\u280B','\u2819','\u2839','\u2838','\u283C','\u2834','\u2826','\u2827','\u2807','\u280F'],M=['Starting Velu','Setting up your preview','Preparing your docs','Warming things up','Almost ready'];let f=0,m=0;const t=Date.now();const C='\\x1b[38;2;220;20;60m',R='\\x1b[0m',D='\\x1b[2m';const d=()=>{const s=(Date.now()-t)/1000|0;process.stdout.write('\\x1b[2K\\r '+C+F[f]+R+' '+M[m]+'\\u2026 '+D+s+'s'+R);f=(f+1)%F.length;};d();setInterval(d,90);setInterval(()=>{if(m<M.length-1)m++;},4000);"});var Yr={};Se(Yr,{default:()=>sa,runValidate:()=>Xr});import ra from"node:fs";import oa from"node:path";function ia(e){try{let t=JSON.parse(ra.readFileSync(oa.join(e,"velu.json"),"utf-8"));if(!t.navigation||typeof t.navigation!="object")return[];let r=Y(t.navigation);return ae(r,e).pageEntries}catch{return[]}}async function Xr(e){let t=at(e),r=ia(e),n=await Cr(e,r),o=[...t,...n],i=!!process.stdout.isTTY;return console.log(it(o,{color:i})),o.some(s=>s.severity!=="warning"&&s.severity!=="info")?1:0}var sa,Zr=_(()=>{re();Me();Yt();Qt();pe();sa=Xr});import ft from"node:path";import B from"node:process";import{readFileSync as aa}from"node:fs";var[,,Qr,mt]=B.argv;function eo(){try{return JSON.parse(aa(new URL("../package.json",import.meta.url),"utf8")).version}catch{return"unknown"}}function la(){let e=B.argv.slice(3);for(let t=0;t<e.length;t++){let r=e[t];if(r==="--out"){t++;continue}if(!r.startsWith("-"))return r}}async function ca(){switch(Qr){case"--version":case"-v":case"version":{console.log(eo());break}case"init":{mt||(console.error("Usage: velu init <project-name>"),B.exit(1));let e=mt,t=ft.resolve(B.cwd(),e),{initProject:r}=await Promise.resolve().then(()=>(cn(),ln));await r(t,e);break}case"migrate":{let{runMigrate:e}=await Promise.resolve().then(()=>(Jn(),Vn));B.exitCode=await e(B.argv.slice(3),eo());break}case"dev":{let{maybeAutoUpdate:e}=await Promise.resolve().then(()=>(Rt(),_t));await e();let t=ft.resolve(B.cwd(),mt??"."),{startDevServer:r}=await Promise.resolve().then(()=>(Kr(),Hr));await r(t);break}case"update":{let{updateCommand:e}=await Promise.resolve().then(()=>(Rt(),_t));await e();break}case"validate":{let e=ft.resolve(B.cwd(),mt??"."),{runValidate:t}=await Promise.resolve().then(()=>(Zr(),Yr)),r=await t(e);B.exit(r);break}case"build":{let e=ft.resolve(B.cwd(),la()??"."),t=B.argv.indexOf("--out"),r=t>-1?B.argv[t+1]:void 0,n=new URL(["..","src","build","index.js"].join("/"),import.meta.url).href,o=a=>import(a),i;try{({runBuild:i}=await o(n))}catch{console.error("velu build is an internal command, not available in this distribution."),B.exit(1)}await i(e,{out:r});break}default:console.log("Usage:"),console.log(" velu init <project-name> scaffold a new docs project"),console.log(" velu migrate mintlify [dir] migrate a Mintlify project (see --help)"),console.log(" velu dev [dir] start the dev preview server"),console.log(" velu validate [dir] check velu.json + content for problems"),console.log(" velu update update velu to the latest version"),B.exit(Qr?1:0)}}ca().catch(e=>{console.error(B.env.VELU_DEBUG?e:`Error: ${e.message}`),B.exit(1)});
|
package/package.json
CHANGED
package/schema/velu.schema.json
CHANGED
|
@@ -320,6 +320,7 @@
|
|
|
320
320
|
"group": { "type": "string", "description": "Sidebar section heading." },
|
|
321
321
|
"icon": { "type": "string", "description": "lucide icon id." },
|
|
322
322
|
"expanded": { "type": "boolean", "description": "Start expanded." },
|
|
323
|
+
"public": { "type": "boolean", "description": "Allow unauthenticated access to this group. Per-page group restrictions still apply." },
|
|
323
324
|
"root": { "type": "string", "description": "Landing page path for the group." },
|
|
324
325
|
"openapi": { "$ref": "#/$defs/openapiRef" },
|
|
325
326
|
"api": { "$ref": "#/$defs/api" },
|
package/src/navigation.js
CHANGED
|
@@ -179,6 +179,7 @@ function normalizeGroup(g) {
|
|
|
179
179
|
if (g.root) pages.unshift({ kind: 'page', pagePath: g.root });
|
|
180
180
|
return {
|
|
181
181
|
kind: 'group',
|
|
182
|
+
...(g.public !== undefined ? { public: g.public } : {}),
|
|
182
183
|
label: g.group,
|
|
183
184
|
icon: g.icon,
|
|
184
185
|
expanded: Boolean(g.expanded),
|
package/src/runtime/App.jsx
CHANGED
|
@@ -89,6 +89,8 @@ function docsAuthActionUrl(action) {
|
|
|
89
89
|
// Resolve it to a relative base. Do not read `window` here: prerender runs
|
|
90
90
|
// this useMemo during renderToString in Node.
|
|
91
91
|
function resolvePublicApiBase(configuredBase) {
|
|
92
|
+
// Private readers must reach the router that verifies and forwards their session.
|
|
93
|
+
if (site.readerPrivate) return BASE_PATH;
|
|
92
94
|
if (!configuredBase) return null;
|
|
93
95
|
if (configuredBase !== '__VELU_SAME_ORIGIN__') return configuredBase;
|
|
94
96
|
return BASE_PATH;
|
|
@@ -801,7 +803,7 @@ function DocsPage() {
|
|
|
801
803
|
// URL path — e.g. essentials/markdown.mdx lives under the "Writing Content"
|
|
802
804
|
// group). Page rows show the path to the page; anchor rows include the page.
|
|
803
805
|
const searchDocs = React.useCallback(async (q) => {
|
|
804
|
-
const results = await pagefindSearch(q);
|
|
806
|
+
const results = site.readerRestricted ? await fetch((import.meta.env.BASE_URL || '/') + 'api/v1/public/search?q=' + encodeURIComponent(q), {credentials:'same-origin',cache:'no-store'}).then(r=>r.ok?r.json():[]) : await pagefindSearch(q);
|
|
805
807
|
if (!Array.isArray(results)) return results;
|
|
806
808
|
return results.map((r) => {
|
|
807
809
|
const res = resolve(r.href.split('#')[0], navigation, pages);
|
|
@@ -1196,7 +1198,11 @@ function DocsPage() {
|
|
|
1196
1198
|
headers: { 'content-type': 'application/json' },
|
|
1197
1199
|
body: '{}',
|
|
1198
1200
|
});
|
|
1199
|
-
if (response.ok)
|
|
1201
|
+
if (response.ok) {
|
|
1202
|
+
const result = response.status === 204 ? null : await response.json();
|
|
1203
|
+
if (result?.redirect) window.location.assign(result.redirect);
|
|
1204
|
+
else window.location.reload();
|
|
1205
|
+
}
|
|
1200
1206
|
}, []);
|
|
1201
1207
|
|
|
1202
1208
|
const navActions = [];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import './dev-warnings.js';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { hydrateRoot } from 'react-dom/client';
|
|
3
|
+
import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
4
4
|
import { BrowserRouter } from 'react-router-dom';
|
|
5
5
|
import 'velu-ui/styles.css';
|
|
6
|
-
import { site } from 'virtual:velu-site';
|
|
6
|
+
import { site, initializeReader } from 'virtual:velu-site';
|
|
7
7
|
import App from './App.jsx';
|
|
8
8
|
|
|
9
9
|
// Subpath hosting: Vite sets BASE_URL from the build's `base` (e.g. "/docs/").
|
|
@@ -31,7 +31,9 @@ function CustomScripts() {
|
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
function mount() {
|
|
35
|
+
const renderRoot = site.guarded ? (_, children) => createRoot(document.getElementById('root')).render(children) : hydrateRoot;
|
|
36
|
+
renderRoot(
|
|
35
37
|
document.getElementById('root'),
|
|
36
38
|
<BrowserRouter basename={basename}>
|
|
37
39
|
<App />
|
|
@@ -39,6 +41,10 @@ hydrateRoot(
|
|
|
39
41
|
</BrowserRouter>
|
|
40
42
|
);
|
|
41
43
|
|
|
44
|
+
}
|
|
45
|
+
if (site.guarded) initializeReader().then(mount).catch(()=>{ document.getElementById("root").textContent="Unable to load documentation. Reload to sign in again."; });
|
|
46
|
+
else mount();
|
|
47
|
+
|
|
42
48
|
// Dev only: the SSR-inlined critical CSS (<style data-velu-ssr>) exists just
|
|
43
49
|
// to avoid FOUC on first paint. By now Vite has injected its own HMR-managed
|
|
44
50
|
// stylesheet from the `velu-ui/styles.css` import above, so drop the stale
|